(
executionId: string,
action: "accept" | "decline" | "cancel",
content: Record<string, unknown> | undefined,
extra: McpRequestJoinKeys,
)
| 1408 | ); |
| 1409 | |
| 1410 | const resumeExecution = ( |
| 1411 | executionId: string, |
| 1412 | action: "accept" | "decline" | "cancel", |
| 1413 | content: Record<string, unknown> | undefined, |
| 1414 | extra: McpRequestJoinKeys, |
| 1415 | ): Effect.Effect<McpToolResult, E> => |
| 1416 | Effect.gen(function* () { |
| 1417 | yield* startMarker("mcp.host.tool.resume.start", { |
| 1418 | "mcp.tool.name": "resume", |
| 1419 | "mcp.execute.execution_id": executionId, |
| 1420 | }); |
| 1421 | debugLog("resume.call", { |
| 1422 | executionId, |
| 1423 | action, |
| 1424 | hasContent: content !== undefined, |
| 1425 | clientCapabilities: server.server.getClientCapabilities() ?? null, |
| 1426 | }); |
| 1427 | const outcome = yield* resumeWithLifecycle(executionId, { action, content }); |
| 1428 | if (!outcome) { |
| 1429 | debugLog("resume.missing_execution", { executionId }); |
| 1430 | if (yield* localExecutionAlreadySettled(executionId)) { |
| 1431 | return alreadySettledResult(executionId); |
| 1432 | } |
| 1433 | const fallback = yield* resumeFallback(executionId, { action, content }); |
| 1434 | if (fallback) { |
| 1435 | debugLog("resume.fallback_result", { executionId, status: fallback.status }); |
| 1436 | return fallbackOutcomeResult(executionId, fallback); |
| 1437 | } |
| 1438 | return missingExecutionResult(executionId); |
| 1439 | } |
| 1440 | debugLog("resume.result", { |
| 1441 | executionId, |
| 1442 | status: outcome.status, |
| 1443 | nextExecutionId: outcome.status === "paused" ? outcome.execution.id : undefined, |
| 1444 | interactionKind: |
| 1445 | outcome.status === "paused" |
| 1446 | ? pausedInteractionKind(outcome.execution.elicitationContext.request) |
| 1447 | : undefined, |
| 1448 | }); |
| 1449 | if (outcome.status === "paused") { |
| 1450 | return yield* formatPausedModelResult(outcome.execution, "resume"); |
| 1451 | } |
| 1452 | return toMcpResult(outcome.result); |
| 1453 | }).pipe( |
| 1454 | Effect.withSpan("mcp.host.tool.resume", { |
| 1455 | attributes: { |
| 1456 | "mcp.tool.name": "resume", |
| 1457 | "mcp.execute.resume.action": action, |
| 1458 | "mcp.execute.execution_id": executionId, |
| 1459 | }, |
| 1460 | }), |
| 1461 | Effect.annotateSpans(joinKeyAttributes(extra)), |
| 1462 | ); |
| 1463 | |
| 1464 | const requireUserResumeApproval = (executionId: string): Effect.Effect<McpToolResult> => |
| 1465 | Effect.sync(() => { |
no test coverage detected