(
executionId: string,
action: "accept" | "decline" | "cancel",
content: Record<string, unknown> | undefined,
extra: McpRequestJoinKeys,
)
| 1351 | ); |
| 1352 | |
| 1353 | const resumeExecution = ( |
| 1354 | executionId: string, |
| 1355 | action: "accept" | "decline" | "cancel", |
| 1356 | content: Record<string, unknown> | undefined, |
| 1357 | extra: McpRequestJoinKeys, |
| 1358 | ): Effect.Effect<McpToolResult, E> => |
| 1359 | Effect.gen(function* () { |
| 1360 | yield* startMarker("mcp.host.tool.resume.start", { |
| 1361 | "mcp.tool.name": "resume", |
| 1362 | "mcp.execute.execution_id": executionId, |
| 1363 | }); |
| 1364 | debugLog("resume.call", { |
| 1365 | executionId, |
| 1366 | action, |
| 1367 | hasContent: content !== undefined, |
| 1368 | clientCapabilities: server.server.getClientCapabilities() ?? null, |
| 1369 | }); |
| 1370 | const outcome = yield* resumeWithLifecycle(executionId, { action, content }); |
| 1371 | if (!outcome) { |
| 1372 | debugLog("resume.missing_execution", { executionId }); |
| 1373 | if (yield* localExecutionAlreadySettled(executionId)) { |
| 1374 | return alreadySettledResult(executionId); |
| 1375 | } |
| 1376 | const fallback = yield* resumeFallback(executionId, { action, content }); |
| 1377 | if (fallback) { |
| 1378 | debugLog("resume.fallback_result", { executionId, status: fallback.status }); |
| 1379 | return fallbackOutcomeResult(executionId, fallback); |
| 1380 | } |
| 1381 | return missingExecutionResult(executionId); |
| 1382 | } |
| 1383 | debugLog("resume.result", { |
| 1384 | executionId, |
| 1385 | status: outcome.status, |
| 1386 | nextExecutionId: outcome.status === "paused" ? outcome.execution.id : undefined, |
| 1387 | interactionKind: |
| 1388 | outcome.status === "paused" |
| 1389 | ? pausedInteractionKind(outcome.execution.elicitationContext.request) |
| 1390 | : undefined, |
| 1391 | }); |
| 1392 | if (outcome.status === "paused") { |
| 1393 | return yield* formatPausedModelResult(outcome.execution, "resume"); |
| 1394 | } |
| 1395 | return toMcpResult(outcome.result); |
| 1396 | }).pipe( |
| 1397 | Effect.withSpan("mcp.host.tool.resume", { |
| 1398 | attributes: { |
| 1399 | "mcp.tool.name": "resume", |
| 1400 | "mcp.execute.resume.action": action, |
| 1401 | "mcp.execute.execution_id": executionId, |
| 1402 | }, |
| 1403 | }), |
| 1404 | Effect.annotateSpans(joinKeyAttributes(extra)), |
| 1405 | ); |
| 1406 | |
| 1407 | const requireUserResumeApproval = (executionId: string): Effect.Effect<McpToolResult> => |
| 1408 | Effect.sync(() => { |
no test coverage detected