@lostgradient/weft 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -24
- package/dist/cli/conformance.js +7 -1
- package/dist/cli/generated/operation-client.generated.d.ts +28 -13
- package/dist/cli/generated/operation-client.generated.js +1 -0
- package/dist/cli/help-text.d.ts +1 -1
- package/dist/cli/help-text.js +1 -0
- package/dist/cli/operation-catalog-snapshot.d.ts +8 -0
- package/dist/cli/operation-catalog-snapshot.js +11 -0
- package/dist/cli/parse-schedule-arguments.js +3 -1
- package/dist/cli/schedule.js +2 -1
- package/dist/cli/types.d.ts +1 -0
- package/dist/cli-main.js +79 -78
- package/dist/client/handle-delegation.d.ts +3 -2
- package/dist/client/handle-delegation.js +3 -1
- package/dist/client/http-client-requests.d.ts +2 -1
- package/dist/client/http-client-requests.js +7 -0
- package/dist/client/http-client.d.ts +9 -6
- package/dist/client/http-client.js +10 -1
- package/dist/client/http-request.d.ts +11 -1
- package/dist/client/http-request.js +17 -7
- package/dist/client/index.d.ts +1 -1
- package/dist/client/interface.d.ts +61 -5
- package/dist/client/local-handles.d.ts +22 -0
- package/dist/client/local-handles.js +23 -0
- package/dist/client/local.d.ts +6 -3
- package/dist/client/local.js +12 -26
- package/dist/client/start-body.d.ts +4 -3
- package/dist/core/byte-arrays.d.ts +5 -0
- package/dist/core/byte-arrays.js +5 -0
- package/dist/core/checkpoint/lifecycle.d.ts +3 -0
- package/dist/core/checkpoint/lifecycle.js +9 -4
- package/dist/core/checkpoint/serialization.js +12 -5
- package/dist/core/codec/extension-codec.d.ts +16 -0
- package/dist/core/codec/extension-codec.js +100 -6
- package/dist/core/context/activity-retry-state.d.ts +38 -0
- package/dist/core/context/activity-retry-state.js +89 -0
- package/dist/core/context/activity-schedule-to-close.d.ts +159 -0
- package/dist/core/context/activity-schedule-to-close.js +69 -0
- package/dist/core/context/child-workflow-pipe.d.ts +5 -5
- package/dist/core/context/child-workflow-pipe.js +15 -2
- package/dist/core/context/context-presence.d.ts +19 -0
- package/dist/core/context/context-presence.js +13 -0
- package/dist/core/context/durable-operations.d.ts +25 -0
- package/dist/core/context/durable-operations.js +64 -0
- package/dist/core/context/index.d.ts +9 -5
- package/dist/core/context/index.js +17 -12
- package/dist/core/context/internals.d.ts +20 -0
- package/dist/core/context/internals.js +3 -1
- package/dist/core/context/operation-request.d.ts +35 -0
- package/dist/core/context/parallel-cache-entry.d.ts +14 -5
- package/dist/core/context/run-operation.d.ts +6 -1
- package/dist/core/context/run-operation.js +41 -87
- package/dist/core/context/session-state.js +7 -8
- package/dist/core/context/speculative-child.js +2 -0
- package/dist/core/context/types.d.ts +15 -0
- package/dist/core/context/version-patching.d.ts +8 -0
- package/dist/core/context/version-patching.js +40 -0
- package/dist/core/context/workflow-logger.d.ts +98 -0
- package/dist/core/context/workflow-logger.js +68 -0
- package/dist/core/engine/activity-heartbeat-tracking.d.ts +64 -0
- package/dist/core/engine/activity-heartbeat-tracking.js +42 -0
- package/dist/core/engine/activity-per-attempt-timeout.d.ts +46 -0
- package/dist/core/engine/activity-per-attempt-timeout.js +36 -0
- package/dist/core/engine/activity-reconciliation.d.ts +1 -0
- package/dist/core/engine/activity-reconciliation.js +12 -1
- package/dist/core/engine/activity-resolution.d.ts +23 -0
- package/dist/core/engine/activity-resolution.js +37 -0
- package/dist/core/engine/aggregate.js +66 -30
- package/dist/core/engine/async-activity-completion.d.ts +23 -6
- package/dist/core/engine/async-activity-completion.js +53 -12
- package/dist/core/engine/attributes-tags.js +9 -4
- package/dist/core/engine/bulk-operations-purge.d.ts +26 -0
- package/dist/core/engine/bulk-operations-purge.js +38 -3
- package/dist/core/engine/bulk-operations-shared.d.ts +2 -0
- package/dist/core/engine/bulk-operations-shared.js +8 -2
- package/dist/core/engine/bulk-operations.d.ts +4 -1
- package/dist/core/engine/bulk-operations.js +235 -24
- package/dist/core/engine/callback-creators-bundles.d.ts +9 -0
- package/dist/core/engine/callback-creators-bundles.js +30 -2
- package/dist/core/engine/callback-creators-core.js +6 -4
- package/dist/core/engine/callback-creators-router.js +10 -0
- package/dist/core/engine/callback-creators-schedule.d.ts +2 -2
- package/dist/core/engine/callback-creators-schedule.js +12 -8
- package/dist/core/engine/candidate-read-batching.d.ts +6 -0
- package/dist/core/engine/candidate-read-batching.js +1 -0
- package/dist/core/engine/checkpoint-io.js +61 -25
- package/dist/core/engine/checkpoint-reads.js +3 -2
- package/dist/core/engine/checkpoint-replay.d.ts +20 -0
- package/dist/core/engine/checkpoint-replay.js +242 -0
- package/dist/core/engine/checkpoint-side-effects.d.ts +23 -0
- package/dist/core/engine/checkpoint-side-effects.js +35 -0
- package/dist/core/engine/child-workflow-cancellation.d.ts +10 -0
- package/dist/core/engine/child-workflow-cancellation.js +40 -0
- package/dist/core/engine/child-workflow.js +27 -4
- package/dist/core/engine/condition-waiters.d.ts +14 -0
- package/dist/core/engine/condition-waiters.js +5 -0
- package/dist/core/engine/construction.d.ts +3 -0
- package/dist/core/engine/construction.js +21 -8
- package/dist/core/engine/coordination-branch-executors.d.ts +70 -0
- package/dist/core/engine/coordination-branch-executors.js +107 -0
- package/dist/core/engine/deferred-consume-envelope.d.ts +59 -0
- package/dist/core/engine/deferred-consume-envelope.js +14 -0
- package/dist/core/engine/disposal.js +13 -0
- package/dist/core/engine/engine-create-types.d.ts +14 -4
- package/dist/core/engine/engine-internal-types.d.ts +26 -3
- package/dist/core/engine/errors.d.ts +47 -0
- package/dist/core/engine/errors.js +20 -0
- package/dist/core/engine/event-log-compaction.d.ts +8 -0
- package/dist/core/engine/event-log-compaction.js +20 -2
- package/dist/core/engine/fenced-write.d.ts +65 -0
- package/dist/core/engine/fenced-write.js +71 -0
- package/dist/core/engine/finalizer-state.d.ts +28 -0
- package/dist/core/engine/finalizer-state.js +16 -0
- package/dist/core/engine/handles.d.ts +8 -0
- package/dist/core/engine/index.d.ts +34 -16
- package/dist/core/engine/index.js +136 -9
- package/dist/core/engine/inline-parking.js +3 -2
- package/dist/core/engine/internals.d.ts +107 -3
- package/dist/core/engine/lease-codec.d.ts +35 -0
- package/dist/core/engine/lease-codec.js +32 -0
- package/dist/core/engine/lease-deposition.d.ts +66 -0
- package/dist/core/engine/lease-deposition.js +10 -0
- package/dist/core/engine/lease-errors.d.ts +99 -0
- package/dist/core/engine/lease-errors.js +30 -0
- package/dist/core/engine/lease-manager.d.ts +114 -0
- package/dist/core/engine/lease-manager.js +135 -0
- package/dist/core/engine/lifecycle/persist.js +10 -32
- package/dist/core/engine/lifecycle/recovered-services.d.ts +8 -6
- package/dist/core/engine/lifecycle/recovered-services.js +18 -3
- package/dist/core/engine/lifecycle/resume.js +16 -9
- package/dist/core/engine/lifecycle/shared.d.ts +8 -1
- package/dist/core/engine/lifecycle/start-batch.d.ts +1 -1
- package/dist/core/engine/lifecycle/start-batch.js +2 -1
- package/dist/core/engine/lifecycle/start-commit.d.ts +9 -0
- package/dist/core/engine/lifecycle/start-commit.js +50 -8
- package/dist/core/engine/lifecycle/start-or-signal-create.d.ts +58 -0
- package/dist/core/engine/lifecycle/start-or-signal-create.js +95 -0
- package/dist/core/engine/lifecycle/start-or-signal.d.ts +3 -2
- package/dist/core/engine/lifecycle/start-or-signal.js +11 -81
- package/dist/core/engine/lifecycle/start-terminal-conflict-purge.d.ts +39 -0
- package/dist/core/engine/lifecycle/start-terminal-conflict-purge.js +28 -0
- package/dist/core/engine/lifecycle/start.d.ts +4 -4
- package/dist/core/engine/lifecycle/start.js +17 -9
- package/dist/core/engine/lifecycle/transition.js +17 -5
- package/dist/core/engine/lifecycle.d.ts +1 -1
- package/dist/core/engine/list-candidate-resolution.js +2 -2
- package/dist/core/engine/listing.js +9 -5
- package/dist/core/engine/operations-activity.d.ts +6 -13
- package/dist/core/engine/operations-activity.js +26 -53
- package/dist/core/engine/operations-coordination.d.ts +10 -0
- package/dist/core/engine/operations-coordination.js +44 -9
- package/dist/core/engine/operations-router.d.ts +6 -0
- package/dist/core/engine/operations-router.js +2 -0
- package/dist/core/engine/operations-speculate.js +6 -2
- package/dist/core/engine/operations-stream.js +12 -2
- package/dist/core/engine/operations-time.d.ts +4 -2
- package/dist/core/engine/operations-time.js +14 -2
- package/dist/core/engine/operations-wait-condition.d.ts +23 -0
- package/dist/core/engine/operations-wait-condition.js +62 -0
- package/dist/core/engine/ownership-options.d.ts +23 -0
- package/dist/core/engine/ownership-options.js +26 -0
- package/dist/core/engine/payload-size-policy.d.ts +3 -0
- package/dist/core/engine/payload-size-policy.js +4 -0
- package/dist/core/engine/pending-updates.d.ts +17 -0
- package/dist/core/engine/pending-updates.js +33 -11
- package/dist/core/engine/queries.js +1 -1
- package/dist/core/engine/registration.d.ts +1 -0
- package/dist/core/engine/registration.js +18 -3
- package/dist/core/engine/schedule-jitter.d.ts +5 -0
- package/dist/core/engine/schedule-jitter.js +10 -0
- package/dist/core/engine/schedule-run.d.ts +17 -0
- package/dist/core/engine/schedule-run.js +38 -0
- package/dist/core/engine/schedule-timer.js +81 -17
- package/dist/core/engine/schedules.d.ts +7 -4
- package/dist/core/engine/schedules.js +37 -16
- package/dist/core/engine/search-attribute-records.d.ts +4 -0
- package/dist/core/engine/search-attribute-records.js +17 -0
- package/dist/core/engine/signals.d.ts +18 -2
- package/dist/core/engine/signals.js +42 -21
- package/dist/core/engine/state-utilities.d.ts +49 -2
- package/dist/core/engine/state-utilities.js +114 -3
- package/dist/core/engine/storage-io.d.ts +16 -2
- package/dist/core/engine/storage-io.js +26 -5
- package/dist/core/engine/stream-chunk-loading.d.ts +2 -0
- package/dist/core/engine/stream-chunk-loading.js +24 -1
- package/dist/core/engine/sub-operation.js +25 -6
- package/dist/core/engine/termination/cleanup.d.ts +3 -1
- package/dist/core/engine/termination/cleanup.js +25 -1
- package/dist/core/engine/termination/complete.js +44 -6
- package/dist/core/engine/termination/finalizer-activity.d.ts +53 -0
- package/dist/core/engine/termination/finalizer-activity.js +30 -0
- package/dist/core/engine/termination/finalizer-claim.d.ts +110 -0
- package/dist/core/engine/termination/finalizer-claim.js +80 -0
- package/dist/core/engine/termination/finalizer.d.ts +48 -0
- package/dist/core/engine/termination/finalizer.js +159 -0
- package/dist/core/engine/termination/suspend.d.ts +3 -1
- package/dist/core/engine/termination.d.ts +1 -0
- package/dist/core/engine/termination.js +4 -0
- package/dist/core/engine/updates.js +5 -25
- package/dist/core/engine/validation/schedule.d.ts +2 -1
- package/dist/core/engine/validation/schedule.js +51 -2
- package/dist/core/engine/validation.js +32 -5
- package/dist/core/engine/waiting-update-response.d.ts +8 -0
- package/dist/core/engine/waiting-update-response.js +22 -0
- package/dist/core/engine/workflow-concurrency.d.ts +10 -0
- package/dist/core/engine/workflow-concurrency.js +136 -0
- package/dist/core/engine/workflow-feed.d.ts +4 -5
- package/dist/core/engine/workflow-feed.js +4 -1
- package/dist/core/engine/workflow-indexes.d.ts +9 -0
- package/dist/core/engine/workflow-indexes.js +10 -0
- package/dist/core/engine/workflow-state-stream.js +33 -13
- package/dist/core/engine/workflow-visibility-queries.d.ts +2 -2
- package/dist/core/engine-helpers.js +1 -0
- package/dist/core/events/activity-events.d.ts +43 -12
- package/dist/core/events/activity-events.js +28 -0
- package/dist/core/events/attribute-events.d.ts +2 -3
- package/dist/core/events/event-map.d.ts +18 -12
- package/dist/core/events/index.d.ts +1 -0
- package/dist/core/events/index.js +1 -0
- package/dist/core/events/schedule-events.d.ts +71 -0
- package/dist/core/events/schedule-events.js +29 -0
- package/dist/core/events/signal-events.d.ts +4 -6
- package/dist/core/events/system-events.d.ts +29 -19
- package/dist/core/events/system-events.js +26 -0
- package/dist/core/events/update-events.d.ts +6 -8
- package/dist/core/events/workflow-events.d.ts +88 -23
- package/dist/core/events/workflow-events.js +26 -0
- package/dist/core/failure-categories.js +5 -17
- package/dist/core/fault-code.d.ts +9 -3
- package/dist/core/fault-code.js +1 -0
- package/dist/core/inline-execution-strategy.context-options.d.ts +69 -0
- package/dist/core/inline-execution-strategy.context-options.js +56 -0
- package/dist/core/inline-execution-strategy.d.ts +31 -36
- package/dist/core/inline-execution-strategy.js +16 -27
- package/dist/core/list-filter-validation.d.ts +1 -1
- package/dist/core/payload-size.d.ts +1 -1
- package/dist/core/persisted-data-incompatible-error.d.ts +9 -7
- package/dist/core/review/events.d.ts +6 -8
- package/dist/core/scheduler/scheduler-class.d.ts +10 -1
- package/dist/core/scheduler/scheduler-class.js +38 -11
- package/dist/core/scheduler/timer-batch.js +9 -1
- package/dist/core/scheduler/timer-sources.d.ts +1 -0
- package/dist/core/scheduler/timer-sources.js +11 -5
- package/dist/core/session-state.d.ts +0 -1
- package/dist/core/session-state.js +2 -2
- package/dist/core/start-workflow-validation.d.ts +34 -0
- package/dist/core/start-workflow-validation.js +19 -0
- package/dist/core/types/activity-verification.d.ts +67 -0
- package/dist/core/types/activity-verification.js +0 -0
- package/dist/core/types/activity.d.ts +80 -61
- package/dist/core/types/bulk.d.ts +50 -9
- package/dist/core/types/checkpoint.d.ts +44 -8
- package/dist/core/types/list-options.d.ts +146 -0
- package/dist/core/types/list-options.js +0 -0
- package/dist/core/types/options.d.ts +121 -165
- package/dist/core/types/schedules.d.ts +39 -3
- package/dist/core/types/services-resolution.d.ts +2 -2
- package/dist/core/types/workflow-builder-runtime.d.ts +12 -3
- package/dist/core/types/workflow-builder-runtime.js +11 -2
- package/dist/core/types/workflow-builder.d.ts +42 -11
- package/dist/core/types/workflow-concurrency.d.ts +39 -0
- package/dist/core/types/workflow-concurrency.js +0 -0
- package/dist/core/types/workflow-context.d.ts +157 -14
- package/dist/core/types/workflow-definition.d.ts +53 -10
- package/dist/core/types/workflow-function.d.ts +84 -9
- package/dist/core/types/workflow-log.d.ts +98 -0
- package/dist/core/types/workflow-log.js +0 -0
- package/dist/core/types/workflow-registries.d.ts +14 -3
- package/dist/core/types/workflow-registry.d.ts +3 -0
- package/dist/core/types.d.ts +4 -0
- package/dist/core/types.js +4 -0
- package/dist/core/versioning.d.ts +9 -39
- package/dist/core/versioning.js +2 -12
- package/dist/core/weft-error.d.ts +44 -1
- package/dist/core/weft-error.js +16 -0
- package/dist/core/worker-execution-strategy-options.d.ts +26 -0
- package/dist/core/worker-execution-strategy.js +40 -36
- package/dist/core/worker-inbound-message.d.ts +38 -0
- package/dist/core/worker-inbound-message.js +37 -0
- package/dist/core/worker-log-abuse-counter.d.ts +175 -0
- package/dist/core/worker-log-abuse-counter.js +107 -0
- package/dist/core/worker-message-helpers.d.ts +47 -0
- package/dist/core/worker-message-helpers.js +26 -0
- package/dist/core/worker-protocol-guard.js +1 -1
- package/dist/core/worker-protocol-log.d.ts +56 -0
- package/dist/core/worker-protocol-log.js +18 -0
- package/dist/core/worker-protocol.d.ts +23 -0
- package/dist/core/worker-protocol.js +12 -2
- package/dist/core/workflow-version-tuple.d.ts +3 -9
- package/dist/core/workflow-version-tuple.js +2 -3
- package/dist/diagnostics/format.js +1 -6
- package/dist/diagnostics/types.d.ts +4 -5
- package/dist/diagnostics/validate.d.ts +0 -1
- package/dist/diagnostics/version-check.d.ts +1 -1
- package/dist/diagnostics/version-check.js +4 -9
- package/dist/index.d.ts +12 -10
- package/dist/index.js +29 -3
- package/dist/json-schema.js +3 -3
- package/dist/mcp/cli.js +19 -19
- package/dist/mcp/dispatcher.js +1 -1
- package/dist/mcp/http.js +16 -6
- package/dist/mcp/protocol.d.ts +2 -0
- package/dist/mcp/protocol.js +1 -1
- package/dist/mcp/session.d.ts +16 -0
- package/dist/mcp/session.js +59 -6
- package/dist/mcp/tools.js +73 -6
- package/dist/observability/index.js +2 -2
- package/dist/server/asyncapi-channels.js +5 -2
- package/dist/server/attribute-filters.d.ts +8 -3
- package/dist/server/attribute-filters.js +6 -1
- package/dist/server/authentication/api-key.d.ts +2 -1
- package/dist/server/authentication/api-key.js +5 -2
- package/dist/server/authentication/constant-time-api-key.d.ts +15 -0
- package/dist/server/authentication/constant-time-api-key.js +24 -0
- package/dist/server/authentication/index.d.ts +1 -1
- package/dist/server/authentication/index.js +7 -4
- package/dist/server/authentication/rotating-api-key-store.d.ts +5 -3
- package/dist/server/authentication/rotating-api-key-store.js +19 -11
- package/dist/server/engine-event-feed-backend.d.ts +4 -5
- package/dist/server/fault-to-http.js +8 -1
- package/dist/server/fault-to-json-rpc.js +1 -0
- package/dist/server/fleet-event-feed.d.ts +31 -0
- package/dist/server/fleet-event-feed.js +157 -0
- package/dist/server/handler/index.js +1 -1
- package/dist/server/handler/response-helpers.js +2 -1
- package/dist/server/handler/route-dispatch.d.ts +6 -3
- package/dist/server/handler/route-dispatch.js +2 -2
- package/dist/server/handler.js +23 -23
- package/dist/server/index.d.ts +32 -2
- package/dist/server/index.js +32 -32
- package/dist/server/json-rpc-transport-helpers.d.ts +1 -0
- package/dist/server/json-rpc-transport-helpers.js +2 -1
- package/dist/server/json-rpc-websocket-runtime.d.ts +11 -2
- package/dist/server/json-rpc-websocket-runtime.js +1 -0
- package/dist/server/json-rpc-websocket-subscriptions.d.ts +10 -0
- package/dist/server/json-rpc-websocket-subscriptions.js +29 -0
- package/dist/server/json-rpc-websocket-types.d.ts +22 -0
- package/dist/server/json-rpc-websocket-types.js +0 -0
- package/dist/server/json-rpc-websocket-validation.js +20 -4
- package/dist/server/json-rpc-websocket.d.ts +2 -43
- package/dist/server/json-rpc-websocket.js +57 -74
- package/dist/server/openapi.d.ts +2 -1
- package/dist/server/openapi.js +1 -3
- package/dist/server/openrpc-document-schema.d.ts +78 -0
- package/dist/server/openrpc-document-schema.js +27 -1
- package/dist/server/openrpc-errors.d.ts +3 -0
- package/dist/server/openrpc-errors.js +2 -1
- package/dist/server/openrpc.js +32 -0
- package/dist/server/operation-catalog/index.d.ts +1 -1
- package/dist/server/operation-catalog/pipeline-helpers.js +1 -0
- package/dist/server/operation-catalog/pipeline-stages.js +26 -12
- package/dist/server/operation-catalog/pipeline.js +8 -1
- package/dist/server/operation-catalog/registry.js +13 -0
- package/dist/server/operation-catalog/types.d.ts +20 -9
- package/dist/server/operation-fault.d.ts +10 -0
- package/dist/server/operation-fault.js +2 -0
- package/dist/server/operation-registry.d.ts +12 -11
- package/dist/server/operation-registry.js +12 -3
- package/dist/server/operations/aggregate-workflows.d.ts +15 -15
- package/dist/server/operations/async-activity.d.ts +2 -2
- package/dist/server/operations/async-activity.js +12 -7
- package/dist/server/operations/bulk-cancel-workflows.d.ts +1 -1
- package/dist/server/operations/bulk-cancel-workflows.js +2 -2
- package/dist/server/operations/bulk-delete-workflows.d.ts +1 -1
- package/dist/server/operations/bulk-delete-workflows.js +2 -2
- package/dist/server/operations/bulk-filter-helpers.d.ts +8 -6
- package/dist/server/operations/bulk-filter-helpers.js +54 -24
- package/dist/server/operations/bulk-mutate-workflow-tags.d.ts +11 -9
- package/dist/server/operations/bulk-mutate-workflow-tags.js +2 -2
- package/dist/server/operations/bulk-operation-helpers.d.ts +2 -2
- package/dist/server/operations/bulk-retry-failed-workflows.d.ts +7 -0
- package/dist/server/operations/bulk-retry-failed-workflows.js +64 -0
- package/dist/server/operations/bulk-signal-workflows.d.ts +11 -9
- package/dist/server/operations/bulk-signal-workflows.js +2 -2
- package/dist/server/operations/cancel-schedule.d.ts +1 -1
- package/dist/server/operations/create-schedule.d.ts +3 -1
- package/dist/server/operations/create-schedule.js +29 -11
- package/dist/server/operations/fleet-events-subscription.d.ts +54 -0
- package/dist/server/operations/fleet-events-subscription.js +99 -0
- package/dist/server/operations/fork-workflow.d.ts +1 -1
- package/dist/server/operations/fork-workflow.js +3 -2
- package/dist/server/operations/get-checkpoint-at.d.ts +1 -1
- package/dist/server/operations/get-registry.d.ts +1 -1
- package/dist/server/operations/get-retention-overview.d.ts +1 -1
- package/dist/server/operations/get-review.d.ts +1 -1
- package/dist/server/operations/get-schedule.d.ts +1 -1
- package/dist/server/operations/get-stream-chunks.d.ts +1 -1
- package/dist/server/operations/get-system-metrics.d.ts +2 -2
- package/dist/server/operations/get-task-diagnostics.d.ts +45 -6
- package/dist/server/operations/get-task-diagnostics.js +101 -7
- package/dist/server/operations/get-update-result.d.ts +1 -1
- package/dist/server/operations/get-workflow-attributes.d.ts +1 -1
- package/dist/server/operations/get-workflow-events.d.ts +1 -1
- package/dist/server/operations/get-workflow-result.d.ts +1 -1
- package/dist/server/operations/get-workflow-timeline.d.ts +1 -1
- package/dist/server/operations/get-workflow.d.ts +1 -1
- package/dist/server/operations/list-checkpoints.d.ts +1 -1
- package/dist/server/operations/list-reviews.d.ts +1 -1
- package/dist/server/operations/list-schedules.d.ts +1 -1
- package/dist/server/operations/list-task-queues.d.ts +2 -2
- package/dist/server/operations/list-workers.d.ts +2 -2
- package/dist/server/operations/list-workflows.d.ts +1 -1
- package/dist/server/operations/operation-helpers.d.ts +16 -1
- package/dist/server/operations/operation-helpers.js +15 -3
- package/dist/server/operations/pause-schedule.d.ts +1 -1
- package/dist/server/operations/purge-workflows.d.ts +5 -5
- package/dist/server/operations/purge-workflows.js +2 -2
- package/dist/server/operations/query-workflow.d.ts +1 -1
- package/dist/server/operations/query-workflow.js +3 -2
- package/dist/server/operations/recover-all.d.ts +1 -1
- package/dist/server/operations/replay-workflow.d.ts +1 -1
- package/dist/server/operations/resume-schedule.d.ts +1 -1
- package/dist/server/operations/set-workflow-attributes.d.ts +1 -1
- package/dist/server/operations/set-workflow-attributes.js +6 -3
- package/dist/server/operations/signal-workflow.js +8 -3
- package/dist/server/operations/single-workflow-tag-mutation.js +13 -3
- package/dist/server/operations/start-or-signal-workflow.d.ts +6 -1
- package/dist/server/operations/start-or-signal-workflow.js +14 -24
- package/dist/server/operations/start-workflow-options.d.ts +6 -0
- package/dist/server/operations/start-workflow-rest-input.d.ts +14 -0
- package/dist/server/operations/start-workflow-rest-input.js +31 -0
- package/dist/server/operations/start-workflow.d.ts +1 -1
- package/dist/server/operations/start-workflow.js +8 -23
- package/dist/server/operations/storage.d.ts +6 -6
- package/dist/server/operations/storage.js +24 -14
- package/dist/server/operations/stream-workflow-sse.d.ts +1 -1
- package/dist/server/operations/submit-review-decision.d.ts +1 -1
- package/dist/server/operations/submit-review-decision.js +6 -3
- package/dist/server/operations/update-schedule.d.ts +1 -1
- package/dist/server/operations/update-schedule.js +7 -4
- package/dist/server/operations/update-workflow.d.ts +1 -1
- package/dist/server/operations/update-workflow.js +7 -3
- package/dist/server/operations/worker-drain.d.ts +8 -8
- package/dist/server/operations/worker-drain.js +11 -8
- package/dist/server/operations/workflow-events-subscription.d.ts +7 -8
- package/dist/server/operations/workflow-events-subscription.js +43 -8
- package/dist/server/rest-binding.d.ts +3 -1
- package/dist/server/rest-bindings.js +12 -0
- package/dist/server/rest-body.d.ts +10 -0
- package/dist/server/rest-body.js +80 -0
- package/dist/server/runtime/authentication-bridge.d.ts +1 -0
- package/dist/server/runtime/authentication-bridge.js +33 -6
- package/dist/server/runtime/client-visible-events.d.ts +3 -0
- package/dist/server/runtime/client-visible-events.js +65 -0
- package/dist/server/runtime/context.d.ts +7 -0
- package/dist/server/runtime/event-broadcasting.d.ts +6 -0
- package/dist/server/runtime/event-broadcasting.js +72 -38
- package/dist/server/runtime/retry.d.ts +1 -0
- package/dist/server/runtime/retry.js +14 -0
- package/dist/server/runtime/shutdown.d.ts +7 -6
- package/dist/server/runtime/shutdown.js +6 -1
- package/dist/server/runtime/task-polling.js +61 -20
- package/dist/server/runtime/task-reconciliation.js +9 -1
- package/dist/server/runtime/task-result-resolution.d.ts +15 -0
- package/dist/server/runtime/task-result-resolution.js +81 -0
- package/dist/server/runtime/websocket-stream.d.ts +20 -1
- package/dist/server/runtime/websocket-stream.js +173 -7
- package/dist/server/runtime/websocket-upgrade.js +22 -3
- package/dist/server/runtime/websocket-worker.d.ts +1 -1
- package/dist/server/runtime/websocket-worker.js +38 -30
- package/dist/server/serve-internals.d.ts +3 -1
- package/dist/server/serve-internals.js +18 -2
- package/dist/server/task-state.d.ts +30 -0
- package/dist/server/task-state.js +28 -0
- package/dist/server/workflow-event-feed.d.ts +36 -115
- package/dist/server/workflow-event-feed.js +92 -27
- package/dist/service-worker/index.js +30 -30
- package/dist/storage/auto.js +1 -1
- package/dist/storage/bun-sql.js +24 -0
- package/dist/storage/compressed-storage.js +1 -1
- package/dist/storage/default-scope.d.ts +7 -4
- package/dist/storage/http.js +2 -2
- package/dist/storage/index.d.ts +76 -4
- package/dist/storage/indexeddb.js +1 -1
- package/dist/storage/interface.d.ts +163 -0
- package/dist/storage/interface.js +1 -1
- package/dist/storage/key-prefixes.d.ts +1 -1
- package/dist/storage/key-prefixes.js +10 -0
- package/dist/storage/lmdb.d.ts +4 -3
- package/dist/storage/lmdb.js +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/neon-batch.d.ts +30 -0
- package/dist/storage/neon-batch.js +30 -0
- package/dist/storage/neon-value-mapping.d.ts +30 -3
- package/dist/storage/neon-value-mapping.js +12 -0
- package/dist/storage/neon.d.ts +16 -0
- package/dist/storage/neon.js +9 -4
- package/dist/storage/node-sqlite.js +23 -0
- package/dist/storage/postgres-key-value-queries.d.ts +69 -44
- package/dist/storage/postgres-key-value-queries.js +62 -24
- package/dist/storage/resolve.js +1 -1
- package/dist/storage/scoped-storage.js +1 -1
- package/dist/storage/testing.d.ts +168 -0
- package/dist/storage/testing.js +2 -0
- package/dist/storage/turso.d.ts +8 -0
- package/dist/storage/turso.js +2 -2
- package/dist/storage/typed-storage.js +1 -1
- package/dist/storage/web-extension.js +1 -1
- package/dist/testing/index.js +20 -20
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/protocol.js +1 -1
- package/dist/workers/worker-replay-state.d.ts +32 -0
- package/dist/workers/worker-replay-state.js +35 -0
- package/dist/workers/worker-state-namespace.d.ts +21 -0
- package/dist/workers/worker-state-namespace.js +13 -0
- package/dist/workers/workflow-runner.d.ts +19 -15
- package/dist/workers/workflow-runner.js +72 -60
- package/dist/workers/workflow-worker-entry.js +5 -2
- package/package.json +5 -1
|
@@ -10,7 +10,8 @@ export async function handleJsonRpcHttpRequestSafely(args) {
|
|
|
10
10
|
return await handleJsonRpcHttpRequest(args.request, {
|
|
11
11
|
registry: args.registry,
|
|
12
12
|
engine: args.engine,
|
|
13
|
-
principal: authContextToPrincipal(args.authContext)
|
|
13
|
+
principal: authContextToPrincipal(args.authContext),
|
|
14
|
+
...args.maxBodyBytes !== void 0 ? { maxBodyBytes: args.maxBodyBytes } : {}
|
|
14
15
|
});
|
|
15
16
|
} catch (error) {
|
|
16
17
|
console.error("Unhandled error in /jsonrpc", { error });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ServerWebSocket } from 'bun';
|
|
2
|
+
import type { FleetEventFeed } from './fleet-event-feed.ts';
|
|
2
3
|
import { type JsonRpcWebSocketSession } from './json-rpc-websocket.ts';
|
|
3
4
|
import type { OperationRegistry } from './operation-catalog.ts';
|
|
4
5
|
import { type Principal } from './principal.ts';
|
|
@@ -13,12 +14,19 @@ export interface WebSocketData {
|
|
|
13
14
|
workerId?: string;
|
|
14
15
|
workerRegistered?: boolean;
|
|
15
16
|
workerProtocolVersion?: number;
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
streamLastDeliveredSequence?: number;
|
|
18
|
+
streamReplayInProgress?: boolean;
|
|
18
19
|
pendingStreamMessages?: Array<{
|
|
19
20
|
sequence: number;
|
|
20
21
|
message: string;
|
|
21
22
|
}>;
|
|
23
|
+
watchLastDeliveredSequence?: number;
|
|
24
|
+
watchReplayInProgress?: boolean;
|
|
25
|
+
pendingWatchMessages?: Array<{
|
|
26
|
+
sequence: number;
|
|
27
|
+
message: string;
|
|
28
|
+
}>;
|
|
29
|
+
workflowStreamConnectionAccepted?: boolean;
|
|
22
30
|
principal?: Principal;
|
|
23
31
|
jsonRpcSession?: JsonRpcWebSocketSession;
|
|
24
32
|
}
|
|
@@ -28,6 +36,7 @@ export declare function openJsonRpcWebSocketSession(options: {
|
|
|
28
36
|
registry: OperationRegistry;
|
|
29
37
|
engine: unknown;
|
|
30
38
|
feed: WorkflowEventFeed;
|
|
39
|
+
fleetFeed?: FleetEventFeed;
|
|
31
40
|
activeSessions: Set<JsonRpcWebSocketSession>;
|
|
32
41
|
}): void;
|
|
33
42
|
export declare function closeJsonRpcWebSocketSession(options: {
|
|
@@ -22,6 +22,7 @@ export function openJsonRpcWebSocketSession(options) {
|
|
|
22
22
|
principal: options.ws.data.principal ?? anonymousPrincipal(),
|
|
23
23
|
emitter: { send: (message) => options.ws.send(message) },
|
|
24
24
|
feed: options.feed,
|
|
25
|
+
...options.fleetFeed !== void 0 ? { fleetFeed: options.fleetFeed } : {},
|
|
25
26
|
transport: "jsonRpcWebSocket"
|
|
26
27
|
});
|
|
27
28
|
options.ws.data.jsonRpcSession = session;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const SESSION_METHODS: {
|
|
2
|
+
readonly SUBSCRIBE: "weft.workflows.subscribe";
|
|
3
|
+
readonly FLEET_SUBSCRIBE: "weft.events.subscribe";
|
|
4
|
+
readonly UNSUBSCRIBE: "weft.workflows.unsubscribe";
|
|
5
|
+
readonly DELIVER: "weft.events.deliver";
|
|
6
|
+
readonly TERMINATED: "weft.events.terminated";
|
|
7
|
+
};
|
|
8
|
+
export declare const WORKFLOW_EVENTS_OPERATION_NAME = "weft.workflows.events";
|
|
9
|
+
export declare const FLEET_EVENTS_OPERATION_NAME = "weft.events.subscribe";
|
|
10
|
+
export declare function createSubscriptionErrorTerminatedFrame(subscriptionId: string, error: unknown): Record<string, unknown>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { JSON_RPC_VERSION } from "./json-rpc-protocol.js";
|
|
2
|
+
import { SubscriptionElementValidationError } from "./operation-catalog.js";
|
|
3
|
+
import { isOperationFault } from "./operations/operation-helpers.js";
|
|
4
|
+
export const SESSION_METHODS = {
|
|
5
|
+
SUBSCRIBE: "weft.workflows.subscribe",
|
|
6
|
+
FLEET_SUBSCRIBE: "weft.events.subscribe",
|
|
7
|
+
UNSUBSCRIBE: "weft.workflows.unsubscribe",
|
|
8
|
+
DELIVER: "weft.events.deliver",
|
|
9
|
+
TERMINATED: "weft.events.terminated"
|
|
10
|
+
}, WORKFLOW_EVENTS_OPERATION_NAME = "weft.workflows.events", FLEET_EVENTS_OPERATION_NAME = "weft.events.subscribe";
|
|
11
|
+
const ENGINE_FAILURE_FAULT = {
|
|
12
|
+
code: "EngineFailure",
|
|
13
|
+
message: "internal error",
|
|
14
|
+
data: {}
|
|
15
|
+
};
|
|
16
|
+
export function createSubscriptionErrorTerminatedFrame(subscriptionId, error) {
|
|
17
|
+
if (error instanceof SubscriptionElementValidationError)
|
|
18
|
+
return createSubscriptionTerminatedFrame(subscriptionId, "validation-failed", error.fault);
|
|
19
|
+
if (isOperationFault(error))
|
|
20
|
+
return createSubscriptionTerminatedFrame(subscriptionId, "server-closed", error);
|
|
21
|
+
return createSubscriptionTerminatedFrame(subscriptionId, "server-closed", ENGINE_FAILURE_FAULT);
|
|
22
|
+
}
|
|
23
|
+
function createSubscriptionTerminatedFrame(subscriptionId, reason, fault) {
|
|
24
|
+
return {
|
|
25
|
+
jsonrpc: JSON_RPC_VERSION,
|
|
26
|
+
method: SESSION_METHODS.TERMINATED,
|
|
27
|
+
params: { subscriptionId, reason, fault }
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FleetEventFeed } from './fleet-event-feed.ts';
|
|
2
|
+
import type { OperationRegistry } from './operation-catalog.ts';
|
|
3
|
+
import type { Principal } from './principal.ts';
|
|
4
|
+
import type { WorkflowEventFeed } from './workflow-event-feed.ts';
|
|
5
|
+
export type JsonRpcWebSocketEmitter = {
|
|
6
|
+
send(message: string): void;
|
|
7
|
+
};
|
|
8
|
+
export type JsonRpcWebSocketSessionOptions = {
|
|
9
|
+
readonly registry: OperationRegistry;
|
|
10
|
+
readonly engine: unknown;
|
|
11
|
+
readonly principal: Principal;
|
|
12
|
+
readonly emitter: JsonRpcWebSocketEmitter;
|
|
13
|
+
readonly feed: WorkflowEventFeed;
|
|
14
|
+
readonly fleetFeed?: FleetEventFeed;
|
|
15
|
+
readonly maxSubscriptions?: number;
|
|
16
|
+
readonly maxFrameBytes?: number;
|
|
17
|
+
readonly transport?: 'jsonRpcHttp' | 'jsonRpcWebSocket' | 'jsonRpcStdio';
|
|
18
|
+
};
|
|
19
|
+
export type JsonRpcWebSocketSession = {
|
|
20
|
+
handleMessage(frame: string): Promise<void>;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
};
|
|
File without changes
|
|
@@ -8,13 +8,20 @@ export function validateSubscribeParams(params) {
|
|
|
8
8
|
const workflowId = params?.workflowId;
|
|
9
9
|
if (typeof workflowId !== "string" || workflowId.length === 0)
|
|
10
10
|
return invalidParams("params.workflowId must be a non-empty string");
|
|
11
|
-
const selector = params?.selector;
|
|
12
|
-
if (selector
|
|
13
|
-
return
|
|
11
|
+
const selector = validateSubscribeSelector(params?.selector);
|
|
12
|
+
if (!selector.ok)
|
|
13
|
+
return selector;
|
|
14
14
|
const fromCursor = params?.fromCursor;
|
|
15
15
|
if (fromCursor !== void 0 && typeof fromCursor !== "string")
|
|
16
16
|
return invalidParams("params.fromCursor must be a string when present");
|
|
17
|
-
return { ok: !0, workflowId, selector, fromCursor };
|
|
17
|
+
return { ok: !0, workflowId, selector: selector.selector, fromCursor };
|
|
18
|
+
}
|
|
19
|
+
function validateSubscribeSelector(rawSelector) {
|
|
20
|
+
if (rawSelector === void 0)
|
|
21
|
+
return { ok: !0, selector: "events" };
|
|
22
|
+
if (rawSelector === "events" || rawSelector === "tokens")
|
|
23
|
+
return { ok: !0, selector: rawSelector };
|
|
24
|
+
return invalidParams("params.selector must be 'events' or 'tokens'");
|
|
18
25
|
}
|
|
19
26
|
export function validateMessageFrame(frame, maxFrameBytes) {
|
|
20
27
|
if (Buffer.byteLength(frame, "utf8") > maxFrameBytes)
|
|
@@ -82,6 +89,15 @@ export function validateSessionPrimitiveFrame(frame) {
|
|
|
82
89
|
},
|
|
83
90
|
id: null
|
|
84
91
|
};
|
|
92
|
+
if (Object.hasOwn(frame.parsed, "params") && frame.parsed.params !== void 0 && !isPlainObject(frame.parsed.params))
|
|
93
|
+
return {
|
|
94
|
+
error: {
|
|
95
|
+
code: JSON_RPC_ERROR_CODES.INVALID_PARAMS,
|
|
96
|
+
message: "params must be an object when present",
|
|
97
|
+
data: { weftCode: "InvalidParams", httpStatus: 400 }
|
|
98
|
+
},
|
|
99
|
+
id: frame.id ?? null
|
|
100
|
+
};
|
|
85
101
|
return null;
|
|
86
102
|
}
|
|
87
103
|
function invalidParams(message) {
|
|
@@ -14,47 +14,6 @@
|
|
|
14
14
|
* - Guarantees every active subscription is torn down on `close()`
|
|
15
15
|
* (or socket disconnect at the transport layer).
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
import type { WorkflowEventFeed } from './workflow-event-feed.ts';
|
|
20
|
-
/** Emitter interface: any `send(string)`-shaped object. */
|
|
21
|
-
export type JsonRpcWebSocketEmitter = {
|
|
22
|
-
send(message: string): void;
|
|
23
|
-
};
|
|
24
|
-
export type JsonRpcWebSocketSessionOptions = {
|
|
25
|
-
readonly registry: OperationRegistry;
|
|
26
|
-
readonly engine: unknown;
|
|
27
|
-
readonly principal: Principal;
|
|
28
|
-
readonly emitter: JsonRpcWebSocketEmitter;
|
|
29
|
-
readonly feed: WorkflowEventFeed;
|
|
30
|
-
/**
|
|
31
|
-
* Maximum concurrent subscriptions per session. Default 100 — a
|
|
32
|
-
* well-behaved client should never need more. Rejected `subscribe`
|
|
33
|
-
* requests above the cap return `InvalidRequest (-32600)` so clients
|
|
34
|
-
* can distinguish resource exhaustion from other failures.
|
|
35
|
-
*/
|
|
36
|
-
readonly maxSubscriptions?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Maximum size of a single incoming frame in bytes. Default 1 MB.
|
|
39
|
-
* Frames exceeding the limit are rejected with a parse error before
|
|
40
|
-
* `JSON.parse` touches the payload — a runaway producer cannot force
|
|
41
|
-
* an unbounded allocation inside the adapter.
|
|
42
|
-
*/
|
|
43
|
-
readonly maxFrameBytes?: number;
|
|
44
|
-
/**
|
|
45
|
-
* Transport identity for the dispatcher's transport-availability
|
|
46
|
-
* check. Defaults to `'jsonRpcWebSocket'`. The stdio session reuses
|
|
47
|
-
* this factory but must pass `'jsonRpcStdio'` so operations with
|
|
48
|
-
* `transports.jsonRpcStdio: false` are rejected on stdio and,
|
|
49
|
-
* conversely, operations that are stdio-only aren't rejected just
|
|
50
|
-
* because they haven't been enabled for WS.
|
|
51
|
-
*/
|
|
52
|
-
readonly transport?: 'jsonRpcHttp' | 'jsonRpcWebSocket' | 'jsonRpcStdio';
|
|
53
|
-
};
|
|
54
|
-
export type JsonRpcWebSocketSession = {
|
|
55
|
-
/** Process one incoming WS frame (UTF-8 text). */
|
|
56
|
-
handleMessage(frame: string): Promise<void>;
|
|
57
|
-
/** Tear down every active subscription and release resources. */
|
|
58
|
-
close(): Promise<void>;
|
|
59
|
-
};
|
|
17
|
+
import type { JsonRpcWebSocketSession, JsonRpcWebSocketSessionOptions } from './json-rpc-websocket-types.ts';
|
|
18
|
+
export type { JsonRpcWebSocketEmitter, JsonRpcWebSocketSession, JsonRpcWebSocketSessionOptions, } from './json-rpc-websocket-types.ts';
|
|
60
19
|
export declare function createJsonRpcWebSocketSession(options: JsonRpcWebSocketSessionOptions): JsonRpcWebSocketSession;
|
|
@@ -1,38 +1,21 @@
|
|
|
1
1
|
import { faultToJsonRpcError } from "./fault-to-json-rpc.js";
|
|
2
2
|
import { dispatchJsonRpc } from "./json-rpc-dispatch.js";
|
|
3
3
|
import { JSON_RPC_ERROR_CODES, JSON_RPC_VERSION } from "./json-rpc-protocol.js";
|
|
4
|
+
import {
|
|
5
|
+
createSubscriptionErrorTerminatedFrame,
|
|
6
|
+
FLEET_EVENTS_OPERATION_NAME,
|
|
7
|
+
SESSION_METHODS,
|
|
8
|
+
WORKFLOW_EVENTS_OPERATION_NAME
|
|
9
|
+
} from "./json-rpc-websocket-subscriptions.js";
|
|
4
10
|
import {
|
|
5
11
|
validateMessageFrame,
|
|
6
12
|
validateSessionPrimitiveFrame,
|
|
7
13
|
validateSubscribeParams
|
|
8
14
|
} from "./json-rpc-websocket-validation.js";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
SubscriptionElementValidationError
|
|
12
|
-
} from "./operation-catalog.js";
|
|
13
|
-
import { workflowEventsSubscriptionOperation } from "./operations/workflow-events-subscription.js";
|
|
14
|
-
const DEFAULT_MAX_SUBSCRIPTIONS = 100, DEFAULT_MAX_FRAME_BYTES = 1048576, SESSION_METHODS = {
|
|
15
|
-
SUBSCRIBE: "weft.workflows.subscribe",
|
|
16
|
-
UNSUBSCRIBE: "weft.workflows.unsubscribe",
|
|
17
|
-
DELIVER: "weft.events.deliver",
|
|
18
|
-
TERMINATED: "weft.events.terminated"
|
|
19
|
-
}, WORKFLOW_EVENTS_OPERATION_NAME = "weft.workflows.events", WORKFLOW_EVENTS_SUBSCRIPTION_OPERATION = workflowEventsSubscriptionOperation;
|
|
20
|
-
function withWorkflowEventsSubscriptionOperation(registry) {
|
|
21
|
-
if (registry.get(WORKFLOW_EVENTS_OPERATION_NAME) !== void 0)
|
|
22
|
-
return registry;
|
|
23
|
-
return {
|
|
24
|
-
get(name) {
|
|
25
|
-
if (name === WORKFLOW_EVENTS_OPERATION_NAME)
|
|
26
|
-
return WORKFLOW_EVENTS_SUBSCRIPTION_OPERATION;
|
|
27
|
-
return registry.get(name);
|
|
28
|
-
},
|
|
29
|
-
list() {
|
|
30
|
-
return [...registry.list(), WORKFLOW_EVENTS_SUBSCRIPTION_OPERATION];
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
15
|
+
import { executeSubscription } from "./operation-catalog.js";
|
|
16
|
+
const DEFAULT_MAX_SUBSCRIPTIONS = 100, DEFAULT_MAX_FRAME_BYTES = 1048576;
|
|
34
17
|
export function createJsonRpcWebSocketSession(options) {
|
|
35
|
-
const { registry, engine, principal, emitter, feed } = options,
|
|
18
|
+
const { registry, engine, principal, emitter, feed, fleetFeed } = options, maxSubscriptions = options.maxSubscriptions ?? DEFAULT_MAX_SUBSCRIPTIONS, maxFrameBytes = options.maxFrameBytes ?? DEFAULT_MAX_FRAME_BYTES, transport = options.transport ?? "jsonRpcWebSocket", subscriptions = new Map;
|
|
36
19
|
let emitterBroken = !1, disposed = !1;
|
|
37
20
|
function emit(message) {
|
|
38
21
|
if (disposed || emitterBroken)
|
|
@@ -60,6 +43,26 @@ export function createJsonRpcWebSocketSession(options) {
|
|
|
60
43
|
});
|
|
61
44
|
return;
|
|
62
45
|
}
|
|
46
|
+
await startSubscription(request, () => executeSubscription(WORKFLOW_EVENTS_OPERATION_NAME, {
|
|
47
|
+
workflowId: validation.workflowId,
|
|
48
|
+
selector: validation.selector,
|
|
49
|
+
...validation.fromCursor === void 0 ? {} : { fromCursor: validation.fromCursor }
|
|
50
|
+
}, {
|
|
51
|
+
principal,
|
|
52
|
+
engine: { feed },
|
|
53
|
+
transport,
|
|
54
|
+
registry
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
async function handleFleetSubscribe(request, params) {
|
|
58
|
+
await startSubscription(request, () => executeSubscription(FLEET_EVENTS_OPERATION_NAME, params ?? {}, {
|
|
59
|
+
principal,
|
|
60
|
+
engine: { fleetFeed },
|
|
61
|
+
transport,
|
|
62
|
+
registry
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
async function startSubscription(request, execute) {
|
|
63
66
|
if (subscriptions.size >= maxSubscriptions) {
|
|
64
67
|
emitResponse(request, {
|
|
65
68
|
jsonrpc: JSON_RPC_VERSION,
|
|
@@ -76,16 +79,7 @@ export function createJsonRpcWebSocketSession(options) {
|
|
|
76
79
|
});
|
|
77
80
|
return;
|
|
78
81
|
}
|
|
79
|
-
const controller = new AbortController, result = await
|
|
80
|
-
workflowId: validation.workflowId,
|
|
81
|
-
selector: validation.selector,
|
|
82
|
-
...validation.fromCursor === void 0 ? {} : { fromCursor: validation.fromCursor }
|
|
83
|
-
}, {
|
|
84
|
-
principal,
|
|
85
|
-
engine: { feed },
|
|
86
|
-
transport,
|
|
87
|
-
registry: subscriptionRegistry
|
|
88
|
-
});
|
|
82
|
+
const controller = new AbortController, result = await execute();
|
|
89
83
|
if (!result.ok) {
|
|
90
84
|
const error = faultToJsonRpcError(result.fault);
|
|
91
85
|
emitResponse(request, {
|
|
@@ -137,26 +131,7 @@ export function createJsonRpcWebSocketSession(options) {
|
|
|
137
131
|
});
|
|
138
132
|
} catch (error) {
|
|
139
133
|
if (!signal.aborted && !shouldSuppressOutput())
|
|
140
|
-
|
|
141
|
-
emit({
|
|
142
|
-
jsonrpc: JSON_RPC_VERSION,
|
|
143
|
-
method: SESSION_METHODS.TERMINATED,
|
|
144
|
-
params: {
|
|
145
|
-
subscriptionId,
|
|
146
|
-
reason: "validation-failed",
|
|
147
|
-
fault: error.fault
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
else
|
|
151
|
-
emit({
|
|
152
|
-
jsonrpc: JSON_RPC_VERSION,
|
|
153
|
-
method: SESSION_METHODS.TERMINATED,
|
|
154
|
-
params: {
|
|
155
|
-
subscriptionId,
|
|
156
|
-
reason: "server-closed",
|
|
157
|
-
fault: { code: "EngineFailure", message: "internal error", data: {} }
|
|
158
|
-
}
|
|
159
|
-
});
|
|
134
|
+
emit(createSubscriptionErrorTerminatedFrame(subscriptionId, error));
|
|
160
135
|
} finally {
|
|
161
136
|
signal.removeEventListener("abort", abortSubscription);
|
|
162
137
|
await closeOnce().catch(() => {});
|
|
@@ -211,6 +186,30 @@ export function createJsonRpcWebSocketSession(options) {
|
|
|
211
186
|
params: { subscriptionId, reason: "client-unsubscribed" }
|
|
212
187
|
});
|
|
213
188
|
}
|
|
189
|
+
function isSessionPrimitive(method) {
|
|
190
|
+
return method === SESSION_METHODS.SUBSCRIBE || method === WORKFLOW_EVENTS_OPERATION_NAME || method === SESSION_METHODS.FLEET_SUBSCRIBE || method === SESSION_METHODS.UNSUBSCRIBE;
|
|
191
|
+
}
|
|
192
|
+
async function handleSessionPrimitive(validation) {
|
|
193
|
+
const sessionPrimitiveError = validateSessionPrimitiveFrame(validation);
|
|
194
|
+
if (sessionPrimitiveError !== null) {
|
|
195
|
+
emit({
|
|
196
|
+
jsonrpc: JSON_RPC_VERSION,
|
|
197
|
+
error: sessionPrimitiveError.error,
|
|
198
|
+
id: sessionPrimitiveError.id
|
|
199
|
+
});
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const request = {
|
|
203
|
+
id: validation.id,
|
|
204
|
+
expectsResponse: validation.hasRequestId
|
|
205
|
+
};
|
|
206
|
+
if (validation.method === SESSION_METHODS.SUBSCRIBE || validation.method === WORKFLOW_EVENTS_OPERATION_NAME)
|
|
207
|
+
await handleSubscribe(request, validation.params);
|
|
208
|
+
else if (validation.method === SESSION_METHODS.FLEET_SUBSCRIBE)
|
|
209
|
+
await handleFleetSubscribe(request, validation.params);
|
|
210
|
+
else
|
|
211
|
+
handleUnsubscribe(request, validation.params);
|
|
212
|
+
}
|
|
214
213
|
async function handleMessage(frame) {
|
|
215
214
|
if (disposed || emitterBroken)
|
|
216
215
|
return;
|
|
@@ -223,24 +222,8 @@ export function createJsonRpcWebSocketSession(options) {
|
|
|
223
222
|
});
|
|
224
223
|
return;
|
|
225
224
|
}
|
|
226
|
-
if (validation.method
|
|
227
|
-
|
|
228
|
-
if (sessionPrimitiveError !== null) {
|
|
229
|
-
emit({
|
|
230
|
-
jsonrpc: JSON_RPC_VERSION,
|
|
231
|
-
error: sessionPrimitiveError.error,
|
|
232
|
-
id: sessionPrimitiveError.id
|
|
233
|
-
});
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
const request = {
|
|
237
|
-
id: validation.id,
|
|
238
|
-
expectsResponse: validation.hasRequestId
|
|
239
|
-
};
|
|
240
|
-
if (validation.method === SESSION_METHODS.SUBSCRIBE)
|
|
241
|
-
await handleSubscribe(request, validation.params);
|
|
242
|
-
else
|
|
243
|
-
handleUnsubscribe(request, validation.params);
|
|
225
|
+
if (isSessionPrimitive(validation.method)) {
|
|
226
|
+
await handleSessionPrimitive(validation);
|
|
244
227
|
return;
|
|
245
228
|
}
|
|
246
229
|
const result = await dispatchJsonRpc(validation.parsed, {
|
package/dist/server/openapi.d.ts
CHANGED
|
@@ -34,7 +34,8 @@ export type OpenApiOptions = {
|
|
|
34
34
|
serverUrl?: string;
|
|
35
35
|
/**
|
|
36
36
|
* Security schemes the live server actually supports. When omitted,
|
|
37
|
-
* emit both
|
|
37
|
+
* emit both current API-key scheme names so generated clients can choose
|
|
38
|
+
* either header-oriented convention.
|
|
38
39
|
*/
|
|
39
40
|
supportedSchemes?: ReadonlySet<OpenApiSecuritySchemeName>;
|
|
40
41
|
};
|
package/dist/server/openapi.js
CHANGED
|
@@ -217,9 +217,7 @@ function buildDirectRouteResponses(route) {
|
|
|
217
217
|
return responses;
|
|
218
218
|
}
|
|
219
219
|
function buildDirectRouteSecurity(route) {
|
|
220
|
-
|
|
221
|
-
return [];
|
|
222
|
-
return;
|
|
220
|
+
return route.access === "public" ? [] : void 0;
|
|
223
221
|
}
|
|
224
222
|
function emitDirectRoutes(paths, tagSet) {
|
|
225
223
|
for (const route of DIRECT_HTTP_ROUTES) {
|
|
@@ -39,6 +39,45 @@ export declare const OpenRpcMethodSchema: z.ZodObject<{
|
|
|
39
39
|
source: z.ZodLiteral<"live">;
|
|
40
40
|
}, z.core.$strict>;
|
|
41
41
|
}, z.core.$strict>>;
|
|
42
|
+
'x-weft-parameterizedAccess': z.ZodOptional<z.ZodObject<{
|
|
43
|
+
discriminator: z.ZodString;
|
|
44
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
45
|
+
variants: z.ZodArray<z.ZodObject<{
|
|
46
|
+
value: z.ZodString;
|
|
47
|
+
access: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
48
|
+
kind: z.ZodLiteral<"public">;
|
|
49
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
+
kind: z.ZodLiteral<"authenticated">;
|
|
51
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
52
|
+
kind: z.ZodLiteral<"scoped">;
|
|
53
|
+
scopes: z.ZodObject<{
|
|
54
|
+
kind: z.ZodEnum<{
|
|
55
|
+
anyOf: "anyOf";
|
|
56
|
+
allOf: "allOf";
|
|
57
|
+
}>;
|
|
58
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
59
|
+
}, z.core.$strict>;
|
|
60
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
61
|
+
kind: z.ZodLiteral<"optionalAuth">;
|
|
62
|
+
authenticatedScopes: z.ZodObject<{
|
|
63
|
+
kind: z.ZodEnum<{
|
|
64
|
+
anyOf: "anyOf";
|
|
65
|
+
allOf: "allOf";
|
|
66
|
+
}>;
|
|
67
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
70
|
+
kind: z.ZodLiteral<"scopedAlternatives">;
|
|
71
|
+
alternatives: z.ZodArray<z.ZodObject<{
|
|
72
|
+
kind: z.ZodEnum<{
|
|
73
|
+
anyOf: "anyOf";
|
|
74
|
+
allOf: "allOf";
|
|
75
|
+
}>;
|
|
76
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
77
|
+
}, z.core.$strict>>;
|
|
78
|
+
}, z.core.$strict>], "kind">;
|
|
79
|
+
}, z.core.$strict>>;
|
|
80
|
+
}, z.core.$strict>>;
|
|
42
81
|
}, z.core.$strict>;
|
|
43
82
|
export declare const OpenRpcDocumentSchema: z.ZodObject<{
|
|
44
83
|
openrpc: z.ZodLiteral<"1.3.2">;
|
|
@@ -90,6 +129,45 @@ export declare const OpenRpcDocumentSchema: z.ZodObject<{
|
|
|
90
129
|
source: z.ZodLiteral<"live">;
|
|
91
130
|
}, z.core.$strict>;
|
|
92
131
|
}, z.core.$strict>>;
|
|
132
|
+
'x-weft-parameterizedAccess': z.ZodOptional<z.ZodObject<{
|
|
133
|
+
discriminator: z.ZodString;
|
|
134
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
135
|
+
variants: z.ZodArray<z.ZodObject<{
|
|
136
|
+
value: z.ZodString;
|
|
137
|
+
access: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
138
|
+
kind: z.ZodLiteral<"public">;
|
|
139
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
140
|
+
kind: z.ZodLiteral<"authenticated">;
|
|
141
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
142
|
+
kind: z.ZodLiteral<"scoped">;
|
|
143
|
+
scopes: z.ZodObject<{
|
|
144
|
+
kind: z.ZodEnum<{
|
|
145
|
+
anyOf: "anyOf";
|
|
146
|
+
allOf: "allOf";
|
|
147
|
+
}>;
|
|
148
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
149
|
+
}, z.core.$strict>;
|
|
150
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
151
|
+
kind: z.ZodLiteral<"optionalAuth">;
|
|
152
|
+
authenticatedScopes: z.ZodObject<{
|
|
153
|
+
kind: z.ZodEnum<{
|
|
154
|
+
anyOf: "anyOf";
|
|
155
|
+
allOf: "allOf";
|
|
156
|
+
}>;
|
|
157
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
158
|
+
}, z.core.$strict>;
|
|
159
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
160
|
+
kind: z.ZodLiteral<"scopedAlternatives">;
|
|
161
|
+
alternatives: z.ZodArray<z.ZodObject<{
|
|
162
|
+
kind: z.ZodEnum<{
|
|
163
|
+
anyOf: "anyOf";
|
|
164
|
+
allOf: "allOf";
|
|
165
|
+
}>;
|
|
166
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
167
|
+
}, z.core.$strict>>;
|
|
168
|
+
}, z.core.$strict>], "kind">;
|
|
169
|
+
}, z.core.$strict>>;
|
|
170
|
+
}, z.core.$strict>>;
|
|
93
171
|
}, z.core.$strict>>;
|
|
94
172
|
components: z.ZodOptional<z.ZodObject<{
|
|
95
173
|
errors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -12,6 +12,31 @@ const OpenRpcMcpMethodMetadataSchema = z.strictObject({
|
|
|
12
12
|
method: z.literal(MCP_TOOLS_LIST_METHOD),
|
|
13
13
|
source: z.literal("live")
|
|
14
14
|
})
|
|
15
|
+
}), OpenRpcScopeRequirementSchema = z.strictObject({
|
|
16
|
+
kind: z.enum(["anyOf", "allOf"]),
|
|
17
|
+
scopes: z.array(z.string())
|
|
18
|
+
}), OpenRpcAccessPolicySchema = z.discriminatedUnion("kind", [
|
|
19
|
+
z.strictObject({ kind: z.literal("public") }),
|
|
20
|
+
z.strictObject({ kind: z.literal("authenticated") }),
|
|
21
|
+
z.strictObject({
|
|
22
|
+
kind: z.literal("scoped"),
|
|
23
|
+
scopes: OpenRpcScopeRequirementSchema
|
|
24
|
+
}),
|
|
25
|
+
z.strictObject({
|
|
26
|
+
kind: z.literal("optionalAuth"),
|
|
27
|
+
authenticatedScopes: OpenRpcScopeRequirementSchema
|
|
28
|
+
}),
|
|
29
|
+
z.strictObject({
|
|
30
|
+
kind: z.literal("scopedAlternatives"),
|
|
31
|
+
alternatives: z.array(OpenRpcScopeRequirementSchema)
|
|
32
|
+
})
|
|
33
|
+
]), OpenRpcParameterizedAccessSchema = z.strictObject({
|
|
34
|
+
discriminator: z.string(),
|
|
35
|
+
defaultValue: z.string().optional(),
|
|
36
|
+
variants: z.array(z.strictObject({
|
|
37
|
+
value: z.string(),
|
|
38
|
+
access: OpenRpcAccessPolicySchema
|
|
39
|
+
}))
|
|
15
40
|
});
|
|
16
41
|
export const OpenRpcMethodSchema = z.strictObject({
|
|
17
42
|
name: z.string(),
|
|
@@ -23,7 +48,8 @@ export const OpenRpcMethodSchema = z.strictObject({
|
|
|
23
48
|
result: ContentDescriptorSchema,
|
|
24
49
|
errors: z.array(z.strictObject({ $ref: z.string() })).optional(),
|
|
25
50
|
"x-weft-paramsSchema": z.record(z.string(), z.unknown()),
|
|
26
|
-
"x-weft-mcp": OpenRpcMcpMethodMetadataSchema.optional()
|
|
51
|
+
"x-weft-mcp": OpenRpcMcpMethodMetadataSchema.optional(),
|
|
52
|
+
"x-weft-parameterizedAccess": OpenRpcParameterizedAccessSchema.optional()
|
|
27
53
|
});
|
|
28
54
|
const OpenRpcMcpMetadataSchema = z.strictObject({
|
|
29
55
|
discoveryPath: z.literal(MCP_DISCOVERY_PATH),
|
|
@@ -23,6 +23,9 @@ export declare const UnprocessableDataSchema: z.ZodObject<{
|
|
|
23
23
|
export declare const TimeoutDataSchema: z.ZodObject<{
|
|
24
24
|
operationName: z.ZodOptional<z.ZodString>;
|
|
25
25
|
}, z.core.$strip>;
|
|
26
|
+
export declare const PayloadTooLargeDataSchema: z.ZodObject<{
|
|
27
|
+
maxBytes: z.ZodNumber;
|
|
28
|
+
}, z.core.$strip>;
|
|
26
29
|
export declare const NotImplementedDataSchema: z.ZodObject<{}, z.core.$strip>;
|
|
27
30
|
export declare const UnsupportedTransportDataSchema: z.ZodObject<{
|
|
28
31
|
transport: z.ZodEnum<{
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
export const UnauthorizedDataSchema = z.object({ reason: z.string() }), ForbiddenDataSchema = z.object({ reason: z.string() }), NotFoundDataSchema = z.object({
|
|
7
7
|
resource: z.string(),
|
|
8
8
|
identifier: z.string().optional()
|
|
9
|
-
}), ConflictDataSchema = z.object({ reason: z.string() }), UnprocessableDataSchema = z.object({ reason: z.string() }), TimeoutDataSchema = z.object({ operationName: z.string().optional() }), NotImplementedDataSchema = z.object({});
|
|
9
|
+
}), ConflictDataSchema = z.object({ reason: z.string() }), UnprocessableDataSchema = z.object({ reason: z.string() }), TimeoutDataSchema = z.object({ operationName: z.string().optional() }), PayloadTooLargeDataSchema = z.object({ maxBytes: z.number() }), NotImplementedDataSchema = z.object({});
|
|
10
10
|
const TransportKindSchema = z.enum([
|
|
11
11
|
"http-rest",
|
|
12
12
|
"jsonRpcHttp",
|
|
@@ -33,6 +33,7 @@ const FAULT_DATA_SCHEMAS = {
|
|
|
33
33
|
Conflict: ConflictDataSchema,
|
|
34
34
|
Unprocessable: UnprocessableDataSchema,
|
|
35
35
|
Timeout: TimeoutDataSchema,
|
|
36
|
+
PayloadTooLarge: PayloadTooLargeDataSchema,
|
|
36
37
|
NotImplemented: NotImplementedDataSchema,
|
|
37
38
|
UnsupportedTransport: UnsupportedTransportDataSchema,
|
|
38
39
|
SubscriptionOverflow: SubscriptionOverflowDataSchema,
|
package/dist/server/openrpc.js
CHANGED
|
@@ -117,9 +117,41 @@ function buildMethod(operation) {
|
|
|
117
117
|
method.description = operation.description;
|
|
118
118
|
if (operation.tags.length > 0)
|
|
119
119
|
method.tags = [...operation.tags].toSorted(compareStrings).map((name) => ({ name }));
|
|
120
|
+
if (operation.parameterizedAccess !== void 0)
|
|
121
|
+
method["x-weft-parameterizedAccess"] = {
|
|
122
|
+
discriminator: operation.parameterizedAccess.discriminator,
|
|
123
|
+
...operation.parameterizedAccess.defaultValue === void 0 ? {} : { defaultValue: operation.parameterizedAccess.defaultValue },
|
|
124
|
+
variants: operation.parameterizedAccess.variants.map((variant) => ({
|
|
125
|
+
value: variant.value,
|
|
126
|
+
access: accessPolicyExtension(variant.access)
|
|
127
|
+
}))
|
|
128
|
+
};
|
|
120
129
|
method.errors = buildMethodErrorReferences(operation);
|
|
121
130
|
return method;
|
|
122
131
|
}
|
|
132
|
+
function accessPolicyExtension(access) {
|
|
133
|
+
if (access.kind === "public")
|
|
134
|
+
return { kind: "public" };
|
|
135
|
+
if (access.kind === "authenticated")
|
|
136
|
+
return { kind: "authenticated" };
|
|
137
|
+
if (access.kind === "scoped")
|
|
138
|
+
return { kind: "scoped", scopes: scopeRequirementExtension(access.scopes) };
|
|
139
|
+
if (access.kind === "optionalAuth")
|
|
140
|
+
return {
|
|
141
|
+
kind: "optionalAuth",
|
|
142
|
+
authenticatedScopes: scopeRequirementExtension(access.authenticatedScopes)
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
kind: "scopedAlternatives",
|
|
146
|
+
alternatives: access.alternatives.map(scopeRequirementExtension)
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function scopeRequirementExtension(requirement) {
|
|
150
|
+
return {
|
|
151
|
+
kind: requirement.kind,
|
|
152
|
+
scopes: [...requirement.scopes].toSorted(compareStrings)
|
|
153
|
+
};
|
|
154
|
+
}
|
|
123
155
|
function buildDiscoverMethod() {
|
|
124
156
|
return {
|
|
125
157
|
name: "rpc.discover",
|
|
@@ -17,6 +17,6 @@ export { executeOperation } from './pipeline.ts';
|
|
|
17
17
|
export { UNIVERSAL_FAULT_DEFAULTS, raiseFault } from './raise-fault.ts';
|
|
18
18
|
export { createOperationRegistry } from './registry.ts';
|
|
19
19
|
export { SubscriptionElementValidationError, executeStream, executeSubscription, } from './stream-pipeline.ts';
|
|
20
|
-
export { OPERATION_NAME_PATTERN, isValidOperationName, validateOperationName, type AuthorizationDecision, type DispatchContext, type DispatchResult, type ErasedOperation, type McpToolMetadata, type OperationContext, type OperationDefinition, type OperationInvocationResult, type OperationKind, type OperationRegistry, type PipelineTrace, type PipelineTraceMarker, type RegistrableOperation, type StreamOperationInvocation, type SubscriptionOperationInvocation, type TransportAvailability, type UnknownKeyDisposition, type UnknownKeyPolicy, } from './types.ts';
|
|
20
|
+
export { OPERATION_NAME_PATTERN, isValidOperationName, validateOperationName, type AuthorizationDecision, type DispatchContext, type DispatchResult, type ErasedOperation, type McpToolMetadata, type OperationContext, type OperationDefinition, type OperationInvocationResult, type OperationKind, type OperationRegistry, type ParameterizedAccessHint, type PipelineTrace, type PipelineTraceMarker, type RegistrableOperation, type StreamOperationInvocation, type SubscriptionOperationInvocation, type TransportAvailability, type UnknownKeyDisposition, type UnknownKeyPolicy, } from './types.ts';
|
|
21
21
|
export { catalogWorkflow } from './workflow-adapter.ts';
|
|
22
22
|
export type { CatalogWorkflowOptions } from './workflow-adapter.ts';
|