Commit Graph

535 Commits

Author SHA1 Message Date
Vercel Release Bot 3dde14d529 Version Packages (beta) (#834) workflow@4.1.0-beta.51 2026-02-02 10:33:56 -08:00
Nathan Rajlich 2d4f52b9e0 Ignore all @workflow/example-* apps from changesets publish (#914) 2026-02-02 10:23:09 -08:00
Peter Wielander 90cd97beca [relaese] Fix workflow/ai peer dependendency causing a major bump in changeset (#913) 2026-02-02 10:00:00 -08:00
Peter Wielander 3730eb83ad Fix issues in prior changesets (#910) 2026-01-30 18:32:38 -08:00
Peter Wielander 773b7f8c6e [release] Changeset for beta-4.1.0 release (#909) 2026-01-30 18:16:58 -08:00
Peter Wielander 6ae65f0ed0 [core] Follow up fixes for v1 compat (#907) 2026-01-30 17:55:19 -08:00
Pranay Prakash 4f68877fbe fix(docs): align header nav responsive breakpoint with mobile menu (#906)
* fix(docs): align header nav responsive breakpoint with mobile menu

The desktop navigation links (Docs, Worlds, Examples) and search button
were using `xl:flex` (1280px) while the mobile hamburger menu used
`md:hidden` (768px). This created a gap between 768px-1280px where
neither the nav links nor the hamburger menu were visible.

Changed both to use `md:flex` so the navigation is visible at the same
breakpoint where the mobile menu button hides.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(docs): add top-level nav links to mobile sidebar menu

The mobile hamburger menu only showed the docs table of contents.
Now it also includes the top-level navigation links (Docs, Worlds,
Examples) at the top of the sheet with a border separator.

This ensures all navigation is accessible at mobile viewports.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:49:24 -08:00
Peter Wielander 972f3ce6ea fix(docs): restore SVG and ZIP file exclusion in middleware matcher (#904)
The docs template refactor accidentally removed the SVG and ZIP file
exclusions from the middleware matcher, causing public static assets
like workflow-circle-symbol-light.svg and workflow-circle-symbol-dark.svg
to be processed by the i18n middleware instead of being served directly.

This restores the original behavior where static files are served from
the public folder without middleware interference.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-01-30 14:22:39 -08:00
Peter Wielander a2b688d062 [core] Add runtime and world backwards compatibility for specVersion v1 (#894) 2026-01-30 13:23:08 -08:00
Nathan Rajlich 13d4ceef74 Use proper pluarlization in the builder log line (#898) 2026-01-30 11:58:55 -08:00
Peter Wielander 60a9b7661a [world-local] Increase default concurrency (#903) 2026-01-30 11:57:47 -08:00
Peter Wielander 36a0b41cb3 [web-shared] Fix o11y binary response parsing (#892) 2026-01-29 16:10:37 -08:00
Karthik Kalyan 0aa50e5ca4 Add 'use client' directives (#891)
* add use client

* add changeset
2026-01-29 15:45:11 -08:00
Peter Wielander b16cec4fdf [world] Fix zod compat for specVersion v1 payloads (#890) 2026-01-29 15:00:57 -08:00
Nathan Rajlich 1f684df6b7 Add a format identifier prefix for serialized data (#884) 2026-01-29 09:21:57 -08:00
Peter Wielander 556d86b521 Docs dark mode styling (#885)
* fix(docs): use true black backgrounds in dark mode and improve sidebar highlight visibility

- Change dark mode background from gray (oklch 0.145) to true black (oklch 0 0 0)
- Adjust card/popover backgrounds from oklch 0.205 to oklch 0.1 for better contrast
- Update secondary/muted/accent backgrounds from oklch 0.269 to oklch 0.15
- Set sidebar background to true black (oklch 0 0 0)
- Increase sidebar-accent from oklch 0.269 to oklch 0.2 for better visibility of highlighted items
- Set sidebar-accent-foreground to pure white (oklch 1 0 0) for maximum contrast

* chore: add empty changeset for docs styling change

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

---------

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-01-28 16:58:14 -08:00
Nathan Rajlich 600047af72 Fix workflow tarball URLs on "docs" app (#882) 2026-01-28 15:18:00 -08:00
Nathan Rajlich 1060f9d04a Change user input/output to be binary data at the World interface (#853) 2026-01-28 10:36:28 -08:00
Alan Cohen 4ad3fcd0a3 Pass runtime option to Vercel Build Output API functions (#800)
Signed-off-by: Alan Cohen <alan.mit@gmail.com>
2026-01-28 10:15:12 -08:00
Matan Kushner 8205717921 [docs] bypass proxy for sitemap and .md paths (#879) 2026-01-28 02:17:53 -05:00
Karthik Kalyan 409972e3b4 [perf]: add configurable dirs option to withWorkflow (#843)
* perf(builders): optimize workflow discovery with hybrid SWC approach

Apply SWC transforms only to files containing workflow/step directives
instead of all files. Uses regex for fast filtering, then SWC where needed.

- esbuild follows imports to build dependency graph
- regex detects 'use workflow'/'use step' directives
- SWC applied only to files with directives (<1% typically)
- other files use esbuild's built-in TS handling

* Remove blank line

* feat(next): add configurable `dirs` option to withWorkflow

Allow users to specify which directories to scan for workflow directives,
helping reduce memory usage and build times in large Next.js applications.

- Add `dirs` option that overrides the default directories
- Document all configuration options in API reference
- Add troubleshooting guide for OOM errors during build

* fix(docs): add missing imports in withWorkflow code example

Add missing import statements and nextConfig declaration to the
troubleshooting code example to fix docs typecheck.

* docs: move OOM troubleshooting to getting-started/next

Move the OOM troubleshooting section from the API reference to the
existing troubleshooting section in docs/getting-started/next.mdx
for better discoverability.

* move dirs inside workflow config
2026-01-27 21:51:39 -08:00
Peter Wielander 0b343192a3 [docs] Document NestJS setup + Vercel e2e tests (#850) 2026-01-27 19:12:50 -08:00
Hayden Bleasel 9ec21584d6 Update docs template (#552) 2026-01-27 18:50:50 -08:00
Pranay Prakash 1b78efa7cb Add documentation for common patterns and architecture notes (#875)
- Document fixed versioning for workflow and @workflow/core
- Add genversion pattern for build-time version injection
- Add turbo caching guidance for generated files
- Document executionContext field flexibility
- Document observability data hydration behavior

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 17:56:56 -08:00
Brice Lechatellier 347ffbcaba fix: extract actual output value from tool results in writeToolOutputToUI (#862)
Signed-off-by: Brice Lechatellier <brice@lechatellier.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 17:55:42 -08:00
John Lindquist 019057fafc Workflow Skills for npx skills (#842)
* Add workflow skill for Claude Code

Add custom slash commands for Claude Code:
- /pr command for creating PRs following repo conventions

Add workflow skill with comprehensive documentation:
- Main SKILL.md with core concepts and quick reference
- Reference docs for frameworks, AI agents, patterns, errors, and API

Signed-off-by: johnlindquist <johnlindquist@gmail.com>
Signed-off-by: John Lindquist <johnlindquist@gmail.com>

* Update SKILL.md serialization docs for custom class support

Add documentation for custom class serialization using @workflow/serde
symbols (WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE) and clarify what can
and cannot be serialized based on recent PR #762.

Signed-off-by: John Lindquist <johnlindquist@gmail.com>

* Fix incorrect API property names in SKILL.md

- Update sleep() example date from 2025 to 2027 (future date)
- Fix getWorkflowMetadata() to use correct properties: workflowRunId,
  workflowStartedAt, url (not runId, workflowName)
- Fix getStepMetadata() to use correct property: attempt (not attemptNumber)

Signed-off-by: John Lindquist <johnlindquist@gmail.com>

* Move skills to skill/workflow directory structure

Reorganize skill files to support multiple skills under ./skill/<name>/

Signed-off-by: John Lindquist <johnlindquist@gmail.com>

* Rename skill to skills (plural)

Signed-off-by: John Lindquist <johnlindquist@gmail.com>

* Refactor skills to use bundled docs from node_modules

- Update SKILL.md to direct agents to search node_modules/workflow/docs/
- Remove manually-maintained reference docs (ai-agents, api-reference, frameworks, patterns)
- Keep common-errors.md for practical troubleshooting
- Add prepack/postpack hooks to bundle docs in npm packages:
  - workflow: All docs from docs/content/docs/
  - @workflow/ai: AI-specific docs
  - @workflow/core: foundations, how-it-works, api-reference
  - @workflow/next: Next.js setup docs

Signed-off-by: John Lindquist <johnlindquist@gmail.com>

* Add AI SDK step function guidance to SKILL.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: John Lindquist <johnlindquist@gmail.com>

* Update SKILL.md formatting and add ecosystem section

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: John Lindquist <johnlindquist@gmail.com>

* Align postpack scripts with AI SDK conventions

Use del-cli for postpack cleanup to match the AI SDK's cross-platform
approach. This ensures consistent tooling across both projects.

- Add del-cli ^5.1.0 to root devDependencies
- Update postpack in @workflow/core, @workflow/next, @workflow/ai, and
  workflow packages from `rm -rf docs` to `del-cli docs`

Signed-off-by: John Lindquist <johnlindquist@gmail.com>

* Add workflow health command to debugging documentation

Document the CLI health check command for verifying workflow/step
endpoint connectivity during local development and production.

Signed-off-by: John Lindquist <johnlindquist@gmail.com>

* Address PR feedback: standardize on rm -rf and improve SKILL.md

- Remove del-cli dependency, use rm -rf consistently in postpack scripts
- Restructure SKILL.md to lead with "Prefer Step Functions" pattern
- Add sandbox limitations table for workflow-context workarounds
- Consolidate examples and remove duplication

Signed-off-by: John Lindquist <johnlindquist@gmail.com>

* Consolidate common-errors.md into SKILL.md

Move useful tips (serialization, streaming, debugging) into main skill
file and remove the separate common-errors.md reference file.

Signed-off-by: John Lindquist <johnlindquist@gmail.com>

---------

Signed-off-by: johnlindquist <johnlindquist@gmail.com>
Signed-off-by: John Lindquist <johnlindquist@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Pranay Prakash <pranay.gp@gmail.com>
2026-01-27 17:41:09 -08:00
Pranay Prakash 8e87b24f7d fix(@workflow/ai): support provider-executed tools (AI SDK v6) (#734)
Support provider-executed tools (AI SDK v6)

- Capture provider-executed tool results from stream
- Skip local execution for tools with providerExecuted: true
- Use correct AI SDK output types (json for objects, text for strings)
- Add warning when provider result is missing

Fixes #628
Fixes #433
Closes #434
2026-01-27 13:40:31 -08:00
Nathan Rajlich da8df6b26f Publish "workflow" and "@workflow/core" package versions in sync (#870) 2026-01-27 13:19:12 -08:00
Pranay Prakash c45bc3fd15 Add SDK version to workflow run executionContext for observability (#868)
* Add SDK version to workflow run executionContext for observability

Wire `@workflow/core` package version through the `executionContext` field
when creating workflow runs. Display the version in the observability UI
attribute panel. Uses genversion for build-time version injection.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix workflowCoreVersion extraction and add turbo.json for caching

- Extract workflowCoreVersion from executionContext in hydrateResourceIO
  before stripping the context (addresses Copilot review comment)
- Add turbo.json to include src/version.ts in build outputs for caching

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update workflowCoreVersion display name to @workflow/core version

Use a display name mapping to render the attribute as "@workflow/core version"
in the observability UI for better readability.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 13:15:06 -08:00
Karthik Kalyan 24ca465869 Allow recreateRun to accept an optional deploymentId parameter (#869) 2026-01-27 13:14:53 -08:00
Nathan Rajlich 244b94a066 Add support for top-level using declarations inside of step / workflow functions (#866) 2026-01-27 10:21:11 -08:00
Michael Han 4d7badce87 docs: URL in docs was missing the docs/ prefix, 404 errors (#852)
Signed-off-by: voyager14 <21mh124@queensu.ca>
2026-01-27 09:42:22 -08:00
Nathan Rajlich 81c5a835ae Add "classes" object to manifest.json file (#864) 2026-01-27 00:35:34 -08:00
Nathan Rajlich f2ab6ee179 Fix Nest workbench app build (#865)
* Use proper OpenAI import

```
Error: ../example/workflows/5_hooks.ts(36,22): error TS2351: This expression is not constructable.
  Type 'typeof import("/vercel/path0/node_modules/.pnpm/openai@6.1.0_ws@8.18.3_zod@4.1.11/node_modules/openai/index")' has no construct signatures.
```

* .
2026-01-27 00:21:33 -08:00
Nathan Rajlich a271719e76 Ignore Astro on local dev tests for source map e2e tests (#863) 2026-01-27 00:11:10 -08:00
Nathan Rajlich b4113da954 Enable custom class serialization transformations for "client" mode (#860) 2026-01-26 23:34:32 -08:00
Nathan Rajlich b59559be70 Submit request bodies with CBOR encoding (#844)
Updated request body encoding to use CBOR instead of JSON for all API requests in the `@workflow/world-vercel` package.

### What changed?

- Replaced JSON.stringify with CBOR encoding for all request bodies in the Vercel World package
- Removed the `dateToStringReplacer` function as it's no longer needed with CBOR encoding
- Updated the `makeRequest` utility to handle CBOR encoding of request bodies
- Renamed data parameters to `requestData` to avoid confusion with the `data` parameter in `makeRequest`

### Why make this change?

CBOR encoding provides several advantages over JSON:
- More efficient binary encoding, resulting in smaller request payloads
- Native support for Date objects without needing custom replacers
- Consistent with the existing response handling which already uses CBOR
- Improves performance for API requests with large payloads

This change maintains API compatibility while improving the underlying transport mechanism.
2026-01-26 16:56:08 -08:00
Peter Wielander 26a98330d4 [world-vercel] Update queue to use VQS v3 API (#799) 2026-01-26 14:55:08 -08:00
Peter Wielander 50f50f44d7 NestJS framework support (#840) 2026-01-26 13:31:22 -08:00
Karthik Kalyan f64b776165 Fix resolve hook theming and token fetching. (#856)
Keep the modal aligned with theme tokens and ensure hook resolution has the token it needs.
2026-01-26 11:51:44 -08:00
Pranay Prakash 243bf8f50d docs: rename Control Flow Patterns to Common Patterns and add new content (#846)
* feat: improve world page metadata and add dynamic OG images

- Update title format to '{Name} World | Workflow DevKit'
- Update worlds index page title to 'Worlds | Workflow DevKit'
- Improve world descriptions in worlds-manifest.json for better SEO
- Add dynamic OG image generation at /worlds/[id]/og
- Add openGraph and twitter metadata to world detail pages

* fix: use opengraph-image.tsx file convention for dynamic OG images

- Replace route-based og/route.tsx with opengraph-image.tsx file convention
- Remove runtime = 'edge' to allow generateStaticParams for static generation
- Simplify page.tsx metadata (Next.js auto-detects opengraph-image.tsx)

* docs: rename Control Flow Patterns to Common Patterns and add new content

- Rename page from control-flow-patterns to common-patterns
- Add redirect for old URL to prevent broken external links
- Add new Timeout Pattern section (Promise.race with sleep)
- Add new Workflow Composition section (direct await vs background execution)
- Implement @setup comment marker to hide type declarations in code examples
- Update navigation and references to new page name

* docs: move Full Example section after Parallel Execution

The Full Example only demonstrates sequential and parallel execution,
so it should come before the new Timeout and Workflow Composition patterns.

* fix: use useLayoutEffect to prevent flash of @setup lines in code blocks

* docs: remove incorrect retry/failure handling guidance from workflow composition
2026-01-26 11:23:37 -08:00
Pranay Prakash 8a146a5bb1 docs: revamp World documentation pages (#763)
* docs: revamp World documentation pages with new structure and design

- Add dedicated world detail pages at /worlds/[id] with MDX-driven content
- Create WorldDetailHero, WorldDetailToc, WorldTestingPerformance components
- Add benchmark history charts and test summary links
- Rewrite local-world, postgres-world, and vercel-world MDX with cleaner structure
- Use h3 headings for configuration options instead of tables/accordions
- Add WorldDataProvider context for passing world data to MDX components
- Add example field to worlds-manifest for linking to example repos
- Update worlds index page design

* fix: update worlds page meta title and description

* feat(docs): improve globe backdrop responsiveness and positioning

- Globe now scales with container width up to 1200px max
- Increased opacity from 20% to 30% for better visibility
- Positioned globe 30% down to show north pole behind header
- Globe component now auto-sizes based on container width

* fix(docs): add light mode support for globe backdrop

* feat: improve world page metadata and add dynamic OG images

- Update title format to '{Name} World | Workflow DevKit'
- Update worlds index page title to 'Worlds | Workflow DevKit'
- Improve world descriptions in worlds-manifest.json for better SEO
- Add dynamic OG image generation at /worlds/[id]/og
- Add openGraph and twitter metadata to world detail pages

* fix: use opengraph-image.tsx file convention for dynamic OG images

- Replace route-based og/route.tsx with opengraph-image.tsx file convention
- Remove runtime = 'edge' to allow generateStaticParams for static generation
- Simplify page.tsx metadata (Next.js auto-detects opengraph-image.tsx)

* docs: improve worlds page UI and restructure deploying section

- Fix globe visibility in light/dark mode
- Fix tooltip positioning on mobile breakpoints
- Remove redundant Documentation button for community worlds
- Add missing pages to Foundations index (streaming, serialization, idempotency)
- Restructure deploying section with new index and building-a-world guide
- Restore original MDX content for official worlds (local, vercel, postgres)
- Auto-expand sidebar folders when child page is active

* docs: simplify worlds page footer sections

* docs: move last updated section under worlds grid

* fix(docs): fix broken links and skip typecheck for interface definitions

- Fix /docs/deploying/world link to /docs/deploying/building-a-world
- Fix /docs/deploying#what-are-worlds invalid anchor to /docs/deploying
- Add @skip-typecheck markers to interface definition code blocks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(docs): address PR review feedback

- benchmark-history/route.ts: Add error handling for JSON parsing,
  distinguish 404s from actual errors
- Globe.tsx: Fix hydration mismatch by deferring theme-dependent
  rendering until component is mounted
- sidebar.tsx: Improve path check robustness for active child detection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 11:16:40 -08:00
Nathan Rajlich 00c7961ecb Remove unused getWritable stub function (#855) 2026-01-26 11:13:23 -08:00
Nathan Rajlich b973b8d00f Add support for CBOR responses (#832) 2026-01-23 15:26:17 -08:00
Peter Wielander 57f637653d [world-local] Fix package info stored in data dir showing the wrong version (#718) 2026-01-23 13:46:44 -08:00
Peter Wielander 36f9395044 [docs] Document multi-turn ai sessions with DurableAgent (#759) 2026-01-23 13:31:00 -08:00
Nathan Rajlich bd8116d40b Add WORKFLOW_SERVER_URL_OVERRIDE var to "world-vercel" for testing (#833)
Added `WORKFLOW_SERVER_URL_OVERRIDE` configuration to the Vercel world adapter and removed the deprecated `WORKFLOW_VERCEL_SKIP_PROXY` and `WORKFLOW_VERCEL_BACKEND_URL` environment variables.

### What changed?

- Added a changeset for a patch release across multiple packages
- Removed `WORKFLOW_VERCEL_SKIP_PROXY` environment variable from GitHub workflow tests
- Removed `WORKFLOW_VERCEL_BACKEND_URL` from environment variables in CLI and core packages
- Simplified the URL resolution logic in the Vercel world adapter
- Added support for a `WORKFLOW_SERVER_URL_OVERRIDE` constant for testing against different workflow-server versions
- Added the `x-vercel-workflow-api-url` header when the URL override is set

### How to test?

1. Verify that Vercel deployments continue to work without the removed environment variables
2. Test with a custom workflow server URL by setting the `WORKFLOW_SERVER_URL_OVERRIDE` constant in the world-vercel package

### Why make this change?

This change simplifies the configuration for the Vercel world adapter by removing deprecated environment variables and standardizing on a cleaner approach for specifying the workflow API URL. The new implementation automatically determines whether to use the proxy based on project configuration, making it more intuitive and reducing the need for explicit configuration.
2026-01-23 11:01:45 -08:00
Nathan Rajlich b16a6828af Move "parse-name" into the utils package (#814) 2026-01-23 10:57:52 -08:00
Pranay Prakash 4966b728a8 implement event-sourced architecture (#621)
* perf: implement event-sourced architecture

* Apply suggestions from code review

* Improve invalid event log handling in step/hook/wait

* Handle serialized workflow run errors correctly

* log error in failing test

* Handle queue idempotency in vercel world

* hotfix for error propogation

* Fix: Incorrect HTTP status code 409 should be 410 for terminal run state rejections in postgres storage

* Fix: The code attempts to pass an unsupported `fatal` property when creating a `step_failed` event. The TypeScript schema for `step_failed` events only allows `error` and `stack` properties, so the `fatal` property causes a compilation error.

This commit fixes the issue reported at packages/core/src/runtime/step-handler.ts:133-139

## TypeScript error: Invalid property 'fatal' in step_failed event

**What fails:** TypeScript compilation fails in `packages/core` due to an invalid property in the `step_failed` event creation.

**How to reproduce:**
```bash
cd /vercel/sandbox/primary
pnpm run -F @workflow/core build
```

**Result:**
```
src/runtime/step-handler.ts(133,32): error TS2769: No overload matches this call.
  Overload 1 of 2, '(runId: null, data: { eventType: "run_created"; ... }, gave the following error.
    Argument of type 'string' is not assignable to parameter of type 'null'.
  Overload 2 of 2, '(runId: string, data: CreateEventRequest, params?: CreateEventParams | undefined): Promise<EventResult>', gave the following error.
    Object literal may only specify known properties, and 'fatal' does not exist in type '{ error: any; stack?: string | undefined; }'.
```

**Issue:** The code attempted to pass a `fatal: true` property in the `eventData` object when creating a `step_failed` event. However, the event schema defined in `packages/world/src/events.ts` for `StepFailedEventSchema` only allows `error` and `stack` properties - the `fatal` property is not part of the schema.

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>

* Fix: Code silently skips updating workflowRun if result.run is undefined, causing workflows to be incorrectly skipped instead of throwing an error

* Add hook_conflict event type for duplicate token detection

Implements hook_conflict events across all world implementations to handle
cases where a workflow attempts to use a hook token already claimed by another
workflow. Instead of throwing errors, the system now records hook_conflict
events in the event log, enabling deterministic replay.

- Add HookConflictEvent schema to @workflow/world
- Implement hook_conflict in world-local, world-postgres, and suspension-handler
- Update hook consumer to reject promises with WorkflowRuntimeError on conflict
- Add HOOK_CONFLICT error slug with documentation
- Add e2e and unit tests for conflict scenarios

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add changeset for hook_conflict events

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add unit tests for hook_conflict handling

- Add tests for hook_conflict event in workflow.test.ts
- Fix world-postgres test to not expect removed message field

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Improve hook-conflict.mdx error guide

- Remove redundant third point in 'Why This Happens' section
- Add example showing how to handle WorkflowRuntimeError for hook conflicts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix docs validation: add hook-conflict to errors index

- Fix broken link in hook-conflict.mdx (/docs/foundations/webhooks -> /docs/api-reference/workflow/create-webhook)
- Add hook-conflict to errors index page so it's discoverable by the docs link validator

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix world-local tests for hook_conflict event behavior

Update tests to expect hook_conflict events instead of thrown errors when
duplicate hook tokens are used. This aligns with the new event-sourced
approach where conflicts are recorded as events rather than thrown.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add specVersion property to World interface for backwards compatibility

- Add specVersion property to World interface to track world package version
- Add specVersion to WorkflowRun schema and run_created event data
- World implementations (vercel, local, postgres) set specVersion from npm version
- Server can use specVersion to route operations based on world version
- Add specVersion display to observability UI attribute panel
- Add spec_version column to postgres runs schema

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add migration for spec_version column in postgres schema

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add drizzle migration journal and snapshot for spec_version column

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Regenerate postgres migration using drizzle-kit

- Properly generates migration with drizzle-kit CLI
- Removes deprecated 'paused' status from enum
- Adds spec_version column

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add backwards compatibility for event-sourced runs

- Add RunNotSupportedError for runs requiring newer world versions
- Add semver-based version utilities (isLegacyVersion) to @workflow/world
- World implementations check specVersion and route to legacy handlers
- Legacy runs (< 4.1.0): run_cancelled skips event storage, wait_completed stores event only
- New runs always get current world version (4.1.0-beta.0)
- Make EventResult.event optional for legacy compatibility

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Refactor spec version from semver strings to integers

Replace semver-based version compatibility with explicit integer spec versions:
- SPEC_VERSION_LEGACY (1): pre-event-sourcing runs
- SPEC_VERSION_CURRENT (2): event-sourced architecture

Use branded SpecVersion type to enforce importing from @workflow/world.
Remove semver dependency from world, world-local, and world-postgres.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Store error as CBOR in postgres world for consistency with input/output

- Add error_cbor bytea columns to workflow_runs and workflow_steps tables
- Deprecate text error column, rename to errorJson with fallback parsing
- Remove JSON.stringify from error writes (run_failed, step_failed, step_retrying)
- Add parseErrorJson helper for backwards compatibility with legacy data

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Use WorkflowRuntimeError and improve run entity handling in core runtime

- Replace generic Error with WorkflowRuntimeError for runtime assertions
- Add explicit check for run entity in run_created response
- Use run.runId instead of event.runId for consistency
- Use actual run status instead of hardcoded 'pending' in attributes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add specVersion to Step, Hook, and Event entities

- Add specVersion field to Step, Hook, and Event interfaces in @workflow/world
- Add spec_version column to steps, hooks, events tables in postgres schema
- Set specVersion to SPEC_VERSION_CURRENT when creating entities in all worlds
- Update migration to include spec_version columns for all entity tables

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Refactor world-local storage into modular files

Split storage.ts (1041 lines) into smaller, focused modules:
- storage/filters.ts: Data filtering helpers
- storage/helpers.ts: ULID and date utilities
- storage/hooks-storage.ts: Hook CRUD operations
- storage/legacy.ts: Legacy event handling
- storage/runs-storage.ts: Run get/list operations
- storage/steps-storage.ts: Step get/list operations
- storage/events-storage.ts: Event create/list operations
- storage/index.ts: Main composition

Also extracted test helpers to test-helpers.ts for reusability.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Remove genversion and World.specVersion property

The World.specVersion string property was never actually read - only
the numeric SPEC_VERSION_CURRENT is used for backwards compatibility.

- Remove genversion dependency and generated version.ts from @workflow/world
- Remove specVersion property from World interface and all implementations
- Minor fix: correct error message to reference 'workflow' package
- Minor fix: correct error source priority in world-vercel events.ts
- Minor fix: update comment in runtime.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Remove genversion from world-local, world-postgres, and world-vercel

These packages no longer need genversion since we removed the
World.specVersion property in the previous commit.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Remove version.ts from .gitignore files

No longer needed after removing genversion.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add legacy/backwards compatibility tests

Tests for world-local and world-postgres covering:
- Legacy runs (specVersion < 2 or null/undefined)
  - run_cancelled handling (updates run, no event stored)
  - wait_completed handling (stores event only)
  - Rejection of unsupported events
  - Hook cleanup on cancellation
- Future runs (specVersion > current)
  - Rejection with RunNotSupportedError
- Current version runs (normal processing)
- Legacy error parsing (errorJson field parsing)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add hook_received support for legacy runs

When resumeHook() is called on a legacy run (specVersion < 2), the
hook_received event was previously rejected. This adds support for
storing hook_received events on legacy runs without entity mutation,
matching the behavior of wait_completed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix missing genversion in world-vercel

Signed-off-by: Peter Wielander <mittgfu@gmail.com>

* Remove deprecated workflow_completed, workflow_failed, and workflow_started events

Replace with run_completed, run_failed, and run_started equivalents.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add specVersion to EventWithRefsSchema in world-vercel

The manually-created EventWithRefsSchema was missing the specVersion field,
which caused specVersion to be stripped when using lazy (refs) mode for events.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Wire specVersion from client through world backends

- Core runtime now sends specVersion in run_created eventData
- world-local accepts specVersion from eventData (defaults to current)
- world-postgres accepts specVersion from eventData (defaults to current)

This matches workflow-server behavior where v2 endpoints accept
specVersion from the client, while v1 endpoints default to legacy.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Move specVersion to event object level, propagate to entities

- Add specVersion to BaseEventSchema (event level, not eventData)
- Remove specVersion from RunCreatedEventSchema.eventData
- Core runtime sends specVersion on event object
- world-local reads specVersion from event, propagates to run/step/hook entities
- world-postgres reads specVersion from event, propagates to run/step/hook entities

This ensures specVersion flows from client through event to all created entities.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update specVersion to be optional in types for backwards compatibility

- specVersion is optional in all entity schemas (runs, steps, hooks, events)
  for backwards compatibility with legacy data in storage
- Runtime always sends specVersion on event requests
- world-local and world-postgres provide fallback to SPEC_VERSION_CURRENT
- Test helpers include specVersion in all event creation calls
- EventWithRefsSchema in world-vercel defaults specVersion to 1 for legacy

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix world-vercel queue tests missing VERCEL_DEPLOYMENT_ID setup

Two tests were calling queue.queue() without setting up
VERCEL_DEPLOYMENT_ID, causing them to fail with "No deploymentId
provided" error before reaching the code they were testing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add specVersion to all event creation calls in core package

The server's CreateEventSchemaV2 requires specVersion on all events,
but only run_created was sending it. This caused 400 Bad Request errors
for all other event types (run_started, run_completed, run_failed,
run_cancelled, step_created, step_started, step_completed, step_failed,
step_retrying, hook_created, hook_received, wait_created, wait_completed).

Now all event creation calls include specVersion: SPEC_VERSION_CURRENT.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Signed-off-by: Peter Wielander <mittgfu@gmail.com>
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
2026-01-22 17:24:52 -08:00
Michael Han 0b5cc48140 fix(builders): manifest missing workflow-only files (no steps), add tests (#831)
* Fix manifest missing workflow-only files (no steps), add tests

Signed-off-by: voyager14 <21mh124@queensu.ca>

* Update packages/builders/src/base-builder.ts

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Signed-off-by: Michael Han <21mh124@queensu.ca>

---------

Signed-off-by: voyager14 <21mh124@queensu.ca>
Signed-off-by: Michael Han <21mh124@queensu.ca>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2026-01-22 17:22:14 -08:00