@smthrs/flow 0.0.0-stage → 1.0.0-rc.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +161 -0
- package/LICENSE +21 -0
- package/README.md +212 -2
- package/THIRD_PARTY_NOTICES.md +52 -0
- package/dist/cjs/Action/Action.d.ts +250 -0
- package/dist/cjs/Action/Action.d.ts.map +1 -0
- package/dist/cjs/Action/Action.js +42 -0
- package/dist/cjs/Action/Action.js.map +7 -0
- package/dist/cjs/Action/AttemptTimedOut.d.ts +33 -0
- package/dist/cjs/Action/AttemptTimedOut.d.ts.map +1 -0
- package/dist/cjs/Action/AttemptTimedOut.js +51 -0
- package/dist/cjs/Action/AttemptTimedOut.js.map +7 -0
- package/dist/cjs/Action/BoundaryMode.d.ts +29 -0
- package/dist/cjs/Action/BoundaryMode.d.ts.map +1 -0
- package/dist/cjs/Action/BoundaryMode.js +36 -0
- package/dist/cjs/Action/BoundaryMode.js.map +7 -0
- package/dist/cjs/Action/CacheEnvironment.d.ts +158 -0
- package/dist/cjs/Action/CacheEnvironment.d.ts.map +1 -0
- package/dist/cjs/Action/CacheEnvironment.js +57 -0
- package/dist/cjs/Action/CacheEnvironment.js.map +7 -0
- package/dist/cjs/Action/ConcurrentKeylessDispatch.d.ts +34 -0
- package/dist/cjs/Action/ConcurrentKeylessDispatch.d.ts.map +1 -0
- package/dist/cjs/Action/ConcurrentKeylessDispatch.js +46 -0
- package/dist/cjs/Action/ConcurrentKeylessDispatch.js.map +7 -0
- package/dist/cjs/Action/Context.d.ts +131 -0
- package/dist/cjs/Action/Context.d.ts.map +1 -0
- package/dist/cjs/Action/Context.js +68 -0
- package/dist/cjs/Action/Context.js.map +7 -0
- package/dist/cjs/Action/DuplicateImplementation.d.ts +20 -0
- package/dist/cjs/Action/DuplicateImplementation.d.ts.map +1 -0
- package/dist/cjs/Action/DuplicateImplementation.js +46 -0
- package/dist/cjs/Action/DuplicateImplementation.js.map +7 -0
- package/dist/cjs/Action/FileBoundary.d.ts +59 -0
- package/dist/cjs/Action/FileBoundary.d.ts.map +1 -0
- package/dist/cjs/Action/FileBoundary.js +81 -0
- package/dist/cjs/Action/FileBoundary.js.map +7 -0
- package/dist/cjs/Action/FileInput.d.ts +28 -0
- package/dist/cjs/Action/FileInput.d.ts.map +1 -0
- package/dist/cjs/Action/FileInput.js +42 -0
- package/dist/cjs/Action/FileInput.js.map +7 -0
- package/dist/cjs/Action/Filegroup.d.ts +16 -0
- package/dist/cjs/Action/Filegroup.d.ts.map +1 -0
- package/dist/cjs/Action/Filegroup.js +27 -0
- package/dist/cjs/Action/Filegroup.js.map +7 -0
- package/dist/cjs/Action/Glob.d.ts +8 -0
- package/dist/cjs/Action/Glob.d.ts.map +1 -0
- package/dist/cjs/Action/Glob.js +28 -0
- package/dist/cjs/Action/Glob.js.map +7 -0
- package/dist/cjs/Action/ImplementationVersionMismatch.d.ts +26 -0
- package/dist/cjs/Action/ImplementationVersionMismatch.d.ts.map +1 -0
- package/dist/cjs/Action/ImplementationVersionMismatch.js +45 -0
- package/dist/cjs/Action/ImplementationVersionMismatch.js.map +7 -0
- package/dist/cjs/Action/Implementations.d.ts +114 -0
- package/dist/cjs/Action/Implementations.d.ts.map +1 -0
- package/dist/cjs/Action/Implementations.js +65 -0
- package/dist/cjs/Action/Implementations.js.map +7 -0
- package/dist/cjs/Action/InfraInterrupt.d.ts +26 -0
- package/dist/cjs/Action/InfraInterrupt.d.ts.map +1 -0
- package/dist/cjs/Action/InfraInterrupt.js +46 -0
- package/dist/cjs/Action/InfraInterrupt.js.map +7 -0
- package/dist/cjs/Action/InfraInterruptRetriesExhausted.d.ts +33 -0
- package/dist/cjs/Action/InfraInterruptRetriesExhausted.d.ts.map +1 -0
- package/dist/cjs/Action/InfraInterruptRetriesExhausted.js +54 -0
- package/dist/cjs/Action/InfraInterruptRetriesExhausted.js.map +7 -0
- package/dist/cjs/Action/IrreversibleRetryRequiresIdempotencyKey.d.ts +26 -0
- package/dist/cjs/Action/IrreversibleRetryRequiresIdempotencyKey.d.ts.map +1 -0
- package/dist/cjs/Action/IrreversibleRetryRequiresIdempotencyKey.js +47 -0
- package/dist/cjs/Action/IrreversibleRetryRequiresIdempotencyKey.js.map +7 -0
- package/dist/cjs/Action/StepIdentity.d.ts +153 -0
- package/dist/cjs/Action/StepIdentity.d.ts.map +1 -0
- package/dist/cjs/Action/StepIdentity.js +75 -0
- package/dist/cjs/Action/StepIdentity.js.map +7 -0
- package/dist/cjs/Action/TreeArtifact.d.ts +8 -0
- package/dist/cjs/Action/TreeArtifact.d.ts.map +1 -0
- package/dist/cjs/Action/TreeArtifact.js +25 -0
- package/dist/cjs/Action/TreeArtifact.js.map +7 -0
- package/dist/cjs/Action/TypeId.d.ts +8 -0
- package/dist/cjs/Action/TypeId.d.ts.map +1 -0
- package/dist/cjs/Action/TypeId.js +25 -0
- package/dist/cjs/Action/TypeId.js.map +7 -0
- package/dist/cjs/Action/UncanonicalIdempotencyKey.d.ts +32 -0
- package/dist/cjs/Action/UncanonicalIdempotencyKey.d.ts.map +1 -0
- package/dist/cjs/Action/UncanonicalIdempotencyKey.js +51 -0
- package/dist/cjs/Action/UncanonicalIdempotencyKey.js.map +7 -0
- package/dist/cjs/Action/idempotencyKey.d.ts +21 -0
- package/dist/cjs/Action/idempotencyKey.d.ts.map +1 -0
- package/dist/cjs/Action/idempotencyKey.js +59 -0
- package/dist/cjs/Action/idempotencyKey.js.map +7 -0
- package/dist/cjs/Action/index.d.ts +29 -0
- package/dist/cjs/Action/index.d.ts.map +1 -0
- package/dist/cjs/Action/index.js +60 -0
- package/dist/cjs/Action/index.js.map +7 -0
- package/dist/cjs/Action/make.d.ts +128 -0
- package/dist/cjs/Action/make.d.ts.map +1 -0
- package/dist/cjs/Action/make.js +387 -0
- package/dist/cjs/Action/make.js.map +7 -0
- package/dist/cjs/Action/raceAll.d.ts +21 -0
- package/dist/cjs/Action/raceAll.d.ts.map +1 -0
- package/dist/cjs/Action/raceAll.js +46 -0
- package/dist/cjs/Action/raceAll.js.map +7 -0
- package/dist/cjs/Action/retry.d.ts +19 -0
- package/dist/cjs/Action/retry.d.ts.map +1 -0
- package/dist/cjs/Action/retry.js +75 -0
- package/dist/cjs/Action/retry.js.map +7 -0
- package/dist/cjs/Deadline.d.ts +110 -0
- package/dist/cjs/Deadline.d.ts.map +1 -0
- package/dist/cjs/Deadline.js +112 -0
- package/dist/cjs/Deadline.js.map +7 -0
- package/dist/cjs/DurableClock.d.ts +60 -0
- package/dist/cjs/DurableClock.d.ts.map +1 -0
- package/dist/cjs/DurableClock.js +107 -0
- package/dist/cjs/DurableClock.js.map +7 -0
- package/dist/cjs/DurableDeferred.d.ts +311 -0
- package/dist/cjs/DurableDeferred.d.ts.map +1 -0
- package/dist/cjs/DurableDeferred.js +322 -0
- package/dist/cjs/DurableDeferred.js.map +7 -0
- package/dist/cjs/DurableQueue.d.ts +160 -0
- package/dist/cjs/DurableQueue.d.ts.map +1 -0
- package/dist/cjs/DurableQueue.js +229 -0
- package/dist/cjs/DurableQueue.js.map +7 -0
- package/dist/cjs/ExternalJob.d.ts +179 -0
- package/dist/cjs/ExternalJob.d.ts.map +1 -0
- package/dist/cjs/ExternalJob.js +339 -0
- package/dist/cjs/ExternalJob.js.map +7 -0
- package/dist/cjs/Fault.d.ts +131 -0
- package/dist/cjs/Fault.d.ts.map +1 -0
- package/dist/cjs/Fault.js +157 -0
- package/dist/cjs/Fault.js.map +7 -0
- package/dist/cjs/Flow/Annotations.d.ts +245 -0
- package/dist/cjs/Flow/Annotations.d.ts.map +1 -0
- package/dist/cjs/Flow/Annotations.js +72 -0
- package/dist/cjs/Flow/Annotations.js.map +7 -0
- package/dist/cjs/Flow/CapabilityCeiling.d.ts +21 -0
- package/dist/cjs/Flow/CapabilityCeiling.d.ts.map +1 -0
- package/dist/cjs/Flow/CapabilityCeiling.js +49 -0
- package/dist/cjs/Flow/CapabilityCeiling.js.map +7 -0
- package/dist/cjs/Flow/DeadlineExceeded.d.ts +33 -0
- package/dist/cjs/Flow/DeadlineExceeded.d.ts.map +1 -0
- package/dist/cjs/Flow/DeadlineExceeded.js +52 -0
- package/dist/cjs/Flow/DeadlineExceeded.js.map +7 -0
- package/dist/cjs/Flow/ExecutionIdRequired.d.ts +25 -0
- package/dist/cjs/Flow/ExecutionIdRequired.d.ts.map +1 -0
- package/dist/cjs/Flow/ExecutionIdRequired.js +46 -0
- package/dist/cjs/Flow/ExecutionIdRequired.js.map +7 -0
- package/dist/cjs/Flow/ExecutionIds.d.ts +80 -0
- package/dist/cjs/Flow/ExecutionIds.d.ts.map +1 -0
- package/dist/cjs/Flow/ExecutionIds.js +66 -0
- package/dist/cjs/Flow/ExecutionIds.js.map +7 -0
- package/dist/cjs/Flow/Flow.d.ts +422 -0
- package/dist/cjs/Flow/Flow.d.ts.map +1 -0
- package/dist/cjs/Flow/Flow.js +17 -0
- package/dist/cjs/Flow/Flow.js.map +7 -0
- package/dist/cjs/Flow/MaxRoundsExceeded.d.ts +35 -0
- package/dist/cjs/Flow/MaxRoundsExceeded.d.ts.map +1 -0
- package/dist/cjs/Flow/MaxRoundsExceeded.js +50 -0
- package/dist/cjs/Flow/MaxRoundsExceeded.js.map +7 -0
- package/dist/cjs/Flow/Outcome.d.ts +162 -0
- package/dist/cjs/Flow/Outcome.d.ts.map +1 -0
- package/dist/cjs/Flow/Outcome.js +80 -0
- package/dist/cjs/Flow/Outcome.js.map +7 -0
- package/dist/cjs/Flow/Result.d.ts +186 -0
- package/dist/cjs/Flow/Result.d.ts.map +1 -0
- package/dist/cjs/Flow/Result.js +159 -0
- package/dist/cjs/Flow/Result.js.map +7 -0
- package/dist/cjs/Flow/Runtime.d.ts +98 -0
- package/dist/cjs/Flow/Runtime.d.ts.map +1 -0
- package/dist/cjs/Flow/Runtime.js +186 -0
- package/dist/cjs/Flow/Runtime.js.map +7 -0
- package/dist/cjs/Flow/TypeId.d.ts +8 -0
- package/dist/cjs/Flow/TypeId.d.ts.map +1 -0
- package/dist/cjs/Flow/TypeId.js +25 -0
- package/dist/cjs/Flow/TypeId.js.map +7 -0
- package/dist/cjs/Flow/index.d.ts +17 -0
- package/dist/cjs/Flow/index.d.ts.map +1 -0
- package/dist/cjs/Flow/index.js +29 -0
- package/dist/cjs/Flow/index.js.map +7 -0
- package/dist/cjs/Flow/internal.d.ts +34 -0
- package/dist/cjs/Flow/internal.d.ts.map +1 -0
- package/dist/cjs/Flow/internal.js +187 -0
- package/dist/cjs/Flow/internal.js.map +7 -0
- package/dist/cjs/Flow/make.d.ts +135 -0
- package/dist/cjs/Flow/make.d.ts.map +1 -0
- package/dist/cjs/Flow/make.js +107 -0
- package/dist/cjs/Flow/make.js.map +7 -0
- package/dist/cjs/FlowRuntime/CancelRequestFailed.d.ts +55 -0
- package/dist/cjs/FlowRuntime/CancelRequestFailed.d.ts.map +1 -0
- package/dist/cjs/FlowRuntime/CancelRequestFailed.js +51 -0
- package/dist/cjs/FlowRuntime/CancelRequestFailed.js.map +7 -0
- package/dist/cjs/FlowRuntime/ExecutionIdentityConflict.d.ts +23 -0
- package/dist/cjs/FlowRuntime/ExecutionIdentityConflict.d.ts.map +1 -0
- package/dist/cjs/FlowRuntime/ExecutionIdentityConflict.js +55 -0
- package/dist/cjs/FlowRuntime/ExecutionIdentityConflict.js.map +7 -0
- package/dist/cjs/FlowRuntime/FlowCycleDetected.d.ts +28 -0
- package/dist/cjs/FlowRuntime/FlowCycleDetected.d.ts.map +1 -0
- package/dist/cjs/FlowRuntime/FlowCycleDetected.js +49 -0
- package/dist/cjs/FlowRuntime/FlowCycleDetected.js.map +7 -0
- package/dist/cjs/FlowRuntime/FlowExecutionNotFound.d.ts +38 -0
- package/dist/cjs/FlowRuntime/FlowExecutionNotFound.d.ts.map +1 -0
- package/dist/cjs/FlowRuntime/FlowExecutionNotFound.js +53 -0
- package/dist/cjs/FlowRuntime/FlowExecutionNotFound.js.map +7 -0
- package/dist/cjs/FlowRuntime/FlowInstance.d.ts +115 -0
- package/dist/cjs/FlowRuntime/FlowInstance.d.ts.map +1 -0
- package/dist/cjs/FlowRuntime/FlowInstance.js +37 -0
- package/dist/cjs/FlowRuntime/FlowInstance.js.map +7 -0
- package/dist/cjs/FlowRuntime/FlowRuntime.d.ts +204 -0
- package/dist/cjs/FlowRuntime/FlowRuntime.d.ts.map +1 -0
- package/dist/cjs/FlowRuntime/FlowRuntime.js +37 -0
- package/dist/cjs/FlowRuntime/FlowRuntime.js.map +7 -0
- package/dist/cjs/FlowRuntime/NodeRecord.d.ts +177 -0
- package/dist/cjs/FlowRuntime/NodeRecord.d.ts.map +1 -0
- package/dist/cjs/FlowRuntime/NodeRecord.js +17 -0
- package/dist/cjs/FlowRuntime/NodeRecord.js.map +7 -0
- package/dist/cjs/FlowRuntime/WaitingAnnotation.d.ts +69 -0
- package/dist/cjs/FlowRuntime/WaitingAnnotation.d.ts.map +1 -0
- package/dist/cjs/FlowRuntime/WaitingAnnotation.js +53 -0
- package/dist/cjs/FlowRuntime/WaitingAnnotation.js.map +7 -0
- package/dist/cjs/FlowRuntime/index.d.ts +14 -0
- package/dist/cjs/FlowRuntime/index.d.ts.map +1 -0
- package/dist/cjs/FlowRuntime/index.js +26 -0
- package/dist/cjs/FlowRuntime/index.js.map +7 -0
- package/dist/cjs/Graph.d.ts +325 -0
- package/dist/cjs/Graph.d.ts.map +1 -0
- package/dist/cjs/Graph.js +1020 -0
- package/dist/cjs/Graph.js.map +7 -0
- package/dist/cjs/HumanTask.d.ts +442 -0
- package/dist/cjs/HumanTask.d.ts.map +1 -0
- package/dist/cjs/HumanTask.js +413 -0
- package/dist/cjs/HumanTask.js.map +7 -0
- package/dist/cjs/Interpreter.d.ts +223 -0
- package/dist/cjs/Interpreter.d.ts.map +1 -0
- package/dist/cjs/Interpreter.js +908 -0
- package/dist/cjs/Interpreter.js.map +7 -0
- package/dist/cjs/Poll.d.ts +240 -0
- package/dist/cjs/Poll.d.ts.map +1 -0
- package/dist/cjs/Poll.js +154 -0
- package/dist/cjs/Poll.js.map +7 -0
- package/dist/cjs/RetryPolicy.d.ts +273 -0
- package/dist/cjs/RetryPolicy.d.ts.map +1 -0
- package/dist/cjs/RetryPolicy.js +251 -0
- package/dist/cjs/RetryPolicy.js.map +7 -0
- package/dist/cjs/Sleep.d.ts +98 -0
- package/dist/cjs/Sleep.d.ts.map +1 -0
- package/dist/cjs/Sleep.js +141 -0
- package/dist/cjs/Sleep.js.map +7 -0
- package/dist/cjs/Stall.d.ts +173 -0
- package/dist/cjs/Stall.d.ts.map +1 -0
- package/dist/cjs/Stall.js +92 -0
- package/dist/cjs/Stall.js.map +7 -0
- package/dist/cjs/WaitFor.d.ts +109 -0
- package/dist/cjs/WaitFor.d.ts.map +1 -0
- package/dist/cjs/WaitFor.js +117 -0
- package/dist/cjs/WaitFor.js.map +7 -0
- package/dist/cjs/index.d.ts +107 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +69 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/BoundedJson.d.ts +48 -0
- package/dist/cjs/internal/BoundedJson.d.ts.map +1 -0
- package/dist/cjs/internal/BoundedJson.js +96 -0
- package/dist/cjs/internal/BoundedJson.js.map +7 -0
- package/dist/cjs/internal/DeclarationSite.d.ts +135 -0
- package/dist/cjs/internal/DeclarationSite.d.ts.map +1 -0
- package/dist/cjs/internal/DeclarationSite.js +89 -0
- package/dist/cjs/internal/DeclarationSite.js.map +7 -0
- package/dist/cjs/internal/Declarations.d.ts +35 -0
- package/dist/cjs/internal/Declarations.d.ts.map +1 -0
- package/dist/cjs/internal/Declarations.js +50 -0
- package/dist/cjs/internal/Declarations.js.map +7 -0
- package/dist/cjs/internal/ExecutionMiddleware.d.ts +21 -0
- package/dist/cjs/internal/ExecutionMiddleware.d.ts.map +1 -0
- package/dist/cjs/internal/ExecutionMiddleware.js +39 -0
- package/dist/cjs/internal/ExecutionMiddleware.js.map +7 -0
- package/dist/cjs/internal/JsonSchemaSubset.d.ts +133 -0
- package/dist/cjs/internal/JsonSchemaSubset.d.ts.map +1 -0
- package/dist/cjs/internal/JsonSchemaSubset.js +229 -0
- package/dist/cjs/internal/JsonSchemaSubset.js.map +7 -0
- package/dist/cjs/internal/OutcomeMarker.d.ts +18 -0
- package/dist/cjs/internal/OutcomeMarker.d.ts.map +1 -0
- package/dist/cjs/internal/OutcomeMarker.js +27 -0
- package/dist/cjs/internal/OutcomeMarker.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/Action/Action.d.ts +250 -0
- package/dist/esm/Action/Action.d.ts.map +1 -0
- package/dist/esm/Action/Action.js +30 -0
- package/dist/esm/Action/Action.js.map +1 -0
- package/dist/esm/Action/AttemptTimedOut.d.ts +33 -0
- package/dist/esm/Action/AttemptTimedOut.d.ts.map +1 -0
- package/dist/esm/Action/AttemptTimedOut.js +32 -0
- package/dist/esm/Action/AttemptTimedOut.js.map +1 -0
- package/dist/esm/Action/BoundaryMode.d.ts +29 -0
- package/dist/esm/Action/BoundaryMode.d.ts.map +1 -0
- package/dist/esm/Action/BoundaryMode.js +23 -0
- package/dist/esm/Action/BoundaryMode.js.map +1 -0
- package/dist/esm/Action/CacheEnvironment.d.ts +158 -0
- package/dist/esm/Action/CacheEnvironment.d.ts.map +1 -0
- package/dist/esm/Action/CacheEnvironment.js +130 -0
- package/dist/esm/Action/CacheEnvironment.js.map +1 -0
- package/dist/esm/Action/ConcurrentKeylessDispatch.d.ts +34 -0
- package/dist/esm/Action/ConcurrentKeylessDispatch.d.ts.map +1 -0
- package/dist/esm/Action/ConcurrentKeylessDispatch.js +33 -0
- package/dist/esm/Action/ConcurrentKeylessDispatch.js.map +1 -0
- package/dist/esm/Action/Context.d.ts +131 -0
- package/dist/esm/Action/Context.d.ts.map +1 -0
- package/dist/esm/Action/Context.js +99 -0
- package/dist/esm/Action/Context.js.map +1 -0
- package/dist/esm/Action/DuplicateImplementation.d.ts +20 -0
- package/dist/esm/Action/DuplicateImplementation.d.ts.map +1 -0
- package/dist/esm/Action/DuplicateImplementation.js +20 -0
- package/dist/esm/Action/DuplicateImplementation.js.map +1 -0
- package/dist/esm/Action/FileBoundary.d.ts +59 -0
- package/dist/esm/Action/FileBoundary.d.ts.map +1 -0
- package/dist/esm/Action/FileBoundary.js +60 -0
- package/dist/esm/Action/FileBoundary.js.map +1 -0
- package/dist/esm/Action/FileInput.d.ts +28 -0
- package/dist/esm/Action/FileInput.d.ts.map +1 -0
- package/dist/esm/Action/FileInput.js +32 -0
- package/dist/esm/Action/FileInput.js.map +1 -0
- package/dist/esm/Action/Filegroup.d.ts +16 -0
- package/dist/esm/Action/Filegroup.d.ts.map +1 -0
- package/dist/esm/Action/Filegroup.js +15 -0
- package/dist/esm/Action/Filegroup.js.map +1 -0
- package/dist/esm/Action/Glob.d.ts +8 -0
- package/dist/esm/Action/Glob.d.ts.map +1 -0
- package/dist/esm/Action/Glob.js +7 -0
- package/dist/esm/Action/Glob.js.map +1 -0
- package/dist/esm/Action/ImplementationVersionMismatch.d.ts +26 -0
- package/dist/esm/Action/ImplementationVersionMismatch.d.ts.map +1 -0
- package/dist/esm/Action/ImplementationVersionMismatch.js +24 -0
- package/dist/esm/Action/ImplementationVersionMismatch.js.map +1 -0
- package/dist/esm/Action/Implementations.d.ts +114 -0
- package/dist/esm/Action/Implementations.d.ts.map +1 -0
- package/dist/esm/Action/Implementations.js +94 -0
- package/dist/esm/Action/Implementations.js.map +1 -0
- package/dist/esm/Action/InfraInterrupt.d.ts +26 -0
- package/dist/esm/Action/InfraInterrupt.d.ts.map +1 -0
- package/dist/esm/Action/InfraInterrupt.js +25 -0
- package/dist/esm/Action/InfraInterrupt.js.map +1 -0
- package/dist/esm/Action/InfraInterruptRetriesExhausted.d.ts +33 -0
- package/dist/esm/Action/InfraInterruptRetriesExhausted.d.ts.map +1 -0
- package/dist/esm/Action/InfraInterruptRetriesExhausted.js +32 -0
- package/dist/esm/Action/InfraInterruptRetriesExhausted.js.map +1 -0
- package/dist/esm/Action/IrreversibleRetryRequiresIdempotencyKey.d.ts +26 -0
- package/dist/esm/Action/IrreversibleRetryRequiresIdempotencyKey.d.ts.map +1 -0
- package/dist/esm/Action/IrreversibleRetryRequiresIdempotencyKey.js +25 -0
- package/dist/esm/Action/IrreversibleRetryRequiresIdempotencyKey.js.map +1 -0
- package/dist/esm/Action/StepIdentity.d.ts +153 -0
- package/dist/esm/Action/StepIdentity.d.ts.map +1 -0
- package/dist/esm/Action/StepIdentity.js +139 -0
- package/dist/esm/Action/StepIdentity.js.map +1 -0
- package/dist/esm/Action/TreeArtifact.d.ts +8 -0
- package/dist/esm/Action/TreeArtifact.d.ts.map +1 -0
- package/dist/esm/Action/TreeArtifact.js +7 -0
- package/dist/esm/Action/TreeArtifact.js.map +1 -0
- package/dist/esm/Action/TypeId.d.ts +8 -0
- package/dist/esm/Action/TypeId.d.ts.map +1 -0
- package/dist/esm/Action/TypeId.js +9 -0
- package/dist/esm/Action/TypeId.js.map +1 -0
- package/dist/esm/Action/UncanonicalIdempotencyKey.d.ts +32 -0
- package/dist/esm/Action/UncanonicalIdempotencyKey.d.ts.map +1 -0
- package/dist/esm/Action/UncanonicalIdempotencyKey.js +31 -0
- package/dist/esm/Action/UncanonicalIdempotencyKey.js.map +1 -0
- package/dist/esm/Action/idempotencyKey.d.ts +21 -0
- package/dist/esm/Action/idempotencyKey.d.ts.map +1 -0
- package/dist/esm/Action/idempotencyKey.js +50 -0
- package/dist/esm/Action/idempotencyKey.js.map +1 -0
- package/dist/esm/Action/index.d.ts +29 -0
- package/dist/esm/Action/index.d.ts.map +1 -0
- package/dist/esm/Action/index.js +30 -0
- package/dist/esm/Action/index.js.map +1 -0
- package/dist/esm/Action/make.d.ts +128 -0
- package/dist/esm/Action/make.d.ts.map +1 -0
- package/dist/esm/Action/make.js +413 -0
- package/dist/esm/Action/make.js.map +1 -0
- package/dist/esm/Action/raceAll.d.ts +21 -0
- package/dist/esm/Action/raceAll.d.ts.map +1 -0
- package/dist/esm/Action/raceAll.js +20 -0
- package/dist/esm/Action/raceAll.js.map +1 -0
- package/dist/esm/Action/retry.d.ts +19 -0
- package/dist/esm/Action/retry.d.ts.map +1 -0
- package/dist/esm/Action/retry.js +72 -0
- package/dist/esm/Action/retry.js.map +1 -0
- package/dist/esm/Deadline.d.ts +110 -0
- package/dist/esm/Deadline.d.ts.map +1 -0
- package/dist/esm/Deadline.js +164 -0
- package/dist/esm/Deadline.js.map +1 -0
- package/dist/esm/DurableClock.d.ts +60 -0
- package/dist/esm/DurableClock.d.ts.map +1 -0
- package/dist/esm/DurableClock.js +122 -0
- package/dist/esm/DurableClock.js.map +1 -0
- package/dist/esm/DurableDeferred.d.ts +311 -0
- package/dist/esm/DurableDeferred.d.ts.map +1 -0
- package/dist/esm/DurableDeferred.js +357 -0
- package/dist/esm/DurableDeferred.js.map +1 -0
- package/dist/esm/DurableQueue.d.ts +160 -0
- package/dist/esm/DurableQueue.d.ts.map +1 -0
- package/dist/esm/DurableQueue.js +303 -0
- package/dist/esm/DurableQueue.js.map +1 -0
- package/dist/esm/ExternalJob.d.ts +179 -0
- package/dist/esm/ExternalJob.d.ts.map +1 -0
- package/dist/esm/ExternalJob.js +296 -0
- package/dist/esm/ExternalJob.js.map +1 -0
- package/dist/esm/Fault.d.ts +131 -0
- package/dist/esm/Fault.d.ts.map +1 -0
- package/dist/esm/Fault.js +198 -0
- package/dist/esm/Fault.js.map +1 -0
- package/dist/esm/Flow/Annotations.d.ts +245 -0
- package/dist/esm/Flow/Annotations.d.ts.map +1 -0
- package/dist/esm/Flow/Annotations.js +110 -0
- package/dist/esm/Flow/Annotations.js.map +1 -0
- package/dist/esm/Flow/CapabilityCeiling.d.ts +21 -0
- package/dist/esm/Flow/CapabilityCeiling.d.ts.map +1 -0
- package/dist/esm/Flow/CapabilityCeiling.js +27 -0
- package/dist/esm/Flow/CapabilityCeiling.js.map +1 -0
- package/dist/esm/Flow/DeadlineExceeded.d.ts +33 -0
- package/dist/esm/Flow/DeadlineExceeded.d.ts.map +1 -0
- package/dist/esm/Flow/DeadlineExceeded.js +34 -0
- package/dist/esm/Flow/DeadlineExceeded.js.map +1 -0
- package/dist/esm/Flow/ExecutionIdRequired.d.ts +25 -0
- package/dist/esm/Flow/ExecutionIdRequired.d.ts.map +1 -0
- package/dist/esm/Flow/ExecutionIdRequired.js +30 -0
- package/dist/esm/Flow/ExecutionIdRequired.js.map +1 -0
- package/dist/esm/Flow/ExecutionIds.d.ts +80 -0
- package/dist/esm/Flow/ExecutionIds.d.ts.map +1 -0
- package/dist/esm/Flow/ExecutionIds.js +91 -0
- package/dist/esm/Flow/ExecutionIds.js.map +1 -0
- package/dist/esm/Flow/Flow.d.ts +422 -0
- package/dist/esm/Flow/Flow.d.ts.map +1 -0
- package/dist/esm/Flow/Flow.js +3 -0
- package/dist/esm/Flow/Flow.js.map +1 -0
- package/dist/esm/Flow/MaxRoundsExceeded.d.ts +35 -0
- package/dist/esm/Flow/MaxRoundsExceeded.d.ts.map +1 -0
- package/dist/esm/Flow/MaxRoundsExceeded.js +34 -0
- package/dist/esm/Flow/MaxRoundsExceeded.js.map +1 -0
- package/dist/esm/Flow/Outcome.d.ts +162 -0
- package/dist/esm/Flow/Outcome.d.ts.map +1 -0
- package/dist/esm/Flow/Outcome.js +115 -0
- package/dist/esm/Flow/Outcome.js.map +1 -0
- package/dist/esm/Flow/Result.d.ts +186 -0
- package/dist/esm/Flow/Result.d.ts.map +1 -0
- package/dist/esm/Flow/Result.js +171 -0
- package/dist/esm/Flow/Result.js.map +1 -0
- package/dist/esm/Flow/Runtime.d.ts +98 -0
- package/dist/esm/Flow/Runtime.d.ts.map +1 -0
- package/dist/esm/Flow/Runtime.js +252 -0
- package/dist/esm/Flow/Runtime.js.map +1 -0
- package/dist/esm/Flow/TypeId.d.ts +8 -0
- package/dist/esm/Flow/TypeId.d.ts.map +1 -0
- package/dist/esm/Flow/TypeId.js +9 -0
- package/dist/esm/Flow/TypeId.js.map +1 -0
- package/dist/esm/Flow/index.d.ts +17 -0
- package/dist/esm/Flow/index.d.ts.map +1 -0
- package/dist/esm/Flow/index.js +18 -0
- package/dist/esm/Flow/index.js.map +1 -0
- package/dist/esm/Flow/internal.d.ts +34 -0
- package/dist/esm/Flow/internal.d.ts.map +1 -0
- package/dist/esm/Flow/internal.js +149 -0
- package/dist/esm/Flow/internal.js.map +1 -0
- package/dist/esm/Flow/make.d.ts +135 -0
- package/dist/esm/Flow/make.d.ts.map +1 -0
- package/dist/esm/Flow/make.js +111 -0
- package/dist/esm/Flow/make.js.map +1 -0
- package/dist/esm/FlowRuntime/CancelRequestFailed.d.ts +55 -0
- package/dist/esm/FlowRuntime/CancelRequestFailed.d.ts.map +1 -0
- package/dist/esm/FlowRuntime/CancelRequestFailed.js +53 -0
- package/dist/esm/FlowRuntime/CancelRequestFailed.js.map +1 -0
- package/dist/esm/FlowRuntime/ExecutionIdentityConflict.d.ts +23 -0
- package/dist/esm/FlowRuntime/ExecutionIdentityConflict.d.ts.map +1 -0
- package/dist/esm/FlowRuntime/ExecutionIdentityConflict.js +24 -0
- package/dist/esm/FlowRuntime/ExecutionIdentityConflict.js.map +1 -0
- package/dist/esm/FlowRuntime/FlowCycleDetected.d.ts +28 -0
- package/dist/esm/FlowRuntime/FlowCycleDetected.d.ts.map +1 -0
- package/dist/esm/FlowRuntime/FlowCycleDetected.js +35 -0
- package/dist/esm/FlowRuntime/FlowCycleDetected.js.map +1 -0
- package/dist/esm/FlowRuntime/FlowExecutionNotFound.d.ts +38 -0
- package/dist/esm/FlowRuntime/FlowExecutionNotFound.d.ts.map +1 -0
- package/dist/esm/FlowRuntime/FlowExecutionNotFound.js +40 -0
- package/dist/esm/FlowRuntime/FlowExecutionNotFound.js.map +1 -0
- package/dist/esm/FlowRuntime/FlowInstance.d.ts +115 -0
- package/dist/esm/FlowRuntime/FlowInstance.d.ts.map +1 -0
- package/dist/esm/FlowRuntime/FlowInstance.js +24 -0
- package/dist/esm/FlowRuntime/FlowInstance.js.map +1 -0
- package/dist/esm/FlowRuntime/FlowRuntime.d.ts +204 -0
- package/dist/esm/FlowRuntime/FlowRuntime.d.ts.map +1 -0
- package/dist/esm/FlowRuntime/FlowRuntime.js +34 -0
- package/dist/esm/FlowRuntime/FlowRuntime.js.map +1 -0
- package/dist/esm/FlowRuntime/NodeRecord.d.ts +177 -0
- package/dist/esm/FlowRuntime/NodeRecord.d.ts.map +1 -0
- package/dist/esm/FlowRuntime/NodeRecord.js +21 -0
- package/dist/esm/FlowRuntime/NodeRecord.js.map +1 -0
- package/dist/esm/FlowRuntime/WaitingAnnotation.d.ts +69 -0
- package/dist/esm/FlowRuntime/WaitingAnnotation.d.ts.map +1 -0
- package/dist/esm/FlowRuntime/WaitingAnnotation.js +53 -0
- package/dist/esm/FlowRuntime/WaitingAnnotation.js.map +1 -0
- package/dist/esm/FlowRuntime/index.d.ts +14 -0
- package/dist/esm/FlowRuntime/index.d.ts.map +1 -0
- package/dist/esm/FlowRuntime/index.js +15 -0
- package/dist/esm/FlowRuntime/index.js.map +1 -0
- package/dist/esm/Graph.d.ts +325 -0
- package/dist/esm/Graph.d.ts.map +1 -0
- package/dist/esm/Graph.js +1485 -0
- package/dist/esm/Graph.js.map +1 -0
- package/dist/esm/HumanTask.d.ts +442 -0
- package/dist/esm/HumanTask.d.ts.map +1 -0
- package/dist/esm/HumanTask.js +798 -0
- package/dist/esm/HumanTask.js.map +1 -0
- package/dist/esm/Interpreter.d.ts +223 -0
- package/dist/esm/Interpreter.d.ts.map +1 -0
- package/dist/esm/Interpreter.js +1289 -0
- package/dist/esm/Interpreter.js.map +1 -0
- package/dist/esm/Poll.d.ts +240 -0
- package/dist/esm/Poll.d.ts.map +1 -0
- package/dist/esm/Poll.js +289 -0
- package/dist/esm/Poll.js.map +1 -0
- package/dist/esm/RetryPolicy.d.ts +273 -0
- package/dist/esm/RetryPolicy.d.ts.map +1 -0
- package/dist/esm/RetryPolicy.js +429 -0
- package/dist/esm/RetryPolicy.js.map +1 -0
- package/dist/esm/Sleep.d.ts +98 -0
- package/dist/esm/Sleep.d.ts.map +1 -0
- package/dist/esm/Sleep.js +256 -0
- package/dist/esm/Sleep.js.map +1 -0
- package/dist/esm/Stall.d.ts +173 -0
- package/dist/esm/Stall.d.ts.map +1 -0
- package/dist/esm/Stall.js +138 -0
- package/dist/esm/Stall.js.map +1 -0
- package/dist/esm/WaitFor.d.ts +109 -0
- package/dist/esm/WaitFor.d.ts.map +1 -0
- package/dist/esm/WaitFor.js +184 -0
- package/dist/esm/WaitFor.js.map +1 -0
- package/dist/esm/index.d.ts +107 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +108 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/BoundedJson.d.ts +48 -0
- package/dist/esm/internal/BoundedJson.d.ts.map +1 -0
- package/dist/esm/internal/BoundedJson.js +107 -0
- package/dist/esm/internal/BoundedJson.js.map +1 -0
- package/dist/esm/internal/DeclarationSite.d.ts +135 -0
- package/dist/esm/internal/DeclarationSite.d.ts.map +1 -0
- package/dist/esm/internal/DeclarationSite.js +196 -0
- package/dist/esm/internal/DeclarationSite.js.map +1 -0
- package/dist/esm/internal/Declarations.d.ts +35 -0
- package/dist/esm/internal/Declarations.d.ts.map +1 -0
- package/dist/esm/internal/Declarations.js +43 -0
- package/dist/esm/internal/Declarations.js.map +1 -0
- package/dist/esm/internal/ExecutionMiddleware.d.ts +21 -0
- package/dist/esm/internal/ExecutionMiddleware.d.ts.map +1 -0
- package/dist/esm/internal/ExecutionMiddleware.js +13 -0
- package/dist/esm/internal/ExecutionMiddleware.js.map +1 -0
- package/dist/esm/internal/JsonSchemaSubset.d.ts +133 -0
- package/dist/esm/internal/JsonSchemaSubset.d.ts.map +1 -0
- package/dist/esm/internal/JsonSchemaSubset.js +363 -0
- package/dist/esm/internal/JsonSchemaSubset.js.map +1 -0
- package/dist/esm/internal/OutcomeMarker.d.ts +18 -0
- package/dist/esm/internal/OutcomeMarker.d.ts.map +1 -0
- package/dist/esm/internal/OutcomeMarker.js +18 -0
- package/dist/esm/internal/OutcomeMarker.js.map +1 -0
- package/docs/README.md +152 -0
- package/docs/api.md +440 -0
- package/docs/concepts/bodies-and-plans.md +167 -0
- package/docs/concepts/execution-identity.md +142 -0
- package/docs/concepts/flows-and-actions.md +129 -0
- package/docs/concepts/suspension-and-replay.md +130 -0
- package/docs/concepts/the-runtime-port.md +110 -0
- package/docs/concepts/trampoline-rounds.md +151 -0
- package/docs/guides/ask-a-person.md +184 -0
- package/docs/guides/build-a-body.md +164 -0
- package/docs/guides/cancel-and-roll-back.md +112 -0
- package/docs/guides/implement-an-action.md +155 -0
- package/docs/guides/inspect-the-plan.md +235 -0
- package/docs/guides/poll-until-ready.md +169 -0
- package/docs/guides/queue-work-to-a-worker.md +122 -0
- package/docs/guides/retry-a-failing-action.md +243 -0
- package/docs/guides/reuse-a-recorded-result.md +129 -0
- package/docs/guides/run-a-child-flow.md +108 -0
- package/docs/guides/run-an-external-job.md +86 -0
- package/docs/guides/use-a-prompt.md +38 -0
- package/docs/guides/wait-for-a-deadline.md +141 -0
- package/docs/guides/wait-for-an-external-signal.md +151 -0
- package/docs/installation.md +87 -0
- package/docs/quickstart.md +164 -0
- package/docs/reference/flow.md +1835 -0
- package/docs/testing.md +157 -0
- package/docs/troubleshooting.md +286 -0
- package/package.json +327 -3
- package/src/Action/Action.ts +333 -0
- package/src/Action/AttemptTimedOut.ts +37 -0
- package/src/Action/BoundaryMode.ts +33 -0
- package/src/Action/CacheEnvironment.ts +170 -0
- package/src/Action/ConcurrentKeylessDispatch.ts +38 -0
- package/src/Action/Context.ts +156 -0
- package/src/Action/DuplicateImplementation.ts +24 -0
- package/src/Action/FileBoundary.ts +77 -0
- package/src/Action/FileInput.ts +42 -0
- package/src/Action/Filegroup.ts +16 -0
- package/src/Action/Glob.ts +8 -0
- package/src/Action/ImplementationVersionMismatch.ts +27 -0
- package/src/Action/Implementations.ts +149 -0
- package/src/Action/InfraInterrupt.ts +30 -0
- package/src/Action/InfraInterruptRetriesExhausted.ts +37 -0
- package/src/Action/IrreversibleRetryRequiresIdempotencyKey.ts +32 -0
- package/src/Action/StepIdentity.ts +219 -0
- package/src/Action/TreeArtifact.ts +8 -0
- package/src/Action/TypeId.ts +9 -0
- package/src/Action/UncanonicalIdempotencyKey.ts +36 -0
- package/src/Action/idempotencyKey.ts +67 -0
- package/src/Action/index.ts +31 -0
- package/src/Action/make.ts +671 -0
- package/src/Action/raceAll.ts +48 -0
- package/src/Action/retry.ts +92 -0
- package/src/Deadline.ts +201 -0
- package/src/DurableClock.ts +176 -0
- package/src/DurableDeferred.ts +753 -0
- package/src/DurableQueue.ts +519 -0
- package/src/ExternalJob.ts +437 -0
- package/src/Fault.ts +279 -0
- package/src/Flow/Annotations.ts +151 -0
- package/src/Flow/CapabilityCeiling.ts +37 -0
- package/src/Flow/DeadlineExceeded.ts +40 -0
- package/src/Flow/ExecutionIdRequired.ts +36 -0
- package/src/Flow/ExecutionIds.ts +133 -0
- package/src/Flow/Flow.ts +576 -0
- package/src/Flow/MaxRoundsExceeded.ts +39 -0
- package/src/Flow/Outcome.ts +179 -0
- package/src/Flow/Result.ts +284 -0
- package/src/Flow/Runtime.ts +339 -0
- package/src/Flow/TypeId.ts +9 -0
- package/src/Flow/index.ts +19 -0
- package/src/Flow/internal.ts +237 -0
- package/src/Flow/make.ts +285 -0
- package/src/FlowRuntime/CancelRequestFailed.ts +56 -0
- package/src/FlowRuntime/ExecutionIdentityConflict.ts +32 -0
- package/src/FlowRuntime/FlowCycleDetected.ts +41 -0
- package/src/FlowRuntime/FlowExecutionNotFound.ts +46 -0
- package/src/FlowRuntime/FlowInstance.ts +128 -0
- package/src/FlowRuntime/FlowRuntime.ts +339 -0
- package/src/FlowRuntime/NodeRecord.ts +185 -0
- package/src/FlowRuntime/WaitingAnnotation.ts +85 -0
- package/src/FlowRuntime/index.ts +17 -0
- package/src/Graph.ts +1865 -0
- package/src/HumanTask.ts +1007 -0
- package/src/Interpreter.ts +1620 -0
- package/src/Poll.ts +420 -0
- package/src/RetryPolicy.ts +550 -0
- package/src/Sleep.ts +296 -0
- package/src/Stall.ts +217 -0
- package/src/WaitFor.ts +228 -0
- package/src/index.ts +125 -0
- package/src/internal/BoundedJson.ts +109 -0
- package/src/internal/DeclarationSite.ts +214 -0
- package/src/internal/Declarations.ts +49 -0
- package/src/internal/ExecutionMiddleware.ts +29 -0
- package/src/internal/JsonSchemaSubset.ts +392 -0
- package/src/internal/OutcomeMarker.ts +19 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
// Deep reviewed and polished by a human on 2026-08-10.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Runtime helpers for flow completion, suspension, scopes, and rollback.
|
|
5
|
+
*
|
|
6
|
+
* @since 0.1.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as Arr from "effect/Array"
|
|
10
|
+
import * as Cause from "effect/Cause"
|
|
11
|
+
import * as Context from "effect/Context"
|
|
12
|
+
import * as Effect from "effect/Effect"
|
|
13
|
+
import * as Exit from "effect/Exit"
|
|
14
|
+
import * as Fiber from "effect/Fiber"
|
|
15
|
+
import * as Filter from "effect/Filter"
|
|
16
|
+
import { dual, identity } from "effect/Function"
|
|
17
|
+
import * as Scope from "effect/Scope"
|
|
18
|
+
import { FlowInstance } from "../FlowRuntime/FlowInstance.ts"
|
|
19
|
+
import { CaptureDefects, SuspendOnFailure } from "./Annotations.ts"
|
|
20
|
+
import { Complete, isResult, type Result, Suspended } from "./Result.ts"
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Runs an effect as a flow execution and converts its outcome into a
|
|
24
|
+
* `Result`, handling suspension, defect capture, interruption, and flow
|
|
25
|
+
* scope finalization.
|
|
26
|
+
*
|
|
27
|
+
* @category results
|
|
28
|
+
* @since 0.1.0
|
|
29
|
+
*/
|
|
30
|
+
export const intoResult = <A, E, R>(
|
|
31
|
+
effect: Effect.Effect<A, E, R>
|
|
32
|
+
): Effect.Effect<
|
|
33
|
+
Result<A, E>,
|
|
34
|
+
never,
|
|
35
|
+
Exclude<R, Scope.Scope> | FlowInstance
|
|
36
|
+
> =>
|
|
37
|
+
Effect.contextWith((context: Context.Context<FlowInstance>) => {
|
|
38
|
+
const instance = Context.get(context, FlowInstance)
|
|
39
|
+
const captureDefects = Context.get(instance.flow.annotations, CaptureDefects)
|
|
40
|
+
const suspendOnFailure = Context.get(instance.flow.annotations, SuspendOnFailure)
|
|
41
|
+
return effect.pipe(
|
|
42
|
+
// Acquire the child and install cleanup atomically. A body can signal
|
|
43
|
+
// readiness before forkChild returns; interruption there must still
|
|
44
|
+
// collect its cleanup failure instead of leaving it to supervision.
|
|
45
|
+
(body) =>
|
|
46
|
+
Effect.acquireUseRelease(
|
|
47
|
+
Effect.forkChild(Effect.interruptible(body), { startImmediately: true }),
|
|
48
|
+
(fiber) => Effect.interruptible(Fiber.join(fiber)),
|
|
49
|
+
(fiber, joined) => {
|
|
50
|
+
if (Exit.isSuccess(joined) || !Cause.hasInterruptsOnly(joined.cause)) return Effect.void
|
|
51
|
+
return Effect.gen(function*() {
|
|
52
|
+
yield* Fiber.interrupt(fiber)
|
|
53
|
+
const exit = yield* Fiber.await(fiber)
|
|
54
|
+
if (Exit.isFailure(exit)) {
|
|
55
|
+
const cleanup = exit.cause.reasons.filter((reason) => !Cause.isInterruptReason(reason))
|
|
56
|
+
if (cleanup.length > 0) {
|
|
57
|
+
return yield* Effect.failCause(
|
|
58
|
+
Cause.fromReasons<never>(
|
|
59
|
+
cleanup.map((reason) => Cause.isFailReason(reason) ? Cause.makeDieReason(reason.error) : reason)
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
Effect.interruptible,
|
|
68
|
+
suspendOnFailure
|
|
69
|
+
? Effect.catchCause((cause) => {
|
|
70
|
+
instance.suspended = true
|
|
71
|
+
if (!Cause.hasInterruptsOnly(cause)) {
|
|
72
|
+
instance.cause = Cause.die(Cause.squash(cause))
|
|
73
|
+
}
|
|
74
|
+
return Effect.interrupt
|
|
75
|
+
})
|
|
76
|
+
: identity,
|
|
77
|
+
Effect.scoped,
|
|
78
|
+
Effect.matchCauseEffect({
|
|
79
|
+
// A body that handed off produced no answer of its own, so the slot
|
|
80
|
+
// the handoff was recorded in wins over the value the handler returned
|
|
81
|
+
// (`docs/concepts/trampoline-rounds.md`).
|
|
82
|
+
onSuccess: (value) =>
|
|
83
|
+
Effect.succeed(
|
|
84
|
+
instance.handoff ?? new Complete({ exit: Exit.succeed(value) })
|
|
85
|
+
),
|
|
86
|
+
onFailure: (cause): Effect.Effect<Result<A, E>> => {
|
|
87
|
+
const [interrupts, reasons] = Arr.partition(
|
|
88
|
+
cause.reasons,
|
|
89
|
+
Filter.fromPredicate(Cause.isInterruptReason)
|
|
90
|
+
)
|
|
91
|
+
const hasInterruptsOnly = interrupts.length === cause.reasons.length
|
|
92
|
+
// A captured failure is a successful Result. Returning it while the
|
|
93
|
+
// caller is stopping discards that value at interrupt restoration.
|
|
94
|
+
// Keep failed cleanup on the cause channel until it reaches the caller.
|
|
95
|
+
if (interrupts.length > 0 && !hasInterruptsOnly) {
|
|
96
|
+
return Effect.failCause(Cause.fromReasons<never>(cause.reasons.map((reason) =>
|
|
97
|
+
Cause.isFailReason(reason) ? Cause.makeDieReason(reason.error) : reason
|
|
98
|
+
)))
|
|
99
|
+
}
|
|
100
|
+
const filtered = reasons.length === 0 ? cause : Cause.fromReasons(reasons)
|
|
101
|
+
return instance.suspended && hasInterruptsOnly
|
|
102
|
+
? Effect.succeed(new Suspended({ cause: instance.cause }))
|
|
103
|
+
: (!instance.interrupted && hasInterruptsOnly) ||
|
|
104
|
+
(!captureDefects && Cause.hasDies(cause))
|
|
105
|
+
? Effect.failCause(filtered as Cause.Cause<never>)
|
|
106
|
+
: Effect.succeed(new Complete({ exit: Exit.failCause(filtered) }))
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
(eff) =>
|
|
110
|
+
Effect.onExitPrimitive(eff, (exit) => {
|
|
111
|
+
if (Exit.isFailure(exit)) {
|
|
112
|
+
return Scope.close(instance.scope, exit)
|
|
113
|
+
} else if (exit.value._tag === "Complete") {
|
|
114
|
+
return Scope.close(instance.scope, exit.value.exit)
|
|
115
|
+
} else if (exit.value._tag === "Handoff") {
|
|
116
|
+
// A handoff ends this round for good — the next round is a separate
|
|
117
|
+
// execution with its own instance and its own scope — so the round's
|
|
118
|
+
// scope closes here exactly as a completion closes it. A suspension
|
|
119
|
+
// is the only settlement that keeps the scope open.
|
|
120
|
+
return Scope.close(instance.scope, Exit.void)
|
|
121
|
+
}
|
|
122
|
+
return Effect.void
|
|
123
|
+
}, true),
|
|
124
|
+
Effect.uninterruptible
|
|
125
|
+
)
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The action regions open on the current fiber's dynamic call stack.
|
|
130
|
+
*
|
|
131
|
+
* `actionState.count` says how many regions are open on an instance; it does
|
|
132
|
+
* not say which of them the current region is nested inside. That difference is
|
|
133
|
+
* the whole of {@link wrapActionResult}'s liveness: a region that suspends
|
|
134
|
+
* waits for the *other* open regions to settle, and an enclosing region can
|
|
135
|
+
* never settle before the region inside it returns. Carrying the enclosing
|
|
136
|
+
* instances in the context is what lets a suspension tell a sibling — which
|
|
137
|
+
* will settle — from an ancestor, which is waiting on the very fiber that is
|
|
138
|
+
* waiting on it.
|
|
139
|
+
*
|
|
140
|
+
* It is a context reference rather than a fiber-local counter because the chain
|
|
141
|
+
* crosses fibers: {@link intoResult} forks the body, and an engine gives every
|
|
142
|
+
* action dispatch a fiber of its own. Context propagates to forked children;
|
|
143
|
+
* a per-fiber counter would restart at each fork and read every ancestor as a
|
|
144
|
+
* sibling again.
|
|
145
|
+
*/
|
|
146
|
+
const EnclosingActions = Context.Reference<ReadonlyArray<FlowInstance["Service"]>>(
|
|
147
|
+
"@smthrs/flow/Flow/EnclosingActions",
|
|
148
|
+
{ defaultValue: () => [] }
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Wraps an action-like effect so flow suspension waits for currently
|
|
153
|
+
* running actions to finish or suspend.
|
|
154
|
+
*
|
|
155
|
+
* The wait is for *siblings*. An action that suspends holds work its siblings
|
|
156
|
+
* have not journaled yet, so the flow must not park out from under them; an
|
|
157
|
+
* enclosing region holds no such work, because everything it is doing is this
|
|
158
|
+
* region. Waiting for one is a deadlock, and it was a real one: a harness cell
|
|
159
|
+
* call is an action, the `wait` flow it dispatches awaits a `DurableClock`
|
|
160
|
+
* under the run's own instance, and the round that should have parked instead
|
|
161
|
+
* blocked forever inside an uninterruptible finalizer — not cancellable, not
|
|
162
|
+
* resumable, and invisible in the journal past the `clock-scheduled` record.
|
|
163
|
+
*
|
|
164
|
+
* @category results
|
|
165
|
+
* @since 0.1.0
|
|
166
|
+
*/
|
|
167
|
+
export const wrapActionResult = <A, E, R>(
|
|
168
|
+
effect: Effect.Effect<A, E, R>,
|
|
169
|
+
isSuspend: (value: A) => boolean
|
|
170
|
+
): Effect.Effect<A, E, R | FlowInstance> =>
|
|
171
|
+
Effect.contextWith((context: Context.Context<FlowInstance>) => {
|
|
172
|
+
const instance = Context.get(context, FlowInstance)
|
|
173
|
+
const enclosing = Context.getUnsafe(context, EnclosingActions)
|
|
174
|
+
// How many of the regions counted on this instance are this one's own
|
|
175
|
+
// ancestors, and so how many of them will still be open once every sibling
|
|
176
|
+
// has settled.
|
|
177
|
+
let ancestors = 0
|
|
178
|
+
for (const open of enclosing) if (open === instance) ancestors++
|
|
179
|
+
const state = instance.actionState
|
|
180
|
+
if (state.count === 0) state.latch.closeUnsafe()
|
|
181
|
+
state.count++
|
|
182
|
+
return Effect.onExit(
|
|
183
|
+
Effect.provideService(effect, EnclosingActions, [...enclosing, instance]),
|
|
184
|
+
(exit) => {
|
|
185
|
+
state.count--
|
|
186
|
+
const isSuspended = Exit.isSuccess(exit) && isSuspend(exit.value)
|
|
187
|
+
if (
|
|
188
|
+
Exit.isSuccess(exit) &&
|
|
189
|
+
isResult(exit.value) &&
|
|
190
|
+
exit.value._tag === "Suspended" &&
|
|
191
|
+
exit.value.cause
|
|
192
|
+
) {
|
|
193
|
+
instance.cause = instance.cause
|
|
194
|
+
? Cause.combine(instance.cause, exit.value.cause)
|
|
195
|
+
: exit.value.cause
|
|
196
|
+
}
|
|
197
|
+
if (state.count === 0) return state.latch.open
|
|
198
|
+
// Every decrement can satisfy a waiter whose threshold is not zero, so
|
|
199
|
+
// the waiters are released to re-test their own. `release` wakes them
|
|
200
|
+
// without opening the latch, so the ones still short of their threshold
|
|
201
|
+
// park again on the next turn of the loop.
|
|
202
|
+
return isSuspended
|
|
203
|
+
? Effect.andThen(state.latch.release, waitForSiblings(instance, ancestors))
|
|
204
|
+
: Effect.asVoid(state.latch.release)
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
// Untraced because this latch loop is a flow scheduler hot path.
|
|
210
|
+
const waitForSiblings = Effect.fnUntraced(function*(
|
|
211
|
+
instance: FlowInstance["Service"],
|
|
212
|
+
ancestors: number
|
|
213
|
+
) {
|
|
214
|
+
const state = instance.actionState
|
|
215
|
+
while (true) {
|
|
216
|
+
if (state.count > ancestors) {
|
|
217
|
+
yield* state.latch.await
|
|
218
|
+
yield* Effect.yieldNow
|
|
219
|
+
continue
|
|
220
|
+
}
|
|
221
|
+
yield* Effect.yieldNow
|
|
222
|
+
if (state.count <= ancestors) return
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Accesses the current round's flow scope. Suspension keeps it open;
|
|
228
|
+
* completion or handoff closes it.
|
|
229
|
+
*
|
|
230
|
+
* @category resource management
|
|
231
|
+
* @since 0.1.0
|
|
232
|
+
*/
|
|
233
|
+
export const scope: Effect.Effect<
|
|
234
|
+
Scope.Scope,
|
|
235
|
+
never,
|
|
236
|
+
FlowInstance
|
|
237
|
+
> = Effect.map(
|
|
238
|
+
FlowInstance,
|
|
239
|
+
(instance) => instance.scope as Scope.Scope
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Provides the current round's flow scope to the given effect. Suspension keeps
|
|
244
|
+
* the scope open; completion or handoff closes it.
|
|
245
|
+
*
|
|
246
|
+
* @category resource management
|
|
247
|
+
* @since 0.1.0
|
|
248
|
+
*/
|
|
249
|
+
export const provideScope = <A, E, R>(
|
|
250
|
+
effect: Effect.Effect<A, E, R>
|
|
251
|
+
): Effect.Effect<A, E, Exclude<R, Scope.Scope> | FlowInstance> =>
|
|
252
|
+
Effect.flatMap(scope, (scope) => Scope.provide(effect, scope))
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Adds an exit finalizer to the current flow scope, preserving the
|
|
256
|
+
* services available when the finalizer is registered.
|
|
257
|
+
*
|
|
258
|
+
* @category resource management
|
|
259
|
+
* @since 0.1.0
|
|
260
|
+
*/
|
|
261
|
+
export const addFinalizer: <R>(
|
|
262
|
+
f: (exit: Exit.Exit<unknown, unknown>) => Effect.Effect<void, never, R>
|
|
263
|
+
) => Effect.Effect<
|
|
264
|
+
void,
|
|
265
|
+
never,
|
|
266
|
+
FlowInstance | R
|
|
267
|
+
> =
|
|
268
|
+
// Untraced because suspension recursively re-enters flow execution.
|
|
269
|
+
Effect.fnUntraced(function*<R>(
|
|
270
|
+
f: (exit: Exit.Exit<unknown, unknown>) => Effect.Effect<void, never, R>
|
|
271
|
+
) {
|
|
272
|
+
const instance = yield* FlowInstance
|
|
273
|
+
const services = yield* Effect.context<R>()
|
|
274
|
+
yield* Scope.addFinalizerExit(instance.scope, (exit) => Effect.provideContext(f(exit), services))
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Runs an effect and registers how to undo its successful result if the
|
|
279
|
+
* current round later exits unsuccessfully.
|
|
280
|
+
*
|
|
281
|
+
* **When to use**
|
|
282
|
+
*
|
|
283
|
+
* Use when a top-level flow operation changes something that must be undone if
|
|
284
|
+
* a later operation causes the same round to fail or be interrupted.
|
|
285
|
+
*
|
|
286
|
+
* **Details**
|
|
287
|
+
*
|
|
288
|
+
* The effect runs first. If it fails, no rollback is registered. If it
|
|
289
|
+
* succeeds, its value is captured in a round-scope finalizer. The finalizer does
|
|
290
|
+
* nothing when the round succeeds; when the round exits unsuccessfully
|
|
291
|
+
* it calls `rollback(value, cause)`. Suspension keeps that scope open.
|
|
292
|
+
*
|
|
293
|
+
* A handoff completes the round successfully and discards its `withRollback` registrations.
|
|
294
|
+
* A later round's failure cannot invoke those rollbacks. The engine does not
|
|
295
|
+
* provide lineage-scoped compensation.
|
|
296
|
+
*
|
|
297
|
+
* **Gotchas**
|
|
298
|
+
*
|
|
299
|
+
* This applies only to effects run directly inside the flow execution. It does
|
|
300
|
+
* not attach rollback behavior to nested actions. The rollback's typed error
|
|
301
|
+
* channel is `never`; handle expected rollback failures inside the callback.
|
|
302
|
+
*
|
|
303
|
+
* @category resource management
|
|
304
|
+
* @since 0.1.0
|
|
305
|
+
*/
|
|
306
|
+
export const withRollback: {
|
|
307
|
+
<A, R2>(
|
|
308
|
+
rollback: (value: A, cause: Cause.Cause<unknown>) => Effect.Effect<void, never, R2>
|
|
309
|
+
): <E, R>(
|
|
310
|
+
effect: Effect.Effect<A, E, R>
|
|
311
|
+
) => Effect.Effect<A, E, R | R2 | FlowInstance | Scope.Scope>
|
|
312
|
+
<A, E, R, R2>(
|
|
313
|
+
effect: Effect.Effect<A, E, R>,
|
|
314
|
+
rollback: (value: A, cause: Cause.Cause<unknown>) => Effect.Effect<void, never, R2>
|
|
315
|
+
): Effect.Effect<A, E, R | R2 | FlowInstance | Scope.Scope>
|
|
316
|
+
} = dual(2, <A, E, R, R2>(
|
|
317
|
+
effect: Effect.Effect<A, E, R>,
|
|
318
|
+
rollback: (value: A, cause: Cause.Cause<unknown>) => Effect.Effect<void, never, R2>
|
|
319
|
+
): Effect.Effect<A, E, R | R2 | FlowInstance | Scope.Scope> =>
|
|
320
|
+
Effect.uninterruptibleMask((restore) =>
|
|
321
|
+
Effect.tap(
|
|
322
|
+
restore(effect),
|
|
323
|
+
(value) => addFinalizer((exit) => Exit.isSuccess(exit) ? Effect.void : rollback(value, exit.cause))
|
|
324
|
+
)
|
|
325
|
+
))
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Marks a flow instance as suspended and interrupts the current fiber to
|
|
329
|
+
* stop execution until it is resumed.
|
|
330
|
+
*
|
|
331
|
+
* @category results
|
|
332
|
+
* @since 0.1.0
|
|
333
|
+
*/
|
|
334
|
+
export const suspend = (instance: FlowInstance["Service"]): Effect.Effect<never> =>
|
|
335
|
+
Effect.interruptible(Effect.callback<never>(() => {
|
|
336
|
+
instance.suspended = true
|
|
337
|
+
const fiber = Fiber.getCurrent()!
|
|
338
|
+
fiber.interruptUnsafe(fiber.id)
|
|
339
|
+
}))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Deep reviewed and polished by a human on 2026-08-10.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Typed durable flow definitions, results, and runtime helpers.
|
|
5
|
+
*
|
|
6
|
+
* @since 0.1.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export * from "./Annotations.ts"
|
|
10
|
+
export * from "./CapabilityCeiling.ts"
|
|
11
|
+
export * from "./DeadlineExceeded.ts"
|
|
12
|
+
export * from "./ExecutionIdRequired.ts"
|
|
13
|
+
export * from "./ExecutionIds.ts"
|
|
14
|
+
export * from "./Flow.ts"
|
|
15
|
+
export * from "./make.ts"
|
|
16
|
+
export * from "./MaxRoundsExceeded.ts"
|
|
17
|
+
export * from "./Outcome.ts"
|
|
18
|
+
export * from "./Result.ts"
|
|
19
|
+
export * from "./Runtime.ts"
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Private flow construction shared by declarations and action registration.
|
|
3
|
+
*
|
|
4
|
+
* @since 1.0.0
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Sha256 } from "@smthrs/crypto"
|
|
9
|
+
import * as Node from "@smthrs/plan/Node"
|
|
10
|
+
import * as Cause from "effect/Cause"
|
|
11
|
+
import * as Context from "effect/Context"
|
|
12
|
+
import * as Crypto from "effect/Crypto"
|
|
13
|
+
import type * as Duration from "effect/Duration"
|
|
14
|
+
import * as Effect from "effect/Effect"
|
|
15
|
+
import * as Schema from "effect/Schema"
|
|
16
|
+
import { ExecutionIdentityConflict } from "../FlowRuntime/ExecutionIdentityConflict.ts"
|
|
17
|
+
import { FlowRuntime } from "../FlowRuntime/FlowRuntime.ts"
|
|
18
|
+
import * as DeclarationSite from "../internal/DeclarationSite.ts"
|
|
19
|
+
import type * as RetryPolicy from "../RetryPolicy.ts"
|
|
20
|
+
import { CurrentExecutionIds } from "./ExecutionIds.ts"
|
|
21
|
+
import type { Any, AnyStructSchema, AnyWithProps, BodySuccess, DeclarationMetadata, Flow } from "./Flow.ts"
|
|
22
|
+
import type { To } from "./Outcome.ts"
|
|
23
|
+
import { withRollback } from "./Runtime.ts"
|
|
24
|
+
import { TypeId } from "./TypeId.ts"
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The identity of an invocation that named no `executionId`: the flow's own
|
|
28
|
+
* declared key when it has one, and the ambient source otherwise.
|
|
29
|
+
*
|
|
30
|
+
* A declared key wins over the ambient source because it is the narrower
|
|
31
|
+
* statement — this author said what makes two invocations of THIS flow the
|
|
32
|
+
* same — where the source is the host's blanket answer for every flow it
|
|
33
|
+
* drives.
|
|
34
|
+
*
|
|
35
|
+
* The tag and declared key are JSON-tuple framed before hashing. Their strings
|
|
36
|
+
* are used exactly as given and encoded as UTF-8, with no Unicode
|
|
37
|
+
* normalization. This preimage encoding freezes at rc.0.
|
|
38
|
+
*/
|
|
39
|
+
const makeExecutionIdFromPayload = (
|
|
40
|
+
self: AnyWithProps,
|
|
41
|
+
payload: unknown
|
|
42
|
+
): Effect.Effect<string, never, any> => {
|
|
43
|
+
const idempotencyKey = self.idempotencyKey
|
|
44
|
+
return idempotencyKey === undefined
|
|
45
|
+
? Effect.flatMap(CurrentExecutionIds, (source) => source.mint(self, payload))
|
|
46
|
+
// The JSON tuple prevents delimiter splicing. This exact framing freezes at rc.0.
|
|
47
|
+
: Schema.decodeUnknownEffect(Sha256)(JSON.stringify([self._tag, idempotencyKey(payload)])).pipe(Effect.orDie)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const resolveExecutionId = (
|
|
51
|
+
self: AnyWithProps,
|
|
52
|
+
payload: unknown,
|
|
53
|
+
executionId: string | undefined
|
|
54
|
+
): Effect.Effect<string, never, any> =>
|
|
55
|
+
executionId === undefined
|
|
56
|
+
? makeExecutionIdFromPayload(self, payload)
|
|
57
|
+
: Effect.succeed(executionId)
|
|
58
|
+
|
|
59
|
+
const Proto = {
|
|
60
|
+
[TypeId]: TypeId,
|
|
61
|
+
annotate(this: AnyWithProps, tag: Context.Key<any, any>, value: any) {
|
|
62
|
+
return DeclarationSite.annotate(
|
|
63
|
+
makeProto({
|
|
64
|
+
_tag: this._tag,
|
|
65
|
+
description: this.description,
|
|
66
|
+
model: this.model,
|
|
67
|
+
effort: this.effort,
|
|
68
|
+
system: this.system,
|
|
69
|
+
chat: this.chat,
|
|
70
|
+
flows: this.flows,
|
|
71
|
+
prompt: this.prompt,
|
|
72
|
+
action: this.action,
|
|
73
|
+
payloadSchema: this.payloadSchema,
|
|
74
|
+
successSchema: this.successSchema,
|
|
75
|
+
errorSchema: this.errorSchema,
|
|
76
|
+
annotations: Context.add(this.annotations, tag, value),
|
|
77
|
+
body: this.body,
|
|
78
|
+
idempotencyKey: this.idempotencyKey,
|
|
79
|
+
suspendedRetryPolicy: this.suspendedRetryPolicy,
|
|
80
|
+
maxRounds: this.maxRounds,
|
|
81
|
+
deadline: this.deadline
|
|
82
|
+
}),
|
|
83
|
+
DeclarationSite.declaredAt(this)
|
|
84
|
+
)
|
|
85
|
+
},
|
|
86
|
+
annotateMerge(this: AnyWithProps, context: Context.Context<any>) {
|
|
87
|
+
return DeclarationSite.annotate(
|
|
88
|
+
makeProto({
|
|
89
|
+
_tag: this._tag,
|
|
90
|
+
description: this.description,
|
|
91
|
+
model: this.model,
|
|
92
|
+
effort: this.effort,
|
|
93
|
+
system: this.system,
|
|
94
|
+
chat: this.chat,
|
|
95
|
+
flows: this.flows,
|
|
96
|
+
prompt: this.prompt,
|
|
97
|
+
action: this.action,
|
|
98
|
+
payloadSchema: this.payloadSchema,
|
|
99
|
+
successSchema: this.successSchema,
|
|
100
|
+
errorSchema: this.errorSchema,
|
|
101
|
+
annotations: Context.merge(this.annotations, context),
|
|
102
|
+
body: this.body,
|
|
103
|
+
idempotencyKey: this.idempotencyKey,
|
|
104
|
+
suspendedRetryPolicy: this.suspendedRetryPolicy,
|
|
105
|
+
maxRounds: this.maxRounds,
|
|
106
|
+
deadline: this.deadline
|
|
107
|
+
}),
|
|
108
|
+
DeclarationSite.declaredAt(this)
|
|
109
|
+
)
|
|
110
|
+
},
|
|
111
|
+
call(this: AnyWithProps, payload: unknown) {
|
|
112
|
+
return Node.flowCall(this, this._tag, "inline", payload)
|
|
113
|
+
},
|
|
114
|
+
child(this: AnyWithProps, payload: unknown) {
|
|
115
|
+
return Node.flowCall(this, this._tag, "boundary", payload)
|
|
116
|
+
},
|
|
117
|
+
to(this: AnyWithProps, payload: unknown): Node.Node<To<unknown>> {
|
|
118
|
+
return Node.flowCall(this, this._tag, "handoff", payload)
|
|
119
|
+
},
|
|
120
|
+
execute<const Discard extends boolean = false>(
|
|
121
|
+
this: AnyWithProps,
|
|
122
|
+
fields: any,
|
|
123
|
+
opts?: {
|
|
124
|
+
readonly discard?: Discard
|
|
125
|
+
readonly executionId?: string | undefined
|
|
126
|
+
} | undefined
|
|
127
|
+
) {
|
|
128
|
+
// Caller input that fails the payload schema is data, not programmer
|
|
129
|
+
// wiring, so it FAILS with the schema's typed `SchemaError` — carrying
|
|
130
|
+
// the offending field path — instead of dying with the raw constructor
|
|
131
|
+
// throw `payloadSchema.make` would produce.
|
|
132
|
+
return this.payloadSchema.makeEffect(fields).pipe(
|
|
133
|
+
Effect.mapError((issue) => new Schema.SchemaError(issue)),
|
|
134
|
+
Effect.flatMap((payload) =>
|
|
135
|
+
Effect.flatMap(
|
|
136
|
+
resolveExecutionId(this, payload, opts?.executionId),
|
|
137
|
+
(executionId) =>
|
|
138
|
+
Effect.flatMap(FlowRuntime, (engine) =>
|
|
139
|
+
Effect.andThen(
|
|
140
|
+
Effect.annotateCurrentSpan({ executionId }),
|
|
141
|
+
engine.execute(this as any, {
|
|
142
|
+
executionId,
|
|
143
|
+
payload,
|
|
144
|
+
discard: opts?.discard,
|
|
145
|
+
suspendedRetryPolicy: this.suspendedRetryPolicy
|
|
146
|
+
}).pipe(Effect.catchCause((cause) => {
|
|
147
|
+
const reason = cause.reasons.length === 1 ? cause.reasons.find(Cause.isDieReason) : undefined
|
|
148
|
+
return reason?.defect instanceof ExecutionIdentityConflict
|
|
149
|
+
? Effect.fail(reason.defect)
|
|
150
|
+
: Effect.failCause(cause)
|
|
151
|
+
}))
|
|
152
|
+
))
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
).pipe(
|
|
156
|
+
Effect.withSpan(
|
|
157
|
+
`${this._tag}.execute`,
|
|
158
|
+
{},
|
|
159
|
+
{ captureStackTrace: false }
|
|
160
|
+
)
|
|
161
|
+
) as any
|
|
162
|
+
},
|
|
163
|
+
start(this: AnyWithProps, payload: unknown) {
|
|
164
|
+
return Effect.flatMap(
|
|
165
|
+
Crypto.Crypto,
|
|
166
|
+
(crypto) =>
|
|
167
|
+
Effect.flatMap(
|
|
168
|
+
Effect.orDie(crypto.randomUUIDv4()),
|
|
169
|
+
(executionId) => this.execute(payload, { executionId, discard: true })
|
|
170
|
+
)
|
|
171
|
+
)
|
|
172
|
+
},
|
|
173
|
+
ensure(this: AnyWithProps, payload: unknown, options: { readonly key: string }) {
|
|
174
|
+
return Schema.decodeUnknownEffect(Schema.String)(options.key).pipe(
|
|
175
|
+
Effect.flatMap((key) => Effect.orDie(Schema.decodeUnknownEffect(Sha256)(JSON.stringify([this._tag, key])))),
|
|
176
|
+
Effect.flatMap((executionId) => this.execute(payload, { executionId, discard: true }))
|
|
177
|
+
)
|
|
178
|
+
},
|
|
179
|
+
poll(this: Flow<string, AnyStructSchema, Schema.Top, Schema.Top, any>, executionId: string) {
|
|
180
|
+
return Effect.flatMap(FlowRuntime, (engine) => engine.poll(this, executionId)).pipe(
|
|
181
|
+
Effect.withSpan(`${this._tag}.poll`, { attributes: { executionId } }, { captureStackTrace: false })
|
|
182
|
+
)
|
|
183
|
+
},
|
|
184
|
+
interrupt(this: AnyWithProps, executionId: string) {
|
|
185
|
+
return Effect.flatMap(FlowRuntime, (engine) => engine.interrupt(this, executionId)).pipe(
|
|
186
|
+
Effect.withSpan(`${this._tag}.interrupt`, { attributes: { executionId } }, { captureStackTrace: false })
|
|
187
|
+
)
|
|
188
|
+
},
|
|
189
|
+
resume(this: Flow<string, AnyStructSchema, Schema.Top, Schema.Top, any>, executionId: string) {
|
|
190
|
+
return Effect.flatMap(FlowRuntime, (engine) => engine.resume(this, executionId)).pipe(
|
|
191
|
+
Effect.withSpan(`${this._tag}.resume`, { attributes: { executionId } }, { captureStackTrace: false })
|
|
192
|
+
)
|
|
193
|
+
},
|
|
194
|
+
executionId(this: AnyWithProps, payload: any) {
|
|
195
|
+
return Effect.flatMap(
|
|
196
|
+
// The channel stays never: precomputing callers must validate first, and an invalid payload dies here.
|
|
197
|
+
Effect.orDie(this.payloadSchema.makeEffect(payload)),
|
|
198
|
+
(payload) => makeExecutionIdFromPayload(this, payload)
|
|
199
|
+
)
|
|
200
|
+
},
|
|
201
|
+
withRollback: ((...args: ReadonlyArray<any>) => (withRollback as any)(...args))
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Builds the private prototype from normalized declaration data.
|
|
206
|
+
*
|
|
207
|
+
* @since 1.0.0
|
|
208
|
+
* @private
|
|
209
|
+
*/
|
|
210
|
+
export const makeProto = <
|
|
211
|
+
const Tag extends string,
|
|
212
|
+
Payload extends AnyStructSchema,
|
|
213
|
+
Success extends Schema.Top,
|
|
214
|
+
Error extends Schema.Top,
|
|
215
|
+
Requires
|
|
216
|
+
>(
|
|
217
|
+
options: DeclarationMetadata & {
|
|
218
|
+
readonly _tag: Tag
|
|
219
|
+
readonly description?: string | undefined
|
|
220
|
+
readonly payloadSchema: Payload
|
|
221
|
+
readonly successSchema: Success
|
|
222
|
+
readonly errorSchema: Error
|
|
223
|
+
readonly annotations: Context.Context<never>
|
|
224
|
+
readonly body: (payload: Payload["Type"]) => Node.Node<BodySuccess<Success["Type"]>, Error["Type"], Requires>
|
|
225
|
+
readonly prompt?: ((payload: Payload["Type"]) => string) | undefined
|
|
226
|
+
readonly action?: Any["action"] | undefined
|
|
227
|
+
readonly idempotencyKey?: ((payload: Payload["Type"]) => string) | undefined
|
|
228
|
+
readonly suspendedRetryPolicy?: RetryPolicy.RetryPolicy | undefined
|
|
229
|
+
readonly maxRounds?: number | undefined
|
|
230
|
+
readonly deadline?: Duration.Duration | undefined
|
|
231
|
+
}
|
|
232
|
+
): Flow<Tag, Payload, Success, Error, Requires> => {
|
|
233
|
+
function Flow() {}
|
|
234
|
+
Object.setPrototypeOf(Flow, Proto)
|
|
235
|
+
Object.assign(Flow, options)
|
|
236
|
+
return Flow as any
|
|
237
|
+
}
|