@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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { WorkflowStatus } from './identity.ts';
|
|
2
|
+
/**
|
|
3
|
+
* A point-in-time view of a workflow's progress, returned by
|
|
4
|
+
* {@link WorkflowHandle.snapshot}. Combines the persisted status with the
|
|
5
|
+
* current checkpoint step (the run's cursor), so a caller — typically after
|
|
6
|
+
* `engine.recoverAll()` — can rebuild its own progress adapter for a recovered
|
|
7
|
+
* run and re-register it on a live surface, without awaiting the run's final
|
|
8
|
+
* result.
|
|
9
|
+
*
|
|
10
|
+
* `step` is the run's current checkpoint step: the number of generator turns it
|
|
11
|
+
* has advanced. For a run live in this engine it reflects the latest in-memory
|
|
12
|
+
* checkpoint (which may be one step ahead of the last durable commit); for a
|
|
13
|
+
* run inspected or recovered in a fresh process it reflects the durably
|
|
14
|
+
* persisted checkpoint. It is `0` for a run that has its initial checkpoint but
|
|
15
|
+
* has not yet advanced, and increases as the run makes progress.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { type WorkflowSnapshot } from '@lostgradient/weft';
|
|
20
|
+
*
|
|
21
|
+
* function describe(snapshot: WorkflowSnapshot): string {
|
|
22
|
+
* return `${snapshot.status} @ step ${snapshot.step}`;
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export interface WorkflowSnapshot {
|
|
27
|
+
status: WorkflowStatus;
|
|
28
|
+
step: number;
|
|
29
|
+
}
|
|
File without changes
|
package/dist/core/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './types/activity-verification.ts';
|
|
1
2
|
export * from './types/activity.ts';
|
|
2
3
|
export * from './types/archive-adapter.ts';
|
|
3
4
|
export * from './types/bulk.ts';
|
|
@@ -7,6 +8,8 @@ export * from './types/definition-schema-to-json.ts';
|
|
|
7
8
|
export * from './types/definition-schema.ts';
|
|
8
9
|
export * from './types/history-policy.ts';
|
|
9
10
|
export * from './types/identity.ts';
|
|
11
|
+
export * from './types/launch-metadata.ts';
|
|
12
|
+
export * from './types/list-options.ts';
|
|
10
13
|
export * from './types/message-handles.ts';
|
|
11
14
|
export * from './types/options.ts';
|
|
12
15
|
export * from './types/payload-size-policy.ts';
|
|
@@ -15,12 +18,16 @@ export * from './types/reviews.ts';
|
|
|
15
18
|
export * from './types/schedules.ts';
|
|
16
19
|
export * from './types/search-attributes.ts';
|
|
17
20
|
export * from './types/serializer.ts';
|
|
21
|
+
export * from './types/services-resolution.ts';
|
|
18
22
|
export * from './types/standard-schema-validate.ts';
|
|
19
23
|
export * from './types/state.ts';
|
|
20
24
|
export * from './types/workflow-builder-helpers.ts';
|
|
21
25
|
export * from './types/workflow-builder-runtime.ts';
|
|
22
26
|
export * from './types/workflow-builder.ts';
|
|
27
|
+
export * from './types/workflow-concurrency.ts';
|
|
23
28
|
export * from './types/workflow-context.ts';
|
|
24
29
|
export * from './types/workflow-function.ts';
|
|
30
|
+
export * from './types/workflow-log.ts';
|
|
25
31
|
export * from './types/workflow-registries.ts';
|
|
26
32
|
export * from './types/workflow-registry.ts';
|
|
33
|
+
export * from './types/workflow-snapshot.ts';
|
package/dist/core/types.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./types/activity-verification.js";
|
|
1
2
|
export * from "./types/activity.js";
|
|
2
3
|
export * from "./types/archive-adapter.js";
|
|
3
4
|
export * from "./types/bulk.js";
|
|
@@ -7,6 +8,8 @@ export * from "./types/definition-schema-to-json.js";
|
|
|
7
8
|
export * from "./types/definition-schema.js";
|
|
8
9
|
export * from "./types/history-policy.js";
|
|
9
10
|
export * from "./types/identity.js";
|
|
11
|
+
export * from "./types/launch-metadata.js";
|
|
12
|
+
export * from "./types/list-options.js";
|
|
10
13
|
export * from "./types/message-handles.js";
|
|
11
14
|
export * from "./types/options.js";
|
|
12
15
|
export * from "./types/payload-size-policy.js";
|
|
@@ -15,12 +18,16 @@ export * from "./types/reviews.js";
|
|
|
15
18
|
export * from "./types/schedules.js";
|
|
16
19
|
export * from "./types/search-attributes.js";
|
|
17
20
|
export * from "./types/serializer.js";
|
|
21
|
+
export * from "./types/services-resolution.js";
|
|
18
22
|
export * from "./types/standard-schema-validate.js";
|
|
19
23
|
export * from "./types/state.js";
|
|
20
24
|
export * from "./types/workflow-builder-helpers.js";
|
|
21
25
|
export * from "./types/workflow-builder-runtime.js";
|
|
22
26
|
export * from "./types/workflow-builder.js";
|
|
27
|
+
export * from "./types/workflow-concurrency.js";
|
|
23
28
|
export * from "./types/workflow-context.js";
|
|
24
29
|
export * from "./types/workflow-function.js";
|
|
30
|
+
export * from "./types/workflow-log.js";
|
|
25
31
|
export * from "./types/workflow-registries.js";
|
|
26
32
|
export * from "./types/workflow-registry.js";
|
|
33
|
+
export * from "./types/workflow-snapshot.js";
|
|
@@ -1,62 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Workflow version comparison and checkpoint
|
|
2
|
+
* Workflow version comparison and checkpoint diagnostics.
|
|
3
3
|
*
|
|
4
4
|
* Provides utilities for detecting version mismatches between stored
|
|
5
|
-
* and registered workflow definitions
|
|
6
|
-
* and building atomic batch operations for version updates.
|
|
5
|
+
* and registered workflow definitions.
|
|
7
6
|
*
|
|
8
7
|
* @module versioning
|
|
9
8
|
*/
|
|
10
|
-
import type { BatchOperation } from '../storage/interface.ts';
|
|
11
9
|
import { WeftError } from './weft-error.ts';
|
|
12
10
|
import type { WorkflowVersionDiff } from './workflow-version-tuple.ts';
|
|
13
11
|
/** Default version string assigned when no version is specified. */
|
|
14
12
|
export declare const DEFAULT_WORKFLOW_VERSION = "0.0.0";
|
|
15
|
-
export type VersionCompatibility = 'compatible' | '
|
|
13
|
+
export type VersionCompatibility = 'compatible' | 'incompatible';
|
|
16
14
|
/**
|
|
17
15
|
* Compare a stored workflow version with the currently registered version.
|
|
18
16
|
*
|
|
19
17
|
* - `"compatible"` — versions match; no action needed.
|
|
20
|
-
* - `"
|
|
21
|
-
*
|
|
22
|
-
* will throw a {@link VersionMismatchError} instead of resuming silently.
|
|
18
|
+
* - `"incompatible"` — versions differ; the engine will throw a
|
|
19
|
+
* {@link VersionMismatchError} instead of resuming silently.
|
|
23
20
|
*
|
|
24
21
|
* @example
|
|
25
22
|
* ```ts
|
|
26
23
|
* import { checkVersionCompatibility } from '@lostgradient/weft';
|
|
27
24
|
*
|
|
28
|
-
* console.log(checkVersionCompatibility('1.0.0', '1.0.0'
|
|
29
|
-
* console.log(checkVersionCompatibility('1.0.0', '2.0.0'
|
|
30
|
-
* console.log(checkVersionCompatibility('1.0.0', '2.0.0', false)); // 'incompatible'
|
|
25
|
+
* console.log(checkVersionCompatibility('1.0.0', '1.0.0')); // 'compatible'
|
|
26
|
+
* console.log(checkVersionCompatibility('1.0.0', '2.0.0')); // 'incompatible'
|
|
31
27
|
* ```
|
|
32
28
|
*/
|
|
33
|
-
export declare function checkVersionCompatibility(storedVersion: string, registeredVersion: string
|
|
34
|
-
/**
|
|
35
|
-
* Run a migration function on checkpoint data, transforming it from one
|
|
36
|
-
* version to another.
|
|
37
|
-
*
|
|
38
|
-
* The caller is responsible for serializing the result back to bytes if needed.
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* import { migrateCheckpoint } from '@lostgradient/weft';
|
|
43
|
-
*
|
|
44
|
-
* const oldData = { step: 0, locals: { counter: 1 }, version: '1.0.0' };
|
|
45
|
-
* const migrated = migrateCheckpoint(oldData, '1.0.0', '2.0.0', (data) => {
|
|
46
|
-
* const d = data as typeof oldData;
|
|
47
|
-
* return { ...d, locals: { ...d.locals, newField: 'default' } };
|
|
48
|
-
* });
|
|
49
|
-
* void migrated;
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare function migrateCheckpoint(checkpointData: unknown, fromVersion: string, _toVersion: string, migrate: (checkpoint: unknown, fromVersion: string) => unknown): unknown;
|
|
53
|
-
/**
|
|
54
|
-
* Build batch operations that atomically update the checkpoint and workflow
|
|
55
|
-
* state after a successful migration.
|
|
56
|
-
*
|
|
57
|
-
* The returned operations are suitable for passing to `Storage.batch()`.
|
|
58
|
-
*/
|
|
59
|
-
export declare function buildVersionUpdateOperations(workflowId: string, newCheckpointBytes: Uint8Array, _newVersion: string, workflowStateBytes: Uint8Array): BatchOperation[];
|
|
29
|
+
export declare function checkVersionCompatibility(storedVersion: string, registeredVersion: string): VersionCompatibility;
|
|
60
30
|
/** Description of a single field-level difference between checkpoint shapes. */
|
|
61
31
|
export type FieldDiff = {
|
|
62
32
|
field: string;
|
|
@@ -115,7 +85,7 @@ export type ShapeDiffOptions = {
|
|
|
115
85
|
};
|
|
116
86
|
/**
|
|
117
87
|
* Thrown when a workflow's stored version does not match its registered
|
|
118
|
-
* version
|
|
88
|
+
* version.
|
|
119
89
|
*
|
|
120
90
|
* When shape information is provided, the error message includes a
|
|
121
91
|
* field-level diff describing exactly which fields changed.
|
package/dist/core/versioning.js
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import { KEYS } from "../storage/interface.js";
|
|
2
1
|
import { WeftError } from "./weft-error.js";
|
|
3
2
|
import { formatWorkflowVersionDiff } from "./workflow-version-tuple.js";
|
|
4
3
|
export const DEFAULT_WORKFLOW_VERSION = "0.0.0";
|
|
5
|
-
export function checkVersionCompatibility(storedVersion, registeredVersion
|
|
4
|
+
export function checkVersionCompatibility(storedVersion, registeredVersion) {
|
|
6
5
|
if (storedVersion === registeredVersion)
|
|
7
6
|
return "compatible";
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
export function migrateCheckpoint(checkpointData, fromVersion, _toVersion, migrate) {
|
|
11
|
-
return migrate(checkpointData, fromVersion);
|
|
12
|
-
}
|
|
13
|
-
export function buildVersionUpdateOperations(workflowId, newCheckpointBytes, _newVersion, workflowStateBytes) {
|
|
14
|
-
return [
|
|
15
|
-
{ type: "put", key: KEYS.checkpoint(workflowId), value: newCheckpointBytes },
|
|
16
|
-
{ type: "put", key: KEYS.workflow(workflowId), value: workflowStateBytes }
|
|
17
|
-
];
|
|
7
|
+
return "incompatible";
|
|
18
8
|
}
|
|
19
9
|
export function diffCheckpointShapes(oldShape, newShape) {
|
|
20
10
|
const diffs = [], allKeys = new Set([...Object.keys(oldShape), ...Object.keys(newShape)]);
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
* when an error may have crossed a realm or duplicate-module boundary, where
|
|
10
10
|
* `instanceof` is unreliable.
|
|
11
11
|
*
|
|
12
|
+
* See `documentation/reference/api-errors.md` for the source-complete error
|
|
13
|
+
* code table and usage guidance for the exported guards.
|
|
14
|
+
*
|
|
12
15
|
* @example
|
|
13
16
|
* ```ts
|
|
14
17
|
* import { isWeftErrorLike, type WeftErrorCode } from '@lostgradient/weft';
|
|
@@ -22,7 +25,7 @@
|
|
|
22
25
|
* }
|
|
23
26
|
* ```
|
|
24
27
|
*/
|
|
25
|
-
export type WeftErrorCode = 'WorkflowAlreadyExistsError' | 'BulkDeleteRequiresTerminalWorkflowsError' | 'BulkOperationConfirmationError' | 'WorkflowTypeNotRegisteredForRecoveryError' | 'EngineCreateNameMismatchError' | 'EngineDisposedError' | 'WorkflowNotFoundError' | 'WorkflowNotRegisteredError' | 'ActivityResolutionError' | 'PersistedDataIncompatibleError' | 'WorkflowTimeoutError' | 'HttpClientError' | 'WorkerProtocolIncompatibleError' | 'UpdateTimeoutError' | 'UpdateValidationError' | 'WorkflowTerminalError' | 'WorkflowBuilderError' | 'VersionMismatchError' | 'EffectReplayConflictError' | 'ReviewTimeoutError' | 'AtomicStateConflictError' | 'StandardSchemaValidationError' | 'ActivityReconciliationCapabilityError' | 'ActivityReconciliationConflictError' | 'ActivityReconciliationIndeterminateError' | 'AsyncActivityTokenNotFoundError' | 'PayloadSizeExceededError';
|
|
28
|
+
export type WeftErrorCode = 'WorkflowAlreadyExistsError' | 'BulkDeleteRequiresTerminalWorkflowsError' | 'BulkOperationConfirmationError' | 'WorkflowTypeNotRegisteredForRecoveryError' | 'EngineCreateNameMismatchError' | 'EngineDisposedError' | 'WorkflowNotFoundError' | 'WorkflowNotRegisteredError' | 'WorkflowConcurrencyLimitExceededError' | 'WorkflowSuspendNotSupportedError' | 'ActivityResolutionError' | 'BranchTopologyChangedError' | 'PersistedDataIncompatibleError' | 'WorkflowTimeoutError' | 'HttpClientError' | 'WorkerProtocolIncompatibleError' | 'UpdateTimeoutError' | 'UpdateValidationError' | 'WorkflowTerminalError' | 'WorkflowBuilderError' | 'VersionMismatchError' | 'EffectReplayConflictError' | 'ReviewTimeoutError' | 'AtomicStateConflictError' | 'StandardSchemaValidationError' | 'ActivityReconciliationCapabilityError' | 'ActivityReconciliationConflictError' | 'ActivityReconciliationIndeterminateError' | 'AsyncActivityTokenNotFoundError' | 'ActivityScheduleToCloseTimeoutError' | 'ActivityPerAttemptTimeoutError' | 'PayloadSizeExceededError' | 'StartOrSignalConflictError' | 'IdempotencyKeyPurgedError';
|
|
26
29
|
/**
|
|
27
30
|
* Generic abstract base for all Weft library errors. The `TCode` parameter
|
|
28
31
|
* makes each subclass's `code` its own literal type; the exported base surface
|
|
@@ -55,6 +58,9 @@ export declare abstract class WeftError<TCode extends string = string> extends E
|
|
|
55
58
|
* object structurally. {@link isWeftErrorCode} narrows a bare `code` *string*,
|
|
56
59
|
* not a caught `unknown`.
|
|
57
60
|
*
|
|
61
|
+
* See `documentation/reference/api-errors.md#error-helpers` for guard selection
|
|
62
|
+
* examples across same-realm and cross-boundary errors.
|
|
63
|
+
*
|
|
58
64
|
* @example
|
|
59
65
|
* ```ts
|
|
60
66
|
* import { isWeftError } from '@lostgradient/weft';
|
|
@@ -71,6 +77,9 @@ export declare function isWeftError(value: unknown): value is WeftError;
|
|
|
71
77
|
* a caught `unknown` (the common `catch` case), reach for {@link isWeftErrorLike},
|
|
72
78
|
* which checks the whole error object structurally.
|
|
73
79
|
*
|
|
80
|
+
* See `documentation/reference/api-errors.md#error-helpers` for guard selection
|
|
81
|
+
* examples across same-realm and cross-boundary errors.
|
|
82
|
+
*
|
|
74
83
|
* @example
|
|
75
84
|
* ```ts
|
|
76
85
|
* import { isWeftErrorCode } from '@lostgradient/weft';
|
|
@@ -96,6 +105,9 @@ export declare function isWeftErrorCode(value: unknown): value is WeftErrorCode;
|
|
|
96
105
|
* To match a *specific* code, narrow with this guard then compare `error.code`
|
|
97
106
|
* — TypeScript narrows it to the matched literal in the branch.
|
|
98
107
|
*
|
|
108
|
+
* See `documentation/reference/api-errors.md#error-helpers` for guard selection
|
|
109
|
+
* examples across same-realm and cross-boundary errors.
|
|
110
|
+
*
|
|
99
111
|
* @example
|
|
100
112
|
* ```ts
|
|
101
113
|
* import { isWeftErrorLike } from '@lostgradient/weft';
|
|
@@ -112,3 +124,34 @@ export declare function isWeftErrorLike(value: unknown): value is {
|
|
|
112
124
|
code: WeftErrorCode;
|
|
113
125
|
message: string;
|
|
114
126
|
};
|
|
127
|
+
/**
|
|
128
|
+
* Transport-uniform error classification: `true` when `error` represents the
|
|
129
|
+
* given public {@link WeftErrorCode}, whether it was thrown in process or
|
|
130
|
+
* arrived over HTTP. This is the canonical way to branch on a specific Weft
|
|
131
|
+
* error without caring which transport produced it — the predicate the
|
|
132
|
+
* `WeftClient` "constructor change, not an API change" promise rests on.
|
|
133
|
+
*
|
|
134
|
+
* It matches two shapes with one rule:
|
|
135
|
+
* - An in-process typed error (or any {@link isWeftErrorLike} value) whose
|
|
136
|
+
* `code` equals `code` — what `LocalClient` throws.
|
|
137
|
+
* - An `HttpClientError` carrying `weftCode === code` — what `HttpClient`
|
|
138
|
+
* throws when the REST fault rehydrated the originating public code. The
|
|
139
|
+
* check is structural (`'weftCode' in error`) rather than `instanceof
|
|
140
|
+
* HttpClientError`, both to stay reliable across realm/duplicate-module
|
|
141
|
+
* boundaries and to keep this guard in the core layer without importing the
|
|
142
|
+
* client.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* import { isWeftFault } from '@lostgradient/weft';
|
|
147
|
+
*
|
|
148
|
+
* // The same branch holds over LocalClient and HttpClient: a missing workflow
|
|
149
|
+
* // is a no-op success ("nothing to tell"), not a failure to re-raise.
|
|
150
|
+
* function rethrowUnlessMissing(error: unknown): void {
|
|
151
|
+
* if (!isWeftFault(error, 'WorkflowNotFoundError')) {
|
|
152
|
+
* throw error;
|
|
153
|
+
* }
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export declare function isWeftFault(error: unknown, code: WeftErrorCode): boolean;
|
package/dist/core/weft-error.js
CHANGED
|
@@ -15,7 +15,10 @@ const publicWeftErrorCodeMap = {
|
|
|
15
15
|
EngineDisposedError: !0,
|
|
16
16
|
WorkflowNotFoundError: !0,
|
|
17
17
|
WorkflowNotRegisteredError: !0,
|
|
18
|
+
WorkflowConcurrencyLimitExceededError: !0,
|
|
19
|
+
WorkflowSuspendNotSupportedError: !0,
|
|
18
20
|
ActivityResolutionError: !0,
|
|
21
|
+
BranchTopologyChangedError: !0,
|
|
19
22
|
PersistedDataIncompatibleError: !0,
|
|
20
23
|
WorkflowTimeoutError: !0,
|
|
21
24
|
HttpClientError: !0,
|
|
@@ -33,7 +36,11 @@ const publicWeftErrorCodeMap = {
|
|
|
33
36
|
ActivityReconciliationConflictError: !0,
|
|
34
37
|
ActivityReconciliationIndeterminateError: !0,
|
|
35
38
|
AsyncActivityTokenNotFoundError: !0,
|
|
36
|
-
|
|
39
|
+
ActivityScheduleToCloseTimeoutError: !0,
|
|
40
|
+
ActivityPerAttemptTimeoutError: !0,
|
|
41
|
+
PayloadSizeExceededError: !0,
|
|
42
|
+
StartOrSignalConflictError: !0,
|
|
43
|
+
IdempotencyKeyPurgedError: !0
|
|
37
44
|
}, PUBLIC_WEFT_ERROR_CODES = new Set(Object.keys(publicWeftErrorCodeMap));
|
|
38
45
|
export function isWeftError(value) {
|
|
39
46
|
return value instanceof WeftError;
|
|
@@ -50,3 +57,14 @@ export function isWeftErrorLike(value) {
|
|
|
50
57
|
return !1;
|
|
51
58
|
}
|
|
52
59
|
}
|
|
60
|
+
export function isWeftFault(error, code) {
|
|
61
|
+
if (isWeftErrorLike(error) && error.code === code)
|
|
62
|
+
return !0;
|
|
63
|
+
if (typeof error !== "object" || error === null)
|
|
64
|
+
return !1;
|
|
65
|
+
try {
|
|
66
|
+
return "weftCode" in error && error.weftCode === code;
|
|
67
|
+
} catch {
|
|
68
|
+
return !1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -1,7 +1,33 @@
|
|
|
1
|
+
import type { WorkflowLogRecord } from './types/workflow-log.ts';
|
|
1
2
|
export interface WorkerExecutionStrategyOptions {
|
|
2
3
|
broadcastEvents?: boolean;
|
|
3
4
|
workflowTurnTimeoutMs?: number;
|
|
4
5
|
maxProtocolMessageBytes?: number;
|
|
5
6
|
requireProtocolVersion?: boolean;
|
|
6
7
|
discardOnCancel?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The engine host's `EngineOptions.onLog` sink (#529). When present, the strategy
|
|
10
|
+
* tells each worker (`hostHasLogSink: true` on `run`/`resume`) to forward `ctx.log`
|
|
11
|
+
* records back as `log` protocol messages, which are delivered here instead of the
|
|
12
|
+
* worker console. When absent, workers log to their own console (the default).
|
|
13
|
+
*/
|
|
14
|
+
onLog?: (record: WorkflowLogRecord) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Monotonic-enough wall clock (ms) for the forwarded-log abuse counter's flood
|
|
17
|
+
* window (#545). Injected so tests advance time deterministically; defaults to
|
|
18
|
+
* `Date.now` when omitted (the non-worker-construction path / direct tests).
|
|
19
|
+
*/
|
|
20
|
+
getNow?: () => number;
|
|
21
|
+
/**
|
|
22
|
+
* Internal test seams for the forwarded-log abuse counter (#545). Not a public
|
|
23
|
+
* engine option — the abuse thresholds are deliberately fixed and generous so honest
|
|
24
|
+
* high-log workflows are never discarded. These exist only so unit tests can inject
|
|
25
|
+
* small thresholds (and a controllable window) to exercise the discard paths without
|
|
26
|
+
* sending thousands of messages; each falls back to its worker-protocol default.
|
|
27
|
+
*/
|
|
28
|
+
forwardedLogFloodWindowMs?: number;
|
|
29
|
+
/** See {@link WorkerExecutionStrategyOptions.forwardedLogFloodWindowMs} — internal test seam (#545). */
|
|
30
|
+
forwardedLogFloodThreshold?: number;
|
|
31
|
+
/** See {@link WorkerExecutionStrategyOptions.forwardedLogFloodWindowMs} — internal test seam (#545). */
|
|
32
|
+
forwardedLogStrikeThreshold?: number;
|
|
7
33
|
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { WorkerCheckpointResumeState } from "./worker-checkpoint-resume-state.js";
|
|
2
|
-
import {
|
|
3
|
-
WorkerExecutionDispatcher
|
|
4
|
-
} from "./worker-execution-dispatcher.js";
|
|
2
|
+
import { WorkerExecutionDispatcher } from "./worker-execution-dispatcher.js";
|
|
5
3
|
import { WorkerExecutionOwnership } from "./worker-execution-ownership.js";
|
|
4
|
+
import {
|
|
5
|
+
buildResumeMessage,
|
|
6
|
+
buildRunMessage
|
|
7
|
+
} from "./worker-inbound-message.js";
|
|
6
8
|
import { WorkerListenerRegistry } from "./worker-listener-registry.js";
|
|
9
|
+
import {
|
|
10
|
+
forwardedLogGateFromStrategyOptions
|
|
11
|
+
} from "./worker-log-abuse-counter.js";
|
|
7
12
|
import {
|
|
8
13
|
emitWorkerMessageToEngine,
|
|
9
14
|
isParkableWaitSignalCheckpoint
|
|
10
15
|
} from "./worker-message-helpers.js";
|
|
11
16
|
import { WorkerProtocolGuard } from "./worker-protocol-guard.js";
|
|
17
|
+
import { isWorkerLogMessage } from "./worker-protocol-log.js";
|
|
12
18
|
import { WORKER_PROTOCOL_VERSION } from "./worker-protocol.js";
|
|
13
19
|
import { WorkerTurnWatchdog } from "./worker-turn-watchdog.js";
|
|
14
20
|
|
|
@@ -23,6 +29,7 @@ export class WorkerExecutionStrategy {
|
|
|
23
29
|
#maxProtocolMessageBytes;
|
|
24
30
|
#requireProtocolVersion;
|
|
25
31
|
#discardOnCancel;
|
|
32
|
+
#forwardedLogGate;
|
|
26
33
|
#turnWatchdog;
|
|
27
34
|
#protocolGuard;
|
|
28
35
|
#dispatcher;
|
|
@@ -30,14 +37,22 @@ export class WorkerExecutionStrategy {
|
|
|
30
37
|
#disposed;
|
|
31
38
|
#nextTurnId;
|
|
32
39
|
constructor(pool, options) {
|
|
40
|
+
const {
|
|
41
|
+
workflowTurnTimeoutMs,
|
|
42
|
+
maxProtocolMessageBytes,
|
|
43
|
+
requireProtocolVersion = !1,
|
|
44
|
+
discardOnCancel = !1,
|
|
45
|
+
broadcastEvents = !1
|
|
46
|
+
} = options ?? {};
|
|
33
47
|
this.#pool = pool;
|
|
34
48
|
this.#ownership = new WorkerExecutionOwnership;
|
|
35
49
|
this.#workerListeners = new WorkerListenerRegistry;
|
|
36
50
|
this.#checkpointResumeState = new WorkerCheckpointResumeState;
|
|
37
|
-
this.#workflowTurnTimeoutMs =
|
|
38
|
-
this.#maxProtocolMessageBytes =
|
|
39
|
-
this.#requireProtocolVersion =
|
|
40
|
-
this.#discardOnCancel =
|
|
51
|
+
this.#workflowTurnTimeoutMs = workflowTurnTimeoutMs;
|
|
52
|
+
this.#maxProtocolMessageBytes = maxProtocolMessageBytes;
|
|
53
|
+
this.#requireProtocolVersion = requireProtocolVersion;
|
|
54
|
+
this.#discardOnCancel = discardOnCancel;
|
|
55
|
+
this.#forwardedLogGate = forwardedLogGateFromStrategyOptions(options, maxProtocolMessageBytes);
|
|
41
56
|
this.#turnWatchdog = new WorkerTurnWatchdog(this.#workflowTurnTimeoutMs, (turn) => {
|
|
42
57
|
this.#handleTurnTimeout(turn);
|
|
43
58
|
});
|
|
@@ -72,7 +87,7 @@ export class WorkerExecutionStrategy {
|
|
|
72
87
|
this.#broadcastListener = null;
|
|
73
88
|
this.#disposed = !1;
|
|
74
89
|
this.#nextTurnId = 1;
|
|
75
|
-
if (
|
|
90
|
+
if (broadcastEvents)
|
|
76
91
|
try {
|
|
77
92
|
this.#broadcastChannel = new BroadcastChannel("weft:events");
|
|
78
93
|
this.#broadcastListener = (event) => {
|
|
@@ -87,22 +102,7 @@ export class WorkerExecutionStrategy {
|
|
|
87
102
|
startWorkflow(parameters) {
|
|
88
103
|
this.#ownership.resetWorkflow(parameters.workflowId);
|
|
89
104
|
this.#checkpointResumeState.resetWorkflow(parameters.workflowId);
|
|
90
|
-
const message =
|
|
91
|
-
type: "run",
|
|
92
|
-
protocolVersion: WORKER_PROTOCOL_VERSION,
|
|
93
|
-
turnId: this.#nextTurnId++,
|
|
94
|
-
workflowId: parameters.workflowId,
|
|
95
|
-
workflowType: parameters.workflowType,
|
|
96
|
-
checkpoint: parameters.checkpoint,
|
|
97
|
-
input: parameters.input,
|
|
98
|
-
executionStateOwnerId: parameters.executionStateOwnerId ?? parameters.workflowId
|
|
99
|
-
};
|
|
100
|
-
if (this.#maxProtocolMessageBytes !== void 0)
|
|
101
|
-
message.maxProtocolMessageBytes = this.#maxProtocolMessageBytes;
|
|
102
|
-
if (parameters.deadline !== void 0)
|
|
103
|
-
message.deadline = parameters.deadline;
|
|
104
|
-
if (parameters.headers)
|
|
105
|
-
message.headers = parameters.headers;
|
|
105
|
+
const message = buildRunMessage(parameters, this.#inboundMessageContext());
|
|
106
106
|
if (!this.#assertHostToWorkerMessageWithinLimit(parameters.workflowId, message))
|
|
107
107
|
return;
|
|
108
108
|
this.#dispatcher.acquireAndSend(parameters.workflowId, message);
|
|
@@ -111,12 +111,14 @@ export class WorkerExecutionStrategy {
|
|
|
111
111
|
const worker = this.#ownership.getActiveWorker(parameters.workflowId);
|
|
112
112
|
if (worker) {
|
|
113
113
|
this.#checkpointResumeState.recordResume(parameters.workflowId);
|
|
114
|
-
|
|
114
|
+
const resumeMessage = buildResumeMessage(parameters, this.#inboundMessageContext());
|
|
115
|
+
this.#dispatcher.postResumeMessage(worker, parameters, resumeMessage);
|
|
115
116
|
return;
|
|
116
117
|
}
|
|
117
118
|
const parkedWorker = this.#ownership.getParkedWorker(parameters.workflowId);
|
|
118
119
|
if (parkedWorker) {
|
|
119
|
-
|
|
120
|
+
const resumeMessage = buildResumeMessage(parameters, this.#inboundMessageContext());
|
|
121
|
+
this.#dispatcher.resumeParkedWorkflow(parameters, parkedWorker, resumeMessage);
|
|
120
122
|
return;
|
|
121
123
|
}
|
|
122
124
|
if (this.#ownership.consumeCancelled(parameters.workflowId))
|
|
@@ -128,18 +130,12 @@ export class WorkerExecutionStrategy {
|
|
|
128
130
|
error: `No worker assigned for workflow: ${parameters.workflowId}`
|
|
129
131
|
});
|
|
130
132
|
}
|
|
131
|
-
#
|
|
132
|
-
|
|
133
|
-
type: "resume",
|
|
134
|
-
protocolVersion: WORKER_PROTOCOL_VERSION,
|
|
133
|
+
#inboundMessageContext() {
|
|
134
|
+
return {
|
|
135
135
|
turnId: this.#nextTurnId++,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
operationResult: parameters.operationResult
|
|
136
|
+
maxProtocolMessageBytes: this.#maxProtocolMessageBytes,
|
|
137
|
+
hasLogSink: this.#forwardedLogGate.hasSink
|
|
139
138
|
};
|
|
140
|
-
if (this.#maxProtocolMessageBytes !== void 0)
|
|
141
|
-
message.maxProtocolMessageBytes = this.#maxProtocolMessageBytes;
|
|
142
|
-
return message;
|
|
143
139
|
}
|
|
144
140
|
cancelWorkflow(workflowId) {
|
|
145
141
|
const worker = this.#ownership.getActiveWorker(workflowId);
|
|
@@ -205,6 +201,12 @@ export class WorkerExecutionStrategy {
|
|
|
205
201
|
this.#messageHandler = null;
|
|
206
202
|
}
|
|
207
203
|
async#handleWorkerMessage(worker, message) {
|
|
204
|
+
if (isWorkerLogMessage(message)) {
|
|
205
|
+
const owns = (id) => this.#ownership.getTargetWorker(id) === worker, abuseDiscard = this.#forwardedLogGate.handle(worker, message, owns);
|
|
206
|
+
if (abuseDiscard)
|
|
207
|
+
this.#discardWorkerAndFailWorkflows(worker, abuseDiscard);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
208
210
|
if (!this.#acceptWorkerMessage(worker, message))
|
|
209
211
|
return;
|
|
210
212
|
this.#turnWatchdog.clear(worker);
|
|
@@ -322,6 +324,7 @@ export class WorkerExecutionStrategy {
|
|
|
322
324
|
const workflowIds = this.#ownership.workflowIdsForWorker(worker);
|
|
323
325
|
if (workflowIds.length === 0) {
|
|
324
326
|
this.#turnWatchdog.clear(worker);
|
|
327
|
+
this.#forwardedLogGate.forget(worker);
|
|
325
328
|
return;
|
|
326
329
|
}
|
|
327
330
|
for (const workflowId of workflowIds) {
|
|
@@ -338,6 +341,7 @@ export class WorkerExecutionStrategy {
|
|
|
338
341
|
});
|
|
339
342
|
}
|
|
340
343
|
this.#turnWatchdog.clear(worker);
|
|
344
|
+
this.#forwardedLogGate.forget(worker);
|
|
341
345
|
this.#workerListeners.detach(worker);
|
|
342
346
|
this.#pool.discard(worker);
|
|
343
347
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builders for the `run`/`resume` {@link WorkerInboundMessage} envelopes the
|
|
3
|
+
* {@link import('./worker-execution-strategy.ts').WorkerExecutionStrategy} sends to a
|
|
4
|
+
* worker. Extracted as free functions so the strategy stays under the line cap and the
|
|
5
|
+
* envelope-construction rules (protocol version, turn id, size cap, host-log-sink
|
|
6
|
+
* stamping) live in one place. The strategy keeps ownership of the turn-id counter and
|
|
7
|
+
* the assert-and-send; these functions only assemble the message.
|
|
8
|
+
*
|
|
9
|
+
* @module core/worker-inbound-message
|
|
10
|
+
*/
|
|
11
|
+
import type { OperationOutcome, WorkerInboundMessage } from './types.ts';
|
|
12
|
+
/** The turn-protocol context every inbound message carries, owned by the strategy. */
|
|
13
|
+
export interface WorkerInboundMessageContext {
|
|
14
|
+
turnId: number;
|
|
15
|
+
maxProtocolMessageBytes: number | undefined;
|
|
16
|
+
/** Whether the engine host installed an `onLog` sink; stamps `hostHasLogSink` (#529). */
|
|
17
|
+
hasLogSink: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Build a `run` inbound message from start parameters and the turn context. */
|
|
20
|
+
export declare function buildRunMessage(parameters: {
|
|
21
|
+
workflowId: string;
|
|
22
|
+
workflowType: string;
|
|
23
|
+
input: unknown;
|
|
24
|
+
checkpoint: ArrayBuffer;
|
|
25
|
+
executionStateOwnerId?: string;
|
|
26
|
+
deadline?: number;
|
|
27
|
+
headers?: [string, string][];
|
|
28
|
+
}, context: WorkerInboundMessageContext): WorkerInboundMessage & {
|
|
29
|
+
type: 'run';
|
|
30
|
+
};
|
|
31
|
+
/** Build a `resume` inbound message from resume parameters and the turn context. */
|
|
32
|
+
export declare function buildResumeMessage(parameters: {
|
|
33
|
+
workflowId: string;
|
|
34
|
+
checkpoint: ArrayBuffer;
|
|
35
|
+
operationResult: OperationOutcome;
|
|
36
|
+
}, context: WorkerInboundMessageContext): WorkerInboundMessage & {
|
|
37
|
+
type: 'resume';
|
|
38
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { WORKER_PROTOCOL_VERSION } from "./worker-protocol.js";
|
|
2
|
+
export function buildRunMessage(parameters, context) {
|
|
3
|
+
const message = {
|
|
4
|
+
type: "run",
|
|
5
|
+
protocolVersion: WORKER_PROTOCOL_VERSION,
|
|
6
|
+
turnId: context.turnId,
|
|
7
|
+
workflowId: parameters.workflowId,
|
|
8
|
+
workflowType: parameters.workflowType,
|
|
9
|
+
checkpoint: parameters.checkpoint,
|
|
10
|
+
input: parameters.input,
|
|
11
|
+
executionStateOwnerId: parameters.executionStateOwnerId ?? parameters.workflowId
|
|
12
|
+
};
|
|
13
|
+
if (context.maxProtocolMessageBytes !== void 0)
|
|
14
|
+
message.maxProtocolMessageBytes = context.maxProtocolMessageBytes;
|
|
15
|
+
if (parameters.deadline !== void 0)
|
|
16
|
+
message.deadline = parameters.deadline;
|
|
17
|
+
if (parameters.headers)
|
|
18
|
+
message.headers = parameters.headers;
|
|
19
|
+
if (context.hasLogSink)
|
|
20
|
+
message.hostHasLogSink = !0;
|
|
21
|
+
return message;
|
|
22
|
+
}
|
|
23
|
+
export function buildResumeMessage(parameters, context) {
|
|
24
|
+
const message = {
|
|
25
|
+
type: "resume",
|
|
26
|
+
protocolVersion: WORKER_PROTOCOL_VERSION,
|
|
27
|
+
turnId: context.turnId,
|
|
28
|
+
workflowId: parameters.workflowId,
|
|
29
|
+
checkpoint: parameters.checkpoint,
|
|
30
|
+
operationResult: parameters.operationResult
|
|
31
|
+
};
|
|
32
|
+
if (context.maxProtocolMessageBytes !== void 0)
|
|
33
|
+
message.maxProtocolMessageBytes = context.maxProtocolMessageBytes;
|
|
34
|
+
if (context.hasLogSink)
|
|
35
|
+
message.hostHasLogSink = !0;
|
|
36
|
+
return message;
|
|
37
|
+
}
|