### Hono Framework App Boundary Example Source: https://github.com/vercel/workflow/blob/main/skills/migrating-to-workflow-sdk/references/runtime-targets.md This example shows how to start a workflow within a Hono framework application. It defines a POST route to initiate the onboarding workflow. ```typescript import { Hono } from 'hono'; import { start } from 'workflow/api'; import { onboardingWorkflow } from '../workflows/onboarding'; const app = new Hono(); app.post('/api/onboarding/start', async (c) => { const body = (await c.req.json()) as { userId: string }; const run = await start(onboardingWorkflow, [body.userId]); return c.json({ runId: run.runId }); }); export default app; ``` -------------------------------- ### Install and Run Published @workflow/web Package Source: https://github.com/vercel/workflow/blob/main/packages/web/README.md Installs the @workflow/web package and its React dependencies, then starts the Next.js server from the installed package. Ensure React runtime dependencies are provided by the host project. The PORT environment variable can be used to specify the port. ```bash mkdir workflow-observability-ui cd workflow-observability-ui npm init -y # You must provide React runtime dependencies in your host project. npm i @workflow/web react react-dom # Run Next.js from the installed package (it contains the .next output) cd node_modules/@workflow/web npx --yes next start -p "${PORT:-3456}" ``` -------------------------------- ### Build and Start Production Server Source: https://github.com/vercel/workflow/blob/main/workbench/tanstack-start/README.md Commands to build the project for production and then start the production server. ```sh pnpm build && pnpm start ``` -------------------------------- ### Initialize World SDK Source: https://github.com/vercel/workflow/blob/main/skills/workflow/SKILL.md Get an instance of the World SDK. This is an asynchronous operation and requires environment setup. ```typescript const world = await getWorld(); ``` -------------------------------- ### Configure Next.js Start Script Source: https://github.com/vercel/workflow/blob/main/packages/web/README.md Sets a start script in the host package.json to run the Next.js server from the installed @workflow/web package, allowing port configuration via the PORT environment variable. ```json { "scripts": { "start": "cd node_modules/@workflow/web && next start -p $PORT" } } ``` -------------------------------- ### Setup Tmux Session for Workflow SDK Development Source: https://github.com/vercel/workflow/blob/main/skills/internal-dev-workbench/SKILL.md This script initializes a 3-pane tmux session for Workflow SDK development. It configures each pane with specific commands for the Next.js workbench, observability UI, and a scratchpad shell, all managed by portless for worktree-scoped URLs. Ensure prerequisites like tmux and portless are installed, and the repository is bootstrapped. ```bash REPO=/path/to/workflow-- # Session name = basename of the branch (matches portless's subdomain prefix # and the statusline's `tmux attach -t ` indicator). For branch # `pgp/foo-bar` this resolves to `foo-bar`. SESSION=$(git -C "$REPO" rev-parse --abbrev-ref HEAD) SESSION="${SESSION##*/}" # Create the session and capture the initial pane ID PANE_DEV=$(tmux new-session -d -s "$SESSION" -c "$REPO" -P -F '#{pane_id}') PANE_OBS=$(tmux split-window -h -t "$PANE_DEV" -c "$REPO" -P -F '#{pane_id}') PANE_SH=$(tmux split-window -v -t "$PANE_OBS" -c "$REPO" -P -F '#{pane_id}') mux select-layout -t "$SESSION" main-vertical # Pane DEV (left): Next.js turbopack workbench, with manifest exposed for e2e tmux send-keys -t "$PANE_DEV" \ 'cd workbench/nextjs-turbopack && WORKFLOW_PUBLIC_MANIFEST=1 portless run --name turbopack pnpm dev' C-m # Pane OBS (top-right): observability UI scoped to the workbench app tmux send-keys -t "$PANE_OBS" \ 'cd workbench/nextjs-turbopack && portless run --name workflow-obs sh -c "pnpm workflow web --webPort $PORT --noBrowser"' C-m # Pane SH (bottom-right): scratchpad at repo root tmux send-keys -t "$PANE_SH" 'echo "scratchpad: $(pwd)"' C-m tmux attach -t "$SESSION" ``` -------------------------------- ### Build Workflow Bundles for Example App Source: https://github.com/vercel/workflow/blob/main/CLAUDE.md Compiles workflow bundles specifically for the example application. ```bash cd workbench/example && pnpm build ``` -------------------------------- ### Local Development Setup with Docker Compose Source: https://github.com/vercel/workflow/blob/main/packages/world-postgres/README.md Set up your local development environment using Docker Compose for PostgreSQL. This includes starting the database, running migrations, and exporting necessary environment variables. ```bash # Start PostgreSQL database docker-compose up -d # Create and run migrations pnpm drizzle-kit generate pnpm drizzle-kit migrate # Set environment variables for local development export WORKFLOW_POSTGRES_URL="postgres://world:world@localhost:5432/world" export WORKFLOW_TARGET_WORLD="@workflow/world-postgres" ``` -------------------------------- ### Install AI SDK v6 Source: https://github.com/vercel/workflow/blob/main/packages/ai/README.md Install the latest AI SDK v6, which is recommended. ```bash npm install ai ``` -------------------------------- ### Example App Development Commands Source: https://github.com/vercel/workflow/blob/main/AGENTS.md Commands for building workflow bundles and using the workflow CLI within the example application directory. ```bash cd workbench/example && pnpm build ``` ```bash cd workbench/example && pnpm workflow [command] ``` ```bash cd workbench/example && pnpm wf [command] # shorthand ``` -------------------------------- ### Framework-Agnostic App Boundary Example Source: https://github.com/vercel/workflow/blob/main/skills/migrating-to-workflow-sdk/references/runtime-targets.md This example demonstrates starting a workflow from a framework-agnostic API endpoint using plain Request and Response objects. It's suitable when a framework-agnostic approach is required, even if specific frameworks are mentioned elsewhere. ```typescript import { start } from 'workflow/api'; import { onboardingWorkflow } from '../workflows/onboarding'; export async function POST(request: Request) { const body = (await request.json()) as { userId: string }; const run = await start(onboardingWorkflow, [body.userId]); return Response.json({ runId: run.runId }); } ``` -------------------------------- ### Run Development Server Source: https://github.com/vercel/workflow/blob/main/workbench/tanstack-start/README.md Use this command to start the development server for the TanStack Start workbench. ```sh pnpm dev ``` -------------------------------- ### Install @workflow/world-postgres Source: https://github.com/vercel/workflow/blob/main/packages/world-postgres/README.md Install the package using npm, pnpm, or yarn. ```bash npm install @workflow/world-postgres # or pnpm add @workflow/world-postgres # or yarn add @workflow/world-postgres ``` -------------------------------- ### Install AI SDK v5 Source: https://github.com/vercel/workflow/blob/main/packages/ai/README.md Install AI SDK v5 if you need to use an older version. ```bash npm install ai@5 ``` -------------------------------- ### Install Workflow Tarball Dependency Source: https://github.com/vercel/workflow/blob/main/tarballs/README.md Example of how to add a workflow tarball as a dependency in a package.json file. This allows for pre-release testing by installing directly from a Vercel deployment URL. ```json { "dependencies": { "workflow": "https://.vercel.sh/workflow.tgz" } } ``` -------------------------------- ### Start and Collect Child Workflow Source: https://github.com/vercel/workflow/blob/main/skills/migrating-to-workflow-sdk/references/shared-patterns.md Demonstrates starting a child workflow using `start` and collecting its result using `getRun`. The `childWorkflow` is defined with `'use workflow'` and `doWork` with `'use step'`. ```typescript import { getRun, start } from 'workflow/api'; export async function childWorkflow(input: string) { 'use workflow'; return await doWork(input); } async function doWork(input: string) { 'use step'; return { input, status: 'done' as const }; } async function spawnChild(input: string): Promise { 'use step'; const run = await start(childWorkflow, [input]); return run.runId; } async function collectChild(runId: string) { 'use step'; const run = getRun(runId); return (await run.returnValue) as { input: string; status: 'done' }; } ``` -------------------------------- ### Start Next.js Dev Server with Workflow Support Source: https://github.com/vercel/workflow/blob/main/CLAUDE.md Launches the Next.js development server with integrated workflow capabilities. ```bash cd workbench/nextjs-turbopack && pnpm dev ``` -------------------------------- ### Install @workflow/ai Source: https://github.com/vercel/workflow/blob/main/packages/ai/README.md Install the @workflow/ai package using npm. ```bash npm install @workflow/ai ``` -------------------------------- ### Start Workflow from API Route Source: https://github.com/vercel/workflow/blob/main/skills/workflow/SKILL.md Use `start()` to launch workflows directly from API routes. It returns immediately without waiting for completion. ```typescript import { start } from "workflow/api"; // From an API route — works directly export async function POST() { const run = await start(myWorkflow, [arg1, arg2]); return Response.json({ runId: run.runId }); } // No-args workflow const run = await start(noArgWorkflow); ``` -------------------------------- ### Setup PostgreSQL Database with CLI Source: https://github.com/vercel/workflow/blob/main/packages/world-postgres/README.md Use the CLI tool to automatically set up your PostgreSQL database. It loads .env files and prioritizes WORKFLOW_POSTGRES_URL, then DATABASE_URL, or defaults to a local instance. ```bash pnpm exec workflow-postgres-setup # or npm exec workflow-postgres-setup ``` -------------------------------- ### Use Workflow CLI Directly in Example App Source: https://github.com/vercel/workflow/blob/main/CLAUDE.md Executes commands using the workflow CLI within the example application directory. Supports both the full 'workflow' command and its shorthand 'wf'. ```bash cd workbench/example && pnpm workflow [command] cd workbench/example && pnpm wf [command] # shorthand ``` -------------------------------- ### Install OpenAI with AI SDK v5 Source: https://github.com/vercel/workflow/blob/main/packages/ai/README.md Install the OpenAI provider package when using AI SDK v5. ```bash npm install ai@5 @ai-sdk/openai@2 ``` -------------------------------- ### Start Next.js Production Server Source: https://github.com/vercel/workflow/blob/main/CLAUDE.md Runs the Next.js application in production mode. ```bash cd workbench/nextjs-turbopack && pnpm start ``` -------------------------------- ### Integration Test Approval Workflow Source: https://github.com/vercel/workflow/blob/main/skills/workflow/SKILL.md An example of integration testing an approval workflow. It demonstrates starting the workflow, waiting for and resuming a hook, waiting for a sleep, and waking up the workflow to check the final result. ```typescript // approval.integration.test.ts import { describe, it, expect } from "vitest"; import { start, getRun, resumeHook } from "workflow/api"; import { waitForHook, waitForSleep } from "@workflow/vitest"; import { approvalWorkflow } from "./approval"; describe("approvalWorkflow", () => { it("should publish when approved", async () => { const run = await start(approvalWorkflow, ["doc-123"]); // Wait for the hook, then resume it await waitForHook(run, { token: "approval:doc-123" }); await resumeHook("approval:doc-123", { approved: true, reviewer: "alice" }); // Wait for sleep, then wake it up const sleepId = await waitForSleep(run); await getRun(run.runId).wakeUp({ correlationIds: [sleepId] }); const result = await run.returnValue; expect(result).toEqual({ status: "published", reviewer: "alice" }); }); }); ``` -------------------------------- ### Install @workflow/nest Package Source: https://github.com/vercel/workflow/blob/main/packages/nest/README.md Install the main package and the required SWC packages for NestJS's SWC builder. ```bash npm install @workflow/nest # or pnpm add @workflow/nest ``` ```bash npm install -D @swc/cli @swc/core # or pnpm add -D @swc/cli @swc/core ``` -------------------------------- ### Next.js App Development Commands Source: https://github.com/vercel/workflow/blob/main/AGENTS.md Commands for starting the Next.js development server with workflow support, building the Next.js application, and starting the production server. ```bash cd workbench/nextjs-turbopack && pnpm dev ``` ```bash cd workbench/nextjs-turbopack && pnpm build ``` ```bash cd workbench/nextjs-turbopack && pnpm start ``` -------------------------------- ### Install Anthropic with AI SDK v6 Source: https://github.com/vercel/workflow/blob/main/packages/ai/README.md Install the Anthropic provider package when using AI SDK v6. ```bash npm install ai @ai-sdk/anthropic ``` -------------------------------- ### Run Local End-to-End Benchmarks Source: https://github.com/vercel/workflow/blob/main/packages/core/scripts/README.md Start the local development server and run the end-to-end benchmarks. This measures execution time for workflows on a local environment. ```bash # Local world (nextjs-turbopack dev server on :3000) cd workbench/nextjs-turbopack && WORKFLOW_PUBLIC_MANIFEST=1 pnpm dev & pnpm bench:local # from repo root ``` -------------------------------- ### Run Development Server Source: https://github.com/vercel/workflow/blob/main/workbench/sveltekit/README.md Starts the Svelte development server to enable hot-reloading. Includes an option to automatically open the application in the default browser. ```shell npm run dev # or start the server and open the app in a new browser tab npm run dev -- --open ``` -------------------------------- ### Input for Static Step Method Source: https://github.com/vercel/workflow/blob/main/packages/swc-plugin-workflow/spec.md Example of a static class method marked with the 'use step' directive. Instance methods are not supported. ```javascript export class MyService { static async process(data) { "use step"; return data.value * 2; } } ``` -------------------------------- ### Start Workflow World Helper Function Source: https://github.com/vercel/workflow/blob/main/skills/migrating-to-workflow-sdk/evals/non-vercel-runtime-branch.md A helper function to initialize the workflow world by calling its start method if available. This is useful for setting up the environment before workflow execution. ```typescript import { getWorld } from 'workflow/runtime'; export async function startWorkflowWorld(): Promise { await getWorld().start?.(); } ``` -------------------------------- ### Workflow Error Handling Examples Source: https://github.com/vercel/workflow/blob/main/skills/workflow/SKILL.md Demonstrates how to use FatalError for permanent failures and RetryableError for transient issues. Includes an example of using Promise.allSettled for parallel steps with mixed criticality. ```typescript import { FatalError, RetryableError } from "workflow"; // Permanent failure — workflow terminates throw new FatalError("Invalid input: missing required field"); // Transient failure — will retry throw new RetryableError("API rate limited", { retryAfter: "5m" }); // Mixed criticality parallel execution const results = await Promise.allSettled([ criticalStep(data), // Must succeed optionalStep(data), // OK to fail enrichmentStep(data), // OK to fail ]); const [critical, optional, enrichment] = results; if (critical.status === "rejected") throw new FatalError(critical.reason); ``` -------------------------------- ### Define Migration Prompt Source: https://github.com/vercel/workflow/blob/main/skills/migrating-to-workflow-sdk/SKILL.md Example of a prompt requesting a workflow migration to the Workflow SDK. ```text Migrate this Inngest workflow to the Workflow SDK. It uses step.waitForEvent() with a timeout and step.realtime.publish(). ``` -------------------------------- ### Instance Method as Workflow Step Source: https://github.com/vercel/workflow/blob/main/packages/swc-plugin-workflow/spec.md This example shows how an instance method can be defined as a workflow step using custom serialization methods. The `this` context is serialized and deserialized automatically. ```javascript import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde'; export class Counter { static [WORKFLOW_SERIALIZE](instance) { return { value: instance.value }; } static [WORKFLOW_DESERIALIZE](data) { return new Counter(data.value); } constructor(value) { this.value = value; } async add(amount) { 'use step'; return this.value + amount; } } ``` ```javascript import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde'; /**__internal_workflows{"steps":{"input.js":{"Counter#add":{"stepId":"step//./input//Counter#add"}}},"classes":{"input.js":{"Counter":{"classId":"class//./input//Counter"}}}}*/; export class Counter { static [WORKFLOW_SERIALIZE](instance) { return { value: instance.value }; } static [WORKFLOW_DESERIALIZE](data) { return new Counter(data.value); } constructor(value) { this.value = value; } async add(amount) { return this.value + amount; } } (function(__wf_fn, __wf_id) { var __wf_sym = Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = new Map()); __wf_reg.set(__wf_id, __wf_fn); __wf_fn.stepId = __wf_id; })(Counter.prototype["add"], "step//./input//Counter#add"); (function(__wf_cls, __wf_id) { var __wf_sym = Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = new Map()); __wf_reg.set(__wf_id, __wf_cls); Object.defineProperty(__wf_cls, "classId", { value: __wf_id, writable: false, enumerable: false, configurable: false }); })(Counter, "class//./input//Counter"); ``` -------------------------------- ### JSON Manifest Example Source: https://github.com/vercel/workflow/blob/main/packages/swc-plugin-workflow/spec.md This is an example of the JSON manifest comment generated at the top of a file. It contains metadata about discovered workflows, steps, and classes with custom serialization, used by bundlers and the runtime. ```javascript /**__internal_workflows{"workflows":{"path/file.ts":{"myWorkflow":{"workflowId":"workflow//./path/file//myWorkflow"}}},"steps":{"path/file.ts":{"myStep":{"stepId":"step//./path/file//myStep"}}},"classes":{"path/file.ts":{"Point":{"classId":"class//./path/file//Point"}}}}*/ ``` -------------------------------- ### Instance Class Method with 'use step' Source: https://github.com/vercel/workflow/blob/main/packages/swc-plugin-workflow/spec.md An example of an instance asynchronous method within a class, using the 'use step' directive. Note that this requires custom serialization. ```javascript async method() { "use step"; } ``` -------------------------------- ### Run Workflow Web UI with CLI Source: https://github.com/vercel/workflow/blob/main/packages/web/README.md Starts the web UI on the default port 3456. Use the --noBrowser flag when running on a server. ```bash npx workflow web --noBrowser ``` -------------------------------- ### Node.js Production Build and Execution Source: https://github.com/vercel/workflow/blob/main/workbench/fastify/README.md Compiles the application for a standard Node.js environment and starts the server using the generated output file. This is suitable for traditional server deployments. ```bash npm run build node .output/server/index.mjs ``` -------------------------------- ### Input for Static Workflow Method Source: https://github.com/vercel/workflow/blob/main/packages/swc-plugin-workflow/spec.md Example of a static class method marked with the 'use workflow' directive. This is used to define workflow entry points. ```javascript export class JobRunner { static async runJob(jobId) { "use workflow"; return await processJob(jobId); } } ``` -------------------------------- ### Static Async Class Method with 'use step' Source: https://github.com/vercel/workflow/blob/main/packages/swc-plugin-workflow/spec.md An example of a static asynchronous method within a class, using the 'use step' directive. This is a supported form for step functions. ```javascript static async method() { "use step"; } ``` -------------------------------- ### PostCSS Configuration for Tailwind CSS Source: https://github.com/vercel/workflow/blob/main/packages/web-shared/README.md Example configuration for postcss.config.mjs in a Next.js application to ensure Tailwind CSS classes are correctly processed by PostCSS. This setup is necessary for the styling of components from '@workflow/web-shared' to be applied correctly. ```javascript const config = { plugins: ['@tailwindcss/postcss'], }; export default config; ``` -------------------------------- ### Build and run for Node.js Source: https://github.com/vercel/workflow/blob/main/workbench/express/README.md Compiles the project and executes the generated server entry point. ```sh npm run build node .output/server/index.mjs ``` -------------------------------- ### Start Child Workflow from Workflow Step Source: https://github.com/vercel/workflow/blob/main/skills/workflow/SKILL.md To start child workflows from within a workflow, `start()` must be wrapped in a step function. This allows for asynchronous execution and integration with workflow logic. ```typescript import { start } from "workflow/api"; // Wrap start() in a step function async function triggerChild(data: string) { "use step"; const run = await start(childWorkflow, [data]); return run.runId; } export async function parentWorkflow() { "use workflow"; const childRunId = await triggerChild("some data"); // Fire-and-forget via step await sleep("1h"); } ``` -------------------------------- ### Build and Preview Production App Source: https://github.com/vercel/workflow/blob/main/workbench/sveltekit/README.md Compiles the application into a production-ready build and provides a command to preview the generated output locally. ```shell npm run build npm run preview ``` -------------------------------- ### Build All Packages Source: https://github.com/vercel/workflow/blob/main/CLAUDE.md Use this command to build all packages within the workspace. ```bash pnpm build ``` -------------------------------- ### Run All Documentation Tests Source: https://github.com/vercel/workflow/blob/main/packages/docs-typecheck/README.md Execute all documentation tests from the repository root or package directory. ```bash pnpm test:docs ``` -------------------------------- ### Build and deploy for Vercel Source: https://github.com/vercel/workflow/blob/main/workbench/express/README.md Configures the build for the Vercel preset and deploys the prebuilt output. ```sh NITRO_PRESET=vercel npm run build npx vercel --prebuilt ``` -------------------------------- ### Run Next.js Development Server Source: https://github.com/vercel/workflow/blob/main/workbench/nextjs-turbopack/README.md Commands to start the Next.js development server using different package managers like npm, yarn, pnpm, and bun. This allows for local development and testing of the application. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Initialize SWC Configuration Source: https://github.com/vercel/workflow/blob/main/packages/nest/README.md Run the init command to generate the .swcrc file with the Workflow SWC plugin for client-mode transformations. Add .swcrc to .gitignore. ```bash npx @workflow/nest init ``` ```bash echo '/.swcrc' >> .gitignore ``` -------------------------------- ### Add Pre-build Scripts to package.json Source: https://github.com/vercel/workflow/blob/main/packages/nest/README.md Configure your package.json scripts to regenerate SWC configuration before builds using 'npx @workflow/nest init --force' and then run 'nest build'. ```json { "scripts": { "prebuild": "npx @workflow/nest init --force", "build": "nest build" } } ``` -------------------------------- ### Get Hooks Source: https://github.com/vercel/workflow/blob/main/skills/workflow/SKILL.md Retrieve a hook by its ID or token. Hooks are used for external integrations or callbacks. ```typescript const hook = await world.hooks.get(hookId); const hook = await world.hooks.getByToken(token); ``` -------------------------------- ### Add WASM Build Target Source: https://github.com/vercel/workflow/blob/main/packages/swc-plugin-workflow/README.md Installs the wasm32-unknown-unknown target for Rust, necessary for building WebAssembly modules. ```bash rustup target add wasm32-unknown-unknown ``` -------------------------------- ### Initialize Workflow Runtime in Next.js Source: https://github.com/vercel/workflow/blob/main/packages/world-postgres/HOW_IT_WORKS.md Start the workflow workers within the Next.js instrumentation file to ensure they are active before request handling. ```ts // instrumentation.ts if (process.env.NEXT_RUNTIME !== "edge") { import("workflow/runtime").then(async ({ getWorld }) => { // start listening to the jobs. const world = await getWorld(); await world.start?.(); }); } ``` -------------------------------- ### Define Workflow World Interface Source: https://github.com/vercel/workflow/blob/main/skills/migrating-to-workflow-sdk/evals/non-vercel-runtime-branch.md Defines the interface for the workflow world, extending Storage, Queue, and Streamer capabilities with an optional start function. ```typescript interface World extends Storage, Queue, Streamer { start?(): Promise; } ``` -------------------------------- ### Run Full Suite Local Benchmarks Source: https://github.com/vercel/workflow/blob/main/packages/core/scripts/README.md Execute the full suite of local end-to-end benchmarks, including stress cases with many steps and concurrent workflows. ```bash # Full suite incl. 1000-step / 1000-concurrent / 500×10KB cases BENCHMARK_FULL_SUITE=true pnpm bench:local ``` -------------------------------- ### Extend Module Resolution Paths Source: https://github.com/vercel/workflow/blob/main/packages/docs-typecheck/README.md Add new package or subpath resolutions to `compilerOptions.paths` in `src/type-checker.ts` to extend module resolution for docs examples. ```typescript paths: { // existing mappings... '@workflow/new-package': [path.join(repoRoot, 'packages/new-package/dist/index')], } ``` -------------------------------- ### Test Core Functionality Source: https://github.com/vercel/workflow/blob/main/CLAUDE.md Navigates to the core package and runs its tests. ```bash cd packages/core && pnpm test ``` -------------------------------- ### Stream Management Source: https://github.com/vercel/workflow/blob/main/skills/workflow/SKILL.md Methods for writing, getting, closing, and listing streams associated with a run. Streams can be used for large data transfers or logs. ```typescript await world.streams.write(runId, name, chunk); await world.streams.writeMulti?.(runId, name, chunks); const readable = await world.streams.get(runId, name, startIndex); await world.streams.close(runId, name); const streamNames = await world.streams.list(runId); const chunks = await world.streams.getChunks(runId, name, { limit, cursor }); const info = await world.streams.getInfo(runId, name); ``` -------------------------------- ### List and Get Steps Source: https://github.com/vercel/workflow/blob/main/skills/workflow/SKILL.md Retrieve steps for a given run, with options for pagination and data resolution. The `runId` is a top-level parameter, not part of pagination. ```typescript const { data, cursor } = await world.steps.list({ runId, pagination: { cursor }, resolveData: 'all' | 'none' }); const step = await world.steps.get(runId, stepId, { resolveData: 'all' | 'none' }); ``` -------------------------------- ### Run Workflow Web UI with Specific Port Source: https://github.com/vercel/workflow/blob/main/skills/internal-dev-workbench/SKILL.md Execute the bundled CLI to start the observability UI configured for the current workbench app. Use `--webPort $PORT` and `--noBrowser` to manage the port and prevent automatic browser opening. ```bash pnpm workflow web --webPort $PORT --noBrowser ``` -------------------------------- ### Initialize Svelte Project Source: https://github.com/vercel/workflow/blob/main/workbench/sveltekit/README.md Creates a new Svelte project using the sv CLI. You can initialize in the current directory or specify a target folder name. ```shell # create a new project in the current directory npx sv create # create a new project in my-app npx sv create my-app ``` -------------------------------- ### Sync Function Declaration with 'use step' Source: https://github.com/vercel/workflow/blob/main/packages/swc-plugin-workflow/spec.md An example of a synchronous function declaration that uses the 'use step' directive. This is a supported form for step functions. ```javascript function name() { "use step"; } ``` -------------------------------- ### Workspace-level Build and Test Commands Source: https://github.com/vercel/workflow/blob/main/AGENTS.md Commands to build, test, format, lint, typecheck, and clean all packages within the workspace. ```bash pnpm build ``` ```bash pnpm test ``` ```bash pnpm test:e2e ``` ```bash pnpm format ``` ```bash pnpm lint ``` ```bash pnpm typecheck ``` ```bash pnpm clean ``` -------------------------------- ### Async Function Declaration with 'use step' Source: https://github.com/vercel/workflow/blob/main/packages/swc-plugin-workflow/spec.md An example of an asynchronous function declaration that uses the 'use step' directive. This is a supported form for step functions. ```javascript async function name() { "use step"; } ``` -------------------------------- ### Vercel Production Build and Deployment Source: https://github.com/vercel/workflow/blob/main/workbench/fastify/README.md Configures the build process for Vercel deployment and executes the deployment using the prebuilt output. This ensures the application is optimized for serverless execution. ```bash NITRO_PRESET=vercel npm run build npx vercel --prebuilt ``` -------------------------------- ### Static Class Getter with 'use step' Source: https://github.com/vercel/workflow/blob/main/packages/swc-plugin-workflow/spec.md An example of a static getter within a class, using the 'use step' directive. This is a supported form for step functions. ```javascript static get name() { "use step"; } ``` -------------------------------- ### Data Hydration (Devalue Format) Source: https://github.com/vercel/workflow/blob/main/skills/workflow/SKILL.md Instructions on how to hydrate serialized step I/O data using `hydrateResourceIO`. ```APIDOC ### Data Hydration (Devalue Format) **Description**: Step I/O is serialized using devalue. You must use `hydrateResourceIO` to deserialize it into usable JavaScript values. **Usage**: ```typescript import { hydrateResourceIO, observabilityRevivers } from "workflow/observability"; const { data: steps } = await world.steps.list({ runId, resolveData: 'all' }); const hydrated = steps.map(s => hydrateResourceIO(s, observabilityRevivers)); // Access hydrated input/output console.log(hydrated[0].input); console.log(hydrated[0].output); ``` `hydrateResourceIO` can also be used with `WorkflowRun` objects. For encrypted workflows, use `hydrateResourceIOWithKey()`. ``` -------------------------------- ### Object Literal Getter with 'use step' Source: https://github.com/vercel/workflow/blob/main/packages/swc-plugin-workflow/spec.md An example of a getter within an object literal, using the 'use step' directive. This is a supported form for step functions. ```javascript get name() { "use step"; } ``` -------------------------------- ### Sync Arrow Function with 'use step' Source: https://github.com/vercel/workflow/blob/main/packages/swc-plugin-workflow/spec.md An example of a synchronous arrow function expression that uses the 'use step' directive. This is a supported form for step functions. ```javascript const name = () => { "use step"; } ``` -------------------------------- ### Run E2E Tests Locally with Dev Server Source: https://github.com/vercel/workflow/blob/main/CLAUDE.md A multi-step process to run end-to-end tests locally. It involves starting a dev server, waiting for it to be ready, running the tests, and then stopping the server. Ensure environment variables like WORKFLOW_PUBLIC_MANIFEST=1 are set. ```bash # Step 1: Start the dev server in background # NOTE: WORKFLOW_PUBLIC_MANIFEST=1 is required for e2e tests to access the workflow manifest cd workbench/nextjs-turbopack && WORKFLOW_PUBLIC_MANIFEST=1 pnpm dev > /tmp/nextjs-dev.log 2>&1 & # Step 2: Wait for server to be ready (usually 15-20 seconds) sleep 15 # Step 3: Run the e2e tests from the project root DEPLOYMENT_URL="http://localhost:3000" APP_NAME="nextjs-turbopack" pnpm vitest run packages/core/e2e/e2e.test.ts # Step 4: Stop the dev server when done pkill -f "pnpm dev" ```