fix(plugin): ask in tools from plugins returns promise instead of effect (#28217)

This commit is contained in:
James Long 2026-05-18 14:57:29 -04:00 committed by GitHub
parent a88b436eec
commit 12ae22378f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -40,6 +40,7 @@ import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
import { Ripgrep } from "../file/ripgrep"
import { Format } from "../format"
import { InstanceState } from "@/effect/instance-state"
import { EffectBridge } from "@/effect/bridge"
import { Question } from "../question"
import { Todo } from "../session/todo"
import { LSP } from "@/lsp/lsp"
@ -158,9 +159,12 @@ export const layer: Layer.Layer<
description: def.description,
execute: (args, toolCtx) =>
Effect.gen(function* () {
// Bridge the host's Effect-based `ask` into a Promise-returning
// function for the plugin to make sure context persists
const bridge = yield* EffectBridge.make()
const pluginCtx: PluginToolContext = {
...toolCtx,
ask: (req) => toolCtx.ask(req),
ask: (req) => bridge.promise(toolCtx.ask(req)),
directory: ctx.directory,
worktree: ctx.worktree,
}

View file

@ -1,5 +1,4 @@
import { z } from "zod"
import { Effect } from "effect"
export type ToolContext = {
sessionID: string
@ -17,7 +16,7 @@ export type ToolContext = {
worktree: string
abort: AbortSignal
metadata(input: { title?: string; metadata?: { [key: string]: any } }): void
ask(input: AskInput): Effect.Effect<void>
ask(input: AskInput): Promise<void>
}
type AskInput = {