eve 0.23.0 → 0.24.1
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.
- package/CHANGELOG.md +22 -0
- package/dist/src/channel/types.d.ts +1 -1
- package/dist/src/cli/run.d.ts +2 -2
- package/dist/src/cli/run.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +11 -11
- package/dist/src/compiled/@ai-sdk/anthropic/index.d.ts +1 -1
- package/dist/src/compiled/@ai-sdk/anthropic/index.js +2 -2
- package/dist/src/compiled/@ai-sdk/google/index.d.ts +7 -0
- package/dist/src/compiled/@ai-sdk/google/index.js +6 -6
- package/dist/src/compiled/@ai-sdk/mcp/index.d.ts +42 -1
- package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/openai/index.d.ts +34 -6
- package/dist/src/compiled/@ai-sdk/openai/index.js +2 -2
- package/dist/src/compiled/@ai-sdk/otel/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/provider/index.d.ts +245 -3
- package/dist/src/compiled/@ai-sdk/provider-utils/index.d.ts +273 -15
- package/dist/src/compiled/@workflow/core/index.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/start.d.ts +12 -0
- package/dist/src/compiled/@workflow/core/runtime.js +1 -1
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/world/analytics.d.ts +56 -21
- package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +46 -0
- package/dist/src/compiled/@workflow/world/queue.d.ts +12 -0
- package/dist/src/compiled/@workflow/world-local/index.js +3 -3
- package/dist/src/compiled/@workflow/world-vercel/index.js +16 -16
- package/dist/src/compiled/_chunks/workflow/attribute-changes-MGTOG_uX.js +20 -0
- package/dist/src/compiled/_chunks/workflow/{dist-CQenixFf.js → dist-Blxnyb7-.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/dist-zLevmMyU.js +77 -0
- package/dist/src/compiled/_chunks/workflow/{resume-hook-BH01MfRF.js → resume-hook-DHP5ql3-.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/run-D8hv1ptT.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{sleep-BkAHCD_s.js → sleep-uA9pS-PT.js} +1 -1
- package/dist/src/compiler/artifacts.d.ts +7 -6
- package/dist/src/compiler/artifacts.js +1 -1
- package/dist/src/compiler/compile-agent.d.ts +15 -2
- package/dist/src/compiler/compile-agent.js +3 -3
- package/dist/src/compiler/manifest.d.ts +12 -6
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-extension.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +2 -2
- package/dist/src/compiler/normalize-tool.d.ts +2 -1
- package/dist/src/compiler/normalize-tool.js +1 -1
- package/dist/src/context/build-base-tool-context.d.ts +5 -1
- package/dist/src/context/build-base-tool-context.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/node-step.d.ts +2 -3
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/run-session-limits.d.ts +0 -9
- package/dist/src/execution/run-session-limits.js +1 -1
- package/dist/src/execution/sandbox/prewarm.d.ts +1 -0
- package/dist/src/execution/sandbox/prewarm.js +1 -1
- package/dist/src/execution/subagent-tool.js +1 -1
- package/dist/src/execution/tool-auth.js +1 -1
- package/dist/src/harness/instrumentation-runtime-context.d.ts +1 -1
- package/dist/src/harness/tool-loop.js +3 -1
- package/dist/src/harness/types.d.ts +5 -7
- package/dist/src/harness/workflow-subagent-limit.d.ts +2 -2
- package/dist/src/internal/application/build-workspace.d.ts +36 -0
- package/dist/src/internal/application/build-workspace.js +1 -0
- package/dist/src/internal/application/compiled-artifacts.d.ts +12 -1
- package/dist/src/internal/application/compiled-artifacts.js +5 -4
- package/dist/src/internal/application/output-publication-artifacts.d.ts +7 -0
- package/dist/src/internal/application/output-publication-artifacts.js +1 -0
- package/dist/src/internal/application/output-publication-journal.d.ts +30 -0
- package/dist/src/internal/application/output-publication-journal.js +1 -0
- package/dist/src/internal/application/output-publication-lock.d.ts +10 -0
- package/dist/src/internal/application/output-publication-lock.js +1 -0
- package/dist/src/internal/application/output-publication.d.ts +33 -0
- package/dist/src/internal/application/output-publication.js +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/production-compiler-artifacts.d.ts +4 -0
- package/dist/src/internal/application/production-compiler-artifacts.js +1 -0
- package/dist/src/internal/application/tsconfig-dependencies.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/authored-definition/schema-backed.d.ts +3 -2
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/authored-directive-prologue.d.ts +4 -0
- package/dist/src/internal/authored-directive-prologue.js +1 -0
- package/dist/src/internal/authored-module-loader.d.ts +15 -5
- package/dist/src/internal/authored-module-loader.js +4 -2
- package/dist/src/internal/authored-module-map-loader.js +1 -1
- package/dist/src/internal/authored-module.d.ts +4 -0
- package/dist/src/internal/authored-module.js +1 -1
- package/dist/src/internal/authored-package-boundary.d.ts +25 -0
- package/dist/src/internal/authored-package-boundary.js +1 -0
- package/dist/src/internal/authored-package-tsconfig-paths.js +1 -1
- package/dist/src/internal/bundler/nitro-node-file-trace.d.ts +10 -0
- package/dist/src/internal/bundler/nitro-node-file-trace.js +1 -0
- package/dist/src/internal/materialize-authored-external-dependencies.d.ts +10 -0
- package/dist/src/internal/materialize-authored-external-dependencies.js +2 -0
- package/dist/src/internal/materialized-authored-modules.d.ts +15 -0
- package/dist/src/internal/materialized-authored-modules.js +1 -0
- package/dist/src/internal/nitro/dev-runtime-artifacts.d.ts +1 -9
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/development-generation.d.ts +12 -0
- package/dist/src/internal/nitro/development-generation.js +1 -0
- package/dist/src/internal/nitro/host/artifacts-config.d.ts +9 -11
- package/dist/src/internal/nitro/host/artifacts-config.js +1 -1
- package/dist/src/internal/nitro/host/build-application.d.ts +2 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.d.ts +1 -7
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
- package/dist/src/internal/nitro/host/channel-routes.d.ts +3 -3
- package/dist/src/internal/nitro/host/configure-nitro-routes.d.ts +9 -5
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +3 -3
- package/dist/src/internal/nitro/host/create-application-nitro.d.ts +18 -10
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dispatch-schedule-in-dev.d.ts +6 -1
- package/dist/src/internal/nitro/host/dispatch-schedule-in-dev.js +1 -1
- package/dist/src/internal/nitro/host/prepare-application-host.d.ts +13 -5
- package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
- package/dist/src/internal/nitro/host/schedule-task-routes.d.ts +3 -3
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/types.d.ts +4 -0
- package/dist/src/internal/nitro/host/vercel-build-prewarm.d.ts +2 -9
- package/dist/src/internal/nitro/host/vercel-build-prewarm.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/load-agent-info-data.d.ts +3 -6
- package/dist/src/internal/nitro/routes/agent-info/load-agent-info-data.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/dev-schedule-dispatch.d.ts +2 -3
- package/dist/src/internal/nitro/routes/dev-schedule-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/info.d.ts +1 -6
- package/dist/src/internal/nitro/routes/info.js +1 -1
- package/dist/src/internal/nitro/routes/runtime-artifacts.d.ts +9 -5
- package/dist/src/internal/nitro/routes/runtime-artifacts.js +1 -1
- package/dist/src/internal/workflow-bundle/build-queue.d.ts +1 -0
- package/dist/src/internal/workflow-bundle/build-queue.js +1 -0
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +0 -1
- package/dist/src/internal/workflow-bundle/builder-support.js +2 -2
- package/dist/src/internal/workflow-bundle/builder.js +2 -2
- package/dist/src/internal/workflow-bundle/nitro-step-entry.d.ts +1 -0
- package/dist/src/internal/workflow-bundle/nitro-step-entry.js +2 -2
- package/dist/src/public/channels/teams/api.d.ts +8 -0
- package/dist/src/public/channels/teams/api.js +2 -2
- package/dist/src/public/channels/teams/defaults.d.ts +2 -2
- package/dist/src/public/channels/teams/defaults.js +1 -1
- package/dist/src/public/channels/teams/hitl.d.ts +4 -0
- package/dist/src/public/channels/teams/hitl.js +1 -1
- package/dist/src/public/channels/teams/index.d.ts +1 -1
- package/dist/src/public/channels/teams/teamsChannel.d.ts +6 -0
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/definitions/tool.d.ts +40 -24
- package/dist/src/public/definitions/tool.js +1 -1
- package/dist/src/public/instrumentation/index.d.ts +3 -3
- package/dist/src/public/tools/index.d.ts +1 -1
- package/dist/src/public/tools/index.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/types.d.ts +6 -6
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/update/channels.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +0 -16
- package/dist/src/shared/atomic-write-file.d.ts +11 -0
- package/dist/src/shared/atomic-write-file.js +1 -0
- package/dist/src/shared/dynamic-tool-definition.d.ts +2 -0
- package/dist/src/shared/guards.d.ts +7 -0
- package/dist/src/shared/guards.js +1 -1
- package/dist/src/shared/path-exists.d.ts +9 -0
- package/dist/src/shared/path-exists.js +1 -0
- package/docs/agent-config.md +8 -8
- package/docs/channels/teams.mdx +5 -1
- package/docs/concepts/default-harness.md +5 -3
- package/docs/guides/deployment.md +3 -3
- package/docs/guides/dynamic-workflows.md +9 -10
- package/docs/reference/cli.md +4 -2
- package/docs/reference/typescript-api.md +27 -27
- package/docs/subagents.mdx +1 -1
- package/docs/tools/overview.mdx +1 -0
- package/package.json +14 -14
- package/dist/src/compiled/_chunks/workflow/attribute-changes-Dmf_myUv.js +0 -20
- package/dist/src/compiled/_chunks/workflow/dist-D7CzPkf8.js +0 -77
- package/dist/src/compiled/_chunks/workflow/run-CL3mguvM.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SharedV4FileDataUrl, SharedV4FileDataReference, SharedV4FileDataText, SharedV4ProviderOptions, SharedV4ProviderReference, JSONValue, ImageModelV4File, LanguageModelV4FunctionTool, LanguageModelV4ProviderTool, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, APICallError, LanguageModelV4Prompt, LanguageModelV4CallOptions, SharedV4Warning, JSONObject, LanguageModelV4FilePart, LanguageModelV4StreamPart, SharedV4ProviderMetadata, TypeValidationContext } from '#compiled/@ai-sdk/provider/index.js';
|
|
1
|
+
import { SharedV4FileDataUrl, SharedV4FileDataReference, SharedV4FileDataText, SharedV4ProviderOptions, SharedV4ProviderReference, JSONValue, ImageModelV4File, LanguageModelV4FunctionTool, LanguageModelV4ProviderTool, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, APICallError, LanguageModelV4Prompt, LanguageModelV4CallOptions, SharedV4Warning, 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';
|
|
@@ -19,6 +19,77 @@ declare function asArray<T>(value: Arrayable<T>): T[];
|
|
|
19
19
|
|
|
20
20
|
declare function combineHeaders(...headers: Array<Record<string, string | undefined> | undefined>): Record<string, string | undefined>;
|
|
21
21
|
|
|
22
|
+
type WebSocketLike = {
|
|
23
|
+
readyState: number;
|
|
24
|
+
/** Bytes queued by `send` but not yet transmitted (native + `ws`). */
|
|
25
|
+
readonly bufferedAmount?: number;
|
|
26
|
+
send(data: string | Uint8Array | ArrayBuffer): void;
|
|
27
|
+
close(code?: number, reason?: string): void;
|
|
28
|
+
onopen: ((event: unknown) => void) | null;
|
|
29
|
+
onmessage: ((event: {
|
|
30
|
+
data: unknown;
|
|
31
|
+
}) => void) | null;
|
|
32
|
+
onerror: ((event: unknown) => void) | null;
|
|
33
|
+
onclose: ((event: unknown) => void) | null;
|
|
34
|
+
};
|
|
35
|
+
type WebSocketConstructor = new (url: string | URL, protocols?: string | string[], options?: {
|
|
36
|
+
headers?: Record<string, string | undefined>;
|
|
37
|
+
}) => WebSocketLike;
|
|
38
|
+
declare function getWebSocketConstructor(webSocket: WebSocketConstructor | undefined): WebSocketConstructor;
|
|
39
|
+
/**
|
|
40
|
+
* Converts an http(s) URL to the corresponding ws(s) URL.
|
|
41
|
+
*/
|
|
42
|
+
declare function toWebSocketUrl(url: string | URL): URL;
|
|
43
|
+
/**
|
|
44
|
+
* Reads WebSocket message data as text, handling string, binary,
|
|
45
|
+
* and Blob payloads.
|
|
46
|
+
*/
|
|
47
|
+
declare function readWebSocketMessageText(data: unknown): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Waits until the socket's send buffer drains below `highWaterMark` bytes.
|
|
50
|
+
* No-op for implementations that do not expose `bufferedAmount`. There is no
|
|
51
|
+
* portable drain event, so this polls. Returns as soon as the socket is no
|
|
52
|
+
* longer open or the signal aborts — `bufferedAmount` never drains on a
|
|
53
|
+
* closed socket, so waiting on would poll forever.
|
|
54
|
+
*/
|
|
55
|
+
declare function waitForWebSocketBufferDrain(socket: WebSocketLike, { highWaterMark, pollIntervalMs, abortSignal, }?: {
|
|
56
|
+
highWaterMark?: number;
|
|
57
|
+
pollIntervalMs?: number;
|
|
58
|
+
abortSignal?: AbortSignal;
|
|
59
|
+
}): Promise<void>;
|
|
60
|
+
|
|
61
|
+
interface WebSocketConnection {
|
|
62
|
+
/** Undefined when the constructor threw or the signal was already aborted. */
|
|
63
|
+
socket: WebSocketLike | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Unregisters the abort listener and closes the socket. Never throws.
|
|
66
|
+
* Handlers stay attached; callers guard their own terminal state.
|
|
67
|
+
*/
|
|
68
|
+
close: (code?: number) => void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Opens a WebSocket for a provider model, owning the transport-generic layer
|
|
72
|
+
* (analogous to `postToApi` for HTTP): constructor resolution, header hygiene,
|
|
73
|
+
* abort wiring, and message decoding. Callers own the URL, the auth channel
|
|
74
|
+
* (subprotocols vs headers), and the wire protocol.
|
|
75
|
+
*/
|
|
76
|
+
declare function connectToWebSocket({ url, protocols, headers, webSocket, abortSignal, onOpen, onMessageText, onProcessingError, onSocketError, onClose, onAbort, }: {
|
|
77
|
+
url: string | URL;
|
|
78
|
+
protocols?: string | string[];
|
|
79
|
+
headers?: Record<string, string | undefined>;
|
|
80
|
+
webSocket?: WebSocketConstructor;
|
|
81
|
+
abortSignal?: AbortSignal;
|
|
82
|
+
onOpen?: (socket: WebSocketLike) => void;
|
|
83
|
+
/** One decoded message. Throws and rejections go to `onProcessingError`. */
|
|
84
|
+
onMessageText: (text: string) => void | PromiseLike<void>;
|
|
85
|
+
/** Constructor throws and message decoding/processing failures. */
|
|
86
|
+
onProcessingError: (error: unknown) => void;
|
|
87
|
+
onSocketError?: () => void;
|
|
88
|
+
onClose?: () => void;
|
|
89
|
+
/** Also called (without opening a socket) when the signal is already aborted. */
|
|
90
|
+
onAbort?: (reason: unknown) => void;
|
|
91
|
+
}): WebSocketConnection;
|
|
92
|
+
|
|
22
93
|
/**
|
|
23
94
|
* Converts an AsyncIterator to a ReadableStream.
|
|
24
95
|
*
|
|
@@ -739,33 +810,67 @@ declare class DownloadError extends AISDKError {
|
|
|
739
810
|
}
|
|
740
811
|
|
|
741
812
|
/**
|
|
742
|
-
*
|
|
813
|
+
* Fetch function type (standardizes the version of fetch used).
|
|
814
|
+
*/
|
|
815
|
+
type FetchFunction = typeof globalThis.fetch;
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Fetches a URL while enforcing the download guard on every hop.
|
|
743
819
|
*
|
|
744
820
|
* Redirects are followed manually (`redirect: 'manual'`) so each hop is
|
|
745
821
|
* validated with {@link validateDownloadUrl} *before* it is requested. Relying
|
|
746
822
|
* on the default `redirect: 'follow'` would issue the request to a redirect
|
|
747
823
|
* target (e.g. an internal address) before we ever see its URL, defeating the
|
|
748
|
-
*
|
|
824
|
+
* guard.
|
|
825
|
+
*
|
|
826
|
+
* Request headers are also protected: {@link sanitizeRequestHeaders} strips
|
|
827
|
+
* proxy/metadata/cookie/hop-by-hop headers before the first request, and all
|
|
828
|
+
* caller headers except `User-Agent` are dropped on a cross-origin redirect.
|
|
829
|
+
* The fetch spec only strips `Authorization` on cross-origin redirects because
|
|
830
|
+
* in a browser, CORS preflighting protects custom headers; there is no CORS on
|
|
831
|
+
* the server, so provider API keys carried in custom headers (e.g. `x-key`)
|
|
832
|
+
* must be dropped here as well.
|
|
749
833
|
*
|
|
750
834
|
* A `redirect: 'manual'` request yields an unreadable opaque response in the
|
|
751
835
|
* browser (and in other spec-compliant fetch implementations), so the redirect
|
|
752
836
|
* target cannot be validated here. In a real browser this is safe to follow
|
|
753
|
-
* natively because
|
|
754
|
-
* cannot reach a server's internal network or
|
|
755
|
-
* runtime we cannot validate the hop, so we fail
|
|
756
|
-
* blindly and bypass the
|
|
837
|
+
* natively because reaching an internal network is not possible (fetch is
|
|
838
|
+
* constrained by CORS and cannot reach a server's internal network or
|
|
839
|
+
* cloud-metadata). On any other runtime we cannot validate the hop, so we fail
|
|
840
|
+
* closed rather than follow it blindly and bypass the guard.
|
|
841
|
+
*
|
|
842
|
+
* A hop that is same-origin with `trustedOrigin` (the developer-configured
|
|
843
|
+
* provider endpoint) skips target validation: that origin is exactly what an
|
|
844
|
+
* unvalidated, config-derived request would fetch anyway, and validating it
|
|
845
|
+
* would break legitimate self-hosted / localhost deployments whose response
|
|
846
|
+
* URLs point back at the configured host. Hops on any other origin are always
|
|
847
|
+
* validated.
|
|
757
848
|
*
|
|
758
849
|
* The returned response is the final (non-redirect) response. The caller is
|
|
759
850
|
* responsible for checking `response.ok` and reading the body.
|
|
760
851
|
*
|
|
852
|
+
* Not solved here: this does string/literal checks only and does not resolve
|
|
853
|
+
* DNS, so a hostname that *resolves* to a private address, and DNS rebinding
|
|
854
|
+
* (the resolved IP flipping between validation and connect), are not blocked.
|
|
855
|
+
* Server deployments fetching untrusted URLs should constrain egress at the
|
|
856
|
+
* network layer or inject a Node `fetch` that pins the resolved IP at connect
|
|
857
|
+
* time — those need DNS/socket APIs not available on all target runtimes
|
|
858
|
+
* (edge, browser, Bun), so they are intentionally not built in.
|
|
859
|
+
*
|
|
761
860
|
* @throws DownloadError if a hop is unsafe, the redirect limit is exceeded, or
|
|
762
861
|
* a redirect cannot be validated on a non-browser runtime.
|
|
763
862
|
*/
|
|
764
|
-
declare function fetchWithValidatedRedirects({ url, headers, abortSignal, maxRedirects, }: {
|
|
863
|
+
declare function fetchWithValidatedRedirects({ url, headers, abortSignal, maxRedirects, fetch, trustedOrigin, }: {
|
|
765
864
|
url: string;
|
|
766
865
|
headers?: HeadersInit;
|
|
767
866
|
abortSignal?: AbortSignal;
|
|
768
867
|
maxRedirects?: number;
|
|
868
|
+
fetch?: FetchFunction;
|
|
869
|
+
/**
|
|
870
|
+
* A developer-configured origin (e.g. the provider's `baseURL`) whose hops
|
|
871
|
+
* skip target validation. Must never be derived from response data.
|
|
872
|
+
*/
|
|
873
|
+
trustedOrigin?: string;
|
|
769
874
|
}): Promise<Response>;
|
|
770
875
|
|
|
771
876
|
/**
|
|
@@ -793,11 +898,6 @@ declare function extractResponseHeaders(response: Response): {
|
|
|
793
898
|
[k: string]: string;
|
|
794
899
|
};
|
|
795
900
|
|
|
796
|
-
/**
|
|
797
|
-
* Fetch function type (standardizes the version of fetch used).
|
|
798
|
-
*/
|
|
799
|
-
type FetchFunction = typeof globalThis.fetch;
|
|
800
|
-
|
|
801
901
|
/**
|
|
802
902
|
* Filters `null` and `undefined` values out of a list of values.
|
|
803
903
|
*
|
|
@@ -970,13 +1070,46 @@ declare const createJsonResponseHandler: <T>(responseSchema: FlexibleSchema<T>)
|
|
|
970
1070
|
declare const createBinaryResponseHandler: () => ResponseHandler<Uint8Array>;
|
|
971
1071
|
declare const createStatusCodeErrorResponseHandler: () => ResponseHandler<APICallError>;
|
|
972
1072
|
|
|
973
|
-
declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, }: {
|
|
1073
|
+
declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, validateUrl, credentialedOrigin, trustedOrigin, }: {
|
|
974
1074
|
url: string;
|
|
975
1075
|
headers?: Record<string, string | undefined>;
|
|
976
1076
|
failedResponseHandler: ResponseHandler<Error>;
|
|
977
1077
|
successfulResponseHandler: ResponseHandler<T>;
|
|
978
1078
|
abortSignal?: AbortSignal;
|
|
979
1079
|
fetch?: FetchFunction;
|
|
1080
|
+
/**
|
|
1081
|
+
* Set `true` when `url` is untrusted (e.g. taken from a provider response
|
|
1082
|
+
* body): it is routed through {@link fetchWithValidatedRedirects}, which
|
|
1083
|
+
* rejects private/loopback/link-local targets and re-validates redirect
|
|
1084
|
+
* hops; blocked URLs throw `DownloadError`. Set `false` only for URLs built
|
|
1085
|
+
* from a developer-configured endpoint.
|
|
1086
|
+
*
|
|
1087
|
+
* Optional for backwards compatibility with existing callers; omitting it
|
|
1088
|
+
* behaves like `false` (no validation). Provider code in this repository
|
|
1089
|
+
* must always pass it explicitly so every call site makes a visible trust
|
|
1090
|
+
* decision — see `contributing/secure-url-handling.md`.
|
|
1091
|
+
*/
|
|
1092
|
+
validateUrl?: boolean;
|
|
1093
|
+
/**
|
|
1094
|
+
* When set, `headers` are sent only if `url` is same-origin with this origin
|
|
1095
|
+
* (the user-agent suffix is always kept). Pass the provider's configured
|
|
1096
|
+
* base URL alongside `validateUrl: true` so credentials never ride a request
|
|
1097
|
+
* to a response-supplied host on a different origin (e.g. a CDN). Redirects
|
|
1098
|
+
* that later cross origin drop all caller headers regardless (see
|
|
1099
|
+
* {@link fetchWithValidatedRedirects}).
|
|
1100
|
+
*/
|
|
1101
|
+
credentialedOrigin?: string;
|
|
1102
|
+
/**
|
|
1103
|
+
* A developer-configured origin (e.g. the provider's `baseURL`) that is
|
|
1104
|
+
* exempt from URL validation when `validateUrl` is `true`. A response URL
|
|
1105
|
+
* (or redirect hop) that is same-origin with it is fetched without target
|
|
1106
|
+
* validation — it points at exactly the host a config-derived
|
|
1107
|
+
* `validateUrl: false` request would fetch anyway, so blocking it would
|
|
1108
|
+
* only break legitimate self-hosted / localhost deployments whose response
|
|
1109
|
+
* URLs point back at the configured host. Hops on any other origin are
|
|
1110
|
+
* still validated. Must never be derived from response data.
|
|
1111
|
+
*/
|
|
1112
|
+
trustedOrigin?: string;
|
|
980
1113
|
}) => Promise<{
|
|
981
1114
|
value: T;
|
|
982
1115
|
rawValue?: unknown;
|
|
@@ -2024,6 +2157,31 @@ declare function resolveProviderReference({ reference, provider, }: {
|
|
|
2024
2157
|
provider: string;
|
|
2025
2158
|
}): string;
|
|
2026
2159
|
|
|
2160
|
+
type RetryFunction = <OUTPUT>(fn: () => PromiseLike<OUTPUT>) => PromiseLike<OUTPUT>;
|
|
2161
|
+
type RetryErrorReason = 'maxRetriesExceeded' | 'errorNotRetryable';
|
|
2162
|
+
type RetryErrorFactory = ({ message, reason, errors, }: {
|
|
2163
|
+
message: string;
|
|
2164
|
+
reason: RetryErrorReason;
|
|
2165
|
+
errors: Array<unknown>;
|
|
2166
|
+
}) => unknown;
|
|
2167
|
+
type RetryDelayProvider = ({ error, exponentialBackoffDelay, }: {
|
|
2168
|
+
error: unknown;
|
|
2169
|
+
exponentialBackoffDelay: number;
|
|
2170
|
+
}) => number;
|
|
2171
|
+
type ShouldRetryFunction = (error: unknown) => boolean | Promise<boolean>;
|
|
2172
|
+
/**
|
|
2173
|
+
* Retries a failed operation with exponential backoff.
|
|
2174
|
+
*/
|
|
2175
|
+
declare const retryWithExponentialBackoff: ({ maxRetries, initialDelayInMs, backoffFactor, abortSignal, shouldRetry, getDelayInMs, createRetryError, }: {
|
|
2176
|
+
maxRetries?: number;
|
|
2177
|
+
initialDelayInMs?: number;
|
|
2178
|
+
backoffFactor?: number;
|
|
2179
|
+
abortSignal?: AbortSignal;
|
|
2180
|
+
shouldRetry: ShouldRetryFunction;
|
|
2181
|
+
getDelayInMs?: RetryDelayProvider;
|
|
2182
|
+
createRetryError?: RetryErrorFactory;
|
|
2183
|
+
}) => RetryFunction;
|
|
2184
|
+
|
|
2027
2185
|
/**
|
|
2028
2186
|
* Serializes a model instance for workflow step boundaries.
|
|
2029
2187
|
* Returns the `modelId` plus the JSON-serializable config properties.
|
|
@@ -2054,6 +2212,8 @@ declare function serializeModelOptions<CONFIG extends {
|
|
|
2054
2212
|
config: JSONObject;
|
|
2055
2213
|
};
|
|
2056
2214
|
|
|
2215
|
+
declare function secureJsonParse(text: string): any;
|
|
2216
|
+
|
|
2057
2217
|
/**
|
|
2058
2218
|
* Minimal interface for a streaming tool call delta from an OpenAI-compatible API.
|
|
2059
2219
|
*/
|
|
@@ -2136,10 +2296,108 @@ declare class StreamingToolCallTracker<DELTA extends StreamingToolCallDelta = St
|
|
|
2136
2296
|
*/
|
|
2137
2297
|
declare function stripFileExtension(filename: string): string;
|
|
2138
2298
|
|
|
2299
|
+
/**
|
|
2300
|
+
* Experimental transcription-stream WebSocket envelope (v1): the standard
|
|
2301
|
+
* serialization of `TranscriptionModelV4.doStream` over a WebSocket. Clients
|
|
2302
|
+
* (e.g. the `@ai-sdk/gateway` provider) encode with this module and servers
|
|
2303
|
+
* (e.g. AI Gateway) decode with it, so the two sides cannot drift.
|
|
2304
|
+
*
|
|
2305
|
+
* Envelope rules:
|
|
2306
|
+
*
|
|
2307
|
+
* 1. The client sends exactly one `transcription-stream.start` TEXT frame
|
|
2308
|
+
* first.
|
|
2309
|
+
* 2. Audio rides BINARY frames containing raw bytes in the declared
|
|
2310
|
+
* `inputAudioFormat` (base64 string chunks are decoded before sending).
|
|
2311
|
+
* 3. The client signals end of audio with the
|
|
2312
|
+
* `transcription-stream.audio-done` TEXT frame; a plain close without it
|
|
2313
|
+
* is an abort.
|
|
2314
|
+
* 4. Every server→client TEXT frame is one JSON-serialized
|
|
2315
|
+
* `TranscriptionModelV4StreamPart` (flattened, no wrapper). Payloads must
|
|
2316
|
+
* be JSON-serializable. `Date` values (`response-metadata.timestamp`)
|
|
2317
|
+
* serialize to ISO 8601 strings and are revived by
|
|
2318
|
+
* `parseTranscriptionStreamPart`. `Error` payloads in `error` parts
|
|
2319
|
+
* serialize as `{ name, message }`.
|
|
2320
|
+
* 5. The server closes with code 1000 after the `finish` part; on failure it
|
|
2321
|
+
* sends an `error` part and closes non-1000. A close without a prior
|
|
2322
|
+
* `finish` is an error.
|
|
2323
|
+
* 6. Unknown frame/part types are ignored in both directions (forward
|
|
2324
|
+
* compatibility).
|
|
2325
|
+
* 7. Servers may enforce a maximum frame size (the AI Gateway rejects frames
|
|
2326
|
+
* over 256 KiB); clients should split audio into frames of at most
|
|
2327
|
+
* 64 KiB.
|
|
2328
|
+
* 8. Connection establishment (URL, auth) is transport-specific and out of
|
|
2329
|
+
* scope.
|
|
2330
|
+
*
|
|
2331
|
+
* The envelope validates frame shape only; server policy (accepted audio
|
|
2332
|
+
* formats, required `rate`, size limits) layers on top. Both parsers use
|
|
2333
|
+
* `secureJsonParse`, so frames carrying `__proto__` / `constructor.prototype`
|
|
2334
|
+
* keys are rejected (prototype-pollution protection) rather than parsed.
|
|
2335
|
+
*/
|
|
2336
|
+
/** Type of the first client TEXT frame. */
|
|
2337
|
+
declare const TRANSCRIPTION_STREAM_START_FRAME_TYPE = "transcription-stream.start";
|
|
2338
|
+
/** Type of the client TEXT frame that signals the end of the audio input. */
|
|
2339
|
+
declare const TRANSCRIPTION_STREAM_AUDIO_DONE_FRAME_TYPE = "transcription-stream.audio-done";
|
|
2340
|
+
/**
|
|
2341
|
+
* The client's session start frame. Optional keys are omitted when undefined.
|
|
2342
|
+
*/
|
|
2343
|
+
type TranscriptionStreamStartFrame = {
|
|
2344
|
+
type: typeof TRANSCRIPTION_STREAM_START_FRAME_TYPE;
|
|
2345
|
+
/** Audio format of the binary audio frames, e.g. `{ type: 'audio/pcm', rate: 16000 }`. */
|
|
2346
|
+
inputAudioFormat: {
|
|
2347
|
+
type: string;
|
|
2348
|
+
rate?: number;
|
|
2349
|
+
};
|
|
2350
|
+
/** Provider-specific options, passed through verbatim. */
|
|
2351
|
+
providerOptions?: Record<string, JSONObject>;
|
|
2352
|
+
/** When true, the server should include `raw` parts in the stream. */
|
|
2353
|
+
includeRawChunks?: boolean;
|
|
2354
|
+
};
|
|
2355
|
+
/** Server-side classification of a client TEXT frame. */
|
|
2356
|
+
type TranscriptionStreamClientFrame = {
|
|
2357
|
+
type: 'start';
|
|
2358
|
+
frame: TranscriptionStreamStartFrame;
|
|
2359
|
+
} | {
|
|
2360
|
+
type: 'audio-done';
|
|
2361
|
+
} | {
|
|
2362
|
+
/** Malformed JSON or a recognized frame with an invalid shape. */
|
|
2363
|
+
type: 'invalid';
|
|
2364
|
+
message: string;
|
|
2365
|
+
} | {
|
|
2366
|
+
/** Unrecognized frame type; ignore for forward compatibility. */
|
|
2367
|
+
type: 'unknown';
|
|
2368
|
+
};
|
|
2369
|
+
/**
|
|
2370
|
+
* Server-side: parse a client TEXT frame. Validates envelope shape only and
|
|
2371
|
+
* rejects prototype-pollution payloads (parsed with `secureJsonParse`). Never
|
|
2372
|
+
* throws.
|
|
2373
|
+
*/
|
|
2374
|
+
declare function parseTranscriptionStreamClientFrame(text: string): TranscriptionStreamClientFrame;
|
|
2375
|
+
/**
|
|
2376
|
+
* Server-side: serialize a transcription stream part as one TEXT frame.
|
|
2377
|
+
* `Error` payloads in `error` parts serialize as `{ name, message }` —
|
|
2378
|
+
* `Error` properties are non-enumerable, so a plain `JSON.stringify` would
|
|
2379
|
+
* serialize them to `{}` and lose the message end-to-end. Returns
|
|
2380
|
+
* `undefined` for payloads that are not JSON-serializable (envelope rule 4,
|
|
2381
|
+
* e.g. bigint or cyclic values); callers drop the frame.
|
|
2382
|
+
*/
|
|
2383
|
+
declare function serializeTranscriptionStreamPart(part: Experimental_TranscriptionModelV4StreamPart): string | undefined;
|
|
2384
|
+
/**
|
|
2385
|
+
* Client-side: parse a server TEXT frame into a transcription stream part.
|
|
2386
|
+
* Returns `undefined` for malformed or unsafe (prototype-polluting) JSON
|
|
2387
|
+
* (parsed with `secureJsonParse`), unknown part types, and known part types
|
|
2388
|
+
* whose required or optional fields are missing or mistyped (including
|
|
2389
|
+
* warning and segment elements) — downstream SDK code dereferences those
|
|
2390
|
+
* fields, so a drifted server must not crash or pollute the stream.
|
|
2391
|
+
* Revives `response-metadata.timestamp` to a `Date`.
|
|
2392
|
+
*/
|
|
2393
|
+
declare function parseTranscriptionStreamPart(text: string): Experimental_TranscriptionModelV4StreamPart | undefined;
|
|
2394
|
+
|
|
2139
2395
|
declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
|
2140
2396
|
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
|
2141
2397
|
declare function convertToBase64(value: string | Uint8Array): string;
|
|
2142
2398
|
|
|
2399
|
+
declare function validateBaseURL(baseURL: string | undefined): string | undefined;
|
|
2400
|
+
|
|
2143
2401
|
/**
|
|
2144
2402
|
* Validates that a URL is safe to download from, blocking private/internal addresses
|
|
2145
2403
|
* to prevent SSRF attacks.
|
|
@@ -2359,4 +2617,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
2359
2617
|
dynamic?: boolean;
|
|
2360
2618
|
}
|
|
2361
2619
|
|
|
2362
|
-
export { type Arrayable, type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type DynamicTool, type ExecutableTool, type SandboxProcess as Experimental_SandboxProcess, type SandboxSession as Experimental_SandboxSession, 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 ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, 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, asArray, asSchema, cancelResponseBody, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertInlineFileDataToUint8Array, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, detectMediaType, downloadBlob, dynamicTool, executeTool, extractLines, extractResponseHeaders, fetchWithValidatedRedirects, filterNullable, generateId, getFromApi, getRuntimeEnvironmentUserAgent, getTopLevelMediaType, injectJsonInstructionIntoMessages, isAbortError, isBrowserRuntime, isBuffer, isCustomReasoning, isExecutableTool, isFullMediaType, isNonNullable, isParsableJson, isProviderReference, isSameOrigin, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, serializeModelOptions, stripFileExtension, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
2620
|
+
export { type Arrayable, type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type DynamicTool, 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 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 ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type RetryDelayProvider, type RetryErrorFactory, type RetryErrorReason, type RetryFunction, type Schema, 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, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, detectMediaType, downloadBlob, dynamicTool, executeTool, parseTranscriptionStreamClientFrame as experimental_parseTranscriptionStreamClientFrame, parseTranscriptionStreamPart as experimental_parseTranscriptionStreamPart, serializeTranscriptionStreamPart as experimental_serializeTranscriptionStreamPart, extractLines, extractResponseHeaders, fetchWithValidatedRedirects, filterNullable, generateId, getFromApi, getRuntimeEnvironmentUserAgent, getTopLevelMediaType, getWebSocketConstructor, injectJsonInstructionIntoMessages, isAbortError, isBrowserRuntime, isBuffer, isCustomReasoning, isExecutableTool, isFullMediaType, isNonNullable, isParsableJson, isProviderReference, isSameOrigin, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, mediaTypeToExtension, 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 };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as e,i as t}from"../../_chunks/workflow/dist-DpDDcpTl.js";import{An as n,C as r,Cn as i,Dn as a,En as o,Mn as s,R as c,T as l,Tn as u,fn as d,h as f,jn as p,mn as m,pn as h,t as g,z as _}from"../../_chunks/workflow/attribute-changes-
|
|
1
|
+
import{c as e,i as t}from"../../_chunks/workflow/dist-DpDDcpTl.js";import{An as n,C as r,Cn as i,Dn as a,En as o,Mn as s,R as c,T as l,Tn as u,fn as d,h as f,jn as p,mn as m,pn as h,t as g,z as _}from"../../_chunks/workflow/attribute-changes-MGTOG_uX.js";import"../../_chunks/workflow/dist-Blxnyb7-.js";import{n as v}from"../../_chunks/workflow/resume-hook-DHP5ql3-.js";import{t as y}from"../../_chunks/workflow/sleep-uA9pS-PT.js";function b(e){p(`createHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-hook`,b)}function x(e){p(`createWebhook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-webhook`,x)}function S({schema:e}={}){function t(e){p(`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 v(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
2
|
`)}`)}return await v(t,r.value)}}}async function C(e,n={}){let r=_.getStore(),a=r?.workflowMetadata?.workflowRunId;if(!a)throw new t(`setAttributes() must be called from a 'use workflow' or 'use step' function. Calling it from plain host code is not supported.`);let o=g(e,n);if(o.length!==0){if(r.runReadyBarrier)try{await r.runReadyBarrier}catch{}await(await i()).events.create(a,{eventType:`attr_set`,specVersion:5,eventData:{changes:o,writer:{type:`step`,stepId:r.stepMetadata.stepId,attempt:r.stepMetadata.attempt},...n.allowReservedAttributes===!0?{allowReservedAttributes:!0}:{}}})}}const w=C;function T(){let e=_.getStore();return e||n(`getStepMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-step-metadata`,T),e.stepMetadata}function E(){let e=_.getStore();return e||s(`getWorkflowMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-workflow-metadata`,E),e.workflowMetadata}function D(e={}){let t=_.getStore();t||s(`getWritable()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-writable`,D);let{namespace:n}=e,i=t.workflowMetadata.workflowRunId,p=c(i,n),g=t.writables??=new Map,v=g.get(p);if(v)return v.writable;let y=l(r(globalThis,t.ops,i,t.encryptionKey,!0,t.runReadyBarrier),t.encryptionKey),b=new f(i,p,t.runReadyBarrier),x=u();return t.ops.push(x.promise),o(y.readable,b,x).catch(()=>{}),a(y.writable,x),Object.defineProperty(y.writable,d,{value:p,writable:!1}),Object.defineProperty(y.writable,m,{value:i,writable:!1}),t.workflowDeploymentId&&Object.defineProperty(y.writable,h,{value:t.workflowDeploymentId,writable:!1}),g.set(p,{writable:y.writable,state:x}),y.writable}export{t as FatalError,e as RetryableError,b as createHook,x as createWebhook,S as defineHook,w as experimental_setAttributes,T as getStepMetadata,E as getWorkflowMetadata,D as getWritable,C as setAttributes,y as sleep};
|
|
@@ -17,6 +17,18 @@ export interface StartOptionsBase {
|
|
|
17
17
|
* The spec version to use for the workflow run. Defaults to the latest version.
|
|
18
18
|
*/
|
|
19
19
|
specVersion?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Optional region identifier for the new run. Currently consumed only
|
|
22
|
+
* by `@workflow/world-vercel`, which embeds the region into the tagged
|
|
23
|
+
* run ID and routes the initial workflow message to the matching
|
|
24
|
+
* regional queue. When omitted, the world falls back to its own
|
|
25
|
+
* default (for `world-vercel`: the `VERCEL_REGION` environment
|
|
26
|
+
* variable, then the server-side default region `iad1` — a concrete,
|
|
27
|
+
* routable region is always chosen).
|
|
28
|
+
*
|
|
29
|
+
* Worlds without a regional dimension ignore this field.
|
|
30
|
+
*/
|
|
31
|
+
region?: string;
|
|
20
32
|
/**
|
|
21
33
|
* Plaintext attributes to seed on the run as it is created.
|
|
22
34
|
*
|