eve 0.52.4 → 0.53.0

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 (149) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/src/cli/commands/init-agent-workspace.d.ts +2 -0
  3. package/dist/src/cli/commands/init-agent-workspace.js +1 -1
  4. package/dist/src/cli/commands/init-install.d.ts +8 -0
  5. package/dist/src/cli/commands/init-install.js +1 -0
  6. package/dist/src/cli/commands/init.d.ts +3 -4
  7. package/dist/src/cli/commands/init.js +1 -1
  8. package/dist/src/cli/dev/tui/message-queue.js +1 -1
  9. package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
  10. package/dist/src/cli/run.js +2 -2
  11. package/dist/src/cli/telemetry/index.d.ts +3 -0
  12. package/dist/src/cli/telemetry/index.js +1 -1
  13. package/dist/src/compiled/.vendor-stamp.json +17 -16
  14. package/dist/src/compiled/@ai-sdk/anthropic/index.d.ts +23 -2
  15. package/dist/src/compiled/@ai-sdk/anthropic/index.js +2 -4
  16. package/dist/src/compiled/@ai-sdk/google/index.d.ts +145 -33
  17. package/dist/src/compiled/@ai-sdk/google/index.js +10 -7
  18. package/dist/src/compiled/@ai-sdk/mcp/index.d.ts +176 -7
  19. package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
  20. package/dist/src/compiled/@ai-sdk/openai/index.d.ts +71 -40
  21. package/dist/src/compiled/@ai-sdk/openai/index.js +8 -8
  22. package/dist/src/compiled/@ai-sdk/otel/index.js +1 -1
  23. package/dist/src/compiled/@ai-sdk/provider/index.d.ts +225 -3
  24. package/dist/src/compiled/@ai-sdk/provider-utils/index.d.ts +220 -151
  25. package/dist/src/compiled/@workflow/core/create-hook.d.ts +3 -0
  26. package/dist/src/compiled/@workflow/core/index.js +2 -2
  27. package/dist/src/compiled/@workflow/core/private.js +1 -1
  28. package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +59 -7
  29. package/dist/src/compiled/@workflow/core/runtime/run.d.ts +42 -0
  30. package/dist/src/compiled/@workflow/core/runtime/start.d.ts +31 -1
  31. package/dist/src/compiled/@workflow/core/runtime.d.ts +2 -2
  32. package/dist/src/compiled/@workflow/core/runtime.js +2 -2
  33. package/dist/src/compiled/@workflow/core/serialization.d.ts +22 -0
  34. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  35. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  36. package/dist/src/compiled/@workflow/errors/index.d.ts +37 -3
  37. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  38. package/dist/src/compiled/@workflow/world/attributes-validation.d.ts +68 -0
  39. package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
  40. package/dist/src/compiled/@workflow/world/interfaces.d.ts +21 -0
  41. package/dist/src/compiled/@workflow/world-local/index.js +5 -5
  42. package/dist/src/compiled/@workflow/world-vercel/index.js +3 -3
  43. package/dist/src/compiled/_chunks/workflow/attribute-changes-C6H-fRVP.js +20 -0
  44. package/dist/src/compiled/_chunks/workflow/dist-DDeH-1ER.js +40 -0
  45. package/dist/src/compiled/_chunks/workflow/dist-DhncQSl7.js +74 -0
  46. package/dist/src/compiled/_chunks/workflow/{dist-BIO9Inoc.js → dist-xTushGCp.js} +1 -1
  47. package/dist/src/compiled/_chunks/workflow/frames-DsEqSDes.js +3 -0
  48. package/dist/src/compiled/_chunks/workflow/{private-aXEeo0fU.js → private-CFJkQA7R.js} +1 -1
  49. package/dist/src/compiled/_chunks/workflow/resume-hook-BRDLAb67.js +1 -0
  50. package/dist/src/compiled/_chunks/workflow/run-BM2OFphk.js +1 -0
  51. package/dist/src/compiled/_chunks/workflow/sleep-6cG0F99-.js +1 -0
  52. package/dist/src/compiled/_chunks/workflow/{ws-transport-M7uk8HV8.js → ws-transport-DuK82LLz.js} +1 -1
  53. package/dist/src/compiler/extension-compatibility.d.ts +7 -6
  54. package/dist/src/compiler/extension-compatibility.js +1 -1
  55. package/dist/src/compiler/manifest.js +1 -1
  56. package/dist/src/compiler/normalize-agent-config.js +1 -1
  57. package/dist/src/compiler/normalize-manifest-helpers.js +1 -1
  58. package/dist/src/context/dynamic-model-lifecycle.js +1 -1
  59. package/dist/src/context/keys.d.ts +11 -2
  60. package/dist/src/context/keys.js +1 -1
  61. package/dist/src/evals/mock-model.js +1 -1
  62. package/dist/src/evals/runner/run-evals.d.ts +1 -1
  63. package/dist/src/evals/runner/run-evals.js +1 -1
  64. package/dist/src/execution/activity-cohort.d.ts +20 -0
  65. package/dist/src/execution/activity-cohort.js +1 -0
  66. package/dist/src/execution/authorization-callback-match.d.ts +1 -0
  67. package/dist/src/execution/authorization-callback-match.js +1 -1
  68. package/dist/src/execution/cancelled-model-call-batch.d.ts +15 -0
  69. package/dist/src/execution/cancelled-model-call-batch.js +1 -0
  70. package/dist/src/execution/coordination-dispatch-shared.js +1 -1
  71. package/dist/src/execution/model-call-batching.d.ts +11 -0
  72. package/dist/src/execution/model-call-batching.js +1 -0
  73. package/dist/src/execution/parked-delivery-wait.js +1 -1
  74. package/dist/src/execution/session-activity-projection.d.ts +2 -0
  75. package/dist/src/execution/session-activity-projection.js +1 -1
  76. package/dist/src/execution/skills/instructions.js +1 -1
  77. package/dist/src/execution/tools/sleep-workflow.js +1 -1
  78. package/dist/src/execution/tools/subagent/invoke-agent.d.ts +5 -5
  79. package/dist/src/execution/tools/subagent/invoke-agent.js +1 -1
  80. package/dist/src/execution/tools/subagent/start.js +1 -1
  81. package/dist/src/execution/tools/workflow/body.js +1 -1
  82. package/dist/src/execution/turn-workflow.js +1 -1
  83. package/dist/src/execution/wire/session-inbox-resume.js +1 -1
  84. package/dist/src/execution/workflow-steps.d.ts +1 -1
  85. package/dist/src/execution/workflow-steps.js +1 -1
  86. package/dist/src/harness/approval-delivery-coordinator.js +1 -1
  87. package/dist/src/harness/authorization.d.ts +1 -0
  88. package/dist/src/harness/authorization.js +1 -1
  89. package/dist/src/harness/compaction.js +1 -1
  90. package/dist/src/harness/current-messages.d.ts +8 -2
  91. package/dist/src/harness/current-messages.js +1 -1
  92. package/dist/src/harness/hitl/approval-input-requests.js +1 -1
  93. package/dist/src/harness/input-requests.js +1 -1
  94. package/dist/src/harness/pending-input-batches.d.ts +4 -0
  95. package/dist/src/harness/pending-input-batches.js +1 -1
  96. package/dist/src/harness/tool-loop.js +2 -2
  97. package/dist/src/harness/turn-client-context.d.ts +1 -1
  98. package/dist/src/internal/application/package.js +1 -1
  99. package/dist/src/internal/authored-definition/core.js +1 -1
  100. package/dist/src/internal/authored-package-boundary.js +1 -1
  101. package/dist/src/internal/mock-model-identity.d.ts +2 -0
  102. package/dist/src/internal/mock-model-identity.js +1 -0
  103. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  104. package/dist/src/internal/workflow-bundle/authored-workflow-directives.js +1 -1
  105. package/dist/src/public/tools/index.d.ts +1 -0
  106. package/dist/src/public/tools/index.js +1 -1
  107. package/dist/src/runtime/resolve-agent.js +1 -1
  108. package/dist/src/self-modification/agent.d.ts +2 -2
  109. package/dist/src/self-modification/agent.js +1 -1
  110. package/dist/src/self-modification/config.d.ts +15 -0
  111. package/dist/src/self-modification/config.js +1 -1
  112. package/dist/src/self-modification/extension/extension.d.ts +3 -0
  113. package/dist/src/self-modification/extension/extension.js +1 -1
  114. package/dist/src/self-modification/setup.d.ts +3 -0
  115. package/dist/src/self-modification/setup.js +25 -4
  116. package/dist/src/setup/integrations/self-modification/setup.js +1 -1
  117. package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
  118. package/dist/src/setup/scaffold/create/project.js +2 -2
  119. package/dist/src/setup/scaffold/update/web-options.js +1 -1
  120. package/dist/src/shared/agent-definition.d.ts +11 -2
  121. package/dist/src/tasks/delivery-context.d.ts +2 -2
  122. package/dist/src/tasks/delivery-context.js +2 -18
  123. package/dist/src/tasks/delivery-policy.js +1 -1
  124. package/dist/src/tools/durable-callbacks.d.ts +18 -1
  125. package/dist/src/tools/durable-callbacks.js +1 -1
  126. package/dist/src/tools/workflow-definition.d.ts +38 -4
  127. package/docs/agent-config.md +44 -8
  128. package/docs/channels/overview.mdx +2 -0
  129. package/docs/channels/slack.mdx +2 -0
  130. package/docs/concepts/execution-model-and-durability.mdx +20 -2
  131. package/docs/evals/running.mdx +3 -1
  132. package/docs/guides/dev-tui.md +11 -11
  133. package/docs/guides/dynamic-capabilities.md +36 -1
  134. package/docs/guides/instrumentation.md +3 -2
  135. package/docs/instructions.mdx +1 -1
  136. package/docs/reference/cli.md +1 -1
  137. package/docs/reference/telemetry.md +1 -1
  138. package/docs/reference/typescript-api.md +36 -35
  139. package/docs/subagents/index.mdx +1 -1
  140. package/docs/tools/overview.mdx +4 -2
  141. package/docs/tools/workflows.mdx +15 -10
  142. package/package.json +17 -17
  143. package/dist/src/compiled/_chunks/workflow/attribute-changes-DpruylJZ.js +0 -20
  144. package/dist/src/compiled/_chunks/workflow/dist-ChzQSWQA.js +0 -65
  145. package/dist/src/compiled/_chunks/workflow/dist-veFIAdWV.js +0 -40
  146. package/dist/src/compiled/_chunks/workflow/frames-DKxlMf3X.js +0 -3
  147. package/dist/src/compiled/_chunks/workflow/resume-hook-DWDi_wCN.js +0 -1
  148. package/dist/src/compiled/_chunks/workflow/run-vsAdI41O.js +0 -1
  149. package/dist/src/compiled/_chunks/workflow/sleep-BKxoNDRv.js +0 -1
@@ -1,4 +1,4 @@
1
- import { SharedV4FileDataUrl, SharedV4FileDataReference, SharedV4FileDataText, SharedV4ProviderOptions, SharedV4ProviderReference, JSONValue, ImageModelV4File, LanguageModelV4ResponseMetadata, LanguageModelV4Usage, LanguageModelV4FunctionTool, LanguageModelV4ProviderTool, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, APICallError, LanguageModelV4Prompt, LanguageModelV4CallOptions, SharedV4Warning, Experimental_BatchV4Status, JSONObject, LanguageModelV4FilePart, LanguageModelV4StreamPart, SharedV4ProviderMetadata, Experimental_TranscriptionModelV4StreamPart, TypeValidationContext } from '#compiled/@ai-sdk/provider/index.js';
1
+ import { SharedV4FileDataUrl, SharedV4FileDataReference, SharedV4FileDataText, SharedV4ProviderOptions, SharedV4ProviderReference, JSONValue, ImageModelV4File, LanguageModelV4ResponseMetadata, LanguageModelV4Usage, LanguageModelV4FunctionTool, LanguageModelV4ProviderTool, JSONSchema7, JSONParseError, TypeValidationError, APICallError, AISDKError, LanguageModelV4Prompt, LanguageModelV4CallOptions, SharedV4Warning, Experimental_BatchV4Status, JSONObject, LanguageModelV4FilePart, LanguageModelV4StreamPart, SharedV4ProviderMetadata, Experimental_TranscriptionModelV4StreamPart, TypeValidationContext } from '#compiled/@ai-sdk/provider/index.js';
2
2
  export { getErrorMessage } from '#compiled/@ai-sdk/provider/index.js';
3
3
  import { StandardSchemaV1, StandardJSONSchemaV1 } from '#compiled/@standard-schema/spec/index.js';
4
4
  export * from '#compiled/@standard-schema/spec/index.js';
@@ -632,8 +632,14 @@ type InlineFileData = Extract<FilePart['data'], {
632
632
  * - `{ type: 'data', data: Uint8Array | Buffer }` → returned as-is
633
633
  * - `{ type: 'data', data: ArrayBuffer }` → wrapped in a `Uint8Array`
634
634
  * - `{ type: 'data', data: string }` → decoded as base64
635
+ *
636
+ * `{ type: 'stream' }` data is rejected: providers without streaming upload
637
+ * support funnel here and surface a clear `UnsupportedFunctionalityError`.
635
638
  */
636
- declare function convertInlineFileDataToUint8Array(data: InlineFileData): Uint8Array;
639
+ declare function convertInlineFileDataToUint8Array(data: InlineFileData | {
640
+ type: 'stream';
641
+ stream: ReadableStream<Uint8Array>;
642
+ }): Uint8Array;
637
643
 
638
644
  /**
639
645
  * Convert an ImageModelV4File to a URL or data URI string.
@@ -781,6 +787,178 @@ declare class DelayedPromise<T> {
781
787
  isPending(): boolean;
782
788
  }
783
789
 
790
+ /**
791
+ * Fetch function type (standardizes the version of fetch used).
792
+ */
793
+ type FetchFunction = typeof globalThis.fetch;
794
+
795
+ /**
796
+ * Used to mark schemas so we can support both Zod and custom schemas.
797
+ */
798
+ declare const schemaSymbol: unique symbol;
799
+ type ValidationResult<OBJECT> = {
800
+ success: true;
801
+ value: OBJECT;
802
+ } | {
803
+ success: false;
804
+ error: Error;
805
+ };
806
+ type Schema<OBJECT = unknown> = {
807
+ /**
808
+ * Used to mark schemas so we can support both Zod and custom schemas.
809
+ */
810
+ [schemaSymbol]: true;
811
+ /**
812
+ * Schema type for inference.
813
+ */
814
+ _type: OBJECT;
815
+ /**
816
+ * Optional. Validates that the structure of a value matches this schema,
817
+ * and returns a typed version of the value if it does.
818
+ */
819
+ readonly validate?: (value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>;
820
+ /**
821
+ * The JSON Schema for the schema. It is passed to the providers.
822
+ */
823
+ readonly jsonSchema: JSONSchema7 | PromiseLike<JSONSchema7>;
824
+ };
825
+ /**
826
+ * Creates a schema with deferred creation.
827
+ * This is important to reduce the startup time of the library
828
+ * and to avoid initializing unused validators.
829
+ *
830
+ * @param createValidator A function that creates a schema.
831
+ * @returns A function that returns a schema.
832
+ */
833
+ declare function lazySchema<SCHEMA>(createSchema: () => Schema<SCHEMA>): LazySchema<SCHEMA>;
834
+ type LazySchema<SCHEMA> = () => Schema<SCHEMA>;
835
+ type ZodSchema<SCHEMA = any> = z3.Schema<SCHEMA, z3.ZodTypeDef, any> | $ZodType<SCHEMA, any>;
836
+ type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & {
837
+ readonly '~standard': StandardSchemaV1.Props<unknown, SCHEMA> & {
838
+ readonly jsonSchema?: StandardJSONSchemaV1.Converter;
839
+ };
840
+ };
841
+ type FlexibleSchema<SCHEMA = any> = Schema<SCHEMA> | LazySchema<SCHEMA> | ZodSchema<SCHEMA> | StandardSchema<SCHEMA>;
842
+ type InferSchema<SCHEMA> = SCHEMA extends ZodSchema<infer T> ? T : SCHEMA extends StandardSchema<infer T> ? T : SCHEMA extends LazySchema<infer T> ? T : SCHEMA extends Schema<infer T> ? T : never;
843
+ /**
844
+ * Create a schema using a JSON Schema.
845
+ *
846
+ * @param jsonSchema The JSON Schema for the schema.
847
+ * @param options.validate Optional. A validation function for the schema.
848
+ */
849
+ declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7 | PromiseLike<JSONSchema7> | (() => JSONSchema7 | PromiseLike<JSONSchema7>), { validate, }?: {
850
+ validate?: (value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>;
851
+ }): Schema<OBJECT>;
852
+ declare function asSchema<OBJECT>(schema: FlexibleSchema<OBJECT> | undefined): Schema<OBJECT>;
853
+ declare function zodSchema<OBJECT>(zodSchema: $ZodType<OBJECT, any> | z3.Schema<OBJECT, z3.ZodTypeDef, any>, options?: {
854
+ /**
855
+ * Enables support for references in the schema.
856
+ * This is required for recursive schemas, e.g. with `z.lazy`.
857
+ * However, not all language models and providers support such references.
858
+ * Defaults to `false`.
859
+ */
860
+ useReferences?: boolean;
861
+ }): Schema<OBJECT>;
862
+
863
+ /**
864
+ * Parses a JSON string into an unknown object.
865
+ *
866
+ * @param text - The JSON string to parse.
867
+ * @returns {JSONValue} - The parsed JSON object.
868
+ */
869
+ declare function parseJSON(options: {
870
+ text: string;
871
+ schema?: undefined;
872
+ }): Promise<JSONValue>;
873
+ /**
874
+ * Parses a JSON string into a strongly-typed object using the provided schema.
875
+ *
876
+ * @template T - The type of the object to parse the JSON into.
877
+ * @param {string} text - The JSON string to parse.
878
+ * @param {Validator<T>} schema - The schema to use for parsing the JSON.
879
+ * @returns {Promise<T>} - The parsed object.
880
+ */
881
+ declare function parseJSON<T>(options: {
882
+ text: string;
883
+ schema: FlexibleSchema<T>;
884
+ }): Promise<T>;
885
+ type ParseResult<T> = {
886
+ success: true;
887
+ value: T;
888
+ rawValue: unknown;
889
+ } | {
890
+ success: false;
891
+ error: JSONParseError | TypeValidationError;
892
+ rawValue: unknown;
893
+ };
894
+ /**
895
+ * Safely parses a JSON string and returns the result as an object of type `unknown`.
896
+ *
897
+ * @param text - The JSON string to parse.
898
+ * @returns {Promise<object>} Either an object with `success: true` and the parsed data, or an object with `success: false` and the error that occurred.
899
+ */
900
+ declare function safeParseJSON(options: {
901
+ text: string;
902
+ schema?: undefined;
903
+ }): Promise<ParseResult<JSONValue>>;
904
+ /**
905
+ * Safely parses a JSON string into a strongly-typed object, using a provided schema to validate the object.
906
+ *
907
+ * @template T - The type of the object to parse the JSON into.
908
+ * @param {string} text - The JSON string to parse.
909
+ * @param {Validator<T>} schema - The schema to use for parsing the JSON.
910
+ * @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
911
+ */
912
+ declare function safeParseJSON<T>(options: {
913
+ text: string;
914
+ schema: FlexibleSchema<T>;
915
+ }): Promise<ParseResult<T>>;
916
+ declare function isParsableJson(input: string): boolean;
917
+
918
+ type ResponseHandler<RETURN_TYPE> = (options: {
919
+ url: string;
920
+ requestBodyValues: unknown;
921
+ response: Response;
922
+ }) => PromiseLike<{
923
+ value: RETURN_TYPE;
924
+ rawValue?: unknown;
925
+ responseHeaders?: Record<string, string>;
926
+ }>;
927
+ declare const createJsonErrorResponseHandler: <T>({ errorSchema, errorToMessage, isRetryable, }: {
928
+ errorSchema: FlexibleSchema<T>;
929
+ errorToMessage: (error: T) => string;
930
+ isRetryable?: (response: Response, error?: T) => boolean;
931
+ }) => ResponseHandler<APICallError>;
932
+ declare const createEventSourceResponseHandler: <T>(chunkSchema: FlexibleSchema<T>) => ResponseHandler<ReadableStream<ParseResult<T>>>;
933
+ declare const createJsonResponseHandler: <T>(responseSchema: FlexibleSchema<T>) => ResponseHandler<T>;
934
+ declare const createJsonLinesResponseHandler: <T>(responseSchema: FlexibleSchema<T>) => ResponseHandler<AsyncGenerator<T>>;
935
+ declare const createBinaryResponseHandler: () => ResponseHandler<Uint8Array>;
936
+ /**
937
+ * Passes the response body through as a `ReadableStream<Uint8Array>` without
938
+ * buffering it (unlike `createBinaryResponseHandler`). The consumer is
939
+ * responsible for draining or cancelling the stream.
940
+ */
941
+ declare const createBinaryStreamResponseHandler: () => ResponseHandler<ReadableStream<Uint8Array>>;
942
+ declare const createStatusCodeErrorResponseHandler: () => ResponseHandler<APICallError>;
943
+
944
+ /**
945
+ * Sends a DELETE request. For URLs built from developer-configured endpoints
946
+ * only — there is no untrusted-URL validation path (use `getFromApi` with
947
+ * `validateUrl` for response-supplied URLs).
948
+ */
949
+ declare const deleteFromApi: <T>({ url, headers, failedResponseHandler, successfulResponseHandler, abortSignal, fetch, }: {
950
+ url: string;
951
+ headers?: Record<string, string | undefined>;
952
+ failedResponseHandler: ResponseHandler<Error>;
953
+ successfulResponseHandler: ResponseHandler<T>;
954
+ abortSignal?: AbortSignal;
955
+ fetch?: FetchFunction;
956
+ }) => Promise<{
957
+ value: T;
958
+ rawValue?: unknown;
959
+ responseHeaders?: Record<string, string>;
960
+ }>;
961
+
784
962
  /**
785
963
  * Detect the IANA media type of a file from its raw bytes or base64 string.
786
964
  *
@@ -861,11 +1039,6 @@ declare class DownloadError extends AISDKError {
861
1039
  */
862
1040
  declare const EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL: unique symbol;
863
1041
 
864
- /**
865
- * Fetch function type (standardizes the version of fetch used).
866
- */
867
- type FetchFunction = typeof globalThis.fetch;
868
-
869
1042
  /**
870
1043
  * Fetches a URL while enforcing the download guard on every hop.
871
1044
  *
@@ -982,149 +1155,6 @@ type IdGenerator = () => string;
982
1155
  */
983
1156
  declare const generateId: IdGenerator;
984
1157
 
985
- /**
986
- * Used to mark schemas so we can support both Zod and custom schemas.
987
- */
988
- declare const schemaSymbol: unique symbol;
989
- type ValidationResult<OBJECT> = {
990
- success: true;
991
- value: OBJECT;
992
- } | {
993
- success: false;
994
- error: Error;
995
- };
996
- type Schema<OBJECT = unknown> = {
997
- /**
998
- * Used to mark schemas so we can support both Zod and custom schemas.
999
- */
1000
- [schemaSymbol]: true;
1001
- /**
1002
- * Schema type for inference.
1003
- */
1004
- _type: OBJECT;
1005
- /**
1006
- * Optional. Validates that the structure of a value matches this schema,
1007
- * and returns a typed version of the value if it does.
1008
- */
1009
- readonly validate?: (value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>;
1010
- /**
1011
- * The JSON Schema for the schema. It is passed to the providers.
1012
- */
1013
- readonly jsonSchema: JSONSchema7 | PromiseLike<JSONSchema7>;
1014
- };
1015
- /**
1016
- * Creates a schema with deferred creation.
1017
- * This is important to reduce the startup time of the library
1018
- * and to avoid initializing unused validators.
1019
- *
1020
- * @param createValidator A function that creates a schema.
1021
- * @returns A function that returns a schema.
1022
- */
1023
- declare function lazySchema<SCHEMA>(createSchema: () => Schema<SCHEMA>): LazySchema<SCHEMA>;
1024
- type LazySchema<SCHEMA> = () => Schema<SCHEMA>;
1025
- type ZodSchema<SCHEMA = any> = z3.Schema<SCHEMA, z3.ZodTypeDef, any> | $ZodType<SCHEMA, any>;
1026
- type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & {
1027
- readonly '~standard': StandardSchemaV1.Props<unknown, SCHEMA> & {
1028
- readonly jsonSchema?: StandardJSONSchemaV1.Converter;
1029
- };
1030
- };
1031
- type FlexibleSchema<SCHEMA = any> = Schema<SCHEMA> | LazySchema<SCHEMA> | ZodSchema<SCHEMA> | StandardSchema<SCHEMA>;
1032
- type InferSchema<SCHEMA> = SCHEMA extends ZodSchema<infer T> ? T : SCHEMA extends StandardSchema<infer T> ? T : SCHEMA extends LazySchema<infer T> ? T : SCHEMA extends Schema<infer T> ? T : never;
1033
- /**
1034
- * Create a schema using a JSON Schema.
1035
- *
1036
- * @param jsonSchema The JSON Schema for the schema.
1037
- * @param options.validate Optional. A validation function for the schema.
1038
- */
1039
- declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7 | PromiseLike<JSONSchema7> | (() => JSONSchema7 | PromiseLike<JSONSchema7>), { validate, }?: {
1040
- validate?: (value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>;
1041
- }): Schema<OBJECT>;
1042
- declare function asSchema<OBJECT>(schema: FlexibleSchema<OBJECT> | undefined): Schema<OBJECT>;
1043
- declare function zodSchema<OBJECT>(zodSchema: $ZodType<OBJECT, any> | z3.Schema<OBJECT, z3.ZodTypeDef, any>, options?: {
1044
- /**
1045
- * Enables support for references in the schema.
1046
- * This is required for recursive schemas, e.g. with `z.lazy`.
1047
- * However, not all language models and providers support such references.
1048
- * Defaults to `false`.
1049
- */
1050
- useReferences?: boolean;
1051
- }): Schema<OBJECT>;
1052
-
1053
- /**
1054
- * Parses a JSON string into an unknown object.
1055
- *
1056
- * @param text - The JSON string to parse.
1057
- * @returns {JSONValue} - The parsed JSON object.
1058
- */
1059
- declare function parseJSON(options: {
1060
- text: string;
1061
- schema?: undefined;
1062
- }): Promise<JSONValue>;
1063
- /**
1064
- * Parses a JSON string into a strongly-typed object using the provided schema.
1065
- *
1066
- * @template T - The type of the object to parse the JSON into.
1067
- * @param {string} text - The JSON string to parse.
1068
- * @param {Validator<T>} schema - The schema to use for parsing the JSON.
1069
- * @returns {Promise<T>} - The parsed object.
1070
- */
1071
- declare function parseJSON<T>(options: {
1072
- text: string;
1073
- schema: FlexibleSchema<T>;
1074
- }): Promise<T>;
1075
- type ParseResult<T> = {
1076
- success: true;
1077
- value: T;
1078
- rawValue: unknown;
1079
- } | {
1080
- success: false;
1081
- error: JSONParseError | TypeValidationError;
1082
- rawValue: unknown;
1083
- };
1084
- /**
1085
- * Safely parses a JSON string and returns the result as an object of type `unknown`.
1086
- *
1087
- * @param text - The JSON string to parse.
1088
- * @returns {Promise<object>} Either an object with `success: true` and the parsed data, or an object with `success: false` and the error that occurred.
1089
- */
1090
- declare function safeParseJSON(options: {
1091
- text: string;
1092
- schema?: undefined;
1093
- }): Promise<ParseResult<JSONValue>>;
1094
- /**
1095
- * Safely parses a JSON string into a strongly-typed object, using a provided schema to validate the object.
1096
- *
1097
- * @template T - The type of the object to parse the JSON into.
1098
- * @param {string} text - The JSON string to parse.
1099
- * @param {Validator<T>} schema - The schema to use for parsing the JSON.
1100
- * @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
1101
- */
1102
- declare function safeParseJSON<T>(options: {
1103
- text: string;
1104
- schema: FlexibleSchema<T>;
1105
- }): Promise<ParseResult<T>>;
1106
- declare function isParsableJson(input: string): boolean;
1107
-
1108
- type ResponseHandler<RETURN_TYPE> = (options: {
1109
- url: string;
1110
- requestBodyValues: unknown;
1111
- response: Response;
1112
- }) => PromiseLike<{
1113
- value: RETURN_TYPE;
1114
- rawValue?: unknown;
1115
- responseHeaders?: Record<string, string>;
1116
- }>;
1117
- declare const createJsonErrorResponseHandler: <T>({ errorSchema, errorToMessage, isRetryable, }: {
1118
- errorSchema: FlexibleSchema<T>;
1119
- errorToMessage: (error: T) => string;
1120
- isRetryable?: (response: Response, error?: T) => boolean;
1121
- }) => ResponseHandler<APICallError>;
1122
- declare const createEventSourceResponseHandler: <T>(chunkSchema: FlexibleSchema<T>) => ResponseHandler<ReadableStream<ParseResult<T>>>;
1123
- declare const createJsonResponseHandler: <T>(responseSchema: FlexibleSchema<T>) => ResponseHandler<T>;
1124
- declare const createJsonLinesResponseHandler: <T>(responseSchema: FlexibleSchema<T>) => ResponseHandler<AsyncGenerator<T>>;
1125
- declare const createBinaryResponseHandler: () => ResponseHandler<Uint8Array>;
1126
- declare const createStatusCodeErrorResponseHandler: () => ResponseHandler<APICallError>;
1127
-
1128
1158
  declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, validateUrl, credentialedOrigin, trustedOrigin, }: {
1129
1159
  url: string;
1130
1160
  headers?: Record<string, string | undefined>;
@@ -1383,6 +1413,45 @@ declare function parseProviderOptions<OPTIONS>({ provider, providerOptions, sche
1383
1413
  schema: FlexibleSchema<OPTIONS>;
1384
1414
  }): Promise<OPTIONS | undefined>;
1385
1415
 
1416
+ /**
1417
+ * A part of a streaming multipart/form-data request body.
1418
+ *
1419
+ * Parts are emitted in array order, which providers may depend on
1420
+ * (e.g. xAI requires expiry fields to precede the file part).
1421
+ */
1422
+ type MultipartStreamPart = {
1423
+ type: 'field';
1424
+ name: string;
1425
+ value: string;
1426
+ } | {
1427
+ type: 'file';
1428
+ name: string;
1429
+ filename?: string;
1430
+ mediaType?: string;
1431
+ content: ReadableStream<Uint8Array> | Uint8Array;
1432
+ };
1433
+ /**
1434
+ * POSTs a multipart/form-data body as a request stream, so file parts backed
1435
+ * by a `ReadableStream` are sent without buffering the full file in memory.
1436
+ *
1437
+ * Requires a fetch implementation that supports streaming request bodies
1438
+ * (`duplex: 'half'`). Callers with fully buffered payloads can keep using
1439
+ * `postFormDataToApi`.
1440
+ */
1441
+ declare const postMultipartStreamToApi: <T>({ url, headers, parts, failedResponseHandler, successfulResponseHandler, abortSignal, fetch, }: {
1442
+ url: string;
1443
+ headers?: Record<string, string | undefined>;
1444
+ parts: Array<MultipartStreamPart>;
1445
+ failedResponseHandler: ResponseHandler<Error>;
1446
+ successfulResponseHandler: ResponseHandler<T>;
1447
+ abortSignal?: AbortSignal;
1448
+ fetch?: FetchFunction;
1449
+ }) => Promise<{
1450
+ value: T;
1451
+ rawValue?: unknown;
1452
+ responseHeaders?: Record<string, string>;
1453
+ }>;
1454
+
1386
1455
  declare const postJsonToApi: <T>({ url, headers, body, failedResponseHandler, successfulResponseHandler, abortSignal, fetch, }: {
1387
1456
  url: string;
1388
1457
  headers?: Record<string, string | undefined>;
@@ -2719,4 +2788,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
2719
2788
  dynamic?: boolean;
2720
2789
  }
2721
2790
 
2722
- export { type Arrayable, type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type DynamicTool, EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, TRANSCRIPTION_STREAM_AUDIO_DONE_FRAME_TYPE as EXPERIMENTAL_TRANSCRIPTION_STREAM_AUDIO_DONE_FRAME_TYPE, TRANSCRIPTION_STREAM_START_FRAME_TYPE as EXPERIMENTAL_TRANSCRIPTION_STREAM_START_FRAME_TYPE, type ExecutableTool, type SandboxProcess as Experimental_SandboxProcess, type SandboxSession as Experimental_SandboxSession, type ToolCallerDefinition as Experimental_ToolCallerDefinition, type ToolCallerTool as Experimental_ToolCallerTool, type TranscriptionStreamClientFrame as Experimental_TranscriptionStreamClientFrame, type TranscriptionStreamStartFrame as Experimental_TranscriptionStreamStartFrame, type FetchFunction, type FileData, type FileDataData, type FileDataReference, type FileDataText, type FileDataUrl, type FilePart, type FlexibleSchema, type FunctionTool, type HasRequiredKey, type IdGenerator, type ImagePart, type InferSchema, type InferToolContext, type InferToolInput, type InferToolOutput, type InferToolSetContext, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderDefinedTool, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderExecutedTool, type ProviderExecutedToolFactory, type ProviderOptions, type ProviderReference, type ProviderStreamError, type ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type RetryDelayProvider, type RetryErrorFactory, type RetryErrorReason, type RetryFunction, type Schema, SerializationError, type ShouldRetryFunction, type StreamingToolCallDelta, StreamingToolCallTracker, type StreamingToolCallTrackerOptions, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type ToolSet, type UserContent, type UserModelMessage, VERSION, type ValidationResult, type WebSocketConnection, type WebSocketConstructor, type WebSocketLike, asArray, asSchema, cancelResponseBody, combineHeaders, connectToWebSocket, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertInlineFileDataToUint8Array, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createNullLanguageModelUsage, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createProviderStreamError, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, detectMediaType, downloadBlob, dynamicTool, executeTool, getToolCaller as experimental_getToolCaller, parseTranscriptionStreamClientFrame as experimental_parseTranscriptionStreamClientFrame, parseTranscriptionStreamPart as experimental_parseTranscriptionStreamPart, serializeTranscriptionStreamPart as experimental_serializeTranscriptionStreamPart, toolCaller as experimental_toolCaller, extractLines, extractResponseHeaders, fetchWithValidatedRedirects, filterNullable, generateId, getFromApi, getRuntimeEnvironmentUserAgent, getTopLevelMediaType, getWebSocketConstructor, injectJsonInstructionIntoMessages, isAbortError, isBrowserRuntime, isBuffer, isCustomReasoning, isExecutableTool, isFullMediaType, isNonNullable, isParsableJson, isProviderReference, isProviderStreamError, isRecord, isSameOrigin, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, mediaTypeToExtension, normalizeBatchRequestCounts, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, readWebSocketMessageText, removeUndefinedEntries, resolve, resolveFullMediaType, resolveProviderReference, retryWithExponentialBackoff, safeParseJSON, safeValidateTypes, secureJsonParse, serializeModelOptions, stripFileExtension, toWebSocketUrl, tool, validateBaseURL, validateDownloadUrl, validateTypes, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
2791
+ export { type Arrayable, type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type DynamicTool, EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, TRANSCRIPTION_STREAM_AUDIO_DONE_FRAME_TYPE as EXPERIMENTAL_TRANSCRIPTION_STREAM_AUDIO_DONE_FRAME_TYPE, TRANSCRIPTION_STREAM_START_FRAME_TYPE as EXPERIMENTAL_TRANSCRIPTION_STREAM_START_FRAME_TYPE, type ExecutableTool, type SandboxProcess as Experimental_SandboxProcess, type SandboxSession as Experimental_SandboxSession, type ToolCallerDefinition as Experimental_ToolCallerDefinition, type ToolCallerTool as Experimental_ToolCallerTool, type TranscriptionStreamClientFrame as Experimental_TranscriptionStreamClientFrame, type TranscriptionStreamStartFrame as Experimental_TranscriptionStreamStartFrame, type FetchFunction, type FileData, type FileDataData, type FileDataReference, type FileDataText, type FileDataUrl, type FilePart, type FlexibleSchema, type FunctionTool, type HasRequiredKey, type IdGenerator, type ImagePart, type InferSchema, type InferToolContext, type InferToolInput, type InferToolOutput, type InferToolSetContext, type LazySchema, type MaybePromiseLike, type ModelMessage, type MultipartStreamPart, type ParseResult, type ProviderDefinedTool, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderExecutedTool, type ProviderExecutedToolFactory, type ProviderOptions, type ProviderReference, type ProviderStreamError, type ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type RetryDelayProvider, type RetryErrorFactory, type RetryErrorReason, type RetryFunction, type Schema, SerializationError, type ShouldRetryFunction, type StreamingToolCallDelta, StreamingToolCallTracker, type StreamingToolCallTrackerOptions, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type ToolSet, type UserContent, type UserModelMessage, VERSION, type ValidationResult, type WebSocketConnection, type WebSocketConstructor, type WebSocketLike, asArray, asSchema, cancelResponseBody, combineHeaders, connectToWebSocket, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertInlineFileDataToUint8Array, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createBinaryStreamResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createNullLanguageModelUsage, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createProviderStreamError, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, deleteFromApi, detectMediaType, downloadBlob, dynamicTool, executeTool, getToolCaller as experimental_getToolCaller, parseTranscriptionStreamClientFrame as experimental_parseTranscriptionStreamClientFrame, parseTranscriptionStreamPart as experimental_parseTranscriptionStreamPart, serializeTranscriptionStreamPart as experimental_serializeTranscriptionStreamPart, toolCaller as experimental_toolCaller, extractLines, extractResponseHeaders, fetchWithValidatedRedirects, filterNullable, generateId, getFromApi, getRuntimeEnvironmentUserAgent, getTopLevelMediaType, getWebSocketConstructor, injectJsonInstructionIntoMessages, isAbortError, isBrowserRuntime, isBuffer, isCustomReasoning, isExecutableTool, isFullMediaType, isNonNullable, isParsableJson, isProviderReference, isProviderStreamError, isRecord, isSameOrigin, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, mediaTypeToExtension, normalizeBatchRequestCounts, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postMultipartStreamToApi, postToApi, readResponseWithSizeLimit, readWebSocketMessageText, removeUndefinedEntries, resolve, resolveFullMediaType, resolveProviderReference, retryWithExponentialBackoff, safeParseJSON, safeValidateTypes, secureJsonParse, serializeModelOptions, stripFileExtension, toWebSocketUrl, tool, validateBaseURL, validateDownloadUrl, validateTypes, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
@@ -163,6 +163,9 @@ export interface HookOptions {
163
163
  /**
164
164
  * Additional user-defined data to include with the hook payload.
165
165
  *
166
+ * Read it back outside the workflow with `getHookByToken()`, where
167
+ * `hook.metadata` is a Promise: `await hook.metadata`.
168
+ *
166
169
  * @example
167
170
  *
168
171
  * ```ts
@@ -1,2 +1,2 @@
1
- import"../../_chunks/workflow/dist-veFIAdWV.js";import{$n as e,Ar as t,F as n,Mr as r,N as i,T as a,X as o,Y as s,br as c,cr as l,dr as u,hr as d,jr as f,mr as p,pr as m,t as h,vr as g,xr as _,yr as v}from"../../_chunks/workflow/attribute-changes-DpruylJZ.js";import{i as y,u as b}from"../../_chunks/workflow/dist-BIO9Inoc.js";import{n as x}from"../../_chunks/workflow/resume-hook-DWDi_wCN.js";import{t as S}from"../../_chunks/workflow/sleep-BKxoNDRv.js";function C(e){f(`createHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-hook`,C)}function w(e){f(`createWebhook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-webhook`,w)}function T({schema:e}={}){function t(e){f(`defineHook().create()`,`https://workflow-sdk.dev/docs/api-reference/workflow/define-hook`,t)}return{create:t,async resume(t,n){if(!e?.[`~standard`])return await x(t,n);let r=e[`~standard`].validate(n);if(r instanceof Promise&&(r=await r),r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>String(typeof e==`object`&&e?e.key:e)).join(`.`);return t?` at "${t}": ${e.message}`:` ${e.message}`});throw Error(`Hook payload did not match the defined schema:\n${e.join(`
2
- `)}`)}return await x(t,r.value)}}}async function E(e,t={}){let n=o.getStore(),r=n?.workflowMetadata?.workflowRunId;if(!r)throw new y(`setAttributes() must be called from a 'use workflow' or 'use step' function. Calling it from plain host code is not supported.`);let i=h(e,t);if(i.length!==0){if(n.runReadyBarrier)try{await n.runReadyBarrier}catch{}await(await u()).events.create(r,{eventType:`attr_set`,specVersion:7,eventData:{changes:i,writer:{type:`step`,stepId:n.stepMetadata.stepId,attempt:n.stepMetadata.attempt},...t.allowReservedAttributes===!0?{allowReservedAttributes:!0}:{}}})}}function D(){let e=o.getStore();return e||t(`getStepMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-step-metadata`,D),e.stepMetadata}function O(){let e=o.getStore();return e||r(`getWorkflowMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-workflow-metadata`,O),e.workflowMetadata}function k(t={}){let u=o.getStore();u||r(`getWritable()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-writable`,k);let{namespace:f}=t,h=u.workflowMetadata.workflowRunId,y=s(h,f);u.writables??=new Map;let b=u.writables,x=b.get(y);if(x)return x.writable;let S=n(i(globalThis,u.ops,h,u.encryptionKey,!0,u.runReadyBarrier),u.encryptionKey),C=new a(h,y,u.runReadyBarrier),w=m();return u.ops.push(w.promise),p(S.readable,C,w).catch(()=>{}),d(S.writable,w),Object.defineProperty(S.writable,g,{value:y,writable:!1}),Object.defineProperty(S.writable,_,{value:h,writable:!1}),u.workflowDeploymentId&&Object.defineProperty(S.writable,v,{value:u.workflowDeploymentId,writable:!1}),e(u.encryptionKey)&&Object.defineProperty(S.writable,c,{value:l(u.encryptionKey.keyPair.publicKey),writable:!1}),b.set(y,{writable:S.writable,state:w}),S.writable}export{y as FatalError,b as RetryableError,C as createHook,w as createWebhook,T as defineHook,D as getStepMetadata,O as getWorkflowMetadata,k as getWritable,E as setAttributes,S as sleep};
1
+ import"../../_chunks/workflow/dist-DDeH-1ER.js";import{$ as e,Cr as t,Fr as n,L as r,Nr as i,P as a,Pr as o,Q as s,Sr as c,T as l,_r as u,dr as d,gr as f,mr as p,nr as m,t as h,vr as g,wr as _,xr as v}from"../../_chunks/workflow/attribute-changes-C6H-fRVP.js";import{i as y,u as b}from"../../_chunks/workflow/dist-xTushGCp.js";import{n as x}from"../../_chunks/workflow/resume-hook-BRDLAb67.js";import{t as S}from"../../_chunks/workflow/sleep-6cG0F99-.js";function C(e){o(`createHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-hook`,C)}function w(e){o(`createWebhook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-webhook`,w)}function T({schema:e}={}){function t(e){o(`defineHook().create()`,`https://workflow-sdk.dev/docs/api-reference/workflow/define-hook`,t)}return{create:t,async resume(t,n){if(!e?.[`~standard`])return await x(t,n);let r=e[`~standard`].validate(n);if(r instanceof Promise&&(r=await r),r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>String(typeof e==`object`&&e?e.key:e)).join(`.`);return t?` at "${t}": ${e.message}`:` ${e.message}`});throw Error(`Hook payload did not match the defined schema:\n${e.join(`
2
+ `)}`)}return await x(t,r.value)}}}async function E(t,n={}){let r=e.getStore(),i=r?.workflowMetadata?.workflowRunId;if(!i)throw new y(`setAttributes() must be called from a 'use workflow' or 'use step' function. Calling it from plain host code is not supported.`);let a=h(t,n);if(a.length!==0){if(r.runReadyBarrier)try{await r.runReadyBarrier}catch{}await(await p()).events.create(i,{eventType:`attr_set`,specVersion:7,eventData:{changes:a,writer:{type:`step`,stepId:r.stepMetadata.stepId,attempt:r.stepMetadata.attempt},...n.allowReservedAttributes===!0?{allowReservedAttributes:!0}:{}}})}}function D(){let t=e.getStore();return t||i(`getStepMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-step-metadata`,D),t.stepMetadata}function O(){let t=e.getStore();return t||n(`getWorkflowMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-workflow-metadata`,O),t.workflowMetadata}function k(i={}){let o=e.getStore();o||n(`getWritable()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-writable`,k);let{namespace:p}=i,h=o.workflowMetadata.workflowRunId,y=s(h,p);o.writables??=new Map;let b=o.writables,x=b.get(y);if(x)return x.writable;let S=r(a(globalThis,o.ops,h,o.encryptionKey,!0,o.runReadyBarrier),o.encryptionKey),C=new l(h,y,o.runReadyBarrier),w=f();return o.ops.push(w.promise),u(S.readable,C,w).catch(()=>{}),g(S.writable,w),Object.defineProperty(S.writable,v,{value:y,writable:!1}),Object.defineProperty(S.writable,_,{value:h,writable:!1}),o.workflowDeploymentId&&Object.defineProperty(S.writable,c,{value:o.workflowDeploymentId,writable:!1}),m(o.encryptionKey)&&Object.defineProperty(S.writable,t,{value:d(o.encryptionKey.keyPair.publicKey),writable:!1}),b.set(y,{writable:S.writable,state:w}),S.writable}export{y as FatalError,b as RetryableError,C as createHook,w as createWebhook,T as defineHook,D as getStepMetadata,O as getWorkflowMetadata,k as getWritable,E as setAttributes,S as sleep};
@@ -1 +1 @@
1
- import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"../../_chunks/workflow/private-aXEeo0fU.js";export{s as awaitEarlierDeliveries,r as getStepFunction,a as hasParkedCommittedDelivery,n as isDeliveryIdle,e as registerDeliveryBarrier,i as registerStepFunction,o as scheduleWhenIdle,t as scheduleWorkflowSuspension};
1
+ import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"../../_chunks/workflow/private-CFJkQA7R.js";export{s as awaitEarlierDeliveries,r as getStepFunction,a as hasParkedCommittedDelivery,n as isDeliveryIdle,e as registerDeliveryBarrier,i as registerStepFunction,o as scheduleWhenIdle,t as scheduleWorkflowSuspension};
@@ -1,9 +1,60 @@
1
- import { type Hook } from '#compiled/@workflow/world/index.js';
1
+ import { type Hook as WorldHook } from '#compiled/@workflow/world/index.js';
2
2
  import { type PayloadKey } from '../serialization.js';
3
3
  /**
4
- * Get the hook by token to find the associated workflow run,
5
- * and hydrate the `metadata` property if it was set from within
6
- * the workflow run.
4
+ * A hook record with its serialized `metadata` omitted: everything a resume
5
+ * actually reads. Resuming never looks at metadata, so the resume path accepts
6
+ * both a raw {@link WorldHook} straight out of a World and a {@link Hook}
7
+ * whose `metadata` is a Promise.
8
+ */
9
+ type ResumableHook = Omit<WorldHook, 'metadata'>;
10
+ /**
11
+ * A hook as returned by {@link getHookByToken} and {@link resumeHook}: the
12
+ * World's {@link WorldHook} record with its user-defined `metadata` hydrated
13
+ * lazily.
14
+ *
15
+ * `metadata` is a getter that returns a Promise — the same shape as
16
+ * `Run.returnValue` — so looking a hook up by token costs exactly one read.
17
+ * Hydrating metadata is a decrypting READ that needs the owning run's payload
18
+ * keys, and resolving those can cost a run fetch plus a `run-key` API round
19
+ * trip (~350ms). Deferring that to first access keeps the lookup fast for the
20
+ * many callers that only need `runId`/`token` — most importantly hook
21
+ * resumption, which never reads metadata at all.
22
+ *
23
+ * The promise is memoized: hydration (and the key resolution behind it) runs at
24
+ * most once per hook object. Awaiting it on a hook that stored no metadata
25
+ * resolves `undefined` and performs no I/O.
26
+ *
27
+ * Like `Run.returnValue`, the accessor is non-enumerable, so it is absent from
28
+ * `{ ...hook }` and `JSON.stringify(hook)` — read it explicitly and include the
29
+ * awaited value if you need to forward it.
30
+ *
31
+ * @example
32
+ *
33
+ * ```ts
34
+ * const hook = await getHookByToken(token);
35
+ * console.log(hook.runId); // no metadata work
36
+ * const metadata = (await hook.metadata) as { allowedUserId?: string } | undefined;
37
+ * ```
38
+ */
39
+ export interface Hook extends ResumableHook {
40
+ /**
41
+ * The hook's user-defined metadata, hydrated on first access and memoized.
42
+ * Resolves `undefined` when the hook carries no metadata.
43
+ */
44
+ readonly metadata: Promise<unknown>;
45
+ }
46
+ /**
47
+ * Get the hook by token to find the associated workflow run.
48
+ *
49
+ * This is a single read. The returned hook's `metadata` is a getter that
50
+ * resolves a Promise (see {@link Hook}), so the run fetch and
51
+ * `run-key` round trip that hydrating it can require are only paid by callers
52
+ * that actually await it:
53
+ *
54
+ * ```ts
55
+ * const hook = await getHookByToken(token);
56
+ * const metadata = await hook.metadata;
57
+ * ```
7
58
  *
8
59
  * A Hook kept by minimum retention remains available here after its run ends,
9
60
  * but cannot be resumed.
@@ -12,8 +63,8 @@ import { type PayloadKey } from '../serialization.js';
12
63
  */
13
64
  export declare function getHookByToken(token: string): Promise<Hook>;
14
65
  /**
15
- * The result of {@link resumeHook}: a {@link Hook} augmented with an optional
16
- * resilience signal.
66
+ * The result of {@link resumeHook}: a {@link Hook} augmented
67
+ * with an optional resilience signal.
17
68
  *
18
69
  * `resilientResume` is retained for source compatibility and is never set.
19
70
  * `resumeHook()` now requires the durable `hook_received` write and workflow
@@ -68,7 +119,7 @@ export type ResumedHook = Hook & {
68
119
  * }
69
120
  * ```
70
121
  */
71
- export declare function resumeHook<T = any>(tokenOrHook: string | Hook, payload: T, encryptionKeyOverride?: PayloadKey): Promise<ResumedHook>;
122
+ export declare function resumeHook<T = any>(tokenOrHook: string | ResumableHook, payload: T, encryptionKeyOverride?: PayloadKey): Promise<ResumedHook>;
72
123
  /**
73
124
  * Resumes a webhook by sending a {@link https://developer.mozilla.org/en-US/docs/Web/API/Request | Request}
74
125
  * object to a hook identified by its token.
@@ -105,4 +156,5 @@ export declare function resumeHook<T = any>(tokenOrHook: string | Hook, payload:
105
156
  * ```
106
157
  */
107
158
  export declare function resumeWebhook(token: string, request: Request): Promise<Response>;
159
+ export {};
108
160
  //# sourceMappingURL=resume-hook.d.ts.map
@@ -61,6 +61,32 @@ export interface WorkflowReadableStreamOptions {
61
61
  */
62
62
  global?: Record<string, any>;
63
63
  }
64
+ /**
65
+ * Options for configuring a writable onto a workflow run's stream.
66
+ */
67
+ export interface WorkflowRunWritableStreamOptions {
68
+ /**
69
+ * An optional namespace to distinguish between multiple streams associated
70
+ * with the same workflow run.
71
+ */
72
+ namespace?: string;
73
+ /**
74
+ * Any asynchronous operations to complete before pausing or terminating the
75
+ * execution environment
76
+ * (i.e. using [`waitUntil()`](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil) or similar).
77
+ *
78
+ * Writes are acknowledged on buffer entry, so a caller that needs them
79
+ * durable before the environment goes away should pass an array here and
80
+ * await it after releasing the writer lock.
81
+ */
82
+ ops?: Promise<any>[];
83
+ /**
84
+ * The global object to use for reducing types from the global scope.
85
+ *
86
+ * Defaults to {@link [`globalThis`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/globalThis)}.
87
+ */
88
+ global?: Record<string, any>;
89
+ }
64
90
  /**
65
91
  * A handler class for a workflow run.
66
92
  */
@@ -145,6 +171,22 @@ export declare class Run<TResult> {
145
171
  * @returns A `WorkflowReadableStream` for the workflow run.
146
172
  */
147
173
  getReadable<R = any>(options?: WorkflowReadableStreamOptions): WorkflowReadableStream<R>;
174
+ /** The writable stream of the workflow run. */
175
+ get writable(): WritableStream;
176
+ /**
177
+ * Returns a writable that appends to this run's stream.
178
+ *
179
+ * Initialization is deferred until the first write. The run must already
180
+ * exist. The writable may be forwarded through `start()` and into steps, but
181
+ * grants no read access or additional authorization.
182
+ *
183
+ * @remarks
184
+ * `writer.close()` closes the shared stream. Contributors should call
185
+ * `releaseLock()`, which also drains pending writes.
186
+ *
187
+ * @param options - The writable stream options.
188
+ */
189
+ getWritable<W = any>(options?: WorkflowRunWritableStreamOptions): WritableStream<W>;
148
190
  }
149
191
  /**
150
192
  * Retrieves a `Run` object for a given run ID.
@@ -1,4 +1,4 @@
1
- import type { World } from '#compiled/@workflow/world/index.js';
1
+ import type { RunRetention, World } from '#compiled/@workflow/world/index.js';
2
2
  import { Run } from './run.js';
3
3
  /**
4
4
  * Reset the `deploymentId: 'latest'` no-op warn-once guard. Test-only,
@@ -48,6 +48,36 @@ export interface StartOptionsBase {
48
48
  * the `setAttributes` option of the same name.
49
49
  */
50
50
  allowReservedAttributes?: boolean;
51
+ /**
52
+ * Set a preference for data retention after run completion.
53
+ *
54
+ * **Experimental.** Both the unit and the set of accepted values are expected
55
+ * to change.
56
+ *
57
+ * Worlds control the retention of user data (event payloads and stream
58
+ * chunks), the event log, and any analytics data. Options are:
59
+ * - `'default'`: same as omission, the World will decide. On Vercel, this
60
+ * is based on your team's plan.
61
+ * - `0`: data is deleted as soon as your run completes or fails. On
62
+ * Vercel, user data is deleted, but metadata may persist for your plan's
63
+ * default retention period.
64
+ *
65
+ * The value is a duration, with zero being the only valid option currently.
66
+ *
67
+ * **Known limitation at `0`.** The purge races your own read of the run's
68
+ * result and generally wins, so `await run.returnValue` on a
69
+ * `experimental_retention: 0` run usually throws `RunExpiredError` rather
70
+ * than resolving. If you need the result, return it through a channel you
71
+ * control, e.g. a step that writes it to external storage.
72
+ *
73
+ * Recorded on the run as the reserved `$retention` attribute, so it
74
+ * requires a World implementing spec version 4 or later. `'default'` is
75
+ * not written at all, keeping it exactly equivalent to omitting the
76
+ * option. Retention is enforced by the World: the first-party Worlds
77
+ * (Vercel, Local, Postgres) implement it, and a World that does not
78
+ * recognize the value keeps the data.
79
+ */
80
+ experimental_retention?: RunRetention;
51
81
  /**
52
82
  * The ID of an existing run this run is being replayed from, if any.
53
83
  *