(
executionId: string,
action: "accept" | "decline" | "cancel",
content: Record<string, unknown> | undefined,
)
| 810 | ); |
| 811 | |
| 812 | const resumeExecution = ( |
| 813 | executionId: string, |
| 814 | action: "accept" | "decline" | "cancel", |
| 815 | content: Record<string, unknown> | undefined, |
| 816 | ): Effect.Effect<McpToolResult, E> => |
| 817 | Effect.gen(function* () { |
| 818 | debugLog("resume.call", { |
| 819 | executionId, |
| 820 | action, |
| 821 | hasContent: content !== undefined, |
| 822 | clientCapabilities: server.server.getClientCapabilities() ?? null, |
| 823 | }); |
| 824 | const outcome = yield* resumeWithLifecycle(executionId, { action, content }); |
| 825 | if (!outcome) { |
| 826 | debugLog("resume.missing_execution", { executionId }); |
| 827 | if (yield* localExecutionAlreadySettled(executionId)) { |
| 828 | return alreadySettledResult(executionId); |
| 829 | } |
| 830 | const fallback = yield* resumeFallback(executionId, { action, content }); |
| 831 | if (fallback) { |
| 832 | debugLog("resume.fallback_result", { executionId, status: fallback.status }); |
| 833 | return fallbackOutcomeResult(executionId, fallback); |
| 834 | } |
| 835 | return missingExecutionResult(executionId); |
| 836 | } |
| 837 | debugLog("resume.result", { |
| 838 | executionId, |
| 839 | status: outcome.status, |
| 840 | nextExecutionId: outcome.status === "paused" ? outcome.execution.id : undefined, |
| 841 | interactionKind: |
| 842 | outcome.status === "paused" |
| 843 | ? pausedInteractionKind(outcome.execution.elicitationContext.request) |
| 844 | : undefined, |
| 845 | }); |
| 846 | if (outcome.status === "paused") { |
| 847 | return yield* formatPausedModelResult(outcome.execution, "resume"); |
| 848 | } |
| 849 | return toMcpResult(outcome.result); |
| 850 | }).pipe( |
| 851 | Effect.withSpan("mcp.host.tool.resume", { |
| 852 | attributes: { |
| 853 | "mcp.tool.name": "resume", |
| 854 | "mcp.execute.resume.action": action, |
| 855 | "mcp.execute.execution_id": executionId, |
| 856 | }, |
| 857 | }), |
| 858 | ); |
| 859 | |
| 860 | const requireUserResumeApproval = (executionId: string): Effect.Effect<McpToolResult> => |
| 861 | Effect.sync(() => { |
no test coverage detected