@adaptivemcp/spec 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/events.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface ToolEventContext {
6
6
  sessionId?: string;
7
7
  requestId?: string;
8
8
  model?: string;
9
+ metadata?: Record<string, unknown>;
9
10
  }
10
11
  /**
11
12
  * Construct a tool execution event with sensible defaults. Timestamps use the
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEjE,eAAO,MAAM,oBAAoB,EAAG,0CAAmD,CAAC;AAExF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,UAAU,EAClB,KAAK,GAAE,OAAO,CAAC,kBAAkB,CAAM,GACtC,kBAAkB,CAYpB"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEjE,eAAO,MAAM,oBAAoB,EAAG,0CAAmD,CAAC;AAExF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,UAAU,EAClB,KAAK,GAAE,OAAO,CAAC,kBAAkB,CAAM,GACtC,kBAAkB,CAYpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG,0CAAmD,CAAC;AAUxF;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,GAAqB,EACrB,MAAkB,EAClB,QAAqC,EAAE;IAEvC,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE;QACnC,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACtD,MAAM;QACN,GAAG,KAAK;KACT,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG,0CAAmD,CAAC;AAWxF;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,GAAqB,EACrB,MAAkB,EAClB,QAAqC,EAAE;IAEvC,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE;QACnC,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACtD,MAAM;QACN,GAAG,KAAK;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,63 @@
1
+ import type { ExecutionNode } from "./types.js";
2
+ /**
3
+ * Canonical, JSON-serializable wire format for a session's execution graph —
4
+ * the shape any MCP server can emit (and any client can parse) for
5
+ * cross-server graph correlation. Field names are snake_case, matching the
6
+ * convention already used by every other *Document wire type in this
7
+ * codebase (`WorkflowGraphDocument`, `GraphInsightsDocument`); TS-internal
8
+ * types like `ExecutionNode` stay camelCase.
9
+ *
10
+ * This replaces the old `ExecutionGraph` type (Map-based `nodes`, never
11
+ * built or consumed anywhere in the codebase) — Maps aren't directly
12
+ * JSON-serializable, so they were never a viable wire format to begin with.
13
+ * "Federation" here means a shared, importable schema + builder other MCP
14
+ * servers' code can construct against — not an implemented multi-server
15
+ * aggregation/discovery protocol, which would need infrastructure (server
16
+ * registries, cross-server RPC) that doesn't exist in this codebase.
17
+ */
18
+ export interface ExecutionGraphResource {
19
+ version: string;
20
+ etag: string;
21
+ generated_at: string;
22
+ session_id: string;
23
+ workflow_id?: string;
24
+ nodes: Array<{
25
+ id: string;
26
+ tool: string;
27
+ server?: string;
28
+ parent?: string;
29
+ children: string[];
30
+ timestamp: string;
31
+ duration_ms?: number;
32
+ status: string;
33
+ cost?: number;
34
+ model?: string;
35
+ /** W3C `traceparent` recorded on the node, if graph tracking generated one. */
36
+ trace_parent?: string;
37
+ }>;
38
+ edges: Array<{
39
+ from: string;
40
+ to: string;
41
+ }>;
42
+ /**
43
+ * Opaque pagination cursor (the `id` of the last returned node) — present
44
+ * when more nodes exist beyond this page. Absent on the last page or when
45
+ * the caller didn't request pagination.
46
+ */
47
+ next_cursor?: string;
48
+ }
49
+ export interface BuildExecutionGraphOptions {
50
+ version: string;
51
+ sessionId: string;
52
+ generatedAt?: string;
53
+ workflowId?: string;
54
+ nextCursor?: string;
55
+ }
56
+ /**
57
+ * Pure builder: maps a flat `ExecutionNode[]` (already the desired page) into
58
+ * the canonical wire shape. `etag` is returned empty — it's a hash of this
59
+ * very output, so callers compute it over the returned object and assign it
60
+ * afterward (see `ExtensionController.buildExecutionGraphDocument`).
61
+ */
62
+ export declare function buildExecutionGraph(nodes: ExecutionNode[], opts: BuildExecutionGraphOptions): ExecutionGraphResource;
63
+ //# sourceMappingURL=execution-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-graph.d.ts","sourceRoot":"","sources":["../src/execution-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,+EAA+E;QAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC,CAAC;IACH,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3C;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,0BAA0B,GAAG,sBAAsB,CA0BpH"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Pure builder: maps a flat `ExecutionNode[]` (already the desired page) into
3
+ * the canonical wire shape. `etag` is returned empty — it's a hash of this
4
+ * very output, so callers compute it over the returned object and assign it
5
+ * afterward (see `ExtensionController.buildExecutionGraphDocument`).
6
+ */
7
+ export function buildExecutionGraph(nodes, opts) {
8
+ const renderedNodes = nodes.map((n) => ({
9
+ id: n.id,
10
+ tool: n.toolName,
11
+ server: n.serverName,
12
+ parent: n.parentId,
13
+ children: n.childrenIds,
14
+ timestamp: n.timestamp,
15
+ duration_ms: n.durationMs,
16
+ status: n.status,
17
+ cost: n.cost?.amount,
18
+ model: n.model,
19
+ trace_parent: n.metadata?.traceparent,
20
+ }));
21
+ const edges = nodes.flatMap((n) => n.childrenIds.map((childId) => ({ from: n.id, to: childId })));
22
+ return {
23
+ version: opts.version,
24
+ etag: "",
25
+ generated_at: opts.generatedAt ?? new Date().toISOString(),
26
+ session_id: opts.sessionId,
27
+ workflow_id: opts.workflowId ?? nodes[0]?.workflowId ?? "unknown",
28
+ nodes: renderedNodes,
29
+ edges,
30
+ next_cursor: opts.nextCursor,
31
+ };
32
+ }
33
+ //# sourceMappingURL=execution-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-graph.js","sourceRoot":"","sources":["../src/execution-graph.ts"],"names":[],"mappings":"AAuDA;;;;;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 -1,5 +1,6 @@
1
1
  export * from "./types.js";
2
2
  export * from "./extensions.js";
3
3
  export * from "./events.js";
4
+ export * from "./execution-graph.js";
4
5
  export { SPEC_VERSION } from "./version.js";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./types.js";
2
2
  export * from "./extensions.js";
3
3
  export * from "./events.js";
4
+ export * from "./execution-graph.js";
4
5
  export { SPEC_VERSION } from "./version.js";
5
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
package/dist/types.d.ts CHANGED
@@ -35,6 +35,10 @@ export interface ToolExecutionEvent {
35
35
  model?: string;
36
36
  cost?: CostInfo;
37
37
  metadata?: Record<string, unknown>;
38
+ /** Parent node ID in the execution graph (for DAG construction) */
39
+ parentId?: string;
40
+ /** Human-readable workflow name (e.g., "deploy_release") */
41
+ workflowId?: string;
38
42
  }
39
43
  export type InsightSource = "telemetry" | "evaluation" | "human" | "memory";
40
44
  /**
@@ -43,6 +47,7 @@ export type InsightSource = "telemetry" | "evaluation" | "human" | "memory";
43
47
  */
44
48
  export interface Insight {
45
49
  toolName: string;
50
+ serverName?: string;
46
51
  key: string;
47
52
  value: unknown;
48
53
  confidence: number;
@@ -51,29 +56,143 @@ export interface Insight {
51
56
  sampleSize?: number;
52
57
  }
53
58
  export type RiskLevel = "low" | "medium" | "high";
59
+ /**
60
+ * Core MCP `ToolAnnotations` (the `annotations` object on a tool in
61
+ * `tools/list`). Adaptive MCP maps its *static* risk onto these native hints so
62
+ * hosts don't have to learn a parallel taxonomy. See `riskToToolAnnotations`.
63
+ */
64
+ export interface ToolAnnotationsLike {
65
+ title?: string;
66
+ readOnlyHint?: boolean;
67
+ destructiveHint?: boolean;
68
+ idempotentHint?: boolean;
69
+ openWorldHint?: boolean;
70
+ }
71
+ /**
72
+ * Map an Adaptive MCP static `risk` level onto core MCP `ToolAnnotations`.
73
+ *
74
+ * The MCP spec says clients MUST treat `ToolAnnotations` as untrusted unless
75
+ * from a trusted server, so this is advisory — but it rides the host's native,
76
+ * already-parsed risk signal (higher uptake than a custom `risk` field). The
77
+ * server-published tools-metadata resource keeps `risk` for the *learned/
78
+ * observed* dimension only (e.g. "observed flaky / costly in practice"), which
79
+ * core hints cannot express. See doubts.md §10/§11 (Strategy 2 of the hybrid).
80
+ */
81
+ export declare function riskToToolAnnotations(risk?: RiskLevel): ToolAnnotationsLike;
54
82
  /**
55
83
  * Written metadata attached to a tool by a human or operator.
84
+ *
85
+ * `risk` here is the *static* operator-assigned risk. Per the governance hybrid
86
+ * (doubts.md §11), static risk SHOULD be projected onto core `Tool.annotations`
87
+ * via `riskToToolAnnotations` rather than emitted in the resource; the resource's
88
+ * `annotation.risk` is reserved for learned/observed risk. `owner`/`tags`/
89
+ * `description` are non-governance metadata with no core-MCP equivalent.
56
90
  */
57
91
  export interface Annotation {
58
92
  toolName: string;
93
+ serverName?: string;
59
94
  risk?: RiskLevel;
60
95
  owner?: string;
61
96
  tags?: string[];
62
97
  description?: string;
63
98
  metadata?: Record<string, unknown>;
64
99
  }
65
- export type RecommendationType = "model" | "approval" | "workflow" | "routing";
100
+ export type RecommendationType = "model" | "approval" | "workflow" | "routing" | "sampling" | "decoding";
66
101
  /**
67
102
  * A suggested adaptation derived from accumulated knowledge.
68
103
  */
69
104
  export interface Recommendation {
70
105
  toolName: string;
106
+ serverName?: string;
71
107
  type: RecommendationType;
72
108
  payload: unknown;
73
109
  rationale: string;
74
110
  confidence: number;
75
111
  generatedAt: string;
76
112
  }
113
+ /**
114
+ * Payload shape for `Recommendation.type === "sampling"`: suggested LLM
115
+ * sampling parameters for the *next* generation turn involving this tool.
116
+ * All fields optional — an advisor only emits the parameters it has an
117
+ * opinion about; a host applying this should treat an absent field as "no
118
+ * change from your own default," never as "set to undefined/null."
119
+ *
120
+ * Advisory only: nothing in this repo makes an LLM completion call, so this
121
+ * payload has no effect unless a host reads it and applies it to its own
122
+ * request.
123
+ *
124
+ * @deprecated Superseded by `DecodingProfile` + `DecodingResolver` (Phase 8,
125
+ * see docs/ROADMAP.md and docs/doubts.md §13 D5). Kept exported and working —
126
+ * a shipped public shape shouldn't break existing consumers for a rename —
127
+ * but new code should produce/consume `DecodingRecommendation` instead. Will
128
+ * be removed at the next `SPEC_VERSION` major bump.
129
+ */
130
+ export interface SamplingRecommendationPayload {
131
+ temperature?: number;
132
+ topP?: number;
133
+ topK?: number;
134
+ presencePenalty?: number;
135
+ repetitionPenalty?: number;
136
+ }
137
+ /**
138
+ * A symbolic, backend-agnostic decoding intent. `DecodingAdvisor` emits this
139
+ * instead of raw sampling numbers — nothing backend-specific belongs here.
140
+ * `DecodingResolver` is the only thing that translates it into concrete
141
+ * knobs for a specific backend. See docs/doubts.md §13 D1.
142
+ */
143
+ export interface DecodingProfile {
144
+ id: "deterministic" | "balanced" | "creative";
145
+ }
146
+ /**
147
+ * Which decoding knobs a specific model/inference backend actually exposes.
148
+ * `DecodingResolver` uses this to translate a `DecodingProfile` into
149
+ * `ResolvedDecodingSettings`, dropping (never approximating) knobs a backend
150
+ * doesn't support — e.g. `minP` and `topP` aren't equivalent, so one is never
151
+ * substituted for the other.
152
+ */
153
+ export interface ModelCapabilities {
154
+ supports: {
155
+ temperature?: boolean;
156
+ topP?: boolean;
157
+ topK?: boolean;
158
+ minP?: boolean;
159
+ presencePenalty?: boolean;
160
+ repetitionPenalty?: boolean;
161
+ frequencyPenalty?: boolean;
162
+ };
163
+ }
164
+ /**
165
+ * Concrete, backend-specific decoding parameters produced by a
166
+ * `DecodingResolver`. Superset of the deprecated `SamplingRecommendationPayload`
167
+ * (adds `minP`/`frequencyPenalty`) — all fields optional, absent means "no
168
+ * opinion," never "set to null."
169
+ */
170
+ export interface ResolvedDecodingSettings {
171
+ temperature?: number;
172
+ topP?: number;
173
+ topK?: number;
174
+ minP?: number;
175
+ presencePenalty?: number;
176
+ repetitionPenalty?: number;
177
+ frequencyPenalty?: number;
178
+ }
179
+ /**
180
+ * What `DecodingAdvisor` + `DecodingResolver` jointly produce: a suggested
181
+ * decoding profile, its concrete resolved settings for a specific backend,
182
+ * the resolver version that produced them (so past decisions stay
183
+ * reproducible after the resolver's tables change), and enough evidence
184
+ * (`confidence`/`reasons`) for a host to decide whether to trust it.
185
+ *
186
+ * Advisory only, same as `SamplingRecommendationPayload` — nothing here is
187
+ * auto-applied; a host reads this and chooses whether to act on it.
188
+ */
189
+ export interface DecodingRecommendation {
190
+ profile: DecodingProfile;
191
+ resolved: ResolvedDecodingSettings;
192
+ resolverVersion: string;
193
+ confidence: number;
194
+ reasons: string[];
195
+ }
77
196
  /**
78
197
  * The store record for a tool, persisted in SQLite.
79
198
  * The YAML tools-metadata view is derived from this record.
@@ -94,6 +213,114 @@ export interface ToolStats {
94
213
  avgDurationMs: number | null;
95
214
  totalCost: number;
96
215
  lastObservedAt: string | null;
216
+ /** Average output tokens per invocation (for context cost tracking) */
217
+ avgOutputTokens?: number;
218
+ }
219
+ /**
220
+ * A single node in the execution graph (DAG).
221
+ * Each tool invocation becomes a node with parent/children relationships.
222
+ */
223
+ export interface ExecutionNode {
224
+ id: string;
225
+ toolName: string;
226
+ serverName?: string;
227
+ sessionId: string;
228
+ workflowId?: string;
229
+ parentId?: string;
230
+ childrenIds: string[];
231
+ timestamp: string;
232
+ durationMs?: number;
233
+ status: ToolStatus;
234
+ input?: unknown;
235
+ output?: unknown;
236
+ error?: ToolError;
237
+ model?: string;
238
+ cost?: CostInfo;
239
+ metadata?: Record<string, unknown>;
240
+ }
241
+ /**
242
+ * Graph analysis results.
243
+ */
244
+ export interface CriticalPathResult {
245
+ path: ExecutionNode[];
246
+ totalDurationMs: number;
247
+ }
248
+ export interface Bottleneck {
249
+ node: ExecutionNode;
250
+ impactScore: number;
251
+ reason: "duration" | "fan_out" | "failure_rate" | "cost";
252
+ }
253
+ export interface FanOutReport {
254
+ maxFanOut: number;
255
+ avgFanOut: number;
256
+ parallelizableNodes: ExecutionNode[];
257
+ sequentialChains: ExecutionNode[][];
258
+ }
259
+ /**
260
+ * A recurring structural anti-pattern detected in a session's graph.
261
+ * Deliberately limited to two named shapes rather than general subgraph
262
+ * isomorphism (NP-hard, unnecessary for small execution DAGs).
263
+ */
264
+ export interface AntiPattern {
265
+ type: "sequential_bottleneck" | "diamond_dependency";
266
+ nodes: ExecutionNode[];
267
+ severity: number;
268
+ }
269
+ export interface FailureCascade {
270
+ rootCause: ExecutionNode;
271
+ affectedNodes: ExecutionNode[];
272
+ blastRadius: number;
273
+ }
274
+ /**
275
+ * Ancestor-based causal ordering among the failed nodes of a session: a
276
+ * failed node with no failed ancestor is a root cause; a failed node
277
+ * downstream of a failed ancestor is a symptom of the nearest one. This is
278
+ * NOT counterfactual causal inference (which would require replaying
279
+ * execution without the trigger) — it's graph-ancestry ordering over the
280
+ * failures actually recorded.
281
+ */
282
+ export interface CausalCascade {
283
+ rootCauses: ExecutionNode[];
284
+ symptoms: Array<{
285
+ node: ExecutionNode;
286
+ causedBy: ExecutionNode;
287
+ }>;
288
+ blastRadius: number;
289
+ }
290
+ export interface CostBreakdown {
291
+ totalCost: number;
292
+ byTool: Record<string, number>;
293
+ byNode: Record<string, number>;
294
+ criticalPathCost: number;
295
+ }
296
+ export interface WorkflowStats {
297
+ workflowId: string;
298
+ totalExecutions: number;
299
+ successRate: number;
300
+ avgDurationMs: number;
301
+ avgCost: number;
302
+ commonPatterns: WorkflowPattern[];
303
+ }
304
+ export interface WorkflowPattern {
305
+ pattern: string;
306
+ frequency: number;
307
+ avgDurationMs: number;
308
+ successRate: number;
309
+ }
310
+ /**
311
+ * A heuristic forecast for an in-progress workflow session, extrapolated
312
+ * from historical runs of the same workflow. NOT a trained/statistical
313
+ * model — a ratio-vs-baseline projection, in the same spirit as
314
+ * `detectAnomalies`'s duration/cost ratio checks.
315
+ */
316
+ export interface WorkflowForecast {
317
+ workflowId: string;
318
+ /** Nodes seen so far / historical avg node count for this workflow, capped at 1. */
319
+ progressRatio: number;
320
+ projectedDurationMs: number;
321
+ projectedCost: number;
322
+ /** Blend of historical failure rate and this session's own failures observed so far. */
323
+ failureProbability: number;
97
324
  }
98
325
  /**
99
326
  * The persistence boundary for Adaptive MCP.
@@ -102,15 +329,27 @@ export interface ToolStats {
102
329
  * backend (SQLite, Postgres, in-memory, remote) can be swapped without touching
103
330
  * the middleware. `MemoryStore` in `@adaptivemcp/memory` is the reference
104
331
  * implementation.
332
+ *
333
+ * Records are identified by the `(toolName, serverName)` pair, not `toolName`
334
+ * alone: two different MCP servers may expose a tool with the same name, and
335
+ * without the server in the key their records would collide. `serverName` is
336
+ * optional on read/write because not every call site knows which server it's
337
+ * dealing with; when omitted, lookups fall back to the most recently updated
338
+ * record with that `toolName` (ambiguous only if the same tool name is in use
339
+ * across multiple servers).
105
340
  */
106
341
  export interface Store {
107
342
  /** Close the underlying backend and release resources. */
108
343
  close(): void;
109
344
  /** Ensure a tool record exists, seeding it with an empty annotation. */
110
345
  ensureTool(toolName: string, serverName?: string): ToolRecord;
111
- /** Read a single tool record, or `undefined` if it has never been observed. */
112
- getTool(toolName: string): ToolRecord | undefined;
113
- /** Read every tool record, ordered by tool name. */
346
+ /**
347
+ * Read a single tool record, or `undefined` if it has never been observed.
348
+ * Pass `serverName` to disambiguate when the same tool name may exist on
349
+ * multiple servers; otherwise the most recently updated match is returned.
350
+ */
351
+ getTool(toolName: string, serverName?: string): ToolRecord | undefined;
352
+ /** Read every tool record, ordered by tool name then server name. */
114
353
  allTools(): ToolRecord[];
115
354
  /** Persist a human-written annotation (the static metadata layer). */
116
355
  setAnnotation(annotation: Annotation): ToolRecord;
@@ -123,8 +362,28 @@ export interface Store {
123
362
  * orchestration, and approval packages so each adaptation pass recomputes its
124
363
  * own recommendations instead of appending duplicates on every observation.
125
364
  */
126
- clearRecommendations(toolName: string, type: RecommendationType): ToolRecord;
365
+ clearRecommendations(toolName: string, type: RecommendationType, serverName?: string): ToolRecord;
127
366
  /** Fold a tool execution event into the persisted stats. */
128
367
  recordExecution(event: ToolExecutionEvent): ToolRecord;
368
+ /** Record an execution node in the graph. */
369
+ recordExecutionNode?(node: ExecutionNode): ExecutionNode;
370
+ /** Get an execution node by ID. */
371
+ getExecutionNode?(id: string): ExecutionNode | undefined;
372
+ /** Get all nodes for a session. */
373
+ getNodesBySession?(sessionId: string): ExecutionNode[];
374
+ /** Get all nodes for a workflow (across sessions). */
375
+ getNodesByWorkflow?(workflowId: string): ExecutionNode[];
376
+ /** Get every distinct workflow ID that has at least one recorded execution node. */
377
+ getWorkflowIds?(): string[];
378
+ /** Get children of a node. */
379
+ getChildren?(parentId: string): ExecutionNode[];
380
+ /** Get parent of a node. */
381
+ getParent?(childId: string): ExecutionNode | undefined;
382
+ /** Get root nodes (no parent) for a session. */
383
+ getRootNodes?(sessionId: string): ExecutionNode[];
384
+ /** Get leaf nodes (no children) for a session. */
385
+ getLeafNodes?(sessionId: string): ExecutionNode[];
386
+ /** Update children IDs of a parent node. */
387
+ updateChildrenIds?(parentId: string, childrenIds: string[]): void;
129
388
  }
130
389
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE1E,MAAM,WAAW,QAAQ;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,O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AE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;IACzD,mCAAmC;IACnC,iBAAiB,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IACvD,sDAAsD;IACtD,kBAAkB,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IACzD,oFAAoF;IACpF,cAAc,CAAC,IAAI,MAAM,EAAE,CAAC;IAC5B,8BAA8B;IAC9B,WAAW,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IAChD,4BAA4B;IAC5B,SAAS,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;IACvD,gDAAgD;IAChD,YAAY,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IAClD,kDAAkD;IAClD,YAAY,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IAClD,4CAA4C;IAC5C,iBAAiB,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CACnE"}
package/dist/types.js CHANGED
@@ -5,5 +5,26 @@
5
5
  * They intentionally avoid coupling to shell commands, filesystems, processes,
6
6
  * sockets, or HTTP requests — those remain implementation details of MCP servers.
7
7
  */
8
- export {};
8
+ /**
9
+ * Map an Adaptive MCP static `risk` level onto core MCP `ToolAnnotations`.
10
+ *
11
+ * The MCP spec says clients MUST treat `ToolAnnotations` as untrusted unless
12
+ * from a trusted server, so this is advisory — but it rides the host's native,
13
+ * already-parsed risk signal (higher uptake than a custom `risk` field). The
14
+ * server-published tools-metadata resource keeps `risk` for the *learned/
15
+ * observed* dimension only (e.g. "observed flaky / costly in practice"), which
16
+ * core hints cannot express. See doubts.md §10/§11 (Strategy 2 of the hybrid).
17
+ */
18
+ export function riskToToolAnnotations(risk) {
19
+ switch (risk) {
20
+ case "high":
21
+ return { destructiveHint: true, openWorldHint: true };
22
+ case "medium":
23
+ return { idempotentHint: false, openWorldHint: true };
24
+ case "low":
25
+ return { readOnlyHint: true };
26
+ default:
27
+ return {};
28
+ }
29
+ }
9
30
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyEH;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAgB;IACpD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,MAAM;YACT,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;QACxD,KAAK,QAAQ;YACX,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;QACxD,KAAK,KAAK;YACR,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QAChC;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptivemcp/spec",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Extension identifiers, event schemas, and shared types for Adaptive MCP.",
5
5
  "license": "MIT",
6
6
  "type": "module",