Skip to content

@lastshotlabs/slingshot-orchestration-engine

npm install @lastshotlabs/slingshot-orchestration-engine

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

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 | undefined

Source: packages/slingshot-orchestration-engine/src/idempotency.ts

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

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,): OrchestrationRuntime

Source: packages/slingshot-orchestration-engine/src/runtime.ts

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

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

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

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(): string

Source: packages/slingshot-orchestration-engine/src/adapter.ts

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

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 | undefined

Source: packages/slingshot-orchestration-engine/src/defineWorkflow.ts

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

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

Error raised when a run lookup (by run id or filter) yields no result.

Source: packages/slingshot-orchestration-engine/src/errors.ts

Error raised when an orchestration operation exceeds its configured timeout.

Source: packages/slingshot-orchestration-engine/src/errors.ts

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

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

Required orchestration adapter contract implemented by all providers.

Source: packages/slingshot-orchestration-engine/src/types.ts

Optional observability capability for adapters that support run listing.

Source: packages/slingshot-orchestration-engine/src/types.ts

Lifecycle events emitted by the orchestration domain.

Source: packages/slingshot-orchestration-engine/src/types.ts

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

Framework-agnostic runtime API used by application code.

Source: packages/slingshot-orchestration-engine/src/types.ts

Inputs required to construct the portable orchestration runtime.

Source: packages/slingshot-orchestration-engine/src/types.ts

A group of workflow steps that execute concurrently.

Source: packages/slingshot-orchestration-engine/src/types.ts

Optional real-time progress subscription capability.

Source: packages/slingshot-orchestration-engine/src/types.ts

Normalized frozen task definition registered with adapters and runtimes.

Source: packages/slingshot-orchestration-engine/src/types.ts

Normalized frozen workflow definition registered with adapters and runtimes.

Source: packages/slingshot-orchestration-engine/src/types.ts

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

Serializable run failure payload returned by adapters.

Source: packages/slingshot-orchestration-engine/src/types.ts

Portable run-list filter used by observability-capable adapters.

Source: packages/slingshot-orchestration-engine/src/types.ts

Handle returned when a task or workflow run is started.

Source: packages/slingshot-orchestration-engine/src/types.ts

Portable run options understood by all adapters.

Source: packages/slingshot-orchestration-engine/src/types.ts

Portable progress payload exposed by reportProgress() and onProgress().

Source: packages/slingshot-orchestration-engine/src/types.ts

Optional scheduling capability for adapters with durable recurring triggers.

Source: packages/slingshot-orchestration-engine/src/types.ts

Portable schedule descriptor returned by scheduling-capable adapters.

Source: packages/slingshot-orchestration-engine/src/types.ts

Optional signal capability for adapters with in-flight workflow signaling.

Source: packages/slingshot-orchestration-engine/src/types.ts

A durable timer entry inside a workflow definition.

Source: packages/slingshot-orchestration-engine/src/types.ts

Minimal logger shape exposed to task handlers.

Source: packages/slingshot-orchestration-engine/src/types.ts

A single workflow step that dispatches a task.

Source: packages/slingshot-orchestration-engine/src/types.ts

Pure data available to step mappers and conditions.

Source: packages/slingshot-orchestration-engine/src/types.ts

Optional per-step behavior overrides applied inside a workflow.

Source: packages/slingshot-orchestration-engine/src/types.ts

Per-step execution snapshot attached to workflow runs.

Source: packages/slingshot-orchestration-engine/src/types.ts

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:

  1. Tolerate services === undefined and fall back to other inputs, or
  2. Express their work as a workflow whose onStart/onComplete hooks run in-process and pass framework-resolved data into the task input.

Source: packages/slingshot-orchestration-engine/src/types.ts

User-authored task definition before normalization.

Source: packages/slingshot-orchestration-engine/src/types.ts

User-authored workflow definition before normalization.

Source: packages/slingshot-orchestration-engine/src/types.ts

Workflow run snapshot that includes step state.

Source: packages/slingshot-orchestration-engine/src/types.ts

Convenience alias for APIs that accept any resolved task regardless of its input/output generics.

Source: packages/slingshot-orchestration-engine/src/types.ts

Convenience alias for APIs that accept any resolved workflow regardless of its input/output generics.

Source: packages/slingshot-orchestration-engine/src/types.ts

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

Feature flags checked with runtime.supports(...) before calling optional APIs.

Source: packages/slingshot-orchestration-engine/src/types.ts

Stable machine-readable orchestration error codes.

Source: packages/slingshot-orchestration-engine/src/types.ts

Portable run lifecycle states used across adapters and HTTP responses.

Source: packages/slingshot-orchestration-engine/src/types.ts

Any entry that can appear in a workflow step list.

Source: packages/slingshot-orchestration-engine/src/types.ts