@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.
- package/CHANGELOG.md +24 -2
- package/dist/actor/cell.d.ts +9 -4
- package/dist/actor/cell.js +7 -11
- package/dist/actor/host.d.ts +7 -3
- package/dist/actor/host.js +57 -33
- package/dist/actor/index.d.ts +1 -1
- package/dist/actor/index.js +1 -1
- package/dist/actor/routing.d.ts +12 -1
- package/dist/actor/routing.js +57 -51
- package/dist/agent/agent-session.d.ts +5 -0
- package/dist/agent/agent-session.js +270 -0
- package/dist/agent/debugger/agent-chat.d.ts +2 -0
- package/dist/agent/debugger/agent-chat.js +176 -0
- package/dist/agent/debugger/index.d.ts +5 -0
- package/dist/agent/debugger/index.js +19 -0
- package/dist/agent/debugger/summarize.d.ts +2 -0
- package/dist/agent/debugger/summarize.js +51 -0
- package/dist/agent/debugger/token-usage.d.ts +3 -0
- package/dist/agent/debugger/token-usage.js +11 -0
- package/dist/agent/definitions-store.d.ts +2 -3
- package/dist/agent/definitions-store.js +2 -4
- package/dist/agent/definitions.d.ts +47 -29
- package/dist/agent/definitions.js +39 -12
- package/dist/agent/effects.d.ts +359 -2
- package/dist/agent/effects.js +60 -34
- package/dist/agent/events.d.ts +175 -19
- package/dist/agent/events.js +45 -10
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.js +1 -0
- package/dist/agent/llm.d.ts +11 -2
- package/dist/agent/llm.js +13 -3
- package/dist/agent/module.d.ts +812 -78
- package/dist/agent/module.js +16 -4
- package/dist/agent/scope.d.ts +174 -18
- package/dist/agent/signals.d.ts +26 -1
- package/dist/agent/signals.js +79 -0
- package/dist/agent/threads.d.ts +3 -33
- package/dist/agent/threads.js +20 -25
- package/dist/agent/tool-schema.d.ts +1 -17
- package/dist/agent/tool-schema.js +3 -43
- package/dist/agent/types.d.ts +49 -4
- package/dist/agent/types.js +5 -5
- package/dist/ai-vercel/index.d.ts +1 -0
- package/dist/ai-vercel/index.js +1 -0
- package/dist/ai-vercel/messages.js +22 -7
- package/dist/ai-vercel/vercel-evaluator.d.ts +36 -0
- package/dist/ai-vercel/vercel-evaluator.js +73 -0
- package/dist/ai-vercel/vercel-llm.js +64 -44
- package/dist/approval/debugger/approvals-view.d.ts +3 -0
- package/dist/approval/debugger/approvals-view.js +16 -0
- package/dist/approval/debugger/index.d.ts +4 -0
- package/dist/approval/debugger/index.js +11 -0
- package/dist/approval/debugger/summarize.d.ts +2 -0
- package/dist/approval/debugger/summarize.js +17 -0
- package/dist/approval/effects.d.ts +89 -0
- package/dist/approval/module.d.ts +179 -29
- package/dist/approval/projections.d.ts +0 -14
- package/dist/approval/projections.js +20 -3
- package/dist/approval/signals.d.ts +2 -0
- package/dist/approval/signals.js +18 -2
- package/dist/cli/cli.js +2 -0
- package/dist/cli/commands.js +12 -16
- package/dist/client/client.d.ts +1213 -18
- package/dist/client/client.js +120 -120
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/sse.d.ts +13 -0
- package/dist/client/sse.js +38 -44
- package/dist/cloudflare/alarm-scheduler.d.ts +12 -2
- package/dist/cloudflare/alarm-scheduler.js +34 -7
- package/dist/cloudflare/durable-object.d.ts +10 -2
- package/dist/cloudflare/durable-object.js +59 -28
- package/dist/cloudflare/event-store.d.ts +7 -2
- package/dist/cloudflare/event-store.js +8 -7
- package/dist/cloudflare/index.d.ts +2 -2
- package/dist/cloudflare/index.js +2 -2
- package/dist/cloudflare/router.d.ts +1 -1
- package/dist/cloudflare/router.js +15 -16
- package/dist/core/catalog.d.ts +3 -3
- package/dist/core/catalog.js +2 -5
- package/dist/core/coalesce.js +5 -3
- package/dist/core/compose.d.ts +2 -1
- package/dist/core/compose.js +19 -2
- package/dist/core/debugger-host.d.ts +16 -0
- package/dist/core/debugger-host.js +1 -0
- package/dist/core/definition-store.d.ts +11 -0
- package/dist/core/definition-store.js +6 -0
- package/dist/core/effects.d.ts +127 -15
- package/dist/core/effects.js +89 -17
- package/dist/core/envelope.d.ts +27 -7
- package/dist/core/envelope.js +20 -6
- package/dist/core/event-codec.d.ts +4 -2
- package/dist/core/event-codec.js +10 -5
- package/dist/core/event-index.js +1 -3
- package/dist/core/fold.d.ts +3 -0
- package/dist/core/fold.js +171 -24
- package/dist/core/ids.d.ts +5 -0
- package/dist/core/ids.js +35 -2
- package/dist/core/index.d.ts +7 -1
- package/dist/core/index.js +6 -1
- package/dist/core/kind.d.ts +22 -0
- package/dist/core/kind.js +17 -0
- package/dist/core/limits.d.ts +34 -0
- package/dist/core/limits.js +46 -0
- package/dist/core/match.d.ts +1 -0
- package/dist/core/match.js +10 -1
- package/dist/core/module-scope.d.ts +22 -20
- package/dist/core/module-scope.js +38 -28
- package/dist/core/module.d.ts +18 -5
- package/dist/core/module.js +4 -0
- package/dist/core/projection.d.ts +13 -13
- package/dist/core/projection.js +9 -5
- package/dist/core/protocol.d.ts +68 -11
- package/dist/core/protocol.js +82 -11
- package/dist/core/published.d.ts +43 -0
- package/dist/core/published.js +44 -0
- package/dist/core/replay.d.ts +312 -3
- package/dist/core/replay.js +11 -1
- package/dist/core/schema.d.ts +11 -20
- package/dist/core/schema.js +63 -80
- package/dist/core/serialize.js +2 -4
- package/dist/core/snapshot-store.d.ts +6 -1
- package/dist/core/snapshot-store.js +15 -2
- package/dist/core/snapshots.d.ts +5 -1
- package/dist/core/snapshots.js +10 -15
- package/dist/core/sqlite-store.js +95 -11
- package/dist/core/state.d.ts +142 -4
- package/dist/core/state.js +78 -0
- package/dist/core/store.d.ts +38 -3
- package/dist/core/store.js +77 -22
- package/dist/core/thread.d.ts +10 -9
- package/dist/core/types.d.ts +5 -8
- package/dist/core/types.js +28 -24
- package/dist/core/validate-event.js +14 -4
- package/dist/core/worker-callback.d.ts +17 -0
- package/dist/core/worker-callback.js +1 -0
- package/dist/debugger/app/assets/index-B3Ah8WAE.css +2 -0
- package/dist/debugger/app/assets/index-Qb371t_O.js +22 -0
- package/dist/debugger/app/assets/rolldown-runtime-CbXtAM7H.js +1 -0
- package/dist/debugger/app/assets/routes-CjtEHgPQ.js +47 -0
- package/dist/debugger/app/index.html +14 -0
- package/dist/debugger/components/composer.d.ts +17 -0
- package/dist/debugger/components/composer.js +25 -0
- package/dist/debugger/components/debugger-split.d.ts +2 -1
- package/dist/debugger/components/debugger-split.js +2 -2
- package/dist/debugger/components/event-inspector.d.ts +2 -1
- package/dist/debugger/components/event-inspector.js +25 -16
- package/dist/debugger/components/event-stream.d.ts +2 -1
- package/dist/debugger/components/event-stream.js +14 -74
- package/dist/debugger/components/follow-list.d.ts +19 -0
- package/dist/debugger/components/follow-list.js +96 -0
- package/dist/debugger/components/json-tree.d.ts +11 -0
- package/dist/debugger/components/json-tree.js +120 -0
- package/dist/debugger/components/json-view.js +2 -2
- package/dist/debugger/components/run-tree.js +53 -20
- package/dist/debugger/components/status-dot.d.ts +4 -0
- package/dist/debugger/components/status-dot.js +6 -2
- package/dist/debugger/context.d.ts +14 -0
- package/dist/debugger/context.js +17 -0
- package/dist/debugger/contracts.d.ts +7 -4
- package/dist/debugger/events/builtin-families.d.ts +3 -0
- package/dist/debugger/events/builtin-families.js +9 -0
- package/dist/debugger/events/catalog.d.ts +3 -4
- package/dist/debugger/events/catalog.js +27 -17
- package/dist/debugger/events/protocol-summarize.d.ts +1 -2
- package/dist/debugger/events/protocol-summarize.js +42 -24
- package/dist/debugger/index.d.ts +20 -6
- package/dist/debugger/index.js +19 -5
- package/dist/debugger/lib/cn.d.ts +1 -0
- package/dist/debugger/lib/cn.js +3 -0
- package/dist/debugger/lib/event-meta.d.ts +2 -3
- package/dist/debugger/lib/event-meta.js +6 -12
- package/dist/debugger/lib/json.d.ts +25 -0
- package/dist/debugger/lib/json.js +87 -0
- package/dist/debugger/lib/payload.d.ts +7 -0
- package/dist/debugger/lib/payload.js +11 -0
- package/dist/debugger/lib/time.d.ts +3 -0
- package/dist/debugger/lib/time.js +24 -0
- package/dist/debugger/plugin.d.ts +36 -0
- package/dist/debugger/plugin.js +14 -0
- package/dist/debugger/server/index.d.ts +14 -0
- package/dist/debugger/server/index.js +114 -0
- package/dist/debugger/shell/debugger-shell.d.ts +15 -0
- package/dist/debugger/shell/debugger-shell.js +43 -0
- package/dist/debugger/shell/definition-key.d.ts +3 -0
- package/dist/debugger/shell/definition-key.js +4 -0
- package/dist/debugger/shell/events-pane.d.ts +12 -0
- package/dist/debugger/shell/events-pane.js +25 -0
- package/dist/debugger/shell/projections-panel.d.ts +4 -0
- package/dist/debugger/shell/projections-panel.js +59 -0
- package/dist/debugger/shell/run-controls.d.ts +4 -0
- package/dist/debugger/shell/run-controls.js +72 -0
- package/dist/debugger/shell/run-search.d.ts +6 -0
- package/dist/debugger/shell/run-search.js +102 -0
- package/dist/debugger/shell/run-type-menu.d.ts +6 -0
- package/dist/debugger/shell/run-type-menu.js +11 -0
- package/dist/debugger/shell/schema-form.d.ts +31 -0
- package/dist/debugger/shell/schema-form.js +117 -0
- package/dist/debugger/shell/start-form.d.ts +3 -0
- package/dist/debugger/shell/start-form.js +75 -0
- package/dist/debugger/shell/use-start-run.d.ts +14 -0
- package/dist/debugger/shell/use-start-run.js +32 -0
- package/dist/debugger/shell/workspace.d.ts +6 -0
- package/dist/debugger/shell/workspace.js +15 -0
- package/dist/debugger/styles.css +111 -27
- package/dist/debugger/ui/button.d.ts +24 -0
- package/dist/debugger/ui/button.js +24 -0
- package/dist/debugger/ui/command.d.ts +9 -0
- package/dist/debugger/ui/command.js +24 -0
- package/dist/debugger/ui/dropdown-menu.d.ts +13 -0
- package/dist/debugger/ui/dropdown-menu.js +37 -0
- package/dist/debugger/ui/panel.d.ts +14 -0
- package/dist/debugger/ui/panel.js +16 -0
- package/dist/debugger/ui/popover.d.ts +7 -0
- package/dist/debugger/ui/popover.js +17 -0
- package/dist/debugger/ui/resizable.d.ts +7 -0
- package/dist/debugger/ui/resizable.js +14 -0
- package/dist/debugger/ui/scroll-area.d.ts +2 -1
- package/dist/debugger/ui/scroll-area.js +5 -3
- package/dist/debugger/ui/select.d.ts +10 -0
- package/dist/debugger/ui/select.js +21 -0
- package/dist/debugger/ui/tabs.js +2 -2
- package/dist/debugger/ui/textarea.d.ts +3 -0
- package/dist/debugger/ui/textarea.js +7 -0
- package/dist/evaluator/definitions-store.d.ts +11 -0
- package/dist/evaluator/definitions-store.js +8 -0
- package/dist/evaluator/definitions.d.ts +18 -0
- package/dist/evaluator/definitions.js +4 -0
- package/dist/evaluator/effects.d.ts +226 -0
- package/dist/evaluator/effects.js +132 -0
- package/dist/evaluator/evaluator.d.ts +24 -0
- package/dist/evaluator/evaluator.js +67 -0
- package/dist/evaluator/events.d.ts +59 -0
- package/dist/evaluator/events.js +21 -0
- package/dist/evaluator/index.d.ts +11 -0
- package/dist/evaluator/index.js +11 -0
- package/dist/evaluator/module.d.ts +606 -0
- package/dist/evaluator/module.js +25 -0
- package/dist/evaluator/projections.d.ts +50 -0
- package/dist/evaluator/projections.js +20 -0
- package/dist/evaluator/scope.d.ts +59 -0
- package/dist/evaluator/scope.js +7 -0
- package/dist/evaluator/signals.d.ts +3 -0
- package/dist/evaluator/signals.js +17 -0
- package/dist/evaluator/threads.d.ts +62 -0
- package/dist/evaluator/threads.js +117 -0
- package/dist/evaluator/types.d.ts +125 -0
- package/dist/evaluator/types.js +51 -0
- package/dist/projectors/delivery.d.ts +83 -0
- package/dist/projectors/delivery.js +182 -0
- package/dist/projectors/index-model.d.ts +1 -1
- package/dist/projectors/index-model.js +4 -6
- package/dist/projectors/index.d.ts +2 -0
- package/dist/projectors/index.js +2 -0
- package/dist/projectors/memory.d.ts +1 -1
- package/dist/projectors/memory.js +10 -8
- package/dist/projectors/postgres.js +44 -58
- package/dist/projectors/projector.d.ts +17 -0
- package/dist/projectors/projector.js +26 -1
- package/dist/projectors/sqlite-delivery.d.ts +4 -0
- package/dist/projectors/sqlite-delivery.js +147 -0
- package/dist/projectors/sqlite.js +23 -23
- package/dist/projectors/with-projectors.d.ts +7 -2
- package/dist/projectors/with-projectors.js +27 -28
- package/dist/react/notify.js +11 -8
- package/dist/react/react.d.ts +2 -3
- package/dist/react/react.js +14 -30
- package/dist/react/sse.d.ts +1 -1
- package/dist/react/sse.js +1 -1
- package/dist/react/store.d.ts +3 -3
- package/dist/react/store.js +109 -119
- package/dist/runtime/cancellation.d.ts +16 -0
- package/dist/runtime/cancellation.js +129 -0
- package/dist/runtime/deadline-transition-planner.d.ts +31 -0
- package/dist/runtime/deadline-transition-planner.js +139 -0
- package/dist/runtime/dispatch-effect.d.ts +3 -2
- package/dist/runtime/dispatch-effect.js +7 -13
- package/dist/runtime/errors.d.ts +51 -0
- package/dist/runtime/errors.js +39 -0
- package/dist/runtime/{runtime-helpers.d.ts → helpers.d.ts} +24 -4
- package/dist/runtime/{runtime-helpers.js → helpers.js} +56 -19
- package/dist/runtime/index.d.ts +3 -3
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/ingress.d.ts +15 -0
- package/dist/runtime/ingress.js +42 -0
- package/dist/runtime/local-effect-executor.d.ts +21 -0
- package/dist/runtime/local-effect-executor.js +137 -0
- package/dist/runtime/looms.d.ts +30 -4
- package/dist/runtime/looms.js +57 -37
- package/dist/runtime/observer.d.ts +45 -0
- package/dist/runtime/observer.js +11 -0
- package/dist/runtime/repository.d.ts +55 -0
- package/dist/runtime/repository.js +293 -0
- package/dist/runtime/retry-policy.d.ts +16 -0
- package/dist/runtime/retry-policy.js +29 -0
- package/dist/runtime/run-execution-context.d.ts +30 -0
- package/dist/runtime/run-execution-context.js +56 -0
- package/dist/runtime/run-start.d.ts +4 -0
- package/dist/runtime/run-start.js +44 -0
- package/dist/runtime/runtime.d.ts +6 -87
- package/dist/runtime/runtime.js +248 -470
- package/dist/runtime/server/auth.d.ts +41 -0
- package/dist/runtime/server/auth.js +45 -0
- package/dist/runtime/server/debugger-host.d.ts +11 -0
- package/dist/runtime/server/debugger-host.js +32 -0
- package/dist/runtime/server/fetch-handler.d.ts +18 -0
- package/dist/runtime/server/fetch-handler.js +62 -0
- package/dist/runtime/server/http.d.ts +38 -0
- package/dist/runtime/server/http.js +66 -0
- package/dist/runtime/server/route-table.d.ts +55 -0
- package/dist/runtime/server/route-table.js +74 -0
- package/dist/runtime/server/routes/definitions.d.ts +3 -0
- package/dist/runtime/server/routes/definitions.js +20 -0
- package/dist/runtime/server/routes/effects.d.ts +3 -0
- package/dist/runtime/server/routes/effects.js +59 -0
- package/dist/runtime/server/routes/operations.d.ts +3 -0
- package/dist/runtime/server/routes/operations.js +14 -0
- package/dist/runtime/server/routes/runs.d.ts +3 -0
- package/dist/runtime/server/routes/runs.js +199 -0
- package/dist/runtime/server.d.ts +4 -8
- package/dist/runtime/server.js +6 -211
- package/dist/runtime/sse.d.ts +2 -1
- package/dist/runtime/sse.js +24 -17
- package/dist/runtime/types.d.ts +117 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/wake-engine.d.ts +20 -0
- package/dist/runtime/wake-engine.js +311 -0
- package/dist/runtime/wake-scheduler.d.ts +3 -4
- package/dist/runtime/wake-scheduler.js +25 -31
- package/dist/runtime/worker-callbacks.d.ts +16 -0
- package/dist/runtime/worker-callbacks.js +167 -0
- package/dist/runtime/worker-effect-dispatch.d.ts +36 -0
- package/dist/runtime/worker-effect-dispatch.js +126 -0
- package/dist/s2/config.d.ts +1 -1
- package/dist/s2/config.js +1 -1
- package/dist/s2/lite.js +70 -82
- package/dist/s2/pagination.d.ts +15 -0
- package/dist/s2/pagination.js +36 -0
- package/dist/s2/projector.js +6 -5
- package/dist/s2/snapshot-store.js +188 -161
- package/dist/s2/store.d.ts +3 -21
- package/dist/s2/store.js +71 -165
- package/dist/testing/index.d.ts +15 -0
- package/dist/testing/index.js +53 -16
- package/dist/workflow/debugger/index.d.ts +4 -0
- package/dist/workflow/debugger/index.js +11 -0
- package/dist/workflow/debugger/nodes-view.d.ts +3 -0
- package/dist/workflow/debugger/nodes-view.js +13 -0
- package/dist/workflow/debugger/summarize.d.ts +2 -0
- package/dist/workflow/debugger/summarize.js +30 -0
- package/dist/workflow/definitions-store.d.ts +2 -3
- package/dist/workflow/definitions-store.js +2 -2
- package/dist/workflow/definitions.d.ts +78 -22
- package/dist/workflow/definitions.js +80 -14
- package/dist/workflow/effects.d.ts +453 -107
- package/dist/workflow/effects.js +214 -115
- package/dist/workflow/events.d.ts +149 -5
- package/dist/workflow/events.js +27 -5
- package/dist/workflow/graph.d.ts +56 -0
- package/dist/workflow/graph.js +207 -0
- package/dist/workflow/index.d.ts +1 -0
- package/dist/workflow/index.js +1 -0
- package/dist/workflow/module.d.ts +1047 -266
- package/dist/workflow/projections.d.ts +14 -12
- package/dist/workflow/projections.js +30 -8
- package/dist/workflow/scope.d.ts +146 -4
- package/dist/workflow/threads.d.ts +383 -155
- package/dist/workflow/threads.js +308 -110
- package/package.json +26 -2
- package/dist/debugger/events/domain-summarize.d.ts +0 -3
- package/dist/debugger/events/domain-summarize.js +0 -107
- package/dist/debugger/events/family.d.ts +0 -8
- package/dist/debugger/events/family.js +0 -44
- package/dist/runtime/events-api.d.ts +0 -4
- package/dist/runtime/events-api.js +0 -84
package/dist/workflow/effects.js
CHANGED
|
@@ -1,204 +1,285 @@
|
|
|
1
|
-
import { Effect, Predicate, Schema } from 'effect';
|
|
2
|
-
import { createThreadId, createWaitId } from '@swirls/looms/core';
|
|
3
|
-
import { NodeStateSchema,
|
|
1
|
+
import { Clock, Data, Effect, Predicate, Schema } from 'effect';
|
|
2
|
+
import { createThreadId, createWaitId, DEFAULT_DEFINITION_VERSION, } from '@swirls/looms/core';
|
|
3
|
+
import { NodeStateSchema, nodeResultBuilders, } from './definitions.js';
|
|
4
4
|
import { WorkflowDefinitionsTag } from './definitions-store.js';
|
|
5
|
+
import { assertJsonWithinLimit, DEFAULT_CHECKPOINT_SIZE_LIMIT_BYTES, DEFAULT_GRAPH_CONCURRENCY, getReadyNodeIds, getSkippableNodeIds, getUnusedFallbackIds, iterationChildWorkflowId, nodeChildWorkflowId, nodeResults, nodeRunKey, } from './graph.js';
|
|
5
6
|
import { workflowModule } from './scope.js';
|
|
6
7
|
const ScheduleInput = Schema.Struct({
|
|
7
8
|
definitionName: Schema.optional(Schema.String),
|
|
9
|
+
definitionVersion: Schema.String.pipe(Schema.withDecodingDefaultKey(Effect.succeed(DEFAULT_DEFINITION_VERSION))),
|
|
8
10
|
nodes: Schema.optional(Schema.Record(Schema.String, NodeStateSchema)),
|
|
9
11
|
input: Schema.optional(Schema.Json),
|
|
10
12
|
});
|
|
11
13
|
const RunNodeInput = Schema.Struct({
|
|
12
14
|
definitionName: Schema.optional(Schema.String),
|
|
15
|
+
definitionVersion: Schema.String.pipe(Schema.withDecodingDefaultKey(Effect.succeed(DEFAULT_DEFINITION_VERSION))),
|
|
13
16
|
nodeId: Schema.String,
|
|
17
|
+
attempt: Schema.Finite.pipe(Schema.withDecodingDefaultKey(Effect.succeed(1))),
|
|
18
|
+
iteration: Schema.optional(Schema.Struct({ index: Schema.Finite, previous: Schema.Json })),
|
|
14
19
|
input: Schema.optional(Schema.Json),
|
|
15
|
-
|
|
20
|
+
nodes: Schema.optional(Schema.Record(Schema.String, NodeStateSchema)),
|
|
16
21
|
});
|
|
22
|
+
class WorkflowNodeError extends Data.TaggedError('WorkflowNodeError') {
|
|
23
|
+
constructor(cause) {
|
|
24
|
+
super({
|
|
25
|
+
cause,
|
|
26
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
27
|
+
});
|
|
28
|
+
this.name = 'WorkflowNodeError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
17
31
|
function isNodeResult(raw) {
|
|
18
32
|
if (!Predicate.isObject(raw) || !('type' in raw)) {
|
|
19
33
|
return false;
|
|
20
34
|
}
|
|
21
|
-
return (raw.type === 'value' ||
|
|
35
|
+
return (raw.type === 'value' ||
|
|
36
|
+
raw.type === 'spawn' ||
|
|
37
|
+
raw.type === 'sleep' ||
|
|
38
|
+
raw.type === 'effects' ||
|
|
39
|
+
raw.type === 'switch' ||
|
|
40
|
+
raw.type === 'map' ||
|
|
41
|
+
raw.type === 'loop');
|
|
42
|
+
}
|
|
43
|
+
function threadFailed(threadId, error) {
|
|
44
|
+
return [{ type: 'runtime.thread.failed', payload: { threadId, error }, threadId }];
|
|
22
45
|
}
|
|
23
46
|
export const scheduleEffect = workflowModule.effect({
|
|
24
47
|
type: 'workflow.schedule',
|
|
25
48
|
input: ScheduleInput,
|
|
26
49
|
execute: (input, ctx) => Effect.gen(function* () {
|
|
27
50
|
const workflows = yield* WorkflowDefinitionsTag;
|
|
28
|
-
const
|
|
29
|
-
|
|
51
|
+
const definition = input.definitionName
|
|
52
|
+
? workflows.get(input.definitionName, input.definitionVersion)
|
|
53
|
+
: undefined;
|
|
30
54
|
if (!definition) {
|
|
31
55
|
return [];
|
|
32
56
|
}
|
|
33
|
-
const
|
|
34
|
-
const nodes = {};
|
|
35
|
-
for (const [id, n] of Object.entries(rawNodes)) {
|
|
36
|
-
// SAFETY: NodeState results are valid JSON-serializable node execution outputs.
|
|
37
|
-
nodes[id] = { status: n.status, result: n.result ?? null };
|
|
38
|
-
}
|
|
57
|
+
const nodes = { ...input.nodes };
|
|
39
58
|
for (const node of definition.nodes) {
|
|
40
|
-
|
|
41
|
-
nodes[node.id] = { status: 'pending', result: null };
|
|
42
|
-
}
|
|
59
|
+
nodes[node.id] ??= { status: 'pending', result: null, error: null, attempts: 0 };
|
|
43
60
|
}
|
|
44
|
-
|
|
45
|
-
return scheduleEvents(definition, { nodes, input: input.input ?? null }, threadId);
|
|
61
|
+
return yield* scheduleEvents(definition, { nodes, input: input.input ?? null }, ctx.threadId);
|
|
46
62
|
}),
|
|
47
63
|
});
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const events = [];
|
|
53
|
-
for (const nodeId of ready) {
|
|
54
|
-
events.push({
|
|
55
|
-
type: 'workflow.node.started',
|
|
56
|
-
payload: { nodeId },
|
|
57
|
-
threadId,
|
|
58
|
-
});
|
|
64
|
+
function failurePolicyEvents(definition, nodes, threadId) {
|
|
65
|
+
const failed = definition.nodes.find((node) => nodes[node.id]?.status === 'failed');
|
|
66
|
+
if (!failed) {
|
|
67
|
+
return undefined;
|
|
59
68
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
const state = nodes[failed.id];
|
|
70
|
+
const policy = failed.failure ?? { type: 'fail' };
|
|
71
|
+
const error = state?.error ?? `Node ${failed.id} failed`;
|
|
72
|
+
switch (policy.type) {
|
|
73
|
+
case 'retry':
|
|
74
|
+
return (state?.attempts ?? 0) < policy.maxAttempts
|
|
75
|
+
? [{ type: 'workflow.node.started', payload: { nodeId: failed.id }, threadId }]
|
|
76
|
+
: threadFailed(threadId, error);
|
|
77
|
+
case 'skip':
|
|
78
|
+
return [
|
|
79
|
+
{
|
|
80
|
+
type: 'workflow.node.skipped',
|
|
81
|
+
payload: { nodeId: failed.id, reason: error, cause: 'policy' },
|
|
82
|
+
threadId,
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
case 'fallback':
|
|
86
|
+
return [
|
|
87
|
+
{
|
|
88
|
+
type: 'workflow.node.skipped',
|
|
89
|
+
payload: { nodeId: failed.id, reason: `fallback:${policy.nodeId}`, cause: 'policy' },
|
|
90
|
+
threadId,
|
|
91
|
+
},
|
|
92
|
+
{ type: 'workflow.node.started', payload: { nodeId: policy.nodeId }, threadId },
|
|
93
|
+
];
|
|
94
|
+
case 'fail':
|
|
95
|
+
return threadFailed(threadId, error);
|
|
96
|
+
default: {
|
|
97
|
+
const exhaustiveCheck = policy;
|
|
98
|
+
return exhaustiveCheck;
|
|
99
|
+
}
|
|
66
100
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
101
|
+
}
|
|
102
|
+
export function scheduleEvents(definition, binding, threadId) {
|
|
103
|
+
return Effect.gen(function* () {
|
|
104
|
+
yield* assertJsonWithinLimit(binding.input, 'Workflow input', definition.inputLimitBytes);
|
|
105
|
+
const policyEvents = failurePolicyEvents(definition, binding.nodes, threadId);
|
|
106
|
+
if (policyEvents) {
|
|
107
|
+
return policyEvents;
|
|
108
|
+
}
|
|
109
|
+
const skipped = [
|
|
110
|
+
...getSkippableNodeIds(definition, binding.nodes).map((nodeId) => ({
|
|
111
|
+
type: 'workflow.node.skipped',
|
|
112
|
+
payload: { nodeId, reason: 'inactive branch', cause: 'inactive' },
|
|
73
113
|
threadId,
|
|
74
|
-
},
|
|
114
|
+
})),
|
|
115
|
+
...getUnusedFallbackIds(definition, binding.nodes).map((nodeId) => ({
|
|
116
|
+
type: 'workflow.node.skipped',
|
|
117
|
+
payload: { nodeId, reason: 'fallback not needed', cause: 'inactive' },
|
|
118
|
+
threadId,
|
|
119
|
+
})),
|
|
75
120
|
];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
121
|
+
if (skipped.length > 0) {
|
|
122
|
+
return skipped;
|
|
123
|
+
}
|
|
124
|
+
const statuses = Object.values(binding.nodes).map((node) => node.status);
|
|
125
|
+
const running = statuses.filter((status) => status === 'running').length;
|
|
126
|
+
const slots = Math.max(0, (definition.concurrency ?? DEFAULT_GRAPH_CONCURRENCY) - running);
|
|
127
|
+
const ready = getReadyNodeIds(definition, binding.nodes).slice(0, slots);
|
|
128
|
+
if (ready.length > 0) {
|
|
129
|
+
return ready.map((nodeId) => ({
|
|
130
|
+
type: 'workflow.node.started',
|
|
131
|
+
payload: { nodeId },
|
|
132
|
+
threadId,
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
if (statuses.some((status) => status === 'pending' || status === 'running')) {
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
const results = nodeResults(definition, binding.nodes);
|
|
139
|
+
const output = definition.output
|
|
140
|
+
? definition.output({ input: binding.input, results })
|
|
141
|
+
: results;
|
|
142
|
+
yield* assertJsonWithinLimit(output, 'Workflow output', definition.outputLimitBytes);
|
|
143
|
+
return [{ type: 'runtime.thread.completed', payload: { threadId, output }, threadId }];
|
|
144
|
+
}).pipe(Effect.catchTag('WorkflowValueTooLargeError', (error) => Effect.succeed(threadFailed(threadId, error.message))));
|
|
89
145
|
}
|
|
90
146
|
export const runNodeEffect = workflowModule.effect({
|
|
91
147
|
type: 'workflow.runNode',
|
|
92
148
|
input: RunNodeInput,
|
|
93
149
|
execute: (input, ctx) => Effect.gen(function* () {
|
|
94
150
|
const workflows = yield* WorkflowDefinitionsTag;
|
|
95
|
-
const
|
|
96
|
-
|
|
151
|
+
const definition = input.definitionName
|
|
152
|
+
? workflows.get(input.definitionName, input.definitionVersion)
|
|
153
|
+
: undefined;
|
|
154
|
+
const run = {
|
|
155
|
+
threadId: ctx.threadId,
|
|
156
|
+
nodeId: input.nodeId,
|
|
157
|
+
attempt: input.attempt,
|
|
158
|
+
iteration: input.iteration,
|
|
159
|
+
input: input.input ?? null,
|
|
160
|
+
nodes: input.nodes ?? {},
|
|
161
|
+
};
|
|
97
162
|
if (!definition) {
|
|
98
|
-
return
|
|
99
|
-
{
|
|
100
|
-
type: 'workflow.node.finished',
|
|
101
|
-
payload: { nodeId: input.nodeId, result: null, error: 'Unknown workflow definition' },
|
|
102
|
-
threadId,
|
|
103
|
-
},
|
|
104
|
-
];
|
|
105
|
-
}
|
|
106
|
-
const rawResults = input.results ?? {};
|
|
107
|
-
const results = {};
|
|
108
|
-
for (const [id, val] of Object.entries(rawResults)) {
|
|
109
|
-
// SAFETY: Node results dictionary maps node IDs to JSON values or null.
|
|
110
|
-
results[id] = val ?? null;
|
|
163
|
+
return finished(run, null, 'Unknown workflow definition');
|
|
111
164
|
}
|
|
112
|
-
return yield* runNode(definition,
|
|
113
|
-
// SAFETY: Workflow input is validated and serialized as JsonValue.
|
|
114
|
-
{ input: input.input ?? null, results }, input.nodeId, threadId);
|
|
165
|
+
return yield* runNode(definition, run);
|
|
115
166
|
}),
|
|
116
167
|
});
|
|
117
|
-
function
|
|
168
|
+
function finished(run, result, error) {
|
|
169
|
+
return [
|
|
170
|
+
{
|
|
171
|
+
type: 'workflow.node.finished',
|
|
172
|
+
payload: { nodeId: run.nodeId, result, error },
|
|
173
|
+
threadId: run.threadId,
|
|
174
|
+
},
|
|
175
|
+
];
|
|
176
|
+
}
|
|
177
|
+
function runNode(definition, run) {
|
|
118
178
|
return Effect.gen(function* () {
|
|
119
|
-
const nodeDef = definition.nodes.find((node) => node.id === nodeId);
|
|
179
|
+
const nodeDef = definition.nodes.find((node) => node.id === run.nodeId);
|
|
120
180
|
if (!nodeDef) {
|
|
121
|
-
return
|
|
122
|
-
{
|
|
123
|
-
type: 'workflow.node.finished',
|
|
124
|
-
payload: { nodeId, result: null, error: `Unknown node: ${nodeId}` },
|
|
125
|
-
threadId,
|
|
126
|
-
},
|
|
127
|
-
];
|
|
181
|
+
return finished(run, null, `Unknown node: ${run.nodeId}`);
|
|
128
182
|
}
|
|
129
|
-
const results = binding.results;
|
|
130
183
|
const raw = yield* Effect.tryPromise({
|
|
131
184
|
try: () => Promise.resolve(nodeDef.run({
|
|
132
|
-
threadId,
|
|
133
|
-
nodeId,
|
|
134
|
-
input:
|
|
135
|
-
results,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
effects: (effects) => ({ type: 'effects', effects }),
|
|
185
|
+
threadId: run.threadId,
|
|
186
|
+
nodeId: run.nodeId,
|
|
187
|
+
input: run.input,
|
|
188
|
+
results: nodeResults(definition, run.nodes),
|
|
189
|
+
iteration: run.iteration,
|
|
190
|
+
...nodeResultBuilders(),
|
|
139
191
|
})),
|
|
140
|
-
catch: (cause) =>
|
|
192
|
+
catch: (cause) => new WorkflowNodeError(cause),
|
|
141
193
|
}).pipe(Effect.map((value) => ({ ok: true, value })), Effect.catch((err) => Effect.succeed({ ok: false, error: err.message })));
|
|
142
194
|
if (!raw.ok) {
|
|
143
|
-
return
|
|
144
|
-
{
|
|
145
|
-
type: 'workflow.node.finished',
|
|
146
|
-
payload: { nodeId, result: null, error: raw.error },
|
|
147
|
-
threadId,
|
|
148
|
-
},
|
|
149
|
-
];
|
|
195
|
+
return finished(run, null, raw.error);
|
|
150
196
|
}
|
|
151
197
|
const result = isNodeResult(raw.value)
|
|
152
198
|
? raw.value
|
|
153
199
|
: { type: 'value', value: raw.value };
|
|
200
|
+
return yield* nodeResultEvents(definition, nodeDef.type, run, result);
|
|
201
|
+
}).pipe(Effect.catchTag('WorkflowValueTooLargeError', (error) => Effect.succeed(finished(run, null, error.message))));
|
|
202
|
+
}
|
|
203
|
+
function nodeResultEvents(definition, nodeType, run, result) {
|
|
204
|
+
return Effect.gen(function* () {
|
|
205
|
+
const { threadId, nodeId, attempt } = run;
|
|
206
|
+
const outputLabel = `Node ${nodeId} output`;
|
|
154
207
|
switch (result.type) {
|
|
155
208
|
case 'value':
|
|
209
|
+
yield* assertJsonWithinLimit(result.value, outputLabel, definition.outputLimitBytes);
|
|
210
|
+
return finished(run, result.value, null);
|
|
211
|
+
case 'switch': {
|
|
212
|
+
const value = result.value ?? result.branch;
|
|
213
|
+
yield* assertJsonWithinLimit(value, outputLabel, definition.outputLimitBytes);
|
|
156
214
|
return [
|
|
157
215
|
{
|
|
158
216
|
type: 'workflow.node.finished',
|
|
159
|
-
payload: { nodeId, result:
|
|
217
|
+
payload: { nodeId, result: value, error: null, branch: result.branch },
|
|
160
218
|
threadId,
|
|
161
219
|
},
|
|
162
220
|
];
|
|
221
|
+
}
|
|
163
222
|
case 'spawn': {
|
|
164
|
-
const childThreadId =
|
|
223
|
+
const childThreadId = result.childThreadId ??
|
|
224
|
+
(nodeType === 'workflow'
|
|
225
|
+
? nodeChildWorkflowId(threadId, nodeId, attempt)
|
|
226
|
+
: createThreadId());
|
|
227
|
+
return spawnRequested(run, childThreadId, result, result.input);
|
|
228
|
+
}
|
|
229
|
+
case 'sleep': {
|
|
230
|
+
const now = yield* Clock.currentTimeMillis;
|
|
231
|
+
const key = nodeRunKey(nodeId, attempt, run.iteration?.index);
|
|
165
232
|
return [
|
|
166
233
|
{
|
|
167
|
-
type: 'workflow.
|
|
234
|
+
type: 'workflow.sleep.requested',
|
|
168
235
|
payload: {
|
|
169
236
|
nodeId,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
definitionName: result.name,
|
|
173
|
-
input: result.input ?? null,
|
|
237
|
+
waitId: createWaitId(threadId, `sleep_${key}`),
|
|
238
|
+
wakeAt: now + result.ms,
|
|
174
239
|
},
|
|
175
240
|
threadId,
|
|
176
241
|
},
|
|
177
242
|
];
|
|
178
243
|
}
|
|
179
|
-
case '
|
|
244
|
+
case 'effects':
|
|
180
245
|
return [
|
|
181
246
|
{
|
|
182
|
-
type: 'workflow.
|
|
183
|
-
payload: {
|
|
184
|
-
nodeId,
|
|
185
|
-
waitId: createWaitId(threadId, `sleep_${nodeId}`),
|
|
186
|
-
wakeAt: Date.now() + result.ms,
|
|
187
|
-
},
|
|
247
|
+
type: 'workflow.effects.requested',
|
|
248
|
+
payload: { nodeId, effects: result.effects ?? [] },
|
|
188
249
|
threadId,
|
|
189
250
|
},
|
|
190
251
|
];
|
|
191
|
-
case '
|
|
252
|
+
case 'map': {
|
|
253
|
+
if (result.items.length === 0) {
|
|
254
|
+
return finished(run, [], null);
|
|
255
|
+
}
|
|
256
|
+
const limitBytes = definition.checkpointLimitBytes ?? DEFAULT_CHECKPOINT_SIZE_LIMIT_BYTES;
|
|
257
|
+
yield* assertJsonWithinLimit(result.items, `Node ${nodeId} items`, limitBytes);
|
|
192
258
|
return [
|
|
193
259
|
{
|
|
194
|
-
type: 'workflow.
|
|
260
|
+
type: 'workflow.map.requested',
|
|
195
261
|
payload: {
|
|
196
262
|
nodeId,
|
|
197
|
-
|
|
263
|
+
attempt,
|
|
264
|
+
kind: result.kind,
|
|
265
|
+
definitionName: result.name,
|
|
266
|
+
definitionVersion: result.version,
|
|
267
|
+
items: result.items,
|
|
268
|
+
concurrency: result.concurrency,
|
|
269
|
+
limitBytes,
|
|
198
270
|
},
|
|
199
271
|
threadId,
|
|
200
272
|
},
|
|
201
273
|
];
|
|
274
|
+
}
|
|
275
|
+
case 'loop': {
|
|
276
|
+
const index = run.iteration?.index ?? 0;
|
|
277
|
+
if (index >= result.maxIterations) {
|
|
278
|
+
return finished(run, run.iteration?.previous ?? null, null);
|
|
279
|
+
}
|
|
280
|
+
const childThreadId = iterationChildWorkflowId(threadId, nodeId, 'loop', attempt, index);
|
|
281
|
+
return spawnRequested(run, childThreadId, result, result.input, index);
|
|
282
|
+
}
|
|
202
283
|
default: {
|
|
203
284
|
const exhaustiveCheck = result;
|
|
204
285
|
return exhaustiveCheck;
|
|
@@ -206,3 +287,21 @@ function runNode(definition, binding, nodeId, threadId) {
|
|
|
206
287
|
}
|
|
207
288
|
});
|
|
208
289
|
}
|
|
290
|
+
function spawnRequested(run, childThreadId, child, input, loopIndex = null) {
|
|
291
|
+
return [
|
|
292
|
+
{
|
|
293
|
+
type: 'workflow.spawn.requested',
|
|
294
|
+
payload: {
|
|
295
|
+
nodeId: run.nodeId,
|
|
296
|
+
attempt: run.attempt,
|
|
297
|
+
childThreadId,
|
|
298
|
+
kind: child.kind,
|
|
299
|
+
definitionName: child.name,
|
|
300
|
+
definitionVersion: child.version,
|
|
301
|
+
input,
|
|
302
|
+
loopIndex,
|
|
303
|
+
},
|
|
304
|
+
threadId: run.threadId,
|
|
305
|
+
},
|
|
306
|
+
];
|
|
307
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
|
-
import { type RuntimeEffect } from '@swirls/looms/core';
|
|
3
2
|
export declare const WorkflowNodeStartedPayloadSchema: Schema.Struct<{
|
|
4
3
|
readonly nodeId: Schema.String;
|
|
5
4
|
}>;
|
|
@@ -7,26 +6,99 @@ export declare const WorkflowNodeFinishedPayloadSchema: Schema.Struct<{
|
|
|
7
6
|
readonly nodeId: Schema.String;
|
|
8
7
|
readonly result: Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
9
8
|
readonly error: Schema.NullOr<Schema.String>;
|
|
9
|
+
readonly branch: Schema.optional<Schema.String>;
|
|
10
10
|
}>;
|
|
11
|
+
export declare const WorkflowSkipCauseSchema: Schema.Union<readonly [Schema.Literal<"inactive">, Schema.Literal<"policy">]>;
|
|
11
12
|
export declare const WorkflowNodeSkippedPayloadSchema: Schema.Struct<{
|
|
12
13
|
readonly nodeId: Schema.String;
|
|
13
14
|
readonly reason: Schema.String;
|
|
15
|
+
readonly cause: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"inactive">, Schema.Literal<"policy">]>, never>;
|
|
14
16
|
}>;
|
|
15
17
|
export declare const WorkflowSpawnRequestedPayloadSchema: Schema.Struct<{
|
|
16
18
|
readonly nodeId: Schema.String;
|
|
19
|
+
readonly attempt: Schema.withDecodingDefaultKey<Schema.Finite, never>;
|
|
17
20
|
readonly childThreadId: Schema.String;
|
|
18
21
|
readonly kind: Schema.String;
|
|
19
22
|
readonly definitionName: Schema.String;
|
|
23
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
20
24
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
25
|
+
/** Set for `loop` iterations: the node re-runs after this child instead of finishing. */
|
|
26
|
+
readonly loopIndex: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Finite>, never>;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const WorkflowMapRequestedPayloadSchema: Schema.Struct<{
|
|
29
|
+
readonly nodeId: Schema.String;
|
|
30
|
+
readonly attempt: Schema.withDecodingDefaultKey<Schema.Finite, never>;
|
|
31
|
+
readonly kind: Schema.String;
|
|
32
|
+
readonly definitionName: Schema.String;
|
|
33
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
34
|
+
readonly items: Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
35
|
+
readonly concurrency: Schema.Finite;
|
|
36
|
+
readonly limitBytes: Schema.Finite;
|
|
21
37
|
}>;
|
|
22
38
|
export declare const WorkflowSleepRequestedPayloadSchema: Schema.Struct<{
|
|
23
39
|
readonly nodeId: Schema.String;
|
|
24
40
|
readonly waitId: Schema.String;
|
|
25
|
-
readonly wakeAt: Schema.
|
|
41
|
+
readonly wakeAt: Schema.Finite;
|
|
26
42
|
}>;
|
|
27
43
|
export declare const WorkflowEffectsRequestedPayloadSchema: Schema.Struct<{
|
|
28
44
|
readonly nodeId: Schema.String;
|
|
29
|
-
readonly effects: Schema.$Array<Schema.Schema<
|
|
45
|
+
readonly effects: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
46
|
+
readonly type: Schema.Literal<"runtime.spawn">;
|
|
47
|
+
readonly childThreadId: Schema.String;
|
|
48
|
+
readonly kind: Schema.String;
|
|
49
|
+
readonly definitionName: Schema.String;
|
|
50
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
51
|
+
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
52
|
+
}>, Schema.Struct<{
|
|
53
|
+
readonly type: Schema.Literal<"runtime.wait">;
|
|
54
|
+
readonly waitId: Schema.String;
|
|
55
|
+
readonly on: Schema.Union<readonly [Schema.Struct<{
|
|
56
|
+
readonly type: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
|
|
57
|
+
readonly match: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
58
|
+
}>, Schema.Struct<{
|
|
59
|
+
readonly timerAt: Schema.Finite;
|
|
60
|
+
}>]>;
|
|
61
|
+
readonly tag: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
62
|
+
}>, Schema.Struct<{
|
|
63
|
+
readonly type: Schema.Literal<"runtime.emit">;
|
|
64
|
+
readonly event: Schema.Struct<{
|
|
65
|
+
readonly type: Schema.String;
|
|
66
|
+
readonly payload: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
67
|
+
readonly threadId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
68
|
+
readonly parentThreadId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
69
|
+
readonly causationId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
70
|
+
readonly correlationId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
71
|
+
readonly effectId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
72
|
+
readonly origin: Schema.optional<Schema.Union<readonly [Schema.Struct<{
|
|
73
|
+
readonly type: Schema.Literal<"thread">;
|
|
74
|
+
readonly threadId: Schema.String;
|
|
75
|
+
}>, Schema.Struct<{
|
|
76
|
+
readonly type: Schema.Literal<"external">;
|
|
77
|
+
readonly actorId: Schema.optional<Schema.String>;
|
|
78
|
+
}>, Schema.Struct<{
|
|
79
|
+
readonly type: Schema.Literal<"system">;
|
|
80
|
+
}>]>>;
|
|
81
|
+
readonly ephemeral: Schema.optional<Schema.Boolean>;
|
|
82
|
+
readonly id: Schema.optional<Schema.String>;
|
|
83
|
+
readonly ts: Schema.optional<Schema.Finite>;
|
|
84
|
+
readonly idempotencyKey: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
85
|
+
}>;
|
|
86
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
87
|
+
}>, Schema.Struct<{
|
|
88
|
+
readonly type: Schema.Literal<"runtime.complete">;
|
|
89
|
+
readonly output: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
90
|
+
}>, Schema.Struct<{
|
|
91
|
+
readonly type: Schema.Literal<"runtime.fail">;
|
|
92
|
+
readonly error: Schema.String;
|
|
93
|
+
}>, Schema.Struct<{
|
|
94
|
+
readonly type: Schema.Literal<"runtime.cancel">;
|
|
95
|
+
readonly threadId: Schema.String;
|
|
96
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
97
|
+
}>, Schema.Struct<{
|
|
98
|
+
readonly type: Schema.String;
|
|
99
|
+
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
100
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
101
|
+
}>]>>;
|
|
30
102
|
}>;
|
|
31
103
|
export declare const workflowCatalog: import("@swirls/looms/core").EventCatalog<"workflow", {
|
|
32
104
|
'node.started': Schema.Struct<{
|
|
@@ -36,25 +108,97 @@ export declare const workflowCatalog: import("@swirls/looms/core").EventCatalog<
|
|
|
36
108
|
readonly nodeId: Schema.String;
|
|
37
109
|
readonly result: Schema.NullOr<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
38
110
|
readonly error: Schema.NullOr<Schema.String>;
|
|
111
|
+
readonly branch: Schema.optional<Schema.String>;
|
|
39
112
|
}>;
|
|
40
113
|
'node.skipped': Schema.Struct<{
|
|
41
114
|
readonly nodeId: Schema.String;
|
|
42
115
|
readonly reason: Schema.String;
|
|
116
|
+
readonly cause: Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<"inactive">, Schema.Literal<"policy">]>, never>;
|
|
43
117
|
}>;
|
|
44
118
|
'spawn.requested': Schema.Struct<{
|
|
45
119
|
readonly nodeId: Schema.String;
|
|
120
|
+
readonly attempt: Schema.withDecodingDefaultKey<Schema.Finite, never>;
|
|
46
121
|
readonly childThreadId: Schema.String;
|
|
47
122
|
readonly kind: Schema.String;
|
|
48
123
|
readonly definitionName: Schema.String;
|
|
124
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
49
125
|
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
126
|
+
/** Set for `loop` iterations: the node re-runs after this child instead of finishing. */
|
|
127
|
+
readonly loopIndex: Schema.withDecodingDefaultKey<Schema.NullOr<Schema.Finite>, never>;
|
|
128
|
+
}>;
|
|
129
|
+
'map.requested': Schema.Struct<{
|
|
130
|
+
readonly nodeId: Schema.String;
|
|
131
|
+
readonly attempt: Schema.withDecodingDefaultKey<Schema.Finite, never>;
|
|
132
|
+
readonly kind: Schema.String;
|
|
133
|
+
readonly definitionName: Schema.String;
|
|
134
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
135
|
+
readonly items: Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
136
|
+
readonly concurrency: Schema.Finite;
|
|
137
|
+
readonly limitBytes: Schema.Finite;
|
|
50
138
|
}>;
|
|
51
139
|
'sleep.requested': Schema.Struct<{
|
|
52
140
|
readonly nodeId: Schema.String;
|
|
53
141
|
readonly waitId: Schema.String;
|
|
54
|
-
readonly wakeAt: Schema.
|
|
142
|
+
readonly wakeAt: Schema.Finite;
|
|
55
143
|
}>;
|
|
56
144
|
'effects.requested': Schema.Struct<{
|
|
57
145
|
readonly nodeId: Schema.String;
|
|
58
|
-
readonly effects: Schema.$Array<Schema.Schema<
|
|
146
|
+
readonly effects: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
147
|
+
readonly type: Schema.Literal<"runtime.spawn">;
|
|
148
|
+
readonly childThreadId: Schema.String;
|
|
149
|
+
readonly kind: Schema.String;
|
|
150
|
+
readonly definitionName: Schema.String;
|
|
151
|
+
readonly definitionVersion: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
152
|
+
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
153
|
+
}>, Schema.Struct<{
|
|
154
|
+
readonly type: Schema.Literal<"runtime.wait">;
|
|
155
|
+
readonly waitId: Schema.String;
|
|
156
|
+
readonly on: Schema.Union<readonly [Schema.Struct<{
|
|
157
|
+
readonly type: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
|
|
158
|
+
readonly match: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
159
|
+
}>, Schema.Struct<{
|
|
160
|
+
readonly timerAt: Schema.Finite;
|
|
161
|
+
}>]>;
|
|
162
|
+
readonly tag: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
163
|
+
}>, Schema.Struct<{
|
|
164
|
+
readonly type: Schema.Literal<"runtime.emit">;
|
|
165
|
+
readonly event: Schema.Struct<{
|
|
166
|
+
readonly type: Schema.String;
|
|
167
|
+
readonly payload: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
168
|
+
readonly threadId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
169
|
+
readonly parentThreadId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
170
|
+
readonly causationId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
171
|
+
readonly correlationId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
172
|
+
readonly effectId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
173
|
+
readonly origin: Schema.optional<Schema.Union<readonly [Schema.Struct<{
|
|
174
|
+
readonly type: Schema.Literal<"thread">;
|
|
175
|
+
readonly threadId: Schema.String;
|
|
176
|
+
}>, Schema.Struct<{
|
|
177
|
+
readonly type: Schema.Literal<"external">;
|
|
178
|
+
readonly actorId: Schema.optional<Schema.String>;
|
|
179
|
+
}>, Schema.Struct<{
|
|
180
|
+
readonly type: Schema.Literal<"system">;
|
|
181
|
+
}>]>>;
|
|
182
|
+
readonly ephemeral: Schema.optional<Schema.Boolean>;
|
|
183
|
+
readonly id: Schema.optional<Schema.String>;
|
|
184
|
+
readonly ts: Schema.optional<Schema.Finite>;
|
|
185
|
+
readonly idempotencyKey: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
186
|
+
}>;
|
|
187
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
188
|
+
}>, Schema.Struct<{
|
|
189
|
+
readonly type: Schema.Literal<"runtime.complete">;
|
|
190
|
+
readonly output: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
191
|
+
}>, Schema.Struct<{
|
|
192
|
+
readonly type: Schema.Literal<"runtime.fail">;
|
|
193
|
+
readonly error: Schema.String;
|
|
194
|
+
}>, Schema.Struct<{
|
|
195
|
+
readonly type: Schema.Literal<"runtime.cancel">;
|
|
196
|
+
readonly threadId: Schema.String;
|
|
197
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
198
|
+
}>, Schema.Struct<{
|
|
199
|
+
readonly type: Schema.String;
|
|
200
|
+
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
201
|
+
readonly tag: Schema.optional<Schema.String>;
|
|
202
|
+
}>]>>;
|
|
59
203
|
}>;
|
|
60
204
|
}>;
|