(
code: string,
extra: McpRequestJoinKeys,
)
| 1216 | .pipe(Effect.map(toMcpResult)); |
| 1217 | |
| 1218 | const executeCode = ( |
| 1219 | code: string, |
| 1220 | extra: McpRequestJoinKeys, |
| 1221 | ): Effect.Effect<McpToolResult, E> => |
| 1222 | Effect.gen(function* () { |
| 1223 | yield* startMarker("mcp.host.tool.execute.start", { |
| 1224 | "mcp.tool.name": "execute", |
| 1225 | "mcp.execute.code_length": code.length, |
| 1226 | }); |
| 1227 | debugLog("execute.call", { |
| 1228 | elicitationMode: elicitationMode.mode, |
| 1229 | elicitationSupport: getElicitationSupport(server), |
| 1230 | clientCapabilities: server.server.getClientCapabilities() ?? null, |
| 1231 | codeLength: code.length, |
| 1232 | }); |
| 1233 | if (elicitationMode.mode === "native") { |
| 1234 | return yield* executeWithNativeElicitation(code, extra); |
| 1235 | } |
| 1236 | const outcome = yield* engine.executeWithPause(code); |
| 1237 | debugLog("execute.paused_flow_result", { |
| 1238 | status: outcome.status, |
| 1239 | executionId: outcome.status === "paused" ? outcome.execution.id : undefined, |
| 1240 | interactionKind: |
| 1241 | outcome.status === "paused" |
| 1242 | ? pausedInteractionKind(outcome.execution.elicitationContext.request) |
| 1243 | : undefined, |
| 1244 | }); |
| 1245 | if (outcome.status === "paused") { |
| 1246 | const deadline = pauseDeadline(); |
| 1247 | yield* Effect.annotateCurrentSpan({ |
| 1248 | "mcp.execute.paused": true, |
| 1249 | "mcp.execute.paused_execution_id": outcome.execution.id, |
| 1250 | "mcp.execute.pause_source": "execute", |
| 1251 | }); |
| 1252 | yield* onExecutionPaused(outcome.execution.id, deadline); |
| 1253 | return elicitationMode.mode === "browser" |
| 1254 | ? yield* requireUserResumeApproval(outcome.execution.id) |
| 1255 | : toMcpPausedResult(formatPausedExecution(outcome.execution, { deadline })); |
| 1256 | } |
| 1257 | return toMcpResult(outcome.result); |
| 1258 | }).pipe( |
| 1259 | Effect.withSpan("mcp.host.tool.execute", { |
| 1260 | attributes: { |
| 1261 | "mcp.tool.name": "execute", |
| 1262 | "mcp.execute.code_length": code.length, |
| 1263 | }, |
| 1264 | }), |
| 1265 | Effect.annotateSpans(joinKeyAttributes(extra)), |
| 1266 | ); |
| 1267 | |
| 1268 | // `search_<integration>` is `execute` running `tools.search` with the |
| 1269 | // namespace pinned. The code is built HERE, from the slug the tool was |
no test coverage detected