@mcpmesh/sdk 1.4.1 → 2.0.0-beta.1
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/dist/__tests__/a2a/a2a-bearer.spec.d.ts +2 -0
- package/dist/__tests__/a2a/a2a-bearer.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/a2a-bearer.spec.js +58 -0
- package/dist/__tests__/a2a/a2a-bearer.spec.js.map +1 -0
- package/dist/__tests__/a2a/a2a-client.spec.d.ts +2 -0
- package/dist/__tests__/a2a/a2a-client.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/a2a-client.spec.js +334 -0
- package/dist/__tests__/a2a/a2a-client.spec.js.map +1 -0
- package/dist/__tests__/a2a/a2a-job.spec.d.ts +2 -0
- package/dist/__tests__/a2a/a2a-job.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/a2a-job.spec.js +255 -0
- package/dist/__tests__/a2a/a2a-job.spec.js.map +1 -0
- package/dist/__tests__/a2a/a2a-stream.spec.d.ts +2 -0
- package/dist/__tests__/a2a/a2a-stream.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/a2a-stream.spec.js +278 -0
- package/dist/__tests__/a2a/a2a-stream.spec.js.map +1 -0
- package/dist/__tests__/a2a/agent-a2a-config.spec.d.ts +2 -0
- package/dist/__tests__/a2a/agent-a2a-config.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/agent-a2a-config.spec.js +262 -0
- package/dist/__tests__/a2a/agent-a2a-config.spec.js.map +1 -0
- package/dist/__tests__/a2a/producer/auth-filter.spec.d.ts +2 -0
- package/dist/__tests__/a2a/producer/auth-filter.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/producer/auth-filter.spec.js +127 -0
- package/dist/__tests__/a2a/producer/auth-filter.spec.js.map +1 -0
- package/dist/__tests__/a2a/producer/card-builder.spec.d.ts +2 -0
- package/dist/__tests__/a2a/producer/card-builder.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/producer/card-builder.spec.js +113 -0
- package/dist/__tests__/a2a/producer/card-builder.spec.js.map +1 -0
- package/dist/__tests__/a2a/producer/dispatcher.spec.d.ts +2 -0
- package/dist/__tests__/a2a/producer/dispatcher.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/producer/dispatcher.spec.js +850 -0
- package/dist/__tests__/a2a/producer/dispatcher.spec.js.map +1 -0
- package/dist/__tests__/a2a/producer/mount-surface-push.spec.d.ts +2 -0
- package/dist/__tests__/a2a/producer/mount-surface-push.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/producer/mount-surface-push.spec.js +164 -0
- package/dist/__tests__/a2a/producer/mount-surface-push.spec.js.map +1 -0
- package/dist/__tests__/a2a/producer/mount.spec.d.ts +2 -0
- package/dist/__tests__/a2a/producer/mount.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/producer/mount.spec.js +433 -0
- package/dist/__tests__/a2a/producer/mount.spec.js.map +1 -0
- package/dist/__tests__/a2a/producer/public-url-cache.spec.d.ts +2 -0
- package/dist/__tests__/a2a/producer/public-url-cache.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/producer/public-url-cache.spec.js +116 -0
- package/dist/__tests__/a2a/producer/public-url-cache.spec.js.map +1 -0
- package/dist/__tests__/a2a/producer/sse-emitter.spec.d.ts +2 -0
- package/dist/__tests__/a2a/producer/sse-emitter.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/producer/sse-emitter.spec.js +754 -0
- package/dist/__tests__/a2a/producer/sse-emitter.spec.js.map +1 -0
- package/dist/__tests__/a2a/producer/state-translator.spec.d.ts +2 -0
- package/dist/__tests__/a2a/producer/state-translator.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/producer/state-translator.spec.js +124 -0
- package/dist/__tests__/a2a/producer/state-translator.spec.js.map +1 -0
- package/dist/__tests__/a2a/producer/task-store.spec.d.ts +2 -0
- package/dist/__tests__/a2a/producer/task-store.spec.d.ts.map +1 -0
- package/dist/__tests__/a2a/producer/task-store.spec.js +180 -0
- package/dist/__tests__/a2a/producer/task-store.spec.js.map +1 -0
- package/dist/__tests__/agent-add-tool.spec.d.ts +2 -0
- package/dist/__tests__/agent-add-tool.spec.d.ts.map +1 -0
- package/dist/__tests__/agent-add-tool.spec.js +483 -0
- package/dist/__tests__/agent-add-tool.spec.js.map +1 -0
- package/dist/__tests__/api-runtime-race.spec.d.ts +2 -0
- package/dist/__tests__/api-runtime-race.spec.d.ts.map +1 -0
- package/dist/__tests__/api-runtime-race.spec.js +193 -0
- package/dist/__tests__/api-runtime-race.spec.js.map +1 -0
- package/dist/__tests__/claim-dispatcher.spec.d.ts +2 -0
- package/dist/__tests__/claim-dispatcher.spec.d.ts.map +1 -0
- package/dist/__tests__/claim-dispatcher.spec.js +408 -0
- package/dist/__tests__/claim-dispatcher.spec.js.map +1 -0
- package/dist/__tests__/inbound-job-dispatch.spec.d.ts +2 -0
- package/dist/__tests__/inbound-job-dispatch.spec.d.ts.map +1 -0
- package/dist/__tests__/inbound-job-dispatch.spec.js +185 -0
- package/dist/__tests__/inbound-job-dispatch.spec.js.map +1 -0
- package/dist/__tests__/job-controller-progress.spec.d.ts +2 -0
- package/dist/__tests__/job-controller-progress.spec.d.ts.map +1 -0
- package/dist/__tests__/job-controller-progress.spec.js +85 -0
- package/dist/__tests__/job-controller-progress.spec.js.map +1 -0
- package/dist/__tests__/jobs-cancel-route.spec.d.ts +2 -0
- package/dist/__tests__/jobs-cancel-route.spec.d.ts.map +1 -0
- package/dist/__tests__/jobs-cancel-route.spec.js +88 -0
- package/dist/__tests__/jobs-cancel-route.spec.js.map +1 -0
- package/dist/__tests__/llm-agent-stream.test.d.ts +14 -0
- package/dist/__tests__/llm-agent-stream.test.d.ts.map +1 -0
- package/dist/__tests__/llm-agent-stream.test.js +341 -0
- package/dist/__tests__/llm-agent-stream.test.js.map +1 -0
- package/dist/__tests__/mesh-job-submitter.spec.d.ts +2 -0
- package/dist/__tests__/mesh-job-submitter.spec.d.ts.map +1 -0
- package/dist/__tests__/mesh-job-submitter.spec.js +110 -0
- package/dist/__tests__/mesh-job-submitter.spec.js.map +1 -0
- package/dist/__tests__/proxy-stream.test.d.ts +9 -0
- package/dist/__tests__/proxy-stream.test.d.ts.map +1 -0
- package/dist/__tests__/proxy-stream.test.js +347 -0
- package/dist/__tests__/proxy-stream.test.js.map +1 -0
- package/dist/__tests__/resolver-meshjob.spec.d.ts +26 -0
- package/dist/__tests__/resolver-meshjob.spec.d.ts.map +1 -0
- package/dist/__tests__/resolver-meshjob.spec.js +201 -0
- package/dist/__tests__/resolver-meshjob.spec.js.map +1 -0
- package/dist/__tests__/schema-verdict-policy.test.d.ts +6 -0
- package/dist/__tests__/schema-verdict-policy.test.d.ts.map +1 -0
- package/dist/__tests__/schema-verdict-policy.test.js +126 -0
- package/dist/__tests__/schema-verdict-policy.test.js.map +1 -0
- package/dist/__tests__/sse-stream.test.d.ts +12 -0
- package/dist/__tests__/sse-stream.test.d.ts.map +1 -0
- package/dist/__tests__/sse-stream.test.js +170 -0
- package/dist/__tests__/sse-stream.test.js.map +1 -0
- package/dist/a2a/a2a-bearer.d.ts +27 -0
- package/dist/a2a/a2a-bearer.d.ts.map +1 -0
- package/dist/a2a/a2a-bearer.js +63 -0
- package/dist/a2a/a2a-bearer.js.map +1 -0
- package/dist/a2a/a2a-client.d.ts +114 -0
- package/dist/a2a/a2a-client.d.ts.map +1 -0
- package/dist/a2a/a2a-client.js +405 -0
- package/dist/a2a/a2a-client.js.map +1 -0
- package/dist/a2a/a2a-event.d.ts +25 -0
- package/dist/a2a/a2a-event.d.ts.map +1 -0
- package/dist/a2a/a2a-event.js +9 -0
- package/dist/a2a/a2a-event.js.map +1 -0
- package/dist/a2a/a2a-job.d.ts +58 -0
- package/dist/a2a/a2a-job.d.ts.map +1 -0
- package/dist/a2a/a2a-job.js +264 -0
- package/dist/a2a/a2a-job.js.map +1 -0
- package/dist/a2a/a2a-stream.d.ts +39 -0
- package/dist/a2a/a2a-stream.d.ts.map +1 -0
- package/dist/a2a/a2a-stream.js +290 -0
- package/dist/a2a/a2a-stream.js.map +1 -0
- package/dist/a2a/errors.d.ts +29 -0
- package/dist/a2a/errors.d.ts.map +1 -0
- package/dist/a2a/errors.js +48 -0
- package/dist/a2a/errors.js.map +1 -0
- package/dist/a2a/index.d.ts +12 -0
- package/dist/a2a/index.d.ts.map +1 -0
- package/dist/a2a/index.js +11 -0
- package/dist/a2a/index.js.map +1 -0
- package/dist/a2a/producer/auth-filter.d.ts +34 -0
- package/dist/a2a/producer/auth-filter.d.ts.map +1 -0
- package/dist/a2a/producer/auth-filter.js +39 -0
- package/dist/a2a/producer/auth-filter.js.map +1 -0
- package/dist/a2a/producer/card-builder.d.ts +59 -0
- package/dist/a2a/producer/card-builder.d.ts.map +1 -0
- package/dist/a2a/producer/card-builder.js +59 -0
- package/dist/a2a/producer/card-builder.js.map +1 -0
- package/dist/a2a/producer/dispatcher.d.ts +276 -0
- package/dist/a2a/producer/dispatcher.d.ts.map +1 -0
- package/dist/a2a/producer/dispatcher.js +896 -0
- package/dist/a2a/producer/dispatcher.js.map +1 -0
- package/dist/a2a/producer/index.d.ts +26 -0
- package/dist/a2a/producer/index.d.ts.map +1 -0
- package/dist/a2a/producer/index.js +23 -0
- package/dist/a2a/producer/index.js.map +1 -0
- package/dist/a2a/producer/mount.d.ts +75 -0
- package/dist/a2a/producer/mount.d.ts.map +1 -0
- package/dist/a2a/producer/mount.js +422 -0
- package/dist/a2a/producer/mount.js.map +1 -0
- package/dist/a2a/producer/public-url-cache.d.ts +73 -0
- package/dist/a2a/producer/public-url-cache.d.ts.map +1 -0
- package/dist/a2a/producer/public-url-cache.js +0 -0
- package/dist/a2a/producer/public-url-cache.js.map +1 -0
- package/dist/a2a/producer/registry.d.ts +138 -0
- package/dist/a2a/producer/registry.d.ts.map +1 -0
- package/dist/a2a/producer/registry.js +117 -0
- package/dist/a2a/producer/registry.js.map +1 -0
- package/dist/a2a/producer/sse-emitter.d.ts +85 -0
- package/dist/a2a/producer/sse-emitter.d.ts.map +1 -0
- package/dist/a2a/producer/sse-emitter.js +405 -0
- package/dist/a2a/producer/sse-emitter.js.map +1 -0
- package/dist/a2a/producer/state-translator.d.ts +63 -0
- package/dist/a2a/producer/state-translator.d.ts.map +1 -0
- package/dist/a2a/producer/state-translator.js +108 -0
- package/dist/a2a/producer/state-translator.js.map +1 -0
- package/dist/a2a/producer/task-store.d.ts +128 -0
- package/dist/a2a/producer/task-store.d.ts.map +1 -0
- package/dist/a2a/producer/task-store.js +128 -0
- package/dist/a2a/producer/task-store.js.map +1 -0
- package/dist/agent.d.ts +72 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +618 -13
- package/dist/agent.js.map +1 -1
- package/dist/api-runtime.d.ts +25 -0
- package/dist/api-runtime.d.ts.map +1 -1
- package/dist/api-runtime.js +75 -2
- package/dist/api-runtime.js.map +1 -1
- package/dist/claim-dispatcher.d.ts +126 -0
- package/dist/claim-dispatcher.d.ts.map +1 -0
- package/dist/claim-dispatcher.js +478 -0
- package/dist/claim-dispatcher.js.map +1 -0
- package/dist/express.d.ts.map +1 -1
- package/dist/express.js +33 -6
- package/dist/express.js.map +1 -1
- package/dist/inbound-job-dispatch.d.ts +105 -0
- package/dist/inbound-job-dispatch.d.ts.map +1 -0
- package/dist/inbound-job-dispatch.js +335 -0
- package/dist/inbound-job-dispatch.js.map +1 -0
- package/dist/index.d.ts +37 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -3
- package/dist/index.js.map +1 -1
- package/dist/job-context.d.ts +107 -0
- package/dist/job-context.d.ts.map +1 -0
- package/dist/job-context.js +95 -0
- package/dist/job-context.js.map +1 -0
- package/dist/jobs-cancel-route.d.ts +36 -0
- package/dist/jobs-cancel-route.d.ts.map +1 -0
- package/dist/jobs-cancel-route.js +60 -0
- package/dist/jobs-cancel-route.js.map +1 -0
- package/dist/jobs-helper-tools.d.ts +48 -0
- package/dist/jobs-helper-tools.d.ts.map +1 -0
- package/dist/jobs-helper-tools.js +133 -0
- package/dist/jobs-helper-tools.js.map +1 -0
- package/dist/llm-agent.d.ts +62 -53
- package/dist/llm-agent.d.ts.map +1 -1
- package/dist/llm-agent.js +211 -292
- package/dist/llm-agent.js.map +1 -1
- package/dist/llm-provider.d.ts +4 -4
- package/dist/llm.d.ts +4 -1
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +7 -17
- package/dist/llm.js.map +1 -1
- package/dist/mesh-job-submitter.d.ts +83 -0
- package/dist/mesh-job-submitter.d.ts.map +1 -0
- package/dist/mesh-job-submitter.js +143 -0
- package/dist/mesh-job-submitter.js.map +1 -0
- package/dist/proxy.d.ts +30 -0
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +351 -1
- package/dist/proxy.js.map +1 -1
- package/dist/resolver-meshjob.d.ts +170 -0
- package/dist/resolver-meshjob.d.ts.map +1 -0
- package/dist/resolver-meshjob.js +159 -0
- package/dist/resolver-meshjob.js.map +1 -0
- package/dist/route.d.ts +4 -0
- package/dist/route.d.ts.map +1 -1
- package/dist/route.js.map +1 -1
- package/dist/schema-normalize.d.ts +62 -0
- package/dist/schema-normalize.d.ts.map +1 -0
- package/dist/schema-normalize.js +128 -0
- package/dist/schema-normalize.js.map +1 -0
- package/dist/sse-stream.d.ts +44 -0
- package/dist/sse-stream.d.ts.map +1 -0
- package/dist/sse-stream.js +173 -0
- package/dist/sse-stream.js.map +1 -0
- package/dist/types.d.ts +351 -9
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DDDI resolver for `MeshJob` parameters (Phase 1 — MeshJob substrate).
|
|
3
|
+
*
|
|
4
|
+
* Implements `MESHJOB_DDDI_CONTRACT.md` for the TypeScript SDK. Mirrors
|
|
5
|
+
* Python's `analyze_mesh_job_signature` from
|
|
6
|
+
* `_mcp_mesh.engine.signature_analyzer`.
|
|
7
|
+
*
|
|
8
|
+
* # TS-specific shape
|
|
9
|
+
*
|
|
10
|
+
* Python uses `inspect.signature` + `typing.get_type_hints` to classify
|
|
11
|
+
* parameters by annotation type. TypeScript erases types at runtime,
|
|
12
|
+
* and the existing SDK does not depend on `reflect-metadata` decorators
|
|
13
|
+
* — `agent.addTool({ ... })` is fully declarative. So the TS resolver
|
|
14
|
+
* input is the explicit declaration:
|
|
15
|
+
*
|
|
16
|
+
* - `dependencies`: array of MeshTool deps in declaration order
|
|
17
|
+
* (matches Python's `dep_index` ordering today).
|
|
18
|
+
* - `meshToolPositions`: signature positions for each MeshTool dep
|
|
19
|
+
* (where in the user `execute(args, ...)` parameter list each
|
|
20
|
+
* dep proxy lands).
|
|
21
|
+
* - `meshJobParamIndex`: signature position of the single MeshJob
|
|
22
|
+
* parameter, or `undefined` if the tool has none.
|
|
23
|
+
*
|
|
24
|
+
* The resolver verifies the contract invariants:
|
|
25
|
+
*
|
|
26
|
+
* - At most one MeshJob parameter per tool (reject otherwise).
|
|
27
|
+
* - MeshTool positions don't overlap with the MeshJob position.
|
|
28
|
+
*
|
|
29
|
+
* Then produces the canonical `ResolvedSignature` the dispatch wrapper
|
|
30
|
+
* uses to inject deps + the MeshJob into `execute(args, ...)`.
|
|
31
|
+
*
|
|
32
|
+
* # Test seam
|
|
33
|
+
*
|
|
34
|
+
* `__tests__/resolver-meshjob.spec.ts` covers the same scenarios as
|
|
35
|
+
* Python's `tests/test_resolver_meshjob.py` and Java's
|
|
36
|
+
* (forthcoming) `MeshJobResolverTest.java`. Whenever any SDK's
|
|
37
|
+
* resolver behaviour changes, update `MESHJOB_DDDI_CONTRACT.md` first
|
|
38
|
+
* then mirror across all three test seams.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* One mesh-tool dependency slot recognised by the resolver. Mirrors
|
|
42
|
+
* Python's `mesh_tool_positions[i]` entry: each entry knows where in
|
|
43
|
+
* the user function's parameter list it should be injected.
|
|
44
|
+
*/
|
|
45
|
+
export interface ResolvedMeshToolDep {
|
|
46
|
+
/** Index into the original `dependencies` array. */
|
|
47
|
+
depIndex: number;
|
|
48
|
+
/**
|
|
49
|
+
* Signature position (0-indexed) where the resolved proxy should be
|
|
50
|
+
* injected as a positional arg to the user `execute` function. For
|
|
51
|
+
* the TS SDK these positions follow `args` (the first positional
|
|
52
|
+
* parameter is always the parsed args object, then deps).
|
|
53
|
+
*/
|
|
54
|
+
signaturePosition: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolver output. Mirrors Python's `MeshJobResolution` plus the
|
|
58
|
+
* `meshToolDeps` projection for TS callers (Python returns just
|
|
59
|
+
* positions; the TS dispatch path threads `depIndex` through).
|
|
60
|
+
*/
|
|
61
|
+
export interface ResolvedSignature {
|
|
62
|
+
/**
|
|
63
|
+
* Mesh-tool dependency slots in declaration order. The dispatch
|
|
64
|
+
* wrapper iterates this list to inject the resolved proxies.
|
|
65
|
+
*
|
|
66
|
+
* Empty when the tool declares no `dependencies`.
|
|
67
|
+
*/
|
|
68
|
+
meshToolDeps: ResolvedMeshToolDep[];
|
|
69
|
+
/**
|
|
70
|
+
* Signature position of the single MeshJob parameter, or
|
|
71
|
+
* `undefined` if the tool does not declare one.
|
|
72
|
+
*
|
|
73
|
+
* Phase 1 invariant: at most one MeshJob param per tool. The
|
|
74
|
+
* resolver throws (see {@link resolveMeshJobSignature}) if this
|
|
75
|
+
* invariant is violated.
|
|
76
|
+
*/
|
|
77
|
+
meshJobParamIndex?: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Input shape for the resolver. The SDK builds this from the user's
|
|
81
|
+
* `addTool({ dependencies, meshToolPositions, meshJobParamIndex })`
|
|
82
|
+
* config; explicit fields keep the resolver pure and easy to test
|
|
83
|
+
* without spinning up a FastMCP server.
|
|
84
|
+
*/
|
|
85
|
+
export interface ResolverInput {
|
|
86
|
+
/**
|
|
87
|
+
* Capability names of declared dependencies in declaration order.
|
|
88
|
+
* The length defines the number of MeshTool slots.
|
|
89
|
+
*/
|
|
90
|
+
dependencies: string[];
|
|
91
|
+
/**
|
|
92
|
+
* Optional explicit signature positions for each MeshTool dep. When
|
|
93
|
+
* omitted, the resolver assigns positions starting at 1 (after
|
|
94
|
+
* `args`) and skipping `meshJobParamIndex` if set, matching the
|
|
95
|
+
* contract's "positional indexing rule".
|
|
96
|
+
*
|
|
97
|
+
* Length MUST match `dependencies.length` when provided.
|
|
98
|
+
*/
|
|
99
|
+
meshToolPositions?: number[];
|
|
100
|
+
/**
|
|
101
|
+
* Signature position of the MeshJob parameter (if any). The contract
|
|
102
|
+
* classifies it as orthogonal to MeshTool positional indexing — it
|
|
103
|
+
* is recorded separately so adding/removing a MeshJob param does
|
|
104
|
+
* NOT shift MeshTool positions.
|
|
105
|
+
*/
|
|
106
|
+
meshJobParamIndex?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Optional name(s) of MeshJob parameters detected at the call site.
|
|
109
|
+
* Used by the resolver to surface a clearer error message when the
|
|
110
|
+
* user accidentally declares more than one. Pass an array like
|
|
111
|
+
* `["job", "secondJob"]` to enable the "at most one" check —
|
|
112
|
+
* undefined skips the check (single position only).
|
|
113
|
+
*/
|
|
114
|
+
meshJobParamNames?: string[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Sentinel error class for resolver violations. Subclasses `Error` so
|
|
118
|
+
* standard `try/catch` works; the SDK calls `addTool` re-throws this
|
|
119
|
+
* verbatim so the user sees the misuse at registration time.
|
|
120
|
+
*
|
|
121
|
+
* The contract specifies the exact wording for the multi-MeshJob case
|
|
122
|
+
* — keeping it stable here lets tests assert against it.
|
|
123
|
+
*/
|
|
124
|
+
export declare class ResolverError extends Error {
|
|
125
|
+
constructor(message: string);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Classify a tool's signature per `MESHJOB_DDDI_CONTRACT.md`.
|
|
129
|
+
*
|
|
130
|
+
* For each dependency in declaration order, assigns a signature
|
|
131
|
+
* position. If `meshJobParamIndex` is set, that position is RESERVED
|
|
132
|
+
* for the MeshJob and skipped when assigning MeshTool positions.
|
|
133
|
+
*
|
|
134
|
+
* Phase 1 invariant: at most one MeshJob parameter — multiple raises
|
|
135
|
+
* `ResolverError` with the contract-specified wording so users see
|
|
136
|
+
* the misuse at registration time.
|
|
137
|
+
*
|
|
138
|
+
* The TS SDK's existing tool-positional layout is `(args, ...deps)` —
|
|
139
|
+
* args is signature position 0, deps start at 1. When
|
|
140
|
+
* `meshJobParamIndex` is set inside that range, it consumes one slot
|
|
141
|
+
* and the resolver shifts subsequent MeshTool positions accordingly.
|
|
142
|
+
*
|
|
143
|
+
* @example MeshTool only
|
|
144
|
+
* ```ts
|
|
145
|
+
* resolveMeshJobSignature({ dependencies: ["a", "b"] })
|
|
146
|
+
* // → { meshToolDeps: [{depIndex:0, signaturePosition:1}, {depIndex:1, signaturePosition:2}] }
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @example MeshJob in middle (sig pos 2)
|
|
150
|
+
* ```ts
|
|
151
|
+
* resolveMeshJobSignature({
|
|
152
|
+
* dependencies: ["weather", "flights"],
|
|
153
|
+
* meshJobParamIndex: 2,
|
|
154
|
+
* })
|
|
155
|
+
* // → { meshToolDeps: [{depIndex:0, signaturePosition:1}, {depIndex:1, signaturePosition:3}],
|
|
156
|
+
* // meshJobParamIndex: 2 }
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* @example Multiple MeshJob params → throws
|
|
160
|
+
* ```ts
|
|
161
|
+
* resolveMeshJobSignature({
|
|
162
|
+
* dependencies: [],
|
|
163
|
+
* meshJobParamIndex: 1,
|
|
164
|
+
* meshJobParamNames: ["firstJob", "secondJob"],
|
|
165
|
+
* })
|
|
166
|
+
* // → throws ResolverError("a tool function may declare at most one MeshJob parameter; ...")
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export declare function resolveMeshJobSignature(input: ResolverInput): ResolvedSignature;
|
|
170
|
+
//# sourceMappingURL=resolver-meshjob.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver-meshjob.d.ts","sourceRoot":"","sources":["../src/resolver-meshjob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,YAAY,EAAE,mBAAmB,EAAE,CAAC;IAEpC;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE7B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,aAAa,GACnB,iBAAiB,CA4EnB"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DDDI resolver for `MeshJob` parameters (Phase 1 — MeshJob substrate).
|
|
3
|
+
*
|
|
4
|
+
* Implements `MESHJOB_DDDI_CONTRACT.md` for the TypeScript SDK. Mirrors
|
|
5
|
+
* Python's `analyze_mesh_job_signature` from
|
|
6
|
+
* `_mcp_mesh.engine.signature_analyzer`.
|
|
7
|
+
*
|
|
8
|
+
* # TS-specific shape
|
|
9
|
+
*
|
|
10
|
+
* Python uses `inspect.signature` + `typing.get_type_hints` to classify
|
|
11
|
+
* parameters by annotation type. TypeScript erases types at runtime,
|
|
12
|
+
* and the existing SDK does not depend on `reflect-metadata` decorators
|
|
13
|
+
* — `agent.addTool({ ... })` is fully declarative. So the TS resolver
|
|
14
|
+
* input is the explicit declaration:
|
|
15
|
+
*
|
|
16
|
+
* - `dependencies`: array of MeshTool deps in declaration order
|
|
17
|
+
* (matches Python's `dep_index` ordering today).
|
|
18
|
+
* - `meshToolPositions`: signature positions for each MeshTool dep
|
|
19
|
+
* (where in the user `execute(args, ...)` parameter list each
|
|
20
|
+
* dep proxy lands).
|
|
21
|
+
* - `meshJobParamIndex`: signature position of the single MeshJob
|
|
22
|
+
* parameter, or `undefined` if the tool has none.
|
|
23
|
+
*
|
|
24
|
+
* The resolver verifies the contract invariants:
|
|
25
|
+
*
|
|
26
|
+
* - At most one MeshJob parameter per tool (reject otherwise).
|
|
27
|
+
* - MeshTool positions don't overlap with the MeshJob position.
|
|
28
|
+
*
|
|
29
|
+
* Then produces the canonical `ResolvedSignature` the dispatch wrapper
|
|
30
|
+
* uses to inject deps + the MeshJob into `execute(args, ...)`.
|
|
31
|
+
*
|
|
32
|
+
* # Test seam
|
|
33
|
+
*
|
|
34
|
+
* `__tests__/resolver-meshjob.spec.ts` covers the same scenarios as
|
|
35
|
+
* Python's `tests/test_resolver_meshjob.py` and Java's
|
|
36
|
+
* (forthcoming) `MeshJobResolverTest.java`. Whenever any SDK's
|
|
37
|
+
* resolver behaviour changes, update `MESHJOB_DDDI_CONTRACT.md` first
|
|
38
|
+
* then mirror across all three test seams.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Sentinel error class for resolver violations. Subclasses `Error` so
|
|
42
|
+
* standard `try/catch` works; the SDK calls `addTool` re-throws this
|
|
43
|
+
* verbatim so the user sees the misuse at registration time.
|
|
44
|
+
*
|
|
45
|
+
* The contract specifies the exact wording for the multi-MeshJob case
|
|
46
|
+
* — keeping it stable here lets tests assert against it.
|
|
47
|
+
*/
|
|
48
|
+
export class ResolverError extends Error {
|
|
49
|
+
constructor(message) {
|
|
50
|
+
super(message);
|
|
51
|
+
this.name = "ResolverError";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Classify a tool's signature per `MESHJOB_DDDI_CONTRACT.md`.
|
|
56
|
+
*
|
|
57
|
+
* For each dependency in declaration order, assigns a signature
|
|
58
|
+
* position. If `meshJobParamIndex` is set, that position is RESERVED
|
|
59
|
+
* for the MeshJob and skipped when assigning MeshTool positions.
|
|
60
|
+
*
|
|
61
|
+
* Phase 1 invariant: at most one MeshJob parameter — multiple raises
|
|
62
|
+
* `ResolverError` with the contract-specified wording so users see
|
|
63
|
+
* the misuse at registration time.
|
|
64
|
+
*
|
|
65
|
+
* The TS SDK's existing tool-positional layout is `(args, ...deps)` —
|
|
66
|
+
* args is signature position 0, deps start at 1. When
|
|
67
|
+
* `meshJobParamIndex` is set inside that range, it consumes one slot
|
|
68
|
+
* and the resolver shifts subsequent MeshTool positions accordingly.
|
|
69
|
+
*
|
|
70
|
+
* @example MeshTool only
|
|
71
|
+
* ```ts
|
|
72
|
+
* resolveMeshJobSignature({ dependencies: ["a", "b"] })
|
|
73
|
+
* // → { meshToolDeps: [{depIndex:0, signaturePosition:1}, {depIndex:1, signaturePosition:2}] }
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example MeshJob in middle (sig pos 2)
|
|
77
|
+
* ```ts
|
|
78
|
+
* resolveMeshJobSignature({
|
|
79
|
+
* dependencies: ["weather", "flights"],
|
|
80
|
+
* meshJobParamIndex: 2,
|
|
81
|
+
* })
|
|
82
|
+
* // → { meshToolDeps: [{depIndex:0, signaturePosition:1}, {depIndex:1, signaturePosition:3}],
|
|
83
|
+
* // meshJobParamIndex: 2 }
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example Multiple MeshJob params → throws
|
|
87
|
+
* ```ts
|
|
88
|
+
* resolveMeshJobSignature({
|
|
89
|
+
* dependencies: [],
|
|
90
|
+
* meshJobParamIndex: 1,
|
|
91
|
+
* meshJobParamNames: ["firstJob", "secondJob"],
|
|
92
|
+
* })
|
|
93
|
+
* // → throws ResolverError("a tool function may declare at most one MeshJob parameter; ...")
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export function resolveMeshJobSignature(input) {
|
|
97
|
+
// Phase 1 invariant: at most one MeshJob param. This is checked when
|
|
98
|
+
// the caller supplies the optional `meshJobParamNames` (set by the
|
|
99
|
+
// hypothetical type-reflective shim that Phase B will introduce in
|
|
100
|
+
// the dispatch wrapper). When the input plumbing only carries a
|
|
101
|
+
// single index, by construction we already have at most one — so
|
|
102
|
+
// skip the check rather than reject ambiguous input shapes.
|
|
103
|
+
if (input.meshJobParamNames && input.meshJobParamNames.length > 1) {
|
|
104
|
+
throw new ResolverError(`a tool function may declare at most one MeshJob parameter; ` +
|
|
105
|
+
`function declares ${input.meshJobParamNames.length}: ` +
|
|
106
|
+
`${input.meshJobParamNames.map((n) => `'${n}'`).join(", ")}`);
|
|
107
|
+
}
|
|
108
|
+
const meshJobParamIndex = input.meshJobParamIndex;
|
|
109
|
+
// Sanity-check explicit positions if provided.
|
|
110
|
+
if (input.meshToolPositions !== undefined) {
|
|
111
|
+
if (input.meshToolPositions.length !== input.dependencies.length) {
|
|
112
|
+
throw new ResolverError(`meshToolPositions length (${input.meshToolPositions.length}) ` +
|
|
113
|
+
`does not match dependencies length (${input.dependencies.length})`);
|
|
114
|
+
}
|
|
115
|
+
if (meshJobParamIndex !== undefined &&
|
|
116
|
+
input.meshToolPositions.includes(meshJobParamIndex)) {
|
|
117
|
+
throw new ResolverError(`meshJobParamIndex ${meshJobParamIndex} collides with a ` +
|
|
118
|
+
`MeshTool position; MeshJob is orthogonal — it must occupy ` +
|
|
119
|
+
`its own signature slot per MESHJOB_DDDI_CONTRACT.md`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Compute mesh-tool positions. Two paths:
|
|
123
|
+
//
|
|
124
|
+
// 1. Caller supplied them explicitly — use as-is (after the
|
|
125
|
+
// collision check above).
|
|
126
|
+
// 2. Default: counter starts at 1 (after `args`), skip the
|
|
127
|
+
// MeshJob position if any.
|
|
128
|
+
//
|
|
129
|
+
// The contract's "positional indexing rule" says: maintain a
|
|
130
|
+
// mesh_tool_position_counter, increment for each MeshTool, and do
|
|
131
|
+
// not touch it for MeshJob. We translate that into "skip the
|
|
132
|
+
// MeshJob signature position" because the TS SDK uses the same
|
|
133
|
+
// signature for `execute(args, ...deps)` whether or not a MeshJob
|
|
134
|
+
// is present.
|
|
135
|
+
let positions;
|
|
136
|
+
if (input.meshToolPositions !== undefined) {
|
|
137
|
+
positions = input.meshToolPositions;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
positions = [];
|
|
141
|
+
let counter = 1; // signature pos 0 is always `args`
|
|
142
|
+
for (let i = 0; i < input.dependencies.length; i++) {
|
|
143
|
+
if (counter === meshJobParamIndex) {
|
|
144
|
+
counter += 1; // skip MeshJob slot
|
|
145
|
+
}
|
|
146
|
+
positions.push(counter);
|
|
147
|
+
counter += 1;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const meshToolDeps = positions.map((signaturePosition, depIndex) => ({
|
|
151
|
+
depIndex,
|
|
152
|
+
signaturePosition,
|
|
153
|
+
}));
|
|
154
|
+
return {
|
|
155
|
+
meshToolDeps,
|
|
156
|
+
meshJobParamIndex,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=resolver-meshjob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver-meshjob.js","sourceRoot":"","sources":["../src/resolver-meshjob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAqFH;;;;;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vD,4DAA4D;gBAC5D,qDAAqD,CACxD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,0CAA0C;IAC1C,EAAE;IACF,8DAA8D;IAC9D,+BAA+B;IAC/B,6DAA6D;IAC7D,gCAAgC;IAChC,EAAE;IACF,6DAA6D;IAC7D,kEAAkE;IAClE,6DAA6D;IAC7D,+DAA+D;IAC/D,kEAAkE;IAClE,cAAc;IACd,IAAI,SAAmB,CAAC;IACxB,IAAI,KAAK,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC1C,SAAS,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,SAAS,GAAG,EAAE,CAAC;QACf,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,mCAAmC;QACpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACnD,IAAI,OAAO,KAAK,iBAAiB,EAAE,CAAC;gBAClC,OAAO,IAAI,CAAC,CAAC,CAAC,oBAAoB;YACpC,CAAC;YACD,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACxB,OAAO,IAAI,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IAED,MAAM,YAAY,GAA0B,SAAS,CAAC,GAAG,CACvD,CAAC,iBAAiB,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;QAChC,QAAQ;QACR,iBAAiB;KAClB,CAAC,CACH,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
package/dist/route.d.ts
CHANGED
|
@@ -71,6 +71,10 @@ export interface RouteMetadata {
|
|
|
71
71
|
capability: string;
|
|
72
72
|
tags: TagSpec[];
|
|
73
73
|
version?: string;
|
|
74
|
+
/** Issue #547: raw expected output schema (post-zodToJsonSchema). */
|
|
75
|
+
expectedSchemaRaw?: object;
|
|
76
|
+
/** Issue #547: schema match mode. */
|
|
77
|
+
matchMode?: "subset" | "strict";
|
|
74
78
|
}>;
|
|
75
79
|
/** Per-dependency kwargs */
|
|
76
80
|
dependencyKwargs?: DependencyKwargs[];
|
package/dist/route.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../src/route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAkBzF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC;AAEnE;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,iBAAiB,KACpB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,CACrC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,iBAAiB,EACvB,IAAI,EAAE,YAAY,KACf,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,y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ACvB,OAAoD;IAEpD,OAAO,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,EAAE;QACzC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC1C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Issue #547: thin wrapper around the Rust normalizer exposed via @mcpmesh/core.
|
|
3
|
+
*
|
|
4
|
+
* The runtime uses this to canonicalize JSON Schemas (input/output for tools,
|
|
5
|
+
* expected schemas for dependencies) so capability matching reduces to
|
|
6
|
+
* byte-equal hash comparison. Mirrors the Python pipeline.
|
|
7
|
+
*/
|
|
8
|
+
export interface NormalizedSchemaResult {
|
|
9
|
+
/** Canonical normalized schema as a JSON string (suitable for shipping). */
|
|
10
|
+
canonicalJson: string | null;
|
|
11
|
+
/** SHA256 hash (sha256:<hex>) of the canonical schema. */
|
|
12
|
+
hash: string | null;
|
|
13
|
+
/** Normalizer verdict: "OK", "WARN", or "BLOCK". */
|
|
14
|
+
verdict: string;
|
|
15
|
+
/** Normalizer warnings (may be empty). */
|
|
16
|
+
warnings: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Issue #547 Phase 4: cluster-wide schema strict mode.
|
|
20
|
+
*
|
|
21
|
+
* Reads `MCP_MESH_SCHEMA_STRICT` once per call. When true, WARN verdicts are
|
|
22
|
+
* promoted to BLOCK so ops can harden a whole cluster without changing every
|
|
23
|
+
* consumer.
|
|
24
|
+
*/
|
|
25
|
+
export declare function clusterStrictEnabled(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Issue #547 Phase 4: schema verdict policy.
|
|
28
|
+
*
|
|
29
|
+
* Composes the cluster-wide strict knob and the per-tool `outputSchemaStrict`
|
|
30
|
+
* override. Returns true when the SDK should refuse agent startup.
|
|
31
|
+
*
|
|
32
|
+
* Truth table:
|
|
33
|
+
* verdict=BLOCK + toolStrict=true -> refuse
|
|
34
|
+
* verdict=BLOCK + toolStrict=false -> log only (override wins)
|
|
35
|
+
* verdict=WARN + clusterStrict=true + toolStrict=true -> refuse
|
|
36
|
+
* verdict=WARN + clusterStrict=true + toolStrict=false -> log only
|
|
37
|
+
* verdict=WARN + clusterStrict=false -> log only
|
|
38
|
+
* verdict=OK -> never refuse
|
|
39
|
+
*/
|
|
40
|
+
export declare function shouldRefuseStartup(verdict: string, clusterStrict: boolean, toolStrict: boolean): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Normalize a raw JSON Schema via the Rust core.
|
|
43
|
+
*
|
|
44
|
+
* Resolves to `null`-fielded result if `@mcpmesh/core` does not yet expose
|
|
45
|
+
* `normalizeSchema` (legacy bundled binary). Logs a warning once per call.
|
|
46
|
+
* Callers should treat that as "schema fields unavailable, ship without".
|
|
47
|
+
*
|
|
48
|
+
* @throws Error when the normalizer returns verdict === "BLOCK". The caller
|
|
49
|
+
* is expected to surface this with an actionable message including
|
|
50
|
+
* the function/dependency name (we don't have that context here).
|
|
51
|
+
*/
|
|
52
|
+
export declare function normalizeSchemaRaw(raw: object, contextLabel: string): NormalizedSchemaResult;
|
|
53
|
+
/**
|
|
54
|
+
* Issue #547 Phase 4: apply the verdict policy on top of {@link normalizeSchemaRaw}.
|
|
55
|
+
*
|
|
56
|
+
* Use this from callsites that need the per-tool override to take effect.
|
|
57
|
+
* Returns the (possibly warning-tagged) result, or throws when startup must
|
|
58
|
+
* be refused. Logs WARN/demoted-BLOCK loudly so they show up in normal
|
|
59
|
+
* deployments.
|
|
60
|
+
*/
|
|
61
|
+
export declare function normalizeSchemaWithPolicy(raw: object, contextLabel: string, clusterStrict: boolean, toolStrict: boolean): NormalizedSchemaResult;
|
|
62
|
+
//# sourceMappingURL=schema-normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-normalize.d.ts","sourceRoot":"","sources":["../src/schema-normalize.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,sBAAsB;IACrC,4EAA4E;IAC5E,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAI9C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,OAAO,EACtB,UAAU,EAAE,OAAO,GAClB,OAAO,CAIT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,GACnB,sBAAsB,CAyCxB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,OAAO,EACtB,UAAU,EAAE,OAAO,GAClB,sBAAsB,CAwDxB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Issue #547: thin wrapper around the Rust normalizer exposed via @mcpmesh/core.
|
|
3
|
+
*
|
|
4
|
+
* The runtime uses this to canonicalize JSON Schemas (input/output for tools,
|
|
5
|
+
* expected schemas for dependencies) so capability matching reduces to
|
|
6
|
+
* byte-equal hash comparison. Mirrors the Python pipeline.
|
|
7
|
+
*/
|
|
8
|
+
import * as core from "@mcpmesh/core";
|
|
9
|
+
/**
|
|
10
|
+
* Issue #547 Phase 4: cluster-wide schema strict mode.
|
|
11
|
+
*
|
|
12
|
+
* Reads `MCP_MESH_SCHEMA_STRICT` once per call. When true, WARN verdicts are
|
|
13
|
+
* promoted to BLOCK so ops can harden a whole cluster without changing every
|
|
14
|
+
* consumer.
|
|
15
|
+
*/
|
|
16
|
+
export function clusterStrictEnabled() {
|
|
17
|
+
const v = process.env.MCP_MESH_SCHEMA_STRICT;
|
|
18
|
+
if (v === undefined)
|
|
19
|
+
return false;
|
|
20
|
+
return ["1", "true", "yes"].includes(v.trim().toLowerCase());
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Issue #547 Phase 4: schema verdict policy.
|
|
24
|
+
*
|
|
25
|
+
* Composes the cluster-wide strict knob and the per-tool `outputSchemaStrict`
|
|
26
|
+
* override. Returns true when the SDK should refuse agent startup.
|
|
27
|
+
*
|
|
28
|
+
* Truth table:
|
|
29
|
+
* verdict=BLOCK + toolStrict=true -> refuse
|
|
30
|
+
* verdict=BLOCK + toolStrict=false -> log only (override wins)
|
|
31
|
+
* verdict=WARN + clusterStrict=true + toolStrict=true -> refuse
|
|
32
|
+
* verdict=WARN + clusterStrict=true + toolStrict=false -> log only
|
|
33
|
+
* verdict=WARN + clusterStrict=false -> log only
|
|
34
|
+
* verdict=OK -> never refuse
|
|
35
|
+
*/
|
|
36
|
+
export function shouldRefuseStartup(verdict, clusterStrict, toolStrict) {
|
|
37
|
+
if (verdict === "BLOCK")
|
|
38
|
+
return toolStrict;
|
|
39
|
+
if (verdict === "WARN")
|
|
40
|
+
return clusterStrict && toolStrict;
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Normalize a raw JSON Schema via the Rust core.
|
|
45
|
+
*
|
|
46
|
+
* Resolves to `null`-fielded result if `@mcpmesh/core` does not yet expose
|
|
47
|
+
* `normalizeSchema` (legacy bundled binary). Logs a warning once per call.
|
|
48
|
+
* Callers should treat that as "schema fields unavailable, ship without".
|
|
49
|
+
*
|
|
50
|
+
* @throws Error when the normalizer returns verdict === "BLOCK". The caller
|
|
51
|
+
* is expected to surface this with an actionable message including
|
|
52
|
+
* the function/dependency name (we don't have that context here).
|
|
53
|
+
*/
|
|
54
|
+
export function normalizeSchemaRaw(raw, contextLabel) {
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
const normalizeFn = core.normalizeSchema;
|
|
57
|
+
if (typeof normalizeFn !== "function") {
|
|
58
|
+
console.warn(`[mesh] normalizeSchema not found in @mcpmesh/core for ${contextLabel} ` +
|
|
59
|
+
`(rebuild napi binding to enable schema canonicalization)`);
|
|
60
|
+
return { canonicalJson: null, hash: null, verdict: "OK", warnings: [] };
|
|
61
|
+
}
|
|
62
|
+
let parsed;
|
|
63
|
+
try {
|
|
64
|
+
parsed = JSON.parse(normalizeFn(JSON.stringify(raw), "typescript"));
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
console.warn(`[mesh] schema normalization failed for ${contextLabel}: ${err instanceof Error ? err.message : String(err)}`);
|
|
68
|
+
return { canonicalJson: null, hash: null, verdict: "OK", warnings: [] };
|
|
69
|
+
}
|
|
70
|
+
const verdict = parsed.verdict ?? "OK";
|
|
71
|
+
const warnings = parsed.warnings ?? [];
|
|
72
|
+
if (verdict === "BLOCK") {
|
|
73
|
+
throw new Error(`Schema normalization BLOCKED for ${contextLabel}: ${warnings.join("; ")}. Cannot start agent.`);
|
|
74
|
+
}
|
|
75
|
+
const canonicalJson = parsed.canonical !== undefined && parsed.canonical !== null
|
|
76
|
+
? JSON.stringify(parsed.canonical)
|
|
77
|
+
: null;
|
|
78
|
+
const hash = parsed.hash || null;
|
|
79
|
+
return { canonicalJson, hash, verdict, warnings };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Issue #547 Phase 4: apply the verdict policy on top of {@link normalizeSchemaRaw}.
|
|
83
|
+
*
|
|
84
|
+
* Use this from callsites that need the per-tool override to take effect.
|
|
85
|
+
* Returns the (possibly warning-tagged) result, or throws when startup must
|
|
86
|
+
* be refused. Logs WARN/demoted-BLOCK loudly so they show up in normal
|
|
87
|
+
* deployments.
|
|
88
|
+
*/
|
|
89
|
+
export function normalizeSchemaWithPolicy(raw, contextLabel, clusterStrict, toolStrict) {
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
const normalizeFn = core.normalizeSchema;
|
|
92
|
+
if (typeof normalizeFn !== "function") {
|
|
93
|
+
console.warn(`[mesh] normalizeSchema not found in @mcpmesh/core for ${contextLabel} ` +
|
|
94
|
+
`(rebuild napi binding to enable schema canonicalization)`);
|
|
95
|
+
return { canonicalJson: null, hash: null, verdict: "OK", warnings: [] };
|
|
96
|
+
}
|
|
97
|
+
let parsed;
|
|
98
|
+
try {
|
|
99
|
+
parsed = JSON.parse(normalizeFn(JSON.stringify(raw), "typescript"));
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
console.warn(`[mesh] schema normalization failed for ${contextLabel}: ${err instanceof Error ? err.message : String(err)}`);
|
|
103
|
+
return { canonicalJson: null, hash: null, verdict: "OK", warnings: [] };
|
|
104
|
+
}
|
|
105
|
+
const verdict = parsed.verdict ?? "OK";
|
|
106
|
+
let warnings = parsed.warnings ?? [];
|
|
107
|
+
if (shouldRefuseStartup(verdict, clusterStrict, toolStrict)) {
|
|
108
|
+
const promoted = verdict === "WARN"
|
|
109
|
+
? " (MCP_MESH_SCHEMA_STRICT=true upgraded WARN→BLOCK)"
|
|
110
|
+
: "";
|
|
111
|
+
throw new Error(`Schema normalization ${verdict} for ${contextLabel}${promoted}: ${warnings.join("; ")}. Cannot start agent.`);
|
|
112
|
+
}
|
|
113
|
+
if (verdict === "BLOCK") {
|
|
114
|
+
// Demoted by per-tool override — log loudly + tag warnings.
|
|
115
|
+
console.warn(`[mesh] Schema BLOCK demoted to WARN for ${contextLabel} ` +
|
|
116
|
+
`(outputSchemaStrict=false): ${warnings.join("; ")}`);
|
|
117
|
+
warnings = warnings.map((w) => `[demoted from BLOCK] ${w}`);
|
|
118
|
+
}
|
|
119
|
+
else if (verdict === "WARN") {
|
|
120
|
+
console.warn(`[mesh] Schema WARN for ${contextLabel}: ${warnings.join("; ")}`);
|
|
121
|
+
}
|
|
122
|
+
const canonicalJson = parsed.canonical !== undefined && parsed.canonical !== null
|
|
123
|
+
? JSON.stringify(parsed.canonical)
|
|
124
|
+
: null;
|
|
125
|
+
const hash = parsed.hash || null;
|
|
126
|
+
return { canonicalJson, hash, verdict, warnings };
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=schema-normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-normalize.js","sourceRoot":"","sources":["../src/schema-normalize.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAatC;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;IAC7C,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAClC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAe,EACf,aAAsB,EACtB,UAAmB;IAEnB,IAAI,OAAO,KAAK,OAAO;QAAE,OAAO,UAAU,CAAC;IAC3C,IAAI,OAAO,KAAK,MAAM;QAAE,OAAO,aAAa,IAAI,UAAU,CAAC;IAC3D,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAChC,GAAW,EACX,YAAoB;IAEpB,8DAA8D;IAC9D,MAAM,WAAW,GAAI,IAAY,CAAC,eAErB,CAAC;IAEd,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;QACtC,OAAO,CAAC,IAAI,CACV,yDAAyD,YAAY,GAAG;YACtE,0DAA0D,CAC7D,CAAC;QACF,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,E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AAI,CAAC,uBAAuB,CAC9G,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;QACxB,4DAA4D;QAC5D,OAAO,CAAC,IAAI,CACV,2CAA2C,YAAY,GAAG;YACxD,+BAA+B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACvD,CAAC;QACF,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;SAAM,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,0BAA0B,YAAY,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,MAAM,aAAa,GACjB,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,KAAK,IAAI;QACzD,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC;QAClC,CAAC,CAAC,IAAI,CAAC;IACX,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC;IACjC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSE streaming helper for Express route handlers.
|
|
3
|
+
*
|
|
4
|
+
* Pipes any ``AsyncIterable<string>`` to an Express ``Response`` as
|
|
5
|
+
* ``text/event-stream``. Designed to be called from inside a ``mesh.route``
|
|
6
|
+
* handler — for example, to forward chunks from a remote streaming tool to
|
|
7
|
+
* a browser client via SSE.
|
|
8
|
+
*
|
|
9
|
+
* Wire format mirrors the Python ``mesh.route`` SSE adapter:
|
|
10
|
+
* - ``data: <chunk>\n\n`` per item
|
|
11
|
+
* - ``data: [DONE]\n\n`` terminator on normal completion
|
|
12
|
+
* - ``event: error\ndata: <json>\n\n`` on per-chunk error
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { mesh } from "@mcpmesh/sdk";
|
|
17
|
+
*
|
|
18
|
+
* app.post("/plan", mesh.route(["trip_planner"], async (req, res, { trip_planner }) => {
|
|
19
|
+
* if (!trip_planner) return res.status(503).end();
|
|
20
|
+
* await mesh.sseStream(res, trip_planner.stream(req.body));
|
|
21
|
+
* }));
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
import type { Response } from "express";
|
|
25
|
+
/**
|
|
26
|
+
* Pipe an ``AsyncIterable<string>`` to an Express ``Response`` as SSE.
|
|
27
|
+
*
|
|
28
|
+
* Sets the standard SSE headers, writes one ``data: <chunk>\n\n`` frame per
|
|
29
|
+
* item from the iterable, and terminates with ``data: [DONE]\n\n``. On
|
|
30
|
+
* per-chunk error (e.g. the upstream stream throws), writes
|
|
31
|
+
* ``event: error\ndata: <json>\n\n`` and ends the response.
|
|
32
|
+
*
|
|
33
|
+
* Resolves when the response has been fully written. Callers do not need to
|
|
34
|
+
* call ``res.end()`` themselves.
|
|
35
|
+
*
|
|
36
|
+
* If the consumer disconnects mid-stream (``res.writableEnded``), iteration
|
|
37
|
+
* stops cleanly via the iterable's ``return()`` method (so the upstream
|
|
38
|
+
* proxy stream's ``finally`` block can release its underlying reader).
|
|
39
|
+
*
|
|
40
|
+
* @param res - Express response object
|
|
41
|
+
* @param source - Async iterable yielding strings
|
|
42
|
+
*/
|
|
43
|
+
export declare function sseStream(res: Response, source: AsyncIterable<string>): Promise<void>;
|
|
44
|
+
//# sourceMappingURL=sse-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse-stream.d.ts","sourceRoot":"","sources":["../src/sse-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAyBxC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,SAAS,CAC7B,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC,CAsGf"}
|