@workflow/core 4.2.0-beta.76 → 4.2.0-beta.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/flushable-stream.d.ts.map +1 -1
  2. package/dist/flushable-stream.js +14 -2
  3. package/dist/private.d.ts.map +1 -1
  4. package/dist/private.js +7 -4
  5. package/dist/runtime/helpers.d.ts +4 -0
  6. package/dist/runtime/helpers.d.ts.map +1 -1
  7. package/dist/runtime/helpers.js +31 -8
  8. package/dist/runtime/resume-hook.d.ts.map +1 -1
  9. package/dist/runtime/resume-hook.js +3 -2
  10. package/dist/runtime/run.d.ts +11 -1
  11. package/dist/runtime/run.d.ts.map +1 -1
  12. package/dist/runtime/run.js +26 -2
  13. package/dist/runtime/runs.d.ts.map +1 -1
  14. package/dist/runtime/runs.js +3 -1
  15. package/dist/runtime/start.d.ts +27 -13
  16. package/dist/runtime/start.d.ts.map +1 -1
  17. package/dist/runtime/start.js +91 -27
  18. package/dist/runtime.d.ts +1 -1
  19. package/dist/runtime.d.ts.map +1 -1
  20. package/dist/runtime.js +31 -8
  21. package/dist/schemas.d.ts +1 -1
  22. package/dist/schemas.d.ts.map +1 -1
  23. package/dist/serialization.d.ts +12 -0
  24. package/dist/serialization.d.ts.map +1 -1
  25. package/dist/serialization.js +37 -3
  26. package/dist/step/context-storage.d.ts +3 -2
  27. package/dist/step/context-storage.d.ts.map +1 -1
  28. package/dist/step/context-storage.js +21 -2
  29. package/dist/version.d.ts +1 -1
  30. package/dist/version.js +1 -1
  31. package/dist/vm/index.d.ts.map +1 -1
  32. package/dist/vm/index.js +2 -1
  33. package/docs/foundations/starting-workflows.mdx +1 -1
  34. package/docs/foundations/streaming.mdx +1 -1
  35. package/docs/how-it-works/encryption.mdx +39 -2
  36. package/docs/how-it-works/event-sourcing.mdx +19 -2
  37. package/docs/how-it-works/framework-integrations.mdx +68 -11
  38. package/package.json +4 -4
@@ -261,6 +261,35 @@ class MyFrameworkBuilder extends BaseBuilder {
261
261
 
262
262
  If your framework supports virtual server routes and dev mode watching, make sure to adapt accordingly. Please open a PR to the Workflow SDK if the base builder class is missing necessary functionality.
263
263
 
264
+ ### Monorepos and Workspace Imports
265
+
266
+ If your framework integration lives in a subdirectory and your workflows import code from sibling workspace packages, pass `projectRoot` to `BaseBuilder`. Use the smallest directory that contains every workspace package imported by your workflows.
267
+
268
+ {/* @skip-typecheck: @workflow/cli internal module */}
269
+ ```typescript title="my-framework-builder.ts" lineNumbers
270
+ import { BaseBuilder } from "@workflow/cli/dist/lib/builders/base-builder";
271
+
272
+ class MyFrameworkBuilder extends BaseBuilder {
273
+ constructor(options: {
274
+ rootDir: string;
275
+ workspaceRoot?: string;
276
+ dev: boolean;
277
+ }) {
278
+ super({
279
+ dirs: ["workflows"],
280
+ workingDir: options.rootDir,
281
+ projectRoot: options.workspaceRoot ?? options.rootDir, // [!code highlight]
282
+ watch: options.dev,
283
+ });
284
+ }
285
+
286
+ override async build(): Promise<void> {
287
+ const inputFiles = await this.getInputFiles();
288
+ // ...
289
+ }
290
+ }
291
+ ```
292
+
264
293
  Hook into your framework's build:
265
294
 
266
295
  {/* @skip-typecheck: incomplete code sample */}
@@ -346,22 +375,50 @@ In the future, the Workflow SDK will emit more routes under the `.well-known/wor
346
375
 
347
376
  ## Security
348
377
 
349
- **How are these HTTP endpoints secured?**
378
+ The workflow and step handler endpoints are invoked by the world's queuing infrastructure, not by end users. How they're secured depends on which world you're deploying to.
379
+
380
+ ### Vercel (`@workflow/world-vercel`)
381
+
382
+ On Vercel, workflow handler functions are not accessible through public endpoints. Handlers use the same [consumer function security](https://vercel.com/docs/queues/concepts#consumer-function-security) mechanism that secures [Vercel Queues](https://vercel.com/docs/queues) consumers.
383
+
384
+ During the build step, the Workflow SDK automatically configures each handler as a queue consumer by writing `experimentalTriggers` to the function's `.vc-config.json`:
385
+
386
+ ```json title=".vc-config.json (generated by Workflow SDK)"
387
+ {
388
+ "experimentalTriggers": [
389
+ {
390
+ "type": "queue/v2beta",
391
+ "topic": "__wkf_step_*",
392
+ "consumer": "default",
393
+ "retryAfterSeconds": 5,
394
+ "initialDelaySeconds": 0
395
+ }
396
+ ]
397
+ }
398
+ ```
399
+
400
+
401
+ Two queue topics are created per deployment:
350
402
 
351
- Security is handled by the **world abstraction** you're using:
403
+ | Handler | Topic | Description |
404
+ | --- | --- | --- |
405
+ | `step.func` | `__wkf_step_*` | Step execution (long-running, `maxDuration: max`) |
406
+ | `flow.func` | `__wkf_workflow_*` | Workflow orchestration (`maxDuration: 60`) |
407
+
408
+ If you're building a framework integration that targets Vercel, you should write these triggers into the `.vc-config.json` for each generated function. The `STEP_QUEUE_TRIGGER` and `WORKFLOW_QUEUE_TRIGGER` constants are exported from `@workflow/builders` for this purpose:
409
+
410
+ ```typescript
411
+ import { STEP_QUEUE_TRIGGER, WORKFLOW_QUEUE_TRIGGER } from "@workflow/builders";
412
+ ```
352
413
 
353
- **Vercel (`@workflow/world-vercel`):**
354
414
 
355
- - Vercel Queue will support private invoke, making routes inaccessible from the public internet
356
- - Handlers receive only a message ID that must be retrieved from Vercel's backend
357
- - Impossible to craft custom payloads without valid queue-issued message IDs
415
+ ### Custom implementations
358
416
 
359
- **Custom implementations:**
417
+ For self-hosted or non-Vercel deployments, you are responsible for securing the handler endpoints:
360
418
 
361
- - Implement authentication via framework middleware
362
- - Use API keys, JWT validation, or other auth schemes
363
- - Network-level security (VPCs, private networks, firewall rules)
364
- - Rate limiting and request validation
419
+ - **Framework middleware** — Add authentication (API keys, JWT, OIDC) in front of the `/.well-known/workflow/v1/*` routes
420
+ - **Network-level security** — Deploy handlers behind a VPC, private network, or firewall rules so only your queue infrastructure can reach them
421
+ - **Rate limiting** Add request validation and rate limiting to prevent abuse
365
422
 
366
423
  Learn more about [building custom Worlds](/docs/deploying/building-a-world).
367
424
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workflow/core",
3
- "version": "4.2.0-beta.76",
3
+ "version": "4.2.0-beta.78",
4
4
  "description": "Core runtime and engine for Workflow SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -83,9 +83,9 @@
83
83
  "@workflow/errors": "4.1.0-beta.20",
84
84
  "@workflow/serde": "4.1.0-beta.2",
85
85
  "@workflow/utils": "4.1.0-beta.13",
86
- "@workflow/world": "4.1.0-beta.15",
87
- "@workflow/world-local": "4.1.0-beta.49",
88
- "@workflow/world-vercel": "4.1.0-beta.47"
86
+ "@workflow/world": "4.1.0-beta.17",
87
+ "@workflow/world-local": "4.1.0-beta.51",
88
+ "@workflow/world-vercel": "4.1.0-beta.49"
89
89
  },
90
90
  "devDependencies": {
91
91
  "@opentelemetry/api": "1.9.0",