@workflow/core 5.0.0-beta.47 → 5.0.0-beta.49

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 (47) hide show
  1. package/dist/classify-error.d.ts.map +1 -1
  2. package/dist/classify-error.js +13 -3
  3. package/dist/describe-error.d.ts.map +1 -1
  4. package/dist/describe-error.js +16 -1
  5. package/dist/private.d.ts +2 -4
  6. package/dist/private.d.ts.map +1 -1
  7. package/dist/private.js +1 -1
  8. package/dist/runtime/constants.d.ts +9 -7
  9. package/dist/runtime/constants.d.ts.map +1 -1
  10. package/dist/runtime/constants.js +10 -8
  11. package/dist/runtime/helpers.d.ts +13 -0
  12. package/dist/runtime/helpers.d.ts.map +1 -1
  13. package/dist/runtime/helpers.js +14 -1
  14. package/dist/runtime/quickjs-serde.d.ts.map +1 -1
  15. package/dist/runtime/quickjs-serde.js +62 -1
  16. package/dist/runtime/run.d.ts +42 -0
  17. package/dist/runtime/run.d.ts.map +1 -1
  18. package/dist/runtime/run.js +102 -17
  19. package/dist/runtime/runs.d.ts.map +1 -1
  20. package/dist/runtime/runs.js +8 -4
  21. package/dist/runtime/start.d.ts +31 -1
  22. package/dist/runtime/start.d.ts.map +1 -1
  23. package/dist/runtime/start.js +38 -6
  24. package/dist/runtime/suspension-handler.d.ts +54 -1
  25. package/dist/runtime/suspension-handler.d.ts.map +1 -1
  26. package/dist/runtime/suspension-handler.js +83 -20
  27. package/dist/runtime.d.ts +1 -1
  28. package/dist/runtime.d.ts.map +1 -1
  29. package/dist/runtime.js +174 -61
  30. package/dist/serialization/reducers/common-vm.d.ts.map +1 -1
  31. package/dist/serialization/reducers/common-vm.js +38 -1
  32. package/dist/serialization/reducers/common.d.ts.map +1 -1
  33. package/dist/serialization/reducers/common.js +26 -2
  34. package/dist/serialization/types.d.ts +7 -0
  35. package/dist/serialization/types.d.ts.map +1 -1
  36. package/dist/serialization/types.js +1 -1
  37. package/dist/serialization.d.ts +46 -2
  38. package/dist/serialization.d.ts.map +1 -1
  39. package/dist/serialization.js +249 -75
  40. package/dist/version.d.ts +1 -1
  41. package/dist/version.js +2 -2
  42. package/dist/workflow/sleep.d.ts.map +1 -1
  43. package/dist/workflow/sleep.js +3 -6
  44. package/dist/workflow.js +6 -6
  45. package/docs/foundations/streaming.mdx +28 -0
  46. package/docs/how-it-works/understanding-directives.mdx +1 -1
  47. package/package.json +10 -10
@@ -314,6 +314,34 @@ export async function POST(request: Request) {
314
314
  }
315
315
  ```
316
316
 
317
+ ## Writing to another run's stream
318
+
319
+ `getRun(runId).getWritable()` appends to a stream owned by another run. This lets short-lived runs contribute to a long-lived holder run's stream using only its ID.
320
+
321
+ ```typescript title="workflows/turn.ts" lineNumbers
322
+ import { getRun } from "workflow/api";
323
+
324
+ type SessionEvent = { turn: number; text: string };
325
+
326
+ async function runTurn(holderRunId: string, turn: number) {
327
+ "use step";
328
+
329
+ const writable = getRun(holderRunId).getWritable<SessionEvent>(); // [!code highlight]
330
+ const writer = writable.getWriter();
331
+
332
+ await writer.write({ turn, text: "done" });
333
+ writer.releaseLock(); // [!code highlight]
334
+ }
335
+ ```
336
+
337
+ Pass `{ namespace: "name" }` to target a [namespaced stream](#namespaced-streams). The writable can also be forwarded through `start()` and into steps.
338
+
339
+ <Callout type="warn">
340
+ Contributors should call `releaseLock()`, which flushes pending writes. Calling `close()` closes the shared stream for every writer.
341
+ </Callout>
342
+
343
+ The API grants append access, not read access or additional authorization. The owning run controls the stream's lifecycle, and writes to an unknown run fail.
344
+
317
345
  ## Common patterns
318
346
 
319
347
  ### Progress updates for long-running tasks
@@ -310,7 +310,7 @@ The directive approach solved all these issues: it works in any project structur
310
310
 
311
311
  We considered decorators, but they presented technical and ergonomic challenges.
312
312
 
313
- **Decorators are non-yet-standard and class-focused**
313
+ **Decorators are not-yet-standard and class-focused**
314
314
 
315
315
  Decorators are not yet a standard syntax ([TC39 proposal](https://github.com/tc39/proposal-decorators)) and they currently only work with classes. A class decorator approach could look like this:
316
316
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workflow/core",
3
- "version": "5.0.0-beta.47",
3
+ "version": "5.0.0-beta.49",
4
4
  "description": "Core runtime and engine for Workflow SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -85,6 +85,12 @@
85
85
  "@standard-schema/spec": "1.0.0",
86
86
  "@types/ms": "2.1.0",
87
87
  "@vercel/functions": "^3.8.0",
88
+ "@workflow/errors": "5.0.0-beta.21",
89
+ "@workflow/serde": "5.0.0-beta.2",
90
+ "@workflow/utils": "5.0.0-beta.10",
91
+ "@workflow/world": "5.0.0-beta.34",
92
+ "@workflow/world-local": "5.0.0-beta.43",
93
+ "@workflow/world-vercel": "5.0.0-beta.45",
88
94
  "debug": "4.4.3",
89
95
  "devalue": "5.9.0",
90
96
  "ms": "2.1.3",
@@ -93,13 +99,7 @@
93
99
  "seedrandom": "3.0.5",
94
100
  "semver": "7.7.4",
95
101
  "ulid": "~3.0.1",
96
- "zod": "~4.3.6",
97
- "@workflow/errors": "5.0.0-beta.19",
98
- "@workflow/serde": "5.0.0-beta.2",
99
- "@workflow/utils": "5.0.0-beta.10",
100
- "@workflow/world": "5.0.0-beta.32",
101
- "@workflow/world-local": "5.0.0-beta.41",
102
- "@workflow/world-vercel": "5.0.0-beta.43"
102
+ "zod": "~4.3.6"
103
103
  },
104
104
  "devDependencies": {
105
105
  "@opentelemetry/api": "1.9.0",
@@ -110,10 +110,10 @@
110
110
  "@types/node": "22.19.0",
111
111
  "@types/seedrandom": "3.0.8",
112
112
  "@types/semver": "7.7.1",
113
+ "@workflow/tsconfig": "5.0.0-beta.0",
113
114
  "cross-env": "10.1.0",
114
115
  "genversion": "3.2.0",
115
- "typescript": "^6.0.3",
116
- "@workflow/tsconfig": "5.0.0-beta.0"
116
+ "typescript": "^6.0.3"
117
117
  },
118
118
  "peerDependencies": {
119
119
  "@opentelemetry/api": "1"