Commit Graph

1400 Commits

Author SHA1 Message Date
Vercel Release Bot 00b12be415 Version Packages (beta) (#499) 2025-12-02 13:01:12 -08:00
Peter Wielander e9494d5816 Update @vercel/queue (#498) 2025-12-02 12:54:50 -08:00
Nathan Rajlich 2f0840bc81 Better error when passing an invalid workflow value to start() (#495) 2025-12-02 12:08:38 -08:00
Nathan Rajlich 555d7a69de Normalize anonymous default export workflow IDs to "default" (#484) 2025-12-02 11:26:29 -08:00
Vercel Release Bot 9916f2a4a6 Version Packages (beta) (#447)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-12-02 10:12:48 -08:00
Peter Wielander 8d4562e856 [world-local] Finish renaming embedded world to local world (#441) 2025-12-02 09:12:40 -08:00
Adrian 1ac5592452 feat: add astro support (#347) 2025-12-02 09:11:46 -08:00
Gal Schlezinger bdde1bd806 core: add span links + message ids to queue spans (#472)
* core: add span links + message ids to queue spans

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* add queue overhead to metrics

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* fix types

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* rename messageId to message.id

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* add changeset

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

---------

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>
2025-12-02 14:11:05 +02:00
Nathan Rajlich e339a2bc77 Add e2e test for spawning child workflows (#475) 2025-12-02 00:30:25 -08:00
Adrian 3c19e909f2 fix: nitro build race conditions (#444)
* test: make dev e2e sequential

* test: increase timeout between tests in dev test

* add logs

* feat: add queue for builds

* refactor: cleanup vite hmr

* chore: cleanup comments

* fix: regex base builder

* test: reduce sleep time between test suites in dev test

* refactor: naming conventions and remove builder value check

* refactor: sveltekit builder queue

* changeset

* fix: regex on base builder workflow code

* test: increase sleep

* format

* fix: make writeFile atomic on workflow entrypoint

* refactor: move build queue to @workflow/builders

* revert: regex stuff with workflow code

* add console log for workflow file changed
2025-12-01 19:55:28 -08:00
Nathan Rajlich 2faddf37f6 Move @workflow/errors package to "dependencies" instead of "devDependencies" (#481) 2025-12-01 17:00:33 -08:00
Adrian cd451e0295 chore(utils): replace execa dependency (#476)
* chore(utils): replace execa dependency

* changeset
2025-12-01 14:15:25 -08:00
Adrian d53bf906ec fix: scan all dirs for standalone builder (#477)
* fix: scan all dirs for standalone builder

* changeset
2025-12-01 13:54:03 -08:00
Adrian bc9b6282c2 fix: @vercel/nft parsing proc file paths in sveltekit adapter (#473)
* fix: build proc paths dynamically

* test

* changeset
2025-12-01 13:00:42 -08:00
Peter Wielander 10c5b91079 [web] Upgrade Next.js to 16 (#465) 2025-12-01 09:23:25 -08:00
Pranay Prakash 6e8e828252 Add stream benchmarks and slightly improve the benchmarking code (#470)
* Add stream benchmarks and cnealup for benchmark code

* 10m delay for local world race

* potential fix for first bute"

* Improve sticky comment stuff

* local world: ignore controller close errors

* show missing data in benchmark comment

* nitrpicks

* Improve leaderboard

* Add benchmark comparisons against main

* changeset
2025-11-30 23:49:37 -08:00
Alex Holovach 34f3f86f31 fix(utils): detect linux ports via /proc (#471)
* fix(utils): detect linux ports via /proc

Signed-off-by: Alex Holovach <alex.holovach@kubiks.ai>

* extract parsePort helper

Signed-off-by: Alex Holovach <alex.holovach@kubiks.ai>

* add changeset

Signed-off-by: Alex Holovach <alex.holovach@kubiks.ai>

---------

Signed-off-by: Alex Holovach <alex.holovach@kubiks.ai>
2025-11-30 14:07:31 -08:00
Peter Wielander 9ea3fa9fd5 [web] Remove peer dependency on world-postgres that can't be resolved during build (#466) 2025-11-30 10:14:33 -08:00
Gal Schlezinger ef8e0e52ab world-postgres: poll faster in pg-boss (#463)
---------

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
2025-11-30 09:45:40 -08:00
Alex Holovach 109fe593fc [web] add PostgreSQL backend support (#459)
---------

Signed-off-by: Alex Holovach <alex.holovach@kubiks.ai>
2025-11-30 08:42:35 -08:00
Pranay Prakash a8f48c5a08 add benchmarking (#460) 2025-11-29 21:21:49 -08:00
Nathan Rajlich 0f1645b8a2 Ignore rejections in waitedUntil promise (#452) 2025-11-28 08:51:22 -08:00
Nathan Rajlich 172e0151ba Add AI provider step wrapper functions (#428) 2025-11-26 23:51:12 -08:00
Nathan Rajlich 5b918611fc Apply workflow function transformation in "step" mode (#420) 2025-11-26 23:35:53 -08:00
Nathan Rajlich 0cacb99fcc Support nested "use step" declarations in non-workflow functions (#418) 2025-11-26 23:20:04 -08:00
Vercel Release Bot 87ad24b3b6 Version Packages (beta) (#416) 2025-11-26 19:55:04 -08:00
Peter Wielander 17904fc7b4 [ai] Pass messages to step functions in DurableAgent and add prepareStep callback (#446) 2025-11-26 19:45:34 -08:00
Adrian 6dd17500da refactor: move rollup plugin to own package (#382)
* refactor: move rollup plugin to own package

* refactor(sveltekit): update sveltekit to use rollup package

* Update packages/rollup/src/index.ts

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

* chore(deps): missing nitro dep

* chore(deps): remove unused deps from @workflow/rollup

* changeset

* chore: project LICENSE symlinks

* refactor: move @swc/core version to pnpm workspace

* chore: cleanup and add readme

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2025-11-26 16:02:13 -08:00
Boris Besemer 40057db00b [world-local] bounded concurrency for queue (#401) 2025-11-26 13:38:22 -08:00
Adrian b042ba70ee fix: externalize bun from step bundle (#425)
* fix: externlize bun from step bundle

* changeset

* fix: add bun to node module esbuild plugin

* feat: add bun to node module esbuild plugin match

* feat: add hint for using bun inside workflow in ts lsp

* fix: add support for bun:* modules
2025-11-26 09:28:59 -08:00
Nathan Rajlich 07800c29ee Support closure variables for serialized step functions (#366) 2025-11-25 00:29:15 -08:00
Nathan Rajlich 8b470f0c1d Apply SWC transformation on step functions returned from factory function (#360)
Added support for transforming step functions that are returned from factory functions.

### What changed?

Enhanced the SWC plugin to detect and transform step functions that are defined within object literals returned by factory functions. The transformation now properly identifies arrow functions with object literal bodies and processes their step functions accordingly.

Added test fixtures to verify the functionality:
- Created test cases for a factory function that returns an object with a step method
- Added corresponding output files for client, step, and workflow modes

### How to test?

1. Create a factory function that returns an object with methods marked as steps:
```javascript
const myFactory = () => ({
  myStep: async () => {
    'use step';
    await fs.mkdir('test');
  },
});
```

2. Verify that the step function is properly transformed and registered when used in a workflow.

### Why make this change?

This enhancement supports a common pattern where developers create factory functions that return objects containing step methods. Without this change, step functions defined in this pattern weren't being properly transformed, which limited the flexibility of the workflow system.
2025-11-25 00:25:44 -08:00
Nathan Rajlich fb9fd0f893 Add support for closure scope vars in step functions (#358)
### What changed?

- Enhanced the SWC plugin to detect and collect closure variables from nested step functions
- Modified the workflow runtime to pass closure variables to step functions during execution
- Updated the serialization/deserialization logic to handle the new closure variable format
- Added a mechanism to access closure variables within step functions
- Added tests to verify closure variable functionality in nested step functions
- Closure variables are stored on the step function execution's `AsyncLocalStorage`​ context

### Example

```typescript
export async function myWorkflow(baseValue: number) {
  'use workflow';
  const multiplier = 3;
  const prefix = 'Result: ';

  const calculate = async () => {
    'use step';
    const result = baseValue * multiplier;
    return `${prefix}${result}`;
  };

  return await calculate();
}
```

### Why make this change?

Previously, nested step functions couldn't access variables from their parent workflow scope, limiting their usefulness and requiring workarounds like passing all needed values as parameters. This change enables a more natural programming model where step functions can access variables from their enclosing scope, making workflow code more intuitive and reducing the need for explicit parameter passing.
2025-11-25 00:21:05 -08:00
Vercel Release Bot 018c5a053e Version Packages (beta) (#410) 2025-11-24 15:22:23 -08:00
Julian Benegas aba5264174 [ai] Add onStepFinish callback to DurableAgent#stream() (#404) 2025-11-24 15:10:49 -08:00
Peter Wielander 6889dacd08 [world-vercel] log warning when detecting zod v3 during enqueue action (#409) 2025-11-24 15:08:15 -08:00
Vercel Release Bot e5c0380bbd Version Packages (beta) (#396) 2025-11-24 14:25:39 -08:00
Peter Wielander 2c438c3bd0 [world-vercel] Fix queue call compatibility for zod v3 (#403) 2025-11-24 12:29:40 -08:00
Adrian edb69c3c0d fix: port detection, postgres nitro apps and nitro app testing (#363)
* add debug logs

* add polling for port test

* nuxt may be hmring on ignored files/folders

* Revert "nuxt may be hmring on ignored files/folders"

This reverts commit c57c3f0dd9e1b757825c777e12b63e050ca44227.

* Update packages/utils/src/get-port.ts

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

* Update packages/world-local/src/config.ts

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

* Update packages/utils/src/get-port.ts

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

* revert getPort

* test new pid to port cmd

* extend sleep time on tests

* fix

* fix race condition in tests

* add logs

* add fallback from pid-port

* remove pid-port fallback

* revert config ts

* test: add getPort test

* update tests for concurrent calls

* temp

* trigger rebuild

* feat: add windows get port support

* fix port sorting

* fix parsing logic and filtering

* fformat

* update ports logi

* revert

* windows port hack

* refactor: optional chaining on windows

* test: change ordering of config tests

* remove wrong test

* simplify windows getPort impl

* use execFileSync instead of execFile

* use execa

* disable test cache

* Update packages/utils/src/get-port.ts

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

* update

* debug

* windows cmd

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* lockfile

* fix: windows port detection

* simplify stuff

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* test: revert gh copilot

* fix

* increase sleep

* revert logs

* revert turbo

* revert

* revert

* changeset

* Update packages/utils/src/get-port.ts

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

* format

* init postgres world for express and hono

* add posgres world to nitro config

* add postgres world start to sveltekit

* add postgres world plugin to nitro apps

* Update workbench/sveltekit/src/hooks.server.ts

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

* Update workbench/vite/vite.config.ts

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

* fix nuxt plugin

* revert vercel compiled hook on nitro

* .

* revert

* update

* CI WILL BE GREEN

* remove log in nitro

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-24 09:30:41 -08:00
Gal Schlezinger 10ce313d56 postgres: fix tests (#394)
* postgres: use non-deprecated drizzle signatures

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* postgres: store metadata in the hook

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* core: do not rely on module cache for world config. instead, use a global and a symbol.

this makes sure that streamers can use in-memory event emitters and that it won't be compiled away into the different flow.js and step.js files.

this was figured out when i was adding a hooks tests to world-testing.

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* add postgres world to all workbench packages

we try to run them with the postgres world but it's not installed

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* Replace jsonb with cbor because zero byte does not work in jsonb :(

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* fix error handling: attempts start at 0 now, and not 1 like when we released. so initial attempt in postgres should reflect that.

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* drain stuff

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* fallback metadata to metadataJson

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* Make code more readable

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

* apply Vade fix

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>

---------

Signed-off-by: Gal Schlezinger <gal@spitfire.co.il>
2025-11-23 11:05:20 -08:00
Nathan Rajlich 00e334506c [ai] Make DurableAgent#stream() return a messages array (#362)
* Make `DurableAgent#stream()` return a `messages` array

* Docs updates

* Docs updates

* fix

---------

Co-authored-by: Pranay Prakash <pranay.gp@gmail.com>
2025-11-23 11:02:53 -08:00
Vercel Release Bot 7a230a9ad1 Version Packages (beta) (#387)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-11-22 07:32:12 -08:00
Pranay Prakash ce50baf96a bring world local back to 4.x 2025-11-22 10:29:36 -05:00
Copilot 34366293a0 Fix streamer bugs and document concurrency limitations in world-local (#391)
* Initial plan

* Fix bugs in world-local: empty chunk handling, type safety, and documentation

Co-authored-by: pranaygp <1797812+pranaygp@users.noreply.github.com>

* Add changeset for world-local bug fixes

Co-authored-by: pranaygp <1797812+pranaygp@users.noreply.github.com>

* Attempt to fix local straming

* fix the actual queue copy problem

* update changeset

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pranaygp <1797812+pranaygp@users.noreply.github.com>
Co-authored-by: Pranay Prakash <pranay.gp@gmail.com>
2025-11-22 07:26:46 -08:00
Peter Wielander 99611405d4 Fix hydration of events with dates and of step functions (#380) 2025-11-21 13:58:02 -05:00
Adrian 73b6c68daf remove suppressUndefinedRejections from base builder (#384) 2025-11-21 06:42:28 -08:00
Vercel Release Bot 2856d665c0 Version Packages (beta) (#375)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-11-20 14:24:12 -08:00
Copilot 154670ae01 Handle FatalError in DurableAgent tool execution (#376)
* Initial plan

* Fix DurableAgent to handle FatalError in tool calls

Convert FatalError exceptions in tool execution to tool-result errors that get
propagated back to the LLM, mimicking AI SDK behavior. Non-fatal errors are
re-thrown to allow workflow retry mechanisms to handle them.

- Updated executeTool to catch FatalError and convert to error-text tool result
- Added comprehensive tests for error handling scenarios
- All tests passing

Co-authored-by: pranaygp <1797812+pranaygp@users.noreply.github.com>

* Address code review feedback and add changeset

Remove unnecessary type assertion and add changeset for the DurableAgent fix

Co-authored-by: pranaygp <1797812+pranaygp@users.noreply.github.com>

* Update packages/ai/src/agent/durable-agent.ts

* Apply suggestion from @pranaygp

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pranaygp <1797812+pranaygp@users.noreply.github.com>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Co-authored-by: Pranay Prakash <pranay.gp@gmail.com>
2025-11-20 14:17:48 -08:00
Nathan Rajlich 43a3f797d3 [ai] Fix "start" and "finish" chunk events in DurableAgent (#378)
* [ai] Remove "start" and "finish" chunk events

* Wire through sendStart and sendFinish properly

* changeset

---------

Co-authored-by: Pranay Prakash <pranay.gp@gmail.com>
2025-11-20 14:16:21 -08:00
Nathan Rajlich e5c5236363 Fix default export workflow function transformation in workflow mode (#373)
Fixed a bug where default export workflow functions with names (e.g., `export default async function testWorkflow()`) would fail at runtime with `ReferenceError: $$default is not defined`. The SWC plugin now correctly keeps the default export as-is and simply adds the workflowId assignment after it, since the function name is available as a binding in the module scope.

Also adds support for anonymous and arrow function default exports, which previously were not being transformed at all.

Fixes #367.
2025-11-20 12:26:12 -08:00