(
code: string,
extra: McpRequestJoinKeys,
)
| 1679 | .pipe(Effect.map(toMcpResult)); |
| 1680 | |
| 1681 | const executeCode = ( |
| 1682 | code: string, |
| 1683 | extra: McpRequestJoinKeys, |
| 1684 | ): Effect.Effect<McpToolResult, E> => |
| 1685 | Effect.gen(function* () { |
| 1686 | yield* startMarker("mcp.host.tool.execute.start", { |
| 1687 | "mcp.tool.name": "execute", |
| 1688 | "mcp.execute.code_length": code.length, |
| 1689 | }); |
| 1690 | debugLog("execute.call", { |
| 1691 | elicitationMode: elicitationMode.mode, |
| 1692 | elicitationSupport: getElicitationSupport(server), |
| 1693 | clientCapabilities: server.server.getClientCapabilities() ?? null, |
| 1694 | codeLength: code.length, |
| 1695 | }); |
| 1696 | if (elicitationMode.mode === "native") { |
| 1697 | return yield* executeWithNativeElicitation(code, extra); |
| 1698 | } |
| 1699 | const outcome = yield* engine.executeWithPause(code); |
| 1700 | debugLog("execute.paused_flow_result", { |
| 1701 | status: outcome.status, |
| 1702 | executionId: outcome.status === "paused" ? outcome.execution.id : undefined, |
| 1703 | interactionKind: |
| 1704 | outcome.status === "paused" |
| 1705 | ? pausedInteractionKind(outcome.execution.elicitationContext.request) |
| 1706 | : undefined, |
| 1707 | }); |
| 1708 | if (outcome.status === "paused") { |
| 1709 | const deadline = pauseDeadline(); |
| 1710 | yield* Effect.annotateCurrentSpan({ |
| 1711 | "mcp.execute.paused": true, |
| 1712 | "mcp.execute.paused_execution_id": outcome.execution.id, |
| 1713 | "mcp.execute.pause_source": "execute", |
| 1714 | }); |
| 1715 | yield* onExecutionPaused(outcome.execution.id, deadline); |
| 1716 | return elicitationMode.mode === "browser" |
| 1717 | ? yield* requireUserResumeApproval(outcome.execution.id) |
| 1718 | : toMcpPausedResult(formatPausedExecution(outcome.execution, { deadline })); |
| 1719 | } |
| 1720 | return toMcpResult(outcome.result); |
| 1721 | }).pipe( |
| 1722 | Effect.withSpan("mcp.host.tool.execute", { |
| 1723 | attributes: { |
| 1724 | "mcp.tool.name": "execute", |
| 1725 | "mcp.execute.code_length": code.length, |
| 1726 | }, |
| 1727 | }), |
| 1728 | Effect.annotateSpans(joinKeyAttributes(extra)), |
| 1729 | ); |
| 1730 | |
| 1731 | // `search_<integration>` is `execute` running `tools.search` with the |
| 1732 | // namespace pinned. The code is built HERE, from the slug the tool was |
no test coverage detected