(
input,
toolUseContext,
canUseTool: CanUseToolFn,
parentMessage: AssistantMessage,
onProgress?: ToolCallProgress<ReplToolCallProgress>,
)
| 480 | } |
| 481 | }, |
| 482 | async call( |
| 483 | input, |
| 484 | toolUseContext, |
| 485 | canUseTool: CanUseToolFn, |
| 486 | parentMessage: AssistantMessage, |
| 487 | onProgress?: ToolCallProgress<ReplToolCallProgress>, |
| 488 | ) { |
| 489 | const replContext = getOrCreateJavascriptReplContext( |
| 490 | toolUseContext, |
| 491 | config.toolName, |
| 492 | ) |
| 493 | replContext.console.clear() |
| 494 | ensureRuntimeHelpers(replContext) |
| 495 | |
| 496 | const virtualMessages: Message[] = [] |
| 497 | const contextModifiers: Array< |
| 498 | (context: ToolUseContext) => ToolUseContext |
| 499 | > = [] |
| 500 | const toolCalls: ReplToolCallSummary[] = [] |
| 501 | const availableTools = augmentToolsForJavascriptRepl(toolUseContext) |
| 502 | const outerToolUseID = toolUseContext.toolUseId ?? randomUUID() |
| 503 | |
| 504 | const globals = replContext.vmContext as Record<string, unknown> |
| 505 | |
| 506 | replContext.registeredTools.clear() |
| 507 | for (const tool of availableTools) { |
| 508 | if (hiddenToolNames.has(tool.name)) { |
| 509 | continue |
| 510 | } |
| 511 | const wrapper = createToolWrapper(tool.name, { |
| 512 | toolUseContext, |
| 513 | availableTools, |
| 514 | canUseTool, |
| 515 | outerToolUseID, |
| 516 | onProgress, |
| 517 | pushMessage: message => { |
| 518 | virtualMessages.push(message) |
| 519 | }, |
| 520 | pushContextModifier: modifyContext => { |
| 521 | contextModifiers.push(modifyContext) |
| 522 | }, |
| 523 | pushCallSummary: summary => { |
| 524 | toolCalls.push(summary) |
| 525 | }, |
| 526 | }) |
| 527 | |
| 528 | const schemaCandidate = |
| 529 | tool.inputJSONSchema ?? |
| 530 | ((tool.inputSchema as { toJSON?: () => unknown }).toJSON?.() ?? {}) |
| 531 | |
| 532 | replContext.registeredTools.set(tool.name, { |
| 533 | name: tool.name, |
| 534 | description: tool.userFacingName(undefined), |
| 535 | schema: ensureRecord(schemaCandidate), |
| 536 | handler: args => wrapper(ensureRecord(args)), |
| 537 | }) |
| 538 | } |
| 539 |
nothing calls this directly
no test coverage detected