eve 0.17.2 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/src/compiled/.vendor-stamp.json +1 -1
  3. package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +19 -16
  4. package/dist/src/compiled/@vercel/sandbox/api-client/index.d.ts +1 -1
  5. package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +37 -23
  6. package/dist/src/compiled/@vercel/sandbox/command.d.ts +2 -8
  7. package/dist/src/compiled/@vercel/sandbox/index.js +5 -5
  8. package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +43 -16
  9. package/dist/src/compiled/@vercel/sandbox/snapshot.d.ts +5 -5
  10. package/dist/src/compiled/_chunks/node/{auth-DF_ft5ea.js → auth-CWHn3Yve.js} +1 -1
  11. package/dist/src/compiled/_chunks/node/{version-TugPKZua.js → version-DD-FX9rK.js} +1 -1
  12. package/dist/src/execution/sandbox/bindings/vercel-create-sdk.js +1 -1
  13. package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
  14. package/dist/src/internal/application/package.js +1 -1
  15. package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -1
  16. package/dist/src/public/channels/auth.d.ts +2 -2
  17. package/dist/src/public/channels/slack/defaults.d.ts +3 -1
  18. package/dist/src/public/channels/slack/defaults.js +3 -3
  19. package/dist/src/public/channels/slack/hitl.d.ts +10 -4
  20. package/dist/src/public/channels/slack/hitl.js +4 -1
  21. package/dist/src/public/channels/slack/interactions.js +1 -1
  22. package/dist/src/public/channels/slack/limits.d.ts +5 -0
  23. package/dist/src/public/channels/slack/limits.js +1 -1
  24. package/dist/src/public/sandbox/vercel-sandbox.d.ts +4 -1
  25. package/dist/src/runtime/governance/auth/oidc.js +1 -1
  26. package/dist/src/setup/boxes/link-project.d.ts +7 -3
  27. package/dist/src/setup/boxes/link-project.js +1 -1
  28. package/dist/src/setup/onboarding.js +1 -1
  29. package/dist/src/setup/scaffold/create/project.js +1 -1
  30. package/dist/src/setup/vercel-project-framework.d.ts +10 -0
  31. package/dist/src/setup/vercel-project-framework.js +1 -0
  32. package/dist/src/setup/vercel-project.d.ts +8 -3
  33. package/dist/src/setup/vercel-project.js +0 -0
  34. package/docs/sandbox.mdx +1 -1
  35. package/package.json +3 -31
@@ -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
- type CreateSandboxParams = BaseCreateSandboxParams | (Omit<BaseCreateSandboxParams, "runtime" | "source"> & {
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
- * Extends both {@link BaseCreateSandboxParams} and {@link GetSandboxParams}
181
- * (minus `name`, which is required on get but optional here) so that any
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
- interface GetOrCreateSandboxParams extends BaseCreateSandboxParams, Omit<GetSandboxParams, "name"> {
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: "failed" | "aborted" | "pending" | "running" | "stopping" | "stopped" | "snapshotting";
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: "failed" | "aborted" | "pending" | "running" | "stopping" | "stopped" | "snapshotting";
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: "created" | "deleted" | "failed";
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: "created" | "deleted" | "failed";
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: "created" | "deleted" | "failed";
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: "created" | "deleted" | "failed";
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: "created" | "deleted" | "failed";
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: "created" | "deleted" | "failed";
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-TugPKZua.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)+`
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};
@@ -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};
@@ -1 +1 @@
1
- async function createVercelEveImageSandbox(e){let t={...e.createOptions,__image:VERCEL_EVE_SANDBOX_IMAGE};return await e.sandboxModule.Sandbox.create(t)}const VERCEL_EVE_SANDBOX_IMAGE=`vercel/eve:latest`;export{createVercelEveImageSandbox};
1
+ async function createVercelEveImageSandbox(e){let{image:t,runtime:n,source:r,...i}=e.createOptions;return r?.type===`snapshot`?await e.sandboxModule.Sandbox.create({...i,source:r}):await e.sandboxModule.Sandbox.create({...i,source:r,image:VERCEL_EVE_SANDBOX_IMAGE})}const VERCEL_EVE_SANDBOX_IMAGE=`vercel/eve:latest`;export{createVercelEveImageSandbox};
@@ -1 +1 @@
1
- import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{streamToBuffer}from"#execution/sandbox/stream-utils.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{adaptMultiplexedCommandToSandboxProcess}from"#execution/sandbox/multiplexed-command.js";import{applyInitialVercelNetworkPolicy,ensureVercelSandboxBaseRuntime}from"#execution/sandbox/bindings/vercel-base-runtime.js";import{createVercelEveImageSandbox}from"#execution/sandbox/bindings/vercel-create-sdk.js";import{isVercelSandboxMissingError,isVercelSnapshotUnavailableError}from"#execution/sandbox/bindings/vercel-errors.js";import{getNamedVercelSandbox}from"#execution/sandbox/bindings/vercel-lookup.js";import{normalizeVercelReadStream}from"#execution/sandbox/bindings/vercel-read-stream.js";function createVercelSandbox(e={}){let t=e.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),n={timeout:DEFAULT_SANDBOX_TIMEOUT_MS,...e.createOptions},r=e.createSandbox??createVercelEveImageSandbox,a=new Map;return{name:`vercel`,async create(e){let o=resolveVercelSandboxTags(n.tags,e.tags),l=e.templateKey===null?null:await readTemplateForCreate({createOptions:n,loadSandboxModule:t,prewarmedTemplates:a,templateKey:e.templateKey}),u=await t(),d;try{d=await ensureSession({createOptions:n,createSandbox:r,existingMetadata:e.existingMetadata,sandboxModule:u,sessionKey:e.sessionKey,snapshotId:l?.snapshotId,tags:o})}catch(t){throw l!==null&&(isVercelSnapshotUnavailableError(t)||isVercelSandboxMissingError(t))?(a.delete(l.templateKey),await(await getNamedVercelSandbox({createOptions:n,sandboxModule:u,sandboxName:l.sandboxName}))?.delete(),new SandboxTemplateNotProvisionedError({backendName:`vercel`,templateKey:l.templateKey})):Error(`Failed to create sandbox session "${e.sessionKey}": ${errorMessage(t)}`,{cause:t})}return l===null&&d.created&&(await ensureVercelSandboxBaseRuntime(d.sandbox),await applyInitialVercelNetworkPolicy(d.sandbox,n.networkPolicy)),createHandle(d.sandbox,e.sessionKey)},async prewarm(e){let i;try{i=await ensureTemplateWithUnavailableRetry({bootstrap:e.bootstrap,createOptions:n,createSandbox:r,loadSandboxModule:t,log:e.log,seedFiles:e.seedFiles,templateKey:e.templateKey})}catch(t){throw Error(`Failed to prewarm Vercel sandbox template "${e.templateKey}": ${errorMessage(t)}`,{cause:t})}return a.set(e.templateKey,i.template),{reused:i.reused}}}}async function ensureTemplateWithUnavailableRetry(e){try{return await ensureTemplate(e)}catch(t){if(!isVercelSnapshotUnavailableError(t)&&!isVercelSandboxMissingError(t))throw t;return e.log?.(`cached template disappeared; rebuilding sandbox template`),await ensureTemplate(e)}}async function readTemplate(e){let t=e.prewarmedTemplates.get(e.templateKey);if(t!==void 0)return t;let n=await e.loadSandboxModule(),r=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:n,sandboxName:e.templateKey});if(r===null||typeof r.currentSnapshotId!=`string`)throw new SandboxTemplateNotProvisionedError({backendName:`vercel`,templateKey:e.templateKey});return{sandboxName:r.name,snapshotId:r.currentSnapshotId,templateKey:e.templateKey}}async function readTemplateForCreate(e){try{return await readTemplate(e)}catch(t){throw SandboxTemplateNotProvisionedError.is(t)?t:Error(`Failed to read sandbox template "${e.templateKey}": ${errorMessage(t)}`,{cause:t})}}async function ensureTemplate(e){let t=await e.loadSandboxModule(),i=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:t,sandboxName:e.templateKey}),a=resolveVercelSandboxTags(e.createOptions.tags,e.tags),o=extractAuthorSnapshotId(e.createOptions);if(i!==null&&isUnprovisionedTerminalTemplateSandbox(i,o)&&(await i.delete(),i=null),i===null?i=await e.createSandbox({sandboxModule:t,createOptions:withBaseSetupNetworkPolicy({...e.createOptions,name:e.templateKey,persistent:!1,tags:a})}):await ensureVercelSandboxTags(i,a),typeof i.currentSnapshotId==`string`&&i.currentSnapshotId.length>0&&i.currentSnapshotId!==o)return{reused:!0,template:{sandboxName:i.name,snapshotId:i.currentSnapshotId,templateKey:e.templateKey}};e.log?.(`preparing base runtime inside sandbox`),await ensureVercelSandboxBaseRuntime(i),await applyInitialVercelNetworkPolicy(i,e.createOptions.networkPolicy);let s=buildSandboxSession(createVercelInternalSandboxSession(i,e.templateKey),createVercelNetworkPolicySetter(i));e.bootstrap!==void 0&&(e.log?.(`running sandbox bootstrap`),await e.bootstrap({use:async t=>(t!==void 0&&await i.update(t),createLoggingSandboxSession({log:e.log,session:s}))}));for(let t of e.seedFiles)typeof t.content==`string`?await s.writeTextFile({content:t.content,path:t.path}):await s.writeBinaryFile({content:t.content,path:t.path});let c=await i.snapshot();return{reused:!1,template:{sandboxName:i.name,snapshotId:c.snapshotId,templateKey:e.templateKey}}}async function ensureSession(e){let t=getVercelSandboxName(e.existingMetadata)??e.sessionKey,n=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:e.sandboxModule,sandboxName:t});if(n!==null)return await ensureVercelSandboxTags(n,e.tags),{created:!1,sandbox:n};let r=createSessionCreateParams(e,t);return e.tags!==void 0&&(r.tags=e.tags),{created:!0,sandbox:await e.createSandbox({createOptions:r,sandboxModule:e.sandboxModule})}}function createSessionCreateParams(e,t){if(e.snapshotId===void 0)return withBaseSetupNetworkPolicy({...e.createOptions,name:t,persistent:!0});let{runtime:n,source:r,...i}=e.createOptions;return{...i,name:t,persistent:!0,source:{snapshotId:e.snapshotId,type:`snapshot`}}}function withBaseSetupNetworkPolicy(e){return{...e,networkPolicy:`allow-all`}}function createHandle(e,t){return{session:buildSandboxSession(createVercelInternalSandboxSession(e,t),createVercelNetworkPolicySetter(e)),useSessionFn:async n=>(n!==void 0&&await e.update(n),buildSandboxSession(createVercelInternalSandboxSession(e,t),createVercelNetworkPolicySetter(e))),async captureState(){return{backendName:`vercel`,metadata:{sandboxName:e.name},sessionKey:t}},async dispose(){}}}function createVercelNetworkPolicySetter(e){return async t=>{await e.update({networkPolicy:t})}}function createVercelInternalSandboxSession(n,r){return{id:r,resolvePath:resolveVercelSandboxPath,async spawn(t){return adaptMultiplexedCommandToSandboxProcess({command:await n.runCommand({args:[`-lc`,t.command],cmd:`bash`,cwd:t.workingDirectory??WORKSPACE_ROOT,detached:!0,env:t.env,signal:t.abortSignal}),getOutput:e=>e.stream})},async readFile(e){return normalizeVercelReadStream(await n.readFile({path:e.path}))},async writeFile(e){let r=await streamToBuffer(e.content);await n.writeFiles([{content:r,path:e.path}])},async removePath(e){await n.fs.rm(e.path,{force:e.force,recursive:e.recursive,signal:e.abortSignal})}}}function resolveVercelSandboxPath(t){return t.startsWith(`/`)?t:`${WORKSPACE_ROOT}/${t}`}function isUnprovisionedTerminalTemplateSandbox(e,t){let n=e.currentSnapshotId;return typeof n==`string`&&n.length>0&&n!==t?!1:e.status===`aborted`||e.status===`failed`||e.status===`stopped`}function extractAuthorSnapshotId(e){let t=e.source;if(t?.type===`snapshot`&&typeof t.snapshotId==`string`)return t.snapshotId}function getVercelSandboxName(e){let t=e?.sandboxName;return typeof t==`string`?t:void 0}function resolveVercelSandboxTags(e,t){let n={};if(e!==void 0)for(let[t,r]of Object.entries(e))n[t]=r;if(t!==void 0)for(let[e,r]of Object.entries(t))n[e]=r;let r=Object.keys(n).length;if(r!==0){if(r>VERCEL_SANDBOX_TAG_LIMIT)throw Error(`Vercel Sandbox supports at most ${VERCEL_SANDBOX_TAG_LIMIT} tags. eve reserves "agent", "channel", and "sessionId"; remove or consolidate custom tags passed to vercel().`);return n}}async function ensureVercelSandboxTags(e,t){t===void 0||areVercelSandboxTagsEqual(e.tags,t)||await e.update({tags:t})}function areVercelSandboxTagsEqual(e,t){let n=e??{},r=Object.entries(n),i=Object.entries(t);return r.length===i.length?i.every(([e,t])=>n[e]===t):!1}function errorMessage(e){if(e instanceof Error){let t=e.json,n=e.text,r=typeof n==`string`&&n.length>0?n:t===void 0?void 0:JSON.stringify(t);return r===void 0?e.message:`${e.message}: ${r}`}return String(e)}const DEFAULT_SANDBOX_TIMEOUT_MS=1800*1e3,VERCEL_SANDBOX_TAG_LIMIT=5;export{createVercelSandbox};
1
+ import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{streamToBuffer}from"#execution/sandbox/stream-utils.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{adaptMultiplexedCommandToSandboxProcess}from"#execution/sandbox/multiplexed-command.js";import{applyInitialVercelNetworkPolicy,ensureVercelSandboxBaseRuntime}from"#execution/sandbox/bindings/vercel-base-runtime.js";import{createVercelEveImageSandbox}from"#execution/sandbox/bindings/vercel-create-sdk.js";import{isVercelSandboxMissingError,isVercelSnapshotUnavailableError}from"#execution/sandbox/bindings/vercel-errors.js";import{getNamedVercelSandbox}from"#execution/sandbox/bindings/vercel-lookup.js";import{normalizeVercelReadStream}from"#execution/sandbox/bindings/vercel-read-stream.js";function createVercelSandbox(e={}){let t=e.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),n={timeout:DEFAULT_SANDBOX_TIMEOUT_MS,...e.createOptions},r=e.createSandbox??createVercelEveImageSandbox,a=new Map;return{name:`vercel`,async create(e){let o=resolveVercelSandboxTags(n.tags,e.tags),l=e.templateKey===null?null:await readTemplateForCreate({createOptions:n,loadSandboxModule:t,prewarmedTemplates:a,templateKey:e.templateKey}),u=await t(),d;try{d=await ensureSession({createOptions:n,createSandbox:r,existingMetadata:e.existingMetadata,sandboxModule:u,sessionKey:e.sessionKey,snapshotId:l?.snapshotId,tags:o})}catch(t){throw l!==null&&(isVercelSnapshotUnavailableError(t)||isVercelSandboxMissingError(t))?(a.delete(l.templateKey),await(await getNamedVercelSandbox({createOptions:n,sandboxModule:u,sandboxName:l.sandboxName}))?.delete(),new SandboxTemplateNotProvisionedError({backendName:`vercel`,templateKey:l.templateKey})):Error(`Failed to create sandbox session "${e.sessionKey}": ${errorMessage(t)}`,{cause:t})}return l===null&&d.created&&(await ensureVercelSandboxBaseRuntime(d.sandbox),await applyInitialVercelNetworkPolicy(d.sandbox,n.networkPolicy)),createHandle(d.sandbox,e.sessionKey)},async prewarm(e){let i;try{i=await ensureTemplateWithUnavailableRetry({bootstrap:e.bootstrap,createOptions:n,createSandbox:r,loadSandboxModule:t,log:e.log,seedFiles:e.seedFiles,templateKey:e.templateKey})}catch(t){throw Error(`Failed to prewarm Vercel sandbox template "${e.templateKey}": ${errorMessage(t)}`,{cause:t})}return a.set(e.templateKey,i.template),{reused:i.reused}}}}async function ensureTemplateWithUnavailableRetry(e){try{return await ensureTemplate(e)}catch(t){if(!isVercelSnapshotUnavailableError(t)&&!isVercelSandboxMissingError(t))throw t;return e.log?.(`cached template disappeared; rebuilding sandbox template`),await ensureTemplate(e)}}async function readTemplate(e){let t=e.prewarmedTemplates.get(e.templateKey);if(t!==void 0)return t;let n=await e.loadSandboxModule(),r=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:n,sandboxName:e.templateKey});if(r===null||typeof r.currentSnapshotId!=`string`)throw new SandboxTemplateNotProvisionedError({backendName:`vercel`,templateKey:e.templateKey});return{sandboxName:r.name,snapshotId:r.currentSnapshotId,templateKey:e.templateKey}}async function readTemplateForCreate(e){try{return await readTemplate(e)}catch(t){throw SandboxTemplateNotProvisionedError.is(t)?t:Error(`Failed to read sandbox template "${e.templateKey}": ${errorMessage(t)}`,{cause:t})}}async function ensureTemplate(e){let t=await e.loadSandboxModule(),i=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:t,sandboxName:e.templateKey}),a=resolveVercelSandboxTags(e.createOptions.tags,e.tags),o=extractAuthorSnapshotId(e.createOptions);if(i!==null&&isUnprovisionedTerminalTemplateSandbox(i,o)&&(await i.delete(),i=null),i===null?i=await e.createSandbox({sandboxModule:t,createOptions:withBaseSetupNetworkPolicy({...e.createOptions,name:e.templateKey,persistent:!1,tags:a})}):await ensureVercelSandboxTags(i,a),typeof i.currentSnapshotId==`string`&&i.currentSnapshotId.length>0&&i.currentSnapshotId!==o)return{reused:!0,template:{sandboxName:i.name,snapshotId:i.currentSnapshotId,templateKey:e.templateKey}};e.log?.(`preparing base runtime inside sandbox`),await ensureVercelSandboxBaseRuntime(i),await applyInitialVercelNetworkPolicy(i,e.createOptions.networkPolicy);let s=buildSandboxSession(createVercelInternalSandboxSession(i,e.templateKey),createVercelNetworkPolicySetter(i));e.bootstrap!==void 0&&(e.log?.(`running sandbox bootstrap`),await e.bootstrap({use:async t=>(t!==void 0&&await i.update(t),createLoggingSandboxSession({log:e.log,session:s}))}));for(let t of e.seedFiles)typeof t.content==`string`?await s.writeTextFile({content:t.content,path:t.path}):await s.writeBinaryFile({content:t.content,path:t.path});let c=await i.snapshot();return{reused:!1,template:{sandboxName:i.name,snapshotId:c.snapshotId,templateKey:e.templateKey}}}async function ensureSession(e){let t=getVercelSandboxName(e.existingMetadata)??e.sessionKey,n=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:e.sandboxModule,sandboxName:t});if(n!==null)return await ensureVercelSandboxTags(n,e.tags),{created:!1,sandbox:n};let r=createSessionCreateParams(e,t);return e.tags!==void 0&&(r.tags=e.tags),{created:!0,sandbox:await e.createSandbox({createOptions:r,sandboxModule:e.sandboxModule})}}function createSessionCreateParams(e,t){if(e.snapshotId===void 0)return withBaseSetupNetworkPolicy({...e.createOptions,name:t,persistent:!0});let{image:n,runtime:r,source:i,...a}=e.createOptions;return{...a,name:t,persistent:!0,source:{snapshotId:e.snapshotId,type:`snapshot`}}}function withBaseSetupNetworkPolicy(e){return{...e,networkPolicy:`allow-all`}}function createHandle(e,t){return{session:buildSandboxSession(createVercelInternalSandboxSession(e,t),createVercelNetworkPolicySetter(e)),useSessionFn:async n=>(n!==void 0&&await e.update(n),buildSandboxSession(createVercelInternalSandboxSession(e,t),createVercelNetworkPolicySetter(e))),async captureState(){return{backendName:`vercel`,metadata:{sandboxName:e.name},sessionKey:t}},async dispose(){}}}function createVercelNetworkPolicySetter(e){return async t=>{await e.update({networkPolicy:t})}}function createVercelInternalSandboxSession(n,r){return{id:r,resolvePath:resolveVercelSandboxPath,async spawn(t){return adaptMultiplexedCommandToSandboxProcess({command:await n.runCommand({args:[`-lc`,t.command],cmd:`bash`,cwd:t.workingDirectory??WORKSPACE_ROOT,detached:!0,env:t.env,signal:t.abortSignal}),getOutput:e=>e.stream})},async readFile(e){return normalizeVercelReadStream(await n.readFile({path:e.path}))},async writeFile(e){let r=await streamToBuffer(e.content);await n.writeFiles([{content:r,path:e.path}])},async removePath(e){await n.fs.rm(e.path,{force:e.force,recursive:e.recursive,signal:e.abortSignal})}}}function resolveVercelSandboxPath(t){return t.startsWith(`/`)?t:`${WORKSPACE_ROOT}/${t}`}function isUnprovisionedTerminalTemplateSandbox(e,t){let n=e.currentSnapshotId;return typeof n==`string`&&n.length>0&&n!==t?!1:e.status===`aborted`||e.status===`failed`||e.status===`stopped`}function extractAuthorSnapshotId(e){let t=e.source;if(t?.type===`snapshot`&&typeof t.snapshotId==`string`)return t.snapshotId}function getVercelSandboxName(e){let t=e?.sandboxName;return typeof t==`string`?t:void 0}function resolveVercelSandboxTags(e,t){let n={};if(e!==void 0)for(let[t,r]of Object.entries(e))n[t]=r;if(t!==void 0)for(let[e,r]of Object.entries(t))n[e]=r;let r=Object.keys(n).length;if(r!==0){if(r>VERCEL_SANDBOX_TAG_LIMIT)throw Error(`Vercel Sandbox supports at most ${VERCEL_SANDBOX_TAG_LIMIT} tags. eve reserves "agent", "channel", and "sessionId"; remove or consolidate custom tags passed to vercel().`);return n}}async function ensureVercelSandboxTags(e,t){t===void 0||areVercelSandboxTagsEqual(e.tags,t)||await e.update({tags:t})}function areVercelSandboxTagsEqual(e,t){let n=e??{},r=Object.entries(n),i=Object.entries(t);return r.length===i.length?i.every(([e,t])=>n[e]===t):!1}function errorMessage(e){if(e instanceof Error){let t=e.json,n=e.text,r=typeof n==`string`&&n.length>0?n:t===void 0?void 0:JSON.stringify(t);return r===void 0?e.message:`${e.message}: ${r}`}return String(e)}const DEFAULT_SANDBOX_TIMEOUT_MS=1800*1e3,VERCEL_SANDBOX_TAG_LIMIT=5;export{createVercelSandbox};
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.17.2`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let n=e;for(;;){if(existsSync(join(n,`package.json`))&&!isBuildOutputPackageRoot(n))return n;let r=dirname(n);if(r===n)throw Error(`Failed to resolve package root from "${e}".`);n=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let r=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(r?.name===t)return r}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageDependencyPath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
1
+ import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.18.1`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let n=e;for(;;){if(existsSync(join(n,`package.json`))&&!isBuildOutputPackageRoot(n))return n;let r=dirname(n);if(r===n)throw Error(`Failed to resolve package root from "${e}".`);n=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let r=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(r?.name===t)return r}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageDependencyPath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
@@ -1 +1 @@
1
- import{existsSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{cp,lstat,mkdir,readFile,readdir,symlink,writeFile}from"node:fs/promises";import{DevelopmentRuntimeSourceSnapshotError,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{extractTsConfigExtendsSpecifiers,isTsConfigFilePath,parseTsConfigObject,readTextFileIfExists,resolveFirstExistingTsConfigExtendsTarget,resolveTsConfigExtendsTargetPaths}from"#internal/application/tsconfig-dependencies.js";const SNAPSHOT_SKIP_NAMES=new Set([`.eve`,`.git`,`.output`,`.turbo`,`.vercel`,`.workflow-data`,`node_modules`]);async function copyDevelopmentSourceSnapshot(t){await mkdir(t.snapshotSourceRoot,{recursive:!0});for(let e of t.copyRoots)await copySnapshotPath({plan:t,sourcePath:e,targetPath:toSnapshotPathForPlan(t,e)});for(let n of t.copyFiles)existsSync(n)&&await copySnapshotPath({plan:t,sourcePath:n,targetPath:toSnapshotPathForPlan(t,n)});await rewriteSnapshotTsConfigAbsoluteExtends(t),await createSnapshotSymlinks(t),await validateDevelopmentSourceSnapshot(t)}async function copySnapshotPath(e){try{if((await lstat(e.sourcePath)).isDirectory()){await copySnapshotDirectory(e);return}await mkdir(dirname(e.targetPath),{recursive:!0}),await cp(e.sourcePath,e.targetPath,{recursive:!0})}catch(t){throw new DevelopmentRuntimeSourceSnapshotError(`Failed to copy development runtime source snapshot path "${e.sourcePath}" to "${e.targetPath}": ${formatErrorMessage(t)}`)}}async function copySnapshotDirectory(e){await mkdir(e.targetPath,{recursive:!0});for(let t of await readdir(e.sourcePath,{withFileTypes:!0})){let r=join(e.sourcePath,t.name);shouldSkipSnapshotSource(e.plan.sourceRoot,r)||await cp(r,join(e.targetPath,t.name),{filter:t=>!shouldSkipSnapshotSource(e.plan.sourceRoot,t),recursive:!0})}}function shouldSkipSnapshotSource(e,t){let n=relative(e,t);return n.length===0?!1:n.split(/[\\/]/).some(e=>SNAPSHOT_SKIP_NAMES.has(e))}async function rewriteSnapshotTsConfigAbsoluteExtends(e){for(let t of e.tsconfigPaths){let n=await readTextFileIfExists(t);if(n===void 0)continue;let r=rewriteTsConfigAbsoluteExtends({configPath:t,snapshotConfigPath:toSnapshotPathForPlan(e,t),snapshotSourceRoot:e.snapshotSourceRoot,source:n,sourceRoot:e.sourceRoot});r!==void 0&&await writeFile(toSnapshotPathForPlan(e,t),r)}}function rewriteTsConfigAbsoluteExtends(e){let t=parseTsConfigObject(e.source);if(t===void 0)return;let n=rewriteTsConfigExtendsValue({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:t.extends});if(n.changed===!0)return`${JSON.stringify({...t,extends:n.value},null,2)}\n`}function rewriteTsConfigExtendsValue(e){if(typeof e.value==`string`){let t=rewriteTsConfigExtendsSpecifier({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:e.value});return t===void 0?{changed:!1,value:e.value}:{changed:!0,value:t}}if(!Array.isArray(e.value))return{changed:!1,value:e.value};let t=!1,n=e.value.map(n=>{if(typeof n!=`string`)return n;let r=rewriteTsConfigExtendsSpecifier({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:n});return r===void 0?n:(t=!0,r)});return{changed:t,value:n}}function rewriteTsConfigExtendsSpecifier(e){if(!isTsConfigFilePath(e.value)||!isAbsoluteFilePath(e.value))return;let t=resolveFirstExistingTsConfigExtendsTarget({configPath:e.configPath,extendsSpecifier:e.value});if(!(t===void 0||!isPathInsideOrEqual(t,e.sourceRoot)))return toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:e.sourceRoot})}async function createSnapshotSymlinks(e){for(let n of e.symlinks){let i=toSnapshotPathForPlan(e,n.linkPath),a=n.targetKind===`local`?toSnapshotPathForPlan(e,n.targetPath):n.targetPath,o=n.targetKind===`local`?relative(dirname(i),a)||`.`:a;await mkdir(dirname(i),{recursive:!0}),await symlink(o,i,`junction`)}}async function validateDevelopmentSourceSnapshot(t){let r=join(t.runtimeAppRoot,`package.json`);if(!existsSync(r))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot is missing the runtime app package.json at "${r}".`);for(let n of t.tsconfigPaths){let r=toSnapshotPathForPlan(t,n);if(!existsSync(r))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot is missing tsconfig dependency "${r}".`);await validateSnapshotTsConfigExtends(r)}}async function validateSnapshotTsConfigExtends(t){let n=extractTsConfigExtendsSpecifiers(await readFile(t,`utf8`));for(let r of n)if(!(!isTsConfigFilePath(r)||resolveTsConfigExtendsTargetPaths({configPath:t,extendsSpecifier:r}).some(t=>existsSync(t))))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot cannot resolve tsconfig extends "${r}" from "${t}".`)}function toSnapshotPathForPlan(e,t){return toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:e.sourceRoot})}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}function isAbsoluteFilePath(e){return e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function formatErrorMessage(e){return e instanceof Error?e.message:String(e)}export{copyDevelopmentSourceSnapshot};
1
+ import{existsSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{cp,lstat,mkdir,readFile,readdir,symlink,writeFile}from"node:fs/promises";import{DevelopmentRuntimeSourceSnapshotError,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{extractTsConfigExtendsSpecifiers,isTsConfigFilePath,parseTsConfigObject,readTextFileIfExists,resolveFirstExistingTsConfigExtendsTarget,resolveTsConfigExtendsTargetPaths}from"#internal/application/tsconfig-dependencies.js";const SNAPSHOT_SKIP_NAMES=new Set([`.eve`,`.git`,`.output`,`.turbo`,`.vercel`,`.workflow-data`,`node_modules`]);async function copyDevelopmentSourceSnapshot(t){await mkdir(t.snapshotSourceRoot,{recursive:!0});for(let e of t.copyRoots)await copySnapshotPath({plan:t,sourcePath:e,targetPath:toSnapshotPathForPlan(t,e)});for(let n of t.copyFiles)existsSync(n)&&await copySnapshotPath({plan:t,sourcePath:n,targetPath:toSnapshotPathForPlan(t,n)});await rewriteSnapshotTsConfigAbsoluteExtends(t),await createSnapshotSymlinks(t),await ensureRuntimePackageJson(t),await validateDevelopmentSourceSnapshot(t)}async function copySnapshotPath(e){try{if((await lstat(e.sourcePath)).isDirectory()){await copySnapshotDirectory(e);return}await mkdir(dirname(e.targetPath),{recursive:!0}),await cp(e.sourcePath,e.targetPath,{recursive:!0})}catch(t){throw new DevelopmentRuntimeSourceSnapshotError(`Failed to copy development runtime source snapshot path "${e.sourcePath}" to "${e.targetPath}": ${formatErrorMessage(t)}`)}}async function copySnapshotDirectory(e){await mkdir(e.targetPath,{recursive:!0});for(let t of await readdir(e.sourcePath,{withFileTypes:!0})){let r=join(e.sourcePath,t.name);shouldSkipSnapshotSource(e.plan.sourceRoot,r)||await cp(r,join(e.targetPath,t.name),{filter:t=>!shouldSkipSnapshotSource(e.plan.sourceRoot,t),recursive:!0})}}function shouldSkipSnapshotSource(e,t){let n=relative(e,t);return n.length===0?!1:n.split(/[\\/]/).some(e=>SNAPSHOT_SKIP_NAMES.has(e))}async function rewriteSnapshotTsConfigAbsoluteExtends(e){for(let t of e.tsconfigPaths){let n=await readTextFileIfExists(t);if(n===void 0)continue;let r=rewriteTsConfigAbsoluteExtends({configPath:t,snapshotConfigPath:toSnapshotPathForPlan(e,t),snapshotSourceRoot:e.snapshotSourceRoot,source:n,sourceRoot:e.sourceRoot});r!==void 0&&await writeFile(toSnapshotPathForPlan(e,t),r)}}function rewriteTsConfigAbsoluteExtends(e){let t=parseTsConfigObject(e.source);if(t===void 0)return;let n=rewriteTsConfigExtendsValue({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:t.extends});if(n.changed===!0)return`${JSON.stringify({...t,extends:n.value},null,2)}\n`}function rewriteTsConfigExtendsValue(e){if(typeof e.value==`string`){let t=rewriteTsConfigExtendsSpecifier({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:e.value});return t===void 0?{changed:!1,value:e.value}:{changed:!0,value:t}}if(!Array.isArray(e.value))return{changed:!1,value:e.value};let t=!1,n=e.value.map(n=>{if(typeof n!=`string`)return n;let r=rewriteTsConfigExtendsSpecifier({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:n});return r===void 0?n:(t=!0,r)});return{changed:t,value:n}}function rewriteTsConfigExtendsSpecifier(e){if(!isTsConfigFilePath(e.value)||!isAbsoluteFilePath(e.value))return;let t=resolveFirstExistingTsConfigExtendsTarget({configPath:e.configPath,extendsSpecifier:e.value});if(!(t===void 0||!isPathInsideOrEqual(t,e.sourceRoot)))return toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:e.sourceRoot})}async function createSnapshotSymlinks(e){for(let n of e.symlinks){let i=toSnapshotPathForPlan(e,n.linkPath),a=n.targetKind===`local`?toSnapshotPathForPlan(e,n.targetPath):n.targetPath,o=n.targetKind===`local`?relative(dirname(i),a)||`.`:a;await mkdir(dirname(i),{recursive:!0}),await symlink(o,i,`junction`)}}async function ensureRuntimePackageJson(t){let r=join(t.runtimeAppRoot,`package.json`);existsSync(r)||(await mkdir(t.runtimeAppRoot,{recursive:!0}),await writeFile(r,`${JSON.stringify({private:!0,type:`module`},null,2)}\n`))}async function validateDevelopmentSourceSnapshot(t){let r=join(t.runtimeAppRoot,`package.json`);if(!existsSync(r))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot is missing the runtime app package.json at "${r}".`);for(let n of t.tsconfigPaths){let r=toSnapshotPathForPlan(t,n);if(!existsSync(r))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot is missing tsconfig dependency "${r}".`);await validateSnapshotTsConfigExtends(r)}}async function validateSnapshotTsConfigExtends(t){let n=extractTsConfigExtendsSpecifiers(await readFile(t,`utf8`));for(let r of n)if(!(!isTsConfigFilePath(r)||resolveTsConfigExtendsTargetPaths({configPath:t,extendsSpecifier:r}).some(t=>existsSync(t))))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot cannot resolve tsconfig extends "${r}" from "${t}".`)}function toSnapshotPathForPlan(e,t){return toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:e.sourceRoot})}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}function isAbsoluteFilePath(e){return e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function formatErrorMessage(e){return e instanceof Error?e.message:String(e)}export{copyDevelopmentSourceSnapshot};
@@ -336,8 +336,8 @@ export interface VerifyVercelOidcOptions {
336
336
  * `email`) are exposed as auth attributes.
337
337
  * - Development tokens with a `user_id` claim authenticate as
338
338
  * `principalType: "user"` only when both the token and configured current
339
- * project environment are `development`. A same-project preview target may
340
- * use one as a `"service"` principal; other target environments reject it.
339
+ * project environment are `development`. Other same-project target
340
+ * environments may use one as a `"service"` principal.
341
341
  * - Tokens from other Vercel projects are accepted **only** when their `sub`
342
342
  * matches one of {@link VerifyVercelOidcOptions.subjects}.
343
343
  *
@@ -25,7 +25,9 @@ export declare function defaultOnDirectMessage(ctx: SlackContext, message: Slack
25
25
  * Default `input.requested` handler — renders each pending HITL
26
26
  * request as Slack `block_actions`. Buttons by default; radio for
27
27
  * ≤6-option select requests; static_select for >6-option select
28
- * requests. Override by declaring `events["input.requested"]`.
28
+ * requests. Batches split into multiple posts when they would exceed
29
+ * Slack's 50-block message cap. Override by declaring
30
+ * `events["input.requested"]`.
29
31
  */
30
32
  export declare function defaultInputRequestedHandler(): NonNullable<SlackChannelEvents["input.requested"]>;
31
33
  /**
@@ -1,4 +1,4 @@
1
- import{createLogger,extractErrorId,formatErrorHint}from"#internal/logging.js";import{truncateMessageText,truncateTypingStatus}from"#public/channels/slack/limits.js";import{buildSlackAuthContext,slackUserIdFromAuthContext}from"#public/channels/slack/auth.js";import{buildAuthCompletedText,buildAuthEphemeralBlocks,buildAuthRequiredPublicText,formatConnectionDisplayName}from"#public/channels/slack/connections.js";import{renderInputRequestBlocks}from"#public/channels/slack/hitl.js";const log=createLogger(`slack.defaults`);function defaultSlackAuth(e,t){let n=e.author;return n?buildSlackAuthContext({channelId:t.slack.channelId,fullName:n.fullName,isBot:n.isBot,teamId:e.teamId,threadTs:t.slack.threadTs,userId:n.userId,userName:n.userName}):null}async function defaultOnAppMention(e,t){return await e.thread.startTyping(`Thinking...`),{auth:defaultSlackAuth(t,e)}}async function defaultOnDirectMessage(e,t){return await e.thread.startTyping(`Thinking...`),{auth:defaultSlackAuth(t,e)}}function firstNonEmptyLine(e){for(let t of e.split(/\r?\n/u)){let e=t.trim();if(e.length>0)return e}}function defaultInputRequestedHandler(){return async(e,t,n)=>{if(e.requests.length===0)return;let i=truncateMessageText(e.requests.map(e=>e.prompt).join(`
2
- `));await t.thread.post({blocks:e.requests.flatMap(renderInputRequestBlocks),text:i})}}const defaultEvents={async"turn.started"(e,t,n){t.state.pendingToolCallMessage=null,t.state.lastReasoningTypingAtMs=null,t.state.lastReasoningTypingStatus=null,await t.thread.startTyping(`Working...`)},async"reasoning.appended"(e,t,n){let r=firstNonEmptyLine(e.reasoningSoFar);if(r===void 0)return;let a=truncateTypingStatus(r),o=t.state.lastReasoningTypingStatus,s=o!=null&&a.startsWith(o)&&a.length>=o.length+4,c=Date.now(),l=t.state.lastReasoningTypingAtMs;if(!s&&l!=null){let e=c-l;if(e>=0&&e<5e3)return}await t.thread.startTyping(a),t.state.lastReasoningTypingAtMs=c,t.state.lastReasoningTypingStatus=a},async"actions.requested"(e,t,n){let r=t.state.pendingToolCallMessage;if(t.state.pendingToolCallMessage=null,r){await t.thread.startTyping(truncateTypingStatus(r));return}let a=e.actions.map(e=>e.kind===`tool-call`?e.toolName:e.kind);await t.thread.startTyping(truncateTypingStatus(`Running ${a.join(`, `)}...`))},async"message.completed"(e,t,n){if(e.finishReason===`tool-calls`){t.state.pendingToolCallMessage=e.message?firstNonEmptyLine(e.message)??null:null;return}if(t.state.pendingToolCallMessage=null,!e.message){await t.thread.startTyping();return}await t.thread.post(e.message)},async"turn.failed"(e,r,i){let a=formatErrorHint(e),o=extractErrorId(e.details);await r.thread.post([`I hit an error while handling your request${a}.`,``,`Please try again, rephrase, or reach out if it keeps failing.`,...o?[``,`_Error id: \`${o}\`_`]:[]].join(`
1
+ import{createLogger,extractErrorId,formatErrorHint}from"#internal/logging.js";import{SLACK_MAX_BLOCKS_PER_MESSAGE,truncateMessageText,truncateTypingStatus}from"#public/channels/slack/limits.js";import{buildSlackAuthContext,slackUserIdFromAuthContext}from"#public/channels/slack/auth.js";import{buildAuthCompletedText,buildAuthEphemeralBlocks,buildAuthRequiredPublicText,formatConnectionDisplayName}from"#public/channels/slack/connections.js";import{formatInputRequestFallbackText,renderInputRequestBlocks}from"#public/channels/slack/hitl.js";const log=createLogger(`slack.defaults`);function defaultSlackAuth(e,t){let n=e.author;return n?buildSlackAuthContext({channelId:t.slack.channelId,fullName:n.fullName,isBot:n.isBot,teamId:e.teamId,threadTs:t.slack.threadTs,userId:n.userId,userName:n.userName}):null}async function defaultOnAppMention(e,t){return await e.thread.startTyping(`Thinking...`),{auth:defaultSlackAuth(t,e)}}async function defaultOnDirectMessage(e,t){return await e.thread.startTyping(`Thinking...`),{auth:defaultSlackAuth(t,e)}}function firstNonEmptyLine(e){for(let t of e.split(/\r?\n/u)){let e=t.trim();if(e.length>0)return e}}function defaultInputRequestedHandler(){return async(e,t,n)=>{for(let n of buildInputRequestPosts(e.requests))await t.thread.post(n)}}function buildInputRequestPosts(e){let t=[];for(let n of e){let e=renderInputRequestBlocks(n),i=t.at(-1);i&&i.blocks.length+e.length<=SLACK_MAX_BLOCKS_PER_MESSAGE?(i.blocks.push(...e),i.fallbacks.push(formatInputRequestFallbackText(n))):t.push({blocks:e,fallbacks:[formatInputRequestFallbackText(n)]})}return t.map(e=>({blocks:e.blocks,text:truncateMessageText(e.fallbacks.join(`
2
+ `))}))}const defaultEvents={async"turn.started"(e,t,n){t.state.pendingToolCallMessage=null,t.state.lastReasoningTypingAtMs=null,t.state.lastReasoningTypingStatus=null,await t.thread.startTyping(`Working...`)},async"reasoning.appended"(e,t,n){let r=firstNonEmptyLine(e.reasoningSoFar);if(r===void 0)return;let i=truncateTypingStatus(r),o=t.state.lastReasoningTypingStatus,s=o!=null&&i.startsWith(o)&&i.length>=o.length+4,c=Date.now(),l=t.state.lastReasoningTypingAtMs;if(!s&&l!=null){let e=c-l;if(e>=0&&e<5e3)return}await t.thread.startTyping(i),t.state.lastReasoningTypingAtMs=c,t.state.lastReasoningTypingStatus=i},async"actions.requested"(e,t,n){let r=t.state.pendingToolCallMessage;if(t.state.pendingToolCallMessage=null,r){await t.thread.startTyping(truncateTypingStatus(r));return}let i=e.actions.map(e=>e.kind===`tool-call`?e.toolName:e.kind);await t.thread.startTyping(truncateTypingStatus(`Running ${i.join(`, `)}...`))},async"message.completed"(e,t,n){if(e.finishReason===`tool-calls`){t.state.pendingToolCallMessage=e.message?firstNonEmptyLine(e.message)??null:null;return}if(t.state.pendingToolCallMessage=null,!e.message){await t.thread.startTyping();return}await t.thread.post(e.message)},async"turn.failed"(e,r,i){let a=formatErrorHint(e),o=extractErrorId(e.details);await r.thread.post([`I hit an error while handling your request${a}.`,``,`Please try again, rephrase, or reach out if it keeps failing.`,...o?[``,`_Error id: \`${o}\`_`]:[]].join(`
3
3
  `))},async"session.failed"(e,r){let i=formatErrorHint(e),a=extractErrorId(e.details);await r.thread.post([`This session couldn't recover from an error${i}.`,``,`Start a new thread to continue — I can't pick this one back up.`,...a?[``,`_Error id: \`${a}\`_`]:[]].join(`
4
- `))},async"authorization.required"(e,t,n){let r=e.authorization?.displayName??formatConnectionDisplayName(e.name),i=slackUserIdFromAuthContext(n.session.auth.current)??t.state.triggeringUserId??null,a=e.authorization?.url,s=t.state.pendingAuthMessageTs??{};if(s[e.name]===void 0){let n=buildAuthRequiredPublicText({displayName:r,hasUser:i!==null});try{let r=await t.thread.post(n);r.id&&(t.state.pendingAuthMessageTs={...s,[e.name]:r.id})}catch(t){log.error(`Slack auth public message delivery failed`,{name:e.name,error:t})}}if(i&&a){let n=e.authorization?.userCode;try{await t.thread.postEphemeral(i,{blocks:buildAuthEphemeralBlocks({displayName:r,url:a,userCode:n}),text:n?`Sign in with ${r}: ${a} (code: ${n})`:`Sign in with ${r}: ${a}`})}catch(t){log.error(`Slack auth ephemeral delivery failed`,{name:e.name,error:t})}}},async"authorization.completed"(e,t,n){let r=t.state.pendingAuthMessageTs??{},i=r[e.name];if(i===void 0)return;let a=buildAuthCompletedText({displayName:e.authorization?.displayName??formatConnectionDisplayName(e.name),outcome:e.outcome,reason:e.reason});try{await t.slack.request(`chat.update`,{channel:t.slack.channelId,ts:i,text:a})}catch(t){log.error(`Slack auth status edit failed`,{name:e.name,error:t})}let o={...r};delete o[e.name],t.state.pendingAuthMessageTs=o}};export{defaultEvents,defaultInputRequestedHandler,defaultOnAppMention,defaultOnDirectMessage,defaultSlackAuth};
4
+ `))},async"authorization.required"(e,t,n){let r=e.authorization?.displayName??formatConnectionDisplayName(e.name),i=slackUserIdFromAuthContext(n.session.auth.current)??t.state.triggeringUserId??null,a=e.authorization?.url,o=t.state.pendingAuthMessageTs??{};if(o[e.name]===void 0){let n=buildAuthRequiredPublicText({displayName:r,hasUser:i!==null});try{let r=await t.thread.post(n);r.id&&(t.state.pendingAuthMessageTs={...o,[e.name]:r.id})}catch(t){log.error(`Slack auth public message delivery failed`,{name:e.name,error:t})}}if(i&&a){let n=e.authorization?.userCode;try{await t.thread.postEphemeral(i,{blocks:buildAuthEphemeralBlocks({displayName:r,url:a,userCode:n}),text:n?`Sign in with ${r}: ${a} (code: ${n})`:`Sign in with ${r}: ${a}`})}catch(t){log.error(`Slack auth ephemeral delivery failed`,{name:e.name,error:t})}}},async"authorization.completed"(e,t,n){let r=t.state.pendingAuthMessageTs??{},i=r[e.name];if(i===void 0)return;let a=buildAuthCompletedText({displayName:e.authorization?.displayName??formatConnectionDisplayName(e.name),outcome:e.outcome,reason:e.reason});try{await t.slack.request(`chat.update`,{channel:t.slack.channelId,ts:i,text:a})}catch(t){log.error(`Slack auth status edit failed`,{name:e.name,error:t})}let o={...r};delete o[e.name],t.state.pendingAuthMessageTs=o}};export{defaultEvents,defaultInputRequestedHandler,defaultOnAppMention,defaultOnDirectMessage,defaultSlackAuth};
@@ -90,6 +90,12 @@ export declare function isHitlAction(actionId: string): boolean;
90
90
  * Always emits at least the prompt section.
91
91
  */
92
92
  export declare function renderInputRequestBlocks(request: InputRequest): unknown[];
93
+ /**
94
+ * Creates the fallback text for one HITL request. Slack clients use this
95
+ * outside the rich Block Kit surface, so include the same approval details
96
+ * that appear in the blocks.
97
+ */
98
+ export declare function formatInputRequestFallbackText(request: InputRequest): string;
93
99
  /**
94
100
  * Metadata round-tripped on the freeform-answer modal's
95
101
  * `private_metadata` field. Threaded from the button click that opens
@@ -125,16 +131,16 @@ export declare function isFreeformAction(actionId: string): boolean;
125
131
  export declare function freeformRequestIdFromActionId(actionId: string): string | undefined;
126
132
  /**
127
133
  * Renders the "answered" replacement blocks for a previously-posted
128
- * HITL card. Preserves the original prompt block (so context stays
129
- * visible), appends a confirmation line naming the chosen answer, and
130
- * attributes the click to the user when their id is known.
134
+ * HITL card. Preserves the original prompt/detail blocks (so context
135
+ * stays visible), appends a confirmation line naming the chosen answer,
136
+ * and attributes the click to the user when their id is known.
131
137
  *
132
138
  * Slack's `chat.update` replaces every block in one shot, so the caller
133
139
  * passes the full list to `blocks` and the rendered fallback text to
134
140
  * `text`.
135
141
  */
136
142
  export declare function buildAnsweredBlocks(input: {
137
- readonly promptBlock: unknown;
143
+ readonly promptBlocks: readonly unknown[];
138
144
  readonly answerLabel: string;
139
145
  readonly userId?: string;
140
146
  }): unknown[];
@@ -1 +1,4 @@
1
- import{truncateModalTitle,truncatePlainText,truncateSectionText}from"#public/channels/slack/limits.js";const HITL_ACTION_PREFIX=`eve_input:`,HITL_FREEFORM_ACTION_PREFIX=`eve_input_freeform:`,HITL_FREEFORM_MODAL_CALLBACK_ID=`eve_input_freeform_submit`,HITL_FREEFORM_MODAL_BLOCK_ID=`eve_freeform_block`,HITL_FREEFORM_MODAL_ACTION_ID=`eve_freeform_text`,BUTTON_ACTION_ID_RE=/^(?<requestId>.+):button:\d+$/u;function deriveHitlResponse(e){if(!e.actionId.startsWith(`eve_input:`))return null;let t=e.actionId.slice(10);if(e.selectedOptionValue!==void 0)return t?{optionId:e.selectedOptionValue,requestId:t}:null;if(e.value!==void 0){let n=BUTTON_ACTION_ID_RE.exec(t)?.groups?.requestId;return n?{optionId:e.value,requestId:n}:null}return null}function isHitlAction(e){return e.startsWith(HITL_ACTION_PREFIX)}function renderInputRequestBlocks(e){let t={text:{text:truncateSectionText(e.prompt),type:`mrkdwn`},type:`section`},a=`${HITL_ACTION_PREFIX}${e.requestId}`,o=e.options,s=e.allowFreeform===!0||!o||o.length===0;return o&&o.length>0&&e.display===`select`?[t,{type:`actions`,elements:[o.length<=6?{type:`radio_buttons`,action_id:a,options:o.map(buildOption)}:{type:`static_select`,action_id:a,options:o.map(buildOption),placeholder:{type:`plain_text`,text:`Choose an option`}}]}]:o&&o.length>0?[t,{type:`actions`,elements:o.map((e,t)=>buildButton(e,a,t))}]:s?[t,{type:`actions`,elements:[{type:`button`,action_id:`${HITL_FREEFORM_ACTION_PREFIX}${e.requestId}`,text:{type:`plain_text`,text:`Type your answer`},style:`primary`,value:e.requestId}]}]:[t]}function buildFreeformModalView(t){let r=t.prompt?truncateModalTitle(t.prompt):`Your answer`,i=t.prompt?[{type:`section`,text:{type:`mrkdwn`,text:truncateSectionText(t.prompt)}}]:[];return{type:`modal`,callback_id:HITL_FREEFORM_MODAL_CALLBACK_ID,private_metadata:JSON.stringify(t.metadata),title:{type:`plain_text`,text:r},submit:{type:`plain_text`,text:`Submit`},close:{type:`plain_text`,text:`Cancel`},blocks:[...i,{type:`input`,block_id:HITL_FREEFORM_MODAL_BLOCK_ID,element:{type:`plain_text_input`,action_id:HITL_FREEFORM_MODAL_ACTION_ID,multiline:!0,placeholder:{type:`plain_text`,text:`Type your answer here...`}},label:{type:`plain_text`,text:`Answer`}}]}}function isFreeformAction(e){return e.startsWith(HITL_FREEFORM_ACTION_PREFIX)}function freeformRequestIdFromActionId(e){if(!isFreeformAction(e))return;let t=e.slice(19);return t.length>0?t:void 0}function buildButton(e,n,r){let i={action_id:`${n}:button:${r}`,text:{text:truncatePlainText(e.label),type:`plain_text`},type:`button`,value:e.id};return(e.style===`primary`||e.style===`danger`)&&(i.style=e.style),i}function buildOption(e){let n={text:{text:truncatePlainText(e.label),type:`plain_text`},value:e.id},r=truncatePlainText(e.description);return r&&r.length>0&&(n.description={text:r,type:`plain_text`}),n}function buildAnsweredBlocks(e){let t=[];return e.promptBlock!==void 0&&e.promptBlock!==null&&t.push(e.promptBlock),t.push({type:`section`,text:{type:`mrkdwn`,text:`:white_check_mark: *${e.answerLabel}*`}}),e.userId&&e.userId.length>0&&t.push({type:`context`,elements:[{type:`mrkdwn`,text:`Answered by <@${e.userId}>`}]}),t}export{HITL_ACTION_PREFIX,HITL_FREEFORM_ACTION_PREFIX,HITL_FREEFORM_MODAL_ACTION_ID,HITL_FREEFORM_MODAL_BLOCK_ID,HITL_FREEFORM_MODAL_CALLBACK_ID,buildAnsweredBlocks,buildFreeformModalView,deriveHitlResponse,freeformRequestIdFromActionId,isFreeformAction,isHitlAction,renderInputRequestBlocks};
1
+ import{SLACK_SECTION_TEXT_MAX_LENGTH,truncateModalTitle,truncatePlainText,truncateSectionText}from"#public/channels/slack/limits.js";const HITL_ACTION_PREFIX=`eve_input:`,HITL_FREEFORM_ACTION_PREFIX=`eve_input_freeform:`,HITL_FREEFORM_MODAL_CALLBACK_ID=`eve_input_freeform_submit`,HITL_FREEFORM_MODAL_BLOCK_ID=`eve_freeform_block`,HITL_FREEFORM_MODAL_ACTION_ID=`eve_freeform_text`,BUTTON_ACTION_ID_RE=/^(?<requestId>.+):button:\d+$/u;function deriveHitlResponse(e){if(!e.actionId.startsWith(`eve_input:`))return null;let t=e.actionId.slice(10);if(e.selectedOptionValue!==void 0)return t?{optionId:e.selectedOptionValue,requestId:t}:null;if(e.value!==void 0){let n=BUTTON_ACTION_ID_RE.exec(t)?.groups?.requestId;return n?{optionId:e.value,requestId:n}:null}return null}function isHitlAction(e){return e.startsWith(HITL_ACTION_PREFIX)}function renderInputRequestBlocks(e){let t={text:{text:truncateSectionText(e.prompt),type:`mrkdwn`},type:`section`},n=renderInputRequestDetailBlocks(e),a=`${HITL_ACTION_PREFIX}${e.requestId}`,o=e.options,s=e.allowFreeform===!0||!o||o.length===0;if(o&&o.length>0&&e.display===`select`){let e=o.length<=6?{type:`radio_buttons`,action_id:a,options:o.map(buildOption)}:{type:`static_select`,action_id:a,options:o.map(buildOption),placeholder:{type:`plain_text`,text:`Choose an option`}};return[t,...n,{type:`actions`,elements:[e]}]}return o&&o.length>0?[t,...n,{type:`actions`,elements:o.map((e,t)=>buildButton(e,a,t))}]:s?[t,...n,{type:`actions`,elements:[{type:`button`,action_id:`${HITL_FREEFORM_ACTION_PREFIX}${e.requestId}`,text:{type:`plain_text`,text:`Type your answer`},style:`primary`,value:e.requestId}]}]:[t]}function formatInputRequestFallbackText(e){let t=formatToolInputDetails(e);return t===void 0?e.prompt:`${e.prompt}\n${t}`}function buildFreeformModalView(e){let n=e.prompt?truncateModalTitle(e.prompt):`Your answer`,i=e.prompt?[{type:`section`,text:{type:`mrkdwn`,text:truncateSectionText(e.prompt)}}]:[];return{type:`modal`,callback_id:HITL_FREEFORM_MODAL_CALLBACK_ID,private_metadata:JSON.stringify(e.metadata),title:{type:`plain_text`,text:n},submit:{type:`plain_text`,text:`Submit`},close:{type:`plain_text`,text:`Cancel`},blocks:[...i,{type:`input`,block_id:HITL_FREEFORM_MODAL_BLOCK_ID,element:{type:`plain_text_input`,action_id:HITL_FREEFORM_MODAL_ACTION_ID,multiline:!0,placeholder:{type:`plain_text`,text:`Type your answer here...`}},label:{type:`plain_text`,text:`Answer`}}]}}function isFreeformAction(e){return e.startsWith(HITL_FREEFORM_ACTION_PREFIX)}function freeformRequestIdFromActionId(e){if(!isFreeformAction(e))return;let t=e.slice(19);return t.length>0?t:void 0}function buildButton(e,t,r){let i={action_id:`${t}:button:${r}`,text:{text:truncatePlainText(e.label),type:`plain_text`},type:`button`,value:e.id};return(e.style===`primary`||e.style===`danger`)&&(i.style=e.style),i}function buildOption(e){let t={text:{text:truncatePlainText(e.label),type:`plain_text`},value:e.id},r=truncatePlainText(e.description);return r&&r.length>0&&(t.description={text:r,type:`plain_text`}),t}function buildAnsweredBlocks(t){let n=[];for(let e of t.promptBlocks)e!=null&&n.push(e);let r=truncateWithEllipsis(t.answerLabel,SLACK_SECTION_TEXT_MAX_LENGTH-20-1);return n.push({type:`section`,text:{type:`mrkdwn`,text:`:white_check_mark: *${r}*`}}),t.userId&&t.userId.length>0&&n.push({type:`context`,elements:[{type:`mrkdwn`,text:`Answered by <@${t.userId}>`}]}),n}function renderInputRequestDetailBlocks(e){let t=formatToolInputDetails(e);return t===void 0?[]:[{type:`section`,text:{type:`mrkdwn`,text:t}}]}function formatToolInputDetails(t){if(!isApprovalRequest(t))return;let n=JSON.stringify(t.action.input,null,2);return n===`{}`?void 0:`*Tool input*
2
+ \`\`\`
3
+ ${truncateWithEllipsis(n,SLACK_SECTION_TEXT_MAX_LENGTH-17-4)}
4
+ \`\`\``}function truncateWithEllipsis(e,t){if(e.length<=t)return e;let n=Math.max(0,t-3);return`${e.slice(0,n).trimEnd()}...`}function isApprovalRequest(e){return e.display===`confirmation`&&e.options?.length===2&&e.options[0]?.id===`approve`&&e.options[1]?.id===`deny`}export{HITL_ACTION_PREFIX,HITL_FREEFORM_ACTION_PREFIX,HITL_FREEFORM_MODAL_ACTION_ID,HITL_FREEFORM_MODAL_BLOCK_ID,HITL_FREEFORM_MODAL_CALLBACK_ID,buildAnsweredBlocks,buildFreeformModalView,deriveHitlResponse,formatInputRequestFallbackText,freeformRequestIdFromActionId,isFreeformAction,isHitlAction,renderInputRequestBlocks};