Add @rivetkit/world-workflow package for Vercel Workflow SDK#4699
Add @rivetkit/world-workflow package for Vercel Workflow SDK#4699
Conversation
Adds a new package implementing the Vercel Workflow SDK World interface backed by three Rivet actors: a per-run workflow actor holding the event log and materialized state, a singleton coordinator for cross-run indexes and hook token uniqueness, and a per-queue runner with retry and idempotency handling. Includes local World type definitions, createRivetWorld factory, registry, and README documenting current gaps (readFromStream live streaming, global hook lookup, correlation id index).
|
🚅 Deployed to the rivet-pr-4699 environment in rivet-frontend
|
Code Review:
|
…nt readFromStream and queue dispatch Major changes: - Rewrite types.ts to match vercel/workflow packages/world/src exactly: runId/stepId/hookId fields, eventType/eventData naming, Streamer.streams namespace, Wait type, specVersion support, HealthCheckPayload - Implement readFromStream via actor event subscription (streams.get drains existing chunks then subscribes to streamAppended broadcast) - Add in-process queue dispatch: createQueueHandler registers handler, queue() dispatches immediately after enqueue via fire-and-forget - Add coordinator hookId index for hooks.get(hookId) lookups - Update workflow-run actor for new event types (hook_received, wait_*) and field renaming (completedAt, correlationId-based step/hook keying) - All files pass tsc --noEmit https://claude.ai/code/session_014t3My5a42LHJ1umwV3vGgh
Description
This PR introduces
@rivetkit/world-workflow, a new package that implements the Vercel Workflow SDK'sWorldinterface using Rivet Actors as the backing storage and queue infrastructure.The implementation replaces traditional Postgres + queue infrastructure with three Rivet actors:
workflowRunActor— One per workflow run (keyed byrunId). Owns:createEventto maintain the event log as the source of truthcoordinatorActor— Singleton (keyed by["coordinator"]). Serves as a cross-run index for:runs.list()querieshooks.getByToken()queueActor— One perValidQueueName(e.g.,__wkf_workflow_0). Handles:The package exports:
createRivetWorld(config)— Factory function to create aWorldinstanceregistry— Pre-configured RivetKit registry containing all three actorsType of change
How Has This Been Tested?
The package compiles successfully as a standalone workspace member. The implementation provides working implementations for the Storage, Queue, and Streamer interfaces with the following known limitations documented in the README:
readFromStreamlive streaming is not yet wired to thestreamAppendedactor eventhooks.get(hookId)lacks a global index; callers must usehooks.getByTokenevents.listByCorrelationIdreturns empty results (correlation IDs are not globally indexed)Checklist:
https://claude.ai/code/session_014t3My5a42LHJ1umwV3vGgh