@lostgradient/weft 0.2.1 → 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 +123 -43
- package/dist/cli/conformance.js +7 -1
- package/dist/cli/generated/operation-client.generated.d.ts +55 -13
- package/dist/cli/generated/operation-client.generated.js +3 -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 +80 -79
- package/dist/client/handle-delegation.d.ts +7 -2
- package/dist/client/handle-delegation.js +9 -1
- package/dist/client/http-client-requests.d.ts +4 -1
- package/dist/client/http-client-requests.js +10 -0
- package/dist/client/http-client.d.ts +10 -4
- package/dist/client/http-client.js +18 -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 +100 -4
- package/dist/client/local.d.ts +7 -1
- package/dist/client/local.js +17 -2
- package/dist/client/start-body.d.ts +9 -2
- package/dist/client/start-body.js +13 -4
- 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 +104 -8
- package/dist/core/codec/index.d.ts +1 -0
- package/dist/core/codec/index.js +1 -0
- package/dist/core/codec/serializer-registry.d.ts +122 -0
- package/dist/core/codec/serializer-registry.js +51 -0
- 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 +18 -5
- package/dist/core/context/index.js +17 -12
- package/dist/core/context/internals.d.ts +29 -0
- package/dist/core/context/internals.js +6 -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 +21 -3
- package/dist/core/context/run-operation.js +56 -93
- 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 -1
- package/dist/core/engine/construction.js +30 -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 +25 -0
- package/dist/core/engine/engine-create-types.d.ts +14 -18
- package/dist/core/engine/engine-internal-types.d.ts +38 -3
- package/dist/core/engine/engine-leak-warnings.d.ts +6 -0
- package/dist/core/engine/engine-leak-warnings.js +4 -0
- package/dist/core/engine/engine-runtime-helpers.d.ts +17 -0
- package/dist/core/engine/engine-runtime-helpers.js +26 -5
- package/dist/core/engine/errors.d.ts +121 -0
- package/dist/core/engine/errors.js +45 -1
- 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/handle-result.js +1 -1
- package/dist/core/engine/handles.d.ts +97 -40
- package/dist/core/engine/handles.js +25 -27
- package/dist/core/engine/index.d.ts +125 -15
- package/dist/core/engine/index.js +207 -11
- package/dist/core/engine/inline-launch-queue.d.ts +14 -0
- package/dist/core/engine/inline-launch-queue.js +32 -7
- package/dist/core/engine/inline-parking.js +3 -2
- package/dist/core/engine/internals.d.ts +125 -13
- 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/fork-helpers.js +1 -7
- package/dist/core/engine/lifecycle/persist.js +15 -52
- 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 +39 -11
- 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 +56 -0
- package/dist/core/engine/lifecycle/start-commit.js +69 -0
- package/dist/core/engine/lifecycle/start-exec.d.ts +30 -2
- package/dist/core/engine/lifecycle/start-exec.js +38 -0
- 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-resolution.d.ts +79 -0
- package/dist/core/engine/lifecycle/start-or-signal-resolution.js +60 -0
- package/dist/core/engine/lifecycle/start-or-signal.d.ts +46 -0
- package/dist/core/engine/lifecycle/start-or-signal.js +71 -0
- 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 +6 -6
- package/dist/core/engine/lifecycle/start.js +47 -45
- package/dist/core/engine/lifecycle/transition.js +17 -5
- package/dist/core/engine/lifecycle.d.ts +3 -2
- package/dist/core/engine/lifecycle.js +9 -2
- package/dist/core/engine/list-candidate-resolution.js +2 -2
- package/dist/core/engine/listing.js +10 -6
- 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/persisted-data-version.d.ts +5 -9
- package/dist/core/engine/persisted-data-version.js +4 -5
- 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-handle.d.ts +45 -0
- package/dist/core/engine/schedule-handle.js +26 -0
- 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 +8 -5
- package/dist/core/engine/schedules.js +44 -19
- 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/second-instance-detector.d.ts +96 -0
- package/dist/core/engine/second-instance-detector.js +108 -0
- package/dist/core/engine/signals.d.ts +38 -0
- package/dist/core/engine/signals.js +55 -19
- 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 +28 -1
- package/dist/core/engine/termination/cleanup.js +44 -2
- package/dist/core/engine/termination/complete.js +48 -9
- 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 +70 -0
- package/dist/core/engine/termination/suspend.js +41 -0
- package/dist/core/engine/termination.d.ts +5 -2
- package/dist/core/engine/termination.js +6 -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 +54 -3
- 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 +9 -8
- 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 +19 -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 +108 -20
- package/dist/core/events/workflow-events.js +35 -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/list-filter-validation.js +2 -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 +56 -0
- package/dist/core/start-workflow-validation.js +30 -1
- package/dist/core/step-context.d.ts +10 -6
- package/dist/core/step-context.js +7 -15
- 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 +86 -64
- package/dist/core/types/bulk.d.ts +50 -9
- package/dist/core/types/checkpoint.d.ts +44 -8
- package/dist/core/types/identity.d.ts +8 -1
- package/dist/core/types/launch-metadata.d.ts +33 -0
- package/dist/core/types/launch-metadata.js +0 -0
- package/dist/core/types/list-options.d.ts +146 -0
- package/dist/core/types/list-options.js +0 -0
- package/dist/core/types/message-handles.d.ts +25 -0
- package/dist/core/types/options.d.ts +165 -215
- package/dist/core/types/reviews.d.ts +2 -1
- package/dist/core/types/schedules.d.ts +39 -3
- package/dist/core/types/services-resolution.d.ts +47 -0
- package/dist/core/types/services-resolution.js +0 -0
- package/dist/core/types/state.d.ts +11 -11
- 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 +47 -15
- 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 +101 -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/workflow-snapshot.d.ts +29 -0
- package/dist/core/types/workflow-snapshot.js +0 -0
- package/dist/core/types.d.ts +7 -0
- package/dist/core/types.js +7 -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 +19 -1
- 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/doctor.js +6 -3
- package/dist/diagnostics/format.js +3 -8
- package/dist/diagnostics/types.d.ts +5 -5
- package/dist/diagnostics/validate.d.ts +0 -1
- package/dist/diagnostics/version-check.d.ts +1 -1
- package/dist/diagnostics/version-check.js +10 -13
- package/dist/index.d.ts +13 -11
- package/dist/index.js +39 -4
- package/dist/json-schema.js +3 -3
- package/dist/mcp/cli.js +35 -35
- package/dist/mcp/dispatcher.js +1 -1
- package/dist/mcp/http.js +16 -6
- package/dist/mcp/list-filter.js +2 -1
- 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 +60 -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 +31 -31
- package/dist/server/index.d.ts +32 -2
- package/dist/server/index.js +35 -35
- package/dist/server/interactive-operations.js +1 -0
- 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/resume-workflow.js +2 -2
- 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 +44 -0
- package/dist/server/operations/start-or-signal-workflow.js +130 -0
- package/dist/server/operations/start-workflow-options.d.ts +38 -0
- package/dist/server/operations/start-workflow-options.js +63 -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 +15 -92
- 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/suspend-workflow.d.ts +13 -0
- package/dist/server/operations/suspend-workflow.js +36 -0
- 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 +21 -8
- package/dist/server/rest-bindings.js +24 -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-dispatch.js +5 -3
- package/dist/server/runtime/task-polling.d.ts +16 -2
- package/dist/server/runtime/task-polling.js +80 -24
- 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 +46 -30
- package/dist/server/serve-internals.d.ts +11 -1
- package/dist/server/serve-internals.js +20 -2
- package/dist/server/task-state.d.ts +38 -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 +31 -31
- package/dist/storage/auto.js +1 -1
- package/dist/storage/bun-sql.js +24 -0
- package/dist/storage/capabilities.d.ts +10 -2
- package/dist/storage/capabilities.js +2 -2
- 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 +81 -4
- package/dist/storage/indexeddb.js +1 -1
- package/dist/storage/interface.d.ts +189 -0
- package/dist/storage/interface.js +1 -1
- package/dist/storage/key-prefixes.d.ts +1 -1
- package/dist/storage/key-prefixes.js +12 -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 +74 -0
- package/dist/storage/neon-value-mapping.js +23 -0
- package/dist/storage/neon.d.ts +124 -0
- package/dist/storage/neon.js +15 -0
- package/dist/storage/node-sqlite-loader.d.ts +71 -0
- package/dist/storage/node-sqlite-loader.js +41 -0
- package/dist/storage/node-sqlite.d.ts +1 -19
- package/dist/storage/node-sqlite.js +61 -32
- package/dist/storage/postgres-key-value-queries.d.ts +104 -0
- package/dist/storage/postgres-key-value-queries.js +101 -0
- package/dist/storage/resolve.d.ts +2 -165
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/storage-configuration.d.ts +209 -0
- package/dist/storage/storage-configuration.js +0 -0
- package/dist/storage/testing.d.ts +168 -0
- package/dist/storage/testing.js +2 -0
- package/dist/storage/text-value-store.d.ts +9 -9
- 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 +35 -35
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/index.js +9 -5
- package/dist/worker/long-poll.js +4 -0
- package/dist/worker/protocol-messages.d.ts +20 -0
- package/dist/worker/protocol-schemas.d.ts +32 -0
- package/dist/worker/protocol-schemas.js +8 -4
- package/dist/worker/protocol-task-result.d.ts +28 -0
- package/dist/worker/protocol-task-result.js +76 -0
- package/dist/worker/protocol.d.ts +4 -15
- package/dist/worker/protocol.js +1 -1
- package/dist/worker/registry/fair-share.d.ts +29 -0
- package/dist/worker/registry/fair-share.js +30 -0
- package/dist/worker/registry/routing.d.ts +18 -0
- package/dist/worker/registry/routing.js +14 -0
- package/dist/worker/registry/types.d.ts +7 -0
- package/dist/worker/registry.d.ts +16 -1
- package/dist/worker/registry.js +24 -36
- 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 +21 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseDuration } from "./scheduler.js";
|
|
2
2
|
import { WeftError } from "./weft-error.js";
|
|
3
3
|
import { assertValidWorkflowId } from "./workflow-identifiers.js";
|
|
4
|
-
export const MAX_WORKFLOW_TAGS = 32, MAX_WORKFLOW_TAG_BYTES = 128;
|
|
4
|
+
export const MAX_WORKFLOW_TAGS = 32, MAX_WORKFLOW_TAG_BYTES = 128, MAX_IDEMPOTENCY_KEY_BYTES = 117;
|
|
5
5
|
const textEncoder = new TextEncoder, EXCLUSIVE_START_WORKFLOW_OPTIONS_ERROR = "Provide only one of startAt or startAfter";
|
|
6
6
|
|
|
7
7
|
export class StartWorkflowValidationError extends WeftError {
|
|
@@ -22,7 +22,36 @@ export const assertExclusiveStartWorkflowOptions = (startAt, startAfter) => {
|
|
|
22
22
|
const message = error instanceof Error ? error.message : String(error);
|
|
23
23
|
throw new StartWorkflowValidationError(message);
|
|
24
24
|
}
|
|
25
|
+
}, coerceStartWorkflowIdempotencyKey = (value, fieldName) => {
|
|
26
|
+
if (typeof value !== "string")
|
|
27
|
+
throw new StartWorkflowValidationError(`${fieldName} must be a string`);
|
|
28
|
+
return assertValidIdempotencyKey(value, fieldName);
|
|
29
|
+
}, assertValidIdempotencyKey = (value, fieldName) => {
|
|
30
|
+
if (value.length === 0)
|
|
31
|
+
throw new StartWorkflowValidationError(`${fieldName} must not be empty`);
|
|
32
|
+
if (textEncoder.encode(value).byteLength > MAX_IDEMPOTENCY_KEY_BYTES)
|
|
33
|
+
throw new StartWorkflowValidationError(`${fieldName} must be at most ${MAX_IDEMPOTENCY_KEY_BYTES} UTF-8 bytes`);
|
|
34
|
+
return value;
|
|
25
35
|
};
|
|
36
|
+
export function assertValidOnTerminalConflict(options) {
|
|
37
|
+
const onTerminalConflict = options?.onTerminalConflict;
|
|
38
|
+
if (onTerminalConflict === void 0 || onTerminalConflict === "error")
|
|
39
|
+
return;
|
|
40
|
+
if (onTerminalConflict !== "start-new")
|
|
41
|
+
throw new StartWorkflowValidationError("options.onTerminalConflict must be 'error' or 'start-new'");
|
|
42
|
+
if (options?.idempotencyKey !== void 0)
|
|
43
|
+
throw new StartWorkflowValidationError("options.onTerminalConflict: 'start-new' is mutually exclusive with options.idempotencyKey: idempotency is a permanent at-most-once mapping and cannot restart a terminal run");
|
|
44
|
+
if (options?.id === void 0)
|
|
45
|
+
throw new StartWorkflowValidationError("options.onTerminalConflict: 'start-new' requires an explicit options.id; a generated id is never a meaningful restart target");
|
|
46
|
+
}
|
|
47
|
+
export function assertIdAndIdempotencyKeyExclusive(options) {
|
|
48
|
+
if (options.id !== void 0 && options.idempotencyKey !== void 0)
|
|
49
|
+
throw new StartWorkflowValidationError("options.id and options.idempotencyKey are mutually exclusive: idempotency assigns its own workflow id and dedups through the idempotency key. Provide one or the other.");
|
|
50
|
+
}
|
|
51
|
+
export function assertOnTerminalConflictUnsupported(options, surface) {
|
|
52
|
+
if (options !== void 0 && "onTerminalConflict" in options && options.onTerminalConflict !== void 0)
|
|
53
|
+
throw new StartWorkflowValidationError(`${surface} does not support options.onTerminalConflict; it is available on engine.start only`);
|
|
54
|
+
}
|
|
26
55
|
export function coerceStartWorkflowTimestamp(value, fieldName) {
|
|
27
56
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)
|
|
28
57
|
throw new StartWorkflowValidationError(`${fieldName} must be a non-negative integer millisecond timestamp`);
|
|
@@ -7,19 +7,23 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module core/step-context
|
|
9
9
|
*/
|
|
10
|
-
import type { ContextOperationRequest } from './context.ts';
|
|
11
10
|
import type { StepWorkflowContext, WorkflowFunction } from './types.ts';
|
|
12
11
|
interface QueuedOperation {
|
|
13
|
-
|
|
12
|
+
/** Explicit, user-supplied step name. Used as the durable activity label. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** The zero-argument step body. Executed by the engine as an inline activity. */
|
|
15
|
+
fn: () => unknown;
|
|
14
16
|
resolve: (value: unknown) => void;
|
|
15
17
|
reject: (reason: unknown) => void;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Internal implementation of {@link StepWorkflowContext} for step-based
|
|
19
|
-
* ("progressive disclosure") workflows.
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* ("progressive disclosure") workflows. Each `step()` call is a thin async
|
|
22
|
+
* enqueue; the compiled generator (see {@link compileStepWorkflow}) drains the
|
|
23
|
+
* queue and runs each step through the engine's durable activity machinery, so
|
|
24
|
+
* a completed step is replayed from the checkpoint rather than re-executed
|
|
25
|
+
* after a crash. Build via {@link compileStepWorkflow} rather than constructing
|
|
26
|
+
* directly.
|
|
23
27
|
*
|
|
24
28
|
* @example
|
|
25
29
|
* ```ts
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { asConcreteContext, runActivityWithRetry } from "./context/run-operation.js";
|
|
2
|
+
|
|
1
3
|
export class StepContext {
|
|
2
4
|
workflowId;
|
|
3
5
|
signal;
|
|
@@ -9,18 +11,8 @@ export class StepContext {
|
|
|
9
11
|
this.signal = signal;
|
|
10
12
|
}
|
|
11
13
|
async step(name, fn) {
|
|
12
|
-
const
|
|
13
|
-
this.#queue.push({
|
|
14
|
-
request: {
|
|
15
|
-
type: "activity",
|
|
16
|
-
operationId,
|
|
17
|
-
activityName: name,
|
|
18
|
-
fn,
|
|
19
|
-
input: void 0
|
|
20
|
-
},
|
|
21
|
-
resolve,
|
|
22
|
-
reject
|
|
23
|
-
});
|
|
14
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
15
|
+
this.#queue.push({ name, fn, resolve, reject });
|
|
24
16
|
this.#notifyQueue?.();
|
|
25
17
|
return promise;
|
|
26
18
|
}
|
|
@@ -43,8 +35,8 @@ export class StepContext {
|
|
|
43
35
|
}
|
|
44
36
|
}
|
|
45
37
|
export function compileStepWorkflow(stepFunction) {
|
|
46
|
-
return async function* (
|
|
47
|
-
const rawContext =
|
|
38
|
+
return async function* (publicContext, input) {
|
|
39
|
+
const rawContext = asConcreteContext(publicContext), stepContext = new StepContext(rawContext.workflowId, rawContext.signal);
|
|
48
40
|
let workflowResult, workflowError;
|
|
49
41
|
const userPromise = stepFunction(stepContext, input).then((result) => {
|
|
50
42
|
workflowResult = result;
|
|
@@ -59,7 +51,7 @@ export function compileStepWorkflow(stepFunction) {
|
|
|
59
51
|
if (queued === null)
|
|
60
52
|
break;
|
|
61
53
|
try {
|
|
62
|
-
const result = yield queued.
|
|
54
|
+
const result = yield* runActivityWithRetry(rawContext, queued.fn, [], queued.name);
|
|
63
55
|
queued.resolve(result);
|
|
64
56
|
} catch (error) {
|
|
65
57
|
queued.reject(error);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity verification types: the two-phase verifier contract an activity can
|
|
3
|
+
* declare via {@link ActivityDefinition.verify}. Split out of `activity.ts` to
|
|
4
|
+
* keep that module under the per-file line ceiling; these types are re-exported
|
|
5
|
+
* through `../types.ts` so the public surface is unchanged.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Identifies whether an activity verifier is checking a fresh result or
|
|
9
|
+
* reconciling a prior keyed dispatch before redispatch.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import type { ActivityVerificationPhase } from '@lostgradient/weft';
|
|
14
|
+
*
|
|
15
|
+
* const phase: ActivityVerificationPhase = 'pre-dispatch-reconciliation';
|
|
16
|
+
* console.log(phase);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export type ActivityVerificationPhase = 'post-execution-validation' | 'pre-dispatch-reconciliation';
|
|
20
|
+
/**
|
|
21
|
+
* Metadata passed to a Tier-0 activity verifier.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import type { ActivityVerificationContext } from '@lostgradient/weft';
|
|
26
|
+
*
|
|
27
|
+
* function shouldQueryExternalSystem(context: ActivityVerificationContext): boolean {
|
|
28
|
+
* return context.phase === 'pre-dispatch-reconciliation';
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export interface ActivityVerificationContext<TInput = unknown> {
|
|
33
|
+
phase: ActivityVerificationPhase;
|
|
34
|
+
workflowId: string;
|
|
35
|
+
activityName: string;
|
|
36
|
+
operationId: string;
|
|
37
|
+
input: TInput;
|
|
38
|
+
idempotencyKey?: string;
|
|
39
|
+
attempt: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Return value for activity verification. Post-execution validation uses a
|
|
43
|
+
* boolean; pre-dispatch reconciliation can report whether a prior keyed side
|
|
44
|
+
* effect completed, did not complete, or is indeterminate.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import type { ActivityVerificationResult } from '@lostgradient/weft';
|
|
49
|
+
*
|
|
50
|
+
* const result: ActivityVerificationResult<string> = {
|
|
51
|
+
* status: 'completed-with-result',
|
|
52
|
+
* result: 'already-finished',
|
|
53
|
+
* };
|
|
54
|
+
* console.log(result.status);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export type ActivityVerificationResult<TOutput = unknown> = boolean | 'not-completed' | 'completed-result-unavailable' | 'indeterminate' | {
|
|
58
|
+
status: 'completed-with-result';
|
|
59
|
+
result: TOutput;
|
|
60
|
+
};
|
|
61
|
+
export type ActivityPostExecutionVerifier<TOutput = unknown> = {
|
|
62
|
+
bivarianceHack(result: TOutput): Promise<boolean> | boolean;
|
|
63
|
+
}['bivarianceHack'];
|
|
64
|
+
export type ActivityTier0Verifier<TInput = unknown, TOutput = unknown> = {
|
|
65
|
+
bivarianceHack(result: TOutput | undefined, context: ActivityVerificationContext<TInput>): Promise<ActivityVerificationResult<TOutput>> | ActivityVerificationResult<TOutput>;
|
|
66
|
+
}['bivarianceHack'];
|
|
67
|
+
export type ActivityVerifier<TInput = unknown, TOutput = unknown> = ActivityPostExecutionVerifier<TOutput> | ActivityTier0Verifier<TInput, TOutput>;
|
|
File without changes
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ActivityVerifier } from './activity-verification.ts';
|
|
1
2
|
import type { DefinitionSchema, InferSchemaOutput } from './definition-schema.ts';
|
|
2
3
|
import type { Duration, RetryPolicy } from './retry-retention.ts';
|
|
3
4
|
/**
|
|
@@ -47,6 +48,53 @@ export type ActivityFunction<TInput = unknown, TOutput = unknown> = (input: TInp
|
|
|
47
48
|
export interface ActivityContext {
|
|
48
49
|
signal: AbortSignal;
|
|
49
50
|
heartbeat(details?: unknown): void;
|
|
51
|
+
/**
|
|
52
|
+
* The heartbeat payload recorded by the PREVIOUS attempt of this activity, or
|
|
53
|
+
* `undefined` if there is none. This is the resumable-batch pattern: a
|
|
54
|
+
* long-running activity that calls `ctx.heartbeat({ done: n })` to record its
|
|
55
|
+
* progress can read `ctx.lastHeartbeatDetails` on a retry and skip the work it
|
|
56
|
+
* already finished, instead of re-running from the start and producing
|
|
57
|
+
* duplicate side effects.
|
|
58
|
+
*
|
|
59
|
+
* It is `undefined` on the first attempt, after an engine restart (the value is
|
|
60
|
+
* held in engine memory, never checkpointed), and for worker-executed
|
|
61
|
+
* activities (which run their function out of process and never observe this).
|
|
62
|
+
* Because it is non-durable, treat it as a best-effort optimization: a correct
|
|
63
|
+
* activity must still produce the right result when `lastHeartbeatDetails` is
|
|
64
|
+
* `undefined`. For a durability guarantee, persist progress in workflow state
|
|
65
|
+
* (e.g. one `ctx.run` per batch with an `idempotencyKey`) instead.
|
|
66
|
+
*
|
|
67
|
+
* Only top-level `ctx.run` activities retry, so this is only ever populated
|
|
68
|
+
* there. An activity called inside `ctx.all` / `ctx.race` does not retry, so its
|
|
69
|
+
* `lastHeartbeatDetails` is always `undefined`.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { activity, type ActivityContext } from '@lostgradient/weft';
|
|
74
|
+
*
|
|
75
|
+
* function resumeFrom(details: unknown): number {
|
|
76
|
+
* return typeof details === 'object' && details !== null && 'done' in details &&
|
|
77
|
+
* typeof (details as { done: unknown }).done === 'number'
|
|
78
|
+
* ? (details as { done: number }).done
|
|
79
|
+
* : 0;
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* const postBatches = activity({
|
|
83
|
+
* name: 'postBatches',
|
|
84
|
+
* execute: async (batches: string[][], ctx?: ActivityContext) => {
|
|
85
|
+
* let done = resumeFrom(ctx?.lastHeartbeatDetails);
|
|
86
|
+
* for (; done < batches.length; done += 1) {
|
|
87
|
+
* await postBatch(batches[done]!);
|
|
88
|
+
* ctx?.heartbeat({ done: done + 1 });
|
|
89
|
+
* }
|
|
90
|
+
* return { posted: done };
|
|
91
|
+
* },
|
|
92
|
+
* });
|
|
93
|
+
* declare function postBatch(batch: string[]): Promise<void>;
|
|
94
|
+
* void postBatches;
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
lastHeartbeatDetails?: unknown;
|
|
50
98
|
/**
|
|
51
99
|
* Defer this activity to out-of-band completion. Calling `completeAsync()`
|
|
52
100
|
* hands the work off to an external system — a webhook, a human callback, a
|
|
@@ -120,68 +168,30 @@ export interface ActivityCallOptions {
|
|
|
120
168
|
sticky?: boolean;
|
|
121
169
|
/** Override the default visibility timeout for this invocation. */
|
|
122
170
|
visibilityTimeout?: Duration;
|
|
171
|
+
/**
|
|
172
|
+
* Total wall-clock budget for this activity across ALL retry attempts and the
|
|
173
|
+
* backoff waits between them — close to Temporal's `scheduleToCloseTimeout`.
|
|
174
|
+
* Unlike `timeout` (a per-attempt cap, reset on every attempt), this budget is
|
|
175
|
+
* measured from the first dispatch and is not reset between attempts. When the
|
|
176
|
+
* budget bars the next attempt, the activity fails with an
|
|
177
|
+
* {@link ActivityScheduleToCloseTimeoutError} (a `timeout` failure category).
|
|
178
|
+
*
|
|
179
|
+
* Enforcement is at the **retry decision point**, not by waiting out the clock:
|
|
180
|
+
* the activity fails when the next retry's backoff would start it at or after the
|
|
181
|
+
* deadline (or when an attempt has already overrun the budget), rather than
|
|
182
|
+
* parking for a backoff that is already doomed. So a retry whose backoff would
|
|
183
|
+
* overshoot the budget is skipped immediately even though the actual elapsed time
|
|
184
|
+
* is still under the budget — the error reports the actual elapsed time and the
|
|
185
|
+
* projected next-dispatch that triggered the decision.
|
|
186
|
+
*
|
|
187
|
+
* It has **no effect unless a retry policy is configured** — a non-retried
|
|
188
|
+
* activity fails on its first error before the budget is ever consulted. Use
|
|
189
|
+
* `timeout` to bound a single attempt. It also applies to top-level `ctx.run`
|
|
190
|
+
* activities only; an activity inside `ctx.all` / `ctx.race` does not retry, so
|
|
191
|
+
* this budget never engages there.
|
|
192
|
+
*/
|
|
193
|
+
scheduleToCloseTimeout?: Duration;
|
|
123
194
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Identifies whether an activity verifier is checking a fresh result or
|
|
126
|
-
* reconciling a prior keyed dispatch before redispatch.
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* ```ts
|
|
130
|
-
* import type { ActivityVerificationPhase } from '@lostgradient/weft';
|
|
131
|
-
*
|
|
132
|
-
* const phase: ActivityVerificationPhase = 'pre-dispatch-reconciliation';
|
|
133
|
-
* console.log(phase);
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
export type ActivityVerificationPhase = 'post-execution-validation' | 'pre-dispatch-reconciliation';
|
|
137
|
-
/**
|
|
138
|
-
* Metadata passed to a Tier-0 activity verifier.
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```ts
|
|
142
|
-
* import type { ActivityVerificationContext } from '@lostgradient/weft';
|
|
143
|
-
*
|
|
144
|
-
* function shouldQueryExternalSystem(context: ActivityVerificationContext): boolean {
|
|
145
|
-
* return context.phase === 'pre-dispatch-reconciliation';
|
|
146
|
-
* }
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
export interface ActivityVerificationContext<TInput = unknown> {
|
|
150
|
-
phase: ActivityVerificationPhase;
|
|
151
|
-
workflowId: string;
|
|
152
|
-
activityName: string;
|
|
153
|
-
operationId: string;
|
|
154
|
-
input: TInput;
|
|
155
|
-
idempotencyKey?: string;
|
|
156
|
-
attempt: number;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Return value for activity verification. Post-execution validation uses a
|
|
160
|
-
* boolean; pre-dispatch reconciliation can report whether a prior keyed side
|
|
161
|
-
* effect completed, did not complete, or is indeterminate.
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```ts
|
|
165
|
-
* import type { ActivityVerificationResult } from '@lostgradient/weft';
|
|
166
|
-
*
|
|
167
|
-
* const result: ActivityVerificationResult<string> = {
|
|
168
|
-
* status: 'completed-with-result',
|
|
169
|
-
* result: 'already-finished',
|
|
170
|
-
* };
|
|
171
|
-
* console.log(result.status);
|
|
172
|
-
* ```
|
|
173
|
-
*/
|
|
174
|
-
export type ActivityVerificationResult<TOutput = unknown> = boolean | 'not-completed' | 'completed-result-unavailable' | 'indeterminate' | {
|
|
175
|
-
status: 'completed-with-result';
|
|
176
|
-
result: TOutput;
|
|
177
|
-
};
|
|
178
|
-
export type ActivityPostExecutionVerifier<TOutput = unknown> = {
|
|
179
|
-
bivarianceHack(result: TOutput): Promise<boolean> | boolean;
|
|
180
|
-
}['bivarianceHack'];
|
|
181
|
-
export type ActivityTier0Verifier<TInput = unknown, TOutput = unknown> = {
|
|
182
|
-
bivarianceHack(result: TOutput | undefined, context: ActivityVerificationContext<TInput>): Promise<ActivityVerificationResult<TOutput>> | ActivityVerificationResult<TOutput>;
|
|
183
|
-
}['bivarianceHack'];
|
|
184
|
-
export type ActivityVerifier<TInput = unknown, TOutput = unknown> = ActivityPostExecutionVerifier<TOutput> | ActivityTier0Verifier<TInput, TOutput>;
|
|
185
195
|
/**
|
|
186
196
|
* Full metadata for an activity, combining the execute function with optional
|
|
187
197
|
* retry policy, timeout, queue routing, compensation, and idempotency. Built
|
|
@@ -218,12 +228,15 @@ export interface ActivityDefinition<TInput = unknown, TOutput = unknown, TName e
|
|
|
218
228
|
/** Activity implementation called by the engine or worker. */
|
|
219
229
|
execute: ActivityFunction<TInput, TOutput>;
|
|
220
230
|
/**
|
|
221
|
-
* Optional
|
|
231
|
+
* Optional verifier, invoked in two phases (see
|
|
232
|
+
* `ActivityVerificationContext.phase`).
|
|
222
233
|
*
|
|
223
234
|
* During normal post-execution validation, return `true` to confirm the
|
|
224
235
|
* activity result or `false` to reject it. During pre-dispatch crash recovery
|
|
225
|
-
* for keyed activities, return an explicit reconciliation state
|
|
226
|
-
*
|
|
236
|
+
* for keyed activities, return an explicit reconciliation state. A boolean is
|
|
237
|
+
* the post-execution result shape, not a Tier-0 reconciliation state, so a
|
|
238
|
+
* boolean returned during pre-dispatch reconciliation fails closed rather than
|
|
239
|
+
* being treated as proof of external completion.
|
|
227
240
|
*/
|
|
228
241
|
verify?: ActivityVerifier<TInput, TOutput>;
|
|
229
242
|
retry?: RetryPolicy;
|
|
@@ -232,6 +245,15 @@ export interface ActivityDefinition<TInput = unknown, TOutput = unknown, TName e
|
|
|
232
245
|
idempotent?: boolean;
|
|
233
246
|
/** Visibility timeout for this activity. Defaults to 30 seconds. */
|
|
234
247
|
visibilityTimeout?: Duration;
|
|
248
|
+
/**
|
|
249
|
+
* Total wall-clock budget across all retry attempts and their backoff waits,
|
|
250
|
+
* measured from the first dispatch. The per-call {@link ActivityCallOptions.scheduleToCloseTimeout}
|
|
251
|
+
* overrides this default. Enforced at the retry decision point (the activity
|
|
252
|
+
* fails when the next retry would start at or after the deadline, not by waiting
|
|
253
|
+
* out the clock), so it only engages for a retried, top-level `ctx.run` activity.
|
|
254
|
+
* See the per-call option for the full contract.
|
|
255
|
+
*/
|
|
256
|
+
scheduleToCloseTimeout?: Duration;
|
|
235
257
|
/**
|
|
236
258
|
* Optional compensation function. When defined and a saga step that ran this
|
|
237
259
|
* activity needs to be rolled back, the engine calls `compensate(input, output)`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WorkflowId, WorkflowStatus } from './identity.ts';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AttributeFilterScalarValue } from './list-options.ts';
|
|
3
3
|
export declare const MAX_BULK_OPERATION_REQUEST_ID_LENGTH = 200;
|
|
4
4
|
export declare const MAX_BULK_CONFIRMATION_TOKEN_LENGTH = 256;
|
|
5
5
|
/**
|
|
@@ -14,7 +14,7 @@ export declare const MAX_BULK_CONFIRMATION_TOKEN_LENGTH = 256;
|
|
|
14
14
|
* void action;
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
export type BulkOperationAction = 'cancel' | 'signal' | 'delete' | 'tag:add' | 'tag:remove' | '
|
|
17
|
+
export type BulkOperationAction = 'cancel' | 'signal' | 'delete' | 'tag:add' | 'tag:remove' | 'retry-failed';
|
|
18
18
|
/**
|
|
19
19
|
* Credential-safe caller summary recorded on bulk audit events. Claims,
|
|
20
20
|
* bearer tokens, API keys, and other credentials are intentionally absent.
|
|
@@ -55,11 +55,11 @@ export type BulkOperationFilterSummary = {
|
|
|
55
55
|
tags?: string[];
|
|
56
56
|
attributes?: Array<{
|
|
57
57
|
key: string;
|
|
58
|
-
value?:
|
|
59
|
-
gt?:
|
|
60
|
-
lt?:
|
|
61
|
-
gte?:
|
|
62
|
-
lte?:
|
|
58
|
+
value?: AttributeFilterScalarValue | AttributeFilterScalarValue[];
|
|
59
|
+
gt?: AttributeFilterScalarValue;
|
|
60
|
+
lt?: AttributeFilterScalarValue;
|
|
61
|
+
gte?: AttributeFilterScalarValue;
|
|
62
|
+
lte?: AttributeFilterScalarValue;
|
|
63
63
|
}>;
|
|
64
64
|
limit?: number;
|
|
65
65
|
offset?: number;
|
|
@@ -126,6 +126,16 @@ export type BulkOperationDryRunResult = {
|
|
|
126
126
|
sampleWorkflowIds: WorkflowId[];
|
|
127
127
|
confirmationToken: string;
|
|
128
128
|
confirmationTokenVersion: 1;
|
|
129
|
+
/**
|
|
130
|
+
* Delete-only, point-in-time advisory: ids in the matched scope that currently owe an
|
|
131
|
+
* engine-driven finalizer (#446) and so would be SKIPPED by the commit (mirrors
|
|
132
|
+
* {@link BulkDeleteResult.skippedTeardownPending}). Present only on a `delete` preview
|
|
133
|
+
* and only when non-empty. `matched`, `scope`, and `confirmationToken` still describe
|
|
134
|
+
* the full filter scope — they are stable and derive the commit token — so this field
|
|
135
|
+
* surfaces the skip without recomputing them (teardown-owed is transient and is
|
|
136
|
+
* re-evaluated at commit time, where the authoritative skip list is reported).
|
|
137
|
+
*/
|
|
138
|
+
skippedTeardownPending?: WorkflowId[];
|
|
129
139
|
};
|
|
130
140
|
/**
|
|
131
141
|
* Options for a dry-run bulk operation preview.
|
|
@@ -145,6 +155,7 @@ export type BulkOperationDryRunOptions = {
|
|
|
145
155
|
dryRun: true;
|
|
146
156
|
requestId?: string;
|
|
147
157
|
principal?: BulkOperationPrincipal;
|
|
158
|
+
bulkConcurrency?: number;
|
|
148
159
|
};
|
|
149
160
|
/**
|
|
150
161
|
* Options for a committed bulk operation.
|
|
@@ -165,6 +176,7 @@ export type BulkOperationCommitOptions = {
|
|
|
165
176
|
confirmationToken?: string;
|
|
166
177
|
requestId?: string;
|
|
167
178
|
principal?: BulkOperationPrincipal;
|
|
179
|
+
bulkConcurrency?: number;
|
|
168
180
|
};
|
|
169
181
|
/**
|
|
170
182
|
* Options accepted by bulk workflow operations.
|
|
@@ -173,7 +185,7 @@ export type BulkOperationCommitOptions = {
|
|
|
173
185
|
* ```ts
|
|
174
186
|
* import type { BulkOperationOptions } from '@lostgradient/weft';
|
|
175
187
|
*
|
|
176
|
-
* const options: BulkOperationOptions = { dryRun: true };
|
|
188
|
+
* const options: BulkOperationOptions = { dryRun: true, bulkConcurrency: 4 };
|
|
177
189
|
* void options;
|
|
178
190
|
* ```
|
|
179
191
|
*/
|
|
@@ -278,6 +290,29 @@ export type BulkCancelResult = {
|
|
|
278
290
|
errors: BulkOperationError[];
|
|
279
291
|
auditEvent?: BulkOperationAuditEvent;
|
|
280
292
|
};
|
|
293
|
+
/**
|
|
294
|
+
* Result of a bulk failed-workflow retry operation (`engine.retryFailedAll`).
|
|
295
|
+
* Reports the number of workflows accepted for retry, the number that failed
|
|
296
|
+
* to restart or resume, and per-workflow error details in `errors`.
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```ts
|
|
300
|
+
* import type { BulkRetryFailedResult } from '@lostgradient/weft';
|
|
301
|
+
*
|
|
302
|
+
* const result: BulkRetryFailedResult = {
|
|
303
|
+
* retried: 2,
|
|
304
|
+
* failed: 1,
|
|
305
|
+
* errors: [{ id: 'wf-3', error: 'Checkpoint no longer exists' }],
|
|
306
|
+
* };
|
|
307
|
+
* void result;
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
export type BulkRetryFailedResult = {
|
|
311
|
+
retried: number;
|
|
312
|
+
failed: number;
|
|
313
|
+
errors: BulkOperationError[];
|
|
314
|
+
auditEvent?: BulkOperationAuditEvent;
|
|
315
|
+
};
|
|
281
316
|
/**
|
|
282
317
|
* Result of a bulk signal operation (`engine.signalAll`). Reports the number
|
|
283
318
|
* of workflows that received the signal and the number for which delivery failed.
|
|
@@ -289,10 +324,16 @@ export type BulkSignalResult = {
|
|
|
289
324
|
};
|
|
290
325
|
/**
|
|
291
326
|
* Result of a bulk delete operation (`engine.deleteAll`). Reports how many
|
|
292
|
-
* terminal workflows were deleted from storage.
|
|
327
|
+
* terminal workflows were deleted from storage. Workflows that still owe an
|
|
328
|
+
* engine-driven finalizer (#446) are NOT deleted — deleting them would drop the
|
|
329
|
+
* finalizer payload before the resource is torn down — and are reported, by id, in
|
|
330
|
+
* `skippedTeardownPending` so the skip is visible rather than silent. The skip is
|
|
331
|
+
* transient: once the finalizer settles, a later `deleteAll` removes the record.
|
|
293
332
|
*/
|
|
294
333
|
export type BulkDeleteResult = {
|
|
295
334
|
deleted: number;
|
|
335
|
+
/** Ids of terminal workflows skipped because they still owe a finalizer run. */
|
|
336
|
+
skippedTeardownPending?: WorkflowId[];
|
|
296
337
|
auditEvent?: BulkOperationAuditEvent;
|
|
297
338
|
};
|
|
298
339
|
/**
|
|
@@ -3,6 +3,7 @@ import { WeftError } from '../weft-error.ts';
|
|
|
3
3
|
import type { FailureCategory, OperationId, WorkflowId } from './identity.ts';
|
|
4
4
|
import type { Duration, RetryPolicy } from './retry-retention.ts';
|
|
5
5
|
import type { SearchAttributeValue } from './search-attributes.ts';
|
|
6
|
+
import type { WorkflowLogRecord } from './workflow-log.ts';
|
|
6
7
|
/** Version tag for Worker-mode operation replay signatures stored in checkpoints. */
|
|
7
8
|
export declare const WORKER_REPLAY_SIGNATURE_FORMAT = "weft-worker-operation-signature-v1";
|
|
8
9
|
/**
|
|
@@ -69,7 +70,7 @@ export interface WorkerReplayOperationFailure {
|
|
|
69
70
|
/**
|
|
70
71
|
* Durable snapshot of a workflow's execution state persisted at each
|
|
71
72
|
* `yield` boundary. Contains the accumulated operation results, local
|
|
72
|
-
* variables,
|
|
73
|
+
* variables, search attributes, and the step counter.
|
|
73
74
|
* Users don't construct checkpoints directly; the engine manages them.
|
|
74
75
|
* Available via time-travel APIs and {@link WorkflowReplay}.
|
|
75
76
|
*
|
|
@@ -91,6 +92,12 @@ export interface Checkpoint {
|
|
|
91
92
|
step: number;
|
|
92
93
|
locals: Record<string, unknown>;
|
|
93
94
|
accumulatedResults: Array<[number, unknown]>;
|
|
95
|
+
/**
|
|
96
|
+
* Highest accumulated-result step whose replay data has been emitted to the
|
|
97
|
+
* workflow event log. Missing means no consumed results have been emitted yet,
|
|
98
|
+
* which is how old unpruned checkpoints are read.
|
|
99
|
+
*/
|
|
100
|
+
accumulatedResultReplayWatermark?: number;
|
|
94
101
|
/**
|
|
95
102
|
* Worker-mode replay guards for cached operation results. Inline execution
|
|
96
103
|
* ignores this optional field; Worker recovery uses it to prove a cached
|
|
@@ -103,15 +110,13 @@ export interface Checkpoint {
|
|
|
103
110
|
* can throw them back into the generator without trusting user result shape.
|
|
104
111
|
*/
|
|
105
112
|
workerReplayFailures?: Array<[number, WorkerReplayOperationFailure]>;
|
|
106
|
-
pendingSignals: string[];
|
|
107
113
|
searchAttributes: Record<string, SearchAttributeValue>;
|
|
108
|
-
/** User-defined workflow code version.
|
|
114
|
+
/** User-defined workflow code version. Checked during recovery. */
|
|
109
115
|
version: string;
|
|
110
116
|
/**
|
|
111
117
|
* Checkpoint schema version. Distinct from `version` (which is the
|
|
112
118
|
* user's workflow code version). Bumped whenever the engine changes
|
|
113
|
-
* the on-disk checkpoint format. Pre-1.0: refuse to load older
|
|
114
|
-
* versions; post-1.0: every bump must ship a migration.
|
|
119
|
+
* the on-disk checkpoint format. Pre-1.0: refuse to load older versions.
|
|
115
120
|
*/
|
|
116
121
|
schemaVersion: number;
|
|
117
122
|
createdAt: number;
|
|
@@ -126,8 +131,9 @@ export interface Checkpoint {
|
|
|
126
131
|
export declare const CURRENT_CHECKPOINT_SCHEMA_VERSION = 2;
|
|
127
132
|
/**
|
|
128
133
|
* Thrown by `validateCheckpointShape` when a checkpoint's
|
|
129
|
-
* `schemaVersion` does not match the engine's current version.
|
|
130
|
-
*
|
|
134
|
+
* `schemaVersion` does not match the engine's current version. A mismatched
|
|
135
|
+
* checkpoint is rejected, never upgraded in place: the engine loads only
|
|
136
|
+
* checkpoints stamped with the exact current schema version.
|
|
131
137
|
*/
|
|
132
138
|
export declare class CheckpointSchemaVersionError extends WeftError<'CheckpointSchemaVersionError'> {
|
|
133
139
|
readonly found: number | 'pre-versioned';
|
|
@@ -183,7 +189,7 @@ export interface TimerEntry {
|
|
|
183
189
|
id: string;
|
|
184
190
|
workflowId: WorkflowId;
|
|
185
191
|
fireAt: number;
|
|
186
|
-
kind: 'sleep' | 'visibility-timeout' | 'execution-deadline' | 'delayed-start' | 'schedule' | 'terminal-cleanup';
|
|
192
|
+
kind: 'sleep' | 'visibility-timeout' | 'execution-deadline' | 'delayed-start' | 'schedule' | 'terminal-cleanup' | 'teardown' | 'wait-condition';
|
|
187
193
|
executionTimeoutMs?: number;
|
|
188
194
|
}
|
|
189
195
|
export type WorkerInboundMessage = {
|
|
@@ -198,6 +204,14 @@ export type WorkerInboundMessage = {
|
|
|
198
204
|
executionStateOwnerId?: string;
|
|
199
205
|
deadline?: number;
|
|
200
206
|
headers?: [string, string][];
|
|
207
|
+
/**
|
|
208
|
+
* Whether the engine host has an `EngineOptions.onLog` sink installed. The
|
|
209
|
+
* worker routes `ctx.log` records back to the host (as a `log` outbound
|
|
210
|
+
* message) only when this is `true`; otherwise it logs to the worker's own
|
|
211
|
+
* console, preserving the default. Omitted (treated as `false`) when no host
|
|
212
|
+
* sink exists, so a worker can never lose logs to a no-op host callback.
|
|
213
|
+
*/
|
|
214
|
+
hostHasLogSink?: boolean;
|
|
201
215
|
} | {
|
|
202
216
|
type: 'resume';
|
|
203
217
|
protocolVersion?: number;
|
|
@@ -206,6 +220,8 @@ export type WorkerInboundMessage = {
|
|
|
206
220
|
workflowId: WorkflowId;
|
|
207
221
|
checkpoint: ArrayBuffer;
|
|
208
222
|
operationResult: OperationOutcome;
|
|
223
|
+
/** See {@link WorkerInboundMessage} `run.hostHasLogSink`; carried on every turn so a rebuilt or resumed worker keeps the capability. */
|
|
224
|
+
hostHasLogSink?: boolean;
|
|
209
225
|
} | {
|
|
210
226
|
type: 'cancel';
|
|
211
227
|
protocolVersion?: number;
|
|
@@ -234,4 +250,24 @@ export type WorkerOutboundMessage = {
|
|
|
234
250
|
errorStack?: string;
|
|
235
251
|
/** Populated when the execution strategy can classify the failure cause. */
|
|
236
252
|
failureCategory?: FailureCategory;
|
|
253
|
+
} | {
|
|
254
|
+
/**
|
|
255
|
+
* A `ctx.log` record forwarded from a worker to the engine host's
|
|
256
|
+
* `EngineOptions.onLog` sink (#529). Unlike the other variants, `log` is a
|
|
257
|
+
* NON-TERMINAL, best-effort observability message: it carries no turn-protocol
|
|
258
|
+
* state, never settles or clears the worker turn, and never reaches the strict
|
|
259
|
+
* accept-or-discard gate. The host delivers a record to the sink IFF the sending
|
|
260
|
+
* worker owns `workflowId` (active or parked) AND `record.workflowId` matches the
|
|
261
|
+
* envelope AND the record is a structurally valid `WorkflowLogRecord` within the
|
|
262
|
+
* size cap; otherwise the record is dropped — a wrong-owner, malformed, oversize,
|
|
263
|
+
* or out-of-turn `log` is never a protocol violation and never discards the
|
|
264
|
+
* worker. A between-turns self-log (a fire-and-forget log resolving while the
|
|
265
|
+
* worker is parked) IS delivered, because the worker still owns its parked
|
|
266
|
+
* workflow. The worker emits these only when the inbound message reported
|
|
267
|
+
* `hostHasLogSink: true`.
|
|
268
|
+
*/
|
|
269
|
+
type: 'log';
|
|
270
|
+
protocolVersion?: number;
|
|
271
|
+
workflowId: WorkflowId;
|
|
272
|
+
record: WorkflowLogRecord;
|
|
237
273
|
};
|
|
@@ -51,5 +51,12 @@ export type FailureCategory = 'application' | 'timeout' | 'cancellation' | 'reso
|
|
|
51
51
|
* Read this off `(await handle.state()).status` to learn whether a workflow
|
|
52
52
|
* is still running, finished cleanly, or failed. Pass it to `engine.list()`
|
|
53
53
|
* filters to scope queries by status.
|
|
54
|
+
*
|
|
55
|
+
* `'suspended'` is a non-terminal, non-running pause: a workflow that was
|
|
56
|
+
* explicitly suspended via {@link WorkflowHandle.suspend} (or
|
|
57
|
+
* `engine.suspend(id)`) keeps its checkpoint and is resumable via
|
|
58
|
+
* {@link WorkflowHandle.resume} (or `engine.resume(id)`), but is NOT
|
|
59
|
+
* auto-recovered by `engine.recoverAll()` — suspension is client-driven
|
|
60
|
+
* preemption, not a fault condition.
|
|
54
61
|
*/
|
|
55
|
-
export type WorkflowStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out';
|
|
62
|
+
export type WorkflowStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out' | 'suspended';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Launch context for a workflow, reconstructed from its persisted state by
|
|
3
|
+
* {@link WorkflowHandle.getLaunchMetadata}. Lets a caller — typically after
|
|
4
|
+
* `engine.recoverAll()` — recover the original input and the launch options that
|
|
5
|
+
* survive in durable state, without keeping a side table that correlates a
|
|
6
|
+
* recovered workflow back to how it was started.
|
|
7
|
+
*
|
|
8
|
+
* `launchOptions` carries only the options recoverable *faithfully* from
|
|
9
|
+
* persisted state: `id` (always) and `tags`. Note `tags` is the run's *current*
|
|
10
|
+
* tag set (tags are mutable via `addTags`/`removeTags`), not necessarily the
|
|
11
|
+
* tags passed at launch. Deliberately excluded: `executionTimeout` (state
|
|
12
|
+
* stores the absolute deadline, not the original duration, so it cannot be
|
|
13
|
+
* reproduced exactly); `idempotencyKey` (no durable trace); `searchAttributes`
|
|
14
|
+
* (live in their own durable index — read them via
|
|
15
|
+
* {@link WorkflowHandle.getAttributes}); and `services` (non-serializable,
|
|
16
|
+
* re-provided on recovery by {@link EngineOptions.resolveWorkflowServices}).
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { type LaunchMetadata } from '@lostgradient/weft';
|
|
21
|
+
*
|
|
22
|
+
* function describe(metadata: LaunchMetadata): string {
|
|
23
|
+
* return `input=${JSON.stringify(metadata.input)} id=${metadata.launchOptions.id}`;
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export interface LaunchMetadata {
|
|
28
|
+
input: unknown;
|
|
29
|
+
launchOptions: {
|
|
30
|
+
id: string;
|
|
31
|
+
tags?: string[];
|
|
32
|
+
};
|
|
33
|
+
}
|
|
File without changes
|