@lastshotlabs/slingshot-orchestration-engine
npm install @lastshotlabs/slingshot-orchestration-engine
Functions
Section titled “Functions”createCachedRunHandle
Section titled “createCachedRunHandle”Wrap a lazy result loader in an idempotent RunHandle.
function createCachedRunHandle<TOutput>(id: string, loader: () => Promise<TOutput>,): RunHandle<TOutput>Source: packages/slingshot-orchestration-engine/src/adapter.ts
createIdempotencyScope
Section titled “createIdempotencyScope”Build the portable adapter-level idempotency scope used to dedupe runs.
Scoping by run type, definition name, and tenant prevents one workload or tenant from replaying another workload’s result when the caller reuses an idempotency key.
function createIdempotencyScope(target: IdempotencyTarget, options: Pick<RunOptions, 'idempotencyKey' | 'tenantId'>,): string | undefinedSource: packages/slingshot-orchestration-engine/src/idempotency.ts
createMemoryAdapter
Section titled “createMemoryAdapter”Create the in-process orchestration adapter.
This adapter is the lightest execution mode: no external infrastructure, no durability across process restarts, and full support for observability/progress within the running process.
function createMemoryAdapter(options: { concurrency?: number; eventSink?: OrchestrationEventSink; maxPayloadBytes?: number; logger?: import('@lastshotlabs/slingshot-core').Logger; /** * Pre-built `HookServices` instance. When provided, the adapter threads it into * workflow `onStart`/`onComplete`/`onFail` hooks and `TaskContext.services`. * Construct via `buildHookServices()` from `@lastshotlabs/slingshot-core` at the * adapter's call site (typically inside the orchestration plugin's * `setupMiddleware`, where `app`/`pluginState`/`bus` are all in scope). * * Omitting this field means hooks see `services: undefined` — appropriate for * tests, standalone scripts, or any setup where the framework state isn't * reachable. */ hookServices?: import('@lastshotlabs/slingshot-core').HookServices; } = {},): OrchestrationAdapter & ObservabilityCapability & SignalCapability & ScheduleCapability &Source: packages/slingshot-orchestration-engine/src/adapters/memory.ts
createOrchestrationRuntime
Section titled “createOrchestrationRuntime”Build the portable orchestration runtime from a concrete adapter plus registered task and workflow definitions.
This composition root is intentionally framework-agnostic. It can run in plain scripts, tests, workers, or inside the Slingshot plugin wrapper.
function createOrchestrationRuntime(options: OrchestrationRuntimeOptions,): OrchestrationRuntimeSource: packages/slingshot-orchestration-engine/src/runtime.ts
createSqliteAdapter
Section titled “createSqliteAdapter”Create the SQLite-backed orchestration adapter.
This adapter reuses the shared task/workflow runners from the core package while persisting run and step state to SQLite so pending work can resume after restart.
function createSqliteAdapter(options: { path: string; concurrency?: number; eventSink?: OrchestrationEventSink; maxPayloadBytes?: number; logger?: import('@lastshotlabs/slingshot-core').Logger; /** Pre-built `HookServices` for in-process workflow hooks and task contexts. See `createMemoryAdapter` for the same field. */ hookServices?: import('@lastshotlabs/slingshot-core').HookServices; }): OrchestrationAdapter & ObservabilityCapability &Source: packages/slingshot-orchestration-engine/src/adapters/sqlite.ts
defineTask
Section titled “defineTask”Define a retryable task that can be registered with an orchestration runtime.
The returned object is frozen and carries normalized retry settings so downstream adapters and workflow steps do not need to repeat defaulting logic.
function defineTask<TInput, TOutput>(config: TaskDefinition<TInput, TOutput>,): ResolvedTask<TInput, TOutput>Source: packages/slingshot-orchestration-engine/src/defineTask.ts
defineWorkflow
Section titled “defineWorkflow”Define an ordered workflow of steps, parallel groups, and sleep entries.
Workflows are transport-neutral definitions. They are only executable after being
registered with createOrchestrationRuntime() or createOrchestrationPackage().
function defineWorkflow<TInput, TOutput>(config: WorkflowDefinition<TInput, TOutput>,): ResolvedWorkflow<TInput, TOutput>Source: packages/slingshot-orchestration-engine/src/defineWorkflow.ts
generateRunId
Section titled “generateRunId”Generate a sortable public orchestration run ID.
The format is run_ plus a Crockford-style timestamp/random suffix so adapters can
use the same externally-visible identifier even when the underlying engine keeps its
own internal job ID.
function generateRunId(): stringSource: packages/slingshot-orchestration-engine/src/adapter.ts
parallel
Section titled “parallel”Group multiple workflow steps so they execute concurrently.
function parallel<TWorkflowInput = unknown>(steps: StepEntry<TWorkflowInput>[],): ParallelEntry<TWorkflowInput>Source: packages/slingshot-orchestration-engine/src/defineWorkflow.ts
Insert a durable timer entry into a workflow definition.
function sleep<TWorkflowInput = unknown>(name: string, duration: | number | ((ctx: { workflowInput: TWorkflowInput; results: Record<string, unknown> }) => number),): SleepEntry<TWorkflowInput>Source: packages/slingshot-orchestration-engine/src/defineWorkflow.ts
Reference a task inside a workflow by object or public name.
Prefer passing the resolved task object when authoring nearby code so refactors stay type-safe. String names remain useful for cross-module composition.
function step<TWorkflowInput = unknown>(name: string, taskOrName: string | AnyResolvedTask, options?: StepOptions<TWorkflowInput>,): StepEntry<TWorkflowInput>Source: packages/slingshot-orchestration-engine/src/defineWorkflow.ts
stepResult
Section titled “stepResult”Read a prior workflow step result with optional result typing.
function stepResult<TResult = unknown>(results: Record<string, unknown>, name: string, task?: AnyResolvedTask,): TResult | undefined; export function stepResult<TResult = unknown>( results: Record<string, unknown>, name: string, ): TResult | undefinedSource: packages/slingshot-orchestration-engine/src/defineWorkflow.ts
Classes
Section titled “Classes”OrchestrationAdapterError
Section titled “OrchestrationAdapterError”Error raised when an underlying adapter (BullMQ, Temporal, etc.) encounters a failure that is not covered by a more specific error type.
Source: packages/slingshot-orchestration-engine/src/errors.ts
OrchestrationError
Section titled “OrchestrationError”Error type used by the orchestration runtime, adapters, and plugin helpers.
Consumers should branch on code for durable error handling instead of parsing the
message text.
Source: packages/slingshot-orchestration-engine/src/errors.ts
OrchestrationRunNotFoundError
Section titled “OrchestrationRunNotFoundError”Error raised when a run lookup (by run id or filter) yields no result.
Source: packages/slingshot-orchestration-engine/src/errors.ts
OrchestrationTimeoutError
Section titled “OrchestrationTimeoutError”Error raised when an orchestration operation exceeds its configured timeout.
Source: packages/slingshot-orchestration-engine/src/errors.ts
WorkflowHookError
Section titled “WorkflowHookError”Thrown when a workflow lifecycle hook (onStart, onComplete, or onFail)
raises and continueOnHookError is not set on the hook configuration. The
workflow is failed with a hookFailed failure step.
Source: packages/slingshot-orchestration-engine/src/engine/workflowRunner.ts
Interfaces
Section titled “Interfaces”CancelOutcome
Section titled “CancelOutcome”Outcome returned by cancelRun() describing whether cancellation was confirmed
by the underlying adapter. confirmed means the run was deleted/finalized.
best-effort means the cancel was issued but post-cancel verification could
not confirm the run is gone — the caller should treat the run as still
potentially executing until they observe a terminal state.
Source: packages/slingshot-orchestration-engine/src/types.ts
CoreOrchestrationAdapter
Section titled “CoreOrchestrationAdapter”Required orchestration adapter contract implemented by all providers.
Source: packages/slingshot-orchestration-engine/src/types.ts
ObservabilityCapability
Section titled “ObservabilityCapability”Optional observability capability for adapters that support run listing.
Source: packages/slingshot-orchestration-engine/src/types.ts
OrchestrationEventMap
Section titled “OrchestrationEventMap”Lifecycle events emitted by the orchestration domain.
Source: packages/slingshot-orchestration-engine/src/types.ts
OrchestrationEventSink
Section titled “OrchestrationEventSink”Port used by the orchestration domain to emit lifecycle events without depending on Slingshot’s concrete event-bus implementation.
Source: packages/slingshot-orchestration-engine/src/types.ts
OrchestrationRuntime
Section titled “OrchestrationRuntime”Framework-agnostic runtime API used by application code.
Source: packages/slingshot-orchestration-engine/src/types.ts
OrchestrationRuntimeOptions
Section titled “OrchestrationRuntimeOptions”Inputs required to construct the portable orchestration runtime.
Source: packages/slingshot-orchestration-engine/src/types.ts
ParallelEntry
Section titled “ParallelEntry”A group of workflow steps that execute concurrently.
Source: packages/slingshot-orchestration-engine/src/types.ts
ProgressCapability
Section titled “ProgressCapability”Optional real-time progress subscription capability.
Source: packages/slingshot-orchestration-engine/src/types.ts
ResolvedTask
Section titled “ResolvedTask”Normalized frozen task definition registered with adapters and runtimes.
Source: packages/slingshot-orchestration-engine/src/types.ts
ResolvedWorkflow
Section titled “ResolvedWorkflow”Normalized frozen workflow definition registered with adapters and runtimes.
Source: packages/slingshot-orchestration-engine/src/types.ts
RetryPolicy
Section titled “RetryPolicy”Retry policy shared by tasks and step-level overrides.
Source: packages/slingshot-orchestration-engine/src/types.ts
Portable task or workflow run snapshot.
Source: packages/slingshot-orchestration-engine/src/types.ts
RunError
Section titled “RunError”Serializable run failure payload returned by adapters.
Source: packages/slingshot-orchestration-engine/src/types.ts
RunFilter
Section titled “RunFilter”Portable run-list filter used by observability-capable adapters.
Source: packages/slingshot-orchestration-engine/src/types.ts
RunHandle
Section titled “RunHandle”Handle returned when a task or workflow run is started.
Source: packages/slingshot-orchestration-engine/src/types.ts
RunOptions
Section titled “RunOptions”Portable run options understood by all adapters.
Source: packages/slingshot-orchestration-engine/src/types.ts
RunProgress
Section titled “RunProgress”Portable progress payload exposed by reportProgress() and onProgress().
Source: packages/slingshot-orchestration-engine/src/types.ts
ScheduleCapability
Section titled “ScheduleCapability”Optional scheduling capability for adapters with durable recurring triggers.
Source: packages/slingshot-orchestration-engine/src/types.ts
ScheduleHandle
Section titled “ScheduleHandle”Portable schedule descriptor returned by scheduling-capable adapters.
Source: packages/slingshot-orchestration-engine/src/types.ts
SignalCapability
Section titled “SignalCapability”Optional signal capability for adapters with in-flight workflow signaling.
Source: packages/slingshot-orchestration-engine/src/types.ts
SleepEntry
Section titled “SleepEntry”A durable timer entry inside a workflow definition.
Source: packages/slingshot-orchestration-engine/src/types.ts
SlingshotLogger
Section titled “SlingshotLogger”Minimal logger shape exposed to task handlers.
Source: packages/slingshot-orchestration-engine/src/types.ts
StepEntry
Section titled “StepEntry”A single workflow step that dispatches a task.
Source: packages/slingshot-orchestration-engine/src/types.ts
StepInputContext
Section titled “StepInputContext”Pure data available to step mappers and conditions.
Source: packages/slingshot-orchestration-engine/src/types.ts
StepOptions
Section titled “StepOptions”Optional per-step behavior overrides applied inside a workflow.
Source: packages/slingshot-orchestration-engine/src/types.ts
StepRun
Section titled “StepRun”Per-step execution snapshot attached to workflow runs.
Source: packages/slingshot-orchestration-engine/src/types.ts
TaskContext
Section titled “TaskContext”Execution context passed to each task invocation.
services carries typed framework accessors for tasks running in-process
(memory and sqlite adapters, in-process bullmq workers). It is undefined
for tasks running in remote isolates (notably the Temporal worker, which
runs in a separate Node.js process where the Hono app is unreachable).
Tasks that need typed entity adapters or capability lookups must either:
- Tolerate
services === undefinedand fall back to other inputs, or - Express their work as a workflow whose
onStart/onCompletehooks run in-process and pass framework-resolved data into the task input.
Source: packages/slingshot-orchestration-engine/src/types.ts
TaskDefinition
Section titled “TaskDefinition”User-authored task definition before normalization.
Source: packages/slingshot-orchestration-engine/src/types.ts
WorkflowDefinition
Section titled “WorkflowDefinition”User-authored workflow definition before normalization.
Source: packages/slingshot-orchestration-engine/src/types.ts
WorkflowRun
Section titled “WorkflowRun”Workflow run snapshot that includes step state.
Source: packages/slingshot-orchestration-engine/src/types.ts
AnyResolvedTask
Section titled “AnyResolvedTask”Convenience alias for APIs that accept any resolved task regardless of its input/output generics.
Source: packages/slingshot-orchestration-engine/src/types.ts
AnyResolvedWorkflow
Section titled “AnyResolvedWorkflow”Convenience alias for APIs that accept any resolved workflow regardless of its input/output generics.
Source: packages/slingshot-orchestration-engine/src/types.ts
OrchestrationAdapter
Section titled “OrchestrationAdapter”Full adapter contract made up of the required core surface plus any optional capabilities an implementation chooses to support.
Source: packages/slingshot-orchestration-engine/src/types.ts
OrchestrationCapability
Section titled “OrchestrationCapability”Feature flags checked with runtime.supports(...) before calling optional APIs.
Source: packages/slingshot-orchestration-engine/src/types.ts
OrchestrationErrorCode
Section titled “OrchestrationErrorCode”Stable machine-readable orchestration error codes.
Source: packages/slingshot-orchestration-engine/src/types.ts
RunStatus
Section titled “RunStatus”Portable run lifecycle states used across adapters and HTTP responses.
Source: packages/slingshot-orchestration-engine/src/types.ts
WorkflowEntry
Section titled “WorkflowEntry”Any entry that can appear in a workflow step list.
Source: packages/slingshot-orchestration-engine/src/types.ts