@stigmer/runner 3.10.0 → 3.11.1-dev.20260812192248
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/dist/.build-fingerprint +1 -1
- package/dist/activities/call-llm.js +9 -10
- package/dist/activities/call-llm.js.map +1 -1
- package/dist/activities/classify-tool-approvals.d.ts +2 -1
- package/dist/activities/classify-tool-approvals.js +28 -2
- package/dist/activities/classify-tool-approvals.js.map +1 -1
- package/dist/activities/discover-mcp-server.d.ts +39 -0
- package/dist/activities/discover-mcp-server.js +165 -28
- package/dist/activities/discover-mcp-server.js.map +1 -1
- package/dist/activities/emit-event.d.ts +14 -2
- package/dist/activities/emit-event.js +52 -17
- package/dist/activities/emit-event.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.d.ts +8 -0
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js +1 -1
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js.map +1 -1
- package/dist/activities/execute-cursor/approval-state.d.ts +28 -2
- package/dist/activities/execute-cursor/approval-state.js +7 -1
- package/dist/activities/execute-cursor/approval-state.js.map +1 -1
- package/dist/activities/execute-cursor/attachment-resolver.d.ts +14 -0
- package/dist/activities/execute-cursor/attachment-resolver.js +18 -4
- package/dist/activities/execute-cursor/attachment-resolver.js.map +1 -1
- package/dist/activities/execute-cursor/blueprint-resolver.d.ts +1 -9
- package/dist/activities/execute-cursor/blueprint-resolver.js +6 -22
- package/dist/activities/execute-cursor/blueprint-resolver.js.map +1 -1
- package/dist/activities/execute-cursor/env-resolver.js +3 -1
- package/dist/activities/execute-cursor/env-resolver.js.map +1 -1
- package/dist/activities/execute-cursor/error-classifier.d.ts +59 -3
- package/dist/activities/execute-cursor/error-classifier.js +115 -6
- package/dist/activities/execute-cursor/error-classifier.js.map +1 -1
- package/dist/activities/execute-cursor/extract-structured-output.d.ts +29 -0
- package/dist/activities/execute-cursor/extract-structured-output.js +58 -0
- package/dist/activities/execute-cursor/extract-structured-output.js.map +1 -0
- package/dist/activities/execute-cursor/hook-script.d.ts +14 -3
- package/dist/activities/execute-cursor/hook-script.js +72 -10
- package/dist/activities/execute-cursor/hook-script.js.map +1 -1
- package/dist/activities/execute-cursor/index.d.ts +51 -11
- package/dist/activities/execute-cursor/index.js +177 -93
- package/dist/activities/execute-cursor/index.js.map +1 -1
- package/dist/activities/execute-cursor/mcp-resolver.d.ts +24 -1
- package/dist/activities/execute-cursor/mcp-resolver.js +5 -2
- package/dist/activities/execute-cursor/mcp-resolver.js.map +1 -1
- package/dist/activities/execute-cursor/model-pricing-data.d.ts +2 -0
- package/dist/activities/execute-cursor/model-pricing-data.js +13 -3
- package/dist/activities/execute-cursor/model-pricing-data.js.map +1 -1
- package/dist/activities/execute-cursor/prompt-builder.d.ts +51 -4
- package/dist/activities/execute-cursor/prompt-builder.js +49 -7
- package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
- package/dist/activities/execute-cursor/turn-recovery.d.ts +52 -0
- package/dist/activities/execute-cursor/turn-recovery.js +193 -0
- package/dist/activities/execute-cursor/turn-recovery.js.map +1 -0
- package/dist/activities/execute-cursor/turn-stream.js +4 -1
- package/dist/activities/execute-cursor/turn-stream.js.map +1 -1
- package/dist/activities/execute-deep-agent/attachment-injector.d.ts +18 -1
- package/dist/activities/execute-deep-agent/attachment-injector.js +68 -23
- package/dist/activities/execute-deep-agent/attachment-injector.js.map +1 -1
- package/dist/activities/execute-deep-agent/environment.js +3 -1
- package/dist/activities/execute-deep-agent/environment.js.map +1 -1
- package/dist/activities/execute-deep-agent/index.js +15 -0
- package/dist/activities/execute-deep-agent/index.js.map +1 -1
- package/dist/activities/execute-deep-agent/prompt-builder.d.ts +7 -7
- package/dist/activities/execute-deep-agent/prompt-builder.js +8 -2
- package/dist/activities/execute-deep-agent/prompt-builder.js.map +1 -1
- package/dist/activities/execute-deep-agent/setup.d.ts +10 -0
- package/dist/activities/execute-deep-agent/setup.js +65 -24
- package/dist/activities/execute-deep-agent/setup.js.map +1 -1
- package/dist/activities/execute-deep-agent/shell-env.d.ts +5 -1
- package/dist/activities/execute-deep-agent/shell-env.js +7 -9
- package/dist/activities/execute-deep-agent/shell-env.js.map +1 -1
- package/dist/activities/execute-deep-agent/subagent-transformer.d.ts +18 -1
- package/dist/activities/execute-deep-agent/subagent-transformer.js +15 -2
- package/dist/activities/execute-deep-agent/subagent-transformer.js.map +1 -1
- package/dist/activities/execute-deep-agent/subagent-wiring.d.ts +27 -6
- package/dist/activities/execute-deep-agent/subagent-wiring.js +26 -5
- package/dist/activities/execute-deep-agent/subagent-wiring.js.map +1 -1
- package/dist/activities/hydrate-workflow-execution.js +8 -3
- package/dist/activities/hydrate-workflow-execution.js.map +1 -1
- package/dist/activities/run-command.d.ts +5 -2
- package/dist/activities/run-command.js +22 -10
- package/dist/activities/run-command.js.map +1 -1
- package/dist/activities/run-env.d.ts +40 -0
- package/dist/activities/run-env.js +66 -0
- package/dist/activities/run-env.js.map +1 -0
- package/dist/activities/workflow-event-activities.d.ts +28 -10
- package/dist/activities/workflow-event-activities.js +87 -58
- package/dist/activities/workflow-event-activities.js.map +1 -1
- package/dist/bootstrap.js +5 -0
- package/dist/bootstrap.js.map +1 -1
- package/dist/claimcheck/payload-codec.js +21 -1
- package/dist/claimcheck/payload-codec.js.map +1 -1
- package/dist/client/stigmer-client.d.ts +83 -21
- package/dist/client/stigmer-client.js +106 -29
- package/dist/client/stigmer-client.js.map +1 -1
- package/dist/encryption/config.d.ts +64 -0
- package/dist/encryption/config.js +108 -0
- package/dist/encryption/config.js.map +1 -0
- package/dist/encryption/index.d.ts +3 -0
- package/dist/encryption/index.js +3 -0
- package/dist/encryption/index.js.map +1 -0
- package/dist/encryption/payload-codec.d.ts +41 -0
- package/dist/encryption/payload-codec.js +130 -0
- package/dist/encryption/payload-codec.js.map +1 -0
- package/dist/middleware/index.d.ts +3 -0
- package/dist/middleware/index.js +7 -0
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/path-normalization.d.ts +57 -0
- package/dist/middleware/path-normalization.js +109 -0
- package/dist/middleware/path-normalization.js.map +1 -0
- package/dist/middleware/types.d.ts +8 -0
- package/dist/payload-codecs.d.ts +17 -0
- package/dist/payload-codecs.js +42 -0
- package/dist/payload-codecs.js.map +1 -0
- package/dist/preflight.d.ts +31 -0
- package/dist/preflight.js +43 -0
- package/dist/preflight.js.map +1 -1
- package/dist/runner-manager.js +21 -17
- package/dist/runner-manager.js.map +1 -1
- package/dist/runner.js +11 -18
- package/dist/runner.js.map +1 -1
- package/dist/shared/approval-policy.d.ts +9 -3
- package/dist/shared/approval-policy.js +15 -6
- package/dist/shared/approval-policy.js.map +1 -1
- package/dist/shared/artifact-storage.d.ts +23 -1
- package/dist/shared/artifact-storage.js +51 -10
- package/dist/shared/artifact-storage.js.map +1 -1
- package/dist/shared/attachment-naming.d.ts +53 -0
- package/dist/shared/attachment-naming.js +59 -0
- package/dist/shared/attachment-naming.js.map +1 -0
- package/dist/shared/caller-identity.d.ts +23 -2
- package/dist/shared/caller-identity.js +36 -5
- package/dist/shared/caller-identity.js.map +1 -1
- package/dist/shared/channel-attachment.js +1 -0
- package/dist/shared/channel-attachment.js.map +1 -1
- package/dist/shared/checkpointer/http-saver.d.ts +26 -1
- package/dist/shared/checkpointer/http-saver.js +54 -8
- package/dist/shared/checkpointer/http-saver.js.map +1 -1
- package/dist/shared/conversation-attachment.js +1 -0
- package/dist/shared/conversation-attachment.js.map +1 -1
- package/dist/shared/conversation-catchup.d.ts +9 -2
- package/dist/shared/conversation-catchup.js +39 -6
- package/dist/shared/conversation-catchup.js.map +1 -1
- package/dist/shared/datastore-attachment.d.ts +50 -7
- package/dist/shared/datastore-attachment.js +93 -11
- package/dist/shared/datastore-attachment.js.map +1 -1
- package/dist/shared/grpc-retry.d.ts +5 -1
- package/dist/shared/grpc-retry.js +5 -1
- package/dist/shared/grpc-retry.js.map +1 -1
- package/dist/shared/http-retry.d.ts +85 -0
- package/dist/shared/http-retry.js +101 -0
- package/dist/shared/http-retry.js.map +1 -0
- package/dist/shared/llm-backend.d.ts +275 -0
- package/dist/shared/llm-backend.js +425 -0
- package/dist/shared/llm-backend.js.map +1 -0
- package/dist/shared/llm-proxy.d.ts +8 -0
- package/dist/shared/llm-proxy.js +15 -0
- package/dist/shared/llm-proxy.js.map +1 -1
- package/dist/shared/mcp-enabled-tools.d.ts +57 -0
- package/dist/shared/mcp-enabled-tools.js +86 -0
- package/dist/shared/mcp-enabled-tools.js.map +1 -0
- package/dist/shared/mcp-manager.d.ts +11 -5
- package/dist/shared/mcp-manager.js +47 -8
- package/dist/shared/mcp-manager.js.map +1 -1
- package/dist/shared/mcp-resolver.d.ts +39 -2
- package/dist/shared/mcp-resolver.js +38 -2
- package/dist/shared/mcp-resolver.js.map +1 -1
- package/dist/shared/mcp-schema-sanitizer.d.ts +70 -0
- package/dist/shared/mcp-schema-sanitizer.js +197 -0
- package/dist/shared/mcp-schema-sanitizer.js.map +1 -0
- package/dist/shared/model-client.d.ts +18 -5
- package/dist/shared/model-client.js +149 -18
- package/dist/shared/model-client.js.map +1 -1
- package/dist/shared/model-error.js +198 -5
- package/dist/shared/model-error.js.map +1 -1
- package/dist/shared/model-pricing-data.d.ts +2 -0
- package/dist/shared/model-pricing-data.js +13 -3
- package/dist/shared/model-pricing-data.js.map +1 -1
- package/dist/shared/model-registry.js +3 -2
- package/dist/shared/model-registry.js.map +1 -1
- package/dist/shared/plan-mode-permissions.d.ts +33 -0
- package/dist/shared/plan-mode-permissions.js +35 -0
- package/dist/shared/plan-mode-permissions.js.map +1 -0
- package/dist/shared/registry-endpoint.d.ts +20 -0
- package/dist/shared/registry-endpoint.js +25 -0
- package/dist/shared/registry-endpoint.js.map +1 -1
- package/dist/shared/runner-credential-keys.d.ts +24 -0
- package/dist/shared/runner-credential-keys.js +47 -0
- package/dist/shared/runner-credential-keys.js.map +1 -0
- package/dist/worker.d.ts +2 -1
- package/dist/worker.js +2 -4
- package/dist/worker.js.map +1 -1
- package/dist/workflow-engine/resolve.d.ts +19 -1
- package/dist/workflow-engine/resolve.js +37 -2
- package/dist/workflow-engine/resolve.js.map +1 -1
- package/dist/workflow-engine/types.d.ts +18 -0
- package/dist/workflow-engine/types.js.map +1 -1
- package/dist/workflows/call-agent-orchestrator.d.ts +9 -0
- package/dist/workflows/call-agent-orchestrator.js +1 -0
- package/dist/workflows/call-agent-orchestrator.js.map +1 -1
- package/dist/workflows/connect-mcp-server.js +9 -0
- package/dist/workflows/connect-mcp-server.js.map +1 -1
- package/dist/workflows/engine-core.js +23 -2
- package/dist/workflows/engine-core.js.map +1 -1
- package/dist/workflows/execute-from-execution.d.ts +1 -1
- package/dist/workflows/execute-from-execution.js +11 -1
- package/dist/workflows/execute-from-execution.js.map +1 -1
- package/dist/workflows/types.d.ts +8 -0
- package/package.json +9 -4
- package/src/__test-utils__/__tests__/vitest-global-setup.test.ts +37 -0
- package/src/__test-utils__/vitest-global-setup.ts +50 -0
- package/src/__tests__/bootstrap.test.ts +43 -0
- package/src/__tests__/claimcheck-codec.test.ts +36 -0
- package/src/__tests__/encryption-codec.test.ts +287 -0
- package/src/__tests__/fixtures/encrypted-payload-fixture.json +15 -0
- package/src/__tests__/history-encryption-e2e.test.ts +243 -0
- package/src/__tests__/preflight.test.ts +65 -2
- package/src/activities/__tests__/call-llm.test.ts +75 -0
- package/src/activities/__tests__/classify-tool-approvals.test.ts +117 -1
- package/src/activities/__tests__/discover-mcp-server.hang.test.ts +103 -0
- package/src/activities/__tests__/discover-mcp-server.test.ts +242 -1
- package/src/activities/__tests__/error-classifier.test.ts +94 -2
- package/src/activities/__tests__/run-command.test.ts +221 -0
- package/src/activities/__tests__/workflow-event-activities.test.ts +107 -8
- package/src/activities/call-llm.ts +9 -16
- package/src/activities/classify-tool-approvals.ts +34 -4
- package/src/activities/discover-mcp-server.ts +203 -31
- package/src/activities/emit-event.ts +65 -21
- package/src/activities/execute-cursor/__test-utils__/cursor-hook-harness.ts +9 -0
- package/src/activities/execute-cursor/__tests__/approval-gate.test.ts +14 -0
- package/src/activities/execute-cursor/__tests__/attachment-resolver.test.ts +53 -0
- package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +151 -16
- package/src/activities/execute-cursor/__tests__/error-classifier-extraction.test.ts +208 -0
- package/src/activities/execute-cursor/__tests__/extract-structured-output.test.ts +120 -0
- package/src/activities/execute-cursor/__tests__/hook-script.test.ts +93 -0
- package/src/activities/execute-cursor/__tests__/mcp-resolver.test.ts +125 -0
- package/src/activities/execute-cursor/__tests__/model-pricing.test.ts +62 -1
- package/src/activities/execute-cursor/__tests__/prompt-builder-delegation.test.ts +1 -1
- package/src/activities/execute-cursor/__tests__/turn-recovery.test.ts +160 -0
- package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +13 -0
- package/src/activities/execute-cursor/approval-state.ts +30 -1
- package/src/activities/execute-cursor/attachment-resolver.ts +31 -3
- package/src/activities/execute-cursor/blueprint-resolver.ts +7 -27
- package/src/activities/execute-cursor/env-resolver.ts +3 -1
- package/src/activities/execute-cursor/error-classifier.ts +131 -7
- package/src/activities/execute-cursor/extract-structured-output.ts +72 -0
- package/src/activities/execute-cursor/hook-script.ts +74 -10
- package/src/activities/execute-cursor/index.ts +209 -109
- package/src/activities/execute-cursor/mcp-resolver.ts +36 -2
- package/src/activities/execute-cursor/model-pricing-data.ts +22 -3
- package/src/activities/execute-cursor/prompt-builder.ts +85 -9
- package/src/activities/execute-cursor/turn-recovery.ts +208 -0
- package/src/activities/execute-cursor/turn-stream.ts +5 -2
- package/src/activities/execute-deep-agent/__tests__/attachment-injector.test.ts +110 -8
- package/src/activities/execute-deep-agent/__tests__/datastore-degradation.test.ts +104 -0
- package/src/activities/execute-deep-agent/__tests__/hitl-reject.test.ts +2 -0
- package/src/activities/execute-deep-agent/__tests__/hitl-resume-approve-all.test.ts +1 -0
- package/src/activities/execute-deep-agent/__tests__/hitl-resume-history.test.ts +1 -0
- package/src/activities/execute-deep-agent/__tests__/plan-mode-path-normalization.test.ts +174 -0
- package/src/activities/execute-deep-agent/__tests__/prompt-builder.test.ts +34 -5
- package/src/activities/execute-deep-agent/__tests__/sequential-gate-resume.test.ts +1 -0
- package/src/activities/execute-deep-agent/__tests__/shell-env.test.ts +24 -10
- package/src/activities/execute-deep-agent/__tests__/subagent-plan-mode-permissions.test.ts +178 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-wiring.test.ts +12 -7
- package/src/activities/execute-deep-agent/attachment-injector.ts +94 -30
- package/src/activities/execute-deep-agent/environment.ts +3 -1
- package/src/activities/execute-deep-agent/index.ts +20 -0
- package/src/activities/execute-deep-agent/prompt-builder.ts +20 -10
- package/src/activities/execute-deep-agent/setup.ts +85 -29
- package/src/activities/execute-deep-agent/shell-env.ts +8 -9
- package/src/activities/execute-deep-agent/subagent-transformer.ts +30 -2
- package/src/activities/execute-deep-agent/subagent-wiring.ts +39 -6
- package/src/activities/hydrate-workflow-execution.ts +8 -3
- package/src/activities/run-command.ts +25 -12
- package/src/activities/run-env.ts +79 -0
- package/src/activities/workflow-event-activities.ts +96 -69
- package/src/bootstrap.ts +5 -0
- package/src/claimcheck/payload-codec.ts +33 -1
- package/src/client/__tests__/stigmer-client.test.ts +110 -11
- package/src/client/stigmer-client.ts +150 -37
- package/src/encryption/config.ts +155 -0
- package/src/encryption/index.ts +3 -0
- package/src/encryption/payload-codec.ts +152 -0
- package/src/middleware/__tests__/path-normalization.test.ts +140 -0
- package/src/middleware/index.ts +8 -0
- package/src/middleware/path-normalization.ts +125 -0
- package/src/middleware/types.ts +11 -0
- package/src/payload-codecs.ts +62 -0
- package/src/preflight.ts +45 -0
- package/src/runner-manager.ts +26 -26
- package/src/runner.ts +12 -27
- package/src/shared/__tests__/approval-policy.test.ts +82 -39
- package/src/shared/__tests__/artifact-storage.test.ts +145 -2
- package/src/shared/__tests__/attachment-naming.test.ts +159 -0
- package/src/shared/__tests__/bedrock-adapter.test.ts +213 -0
- package/src/shared/__tests__/bedrock-seam.test.ts +390 -0
- package/src/shared/__tests__/caller-identity.test.ts +25 -0
- package/src/shared/__tests__/channel-attachment.test.ts +1 -1
- package/src/shared/__tests__/connect-backfill.test.ts +1 -0
- package/src/shared/__tests__/conversation-attachment.test.ts +1 -1
- package/src/shared/__tests__/conversation-catchup.test.ts +24 -0
- package/src/shared/__tests__/datastore-attachment.test.ts +129 -1
- package/src/shared/__tests__/foundry-adapter.test.ts +276 -0
- package/src/shared/__tests__/foundry-seam.test.ts +482 -0
- package/src/shared/__tests__/http-retry.test.ts +68 -0
- package/src/shared/__tests__/llm-backend.test.ts +616 -0
- package/src/shared/__tests__/mcp-enabled-tools.test.ts +86 -0
- package/src/shared/__tests__/mcp-manager.test.ts +137 -15
- package/src/shared/__tests__/mcp-resolver.test.ts +146 -3
- package/src/shared/__tests__/mcp-schema-sanitizer.test.ts +267 -0
- package/src/shared/__tests__/model-client.test.ts +200 -0
- package/src/shared/__tests__/model-error.test.ts +289 -1
- package/src/shared/__tests__/model-pricing.test.ts +62 -2
- package/src/shared/__tests__/model-registry.test.ts +22 -0
- package/src/shared/__tests__/synthesized-attachment.test.ts +1 -0
- package/src/shared/__tests__/vertex-adapter.test.ts +169 -0
- package/src/shared/__tests__/vertex-seam.test.ts +295 -0
- package/src/shared/approval-policy.ts +14 -7
- package/src/shared/artifact-storage.ts +75 -10
- package/src/shared/attachment-naming.ts +78 -0
- package/src/shared/caller-identity.ts +40 -5
- package/src/shared/channel-attachment.ts +1 -0
- package/src/shared/checkpointer/__tests__/http-saver.test.ts +196 -1
- package/src/shared/checkpointer/http-saver.ts +71 -8
- package/src/shared/conversation-attachment.ts +1 -0
- package/src/shared/conversation-catchup.ts +39 -6
- package/src/shared/datastore-attachment.ts +106 -11
- package/src/shared/grpc-retry.ts +5 -1
- package/src/shared/http-retry.ts +139 -0
- package/src/shared/llm-backend.ts +544 -0
- package/src/shared/llm-proxy.ts +15 -0
- package/src/shared/mcp-enabled-tools.ts +105 -0
- package/src/shared/mcp-manager.ts +56 -8
- package/src/shared/mcp-resolver.ts +73 -2
- package/src/shared/mcp-schema-sanitizer.ts +224 -0
- package/src/shared/model-client.ts +179 -19
- package/src/shared/model-error.ts +222 -4
- package/src/shared/model-pricing-data.ts +22 -3
- package/src/shared/model-registry.ts +7 -2
- package/src/shared/plan-mode-permissions.ts +37 -0
- package/src/shared/registry-endpoint.ts +27 -0
- package/src/shared/runner-credential-keys.ts +46 -0
- package/src/worker.ts +4 -5
- package/src/workflow-engine/__tests__/tasks/emit-event.test.ts +127 -49
- package/src/workflow-engine/resolve.ts +48 -2
- package/src/workflow-engine/types.ts +18 -0
- package/src/workflows/__tests__/connect-mcp-server.test.ts +25 -0
- package/src/workflows/__tests__/execute-serverless-workflow.test.ts +68 -2
- package/src/workflows/call-agent-orchestrator.ts +10 -0
- package/src/workflows/connect-mcp-server.ts +9 -0
- package/src/workflows/engine-core.ts +23 -2
- package/src/workflows/execute-from-execution.ts +12 -2
- package/src/workflows/types.ts +8 -0
- package/dist/activities/execute-cursor/mcp-config.d.ts +0 -30
- package/dist/activities/execute-cursor/mcp-config.js +0 -39
- package/dist/activities/execute-cursor/mcp-config.js.map +0 -1
- package/src/activities/execute-cursor/mcp-config.ts +0 -66
|
@@ -22,8 +22,12 @@
|
|
|
22
22
|
* OSS callers resolve as the local principal (T05 R2).
|
|
23
23
|
*
|
|
24
24
|
* Approval-free by construction (DD-001 SD-3): empty toolApprovals +
|
|
25
|
-
* pinnedToolApprovals mean mergeApprovalPolicies
|
|
26
|
-
* this server — zero classifier involvement
|
|
25
|
+
* pinnedToolApprovals + toolApprovalOverrides mean mergeApprovalPolicies
|
|
26
|
+
* emits no entries for this server — zero classifier involvement, and no
|
|
27
|
+
* proto surface can target it (the attachment has no McpServerUsage, and
|
|
28
|
+
* since issue #349 an agent's overrides are scoped to their own usage's
|
|
29
|
+
* server, so a same-named override elsewhere cannot reach this one).
|
|
30
|
+
* `discoveredCapabilitiesEmpty`
|
|
27
31
|
* is false and the attachment has no McpServerUsage, so the connect
|
|
28
32
|
* backfill (whose destructiveHint tightener would force-gate
|
|
29
33
|
* delete_record — silently skipped on channels under UNATTENDED mode)
|
|
@@ -63,6 +67,7 @@ export function synthesizeDatastoreAttachment(
|
|
|
63
67
|
slug: DATASTORE_ATTACHMENT_SLUG,
|
|
64
68
|
toolApprovals: [],
|
|
65
69
|
pinnedToolApprovals: [],
|
|
70
|
+
toolApprovalOverrides: [],
|
|
66
71
|
discoveredCapabilitiesEmpty: false,
|
|
67
72
|
};
|
|
68
73
|
|
|
@@ -90,25 +95,115 @@ export function synthesizeDatastoreAttachment(
|
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
/**
|
|
93
|
-
* The
|
|
94
|
-
*
|
|
95
|
-
* the
|
|
96
|
-
*
|
|
98
|
+
* The five record tools the records roster always serves (DD-005; the
|
|
99
|
+
* mcp-server's records roster registers all five unconditionally for the
|
|
100
|
+
* agent audience — only the `org` argument shape varies by audience, see
|
|
101
|
+
* mcp-server/src/domains/records/tools.ts). Because the roster never
|
|
102
|
+
* legitimately narrows, any of these missing from the connected toolset
|
|
103
|
+
* means the store is degraded (issue #325) — the prompt section and the
|
|
104
|
+
* reconciliation both derive from this one list so they cannot drift.
|
|
97
105
|
*/
|
|
98
|
-
export
|
|
99
|
-
|
|
106
|
+
export const EXPECTED_RECORD_TOOLS = [
|
|
107
|
+
"describe_datastore",
|
|
108
|
+
"find_records",
|
|
109
|
+
"insert_record",
|
|
110
|
+
"update_record",
|
|
111
|
+
"delete_record",
|
|
112
|
+
] as const;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Reconcile the record tools actually connected against the roster
|
|
116
|
+
* contract (issue #325). Returns the expected tools absent from
|
|
117
|
+
* `actualToolNames` — empty means healthy. Names are bare tool names
|
|
118
|
+
* exactly as reported by tools/list (the mcp-enabled-tools identity
|
|
119
|
+
* space); extraneous names are ignored.
|
|
120
|
+
*/
|
|
121
|
+
export function missingRecordTools(actualToolNames: Iterable<string>): string[] {
|
|
122
|
+
const present = new Set(actualToolNames);
|
|
123
|
+
return EXPECTED_RECORD_TOOLS.filter((name) => !present.has(name));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The operator-facing degradation notice (issue #325): pushed as a
|
|
128
|
+
* MESSAGE_SYSTEM row on the execution status so "declared N datastores,
|
|
129
|
+
* X/5 record tools connected" is visible without reading a transcript.
|
|
130
|
+
* Lives HERE with the rest of the datastore-attachment wording — the
|
|
131
|
+
* harness only threads it.
|
|
132
|
+
*/
|
|
133
|
+
export function formatDatastoreDegradationNotice(
|
|
134
|
+
declaredCount: number,
|
|
135
|
+
missing: readonly string[],
|
|
136
|
+
): string {
|
|
137
|
+
const connected = EXPECTED_RECORD_TOOLS.length - missing.length;
|
|
138
|
+
return (
|
|
139
|
+
`Datastore record tools unavailable this turn: declared ` +
|
|
140
|
+
`${declaredCount} datastore(s), ${connected}/${EXPECTED_RECORD_TOOLS.length} ` +
|
|
141
|
+
`record tools connected (missing: ${missing.join(", ")}). The agent has ` +
|
|
142
|
+
`been instructed to disclose this instead of answering from memory.`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The datastores prompt section (DD-005 SD-5, the skills-section
|
|
148
|
+
* precedent). Shared by both harnesses so the section text cannot drift
|
|
149
|
+
* (the sender-identity precedent). Two honest renderings (issue #325):
|
|
150
|
+
*
|
|
151
|
+
* - Healthy (`missingToolNames` empty or omitted — the Cursor harness
|
|
152
|
+
* always calls it this way: the Cursor SDK connects MCP itself, so
|
|
153
|
+
* that harness can never observe the live roster):
|
|
154
|
+
* `<available_datastores>` names the attached datastores, points the
|
|
155
|
+
* model at describe_datastore first, and carries a standing
|
|
156
|
+
* failure-disclosure instruction — the only mechanism that covers
|
|
157
|
+
* tools which connected but fail at call time (the WhatsApp-pilot
|
|
158
|
+
* outage shape).
|
|
159
|
+
* - Degraded (deep-agent only, from missingRecordTools against the
|
|
160
|
+
* connected roster): `<unavailable_datastores>` instead — the section
|
|
161
|
+
* must not promise tools the agent does not have. Names the declared
|
|
162
|
+
* datastores, states which record tools are missing, and instructs
|
|
163
|
+
* plain disclosure over improvisation.
|
|
164
|
+
*/
|
|
165
|
+
export function formatDatastoresSection(
|
|
166
|
+
datastoreUsages: DatastoreUsage[],
|
|
167
|
+
missingToolNames: readonly string[] = [],
|
|
168
|
+
): string {
|
|
169
|
+
const entries = datastoreUsages
|
|
100
170
|
.map((u) => u.datastoreRef?.slug)
|
|
101
|
-
.filter((s): s is string => !!s)
|
|
102
|
-
|
|
171
|
+
.filter((s): s is string => !!s)
|
|
172
|
+
.map((slug) => `- ${slug}`);
|
|
173
|
+
|
|
174
|
+
if (missingToolNames.length > 0) {
|
|
175
|
+
return [
|
|
176
|
+
"<unavailable_datastores>",
|
|
177
|
+
"This agent is configured to use the datastores listed below, but the",
|
|
178
|
+
"following record tools failed to connect this turn:",
|
|
179
|
+
missingToolNames.join(", ") + ".",
|
|
180
|
+
"Treat these datastores as unreachable for any operation that needs a",
|
|
181
|
+
"missing tool.",
|
|
182
|
+
"",
|
|
183
|
+
...entries,
|
|
184
|
+
"",
|
|
185
|
+
"When the user's request depends on one of these datastores, tell them",
|
|
186
|
+
"plainly that the datastore cannot be reached right now. Never answer",
|
|
187
|
+
"from memory, guess, or improvise a substitute for what the datastore",
|
|
188
|
+
"would have returned.",
|
|
189
|
+
"</unavailable_datastores>",
|
|
190
|
+
].join("\n");
|
|
191
|
+
}
|
|
192
|
+
|
|
103
193
|
return [
|
|
104
194
|
"<available_datastores>",
|
|
105
195
|
"You have access to the following datastores through the record tools",
|
|
106
|
-
"
|
|
196
|
+
`(${EXPECTED_RECORD_TOOLS.join(", ")}).`,
|
|
107
197
|
"Before your first operation against a datastore, call describe_datastore to",
|
|
108
198
|
"learn its collections, field encodings, and which operations you are allowed",
|
|
109
199
|
"to perform.",
|
|
110
200
|
"",
|
|
111
201
|
...entries,
|
|
202
|
+
"",
|
|
203
|
+
"If any record tool is missing from your toolset or a record tool call",
|
|
204
|
+
"fails, the datastore is unreachable: tell the user plainly that you cannot",
|
|
205
|
+
"reach it right now, and do not answer from memory, guess, or improvise a",
|
|
206
|
+
"substitute for what it would have returned.",
|
|
112
207
|
"</available_datastores>",
|
|
113
208
|
].join("\n");
|
|
114
209
|
}
|
package/src/shared/grpc-retry.ts
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
* `updateStatus` should back off and retry (transient transport errors) or
|
|
7
7
|
* fail fast (deterministic errors). This module is intentionally just the
|
|
8
8
|
* classification policy + its options type, kept small and separately tested;
|
|
9
|
-
* the persist loop that consumes it lives with the rest of the persist logic
|
|
9
|
+
* the persist loop that consumes it lives with the rest of the persist logic
|
|
10
|
+
* in status.ts — a single consumer whose loop is interwoven with persist
|
|
11
|
+
* semantics. (The HTTP twin, http-retry.ts, diverged there deliberately: with
|
|
12
|
+
* three fetch clients needing a byte-identical loop it hosts the shared
|
|
13
|
+
* fetchWithRetry too — see its module doc.)
|
|
10
14
|
*/
|
|
11
15
|
|
|
12
16
|
import { ConnectError, Code } from "@connectrpc/connect";
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP error classification AND the shared bounded-backoff loop for
|
|
3
|
+
* side-channel proxy retries.
|
|
4
|
+
*
|
|
5
|
+
* The runner reaches stigmer-service's Side-Channel Proxy (`/v1/proxy/...`)
|
|
6
|
+
* over plain `fetch` from several clients: the checkpoint saver, artifact
|
|
7
|
+
* storage, and the model-registry fetches (stigmer/stigmer#468). This module
|
|
8
|
+
* is the one place that answers "is this HTTP failure worth retrying?" — the
|
|
9
|
+
* `fetch` twin of grpc-retry.ts — and, since #468, also owns the
|
|
10
|
+
* {@link fetchWithRetry} loop those clients share. That is a deliberate
|
|
11
|
+
* divergence from grpc-retry.ts's policy-only split: the gRPC side has a
|
|
12
|
+
* single consumer whose loop is interwoven with persist-specific logic
|
|
13
|
+
* (status.ts), while the HTTP side grew three consumers needing a
|
|
14
|
+
* byte-identical loop — per-client copies were the drift risk, not the seam.
|
|
15
|
+
*
|
|
16
|
+
* The policy is grounded in what the proxy actually emits, not HTTP folklore.
|
|
17
|
+
* CheckpointerProxyController returns exactly four deterministic errors —
|
|
18
|
+
* 400 (malformed document), 403 (FGA deny), 404 (no such checkpoint), and
|
|
19
|
+
* 413 (the 4 MB cap) — and never a transient status. Transient failures
|
|
20
|
+
* reach the runner only as 5xx (Spring's error handler, ingress 502-504),
|
|
21
|
+
* 408/429 (infrastructure between runner and service), or as network-level
|
|
22
|
+
* fetch rejections. 401/403 stay terminal deliberately: retrying cannot fix
|
|
23
|
+
* an expired or rejected credential. The same classification holds for the
|
|
24
|
+
* presigned R2 URLs artifact storage talks to: their deterministic failures
|
|
25
|
+
* (403 expired signature, 404 missing object) are 4xx, their transient ones
|
|
26
|
+
* are 5xx/network.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* True for HTTP statuses that signal a transient condition worth retrying:
|
|
31
|
+
* 408 (request timeout), 429 (throttled), and all 5xx. Every other status is
|
|
32
|
+
* deterministic — the proxy's 4xx errors mean the same request will fail the
|
|
33
|
+
* same way forever.
|
|
34
|
+
*/
|
|
35
|
+
export function isRetryableHttpStatus(status: number): boolean {
|
|
36
|
+
return status === 408 || status === 429 || status >= 500;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* True for `fetch` rejections that signal a transient transport condition:
|
|
41
|
+
*
|
|
42
|
+
* - `TypeError` — undici's network-failure shape (`fetch failed`, with the
|
|
43
|
+
* ECONNREFUSED/ECONNRESET/DNS cause attached). A deterministic TypeError
|
|
44
|
+
* (e.g. a malformed URL) also matches, which is accepted: such a bug fails
|
|
45
|
+
* every attempt including the first test run, and the bounded budget caps
|
|
46
|
+
* the wasted retries at seconds.
|
|
47
|
+
* - `TimeoutError` — the rejection shape of `AbortSignal.timeout()`, i.e. a
|
|
48
|
+
* hung connection whose attempt we bounded ourselves.
|
|
49
|
+
*
|
|
50
|
+
* A manual abort (`AbortError`) is deliberately NOT retryable: the caller
|
|
51
|
+
* cancelled on purpose.
|
|
52
|
+
*/
|
|
53
|
+
export function isRetryableFetchError(err: unknown): boolean {
|
|
54
|
+
if (err instanceof TypeError) return true;
|
|
55
|
+
return err instanceof Error && err.name === "TimeoutError";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A fully-resolved retry policy for {@link fetchWithRetry}. Every field is
|
|
60
|
+
* required on purpose: defaults differ per client (the checkpointer and the
|
|
61
|
+
* presign endpoints run 30 s requests, artifact transfers 120 s, registry
|
|
62
|
+
* fetches 10 s), so each client resolves its own defaults once and this
|
|
63
|
+
* module never guesses.
|
|
64
|
+
*/
|
|
65
|
+
export interface FetchRetryPolicy {
|
|
66
|
+
/** Client name for retry logs, e.g. "HttpCheckpointSaver". */
|
|
67
|
+
readonly label: string;
|
|
68
|
+
/** Delay before the first retry (ms); doubles per attempt via the factor. */
|
|
69
|
+
readonly baseDelayMs: number;
|
|
70
|
+
readonly backoffFactor: number;
|
|
71
|
+
/** Retry attempts after the initial one. */
|
|
72
|
+
readonly maxRetries: number;
|
|
73
|
+
/**
|
|
74
|
+
* Milliseconds before an in-flight request is aborted and the attempt is
|
|
75
|
+
* classified retryable. Without it a hung connection (the realistic
|
|
76
|
+
* unplanned-pod-kill symptom) stalls forever and the retry never engages.
|
|
77
|
+
*/
|
|
78
|
+
readonly requestTimeoutMs: number;
|
|
79
|
+
/** Injectable delay for tests; defaults to a real setTimeout sleep. */
|
|
80
|
+
readonly delayFn?: (ms: number) => Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function defaultDelay(ms: number): Promise<void> {
|
|
84
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* `fetch` with bounded exponential backoff on transient failures and a
|
|
89
|
+
* per-request abort timeout.
|
|
90
|
+
*
|
|
91
|
+
* Composition contract: on a non-retryable status — or when the budget is
|
|
92
|
+
* exhausted on a retryable one — the last `Response` is RETURNED, so every
|
|
93
|
+
* call site keeps its own `resp.ok` / 404 handling unchanged; this wrapper
|
|
94
|
+
* changes when a response arrives, never what call sites do with it. It
|
|
95
|
+
* throws only what `fetch` itself throws: a network-level rejection that is
|
|
96
|
+
* non-retryable or has exhausted the budget.
|
|
97
|
+
*/
|
|
98
|
+
export async function fetchWithRetry(
|
|
99
|
+
url: string,
|
|
100
|
+
init: RequestInit | undefined,
|
|
101
|
+
policy: FetchRetryPolicy,
|
|
102
|
+
): Promise<Response> {
|
|
103
|
+
const delay = policy.delayFn ?? defaultDelay;
|
|
104
|
+
for (let attempt = 0; ; attempt++) {
|
|
105
|
+
const canRetry = attempt < policy.maxRetries;
|
|
106
|
+
let resp: Response;
|
|
107
|
+
try {
|
|
108
|
+
resp = await fetch(url, {
|
|
109
|
+
...init,
|
|
110
|
+
signal: AbortSignal.timeout(policy.requestTimeoutMs),
|
|
111
|
+
});
|
|
112
|
+
} catch (err) {
|
|
113
|
+
if (canRetry && isRetryableFetchError(err)) {
|
|
114
|
+
await backOff(policy, delay, attempt, String(err));
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
119
|
+
if (canRetry && isRetryableHttpStatus(resp.status)) {
|
|
120
|
+
await backOff(policy, delay, attempt, `HTTP ${resp.status} ${resp.statusText}`);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
return resp;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function backOff(
|
|
128
|
+
policy: FetchRetryPolicy,
|
|
129
|
+
delay: (ms: number) => Promise<void>,
|
|
130
|
+
attempt: number,
|
|
131
|
+
reason: string,
|
|
132
|
+
): Promise<void> {
|
|
133
|
+
const delayMs = policy.baseDelayMs * Math.pow(policy.backoffFactor, attempt);
|
|
134
|
+
console.warn(
|
|
135
|
+
`[${policy.label}] retryable failure ` +
|
|
136
|
+
`(attempt ${attempt + 1}/${policy.maxRetries + 1}, retry in ${delayMs}ms): ${reason}`,
|
|
137
|
+
);
|
|
138
|
+
await delay(delayMs);
|
|
139
|
+
}
|