(
executionId: string,
action: "accept" | "decline" | "cancel",
content: Record<string, unknown> | undefined,
extra: McpRequestJoinKeys,
)
| 1382 | ); |
| 1383 | |
| 1384 | const resumeExecution = ( |
| 1385 | executionId: string, |
| 1386 | action: "accept" | "decline" | "cancel", |
| 1387 | content: Record<string, unknown> | undefined, |
| 1388 | extra: McpRequestJoinKeys, |
| 1389 | ): Effect.Effect<McpToolResult, E> => |
| 1390 | Effect.gen(function* () { |
| 1391 | yield* startMarker("mcp.host.tool.resume.start", { |
| 1392 | "mcp.tool.name": "resume", |
| 1393 | "mcp.execute.execution_id": executionId, |
| 1394 | }); |
| 1395 | debugLog("resume.call", { |
| 1396 | executionId, |
| 1397 | action, |
| 1398 | hasContent: content !== undefined, |
| 1399 | clientCapabilities: server.server.getClientCapabilities() ?? null, |
| 1400 | }); |
| 1401 | const outcome = yield* resumeWithLifecycle(executionId, { action, content }); |
| 1402 | if (!outcome) { |
| 1403 | debugLog("resume.missing_execution", { executionId }); |
| 1404 | if (yield* localExecutionAlreadySettled(executionId)) { |
| 1405 | return alreadySettledResult(executionId); |
| 1406 | } |
| 1407 | const fallback = yield* resumeFallback(executionId, { action, content }); |
| 1408 | if (fallback) { |
| 1409 | debugLog("resume.fallback_result", { executionId, status: fallback.status }); |
| 1410 | return fallbackOutcomeResult(executionId, fallback); |
| 1411 | } |
| 1412 | return missingExecutionResult(executionId); |
| 1413 | } |
| 1414 | debugLog("resume.result", { |
| 1415 | executionId, |
| 1416 | status: outcome.status, |
| 1417 | nextExecutionId: outcome.status === "paused" ? outcome.execution.id : undefined, |
| 1418 | interactionKind: |
| 1419 | outcome.status === "paused" |
| 1420 | ? pausedInteractionKind(outcome.execution.elicitationContext.request) |
| 1421 | : undefined, |
| 1422 | }); |
| 1423 | if (outcome.status === "paused") { |
| 1424 | return yield* formatPausedModelResult(outcome.execution, "resume"); |
| 1425 | } |
| 1426 | return toMcpResult(outcome.result); |
| 1427 | }).pipe( |
| 1428 | Effect.withSpan("mcp.host.tool.resume", { |
| 1429 | attributes: { |
| 1430 | "mcp.tool.name": "resume", |
| 1431 | "mcp.execute.resume.action": action, |
| 1432 | "mcp.execute.execution_id": executionId, |
| 1433 | }, |
| 1434 | }), |
| 1435 | Effect.annotateSpans(joinKeyAttributes(extra)), |
| 1436 | ); |
| 1437 | |
| 1438 | const requireUserResumeApproval = (executionId: string): Effect.Effect<McpToolResult> => |
| 1439 | Effect.sync(() => { |
no test coverage detected