(tool: { execute: (...args: any[]) => any })
| 1972 | // Abort signal propagation tests for inline tool execution |
| 1973 | |
| 1974 | function hangUntilAborted(tool: { execute: (...args: any[]) => any }) { |
| 1975 | return Effect.gen(function* () { |
| 1976 | const ready = yield* Deferred.make<void>() |
| 1977 | const aborted = yield* Deferred.make<void>() |
| 1978 | const original = tool.execute |
| 1979 | tool.execute = (_args: any, ctx: any) => { |
| 1980 | ctx.abort.addEventListener("abort", () => succeedVoid(aborted), { once: true }) |
| 1981 | if (ctx.abort.aborted) succeedVoid(aborted) |
| 1982 | succeedVoid(ready) |
| 1983 | return Effect.callback<never>(() => Effect.sync(() => succeedVoid(aborted))) |
| 1984 | } |
| 1985 | const restore = Effect.addFinalizer(() => Effect.sync(() => void (tool.execute = original))) |
| 1986 | return { ready, aborted, restore } |
| 1987 | }) |
| 1988 | } |
| 1989 | |
| 1990 | noLLMServer.instance( |
| 1991 | "interrupt propagates abort signal to read tool via file part (text/plain)", |
no test coverage detected