(code: string, extra: RequestContext)
| 1184 | }); |
| 1185 | |
| 1186 | const executeCode = (code: string, extra: RequestContext): Effect.Effect<McpHandlerResult, E> => |
| 1187 | Effect.gen(function* () { |
| 1188 | yield* startMarker("mcp.host.tool.execute.start", { |
| 1189 | "mcp.tool.name": "execute", |
| 1190 | "mcp.execute.code_length": code.length, |
| 1191 | }); |
| 1192 | debugLog("execute.call", { |
| 1193 | elicitationMode: elicitationMode.mode, |
| 1194 | elicitationSupport: assembly.getElicitationSupport(), |
| 1195 | clientCapabilities: assembly.getClientCapabilities(), |
| 1196 | codeLength: code.length, |
| 1197 | }); |
| 1198 | if (elicitationMode.mode === "native") { |
| 1199 | return yield* executeWithNativeElicitation(code, extra, "execute"); |
| 1200 | } |
| 1201 | const outcome = yield* engine.executeWithPause(code); |
| 1202 | debugLog("execute.paused_flow_result", { |
| 1203 | status: outcome.status, |
| 1204 | executionId: outcome.status === "paused" ? outcome.execution.id : undefined, |
| 1205 | interactionKind: |
| 1206 | outcome.status === "paused" |
| 1207 | ? pausedInteractionKind(outcome.execution.elicitationContext.request) |
| 1208 | : undefined, |
| 1209 | }); |
| 1210 | if (outcome.status === "paused") { |
| 1211 | const deadline = pauseDeadline(); |
| 1212 | yield* Effect.annotateCurrentSpan({ |
| 1213 | "mcp.execute.paused": true, |
| 1214 | "mcp.execute.paused_execution_id": outcome.execution.id, |
| 1215 | "mcp.execute.pause_source": "execute", |
| 1216 | }); |
| 1217 | yield* onExecutionPaused(outcome.execution.id, deadline); |
| 1218 | return elicitationMode.mode === "browser" |
| 1219 | ? yield* requireUserResumeApproval(outcome.execution.id) |
| 1220 | : toMcpPausedResult(formatPausedExecution(outcome.execution, { deadline })); |
| 1221 | } |
| 1222 | return toMcpResult(outcome.result); |
| 1223 | }).pipe( |
| 1224 | Effect.withSpan("mcp.host.tool.execute", { |
| 1225 | attributes: { |
| 1226 | "mcp.tool.name": "execute", |
| 1227 | "mcp.execute.code_length": code.length, |
| 1228 | }, |
| 1229 | }), |
| 1230 | Effect.annotateSpans(requestSpanAttributes(extra)), |
| 1231 | ); |
| 1232 | |
| 1233 | /** What the caller could bind an unresolved role to. Best effort: the |
| 1234 | * connections port is optional, and a failure to enumerate must not |
no test coverage detected