refactor(tool): Tool.Context.metadata returns Effect (#21972)
This commit is contained in:
@@ -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,
|
||||
},
|
||||
})
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user