@swirls/looms 0.3.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.
- package/CHANGELOG.md +64 -0
- package/dist/actor/cell.d.ts +21 -2
- package/dist/actor/cell.js +15 -3
- package/dist/actor/host.d.ts +10 -2
- package/dist/actor/host.js +27 -4
- package/dist/actor/index.d.ts +2 -1
- package/dist/actor/index.js +1 -1
- package/dist/actor/routing.d.ts +3 -0
- package/dist/actor/routing.js +13 -2
- package/dist/agent/debugger/agent-chat.js +3 -30
- package/dist/agent/debugger/streaming-text.d.ts +6 -0
- package/dist/agent/debugger/streaming-text.js +33 -0
- package/dist/agent/definitions-store.d.ts +1 -1
- package/dist/agent/definitions-store.js +1 -1
- package/dist/agent/definitions.d.ts +48 -0
- package/dist/agent/definitions.js +44 -0
- package/dist/agent/effects.d.ts +184 -0
- package/dist/agent/effects.js +172 -40
- package/dist/agent/events.d.ts +89 -0
- package/dist/agent/events.js +25 -0
- package/dist/agent/module.d.ts +819 -407
- package/dist/agent/module.js +5 -1
- package/dist/agent/scope.d.ts +88 -0
- package/dist/agent/threads.js +39 -3
- package/dist/agent/types.d.ts +4 -0
- package/dist/approval/effects.d.ts +40 -0
- package/dist/approval/module.d.ts +80 -0
- package/dist/client/client.d.ts +468 -119
- package/dist/client/client.js +214 -21
- package/dist/client/index.d.ts +1 -1
- package/dist/client/sse.d.ts +1 -1
- package/dist/client/sse.js +2 -2
- package/dist/cloudflare/durable-object.d.ts +66 -2
- package/dist/cloudflare/durable-object.js +96 -1
- package/dist/cloudflare/event-store.d.ts +7 -3
- package/dist/cloudflare/event-store.js +16 -3
- package/dist/cloudflare/index.d.ts +7 -1
- package/dist/cloudflare/index.js +7 -1
- package/dist/cloudflare/memory-queue.d.ts +18 -0
- package/dist/cloudflare/memory-queue.js +53 -0
- package/dist/cloudflare/queue-consumer.d.ts +52 -0
- package/dist/cloudflare/queue-consumer.js +102 -0
- package/dist/cloudflare/queue-message.d.ts +31 -0
- package/dist/cloudflare/queue-message.js +33 -0
- package/dist/cloudflare/queue-pull.d.ts +62 -0
- package/dist/cloudflare/queue-pull.js +130 -0
- package/dist/cloudflare/queue-worker.d.ts +39 -0
- package/dist/cloudflare/queue-worker.js +62 -0
- package/dist/cloudflare/r2-blob-store.d.ts +33 -0
- package/dist/cloudflare/r2-blob-store.js +60 -0
- package/dist/cloudflare/router.d.ts +4 -1
- package/dist/cloudflare/router.js +8 -3
- package/dist/cloudflare/websocket.d.ts +27 -0
- package/dist/cloudflare/websocket.js +215 -0
- package/dist/core/attempts.d.ts +8 -0
- package/dist/core/attempts.js +27 -0
- package/dist/core/blob-offload.d.ts +21 -0
- package/dist/core/blob-offload.js +143 -0
- package/dist/core/blob-store.d.ts +45 -0
- package/dist/core/blob-store.js +164 -0
- package/dist/core/blobs.d.ts +37 -0
- package/dist/core/blobs.js +160 -0
- package/dist/core/definition-resolver.d.ts +40 -0
- package/dist/core/definition-resolver.js +129 -0
- package/dist/core/definition-store.d.ts +6 -0
- package/dist/core/definition-store.js +37 -1
- package/dist/core/effects.d.ts +86 -3
- package/dist/core/effects.js +99 -3
- package/dist/core/envelope.d.ts +9 -0
- package/dist/core/envelope.js +4 -0
- package/dist/core/event-codec.js +3 -0
- package/dist/core/fold.js +83 -1
- package/dist/core/ids.d.ts +2 -0
- package/dist/core/ids.js +4 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.js +9 -0
- package/dist/core/launcher.d.ts +97 -0
- package/dist/core/launcher.js +67 -0
- package/dist/core/module-scope.d.ts +7 -3
- package/dist/core/module-scope.js +3 -0
- package/dist/core/module.d.ts +10 -0
- package/dist/core/projection.d.ts +5 -4
- package/dist/core/projection.js +4 -0
- package/dist/core/protocol.d.ts +36 -1
- package/dist/core/protocol.js +35 -0
- package/dist/core/published.d.ts +2 -0
- package/dist/core/published.js +4 -1
- package/dist/{react → core}/register.d.ts +9 -8
- package/dist/core/replay.d.ts +96 -0
- package/dist/core/run-context.d.ts +33 -0
- package/dist/core/run-context.js +23 -0
- package/dist/core/sqlite-store.js +57 -5
- package/dist/core/state.d.ts +60 -0
- package/dist/core/state.js +19 -0
- package/dist/core/store.d.ts +6 -0
- package/dist/core/store.js +7 -0
- package/dist/core/subscription.d.ts +97 -0
- package/dist/core/subscription.js +224 -0
- package/dist/core/thread.d.ts +7 -0
- package/dist/core/thread.js +1 -0
- package/dist/core/trace.d.ts +21 -0
- package/dist/core/trace.js +45 -0
- package/dist/core/worker-callback.d.ts +25 -1
- package/dist/debugger/app/assets/{index-CgDzWJg7.css → index-B7GdT1UA.css} +1 -1
- package/dist/debugger/app/assets/index-C31SnCuN.js +22 -0
- package/dist/debugger/app/assets/routes-DPA3O5AF.js +47 -0
- package/dist/debugger/app/index.html +2 -2
- package/dist/debugger/components/event-inspector.d.ts +3 -1
- package/dist/debugger/components/event-inspector.js +25 -4
- package/dist/debugger/components/event-stream.d.ts +4 -1
- package/dist/debugger/components/event-stream.js +2 -2
- package/dist/debugger/components/run-tree.d.ts +5 -2
- package/dist/debugger/components/run-tree.js +10 -4
- package/dist/debugger/context.d.ts +8 -1
- package/dist/debugger/context.js +15 -3
- package/dist/debugger/events/protocol-summarize.js +18 -3
- package/dist/debugger/index.d.ts +1 -1
- package/dist/debugger/index.js +1 -1
- package/dist/debugger/shell/debugger-shell.js +1 -1
- package/dist/debugger/shell/events-pane.js +4 -3
- package/dist/debugger/styles.css +1 -0
- package/dist/evaluator/definitions-store.d.ts +3 -4
- package/dist/evaluator/definitions-store.js +3 -3
- package/dist/evaluator/definitions.d.ts +4 -1
- package/dist/evaluator/definitions.js +5 -2
- package/dist/evaluator/effects.d.ts +41 -0
- package/dist/evaluator/effects.js +6 -2
- package/dist/evaluator/module.d.ts +84 -0
- package/dist/evaluator/module.js +7 -3
- package/dist/evaluator/threads.d.ts +2 -0
- package/dist/evaluator/threads.js +4 -0
- package/dist/projectors/event-log.d.ts +87 -0
- package/dist/projectors/event-log.js +396 -0
- package/dist/projectors/index-model.d.ts +12 -0
- package/dist/projectors/index-model.js +12 -3
- package/dist/projectors/memory.js +7 -0
- package/dist/projectors/postgres.d.ts +1 -0
- package/dist/projectors/postgres.js +32 -15
- package/dist/projectors/schema.d.ts +5 -0
- package/dist/projectors/schema.js +26 -1
- package/dist/projectors/sqlite.js +47 -19
- package/dist/projectors/with-projectors.d.ts +7 -1
- package/dist/projectors/with-projectors.js +13 -3
- package/dist/react/derived.d.ts +26 -8
- package/dist/react/derived.js +23 -26
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +2 -2
- package/dist/react/materialize.js +5 -1
- package/dist/react/react.d.ts +16 -9
- package/dist/react/react.js +47 -23
- package/dist/react/store.d.ts +14 -6
- package/dist/react/store.js +104 -12
- package/dist/react/tables.d.ts +4 -1
- package/dist/runtime/cancellation.d.ts +2 -1
- package/dist/runtime/cancellation.js +35 -2
- package/dist/runtime/child-run.d.ts +10 -0
- package/dist/runtime/child-run.js +58 -0
- package/dist/runtime/deadline-transition-planner.js +11 -2
- package/dist/runtime/dispatch-effect.d.ts +2 -2
- package/dist/runtime/dispatch-effect.js +43 -19
- package/dist/runtime/errors.d.ts +14 -1
- package/dist/runtime/errors.js +10 -0
- package/dist/runtime/filesystem-blob-store.d.ts +6 -0
- package/dist/runtime/filesystem-blob-store.js +59 -0
- package/dist/runtime/helpers.d.ts +15 -6
- package/dist/runtime/helpers.js +46 -6
- package/dist/runtime/index.d.ts +4 -2
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/local-effect-executor.d.ts +11 -2
- package/dist/runtime/local-effect-executor.js +80 -4
- package/dist/runtime/looms.d.ts +38 -4
- package/dist/runtime/looms.js +17 -3
- package/dist/runtime/repository.d.ts +5 -4
- package/dist/runtime/repository.js +5 -2
- package/dist/runtime/retry-policy.d.ts +5 -0
- package/dist/runtime/retry-policy.js +10 -2
- package/dist/runtime/run-start.d.ts +1 -1
- package/dist/runtime/run-start.js +10 -0
- package/dist/runtime/runtime.d.ts +2 -2
- package/dist/runtime/runtime.js +191 -68
- package/dist/runtime/server/auth.d.ts +3 -0
- package/dist/runtime/server/fetch-handler.d.ts +2 -2
- package/dist/runtime/server/fetch-handler.js +35 -4
- package/dist/runtime/server/grant.d.ts +49 -0
- package/dist/runtime/server/grant.js +177 -0
- package/dist/runtime/server/routes/effects.js +47 -5
- package/dist/runtime/server/routes/runs.js +6 -1
- package/dist/runtime/server/run-route.d.ts +18 -0
- package/dist/runtime/server/run-route.js +26 -0
- package/dist/runtime/server.d.ts +3 -1
- package/dist/runtime/server.js +3 -1
- package/dist/runtime/sse.js +26 -4
- package/dist/runtime/subscription.d.ts +8 -0
- package/dist/runtime/subscription.js +23 -0
- package/dist/runtime/types.d.ts +87 -8
- package/dist/runtime/wake-engine.d.ts +4 -2
- package/dist/runtime/wake-engine.js +57 -6
- package/dist/runtime/worker-callbacks.d.ts +12 -2
- package/dist/runtime/worker-callbacks.js +102 -72
- package/dist/runtime/worker-effect-dispatch.d.ts +14 -5
- package/dist/runtime/worker-effect-dispatch.js +84 -18
- package/dist/schedule/debugger/index.d.ts +4 -0
- package/dist/schedule/debugger/index.js +11 -0
- package/dist/schedule/debugger/schedule-view.d.ts +3 -0
- package/dist/schedule/debugger/schedule-view.js +68 -0
- package/dist/schedule/debugger/summarize.d.ts +2 -0
- package/dist/schedule/debugger/summarize.js +43 -0
- package/dist/schedule/definitions-store.d.ts +10 -0
- package/dist/schedule/definitions-store.js +8 -0
- package/dist/schedule/definitions.d.ts +57 -0
- package/dist/schedule/definitions.js +30 -0
- package/dist/schedule/effects.d.ts +756 -0
- package/dist/schedule/effects.js +244 -0
- package/dist/schedule/ensure.d.ts +55 -0
- package/dist/schedule/ensure.js +109 -0
- package/dist/schedule/events.d.ts +116 -0
- package/dist/schedule/events.js +49 -0
- package/dist/schedule/index.d.ts +11 -0
- package/dist/schedule/index.js +11 -0
- package/dist/schedule/module.d.ts +1474 -0
- package/dist/schedule/module.js +22 -0
- package/dist/schedule/projections.d.ts +55 -0
- package/dist/schedule/projections.js +88 -0
- package/dist/schedule/scope.d.ts +121 -0
- package/dist/schedule/scope.js +7 -0
- package/dist/schedule/signals.d.ts +25 -0
- package/dist/schedule/signals.js +33 -0
- package/dist/schedule/specs.d.ts +59 -0
- package/dist/schedule/specs.js +231 -0
- package/dist/schedule/threads.d.ts +25 -0
- package/dist/schedule/threads.js +259 -0
- package/dist/testing/corpus-module.d.ts +34 -0
- package/dist/testing/corpus-module.js +87 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +5 -6
- package/dist/testing/replay-corpus.d.ts +22 -0
- package/dist/testing/replay-corpus.js +50 -0
- package/dist/workflow/definitions-store.d.ts +1 -1
- package/dist/workflow/definitions-store.js +1 -1
- package/dist/workflow/definitions.d.ts +14 -0
- package/dist/workflow/effects.d.ts +122 -0
- package/dist/workflow/effects.js +16 -6
- package/dist/workflow/events.d.ts +42 -0
- package/dist/workflow/events.js +4 -0
- package/dist/workflow/module.d.ts +345 -32
- package/dist/workflow/module.js +7 -3
- package/dist/workflow/scope.d.ts +42 -0
- package/dist/workflow/threads.d.ts +72 -0
- package/dist/workflow/threads.js +106 -38
- package/package.json +11 -2
- package/dist/debugger/app/assets/index-BevQYa-U.js +0 -22
- package/dist/debugger/app/assets/routes-B17Om93i.js +0 -47
- /package/dist/{react → core}/register.js +0 -0
|
@@ -23,6 +23,19 @@ export declare const scheduleEffect: NoInfer<import("@swirls/looms/core").Effect
|
|
|
23
23
|
} | undefined;
|
|
24
24
|
readonly input?: Schema.Json | undefined;
|
|
25
25
|
}, WorkflowDefinitionsTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
26
|
+
readonly type: "runtime.child.close.requested";
|
|
27
|
+
readonly payload: {
|
|
28
|
+
readonly policy: "terminate" | "wait";
|
|
29
|
+
};
|
|
30
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
31
|
+
readonly type: "runtime.child.settled";
|
|
32
|
+
readonly payload: {
|
|
33
|
+
readonly runId: string;
|
|
34
|
+
readonly status: "cancelled" | "completed" | "failed";
|
|
35
|
+
readonly output: Schema.Json;
|
|
36
|
+
readonly error: string | null;
|
|
37
|
+
};
|
|
38
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
26
39
|
readonly type: "runtime.effect.ambiguous";
|
|
27
40
|
readonly payload: {
|
|
28
41
|
readonly effectId: string;
|
|
@@ -66,6 +79,8 @@ export declare const scheduleEffect: NoInfer<import("@swirls/looms/core").Effect
|
|
|
66
79
|
readonly payload: {
|
|
67
80
|
readonly effectId: string;
|
|
68
81
|
readonly error: string;
|
|
82
|
+
readonly nonRetryable?: boolean | undefined;
|
|
83
|
+
readonly retryAfterMs?: number | undefined;
|
|
69
84
|
};
|
|
70
85
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
71
86
|
readonly type: "runtime.effect.heartbeat";
|
|
@@ -74,6 +89,7 @@ export declare const scheduleEffect: NoInfer<import("@swirls/looms/core").Effect
|
|
|
74
89
|
readonly attempt: number;
|
|
75
90
|
readonly heartbeatAt: number;
|
|
76
91
|
readonly deadlineAt: number | null;
|
|
92
|
+
readonly details?: Schema.Json | undefined;
|
|
77
93
|
};
|
|
78
94
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
79
95
|
readonly type: "runtime.effect.queued";
|
|
@@ -126,6 +142,16 @@ export declare const scheduleEffect: NoInfer<import("@swirls/looms/core").Effect
|
|
|
126
142
|
readonly sourceRunId: string;
|
|
127
143
|
readonly sourceSeq: number;
|
|
128
144
|
};
|
|
145
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
146
|
+
readonly type: "runtime.run.launched";
|
|
147
|
+
readonly payload: {
|
|
148
|
+
readonly runId: string;
|
|
149
|
+
readonly kind: string;
|
|
150
|
+
readonly definitionName: string;
|
|
151
|
+
readonly definitionVersion: string;
|
|
152
|
+
readonly effectId: string;
|
|
153
|
+
readonly close: "terminate" | "wait";
|
|
154
|
+
};
|
|
129
155
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
130
156
|
readonly type: "runtime.run.started";
|
|
131
157
|
readonly payload: {
|
|
@@ -135,6 +161,20 @@ export declare const scheduleEffect: NoInfer<import("@swirls/looms/core").Effect
|
|
|
135
161
|
readonly definitionVersion: string;
|
|
136
162
|
readonly input: Schema.Json;
|
|
137
163
|
readonly requestedThreadId?: string | null | undefined;
|
|
164
|
+
readonly launchedBy?: {
|
|
165
|
+
readonly runId: string;
|
|
166
|
+
readonly threadId: string;
|
|
167
|
+
readonly effectId: string;
|
|
168
|
+
readonly causationId: string;
|
|
169
|
+
readonly causationSeq: number;
|
|
170
|
+
} | undefined;
|
|
171
|
+
readonly attributes?: {
|
|
172
|
+
readonly [x: string]: string;
|
|
173
|
+
} | undefined;
|
|
174
|
+
readonly trace?: {
|
|
175
|
+
readonly traceparent: string;
|
|
176
|
+
readonly tracestate?: string | undefined;
|
|
177
|
+
} | undefined;
|
|
138
178
|
};
|
|
139
179
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
140
180
|
readonly type: "runtime.signal.received";
|
|
@@ -258,6 +298,9 @@ export declare const scheduleEffect: NoInfer<import("@swirls/looms/core").Effect
|
|
|
258
298
|
readonly actorId?: string | undefined;
|
|
259
299
|
} | {
|
|
260
300
|
readonly type: "system";
|
|
301
|
+
} | {
|
|
302
|
+
readonly type: "run";
|
|
303
|
+
readonly runId: string;
|
|
261
304
|
} | undefined;
|
|
262
305
|
readonly ephemeral?: boolean | undefined;
|
|
263
306
|
readonly id?: string | undefined;
|
|
@@ -275,10 +318,24 @@ export declare const scheduleEffect: NoInfer<import("@swirls/looms/core").Effect
|
|
|
275
318
|
readonly type: "runtime.cancel";
|
|
276
319
|
readonly threadId: string;
|
|
277
320
|
readonly tag?: string | undefined;
|
|
321
|
+
} | {
|
|
322
|
+
readonly type: "runtime.launch";
|
|
323
|
+
readonly runId: string;
|
|
324
|
+
readonly kind: string;
|
|
325
|
+
readonly definitionName: string;
|
|
326
|
+
readonly definitionVersion: string;
|
|
327
|
+
readonly input: Schema.Json;
|
|
328
|
+
readonly close: "terminate" | "wait";
|
|
329
|
+
readonly tag?: string | undefined;
|
|
330
|
+
} | {
|
|
331
|
+
readonly type: "runtime.cancelRun";
|
|
332
|
+
readonly runId: string;
|
|
333
|
+
readonly tag?: string | undefined;
|
|
278
334
|
} | {
|
|
279
335
|
readonly type: string;
|
|
280
336
|
readonly input: Schema.Json;
|
|
281
337
|
readonly tag?: string | undefined;
|
|
338
|
+
readonly at?: number | undefined;
|
|
282
339
|
})[];
|
|
283
340
|
};
|
|
284
341
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
@@ -292,6 +349,8 @@ export declare const scheduleEffect: NoInfer<import("@swirls/looms/core").Effect
|
|
|
292
349
|
readonly items: readonly Schema.Json[];
|
|
293
350
|
readonly concurrency: number;
|
|
294
351
|
readonly limitBytes: number;
|
|
352
|
+
readonly execution: "run" | "thread";
|
|
353
|
+
readonly close: "terminate" | "wait";
|
|
295
354
|
};
|
|
296
355
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
297
356
|
readonly type: "workflow.node.finished";
|
|
@@ -331,6 +390,8 @@ export declare const scheduleEffect: NoInfer<import("@swirls/looms/core").Effect
|
|
|
331
390
|
readonly definitionVersion: string;
|
|
332
391
|
readonly input: Schema.Json;
|
|
333
392
|
readonly loopIndex: number | null;
|
|
393
|
+
readonly execution: "run" | "thread";
|
|
394
|
+
readonly close: "terminate" | "wait";
|
|
334
395
|
};
|
|
335
396
|
})>>;
|
|
336
397
|
export declare function scheduleEvents(definition: WorkflowDefinition, binding: {
|
|
@@ -362,6 +423,19 @@ export declare const runNodeEffect: NoInfer<import("@swirls/looms/core").EffectD
|
|
|
362
423
|
};
|
|
363
424
|
} | undefined;
|
|
364
425
|
}, WorkflowDefinitionsTag, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
426
|
+
readonly type: "runtime.child.close.requested";
|
|
427
|
+
readonly payload: {
|
|
428
|
+
readonly policy: "terminate" | "wait";
|
|
429
|
+
};
|
|
430
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
431
|
+
readonly type: "runtime.child.settled";
|
|
432
|
+
readonly payload: {
|
|
433
|
+
readonly runId: string;
|
|
434
|
+
readonly status: "cancelled" | "completed" | "failed";
|
|
435
|
+
readonly output: Schema.Json;
|
|
436
|
+
readonly error: string | null;
|
|
437
|
+
};
|
|
438
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
365
439
|
readonly type: "runtime.effect.ambiguous";
|
|
366
440
|
readonly payload: {
|
|
367
441
|
readonly effectId: string;
|
|
@@ -405,6 +479,8 @@ export declare const runNodeEffect: NoInfer<import("@swirls/looms/core").EffectD
|
|
|
405
479
|
readonly payload: {
|
|
406
480
|
readonly effectId: string;
|
|
407
481
|
readonly error: string;
|
|
482
|
+
readonly nonRetryable?: boolean | undefined;
|
|
483
|
+
readonly retryAfterMs?: number | undefined;
|
|
408
484
|
};
|
|
409
485
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
410
486
|
readonly type: "runtime.effect.heartbeat";
|
|
@@ -413,6 +489,7 @@ export declare const runNodeEffect: NoInfer<import("@swirls/looms/core").EffectD
|
|
|
413
489
|
readonly attempt: number;
|
|
414
490
|
readonly heartbeatAt: number;
|
|
415
491
|
readonly deadlineAt: number | null;
|
|
492
|
+
readonly details?: Schema.Json | undefined;
|
|
416
493
|
};
|
|
417
494
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
418
495
|
readonly type: "runtime.effect.queued";
|
|
@@ -465,6 +542,16 @@ export declare const runNodeEffect: NoInfer<import("@swirls/looms/core").EffectD
|
|
|
465
542
|
readonly sourceRunId: string;
|
|
466
543
|
readonly sourceSeq: number;
|
|
467
544
|
};
|
|
545
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
546
|
+
readonly type: "runtime.run.launched";
|
|
547
|
+
readonly payload: {
|
|
548
|
+
readonly runId: string;
|
|
549
|
+
readonly kind: string;
|
|
550
|
+
readonly definitionName: string;
|
|
551
|
+
readonly definitionVersion: string;
|
|
552
|
+
readonly effectId: string;
|
|
553
|
+
readonly close: "terminate" | "wait";
|
|
554
|
+
};
|
|
468
555
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
469
556
|
readonly type: "runtime.run.started";
|
|
470
557
|
readonly payload: {
|
|
@@ -474,6 +561,20 @@ export declare const runNodeEffect: NoInfer<import("@swirls/looms/core").EffectD
|
|
|
474
561
|
readonly definitionVersion: string;
|
|
475
562
|
readonly input: Schema.Json;
|
|
476
563
|
readonly requestedThreadId?: string | null | undefined;
|
|
564
|
+
readonly launchedBy?: {
|
|
565
|
+
readonly runId: string;
|
|
566
|
+
readonly threadId: string;
|
|
567
|
+
readonly effectId: string;
|
|
568
|
+
readonly causationId: string;
|
|
569
|
+
readonly causationSeq: number;
|
|
570
|
+
} | undefined;
|
|
571
|
+
readonly attributes?: {
|
|
572
|
+
readonly [x: string]: string;
|
|
573
|
+
} | undefined;
|
|
574
|
+
readonly trace?: {
|
|
575
|
+
readonly traceparent: string;
|
|
576
|
+
readonly tracestate?: string | undefined;
|
|
577
|
+
} | undefined;
|
|
477
578
|
};
|
|
478
579
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
479
580
|
readonly type: "runtime.signal.received";
|
|
@@ -597,6 +698,9 @@ export declare const runNodeEffect: NoInfer<import("@swirls/looms/core").EffectD
|
|
|
597
698
|
readonly actorId?: string | undefined;
|
|
598
699
|
} | {
|
|
599
700
|
readonly type: "system";
|
|
701
|
+
} | {
|
|
702
|
+
readonly type: "run";
|
|
703
|
+
readonly runId: string;
|
|
600
704
|
} | undefined;
|
|
601
705
|
readonly ephemeral?: boolean | undefined;
|
|
602
706
|
readonly id?: string | undefined;
|
|
@@ -614,10 +718,24 @@ export declare const runNodeEffect: NoInfer<import("@swirls/looms/core").EffectD
|
|
|
614
718
|
readonly type: "runtime.cancel";
|
|
615
719
|
readonly threadId: string;
|
|
616
720
|
readonly tag?: string | undefined;
|
|
721
|
+
} | {
|
|
722
|
+
readonly type: "runtime.launch";
|
|
723
|
+
readonly runId: string;
|
|
724
|
+
readonly kind: string;
|
|
725
|
+
readonly definitionName: string;
|
|
726
|
+
readonly definitionVersion: string;
|
|
727
|
+
readonly input: Schema.Json;
|
|
728
|
+
readonly close: "terminate" | "wait";
|
|
729
|
+
readonly tag?: string | undefined;
|
|
730
|
+
} | {
|
|
731
|
+
readonly type: "runtime.cancelRun";
|
|
732
|
+
readonly runId: string;
|
|
733
|
+
readonly tag?: string | undefined;
|
|
617
734
|
} | {
|
|
618
735
|
readonly type: string;
|
|
619
736
|
readonly input: Schema.Json;
|
|
620
737
|
readonly tag?: string | undefined;
|
|
738
|
+
readonly at?: number | undefined;
|
|
621
739
|
})[];
|
|
622
740
|
};
|
|
623
741
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
@@ -631,6 +749,8 @@ export declare const runNodeEffect: NoInfer<import("@swirls/looms/core").EffectD
|
|
|
631
749
|
readonly items: readonly Schema.Json[];
|
|
632
750
|
readonly concurrency: number;
|
|
633
751
|
readonly limitBytes: number;
|
|
752
|
+
readonly execution: "run" | "thread";
|
|
753
|
+
readonly close: "terminate" | "wait";
|
|
634
754
|
};
|
|
635
755
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
636
756
|
readonly type: "workflow.node.finished";
|
|
@@ -670,6 +790,8 @@ export declare const runNodeEffect: NoInfer<import("@swirls/looms/core").EffectD
|
|
|
670
790
|
readonly definitionVersion: string;
|
|
671
791
|
readonly input: Schema.Json;
|
|
672
792
|
readonly loopIndex: number | null;
|
|
793
|
+
readonly execution: "run" | "thread";
|
|
794
|
+
readonly close: "terminate" | "wait";
|
|
673
795
|
};
|
|
674
796
|
})>>;
|
|
675
797
|
export {};
|
package/dist/workflow/effects.js
CHANGED
|
@@ -50,10 +50,12 @@ export const scheduleEffect = workflowModule.effect({
|
|
|
50
50
|
execute: (input, ctx) => Effect.gen(function* () {
|
|
51
51
|
const workflows = yield* WorkflowDefinitionsTag;
|
|
52
52
|
const definition = input.definitionName
|
|
53
|
-
? workflows.
|
|
53
|
+
? yield* workflows.resolve(input.definitionName, input.definitionVersion)
|
|
54
54
|
: undefined;
|
|
55
55
|
if (!definition) {
|
|
56
|
-
return
|
|
56
|
+
return input.definitionName
|
|
57
|
+
? threadFailed(ctx.threadId, `Unknown workflow definition ${input.definitionName}@${input.definitionVersion}`)
|
|
58
|
+
: [];
|
|
57
59
|
}
|
|
58
60
|
const nodes = { ...input.nodes };
|
|
59
61
|
for (const node of definition.nodes) {
|
|
@@ -150,7 +152,7 @@ export const runNodeEffect = workflowModule.effect({
|
|
|
150
152
|
execute: (input, ctx) => Effect.gen(function* () {
|
|
151
153
|
const workflows = yield* WorkflowDefinitionsTag;
|
|
152
154
|
const definition = input.definitionName
|
|
153
|
-
? workflows.
|
|
155
|
+
? yield* workflows.resolve(input.definitionName, input.definitionVersion)
|
|
154
156
|
: undefined;
|
|
155
157
|
const run = {
|
|
156
158
|
threadId: ctx.threadId,
|
|
@@ -225,7 +227,7 @@ function nodeResultEvents(definition, nodeType, run, result) {
|
|
|
225
227
|
(nodeType === 'workflow'
|
|
226
228
|
? nodeChildWorkflowId(threadId, nodeId, attempt)
|
|
227
229
|
: createThreadId());
|
|
228
|
-
return spawnRequested(run, childThreadId, result, result.input);
|
|
230
|
+
return spawnRequested(definition, run, childThreadId, result, result.input);
|
|
229
231
|
}
|
|
230
232
|
case 'sleep': {
|
|
231
233
|
const now = yield* Clock.currentTimeMillis;
|
|
@@ -268,6 +270,7 @@ function nodeResultEvents(definition, nodeType, run, result) {
|
|
|
268
270
|
items: result.items,
|
|
269
271
|
concurrency: result.concurrency,
|
|
270
272
|
limitBytes,
|
|
273
|
+
...childPolicy(definition),
|
|
271
274
|
},
|
|
272
275
|
threadId,
|
|
273
276
|
},
|
|
@@ -279,7 +282,7 @@ function nodeResultEvents(definition, nodeType, run, result) {
|
|
|
279
282
|
return finished(run, run.iteration?.previous ?? null, null);
|
|
280
283
|
}
|
|
281
284
|
const childThreadId = iterationChildWorkflowId(threadId, nodeId, 'loop', attempt, index);
|
|
282
|
-
return spawnRequested(run, childThreadId, result, result.input, index);
|
|
285
|
+
return spawnRequested(definition, run, childThreadId, result, result.input, index);
|
|
283
286
|
}
|
|
284
287
|
default: {
|
|
285
288
|
const exhaustiveCheck = result;
|
|
@@ -288,7 +291,13 @@ function nodeResultEvents(definition, nodeType, run, result) {
|
|
|
288
291
|
}
|
|
289
292
|
});
|
|
290
293
|
}
|
|
291
|
-
function
|
|
294
|
+
function childPolicy(definition) {
|
|
295
|
+
return {
|
|
296
|
+
execution: definition.childExecution ?? 'thread',
|
|
297
|
+
close: definition.childClose ?? 'terminate',
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function spawnRequested(definition, run, childThreadId, child, input, loopIndex = null) {
|
|
292
301
|
return [
|
|
293
302
|
{
|
|
294
303
|
type: 'workflow.spawn.requested',
|
|
@@ -301,6 +310,7 @@ function spawnRequested(run, childThreadId, child, input, loopIndex = null) {
|
|
|
301
310
|
definitionVersion: child.version,
|
|
302
311
|
input,
|
|
303
312
|
loopIndex,
|
|
313
|
+
...childPolicy(definition),
|
|
304
314
|
},
|
|
305
315
|
threadId: run.threadId,
|
|
306
316
|
},
|
|
@@ -24,6 +24,8 @@ export declare const WorkflowSpawnRequestedPayloadSchema: Schema.Struct<{
|
|
|
24
24
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
25
25
|
/** Set for `loop` iterations: the node re-runs after this child instead of finishing. */
|
|
26
26
|
readonly loopIndex: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Finite>, never>;
|
|
27
|
+
readonly execution: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"thread">, Schema.Literal<"run">]>, never>;
|
|
28
|
+
readonly close: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>, never>;
|
|
27
29
|
}>;
|
|
28
30
|
export declare const WorkflowMapRequestedPayloadSchema: Schema.Struct<{
|
|
29
31
|
readonly nodeId: Schema.String;
|
|
@@ -34,6 +36,8 @@ export declare const WorkflowMapRequestedPayloadSchema: Schema.Struct<{
|
|
|
34
36
|
readonly items: Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
35
37
|
readonly concurrency: Schema.Finite;
|
|
36
38
|
readonly limitBytes: Schema.Finite;
|
|
39
|
+
readonly execution: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"thread">, Schema.Literal<"run">]>, never>;
|
|
40
|
+
readonly close: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>, never>;
|
|
37
41
|
}>;
|
|
38
42
|
export declare const WorkflowSleepRequestedPayloadSchema: Schema.Struct<{
|
|
39
43
|
readonly nodeId: Schema.String;
|
|
@@ -77,6 +81,9 @@ export declare const WorkflowEffectsRequestedPayloadSchema: Schema.Struct<{
|
|
|
77
81
|
readonly actorId: Schema.optional<Schema.String>;
|
|
78
82
|
}>, Schema.Struct<{
|
|
79
83
|
readonly type: Schema.Literal<"system">;
|
|
84
|
+
}>, Schema.Struct<{
|
|
85
|
+
readonly type: Schema.Literal<"run">;
|
|
86
|
+
readonly runId: Schema.String;
|
|
80
87
|
}>]>>;
|
|
81
88
|
readonly ephemeral: Schema.optional<Schema.Boolean>;
|
|
82
89
|
readonly id: Schema.optional<Schema.String>;
|
|
@@ -94,10 +101,24 @@ export declare const WorkflowEffectsRequestedPayloadSchema: Schema.Struct<{
|
|
|
94
101
|
readonly type: Schema.Literal<"runtime.cancel">;
|
|
95
102
|
readonly threadId: Schema.String;
|
|
96
103
|
readonly tag: Schema.optional<Schema.String>;
|
|
104
|
+
}>, Schema.Struct<{
|
|
105
|
+
readonly type: Schema.Literal<"runtime.launch">;
|
|
106
|
+
readonly runId: Schema.String;
|
|
107
|
+
readonly kind: Schema.String;
|
|
108
|
+
readonly definitionName: Schema.String;
|
|
109
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
110
|
+
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
111
|
+
readonly close: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>, never>;
|
|
112
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
113
|
+
}>, Schema.Struct<{
|
|
114
|
+
readonly type: Schema.Literal<"runtime.cancelRun">;
|
|
115
|
+
readonly runId: Schema.String;
|
|
116
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
97
117
|
}>, Schema.Struct<{
|
|
98
118
|
readonly type: Schema.String;
|
|
99
119
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
100
120
|
readonly tag: Schema.optional<Schema.String>;
|
|
121
|
+
readonly at: Schema.optional<Schema.Finite>;
|
|
101
122
|
}>]>>;
|
|
102
123
|
}>;
|
|
103
124
|
export declare const workflowCatalog: import("@swirls/looms/core").EventCatalog<"workflow", {
|
|
@@ -125,6 +146,8 @@ export declare const workflowCatalog: import("@swirls/looms/core").EventCatalog<
|
|
|
125
146
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
126
147
|
/** Set for `loop` iterations: the node re-runs after this child instead of finishing. */
|
|
127
148
|
readonly loopIndex: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Finite>, never>;
|
|
149
|
+
readonly execution: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"thread">, Schema.Literal<"run">]>, never>;
|
|
150
|
+
readonly close: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>, never>;
|
|
128
151
|
}>;
|
|
129
152
|
'map.requested': Schema.Struct<{
|
|
130
153
|
readonly nodeId: Schema.String;
|
|
@@ -135,6 +158,8 @@ export declare const workflowCatalog: import("@swirls/looms/core").EventCatalog<
|
|
|
135
158
|
readonly items: Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
136
159
|
readonly concurrency: Schema.Finite;
|
|
137
160
|
readonly limitBytes: Schema.Finite;
|
|
161
|
+
readonly execution: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"thread">, Schema.Literal<"run">]>, never>;
|
|
162
|
+
readonly close: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>, never>;
|
|
138
163
|
}>;
|
|
139
164
|
'sleep.requested': Schema.Struct<{
|
|
140
165
|
readonly nodeId: Schema.String;
|
|
@@ -178,6 +203,9 @@ export declare const workflowCatalog: import("@swirls/looms/core").EventCatalog<
|
|
|
178
203
|
readonly actorId: Schema.optional<Schema.String>;
|
|
179
204
|
}>, Schema.Struct<{
|
|
180
205
|
readonly type: Schema.Literal<"system">;
|
|
206
|
+
}>, Schema.Struct<{
|
|
207
|
+
readonly type: Schema.Literal<"run">;
|
|
208
|
+
readonly runId: Schema.String;
|
|
181
209
|
}>]>>;
|
|
182
210
|
readonly ephemeral: Schema.optional<Schema.Boolean>;
|
|
183
211
|
readonly id: Schema.optional<Schema.String>;
|
|
@@ -195,10 +223,24 @@ export declare const workflowCatalog: import("@swirls/looms/core").EventCatalog<
|
|
|
195
223
|
readonly type: Schema.Literal<"runtime.cancel">;
|
|
196
224
|
readonly threadId: Schema.String;
|
|
197
225
|
readonly tag: Schema.optional<Schema.String>;
|
|
226
|
+
}>, Schema.Struct<{
|
|
227
|
+
readonly type: Schema.Literal<"runtime.launch">;
|
|
228
|
+
readonly runId: Schema.String;
|
|
229
|
+
readonly kind: Schema.String;
|
|
230
|
+
readonly definitionName: Schema.String;
|
|
231
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
232
|
+
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
233
|
+
readonly close: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"terminate">, Schema.Literal<"wait">]>, never>;
|
|
234
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
235
|
+
}>, Schema.Struct<{
|
|
236
|
+
readonly type: Schema.Literal<"runtime.cancelRun">;
|
|
237
|
+
readonly runId: Schema.String;
|
|
238
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
198
239
|
}>, Schema.Struct<{
|
|
199
240
|
readonly type: Schema.String;
|
|
200
241
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
201
242
|
readonly tag: Schema.optional<Schema.String>;
|
|
243
|
+
readonly at: Schema.optional<Schema.Finite>;
|
|
202
244
|
}>]>>;
|
|
203
245
|
}>;
|
|
204
246
|
}>;
|
package/dist/workflow/events.js
CHANGED
|
@@ -30,6 +30,8 @@ export const WorkflowSpawnRequestedPayloadSchema = Schema.Struct({
|
|
|
30
30
|
input: Schema.Json,
|
|
31
31
|
/** Set for `loop` iterations: the node re-runs after this child instead of finishing. */
|
|
32
32
|
loopIndex: Schema.NullOr(Schema.Finite).pipe(Schema.withDecodingDefaultKey(Effect.succeed(null))),
|
|
33
|
+
execution: Schema.Union([Schema.Literal('thread'), Schema.Literal('run')]).pipe(Schema.withDecodingDefaultKey(Effect.succeed('thread'))),
|
|
34
|
+
close: Schema.Union([Schema.Literal('terminate'), Schema.Literal('wait')]).pipe(Schema.withDecodingDefaultKey(Effect.succeed('terminate'))),
|
|
33
35
|
});
|
|
34
36
|
export const WorkflowMapRequestedPayloadSchema = Schema.Struct({
|
|
35
37
|
nodeId: Schema.String,
|
|
@@ -40,6 +42,8 @@ export const WorkflowMapRequestedPayloadSchema = Schema.Struct({
|
|
|
40
42
|
items: Schema.Array(Schema.Json),
|
|
41
43
|
concurrency: Schema.Finite,
|
|
42
44
|
limitBytes: Schema.Finite,
|
|
45
|
+
execution: Schema.Union([Schema.Literal('thread'), Schema.Literal('run')]).pipe(Schema.withDecodingDefaultKey(Effect.succeed('thread'))),
|
|
46
|
+
close: Schema.Union([Schema.Literal('terminate'), Schema.Literal('wait')]).pipe(Schema.withDecodingDefaultKey(Effect.succeed('terminate'))),
|
|
43
47
|
});
|
|
44
48
|
export const WorkflowSleepRequestedPayloadSchema = Schema.Struct({
|
|
45
49
|
nodeId: Schema.String,
|