@stigmer/runner 3.11.0 → 3.12.0
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 +2 -0
- package/dist/.build-fingerprint +1 -1
- package/dist/activities/discover-mcp-server.d.ts +7 -0
- package/dist/activities/discover-mcp-server.js +6 -4
- 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/attachment-resolver.d.ts +11 -0
- package/dist/activities/execute-cursor/attachment-resolver.js +8 -0
- 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 +0 -1
- package/dist/activities/execute-cursor/blueprint-resolver.js.map +1 -1
- package/dist/activities/execute-cursor/error-classifier.d.ts +19 -0
- package/dist/activities/execute-cursor/error-classifier.js +34 -3
- package/dist/activities/execute-cursor/error-classifier.js.map +1 -1
- package/dist/activities/execute-cursor/index.d.ts +52 -12
- package/dist/activities/execute-cursor/index.js +141 -67
- package/dist/activities/execute-cursor/index.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 +48 -11
- package/dist/activities/execute-cursor/prompt-builder.js +57 -10
- 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-deep-agent/attachment-injector.d.ts +11 -0
- package/dist/activities/execute-deep-agent/attachment-injector.js +7 -1
- package/dist/activities/execute-deep-agent/attachment-injector.js.map +1 -1
- package/dist/activities/execute-deep-agent/index.js +0 -15
- package/dist/activities/execute-deep-agent/index.js.map +1 -1
- package/dist/activities/execute-deep-agent/mcp-gate.d.ts +0 -2
- package/dist/activities/execute-deep-agent/mcp-gate.js +0 -1
- package/dist/activities/execute-deep-agent/mcp-gate.js.map +1 -1
- package/dist/activities/execute-deep-agent/prompt-builder.d.ts +7 -8
- package/dist/activities/execute-deep-agent/prompt-builder.js +14 -7
- package/dist/activities/execute-deep-agent/prompt-builder.js.map +1 -1
- package/dist/activities/execute-deep-agent/setup.d.ts +0 -10
- package/dist/activities/execute-deep-agent/setup.js +22 -49
- 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.js +7 -1
- package/dist/activities/execute-deep-agent/subagent-transformer.js.map +1 -1
- package/dist/activities/execute-deep-agent/subagent-wiring.d.ts +17 -3
- package/dist/activities/execute-deep-agent/subagent-wiring.js +14 -2
- package/dist/activities/execute-deep-agent/subagent-wiring.js.map +1 -1
- package/dist/activities/hydrate-workflow-execution.js +8 -5
- 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/bootstrap.js +5 -0
- package/dist/bootstrap.js.map +1 -1
- package/dist/client/stigmer-client.d.ts +83 -26
- package/dist/client/stigmer-client.js +88 -24
- package/dist/client/stigmer-client.js.map +1 -1
- package/dist/config.d.ts +6 -5
- package/dist/config.js.map +1 -1
- package/dist/encryption/config.d.ts +41 -9
- package/dist/encryption/config.js +63 -23
- package/dist/encryption/config.js.map +1 -1
- 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 +2 -1
- package/dist/payload-codecs.js +7 -3
- package/dist/payload-codecs.js.map +1 -1
- package/dist/runner-manager.js +17 -3
- package/dist/runner-manager.js.map +1 -1
- package/dist/runner.js +7 -3
- package/dist/runner.js.map +1 -1
- package/dist/shared/artifact-storage.d.ts +34 -1
- package/dist/shared/artifact-storage.js +53 -10
- package/dist/shared/artifact-storage.js.map +1 -1
- package/dist/shared/attachment-download-urls.d.ts +62 -0
- package/dist/shared/attachment-download-urls.js +79 -0
- package/dist/shared/attachment-download-urls.js.map +1 -0
- package/dist/shared/channel-attachment.d.ts +1 -1
- package/dist/shared/channel-attachment.js +1 -1
- package/dist/shared/checkpointer/http-saver.d.ts +4 -20
- package/dist/shared/checkpointer/http-saver.js +15 -57
- package/dist/shared/checkpointer/http-saver.js.map +1 -1
- package/dist/shared/conversation-attachment.d.ts +2 -3
- package/dist/shared/conversation-attachment.js +2 -3
- 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/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 +51 -9
- package/dist/shared/http-retry.js +60 -9
- package/dist/shared/http-retry.js.map +1 -1
- package/dist/shared/mcp-manager.d.ts +8 -4
- package/dist/shared/mcp-manager.js +30 -4
- package/dist/shared/mcp-manager.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/mcp-transport-guard.d.ts +2 -2
- package/dist/shared/mcp-transport-guard.js +2 -2
- package/dist/shared/model-client.d.ts +6 -0
- package/dist/shared/model-client.js +14 -3
- package/dist/shared/model-client.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 +7 -0
- package/dist/shared/plan-mode-permissions.js +7 -0
- package/dist/shared/plan-mode-permissions.js.map +1 -1
- 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/shared/synthesized-attachment.d.ts +4 -4
- package/dist/shared/synthesized-attachment.js +4 -4
- 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/workflows/connect-mcp-server.js +2 -0
- package/dist/workflows/connect-mcp-server.js.map +1 -1
- package/dist/workflows/types.d.ts +8 -0
- package/package.json +3 -4
- package/src/__test-utils__/__tests__/vitest-global-setup.test.ts +37 -0
- package/src/__test-utils__/fake-artifact-storage.ts +10 -1
- package/src/__test-utils__/vitest-global-setup.ts +50 -0
- package/src/__tests__/bootstrap.test.ts +43 -0
- package/src/__tests__/encryption-codec.test.ts +53 -0
- package/src/__tests__/preflight.test.ts +15 -0
- package/src/activities/__tests__/discover-mcp-server.test.ts +39 -1
- package/src/activities/__tests__/error-classifier.test.ts +94 -2
- package/src/activities/__tests__/run-command.test.ts +221 -0
- package/src/activities/discover-mcp-server.ts +16 -2
- package/src/activities/emit-event.ts +65 -21
- package/src/activities/execute-cursor/__tests__/attachment-resolver.test.ts +63 -3
- package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +173 -31
- package/src/activities/execute-cursor/__tests__/model-pricing.test.ts +62 -1
- package/src/activities/execute-cursor/__tests__/turn-recovery.test.ts +160 -0
- package/src/activities/execute-cursor/attachment-resolver.ts +24 -0
- package/src/activities/execute-cursor/blueprint-resolver.ts +1 -10
- package/src/activities/execute-cursor/error-classifier.ts +40 -3
- package/src/activities/execute-cursor/index.ts +175 -74
- package/src/activities/execute-cursor/model-pricing-data.ts +22 -3
- package/src/activities/execute-cursor/prompt-builder.ts +89 -22
- package/src/activities/execute-cursor/turn-recovery.ts +208 -0
- package/src/activities/execute-deep-agent/__tests__/attachment-injector.test.ts +105 -0
- package/src/activities/execute-deep-agent/__tests__/hitl-reject.test.ts +0 -2
- package/src/activities/execute-deep-agent/__tests__/hitl-resume-approve-all.test.ts +0 -1
- package/src/activities/execute-deep-agent/__tests__/hitl-resume-history.test.ts +0 -1
- package/src/activities/execute-deep-agent/__tests__/mcp-gate.test.ts +2 -7
- 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 +71 -0
- package/src/activities/execute-deep-agent/__tests__/sequential-gate-resume.test.ts +0 -1
- 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 +22 -17
- package/src/activities/execute-deep-agent/attachment-injector.ts +20 -1
- package/src/activities/execute-deep-agent/index.ts +0 -19
- package/src/activities/execute-deep-agent/mcp-gate.ts +0 -3
- package/src/activities/execute-deep-agent/prompt-builder.ts +27 -15
- package/src/activities/execute-deep-agent/setup.ts +22 -73
- package/src/activities/execute-deep-agent/shell-env.ts +8 -9
- package/src/activities/execute-deep-agent/subagent-transformer.ts +7 -1
- package/src/activities/execute-deep-agent/subagent-wiring.ts +26 -3
- package/src/activities/hydrate-workflow-execution.ts +8 -5
- package/src/activities/run-command.ts +25 -12
- package/src/activities/run-env.ts +79 -0
- package/src/bootstrap.ts +5 -0
- package/src/client/__tests__/stigmer-client.test.ts +104 -5
- package/src/client/stigmer-client.ts +128 -29
- package/src/config.ts +6 -5
- package/src/encryption/config.ts +87 -23
- 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 +8 -2
- package/src/runner-manager.ts +21 -3
- package/src/runner.ts +7 -3
- package/src/shared/__tests__/artifact-storage.test.ts +154 -2
- package/src/shared/__tests__/attachment-download-urls.test.ts +70 -0
- package/src/shared/__tests__/channel-attachment.test.ts +2 -2
- package/src/shared/__tests__/conversation-catchup.test.ts +24 -0
- package/src/shared/__tests__/http-retry.test.ts +5 -4
- package/src/shared/__tests__/mcp-manager.test.ts +53 -13
- package/src/shared/__tests__/mcp-schema-sanitizer.test.ts +267 -0
- package/src/shared/__tests__/model-client.test.ts +46 -0
- 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 +19 -41
- package/src/shared/artifact-storage.ts +86 -10
- package/src/shared/attachment-download-urls.ts +98 -0
- package/src/shared/channel-attachment.ts +1 -1
- package/src/shared/checkpointer/http-saver.ts +15 -60
- package/src/shared/conversation-attachment.ts +2 -3
- package/src/shared/conversation-catchup.ts +39 -6
- package/src/shared/grpc-retry.ts +5 -1
- package/src/shared/http-retry.ts +98 -9
- package/src/shared/mcp-manager.ts +35 -4
- package/src/shared/mcp-schema-sanitizer.ts +224 -0
- package/src/shared/mcp-transport-guard.ts +2 -2
- package/src/shared/model-client.ts +21 -3
- package/src/shared/model-pricing-data.ts +22 -3
- package/src/shared/model-registry.ts +7 -2
- package/src/shared/plan-mode-permissions.ts +7 -0
- package/src/shared/registry-endpoint.ts +27 -0
- package/src/shared/runner-credential-keys.ts +46 -0
- package/src/shared/synthesized-attachment.ts +4 -4
- package/src/workflow-engine/__tests__/tasks/emit-event.test.ts +127 -49
- package/src/workflow-engine/resolve.ts +48 -2
- package/src/workflows/__tests__/connect-mcp-server.test.ts +25 -0
- package/src/workflows/connect-mcp-server.ts +2 -0
- 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/dist/shared/datastore-attachment.d.ts +0 -99
- package/dist/shared/datastore-attachment.js +0 -184
- package/dist/shared/datastore-attachment.js.map +0 -1
- package/src/activities/execute-cursor/mcp-config.ts +0 -66
- package/src/activities/execute-deep-agent/__tests__/datastore-degradation.test.ts +0 -104
- package/src/shared/__tests__/datastore-attachment.test.ts +0 -293
- package/src/shared/datastore-attachment.ts +0 -209
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP error classification
|
|
2
|
+
* HTTP error classification AND the shared bounded-backoff loop for
|
|
3
|
+
* side-channel proxy retries.
|
|
3
4
|
*
|
|
4
5
|
* The runner reaches stigmer-service's Side-Channel Proxy (`/v1/proxy/...`)
|
|
5
|
-
* over plain `fetch` from several clients
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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.
|
|
12
15
|
*
|
|
13
16
|
* The policy is grounded in what the proxy actually emits, not HTTP folklore.
|
|
14
17
|
* CheckpointerProxyController returns exactly four deterministic errors —
|
|
@@ -17,7 +20,10 @@
|
|
|
17
20
|
* reach the runner only as 5xx (Spring's error handler, ingress 502-504),
|
|
18
21
|
* 408/429 (infrastructure between runner and service), or as network-level
|
|
19
22
|
* fetch rejections. 401/403 stay terminal deliberately: retrying cannot fix
|
|
20
|
-
* an expired or rejected credential.
|
|
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.
|
|
21
27
|
*/
|
|
22
28
|
/**
|
|
23
29
|
* True for HTTP statuses that signal a transient condition worth retrying:
|
|
@@ -47,4 +53,49 @@ export function isRetryableFetchError(err) {
|
|
|
47
53
|
return true;
|
|
48
54
|
return err instanceof Error && err.name === "TimeoutError";
|
|
49
55
|
}
|
|
56
|
+
function defaultDelay(ms) {
|
|
57
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* `fetch` with bounded exponential backoff on transient failures and a
|
|
61
|
+
* per-request abort timeout.
|
|
62
|
+
*
|
|
63
|
+
* Composition contract: on a non-retryable status — or when the budget is
|
|
64
|
+
* exhausted on a retryable one — the last `Response` is RETURNED, so every
|
|
65
|
+
* call site keeps its own `resp.ok` / 404 handling unchanged; this wrapper
|
|
66
|
+
* changes when a response arrives, never what call sites do with it. It
|
|
67
|
+
* throws only what `fetch` itself throws: a network-level rejection that is
|
|
68
|
+
* non-retryable or has exhausted the budget.
|
|
69
|
+
*/
|
|
70
|
+
export async function fetchWithRetry(url, init, policy) {
|
|
71
|
+
const delay = policy.delayFn ?? defaultDelay;
|
|
72
|
+
for (let attempt = 0;; attempt++) {
|
|
73
|
+
const canRetry = attempt < policy.maxRetries;
|
|
74
|
+
let resp;
|
|
75
|
+
try {
|
|
76
|
+
resp = await fetch(url, {
|
|
77
|
+
...init,
|
|
78
|
+
signal: AbortSignal.timeout(policy.requestTimeoutMs),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
if (canRetry && isRetryableFetchError(err)) {
|
|
83
|
+
await backOff(policy, delay, attempt, String(err));
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
throw err;
|
|
87
|
+
}
|
|
88
|
+
if (canRetry && isRetryableHttpStatus(resp.status)) {
|
|
89
|
+
await backOff(policy, delay, attempt, `HTTP ${resp.status} ${resp.statusText}`);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
return resp;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function backOff(policy, delay, attempt, reason) {
|
|
96
|
+
const delayMs = policy.baseDelayMs * Math.pow(policy.backoffFactor, attempt);
|
|
97
|
+
console.warn(`[${policy.label}] retryable failure ` +
|
|
98
|
+
`(attempt ${attempt + 1}/${policy.maxRetries + 1}, retry in ${delayMs}ms): ${reason}`);
|
|
99
|
+
await delay(delayMs);
|
|
100
|
+
}
|
|
50
101
|
//# sourceMappingURL=http-retry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-retry.js","sourceRoot":"","sources":["../../src/shared/http-retry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"http-retry.js","sourceRoot":"","sources":["../../src/shared/http-retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,OAAO,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC;AAC3D,CAAC;AAED;;;;;;;;;;;;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C,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;YAChF,SAAS;QACX,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,KAAK,UAAU,OAAO,CACpB,MAAwB,EACxB,KAAoC,EACpC,OAAe,EACf,MAAc;IAEd,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC7E,OAAO,CAAC,IAAI,CACV,IAAI,MAAM,CAAC,KAAK,sBAAsB;QACtC,YAAY,OAAO,GAAG,CAAC,IAAI,MAAM,CAAC,UAAU,GAAG,CAAC,cAAc,OAAO,QAAQ,MAAM,EAAE,CACtF,CAAC;IACF,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* Wraps @langchain/mcp-adapters MultiServerMCPClient with:
|
|
5
5
|
* - Conversion from ResolvedMcpServer[] to the SDK's Connection config
|
|
6
6
|
* - Proper async cleanup via close()
|
|
7
|
+
* - Input-schema sanitization of unicode-invalid regex patterns
|
|
8
|
+
* (issue #420; semantics in shared/mcp-schema-sanitizer.ts) — a vendor
|
|
9
|
+
* pattern that cannot compile under the /u flag must not leave its tool
|
|
10
|
+
* permanently uncallable
|
|
7
11
|
* - Tool filtering by each server's effective enabled_tools allow-list
|
|
8
12
|
* (issue #350; semantics in shared/mcp-enabled-tools.ts) — the model only
|
|
9
13
|
* ever sees the tools the agent's manifest enables
|
|
@@ -18,10 +22,10 @@
|
|
|
18
22
|
* (HOME, LOGNAME, PATH, SHELL, TERM, USER — getDefaultEnvironment in
|
|
19
23
|
* @modelcontextprotocol/sdk, merged under whatever we pass). The
|
|
20
24
|
* runner's own process env is never passed: it carries runner-internal
|
|
21
|
-
* credentials (
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
+
* credentials (enumerated in runner-credential-keys.ts) that no
|
|
26
|
+
* third-party MCP subprocess may see. A declared-empty env and an
|
|
27
|
+
* undeclared env are deliberately equivalent — both yield the SDK base
|
|
28
|
+
* environment.
|
|
25
29
|
*
|
|
26
30
|
* The Cursor execution path does NOT use this manager — it passes MCP
|
|
27
31
|
* configs directly to the Cursor SDK via toCursorMcpConfig(). This
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* Wraps @langchain/mcp-adapters MultiServerMCPClient with:
|
|
5
5
|
* - Conversion from ResolvedMcpServer[] to the SDK's Connection config
|
|
6
6
|
* - Proper async cleanup via close()
|
|
7
|
+
* - Input-schema sanitization of unicode-invalid regex patterns
|
|
8
|
+
* (issue #420; semantics in shared/mcp-schema-sanitizer.ts) — a vendor
|
|
9
|
+
* pattern that cannot compile under the /u flag must not leave its tool
|
|
10
|
+
* permanently uncallable
|
|
7
11
|
* - Tool filtering by each server's effective enabled_tools allow-list
|
|
8
12
|
* (issue #350; semantics in shared/mcp-enabled-tools.ts) — the model only
|
|
9
13
|
* ever sees the tools the agent's manifest enables
|
|
@@ -18,10 +22,10 @@
|
|
|
18
22
|
* (HOME, LOGNAME, PATH, SHELL, TERM, USER — getDefaultEnvironment in
|
|
19
23
|
* @modelcontextprotocol/sdk, merged under whatever we pass). The
|
|
20
24
|
* runner's own process env is never passed: it carries runner-internal
|
|
21
|
-
* credentials (
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
+
* credentials (enumerated in runner-credential-keys.ts) that no
|
|
26
|
+
* third-party MCP subprocess may see. A declared-empty env and an
|
|
27
|
+
* undeclared env are deliberately equivalent — both yield the SDK base
|
|
28
|
+
* environment.
|
|
25
29
|
*
|
|
26
30
|
* The Cursor execution path does NOT use this manager — it passes MCP
|
|
27
31
|
* configs directly to the Cursor SDK via toCursorMcpConfig(). This
|
|
@@ -31,6 +35,7 @@
|
|
|
31
35
|
*/
|
|
32
36
|
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
|
|
33
37
|
import { filterToolsByEnabledTools } from "./mcp-enabled-tools.js";
|
|
38
|
+
import { sanitizeSchemaPatterns } from "./mcp-schema-sanitizer.js";
|
|
34
39
|
/**
|
|
35
40
|
* Convert harness-agnostic ResolvedMcpServer[] into the
|
|
36
41
|
* MultiServerMCPClient connection config format.
|
|
@@ -80,6 +85,27 @@ export async function connectMcpServers(servers) {
|
|
|
80
85
|
}
|
|
81
86
|
const client = new MultiServerMCPClient(connectionConfig);
|
|
82
87
|
const discoveredToolMap = await client.initializeConnections();
|
|
88
|
+
// Drop unicode-invalid regex patterns from every discovered tool's input
|
|
89
|
+
// schema BEFORE anything downstream holds a reference (issue #420):
|
|
90
|
+
// @langchain/core re-validates against tool.schema on every invocation,
|
|
91
|
+
// so one vendor pattern that cannot compile under the /u flag would
|
|
92
|
+
// otherwise make its tool permanently uncallable. Semantics and the
|
|
93
|
+
// loosen-never-tighten invariant live in shared/mcp-schema-sanitizer.ts.
|
|
94
|
+
for (const [slug, discovered] of Object.entries(discoveredToolMap)) {
|
|
95
|
+
for (const tool of discovered) {
|
|
96
|
+
const droppedPatterns = sanitizeSchemaPatterns(tool.schema);
|
|
97
|
+
if (droppedPatterns.length > 0) {
|
|
98
|
+
console.warn(`[MCP] Server '${slug}' tool '${tool.name}': dropped ` +
|
|
99
|
+
`${droppedPatterns.length} regex pattern(s) that cannot compile ` +
|
|
100
|
+
`under the unicode flag — the tool stays callable, the server ` +
|
|
101
|
+
`still validates its own inputs (issue #420): ` +
|
|
102
|
+
droppedPatterns
|
|
103
|
+
.map((d) => `${d.location} ${JSON.stringify(d.pattern)}` +
|
|
104
|
+
(d.compilesWithoutUnicodeFlag ? "" : " (invalid without /u too)"))
|
|
105
|
+
.join(", "));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
83
109
|
// Enforce each server's effective enabled_tools allow-list (issue #350)
|
|
84
110
|
// HERE, before anything downstream sees the tools: the parent tool list,
|
|
85
111
|
// the approval gate's toolServerMap, and the sub-agent McpAccess filter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-manager.js","sourceRoot":"","sources":["../../src/shared/mcp-manager.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mcp-manager.js","sourceRoot":"","sources":["../../src/shared/mcp-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAI/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAA4B;IAE5B,MAAM,MAAM,GAA+B,EAAE,CAAC;IAE9C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,cAAc,KAAK,OAAO,EAAE,CAAC;YACtC,IAAI,CAAC,MAAM,CAAC,OAAO;gBAAE,SAAS;YAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACxD,OAAO,CAAC,GAAG,CACT,iBAAiB,MAAM,CAAC,IAAI,qCAAqC;oBACjE,mEAAmE;oBACnE,2CAA2C,CAC5C,CAAC;YACJ,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG;gBACpB,SAAS,EAAE,OAAO;gBAClB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE;gBACvB,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,GAAG,EAAE,MAAM,CAAC,GAAG;aAChB,CAAC;QACJ,CAAC;aAAM,IAAI,MAAM,CAAC,cAAc,KAAK,MAAM,IAAI,M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AAC,aAAa,CAAC;aAC5D,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;aAC1C,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unicode-flag regex sanitization for MCP tool input schemas (issue #420).
|
|
3
|
+
*
|
|
4
|
+
* Why this exists: real-world MCP servers ship JSON-schema `pattern` values
|
|
5
|
+
* that are legal as plain ECMAScript regexes but invalid under the unicode
|
|
6
|
+
* flag (PayPal's `^https\:\/\/` — `\:` is an invalid escape under /u).
|
|
7
|
+
* @langchain/core validates tool input on EVERY call with
|
|
8
|
+
* @cfworker/json-schema, which compiles patterns via `new RegExp(p, "u")`
|
|
9
|
+
* at exactly two uncaught sites: the `pattern` keyword and each
|
|
10
|
+
* `patternProperties` key. One bad vendor pattern therefore makes the tool
|
|
11
|
+
* permanently uncallable on the deep-agent path — every invocation dies
|
|
12
|
+
* with a cryptic SyntaxError before the tool is ever reached. (The third
|
|
13
|
+
* /u compile site, `format: "regex"`, validates instance values inside a
|
|
14
|
+
* try/catch and fails gracefully — not a crash surface.)
|
|
15
|
+
*
|
|
16
|
+
* The fix: at the deep-agent connect funnel (mcp-manager.ts
|
|
17
|
+
* connectMcpServers), drop every pattern that cannot compile under /u.
|
|
18
|
+
* Dropping is deliberate — rewriting to a /u-safe equivalent would need an
|
|
19
|
+
* Annex-B-aware regex transpiler, disproportionate machinery for what is
|
|
20
|
+
* best-effort client-side validation; the MCP server still validates its
|
|
21
|
+
* own inputs server-side. This mirrors the loosening posture of
|
|
22
|
+
* @langchain/mcp-adapters' own schema pipeline (dereferenceJsonSchema →
|
|
23
|
+
* simplifyJsonSchemaForLLM), which already normalizes schemas for this
|
|
24
|
+
* exact validator.
|
|
25
|
+
*
|
|
26
|
+
* THE INVARIANT: sanitization may only ever LOOSEN validation, never
|
|
27
|
+
* tighten it. Dropping a `patternProperties` entry naively would violate
|
|
28
|
+
* this — @cfworker marks pattern-matched keys as "evaluated" and routes
|
|
29
|
+
* unevaluated keys into the `additionalProperties` / `unevaluatedProperties`
|
|
30
|
+
* checks, so under `additionalProperties: false` the drop would flip a
|
|
31
|
+
* crash into a false REJECTION of valid inputs. Whenever a
|
|
32
|
+
* `patternProperties` entry is dropped, any restrictive
|
|
33
|
+
* `additionalProperties` / `unevaluatedProperties` at that schema level is
|
|
34
|
+
* therefore relaxed too.
|
|
35
|
+
*
|
|
36
|
+
* Scope: this sanitizer serves the EXECUTION path only. Discovery
|
|
37
|
+
* (activities/discover-mcp-server.ts) persists tool schemas verbatim from
|
|
38
|
+
* listTools — deliberately: the stored schema is the vendor's truth for
|
|
39
|
+
* display, and discovery never invokes tools, so it cannot hit the crash.
|
|
40
|
+
* Do not "extend" sanitization there.
|
|
41
|
+
*/
|
|
42
|
+
/** One dropped regex constraint, for the caller's log line. */
|
|
43
|
+
export interface DroppedPattern {
|
|
44
|
+
/** JSON-pointer-style path of the dropped constraint within the schema. */
|
|
45
|
+
location: string;
|
|
46
|
+
/** The pattern source that failed to compile under the unicode flag. */
|
|
47
|
+
pattern: string;
|
|
48
|
+
/**
|
|
49
|
+
* True when the pattern compiles WITHOUT the /u flag — vendor sloppiness
|
|
50
|
+
* (Annex B legacy syntax), the oss#420 class. False means the regex is
|
|
51
|
+
* broken outright; either way validation could only crash, so both drop.
|
|
52
|
+
*/
|
|
53
|
+
compilesWithoutUnicodeFlag: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Drop unicode-invalid regex patterns from a JSON schema, in place.
|
|
57
|
+
*
|
|
58
|
+
* Walks only schema positions (the recursion set is @cfworker's own
|
|
59
|
+
* validated-keyword list), so a property literally NAMED "pattern" under
|
|
60
|
+
* `properties` is never touched. The walker handles composition keywords
|
|
61
|
+
* (anyOf/allOf/oneOf/not/if-then-else) even though the adapter's
|
|
62
|
+
* simplifyJsonSchemaForLLM currently strips them, and carries a visited-set
|
|
63
|
+
* cycle guard even though the adapter's $ref inlining currently guarantees
|
|
64
|
+
* an acyclic result — correctness here must not depend on another
|
|
65
|
+
* package's internals holding across dependency bumps.
|
|
66
|
+
*
|
|
67
|
+
* Returns the dropped constraints (empty for clean schemas — the common
|
|
68
|
+
* case, which this walk leaves byte-identical).
|
|
69
|
+
*/
|
|
70
|
+
export declare function sanitizeSchemaPatterns(schema: unknown): DroppedPattern[];
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unicode-flag regex sanitization for MCP tool input schemas (issue #420).
|
|
3
|
+
*
|
|
4
|
+
* Why this exists: real-world MCP servers ship JSON-schema `pattern` values
|
|
5
|
+
* that are legal as plain ECMAScript regexes but invalid under the unicode
|
|
6
|
+
* flag (PayPal's `^https\:\/\/` — `\:` is an invalid escape under /u).
|
|
7
|
+
* @langchain/core validates tool input on EVERY call with
|
|
8
|
+
* @cfworker/json-schema, which compiles patterns via `new RegExp(p, "u")`
|
|
9
|
+
* at exactly two uncaught sites: the `pattern` keyword and each
|
|
10
|
+
* `patternProperties` key. One bad vendor pattern therefore makes the tool
|
|
11
|
+
* permanently uncallable on the deep-agent path — every invocation dies
|
|
12
|
+
* with a cryptic SyntaxError before the tool is ever reached. (The third
|
|
13
|
+
* /u compile site, `format: "regex"`, validates instance values inside a
|
|
14
|
+
* try/catch and fails gracefully — not a crash surface.)
|
|
15
|
+
*
|
|
16
|
+
* The fix: at the deep-agent connect funnel (mcp-manager.ts
|
|
17
|
+
* connectMcpServers), drop every pattern that cannot compile under /u.
|
|
18
|
+
* Dropping is deliberate — rewriting to a /u-safe equivalent would need an
|
|
19
|
+
* Annex-B-aware regex transpiler, disproportionate machinery for what is
|
|
20
|
+
* best-effort client-side validation; the MCP server still validates its
|
|
21
|
+
* own inputs server-side. This mirrors the loosening posture of
|
|
22
|
+
* @langchain/mcp-adapters' own schema pipeline (dereferenceJsonSchema →
|
|
23
|
+
* simplifyJsonSchemaForLLM), which already normalizes schemas for this
|
|
24
|
+
* exact validator.
|
|
25
|
+
*
|
|
26
|
+
* THE INVARIANT: sanitization may only ever LOOSEN validation, never
|
|
27
|
+
* tighten it. Dropping a `patternProperties` entry naively would violate
|
|
28
|
+
* this — @cfworker marks pattern-matched keys as "evaluated" and routes
|
|
29
|
+
* unevaluated keys into the `additionalProperties` / `unevaluatedProperties`
|
|
30
|
+
* checks, so under `additionalProperties: false` the drop would flip a
|
|
31
|
+
* crash into a false REJECTION of valid inputs. Whenever a
|
|
32
|
+
* `patternProperties` entry is dropped, any restrictive
|
|
33
|
+
* `additionalProperties` / `unevaluatedProperties` at that schema level is
|
|
34
|
+
* therefore relaxed too.
|
|
35
|
+
*
|
|
36
|
+
* Scope: this sanitizer serves the EXECUTION path only. Discovery
|
|
37
|
+
* (activities/discover-mcp-server.ts) persists tool schemas verbatim from
|
|
38
|
+
* listTools — deliberately: the stored schema is the vendor's truth for
|
|
39
|
+
* display, and discovery never invokes tools, so it cannot hit the crash.
|
|
40
|
+
* Do not "extend" sanitization there.
|
|
41
|
+
*/
|
|
42
|
+
/** Keywords whose value is a single subschema. */
|
|
43
|
+
const SINGLE_SCHEMA_KEYWORDS = [
|
|
44
|
+
"additionalProperties",
|
|
45
|
+
"unevaluatedProperties",
|
|
46
|
+
"propertyNames",
|
|
47
|
+
"items",
|
|
48
|
+
"additionalItems",
|
|
49
|
+
"unevaluatedItems",
|
|
50
|
+
"contains",
|
|
51
|
+
"not",
|
|
52
|
+
"if",
|
|
53
|
+
"then",
|
|
54
|
+
"else",
|
|
55
|
+
];
|
|
56
|
+
/** Keywords whose value is an array of subschemas. */
|
|
57
|
+
const SCHEMA_ARRAY_KEYWORDS = ["anyOf", "allOf", "oneOf", "prefixItems"];
|
|
58
|
+
/** Keywords whose value is an object mapping names to subschemas. */
|
|
59
|
+
const SCHEMA_MAP_KEYWORDS = [
|
|
60
|
+
"properties",
|
|
61
|
+
"patternProperties",
|
|
62
|
+
"dependentSchemas",
|
|
63
|
+
"$defs",
|
|
64
|
+
"definitions",
|
|
65
|
+
];
|
|
66
|
+
function compilesUnderUnicodeFlag(pattern) {
|
|
67
|
+
try {
|
|
68
|
+
new RegExp(pattern, "u");
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function compilesWithoutUnicodeFlag(pattern) {
|
|
76
|
+
try {
|
|
77
|
+
new RegExp(pattern);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function isPlainObject(value) {
|
|
85
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
86
|
+
}
|
|
87
|
+
/** JSON-pointer token escaping (RFC 6901): `~` → `~0`, `/` → `~1`. */
|
|
88
|
+
function pointerToken(token) {
|
|
89
|
+
return token.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Drop unicode-invalid regex patterns from a JSON schema, in place.
|
|
93
|
+
*
|
|
94
|
+
* Walks only schema positions (the recursion set is @cfworker's own
|
|
95
|
+
* validated-keyword list), so a property literally NAMED "pattern" under
|
|
96
|
+
* `properties` is never touched. The walker handles composition keywords
|
|
97
|
+
* (anyOf/allOf/oneOf/not/if-then-else) even though the adapter's
|
|
98
|
+
* simplifyJsonSchemaForLLM currently strips them, and carries a visited-set
|
|
99
|
+
* cycle guard even though the adapter's $ref inlining currently guarantees
|
|
100
|
+
* an acyclic result — correctness here must not depend on another
|
|
101
|
+
* package's internals holding across dependency bumps.
|
|
102
|
+
*
|
|
103
|
+
* Returns the dropped constraints (empty for clean schemas — the common
|
|
104
|
+
* case, which this walk leaves byte-identical).
|
|
105
|
+
*/
|
|
106
|
+
export function sanitizeSchemaPatterns(schema) {
|
|
107
|
+
const dropped = [];
|
|
108
|
+
if (!isPlainObject(schema))
|
|
109
|
+
return dropped;
|
|
110
|
+
walkSchema(schema, "", dropped, new Set());
|
|
111
|
+
return dropped;
|
|
112
|
+
}
|
|
113
|
+
function recordDrop(dropped, location, pattern) {
|
|
114
|
+
dropped.push({
|
|
115
|
+
location,
|
|
116
|
+
pattern,
|
|
117
|
+
compilesWithoutUnicodeFlag: compilesWithoutUnicodeFlag(pattern),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function walkSchema(node, path, dropped, seen) {
|
|
121
|
+
if (seen.has(node))
|
|
122
|
+
return;
|
|
123
|
+
seen.add(node);
|
|
124
|
+
if (typeof node.pattern === "string" && !compilesUnderUnicodeFlag(node.pattern)) {
|
|
125
|
+
recordDrop(dropped, `${path}/pattern`, node.pattern);
|
|
126
|
+
delete node.pattern;
|
|
127
|
+
}
|
|
128
|
+
if (isPlainObject(node.patternProperties)) {
|
|
129
|
+
const patternProperties = node.patternProperties;
|
|
130
|
+
let droppedEntry = false;
|
|
131
|
+
for (const key of Object.keys(patternProperties)) {
|
|
132
|
+
if (compilesUnderUnicodeFlag(key))
|
|
133
|
+
continue;
|
|
134
|
+
recordDrop(dropped, `${path}/patternProperties/${pointerToken(key)}`, key);
|
|
135
|
+
delete patternProperties[key];
|
|
136
|
+
droppedEntry = true;
|
|
137
|
+
}
|
|
138
|
+
if (droppedEntry) {
|
|
139
|
+
// Never-tighten: keys the dropped pattern used to match would now
|
|
140
|
+
// fall through to these checks and could be falsely rejected.
|
|
141
|
+
if (node.additionalProperties !== undefined && node.additionalProperties !== true) {
|
|
142
|
+
delete node.additionalProperties;
|
|
143
|
+
}
|
|
144
|
+
if (node.unevaluatedProperties !== undefined && node.unevaluatedProperties !== true) {
|
|
145
|
+
delete node.unevaluatedProperties;
|
|
146
|
+
}
|
|
147
|
+
if (Object.keys(patternProperties).length === 0) {
|
|
148
|
+
delete node.patternProperties;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
for (const keyword of SINGLE_SCHEMA_KEYWORDS) {
|
|
153
|
+
const value = node[keyword];
|
|
154
|
+
if (isPlainObject(value)) {
|
|
155
|
+
walkSchema(value, `${path}/${keyword}`, dropped, seen);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (const keyword of SCHEMA_ARRAY_KEYWORDS) {
|
|
159
|
+
const value = node[keyword];
|
|
160
|
+
if (!Array.isArray(value))
|
|
161
|
+
continue;
|
|
162
|
+
value.forEach((entry, index) => {
|
|
163
|
+
if (isPlainObject(entry)) {
|
|
164
|
+
walkSchema(entry, `${path}/${keyword}/${index}`, dropped, seen);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
for (const keyword of SCHEMA_MAP_KEYWORDS) {
|
|
169
|
+
const value = node[keyword];
|
|
170
|
+
if (!isPlainObject(value))
|
|
171
|
+
continue;
|
|
172
|
+
for (const [name, entry] of Object.entries(value)) {
|
|
173
|
+
if (isPlainObject(entry)) {
|
|
174
|
+
walkSchema(entry, `${path}/${keyword}/${pointerToken(name)}`, dropped, seen);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Draft-07 `items` tuple form and `dependencies` schema form — both
|
|
179
|
+
// keywords are dual-shaped, so the typed loops above miss these arms.
|
|
180
|
+
if (Array.isArray(node.items)) {
|
|
181
|
+
node.items.forEach((entry, index) => {
|
|
182
|
+
if (isPlainObject(entry)) {
|
|
183
|
+
walkSchema(entry, `${path}/items/${index}`, dropped, seen);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (isPlainObject(node.dependencies)) {
|
|
188
|
+
for (const [name, entry] of Object.entries(node.dependencies)) {
|
|
189
|
+
// Array-valued entries are dependentRequired (property names, not
|
|
190
|
+
// schemas) — only schema-valued entries are walked.
|
|
191
|
+
if (isPlainObject(entry)) {
|
|
192
|
+
walkSchema(entry, `${path}/dependencies/${pointerToken(name)}`, dropped, seen);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=mcp-schema-sanitizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-schema-sanitizer.js","sourceRoot":"","sources":["../../src/shared/mcp-schema-sanitizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAgBH,kDAAkD;AAClD,MAAM,sBAAsB,GAAG;IAC7B,sBAAsB;IACtB,uBAAuB;IACvB,eAAe;IACf,OAAO;IACP,iBAAiB;IACjB,kBAAkB;IAClB,UAAU;IACV,KAAK;IACL,IAAI;IACJ,MAAM;IACN,MAAM;CACE,CAAC;AAEX,sDAAsD;AACtD,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,CAAU,CAAC;AAElF,qEAAqE;AACrE,MAAM,mBAAmB,GAAG;IAC1B,YAAY;IACZ,mBAAmB;IACnB,kBAAkB;IAClB,OAAO;IACP,aAAa;CACL,CAAC;AAEX,SAAS,wBAAwB,CAAC,OAAe;IAC/C,IAAI,CAAC;QACH,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B,CAAC,OAAe;IACjD,IAAI,CAAC;QACH,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,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,CAAC;IACD,IAAI,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9D,kEAAkE;YAClE,oDAAoD;YACpD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,UAAU,CAAC,KAAK,EAAE,GAAG,IAAI,iBAAiB,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -45,8 +45,8 @@ export declare function resolveMcpTransportPosture(mode: "local" | "cloud", env?
|
|
|
45
45
|
/**
|
|
46
46
|
* Assert that a resolved MCP server's transport is allowed under the given
|
|
47
47
|
* posture. Applies only to user-defined McpServer resources flowing through
|
|
48
|
-
* the resolvers — the internal
|
|
49
|
-
* separately and
|
|
48
|
+
* the resolvers — the internal synthesized attachments are built
|
|
49
|
+
* separately and are already HTTP in cloud mode.
|
|
50
50
|
*
|
|
51
51
|
* @throws McpTransportError when the posture forbids stdio and the server uses it
|
|
52
52
|
*/
|
|
@@ -54,8 +54,8 @@ export function resolveMcpTransportPosture(mode, env = process.env) {
|
|
|
54
54
|
/**
|
|
55
55
|
* Assert that a resolved MCP server's transport is allowed under the given
|
|
56
56
|
* posture. Applies only to user-defined McpServer resources flowing through
|
|
57
|
-
* the resolvers — the internal
|
|
58
|
-
* separately and
|
|
57
|
+
* the resolvers — the internal synthesized attachments are built
|
|
58
|
+
* separately and are already HTTP in cloud mode.
|
|
59
59
|
*
|
|
60
60
|
* @throws McpTransportError when the posture forbids stdio and the server uses it
|
|
61
61
|
*/
|
|
@@ -34,6 +34,12 @@ export interface BuildChatModelOptions {
|
|
|
34
34
|
* stays the caller's decision to avoid silently changing behavior.
|
|
35
35
|
*/
|
|
36
36
|
readonly maxTokens?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Per-request bound. When omitted, defaults to the operator's
|
|
39
|
+
* STIGMER_LLM_REQUEST_TIMEOUT_MS — resolved HERE, not per caller, so no
|
|
40
|
+
* call site can drop the bound by forgetting to plumb it (the sub-agent
|
|
41
|
+
* factory did exactly that; stigmer/stigmer#468). An explicit value wins.
|
|
42
|
+
*/
|
|
37
43
|
readonly timeoutMs?: number;
|
|
38
44
|
readonly maxRetries?: number;
|
|
39
45
|
}
|
|
@@ -17,6 +17,16 @@ import { ChatOpenAI } from "@langchain/openai";
|
|
|
17
17
|
import { inferProvider, stripProviderPrefix, resolveProxyBaseUrl, buildProxyHeaders, } from "./llm-proxy.js";
|
|
18
18
|
import { resolveAnthropicBackend, checkVertexPrerequisites, checkBedrockPrerequisites, checkFoundryPrerequisites, toVertexModelId, toBedrockModelId, toFoundryDeploymentName, } from "./llm-backend.js";
|
|
19
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
|
+
}
|
|
20
30
|
/**
|
|
21
31
|
* Build a configured chat model, resolving the registry id to a provider API
|
|
22
32
|
* id first. The resolution MUST precede provider inference and prefix
|
|
@@ -27,6 +37,7 @@ export async function buildChatModel(opts) {
|
|
|
27
37
|
const resolved = await resolveToApiModelId(opts.modelName);
|
|
28
38
|
const provider = inferProvider(resolved);
|
|
29
39
|
const apiModelId = stripProviderPrefix(resolved);
|
|
40
|
+
const timeoutMs = opts.timeoutMs ?? resolveDefaultTimeoutMs();
|
|
30
41
|
// Backend precedence by construction: a proxied call never consults the
|
|
31
42
|
// backend var — the proxy owns provider routing (the factories' preflight
|
|
32
43
|
// warns when both are configured). Selection is deployment-static and read
|
|
@@ -137,7 +148,7 @@ export async function buildChatModel(opts) {
|
|
|
137
148
|
temperature: opts.temperature ?? 0,
|
|
138
149
|
apiKey,
|
|
139
150
|
...(maxTokens ? { maxTokens } : {}),
|
|
140
|
-
...(
|
|
151
|
+
...(timeoutMs ? { maxRetries: opts.maxRetries ?? 0 } : {}),
|
|
141
152
|
};
|
|
142
153
|
// The request timeout lives in a different slot per wrapper: ChatOpenAI
|
|
143
154
|
// reads `timeout` as a constructor field, but ChatAnthropic ignores it
|
|
@@ -150,7 +161,7 @@ export async function buildChatModel(opts) {
|
|
|
150
161
|
// that is LangChain's own retry knob, distinct from the SDK-level
|
|
151
162
|
// maxRetries the factories receive.
|
|
152
163
|
const anthropicClientOptions = {
|
|
153
|
-
...(
|
|
164
|
+
...(timeoutMs ? { timeout: timeoutMs } : {}),
|
|
154
165
|
...(baseUrl ? { baseURL: baseUrl } : {}),
|
|
155
166
|
...(headers ? { defaultHeaders: headers } : {}),
|
|
156
167
|
};
|
|
@@ -164,7 +175,7 @@ export async function buildChatModel(opts) {
|
|
|
164
175
|
? new ChatOpenAI({
|
|
165
176
|
model: apiModelId,
|
|
166
177
|
...common,
|
|
167
|
-
...(
|
|
178
|
+
...(timeoutMs ? { timeout: timeoutMs } : {}),
|
|
168
179
|
...(baseUrl || headers
|
|
169
180
|
? {
|
|
170
181
|
configuration: {
|
|
@@ -1 +1 @@
|
|
|
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,E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AC,CAAC,EAAE,CAAC;YAC5C,GAAG,CAAC,OAAO,IAAI,OAAO;gBACpB,CAAC,CAAC;oBACE,aAAa,EAAE;wBACb,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;wBACxC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBAChD;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;QACJ,CAAC,CAAC,mBAAmB;YACnB,CAAC,CAAC,gEAAgE;gBAChE,mEAAmE;gBACnE,oEAAoE;gBACpE,mEAAmE;gBACnE,oEAAoE;gBACpE,wDAAwD;gBACxD,IAAI,aAAa,CAAC;oBAChB,KAAK,EAAE,WAAW;oBAClB,GAAG,MAAM;oBACT,GAAG,2BAA2B;oBAC9B,YAAY,EAAE,mBAAmB;iBAClC,CAAC;YACJ,CAAC,CAAC,IAAI,aAAa,CAAC;gBAChB,KAAK,EAAE,UAAU;gBACjB,GAAG,MAAM;gBACT,GAAG,2BAA2B;aAC/B,CAAC,CAAC;IAET,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AACzC,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;
|