@mcpmesh/sdk 2.8.2 → 3.0.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__/agent-add-tool.spec.js +106 -0
- package/dist/__tests__/agent-add-tool.spec.js.map +1 -1
- package/dist/__tests__/api-runtime-apply-idempotency.spec.d.ts +2 -0
- package/dist/__tests__/api-runtime-apply-idempotency.spec.d.ts.map +1 -0
- package/dist/__tests__/api-runtime-apply-idempotency.spec.js +89 -0
- package/dist/__tests__/api-runtime-apply-idempotency.spec.js.map +1 -0
- package/dist/__tests__/claim-dispatcher-resume-cursor.test.d.ts +2 -0
- package/dist/__tests__/claim-dispatcher-resume-cursor.test.d.ts.map +1 -0
- package/dist/__tests__/claim-dispatcher-resume-cursor.test.js +145 -0
- package/dist/__tests__/claim-dispatcher-resume-cursor.test.js.map +1 -0
- package/dist/__tests__/dependency-apply-idempotency.spec.d.ts +2 -0
- package/dist/__tests__/dependency-apply-idempotency.spec.d.ts.map +1 -0
- package/dist/__tests__/dependency-apply-idempotency.spec.js +114 -0
- package/dist/__tests__/dependency-apply-idempotency.spec.js.map +1 -0
- package/dist/__tests__/service-view-types.spec.d.ts +2 -0
- package/dist/__tests__/service-view-types.spec.d.ts.map +1 -0
- package/dist/__tests__/service-view-types.spec.js +66 -0
- package/dist/__tests__/service-view-types.spec.js.map +1 -0
- package/dist/__tests__/service-view.spec.d.ts +2 -0
- package/dist/__tests__/service-view.spec.d.ts.map +1 -0
- package/dist/__tests__/service-view.spec.js +902 -0
- package/dist/__tests__/service-view.spec.js.map +1 -0
- package/dist/__tests__/superseded-signal.spec.d.ts +19 -0
- package/dist/__tests__/superseded-signal.spec.d.ts.map +1 -0
- package/dist/__tests__/superseded-signal.spec.js +222 -0
- package/dist/__tests__/superseded-signal.spec.js.map +1 -0
- package/dist/__tests__/worker-error-serde.spec.d.ts +2 -0
- package/dist/__tests__/worker-error-serde.spec.d.ts.map +1 -0
- package/dist/__tests__/worker-error-serde.spec.js +122 -0
- package/dist/__tests__/worker-error-serde.spec.js.map +1 -0
- package/dist/a2a/producer/mount.d.ts.map +1 -1
- package/dist/a2a/producer/mount.js +4 -0
- package/dist/a2a/producer/mount.js.map +1 -1
- package/dist/agent.d.ts +53 -3
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +406 -33
- package/dist/agent.js.map +1 -1
- package/dist/api-runtime.d.ts +9 -0
- package/dist/api-runtime.d.ts.map +1 -1
- package/dist/api-runtime.js +29 -0
- package/dist/api-runtime.js.map +1 -1
- package/dist/claim-dispatcher.d.ts +25 -1
- package/dist/claim-dispatcher.d.ts.map +1 -1
- package/dist/claim-dispatcher.js +51 -2
- package/dist/claim-dispatcher.js.map +1 -1
- package/dist/inbound-job-dispatch.d.ts +1 -1
- package/dist/inbound-job-dispatch.d.ts.map +1 -1
- package/dist/inbound-job-dispatch.js +8 -2
- package/dist/inbound-job-dispatch.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/llm-provider.d.ts +14 -16
- package/dist/llm-provider.d.ts.map +1 -1
- package/dist/llm-provider.js +2 -4
- package/dist/llm-provider.js.map +1 -1
- package/dist/llm.d.ts +1 -2
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +1 -2
- package/dist/llm.js.map +1 -1
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +37 -0
- package/dist/proxy.js.map +1 -1
- package/dist/route.d.ts.map +1 -1
- package/dist/route.js +5 -0
- package/dist/route.js.map +1 -1
- package/dist/service-view.d.ts +245 -0
- package/dist/service-view.d.ts.map +1 -0
- package/dist/service-view.js +210 -0
- package/dist/service-view.js.map +1 -0
- package/dist/settle.d.ts +22 -0
- package/dist/settle.d.ts.map +1 -1
- package/dist/settle.js +51 -22
- package/dist/settle.js.map +1 -1
- package/dist/superseded.d.ts +70 -0
- package/dist/superseded.d.ts.map +1 -0
- package/dist/superseded.js +99 -0
- package/dist/superseded.js.map +1 -0
- package/dist/tool-worker-entry.js +1 -12
- package/dist/tool-worker-entry.js.map +1 -1
- package/dist/tool-worker-pool.d.ts.map +1 -1
- package/dist/tool-worker-pool.js +1 -12
- package/dist/tool-worker-pool.js.map +1 -1
- package/dist/types.d.ts +31 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/worker-error-serde.d.ts +40 -0
- package/dist/worker-error-serde.d.ts.map +1 -0
- package/dist/worker-error-serde.js +86 -0
- package/dist/worker-error-serde.js.map +1 -0
- package/package.json +2 -2
package/dist/agent.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { FastMCP } from "fastmcp";
|
|
|
12
12
|
import type { z } from "zod";
|
|
13
13
|
import { type JsAgentHandle } from "@mcpmesh/core";
|
|
14
14
|
import type { AgentConfig, ResolvedAgentConfig, MeshToolDef, McpMeshTool, LlmProviderConfig } from "./types.js";
|
|
15
|
+
import { type ServiceProducerMethod } from "./service-view.js";
|
|
15
16
|
/**
|
|
16
17
|
* Globally-set symbol that user agent code can check to detect whether it
|
|
17
18
|
* is running inside a mesh tool-isolation worker. The mesh runtime sets
|
|
@@ -40,6 +41,7 @@ export declare const IN_WORKER_SYMBOL: unique symbol;
|
|
|
40
41
|
export declare function __getWorkerToolMap(): Map<string, (...args: unknown[]) => unknown>;
|
|
41
42
|
/** Test support: drop the warn-once dedupe so a fresh suite warns again. */
|
|
42
43
|
export declare function __resetUnwiredSlotWarnedForTests(): void;
|
|
44
|
+
export declare function depSignature(endpoint: string, functionName: string, kwargs: unknown, agentId: string): string;
|
|
43
45
|
/**
|
|
44
46
|
* MeshAgent wraps a FastMCP server with MCP Mesh capabilities.
|
|
45
47
|
*
|
|
@@ -98,6 +100,7 @@ export declare class MeshAgent {
|
|
|
98
100
|
* different tags/settings without overwriting each other.
|
|
99
101
|
*/
|
|
100
102
|
private resolvedDeps;
|
|
103
|
+
private appliedDepSignatures;
|
|
101
104
|
private _workerMode;
|
|
102
105
|
/**
|
|
103
106
|
* Phase 1 MeshJob substrate: per-tool ClaimHandler for `task: true`
|
|
@@ -150,6 +153,34 @@ export declare class MeshAgent {
|
|
|
150
153
|
* they will be injected positionally at runtime.
|
|
151
154
|
*/
|
|
152
155
|
addTool<T extends z.ZodType>(def: MeshToolDef<T>): this;
|
|
156
|
+
/**
|
|
157
|
+
* RFC #1280 producer sugar: publish each entry of `methods` as an ordinary
|
|
158
|
+
* mesh tool with capability `prefix.<method>`, routed through the SAME
|
|
159
|
+
* `addTool` machinery (schemas, heartbeat, DI, duplicate handling all fall
|
|
160
|
+
* out). Entries are registered NAME-SORTED for deterministic registration.
|
|
161
|
+
*
|
|
162
|
+
* Each entry is either a bare execute function (shorthand) or an object
|
|
163
|
+
* `{ execute, parameters?, tags?, version?, description?, dependencies?, ... }`
|
|
164
|
+
* carrying any `addTool` passthrough (but NOT `name`/`capability` — those are
|
|
165
|
+
* derived). A method with no `parameters` gets a permissive passthrough schema.
|
|
166
|
+
*
|
|
167
|
+
* The prefix AND every derived capability are validated against the segment-
|
|
168
|
+
* wise dotted grammar (kept in lockstep with the Go registry validator —
|
|
169
|
+
* src/core/registry/validation.go). addTool applies the same grammar to its
|
|
170
|
+
* produced capability (#1293 item 6), so both surfaces validate a PRODUCED
|
|
171
|
+
* capability name before it reaches the registry; dependency capability names
|
|
172
|
+
* remain the registry's authority.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* agent.addService("media", {
|
|
177
|
+
* caption: async (args) => ({ caption: `...${args.text}` }),
|
|
178
|
+
* thumbnail: { execute: async (args) => ({ url: "..." }), tags: ["fast"] },
|
|
179
|
+
* });
|
|
180
|
+
* // → tools/capabilities "media.caption" and "media.thumbnail"
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
addService(prefix: string, methods: Record<string, ServiceProducerMethod>): this;
|
|
153
184
|
/**
|
|
154
185
|
* Add an LLM provider to the agent.
|
|
155
186
|
*
|
|
@@ -197,19 +228,38 @@ export declare class MeshAgent {
|
|
|
197
228
|
* Build the positional dependency-slot array for one tool call, shared by
|
|
198
229
|
* BOTH the inbound HTTP wrapper (wrappedExecute) and the claim-dispatch
|
|
199
230
|
* path (the ClaimHandler for task:true tools). Centralising this keeps the
|
|
200
|
-
* two slot-assembly sites identical:
|
|
231
|
+
* two slot-assembly sites identical. One entry per AUTHORED slot:
|
|
232
|
+
* - a service-view slot (RFC #1280) → a facade over its method edges
|
|
201
233
|
* - the MeshJob slot (meshJobDepIndex) → a freshly-bound MeshJobSubmitter
|
|
202
|
-
* - every other slot → resolvedDeps.get(`${toolName}:dep_${
|
|
234
|
+
* - every other slot → resolvedDeps.get(`${toolName}:dep_${edgeIndex}`) ?? null
|
|
235
|
+
*
|
|
236
|
+
* `depSlots` carries the slot→edge mapping (a `dep` slot owns one edge; a
|
|
237
|
+
* `view` slot owns a contiguous edge range). `edges` is the flat edge array;
|
|
238
|
+
* a slot's proxy/capability is read via its edge index.
|
|
203
239
|
*
|
|
204
240
|
* #1231: a typed dep slot can resolve at the registry yet never receive an
|
|
205
241
|
* injected proxy, leaving the parameter null. Once the settle latch has
|
|
206
242
|
* flipped (during settling the proxy may still land), warn ONCE per
|
|
207
243
|
* tool+slot — the array is rebuilt per call, so a per-call warning would
|
|
208
|
-
* spam. The warn-once dedupe keys on `${toolName}:dep_${
|
|
244
|
+
* spam. The warn-once dedupe keys on `${toolName}:dep_${edgeIndex}` via the
|
|
209
245
|
* module-level `_unwiredSlotWarned` Set, so a tool exercised via BOTH the
|
|
210
246
|
* inbound and claim paths warns at most once total.
|
|
211
247
|
*/
|
|
212
248
|
private _buildDepSlots;
|
|
249
|
+
/**
|
|
250
|
+
* RFC #1280: build the facade injected at a service-view slot. Each facade
|
|
251
|
+
* method reads its edge's CURRENT proxy from `resolvedDeps` at call time —
|
|
252
|
+
* rebinding-free: a `dependency_available`/`unavailable` event swapping the
|
|
253
|
+
* per-edge proxy is observed on the next call without rebuilding the facade.
|
|
254
|
+
*
|
|
255
|
+
* The `minAvailable` floor is enforced BEFORE delegation on every call: below
|
|
256
|
+
* the floor during the settling window (#1193) the method performs the same
|
|
257
|
+
* bounded, capability-keyed wait the injected-proxy path uses, recounts, then
|
|
258
|
+
* throws {@link MeshServiceUnavailableError}. An unresolved OPTIONAL method
|
|
259
|
+
* edge throws a `TypeError` — the same failure shape a directly-injected
|
|
260
|
+
* unresolved `McpMeshTool` (a null proxy) produces when called.
|
|
261
|
+
*/
|
|
262
|
+
private _buildServiceViewFacade;
|
|
213
263
|
private _getOrBuildA2AClient;
|
|
214
264
|
/**
|
|
215
265
|
* Convert Zod schema to JSON Schema.
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,OAAO,EAGL,KAAK,aAAa,EAInB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,WAAW,EAEX,WAAW,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,OAAO,EAGL,KAAK,aAAa,EAInB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,WAAW,EAEX,WAAW,EAGX,iBAAiB,EAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAQL,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB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