Standardized output format for blocks/tools. Updated executor so we can now resolve sub-json values for tagged inputs. Updated serializer to match new block output format.

This commit is contained in:
Waleed Latif
2025-01-30 13:50:35 -08:00
parent 15b42c7d19
commit 3850c112ca
31 changed files with 798 additions and 775 deletions

View File

@@ -6,7 +6,10 @@ interface CodeExecutionInput {
}
interface CodeExecutionOutput extends ToolResponse {
output: Record<string, any>
output: {
result: any
stdout: string
}
}
export const functionExecuteTool: ToolConfig<CodeExecutionInput, CodeExecutionOutput> = {
@@ -68,13 +71,21 @@ export const functionExecuteTool: ToolConfig<CodeExecutionInput, CodeExecutionOu
try {
// Try parsing the output as JSON
const parsed = JSON.parse(stdout)
return { output: parsed }
} catch {
// If not JSON, wrap it in a JSON object
return {
output: {
result: stdout
}
success: true,
output: {
result: parsed,
stdout
}
}
} catch {
// If not JSON, return as string
return {
success: true,
output: {
result: stdout,
stdout
}
}
}
},