@spine-event-engine/server 2.0.0-snapshot.21 → 2.0.0-snapshot.23

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 (168) hide show
  1. package/README.md +104 -7
  2. package/REFERENCE.md +199 -19
  3. package/dist/agent/agent-admission.d.ts +80 -0
  4. package/dist/agent/agent-admission.d.ts.map +1 -0
  5. package/dist/agent/agent-admission.js +127 -0
  6. package/dist/agent/agent-admission.js.map +1 -0
  7. package/dist/agent/agent-ai-binding.d.ts +24 -0
  8. package/dist/agent/agent-ai-binding.d.ts.map +1 -0
  9. package/dist/agent/agent-ai-binding.js +48 -0
  10. package/dist/agent/agent-ai-binding.js.map +1 -0
  11. package/dist/agent/agent-ai-runtime.d.ts +76 -0
  12. package/dist/agent/agent-ai-runtime.d.ts.map +1 -0
  13. package/dist/agent/agent-ai-runtime.js +1269 -0
  14. package/dist/agent/agent-ai-runtime.js.map +1 -0
  15. package/dist/agent/agent-execution-capacity.d.ts +43 -0
  16. package/dist/agent/agent-execution-capacity.d.ts.map +1 -0
  17. package/dist/agent/agent-execution-capacity.js +147 -0
  18. package/dist/agent/agent-execution-capacity.js.map +1 -0
  19. package/dist/agent/agent-execution-fault.d.ts +18 -0
  20. package/dist/agent/agent-execution-fault.d.ts.map +1 -0
  21. package/dist/agent/agent-execution-fault.js +31 -0
  22. package/dist/agent/agent-execution-fault.js.map +1 -0
  23. package/dist/agent/agent-execution-session.d.ts +103 -0
  24. package/dist/agent/agent-execution-session.d.ts.map +1 -0
  25. package/dist/agent/agent-execution-session.js +238 -0
  26. package/dist/agent/agent-execution-session.js.map +1 -0
  27. package/dist/agent/agent-history.d.ts +148 -0
  28. package/dist/agent/agent-history.d.ts.map +1 -0
  29. package/dist/agent/agent-history.js +340 -0
  30. package/dist/agent/agent-history.js.map +1 -0
  31. package/dist/agent/agent-interaction-audit.d.ts +58 -0
  32. package/dist/agent/agent-interaction-audit.d.ts.map +1 -0
  33. package/dist/agent/agent-interaction-audit.js +114 -0
  34. package/dist/agent/agent-interaction-audit.js.map +1 -0
  35. package/dist/agent/agent-interaction-events.d.ts +40 -0
  36. package/dist/agent/agent-interaction-events.d.ts.map +1 -0
  37. package/dist/agent/agent-interaction-events.js +129 -0
  38. package/dist/agent/agent-interaction-events.js.map +1 -0
  39. package/dist/agent/agent-mcp-budget.d.ts +125 -0
  40. package/dist/agent/agent-mcp-budget.d.ts.map +1 -0
  41. package/dist/agent/agent-mcp-budget.js +566 -0
  42. package/dist/agent/agent-mcp-budget.js.map +1 -0
  43. package/dist/agent/agent-mcp-host.d.ts +125 -0
  44. package/dist/agent/agent-mcp-host.d.ts.map +1 -0
  45. package/dist/agent/agent-mcp-host.js +15 -0
  46. package/dist/agent/agent-mcp-host.js.map +1 -0
  47. package/dist/agent/agent-mcp-runtime.d.ts +199 -0
  48. package/dist/agent/agent-mcp-runtime.d.ts.map +1 -0
  49. package/dist/agent/agent-mcp-runtime.js +621 -0
  50. package/dist/agent/agent-mcp-runtime.js.map +1 -0
  51. package/dist/agent/agent-model-selection.d.ts +129 -0
  52. package/dist/agent/agent-model-selection.d.ts.map +1 -0
  53. package/dist/agent/agent-model-selection.js +342 -0
  54. package/dist/agent/agent-model-selection.js.map +1 -0
  55. package/dist/agent/agent-read-runtime.d.ts +70 -0
  56. package/dist/agent/agent-read-runtime.d.ts.map +1 -0
  57. package/dist/agent/agent-read-runtime.js +320 -0
  58. package/dist/agent/agent-read-runtime.js.map +1 -0
  59. package/dist/agent/agent-revisions.d.ts +35 -0
  60. package/dist/agent/agent-revisions.d.ts.map +1 -0
  61. package/dist/agent/agent-revisions.js +133 -0
  62. package/dist/agent/agent-revisions.js.map +1 -0
  63. package/dist/agent/agent-scheduler.d.ts +99 -0
  64. package/dist/agent/agent-scheduler.d.ts.map +1 -0
  65. package/dist/agent/agent-scheduler.js +398 -0
  66. package/dist/agent/agent-scheduler.js.map +1 -0
  67. package/dist/bus/command-bus.d.ts +62 -0
  68. package/dist/bus/command-bus.d.ts.map +1 -1
  69. package/dist/bus/command-bus.js +51 -2
  70. package/dist/bus/command-bus.js.map +1 -1
  71. package/dist/bus/event-bus.d.ts +137 -3
  72. package/dist/bus/event-bus.d.ts.map +1 -1
  73. package/dist/bus/event-bus.js +133 -2
  74. package/dist/bus/event-bus.js.map +1 -1
  75. package/dist/bus/saved-dispatcher-binding.d.ts +96 -0
  76. package/dist/bus/saved-dispatcher-binding.d.ts.map +1 -0
  77. package/dist/bus/saved-dispatcher-binding.js +35 -0
  78. package/dist/bus/saved-dispatcher-binding.js.map +1 -0
  79. package/dist/context/bounded-context.d.ts +36 -2
  80. package/dist/context/bounded-context.d.ts.map +1 -1
  81. package/dist/context/bounded-context.js +253 -54
  82. package/dist/context/bounded-context.js.map +1 -1
  83. package/dist/context/entity-inbox.d.ts.map +1 -1
  84. package/dist/context/entity-inbox.js +5 -5
  85. package/dist/context/entity-inbox.js.map +1 -1
  86. package/dist/context/projection-handoff.d.ts.map +1 -1
  87. package/dist/context/projection-handoff.js +2 -1
  88. package/dist/context/projection-handoff.js.map +1 -1
  89. package/dist/context/tenant-index.d.ts +25 -0
  90. package/dist/context/tenant-index.d.ts.map +1 -1
  91. package/dist/context/tenant-index.js +45 -1
  92. package/dist/context/tenant-index.js.map +1 -1
  93. package/dist/delivery/delivery.d.ts.map +1 -1
  94. package/dist/delivery/delivery.js +4 -3
  95. package/dist/delivery/delivery.js.map +1 -1
  96. package/dist/delivery/inbox-records.d.ts +13 -0
  97. package/dist/delivery/inbox-records.d.ts.map +1 -1
  98. package/dist/delivery/inbox-records.js +204 -30
  99. package/dist/delivery/inbox-records.js.map +1 -1
  100. package/dist/delivery/inbox-storage.d.ts.map +1 -1
  101. package/dist/delivery/inbox-storage.js +26 -5
  102. package/dist/delivery/inbox-storage.js.map +1 -1
  103. package/dist/delivery/inbox.d.ts +7 -7
  104. package/dist/delivery/inbox.d.ts.map +1 -1
  105. package/dist/delivery/inbox.js +1 -2
  106. package/dist/delivery/inbox.js.map +1 -1
  107. package/dist/delivery/sharded-work-registry.d.ts +1 -0
  108. package/dist/delivery/sharded-work-registry.d.ts.map +1 -1
  109. package/dist/delivery/sharded-work-registry.js +3 -1
  110. package/dist/delivery/sharded-work-registry.js.map +1 -1
  111. package/dist/entity/entity-transaction.d.ts.map +1 -1
  112. package/dist/entity/entity-transaction.js +2 -6
  113. package/dist/entity/entity-transaction.js.map +1 -1
  114. package/dist/entity/entity.d.ts +82 -3
  115. package/dist/entity/entity.d.ts.map +1 -1
  116. package/dist/entity/entity.js +121 -22
  117. package/dist/entity/entity.js.map +1 -1
  118. package/dist/handler/generated-handler-registry.js +8 -3
  119. package/dist/handler/generated-handler-registry.js.map +1 -1
  120. package/dist/handler/handler-metadata.d.ts +17 -1
  121. package/dist/handler/handler-metadata.d.ts.map +1 -1
  122. package/dist/handler/handler-metadata.js +10 -4
  123. package/dist/handler/handler-metadata.js.map +1 -1
  124. package/dist/index.d.ts +3 -3
  125. package/dist/index.d.ts.map +1 -1
  126. package/dist/index.js +2 -2
  127. package/dist/index.js.map +1 -1
  128. package/dist/integration/third-party-context.d.ts +5 -0
  129. package/dist/integration/third-party-context.d.ts.map +1 -1
  130. package/dist/integration/third-party-context.js +7 -6
  131. package/dist/integration/third-party-context.js.map +1 -1
  132. package/dist/repository/commit-fence.d.ts +11 -0
  133. package/dist/repository/commit-fence.d.ts.map +1 -1
  134. package/dist/repository/commit-fence.js +13 -0
  135. package/dist/repository/commit-fence.js.map +1 -1
  136. package/dist/repository/repository.d.ts +222 -13
  137. package/dist/repository/repository.d.ts.map +1 -1
  138. package/dist/repository/repository.js +2329 -137
  139. package/dist/repository/repository.js.map +1 -1
  140. package/dist/runtime/signal-metadata.d.ts +7 -47
  141. package/dist/runtime/signal-metadata.d.ts.map +1 -1
  142. package/dist/runtime/signal-metadata.js +8 -62
  143. package/dist/runtime/signal-metadata.js.map +1 -1
  144. package/dist/runtime/signal-publisher.d.ts +6 -0
  145. package/dist/runtime/signal-publisher.d.ts.map +1 -1
  146. package/dist/runtime/signal-publisher.js +13 -0
  147. package/dist/runtime/signal-publisher.js.map +1 -1
  148. package/dist/runtime/standalone-handler-runtime.d.ts +7 -0
  149. package/dist/runtime/standalone-handler-runtime.d.ts.map +1 -1
  150. package/dist/runtime/standalone-handler-runtime.js +148 -11
  151. package/dist/runtime/standalone-handler-runtime.js.map +1 -1
  152. package/dist/server/managed-server-application.d.ts +36 -6
  153. package/dist/server/managed-server-application.d.ts.map +1 -1
  154. package/dist/server/managed-server-application.js +257 -4
  155. package/dist/server/managed-server-application.js.map +1 -1
  156. package/dist/server/server.d.ts +9 -0
  157. package/dist/server/server.d.ts.map +1 -1
  158. package/dist/server/server.js +13 -1
  159. package/dist/server/server.js.map +1 -1
  160. package/dist/stand/subscription-registry.d.ts.map +1 -1
  161. package/dist/stand/subscription-registry.js +9 -8
  162. package/dist/stand/subscription-registry.js.map +1 -1
  163. package/dist/testing/index.d.ts +57 -1
  164. package/dist/testing/index.d.ts.map +1 -1
  165. package/dist/testing/index.js +87 -0
  166. package/dist/testing/index.js.map +1 -1
  167. package/dist/tsconfig.tsbuildinfo +1 -1
  168. package/package.json +14 -12
@@ -0,0 +1,621 @@
1
+ /*
2
+ * Copyright 2026, CodeMatters. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
+ * in compliance with the License. You may obtain a copy of the License at
6
+ *
7
+ * https://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
10
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
+ * or implied. See the License for the specific language governing permissions and limitations under
12
+ * the License.
13
+ */
14
+ import { createHash, randomUUID } from "node:crypto";
15
+ import { create } from "@bufbuild/protobuf";
16
+ import { AnyMessages, Time } from "@spine-event-engine/core";
17
+ import { mcpDefinition, mcpRegistration, registryOptions, } from "@spine-event-engine/ai/spi/runtime";
18
+ import { AiMcpSetupFailure } from "@spine-event-engine/ai/spi/adapter";
19
+ import { AgentHistoryEntrySchema, AiDiagnosticIdSchema, AiOutcome, AiToolCallIdSchema as ToolCallIdSchema, ConversationRecordIdSchema, ConversationRecordSchema, McpServerIdSchema, McpToolNameSchema, ToolEffect, ToolResponseSchema, } from "@spine-event-engine/proto/agent";
20
+ import { AgentExecutionFault } from "./agent-execution-fault.js";
21
+ /**
22
+ * Safe MCP runtime failure whose text contains no scoped credentials.
23
+ */
24
+ class SafeMcpError extends Error {
25
+ }
26
+ const toolDispatchReasons = new Map([
27
+ ["Agent tool proposal was concurrently journaled.", "concurrent-proposal"],
28
+ ["Agent tool call ID is unknown.", "unknown-call"],
29
+ ["Agent tool already completed.", "already-completed"],
30
+ ["Agent tool completion does not match a pending intent.", "completion-mismatch"],
31
+ ["Agent invocation tool-call budget is exhausted.", "tool-count-budget"],
32
+ ["Agent invocation input byte budget is exhausted.", "input-byte-budget"],
33
+ ["Agent invocation output byte credit is exhausted.", "output-byte-budget"],
34
+ ["Agent MCP journal exceeds invocation recovery bytes.", "recovery-byte-budget"],
35
+ ["Agent MCP head exceeds provider execution head bytes.", "head-byte-budget"],
36
+ ["Agent MCP journal exceeds provider execution record bytes.", "record-byte-budget"],
37
+ ["Agent MCP conversation history exceeds provider history bytes.", "history-byte-budget"],
38
+ ["Agent MCP mutation exceeds provider transaction payload bytes.", "transaction-byte-budget"],
39
+ ["MCP call already active", "ticket-collision"],
40
+ ]);
41
+ /**
42
+ * Executes one selected MCP catalog and its calls under the shared Agent journal.
43
+ */
44
+ export class AgentMcpRuntime {
45
+ host;
46
+ allowedTools;
47
+ /**
48
+ * Connected protocol sessions indexed by registered server ID.
49
+ */
50
+ sessions = new Map();
51
+ /**
52
+ * Cancellation for all callbacks and protocol sessions in this invocation.
53
+ */
54
+ closed = new AbortController();
55
+ /**
56
+ * Shared discovery result for concurrent prepare callers.
57
+ */
58
+ prepared;
59
+ /**
60
+ * Shared completion for all callers closing this invocation.
61
+ */
62
+ closing;
63
+ /**
64
+ * Binds one accepted capability tool list to the active fenced operation.
65
+ *
66
+ * @param host Shared budget, session and diagnostic authority.
67
+ * @param allowedTools Capability tools in declared order.
68
+ */
69
+ constructor(host, allowedTools) {
70
+ this.host = host;
71
+ this.allowedTools = allowedTools;
72
+ }
73
+ /**
74
+ * Prepares the exact configured catalog before a model request is prepared.
75
+ *
76
+ * @returns Immutable descriptions and schemas in capability order.
77
+ */
78
+ prepare() {
79
+ if (this.closed.signal.aborted)
80
+ return Promise.reject(new SafeMcpError("MCP runtime closed"));
81
+ this.prepared ??= this.prepareAll();
82
+ return this.prepared;
83
+ }
84
+ /**
85
+ * Validates and executes one model-proposed call through persisted intent.
86
+ *
87
+ * @param invocation Correlated model proposal with canonical arguments.
88
+ * @returns Saved or newly journaled bounded tool response.
89
+ */
90
+ async call(invocation) {
91
+ await this.prepare();
92
+ const server = this.serverFor(invocation.server);
93
+ const policy = server?.tools[invocation.tool];
94
+ const session = this.sessions.get(invocation.server);
95
+ if (!this.isAllowed(invocation) || !policy || !session)
96
+ return this.rejected("UNSUPPORTED_CAPABILITY");
97
+ if (policy.maxArgumentBytes !== undefined &&
98
+ Buffer.byteLength(invocation.argumentsJson, "utf8") > policy.maxArgumentBytes)
99
+ return this.rejected("INVALID_INPUT");
100
+ let argumentsObject;
101
+ try {
102
+ session.validateArguments(invocation.tool, invocation.argumentsJson);
103
+ const parsed = JSON.parse(invocation.argumentsJson);
104
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
105
+ throw new SafeMcpError("MCP tool arguments must be a JSON object");
106
+ argumentsObject = parsed;
107
+ }
108
+ catch {
109
+ return this.rejected("INVALID_INPUT");
110
+ }
111
+ const authorization = await this.authorize(invocation, policy, argumentsObject);
112
+ if (authorization === "unavailable")
113
+ return this.rejected("UNAVAILABLE");
114
+ if (authorization === "denied")
115
+ return this.rejected("AUTHENTICATION_REQUIRED");
116
+ return this.dispatch(invocation, session, policy);
117
+ }
118
+ /**
119
+ * Checks one registered tool authorization callback before intent is saved.
120
+ *
121
+ * @param call Model-proposed tool call.
122
+ * @param policy Registered tool policy.
123
+ * @param argumentsObject Parsed JSON object arguments.
124
+ * @returns Allowed, denied or unavailable authorization state.
125
+ */
126
+ async authorize(call, policy, argumentsObject) {
127
+ try {
128
+ const allowed = await this.bounded((control) => policy.authorize(this.host.scope, {
129
+ tool: { server: call.server, tool: call.tool },
130
+ arguments: argumentsObject,
131
+ }, control), this.hookTimeout());
132
+ return allowed ? "allowed" : "denied";
133
+ }
134
+ catch {
135
+ return "unavailable";
136
+ }
137
+ }
138
+ /**
139
+ * Cancels pending work and attempts bounded cleanup of connected protocol sessions.
140
+ *
141
+ * @returns Shared completion, rejecting if cleanup fails or exceeds the deadline.
142
+ */
143
+ close() {
144
+ this.closing ??= this.closeSessions();
145
+ return this.closing;
146
+ }
147
+ /**
148
+ * Cancels callbacks and bounds the wait for connected protocol sessions.
149
+ *
150
+ * @returns Shared cleanup completion or a safe rejection.
151
+ */
152
+ async closeSessions() {
153
+ this.closed.abort();
154
+ const sessions = [...this.sessions.values()];
155
+ this.sessions.clear();
156
+ const settled = Promise.allSettled(sessions.map((session) => Promise.resolve().then(() => session.close())));
157
+ const timeoutMs = this.hookTimeout();
158
+ const timeoutDeadline = timeoutMs === undefined ? undefined : Time.currentTimeMillis() + timeoutMs;
159
+ const deadline = this.host.deadlineEpochMs === undefined
160
+ ? timeoutDeadline
161
+ : timeoutDeadline === undefined
162
+ ? this.host.deadlineEpochMs
163
+ : Math.min(this.host.deadlineEpochMs, timeoutDeadline);
164
+ const child = new AbortController();
165
+ const stop = deadline === undefined ? () => undefined : schedule(deadline, child);
166
+ const abort = abortWait(child.signal);
167
+ let closed;
168
+ try {
169
+ closed = await Promise.race([settled, abort.promise]);
170
+ }
171
+ finally {
172
+ abort.dispose();
173
+ stop();
174
+ }
175
+ if (closed.some((result) => result.status === "rejected"))
176
+ throw new SafeMcpError("MCP session close failed");
177
+ }
178
+ /**
179
+ * Lists registry-approved servers without making a connection.
180
+ *
181
+ * @returns Exact servers and configured tools.
182
+ */
183
+ selected() {
184
+ const servers = new Map();
185
+ for (const ref of this.allowedTools) {
186
+ const registration = mcpRegistration(this.host.registry, ref.server);
187
+ if (!registration)
188
+ throw new SafeMcpError("MCP server is not registered");
189
+ const definition = mcpDefinition(registration);
190
+ if (!Object.hasOwn(definition.tools, ref.tool))
191
+ throw new SafeMcpError("MCP tool is not configured");
192
+ const selected = servers.get(ref.server) ?? { definition, tools: [] };
193
+ if (selected.tools.includes(ref.tool))
194
+ throw new SafeMcpError("MCP tool reference is duplicated");
195
+ selected.tools.push(ref.tool);
196
+ servers.set(ref.server, selected);
197
+ }
198
+ return servers;
199
+ }
200
+ /**
201
+ * Prepares every selected server under bounded authorization.
202
+ *
203
+ * @returns Catalog in capability order.
204
+ */
205
+ async prepareAll() {
206
+ const selected = this.selected();
207
+ if (!selected.size)
208
+ return Object.freeze([]);
209
+ if (!this.host.backend.mcp)
210
+ throw new SafeMcpError("Selected backend has no MCP protocol factory");
211
+ const definitions = new Map();
212
+ try {
213
+ for (const [id, server] of selected) {
214
+ const session = await this.connect(server.definition);
215
+ const found = await this.bounded(() => session.discover(server.tools), this.hookTimeout());
216
+ this.collectDefinitions(id, server.tools, found, definitions);
217
+ }
218
+ return this.orderedCatalog(definitions);
219
+ }
220
+ catch (error) {
221
+ try {
222
+ await this.close();
223
+ }
224
+ catch {
225
+ /* The setup failure remains authoritative. */
226
+ }
227
+ if (error instanceof AiMcpSetupFailure || error instanceof AgentExecutionFault)
228
+ throw error;
229
+ throw error instanceof SafeMcpError ? error : new SafeMcpError("MCP setup failed");
230
+ }
231
+ }
232
+ /**
233
+ * Checks discovered definitions against configured names without advertising extras.
234
+ *
235
+ * @param id Registered server ID.
236
+ * @param allowed Configured tool names.
237
+ * @param found Bounded discovery result.
238
+ * @param definitions Accumulated exact catalog.
239
+ */
240
+ collectDefinitions(id, allowed, found, definitions) {
241
+ for (const tool of found) {
242
+ const key = `${id}\u0000${tool.name}`;
243
+ if (!allowed.includes(tool.name) || definitions.has(key))
244
+ throw new AiMcpSetupFailure("UNSUPPORTED_CAPABILITY");
245
+ definitions.set(key, Object.freeze({
246
+ server: id,
247
+ tool: tool.name,
248
+ description: tool.description,
249
+ inputSchemaJson: tool.inputSchemaJson,
250
+ ...(tool.outputSchemaJson === undefined
251
+ ? {}
252
+ : { outputSchemaJson: tool.outputSchemaJson }),
253
+ }));
254
+ }
255
+ }
256
+ /**
257
+ * Returns the exact discovered catalog in capability order.
258
+ *
259
+ * @param definitions Checked descriptions and schemas by configured reference.
260
+ * @returns Immutable catalog in capability order.
261
+ */
262
+ orderedCatalog(definitions) {
263
+ return Object.freeze(this.allowedTools.map((ref) => {
264
+ const definition = definitions.get(`${ref.server}\u0000${ref.tool}`);
265
+ if (!definition)
266
+ throw new AiMcpSetupFailure("UNSUPPORTED_CAPABILITY");
267
+ return definition;
268
+ }));
269
+ }
270
+ /**
271
+ * Connects one authorized server and checks its credential-free identity.
272
+ *
273
+ * @param server Registered server configuration.
274
+ * @returns Scoped protocol session.
275
+ */
276
+ async connect(server) {
277
+ const timeout = this.hookTimeout();
278
+ const allowed = await this.bounded((control) => server.authorizeConnect(this.host.scope, control), timeout);
279
+ if (!allowed)
280
+ throw new AiMcpSetupFailure("AUTHENTICATION_REQUIRED");
281
+ const resolved = await this.resolve(server);
282
+ const factory = this.host.backend.mcp;
283
+ if (!factory)
284
+ throw new SafeMcpError("Selected backend has no MCP protocol factory");
285
+ const session = await this.bounded((control) => factory.connect({
286
+ server,
287
+ scope: this.host.scope,
288
+ resolved,
289
+ control: this.protocol(server.id, control),
290
+ }), timeout, (late) => late.close());
291
+ await this.checkConnectionIdentity(server, session, timeout);
292
+ this.sessions.set(server.id, session);
293
+ return session;
294
+ }
295
+ /**
296
+ * Rejects identity drift after attempting bounded cleanup of the session.
297
+ *
298
+ * @param server Registered server configuration.
299
+ * @param session Newly connected protocol session.
300
+ * @param timeout Local callback timeout in milliseconds.
301
+ * @returns Completion after identity verification.
302
+ */
303
+ async checkConnectionIdentity(server, session, timeout) {
304
+ if (session.identity.serverId !== server.id ||
305
+ session.identity.revision !== server.revision ||
306
+ session.identity.endpoint !== endpointDigest(server)) {
307
+ try {
308
+ await this.bounded(() => session.close(), timeout);
309
+ }
310
+ catch {
311
+ // Identity mismatch remains the safe rejection after bounded cleanup.
312
+ }
313
+ throw new SafeMcpError("MCP connection identity changed");
314
+ }
315
+ }
316
+ /**
317
+ * Resolves scoped credentials without adding them to recorded identity.
318
+ *
319
+ * @param server Registered server configuration.
320
+ * @returns Headers or child environment for connection construction.
321
+ */
322
+ async resolve(server) {
323
+ const transport = server.transport;
324
+ const timeout = this.hookTimeout();
325
+ if (transport.kind === "streamable-http") {
326
+ const headers = transport.headers;
327
+ return headers
328
+ ? { headers: await this.bounded((control) => headers(this.host.scope, control), timeout) }
329
+ : {};
330
+ }
331
+ const environment = transport.environment;
332
+ return environment
333
+ ? {
334
+ environment: await this.bounded((control) => environment(this.host.scope, control), timeout),
335
+ }
336
+ : {};
337
+ }
338
+ /**
339
+ * Reads the finite callback bound from application registration.
340
+ *
341
+ * @returns Callback timeout in milliseconds.
342
+ */
343
+ hookTimeout() {
344
+ return registryOptions(this.host.registry).hookTimeoutMs;
345
+ }
346
+ /**
347
+ * Binds protocol reservations and receipts to the shared budget.
348
+ *
349
+ * @param server Registered server ID.
350
+ * @param control Bounded connection control.
351
+ * @returns Protocol controls scoped to this operation.
352
+ */
353
+ protocol(server, control) {
354
+ return {
355
+ signal: control.signal,
356
+ ...(this.host.deadlineEpochMs === undefined
357
+ ? {}
358
+ : { deadlineEpochMs: this.host.deadlineEpochMs }),
359
+ nowEpochMs: () => Time.currentTimeMillis(),
360
+ hasAuthority: () => !control.signal.aborted && !this.closed.signal.aborted,
361
+ reserveMessage: (request) => this.host.reserveMessage(server, request),
362
+ onReceived: (id, bytes) => {
363
+ this.host.onReceived(id, bytes);
364
+ },
365
+ finishMessage: (id, bytes) => this.host.finishMessage(id, bytes),
366
+ };
367
+ }
368
+ /**
369
+ * Checks whether the capability listed this exact tool reference.
370
+ *
371
+ * @param call Model-proposed tool reference.
372
+ * @returns Whether the tool is in the configured allowlist.
373
+ */
374
+ isAllowed(call) {
375
+ return this.allowedTools.some((ref) => ref.server === call.server && ref.tool === call.tool);
376
+ }
377
+ /**
378
+ * Finds a registered server by ID.
379
+ *
380
+ * @param id Registered server ID.
381
+ * @returns Server definition, or absence for an unknown ID.
382
+ */
383
+ serverFor(id) {
384
+ const registration = mcpRegistration(this.host.registry, id);
385
+ return registration ? mcpDefinition(registration) : undefined;
386
+ }
387
+ /**
388
+ * Records intent, dispatches once and persists the resulting response.
389
+ *
390
+ * @param call Correlated model proposal.
391
+ * @param session Checked protocol session.
392
+ * @param policy Registered tool policy.
393
+ * @returns Saved or newly persisted response.
394
+ */
395
+ async dispatch(call, session, policy) {
396
+ const request = {
397
+ server: create(McpServerIdSchema, { value: call.server }),
398
+ tool: create(McpToolNameSchema, { value: call.tool }),
399
+ argumentsJson: call.argumentsJson,
400
+ effect: policy.effect === "write" ? ToolEffect.WRITE : ToolEffect.READ,
401
+ };
402
+ let stage = "intent";
403
+ try {
404
+ const intent = await this.host.journalToolIntent(call, request);
405
+ if (intent.kind !== "new")
406
+ return intent.response;
407
+ stage = "mark";
408
+ await this.host.markToolDispatched(intent.callId);
409
+ stage = "perform";
410
+ const response = await this.perform(call, session, policy, intent.callId);
411
+ stage = "finish";
412
+ await this.host.finishTool(intent.callId, response, this.history(response));
413
+ return response;
414
+ }
415
+ catch (error) {
416
+ console.error(`[Release Notes Studio generation] stage=mcp-dispatch code=${stage}`);
417
+ const reason = error instanceof Error ? toolDispatchReasons.get(error.message) : undefined;
418
+ console.error(`[Release Notes Studio generation] stage=mcp-reason code=${reason ?? "other"}`);
419
+ throw error;
420
+ }
421
+ }
422
+ /**
423
+ * Performs a bounded call and preserves uncertainty for failed writes.
424
+ *
425
+ * @param call Correlated model proposal.
426
+ * @param session Checked protocol session.
427
+ * @param policy Registered tool policy.
428
+ * @param callId Runtime-allocated tool call ID.
429
+ * @returns Supported result or recorded safe failure.
430
+ */
431
+ async perform(call, session, policy, callId) {
432
+ try {
433
+ const result = await this.bounded((control) => session.call(call.tool, call.argumentsJson, {
434
+ toolCallId: callId,
435
+ signal: control.signal,
436
+ ...(control.deadlineEpochMs === undefined
437
+ ? {}
438
+ : { deadlineEpochMs: control.deadlineEpochMs }),
439
+ ...(policy.maxResultBytes === undefined
440
+ ? {}
441
+ : { maxResultBytes: policy.maxResultBytes }),
442
+ }), policy.timeoutMs);
443
+ return this.response(callId, result);
444
+ }
445
+ catch {
446
+ const unknown = policy.effect === "write";
447
+ const failure = await this.host.recordFailure(unknown ? "TOOL_OUTCOME_UNKNOWN" : "TOOL_FAILED", false);
448
+ return create(ToolResponseSchema, {
449
+ call: create(ToolCallIdSchema, { value: callId }),
450
+ outcome: unknown ? AiOutcome.UNKNOWN : AiOutcome.FAILED,
451
+ diagnosticId: create(AiDiagnosticIdSchema, { value: failure.diagnosticId }),
452
+ });
453
+ }
454
+ }
455
+ /**
456
+ * Converts supported text and structured JSON with the MCP error flag.
457
+ *
458
+ * @param callId Runtime-allocated tool call ID.
459
+ * @param result Bounded protocol result.
460
+ * @returns Domain tool response.
461
+ */
462
+ response(callId, result) {
463
+ const structured = result.content.filter((part) => part.kind === "json");
464
+ if (structured.length > 1)
465
+ throw new Error("MCP result has multiple structured values");
466
+ return create(ToolResponseSchema, {
467
+ call: create(ToolCallIdSchema, { value: callId }),
468
+ outcome: result.isError ? AiOutcome.FAILED : AiOutcome.ADMITTED,
469
+ text: result.content.flatMap((part) => (part.kind === "text" ? [part.text] : [])),
470
+ ...(structured[0]?.kind === "json" ? { structuredJson: structured[0].json } : {}),
471
+ toolError: result.isError,
472
+ });
473
+ }
474
+ /**
475
+ * Records a failed proposal without fabricating an authorized request.
476
+ *
477
+ * @param code Safe failure category.
478
+ * @returns Failed response with a persisted diagnostic reference.
479
+ */
480
+ async rejected(code) {
481
+ const failure = await this.host.recordFailure(code, false);
482
+ return create(ToolResponseSchema, {
483
+ call: create(ToolCallIdSchema, { value: randomUUID() }),
484
+ outcome: AiOutcome.FAILED,
485
+ diagnosticId: create(AiDiagnosticIdSchema, { value: failure.diagnosticId }),
486
+ });
487
+ }
488
+ /**
489
+ * Creates response history for one completed tool intent.
490
+ *
491
+ * @param response Persisted tool response.
492
+ * @returns Conversation record wrapped as an Agent history entry.
493
+ */
494
+ history(response) {
495
+ const occurredAt = Time.currentTime();
496
+ return create(AgentHistoryEntrySchema, {
497
+ occurredAt,
498
+ item: {
499
+ case: "conversationRecord",
500
+ value: create(ConversationRecordSchema, {
501
+ id: create(ConversationRecordIdSchema, { value: randomUUID() }),
502
+ conversation: this.host.operation.conversation,
503
+ operation: this.host.operation.operation,
504
+ toolCall: response.call,
505
+ occurredAt,
506
+ content: AnyMessages.pack(ToolResponseSchema, response),
507
+ }),
508
+ },
509
+ });
510
+ }
511
+ /**
512
+ * Executes one callback within the operation and local deadline.
513
+ *
514
+ * @typeParam T Callback result type.
515
+ * @param run Callback with a child cancellation control.
516
+ * @param limitMs Configured local timeout in milliseconds.
517
+ * @param onLate Cleanup for a resource created after cancellation.
518
+ * @returns Callback result before the deadline.
519
+ */
520
+ async bounded(run, limitMs, onLate) {
521
+ const now = Time.currentTimeMillis();
522
+ const deadline = effectiveDeadline(this.host.deadlineEpochMs, limitMs, now);
523
+ if (this.host.signal.aborted ||
524
+ this.closed.signal.aborted ||
525
+ (deadline !== undefined && deadline <= now))
526
+ throw new SafeMcpError("MCP operation deadline or cancellation");
527
+ const child = new AbortController();
528
+ const signal = AbortSignal.any([this.host.signal, this.closed.signal, child.signal]);
529
+ const stop = deadline === undefined ? () => undefined : schedule(deadline, child);
530
+ const running = Promise.resolve().then(() => run({ signal, ...(deadline === undefined ? {} : { deadlineEpochMs: deadline }) }));
531
+ const abort = abortWait(signal);
532
+ try {
533
+ return await Promise.race([running, abort.promise]);
534
+ }
535
+ catch (error) {
536
+ if (onLate)
537
+ void running.then(onLate, () => undefined).catch(() => undefined);
538
+ throw error;
539
+ }
540
+ finally {
541
+ abort.dispose();
542
+ stop();
543
+ }
544
+ }
545
+ }
546
+ /**
547
+ * Chooses the earliest explicitly configured host or local deadline.
548
+ *
549
+ * @param hostDeadline Host operation deadline, if configured.
550
+ * @param limitMs Explicit local callback limit, if configured.
551
+ * @param now Current domain time in epoch milliseconds.
552
+ * @returns Effective deadline or undefined when neither exists.
553
+ */
554
+ const effectiveDeadline = (hostDeadline, limitMs, now) => {
555
+ const local = limitMs === undefined ? undefined : now + limitMs;
556
+ return hostDeadline === undefined
557
+ ? local
558
+ : local === undefined
559
+ ? hostDeadline
560
+ : Math.min(hostDeadline, local);
561
+ };
562
+ /**
563
+ * Calculates SHA-256 of the configured transport endpoint without resolved credentials.
564
+ *
565
+ * @param server Registered transport configuration.
566
+ * @returns Credential-free endpoint digest.
567
+ */
568
+ const endpointDigest = (server) => {
569
+ const transport = server.transport;
570
+ const fingerprint = transport.kind === "streamable-http"
571
+ ? transport.url
572
+ : JSON.stringify([transport.executable, transport.args, transport.cwd]);
573
+ return `sha256:${createHash("sha256").update(fingerprint).digest("hex")}`;
574
+ };
575
+ /**
576
+ * Creates an abort rejection with listener cleanup for one bounded callback.
577
+ *
578
+ * @param signal Child cancellation signal.
579
+ * @returns Abort promise and listener disposal.
580
+ */
581
+ const abortWait = (signal) => {
582
+ let listener;
583
+ const promise = new Promise((_, reject) => {
584
+ listener = () => {
585
+ reject(new SafeMcpError("MCP operation deadline or cancellation"));
586
+ };
587
+ if (signal.aborted)
588
+ listener();
589
+ else
590
+ signal.addEventListener("abort", listener, { once: true });
591
+ });
592
+ return {
593
+ promise,
594
+ dispose: () => {
595
+ if (listener)
596
+ signal.removeEventListener("abort", listener);
597
+ },
598
+ };
599
+ };
600
+ /**
601
+ * Schedules a timer that rechecks long absolute deadlines.
602
+ *
603
+ * @param deadline Absolute epoch millisecond deadline.
604
+ * @param child Child controller to abort when expired.
605
+ * @returns Timer cancellation.
606
+ */
607
+ const schedule = (deadline, child) => {
608
+ let timer;
609
+ const tick = () => {
610
+ const remaining = deadline - Time.currentTimeMillis();
611
+ if (remaining <= 0)
612
+ child.abort();
613
+ else
614
+ timer = setTimeout(tick, Math.min(remaining, 2_147_483_647));
615
+ };
616
+ tick();
617
+ return () => {
618
+ clearTimeout(timer);
619
+ };
620
+ };
621
+ //# sourceMappingURL=agent-mcp-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-mcp-runtime.js","sourceRoot":"","sources":["../../src/agent/agent-mcp-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,GAChB,MAAM,oCAAoC,CAAC;AAQ5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,SAAS,EACT,kBAAkB,IAAI,gBAAgB,EACtC,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,kBAAkB,GAGnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAOjE;;GAEG;AACH,MAAM,YAAa,SAAQ,KAAK;CAAG;AAEnC,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,CAAC,iDAAiD,EAAE,qBAAqB,CAAC;IAC1E,CAAC,gCAAgC,EAAE,cAAc,CAAC;IAClD,CAAC,+BAA+B,EAAE,mBAAmB,CAAC;IACtD,CAAC,wDAAwD,EAAE,qBAAqB,CA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