@reason-machines/cli-linux-x64 0.2.419 → 0.2.421
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.txt +8 -7
- package/bin/reason +2 -2
- package/bin/runtime/srt/sandbox-runtime.mjs +52 -52
- package/bin/vm-hands/api-18d75dfn.js +2 -0
- package/bin/vm-hands/api-credentials-3vhge1ap.js +2 -0
- package/bin/vm-hands/connect-cli-5r07fda9.js +2 -0
- package/bin/vm-hands/custom-endpoint-device-17t4efc4.js +2 -0
- package/bin/vm-hands/desktop-account-6sjrxy69.js +2 -0
- package/bin/vm-hands/device-workspace-s50q53sz.js +2 -0
- package/bin/vm-hands/fsevents-p3d8kd0p.js +2 -0
- package/bin/vm-hands/hands-worker-source-kddz4y15.js +2 -0
- package/bin/vm-hands/index-wrw65904.js +12818 -0
- package/bin/vm-hands/install-receipt-ysa70fvh.js +2 -0
- package/bin/vm-hands/local-automation-764g234v.js +2 -0
- package/bin/vm-hands/local-capabilities-mg6eae35.js +2 -0
- package/bin/vm-hands/local-desktop-users-cppjjr81.js +2 -0
- package/bin/vm-hands/local-display-mac-0qz3b627.js +2 -0
- package/bin/vm-hands/local-display-session-a59620te.js +2 -0
- package/bin/vm-hands/local-display-video-6zdpjv5n.js +2 -0
- package/bin/vm-hands/local-managed-process-s7j196kq.js +2 -0
- package/bin/vm-hands/local-pty-session-rpk05ap5.js +2 -0
- package/bin/vm-hands/managed-runtime-vg23x3np.js +2 -0
- package/bin/vm-hands/network-contract-trkxqc0w.js +2 -0
- package/bin/vm-hands/package-xqbhdf15.js +2 -0
- package/bin/vm-hands/permissions-zkrmth58.js +2 -0
- package/bin/vm-hands/reason-hands-protocol-xn3ddz70.js +2 -0
- package/bin/vm-hands/serve-service-y2sa6493.js +2 -0
- package/bin/vm-hands/status-6qmcgcem.js +10 -0
- package/bin/vm-hands/version-42drg7mg.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-agsp101y.js → vm-hands-entry-lite-21qpxvt8.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-2x8g6ktg.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-33hwmnd3.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-3krzmhkk.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-4vks5phw.js +42 -0
- package/bin/vm-hands/vm-hands-entry-lite-4wpqs406.js +126 -0
- package/bin/vm-hands/vm-hands-entry-lite-50zbqwkv.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-5dtfehjv.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-60pg3wxj.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-6c67a3jc.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-7fsj5nrx.js +539 -0
- package/bin/vm-hands/vm-hands-entry-lite-8r31b0ps.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-8wf6y7xy.js +105 -0
- package/bin/vm-hands/vm-hands-entry-lite-aj139v8j.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-avc65bd7.js +65 -0
- package/bin/vm-hands/{vm-hands-entry-lite-vsa7t6m9.js → vm-hands-entry-lite-beyyy1gz.js} +54 -54
- package/bin/vm-hands/vm-hands-entry-lite-bx5zy5bd.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-c8ga19q0.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-djg69hf4.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-dk79tnax.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-dsxpxqd3.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-ec9jemny.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-fbhqfzbq.js +4 -0
- package/bin/vm-hands/{vm-hands-entry-lite-4k4h9rcq.js → vm-hands-entry-lite-fcvf8md1.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-g4zd2d5n.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-gvh1qskx.js +128 -0
- package/bin/vm-hands/vm-hands-entry-lite-hbs3tpdg.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-hek6nw5m.js +9 -0
- package/bin/vm-hands/vm-hands-entry-lite-hk6trmwa.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-jev771b3.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-jzz73e3f.js +112 -0
- package/bin/vm-hands/vm-hands-entry-lite-m1yxqqaz.js +14 -0
- package/bin/vm-hands/vm-hands-entry-lite-np07qyeq.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-nzmkyezg.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-pf5qtbj5.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-qy9xg6em.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-6y6pz2yw.js → vm-hands-entry-lite-rfz60hb3.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-s1nwwtcs.js +452 -0
- package/bin/vm-hands/vm-hands-entry-lite-s4bharcb.js +9 -0
- package/bin/vm-hands/vm-hands-entry-lite-s5qkb1fk.js +6 -0
- package/bin/vm-hands/vm-hands-entry-lite-tdgtpx8e.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-vpz54vwj.js +7 -0
- package/bin/vm-hands/vm-hands-entry-lite-weqw6ykz.js +52 -0
- package/bin/vm-hands/vm-hands-entry-lite-wx4ax7wg.js +4 -0
- package/bin/vm-hands/{vm-hands-entry-lite-fzkfajew.js → vm-hands-entry-lite-ycnrtwdf.js} +5 -9
- package/bin/vm-hands/vm-hands-entry-lite-yretc2th.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-z76nfb19.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-zp6naptr.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite.js +3 -1
- package/bin/vm-hands/vm-hands-executor-957e80sb.js +11 -0
- package/bin/vm-hands/vm-hands-op-runner-65erpgzp.js +2 -0
- package/bin/vm-hands/vm-hands-runtime-6stbsbbw.js +4 -0
- package/bin/vm-hands/worker-preview-readiness-w62n91kr.js +2 -0
- package/bin/vm-hands/worker-sandbox-2r5nseff.js +2 -0
- package/package.json +1 -1
- package/bin/vm-hands/api-credentials-s4897qxy.js +0 -2
- package/bin/vm-hands/api-m73x3da5.js +0 -2
- package/bin/vm-hands/ask-relay-4kwcx2b7.js +0 -8
- package/bin/vm-hands/connect-cli-34b18gjs.js +0 -2
- package/bin/vm-hands/custom-endpoint-device-j012b4bd.js +0 -2
- package/bin/vm-hands/desktop-account-0q0arpzk.js +0 -2
- package/bin/vm-hands/device-workspace-3jxhs54b.js +0 -2
- package/bin/vm-hands/hands-worker-source-y64axsw3.js +0 -2
- package/bin/vm-hands/index-194s4vz0.js +0 -12818
- package/bin/vm-hands/install-receipt-1g68b446.js +0 -2
- package/bin/vm-hands/local-automation-k2w46hn2.js +0 -2
- package/bin/vm-hands/local-capabilities-tdzbqmrb.js +0 -2
- package/bin/vm-hands/local-desktop-users-6thzvydd.js +0 -2
- package/bin/vm-hands/local-display-mac-59ma7sxa.js +0 -2
- package/bin/vm-hands/local-display-session-4833qq7h.js +0 -2
- package/bin/vm-hands/local-display-video-c1143mz6.js +0 -2
- package/bin/vm-hands/local-managed-process-mr0zpk7c.js +0 -2
- package/bin/vm-hands/local-pty-session-bwarwpsd.js +0 -2
- package/bin/vm-hands/managed-runtime-vz1wqwwg.js +0 -2
- package/bin/vm-hands/network-contract-gprc37sw.js +0 -2
- package/bin/vm-hands/package-ej9snd47.js +0 -2
- package/bin/vm-hands/permissions-7sfghef4.js +0 -2
- package/bin/vm-hands/reason-hands-protocol-jsrkawe2.js +0 -2
- package/bin/vm-hands/serve-service-kngyzh74.js +0 -2
- package/bin/vm-hands/status-jz29fb95.js +0 -96
- package/bin/vm-hands/version-g29vt13t.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-0h4qmgm2.js +0 -9
- package/bin/vm-hands/vm-hands-entry-lite-0k13wmzm.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-1exfjv79.js +0 -52
- package/bin/vm-hands/vm-hands-entry-lite-26q3hbdc.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-28s7v15d.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-2m5dwrdf.js +0 -6
- package/bin/vm-hands/vm-hands-entry-lite-37hvds7z.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-3rqdzqhk.js +0 -112
- package/bin/vm-hands/vm-hands-entry-lite-4gh5kfr4.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-6nwbqg37.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-714wspqb.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-7zk0r3p9.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-9qep7pka.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-am6kj1n1.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-as1tkffn.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-bxt4n1nj.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-c2g3wmkp.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-d2w8tghq.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-d98m00b8.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-daxcxjze.js +0 -344
- package/bin/vm-hands/vm-hands-entry-lite-dcnyve97.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-e1b89x66.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-ej5ffjck.js +0 -105
- package/bin/vm-hands/vm-hands-entry-lite-ejkba2nk.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-f3wh0dza.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-f5xb489y.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-feybcq63.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-fpp2bs9y.js +0 -452
- package/bin/vm-hands/vm-hands-entry-lite-gt497d5x.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-gxper06w.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-j2ng164q.js +0 -9
- package/bin/vm-hands/vm-hands-entry-lite-jp9q2vsx.js +0 -127
- package/bin/vm-hands/vm-hands-entry-lite-magmzx9c.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-ntx8fdyq.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-pfzczmaa.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-pkc4ry5x.js +0 -539
- package/bin/vm-hands/vm-hands-entry-lite-pp7jfqzr.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-q8wkrzer.js +0 -66
- package/bin/vm-hands/vm-hands-entry-lite-s823n1q9.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-s9xf5z69.js +0 -7
- package/bin/vm-hands/vm-hands-entry-lite-tchc7z17.js +0 -128
- package/bin/vm-hands/vm-hands-entry-lite-tytfs183.js +0 -42
- package/bin/vm-hands/vm-hands-entry-lite-v4jtxgaj.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-vgpt2n1v.js +0 -11
- package/bin/vm-hands/vm-hands-entry-lite-xp3qzxk5.js +0 -3
- package/bin/vm-hands/vm-hands-executor-epyhpjv3.js +0 -11
- package/bin/vm-hands/vm-hands-op-runner-fn1qph82.js +0 -2
- package/bin/vm-hands/vm-hands-runtime-8vt9etvv.js +0 -4
- package/bin/vm-hands/worker-preview-readiness-yfjgban2.js +0 -2
- package/bin/vm-hands/worker-sandbox-z0t69av8.js +0 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{g,Gr,mo,xe}from"./vm-hands-entry-lite-aj139v8j.js";import{t,o,d,u,i,ns,W,_,s,n}from"./vm-hands-entry-lite-avc65bd7.js";var J=/^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/;function v(e){let r=typeof e==="string"?J.exec(e):null;return r?{major:Number(r[1]),minor:Number(r[2])}:null}var Q=25,Le=i({machine:t().min(1).max(200),person:t().min(1).max(200),team:t().min(1).max(200),version:t().max(64).optional(),wait_seconds:o().int().min(0).max(Q).optional()}),K=_("kind",[i({id:t(),kind:n("who"),all:d().optional()}),i({id:t(),kind:n("send"),to:t(),body:t(),from_name:t(),from_agent:t(),wake:d(),reply_to:t().max(100).optional(),notify:d().optional()})]),P=i({job:K.nullable(),retry_after_seconds:o().optional()}),V=i({address:t(),person:t(),machine:t(),agent:t(),repo:t().nullable(),branch:t().nullable(),status:t(),since:o().nullable(),doing:t().nullable(),worker:d(),tier:t().max(10).optional()}),Y=i({person:t(),machine:t(),online:d()}),X=i({team:t().nullable(),sessions:u(V).max(2000),machines:u(Y).max(500),all:d().optional()}),Z=i({address:t().max(300),state:t().max(40),note:t().max(500)}),Ne=W([i({who:X}),i({sent:i({ids:u(t().max(100)).max(500),recipients:u(t().max(300)).max(500),from:t().max(300),deliveries:u(Z).max(500).optional()})}),i({error:t().min(1).max(2000)})]),ee=i({id:t().max(100),from:t().max(300),from_agent:t().max(100).nullable(),to:t().max(300),reply_to:t().max(100).nullable(),body:t().max(64000),sent_at:o()}),De=i({messages:u(ee).max(100)});import{randomBytes as ne}from"crypto";import{chmodSync as C,existsSync as A,lstatSync as te,mkdirSync as se,readFileSync as U,renameSync as oe,unlinkSync as q,writeFileSync as O}from"fs";import{homedir as re}from"os";import{dirname as ie,join as x}from"path";function b(e=process.env,r=re()){let a=e.XDG_CONFIG_HOME?.trim()||x(r,".config"),c=g({env:e})==="staging"?["staging"]:[];return x(xe(a,...c),"credentials.json")}function z(e,r=b()){return se(ie(r),{recursive:!0,mode:448}),O(r,`${JSON.stringify(e,null,2)}
|
|
3
|
+
`,{mode:384}),C(r,384),r}function k(e=b()){if(!A(e))return null;try{let r=U(e,"utf8"),a=JSON.parse(r);if(typeof a.apiOrigin!=="string"||typeof a.clientId!=="string"||typeof a.accessToken!=="string"||typeof a.refreshToken!=="string"||typeof a.expiresAt!=="string"||typeof a.orgId!=="string"||!Array.isArray(a.scopes))return null;let l=new URL(a.apiOrigin).origin,c=Gr(l);if(c!==l)ae(e,r,c);return{apiOrigin:c,clientId:a.clientId,accessToken:a.accessToken,refreshToken:a.refreshToken,expiresAt:a.expiresAt,scopes:a.scopes.filter((m)=>typeof m==="string"),orgId:a.orgId}}catch{return null}}function ae(e,r,a){let l=`${e}.${process.pid}.${ne(6).toString("hex")}.tmp`;try{let c=te(e);if(!c.isFile()||process.platform!=="win32"&&c.uid!==process.geteuid?.())return;let m=JSON.parse(r);if(O(l,`${JSON.stringify({...m,apiOrigin:a},null,2)}
|
|
4
|
+
`,{mode:384,flag:"wx"}),C(l,384),U(e,"utf8")!==r)throw Error("credentials_changed");oe(l,e)}catch{try{q(l)}catch{}}}function M(e=b()){if(!A(e))return!1;return q(e),!0}var j=["run","mcp:read","mcp:write","secrets:read","secrets:write","sessions:read","sessions:debug","devices:read","devices:write","devices:use","ssh:write","knowledge:read","memory:read","memory:write","skills:read","skills:write","repos:read","repos:write","reviews:read","reviews:write","deployment:read","analytics:read","org:read","org:write","attachments:read","attachments:write","guardrails:read","guardrails:write","network:read","network:write","automations:read","automations:write","agent_auth:read"];var cn=j.filter((e)=>e!=="network:read"&&e!=="network:write");class R extends Error{oauthCode;constructor(e,r=null){super(e);this.oauthCode=r;this.name="LoginError"}}function le(e,r){let a=typeof e.error==="string"?e.error:null,l=typeof e.error_description==="string"?e.error_description:a?a:r;return new R(l,a)}async function ce(e,r,a,l){let c=await a(`${e}/mcp/oauth/token`,{method:"POST",redirect:"error",headers:{"content-type":"application/x-www-form-urlencoded"},body:r,signal:l}),m=await c.json().catch(()=>({}));if(!c.ok)throw le(m,`OAuth token request failed (${c.status})`);return m}var de=1e4;async function me(e,r={}){let a=r.fetchImpl??fetch,l=await ce(e.apiOrigin,new URLSearchParams({grant_type:"refresh_token",client_id:e.clientId,refresh_token:e.refreshToken}),a,AbortSignal.timeout(de)).catch((m)=>{if(m instanceof Error&&m.name==="TimeoutError")throw new R("Reason did not answer the login refresh in time. Check the network and retry.");throw m});if(typeof l.access_token!=="string"||typeof l.refresh_token!=="string"||typeof l.expires_in!=="number")throw new R("Reason returned an incomplete refreshed login.");let c={...e,accessToken:l.access_token,refreshToken:l.refresh_token,expiresAt:new Date(Date.now()+l.expires_in*1000).toISOString(),scopes:typeof l.scope==="string"?l.scope.split(/\s+/).filter(Boolean):e.scopes};return z(c,r.path??b()),c}var w=new Map;function E(e,r){if(!r)return e;if(r.aborted)return Promise.reject(r.reason);return new Promise((a,l)=>{let c=()=>l(r.reason);r.addEventListener("abort",c,{once:!0}),e.then(a,l).finally(()=>r.removeEventListener("abort",c))})}async function Tt(e={}){let r=e.path??b(),a=k(r);if(!a)return null;let l=e.apiOrigin??T(process.env,"REASON_API_URL")?.trim();if(l&&!mo(a.apiOrigin,new URL(l).origin))return null;let c=Date.parse(a.expiresAt)<=Date.now()+60000;if(!e.forceRefresh&&!c)return a;let m=[r,a.apiOrigin,a.clientId,a.refreshToken].join("\x00"),p=w.get(m);if(p)return E(p,e.signal);let f;return f=me(a,{fetchImpl:e.fetchImpl,path:r}).catch(async(y)=>{if(!(y instanceof R)||y.oauthCode!=="invalid_grant"&&y.oauthCode!=="invalid_client")throw y;let S=k(r),B=y.oauthCode==="invalid_client"?S?.clientId!==a.clientId:S?.refreshToken!==a.refreshToken;if(S&&B)return Tt({fetchImpl:e.fetchImpl,path:r});return M(r),null}).finally(()=>{if(w.get(m)===f)w.delete(m)}),w.set(m,f),E(f,e.signal)}var ue=i({label:t(),used_percent:o().min(0).max(100).nullable(),resets_at:t().nullable(),exhausted:d().nullable()}),ge=i({groups:u(i({selectable:d().optional(),accounts:u(i({source_id:t().min(1),model_ids:u(t().min(1)).optional()}))}))});function he(e){let r=ge.safeParse(e);if(!r.success)return;return r.data.groups.some((a)=>a.selectable!==!1&&a.accounts.some((l)=>l.model_ids===void 0||l.model_ids.length>0))}class I extends Error{status;code;suggestedModel;retryAfterMs;resolutionReason;constructor(e,r,a,l,c,m){super(a);this.status=e;this.code=r;this.suggestedModel=l;this.retryAfterMs=c;this.resolutionReason=m;this.name="ApiError"}static rateLimitDelayMs(e,r){if(!(e instanceof I)||e.status!==429)return null;return Math.min(60000,Math.max(r,e.retryAfterMs??0))}}var pe=["minimal","low","medium","high","xhigh","max"],fe=i({id:t().min(1),kind:t(),name:t(),custom_name:t().nullish(),status:t(),online:d(),compatible:d().optional(),compatibility_reason:t().nullish(),folder_lane_of:t().nullish(),roots:u(i({id:t().min(1),label:t()}))}),ye=i({devices:u(fe),end_cursor:t().nullish(),has_next_page:d().optional()}),_e=i({id:t().min(1),name:t()}),be=i({items:u(_e)}),Re=i({id:t().min(1),name:t(),main:d(),mine:d(),session_id:t().nullish(),appearance:i({color:t().nullish()}).nullish().catch(null)}),we=i({items:u(Re)}),Se=i({skill_id:t().min(1),name:t(),description:t().nullish(),activation_keywords:u(t()).default([]),is_enabled:d().default(!0)}),ke=i({items:u(Se).default([])}),ve=i({id:t().min(1),kind:t(),enabled:d(),schedule:i({expression:t().nullish(),every_seconds:o().nullish(),next_run_at:t().nullish()}).nullish(),github:i({event:t().nullish(),action:t().nullish(),repo:t().nullish()}).nullish(),last_fired_at:t().nullish()}),N=i({id:t().min(1),name:t().nullish(),instructions:t().nullish(),enabled:d(),triggers:u(ve).default([])}),Pe=i({items:u(N).default([]),end_cursor:t().nullish(),has_next_page:d().optional()}),Ie=i({id:t().min(1),slug:t().nullish(),name:t(),description:t().nullish(),transport:t().nullish(),url:t().nullish(),enabled:d()}),Ce=i({items:u(Ie).default([])}),$e=i({status:t(),summary:t().nullish(),category:t().nullish(),outcome:t().nullish(),message_count:o().nullish(),pr_url:t().nullish(),cost_usd:o().nullish(),generated_at:t().nullish()}),L=i({tags:u(t()).default([])}),Ae=s(["linux","macos"]),D=i({id:t().min(1),name:t().min(1),platform:Ae.nullable(),workers:i({total:o().int(),online:o().int(),busy:o().int(),idle:o().int()}),sessions:i({queued:o().int(),running:o().int()})}),Ue=i({machines:u(D)}),Te=i({machine:D}),qe=i({deleted:n(!0),revoked_workers:o().int(),revoked_tokens:o().int()}),Oe=i({token:i({id:t().min(1),machine_id:t().min(1),token_prefix:t()}),secret:t().startsWith("rmt_")}),H=ns({machine_id:t().min(1),machine_name:t().min(1)}),ze=H.extend({organization_id:t().min(1)}),pn=i({id:t().min(1),name:t().min(1),state:s(["waiting","placed"]),queue_position:o().int().nullable()});var fn=W([i({kind:n("cloud")}),i({kind:s(["mac","headless"]),device_id:t().min(1),root_id:t().min(1)})]);function h(e,r,a){let l=e.safeParse(r);if(!l.success)throw new I(502,a,"Reason returned an unexpected response.");return l.data}var Me=i({error:i({type:t(),message:t()})});function F(e,r,a){let l=Me.safeParse(r),c=typeof r.error==="string"?r.error:l.success?l.data.error.type:`http_${e}`,m=typeof r.detail==="string"?r.detail:typeof r.message==="string"?r.message:l.success?l.data.error.message:`Reason request failed (${e}${typeof r.error==="string"?` ${r.error}`:""})`,p=c==="github_connection_required"&&typeof r.connect_url==="string"&&/^https?:\/\//.test(r.connect_url)?` Connect it at ${r.connect_url}`:"",f=a===null||a.trim()===""?NaN:Number(a);return new I(e,c,`${m}${p}`,typeof r.suggested_model==="string"?r.suggested_model:void 0,Number.isFinite(f)&&f>=0?f*1000:void 0,typeof r.resolution_reason==="string"?r.resolution_reason:void 0)}async function fs(e){let r=await(e.fetchImpl??fetch)(`${e.apiOrigin}/v3/machines/enrollment-tickets`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,accept:"application/json","content-type":"application/json"},body:JSON.stringify(e.body),signal:AbortSignal.timeout(30000),redirect:"error"}),a=await r.json().catch(()=>({}));if(!r.ok)throw F(r.status,a,r.headers.get("retry-after"));return h(ze,a,"invalid_machine_ticket")}class qo{options;credentials;constructor(e,r={}){this.options=r;this.credentials=e}trackEvent(e,r={}){}async request(e,r={},a=!1){let l=this.options.fetchImpl??fetch,c=await l(`${this.credentials.apiOrigin}/v3${e}`,{method:r.method??"GET",headers:{authorization:`Bearer ${this.credentials.accessToken}`,accept:"application/json","user-agent":"reason-cli","x-reason-agent":"Reason CLI",...r.raw?{"content-type":r.raw.contentType}:r.body===void 0?{}:{"content-type":"application/json"},...r.headers},body:r.raw?r.raw.bytes:r.body===void 0?void 0:JSON.stringify(r.body),signal:r.signal,redirect:"error"}),m=await c.json().catch(()=>({}));if(c.status===401&&!a&&r.retryUnauthorized!==!1&&this.credentials.credentialKind!=="api_key"){let p=await Tt({fetchImpl:l,path:this.options.credentialsPath,forceRefresh:!0,signal:r.signal});if(p)return this.credentials=p,this.request(e,r,!0)}if(!c.ok)throw F(c.status,m,c.headers.get("retry-after"));return m}createHeadlessDeviceEnrollmentTicket(e){return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/devices/enrollment-tickets`,{method:"POST",body:e,signal:AbortSignal.timeout(30000),retryUnauthorized:!1})}async enrollHeadlessDevice(e){try{return await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/devices/enrollments`,{method:"POST",body:e,signal:AbortSignal.timeout(30000),retryUnauthorized:!1})}catch(r){if(r instanceof I&&(r.status===404||r.status===405||r.status===403&&r.code==="endpoint_not_available"))return null;throw r}}addDeviceRoot(e,r){return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/devices/${encodeURIComponent(e)}/roots`,{method:"POST",body:r,signal:AbortSignal.timeout(30000)})}removeDeviceRoot(e,r){return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/devices/${encodeURIComponent(e)}/roots/${encodeURIComponent(r)}`,{method:"DELETE",signal:AbortSignal.timeout(30000)})}machinePath(e,r=""){let a=`/organizations/${encodeURIComponent(this.credentials.orgId)}/machines`;return e===void 0?a:`${a}/${encodeURIComponent(e)}${r}`}async listMachines(){return h(Ue,await this.request(this.machinePath()),"invalid_machine_list").machines}async createMachine(e){let r=await this.request(this.machinePath(),{method:"POST",body:{name:e.name,...e.platform?{platform:e.platform}:{}}});return h(Te,r,"invalid_machine").machine}async deleteMachine(e){let r=await this.request(this.machinePath(e),{method:"DELETE"});return h(qe,r,"invalid_machine_deletion")}async createMachineToken(e){let r=await this.request(this.machinePath(e,"/tokens"),{method:"POST",body:{}});return h(Oe,r,"invalid_machine_token")}async createMachineEnrollmentTicket(e,r){let a=await this.request(this.machinePath(e,"/enrollment-tickets"),{method:"POST",body:r,signal:AbortSignal.timeout(30000),retryUnauthorized:!1});return h(H,a,"invalid_machine_ticket")}self(e){return this.request("/self",{signal:e})}agentNetwork(){return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/agent-network`,{signal:AbortSignal.timeout(30000)})}startAgentNetwork(e){return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/agent-network`,{method:"POST",body:e,signal:AbortSignal.timeout(30000)})}rotateAgentNetwork(e){return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/agent-network`,{method:"PUT",body:e,signal:AbortSignal.timeout(30000)})}async claimAgentNetworkRelayJob(e,r){let a=await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/agent-network/relay/claim`,{method:"POST",body:e,signal:r});return h(P,a,"invalid_agent_network_job")}async completeAgentNetworkRelayJob(e,r){await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/agent-network/relay/jobs/${encodeURIComponent(e)}`,{method:"POST",body:r,signal:AbortSignal.timeout(30000)})}async recordAgentNetworkRelayReplies(e){await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/agent-network/relay/replies`,{method:"POST",body:{messages:e},signal:AbortSignal.timeout(30000)})}async workspaceMembers(){return((await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/members/users`,{signal:AbortSignal.timeout(30000)})).items??[]).flatMap((r)=>typeof r.email==="string"?[{email:r.email,role:typeof r.role==="string"?r.role:"member"}]:[])}claimExistingCliPairing(e){return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/onboarding/import/pairing/claim-existing`,{method:"POST",body:{pairing_code:e}})}async claudeCodeSignIn(e){return(await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/provider-credentials`,{retryUnauthorized:!1,signal:e?AbortSignal.any([e,AbortSignal.timeout(15000)]):AbortSignal.timeout(15000)})).claude_code_sign_in===!0}connectAnthropicProvider(e,r,a={}){let l=e.kind==="setup_token"?{setup_token:e.token}:{access_token:e.credential.access,refresh_token:e.credential.refresh,expires_at:new Date(e.credential.expires).toISOString()};return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/provider-credentials/anthropic`,{method:"POST",retryUnauthorized:a.retryUnauthorized,signal:a.signal,body:{...l,...r?{account_key:r}:{}}})}async listRepositories(){return((await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/repositories`)).items??[]).flatMap((r)=>{let a=typeof r.full_name==="string"?r.full_name:typeof r.repo_full_name==="string"?r.repo_full_name:null;if(!a)return[];return[{repo_id:typeof r.repo_id==="string"?r.repo_id:void 0,full_name:a,provider:r.provider==="gitlab"?"gitlab":"github",default_branch:typeof r.default_branch==="string"?r.default_branch:null,private:typeof r.private==="boolean"?r.private:void 0}]})}async listProjects(){let e=await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/projects`),r=be.safeParse(e);if(!r.success)throw new I(502,"invalid_project_list","Reason returned an unexpected project list.");return r.data.items}async listReasons(){let e=await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/reasons`);return h(we,e,"invalid_reason_list").items}async openReasonConversation(e){let r=await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/reasons/${encodeURIComponent(e)}/conversation`,{method:"POST"});return h(i({session_id:t().min(1)}),r,"invalid_reason_conversation").session_id}async listSkills(){try{let e=await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/skills`);return h(ke,e,"invalid_skill_list").items}catch(e){if(e instanceof I&&(e.status===403||e.status===404))return[];throw e}}async listDevices(){let e=[],r=null;for(let a=0;a<50;a+=1){let l=await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/devices${r?`?after=${encodeURIComponent(r)}`:""}`),c=ye.safeParse(l);if(!c.success)throw new I(502,"invalid_device_list","Reason returned an unexpected machine list.");if(e.push(...c.data.devices),r=c.data.has_next_page?c.data.end_cursor??null:null,!r)break}return e}async listModels(){try{let r=((await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/agent-auth/models`)).models??[]).filter((c)=>c.hidden!==!0),a=r.filter((c)=>c.available!==!1).map(({reasoning_efforts:c,hidden:m,available:p,...f})=>({...f,...Array.isArray(c)?{reasoning_efforts:pe.filter((y)=>c.includes(y))}:{}})),l=new Set(a.map((c)=>c.detail));return{models:a.length>1&&l.size===1?a.map(({detail:c,...m})=>m):a,runnable:a.length>0||r.length===0}}catch(e){if(e instanceof I&&(e.status===403||e.status===404))return{models:[],runnable:!0};throw e}}async getAgentVersion(e){try{let r=await this.request("/deployment",{signal:e,retryUnauthorized:!1});return v(r.reason_version)?r.reason_version:null}catch{return null}}async getUsageQuota(){try{let e=ue.safeParse(await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/usage/quota`));if(!e.success)return null;let r;try{r=he(await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/agent-auth/models`))}catch{}return{...e.data,own_inference:r}}catch(e){if(e instanceof I&&(e.status===403||e.status===404))return null;throw e}}async listSessions(e=50,r,a={}){let l=new URLSearchParams({first:String(Math.min(Math.max(e,1),200)),status:a.status??"active"});if(r)l.set("project_id",r);if(a.origin)l.set("origin",a.origin);return(await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions?${l.toString()}`)).items??[]}getSession(e,r){let a=r?.fields.length?`?fields=${encodeURIComponent(r.fields.join(","))}`:"";return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/${encodeURIComponent(e)}${a}`)}async prestartSession(e){let r=await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/prestart`,{method:"POST",body:{client_session_id:e}});return r?.status==="starting"||r?.status==="ready"}async createSession(e){let r=e.mode==="ephemeral"||e.workspaceOwnership==="externally-managed";if(e.attachments?.length)await this.requireSessionAttachments();if(r||e.runtimeProfile){let c=await this.request("/deployment");if(r&&(!Array.isArray(c.session_modes)||!c.session_modes.includes(e.mode??"standard")||!Array.isArray(c.workspace_ownerships)||!c.workspace_ownerships.includes(e.workspaceOwnership??"managed")))throw Error("Deployment does not support the requested Session policy; refusing to create a Session.");if(e.runtimeProfile&&(!Array.isArray(c.experimental_runtime_profiles)||!c.experimental_runtime_profiles.includes(e.runtimeProfile)))throw Error("Deployment does not support the requested runtime profile; refusing to create a Session.")}let a=await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions`,{method:"POST",body:{prompt:e.prompt,...e.attachments?.length?{attachments:e.attachments}:{},...e.mode?{mode:e.mode}:{},...e.workspaceOwnership?{workspace_ownership:e.workspaceOwnership}:{},...e.target?{target:e.target}:{},...e.repo?{repo:e.repo}:{},...e.provider?{provider:e.provider}:{},...e.model?{model:e.model}:{},...e.reasoningEffort?{reasoning_effort:e.reasoningEffort}:{},...e.runtimeProfile?{experimental_runtime_profile:e.runtimeProfile}:{},...e.ref?{ref:e.ref}:{},...e.branch?{branch:e.branch}:{},...e.completionMode?{completion_mode:e.completionMode}:{},...e.env&&Object.keys(e.env).length>0?{env:e.env}:{},...e.clientSessionId?{client_session_id:e.clientSessionId}:{},...e.longRunning?{long_running:{enabled:!0}}:{},...e.spendLimitRcu?{spend_limit_rcu:e.spendLimitRcu}:{},idempotency_key:`cli-${crypto.randomUUID()}`}}),l=await this.getSession(a.session_id);if(r){let c=l.session_policy,m=["memoryRead","memoryWrite","skills","inheritedInstructions","integrations","secretInjection"];if(!c||c.version!==1||c.mode!==(e.mode??"standard")||c.workspaceOwnership!==(e.workspaceOwnership??"managed")||!c.components||m.some((p)=>c.components[p]!==!0))throw await this.cancelSession(a.session_id),Error("Server did not attest the requested Session policy; cancellation requested.")}if(e.runtimeProfile&&l.experimental_runtime_profile!==e.runtimeProfile)throw await this.cancelSession(a.session_id),Error("Server did not attest the requested runtime profile; cancellation requested.");return l}async getEvents(e,r=-1,a={}){try{return await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/${encodeURIComponent(e)}/events?after_seq=${r}&limit=500${a.waitMs?`&wait_ms=${a.waitMs}`:""}`,a.signal?{signal:a.signal}:{})}catch(l){if(!(l instanceof I)||l.status!==403&&l.status!==404)throw l;return{session:await this.getSession(e),items:[],next_seq:r}}}async getMessages(e,r){return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/${encodeURIComponent(e)}/messages?first=500${r===void 0?"":`&after_seq=${r}`}`)}async getAttachments(e,r){try{return(await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/${encodeURIComponent(e)}/attachments${r?`?view=${r}`:""}`)).items??[]}catch(a){if(a instanceof I&&(a.status===403||a.status===404))return[];throw a}}async requireSessionAttachments(){let e=await this.request("/deployment",{headers:{"cache-control":"no-cache"}});if(e.session_attachments!==!0){let r=typeof e.reason_version==="string"&&/^\d+\.\d+(?:\.\d+)?$/.test(e.reason_version)?`Agent ${e.reason_version}`:null,a=typeof e.commit_sha==="string"&&/^[a-f0-9]{40,64}$/i.test(e.commit_sha)?`server ${e.commit_sha.slice(0,12)}`:null,l=[r,a].filter(Boolean).join(", ");throw Error(`This server does not support Session image attachments: ${new URL(this.credentials.apiOrigin).host}${l?` (${l})`:""}. The API server needs an attachment-capable deployment; updating the Agent version alone is not enough. Your image was not sent; retry after the server update.`)}}async sendMessage(e,r,a={}){if(a.attachments?.length)await this.requireSessionAttachments();return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/${encodeURIComponent(e)}/messages`,{method:"POST",body:{message:r,...a.attachments?.length?{attachments:a.attachments}:{},...a.model?{model:a.model}:{},...a.reasoningEffort?{reasoning_effort:a.reasoningEffort}:{},...a.target?{target:a.target}:{},...a.delivery?{delivery:a.delivery}:{}}})}async steerQueuedMessage(e,r){await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/${encodeURIComponent(e)}/messages/${encodeURIComponent(r)}/steer`,{method:"POST",body:{}})}async withdrawQueuedMessage(e,r){await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/${encodeURIComponent(e)}/messages/${encodeURIComponent(r)}/queued`,{method:"DELETE"})}async getConversation(e){let r=[],a=null;for(let l=0;l<50;l+=1){let c=await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/${encodeURIComponent(e)}/conversation${a?`?after=${encodeURIComponent(a)}`:""}`);if(r.push(...c.items??[]),!c.has_next_page||!c.end_cursor)break;a=c.end_cursor}return r}createSharedLink(e,r){return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/${encodeURIComponent(e)}/shared-links`,{method:"POST",body:{url:r.url,...r.label?{label:r.label}:{},...r.expiresInSeconds!==void 0?{expires_in_seconds:r.expiresInSeconds}:{}}})}sessionAction(e,r,a={}){return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/${encodeURIComponent(e)}/${r}`,{method:"POST",body:a})}renameSession(e,r){return this.sessionAction(e,"rename",{title:r||null})}moveSessionToProject(e,r){return this.sessionAction(e,"project",{project_id:r})}compactSession(e){return this.sessionAction(e,"compact")}retrySession(e){return this.sessionAction(e,"retry")}rewindSession(e,r){return this.sessionAction(e,"rewind",{message_id:r.messageId,content:r.content,request_id:r.requestId})}forkSession(e,r){return this.sessionAction(e,"fork",{...r.message?{message:r.message}:{},client_session_id:r.clientSessionId})}cancelSession(e,r={}){return this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/${encodeURIComponent(e)}/cancel`,{method:"POST",body:r.mode==="hard"?{mode:"hard"}:{}})}sessionPath(e,r=""){return`/organizations/${encodeURIComponent(this.credentials.orgId)}/sessions/${encodeURIComponent(e)}${r}`}async archiveSession(e){await this.request(this.sessionPath(e,"/archive"),{method:"POST",body:{}})}async unarchiveSession(e){await this.request(this.sessionPath(e,"/unarchive"),{method:"POST",body:{}})}async deleteSession(e){await this.request(this.sessionPath(e),{method:"DELETE"})}async listSessionTags(e){return h(L,await this.request(this.sessionPath(e,"/tags")),"invalid_session_tags").tags}async appendSessionTags(e,r){let a=await this.request(this.sessionPath(e,"/tags"),{method:"POST",body:{tags:r}});return h(L,a,"invalid_session_tags").tags}async sessionInsight(e,r=!1){let a=await this.request(this.sessionPath(e,r?"/insights/generate":"/insights"),r?{method:"POST",body:{}}:{});return h($e,a,"invalid_session_insight")}async listAutomations(){let e=[],r=null;for(let a=0;a<20;a+=1){let l=await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/automations?first=100${r?`&after=${encodeURIComponent(r)}`:""}`),c=h(Pe,l,"invalid_automation_list");if(e.push(...c.items),r=c.has_next_page?c.end_cursor??null:null,!r)break}return e}async createScheduledAutomation(e,r){let a=`/organizations/${encodeURIComponent(this.credentials.orgId)}/automations`,l=h(N,await this.request(a,{method:"POST",body:{name:e.name,instructions:e.instructions,...e.repo?{repo:e.repo.full_name,provider:e.repo.provider}:{}}}),"invalid_automation");try{await this.request(`${a}/${encodeURIComponent(l.id)}/triggers`,{method:"POST",body:r})}catch(c){throw await this.deleteAutomation(l.id).catch(()=>{return}),c}return l}async setAutomationEnabled(e,r){await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/automations/${encodeURIComponent(e)}`,{method:"PATCH",body:{enabled:r}})}async deleteAutomation(e){await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/automations/${encodeURIComponent(e)}`,{method:"DELETE"})}async transcribe(e,r){let a=await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/transcribe`,{method:"POST",raw:{bytes:e,contentType:r}});return h(i({transcript:t()}),a,"invalid_transcript").transcript}async listMcpServers(){let e=await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/mcp-servers`);return h(Ce,e,"invalid_mcp_server_list").items}async setSkillEnabled(e,r){await this.request(`/organizations/${encodeURIComponent(this.credentials.orgId)}/skills/${encodeURIComponent(e)}`,{method:"PUT",body:{is_enabled:r}})}}
|
|
5
|
+
export{Tt,I,fs,qo};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{g}from"./vm-hands-entry-lite-aj139v8j.js";import{Wr,qn,Vr,Wn}from"./vm-hands-entry-lite-g4zd2d5n.js";import{Xn,Qt,Oo}from"./vm-hands-entry-lite-hek6nw5m.js";import{C}from"./vm-hands-entry-lite-6c67a3jc.js";import{spawnSync as v}from"child_process";import{createHash as ke,randomUUID as Se}from"crypto";import{chmodSync as we,existsSync as P,mkdirSync as $e,readdirSync as Ve,readFileSync as k,renameSync as ye,rmSync as u,statSync as ve,writeFileSync as be}from"fs";import{dirname as We,isAbsolute as q,join as p}from"path";import{spawnSync as de}from"child_process";import{readFileSync as me}from"fs";import{userInfo as D}from"os";import{join as fe}from"path";var ge="REASON_SCHEDULED_TASK";function H(r){return fe(r,"AppData","Local","Reason","Tasks")}function w(r){if(/[\0-\x1f\x7f"%]/.test(r))throw Error(`A background task cannot use a value with a double quote, percent sign or control character: ${r}`);return`'${r.replace(/['\u2018\u2019\u201a\u201b]/g,"$&$&")}'`}function M(r){if(!/^[A-Za-z0-9._-]+$/.test(r))throw Error(`Invalid Windows Scheduled Task name: ${r}`);return`$env:${ge}=${w(r)};`}function K(r){let e=Object.entries(r.environment).map(([t,i])=>{if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(t))throw Error(`Invalid Windows Scheduled Task environment name: ${t}`);return`$env:${t}=${w(i)};`}),n=`$global:LASTEXITCODE=1; & ${[r.program,...r.args].map(w).join(" ")} 2>&1 | ForEach-Object { Add-Content -LiteralPath ${w(r.log)} -Value $_.ToString() -Encoding UTF8 }; $c=$LASTEXITCODE;`;return[M(r.name),...e,"$ErrorActionPreference='Continue';",r.keepAlive?`do { ${n} if ($c) { Start-Sleep -Seconds 10 } } while ($c)`:`${n} exit $c`].join(" ")}function I(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function pe(){let r=process.env.USERDOMAIN?.trim();return r?`${r}\\${D().username}`:D().username}function U(r){let e=I(r.user??pe()),n=r.schedule==="logon",t=r.schedule==="logon"?`<LogonTrigger><Enabled>true</Enabled><UserId>${e}</UserId></LogonTrigger>`:`<TimeTrigger><Repetition><Interval>PT${r.schedule.everyMinutes}M</Interval><StopAtDurationEnd>false</StopAtDurationEnd></Repetition><StartBoundary>2026-01-01T00:00:00</StartBoundary><Enabled>true</Enabled></TimeTrigger>`,i=`-NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -Command "${r.script}"`;return`<?xml version="1.0" encoding="UTF-16"?>
|
|
3
|
+
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
4
|
+
<RegistrationInfo>
|
|
5
|
+
<Description>${I(r.description)}</Description>
|
|
6
|
+
</RegistrationInfo>
|
|
7
|
+
<Triggers>
|
|
8
|
+
${t}
|
|
9
|
+
</Triggers>
|
|
10
|
+
<Principals>
|
|
11
|
+
<Principal id="Author">
|
|
12
|
+
<UserId>${e}</UserId>
|
|
13
|
+
<LogonType>InteractiveToken</LogonType>
|
|
14
|
+
<RunLevel>LeastPrivilege</RunLevel>
|
|
15
|
+
</Principal>
|
|
16
|
+
</Principals>
|
|
17
|
+
<Settings>
|
|
18
|
+
<MultipleInstancesPolicy>${n?"StopExisting":"IgnoreNew"}</MultipleInstancesPolicy>
|
|
19
|
+
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
|
|
20
|
+
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
|
|
21
|
+
<StartWhenAvailable>true</StartWhenAvailable>
|
|
22
|
+
<IdleSettings>
|
|
23
|
+
<StopOnIdleEnd>false</StopOnIdleEnd>
|
|
24
|
+
<RestartOnIdle>false</RestartOnIdle>
|
|
25
|
+
</IdleSettings>
|
|
26
|
+
<ExecutionTimeLimit>${n?"PT0S":"PT1H"}</ExecutionTimeLimit>
|
|
27
|
+
<Priority>${n?5:7}</Priority>
|
|
28
|
+
</Settings>
|
|
29
|
+
<Actions Context="Author">
|
|
30
|
+
<Exec>
|
|
31
|
+
<Command>%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe</Command>
|
|
32
|
+
<Arguments>${I(i)}</Arguments>
|
|
33
|
+
</Exec>
|
|
34
|
+
</Actions>
|
|
35
|
+
</Task>
|
|
36
|
+
`}function B(r){return Buffer.concat([Buffer.from([255,254]),Buffer.from(r.replaceAll(`\r
|
|
37
|
+
`,`
|
|
38
|
+
`).replaceAll(`
|
|
39
|
+
`,`\r
|
|
40
|
+
`),"utf16le")])}function V(r){let e=me(r);return(e[0]===255&&e[1]===254?e.subarray(2).toString("utf16le"):e.toString("utf8")).replaceAll(`\r
|
|
41
|
+
`,`
|
|
42
|
+
`)}function j(r,e){return["/Create","/TN",r,"/XML",e,"/F"]}function x(r){return["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",Buffer.from(r,"utf16le").toString("base64")]}function E(r){return`'*${M(r).replaceAll("'","''")}*'`}function _(r,e){return x(["$all = @(Get-CimInstance Win32_Process)",`$wrappers = @($all | ? { $_.ProcessId -ne $PID -and $_.CommandLine -like ${E(r)} })`,...e.keepWrapper?[]:["foreach ($w in $wrappers) { Stop-Process -Id $w.ProcessId -Force -ErrorAction SilentlyContinue }"],`foreach ($w in $wrappers) { $all | ? { $_.ParentProcessId -eq $w.ProcessId } | % { taskkill.exe /F ${e.tree?"/T ":""}/PID $_.ProcessId | Out-Null } }`].join(`
|
|
43
|
+
`))}function F(r){return x(["$all = @(Get-CimInstance Win32_Process)",`$wrappers = @($all | ? { $_.ProcessId -ne $PID -and $_.CommandLine -like ${E(r)} })`,"foreach ($w in $wrappers) { if ($all | ? { $_.ParentProcessId -eq $w.ProcessId -and $_.Name -ne 'conhost.exe' }) { 'running'; exit 0 } }","exit 1"].join(`
|
|
44
|
+
`))}function X(r,e=process.pid){let n=de(C("powershell.exe"),x(["$all = @{}; Get-CimInstance Win32_Process | % { $all[[int]$_.ProcessId] = $_ }",`$p = $all[${Math.trunc(e)}]`,"for ($i = 0; $p -and $i -lt 64; $i++) {",` if ($p.CommandLine -like ${E(r)}) { exit 10 }`," $n = $all[[int]$p.ParentProcessId]"," if (-not $n -or $n.ProcessId -eq $p.ProcessId -or $n.CreationDate -gt $p.CreationDate) { exit 11 }"," $p = $n","}","exit 11"].join(`
|
|
45
|
+
`)),{stdio:"ignore",timeout:15000,windowsHide:!0});return n.status===10?!0:n.status===11?!1:null}var zr="REASON_WORKER_SERVICE",Ae="worker_identity_unavailable";function Ee(r){return{platform:process.platform,home:r,uid:process.getuid?.(),command:(e,n)=>v(C(e),[...n],{stdio:"ignore"}).status??1,read:(e,n)=>{let t=v(C(e),[...n],{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4});return t.status===0?t.stdout:null},sleep:(e)=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e),workerIdentity:(e)=>Oo(r,e),insideService:(e,n)=>Ie(e,process.platform,process.getuid?.(),n)}}function Ie(r,e,n,t=!0){if(process.env[zr]===r||process.env.XPC_SERVICE_NAME===r)return!0;if(e==="linux")try{return k("/proc/self/cgroup","utf8").includes(`/${r}.service`)}catch{return!0}if(e==="win32")return X(r)??t;if(e!=="darwin")return!1;if(typeof n!=="number")return!0;let i=v("/bin/launchctl",["print",`gui/${n}/${r}`],{encoding:"utf8",timeout:5000});if(i.status===xe)return!1;if(i.error||i.status!==0)return!0;let s=Number(/^\s*pid = (\d+)$/m.exec(i.stdout??"")?.[1]??0);if(!s)return!1;let a=process.pid;for(let o=0;o<64&&a>1;o+=1){if(a===s)return!0;let l=v("/bin/ps",["-o","ppid=","-p",String(a)],{encoding:"utf8",timeout:5000}),c=Number(l.stdout?.trim());if(l.error||l.status!==0||!Number.isSafeInteger(c)||c<=0)return!0;if(c===a)return!1;a=c}return a>1}var xe=113;class J extends Error{code;constructor(r,e){super(r);this.code=e}}function Hn(r,e){if(!re(r.home,r.platform))throw new J(ee);if(r.platform==="darwin")S(r);let n=Wn(Wr(e,r.home)),t=g({env:e})==="staging",i=t?"ara-staging":"ara",s=[n?qn(n):null,T(e,"REASON_CLI_LAUNCHER_PATH")?.trim(),r.platform==="win32"?p(r.home,"AppData","Local","Reason",...t?["staging"]:[],"bin",t?"reason-staging.exe":"reason.exe"):p(r.home,".local","bin",i)];for(let a of s)try{if(a&&q(a)&&ve(a).isFile())return Vr(a)}catch{}throw new J(`A background service runs the installed Reason launcher, which was not found. Install Reason with: ${r.platform==="win32"?"irm https://reasonmachines.com/install.ps1 | iex":"curl -fsSL https://reasonmachines.com/install | sh"}`,"worker_launcher_missing")}var R=/(<key>ProgramArguments<\/key>\s*<array>\n)((?:\s*<string>[^<]*<\/string>\n)*)(\s*<\/array>)/,y=new RegExp(`(\\n\\s*<key>${Qt}</key>\\s*<string>)[^<]*(</string>)`),_e=/(<key>EnvironmentVariables<\/key>\s*<dict>[\s\S]*?)(\n\s*<\/dict>)/;function Te(r){return r.replaceAll("<","<").replaceAll(">",">").replaceAll(""",'"').replaceAll("'","'").replaceAll("&","&")}function Y(r){let e=[...(R.exec(r)?.[2]??"").matchAll(/<string>([^<]*)<\/string>/g)].map((t)=>Te(t[1])),n=e[1]==="--run-worker"?e.slice(2):e;return n[0]?{launcher:n[0],args:n.slice(1)}:null}function z(r,e,n){let t=n.workerIdentity?.(r)??null;return{program:t?[t.executable,"--run-worker",r,...e]:[r,...e],identity:t}}function h(r){return r.map((e)=>` <string>${d(e)}</string>`).join(`
|
|
46
|
+
`)}function Z(r,e){let n;try{n=k(r,"utf8")}catch{return null}let t=Y(n);if(!t)return null;let i=q(t.launcher)?Vr(t.launcher):t.launcher,{program:s,identity:a}=z(i,t.args,e),o=n.replace(R,(l,c,m,O)=>`${c}${h(s)}
|
|
47
|
+
${O}`);if(!a)o=o.replace(y,"");else if(y.test(o))o=o.replace(y,(l,c,m)=>`${c}${d(a.app)}${m}`);else o=o.replace(_e,(l,c,m)=>`${c}
|
|
48
|
+
<key>${Qt}</key>
|
|
49
|
+
<string>${d(a.app)}</string>${m}`);return o===n?null:o}function Pe(r,e){let n=Z(r,e);if(n!==null)A(r,n)}function $s(r,e,n){if(e.platform!=="darwin")return!1;let t=Xe(r,e,n);return t!==null&&Z(t.definition,e)!==null}var W="com.reasonmachines.worker.",N="so.reason.worker.",Q=[W,N];function ho(r,e=W){return`${e}connect${r==="production"?"":`.${r}`}`}function Bs(r,e){return Q.some((n)=>r===ho(e,n))}function Re(r,e,n){if(e==="connect")return ho(r.channel,n);let t=ke("sha256").update(r.workspaceRoot).digest("hex").slice(0,8);return`${n}${r.name.toLowerCase()}.${t}`}var ee="A background service needs macOS (launchd), Linux (systemd --user) or Windows (Task Scheduler).";function re(r,e){if(e==="darwin")return{directory:p(r,"Library","LaunchAgents"),suffix:".plist"};if(e==="linux")return{directory:p(r,".config","systemd","user"),suffix:".service"};if(e==="win32")return{directory:H(r),suffix:".xml"};return null}function f(r,e,n,t=W){let i=Re(r,n,t),s=re(e.home,e.platform);if(!s)return null;return{label:i,definition:p(s.directory,`${i}${s.suffix}`),logs:e.platform==="linux"?`journalctl --user -u ${i}.service`:p(r.stateDirectory,"service.log")}}function Xe(r,e,n="serve"){return ne(r,e,n)[0]??null}function ne(r,e,n){return Q.map((t)=>f(r,e,n,t)).filter((t)=>t!==null&&P(t.definition))}function te(r,e,n){let t=f(r,e,n,N);return t&&P(t.definition)?t:null}function Yo(r,e,n){let t=f(r,e,n),i=te(r,e,n);if(!t||!i||!P(t.definition)||e.insideService?.(i.label))return null;if(!Ce(t,e))return"current_not_running";if(e.platform==="darwin"){if(typeof e.uid==="number"&&e.uid>0)e.command("/bin/launchctl",["bootout",`gui/${e.uid}/${i.label}`]);return u(i.definition,{force:!0}),"retired"}if(e.platform==="win32")return b(i,e,!0),"retired";return e.command("systemctl",["--user","disable","--now",`${i.label}.service`]),u(i.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"]),"retired"}function Ce(r,e){if(e.platform==="darwin")return typeof e.uid==="number"&&e.uid>0&&e.command("/bin/launchctl",["print",`gui/${e.uid}/${r.label}`])===0;if(e.platform==="win32")return e.command("schtasks",["/Query","/TN",r.label])===0;let n=`${r.label}.service`;return e.command("systemctl",["--user","is-enabled","--quiet",n])===0&&he.has(e.read("systemctl",["--user","show","--property=ActiveState","--value",n])?.trim()??"")}var he=new Set(["active","activating","reloading"]);function zn(r,e){if(e.platform==="darwin"){if(typeof e.uid!=="number"||e.uid<=0)return!1;let n=e.read("/bin/launchctl",["print",`gui/${e.uid}/${r.label}`]);return Number(/^\s*pid = (\d+)$/m.exec(n??"")?.[1]??0)>0}if(e.platform==="win32")return e.read("powershell.exe",F(r.label))?.trim()==="running";return Number(e.read("systemctl",["--user","show","--property=MainPID","--value",`${r.label}.service`])?.trim()??0)>0}function Fs(r){let{config:e,launcher:n,host:t,kind:i}=r,s=f(e,t,i);if(!s)return!1;let a;try{a=t.platform==="win32"?V(s.definition):k(s.definition,"utf8")}catch{return!1}if(t.platform==="win32")return a===se(e,i,s,n);if(t.platform!=="darwin")return a===oe(e,i,s,n,t.home,r.path);let o=Y(a);return a.replace(y,"").replace(R,(c,m,O,ue)=>`${m}${o?`${h([o.launcher,...o.args])}
|
|
50
|
+
`:""}${ue}`)===ie(e,i,s,n,{...t,workerIdentity:()=>null},r.path).plist}function L(r,e){if(e==="connect")return{args:["connect"],environment:{REASON_CLI_CHANNEL:r.channel},description:"Reason connection of this computer"};return{args:["serve",r.name,"--dir",r.workspaceRoot,...r.executionMode==="confined"?["--sandbox"]:[]],environment:{},description:`Reason machine ${r.name} worker`}}function d(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function G(r,e=!1){if(/[\0-\x1f\x7f]/.test(r))throw new J("A background service cannot use a path with control characters.");let n=r.replaceAll("\\","\\\\").replaceAll('"',"\\\"").replaceAll("%","%%");return`"${e?n.replaceAll("$","$$$$"):n}"`}function ie(r,e,n,t,i,s){let a=L(r,e),o=z(t,a.args,i),l={HOME:i.home,PATH:s,[zr]:n.label,...a.environment,...o.identity?{[Qt]:o.identity.app}:{}};return{identity:o.identity,plist:`<?xml version="1.0" encoding="UTF-8"?>
|
|
51
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
52
|
+
<plist version="1.0">
|
|
53
|
+
<dict>
|
|
54
|
+
<key>Label</key>
|
|
55
|
+
<string>${d(n.label)}</string>
|
|
56
|
+
<key>AssociatedBundleIdentifiers</key>
|
|
57
|
+
<array>
|
|
58
|
+
<string>${Xn}</string>
|
|
59
|
+
</array>
|
|
60
|
+
<key>ProgramArguments</key>
|
|
61
|
+
<array>
|
|
62
|
+
${h(o.program)}
|
|
63
|
+
</array>
|
|
64
|
+
<key>EnvironmentVariables</key>
|
|
65
|
+
<dict>
|
|
66
|
+
${Object.entries(l).map(([c,m])=>` <key>${c}</key>
|
|
67
|
+
<string>${d(m)}</string>`).join(`
|
|
68
|
+
`)}
|
|
69
|
+
</dict>
|
|
70
|
+
<key>RunAtLoad</key>
|
|
71
|
+
<true/>
|
|
72
|
+
<key>KeepAlive</key>
|
|
73
|
+
<dict>
|
|
74
|
+
<key>SuccessfulExit</key>
|
|
75
|
+
<false/>
|
|
76
|
+
</dict>
|
|
77
|
+
<key>ThrottleInterval</key>
|
|
78
|
+
<integer>10</integer>
|
|
79
|
+
<key>ExitTimeOut</key>
|
|
80
|
+
<integer>${Math.ceil(r.shutdownGraceMs/1000)+10}</integer>
|
|
81
|
+
<key>ProcessType</key>
|
|
82
|
+
<string>Standard</string>
|
|
83
|
+
<key>Umask</key>
|
|
84
|
+
<integer>63</integer>
|
|
85
|
+
<key>StandardOutPath</key>
|
|
86
|
+
<string>${d(n.logs)}</string>
|
|
87
|
+
<key>StandardErrorPath</key>
|
|
88
|
+
<string>${d(n.logs)}</string>
|
|
89
|
+
</dict>
|
|
90
|
+
</plist>
|
|
91
|
+
`}}function oe(r,e,n,t,i,s){let a=L(r,e);return`[Unit]
|
|
92
|
+
Description=${a.description}
|
|
93
|
+
|
|
94
|
+
[Service]
|
|
95
|
+
ExecStart=${[t,...a.args].map((o)=>G(o,!0)).join(" ")}
|
|
96
|
+
Environment=${[`HOME=${i}`,`PATH=${s}`,`${zr}=${n.label}`,...Object.entries(a.environment).map(([o,l])=>`${o}=${l}`)].map((o)=>G(o)).join(" ")}
|
|
97
|
+
Restart=on-failure
|
|
98
|
+
RestartSec=10
|
|
99
|
+
TimeoutStopSec=${Math.ceil(r.shutdownGraceMs/1000)+10}
|
|
100
|
+
UMask=0077
|
|
101
|
+
|
|
102
|
+
[Install]
|
|
103
|
+
WantedBy=default.target
|
|
104
|
+
`}function se(r,e,n,t){let i=L(r,e);return U({description:i.description,schedule:"logon",script:K({name:n.label,program:t,args:i.args,environment:{[zr]:n.label,...i.environment},log:n.logs,keepAlive:!0})})}function ae(r,e,n){e.command("powershell.exe",_(r.label,{tree:n,keepWrapper:!n}))}function b(r,e,n){e.command("schtasks",["/Delete","/F","/TN",r.label]),e.command("powershell.exe",_(r.label,{tree:n,keepWrapper:!1})),u(r.definition,{force:!0})}function A(r,e){$e(We(r),{recursive:!0,mode:448});let n=`${r}.${Se()}.tmp`;try{be(n,e,{mode:384,flag:"wx"}),we(n,384),ye(n,r)}finally{u(n,{force:!0})}}function S(r){if(typeof r.uid!=="number"||!Number.isSafeInteger(r.uid)||r.uid<=0)throw new J("Set up a background service as your own user, not with sudo.","worker_service_root_user");return`gui/${r.uid}`}function js(r){let{config:e,launcher:n,host:t}=r,i=r.kind??"serve",s=te(e,t,i),a=s!==null&&t.insideService?.(s.label)===!0,o=f(e,t,i,a?N:W);if(!o)throw new J(ee);if(t.platform==="darwin")S(t);if(t.platform==="linux"&&t.command("systemctl",["--user","show-environment"])!==0)throw new J("No background service here: this computer has no systemd user session.","worker_service_manager_missing");let l=t.platform==="darwin"?ie(e,i,o,n,t,r.path):null;if(A(o.definition,l?l.plist:t.platform==="win32"?B(se(e,i,o,n)):oe(e,i,o,n,t.home,r.path)),le(e,t,o,a?null:s),l)return l.identity?o:{...o,identityProblem:Ae};if(t.platform==="win32")return o;return{...o,lingering:t.command("loginctl",["enable-linger"])===0}}function le(r,e,n,t){if(e.platform==="darwin"){let a=S(e);if(t)e.command("/bin/launchctl",["bootout",`${a}/${t.label}`]);if(ce(r,n,e)){if(t)u(t.definition,{force:!0});return}if(u(n.definition,{force:!0}),t)e.command("/bin/launchctl",["bootstrap",a,t.definition]);throw new J("Could not start the background service (launchctl bootstrap failed).","worker_service_start_failed")}if(e.platform==="win32"){if(t)b(t,e,!0);if(e.command("schtasks",j(n.label,n.definition))===0){if(ae(n,e,e.insideService?.(n.label)!==!0),e.command("schtasks",["/Run","/TN",n.label])===0)return}throw b(n,e,!0),new J("Could not start the background service (schtasks failed).")}let i=`${n.label}.service`,s=t?`${t.label}.service`:null;if(e.command("systemctl",["--user","daemon-reload"])!==0||s!==null&&e.command("systemctl",["--user","disable","--now",s])!==0||e.command("systemctl",["--user","enable",i])!==0||e.command("systemctl",["--user","restart",i])!==0){if(e.command("systemctl",["--user","disable",i]),u(n.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"]),s)e.command("systemctl",["--user","enable","--now",s]);throw new J("Could not start the background service (systemctl --user failed).","worker_service_start_failed")}if(t)u(t.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"])}function ce(r,e,n){let t=S(n);n.command("/bin/launchctl",["bootout",`${t}/${e.label}`]);let i=(Math.ceil(r.shutdownGraceMs/1000)+10)*1000;for(let s=0,a=100;;a=Math.min(a*2,2000)){if(n.command("/bin/launchctl",["bootstrap",t,e.definition])===0)return!0;if(s>=i)return!1;n.sleep(a),s+=a}}function qr(r,e,n){let t=Xe(r,e,n);if(!t)return null;let i=e.insideService?.(t.label)===!0;if(e.platform==="darwin"&&!i)Pe(t.definition,e);let s=f(r,e,n);if(s&&t.label!==s.label&&!i)return A(s.definition,k(t.definition,"utf8").replaceAll(t.label,s.label)),le(r,e,s,t),s;let a=e.platform==="darwin"&&i,o;if(e.platform==="win32")ae(t,e,!i),o=e.command("schtasks",["/Run","/TN",t.label])===0;else if(a)o=e.command("/bin/launchctl",["kickstart","-k",`${S(e)}/${t.label}`])===0;else if(e.platform==="darwin")o=ce(r,t,e);else e.command("systemctl",["--user","enable",`${t.label}.service`]),o=e.command("systemctl",["--user","restart",`${t.label}.service`])===0;if(!o)throw new J(`Could not restart the background service ${t.label}.`,"worker_service_restart_failed");if(s&&t.label===s.label)Yo(r,e,n);return t}function Us(r,e,n,t){let i=Xe(r,n,t),s=f(e,n,t);if(n.platform!=="darwin"||!i||!s)return;let a=`<string>${d(i.logs)}</string>`,o=k(i.definition,"utf8");if(o.includes(a))A(i.definition,o.replaceAll(a,`<string>${d(s.logs)}</string>`))}function Hs(r,e,n="serve"){let t=ne(r,e,n);for(let i of t){if(e.platform==="win32"){b(i,e,e.insideService?.(i.label,!1)!==!0);continue}if(e.platform==="darwin"){if(typeof e.uid==="number"&&e.uid>0)e.command("/bin/launchctl",["bootout",`gui/${e.uid}/${i.label}`]);u(i.definition,{force:!0});continue}e.command("systemctl",["--user","disable","--now",`${i.label}.service`]),u(i.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"])}return t[0]??null}
|
|
105
|
+
export{zr,Ee,J,Hn,$s,ho,Bs,Xe,Yo,zn,Fs,js,qr,Us,Hs};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{basename as ln}from"path";var pt=["production","staging"],un="https://api.reasonmachines.com",fn="https://staging-api.reasonmachines.com";var A={production:{api:"https://api.reasonmachines.ai",app:"https://reasonmachines.ai"},staging:{api:"https://staging-api.reasonmachines.ai",app:"https://staging.reasonmachines.ai"}},gn=new Set(["ara-staging","ara-staging.exe","reason-staging","reason-staging.exe"]);function g(n={}){let e=T(n.env??process.env,"REASON_CLI_CHANNEL")?.trim().toLowerCase();if(e){if(pt.includes(e))return e;throw Error(`Unknown Reason CLI channel: ${e}`)}let r=ln(n.executablePath??process.execPath).toLowerCase();return gn.has(r)?"staging":"production"}function Kt(n){return n==="staging"?fn:un}var U={production:["https://api.ara.so",A.production.api],staging:["https://api-staging.ara.so",A.staging.api]};function Gr(n){let e;try{e=new URL(n).origin}catch{return n}let r=pt.find((t)=>U[t].includes(e));return r?Kt(r):e}function mo(n,e){return n===e||Gr(n)===Gr(e)}function go(n,e){return pt.some((r)=>U[r].includes(n)&&e===Kt(r))}function _o(n,e){try{let r=new URL(e);return!r.username&&!r.password&&(r.origin===Kt(n)||r.origin===A[n].api)}catch{return!1}}function Vn(n){try{let e=new URL(n).hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="localhost"||e==="127.0.0.1"||e==="::1"}catch{return!1}}import{randomBytes as J}from"crypto";import{chmodSync as q,closeSync as B,constants as bn,linkSync as V,lstatSync as w,mkdirSync as z,openSync as En,readdirSync as L,readFileSync as Wn,readlinkSync as _,renameSync as k,rmdirSync as Q,symlinkSync as S,unlinkSync as y}from"fs";import{createRequire as Nn}from"module";import{constants as Sn}from"os";import{basename as R,join as l,sep as kn}from"path";import{existsSync as O,lstatSync as j,readdirSync as pn,readFileSync as mn,readlinkSync as dn,realpathSync as yn}from"fs";import{join as d,sep as hn}from"path";function G(n,...e){let r=d(n,"ara"),t=d(n,"reason");if(!Kr(r))return d(t,...e);if(!O(t))return d(r,...e);return O(d(r,...e))&&!O(d(t,...e))?d(r,...e):d(t,...e)}function Kr(n){try{let e=j(n);if(!e.isSymbolicLink())return e.isDirectory();return dn(n)!=="reason"&&O(n)}catch{return!1}}function X(n,e=[]){if(!Kr(n))return!1;let r;try{r=[n,...pn(n,{withFileTypes:!0}).filter((t)=>t.isDirectory()).map((t)=>d(n,t.name))]}catch{return!1}return r.some((t)=>["connect","connect-once"].filter((i)=>!e.includes(d(t,i))).some((i)=>{let s=d(t,i,"worker.json");try{j(s)}catch{return!1}try{let a=JSON.parse(mn(s,"utf8"))?.stateDirectory;if(typeof a!=="string")return!0;let c=(o,u)=>o===u||o.startsWith(u+hn);return c(a,n)||c(M(a),M(n))}catch{return!0}}))}function M(n){try{return yn(n)}catch{return n}}var P=new Set(["credentials.json","local-device.json","local-device.revoked.json","local-device.auth-migration.json","local-device.json.registration-pending.json","local-daemon.json","local-daemon.json.workspaces.json","local-root-fingerprint-key.json","instances","workspaces"]),Z=new Set(["local-device.proxy.json"]),Cn=new Set(["local-device.key","local-device.binding"]),W=new Map;function ht(n,e,r){let t=l(n,"ara");if(process.platform==="win32"||/[/\\]\.reason-ssh[/\\][^/\\]+[/\\]installer-home[/\\]\.config$/.test(n))return{state:m(t)?.isDirectory()?"kept":"absent"};return vn(t,l(n,"reason"),{linkAlways:!0,kept:(i)=>X(i,r??[]),native:e===void 0?An:()=>e},r!==void 0)}function xe(n,...e){return ht(n),G(n,...e)}var nn="config_rename_unavailable:busy";function vn(n,e,r,t=!1){let i=t?void 0:W.get(n);if(i)return i;let s;try{s=_n(n,e,r)}catch(a){let c=`config_rename_unavailable:${E(a)??"failed"}`;try{return{state:m(n)?.isDirectory()?"kept":"absent",problem:c}}catch{return{state:"kept",problem:c}}}if(!(s.state==="absent"&&r.linkAlways)&&s.problem!==nn&&!(s.state==="kept"&&!s.problem))W.set(n,s);return s}function _n(n,e,r){wn(e,r.native);let t=!1;for(let i=0;i<8;i+=1){let s=m(n);if(s?.isSymbolicLink())return _(n)===R(e)?{state:t?"renamed":"linked"}:{state:"kept"};if(!s){if(D(e))f(()=>y(e),"ENOENT");if(!(t||r.linkAlways)||!x(e))return{state:"absent"};let o=v(e,"link");S(R(e),o);try{f(()=>k(o,n),"EISDIR","ENOTEMPTY","EEXIST","ENOTDIR")}finally{f(()=>y(o),"ENOENT")}continue}if(!s.isDirectory())return{state:"absent"};if(r.kept(n))return K(e),{state:"kept"};let a=r.native();if(!a)return K(e),{state:"kept",problem:"config_rename_unavailable:no_native"};let c=In(a,n);if(!c)return{state:"kept",problem:nn};try{if(w(n).isSymbolicLink())continue;let o=Rn(a,n,e);if(o)return{state:"kept",problem:o};t=!0}finally{c()}}throw Object.assign(Error("legacy directory rename did not settle"),{code:"unsettled"})}function Rn(n,e,r){let t=m(r);if(!t||D(r)){if(!t)S(R(r),r);try{n.exchange(e,r)}catch(o){if(D(r))f(()=>y(r),"ENOENT");return`config_rename_unavailable:${E(o)??"exchange_failed"}`}return null}if(!t.isDirectory())return"config_rename_unavailable:ENOTDIR";if(t.dev!==w(e).dev)return"config_rename_unavailable:EXDEV";let i=[v(r,"probe"),v(r,"probe")];try{S("a",i[0]),S("b",i[1]),n.exchange(i[0],i[1])}catch(o){return`config_rename_unavailable:${E(o)??"exchange_failed"}`}finally{for(let o of i)f(()=>y(o),"ENOENT")}let s=cn(r);for(let o of Cn){let u=m(l(r,o)),p=m(l(e,o));if(u&&p&&u.ino!==p.ino)z(`${s}-replaced`,{mode:448,recursive:!0}),k(l(r,o),l(`${s}-replaced`,o))}let a={linked:new Map,unitsKept:new Set};rn(e,r,"",a);let c=v(r,"rename");S(R(r),c);try{n.exchange(e,c)}catch(o){return f(()=>y(c),"ENOENT"),`config_rename_unavailable:${E(o)??"exchange_failed"}`}return tn(c,r,a,s),null}function en(n){return n===""||!n.includes(kn)}function rn(n,e,r,t){let i=en(r)&&sn(l(e,r),l(n,r));if(i)t.unitsKept.add(r);for(let s of L(l(n,r))){if(i&&(P.has(s)||Z.has(s)))continue;let a=l(r,s),c=l(n,a),o=l(e,a),u=m(c);if(!u)continue;let p=m(o);if(u.isDirectory()){if(!p)f(()=>z(o,{mode:u.mode&4095}),"EEXIST"),q(o,u.mode&4095);if(x(o))rn(n,e,a,t)}else if(!p){if(u.isSymbolicLink())f(()=>S(_(c),o),"EEXIST");else if(f(()=>V(c,o),"EEXIST","ENOENT"))t.linked.set(a,u.ino)}}}function wn(n,e){let r;try{if(!x(n))return;r=L(n)}catch{return}for(let t of r){let i=/^\.(rename|link|probe|claim)-(\d+)-[0-9a-f]+$/.exec(t);if(!i)continue;let s=l(n,t),a=m(s);if(!a)continue;if(!a.isDirectory()){if(!Y(Number(i[2])))f(()=>y(s),"ENOENT");continue}let c=e(),o=null;if(c){try{o=c.lock(s)}catch{continue}if(!o)continue}else if(Y(Number(i[2])))continue;try{let u=v(n,"claim");if(f(()=>k(s,u),"ENOENT"))tn(u,n,null,cn(n))}finally{o?.()}}}function tn(n,e,r,t){for(let[i,s]of r?.linked??[])if(!m(l(n,i))&&m(l(e,i))?.ino===s)f(()=>y(l(e,i)),"ENOENT");if(on(n,e,"",r),f(()=>Q(n),"ENOTEMPTY","EEXIST"))return;k(n,t),q(t,448)}function on(n,e,r,t){let i=en(r)&&(t?t.unitsKept.has(r):sn(l(e,r),l(n,r)));for(let s of L(l(n,r))){let a=l(r,s),c=l(n,a),o=l(e,a),u=w(c),p=m(o);if(p&&u.ino===p.ino&&u.dev===p.dev){y(c);continue}if(u.isFile()&&p?.isFile()&&t?.linked.get(a)===p.ino){k(c,o);continue}if(i&&(P.has(s)||Z.has(s)))continue;if(!p){if(u.isFile()){if(f(()=>V(c,o),"EEXIST"))y(c)}else f(()=>k(c,o),"EEXIST","ENOTEMPTY");continue}if(u.isDirectory()&&p.isDirectory())on(n,e,a,t),f(()=>Q(c),"ENOTEMPTY","EEXIST")}}function sn(n,e){for(let r of P)if(an(l(n,r),l(e,r)))return!0;return!1}function an(n,e){let r=m(n);if(!r)return!1;let t=m(e);if(!t)return!0;if(r.isDirectory()){if(!t.isDirectory())return!0;return L(n).some((i)=>an(l(n,i),l(e,i)))}if(r.isSymbolicLink())return!t.isSymbolicLink()||_(n)!==_(e);return r.ino!==t.ino||r.dev!==t.dev}function K(n){if(D(n))f(()=>y(n),"ENOENT")}function cn(n){return l(n,`.pre-rename-${new Date().toISOString().replace(/[:.]/g,"-")}-${J(3).toString("hex")}`)}function D(n){try{return w(n).isSymbolicLink()&&_(n)===R(n)}catch{return!1}}function x(n){let e=m(n);return e!==null&&e.isDirectory()}function In(n,e){for(let r=0;r<40;r+=1){let t=n.lock(e);if(t)return t;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,50)}return null}function v(n,e){return l(n,`.${e}-${process.pid}-${J(6).toString("hex")}`)}function Y(n){if(n===process.pid)return!1;try{return process.kill(n,0),!0}catch(e){return E(e)==="EPERM"}}function m(n){try{return w(n)}catch(e){if(E(e)==="ENOENT"||E(e)==="ENOTDIR")return null;throw e}}function f(n,...e){try{return n(),!0}catch(r){if(e.includes(E(r)??""))return!1;throw r}}function E(n){return n instanceof Error&&"code"in n&&typeof n.code==="string"?n.code:void 0}var C,On=2,Dn=4,Ln=2,Tn=2,H=-100;function An(){if(C!==void 0)return C;if(C=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let n;try{n=Nn(import.meta.url)("bun:ffi")}catch{return null}let e=process.platform==="darwin",r=e?"__error":"__errno_location",t=e?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`],{FFIType:i}=n;for(let s of t)try{let a=e?"renamex_np":"renameat2",o=n.dlopen(s,{flock:{args:[i.i32,i.i32],returns:i.i32},[r]:{args:[],returns:i.ptr},[a]:e?{args:[i.ptr,i.ptr,i.u32],returns:i.i32}:{args:[i.i32,i.ptr,i.i32,i.ptr,i.u32],returns:i.i32}}).symbols,u=o[r]();if(u===null)continue;let p=(N)=>{let b=n.read.i32(u),h=Object.entries(Sn.errno).find(([,I])=>I===b)?.[0]??`errno_${b}`;return Object.assign(Error(`${N} failed: ${h}`),{code:h})},F=(N)=>Buffer.from(`${N}\x00`,"utf8");return C={exchange(N,b){let h=F(N),I=F(b);if((e?o[a](n.ptr(h),n.ptr(I),Ln):o[a](H,n.ptr(h),H,n.ptr(I),Tn))!==0)throw p("exchange")},lock(N){let b=En(N,bn.O_RDONLY);if(o.flock(b,On|Dn)===0)return()=>B(b);let h=p("lock");if(B(b),h.code==="EWOULDBLOCK"||h.code==="EAGAIN")return null;throw h}},C}catch{}return null}
|
|
3
|
+
export{pt,g,Kt,Gr,mo,go,_o,Vn,Kr,ht,xe};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{os}from"./vm-hands-entry-lite-hbs3tpdg.js";var Xr,$o=Object.freeze({status:"aborted"});function z(e,r,a){function p(h,g){if(!h._zod)Object.defineProperty(h,"_zod",{value:{def:g,constr:m,traits:new Set},enumerable:!1});if(h._zod.traits.has(e))return;h._zod.traits.add(e),r(h,g);let x=m.prototype,v=Object.keys(x);for(let w=0;w<v.length;w++){let P=v[w];if(!(P in h))h[P]=x[P].bind(h)}}let l=a?.Parent??Object;class f extends l{}Object.defineProperty(f,"name",{value:e});function m(h){var g;let x=a?.Parent?new f:this;p(x,h),(g=x._zod).deferred??(g.deferred=[]);for(let v of x._zod.deferred)v();return x}return Object.defineProperty(m,"init",{value:p}),Object.defineProperty(m,Symbol.hasInstance,{value:(h)=>{if(a?.Parent&&h instanceof a.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(m,"name",{value:e}),m}var gc=Symbol("zod_brand");class V extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ue extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Xr=globalThis).__zod_globalConfig??(Xr.__zod_globalConfig={});var ne=globalThis.__zod_globalConfig;function L(e){if(e)Object.assign(ne,e);return ne}function be(e){let r=Object.values(e).filter((p)=>typeof p==="number");return Object.entries(e).filter(([p,l])=>r.indexOf(+p)===-1).map(([p,l])=>l)}function Pi(e,r="|"){return e.map((a)=>Ti(a)).join(r)}function ae(e,r){if(typeof r==="bigint")return r.toString();return r}function pe(e){return{get value(){{let a=e();return Object.defineProperty(this,"value",{value:a}),a}throw Error("cached value already set")}}}function we(e){return e===null||e===void 0}function ke(e){let r=e.startsWith("^")?1:0,a=e.endsWith("$")?e.length-1:e.length;return e.slice(r,a)}function Qr(e,r){let a=e/r,p=Math.round(a),l=Number.EPSILON*Math.max(Math.abs(a),1);if(Math.abs(a-p)<l)return 0;return a-p}var Hr=Symbol("evaluating");function S(e,r,a){let p=void 0;Object.defineProperty(e,r,{get(){if(p===Hr)return;if(p===void 0)p=Hr,p=a();return p},set(l){Object.defineProperty(e,r,{value:l})},configurable:!0})}function H(e,r,a){Object.defineProperty(e,r,{value:a,writable:!0,enumerable:!0,configurable:!0})}function K(...e){let r={};for(let a of e){let p=Object.getOwnPropertyDescriptors(a);Object.assign(r,p)}return Object.defineProperties({},r)}function Ve(e){return JSON.stringify(e)}function et(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var We="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function se(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var rt=pe(()=>{if(ne.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Q(e){if(se(e)===!1)return!1;let r=e.constructor;if(r===void 0)return!0;if(typeof r!=="function")return!0;let a=r.prototype;if(se(a)===!1)return!1;if(Object.prototype.hasOwnProperty.call(a,"isPrototypeOf")===!1)return!1;return!0}function Ke(e){if(Q(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var tt=new Set(["string","number","symbol"]);function G(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function M(e,r,a){let p=new e._zod.constr(r??e._zod.def);if(!r||a?.parent)p._zod.parent=e;return p}function b(e){let r=e;if(!r)return{};if(typeof r==="string")return{error:()=>r};if(r?.message!==void 0){if(r?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");r.error=r.message}if(delete r.message,typeof r.error==="string")return{...r,error:()=>r.error};return r}function Ti(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function ot(e){return Object.keys(e).filter((r)=>e[r]._zod.optin==="optional"&&e[r]._zod.optout==="optional")}var nt={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Qs(e,r){let a=e._zod.def,p=a.checks;if(p&&p.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let f=K(e._zod.def,{get shape(){let m={};for(let h in r){if(!(h in a.shape))throw Error(`Unrecognized key: "${h}"`);if(!r[h])continue;m[h]=a.shape[h]}return H(this,"shape",m),m},checks:[]});return M(e,f)}function ei(e,r){let a=e._zod.def,p=a.checks;if(p&&p.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let f=K(e._zod.def,{get shape(){let m={...e._zod.def.shape};for(let h in r){if(!(h in a.shape))throw Error(`Unrecognized key: "${h}"`);if(!r[h])continue;delete m[h]}return H(this,"shape",m),m},checks:[]});return M(e,f)}function ri(e,r){if(!Q(r))throw Error("Invalid input to extend: expected a plain object");let a=e._zod.def.checks;if(a&&a.length>0){let f=e._zod.def.shape;for(let m in r)if(Object.getOwnPropertyDescriptor(f,m)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let l=K(e._zod.def,{get shape(){let f={...e._zod.def.shape,...r};return H(this,"shape",f),f}});return M(e,l)}function ti(e,r){if(!Q(r))throw Error("Invalid input to safeExtend: expected a plain object");let a=K(e._zod.def,{get shape(){let p={...e._zod.def.shape,...r};return H(this,"shape",p),p}});return M(e,a)}function oi(e,r){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let a=K(e._zod.def,{get shape(){let p={...e._zod.def.shape,...r._zod.def.shape};return H(this,"shape",p),p},get catchall(){return r._zod.def.catchall},checks:r._zod.def.checks??[]});return M(e,a)}function ni(e,r,a){let l=r._zod.def.checks;if(l&&l.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let m=K(r._zod.def,{get shape(){let h=r._zod.def.shape,g={...h};if(a)for(let x in a){if(!(x in h))throw Error(`Unrecognized key: "${x}"`);if(!a[x])continue;g[x]=e?new e({type:"optional",innerType:h[x]}):h[x]}else for(let x in h)g[x]=e?new e({type:"optional",innerType:h[x]}):h[x];return H(this,"shape",g),g},checks:[]});return M(r,m)}function si(e,r,a){let p=K(r._zod.def,{get shape(){let l=r._zod.def.shape,f={...l};if(a)for(let m in a){if(!(m in f))throw Error(`Unrecognized key: "${m}"`);if(!a[m])continue;f[m]=new e({type:"nonoptional",innerType:l[m]})}else for(let m in l)f[m]=new e({type:"nonoptional",innerType:l[m]});return H(this,"shape",f),f}});return M(r,p)}function re(e,r=0){if(e.aborted===!0)return!0;for(let a=r;a<e.issues.length;a++)if(e.issues[a]?.continue!==!0)return!0;return!1}function st(e,r=0){if(e.aborted===!0)return!0;for(let a=r;a<e.issues.length;a++)if(e.issues[a]?.continue===!1)return!0;return!1}function q(e,r){return r.map((a)=>{var p;return(p=a).path??(p.path=[]),a.path.unshift(e),a})}function $e(e){return typeof e==="string"?e:e?.message}function J(e,r,a){let p=e.message?e.message:$e(e.inst?._zod.def?.error?.(e))??$e(r?.error?.(e))??$e(a.customError?.(e))??$e(a.localeError?.(e))??"Invalid input",{inst:l,continue:f,input:m,...h}=e;if(h.path??(h.path=[]),h.message=p,r?.reportInput)h.input=m;return h}function Ze(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Bo(e){let r=typeof e;switch(r){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let a=e;if(a&&Object.getPrototypeOf(a)!==Object.prototype&&"constructor"in a&&a.constructor)return a.constructor.name}}return r}function te(...e){let[r,a,p]=e;if(typeof r==="string")return{message:r,code:"custom",input:a,inst:p};return{...r}}var it=(e,r)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:r,enumerable:!1}),e.message=JSON.stringify(r,ae,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Pe=z("$ZodError",it),Ge=z("$ZodError",it,{Parent:Error});function ct(e,r=(a)=>a.message){let a={},p=[];for(let l of e.issues)if(l.path.length>0)a[l.path[0]]=a[l.path[0]]||[],a[l.path[0]].push(r(l));else p.push(r(l));return{formErrors:p,fieldErrors:a}}function ut(e,r=(a)=>a.message){let a={_errors:[]},p=(l,f=[])=>{for(let m of l.issues)if(m.code==="invalid_union"&&m.errors.length)m.errors.map((h)=>p({issues:h},[...f,...m.path]));else if(m.code==="invalid_key")p({issues:m.issues},[...f,...m.path]);else if(m.code==="invalid_element")p({issues:m.issues},[...f,...m.path]);else{let h=[...f,...m.path];if(h.length===0)a._errors.push(r(m));else{let g=a,x=0;while(x<h.length){let v=h[x];if(x!==h.length-1)g[v]=g[v]||{_errors:[]};else g[v]=g[v]||{_errors:[]},g[v]._errors.push(r(m));g=g[v],x++}}}};return p(e),a}var Se=(e)=>(r,a,p,l)=>{let f=p?{...p,async:!1}:{async:!1},m=r._zod.run({value:a,issues:[]},f);if(m instanceof Promise)throw new V;if(m.issues.length){let h=new(l?.Err??e)(m.issues.map((g)=>J(g,f,L())));throw We(h,l?.callee),h}return m.value};var Oe=(e)=>async(r,a,p,l)=>{let f=p?{...p,async:!0}:{async:!0},m=r._zod.run({value:a,issues:[]},f);if(m instanceof Promise)m=await m;if(m.issues.length){let h=new(l?.Err??e)(m.issues.map((g)=>J(g,f,L())));throw We(h,l?.callee),h}return m.value};var le=(e)=>(r,a,p)=>{let l=p?{...p,async:!1}:{async:!1},f=r._zod.run({value:a,issues:[]},l);if(f instanceof Promise)throw new V;return f.issues.length?{success:!1,error:new(e??Pe)(f.issues.map((m)=>J(m,l,L())))}:{success:!0,data:f.value}},at=le(Ge),fe=(e)=>async(r,a,p)=>{let l=p?{...p,async:!0}:{async:!0},f=r._zod.run({value:a,issues:[]},l);if(f instanceof Promise)f=await f;return f.issues.length?{success:!1,error:new e(f.issues.map((m)=>J(m,l,L())))}:{success:!0,data:f.value}},pt=fe(Ge),lt=(e)=>(r,a,p)=>{let l=p?{...p,direction:"backward"}:{direction:"backward"};return Se(e)(r,a,l)};var ft=(e)=>(r,a,p)=>Se(e)(r,a,p);var dt=(e)=>async(r,a,p)=>{let l=p?{...p,direction:"backward"}:{direction:"backward"};return Oe(e)(r,a,l)};var mt=(e)=>async(r,a,p)=>Oe(e)(r,a,p);var ht=(e)=>(r,a,p)=>{let l=p?{...p,direction:"backward"}:{direction:"backward"};return le(e)(r,a,l)};var _t=(e)=>(r,a,p)=>le(e)(r,a,p);var gt=(e)=>async(r,a,p)=>{let l=p?{...p,direction:"backward"}:{direction:"backward"};return fe(e)(r,a,l)};var zt=(e)=>async(r,a,p)=>fe(e)(r,a,p);var vt=/^[cC][0-9a-z]{6,}$/,yt=/^[0-9a-z]+$/,$t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,bt=/^[0-9a-vA-V]{20}$/,wt=/^[A-Za-z0-9]{27}$/,kt=/^[a-zA-Z0-9_-]{21}$/,Zt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Pt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,qe=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var St=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var ci="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ot(){return new RegExp(ci,"u")}var It=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Tt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Nt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,At=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ye=/^[A-Za-z0-9_-]*$/;var Ct=/^https?$/,Rt=/^\+[1-9]\d{6,14}$/,Dt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Lt=new RegExp(`^${Dt}$`);function Ft(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Ut(e){return new RegExp(`^${Ft(e)}$`)}function Mt(e){let r=Ft({precision:e.precision}),a=["Z"];if(e.local)a.push("");if(e.offset)a.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let p=`${r}(?:${a.join("|")})`;return new RegExp(`^${Dt}T(?:${p})$`)}var Jt=(e)=>{let r=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${r}$`)};var Bt=/^-?\d+$/,Xe=/^-?\d+(?:\.\d+)?$/,Vt=/^(?:true|false)$/i,Wt=/^null$/i;var Kt=/^[^A-Z]*$/,Gt=/^[^a-z]*$/;var D=z("$ZodCheck",(e,r)=>{var a;e._zod??(e._zod={}),e._zod.def=r,(a=e._zod).onattach??(a.onattach=[])}),qt={number:"number",bigint:"bigint",object:"date"},He=z("$ZodCheckLessThan",(e,r)=>{D.init(e,r);let a=qt[typeof r.value];e._zod.onattach.push((p)=>{let l=p._zod.bag,f=(r.inclusive?l.maximum:l.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(r.value<f)if(r.inclusive)l.maximum=r.value;else l.exclusiveMaximum=r.value}),e._zod.check=(p)=>{if(r.inclusive?p.value<=r.value:p.value<r.value)return;p.issues.push({origin:a,code:"too_big",maximum:typeof r.value==="object"?r.value.getTime():r.value,input:p.value,inclusive:r.inclusive,inst:e,continue:!r.abort})}}),Qe=z("$ZodCheckGreaterThan",(e,r)=>{D.init(e,r);let a=qt[typeof r.value];e._zod.onattach.push((p)=>{let l=p._zod.bag,f=(r.inclusive?l.minimum:l.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(r.value>f)if(r.inclusive)l.minimum=r.value;else l.exclusiveMinimum=r.value}),e._zod.check=(p)=>{if(r.inclusive?p.value>=r.value:p.value>r.value)return;p.issues.push({origin:a,code:"too_small",minimum:typeof r.value==="object"?r.value.getTime():r.value,input:p.value,inclusive:r.inclusive,inst:e,continue:!r.abort})}}),Yt=z("$ZodCheckMultipleOf",(e,r)=>{D.init(e,r),e._zod.onattach.push((a)=>{var p;(p=a._zod.bag).multipleOf??(p.multipleOf=r.value)}),e._zod.check=(a)=>{if(typeof a.value!==typeof r.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof a.value==="bigint"?a.value%r.value===BigInt(0):Qr(a.value,r.value)===0)return;a.issues.push({origin:typeof a.value,code:"not_multiple_of",divisor:r.value,input:a.value,inst:e,continue:!r.abort})}}),Xt=z("$ZodCheckNumberFormat",(e,r)=>{D.init(e,r),r.format=r.format||"float64";let a=r.format?.includes("int"),p=a?"int":"number",[l,f]=nt[r.format];e._zod.onattach.push((m)=>{let h=m._zod.bag;if(h.format=r.format,h.minimum=l,h.maximum=f,a)h.pattern=Bt}),e._zod.check=(m)=>{let h=m.value;if(a){if(!Number.isInteger(h)){m.issues.push({expected:p,format:r.format,code:"invalid_type",continue:!1,input:h,inst:e});return}if(!Number.isSafeInteger(h)){if(h>0)m.issues.push({input:h,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:p,inclusive:!0,continue:!r.abort});else m.issues.push({input:h,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:p,inclusive:!0,continue:!r.abort});return}}if(h<l)m.issues.push({origin:"number",input:h,code:"too_small",minimum:l,inclusive:!0,inst:e,continue:!r.abort});if(h>f)m.issues.push({origin:"number",input:h,code:"too_big",maximum:f,inclusive:!0,inst:e,continue:!r.abort})}});var Ht=z("$ZodCheckMaxLength",(e,r)=>{var a;D.init(e,r),(a=e._zod.def).when??(a.when=(p)=>{let l=p.value;return!we(l)&&l.length!==void 0}),e._zod.onattach.push((p)=>{let l=p._zod.bag.maximum??Number.POSITIVE_INFINITY;if(r.maximum<l)p._zod.bag.maximum=r.maximum}),e._zod.check=(p)=>{let l=p.value;if(l.length<=r.maximum)return;let m=Ze(l);p.issues.push({origin:m,code:"too_big",maximum:r.maximum,inclusive:!0,input:l,inst:e,continue:!r.abort})}}),Qt=z("$ZodCheckMinLength",(e,r)=>{var a;D.init(e,r),(a=e._zod.def).when??(a.when=(p)=>{let l=p.value;return!we(l)&&l.length!==void 0}),e._zod.onattach.push((p)=>{let l=p._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(r.minimum>l)p._zod.bag.minimum=r.minimum}),e._zod.check=(p)=>{let l=p.value;if(l.length>=r.minimum)return;let m=Ze(l);p.issues.push({origin:m,code:"too_small",minimum:r.minimum,inclusive:!0,input:l,inst:e,continue:!r.abort})}}),eo=z("$ZodCheckLengthEquals",(e,r)=>{var a;D.init(e,r),(a=e._zod.def).when??(a.when=(p)=>{let l=p.value;return!we(l)&&l.length!==void 0}),e._zod.onattach.push((p)=>{let l=p._zod.bag;l.minimum=r.length,l.maximum=r.length,l.length=r.length}),e._zod.check=(p)=>{let l=p.value,f=l.length;if(f===r.length)return;let m=Ze(l),h=f>r.length;p.issues.push({origin:m,...h?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},inclusive:!0,exact:!0,input:p.value,inst:e,continue:!r.abort})}}),de=z("$ZodCheckStringFormat",(e,r)=>{var a,p;if(D.init(e,r),e._zod.onattach.push((l)=>{let f=l._zod.bag;if(f.format=r.format,r.pattern)f.patterns??(f.patterns=new Set),f.patterns.add(r.pattern)}),r.pattern)(a=e._zod).check??(a.check=(l)=>{if(r.pattern.lastIndex=0,r.pattern.test(l.value))return;l.issues.push({origin:"string",code:"invalid_format",format:r.format,input:l.value,...r.pattern?{pattern:r.pattern.toString()}:{},inst:e,continue:!r.abort})});else(p=e._zod).check??(p.check=()=>{})}),ro=z("$ZodCheckRegex",(e,r)=>{de.init(e,r),e._zod.check=(a)=>{if(r.pattern.lastIndex=0,r.pattern.test(a.value))return;a.issues.push({origin:"string",code:"invalid_format",format:"regex",input:a.value,pattern:r.pattern.toString(),inst:e,continue:!r.abort})}}),to=z("$ZodCheckLowerCase",(e,r)=>{r.pattern??(r.pattern=Kt),de.init(e,r)}),oo=z("$ZodCheckUpperCase",(e,r)=>{r.pattern??(r.pattern=Gt),de.init(e,r)}),no=z("$ZodCheckIncludes",(e,r)=>{D.init(e,r);let a=G(r.includes),p=new RegExp(typeof r.position==="number"?`^.{${r.position}}${a}`:a);r.pattern=p,e._zod.onattach.push((l)=>{let f=l._zod.bag;f.patterns??(f.patterns=new Set),f.patterns.add(p)}),e._zod.check=(l)=>{if(l.value.includes(r.includes,r.position))return;l.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:r.includes,input:l.value,inst:e,continue:!r.abort})}}),so=z("$ZodCheckStartsWith",(e,r)=>{D.init(e,r);let a=new RegExp(`^${G(r.prefix)}.*`);r.pattern??(r.pattern=a),e._zod.onattach.push((p)=>{let l=p._zod.bag;l.patterns??(l.patterns=new Set),l.patterns.add(a)}),e._zod.check=(p)=>{if(p.value.startsWith(r.prefix))return;p.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:r.prefix,input:p.value,inst:e,continue:!r.abort})}}),io=z("$ZodCheckEndsWith",(e,r)=>{D.init(e,r);let a=new RegExp(`.*${G(r.suffix)}$`);r.pattern??(r.pattern=a),e._zod.onattach.push((p)=>{let l=p._zod.bag;l.patterns??(l.patterns=new Set),l.patterns.add(a)}),e._zod.check=(p)=>{if(p.value.endsWith(r.suffix))return;p.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:r.suffix,input:p.value,inst:e,continue:!r.abort})}});var co=z("$ZodCheckOverwrite",(e,r)=>{D.init(e,r),e._zod.check=(a)=>{a.value=r.tx(a.value)}});class er{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let a=e.split(`
|
|
3
|
+
`).filter((f)=>f),p=Math.min(...a.map((f)=>f.length-f.trimStart().length)),l=a.map((f)=>f.slice(p)).map((f)=>" ".repeat(this.indent*2)+f);for(let f of l)this.content.push(f)}compile(){let e=Function,r=this?.args,p=[...(this?.content??[""]).map((l)=>` ${l}`)];return new e(...r,p.join(`
|
|
4
|
+
`))}}var ao={major:4,minor:4,patch:3};var I=z("$ZodType",(e,r)=>{var a;e??(e={}),e._zod.def=r,e._zod.bag=e._zod.bag||{},e._zod.version=ao;let p=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))p.unshift(e);for(let l of p)for(let f of l._zod.onattach)f(e);if(p.length===0)(a=e._zod).deferred??(a.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let l=(m,h,g)=>{let x=re(m),v;for(let w of h){if(w._zod.def.when){if(st(m))continue;if(!w._zod.def.when(m))continue}else if(x)continue;let P=m.issues.length,Z=w._zod.check(m);if(Z instanceof Promise&&g?.async===!1)throw new V;if(v||Z instanceof Promise)v=(v??Promise.resolve()).then(async()=>{if(await Z,m.issues.length===P)return;if(!x)x=re(m,P)});else{if(m.issues.length===P)continue;if(!x)x=re(m,P)}}if(v)return v.then(()=>m);return m},f=(m,h,g)=>{if(re(m))return m.aborted=!0,m;let x=l(h,p,g);if(x instanceof Promise){if(g.async===!1)throw new V;return x.then((v)=>e._zod.parse(v,g))}return e._zod.parse(x,g)};e._zod.run=(m,h)=>{if(h.skipChecks)return e._zod.parse(m,h);if(h.direction==="backward"){let x=e._zod.parse({value:m.value,issues:[]},{...h,skipChecks:!0});if(x instanceof Promise)return x.then((v)=>f(v,m,h));return f(x,m,h)}let g=e._zod.parse(m,h);if(g instanceof Promise){if(h.async===!1)throw new V;return g.then((x)=>l(x,p,h))}return l(g,p,h)}}S(e,"~standard",()=>({validate:(l)=>{try{let f=at(e,l);return f.success?{value:f.data}:{issues:f.error?.issues}}catch(f){return pt(e,l).then((m)=>m.success?{value:m.data}:{issues:m.error?.issues})}},vendor:"zod",version:1}))}),Ae=z("$ZodString",(e,r)=>{I.init(e,r),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Jt(e._zod.bag),e._zod.parse=(a,p)=>{if(r.coerce)try{a.value=String(a.value)}catch(l){}if(typeof a.value==="string")return a;return a.issues.push({expected:"string",code:"invalid_type",input:a.value,inst:e}),a}}),T=z("$ZodStringFormat",(e,r)=>{de.init(e,r),Ae.init(e,r)}),zo=z("$ZodGUID",(e,r)=>{r.pattern??(r.pattern=Pt),T.init(e,r)}),vo=z("$ZodUUID",(e,r)=>{if(r.version){let p={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[r.version];if(p===void 0)throw Error(`Invalid UUID version: "${r.version}"`);r.pattern??(r.pattern=qe(p))}else r.pattern??(r.pattern=qe());T.init(e,r)}),yo=z("$ZodEmail",(e,r)=>{r.pattern??(r.pattern=St),T.init(e,r)}),bo=z("$ZodURL",(e,r)=>{T.init(e,r),e._zod.check=(a)=>{try{let p=a.value.trim();if(!r.normalize&&r.protocol?.source===Ct.source){if(!/^https?:\/\//i.test(p)){a.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:a.value,inst:e,continue:!r.abort});return}}let l=new URL(p);if(r.hostname){if(r.hostname.lastIndex=0,!r.hostname.test(l.hostname))a.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:r.hostname.source,input:a.value,inst:e,continue:!r.abort})}if(r.protocol){if(r.protocol.lastIndex=0,!r.protocol.test(l.protocol.endsWith(":")?l.protocol.slice(0,-1):l.protocol))a.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:r.protocol.source,input:a.value,inst:e,continue:!r.abort})}if(r.normalize)a.value=l.href;else a.value=p;return}catch(p){a.issues.push({code:"invalid_format",format:"url",input:a.value,inst:e,continue:!r.abort})}}}),wo=z("$ZodEmoji",(e,r)=>{r.pattern??(r.pattern=Ot()),T.init(e,r)}),ko=z("$ZodNanoID",(e,r)=>{r.pattern??(r.pattern=kt),T.init(e,r)}),Zo=z("$ZodCUID",(e,r)=>{r.pattern??(r.pattern=vt),T.init(e,r)}),Po=z("$ZodCUID2",(e,r)=>{r.pattern??(r.pattern=yt),T.init(e,r)}),So=z("$ZodULID",(e,r)=>{r.pattern??(r.pattern=$t),T.init(e,r)}),Oo=z("$ZodXID",(e,r)=>{r.pattern??(r.pattern=bt),T.init(e,r)}),Eo=z("$ZodKSUID",(e,r)=>{r.pattern??(r.pattern=wt),T.init(e,r)}),Io=z("$ZodISODateTime",(e,r)=>{r.pattern??(r.pattern=Mt(r)),T.init(e,r)}),To=z("$ZodISODate",(e,r)=>{r.pattern??(r.pattern=Lt),T.init(e,r)}),No=z("$ZodISOTime",(e,r)=>{r.pattern??(r.pattern=Ut(r)),T.init(e,r)}),Ao=z("$ZodISODuration",(e,r)=>{r.pattern??(r.pattern=Zt),T.init(e,r)}),jo=z("$ZodIPv4",(e,r)=>{r.pattern??(r.pattern=It),T.init(e,r),e._zod.bag.format="ipv4"}),Co=z("$ZodIPv6",(e,r)=>{r.pattern??(r.pattern=Tt),T.init(e,r),e._zod.bag.format="ipv6",e._zod.check=(a)=>{try{new URL(`http://[${a.value}]`)}catch{a.issues.push({code:"invalid_format",format:"ipv6",input:a.value,inst:e,continue:!r.abort})}}});var Ro=z("$ZodCIDRv4",(e,r)=>{r.pattern??(r.pattern=Nt),T.init(e,r)}),Do=z("$ZodCIDRv6",(e,r)=>{r.pattern??(r.pattern=At),T.init(e,r),e._zod.check=(a)=>{let p=a.value.split("/");try{if(p.length!==2)throw Error();let[l,f]=p;if(!f)throw Error();let m=Number(f);if(`${m}`!==f)throw Error();if(m<0||m>128)throw Error();new URL(`http://[${l}]`)}catch{a.issues.push({code:"invalid_format",format:"cidrv6",input:a.value,inst:e,continue:!r.abort})}}});function Lo(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Uo=z("$ZodBase64",(e,r)=>{r.pattern??(r.pattern=jt),T.init(e,r),e._zod.bag.contentEncoding="base64",e._zod.check=(a)=>{if(Lo(a.value))return;a.issues.push({code:"invalid_format",format:"base64",input:a.value,inst:e,continue:!r.abort})}});function ui(e){if(!Ye.test(e))return!1;let r=e.replace(/[-_]/g,(p)=>p==="-"?"+":"/"),a=r.padEnd(Math.ceil(r.length/4)*4,"=");return Lo(a)}var Mo=z("$ZodBase64URL",(e,r)=>{r.pattern??(r.pattern=Ye),T.init(e,r),e._zod.bag.contentEncoding="base64url",e._zod.check=(a)=>{if(ui(a.value))return;a.issues.push({code:"invalid_format",format:"base64url",input:a.value,inst:e,continue:!r.abort})}}),Jo=z("$ZodE164",(e,r)=>{r.pattern??(r.pattern=Rt),T.init(e,r)});function ai(e,r=null){try{let a=e.split(".");if(a.length!==3)return!1;let[p]=a;if(!p)return!1;let l=JSON.parse(atob(p));if("typ"in l&&l?.typ!=="JWT")return!1;if(!l.alg)return!1;if(r&&(!("alg"in l)||l.alg!==r))return!1;return!0}catch{return!1}}var Vo=z("$ZodJWT",(e,r)=>{T.init(e,r),e._zod.check=(a)=>{if(ai(a.value,r.alg))return;a.issues.push({code:"invalid_format",format:"jwt",input:a.value,inst:e,continue:!r.abort})}});var tr=z("$ZodNumber",(e,r)=>{I.init(e,r),e._zod.pattern=e._zod.bag.pattern??Xe,e._zod.parse=(a,p)=>{if(r.coerce)try{a.value=Number(a.value)}catch(m){}let l=a.value;if(typeof l==="number"&&!Number.isNaN(l)&&Number.isFinite(l))return a;let f=typeof l==="number"?Number.isNaN(l)?"NaN":!Number.isFinite(l)?"Infinity":void 0:void 0;return a.issues.push({expected:"number",code:"invalid_type",input:l,inst:e,...f?{received:f}:{}}),a}}),Wo=z("$ZodNumberFormat",(e,r)=>{Xt.init(e,r),tr.init(e,r)}),Ko=z("$ZodBoolean",(e,r)=>{I.init(e,r),e._zod.pattern=Vt,e._zod.parse=(a,p)=>{if(r.coerce)try{a.value=Boolean(a.value)}catch(f){}let l=a.value;if(typeof l==="boolean")return a;return a.issues.push({expected:"boolean",code:"invalid_type",input:l,inst:e}),a}});var Go=z("$ZodNull",(e,r)=>{I.init(e,r),e._zod.pattern=Wt,e._zod.values=new Set([null]),e._zod.parse=(a,p)=>{let l=a.value;if(l===null)return a;return a.issues.push({expected:"null",code:"invalid_type",input:l,inst:e}),a}});var qo=z("$ZodUnknown",(e,r)=>{I.init(e,r),e._zod.parse=(a)=>a}),Yo=z("$ZodNever",(e,r)=>{I.init(e,r),e._zod.parse=(a,p)=>(a.issues.push({expected:"never",code:"invalid_type",input:a.value,inst:e}),a)});function po(e,r,a){if(e.issues.length)r.issues.push(...q(a,e.issues));r.value[a]=e.value}var Xo=z("$ZodArray",(e,r)=>{I.init(e,r),e._zod.parse=(a,p)=>{let l=a.value;if(!Array.isArray(l))return a.issues.push({expected:"array",code:"invalid_type",input:l,inst:e}),a;a.value=Array(l.length);let f=[];for(let m=0;m<l.length;m++){let h=l[m],g=r.element._zod.run({value:h,issues:[]},p);if(g instanceof Promise)f.push(g.then((x)=>po(x,a,m)));else po(g,a,m)}if(f.length)return Promise.all(f).then(()=>a);return a}});function Ne(e,r,a,p,l,f){let m=a in p;if(e.issues.length){if(l&&f&&!m)return;r.issues.push(...q(a,e.issues))}if(!m&&!l){if(!e.issues.length)r.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[a]});return}if(e.value===void 0){if(m)r.value[a]=void 0}else r.value[a]=e.value}function Ho(e){let r=Object.keys(e.shape);for(let p of r)if(!e.shape?.[p]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${p}": expected a Zod schema`);let a=ot(e.shape);return{...e,keys:r,keySet:new Set(r),numKeys:r.length,optionalKeys:new Set(a)}}function Qo(e,r,a,p,l,f){let m=[],h=l.keySet,g=l.catchall._zod,x=g.def.type,v=g.optin==="optional",w=g.optout==="optional";for(let P in r){if(P==="__proto__")continue;if(h.has(P))continue;if(x==="never"){m.push(P);continue}let Z=g.run({value:r[P],issues:[]},p);if(Z instanceof Promise)e.push(Z.then((O)=>Ne(O,a,P,r,v,w)));else Ne(Z,a,P,r,v,w)}if(m.length)a.issues.push({code:"unrecognized_keys",keys:m,input:r,inst:f});if(!e.length)return a;return Promise.all(e).then(()=>a)}var pi=z("$ZodObject",(e,r)=>{if(I.init(e,r),!Object.getOwnPropertyDescriptor(r,"shape")?.get){let h=r.shape;Object.defineProperty(r,"shape",{get:()=>{let g={...h};return Object.defineProperty(r,"shape",{value:g}),g}})}let p=pe(()=>Ho(r));S(e._zod,"propValues",()=>{let h=r.shape,g={};for(let x in h){let v=h[x]._zod;if(v.values){g[x]??(g[x]=new Set);for(let w of v.values)g[x].add(w)}}return g});let l=se,f=r.catchall,m;e._zod.parse=(h,g)=>{m??(m=p.value);let x=h.value;if(!l(x))return h.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),h;h.value={};let v=[],w=m.shape;for(let P of m.keys){let Z=w[P],O=Z._zod.optin==="optional",ce=Z._zod.optout==="optional",C=Z._zod.run({value:x[P],issues:[]},g);if(C instanceof Promise)v.push(C.then((Je)=>Ne(Je,h,P,x,O,ce)));else Ne(C,h,P,x,O,ce)}if(!f)return v.length?Promise.all(v).then(()=>h):h;return Qo(v,x,h,g,p.value,e)}}),en=z("$ZodObjectJIT",(e,r)=>{pi.init(e,r);let a=e._zod.parse,p=pe(()=>Ho(r)),l=(P)=>{let Z=new er(["shape","payload","ctx"]),O=p.value,ce=(B)=>{let j=Ve(B);return`shape[${j}]._zod.run({ value: input[${j}], issues: [] }, ctx)`};Z.write("const input = payload.value;");let C=Object.create(null),Je=0;for(let B of O.keys)C[B]=`key_${Je++}`;Z.write("const newResult = {};");for(let B of O.keys){let j=C[B],R=Ve(B),qr=P[B],Yr=qr?._zod?.optin==="optional",Hs=qr?._zod?.optout==="optional";if(Z.write(`const ${j} = ${ce(B)};`),Yr&&Hs)Z.write(`
|
|
5
|
+
if (${j}.issues.length) {
|
|
6
|
+
if (${R} in input) {
|
|
7
|
+
payload.issues = payload.issues.concat(${j}.issues.map(iss => ({
|
|
8
|
+
...iss,
|
|
9
|
+
path: iss.path ? [${R}, ...iss.path] : [${R}]
|
|
10
|
+
})));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (${j}.value === undefined) {
|
|
15
|
+
if (${R} in input) {
|
|
16
|
+
newResult[${R}] = undefined;
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
newResult[${R}] = ${j}.value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
`);else if(!Yr)Z.write(`
|
|
23
|
+
const ${j}_present = ${R} in input;
|
|
24
|
+
if (${j}.issues.length) {
|
|
25
|
+
payload.issues = payload.issues.concat(${j}.issues.map(iss => ({
|
|
26
|
+
...iss,
|
|
27
|
+
path: iss.path ? [${R}, ...iss.path] : [${R}]
|
|
28
|
+
})));
|
|
29
|
+
}
|
|
30
|
+
if (!${j}_present && !${j}.issues.length) {
|
|
31
|
+
payload.issues.push({
|
|
32
|
+
code: "invalid_type",
|
|
33
|
+
expected: "nonoptional",
|
|
34
|
+
input: undefined,
|
|
35
|
+
path: [${R}]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (${j}_present) {
|
|
40
|
+
if (${j}.value === undefined) {
|
|
41
|
+
newResult[${R}] = undefined;
|
|
42
|
+
} else {
|
|
43
|
+
newResult[${R}] = ${j}.value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
`);else Z.write(`
|
|
48
|
+
if (${j}.issues.length) {
|
|
49
|
+
payload.issues = payload.issues.concat(${j}.issues.map(iss => ({
|
|
50
|
+
...iss,
|
|
51
|
+
path: iss.path ? [${R}, ...iss.path] : [${R}]
|
|
52
|
+
})));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (${j}.value === undefined) {
|
|
56
|
+
if (${R} in input) {
|
|
57
|
+
newResult[${R}] = undefined;
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
newResult[${R}] = ${j}.value;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
`)}Z.write("payload.value = newResult;"),Z.write("return payload;");let Xs=Z.compile();return(B,j)=>Xs(P,B,j)},f,m=se,h=!ne.jitless,x=h&&rt.value,v=r.catchall,w;e._zod.parse=(P,Z)=>{w??(w=p.value);let O=P.value;if(!m(O))return P.issues.push({expected:"object",code:"invalid_type",input:O,inst:e}),P;if(h&&x&&Z?.async===!1&&Z.jitless!==!0){if(!f)f=l(r.shape);if(P=f(P,Z),!v)return P;return Qo([],O,P,Z,w,e)}return a(P,Z)}});function lo(e,r,a,p){for(let f of e)if(f.issues.length===0)return r.value=f.value,r;let l=e.filter((f)=>!re(f));if(l.length===1)return r.value=l[0].value,l[0];return r.issues.push({code:"invalid_union",input:r.value,inst:a,errors:e.map((f)=>f.issues.map((m)=>J(m,p,L())))}),r}var or=z("$ZodUnion",(e,r)=>{I.init(e,r),S(e._zod,"optin",()=>r.options.some((p)=>p._zod.optin==="optional")?"optional":void 0),S(e._zod,"optout",()=>r.options.some((p)=>p._zod.optout==="optional")?"optional":void 0),S(e._zod,"values",()=>{if(r.options.every((p)=>p._zod.values))return new Set(r.options.flatMap((p)=>Array.from(p._zod.values)));return}),S(e._zod,"pattern",()=>{if(r.options.every((p)=>p._zod.pattern)){let p=r.options.map((l)=>l._zod.pattern);return new RegExp(`^(${p.map((l)=>ke(l.source)).join("|")})$`)}return});let a=r.options.length===1?r.options[0]._zod.run:null;e._zod.parse=(p,l)=>{if(a)return a(p,l);let f=!1,m=[];for(let h of r.options){let g=h._zod.run({value:p.value,issues:[]},l);if(g instanceof Promise)m.push(g),f=!0;else{if(g.issues.length===0)return g;m.push(g)}}if(!f)return lo(m,p,e,l);return Promise.all(m).then((h)=>lo(h,p,e,l))}});var rn=z("$ZodDiscriminatedUnion",(e,r)=>{r.inclusive=!1,or.init(e,r);let a=e._zod.parse;S(e._zod,"propValues",()=>{let l={};for(let f of r.options){let m=f._zod.propValues;if(!m||Object.keys(m).length===0)throw Error(`Invalid discriminated union option at index "${r.options.indexOf(f)}"`);for(let[h,g]of Object.entries(m)){if(!l[h])l[h]=new Set;for(let x of g)l[h].add(x)}}return l});let p=pe(()=>{let l=r.options,f=new Map;for(let m of l){let h=m._zod.propValues?.[r.discriminator];if(!h||h.size===0)throw Error(`Invalid discriminated union option at index "${r.options.indexOf(m)}"`);for(let g of h){if(f.has(g))throw Error(`Duplicate discriminator value "${String(g)}"`);f.set(g,m)}}return f});e._zod.parse=(l,f)=>{let m=l.value;if(!se(m))return l.issues.push({code:"invalid_type",expected:"object",input:m,inst:e}),l;let h=p.value.get(m?.[r.discriminator]);if(h)return h._zod.run(l,f);if(r.unionFallback||f.direction==="backward")return a(l,f);return l.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:r.discriminator,options:Array.from(p.value.keys()),input:m,path:[r.discriminator],inst:e}),l}}),tn=z("$ZodIntersection",(e,r)=>{I.init(e,r),e._zod.parse=(a,p)=>{let l=a.value,f=r.left._zod.run({value:l,issues:[]},p),m=r.right._zod.run({value:l,issues:[]},p);if(f instanceof Promise||m instanceof Promise)return Promise.all([f,m]).then(([g,x])=>fo(a,g,x));return fo(a,f,m)}});function rr(e,r){if(e===r)return{valid:!0,data:e};if(e instanceof Date&&r instanceof Date&&+e===+r)return{valid:!0,data:e};if(Q(e)&&Q(r)){let a=Object.keys(r),p=Object.keys(e).filter((f)=>a.indexOf(f)!==-1),l={...e,...r};for(let f of p){let m=rr(e[f],r[f]);if(!m.valid)return{valid:!1,mergeErrorPath:[f,...m.mergeErrorPath]};l[f]=m.data}return{valid:!0,data:l}}if(Array.isArray(e)&&Array.isArray(r)){if(e.length!==r.length)return{valid:!1,mergeErrorPath:[]};let a=[];for(let p=0;p<e.length;p++){let l=e[p],f=r[p],m=rr(l,f);if(!m.valid)return{valid:!1,mergeErrorPath:[p,...m.mergeErrorPath]};a.push(m.data)}return{valid:!0,data:a}}return{valid:!1,mergeErrorPath:[]}}function fo(e,r,a){let p=new Map,l;for(let h of r.issues)if(h.code==="unrecognized_keys"){l??(l=h);for(let g of h.keys){if(!p.has(g))p.set(g,{});p.get(g).l=!0}}else e.issues.push(h);for(let h of a.issues)if(h.code==="unrecognized_keys")for(let g of h.keys){if(!p.has(g))p.set(g,{});p.get(g).r=!0}else e.issues.push(h);let f=[...p].filter(([,h])=>h.l&&h.r).map(([h])=>h);if(f.length&&l)e.issues.push({...l,keys:f});if(re(e))return e;let m=rr(r.value,a.value);if(!m.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(m.mergeErrorPath)}`);return e.value=m.data,e}var sn=z("$ZodRecord",(e,r)=>{I.init(e,r),e._zod.parse=(a,p)=>{let l=a.value;if(!Q(l))return a.issues.push({expected:"record",code:"invalid_type",input:l,inst:e}),a;let f=[],m=r.keyType._zod.values;if(m){a.value={};let h=new Set;for(let x of m)if(typeof x==="string"||typeof x==="number"||typeof x==="symbol"){h.add(typeof x==="number"?x.toString():x);let v=r.keyType._zod.run({value:x,issues:[]},p);if(v instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(v.issues.length){a.issues.push({code:"invalid_key",origin:"record",issues:v.issues.map((Z)=>J(Z,p,L())),input:x,path:[x],inst:e});continue}let w=v.value,P=r.valueType._zod.run({value:l[x],issues:[]},p);if(P instanceof Promise)f.push(P.then((Z)=>{if(Z.issues.length)a.issues.push(...q(x,Z.issues));a.value[w]=Z.value}));else{if(P.issues.length)a.issues.push(...q(x,P.issues));a.value[w]=P.value}}let g;for(let x in l)if(!h.has(x))g=g??[],g.push(x);if(g&&g.length>0)a.issues.push({code:"unrecognized_keys",input:l,inst:e,keys:g})}else{a.value={};for(let h of Reflect.ownKeys(l)){if(h==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(l,h))continue;let g=r.keyType._zod.run({value:h,issues:[]},p);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof h==="string"&&Xe.test(h)&&g.issues.length){let w=r.keyType._zod.run({value:Number(h),issues:[]},p);if(w instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(w.issues.length===0)g=w}if(g.issues.length){if(r.mode==="loose")a.value[h]=l[h];else a.issues.push({code:"invalid_key",origin:"record",issues:g.issues.map((w)=>J(w,p,L())),input:h,path:[h],inst:e});continue}let v=r.valueType._zod.run({value:l[h],issues:[]},p);if(v instanceof Promise)f.push(v.then((w)=>{if(w.issues.length)a.issues.push(...q(h,w.issues));a.value[g.value]=w.value}));else{if(v.issues.length)a.issues.push(...q(h,v.issues));a.value[g.value]=v.value}}}if(f.length)return Promise.all(f).then(()=>a);return a}});var cn=z("$ZodEnum",(e,r)=>{I.init(e,r);let a=be(r.entries),p=new Set(a);e._zod.values=p,e._zod.pattern=new RegExp(`^(${a.filter((l)=>tt.has(typeof l)).map((l)=>typeof l==="string"?G(l):l.toString()).join("|")})$`),e._zod.parse=(l,f)=>{let m=l.value;if(p.has(m))return l;return l.issues.push({code:"invalid_value",values:a,input:m,inst:e}),l}}),un=z("$ZodLiteral",(e,r)=>{if(I.init(e,r),r.values.length===0)throw Error("Cannot create literal schema with no valid values");let a=new Set(r.values);e._zod.values=a,e._zod.pattern=new RegExp(`^(${r.values.map((p)=>typeof p==="string"?G(p):p?G(p.toString()):String(p)).join("|")})$`),e._zod.parse=(p,l)=>{let f=p.value;if(a.has(f))return p;return p.issues.push({code:"invalid_value",values:r.values,input:f,inst:e}),p}});var an=z("$ZodTransform",(e,r)=>{I.init(e,r),e._zod.optin="optional",e._zod.parse=(a,p)=>{if(p.direction==="backward")throw new ue(e.constructor.name);let l=r.transform(a.value,a);if(p.async)return(l instanceof Promise?l:Promise.resolve(l)).then((m)=>(a.value=m,a.fallback=!0,a));if(l instanceof Promise)throw new V;return a.value=l,a.fallback=!0,a}});function mo(e,r){if(r===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var nr=z("$ZodOptional",(e,r)=>{I.init(e,r),e._zod.optin="optional",e._zod.optout="optional",S(e._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,void 0]):void 0),S(e._zod,"pattern",()=>{let a=r.innerType._zod.pattern;return a?new RegExp(`^(${ke(a.source)})?$`):void 0}),e._zod.parse=(a,p)=>{if(r.innerType._zod.optin==="optional"){let l=a.value,f=r.innerType._zod.run(a,p);if(f instanceof Promise)return f.then((m)=>mo(m,l));return mo(f,l)}if(a.value===void 0)return a;return r.innerType._zod.run(a,p)}}),pn=z("$ZodExactOptional",(e,r)=>{nr.init(e,r),S(e._zod,"values",()=>r.innerType._zod.values),S(e._zod,"pattern",()=>r.innerType._zod.pattern),e._zod.parse=(a,p)=>r.innerType._zod.run(a,p)}),ln=z("$ZodNullable",(e,r)=>{I.init(e,r),S(e._zod,"optin",()=>r.innerType._zod.optin),S(e._zod,"optout",()=>r.innerType._zod.optout),S(e._zod,"pattern",()=>{let a=r.innerType._zod.pattern;return a?new RegExp(`^(${ke(a.source)}|null)$`):void 0}),S(e._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,null]):void 0),e._zod.parse=(a,p)=>{if(a.value===null)return a;return r.innerType._zod.run(a,p)}}),fn=z("$ZodDefault",(e,r)=>{I.init(e,r),e._zod.optin="optional",S(e._zod,"values",()=>r.innerType._zod.values),e._zod.parse=(a,p)=>{if(p.direction==="backward")return r.innerType._zod.run(a,p);if(a.value===void 0)return a.value=r.defaultValue,a;let l=r.innerType._zod.run(a,p);if(l instanceof Promise)return l.then((f)=>ho(f,r));return ho(l,r)}});function ho(e,r){if(e.value===void 0)e.value=r.defaultValue;return e}var dn=z("$ZodPrefault",(e,r)=>{I.init(e,r),e._zod.optin="optional",S(e._zod,"values",()=>r.innerType._zod.values),e._zod.parse=(a,p)=>{if(p.direction==="backward")return r.innerType._zod.run(a,p);if(a.value===void 0)a.value=r.defaultValue;return r.innerType._zod.run(a,p)}}),mn=z("$ZodNonOptional",(e,r)=>{I.init(e,r),S(e._zod,"values",()=>{let a=r.innerType._zod.values;return a?new Set([...a].filter((p)=>p!==void 0)):void 0}),e._zod.parse=(a,p)=>{let l=r.innerType._zod.run(a,p);if(l instanceof Promise)return l.then((f)=>_o(f,e));return _o(l,e)}});function _o(e,r){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:r});return e}var hn=z("$ZodCatch",(e,r)=>{I.init(e,r),e._zod.optin="optional",S(e._zod,"optout",()=>r.innerType._zod.optout),S(e._zod,"values",()=>r.innerType._zod.values),e._zod.parse=(a,p)=>{if(p.direction==="backward")return r.innerType._zod.run(a,p);let l=r.innerType._zod.run(a,p);if(l instanceof Promise)return l.then((f)=>{if(a.value=f.value,f.issues.length)a.value=r.catchValue({...a,error:{issues:f.issues.map((m)=>J(m,p,L()))},input:a.value}),a.issues=[],a.fallback=!0;return a});if(a.value=l.value,l.issues.length)a.value=r.catchValue({...a,error:{issues:l.issues.map((f)=>J(f,p,L()))},input:a.value}),a.issues=[],a.fallback=!0;return a}});var _n=z("$ZodPipe",(e,r)=>{I.init(e,r),S(e._zod,"values",()=>r.in._zod.values),S(e._zod,"optin",()=>r.in._zod.optin),S(e._zod,"optout",()=>r.out._zod.optout),S(e._zod,"propValues",()=>r.in._zod.propValues),e._zod.parse=(a,p)=>{if(p.direction==="backward"){let f=r.out._zod.run(a,p);if(f instanceof Promise)return f.then((m)=>Te(m,r.in,p));return Te(f,r.in,p)}let l=r.in._zod.run(a,p);if(l instanceof Promise)return l.then((f)=>Te(f,r.out,p));return Te(l,r.out,p)}});function Te(e,r,a){if(e.issues.length)return e.aborted=!0,e;return r._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},a)}var gn=z("$ZodReadonly",(e,r)=>{I.init(e,r),S(e._zod,"propValues",()=>r.innerType._zod.propValues),S(e._zod,"values",()=>r.innerType._zod.values),S(e._zod,"optin",()=>r.innerType?._zod?.optin),S(e._zod,"optout",()=>r.innerType?._zod?.optout),e._zod.parse=(a,p)=>{if(p.direction==="backward")return r.innerType._zod.run(a,p);let l=r.innerType._zod.run(a,p);if(l instanceof Promise)return l.then(go);return go(l)}});function go(e){return e.value=Object.freeze(e.value),e}var xn=z("$ZodLazy",(e,r)=>{I.init(e,r),S(e._zod,"innerType",()=>{let a=r;if(!a._cachedInner)a._cachedInner=r.getter();return a._cachedInner}),S(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),S(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),S(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),S(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(a,p)=>e._zod.innerType._zod.run(a,p)}),zn=z("$ZodCustom",(e,r)=>{D.init(e,r),I.init(e,r),e._zod.parse=(a,p)=>a,e._zod.check=(a)=>{let p=a.value,l=r.fn(p);if(l instanceof Promise)return l.then((f)=>xo(f,a,p,e));xo(l,a,p,e);return}});function xo(e,r,a,p){if(!e){let l={code:"custom",input:a,inst:p,path:[...p._zod.def.path??[]],continue:!p._zod.def.abort};if(p._zod.def.params)l.params=p._zod.def.params;r.issues.push(te(l))}}var vn,Rc=Symbol("ZodOutput"),Dc=Symbol("ZodInput");class yn{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let a=r[0];if(this._map.set(e,a),a&&typeof a==="object"&&"id"in a)this._idmap.set(a.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);if(r&&typeof r==="object"&&"id"in r)this._idmap.delete(r.id);return this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let a={...this.get(r)??{}};delete a.id;let p={...a,...this._map.get(e)};return Object.keys(p).length?p:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function li(){return new yn}(vn=globalThis).__zod_globalRegistry??(vn.__zod_globalRegistry=li());var oe=globalThis.__zod_globalRegistry;function $n(e,r){return new e({type:"string",...b(r)})}function bn(e,r){return new e({type:"string",format:"email",check:"string_format",abort:!1,...b(r)})}function je(e,r){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...b(r)})}function sr(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...b(r)})}function wn(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...b(r)})}function kn(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...b(r)})}function Zn(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...b(r)})}function ir(e,r){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(r)})}function Pn(e,r){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...b(r)})}function Sn(e,r){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...b(r)})}function On(e,r){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...b(r)})}function En(e,r){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...b(r)})}function In(e,r){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...b(r)})}function Tn(e,r){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...b(r)})}function Nn(e,r){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...b(r)})}function An(e,r){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...b(r)})}function jn(e,r){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...b(r)})}function Cn(e,r){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...b(r)})}function Rn(e,r){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...b(r)})}function Dn(e,r){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...b(r)})}function Ln(e,r){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...b(r)})}function Fn(e,r){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...b(r)})}function Un(e,r){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...b(r)})}function Mn(e,r){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...b(r)})}function Jn(e,r){return new e({type:"string",format:"date",check:"string_format",...b(r)})}function Bn(e,r){return new e({type:"string",format:"time",check:"string_format",precision:null,...b(r)})}function Vn(e,r){return new e({type:"string",format:"duration",check:"string_format",...b(r)})}function Wn(e,r){return new e({type:"number",checks:[],...b(r)})}function Kn(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...b(r)})}function Gn(e,r){return new e({type:"boolean",...b(r)})}function qn(e,r){return new e({type:"null",...b(r)})}function Yn(e){return new e({type:"unknown"})}function Xn(e,r){return new e({type:"never",...b(r)})}function Ce(e,r){return new He({check:"less_than",...b(r),value:e,inclusive:!1})}function me(e,r){return new He({check:"less_than",...b(r),value:e,inclusive:!0})}function Re(e,r){return new Qe({check:"greater_than",...b(r),value:e,inclusive:!1})}function he(e,r){return new Qe({check:"greater_than",...b(r),value:e,inclusive:!0})}function De(e,r){return new Yt({check:"multiple_of",...b(r),value:e})}function Le(e,r){return new Ht({check:"max_length",...b(r),maximum:e})}function ie(e,r){return new Qt({check:"min_length",...b(r),minimum:e})}function Fe(e,r){return new eo({check:"length_equals",...b(r),length:e})}function cr(e,r){return new ro({check:"string_format",format:"regex",...b(r),pattern:e})}function ur(e){return new to({check:"string_format",format:"lowercase",...b(e)})}function ar(e){return new oo({check:"string_format",format:"uppercase",...b(e)})}function pr(e,r){return new no({check:"string_format",format:"includes",...b(r),includes:e})}function lr(e,r){return new so({check:"string_format",format:"starts_with",...b(r),prefix:e})}function fr(e,r){return new io({check:"string_format",format:"ends_with",...b(r),suffix:e})}function X(e){return new co({check:"overwrite",tx:e})}function dr(e){return X((r)=>r.normalize(e))}function mr(){return X((e)=>e.trim())}function hr(){return X((e)=>e.toLowerCase())}function _r(){return X((e)=>e.toUpperCase())}function gr(){return X((e)=>et(e))}function Hn(e,r,a){return new e({type:"array",element:r,...b(a)})}function Qn(e,r,a){let p=b(a);return p.abort??(p.abort=!0),new e({type:"custom",check:"custom",fn:r,...p})}function es(e,r,a){return new e({type:"custom",check:"custom",fn:r,...b(a)})}function ts(e,r){let a=fi((p)=>(p.addIssue=(l)=>{if(typeof l==="string")p.issues.push(te(l,p.value,a._zod.def));else{let f=l;if(f.fatal)f.continue=!1;f.code??(f.code="custom"),f.input??(f.input=p.value),f.inst??(f.inst=a),f.continue??(f.continue=!a._zod.def.abort),p.issues.push(te(f))}},e(p.value,p)),r);return a}function fi(e,r){let a=new D({check:"custom",...b(r)});return a._zod.check=e,a}function ge(e){let r=e?.target??"draft-2020-12";if(r==="draft-4")r="draft-04";if(r==="draft-7")r="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??oe,target:r,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 E(e,r,a={path:[],schemaPath:[]}){var p;let l=e._zod.def,f=r.seen.get(e);if(f){if(f.count++,a.schemaPath.includes(e))f.cycle=a.path;return f.schema}let m={schema:{},count:1,cycle:void 0,path:a.path};r.seen.set(e,m);let h=e._zod.toJSONSchema?.();if(h)m.schema=h;else{let v={...a,schemaPath:[...a.schemaPath,e],path:a.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(r,m.schema,v);else{let P=m.schema,Z=r.processors[l.type];if(!Z)throw Error(`[toJSONSchema]: Non-representable type encountered: ${l.type}`);Z(e,r,P,v)}let w=e._zod.parent;if(w){if(!m.ref)m.ref=w;E(w,r,v),r.seen.get(w).isParent=!0}}let g=r.metadataRegistry.get(e);if(g)Object.assign(m.schema,g);if(r.io==="input"&&F(e))delete m.schema.examples,delete m.schema.default;if(r.io==="input"&&"_prefault"in m.schema)(p=m.schema).default??(p.default=m.schema._prefault);return delete m.schema._prefault,r.seen.get(e).schema}function xe(e,r){let a=e.seen.get(r);if(!a)throw Error("Unprocessed schema. This is a bug in Zod.");let p=new Map;for(let m of e.seen.entries()){let h=e.metadataRegistry.get(m[0])?.id;if(h){let g=p.get(h);if(g&&g!==m[0])throw Error(`Duplicate schema id "${h}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);p.set(h,m[0])}}let l=(m)=>{let h=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let w=e.external.registry.get(m[0])?.id,P=e.external.uri??((O)=>O);if(w)return{ref:P(w)};let Z=m[1].defId??m[1].schema.id??`schema${e.counter++}`;return m[1].defId=Z,{defId:Z,ref:`${P("__shared")}#/${h}/${Z}`}}if(m[1]===a)return{ref:"#"};let x=`${"#"}/${h}/`,v=m[1].schema.id??`__schema${e.counter++}`;return{defId:v,ref:x+v}},f=(m)=>{if(m[1].schema.$ref)return;let h=m[1],{ref:g,defId:x}=l(m);if(h.def={...h.schema},x)h.defId=x;let v=h.schema;for(let w in v)delete v[w];v.$ref=g};if(e.cycles==="throw")for(let m of e.seen.entries()){let h=m[1];if(h.cycle)throw Error(`Cycle detected: #/${h.cycle?.join("/")}/<root>
|
|
64
|
+
|
|
65
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let m of e.seen.entries()){let h=m[1];if(r===m[0]){f(m);continue}if(e.external){let x=e.external.registry.get(m[0])?.id;if(r!==m[0]&&x){f(m);continue}}if(e.metadataRegistry.get(m[0])?.id){f(m);continue}if(h.cycle){f(m);continue}if(h.count>1){if(e.reused==="ref"){f(m);continue}}}}function ze(e,r){let a=e.seen.get(r);if(!a)throw Error("Unprocessed schema. This is a bug in Zod.");let p=(h)=>{let g=e.seen.get(h);if(g.ref===null)return;let x=g.def??g.schema,v={...x},w=g.ref;if(g.ref=null,w){p(w);let Z=e.seen.get(w),O=Z.schema;if(O.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))x.allOf=x.allOf??[],x.allOf.push(O);else Object.assign(x,O);if(Object.assign(x,v),h._zod.parent===w)for(let C in x){if(C==="$ref"||C==="allOf")continue;if(!(C in v))delete x[C]}if(O.$ref&&Z.def)for(let C in x){if(C==="$ref"||C==="allOf")continue;if(C in Z.def&&JSON.stringify(x[C])===JSON.stringify(Z.def[C]))delete x[C]}}let P=h._zod.parent;if(P&&P!==w){p(P);let Z=e.seen.get(P);if(Z?.schema.$ref){if(x.$ref=Z.schema.$ref,Z.def)for(let O in x){if(O==="$ref"||O==="allOf")continue;if(O in Z.def&&JSON.stringify(x[O])===JSON.stringify(Z.def[O]))delete x[O]}}}e.override({zodSchema:h,jsonSchema:x,path:g.path??[]})};for(let h of[...e.seen.entries()].reverse())p(h[0]);let l={};if(e.target==="draft-2020-12")l.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")l.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")l.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let h=e.external.registry.get(r)?.id;if(!h)throw Error("Schema is missing an `id` property");l.$id=e.external.uri(h)}Object.assign(l,a.def??a.schema);let f=e.metadataRegistry.get(r)?.id;if(f!==void 0&&l.id===f)delete l.id;let m=e.external?.defs??{};for(let h of e.seen.entries()){let g=h[1];if(g.def&&g.defId){if(g.def.id===g.defId)delete g.def.id;m[g.defId]=g.def}}if(e.external);else if(Object.keys(m).length>0)if(e.target==="draft-2020-12")l.$defs=m;else l.definitions=m;try{let h=JSON.parse(JSON.stringify(l));return Object.defineProperty(h,"~standard",{value:{...r["~standard"],jsonSchema:{input:_e(r,"input",e.processors),output:_e(r,"output",e.processors)}},enumerable:!1,writable:!1}),h}catch(h){throw Error("Error converting schema to JSON.")}}function F(e,r){let a=r??{seen:new Set};if(a.seen.has(e))return!1;a.seen.add(e);let p=e._zod.def;if(p.type==="transform")return!0;if(p.type==="array")return F(p.element,a);if(p.type==="set")return F(p.valueType,a);if(p.type==="lazy")return F(p.getter(),a);if(p.type==="promise"||p.type==="optional"||p.type==="nonoptional"||p.type==="nullable"||p.type==="readonly"||p.type==="default"||p.type==="prefault")return F(p.innerType,a);if(p.type==="intersection")return F(p.left,a)||F(p.right,a);if(p.type==="record"||p.type==="map")return F(p.keyType,a)||F(p.valueType,a);if(p.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return F(p.in,a)||F(p.out,a)}if(p.type==="object"){for(let l in p.shape)if(F(p.shape[l],a))return!0;return!1}if(p.type==="union"){for(let l of p.options)if(F(l,a))return!0;return!1}if(p.type==="tuple"){for(let l of p.items)if(F(l,a))return!0;if(p.rest&&F(p.rest,a))return!0;return!1}return!1}var ss=(e,r={})=>(a)=>{let p=ge({...a,processors:r});return E(e,p),xe(p,e),ze(p,e)},_e=(e,r,a={})=>(p)=>{let{libraryOptions:l,target:f}=p??{},m=ge({...l??{},target:f,io:r,processors:a});return E(e,m),xe(m,e),ze(m,e)};var di={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},xr=(e,r,a,p)=>{let l=a;l.type="string";let{minimum:f,maximum:m,format:h,patterns:g,contentEncoding:x}=e._zod.bag;if(typeof f==="number")l.minLength=f;if(typeof m==="number")l.maxLength=m;if(h){if(l.format=di[h]??h,l.format==="")delete l.format;if(h==="time")delete l.format}if(x)l.contentEncoding=x;if(g&&g.size>0){let v=[...g];if(v.length===1)l.pattern=v[0].source;else if(v.length>1)l.allOf=[...v.map((w)=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:w.source}))]}},zr=(e,r,a,p)=>{let l=a,{minimum:f,maximum:m,format:h,multipleOf:g,exclusiveMaximum:x,exclusiveMinimum:v}=e._zod.bag;if(typeof h==="string"&&h.includes("int"))l.type="integer";else l.type="number";let w=typeof v==="number"&&v>=(f??Number.NEGATIVE_INFINITY),P=typeof x==="number"&&x<=(m??Number.POSITIVE_INFINITY),Z=r.target==="draft-04"||r.target==="openapi-3.0";if(w)if(Z)l.minimum=v,l.exclusiveMinimum=!0;else l.exclusiveMinimum=v;else if(typeof f==="number")l.minimum=f;if(P)if(Z)l.maximum=x,l.exclusiveMaximum=!0;else l.exclusiveMaximum=x;else if(typeof m==="number")l.maximum=m;if(typeof g==="number")l.multipleOf=g},vr=(e,r,a,p)=>{a.type="boolean"},us=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},as=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},yr=(e,r,a,p)=>{if(r.target==="openapi-3.0")a.type="string",a.nullable=!0,a.enum=[null];else a.type="null"},ps=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},ls=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},$r=(e,r,a,p)=>{a.not={}},fs=(e,r,a,p)=>{},br=(e,r,a,p)=>{},ds=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},wr=(e,r,a,p)=>{let l=e._zod.def,f=be(l.entries);if(f.every((m)=>typeof m==="number"))a.type="number";if(f.every((m)=>typeof m==="string"))a.type="string";a.enum=f},kr=(e,r,a,p)=>{let l=e._zod.def,f=[];for(let m of l.values)if(m===void 0){if(r.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof m==="bigint")if(r.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else f.push(Number(m));else f.push(m);if(f.length===0);else if(f.length===1){let m=f[0];if(a.type=m===null?"null":typeof m,r.target==="draft-04"||r.target==="openapi-3.0")a.enum=[m];else a.const=m}else{if(f.every((m)=>typeof m==="number"))a.type="number";if(f.every((m)=>typeof m==="string"))a.type="string";if(f.every((m)=>typeof m==="boolean"))a.type="boolean";if(f.every((m)=>m===null))a.type="null";a.enum=f}},ms=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},hs=(e,r,a,p)=>{let l=a,f=e._zod.pattern;if(!f)throw Error("Pattern not found in template literal");l.type="string",l.pattern=f.source},_s=(e,r,a,p)=>{let l=a,f={type:"string",format:"binary",contentEncoding:"binary"},{minimum:m,maximum:h,mime:g}=e._zod.bag;if(m!==void 0)f.minLength=m;if(h!==void 0)f.maxLength=h;if(g)if(g.length===1)f.contentMediaType=g[0],Object.assign(l,f);else Object.assign(l,f),l.anyOf=g.map((x)=>({contentMediaType:x}));else Object.assign(l,f)},gs=(e,r,a,p)=>{a.type="boolean"},Zr=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},xs=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},Pr=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},zs=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},vs=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},Sr=(e,r,a,p)=>{let l=a,f=e._zod.def,{minimum:m,maximum:h}=e._zod.bag;if(typeof m==="number")l.minItems=m;if(typeof h==="number")l.maxItems=h;l.type="array",l.items=E(f.element,r,{...p,path:[...p.path,"items"]})},Or=(e,r,a,p)=>{let l=a,f=e._zod.def;l.type="object",l.properties={};let m=f.shape;for(let x in m)l.properties[x]=E(m[x],r,{...p,path:[...p.path,"properties",x]});let h=new Set(Object.keys(m)),g=new Set([...h].filter((x)=>{let v=f.shape[x]._zod;if(r.io==="input")return v.optin===void 0;else return v.optout===void 0}));if(g.size>0)l.required=Array.from(g);if(f.catchall?._zod.def.type==="never")l.additionalProperties=!1;else if(!f.catchall){if(r.io==="output")l.additionalProperties=!1}else if(f.catchall)l.additionalProperties=E(f.catchall,r,{...p,path:[...p.path,"additionalProperties"]})},Er=(e,r,a,p)=>{let l=e._zod.def,f=l.inclusive===!1,m=l.options.map((h,g)=>E(h,r,{...p,path:[...p.path,f?"oneOf":"anyOf",g]}));if(f)a.oneOf=m;else a.anyOf=m},Ir=(e,r,a,p)=>{let l=e._zod.def,f=E(l.left,r,{...p,path:[...p.path,"allOf",0]}),m=E(l.right,r,{...p,path:[...p.path,"allOf",1]}),h=(x)=>("allOf"in x)&&Object.keys(x).length===1,g=[...h(f)?f.allOf:[f],...h(m)?m.allOf:[m]];a.allOf=g},ys=(e,r,a,p)=>{let l=a,f=e._zod.def;l.type="array";let m=r.target==="draft-2020-12"?"prefixItems":"items",h=r.target==="draft-2020-12"?"items":r.target==="openapi-3.0"?"items":"additionalItems",g=f.items.map((P,Z)=>E(P,r,{...p,path:[...p.path,m,Z]})),x=f.rest?E(f.rest,r,{...p,path:[...p.path,h,...r.target==="openapi-3.0"?[f.items.length]:[]]}):null;if(r.target==="draft-2020-12"){if(l.prefixItems=g,x)l.items=x}else if(r.target==="openapi-3.0"){if(l.items={anyOf:g},x)l.items.anyOf.push(x);if(l.minItems=g.length,!x)l.maxItems=g.length}else if(l.items=g,x)l.additionalItems=x;let{minimum:v,maximum:w}=e._zod.bag;if(typeof v==="number")l.minItems=v;if(typeof w==="number")l.maxItems=w},Tr=(e,r,a,p)=>{let l=a,f=e._zod.def;l.type="object";let m=f.keyType,g=m._zod.bag?.patterns;if(f.mode==="loose"&&g&&g.size>0){let v=E(f.valueType,r,{...p,path:[...p.path,"patternProperties","*"]});l.patternProperties={};for(let w of g)l.patternProperties[w.source]=v}else{if(r.target==="draft-07"||r.target==="draft-2020-12")l.propertyNames=E(f.keyType,r,{...p,path:[...p.path,"propertyNames"]});l.additionalProperties=E(f.valueType,r,{...p,path:[...p.path,"additionalProperties"]})}let x=m._zod.values;if(x){let v=[...x].filter((w)=>typeof w==="string"||typeof w==="number");if(v.length>0)l.required=v}},Nr=(e,r,a,p)=>{let l=e._zod.def,f=E(l.innerType,r,p),m=r.seen.get(e);if(r.target==="openapi-3.0")m.ref=l.innerType,a.nullable=!0;else a.anyOf=[f,{type:"null"}]},Ar=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType},jr=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType,a.default=JSON.parse(JSON.stringify(l.defaultValue))},Cr=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);if(f.ref=l.innerType,r.io==="input")a._prefault=JSON.parse(JSON.stringify(l.defaultValue))},Rr=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType;let m;try{m=l.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}a.default=m},Dr=(e,r,a,p)=>{let l=e._zod.def,f=l.in._zod.traits.has("$ZodTransform"),m=r.io==="input"?f?l.out:l.in:l.out;E(m,r,p);let h=r.seen.get(e);h.ref=m},Lr=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType,a.readOnly=!0},$s=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType},Ue=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType},Fr=(e,r,a,p)=>{let l=e._zod.innerType;E(l,r,p);let f=r.seen.get(e);f.ref=l},cs={string:xr,number:zr,boolean:vr,bigint:us,symbol:as,null:yr,undefined:ps,void:ls,never:$r,any:fs,unknown:br,date:ds,enum:wr,literal:kr,nan:ms,template_literal:hs,file:_s,success:gs,custom:Zr,function:xs,transform:Pr,map:zs,set:vs,array:Sr,object:Or,union:Er,intersection:Ir,tuple:ys,record:Tr,nullable:Nr,nonoptional:Ar,default:jr,prefault:Cr,catch:Rr,pipe:Dr,readonly:Lr,promise:$s,optional:Ue,lazy:Fr};function nn(e,r){if("_idmap"in e){let p=e,l=ge({...r,processors:cs}),f={};for(let g of p._idmap.entries()){let[x,v]=g;E(v,l)}let m={},h={registry:p,uri:r?.uri,defs:f};l.external=h;for(let g of p._idmap.entries()){let[x,v]=g;xe(l,v),m[x]=ze(l,v)}if(Object.keys(f).length>0){let g=l.target==="draft-2020-12"?"$defs":"definitions";m.__shared={[g]:f}}return{schemas:m}}let a=ge({...r,processors:cs});return E(e,a),xe(a,e),ze(a,e)}var y={};os(y,{ZodISODate:()=>ws,ZodISODateTime:()=>bs,ZodISODuration:()=>Zs,ZodISOTime:()=>ks,date:()=>Mr,datetime:()=>Ur,duration:()=>Br,time:()=>Jr});var bs=z("ZodISODateTime",(e,r)=>{Io.init(e,r),A.init(e,r)});function Ur(e){return Mn(bs,e)}var ws=z("ZodISODate",(e,r)=>{To.init(e,r),A.init(e,r)});function Mr(e){return Jn(ws,e)}var ks=z("ZodISOTime",(e,r)=>{No.init(e,r),A.init(e,r)});function Jr(e){return Bn(ks,e)}var Zs=z("ZodISODuration",(e,r)=>{Ao.init(e,r),A.init(e,r)});function Br(e){return Vn(Zs,e)}var yi=(e,r)=>{Pe.init(e,r),e.name="ZodError",Object.defineProperties(e,{format:{value:(a)=>ut(e,a)},flatten:{value:(a)=>ct(e,a)},addIssue:{value:(a)=>{e.issues.push(a),e.message=JSON.stringify(e.issues,ae,2)}},addIssues:{value:(a)=>{e.issues.push(...a),e.message=JSON.stringify(e.issues,ae,2)}},isEmpty:{get(){return e.issues.length===0}}})};var U=z("ZodError",yi,{Parent:Error});var Ps=Se(U),Ss=Oe(U),Os=le(U),Es=fe(U),Is=lt(U),Ts=ft(U),Ns=dt(U),As=mt(U),js=ht(U),Cs=_t(U),Rs=gt(U),Ds=zt(U);var Ls=new WeakMap;function ye(e,r,a){let p=Object.getPrototypeOf(e),l=Ls.get(p);if(!l)l=new Set,Ls.set(p,l);if(l.has(r))return;l.add(r);for(let f in a){let m=a[f];Object.defineProperty(p,f,{configurable:!0,enumerable:!1,get(){let h=m.bind(this);return Object.defineProperty(this,f,{configurable:!0,writable:!0,enumerable:!0,value:h}),h},set(h){Object.defineProperty(this,f,{configurable:!0,writable:!0,enumerable:!0,value:h})}})}}var N=z("ZodType",(e,r)=>(I.init(e,r),Object.assign(e["~standard"],{jsonSchema:{input:_e(e,"input"),output:_e(e,"output")}}),e.toJSONSchema=ss(e,{}),e.def=r,e.type=r.type,Object.defineProperty(e,"_def",{value:r}),e.parse=(a,p)=>Ps(e,a,p,{callee:e.parse}),e.safeParse=(a,p)=>Os(e,a,p),e.parseAsync=async(a,p)=>Ss(e,a,p,{callee:e.parseAsync}),e.safeParseAsync=async(a,p)=>Es(e,a,p),e.spa=e.safeParseAsync,e.encode=(a,p)=>Is(e,a,p),e.decode=(a,p)=>Ts(e,a,p),e.encodeAsync=async(a,p)=>Ns(e,a,p),e.decodeAsync=async(a,p)=>As(e,a,p),e.safeEncode=(a,p)=>js(e,a,p),e.safeDecode=(a,p)=>Cs(e,a,p),e.safeEncodeAsync=async(a,p)=>Rs(e,a,p),e.safeDecodeAsync=async(a,p)=>Ds(e,a,p),ye(e,"ZodType",{check(...a){let p=this.def;return this.clone(K(p,{checks:[...p.checks??[],...a.map((l)=>typeof l==="function"?{_zod:{check:l,def:{check:"custom"},onattach:[]}}:l)]}),{parent:!0})},with(...a){return this.check(...a)},clone(a,p){return M(this,a,p)},brand(){return this},register(a,p){return a.add(this,p),this},refine(a,p){return this.check(hc(a,p))},superRefine(a,p){return this.check(_c(a,p))},overwrite(a){return this.check(X(a))},optional(){return Us(this)},exactOptional(){return tc(this)},nullable(){return Ms(this)},nullish(){return Us(Ms(this))},nonoptional(a){return uc(this,a)},array(){return u(this)},or(a){return W([this,a])},and(a){return Xi(this,a)},transform(a){return Js(this,ec(a))},default(a){return sc(this,a)},prefault(a){return cc(this,a)},catch(a){return pc(this,a)},pipe(a){return Js(this,a)},readonly(){return dc(this)},describe(a){let p=this.clone();return oe.add(p,{description:a}),p},meta(...a){if(a.length===0)return oe.get(this);let p=this.clone();return oe.add(p,a[0]),p},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(a){return a(this)}}),Object.defineProperty(e,"description",{get(){return oe.get(e)?.description},configurable:!0}),e)),Bs=z("_ZodString",(e,r)=>{Ae.init(e,r),N.init(e,r),e._zod.processJSONSchema=(p,l,f)=>xr(e,p,l,f);let a=e._zod.bag;e.format=a.format??null,e.minLength=a.minimum??null,e.maxLength=a.maximum??null,ye(e,"_ZodString",{regex(...p){return this.check(cr(...p))},includes(...p){return this.check(pr(...p))},startsWith(...p){return this.check(lr(...p))},endsWith(...p){return this.check(fr(...p))},min(...p){return this.check(ie(...p))},max(...p){return this.check(Le(...p))},length(...p){return this.check(Fe(...p))},nonempty(...p){return this.check(ie(1,...p))},lowercase(p){return this.check(ur(p))},uppercase(p){return this.check(ar(p))},trim(){return this.check(mr())},normalize(...p){return this.check(dr(...p))},toLowerCase(){return this.check(hr())},toUpperCase(){return this.check(_r())},slugify(){return this.check(gr())}})}),bi=z("ZodString",(e,r)=>{Ae.init(e,r),Bs.init(e,r),e.email=(a)=>e.check(bn(wi,a)),e.url=(a)=>e.check(ir(Vs,a)),e.jwt=(a)=>e.check(Un(Mi,a)),e.emoji=(a)=>e.check(Pn(ki,a)),e.guid=(a)=>e.check(je(Vr,a)),e.uuid=(a)=>e.check(sr(ve,a)),e.uuidv4=(a)=>e.check(wn(ve,a)),e.uuidv6=(a)=>e.check(kn(ve,a)),e.uuidv7=(a)=>e.check(Zn(ve,a)),e.nanoid=(a)=>e.check(Sn(Zi,a)),e.guid=(a)=>e.check(je(Vr,a)),e.cuid=(a)=>e.check(On(Si,a)),e.cuid2=(a)=>e.check(En(Oi,a)),e.ulid=(a)=>e.check(In(Ei,a)),e.base64=(a)=>e.check(Dn(Li,a)),e.base64url=(a)=>e.check(Ln(Fi,a)),e.xid=(a)=>e.check(Tn(Ii,a)),e.ksuid=(a)=>e.check(Nn(Ni,a)),e.ipv4=(a)=>e.check(An(Ai,a)),e.ipv6=(a)=>e.check(jn(ji,a)),e.cidrv4=(a)=>e.check(Cn(Ci,a)),e.cidrv6=(a)=>e.check(Rn(Di,a)),e.e164=(a)=>e.check(Fn(Ui,a)),e.datetime=(a)=>e.check(Ur(a)),e.date=(a)=>e.check(Mr(a)),e.time=(a)=>e.check(Jr(a)),e.duration=(a)=>e.check(Br(a))});function t(e){return $n(bi,e)}var A=z("ZodStringFormat",(e,r)=>{T.init(e,r),Bs.init(e,r)}),wi=z("ZodEmail",(e,r)=>{yo.init(e,r),A.init(e,r)});var Vr=z("ZodGUID",(e,r)=>{zo.init(e,r),A.init(e,r)});function Et(e){return je(Vr,e)}var ve=z("ZodUUID",(e,r)=>{vo.init(e,r),A.init(e,r)});function k(e){return sr(ve,e)}var Vs=z("ZodURL",(e,r)=>{bo.init(e,r),A.init(e,r)});function xt(e){return ir(Vs,e)}var ki=z("ZodEmoji",(e,r)=>{wo.init(e,r),A.init(e,r)});var Zi=z("ZodNanoID",(e,r)=>{ko.init(e,r),A.init(e,r)});var Si=z("ZodCUID",(e,r)=>{Zo.init(e,r),A.init(e,r)});var Oi=z("ZodCUID2",(e,r)=>{Po.init(e,r),A.init(e,r)});var Ei=z("ZodULID",(e,r)=>{So.init(e,r),A.init(e,r)});var Ii=z("ZodXID",(e,r)=>{Oo.init(e,r),A.init(e,r)});var Ni=z("ZodKSUID",(e,r)=>{Eo.init(e,r),A.init(e,r)});var Ai=z("ZodIPv4",(e,r)=>{jo.init(e,r),A.init(e,r)});var ji=z("ZodIPv6",(e,r)=>{Co.init(e,r),A.init(e,r)});var Ci=z("ZodCIDRv4",(e,r)=>{Ro.init(e,r),A.init(e,r)});var Di=z("ZodCIDRv6",(e,r)=>{Do.init(e,r),A.init(e,r)});var Li=z("ZodBase64",(e,r)=>{Uo.init(e,r),A.init(e,r)});var Fi=z("ZodBase64URL",(e,r)=>{Mo.init(e,r),A.init(e,r)});var Ui=z("ZodE164",(e,r)=>{Jo.init(e,r),A.init(e,r)});var Mi=z("ZodJWT",(e,r)=>{Vo.init(e,r),A.init(e,r)});var Ws=z("ZodNumber",(e,r)=>{tr.init(e,r),N.init(e,r),e._zod.processJSONSchema=(p,l,f)=>zr(e,p,l,f),ye(e,"ZodNumber",{gt(p,l){return this.check(Re(p,l))},gte(p,l){return this.check(he(p,l))},min(p,l){return this.check(he(p,l))},lt(p,l){return this.check(Ce(p,l))},lte(p,l){return this.check(me(p,l))},max(p,l){return this.check(me(p,l))},int(p){return this.check(Fs(p))},safe(p){return this.check(Fs(p))},positive(p){return this.check(Re(0,p))},nonnegative(p){return this.check(he(0,p))},negative(p){return this.check(Ce(0,p))},nonpositive(p){return this.check(me(0,p))},multipleOf(p,l){return this.check(De(p,l))},step(p,l){return this.check(De(p,l))},finite(){return this}});let a=e._zod.bag;e.minValue=Math.max(a.minimum??Number.NEGATIVE_INFINITY,a.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(a.maximum??Number.POSITIVE_INFINITY,a.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(a.format??"").includes("int")||Number.isSafeInteger(a.multipleOf??0.5),e.isFinite=!0,e.format=a.format??null});function o(e){return Wn(Ws,e)}var Ji=z("ZodNumberFormat",(e,r)=>{Wo.init(e,r),Ws.init(e,r)});function Fs(e){return Kn(Ji,e)}var Bi=z("ZodBoolean",(e,r)=>{Ko.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>vr(e,a,p,l)});function d(e){return Gn(Bi,e)}var Vi=z("ZodNull",(e,r)=>{Go.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>yr(e,a,p,l)});function rs(e){return qn(Vi,e)}var Wi=z("ZodUnknown",(e,r)=>{qo.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>br(e,a,p,l)});function Ie(){return Yn(Wi)}var Ki=z("ZodNever",(e,r)=>{Yo.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>$r(e,a,p,l)});function Ri(e){return Xn(Ki,e)}var Gi=z("ZodArray",(e,r)=>{Xo.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Sr(e,a,p,l),e.element=r.element,ye(e,"ZodArray",{min(a,p){return this.check(ie(a,p))},nonempty(a){return this.check(ie(1,a))},max(a,p){return this.check(Le(a,p))},length(a,p){return this.check(Fe(a,p))},unwrap(){return this.element}})});function u(e,r){return Hn(Gi,e,r)}var Gr=z("ZodObject",(e,r)=>{en.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Or(e,a,p,l),S(e,"shape",()=>r.shape),ye(e,"ZodObject",{keyof(){return s(Object.keys(this._zod.def.shape))},catchall(a){return this.clone({...this._zod.def,catchall:a})},passthrough(){return this.clone({...this._zod.def,catchall:Ie()})},loose(){return this.clone({...this._zod.def,catchall:Ie()})},strict(){return this.clone({...this._zod.def,catchall:Ri()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(a){return ri(this,a)},safeExtend(a){return ti(this,a)},merge(a){return oi(this,a)},pick(a){return Qs(this,a)},omit(a){return ei(this,a)},partial(...a){return ni(Gs,this,a[0])},required(...a){return si(qs,this,a[0])}})});function i(e,r){let a={type:"object",shape:e??{},...b(r)};return new Gr(a)}function c(e,r){return new Gr({type:"object",shape:e,catchall:Ri(),...b(r)})}function ns(e,r){return new Gr({type:"object",shape:e,catchall:Ie(),...b(r)})}var Ks=z("ZodUnion",(e,r)=>{or.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Er(e,a,p,l),e.options=r.options});function W(e,r){return new Ks({type:"union",options:e,...b(r)})}var qi=z("ZodDiscriminatedUnion",(e,r)=>{Ks.init(e,r),rn.init(e,r)});function _(e,r,a){return new qi({type:"union",options:r,discriminator:e,...b(a)})}var Yi=z("ZodIntersection",(e,r)=>{tn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Ir(e,a,p,l)});function Xi(e,r){return new Yi({type:"intersection",left:e,right:r})}var Wr=z("ZodRecord",(e,r)=>{sn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Tr(e,a,p,l),e.keyType=r.keyType,e.valueType=r.valueType});function ee(e,r,a){if(!r||!r._zod)return new Wr({type:"record",keyType:t(),valueType:e,...b(r)});return new Wr({type:"record",keyType:e,valueType:r,...b(a)})}function is(e,r,a){let p=M(e);return p._zod.values=void 0,new Wr({type:"record",keyType:p,valueType:r,...b(a)})}var Kr=z("ZodEnum",(e,r)=>{cn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(p,l,f)=>wr(e,p,l,f),e.enum=r.entries,e.options=Object.values(r.entries);let a=new Set(Object.keys(r.entries));e.extract=(p,l)=>{let f={};for(let m of p)if(a.has(m))f[m]=r.entries[m];else throw Error(`Key ${m} not found in enum`);return new Kr({...r,checks:[],...b(l),entries:f})},e.exclude=(p,l)=>{let f={...r.entries};for(let m of p)if(a.has(m))delete f[m];else throw Error(`Key ${m} not found in enum`);return new Kr({...r,checks:[],...b(l),entries:f})}});function s(e,r){let a=Array.isArray(e)?Object.fromEntries(e.map((p)=>[p,p])):e;return new Kr({type:"enum",entries:a,...b(r)})}var Hi=z("ZodLiteral",(e,r)=>{un.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>kr(e,a,p,l),e.values=new Set(r.values),Object.defineProperty(e,"value",{get(){if(r.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function n(e,r){return new Hi({type:"literal",values:Array.isArray(e)?e:[e],...b(r)})}var Qi=z("ZodTransform",(e,r)=>{an.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Pr(e,a,p,l),e._zod.parse=(a,p)=>{if(p.direction==="backward")throw new ue(e.constructor.name);a.addIssue=(f)=>{if(typeof f==="string")a.issues.push(te(f,a.value,r));else{let m=f;if(m.fatal)m.continue=!1;m.code??(m.code="custom"),m.input??(m.input=a.value),m.inst??(m.inst=e),a.issues.push(te(m))}};let l=r.transform(a.value,a);if(l instanceof Promise)return l.then((f)=>(a.value=f,a.fallback=!0,a));return a.value=l,a.fallback=!0,a}});function ec(e){return new Qi({type:"transform",transform:e})}var Gs=z("ZodOptional",(e,r)=>{nr.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Ue(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function Us(e){return new Gs({type:"optional",innerType:e})}var rc=z("ZodExactOptional",(e,r)=>{pn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Ue(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function tc(e){return new rc({type:"optional",innerType:e})}var oc=z("ZodNullable",(e,r)=>{ln.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Nr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function Ms(e){return new oc({type:"nullable",innerType:e})}var nc=z("ZodDefault",(e,r)=>{fn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>jr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sc(e,r){return new nc({type:"default",innerType:e,get defaultValue(){return typeof r==="function"?r():Ke(r)}})}var ic=z("ZodPrefault",(e,r)=>{dn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Cr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function cc(e,r){return new ic({type:"prefault",innerType:e,get defaultValue(){return typeof r==="function"?r():Ke(r)}})}var qs=z("ZodNonOptional",(e,r)=>{mn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Ar(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function uc(e,r){return new qs({type:"nonoptional",innerType:e,...b(r)})}var ac=z("ZodCatch",(e,r)=>{hn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Rr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pc(e,r){return new ac({type:"catch",innerType:e,catchValue:typeof r==="function"?r:()=>r})}var lc=z("ZodPipe",(e,r)=>{_n.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Dr(e,a,p,l),e.in=r.in,e.out=r.out});function Js(e,r){return new lc({type:"pipe",in:e,out:r})}var fc=z("ZodReadonly",(e,r)=>{gn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Lr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function dc(e){return new fc({type:"readonly",innerType:e})}var mc=z("ZodLazy",(e,r)=>{xn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Fr(e,a,p,l),e.unwrap=()=>e._zod.def.getter()});function Fo(e){return new mc({type:"lazy",getter:e})}var Ys=z("ZodCustom",(e,r)=>{zn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Zr(e,a,p,l)});function on(e,r){return Qn(Ys,e??(()=>!0),r)}function hc(e,r={}){return es(Ys,e,r)}function _c(e,r){return ts(e,r)}export{$o,L,Pi,Ti,Bo,nn,y,t,Et,k,xt,o,d,rs,Ie,Ri,u,i,c,ns,W,_,ee,is,s,n,Fo,on};
|