File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -135,14 +135,17 @@ export const layer: Layer.Layer<
135135 worktree : ctx . worktree ,
136136 }
137137 const result = yield * Effect . promise ( ( ) => def . execute ( args as any , pluginCtx ) )
138+ const output = typeof result === "string" ? result : result . output
139+ const metadata = typeof result === "string" ? { } : ( result . metadata ?? { } )
138140 const info = yield * agent . get ( toolCtx . agent )
139- const out = yield * truncate . output ( result , { } , info )
141+ const out = yield * truncate . output ( output , { } , info )
140142 return {
141143 title : "" ,
142- output : out . truncated ? out . content : result ,
144+ output : out . truncated ? out . content : output ,
143145 metadata : {
146+ ...metadata ,
144147 truncated : out . truncated ,
145- outputPath : out . truncated ? out . outputPath : undefined ,
148+ ... ( out . truncated && { outputPath : out . outputPath } ) ,
146149 } ,
147150 }
148151 } ) ,
Original file line number Diff line number Diff line change @@ -27,10 +27,12 @@ type AskInput = {
2727 metadata : { [ key : string ] : any }
2828}
2929
30+ export type ToolResult = string | { output : string ; metadata ?: { [ key : string ] : any } }
31+
3032export function tool < Args extends z . ZodRawShape > ( input : {
3133 description : string
3234 args : Args
33- execute ( args : z . infer < z . ZodObject < Args > > , context : ToolContext ) : Promise < string >
35+ execute ( args : z . infer < z . ZodObject < Args > > , context : ToolContext ) : Promise < ToolResult >
3436} ) {
3537 return input
3638}
You can’t perform that action at this time.
0 commit comments