refactor(tool): Tool.Context.metadata returns Effect (#21972)

This commit is contained in:
Kit Langton
2026-04-10 23:12:04 -04:00
committed by GitHub
parent 9581bf0670
commit 3dd09147c2
17 changed files with 63 additions and 67 deletions

View File

@@ -385,7 +385,7 @@ export const BashTool = Tool.define(
let expired = false
let aborted = false
ctx.metadata({
yield* ctx.metadata({
metadata: {
output: "",
description: input.description,
@@ -397,16 +397,15 @@ export const BashTool = Tool.define(
const handle = yield* spawner.spawn(cmd(input.shell, input.name, input.command, input.cwd, input.env))
yield* Effect.forkScoped(
Stream.runForEach(Stream.decodeText(handle.all), (chunk) =>
Effect.sync(() => {
output += chunk
ctx.metadata({
metadata: {
output: preview(output),
description: input.description,
},
})
}),
Stream.runForEach(Stream.decodeText(handle.all), (chunk) => {
output += chunk
return ctx.metadata({
metadata: {
output: preview(output),
description: input.description,
},
})
},
),
)

View File

@@ -158,7 +158,7 @@ export const EditTool = Tool.define(
if (change.removed) filediff.deletions += change.count || 0
}
ctx.metadata({
yield* ctx.metadata({
metadata: {
diff,
filediff,

View File

@@ -109,7 +109,7 @@ export const TaskTool = Tool.define(
providerID: msg.info.providerID,
}
ctx.metadata({
yield* ctx.metadata({
title: params.description,
metadata: {
sessionId: nextSession.id,

View File

@@ -22,7 +22,7 @@ export namespace Tool {
callID?: string
extra?: { [key: string]: any }
messages: MessageV2.WithParts[]
metadata(input: { title?: string; metadata?: M }): void
metadata(input: { title?: string; metadata?: M }): Effect.Effect<void>
ask(input: Omit<Permission.Request, "id" | "sessionID" | "tool">): Effect.Effect<void>
}