Skip to content

@lastshotlabs/slingshot-orchestration-temporal

npm install @lastshotlabs/slingshot-orchestration-temporal

Build the Temporal search attributes written for a Slingshot run.

function buildSearchAttributes(kind: 'task' | 'workflow', name: string, opts?: Pick<RunOptions, 'tenantId' | 'priority' | 'tags'>,): Record<string, string[] | number[]>

Source: packages/slingshot-orchestration-temporal/src/searchAttributes.ts

Translate a portable run filter into a Temporal visibility query string.

function buildVisibilityQuery(filter?: RunFilter): string | undefined

Source: packages/slingshot-orchestration-temporal/src/searchAttributes.ts

Creates a Temporal-backed OrchestrationAdapter that translates the framework’s task/workflow operations into Temporal Client calls.

The adapter validates the supplied options, then returns an OrchestrationAdapter whose methods map to Temporal primitives:

  • registerTask / registerWorkflow — record definitions (immutable after start()).
  • runTask / runWorkflow — start a Temporal workflow execution with idempotent workflowId derivation and USE_EXISTING conflict policy.
  • getRun — describe + query a workflow to build a unified Run view including progress, steps, and terminal output/error.
  • cancelRun / signal — cancel or deliver a user-defined signal.
  • schedule / unschedule / listSchedules — manage cron-based schedules.
  • listRuns — paginated visibility query with offset/limit support.
  • onProgress — poll-based progress subscription with automatic cleanup.
  • start — verify connectivity and search-attribute availability.
  • shutdown — dispose progress pollers, close the client and (if owned) the underlying connection.
function createTemporalOrchestrationAdapter(rawOptions: TemporalOrchestrationAdapterOptions & { structuredLogger?: Logger; logger?: Logger; },): OrchestrationAdapter & SignalCapability & ScheduleCapability & ObservabilityCapability & ProgressCapability & TemporalOrchestrationHealthCapability

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

Create the Temporal worker supervisor that executes portable Slingshot tasks and workflows inside real Temporal workers.

async function createTemporalOrchestrationWorker(rawOptions: TemporalOrchestrationWorkerOptions,): Promise<TemporalOrchestrationWorkerSupervisor>

Source: packages/slingshot-orchestration-temporal/src/worker.ts

Derive the Temporal workflow ID used for a portable run.

When an idempotency key is present the result is deterministic across retries for the same task/workflow name and tenant. Without one, a fresh public run ID is generated.

function deriveTemporalRunId(options: { kind: 'task' | 'workflow'; name: string; tenantId?: string; idempotencyKey?: string; }): string

Source: packages/slingshot-orchestration-temporal/src/ids.ts

Encode a single Slingshot run tag into a Temporal-safe visibility token.

function encodeTag(key: string, value: string): string

Source: packages/slingshot-orchestration-temporal/src/searchAttributes.ts

Encode a tag map into stable, sorted Temporal visibility values.

function encodeTags(tags?: Record<string, string>): string[]

Source: packages/slingshot-orchestration-temporal/src/searchAttributes.ts

Generate a temporary definitions module that re-exports a set of handlers files so the Temporal worker can import them through a single module path.

async function generateDirectoryDefinitionsModule(options: { outDir: string; files: readonly string[]; }): Promise<string>

Source: packages/slingshot-orchestration-temporal/src/workflowModuleGenerator.ts

Map a Temporal failure to a typed OrchestrationError so that callers receive a stable, machine-readable code rather than an opaque throw.

Handled cases:

  • WorkflowFailedError — surfaces the underlying cause message as ADAPTER_ERROR
  • CancelledFailure — maps to ADAPTER_ERROR with a clear “cancelled” message
  • TerminatedFailure — maps to ADAPTER_ERROR with a clear “terminated” message
  • TimeoutFailure — maps to ADAPTER_ERROR with the timeout type in the message

All other errors are wrapped with wrapTemporalError.

function mapTemporalFailure(prefix: string, error: unknown): OrchestrationError

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

Map Temporal workflow execution states onto the portable orchestration run status enum.

function mapTemporalStatus(statusName: string | undefined): RunStatus

Source: packages/slingshot-orchestration-temporal/src/statusMap.ts

Validation schema for the server-side Temporal orchestration adapter options.

dataConverter and interceptors are pass-through slots forwarded to both the Temporal Client and Worker constructors. Use dataConverter to install a payload codec for sensitive-data redaction (PII), and interceptors to inject auth headers, tracing, or custom workflow/activity interceptor modules.

Source: packages/slingshot-orchestration-temporal/src/validation.ts

Validation schema for manifest-style Temporal connection settings.

FieldDescription
addressTemporal server host:port address.
defaultActivityTaskQueueDefault task queue for activity tasks when not specified per-activity.
namespaceTemporal namespace to connect to. Defaults to the server default namespace.
tlsTLS configuration for securing the Temporal connection.
workflowTaskQueueTask queue used for dispatching workflow tasks.

Source: packages/slingshot-orchestration-temporal/src/validation.ts

Validation schema for the Temporal worker bootstrap options.

FieldDescription
buildIdBuild identifier used for Temporal worker versioning.
connectionTemporal NativeConnection or Connection instance for the worker.
defaultActivityTaskQueueDefault task queue for activity tasks when not specified per-activity.
definitionsModulePathAbsolute or resolvable path to the module exporting task and workflow definitions.
eventSinkEvent sink for forwarding worker lifecycle events to the application event bus.
generatedWorkflowsDirDirectory containing generated Temporal workflow bundles.
identityHuman-readable identity string reported to the Temporal server for this worker.
maxConcurrentActivityTaskExecutionsMaximum number of activity tasks executed concurrently by this worker.
maxConcurrentWorkflowTaskExecutionsMaximum number of workflow tasks executed concurrently by this worker.
namespaceTemporal namespace the worker connects to.
ownsConnectionWhen true the worker will close the connection on shutdown.
taskNamesExplicit list of task names to register. When omitted all exported tasks are used.
workflowTaskQueueTask queue the worker polls for workflow tasks.

Source: packages/slingshot-orchestration-temporal/src/validation.ts

Convert an unknown thrown value into the portable orchestration RunError shape.

function toRunError(error: unknown): RunError

Source: packages/slingshot-orchestration-temporal/src/runError.ts

Wrap an unknown Temporal failure in a portable OrchestrationError.

function wrapTemporalError(message: string, error: unknown): OrchestrationError

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

Error raised when the Temporal adapter cannot establish or maintain a connection to the Temporal server.

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

Base error for Temporal-specific orchestration failures.

Adds an adapter field so consumers can identify which adapter backend produced the error when multiple orchestration adapters are in use.

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

Health-check capability for the Temporal orchestration adapter.

Returns the current health state including Temporal connection status and whether the adapter has been started.

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

Typed manifest-style Temporal connection settings.

Source: packages/slingshot-orchestration-temporal/src/validation.ts

Typed options accepted by createTemporalOrchestrationAdapter().

Source: packages/slingshot-orchestration-temporal/src/validation.ts

Typed options accepted by createTemporalOrchestrationWorker().

Source: packages/slingshot-orchestration-temporal/src/validation.ts