Skip to main content
The @output.ai/core package provides the workflow abstraction layer and worker runtime that connects to Temporal.

Installation

npm install @output.ai/core

Worker Startup

When you run output dev, the CLI starts Docker Compose which launches a worker container. The worker executes the output-worker binary from this package, which:
  1. Scans your project for workflow files (workflow.js), step files (steps.js, shared_steps.js), and evaluator files (evaluators.js)
  2. Creates a catalog of all discovered workflows and their activities with metadata (name, description, input/output schemas)
  3. Connects to Temporal at the configured address (default: localhost:7233)
  4. Registers a catalog workflow that enables the API server to discover available workflows
  5. Starts the Temporal worker to process workflow executions

File Discovery

The worker scans your src/workflows/ directory for these file patterns:
FilePurpose
workflow.jsWorkflow definition (orchestration logic)
steps.jsStep implementations (I/O operations)
evaluators.jsEvaluator implementations (return evaluation results)
shared_steps.jsReusable steps across workflows
Each discovered component is logged during startup:
[Core.Scanner] Workflow loaded: simple at src/workflows/simple/workflow.js
[Core.Scanner] Component loaded: step fetchData at src/workflows/simple/steps.js

How Temporal Connects

The Output Core SDK abstracts Temporal’s native concepts:
Output SDKTemporal Equivalent
workflow()Workflow Definition
step()Activity
evaluator()Activity (returns EvaluationResult)
When you call a step from a workflow, the SDK:
  1. Proxies the call through Temporal’s activity system
  2. Applies retry policies (default: 3 attempts, exponential backoff)
  3. Validates input/output against your Zod schemas
  4. Traces the execution for observability

Key Exports

import {
  workflow,
  step,
  evaluator,
  createWebhook,
  z
} from '@output.ai/core';

workflow

Define an orchestrator that coordinates steps:
export default workflow({
  name: 'processOrder',
  inputSchema: z.object({ orderId: z.string() }),
  outputSchema: z.object({ status: z.string() }),
  fn: async function(input) {
    const order = await this.step.fetchOrder(input.orderId);
    return { status: order.status };
  }
});

step

Define a reusable unit that handles I/O:
export const fetchOrder = step({
  name: 'fetchOrder',
  inputSchema: z.string(),
  outputSchema: z.object({ status: z.string() }),
  fn: async (orderId) => {
    // API calls, database queries, etc.
    return { status: 'completed' };
  }
});

createWebhook

Pause a workflow until external input is received:
const feedback = await createWebhook({
  url: 'https://your-app.com/callback',
  payload: { workflowId: context.workflowId }
});

Environment Variables

The worker reads these environment variables:
VariableDefaultDescription
CATALOG_IDRequired. Identifies this worker’s catalog (used as task queue name)
TEMPORAL_ADDRESSlocalhost:7233Temporal server gRPC address
TEMPORAL_NAMESPACEdefaultTemporal namespace
TEMPORAL_API_KEYAPI key for Temporal Cloud (enables TLS)