(
executionId: string,
action: "accept" | "decline" | "cancel",
content: Record<string, unknown> | undefined,
extra: McpRequestJoinKeys,
)
| 1325 | ); |
| 1326 | |
| 1327 | const resumeExecution = ( |
| 1328 | executionId: string, |
| 1329 | action: "accept" | "decline" | "cancel", |
| 1330 | content: Record<string, unknown> | undefined, |
| 1331 | extra: McpRequestJoinKeys, |
| 1332 | ): Effect.Effect<McpToolResult, E> => |
| 1333 | Effect.gen(function* () { |
| 1334 | yield* startMarker("mcp.host.tool.resume.start", { |
| 1335 | "mcp.tool.name": "resume", |
| 1336 | "mcp.execute.execution_id": executionId, |
| 1337 | }); |
| 1338 | debugLog("resume.call", { |
| 1339 | executionId, |
| 1340 | action, |
| 1341 | hasContent: content !== undefined, |
| 1342 | clientCapabilities: server.server.getClientCapabilities() ?? null, |
| 1343 | }); |
| 1344 | const outcome = yield* resumeWithLifecycle(executionId, { action, content }); |
| 1345 | if (!outcome) { |
| 1346 | debugLog("resume.missing_execution", { executionId }); |
| 1347 | if (yield* localExecutionAlreadySettled(executionId)) { |
| 1348 | return alreadySettledResult(executionId); |
| 1349 | } |
| 1350 | const fallback = yield* resumeFallback(executionId, { action, content }); |
| 1351 | if (fallback) { |
| 1352 | debugLog("resume.fallback_result", { executionId, status: fallback.status }); |
| 1353 | return fallbackOutcomeResult(executionId, fallback); |
| 1354 | } |
| 1355 | return missingExecutionResult(executionId); |
| 1356 | } |
| 1357 | debugLog("resume.result", { |
| 1358 | executionId, |
| 1359 | status: outcome.status, |
| 1360 | nextExecutionId: outcome.status === "paused" ? outcome.execution.id : undefined, |
| 1361 | interactionKind: |
| 1362 | outcome.status === "paused" |
| 1363 | ? pausedInteractionKind(outcome.execution.elicitationContext.request) |
| 1364 | : undefined, |
| 1365 | }); |
| 1366 | if (outcome.status === "paused") { |
| 1367 | return yield* formatPausedModelResult(outcome.execution, "resume"); |
| 1368 | } |
| 1369 | return toMcpResult(outcome.result); |
| 1370 | }).pipe( |
| 1371 | Effect.withSpan("mcp.host.tool.resume", { |
| 1372 | attributes: { |
| 1373 | "mcp.tool.name": "resume", |
| 1374 | "mcp.execute.resume.action": action, |
| 1375 | "mcp.execute.execution_id": executionId, |
| 1376 | }, |
| 1377 | }), |
| 1378 | Effect.annotateSpans(joinKeyAttributes(extra)), |
| 1379 | ); |
| 1380 | |
| 1381 | const requireUserResumeApproval = (executionId: string): Effect.Effect<McpToolResult> => |
| 1382 | Effect.sync(() => { |
no test coverage detected