mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-19 16:40:48 +00:00
fix(plugin): ask in tools from plugins returns promise instead of effect (#28217)
This commit is contained in:
parent
a88b436eec
commit
12ae22378f
2 changed files with 6 additions and 3 deletions
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue