mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 18:57:17 +03:00
fix(plugin): forward Promise tool cancellation (#50190)
This commit is contained in:
committed by
GitHub
Unverified
parent
6238af397e
commit
e3a3fa7108
@@ -250,12 +250,13 @@ export function fromPromise(plugin: Plugin) {
|
||||
|
||||
const promiseExecutor =
|
||||
(execute: Tool.Info["execute"]): Info["execute"] =>
|
||||
(input, context) =>
|
||||
run(
|
||||
(input, tool) =>
|
||||
Effect.runPromiseWith(context)(
|
||||
execute(input, {
|
||||
...context,
|
||||
progress: (update) => Effect.promise(() => context.progress(update)),
|
||||
...tool,
|
||||
progress: (update) => Effect.promise(() => tool.progress(update)),
|
||||
}),
|
||||
{ signal: tool.signal },
|
||||
)
|
||||
|
||||
const adaptApiMethod = <PromiseMethod>(
|
||||
@@ -612,9 +613,10 @@ function attempt<A>(evaluate: (signal: AbortSignal) => PromiseLike<A>) {
|
||||
type RuntimeSchema = Schema.Codec<unknown, unknown>
|
||||
|
||||
const executePromiseTool = (tool: Info, input: any, context: Tool.Context) =>
|
||||
Effect.promise(() =>
|
||||
Effect.promise((signal) =>
|
||||
tool.execute(input, {
|
||||
...context,
|
||||
progress: (update) => Effect.runPromise(context.progress(update)),
|
||||
signal,
|
||||
progress: (update) => Effect.runPromise(context.progress(update), { signal }),
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -9,6 +9,7 @@ import type { Types } from "effect"
|
||||
import type { Hooks, Transform } from "./registration.js"
|
||||
|
||||
export interface ToolContext extends Omit<Tool.Context, "progress"> {
|
||||
readonly signal: AbortSignal
|
||||
readonly progress: (update: Tool.Metadata) => Promise<void>
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user