experimental-ash 0.18.3 → 0.20.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.
- package/CHANGELOG.md +35 -0
- package/dist/docs/internals/context.md +7 -0
- package/dist/docs/public/channels/README.md +5 -0
- package/dist/docs/public/channels/slack.md +58 -4
- package/dist/docs/public/hooks.md +4 -2
- package/dist/docs/public/sandbox.md +71 -49
- package/dist/docs/public/tools.md +55 -3
- package/dist/docs/public/typescript-api.md +6 -1
- package/dist/src/channel/adapter.js +12 -2
- package/dist/src/channel/routes.d.ts +9 -1
- package/dist/src/channel/send.js +3 -3
- package/dist/src/channel/types.d.ts +3 -1
- package/dist/src/chunks/{dev-authored-source-watcher-j7YWh2Gx.js → dev-authored-source-watcher-NA8BZIXr.js} +1 -1
- package/dist/src/chunks/host-DOH_6p0f.js +22 -0
- package/dist/src/chunks/{paths-Dwv0Eash.js → paths-CbL9m08U.js} +25 -25
- package/dist/src/chunks/{prewarm-CQYfka30.js → prewarm-Bz6Jr9J1.js} +1 -1
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/run.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +7 -7
- package/dist/src/compiled/@ai-sdk/anthropic/index.js +2 -2
- package/dist/src/compiled/@ai-sdk/anthropic/package.json +1 -1
- package/dist/src/compiled/@ai-sdk/google/index.js +6 -6
- package/dist/src/compiled/@ai-sdk/google/package.json +1 -1
- package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/mcp/package.json +1 -1
- package/dist/src/compiled/@ai-sdk/openai/index.js +6 -10
- package/dist/src/compiled/@ai-sdk/openai/package.json +1 -1
- package/dist/src/compiled/@ai-sdk/otel/index.js +2 -2
- package/dist/src/compiled/@ai-sdk/otel/package.json +1 -1
- package/dist/src/compiled/@ai-sdk/provider/package.json +1 -1
- package/dist/src/compiled/@vercel/sandbox/index.d.ts +6 -1
- package/dist/src/compiled/@workflow/core/index.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +5 -5
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/_chunks/workflow/{context-errors-CmtmBosi.js → context-errors-zbKocOyk.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/dist-CpUQh3NH.js +14 -0
- package/dist/src/compiled/_chunks/workflow/{resume-hook-BqY8TqOE.js → resume-hook-CL8Ed91K.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/sleep-Dn3i9nxI.js +1 -0
- package/dist/src/context/hook-lifecycle.js +5 -1
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/node-step.js +1 -0
- package/dist/src/execution/sandbox/bash-tool.js +1 -1
- package/dist/src/execution/sandbox/bindings/local.d.ts +14 -1
- package/dist/src/execution/sandbox/bindings/local.js +22 -16
- package/dist/src/execution/sandbox/bindings/vercel.d.ts +6 -0
- package/dist/src/execution/sandbox/bindings/vercel.js +25 -14
- package/dist/src/execution/sandbox/glob-tool.js +1 -1
- package/dist/src/execution/sandbox/grep-tool.js +1 -1
- package/dist/src/execution/sandbox/lazy-backend.d.ts +15 -0
- package/dist/src/execution/sandbox/lazy-backend.js +33 -0
- package/dist/src/execution/sandbox/read-file-tool.js +1 -1
- package/dist/src/execution/sandbox/ripgrep-probe.js +1 -1
- package/dist/src/execution/sandbox/session.js +49 -31
- package/dist/src/execution/sandbox/stream-utils.d.ts +2 -2
- package/dist/src/execution/sandbox/stream-utils.js +1 -1
- package/dist/src/execution/sandbox/write-file-tool.js +3 -3
- package/dist/src/execution/skills/types.d.ts +1 -1
- package/dist/src/execution/workflow-entry.d.ts +2 -4
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/harness/attachment-staging.js +10 -11
- package/dist/src/harness/execute-tool.d.ts +1 -0
- package/dist/src/harness/messages.js +15 -0
- package/dist/src/harness/tools.js +5 -0
- package/dist/src/harness/types.d.ts +6 -7
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/sandbox.d.ts +8 -2
- package/dist/src/internal/authored-definition/sandbox.js +10 -2
- package/dist/src/internal/authored-definition/schema-backed.js +12 -1
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +1 -1
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +1 -0
- package/dist/src/internal/workflow-bundle/builder-support.js +14 -0
- package/dist/src/internal/workflow-bundle/builder.js +6 -6
- package/dist/src/public/channels/slack/api-encoding.d.ts +1 -1
- package/dist/src/public/channels/slack/api-encoding.js +1 -7
- package/dist/src/public/channels/slack/api.d.ts +5 -4
- package/dist/src/public/channels/slack/api.js +6 -6
- package/dist/src/public/channels/slack/index.d.ts +3 -0
- package/dist/src/public/channels/slack/index.js +2 -0
- package/dist/src/public/channels/slack/slackChannel.d.ts +12 -4
- package/dist/src/public/channels/slack/slackChannel.js +4 -1
- package/dist/src/public/channels/slack/thread.d.ts +26 -0
- package/dist/src/public/channels/slack/thread.js +45 -0
- package/dist/src/public/definitions/sandbox.d.ts +1 -1
- package/dist/src/public/definitions/tool.d.ts +25 -0
- package/dist/src/public/sandbox/backends/default.d.ts +16 -1
- package/dist/src/public/sandbox/backends/default.js +7 -19
- package/dist/src/public/sandbox/backends/local.d.ts +7 -4
- package/dist/src/public/sandbox/backends/local.js +7 -5
- package/dist/src/public/sandbox/backends/vercel.d.ts +9 -3
- package/dist/src/public/sandbox/backends/vercel.js +9 -3
- package/dist/src/public/sandbox/index.d.ts +3 -2
- package/dist/src/public/sandbox/local-sandbox.d.ts +7 -0
- package/dist/src/public/sandbox/local-sandbox.js +1 -0
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +13 -1
- package/dist/src/public/tools/index.d.ts +1 -1
- package/dist/src/runtime/resolve-sandbox.js +5 -1
- package/dist/src/runtime/resolve-tool.js +3 -0
- package/dist/src/runtime/skills/sandbox-access.js +3 -3
- package/dist/src/runtime/types.d.ts +17 -2
- package/dist/src/shared/sandbox-definition.d.ts +16 -1
- package/dist/src/shared/sandbox-session.d.ts +53 -121
- package/package.json +9 -9
- package/dist/src/chunks/host-C19hLVqS.js +0 -22
- package/dist/src/compiled/_chunks/workflow/dist-4zn5tehu.js +0 -10
- package/dist/src/compiled/_chunks/workflow/dist-DTWUhyDN.js +0 -5
- package/dist/src/compiled/_chunks/workflow/sleep-D30F1GSr.js +0 -1
- /package/dist/src/compiled/_chunks/workflow/{dist-B6aByiku.js → dist-0iNBqPYp.js} +0 -0
- /package/dist/src/compiled/_chunks/workflow/{dist-CVo7knbW.js → dist-D774SUM4.js} +0 -0
- /package/dist/src/compiled/_chunks/workflow/{src-Bc9OYRaN.js → src-ClRYdO4-.js} +0 -0
- /package/dist/src/compiled/_chunks/workflow/{symbols-DkV1V0kM.js → symbols-D-4tVV8x.js} +0 -0
- /package/dist/src/compiled/_chunks/workflow/{token-Cq5QjRq8.js → token-CsNmv7KW.js} +0 -0
- /package/dist/src/compiled/_chunks/workflow/{token-Duaoxfi5.js → token-j5Cl4rrs.js} +0 -0
|
@@ -25,13 +25,28 @@ export interface SandboxDefinition<BO = Record<string, never>, SO = Record<strin
|
|
|
25
25
|
/**
|
|
26
26
|
* Backend that runs this sandbox.
|
|
27
27
|
*
|
|
28
|
+
* Accepts either a {@link SandboxBackend} value or a zero-arg factory
|
|
29
|
+
* function that returns one. The factory form is invoked lazily on
|
|
30
|
+
* first framework access and the result is memoized for the lifetime
|
|
31
|
+
* of the process, so backend-internal state (such as the Vercel
|
|
32
|
+
* backend's prewarmed-template cache) is preserved across every call.
|
|
33
|
+
* Use the factory form to defer evaluation — for example, when create
|
|
34
|
+
* options depend on environment variables that aren't set at module
|
|
35
|
+
* load time:
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* defineSandbox({
|
|
39
|
+
* backend: () => vercelBackend({ env: { TOKEN: process.env.TOKEN ?? "" } }),
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
28
43
|
* When this field is omitted, Ash substitutes `defaultBackend()` at
|
|
29
44
|
* runtime, which delegates to `vercelBackend()` on hosted Vercel
|
|
30
45
|
* (where `process.env.VERCEL` is set) and to `localBackend()`
|
|
31
46
|
* everywhere else. Set `backend` explicitly to pin the sandbox to a
|
|
32
47
|
* specific backend regardless of environment.
|
|
33
48
|
*/
|
|
34
|
-
backend: SandboxBackend<BO, SO
|
|
49
|
+
backend: SandboxBackend<BO, SO> | (() => SandboxBackend<BO, SO>);
|
|
35
50
|
bootstrap?(input: SandboxBootstrapContext<BO>): Promise<void> | void;
|
|
36
51
|
onSession?(input: SandboxSessionContext<SO>): Promise<void> | void;
|
|
37
52
|
}
|
|
@@ -1,46 +1,58 @@
|
|
|
1
1
|
import type { Experimental_Sandbox as AiSdkSandbox } from "ai";
|
|
2
2
|
/**
|
|
3
|
-
* Options for running a sandbox
|
|
3
|
+
* Options for running one command in a sandbox. Shape mirrors the AI
|
|
4
|
+
* SDK {@link AiSdkSandbox} `runCommand` argument so authored code that
|
|
5
|
+
* targets either surface uses the same call shape.
|
|
4
6
|
*/
|
|
5
|
-
export type
|
|
7
|
+
export type SandboxRunCommandOptions = Parameters<AiSdkSandbox["runCommand"]>[0];
|
|
6
8
|
/**
|
|
7
9
|
* Serializable result returned after running one sandbox command.
|
|
8
10
|
*/
|
|
9
|
-
export type SandboxCommandResult =
|
|
11
|
+
export type SandboxCommandResult = Awaited<ReturnType<AiSdkSandbox["runCommand"]>>;
|
|
10
12
|
/**
|
|
11
|
-
* Options for reading
|
|
13
|
+
* Options for reading one file as a stream of bytes.
|
|
12
14
|
*/
|
|
13
|
-
export
|
|
14
|
-
/**
|
|
15
|
-
* Text encoding used to decode the file bytes. Defaults to `"utf-8"`.
|
|
16
|
-
*
|
|
17
|
-
* `"utf-8"` decodes with `TextDecoder` in fatal mode; other encodings
|
|
18
|
-
* fall back to Node's `Buffer.toString(encoding)`.
|
|
19
|
-
*/
|
|
20
|
-
readonly encoding?: string;
|
|
21
|
-
/**
|
|
22
|
-
* 1-based inclusive end line. When past the file's line count, the read
|
|
23
|
-
* returns through EOF without error.
|
|
24
|
-
*/
|
|
25
|
-
readonly endLine?: number;
|
|
26
|
-
/**
|
|
27
|
-
* 1-based inclusive start line. Defaults to 1.
|
|
28
|
-
*/
|
|
29
|
-
readonly startLine?: number;
|
|
30
|
-
}
|
|
15
|
+
export type SandboxReadFileOptions = Parameters<AiSdkSandbox["readFile"]>[0];
|
|
31
16
|
/**
|
|
32
|
-
* Options for
|
|
17
|
+
* Options for reading one file as raw bytes.
|
|
33
18
|
*/
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
export type SandboxReadBinaryFileOptions = Parameters<AiSdkSandbox["readBinaryFile"]>[0];
|
|
20
|
+
/**
|
|
21
|
+
* Options for reading one text file from a sandbox.
|
|
22
|
+
*
|
|
23
|
+
* `encoding`, `startLine`, and `endLine` are passed through to the
|
|
24
|
+
* public-surface decoder. `"utf-8"` decodes with `TextDecoder` in fatal
|
|
25
|
+
* mode; other encodings fall back to Node's `Buffer.toString(encoding)`.
|
|
26
|
+
* Line ranges are 1-based and inclusive; `endLine` past the file's line
|
|
27
|
+
* count returns through EOF without error.
|
|
28
|
+
*/
|
|
29
|
+
export type SandboxReadTextFileOptions = Parameters<AiSdkSandbox["readTextFile"]>[0];
|
|
30
|
+
/**
|
|
31
|
+
* Options for writing one file from a stream of bytes.
|
|
32
|
+
*/
|
|
33
|
+
export type SandboxWriteFileOptions = Parameters<AiSdkSandbox["writeFile"]>[0];
|
|
34
|
+
/**
|
|
35
|
+
* Options for writing one file from raw bytes.
|
|
36
|
+
*/
|
|
37
|
+
export type SandboxWriteBinaryFileOptions = Parameters<AiSdkSandbox["writeBinaryFile"]>[0];
|
|
38
|
+
/**
|
|
39
|
+
* Options for writing one text file to a sandbox.
|
|
40
|
+
*/
|
|
41
|
+
export type SandboxWriteTextFileOptions = Parameters<AiSdkSandbox["writeTextFile"]>[0];
|
|
40
42
|
/**
|
|
41
43
|
* Public Ash-owned sandbox session exposed to authored lifecycle hooks.
|
|
44
|
+
*
|
|
45
|
+
* The seven I/O methods (`runCommand`, `readFile`, `readBinaryFile`,
|
|
46
|
+
* `readTextFile`, `writeFile`, `writeBinaryFile`, `writeTextFile`) are
|
|
47
|
+
* pulled directly from the AI SDK {@link AiSdkSandbox} type, so authored
|
|
48
|
+
* code that targets either surface uses identical signatures. `id` and
|
|
49
|
+
* `resolvePath` are Ash-specific extensions that the runtime relies on
|
|
50
|
+
* for caching and `/workspace` path anchoring.
|
|
51
|
+
*
|
|
52
|
+
* Relative paths resolve from `/workspace`, the live working directory
|
|
53
|
+
* for every backend. Absolute paths pass through unchanged.
|
|
42
54
|
*/
|
|
43
|
-
export interface SandboxSession {
|
|
55
|
+
export interface SandboxSession extends Pick<AiSdkSandbox, "runCommand" | "readFile" | "readBinaryFile" | "readTextFile" | "writeFile" | "writeBinaryFile" | "writeTextFile"> {
|
|
44
56
|
/**
|
|
45
57
|
* Stable identifier for the backend session this handle wraps.
|
|
46
58
|
*
|
|
@@ -52,43 +64,6 @@ export interface SandboxSession {
|
|
|
52
64
|
* outlive individual step executions.
|
|
53
65
|
*/
|
|
54
66
|
readonly id: string;
|
|
55
|
-
/**
|
|
56
|
-
* Reads one file from the sandbox as a stream of bytes.
|
|
57
|
-
*
|
|
58
|
-
* Returns `null` when the file does not exist. This is the lowest-level
|
|
59
|
-
* read primitive; prefer {@link SandboxSession.readBinaryFile} or
|
|
60
|
-
* {@link SandboxSession.readTextFile} unless you specifically need to
|
|
61
|
-
* stream bytes (e.g. piping a large file through a transformation).
|
|
62
|
-
*
|
|
63
|
-
* Relative paths resolve from `/workspace`, the live working directory
|
|
64
|
-
* for every backend. Absolute paths pass through unchanged.
|
|
65
|
-
*/
|
|
66
|
-
readFile(path: string): Promise<ReadableStream<Uint8Array> | null>;
|
|
67
|
-
/**
|
|
68
|
-
* Reads one file from the sandbox as raw bytes.
|
|
69
|
-
*
|
|
70
|
-
* Returns `null` when the file does not exist. Safe for binary payloads
|
|
71
|
-
* (images, PDFs, archives, attachment bytes written by the framework at
|
|
72
|
-
* `/workspace/attachments/...`).
|
|
73
|
-
*
|
|
74
|
-
* Relative paths resolve from `/workspace`. Absolute paths pass through
|
|
75
|
-
* unchanged.
|
|
76
|
-
*/
|
|
77
|
-
readBinaryFile(path: string): Promise<Buffer | null>;
|
|
78
|
-
/**
|
|
79
|
-
* Reads one text file from the sandbox, decoded using the requested
|
|
80
|
-
* encoding (default `"utf-8"`).
|
|
81
|
-
*
|
|
82
|
-
* Returns `null` when the file does not exist. Throws when the file
|
|
83
|
-
* contains bytes that cannot be decoded with the requested encoding.
|
|
84
|
-
*
|
|
85
|
-
* Relative paths resolve from `/workspace`. Absolute paths pass through
|
|
86
|
-
* unchanged.
|
|
87
|
-
*
|
|
88
|
-
* Line ranges are 1-based and inclusive. When `endLine` is past EOF the
|
|
89
|
-
* read returns through EOF without error.
|
|
90
|
-
*/
|
|
91
|
-
readTextFile(path: string, options?: SandboxReadTextFileOptions): Promise<string | null>;
|
|
92
67
|
/**
|
|
93
68
|
* Anchors a sandbox-relative path to `/workspace` and returns the
|
|
94
69
|
* resulting absolute path.
|
|
@@ -97,69 +72,26 @@ export interface SandboxSession {
|
|
|
97
72
|
* The read and write methods already apply this internally.
|
|
98
73
|
*/
|
|
99
74
|
resolvePath(path: string): string;
|
|
100
|
-
/**
|
|
101
|
-
* Runs one shell command inside the current sandbox session and returns the
|
|
102
|
-
* captured stdout, stderr, and exit code.
|
|
103
|
-
*
|
|
104
|
-
* Commands execute with `/workspace` as the working directory on every
|
|
105
|
-
* backend.
|
|
106
|
-
*/
|
|
107
|
-
runCommand(command: string, options?: SandboxCommandOptions): Promise<SandboxCommandResult>;
|
|
108
|
-
/**
|
|
109
|
-
* Writes one file to the sandbox from a stream of bytes, creating parent
|
|
110
|
-
* directories recursively and overwriting any existing file.
|
|
111
|
-
*
|
|
112
|
-
* This is the lowest-level write primitive; prefer
|
|
113
|
-
* {@link SandboxSession.writeBinaryFile} or
|
|
114
|
-
* {@link SandboxSession.writeTextFile} when the full content is already
|
|
115
|
-
* materialized in memory.
|
|
116
|
-
*
|
|
117
|
-
* Relative paths resolve from `/workspace`. Absolute paths pass through
|
|
118
|
-
* unchanged.
|
|
119
|
-
*/
|
|
120
|
-
writeFile(path: string, content: ReadableStream<Uint8Array>): Promise<void>;
|
|
121
|
-
/**
|
|
122
|
-
* Writes one file to the sandbox from a raw byte buffer, creating
|
|
123
|
-
* parent directories recursively and overwriting any existing file.
|
|
124
|
-
*
|
|
125
|
-
* Relative paths resolve from `/workspace`. Absolute paths pass through
|
|
126
|
-
* unchanged.
|
|
127
|
-
*/
|
|
128
|
-
writeBinaryFile(path: string, content: Buffer): Promise<void>;
|
|
129
|
-
/**
|
|
130
|
-
* Writes one file to the sandbox from a string, encoded using the
|
|
131
|
-
* requested encoding (default `"utf-8"`). Creates parent directories
|
|
132
|
-
* recursively and overwrites any existing file.
|
|
133
|
-
*
|
|
134
|
-
* Relative paths resolve from `/workspace`. Absolute paths pass through
|
|
135
|
-
* unchanged.
|
|
136
|
-
*/
|
|
137
|
-
writeTextFile(path: string, content: string, options?: SandboxWriteTextFileOptions): Promise<void>;
|
|
138
75
|
}
|
|
139
76
|
/**
|
|
140
77
|
* Internal sandbox session, used to construct the public {@link SandboxSession}.
|
|
141
78
|
*
|
|
142
|
-
* Backend implementers only need to provide byte-oriented file I/O
|
|
143
|
-
* public surface (binary and text variants,
|
|
144
|
-
* handling) is built on top of these
|
|
79
|
+
* Backend implementers only need to provide byte-oriented file I/O and
|
|
80
|
+
* command execution; the public surface (binary and text variants,
|
|
81
|
+
* line-range slicing, encoding handling) is built on top of these
|
|
82
|
+
* primitives by `buildSandboxSession`.
|
|
83
|
+
*
|
|
84
|
+
* Each method's signature mirrors its public counterpart (and the AI
|
|
85
|
+
* SDK {@link AiSdkSandbox} surface) so backends look symmetric with
|
|
86
|
+
* what authored code sees. The `path` field on `readFile`/`writeFile`
|
|
87
|
+
* here is the **already-resolved** path - the public-surface builder
|
|
88
|
+
* calls `resolvePath` before delegating.
|
|
145
89
|
*/
|
|
146
|
-
export interface InternalSandboxSession {
|
|
90
|
+
export interface InternalSandboxSession extends Pick<AiSdkSandbox, "runCommand" | "readFile" | "writeFile"> {
|
|
147
91
|
/**
|
|
148
92
|
* Stable identifier surfaced on the public {@link SandboxSession}.
|
|
149
93
|
*/
|
|
150
94
|
readonly id: string;
|
|
151
|
-
/**
|
|
152
|
-
* Reads the file at `resolvedPath` as a stream of bytes, or `null` if
|
|
153
|
-
* missing.
|
|
154
|
-
*/
|
|
155
|
-
readFile(resolvedPath: string): Promise<ReadableStream<Uint8Array> | null>;
|
|
156
95
|
/** Translates a user-facing path to the backend's native path. */
|
|
157
96
|
resolvePath(path: string): string;
|
|
158
|
-
/** Runs one shell command inside the sandbox. */
|
|
159
|
-
runCommand(command: string, options?: SandboxCommandOptions): Promise<SandboxCommandResult>;
|
|
160
|
-
/**
|
|
161
|
-
* Writes the bytes from `content` to `resolvedPath`, creating parent
|
|
162
|
-
* directories recursively and overwriting any existing file.
|
|
163
|
-
*/
|
|
164
|
-
writeFile(resolvedPath: string, content: ReadableStream<Uint8Array>): Promise<void>;
|
|
165
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "experimental-ash",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"ash": "./bin/ash.js",
|
|
6
6
|
"experimental-ash": "./bin/ash.js"
|
|
@@ -155,12 +155,12 @@
|
|
|
155
155
|
"nitro": "3.0.260429-beta"
|
|
156
156
|
},
|
|
157
157
|
"devDependencies": {
|
|
158
|
-
"@ai-sdk/anthropic": "4.0.0-canary.
|
|
159
|
-
"@ai-sdk/google": "4.0.0-canary.
|
|
160
|
-
"@ai-sdk/mcp": "2.0.0-canary.
|
|
161
|
-
"@ai-sdk/openai": "4.0.0-canary.
|
|
162
|
-
"@ai-sdk/otel": "1.0.0-canary.
|
|
163
|
-
"@ai-sdk/provider": "4.0.0-canary.
|
|
158
|
+
"@ai-sdk/anthropic": "4.0.0-canary.57",
|
|
159
|
+
"@ai-sdk/google": "4.0.0-canary.67",
|
|
160
|
+
"@ai-sdk/mcp": "2.0.0-canary.52",
|
|
161
|
+
"@ai-sdk/openai": "4.0.0-canary.61",
|
|
162
|
+
"@ai-sdk/otel": "1.0.0-canary.90",
|
|
163
|
+
"@ai-sdk/provider": "4.0.0-canary.17",
|
|
164
164
|
"@chat-adapter/slack": "4.28.1",
|
|
165
165
|
"@chat-adapter/state-memory": "4.28.1",
|
|
166
166
|
"@standard-schema/spec": "1.1.0",
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
"@workflow/core": "5.0.0-beta.5",
|
|
173
173
|
"@workflow/errors": "5.0.0-beta.2",
|
|
174
174
|
"@workflow/world-local": "5.0.0-beta.4",
|
|
175
|
-
"ai": "7.0.0-canary.
|
|
175
|
+
"ai": "7.0.0-canary.144",
|
|
176
176
|
"autoevals": "0.0.132",
|
|
177
177
|
"chat": "4.28.1",
|
|
178
178
|
"chokidar": "5.0.0",
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
},
|
|
191
191
|
"peerDependencies": {
|
|
192
192
|
"@opentelemetry/api": "^1.9.0",
|
|
193
|
-
"ai": "7.0.0-canary.
|
|
193
|
+
"ai": "7.0.0-canary.144",
|
|
194
194
|
"braintrust": ">=3.0.0",
|
|
195
195
|
"react": "^19.2.6"
|
|
196
196
|
},
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./chunk-8L7ocgPr.js";import{C as t,T as n,i as r,r as i,w as a}from"./paths-Dwv0Eash.js";import{a as o,i as s,n as c,r as l}from"./authored-module-loader-XcFLnl49.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./package-DmsQgn4v.js";import{g,m as ee,p as te}from"./types-MZUhN0Zy.js";import{a as ne,c as re,n as ie,o as ae,r as oe,t as se}from"./prewarm-CQYfka30.js";import{builtinModules as ce}from"node:module";import{dirname as _,extname as le,isAbsolute as ue,join as v,relative as y,resolve as b,sep as de}from"node:path";import{cp as x,mkdir as S,readFile as C,readdir as fe,realpath as pe,rename as me,rm as w,writeFile as T}from"node:fs/promises";import{randomUUID as he}from"node:crypto";import{existsSync as ge,readFileSync as _e}from"node:fs";import{fileURLToPath as ve}from"node:url";import{build as ye,copyPublicAssets as be,createDevServer as xe,createNitro as Se,prepare as Ce,prerender as we}from"nitro/builder";import{Buffer as Te}from"node:buffer";const Ee=`ash-cache.json`;async function E(e){let t=await Oe(e),n=h().version;t!==null&&t===n||await w(e,{force:!0,recursive:!0})}async function De(e){await S(e,{recursive:!0}),await T(v(e,Ee),`${JSON.stringify({ashVersion:h().version},null,2)}\n`)}async function Oe(e){try{let t=JSON.parse(await C(v(e,Ee),`utf8`));return typeof t.ashVersion==`string`?t.ashVersion:null}catch(e){return e instanceof Error&&`code`in e&&e.code,null}}const ke=new Set([`__builtin_response_array_buffer`,`__builtin_response_json`,`__builtin_response_text`]);async function Ae(e){if(e.mode===!1)return{code:e.source,workflowManifest:{}};let t=await je(e.filename,e.source),n=Ne(t);if(n.length===0)return{code:e.source,workflowManifest:{}};let r=e.moduleSpecifier??`./${Je(e.filename)}`,i={},a=[],o=[],s=!1;for(let t of n){if(t.directive===`use step`){let n=Ye(r,t.name);i.steps??={};let c=i.steps[e.filename]??={};if(c[t.name]={stepId:n},e.mode===`workflow`){let e=t.exportPrefix.length>0?`export `:``;a.push({end:t.rangeEnd,start:t.rangeStart,text:`${e}var ${t.name} = globalThis[Symbol.for("WORKFLOW_USE_STEP")](${JSON.stringify(n)});`})}else a.push({end:t.directiveEnd,start:t.directiveStart,text:``}),e.mode===`step`?(s=!0,o.push(`registerStepFunction(${JSON.stringify(n)}, ${t.name});`)):o.push(`${t.name}.stepId = ${JSON.stringify(n)};`);continue}let n=`workflow//${r}//${t.name}`;i.workflows??={};let c=i.workflows[e.filename]??={};c[t.name]={workflowId:n},e.mode===`workflow`?(a.push({end:t.directiveEnd,start:t.directiveStart,text:``}),o.push(`${t.name}.workflowId = ${JSON.stringify(n)};`),o.push(`globalThis.__private_workflows.set(${JSON.stringify(n)}, ${t.name});`)):(a.push({end:t.directiveEnd,start:t.directiveStart,text:`throw new Error(${JSON.stringify(`You attempted to execute workflow ${t.name} function directly. To start a workflow, use start(${t.name}) from workflow/api`)});`}),o.push(`${t.name}.workflowId = ${JSON.stringify(n)};`))}let c=`/**__internal_workflows${JSON.stringify(i)}*/;`,l=n.some(e=>e.directive===`use workflow`);if(e.mode===`workflow`&&!l)return{code:`${c}\n${Me(e.source,t,n,r)}`,workflowManifest:i};let u=Re(e.source,a),d=e.mode===`workflow`?await ze(e.filename,u):u;return{code:`${s?`import { registerStepFunction } from "workflow/internal/private";\n${c}\n`:`${c}\n`}${d}${o.length>0?`\n${o.join(`
|
|
2
|
-
`)}\n`:``}`,workflowManifest:i}}async function je(e,t){let{parseAst:n}=await o();return n(t,{astType:`ts`,lang:qe(e),range:!0,sourceType:`module`},e)}function Me(e,t,n,r){let i=Be(e,t),a=n.filter(e=>e.directive===`use step`).map(e=>{let t=e.exportPrefix.length>0?`export `:``,n=Ye(r,e.name);return`${t}var ${e.name} = globalThis[Symbol.for("WORKFLOW_USE_STEP")](${JSON.stringify(n)});`}),o=[...i,...a];return o.length>0?`${o.join(`
|
|
3
|
-
`)}\n`:``}function Ne(e){let t=[];for(let n of e.body??[]){let e=Pe(n);if(e===null)continue;let r=e.fn,i=r.id?.name,a=Ie(r.body);if(r.async!==!0||i===void 0||a===void 0)continue;let o=Le(a[0]);o!==null&&t.push({directive:o.value,directiveEnd:o.end,directiveStart:o.start,exportPrefix:e.exported?`export `:``,name:i,rangeEnd:e.end,rangeStart:e.start})}return t}function Pe(e){return e.type===`FunctionDeclaration`?Fe(e,!1,e):e.type!==`ExportNamedDeclaration`||e.declaration?.type!==`FunctionDeclaration`?null:Fe(e.declaration,!0,e)}function Fe(e,t,n){return e.start===void 0||e.end===void 0||n.start===void 0||n.end===void 0?null:{end:n.end,exported:t,fn:e,start:n.start}}function Ie(e){return e===void 0||Array.isArray(e)?e:e.body}function Le(e){let t=e?.directive??(e?.type===`ExpressionStatement`&&e.expression?.type===`Literal`?e.expression.value:void 0);return t!==`use workflow`&&t!==`use step`||e?.start===void 0||e.end===void 0?null:{end:e.end,start:e.start,value:t}}function Re(e,t){let n=``,r=0;for(let i of[...t].sort((e,t)=>e.start-t.start))n+=e.slice(r,i.start),n+=i.text,r=i.end;return n+e.slice(r)}async function ze(e,t){let n=await je(e,t),r=We(n),i=[];for(let e of n.body??[]){if(e.type!==`ImportDeclaration`||e.start===void 0||e.end===void 0)continue;let n=Ue(e);n.length>0&&n.every(e=>!r.has(e))&&i.push({end:Ke(t,e.end),start:e.start,text:``})}return i.length>0?Re(t,i):t}function Be(e,t){let n=[];for(let r of t.body??[])r.type===`ExportNamedDeclaration`&&r.declaration?.type===`VariableDeclaration`&&r.declaration.kind===`const`&&r.start!==void 0&&r.end!==void 0&&(r.declaration.declarations??[]).every(Ve)&&n.push(e.slice(r.start,r.end).trim());return n}function Ve(e){return He(e.init)}function He(e){return e==null?!1:e.type===`Literal`?e.value===null||typeof e.value==`boolean`||typeof e.value==`number`||typeof e.value==`string`:e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`||e.type===`TSNonNullExpression`||e.type===`TSTypeAssertion`?He(e.expression):e.type===`UnaryExpression`&&e.argument?.type===`Literal`?typeof e.argument.value==`number`:!1}function Ue(e){return e.importKind===`type`?[]:(e.specifiers??[]).filter(e=>e.importKind!==`type`).map(e=>e.local?.name).filter(e=>e!==void 0)}function We(e){let t=new Set;return D(e,e=>{e.type===`Identifier`&&typeof e.name==`string`&&t.add(e.name)}),t}function D(e,t){if(!(e.type===`ImportDeclaration`||e.type?.startsWith(`TS`))){t(e);for(let n of Object.values(e))if(Array.isArray(n))for(let e of n)Ge(e)&&D(e,t);else Ge(n)&&D(n,t)}}function Ge(e){return typeof e==`object`&&!!e&&typeof e.type==`string`}function Ke(e,t){let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n+=1;return e[n]===`\r`&&e[n+1]===`
|
|
4
|
-
`?n+2:e[n]===`
|
|
5
|
-
`?n+1:n}function qe(e){return e.endsWith(`.tsx`)?`tsx`:e.endsWith(`.jsx`)?`jsx`:/\.[cm]?ts$/.test(e)?`ts`:`js`}function Je(e){return e.replace(/\.(?:[cm]?[jt]sx?)$/,``)}function Ye(e,t){return ke.has(t)?t:`step//${e}//${t}`}const Xe={type:`queue/v2beta`,topic:`__wkf_workflow_*`,consumer:`default`,retryAfterSeconds:5,initialDelaySeconds:0},O=new Map,Ze=new Map;async function k(e,t,n,r,i){let a=i??process.cwd(),{moduleSpecifier:o}=et(r===void 0?ue(e)?e:v(a,e):r,a);return Ae({filename:e,mode:n,moduleSpecifier:o,source:t})}function Qe(e){return{hasSerde:e.includes(`workflow.serde`)||e.includes(`@serde`)||e.includes(`workflowSerde`)||e.includes(`__workflow_serde`),hasUseStep:/["']use step["']/.test(e),hasUseWorkflow:/["']use workflow["']/.test(e)}}function $e(e,t){let n=M(e),r=!n&&it(e,t);if(n||r){let n=A(e);if(n!==null){let i=rt(t).has(n.name);if(!(r||i))return{importPath:N(e,t),isPackage:!1};let a=tt(e,n);return a?{importPath:`${n.name}${a}`,isPackage:!0}:st(e,n)?{importPath:n.name,isPackage:!0}:{importPath:N(e,t),isPackage:!1}}}return{importPath:N(e,t),isPackage:!1}}function et(e,t){let n=M(e),r=!n&&it(e,t);if(!n&&!r)return{moduleSpecifier:void 0};let i=A(e);if(i===null)return{moduleSpecifier:void 0};let a=tt(e,i);return{moduleSpecifier:a?`${i.name}${a}@${i.version}`:`${i.name}@${i.version}`}}function A(e){let t=_(e),n=[];for(;t!==_(t);){let e=O.get(t);if(e!==void 0){for(let t of n)O.set(t,e);return e}n.push(t);let r=v(t,`package.json`);if(ge(r))try{let e=JSON.parse(_e(r,`utf8`));if(typeof e.name==`string`&&typeof e.version==`string`){let r={dir:t,exports:e.exports,main:e.main,module:e.module,name:e.name,version:e.version};O.set(t,r);for(let e of n)O.set(e,r);return r}}catch{}t=_(t)}for(let e of n)O.set(e,null);return null}function tt(e,t){if(t.exports===null||typeof t.exports!=`object`||Array.isArray(t.exports))return``;let n=e.replace(/\\/g,`/`),r=t.dir.replace(/\\/g,`/`),i=n.startsWith(`${r}/`)?`./${n.substring(r.length+1)}`:null;if(i===null)return``;for(let[e,n]of Object.entries(t.exports)){let t=j(n);if(t!==null&&nt(t)===i)return e===`.`?``:e.substring(1)}return``}function j(e){if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=j(t);if(e!==null)return e}return null}if(typeof e==`object`&&e)for(let t of[`workflow`,`default`,`require`,`import`,`node`]){let n=e[t],r=j(n);if(r!==null)return r}return null}function nt(e){return e.startsWith(`./`)?e:`./${e}`}function M(e){return e.split(de).join(`/`).includes(`/node_modules/`)}function rt(e){let t=Ze.get(e);if(t!==void 0)return t;let n=new Set,r=v(e,`package.json`);if(ge(r))try{let e=JSON.parse(_e(r,`utf8`));for(let t of[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`]){let r=e[t];if(typeof r==`object`&&r&&!Array.isArray(r))for(let e of Object.keys(r))n.add(e)}}catch{}return Ze.set(e,n),n}function it(e,t){if(M(e))return!1;let n=A(e);return n===null||b(n.dir)===b(t)?!1:rt(t).has(n.name)}function N(e,t){let n=t.replace(/\\/g,`/`),r=e.replace(/\\/g,`/`),i=r.startsWith(`${n}/`)?r.substring(n.length+1):y(t,e).replace(/\\/g,`/`);return i.startsWith(`.`)||(i=`./${i}`),i}function at(e){if(typeof e==`string`||Array.isArray(e))return!0;if(typeof e!=`object`||!e)return!1;let t=Object.keys(e);return t.length>0&&t.every(e=>!e.startsWith(`.`))?!0:`.`in e}function ot(e){let t=e.replace(/\\/g,`/`);return t.startsWith(`./`)?t.substring(2):t.startsWith(`/`)?t.substring(1):t}function st(e,t){let n=e.replace(/\\/g,`/`),r=t.dir.replace(/\\/g,`/`);if(!n.startsWith(`${r}/`))return!1;let i=n.substring(r.length+1);if(t.exports!==void 0){let e;if(t.exports!==null&&typeof t.exports==`object`&&`.`in t.exports)e=t.exports[`.`];else if(at(t.exports))e=t.exports;else return!1;let n=j(e);return n!==null&&ot(n)===i}return[t.module,t.main,`index.js`,`index.mjs`,`index.cjs`,`index.ts`,`index.mts`,`index.cts`].flatMap(e=>typeof e==`string`?[ot(e)]:[]).includes(i)}const ct=`\0ash-workflow-entry`,lt=new Set([`server-only`,`client-only`,`next/dist/compiled/server-only`,`next/dist/compiled/client-only`]);new Set([...ce,...ce.map(e=>`node:${e}`)]);const ut=new Set([`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`]),dt=new Set([`node_modules`,`.git`,`.next`,`.nuxt`,`.output`,`.vercel`,`.workflow-data`,`.workflow-vitest`,`.well-known`,`.svelte-kit`,`.turbo`,`.cache`,`.yarn`,`.pnpm-store`]);async function ft(e){let t=[];async function n(e){let r;try{r=await fe(e,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}for(let i of r){if(i.isDirectory()){dt.has(i.name)||await n(v(e,i.name));continue}if(!i.isFile())continue;let r=i.name.match(/\.[^.]+$/)?.[0];r!==void 0&&ut.has(r)&&t.push(v(e,i.name))}}return await n(e),t}function pt(e,t){let{importPath:n,isPackage:r}=$e(e,t);return r?`import ${JSON.stringify(n)};`:`import ${JSON.stringify(St(t,e))};`}function mt(e){return{name:`ash-workflow-virtual-entry`,resolveId(e){if(e===`\0ash-workflow-entry`)return{id:e}},load(t){if(t===`\0ash-workflow-entry`)return{code:e,moduleSideEffects:!0,moduleType:`js`}}}}function ht(){return{name:`ash-workflow-pseudo-packages`,resolveId(e){if(lt.has(e))return{id:`\0ash-workflow-pseudo-package:${e}`}},load(e){if(e.startsWith(`\0ash-workflow-pseudo-package:`))return{code:``,moduleType:`js`}}}}function gt(e,t={}){return{name:`ash-package-imports`,resolveId(n){let r=n.match(/^#compiled\/(.+)$/)?.[1];if(r!==void 0)return t.workflowCondition===!0&&r===`@workflow/core/index.js`?P([v(e,`src`,`internal`,`workflow-bundle`,`workflow-core-shim.ts`),v(e,`dist`,`src`,`internal`,`workflow-bundle`,`workflow-core-shim.js`)]):P([v(e,`.generated`,`compiled`,r),v(e,`dist`,`src`,`compiled`,r)]);let i=n.match(/^#(.+)\.js$/)?.[1];if(i!==void 0)return P([`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`].flatMap(t=>[v(e,`src`,`${i}${t}`),v(e,`dist`,`src`,`${i}${t}`)]))}}}function _t(e){let t=new Set(e.sideEffectFiles?.map(e=>e.replaceAll(`\\`,`/`))??[]);return{name:`ash-workflow-transform`,async load(n){if(!Et(n))return;let r=await C(n,`utf8`),i=await k(Tt(e.workingDir,n),r.replace(/require\(\s*(['"])server-only\1\s*\)/g,`void 0`).replace(/require\(\s*(['"])client-only\1\s*\)/g,`void 0`),e.mode??`workflow`,n,e.projectRoot);return wt(e.manifest,i.workflowManifest),{code:i.code,map:null,moduleSideEffects:t.has(n.replaceAll(`\\`,`/`))||void 0}}}}async function vt(e){let t=`// biome-ignore-all lint: generated file
|
|
6
|
-
/* eslint-disable */
|
|
7
|
-
import { workflowEntrypoint } from 'workflow/runtime';
|
|
8
|
-
|
|
9
|
-
const workflowCode = \`${(e.code.endsWith(`
|
|
10
|
-
`)?e.code:`${e.code}\n`).replace(/[\\`$]/g,`\\$&`)}\`;
|
|
11
|
-
|
|
12
|
-
export const POST = workflowEntrypoint(workflowCode);`;if(!e.bundleFinalOutput){await Ct(e.outfile,t);return}let n=s(await l({cwd:e.workingDir,input:ct,external:e=>e===`@aws-sdk/credential-provider-web-identity`,platform:`node`,plugins:[mt(t)],write:!1,output:{comments:!1,format:e.format,sourcemap:!1}}),`final workflow bundle for "${e.outfile}"`);await Ct(e.outfile,n.code)}function yt(e){let t={};for(let[n,r]of Object.entries(e??{})){t[n]={};for(let[e,i]of Object.entries(r))t[n][e]={stepId:i.stepId}}return t}function bt(e){let t={};for(let[n,r]of Object.entries(e??{})){t[n]={};for(let[e,i]of Object.entries(r))t[n][e]={graph:{edges:[],nodes:[]},workflowId:i.workflowId}}return t}function xt(e){let t={};for(let[n,r]of Object.entries(e??{})){t[n]={};for(let[e,i]of Object.entries(r))t[n][e]={classId:i.classId}}return t}function St(e,t){let n=y(e,t).replaceAll(`\\`,`/`);return n.startsWith(`./`)||n.startsWith(`../`)?n:`./${n}`}function P(e){for(let t of e)if(ge(t))return{id:b(t)}}async function Ct(e,t){await S(_(e),{recursive:!0});let n=`${e}.${process.pid}.${Date.now()}.tmp`;await T(n,t),await me(n,e)}function wt(e,t){e.steps=F(e.steps,t.steps),e.workflows=F(e.workflows,t.workflows),e.classes=F(e.classes,t.classes)}function F(e,t){if(t===void 0)return e;let n={...e};for(let[e,r]of Object.entries(t))n[e]={...n[e],...r};return n}function Tt(e,t){let n=t.replaceAll(`\\`,`/`),r=y(e.replaceAll(`\\`,`/`),n).replaceAll(`\\`,`/`);return r.startsWith(`../`)&&(r=r.split(`/`).filter(e=>e!==`..`).join(`/`)),r}function Et(e){return/\.(?:[cm]?[jt]sx?)$/.test(e)}async function Dt(e){let t=[...e.discoveredEntries.discoveredSteps].sort(),n=new Set(t),r=[...e.discoveredEntries.discoveredSerdeFiles].sort().filter(e=>!n.has(e)),i=await kt({projectRoot:e.projectRoot,stepFiles:t,serdeOnlyFiles:r,workingDir:e.workingDir}),a=_(e.outfile),o=[`// Generated by Ash. Do not edit by hand.`,...Ot({builtinsImportSpecifier:e.builtinsPath===void 0?`workflow/internal/builtins`:I({outfileDirectory:a,preferAbsoluteFileImports:e.preferAbsoluteFileImports??!1,targetPath:e.builtinsPath}),outfileDirectory:a,preferAbsoluteFileImports:e.preferAbsoluteFileImports??!1,serdeOnlyFiles:r,stepFiles:t}),`export const __steps_registered = true;`,``].join(`
|
|
13
|
-
`);return await S(a,{recursive:!0}),await Nt(e.outfile)!==o&&await T(e.outfile,o),i}function Ot(e){return[e.builtinsImportSpecifier,...e.stepFiles.map(t=>I({outfileDirectory:e.outfileDirectory,preferAbsoluteFileImports:e.preferAbsoluteFileImports,targetPath:t})),...e.serdeOnlyFiles.map(t=>I({outfileDirectory:e.outfileDirectory,preferAbsoluteFileImports:e.preferAbsoluteFileImports,targetPath:t}))].map(e=>`import ${JSON.stringify(e)};`)}function I(e){return e.preferAbsoluteFileImports?t(e.targetPath):Mt(e.outfileDirectory,e.targetPath)}async function kt(e){let t={},n=[...e.stepFiles,...e.serdeOnlyFiles];for(let r of n){let n=await C(r,`utf8`);At(t,(await k(jt(e.workingDir,r),n,`step`,r,e.projectRoot)).workflowManifest)}return t}function At(e,t){e.steps=L(e.steps,t.steps),e.workflows=L(e.workflows,t.workflows),e.classes=L(e.classes,t.classes)}function L(e,t){if(t===void 0)return e;let n={...e};for(let[e,r]of Object.entries(t))n[e]={...n[e],...r};return n}function jt(e,t){let n=t.replaceAll(`\\`,`/`),r=y(e.replaceAll(`\\`,`/`),n).replaceAll(`\\`,`/`);return r.startsWith(`../`)&&(r=r.split(`/`).filter(e=>e!==`..`).join(`/`)),r}function Mt(e,t){let n=y(e,t).replaceAll(`\\`,`/`);return n.startsWith(`.`)?n:`./${n}`}async function Nt(e){try{return await C(e,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return null;throw e}}const Pt=[`@mongodb-js/zstd`,`node-liblzma`],Ft=[`@chat-adapter/slack`,`chat`];function It(e){let t={};return Lt(e)&&Object.assign(t,e),t}function Lt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Rt(e){await w(e,{force:!0,recursive:!0}),await S(e,{recursive:!0})}async function zt(e){try{return await pe(e.sourcePath)}catch{return await pe(e.fallbackPath)}}async function Bt(e){let t=await zt({fallbackPath:e.fallbackPath,sourcePath:e.sourcePath});await Rt(e.targetPath),await x(t,e.targetPath,{dereference:!0,recursive:!0})}function Vt(e){let t=y(e.fromDirectoryPath,e.toFilePath).replaceAll(`\\`,`/`);return t.startsWith(`.`)?t:`./${t}`}function Ht(e){return[`import nitroHandler from ${JSON.stringify(e.delegateImportPath)};`,``,`function invokeNitroHandler(request, context) {`,` if (typeof nitroHandler === "function") {`,` return nitroHandler(request, context);`,` }`,``,` if (nitroHandler !== null && typeof nitroHandler === "object" && "fetch" in nitroHandler) {`,` const fetch = nitroHandler.fetch;`,` if (typeof fetch === "function") {`,` return fetch.call(nitroHandler, request, context);`,` }`,` }`,``,` throw new TypeError("Expected Nitro handler to export a function or an object with fetch(request, context).");`,`}`,``,`const workflowRoutePath = ${JSON.stringify(e.workflowRoutePath)};`,``,`function rewriteRequestToWorkflowRoute(request) {`,` const sourceUrl = new URL(request.url);`,` const routedUrl = new URL(workflowRoutePath, sourceUrl);`,` routedUrl.search = sourceUrl.search;`,` return new Request(routedUrl, request);`,`}`,``,`export default {`,` fetch(request, context) {`,` return invokeNitroHandler(rewriteRequestToWorkflowRoute(request), context);`,` },`,`};`,``].join(`
|
|
14
|
-
`)}async function Ut(e){try{let t=JSON.parse(await C(v(e,`.vc-config.json`),`utf8`));if(typeof t.handler==`string`&&t.handler.length>0)return t.handler}catch{}return`index.mjs`}async function Wt(e){let t=await Ut(e.functionDirectoryPath),n=v(e.functionDirectoryPath,t),r=_(n),i=le(t),a=v(r,`__ash_nitro_handler__${i.length>0?i:`.mjs`}`),o=Vt({fromDirectoryPath:r,toFilePath:a});await me(n,a),await T(n,Ht({delegateImportPath:o,workflowRoutePath:e.workflowRoutePath}))}const Gt=new Map;var Kt=class{#e;#t;config;#n=new WeakMap;constructor(e){this.config={buildTarget:`standalone`,dirs:[m(`src/execution`)],externalPackages:[...Pt,...Ft],projectRoot:e.appRoot,watch:e.watch,workingDir:e.rootDir},this.#e=e.compiledArtifactsBootstrapPath,this.#t=e.outDir}async build(e={}){let t=(Gt.get(this.#t)??Promise.resolve()).then(()=>this.#r(e));Gt.set(this.#t,t.catch(()=>{})),await t}async#r(e){await E(this.#t);let t=await this.#i();if(t.length===0)throw Error(`Expected the execution workflow source file under "${m(`src/execution`)}".`);let n=await this.findTsConfigPath();await S(this.#t,{recursive:!0});let r=await this.discoverEntries(t,this.#t,n),i=v(this.#t,`workflows.mjs`),{manifest:a}=await this.createWorkflowsBundle({discoveredEntries:r,keepInterimBundleContext:!1,outfile:i,bundleFinalOutput:!1,format:`esm`,inputFiles:t,tsconfigPath:n}),o=v(this.#t,`steps.mjs`),s=await Dt({builtinsPath:u(`workflow/internal/builtins`),discoveredEntries:r,outfile:o,preferAbsoluteFileImports:!0,projectRoot:this.config.projectRoot??this.config.workingDir,workingDir:this.config.workingDir}),c=e.nitroStepOutfile;c!==void 0&&c!==o&&await Dt({builtinsPath:u(`workflow/internal/builtins`),discoveredEntries:r,outfile:c,preferAbsoluteFileImports:!0,projectRoot:this.config.projectRoot??this.config.workingDir,workingDir:this.config.workingDir}),await qt(i,o),await Jt(i),await Yt(i);let l=e.nitroWorkflowOutfile;l!==void 0&&l!==i&&(await S(_(l),{recursive:!0}),await nn(i,l),c!==void 0&&(await qt(l,c),await Jt(l),await Yt(l))),await this.createManifest({workflowBundlePath:v(this.#t,`workflows.mjs`),manifestDir:this.#t,manifest:{steps:{...s.steps,...a.steps},workflows:{...s.workflows,...a.workflows},classes:{...s.classes,...a.classes}}}),await De(this.#t)}get transformProjectRoot(){return this.config.projectRoot??this.config.workingDir}async findTsConfigPath(){let e=this.config.workingDir;for(;;){for(let t of[`tsconfig.json`,`jsconfig.json`]){let n=v(e,t);try{return await C(n),n}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}}let t=_(e);if(t===e)return;e=t}}async getInputFiles(){let e=this.config.dirs.map(e=>b(this.config.workingDir,e));return(await Promise.all(e.map(e=>ft(e)))).flat()}async discoverEntries(e,t,n){let r=this.#n.get(e);if(r!==void 0)return r;let i={discoveredSerdeFiles:[],discoveredSteps:[],discoveredWorkflows:[]};for(let t of e){let e=Qe(await C(t,`utf8`));e.hasUseStep&&i.discoveredSteps.push(t),e.hasUseWorkflow&&i.discoveredWorkflows.push(t),e.hasSerde&&i.discoveredSerdeFiles.push(t)}return this.#n.set(e,i),i}async createWorkflowsBundle({bundleFinalOutput:e=!0,discoveredEntries:t,format:n=`cjs`,inputFiles:r,keepInterimBundleContext:i=this.config.watch,outfile:a,tsconfigPath:o}){let c=t??await this.discoverEntries(r,_(a),o),u=[...c.discoveredWorkflows].sort(),d=new Set(u),f=[...c.discoveredSerdeFiles].sort().filter(e=>!d.has(e)),p={},m=[...u.map(e=>pt(e,this.config.workingDir)),...f.map(e=>pt(e,this.config.workingDir))].join(`
|
|
15
|
-
`);return await vt({bundleFinalOutput:e,code:s(await l({cwd:this.config.workingDir,input:ct,platform:`neutral`,plugins:[mt(m),ht(),gt(this.config.workingDir,{workflowCondition:!0}),_t({manifest:p,projectRoot:this.transformProjectRoot,sideEffectFiles:[...u,...f],workingDir:this.config.workingDir})],resolve:{conditionNames:[`ash-source`,`workflow`,`node`,`import`,`default`],extensions:[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`],mainFields:[`module`,`main`]},tsconfig:o??!1,write:!1,output:{banner:`globalThis.__private_workflows = new Map();`,codeSplitting:!1,comments:!1,format:`cjs`,sourcemap:`inline`}}),`intermediate workflow bundle for "${a}"`).code,format:n,outfile:a,workingDir:this.config.workingDir}),i?{bundleFinal:async t=>{await vt({bundleFinalOutput:e,code:t,format:n,outfile:a,workingDir:this.config.workingDir})},interimBundleCtx:void 0,manifest:p}:{manifest:p}}async createManifest({manifest:e,manifestDir:t}){let n={version:`1.0.0`,steps:yt(e.steps),workflows:bt(e.workflows),classes:xt(e.classes)},r=JSON.stringify(n,null,2);return await S(t,{recursive:!0}),await T(v(t,`manifest.json`),r),r}async buildVercelOutput(e){await this.build();let t=v(this.#t,`vercel-build-output`,`functions`,`.well-known`,`workflow`,`v1`),n=v(t,`flow.func`),r=v(e.outputDir,`functions`,`.well-known`,`workflow`,`v1`),i=v(e.flowNitroOutputDir,`functions`,`__server.func`),a=v(e.flowNitroOutputDir,`functions`,`.well-known`,`workflow`,`v1`,`flow.func`),o=v(r,`flow.func`),s=v(r,`step.func`),c=v(r,`webhook`,`[token].func`);await Bt({fallbackPath:i,sourcePath:a,targetPath:n}),await Promise.all([this.#a(n,{experimentalTriggers:Array.from([Xe]),maxDuration:`max`,runtime:e.runtime??null,shouldAddHelpers:!1}),x(v(this.#t,`manifest.json`),v(t,`manifest.json`))]),await Wt({functionDirectoryPath:n,workflowRoutePath:`/.well-known/workflow/v1/flow`}),await Promise.all([w(o,{force:!0,recursive:!0}),w(s,{force:!0,recursive:!0}),w(c,{force:!0,recursive:!0})]),await S(r,{recursive:!0}),await Promise.all([x(n,o,{recursive:!0}),x(v(t,`manifest.json`),v(r,`manifest.json`))])}async#i(){return[...await this.getInputFiles(),this.#e]}async#a(e,t){let n=v(e,`.vc-config.json`),r=await this.#o(n),i={...r};i.environment=It(r.environment),t.runtime!==null&&(i.runtime=t.runtime),t.maxDuration!==void 0&&(i.maxDuration=t.maxDuration),t.shouldAddHelpers!==void 0&&(i.shouldAddHelpers=t.shouldAddHelpers),t.shouldAddSourcemapSupport!==void 0&&(i.shouldAddSourcemapSupport=t.shouldAddSourcemapSupport),t.experimentalTriggers!==void 0&&(i.experimentalTriggers=[...t.experimentalTriggers]),await T(n,`${JSON.stringify(i,null,2)}\n`)}async#o(e){try{let t=JSON.parse(await C(e,`utf8`));if(typeof t==`object`&&t)return t}catch{}return{}}};async function qt(e,t){let n=await R(e);if(n===null||n.includes(`__ashWorkflowStepsRegistered`))return;let r=en(_(e),t),i=[`import { __steps_registered as __ashWorkflowStepsRegistered } from ${JSON.stringify(r)};`,`void __ashWorkflowStepsRegistered;`,``].join(`
|
|
16
|
-
`),a=n.match(/^import\s.+?;\n/m);if(a===null||a.index===void 0){await T(e,`${i}${n}`);return}let o=a.index+a[0].length;await T(e,`${n.slice(0,o)}${i}${n.slice(o)}`)}async function Jt(e){let t=await R(e);if(t===null)return;let n=t;for(let e of[`workflow`,`workflow/api`,`workflow/internal/builtins`,`workflow/internal/private`,`workflow/runtime`]){let t=$t(u(e));n=Qt(n,e,t)}n!==t&&await T(e,n)}async function Yt(e){let t=await R(e);if(t===null)return;let n=t.indexOf(`const workflowCode = `),r=t.lastIndexOf(`;
|
|
17
|
-
|
|
18
|
-
export const POST = workflowEntrypoint(workflowCode);`);if(n===-1||r===-1||r<=n)return;let i=n+21,a=t.slice(i,r);if(!a.trimStart().startsWith("`"))return;let o=Zt(a,e),s=`${t.slice(0,i)}${Xt(o)}${t.slice(r)}`;s!==t&&await T(e,s)}function Xt(e){let t=Te.from(e,`utf8`).toString(`base64`).match(/.{1,16384}/g)??[``];return`Buffer.from(${JSON.stringify(t)}.join(""), "base64").toString("utf8")`}function Zt(e,t){let n=e.trim();if(!n.startsWith("`")||!n.endsWith("`"))throw Error(`Expected generated workflow code literal in "${t}" to be a template.`);let r=n.slice(1,-1),i=``;for(let e=0;e<r.length;e+=1){let t=r[e];if(t!==`\\`){i+=t;continue}let n=r[e+1];if(n===`\\`||n==="`"||n===`$`){i+=n,e+=1;continue}i+=t}return i}function Qt(e,t,n){return e.replaceAll(JSON.stringify(t),JSON.stringify(n)).replaceAll(`'${t}'`,JSON.stringify(n))}function $t(e){return t(e)}function en(e,t){let n=y(e,t).replaceAll(`\\`,`/`);return n.startsWith(`.`)?n:`./${n}`}async function R(e){try{return await C(e,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return null;throw e}}async function tn(e){try{return await C(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return null;throw e}}async function nn(e,t){let n=await C(e),r=await tn(t);r!==null&&r.equals(n)||await T(t,n)}const rn=`\0ash-pruned-local-sandbox-backend`,an=/[/\\]bindings[/\\]local\.js$/;function on(){return{name:`ash-hosted-sandbox-backend-prune`,load(e){return e===rn?[`export function createLocalSandboxBackend() {`,` throw new Error("The local sandbox backend is pruned from hosted server bundles.");`,`}`,``].join(`
|
|
19
|
-
`):null},resolveId(e){return an.test(e)?rn:null}}}function sn(e){return e===`all`||e===`app`}function cn(e){return z(e)}function z(e){return e===`all`||e===`flow`}function B(e,t){let r=`#ash-route-handler/${t.method??`ALL`} ${t.route}`,i=n(t.handlerPath);e.options.handlers.push({handler:r,method:t.method,route:t.route}),e.options.virtual[r]=[`import handler from ${i};`,`export default handler;`].join(`
|
|
20
|
-
`)}function V(e){return v(e.options.buildDir,`workflow`)}function ln(e,t){let n=y(e,t).replaceAll(`\\`,`/`);return n.startsWith(`.`)?n:`./${n}`}async function un(e,t){let n=v(V(e),`${t.bundleName}-handler.mjs`),r=_(n),i=ln(r,t.bundlePath),a=(t.directHandlers??[]).map(e=>{let t=ln(r,e.bundlePath);return{importSpecifier:t,isOwnBundle:t===i,queuePrefix:e.queuePrefix}});await S(r,{recursive:!0}),await T(n,dn({bundlePath:i,directHandlers:a,runtimeImportSpecifier:t.runtimeImportSpecifier})),e.options.handlers.push({handler:n,route:t.route})}function dn(e){let t=[`// Generated by Ash. Do not edit by hand.`,`import { POST } from ${JSON.stringify(e.bundlePath)};`];if(e.directHandlers.length>0&&e.runtimeImportSpecifier!==void 0){let n=0,r=e.directHandlers.map(e=>{if(e.isOwnBundle)return{...e,binding:`POST`};let t=`__ashWorkflowDirectHandler${n}`;return n+=1,{...e,binding:t}});for(let e of r)e.isOwnBundle||t.push(`import { POST as ${e.binding} } from ${JSON.stringify(e.importSpecifier)};`);t.push(`import { getWorld as __ashGetWorkflowWorld } from ${JSON.stringify(e.runtimeImportSpecifier)};`,``,`try {`,` const __ashWorkflowWorld = __ashGetWorkflowWorld();`,` if (typeof __ashWorkflowWorld?.registerHandler === "function") {`);for(let e of r)t.push(` __ashWorkflowWorld.registerHandler(${JSON.stringify(e.queuePrefix)}, ${e.binding});`);t.push(` }`,`} catch (err) {`,` console.warn("[ash] Failed to register direct workflow queue handlers:", err);`,`}`)}return t.push(``,`export default async ({ req }) => {`,` return await POST(req);`,`};`,``),t.join(`
|
|
21
|
-
`)}function fn(e,t){let r=`#ash-route${t.route}`,i=n(t.modulePath);e.options.handlers.push({handler:r,method:t.method,route:t.route}),e.options.virtual[r]=[`import { ${t.handlerExport} } from ${i};`,`export default async (event) => ${t.handlerExport}(${t.args}, event.req);`].join(`
|
|
22
|
-
`)}async function pn(e,n,r){if(cn(r.surface)){let t=f(),i=new Kt({appRoot:n.appRoot,compiledArtifactsBootstrapPath:n.compiledArtifacts.bootstrapPath,outDir:n.workflowBuildDir,rootDir:t,watch:e.options.dev}),a=Promise.resolve(),o=async()=>{await i.build({nitroStepOutfile:z(r.surface)?v(V(e),`steps.mjs`):void 0,nitroWorkflowOutfile:e.options.dev&&z(r.surface)?v(V(e),`workflows.mjs`):void 0})},s=async()=>{let e=a.then(o);a=e.catch(()=>{}),await e},c=!0;await s(),e.hooks.hook(`build:before`,async()=>{if(c){c=!1;return}await s()}),e.options.dev&&e.hooks.hook(`dev:reload`,async()=>{await s()})}let i=re({appRoot:n.appRoot,dev:e.options.dev});sn(r.surface)&&(B(e,{handlerPath:d(`src/internal/nitro/routes/index.ts`),method:`GET`,route:`/`}),B(e,{handlerPath:d(`src/internal/nitro/routes/health.ts`),method:`GET`,route:te}),fn(e,{args:JSON.stringify({appRoot:i.appRoot}),handlerExport:`handleAgentInfoRequest`,method:`GET`,modulePath:d(`src/internal/nitro/routes/info.ts`),route:ee}),B(e,{handlerPath:d(`src/internal/nitro/routes/workflow-runs.ts`),method:`GET`,route:`/api/runs`}),B(e,{handlerPath:d(`src/internal/nitro/routes/workflow-run.ts`),method:`GET`,route:`/api/runs/:runId`}),B(e,{handlerPath:d(`src/internal/nitro/routes/workflow-run-steps.ts`),method:`GET`,route:`/api/runs/:runId/steps`}),B(e,{handlerPath:d(`src/internal/nitro/routes/workflow-run-events.ts`),method:`GET`,route:`/api/runs/:runId/events`}),ae(e,{artifactsConfig:i,registrations:ne(n)}));let a=V(e),o=z(r.surface)?e.options.dev?v(a,`workflows.mjs`):v(n.workflowBuildDir,`workflows.mjs`):void 0,s=e.options.dev&&o!==void 0?[{bundlePath:o,queuePrefix:`__wkf_workflow_`}]:[],c=s.length>0?t(u(`workflow/runtime`)):void 0;o&&await un(e,{bundleName:`workflows`,bundlePath:o,directHandlers:s,route:`/.well-known/workflow/v1/flow`,runtimeImportSpecifier:c}),e.routing.sync()}function mn(){return`${g}/cron/${he()}`}function hn(e){e.options.vercel!==void 0&&(e.options.vercel.cronHandlerRoute=mn())}function gn(e){return{plugins:[c(),...e]}}function _n(e){e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({name:`ash:nitro-routing-import-specifiers`,transform(e,t){if(t!==`#nitro/virtual/routing`&&t!==`#nitro/virtual/routing-meta`)return null;let n=a(e);return n===e?null:{code:n,map:null}}})})}const vn=`@alinea/generated.@appsignal/nodejs.@aws-sdk/client-s3.@aws-sdk/s3-presigned-post.@blockfrost/blockfrost-js.@highlight-run/node.@huggingface/transformers.@jpg-store/lucid-cardano.@libsql/client.@mikro-orm/core.@mikro-orm/knex.@node-rs/argon2.@node-rs/bcrypt.@prisma/client.@react-pdf/renderer.@sentry/profiling-node.@sparticuz/chromium.@sparticuz/chromium-min.@statsig/statsig-node-core.@swc/core.@xenova/transformers.@zenstackhq/runtime.argon2.autoprefixer.aws-crt.bcrypt.better-sqlite3.canvas.chromadb-default-embed.config.cpu-features.cypress.dd-trace.eslint.express.firebase-admin.htmlrewriter.import-in-the-middle.isolated-vm.jest.jsdom.keyv.libsql.mdx-bundler.mongodb.mongoose.newrelic.next-mdx-remote.next-seo.node-cron.node-pty.node-web-audio-api.onnxruntime-node.oslo.pg.pino.pino-pretty.pino-roll.playwright.playwright-core.postcss.prettier.prisma.puppeteer.puppeteer-core.ravendb.require-in-the-middle.rimraf.sharp.shiki.sqlite3.thread-stream.ts-morph.ts-node.typescript.vscode-oniguruma.webpack.websocket.zeromq`.split(`.`);function yn(e){if(e)return{config:{version:3,framework:{version:h().version}}}}const bn=[`workflow`,`workflow/api`,`workflow/errors`,`workflow/internal/builtins`,`workflow/internal/private`,`workflow/runtime`],xn=Symbol(`ash.workflow-transform-patched`),Sn=[`@napi-rs/keyring`];function Cn(){let e={};for(let t of bn)e[t]=u(t);return e}function wn(e){if(!e&&process.env.VERCEL)return`vercel`}function Tn(e){return e===`all`||e===`app`}function H(e){return e===`all`||e===`flow`}function U(e){return H(e)}function En(e,t){return e.options.dev?v(e.options.buildDir,`workflow`,`steps.mjs`):v(t.workflowBuildDir,`steps.mjs`)}function Dn(e){let t=e.compileResult.manifest.config.build;return[...new Set([...Sn,...vn,...t?.externalDependencies??[]])].filter(e=>e!==p)}function W(e){return e.replaceAll(`\\`,`/`)}function G(e){let t=e.indexOf(`?`),n=e.indexOf(`#`),r=t===-1?n:n===-1?t:Math.min(t,n);return r===-1?e:e.slice(0,r)}function K(e){return e.startsWith(`/@fs/`)?e.slice(4):e}function q(e,t){return t.startsWith(`file://`)?W(K(G(ve(t)))):ue(t)?W(K(G(t))):W(K(G(b(e,t))))}function On(e,t){let n=W(e);return n.startsWith(t)||n.includes(`/.ash/workflow-cache/`)}function J(e){let t=W(e);return process.platform===`win32`?t.toLowerCase():t}function kn(e){let t=/^\s*import\s+(?:.+?\s+from\s+)?["']([^"']+)["'];?\s*$/gm,n=[];for(let r of e.matchAll(t)){let e=r[1];e!==void 0&&n.push(e)}return n}function An(e,t,n){return t.startsWith(`workflow`)?u(t):t.startsWith(`.`)||t.startsWith(`/`)||t.startsWith(`file://`)?q(n===void 0?e:_(q(e,n)),t):null}async function Y(e,t){let n=await C(e,`utf8`),r=new Set;for(let i of kn(n)){let n=An(t,i,e);n!==null&&r.add(J(n))}return r}async function jn(e,t){if(e.options.noExternals===!0)return;let n;try{n=await Y(t,e.options.rootDir)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let r=Array.isArray(e.options.noExternals)?[...e.options.noExternals]:[];e.options.noExternals=[...new Set([...r,...n])]}function Mn(e,t){let n=W(e).replace(/\/$/,``),r=W(t),i=n.toLowerCase(),a=r.toLowerCase();if(a.startsWith(`${i}/`))return r.slice(n.length+1);if(a===i)return`.`;let o=y(n,r).replaceAll(`\\`,`/`);if(o.startsWith(`../`)&&(o=o.split(`/`).filter(e=>e!==`..`).join(`/`)),o.includes(`:`)||o.startsWith(`/`)){let e=r.split(`/`).pop();return e===void 0||e.length===0?`unknown.ts`:e}return o}function Nn(e,t){let n=[t,v(e.options.buildDir,`workflow`)].map(t=>q(e.options.rootDir,t));e.hooks.hook(`rollup:before`,(t,r)=>{Array.isArray(r.plugins)&&r.plugins.unshift({name:`ash:workflow-module-side-effects`,resolveId(t,r){let i=An(e.options.rootDir,t,r)??q(e.options.rootDir,t);return n.some(e=>On(i,e))?{id:i,moduleSideEffects:`no-treeshake`}:null}})})}function Pn(e,t){let n=null,r=async()=>(n===null&&(n=await Y(t.stepEntrypointPath,e.options.rootDir)),n);e.hooks.hook(`build:before`,()=>{n=null}),e.options.dev&&e.hooks.hook(`dev:reload`,()=>{n=null}),e.hooks.hook(`rollup:before`,(t,n)=>{Array.isArray(n.plugins)&&n.plugins.unshift({name:`ash:workflow-step-module-side-effects`,async resolveId(t,n){let i=An(e.options.rootDir,t,n);return i===null||!(await r()).has(J(i))?null:{id:i,moduleSideEffects:`no-treeshake`}}})})}function Fn(e,t){let n=null,r=async()=>(n===null&&(n=await Y(t.stepEntrypointPath,e.options.rootDir)),n);e.hooks.hook(`build:before`,()=>{n=null}),e.options.dev&&e.hooks.hook(`dev:reload`,()=>{n=null}),e.hooks.hook(`rollup:before`,(t,n)=>{Array.isArray(n.plugins)&&n.plugins.unshift({async transform(t,n){let i=await r(),a=q(e.options.rootDir,n);return i.has(J(a))?{code:(await k(Mn(e.options.rootDir,a),t,`step`,a,e.options.rootDir)).code,map:null}:null},name:`ash:workflow-step-transform`})})}function In(e,t){let n=W(t);e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({name:`ash:instrumentation-module-side-effects`,resolveId(e){return W(e)===n?{id:e,moduleSideEffects:`no-treeshake`}:null}})})}function Ln(e,t){let n=W(t);e.hooks.hook(`rollup:before`,(e,t)=>{if(Array.isArray(t.plugins))for(let e of t.plugins){if(typeof e!=`object`||!e)continue;let t=e;if(t.name!==`workflow:transform`||t[xn]===!0||typeof t.transform!=`function`)continue;let r=t.transform;t.transform=function(e,t,...i){return On(t,n)?null:r.call(this,e,t,...i)},t[xn]=!0}})}async function X(e,t,n={}){let r=n.surface??`all`,a=(!t||n.schedules===!0)&&Tn(r)&&e.scheduleRegistrations.length>0,o=wn(t),s=o===`vercel`?on():null,c=s===null?[]:[s],l=gn(c),u=gn(c),f=Dn(e),p=i(e.appRoot,r),h=e.compiledArtifacts.instrumentationPluginPath===void 0?[e.compiledArtifacts.bootstrapPath]:[e.compiledArtifacts.instrumentationPluginPath,e.compiledArtifacts.bootstrapPath];await E(p);let g=await Se({_cli:{command:t?`dev`:`build`},buildDir:p,dev:t,logLevel:t?1:void 0,output:n.outputDir===void 0?void 0:{dir:n.outputDir},preset:o,plugins:h,publicAssets:[],scanDirs:U(r)?[m(`src/execution`)]:void 0,rolldownConfig:l,rollupConfig:u,rootDir:e.appRoot,serverDir:!1,traceDeps:f,vercel:yn(o===`vercel`&&Tn(r))},t?{watch:!0}:void 0);if(await De(p),_n(g),H(r)){let t=Cn();for(let[e,n]of Object.entries(t))g.options.alias[e]=n;Nn(g,e.workflowBuildDir),Ln(g,e.workflowBuildDir)}if(U(r)){let t=En(g,e);Pn(g,{stepEntrypointPath:t}),Fn(g,{stepEntrypointPath:t})}if(e.compiledArtifacts.instrumentationSourcePath!==void 0&&In(g,e.compiledArtifacts.instrumentationSourcePath),t&&H(r)){let t=e.workflowBuildDir,n=new Set([W(v(t,`workflows.mjs`))]);g.hooks.hook(`rollup:before`,(e,t)=>{let r=t.external;t.external=(e,...t)=>{if(n.has(W(e)))return!0;if(typeof r==`function`)return r(e,...t)}})}return a&&(hn(g),oe(g,{artifactsConfig:re({appRoot:e.appRoot,dev:g.options.dev}),dispatchModulePath:d(`src/internal/nitro/routes/schedule-task.ts`),registrations:e.scheduleRegistrations})),await pn(g,e,{surface:r}),U(r)&&await jn(g,En(g,e)),g}function Rn(e){if(typeof e!=`string`||e.length===0)return`unknown`;let t=e.toLowerCase();return t===`slack`||t.includes(`slack`)?`slack`:t===`http`?`http`:t.includes(`webhook`)?`webhook`:`unknown`}function zn(e){let{manifest:t}=e;return{kind:`vercel-ash-agent-summary`,schemaVersion:2,generatorVersion:e.generatorVersion??h().version,agent:{name:t.config.name,description:t.config.description,modelId:t.config.model.id},instructions:t.instructions?Hn(t.instructions):null,schedules:t.schedules.map(Un),tools:t.tools.map(Wn),skills:t.skills.map(Gn),connections:t.connections.map(Kn),channels:t.channels.filter(Vn).map(qn),sandbox:t.sandbox===null?null:{logicalPath:t.sandbox.logicalPath},subagents:t.subagents.map(Jn),diagnostics:{errors:t.diagnosticsSummary.errors,warnings:t.diagnosticsSummary.warnings}}}async function Bn(e){let t=zn({generatorVersion:e.generatorVersion,manifest:e.manifest}),n=v(e.appRoot,`.ash/agent-summary.json`);return await S(_(n),{recursive:!0}),await T(n,`${JSON.stringify(t,null,2)}\n`),n}function Vn(e){return e.kind===`channel`}function Hn(e){return{logicalPath:e.logicalPath,sourceKind:e.sourceKind,markdown:e.markdown}}function Un(e){return{name:e.name,cron:e.cron,logicalPath:e.logicalPath}}function Wn(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}function Gn(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath,sourceKind:e.sourceKind}}function Kn(e){let t={name:e.connectionName,description:e.description,url:e.url,logicalPath:e.logicalPath,type:`mcp`};return e.vercelConnect===void 0?t:{...t,vercelConnect:{connector:e.vercelConnect.connector}}}function qn(e){let t={name:e.name,method:e.method,urlPath:e.urlPath,type:Rn(e.adapterKind),logicalPath:e.logicalPath};return e.adapterKind===void 0?t:{...t,adapterKind:e.adapterKind}}function Jn(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}function Yn(){let e=process.env.VERCEL?.trim(),t=process.env.VERCEL_DEPLOYMENT_ID?.trim();return typeof e==`string`&&e.length>0&&typeof t==`string`&&t.length>0}async function Xn(e){return Yn()?(await se(e),!0):!1}function Zn(e){return e.replace(/[\\/]+$/,``)}async function Qn(e){try{return JSON.parse(await C(v(e,`functions`,`__server.func`,`.vc-config.json`),`utf8`)).runtime}catch{return}}async function $n(e){let t=new Kt({appRoot:e.appRoot,compiledArtifactsBootstrapPath:e.compiledArtifactsBootstrapPath,outDir:e.workflowBuildDir,rootDir:f(),watch:!1}),n=await Qn(e.outputDir);await t.buildVercelOutput({flowNitroOutputDir:e.flowNitroOutputDir,outputDir:e.outputDir,runtime:n})}async function er(e){let t=Zn(e.options.output.dir);return await E(t),await Ce(e),await be(e),await we(e),await ye(e),await De(t),t}async function tr(e,t){let n=await X(e,!1,{outputDir:r(e.appRoot,t),surface:t});try{return await er(n)}finally{await n.close()}}async function nr(e){let t=await ie(e);if(!process.env.VERCEL){let e=await X(t,!1);try{let n=await er(e);return await Bn({manifest:t.compileResult.manifest,appRoot:t.appRoot}),n}finally{await e.close()}}let n=await X(t,!1,{surface:`app`});try{let e=await er(n);await Xn({appRoot:t.appRoot,log(e){console.log(e)}});let r=await tr(t,`flow`);return await $n({appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifacts.bootstrapPath,flowNitroOutputDir:r,outputDir:e,workflowBuildDir:t.workflowBuildDir}),await Bn({manifest:t.compileResult.manifest,appRoot:t.appRoot}),e}finally{await n.close()}}const Z=65535,Q=`WORKFLOW_LOCAL_BASE_URL`,$=`PORT`,rr=new Set([`[::]`,`::`,`0.0.0.0`]);function ir(e){let t=new URL(e);return rr.has(t.hostname)?(t.hostname=`127.0.0.1`,t.toString()):e}function ar(e){return e instanceof Error&&`code`in e&&e.code===`EADDRINUSE`}function or(e){let t=typeof e==`string`?Number(e):e??3e3;if(!Number.isInteger(t)||t<0||t>Z)throw Error(`Invalid development server port "${String(e)}". Expected an integer between 0 and ${Z}.`);return t}function sr(){let e=process.env[$];if(e===void 0||e.trim()===``)return;let t=Number(e);if(!Number.isInteger(t)||t<0||t>Z)throw Error(`Invalid ${$} environment variable "${e}". Expected an integer between 0 and ${Z}.`);return t}function cr(e){let t=or(e.port);if(t===0||!e.retryOnAddressInUse)return[t];let n=[];for(let e=0;e<10;e+=1){let r=t+e;if(r>65535)break;n.push(r)}return n}function lr(e){let t=process.env[Q],n=process.env[$],r=new URL(ir(e));return process.env[Q]=r.origin,r.port&&(process.env[$]=r.port),()=>{t===void 0?delete process.env[Q]:process.env[Q]=t,n===void 0?delete process.env[$]:process.env[$]=n}}function ur(e){let t=()=>{};return e.once(`error`,t),()=>{e.off(`error`,t)}}function dr(e){let t=e.upgrade.bind(e);e.upgrade=async(e,n,r)=>{let i=ur(n);try{await t(e,n,r)}catch{n.destroyed||n.destroy()}finally{i()}}}async function fr(e){let t=cr({port:e.port,retryOnAddressInUse:e.retryOnAddressInUse}),n;for(let r of t){let t=e.devServer.listen({hostname:e.host,port:r,silent:!0});try{return await t.ready(),t}catch(r){if(n=r,await t.close().catch(()=>{}),!ar(r)||!e.retryOnAddressInUse)throw r}}throw Error(`Failed to start Nitro dev server after ${t.length} attempts. Tried ports ${t.join(`, `)}.`,{cause:n})}async function pr(e,t={}){let n=t.schedules===!0,r=await ie(e);await se({appRoot:r.appRoot,log:e=>console.log(e)});let i=await X(r,!0,{schedules:n}),a=xe(i);dr(a);let o=t.host??i.options.devServer.hostname,s=t.port??sr(),c=s??i.options.devServer.port,l=s===void 0,u;try{let e=await fr({devServer:a,host:o,port:c,retryOnAddressInUse:l});if(!e.url)throw Error(`Nitro dev server did not expose a URL.`);u=lr(e.url),await Ce(i),await ye(i);let{startAuthoredSourceWatcher:t}=await import(`./dev-authored-source-watcher-j7YWh2Gx.js`),s=await t({nitro:i,preparedHost:r,schedulesEnabled:n}),d=u;if(d===void 0)throw Error(`Workflow local queue environment was not initialized.`);return{async close(){try{await s.close(),await a.close(),await i.close()}finally{d()}},url:ir(e.url)}}catch(e){throw u?.(),await a.close().catch(()=>{}),await i.close().catch(()=>{}),e}}var mr=e({buildHost:()=>hr,startHost:()=>gr});async function hr(e){return await nr(e)}async function gr(e,t={}){return await pr(e,t)}export{gr as n,mr as t};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var e;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(e||={});var t;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(t||={});const n=e.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),r=e=>{switch(typeof e){case`undefined`:return n.undefined;case`string`:return n.string;case`number`:return Number.isNaN(e)?n.nan:n.number;case`boolean`:return n.boolean;case`function`:return n.function;case`bigint`:return n.bigint;case`symbol`:return n.symbol;case`object`:return Array.isArray(e)?n.array:e===null?n.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?n.promise:typeof Map<`u`&&e instanceof Map?n.map:typeof Set<`u`&&e instanceof Set?n.set:typeof Date<`u`&&e instanceof Date?n.date:n.object;default:return n.unknown}},i=e.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]);var a=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(e){if(!(e instanceof t))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t=Object.create(null),n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};a.create=e=>new a(e);const o=(t,r)=>{let a;switch(t.code){case i.invalid_type:a=t.received===n.undefined?`Required`:`Expected ${t.expected}, received ${t.received}`;break;case i.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(t.expected,e.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:a=`Unrecognized key(s) in object: ${e.joinValues(t.keys,`, `)}`;break;case i.invalid_union:a=`Invalid input`;break;case i.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${e.joinValues(t.options)}`;break;case i.invalid_enum_value:a=`Invalid enum value. Expected ${e.joinValues(t.options)}, received '${t.received}'`;break;case i.invalid_arguments:a=`Invalid function arguments`;break;case i.invalid_return_type:a=`Invalid function return type`;break;case i.invalid_date:a=`Invalid date`;break;case i.invalid_string:typeof t.validation==`object`?`includes`in t.validation?(a=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position==`number`&&(a=`${a} at one or more positions greater than or equal to ${t.validation.position}`)):`startsWith`in t.validation?a=`Invalid input: must start with "${t.validation.startsWith}"`:`endsWith`in t.validation?a=`Invalid input: must end with "${t.validation.endsWith}"`:e.assertNever(t.validation):a=t.validation===`regex`?`Invalid`:`Invalid ${t.validation}`;break;case i.too_small:a=t.type===`array`?`Array must contain ${t.exact?`exactly`:t.inclusive?`at least`:`more than`} ${t.minimum} element(s)`:t.type===`string`?`String must contain ${t.exact?`exactly`:t.inclusive?`at least`:`over`} ${t.minimum} character(s)`:t.type===`number`||t.type===`bigint`?`Number must be ${t.exact?`exactly equal to `:t.inclusive?`greater than or equal to `:`greater than `}${t.minimum}`:t.type===`date`?`Date must be ${t.exact?`exactly equal to `:t.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(t.minimum))}`:`Invalid input`;break;case i.too_big:a=t.type===`array`?`Array must contain ${t.exact?`exactly`:t.inclusive?`at most`:`less than`} ${t.maximum} element(s)`:t.type===`string`?`String must contain ${t.exact?`exactly`:t.inclusive?`at most`:`under`} ${t.maximum} character(s)`:t.type===`number`?`Number must be ${t.exact?`exactly`:t.inclusive?`less than or equal to`:`less than`} ${t.maximum}`:t.type===`bigint`?`BigInt must be ${t.exact?`exactly`:t.inclusive?`less than or equal to`:`less than`} ${t.maximum}`:t.type===`date`?`Date must be ${t.exact?`exactly`:t.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(t.maximum))}`:`Invalid input`;break;case i.custom:a=`Invalid input`;break;case i.invalid_intersection_types:a=`Intersection results could not be merged`;break;case i.not_multiple_of:a=`Number must be a multiple of ${t.multipleOf}`;break;case i.not_finite:a=`Number must be finite`;break;default:a=r.defaultError,e.assertNever(t)}return{message:a}};let s=o;function c(){return s}const l=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function u(e,t){let n=c(),r=l({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===o?void 0:o].filter(e=>!!e)});e.common.issues.push(r)}var d=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return f;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return f;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};const f=Object.freeze({status:`aborted`}),p=e=>({status:`dirty`,value:e}),m=e=>({status:`valid`,value:e}),h=e=>e.status===`aborted`,g=e=>e.status===`dirty`,_=e=>e.status===`valid`,v=e=>typeof Promise<`u`&&e instanceof Promise;var y;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(y||={});var b=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const ee=(e,t)=>{if(_(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new a(e.common.issues);return this._error=t,this._error}}};function x(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var S=class{get description(){return this._def.description}_getType(e){return r(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new d,ctx:{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(v(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)};return ee(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return _(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>_(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},i=this._parse({data:e,path:n.path,parent:n});return ee(n,await(v(i)?i:Promise.resolve(i)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let a=e(t),o=()=>r.addIssue({code:i.custom,...n(t)});return typeof Promise<`u`&&a instanceof Promise?a.then(e=>e?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new K({schema:this,typeName:$.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return q.create(this,this._def)}nullable(){return J.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return P.create(this)}promise(){return G.create(this,this._def)}or(e){return L.create([this,e],this._def)}and(e){return z.create(this,e,this._def)}transform(e){return new K({...x(this._def),schema:this,typeName:$.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Y({...x(this._def),innerType:this,defaultValue:t,typeName:$.ZodDefault})}brand(){return new Ne({typeName:$.ZodBranded,type:this,...x(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new X({...x(this._def),innerType:this,catchValue:t,typeName:$.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Pe.create(this,e)}readonly(){return Q.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const te=/^c[^\s-]{8,}$/i,ne=/^[0-9a-z]+$/,re=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ie=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ae=/^[a-z0-9_-]{21}$/i,oe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,se=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ce=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let le;const ue=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,de=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,fe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,pe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,me=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,he=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ge=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,_e=RegExp(`^${ge}$`);function ve(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function ye(e){return RegExp(`^${ve(e)}$`)}function be(e){let t=`${ge}T${ve(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function xe(e,t){return!!((t===`v4`||!t)&&ue.test(e)||(t===`v6`||!t)&&fe.test(e))}function Se(e,t){if(!oe.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Ce(e,t){return!!((t===`v4`||!t)&&de.test(e)||(t===`v6`||!t)&&pe.test(e))}var C=class t extends S{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==n.string){let e=this._getOrReturnCtx(t);return u(e,{code:i.invalid_type,expected:n.string,received:e.parsedType}),f}let r=new d,a;for(let n of this._def.checks)if(n.kind===`min`)t.data.length<n.value&&(a=this._getOrReturnCtx(t,a),u(a,{code:i.too_small,minimum:n.value,type:`string`,inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind===`max`)t.data.length>n.value&&(a=this._getOrReturnCtx(t,a),u(a,{code:i.too_big,maximum:n.value,type:`string`,inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind===`length`){let e=t.data.length>n.value,o=t.data.length<n.value;(e||o)&&(a=this._getOrReturnCtx(t,a),e?u(a,{code:i.too_big,maximum:n.value,type:`string`,inclusive:!0,exact:!0,message:n.message}):o&&u(a,{code:i.too_small,minimum:n.value,type:`string`,inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind===`email`)ce.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`email`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`emoji`)le||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),le.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`emoji`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`uuid`)ie.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`uuid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`nanoid`)ae.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`nanoid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`cuid`)te.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`cuid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`cuid2`)ne.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`cuid2`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`ulid`)re.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`ulid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`url`)try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),u(a,{validation:`url`,code:i.invalid_string,message:n.message}),r.dirty()}else n.kind===`regex`?(n.regex.lastIndex=0,n.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`regex`,code:i.invalid_string,message:n.message}),r.dirty())):n.kind===`trim`?t.data=t.data.trim():n.kind===`includes`?t.data.includes(n.value,n.position)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),r.dirty()):n.kind===`toLowerCase`?t.data=t.data.toLowerCase():n.kind===`toUpperCase`?t.data=t.data.toUpperCase():n.kind===`startsWith`?t.data.startsWith(n.value)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind===`endsWith`?t.data.endsWith(n.value)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind===`datetime`?be(n).test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:`datetime`,message:n.message}),r.dirty()):n.kind===`date`?_e.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:`date`,message:n.message}),r.dirty()):n.kind===`time`?ye(n).test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:i.invalid_string,validation:`time`,message:n.message}),r.dirty()):n.kind===`duration`?se.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`duration`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`ip`?xe(t.data,n.version)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`ip`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`jwt`?Se(t.data,n.alg)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`jwt`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`cidr`?Ce(t.data,n.version)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`cidr`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`base64`?me.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`base64`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`base64url`?he.test(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{validation:`base64url`,code:i.invalid_string,message:n.message}),r.dirty()):e.assertNever(n);return{status:r.value,value:t.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:i.invalid_string,...y.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:`email`,...y.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...y.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...y.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...y.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...y.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...y.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...y.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...y.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...y.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...y.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...y.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...y.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...y.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...y.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...y.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...y.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...y.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...y.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...y.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...y.errToObj(t)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};C.create=e=>new C({checks:[],typeName:$.ZodString,coerce:e?.coerce??!1,...x(e)});function we(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var w=class t extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==n.number){let e=this._getOrReturnCtx(t);return u(e,{code:i.invalid_type,expected:n.number,received:e.parsedType}),f}let r,a=new d;for(let n of this._def.checks)n.kind===`int`?e.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:i.invalid_type,expected:`integer`,received:`float`,message:n.message}),a.dirty()):n.kind===`min`?(n.inclusive?t.data<n.value:t.data<=n.value)&&(r=this._getOrReturnCtx(t,r),u(r,{code:i.too_small,minimum:n.value,type:`number`,inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind===`max`?(n.inclusive?t.data>n.value:t.data>=n.value)&&(r=this._getOrReturnCtx(t,r),u(r,{code:i.too_big,maximum:n.value,type:`number`,inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind===`multipleOf`?we(t.data,n.value)!==0&&(r=this._getOrReturnCtx(t,r),u(r,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind===`finite`?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:i.not_finite,message:n.message}),a.dirty()):e.assertNever(n);return{status:a.value,value:t.data}}gte(e,t){return this.setLimit(`min`,e,!0,y.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,y.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,y.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,y.toString(t))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:y.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:`int`,message:y.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:y.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:y.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:y.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:y.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(t=>t.kind===`int`||t.kind===`multipleOf`&&e.isInteger(t.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};w.create=e=>new w({checks:[],typeName:$.ZodNumber,coerce:e?.coerce||!1,...x(e)});var T=class t extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==n.bigint)return this._getInvalidInput(t);let r,a=new d;for(let n of this._def.checks)n.kind===`min`?(n.inclusive?t.data<n.value:t.data<=n.value)&&(r=this._getOrReturnCtx(t,r),u(r,{code:i.too_small,type:`bigint`,minimum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind===`max`?(n.inclusive?t.data>n.value:t.data>=n.value)&&(r=this._getOrReturnCtx(t,r),u(r,{code:i.too_big,type:`bigint`,maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind===`multipleOf`?t.data%n.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),u(r,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):e.assertNever(n);return{status:a.value,value:t.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.bigint,received:t.parsedType}),f}gte(e,t){return this.setLimit(`min`,e,!0,y.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,y.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,y.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,y.toString(t))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:y.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:y.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};T.create=e=>new T({checks:[],typeName:$.ZodBigInt,coerce:e?.coerce??!1,...x(e)});var E=class extends S{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==n.boolean){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.boolean,received:t.parsedType}),f}return m(e.data)}};E.create=e=>new E({typeName:$.ZodBoolean,coerce:e?.coerce||!1,...x(e)});var D=class t extends S{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==n.date){let e=this._getOrReturnCtx(t);return u(e,{code:i.invalid_type,expected:n.date,received:e.parsedType}),f}if(Number.isNaN(t.data.getTime()))return u(this._getOrReturnCtx(t),{code:i.invalid_date}),f;let r=new d,a;for(let n of this._def.checks)n.kind===`min`?t.data.getTime()<n.value&&(a=this._getOrReturnCtx(t,a),u(a,{code:i.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:`date`}),r.dirty()):n.kind===`max`?t.data.getTime()>n.value&&(a=this._getOrReturnCtx(t,a),u(a,{code:i.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:`date`}),r.dirty()):e.assertNever(n);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:y.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:y.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};D.create=e=>new D({checks:[],coerce:e?.coerce||!1,typeName:$.ZodDate,...x(e)});var O=class extends S{_parse(e){if(this._getType(e)!==n.symbol){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.symbol,received:t.parsedType}),f}return m(e.data)}};O.create=e=>new O({typeName:$.ZodSymbol,...x(e)});var k=class extends S{_parse(e){if(this._getType(e)!==n.undefined){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.undefined,received:t.parsedType}),f}return m(e.data)}};k.create=e=>new k({typeName:$.ZodUndefined,...x(e)});var A=class extends S{_parse(e){if(this._getType(e)!==n.null){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.null,received:t.parsedType}),f}return m(e.data)}};A.create=e=>new A({typeName:$.ZodNull,...x(e)});var j=class extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return m(e.data)}};j.create=e=>new j({typeName:$.ZodAny,...x(e)});var M=class extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return m(e.data)}};M.create=e=>new M({typeName:$.ZodUnknown,...x(e)});var N=class extends S{_parse(e){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.never,received:t.parsedType}),f}};N.create=e=>new N({typeName:$.ZodNever,...x(e)});var Te=class extends S{_parse(e){if(this._getType(e)!==n.undefined){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.void,received:t.parsedType}),f}return m(e.data)}};Te.create=e=>new Te({typeName:$.ZodVoid,...x(e)});var P=class e extends S{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==n.array)return u(t,{code:i.invalid_type,expected:n.array,received:t.parsedType}),f;if(a.exactLength!==null){let e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(u(t,{code:e?i.too_big:i.too_small,minimum:n?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(u(t,{code:i.too_small,minimum:a.minLength.value,type:`array`,inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(u(t,{code:i.too_big,maximum:a.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>a.type._parseAsync(new b(t,e,t.path,n)))).then(e=>d.mergeArray(r,e));let o=[...t.data].map((e,n)=>a.type._parseSync(new b(t,e,t.path,n)));return d.mergeArray(r,o)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:y.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:y.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:y.toString(n)}})}nonempty(e){return this.min(1,e)}};P.create=(e,t)=>new P({type:e,minLength:null,maxLength:null,exactLength:null,typeName:$.ZodArray,...x(t)});function F(e){if(e instanceof I){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=q.create(F(r))}return new I({...e._def,shape:()=>t})}else if(e instanceof P)return new P({...e._def,type:F(e.element)});else if(e instanceof q)return q.create(F(e.unwrap()));else if(e instanceof J)return J.create(F(e.unwrap()));else if(e instanceof B)return B.create(e.items.map(e=>F(e)));else return e}var I=class t extends S{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=e.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(e){if(this._getType(e)!==n.object){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),f}let{status:t,ctx:r}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof N&&this._def.unknownKeys===`strip`))for(let e in r.data)o.includes(e)||s.push(e);let c=[];for(let e of o){let t=a[e],n=r.data[e];c.push({key:{status:`valid`,value:e},value:t._parse(new b(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof N){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of s)c.push({key:{status:`valid`,value:e},value:{status:`valid`,value:r.data[e]}});else if(e===`strict`)s.length>0&&(u(r,{code:i.unrecognized_keys,keys:s}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of s){let n=r.data[t];c.push({key:{status:`valid`,value:t},value:e._parse(new b(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of c){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>d.mergeObjectSync(t,e)):d.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new t({...this._def,unknownKeys:`strict`,...e===void 0?{}:{errorMap:(t,n)=>{let r=this._def.errorMap?.(t,n).message??n.defaultError;return t.code===`unrecognized_keys`?{message:y.errToObj(e).message??r}:{message:r}}}})}strip(){return new t({...this._def,unknownKeys:`strip`})}passthrough(){return new t({...this._def,unknownKeys:`passthrough`})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new t({...this._def,catchall:e})}pick(n){let r={};for(let t of e.objectKeys(n))n[t]&&this.shape[t]&&(r[t]=this.shape[t]);return new t({...this._def,shape:()=>r})}omit(n){let r={};for(let t of e.objectKeys(this.shape))n[t]||(r[t]=this.shape[t]);return new t({...this._def,shape:()=>r})}deepPartial(){return F(this)}partial(n){let r={};for(let t of e.objectKeys(this.shape)){let e=this.shape[t];n&&!n[t]?r[t]=e:r[t]=e.optional()}return new t({...this._def,shape:()=>r})}required(n){let r={};for(let t of e.objectKeys(this.shape))if(n&&!n[t])r[t]=this.shape[t];else{let e=this.shape[t];for(;e instanceof q;)e=e._def.innerType;r[t]=e}return new t({...this._def,shape:()=>r})}keyof(){return Me(e.objectKeys(this.shape))}};I.create=(e,t)=>new I({shape:()=>e,unknownKeys:`strip`,catchall:N.create(),typeName:$.ZodObject,...x(t)}),I.strictCreate=(e,t)=>new I({shape:()=>e,unknownKeys:`strict`,catchall:N.create(),typeName:$.ZodObject,...x(t)}),I.lazycreate=(e,t)=>new I({shape:e,unknownKeys:`strip`,catchall:N.create(),typeName:$.ZodObject,...x(t)});var L=class extends S{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new a(e.ctx.common.issues));return u(t,{code:i.invalid_union,unionErrors:n}),f}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let o=r.map(e=>new a(e));return u(t,{code:i.invalid_union,unionErrors:o}),f}}get options(){return this._def.options}};L.create=(e,t)=>new L({options:e,typeName:$.ZodUnion,...x(t)});const R=t=>t instanceof V?R(t.schema):t instanceof K?R(t.innerType()):t instanceof H?[t.value]:t instanceof U?t.options:t instanceof W?e.objectValues(t.enum):t instanceof Y?R(t._def.innerType):t instanceof k?[void 0]:t instanceof A?[null]:t instanceof q?[void 0,...R(t.unwrap())]:t instanceof J?[null,...R(t.unwrap())]:t instanceof Ne||t instanceof Q?R(t.unwrap()):t instanceof X?R(t._def.innerType):[];var Ee=class e extends S{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.object)return u(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),f;let r=this.discriminator,a=t.data[r],o=this.optionsMap.get(a);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(u(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),f)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=R(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:$.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...x(r)})}};function De(t,i){let a=r(t),o=r(i);if(t===i)return{valid:!0,data:t};if(a===n.object&&o===n.object){let n=e.objectKeys(i),r=e.objectKeys(t).filter(e=>n.indexOf(e)!==-1),a={...t,...i};for(let e of r){let n=De(t[e],i[e]);if(!n.valid)return{valid:!1};a[e]=n.data}return{valid:!0,data:a}}else if(a===n.array&&o===n.array){if(t.length!==i.length)return{valid:!1};let e=[];for(let n=0;n<t.length;n++){let r=t[n],a=i[n],o=De(r,a);if(!o.valid)return{valid:!1};e.push(o.data)}return{valid:!0,data:e}}else if(a===n.date&&o===n.date&&+t==+i)return{valid:!0,data:t};else return{valid:!1}}var z=class extends S{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(h(e)||h(r))return f;let a=De(e.value,r.value);return a.valid?((g(e)||g(r))&&t.dirty(),{status:t.value,value:a.data}):(u(n,{code:i.invalid_intersection_types}),f)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};z.create=(e,t,n)=>new z({left:e,right:t,typeName:$.ZodIntersection,...x(n)});var B=class e extends S{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.array)return u(r,{code:i.invalid_type,expected:n.array,received:r.parsedType}),f;if(r.data.length<this._def.items.length)return u(r,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),f;!this._def.rest&&r.data.length>this._def.items.length&&(u(r,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let a=[...r.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new b(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(a).then(e=>d.mergeArray(t,e)):d.mergeArray(t,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};B.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new B({items:e,typeName:$.ZodTuple,rest:null,...x(t)})};var Oe=class e extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.object)return u(r,{code:i.invalid_type,expected:n.object,received:r.parsedType}),f;let a=[],o=this._def.keyType,s=this._def.valueType;for(let e in r.data)a.push({key:o._parse(new b(r,e,r.path,e)),value:s._parse(new b(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?d.mergeObjectAsync(t,a):d.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof S?new e({keyType:t,valueType:n,typeName:$.ZodRecord,...x(r)}):new e({keyType:C.create(),valueType:t,typeName:$.ZodRecord,...x(n)})}},ke=class extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.map)return u(r,{code:i.invalid_type,expected:n.map,received:r.parsedType}),f;let a=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([e,t],n)=>({key:a._parse(new b(r,e,r.path,[n,`key`])),value:o._parse(new b(r,t,r.path,[n,`value`]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of s){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return f;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of s){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return f;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};ke.create=(e,t,n)=>new ke({valueType:t,keyType:e,typeName:$.ZodMap,...x(n)});var Ae=class e extends S{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.set)return u(r,{code:i.invalid_type,expected:n.set,received:r.parsedType}),f;let a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(u(r,{code:i.too_small,minimum:a.minSize.value,type:`set`,inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(u(r,{code:i.too_big,maximum:a.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());let o=this._def.valueType;function s(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return f;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let c=[...r.data.values()].map((e,t)=>o._parse(new b(r,e,r.path,t)));return r.common.async?Promise.all(c).then(e=>s(e)):s(c)}min(t,n){return new e({...this._def,minSize:{value:t,message:y.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:y.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ae.create=(e,t)=>new Ae({valueType:e,minSize:null,maxSize:null,typeName:$.ZodSet,...x(t)});var je=class e extends S{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.function)return u(t,{code:i.invalid_type,expected:n.function,received:t.parsedType}),f;function r(e,n){return l({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,c(),o].filter(e=>!!e),issueData:{code:i.invalid_arguments,argumentsError:n}})}function s(e,n){return l({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,c(),o].filter(e=>!!e),issueData:{code:i.invalid_return_type,returnTypeError:n}})}let d={errorMap:t.common.contextualErrorMap},p=t.data;if(this._def.returns instanceof G){let e=this;return m(async function(...t){let n=new a([]),i=await e._def.args.parseAsync(t,d).catch(e=>{throw n.addIssue(r(t,e)),n}),o=await Reflect.apply(p,this,i);return await e._def.returns._def.type.parseAsync(o,d).catch(e=>{throw n.addIssue(s(o,e)),n})})}else{let e=this;return m(function(...t){let n=e._def.args.safeParse(t,d);if(!n.success)throw new a([r(t,n.error)]);let i=Reflect.apply(p,this,n.data),o=e._def.returns.safeParse(i,d);if(!o.success)throw new a([s(i,o.error)]);return o.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:B.create(t).rest(M.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||B.create([]).rest(M.create()),returns:n||M.create(),typeName:$.ZodFunction,...x(r)})}},V=class extends S{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};V.create=(e,t)=>new V({getter:e,typeName:$.ZodLazy,...x(t)});var H=class extends S{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),f}return{status:`valid`,value:e.data}}get value(){return this._def.value}};H.create=(e,t)=>new H({value:e,typeName:$.ZodLiteral,...x(t)});function Me(e,t){return new U({values:e,typeName:$.ZodEnum,...x(t)})}var U=class t extends S{_parse(t){if(typeof t.data!=`string`){let n=this._getOrReturnCtx(t),r=this._def.values;return u(n,{expected:e.joinValues(r),received:n.parsedType,code:i.invalid_type}),f}if(this._cache||=new Set(this._def.values),!this._cache.has(t.data)){let e=this._getOrReturnCtx(t),n=this._def.values;return u(e,{received:e.data,code:i.invalid_enum_value,options:n}),f}return m(t.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(t=>!e.includes(t)),{...this._def,...n})}};U.create=Me;var W=class extends S{_parse(t){let r=e.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==n.string&&a.parsedType!==n.number){let t=e.objectValues(r);return u(a,{expected:e.joinValues(t),received:a.parsedType,code:i.invalid_type}),f}if(this._cache||=new Set(e.getValidEnumValues(this._def.values)),!this._cache.has(t.data)){let t=e.objectValues(r);return u(a,{received:a.data,code:i.invalid_enum_value,options:t}),f}return m(t.data)}get enum(){return this._def.values}};W.create=(e,t)=>new W({values:e,typeName:$.ZodNativeEnum,...x(t)});var G=class extends S{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==n.promise&&t.common.async===!1?(u(t,{code:i.invalid_type,expected:n.promise,received:t.parsedType}),f):m((t.parsedType===n.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};G.create=(e,t)=>new G({type:e,typeName:$.ZodPromise,...x(t)});var K=class extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:e=>{u(r,e),e.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type===`preprocess`){let e=i.transform(r.data,a);if(r.common.async)return Promise.resolve(e).then(async e=>{if(n.value===`aborted`)return f;let t=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return t.status===`aborted`?f:t.status===`dirty`||n.value===`dirty`?p(t.value):t});{if(n.value===`aborted`)return f;let t=this._def.schema._parseSync({data:e,path:r.path,parent:r});return t.status===`aborted`?f:t.status===`dirty`||n.value===`dirty`?p(t.value):t}}if(i.type===`refinement`){let e=e=>{let t=i.refinement(e,a);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(r.common.async===!1){let t=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return t.status===`aborted`?f:(t.status===`dirty`&&n.dirty(),e(t.value),{status:n.value,value:t.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(t=>t.status===`aborted`?f:(t.status===`dirty`&&n.dirty(),e(t.value).then(()=>({status:n.value,value:t.value}))))}if(i.type===`transform`)if(r.common.async===!1){let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!_(e))return f;let t=i.transform(e.value,a);if(t instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:n.value,value:t}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>_(e)?Promise.resolve(i.transform(e.value,a)).then(e=>({status:n.value,value:e})):f);e.assertNever(i)}};K.create=(e,t,n)=>new K({schema:e,typeName:$.ZodEffects,effect:t,...x(n)}),K.createWithPreprocess=(e,t,n)=>new K({schema:t,effect:{type:`preprocess`,transform:e},typeName:$.ZodEffects,...x(n)});var q=class extends S{_parse(e){return this._getType(e)===n.undefined?m(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};q.create=(e,t)=>new q({innerType:e,typeName:$.ZodOptional,...x(t)});var J=class extends S{_parse(e){return this._getType(e)===n.null?m(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};J.create=(e,t)=>new J({innerType:e,typeName:$.ZodNullable,...x(t)});var Y=class extends S{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===n.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Y.create=(e,t)=>new Y({innerType:e,typeName:$.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...x(t)});var X=class extends S{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return v(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new a(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new a(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};X.create=(e,t)=>new X({innerType:e,typeName:$.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...x(t)});var Z=class extends S{_parse(e){if(this._getType(e)!==n.nan){let t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.nan,received:t.parsedType}),f}return{status:`valid`,value:e.data}}};Z.create=e=>new Z({typeName:$.ZodNaN,...x(e)});var Ne=class extends S{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Pe=class e extends S{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?f:e.status===`dirty`?(t.dirty(),p(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?f:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:$.ZodPipeline})}},Q=class extends S{_parse(e){let t=this._def.innerType._parse(e),n=e=>(_(e)&&(e.value=Object.freeze(e.value)),e);return v(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Q.create=(e,t)=>new Q({innerType:e,typeName:$.ZodReadonly,...x(t)}),I.lazycreate;var $;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})($||={}),C.create,w.create,Z.create,T.create,E.create,D.create,O.create,k.create,A.create,j.create,M.create,N.create,Te.create,P.create,I.create,I.strictCreate,L.create,Ee.create,z.create,B.create,Oe.create,ke.create,Ae.create,je.create,V.create,H.create,U.create,W.create,G.create,K.create,q.create,J.create,K.createWithPreprocess,Pe.create;var Fe=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function Ie(e){}function Le(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=Ie,onError:n=Ie,onRetry:r=Ie,onComment:i}=e,a=[],o=!0,s,c=``,l=0,u;function d(e){if(o&&(o=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),a.length===0){let t=f(e);t!==``&&a.push(t);return}if(e.indexOf(`
|
|
2
|
-
`)===-1&&e.indexOf(`\r`)===-1){a.push(e);return}a.push(e);let t=a.join(``);a.length=0;let n=f(t);n!==``&&a.push(n)}function f(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
|
|
3
|
-
`,n);for(;r!==-1;){if(n===r){l>0&&t({id:s,event:u,data:c}),s=void 0,c=``,l=0,u=void 0,n=r+1,r=e.indexOf(`
|
|
4
|
-
`,n);continue}let i=e.charCodeAt(n);if(Re(e,n,i)){let i=e.charCodeAt(n+5)===32?n+6:n+5,a=e.slice(i,r);if(l===0&&e.charCodeAt(r+1)===10){t({id:s,event:u,data:a}),s=void 0,c=``,u=void 0,n=r+2,r=e.indexOf(`
|
|
5
|
-
`,n);continue}c=l===0?a:`${c}
|
|
6
|
-
${a}`,l++}else ze(e,n,i)?u=e.slice(e.charCodeAt(n+6)===32?n+7:n+6,r)||void 0:p(e,n,r);n=r+1,r=e.indexOf(`
|
|
7
|
-
`,n)}return e.slice(n)}for(;n<e.length;){let t=e.indexOf(`\r`,n),r=e.indexOf(`
|
|
8
|
-
`,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;p(e,n,i),n=i+1,e.charCodeAt(n-1)===13&&e.charCodeAt(n)===10&&n++}return e.slice(n)}function p(e,t,n){if(t===n){h();return}let r=e.charCodeAt(t);if(Re(e,t,r)){let r=e.charCodeAt(t+5)===32?t+6:t+5,i=e.slice(r,n);c=l===0?i:`${c}
|
|
9
|
-
${i}`,l++;return}if(ze(e,t,r)){u=e.slice(e.charCodeAt(t+6)===32?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===32?t+4:t+3,n);s=r.includes(`\0`)?void 0:r;return}if(r===58){i&&i(e.slice(t,n).slice(e.charCodeAt(t+1)===32?2:1));return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){m(a,``,a);return}let d=a.slice(0,o),f=a.charCodeAt(o+1)===32?2:1;m(d,a.slice(o+f),a)}function m(e,t,i){switch(e){case`event`:u=t||void 0;break;case`data`:c=l===0?t:`${c}
|
|
10
|
-
${t}`,l++;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new Fe(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new Fe(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function h(){l>0&&t({id:s,event:u,data:c}),s=void 0,c=``,l=0,u=void 0}function g(e={}){if(e.consume&&a.length>0){let e=a.join(``);p(e,0,e.length)}o=!0,s=void 0,c=``,l=0,u=void 0,a.length=0}return{feed:d,reset:g}}function Re(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function ze(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var Be=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Le({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};const Ve=Symbol.for(`workflow-serialize`),He=Symbol.for(`workflow-deserialize`);export{$ as i,Ve as n,Be as r,He as t};
|