| 543 | } |
| 544 | |
| 545 | export async function clearPythonReplContext( |
| 546 | toolUseContext: ToolUseContext, |
| 547 | toolName: string, |
| 548 | ): Promise<void> { |
| 549 | const existing = toolUseContext.getAppState().pythonReplContexts?.get(toolName) |
| 550 | await existing?.reset() |
| 551 | toolUseContext.setAppState(prev => { |
| 552 | if (!prev.pythonReplContexts?.has(toolName)) { |
| 553 | return prev |
| 554 | } |
| 555 | const contexts = new Map(prev.pythonReplContexts) |
| 556 | contexts.delete(toolName) |
| 557 | return { |
| 558 | ...prev, |
| 559 | pythonReplContexts: contexts, |
| 560 | } |
| 561 | }) |
| 562 | } |
| 563 | |
| 564 | export function createPythonReplTool(config: PythonReplToolConfig) { |
| 565 | const inputSchema = buildInputSchema(config.inputSchemaDescription) |