* 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
* 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
* 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
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.
### 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.
* 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>
* 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>
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.