Skip to main content
Node.js runtime required for Temporal workers. Temporal’s workflow runtime uses V8 isolates and cannot run in Deno. Use MockTemporalAgent in Deno for unit tests - it works without a Temporal server.
Temporal is a durable execution platform that makes long-running workflows resilient to failures. When you run a Vibes agent through Temporal, every model call and tool invocation is automatically retried on failure, replayed correctly after crashes, and auditable through Temporal’s history service. This makes Temporal the right choice for workflows that take minutes or hours, need guaranteed completion, or must survive process restarts.

How it works

The key insight: workflowFn is a deterministic orchestrator. It schedules activities (model turns, tool calls) as separate execution units. If the worker crashes mid-run, Temporal replays workflowFn from its event history and skips already-completed activities, resuming exactly where it left off.

Installation

Temporal requires three npm packages. These must run in a Node.js process:
The Vibes framework package (@vibesjs/sdk) provides TemporalAgent and MockTemporalAgent. No separate Temporal-specific Vibes package is needed.

TemporalAgent setup

TemporalAgentOptions fields: TemporalActivityOptions fields:

Worker setup (Node.js process)

The worker runs in a Node.js process. It registers temporalAgent.activities (a property) and a workflowsPath pointing to your workflow file.
Your workflows.ts file re-exports temporalAgent.workflowFn (also a property):
temporalAgent.activities and temporalAgent.workflowFn are properties, not methods.Do NOT call them with parentheses - they are not functions:
  • temporalAgent.activities - correct (property access)
  • temporalAgent.workflowFn - correct (property access)
Adding () after either property causes a TypeError at runtime.

Starting workflows

Workflows are started via the Temporal client - there is no framework method for this. The client connects to the Temporal server and schedules execution on the worker’s task queue.
You can also start a workflow and check it later without blocking:

Migration Warning: Five API Bugs in Old Documentation

If you’re migrating from older Vibes documentation, the following APIs were documented incorrectly. None of these exist in the actual framework:
  1. temporalAgent.start(client, opts) - This method does not exist. Use client.workflow.start(temporalAgent.workflowFn, opts) instead.
  2. temporalAgent.workflowsPath() - This method does not exist. Provide your own workflow file that re-exports temporalAgent.workflowFn.
  3. activities used as a method call - activities is a property, not a method. Use temporalAgent.activities (no parentheses).
  4. new MockTemporalAgent(agent) without a second argument - The constructor requires TemporalAgentOptions including taskQueue. Use new MockTemporalAgent(agent, { taskQueue: "test" }).
  5. serializeAgentState / deserializeAgentState - These exports do not exist. The correct names are serializeRunState and deserializeRunState.

MockTemporalAgent (testing)

MockTemporalAgent runs the same agent logic as TemporalAgent but without a real Temporal server. It records activity history for assertions, supports deterministic replay, and works in Deno.
MockTemporalAgent methods:

Testing pattern

Serialization helpers

When passing agent state through Temporal (which serializes all workflow arguments and results), you may need to convert between Vibes ModelMessage types and JSON-serializable formats.
The old docs used serializeAgentState and deserializeAgentState - these names do not exist. The correct exports are serializeRunState and deserializeRunState.

API reference

TemporalAgent

TemporalAgentOptions

TemporalActivityOptions

MockTemporalAgent

Serialization