@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.
Files changed (92) hide show
  1. package/dist/__tests__/agent-add-tool.spec.js +106 -0
  2. package/dist/__tests__/agent-add-tool.spec.js.map +1 -1
  3. package/dist/__tests__/api-runtime-apply-idempotency.spec.d.ts +2 -0
  4. package/dist/__tests__/api-runtime-apply-idempotency.spec.d.ts.map +1 -0
  5. package/dist/__tests__/api-runtime-apply-idempotency.spec.js +89 -0
  6. package/dist/__tests__/api-runtime-apply-idempotency.spec.js.map +1 -0
  7. package/dist/__tests__/claim-dispatcher-resume-cursor.test.d.ts +2 -0
  8. package/dist/__tests__/claim-dispatcher-resume-cursor.test.d.ts.map +1 -0
  9. package/dist/__tests__/claim-dispatcher-resume-cursor.test.js +145 -0
  10. package/dist/__tests__/claim-dispatcher-resume-cursor.test.js.map +1 -0
  11. package/dist/__tests__/dependency-apply-idempotency.spec.d.ts +2 -0
  12. package/dist/__tests__/dependency-apply-idempotency.spec.d.ts.map +1 -0
  13. package/dist/__tests__/dependency-apply-idempotency.spec.js +114 -0
  14. package/dist/__tests__/dependency-apply-idempotency.spec.js.map +1 -0
  15. package/dist/__tests__/service-view-types.spec.d.ts +2 -0
  16. package/dist/__tests__/service-view-types.spec.d.ts.map +1 -0
  17. package/dist/__tests__/service-view-types.spec.js +66 -0
  18. package/dist/__tests__/service-view-types.spec.js.map +1 -0
  19. package/dist/__tests__/service-view.spec.d.ts +2 -0
  20. package/dist/__tests__/service-view.spec.d.ts.map +1 -0
  21. package/dist/__tests__/service-view.spec.js +902 -0
  22. package/dist/__tests__/service-view.spec.js.map +1 -0
  23. package/dist/__tests__/superseded-signal.spec.d.ts +19 -0
  24. package/dist/__tests__/superseded-signal.spec.d.ts.map +1 -0
  25. package/dist/__tests__/superseded-signal.spec.js +222 -0
  26. package/dist/__tests__/superseded-signal.spec.js.map +1 -0
  27. package/dist/__tests__/worker-error-serde.spec.d.ts +2 -0
  28. package/dist/__tests__/worker-error-serde.spec.d.ts.map +1 -0
  29. package/dist/__tests__/worker-error-serde.spec.js +122 -0
  30. package/dist/__tests__/worker-error-serde.spec.js.map +1 -0
  31. package/dist/a2a/producer/mount.d.ts.map +1 -1
  32. package/dist/a2a/producer/mount.js +4 -0
  33. package/dist/a2a/producer/mount.js.map +1 -1
  34. package/dist/agent.d.ts +53 -3
  35. package/dist/agent.d.ts.map +1 -1
  36. package/dist/agent.js +406 -33
  37. package/dist/agent.js.map +1 -1
  38. package/dist/api-runtime.d.ts +9 -0
  39. package/dist/api-runtime.d.ts.map +1 -1
  40. package/dist/api-runtime.js +29 -0
  41. package/dist/api-runtime.js.map +1 -1
  42. package/dist/claim-dispatcher.d.ts +25 -1
  43. package/dist/claim-dispatcher.d.ts.map +1 -1
  44. package/dist/claim-dispatcher.js +51 -2
  45. package/dist/claim-dispatcher.js.map +1 -1
  46. package/dist/inbound-job-dispatch.d.ts +1 -1
  47. package/dist/inbound-job-dispatch.d.ts.map +1 -1
  48. package/dist/inbound-job-dispatch.js +8 -2
  49. package/dist/inbound-job-dispatch.js.map +1 -1
  50. package/dist/index.d.ts +6 -2
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +9 -2
  53. package/dist/index.js.map +1 -1
  54. package/dist/llm-provider.d.ts +14 -16
  55. package/dist/llm-provider.d.ts.map +1 -1
  56. package/dist/llm-provider.js +2 -4
  57. package/dist/llm-provider.js.map +1 -1
  58. package/dist/llm.d.ts +1 -2
  59. package/dist/llm.d.ts.map +1 -1
  60. package/dist/llm.js +1 -2
  61. package/dist/llm.js.map +1 -1
  62. package/dist/proxy.d.ts.map +1 -1
  63. package/dist/proxy.js +37 -0
  64. package/dist/proxy.js.map +1 -1
  65. package/dist/route.d.ts.map +1 -1
  66. package/dist/route.js +5 -0
  67. package/dist/route.js.map +1 -1
  68. package/dist/service-view.d.ts +245 -0
  69. package/dist/service-view.d.ts.map +1 -0
  70. package/dist/service-view.js +210 -0
  71. package/dist/service-view.js.map +1 -0
  72. package/dist/settle.d.ts +22 -0
  73. package/dist/settle.d.ts.map +1 -1
  74. package/dist/settle.js +51 -22
  75. package/dist/settle.js.map +1 -1
  76. package/dist/superseded.d.ts +70 -0
  77. package/dist/superseded.d.ts.map +1 -0
  78. package/dist/superseded.js +99 -0
  79. package/dist/superseded.js.map +1 -0
  80. package/dist/tool-worker-entry.js +1 -12
  81. package/dist/tool-worker-entry.js.map +1 -1
  82. package/dist/tool-worker-pool.d.ts.map +1 -1
  83. package/dist/tool-worker-pool.js +1 -12
  84. package/dist/tool-worker-pool.js.map +1 -1
  85. package/dist/types.d.ts +31 -1
  86. package/dist/types.d.ts.map +1 -1
  87. package/dist/types.js.map +1 -1
  88. package/dist/worker-error-serde.d.ts +40 -0
  89. package/dist/worker-error-serde.d.ts.map +1 -0
  90. package/dist/worker-error-serde.js +86 -0
  91. package/dist/worker-error-serde.js.map +1 -0
  92. package/package.json +2 -2
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Service views (RFC #1280) for the TypeScript SDK.
3
+ *
4
+ * Two related roles, mirroring the Java runtime (`@McpMeshService`) so the
5
+ * cross-runtime contract (integration suite uc37) holds identically:
6
+ *
7
+ * 1. CONSUMER VIEW — `mesh.serviceView({ methods, minAvailable? })` produces a
8
+ * branded object that occupies ONE positional dependency slot in a tool's
9
+ * `dependencies` array but expands into N ordinary dependency edges (one per
10
+ * method, SORTED BY NAME for deterministic registration). At call time the
11
+ * framework injects a facade whose methods delegate to each edge's own
12
+ * resolved proxy — so different methods may bind different provider agents
13
+ * and rebind independently as topology changes. There are NO wire or
14
+ * registry changes: every method is an ordinary dependency edge.
15
+ *
16
+ * 2. PRODUCER SUGAR — `agent.addService("prefix", { ... })` publishes each
17
+ * entry (name-sorted) as an ordinary mesh tool with capability
18
+ * `prefix.<method>` through the existing `addTool` machinery.
19
+ *
20
+ * A service view is purely consumer-local: there is no group versioning and no
21
+ * interface-level availability summary. The optional `minAvailable` floor is a
22
+ * consumer-local circuit breaker with no wire effect.
23
+ */
24
+ import { z } from "zod";
25
+ import type { DependencySpec, NormalizedDependency, TagSpec, MeshToolDef } from "./types.js";
26
+ /**
27
+ * Reject any {@link ServiceView} in a dependency list for a surface that does
28
+ * NOT support the tool-parameter facade form (mesh.route, mesh.a2a.mount). A
29
+ * view there would normalize to a `capability: undefined` edge — a settle key
30
+ * that never resolves plus a nameless dependency shipped to the registry.
31
+ * Shared by every such call site so the error message + policy stay identical.
32
+ */
33
+ export declare function assertNoServiceViewDeps(deps: ReadonlyArray<unknown>, surface: string): void;
34
+ /**
35
+ * Segment-wise dotted capability-name grammar. Kept in lockstep with the Go
36
+ * registry validator's `capabilityNamePattern`
37
+ * (src/core/registry/validation.go: `^[a-zA-Z][a-zA-Z0-9_-]*(\.[a-zA-Z][a-zA-Z0-9_-]*)*$`)
38
+ * and the Python/Java runtimes. Applied to the PRODUCED capability names of
39
+ * `agent.addService` (the derived `prefix.method`) and `agent.addTool`
40
+ * (`capability ?? name`, #1293 item 6) — both validate before the name reaches
41
+ * the registry. Dependency capability names are deliberately left unvalidated
42
+ * (the registry remains their single authority).
43
+ */
44
+ export declare const CAPABILITY_NAME_PATTERN: RegExp;
45
+ /**
46
+ * Brand symbol marking a `mesh.serviceView(...)` result so the dependency
47
+ * expander can detect a view slot structurally (config-over-reflection, the
48
+ * same precedent as `meshJobDepIndex`). `Symbol.for` keeps the brand stable
49
+ * across duplicate module instances.
50
+ */
51
+ export declare const SERVICE_VIEW_BRAND: unique symbol;
52
+ /** A single view method — a capability string shorthand or a full selector. */
53
+ export type ServiceViewMethodSpec = string | {
54
+ /** Capability this method binds. */
55
+ capability: string;
56
+ /** Tags for filtering (supports OR alternatives via nested arrays). */
57
+ tags?: TagSpec[];
58
+ /** Version constraint (e.g. ">=2.0.0"). */
59
+ version?: string;
60
+ /** Issue #1249 opt-in strictness for this edge (default soft-fail). */
61
+ required?: boolean;
62
+ /**
63
+ * Issue #547: optional Zod schema describing the expected provider
64
+ * response for this method edge (parity with Java `@Selector` schema
65
+ * matching). Passed through `normalizeDependency` exactly like an ordinary
66
+ * object dependency, so the registry filters providers by canonical hash.
67
+ */
68
+ expectedSchema?: z.ZodType<unknown>;
69
+ /** Issue #547: schema match mode (defaults to "subset" when expectedSchema set). */
70
+ matchMode?: "subset" | "strict";
71
+ };
72
+ /**
73
+ * A consumer service-view specification. `methods` maps facade method names to
74
+ * their capability binding; the injected facade exposes exactly these keys.
75
+ */
76
+ export interface ServiceViewSpec {
77
+ /** Facade method name → capability binding. At least one entry required. */
78
+ methods: Record<string, ServiceViewMethodSpec>;
79
+ /**
80
+ * Optional availability floor. When fewer than `minAvailable` of the view's
81
+ * methods currently resolve, EVERY facade call throws
82
+ * {@link MeshServiceUnavailableError} — a consumer-local circuit breaker with
83
+ * no wire effect. Default 0 = no floor (each method soft/hard-fails per its
84
+ * own `required` flag).
85
+ */
86
+ minAvailable?: number;
87
+ /** Optional label surfaced in floor-breach errors and logs. */
88
+ name?: string;
89
+ }
90
+ /**
91
+ * A single facade method. Signature mirrors {@link import("./types.js").McpMeshTool}'s
92
+ * callable form so a view method is a drop-in for a directly-injected proxy.
93
+ */
94
+ export type MeshServiceFacadeMethod = (args?: Record<string, unknown>, options?: {
95
+ headers?: Record<string, string>;
96
+ }) => Promise<unknown>;
97
+ /**
98
+ * The injected facade type inferred from a {@link ServiceView} (or a bare
99
+ * {@link ServiceViewSpec}). Each spec method key becomes a callable facade
100
+ * method.
101
+ *
102
+ * **How to type the view slot in `execute`:** leave the positional parameters
103
+ * un-annotated (they infer as the injected `McpMeshTool | MeshJob | null`
104
+ * union) and narrow the view slot with a cast at point of use. A direct
105
+ * parameter annotation (`media: MeshServiceFacade<typeof Media>`) does NOT
106
+ * compile under `strictFunctionTypes`: `execute`'s dependency parameters are
107
+ * checked contravariantly, so any type narrower than the full injected union —
108
+ * including a plain `McpMeshTool | null` — is rejected. This is why the cast
109
+ * idiom is the canonical form (it also matches how ordinary `McpMeshTool` deps
110
+ * are consumed):
111
+ *
112
+ * ```ts
113
+ * import { mesh, type MeshServiceFacade } from "@mcpmesh/sdk";
114
+ *
115
+ * const Media = mesh.serviceView({ methods: { caption: "media.caption" } });
116
+ *
117
+ * agent.addTool({
118
+ * name: "process",
119
+ * parameters: z.object({ text: z.string() }),
120
+ * dependencies: ["audit_log", Media],
121
+ * execute: async (args, auditLog, media) => {
122
+ * const svc = media as MeshServiceFacade<typeof Media>;
123
+ * return await svc.caption({ text: args.text });
124
+ * },
125
+ * });
126
+ * ```
127
+ */
128
+ export type MeshServiceFacade<V> = V extends ServiceView<infer S> ? {
129
+ [K in keyof S["methods"]]: MeshServiceFacadeMethod;
130
+ } : V extends ServiceViewSpec ? {
131
+ [K in keyof V["methods"]]: MeshServiceFacadeMethod;
132
+ } : never;
133
+ /**
134
+ * A branded service-view value produced by {@link serviceView}. Placed in a
135
+ * tool's `dependencies` array where it occupies one positional slot.
136
+ */
137
+ export interface ServiceView<S extends ServiceViewSpec = ServiceViewSpec> {
138
+ readonly [SERVICE_VIEW_BRAND]: true;
139
+ readonly spec: S;
140
+ }
141
+ /** Structural brand check — true for a `mesh.serviceView(...)` result. */
142
+ export declare function isServiceView(value: unknown): value is ServiceView;
143
+ /**
144
+ * Thrown by every facade call when a view is below its declared
145
+ * {@link ServiceViewSpec.minAvailable} floor. Carries the view label plus the
146
+ * current/total/floor counts so the failure is actionable. Mirrors Java's
147
+ * `MeshServiceUnavailableException`.
148
+ */
149
+ export declare class MeshServiceUnavailableError extends Error {
150
+ /** View label (spec.name or a derived owner:slot label). */
151
+ readonly service: string;
152
+ /** View methods currently resolving to a provider. */
153
+ readonly available: number;
154
+ /** Total dependency-bound view methods. */
155
+ readonly total: number;
156
+ /** The declared availability floor. */
157
+ readonly floor: number;
158
+ readonly name = "MeshServiceUnavailableError";
159
+ constructor(
160
+ /** View label (spec.name or a derived owner:slot label). */
161
+ service: string,
162
+ /** View methods currently resolving to a provider. */
163
+ available: number,
164
+ /** Total dependency-bound view methods. */
165
+ total: number,
166
+ /** The declared availability floor. */
167
+ floor: number);
168
+ }
169
+ /**
170
+ * Construct a consumer service view. Validates the spec at construction time
171
+ * (empty methods map; blank capability; out-of-range `minAvailable`) so misuse
172
+ * fails loud before the agent talks to the registry.
173
+ */
174
+ export declare function serviceView<S extends ServiceViewSpec>(spec: S): ServiceView<S>;
175
+ /** One view method's flat-edge placement within the expanded dependency list. */
176
+ export interface ViewMethodEdge {
177
+ /** Facade method name (spec key). */
178
+ method: string;
179
+ /** Index into the flat edge array (settle-key / resolvedDeps / wire index). */
180
+ edgeIndex: number;
181
+ }
182
+ /**
183
+ * One positional dependency slot after expansion. A `dep` slot maps to exactly
184
+ * one edge; a `view` slot collapses N edges into a single facade argument. The
185
+ * disjoint edge ranges are tracked here (mirrors Java's index-range mapping).
186
+ */
187
+ export type DepSlot = {
188
+ kind: "dep";
189
+ edgeIndex: number;
190
+ } | {
191
+ kind: "view";
192
+ name: string;
193
+ minAvailable: number;
194
+ methods: ViewMethodEdge[];
195
+ };
196
+ /** Result of expanding a mixed `(DependencySpec | ServiceView)[]` list. */
197
+ export interface ExpandedDeps {
198
+ /**
199
+ * Flat dependency edges in wire/settle/resolve order. This is what ships to
200
+ * the registry, what settle keys index (`owner:dep_<edgeIndex>`), what
201
+ * `dependency_available` events address, and what `resolvedDeps` keys — one
202
+ * entry per edge, view methods expanded IN-PLACE at the view's array position
203
+ * in NAME-SORTED order.
204
+ */
205
+ edges: NormalizedDependency[];
206
+ /**
207
+ * Positional execute slots (one per authored `dependencies` entry). A view
208
+ * entry is ONE slot spanning a contiguous edge range; a non-view entry is one
209
+ * slot mapping to one edge. For a view-free list `slots[i].edgeIndex === i`.
210
+ */
211
+ slots: DepSlot[];
212
+ }
213
+ /**
214
+ * Expand a tool's authored dependency list (a mix of {@link DependencySpec} and
215
+ * {@link ServiceView}) into the flat edge array + the positional slot layout.
216
+ *
217
+ * Layout contract (identical to the Java runtime — see uc37):
218
+ * - non-view entries keep their exact slot↔edge pairing;
219
+ * - a view entry contributes ONE slot at its array position but N edges,
220
+ * expanded IN-PLACE (name-sorted) so the flat edge indices stay contiguous
221
+ * and every downstream index consumer (settle keys, wire payload,
222
+ * resolution events, required guard) sees ordinary edges.
223
+ *
224
+ * For a view-free list this returns `edges` byte-identical to
225
+ * `deps.map(normalizeDependency)` and `slots[i] = { kind: "dep", edgeIndex: i }`
226
+ * — zero behavior change.
227
+ */
228
+ export declare function expandDependencies(deps: ReadonlyArray<DependencySpec | ServiceView>, ownerLabel: string): ExpandedDeps;
229
+ /**
230
+ * A producer method for `agent.addService`. Either a bare execute function
231
+ * (shorthand) or an object carrying `execute` plus any `addTool` passthrough
232
+ * (tags/version/description/parameters/dependencies/...). `name` and
233
+ * `capability` are DERIVED (`prefix.<method>`) and must not be supplied.
234
+ */
235
+ export type ServiceProducerMethod = ((...args: never[]) => Promise<unknown> | unknown) | ServiceProducerMethodObject;
236
+ /** Object form of a {@link ServiceProducerMethod}. */
237
+ export type ServiceProducerMethodObject = Omit<Partial<MeshToolDef>, "name" | "capability" | "execute" | "parameters"> & {
238
+ /** Method implementation (positional deps injected after args, as usual). */
239
+ execute: MeshToolDef["execute"];
240
+ /** Optional Zod input schema. Defaults to a permissive passthrough object. */
241
+ parameters?: z.ZodType;
242
+ };
243
+ /** Permissive default schema for producer methods that declare no `parameters`. */
244
+ export declare function defaultProducerParams(): z.ZodType;
245
+ //# sourceMappingURL=service-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-view.d.ts","sourceRoot":"","sources":["../src/service-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,OAAO,EACP,WAAW,EACZ,MAAM,YAAY,CAAC;AAGpB;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EA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ACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B,CAAC;AAEN,2EAA2E;AAC3E,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B;;;;OAIG;IACH,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB;AAgBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,aAAa,CAAC,cAAc,GAAG,WAAW,CAAC,EACjD,UAAU,EAAE,MAAM,GACjB,YAAY,CAgDd;AAED;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAC7B,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,GAClD,2BAA2B,CAAC;AAEhC,sDAAsD;AACtD,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAC5C,OAAO,CAAC,WAAW,CAAC,EACpB,MAAM,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,CACjD,GAAG;IACF,6EAA6E;IAC7E,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAChC,8EAA8E;IAC9E,UAAU,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;CACxB,CAAC;AAEF,mFAAmF;AACnF,wBAAgB,qBAAqB,IAAI,CAAC,CAAC,OAAO,CAEjD"}
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Service views (RFC #1280) for the TypeScript SDK.
3
+ *
4
+ * Two related roles, mirroring the Java runtime (`@McpMeshService`) so the
5
+ * cross-runtime contract (integration suite uc37) holds identically:
6
+ *
7
+ * 1. CONSUMER VIEW — `mesh.serviceView({ methods, minAvailable? })` produces a
8
+ * branded object that occupies ONE positional dependency slot in a tool's
9
+ * `dependencies` array but expands into N ordinary dependency edges (one per
10
+ * method, SORTED BY NAME for deterministic registration). At call time the
11
+ * framework injects a facade whose methods delegate to each edge's own
12
+ * resolved proxy — so different methods may bind different provider agents
13
+ * and rebind independently as topology changes. There are NO wire or
14
+ * registry changes: every method is an ordinary dependency edge.
15
+ *
16
+ * 2. PRODUCER SUGAR — `agent.addService("prefix", { ... })` publishes each
17
+ * entry (name-sorted) as an ordinary mesh tool with capability
18
+ * `prefix.<method>` through the existing `addTool` machinery.
19
+ *
20
+ * A service view is purely consumer-local: there is no group versioning and no
21
+ * interface-level availability summary. The optional `minAvailable` floor is a
22
+ * consumer-local circuit breaker with no wire effect.
23
+ */
24
+ import { z } from "zod";
25
+ import { normalizeDependency } from "./proxy.js";
26
+ /**
27
+ * Reject any {@link ServiceView} in a dependency list for a surface that does
28
+ * NOT support the tool-parameter facade form (mesh.route, mesh.a2a.mount). A
29
+ * view there would normalize to a `capability: undefined` edge — a settle key
30
+ * that never resolves plus a nameless dependency shipped to the registry.
31
+ * Shared by every such call site so the error message + policy stay identical.
32
+ */
33
+ export function assertNoServiceViewDeps(deps, surface) {
34
+ for (const dep of deps) {
35
+ if (isServiceView(dep)) {
36
+ throw new Error(`${surface} does not support mesh.serviceView(...) dependencies ` +
37
+ `(RFC #1280 service views are a tool-parameter surface). Declare the ` +
38
+ `individual capability deps directly, or use a service view inside ` +
39
+ `agent.addTool(...).`);
40
+ }
41
+ }
42
+ }
43
+ /**
44
+ * Segment-wise dotted capability-name grammar. Kept in lockstep with the Go
45
+ * registry validator's `capabilityNamePattern`
46
+ * (src/core/registry/validation.go: `^[a-zA-Z][a-zA-Z0-9_-]*(\.[a-zA-Z][a-zA-Z0-9_-]*)*$`)
47
+ * and the Python/Java runtimes. Applied to the PRODUCED capability names of
48
+ * `agent.addService` (the derived `prefix.method`) and `agent.addTool`
49
+ * (`capability ?? name`, #1293 item 6) — both validate before the name reaches
50
+ * the registry. Dependency capability names are deliberately left unvalidated
51
+ * (the registry remains their single authority).
52
+ */
53
+ export const CAPABILITY_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9_-]*(\.[a-zA-Z][a-zA-Z0-9_-]*)*$/;
54
+ /**
55
+ * Brand symbol marking a `mesh.serviceView(...)` result so the dependency
56
+ * expander can detect a view slot structurally (config-over-reflection, the
57
+ * same precedent as `meshJobDepIndex`). `Symbol.for` keeps the brand stable
58
+ * across duplicate module instances.
59
+ */
60
+ export const SERVICE_VIEW_BRAND = Symbol.for("@mcpmesh/sdk/service-view");
61
+ /** Structural brand check — true for a `mesh.serviceView(...)` result. */
62
+ export function isServiceView(value) {
63
+ return (typeof value === "object" &&
64
+ value !== null &&
65
+ value[SERVICE_VIEW_BRAND] === true);
66
+ }
67
+ /**
68
+ * Thrown by every facade call when a view is below its declared
69
+ * {@link ServiceViewSpec.minAvailable} floor. Carries the view label plus the
70
+ * current/total/floor counts so the failure is actionable. Mirrors Java's
71
+ * `MeshServiceUnavailableException`.
72
+ */
73
+ export class MeshServiceUnavailableError extends Error {
74
+ service;
75
+ available;
76
+ total;
77
+ floor;
78
+ name = "MeshServiceUnavailableError";
79
+ constructor(
80
+ /** View label (spec.name or a derived owner:slot label). */
81
+ service,
82
+ /** View methods currently resolving to a provider. */
83
+ available,
84
+ /** Total dependency-bound view methods. */
85
+ total,
86
+ /** The declared availability floor. */
87
+ floor) {
88
+ super(`Mesh service view unavailable (${service}): ${available}/${total} ` +
89
+ `method(s) resolved, below the declared minAvailable=${floor} floor`);
90
+ this.service = service;
91
+ this.available = available;
92
+ this.total = total;
93
+ this.floor = floor;
94
+ }
95
+ }
96
+ /**
97
+ * Construct a consumer service view. Validates the spec at construction time
98
+ * (empty methods map; blank capability; out-of-range `minAvailable`) so misuse
99
+ * fails loud before the agent talks to the registry.
100
+ */
101
+ export function serviceView(spec) {
102
+ if (spec == null ||
103
+ typeof spec !== "object" ||
104
+ typeof spec.methods !== "object" ||
105
+ spec.methods === null ||
106
+ Array.isArray(spec.methods)) {
107
+ throw new Error("mesh.serviceView: `methods` must be an object mapping method names to " +
108
+ "capabilities.");
109
+ }
110
+ const keys = Object.keys(spec.methods);
111
+ if (keys.length === 0) {
112
+ throw new Error("mesh.serviceView: `methods` must declare at least one method (got an " +
113
+ "empty methods map).");
114
+ }
115
+ for (const key of keys) {
116
+ const m = spec.methods[key];
117
+ const capability = typeof m === "string" ? m : m?.capability;
118
+ if (typeof capability !== "string" || capability.trim() === "") {
119
+ throw new Error(`mesh.serviceView: method '${key}' has a blank capability.`);
120
+ }
121
+ }
122
+ const min = spec.minAvailable;
123
+ if (min !== undefined) {
124
+ if (!Number.isInteger(min) || min < 0) {
125
+ throw new Error(`mesh.serviceView: minAvailable must be an integer >= 0 (got ${min}).`);
126
+ }
127
+ if (min > keys.length) {
128
+ throw new Error(`mesh.serviceView: minAvailable=${min} exceeds the number of methods ` +
129
+ `(${keys.length}) — the floor can never be satisfied.`);
130
+ }
131
+ }
132
+ return {
133
+ [SERVICE_VIEW_BRAND]: true,
134
+ spec,
135
+ };
136
+ }
137
+ function normalizeViewMethod(m) {
138
+ if (typeof m === "string") {
139
+ return normalizeDependency(m);
140
+ }
141
+ return normalizeDependency({
142
+ capability: m.capability,
143
+ tags: m.tags,
144
+ version: m.version,
145
+ required: m.required,
146
+ expectedSchema: m.expectedSchema,
147
+ matchMode: m.matchMode,
148
+ });
149
+ }
150
+ /**
151
+ * Expand a tool's authored dependency list (a mix of {@link DependencySpec} and
152
+ * {@link ServiceView}) into the flat edge array + the positional slot layout.
153
+ *
154
+ * Layout contract (identical to the Java runtime — see uc37):
155
+ * - non-view entries keep their exact slot↔edge pairing;
156
+ * - a view entry contributes ONE slot at its array position but N edges,
157
+ * expanded IN-PLACE (name-sorted) so the flat edge indices stay contiguous
158
+ * and every downstream index consumer (settle keys, wire payload,
159
+ * resolution events, required guard) sees ordinary edges.
160
+ *
161
+ * For a view-free list this returns `edges` byte-identical to
162
+ * `deps.map(normalizeDependency)` and `slots[i] = { kind: "dep", edgeIndex: i }`
163
+ * — zero behavior change.
164
+ */
165
+ export function expandDependencies(deps, ownerLabel) {
166
+ const edges = [];
167
+ const slots = [];
168
+ deps.forEach((entry, slotIndex) => {
169
+ if (isServiceView(entry)) {
170
+ const spec = entry.spec;
171
+ // Object key order is insertion-based; MUST sort by name for a
172
+ // deterministic edge layout across runtimes.
173
+ const methodNames = Object.keys(spec.methods).sort();
174
+ const methods = [];
175
+ for (const method of methodNames) {
176
+ const edgeIndex = edges.length;
177
+ edges.push(normalizeViewMethod(spec.methods[method]));
178
+ methods.push({ method, edgeIndex });
179
+ }
180
+ slots.push({
181
+ kind: "view",
182
+ name: spec.name ?? `${ownerLabel}:view${slotIndex}`,
183
+ minAvailable: spec.minAvailable ?? 0,
184
+ methods,
185
+ });
186
+ return;
187
+ }
188
+ // Guard: an object without a `capability` in a dependencies array is almost
189
+ // certainly a producer-method object placed where a view/dep was expected
190
+ // (or a malformed spec). Fail loud rather than shipping a `capability:
191
+ // undefined` edge.
192
+ if (typeof entry === "object" &&
193
+ entry !== null &&
194
+ typeof entry.capability !== "string") {
195
+ throw new Error(`${ownerLabel}: dependency #${slotIndex} is an object without a ` +
196
+ `'capability' — expected a DependencySpec (string or { capability }) ` +
197
+ `or a mesh.serviceView(...). If this is a producer method, register ` +
198
+ `it with agent.addService(...).`);
199
+ }
200
+ const edgeIndex = edges.length;
201
+ edges.push(normalizeDependency(entry));
202
+ slots.push({ kind: "dep", edgeIndex });
203
+ });
204
+ return { edges, slots };
205
+ }
206
+ /** Permissive default schema for producer methods that declare no `parameters`. */
207
+ export function defaultProducerParams() {
208
+ return z.object({}).passthrough();
209
+ }
210
+ //# sourceMappingURL=service-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-view.js","sourceRoot":"","sources":["../src/service-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;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BACtD,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;YACtC,CAAC;YACD,KAAK,CAAC,IAAI,CAAC;gBACT,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,GAAG,UAAU,QAAQ,SAAS,EAAE;gBACnD,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,CAAC;gBACpC,OAAO;aACR,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,4EAA4E;QAC5E,0EAA0E;QAC1E,uEAAuE;QACvE,mBAAmB;QACnB,IACE,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACd,OAAQ,KAAkC,CAAC,UAAU,KAAK,QAAQ,EAClE,CAAC;YACD,MAAM,IAAI,KAAK,CACb,GAAG,UAAU,iBAAiB,SAAS,0BAA0B;gBAC/D,sEAAsE;gBACtE,qEAAqE;gBACrE,gCAAgC,CACnC,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAuB,CAAC,CAAC,CAAC;QACzD,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC;AAuBD,mFAAmF;AACnF,MAAM,UAAU,qBAAqB;IACnC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACpC,CAAC"}
package/dist/settle.d.ts CHANGED
@@ -109,6 +109,19 @@ export declare class SettleState {
109
109
  remainingMs(): number;
110
110
  isResolved(depKey: string): boolean;
111
111
  private waiterFor;
112
+ /**
113
+ * Shared wait plumbing for {@link waitFor} / {@link waitForAny}: log the
114
+ * settle cadence for each capability (INFO first time, DEBUG after), bump the
115
+ * diagnostic `waitCount`, and race every `depKeys` resolution waiter against
116
+ * ONE budget timer bounded by `remaining` — never a fixed sleep. Callers apply
117
+ * their own resolved-state filtering + early-return BEFORE calling this, so
118
+ * `depKeys` are the genuinely-still-pending keys and `remaining > 0`.
119
+ *
120
+ * On timeout the caller simply proceeds — the unresolved dep injects null
121
+ * exactly as today; the existing unresolved-dep handling covers the
122
+ * diagnostic (no double-logging here).
123
+ */
124
+ private raceWaiters;
112
125
  /**
113
126
  * Wait until `depKey` resolves or the remaining settle budget elapses.
114
127
  * Event-driven: the dependency's resolution promise is raced against a
@@ -121,6 +134,15 @@ export declare class SettleState {
121
134
  * regardless of how many deps are pending.
122
135
  */
123
136
  awaitPending(pending: PendingSettleDep[]): Promise<void>;
137
+ /**
138
+ * Wait until ANY of `pending` resolves or the remaining settle budget
139
+ * elapses. Unlike {@link awaitPending} (which blocks on each key in turn),
140
+ * this races every pending key's resolution promise against ONE budget timer,
141
+ * so a caller gated on a floor wakes the moment ANY qualifying dependency
142
+ * lands — never sleeping on an already-satisfied floor because it happened to
143
+ * be awaiting a still-pending sibling key (RFC #1280 minAvailable).
144
+ */
145
+ waitForAny(pending: PendingSettleDep[]): Promise<void>;
124
146
  }
125
147
  /** Get the process-wide settle state. */
126
148
  export declare function getSettleState(): SettleState;
@@ -1 +1 @@
1
- {"version":3,"file":"settle.d.ts","sourceRoot":"","sources":["../src/settle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAIH,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAQjD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAmBhD;AAOD,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,qBAAa,WAAW;IACtB;;;;;OAKG;IACH,OAAO,CAAC,O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C"}
package/dist/settle.js CHANGED
@@ -218,32 +218,36 @@ export class SettleState {
218
218
  return waiter;
219
219
  }
220
220
  /**
221
- * Wait until `depKey` resolves or the remaining settle budget elapses.
222
- * Event-driven: the dependency's resolution promise is raced against a
223
- * timer bounded by the remaining window never a fixed sleep.
221
+ * Shared wait plumbing for {@link waitFor} / {@link waitForAny}: log the
222
+ * settle cadence for each capability (INFO first time, DEBUG after), bump the
223
+ * diagnostic `waitCount`, and race every `depKeys` resolution waiter against
224
+ * ONE budget timer bounded by `remaining` — never a fixed sleep. Callers apply
225
+ * their own resolved-state filtering + early-return BEFORE calling this, so
226
+ * `depKeys` are the genuinely-still-pending keys and `remaining > 0`.
227
+ *
228
+ * On timeout the caller simply proceeds — the unresolved dep injects null
229
+ * exactly as today; the existing unresolved-dep handling covers the
230
+ * diagnostic (no double-logging here).
224
231
  */
225
- async waitFor(depKey, capability) {
226
- const remaining = this.remainingMs();
227
- if (remaining <= 0 || this.resolved.has(depKey)) {
228
- return;
229
- }
230
- const waiter = this.waiterFor(depKey);
232
+ async raceWaiters(depKeys, capabilities, remaining) {
231
233
  const remainingSecs = (remaining / 1000).toFixed(1);
232
- const message = `waiting up to ${remainingSecs}s for dependency '${capability}' to settle`;
233
- if (!this.loggedWaits.has(capability)) {
234
- // One INFO line per capability per process; later waits at DEBUG
235
- // (matches the Python/Java log cadence).
236
- this.loggedWaits.add(capability);
237
- console.log(message);
238
- }
239
- else {
240
- console.debug(message);
234
+ for (const capability of capabilities) {
235
+ const message = `waiting up to ${remainingSecs}s for dependency '${capability}' to settle`;
236
+ if (!this.loggedWaits.has(capability)) {
237
+ // One INFO line per capability per process; later waits at DEBUG
238
+ // (matches the Python/Java log cadence).
239
+ this.loggedWaits.add(capability);
240
+ console.log(message);
241
+ }
242
+ else {
243
+ console.debug(message);
244
+ }
241
245
  }
242
246
  this.waitCount++;
243
247
  let timer;
244
248
  try {
245
249
  await Promise.race([
246
- waiter.promise,
250
+ ...depKeys.map((k) => this.waiterFor(k).promise),
247
251
  new Promise((resolve) => {
248
252
  timer = setTimeout(resolve, remaining);
249
253
  // Never keep the process alive just for a settle timer.
@@ -256,9 +260,18 @@ export class SettleState {
256
260
  clearTimeout(timer);
257
261
  }
258
262
  }
259
- // On timeout we simply proceed — the unresolved dep injects null
260
- // exactly as today; the existing unresolved-dep handling covers the
261
- // diagnostic (no double-logging here).
263
+ }
264
+ /**
265
+ * Wait until `depKey` resolves or the remaining settle budget elapses.
266
+ * Event-driven: the dependency's resolution promise is raced against a
267
+ * timer bounded by the remaining window — never a fixed sleep.
268
+ */
269
+ async waitFor(depKey, capability) {
270
+ const remaining = this.remainingMs();
271
+ if (remaining <= 0 || this.resolved.has(depKey)) {
272
+ return;
273
+ }
274
+ await this.raceWaiters([depKey], [capability], remaining);
262
275
  }
263
276
  /**
264
277
  * Await every pending dependency in turn. The per-wait budget is the
@@ -270,6 +283,22 @@ export class SettleState {
270
283
  await this.waitFor(depKey, capability);
271
284
  }
272
285
  }
286
+ /**
287
+ * Wait until ANY of `pending` resolves or the remaining settle budget
288
+ * elapses. Unlike {@link awaitPending} (which blocks on each key in turn),
289
+ * this races every pending key's resolution promise against ONE budget timer,
290
+ * so a caller gated on a floor wakes the moment ANY qualifying dependency
291
+ * lands — never sleeping on an already-satisfied floor because it happened to
292
+ * be awaiting a still-pending sibling key (RFC #1280 minAvailable).
293
+ */
294
+ async waitForAny(pending) {
295
+ const remaining = this.remainingMs();
296
+ const unresolved = pending.filter((p) => !this.resolved.has(p.depKey));
297
+ if (remaining <= 0 || unresolved.length === 0) {
298
+ return;
299
+ }
300
+ await this.raceWaiters(unresolved.map((p) => p.depKey), unresolved.map((p) => p.capability), remaining);
301
+ }
273
302
  }
274
303
  let settleState = new SettleState();
275
304
  /** Get the process-wide settle state. */
@@ -1 +1 @@
1
- {"version":3,"file":"settle.js","sourceRoot":"","sources":["../src/settle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkC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