@swirls/looms 0.4.0 → 0.5.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 (241) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/actor/cell.d.ts +21 -2
  3. package/dist/actor/cell.js +15 -3
  4. package/dist/actor/host.d.ts +10 -2
  5. package/dist/actor/host.js +27 -4
  6. package/dist/actor/index.d.ts +2 -1
  7. package/dist/actor/index.js +1 -1
  8. package/dist/actor/routing.d.ts +3 -0
  9. package/dist/actor/routing.js +13 -2
  10. package/dist/agent/definitions-store.d.ts +1 -1
  11. package/dist/agent/definitions-store.js +1 -1
  12. package/dist/agent/definitions.d.ts +48 -0
  13. package/dist/agent/definitions.js +44 -0
  14. package/dist/agent/effects.d.ts +184 -0
  15. package/dist/agent/effects.js +172 -40
  16. package/dist/agent/events.d.ts +89 -0
  17. package/dist/agent/events.js +25 -0
  18. package/dist/agent/module.d.ts +412 -0
  19. package/dist/agent/module.js +5 -1
  20. package/dist/agent/scope.d.ts +88 -0
  21. package/dist/agent/threads.js +39 -3
  22. package/dist/agent/types.d.ts +4 -0
  23. package/dist/approval/effects.d.ts +40 -0
  24. package/dist/approval/module.d.ts +80 -0
  25. package/dist/client/client.d.ts +468 -119
  26. package/dist/client/client.js +214 -21
  27. package/dist/client/index.d.ts +1 -1
  28. package/dist/client/sse.d.ts +1 -1
  29. package/dist/client/sse.js +2 -2
  30. package/dist/cloudflare/durable-object.d.ts +66 -2
  31. package/dist/cloudflare/durable-object.js +96 -1
  32. package/dist/cloudflare/event-store.d.ts +7 -3
  33. package/dist/cloudflare/event-store.js +16 -3
  34. package/dist/cloudflare/index.d.ts +7 -1
  35. package/dist/cloudflare/index.js +7 -1
  36. package/dist/cloudflare/memory-queue.d.ts +18 -0
  37. package/dist/cloudflare/memory-queue.js +53 -0
  38. package/dist/cloudflare/queue-consumer.d.ts +52 -0
  39. package/dist/cloudflare/queue-consumer.js +102 -0
  40. package/dist/cloudflare/queue-message.d.ts +31 -0
  41. package/dist/cloudflare/queue-message.js +33 -0
  42. package/dist/cloudflare/queue-pull.d.ts +62 -0
  43. package/dist/cloudflare/queue-pull.js +130 -0
  44. package/dist/cloudflare/queue-worker.d.ts +39 -0
  45. package/dist/cloudflare/queue-worker.js +62 -0
  46. package/dist/cloudflare/r2-blob-store.d.ts +33 -0
  47. package/dist/cloudflare/r2-blob-store.js +60 -0
  48. package/dist/cloudflare/router.d.ts +4 -1
  49. package/dist/cloudflare/router.js +8 -3
  50. package/dist/cloudflare/websocket.d.ts +27 -0
  51. package/dist/cloudflare/websocket.js +215 -0
  52. package/dist/core/blob-offload.d.ts +21 -0
  53. package/dist/core/blob-offload.js +143 -0
  54. package/dist/core/blob-store.d.ts +45 -0
  55. package/dist/core/blob-store.js +164 -0
  56. package/dist/core/blobs.d.ts +37 -0
  57. package/dist/core/blobs.js +160 -0
  58. package/dist/core/definition-resolver.d.ts +40 -0
  59. package/dist/core/definition-resolver.js +129 -0
  60. package/dist/core/definition-store.d.ts +6 -0
  61. package/dist/core/definition-store.js +37 -1
  62. package/dist/core/effects.d.ts +86 -3
  63. package/dist/core/effects.js +99 -3
  64. package/dist/core/envelope.d.ts +9 -0
  65. package/dist/core/envelope.js +4 -0
  66. package/dist/core/event-codec.js +3 -0
  67. package/dist/core/fold.js +83 -1
  68. package/dist/core/ids.d.ts +2 -0
  69. package/dist/core/ids.js +4 -0
  70. package/dist/core/index.d.ts +8 -0
  71. package/dist/core/index.js +8 -0
  72. package/dist/core/launcher.d.ts +97 -0
  73. package/dist/core/launcher.js +67 -0
  74. package/dist/core/module-scope.d.ts +7 -3
  75. package/dist/core/module-scope.js +3 -0
  76. package/dist/core/module.d.ts +10 -0
  77. package/dist/core/projection.js +4 -0
  78. package/dist/core/protocol.d.ts +36 -1
  79. package/dist/core/protocol.js +35 -0
  80. package/dist/core/published.d.ts +2 -0
  81. package/dist/core/published.js +4 -1
  82. package/dist/core/replay.d.ts +96 -0
  83. package/dist/core/run-context.d.ts +33 -0
  84. package/dist/core/run-context.js +23 -0
  85. package/dist/core/sqlite-store.js +57 -5
  86. package/dist/core/state.d.ts +60 -0
  87. package/dist/core/state.js +19 -0
  88. package/dist/core/store.d.ts +6 -0
  89. package/dist/core/store.js +7 -0
  90. package/dist/core/subscription.d.ts +97 -0
  91. package/dist/core/subscription.js +224 -0
  92. package/dist/core/thread.d.ts +7 -0
  93. package/dist/core/thread.js +1 -0
  94. package/dist/core/trace.d.ts +21 -0
  95. package/dist/core/trace.js +45 -0
  96. package/dist/core/worker-callback.d.ts +25 -1
  97. package/dist/debugger/app/assets/{index-CgDzWJg7.css → index-B7GdT1UA.css} +1 -1
  98. package/dist/debugger/app/assets/index-C31SnCuN.js +22 -0
  99. package/dist/debugger/app/assets/routes-DPA3O5AF.js +47 -0
  100. package/dist/debugger/app/index.html +2 -2
  101. package/dist/debugger/components/event-inspector.d.ts +3 -1
  102. package/dist/debugger/components/event-inspector.js +25 -4
  103. package/dist/debugger/components/event-stream.d.ts +4 -1
  104. package/dist/debugger/components/event-stream.js +2 -2
  105. package/dist/debugger/components/run-tree.d.ts +5 -2
  106. package/dist/debugger/components/run-tree.js +10 -4
  107. package/dist/debugger/context.d.ts +8 -1
  108. package/dist/debugger/context.js +15 -3
  109. package/dist/debugger/events/protocol-summarize.js +18 -3
  110. package/dist/debugger/index.d.ts +1 -1
  111. package/dist/debugger/index.js +1 -1
  112. package/dist/debugger/shell/debugger-shell.js +1 -1
  113. package/dist/debugger/shell/events-pane.js +4 -3
  114. package/dist/debugger/styles.css +1 -0
  115. package/dist/evaluator/definitions-store.d.ts +3 -4
  116. package/dist/evaluator/definitions-store.js +3 -3
  117. package/dist/evaluator/definitions.d.ts +4 -1
  118. package/dist/evaluator/definitions.js +5 -2
  119. package/dist/evaluator/effects.d.ts +74 -33
  120. package/dist/evaluator/effects.js +6 -2
  121. package/dist/evaluator/module.d.ts +150 -66
  122. package/dist/evaluator/module.js +7 -3
  123. package/dist/evaluator/threads.d.ts +2 -0
  124. package/dist/evaluator/threads.js +4 -0
  125. package/dist/projectors/event-log.d.ts +87 -0
  126. package/dist/projectors/event-log.js +396 -0
  127. package/dist/projectors/index-model.d.ts +12 -0
  128. package/dist/projectors/index-model.js +12 -3
  129. package/dist/projectors/memory.js +7 -0
  130. package/dist/projectors/postgres.d.ts +1 -0
  131. package/dist/projectors/postgres.js +32 -15
  132. package/dist/projectors/schema.d.ts +5 -0
  133. package/dist/projectors/schema.js +26 -1
  134. package/dist/projectors/sqlite.js +47 -19
  135. package/dist/projectors/with-projectors.d.ts +7 -1
  136. package/dist/projectors/with-projectors.js +13 -3
  137. package/dist/react/materialize.js +5 -1
  138. package/dist/react/react.d.ts +10 -2
  139. package/dist/react/react.js +43 -19
  140. package/dist/react/store.d.ts +11 -2
  141. package/dist/react/store.js +104 -12
  142. package/dist/react/tables.d.ts +4 -1
  143. package/dist/runtime/cancellation.d.ts +2 -1
  144. package/dist/runtime/cancellation.js +35 -2
  145. package/dist/runtime/child-run.d.ts +10 -0
  146. package/dist/runtime/child-run.js +58 -0
  147. package/dist/runtime/deadline-transition-planner.js +11 -2
  148. package/dist/runtime/dispatch-effect.d.ts +2 -2
  149. package/dist/runtime/dispatch-effect.js +43 -19
  150. package/dist/runtime/errors.d.ts +14 -1
  151. package/dist/runtime/errors.js +10 -0
  152. package/dist/runtime/filesystem-blob-store.d.ts +6 -0
  153. package/dist/runtime/filesystem-blob-store.js +59 -0
  154. package/dist/runtime/helpers.d.ts +15 -6
  155. package/dist/runtime/helpers.js +46 -6
  156. package/dist/runtime/index.d.ts +4 -2
  157. package/dist/runtime/index.js +3 -1
  158. package/dist/runtime/local-effect-executor.d.ts +11 -2
  159. package/dist/runtime/local-effect-executor.js +80 -4
  160. package/dist/runtime/looms.d.ts +38 -4
  161. package/dist/runtime/looms.js +17 -3
  162. package/dist/runtime/repository.d.ts +5 -4
  163. package/dist/runtime/repository.js +5 -2
  164. package/dist/runtime/retry-policy.d.ts +5 -0
  165. package/dist/runtime/retry-policy.js +10 -2
  166. package/dist/runtime/run-start.d.ts +1 -1
  167. package/dist/runtime/run-start.js +10 -0
  168. package/dist/runtime/runtime.d.ts +2 -2
  169. package/dist/runtime/runtime.js +191 -68
  170. package/dist/runtime/server/auth.d.ts +3 -0
  171. package/dist/runtime/server/fetch-handler.d.ts +2 -2
  172. package/dist/runtime/server/fetch-handler.js +35 -4
  173. package/dist/runtime/server/grant.d.ts +49 -0
  174. package/dist/runtime/server/grant.js +177 -0
  175. package/dist/runtime/server/routes/effects.js +47 -5
  176. package/dist/runtime/server/routes/runs.js +6 -1
  177. package/dist/runtime/server/run-route.d.ts +18 -0
  178. package/dist/runtime/server/run-route.js +26 -0
  179. package/dist/runtime/server.d.ts +3 -1
  180. package/dist/runtime/server.js +3 -1
  181. package/dist/runtime/sse.js +26 -4
  182. package/dist/runtime/subscription.d.ts +8 -0
  183. package/dist/runtime/subscription.js +23 -0
  184. package/dist/runtime/types.d.ts +87 -8
  185. package/dist/runtime/wake-engine.d.ts +4 -2
  186. package/dist/runtime/wake-engine.js +57 -6
  187. package/dist/runtime/worker-callbacks.d.ts +12 -2
  188. package/dist/runtime/worker-callbacks.js +102 -72
  189. package/dist/runtime/worker-effect-dispatch.d.ts +14 -5
  190. package/dist/runtime/worker-effect-dispatch.js +84 -18
  191. package/dist/schedule/debugger/index.d.ts +4 -0
  192. package/dist/schedule/debugger/index.js +11 -0
  193. package/dist/schedule/debugger/schedule-view.d.ts +3 -0
  194. package/dist/schedule/debugger/schedule-view.js +68 -0
  195. package/dist/schedule/debugger/summarize.d.ts +2 -0
  196. package/dist/schedule/debugger/summarize.js +43 -0
  197. package/dist/schedule/definitions-store.d.ts +10 -0
  198. package/dist/schedule/definitions-store.js +8 -0
  199. package/dist/schedule/definitions.d.ts +57 -0
  200. package/dist/schedule/definitions.js +30 -0
  201. package/dist/schedule/effects.d.ts +756 -0
  202. package/dist/schedule/effects.js +244 -0
  203. package/dist/schedule/ensure.d.ts +55 -0
  204. package/dist/schedule/ensure.js +109 -0
  205. package/dist/schedule/events.d.ts +116 -0
  206. package/dist/schedule/events.js +49 -0
  207. package/dist/schedule/index.d.ts +11 -0
  208. package/dist/schedule/index.js +11 -0
  209. package/dist/schedule/module.d.ts +1474 -0
  210. package/dist/schedule/module.js +22 -0
  211. package/dist/schedule/projections.d.ts +55 -0
  212. package/dist/schedule/projections.js +88 -0
  213. package/dist/schedule/scope.d.ts +121 -0
  214. package/dist/schedule/scope.js +7 -0
  215. package/dist/schedule/signals.d.ts +25 -0
  216. package/dist/schedule/signals.js +33 -0
  217. package/dist/schedule/specs.d.ts +59 -0
  218. package/dist/schedule/specs.js +231 -0
  219. package/dist/schedule/threads.d.ts +25 -0
  220. package/dist/schedule/threads.js +259 -0
  221. package/dist/testing/corpus-module.d.ts +34 -0
  222. package/dist/testing/corpus-module.js +87 -0
  223. package/dist/testing/index.d.ts +2 -0
  224. package/dist/testing/index.js +5 -6
  225. package/dist/testing/replay-corpus.d.ts +22 -0
  226. package/dist/testing/replay-corpus.js +50 -0
  227. package/dist/workflow/definitions-store.d.ts +1 -1
  228. package/dist/workflow/definitions-store.js +1 -1
  229. package/dist/workflow/definitions.d.ts +14 -0
  230. package/dist/workflow/effects.d.ts +122 -0
  231. package/dist/workflow/effects.js +16 -6
  232. package/dist/workflow/events.d.ts +42 -0
  233. package/dist/workflow/events.js +4 -0
  234. package/dist/workflow/module.d.ts +345 -32
  235. package/dist/workflow/module.js +7 -3
  236. package/dist/workflow/scope.d.ts +42 -0
  237. package/dist/workflow/threads.d.ts +72 -0
  238. package/dist/workflow/threads.js +106 -38
  239. package/package.json +10 -1
  240. package/dist/debugger/app/assets/index-D--9esm9.js +0 -22
  241. package/dist/debugger/app/assets/routes-Dakrdusf.js +0 -47
@@ -39,8 +39,55 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
39
39
  evaluate: import("@swirls/looms/core").EffectDefinition<{
40
40
  readonly evaluationId: string;
41
41
  readonly definitionName?: string | undefined;
42
+ readonly definitionVersion?: string | undefined;
42
43
  readonly input?: import("effect/Schema").Json | undefined;
43
44
  }, import("./definitions-store").EvaluatorDefinitionsTag | EvaluatorTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
45
+ readonly type: "evaluator.evaluated";
46
+ readonly payload: {
47
+ readonly evaluationId: string;
48
+ readonly definitionName?: string | undefined;
49
+ readonly answers: {
50
+ readonly [x: string]: {
51
+ readonly type: "boolean";
52
+ readonly value: boolean;
53
+ readonly probability: number;
54
+ } | {
55
+ readonly type: "choice";
56
+ readonly value: string;
57
+ } | {
58
+ readonly type: "score";
59
+ readonly value: number;
60
+ };
61
+ };
62
+ readonly route: string;
63
+ readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
64
+ readonly usage?: {
65
+ readonly input: number;
66
+ readonly output: number;
67
+ } | undefined;
68
+ };
69
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
70
+ readonly type: "evaluator.requested";
71
+ readonly payload: {
72
+ readonly evaluationId: string;
73
+ readonly definitionName?: string | undefined;
74
+ readonly state: string;
75
+ readonly model?: string | undefined;
76
+ };
77
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
78
+ readonly type: "runtime.child.close.requested";
79
+ readonly payload: {
80
+ readonly policy: "terminate" | "wait";
81
+ };
82
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
83
+ readonly type: "runtime.child.settled";
84
+ readonly payload: {
85
+ readonly runId: string;
86
+ readonly status: "cancelled" | "completed" | "failed";
87
+ readonly output: import("effect/Schema").Json;
88
+ readonly error: string | null;
89
+ };
90
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
44
91
  readonly type: "runtime.effect.ambiguous";
45
92
  readonly payload: {
46
93
  readonly effectId: string;
@@ -84,6 +131,8 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
84
131
  readonly payload: {
85
132
  readonly effectId: string;
86
133
  readonly error: string;
134
+ readonly nonRetryable?: boolean | undefined;
135
+ readonly retryAfterMs?: number | undefined;
87
136
  };
88
137
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
89
138
  readonly type: "runtime.effect.heartbeat";
@@ -92,6 +141,7 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
92
141
  readonly attempt: number;
93
142
  readonly heartbeatAt: number;
94
143
  readonly deadlineAt: number | null;
144
+ readonly details?: import("effect/Schema").Json | undefined;
95
145
  };
96
146
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
97
147
  readonly type: "runtime.effect.queued";
@@ -144,6 +194,16 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
144
194
  readonly sourceRunId: string;
145
195
  readonly sourceSeq: number;
146
196
  };
197
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
198
+ readonly type: "runtime.run.launched";
199
+ readonly payload: {
200
+ readonly runId: string;
201
+ readonly kind: string;
202
+ readonly definitionName: string;
203
+ readonly definitionVersion: string;
204
+ readonly effectId: string;
205
+ readonly close: "terminate" | "wait";
206
+ };
147
207
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
148
208
  readonly type: "runtime.run.started";
149
209
  readonly payload: {
@@ -153,6 +213,20 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
153
213
  readonly definitionVersion: string;
154
214
  readonly input: import("effect/Schema").Json;
155
215
  readonly requestedThreadId?: string | null | undefined;
216
+ readonly launchedBy?: {
217
+ readonly runId: string;
218
+ readonly threadId: string;
219
+ readonly effectId: string;
220
+ readonly causationId: string;
221
+ readonly causationSeq: number;
222
+ } | undefined;
223
+ readonly attributes?: {
224
+ readonly [x: string]: string;
225
+ } | undefined;
226
+ readonly trace?: {
227
+ readonly traceparent: string;
228
+ readonly tracestate?: string | undefined;
229
+ } | undefined;
156
230
  };
157
231
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
158
232
  readonly type: "runtime.signal.received";
@@ -237,43 +311,11 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
237
311
  readonly payload: import("effect/Schema").Json;
238
312
  };
239
313
  };
240
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
241
- readonly type: "evaluator.evaluated";
242
- readonly payload: {
243
- readonly evaluationId: string;
244
- readonly definitionName?: string | undefined;
245
- readonly answers: {
246
- readonly [x: string]: {
247
- readonly type: "boolean";
248
- readonly value: boolean;
249
- readonly probability: number;
250
- } | {
251
- readonly type: "choice";
252
- readonly value: string;
253
- } | {
254
- readonly type: "score";
255
- readonly value: number;
256
- };
257
- };
258
- readonly route: string;
259
- readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
260
- readonly usage?: {
261
- readonly input: number;
262
- readonly output: number;
263
- } | undefined;
264
- };
265
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
266
- readonly type: "evaluator.requested";
267
- readonly payload: {
268
- readonly evaluationId: string;
269
- readonly definitionName?: string | undefined;
270
- readonly state: string;
271
- readonly model?: string | undefined;
272
- };
273
314
  })>;
274
315
  }, {
275
316
  evaluator: import("@swirls/looms/core").ThreadDefinition<{
276
317
  readonly definitionName?: string | undefined;
318
+ readonly definitionVersion?: string | undefined;
277
319
  readonly input: import("effect/Schema").Json;
278
320
  readonly evaluationId: string;
279
321
  readonly dispatched: boolean;
@@ -334,8 +376,55 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
334
376
  evaluate: import("@swirls/looms/core").EffectDefinition<{
335
377
  readonly evaluationId: string;
336
378
  readonly definitionName?: string | undefined;
379
+ readonly definitionVersion?: string | undefined;
337
380
  readonly input?: import("effect/Schema").Json | undefined;
338
381
  }, import("./definitions-store").EvaluatorDefinitionsTag | EvaluatorTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
382
+ readonly type: "evaluator.evaluated";
383
+ readonly payload: {
384
+ readonly evaluationId: string;
385
+ readonly definitionName?: string | undefined;
386
+ readonly answers: {
387
+ readonly [x: string]: {
388
+ readonly type: "boolean";
389
+ readonly value: boolean;
390
+ readonly probability: number;
391
+ } | {
392
+ readonly type: "choice";
393
+ readonly value: string;
394
+ } | {
395
+ readonly type: "score";
396
+ readonly value: number;
397
+ };
398
+ };
399
+ readonly route: string;
400
+ readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
401
+ readonly usage?: {
402
+ readonly input: number;
403
+ readonly output: number;
404
+ } | undefined;
405
+ };
406
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
407
+ readonly type: "evaluator.requested";
408
+ readonly payload: {
409
+ readonly evaluationId: string;
410
+ readonly definitionName?: string | undefined;
411
+ readonly state: string;
412
+ readonly model?: string | undefined;
413
+ };
414
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
415
+ readonly type: "runtime.child.close.requested";
416
+ readonly payload: {
417
+ readonly policy: "terminate" | "wait";
418
+ };
419
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
420
+ readonly type: "runtime.child.settled";
421
+ readonly payload: {
422
+ readonly runId: string;
423
+ readonly status: "cancelled" | "completed" | "failed";
424
+ readonly output: import("effect/Schema").Json;
425
+ readonly error: string | null;
426
+ };
427
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
339
428
  readonly type: "runtime.effect.ambiguous";
340
429
  readonly payload: {
341
430
  readonly effectId: string;
@@ -379,6 +468,8 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
379
468
  readonly payload: {
380
469
  readonly effectId: string;
381
470
  readonly error: string;
471
+ readonly nonRetryable?: boolean | undefined;
472
+ readonly retryAfterMs?: number | undefined;
382
473
  };
383
474
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
384
475
  readonly type: "runtime.effect.heartbeat";
@@ -387,6 +478,7 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
387
478
  readonly attempt: number;
388
479
  readonly heartbeatAt: number;
389
480
  readonly deadlineAt: number | null;
481
+ readonly details?: import("effect/Schema").Json | undefined;
390
482
  };
391
483
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
392
484
  readonly type: "runtime.effect.queued";
@@ -439,6 +531,16 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
439
531
  readonly sourceRunId: string;
440
532
  readonly sourceSeq: number;
441
533
  };
534
+ }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
535
+ readonly type: "runtime.run.launched";
536
+ readonly payload: {
537
+ readonly runId: string;
538
+ readonly kind: string;
539
+ readonly definitionName: string;
540
+ readonly definitionVersion: string;
541
+ readonly effectId: string;
542
+ readonly close: "terminate" | "wait";
543
+ };
442
544
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
443
545
  readonly type: "runtime.run.started";
444
546
  readonly payload: {
@@ -448,6 +550,20 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
448
550
  readonly definitionVersion: string;
449
551
  readonly input: import("effect/Schema").Json;
450
552
  readonly requestedThreadId?: string | null | undefined;
553
+ readonly launchedBy?: {
554
+ readonly runId: string;
555
+ readonly threadId: string;
556
+ readonly effectId: string;
557
+ readonly causationId: string;
558
+ readonly causationSeq: number;
559
+ } | undefined;
560
+ readonly attributes?: {
561
+ readonly [x: string]: string;
562
+ } | undefined;
563
+ readonly trace?: {
564
+ readonly traceparent: string;
565
+ readonly tracestate?: string | undefined;
566
+ } | undefined;
451
567
  };
452
568
  }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
453
569
  readonly type: "runtime.signal.received";
@@ -532,44 +648,12 @@ export declare function evaluator(options?: EvaluatorModuleOptions): import("@sw
532
648
  readonly payload: import("effect/Schema").Json;
533
649
  };
534
650
  };
535
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
536
- readonly type: "evaluator.evaluated";
537
- readonly payload: {
538
- readonly evaluationId: string;
539
- readonly definitionName?: string | undefined;
540
- readonly answers: {
541
- readonly [x: string]: {
542
- readonly type: "boolean";
543
- readonly value: boolean;
544
- readonly probability: number;
545
- } | {
546
- readonly type: "choice";
547
- readonly value: string;
548
- } | {
549
- readonly type: "score";
550
- readonly value: number;
551
- };
552
- };
553
- readonly route: string;
554
- readonly reason: "model" | "skipped" | "unavailable" | "uncertain";
555
- readonly usage?: {
556
- readonly input: number;
557
- readonly output: number;
558
- } | undefined;
559
- };
560
- }) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
561
- readonly type: "evaluator.requested";
562
- readonly payload: {
563
- readonly evaluationId: string;
564
- readonly definitionName?: string | undefined;
565
- readonly state: string;
566
- readonly model?: string | undefined;
567
- };
568
651
  })>;
569
652
  };
570
653
  readonly threads: {
571
654
  evaluator: import("@swirls/looms/core").ThreadDefinition<{
572
655
  readonly definitionName?: string | undefined;
656
+ readonly definitionVersion?: string | undefined;
573
657
  readonly input: import("effect/Schema").Json;
574
658
  readonly evaluationId: string;
575
659
  readonly dispatched: boolean;
@@ -1,5 +1,5 @@
1
1
  import { Layer } from 'effect';
2
- import { defineModule } from '@swirls/looms/core';
2
+ import { defineModule, makeDefinitionStore } from '@swirls/looms/core';
3
3
  import { EvaluatorDefinitionsLive } from './definitions-store.js';
4
4
  import { evaluateEffect } from './effects.js';
5
5
  import { evaluatorFromAdapter, EvaluatorTag, StubEvaluatorLive, } from './evaluator.js';
@@ -7,12 +7,13 @@ import { evaluations } from './projections.js';
7
7
  import { evaluatorModule } from './scope.js';
8
8
  import { evaluatorThread } from './threads.js';
9
9
  export function evaluator(options = {}) {
10
- const definitions = options.definitions ?? [];
10
+ const listed = options.definitions ?? [];
11
+ const definitions = makeDefinitionStore('evaluator', listed);
11
12
  const evaluatorLayer = options.evaluator
12
13
  ? Layer.succeed(EvaluatorTag, evaluatorFromAdapter(options.evaluator))
13
14
  : StubEvaluatorLive(options.evaluatorPolicy);
14
15
  return defineModule(evaluatorModule, () => ({
15
- definitions,
16
+ definitions: listed,
16
17
  threads: { evaluator: evaluatorThread },
17
18
  effects: {
18
19
  evaluate: evaluateEffect,
@@ -21,5 +22,8 @@ export function evaluator(options = {}) {
21
22
  evaluations,
22
23
  },
23
24
  services: () => Layer.merge(evaluatorLayer, EvaluatorDefinitionsLive(definitions)),
25
+ bindHost(host) {
26
+ definitions.useResolver(host.definitionResolver);
27
+ },
24
28
  }));
25
29
  }
@@ -1,6 +1,7 @@
1
1
  import { Schema } from 'effect';
2
2
  export declare const EvaluatorThreadStateSchema: Schema.Struct<{
3
3
  readonly definitionName: Schema.optional<Schema.String>;
4
+ readonly definitionVersion: Schema.optional<Schema.String>;
4
5
  readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
5
6
  readonly evaluationId: Schema.String;
6
7
  readonly dispatched: Schema.Boolean;
@@ -31,6 +32,7 @@ export declare const EvaluatorThreadStateSchema: Schema.Struct<{
31
32
  export type EvaluatorThreadState = Schema.Schema.Type<typeof EvaluatorThreadStateSchema>;
32
33
  export declare const evaluatorThread: import("@swirls/looms/core").ThreadDefinition<{
33
34
  readonly definitionName?: string | undefined;
35
+ readonly definitionVersion?: string | undefined;
34
36
  readonly input: Schema.Json;
35
37
  readonly evaluationId: string;
36
38
  readonly dispatched: boolean;
@@ -5,6 +5,7 @@ import { EvaluatorEvaluatedPayloadSchema } from './events.js';
5
5
  import { evaluatorModule } from './scope.js';
6
6
  export const EvaluatorThreadStateSchema = Schema.Struct({
7
7
  definitionName: Schema.optional(Schema.String),
8
+ definitionVersion: Schema.optional(Schema.String),
8
9
  input: Schema.Json,
9
10
  evaluationId: Schema.String,
10
11
  dispatched: Schema.Boolean,
@@ -26,6 +27,7 @@ export const evaluatorThread = evaluatorModule.thread({
26
27
  shape: EvaluatorThreadStateSchema,
27
28
  initialState: (ctx) => ({
28
29
  definitionName: ctx.definitionName,
30
+ definitionVersion: ctx.definitionVersion,
29
31
  input: ctx.input,
30
32
  evaluationId: `eval_${ctx.threadId}`,
31
33
  dispatched: false,
@@ -42,6 +44,7 @@ export const evaluatorThread = evaluatorModule.thread({
42
44
  return {
43
45
  ...state,
44
46
  definitionName: event.payload.definitionName || state.definitionName,
47
+ definitionVersion: event.payload.definitionVersion || state.definitionVersion,
45
48
  input: event.payload.input ?? state.input,
46
49
  evaluationId: `eval_${ctx.threadId}`,
47
50
  };
@@ -105,6 +108,7 @@ export const evaluatorThread = evaluatorModule.thread({
105
108
  effects.push(invoke(evaluateEffect, {
106
109
  evaluationId: state.evaluationId,
107
110
  definitionName: state.definitionName,
111
+ definitionVersion: state.definitionVersion,
108
112
  input: state.input,
109
113
  }, `evaluate_${state.evaluationId}`));
110
114
  }
@@ -0,0 +1,87 @@
1
+ import { type Sql } from 'postgres';
2
+ import { type EventEnvelope, type EventOrigin, type EventStore, type JsonValue, type RunStatus } from '@swirls/looms/core';
3
+ import type { Projector } from './projector';
4
+ export declare const POSTGRES_EVENT_LOG_SCHEMA_SQL: string;
5
+ export interface EventLogEntry {
6
+ readonly runId: string;
7
+ readonly seq: number;
8
+ readonly eventId: string;
9
+ readonly ts: number;
10
+ readonly type: string;
11
+ readonly payload: JsonValue;
12
+ readonly threadId: string | null;
13
+ readonly parentThreadId: string | null;
14
+ readonly causationId: string | null;
15
+ readonly correlationId: string | null;
16
+ readonly effectId: string | null;
17
+ readonly origin: EventOrigin;
18
+ readonly idempotencyKey: string | null;
19
+ }
20
+ export interface RunLogRow {
21
+ readonly runId: string;
22
+ readonly status: RunStatus;
23
+ readonly kind: string | null;
24
+ readonly definitionName: string | null;
25
+ readonly definitionVersion: string | null;
26
+ readonly rootThreadId: string | null;
27
+ readonly parentRunId: string | null;
28
+ readonly launchedByEffectId: string | null;
29
+ readonly correlationId: string | null;
30
+ readonly attributes: {
31
+ readonly [key: string]: string;
32
+ };
33
+ readonly tenant: string | null;
34
+ readonly project: string | null;
35
+ readonly org: string | null;
36
+ readonly startedAt: number | null;
37
+ readonly updatedAt: number;
38
+ readonly completedAt: number | null;
39
+ }
40
+ export type EventLogOp = {
41
+ readonly type: 'insert';
42
+ readonly entry: EventLogEntry;
43
+ } | {
44
+ readonly type: 'start';
45
+ readonly runId: string;
46
+ readonly kind: string | null;
47
+ readonly definitionName: string | null;
48
+ readonly definitionVersion: string | null;
49
+ readonly rootThreadId: string | null;
50
+ readonly parentRunId: string | null;
51
+ readonly launchedByEffectId: string | null;
52
+ readonly correlationId: string | null;
53
+ readonly attributes: {
54
+ readonly [key: string]: string;
55
+ };
56
+ readonly tenant: string | null;
57
+ readonly project: string | null;
58
+ readonly org: string | null;
59
+ readonly at: number;
60
+ } | {
61
+ readonly type: 'finish';
62
+ readonly runId: string;
63
+ readonly status: 'completed' | 'failed' | 'cancelled';
64
+ readonly at: number;
65
+ } | {
66
+ readonly type: 'touch';
67
+ readonly runId: string;
68
+ readonly at: number;
69
+ };
70
+ export interface EventLogProjector extends Projector {
71
+ /** Replays the source log into this sink. Safe to repeat; do not run it beside live delivery. */
72
+ rebuild(source: EventStore, options?: {
73
+ readonly runId?: string;
74
+ readonly batchSize?: number;
75
+ }): Promise<number>;
76
+ }
77
+ export interface MemoryEventLog extends EventLogProjector {
78
+ events(runId: string): readonly EventLogEntry[];
79
+ run(runId: string): RunLogRow | null;
80
+ }
81
+ export declare function eventLogOps(event: EventEnvelope): readonly EventLogOp[];
82
+ export declare function memoryEventLog(): MemoryEventLog;
83
+ export declare function postgresEventLog(options: {
84
+ url: string;
85
+ } | {
86
+ sql: Sql;
87
+ }): EventLogProjector;