@methodts/runtime 0.1.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.
Files changed (537) hide show
  1. package/dist/__fixtures__/executor-fixtures.d.ts +10 -0
  2. package/dist/__fixtures__/executor-fixtures.d.ts.map +1 -0
  3. package/dist/__fixtures__/executor-fixtures.js +36 -0
  4. package/dist/__fixtures__/executor-fixtures.js.map +1 -0
  5. package/dist/architecture.test.d.ts +2 -0
  6. package/dist/architecture.test.d.ts.map +1 -0
  7. package/dist/architecture.test.js +143 -0
  8. package/dist/architecture.test.js.map +1 -0
  9. package/dist/config/cost-governor-config.d.ts +40 -0
  10. package/dist/config/cost-governor-config.d.ts.map +1 -0
  11. package/dist/config/cost-governor-config.js +48 -0
  12. package/dist/config/cost-governor-config.js.map +1 -0
  13. package/dist/config/index.d.ts +7 -0
  14. package/dist/config/index.d.ts.map +1 -0
  15. package/dist/config/index.js +6 -0
  16. package/dist/config/index.js.map +1 -0
  17. package/dist/config/sessions-config.d.ts +29 -0
  18. package/dist/config/sessions-config.d.ts.map +1 -0
  19. package/dist/config/sessions-config.js +37 -0
  20. package/dist/config/sessions-config.js.map +1 -0
  21. package/dist/config/strategies-config.d.ts +38 -0
  22. package/dist/config/strategies-config.d.ts.map +1 -0
  23. package/dist/config/strategies-config.js +41 -0
  24. package/dist/config/strategies-config.js.map +1 -0
  25. package/dist/cost-governor/backpressure-queue.d.ts +20 -0
  26. package/dist/cost-governor/backpressure-queue.d.ts.map +1 -0
  27. package/dist/cost-governor/backpressure-queue.js +78 -0
  28. package/dist/cost-governor/backpressure-queue.js.map +1 -0
  29. package/dist/cost-governor/backpressure-queue.test.d.ts +2 -0
  30. package/dist/cost-governor/backpressure-queue.test.d.ts.map +1 -0
  31. package/dist/cost-governor/backpressure-queue.test.js +48 -0
  32. package/dist/cost-governor/backpressure-queue.test.js.map +1 -0
  33. package/dist/cost-governor/cost-events.d.ts +65 -0
  34. package/dist/cost-governor/cost-events.d.ts.map +1 -0
  35. package/dist/cost-governor/cost-events.js +48 -0
  36. package/dist/cost-governor/cost-events.js.map +1 -0
  37. package/dist/cost-governor/cost-governor-app-id.test.d.ts +19 -0
  38. package/dist/cost-governor/cost-governor-app-id.test.d.ts.map +1 -0
  39. package/dist/cost-governor/cost-governor-app-id.test.js +201 -0
  40. package/dist/cost-governor/cost-governor-app-id.test.js.map +1 -0
  41. package/dist/cost-governor/cost-oracle-impl.d.ts +19 -0
  42. package/dist/cost-governor/cost-oracle-impl.d.ts.map +1 -0
  43. package/dist/cost-governor/cost-oracle-impl.js +52 -0
  44. package/dist/cost-governor/cost-oracle-impl.js.map +1 -0
  45. package/dist/cost-governor/estimator.d.ts +22 -0
  46. package/dist/cost-governor/estimator.d.ts.map +1 -0
  47. package/dist/cost-governor/estimator.js +119 -0
  48. package/dist/cost-governor/estimator.js.map +1 -0
  49. package/dist/cost-governor/estimator.test.d.ts +2 -0
  50. package/dist/cost-governor/estimator.test.d.ts.map +1 -0
  51. package/dist/cost-governor/estimator.test.js +141 -0
  52. package/dist/cost-governor/estimator.test.js.map +1 -0
  53. package/dist/cost-governor/index.d.ts +75 -0
  54. package/dist/cost-governor/index.d.ts.map +1 -0
  55. package/dist/cost-governor/index.js +120 -0
  56. package/dist/cost-governor/index.js.map +1 -0
  57. package/dist/cost-governor/observations-store.d.ts +49 -0
  58. package/dist/cost-governor/observations-store.d.ts.map +1 -0
  59. package/dist/cost-governor/observations-store.js +179 -0
  60. package/dist/cost-governor/observations-store.js.map +1 -0
  61. package/dist/cost-governor/observations-store.test.d.ts +2 -0
  62. package/dist/cost-governor/observations-store.test.d.ts.map +1 -0
  63. package/dist/cost-governor/observations-store.test.js +191 -0
  64. package/dist/cost-governor/observations-store.test.js.map +1 -0
  65. package/dist/cost-governor/percentile.d.ts +17 -0
  66. package/dist/cost-governor/percentile.d.ts.map +1 -0
  67. package/dist/cost-governor/percentile.js +33 -0
  68. package/dist/cost-governor/percentile.js.map +1 -0
  69. package/dist/cost-governor/percentile.test.d.ts +2 -0
  70. package/dist/cost-governor/percentile.test.d.ts.map +1 -0
  71. package/dist/cost-governor/percentile.test.js +46 -0
  72. package/dist/cost-governor/percentile.test.js.map +1 -0
  73. package/dist/cost-governor/rate-governor-impl.d.ts +73 -0
  74. package/dist/cost-governor/rate-governor-impl.d.ts.map +1 -0
  75. package/dist/cost-governor/rate-governor-impl.js +148 -0
  76. package/dist/cost-governor/rate-governor-impl.js.map +1 -0
  77. package/dist/cost-governor/signature-builder.d.ts +22 -0
  78. package/dist/cost-governor/signature-builder.d.ts.map +1 -0
  79. package/dist/cost-governor/signature-builder.js +43 -0
  80. package/dist/cost-governor/signature-builder.js.map +1 -0
  81. package/dist/cost-governor/signature-builder.test.d.ts +2 -0
  82. package/dist/cost-governor/signature-builder.test.d.ts.map +1 -0
  83. package/dist/cost-governor/signature-builder.test.js +58 -0
  84. package/dist/cost-governor/signature-builder.test.js.map +1 -0
  85. package/dist/cost-governor/token-bucket.d.ts +57 -0
  86. package/dist/cost-governor/token-bucket.d.ts.map +1 -0
  87. package/dist/cost-governor/token-bucket.js +109 -0
  88. package/dist/cost-governor/token-bucket.js.map +1 -0
  89. package/dist/cost-governor/token-bucket.test.d.ts +2 -0
  90. package/dist/cost-governor/token-bucket.test.d.ts.map +1 -0
  91. package/dist/cost-governor/token-bucket.test.js +67 -0
  92. package/dist/cost-governor/token-bucket.test.js.map +1 -0
  93. package/dist/dlq/cortex-dlq-observer.d.ts +22 -0
  94. package/dist/dlq/cortex-dlq-observer.d.ts.map +1 -0
  95. package/dist/dlq/cortex-dlq-observer.js +29 -0
  96. package/dist/dlq/cortex-dlq-observer.js.map +1 -0
  97. package/dist/dlq/dlq-observer.test.d.ts +8 -0
  98. package/dist/dlq/dlq-observer.test.d.ts.map +1 -0
  99. package/dist/dlq/dlq-observer.test.js +103 -0
  100. package/dist/dlq/dlq-observer.test.js.map +1 -0
  101. package/dist/dlq/index.d.ts +6 -0
  102. package/dist/dlq/index.d.ts.map +1 -0
  103. package/dist/dlq/index.js +6 -0
  104. package/dist/dlq/index.js.map +1 -0
  105. package/dist/event-bus/adapters.d.ts +50 -0
  106. package/dist/event-bus/adapters.d.ts.map +1 -0
  107. package/dist/event-bus/adapters.js +51 -0
  108. package/dist/event-bus/adapters.js.map +1 -0
  109. package/dist/event-bus/adapters.test.d.ts +5 -0
  110. package/dist/event-bus/adapters.test.d.ts.map +1 -0
  111. package/dist/event-bus/adapters.test.js +73 -0
  112. package/dist/event-bus/adapters.test.js.map +1 -0
  113. package/dist/event-bus/agent-event-adapter.d.ts +22 -0
  114. package/dist/event-bus/agent-event-adapter.d.ts.map +1 -0
  115. package/dist/event-bus/agent-event-adapter.js +49 -0
  116. package/dist/event-bus/agent-event-adapter.js.map +1 -0
  117. package/dist/event-bus/agent-event-adapter.test.d.ts +5 -0
  118. package/dist/event-bus/agent-event-adapter.test.d.ts.map +1 -0
  119. package/dist/event-bus/agent-event-adapter.test.js +170 -0
  120. package/dist/event-bus/agent-event-adapter.test.js.map +1 -0
  121. package/dist/event-bus/channel-sink.d.ts +71 -0
  122. package/dist/event-bus/channel-sink.d.ts.map +1 -0
  123. package/dist/event-bus/channel-sink.js +159 -0
  124. package/dist/event-bus/channel-sink.js.map +1 -0
  125. package/dist/event-bus/channel-sink.test.d.ts +5 -0
  126. package/dist/event-bus/channel-sink.test.d.ts.map +1 -0
  127. package/dist/event-bus/channel-sink.test.js +234 -0
  128. package/dist/event-bus/channel-sink.test.js.map +1 -0
  129. package/dist/event-bus/event-types.snapshot.test.d.ts +27 -0
  130. package/dist/event-bus/event-types.snapshot.test.d.ts.map +1 -0
  131. package/dist/event-bus/event-types.snapshot.test.js +165 -0
  132. package/dist/event-bus/event-types.snapshot.test.js.map +1 -0
  133. package/dist/event-bus/genesis-sink.d.ts +55 -0
  134. package/dist/event-bus/genesis-sink.d.ts.map +1 -0
  135. package/dist/event-bus/genesis-sink.js +141 -0
  136. package/dist/event-bus/genesis-sink.js.map +1 -0
  137. package/dist/event-bus/genesis-sink.test.d.ts +5 -0
  138. package/dist/event-bus/genesis-sink.test.d.ts.map +1 -0
  139. package/dist/event-bus/genesis-sink.test.js +160 -0
  140. package/dist/event-bus/genesis-sink.test.js.map +1 -0
  141. package/dist/event-bus/in-memory-event-bus.d.ts +60 -0
  142. package/dist/event-bus/in-memory-event-bus.d.ts.map +1 -0
  143. package/dist/event-bus/in-memory-event-bus.js +274 -0
  144. package/dist/event-bus/in-memory-event-bus.js.map +1 -0
  145. package/dist/event-bus/in-memory-event-bus.test.d.ts +5 -0
  146. package/dist/event-bus/in-memory-event-bus.test.d.ts.map +1 -0
  147. package/dist/event-bus/in-memory-event-bus.test.js +457 -0
  148. package/dist/event-bus/in-memory-event-bus.test.js.map +1 -0
  149. package/dist/event-bus/index.d.ts +22 -0
  150. package/dist/event-bus/index.d.ts.map +1 -0
  151. package/dist/event-bus/index.js +17 -0
  152. package/dist/event-bus/index.js.map +1 -0
  153. package/dist/event-bus/persistence-sink.d.ts +74 -0
  154. package/dist/event-bus/persistence-sink.d.ts.map +1 -0
  155. package/dist/event-bus/persistence-sink.js +193 -0
  156. package/dist/event-bus/persistence-sink.js.map +1 -0
  157. package/dist/event-bus/persistence-sink.test.d.ts +6 -0
  158. package/dist/event-bus/persistence-sink.test.d.ts.map +1 -0
  159. package/dist/event-bus/persistence-sink.test.js +319 -0
  160. package/dist/event-bus/persistence-sink.test.js.map +1 -0
  161. package/dist/event-bus/session-checkpoint-sink.d.ts +91 -0
  162. package/dist/event-bus/session-checkpoint-sink.d.ts.map +1 -0
  163. package/dist/event-bus/session-checkpoint-sink.js +107 -0
  164. package/dist/event-bus/session-checkpoint-sink.js.map +1 -0
  165. package/dist/event-bus/session-checkpoint-sink.test.d.ts +5 -0
  166. package/dist/event-bus/session-checkpoint-sink.test.d.ts.map +1 -0
  167. package/dist/event-bus/session-checkpoint-sink.test.js +215 -0
  168. package/dist/event-bus/session-checkpoint-sink.test.js.map +1 -0
  169. package/dist/event-bus/webhook-connector.d.ts +59 -0
  170. package/dist/event-bus/webhook-connector.d.ts.map +1 -0
  171. package/dist/event-bus/webhook-connector.js +191 -0
  172. package/dist/event-bus/webhook-connector.js.map +1 -0
  173. package/dist/event-bus/webhook-connector.test.d.ts +5 -0
  174. package/dist/event-bus/webhook-connector.test.d.ts.map +1 -0
  175. package/dist/event-bus/webhook-connector.test.js +214 -0
  176. package/dist/event-bus/webhook-connector.test.js.map +1 -0
  177. package/dist/executors/cortex-job-backed-executor.d.ts +137 -0
  178. package/dist/executors/cortex-job-backed-executor.d.ts.map +1 -0
  179. package/dist/executors/cortex-job-backed-executor.js +441 -0
  180. package/dist/executors/cortex-job-backed-executor.js.map +1 -0
  181. package/dist/executors/cortex-job-backed-executor.test.d.ts +13 -0
  182. package/dist/executors/cortex-job-backed-executor.test.d.ts.map +1 -0
  183. package/dist/executors/cortex-job-backed-executor.test.js +303 -0
  184. package/dist/executors/cortex-job-backed-executor.test.js.map +1 -0
  185. package/dist/executors/index.d.ts +9 -0
  186. package/dist/executors/index.d.ts.map +1 -0
  187. package/dist/executors/index.js +9 -0
  188. package/dist/executors/index.js.map +1 -0
  189. package/dist/index.d.ts +2 -0
  190. package/dist/index.d.ts.map +1 -0
  191. package/dist/index.js +13 -0
  192. package/dist/index.js.map +1 -0
  193. package/dist/ports/checkpoint-sink.d.ts +69 -0
  194. package/dist/ports/checkpoint-sink.d.ts.map +1 -0
  195. package/dist/ports/checkpoint-sink.js +16 -0
  196. package/dist/ports/checkpoint-sink.js.map +1 -0
  197. package/dist/ports/checkpoint.d.ts +68 -0
  198. package/dist/ports/checkpoint.d.ts.map +1 -0
  199. package/dist/ports/checkpoint.js +14 -0
  200. package/dist/ports/checkpoint.js.map +1 -0
  201. package/dist/ports/continuation-envelope-cross-app.test.d.ts +10 -0
  202. package/dist/ports/continuation-envelope-cross-app.test.d.ts.map +1 -0
  203. package/dist/ports/continuation-envelope-cross-app.test.js +95 -0
  204. package/dist/ports/continuation-envelope-cross-app.test.js.map +1 -0
  205. package/dist/ports/continuation-envelope.d.ts +199 -0
  206. package/dist/ports/continuation-envelope.d.ts.map +1 -0
  207. package/dist/ports/continuation-envelope.js +69 -0
  208. package/dist/ports/continuation-envelope.js.map +1 -0
  209. package/dist/ports/conversation.d.ts +64 -0
  210. package/dist/ports/conversation.d.ts.map +1 -0
  211. package/dist/ports/conversation.js +19 -0
  212. package/dist/ports/conversation.js.map +1 -0
  213. package/dist/ports/cost-oracle.d.ts +26 -0
  214. package/dist/ports/cost-oracle.d.ts.map +1 -0
  215. package/dist/ports/cost-oracle.js +9 -0
  216. package/dist/ports/cost-oracle.js.map +1 -0
  217. package/dist/ports/cross-app-invoker.d.ts +198 -0
  218. package/dist/ports/cross-app-invoker.d.ts.map +1 -0
  219. package/dist/ports/cross-app-invoker.js +157 -0
  220. package/dist/ports/cross-app-invoker.js.map +1 -0
  221. package/dist/ports/dlq-observer.d.ts +40 -0
  222. package/dist/ports/dlq-observer.d.ts.map +1 -0
  223. package/dist/ports/dlq-observer.js +20 -0
  224. package/dist/ports/dlq-observer.js.map +1 -0
  225. package/dist/ports/event-bus.d.ts +169 -0
  226. package/dist/ports/event-bus.d.ts.map +1 -0
  227. package/dist/ports/event-bus.js +20 -0
  228. package/dist/ports/event-bus.js.map +1 -0
  229. package/dist/ports/event-reader.d.ts +21 -0
  230. package/dist/ports/event-reader.d.ts.map +1 -0
  231. package/dist/ports/event-reader.js +12 -0
  232. package/dist/ports/event-reader.js.map +1 -0
  233. package/dist/ports/event-rotator.d.ts +39 -0
  234. package/dist/ports/event-rotator.d.ts.map +1 -0
  235. package/dist/ports/event-rotator.js +15 -0
  236. package/dist/ports/event-rotator.js.map +1 -0
  237. package/dist/ports/file-system.d.ts +48 -0
  238. package/dist/ports/file-system.d.ts.map +1 -0
  239. package/dist/ports/file-system.js +10 -0
  240. package/dist/ports/file-system.js.map +1 -0
  241. package/dist/ports/historical-observations.d.ts +39 -0
  242. package/dist/ports/historical-observations.d.ts.map +1 -0
  243. package/dist/ports/historical-observations.js +12 -0
  244. package/dist/ports/historical-observations.js.map +1 -0
  245. package/dist/ports/in-memory-source.d.ts +46 -0
  246. package/dist/ports/in-memory-source.d.ts.map +1 -0
  247. package/dist/ports/in-memory-source.js +69 -0
  248. package/dist/ports/in-memory-source.js.map +1 -0
  249. package/dist/ports/index.d.ts +32 -0
  250. package/dist/ports/index.d.ts.map +1 -0
  251. package/dist/ports/index.js +10 -0
  252. package/dist/ports/index.js.map +1 -0
  253. package/dist/ports/job-backed-executor.d.ts +139 -0
  254. package/dist/ports/job-backed-executor.d.ts.map +1 -0
  255. package/dist/ports/job-backed-executor.js +56 -0
  256. package/dist/ports/job-backed-executor.js.map +1 -0
  257. package/dist/ports/methodology-source.d.ts +95 -0
  258. package/dist/ports/methodology-source.d.ts.map +1 -0
  259. package/dist/ports/methodology-source.js +26 -0
  260. package/dist/ports/methodology-source.js.map +1 -0
  261. package/dist/ports/native-session-discovery.d.ts +20 -0
  262. package/dist/ports/native-session-discovery.d.ts.map +1 -0
  263. package/dist/ports/native-session-discovery.js +13 -0
  264. package/dist/ports/native-session-discovery.js.map +1 -0
  265. package/dist/ports/projection-store.d.ts +48 -0
  266. package/dist/ports/projection-store.d.ts.map +1 -0
  267. package/dist/ports/projection-store.js +17 -0
  268. package/dist/ports/projection-store.js.map +1 -0
  269. package/dist/ports/projection.d.ts +29 -0
  270. package/dist/ports/projection.d.ts.map +1 -0
  271. package/dist/ports/projection.js +13 -0
  272. package/dist/ports/projection.js.map +1 -0
  273. package/dist/ports/rate-governor.d.ts +17 -0
  274. package/dist/ports/rate-governor.d.ts.map +1 -0
  275. package/dist/ports/rate-governor.js +11 -0
  276. package/dist/ports/rate-governor.js.map +1 -0
  277. package/dist/ports/schedule-client.d.ts +29 -0
  278. package/dist/ports/schedule-client.d.ts.map +1 -0
  279. package/dist/ports/schedule-client.js +2 -0
  280. package/dist/ports/schedule-client.js.map +1 -0
  281. package/dist/ports/session-pool.d.ts +162 -0
  282. package/dist/ports/session-pool.d.ts.map +1 -0
  283. package/dist/ports/session-pool.js +21 -0
  284. package/dist/ports/session-pool.js.map +1 -0
  285. package/dist/ports/session-store-errors.d.ts +22 -0
  286. package/dist/ports/session-store-errors.d.ts.map +1 -0
  287. package/dist/ports/session-store-errors.js +29 -0
  288. package/dist/ports/session-store-errors.js.map +1 -0
  289. package/dist/ports/session-store-types.d.ts +132 -0
  290. package/dist/ports/session-store-types.d.ts.map +1 -0
  291. package/dist/ports/session-store-types.js +14 -0
  292. package/dist/ports/session-store-types.js.map +1 -0
  293. package/dist/ports/session-store.d.ts +69 -0
  294. package/dist/ports/session-store.d.ts.map +1 -0
  295. package/dist/ports/session-store.js +23 -0
  296. package/dist/ports/session-store.js.map +1 -0
  297. package/dist/ports/yaml-loader.d.ts +15 -0
  298. package/dist/ports/yaml-loader.d.ts.map +1 -0
  299. package/dist/ports/yaml-loader.js +13 -0
  300. package/dist/ports/yaml-loader.js.map +1 -0
  301. package/dist/scheduling/index.d.ts +6 -0
  302. package/dist/scheduling/index.d.ts.map +1 -0
  303. package/dist/scheduling/index.js +6 -0
  304. package/dist/scheduling/index.js.map +1 -0
  305. package/dist/scheduling/scheduled-pact.d.ts +97 -0
  306. package/dist/scheduling/scheduled-pact.d.ts.map +1 -0
  307. package/dist/scheduling/scheduled-pact.js +89 -0
  308. package/dist/scheduling/scheduled-pact.js.map +1 -0
  309. package/dist/sessions/__tests__/cognitive-modules.test.d.ts +10 -0
  310. package/dist/sessions/__tests__/cognitive-modules.test.d.ts.map +1 -0
  311. package/dist/sessions/__tests__/cognitive-modules.test.js +535 -0
  312. package/dist/sessions/__tests__/cognitive-modules.test.js.map +1 -0
  313. package/dist/sessions/__tests__/cognitive-provider.test.d.ts +13 -0
  314. package/dist/sessions/__tests__/cognitive-provider.test.d.ts.map +1 -0
  315. package/dist/sessions/__tests__/cognitive-provider.test.js +331 -0
  316. package/dist/sessions/__tests__/cognitive-provider.test.js.map +1 -0
  317. package/dist/sessions/__tests__/cognitive-sink.test.d.ts +19 -0
  318. package/dist/sessions/__tests__/cognitive-sink.test.d.ts.map +1 -0
  319. package/dist/sessions/__tests__/cognitive-sink.test.js +334 -0
  320. package/dist/sessions/__tests__/cognitive-sink.test.js.map +1 -0
  321. package/dist/sessions/__tests__/runtime-tools.test.d.ts +2 -0
  322. package/dist/sessions/__tests__/runtime-tools.test.d.ts.map +1 -0
  323. package/dist/sessions/__tests__/runtime-tools.test.js +83 -0
  324. package/dist/sessions/__tests__/runtime-tools.test.js.map +1 -0
  325. package/dist/sessions/auto-retro.d.ts +29 -0
  326. package/dist/sessions/auto-retro.d.ts.map +1 -0
  327. package/dist/sessions/auto-retro.js +181 -0
  328. package/dist/sessions/auto-retro.js.map +1 -0
  329. package/dist/sessions/auto-retro.test.d.ts +2 -0
  330. package/dist/sessions/auto-retro.test.d.ts.map +1 -0
  331. package/dist/sessions/auto-retro.test.js +361 -0
  332. package/dist/sessions/auto-retro.test.js.map +1 -0
  333. package/dist/sessions/channels.d.ts +55 -0
  334. package/dist/sessions/channels.d.ts.map +1 -0
  335. package/dist/sessions/channels.js +118 -0
  336. package/dist/sessions/channels.js.map +1 -0
  337. package/dist/sessions/channels.test.d.ts +2 -0
  338. package/dist/sessions/channels.test.d.ts.map +1 -0
  339. package/dist/sessions/channels.test.js +285 -0
  340. package/dist/sessions/channels.test.js.map +1 -0
  341. package/dist/sessions/cognitive-modules.d.ts +100 -0
  342. package/dist/sessions/cognitive-modules.d.ts.map +1 -0
  343. package/dist/sessions/cognitive-modules.js +458 -0
  344. package/dist/sessions/cognitive-modules.js.map +1 -0
  345. package/dist/sessions/cognitive-provider.d.ts +42 -0
  346. package/dist/sessions/cognitive-provider.d.ts.map +1 -0
  347. package/dist/sessions/cognitive-provider.js +208 -0
  348. package/dist/sessions/cognitive-provider.js.map +1 -0
  349. package/dist/sessions/cognitive-sink.d.ts +73 -0
  350. package/dist/sessions/cognitive-sink.d.ts.map +1 -0
  351. package/dist/sessions/cognitive-sink.js +154 -0
  352. package/dist/sessions/cognitive-sink.js.map +1 -0
  353. package/dist/sessions/diagnostics.d.ts +70 -0
  354. package/dist/sessions/diagnostics.d.ts.map +1 -0
  355. package/dist/sessions/diagnostics.js +129 -0
  356. package/dist/sessions/diagnostics.js.map +1 -0
  357. package/dist/sessions/diagnostics.test.d.ts +2 -0
  358. package/dist/sessions/diagnostics.test.d.ts.map +1 -0
  359. package/dist/sessions/diagnostics.test.js +135 -0
  360. package/dist/sessions/diagnostics.test.js.map +1 -0
  361. package/dist/sessions/index.d.ts +32 -0
  362. package/dist/sessions/index.d.ts.map +1 -0
  363. package/dist/sessions/index.js +33 -0
  364. package/dist/sessions/index.js.map +1 -0
  365. package/dist/sessions/pool.d.ts +218 -0
  366. package/dist/sessions/pool.d.ts.map +1 -0
  367. package/dist/sessions/pool.js +991 -0
  368. package/dist/sessions/pool.js.map +1 -0
  369. package/dist/sessions/pool.test.d.ts +2 -0
  370. package/dist/sessions/pool.test.d.ts.map +1 -0
  371. package/dist/sessions/pool.test.js +633 -0
  372. package/dist/sessions/pool.test.js.map +1 -0
  373. package/dist/sessions/print-session.d.ts +142 -0
  374. package/dist/sessions/print-session.d.ts.map +1 -0
  375. package/dist/sessions/print-session.js +325 -0
  376. package/dist/sessions/print-session.js.map +1 -0
  377. package/dist/sessions/print-session.test.d.ts +2 -0
  378. package/dist/sessions/print-session.test.d.ts.map +1 -0
  379. package/dist/sessions/print-session.test.js +418 -0
  380. package/dist/sessions/print-session.test.js.map +1 -0
  381. package/dist/sessions/runtime-tools.d.ts +22 -0
  382. package/dist/sessions/runtime-tools.d.ts.map +1 -0
  383. package/dist/sessions/runtime-tools.js +162 -0
  384. package/dist/sessions/runtime-tools.js.map +1 -0
  385. package/dist/sessions/scope-hook.d.ts +77 -0
  386. package/dist/sessions/scope-hook.d.ts.map +1 -0
  387. package/dist/sessions/scope-hook.js +323 -0
  388. package/dist/sessions/scope-hook.js.map +1 -0
  389. package/dist/sessions/scope-hook.test.d.ts +2 -0
  390. package/dist/sessions/scope-hook.test.d.ts.map +1 -0
  391. package/dist/sessions/scope-hook.test.js +249 -0
  392. package/dist/sessions/scope-hook.test.js.map +1 -0
  393. package/dist/sessions/session-store/checkpoint-sink-impl.d.ts +16 -0
  394. package/dist/sessions/session-store/checkpoint-sink-impl.d.ts.map +1 -0
  395. package/dist/sessions/session-store/checkpoint-sink-impl.js +191 -0
  396. package/dist/sessions/session-store/checkpoint-sink-impl.js.map +1 -0
  397. package/dist/sessions/session-store/checkpoint-sink-impl.test.d.ts +5 -0
  398. package/dist/sessions/session-store/checkpoint-sink-impl.test.d.ts.map +1 -0
  399. package/dist/sessions/session-store/checkpoint-sink-impl.test.js +137 -0
  400. package/dist/sessions/session-store/checkpoint-sink-impl.test.js.map +1 -0
  401. package/dist/sessions/session-store/conformance.d.ts +59 -0
  402. package/dist/sessions/session-store/conformance.d.ts.map +1 -0
  403. package/dist/sessions/session-store/conformance.js +172 -0
  404. package/dist/sessions/session-store/conformance.js.map +1 -0
  405. package/dist/sessions/session-store/conformance.test.d.ts +7 -0
  406. package/dist/sessions/session-store/conformance.test.d.ts.map +1 -0
  407. package/dist/sessions/session-store/conformance.test.js +22 -0
  408. package/dist/sessions/session-store/conformance.test.js.map +1 -0
  409. package/dist/sessions/session-store/in-memory-session-store.d.ts +23 -0
  410. package/dist/sessions/session-store/in-memory-session-store.d.ts.map +1 -0
  411. package/dist/sessions/session-store/in-memory-session-store.js +197 -0
  412. package/dist/sessions/session-store/in-memory-session-store.js.map +1 -0
  413. package/dist/sessions/session-store/in-memory-session-store.test.d.ts +6 -0
  414. package/dist/sessions/session-store/in-memory-session-store.test.d.ts.map +1 -0
  415. package/dist/sessions/session-store/in-memory-session-store.test.js +183 -0
  416. package/dist/sessions/session-store/in-memory-session-store.test.js.map +1 -0
  417. package/dist/sessions/session-store/index.d.ts +20 -0
  418. package/dist/sessions/session-store/index.d.ts.map +1 -0
  419. package/dist/sessions/session-store/index.js +15 -0
  420. package/dist/sessions/session-store/index.js.map +1 -0
  421. package/dist/sessions/session-store/resume.d.ts +88 -0
  422. package/dist/sessions/session-store/resume.d.ts.map +1 -0
  423. package/dist/sessions/session-store/resume.js +96 -0
  424. package/dist/sessions/session-store/resume.js.map +1 -0
  425. package/dist/sessions/session-store/resume.test.d.ts +5 -0
  426. package/dist/sessions/session-store/resume.test.d.ts.map +1 -0
  427. package/dist/sessions/session-store/resume.test.js +119 -0
  428. package/dist/sessions/session-store/resume.test.js.map +1 -0
  429. package/dist/sessions/spawn-queue.d.ts +28 -0
  430. package/dist/sessions/spawn-queue.d.ts.map +1 -0
  431. package/dist/sessions/spawn-queue.js +63 -0
  432. package/dist/sessions/spawn-queue.js.map +1 -0
  433. package/dist/sessions/spawn-queue.test.d.ts +2 -0
  434. package/dist/sessions/spawn-queue.test.d.ts.map +1 -0
  435. package/dist/sessions/spawn-queue.test.js +65 -0
  436. package/dist/sessions/spawn-queue.test.js.map +1 -0
  437. package/dist/sessions/types.d.ts +16 -0
  438. package/dist/sessions/types.d.ts.map +1 -0
  439. package/dist/sessions/types.js +11 -0
  440. package/dist/sessions/types.js.map +1 -0
  441. package/dist/sessions/worktree-stale.test.d.ts +2 -0
  442. package/dist/sessions/worktree-stale.test.d.ts.map +1 -0
  443. package/dist/sessions/worktree-stale.test.js +468 -0
  444. package/dist/sessions/worktree-stale.test.js.map +1 -0
  445. package/dist/strategy/artifact-store.d.ts +12 -0
  446. package/dist/strategy/artifact-store.d.ts.map +1 -0
  447. package/dist/strategy/artifact-store.js +12 -0
  448. package/dist/strategy/artifact-store.js.map +1 -0
  449. package/dist/strategy/artifact-store.test.d.ts +2 -0
  450. package/dist/strategy/artifact-store.test.d.ts.map +1 -0
  451. package/dist/strategy/artifact-store.test.js +170 -0
  452. package/dist/strategy/artifact-store.test.js.map +1 -0
  453. package/dist/strategy/context-load-executor.d.ts +23 -0
  454. package/dist/strategy/context-load-executor.d.ts.map +1 -0
  455. package/dist/strategy/context-load-executor.js +87 -0
  456. package/dist/strategy/context-load-executor.js.map +1 -0
  457. package/dist/strategy/context-load-executor.test.d.ts +16 -0
  458. package/dist/strategy/context-load-executor.test.d.ts.map +1 -0
  459. package/dist/strategy/context-load-executor.test.js +158 -0
  460. package/dist/strategy/context-load-executor.test.js.map +1 -0
  461. package/dist/strategy/cortex-cross-app-invoker.stub.d.ts +65 -0
  462. package/dist/strategy/cortex-cross-app-invoker.stub.d.ts.map +1 -0
  463. package/dist/strategy/cortex-cross-app-invoker.stub.js +68 -0
  464. package/dist/strategy/cortex-cross-app-invoker.stub.js.map +1 -0
  465. package/dist/strategy/cross-app-node-executor.d.ts +54 -0
  466. package/dist/strategy/cross-app-node-executor.d.ts.map +1 -0
  467. package/dist/strategy/cross-app-node-executor.js +98 -0
  468. package/dist/strategy/cross-app-node-executor.js.map +1 -0
  469. package/dist/strategy/cross-app-node-executor.test.d.ts +13 -0
  470. package/dist/strategy/cross-app-node-executor.test.d.ts.map +1 -0
  471. package/dist/strategy/cross-app-node-executor.test.js +160 -0
  472. package/dist/strategy/cross-app-node-executor.test.js.map +1 -0
  473. package/dist/strategy/gates.d.ts +13 -0
  474. package/dist/strategy/gates.d.ts.map +1 -0
  475. package/dist/strategy/gates.js +13 -0
  476. package/dist/strategy/gates.js.map +1 -0
  477. package/dist/strategy/gates.test.d.ts +2 -0
  478. package/dist/strategy/gates.test.d.ts.map +1 -0
  479. package/dist/strategy/gates.test.js +299 -0
  480. package/dist/strategy/gates.test.js.map +1 -0
  481. package/dist/strategy/human-approval-resolver.d.ts +23 -0
  482. package/dist/strategy/human-approval-resolver.d.ts.map +1 -0
  483. package/dist/strategy/human-approval-resolver.js +94 -0
  484. package/dist/strategy/human-approval-resolver.js.map +1 -0
  485. package/dist/strategy/human-approval-resolver.test.d.ts +16 -0
  486. package/dist/strategy/human-approval-resolver.test.d.ts.map +1 -0
  487. package/dist/strategy/human-approval-resolver.test.js +200 -0
  488. package/dist/strategy/human-approval-resolver.test.js.map +1 -0
  489. package/dist/strategy/in-process-cross-app-invoker.d.ts +105 -0
  490. package/dist/strategy/in-process-cross-app-invoker.d.ts.map +1 -0
  491. package/dist/strategy/in-process-cross-app-invoker.js +206 -0
  492. package/dist/strategy/in-process-cross-app-invoker.js.map +1 -0
  493. package/dist/strategy/in-process-cross-app-invoker.test.d.ts +15 -0
  494. package/dist/strategy/in-process-cross-app-invoker.test.d.ts.map +1 -0
  495. package/dist/strategy/in-process-cross-app-invoker.test.js +190 -0
  496. package/dist/strategy/in-process-cross-app-invoker.test.js.map +1 -0
  497. package/dist/strategy/index.d.ts +29 -0
  498. package/dist/strategy/index.d.ts.map +1 -0
  499. package/dist/strategy/index.js +29 -0
  500. package/dist/strategy/index.js.map +1 -0
  501. package/dist/strategy/pacta-strategy.d.ts +97 -0
  502. package/dist/strategy/pacta-strategy.d.ts.map +1 -0
  503. package/dist/strategy/pacta-strategy.js +117 -0
  504. package/dist/strategy/pacta-strategy.js.map +1 -0
  505. package/dist/strategy/pacta-strategy.test.d.ts +2 -0
  506. package/dist/strategy/pacta-strategy.test.d.ts.map +1 -0
  507. package/dist/strategy/pacta-strategy.test.js +234 -0
  508. package/dist/strategy/pacta-strategy.test.js.map +1 -0
  509. package/dist/strategy/retro-generator.d.ts +18 -0
  510. package/dist/strategy/retro-generator.d.ts.map +1 -0
  511. package/dist/strategy/retro-generator.js +22 -0
  512. package/dist/strategy/retro-generator.js.map +1 -0
  513. package/dist/strategy/retro-writer.d.ts +25 -0
  514. package/dist/strategy/retro-writer.d.ts.map +1 -0
  515. package/dist/strategy/retro-writer.js +65 -0
  516. package/dist/strategy/retro-writer.js.map +1 -0
  517. package/dist/strategy/strategy-executor.d.ts +39 -0
  518. package/dist/strategy/strategy-executor.d.ts.map +1 -0
  519. package/dist/strategy/strategy-executor.js +253 -0
  520. package/dist/strategy/strategy-executor.js.map +1 -0
  521. package/dist/strategy/strategy-executor.test.d.ts +8 -0
  522. package/dist/strategy/strategy-executor.test.d.ts.map +1 -0
  523. package/dist/strategy/strategy-executor.test.js +1301 -0
  524. package/dist/strategy/strategy-executor.test.js.map +1 -0
  525. package/dist/strategy/strategy-parser.d.ts +30 -0
  526. package/dist/strategy/strategy-parser.d.ts.map +1 -0
  527. package/dist/strategy/strategy-parser.js +30 -0
  528. package/dist/strategy/strategy-parser.js.map +1 -0
  529. package/dist/strategy/sub-strategy-source.d.ts +27 -0
  530. package/dist/strategy/sub-strategy-source.d.ts.map +1 -0
  531. package/dist/strategy/sub-strategy-source.js +77 -0
  532. package/dist/strategy/sub-strategy-source.js.map +1 -0
  533. package/dist/strategy/types.d.ts +12 -0
  534. package/dist/strategy/types.d.ts.map +1 -0
  535. package/dist/strategy/types.js +9 -0
  536. package/dist/strategy/types.js.map +1 -0
  537. package/package.json +87 -0
@@ -0,0 +1,198 @@
1
+ /**
2
+ * CrossAppInvoker — transport-free port for cross-app strategy invocation (PRD-067).
3
+ *
4
+ * Frozen (Track A simulator surfaces): 2026-04-15 — see
5
+ * `.method/sessions/fcd-design-prd-067-multi-app-strategy/prd.md` §6.1.
6
+ *
7
+ * Owner: @methodts/runtime (defines port)
8
+ * Producer: @methodts/agent-runtime/cortex (CortexCrossAppInvoker — BLOCKED on
9
+ * Cortex PRD-080) and @methodts/runtime (InProcessCrossAppInvoker
10
+ * simulator — shipping in this PR)
11
+ * Consumer: @methodts/runtime/strategy (DagStrategyExecutor cross-app-invoke node dispatch)
12
+ *
13
+ * Gates:
14
+ * - G-BOUNDARY: zero `@cortex/*` imports in this file — only port-local types.
15
+ * - G-PORT: strategy executor MUST dispatch through this port, never directly
16
+ * through `ctx.apps.invoke`.
17
+ *
18
+ * PRD-067 §12.3 ships `InProcessCrossAppInvoker` now so tests + single-process
19
+ * demos can exercise cross-app DAG flows without waiting for Cortex PRD-080
20
+ * (`🔜 deferred`, Wave 5). Swapping the simulator for the live adapter is a
21
+ * single composition-root line change once PRD-080 thaws.
22
+ */
23
+ /** Delegation context carried into any RFC 8693 token exchange on dispatch.
24
+ *
25
+ * Constructed by the strategy executor from the pact's token context (see S3
26
+ * `CortexTokenExchangeMiddleware`). Tenant-app code does not build this.
27
+ */
28
+ export interface DelegationCarry {
29
+ /** The caller's ctx-issued token (agent-scoped). Opaque to method; the
30
+ * Cortex adapter threads it into `ctx.auth.exchangeForAgent`. */
31
+ readonly parentToken: string;
32
+ /** Exchange depth the caller has already consumed (RFC 8693). The adapter
33
+ * rejects when `currentDepth >= maxDelegationDepth` per PRD-061/PRD-080. */
34
+ readonly currentDepth: number;
35
+ /** Originating request id — flows into the caller-side audit entry and
36
+ * correlates with `tokenContext.originatingRequestId` on the envelope. */
37
+ readonly originatingRequestId: string;
38
+ }
39
+ /** Request to invoke an operation on a target Cortex tenant app. */
40
+ export interface CrossAppInvokeRequest<Input = unknown> {
41
+ /** Target Cortex app id. MUST be present in the caller's `requires.apps[]`
42
+ * manifest block. Enforced by Cortex at runtime; the Method adapter also
43
+ * pre-checks via `capabilities().allowedTargetAppIds` to fail fast. */
44
+ readonly targetAppId: string;
45
+ /** Operation name on the target app. PRD-080 constrains cross-app calls to
46
+ * operations, never tools. */
47
+ readonly operation: string;
48
+ /** Typed payload. Shape contract belongs to the target app's operation
49
+ * schema — the invoker does NOT validate it; the caller's strategy DAG
50
+ * node config declares its expected shape via `input_projection`. */
51
+ readonly input: Input;
52
+ /** Optional per-call timeout (milliseconds). Default: executor's
53
+ * `defaultTimeoutMs`. */
54
+ readonly timeoutMs?: number;
55
+ /** Optional idempotency key. If the same
56
+ * `(targetAppId, operation, idempotencyKey)` triple is seen twice the
57
+ * target returns the first result. Recommended: the strategy DAG's
58
+ * `${sessionId}:${nodeId}` tuple to dedupe across retries. */
59
+ readonly idempotencyKey?: string;
60
+ /** Delegation context for RFC 8693 token exchange. */
61
+ readonly delegation: DelegationCarry;
62
+ /** Strategy correlation identifiers — flow into the caller-side audit
63
+ * entry and the continuation envelope's `crossApp.callerNodeId`. */
64
+ readonly caller: {
65
+ readonly sessionId: string;
66
+ readonly nodeId: string;
67
+ };
68
+ }
69
+ /** Result of a cross-app invocation. */
70
+ export interface CrossAppInvokeResult<Output = unknown> {
71
+ /** The target operation's output, opaque to the port. */
72
+ readonly output: Output;
73
+ /** Target app's decisionId as returned by `ctx.apps.invoke` (PRD-080 §5.7).
74
+ * Method appends this to its caller-side audit entry so the dual-audit
75
+ * correlation works end-to-end. */
76
+ readonly targetDecisionId: string;
77
+ /** Wall-clock latency (ms) measured at the call site — includes token
78
+ * exchange, scope check, transport, and target execution. */
79
+ readonly latencyMs: number;
80
+ /** Cost attributed to the CALLER's budget (USD) as reported by `ctx.llm`
81
+ * at dispatch time. Callee's own `ctx.llm` cost is NOT included here —
82
+ * the callee debits its own budget separately and the caller never sees
83
+ * the callee's line item. */
84
+ readonly callerCostUsd: number;
85
+ }
86
+ /** Declarative capabilities of a concrete invoker implementation, asked at
87
+ * compose time by the strategy executor so dev-mode bridges can fail fast
88
+ * rather than at execution. */
89
+ export interface CrossAppInvokerCapabilities {
90
+ /** True when the invoker can actually dispatch; false for null invokers. */
91
+ readonly enabled: boolean;
92
+ /** Max RFC 8693 delegation depth this invoker will accept before rejecting
93
+ * at dispatch time. Echoes the PRD-061/PRD-080 default of 2. Adapters
94
+ * MAY declare a lower cap (e.g. a simulator that runs depth 1 only). */
95
+ readonly maxDelegationDepth: number;
96
+ /** Allowed target app ids — derived from the tenant app's
97
+ * `requires.apps[]` manifest block. Empty `undefined` means "adapter
98
+ * doesn't enforce — trust the Cortex runtime check". A non-empty set
99
+ * lets the strategy compose-time validator reject DAGs targeting
100
+ * undeclared apps before execution starts. */
101
+ readonly allowedTargetAppIds?: ReadonlySet<string>;
102
+ }
103
+ /**
104
+ * Transport-free port the strategy DAG executor calls to dispatch a
105
+ * `cross-app-invoke` node. The `@methodts/runtime` layer knows nothing about
106
+ * Cortex; the adapter in `@methodts/agent-runtime/cortex` implements this port
107
+ * by calling `ctx.apps.invoke` (Cortex PRD-080).
108
+ *
109
+ * Implementations (per PRD-067 §6.1):
110
+ * - `InProcessCrossAppInvoker` — in-memory map of registered simulator
111
+ * apps; dispatches synchronously in-process. Shipping in this PR.
112
+ * - `CortexCrossAppInvoker` — wraps `ctx.apps.invoke`. BLOCKED on Cortex
113
+ * PRD-080 freeze.
114
+ * - `NullCrossAppInvoker` — throws `CrossAppNotConfiguredError` on every
115
+ * call; the default when no cross-app capability is wired.
116
+ *
117
+ * Fire-and-forget is explicitly not supported (PRD-080 §4 OOS): every call
118
+ * is request/reply.
119
+ */
120
+ export interface CrossAppInvoker {
121
+ /** Invoke a named operation on a target app. */
122
+ invoke<Input = unknown, Output = unknown>(request: CrossAppInvokeRequest<Input>): Promise<CrossAppInvokeResult<Output>>;
123
+ /** Declare capabilities the strategy executor can check at compose time. */
124
+ capabilities(): CrossAppInvokerCapabilities;
125
+ }
126
+ /** Thrown when a `cross-app-invoke` node runs but no invoker is wired
127
+ * (composition root received `NullCrossAppInvoker` or none at all). */
128
+ export declare class CrossAppNotConfiguredError extends Error {
129
+ readonly code: "CROSS_APP_NOT_CONFIGURED";
130
+ constructor(message?: string);
131
+ }
132
+ /** Thrown at compose time when a DAG targets an app not in the manifest
133
+ * `requires.apps[]` block (i.e. not in `capabilities().allowedTargetAppIds`). */
134
+ export declare class CrossAppTargetNotDeclaredError extends Error {
135
+ readonly code: "CROSS_APP_TARGET_NOT_DECLARED";
136
+ readonly targetAppId: string;
137
+ readonly allowedTargetAppIds: ReadonlySet<string>;
138
+ constructor(targetAppId: string, allowedTargetAppIds: ReadonlySet<string>);
139
+ }
140
+ /** Surfaces Cortex PRD-080's `cross_app_scope_missing` 403 as a typed error. */
141
+ export declare class CrossAppScopeMissingError extends Error {
142
+ readonly code: "CROSS_APP_SCOPE_MISSING";
143
+ readonly targetAppId: string;
144
+ readonly operation: string;
145
+ constructor(targetAppId: string, operation: string);
146
+ }
147
+ /** Thrown when the delegation depth would exceed the invoker's declared
148
+ * max (PRD-067 §9.1 conflict point — default cap is 2). */
149
+ export declare class CrossAppDelegationDepthExceededError extends Error {
150
+ readonly code: "CROSS_APP_DELEGATION_DEPTH_EXCEEDED";
151
+ readonly currentDepth: number;
152
+ readonly maxDepth: number;
153
+ constructor(currentDepth: number, maxDepth: number);
154
+ }
155
+ /** Thrown when the target app/operation is registered but its handler threw
156
+ * — the invoker captures the target error and re-raises so the strategy
157
+ * gate/retry machinery can resolve it as a node failure (PRD-067 §9 risk:
158
+ * "Failure isolation"). */
159
+ export declare class CrossAppTargetError extends Error {
160
+ readonly code: "CROSS_APP_TARGET_ERROR";
161
+ readonly targetAppId: string;
162
+ readonly operation: string;
163
+ readonly targetDecisionId: string;
164
+ readonly cause: unknown;
165
+ constructor(targetAppId: string, operation: string, targetDecisionId: string, cause: unknown);
166
+ }
167
+ /** Thrown when a target app is not registered with the invoker (simulator
168
+ * analogue of Cortex's deploy-time app-dep graph check). */
169
+ export declare class CrossAppTargetUnknownError extends Error {
170
+ readonly code: "CROSS_APP_TARGET_UNKNOWN";
171
+ readonly targetAppId: string;
172
+ readonly operation: string;
173
+ constructor(targetAppId: string, operation: string, knownAppIds: readonly string[]);
174
+ }
175
+ /** Default invoker used when the composition root did not wire a real one.
176
+ *
177
+ * `invoke()` throws `CrossAppNotConfiguredError` on every call; `capabilities()`
178
+ * reports `{ enabled: false }` so the strategy parser can refuse cross-app
179
+ * nodes at compose time rather than at runtime.
180
+ */
181
+ export declare class NullCrossAppInvoker implements CrossAppInvoker {
182
+ invoke<Input, Output>(_request: CrossAppInvokeRequest<Input>): Promise<CrossAppInvokeResult<Output>>;
183
+ capabilities(): CrossAppInvokerCapabilities;
184
+ }
185
+ /** Default delegation depth cap, matching PRD-061/PRD-080 RFC 8693 defaults. */
186
+ export declare const CROSS_APP_DEFAULT_MAX_DELEGATION_DEPTH = 2;
187
+ /**
188
+ * Compose-time validator — given a strategy's declared set of target apps,
189
+ * fails fast if any are not in the invoker's allowlist. Strategy executors
190
+ * call this before walking the DAG so a misconfigured manifest surfaces at
191
+ * compose time rather than at node dispatch.
192
+ *
193
+ * Behavior: when `capabilities().allowedTargetAppIds` is `undefined` the
194
+ * check is skipped (adapter declared "trust Cortex runtime check"). When
195
+ * the set is present (even empty), every declared target must be a member.
196
+ */
197
+ export declare function assertCrossAppTargetsAllowed(invoker: CrossAppInvoker, declaredTargetAppIds: readonly string[]): void;
198
+ //# sourceMappingURL=cross-app-invoker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-app-invoker.d.ts","sourceRoot":"","sources":["../../src/ports/cross-app-invoker.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;sEACkE;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;iFAC6E;IAC7E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;+EAC2E;IAC3E,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;CACvC;AAED,oEAAoE;AACpE,MAAM,WAAW,qBAAqB,CAAC,KAAK,GAAG,OAAO;IACpD;;4EAEwE;IACxE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B;mCAC+B;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;0EAEsE;IACtE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAEtB;8BAC0B;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;;mEAG+D;IAC/D,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAEjC,sDAAsD;IACtD,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IAErC;yEACqE;IACrE,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,wCAAwC;AACxC,MAAM,WAAW,oBAAoB,CAAC,MAAM,GAAG,OAAO;IACpD,yDAAyD;IACzD,QAAQ,C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AoB,CAAC,MAAM,CAAC,CAAC;IAIxC,YAAY,IAAI,2BAA2B;CAO5C;AAED,gFAAgF;AAChF,eAAO,MAAM,sCAAsC,IAAI,CAAC;AAExD;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,eAAe,EACxB,oBAAoB,EAAE,SAAS,MAAM,EAAE,GACtC,IAAI,CASN"}
@@ -0,0 +1,157 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * CrossAppInvoker — transport-free port for cross-app strategy invocation (PRD-067).
4
+ *
5
+ * Frozen (Track A simulator surfaces): 2026-04-15 — see
6
+ * `.method/sessions/fcd-design-prd-067-multi-app-strategy/prd.md` §6.1.
7
+ *
8
+ * Owner: @methodts/runtime (defines port)
9
+ * Producer: @methodts/agent-runtime/cortex (CortexCrossAppInvoker — BLOCKED on
10
+ * Cortex PRD-080) and @methodts/runtime (InProcessCrossAppInvoker
11
+ * simulator — shipping in this PR)
12
+ * Consumer: @methodts/runtime/strategy (DagStrategyExecutor cross-app-invoke node dispatch)
13
+ *
14
+ * Gates:
15
+ * - G-BOUNDARY: zero `@cortex/*` imports in this file — only port-local types.
16
+ * - G-PORT: strategy executor MUST dispatch through this port, never directly
17
+ * through `ctx.apps.invoke`.
18
+ *
19
+ * PRD-067 §12.3 ships `InProcessCrossAppInvoker` now so tests + single-process
20
+ * demos can exercise cross-app DAG flows without waiting for Cortex PRD-080
21
+ * (`🔜 deferred`, Wave 5). Swapping the simulator for the live adapter is a
22
+ * single composition-root line change once PRD-080 thaws.
23
+ */
24
+ // ── Typed error classes ─────────────────────────────────────────
25
+ /** Thrown when a `cross-app-invoke` node runs but no invoker is wired
26
+ * (composition root received `NullCrossAppInvoker` or none at all). */
27
+ export class CrossAppNotConfiguredError extends Error {
28
+ code = 'CROSS_APP_NOT_CONFIGURED';
29
+ constructor(message) {
30
+ super(message ??
31
+ 'CrossAppInvoker not configured — strategy DAG declares a cross-app-invoke node but the runtime has no invoker wired. Inject CortexCrossAppInvoker (prod) or InProcessCrossAppInvoker (simulator/test).');
32
+ this.name = 'CrossAppNotConfiguredError';
33
+ }
34
+ }
35
+ /** Thrown at compose time when a DAG targets an app not in the manifest
36
+ * `requires.apps[]` block (i.e. not in `capabilities().allowedTargetAppIds`). */
37
+ export class CrossAppTargetNotDeclaredError extends Error {
38
+ code = 'CROSS_APP_TARGET_NOT_DECLARED';
39
+ targetAppId;
40
+ allowedTargetAppIds;
41
+ constructor(targetAppId, allowedTargetAppIds) {
42
+ super(`Cross-app target "${targetAppId}" is not declared in the caller's requires.apps[] manifest block. ` +
43
+ `Allowed: [${[...allowedTargetAppIds].sort().join(', ') || '<none>'}]. ` +
44
+ `Add "${targetAppId}" to the tenant app's manifest or remove the cross-app-invoke node from the strategy.`);
45
+ this.name = 'CrossAppTargetNotDeclaredError';
46
+ this.targetAppId = targetAppId;
47
+ this.allowedTargetAppIds = allowedTargetAppIds;
48
+ }
49
+ }
50
+ /** Surfaces Cortex PRD-080's `cross_app_scope_missing` 403 as a typed error. */
51
+ export class CrossAppScopeMissingError extends Error {
52
+ code = 'CROSS_APP_SCOPE_MISSING';
53
+ targetAppId;
54
+ operation;
55
+ constructor(targetAppId, operation) {
56
+ super(`Cross-app call to "${targetAppId}.${operation}" rejected: token is missing the required app:${targetAppId}:${operation} scope. ` +
57
+ `The caller's ctx-issued token must carry that scope claim. ` +
58
+ `This maps to Cortex PRD-080's cross_app_scope_missing 403.`);
59
+ this.name = 'CrossAppScopeMissingError';
60
+ this.targetAppId = targetAppId;
61
+ this.operation = operation;
62
+ }
63
+ }
64
+ /** Thrown when the delegation depth would exceed the invoker's declared
65
+ * max (PRD-067 §9.1 conflict point — default cap is 2). */
66
+ export class CrossAppDelegationDepthExceededError extends Error {
67
+ code = 'CROSS_APP_DELEGATION_DEPTH_EXCEEDED';
68
+ currentDepth;
69
+ maxDepth;
70
+ constructor(currentDepth, maxDepth) {
71
+ super(`Cross-app invocation rejected: delegation depth ${currentDepth} would exceed the cap of ${maxDepth}. ` +
72
+ `Per PRD-061/PRD-080 the hard cap is 2 — user → agent → cross-app is the deepest valid chain. ` +
73
+ `PRD-067 §9.1 default mitigation: re-compose deep sub-agent trees as siblings via additional cross-app-invoke calls (flatten the tree).`);
74
+ this.name = 'CrossAppDelegationDepthExceededError';
75
+ this.currentDepth = currentDepth;
76
+ this.maxDepth = maxDepth;
77
+ }
78
+ }
79
+ /** Thrown when the target app/operation is registered but its handler threw
80
+ * — the invoker captures the target error and re-raises so the strategy
81
+ * gate/retry machinery can resolve it as a node failure (PRD-067 §9 risk:
82
+ * "Failure isolation"). */
83
+ export class CrossAppTargetError extends Error {
84
+ code = 'CROSS_APP_TARGET_ERROR';
85
+ targetAppId;
86
+ operation;
87
+ targetDecisionId;
88
+ cause;
89
+ constructor(targetAppId, operation, targetDecisionId, cause) {
90
+ const causeMsg = cause instanceof Error ? cause.message : String(cause);
91
+ super(`Cross-app target "${targetAppId}.${operation}" failed (decisionId=${targetDecisionId}): ${causeMsg}`);
92
+ this.name = 'CrossAppTargetError';
93
+ this.targetAppId = targetAppId;
94
+ this.operation = operation;
95
+ this.targetDecisionId = targetDecisionId;
96
+ this.cause = cause;
97
+ }
98
+ }
99
+ /** Thrown when a target app is not registered with the invoker (simulator
100
+ * analogue of Cortex's deploy-time app-dep graph check). */
101
+ export class CrossAppTargetUnknownError extends Error {
102
+ code = 'CROSS_APP_TARGET_UNKNOWN';
103
+ targetAppId;
104
+ operation;
105
+ constructor(targetAppId, operation, knownAppIds) {
106
+ super(`Cross-app target "${targetAppId}.${operation}" unknown to invoker. ` +
107
+ `Registered apps: [${[...knownAppIds].sort().join(', ') || '<none>'}]. ` +
108
+ `In the simulator, register the app via InProcessCrossAppInvoker.registerApp(); ` +
109
+ `in production, confirm the app is deployed and declared in requires.apps[].`);
110
+ this.name = 'CrossAppTargetUnknownError';
111
+ this.targetAppId = targetAppId;
112
+ this.operation = operation;
113
+ }
114
+ }
115
+ // ── Default null invoker ────────────────────────────────────────
116
+ /** Default invoker used when the composition root did not wire a real one.
117
+ *
118
+ * `invoke()` throws `CrossAppNotConfiguredError` on every call; `capabilities()`
119
+ * reports `{ enabled: false }` so the strategy parser can refuse cross-app
120
+ * nodes at compose time rather than at runtime.
121
+ */
122
+ export class NullCrossAppInvoker {
123
+ async invoke(_request) {
124
+ throw new CrossAppNotConfiguredError();
125
+ }
126
+ capabilities() {
127
+ return {
128
+ enabled: false,
129
+ maxDelegationDepth: 2,
130
+ allowedTargetAppIds: new Set(),
131
+ };
132
+ }
133
+ }
134
+ /** Default delegation depth cap, matching PRD-061/PRD-080 RFC 8693 defaults. */
135
+ export const CROSS_APP_DEFAULT_MAX_DELEGATION_DEPTH = 2;
136
+ /**
137
+ * Compose-time validator — given a strategy's declared set of target apps,
138
+ * fails fast if any are not in the invoker's allowlist. Strategy executors
139
+ * call this before walking the DAG so a misconfigured manifest surfaces at
140
+ * compose time rather than at node dispatch.
141
+ *
142
+ * Behavior: when `capabilities().allowedTargetAppIds` is `undefined` the
143
+ * check is skipped (adapter declared "trust Cortex runtime check"). When
144
+ * the set is present (even empty), every declared target must be a member.
145
+ */
146
+ export function assertCrossAppTargetsAllowed(invoker, declaredTargetAppIds) {
147
+ const caps = invoker.capabilities();
148
+ const allowed = caps.allowedTargetAppIds;
149
+ if (allowed === undefined)
150
+ return;
151
+ for (const targetAppId of declaredTargetAppIds) {
152
+ if (!allowed.has(targetAppId)) {
153
+ throw new CrossAppTargetNotDeclaredError(targetAppId, allowed);
154
+ }
155
+ }
156
+ }
157
+ //# sourceMappingURL=cross-app-invoker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-app-invoker.js","sourceRoot":"","sources":["../../src/ports/cross-app-invoker.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;;;;;;;;;;;;;;;;;;;GAqBG;AA4HH,mEAAmE;AAEnE;wEACwE;AACxE,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,IAAI,GAAG,0BAAmC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K;YACxE,iFAAiF;YACjF,6EAA6E,CAChF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAED,mEAAmE;AAEnE;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAC9B,KAAK,CAAC,MAAM,CACV,QAAsC;QAEtC,MAAM,IAAI,0BAA0B,EAAE,CAAC;IACzC,CAAC;IAED,YAAY;QACV,OAAO;YACL,OAAO,EAAE,KAAK;YACd,kBAAkB,EAAE,CAAC;YACrB,mBAAmB,EAAE,IAAI,GAAG,EAAU;SACvC,CAAC;IACJ,CAAC;CACF;AAED,gFAAgF;AAChF,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC,CAAC;AAExD;;;;;;;;;GASG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAwB,EACxB,oBAAuC;IAEvC,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC;IACzC,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO;IAClC,KAAK,MAAM,WAAW,IAAI,oBAAoB,EAAE,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,8BAA8B,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * DLQ observability port — PRD-062 / S5 §2.4.
3
+ *
4
+ * When Cortex's retry policy exhausts (attempt=4 failed, moved to DLQ),
5
+ * the tenant app MUST give the runtime a chance to observe and emit a
6
+ * terminal `AgentEvent`. This port is attached to the DLQ inspection hook.
7
+ *
8
+ * Two emission paths (G-DLQ-SINGLE-EMIT, S5 §7):
9
+ * - INLINE: from the continuation handler when pacta classifies "ack +
10
+ * signal DLQ" (budget exhaustion, checkpoint corruption, budget_expired).
11
+ * - EXTERNAL: from Cortex's DLQ — the tenant's inspection job calls
12
+ * `onDeadLetter(envelope, record)` which emits the same event.
13
+ *
14
+ * The observer MUST emit at most one `PactDeadLetterEvent` per
15
+ * `sessionId`, regardless of how many times either path fires. The
16
+ * executor coordinates via SessionStore finalize-status.
17
+ */
18
+ import type { ContinuationEnvelope } from './continuation-envelope.js';
19
+ import type { PactDeadLetterEvent } from '@methodts/pacta';
20
+ export interface DlqObserver {
21
+ /**
22
+ * Called by the tenant app when a DLQ record is observed for a
23
+ * `method.pact.continue` job. The observer unpacks the envelope,
24
+ * emits a `PactDeadLetterEvent` on the host's event channel, and
25
+ * finalises the session (unless already terminal).
26
+ *
27
+ * Returns the emitted event (or `null` if suppressed because the
28
+ * session was already terminal — idempotent).
29
+ */
30
+ onDeadLetter(envelope: ContinuationEnvelope, dlqRecord: DlqRecord): Promise<PactDeadLetterEvent | null>;
31
+ }
32
+ export interface DlqRecord {
33
+ jobId: string;
34
+ attempts: number;
35
+ lastError: string;
36
+ deadLetteredAt: number;
37
+ }
38
+ /** Re-export for convenient import from the ports barrel. */
39
+ export type { PactDeadLetterEvent } from '@methodts/pacta';
40
+ //# sourceMappingURL=dlq-observer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dlq-observer.d.ts","sourceRoot":"","sources":["../../src/ports/dlq-observer.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,WAAW,WAAW;IAC1B;;;;;;;;OAQG;IACH,YAAY,CACV,QAAQ,EAAE,oBAAoB,EAC9B,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,6DAA6D;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,20 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * DLQ observability port — PRD-062 / S5 §2.4.
4
+ *
5
+ * When Cortex's retry policy exhausts (attempt=4 failed, moved to DLQ),
6
+ * the tenant app MUST give the runtime a chance to observe and emit a
7
+ * terminal `AgentEvent`. This port is attached to the DLQ inspection hook.
8
+ *
9
+ * Two emission paths (G-DLQ-SINGLE-EMIT, S5 §7):
10
+ * - INLINE: from the continuation handler when pacta classifies "ack +
11
+ * signal DLQ" (budget exhaustion, checkpoint corruption, budget_expired).
12
+ * - EXTERNAL: from Cortex's DLQ — the tenant's inspection job calls
13
+ * `onDeadLetter(envelope, record)` which emits the same event.
14
+ *
15
+ * The observer MUST emit at most one `PactDeadLetterEvent` per
16
+ * `sessionId`, regardless of how many times either path fires. The
17
+ * executor coordinates via SessionStore finalize-status.
18
+ */
19
+ export {};
20
+ //# sourceMappingURL=dlq-observer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dlq-observer.js","sourceRoot":"","sources":["../../src/ports/dlq-observer.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;;;;;;;;;;;;;;GAgBG"}
@@ -0,0 +1,169 @@
1
+ /**
2
+ * EventBus — Port interface for the Universal Event Bus (PRD 026).
3
+ *
4
+ * The event bus is runtime-level infrastructure. Domains emit typed events
5
+ * through the port. Consumers (WebSocket, persistence, Genesis, parent agents)
6
+ * subscribe through the same interface. Neither producers nor consumers
7
+ * know about each other.
8
+ *
9
+ * PRD-057: Moved from @methodts/bridge/ports/event-bus.ts. The type was
10
+ * renamed `BridgeEvent` → `RuntimeEvent` to reflect that the bus now serves
11
+ * multiple consumers (bridge, agent-runtime, future SLM server). Event
12
+ * `type` strings (wire format) are unchanged.
13
+ *
14
+ * Design: DR-15 compliant — domains accept the port via injection.
15
+ * The composition root (server-entry.ts in bridge) creates the bus, registers
16
+ * sinks, and injects the bus into domains.
17
+ */
18
+ /**
19
+ * Domain classification for events. Extensible — new domains can be added
20
+ * without modifying this type. The union is a type-level hint, not a runtime enum.
21
+ * The `(string & {})` escape hatch keeps this neutral across downstream consumers.
22
+ */
23
+ export type EventDomain = 'session' | 'strategy' | 'trigger' | 'project' | 'methodology' | 'system' | 'agent' | (string & {});
24
+ export type EventSeverity = 'info' | 'warning' | 'error' | 'critical';
25
+ /**
26
+ * Canonical event shape for the entire runtime. Every domain event is expressed
27
+ * as a RuntimeEvent. Bus assigns id, timestamp, and sequence on emit.
28
+ *
29
+ * Renamed from `BridgeEvent` per PRD-057 / S2 §4. A back-compat alias lives in
30
+ * `@methodts/bridge/ports/event-bus.ts`.
31
+ */
32
+ export interface RuntimeEvent {
33
+ /** UUID, globally unique. Assigned by the bus. */
34
+ id: string;
35
+ /** Schema version for future evolution. */
36
+ version: 1;
37
+ /** ISO 8601 timestamp. Assigned by the bus. */
38
+ timestamp: string;
39
+ /** Monotonic sequence number. Assigned by the bus. */
40
+ sequence: number;
41
+ /** Which domain produced this event. */
42
+ domain: EventDomain;
43
+ /** Domain-owned type string (e.g., 'session.spawned', 'strategy.gate_failed'). */
44
+ type: string;
45
+ /** Event severity level. */
46
+ severity: EventSeverity;
47
+ /** Which project this event belongs to (if applicable). */
48
+ projectId?: string;
49
+ /** Which session produced this event (if applicable). */
50
+ sessionId?: string;
51
+ /** Domain-specific data. */
52
+ payload: Record<string, unknown>;
53
+ /** Which component emitted (e.g., 'bridge/sessions/pool', 'runtime/event-bus/persistence-sink'). */
54
+ source: string;
55
+ /** Links related events (e.g., all events from one strategy execution). */
56
+ correlationId?: string;
57
+ /** Originating bridge node ID (set when event is federated from another bridge). */
58
+ sourceNodeId?: string;
59
+ /** True if this event was received from another bridge via cluster federation. */
60
+ federated?: boolean;
61
+ }
62
+ /**
63
+ * Input to EventBus.emit() — bus-assigned fields (id, timestamp, sequence)
64
+ * are omitted since the bus fills them in.
65
+ *
66
+ * Renamed from `BridgeEventInput` per PRD-057 / S2 §4.
67
+ */
68
+ export type RuntimeEventInput = Omit<RuntimeEvent, 'id' | 'timestamp' | 'sequence'>;
69
+ export interface EventFilter {
70
+ domain?: EventDomain | EventDomain[];
71
+ /** Glob-style patterns: 'session.*', 'strategy.gate_*'. */
72
+ type?: string | string[];
73
+ projectId?: string;
74
+ sessionId?: string;
75
+ severity?: EventSeverity | EventSeverity[];
76
+ }
77
+ export interface EventSubscription {
78
+ unsubscribe: () => void;
79
+ }
80
+ /**
81
+ * A sink receives all events from the bus. Sinks are registered in
82
+ * the composition root — no domain registers sinks directly.
83
+ */
84
+ export interface EventSink {
85
+ name: string;
86
+ onEvent(event: RuntimeEvent): void | Promise<void>;
87
+ onError?: (error: Error, event: RuntimeEvent) => void;
88
+ }
89
+ /**
90
+ * Health status for a connector.
91
+ */
92
+ export interface ConnectorHealth {
93
+ connected: boolean;
94
+ lastEventAt: string | null;
95
+ errorCount: number;
96
+ }
97
+ /**
98
+ * An EventConnector extends EventSink with lifecycle management for
99
+ * long-lived external connections (webhooks, Slack, external APIs).
100
+ *
101
+ * Connectors manage their own retry/backoff. The composition root
102
+ * calls connect() after registration and disconnect() on shutdown.
103
+ */
104
+ export interface EventConnector extends EventSink {
105
+ /** Establish connection to the external system. */
106
+ connect(): Promise<void>;
107
+ /** Graceful teardown. */
108
+ disconnect(): Promise<void>;
109
+ /** Current health status. */
110
+ health(): ConnectorHealth;
111
+ }
112
+ /**
113
+ * Payload shape for domain='strategy', type='gate.awaiting_approval'.
114
+ * Emitted by bridge/strategies when a human_approval gate fires and the
115
+ * executor suspends waiting for a human decision.
116
+ */
117
+ export interface StrategyGateAwaitingApprovalPayload {
118
+ strategy_id: string;
119
+ execution_id: string;
120
+ gate_id: string;
121
+ node_id: string;
122
+ /** GlyphJS markdown to display in the dashboard (surface contract, PRD excerpt, etc.) */
123
+ artifact_markdown: string;
124
+ artifact_type: 'surface_record' | 'prd' | 'plan' | 'review_report' | 'custom';
125
+ /** Milliseconds before oversight escalation fires. */
126
+ timeout_ms: number;
127
+ }
128
+ /**
129
+ * Payload shape for domain='strategy', type='gate.approval_response'.
130
+ * Sent by the frontend dashboard to resume a suspended human_approval gate.
131
+ */
132
+ export interface StrategyGateApprovalResponsePayload {
133
+ execution_id: string;
134
+ gate_id: string;
135
+ decision: 'approved' | 'rejected' | 'changes_requested';
136
+ /** Passed as retry context when decision is rejected or changes_requested. */
137
+ feedback?: string;
138
+ }
139
+ /**
140
+ * Port interface for the Universal Event Bus.
141
+ *
142
+ * - emit(): non-blocking, bus assigns id/timestamp/sequence. No sink failure blocks emit.
143
+ * - subscribe(): filter-based subscription for in-process consumers.
144
+ * - query(): historical query (requires persistence sink).
145
+ * - registerSink(): register a sink to receive all events.
146
+ */
147
+ export interface EventBus {
148
+ /**
149
+ * Emit an event to all subscribers and sinks.
150
+ * Bus assigns id, timestamp, and sequence. Non-blocking.
151
+ */
152
+ emit(event: RuntimeEventInput): RuntimeEvent;
153
+ /**
154
+ * Import a pre-existing event (e.g., from replay) without reassigning
155
+ * id, timestamp, or sequence. Pushes to ring buffer and dispatches to
156
+ * sinks/subscribers. Updates internal sequence counter to avoid collisions.
157
+ */
158
+ importEvent(event: RuntimeEvent): void;
159
+ /** Subscribe to events matching a filter. */
160
+ subscribe(filter: EventFilter, handler: (event: RuntimeEvent) => void): EventSubscription;
161
+ /** Query past events from the ring buffer. */
162
+ query(filter: EventFilter, options?: {
163
+ limit?: number;
164
+ since?: string;
165
+ }): RuntimeEvent[];
166
+ /** Register a sink that receives all events. */
167
+ registerSink(sink: EventSink): void;
168
+ }
169
+ //# sourceMappingURL=event-bus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-bus.d.ts","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EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,mCAAmC;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,UAAU,GAAG,UAAU,GAAG,mBAAmB,CAAC;IACxD,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAID;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CAAC;IAE7C;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAEvC,6CAA6C;IAC7C,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,iBAAiB,CAAC;IAE1F,8CAA8C;IAC9C,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,YAAY,EAAE,CAAC;IAEzF,gDAAgD;IAChD,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;CACrC"}
@@ -0,0 +1,20 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * EventBus — Port interface for the Universal Event Bus (PRD 026).
4
+ *
5
+ * The event bus is runtime-level infrastructure. Domains emit typed events
6
+ * through the port. Consumers (WebSocket, persistence, Genesis, parent agents)
7
+ * subscribe through the same interface. Neither producers nor consumers
8
+ * know about each other.
9
+ *
10
+ * PRD-057: Moved from @methodts/bridge/ports/event-bus.ts. The type was
11
+ * renamed `BridgeEvent` → `RuntimeEvent` to reflect that the bus now serves
12
+ * multiple consumers (bridge, agent-runtime, future SLM server). Event
13
+ * `type` strings (wire format) are unchanged.
14
+ *
15
+ * Design: DR-15 compliant — domains accept the port via injection.
16
+ * The composition root (server-entry.ts in bridge) creates the bus, registers
17
+ * sinks, and injects the bus into domains.
18
+ */
19
+ export {};
20
+ //# sourceMappingURL=event-bus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../src/ports/event-bus.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;;;;;;;;;;;;;;GAgBG"}