Commit Graph

646 Commits

Author SHA1 Message Date
Vercel Release Bot f4d168b012 Version Packages (beta) (#1045) workflow@4.1.0-beta.58 2026-02-19 15:16:28 -08:00
Casey Gowrie 29347b79ea New vercel queue client with v2beta consumers (#1096) 2026-02-19 22:24:15 +00:00
Peter Wielander 852e3f1788 Do not re-throw error when multiple workflow invocations race to complete/fail the workflow (#1118) 2026-02-18 14:00:47 -08:00
Nathan Rajlich ea3254e7ce Fix projectConfig.projectId containing project name instead of ID (#999)
* Fix projectConfig.projectId containing project name instead of ID

* add changeset

* Address review: fix changeset description, normalize slug-based project IDs, add clarifying comments
2026-02-18 02:03:31 -08:00
Nathan Rajlich 6e72b295e7 Add World.getEncryptionKeyForRun and thread encryption key through serialization (#979)
## Summary

- Adds `World.getEncryptionKeyForRun(run)` returning `Uint8Array | undefined` as the interface for retrieving per-run encryption keys
- Updates all 8 dehydrate/hydrate serialization functions to accept `key: Uint8Array | undefined`
- Updates runtime callers, CLI, and tests to thread the key parameter through
2026-02-18 00:53:49 -08:00
Nathan Rajlich 0d5323c0a7 Make serialization functions async (#978)
## Summary

- Makes all 8 dehydrate/hydrate serialization functions in `@workflow/core` async (returning `Promise<...>`)
- Updates all call sites across runtime, CLI, and test code to `await` the results
- Pure mechanical refactor — no functional changes, prerequisite for encryption support

Part 1 of the end-to-end encryption PR stack.
2026-02-17 23:18:44 -08:00
Karthik Kalyan 323da45b14 [web-shared] Minor perf hardening to minimize renders (#1104)
* [web-shared] reduce redundant render

* [web-shared] add changeset
2026-02-17 18:44:16 -08:00
Pranay Prakash 704661078f Auto-inject workflow run/step ID VQS headers from queue payload (#1098)
Move `x-workflow-run-id` and `x-workflow-step-id` header injection into
`world-vercel` queue implementation so callers don't need to set them
manually. The headers are extracted from the queue payload itself.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 21:44:06 +00:00
Karthik Kalyan 8a03a93b62 [web-shared] Improve liveness updates and fix bugs in Trace Viewer (#1086)
* [workflow o11y] Fix traceviewer bugs

* [workflow o11y] Fix traceviewer bugs - add changeset

* [workflow o11y] Fix react inspector state for open/close items

* [workflow o11y] Fix react inspector state for open/close items
2026-02-17 10:04:40 -08:00
Nathan Rajlich 54879835f3 Fix pages router default args: use empty array instead of [42] (#1081) 2026-02-17 01:47:48 -08:00
Nathan Rajlich 262ef3a21a Fix CLI missing specVersion in "run_cancelled" event payload (#1078)
The CLI's `cancelRun` in `packages/cli/src/lib/inspect/run.ts` sent `{ eventType: 'run_cancelled' }` without `specVersion`, causing the Vercel API's `/v2/runs/{id}/events` endpoint to reject the request with a 400 error. The core runtime's `cancelRun` already handled this correctly, so the fix removes the redundant CLI wrapper and calls the core implementation directly.

The bug was introduced in 4966b72 ("implement event-sourced architecture (#621)") which changed the CLI cancel from `world.runs.cancel(runId)` to `world.events.create(runId, ...)` but omitted `specVersion` from the payload. The same commit correctly included it in `Run#cancel()` in core — it was simply missed in the CLI path. A later commit (86a7930) added v1Compat branching but still never added specVersion. The final merged state in a2b688d (PR #894) still omits it.

Also adds a CLI cancel e2e test that starts a long-running workflow, cancels it via the CLI command, and verifies the run status.
2026-02-16 18:16:06 -08:00
JJ Kasper b733e2a173 Unlock canary Next.js version in tests and bump min deferred version (#1088)
* Unlock canary Next.js version

* bump min version
2026-02-16 17:27:16 -08:00
yao bcbdd024ef [nest] Support CommonJS compilation for NestJS projects (#982)
Signed-off-by: yao <zhangyaoruo@outlook.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-16 17:18:45 -08:00
Pranay Prakash 5e06a7c833 Materialize waits as entities to prevent duplicate wait_completed events (#1057)
* Handle 409 conflict when completing waits that were already completed

When multiple concurrent workflow invocations race to complete the same
wait, the server returns 409 (conflict) for duplicates. This change
handles the 409 gracefully in both runtime.ts (sleep elapsed check) and
runs.ts (wakeUpRun), preventing crashes and treating already-completed
waits as successful.

Also updates event-sourcing docs to reflect that waits are now
materialized as entities in storage with atomic completion guarantees.

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

* Point e2e tests at workflow-server preview for wait materialization branch

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

* Materialize waits as entities in local and postgres worlds to prevent duplicate wait_completed events

Adds Wait type/schema to the shared world package and implements wait entity
materialization in both local (filesystem) and postgres world implementations,
matching the DynamoDB behavior. wait_created creates a wait entity with status
'waiting', and wait_completed transitions it to 'completed' with guards that
reject duplicates (409).

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

* Fix waitId to use composite key for consistency with postgres world

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

* Clean up wait entities on terminal run states and register waits migration

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

* Clear WORKFLOW_SERVER_URL_OVERRIDE for merge

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

* Update changeset for all affected packages and restore server URL override

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

* Clear WORKFLOW_SERVER_URL_OVERRIDE now that server PR is merged

The server-side changes (vercel/workflow-server#265) have been merged to main
and deployed to production, so we no longer need to point at the preview URL.

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 16:46:49 -08:00
Nathan Rajlich 0946dad01b Remove "workflow/internal/serialization" export (#1082)
* Remove "workflow/internal/serialization" export

Was only being used in these two e2e test files and the data being passed in those tests don't rely on any specialized data types, so just use JSON there.

* Fix: Removing the `workflow/internal/serialization` export from package.json breaks 5 files in `packages/world-testing` that still import `hydrateWorkflowReturnValue` from that path.

Co-authored-by: TooTallNate <n@n8.io>

* lockfile

---------

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
2026-02-16 11:50:57 -08:00
Pranay Prakash f934e52c22 add closure comment in sleep test helper (#1071)
Per TooTallNate's review on #1055: the setupWorkflowContext helper
has a circular reference where ctx.onWorkflowError is accessed via
closure before it's defined on the object. Add a clarifying comment.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:48:18 -08:00
Peter Wielander 0edcccf84d [ci] Skip for CI checks when doing vercel backend testing only (#1063) 2026-02-15 18:37:17 +00:00
Nathan Rajlich 89f96306ea fix(docs): correct retry instructions in corrupted-event-log error page (#1059)
Remove reference to non-existent 'npx workflow runs start' CLI command.
The correct way to retry is via the Re-run button in the Workflow Dashboard.
2026-02-14 01:07:00 -08:00
Pranay Prakash c2b4fe9906 fix(core): detect and fatal error on orphaned/invalid events (#1055)
* fix(core): detect and fatal error on orphaned/invalid events in EventsConsumer

When an event log has duplicate or invalid events (e.g., 2 wait_completed for a single wait_created), the EventsConsumer gets stuck: the orphaned event has no callback to consume it, so eventIndex never advances, blocking all subsequent events and hanging the workflow forever. This adds deferred orphaned event detection that raises a WorkflowRuntimeError instead.

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

* add corrupted-event-log error slug and docs page

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

* add changeset for orphaned event detection

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

* address PR feedback on docs and JSDoc

- Add JSDoc to EventsConsumer constructor's onUnconsumedEvent parameter
- Rewrite docs to clarify this is a SDK/server bug, not user code
- Remove cancel/programmatic retry advice; run is already marked failed
- Emphasize error is uncatchable inside workflow code
- Add steps: upgrade package, retry via dashboard/CLI, report issue on GitHub

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

* address PR review: structured options, required callback, reorder docs

- Change EventsConsumer constructor to use structured EventsConsumerOptions object
- Make onUnconsumedEvent required (all callsites provide it)
- Move corrupted-event-log card to last position in errors index
- Update all callsites in tests

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

* fix docs code sample to pass type-checking

Use correct imports (getRun from workflow/api) and declare variables
to satisfy the docs-typecheck CI job.

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

* add e2e test for parallel sleep (Promise.all with 10x sleep)

Adds parallelSleepWorkflow that does Promise.all with 10 concurrent
sleep('1s') calls, and an e2e test asserting it completes or fails
within a reasonable time (not hanging).

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

* fix parallelSleep e2e test: await returnValue instead of checking status

run.status returns immediately and the workflow is still 'running'.
Use run.returnValue which polls until completion.

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

* fix parallelSleep e2e: assert parallel completion under 10s

The test verifies 10 concurrent sleep('1s') calls complete in parallel
(~1s) rather than serially (10s) or hanging indefinitely. 30s timeout
is sufficient since the workflow should finish in ~1-2s.

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 23:31:39 -08:00
JJ Kasper c6b75b7698 test(core): stream and capture build logs in local e2e (#1050) 2026-02-14 02:33:09 +00:00
JJ Kasper 550997659d Update tests.yml triggers for release PR (#1048) 2026-02-14 02:31:22 +00:00
Peter Wielander 9f77380493 Fix 429 retry (#1051) 2026-02-13 17:10:14 -08:00
Karthik Kalyan befc01d7cb Fix sidebar title (#1053)
* Fix sidebar title

* Fix sidebar title

* Fix sidebar title

* Fix sidebar title

* Fix sidebar title
2026-02-14 01:09:58 +00:00
JJ Kasper 565e5ebd56 Lock Next.js canary version (#1054) 2026-02-13 23:13:44 +00:00
JJ Kasper 26399c107a ci: add 30-minute timeouts to test jobs (#1052) 2026-02-13 14:45:23 -08:00
Nathan Rajlich 5213309073 Fix "dev" script in web package (#1039)
* Fix "dev" script in `web` package

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Nathan Rajlich <n@n8.io>

---------

Signed-off-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-13 14:24:27 -08:00
Nathan Rajlich 260f77e023 Retheme <DataInspector> to match Node.js util.inspect() colors (#1033)
Replaces the Chrome DevTools color scheme with one inspired by
Node.js util.inspect() ANSI stylizing: green strings, yellow
numbers/booleans, grey undefined, magenta dates, cyan functions,
and neutral property names. Adds an extended theme context to
color Date instances (react-inspector has no built-in theme key
for dates). Removes color-hash dependency which is no longer used.
2026-02-13 14:21:18 -08:00
Nathan Rajlich dbf8434907 Extract reusable <DataInspector> component and fix class instance rendering (#1032)
Consolidate all ObjectInspector usage into a single DataInspector component
with shared theming, custom nodeRenderer for StreamRef/ClassInstanceRef, and
stream click context. Update all consumers (attribute-panel, events-list,
event-list-view, stream-viewer, conversation-view) to use DataInspector
instead of direct ObjectInspector or JSON.stringify. Fix class instance
hydration to create objects with dynamically-named constructors so
react-inspector shows proper class names via constructor.name.
2026-02-13 14:20:24 -08:00
JJ Kasper f5ae600db4 fix(e2e): stabilize 5xx step_completed fault injection (#1046) 2026-02-13 14:03:06 -08:00
Pranay Prakash c9b4547b0b claude fix demo (#1047) 2026-02-13 13:53:42 -08:00
Nathan Rajlich 8cfb43808b Use @vercel/cli-auth for auth token reading and OAuth refresh (#1043)
* Use `@vercel/cli-auth` for auth token reading and OAuth refresh

Replace the manual auth.json reading logic in the CLI with the `@vercel/cli-auth` package, which handles credential storage via CredentialsStore and OAuth token refresh via the OAuth client.

Previously, the CLI would read the token from disk but had no refresh logic — if the token was expired, API calls would fail.
Now, getAuthToken() checks token expiry and automatically refreshes it using the stored refresh token before returning it.

* Remove dead logging
2026-02-13 21:46:11 +00:00
Karthik Kalyan 1c1157340d [builders][web-shared] Improvements to o11y and fixes to graph generation code path (#1031)
* [workflow o11y] rebase on latest main and keep targeted UI/builders changes

Rebase the branch intent onto latest main by preserving web-shared UI refactors and builders base-builder updates while taking main for hydration and data-fetching behavior elsewhere.

Co-authored-by: Cursor <cursoragent@cursor.com>

* [workflow o11y] align web-shared hydration revivers with main

Revert the hydration reviver delta for URL, URLSearchParams, and Headers so web-shared matches main behavior while keeping the targeted UI/builders-only scope on this branch.

Co-authored-by: Cursor <cursoragent@cursor.com>

* [workflow o11y] restore PR #1017 detail-panel decoupling

Bring the web-shared trace/detail panel files back in sync with main so PR #1017 behavior is preserved and not regressed on this branch.

Co-authored-by: Cursor <cursoragent@cursor.com>

* [workflow o11y] restore PR #1018 react-inspector sidebar updates

Bring web-shared o11y rendering files back in sync with main so ObjectInspector-based sidebar rendering and related UI behavior from PR #1018 remain intact on this branch.

Co-authored-by: Cursor <cursoragent@cursor.com>

* [workflow o11y] keep custom viewers and apply inspector rendering

Preserve the branch-specific event list and stream viewer UX while applying react-inspector rendering to payload/chunk data so complex hydrated values render correctly without reverting custom UI behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>

* [workflow o11y] trace viewer UX improvements and Geist alignment

- Add live tick animation, context menu, and cancel run support from PR #984
- Decouple side panel styling to use Geist design tokens (inline styles)
- Fix sleep span detail panel showing events instead of wait entity attributes
- Fix stream viewer flickering by removing unstable object deps
- Remove Chunks/Output toggle from stream viewer, show only chunks
- Add resolve hook modal, wake-up sleep, and cancel run plumbing
- Add loading skeleton for stream viewer

Co-authored-by: Cursor <cursoragent@cursor.com>

* Bug fixes

* Bug fixes

* Bug fixes

* Bug fixes

* Bug fixes

* Bug fixes

* Bug fixes

* Bug fixes

* Bug fixes

* Bug fixes

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-13 13:27:16 -08:00
Vercel Release Bot cf98219931 Version Packages (beta) (#1037)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
workflow@4.1.0-beta.57
2026-02-13 13:26:11 -08:00
JJ Kasper 30076ecea8 Enable lazyDiscovery in workbench (#1044) 2026-02-13 12:45:46 -08:00
JJ Kasper b0464b6af2 Always run canary Next.js tests (#1042) 2026-02-13 18:36:18 +00:00
JJ Kasper f4a1994c4b Fix condition for lazy discovery with canary (#1038)
* Fix condition for lazy discovery with canary

* revert test change
2026-02-13 10:13:36 -08:00
JJ Kasper 01e8e80462 Make lazy discovery in Next.js opt-in (#1036) 2026-02-13 16:36:24 +00:00
Hayden Bleasel 6da8e2358b Update Docs (#1028)
* Remove math and mermaid

* Add alternates
2026-02-13 05:59:28 +00:00
Vercel Release Bot 295f6cd0b6 Version Packages (beta) (#1013)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
workflow@4.1.0-beta.56
2026-02-12 20:09:35 -08:00
Pranay Prakash ff9fcc25ad Fix benchmark history continuity and caching (#1034)
* Fix benchmark history continuity across metric name rename

The concurrent step benchmarks were renamed in beta.53 (dropping the
"stress test: " prefix), which broke the history API's exact-name lookup
against older gh-pages data. Add legacy alias fallbacks so charts show
continuous history across the rename boundary.

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

* Paginate GitHub API calls and use generic legacy name fallback

Three fixes:
- Paginate gh-pages commits (was fetching 100 of 216, missing most history)
- Paginate tags (workflow@ tags were cut off beyond page 1)
- Paginate main branch commits for commits mode
- Replace hardcoded LEGACY_METRIC_ALIASES with generic "stress test: "
  prefix fallback

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

* Cache benchmark history with unstable_cache and aggressive CDN TTLs

The snapshot map (200+ GitHub API fetches) is now cached via
unstable_cache for 1 hour, shared across all parameter combinations.
Tags are cached separately. Individual fetch calls use force-cache
with long revalidation periods since historical data is immutable.

CDN cache bumped from 5min to 1h with 24h stale-while-revalidate,
matching how infrequently benchmark data changes.

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 19:57:18 -08:00
Pranay Prakash 8d117cd219 Retry 5xx errors from workflow-server in step handler (#1011)
* Retry 5xx errors from workflow-server in step handler

Add `withServerErrorRetry` helper that retries world calls on 5xx errors
with exponential backoff (500ms, 1s, 2s ≈ 3.5s total). Applied to all
`world.events.create` calls in the step handler so transient
workflow-server errors don't consume step attempts.

If retries are exhausted, the error is thrown to the queue for
higher-level retry without burning a step attempt.

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

* Address PR review comments on 5xx retry handling

- Fix misleading `maxAttempts` log field to `maxRetries` in withServerErrorRetry
- Update step-handler comment to accurately note that queue retries may
  still consume step attempts since step_started has already incremented
- Add unit tests for withServerErrorRetry (7 tests covering success,
  retry/backoff, exhaustion, and non-5xx passthrough)

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

* Add tests for 429/5xx retry handling

Unit tests for withThrottleRetry and withServerErrorRetry helpers, plus
an e2e test that exercises the 5xx retry codepath during step execution
via run-scoped fault injection.

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

* Wrap VQS errors in WorkflowAPIError and add retry to queueMessage

VQS throws its own error types (InternalServerError, ConsumerDiscoveryError,
ConsumerRegistryNotConfiguredError) that don't match WorkflowAPIError.is().
Wrapping them at the world-vercel boundary enables withServerErrorRetry in
queueMessage() to automatically retry transient queue failures.

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

* Update changeset to include @workflow/world-vercel

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

* Remove queue retry logic per review feedback

Queue retrying will be handled natively by the @vercel/queue client
instead. Reverts VQS error wrapping and withServerErrorRetry in
queueMessage().

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 18:42:36 -08:00
JJ Kasper 94760b4640 Track loader transform deps instead of clearing Next cache (#1029)
* Track loader transform dependencies and remove SWC cache invalidation

* changeset
2026-02-12 17:41:47 -08:00
Nathan Rajlich 8a53c3fa3d Use react-inspector for data rendering in o11y sidebar (#1018)
## Summary

Replace the custom `JSON.stringify`-based data renderer with [`react-inspector`](https://www.npmjs.com/package/react-inspector)'s `ObjectInspector` component for proper display of all JavaScript types in the o11y sidebar panel.

## Before

Data was rendered via `JSON.stringify(value, null, 2)` in a `<pre>` block. Non-plain-object types like `Map`, `Set`, `URLSearchParams`, `Date`, `Error`, `RegExp`, and typed arrays all rendered as `{}` or lost their type information.

## After

Uses `react-inspector` (the same rendering engine as Chrome DevTools) to display data as expandable tree views with proper type labels:
- `URLSearchParams {size: 12}` with entries visible
- `Map(3)` / `Set(5)` with contents
- `Date "2026-02-11T..."` 
- `Error {message: "...", stack: "..."}` 
- `Uint8Array(32)` with byte values

## Implementation

- Replace `JsonBlock` function with `DataInspector` component using `ObjectInspector`
- Custom theme with transparent background and design system CSS variables (`--ds-gray-*`, `--font-mono`)
- Dark/light mode support via `useDarkMode` hook
- `StreamRef` and `ClassInstanceRef` objects still render as custom components (clickable stream links and styled class cards)
- Expand level defaults to 2 for a good overview without overwhelming

## Dependencies
- Added `react-inspector@9` to `@workflow/web-shared`
2026-02-12 17:37:50 -08:00
Nathan Rajlich 4938b24674 Decouple detail panel from trace viewer web worker pipeline (#1017)
## Summary

Render the `EntityDetailPanel` (step/hook/event detail sidebar) outside the trace viewer's `TraceViewerContextProvider`, so hydrated data no longer passes through the web worker's `postMessage` structured clone boundary.

## Problem

The trace viewer uses a web worker for span layout calculations, sending data via `postMessage` which requires structured cloning. After moving hydration client-side, the hydrated data (containing `URLSearchParams`, `Headers`, and other non-structurally-cloneable types) was embedded in trace span attributes and sent to the worker, causing `DOMException: URLSearchParams object could not be cloned`.

## Solution

Render the detail panel as a **sibling** to the trace timeline instead of nested inside the context:

```
Before:                          After:
TraceViewerContext               [flex row]
  └─ Timeline                     ├─ TraceViewerContext
       └─ Panel (inside worker)   │    └─ Timeline (worker)
                                  └─ Panel (direct props)
```

- `WorkflowTraceViewer`: flex layout with timeline + panel as siblings
- `SelectionBridge`: lightweight component inside context that reads the selected span and passes it up via callback
- `EntityDetailPanel`: no longer imports `useTraceViewer()`, receives selected span info via `selectedSpan` prop
- Panel has independent width/resize state (no longer coupled to the trace viewer context)
- Strip `input`/`output`/`error` from trace span attributes to keep worker data lightweight

## Also fixes
- Stale `customPanelComponent` bug — the panel was stored in context state during initialization and never updated, causing data to be lost on re-renders
2026-02-12 17:17:07 -08:00
Nathan Rajlich c56dc3848e Extract browser-safe serialization format and move hydration client-side (#1015)
## Summary

Split the serialization/deserialization logic into environment-specific layers so data hydration can happen client-side in the browser. This is a prerequisite for e2e encryption where decryption keys are only available in the browser.

## Architecture

### Layer 1: `@workflow/core/serialization-format` (new, browser-safe)
- Format prefix encoding/decoding (`devl`, future `encr`, etc.)
- Generic `hydrateData()` dispatch — handles Uint8Array (v2 binary), legacy arrays (v1), and plain values
- `hydrateResourceIO(resource, revivers)` resource-type dispatcher (step/hook/event/workflow field mapping)
- `ClassInstanceRef` (plain data class, no `node:util` dependency)
- `StreamRef`, type guards (`isStreamRef`, `isStreamId`, `isClassInstanceRef`), utility functions (`extractStreamIds`, `truncateId`)
- Shared `observabilityRevivers` for stream/class/step display overrides
- 36 unit tests covering all of the above

### Layer 2: Environment-specific revivers
- **`@workflow/web-shared`** (`lib/hydration.ts`) — browser-safe revivers using `atob()` for base64, real `URLSearchParams`/`Headers`/`URL` instances, `ClassInstanceRef` for UI rendering
- **`@workflow/cli`** (`lib/inspect/hydration.ts`) — Node.js revivers using `Buffer.from()` for base64, `CLIClassInstanceRef` with `util.inspect.custom` for CLI output

Each module exports a pre-bound `hydrateResourceIO(resource)` that uses its environment's revivers.

### Removed: `@workflow/core/observability`
- Deleted `observability.ts` and `observability.test.ts` entirely (no remaining consumers)
- Removed `"./observability"` export from `@workflow/core/package.json`
- Removed the `workflow` package's `internal/observability.ts` re-export
- All functionality has been split between `serialization-format.ts` (shared types/utilities) and the environment-specific hydration modules

## Web package changes
- Server passes raw world data through without hydration (CBOR preserves `Uint8Array`)
- Client calls `hydrateResourceIO` from `@workflow/web-shared` after receiving CBOR-decoded data
- No Vite `node:*` stubs needed since `@workflow/core/serialization-format` is browser-safe
- Optimized: event hydration finds the matching event before hydrating (instead of hydrating all)
- Reduced server log noise from handled API errors (4xx errors no longer logged)

## Packages affected
- `@workflow/core` — new `serialization-format` export (with tests), removed `observability` export
- `@workflow/web-shared` — new `lib/hydration.ts` with browser-safe revivers
- `@workflow/cli` — new `lib/inspect/hydration.ts` with Node.js revivers, updated `output.ts` import
- `@workflow/web` — client-side hydration, removed server-side hydration
- `workflow` — removed `internal/observability.ts` re-export
2026-02-12 16:58:19 -08:00
Nathan Rajlich 7653e6bfdb Migrate @workflow/web from Next.js to React Router v7 (#1005)
## Summary

- Replace Next.js App Router with React Router v7.13.0 framework mode (Vite-based), eliminating the large `next` dependency from the web, CLI, and workflow metapackages
- Serve the web UI in-process from the CLI via Express instead of spawning `next start` as a child process
- Switch RPC transport from JSON to CBOR to preserve binary data types across the wire
- Replace `nuqs` URL state management with React Router's `useSearchParams`
- Replace Next.js server actions with an RPC resource route (`/api/rpc`) and a thin CBOR-based client

## Motivation

The `next` package is ~300MB installed and was the single largest dependency in the monorepo. It also required spawning a separate child process from the CLI to run the o11y web server, adding complexity around process lifecycle management, port readiness polling, and environment variable forwarding.

With React Router framework mode, the web package builds to a standard Express-compatible server bundle that the CLI can import and serve directly in its own process.

## What changed

**Framework swap (`@workflow/web`):**
- `next.config.ts` / `postcss.config.mjs` → `react-router.config.ts` / `vite.config.ts`
- `src/` directory → `app/` directory (React Router convention)
- `src/app/layout.tsx` + `layout-client.tsx` → `app/root.tsx`
- `src/app/page.tsx` → `app/routes/home.tsx`
- `src/app/run/[runId]/page.tsx` → `app/routes/run-detail.tsx`
- Path alias `@/` → `~/`
- Removed all `'use client'` / `'use server'` directives

**Data transport:**
- Server actions → RPC resource route at `/api/rpc` with CBOR encoding
- CBOR preserves `Uint8Array` and other binary types natively (no base64 overhead)
- Stream reading → dedicated `/api/stream/:streamId` resource route

**URL state:**
- `nuqs` (`useQueryState`) → `useSearchParams` from `react-router`

**Fonts:**
- `next/font/google` → Geist `.woff2` files referenced directly from `node_modules/geist` via `@font-face` in CSS

**CLI integration (`@workflow/cli`):**
- `import('@workflow/web/server').then(m => m.startServer(port))`
- No child process, no readiness polling, no cleanup handlers

**Radix UI compatibility:**
- `onSubmit` preventDefault on `AlertDialogContent` and `SheetContent` to prevent Radix's internal `<form method="dialog">` from triggering React Router route actions
- Catch-all action on root route for any stray POSTs

## Dependencies removed
- `next`, `swr`, `nuqs`, `@tailwindcss/postcss`

## Dependencies added
- `react-router` / `@react-router/dev` / `@react-router/node` / `@react-router/express` (all `7.13.0`)
- `express`, `vite`, `@tailwindcss/vite`, `cbor-x`, `isbot`, `cross-env`
- `geist` (devDep)
2026-02-12 16:30:51 -08:00
Nathan Rajlich d7d005b54b Allow @ in workflow names to support scoped packages (#990) 2026-02-12 11:40:17 -08:00
Hayden Bleasel 2cc8c3dc9c Update docs (#1010)
* Run update script

* Update deps

* Restore code block modifications

* Reapply navbar patch

* Restore custom proxy config

* Add md-metadata

* Add new frontmatter
2026-02-12 19:27:52 +00:00
Nathan Rajlich 63caf93138 Add format prefix to stream chunks and use .bin extension for chunk files (in world-local) (#1020)
Stream chunks were serialized as raw devalue text without the 'devl'
format prefix, unlike step inputs/outputs. This meant stream data
couldn't go through the same hydration/deserialization pipeline.

Core changes (serialization.ts):
- getSerializeStream: each chunk is now individually wrapped with
  encodeWithFormatPrefix('devl', payload) — same as step data
- getDeserializeStream: handles both format-prefixed chunks (current)
  and legacy newline-delimited text (backwards compatible)

World-local changes (streamer.ts):
- Stream chunk files now use .bin extension instead of .json, since
  the content is binary (1-byte eof flag + serialized chunk data)
- Add listFilesByExtension() utility to fs.ts for generic file listing

* chore: add changeset

* world-local: add backwards compat for legacy .json chunk files

When reading stream chunks, list both .bin (current) and .json
(legacy) files so streams written before the extension change
continue to work.

* core: add format prefix and length-prefix framing to stream chunks

Stream chunks were serialized as raw devalue text without the 'devl'
format prefix or any framing, unlike step inputs/outputs.

Core changes (serialization.ts):
- getSerializeStream: each chunk is now wrapped with
  encodeWithFormatPrefix('devl', payload) inside a length-prefixed
  frame: [4-byte big-endian length][format-prefixed payload]
- getDeserializeStream: handles both length-prefixed framed chunks
  (current) and legacy newline-delimited text (backwards compatible)
- Added 6 unit tests covering framing, round-trip, concatenation,
  splitting, and legacy fallback

World-local changes (streamer.ts):
- Stream chunk files now use .bin extension instead of .json
- readFromStream lists both .bin and .json files for backwards compat
- Updated streamer.test.ts to expect .bin extension

Split changesets: core (format + framing) and world-local (.bin extension)
2026-02-12 11:06:41 -08:00
Peter Wielander b2ba6ff70e [ci] Add flag that can disable non-vercel e2e tests (#1006) 2026-02-11 16:53:55 -08:00