eve 0.22.4 → 0.22.6

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 (112) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +2 -0
  3. package/dist/src/cli/commands/agent-instructions.d.ts +15 -0
  4. package/dist/src/cli/commands/agent-instructions.js +3 -1
  5. package/dist/src/cli/commands/agent-prompt/scaffold.md +3 -0
  6. package/dist/src/cli/commands/extension-build.d.ts +9 -0
  7. package/dist/src/cli/commands/extension-build.js +1 -0
  8. package/dist/src/cli/commands/extension-init.d.ts +25 -0
  9. package/dist/src/cli/commands/extension-init.js +1 -0
  10. package/dist/src/cli/commands/info.js +1 -1
  11. package/dist/src/cli/commands/init-git.js +1 -1
  12. package/dist/src/cli/commands/init-repl.js +1 -1
  13. package/dist/src/cli/commands/init.d.ts +2 -0
  14. package/dist/src/cli/commands/init.js +1 -1
  15. package/dist/src/cli/run.js +1 -1
  16. package/dist/src/compiled/.vendor-stamp.json +4 -4
  17. package/dist/src/compiled/@workflow/core/global.d.ts +20 -0
  18. package/dist/src/compiled/@workflow/core/index.d.ts +1 -1
  19. package/dist/src/compiled/@workflow/core/index.js +2 -2
  20. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +54 -0
  21. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +11 -3
  22. package/dist/src/compiled/@workflow/core/runtime/run.d.ts +6 -2
  23. package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +36 -2
  24. package/dist/src/compiled/@workflow/core/runtime/start.d.ts +29 -1
  25. package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +23 -0
  26. package/dist/src/compiled/@workflow/core/runtime/step-latency.d.ts +131 -0
  27. package/dist/src/compiled/@workflow/core/runtime/step-ownership.d.ts +72 -0
  28. package/dist/src/compiled/@workflow/core/runtime/step-single-flight.d.ts +12 -0
  29. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +7 -0
  30. package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
  31. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  32. package/dist/src/compiled/@workflow/core/serialization-format.d.ts +1 -0
  33. package/dist/src/compiled/@workflow/core/set-attributes.d.ts +12 -7
  34. package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +1 -1
  35. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +40 -0
  36. package/dist/src/compiled/@workflow/core/telemetry.d.ts +8 -0
  37. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  38. package/dist/src/compiled/@workflow/core/workflow/index.d.ts +1 -1
  39. package/dist/src/compiled/@workflow/core/workflow/set-attributes.d.ts +20 -16
  40. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  41. package/dist/src/compiled/@workflow/world/analytics.d.ts +4 -4
  42. package/dist/src/compiled/@workflow/world/events.d.ts +142 -21
  43. package/dist/src/compiled/@workflow/world/hooks.d.ts +1 -24
  44. package/dist/src/compiled/@workflow/world/index.d.ts +3 -2
  45. package/dist/src/compiled/@workflow/world/queue.d.ts +10 -0
  46. package/dist/src/compiled/@workflow/world/recovery.d.ts +3 -2
  47. package/dist/src/compiled/@workflow/world/ulid.d.ts +9 -0
  48. package/dist/src/compiled/@workflow/world-local/index.js +4 -4
  49. package/dist/src/compiled/@workflow/world-vercel/index.js +16 -16
  50. package/dist/src/compiled/_chunks/workflow/attribute-changes-Dmf_myUv.js +20 -0
  51. package/dist/src/compiled/_chunks/workflow/{dist-DJU_7R9s.js → dist-CQenixFf.js} +1 -1
  52. package/dist/src/compiled/_chunks/workflow/{functions-CnVBREsg.js → functions-BCMO8vbf.js} +1 -1
  53. package/dist/src/compiled/_chunks/workflow/resume-hook-BH01MfRF.js +1 -0
  54. package/dist/src/compiled/_chunks/workflow/run-CL3mguvM.js +1 -0
  55. package/dist/src/compiled/_chunks/workflow/{sleep-phozDCW8.js → sleep-BkAHCD_s.js} +1 -1
  56. package/dist/src/harness/emission.d.ts +2 -4
  57. package/dist/src/harness/emission.js +1 -1
  58. package/dist/src/harness/inline-tool-authorization.d.ts +3 -0
  59. package/dist/src/harness/inline-tool-authorization.js +1 -0
  60. package/dist/src/harness/interruptible-stream.d.ts +5 -0
  61. package/dist/src/harness/interruptible-stream.js +1 -0
  62. package/dist/src/harness/model-call-error.js +1 -1
  63. package/dist/src/harness/ordered-stream-emitter.d.ts +17 -0
  64. package/dist/src/harness/ordered-stream-emitter.js +1 -0
  65. package/dist/src/harness/stream-actions.d.ts +1 -0
  66. package/dist/src/harness/stream-actions.js +1 -1
  67. package/dist/src/harness/subagent-depth.d.ts +1 -1
  68. package/dist/src/harness/subagent-depth.js +1 -1
  69. package/dist/src/harness/tool-loop.js +1 -1
  70. package/dist/src/internal/application/optional-package-install.js +2 -2
  71. package/dist/src/internal/application/package.js +1 -1
  72. package/dist/src/internal/application/paths.d.ts +1 -0
  73. package/dist/src/internal/application/paths.js +1 -1
  74. package/dist/src/internal/authored-module-loader.d.ts +1 -1
  75. package/dist/src/internal/nitro/host/build-application.js +1 -1
  76. package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
  77. package/dist/src/internal/nitro/host/vercel-build-output-config.d.ts +1 -0
  78. package/dist/src/internal/nitro/host/vercel-build-output-config.js +1 -1
  79. package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +1 -1
  80. package/dist/src/public/definitions/extension.d.ts +4 -4
  81. package/dist/src/public/models/openai/chatgpt/auth.d.ts +69 -0
  82. package/dist/src/public/models/openai/chatgpt/auth.js +1 -0
  83. package/dist/src/public/models/openai/chatgpt/model.d.ts +8 -0
  84. package/dist/src/public/models/openai/chatgpt/model.js +1 -0
  85. package/dist/src/public/models/openai/chatgpt/transport.d.ts +24 -0
  86. package/dist/src/public/models/openai/chatgpt/transport.js +1 -0
  87. package/dist/src/public/models/openai/chatgpt/unsigned-jwt.d.ts +5 -0
  88. package/dist/src/public/models/openai/chatgpt/unsigned-jwt.js +1 -0
  89. package/dist/src/public/models/openai/index.d.ts +30 -0
  90. package/dist/src/public/models/openai/index.js +1 -0
  91. package/dist/src/public/next/server.js +2 -2
  92. package/dist/src/public/nuxt/dev-server.js +1 -1
  93. package/dist/src/public/sveltekit/dev-server.js +1 -1
  94. package/dist/src/setup/scaffold/create/extension.d.ts +30 -0
  95. package/dist/src/setup/scaffold/create/extension.js +34 -0
  96. package/dist/src/setup/scaffold/create/project.d.ts +2 -0
  97. package/dist/src/setup/scaffold/create/project.js +2 -2
  98. package/dist/src/setup/scaffold/index.d.ts +1 -0
  99. package/dist/src/setup/scaffold/index.js +1 -1
  100. package/dist/src/shared/agent-definition.d.ts +1 -1
  101. package/docs/agent-config.md +1 -1
  102. package/docs/channels/slack.mdx +6 -0
  103. package/docs/concepts/sessions-runs-and-streaming.md +1 -1
  104. package/docs/extensions.md +21 -13
  105. package/docs/guides/client/streaming.mdx +1 -1
  106. package/docs/reference/cli.md +56 -22
  107. package/docs/reference/typescript-api.md +17 -0
  108. package/docs/subagents.mdx +1 -1
  109. package/package.json +10 -5
  110. package/dist/src/compiled/_chunks/workflow/attribute-changes-BnKD8Y3m.js +0 -20
  111. package/dist/src/compiled/_chunks/workflow/resume-hook-DjPY9VGg.js +0 -1
  112. package/dist/src/compiled/_chunks/workflow/run-BSANnUPR.js +0 -1
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Options accepted by `experimental_setAttributes`.
2
+ * Options accepted by `setAttributes`.
3
3
  */
4
- export interface ExperimentalSetAttributesOptions {
4
+ export interface SetAttributesOptions {
5
5
  /**
6
6
  * Permit attribute keys that start with the reserved `$` prefix.
7
7
  * **Default: `false`.**
@@ -20,14 +20,13 @@ export interface ExperimentalSetAttributesOptions {
20
20
  */
21
21
  allowReservedAttributes?: boolean;
22
22
  }
23
+ /**
24
+ * @deprecated Use {@link SetAttributesOptions} instead.
25
+ */
26
+ export type ExperimentalSetAttributesOptions = SetAttributesOptions;
23
27
  /**
24
28
  * Attach plaintext string key/value metadata to the current workflow run.
25
29
  *
26
- * **EXPERIMENTAL.** The `experimental_` prefix is deliberate — the
27
- * shape, semantics, and dispatch path are likely to change before this
28
- * is renamed to a stable export. Use only when you can absorb a
29
- * breaking rename later.
30
- *
31
30
  * Callable only from a workflow body (`'use workflow'`). The call is
32
31
  * dispatched as a native `attr_set` event and materialized on the run.
33
32
  *
@@ -41,33 +40,38 @@ export interface ExperimentalSetAttributesOptions {
41
40
  * trying to write a `$`-prefixed key throws `FatalError`. If you are a
42
41
  * framework author and need to set a reserved key, pass
43
42
  * `{ allowReservedAttributes: true }` as the second argument — see
44
- * `ExperimentalSetAttributesOptions` for the trade-offs.
43
+ * `SetAttributesOptions` for the trade-offs.
45
44
  *
46
- * **WARNING**: While this feature is experimental, calling e.g.
47
- * `Promise.all([experimental_setAttributes({ a: '1' }), experimental_setAttributes({ a: '2' })])`
45
+ * **WARNING**: Calling e.g.
46
+ * `Promise.all([setAttributes({ a: '1' }), setAttributes({ a: '2' })])`
48
47
  * is not guaranteed to be ordered consistently, but the equivalent
49
48
  * sequential `.then()` chain is.
50
49
  *
51
50
  * @example
52
51
  * ```ts
53
- * import { experimental_setAttributes } from 'workflow';
52
+ * import { setAttributes } from 'workflow';
54
53
  *
55
54
  * export async function myWorkflow() {
56
55
  * 'use workflow';
57
- * await experimental_setAttributes({ phase: 'init' });
56
+ * await setAttributes({ phase: 'init' });
58
57
  * // ... work ...
59
- * await experimental_setAttributes({ phase: 'done', orderId: 'ord_123' });
60
- * await experimental_setAttributes({ orderId: undefined }); // remove
58
+ * await setAttributes({ phase: 'done', orderId: 'ord_123' });
59
+ * await setAttributes({ orderId: undefined }); // remove
61
60
  * }
62
61
  * ```
63
62
  *
64
63
  * @example Framework / library code writing into the reserved namespace.
65
64
  * ```ts
66
- * await experimental_setAttributes(
65
+ * await setAttributes(
67
66
  * { '$agent.kind': 'durable-agent' },
68
67
  * { allowReservedAttributes: true }
69
68
  * );
70
69
  * ```
71
70
  */
72
- export declare function experimental_setAttributes(attrs: Record<string, string | undefined>, options?: ExperimentalSetAttributesOptions): Promise<void>;
71
+ export declare function setAttributes(attrs: Record<string, string | undefined>, options?: SetAttributesOptions): Promise<void>;
72
+ /**
73
+ * @deprecated The feature is no longer experimental — use
74
+ * {@link setAttributes} instead.
75
+ */
76
+ export declare const experimental_setAttributes: typeof setAttributes;
73
77
  //# sourceMappingURL=set-attributes.d.ts.map
@@ -1 +1 @@
1
- import{i as e}from"../../_chunks/workflow/dist-CttsoN4D.js";import{c as t,i as n}from"../../_chunks/workflow/dist-DpDDcpTl.js";import{An as r,En as i,On as a,Tn as o,dn as s,fn as c,nn as l,pn as u,rn as d,sn as f,t as p}from"../../_chunks/workflow/attribute-changes-BnKD8Y3m.js";import{t as m}from"../../_chunks/workflow/sleep-phozDCW8.js";import{t as h}from"../../_chunks/workflow/run-BSANnUPR.js";async function g(e,t={}){let r=p(e,t);if(r.length===0)return;let i=t.allowReservedAttributes===!0,a=globalThis[u];if(!a)throw new n("experimental_setAttributes() called outside a workflow runtime context. It must be called from within a workflow body (`use workflow`).");await a(r,i?{allowReservedAttributes:!0}:{})}d(l,h);function _(e){let t=globalThis[s];return t||i(`createHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-hook`,_),t(e)}function v(t){let{respondWith:n,token:i,...a}=t??{};if(i!==void 0)throw Error("`createWebhook()` does not accept a `token` option. Webhook tokens are always randomly generated. Use `createHook()` with `resumeHook()` for deterministic token patterns.");let o;n!==void 0&&(o={respondWith:n});let s=_({...a,metadata:o,isWebhook:!0}),{url:c}=r();return s.url=e(c,{type:`webhook`,token:s.token}),s}function y(){function e(t,n){a(`defineHook().resume()`,`https://workflow-sdk.dev/docs/api-reference/workflow-api/resume-hook`,e)}return{create(e){return _(e)},resume:e}}function b(e={}){let{namespace:t}=e,n=globalThis[c](t);return Object.create(globalThis.WritableStream.prototype,{[f]:{value:n,writable:!1}})}function x(){o(`getStepMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-step-metadata`,x)}function S(){a(`resumeHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow-api/resume-hook`,S)}export{n as FatalError,t as RetryableError,_ as createHook,v as createWebhook,y as defineHook,g as experimental_setAttributes,x as getStepMetadata,r as getWorkflowMetadata,b as getWritable,S as resumeHook,m as sleep};
1
+ import{i as e}from"../../_chunks/workflow/dist-CttsoN4D.js";import{c as t,i as n}from"../../_chunks/workflow/dist-DpDDcpTl.js";import{An as r,Fn as i,Nn as a,_n as o,cn as s,fn as c,gn as l,jn as u,sn as d,t as f,vn as p}from"../../_chunks/workflow/attribute-changes-Dmf_myUv.js";import{t as m}from"../../_chunks/workflow/sleep-BkAHCD_s.js";import{t as h}from"../../_chunks/workflow/run-CL3mguvM.js";s(d,h);function g(e){let t=globalThis[l];return t||u(`createHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-hook`,g),t(e)}function _(t){let{respondWith:n,token:r,...a}=t??{};if(r!==void 0)throw Error("`createWebhook()` does not accept a `token` option. Webhook tokens are always randomly generated. Use `createHook()` with `resumeHook()` for deterministic token patterns.");let o;n!==void 0&&(o={respondWith:n});let s=g({...a,metadata:o,isWebhook:!0}),{url:c}=i();return s.url=e(c,{type:`webhook`,token:s.token}),s}function v(){function e(t,n){a(`defineHook().resume()`,`https://workflow-sdk.dev/docs/api-reference/workflow-api/resume-hook`,e)}return{create(e){return g(e)},resume:e}}async function y(e,t={}){let r=f(e,t);if(r.length===0)return;let i=t.allowReservedAttributes===!0,a=globalThis[p];if(!a)throw new n("setAttributes() called outside a workflow runtime context. It must be called from within a workflow body (`use workflow`).");await a(r,i?{allowReservedAttributes:!0}:{})}const b=y;function x(e={}){let{namespace:t}=e,n=globalThis[o](t);return Object.create(globalThis.WritableStream.prototype,{[c]:{value:n,writable:!1}})}function S(){r(`getStepMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-step-metadata`,S)}function C(){a(`resumeHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow-api/resume-hook`,C)}export{n as FatalError,t as RetryableError,g as createHook,_ as createWebhook,v as defineHook,b as experimental_setAttributes,S as getStepMetadata,i as getWorkflowMetadata,x as getWritable,C as resumeHook,y as setAttributes,m as sleep};
@@ -47,18 +47,18 @@ export declare const AnalyticsEventSchema: z.ZodObject<{
47
47
  eventId: z.ZodString;
48
48
  eventType: z.ZodEnum<{
49
49
  run_created: "run_created";
50
+ run_started: "run_started";
50
51
  run_completed: "run_completed";
51
52
  run_failed: "run_failed";
53
+ run_cancelled: "run_cancelled";
54
+ attr_set: "attr_set";
52
55
  step_created: "step_created";
53
56
  step_completed: "step_completed";
54
57
  step_failed: "step_failed";
55
58
  step_retrying: "step_retrying";
59
+ step_started: "step_started";
56
60
  hook_created: "hook_created";
57
61
  hook_received: "hook_received";
58
- run_started: "run_started";
59
- run_cancelled: "run_cancelled";
60
- attr_set: "attr_set";
61
- step_started: "step_started";
62
62
  hook_disposed: "hook_disposed";
63
63
  hook_conflict: "hook_conflict";
64
64
  wait_created: "wait_created";
@@ -1,37 +1,35 @@
1
1
  import { z } from '#compiled/zod/index.js';
2
2
  import type { PaginationOptions, ResolveData } from './shared.js';
3
- /**
4
- * Fields within eventData that hold ref/payload data per event type.
5
- * When resolveData is 'none', only these fields are stripped — all other
6
- * metadata (stepName, workflowName, etc.) is preserved.
7
- */
8
- export declare const EVENT_DATA_REF_FIELDS: Record<string, string[]>;
9
- /**
10
- * Strip ref/payload fields from eventData based on resolveData setting.
11
- * When resolveData is 'none', removes only large data fields (refs) from
12
- * eventData while preserving metadata like stepName, workflowName, etc.
13
- */
14
- export declare function stripEventDataRefs(event: Event, resolveData: ResolveData): Event;
15
3
  export declare const EventTypeSchema: z.ZodEnum<{
16
4
  run_created: "run_created";
5
+ run_started: "run_started";
17
6
  run_completed: "run_completed";
18
7
  run_failed: "run_failed";
8
+ run_cancelled: "run_cancelled";
9
+ attr_set: "attr_set";
19
10
  step_created: "step_created";
20
11
  step_completed: "step_completed";
21
12
  step_failed: "step_failed";
22
13
  step_retrying: "step_retrying";
14
+ step_started: "step_started";
23
15
  hook_created: "hook_created";
24
16
  hook_received: "hook_received";
25
- run_started: "run_started";
26
- run_cancelled: "run_cancelled";
27
- attr_set: "attr_set";
28
- step_started: "step_started";
29
17
  hook_disposed: "hook_disposed";
30
18
  hook_conflict: "hook_conflict";
31
19
  wait_created: "wait_created";
32
20
  wait_completed: "wait_completed";
33
21
  }>;
34
22
  export type EventType = z.infer<typeof EventTypeSchema>;
23
+ declare const RunEventTypeSchema: z.ZodEnum<{
24
+ run_created: "run_created";
25
+ run_started: "run_started";
26
+ run_completed: "run_completed";
27
+ run_failed: "run_failed";
28
+ run_cancelled: "run_cancelled";
29
+ }>;
30
+ export type RunEventType = z.infer<typeof RunEventTypeSchema>;
31
+ export declare const RUN_EVENT_TYPES: ("run_created" | "run_started" | "run_completed" | "run_failed" | "run_cancelled")[];
32
+ export declare function isRunEventType(eventType: string): eventType is RunEventType;
35
33
  export declare const TerminalRunEventTypeSchema: z.ZodEnum<{
36
34
  run_completed: "run_completed";
37
35
  run_failed: "run_failed";
@@ -40,21 +38,101 @@ export declare const TerminalRunEventTypeSchema: z.ZodEnum<{
40
38
  export type TerminalRunEventType = z.infer<typeof TerminalRunEventTypeSchema>;
41
39
  export declare const TERMINAL_RUN_EVENT_TYPES: ("run_completed" | "run_failed" | "run_cancelled")[];
42
40
  export declare function isTerminalRunEventType(eventType: string): eventType is TerminalRunEventType;
41
+ declare const StepEventTypeSchema: z.ZodEnum<{
42
+ step_created: "step_created";
43
+ step_completed: "step_completed";
44
+ step_failed: "step_failed";
45
+ step_retrying: "step_retrying";
46
+ step_started: "step_started";
47
+ }>;
48
+ export type StepEventType = z.infer<typeof StepEventTypeSchema>;
49
+ export declare const STEP_EVENT_TYPES: ("step_created" | "step_completed" | "step_failed" | "step_retrying" | "step_started")[];
50
+ export declare function isStepEventType(eventType: string): eventType is StepEventType;
51
+ declare const TerminalStepEventTypeSchema: z.ZodEnum<{
52
+ step_completed: "step_completed";
53
+ step_failed: "step_failed";
54
+ }>;
55
+ export type TerminalStepEventType = z.infer<typeof TerminalStepEventTypeSchema>;
56
+ export declare const TERMINAL_STEP_EVENT_TYPES: ("step_completed" | "step_failed")[];
57
+ export declare function isTerminalStepEventType(eventType: string): eventType is TerminalStepEventType;
58
+ declare const HookLifecycleEventTypeSchema: z.ZodEnum<{
59
+ hook_created: "hook_created";
60
+ hook_received: "hook_received";
61
+ hook_disposed: "hook_disposed";
62
+ }>;
63
+ export type HookLifecycleEventType = z.infer<typeof HookLifecycleEventTypeSchema>;
64
+ export declare const HOOK_LIFECYCLE_EVENT_TYPES: ("hook_created" | "hook_received" | "hook_disposed")[];
65
+ export declare function isHookLifecycleEventType(eventType: string): eventType is HookLifecycleEventType;
66
+ declare const HookEventRequiringExistenceTypeSchema: z.ZodEnum<{
67
+ hook_received: "hook_received";
68
+ hook_disposed: "hook_disposed";
69
+ }>;
70
+ export type HookEventRequiringExistenceType = z.infer<typeof HookEventRequiringExistenceTypeSchema>;
71
+ export declare const HOOK_EVENTS_REQUIRING_EXISTENCE: ("hook_received" | "hook_disposed")[];
72
+ export declare function isHookEventRequiringExistence(eventType: string): eventType is HookEventRequiringExistenceType;
73
+ declare const WaitEventTypeSchema: z.ZodEnum<{
74
+ wait_created: "wait_created";
75
+ wait_completed: "wait_completed";
76
+ }>;
77
+ export type WaitEventType = z.infer<typeof WaitEventTypeSchema>;
78
+ export declare const WAIT_EVENT_TYPES: ("wait_created" | "wait_completed")[];
79
+ export declare function isWaitEventType(eventType: string): eventType is WaitEventType;
80
+ declare const ChildEntityCreationEventTypeSchema: z.ZodEnum<{
81
+ step_created: "step_created";
82
+ hook_created: "hook_created";
83
+ wait_created: "wait_created";
84
+ }>;
85
+ export type ChildEntityCreationEventType = z.infer<typeof ChildEntityCreationEventTypeSchema>;
86
+ export declare const CHILD_ENTITY_CREATION_EVENT_TYPES: ("step_created" | "hook_created" | "wait_created")[];
87
+ export declare function isChildEntityCreationEventType(eventType: string): eventType is ChildEntityCreationEventType;
88
+ /**
89
+ * Field within eventData that carries the opaque user payload for event types
90
+ * that have one. V4 worlds split this field into the wire body while keeping
91
+ * the remaining eventData fields in metadata.
92
+ */
93
+ export declare const EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE: {
94
+ readonly run_created: "input";
95
+ readonly run_started: "input";
96
+ readonly run_completed: "output";
97
+ readonly run_failed: "error";
98
+ readonly step_created: "input";
99
+ readonly step_started: "input";
100
+ readonly step_completed: "result";
101
+ readonly step_failed: "error";
102
+ readonly step_retrying: "error";
103
+ readonly hook_created: "metadata";
104
+ readonly hook_received: "payload";
105
+ };
106
+ export type EventDataPayloadField = (typeof EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE)[keyof typeof EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE];
107
+ /**
108
+ * Fields within eventData that hold ref/payload data per event type.
109
+ * When resolveData is 'none', only these fields are stripped — all other
110
+ * metadata (stepName, workflowName, etc.) is preserved.
111
+ */
112
+ export declare const EVENT_DATA_REF_FIELDS: Record<string, readonly EventDataPayloadField[]>;
113
+ export declare function getEventDataRefFields(eventType: string): readonly string[];
114
+ export declare function getEventDataPayloadField(eventType: string): EventDataPayloadField | undefined;
115
+ /**
116
+ * Strip ref/payload fields from eventData based on resolveData setting.
117
+ * When resolveData is 'none', removes only large data fields (refs) from
118
+ * eventData while preserving metadata like stepName, workflowName, etc.
119
+ */
120
+ export declare function stripEventDataRefs(event: Event, resolveData: ResolveData): Event;
43
121
  export declare const BaseEventSchema: z.ZodObject<{
44
122
  eventType: z.ZodEnum<{
45
123
  run_created: "run_created";
124
+ run_started: "run_started";
46
125
  run_completed: "run_completed";
47
126
  run_failed: "run_failed";
127
+ run_cancelled: "run_cancelled";
128
+ attr_set: "attr_set";
48
129
  step_created: "step_created";
49
130
  step_completed: "step_completed";
50
131
  step_failed: "step_failed";
51
132
  step_retrying: "step_retrying";
133
+ step_started: "step_started";
52
134
  hook_created: "hook_created";
53
135
  hook_received: "hook_received";
54
- run_started: "run_started";
55
- run_cancelled: "run_cancelled";
56
- attr_set: "attr_set";
57
- step_started: "step_started";
58
136
  hook_disposed: "hook_disposed";
59
137
  hook_conflict: "hook_conflict";
60
138
  wait_created: "wait_created";
@@ -164,6 +242,9 @@ export declare const CreateEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
164
242
  correlationId: z.ZodOptional<z.ZodString>;
165
243
  specVersion: z.ZodOptional<z.ZodNumber>;
166
244
  eventType: z.ZodLiteral<"run_cancelled">;
245
+ eventData: z.ZodOptional<z.ZodObject<{
246
+ cancelReason: z.ZodOptional<z.ZodString>;
247
+ }, z.core.$strip>>;
167
248
  }, z.core.$strip>, z.ZodObject<{
168
249
  specVersion: z.ZodOptional<z.ZodNumber>;
169
250
  eventType: z.ZodLiteral<"attr_set">;
@@ -196,6 +277,11 @@ export declare const CreateEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
196
277
  eventType: z.ZodLiteral<"step_completed">;
197
278
  correlationId: z.ZodString;
198
279
  eventData: z.ZodObject<{
280
+ ttfs: z.ZodOptional<z.ZodNumber>;
281
+ stso: z.ZodOptional<z.ZodNumber>;
282
+ stepCount: z.ZodOptional<z.ZodNumber>;
283
+ eventCount: z.ZodOptional<z.ZodNumber>;
284
+ optimizations: z.ZodOptional<z.ZodArray<z.ZodString>>;
199
285
  stepName: z.ZodOptional<z.ZodString>;
200
286
  workflowName: z.ZodOptional<z.ZodString>;
201
287
  result: z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>;
@@ -205,6 +291,11 @@ export declare const CreateEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
205
291
  eventType: z.ZodLiteral<"step_failed">;
206
292
  correlationId: z.ZodString;
207
293
  eventData: z.ZodObject<{
294
+ ttfs: z.ZodOptional<z.ZodNumber>;
295
+ stso: z.ZodOptional<z.ZodNumber>;
296
+ stepCount: z.ZodOptional<z.ZodNumber>;
297
+ eventCount: z.ZodOptional<z.ZodNumber>;
298
+ optimizations: z.ZodOptional<z.ZodArray<z.ZodString>>;
208
299
  stepName: z.ZodOptional<z.ZodString>;
209
300
  error: z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>;
210
301
  }, z.core.$strip>;
@@ -226,6 +317,7 @@ export declare const CreateEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
226
317
  attempt: z.ZodOptional<z.ZodNumber>;
227
318
  workflowName: z.ZodOptional<z.ZodString>;
228
319
  input: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>>;
320
+ ownerMessageId: z.ZodOptional<z.ZodString>;
229
321
  }, z.core.$strip>>;
230
322
  }, z.core.$strip>, z.ZodObject<{
231
323
  specVersion: z.ZodOptional<z.ZodNumber>;
@@ -310,6 +402,9 @@ export declare const EventSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<[z.Z
310
402
  correlationId: z.ZodOptional<z.ZodString>;
311
403
  specVersion: z.ZodOptional<z.ZodNumber>;
312
404
  eventType: z.ZodLiteral<"run_cancelled">;
405
+ eventData: z.ZodOptional<z.ZodObject<{
406
+ cancelReason: z.ZodOptional<z.ZodString>;
407
+ }, z.core.$strip>>;
313
408
  }, z.core.$strip>, z.ZodObject<{
314
409
  specVersion: z.ZodOptional<z.ZodNumber>;
315
410
  eventType: z.ZodLiteral<"attr_set">;
@@ -342,6 +437,11 @@ export declare const EventSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<[z.Z
342
437
  eventType: z.ZodLiteral<"step_completed">;
343
438
  correlationId: z.ZodString;
344
439
  eventData: z.ZodObject<{
440
+ ttfs: z.ZodOptional<z.ZodNumber>;
441
+ stso: z.ZodOptional<z.ZodNumber>;
442
+ stepCount: z.ZodOptional<z.ZodNumber>;
443
+ eventCount: z.ZodOptional<z.ZodNumber>;
444
+ optimizations: z.ZodOptional<z.ZodArray<z.ZodString>>;
345
445
  stepName: z.ZodOptional<z.ZodString>;
346
446
  workflowName: z.ZodOptional<z.ZodString>;
347
447
  result: z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>;
@@ -351,6 +451,11 @@ export declare const EventSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<[z.Z
351
451
  eventType: z.ZodLiteral<"step_failed">;
352
452
  correlationId: z.ZodString;
353
453
  eventData: z.ZodObject<{
454
+ ttfs: z.ZodOptional<z.ZodNumber>;
455
+ stso: z.ZodOptional<z.ZodNumber>;
456
+ stepCount: z.ZodOptional<z.ZodNumber>;
457
+ eventCount: z.ZodOptional<z.ZodNumber>;
458
+ optimizations: z.ZodOptional<z.ZodArray<z.ZodString>>;
354
459
  stepName: z.ZodOptional<z.ZodString>;
355
460
  error: z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>;
356
461
  }, z.core.$strip>;
@@ -372,6 +477,7 @@ export declare const EventSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<[z.Z
372
477
  attempt: z.ZodOptional<z.ZodNumber>;
373
478
  workflowName: z.ZodOptional<z.ZodString>;
374
479
  input: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>>;
480
+ ownerMessageId: z.ZodOptional<z.ZodString>;
375
481
  }, z.core.$strip>>;
376
482
  }, z.core.$strip>, z.ZodObject<{
377
483
  specVersion: z.ZodOptional<z.ZodNumber>;
@@ -428,7 +534,14 @@ export declare const EventSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<[z.Z
428
534
  specVersion: z.ZodOptional<z.ZodNumber>;
429
535
  }, z.core.$strip>>;
430
536
  export type Event = z.infer<typeof EventSchema>;
431
- export type HookCreatedEvent = z.infer<typeof HookCreatedEventSchema>;
537
+ export type EventOfType<T extends EventType> = Extract<Event, {
538
+ eventType: T;
539
+ }>;
540
+ export type EventRequestOfType<T extends EventType> = Extract<AnyEventRequest, {
541
+ eventType: T;
542
+ }>;
543
+ export type HookCreatedEvent = EventOfType<'hook_created'>;
544
+ export type HookCreatedEventRequest = EventRequestOfType<'hook_created'>;
432
545
  export type HookReceivedEvent = z.infer<typeof HookReceivedEventSchema>;
433
546
  export type HookConflictEvent = z.infer<typeof HookConflictEventSchema>;
434
547
  /**
@@ -436,6 +549,14 @@ export type HookConflictEvent = z.infer<typeof HookConflictEventSchema>;
436
549
  * @internal Use CreateEventRequest or RunCreatedEventRequest instead.
437
550
  */
438
551
  export type AnyEventRequest = z.infer<typeof CreateEventSchema>;
552
+ type ChildEntityCreationEventRequest = EventRequestOfType<ChildEntityCreationEventType> | (EventRequestOfType<'step_started'> & {
553
+ eventData: {
554
+ stepName: string;
555
+ input: unknown;
556
+ };
557
+ });
558
+ /** Includes lazy step_started requests that create their step on demand. */
559
+ export declare function isChildEntityCreationEvent(event: AnyEventRequest): event is ChildEntityCreationEventRequest;
439
560
  /**
440
561
  * Event request for creating a new workflow run.
441
562
  * Can be used with a client-generated runId or null for server-generated.
@@ -28,30 +28,7 @@ export declare const HookSchema: z.ZodObject<{
28
28
  * - specVersion >= 2: Uint8Array (binary devalue format)
29
29
  * - specVersion 1: unknown (legacy JSON format)
30
30
  */
31
- export type Hook = z.infer<typeof HookSchema> & {
32
- /** The unique identifier of the workflow run this hook belongs to. */
33
- runId: string;
34
- /** The unique identifier of this hook within the workflow run. */
35
- hookId: string;
36
- /** The secret token used to reference this hook. */
37
- token: string;
38
- /** The owner ID (team or user) that owns this hook. */
39
- ownerId: string;
40
- /** The project ID this hook belongs to. */
41
- projectId: string;
42
- /** The environment (e.g., "production", "preview", "development") where this hook was created. */
43
- environment: string;
44
- /** Optional metadata associated with the hook, set when the hook was created. */
45
- metadata?: SerializedData;
46
- /** The timestamp when this hook was created. */
47
- createdAt: Date;
48
- /** The spec version when this hook was created. */
49
- specVersion?: number;
50
- /** Whether this hook is resumable via the public webhook endpoint. undefined = legacy (treated as true for backwards compat). */
51
- isWebhook?: boolean;
52
- /** Whether this hook is a system-managed hook (e.g., for abort signals). */
53
- isSystem?: boolean;
54
- };
31
+ export type Hook = z.infer<typeof HookSchema>;
55
32
  export interface CreateHookRequest {
56
33
  hookId: string;
57
34
  token: string;
@@ -4,7 +4,7 @@ export type * from './attributes.js';
4
4
  export { ATTRIBUTE_KEY_MAX_LENGTH, ATTRIBUTE_MAX_PER_RUN, ATTRIBUTE_VALUE_MAX_BYTES, AttributeChangeSchema, AttributeChangesSchema, AttributeValidationError, applyAttributeChanges, RESERVED_ATTRIBUTE_KEY_PREFIX, validateAttributeChanges, validateAttributeKey, validateAttributeValue, } from './attributes.js';
5
5
  export { _resetEnvWarnCacheForTests, type EnvNumberOptions, envNumber, } from './env-config.js';
6
6
  export type * from './events.js';
7
- export { BaseEventSchema, CreateEventSchema, EVENT_DATA_REF_FIELDS, EventSchema, EventTypeSchema, HookCreatedEventSchema, isTerminalRunEventType, stripEventDataRefs, TERMINAL_RUN_EVENT_TYPES, TerminalRunEventTypeSchema, } from './events.js';
7
+ export { BaseEventSchema, CHILD_ENTITY_CREATION_EVENT_TYPES, CreateEventSchema, EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE, EVENT_DATA_REF_FIELDS, EventSchema, EventTypeSchema, getEventDataPayloadField, getEventDataRefFields, HOOK_EVENTS_REQUIRING_EXISTENCE, HOOK_LIFECYCLE_EVENT_TYPES, HookCreatedEventSchema, isChildEntityCreationEvent, isChildEntityCreationEventType, isHookEventRequiringExistence, isHookLifecycleEventType, isRunEventType, isStepEventType, isTerminalRunEventType, isTerminalStepEventType, isWaitEventType, RUN_EVENT_TYPES, STEP_EVENT_TYPES, stripEventDataRefs, TERMINAL_RUN_EVENT_TYPES, TERMINAL_STEP_EVENT_TYPES, TerminalRunEventTypeSchema, WAIT_EVENT_TYPES, } from './events.js';
8
8
  export type * from './hooks.js';
9
9
  export { HookSchema } from './hooks.js';
10
10
  export type * from './interfaces.js';
@@ -22,7 +22,8 @@ export type { SpecVersion } from './spec-version.js';
22
22
  export { isLegacySpecVersion, requiresNewerWorld, SPEC_VERSION_CURRENT, SPEC_VERSION_LEGACY, SPEC_VERSION_SUPPORTS_ATTRIBUTES, SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT, SPEC_VERSION_SUPPORTS_COMPRESSION, SPEC_VERSION_SUPPORTS_EVENT_SOURCING, } from './spec-version.js';
23
23
  export type * from './steps.js';
24
24
  export { isTerminalStepStatus, StepSchema, StepStatusSchema, TERMINAL_STEP_STATUSES, TerminalStepStatusSchema, } from './steps.js';
25
- export { DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS, DEFAULT_TIMESTAMP_THRESHOLD_MS, DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS, ulidToDate, validateUlidTimestamp, } from './ulid.js';
25
+ export { DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS, DEFAULT_TIMESTAMP_THRESHOLD_MS, DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS, ulidToDate, validateUlidTimestamp, workflowRunIdSchema, } from './ulid.js';
26
+ export type { WorkflowRunId } from './ulid.js';
26
27
  export type * from './waits.js';
27
28
  export { WaitSchema, WaitStatusSchema } from './waits.js';
28
29
  //# sourceMappingURL=index.d.ts.map
@@ -147,6 +147,16 @@ export interface Queue {
147
147
  }>;
148
148
  /**
149
149
  * Creates an HTTP queue handler for processing messages from a specific queue.
150
+ *
151
+ * `meta.messageId` SHOULD be stable across redeliveries of the same message
152
+ * (one ID per enqueued message, reused on every delivery attempt). The
153
+ * runtime's inline step ownership uses it as a liveness lease: the lazy
154
+ * `step_started` records the handling invocation's messageId, and only a
155
+ * delivery of that same message may re-execute the step before the
156
+ * ownership lease expires (crash recovery via queue redelivery). A World
157
+ * whose queue mints a fresh ID per delivery degrades gracefully — owner
158
+ * redeliveries fall back to the delayed-backstop path instead of executing
159
+ * immediately, adding recovery latency but never wedging or duplicating.
150
160
  */
151
161
  createQueueHandler(queueNamePrefix: QueuePrefix, handler: (message: unknown, meta: {
152
162
  attempt: number;
@@ -1,5 +1,5 @@
1
- import type { Queue } from './queue.js';
2
1
  import type { Storage } from './interfaces.js';
2
+ import { type Queue } from './queue.js';
3
3
  /**
4
4
  * Re-enqueue all active (pending/running) workflow runs so they resume
5
5
  * processing after a world restart. The workflow handler is idempotent
@@ -8,6 +8,7 @@ import type { Storage } from './interfaces.js';
8
8
  * @param runs - Storage runs interface for listing active runs
9
9
  * @param enqueue - Queue's enqueue method
10
10
  * @param label - Log prefix for identifying the world implementation (e.g. "world-local")
11
+ * @param namespace - Optional queue namespace. Defaults to WORKFLOW_QUEUE_NAMESPACE.
11
12
  */
12
- export declare function reenqueueActiveRuns(runs: Storage['runs'], enqueue: Queue['queue'], label: string): Promise<void>;
13
+ export declare function reenqueueActiveRuns(runs: Storage['runs'], enqueue: Queue['queue'], label: string, namespace?: string): Promise<void>;
13
14
  //# sourceMappingURL=recovery.d.ts.map
@@ -1,3 +1,12 @@
1
+ import { z } from '#compiled/zod/index.js';
2
+ /**
3
+ * A workflow run ID: the `wrun_` prefix followed by a 26-char ULID (minted
4
+ * client-side in core's `start()`). Validates the exact shape — prefix plus a
5
+ * well-formed ULID — rather than a loose length bound, so callers can't smuggle
6
+ * arbitrary strings through APIs that persist a run ID verbatim.
7
+ */
8
+ export declare const workflowRunIdSchema: z.ZodTemplateLiteral<`wrun_${string}`>;
9
+ export type WorkflowRunId = z.infer<typeof workflowRunIdSchema>;
1
10
  /**
2
11
  * Default threshold for ULID timestamps in the past (24 hours).
3
12
  *