@spine-event-engine/server 2.0.0-snapshot.24 → 2.0.0-snapshot.26

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 (374) hide show
  1. package/README.md +86 -19
  2. package/REFERENCE.md +538 -150
  3. package/dist/agent/agent-acceptance-receipts.d.ts +69 -0
  4. package/dist/agent/agent-acceptance-receipts.d.ts.map +1 -0
  5. package/dist/agent/agent-acceptance-receipts.js +198 -0
  6. package/dist/agent/agent-acceptance-receipts.js.map +1 -0
  7. package/dist/agent/agent-execution-capacity.d.ts +37 -9
  8. package/dist/agent/agent-execution-capacity.d.ts.map +1 -1
  9. package/dist/agent/agent-execution-capacity.js +73 -15
  10. package/dist/agent/agent-execution-capacity.js.map +1 -1
  11. package/dist/agent/agent-history.d.ts +33 -12
  12. package/dist/agent/agent-history.d.ts.map +1 -1
  13. package/dist/agent/agent-history.js +61 -18
  14. package/dist/agent/agent-history.js.map +1 -1
  15. package/dist/agent/agent-live-ai-audit.d.ts +95 -0
  16. package/dist/agent/agent-live-ai-audit.d.ts.map +1 -0
  17. package/dist/agent/agent-live-ai-audit.js +290 -0
  18. package/dist/agent/agent-live-ai-audit.js.map +1 -0
  19. package/dist/agent/agent-live-ai-runtime.d.ts +300 -0
  20. package/dist/agent/agent-live-ai-runtime.d.ts.map +1 -0
  21. package/dist/agent/agent-live-ai-runtime.js +611 -0
  22. package/dist/agent/agent-live-ai-runtime.js.map +1 -0
  23. package/dist/agent/agent-live-audit.d.ts +67 -0
  24. package/dist/agent/agent-live-audit.d.ts.map +1 -0
  25. package/dist/agent/agent-live-audit.js +121 -0
  26. package/dist/agent/agent-live-audit.js.map +1 -0
  27. package/dist/agent/agent-live-budget.d.ts +84 -0
  28. package/dist/agent/agent-live-budget.d.ts.map +1 -0
  29. package/dist/agent/agent-live-budget.js +161 -0
  30. package/dist/agent/agent-live-budget.js.map +1 -0
  31. package/dist/agent/agent-live-fault.d.ts +18 -0
  32. package/dist/agent/agent-live-fault.d.ts.map +1 -0
  33. package/dist/agent/{agent-execution-fault.js → agent-live-fault.js} +7 -7
  34. package/dist/agent/agent-live-fault.js.map +1 -0
  35. package/dist/agent/agent-live-inputs.d.ts +74 -0
  36. package/dist/agent/agent-live-inputs.d.ts.map +1 -0
  37. package/dist/agent/agent-live-inputs.js +15 -0
  38. package/dist/agent/agent-live-inputs.js.map +1 -0
  39. package/dist/agent/agent-live-interaction-events.d.ts +46 -0
  40. package/dist/agent/agent-live-interaction-events.d.ts.map +1 -0
  41. package/dist/agent/agent-live-interaction-events.js +104 -0
  42. package/dist/agent/agent-live-interaction-events.js.map +1 -0
  43. package/dist/agent/agent-live-mcp-controls.d.ts +129 -0
  44. package/dist/agent/agent-live-mcp-controls.d.ts.map +1 -0
  45. package/dist/agent/agent-live-mcp-controls.js +228 -0
  46. package/dist/agent/agent-live-mcp-controls.js.map +1 -0
  47. package/dist/agent/agent-live-mcp-host.d.ts +88 -0
  48. package/dist/agent/agent-live-mcp-host.d.ts.map +1 -0
  49. package/dist/agent/{agent-mcp-host.js → agent-live-mcp-host.js} +1 -1
  50. package/dist/agent/agent-live-mcp-host.js.map +1 -0
  51. package/dist/agent/{agent-mcp-runtime.d.ts → agent-live-mcp-runtime.d.ts} +6 -6
  52. package/dist/agent/agent-live-mcp-runtime.d.ts.map +1 -0
  53. package/dist/agent/{agent-mcp-runtime.js → agent-live-mcp-runtime.js} +13 -42
  54. package/dist/agent/agent-live-mcp-runtime.js.map +1 -0
  55. package/dist/agent/agent-live-read-runtime.d.ts +72 -0
  56. package/dist/agent/agent-live-read-runtime.d.ts.map +1 -0
  57. package/dist/agent/agent-live-read-runtime.js +122 -0
  58. package/dist/agent/agent-live-read-runtime.js.map +1 -0
  59. package/dist/agent/agent-model-selection.d.ts +21 -34
  60. package/dist/agent/agent-model-selection.d.ts.map +1 -1
  61. package/dist/agent/agent-model-selection.js +61 -78
  62. package/dist/agent/agent-model-selection.js.map +1 -1
  63. package/dist/browser/browser-server.d.ts +163 -0
  64. package/dist/browser/browser-server.d.ts.map +1 -1
  65. package/dist/browser/browser-server.js +579 -188
  66. package/dist/browser/browser-server.js.map +1 -1
  67. package/dist/browser/durable-subscription-bindings.d.ts +5 -0
  68. package/dist/browser/durable-subscription-bindings.d.ts.map +1 -1
  69. package/dist/browser/durable-subscription-bindings.js +226 -38
  70. package/dist/browser/durable-subscription-bindings.js.map +1 -1
  71. package/dist/browser/options.d.ts +5 -0
  72. package/dist/browser/options.d.ts.map +1 -1
  73. package/dist/bus/command-bus.d.ts +17 -18
  74. package/dist/bus/command-bus.d.ts.map +1 -1
  75. package/dist/bus/command-bus.js +97 -54
  76. package/dist/bus/command-bus.js.map +1 -1
  77. package/dist/bus/command-errors.d.ts +20 -4
  78. package/dist/bus/command-errors.d.ts.map +1 -1
  79. package/dist/bus/command-errors.js +47 -7
  80. package/dist/bus/command-errors.js.map +1 -1
  81. package/dist/bus/event-bus.d.ts +20 -4
  82. package/dist/bus/event-bus.d.ts.map +1 -1
  83. package/dist/bus/event-bus.js +166 -14
  84. package/dist/bus/event-bus.js.map +1 -1
  85. package/dist/context/bounded-context.d.ts +169 -98
  86. package/dist/context/bounded-context.d.ts.map +1 -1
  87. package/dist/context/bounded-context.js +837 -503
  88. package/dist/context/bounded-context.js.map +1 -1
  89. package/dist/context/entity-inbox.d.ts +7 -2
  90. package/dist/context/entity-inbox.d.ts.map +1 -1
  91. package/dist/context/entity-inbox.js +22 -13
  92. package/dist/context/entity-inbox.js.map +1 -1
  93. package/dist/context/local-inbox-handoff.d.ts +34 -34
  94. package/dist/context/local-inbox-handoff.d.ts.map +1 -1
  95. package/dist/context/local-inbox-handoff.js +108 -150
  96. package/dist/context/local-inbox-handoff.js.map +1 -1
  97. package/dist/context/projection-handoff.d.ts +2 -2
  98. package/dist/context/projection-handoff.d.ts.map +1 -1
  99. package/dist/context/projection-handoff.js +10 -8
  100. package/dist/context/projection-handoff.js.map +1 -1
  101. package/dist/context/tenant-index.d.ts +36 -31
  102. package/dist/context/tenant-index.d.ts.map +1 -1
  103. package/dist/context/tenant-index.js +123 -125
  104. package/dist/context/tenant-index.js.map +1 -1
  105. package/dist/context/tenant-unknown-error.d.ts +33 -0
  106. package/dist/context/tenant-unknown-error.d.ts.map +1 -0
  107. package/dist/context/tenant-unknown-error.js +75 -0
  108. package/dist/context/tenant-unknown-error.js.map +1 -0
  109. package/dist/delivery/agent-delivery-scope.d.ts +66 -0
  110. package/dist/delivery/agent-delivery-scope.d.ts.map +1 -0
  111. package/dist/delivery/agent-delivery-scope.js +44 -0
  112. package/dist/delivery/agent-delivery-scope.js.map +1 -0
  113. package/dist/delivery/delivery-builder.d.ts +25 -1
  114. package/dist/delivery/delivery-builder.d.ts.map +1 -1
  115. package/dist/delivery/delivery-builder.js +89 -0
  116. package/dist/delivery/delivery-builder.js.map +1 -1
  117. package/dist/delivery/delivery-monitor.d.ts +1 -1
  118. package/dist/delivery/delivery-monitor.js +1 -1
  119. package/dist/delivery/delivery-run-control.d.ts +6 -0
  120. package/dist/delivery/delivery-run-control.d.ts.map +1 -1
  121. package/dist/delivery/delivery-run-control.js +10 -0
  122. package/dist/delivery/delivery-run-control.js.map +1 -1
  123. package/dist/delivery/delivery-supervisor.d.ts.map +1 -1
  124. package/dist/delivery/delivery-supervisor.js +28 -4
  125. package/dist/delivery/delivery-supervisor.js.map +1 -1
  126. package/dist/delivery/delivery-tenant.d.ts +17 -0
  127. package/dist/delivery/delivery-tenant.d.ts.map +1 -0
  128. package/dist/delivery/delivery-tenant.js +50 -0
  129. package/dist/delivery/delivery-tenant.js.map +1 -0
  130. package/dist/delivery/delivery.d.ts +96 -2
  131. package/dist/delivery/delivery.d.ts.map +1 -1
  132. package/dist/delivery/delivery.js +693 -53
  133. package/dist/delivery/delivery.js.map +1 -1
  134. package/dist/delivery/inbox-records.d.ts.map +1 -1
  135. package/dist/delivery/inbox-records.js +9 -16
  136. package/dist/delivery/inbox-records.js.map +1 -1
  137. package/dist/delivery/inbox-storage.d.ts +6 -0
  138. package/dist/delivery/inbox-storage.d.ts.map +1 -1
  139. package/dist/delivery/inbox-storage.js +43 -6
  140. package/dist/delivery/inbox-storage.js.map +1 -1
  141. package/dist/delivery/inbox.d.ts.map +1 -1
  142. package/dist/delivery/inbox.js +3 -2
  143. package/dist/delivery/inbox.js.map +1 -1
  144. package/dist/delivery/reception-observation.d.ts +12 -4
  145. package/dist/delivery/reception-observation.d.ts.map +1 -1
  146. package/dist/delivery/reception-observation.js +14 -3
  147. package/dist/delivery/reception-observation.js.map +1 -1
  148. package/dist/delivery/sharded-work-registry.d.ts +6 -0
  149. package/dist/delivery/sharded-work-registry.d.ts.map +1 -1
  150. package/dist/delivery/sharded-work-registry.js +41 -4
  151. package/dist/delivery/sharded-work-registry.js.map +1 -1
  152. package/dist/entity/entity-storage-descriptor.d.ts.map +1 -1
  153. package/dist/entity/entity-storage-descriptor.js +7 -4
  154. package/dist/entity/entity-storage-descriptor.js.map +1 -1
  155. package/dist/entity/entity.d.ts +59 -0
  156. package/dist/entity/entity.d.ts.map +1 -1
  157. package/dist/entity/entity.js +60 -0
  158. package/dist/entity/entity.js.map +1 -1
  159. package/dist/handler/app-query-handler.d.ts +60 -0
  160. package/dist/handler/app-query-handler.d.ts.map +1 -0
  161. package/dist/{bus/saved-dispatcher-binding.js → handler/app-query-handler.js} +8 -12
  162. package/dist/handler/app-query-handler.js.map +1 -0
  163. package/dist/handler/generated-registry-discovery.d.ts +6 -0
  164. package/dist/handler/generated-registry-discovery.d.ts.map +1 -1
  165. package/dist/handler/generated-registry-discovery.js +71 -2
  166. package/dist/handler/generated-registry-discovery.js.map +1 -1
  167. package/dist/handler/handler-decorators.d.ts +8 -29
  168. package/dist/handler/handler-decorators.d.ts.map +1 -1
  169. package/dist/handler/handler-decorators.js +33 -210
  170. package/dist/handler/handler-decorators.js.map +1 -1
  171. package/dist/handler/spine-metadata-inventory.d.ts +99 -0
  172. package/dist/handler/spine-metadata-inventory.d.ts.map +1 -0
  173. package/dist/handler/spine-metadata-inventory.js +162 -0
  174. package/dist/handler/spine-metadata-inventory.js.map +1 -0
  175. package/dist/index.d.ts +9 -5
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +6 -3
  178. package/dist/index.js.map +1 -1
  179. package/dist/integration/external-messages.d.ts.map +1 -1
  180. package/dist/integration/external-messages.js +9 -15
  181. package/dist/integration/external-messages.js.map +1 -1
  182. package/dist/integration/integration-broker.d.ts.map +1 -1
  183. package/dist/integration/integration-broker.js +112 -6
  184. package/dist/integration/integration-broker.js.map +1 -1
  185. package/dist/integration/third-party-context.d.ts.map +1 -1
  186. package/dist/integration/third-party-context.js +7 -10
  187. package/dist/integration/third-party-context.js.map +1 -1
  188. package/dist/repository/primitive-id.js +26 -11
  189. package/dist/repository/primitive-id.js.map +1 -1
  190. package/dist/repository/repository.d.ts +75 -60
  191. package/dist/repository/repository.d.ts.map +1 -1
  192. package/dist/repository/repository.js +1757 -1818
  193. package/dist/repository/repository.js.map +1 -1
  194. package/dist/runtime/runtime.d.ts +13 -0
  195. package/dist/runtime/runtime.d.ts.map +1 -1
  196. package/dist/runtime/runtime.js +18 -0
  197. package/dist/runtime/runtime.js.map +1 -1
  198. package/dist/runtime/signal-metadata.d.ts.map +1 -1
  199. package/dist/runtime/signal-metadata.js +6 -6
  200. package/dist/runtime/signal-metadata.js.map +1 -1
  201. package/dist/runtime/signal-publisher.d.ts +0 -6
  202. package/dist/runtime/signal-publisher.d.ts.map +1 -1
  203. package/dist/runtime/signal-publisher.js +1 -9
  204. package/dist/runtime/signal-publisher.js.map +1 -1
  205. package/dist/runtime/standalone-handler-runtime.d.ts +0 -7
  206. package/dist/runtime/standalone-handler-runtime.d.ts.map +1 -1
  207. package/dist/runtime/standalone-handler-runtime.js +13 -99
  208. package/dist/runtime/standalone-handler-runtime.js.map +1 -1
  209. package/dist/server/managed-delivery-gate.d.ts +34 -0
  210. package/dist/server/managed-delivery-gate.d.ts.map +1 -0
  211. package/dist/server/managed-delivery-gate.js +70 -0
  212. package/dist/server/managed-delivery-gate.js.map +1 -0
  213. package/dist/server/managed-server-application.d.ts +12 -11
  214. package/dist/server/managed-server-application.d.ts.map +1 -1
  215. package/dist/server/managed-server-application.js +48 -29
  216. package/dist/server/managed-server-application.js.map +1 -1
  217. package/dist/server/node-coordinator.d.ts +18 -5
  218. package/dist/server/node-coordinator.d.ts.map +1 -1
  219. package/dist/server/node-coordinator.js +554 -84
  220. package/dist/server/node-coordinator.js.map +1 -1
  221. package/dist/server/reserved-spine-rpc-paths.json +1 -0
  222. package/dist/server/server-environment.d.ts +220 -25
  223. package/dist/server/server-environment.d.ts.map +1 -1
  224. package/dist/server/server-environment.js +734 -145
  225. package/dist/server/server-environment.js.map +1 -1
  226. package/dist/server/server-log.d.ts +7 -0
  227. package/dist/server/server-log.d.ts.map +1 -1
  228. package/dist/server/server-log.js +14 -1
  229. package/dist/server/server-log.js.map +1 -1
  230. package/dist/server/server.d.ts +60 -29
  231. package/dist/server/server.d.ts.map +1 -1
  232. package/dist/server/server.js +155 -201
  233. package/dist/server/server.js.map +1 -1
  234. package/dist/services/app-query-execution.d.ts +53 -0
  235. package/dist/services/app-query-execution.d.ts.map +1 -0
  236. package/dist/services/app-query-execution.js +408 -0
  237. package/dist/services/app-query-execution.js.map +1 -0
  238. package/dist/services/query-reader.d.ts +32 -7
  239. package/dist/services/query-reader.d.ts.map +1 -1
  240. package/dist/services/query-reader.js +22 -2
  241. package/dist/services/query-reader.js.map +1 -1
  242. package/dist/services/read-request-status.d.ts +65 -0
  243. package/dist/services/read-request-status.d.ts.map +1 -0
  244. package/dist/services/read-request-status.js +151 -0
  245. package/dist/services/read-request-status.js.map +1 -0
  246. package/dist/services/spine-services.d.ts +37 -8
  247. package/dist/services/spine-services.d.ts.map +1 -1
  248. package/dist/services/spine-services.js +1103 -470
  249. package/dist/services/spine-services.js.map +1 -1
  250. package/dist/services/trusted-reader-ingress.d.ts +92 -0
  251. package/dist/services/trusted-reader-ingress.d.ts.map +1 -0
  252. package/dist/services/trusted-reader-ingress.js +89 -0
  253. package/dist/services/trusted-reader-ingress.js.map +1 -0
  254. package/dist/spi/handler-registry.d.ts +2 -0
  255. package/dist/spi/handler-registry.d.ts.map +1 -1
  256. package/dist/spi/handler-registry.js +1 -1
  257. package/dist/spi/handler-registry.js.map +1 -1
  258. package/dist/stand/event-origin-filter.js +3 -3
  259. package/dist/stand/event-origin-filter.js.map +1 -1
  260. package/dist/stand/read-side-filter-engine.d.ts +46 -0
  261. package/dist/stand/read-side-filter-engine.d.ts.map +1 -0
  262. package/dist/stand/read-side-filter-engine.js +356 -0
  263. package/dist/stand/read-side-filter-engine.js.map +1 -0
  264. package/dist/stand/read-side-filter.d.ts +247 -0
  265. package/dist/stand/read-side-filter.d.ts.map +1 -0
  266. package/dist/stand/read-side-filter.js +39 -0
  267. package/dist/stand/read-side-filter.js.map +1 -0
  268. package/dist/stand/read-side-message.d.ts +66 -0
  269. package/dist/stand/read-side-message.d.ts.map +1 -0
  270. package/dist/stand/read-side-message.js +167 -0
  271. package/dist/stand/read-side-message.js.map +1 -0
  272. package/dist/stand/stand-direct-delivery.d.ts +161 -0
  273. package/dist/stand/stand-direct-delivery.d.ts.map +1 -0
  274. package/dist/stand/stand-direct-delivery.js +210 -0
  275. package/dist/stand/stand-direct-delivery.js.map +1 -0
  276. package/dist/stand/stand.d.ts +94 -42
  277. package/dist/stand/stand.d.ts.map +1 -1
  278. package/dist/stand/stand.js +460 -60
  279. package/dist/stand/stand.js.map +1 -1
  280. package/dist/stand/subscription-observer.d.ts.map +1 -1
  281. package/dist/stand/subscription-observer.js +157 -40
  282. package/dist/stand/subscription-observer.js.map +1 -1
  283. package/dist/stand/subscription-read-filters.d.ts +40 -0
  284. package/dist/stand/subscription-read-filters.d.ts.map +1 -0
  285. package/dist/stand/subscription-read-filters.js +91 -0
  286. package/dist/stand/subscription-read-filters.js.map +1 -0
  287. package/dist/stand/subscription-reader-binding.d.ts +20 -0
  288. package/dist/stand/subscription-reader-binding.d.ts.map +1 -0
  289. package/dist/stand/subscription-reader-binding.js +56 -0
  290. package/dist/stand/subscription-reader-binding.js.map +1 -0
  291. package/dist/stand/subscription-records.d.ts +30 -3
  292. package/dist/stand/subscription-records.d.ts.map +1 -1
  293. package/dist/stand/subscription-records.js +61 -16
  294. package/dist/stand/subscription-records.js.map +1 -1
  295. package/dist/stand/subscription-registry.d.ts +54 -15
  296. package/dist/stand/subscription-registry.d.ts.map +1 -1
  297. package/dist/stand/subscription-registry.js +164 -41
  298. package/dist/stand/subscription-registry.js.map +1 -1
  299. package/dist/stand/subscription-runtime.d.ts +12 -5
  300. package/dist/stand/subscription-runtime.d.ts.map +1 -1
  301. package/dist/stand/subscription-runtime.js +183 -34
  302. package/dist/stand/subscription-runtime.js.map +1 -1
  303. package/dist/testing/index.d.ts.map +1 -1
  304. package/dist/testing/index.js +4 -3
  305. package/dist/testing/index.js.map +1 -1
  306. package/dist/tsconfig.tsbuildinfo +1 -1
  307. package/package.json +14 -14
  308. package/dist/agent/agent-admission.d.ts +0 -80
  309. package/dist/agent/agent-admission.d.ts.map +0 -1
  310. package/dist/agent/agent-admission.js +0 -127
  311. package/dist/agent/agent-admission.js.map +0 -1
  312. package/dist/agent/agent-ai-runtime.d.ts +0 -76
  313. package/dist/agent/agent-ai-runtime.d.ts.map +0 -1
  314. package/dist/agent/agent-ai-runtime.js +0 -1269
  315. package/dist/agent/agent-ai-runtime.js.map +0 -1
  316. package/dist/agent/agent-execution-fault.d.ts +0 -18
  317. package/dist/agent/agent-execution-fault.d.ts.map +0 -1
  318. package/dist/agent/agent-execution-fault.js.map +0 -1
  319. package/dist/agent/agent-execution-session.d.ts +0 -103
  320. package/dist/agent/agent-execution-session.d.ts.map +0 -1
  321. package/dist/agent/agent-execution-session.js +0 -238
  322. package/dist/agent/agent-execution-session.js.map +0 -1
  323. package/dist/agent/agent-interaction-audit.d.ts +0 -58
  324. package/dist/agent/agent-interaction-audit.d.ts.map +0 -1
  325. package/dist/agent/agent-interaction-audit.js +0 -114
  326. package/dist/agent/agent-interaction-audit.js.map +0 -1
  327. package/dist/agent/agent-interaction-events.d.ts +0 -40
  328. package/dist/agent/agent-interaction-events.d.ts.map +0 -1
  329. package/dist/agent/agent-interaction-events.js +0 -129
  330. package/dist/agent/agent-interaction-events.js.map +0 -1
  331. package/dist/agent/agent-mcp-budget.d.ts +0 -125
  332. package/dist/agent/agent-mcp-budget.d.ts.map +0 -1
  333. package/dist/agent/agent-mcp-budget.js +0 -566
  334. package/dist/agent/agent-mcp-budget.js.map +0 -1
  335. package/dist/agent/agent-mcp-host.d.ts +0 -125
  336. package/dist/agent/agent-mcp-host.d.ts.map +0 -1
  337. package/dist/agent/agent-mcp-host.js.map +0 -1
  338. package/dist/agent/agent-mcp-runtime.d.ts.map +0 -1
  339. package/dist/agent/agent-mcp-runtime.js.map +0 -1
  340. package/dist/agent/agent-read-runtime.d.ts +0 -70
  341. package/dist/agent/agent-read-runtime.d.ts.map +0 -1
  342. package/dist/agent/agent-read-runtime.js +0 -320
  343. package/dist/agent/agent-read-runtime.js.map +0 -1
  344. package/dist/agent/agent-revisions.d.ts +0 -35
  345. package/dist/agent/agent-revisions.d.ts.map +0 -1
  346. package/dist/agent/agent-revisions.js +0 -133
  347. package/dist/agent/agent-revisions.js.map +0 -1
  348. package/dist/agent/agent-scheduler.d.ts +0 -99
  349. package/dist/agent/agent-scheduler.d.ts.map +0 -1
  350. package/dist/agent/agent-scheduler.js +0 -398
  351. package/dist/agent/agent-scheduler.js.map +0 -1
  352. package/dist/bus/saved-dispatcher-binding.d.ts +0 -53
  353. package/dist/bus/saved-dispatcher-binding.d.ts.map +0 -1
  354. package/dist/bus/saved-dispatcher-binding.js.map +0 -1
  355. package/dist/delivery/delivery-run-coordinator.d.ts +0 -218
  356. package/dist/delivery/delivery-run-coordinator.d.ts.map +0 -1
  357. package/dist/delivery/delivery-run-coordinator.js +0 -609
  358. package/dist/delivery/delivery-run-coordinator.js.map +0 -1
  359. package/dist/delivery/parked-delivery-obligations.d.ts +0 -182
  360. package/dist/delivery/parked-delivery-obligations.d.ts.map +0 -1
  361. package/dist/delivery/parked-delivery-obligations.js +0 -390
  362. package/dist/delivery/parked-delivery-obligations.js.map +0 -1
  363. package/dist/server/environment-attachment.d.ts +0 -356
  364. package/dist/server/environment-attachment.d.ts.map +0 -1
  365. package/dist/server/environment-attachment.js +0 -2062
  366. package/dist/server/environment-attachment.js.map +0 -1
  367. package/dist/server/environment-delivery-records.d.ts +0 -77
  368. package/dist/server/environment-delivery-records.d.ts.map +0 -1
  369. package/dist/server/environment-delivery-records.js +0 -282
  370. package/dist/server/environment-delivery-records.js.map +0 -1
  371. package/dist/server/environment-delivery-worker.d.ts +0 -161
  372. package/dist/server/environment-delivery-worker.d.ts.map +0 -1
  373. package/dist/server/environment-delivery-worker.js +0 -973
  374. package/dist/server/environment-delivery-worker.js.map +0 -1
@@ -0,0 +1,46 @@
1
+ import { type MessageShape } from "@bufbuild/protobuf";
2
+ import { type MessageSchema } from "@spine-event-engine/core";
3
+ import { type MessageId, type Event } from "@spine-event-engine/proto";
4
+ import { type AgentOperationRef } from "@spine-event-engine/proto/agent";
5
+ import type { SignalMetadata } from "../runtime/signal-metadata.js";
6
+ import type { AgentLiveInvocation, AgentLiveModel, AgentOperationIdentity } from "./agent-live-inputs.js";
7
+ /**
8
+ * Validation and envelope construction for one live Agent operation.
9
+ */
10
+ interface LiveInteractionEvents {
11
+ /**
12
+ * Returns the original typed source without changing its payload URL.
13
+ *
14
+ * @param invocation Captured live Agent invocation.
15
+ * @returns The original typed Command or Event source reference.
16
+ */
17
+ sourceRef(invocation: AgentLiveInvocation): MessageId;
18
+ /**
19
+ * Creates a typed reference without a durable execution journal.
20
+ *
21
+ * @param invocation Captured live Agent invocation.
22
+ * @param operation Current AI operation identity.
23
+ * @param selected Models or selection retained for this invocation.
24
+ * @param stateSchema Generated Entity state schema.
25
+ * @returns The typed reference for this live AI operation.
26
+ */
27
+ operationRef(invocation: AgentLiveInvocation, operation: AgentOperationIdentity, stateSchema: MessageSchema, selected: AgentLiveModel): AgentOperationRef;
28
+ /**
29
+ * Creates one original System Event after validating its typed payload.
30
+ *
31
+ * @typeParam Schema Generated schema of the original System fact.
32
+ * @param agentId Typed Agent identifier.
33
+ * @param invocation Captured live Agent invocation.
34
+ * @param metadata Captured signal metadata.
35
+ * @param payload Typed serialized payload.
36
+ * @param schema Generated Protobuf schema for the payload.
37
+ * @returns The original System Event envelope for the validated payload.
38
+ */
39
+ envelope<Schema extends MessageSchema>(invocation: AgentLiveInvocation, metadata: SignalMetadata, agentId: AgentLiveInvocation["recipientId"], schema: Schema, payload: MessageShape<Schema>): Event;
40
+ }
41
+ /**
42
+ * Builds validated source and System-event facts without an execution journal.
43
+ */
44
+ export declare const AgentLiveInteractionEvents: LiveInteractionEvents;
45
+ export {};
46
+ //# sourceMappingURL=agent-live-interaction-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-live-interaction-events.d.ts","sourceRoot":"","sources":["../../src/agent/agent-live-interaction-events.ts"],"names":[],"mappings":"AAcA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvE,OAAO,EAAiC,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,KAAK,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,UAAU,qBAAqB;IAC7B;;;;;OAKG;IACH,SAAS,CAAC,UAAU,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAEtD;;;;;;;;OAQG;IACH,YAAY,CACV,UAAU,EAAE,mBAAmB,EAC/B,SAAS,EAAE,sBAAsB,EACjC,WAAW,EAAE,aAAa,EAC1B,QAAQ,EAAE,cAAc,GACvB,iBAAiB,CAAC;IAErB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,SAAS,aAAa,EACnC,UAAU,EAAE,mBAAmB,EAC/B,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,mBAAmB,CAAC,aAAa,CAAC,EAC3C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,GAC5B,KAAK,CAAC;CACV;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,qBAiGvC,CAAC"}
@@ -0,0 +1,104 @@
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 { create, equals } from "@bufbuild/protobuf";
15
+ import { AnySchema } from "@bufbuild/protobuf/wkt";
16
+ import { AnyPacker, TypeUrls, Validate } from "@spine-event-engine/core";
17
+ import { CommandIdSchema, EventIdSchema, EventSchema, MessageIdSchema, } from "@spine-event-engine/proto";
18
+ import { AgentOperationRefSchema, AiModelKind, ModelRefSchema, } from "@spine-event-engine/proto/agent";
19
+ /**
20
+ * Builds validated source and System-event facts without an execution journal.
21
+ */
22
+ export const AgentLiveInteractionEvents = Object.freeze({
23
+ /**
24
+ * Correlates one live AI call with the original typed source and selected model.
25
+ * @param invocation Original source, Agent ID, and state type.
26
+ * @param operation Required operation and conversation IDs.
27
+ * @param stateSchema Generated Agent state descriptor.
28
+ * @param selected Authorized model and connection.
29
+ * @returns Validated operation reference.
30
+ */
31
+ operationRef(invocation, operation, stateSchema, selected) {
32
+ if (invocation.stateType !== stateSchema.typeName)
33
+ throw new TypeError("Agent interaction state type does not match accepted work.");
34
+ if (!invocation.recipientId.typeUrl.trim())
35
+ throw new TypeError("Agent interaction requires typed Agent ID.");
36
+ if (!operation.operation.value.trim() || !operation.conversation.value.trim())
37
+ throw new TypeError("Agent interaction requires operation and conversation IDs.");
38
+ const kind = Reflect.get(selected, "kind");
39
+ if (kind !== AiModelKind.GENERATION && kind !== AiModelKind.DECISION)
40
+ throw new TypeError("Agent interaction requires a selected model and kind.");
41
+ Validate.check(ModelRefSchema, selected.model);
42
+ const sourceSignal = this.sourceRef(invocation);
43
+ return Validate.check(AgentOperationRefSchema, create(AgentOperationRefSchema, {
44
+ operation: operation.operation,
45
+ agent: create(MessageIdSchema, {
46
+ id: invocation.recipientId,
47
+ typeUrl: TypeUrls.derive(stateSchema),
48
+ }),
49
+ sourceSignal,
50
+ model: selected.model,
51
+ kind: selected.kind,
52
+ conversation: operation.conversation,
53
+ }));
54
+ },
55
+ /**
56
+ * Wraps one typed System payload with the original source and Agent producer.
57
+ * @typeParam Schema Generated System payload descriptor.
58
+ * @param invocation Original source and typed recipient.
59
+ * @param metadata Signal ID, Time, and causal context provider.
60
+ * @param agentId Typed producer Agent ID.
61
+ * @param schema Generated System payload descriptor.
62
+ * @param payload Typed System payload.
63
+ * @returns Validated original Event envelope.
64
+ */
65
+ envelope(invocation, metadata, agentId, schema, payload) {
66
+ if (!agentId.typeUrl.trim() || !equals(AnySchema, invocation.recipientId, agentId))
67
+ throw new TypeError("Agent interaction producer differs from accepted recipient.");
68
+ this.sourceRef(invocation);
69
+ Validate.check(schema, payload);
70
+ const source = invocation.source;
71
+ const origin = source.case === "command"
72
+ ? metadata.eventFromCommand(source.value, {})
73
+ : metadata.eventFromEvent(source.value, {});
74
+ origin.context.producerId = agentId;
75
+ return Validate.check(EventSchema, create(EventSchema, {
76
+ id: origin.id,
77
+ context: origin.context,
78
+ message: AnyPacker.pack(schema, payload),
79
+ }));
80
+ },
81
+ /**
82
+ * Requires a typed source ID and preserves its concrete payload URL.
83
+ */
84
+ sourceRef(invocation) {
85
+ const source = invocation.source;
86
+ if (source.case === "command") {
87
+ const id = source.value.id;
88
+ if (!id?.uuid.trim())
89
+ throw new TypeError("Agent interaction requires source Command ID.");
90
+ const typeUrl = source.value.message?.typeUrl;
91
+ if (!typeUrl?.trim())
92
+ throw new TypeError("Agent interaction requires source payload type.");
93
+ return create(MessageIdSchema, { id: AnyPacker.pack(CommandIdSchema, id), typeUrl });
94
+ }
95
+ const id = source.value.id;
96
+ if (!id?.value.trim())
97
+ throw new TypeError("Agent interaction requires source Event ID.");
98
+ const typeUrl = source.value.message?.typeUrl;
99
+ if (!typeUrl?.trim())
100
+ throw new TypeError("Agent interaction requires source payload type.");
101
+ return create(MessageIdSchema, { id: AnyPacker.pack(EventIdSchema, id), typeUrl });
102
+ },
103
+ });
104
+ //# sourceMappingURL=agent-live-interaction-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-live-interaction-events.js","sourceRoot":"","sources":["../../src/agent/agent-live-interaction-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAqB,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAsB,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EACL,eAAe,EACf,aAAa,EACb,WAAW,EACX,eAAe,GAGhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,EACvB,WAAW,EACX,cAAc,GAEf,MAAM,iCAAiC,CAAC;AAwDzC;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAA0B,MAAM,CAAC,MAAM,CAAC;IAC7E;;;;;;;OAOG;IACH,YAAY,CACV,UAA+B,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+C,CAAC,CAAC;YAC3F,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC;YAC9C,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE;gBAAE,MAAM,IAAI,SAAS,CAAC,iDAAiD,CAAC,CAAC;YAC7F,OAAO,MAAM,CAAC,eAAe,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QACvF,CAAC;QACD,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE;YAAE,MAAM,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;QAC1F,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC;QAC9C,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE;YAAE,MAAM,IAAI,SAAS,CAAC,iDAAiD,CAAC,CAAC;QAC7F,OAAO,MAAM,CAAC,eAAe,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IACrF,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,129 @@
1
+ import type { AiFailure, AiRegistry, AiScope } from "@spine-event-engine/ai";
2
+ import type { AiBackendDefinition, AiMcpMessageRequest, AiMcpMessageTicket, AiToolInvocation } from "@spine-event-engine/ai/spi/adapter";
3
+ import { type AgentHistoryEntry, type ToolRequest, type ToolResponse } from "@spine-event-engine/proto/agent";
4
+ import type { AgentLiveAiAudit } from "./agent-live-ai-audit.js";
5
+ import { AgentLiveBudget } from "./agent-live-budget.js";
6
+ import type { AgentLiveMcpHost } from "./agent-live-mcp-host.js";
7
+ import type { AgentOperationIdentity } from "./agent-live-inputs.js";
8
+ /**
9
+ * Invocation-local MCP admissions and measured physical credit.
10
+ */
11
+ export declare class AgentLiveMcpControls implements AgentLiveMcpHost {
12
+ #private;
13
+ private readonly input;
14
+ /**
15
+ * Binds one selected catalog to its live invocation budget and audit.
16
+ *
17
+ * @param input Typed input for this operation.
18
+ */
19
+ constructor(input: {
20
+ scope: AiScope;
21
+ registry: AiRegistry;
22
+ backend: AiBackendDefinition;
23
+ operation: AgentOperationIdentity;
24
+ signal: AbortSignal;
25
+ deadlineEpochMs?: number;
26
+ budget: AgentLiveBudget;
27
+ audit: AgentLiveAiAudit;
28
+ maxToolCalls?: number;
29
+ onProposal: (invocation: AiToolInvocation) => void;
30
+ });
31
+ /**
32
+ * Returns the selected AI scope.
33
+ *
34
+ * @returns The selected AI scope for this invocation.*/ get scope(): AiScope;
35
+ /**
36
+ * Returns the registered backends and MCP catalog.
37
+ *
38
+ * @returns The configured backend and MCP registry.*/ get registry(): AiRegistry;
39
+ /**
40
+ * Returns the selected backend definition.
41
+ *
42
+ * @returns The selected backend definition.*/ get backend(): AiBackendDefinition;
43
+ /**
44
+ * Returns the current operation identity.
45
+ *
46
+ * @returns The current typed AI operation identity.*/ get operation(): AgentOperationIdentity;
47
+ /**
48
+ * Returns the fenced invocation signal.
49
+ *
50
+ * @returns The cancellation signal for this invocation.*/ get signal(): AbortSignal;
51
+ /**
52
+ * Returns the absolute invocation deadline.
53
+ *
54
+ * @returns The absolute deadline, when configured.*/ get deadlineEpochMs(): number | undefined;
55
+ /**
56
+ * Acquires complete protocol response credit before a physical send.
57
+ *
58
+ * @param request Typed request for the current operation.
59
+ * @param server Configured MCP server registration.
60
+ * @returns A physical protocol ticket with complete response credit.
61
+ */
62
+ reserveMessage(server: string, request: AiMcpMessageRequest): Promise<AiMcpMessageTicket>;
63
+ /**
64
+ * Performs synchronous admission before returning a protocol ticket.
65
+ *
66
+ * @param request Typed request for the current operation.
67
+ * @param server Configured MCP server registration.
68
+ * @returns The admitted protocol ticket before asynchronous work begins.
69
+ */
70
+ private reservePhysicalMessage;
71
+ /**
72
+ * Checks decoded chunks against the reserved physical response credit.
73
+ *
74
+ * @param bytes Measured serialized byte count.
75
+ * @param ticketId Reserved physical attempt identifier.
76
+ */
77
+ onReceived(ticketId: string, bytes: number): void;
78
+ /**
79
+ * Completes a known receipt; unknown outcomes retain full reserved credit.
80
+ *
81
+ * @param receivedBytes Measured received payload bytes.
82
+ * @param ticketId Reserved physical attempt identifier.
83
+ * @returns Completion after a known protocol receipt is accounted for.
84
+ */
85
+ finishMessage(ticketId: string, receivedBytes?: number): Promise<void>;
86
+ /**
87
+ * Admits a model-proposed call before asynchronous audit or dispatch.
88
+ *
89
+ * @param facts Complete audit facts for the operation.
90
+ * @param invocation Captured live Agent invocation.
91
+ * @returns The unique live call identifier for an authorized tool.
92
+ */
93
+ admitTool(invocation: AiToolInvocation, facts: Pick<ToolRequest, "server" | "tool" | "argumentsJson" | "effect">): Promise<string>;
94
+ /**
95
+ * Marks the exact pre-send boundary once.
96
+ *
97
+ * @param callId Exact MCP tool call identifier.
98
+ */
99
+ markToolDispatched(callId: string): void;
100
+ /**
101
+ * Writes a completed tool result and conversation before continuation.
102
+ *
103
+ * @param callId Exact MCP tool call identifier.
104
+ * @param history Retained history entries or history port.
105
+ * @param response Typed response from the provider.
106
+ * @returns Completion after the tool result and conversation are saved.
107
+ */
108
+ finishTool(callId: string, response: ToolResponse, history: AgentHistoryEntry): Promise<void>;
109
+ /**
110
+ * Returns a safe invocation-local diagnostic reference.
111
+ *
112
+ * @param code Recorded failure code.
113
+ * @param retryableByNewSignal Whether a fresh signal may retry this failure.
114
+ * @returns A safe local diagnostic reference for the failed operation.
115
+ */
116
+ recordFailure(code: AiFailure["code"], retryableByNewSignal: boolean): Promise<AiFailure>;
117
+ /**
118
+ * Returns the active physical reservation or rejects a stale ticket.
119
+ *
120
+ * @param id Typed identifier of the requested item.
121
+ * @returns The active physical ticket for the requested message ID.
122
+ */
123
+ private message;
124
+ /**
125
+ * Rejects callbacks after handler cancellation.
126
+ */
127
+ private requireActive;
128
+ }
129
+ //# sourceMappingURL=agent-live-mcp-controls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-live-mcp-controls.d.ts","sourceRoot":"","sources":["../../src/agent/agent-live-mcp-controls.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAQrE;;GAEG;AACH,qBAAa,oBAAqB,YAAW,gBAAgB;;IAezD,OAAO,CAAC,QAAQ,CAAC,KAAK;IANxB;;;;OAIG;gBAEgB,KAAK,EAAE;QACtB,KAAK,EAAE,OAAO,CAAC;QACf,QAAQ,EAAE,UAAU,CAAC;QACrB,OAAO,EAAE,mBAAmB,CAAC;QAC7B,SAAS,EAAE,sBAAsB,CAAC;QAClC,MAAM,EAAE,WAAW,CAAC;QACpB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,MAAM,EAAE,eAAe,CAAC;QACxB,KAAK,EAAE,gBAAgB,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,CAAC,UAAU,EAAE,gBAAgB,KAAK,IAAI,CAAC;KACpD;IAGH;;;4DAGwD,CAAC,IAAI,KAAK,IAAI,OAAO,CAE5E;IAED;;;0DAGsD,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 +1,228 @@
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 { randomUUID } from "node:crypto";
15
+ import { create } from "@bufbuild/protobuf";
16
+ import { AiToolCallIdSchema as ToolCallIdSchema, ToolRequestSchema, } from "@spine-event-engine/proto/agent";
17
+ import { Validate } from "@spine-event-engine/core";
18
+ import { AgentLiveBudget } from "./agent-live-budget.js";
19
+ /**
20
+ * Invocation-local MCP admissions and measured physical credit.
21
+ */
22
+ export class AgentLiveMcpControls {
23
+ input;
24
+ #messages = new Map();
25
+ #tools = new Map();
26
+ #proposals = new Set();
27
+ #toolCount = 0;
28
+ /**
29
+ * Binds one selected catalog to its live invocation budget and audit.
30
+ *
31
+ * @param input Typed input for this operation.
32
+ */
33
+ constructor(input) {
34
+ this.input = input;
35
+ }
36
+ /**
37
+ * Returns the selected AI scope.
38
+ *
39
+ * @returns The selected AI scope for this invocation.*/ get scope() {
40
+ return this.input.scope;
41
+ }
42
+ /**
43
+ * Returns the registered backends and MCP catalog.
44
+ *
45
+ * @returns The configured backend and MCP registry.*/ get registry() {
46
+ return this.input.registry;
47
+ }
48
+ /**
49
+ * Returns the selected backend definition.
50
+ *
51
+ * @returns The selected backend definition.*/ get backend() {
52
+ return this.input.backend;
53
+ }
54
+ /**
55
+ * Returns the current operation identity.
56
+ *
57
+ * @returns The current typed AI operation identity.*/ get operation() {
58
+ return this.input.operation;
59
+ }
60
+ /**
61
+ * Returns the fenced invocation signal.
62
+ *
63
+ * @returns The cancellation signal for this invocation.*/ get signal() {
64
+ return this.input.signal;
65
+ }
66
+ /**
67
+ * Returns the absolute invocation deadline.
68
+ *
69
+ * @returns The absolute deadline, when configured.*/ get deadlineEpochMs() {
70
+ return this.input.deadlineEpochMs;
71
+ }
72
+ /**
73
+ * Acquires complete protocol response credit before a physical send.
74
+ *
75
+ * @param request Typed request for the current operation.
76
+ * @param server Configured MCP server registration.
77
+ * @returns A physical protocol ticket with complete response credit.
78
+ */
79
+ reserveMessage(server, request) {
80
+ try {
81
+ return Promise.resolve(this.reservePhysicalMessage(server, request));
82
+ }
83
+ catch (error) {
84
+ return Promise.reject(error instanceof Error ? error : new Error("MCP admission failed", { cause: error }));
85
+ }
86
+ }
87
+ /**
88
+ * Performs synchronous admission before returning a protocol ticket.
89
+ *
90
+ * @param request Typed request for the current operation.
91
+ * @param server Configured MCP server registration.
92
+ * @returns The admitted protocol ticket before asynchronous work begins.
93
+ */
94
+ reservePhysicalMessage(server, request) {
95
+ this.requireActive();
96
+ if (!server.trim() || !request.method.trim())
97
+ throw new TypeError("MCP message identity is empty.");
98
+ if (request.phase === "call" && !this.#tools.get(request.toolCallId ?? "")?.dispatched)
99
+ throw new Error("MCP tool has not been dispatched.");
100
+ const reservation = this.input.budget.reservePhysical(request.inputBytes, request.maxOutputBytes, "protocol");
101
+ const id = randomUUID();
102
+ this.#messages.set(id, reservation);
103
+ return {
104
+ id,
105
+ signal: this.signal,
106
+ ...(this.deadlineEpochMs === undefined ? {} : { deadlineEpochMs: this.deadlineEpochMs }),
107
+ ...(reservation.maxOutputBytes === undefined
108
+ ? {}
109
+ : { maxOutputBytes: reservation.maxOutputBytes }),
110
+ };
111
+ }
112
+ /**
113
+ * Checks decoded chunks against the reserved physical response credit.
114
+ *
115
+ * @param bytes Measured serialized byte count.
116
+ * @param ticketId Reserved physical attempt identifier.
117
+ */
118
+ onReceived(ticketId, bytes) {
119
+ this.input.budget.onReceived(this.message(ticketId), bytes);
120
+ }
121
+ /**
122
+ * Completes a known receipt; unknown outcomes retain full reserved credit.
123
+ *
124
+ * @param receivedBytes Measured received payload bytes.
125
+ * @param ticketId Reserved physical attempt identifier.
126
+ * @returns Completion after a known protocol receipt is accounted for.
127
+ */
128
+ finishMessage(ticketId, receivedBytes) {
129
+ try {
130
+ const ticket = this.message(ticketId);
131
+ if (receivedBytes !== undefined)
132
+ this.input.budget.settlePhysical(ticket, receivedBytes);
133
+ this.#messages.delete(ticketId);
134
+ return Promise.resolve();
135
+ }
136
+ catch (error) {
137
+ return Promise.reject(error instanceof Error ? error : new Error("MCP receipt failed", { cause: error }));
138
+ }
139
+ }
140
+ /**
141
+ * Admits a model-proposed call before asynchronous audit or dispatch.
142
+ *
143
+ * @param facts Complete audit facts for the operation.
144
+ * @param invocation Captured live Agent invocation.
145
+ * @returns The unique live call identifier for an authorized tool.
146
+ */
147
+ async admitTool(invocation, facts) {
148
+ this.requireActive();
149
+ this.input.onProposal(invocation);
150
+ const proposal = `${invocation.ticketId}\u0000${invocation.providerCallId}`;
151
+ if (this.#proposals.has(proposal))
152
+ throw new Error("MCP model proposal was already admitted.");
153
+ if (this.input.maxToolCalls !== undefined && this.#toolCount >= this.input.maxToolCalls)
154
+ throw new Error("Agent tool call budget is exhausted.");
155
+ this.input.budget.reserveToolCall();
156
+ this.#toolCount++;
157
+ this.#proposals.add(proposal);
158
+ const id = randomUUID();
159
+ this.#tools.set(id, { proposal, dispatched: false, finished: false });
160
+ const request = create(ToolRequestSchema, {
161
+ ...facts,
162
+ call: create(ToolCallIdSchema, { value: id }),
163
+ });
164
+ Validate.check(ToolRequestSchema, request);
165
+ await this.input.audit.toolStarted(invocation, request);
166
+ return id;
167
+ }
168
+ /**
169
+ * Marks the exact pre-send boundary once.
170
+ *
171
+ * @param callId Exact MCP tool call identifier.
172
+ */
173
+ markToolDispatched(callId) {
174
+ const claim = this.#tools.get(callId);
175
+ if (claim === undefined || claim.dispatched)
176
+ throw new Error("MCP tool is missing or already dispatched.");
177
+ this.requireActive();
178
+ claim.dispatched = true;
179
+ }
180
+ /**
181
+ * Writes a completed tool result and conversation before continuation.
182
+ *
183
+ * @param callId Exact MCP tool call identifier.
184
+ * @param history Retained history entries or history port.
185
+ * @param response Typed response from the provider.
186
+ * @returns Completion after the tool result and conversation are saved.
187
+ */
188
+ async finishTool(callId, response, history) {
189
+ const claim = this.#tools.get(callId);
190
+ if (claim === undefined ||
191
+ !claim.dispatched ||
192
+ claim.finished ||
193
+ response.call?.value !== callId)
194
+ throw new Error("MCP tool completion does not match its dispatch.");
195
+ await this.input.audit.toolFinished(response, history);
196
+ claim.finished = true;
197
+ }
198
+ /**
199
+ * Returns a safe invocation-local diagnostic reference.
200
+ *
201
+ * @param code Recorded failure code.
202
+ * @param retryableByNewSignal Whether a fresh signal may retry this failure.
203
+ * @returns A safe local diagnostic reference for the failed operation.
204
+ */
205
+ recordFailure(code, retryableByNewSignal) {
206
+ return Promise.resolve({ code, retryableByNewSignal, diagnosticId: randomUUID() });
207
+ }
208
+ /**
209
+ * Returns the active physical reservation or rejects a stale ticket.
210
+ *
211
+ * @param id Typed identifier of the requested item.
212
+ * @returns The active physical ticket for the requested message ID.
213
+ */
214
+ message(id) {
215
+ const ticket = this.#messages.get(id);
216
+ if (ticket === undefined)
217
+ throw new Error("MCP physical ticket is no longer active.");
218
+ return ticket;
219
+ }
220
+ /**
221
+ * Rejects callbacks after handler cancellation.
222
+ */
223
+ requireActive() {
224
+ if (this.signal.aborted)
225
+ throw new Error("MCP invocation is closed.");
226
+ }
227
+ }
228
+ //# sourceMappingURL=agent-live-mcp-controls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-live-mcp-controls.js","sourceRoot":"","sources":["../../src/agent/agent-live-mcp-controls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAQ5C,OAAO,EACL,kBAAkB,IAAI,gBAAgB,EACtC,i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AK,KAAK,SAAS;YACnB,CAAC,KAAK,CAAC,UAAU;YACjB,KAAK,CAAC,QAAQ;YACd,QAAQ,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM;YAE/B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtE,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACvD,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CAAC,IAAuB,EAAE,oBAA6B;QAClE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;IACrF,CAAC;IAED;;;;;OAKG;IACK,OAAO,CAAC,EAAU;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACtC,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QACtF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACK,aAAa;QACnB,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACxE,CAAC;CACF"}
@@ -0,0 +1,88 @@
1
+ import type { AiFailure, AiRegistry, AiScope } from "@spine-event-engine/ai";
2
+ import type { AiBackendDefinition, AiMcpMessageRequest, AiMcpMessageTicket, AiToolInvocation } from "@spine-event-engine/ai/spi/adapter";
3
+ import type { AgentHistoryEntry, ToolRequest, ToolResponse } from "@spine-event-engine/proto/agent";
4
+ import type { AgentOperationIdentity } from "./agent-live-inputs.js";
5
+ /**
6
+ * Invocation-local controls used by one selected MCP catalog.
7
+ */
8
+ export interface AgentLiveMcpHost {
9
+ /**
10
+ * Selected AI scope for this invocation.
11
+ */
12
+ readonly scope: AiScope;
13
+ /**
14
+ * Registered backend and MCP catalog.
15
+ */
16
+ readonly registry: AiRegistry;
17
+ /**
18
+ * Selected backend definition.
19
+ */
20
+ readonly backend: AiBackendDefinition;
21
+ /**
22
+ * Current typed AI operation identity.
23
+ */
24
+ readonly operation: AgentOperationIdentity;
25
+ /**
26
+ * Cancellation fence for the invocation.
27
+ */
28
+ readonly signal: AbortSignal;
29
+ /**
30
+ * Absolute invocation deadline, when configured.
31
+ */
32
+ readonly deadlineEpochMs: number | undefined;
33
+ /**
34
+ * Acquires complete physical request and response credit before an MCP send.
35
+ *
36
+ * @param request Typed request for the current operation.
37
+ * @param server Configured MCP server registration.
38
+ * @returns A physical protocol ticket with complete response credit.
39
+ */
40
+ reserveMessage(server: string, request: AiMcpMessageRequest): Promise<AiMcpMessageTicket>;
41
+ /**
42
+ * Checks decoded chunks against their already reserved ticket.
43
+ *
44
+ * @param bytes Measured serialized byte count.
45
+ * @param ticketId Reserved physical attempt identifier.
46
+ */
47
+ onReceived(ticketId: string, bytes: number): void;
48
+ /**
49
+ * Completes a known receipt, retaining full credit for unknown outcomes.
50
+ *
51
+ * @param receivedBytes Measured received payload bytes.
52
+ * @param ticketId Reserved physical attempt identifier.
53
+ * @returns Completion after a known protocol receipt is accounted for.
54
+ */
55
+ finishMessage(ticketId: string, receivedBytes?: number): Promise<void>;
56
+ /**
57
+ * Admits one vetted model-proposed tool and returns its unique live call ID.
58
+ *
59
+ * @param invocation Captured live Agent invocation.
60
+ * @param request Typed request for the current operation.
61
+ * @returns The unique live call identifier for an authorized tool.
62
+ */
63
+ admitTool(invocation: AiToolInvocation, request: Pick<ToolRequest, "server" | "tool" | "argumentsJson" | "effect">): Promise<string>;
64
+ /**
65
+ * Marks the pre-send boundary so the same write cannot be dispatched twice.
66
+ *
67
+ * @param callId Exact MCP tool call identifier.
68
+ */
69
+ markToolDispatched(callId: string): void;
70
+ /**
71
+ * Writes the result and original conversation row before model continuation.
72
+ *
73
+ * @param callId Exact MCP tool call identifier.
74
+ * @param history Retained history entries or history port.
75
+ * @param response Typed response from the provider.
76
+ * @returns Completion after the tool result and conversation are saved.
77
+ */
78
+ finishTool(callId: string, response: ToolResponse, history: AgentHistoryEntry): Promise<void>;
79
+ /**
80
+ * Creates a safe local diagnostic for a failed tool or protocol operation.
81
+ *
82
+ * @param code Recorded failure code.
83
+ * @param retryableByNewSignal Whether a fresh signal may retry this failure.
84
+ * @returns A safe local diagnostic reference for the failed operation.
85
+ */
86
+ recordFailure(code: AiFailure["code"], retryableByNewSignal: boolean): Promise<AiFailure>;
87
+ }
88
+ //# sourceMappingURL=agent-live-mcp-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-live-mcp-host.d.ts","sourceRoot":"","sources":["../../src/agent/agent-live-mcp-host.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7C;;;;;;OAMG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAE1F;;;;;OAKG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAElD;;;;;;OAMG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvE;;;;;;OAMG;IACH,SAAS,CACP,UAAU,EAAE,gBAAgB,EAC5B,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,MAAM,GAAG,eAAe,GAAG,QAAQ,CAAC,GACzE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;;OAIG;IACH,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC;;;;;;;OAOG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9F;;;;;;OAMG;IACH,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,oBAAoB,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CAC3F"}
@@ -12,4 +12,4 @@
12
12
  * the License.
13
13
  */
14
14
  export {};
15
- //# sourceMappingURL=agent-mcp-host.js.map
15
+ //# sourceMappingURL=agent-live-mcp-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-live-mcp-host.js","sourceRoot":"","sources":["../../src/agent/agent-live-mcp-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}