@swirls/looms 0.0.2 → 0.2.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 (375) hide show
  1. package/CHANGELOG.md +24 -2
  2. package/dist/actor/cell.d.ts +9 -4
  3. package/dist/actor/cell.js +7 -11
  4. package/dist/actor/host.d.ts +7 -3
  5. package/dist/actor/host.js +57 -33
  6. package/dist/actor/index.d.ts +1 -1
  7. package/dist/actor/index.js +1 -1
  8. package/dist/actor/routing.d.ts +12 -1
  9. package/dist/actor/routing.js +57 -51
  10. package/dist/agent/agent-session.d.ts +5 -0
  11. package/dist/agent/agent-session.js +270 -0
  12. package/dist/agent/debugger/agent-chat.d.ts +2 -0
  13. package/dist/agent/debugger/agent-chat.js +176 -0
  14. package/dist/agent/debugger/index.d.ts +5 -0
  15. package/dist/agent/debugger/index.js +19 -0
  16. package/dist/agent/debugger/summarize.d.ts +2 -0
  17. package/dist/agent/debugger/summarize.js +51 -0
  18. package/dist/agent/debugger/token-usage.d.ts +3 -0
  19. package/dist/agent/debugger/token-usage.js +11 -0
  20. package/dist/agent/definitions-store.d.ts +2 -3
  21. package/dist/agent/definitions-store.js +2 -4
  22. package/dist/agent/definitions.d.ts +47 -29
  23. package/dist/agent/definitions.js +39 -12
  24. package/dist/agent/effects.d.ts +359 -2
  25. package/dist/agent/effects.js +60 -34
  26. package/dist/agent/events.d.ts +175 -19
  27. package/dist/agent/events.js +45 -10
  28. package/dist/agent/index.d.ts +1 -0
  29. package/dist/agent/index.js +1 -0
  30. package/dist/agent/llm.d.ts +11 -2
  31. package/dist/agent/llm.js +13 -3
  32. package/dist/agent/module.d.ts +812 -78
  33. package/dist/agent/module.js +16 -4
  34. package/dist/agent/scope.d.ts +174 -18
  35. package/dist/agent/signals.d.ts +26 -1
  36. package/dist/agent/signals.js +79 -0
  37. package/dist/agent/threads.d.ts +3 -33
  38. package/dist/agent/threads.js +20 -25
  39. package/dist/agent/tool-schema.d.ts +1 -17
  40. package/dist/agent/tool-schema.js +3 -43
  41. package/dist/agent/types.d.ts +49 -4
  42. package/dist/agent/types.js +5 -5
  43. package/dist/ai-vercel/index.d.ts +1 -0
  44. package/dist/ai-vercel/index.js +1 -0
  45. package/dist/ai-vercel/messages.js +22 -7
  46. package/dist/ai-vercel/vercel-evaluator.d.ts +36 -0
  47. package/dist/ai-vercel/vercel-evaluator.js +73 -0
  48. package/dist/ai-vercel/vercel-llm.js +64 -44
  49. package/dist/approval/debugger/approvals-view.d.ts +3 -0
  50. package/dist/approval/debugger/approvals-view.js +16 -0
  51. package/dist/approval/debugger/index.d.ts +4 -0
  52. package/dist/approval/debugger/index.js +11 -0
  53. package/dist/approval/debugger/summarize.d.ts +2 -0
  54. package/dist/approval/debugger/summarize.js +17 -0
  55. package/dist/approval/effects.d.ts +89 -0
  56. package/dist/approval/module.d.ts +179 -29
  57. package/dist/approval/projections.d.ts +0 -14
  58. package/dist/approval/projections.js +20 -3
  59. package/dist/approval/signals.d.ts +2 -0
  60. package/dist/approval/signals.js +18 -2
  61. package/dist/cli/cli.js +2 -0
  62. package/dist/cli/commands.js +12 -16
  63. package/dist/client/client.d.ts +1213 -18
  64. package/dist/client/client.js +120 -120
  65. package/dist/client/index.d.ts +1 -1
  66. package/dist/client/index.js +1 -1
  67. package/dist/client/sse.d.ts +13 -0
  68. package/dist/client/sse.js +38 -44
  69. package/dist/cloudflare/alarm-scheduler.d.ts +12 -2
  70. package/dist/cloudflare/alarm-scheduler.js +34 -7
  71. package/dist/cloudflare/durable-object.d.ts +10 -2
  72. package/dist/cloudflare/durable-object.js +59 -28
  73. package/dist/cloudflare/event-store.d.ts +7 -2
  74. package/dist/cloudflare/event-store.js +8 -7
  75. package/dist/cloudflare/index.d.ts +2 -2
  76. package/dist/cloudflare/index.js +2 -2
  77. package/dist/cloudflare/router.d.ts +1 -1
  78. package/dist/cloudflare/router.js +15 -16
  79. package/dist/core/catalog.d.ts +3 -3
  80. package/dist/core/catalog.js +2 -5
  81. package/dist/core/coalesce.js +5 -3
  82. package/dist/core/compose.d.ts +2 -1
  83. package/dist/core/compose.js +19 -2
  84. package/dist/core/debugger-host.d.ts +16 -0
  85. package/dist/core/debugger-host.js +1 -0
  86. package/dist/core/definition-store.d.ts +11 -0
  87. package/dist/core/definition-store.js +6 -0
  88. package/dist/core/effects.d.ts +127 -15
  89. package/dist/core/effects.js +89 -17
  90. package/dist/core/envelope.d.ts +27 -7
  91. package/dist/core/envelope.js +20 -6
  92. package/dist/core/event-codec.d.ts +4 -2
  93. package/dist/core/event-codec.js +10 -5
  94. package/dist/core/event-index.js +1 -3
  95. package/dist/core/fold.d.ts +3 -0
  96. package/dist/core/fold.js +171 -24
  97. package/dist/core/ids.d.ts +5 -0
  98. package/dist/core/ids.js +35 -2
  99. package/dist/core/index.d.ts +7 -1
  100. package/dist/core/index.js +6 -1
  101. package/dist/core/kind.d.ts +22 -0
  102. package/dist/core/kind.js +17 -0
  103. package/dist/core/limits.d.ts +34 -0
  104. package/dist/core/limits.js +46 -0
  105. package/dist/core/match.d.ts +1 -0
  106. package/dist/core/match.js +10 -1
  107. package/dist/core/module-scope.d.ts +22 -20
  108. package/dist/core/module-scope.js +38 -28
  109. package/dist/core/module.d.ts +18 -5
  110. package/dist/core/module.js +4 -0
  111. package/dist/core/projection.d.ts +13 -13
  112. package/dist/core/projection.js +9 -5
  113. package/dist/core/protocol.d.ts +68 -11
  114. package/dist/core/protocol.js +82 -11
  115. package/dist/core/published.d.ts +43 -0
  116. package/dist/core/published.js +44 -0
  117. package/dist/core/replay.d.ts +312 -3
  118. package/dist/core/replay.js +11 -1
  119. package/dist/core/schema.d.ts +11 -20
  120. package/dist/core/schema.js +63 -80
  121. package/dist/core/serialize.js +2 -4
  122. package/dist/core/snapshot-store.d.ts +6 -1
  123. package/dist/core/snapshot-store.js +15 -2
  124. package/dist/core/snapshots.d.ts +5 -1
  125. package/dist/core/snapshots.js +10 -15
  126. package/dist/core/sqlite-store.js +95 -11
  127. package/dist/core/state.d.ts +142 -4
  128. package/dist/core/state.js +78 -0
  129. package/dist/core/store.d.ts +38 -3
  130. package/dist/core/store.js +77 -22
  131. package/dist/core/thread.d.ts +10 -9
  132. package/dist/core/types.d.ts +5 -8
  133. package/dist/core/types.js +28 -24
  134. package/dist/core/validate-event.js +14 -4
  135. package/dist/core/worker-callback.d.ts +17 -0
  136. package/dist/core/worker-callback.js +1 -0
  137. package/dist/debugger/app/assets/index-B3Ah8WAE.css +2 -0
  138. package/dist/debugger/app/assets/index-Qb371t_O.js +22 -0
  139. package/dist/debugger/app/assets/rolldown-runtime-CbXtAM7H.js +1 -0
  140. package/dist/debugger/app/assets/routes-CjtEHgPQ.js +47 -0
  141. package/dist/debugger/app/index.html +14 -0
  142. package/dist/debugger/components/composer.d.ts +17 -0
  143. package/dist/debugger/components/composer.js +25 -0
  144. package/dist/debugger/components/debugger-split.d.ts +2 -1
  145. package/dist/debugger/components/debugger-split.js +2 -2
  146. package/dist/debugger/components/event-inspector.d.ts +2 -1
  147. package/dist/debugger/components/event-inspector.js +25 -16
  148. package/dist/debugger/components/event-stream.d.ts +2 -1
  149. package/dist/debugger/components/event-stream.js +14 -74
  150. package/dist/debugger/components/follow-list.d.ts +19 -0
  151. package/dist/debugger/components/follow-list.js +96 -0
  152. package/dist/debugger/components/json-tree.d.ts +11 -0
  153. package/dist/debugger/components/json-tree.js +120 -0
  154. package/dist/debugger/components/json-view.js +2 -2
  155. package/dist/debugger/components/run-tree.js +53 -20
  156. package/dist/debugger/components/status-dot.d.ts +4 -0
  157. package/dist/debugger/components/status-dot.js +6 -2
  158. package/dist/debugger/context.d.ts +14 -0
  159. package/dist/debugger/context.js +17 -0
  160. package/dist/debugger/contracts.d.ts +7 -4
  161. package/dist/debugger/events/builtin-families.d.ts +3 -0
  162. package/dist/debugger/events/builtin-families.js +9 -0
  163. package/dist/debugger/events/catalog.d.ts +3 -4
  164. package/dist/debugger/events/catalog.js +27 -17
  165. package/dist/debugger/events/protocol-summarize.d.ts +1 -2
  166. package/dist/debugger/events/protocol-summarize.js +42 -24
  167. package/dist/debugger/index.d.ts +20 -6
  168. package/dist/debugger/index.js +19 -5
  169. package/dist/debugger/lib/cn.d.ts +1 -0
  170. package/dist/debugger/lib/cn.js +3 -0
  171. package/dist/debugger/lib/event-meta.d.ts +2 -3
  172. package/dist/debugger/lib/event-meta.js +6 -12
  173. package/dist/debugger/lib/json.d.ts +25 -0
  174. package/dist/debugger/lib/json.js +87 -0
  175. package/dist/debugger/lib/payload.d.ts +7 -0
  176. package/dist/debugger/lib/payload.js +11 -0
  177. package/dist/debugger/lib/time.d.ts +3 -0
  178. package/dist/debugger/lib/time.js +24 -0
  179. package/dist/debugger/plugin.d.ts +36 -0
  180. package/dist/debugger/plugin.js +14 -0
  181. package/dist/debugger/server/index.d.ts +14 -0
  182. package/dist/debugger/server/index.js +114 -0
  183. package/dist/debugger/shell/debugger-shell.d.ts +15 -0
  184. package/dist/debugger/shell/debugger-shell.js +43 -0
  185. package/dist/debugger/shell/definition-key.d.ts +3 -0
  186. package/dist/debugger/shell/definition-key.js +4 -0
  187. package/dist/debugger/shell/events-pane.d.ts +12 -0
  188. package/dist/debugger/shell/events-pane.js +25 -0
  189. package/dist/debugger/shell/projections-panel.d.ts +4 -0
  190. package/dist/debugger/shell/projections-panel.js +59 -0
  191. package/dist/debugger/shell/run-controls.d.ts +4 -0
  192. package/dist/debugger/shell/run-controls.js +72 -0
  193. package/dist/debugger/shell/run-search.d.ts +6 -0
  194. package/dist/debugger/shell/run-search.js +102 -0
  195. package/dist/debugger/shell/run-type-menu.d.ts +6 -0
  196. package/dist/debugger/shell/run-type-menu.js +11 -0
  197. package/dist/debugger/shell/schema-form.d.ts +31 -0
  198. package/dist/debugger/shell/schema-form.js +117 -0
  199. package/dist/debugger/shell/start-form.d.ts +3 -0
  200. package/dist/debugger/shell/start-form.js +75 -0
  201. package/dist/debugger/shell/use-start-run.d.ts +14 -0
  202. package/dist/debugger/shell/use-start-run.js +32 -0
  203. package/dist/debugger/shell/workspace.d.ts +6 -0
  204. package/dist/debugger/shell/workspace.js +15 -0
  205. package/dist/debugger/styles.css +111 -27
  206. package/dist/debugger/ui/button.d.ts +24 -0
  207. package/dist/debugger/ui/button.js +24 -0
  208. package/dist/debugger/ui/command.d.ts +9 -0
  209. package/dist/debugger/ui/command.js +24 -0
  210. package/dist/debugger/ui/dropdown-menu.d.ts +13 -0
  211. package/dist/debugger/ui/dropdown-menu.js +37 -0
  212. package/dist/debugger/ui/panel.d.ts +14 -0
  213. package/dist/debugger/ui/panel.js +16 -0
  214. package/dist/debugger/ui/popover.d.ts +7 -0
  215. package/dist/debugger/ui/popover.js +17 -0
  216. package/dist/debugger/ui/resizable.d.ts +7 -0
  217. package/dist/debugger/ui/resizable.js +14 -0
  218. package/dist/debugger/ui/scroll-area.d.ts +2 -1
  219. package/dist/debugger/ui/scroll-area.js +5 -3
  220. package/dist/debugger/ui/select.d.ts +10 -0
  221. package/dist/debugger/ui/select.js +21 -0
  222. package/dist/debugger/ui/tabs.js +2 -2
  223. package/dist/debugger/ui/textarea.d.ts +3 -0
  224. package/dist/debugger/ui/textarea.js +7 -0
  225. package/dist/evaluator/definitions-store.d.ts +11 -0
  226. package/dist/evaluator/definitions-store.js +8 -0
  227. package/dist/evaluator/definitions.d.ts +18 -0
  228. package/dist/evaluator/definitions.js +4 -0
  229. package/dist/evaluator/effects.d.ts +226 -0
  230. package/dist/evaluator/effects.js +132 -0
  231. package/dist/evaluator/evaluator.d.ts +24 -0
  232. package/dist/evaluator/evaluator.js +67 -0
  233. package/dist/evaluator/events.d.ts +59 -0
  234. package/dist/evaluator/events.js +21 -0
  235. package/dist/evaluator/index.d.ts +11 -0
  236. package/dist/evaluator/index.js +11 -0
  237. package/dist/evaluator/module.d.ts +606 -0
  238. package/dist/evaluator/module.js +25 -0
  239. package/dist/evaluator/projections.d.ts +50 -0
  240. package/dist/evaluator/projections.js +20 -0
  241. package/dist/evaluator/scope.d.ts +59 -0
  242. package/dist/evaluator/scope.js +7 -0
  243. package/dist/evaluator/signals.d.ts +3 -0
  244. package/dist/evaluator/signals.js +17 -0
  245. package/dist/evaluator/threads.d.ts +62 -0
  246. package/dist/evaluator/threads.js +117 -0
  247. package/dist/evaluator/types.d.ts +125 -0
  248. package/dist/evaluator/types.js +51 -0
  249. package/dist/projectors/delivery.d.ts +83 -0
  250. package/dist/projectors/delivery.js +182 -0
  251. package/dist/projectors/index-model.d.ts +1 -1
  252. package/dist/projectors/index-model.js +4 -6
  253. package/dist/projectors/index.d.ts +2 -0
  254. package/dist/projectors/index.js +2 -0
  255. package/dist/projectors/memory.d.ts +1 -1
  256. package/dist/projectors/memory.js +10 -8
  257. package/dist/projectors/postgres.js +44 -58
  258. package/dist/projectors/projector.d.ts +17 -0
  259. package/dist/projectors/projector.js +26 -1
  260. package/dist/projectors/sqlite-delivery.d.ts +4 -0
  261. package/dist/projectors/sqlite-delivery.js +147 -0
  262. package/dist/projectors/sqlite.js +23 -23
  263. package/dist/projectors/with-projectors.d.ts +7 -2
  264. package/dist/projectors/with-projectors.js +27 -28
  265. package/dist/react/notify.js +11 -8
  266. package/dist/react/react.d.ts +2 -3
  267. package/dist/react/react.js +14 -30
  268. package/dist/react/sse.d.ts +1 -1
  269. package/dist/react/sse.js +1 -1
  270. package/dist/react/store.d.ts +3 -3
  271. package/dist/react/store.js +109 -119
  272. package/dist/runtime/cancellation.d.ts +16 -0
  273. package/dist/runtime/cancellation.js +129 -0
  274. package/dist/runtime/deadline-transition-planner.d.ts +31 -0
  275. package/dist/runtime/deadline-transition-planner.js +139 -0
  276. package/dist/runtime/dispatch-effect.d.ts +3 -2
  277. package/dist/runtime/dispatch-effect.js +7 -13
  278. package/dist/runtime/errors.d.ts +51 -0
  279. package/dist/runtime/errors.js +39 -0
  280. package/dist/runtime/{runtime-helpers.d.ts → helpers.d.ts} +24 -4
  281. package/dist/runtime/{runtime-helpers.js → helpers.js} +56 -19
  282. package/dist/runtime/index.d.ts +3 -3
  283. package/dist/runtime/index.js +3 -3
  284. package/dist/runtime/ingress.d.ts +15 -0
  285. package/dist/runtime/ingress.js +42 -0
  286. package/dist/runtime/local-effect-executor.d.ts +21 -0
  287. package/dist/runtime/local-effect-executor.js +137 -0
  288. package/dist/runtime/looms.d.ts +30 -4
  289. package/dist/runtime/looms.js +57 -37
  290. package/dist/runtime/observer.d.ts +45 -0
  291. package/dist/runtime/observer.js +11 -0
  292. package/dist/runtime/repository.d.ts +55 -0
  293. package/dist/runtime/repository.js +293 -0
  294. package/dist/runtime/retry-policy.d.ts +16 -0
  295. package/dist/runtime/retry-policy.js +29 -0
  296. package/dist/runtime/run-execution-context.d.ts +30 -0
  297. package/dist/runtime/run-execution-context.js +56 -0
  298. package/dist/runtime/run-start.d.ts +4 -0
  299. package/dist/runtime/run-start.js +44 -0
  300. package/dist/runtime/runtime.d.ts +6 -87
  301. package/dist/runtime/runtime.js +248 -470
  302. package/dist/runtime/server/auth.d.ts +41 -0
  303. package/dist/runtime/server/auth.js +45 -0
  304. package/dist/runtime/server/debugger-host.d.ts +11 -0
  305. package/dist/runtime/server/debugger-host.js +32 -0
  306. package/dist/runtime/server/fetch-handler.d.ts +18 -0
  307. package/dist/runtime/server/fetch-handler.js +62 -0
  308. package/dist/runtime/server/http.d.ts +38 -0
  309. package/dist/runtime/server/http.js +66 -0
  310. package/dist/runtime/server/route-table.d.ts +55 -0
  311. package/dist/runtime/server/route-table.js +74 -0
  312. package/dist/runtime/server/routes/definitions.d.ts +3 -0
  313. package/dist/runtime/server/routes/definitions.js +20 -0
  314. package/dist/runtime/server/routes/effects.d.ts +3 -0
  315. package/dist/runtime/server/routes/effects.js +59 -0
  316. package/dist/runtime/server/routes/operations.d.ts +3 -0
  317. package/dist/runtime/server/routes/operations.js +14 -0
  318. package/dist/runtime/server/routes/runs.d.ts +3 -0
  319. package/dist/runtime/server/routes/runs.js +199 -0
  320. package/dist/runtime/server.d.ts +4 -8
  321. package/dist/runtime/server.js +6 -211
  322. package/dist/runtime/sse.d.ts +2 -1
  323. package/dist/runtime/sse.js +24 -17
  324. package/dist/runtime/types.d.ts +117 -0
  325. package/dist/runtime/types.js +1 -0
  326. package/dist/runtime/wake-engine.d.ts +20 -0
  327. package/dist/runtime/wake-engine.js +311 -0
  328. package/dist/runtime/wake-scheduler.d.ts +3 -4
  329. package/dist/runtime/wake-scheduler.js +25 -31
  330. package/dist/runtime/worker-callbacks.d.ts +16 -0
  331. package/dist/runtime/worker-callbacks.js +167 -0
  332. package/dist/runtime/worker-effect-dispatch.d.ts +36 -0
  333. package/dist/runtime/worker-effect-dispatch.js +126 -0
  334. package/dist/s2/config.d.ts +1 -1
  335. package/dist/s2/config.js +1 -1
  336. package/dist/s2/lite.js +70 -82
  337. package/dist/s2/pagination.d.ts +15 -0
  338. package/dist/s2/pagination.js +36 -0
  339. package/dist/s2/projector.js +6 -5
  340. package/dist/s2/snapshot-store.js +188 -161
  341. package/dist/s2/store.d.ts +3 -21
  342. package/dist/s2/store.js +71 -165
  343. package/dist/testing/index.d.ts +15 -0
  344. package/dist/testing/index.js +53 -16
  345. package/dist/workflow/debugger/index.d.ts +4 -0
  346. package/dist/workflow/debugger/index.js +11 -0
  347. package/dist/workflow/debugger/nodes-view.d.ts +3 -0
  348. package/dist/workflow/debugger/nodes-view.js +13 -0
  349. package/dist/workflow/debugger/summarize.d.ts +2 -0
  350. package/dist/workflow/debugger/summarize.js +30 -0
  351. package/dist/workflow/definitions-store.d.ts +2 -3
  352. package/dist/workflow/definitions-store.js +2 -2
  353. package/dist/workflow/definitions.d.ts +78 -22
  354. package/dist/workflow/definitions.js +80 -14
  355. package/dist/workflow/effects.d.ts +453 -107
  356. package/dist/workflow/effects.js +214 -115
  357. package/dist/workflow/events.d.ts +149 -5
  358. package/dist/workflow/events.js +27 -5
  359. package/dist/workflow/graph.d.ts +56 -0
  360. package/dist/workflow/graph.js +207 -0
  361. package/dist/workflow/index.d.ts +1 -0
  362. package/dist/workflow/index.js +1 -0
  363. package/dist/workflow/module.d.ts +1047 -266
  364. package/dist/workflow/projections.d.ts +14 -12
  365. package/dist/workflow/projections.js +30 -8
  366. package/dist/workflow/scope.d.ts +146 -4
  367. package/dist/workflow/threads.d.ts +383 -155
  368. package/dist/workflow/threads.js +308 -110
  369. package/package.json +26 -2
  370. package/dist/debugger/events/domain-summarize.d.ts +0 -3
  371. package/dist/debugger/events/domain-summarize.js +0 -107
  372. package/dist/debugger/events/family.d.ts +0 -8
  373. package/dist/debugger/events/family.js +0 -44
  374. package/dist/runtime/events-api.d.ts +0 -4
  375. package/dist/runtime/events-api.js +0 -84
@@ -1,4 +1,5 @@
1
1
  import { Predicate, Schema, Stream } from 'effect';
2
+ import { DEFAULT_DEFINITION_VERSION } from './module.js';
2
3
  import { isTerminalStatus } from './thread.js';
3
4
  export function defineProjection(def) {
4
5
  return def;
@@ -26,8 +27,6 @@ export function projectStream(definition, stream, from) {
26
27
  const getInitial = () => (from !== undefined ? from : definition.initialState);
27
28
  return Stream.runFold(stream, getInitial, (state, event) => event.ephemeral ? state : definition.reduce(state, event));
28
29
  }
29
- // SAFETY: TreeBuildState is folded by reducers; Schema.Unknown is a typed placeholder, not a decoder.
30
- export const TreeBuildStateSchema = Schema.Unknown;
31
30
  function readPayload(event) {
32
31
  if (!Predicate.isObject(event.payload)) {
33
32
  return {};
@@ -40,7 +39,6 @@ function readString(obj, key) {
40
39
  }
41
40
  export const threadTree = defineProjection({
42
41
  name: 'threadTree',
43
- shape: TreeBuildStateSchema,
44
42
  initialState: { runId: '', records: {}, rootThreadId: null },
45
43
  reduce(state, event) {
46
44
  const payload = readPayload(event);
@@ -57,6 +55,7 @@ export const threadTree = defineProjection({
57
55
  const threadId = readString(payload, 'threadId') ?? event.threadId;
58
56
  const kind = readString(payload, 'kind');
59
57
  const definitionName = readString(payload, 'definitionName');
58
+ const definitionVersion = readString(payload, 'definitionVersion') ?? DEFAULT_DEFINITION_VERSION;
60
59
  if (!threadId || !kind || !definitionName) {
61
60
  return { ...state, runId: event.runId };
62
61
  }
@@ -66,6 +65,7 @@ export const threadTree = defineProjection({
66
65
  threadId,
67
66
  kind,
68
67
  definitionName,
68
+ definitionVersion,
69
69
  parentThreadId,
70
70
  status: 'running',
71
71
  input: payload.input ?? null,
@@ -173,10 +173,13 @@ export function toThreadTree(state) {
173
173
  runId: state.runId,
174
174
  status: 'running',
175
175
  rootThreadId: state.rootThreadId,
176
+ startIdentity: null,
176
177
  threads: state.records,
177
178
  waits: {},
178
179
  outstandingEffects: [],
180
+ effectExecutions: {},
179
181
  completedEffectIds: [],
182
+ processedIdempotencyKeys: [],
180
183
  });
181
184
  }
182
185
  export function treeFromRun(state) {
@@ -196,6 +199,7 @@ export function treeFromRun(state) {
196
199
  threadId: record.threadId,
197
200
  kind: record.kind,
198
201
  definitionName: record.definitionName,
202
+ definitionVersion: record.definitionVersion,
199
203
  status: isWaiting ? 'waiting' : record.status,
200
204
  parentThreadId: record.parentThreadId,
201
205
  children: (byParent.get(record.threadId) ?? []).map(toNode),
@@ -210,13 +214,13 @@ export function treeFromRun(state) {
210
214
  };
211
215
  }
212
216
  export const TimelineEntrySchema = Schema.Struct({
213
- seq: Schema.Number,
217
+ seq: Schema.Finite,
214
218
  id: Schema.String,
215
219
  type: Schema.String,
216
220
  threadId: Schema.NullOr(Schema.String),
217
221
  causationId: Schema.NullOr(Schema.String),
218
222
  effectId: Schema.NullOr(Schema.String),
219
- ts: Schema.Number,
223
+ ts: Schema.Finite,
220
224
  });
221
225
  export const TimelineSchema = Schema.mutable(Schema.Array(TimelineEntrySchema));
222
226
  export const timeline = defineProjection({
@@ -1,27 +1,27 @@
1
1
  import { Schema } from 'effect';
2
2
  import { type EventInputOf, type EventsOfCatalog } from './catalog';
3
- import type { WaitCondition } from './effects';
4
- export declare const WaitConditionSchema: Schema.Union<readonly [Schema.Struct<{
5
- readonly type: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
6
- readonly match: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
7
- }>, Schema.Struct<{
8
- readonly timerAt: Schema.Number;
9
- }>]>;
3
+ import { WaitConditionSchema, type WaitCondition } from './effects';
10
4
  export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime", {
11
5
  'run.started': Schema.Struct<{
12
6
  readonly rootThreadId: Schema.optional<Schema.String>;
13
7
  readonly kind: Schema.String;
14
8
  readonly definitionName: Schema.String;
9
+ readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
15
10
  readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
11
+ readonly requestedThreadId: Schema.optional<Schema.NullOr<Schema.String>>;
16
12
  }>;
17
13
  'run.completed': Schema.Struct<{
18
14
  readonly output: Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
19
15
  readonly error: Schema.NullOr<Schema.String>;
20
16
  }>;
17
+ 'run.cancelled': Schema.Struct<{
18
+ readonly reason: Schema.optional<Schema.String>;
19
+ }>;
21
20
  'thread.started': Schema.Struct<{
22
21
  readonly threadId: Schema.String;
23
22
  readonly kind: Schema.String;
24
23
  readonly definitionName: Schema.String;
24
+ readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
25
25
  readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
26
26
  readonly parentThreadId: Schema.NullOr<Schema.String>;
27
27
  }>;
@@ -37,6 +37,9 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
37
37
  readonly threadId: Schema.String;
38
38
  readonly reason: Schema.optional<Schema.String>;
39
39
  }>;
40
+ 'thread.cancel.requested': Schema.Struct<{
41
+ readonly threadId: Schema.String;
42
+ }>;
40
43
  'wait.registered': Schema.Struct<{
41
44
  readonly waitId: Schema.String;
42
45
  readonly threadId: Schema.optional<Schema.String>;
@@ -44,7 +47,7 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
44
47
  readonly type: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
45
48
  readonly match: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
46
49
  }>, Schema.Struct<{
47
- readonly timerAt: Schema.Number;
50
+ readonly timerAt: Schema.Finite;
48
51
  }>]>;
49
52
  readonly tag: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
50
53
  }>;
@@ -60,7 +63,7 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
60
63
  'timer.set': Schema.Struct<{
61
64
  readonly timerId: Schema.String;
62
65
  readonly waitId: Schema.String;
63
- readonly wakeAt: Schema.Number;
66
+ readonly wakeAt: Schema.Finite;
64
67
  }>;
65
68
  'timer.fired': Schema.Struct<{
66
69
  readonly timerId: Schema.String;
@@ -70,8 +73,62 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
70
73
  readonly effectId: Schema.String;
71
74
  readonly error: Schema.String;
72
75
  }>;
76
+ 'effect.attempt.started': Schema.Struct<{
77
+ readonly effectId: Schema.String;
78
+ readonly attempt: Schema.Finite;
79
+ }>;
80
+ 'effect.queued': Schema.Struct<{
81
+ readonly effectId: Schema.String;
82
+ readonly attempt: Schema.Finite;
83
+ readonly deadlineAt: Schema.NullOr<Schema.Finite>;
84
+ }>;
85
+ 'effect.dispatched': Schema.Struct<{
86
+ readonly effectId: Schema.String;
87
+ readonly attempt: Schema.Finite;
88
+ readonly deadlineAt: Schema.NullOr<Schema.Finite>;
89
+ }>;
90
+ 'effect.worker.started': Schema.Struct<{
91
+ readonly effectId: Schema.String;
92
+ readonly attempt: Schema.Finite;
93
+ readonly deadlineAt: Schema.NullOr<Schema.Finite>;
94
+ }>;
95
+ 'effect.heartbeat': Schema.Struct<{
96
+ readonly effectId: Schema.String;
97
+ readonly attempt: Schema.Finite;
98
+ readonly heartbeatAt: Schema.Finite;
99
+ readonly deadlineAt: Schema.NullOr<Schema.Finite>;
100
+ }>;
101
+ 'effect.cancel.requested': Schema.Struct<{
102
+ readonly effectId: Schema.String;
103
+ readonly attempt: Schema.Finite;
104
+ readonly deadlineAt: Schema.NullOr<Schema.Finite>;
105
+ }>;
106
+ 'effect.cancelled': Schema.Struct<{
107
+ readonly effectId: Schema.String;
108
+ readonly attempt: Schema.Finite;
109
+ }>;
110
+ 'effect.completed': Schema.Struct<{
111
+ readonly effectId: Schema.String;
112
+ readonly attempt: Schema.Finite;
113
+ }>;
114
+ 'effect.timed_out': Schema.Struct<{
115
+ readonly effectId: Schema.String;
116
+ readonly attempt: Schema.Finite;
117
+ readonly timeout: Schema.String;
118
+ }>;
119
+ 'effect.ambiguous': Schema.Struct<{
120
+ readonly effectId: Schema.String;
121
+ readonly attempt: Schema.Finite;
122
+ readonly error: Schema.String;
123
+ }>;
124
+ 'effect.retry.scheduled': Schema.Struct<{
125
+ readonly effectId: Schema.String;
126
+ readonly attempt: Schema.Finite;
127
+ readonly nextAttemptAt: Schema.Finite;
128
+ readonly error: Schema.String;
129
+ }>;
73
130
  'snapshot.taken': Schema.Struct<{
74
- readonly seq: Schema.Number;
131
+ readonly seq: Schema.Finite;
75
132
  readonly stateHash: Schema.String;
76
133
  readonly state: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
77
134
  }>;
@@ -81,7 +138,7 @@ export declare const protocolCatalog: import("./catalog").EventCatalog<"runtime"
81
138
  }>;
82
139
  export type ProtocolEvent = EventsOfCatalog<typeof protocolCatalog>;
83
140
  export type ProtocolEventInput = EventInputOf<typeof protocolCatalog>;
84
- export declare const PROTOCOL_TYPES: readonly ['runtime.run.started', 'runtime.run.completed', 'runtime.thread.started', 'runtime.thread.completed', 'runtime.thread.failed', 'runtime.thread.cancelled', 'runtime.wait.registered', 'runtime.wait.satisfied', 'runtime.timer.set', 'runtime.timer.fired', 'runtime.effect.failed', 'runtime.snapshot.taken', 'runtime.signal.received'];
141
+ export declare const PROTOCOL_TYPES: readonly ['runtime.run.started', 'runtime.run.completed', 'runtime.run.cancelled', 'runtime.thread.started', 'runtime.thread.completed', 'runtime.thread.failed', 'runtime.thread.cancelled', 'runtime.thread.cancel.requested', 'runtime.wait.registered', 'runtime.wait.satisfied', 'runtime.timer.set', 'runtime.timer.fired', 'runtime.effect.failed', 'runtime.effect.attempt.started', 'runtime.effect.queued', 'runtime.effect.dispatched', 'runtime.effect.worker.started', 'runtime.effect.heartbeat', 'runtime.effect.cancel.requested', 'runtime.effect.cancelled', 'runtime.effect.completed', 'runtime.effect.timed_out', 'runtime.effect.ambiguous', 'runtime.effect.retry.scheduled', 'runtime.snapshot.taken', 'runtime.signal.received'];
85
142
  export type ProtocolEventType = (typeof PROTOCOL_TYPES)[number];
86
143
  export declare function isProtocolType(type: string): type is ProtocolEventType;
87
144
  export type RunStartedPayload = Schema.Schema.Type<(typeof protocolCatalog.entries)['run.started']>;
@@ -1,29 +1,30 @@
1
- import { Schema } from 'effect';
1
+ import { Effect, Schema } from 'effect';
2
2
  import { defineEventCatalog } from './catalog.js';
3
+ import { WaitConditionSchema } from './effects.js';
3
4
  import { JsonValueSchema } from './envelope.js';
4
- const WaitOnEventSchema = Schema.Struct({
5
- type: Schema.Union([Schema.String, Schema.Array(Schema.String)]),
6
- match: Schema.optional(JsonValueSchema),
7
- });
8
- const WaitOnTimerSchema = Schema.Struct({
9
- timerAt: Schema.Number,
10
- });
11
- export const WaitConditionSchema = Schema.Union([WaitOnEventSchema, WaitOnTimerSchema]);
5
+ import { DEFAULT_DEFINITION_VERSION } from './module.js';
6
+ const DefinitionVersionSchema = Schema.String.pipe(Schema.withDecodingDefaultKey(Effect.succeed(DEFAULT_DEFINITION_VERSION)));
12
7
  export const protocolCatalog = defineEventCatalog('runtime', {
13
8
  'run.started': Schema.Struct({
14
9
  rootThreadId: Schema.optional(Schema.String),
15
10
  kind: Schema.String,
16
11
  definitionName: Schema.String,
12
+ definitionVersion: DefinitionVersionSchema,
17
13
  input: JsonValueSchema,
14
+ requestedThreadId: Schema.optional(Schema.NullOr(Schema.String)),
18
15
  }),
19
16
  'run.completed': Schema.Struct({
20
17
  output: Schema.NullOr(JsonValueSchema),
21
18
  error: Schema.NullOr(Schema.String),
22
19
  }),
20
+ 'run.cancelled': Schema.Struct({
21
+ reason: Schema.optional(Schema.String),
22
+ }),
23
23
  'thread.started': Schema.Struct({
24
24
  threadId: Schema.String,
25
25
  kind: Schema.String,
26
26
  definitionName: Schema.String,
27
+ definitionVersion: DefinitionVersionSchema,
27
28
  input: JsonValueSchema,
28
29
  parentThreadId: Schema.NullOr(Schema.String),
29
30
  }),
@@ -39,6 +40,9 @@ export const protocolCatalog = defineEventCatalog('runtime', {
39
40
  threadId: Schema.String,
40
41
  reason: Schema.optional(Schema.String),
41
42
  }),
43
+ 'thread.cancel.requested': Schema.Struct({
44
+ threadId: Schema.String,
45
+ }),
42
46
  'wait.registered': Schema.Struct({
43
47
  waitId: Schema.String,
44
48
  threadId: Schema.optional(Schema.String),
@@ -57,7 +61,7 @@ export const protocolCatalog = defineEventCatalog('runtime', {
57
61
  'timer.set': Schema.Struct({
58
62
  timerId: Schema.String,
59
63
  waitId: Schema.String,
60
- wakeAt: Schema.Number,
64
+ wakeAt: Schema.Finite,
61
65
  }),
62
66
  'timer.fired': Schema.Struct({
63
67
  timerId: Schema.String,
@@ -67,8 +71,62 @@ export const protocolCatalog = defineEventCatalog('runtime', {
67
71
  effectId: Schema.String,
68
72
  error: Schema.String,
69
73
  }),
74
+ 'effect.attempt.started': Schema.Struct({
75
+ effectId: Schema.String,
76
+ attempt: Schema.Finite,
77
+ }),
78
+ 'effect.queued': Schema.Struct({
79
+ effectId: Schema.String,
80
+ attempt: Schema.Finite,
81
+ deadlineAt: Schema.NullOr(Schema.Finite),
82
+ }),
83
+ 'effect.dispatched': Schema.Struct({
84
+ effectId: Schema.String,
85
+ attempt: Schema.Finite,
86
+ deadlineAt: Schema.NullOr(Schema.Finite),
87
+ }),
88
+ 'effect.worker.started': Schema.Struct({
89
+ effectId: Schema.String,
90
+ attempt: Schema.Finite,
91
+ deadlineAt: Schema.NullOr(Schema.Finite),
92
+ }),
93
+ 'effect.heartbeat': Schema.Struct({
94
+ effectId: Schema.String,
95
+ attempt: Schema.Finite,
96
+ heartbeatAt: Schema.Finite,
97
+ deadlineAt: Schema.NullOr(Schema.Finite),
98
+ }),
99
+ 'effect.cancel.requested': Schema.Struct({
100
+ effectId: Schema.String,
101
+ attempt: Schema.Finite,
102
+ deadlineAt: Schema.NullOr(Schema.Finite),
103
+ }),
104
+ 'effect.cancelled': Schema.Struct({
105
+ effectId: Schema.String,
106
+ attempt: Schema.Finite,
107
+ }),
108
+ 'effect.completed': Schema.Struct({
109
+ effectId: Schema.String,
110
+ attempt: Schema.Finite,
111
+ }),
112
+ 'effect.timed_out': Schema.Struct({
113
+ effectId: Schema.String,
114
+ attempt: Schema.Finite,
115
+ timeout: Schema.String,
116
+ }),
117
+ 'effect.ambiguous': Schema.Struct({
118
+ effectId: Schema.String,
119
+ attempt: Schema.Finite,
120
+ error: Schema.String,
121
+ }),
122
+ 'effect.retry.scheduled': Schema.Struct({
123
+ effectId: Schema.String,
124
+ attempt: Schema.Finite,
125
+ nextAttemptAt: Schema.Finite,
126
+ error: Schema.String,
127
+ }),
70
128
  'snapshot.taken': Schema.Struct({
71
- seq: Schema.Number,
129
+ seq: Schema.Finite,
72
130
  stateHash: Schema.String,
73
131
  state: Schema.optional(JsonValueSchema),
74
132
  }),
@@ -79,15 +137,28 @@ export const protocolCatalog = defineEventCatalog('runtime', {
79
137
  export const PROTOCOL_TYPES = [
80
138
  'runtime.run.started',
81
139
  'runtime.run.completed',
140
+ 'runtime.run.cancelled',
82
141
  'runtime.thread.started',
83
142
  'runtime.thread.completed',
84
143
  'runtime.thread.failed',
85
144
  'runtime.thread.cancelled',
145
+ 'runtime.thread.cancel.requested',
86
146
  'runtime.wait.registered',
87
147
  'runtime.wait.satisfied',
88
148
  'runtime.timer.set',
89
149
  'runtime.timer.fired',
90
150
  'runtime.effect.failed',
151
+ 'runtime.effect.attempt.started',
152
+ 'runtime.effect.queued',
153
+ 'runtime.effect.dispatched',
154
+ 'runtime.effect.worker.started',
155
+ 'runtime.effect.heartbeat',
156
+ 'runtime.effect.cancel.requested',
157
+ 'runtime.effect.cancelled',
158
+ 'runtime.effect.completed',
159
+ 'runtime.effect.timed_out',
160
+ 'runtime.effect.ambiguous',
161
+ 'runtime.effect.retry.scheduled',
91
162
  'runtime.snapshot.taken',
92
163
  'runtime.signal.received',
93
164
  ];
@@ -0,0 +1,43 @@
1
+ import { Schema } from 'effect';
2
+ import type { RegisteredDefinition } from './module';
3
+ import { type RunState } from './state';
4
+ /** A registered definition as `GET /definitions` publishes it. */
5
+ export declare const PublishedDefinitionSchema: Schema.Struct<{
6
+ readonly kind: Schema.String;
7
+ readonly name: Schema.String;
8
+ readonly version: Schema.String;
9
+ readonly description: Schema.optional<Schema.String>;
10
+ /** JSON Schema derived from the definition's `input`. */
11
+ readonly inputSchema: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
12
+ }>;
13
+ export type PublishedDefinition = Schema.Schema.Type<typeof PublishedDefinitionSchema>;
14
+ export declare const DefinitionCatalogSchema: Schema.Struct<{
15
+ readonly definitions: Schema.$Array<Schema.Struct<{
16
+ readonly kind: Schema.String;
17
+ readonly name: Schema.String;
18
+ readonly version: Schema.String;
19
+ readonly description: Schema.optional<Schema.String>;
20
+ /** JSON Schema derived from the definition's `input`. */
21
+ readonly inputSchema: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
22
+ }>>;
23
+ readonly projections: Schema.$Array<Schema.String>;
24
+ }>;
25
+ export type DefinitionCatalog = Schema.Schema.Type<typeof DefinitionCatalogSchema>;
26
+ export declare function publishDefinition(definition: RegisteredDefinition): PublishedDefinition;
27
+ /** A run as `GET /runs/summaries` lists it. */
28
+ export declare const RunSummarySchema: Schema.Struct<{
29
+ readonly runId: Schema.String;
30
+ readonly status: Schema.Union<readonly [Schema.Literal<"running">, Schema.Literal<"completed">, Schema.Literal<"failed">, Schema.Literal<"cancelled">]>;
31
+ readonly kind: Schema.NullOr<Schema.String>;
32
+ readonly definitionName: Schema.NullOr<Schema.String>;
33
+ }>;
34
+ export type RunSummary = Schema.Schema.Type<typeof RunSummarySchema>;
35
+ export declare function summarizeRun(state: RunState): RunSummary;
36
+ export declare const RunSummariesSchema: Schema.Struct<{
37
+ readonly runs: Schema.$Array<Schema.Struct<{
38
+ readonly runId: Schema.String;
39
+ readonly status: Schema.Union<readonly [Schema.Literal<"running">, Schema.Literal<"completed">, Schema.Literal<"failed">, Schema.Literal<"cancelled">]>;
40
+ readonly kind: Schema.NullOr<Schema.String>;
41
+ readonly definitionName: Schema.NullOr<Schema.String>;
42
+ }>>;
43
+ }>;
@@ -0,0 +1,44 @@
1
+ import { Schema } from 'effect';
2
+ import { JsonValueSchema } from './envelope.js';
3
+ import { jsonSchemaOfInput } from './schema.js';
4
+ import { RunStateSchema } from './state.js';
5
+ /** A registered definition as `GET /definitions` publishes it. */
6
+ export const PublishedDefinitionSchema = Schema.Struct({
7
+ kind: Schema.String,
8
+ name: Schema.String,
9
+ version: Schema.String,
10
+ description: Schema.optional(Schema.String),
11
+ /** JSON Schema derived from the definition's `input`. */
12
+ inputSchema: Schema.optional(JsonValueSchema),
13
+ });
14
+ export const DefinitionCatalogSchema = Schema.Struct({
15
+ definitions: Schema.Array(PublishedDefinitionSchema),
16
+ projections: Schema.Array(Schema.String),
17
+ });
18
+ export function publishDefinition(definition) {
19
+ return {
20
+ kind: definition.kind,
21
+ name: definition.name,
22
+ version: definition.version,
23
+ description: definition.description,
24
+ inputSchema: jsonSchemaOfInput(definition.input),
25
+ };
26
+ }
27
+ /** A run as `GET /runs/summaries` lists it. */
28
+ export const RunSummarySchema = Schema.Struct({
29
+ runId: Schema.String,
30
+ status: RunStateSchema.fields.status,
31
+ kind: Schema.NullOr(Schema.String),
32
+ definitionName: Schema.NullOr(Schema.String),
33
+ });
34
+ export function summarizeRun(state) {
35
+ return {
36
+ runId: state.runId,
37
+ status: state.status,
38
+ kind: state.startIdentity?.kind ?? null,
39
+ definitionName: state.startIdentity?.definitionName ?? null,
40
+ };
41
+ }
42
+ export const RunSummariesSchema = Schema.Struct({
43
+ runs: Schema.Array(RunSummarySchema),
44
+ });