@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,200 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * EventBusHumanApprovalResolver — Unit tests (F-L-1).
4
+ *
5
+ * Validates the EventBus-backed approval resolution logic:
6
+ * - Matching response resolves approved
7
+ * - Rejection with feedback
8
+ * - Timeout fires when no response arrives
9
+ * - Mismatched execution_id is ignored (falls through to timeout)
10
+ * - Emit failure does not abort the subscription wait
11
+ *
12
+ * PRD-057 / S2 §3.2 / C2: moved from @methodts/bridge/domains/strategies/.
13
+ * The test uses a tiny inline EventBus so it stays runnable without
14
+ * depending on @methodts/runtime/event-bus (which lands in C3).
15
+ */
16
+ import { describe, it } from 'node:test';
17
+ import assert from 'node:assert/strict';
18
+ import { randomUUID } from 'node:crypto';
19
+ import { EventBusHumanApprovalResolver } from './human-approval-resolver.js';
20
+ // ── Tiny in-memory EventBus for runtime-local tests ─────────────
21
+ class TinyEventBus {
22
+ subs = [];
23
+ sinks = [];
24
+ seq = 0;
25
+ emit(input) {
26
+ const event = {
27
+ ...input,
28
+ id: randomUUID(),
29
+ version: 1,
30
+ timestamp: new Date().toISOString(),
31
+ sequence: ++this.seq,
32
+ };
33
+ for (const sink of this.sinks) {
34
+ try {
35
+ void sink.onEvent(event);
36
+ }
37
+ catch { /* swallow */ }
38
+ }
39
+ for (const sub of this.subs) {
40
+ if (this.matches(event, sub.filter)) {
41
+ try {
42
+ sub.handler(event);
43
+ }
44
+ catch { /* swallow */ }
45
+ }
46
+ }
47
+ return event;
48
+ }
49
+ importEvent(event) {
50
+ if (event.sequence > this.seq)
51
+ this.seq = event.sequence;
52
+ for (const sink of this.sinks) {
53
+ try {
54
+ void sink.onEvent(event);
55
+ }
56
+ catch { /* swallow */ }
57
+ }
58
+ for (const sub of this.subs) {
59
+ if (this.matches(event, sub.filter)) {
60
+ try {
61
+ sub.handler(event);
62
+ }
63
+ catch { /* swallow */ }
64
+ }
65
+ }
66
+ }
67
+ subscribe(filter, handler) {
68
+ const entry = { filter, handler };
69
+ this.subs.push(entry);
70
+ return {
71
+ unsubscribe: () => {
72
+ const idx = this.subs.indexOf(entry);
73
+ if (idx !== -1)
74
+ this.subs.splice(idx, 1);
75
+ },
76
+ };
77
+ }
78
+ query() { return []; }
79
+ registerSink(sink) { this.sinks.push(sink); }
80
+ matches(event, filter) {
81
+ if (filter.domain !== undefined) {
82
+ const ds = Array.isArray(filter.domain) ? filter.domain : [filter.domain];
83
+ if (!ds.includes(event.domain))
84
+ return false;
85
+ }
86
+ if (filter.type !== undefined) {
87
+ const ts = Array.isArray(filter.type) ? filter.type : [filter.type];
88
+ if (!ts.includes(event.type))
89
+ return false;
90
+ }
91
+ return true;
92
+ }
93
+ }
94
+ // ── Helpers ──────────────────────────────────────────────────────
95
+ function makeCtx(overrides = {}) {
96
+ return {
97
+ strategy_id: 'test-strategy',
98
+ execution_id: 'exec-001',
99
+ gate_id: 'gate-001',
100
+ node_id: 'node-001',
101
+ timeout_ms: 5000,
102
+ ...overrides,
103
+ };
104
+ }
105
+ function makeApprovalResponse(executionId, gateId, decision, feedback) {
106
+ return {
107
+ version: 1,
108
+ domain: 'strategy',
109
+ type: 'gate.approval_response',
110
+ severity: 'info',
111
+ payload: {
112
+ execution_id: executionId,
113
+ gate_id: gateId,
114
+ decision,
115
+ ...(feedback ? { feedback } : {}),
116
+ },
117
+ source: 'test',
118
+ };
119
+ }
120
+ // ── Helpers for timeout-based tests ──────────────────────────────
121
+ // The resolver calls .unref() on its internal timer so it won't keep
122
+ // a production server alive. In tests we need the event loop to stay
123
+ // alive until the timeout fires, so we create a short ref'd keepalive.
124
+ function withKeepAlive(ms, fn) {
125
+ return new Promise((resolve, reject) => {
126
+ const keepAlive = setTimeout(() => { }, ms + 500);
127
+ fn().then((v) => { clearTimeout(keepAlive); resolve(v); }, (e) => { clearTimeout(keepAlive); reject(e); });
128
+ });
129
+ }
130
+ // ── Tests ────────────────────────────────────────────────────────
131
+ describe('EventBusHumanApprovalResolver', () => {
132
+ it('matching response resolves approved', async () => {
133
+ const bus = new TinyEventBus();
134
+ const resolver = new EventBusHumanApprovalResolver(bus);
135
+ const ctx = makeCtx();
136
+ const promise = resolver.requestApproval(ctx);
137
+ // Emit a matching approval response
138
+ bus.emit(makeApprovalResponse('exec-001', 'gate-001', 'approved'));
139
+ const result = await promise;
140
+ assert.deepStrictEqual(result, { approved: true });
141
+ });
142
+ it('rejection with feedback', async () => {
143
+ const bus = new TinyEventBus();
144
+ const resolver = new EventBusHumanApprovalResolver(bus);
145
+ const ctx = makeCtx();
146
+ const promise = resolver.requestApproval(ctx);
147
+ bus.emit(makeApprovalResponse('exec-001', 'gate-001', 'rejected', 'needs work'));
148
+ const result = await promise;
149
+ assert.deepStrictEqual(result, { approved: false, feedback: 'needs work' });
150
+ });
151
+ it('timeout fires when no response arrives', async () => {
152
+ const result = await withKeepAlive(200, async () => {
153
+ const bus = new TinyEventBus();
154
+ const resolver = new EventBusHumanApprovalResolver(bus);
155
+ const ctx = makeCtx({ timeout_ms: 50 });
156
+ return resolver.requestApproval(ctx);
157
+ });
158
+ assert.deepStrictEqual(result, { approved: false, feedback: 'Human approval timed out' });
159
+ });
160
+ it('mismatched execution_id is ignored — falls through to timeout', async () => {
161
+ const result = await withKeepAlive(300, async () => {
162
+ const bus = new TinyEventBus();
163
+ const resolver = new EventBusHumanApprovalResolver(bus);
164
+ const ctx = makeCtx({ timeout_ms: 100 });
165
+ const promise = resolver.requestApproval(ctx);
166
+ // Emit a response with wrong execution_id — should be ignored
167
+ bus.emit(makeApprovalResponse('wrong-exec-id', 'gate-001', 'approved'));
168
+ return promise;
169
+ });
170
+ assert.deepStrictEqual(result, { approved: false, feedback: 'Human approval timed out' });
171
+ });
172
+ it('emit failure does not abort the subscription wait', async () => {
173
+ const result = await withKeepAlive(500, async () => {
174
+ const bus = new TinyEventBus();
175
+ const resolver = new EventBusHumanApprovalResolver(bus);
176
+ // Sabotage emit by making it throw after the subscription is set up.
177
+ // The resolver subscribes BEFORE emitting, so we override emit to throw
178
+ // only on the awaiting_approval event (the one the resolver emits).
179
+ const originalEmit = bus.emit.bind(bus);
180
+ let emitCallCount = 0;
181
+ bus.emit = (input) => {
182
+ emitCallCount++;
183
+ if (input.type === 'gate.awaiting_approval') {
184
+ throw new Error('Simulated emit failure');
185
+ }
186
+ return originalEmit(input);
187
+ };
188
+ const ctx = makeCtx({ timeout_ms: 200 });
189
+ const promise = resolver.requestApproval(ctx);
190
+ assert.equal(emitCallCount, 1, 'emit should have been called once (and thrown)');
191
+ // Restore emit so we can deliver the response
192
+ bus.emit = originalEmit;
193
+ // The subscription was set up before emit, so it should still work
194
+ bus.emit(makeApprovalResponse('exec-001', 'gate-001', 'approved'));
195
+ return promise;
196
+ });
197
+ assert.deepStrictEqual(result, { approved: true });
198
+ });
199
+ });
200
+ //# sourceMappingURL=human-approval-resolver.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"human-approval-resolver.test.js","sourceRoot":"","sources":["../../src/strategy/human-approval-resolver.test.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAA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AC,IAAI,GAAG,YAAY,CAAC;YAExB,mEAAmE;YACnE,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;YAEnE,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * InProcessCrossAppInvoker — in-memory simulator for the CrossAppInvoker port.
3
+ *
4
+ * PRD-067 Track A (Wave 0 §8): ships with this PR so multi-app strategy DAGs
5
+ * can be exercised in tests + single-process demos without waiting for Cortex
6
+ * PRD-080 (`🔜 deferred`, Wave 5). Swapping the simulator for the live
7
+ * CortexCrossAppInvoker is a single composition-root line change once
8
+ * PRD-080 thaws.
9
+ *
10
+ * The simulator:
11
+ * - Maps `targetAppId → { operation → handler }` via an in-memory registry
12
+ * - Dispatches synchronously in-process (no SQS, no HTTP, no real auth)
13
+ * - Enforces the same delegation-depth cap as the live adapter
14
+ * - Enforces a caller-side allowlist mirrored from `requires.apps[]`
15
+ * - Honors `idempotencyKey` by caching the first result per key
16
+ * - Generates synthetic `decisionId`s + wall-clock `latencyMs`
17
+ * - Captures target handler throws as `CrossAppTargetError` (so the caller's
18
+ * strategy gate machinery resolves them as node failures — see G-FAILURE-ISOLATION)
19
+ *
20
+ * Owner: @methodts/runtime (simulator lives next to the port for discoverability)
21
+ * Producer: tests + single-process demos wire this at the composition root
22
+ * Consumer: DagStrategyExecutor (via the CrossAppInvoker port)
23
+ *
24
+ * NOTE: this is a SIMULATOR — it does not exercise token exchange, audit
25
+ * correlation against a real Cortex audit stream, cost metering against a
26
+ * real `ctx.llm` reservation, or health-propagation from PRD-077. Those all
27
+ * require the live CortexCrossAppInvoker (Track B, blocked on PRD-080).
28
+ */
29
+ import { type CrossAppInvokeRequest, type CrossAppInvokeResult, type CrossAppInvoker, type CrossAppInvokerCapabilities } from '../ports/cross-app-invoker.js';
30
+ /** A registered target-app operation handler.
31
+ *
32
+ * Handlers are synchronous-or-async functions receiving the input payload +
33
+ * metadata about the caller; they return the operation's output. Throws are
34
+ * captured by the invoker and surfaced as `CrossAppTargetError` (failure
35
+ * isolation — see PRD-067 §9 G-FAILURE-ISOLATION).
36
+ */
37
+ export type InProcessCrossAppHandler<Input = unknown, Output = unknown> = (input: Input, meta: {
38
+ readonly targetAppId: string;
39
+ readonly operation: string;
40
+ readonly targetDecisionId: string;
41
+ readonly callerSessionId: string;
42
+ readonly callerNodeId: string;
43
+ readonly delegation: CrossAppInvokeRequest<Input>['delegation'];
44
+ }) => Output | Promise<Output>;
45
+ /** Options controlling the simulator's behavior. */
46
+ export interface InProcessCrossAppInvokerOptions {
47
+ /** Max RFC 8693 delegation depth the simulator will accept before rejecting.
48
+ * Defaults to `CROSS_APP_DEFAULT_MAX_DELEGATION_DEPTH` (= 2, matching
49
+ * PRD-061/PRD-080). Tests may lower this to exercise the cap. */
50
+ readonly maxDelegationDepth?: number;
51
+ /** Simulated caller-side cost (USD) attributed to each dispatch. Default 0
52
+ * — tests may override to inspect budget accounting. */
53
+ readonly simulatedCallerCostUsd?: number;
54
+ /** When set, `capabilities().allowedTargetAppIds` returns this set exactly —
55
+ * overriding the default behavior of deriving it from the registered app
56
+ * ids. Use this to model a manifest that declares more apps than have
57
+ * been registered yet (or fewer, for negative tests). */
58
+ readonly allowedTargetAppIdsOverride?: ReadonlySet<string>;
59
+ /** Clock shim — injected for deterministic latency in tests. Defaults to
60
+ * `Date.now`. */
61
+ readonly now?: () => number;
62
+ /** Decision id generator — defaults to a monotonic counter so tests see
63
+ * stable synthetic ids. Supply `crypto.randomUUID` for realism. */
64
+ readonly nextDecisionId?: () => string;
65
+ }
66
+ /** In-memory `CrossAppInvoker` implementation for tests + single-process demos.
67
+ *
68
+ * Usage:
69
+ * ```ts
70
+ * const invoker = new InProcessCrossAppInvoker();
71
+ * invoker.registerApp('feature-dev-agent', {
72
+ * commission_fix: async (input, meta) => ({ pr_url: '...', effort: 'S' }),
73
+ * });
74
+ * // Pass invoker to the strategy executor at the composition root.
75
+ * ```
76
+ */
77
+ export declare class InProcessCrossAppInvoker implements CrossAppInvoker {
78
+ private readonly apps;
79
+ private readonly idempotencyCache;
80
+ private readonly maxDelegationDepth;
81
+ private readonly simulatedCallerCostUsd;
82
+ private readonly allowedTargetAppIdsOverride;
83
+ private readonly now;
84
+ private readonly nextDecisionId;
85
+ private decisionCounter;
86
+ constructor(options?: InProcessCrossAppInvokerOptions);
87
+ /**
88
+ * Register a simulated target app with one-or-more operation handlers.
89
+ *
90
+ * Calling `registerApp` twice with the same `appId` merges the handler
91
+ * tables — the second call's handlers override any colliding operation
92
+ * names. This makes test setup incremental without forcing callers to
93
+ * rebuild the whole app each time.
94
+ */
95
+ registerApp(appId: string, operations: Readonly<Record<string, InProcessCrossAppHandler<never, unknown>>>): void;
96
+ /** Remove a registered app. Returns true if something was removed. */
97
+ unregisterApp(appId: string): boolean;
98
+ /** Clear the idempotency cache — useful between tests. */
99
+ clearIdempotencyCache(): void;
100
+ /** List all registered app ids. Sorted for stable output in diagnostics. */
101
+ listRegisteredAppIds(): readonly string[];
102
+ capabilities(): CrossAppInvokerCapabilities;
103
+ invoke<Input = unknown, Output = unknown>(request: CrossAppInvokeRequest<Input>): Promise<CrossAppInvokeResult<Output>>;
104
+ }
105
+ //# sourceMappingURL=in-process-cross-app-invoker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-process-cross-app-invoker.d.ts","sourceRoot":"","sources":["../../src/strategy/in-process-cross-app-invoker.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAGjC,MAAM,+BA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CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAe;IAC9C,OAAO,CAAC,eAAe,CAAK;gBAEhB,OAAO,GAAE,+BAAoC;IAezD;;;;;;;OAOG;IACH,WAAW,CACT,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,QAAQ,CAClB,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CACzD,GACA,IAAI;IAcP,sEAAsE;IACtE,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIrC,0DAA0D;IAC1D,qBAAqB,IAAI,IAAI;IAI7B,4EAA4E;IAC5E,oBAAoB,IAAI,SAAS,MAAM,EAAE;IAIzC,YAAY,IAAI,2BAA2B;IAWrC,MAAM,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EAC5C,OAAO,EAAE,qBAAqB,CAAC,KAAK,CAAC,GACpC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;CAqHzC"}
@@ -0,0 +1,206 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * InProcessCrossAppInvoker — in-memory simulator for the CrossAppInvoker port.
4
+ *
5
+ * PRD-067 Track A (Wave 0 §8): ships with this PR so multi-app strategy DAGs
6
+ * can be exercised in tests + single-process demos without waiting for Cortex
7
+ * PRD-080 (`🔜 deferred`, Wave 5). Swapping the simulator for the live
8
+ * CortexCrossAppInvoker is a single composition-root line change once
9
+ * PRD-080 thaws.
10
+ *
11
+ * The simulator:
12
+ * - Maps `targetAppId → { operation → handler }` via an in-memory registry
13
+ * - Dispatches synchronously in-process (no SQS, no HTTP, no real auth)
14
+ * - Enforces the same delegation-depth cap as the live adapter
15
+ * - Enforces a caller-side allowlist mirrored from `requires.apps[]`
16
+ * - Honors `idempotencyKey` by caching the first result per key
17
+ * - Generates synthetic `decisionId`s + wall-clock `latencyMs`
18
+ * - Captures target handler throws as `CrossAppTargetError` (so the caller's
19
+ * strategy gate machinery resolves them as node failures — see G-FAILURE-ISOLATION)
20
+ *
21
+ * Owner: @methodts/runtime (simulator lives next to the port for discoverability)
22
+ * Producer: tests + single-process demos wire this at the composition root
23
+ * Consumer: DagStrategyExecutor (via the CrossAppInvoker port)
24
+ *
25
+ * NOTE: this is a SIMULATOR — it does not exercise token exchange, audit
26
+ * correlation against a real Cortex audit stream, cost metering against a
27
+ * real `ctx.llm` reservation, or health-propagation from PRD-077. Those all
28
+ * require the live CortexCrossAppInvoker (Track B, blocked on PRD-080).
29
+ */
30
+ import { CROSS_APP_DEFAULT_MAX_DELEGATION_DEPTH, CrossAppDelegationDepthExceededError, CrossAppTargetError, CrossAppTargetUnknownError, } from '../ports/cross-app-invoker.js';
31
+ /** In-memory `CrossAppInvoker` implementation for tests + single-process demos.
32
+ *
33
+ * Usage:
34
+ * ```ts
35
+ * const invoker = new InProcessCrossAppInvoker();
36
+ * invoker.registerApp('feature-dev-agent', {
37
+ * commission_fix: async (input, meta) => ({ pr_url: '...', effort: 'S' }),
38
+ * });
39
+ * // Pass invoker to the strategy executor at the composition root.
40
+ * ```
41
+ */
42
+ export class InProcessCrossAppInvoker {
43
+ apps = new Map();
44
+ idempotencyCache = new Map();
45
+ maxDelegationDepth;
46
+ simulatedCallerCostUsd;
47
+ allowedTargetAppIdsOverride;
48
+ now;
49
+ nextDecisionId;
50
+ decisionCounter = 0;
51
+ constructor(options = {}) {
52
+ this.maxDelegationDepth =
53
+ options.maxDelegationDepth ?? CROSS_APP_DEFAULT_MAX_DELEGATION_DEPTH;
54
+ this.simulatedCallerCostUsd = options.simulatedCallerCostUsd ?? 0;
55
+ this.allowedTargetAppIdsOverride =
56
+ options.allowedTargetAppIdsOverride ?? null;
57
+ this.now = options.now ?? (() => Date.now());
58
+ this.nextDecisionId =
59
+ options.nextDecisionId ??
60
+ (() => {
61
+ this.decisionCounter += 1;
62
+ return `in-proc-decision-${this.decisionCounter.toString(36)}`;
63
+ });
64
+ }
65
+ /**
66
+ * Register a simulated target app with one-or-more operation handlers.
67
+ *
68
+ * Calling `registerApp` twice with the same `appId` merges the handler
69
+ * tables — the second call's handlers override any colliding operation
70
+ * names. This makes test setup incremental without forcing callers to
71
+ * rebuild the whole app each time.
72
+ */
73
+ registerApp(appId, operations) {
74
+ const existing = this.apps.get(appId);
75
+ const next = existing ?? {
76
+ operations: new Map(),
77
+ };
78
+ for (const [op, handler] of Object.entries(operations)) {
79
+ // Cast: the handler's declared Input is `never` to accept any input at
80
+ // the registry boundary; runtime shape is the target operation's
81
+ // responsibility.
82
+ next.operations.set(op, handler);
83
+ }
84
+ this.apps.set(appId, next);
85
+ }
86
+ /** Remove a registered app. Returns true if something was removed. */
87
+ unregisterApp(appId) {
88
+ return this.apps.delete(appId);
89
+ }
90
+ /** Clear the idempotency cache — useful between tests. */
91
+ clearIdempotencyCache() {
92
+ this.idempotencyCache.clear();
93
+ }
94
+ /** List all registered app ids. Sorted for stable output in diagnostics. */
95
+ listRegisteredAppIds() {
96
+ return [...this.apps.keys()].sort();
97
+ }
98
+ capabilities() {
99
+ const allowedTargetAppIds = this.allowedTargetAppIdsOverride ??
100
+ new Set(this.apps.keys());
101
+ return {
102
+ enabled: true,
103
+ maxDelegationDepth: this.maxDelegationDepth,
104
+ allowedTargetAppIds,
105
+ };
106
+ }
107
+ async invoke(request) {
108
+ // Depth cap first — cheapest to reject.
109
+ if (request.delegation.currentDepth >= this.maxDelegationDepth) {
110
+ throw new CrossAppDelegationDepthExceededError(request.delegation.currentDepth, this.maxDelegationDepth);
111
+ }
112
+ // Allowlist check. Skipped when the capabilities set is explicitly empty
113
+ // AND no override was provided (i.e. no apps registered yet) — in that
114
+ // case the target lookup below throws `CrossAppTargetUnknownError`
115
+ // which carries better diagnostics for the simulator case.
116
+ const allowed = this.allowedTargetAppIdsOverride ??
117
+ new Set(this.apps.keys());
118
+ if (this.allowedTargetAppIdsOverride !== null &&
119
+ !allowed.has(request.targetAppId)) {
120
+ // Override present and target not in it → fail as unknown (the
121
+ // simulator's idiomatic error for this case; compose-time enforcement
122
+ // lives in `assertCrossAppTargetsAllowed`).
123
+ throw new CrossAppTargetUnknownError(request.targetAppId, request.operation, [...allowed].sort());
124
+ }
125
+ // Idempotency short-circuit: same (target, op, key) → return first result.
126
+ const idempotencyCacheKey = request.idempotencyKey
127
+ ? `${request.targetAppId}::${request.operation}::${request.idempotencyKey}`
128
+ : null;
129
+ if (idempotencyCacheKey !== null) {
130
+ const cached = this.idempotencyCache.get(idempotencyCacheKey);
131
+ if (cached) {
132
+ return cached.result;
133
+ }
134
+ }
135
+ // Lookup target app + operation.
136
+ const app = this.apps.get(request.targetAppId);
137
+ if (!app) {
138
+ throw new CrossAppTargetUnknownError(request.targetAppId, request.operation, this.listRegisteredAppIds());
139
+ }
140
+ const handler = app.operations.get(request.operation);
141
+ if (!handler) {
142
+ throw new CrossAppTargetUnknownError(request.targetAppId, request.operation, this.listRegisteredAppIds());
143
+ }
144
+ const targetDecisionId = this.nextDecisionId();
145
+ const startedAt = this.now();
146
+ // Optional timeout — if the handler runs longer than timeoutMs, surface
147
+ // as a target error (mirrors how the live adapter would surface an HTTP
148
+ // timeout).
149
+ const invocation = Promise.resolve().then(() => handler(request.input, {
150
+ targetAppId: request.targetAppId,
151
+ operation: request.operation,
152
+ targetDecisionId,
153
+ callerSessionId: request.caller.sessionId,
154
+ callerNodeId: request.caller.nodeId,
155
+ delegation: request.delegation,
156
+ }));
157
+ let rawOutput;
158
+ try {
159
+ if (request.timeoutMs !== undefined && request.timeoutMs > 0) {
160
+ rawOutput = await withTimeout(invocation, request.timeoutMs, request.targetAppId, request.operation);
161
+ }
162
+ else {
163
+ rawOutput = await invocation;
164
+ }
165
+ }
166
+ catch (cause) {
167
+ // Failure isolation (G-FAILURE-ISOLATION): wrap the throw so the
168
+ // strategy executor sees a typed, caller-local error. The executor's
169
+ // gate/retry machinery resolves this as a node failure; it never
170
+ // propagates as an unhandled exception.
171
+ throw new CrossAppTargetError(request.targetAppId, request.operation, targetDecisionId, cause);
172
+ }
173
+ const latencyMs = Math.max(0, this.now() - startedAt);
174
+ const result = {
175
+ output: rawOutput,
176
+ targetDecisionId,
177
+ latencyMs,
178
+ callerCostUsd: this.simulatedCallerCostUsd,
179
+ };
180
+ if (idempotencyCacheKey !== null) {
181
+ this.idempotencyCache.set(idempotencyCacheKey, {
182
+ result: result,
183
+ });
184
+ }
185
+ return result;
186
+ }
187
+ }
188
+ async function withTimeout(promise, timeoutMs, targetAppId, operation) {
189
+ let timer;
190
+ const timeout = new Promise((_, reject) => {
191
+ timer = setTimeout(() => {
192
+ reject(new Error(`Cross-app invocation to "${targetAppId}.${operation}" timed out after ${timeoutMs}ms`));
193
+ }, timeoutMs);
194
+ if (timer && typeof timer === 'object' && 'unref' in timer) {
195
+ timer.unref();
196
+ }
197
+ });
198
+ try {
199
+ return await Promise.race([promise, timeout]);
200
+ }
201
+ finally {
202
+ if (timer !== undefined)
203
+ clearTimeout(timer);
204
+ }
205
+ }
206
+ //# sourceMappingURL=in-process-cross-app-invoker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-process-cross-app-invoker.js","sourceRoot":"","sources":["../../src/strategy/in-process-cross-app-invoker.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,sCAAsC,EACtC,oCAAoC,EAKpC,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AAuDvC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,wBAAwB;IAClB,IAAI,GAAG,IAAI,GAAG,EAAyB,CAAC;IACxC,gBAAgB,GAAG,IAAI,GAAG,EAA6B,CAAC;IACxD,kBAAkB,CAAS;IAC3B,sBAAsB,CAAS;IAC/B,2BAA2B,CAA6B;IACxD,GAAG,CAAe;IAClB,cAAc,CAAe;IACtC,eAAe,GAAG,CAAC,CAAC;IAE5B,YAAY,UAA2C,EAAE;QACvD,IAAI,CA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AI,KAAgD,CAAC;IACrD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAC/C,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,MAAM,CACJ,IAAI,KAAK,CACP,4BAA4B,WAAW,IAAI,SAAS,qBAAqB,SAAS,IAAI,CACvF,CACF,CAAC;QACJ,CAAC,EAAE,SAAS,CAAC,CAAC;QACd,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC;YAC3D,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAChD,CAAC;YAAS,CAAC;QACT,IAAI,KAAK,KAAK,SAAS;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Tests for InProcessCrossAppInvoker (PRD-067 Track A simulator).
3
+ *
4
+ * Covers:
5
+ * - Basic register + invoke happy path
6
+ * - Idempotency caching
7
+ * - Depth-cap rejection (G-DELEGATION-DEPTH-CAP)
8
+ * - Unknown target app / operation (simulator analogue of allowlist failure)
9
+ * - Allowlist override (G-TARGET-ALLOWLIST)
10
+ * - Target handler throws → wrapped as CrossAppTargetError (G-FAILURE-ISOLATION)
11
+ * - capabilities() reports registered apps
12
+ * - assertCrossAppTargetsAllowed compose-time check
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=in-process-cross-app-invoker.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-process-cross-app-invoker.test.d.ts","sourceRoot":"","sources":["../../src/strategy/in-process-cross-app-invoker.test.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;GAYG"}