@lostgradient/weft 0.3.0 → 0.4.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/README.md +79 -24
- package/dist/cli/conformance.js +7 -1
- package/dist/cli/generated/operation-client.generated.d.ts +28 -13
- package/dist/cli/generated/operation-client.generated.js +1 -0
- package/dist/cli/help-text.d.ts +1 -1
- package/dist/cli/help-text.js +1 -0
- package/dist/cli/operation-catalog-snapshot.d.ts +8 -0
- package/dist/cli/operation-catalog-snapshot.js +11 -0
- package/dist/cli/parse-schedule-arguments.js +3 -1
- package/dist/cli/schedule.js +2 -1
- package/dist/cli/types.d.ts +1 -0
- package/dist/cli-main.js +79 -78
- package/dist/client/handle-delegation.d.ts +3 -2
- package/dist/client/handle-delegation.js +3 -1
- package/dist/client/http-client-requests.d.ts +2 -1
- package/dist/client/http-client-requests.js +7 -0
- package/dist/client/http-client.d.ts +9 -6
- package/dist/client/http-client.js +10 -1
- package/dist/client/http-request.d.ts +11 -1
- package/dist/client/http-request.js +17 -7
- package/dist/client/index.d.ts +1 -1
- package/dist/client/interface.d.ts +46 -5
- package/dist/client/local.d.ts +4 -1
- package/dist/client/local.js +12 -4
- package/dist/client/start-body.d.ts +4 -3
- package/dist/core/byte-arrays.d.ts +5 -0
- package/dist/core/byte-arrays.js +5 -0
- package/dist/core/checkpoint/lifecycle.d.ts +3 -0
- package/dist/core/checkpoint/lifecycle.js +9 -4
- package/dist/core/checkpoint/serialization.js +12 -5
- package/dist/core/codec/extension-codec.d.ts +16 -0
- package/dist/core/codec/extension-codec.js +100 -6
- package/dist/core/context/activity-retry-state.d.ts +38 -0
- package/dist/core/context/activity-retry-state.js +89 -0
- package/dist/core/context/activity-schedule-to-close.d.ts +159 -0
- package/dist/core/context/activity-schedule-to-close.js +69 -0
- package/dist/core/context/child-workflow-pipe.d.ts +5 -5
- package/dist/core/context/child-workflow-pipe.js +15 -2
- package/dist/core/context/context-presence.d.ts +19 -0
- package/dist/core/context/context-presence.js +13 -0
- package/dist/core/context/durable-operations.d.ts +25 -0
- package/dist/core/context/durable-operations.js +64 -0
- package/dist/core/context/index.d.ts +9 -5
- package/dist/core/context/index.js +17 -12
- package/dist/core/context/internals.d.ts +20 -0
- package/dist/core/context/internals.js +3 -1
- package/dist/core/context/operation-request.d.ts +35 -0
- package/dist/core/context/parallel-cache-entry.d.ts +14 -5
- package/dist/core/context/run-operation.d.ts +6 -1
- package/dist/core/context/run-operation.js +41 -87
- package/dist/core/context/session-state.js +7 -8
- package/dist/core/context/speculative-child.js +2 -0
- package/dist/core/context/types.d.ts +15 -0
- package/dist/core/context/version-patching.d.ts +8 -0
- package/dist/core/context/version-patching.js +40 -0
- package/dist/core/context/workflow-logger.d.ts +98 -0
- package/dist/core/context/workflow-logger.js +68 -0
- package/dist/core/engine/activity-heartbeat-tracking.d.ts +64 -0
- package/dist/core/engine/activity-heartbeat-tracking.js +42 -0
- package/dist/core/engine/activity-per-attempt-timeout.d.ts +41 -0
- package/dist/core/engine/activity-per-attempt-timeout.js +36 -0
- package/dist/core/engine/activity-reconciliation.d.ts +1 -0
- package/dist/core/engine/activity-reconciliation.js +12 -1
- package/dist/core/engine/activity-resolution.d.ts +23 -0
- package/dist/core/engine/activity-resolution.js +37 -0
- package/dist/core/engine/aggregate.js +66 -30
- package/dist/core/engine/async-activity-completion.d.ts +23 -6
- package/dist/core/engine/async-activity-completion.js +53 -12
- package/dist/core/engine/attributes-tags.js +9 -4
- package/dist/core/engine/bulk-operations-purge.d.ts +26 -0
- package/dist/core/engine/bulk-operations-purge.js +38 -3
- package/dist/core/engine/bulk-operations-shared.d.ts +2 -0
- package/dist/core/engine/bulk-operations-shared.js +8 -2
- package/dist/core/engine/bulk-operations.d.ts +4 -1
- package/dist/core/engine/bulk-operations.js +235 -24
- package/dist/core/engine/callback-creators-bundles.d.ts +9 -0
- package/dist/core/engine/callback-creators-bundles.js +30 -2
- package/dist/core/engine/callback-creators-core.js +6 -4
- package/dist/core/engine/callback-creators-router.js +10 -0
- package/dist/core/engine/callback-creators-schedule.d.ts +2 -2
- package/dist/core/engine/callback-creators-schedule.js +12 -8
- package/dist/core/engine/candidate-read-batching.d.ts +6 -0
- package/dist/core/engine/candidate-read-batching.js +1 -0
- package/dist/core/engine/checkpoint-io.js +61 -25
- package/dist/core/engine/checkpoint-reads.js +3 -2
- package/dist/core/engine/checkpoint-replay.d.ts +20 -0
- package/dist/core/engine/checkpoint-replay.js +242 -0
- package/dist/core/engine/checkpoint-side-effects.d.ts +23 -0
- package/dist/core/engine/checkpoint-side-effects.js +35 -0
- package/dist/core/engine/child-workflow-cancellation.d.ts +10 -0
- package/dist/core/engine/child-workflow-cancellation.js +40 -0
- package/dist/core/engine/child-workflow.js +27 -4
- package/dist/core/engine/condition-waiters.d.ts +14 -0
- package/dist/core/engine/condition-waiters.js +5 -0
- package/dist/core/engine/construction.d.ts +3 -0
- package/dist/core/engine/construction.js +21 -8
- package/dist/core/engine/coordination-branch-executors.d.ts +70 -0
- package/dist/core/engine/coordination-branch-executors.js +107 -0
- package/dist/core/engine/deferred-consume-envelope.d.ts +59 -0
- package/dist/core/engine/deferred-consume-envelope.js +14 -0
- package/dist/core/engine/disposal.js +13 -0
- package/dist/core/engine/engine-create-types.d.ts +14 -4
- package/dist/core/engine/engine-internal-types.d.ts +26 -3
- package/dist/core/engine/errors.d.ts +47 -0
- package/dist/core/engine/errors.js +20 -0
- package/dist/core/engine/event-log-compaction.d.ts +8 -0
- package/dist/core/engine/event-log-compaction.js +20 -2
- package/dist/core/engine/fenced-write.d.ts +65 -0
- package/dist/core/engine/fenced-write.js +71 -0
- package/dist/core/engine/finalizer-state.d.ts +28 -0
- package/dist/core/engine/finalizer-state.js +16 -0
- package/dist/core/engine/handles.d.ts +8 -0
- package/dist/core/engine/index.d.ts +34 -16
- package/dist/core/engine/index.js +133 -8
- package/dist/core/engine/inline-parking.js +3 -2
- package/dist/core/engine/internals.d.ts +107 -3
- package/dist/core/engine/lease-codec.d.ts +35 -0
- package/dist/core/engine/lease-codec.js +32 -0
- package/dist/core/engine/lease-deposition.d.ts +66 -0
- package/dist/core/engine/lease-deposition.js +10 -0
- package/dist/core/engine/lease-errors.d.ts +99 -0
- package/dist/core/engine/lease-errors.js +30 -0
- package/dist/core/engine/lease-manager.d.ts +114 -0
- package/dist/core/engine/lease-manager.js +135 -0
- package/dist/core/engine/lifecycle/persist.js +10 -32
- package/dist/core/engine/lifecycle/recovered-services.d.ts +8 -6
- package/dist/core/engine/lifecycle/recovered-services.js +18 -3
- package/dist/core/engine/lifecycle/resume.js +16 -9
- package/dist/core/engine/lifecycle/shared.d.ts +8 -1
- package/dist/core/engine/lifecycle/start-batch.d.ts +1 -1
- package/dist/core/engine/lifecycle/start-batch.js +2 -1
- package/dist/core/engine/lifecycle/start-commit.d.ts +9 -0
- package/dist/core/engine/lifecycle/start-commit.js +50 -8
- package/dist/core/engine/lifecycle/start-or-signal-create.d.ts +58 -0
- package/dist/core/engine/lifecycle/start-or-signal-create.js +95 -0
- package/dist/core/engine/lifecycle/start-or-signal.d.ts +3 -2
- package/dist/core/engine/lifecycle/start-or-signal.js +11 -81
- package/dist/core/engine/lifecycle/start-terminal-conflict-purge.d.ts +39 -0
- package/dist/core/engine/lifecycle/start-terminal-conflict-purge.js +28 -0
- package/dist/core/engine/lifecycle/start.d.ts +4 -4
- package/dist/core/engine/lifecycle/start.js +17 -9
- package/dist/core/engine/lifecycle/transition.js +17 -5
- package/dist/core/engine/lifecycle.d.ts +1 -1
- package/dist/core/engine/list-candidate-resolution.js +2 -2
- package/dist/core/engine/listing.js +9 -5
- package/dist/core/engine/operations-activity.d.ts +4 -11
- package/dist/core/engine/operations-activity.js +22 -49
- package/dist/core/engine/operations-coordination.d.ts +10 -0
- package/dist/core/engine/operations-coordination.js +43 -8
- package/dist/core/engine/operations-router.d.ts +6 -0
- package/dist/core/engine/operations-router.js +2 -0
- package/dist/core/engine/operations-speculate.js +6 -2
- package/dist/core/engine/operations-stream.js +12 -2
- package/dist/core/engine/operations-time.d.ts +4 -2
- package/dist/core/engine/operations-time.js +14 -2
- package/dist/core/engine/operations-wait-condition.d.ts +23 -0
- package/dist/core/engine/operations-wait-condition.js +62 -0
- package/dist/core/engine/ownership-options.d.ts +23 -0
- package/dist/core/engine/ownership-options.js +26 -0
- package/dist/core/engine/payload-size-policy.d.ts +3 -0
- package/dist/core/engine/payload-size-policy.js +4 -0
- package/dist/core/engine/pending-updates.d.ts +17 -0
- package/dist/core/engine/pending-updates.js +33 -11
- package/dist/core/engine/queries.js +1 -1
- package/dist/core/engine/registration.d.ts +1 -0
- package/dist/core/engine/registration.js +18 -3
- package/dist/core/engine/schedule-jitter.d.ts +5 -0
- package/dist/core/engine/schedule-jitter.js +10 -0
- package/dist/core/engine/schedule-run.d.ts +17 -0
- package/dist/core/engine/schedule-run.js +38 -0
- package/dist/core/engine/schedule-timer.js +81 -17
- package/dist/core/engine/schedules.d.ts +7 -4
- package/dist/core/engine/schedules.js +37 -16
- package/dist/core/engine/search-attribute-records.d.ts +4 -0
- package/dist/core/engine/search-attribute-records.js +17 -0
- package/dist/core/engine/signals.d.ts +18 -2
- package/dist/core/engine/signals.js +42 -21
- package/dist/core/engine/state-utilities.d.ts +49 -2
- package/dist/core/engine/state-utilities.js +114 -3
- package/dist/core/engine/storage-io.d.ts +16 -2
- package/dist/core/engine/storage-io.js +26 -5
- package/dist/core/engine/stream-chunk-loading.d.ts +2 -0
- package/dist/core/engine/stream-chunk-loading.js +24 -1
- package/dist/core/engine/sub-operation.js +22 -3
- package/dist/core/engine/termination/cleanup.d.ts +3 -1
- package/dist/core/engine/termination/cleanup.js +25 -1
- package/dist/core/engine/termination/complete.js +44 -6
- package/dist/core/engine/termination/finalizer-activity.d.ts +53 -0
- package/dist/core/engine/termination/finalizer-activity.js +30 -0
- package/dist/core/engine/termination/finalizer-claim.d.ts +110 -0
- package/dist/core/engine/termination/finalizer-claim.js +80 -0
- package/dist/core/engine/termination/finalizer.d.ts +48 -0
- package/dist/core/engine/termination/finalizer.js +159 -0
- package/dist/core/engine/termination/suspend.d.ts +3 -1
- package/dist/core/engine/termination.d.ts +1 -0
- package/dist/core/engine/termination.js +4 -0
- package/dist/core/engine/updates.js +5 -25
- package/dist/core/engine/validation/schedule.d.ts +2 -1
- package/dist/core/engine/validation/schedule.js +51 -2
- package/dist/core/engine/validation.js +32 -5
- package/dist/core/engine/waiting-update-response.d.ts +8 -0
- package/dist/core/engine/waiting-update-response.js +22 -0
- package/dist/core/engine/workflow-concurrency.d.ts +10 -0
- package/dist/core/engine/workflow-concurrency.js +136 -0
- package/dist/core/engine/workflow-feed.d.ts +4 -5
- package/dist/core/engine/workflow-feed.js +4 -1
- package/dist/core/engine/workflow-indexes.d.ts +9 -0
- package/dist/core/engine/workflow-indexes.js +10 -0
- package/dist/core/engine/workflow-state-stream.js +33 -13
- package/dist/core/engine/workflow-visibility-queries.d.ts +2 -2
- package/dist/core/engine-helpers.js +1 -0
- package/dist/core/events/activity-events.d.ts +43 -12
- package/dist/core/events/activity-events.js +28 -0
- package/dist/core/events/attribute-events.d.ts +2 -3
- package/dist/core/events/event-map.d.ts +18 -12
- package/dist/core/events/index.d.ts +1 -0
- package/dist/core/events/index.js +1 -0
- package/dist/core/events/schedule-events.d.ts +71 -0
- package/dist/core/events/schedule-events.js +29 -0
- package/dist/core/events/signal-events.d.ts +4 -6
- package/dist/core/events/system-events.d.ts +29 -19
- package/dist/core/events/system-events.js +26 -0
- package/dist/core/events/update-events.d.ts +6 -8
- package/dist/core/events/workflow-events.d.ts +88 -23
- package/dist/core/events/workflow-events.js +26 -0
- package/dist/core/failure-categories.js +5 -17
- package/dist/core/fault-code.d.ts +9 -3
- package/dist/core/fault-code.js +1 -0
- package/dist/core/inline-execution-strategy.context-options.d.ts +69 -0
- package/dist/core/inline-execution-strategy.context-options.js +56 -0
- package/dist/core/inline-execution-strategy.d.ts +31 -36
- package/dist/core/inline-execution-strategy.js +16 -27
- package/dist/core/list-filter-validation.d.ts +1 -1
- package/dist/core/payload-size.d.ts +1 -1
- package/dist/core/persisted-data-incompatible-error.d.ts +9 -7
- package/dist/core/review/events.d.ts +6 -8
- package/dist/core/scheduler/scheduler-class.d.ts +10 -1
- package/dist/core/scheduler/scheduler-class.js +38 -11
- package/dist/core/scheduler/timer-batch.js +9 -1
- package/dist/core/scheduler/timer-sources.d.ts +1 -0
- package/dist/core/scheduler/timer-sources.js +11 -5
- package/dist/core/session-state.d.ts +0 -1
- package/dist/core/session-state.js +2 -2
- package/dist/core/start-workflow-validation.d.ts +34 -0
- package/dist/core/start-workflow-validation.js +19 -0
- package/dist/core/types/activity-verification.d.ts +67 -0
- package/dist/core/types/activity-verification.js +0 -0
- package/dist/core/types/activity.d.ts +80 -61
- package/dist/core/types/bulk.d.ts +50 -9
- package/dist/core/types/checkpoint.d.ts +44 -8
- package/dist/core/types/list-options.d.ts +146 -0
- package/dist/core/types/list-options.js +0 -0
- package/dist/core/types/options.d.ts +121 -165
- package/dist/core/types/schedules.d.ts +39 -3
- package/dist/core/types/services-resolution.d.ts +2 -2
- package/dist/core/types/workflow-builder-runtime.d.ts +12 -3
- package/dist/core/types/workflow-builder-runtime.js +11 -2
- package/dist/core/types/workflow-builder.d.ts +42 -11
- package/dist/core/types/workflow-concurrency.d.ts +39 -0
- package/dist/core/types/workflow-concurrency.js +0 -0
- package/dist/core/types/workflow-context.d.ts +157 -14
- package/dist/core/types/workflow-definition.d.ts +53 -10
- package/dist/core/types/workflow-function.d.ts +84 -9
- package/dist/core/types/workflow-log.d.ts +98 -0
- package/dist/core/types/workflow-log.js +0 -0
- package/dist/core/types/workflow-registries.d.ts +14 -3
- package/dist/core/types/workflow-registry.d.ts +3 -0
- package/dist/core/types.d.ts +4 -0
- package/dist/core/types.js +4 -0
- package/dist/core/versioning.d.ts +9 -39
- package/dist/core/versioning.js +2 -12
- package/dist/core/weft-error.d.ts +44 -1
- package/dist/core/weft-error.js +16 -0
- package/dist/core/worker-execution-strategy-options.d.ts +26 -0
- package/dist/core/worker-execution-strategy.js +40 -36
- package/dist/core/worker-inbound-message.d.ts +38 -0
- package/dist/core/worker-inbound-message.js +37 -0
- package/dist/core/worker-log-abuse-counter.d.ts +175 -0
- package/dist/core/worker-log-abuse-counter.js +107 -0
- package/dist/core/worker-message-helpers.d.ts +47 -0
- package/dist/core/worker-message-helpers.js +26 -0
- package/dist/core/worker-protocol-guard.js +1 -1
- package/dist/core/worker-protocol-log.d.ts +56 -0
- package/dist/core/worker-protocol-log.js +18 -0
- package/dist/core/worker-protocol.d.ts +23 -0
- package/dist/core/worker-protocol.js +12 -2
- package/dist/core/workflow-version-tuple.d.ts +3 -9
- package/dist/core/workflow-version-tuple.js +2 -3
- package/dist/diagnostics/format.js +1 -6
- package/dist/diagnostics/types.d.ts +4 -5
- package/dist/diagnostics/validate.d.ts +0 -1
- package/dist/diagnostics/version-check.d.ts +1 -1
- package/dist/diagnostics/version-check.js +4 -9
- package/dist/index.d.ts +12 -10
- package/dist/index.js +29 -3
- package/dist/json-schema.js +3 -3
- package/dist/mcp/cli.js +27 -27
- package/dist/mcp/dispatcher.js +1 -1
- package/dist/mcp/http.js +16 -6
- package/dist/mcp/protocol.d.ts +2 -0
- package/dist/mcp/protocol.js +1 -1
- package/dist/mcp/session.d.ts +16 -0
- package/dist/mcp/session.js +59 -6
- package/dist/mcp/tools.js +73 -6
- package/dist/observability/index.js +2 -2
- package/dist/server/asyncapi-channels.js +5 -2
- package/dist/server/attribute-filters.d.ts +8 -3
- package/dist/server/attribute-filters.js +6 -1
- package/dist/server/authentication/api-key.d.ts +2 -1
- package/dist/server/authentication/api-key.js +5 -2
- package/dist/server/authentication/constant-time-api-key.d.ts +15 -0
- package/dist/server/authentication/constant-time-api-key.js +24 -0
- package/dist/server/authentication/index.d.ts +1 -1
- package/dist/server/authentication/index.js +7 -4
- package/dist/server/authentication/rotating-api-key-store.d.ts +5 -3
- package/dist/server/authentication/rotating-api-key-store.js +19 -11
- package/dist/server/engine-event-feed-backend.d.ts +4 -5
- package/dist/server/fault-to-http.js +8 -1
- package/dist/server/fault-to-json-rpc.js +1 -0
- package/dist/server/fleet-event-feed.d.ts +31 -0
- package/dist/server/fleet-event-feed.js +157 -0
- package/dist/server/handler/index.js +1 -1
- package/dist/server/handler/response-helpers.js +2 -1
- package/dist/server/handler/route-dispatch.d.ts +6 -3
- package/dist/server/handler/route-dispatch.js +2 -2
- package/dist/server/handler.js +23 -23
- package/dist/server/index.d.ts +32 -2
- package/dist/server/index.js +26 -26
- package/dist/server/json-rpc-transport-helpers.d.ts +1 -0
- package/dist/server/json-rpc-transport-helpers.js +2 -1
- package/dist/server/json-rpc-websocket-runtime.d.ts +11 -2
- package/dist/server/json-rpc-websocket-runtime.js +1 -0
- package/dist/server/json-rpc-websocket-subscriptions.d.ts +10 -0
- package/dist/server/json-rpc-websocket-subscriptions.js +29 -0
- package/dist/server/json-rpc-websocket-types.d.ts +22 -0
- package/dist/server/json-rpc-websocket-types.js +0 -0
- package/dist/server/json-rpc-websocket-validation.js +20 -4
- package/dist/server/json-rpc-websocket.d.ts +2 -43
- package/dist/server/json-rpc-websocket.js +57 -74
- package/dist/server/openapi.d.ts +2 -1
- package/dist/server/openapi.js +1 -3
- package/dist/server/openrpc-document-schema.d.ts +78 -0
- package/dist/server/openrpc-document-schema.js +27 -1
- package/dist/server/openrpc-errors.d.ts +3 -0
- package/dist/server/openrpc-errors.js +2 -1
- package/dist/server/openrpc.js +32 -0
- package/dist/server/operation-catalog/index.d.ts +1 -1
- package/dist/server/operation-catalog/pipeline-helpers.js +1 -0
- package/dist/server/operation-catalog/pipeline-stages.js +26 -12
- package/dist/server/operation-catalog/pipeline.js +8 -1
- package/dist/server/operation-catalog/registry.js +13 -0
- package/dist/server/operation-catalog/types.d.ts +20 -9
- package/dist/server/operation-fault.d.ts +10 -0
- package/dist/server/operation-fault.js +2 -0
- package/dist/server/operation-registry.d.ts +12 -11
- package/dist/server/operation-registry.js +12 -3
- package/dist/server/operations/aggregate-workflows.d.ts +15 -15
- package/dist/server/operations/async-activity.d.ts +2 -2
- package/dist/server/operations/async-activity.js +12 -7
- package/dist/server/operations/bulk-cancel-workflows.d.ts +1 -1
- package/dist/server/operations/bulk-cancel-workflows.js +2 -2
- package/dist/server/operations/bulk-delete-workflows.d.ts +1 -1
- package/dist/server/operations/bulk-delete-workflows.js +2 -2
- package/dist/server/operations/bulk-filter-helpers.d.ts +8 -6
- package/dist/server/operations/bulk-filter-helpers.js +54 -24
- package/dist/server/operations/bulk-mutate-workflow-tags.d.ts +11 -9
- package/dist/server/operations/bulk-mutate-workflow-tags.js +2 -2
- package/dist/server/operations/bulk-operation-helpers.d.ts +2 -2
- package/dist/server/operations/bulk-retry-failed-workflows.d.ts +7 -0
- package/dist/server/operations/bulk-retry-failed-workflows.js +64 -0
- package/dist/server/operations/bulk-signal-workflows.d.ts +11 -9
- package/dist/server/operations/bulk-signal-workflows.js +2 -2
- package/dist/server/operations/cancel-schedule.d.ts +1 -1
- package/dist/server/operations/create-schedule.d.ts +3 -1
- package/dist/server/operations/create-schedule.js +29 -11
- package/dist/server/operations/fleet-events-subscription.d.ts +54 -0
- package/dist/server/operations/fleet-events-subscription.js +99 -0
- package/dist/server/operations/fork-workflow.d.ts +1 -1
- package/dist/server/operations/fork-workflow.js +3 -2
- package/dist/server/operations/get-checkpoint-at.d.ts +1 -1
- package/dist/server/operations/get-registry.d.ts +1 -1
- package/dist/server/operations/get-retention-overview.d.ts +1 -1
- package/dist/server/operations/get-review.d.ts +1 -1
- package/dist/server/operations/get-schedule.d.ts +1 -1
- package/dist/server/operations/get-stream-chunks.d.ts +1 -1
- package/dist/server/operations/get-system-metrics.d.ts +2 -2
- package/dist/server/operations/get-task-diagnostics.d.ts +45 -6
- package/dist/server/operations/get-task-diagnostics.js +101 -7
- package/dist/server/operations/get-update-result.d.ts +1 -1
- package/dist/server/operations/get-workflow-attributes.d.ts +1 -1
- package/dist/server/operations/get-workflow-events.d.ts +1 -1
- package/dist/server/operations/get-workflow-result.d.ts +1 -1
- package/dist/server/operations/get-workflow-timeline.d.ts +1 -1
- package/dist/server/operations/get-workflow.d.ts +1 -1
- package/dist/server/operations/list-checkpoints.d.ts +1 -1
- package/dist/server/operations/list-reviews.d.ts +1 -1
- package/dist/server/operations/list-schedules.d.ts +1 -1
- package/dist/server/operations/list-task-queues.d.ts +2 -2
- package/dist/server/operations/list-workers.d.ts +2 -2
- package/dist/server/operations/list-workflows.d.ts +1 -1
- package/dist/server/operations/operation-helpers.d.ts +16 -1
- package/dist/server/operations/operation-helpers.js +15 -3
- package/dist/server/operations/pause-schedule.d.ts +1 -1
- package/dist/server/operations/purge-workflows.d.ts +5 -5
- package/dist/server/operations/purge-workflows.js +2 -2
- package/dist/server/operations/query-workflow.d.ts +1 -1
- package/dist/server/operations/query-workflow.js +3 -2
- package/dist/server/operations/recover-all.d.ts +1 -1
- package/dist/server/operations/replay-workflow.d.ts +1 -1
- package/dist/server/operations/resume-schedule.d.ts +1 -1
- package/dist/server/operations/set-workflow-attributes.d.ts +1 -1
- package/dist/server/operations/set-workflow-attributes.js +6 -3
- package/dist/server/operations/signal-workflow.js +8 -3
- package/dist/server/operations/single-workflow-tag-mutation.js +13 -3
- package/dist/server/operations/start-or-signal-workflow.d.ts +6 -1
- package/dist/server/operations/start-or-signal-workflow.js +14 -24
- package/dist/server/operations/start-workflow-options.d.ts +6 -0
- package/dist/server/operations/start-workflow-rest-input.d.ts +14 -0
- package/dist/server/operations/start-workflow-rest-input.js +31 -0
- package/dist/server/operations/start-workflow.d.ts +1 -1
- package/dist/server/operations/start-workflow.js +8 -23
- package/dist/server/operations/storage.d.ts +6 -6
- package/dist/server/operations/storage.js +24 -14
- package/dist/server/operations/stream-workflow-sse.d.ts +1 -1
- package/dist/server/operations/submit-review-decision.d.ts +1 -1
- package/dist/server/operations/submit-review-decision.js +6 -3
- package/dist/server/operations/update-schedule.d.ts +1 -1
- package/dist/server/operations/update-schedule.js +7 -4
- package/dist/server/operations/update-workflow.d.ts +1 -1
- package/dist/server/operations/update-workflow.js +7 -3
- package/dist/server/operations/worker-drain.d.ts +8 -8
- package/dist/server/operations/worker-drain.js +11 -8
- package/dist/server/operations/workflow-events-subscription.d.ts +7 -8
- package/dist/server/operations/workflow-events-subscription.js +43 -8
- package/dist/server/rest-binding.d.ts +3 -1
- package/dist/server/rest-bindings.js +12 -0
- package/dist/server/rest-body.d.ts +10 -0
- package/dist/server/rest-body.js +80 -0
- package/dist/server/runtime/authentication-bridge.d.ts +1 -0
- package/dist/server/runtime/authentication-bridge.js +33 -6
- package/dist/server/runtime/client-visible-events.d.ts +3 -0
- package/dist/server/runtime/client-visible-events.js +65 -0
- package/dist/server/runtime/context.d.ts +7 -0
- package/dist/server/runtime/event-broadcasting.d.ts +6 -0
- package/dist/server/runtime/event-broadcasting.js +72 -38
- package/dist/server/runtime/retry.d.ts +1 -0
- package/dist/server/runtime/retry.js +14 -0
- package/dist/server/runtime/shutdown.d.ts +7 -6
- package/dist/server/runtime/shutdown.js +6 -1
- package/dist/server/runtime/task-polling.js +61 -20
- package/dist/server/runtime/task-reconciliation.js +9 -1
- package/dist/server/runtime/task-result-resolution.d.ts +15 -0
- package/dist/server/runtime/task-result-resolution.js +81 -0
- package/dist/server/runtime/websocket-stream.d.ts +20 -1
- package/dist/server/runtime/websocket-stream.js +173 -7
- package/dist/server/runtime/websocket-upgrade.js +22 -3
- package/dist/server/runtime/websocket-worker.d.ts +1 -1
- package/dist/server/runtime/websocket-worker.js +38 -30
- package/dist/server/serve-internals.d.ts +3 -1
- package/dist/server/serve-internals.js +18 -2
- package/dist/server/task-state.d.ts +30 -0
- package/dist/server/task-state.js +28 -0
- package/dist/server/workflow-event-feed.d.ts +36 -115
- package/dist/server/workflow-event-feed.js +92 -27
- package/dist/service-worker/index.js +30 -30
- package/dist/storage/auto.js +1 -1
- package/dist/storage/bun-sql.js +24 -0
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/default-scope.d.ts +7 -4
- package/dist/storage/http.js +2 -2
- package/dist/storage/index.d.ts +76 -4
- package/dist/storage/indexeddb.js +1 -1
- package/dist/storage/interface.d.ts +163 -0
- package/dist/storage/interface.js +1 -1
- package/dist/storage/key-prefixes.d.ts +1 -1
- package/dist/storage/key-prefixes.js +10 -0
- package/dist/storage/lmdb.d.ts +4 -3
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon-batch.d.ts +30 -0
- package/dist/storage/neon-batch.js +30 -0
- package/dist/storage/neon-value-mapping.d.ts +30 -3
- package/dist/storage/neon-value-mapping.js +12 -0
- package/dist/storage/neon.d.ts +16 -0
- package/dist/storage/neon.js +9 -4
- package/dist/storage/node-sqlite.js +23 -0
- package/dist/storage/postgres-key-value-queries.d.ts +69 -44
- package/dist/storage/postgres-key-value-queries.js +62 -24
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/testing.d.ts +168 -0
- package/dist/storage/testing.js +2 -0
- package/dist/storage/turso.d.ts +8 -0
- package/dist/storage/turso.js +2 -2
- package/dist/storage/typed-storage.js +1 -1
- package/dist/storage/web-extension.js +1 -1
- package/dist/testing/index.js +28 -28
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/protocol.js +1 -1
- package/dist/workers/worker-replay-state.d.ts +32 -0
- package/dist/workers/worker-replay-state.js +35 -0
- package/dist/workers/worker-state-namespace.d.ts +21 -0
- package/dist/workers/worker-state-namespace.js +13 -0
- package/dist/workers/workflow-runner.d.ts +19 -15
- package/dist/workers/workflow-runner.js +72 -60
- package/dist/workers/workflow-worker-entry.js +5 -2
- package/package.json +5 -1
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { type BatchOperation, type Storage } from '../../storage/interface.ts';
|
|
15
15
|
import type { WorkflowState } from '../types.ts';
|
|
16
16
|
import { WeftError } from '../weft-error.ts';
|
|
17
|
+
import type { EngineInternals } from './internals.ts';
|
|
17
18
|
/**
|
|
18
19
|
* Bumped whenever the index layout or population rules change. The engine
|
|
19
20
|
* compares this to the watermark stored at `wf-idx-meta:version` to decide
|
|
@@ -96,8 +97,16 @@ export declare function buildWorkflowVisibilityIndexTransition(workflowId: strin
|
|
|
96
97
|
* consult the new `wf-idx-*` rows when the watermark is `current`.
|
|
97
98
|
*/
|
|
98
99
|
export type WorkflowVisibilityWatermark = 'current' | 'stale';
|
|
100
|
+
export declare const WORKFLOW_VISIBILITY_WATERMARK_CACHE_TTL_MS = 1000;
|
|
99
101
|
/**
|
|
100
102
|
* Read the visibility-index watermark. Returns `'current'` when the
|
|
101
103
|
* persisted version is at or above {@link WORKFLOW_VISIBILITY_INDEX_VERSION}.
|
|
102
104
|
*/
|
|
103
105
|
export declare function getWorkflowVisibilityWatermark(storage: Storage): Promise<WorkflowVisibilityWatermark>;
|
|
106
|
+
/**
|
|
107
|
+
* Read the visibility-index watermark through the engine-local query cache.
|
|
108
|
+
* The short freshness window avoids repeated metadata reads during bursts of
|
|
109
|
+
* list/aggregate queries without pinning an external backfill or drop decision
|
|
110
|
+
* until process restart.
|
|
111
|
+
*/
|
|
112
|
+
export declare function getCachedWorkflowVisibilityWatermark(internals: EngineInternals): Promise<WorkflowVisibilityWatermark>;
|
|
@@ -77,6 +77,7 @@ function buildWorkflowVisibilityIndexOperationsInternal(workflowId, previousKeys
|
|
|
77
77
|
return { batchOps, nextManifestKeys: nextKeys };
|
|
78
78
|
}
|
|
79
79
|
const EMPTY_INDEX_VALUE = new Uint8Array(0);
|
|
80
|
+
export const WORKFLOW_VISIBILITY_WATERMARK_CACHE_TTL_MS = 1000;
|
|
80
81
|
export async function getWorkflowVisibilityWatermark(storage) {
|
|
81
82
|
const bytes = await storage.get(KEYS.workflowVisibilityMetaVersion());
|
|
82
83
|
if (!bytes)
|
|
@@ -91,3 +92,12 @@ export async function getWorkflowVisibilityWatermark(storage) {
|
|
|
91
92
|
return "stale";
|
|
92
93
|
return payload >= WORKFLOW_VISIBILITY_INDEX_VERSION ? "current" : "stale";
|
|
93
94
|
}
|
|
95
|
+
export async function getCachedWorkflowVisibilityWatermark(internals) {
|
|
96
|
+
const { workflowVisibilityWatermark: cachedWatermark, workflowVisibilityWatermarkExpiresAt: expiresAt } = internals, now = Date.now();
|
|
97
|
+
if (cachedWatermark !== void 0 && expiresAt !== void 0 && now < expiresAt)
|
|
98
|
+
return cachedWatermark;
|
|
99
|
+
const watermark = await getWorkflowVisibilityWatermark(internals.storage);
|
|
100
|
+
internals.workflowVisibilityWatermark = watermark;
|
|
101
|
+
internals.workflowVisibilityWatermarkExpiresAt = now + WORKFLOW_VISIBILITY_WATERMARK_CACHE_TTL_MS;
|
|
102
|
+
return watermark;
|
|
103
|
+
}
|
|
@@ -6,25 +6,35 @@ import {
|
|
|
6
6
|
import { failureCategorySearchValues, isFailureCategory } from "../failure-categories.js";
|
|
7
7
|
import { encodeAttributeValue, searchAttributeName } from "../search-attributes.js";
|
|
8
8
|
import { normalizeWorkflowTags } from "../workflow-tags.js";
|
|
9
|
-
import {
|
|
9
|
+
import { CONSTRAINED_ID_CHUNK_SIZE } from "./candidate-read-batching.js";
|
|
10
|
+
import {
|
|
11
|
+
attributeFilterExactValues,
|
|
12
|
+
decodeSearchAttributeRecord,
|
|
13
|
+
intersectIdentifierSets,
|
|
14
|
+
listFilterHasAttributeFilters,
|
|
15
|
+
matchesListFilter
|
|
16
|
+
} from "./state-utilities.js";
|
|
10
17
|
import { decodeWorkflowState } from "./validation.js";
|
|
11
18
|
const ATTRIBUTE_SCAN_CONCURRENCY = 8;
|
|
12
19
|
export async function* streamMatchingWorkflowStates(internals, filter) {
|
|
13
20
|
const normalizedTagFilters = normalizeWorkflowTags(filter?.tags), constrainedIds = await resolveConstrainedIds(internals, filter, normalizedTagFilters);
|
|
14
21
|
if (constrainedIds !== null) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
const orderedIds = [...constrainedIds];
|
|
23
|
+
for (let start = 0;start < orderedIds.length; start += CONSTRAINED_ID_CHUNK_SIZE) {
|
|
24
|
+
const chunkIds = orderedIds.slice(start, start + CONSTRAINED_ID_CHUNK_SIZE), chunkStates = await Promise.all(chunkIds.map((workflowId) => loadMatchingWorkflowState(internals, workflowId, filter, constrainedIds, normalizedTagFilters)));
|
|
25
|
+
for (const state of chunkStates) {
|
|
26
|
+
if (state === null)
|
|
27
|
+
continue;
|
|
28
|
+
yield state;
|
|
29
|
+
}
|
|
20
30
|
}
|
|
21
31
|
return;
|
|
22
32
|
}
|
|
23
33
|
for await (const [key, value] of internals.storage.scan("wf:")) {
|
|
24
34
|
if (!isTopLevelWorkflowStateKey(key))
|
|
25
35
|
continue;
|
|
26
|
-
const state = decodeWorkflowState(value);
|
|
27
|
-
if (!matchesListFilter(state, filter, constrainedIds, normalizedTagFilters))
|
|
36
|
+
const state = decodeWorkflowState(value), searchAttributes = await readSearchAttributesForFilter(internals, state.id, filter);
|
|
37
|
+
if (!matchesListFilter(state, filter, constrainedIds, normalizedTagFilters, searchAttributes))
|
|
28
38
|
continue;
|
|
29
39
|
yield state;
|
|
30
40
|
}
|
|
@@ -33,11 +43,16 @@ async function loadMatchingWorkflowState(internals, workflowId, filter, constrai
|
|
|
33
43
|
const stateBytes = await internals.storage.get(KEYS.workflow(workflowId));
|
|
34
44
|
if (!stateBytes)
|
|
35
45
|
return null;
|
|
36
|
-
const state = decodeWorkflowState(stateBytes);
|
|
37
|
-
if (!matchesListFilter(state, filter, constrainedIds, normalizedTagFilters))
|
|
46
|
+
const state = decodeWorkflowState(stateBytes), searchAttributes = await readSearchAttributesForFilter(internals, workflowId, filter);
|
|
47
|
+
if (!matchesListFilter(state, filter, constrainedIds, normalizedTagFilters, searchAttributes))
|
|
38
48
|
return null;
|
|
39
49
|
return state;
|
|
40
50
|
}
|
|
51
|
+
async function readSearchAttributesForFilter(internals, workflowId, filter) {
|
|
52
|
+
if (!listFilterHasAttributeFilters(filter))
|
|
53
|
+
return null;
|
|
54
|
+
return decodeSearchAttributeRecord(await internals.storage.get(KEYS.attribute(workflowId)));
|
|
55
|
+
}
|
|
41
56
|
export async function resolveConstrainedIds(internals, filter, normalizedTagFilters) {
|
|
42
57
|
const attributeFilters = filter?.attributes, hasAttributeFilters = attributeFilters !== void 0 && attributeFilters.length > 0, hasTagFilters = normalizedTagFilters !== void 0 && normalizedTagFilters.length > 0;
|
|
43
58
|
if (!hasAttributeFilters && !hasTagFilters)
|
|
@@ -78,10 +93,15 @@ function requireConstrainedIdSet(idSet) {
|
|
|
78
93
|
return idSet;
|
|
79
94
|
}
|
|
80
95
|
async function collectExactAttributeMatches(internals, filter, attributeName, ids) {
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
96
|
+
const exactValues = attributeFilterExactValues(filter);
|
|
97
|
+
if (exactValues === null)
|
|
83
98
|
return;
|
|
84
|
-
const values =
|
|
99
|
+
const values = [];
|
|
100
|
+
for (const exactValue of exactValues)
|
|
101
|
+
if (filter.key === "failureCategory" && isFailureCategory(exactValue))
|
|
102
|
+
values.push(...failureCategorySearchValues(exactValue));
|
|
103
|
+
else
|
|
104
|
+
values.push(exactValue);
|
|
85
105
|
for (const value of values) {
|
|
86
106
|
const exactPrefix = `idx:${attributeName}:${encodeAttributeValue(value)}:`;
|
|
87
107
|
for await (const [key] of internals.storage.scan(exactPrefix))
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Every helper assumes the visibility-index watermark is `current` — the
|
|
8
8
|
* caller checks {@link getWorkflowVisibilityWatermark} once per query and
|
|
9
|
-
*
|
|
9
|
+
* uses the current full-scan correctness path when it is `stale`.
|
|
10
10
|
*
|
|
11
11
|
* @module core/engine/workflow-visibility-queries
|
|
12
12
|
*/
|
|
13
13
|
import { type Storage } from '../../storage/interface.ts';
|
|
14
14
|
import type { FailureCategory, WorkflowStatus } from '../types/identity.ts';
|
|
15
|
-
import type { TimeRange } from '../types/options.ts';
|
|
15
|
+
import type { TimeRange } from '../types/list-options.ts';
|
|
16
16
|
/**
|
|
17
17
|
* Match every workflow whose `status` appears in `statuses`. Empty input
|
|
18
18
|
* returns an empty set (intersection short-circuits to "no matches").
|
|
@@ -25,6 +25,7 @@ export async function cleanupPartialStreamChunks(storage, workflowId, key, writt
|
|
|
25
25
|
return;
|
|
26
26
|
const deleteOperations = [
|
|
27
27
|
...writtenKeys.map((writtenKey) => ({ type: "delete", key: writtenKey })),
|
|
28
|
+
{ type: "delete", key: KEYS.streamTail(workflowId, key) },
|
|
28
29
|
{ type: "delete", key: KEYS.streamMetadata(workflowId, key) }
|
|
29
30
|
];
|
|
30
31
|
await storage.batch(deleteOperations).catch((deleteError) => {
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
* import { Engine, ActivityStartedEvent } from '@lostgradient/weft';
|
|
9
9
|
*
|
|
10
10
|
* const engine = new Engine();
|
|
11
|
-
* engine.addEventListener(
|
|
12
|
-
*
|
|
13
|
-
* console.log('activity started:', ev.activityName, 'attempt', ev.attempt);
|
|
11
|
+
* engine.addEventListener(ActivityStartedEvent.type, (event) => {
|
|
12
|
+
* console.log('activity started:', event.activityName, 'attempt', event.attempt);
|
|
14
13
|
* });
|
|
15
14
|
* ```
|
|
16
15
|
*/
|
|
@@ -32,9 +31,8 @@ export declare class ActivityStartedEvent extends Event {
|
|
|
32
31
|
* import { Engine, ActivityCompletedEvent } from '@lostgradient/weft';
|
|
33
32
|
*
|
|
34
33
|
* const engine = new Engine();
|
|
35
|
-
* engine.addEventListener(
|
|
36
|
-
*
|
|
37
|
-
* console.log(ev.activityName, 'completed in', ev.duration, 'ms');
|
|
34
|
+
* engine.addEventListener(ActivityCompletedEvent.type, (event) => {
|
|
35
|
+
* console.log(event.activityName, 'completed in', event.duration, 'ms');
|
|
38
36
|
* });
|
|
39
37
|
* ```
|
|
40
38
|
*/
|
|
@@ -61,9 +59,8 @@ export declare class ActivityCompletedEvent extends Event {
|
|
|
61
59
|
* import { Engine, ActivityAsyncPendingEvent } from '@lostgradient/weft';
|
|
62
60
|
*
|
|
63
61
|
* const engine = new Engine();
|
|
64
|
-
* engine.addEventListener(
|
|
65
|
-
*
|
|
66
|
-
* console.log('awaiting external completion of', ev.activityName, 'token', ev.token);
|
|
62
|
+
* engine.addEventListener(ActivityAsyncPendingEvent.type, (event) => {
|
|
63
|
+
* console.log('awaiting external completion of', event.activityName, 'token', event.token);
|
|
67
64
|
* });
|
|
68
65
|
* ```
|
|
69
66
|
*/
|
|
@@ -87,9 +84,8 @@ export declare class ActivityAsyncPendingEvent extends Event {
|
|
|
87
84
|
* import { Engine, ActivityFailedEvent } from '@lostgradient/weft';
|
|
88
85
|
*
|
|
89
86
|
* const engine = new Engine();
|
|
90
|
-
* engine.addEventListener(
|
|
91
|
-
*
|
|
92
|
-
* console.error(ev.activityName, 'attempt', ev.attempt, 'failed:', ev.error.message);
|
|
87
|
+
* engine.addEventListener(ActivityFailedEvent.type, (event) => {
|
|
88
|
+
* console.error(event.activityName, 'attempt', event.attempt, 'failed:', event.error.message);
|
|
93
89
|
* });
|
|
94
90
|
* ```
|
|
95
91
|
*/
|
|
@@ -102,3 +98,38 @@ export declare class ActivityFailedEvent extends Event {
|
|
|
102
98
|
readonly attempt: number;
|
|
103
99
|
constructor(operationId: string, workflowId: string, activityName: string, error: Error, attempt: number);
|
|
104
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Fired on the {@link Engine} when a remote worker task result cannot be
|
|
103
|
+
* durably moved from in-flight to resolved after storage retries are exhausted.
|
|
104
|
+
* The durable dead-letter guard prevents reconciliation from silently
|
|
105
|
+
* re-dispatching the already-completed worker attempt until an operator clears
|
|
106
|
+
* the diagnostic entry.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* import { Engine, TaskResultDeadLetteredEvent } from '@lostgradient/weft';
|
|
111
|
+
*
|
|
112
|
+
* const engine = new Engine();
|
|
113
|
+
* engine.addEventListener(TaskResultDeadLetteredEvent.type, (event) => {
|
|
114
|
+
* console.warn('task dead-lettered:', event.operationId, event.reason);
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare class TaskResultDeadLetteredEvent extends Event {
|
|
119
|
+
static readonly type: "task:dead-lettered";
|
|
120
|
+
readonly operationId: string;
|
|
121
|
+
readonly workflowId: string | undefined;
|
|
122
|
+
readonly activityName: string | undefined;
|
|
123
|
+
readonly queue: string | undefined;
|
|
124
|
+
readonly workerId: string | undefined;
|
|
125
|
+
readonly reason: 'result-resolution-storage-exhausted';
|
|
126
|
+
readonly errorMessage: string;
|
|
127
|
+
constructor({ operationId, workflowId, activityName, queue, workerId, errorMessage, }: {
|
|
128
|
+
operationId: string;
|
|
129
|
+
workflowId?: string | undefined;
|
|
130
|
+
activityName?: string | undefined;
|
|
131
|
+
queue?: string | undefined;
|
|
132
|
+
workerId?: string | undefined;
|
|
133
|
+
errorMessage: string;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
@@ -61,3 +61,31 @@ export class ActivityFailedEvent extends Event {
|
|
|
61
61
|
this.attempt = attempt;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
|
|
65
|
+
export class TaskResultDeadLetteredEvent extends Event {
|
|
66
|
+
static type = "task:dead-lettered";
|
|
67
|
+
operationId;
|
|
68
|
+
workflowId;
|
|
69
|
+
activityName;
|
|
70
|
+
queue;
|
|
71
|
+
workerId;
|
|
72
|
+
reason;
|
|
73
|
+
errorMessage;
|
|
74
|
+
constructor({
|
|
75
|
+
operationId,
|
|
76
|
+
workflowId,
|
|
77
|
+
activityName,
|
|
78
|
+
queue,
|
|
79
|
+
workerId,
|
|
80
|
+
errorMessage
|
|
81
|
+
}) {
|
|
82
|
+
super(TaskResultDeadLetteredEvent.type);
|
|
83
|
+
this.operationId = operationId;
|
|
84
|
+
this.workflowId = workflowId;
|
|
85
|
+
this.activityName = activityName;
|
|
86
|
+
this.queue = queue;
|
|
87
|
+
this.workerId = workerId;
|
|
88
|
+
this.reason = "result-resolution-storage-exhausted";
|
|
89
|
+
this.errorMessage = errorMessage;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
* import { Engine, AttributesChangedEvent } from '@lostgradient/weft';
|
|
9
9
|
*
|
|
10
10
|
* const engine = new Engine();
|
|
11
|
-
* engine.addEventListener(
|
|
12
|
-
*
|
|
13
|
-
* console.log('attributes changed for', ev.workflowId, ev.changes);
|
|
11
|
+
* engine.addEventListener(AttributesChangedEvent.type, (event) => {
|
|
12
|
+
* console.log('attributes changed for', event.workflowId, event.changes);
|
|
14
13
|
* });
|
|
15
14
|
* ```
|
|
16
15
|
*/
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import type { ReviewCompletedEvent, ReviewRequestedEvent } from '../review/events.ts';
|
|
2
|
-
import type { ActivityAsyncPendingEvent, ActivityCompletedEvent, ActivityFailedEvent, ActivityStartedEvent } from './activity-events.ts';
|
|
2
|
+
import type { ActivityAsyncPendingEvent, ActivityCompletedEvent, ActivityFailedEvent, ActivityStartedEvent, TaskResultDeadLetteredEvent } from './activity-events.ts';
|
|
3
3
|
import type { AttributesChangedEvent } from './attribute-events.ts';
|
|
4
|
+
import type { ScheduleFiredEvent, ScheduleMissedFireEvent } from './schedule-events.ts';
|
|
4
5
|
import type { SignalDeliveredEvent, SignalReceivedEvent } from './signal-events.ts';
|
|
5
|
-
import type { AlertFiredEvent, AlertResolvedEvent, CheckpointSizeWarningEvent, CleanupWarningEvent, ConstraintViolatedEvent, DevelopmentWarningEvent, StorageSizeReportedEvent } from './system-events.ts';
|
|
6
|
+
import type { AlertFiredEvent, AlertResolvedEvent, CheckpointSizeWarningEvent, CleanupWarningEvent, ConstraintViolatedEvent, DevelopmentWarningEvent, StorageSizeReportedEvent, WorkerConnectedEvent, WorkerDisconnectedEvent } from './system-events.ts';
|
|
6
7
|
import type { UpdateCompletedEvent, UpdateReceivedEvent } from './update-events.ts';
|
|
7
|
-
import type { WorkflowCancelledEvent, WorkflowCompletedEvent, WorkflowFailedEvent, WorkflowRecoverySkippedEvent, WorkflowResumedEvent, WorkflowStartedEvent, WorkflowSuspendedEvent, WorkflowTimedOutEvent } from './workflow-events.ts';
|
|
8
|
+
import type { WorkflowCancelledEvent, WorkflowCompletedEvent, WorkflowDefinitionRegisteredEvent, WorkflowFailedEvent, WorkflowRecoverySkippedEvent, WorkflowResumedEvent, WorkflowStartedEvent, WorkflowSuspendedEvent, WorkflowTeardownEvent, WorkflowTimedOutEvent } from './workflow-events.ts';
|
|
8
9
|
/**
|
|
9
10
|
* Record mapping each event-name string the {@link Engine} dispatches to its
|
|
10
|
-
* corresponding typed `Event` subclass.
|
|
11
|
-
* {@link TypedEventTarget} to get type-safe `addEventListener` /
|
|
12
|
-
* `removeEventListener` on the engine.
|
|
11
|
+
* corresponding typed `Event` subclass.
|
|
13
12
|
*
|
|
14
13
|
* @example
|
|
15
14
|
* ```ts
|
|
16
|
-
* import { Engine, type
|
|
15
|
+
* import { Engine, type WeftEventMap } from '@lostgradient/weft';
|
|
17
16
|
*
|
|
18
17
|
* function listenAll(engine: Engine) {
|
|
19
|
-
* (
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
18
|
+
* engine.addEventListener('workflow:completed', (event) => {
|
|
19
|
+
* const completed: WeftEventMap['workflow:completed'] = event;
|
|
20
|
+
* console.log('done', completed.workflowId, completed.result);
|
|
21
|
+
* });
|
|
23
22
|
* }
|
|
24
23
|
* void listenAll;
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
26
|
export type WeftEventMap = {
|
|
27
|
+
'workflow:definition-registered': WorkflowDefinitionRegisteredEvent;
|
|
28
28
|
'workflow:started': WorkflowStartedEvent;
|
|
29
29
|
'workflow:completed': WorkflowCompletedEvent;
|
|
30
30
|
'workflow:failed': WorkflowFailedEvent;
|
|
@@ -33,21 +33,27 @@ export type WeftEventMap = {
|
|
|
33
33
|
'workflow:resumed': WorkflowResumedEvent;
|
|
34
34
|
'workflow:suspended': WorkflowSuspendedEvent;
|
|
35
35
|
'workflow:recovery-skipped': WorkflowRecoverySkippedEvent;
|
|
36
|
+
'workflow:teardown': WorkflowTeardownEvent;
|
|
36
37
|
'activity:started': ActivityStartedEvent;
|
|
37
38
|
'activity:completed': ActivityCompletedEvent;
|
|
38
39
|
'activity:failed': ActivityFailedEvent;
|
|
39
40
|
'activity:async-pending': ActivityAsyncPendingEvent;
|
|
41
|
+
'task:dead-lettered': TaskResultDeadLetteredEvent;
|
|
40
42
|
'signal:received': SignalReceivedEvent;
|
|
41
43
|
'signal:delivered': SignalDeliveredEvent;
|
|
44
|
+
'schedule:fired': ScheduleFiredEvent;
|
|
42
45
|
'human-review:requested': ReviewRequestedEvent;
|
|
43
46
|
'human-review:completed': ReviewCompletedEvent;
|
|
44
47
|
'attributes:changed': AttributesChangedEvent;
|
|
48
|
+
'schedule:missed-fire': ScheduleMissedFireEvent;
|
|
45
49
|
'update:received': UpdateReceivedEvent;
|
|
46
50
|
'update:completed': UpdateCompletedEvent;
|
|
47
51
|
'checkpoint:size-warning': CheckpointSizeWarningEvent;
|
|
48
52
|
'development:warning': DevelopmentWarningEvent;
|
|
49
53
|
'cleanup:warning': CleanupWarningEvent;
|
|
50
54
|
'storage:size-reported': StorageSizeReportedEvent;
|
|
55
|
+
'worker:connected': WorkerConnectedEvent;
|
|
56
|
+
'worker:disconnected': WorkerDisconnectedEvent;
|
|
51
57
|
'alert:fired': AlertFiredEvent;
|
|
52
58
|
'alert:resolved': AlertResolvedEvent;
|
|
53
59
|
'constraint:violated': ConstraintViolatedEvent;
|
|
@@ -69,7 +75,7 @@ export type WeftEventMap = {
|
|
|
69
75
|
* });
|
|
70
76
|
* }
|
|
71
77
|
* const engine = new Engine();
|
|
72
|
-
* addTypedListener(engine
|
|
78
|
+
* addTypedListener(engine);
|
|
73
79
|
* void engine;
|
|
74
80
|
* ```
|
|
75
81
|
*/
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fired on the {@link Engine} each time a schedule launches an occurrence — i.e.
|
|
3
|
+
* whenever a scheduled run is actually started, whether that is a fresh cadence
|
|
4
|
+
* tick, a `cancel-running` replacement, or a `queue`d run draining after the
|
|
5
|
+
* previous one finished. A fire means a workflow was launched: the blocked
|
|
6
|
+
* policies (`skip`, and `queue` while a run is already active) intentionally do
|
|
7
|
+
* **not** emit, since nothing started.
|
|
8
|
+
*
|
|
9
|
+
* Delivery is process-local and best-effort — listen via
|
|
10
|
+
* `engine.addEventListener('schedule:fired', handler)` on the live engine that
|
|
11
|
+
* owns the schedule. The durable part (the cadence, and the launched run itself)
|
|
12
|
+
* is handled by the schedule; the event is dispatched synchronously right after
|
|
13
|
+
* the run's durable start commits, so a crash in that narrow window — start
|
|
14
|
+
* committed, dispatch not yet reached — can drop the notification without
|
|
15
|
+
* affecting the run. Treat it as a reaction signal, not a durable record. This
|
|
16
|
+
* lets a consumer react to a firing without polling `engine.list()` or
|
|
17
|
+
* `getSchedule()`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { workflow, Engine, ScheduleFiredEvent } from '@lostgradient/weft';
|
|
22
|
+
*
|
|
23
|
+
* const engine = new Engine();
|
|
24
|
+
* engine.addEventListener('schedule:fired', (e: Event) => {
|
|
25
|
+
* const ev = e as ScheduleFiredEvent;
|
|
26
|
+
* console.log('schedule', ev.scheduleId, 'launched run', ev.workflowId);
|
|
27
|
+
* });
|
|
28
|
+
* engine.register(workflow({ name: 'tick' }).execute(async function* () { return 'ok'; }));
|
|
29
|
+
* await engine.schedule('tick', null, { every: '1h' });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class ScheduleFiredEvent extends Event {
|
|
33
|
+
static readonly type: "schedule:fired";
|
|
34
|
+
/** The schedule whose occurrence fired. */
|
|
35
|
+
readonly scheduleId: string;
|
|
36
|
+
/** The workflow run this occurrence launched. */
|
|
37
|
+
readonly workflowId: string;
|
|
38
|
+
/** Wall-clock time the run was launched, from the engine's injected clock. */
|
|
39
|
+
readonly firedAt: number;
|
|
40
|
+
/**
|
|
41
|
+
* The scheduled grid timestamp the occurrence was due. `undefined` for a run
|
|
42
|
+
* that drained from the `queue` overlap policy: a queued occurrence is tracked
|
|
43
|
+
* only as a count (`queuedRuns`), so its original due timestamp is not retained
|
|
44
|
+
* and cannot be reported when the run finally launches.
|
|
45
|
+
*/
|
|
46
|
+
readonly occurrence: number | undefined;
|
|
47
|
+
constructor(scheduleId: string, workflowId: string, firedAt: number, occurrence?: number);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Fired on the {@link Engine} when a non-backfill schedule timer is more than
|
|
51
|
+
* one second late and the engine skips the missed occurrence window instead of
|
|
52
|
+
* starting workflows for those ticks.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { Engine, ScheduleMissedFireEvent } from '@lostgradient/weft';
|
|
57
|
+
*
|
|
58
|
+
* const engine = new Engine();
|
|
59
|
+
* engine.addEventListener(ScheduleMissedFireEvent.type, (event) => {
|
|
60
|
+
* console.warn(event.scheduleId, 'missed', event.missedCount, 'scheduled ticks');
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare class ScheduleMissedFireEvent extends Event {
|
|
65
|
+
static readonly type: "schedule:missed-fire";
|
|
66
|
+
readonly scheduleId: string;
|
|
67
|
+
readonly missedCount: number;
|
|
68
|
+
readonly windowStart: number;
|
|
69
|
+
readonly windowEnd: number;
|
|
70
|
+
constructor(scheduleId: string, missedCount: number, windowStart: number, windowEnd: number);
|
|
71
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class ScheduleFiredEvent extends Event {
|
|
2
|
+
static type = "schedule:fired";
|
|
3
|
+
scheduleId;
|
|
4
|
+
workflowId;
|
|
5
|
+
firedAt;
|
|
6
|
+
occurrence;
|
|
7
|
+
constructor(scheduleId, workflowId, firedAt, occurrence) {
|
|
8
|
+
super(ScheduleFiredEvent.type);
|
|
9
|
+
this.scheduleId = scheduleId;
|
|
10
|
+
this.workflowId = workflowId;
|
|
11
|
+
this.firedAt = firedAt;
|
|
12
|
+
this.occurrence = occurrence;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class ScheduleMissedFireEvent extends Event {
|
|
17
|
+
static type = "schedule:missed-fire";
|
|
18
|
+
scheduleId;
|
|
19
|
+
missedCount;
|
|
20
|
+
windowStart;
|
|
21
|
+
windowEnd;
|
|
22
|
+
constructor(scheduleId, missedCount, windowStart, windowEnd) {
|
|
23
|
+
super(ScheduleMissedFireEvent.type);
|
|
24
|
+
this.scheduleId = scheduleId;
|
|
25
|
+
this.missedCount = missedCount;
|
|
26
|
+
this.windowStart = windowStart;
|
|
27
|
+
this.windowEnd = windowEnd;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
* import { Engine, SignalReceivedEvent } from '@lostgradient/weft';
|
|
9
9
|
*
|
|
10
10
|
* const engine = new Engine();
|
|
11
|
-
* engine.addEventListener(
|
|
12
|
-
*
|
|
13
|
-
* console.log(ev.workflowId, 'received signal', ev.signalName);
|
|
11
|
+
* engine.addEventListener(SignalReceivedEvent.type, (event) => {
|
|
12
|
+
* console.log(event.workflowId, 'received signal', event.signalName);
|
|
14
13
|
* });
|
|
15
14
|
* ```
|
|
16
15
|
*/
|
|
@@ -31,9 +30,8 @@ export declare class SignalReceivedEvent extends Event {
|
|
|
31
30
|
* import { Engine, SignalDeliveredEvent } from '@lostgradient/weft';
|
|
32
31
|
*
|
|
33
32
|
* const engine = new Engine();
|
|
34
|
-
* engine.addEventListener(
|
|
35
|
-
*
|
|
36
|
-
* console.log('signal', ev.signalName, 'delivered to', ev.workflowId);
|
|
33
|
+
* engine.addEventListener(SignalDeliveredEvent.type, (event) => {
|
|
34
|
+
* console.log('signal', event.signalName, 'delivered to', event.workflowId);
|
|
37
35
|
* });
|
|
38
36
|
* ```
|
|
39
37
|
*/
|
|
@@ -9,9 +9,8 @@ import type { ConstraintViolation } from '../constraint.ts';
|
|
|
9
9
|
* import { Engine, CheckpointSizeWarningEvent } from '@lostgradient/weft';
|
|
10
10
|
*
|
|
11
11
|
* const engine = new Engine({ checkpointSizeWarningThreshold: 32_000 });
|
|
12
|
-
* engine.addEventListener(
|
|
13
|
-
*
|
|
14
|
-
* console.warn(ev.workflowId, 'checkpoint at step', ev.step, 'is', ev.sizeBytes, 'bytes');
|
|
12
|
+
* engine.addEventListener(CheckpointSizeWarningEvent.type, (event) => {
|
|
13
|
+
* console.warn(event.workflowId, 'checkpoint at step', event.step, 'is', event.sizeBytes, 'bytes');
|
|
15
14
|
* });
|
|
16
15
|
* ```
|
|
17
16
|
*/
|
|
@@ -33,9 +32,8 @@ export declare class CheckpointSizeWarningEvent extends Event {
|
|
|
33
32
|
* import { Engine, DevelopmentWarningEvent } from '@lostgradient/weft';
|
|
34
33
|
*
|
|
35
34
|
* const engine = new Engine({ development: true });
|
|
36
|
-
* engine.addEventListener(
|
|
37
|
-
*
|
|
38
|
-
* console.warn('[dev]', ev.message, 'paths:', ev.fieldPaths);
|
|
35
|
+
* engine.addEventListener(DevelopmentWarningEvent.type, (event) => {
|
|
36
|
+
* console.warn('[dev]', event.message, 'paths:', event.fieldPaths);
|
|
39
37
|
* });
|
|
40
38
|
* ```
|
|
41
39
|
*/
|
|
@@ -63,9 +61,8 @@ export declare class CleanupWarningEvent extends Event {
|
|
|
63
61
|
* import { Engine, StorageSizeReportedEvent } from '@lostgradient/weft';
|
|
64
62
|
*
|
|
65
63
|
* const engine = new Engine();
|
|
66
|
-
* engine.addEventListener(
|
|
67
|
-
*
|
|
68
|
-
* console.log('total storage:', ev.sizeBytes, 'bytes');
|
|
64
|
+
* engine.addEventListener(StorageSizeReportedEvent.type, (event) => {
|
|
65
|
+
* console.log('total storage:', event.sizeBytes, 'bytes');
|
|
69
66
|
* });
|
|
70
67
|
* ```
|
|
71
68
|
*/
|
|
@@ -74,6 +71,22 @@ export declare class StorageSizeReportedEvent extends Event {
|
|
|
74
71
|
readonly sizeBytes: number;
|
|
75
72
|
constructor(sizeBytes: number);
|
|
76
73
|
}
|
|
74
|
+
/** Fired when a remote worker successfully registers with the server runtime. */
|
|
75
|
+
export declare class WorkerConnectedEvent extends Event {
|
|
76
|
+
static readonly type: "worker:connected";
|
|
77
|
+
readonly workerId: string;
|
|
78
|
+
readonly queue: string;
|
|
79
|
+
readonly activities: readonly string[];
|
|
80
|
+
readonly concurrency: number;
|
|
81
|
+
constructor(workerId: string, queue: string, activities: readonly string[], concurrency: number);
|
|
82
|
+
}
|
|
83
|
+
/** Fired when a registered remote worker is removed after disconnect handling. */
|
|
84
|
+
export declare class WorkerDisconnectedEvent extends Event {
|
|
85
|
+
static readonly type: "worker:disconnected";
|
|
86
|
+
readonly workerId: string;
|
|
87
|
+
readonly inFlightTaskCount: number;
|
|
88
|
+
constructor(workerId: string, inFlightTaskCount: number);
|
|
89
|
+
}
|
|
77
90
|
/**
|
|
78
91
|
* Fired on the {@link Engine} when a built-in alert metric breaches its
|
|
79
92
|
* threshold. Read `e.metric`, `e.threshold`, `e.currentValue`, and
|
|
@@ -84,9 +97,8 @@ export declare class StorageSizeReportedEvent extends Event {
|
|
|
84
97
|
* import { Engine, AlertFiredEvent } from '@lostgradient/weft';
|
|
85
98
|
*
|
|
86
99
|
* const engine = new Engine();
|
|
87
|
-
* engine.addEventListener(
|
|
88
|
-
*
|
|
89
|
-
* console.warn('alert fired:', ev.metric, 'current:', ev.currentValue, 'threshold:', ev.threshold);
|
|
100
|
+
* engine.addEventListener(AlertFiredEvent.type, (event) => {
|
|
101
|
+
* console.warn('alert fired:', event.metric, 'current:', event.currentValue, 'threshold:', event.threshold);
|
|
90
102
|
* });
|
|
91
103
|
* ```
|
|
92
104
|
*/
|
|
@@ -108,9 +120,8 @@ export declare class AlertFiredEvent extends Event {
|
|
|
108
120
|
* import { Engine, AlertResolvedEvent } from '@lostgradient/weft';
|
|
109
121
|
*
|
|
110
122
|
* const engine = new Engine();
|
|
111
|
-
* engine.addEventListener(
|
|
112
|
-
*
|
|
113
|
-
* console.log('alert resolved:', ev.metric, 'value back to', ev.currentValue);
|
|
123
|
+
* engine.addEventListener(AlertResolvedEvent.type, (event) => {
|
|
124
|
+
* console.log('alert resolved:', event.metric, 'value back to', event.currentValue);
|
|
114
125
|
* });
|
|
115
126
|
* ```
|
|
116
127
|
*/
|
|
@@ -132,10 +143,9 @@ export declare class AlertResolvedEvent extends Event {
|
|
|
132
143
|
* import { Engine, ConstraintViolatedEvent } from '@lostgradient/weft';
|
|
133
144
|
*
|
|
134
145
|
* const engine = new Engine();
|
|
135
|
-
* engine.addEventListener(
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* 'action:', ev.onViolation);
|
|
146
|
+
* engine.addEventListener(ConstraintViolatedEvent.type, (event) => {
|
|
147
|
+
* console.warn('constraint', event.constraintName, 'violated in', event.workflowId,
|
|
148
|
+
* 'action:', event.onViolation);
|
|
139
149
|
* });
|
|
140
150
|
* ```
|
|
141
151
|
*/
|
|
@@ -46,6 +46,32 @@ export class StorageSizeReportedEvent extends Event {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
export class WorkerConnectedEvent extends Event {
|
|
50
|
+
static type = "worker:connected";
|
|
51
|
+
workerId;
|
|
52
|
+
queue;
|
|
53
|
+
activities;
|
|
54
|
+
concurrency;
|
|
55
|
+
constructor(workerId, queue, activities, concurrency) {
|
|
56
|
+
super(WorkerConnectedEvent.type);
|
|
57
|
+
this.workerId = workerId;
|
|
58
|
+
this.queue = queue;
|
|
59
|
+
this.activities = activities;
|
|
60
|
+
this.concurrency = concurrency;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class WorkerDisconnectedEvent extends Event {
|
|
65
|
+
static type = "worker:disconnected";
|
|
66
|
+
workerId;
|
|
67
|
+
inFlightTaskCount;
|
|
68
|
+
constructor(workerId, inFlightTaskCount) {
|
|
69
|
+
super(WorkerDisconnectedEvent.type);
|
|
70
|
+
this.workerId = workerId;
|
|
71
|
+
this.inFlightTaskCount = inFlightTaskCount;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
49
75
|
export class AlertFiredEvent extends Event {
|
|
50
76
|
static type = "alert:fired";
|
|
51
77
|
metric;
|