(
code: string,
extra: McpRequestJoinKeys,
)
| 1202 | .pipe(Effect.map(toMcpResult)); |
| 1203 | |
| 1204 | const executeCode = ( |
| 1205 | code: string, |
| 1206 | extra: McpRequestJoinKeys, |
| 1207 | ): Effect.Effect<McpToolResult, E> => |
| 1208 | Effect.gen(function* () { |
| 1209 | yield* startMarker("mcp.host.tool.execute.start", { |
| 1210 | "mcp.tool.name": "execute", |
| 1211 | "mcp.execute.code_length": code.length, |
| 1212 | }); |
| 1213 | debugLog("execute.call", { |
| 1214 | elicitationMode: elicitationMode.mode, |
| 1215 | elicitationSupport: getElicitationSupport(server), |
| 1216 | clientCapabilities: server.server.getClientCapabilities() ?? null, |
| 1217 | codeLength: code.length, |
| 1218 | }); |
| 1219 | if (elicitationMode.mode === "native") { |
| 1220 | return yield* executeWithNativeElicitation(code, extra); |
| 1221 | } |
| 1222 | const outcome = yield* engine.executeWithPause(code); |
| 1223 | debugLog("execute.paused_flow_result", { |
| 1224 | status: outcome.status, |
| 1225 | executionId: outcome.status === "paused" ? outcome.execution.id : undefined, |
| 1226 | interactionKind: |
| 1227 | outcome.status === "paused" |
| 1228 | ? pausedInteractionKind(outcome.execution.elicitationContext.request) |
| 1229 | : undefined, |
| 1230 | }); |
| 1231 | if (outcome.status === "paused") { |
| 1232 | const deadline = pauseDeadline(); |
| 1233 | yield* Effect.annotateCurrentSpan({ |
| 1234 | "mcp.execute.paused": true, |
| 1235 | "mcp.execute.paused_execution_id": outcome.execution.id, |
| 1236 | "mcp.execute.pause_source": "execute", |
| 1237 | }); |
| 1238 | yield* onExecutionPaused(outcome.execution.id, deadline); |
| 1239 | return elicitationMode.mode === "browser" |
| 1240 | ? yield* requireUserResumeApproval(outcome.execution.id) |
| 1241 | : toMcpPausedResult(formatPausedExecution(outcome.execution, { deadline })); |
| 1242 | } |
| 1243 | return toMcpResult(outcome.result); |
| 1244 | }).pipe( |
| 1245 | Effect.withSpan("mcp.host.tool.execute", { |
| 1246 | attributes: { |
| 1247 | "mcp.tool.name": "execute", |
| 1248 | "mcp.execute.code_length": code.length, |
| 1249 | }, |
| 1250 | }), |
| 1251 | Effect.annotateSpans(joinKeyAttributes(extra)), |
| 1252 | ); |
| 1253 | |
| 1254 | /** What the caller could bind an unresolved role to. Best effort: the |
| 1255 | * connections port is optional, and a failure to enumerate must not |
no test coverage detected