eve 0.17.1 → 0.18.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 +27 -0
- package/dist/src/channel/types.d.ts +11 -0
- package/dist/src/cli/dev/tui/status-line.d.ts +1 -1
- package/dist/src/compiled/.vendor-stamp.json +2 -2
- package/dist/src/compiled/@chat-adapter/slack/api.d.ts +132 -0
- package/dist/src/compiled/@chat-adapter/slack/api.js +1 -0
- package/dist/src/compiled/@chat-adapter/slack/blocks.js +1 -1
- package/dist/src/compiled/@chat-adapter/slack/format.d.ts +33 -0
- package/dist/src/compiled/@chat-adapter/slack/format.js +1 -0
- package/dist/src/compiled/@chat-adapter/slack/index.js +28 -28
- package/dist/src/compiled/@chat-adapter/slack/types-AntsVifS.d.ts +187 -0
- package/dist/src/compiled/@chat-adapter/slack/webhook.d.ts +10 -0
- package/dist/src/compiled/@chat-adapter/slack/webhook.js +1 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +19 -16
- package/dist/src/compiled/@vercel/sandbox/api-client/index.d.ts +1 -1
- package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +37 -23
- package/dist/src/compiled/@vercel/sandbox/command.d.ts +2 -8
- package/dist/src/compiled/@vercel/sandbox/index.js +5 -5
- package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +43 -16
- package/dist/src/compiled/@vercel/sandbox/snapshot.d.ts +5 -5
- package/dist/src/compiled/_chunks/node/{auth-DF_ft5ea.js → auth-CWHn3Yve.js} +1 -1
- package/dist/src/compiled/_chunks/node/chunk-AYN7QRWH-B__hKQV7.js +1 -0
- package/dist/src/compiled/_chunks/node/chunk-HFKBBKCJ-CWaVIQuL.js +1 -0
- package/dist/src/compiled/_chunks/node/{version-TugPKZua.js → version-DD-FX9rK.js} +1 -1
- package/dist/src/compiler/manifest.d.ts +2 -2
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/context/keys.d.ts +2 -0
- package/dist/src/context/keys.js +1 -1
- package/dist/src/evals/assertions/run.js +2 -2
- package/dist/src/execution/create-session-step.d.ts +2 -0
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +3 -0
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-create-sdk.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/execution/session.d.ts +6 -1
- package/dist/src/execution/session.js +3 -3
- package/dist/src/execution/subagent-tool.js +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/harness/advertised-tools.d.ts +33 -0
- package/dist/src/harness/advertised-tools.js +1 -0
- package/dist/src/harness/subagent-depth.d.ts +17 -0
- package/dist/src/harness/subagent-depth.js +1 -0
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/turn-tag-state.d.ts +30 -22
- package/dist/src/harness/turn-tag-state.js +1 -1
- package/dist/src/harness/types.d.ts +28 -0
- package/dist/src/harness/workflow-continuation-security.d.ts +1 -0
- package/dist/src/harness/workflow-continuation-security.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -1
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/channel-route-context.d.ts +5 -0
- package/dist/src/internal/nitro/routes/channel-route-context.js +1 -0
- package/dist/src/internal/nitro/routes/info.d.ts +2 -6
- package/dist/src/internal/nitro/routes/info.js +1 -1
- package/dist/src/protocol/routes.d.ts +2 -4
- package/dist/src/public/channels/auth.d.ts +2 -2
- package/dist/src/public/channels/eve.d.ts +5 -4
- package/dist/src/public/channels/eve.js +1 -1
- package/dist/src/public/channels/slack/api.d.ts +3 -6
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/inbound.d.ts +11 -9
- package/dist/src/public/channels/slack/inbound.js +1 -1
- package/dist/src/public/channels/slack/interactions.d.ts +2 -1
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/mrkdwn.d.ts +3 -35
- package/dist/src/public/channels/slack/mrkdwn.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/slack/verify.d.ts +4 -42
- package/dist/src/public/channels/slack/verify.js +1 -1
- package/dist/src/public/definitions/agent.d.ts +1 -1
- package/dist/src/public/index.d.ts +1 -1
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +4 -1
- package/dist/src/runtime/governance/auth/oidc.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/setup/boxes/link-project.d.ts +7 -3
- package/dist/src/setup/boxes/link-project.js +1 -1
- package/dist/src/setup/boxes/preflight.js +1 -1
- package/dist/src/setup/boxes/select-model.js +1 -1
- package/dist/src/setup/flows/model.js +1 -1
- package/dist/src/setup/onboarding.js +1 -1
- package/dist/src/setup/scaffold/create/project.d.ts +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/create/web-template.d.ts +3 -0
- package/dist/src/setup/scaffold/create/web-template.js +1 -1
- package/dist/src/setup/vercel-project-framework.d.ts +10 -0
- package/dist/src/setup/vercel-project-framework.js +1 -0
- package/dist/src/setup/vercel-project.d.ts +8 -3
- package/dist/src/setup/vercel-project.js +0 -0
- package/dist/src/shared/agent-definition.d.ts +37 -0
- package/dist/src/shared/default-agent-model.d.ts +1 -1
- package/dist/src/shared/default-agent-model.js +1 -1
- package/docs/agent-config.md +35 -8
- package/docs/channels/eve.mdx +3 -2
- package/docs/concepts/sessions-runs-and-streaming.md +2 -2
- package/docs/getting-started.mdx +5 -5
- package/docs/reference/typescript-api.md +1 -1
- package/docs/sandbox.mdx +1 -1
- package/docs/subagents.mdx +19 -0
- package/package.json +3 -31
- package/dist/src/compiled/_chunks/node/chunk-AYN7QRWH-Csu8sG38.js +0 -1
|
@@ -63,11 +63,6 @@ interface BaseCreateSandboxParams {
|
|
|
63
63
|
resources?: {
|
|
64
64
|
vcpus: number;
|
|
65
65
|
};
|
|
66
|
-
/**
|
|
67
|
-
* The runtime of the sandbox, currently only `node24`, `node22`, `node26` and `python3.13` are supported.
|
|
68
|
-
* If not specified, the default runtime `node24` will be used.
|
|
69
|
-
*/
|
|
70
|
-
runtime?: RUNTIMES | (string & {});
|
|
71
66
|
/**
|
|
72
67
|
* Network policy to define network restrictions for the sandbox.
|
|
73
68
|
* Defaults to full internet access if not specified.
|
|
@@ -131,11 +126,42 @@ interface BaseCreateSandboxParams {
|
|
|
131
126
|
*/
|
|
132
127
|
onResume?: (sandbox: Sandbox) => Promise<void>;
|
|
133
128
|
}
|
|
134
|
-
|
|
129
|
+
/**
|
|
130
|
+
* `runtime` and `image` are mutually exclusive: a sandbox starts from either a
|
|
131
|
+
* stock runtime or a custom VCR image, never both. The `never` counterpart in
|
|
132
|
+
* each branch makes passing both a compile-time error.
|
|
133
|
+
* @inline
|
|
134
|
+
*/
|
|
135
|
+
type RuntimeOrImage = {
|
|
136
|
+
/**
|
|
137
|
+
* The runtime of the sandbox, currently only `node24`, `node22`, `node26`
|
|
138
|
+
* and `python3.13` are supported.
|
|
139
|
+
* If not specified, the default runtime `node24` will be used.
|
|
140
|
+
*/
|
|
141
|
+
runtime?: RUNTIMES | (string & {});
|
|
142
|
+
image?: never;
|
|
143
|
+
} | {
|
|
144
|
+
/**
|
|
145
|
+
* A Vercel Container Registry (VCR) image to start the sandbox from,
|
|
146
|
+
* scoped to the sandbox's project. Accepts a repository name, an
|
|
147
|
+
* optional tag or digest, or a fully-qualified VCR URL. A bare
|
|
148
|
+
* repository name resolves to the `latest` tag.
|
|
149
|
+
*
|
|
150
|
+
* @example "my-repo" // latest tag
|
|
151
|
+
* @example "my-repo:v1" // specific tag
|
|
152
|
+
* @example "my-repo@sha256:..." // specific digest
|
|
153
|
+
* @example "vcr.vercel.com/my-team/my-project/my-repo:v1" // fully-qualified
|
|
154
|
+
*/
|
|
155
|
+
image?: string;
|
|
156
|
+
runtime?: never;
|
|
157
|
+
};
|
|
158
|
+
type CreateSandboxParams = (BaseCreateSandboxParams & RuntimeOrImage) | (Omit<BaseCreateSandboxParams, "source"> & {
|
|
135
159
|
source: {
|
|
136
160
|
type: "snapshot";
|
|
137
161
|
snapshotId: string;
|
|
138
162
|
};
|
|
163
|
+
runtime?: never;
|
|
164
|
+
image?: never;
|
|
139
165
|
});
|
|
140
166
|
/**
|
|
141
167
|
* Parameters for {@link Sandbox.fork}.
|
|
@@ -177,14 +203,15 @@ interface GetSandboxParams {
|
|
|
177
203
|
onResume?: (sandbox: Sandbox) => Promise<void>;
|
|
178
204
|
}
|
|
179
205
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* new parameter added to either flow is picked up automatically. The
|
|
183
|
-
* structural overlap on `signal` / `onResume` is intentional — both
|
|
184
|
-
* interfaces declare them with identical optional types.
|
|
206
|
+
* Combines {@link CreateSandboxParams} with get-specific options so that any
|
|
207
|
+
* new parameter added to either flow is picked up automatically.
|
|
185
208
|
* @inline
|
|
186
209
|
*/
|
|
187
|
-
|
|
210
|
+
type GetOrCreateSandboxParams = CreateSandboxParams & {
|
|
211
|
+
/**
|
|
212
|
+
* Whether to resume an existing session. Defaults to true.
|
|
213
|
+
*/
|
|
214
|
+
resume?: boolean;
|
|
188
215
|
/**
|
|
189
216
|
* Called once after a sandbox is freshly created (not when an existing
|
|
190
217
|
* sandbox is retrieved). Use this for one-time setup such as seeding
|
|
@@ -192,7 +219,7 @@ interface GetOrCreateSandboxParams extends BaseCreateSandboxParams, Omit<GetSand
|
|
|
192
219
|
* {@link Sandbox.getOrCreate} resolves.
|
|
193
220
|
*/
|
|
194
221
|
onCreate?: (sandbox: Sandbox) => Promise<void>;
|
|
195
|
-
}
|
|
222
|
+
};
|
|
196
223
|
/**
|
|
197
224
|
* Serialized representation of a Sandbox for @workflow/serde.
|
|
198
225
|
* Fields `metadata` and `routes` are the original wire format from main.
|
|
@@ -376,7 +403,7 @@ declare class Sandbox {
|
|
|
376
403
|
createdAt: number;
|
|
377
404
|
updatedAt: number;
|
|
378
405
|
currentSessionId: string;
|
|
379
|
-
status: "
|
|
406
|
+
status: "pending" | "running" | "stopping" | "stopped" | "failed" | "aborted" | "snapshotting";
|
|
380
407
|
region?: string | undefined;
|
|
381
408
|
vcpus?: number | undefined;
|
|
382
409
|
memory?: number | undefined;
|
|
@@ -912,7 +939,7 @@ declare class Sandbox {
|
|
|
912
939
|
region: string;
|
|
913
940
|
runtime: string;
|
|
914
941
|
timeout: number;
|
|
915
|
-
status: "
|
|
942
|
+
status: "pending" | "running" | "stopping" | "stopped" | "failed" | "aborted" | "snapshotting";
|
|
916
943
|
requestedAt: number;
|
|
917
944
|
createdAt: number;
|
|
918
945
|
cwd: string;
|
|
@@ -1038,7 +1065,7 @@ declare class Sandbox {
|
|
|
1038
1065
|
id: string;
|
|
1039
1066
|
sourceSessionId: string;
|
|
1040
1067
|
region: string;
|
|
1041
|
-
status: "
|
|
1068
|
+
status: "failed" | "created" | "deleted";
|
|
1042
1069
|
sizeBytes: number;
|
|
1043
1070
|
createdAt: number;
|
|
1044
1071
|
updatedAt: number;
|
|
@@ -110,7 +110,7 @@ declare class Snapshot {
|
|
|
110
110
|
id: string;
|
|
111
111
|
sourceSessionId: string;
|
|
112
112
|
region: string;
|
|
113
|
-
status: "
|
|
113
|
+
status: "failed" | "created" | "deleted";
|
|
114
114
|
sizeBytes: number;
|
|
115
115
|
createdAt: number;
|
|
116
116
|
updatedAt: number;
|
|
@@ -148,7 +148,7 @@ declare class Snapshot {
|
|
|
148
148
|
id: string;
|
|
149
149
|
sourceSessionId: string;
|
|
150
150
|
region: string;
|
|
151
|
-
status: "
|
|
151
|
+
status: "failed" | "created" | "deleted";
|
|
152
152
|
sizeBytes: number;
|
|
153
153
|
createdAt: number;
|
|
154
154
|
updatedAt: number;
|
|
@@ -161,7 +161,7 @@ declare class Snapshot {
|
|
|
161
161
|
id: string;
|
|
162
162
|
sourceSessionId: string;
|
|
163
163
|
region: string;
|
|
164
|
-
status: "
|
|
164
|
+
status: "failed" | "created" | "deleted";
|
|
165
165
|
sizeBytes: number;
|
|
166
166
|
createdAt: number;
|
|
167
167
|
updatedAt: number;
|
|
@@ -181,7 +181,7 @@ declare class Snapshot {
|
|
|
181
181
|
id: string;
|
|
182
182
|
sourceSessionId: string;
|
|
183
183
|
region: string;
|
|
184
|
-
status: "
|
|
184
|
+
status: "failed" | "created" | "deleted";
|
|
185
185
|
sizeBytes: number;
|
|
186
186
|
createdAt: number;
|
|
187
187
|
updatedAt: number;
|
|
@@ -194,7 +194,7 @@ declare class Snapshot {
|
|
|
194
194
|
id: string;
|
|
195
195
|
sourceSessionId: string;
|
|
196
196
|
region: string;
|
|
197
|
-
status: "
|
|
197
|
+
status: "failed" | "created" | "deleted";
|
|
198
198
|
sizeBytes: number;
|
|
199
199
|
createdAt: number;
|
|
200
200
|
updatedAt: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as e,o as t,r as n}from"./dist-BdTs18CF.js";import{c as r,d as i,h as a,i as o,l as s,m as c,n as l,p as u,s as d,t as f}from"./version-
|
|
1
|
+
import{c as e,o as t,r as n}from"./dist-BdTs18CF.js";import{c as r,d as i,h as a,i as o,l as s,m as c,n as l,p as u,s as d,t as f}from"./version-DD-FX9rK.js";import*as p from"node:path";import m from"node:path";import{homedir as h}from"node:os";import g from"node:fs";import{setTimeout as _}from"node:timers/promises";import*as v from"node:fs/promises";import y from"os";const b={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};var ee;ee||={};const x=i().transform((e,t)=>{try{return JSON.parse(e)}catch(e){return t.addIssue({code:b.custom,message:`Invalid JSON: ${e.message}`}),a}});var S=n(((e,n)=>{let r=t(`os`),i=t(`path`),a=/^win/i.test(process.platform);function o(e){return i.normalize(i.join(e,`.`))}let s=()=>{let{env:e}=process,t={};return t.home=()=>o(r.homedir?r.homedir():e.HOME),t.temp=()=>o(r.tmpdir?r.tmpdir():e.TMPDIR||e.TEMP||e.TMP),t},c=()=>{let{env:e}=process,t={};return t.home=()=>o(r.homedir?r.homedir():e.USERPROFILE||i.join(e.HOMEDRIVE,e.HOMEPATH)||e.HOME),t.temp=()=>o(r.tmpdir?r.tmpdir():e.TEMP||e.TMP||i.join(e.LOCALAPPDATA||e.SystemRoot||e.windir,`Temp`)),t};n.exports=new class e{constructor(){let t=function(){return new e};this._fn=t;let n=a?c():s();return Object.keys(n).forEach(e=>{this._fn[e]=n[e]}),this._fn}}})),C=n(((e,n)=>{let r=t(`path`),i=S(),a=()=>{let e={};return e.cache=()=>process.env.XDG_CACHE_HOME||r.join(i.home()||i.temp(),`.cache`),e.config=()=>process.env.XDG_CONFIG_HOME||r.join(i.home()||i.temp(),`.config`),e.data=()=>process.env.XDG_DATA_HOME||r.join(i.home()||i.temp(),`.local`,`share`),e.runtime=()=>process.env.XDG_RUNTIME_DIR||void 0,e.state=()=>process.env.XDG_STATE_HOME||r.join(i.home()||i.temp(),`.local`,`state`),e},o=()=>{let e={};return e.cache=()=>process.env.XDG_CACHE_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`Caches`),e.config=()=>process.env.XDG_CONFIG_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`Preferences`),e.data=()=>process.env.XDG_DATA_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`Application Support`),e.runtime=()=>process.env.XDG_RUNTIME_DIR||void 0,e.state=()=>process.env.XDG_STATE_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`State`),e},s=()=>{let e={};return e.cache=()=>{let e=process.env.LOCALAPPDATA||r.join(i.home()||i.temp(),`AppData`,`Local`);return process.env.XDG_CACHE_HOME||r.join(e,`xdg.cache`)},e.config=()=>{let e=process.env.APPDATA||r.join(i.home()||i.temp(),`AppData`,`Roaming`);return process.env.XDG_CONFIG_HOME||r.join(e,`xdg.config`)},e.data=()=>{let e=process.env.APPDATA||r.join(i.home()||i.temp(),`AppData`,`Roaming`);return process.env.XDG_DATA_HOME||r.join(e,`xdg.data`)},e.runtime=()=>process.env.XDG_RUNTIME_DIR||void 0,e.state=()=>{let e=process.env.LOCALAPPDATA||r.join(i.home()||i.temp(),`AppData`,`Local`);return process.env.XDG_STATE_HOME||r.join(e,`xdg.state`)},e},c=()=>{let e=function(){return c()},t={};return t=/^darwin$/i.test(process.platform)?o():/^win/i.test(process.platform)?s():a(),t.configDirs=()=>{let e=[];return e.push(t.config()),process.env.XDG_CONFIG_DIRS&&e.push(...process.env.XDG_CONFIG_DIRS.split(r.delimiter)),e},t.dataDirs=()=>{let e=[];return e.push(t.data()),process.env.XDG_DATA_DIRS&&e.push(...process.env.XDG_DATA_DIRS.split(r.delimiter)),e},Object.keys(t).forEach(n=>{e[n]=t[n]}),e};n.exports=c()})),w=e(n(((e,n)=>{let r=t(`path`),i=t(`os`),a=C(),o=/^win/i.test(process.platform);function s(e,t){if(e||={},typeof e!=`object`&&(e={isolated:e}),e.isolated=e.isolated===void 0||e.isolated===null?t:e.isolated,typeof e.isolated!=`boolean`)throw TypeError(`Expected boolean for "isolated" argument, got ${typeof e.isolated}`);return e}let c=(e,t)=>{let n={};return n.cache=(n={isolated:null})=>(n=s(n,t),r.join(a.cache(),n.isolated?e:``)),n.config=(n={isolated:null})=>(n=s(n,t),r.join(a.config(),n.isolated?e:``)),n.data=(n={isolated:null})=>(n=s(n,t),r.join(a.data(),n.isolated?e:``)),n.runtime=(n={isolated:null})=>(n=s(n,t),a.runtime()?r.join(a.runtime(),n.isolated?e:``):void 0),n.state=(n={isolated:null})=>(n=s(n,t),r.join(a.state(),n.isolated?e:``)),n.configDirs=(n={isolated:null})=>(n=s(n,t),a.configDirs().map(t=>r.join(t,n.isolated?e:``))),n.dataDirs=(n={isolated:null})=>(n=s(n,t),a.dataDirs().map(t=>r.join(t,n.isolated?e:``))),n},l=(e,t)=>{let{env:n}=process,o=i.homedir(),c=i.tmpdir(),l=n.APPDATA||r.join(o||c,`AppData`,`Roaming`),u=n.LOCALAPPDATA||r.join(o||c,`AppData`,`Local`),d={};return d.cache=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_CACHE_HOME?r.join(a.cache(),i.isolated?e:``):r.join(u,i.isolated?e:``,`Cache`)),d.config=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_CONFIG_HOME?r.join(a.config(),i.isolated?e:``):r.join(l,i.isolated?e:``,`Config`)),d.data=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_DATA_HOME?r.join(a.data(),i.isolated?e:``):r.join(l,i.isolated?e:``,`Data`)),d.runtime=(n={isolated:null})=>(n=s(n,t),a.runtime()?r.join(a.runtime(),n.isolated?e:``):void 0),d.state=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_STATE_HOME?r.join(a.state(),i.isolated?e:``):r.join(u,i.isolated?e:``,`State`)),d.configDirs=(i={isolated:null})=>{i=s(i,t);let a=[d.config(i)];return n.XDG_CONFIG_DIRS&&a.push(...n.XDG_CONFIG_DIRS.split(r.delimiter).map(t=>r.join(t,i.isolated?e:``))),a},d.dataDirs=(i={isolated:null})=>{i=s(i,t);let a=[d.data(i)];return n.XDG_DATA_DIRS&&a.push(...n.XDG_DATA_DIRS.split(r.delimiter).map(t=>r.join(t,i.isolated?e:``))),a},d};n.exports=new class e{constructor(n={name:null,suffix:null,isolated:!0}){let i=function(t={name:null,suffix:null,isolated:!0}){return new e(t)};this._fn=i,n||={},typeof n!=`object`&&(n={name:n});let a=n.name||``;if(typeof a!=`string`)throw TypeError(`Expected string for "name" argument, got ${typeof a}`);let s=n.suffix||``;if(typeof s!=`string`)throw TypeError(`Expected string for "suffix" argument, got ${typeof s}`);let u=n.isolated===void 0||n.isolated===null?!0:n.isolated;if(typeof u!=`boolean`)throw TypeError(`Expected boolean for "isolated" argument, got ${typeof u}`);a||=r.parse(process.pkg?process.execPath:t.main?t.main.filename:process.argv[0]).name,s&&(a+=s),this._fn.$name=()=>a,this._fn.$isolated=()=>u;let d=o?l(a,u):c(a,u);return Object.keys(d).forEach(e=>{this._fn[e]=d[e]}),this._fn}}}))(),1);const T=r().transform(e=>new Date(e*1e3)),E=s({token:i().min(1).optional(),refreshToken:i().min(1).optional(),expiresAt:T.optional()}),te=x.pipe(E),ne=e=>{try{return g.lstatSync(e).isDirectory()}catch{return!1}},D=()=>{if(process.env.VERCEL_AUTH_CONFIG_DIR)return process.env.VERCEL_AUTH_CONFIG_DIR;let e=(0,w.default)(`com.vercel.cli`).dataDirs();return[...e,m.join(h(),`.now`),...(0,w.default)(`now`).dataDirs()].find(e=>ne(e))||e[0]},O=()=>{try{let e=m.join(D(),`auth.json`);return te.parse(g.readFileSync(e,`utf8`))}catch{return null}};function k(e){let t=m.join(D(),`auth.json`);g.mkdirSync(m.dirname(t),{recursive:!0});let n={token:e.token,expiresAt:e.expiresAt&&Math.round(e.expiresAt.getTime()/1e3),refreshToken:e.refreshToken};g.writeFileSync(t,JSON.stringify(n)+`
|
|
2
2
|
`)}const A=`${y.hostname()} @ vercel/sandbox/${f} node-${process.version} ${y.platform()} (${y.arch()})`,j=new URL(`https://vercel.com`),M=`cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp`,N=s({issuer:i().url(),device_authorization_endpoint:i().url(),token_endpoint:i().url(),revocation_endpoint:i().url(),jwks_uri:i().url(),introspection_endpoint:i().url()});let P;const F=s({device_code:i(),user_code:i(),verification_uri:i().url(),verification_uri_complete:i().url(),expires_in:r(),interval:r()}),I=s({active:d(!0),client_id:i(),session_id:i()}).or(s({active:d(!1)}));async function L(){if(P)return P;let e=await fetch(new URL(`.well-known/openid-configuration`,j),{headers:{"Content-Type":`application/json`,"user-agent":A}});return P=N.parse(await e.json()),P}async function R(){let e=await L();return{async deviceAuthorizationRequest(){let t=await(await fetch(e.device_authorization_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":A},body:new URLSearchParams({client_id:M,scope:`openid offline_access`})})).json(),n=F.safeParse(t);if(!n.success)throw new H(`Failed to parse device authorization response from the Vercel authorization server.`,t);return{device_code:n.data.device_code,user_code:n.data.user_code,verification_uri:n.data.verification_uri,verification_uri_complete:n.data.verification_uri_complete,expiresAt:Date.now()+n.data.expires_in*1e3,interval:n.data.interval}},async deviceAccessTokenRequest(t){try{return[null,await fetch(e.token_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":A},body:new URLSearchParams({client_id:M,grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:t}),signal:AbortSignal.timeout(10*1e3)})]}catch(e){return e instanceof Error?[e]:[Error(`An unknown error occurred. See the logs for details.`,{cause:e})]}},async processTokenResponse(e){let t=await e.json(),n=z.safeParse(t);return n.success?[null,n.data]:[new H(`Failed to parse token response from the Vercel authorization server.`,t)]},async revokeToken(t){let n=await fetch(e.revocation_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":A},body:new URLSearchParams({token:t,client_id:M})});if(!n.ok)return new H(`Revocation request failed`,await n.json())},async refreshToken(t){let n=await fetch(e.token_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":A},body:new URLSearchParams({client_id:M,grant_type:`refresh_token`,refresh_token:t})}),[r,i]=await this.processTokenResponse(n);if(r)throw r;return i},async introspectToken(t){let n=await(await fetch(e.introspection_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":A},body:new URLSearchParams({token:t})})).json(),r=I.safeParse(n);if(!r.success)throw new H(`Failed to parse introspection response from the Vercel authorization server.`,n);return r.data}}}const z=s({access_token:i(),token_type:d(`Bearer`),expires_in:r(),refresh_token:i().optional(),scope:i().optional()}),B=s({error:l([`invalid_request`,`invalid_client`,`invalid_grant`,`unauthorized_client`,`unsupported_grant_type`,`invalid_scope`,`server_error`,`authorization_pending`,`slow_down`,`access_denied`,`expired_token`,`unsupported_token_type`]),error_description:i().optional(),error_uri:i().optional()});function V(e){try{return B.parse(e)}catch(e){return e instanceof c?TypeError(`Invalid OAuth error response: ${e.message}`):TypeError(`Failed to parse OAuth error response`)}}var H=class extends Error{constructor(e,t){super(e),this.name=`OAuthError`;let n=V(t);if(n instanceof TypeError){this.cause=Error(`Unexpected response from the Vercel authorization server.`),this.code=`server_error`;return}let r=n.error;n.error_description&&(r+=`: ${n.error_description}`),n.error_uri&&(r+=` (${n.error_uri})`),this.cause=Error(r),this.code=n.error}};function U(e){return e instanceof H}async function*W({request:e,oauth:t}){let n=new AbortController;try{let r=e.interval*1e3;for(;Date.now()<e.expiresAt;){let[i,a]=await t.deviceAccessTokenRequest(e.device_code);if(i){if(i.message.includes(`timeout`)){r*=2,yield{_tag:`Timeout`,newInterval:r},await _(r,{signal:n.signal});continue}yield{_tag:`Error`,error:i};return}yield{_tag:`Response`,response:a.clone()};let[o,s]=await t.processTokenResponse(a);if(U(o)){let{code:e}=o;switch(e){case`authorization_pending`:await _(r,{signal:n.signal});continue;case`slow_down`:r+=5*1e3,yield{_tag:`SlowDown`,newInterval:r},await _(r,{signal:n.signal});continue;default:yield{_tag:`Error`,error:o.cause};return}}if(o){yield{_tag:`Error`,error:o};return}k({token:s.access_token,expiresAt:new Date(Date.now()+s.expires_in*1e3),refreshToken:s.refresh_token});return}yield{_tag:`Error`,error:Error(`Timed out waiting for authentication. Please try again.`)};return}finally{n.abort()}}var G=class extends Error{constructor(e){super(`HTTP ${e.statusCode}: ${e.responseText}`),this.name=`NotOk`,this.response=e}};async function K(e){let t=await fetch(`https://vercel.com/api${e.endpoint}`,{method:e.method,body:e.body,headers:{Authorization:`Bearer ${e.token}`,"Content-Type":`application/json`}});if(!t.ok){let e=await t.text();try{let{error:t}=JSON.parse(e);e=`${t.code.toUpperCase()}: ${t.message}`}catch{}throw new G({responseText:e,statusCode:t.status})}return await t.json()}const q=x.pipe(s({projectId:i(),orgId:i()}));async function J(e){let t=p.join(e,`.vercel`,`project.json`),n;try{n=await v.readFile(t,`utf-8`)}catch{return null}let r=q.safeParse(n);return r.success?{projectId:r.data.projectId,teamId:r.data.orgId}:null}const Y=s({user:s({defaultTeamId:i().nullable(),username:i()})}),X=s({id:i(),slug:i(),updatedAt:r().optional(),membership:s({role:i()}),billing:s({plan:i()})}),re=s({teams:o(u()).transform(e=>e.flatMap(e=>{let t=X.safeParse(e);return t.success?[t.data]:[]})),pagination:s({count:r(),next:r().nullable()})}),Z=`vercel-sandbox-default-project`;function Q(e){return e instanceof G&&(e.response.statusCode===402||e.response.statusCode===403)}async function ie(e){let t=await J(e.cwd??process.cwd());if(t){let n=await ae(e.token,t.teamId,t.projectId);return{...t,created:!1,...n}}if(e.teamId)return $(e.token,e.teamId);let{defaultTeamId:n,username:r}=(await K({token:e.token,endpoint:`/v2/user`}).then(Y.parse)).user;if(n)try{let t=await $(e.token,n);try{let r=await K({token:e.token,endpoint:`/v2/teams/${encodeURIComponent(n)}`}).then(s({slug:i()}).parse);return{...t,teamSlug:r.slug}}catch{return t}}catch(e){if(!Q(e))throw e}let a=null;do{let t=a===null?`/v2/teams?limit=20`:`/v2/teams?limit=20&until=${a}`,i=await K({token:e.token,endpoint:t}).then(re.parse);a=i.pagination.next;let o=i.teams.filter(e=>e.membership.role===`OWNER`&&e.billing.plan===`hobby`);if(o.length===0)continue;let s=o.find(e=>e.slug===r)??o.sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0))[0];if(s&&s.id!==n)try{return{...await $(e.token,s.id),teamSlug:s.slug}}catch(e){if(!Q(e))throw e}}while(a!==null);try{return{...await $(e.token,r),teamSlug:r}}catch(e){if(!Q(e))throw e}throw new G({statusCode:403,responseText:`Authenticated as "${r}" but none of the available teams allow sandbox creation.`})}async function $(e,t){let n=t.startsWith(`team_`)?`teamId=${encodeURIComponent(t)}`:`slug=${encodeURIComponent(t)}`,r=!1;try{await K({token:e,endpoint:`/v2/projects/vercel-sandbox-default-project?${n}`})}catch(t){if(!(t instanceof G)||t.response.statusCode!==404)throw t;await K({token:e,endpoint:`/v11/projects?${n}`,method:`POST`,body:JSON.stringify({name:Z})}),r=!0}return{projectId:Z,teamId:t,created:r}}async function ae(e,t,n){try{let r=t.startsWith(`team_`)?`teamId=${encodeURIComponent(t)}`:`slug=${encodeURIComponent(t)}`,[a,o]=await Promise.all([K({token:e,endpoint:`/v2/teams/${encodeURIComponent(t)}`}).then(s({slug:i()}).parse),K({token:e,endpoint:`/v2/projects/${encodeURIComponent(n)}?${r}`}).then(s({name:i()}).parse)]);return{teamSlug:a.slug,projectSlug:o.name}}catch{return{}}}export{G as NotOk,R as OAuth,O as getAuth,ie as inferScope,U as isOAuthError,W as pollForToken,k as updateAuthConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=/[<>|]/,t=/[\^|>]/,n=/^[A-Z0-9_]+$/,r=/(?<![<\w])@([A-Z][A-Z0-9_]+)/g,i=3e3;function a(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function o(e){return e.replace(/</g,`<`).replace(/>/g,`>`).replace(/&/g,`&`)}function s(e,t={}){return v(e),{...t.emoji===void 0?{}:{emoji:t.emoji},text:e,type:`plain_text`}}function c(e,t={}){return v(e),{text:e,type:`mrkdwn`,...t.verbatim===void 0?{}:{verbatim:t.verbatim}}}function l(e){return y(e,`userId`),`<@${e}>`}function u(e){return y(e,`channelId`),`<#${e}>`}function d(e){return y(e,`userGroupId`),`<!subteam^${e}>`}function f(e){return`<!${e}>`}function p(e,t){return b(e,`url`),t?`<${e}|${a(t)}>`:`<${e}>`}function m(e,t,n,r={}){x(t,`token`);let i=e instanceof Date?Math.floor(e.getTime()/1e3):e;if(!Number.isInteger(i))throw TypeError(`timestamp must be an integer unix timestamp or Date`);return`<!date^${i}^${t}${r.link?`^${S(r.link)}`:``}|${a(n)}>`}function h(e){let t=e;return t=t.replace(/<@([A-Z0-9_]+)\|([^<>]+)>/g,`@$2`),t=t.replace(/<@([A-Z0-9_]+)>/g,`@$1`),t=t.replace(/<#[A-Z0-9_]+\|([^<>]+)>/g,`#$1`),t=t.replace(/<#([A-Z0-9_]+)>/g,`#$1`),t=t.replace(/<(https?:\/\/[^|<>]+)\|([^<>]+)>/g,`[$2]($1)`),t=t.replace(/<(https?:\/\/[^<>]+)>/g,`$1`),t=t.replace(/(?<![_*\\])\*([^*\n]+)\*(?![_*])/g,`**$1**`),t=t.replace(/(?<!~)~([^~\n]+)~(?!~)/g,`~~$1~~`),o(t)}function g(e){return e.replace(/\*\*(.+?)\*\*/g,`*$1*`)}function _(e){return e.replace(r,`<@$1>`)}function v(e){if(e.length<1||e.length>i)throw TypeError(`text must be between 1 and ${i} characters`)}function y(e,t){if(!n.test(e))throw TypeError(`${t} must be a Slack ID`)}function b(t,n){if(e.test(t))throw TypeError(`${n} cannot contain Slack control characters`)}function x(e,n){if(t.test(e))throw TypeError(`${n} cannot contain Slack date control characters`)}function S(e){return x(e,`link`),e}export{m as a,l as c,g as d,h as f,u as i,d as l,s as n,p as o,o as p,a as r,f as s,c as t,_ as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{constructor(e){super(e),this.name=`SlackWebhookError`}},t=class extends e{constructor(e){super(e),this.name=`SlackWebhookVerificationError`}},n=class extends e{constructor(e){super(e),this.name=`SlackWebhookParseError`}};function r(e,t){if(!e)return;if(typeof Headers<`u`&&e instanceof Headers)return e.get(t)??void 0;let n=t.toLowerCase();if(d(e)){for(let[t,r]of e)if(t.toLowerCase()===n)return r;return}for(let[t,r]of Object.entries(e))if(t.toLowerCase()===n)return f(r)}function i(e){let t=r(e,`x-slack-retry-num`);if(!t)return;let n=Number(t);if(Number.isFinite(n))return{num:n,reason:r(e,`x-slack-retry-reason`)}}function a(e,t){return t.includes(`application/x-www-form-urlencoded`)?!0:t.includes(`application/json`)?!1:!e.trimStart().startsWith(`{`)&&e.includes(`=`)}function o(e){try{return JSON.parse(e)}catch{throw new n(`Slack webhook body is invalid JSON`)}}function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function c(e){return s(e)?e:void 0}function l(e){return typeof e==`string`?e:``}function u(e){return l(e)||void 0}function d(e){return typeof e[Symbol.iterator]==`function`}function f(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e[0]}function p(e,t={}){let n=t.headers,s=t.contentType??r(n,`content-type`)??``,c=i(n);return a(e,s)?m(e,c):h(o(e),c)}function m(e,t){let n=new URLSearchParams(e),r=n.get(`payload`);return r===null?n.has(`command`)?v(n,t):{kind:`unsupported`,raw:Object.fromEntries(n),retry:t,type:`form`}:g(o(r),t)}function h(e,t){if(!s(e))return{kind:`unsupported`,raw:e,retry:t,type:`unknown`};if(e.type===`url_verification`&&typeof e.challenge==`string`)return{challenge:e.challenge,kind:`url_verification`,raw:e,retry:t};if(e.type!==`event_callback`||!s(e.event))return{kind:`unsupported`,raw:e,retry:t,type:typeof e.type==`string`?e.type:`unknown`};let n=e.event;return n.type===`app_mention`?_(`app_mention`,e,n,t):n.type===`message`&&n.channel_type===`im`?_(`direct_message`,e,n,t):{kind:`unsupported`,raw:e,retry:t,type:typeof n.type==`string`?n.type:`event_callback`}}function g(e,t){if(!s(e))return{kind:`unsupported`,raw:e,retry:t,type:`interaction`};switch(e.type){case`block_actions`:return y(e,t);case`block_suggestion`:return x(e,t);case`view_submission`:return S(e,t);case`view_closed`:return C(e,t);default:return{kind:`unsupported`,raw:e,retry:t,type:typeof e.type==`string`?e.type:`interaction`}}}function _(e,t,n,r){let i=l(n.channel),a=l(n.ts),o=l(n.thread_ts)||a,s=u(n.team_id)||u(t.team_id),c=u(t.enterprise_id)||u(t.context_enterprise_id),d=i?{channelId:i,enterpriseId:c,teamId:s,threadTs:o}:{channelId:``,enterpriseId:c,teamId:s,threadTs:o},f={apiAppId:u(t.api_app_id),channelId:i,continuation:d,enterpriseId:c,eventId:u(t.event_id),eventTime:typeof t.event_time==`number`?t.event_time:void 0,files:w(n.files),eventType:n.type,isExtSharedChannel:typeof t.is_ext_shared_channel==`boolean`?t.is_ext_shared_channel:void 0,raw:n,retry:r,teamId:s,text:l(n.text),threadTs:o,ts:a,userId:u(n.user)};return e===`app_mention`?{...f,eventType:`app_mention`,kind:e}:{...f,botId:u(n.bot_id),eventType:`message`,kind:e,subtype:u(n.subtype)}}function v(e,t){let n=e.get(`enterprise_id`)||void 0,r=e.get(`team_id`)||void 0;return{channelId:e.get(`channel_id`)??``,channelName:e.get(`channel_name`)||void 0,command:e.get(`command`)??``,enterpriseId:n,isEnterpriseInstall:e.get(`is_enterprise_install`)===`true`,kind:`slash_command`,raw:Object.fromEntries(e),responseUrl:e.get(`response_url`)||void 0,retry:t,teamId:r,text:e.get(`text`)??``,triggerId:e.get(`trigger_id`)||void 0,userId:e.get(`user_id`)??``,userName:e.get(`user_name`)||void 0}}function y(e,t){let n=c(e.channel),r=c(e.container),i=c(e.message),a=E(e.user),o=c(e.team),s=c(e.enterprise),l=u(n?.id)||u(r?.channel_id),d=u(i?.ts)||u(r?.message_ts),f=u(i?.thread_ts)||u(r?.thread_ts)||d,p=u(o?.id)||a.teamId,m=u(s?.id)||u(o?.enterprise_id),h=l&&f?{channelId:l,enterpriseId:m,teamId:p,threadTs:f}:void 0,g=Array.isArray(i?.blocks)?i.blocks:void 0,_=D(g);return{actions:Array.isArray(e.actions)?e.actions.map(e=>b(e,a)):[],channelId:l,continuation:h,enterpriseId:m,isEnterpriseInstall:typeof e.is_enterprise_install==`boolean`?e.is_enterprise_install:void 0,kind:`block_actions`,messageBlocks:g,messagePromptBlock:_,messagePromptText:O(_),messageTs:d,raw:e,responseUrl:u(e.response_url),retry:t,teamId:p,threadTs:f,triggerId:u(e.trigger_id),user:a,userId:a.id,userName:a.username||a.name}}function b(e,t){let n=s(e)?e:{},r=c(n.selected_option),i=c(n.text),a=c(r?.text);return{actionId:l(n.action_id),blockId:u(n.block_id),label:u(a?.text)||u(i?.text),raw:n,selectedOptionLabel:u(a?.text),selectedOptionValue:u(r?.value),type:l(n.type),user:t,value:u(n.value)}}function x(e,t){let n=c(e.channel),r=c(e.team),i=c(e.enterprise),a=c(e.user);return{actionId:l(e.action_id),blockId:l(e.block_id),channelId:u(n?.id),enterpriseId:u(i?.id)||u(r?.enterprise_id),kind:`block_suggestion`,raw:e,retry:t,teamId:u(r?.id),userId:l(a?.id),value:l(e.value)}}function S(e,t){let n=c(e.team),r=c(e.enterprise),i=E(e.user),a=c(e.view)??{};return{callbackId:u(a.callback_id),enterpriseId:u(r?.id)||u(n?.enterprise_id),kind:`view_submission`,privateMetadata:u(a.private_metadata),raw:e,responseUrls:Array.isArray(a.response_urls)?a.response_urls:void 0,retry:t,teamId:u(n?.id),user:i,userId:i.id,values:k(a),view:a}}function C(e,t){let n=c(e.team),r=c(e.enterprise),i=E(e.user);return{enterpriseId:u(r?.id)||u(n?.enterprise_id),kind:`view_closed`,raw:e,retry:t,teamId:u(n?.id),user:i,userId:i.id,view:c(e.view)??{}}}function w(e){return Array.isArray(e)?e.map(e=>s(e)?e:void 0).filter(e=>e!==void 0).map(e=>{let t=u(e.mimetype);return{downloadUrl:u(e.url_private_download),filetype:u(e.filetype),id:l(e.id),mimeType:t,name:u(e.name),raw:e,size:typeof e.size==`number`?e.size:void 0,title:u(e.title),type:T(t),url:u(e.url_private)}}):[]}function T(e){return e?.startsWith(`image/`)?`image`:e?.startsWith(`video/`)?`video`:e?.startsWith(`audio/`)?`audio`:`file`}function E(e){let t=c(e)??{};return{id:l(t.id),name:u(t.name),teamId:u(t.team_id),username:u(t.username)}}function D(e){return e?.find(e=>{let t=c(e);return t?.type===`section`&&c(t.text)})}function O(e){return u(c(c(e)?.text)?.text)}function k(e){let t=c(c(e.state)?.values);if(!t)return[];let n=[];for(let[e,r]of Object.entries(t)){let t=c(r);if(t)for(let[r,i]of Object.entries(t)){let t=c(i);if(!t)continue;let a=c(t.selected_option),o=c(a?.text);n.push({actionId:r,blockId:e,raw:t,selectedOptionLabel:u(o?.text),selectedOptionValue:u(a?.value),type:u(t.type),value:u(t.value)})}}return n}var A=/^[\da-f]+$/i;async function j(e,t){return p(await M(e,t),{contentType:t.contentType,headers:e.headers})}async function M(e,n){let r=await e.text();if(n.webhookVerifier){let i=await n.webhookVerifier(e,r);if(!i)throw new t(`Slack webhook verifier rejected the request`);return typeof i==`string`?i:r}return await N(r,e.headers,n),r}async function N(e,n,i){let a=i.signingSecret;if(!a)throw new t(`Slack signing secret is required`);let o=r(n,`x-slack-request-timestamp`),s=r(n,`x-slack-signature`);if(!(o&&s))throw new t(`Slack signature headers are required`);let c=Number(o);if(!Number.isFinite(c))throw new t(`Slack timestamp is invalid`);let l=Math.floor((i.now?.()??Date.now())/1e3),u=i.maxSkewSeconds??300;if(Math.abs(l-c)>u)throw new t(`Slack timestamp is too old`);if(!await P(e,a,o,s))throw new t(`Slack signature is invalid`)}async function P(e,n,r,i){let a=globalThis.crypto;if(!a?.subtle)throw new t(`Web Crypto is not available`);let o=new TextEncoder,s=await a.subtle.importKey(`raw`,o.encode(n),{hash:`SHA-256`,name:`HMAC`},!1,[`verify`]);return a.subtle.verify(`HMAC`,s,F(i),o.encode(`v0:${r}:${e}`))}function F(e){if(!e.startsWith(`v0=`))throw new t(`Slack signature is invalid`);let n=e.slice(3);if(n.length%2!=0||!A.test(n))throw new t(`Slack signature is invalid`);let r=new ArrayBuffer(n.length/2),i=new Uint8Array(r);for(let e=0;e<i.length;e++)i[e]=Number.parseInt(n.slice(e*2,e*2+2),16);return r}export{j as a,p as i,n,M as o,t as r,N as s,e as t};
|
|
@@ -61,4 +61,4 @@ var e;const t=Object.freeze({status:`aborted`});function n(e,t,n){function r(n,r
|
|
|
61
61
|
|
|
62
62
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},o,s=_,c=!a.jitless,u=c&&re.value,d=t.catchall,f;e._zod.parse=(a,l)=>{f??=r.value;let p=a.value;return s(p)?c&&u&&l?.async===!1&&l.jitless!==!0?(o||=i(t.shape),a=o(a,l),d?on([],p,a,l,f,e):a):n(a,l):(a.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),a)}});function ln(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!S(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>T(e,r,o())))}),t)}const un=n(`$ZodUnion`,(e,t)=>{P.init(e,t),m(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),m(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),m(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),m(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>d(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>ln(t,r,e,i)):ln(o,r,e,i)}}),dn=n(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,un.init(e,t);let n=e._zod.parse;m(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=l(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!_(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),fn=n(`$ZodIntersection`,(e,t)=>{P.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>pn(e,t,n)):pn(e,i,a)}});function R(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(v(e)&&v(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=R(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=R(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function pn(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),S(e))return e;let o=R(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const mn=n(`$ZodRecord`,(e,t)=>{P.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!v(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],s=t.keyType._zod.values;if(s){n.value={};let c=new Set;for(let l of s)if(typeof l==`string`||typeof l==`number`||typeof l==`symbol`){c.add(typeof l==`number`?l.toString():l);let s=t.keyType._zod.run({value:l,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>T(e,r,o())),input:l,path:[l],inst:e});continue}let u=s.value,d=t.valueType._zod.run({value:i[l],issues:[]},r);d instanceof Promise?a.push(d.then(e=>{e.issues.length&&n.issues.push(...C(l,e.issues)),n.value[u]=e.value})):(d.issues.length&&n.issues.push(...C(l,d.issues)),n.value[u]=d.value)}let l;for(let e in i)c.has(e)||(l??=[],l.push(e));l&&l.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:l})}else{n.value={};for(let s of Reflect.ownKeys(i)){if(s===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,s))continue;let c=t.keyType._zod.run({value:s,issues:[]},r);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof s==`string`&&rt.test(s)&&c.issues.length){let e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(c=e)}if(c.issues.length){t.mode===`loose`?n.value[s]=i[s]:n.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>T(e,r,o())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:i[s],issues:[]},r);l instanceof Promise?a.push(l.then(e=>{e.issues.length&&n.issues.push(...C(s,e.issues)),n.value[c.value]=e.value})):(l.issues.length&&n.issues.push(...C(s,l.issues)),n.value[c.value]=l.value)}}return a.length?Promise.all(a).then(()=>n):n}}),hn=n(`$ZodEnum`,(e,t)=>{P.init(e,t);let n=s(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ae.has(typeof e)).map(e=>typeof e==`string`?y(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),gn=n(`$ZodLiteral`,(e,t)=>{if(P.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?y(e):e?y(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),_n=n(`$ZodTransform`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,a)=>{if(a.direction===`backward`)throw new i(e.constructor.name);let o=t.transform(n.value,n);if(a.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(n.value=e,n.fallback=!0,n));if(o instanceof Promise)throw new r;return n.value=o,n.fallback=!0,n}});function vn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const yn=n(`$ZodOptional`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,m(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),m(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${d(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>vn(e,r)):vn(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),bn=n(`$ZodExactOptional`,(e,t)=>{yn.init(e,t),m(e._zod,`values`,()=>t.innerType._zod.values),m(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),xn=n(`$ZodNullable`,(e,t)=>{P.init(e,t),m(e._zod,`optin`,()=>t.innerType._zod.optin),m(e._zod,`optout`,()=>t.innerType._zod.optout),m(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${d(e.source)}|null)$`):void 0}),m(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Sn=n(`$ZodDefault`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,m(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Cn(e,t)):Cn(r,t)}});function Cn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const wn=n(`$ZodPrefault`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,m(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Tn=n(`$ZodNonOptional`,(e,t)=>{P.init(e,t),m(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>En(t,e)):En(i,e)}});function En(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const Dn=n(`$ZodCatch`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,m(e._zod,`optout`,()=>t.innerType._zod.optout),m(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>T(e,n,o()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>T(e,n,o()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),On=n(`$ZodPipe`,(e,t)=>{P.init(e,t),m(e._zod,`values`,()=>t.in._zod.values),m(e._zod,`optin`,()=>t.in._zod.optin),m(e._zod,`optout`,()=>t.out._zod.optout),m(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>z(e,t.in,n)):z(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>z(e,t.out,n)):z(r,t.out,n)}});function z(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const kn=n(`$ZodReadonly`,(e,t)=>{P.init(e,t),m(e._zod,`propValues`,()=>t.innerType._zod.propValues),m(e._zod,`values`,()=>t.innerType._zod.values),m(e._zod,`optin`,()=>t.innerType?._zod?.optin),m(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(An):An(r)}});function An(e){return e.value=Object.freeze(e.value),e}const jn=n(`$ZodCustom`,(e,t)=>{M.init(e,t),P.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Mn(t,n,r,e));Mn(i,n,r,e)}});function Mn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(D(e))}}var Nn,Pn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Fn(){return new Pn}(Nn=globalThis).__zod_globalRegistry??(Nn.__zod_globalRegistry=Fn());const B=globalThis.__zod_globalRegistry;function In(e,t){return new e({type:`string`,...x(t)})}function Ln(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...x(t)})}function Rn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...x(t)})}function zn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...x(t)})}function Bn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...x(t)})}function Vn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...x(t)})}function Hn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...x(t)})}function Un(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...x(t)})}function Wn(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...x(t)})}function Gn(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...x(t)})}function Kn(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...x(t)})}function qn(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...x(t)})}function Jn(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...x(t)})}function Yn(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...x(t)})}function Xn(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...x(t)})}function Zn(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...x(t)})}function Qn(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...x(t)})}function $n(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...x(t)})}function er(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...x(t)})}function tr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...x(t)})}function nr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...x(t)})}function rr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...x(t)})}function ir(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...x(t)})}function ar(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...x(t)})}function or(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...x(t)})}function sr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...x(t)})}function cr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...x(t)})}function lr(e,t){return new e({type:`number`,checks:[],...x(t)})}function ur(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...x(t)})}function dr(e,t){return new e({type:`boolean`,...x(t)})}function fr(e){return new e({type:`any`})}function pr(e){return new e({type:`unknown`})}function mr(e,t){return new e({type:`never`,...x(t)})}function hr(e,t){return new ct({check:`less_than`,...x(t),value:e,inclusive:!1})}function V(e,t){return new ct({check:`less_than`,...x(t),value:e,inclusive:!0})}function gr(e,t){return new lt({check:`greater_than`,...x(t),value:e,inclusive:!1})}function H(e,t){return new lt({check:`greater_than`,...x(t),value:e,inclusive:!0})}function _r(e,t){return new ut({check:`multiple_of`,...x(t),value:e})}function vr(e,t){return new ft({check:`max_length`,...x(t),maximum:e})}function U(e,t){return new pt({check:`min_length`,...x(t),minimum:e})}function yr(e,t){return new mt({check:`length_equals`,...x(t),length:e})}function br(e,t){return new ht({check:`string_format`,format:`regex`,...x(t),pattern:e})}function xr(e){return new gt({check:`string_format`,format:`lowercase`,...x(e)})}function Sr(e){return new _t({check:`string_format`,format:`uppercase`,...x(e)})}function Cr(e,t){return new vt({check:`string_format`,format:`includes`,...x(t),includes:e})}function wr(e,t){return new yt({check:`string_format`,format:`starts_with`,...x(t),prefix:e})}function Tr(e,t){return new bt({check:`string_format`,format:`ends_with`,...x(t),suffix:e})}function W(e){return new xt({check:`overwrite`,tx:e})}function Er(e){return W(t=>t.normalize(e))}function Dr(){return W(e=>e.trim())}function Or(){return W(e=>e.toLowerCase())}function kr(){return W(e=>e.toUpperCase())}function Ar(){return W(e=>te(e))}function jr(e,t,n){return new e({type:`array`,element:t,...x(n)})}function Mr(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...x(n)})}function Nr(e,t){let n=Pr(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(D(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(D(r))}},e(t.value,t)),t);return n}function Pr(e,t){let n=new M({check:`custom`,...x(t)});return n._zod.check=e,n}function Fr(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??B,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function G(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,G(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&K(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ir(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
63
63
|
|
|
64
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Lr(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:q(t,`input`,e.processors),output:q(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function K(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return K(r.element,n);if(r.type===`set`)return K(r.valueType,n);if(r.type===`lazy`)return K(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return K(r.innerType,n);if(r.type===`intersection`)return K(r.left,n)||K(r.right,n);if(r.type===`record`||r.type===`map`)return K(r.keyType,n)||K(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:K(r.in,n)||K(r.out,n);if(r.type===`object`){for(let e in r.shape)if(K(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(K(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(K(e,n))return!0;return!!(r.rest&&K(r.rest,n))}return!1}const Rr=(e,t={})=>n=>{let r=Fr({...n,processors:t});return G(e,r),Ir(r,e),Lr(r,e)},q=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Fr({...i??{},target:a,io:t,processors:n});return G(e,o),Ir(o,e),Lr(o,e)},zr={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Br=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=zr[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Vr=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Hr=(e,t,n,r)=>{n.type=`boolean`},Ur=(e,t,n,r)=>{n.not={}},Wr=(e,t,n,r)=>{let i=e._zod.def,a=s(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Gr=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Kr=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},qr=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Jr=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=G(a.element,t,{...r,path:[...r.path,`items`]})},Yr=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=G(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=G(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Xr=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>G(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Zr=(e,t,n,r)=>{let i=e._zod.def,a=G(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=G(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Qr=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=G(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=G(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=G(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},$r=(e,t,n,r)=>{let i=e._zod.def,a=G(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ei=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ti=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ni=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ri=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ii=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;G(o,t,r);let s=t.seen.get(e);s.ref=o},ai=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},oi=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},si=n(`ZodISODateTime`,(e,t)=>{Ft.init(e,t),Z.init(e,t)});function ci(e){return ar(si,e)}const li=n(`ZodISODate`,(e,t)=>{It.init(e,t),Z.init(e,t)});function ui(e){return or(li,e)}const di=n(`ZodISOTime`,(e,t)=>{Lt.init(e,t),Z.init(e,t)});function fi(e){return sr(di,e)}const pi=n(`ZodISODuration`,(e,t)=>{Rt.init(e,t),Z.init(e,t)});function mi(e){return cr(pi,e)}const hi=(e,t)=>{_e.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>be(e,t)},flatten:{value:t=>ye(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,c,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,c,2)}},isEmpty:{get(){return e.issues.length===0}}})},gi=n(`ZodError`,hi),J=n(`ZodError`,hi,{Parent:Error}),_i=O(J),vi=k(J),yi=A(J),bi=j(J),xi=Ce(J),Si=we(J),Ci=Te(J),wi=Ee(J),Ti=De(J),Ei=Oe(J),Di=ke(J),Oi=Ae(J),ki=new WeakMap;function Y(e,t,n){let r=Object.getPrototypeOf(e),i=ki.get(r);if(i||(i=new Set,ki.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}const X=n(`ZodType`,(e,t)=>(P.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:q(e,`input`),output:q(e,`output`)}}),e.toJSONSchema=Rr(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>_i(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>yi(e,t,n),e.parseAsync=async(t,n)=>vi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>bi(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>xi(e,t,n),e.decode=(t,n)=>Si(e,t,n),e.encodeAsync=async(t,n)=>Ci(e,t,n),e.decodeAsync=async(t,n)=>wi(e,t,n),e.safeEncode=(t,n)=>Ti(e,t,n),e.safeDecode=(t,n)=>Ei(e,t,n),e.safeEncodeAsync=async(t,n)=>Di(e,t,n),e.safeDecodeAsync=async(t,n)=>Oi(e,t,n),Y(e,`ZodType`,{check(...e){let t=this.def;return this.clone(g(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return b(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ga(e,t))},superRefine(e,t){return this.check(Ka(e,t))},overwrite(e){return this.check(W(e))},optional(){return Da(this)},exactOptional(){return ka(this)},nullable(){return ja(this)},nullish(){return Da(ja(this))},nonoptional(e){return La(this,e)},array(){return la(this)},or(e){return pa([this,e])},and(e){return _a(this,e)},transform(e){return Va(this,Ta(e))},default(e){return Na(this,e)},prefault(e){return Fa(this,e)},catch(e){return za(this,e)},pipe(e){return Va(this,e)},readonly(){return Ua(this)},describe(e){let t=this.clone();return B.add(t,{description:e}),t},meta(...e){if(e.length===0)return B.get(this);let t=this.clone();return B.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return B.get(e)?.description},configurable:!0}),e)),Ai=n(`_ZodString`,(e,t)=>{F.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Br(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Y(e,`_ZodString`,{regex(...e){return this.check(br(...e))},includes(...e){return this.check(Cr(...e))},startsWith(...e){return this.check(wr(...e))},endsWith(...e){return this.check(Tr(...e))},min(...e){return this.check(U(...e))},max(...e){return this.check(vr(...e))},length(...e){return this.check(yr(...e))},nonempty(...e){return this.check(U(1,...e))},lowercase(e){return this.check(xr(e))},uppercase(e){return this.check(Sr(e))},trim(){return this.check(Dr())},normalize(...e){return this.check(Er(...e))},toLowerCase(){return this.check(Or())},toUpperCase(){return this.check(kr())},slugify(){return this.check(Ar())}})}),ji=n(`ZodString`,(e,t)=>{F.init(e,t),Ai.init(e,t),e.email=t=>e.check(Ln(Ni,t)),e.url=t=>e.check(Un(Fi,t)),e.jwt=t=>e.check(ir(Xi,t)),e.emoji=t=>e.check(Wn(Ii,t)),e.guid=t=>e.check(Rn(Pi,t)),e.uuid=t=>e.check(zn(Q,t)),e.uuidv4=t=>e.check(Bn(Q,t)),e.uuidv6=t=>e.check(Vn(Q,t)),e.uuidv7=t=>e.check(Hn(Q,t)),e.nanoid=t=>e.check(Gn(Li,t)),e.guid=t=>e.check(Rn(Pi,t)),e.cuid=t=>e.check(Kn(Ri,t)),e.cuid2=t=>e.check(qn(zi,t)),e.ulid=t=>e.check(Jn(Bi,t)),e.base64=t=>e.check(tr(qi,t)),e.base64url=t=>e.check(nr(Ji,t)),e.xid=t=>e.check(Yn(Vi,t)),e.ksuid=t=>e.check(Xn(Hi,t)),e.ipv4=t=>e.check(Zn(Ui,t)),e.ipv6=t=>e.check(Qn(Wi,t)),e.cidrv4=t=>e.check($n(Gi,t)),e.cidrv6=t=>e.check(er(Ki,t)),e.e164=t=>e.check(rr(Yi,t)),e.datetime=t=>e.check(ci(t)),e.date=t=>e.check(ui(t)),e.time=t=>e.check(fi(t)),e.duration=t=>e.check(mi(t))});function Mi(e){return In(ji,e)}const Z=n(`ZodStringFormat`,(e,t)=>{I.init(e,t),Ai.init(e,t)}),Ni=n(`ZodEmail`,(e,t)=>{Et.init(e,t),Z.init(e,t)}),Pi=n(`ZodGUID`,(e,t)=>{wt.init(e,t),Z.init(e,t)}),Q=n(`ZodUUID`,(e,t)=>{Tt.init(e,t),Z.init(e,t)}),Fi=n(`ZodURL`,(e,t)=>{Dt.init(e,t),Z.init(e,t)}),Ii=n(`ZodEmoji`,(e,t)=>{Ot.init(e,t),Z.init(e,t)}),Li=n(`ZodNanoID`,(e,t)=>{kt.init(e,t),Z.init(e,t)}),Ri=n(`ZodCUID`,(e,t)=>{At.init(e,t),Z.init(e,t)}),zi=n(`ZodCUID2`,(e,t)=>{jt.init(e,t),Z.init(e,t)}),Bi=n(`ZodULID`,(e,t)=>{Mt.init(e,t),Z.init(e,t)}),Vi=n(`ZodXID`,(e,t)=>{Nt.init(e,t),Z.init(e,t)}),Hi=n(`ZodKSUID`,(e,t)=>{Pt.init(e,t),Z.init(e,t)}),Ui=n(`ZodIPv4`,(e,t)=>{zt.init(e,t),Z.init(e,t)}),Wi=n(`ZodIPv6`,(e,t)=>{Bt.init(e,t),Z.init(e,t)}),Gi=n(`ZodCIDRv4`,(e,t)=>{Vt.init(e,t),Z.init(e,t)}),Ki=n(`ZodCIDRv6`,(e,t)=>{Ht.init(e,t),Z.init(e,t)}),qi=n(`ZodBase64`,(e,t)=>{Wt.init(e,t),Z.init(e,t)}),Ji=n(`ZodBase64URL`,(e,t)=>{Kt.init(e,t),Z.init(e,t)}),Yi=n(`ZodE164`,(e,t)=>{qt.init(e,t),Z.init(e,t)}),Xi=n(`ZodJWT`,(e,t)=>{Yt.init(e,t),Z.init(e,t)}),Zi=n(`ZodNumber`,(e,t)=>{Xt.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vr(e,t,n,r),Y(e,`ZodNumber`,{gt(e,t){return this.check(gr(e,t))},gte(e,t){return this.check(H(e,t))},min(e,t){return this.check(H(e,t))},lt(e,t){return this.check(hr(e,t))},lte(e,t){return this.check(V(e,t))},max(e,t){return this.check(V(e,t))},int(e){return this.check(ea(e))},safe(e){return this.check(ea(e))},positive(e){return this.check(gr(0,e))},nonnegative(e){return this.check(H(0,e))},negative(e){return this.check(hr(0,e))},nonpositive(e){return this.check(V(0,e))},multipleOf(e,t){return this.check(_r(e,t))},step(e,t){return this.check(_r(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Qi(e){return lr(Zi,e)}const $i=n(`ZodNumberFormat`,(e,t)=>{Zt.init(e,t),Zi.init(e,t)});function ea(e){return ur($i,e)}const ta=n(`ZodBoolean`,(e,t)=>{Qt.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hr(e,t,n,r)});function na(e){return dr(ta,e)}const ra=n(`ZodAny`,(e,t)=>{$t.init(e,t),X.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ia(){return fr(ra)}const aa=n(`ZodUnknown`,(e,t)=>{en.init(e,t),X.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function $(){return pr(aa)}const oa=n(`ZodNever`,(e,t)=>{tn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ur(e,t,n,r)});function sa(e){return mr(oa,e)}const ca=n(`ZodArray`,(e,t)=>{rn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jr(e,t,n,r),e.element=t.element,Y(e,`ZodArray`,{min(e,t){return this.check(U(e,t))},nonempty(e){return this.check(U(1,e))},max(e,t){return this.check(vr(e,t))},length(e,t){return this.check(yr(e,t))},unwrap(){return this.element}})});function la(e,t){return jr(ca,e,t)}const ua=n(`ZodObject`,(e,t)=>{cn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yr(e,t,n,r),m(e,`shape`,()=>t.shape),Y(e,`ZodObject`,{keyof(){return xa(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:$()})},loose(){return this.clone({...this._zod.def,catchall:$()})},strict(){return this.clone({...this._zod.def,catchall:sa()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ue(this,e)},safeExtend(e){return de(this,e)},merge(e){return fe(this,e)},pick(e){return ce(this,e)},omit(e){return le(this,e)},partial(...e){return pe(Ea,this,e[0])},required(...e){return me(Ia,this,e[0])}})});function da(e,t){return new ua({type:`object`,shape:e??{},...x(t)})}const fa=n(`ZodUnion`,(e,t)=>{un.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xr(e,t,n,r),e.options=t.options});function pa(e,t){return new fa({type:`union`,options:e,...x(t)})}const ma=n(`ZodDiscriminatedUnion`,(e,t)=>{fa.init(e,t),dn.init(e,t)});function ha(e,t,n){return new ma({type:`union`,options:t,discriminator:e,...x(n)})}const ga=n(`ZodIntersection`,(e,t)=>{fn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zr(e,t,n,r)});function _a(e,t){return new ga({type:`intersection`,left:e,right:t})}const va=n(`ZodRecord`,(e,t)=>{mn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qr(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ya(e,t,n){return!t||!t._zod?new va({type:`record`,keyType:Mi(),valueType:e,...x(t)}):new va({type:`record`,keyType:e,valueType:t,...x(n)})}const ba=n(`ZodEnum`,(e,t)=>{hn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wr(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new ba({...t,checks:[],...x(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new ba({...t,checks:[],...x(r),entries:i})}});function xa(e,t){return new ba({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...x(t)})}const Sa=n(`ZodLiteral`,(e,t)=>{gn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gr(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ca(e,t){return new Sa({type:`literal`,values:Array.isArray(e)?e:[e],...x(t)})}const wa=n(`ZodTransform`,(e,t)=>{_n.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qr(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new i(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(D(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(D(t))}};let a=t.transform(n.value,n);return a instanceof Promise?a.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=a,n.fallback=!0,n)}});function Ta(e){return new wa({type:`transform`,transform:e})}const Ea=n(`ZodOptional`,(e,t)=>{yn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Da(e){return new Ea({type:`optional`,innerType:e})}const Oa=n(`ZodExactOptional`,(e,t)=>{bn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ka(e){return new Oa({type:`optional`,innerType:e})}const Aa=n(`ZodNullable`,(e,t)=>{xn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$r(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ja(e){return new Aa({type:`nullable`,innerType:e})}const Ma=n(`ZodDefault`,(e,t)=>{Sn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ti(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Na(e,t){return new Ma({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}const Pa=n(`ZodPrefault`,(e,t)=>{wn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ni(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fa(e,t){return new Pa({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}const Ia=n(`ZodNonOptional`,(e,t)=>{Tn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ei(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function La(e,t){return new Ia({type:`nonoptional`,innerType:e,...x(t)})}const Ra=n(`ZodCatch`,(e,t)=>{Dn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ri(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function za(e,t){return new Ra({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Ba=n(`ZodPipe`,(e,t)=>{On.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ii(e,t,n,r),e.in=t.in,e.out=t.out});function Va(e,t){return new Ba({type:`pipe`,in:e,out:t})}const Ha=n(`ZodReadonly`,(e,t)=>{kn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ai(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ua(e){return new Ha({type:`readonly`,innerType:e})}const Wa=n(`ZodCustom`,(e,t)=>{jn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kr(e,t,n,r)});function Ga(e,t={}){return Mr(Wa,e,t)}function Ka(e,t){return Nr(e,t)}const qa=`2.2.1`;export{na as a,Qi as c,Mi as d,pa as f,t as h,la as i,da as l,gi as m,xa as n,ha as o,$ as p,ia as r,Ca as s,qa as t,ya as u};
|
|
64
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Lr(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:q(t,`input`,e.processors),output:q(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function K(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return K(r.element,n);if(r.type===`set`)return K(r.valueType,n);if(r.type===`lazy`)return K(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return K(r.innerType,n);if(r.type===`intersection`)return K(r.left,n)||K(r.right,n);if(r.type===`record`||r.type===`map`)return K(r.keyType,n)||K(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:K(r.in,n)||K(r.out,n);if(r.type===`object`){for(let e in r.shape)if(K(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(K(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(K(e,n))return!0;return!!(r.rest&&K(r.rest,n))}return!1}const Rr=(e,t={})=>n=>{let r=Fr({...n,processors:t});return G(e,r),Ir(r,e),Lr(r,e)},q=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Fr({...i??{},target:a,io:t,processors:n});return G(e,o),Ir(o,e),Lr(o,e)},zr={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Br=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=zr[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Vr=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Hr=(e,t,n,r)=>{n.type=`boolean`},Ur=(e,t,n,r)=>{n.not={}},Wr=(e,t,n,r)=>{let i=e._zod.def,a=s(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Gr=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Kr=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},qr=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Jr=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=G(a.element,t,{...r,path:[...r.path,`items`]})},Yr=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=G(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=G(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Xr=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>G(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Zr=(e,t,n,r)=>{let i=e._zod.def,a=G(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=G(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Qr=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=G(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=G(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=G(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},$r=(e,t,n,r)=>{let i=e._zod.def,a=G(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ei=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ti=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ni=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ri=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ii=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;G(o,t,r);let s=t.seen.get(e);s.ref=o},ai=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},oi=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},si=n(`ZodISODateTime`,(e,t)=>{Ft.init(e,t),Z.init(e,t)});function ci(e){return ar(si,e)}const li=n(`ZodISODate`,(e,t)=>{It.init(e,t),Z.init(e,t)});function ui(e){return or(li,e)}const di=n(`ZodISOTime`,(e,t)=>{Lt.init(e,t),Z.init(e,t)});function fi(e){return sr(di,e)}const pi=n(`ZodISODuration`,(e,t)=>{Rt.init(e,t),Z.init(e,t)});function mi(e){return cr(pi,e)}const hi=(e,t)=>{_e.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>be(e,t)},flatten:{value:t=>ye(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,c,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,c,2)}},isEmpty:{get(){return e.issues.length===0}}})},gi=n(`ZodError`,hi),J=n(`ZodError`,hi,{Parent:Error}),_i=O(J),vi=k(J),yi=A(J),bi=j(J),xi=Ce(J),Si=we(J),Ci=Te(J),wi=Ee(J),Ti=De(J),Ei=Oe(J),Di=ke(J),Oi=Ae(J),ki=new WeakMap;function Y(e,t,n){let r=Object.getPrototypeOf(e),i=ki.get(r);if(i||(i=new Set,ki.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}const X=n(`ZodType`,(e,t)=>(P.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:q(e,`input`),output:q(e,`output`)}}),e.toJSONSchema=Rr(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>_i(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>yi(e,t,n),e.parseAsync=async(t,n)=>vi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>bi(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>xi(e,t,n),e.decode=(t,n)=>Si(e,t,n),e.encodeAsync=async(t,n)=>Ci(e,t,n),e.decodeAsync=async(t,n)=>wi(e,t,n),e.safeEncode=(t,n)=>Ti(e,t,n),e.safeDecode=(t,n)=>Ei(e,t,n),e.safeEncodeAsync=async(t,n)=>Di(e,t,n),e.safeDecodeAsync=async(t,n)=>Oi(e,t,n),Y(e,`ZodType`,{check(...e){let t=this.def;return this.clone(g(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return b(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ga(e,t))},superRefine(e,t){return this.check(Ka(e,t))},overwrite(e){return this.check(W(e))},optional(){return Da(this)},exactOptional(){return ka(this)},nullable(){return ja(this)},nullish(){return Da(ja(this))},nonoptional(e){return La(this,e)},array(){return la(this)},or(e){return pa([this,e])},and(e){return _a(this,e)},transform(e){return Va(this,Ta(e))},default(e){return Na(this,e)},prefault(e){return Fa(this,e)},catch(e){return za(this,e)},pipe(e){return Va(this,e)},readonly(){return Ua(this)},describe(e){let t=this.clone();return B.add(t,{description:e}),t},meta(...e){if(e.length===0)return B.get(this);let t=this.clone();return B.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return B.get(e)?.description},configurable:!0}),e)),Ai=n(`_ZodString`,(e,t)=>{F.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Br(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Y(e,`_ZodString`,{regex(...e){return this.check(br(...e))},includes(...e){return this.check(Cr(...e))},startsWith(...e){return this.check(wr(...e))},endsWith(...e){return this.check(Tr(...e))},min(...e){return this.check(U(...e))},max(...e){return this.check(vr(...e))},length(...e){return this.check(yr(...e))},nonempty(...e){return this.check(U(1,...e))},lowercase(e){return this.check(xr(e))},uppercase(e){return this.check(Sr(e))},trim(){return this.check(Dr())},normalize(...e){return this.check(Er(...e))},toLowerCase(){return this.check(Or())},toUpperCase(){return this.check(kr())},slugify(){return this.check(Ar())}})}),ji=n(`ZodString`,(e,t)=>{F.init(e,t),Ai.init(e,t),e.email=t=>e.check(Ln(Ni,t)),e.url=t=>e.check(Un(Fi,t)),e.jwt=t=>e.check(ir(Xi,t)),e.emoji=t=>e.check(Wn(Ii,t)),e.guid=t=>e.check(Rn(Pi,t)),e.uuid=t=>e.check(zn(Q,t)),e.uuidv4=t=>e.check(Bn(Q,t)),e.uuidv6=t=>e.check(Vn(Q,t)),e.uuidv7=t=>e.check(Hn(Q,t)),e.nanoid=t=>e.check(Gn(Li,t)),e.guid=t=>e.check(Rn(Pi,t)),e.cuid=t=>e.check(Kn(Ri,t)),e.cuid2=t=>e.check(qn(zi,t)),e.ulid=t=>e.check(Jn(Bi,t)),e.base64=t=>e.check(tr(qi,t)),e.base64url=t=>e.check(nr(Ji,t)),e.xid=t=>e.check(Yn(Vi,t)),e.ksuid=t=>e.check(Xn(Hi,t)),e.ipv4=t=>e.check(Zn(Ui,t)),e.ipv6=t=>e.check(Qn(Wi,t)),e.cidrv4=t=>e.check($n(Gi,t)),e.cidrv6=t=>e.check(er(Ki,t)),e.e164=t=>e.check(rr(Yi,t)),e.datetime=t=>e.check(ci(t)),e.date=t=>e.check(ui(t)),e.time=t=>e.check(fi(t)),e.duration=t=>e.check(mi(t))});function Mi(e){return In(ji,e)}const Z=n(`ZodStringFormat`,(e,t)=>{I.init(e,t),Ai.init(e,t)}),Ni=n(`ZodEmail`,(e,t)=>{Et.init(e,t),Z.init(e,t)}),Pi=n(`ZodGUID`,(e,t)=>{wt.init(e,t),Z.init(e,t)}),Q=n(`ZodUUID`,(e,t)=>{Tt.init(e,t),Z.init(e,t)}),Fi=n(`ZodURL`,(e,t)=>{Dt.init(e,t),Z.init(e,t)}),Ii=n(`ZodEmoji`,(e,t)=>{Ot.init(e,t),Z.init(e,t)}),Li=n(`ZodNanoID`,(e,t)=>{kt.init(e,t),Z.init(e,t)}),Ri=n(`ZodCUID`,(e,t)=>{At.init(e,t),Z.init(e,t)}),zi=n(`ZodCUID2`,(e,t)=>{jt.init(e,t),Z.init(e,t)}),Bi=n(`ZodULID`,(e,t)=>{Mt.init(e,t),Z.init(e,t)}),Vi=n(`ZodXID`,(e,t)=>{Nt.init(e,t),Z.init(e,t)}),Hi=n(`ZodKSUID`,(e,t)=>{Pt.init(e,t),Z.init(e,t)}),Ui=n(`ZodIPv4`,(e,t)=>{zt.init(e,t),Z.init(e,t)}),Wi=n(`ZodIPv6`,(e,t)=>{Bt.init(e,t),Z.init(e,t)}),Gi=n(`ZodCIDRv4`,(e,t)=>{Vt.init(e,t),Z.init(e,t)}),Ki=n(`ZodCIDRv6`,(e,t)=>{Ht.init(e,t),Z.init(e,t)}),qi=n(`ZodBase64`,(e,t)=>{Wt.init(e,t),Z.init(e,t)}),Ji=n(`ZodBase64URL`,(e,t)=>{Kt.init(e,t),Z.init(e,t)}),Yi=n(`ZodE164`,(e,t)=>{qt.init(e,t),Z.init(e,t)}),Xi=n(`ZodJWT`,(e,t)=>{Yt.init(e,t),Z.init(e,t)}),Zi=n(`ZodNumber`,(e,t)=>{Xt.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vr(e,t,n,r),Y(e,`ZodNumber`,{gt(e,t){return this.check(gr(e,t))},gte(e,t){return this.check(H(e,t))},min(e,t){return this.check(H(e,t))},lt(e,t){return this.check(hr(e,t))},lte(e,t){return this.check(V(e,t))},max(e,t){return this.check(V(e,t))},int(e){return this.check(ea(e))},safe(e){return this.check(ea(e))},positive(e){return this.check(gr(0,e))},nonnegative(e){return this.check(H(0,e))},negative(e){return this.check(hr(0,e))},nonpositive(e){return this.check(V(0,e))},multipleOf(e,t){return this.check(_r(e,t))},step(e,t){return this.check(_r(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Qi(e){return lr(Zi,e)}const $i=n(`ZodNumberFormat`,(e,t)=>{Zt.init(e,t),Zi.init(e,t)});function ea(e){return ur($i,e)}const ta=n(`ZodBoolean`,(e,t)=>{Qt.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hr(e,t,n,r)});function na(e){return dr(ta,e)}const ra=n(`ZodAny`,(e,t)=>{$t.init(e,t),X.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ia(){return fr(ra)}const aa=n(`ZodUnknown`,(e,t)=>{en.init(e,t),X.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function $(){return pr(aa)}const oa=n(`ZodNever`,(e,t)=>{tn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ur(e,t,n,r)});function sa(e){return mr(oa,e)}const ca=n(`ZodArray`,(e,t)=>{rn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jr(e,t,n,r),e.element=t.element,Y(e,`ZodArray`,{min(e,t){return this.check(U(e,t))},nonempty(e){return this.check(U(1,e))},max(e,t){return this.check(vr(e,t))},length(e,t){return this.check(yr(e,t))},unwrap(){return this.element}})});function la(e,t){return jr(ca,e,t)}const ua=n(`ZodObject`,(e,t)=>{cn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yr(e,t,n,r),m(e,`shape`,()=>t.shape),Y(e,`ZodObject`,{keyof(){return xa(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:$()})},loose(){return this.clone({...this._zod.def,catchall:$()})},strict(){return this.clone({...this._zod.def,catchall:sa()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ue(this,e)},safeExtend(e){return de(this,e)},merge(e){return fe(this,e)},pick(e){return ce(this,e)},omit(e){return le(this,e)},partial(...e){return pe(Ea,this,e[0])},required(...e){return me(Ia,this,e[0])}})});function da(e,t){return new ua({type:`object`,shape:e??{},...x(t)})}const fa=n(`ZodUnion`,(e,t)=>{un.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xr(e,t,n,r),e.options=t.options});function pa(e,t){return new fa({type:`union`,options:e,...x(t)})}const ma=n(`ZodDiscriminatedUnion`,(e,t)=>{fa.init(e,t),dn.init(e,t)});function ha(e,t,n){return new ma({type:`union`,options:t,discriminator:e,...x(n)})}const ga=n(`ZodIntersection`,(e,t)=>{fn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zr(e,t,n,r)});function _a(e,t){return new ga({type:`intersection`,left:e,right:t})}const va=n(`ZodRecord`,(e,t)=>{mn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qr(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ya(e,t,n){return!t||!t._zod?new va({type:`record`,keyType:Mi(),valueType:e,...x(t)}):new va({type:`record`,keyType:e,valueType:t,...x(n)})}const ba=n(`ZodEnum`,(e,t)=>{hn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wr(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new ba({...t,checks:[],...x(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new ba({...t,checks:[],...x(r),entries:i})}});function xa(e,t){return new ba({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...x(t)})}const Sa=n(`ZodLiteral`,(e,t)=>{gn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gr(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ca(e,t){return new Sa({type:`literal`,values:Array.isArray(e)?e:[e],...x(t)})}const wa=n(`ZodTransform`,(e,t)=>{_n.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qr(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new i(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(D(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(D(t))}};let a=t.transform(n.value,n);return a instanceof Promise?a.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=a,n.fallback=!0,n)}});function Ta(e){return new wa({type:`transform`,transform:e})}const Ea=n(`ZodOptional`,(e,t)=>{yn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Da(e){return new Ea({type:`optional`,innerType:e})}const Oa=n(`ZodExactOptional`,(e,t)=>{bn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ka(e){return new Oa({type:`optional`,innerType:e})}const Aa=n(`ZodNullable`,(e,t)=>{xn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$r(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ja(e){return new Aa({type:`nullable`,innerType:e})}const Ma=n(`ZodDefault`,(e,t)=>{Sn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ti(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Na(e,t){return new Ma({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}const Pa=n(`ZodPrefault`,(e,t)=>{wn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ni(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fa(e,t){return new Pa({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}const Ia=n(`ZodNonOptional`,(e,t)=>{Tn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ei(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function La(e,t){return new Ia({type:`nonoptional`,innerType:e,...x(t)})}const Ra=n(`ZodCatch`,(e,t)=>{Dn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ri(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function za(e,t){return new Ra({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Ba=n(`ZodPipe`,(e,t)=>{On.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ii(e,t,n,r),e.in=t.in,e.out=t.out});function Va(e,t){return new Ba({type:`pipe`,in:e,out:t})}const Ha=n(`ZodReadonly`,(e,t)=>{kn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ai(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ua(e){return new Ha({type:`readonly`,innerType:e})}const Wa=n(`ZodCustom`,(e,t)=>{jn.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kr(e,t,n,r)});function Ga(e,t={}){return Mr(Wa,e,t)}function Ka(e,t){return Nr(e,t)}const qa=`2.3.0`;export{na as a,Qi as c,Mi as d,pa as f,t as h,la as i,da as l,gi as m,xa as n,ha as o,$ as p,ia as r,Ca as s,qa as t,ya as u};
|
|
@@ -19,7 +19,7 @@ export declare const ROOT_COMPILED_AGENT_NODE_ID = "__root__";
|
|
|
19
19
|
/**
|
|
20
20
|
* Current compiled manifest schema version.
|
|
21
21
|
*/
|
|
22
|
-
export declare const COMPILED_AGENT_MANIFEST_VERSION =
|
|
22
|
+
export declare const COMPILED_AGENT_MANIFEST_VERSION = 32;
|
|
23
23
|
/**
|
|
24
24
|
* Compiled channel entry preserved in the compiled manifest.
|
|
25
25
|
*/
|
|
@@ -455,7 +455,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
|
|
|
455
455
|
sourceId: z.ZodString;
|
|
456
456
|
sourceKind: z.ZodLiteral<"module">;
|
|
457
457
|
}, z.core.$strict>>;
|
|
458
|
-
version: z.ZodLiteral<
|
|
458
|
+
version: z.ZodLiteral<32>;
|
|
459
459
|
workspaceResourceRoot: z.ZodObject<{
|
|
460
460
|
contentHash: z.ZodOptional<z.ZodString>;
|
|
461
461
|
logicalPath: z.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{discoverDiagnosticsSummarySchema}from"#discover/diagnostics.js";import{compiledRemoteAgentNodeSchema}from"#compiler/remote-agent-node.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const COMPILED_AGENT_MANIFEST_KIND=`eve-agent-compiled-manifest`,ROOT_COMPILED_AGENT_NODE_ID=`__root__`,COMPILED_AGENT_MANIFEST_VERSION=31,moduleSourceRefSchema=z.object({exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),channelMethodSchema=z.union([z.literal(`GET`),z.literal(`POST`),z.literal(`PUT`),z.literal(`PATCH`),z.literal(`DELETE`),z.literal(`WEBSOCKET`)]),compiledChannelCorsSchema=z.object({origin:z.union([z.literal(`*`),z.literal(`null`),z.array(z.string())]).optional(),methods:z.union([z.literal(`*`),z.array(z.string())]).optional(),allowHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),exposeHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),credentials:z.boolean().optional(),maxAge:z.union([z.string(),z.literal(!1)]).optional(),preflight:z.object({statusCode:z.number().int().min(100).max(599).optional()}).strict().optional()}).strict(),compiledChannelDefinitionSchema=z.object({kind:z.literal(`channel`),name:z.string(),logicalPath:z.string(),method:channelMethodSchema,urlPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional(),adapterKind:z.string().optional(),cors:compiledChannelCorsSchema.optional()}).strict(),disabledCompiledChannelEntrySchema=z.object({kind:z.literal(`disabled`),name:z.string(),logicalPath:z.string()}).strict(),compiledChannelEntrySchema=z.union([compiledChannelDefinitionSchema,disabledCompiledChannelEntrySchema]),modelRoutingSchema=z.union([z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}).strict(),z.object({kind:z.literal(`external`),provider:z.string()}).strict()]),compiledRuntimeModelReferenceSchema=z.object({contextWindowTokens:z.number().int().positive().optional(),id:z.string(),source:moduleSourceRefSchema.optional(),providerOptions:z.record(z.string(),jsonObjectSchema).optional(),routing:modelRoutingSchema}).strict(),compiledAgentBuildDefinitionSchema=z.object({externalDependencies:z.array(z.string()).optional()}).strict(),compiledAgentWorkflowWorldDefinitionSchema=z.string(),compiledAgentWorkflowDefinitionSchema=z.object({world:compiledAgentWorkflowWorldDefinitionSchema.optional()}).strict(),compiledAgentCompactionDefinitionSchema=z.object({model:compiledRuntimeModelReferenceSchema.optional(),thresholdPercent:z.number().finite().min(0).max(1).optional()}).strict(),compiledAgentConfigSchema=z.object({build:compiledAgentBuildDefinitionSchema.optional(),compaction:compiledAgentCompactionDefinitionSchema.optional(),description:z.string().optional(),experimental:z.object({workflow:compiledAgentWorkflowDefinitionSchema.optional()}).strict().optional(),model:compiledRuntimeModelReferenceSchema,name:z.string(),outputSchema:jsonObjectSchema.optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional(),source:moduleSourceRefSchema.optional()}).strict(),compiledInstructionsSchema=z.object({name:z.string(),logicalPath:z.string(),markdown:z.string(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSkillBaseFields={name:z.string(),description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional(),sourceId:z.string(),logicalPath:z.string()},compiledSkillSourceSchema=z.discriminatedUnion(`sourceKind`,[z.object({...compiledSkillBaseFields,sourceKind:z.literal(`markdown`)}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`skill-package`),skillId:z.string(),skillFilePath:z.string(),rootPath:z.string(),assetsPath:z.string().optional(),referencesPath:z.string().optional(),scriptsPath:z.string().optional()}).strict()]),compiledScheduleDefinitionSchema=z.object({cron:z.string(),hasRun:z.boolean(),name:z.string(),logicalPath:z.string(),markdown:z.string().optional(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSandboxDefinitionSchema=z.object({backendName:z.string().optional(),description:z.string().optional(),exportName:z.string().optional(),logicalPath:z.string(),revalidationKey:z.string().optional(),sourceHash:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSandboxWorkspaceSchema=z.object({logicalPath:z.string(),rootEntries:z.array(z.string()).readonly(),sourceId:z.string(),sourcePath:z.string()}).strict(),compiledWorkspaceResourceRootSchema=z.object({contentHash:z.string().optional(),logicalPath:z.string(),rootEntries:z.array(z.string()).readonly()}).strict(),compiledConnectionDefinitionSchema=z.object({connectionName:z.string(),description:z.string(),exportName:z.string().optional(),logicalPath:z.string(),protocol:z.enum([`mcp`,`openapi`]).default(`mcp`),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string(),vercelConnect:z.object({connector:z.string()}).strict().optional()}).strict(),compiledToolDefinitionSchema=z.object({description:z.string(),exportName:z.string().optional(),inputSchema:jsonObjectSchema.nullable(),logicalPath:z.string(),name:z.string(),outputSchema:jsonObjectSchema.optional(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicToolDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicSkillDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicInstructionsDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledHookDefinitionSchema=z.object({exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledAgentNodeManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowEnabled:z.boolean().default(!1),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),remoteAgents:z.array(compiledRemoteAgentNodeSchema),skills:z.array(compiledSkillSourceSchema).readonly(),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict(),compiledSubagentNodeSchema=z.object({agent:compiledAgentNodeManifestSchema,description:z.string(),entryPath:z.string(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),compiledSubagentEdgeSchema=z.object({childNodeId:z.string(),parentNodeId:z.string()}).strict(),compiledAgentManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowEnabled:z.boolean().default(!1),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),kind:z.literal(COMPILED_AGENT_MANIFEST_KIND),remoteAgents:z.array(compiledRemoteAgentNodeSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),skills:z.array(compiledSkillSourceSchema).readonly(),subagentEdges:z.array(compiledSubagentEdgeSchema),subagents:z.array(compiledSubagentNodeSchema),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),version:z.literal(31),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict();function createCompiledAgentNodeManifest(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cloneCompiledRuntimeModelReference(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,experimental:e.config.experimental===void 0?void 0:{workflow:e.config.experimental.workflow===void 0?void 0:{world:e.config.experimental.workflow.world}},model:cloneCompiledRuntimeModelReference(e.config.model),name:e.config.name,outputSchema:e.config.outputSchema,reasoning:e.config.reasoning,source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],workflowEnabled:e.workflowEnabled??!1,dynamicInstructions:[...e.dynamicInstructions??[]],dynamicSkills:[...e.dynamicSkills??[]],dynamicTools:[...e.dynamicTools??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:deriveResourceRootEntries({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function deriveResourceRootEntries(e){let t=new Set;(e.skills??[]).length>0&&t.add(`skills/`);for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function createCompiledSubagentNodeId(e,t){return e===`__root__`?t:`${e}::${t}`}function createCompiledAgentManifest(e){return{...createCompiledAgentNodeManifest(e),kind:COMPILED_AGENT_MANIFEST_KIND,subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:31}}function cloneCompiledRuntimeModelReference(e){let t={id:e.id,routing:cloneModelRouting(e.routing)};return e.contextWindowTokens!==void 0&&(t.contextWindowTokens=e.contextWindowTokens),e.providerOptions!==void 0&&(t.providerOptions={...e.providerOptions}),e.source!==void 0&&(t.source={...e.source}),t}function cloneModelRouting(e){return e.kind===`external`?{kind:`external`,provider:e.provider}:e.byok===void 0?{kind:`gateway`,target:e.target}:{kind:`gateway`,target:e.target,byok:e.byok}}export{COMPILED_AGENT_MANIFEST_KIND,COMPILED_AGENT_MANIFEST_VERSION,ROOT_COMPILED_AGENT_NODE_ID,compiledAgentManifestSchema,createCompiledAgentManifest,createCompiledAgentNodeManifest,createCompiledSubagentNodeId,deriveResourceRootEntries};
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{discoverDiagnosticsSummarySchema}from"#discover/diagnostics.js";import{compiledRemoteAgentNodeSchema}from"#compiler/remote-agent-node.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const COMPILED_AGENT_MANIFEST_KIND=`eve-agent-compiled-manifest`,ROOT_COMPILED_AGENT_NODE_ID=`__root__`,COMPILED_AGENT_MANIFEST_VERSION=32,moduleSourceRefSchema=z.object({exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),channelMethodSchema=z.union([z.literal(`GET`),z.literal(`POST`),z.literal(`PUT`),z.literal(`PATCH`),z.literal(`DELETE`),z.literal(`WEBSOCKET`)]),compiledChannelCorsSchema=z.object({origin:z.union([z.literal(`*`),z.literal(`null`),z.array(z.string())]).optional(),methods:z.union([z.literal(`*`),z.array(z.string())]).optional(),allowHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),exposeHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),credentials:z.boolean().optional(),maxAge:z.union([z.string(),z.literal(!1)]).optional(),preflight:z.object({statusCode:z.number().int().min(100).max(599).optional()}).strict().optional()}).strict(),compiledChannelDefinitionSchema=z.object({kind:z.literal(`channel`),name:z.string(),logicalPath:z.string(),method:channelMethodSchema,urlPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional(),adapterKind:z.string().optional(),cors:compiledChannelCorsSchema.optional()}).strict(),disabledCompiledChannelEntrySchema=z.object({kind:z.literal(`disabled`),name:z.string(),logicalPath:z.string()}).strict(),compiledChannelEntrySchema=z.union([compiledChannelDefinitionSchema,disabledCompiledChannelEntrySchema]),modelRoutingSchema=z.union([z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}).strict(),z.object({kind:z.literal(`external`),provider:z.string()}).strict()]),compiledRuntimeModelReferenceSchema=z.object({contextWindowTokens:z.number().int().positive().optional(),id:z.string(),source:moduleSourceRefSchema.optional(),providerOptions:z.record(z.string(),jsonObjectSchema).optional(),routing:modelRoutingSchema}).strict(),compiledAgentBuildDefinitionSchema=z.object({externalDependencies:z.array(z.string()).optional()}).strict(),compiledAgentWorkflowWorldDefinitionSchema=z.string(),compiledAgentWorkflowDefinitionSchema=z.object({world:compiledAgentWorkflowWorldDefinitionSchema.optional()}).strict(),compiledAgentCompactionDefinitionSchema=z.object({model:compiledRuntimeModelReferenceSchema.optional(),thresholdPercent:z.number().finite().min(0).max(1).optional()}).strict(),compiledAgentLimitsDefinitionSchema=z.object({maxSubagentDepth:z.number().int().positive().optional(),maxInputTokensPerSession:z.number().int().positive().optional(),maxOutputTokensPerSession:z.number().int().positive().optional()}).strict(),compiledAgentConfigSchema=z.object({build:compiledAgentBuildDefinitionSchema.optional(),compaction:compiledAgentCompactionDefinitionSchema.optional(),description:z.string().optional(),experimental:z.object({workflow:compiledAgentWorkflowDefinitionSchema.optional()}).strict().optional(),model:compiledRuntimeModelReferenceSchema,name:z.string(),outputSchema:jsonObjectSchema.optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional(),source:moduleSourceRefSchema.optional(),limits:compiledAgentLimitsDefinitionSchema.optional()}).strict(),compiledInstructionsSchema=z.object({name:z.string(),logicalPath:z.string(),markdown:z.string(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSkillBaseFields={name:z.string(),description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional(),sourceId:z.string(),logicalPath:z.string()},compiledSkillSourceSchema=z.discriminatedUnion(`sourceKind`,[z.object({...compiledSkillBaseFields,sourceKind:z.literal(`markdown`)}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`skill-package`),skillId:z.string(),skillFilePath:z.string(),rootPath:z.string(),assetsPath:z.string().optional(),referencesPath:z.string().optional(),scriptsPath:z.string().optional()}).strict()]),compiledScheduleDefinitionSchema=z.object({cron:z.string(),hasRun:z.boolean(),name:z.string(),logicalPath:z.string(),markdown:z.string().optional(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSandboxDefinitionSchema=z.object({backendName:z.string().optional(),description:z.string().optional(),exportName:z.string().optional(),logicalPath:z.string(),revalidationKey:z.string().optional(),sourceHash:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSandboxWorkspaceSchema=z.object({logicalPath:z.string(),rootEntries:z.array(z.string()).readonly(),sourceId:z.string(),sourcePath:z.string()}).strict(),compiledWorkspaceResourceRootSchema=z.object({contentHash:z.string().optional(),logicalPath:z.string(),rootEntries:z.array(z.string()).readonly()}).strict(),compiledConnectionDefinitionSchema=z.object({connectionName:z.string(),description:z.string(),exportName:z.string().optional(),logicalPath:z.string(),protocol:z.enum([`mcp`,`openapi`]).default(`mcp`),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string(),vercelConnect:z.object({connector:z.string()}).strict().optional()}).strict(),compiledToolDefinitionSchema=z.object({description:z.string(),exportName:z.string().optional(),inputSchema:jsonObjectSchema.nullable(),logicalPath:z.string(),name:z.string(),outputSchema:jsonObjectSchema.optional(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicToolDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicSkillDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicInstructionsDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledHookDefinitionSchema=z.object({exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledAgentNodeManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowEnabled:z.boolean().default(!1),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),remoteAgents:z.array(compiledRemoteAgentNodeSchema),skills:z.array(compiledSkillSourceSchema).readonly(),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict(),compiledSubagentNodeSchema=z.object({agent:compiledAgentNodeManifestSchema,description:z.string(),entryPath:z.string(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),compiledSubagentEdgeSchema=z.object({childNodeId:z.string(),parentNodeId:z.string()}).strict(),compiledAgentManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowEnabled:z.boolean().default(!1),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),kind:z.literal(COMPILED_AGENT_MANIFEST_KIND),remoteAgents:z.array(compiledRemoteAgentNodeSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),skills:z.array(compiledSkillSourceSchema).readonly(),subagentEdges:z.array(compiledSubagentEdgeSchema),subagents:z.array(compiledSubagentNodeSchema),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),version:z.literal(32),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict();function createCompiledAgentNodeManifest(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cloneCompiledRuntimeModelReference(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,experimental:e.config.experimental===void 0?void 0:{workflow:e.config.experimental.workflow===void 0?void 0:{world:e.config.experimental.workflow.world}},model:cloneCompiledRuntimeModelReference(e.config.model),name:e.config.name,outputSchema:e.config.outputSchema,reasoning:e.config.reasoning,limits:e.config.limits===void 0?void 0:{maxInputTokensPerSession:e.config.limits.maxInputTokensPerSession,maxOutputTokensPerSession:e.config.limits.maxOutputTokensPerSession,maxSubagentDepth:e.config.limits.maxSubagentDepth},source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],workflowEnabled:e.workflowEnabled??!1,dynamicInstructions:[...e.dynamicInstructions??[]],dynamicSkills:[...e.dynamicSkills??[]],dynamicTools:[...e.dynamicTools??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:deriveResourceRootEntries({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function deriveResourceRootEntries(e){let t=new Set;(e.skills??[]).length>0&&t.add(`skills/`);for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function createCompiledSubagentNodeId(e,t){return e===`__root__`?t:`${e}::${t}`}function createCompiledAgentManifest(e){return{...createCompiledAgentNodeManifest(e),kind:COMPILED_AGENT_MANIFEST_KIND,subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:32}}function cloneCompiledRuntimeModelReference(e){let t={id:e.id,routing:cloneModelRouting(e.routing)};return e.contextWindowTokens!==void 0&&(t.contextWindowTokens=e.contextWindowTokens),e.providerOptions!==void 0&&(t.providerOptions={...e.providerOptions}),e.source!==void 0&&(t.source={...e.source}),t}function cloneModelRouting(e){return e.kind===`external`?{kind:`external`,provider:e.provider}:e.byok===void 0?{kind:`gateway`,target:e.target}:{kind:`gateway`,target:e.target,byok:e.byok}}export{COMPILED_AGENT_MANIFEST_KIND,COMPILED_AGENT_MANIFEST_VERSION,ROOT_COMPILED_AGENT_NODE_ID,compiledAgentManifestSchema,createCompiledAgentManifest,createCompiledAgentNodeManifest,createCompiledSubagentNodeId,deriveResourceRootEntries};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isAbsolute,join,relative,resolve}from"node:path";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{toErrorMessage}from"#shared/errors.js";import{normalizeJsonSchemaDefinition}from"#shared/json-schema.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{classifyModelRouting}from"#internal/classify-model-routing.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{parseJsonObject}from"#shared/json.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";async function compileAgentConfig(e,t){let n=e.configModule,r=n===void 0?void 0:formatAgentConfigModulePath(e,n),a=normalizeAgentDefinition(n===void 0?{model:DEFAULT_AGENT_MODEL_ID}:await loadModuleBackedDefinition({agentRoot:e.agentRoot,displayPath:r,kind:`agent config`,source:n}),n===void 0?`Expected the default agent config to match the public eve shape.`:`Expected the agent config export "${n.exportName??`default`}" from "${r}" to match the public eve shape.`),o=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:a.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:a.model}),s={},c={compaction:s,model:o,name:e.agentId};a.description!==void 0&&(c.description=a.description);let l=normalizeExperimentalDefinition(a.experimental);return l!==void 0&&(c.experimental=l),a.build!==void 0&&(c.build={externalDependencies:a.build.externalDependencies===void 0?void 0:[...a.build.externalDependencies]}),a.outputSchema!==void 0&&(c.outputSchema=normalizeJsonSchemaDefinition(a.outputSchema,`output`)),a.reasoning!==void 0&&(c.reasoning=a.reasoning),n!==void 0&&(c.source={exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId}),a.compaction?.model!==void 0&&(s.model=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:a.compaction.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:a.compaction.model})),a.compaction?.thresholdPercent!==void 0&&(s.thresholdPercent=a.compaction.thresholdPercent),c}function normalizeExperimentalDefinition(e){if(e===void 0)return;let t={};return e.workflow!==void 0&&(t.workflow={world:e.workflow.world}),t}async function normalizeAuthoredModelReference(e){if(typeof e.value==`string`)return await withCompiledRuntimeModelLimits({id:formatLanguageModelGatewayId(e.value),providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(e.value,e.providerOptions)},e);let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,r=n.specificationVersion;if(r!==`v2`&&r!==`v3`&&r!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${e.sourcePath??t.logicalPath}" to provide a valid AI SDK language model.`);let i={id:formatLanguageModelGatewayId(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(n,e.providerOptions)};if(e.contextWindowTokens===void 0){let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...i,id:t.slug,contextWindowTokens:t.limits.contextWindowTokens}}return await withCompiledRuntimeModelLimits(i,e)}function formatAgentConfigModulePath(e,r){let i=join(e.agentRoot,r.logicalPath);return normalizeLogicalPath(relative(resolveTopLevelAgentRoot(e),i))}function resolveTopLevelAgentRoot(e){let t=resolve(e.appRoot),n=resolve(t,`agent`);return isPathInsideOrEqual(n,resolve(e.agentRoot))?n:t}function isPathInsideOrEqual(t,r){let i=relative(t,r);return i===``||!i.startsWith(`..`)&&!isAbsolute(i)}async function withCompiledRuntimeModelLimits(e,t){if(t.contextWindowTokens!==void 0)return{...e,contextWindowTokens:t.contextWindowTokens};let n;try{n=await t.modelCatalog.getModelLimits(e.id)}catch(n){throw Error(`Failed to load AI Gateway model metadata for ${t.purpose} "${e.id}". ${toErrorMessage(n)}`)}if(n===null)throw Error(`Cannot compile agent compaction because ${t.purpose} "${e.id}" does not have known AI Gateway context window metadata.`);return{...e,contextWindowTokens:n.contextWindowTokens}}function parseProviderOptionsRecord(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=parseJsonObject(r);return t}export{compileAgentConfig};
|
|
1
|
+
import{isAbsolute,join,relative,resolve}from"node:path";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{toErrorMessage}from"#shared/errors.js";import{normalizeJsonSchemaDefinition}from"#shared/json-schema.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{classifyModelRouting}from"#internal/classify-model-routing.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{parseJsonObject}from"#shared/json.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";async function compileAgentConfig(e,t){let n=e.configModule,r=n===void 0?void 0:formatAgentConfigModulePath(e,n),a=normalizeAgentDefinition(n===void 0?{model:DEFAULT_AGENT_MODEL_ID}:await loadModuleBackedDefinition({agentRoot:e.agentRoot,displayPath:r,kind:`agent config`,source:n}),n===void 0?`Expected the default agent config to match the public eve shape.`:`Expected the agent config export "${n.exportName??`default`}" from "${r}" to match the public eve shape.`),o=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:a.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:a.model}),s={},c={compaction:s,model:o,name:e.agentId};a.description!==void 0&&(c.description=a.description);let l=normalizeExperimentalDefinition(a.experimental);return l!==void 0&&(c.experimental=l),a.build!==void 0&&(c.build={externalDependencies:a.build.externalDependencies===void 0?void 0:[...a.build.externalDependencies]}),a.outputSchema!==void 0&&(c.outputSchema=normalizeJsonSchemaDefinition(a.outputSchema,`output`)),a.reasoning!==void 0&&(c.reasoning=a.reasoning),a.limits!==void 0&&(c.limits={maxSubagentDepth:a.limits.maxSubagentDepth,maxInputTokensPerSession:a.limits.maxInputTokensPerSession,maxOutputTokensPerSession:a.limits.maxOutputTokensPerSession}),n!==void 0&&(c.source={exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId}),a.compaction?.model!==void 0&&(s.model=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:a.compaction.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:a.compaction.model})),a.compaction?.thresholdPercent!==void 0&&(s.thresholdPercent=a.compaction.thresholdPercent),c}function normalizeExperimentalDefinition(e){if(e===void 0)return;let t={};return e.workflow!==void 0&&(t.workflow={world:e.workflow.world}),t}async function normalizeAuthoredModelReference(e){if(typeof e.value==`string`)return await withCompiledRuntimeModelLimits({id:formatLanguageModelGatewayId(e.value),providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(e.value,e.providerOptions)},e);let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,r=n.specificationVersion;if(r!==`v2`&&r!==`v3`&&r!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${e.sourcePath??t.logicalPath}" to provide a valid AI SDK language model.`);let i={id:formatLanguageModelGatewayId(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(n,e.providerOptions)};if(e.contextWindowTokens===void 0){let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...i,id:t.slug,contextWindowTokens:t.limits.contextWindowTokens}}return await withCompiledRuntimeModelLimits(i,e)}function formatAgentConfigModulePath(e,r){let i=join(e.agentRoot,r.logicalPath);return normalizeLogicalPath(relative(resolveTopLevelAgentRoot(e),i))}function resolveTopLevelAgentRoot(e){let t=resolve(e.appRoot),n=resolve(t,`agent`);return isPathInsideOrEqual(n,resolve(e.agentRoot))?n:t}function isPathInsideOrEqual(t,r){let i=relative(t,r);return i===``||!i.startsWith(`..`)&&!isAbsolute(i)}async function withCompiledRuntimeModelLimits(e,t){if(t.contextWindowTokens!==void 0)return{...e,contextWindowTokens:t.contextWindowTokens};let n;try{n=await t.modelCatalog.getModelLimits(e.id)}catch(n){throw Error(`Failed to load AI Gateway model metadata for ${t.purpose} "${e.id}". ${toErrorMessage(n)}`)}if(n===null)throw Error(`Cannot compile agent compaction because ${t.purpose} "${e.id}" does not have known AI Gateway context window metadata.`);return{...e,contextWindowTokens:n.contextWindowTokens}}function parseProviderOptionsRecord(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=parseJsonObject(r);return t}export{compileAgentConfig};
|
|
@@ -42,6 +42,8 @@ export declare const ChannelRequestIdKey: ContextKey<string>;
|
|
|
42
42
|
export declare const ChannelInstrumentationKey: ContextKey<ChannelInstrumentationProjection>;
|
|
43
43
|
export declare const ModeKey: ContextKey<RunMode>;
|
|
44
44
|
export declare const ParentSessionKey: ContextKey<SessionParent>;
|
|
45
|
+
export declare const SubagentDepthKey: ContextKey<number>;
|
|
46
|
+
export declare const SubagentMaxDepthKey: ContextKey<number>;
|
|
45
47
|
/**
|
|
46
48
|
* Session-level capability flags (see {@link SessionCapabilities}). Set
|
|
47
49
|
* on root runs by channel routes and inherited pointwise by subagent
|
package/dist/src/context/keys.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ContextKey}from"#context/key.js";const AuthKey=new ContextKey(`eve.auth`),InitiatorAuthKey=new ContextKey(`eve.initiatorAuth`),SessionIdKey=new ContextKey(`eve.sessionId`),ContinuationTokenKey=new ContextKey(`eve.continuationToken`),ChannelRequestIdKey=new ContextKey(`eve.channelRequestId`),ChannelInstrumentationKey=new ContextKey(`eve.channelInstrumentation`),ModeKey=new ContextKey(`eve.mode`),ParentSessionKey=new ContextKey(`eve.parentSession`),CapabilitiesKey=new ContextKey(`eve.capabilities`),SessionCallbackKey=new ContextKey(`eve.sessionCallback`),SessionKey=new ContextKey(`eve.session`),SandboxKey=new ContextKey(`eve.sandbox`),SessionDynamicToolMetadataKey=new ContextKey(`eve.sessionDynamicToolMetadata`),TurnDynamicToolMetadataKey=new ContextKey(`eve.turnDynamicToolMetadata`),LiveStepToolsKey=new ContextKey(`eve.liveStepTools`),DynamicSkillManifestKey=new ContextKey(`eve.dynamicSkillManifest`),SessionDynamicInstructionsKey=new ContextKey(`eve.sessionDynamicInstructions`),TurnDynamicInstructionsKey=new ContextKey(`eve.turnDynamicInstructions`);export{AuthKey,CapabilitiesKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationTokenKey,DynamicSkillManifestKey,InitiatorAuthKey,LiveStepToolsKey,ModeKey,ParentSessionKey,SandboxKey,SessionCallbackKey,SessionDynamicInstructionsKey,SessionDynamicToolMetadataKey,SessionIdKey,SessionKey,TurnDynamicInstructionsKey,TurnDynamicToolMetadataKey};
|
|
1
|
+
import{ContextKey}from"#context/key.js";const AuthKey=new ContextKey(`eve.auth`),InitiatorAuthKey=new ContextKey(`eve.initiatorAuth`),SessionIdKey=new ContextKey(`eve.sessionId`),ContinuationTokenKey=new ContextKey(`eve.continuationToken`),ChannelRequestIdKey=new ContextKey(`eve.channelRequestId`),ChannelInstrumentationKey=new ContextKey(`eve.channelInstrumentation`),ModeKey=new ContextKey(`eve.mode`),ParentSessionKey=new ContextKey(`eve.parentSession`),SubagentDepthKey=new ContextKey(`eve.subagentDepth`),SubagentMaxDepthKey=new ContextKey(`eve.subagentMaxDepth`),CapabilitiesKey=new ContextKey(`eve.capabilities`),SessionCallbackKey=new ContextKey(`eve.sessionCallback`),SessionKey=new ContextKey(`eve.session`),SandboxKey=new ContextKey(`eve.sandbox`),SessionDynamicToolMetadataKey=new ContextKey(`eve.sessionDynamicToolMetadata`),TurnDynamicToolMetadataKey=new ContextKey(`eve.turnDynamicToolMetadata`),LiveStepToolsKey=new ContextKey(`eve.liveStepTools`),DynamicSkillManifestKey=new ContextKey(`eve.dynamicSkillManifest`),SessionDynamicInstructionsKey=new ContextKey(`eve.sessionDynamicInstructions`),TurnDynamicInstructionsKey=new ContextKey(`eve.turnDynamicInstructions`);export{AuthKey,CapabilitiesKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationTokenKey,DynamicSkillManifestKey,InitiatorAuthKey,LiveStepToolsKey,ModeKey,ParentSessionKey,SandboxKey,SessionCallbackKey,SessionDynamicInstructionsKey,SessionDynamicToolMetadataKey,SessionIdKey,SessionKey,SubagentDepthKey,SubagentMaxDepthKey,TurnDynamicInstructionsKey,TurnDynamicToolMetadataKey};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{deepEquals,eventMatches,subagentCallMatches,testRegExp,toolCallMatches}from"#evals/match.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";const PASS={score:1},fail=(e,t)=>({score:0,message:e,metadata:t});function succeeded(){return{name:`succeeded`,evaluate(e){let t=runFailure(e);return t===void 0?e.derived.parked?fail(`run parked on ${e.derived.inputRequests.length} unanswered input request(s)`):PASS:t}}}function parked(){return{name:`parked`,evaluate(e){let t=runFailure(e);return t===void 0?e.derived.parked?PASS:fail(`expected the run to park on HITL input; it ended "${e.status}" with no pending requests`):t}}}function messageIncludes(e){return{name:`messageIncludes(${String(e)})`,evaluate(t){let n=joinCompletedMessages(t.events);return(typeof e==`string`?n.includes(e):testRegExp(e,n))?PASS:fail(`assistant messages did not include ${String(e)}; got: ${truncate(n)}`)}}}function calledTool(e,t={}){return validateCount(t.count),{name:`calledTool(${e})`,evaluate(n){let r=n.derived.toolCalls.filter(t=>t.name===e),a=r.filter(e=>toolCallMatches(e,t));if(t.count===void 0?a.length>0:a.length===t.count)return{score:1,metadata:{matchingCalls:a.length}};let o=r.length>0?`observed ${e} calls: ${r.map(e=>truncate(JSON.stringify(e.input))).join(`, `)}`:`observed tools: [${n.derived.toolCalls.map(e=>e.name).join(`, `)}]`;return fail(`${t.count===void 0?`expected a matching call to "${e}"`:`expected exactly ${t.count} matching call(s), found ${a.length}`}; ${o}`)}}}function loadedSkill(e,t={}){return{...calledTool(LOAD_SKILL_TOOL_NAME,{...t,input:{skill:e}}),name:`loadedSkill(${e})`}}function notCalledTool(e){return{name:`notCalledTool(${e})`,evaluate(t){let n=t.derived.toolCalls.filter(t=>t.name===e).length;return n===0?PASS:fail(`"${e}" was called ${n} time(s)`)}}}function toolOrder(e){return{name:`toolOrder(${e.join(` → `)})`,evaluate(t){let n=requestedTools(t.events).map(e=>e.name),r=missingOrderedName(e,n);return r===void 0?PASS:fail(`missing "${r.name}" after [${e.slice(0,r.cursor).join(`, `)}]; observed request order: [${n.join(`, `)}]`)}}}function usedNoTools(){return{name:`usedNoTools`,evaluate(e){let t=e.derived.toolCallCount;return t===0?PASS:fail(`expected no tool calls, got ${t}`,{toolCallCount:t})}}}function maxToolCalls(e){return validateCount(e),{name:`maxToolCalls(${e})`,evaluate(t){let n=t.derived.toolCallCount;return n<=e?PASS:fail(`expected at most ${e} tool calls, got ${n}`,{maxAllowed:e,toolCallCount:n})}}}function noFailedActions(){return{name:`noFailedActions`,evaluate(e){let t=e.events.filter(e=>e.type===`action.result`&&(e.data.status===`failed`||e.data.result.isError===!0));if(t.length===0)return PASS;let n=t.map(
|
|
2
|
-
`)}function failureDetail(e,t){return t===void 0?e:`${e} (code: ${t})`}function runFailure(e){if(e.status===`failed`)return fail(failureDetail(`run failed`,e.derived.failureCode));let t=e.events.find(e=>e.type===`turn.failed`||e.type===`step.failed`);return t===void 0?void 0:fail(`${t.type} (${t.data.code}): ${t.data.message}`)}function truncate(e,t=200){return e===void 0?`undefined`:e.length<=t?e:`${e.slice(0,t)}…`}function validateCount(e){if(e!==void 0&&(!Number.isInteger(e)||e<0))throw TypeError(`Assertion count must be a non-negative integer; received ${e}.`)}function missingOrderedName(e,t){let n=0;for(let r of t)if(r===e[n]&&(n+=1),n===e.length)return;let r=e[n];return r===void 0?void 0:{cursor:n,name:r}}function requestedTools(e){let t=[],n=new Set,append=(e,r)=>{n.has(e)||(n.add(e),t.push({callId:e,name:r}))};for(let t of e)if(t.type===`actions.requested`)for(let e of t.data.actions)e.kind===`tool-call`&&append(e.callId,e.toolName);else if(t.type===`input.requested`)for(let e of t.data.requests){let{action:t}=e;t.kind===`tool-call`&&append(t.callId,t.toolName)}return t}export{calledSubagent,calledTool,eventOrder,eventsSatisfy,loadedSkill,maxToolCalls,messageIncludes,noFailedActions,notCalledTool,notEvent,outputEquals,outputMatches,parked,succeeded,toolOrder,typedEvent,usedNoTools};
|
|
1
|
+
import{deepEquals,eventMatches,subagentCallMatches,testRegExp,toolCallMatches}from"#evals/match.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";const PASS={score:1},fail=(e,t)=>({score:0,message:e,metadata:t});function succeeded(){return{name:`succeeded`,evaluate(e){let t=runFailure(e);return t===void 0?e.derived.parked?fail(`run parked on ${e.derived.inputRequests.length} unanswered input request(s)`):PASS:t}}}function parked(){return{name:`parked`,evaluate(e){let t=runFailure(e);return t===void 0?e.derived.parked?PASS:fail(`expected the run to park on HITL input; it ended "${e.status}" with no pending requests`):t}}}function messageIncludes(e){return{name:`messageIncludes(${String(e)})`,evaluate(t){let n=joinCompletedMessages(t.events);return(typeof e==`string`?n.includes(e):testRegExp(e,n))?PASS:fail(`assistant messages did not include ${String(e)}; got: ${truncate(n)}`)}}}function calledTool(e,t={}){return validateCount(t.count),{name:`calledTool(${e})`,evaluate(n){let r=n.derived.toolCalls.filter(t=>t.name===e),a=r.filter(e=>toolCallMatches(e,t));if(t.count===void 0?a.length>0:a.length===t.count)return{score:1,metadata:{matchingCalls:a.length}};let o=r.length>0?`observed ${e} calls: ${r.map(e=>truncate(JSON.stringify(e.input))).join(`, `)}`:`observed tools: [${n.derived.toolCalls.map(e=>e.name).join(`, `)}]`;return fail(`${t.count===void 0?`expected a matching call to "${e}"`:`expected exactly ${t.count} matching call(s), found ${a.length}`}; ${o}`)}}}function loadedSkill(e,t={}){return{...calledTool(LOAD_SKILL_TOOL_NAME,{...t,input:{skill:e}}),name:`loadedSkill(${e})`}}function notCalledTool(e){return{name:`notCalledTool(${e})`,evaluate(t){let n=t.derived.toolCalls.filter(t=>t.name===e).length;return n===0?PASS:fail(`"${e}" was called ${n} time(s)`)}}}function toolOrder(e){return{name:`toolOrder(${e.join(` → `)})`,evaluate(t){let n=requestedTools(t.events).map(e=>e.name),r=missingOrderedName(e,n);return r===void 0?PASS:fail(`missing "${r.name}" after [${e.slice(0,r.cursor).join(`, `)}]; observed request order: [${n.join(`, `)}]`)}}}function usedNoTools(){return{name:`usedNoTools`,evaluate(e){let t=e.derived.toolCallCount;return t===0?PASS:fail(`expected no tool calls, got ${t}`,{toolCallCount:t})}}}function maxToolCalls(e){return validateCount(e),{name:`maxToolCalls(${e})`,evaluate(t){let n=t.derived.toolCallCount;return n<=e?PASS:fail(`expected at most ${e} tool calls, got ${n}`,{maxAllowed:e,toolCallCount:n})}}}function noFailedActions(){return{name:`noFailedActions`,evaluate(e){let t=e.events.filter(e=>e.type===`action.result`&&(e.data.status===`failed`||e.data.result.isError===!0));if(t.length===0)return PASS;let n=t.map(formatFailedActionResult);return fail(`${t.length} failed action(s): ${n.join(`; `)}`,{failedActions:t.map(e=>({callId:e.data.result.callId,error:e.data.error,kind:e.data.result.kind,output:e.data.result.output,status:e.data.status}))})}}}function calledSubagent(e,t={}){return validateCount(t.count),{name:`calledSubagent(${e})`,evaluate(r){let i=r.derived.subagentCalls.filter(t=>t.name===e),a=i.filter(e=>subagentCallMatches(e,t));return(t.count===void 0?a.length>0:a.length===t.count)?{score:1,metadata:{matchingCalls:a.length}}:i.length===0?fail(`subagent "${e}" was never called; observed: [${r.derived.subagentCalls.map(e=>e.name).join(`, `)}]`,{observedSubagentCalls:r.derived.subagentCalls}):fail(`subagent "${e}" was called but ${a.length} call(s) matched the constraints`,{observedSubagentCalls:i})}}}function eventsSatisfy(e,t){return{name:`eventsSatisfy(${e})`,evaluate(n){return t(n.events)?PASS:fail(`event predicate "${e}" did not hold`)}}}function typedEvent(e){return validateCount(e.count),{name:`event(${e.type})`,evaluate(n){let r=n.events.filter(n=>eventMatches(n,e));return(e.count===void 0?r.length>0:r.length===e.count)?{score:1,metadata:{matchingEvents:r.length}}:fail(`expected ${e.count===void 0?`at least one`:`exactly ${e.count}`} matching ${e.type} event(s), found ${r.length}; observed: [${n.events.map(e=>e.type).join(`, `)}]`)}}}function notEvent(e){return{name:`notEvent(${e.type})`,evaluate(n){let r=n.events.filter(n=>eventMatches(n,e));return r.length===0?PASS:fail(`expected no matching ${e.type} events, found ${r.length}`)}}}function eventOrder(e){for(let t of e)validateCount(t.count);return{name:`eventOrder(${e.map(e=>e.type).join(` → `)})`,evaluate(n){let r=-1;for(let i of e){let e=n.events.flatMap((e,n)=>eventMatches(e,i)?[n]:[]);if(!(i.count===void 0?e.length>0:e.length===i.count))return fail(`expected ${i.count===void 0?`at least one`:`exactly ${i.count}`} matching ${i.type} event(s), found ${e.length}`);let a=e[0];if(a===void 0||a<=r)return fail(`event group ${i.type} did not occur after the previous group`);r=e[e.length-1]??r}return PASS}}}function outputEquals(t){return{name:`outputEquals`,evaluate(n){return deepEquals(n.output,t)?PASS:fail(`output ${truncate(JSON.stringify(n.output))} does not equal expected ${truncate(JSON.stringify(t))}`)}}}function outputMatches(e){return{name:`outputMatches`,async evaluate(t){let n=await e[`~standard`].validate(t.output);return!(`issues`in n)||n.issues===void 0?PASS:fail(`output failed schema validation: ${n.issues.map(e=>e.message).join(`; `)}`)}}}function joinCompletedMessages(e){let t=[];for(let n of e)n.type===`message.completed`&&n.data.message!==null&&t.push(n.data.message);return t.join(`
|
|
2
|
+
`)}function failureDetail(e,t){return t===void 0?e:`${e} (code: ${t})`}function formatFailedActionResult(e){let{result:t,status:n}=e.data;return[actionResultLabel(t),`callId=${t.callId}`,`status=${n}`,t.isError===!0?`isError=true`:void 0,e.data.error?.message===void 0?void 0:`error=${e.data.error.message}`,`output=${truncate(formatUnknown(t.output))}`].filter(e=>e!==void 0).join(` `)}function actionResultLabel(e){switch(e.kind){case`tool-result`:return`tool-result:${e.toolName}`;case`subagent-result`:return`subagent-result:${e.subagentName}`;case`load-skill-result`:return e.name===void 0?`load-skill-result`:`load-skill-result:${e.name}`}}function runFailure(e){if(e.status===`failed`)return fail(failureDetail(`run failed`,e.derived.failureCode));let t=e.events.find(e=>e.type===`turn.failed`||e.type===`step.failed`);return t===void 0?void 0:fail(`${t.type} (${t.data.code}): ${t.data.message}`)}function truncate(e,t=200){return e===void 0?`undefined`:e.length<=t?e:`${e.slice(0,t)}…`}function formatUnknown(e){if(e!==void 0){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}}function validateCount(e){if(e!==void 0&&(!Number.isInteger(e)||e<0))throw TypeError(`Assertion count must be a non-negative integer; received ${e}.`)}function missingOrderedName(e,t){let n=0;for(let r of t)if(r===e[n]&&(n+=1),n===e.length)return;let r=e[n];return r===void 0?void 0:{cursor:n,name:r}}function requestedTools(e){let t=[],n=new Set,append=(e,r)=>{n.has(e)||(n.add(e),t.push({callId:e,name:r}))};for(let t of e)if(t.type===`actions.requested`)for(let e of t.data.actions)e.kind===`tool-call`&&append(e.callId,e.toolName);else if(t.type===`input.requested`)for(let e of t.data.requests){let{action:t}=e;t.kind===`tool-call`&&append(t.callId,t.toolName)}return t}export{calledSubagent,calledTool,eventOrder,eventsSatisfy,loadedSkill,maxToolCalls,messageIncludes,noFailedActions,notCalledTool,notEvent,outputEquals,outputMatches,parked,succeeded,toolOrder,typedEvent,usedNoTools};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{createDurableSessionState}from"#execution/durable-session-store.js";import{createSession}from"#execution/session.js";async function createSessionStep(e){"use step";let t=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:e.nodeId});return{state:createDurableSessionState({session:createSession({compactionOverrides:{thresholdPercent:t.resolvedAgent.config.compaction?.thresholdPercent},continuationToken:e.continuationToken,outputSchema:e.outputSchema,rootSessionId:e.rootSessionId,sessionId:e.sessionId,turnAgent:t.turnAgent})})}}export{createSessionStep};
|
|
1
|
+
import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{createDurableSessionState}from"#execution/durable-session-store.js";import{createSession}from"#execution/session.js";async function createSessionStep(e){"use step";let t=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:e.nodeId});return{state:createDurableSessionState({session:createSession({compactionOverrides:{thresholdPercent:t.resolvedAgent.config.compaction?.thresholdPercent},continuationToken:e.continuationToken,limits:{maxInputTokensPerSession:t.resolvedAgent.config.limits?.maxInputTokensPerSession,maxOutputTokensPerSession:t.resolvedAgent.config.limits?.maxOutputTokensPerSession},outputSchema:e.outputSchema,rootSessionId:e.rootSessionId,sessionId:e.sessionId,subagentDepth:e.subagentDepth,subagentMaxDepth:e.subagentMaxDepth??t.resolvedAgent.config.limits?.maxSubagentDepth,turnAgent:t.turnAgent})})}}export{createSessionStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{callAdapterEventHandler}from"#channel/adapter.js";import{AuthKey,CapabilitiesKey,ChannelInstrumentationKey,InitiatorAuthKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{createSubagentCalledEvent,encodeMessageStreamEvent,timestampHandleMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{hydrateDurableSession}from"#execution/session.js";import{deserializeContext}from"#context/serialize.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{getPendingRuntimeActionBatch,recordPendingSubagentChildToken}from"#harness/runtime-actions.js";import{resolveRemoteAgentForAction,startRemoteAgentSession}from"#execution/remote-agent-dispatch.js";import{buildSubagentRunInput}from"#execution/subagent-tool.js";import{createWorkflowRuntime,workflowEntryReference}from"#execution/workflow-runtime.js";const log=createLogger(`execution.dispatch-runtime-actions`);async function dispatchRuntimeActionsStep(e){"use step";let s=await readDurableSession(e.sessionState),f=getPendingRuntimeActionBatch(s.state);if(f===void 0||f.actions.length===0)return{results:[],sessionState:e.sessionState};let p=await deserializeContext(e.serializedContext),m=p.require(BundleKey),h=hydrateDurableSession({compactionOverrides:{thresholdPercent:m.resolvedAgent.config.compaction?.thresholdPercent},durable:s,turnAgent:m.turnAgent}),g=p.require(ChannelKey),_=p.get(AuthKey)??null,v=p.get(CapabilitiesKey),y=p.get(ChannelInstrumentationKey),b=p.get(InitiatorAuthKey)??null,x=e.parentWritable.getWriter(),S=buildAdapterContext(g,p),C=h,w=[];try{for(let r of f.actions){let i,a,o,s;switch(r.kind){case`subagent-call`:{let t=m.subagentRegistry.subagentsByNodeId.get(r.nodeId),n=t?.definition.kind===`subagent`?{description:t.definition.description,type:`local`}:{type:`runtime`},o=createWorkflowRuntime({compiledArtifactsSource:m.compiledArtifactsSource,nodeId:r.nodeId}),{childContinuationToken:c,runInput:l}=buildSubagentRunInput({action:r,auth:_,batchEvent:f.event,capabilities:v,channelMetadata:y,initiatorAuth:b,parentContinuationToken:e.parentContinuationToken,session:h,source:n}),u=await o.run(l);
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{callAdapterEventHandler}from"#channel/adapter.js";import{AuthKey,CapabilitiesKey,ChannelInstrumentationKey,InitiatorAuthKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{createSubagentCalledEvent,encodeMessageStreamEvent,timestampHandleMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{hydrateDurableSession}from"#execution/session.js";import{deserializeContext}from"#context/serialize.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{getPendingRuntimeActionBatch,recordPendingSubagentChildToken}from"#harness/runtime-actions.js";import{resolveRemoteAgentForAction,startRemoteAgentSession}from"#execution/remote-agent-dispatch.js";import{buildSubagentRunInput}from"#execution/subagent-tool.js";import{createWorkflowRuntime,workflowEntryReference}from"#execution/workflow-runtime.js";import{getSubagentDelegationName,isSubagentDelegationAction,resolveSubagentDelegationLimit}from"#harness/subagent-depth.js";const log=createLogger(`execution.dispatch-runtime-actions`);async function dispatchRuntimeActionsStep(e){"use step";let s=await readDurableSession(e.sessionState),f=getPendingRuntimeActionBatch(s.state);if(f===void 0||f.actions.length===0)return{results:[],sessionState:e.sessionState};let p=await deserializeContext(e.serializedContext),m=p.require(BundleKey),h=hydrateDurableSession({compactionOverrides:{thresholdPercent:m.resolvedAgent.config.compaction?.thresholdPercent},durable:s,turnAgent:m.turnAgent}),g=p.require(ChannelKey),_=p.get(AuthKey)??null,v=p.get(CapabilitiesKey),y=p.get(ChannelInstrumentationKey),b=p.get(InitiatorAuthKey)??null,x=e.parentWritable.getWriter(),S=buildAdapterContext(g,p),C=resolveSubagentDelegationLimit(h),w=h,T=[];try{for(let r of f.actions){if(C.reached&&isSubagentDelegationAction(r)){log.warn(`subagent depth limit reached; blocking delegated call`,{callId:r.callId,currentDepth:C.currentDepth,maxDepth:C.maxDepth,nodeId:r.nodeId,subagentName:getSubagentDelegationName(r)}),T.push(createSubagentDepthLimitResult({action:r,delegationLimit:C}));continue}let i,a,o,s;switch(r.kind){case`subagent-call`:{let t=m.subagentRegistry.subagentsByNodeId.get(r.nodeId),n=t?.definition.kind===`subagent`?{description:t.definition.description,type:`local`}:{type:`runtime`},o=createWorkflowRuntime({compiledArtifactsSource:m.compiledArtifactsSource,nodeId:r.nodeId}),{childContinuationToken:c,runInput:l}=buildSubagentRunInput({action:r,auth:_,batchEvent:f.event,capabilities:v,channelMetadata:y,initiatorAuth:b,parentContinuationToken:e.parentContinuationToken,session:h,source:n}),u=await o.run(l);w=recordPendingSubagentChildToken({callId:r.callId,childContinuationToken:c,session:w}),i=u.sessionId,a=r.name,s=r.subagentName;break}case`remote-agent-call`:{let n;try{n=resolveRemoteAgentForAction({nodeId:r.nodeId,remoteAgentName:r.remoteAgentName,registry:m.subagentRegistry.subagentsByNodeId}),i=await startRemoteAgentSession({action:r,callbackBaseUrl:e.callbackBaseUrl,callbackToken:e.parentContinuationToken,remote:n,session:h})}catch(e){logError(log,`remote agent start failed`,e,{remoteAgentName:r.remoteAgentName,nodeId:r.nodeId,callId:r.callId}),T.push(createRemoteAgentStartFailureResult({action:r,error:e}));continue}a=r.name,o={url:n.url},s=r.remoteAgentName;break}default:throw Error(`Unsupported runtime action kind "${r.kind}" in workflow runtime.`)}let d=await callAdapterEventHandler(g,createSubagentCalledEvent({callId:r.callId,childSessionId:i,name:a,remote:o,sequence:f.event.sequence,sessionId:h.sessionId,toolName:s,turnId:f.event.turnId,workflowId:workflowEntryReference.workflowId}),S);await x.write(encodeMessageStreamEvent(timestampHandleMessageStreamEvent(d)))}}finally{x.releaseLock()}return{results:T,sessionState:w===h?e.sessionState:createDurableSessionState({session:w})}}function createRemoteAgentStartFailureResult(e){return{callId:e.action.callId,isError:!0,kind:`subagent-result`,output:{code:`REMOTE_AGENT_START_FAILED`,message:toErrorMessage(e.error)},subagentName:e.action.remoteAgentName}}function createSubagentDepthLimitResult(e){let t=getSubagentDelegationName(e.action);return{callId:e.action.callId,isError:!0,kind:`subagent-result`,output:{code:`SUBAGENT_DEPTH_LIMIT_REACHED`,currentDepth:e.delegationLimit.currentDepth,maxDepth:e.delegationLimit.maxDepth,message:`Subagent depth limit reached (${e.delegationLimit.maxDepth}); "${t}" was not called.`},subagentName:t}}export{dispatchRuntimeActionsStep};
|