(code: string)
| 638 | ).pipe(Effect.withSpan("mcp.host.create_server")); |
| 639 | |
| 640 | const executeCode = (code: string): Effect.Effect<McpToolResult, E> => |
| 641 | Effect.gen(function* () { |
| 642 | debugLog("execute.call", { |
| 643 | elicitationMode: elicitationMode.mode, |
| 644 | elicitationSupport: getElicitationSupport(server), |
| 645 | clientCapabilities: server.server.getClientCapabilities() ?? null, |
| 646 | codeLength: code.length, |
| 647 | }); |
| 648 | if (elicitationMode.mode === "native") { |
| 649 | const result = yield* engine.execute(code, { |
| 650 | onElicitation: makeMcpElicitationHandler(server, debugLog), |
| 651 | }); |
| 652 | return toMcpResult(result); |
| 653 | } |
| 654 | const outcome = yield* engine.executeWithPause(code); |
| 655 | debugLog("execute.paused_flow_result", { |
| 656 | status: outcome.status, |
| 657 | executionId: outcome.status === "paused" ? outcome.execution.id : undefined, |
| 658 | interactionKind: |
| 659 | outcome.status === "paused" |
| 660 | ? pausedInteractionKind(outcome.execution.elicitationContext.request) |
| 661 | : undefined, |
| 662 | }); |
| 663 | if (outcome.status === "paused") { |
| 664 | yield* Effect.annotateCurrentSpan({ |
| 665 | "mcp.execute.paused": true, |
| 666 | "mcp.execute.paused_execution_id": outcome.execution.id, |
| 667 | "mcp.execute.pause_source": "execute", |
| 668 | }); |
| 669 | yield* onExecutionPaused(outcome.execution.id); |
| 670 | } |
| 671 | return outcome.status === "completed" |
| 672 | ? toMcpResult(outcome.result) |
| 673 | : elicitationMode.mode === "browser" |
| 674 | ? yield* requireUserResumeApproval(outcome.execution.id) |
| 675 | : toMcpPausedResult(formatPausedExecution(outcome.execution)); |
| 676 | }).pipe( |
| 677 | Effect.withSpan("mcp.host.tool.execute", { |
| 678 | attributes: { |
| 679 | "mcp.tool.name": "execute", |
| 680 | "mcp.execute.code_length": code.length, |
| 681 | }, |
| 682 | }), |
| 683 | ); |
| 684 | |
| 685 | const resumeExecution = ( |
| 686 | executionId: string, |
no test coverage detected