@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
|
@@ -6,15 +6,27 @@
|
|
|
6
6
|
* (e.g. "claude-haiku-4-5-20251001") before a client is built — so no
|
|
7
7
|
* activity can bypass the translation and 404 the provider.
|
|
8
8
|
*
|
|
9
|
-
* Layering: `llm-proxy.ts`
|
|
10
|
-
* dependency); this module is the LangChain-aware layer above
|
|
11
|
-
* the resolve -> infer-provider -> strip-prefix ->
|
|
12
|
-
* sequence that used to be copy-pasted
|
|
9
|
+
* Layering: `llm-proxy.ts` and `llm-backend.ts` stay pure routing utilities
|
|
10
|
+
* (no LangChain dependency); this module is the LangChain-aware layer above
|
|
11
|
+
* them that owns the resolve -> infer-provider -> strip-prefix ->
|
|
12
|
+
* proxy-or-backend-wire -> construct sequence that used to be copy-pasted
|
|
13
|
+
* across every LLM activity.
|
|
13
14
|
*/
|
|
14
15
|
import { ChatAnthropic } from "@langchain/anthropic";
|
|
15
16
|
import { ChatOpenAI } from "@langchain/openai";
|
|
16
17
|
import { inferProvider, stripProviderPrefix, resolveProxyBaseUrl, buildProxyHeaders, } from "./llm-proxy.js";
|
|
18
|
+
import { resolveAnthropicBackend, checkVertexPrerequisites, checkBedrockPrerequisites, checkFoundryPrerequisites, toVertexModelId, toBedrockModelId, toFoundryDeploymentName, } from "./llm-backend.js";
|
|
17
19
|
import { resolveToApiModelId } from "./model-registry.js";
|
|
20
|
+
/**
|
|
21
|
+
* The operator's request-timeout bound. Only a positive integer means
|
|
22
|
+
* "bound the request" — unset, non-numeric, zero, and negative all
|
|
23
|
+
* normalize to no bound. Deployment-static env, read here the same way
|
|
24
|
+
* provider API keys are.
|
|
25
|
+
*/
|
|
26
|
+
function resolveDefaultTimeoutMs() {
|
|
27
|
+
const parsed = Number.parseInt(process.env.STIGMER_LLM_REQUEST_TIMEOUT_MS ?? "", 10);
|
|
28
|
+
return parsed > 0 ? parsed : undefined;
|
|
29
|
+
}
|
|
18
30
|
/**
|
|
19
31
|
* Build a configured chat model, resolving the registry id to a provider API
|
|
20
32
|
* id first. The resolution MUST precede provider inference and prefix
|
|
@@ -25,6 +37,100 @@ export async function buildChatModel(opts) {
|
|
|
25
37
|
const resolved = await resolveToApiModelId(opts.modelName);
|
|
26
38
|
const provider = inferProvider(resolved);
|
|
27
39
|
const apiModelId = stripProviderPrefix(resolved);
|
|
40
|
+
const timeoutMs = opts.timeoutMs ?? resolveDefaultTimeoutMs();
|
|
41
|
+
// Backend precedence by construction: a proxied call never consults the
|
|
42
|
+
// backend var — the proxy owns provider routing (the factories' preflight
|
|
43
|
+
// warns when both are configured). Selection is deployment-static and read
|
|
44
|
+
// here the same way provider API keys are, not plumbed through Config.
|
|
45
|
+
const anthropicBackend = provider === "anthropic" && !opts.proxyEndpoint
|
|
46
|
+
? resolveAnthropicBackend()
|
|
47
|
+
: "public";
|
|
48
|
+
// Backend SDKs (and their auth subtrees: google-auth-library, AWS smithy)
|
|
49
|
+
// load lazily so deployments that never configure a backend never
|
|
50
|
+
// evaluate them — cheap cold starts stay cheap, and bundle-slim's CJS
|
|
51
|
+
// output preserves exactly this deferred evaluation (see
|
|
52
|
+
// scripts/bundle-slim.mjs). The factory is invoked lazily by
|
|
53
|
+
// ChatAnthropic once per cached client (batch + streaming), so the class
|
|
54
|
+
// is captured here, in async context.
|
|
55
|
+
//
|
|
56
|
+
// Each factory MUST honor options.maxRetries and options.timeout:
|
|
57
|
+
// LangChain owns retrying and hands the factory maxRetries: 0 — a factory
|
|
58
|
+
// that drops it nests the SDK's default 2 retries inside LangChain's
|
|
59
|
+
// retry loop, multiplying every transient failure — and `timeout` arrives
|
|
60
|
+
// through the same options object (ChatAnthropic spreads clientOptions
|
|
61
|
+
// into it), so a factory that drops it silently unbounds
|
|
62
|
+
// STIGMER_LLM_REQUEST_TIMEOUT_MS on that backend. Pinned by the seam
|
|
63
|
+
// tests. Prerequisites are re-checked here (not only in
|
|
64
|
+
// the factories' preflight) so paths that construct models without a
|
|
65
|
+
// runner factory still fail at dispatch with the catalog message instead
|
|
66
|
+
// of mid-request. Credentials are read natively by each SDK from its
|
|
67
|
+
// standard conventions (GCP: CLOUD_ML_REGION + ADC; AWS: AWS_REGION +
|
|
68
|
+
// the credential chain / AWS_BEARER_TOKEN_BEDROCK; Foundry:
|
|
69
|
+
// ANTHROPIC_FOUNDRY_API_KEY, or the Azure credential chain when no key
|
|
70
|
+
// is set).
|
|
71
|
+
let backendCreateClient;
|
|
72
|
+
let wireModelId = apiModelId;
|
|
73
|
+
let maxTokens = opts.maxTokens;
|
|
74
|
+
if (anthropicBackend === "vertex") {
|
|
75
|
+
const prereq = checkVertexPrerequisites();
|
|
76
|
+
if (prereq !== null)
|
|
77
|
+
throw new Error(prereq);
|
|
78
|
+
const { AnthropicVertex } = await import("@anthropic-ai/vertex-sdk");
|
|
79
|
+
backendCreateClient = (options) => new AnthropicVertex({ maxRetries: options.maxRetries, timeout: options.timeout });
|
|
80
|
+
wireModelId = toVertexModelId(apiModelId);
|
|
81
|
+
}
|
|
82
|
+
else if (anthropicBackend === "bedrock") {
|
|
83
|
+
const prereq = checkBedrockPrerequisites();
|
|
84
|
+
if (prereq !== null)
|
|
85
|
+
throw new Error(prereq);
|
|
86
|
+
const { AnthropicBedrock } = await import("@anthropic-ai/bedrock-sdk");
|
|
87
|
+
backendCreateClient = (options) => new AnthropicBedrock({ maxRetries: options.maxRetries, timeout: options.timeout });
|
|
88
|
+
wireModelId = toBedrockModelId(apiModelId);
|
|
89
|
+
if (maxTokens === undefined) {
|
|
90
|
+
// LangChain's per-model maxTokens table prefix-matches the model
|
|
91
|
+
// name. Vertex's translated ids still match their canonical prefix;
|
|
92
|
+
// Bedrock's `anthropic.…` ids match nothing and silently fall back
|
|
93
|
+
// to 4096 — a silent output cap. Probe the CANONICAL id with a
|
|
94
|
+
// throwaway construction (pure field assignment, no I/O; the key is
|
|
95
|
+
// never used) so bedrock inherits exactly the default the public API
|
|
96
|
+
// and vertex get for the same model — including models the table
|
|
97
|
+
// doesn't know yet, where all backends agree on the fallback.
|
|
98
|
+
// Pinned by the canonical-parity test in bedrock-adapter.test.ts.
|
|
99
|
+
maxTokens = new ChatAnthropic({ model: apiModelId, apiKey: "max-tokens-probe" }).maxTokens;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (anthropicBackend === "foundry") {
|
|
103
|
+
const prereq = checkFoundryPrerequisites();
|
|
104
|
+
if (prereq !== null)
|
|
105
|
+
throw new Error(prereq);
|
|
106
|
+
const { AnthropicFoundry } = await import("@anthropic-ai/foundry-sdk");
|
|
107
|
+
// Auth is an explicit either/or (the Foundry constructor throws when
|
|
108
|
+
// given both a key and a token provider): ANTHROPIC_FOUNDRY_API_KEY if
|
|
109
|
+
// present, otherwise keyless Microsoft Entra ID through the Azure
|
|
110
|
+
// credential chain (env service principal -> workload identity ->
|
|
111
|
+
// managed identity -> az CLI) — the Azure analogue of Vertex ADC and
|
|
112
|
+
// the AWS chain, resolved at request time. The provider is built once
|
|
113
|
+
// here (getBearerTokenProvider caches tokens until near-expiry) and
|
|
114
|
+
// shared by both cached clients; the SDK still consults it per request,
|
|
115
|
+
// so refreshed tokens flow without reconstruction (pinned by
|
|
116
|
+
// foundry-seam.test.ts). Endpoint (resource or base URL) and the key
|
|
117
|
+
// are read natively by the SDK from its own env vars.
|
|
118
|
+
let azureADTokenProvider;
|
|
119
|
+
if (!process.env.ANTHROPIC_FOUNDRY_API_KEY?.trim()) {
|
|
120
|
+
const { DefaultAzureCredential, getBearerTokenProvider } = await import("@azure/identity");
|
|
121
|
+
azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), "https://ai.azure.com/.default");
|
|
122
|
+
}
|
|
123
|
+
backendCreateClient = (options) => new AnthropicFoundry({
|
|
124
|
+
maxRetries: options.maxRetries,
|
|
125
|
+
timeout: options.timeout,
|
|
126
|
+
...(azureADTokenProvider ? { azureADTokenProvider } : {}),
|
|
127
|
+
});
|
|
128
|
+
// Unlike the vertex/bedrock ids, the deployment name needs no maxTokens
|
|
129
|
+
// handling: stripping the snapshot date preserves LangChain's per-model
|
|
130
|
+
// default (probed 2026-08-11 across the full catalog; pinned by the
|
|
131
|
+
// parity test in foundry-adapter.test.ts).
|
|
132
|
+
wireModelId = toFoundryDeploymentName(apiModelId);
|
|
133
|
+
}
|
|
28
134
|
const baseUrl = opts.proxyEndpoint
|
|
29
135
|
? resolveProxyBaseUrl(opts.proxyEndpoint, provider)
|
|
30
136
|
: undefined;
|
|
@@ -41,9 +147,27 @@ export async function buildChatModel(opts) {
|
|
|
41
147
|
const common = {
|
|
42
148
|
temperature: opts.temperature ?? 0,
|
|
43
149
|
apiKey,
|
|
44
|
-
...(
|
|
45
|
-
...(
|
|
150
|
+
...(maxTokens ? { maxTokens } : {}),
|
|
151
|
+
...(timeoutMs ? { maxRetries: opts.maxRetries ?? 0 } : {}),
|
|
46
152
|
};
|
|
153
|
+
// The request timeout lives in a different slot per wrapper: ChatOpenAI
|
|
154
|
+
// reads `timeout` as a constructor field, but ChatAnthropic ignores it
|
|
155
|
+
// there — its slot is `clientOptions.timeout`, which the wrapper spreads
|
|
156
|
+
// into the createClient factory options and (on the default factory) the
|
|
157
|
+
// SDK constructor. This split is what makes STIGMER_LLM_REQUEST_TIMEOUT_MS
|
|
158
|
+
// bound every path; putting `timeout` in the shared constructor spread is
|
|
159
|
+
// the exact regression that made it inert for Anthropic (T02 finding 2).
|
|
160
|
+
// The `maxRetries` half above stays constructor-level for both wrappers:
|
|
161
|
+
// that is LangChain's own retry knob, distinct from the SDK-level
|
|
162
|
+
// maxRetries the factories receive.
|
|
163
|
+
const anthropicClientOptions = {
|
|
164
|
+
...(timeoutMs ? { timeout: timeoutMs } : {}),
|
|
165
|
+
...(baseUrl ? { baseURL: baseUrl } : {}),
|
|
166
|
+
...(headers ? { defaultHeaders: headers } : {}),
|
|
167
|
+
};
|
|
168
|
+
const anthropicClientOptionsField = Object.keys(anthropicClientOptions).length > 0
|
|
169
|
+
? { clientOptions: anthropicClientOptions }
|
|
170
|
+
: {};
|
|
47
171
|
// The two SDKs name the transport-override block differently (OpenAI:
|
|
48
172
|
// `configuration`, Anthropic: `clientOptions`) — encapsulating that here is
|
|
49
173
|
// the whole point, since the shape mismatch is where bugs used to hide.
|
|
@@ -51,6 +175,7 @@ export async function buildChatModel(opts) {
|
|
|
51
175
|
? new ChatOpenAI({
|
|
52
176
|
model: apiModelId,
|
|
53
177
|
...common,
|
|
178
|
+
...(timeoutMs ? { timeout: timeoutMs } : {}),
|
|
54
179
|
...(baseUrl || headers
|
|
55
180
|
? {
|
|
56
181
|
configuration: {
|
|
@@ -60,18 +185,24 @@ export async function buildChatModel(opts) {
|
|
|
60
185
|
}
|
|
61
186
|
: {}),
|
|
62
187
|
})
|
|
63
|
-
:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
188
|
+
: backendCreateClient
|
|
189
|
+
? // Backend adapter: the translated id is wire detail only — each
|
|
190
|
+
// client moves it from the JSON body into its URL path. The waiver
|
|
191
|
+
// in ChatAnthropic (an API key is not required when createClient is
|
|
192
|
+
// provided) is what lets this construct with no ANTHROPIC_API_KEY.
|
|
193
|
+
// (Backend mode never has a proxy — see the precedence rule above —
|
|
194
|
+
// so the clientOptions here carry at most the timeout.)
|
|
195
|
+
new ChatAnthropic({
|
|
196
|
+
model: wireModelId,
|
|
197
|
+
...common,
|
|
198
|
+
...anthropicClientOptionsField,
|
|
199
|
+
createClient: backendCreateClient,
|
|
200
|
+
})
|
|
201
|
+
: new ChatAnthropic({
|
|
202
|
+
model: apiModelId,
|
|
203
|
+
...common,
|
|
204
|
+
...anthropicClientOptionsField,
|
|
205
|
+
});
|
|
75
206
|
return { model, provider, apiModelId };
|
|
76
207
|
}
|
|
77
208
|
//# sourceMappingURL=model-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-client.js","sourceRoot":"","sources":["../../src/shared/model-client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"model-client.js","sourceRoot":"","sources":["../../src/shared/model-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,GAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,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,2BAA2B;aAC/B,CAAC,CAAC;IAET,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* status mapping, otherwise the proxy's 503 would classify as a retryable
|
|
25
25
|
* 5xx and waste Temporal retries against a dead platform account.
|
|
26
26
|
*/
|
|
27
|
+
import { parseAnthropicBackend, BACKEND_DOC_URL, BEDROCK_INFERENCE_PREFIX_ENV, FOUNDRY_DEPLOYMENT_MAP_ENV, FOUNDRY_RESOURCE_ENV, } from "./llm-backend.js";
|
|
27
28
|
/**
|
|
28
29
|
* Machine-readable code the cloud proxy embeds in rewritten platform-fault
|
|
29
30
|
* error messages. The message text is the contract carrier — it is the one
|
|
@@ -62,6 +63,7 @@ export function unwrapModelError(err) {
|
|
|
62
63
|
export function classifyModelCallError(err, ctx) {
|
|
63
64
|
const root = unwrapModelError(err);
|
|
64
65
|
const message = root instanceof Error ? root.message : String(root);
|
|
66
|
+
const backend = resolveDirectBackend(ctx);
|
|
65
67
|
// 1. Platform sentinel — before status mapping (see module doc).
|
|
66
68
|
if (message.includes(PLATFORM_CAPACITY_SENTINEL)) {
|
|
67
69
|
return {
|
|
@@ -70,6 +72,63 @@ export function classifyModelCallError(err, ctx) {
|
|
|
70
72
|
message: platformCapacityMessage(ctx),
|
|
71
73
|
};
|
|
72
74
|
}
|
|
75
|
+
// 1b. Backend credential acquisition — also before status mapping: these
|
|
76
|
+
// failures come from the auth library (thrown while adapting the
|
|
77
|
+
// request, usually with no HTTP status) and won't self-heal on retry.
|
|
78
|
+
// Raw, they read like library internals ("Could not load the default
|
|
79
|
+
// credentials"); the operator needs to hear "fix your cloud
|
|
80
|
+
// credentials".
|
|
81
|
+
if (backend === "vertex" && isGoogleCredentialMessage(message)) {
|
|
82
|
+
return {
|
|
83
|
+
code: "LLM_BACKEND_CREDENTIALS",
|
|
84
|
+
retryable: false,
|
|
85
|
+
message: `The vertex backend could not acquire Google credentials for ${modelLabel(ctx)}. ` +
|
|
86
|
+
`Set GOOGLE_APPLICATION_CREDENTIALS to a service-account key, or run on a GCP ` +
|
|
87
|
+
`identity (workload identity / metadata server). ANTHROPIC_VERTEX_PROJECT_ID is ` +
|
|
88
|
+
`only needed when the credentials don't carry a project. See ${BACKEND_DOC_URL}. ` +
|
|
89
|
+
`Underlying error: ${message}`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
if (backend === "bedrock" && isAwsCredentialMessage(message)) {
|
|
93
|
+
return {
|
|
94
|
+
code: "LLM_BACKEND_CREDENTIALS",
|
|
95
|
+
retryable: false,
|
|
96
|
+
message: `The bedrock backend could not acquire AWS credentials for ${modelLabel(ctx)}. ` +
|
|
97
|
+
`Provide credentials through the standard AWS chain (environment keys, an IAM ` +
|
|
98
|
+
`role / IRSA, config files) or set AWS_BEARER_TOKEN_BEDROCK. See ${BACKEND_DOC_URL}. ` +
|
|
99
|
+
`Underlying error: ${message}`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (backend === "foundry" && isFoundryCredentialMessage(message)) {
|
|
103
|
+
// Only the keyless Entra path can land here: API-key failures arrive
|
|
104
|
+
// as HTTP 401s (status arm below), while a failing token provider
|
|
105
|
+
// throws statusless from inside the Foundry SDK's authHeaders.
|
|
106
|
+
return {
|
|
107
|
+
code: "LLM_BACKEND_CREDENTIALS",
|
|
108
|
+
retryable: false,
|
|
109
|
+
message: `The foundry backend could not acquire a Microsoft Entra ID token for ${modelLabel(ctx)}. ` +
|
|
110
|
+
`Give the runner an Azure identity the credential chain can resolve (workload ` +
|
|
111
|
+
`identity / managed identity, service-principal env vars, or az login), or set ` +
|
|
112
|
+
`ANTHROPIC_FOUNDRY_API_KEY to use API-key auth instead. See ${BACKEND_DOC_URL}. ` +
|
|
113
|
+
`Underlying error: ${message}`,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
// 1c. Bedrock's inference-profile rejection — a config condition, not a
|
|
117
|
+
// bad request: newer Claude models cannot be invoked by bare model id
|
|
118
|
+
// (AWS lists their in-region endpoint as N/A). The operator remedy is
|
|
119
|
+
// one env var, so say exactly that instead of relaying AWS prose that
|
|
120
|
+
// talks about ARNs and provisioned throughput.
|
|
121
|
+
if (backend === "bedrock" && isBedrockInferenceProfileMessage(message)) {
|
|
122
|
+
return {
|
|
123
|
+
code: "LLM_BACKEND_MODEL_ROUTING",
|
|
124
|
+
retryable: false,
|
|
125
|
+
message: `Bedrock requires an inference profile for ${modelLabel(ctx)} — the bare model ` +
|
|
126
|
+
`id cannot be invoked on-demand. Set ${BEDROCK_INFERENCE_PREFIX_ENV} to your ` +
|
|
127
|
+
`deployment's geography (e.g. "us", "eu", or "global"), or map this model ` +
|
|
128
|
+
`explicitly in STIGMER_BEDROCK_MODEL_MAP. See ${BACKEND_DOC_URL}. ` +
|
|
129
|
+
`Underlying error: ${message}`,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
73
132
|
// 2. Provider billing prose. In direct mode this is the user's own
|
|
74
133
|
// account and the fix is theirs. In proxy mode these patterns should
|
|
75
134
|
// never appear (the proxy rewrites them), but a version-skewed proxy
|
|
@@ -97,7 +156,7 @@ export function classifyModelCallError(err, ctx) {
|
|
|
97
156
|
? root.status
|
|
98
157
|
: undefined;
|
|
99
158
|
if (status !== undefined) {
|
|
100
|
-
return classifyByStatus(status, message, ctx);
|
|
159
|
+
return classifyByStatus(status, message, ctx, backend);
|
|
101
160
|
}
|
|
102
161
|
// 4. Connection/timeout heuristics on the root error's class name. Strict
|
|
103
162
|
// (SDK class names only) unless the caller vouches that every error it
|
|
@@ -130,7 +189,7 @@ export function classifyModelCallError(err, ctx) {
|
|
|
130
189
|
* internally with backoff; retrying on top causes duplicates
|
|
131
190
|
* - 5xx: retryable — transient provider outages
|
|
132
191
|
*/
|
|
133
|
-
function classifyByStatus(status, rawMessage, ctx) {
|
|
192
|
+
function classifyByStatus(status, rawMessage, ctx, backend) {
|
|
134
193
|
const context = modelLabel(ctx);
|
|
135
194
|
switch (status) {
|
|
136
195
|
case 401:
|
|
@@ -140,7 +199,23 @@ function classifyByStatus(status, rawMessage, ctx) {
|
|
|
140
199
|
message: ctx.proxyMode
|
|
141
200
|
? `The Stigmer platform rejected this model call (authentication, HTTP 401) for ${context}. ` +
|
|
142
201
|
`Your session token may have expired — retry the execution, and contact support if it persists.`
|
|
143
|
-
|
|
202
|
+
// On a cloud backend the credential is a cloud identity — "check
|
|
203
|
+
// your API key" would send the operator hunting for a key that
|
|
204
|
+
// isn't in play.
|
|
205
|
+
: backend === "vertex"
|
|
206
|
+
? `Google rejected this Vertex AI call (authentication, HTTP 401) for ${context}. ` +
|
|
207
|
+
`The credentials are expired or not valid for this project — check ` +
|
|
208
|
+
`GOOGLE_APPLICATION_CREDENTIALS or the runner's GCP identity. See ${BACKEND_DOC_URL}.`
|
|
209
|
+
: backend === "bedrock"
|
|
210
|
+
? `AWS rejected this Bedrock call (authentication, HTTP 401) for ${context}. ` +
|
|
211
|
+
`The credentials are expired or invalid — check the runner's AWS identity ` +
|
|
212
|
+
`(environment keys, IAM role / IRSA) or AWS_BEARER_TOKEN_BEDROCK. See ${BACKEND_DOC_URL}.`
|
|
213
|
+
: backend === "foundry"
|
|
214
|
+
? `Azure rejected this Microsoft Foundry call (authentication, HTTP 401) for ${context}. ` +
|
|
215
|
+
`The credential is expired or not valid for this Foundry resource — check ` +
|
|
216
|
+
`ANTHROPIC_FOUNDRY_API_KEY (find it on the deployment's Details tab) or the ` +
|
|
217
|
+
`runner's Azure identity. See ${BACKEND_DOC_URL}.`
|
|
218
|
+
: `Authentication failed for ${context}. Check that your API key is valid and not expired.`,
|
|
144
219
|
};
|
|
145
220
|
case 403:
|
|
146
221
|
return {
|
|
@@ -149,13 +224,50 @@ function classifyByStatus(status, rawMessage, ctx) {
|
|
|
149
224
|
message: ctx.proxyMode
|
|
150
225
|
? `The Stigmer platform denied this model call (authorization, HTTP 403) for ${context}. ` +
|
|
151
226
|
`Verify this execution is permitted to use the model, and contact support if it persists.`
|
|
152
|
-
:
|
|
227
|
+
: backend === "vertex"
|
|
228
|
+
? `Vertex AI denied this call (HTTP 403) for ${context}. Grant the runner's ` +
|
|
229
|
+
`service account the "Vertex AI User" role (aiplatform.endpoints.predict) ` +
|
|
230
|
+
`in the target project. See ${BACKEND_DOC_URL}.`
|
|
231
|
+
: backend === "bedrock"
|
|
232
|
+
// The most common Bedrock setup mistake: Anthropic models must
|
|
233
|
+
// be enabled per account ("Model access" in the Bedrock console,
|
|
234
|
+
// including the use-case submission), on top of IAM.
|
|
235
|
+
? `Bedrock denied this call (HTTP 403) for ${context}. Enable this Claude model ` +
|
|
236
|
+
`under "Model access" in the Bedrock console (Anthropic models require a ` +
|
|
237
|
+
`use-case submission), and grant the runner's identity bedrock:InvokeModel ` +
|
|
238
|
+
`for the model and its inference profile. See ${BACKEND_DOC_URL}.`
|
|
239
|
+
: backend === "foundry"
|
|
240
|
+
? `Microsoft Foundry denied this call (HTTP 403) for ${context}. Grant the ` +
|
|
241
|
+
`runner's Azure identity the "Foundry User" (or "Cognitive Services User") ` +
|
|
242
|
+
`RBAC role on the Foundry resource. See ${BACKEND_DOC_URL}.`
|
|
243
|
+
: `Access denied for ${context}. Verify that your API key has permission to use this model.`,
|
|
153
244
|
};
|
|
154
245
|
case 404:
|
|
155
246
|
return {
|
|
156
247
|
code: "LLM_MODEL_NOT_FOUND",
|
|
157
248
|
retryable: false,
|
|
158
|
-
|
|
249
|
+
// The most common Vertex setup mistake: Claude models must be enabled
|
|
250
|
+
// per project in Model Garden, and availability varies by region.
|
|
251
|
+
message: backend === "vertex"
|
|
252
|
+
? `Model not found on Vertex AI: ${context}. Enable this Claude model for your ` +
|
|
253
|
+
`project in the Vertex AI Model Garden, and confirm it is available in ` +
|
|
254
|
+
`${describeVertexRegion()} — availability varies by region. See ${BACKEND_DOC_URL}.`
|
|
255
|
+
: backend === "bedrock"
|
|
256
|
+
? `Model not found on Bedrock: ${context}. Confirm the model is available in ` +
|
|
257
|
+
`${describeBedrockRegion()} — availability varies by region — and that the ` +
|
|
258
|
+
`resolved Bedrock id is right for your deployment (STIGMER_BEDROCK_MODEL_MAP ` +
|
|
259
|
+
`overrides, ${BEDROCK_INFERENCE_PREFIX_ENV} for inference profiles). See ${BACKEND_DOC_URL}.`
|
|
260
|
+
: backend === "foundry"
|
|
261
|
+
// The most common Foundry setup mistake: Foundry routes by
|
|
262
|
+
// DEPLOYMENT NAME, and deployments are created one by one in
|
|
263
|
+
// the portal — a model with no deployment (or a custom name)
|
|
264
|
+
// 404s even though the model itself exists on Foundry.
|
|
265
|
+
? `Model deployment not found on Microsoft Foundry: ${context}. Foundry routes ` +
|
|
266
|
+
`by deployment name — confirm a deployment for this model exists in ` +
|
|
267
|
+
`${describeFoundryResource()} (default deployment names are the dateless ` +
|
|
268
|
+
`model ids), or map it to your custom deployment name in ` +
|
|
269
|
+
`${FOUNDRY_DEPLOYMENT_MAP_ENV}. See ${BACKEND_DOC_URL}.`
|
|
270
|
+
: `Model not found: ${context}. Verify the model name is correct and available in your account.`,
|
|
159
271
|
};
|
|
160
272
|
case 400:
|
|
161
273
|
return {
|
|
@@ -207,6 +319,87 @@ export function describeExecutionError(err, ctx) {
|
|
|
207
319
|
errorMessage: root instanceof Error ? root.message : String(root),
|
|
208
320
|
};
|
|
209
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* The backend serving this direct-mode Anthropic call — the only condition
|
|
324
|
+
* under which a backend's specific arms may speak. Proxied calls and other
|
|
325
|
+
* providers read as "public" (no backend wording applies). The backend is
|
|
326
|
+
* resolved from env here (deployment-static, like the API keys
|
|
327
|
+
* model-client reads) rather than threaded through every activity's
|
|
328
|
+
* ModelErrorContext; an invalid var value also reads as public, since
|
|
329
|
+
* classification must never throw and invalid values are already fatal at
|
|
330
|
+
* the factories' preflight and at model construction.
|
|
331
|
+
*/
|
|
332
|
+
function resolveDirectBackend(ctx) {
|
|
333
|
+
if (ctx.proxyMode || ctx.provider !== "anthropic")
|
|
334
|
+
return "public";
|
|
335
|
+
const parsed = parseAnthropicBackend();
|
|
336
|
+
return parsed.ok ? parsed.backend : "public";
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Google credential-acquisition prose, matched against the raw message.
|
|
340
|
+
* Narrow by design (mirrors isProviderBillingMessage): pinned to
|
|
341
|
+
* google-auth-library's ADC failure, its project-detection failure, the
|
|
342
|
+
* Vertex SDK's own projectId error, and OAuth's invalid_grant (expired or
|
|
343
|
+
* revoked service-account key). A miss falls through to status
|
|
344
|
+
* classification — never worse than the raw error.
|
|
345
|
+
*/
|
|
346
|
+
function isGoogleCredentialMessage(message) {
|
|
347
|
+
const lower = message.toLowerCase();
|
|
348
|
+
return (lower.includes("could not load the default credentials")
|
|
349
|
+
|| lower.includes("unable to detect a project id")
|
|
350
|
+
|| lower.includes("no projectid was given")
|
|
351
|
+
|| lower.includes("invalid_grant"));
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* AWS credential-acquisition prose, matched against the raw message.
|
|
355
|
+
* Narrow by design (mirrors isGoogleCredentialMessage): pinned to the AWS
|
|
356
|
+
* credential provider chain's terminal failure
|
|
357
|
+
* (@aws-sdk/credential-providers' CredentialsProviderError wordings) and
|
|
358
|
+
* the SigV4 signer's invalid-shape error. A miss falls through to status
|
|
359
|
+
* classification — never worse than the raw error.
|
|
360
|
+
*/
|
|
361
|
+
function isAwsCredentialMessage(message) {
|
|
362
|
+
const lower = message.toLowerCase();
|
|
363
|
+
return (lower.includes("could not load credentials from any providers")
|
|
364
|
+
|| lower.includes("credential is missing")
|
|
365
|
+
|| lower.includes("resolved credential object is not valid"));
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Bedrock's bare-model-id rejection prose (HTTP 400 ValidationException):
|
|
369
|
+
* "Invocation of model ID … with on-demand throughput isn't supported.
|
|
370
|
+
* Retry your request with the ID or ARN of an inference profile …".
|
|
371
|
+
* Matched narrowly on the phrase that only this condition carries.
|
|
372
|
+
*/
|
|
373
|
+
function isBedrockInferenceProfileMessage(message) {
|
|
374
|
+
return message.toLowerCase().includes("on-demand throughput isn't supported");
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Entra ID token-acquisition prose, matched against the raw message.
|
|
378
|
+
* Narrow by design (mirrors the Google/AWS matchers), and narrower than it
|
|
379
|
+
* looks: the Foundry SDK wraps EVERY token-provider failure — whatever
|
|
380
|
+
* @azure/identity's credential chain threw — in this one prefix before
|
|
381
|
+
* rethrowing (pinned by foundry-seam.test.ts), so a single phrase covers
|
|
382
|
+
* the whole family. A miss falls through to status classification — never
|
|
383
|
+
* worse than the raw error.
|
|
384
|
+
*/
|
|
385
|
+
function isFoundryCredentialMessage(message) {
|
|
386
|
+
return message.toLowerCase().includes("failed to get token from azureadtokenprovider");
|
|
387
|
+
}
|
|
388
|
+
/** "region {value}" when CLOUD_ML_REGION is set, else a pointer to the var. */
|
|
389
|
+
function describeVertexRegion() {
|
|
390
|
+
const region = process.env.CLOUD_ML_REGION?.trim();
|
|
391
|
+
return region ? `region "${region}"` : "your CLOUD_ML_REGION";
|
|
392
|
+
}
|
|
393
|
+
/** "region {value}" when AWS_REGION is set, else a pointer to the var. */
|
|
394
|
+
function describeBedrockRegion() {
|
|
395
|
+
const region = process.env.AWS_REGION?.trim();
|
|
396
|
+
return region ? `region "${region}"` : "your AWS_REGION";
|
|
397
|
+
}
|
|
398
|
+
/** `resource "{value}"` when the resource var is set, else a generic label. */
|
|
399
|
+
function describeFoundryResource() {
|
|
400
|
+
const resource = process.env[FOUNDRY_RESOURCE_ENV]?.trim();
|
|
401
|
+
return resource ? `resource "${resource}"` : "your Foundry resource";
|
|
402
|
+
}
|
|
210
403
|
/**
|
|
211
404
|
* Provider billing-exhaustion prose, matched against the raw message. Narrow
|
|
212
405
|
* by design: these phrases are pinned to real provider wordings (Anthropic's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-error.js","sourceRoot":"","sources":["../../src/shared/model-error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CAAC,QAAQ;QAAE,OAAO,cAAc,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC;IAC7D,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -16,3 +16,5 @@ export interface ModelPricing {
|
|
|
16
16
|
}
|
|
17
17
|
export declare const DEFAULT_PRICING: ModelPricing;
|
|
18
18
|
export declare function getPricingTable(): Promise<readonly ModelPricing[]>;
|
|
19
|
+
/** Exposed for testing — resets the in-memory cache. */
|
|
20
|
+
export declare function _resetPricingCache(): void;
|
|
@@ -5,8 +5,13 @@
|
|
|
5
5
|
* with pricing info, and caches the result. Falls back to conservative
|
|
6
6
|
* default pricing if the API is unreachable.
|
|
7
7
|
*/
|
|
8
|
-
import { resolveModelRegistryUrl, buildRegistryHeaders } from "./registry-endpoint.js";
|
|
8
|
+
import { resolveModelRegistryUrl, buildRegistryHeaders, REGISTRY_RETRY_POLICY, } from "./registry-endpoint.js";
|
|
9
|
+
import { fetchWithRetry } from "./http-retry.js";
|
|
9
10
|
const CACHE_TTL_MS = 3_600_000;
|
|
11
|
+
// Failed fetches are cached much shorter than successes (the model-registry.ts
|
|
12
|
+
// policy): a transient failure must not pin DEFAULT_PRICING — wrong rates for
|
|
13
|
+
// cost tracking — for a full hour.
|
|
14
|
+
const FAILURE_CACHE_TTL_MS = 60_000;
|
|
10
15
|
export const DEFAULT_PRICING = {
|
|
11
16
|
model: "unknown",
|
|
12
17
|
displayName: "Unknown",
|
|
@@ -37,7 +42,7 @@ function parsePricingTable(json) {
|
|
|
37
42
|
}));
|
|
38
43
|
}
|
|
39
44
|
async function fetchFromApi() {
|
|
40
|
-
const res = await
|
|
45
|
+
const res = await fetchWithRetry(resolveModelRegistryUrl(), { headers: buildRegistryHeaders() }, REGISTRY_RETRY_POLICY);
|
|
41
46
|
if (!res.ok)
|
|
42
47
|
throw new Error(`Model registry fetch failed: ${res.status}`);
|
|
43
48
|
const data = await res.json();
|
|
@@ -61,7 +66,7 @@ export async function getPricingTable() {
|
|
|
61
66
|
.catch((err) => {
|
|
62
67
|
console.warn(`Failed to fetch model registry, using default pricing: ${err}`);
|
|
63
68
|
const fallback = [DEFAULT_PRICING];
|
|
64
|
-
cache = { data: fallback, expiresAt: Date.now() +
|
|
69
|
+
cache = { data: fallback, expiresAt: Date.now() + FAILURE_CACHE_TTL_MS };
|
|
65
70
|
return fallback;
|
|
66
71
|
})
|
|
67
72
|
.finally(() => {
|
|
@@ -69,4 +74,9 @@ export async function getPricingTable() {
|
|
|
69
74
|
});
|
|
70
75
|
return inflightFetch;
|
|
71
76
|
}
|
|
77
|
+
/** Exposed for testing — resets the in-memory cache. */
|
|
78
|
+
export function _resetPricingCache() {
|
|
79
|
+
cache = null;
|
|
80
|
+
inflightFetch = null;
|
|
81
|
+
}
|
|
72
82
|
//# sourceMappingURL=model-pricing-data.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-pricing-data.js","sourceRoot":"","sources":["../../src/shared/model-pricing-data.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA0BH,OAAO,
|
|
1
|
+
{"version":3,"file":"model-pricing-data.js","sourceRoot":"","sources":["../../src/shared/model-pricing-data.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA0BH,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,+EAA+E;AAC/E,8EAA8E;AAC9E,mCAAmC;AACnC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAEpC,MAAM,CAAC,MAAM,eAAe,GAAiB;IAC3C,KAAK,EAAE,SAAS;IAChB,WAAW,EAAE,SAAS;IACtB,QAAQ,EAAE,UAAU;IACpB,oBAAoB,EAAE,IAAI;IAC1B,qBAAqB,EAAE,IAAI;IAC3B,yBAAyB,EAAE,IAAI;IAC/B,wBAAwB,EAAE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
*/
|
|
12
|
-
import { resolveModelRegistryUrl, buildRegistryHeaders } from "./registry-endpoint.js";
|
|
12
|
+
import { resolveModelRegistryUrl, buildRegistryHeaders, REGISTRY_RETRY_POLICY, } from "./registry-endpoint.js";
|
|
13
|
+
import { fetchWithRetry } from "./http-retry.js";
|
|
13
14
|
const CACHE_TTL_MS = 3_600_000;
|
|
14
15
|
// Failed fetches are cached much shorter than successes: a transient failure
|
|
15
16
|
// must not poison id -> apiModelId resolution (and thereby fail every llm_call
|
|
@@ -47,7 +48,7 @@ function parseVisionCapability(capabilities) {
|
|
|
47
48
|
}
|
|
48
49
|
async function fetchRegistry() {
|
|
49
50
|
const url = resolveModelRegistryUrl();
|
|
50
|
-
const res = await
|
|
51
|
+
const res = await fetchWithRetry(url, { headers: buildRegistryHeaders() }, REGISTRY_RETRY_POLICY);
|
|
51
52
|
if (!res.ok)
|
|
52
53
|
throw new Error(`Model registry fetch failed: ${res.status}`);
|
|
53
54
|
const data = await res.json();
|