alchemylab-opencode 2.0.1 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/NODE_COMPAT.md +8 -1
  2. package/dist/20260127222353_familiar_lady_ursula-YYOFSQD5.js +18 -0
  3. package/dist/20260211171708_add_project_commands-3GKQTPBZ.js +18 -0
  4. package/dist/20260213144116_wakeful_the_professor-ROO7OAVL.js +18 -0
  5. package/dist/20260225215848_workspace-V2OZTNFF.js +18 -0
  6. package/dist/20260227213759_add_session_workspace_id-GVDWAXKM.js +18 -0
  7. package/dist/20260228203230_blue_harpoon-Z5QP2II5.js +18 -0
  8. package/dist/20260303231226_add_workspace_fields-QOVAFN7W.js +18 -0
  9. package/dist/20260309230000_move_org_to_state-RQURSDZD.js +18 -0
  10. package/dist/20260312043431_session_message_cursor-VBISKDXL.js +18 -0
  11. package/dist/20260323234822_events-PILJHLNA.js +18 -0
  12. package/dist/20260410174513_workspace-name-63YCZ5NS.js +18 -0
  13. package/dist/20260413175956_chief_energizer-NMAZYGDO.js +18 -0
  14. package/dist/20260423070820_add_icon_url_override-RAJCVNEP.js +18 -0
  15. package/dist/20260427172553_slow_nightmare-ULYYZLR4.js +18 -0
  16. package/dist/20260428004200_add_session_path-U4WO2TGE.js +18 -0
  17. package/dist/20260501142318_next_venus-6BCYATSC.js +18 -0
  18. package/dist/20260504145000_add_sync_owner-RGVHV6LN.js +18 -0
  19. package/dist/20260507164347_add_workspace_time-GE6UHNPM.js +18 -0
  20. package/dist/{20260510033149_session_usage-UGBVOXZB.js → 20260510033149_session_usage-7XHCFVKY.js} +5 -1
  21. package/dist/20260511000411_data_migration_state-2EGZKFLB.js +18 -0
  22. package/dist/20260511173437_session-metadata-K322YY33.js +18 -0
  23. package/dist/20260601010001_normalize_storage_paths-VZDTY366.js +18 -0
  24. package/dist/{20260225215848_workspace-ZMSOZSPA.js → 20260601202201_amazing_prowler-YT6PLK3L.js} +5 -1
  25. package/dist/{20260228203230_blue_harpoon-IW3Z4TQZ.js → 20260602002951_lowly_union_jack-6VLQTBVB.js} +5 -1
  26. package/dist/20260602182828_add_project_directories-TVSRD25A.js +18 -0
  27. package/dist/20260603001617_session_message_projection_indexes-PHKTF6HK.js +18 -0
  28. package/dist/{20260622170816_reset_v2_session_state-5JPHJTZG.js → 20260603040000_session_message_projection_order-7RTV2POG.js} +5 -1
  29. package/dist/20260603141458_session_input_inbox-RSBWABG7.js +18 -0
  30. package/dist/20260603160727_jittery_ezekiel_stane-DXBLLRVV.js +18 -0
  31. package/dist/20260604172448_event_sourced_session_input-H6Z3JEBD.js +18 -0
  32. package/dist/20260605003541_add_session_context_snapshot-6FDPM2TK.js +18 -0
  33. package/dist/20260605042240_add_context_epoch_agent-C2OF2UKR.js +18 -0
  34. package/dist/20260611035744_credential-YNZ47FSH.js +18 -0
  35. package/dist/20260611192811_lush_chimera-E357VI6P.js +18 -0
  36. package/dist/20260612174303_project_dir_strategy-VUGGK42O.js +18 -0
  37. package/dist/20260622142730_simplify_session_context_epoch-UYGXZ5BX.js +18 -0
  38. package/dist/20260622170816_reset_v2_session_state-EILLPCJQ.js +18 -0
  39. package/dist/20260622202450_simplify_session_input-Y65GDGBO.js +18 -0
  40. package/dist/NodeSdk-AGMQWBHH.js +18 -0
  41. package/dist/anthropic-45OFTLAW.js +18 -0
  42. package/dist/anthropic-FVULF7C3.js +18 -0
  43. package/dist/app-runtime-LDQWNGWP.js +18 -0
  44. package/dist/chunk-2JE3QYG6.js +18 -0
  45. package/dist/chunk-2MRHL4B2.js +18 -0
  46. package/dist/chunk-4GJE6OMN.js +190 -0
  47. package/dist/chunk-4MBUHJHY.js +22 -0
  48. package/dist/chunk-5BLZCAU6.js +55 -0
  49. package/dist/chunk-7XX6TY62.js +259 -0
  50. package/dist/chunk-ANF3QA3Z.js +48 -0
  51. package/dist/chunk-AZUMH3TO.js +18 -0
  52. package/dist/chunk-B74WSFN4.js +878 -0
  53. package/dist/chunk-BQ4IEPN3.js +19 -0
  54. package/dist/chunk-CYRZU5QM.js +33 -0
  55. package/dist/chunk-DADVNQTM.js +1490 -0
  56. package/dist/chunk-DO2UZ6NY.js +18 -0
  57. package/dist/chunk-DWEYXIQI.js +780 -0
  58. package/dist/chunk-EK6FQQHY.js +20 -0
  59. package/dist/chunk-ELPXQ32J.js +90 -0
  60. package/dist/chunk-FGLPSSRK.js +19 -0
  61. package/dist/chunk-FOHYZ7MJ.js +55 -0
  62. package/dist/chunk-FV7U6PVP.js +18 -0
  63. package/dist/chunk-FYYAOZPU.js +18 -0
  64. package/dist/chunk-G7PFO5HG.js +920 -0
  65. package/dist/chunk-GDWO6EXN.js +22 -0
  66. package/dist/chunk-GW3ZRKAI.js +20 -0
  67. package/dist/chunk-IYUSBBGY.js +35 -0
  68. package/dist/chunk-JPOFLMNH.js +18 -0
  69. package/dist/{chunk-VURLSDCB.js → chunk-K5LKDIVU.js} +4 -0
  70. package/dist/chunk-KS4WLVK5.js +19 -0
  71. package/dist/chunk-LIXP4TPL.js +18 -0
  72. package/dist/chunk-LSC4RT5V.js +36 -0
  73. package/dist/chunk-M5A6NFHQ.js +28 -0
  74. package/dist/chunk-M6E6KNLV.js +30 -0
  75. package/dist/chunk-MLFZXUGQ.js +18 -0
  76. package/dist/chunk-NDI67DRG.js +31 -0
  77. package/dist/chunk-NGT6LCW6.js +18 -0
  78. package/dist/chunk-OCWGUTZJ.js +36 -0
  79. package/dist/chunk-OGDRUXMJ.js +18 -0
  80. package/dist/chunk-OGJKLJC7.js +29 -0
  81. package/dist/chunk-OT2YNR56.js +19 -0
  82. package/dist/chunk-OUVSKG2H.js +19 -0
  83. package/dist/chunk-P5RLCJUV.js +18 -0
  84. package/dist/chunk-Q3WIUQXB.js +18 -0
  85. package/dist/{20260227213759_add_session_workspace_id-ROENWPKA.js → chunk-QCRIXKIC.js} +5 -1
  86. package/dist/chunk-QD24DLUD.js +18 -0
  87. package/dist/chunk-R2GWBJEP.js +18 -0
  88. package/dist/chunk-RPAXSOGH.js +18 -0
  89. package/dist/chunk-TK5R7QUN.js +18 -0
  90. package/dist/chunk-TNQWZFIZ.js +28 -0
  91. package/dist/chunk-UCLPBO4I.js +18 -0
  92. package/dist/chunk-UPEPL4I2.js +18 -0
  93. package/dist/chunk-V6FDDNGV.js +117 -0
  94. package/dist/chunk-V6HERYFV.js +18 -0
  95. package/dist/chunk-V7XKKJ7X.js +24 -0
  96. package/dist/chunk-VHDYUBBS.js +23 -0
  97. package/dist/chunk-VWLJXTZ5.js +18 -0
  98. package/dist/chunk-VXAPFOIL.js +22 -0
  99. package/dist/chunk-WKZYINC7.js +29 -0
  100. package/dist/chunk-WPMP2ZFE.js +40 -0
  101. package/dist/chunk-WRTNIOI3.js +18 -0
  102. package/dist/chunk-X5F46HR5.js +18 -0
  103. package/dist/chunk-XPS7TQZG.js +22 -0
  104. package/dist/chunk-YJPP6IQ3.js +23 -0
  105. package/dist/chunk-ZYQWFC55.js +22 -0
  106. package/dist/code-mode-YYOGD36U.js +502 -0
  107. package/dist/copilot-provider-QVMLQZZC.js +18 -0
  108. package/dist/dist-5NQOHNPL.js +18 -0
  109. package/dist/dist-7CT3XCNN.js +32 -0
  110. package/dist/dist-CL46WFZG.js +18 -0
  111. package/dist/{20260605042240_add_context_epoch_agent-W6IQYZXE.js → dist-CYBRID2F.js} +5 -1
  112. package/dist/dist-HXJTF22W.js +32 -0
  113. package/dist/dist-JFXI53ZF.js +22 -0
  114. package/dist/dist-KBYKWVT5.js +22 -0
  115. package/dist/dist-KM5HCPZX.js +35 -0
  116. package/dist/dist-KTNLTEHB.js +18 -0
  117. package/dist/dist-KZ5R5QM5.js +24 -0
  118. package/dist/dist-NLXUYBW7.js +32 -0
  119. package/dist/dist-O4DF72J2.js +22 -0
  120. package/dist/dist-PH4MEGVR.js +22 -0
  121. package/dist/{20260511000411_data_migration_state-FB4LBFSE.js → dist-QJPOJCLB.js} +5 -1
  122. package/dist/dist-QYH62TCJ.js +22 -0
  123. package/dist/{20260303231226_add_workspace_fields-OUVZMNAG.js → dist-RIC4WKHC.js} +5 -1
  124. package/dist/dist-T776XKTM.js +22 -0
  125. package/dist/dist-TCE5MKZQ.js +23 -0
  126. package/dist/dist-TH2Q44RX.js +50 -0
  127. package/dist/dist-VV5FV5RT.js +101 -0
  128. package/dist/dist-XAFENVUS.js +22 -0
  129. package/dist/dist-XPFB35TX.js +32 -0
  130. package/dist/dist-YUH4RKR5.js +28 -0
  131. package/dist/dist-es-43ZM44MP.js +18 -0
  132. package/dist/dist-es-6PLFRCS4.js +18 -0
  133. package/dist/dist-es-G5UIJOU7.js +26 -0
  134. package/dist/{20260428004200_add_session_path-LGW75WYA.js → dist-es-HYIIGUNX.js} +5 -1
  135. package/dist/dist-es-L2GU465G.js +18 -0
  136. package/dist/dist-es-LSR2QCFZ.js +18 -0
  137. package/dist/dist-es-RGEIM2BP.js +18 -0
  138. package/dist/dist-es-SITTNOGV.js +18 -0
  139. package/dist/dist-es-W5GYOX6F.js +18 -0
  140. package/dist/esm-NN5W7YCL.js +18 -0
  141. package/dist/esm-XWJSHYHG.js +18 -0
  142. package/dist/getMachineId-bsd-L5I5TZ5I.js +18 -0
  143. package/dist/getMachineId-darwin-YB7KG37W.js +19 -0
  144. package/dist/getMachineId-linux-EL47KXX7.js +18 -0
  145. package/dist/getMachineId-unsupported-QOWPEBPN.js +18 -0
  146. package/dist/getMachineId-win-HCRYRDFJ.js +18 -0
  147. package/dist/lib-ZP7Q6A3E.js +199 -0
  148. package/dist/loadCognitoIdentity-EWT55EI7.js +18 -0
  149. package/dist/loadSso-AGOUE6RL.js +18 -0
  150. package/dist/{20260213144116_wakeful_the_professor-ZVDD54AK.js → loadSts-RH5L3PIX.js} +5 -1
  151. package/dist/mantle-IJXDXT4M.js +25 -0
  152. package/dist/mime-types-46EO4HOZ.js +18 -0
  153. package/dist/multipart-parser-KZWMKXA4.js +19 -0
  154. package/dist/{20260211171708_add_project_commands-GDOHPDPF.js → open-7KXTRM37.js} +5 -1
  155. package/dist/openai-ZOJI6I5R.js +18 -0
  156. package/dist/p-map-CYL6ILJW.js +18 -0
  157. package/dist/photon-W56QZY4L.js +18 -0
  158. package/dist/{20260423070820_add_icon_url_override-X5SHFGTI.js → pkce-VT4ITJTB.js} +5 -1
  159. package/dist/{pty.node-Y3N2XKYG.js → pty.node-IWULXXG6.js} +5 -1
  160. package/dist/run.js +5 -1
  161. package/dist/serve.js +143 -1
  162. package/dist/server-LVIHYOCY.js +21 -0
  163. package/dist/session-6OPJNJMK.js +18 -0
  164. package/dist/signin-OCIW23YM.js +18 -0
  165. package/dist/src-3NCXEROI.js +18 -0
  166. package/dist/src-LXWGIUZH.js +18 -0
  167. package/dist/src-WDYKISPD.js +20 -0
  168. package/dist/src-YAAFIGTW.js +18 -0
  169. package/dist/sso-oidc-OMMKINFE.js +18 -0
  170. package/dist/sts-MWK22JIX.js +18 -0
  171. package/dist/token-QPO3OAGS.js +18 -0
  172. package/dist/token-util-YGPCEEPO.js +18 -0
  173. package/dist/unified-W3ZKZ4HG.js +18 -0
  174. package/dist/worktree-32M5MTFE.js +18 -0
  175. package/package.json +40 -40
  176. package/postinstall.cjs +4 -2
  177. package/dist/20260127222353_familiar_lady_ursula-KV747FJX.js +0 -14
  178. package/dist/20260309230000_move_org_to_state-NOXAPU5V.js +0 -14
  179. package/dist/20260312043431_session_message_cursor-DJ4T3T4R.js +0 -14
  180. package/dist/20260323234822_events-72GIKJ2A.js +0 -14
  181. package/dist/20260410174513_workspace-name-JXSWFBJN.js +0 -14
  182. package/dist/20260413175956_chief_energizer-4HEWZ6U3.js +0 -14
  183. package/dist/20260427172553_slow_nightmare-PS5T2AH2.js +0 -14
  184. package/dist/20260501142318_next_venus-J3TLVXZ6.js +0 -14
  185. package/dist/20260504145000_add_sync_owner-3R52GB4C.js +0 -14
  186. package/dist/20260507164347_add_workspace_time-JHDRCZAR.js +0 -14
  187. package/dist/20260511173437_session-metadata-T2XHGWHS.js +0 -14
  188. package/dist/20260601010001_normalize_storage_paths-5MAY5GT3.js +0 -14
  189. package/dist/20260601202201_amazing_prowler-PET224YG.js +0 -14
  190. package/dist/20260602002951_lowly_union_jack-PG6XDMGL.js +0 -14
  191. package/dist/20260602182828_add_project_directories-ZCH2ACGG.js +0 -14
  192. package/dist/20260603001617_session_message_projection_indexes-XVLJTUF2.js +0 -14
  193. package/dist/20260603040000_session_message_projection_order-XG6RACZQ.js +0 -14
  194. package/dist/20260603141458_session_input_inbox-K2VQ7V6E.js +0 -14
  195. package/dist/20260603160727_jittery_ezekiel_stane-WKJLRDO7.js +0 -14
  196. package/dist/20260604172448_event_sourced_session_input-NTXOECR7.js +0 -14
  197. package/dist/20260605003541_add_session_context_snapshot-DXMQEXMT.js +0 -14
  198. package/dist/20260611035744_credential-XTMSYTJD.js +0 -14
  199. package/dist/20260611192811_lush_chimera-XPLIQMJD.js +0 -14
  200. package/dist/20260612174303_project_dir_strategy-FR2NGQKK.js +0 -14
  201. package/dist/20260622142730_simplify_session_context_epoch-NTQZR3RE.js +0 -14
  202. package/dist/20260622202450_simplify_session_input-2EXF2HMV.js +0 -14
  203. package/dist/app-runtime-HQBOCDV5.js +0 -14
  204. package/dist/chunk-4FEBIOI5.js +0 -865
  205. package/dist/chunk-4K2RXRZL.js +0 -14
  206. package/dist/chunk-4RFMKEKM.js +0 -1455
  207. package/dist/chunk-BM2C7NHL.js +0 -41
  208. package/dist/chunk-MKEMZFJI.js +0 -393
  209. package/dist/chunk-OMDJ6ZZ2.js +0 -684
  210. package/dist/chunk-OWMG4NNF.js +0 -186
  211. package/dist/chunk-QRABYJKL.js +0 -14
  212. package/dist/chunk-RHIWAYN5.js +0 -14
  213. package/dist/chunk-Z5TLIUAI.js +0 -28
  214. package/dist/code-mode-7BQJUARW.js +0 -40
  215. package/dist/copilot-provider-TX4YFKJZ.js +0 -14
  216. package/dist/photon-VQS5F5BI.js +0 -14
  217. package/dist/server-BFUQR7MX.js +0 -17
  218. package/dist/session-6RNXZNG6.js +0 -14
  219. package/dist/worktree-QHQHX3SG.js +0 -14
  220. package/patches/@ai-sdk%2Famazon-bedrock@4.0.166.patch +0 -164
  221. package/patches/@ai-sdk%2Fanthropic@3.0.111.patch +0 -528
  222. package/patches/@ai-sdk%2Fgoogle@3.0.73.patch +0 -69
  223. package/patches/@ai-sdk%2Fgroq@3.0.31.patch +0 -79
  224. package/patches/@ai-sdk%2Fmistral@3.0.51.patch +0 -714
  225. package/patches/@ai-sdk%2Fopenai-compatible@2.0.41.patch +0 -39
  226. package/patches/@ai-sdk%2Fopenai@3.0.88.patch +0 -280
  227. package/patches/@ai-sdk%2Fxai@3.0.139.patch +0 -296
  228. package/patches/@modelcontextprotocol%2Fsdk@1.29.0.patch +0 -647
  229. package/patches/@npmcli%2Fagent@4.0.2.patch +0 -13
  230. package/patches/effect@4.0.0-beta.83.patch +0 -57
  231. package/patches/gcp-metadata@8.1.2.patch +0 -14
  232. package/patches/pacote@21.5.0.patch +0 -18
@@ -0,0 +1,18 @@
1
+ // Built by esbuild from opencode-server source
2
+ if (typeof globalThis.Bun === 'undefined') {
3
+ globalThis.Bun = {
4
+ version: '0.0.0-node-compat',
5
+ stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
+ which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
+ };
8
+ }
9
+ if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
+ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
+ import { createRequire as __alchemyCreateRequire } from 'node:module';
12
+ const require = __alchemyCreateRequire(import.meta.url);
13
+ import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
14
+ import { dirname as __alchemyDirname } from 'node:path';
15
+ const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
16
+ const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
17
+
18
+ import{a as c}from"./chunk-2MRHL4B2.js";var x;(function(r){r.assertEqual=a=>{};function e(a){}c(e,"assertIs"),r.assertIs=e;function t(a){throw new Error}c(t,"assertNever"),r.assertNever=t,r.arrayToEnum=a=>{let n={};for(let i of a)n[i]=i;return n},r.getValidEnumValues=a=>{let n=r.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),i={};for(let o of n)i[o]=a[o];return r.objectValues(i)},r.objectValues=a=>r.objectKeys(a).map(function(n){return a[n]}),r.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let n=[];for(let i in a)Object.prototype.hasOwnProperty.call(a,i)&&n.push(i);return n},r.find=(a,n)=>{for(let i of a)if(n(i))return i},r.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function s(a,n=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(n)}c(s,"joinValues"),r.joinValues=s,r.jsonStringifyReplacer=(a,n)=>typeof n=="bigint"?n.toString():n})(x||(x={}));var we;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(we||(we={}));var l=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),N=c(r=>{switch(typeof r){case"undefined":return l.undefined;case"string":return l.string;case"number":return Number.isNaN(r)?l.nan:l.number;case"boolean":return l.boolean;case"function":return l.function;case"bigint":return l.bigint;case"symbol":return l.symbol;case"object":return Array.isArray(r)?l.array:r===null?l.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?l.promise:typeof Map<"u"&&r instanceof Map?l.map:typeof Set<"u"&&r instanceof Set?l.set:typeof Date<"u"&&r instanceof Date?l.date:l.object;default:return l.unknown}},"getParsedType");var d=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);var w=class r extends Error{static{c(this,"ZodError")}get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(n){return n.message},s={_errors:[]},a=c(n=>{for(let i of n.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,h=0;for(;h<i.path.length;){let f=i.path[h];h===i.path.length-1?(o[f]=o[f]||{_errors:[]},o[f]._errors.push(t(i))):o[f]=o[f]||{_errors:[]},o=o[f],h++}}},"processError");return a(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},s=[];for(let a of this.issues)if(a.path.length>0){let n=a.path[0];t[n]=t[n]||[],t[n].push(e(a))}else s.push(e(a));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};w.create=r=>new w(r);var Ae=c((r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===l.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}},"errorMap"),Z=Ae;var Re=Z;function K(){return Re}c(K,"getErrorMap");var p;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}));var le=c(r=>{let{data:e,path:t,errorMaps:s,issueData:a}=r,n=[...t,...a.path||[]],i={...a,path:n};if(a.message!==void 0)return{...a,path:n,message:a.message};let o="",h=s.filter(f=>!!f).slice().reverse();for(let f of h)o=f(i,{data:e,defaultError:o}).message;return{...a,path:n,message:o}},"makeIssue");function u(r,e){let t=K(),s=le({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Z?void 0:Z].filter(a=>!!a)});r.common.issues.push(s)}c(u,"addIssueToContext");var k=class r{static{c(this,"ParseStatus")}constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let a of t){if(a.status==="aborted")return m;a.status==="dirty"&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let a of t){let n=await a.key,i=await a.value;s.push({key:n,value:i})}return r.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let a of t){let{key:n,value:i}=a;if(n.status==="aborted"||i.status==="aborted")return m;n.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(s[n.value]=i.value)}return{status:e.value,value:s}}},m=Object.freeze({status:"aborted"}),z=c(r=>({status:"dirty",value:r}),"DIRTY"),b=c(r=>({status:"valid",value:r}),"OK"),me=c(r=>r.status==="aborted","isAborted"),ye=c(r=>r.status==="dirty","isDirty"),V=c(r=>r.status==="valid","isValid"),ee=c(r=>typeof Promise<"u"&&r instanceof Promise,"isAsync");var O=class{static{c(this,"ParseInputLazyPath")}constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Te=c((r,e)=>{if(V(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new w(r.common.issues);return this._error=t,this._error}}},"handleResult");function _(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:s,description:a}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:c((i,o)=>{let{message:h}=r;return i.code==="invalid_enum_value"?{message:h??o.defaultError}:typeof o.data>"u"?{message:h??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:h??t??o.defaultError}},"customMap"),description:a}}c(_,"processCreateParams");var g=class{static{c(this,"ZodType")}get description(){return this._def.description}_getType(e){return N(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:N(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new k,ctx:{common:e.parent.common,data:e.data,parsedType:N(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ee(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:N(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Te(s,a)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:N(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return V(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>V(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:N(e)},a=this._parse({data:e,path:s.path,parent:s}),n=await(ee(a)?a:Promise.resolve(a));return Te(s,n)}refine(e,t){let s=c(a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t,"getIssueProperties");return this._refinement((a,n)=>{let i=e(a),o=c(()=>n.addIssue({code:d.custom,...s(a)}),"setError");return typeof Promise<"u"&&i instanceof Promise?i.then(h=>h?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,a)=>e(s)?!0:(a.addIssue(typeof t=="function"?t(s,a):t),!1))}_refinement(e){return new A({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:c(t=>this["~validate"](t),"validate")}}optional(){return S.create(this,this._def)}nullable(){return E.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return M.create(this)}promise(){return P.create(this,this._def)}or(e){return B.create([this,e],this._def)}and(e){return W.create(this,e,this._def)}transform(e){return new A({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new G({..._(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new fe({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Q({..._(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return he.create(this,e)}readonly(){return X.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ne=/^c[^\s-]{8,}$/i,je=/^[0-9a-z]+$/,Ie=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ee=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ze=/^[a-z0-9_-]{21}$/i,$e=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Me=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ve=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Pe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",_e,ze=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,De=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Le=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ue=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Fe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Be=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ce="((\\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])))",We=new RegExp(`^${Ce}$`);function Oe(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}c(Oe,"timeRegexSource");function qe(r){return new RegExp(`^${Oe(r)}$`)}c(qe,"timeRegex");function Je(r){let e=`${Ce}T${Oe(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}c(Je,"datetimeRegex");function Ye(r,e){return!!((e==="v4"||!e)&&ze.test(r)||(e==="v6"||!e)&&Le.test(r))}c(Ye,"isValidIP");function He(r,e){if(!$e.test(r))return!1;try{let[t]=r.split(".");if(!t)return!1;let s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(s));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}c(He,"isValidJWT");function Ge(r,e){return!!((e==="v4"||!e)&&De.test(r)||(e==="v6"||!e)&&Ue.test(r))}c(Ge,"isValidCidr");var L=class r extends g{static{c(this,"ZodString")}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==l.string){let n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:l.string,received:n.parsedType}),m}let s=new k,a;for(let n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:d.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),s.dirty());else if(n.kind==="max")e.data.length>n.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:d.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),s.dirty());else if(n.kind==="length"){let i=e.data.length>n.value,o=e.data.length<n.value;(i||o)&&(a=this._getOrReturnCtx(e,a),i?u(a,{code:d.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):o&&u(a,{code:d.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),s.dirty())}else if(n.kind==="email")Ve.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"email",code:d.invalid_string,message:n.message}),s.dirty());else if(n.kind==="emoji")_e||(_e=new RegExp(Pe,"u")),_e.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"emoji",code:d.invalid_string,message:n.message}),s.dirty());else if(n.kind==="uuid")Ee.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"uuid",code:d.invalid_string,message:n.message}),s.dirty());else if(n.kind==="nanoid")Ze.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"nanoid",code:d.invalid_string,message:n.message}),s.dirty());else if(n.kind==="cuid")Ne.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cuid",code:d.invalid_string,message:n.message}),s.dirty());else if(n.kind==="cuid2")je.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cuid2",code:d.invalid_string,message:n.message}),s.dirty());else if(n.kind==="ulid")Ie.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"ulid",code:d.invalid_string,message:n.message}),s.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),u(a,{validation:"url",code:d.invalid_string,message:n.message}),s.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"regex",code:d.invalid_string,message:n.message}),s.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(a=this._getOrReturnCtx(e,a),u(a,{code:d.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),s.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(a=this._getOrReturnCtx(e,a),u(a,{code:d.invalid_string,validation:{startsWith:n.value},message:n.message}),s.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(a=this._getOrReturnCtx(e,a),u(a,{code:d.invalid_string,validation:{endsWith:n.value},message:n.message}),s.dirty()):n.kind==="datetime"?Je(n).test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:d.invalid_string,validation:"datetime",message:n.message}),s.dirty()):n.kind==="date"?We.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:d.invalid_string,validation:"date",message:n.message}),s.dirty()):n.kind==="time"?qe(n).test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:d.invalid_string,validation:"time",message:n.message}),s.dirty()):n.kind==="duration"?Me.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"duration",code:d.invalid_string,message:n.message}),s.dirty()):n.kind==="ip"?Ye(e.data,n.version)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"ip",code:d.invalid_string,message:n.message}),s.dirty()):n.kind==="jwt"?He(e.data,n.alg)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"jwt",code:d.invalid_string,message:n.message}),s.dirty()):n.kind==="cidr"?Ge(e.data,n.version)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cidr",code:d.invalid_string,message:n.message}),s.dirty()):n.kind==="base64"?Fe.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"base64",code:d.invalid_string,message:n.message}),s.dirty()):n.kind==="base64url"?Be.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"base64url",code:d.invalid_string,message:n.message}),s.dirty()):x.assertNever(n);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(a=>e.test(a),{validation:t,code:d.invalid_string,...p.errToObj(s)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...p.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...p.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};L.create=r=>new L({checks:[],typeName:y.ZodString,coerce:r?.coerce??!1,..._(r)});function Qe(r,e){let t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,a=t>s?t:s,n=Number.parseInt(r.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return n%i/10**a}c(Qe,"floatSafeRemainder");var te=class r extends g{static{c(this,"ZodNumber")}constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==l.number){let n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:l.number,received:n.parsedType}),m}let s,a=new k;for(let n of this._def.checks)n.kind==="int"?x.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_type,expected:"integer",received:"float",message:n.message}),a.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="multipleOf"?Qe(e.data,n.value)!==0&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.not_finite,message:n.message}),a.dirty()):x.assertNever(n);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,a){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(a)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};te.create=r=>new te({checks:[],typeName:y.ZodNumber,coerce:r?.coerce||!1,..._(r)});var re=class r extends g{static{c(this,"ZodBigInt")}constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==l.bigint)return this._getInvalidInput(e);let s,a=new k;for(let n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):x.assertNever(n);return{status:a.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:l.bigint,received:t.parsedType}),m}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,a){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(a)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};re.create=r=>new re({checks:[],typeName:y.ZodBigInt,coerce:r?.coerce??!1,..._(r)});var se=class extends g{static{c(this,"ZodBoolean")}_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==l.boolean){let s=this._getOrReturnCtx(e);return u(s,{code:d.invalid_type,expected:l.boolean,received:s.parsedType}),m}return b(e.data)}};se.create=r=>new se({typeName:y.ZodBoolean,coerce:r?.coerce||!1,..._(r)});var ae=class r extends g{static{c(this,"ZodDate")}_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==l.date){let n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:l.date,received:n.parsedType}),m}if(Number.isNaN(e.data.getTime())){let n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_date}),m}let s=new k,a;for(let n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:d.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),s.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:d.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),s.dirty()):x.assertNever(n);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};ae.create=r=>new ae({checks:[],coerce:r?.coerce||!1,typeName:y.ZodDate,..._(r)});var ne=class extends g{static{c(this,"ZodSymbol")}_parse(e){if(this._getType(e)!==l.symbol){let s=this._getOrReturnCtx(e);return u(s,{code:d.invalid_type,expected:l.symbol,received:s.parsedType}),m}return b(e.data)}};ne.create=r=>new ne({typeName:y.ZodSymbol,..._(r)});var U=class extends g{static{c(this,"ZodUndefined")}_parse(e){if(this._getType(e)!==l.undefined){let s=this._getOrReturnCtx(e);return u(s,{code:d.invalid_type,expected:l.undefined,received:s.parsedType}),m}return b(e.data)}};U.create=r=>new U({typeName:y.ZodUndefined,..._(r)});var F=class extends g{static{c(this,"ZodNull")}_parse(e){if(this._getType(e)!==l.null){let s=this._getOrReturnCtx(e);return u(s,{code:d.invalid_type,expected:l.null,received:s.parsedType}),m}return b(e.data)}};F.create=r=>new F({typeName:y.ZodNull,..._(r)});var ie=class extends g{static{c(this,"ZodAny")}constructor(){super(...arguments),this._any=!0}_parse(e){return b(e.data)}};ie.create=r=>new ie({typeName:y.ZodAny,..._(r)});var $=class extends g{static{c(this,"ZodUnknown")}constructor(){super(...arguments),this._unknown=!0}_parse(e){return b(e.data)}};$.create=r=>new $({typeName:y.ZodUnknown,..._(r)});var R=class extends g{static{c(this,"ZodNever")}_parse(e){let t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:l.never,received:t.parsedType}),m}};R.create=r=>new R({typeName:y.ZodNever,..._(r)});var oe=class extends g{static{c(this,"ZodVoid")}_parse(e){if(this._getType(e)!==l.undefined){let s=this._getOrReturnCtx(e);return u(s,{code:d.invalid_type,expected:l.void,received:s.parsedType}),m}return b(e.data)}};oe.create=r=>new oe({typeName:y.ZodVoid,..._(r)});var M=class r extends g{static{c(this,"ZodArray")}_parse(e){let{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==l.array)return u(t,{code:d.invalid_type,expected:l.array,received:t.parsedType}),m;if(a.exactLength!==null){let i=t.data.length>a.exactLength.value,o=t.data.length<a.exactLength.value;(i||o)&&(u(t,{code:i?d.too_big:d.too_small,minimum:o?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(u(t,{code:d.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(u(t,{code:d.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>a.type._parseAsync(new O(t,i,t.path,o)))).then(i=>k.mergeArray(s,i));let n=[...t.data].map((i,o)=>a.type._parseSync(new O(t,i,t.path,o)));return k.mergeArray(s,n)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}};M.create=(r,e)=>new M({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});function D(r){if(r instanceof T){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=S.create(D(s))}return new T({...r._def,shape:c(()=>e,"shape")})}else return r instanceof M?new M({...r._def,type:D(r.element)}):r instanceof S?S.create(D(r.unwrap())):r instanceof E?E.create(D(r.unwrap())):r instanceof I?I.create(r.items.map(e=>D(e))):r}c(D,"deepPartialify");var T=class r extends g{static{c(this,"ZodObject")}constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==l.object){let f=this._getOrReturnCtx(e);return u(f,{code:d.invalid_type,expected:l.object,received:f.parsedType}),m}let{status:s,ctx:a}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof R&&this._def.unknownKeys==="strip"))for(let f in a.data)i.includes(f)||o.push(f);let h=[];for(let f of i){let v=n[f],C=a.data[f];h.push({key:{status:"valid",value:f},value:v._parse(new O(a,C,a.path,f)),alwaysSet:f in a.data})}if(this._def.catchall instanceof R){let f=this._def.unknownKeys;if(f==="passthrough")for(let v of o)h.push({key:{status:"valid",value:v},value:{status:"valid",value:a.data[v]}});else if(f==="strict")o.length>0&&(u(a,{code:d.unrecognized_keys,keys:o}),s.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let f=this._def.catchall;for(let v of o){let C=a.data[v];h.push({key:{status:"valid",value:v},value:f._parse(new O(a,C,a.path,v)),alwaysSet:v in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let f=[];for(let v of h){let C=await v.key,be=await v.value;f.push({key:C,value:be,alwaysSet:v.alwaysSet})}return f}).then(f=>k.mergeObjectSync(s,f)):k.mergeObjectSync(s,h)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:c((t,s)=>{let a=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:p.errToObj(e).message??a}:{message:a}},"errorMap")}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:c(()=>({...this._def.shape(),...e}),"shape")})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:c(()=>({...this._def.shape(),...e._def.shape()}),"shape"),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let s of x.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new r({...this._def,shape:c(()=>t,"shape")})}omit(e){let t={};for(let s of x.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new r({...this._def,shape:c(()=>t,"shape")})}deepPartial(){return D(this)}partial(e){let t={};for(let s of x.objectKeys(this.shape)){let a=this.shape[s];e&&!e[s]?t[s]=a:t[s]=a.optional()}return new r({...this._def,shape:c(()=>t,"shape")})}required(e){let t={};for(let s of x.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof S;)n=n._def.innerType;t[s]=n}return new r({...this._def,shape:c(()=>t,"shape")})}keyof(){return Se(x.objectKeys(this.shape))}};T.create=(r,e)=>new T({shape:c(()=>r,"shape"),unknownKeys:"strip",catchall:R.create(),typeName:y.ZodObject,..._(e)});T.strictCreate=(r,e)=>new T({shape:c(()=>r,"shape"),unknownKeys:"strict",catchall:R.create(),typeName:y.ZodObject,..._(e)});T.lazycreate=(r,e)=>new T({shape:r,unknownKeys:"strip",catchall:R.create(),typeName:y.ZodObject,..._(e)});var B=class extends g{static{c(this,"ZodUnion")}_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function a(n){for(let o of n)if(o.result.status==="valid")return o.result;for(let o of n)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=n.map(o=>new w(o.ctx.common.issues));return u(t,{code:d.invalid_union,unionErrors:i}),m}if(c(a,"handleResults"),t.common.async)return Promise.all(s.map(async n=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(a);{let n,i=[];for(let h of s){let f={...t,common:{...t.common,issues:[]},parent:null},v=h._parseSync({data:t.data,path:t.path,parent:f});if(v.status==="valid")return v;v.status==="dirty"&&!n&&(n={result:v,ctx:f}),f.common.issues.length&&i.push(f.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;let o=i.map(h=>new w(h));return u(t,{code:d.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}};B.create=(r,e)=>new B({options:r,typeName:y.ZodUnion,..._(e)});var j=c(r=>r instanceof q?j(r.schema):r instanceof A?j(r.innerType()):r instanceof J?[r.value]:r instanceof Y?r.options:r instanceof H?x.objectValues(r.enum):r instanceof G?j(r._def.innerType):r instanceof U?[void 0]:r instanceof F?[null]:r instanceof S?[void 0,...j(r.unwrap())]:r instanceof E?[null,...j(r.unwrap())]:r instanceof fe||r instanceof X?j(r.unwrap()):r instanceof Q?j(r._def.innerType):[],"getDiscriminator"),ge=class r extends g{static{c(this,"ZodDiscriminatedUnion")}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==l.object)return u(t,{code:d.invalid_type,expected:l.object,received:t.parsedType}),m;let s=this.discriminator,a=t.data[s],n=this.optionsMap.get(a);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(u(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let a=new Map;for(let n of t){let i=j(n.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(a.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);a.set(o,n)}}return new r({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,..._(s)})}};function ve(r,e){let t=N(r),s=N(e);if(r===e)return{valid:!0,data:r};if(t===l.object&&s===l.object){let a=x.objectKeys(e),n=x.objectKeys(r).filter(o=>a.indexOf(o)!==-1),i={...r,...e};for(let o of n){let h=ve(r[o],e[o]);if(!h.valid)return{valid:!1};i[o]=h.data}return{valid:!0,data:i}}else if(t===l.array&&s===l.array){if(r.length!==e.length)return{valid:!1};let a=[];for(let n=0;n<r.length;n++){let i=r[n],o=e[n],h=ve(i,o);if(!h.valid)return{valid:!1};a.push(h.data)}return{valid:!0,data:a}}else return t===l.date&&s===l.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}c(ve,"mergeValues");var W=class extends g{static{c(this,"ZodIntersection")}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),a=c((n,i)=>{if(me(n)||me(i))return m;let o=ve(n.value,i.value);return o.valid?((ye(n)||ye(i))&&t.dirty(),{status:t.value,value:o.data}):(u(s,{code:d.invalid_intersection_types}),m)},"handleParsed");return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([n,i])=>a(n,i)):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};W.create=(r,e,t)=>new W({left:r,right:e,typeName:y.ZodIntersection,..._(t)});var I=class r extends g{static{c(this,"ZodTuple")}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==l.array)return u(s,{code:d.invalid_type,expected:l.array,received:s.parsedType}),m;if(s.data.length<this._def.items.length)return u(s,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&s.data.length>this._def.items.length&&(u(s,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let n=[...s.data].map((i,o)=>{let h=this._def.items[o]||this._def.rest;return h?h._parse(new O(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(n).then(i=>k.mergeArray(t,i)):k.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};I.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new I({items:r,typeName:y.ZodTuple,rest:null,..._(e)})};var xe=class r extends g{static{c(this,"ZodRecord")}get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==l.object)return u(s,{code:d.invalid_type,expected:l.object,received:s.parsedType}),m;let a=[],n=this._def.keyType,i=this._def.valueType;for(let o in s.data)a.push({key:n._parse(new O(s,o,s.path,o)),value:i._parse(new O(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?k.mergeObjectAsync(t,a):k.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof g?new r({keyType:e,valueType:t,typeName:y.ZodRecord,..._(s)}):new r({keyType:L.create(),valueType:e,typeName:y.ZodRecord,..._(t)})}},ce=class extends g{static{c(this,"ZodMap")}get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==l.map)return u(s,{code:d.invalid_type,expected:l.map,received:s.parsedType}),m;let a=this._def.keyType,n=this._def.valueType,i=[...s.data.entries()].map(([o,h],f)=>({key:a._parse(new O(s,o,s.path,[f,"key"])),value:n._parse(new O(s,h,s.path,[f,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let h of i){let f=await h.key,v=await h.value;if(f.status==="aborted"||v.status==="aborted")return m;(f.status==="dirty"||v.status==="dirty")&&t.dirty(),o.set(f.value,v.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let h of i){let f=h.key,v=h.value;if(f.status==="aborted"||v.status==="aborted")return m;(f.status==="dirty"||v.status==="dirty")&&t.dirty(),o.set(f.value,v.value)}return{status:t.value,value:o}}}};ce.create=(r,e,t)=>new ce({valueType:e,keyType:r,typeName:y.ZodMap,..._(t)});var de=class r extends g{static{c(this,"ZodSet")}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==l.set)return u(s,{code:d.invalid_type,expected:l.set,received:s.parsedType}),m;let a=this._def;a.minSize!==null&&s.data.size<a.minSize.value&&(u(s,{code:d.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&s.data.size>a.maxSize.value&&(u(s,{code:d.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());let n=this._def.valueType;function i(h){let f=new Set;for(let v of h){if(v.status==="aborted")return m;v.status==="dirty"&&t.dirty(),f.add(v.value)}return{status:t.value,value:f}}c(i,"finalizeSet");let o=[...s.data.values()].map((h,f)=>n._parse(new O(s,h,s.path,f)));return s.common.async?Promise.all(o).then(h=>i(h)):i(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:p.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};de.create=(r,e)=>new de({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});var ke=class r extends g{static{c(this,"ZodFunction")}constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==l.function)return u(t,{code:d.invalid_type,expected:l.function,received:t.parsedType}),m;function s(o,h){return le({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,K(),Z].filter(f=>!!f),issueData:{code:d.invalid_arguments,argumentsError:h}})}c(s,"makeArgsIssue");function a(o,h){return le({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,K(),Z].filter(f=>!!f),issueData:{code:d.invalid_return_type,returnTypeError:h}})}c(a,"makeReturnsIssue");let n={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof P){let o=this;return b(async function(...h){let f=new w([]),v=await o._def.args.parseAsync(h,n).catch(pe=>{throw f.addIssue(s(h,pe)),f}),C=await Reflect.apply(i,this,v);return await o._def.returns._def.type.parseAsync(C,n).catch(pe=>{throw f.addIssue(a(C,pe)),f})})}else{let o=this;return b(function(...h){let f=o._def.args.safeParse(h,n);if(!f.success)throw new w([s(h,f.error)]);let v=Reflect.apply(i,this,f.data),C=o._def.returns.safeParse(v,n);if(!C.success)throw new w([a(v,C.error)]);return C.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:I.create(e).rest($.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new r({args:e||I.create([]).rest($.create()),returns:t||$.create(),typeName:y.ZodFunction,..._(s)})}},q=class extends g{static{c(this,"ZodLazy")}get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};q.create=(r,e)=>new q({getter:r,typeName:y.ZodLazy,..._(e)});var J=class extends g{static{c(this,"ZodLiteral")}_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}};J.create=(r,e)=>new J({value:r,typeName:y.ZodLiteral,..._(e)});function Se(r,e){return new Y({values:r,typeName:y.ZodEnum,..._(e)})}c(Se,"createZodEnum");var Y=class r extends g{static{c(this,"ZodEnum")}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{expected:x.joinValues(s),received:t.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{received:t.data,code:d.invalid_enum_value,options:s}),m}return b(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};Y.create=Se;var H=class extends g{static{c(this,"ZodNativeEnum")}_parse(e){let t=x.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==l.string&&s.parsedType!==l.number){let a=x.objectValues(t);return u(s,{expected:x.joinValues(a),received:s.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let a=x.objectValues(t);return u(s,{received:s.data,code:d.invalid_enum_value,options:a}),m}return b(e.data)}get enum(){return this._def.values}};H.create=(r,e)=>new H({values:r,typeName:y.ZodNativeEnum,..._(e)});var P=class extends g{static{c(this,"ZodPromise")}unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==l.promise&&t.common.async===!1)return u(t,{code:d.invalid_type,expected:l.promise,received:t.parsedType}),m;let s=t.parsedType===l.promise?t.data:Promise.resolve(t.data);return b(s.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}};P.create=(r,e)=>new P({type:r,typeName:y.ZodPromise,..._(e)});var A=class extends g{static{c(this,"ZodEffects")}innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),a=this._def.effect||null,n={addIssue:c(i=>{u(s,i),i.fatal?t.abort():t.dirty()},"addIssue"),get path(){return s.path}};if(n.addIssue=n.addIssue.bind(n),a.type==="preprocess"){let i=a.transform(s.data,n);if(s.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return m;let h=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return h.status==="aborted"?m:h.status==="dirty"?z(h.value):t.value==="dirty"?z(h.value):h});{if(t.value==="aborted")return m;let o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?m:o.status==="dirty"?z(o.value):t.value==="dirty"?z(o.value):o}}if(a.type==="refinement"){let i=c(o=>{let h=a.refinement(o,n);if(s.common.async)return Promise.resolve(h);if(h instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o},"executeRefinement");if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(a.type==="transform")if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!V(i))return m;let o=a.transform(i.value,n);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>V(i)?Promise.resolve(a.transform(i.value,n)).then(o=>({status:t.value,value:o})):m);x.assertNever(a)}};A.create=(r,e,t)=>new A({schema:r,typeName:y.ZodEffects,effect:e,..._(t)});A.createWithPreprocess=(r,e,t)=>new A({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects,..._(t)});var S=class extends g{static{c(this,"ZodOptional")}_parse(e){return this._getType(e)===l.undefined?b(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};S.create=(r,e)=>new S({innerType:r,typeName:y.ZodOptional,..._(e)});var E=class extends g{static{c(this,"ZodNullable")}_parse(e){return this._getType(e)===l.null?b(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};E.create=(r,e)=>new E({innerType:r,typeName:y.ZodNullable,..._(e)});var G=class extends g{static{c(this,"ZodDefault")}_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===l.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};G.create=(r,e)=>new G({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});var Q=class extends g{static{c(this,"ZodCatch")}_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ee(a)?a.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new w(s.common.issues)},input:s.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new w(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};Q.create=(r,e)=>new Q({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});var ue=class extends g{static{c(this,"ZodNaN")}_parse(e){if(this._getType(e)!==l.nan){let s=this._getOrReturnCtx(e);return u(s,{code:d.invalid_type,expected:l.nan,received:s.parsedType}),m}return{status:"valid",value:e.data}}};ue.create=r=>new ue({typeName:y.ZodNaN,..._(r)});var fe=class extends g{static{c(this,"ZodBranded")}_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},he=class r extends g{static{c(this,"ZodPipeline")}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return c(async()=>{let n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?m:n.status==="dirty"?(t.dirty(),z(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})},"handleAsync")();{let a=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?m:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:s.path,parent:s})}}static create(e,t){return new r({in:e,out:t,typeName:y.ZodPipeline})}},X=class extends g{static{c(this,"ZodReadonly")}_parse(e){let t=this._def.innerType._parse(e),s=c(a=>(V(a)&&(a.value=Object.freeze(a.value)),a),"freeze");return ee(t)?t.then(a=>s(a)):s(t)}unwrap(){return this._def.innerType}};X.create=(r,e)=>new X({innerType:r,typeName:y.ZodReadonly,..._(e)});var At={object:T.lazycreate},y;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(y||(y={}));var Rt=L.create,Nt=te.create,jt=ue.create,It=re.create,Et=se.create,Zt=ae.create,$t=ne.create,Mt=U.create,Vt=F.create,Pt=ie.create,zt=$.create,Dt=R.create,Lt=oe.create,Ut=M.create,Ft=T.create,Bt=T.strictCreate,Wt=B.create,qt=ge.create,Jt=W.create,Yt=I.create,Ht=xe.create,Gt=ce.create,Qt=de.create,Xt=ke.create,Kt=q.create,er=J.create,tr=Y.create,rr=H.create,sr=P.create,ar=A.create,nr=S.create,ir=E.create,or=A.createWithPreprocess,cr=he.create;export{y as a};
@@ -10,5 +10,9 @@ if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => {
10
10
  if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
11
  import { createRequire as __alchemyCreateRequire } from 'node:module';
12
12
  const require = __alchemyCreateRequire(import.meta.url);
13
+ import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
14
+ import { dirname as __alchemyDirname } from 'node:path';
15
+ const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
16
+ const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
13
17
 
14
- import"./chunk-RHIWAYN5.js";import{Effect as s}from"effect";var o={id:"20260227213759_add_session_workspace_id",up(i){return s.gen(function*(){yield*i.run("ALTER TABLE `session` ADD `workspace_id` text;"),yield*i.run("CREATE INDEX `session_workspace_idx` ON `session` (`workspace_id`);")})}};export{o as default};
18
+ import{A as o}from"./chunk-WPMP2ZFE.js";var r=o;export{r as a};
@@ -0,0 +1,18 @@
1
+ // Built by esbuild from opencode-server source
2
+ if (typeof globalThis.Bun === 'undefined') {
3
+ globalThis.Bun = {
4
+ version: '0.0.0-node-compat',
5
+ stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
+ which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
+ };
8
+ }
9
+ if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
+ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
+ import { createRequire as __alchemyCreateRequire } from 'node:module';
12
+ const require = __alchemyCreateRequire(import.meta.url);
13
+ import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
14
+ import { dirname as __alchemyDirname } from 'node:path';
15
+ const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
16
+ const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
17
+
18
+ import{a as r}from"./chunk-2MRHL4B2.js";import n from"crypto";function c(e=43){let t=n.randomBytes(e);return o(t)}r(c,"generateSecret");function s(e){let t=n.createHash("sha256").update(e).digest();return o(t)}r(s,"generateCodeChallengeFromVerifier");function o(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}r(o,"base64UrlEncode");export{c as a,s as b};
@@ -0,0 +1,18 @@
1
+ // Built by esbuild from opencode-server source
2
+ if (typeof globalThis.Bun === 'undefined') {
3
+ globalThis.Bun = {
4
+ version: '0.0.0-node-compat',
5
+ stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
+ which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
+ };
8
+ }
9
+ if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
+ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
+ import { createRequire as __alchemyCreateRequire } from 'node:module';
12
+ const require = __alchemyCreateRequire(import.meta.url);
13
+ import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
14
+ import { dirname as __alchemyDirname } from 'node:path';
15
+ const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
16
+ const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
17
+
18
+ import{a as sr,c as Ne,cd as ge,ia as Be,ja as $e,la as le,lb as pr,ma as ce,mb as fe,mc as dr,na as N,pa as Qe,pc as Q,q as lr,rc as ur,sc as mr,tc as yr,uc as Ze,x as Ke,ya as cr,za as fr}from"./chunk-7XX6TY62.js";import{a as Cr}from"./chunk-FV7U6PVP.js";import{Bc as ar,Bf as t,Tc as ee,bb as se,bi as W,pj as u,rg as or}from"./chunk-ELPXQ32J.js";import{a as o,d as Pr,e as Fe,g as ir}from"./chunk-2MRHL4B2.js";var br=Pr((xr,He)=>{((x,v)=>{typeof define=="function"&&define.amd?define([],v):typeof He=="object"&&He.exports?He.exports=v():x.fuzzysort=v()})(xr,x=>{"use strict";var v=o((r,e)=>{if(!r||!e)return B;var i=R(r);me(e)||(e=M(e));var f=i.bitflags;return(f&e._bitflags)!==f?B:H(i,e)},"single"),g=o((r,e,i)=>{if(!r)return i?.all?Y(e,i):Ve;var f=R(r),p=f.bitflags,l=f.containsSpace,a=T(i?.threshold||0),y=i?.limit||Je,d=0,_=0,S=e.length;function X(ye){d<y?(Te.add(ye),++d):(++_,ye._score>Te.peek()._score&&Te.replaceTop(ye))}if(o(X,"push_result"),i?.key)for(var G=i.key,E=0;E<S;++E){var q=e[E],F=Re(q,G);if(F&&(me(F)||(F=M(F)),(p&F._bitflags)===p)){var C=H(f,F);C!==B&&(C._score<a||(C.obj=q,X(C)))}}else if(i?.keys){var ae=i.keys,K=ae.length;e:for(var E=0;E<S;++E){var q=e[E];{for(var O=0,w=0;w<K;++w){var G=ae[w],F=Re(q,G);if(!F){We[w]=Ie;continue}me(F)||(F=M(F)),We[w]=F,O|=F._bitflags}if((p&O)!==p)continue}if(l)for(let k=0;k<f.spaceSearches.length;k++)te[k]=J;for(var w=0;w<K;++w){if(F=We[w],F===Ie){xe[w]=Ie;continue}if(xe[w]=H(f,F,!1,l),xe[w]===B){xe[w]=Ie;continue}if(l)for(let L=0;L<f.spaceSearches.length;L++){if(ue[L]>-1e3&&te[L]>J){var $=(te[L]+ue[L])/4;$>te[L]&&(te[L]=$)}ue[L]>te[L]&&(te[L]=ue[L])}}if(l){for(let k=0;k<f.spaceSearches.length;k++)if(te[k]===J)continue e}else{var b=!1;for(let k=0;k<K;k++)if(xe[k]._score!==J){b=!0;break}if(!b)continue}var V=new h(K);for(let k=0;k<K;k++)V[k]=xe[k];if(l){var D=0;for(let k=0;k<f.spaceSearches.length;k++)D+=te[k]}else{var D=J;for(let L=0;L<K;L++){var C=V[L];if(C._score>-1e3&&D>J){var $=(D+C._score)/4;$>D&&(D=$)}C._score>D&&(D=C._score)}}if(V.obj=q,V._score=D,i?.scoreFn){if(D=i.scoreFn(V),!D)continue;D=T(D),V._score=D}D<a||X(V)}}else for(var E=0;E<S;++E){var F=e[E];if(F&&(me(F)||(F=M(F)),(p&F._bitflags)===p)){var C=H(f,F);C!==B&&(C._score<a||X(C))}}if(d===0)return Ve;for(var oe=new Array(d),E=d-1;E>=0;--E)oe[E]=Te.poll();return oe.total=d+_,oe},"go"),c=o((r,e="<b>",i="</b>")=>{for(var f=typeof e=="function"?e:void 0,p=r.target,l=p.length,a=r.indexes,y="",d=0,_=0,S=!1,X=[],G=0;G<l;++G){var E=p[G];if(a[_]===G){if(++_,S||(S=!0,f?(X.push(y),y=""):y+=e),_===a.length){f?(y+=E,X.push(f(y,d++)),y="",X.push(p.substr(G+1))):y+=E+i+p.substr(G+1);break}}else S&&(S=!1,f?(X.push(f(y,d++)),y=""):y+=i);y+=E}return f?X:y},"highlight"),m=o(r=>{typeof r=="number"?r=""+r:typeof r!="string"&&(r="");var e=he(r);return A(r,{_targetLower:e._lower,_targetLowerCodes:e.lowerCodes,_bitflags:e.bitflags})},"prepare"),s=o(()=>{Ue.clear(),Xe.clear()},"cleanup");class n{static{o(this,"Result")}get indexes(){return this._indexes.slice(0,this._indexes.len).sort((e,i)=>e-i)}set indexes(e){return this._indexes=e}highlight(e,i){return c(this,e,i)}get score(){return I(this._score)}set score(e){this._score=T(e)}}class h extends Array{static{o(this,"KeysResult")}get score(){return I(this._score)}set score(e){this._score=T(e)}}var A=o((r,e)=>{let i=new n;return i.target=r,i.obj=e.obj??B,i._score=e._score??J,i._indexes=e._indexes??[],i._targetLower=e._targetLower??"",i._targetLowerCodes=e._targetLowerCodes??B,i._nextBeginningIndexes=e._nextBeginningIndexes??B,i._bitflags=e._bitflags??0,i},"new_result"),I=o(r=>r===J?0:r>1?r:Math.E**(((-r+1)**.04307-1)*-2),"normalizeScore"),T=o(r=>r===0?J:r>1?r:1-Math.pow(Math.log(r)/-2+1,1/.04307),"denormalizeScore"),P=o(r=>{typeof r=="number"?r=""+r:typeof r!="string"&&(r=""),r=r.trim();var e=he(r),i=[];if(e.containsSpace){var f=r.split(/\s+/);f=[...new Set(f)];for(var p=0;p<f.length;p++)if(f[p]!==""){var l=he(f[p]);i.push({lowerCodes:l.lowerCodes,_lower:f[p].toLowerCase(),containsSpace:!1})}}return{lowerCodes:e.lowerCodes,_lower:e._lower,containsSpace:e.containsSpace,bitflags:e.bitflags,spaceSearches:i}},"prepareSearch"),M=o(r=>{if(r.length>999)return m(r);var e=Ue.get(r);return e!==void 0||(e=m(r),Ue.set(r,e)),e},"getPrepared"),R=o(r=>{if(r.length>999)return P(r);var e=Xe.get(r);return e!==void 0||(e=P(r),Xe.set(r,e)),e},"getPreparedSearch"),Y=o((r,e)=>{var i=[];i.total=r.length;var f=e?.limit||Je;if(e?.key)for(var p=0;p<r.length;p++){var l=r[p],a=Re(l,e.key);if(a!=B){me(a)||(a=M(a));var y=A(a.target,{_score:a._score,obj:l});if(i.push(y),i.length>=f)return i}}else if(e?.keys)for(var p=0;p<r.length;p++){for(var l=r[p],d=new h(e.keys.length),_=e.keys.length-1;_>=0;--_){var a=Re(l,e.keys[_]);if(!a){d[_]=Ie;continue}me(a)||(a=M(a)),a._score=J,a._indexes.len=0,d[_]=a}if(d.obj=l,d._score=J,i.push(d),i.length>=f)return i}else for(var p=0;p<r.length;p++){var a=r[p];if(a!=B&&(me(a)||(a=M(a)),a._score=J,a._indexes.len=0,i.push(a),i.length>=f))return i}return i},"all"),H=o((r,e,i=!1,f=!1)=>{if(i===!1&&r.containsSpace)return U(r,e,f);for(var p=r._lower,l=r.lowerCodes,a=l[0],y=e._targetLowerCodes,d=l.length,_=y.length,E=0,S=0,X=0;;){var G=a===y[S];if(G){if(re[X++]=S,++E,E===d)break;a=l[E]}if(++S,S>=_)return B}var E=0,q=!1,F=0,C=e._nextBeginningIndexes;C===B&&(C=e._nextBeginningIndexes=Ir(e.target)),S=re[0]===0?0:C[re[0]-1];var ae=0;if(S!==_)for(;;)if(S>=_){if(E<=0||(++ae,ae>200))break;--E;var K=Ae[--F];S=C[K]}else{var G=l[E]===y[S];if(G){if(Ae[F++]=S,++E,E===d){q=!0;break}++S}else S=C[S]}var O=d<=1?-1:e._targetLower.indexOf(p,re[0]),w=!!~O,$=w?O===0||e._nextBeginningIndexes[O-1]===O:!1;if(w&&!$){for(var b=0;b<C.length;b=C[b])if(!(b<=O)){for(var V=0;V<d&&l[V]===e._targetLowerCodes[b+V];V++);if(V===d){O=b,$=!0;break}}}var D=o(k=>{for(var L=0,nr=0,ne=1;ne<d;++ne)k[ne]-k[ne-1]!==1&&(L-=k[ne],++nr);var kr=k[d-1]-k[0]-(d-1);if(L-=(12+kr)*nr,k[0]!==0&&(L-=k[0]*k[0]*.2),!q)L*=1e3;else{for(var Ye=1,ne=C[0];ne<_;ne=C[ne])++Ye;Ye>24&&(L*=(Ye-24)*10)}return L-=(_-d)/2,w&&(L/=1+d*d*1),$&&(L/=1+d*d*1),L-=(_-d)/2,L},"calculateScore");if(q)if($){for(var b=0;b<d;++b)re[b]=O+b;var oe=re,ye=D(re)}else var oe=Ae,ye=D(Ae);else{if(w)for(var b=0;b<d;++b)re[b]=O+b;var oe=re,ye=D(oe)}e._score=ye;for(var b=0;b<d;++b)e._indexes[b]=oe[b];e._indexes.len=d;let De=new n;return De.target=e.target,De._score=e._score,De._indexes=e._indexes,De},"algorithm"),U=o((r,e,i)=>{for(var f=new Set,p=0,l=B,a=0,y=r.spaceSearches,d=y.length,_=0,S=o(()=>{for(let $=_-1;$>=0;$--)e._nextBeginningIndexes[Me[$*2+0]]=Me[$*2+1]},"resetNextBeginningIndexes"),X=!1,w=0;w<d;++w){ue[w]=J;var G=y[w];if(l=H(G,e),i){if(l===B)continue;X=!0}else if(l===B)return S(),B;var E=w===d-1;if(!E){var q=l._indexes,F=!0;for(let b=0;b<q.len-1;b++)if(q[b+1]-q[b]!==1){F=!1;break}if(F){var C=q[q.len-1]+1,ae=e._nextBeginningIndexes[C-1];for(let b=C-1;b>=0&&ae===e._nextBeginningIndexes[b];b--)e._nextBeginningIndexes[b]=C,Me[_*2+0]=b,Me[_*2+1]=ae,_++}}p+=l._score/d,ue[w]=l._score/d,l._indexes[0]<a&&(p-=(a-l._indexes[0])*2),a=l._indexes[0];for(var K=0;K<l._indexes.len;++K)f.add(l._indexes[K])}if(i&&!X)return B;S();var O=H(r,e,!0);if(O!==B&&O._score>p){if(i)for(var w=0;w<d;++w)ue[w]=O._score/d;return O}i&&(l=e),l._score=p;var w=0;for(let $ of f)l._indexes[w++]=$;return l._indexes.len=w,l},"algorithmSpaces"),j=o(r=>r.replace(new RegExp("\\p{Script=Latin}+","gu"),e=>e.normalize("NFD")).replace(/[\u0300-\u036f]/g,""),"remove_accents"),he=o(r=>{r=j(r);for(var e=r.length,i=r.toLowerCase(),f=[],p=0,l=!1,a=0;a<e;++a){var y=f[a]=i.charCodeAt(a);if(y===32){l=!0;continue}var d=y>=97&&y<=122?y-97:y>=48&&y<=57?26:y<=127?30:31;p|=1<<d}return{lowerCodes:f,bitflags:p,containsSpace:l,_lower:i}},"prepareLowerInfo"),de=o(r=>{for(var e=r.length,i=[],f=0,p=!1,l=!1,a=0;a<e;++a){var y=r.charCodeAt(a),d=y>=65&&y<=90,_=d||y>=97&&y<=122||y>=48&&y<=57,S=d&&!p||!l||!_;p=d,l=_,S&&(i[f++]=a)}return i},"prepareBeginningIndexes"),Ir=o(r=>{r=j(r);for(var e=r.length,i=de(r),f=[],p=i[0],l=0,a=0;a<e;++a)p>a?f[a]=p:(p=i[++l],f[a]=p===void 0?e:p);return f},"prepareNextBeginningIndexes"),Ue=new Map,Xe=new Map,re=[],Ae=[],Me=[],te=[],ue=[],We=[],xe=[],Re=o((r,e)=>{var i=r[e];if(i!==void 0)return i;if(typeof e=="function")return e(r);var f=e;Array.isArray(e)||(f=e.split("."));for(var p=f.length,l=-1;r&&++l<p;)r=r[f[l]];return r},"getValue"),me=o(r=>typeof r=="object"&&typeof r._bitflags=="number","isPrepared"),Je=1/0,J=-Je,Ve=[];Ve.total=0;var B=null,Ie=m(""),Fr=o(r=>{var e=[],i=0,f={},p=o(l=>{for(var a=0,y=e[a],d=1;d<i;){var _=d+1;a=d,_<i&&e[_]._score<e[d]._score&&(a=_),e[a-1>>1]=e[a],d=1+(a<<1)}for(var S=a-1>>1;a>0&&y._score<e[S]._score;S=(a=S)-1>>1)e[a]=e[S];e[a]=y},"v");return f.add=(l=>{var a=i;e[i++]=l;for(var y=a-1>>1;a>0&&l._score<e[y]._score;y=(a=y)-1>>1)e[a]=e[y];e[a]=l}),f.poll=(l=>{if(i!==0){var a=e[0];return e[0]=e[--i],p(),a}}),f.peek=(l=>{if(i!==0)return e[0]}),f.replaceTop=(l=>{e[0]=l,p()}),f},"fastpriorityqueue"),Te=Fr();return{single:v,go:g,prepare:m,cleanup:s}})});var Se={};Fe(Se,{Error:()=>Ce,InvalidPatternError:()=>Le,Ripgrep:()=>Se,Service:()=>be,node:()=>Br});var Pe={};Fe(Pe,{Entry:()=>z,Event:()=>Lr,FileSystem:()=>Pe,FindInput:()=>ke,Match:()=>pe,Submatch:()=>ze});var gr=cr({type:"file.edited",schema:{file:u.String}}),Lr={Edited:gr,Definitions:fr(gr)},z=u.Struct({path:N,type:u.Literals(["file","directory"])}).annotate({identifier:"FileSystem.Entry"}),ze=u.Struct({text:u.String,start:ce,end:ce}).annotate({identifier:"FileSystem.Submatch"}),pe=u.Struct({entry:z,line:le,offset:ce,text:u.String,submatches:u.Array(ze)}).annotate({identifier:"FileSystem.Match"}),ke=class extends u.Class("FileSystem.FindInput")({query:u.String,type:u.Literals(["file","directory"]).pipe(Qe),limit:le.pipe(Qe)}){static{o(this,"FindInput")}};import je from"path";var vr=ir(Cr(),1);import Ar from"path";function Ge(x,v){let g=v?.PATH??v?.Path??process.env.PATH??process.env.Path??"",c=g?g+Ar.delimiter+fe.Path.bin:fe.Path.bin,m=vr.default.sync(x,{nothrow:!0,path:c,pathExt:v?.PATHEXT??v?.PathExt??process.env.PATHEXT??process.env.PathExt});return typeof m=="string"?m:null}o(Ge,"which");var Oe;(s=>{let x="15.1.0",v={"arm64-darwin":{platform:"aarch64-apple-darwin",extension:"tar.gz"},"arm64-linux":{platform:"aarch64-unknown-linux-gnu",extension:"tar.gz"},"x64-darwin":{platform:"x86_64-apple-darwin",extension:"tar.gz"},"x64-linux":{platform:"x86_64-unknown-linux-musl",extension:"tar.gz"},"arm64-win32":{platform:"aarch64-pc-windows-msvc",extension:"zip"},"ia32-win32":{platform:"i686-pc-windows-msvc",extension:"zip"},"x64-win32":{platform:"x86_64-pc-windows-msvc",extension:"zip"}};class g extends se.Service()("@opencode/RipgrepBinary"){static{o(this,"Service")}}s.Service=g;let c=ee.effect(g,t.gen(function*(){let n=yield*Q.Service,h=Ke.filterStatusOk(yield*Ke.HttpClient),A=yield*sr,I=t.fnUntraced(function*(P,M){let R=yield*A.spawn(Ne.make(P,M,{extendEnv:!0,stdin:"ignore"})),[Y,H,U]=yield*t.all([W.mkString(W.decodeText(R.stdout)),W.mkString(W.decodeText(R.stderr)),R.exitCode],{concurrency:"unbounded"});return{stdout:Y,stderr:H,code:U}},t.scoped),T=t.fnUntraced(function*(P,M,R){let Y=yield*n.makeTempDirectoryScoped({directory:fe.Path.bin,prefix:"ripgrep-"});if(M.extension==="zip"){let U=(yield*t.sync(()=>Ge("powershell.exe")??Ge("pwsh.exe")))??"powershell.exe",j=yield*I(U,["-NoProfile","-NonInteractive","-Command",`$global:ProgressPreference = 'SilentlyContinue'; Expand-Archive -LiteralPath '${P.replaceAll("'","''")}' -DestinationPath '${Y.replaceAll("'","''")}' -Force`]);if(j.code!==0)throw new Error(j.stderr.trim()||j.stdout.trim()||`ripgrep extraction failed with code ${j.code}`)}if(M.extension==="tar.gz"){let U=yield*I("tar",["-xzf",P,"-C",Y]);if(U.code!==0)throw new Error(U.stderr.trim()||U.stdout.trim()||`ripgrep extraction failed with code ${U.code}`)}let H=je.join(Y,`ripgrep-${x}-${M.platform}`,process.platform==="win32"?"rg.exe":"rg");if(!(yield*n.isFile(H)))throw new Error(`ripgrep archive did not contain executable: ${H}`);yield*n.copyFile(H,R),process.platform!=="win32"&&(yield*n.chmod(R,493))},t.scoped);return g.of({filepath:yield*t.cached(t.gen(function*(){let P=yield*t.sync(()=>Ge(process.platform==="win32"?"rg.exe":"rg"));if(P&&(yield*n.isFile(P).pipe(t.orDie)))return P;let M=je.join(fe.Path.bin,`rg${process.platform==="win32"?".exe":""}`);if(yield*n.isFile(M).pipe(t.orDie))return M;let R=`${process.arch}-${process.platform}`,Y=v[R];if(!Y)throw new Error(`unsupported platform for ripgrep: ${R}`);let H=`ripgrep-${x}-${Y.platform}.${Y.extension}`,U=`https://github.com/BurntSushi/ripgrep/releases/download/${x}/${H}`,j=je.join(fe.Path.bin,H);yield*t.logInfo("downloading ripgrep",{url:U}),yield*n.ensureDir(fe.Path.bin).pipe(t.orDie);let he=yield*lr.get(U).pipe(h.execute,t.flatMap(de=>de.arrayBuffer),t.mapError(de=>de instanceof Error?de:new Error(String(de))));if(he.byteLength===0)throw new Error(`failed to download ripgrep from ${U}`);return yield*n.writeWithDirs(j,new Uint8Array(he)),yield*T(j,Y,M),yield*n.remove(j,{force:!0}).pipe(t.ignore),M}))})}));s.node=Be({service:g,layer:c,deps:[Q.node,dr,ur.node]})})(Oe||={});var Mr=8*1024,hr=64*1024,Rr=100,Tr=u.Struct({type:u.Literal("match"),data:u.Struct({path:u.Struct({text:u.String}),lines:u.Struct({text:u.String}),line_number:le,absolute_offset:ce,submatches:u.Array(u.Struct({match:u.Struct({text:u.String}),start:ce,end:ce}))})}),Ce=class extends u.TaggedErrorClass()("Ripgrep.Error",{message:u.String,cause:u.optional(u.Defect())}){static{o(this,"Error")}},Le=class extends u.TaggedErrorClass()("Ripgrep.InvalidPatternError",{pattern:u.String,message:u.String}){static{o(this,"InvalidPatternError")}},be=class extends se.Service()("@opencode/v2/Ripgrep"){static{o(this,"Service")}},ve=o((x,v)=>new Ce({message:x,cause:v}),"failure"),Dr=o(x=>x.includes("regex parse error")||x.includes("error parsing regex"),"isInvalidPattern"),Nr=ee.effect(be,t.gen(function*(){let x=yield*Ze.Service,v=yield*Oe.Service,g=o(c=>{let m=t.scoped(t.gen(function*(){let n=yield*x.spawn(Ne.make(yield*v.filepath,c.args,{cwd:c.cwd,extendEnv:!0,stdin:"ignore"})),h=yield*yr(n.stderr,Mr).pipe(t.map(R=>R.buffer.toString("utf8")),t.forkScoped),A=0,I=yield*W.decodeText(n.stdout).pipe(W.splitLines,W.filter(R=>R.length>0),W.mapEffect(c.parse),W.filter(R=>R!==void 0),W.tap(R=>!c.onItem||A++>=c.limit?t.void:c.onItem(R)),W.take(c.limit+1),W.runCollect,t.map(R=>[...R])),T=I.length>c.limit;if(T)return{items:I.slice(0,c.limit),truncated:T,partial:!1};let P=yield*n.exitCode,M=yield*or.join(h);return c.pattern&&P===2&&Dr(M)?yield*new Le({pattern:c.pattern,message:M.trim()}):P!==0&&P!==1&&P!==2?yield*ve(M.trim()||`ripgrep failed with code ${P}`):{items:P===1?[]:I,truncated:!1,partial:P===2}}));return(c.signal?m.pipe(t.raceFirst(mr(c.signal))):m).pipe(t.mapError(n=>n instanceof Ce||n instanceof Le?n:ve("ripgrep execution failed",n)))},"run");return be.of({glob:o(c=>g({cwd:c.cwd,limit:c.limit,signal:c.signal,args:["--no-config","--files",...c.hidden?["--hidden"]:[],...c.follow?["--follow"]:[],`--glob=${c.pattern}`,"--glob=!**/.git/**","."],parse:o(m=>t.succeed(m.replace(/^(?:\.[\\/])+/u,"").replace(/^[\\/]+/u,"").replaceAll("\\","/")),"parse")}).pipe(t.map(m=>m.items.map(s=>z.make({path:N.make(s),type:"file"}))),t.catchTag("Ripgrep.InvalidPatternError",m=>t.fail(ve(m.message,m)))),"glob"),find:o(c=>g({cwd:c.cwd,limit:c.limit,signal:c.signal,args:["--no-config","--files",...c.hidden?["--hidden"]:[],...c.follow?["--follow"]:[],...c.pattern==="*"?[]:[`--glob=${c.pattern}`],"--glob=!**/.git/**","."],parse:o(m=>{let s=m.replace(/^(?:\.[\\/])+/u,"").replace(/^[\\/]+/u,"").replaceAll("\\","/");return t.succeed(z.make({path:N.make(s),type:"file"}))},"parse"),onItem:c.onEntry}).pipe(t.map(m=>m.items),t.catchTag("Ripgrep.InvalidPatternError",m=>t.fail(ve(m.message,m)))),"find"),grep:o(c=>g({...c,args:["--no-config","--json","--hidden","--no-messages",...c.include?[`--glob=${c.include}`]:[],"--glob=!**/.git/**","--",c.pattern,c.file??"."],parse:o(m=>(Buffer.byteLength(m,"utf8")>hr?t.fail(ve(`Ripgrep JSON record exceeded ${hr} bytes`)):t.try({try:o(()=>JSON.parse(m),"try"),catch:o(s=>ve("Invalid ripgrep JSON output",s),"catch")})).pipe(t.flatMap(s=>!s||typeof s!="object"||!("type"in s)||s.type!=="match"?t.succeed(void 0):u.decodeUnknownEffect(Tr)(s).pipe(t.map(n=>({...n.data,path:{text:n.data.path.text.replace(/^\.[\\/]/,"")},submatches:n.data.submatches.slice(0,Rr)})),t.mapError(n=>ve("Invalid ripgrep match output",n))))),"parse")}).pipe(t.map(m=>m.items.map(s=>{let n=s.path.text.replace(/^(?:\.[\\/])+/u,"").replace(/^[\\/]+/u,"").replaceAll("\\","/");return pe.make({entry:z.make({path:N.make(n),type:"file"}),line:s.line_number,offset:s.absolute_offset,text:s.lines.text.length>2e3?s.lines.text.slice(0,2e3).replace(/[\uD800-\uDBFF]$/,"")+"...":s.lines.text,submatches:s.submatches.map(h=>({text:h.match.text,start:h.start,end:h.end}))})}))),"grep")})})),Br=Be({service:be,layer:Nr,deps:[Oe.node,Ze.node]});var tr={};Fe(tr,{Content:()=>qr,Entry:()=>z,Event:()=>Xr,FileSystem:()=>tr,FindInput:()=>ke,GlobInput:()=>er,GrepInput:()=>rr,ListInput:()=>Ur,Match:()=>pe,ReadInput:()=>Hr,Service:()=>Ee,Submatch:()=>ze,node:()=>Jr});import qe from"path";var _e={};Fe(_e,{FileSystemSearch:()=>_e,Service:()=>ie,fffLayer:()=>_r,locationLayer:()=>Gr,node:()=>Or,ripgrepLayer:()=>wr});import Z from"path";var we={};Fe(we,{Fff:()=>we,available:()=>$r,create:()=>zr});function $r(){return!1}o($r,"available");function zr(x){return{ok:!1,error:"fff unavailable on node runtime"}}o(zr,"create");var Sr=ir(br(),1);var ie=class extends se.Service()("@opencode/v2/FileSystem/Search"){static{o(this,"Service")}},wr=ee.effect(ie,t.gen(function*(){let x=yield*Q.Service,v=yield*ge.Service,g=yield*Se.Service,c=yield*ar.Scope,m={files:[],directories:[]},s=new Set;return yield*g.find({cwd:v.directory,pattern:"*",limit:v.vcs?Number.MAX_SAFE_INTEGER:1e5,onEntry:o(n=>t.sync(()=>{m.files.push(n.path);let h=n.path.split("/");h.slice(0,-1).forEach((A,I)=>s.add(h.slice(0,I+1).join("/")+Z.sep)),m.directories=Array.from(s)}),"onEntry")}).pipe(t.orDie,t.asVoid,t.forkIn(c)),ie.of({glob:o(n=>t.gen(function*(){let h=Z.resolve(v.directory,n.path??"."),I=(yield*x.stat(h).pipe(t.orDie)).type==="File"?Z.dirname(h):h;return yield*g.glob({cwd:I,pattern:n.pattern,limit:n.limit??Number.MAX_SAFE_INTEGER}).pipe(t.map(T=>T.map(P=>z.make({...P,path:N.make(Z.relative(v.directory,Z.resolve(I,P.path)))}))),t.orDie)}),"glob"),grep:o(n=>t.gen(function*(){let h=Z.resolve(v.directory,n.path??"."),A=yield*x.stat(h).pipe(t.orDie),I=A.type==="File"?Z.dirname(h):h;return yield*g.grep({cwd:I,pattern:n.pattern,file:A.type==="File"?Z.basename(h):void 0,include:n.include,limit:n.limit??Number.MAX_SAFE_INTEGER}).pipe(t.map(T=>T.map(P=>pe.make({...P,entry:z.make({...P.entry,path:N.make(Z.relative(v.directory,Z.resolve(I,P.entry.path)))})}))),t.orDie)}),"grep"),find:o(n=>t.gen(function*(){let h=n.type==="file"?m.files:n.type==="directory"?m.directories:[...m.files,...m.directories];return Sr.default.go(n.query,h,{limit:n.limit??50}).map(A=>{let I=A.target,T=I.endsWith(Z.sep)?"directory":"file";return z.make({path:N.make(I),type:T})})}),"find")})})),_r=ee.effect(ie,t.gen(function*(){let x=yield*ge.Service,v=yield*t.try({try:o(()=>we.create({basePath:x.directory,aiMode:!0,disableMmapCache:!0,disableContentIndexing:!0}),"try"),catch:o(g=>g,"catch")}).pipe(t.catch(g=>t.logWarning("failed to initialize fff",{error:g}).pipe(t.as(void 0))));return v?.ok?(yield*t.addFinalizer(()=>t.sync(()=>v.value.destroy()).pipe(t.ignore)),ie.of({glob:o(g=>t.sync(()=>{let c=g.path?.replaceAll("\\","/").replace(/\/$/,""),m=v.value.glob(c?`${c}/${g.pattern}`:g.pattern,{pageIndex:0,pageSize:g.limit});if(!m.ok)throw m.error;return m.value.items.map(s=>z.make({path:N.make(s.relativePath.replaceAll("\\","/")),type:"file"}))}),"glob"),grep:o(g=>t.sync(()=>{let c=g.path?.replaceAll("\\","/").replace(/\/$/,""),m=v.value.grep([c?`${c}/**`:void 0,g.include,g.pattern].filter(s=>s!==void 0).join(" "),{mode:"regex",pageSize:g.limit,timeBudgetMs:1500});if(!m.ok)throw m.error;return m.value.items.map(s=>{let n=Buffer.from(s.lineContent);return pe.make({entry:z.make({path:N.make(s.relativePath.replaceAll("\\","/")),type:"file"}),line:s.lineNumber,offset:s.byteOffset,text:s.lineContent.length>2e3?s.lineContent.slice(0,2e3)+"...":s.lineContent,submatches:s.matchRanges.map(([h,A])=>({text:n.subarray(h,A).toString("utf8"),start:h,end:A}))})})}),"grep"),find:o(g=>t.sync(()=>{let c={pageIndex:0,pageSize:g.limit??50};return(()=>{if(g.type==="file"){let n=v.value.fileSearch(g.query.trim(),c);if(!n.ok)throw n.error;return n.value.items.map((h,A)=>({path:h.relativePath,type:"file",score:n.value.scores[A]?.total??0}))}if(g.type==="directory"){let n=v.value.directorySearch(g.query.trim(),c);if(!n.ok)throw n.error;return n.value.items.map((h,A)=>({path:h.relativePath,type:"directory",score:n.value.scores[A]?.total??0}))}let s=v.value.mixedSearch(g.query.trim(),c);if(!s.ok)throw s.error;return s.value.items.map((n,h)=>({path:n.item.relativePath,type:n.type,score:s.value.scores[h]?.total??0}))})().sort((s,n)=>n.score-s.score||s.path.length-n.path.length).map(s=>{let n=s.path.replaceAll("\\","/").replace(/\/$/,"");return z.make({path:N.make(n+(s.type==="directory"?Z.sep:"")),type:s.type})})}),"find")})):(v&&(yield*t.logWarning("failed to initialize fff",{error:v.error})),ie.of({find:o(()=>t.succeed([]),"find"),glob:o(()=>t.succeed([]),"glob"),grep:o(()=>t.succeed([]),"grep")}))})),Er=ee.unwrap(t.sync(()=>pr.OPENCODE_DISABLE_FFF||!we.available()?wr:_r)),Gr=Er,Or=$e({service:ie,layer:Er,deps:[Q.node,ge.node,Se.node]});var Hr=u.Struct({path:N}),qr=u.Struct({uri:u.String,name:u.String.pipe(u.optional),content:u.String,encoding:u.Literals(["utf8","base64"]),mime:u.String}).annotate({identifier:"FileSystem.Content"}),Ur=u.Struct({path:N.pipe(u.optional)});var er=class extends u.Class("FileSystem.GlobInput")({pattern:u.String,path:N.pipe(u.optional),limit:le.pipe(u.optional)}){static{o(this,"GlobInput")}},rr=class extends u.Class("FileSystem.GrepInput")({pattern:u.String,path:N.pipe(u.optional),include:u.String.pipe(u.optional),limit:le.pipe(u.optional)}){static{o(this,"GrepInput")}},Xr=Pe.Event,Ee=class extends se.Service()("@opencode/v2/FileSystem"){static{o(this,"Service")}},Wr=ee.effect(Ee,t.gen(function*(){let x=yield*Q.Service,v=yield*ge.Service,g=yield*_e.Service,c=yield*x.realPath(v.directory).pipe(t.orDie),m=t.fnUntraced(function*(s){let n=qe.resolve(v.directory,s??".");if(!Q.contains(v.directory,n))return yield*t.die(new Error("Path escapes the location"));let h=yield*x.realPath(n).pipe(t.orDie);return Q.contains(c,h)?{absolute:n,real:h,directory:v.directory,root:c}:yield*t.die(new Error("Path escapes the location"))});return Ee.of({find:g.find,glob:g.glob,grep:g.grep,read:t.fn("FileSystem.read")(function*(s){let n=yield*m(s.path);return(yield*x.stat(n.real).pipe(t.orDie)).type!=="File"?yield*t.die(new Error("Path is not a file")):{content:yield*x.readFile(n.real).pipe(t.orDie),mime:Q.mimeType(n.real)}}),list:t.fn("FileSystem.list")(function*(s={}){let n=yield*m(s.path);return(yield*x.stat(n.real).pipe(t.orDie)).type!=="Directory"?yield*t.die(new Error("Path is not a directory")):yield*x.readDirectoryEntries(n.real).pipe(t.orDie,t.map(A=>A.flatMap(I=>{if(I.type!=="file"&&I.type!=="directory")return[];let T=qe.join(n.absolute,I.name),P=qe.relative(n.directory,T);return[z.make({path:N.make(P+(I.type==="directory"?qe.sep:"")),type:I.type})]}).sort((I,T)=>I.type===T.type?I.path.localeCompare(T.path):I.type==="directory"?-1:1)))})})})),Jr=$e({service:Ee,layer:Wr,deps:[Q.node,ge.node,_e.node]});export{br as a,Pe as b,Ge as c,Se as d,_e as e,tr as f};
@@ -0,0 +1,18 @@
1
+ // Built by esbuild from opencode-server source
2
+ if (typeof globalThis.Bun === 'undefined') {
3
+ globalThis.Bun = {
4
+ version: '0.0.0-node-compat',
5
+ stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
+ which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
+ };
8
+ }
9
+ if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
+ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
+ import { createRequire as __alchemyCreateRequire } from 'node:module';
12
+ const require = __alchemyCreateRequire(import.meta.url);
13
+ import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
14
+ import { dirname as __alchemyDirname } from 'node:path';
15
+ const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
16
+ const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
17
+
18
+ import{c as V}from"./chunk-OCWGUTZJ.js";import{f as v}from"./chunk-CYRZU5QM.js";import{a as _,g as N}from"./chunk-2MRHL4B2.js";var S=N(V()),C=N(v());var A="AWS_ACCESS_KEY_ID",p="AWS_SECRET_ACCESS_KEY",I="AWS_SESSION_TOKEN",a="AWS_CREDENTIAL_EXPIRATION",i="AWS_CREDENTIAL_SCOPE",T="AWS_ACCOUNT_ID",d=_(e=>async()=>{e?.logger?.debug("@aws-sdk/credential-provider-env - fromEnv");let o=process.env[A],E=process.env[p],r=process.env[I],n=process.env[a],s=process.env[i],t=process.env[T];if(o&&E){let c={accessKeyId:o,secretAccessKey:E,...r&&{sessionToken:r},...n&&{expiration:new Date(n)},...s&&{credentialScope:s},...t&&{accountId:t}};return(0,S.setCredentialFeature)(c,"CREDENTIALS_ENV_VARS","g"),c}throw new C.CredentialsProviderError("Unable to find environment variable credentials.",{logger:e?.logger})},"fromEnv");export{A as a,p as b,I as c,a as d,i as e,T as f,d as g};
@@ -0,0 +1,18 @@
1
+ // Built by esbuild from opencode-server source
2
+ if (typeof globalThis.Bun === 'undefined') {
3
+ globalThis.Bun = {
4
+ version: '0.0.0-node-compat',
5
+ stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
+ which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
+ };
8
+ }
9
+ if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
+ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
+ import { createRequire as __alchemyCreateRequire } from 'node:module';
12
+ const require = __alchemyCreateRequire(import.meta.url);
13
+ import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
14
+ import { dirname as __alchemyDirname } from 'node:path';
15
+ const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
16
+ const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
17
+
18
+ import{Ae as s,ja as f}from"./chunk-7XX6TY62.js";import{Bf as r,Tc as d,bb as x,pj as e}from"./chunk-ELPXQ32J.js";import{a as t,e as z}from"./chunk-2MRHL4B2.js";var h={};z(h,{DecodeError:()=>g,Image:()=>h,ResizerUnavailableError:()=>n,Service:()=>o,SizeError:()=>l,locationLayer:()=>E,node:()=>S});var n=class extends e.TaggedErrorClass()("Image.ResizerUnavailableError",{}){static{t(this,"ResizerUnavailableError")}},g=class extends e.TaggedErrorClass()("Image.DecodeError",{resource:e.String}){static{t(this,"DecodeError")}get message(){return`Image could not be decoded: ${this.resource}`}},l=class extends e.TaggedErrorClass()("Image.SizeError",{resource:e.String,width:e.Number,height:e.Number,bytes:e.Number,maxWidth:e.Number,maxHeight:e.Number,maxBytes:e.Number}){static{t(this,"SizeError")}get message(){return`Image ${this.resource} is ${this.width}x${this.height} with base64 size ${this.bytes}, exceeding configured limits ${this.maxWidth}x${this.maxHeight}/${this.maxBytes} bytes`}},o=class extends x.Service()("@opencode/Image"){static{t(this,"Service")}},y=d.effect(o,r.gen(function*(){let a=yield*s.Service,p=yield*r.cached(r.tryPromise({try:t(()=>import("./photon-W56QZY4L.js"),"try"),catch:t(()=>new n,"catch")}).pipe(r.flatMap(m=>m.make))),u=r.fn("Image.normalize")(function*(m,b){let i=Object.assign({},...(yield*a.entries()).flatMap(c=>c.type==="document"&&c.info.attachments?.image?[c.info.attachments.image]:[]));return yield*(yield*p)(m,b,{autoResize:i.auto_resize??!0,maxWidth:i.max_width??2e3,maxHeight:i.max_height??2e3,maxBase64Bytes:i.max_base64_bytes??5*1024*1024})});return o.of({normalize:u})})),E=y.pipe(d.provide(s.locationLayer)),S=f({service:o,layer:y,deps:[s.node]});export{n as a,g as b,l as c,h as d};
@@ -0,0 +1,28 @@
1
+ // Built by esbuild from opencode-server source
2
+ if (typeof globalThis.Bun === 'undefined') {
3
+ globalThis.Bun = {
4
+ version: '0.0.0-node-compat',
5
+ stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
+ which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
+ };
8
+ }
9
+ if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
+ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
+ import { createRequire as __alchemyCreateRequire } from 'node:module';
12
+ const require = __alchemyCreateRequire(import.meta.url);
13
+ import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
14
+ import { dirname as __alchemyDirname } from 'node:path';
15
+ const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
16
+ const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
17
+
18
+ import{a as O,b as F,c as K,d as ce,e as pe,f as P,g as he,h as X,i as I,j as q,k as me,l as A,m as W,n as M,o as ge}from"./chunk-GDWO6EXN.js";import{f as ue,g as Q,l as de,n as H}from"./chunk-WKZYINC7.js";import{A as t}from"./chunk-WPMP2ZFE.js";import{a as m}from"./chunk-2MRHL4B2.js";function N(e){return e.replace(/[_-]([a-z])/g,o=>o[1].toUpperCase())}m(N,"toCamelCase");function Te(e,o){let s=N(e);return s!==e&&o?.[s]!=null?s:e}m(Te,"resolveProviderOptionsKey");var je=t.object({error:t.object({message:t.string(),type:t.string().nullish(),param:t.any().nullish(),code:t.union([t.string(),t.number()]).nullish()})}),V={errorSchema:je,errorToMessage:m(e=>e.error.message,"errorToMessage")};function fe(e){var o,s,r,d,c,l;if(e==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let p=(o=e.prompt_tokens)!=null?o:0,f=(s=e.completion_tokens)!=null?s:0,n=(d=(r=e.prompt_tokens_details)==null?void 0:r.cached_tokens)!=null?d:0,u=(l=(c=e.completion_tokens_details)==null?void 0:c.reasoning_tokens)!=null?l:0;return{inputTokens:{total:p,noCache:p-n,cacheRead:n,cacheWrite:void 0},outputTokens:{total:f,text:f-u,reasoning:u},raw:e}}m(fe,"convertOpenAICompatibleChatUsage");function $(e){var o,s;return(s=(o=e?.providerOptions)==null?void 0:o.openaiCompatible)!=null?s:{}}m($,"getOpenAIMetadata");function Ie(e){switch(e){case"audio/wav":return"wav";case"audio/mp3":case"audio/mpeg":return"mp3";default:return null}}m(Ie,"getAudioFormat");function Oe(e){var o,s,r;let d=[];for(let{role:c,content:l,...p}of e){let f=$({...p});switch(c){case"system":{d.push({role:"system",content:l,...f});break}case"user":{if(l.length===1&&l[0].type==="text"){d.push({role:"user",content:l[0].text,...$(l[0])});break}d.push({role:"user",content:l.map(n=>{var u;let a=$(n);switch(n.type){case"text":return{type:"text",text:n.text,...a};case"file":{if(n.mediaType.startsWith("image/")){let i=n.mediaType==="image/*"?"image/jpeg":n.mediaType;return{type:"image_url",image_url:{url:n.data instanceof URL?n.data.toString():`data:${i};base64,${K(n.data)}`},...a}}if(n.mediaType.startsWith("audio/")){if(n.data instanceof URL)throw new H({functionality:"audio file parts with URLs"});let i=Ie(n.mediaType);if(i===null)throw new H({functionality:`audio media type ${n.mediaType}`});return{type:"input_audio",input_audio:{data:K(n.data),format:i},...a}}if(n.mediaType==="application/pdf"){if(n.data instanceof URL)throw new H({functionality:"PDF file parts with URLs"});return{type:"file",file:{filename:(u=n.filename)!=null?u:"document.pdf",file_data:`data:application/pdf;base64,${K(n.data)}`},...a}}if(n.mediaType.startsWith("text/"))return{type:"text",text:n.data instanceof URL?n.data.toString():typeof n.data=="string"?new TextDecoder().decode(F(n.data)):new TextDecoder().decode(n.data),...a};throw new H({functionality:`file part media type ${n.mediaType}`})}}}),...f});break}case"assistant":{let n="",u="",a=[];for(let i of l){let g=$(i);switch(i.type){case"text":{n+=i.text;break}case"reasoning":{u+=i.text;break}case"tool-call":{let _=(s=(o=i.providerOptions)==null?void 0:o.google)==null?void 0:s.thoughtSignature;a.push({id:i.toolCallId,type:"function",function:{name:i.toolName,arguments:JSON.stringify(i.input)},...g,..._?{extra_content:{google:{thought_signature:String(_)}}}:{}});break}}}d.push({role:"assistant",content:n,...u.length>0?{reasoning_content:u}:{},tool_calls:a.length>0?a:void 0,...f});break}case"tool":{for(let n of l){if(n.type==="tool-approval-response")continue;let u=n.output,a;switch(u.type){case"text":case"error-text":a=u.value;break;case"execution-denied":a=(r=u.reason)!=null?r:"Tool execution denied.";break;case"content":case"json":case"error-json":a=JSON.stringify(u.value);break}let i=$(n);d.push({role:"tool",tool_call_id:n.toolCallId,content:a,...i})}break}default:{let n=c;throw new Error(`Unsupported role: ${n}`)}}}return d}m(Oe,"convertToOpenAICompatibleChatMessages");function ve({id:e,model:o,created:s}){return{id:e??void 0,modelId:o??void 0,timestamp:s!=null?new Date(s*1e3):void 0}}m(ve,"getResponseMetadata");function _e(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"other"}}m(_e,"mapOpenAICompatibleFinishReason");var B=t.object({user:t.string().optional(),reasoningEffort:t.string().optional(),textVerbosity:t.string().optional(),strictJsonSchema:t.boolean().optional()});function He({tools:e,toolChoice:o}){e=e?.length?e:void 0;let s=[];if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:s};let r=[];for(let c of e)c.type==="provider"?s.push({type:"unsupported",feature:`provider-defined tool ${c.id}`}):r.push({type:"function",function:{name:c.name,description:c.description,parameters:c.inputSchema,...c.strict!=null?{strict:c.strict}:{}}});if(o==null)return{tools:r,toolChoice:void 0,toolWarnings:s};let d=o.type;switch(d){case"auto":case"none":case"required":return{tools:r,toolChoice:d,toolWarnings:s};case"tool":return{tools:r,toolChoice:{type:"function",function:{name:o.toolName}},toolWarnings:s};default:{let c=d;throw new H({functionality:`tool choice type: ${c}`})}}}m(He,"prepareTools");var qe=class{static{m(this,"OpenAICompatibleChatLanguageModel")}constructor(e,o){this.specificationVersion="v3";var s,r;this.modelId=e,this.config=o;let d=(s=o.errorStructure)!=null?s:V;this.chunkSchema=Me(d.errorSchema),this.failedResponseHandler=A(d),this.supportsStructuredOutputs=(r=o.supportsStructuredOutputs)!=null?r:!1}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get supportedUrls(){var e,o,s;return(s=(o=(e=this.config).supportedUrls)==null?void 0:o.call(e))!=null?s:{}}transformRequestBody(e){var o,s,r;return(r=(s=(o=this.config).transformRequestBody)==null?void 0:s.call(o,e))!=null?r:e}async getArgs({prompt:e,maxOutputTokens:o,temperature:s,topP:r,topK:d,frequencyPenalty:c,presencePenalty:l,providerOptions:p,stopSequences:f,responseFormat:n,seed:u,toolChoice:a,tools:i}){var g,_,b,v,h;let w=[],C=await I({provider:"openai-compatible",providerOptions:p,schema:B});C!=null&&w.push({type:"other",message:"The 'openai-compatible' key in providerOptions is deprecated. Use 'openaiCompatible' instead."});let x=Object.assign(C??{},(g=await I({provider:"openaiCompatible",providerOptions:p,schema:B}))!=null?g:{},(_=await I({provider:this.providerOptionsName,providerOptions:p,schema:B}))!=null?_:{},(b=await I({provider:N(this.providerOptionsName),providerOptions:p,schema:B}))!=null?b:{}),S=(v=x?.strictJsonSchema)!=null?v:!0;d!=null&&w.push({type:"unsupported",feature:"topK"}),n?.type==="json"&&n.schema!=null&&!this.supportsStructuredOutputs&&w.push({type:"unsupported",feature:"responseFormat",details:"JSON response format schema is only supported with structuredOutputs"});let{tools:y,toolChoice:k,toolWarnings:E}=He({tools:i,toolChoice:a});return{metadataKey:Te(this.providerOptionsName,p),args:{model:this.modelId,user:x.user,max_tokens:o,temperature:s,top_p:r,frequency_penalty:c,presence_penalty:l,response_format:n?.type==="json"?this.supportsStructuredOutputs===!0&&n.schema!=null?{type:"json_schema",json_schema:{schema:n.schema,strict:S,name:(h=n.name)!=null?h:"response",description:n.description}}:{type:"json_object"}:void 0,stop:f,seed:u,...Object.fromEntries(Object.entries({...p?.[this.providerOptionsName],...p?.[N(this.providerOptionsName)]}).filter(([z])=>!Object.keys(B.shape).includes(z))),reasoning_effort:x.reasoningEffort,verbosity:x.textVerbosity,messages:Oe(e),tools:y,tool_choice:k},warnings:[...w,...E]}}async doGenerate(e){var o,s,r,d,c,l,p,f;let{args:n,warnings:u,metadataKey:a}=await this.getArgs({...e}),i=this.transformRequestBody(n),g=JSON.stringify(i),{responseHeaders:_,value:b,rawValue:v}=await q({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:O(this.config.headers(),e.headers),body:i,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:M(Ee),abortSignal:e.abortSignal,fetch:this.config.fetch}),h=b.choices[0],w=[],C=h.message.content;C!=null&&C.length>0&&w.push({type:"text",text:C});let x=(o=h.message.reasoning_content)!=null?o:h.message.reasoning;if(x!=null&&x.length>0&&w.push({type:"reasoning",text:x}),h.message.tool_calls!=null)for(let k of h.message.tool_calls){let E=(r=(s=k.extra_content)==null?void 0:s.google)==null?void 0:r.thought_signature;w.push({type:"tool-call",toolCallId:(d=k.id)!=null?d:P(),toolName:k.function.name,input:k.function.arguments,...E?{providerMetadata:{[a]:{thoughtSignature:E}}}:{}})}let S={[a]:{},...await((l=(c=this.config.metadataExtractor)==null?void 0:c.extractMetadata)==null?void 0:l.call(c,{parsedBody:v}))},y=(p=b.usage)==null?void 0:p.completion_tokens_details;return y?.accepted_prediction_tokens!=null&&(S[a].acceptedPredictionTokens=y?.accepted_prediction_tokens),y?.rejected_prediction_tokens!=null&&(S[a].rejectedPredictionTokens=y?.rejected_prediction_tokens),{content:w,finishReason:{unified:_e(h.finish_reason),raw:(f=h.finish_reason)!=null?f:void 0},usage:fe(b.usage),providerMetadata:S,request:{body:g},response:{...ve(b),headers:_,body:v},warnings:u}}async doStream(e){var o;let{args:s,warnings:r,metadataKey:d}=await this.getArgs({...e}),c=this.transformRequestBody({...s,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0}),l=(o=this.config.metadataExtractor)==null?void 0:o.createStreamExtractor(),{responseHeaders:p,value:f}=await q({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:O(this.config.headers(),e.headers),body:c,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:W(this.chunkSchema),abortSignal:e.abortSignal,fetch:this.config.fetch}),n=[],u={unified:"other",raw:void 0},a,i=!0,g=d,_=!1,b=!1;return{stream:f.pipeThrough(new TransformStream({start(v){v.enqueue({type:"stream-start",warnings:r})},transform(v,h){var w,C,x,S,y,k,E,G,z,Z,ee,te,ne,oe,se,ae,ie,re;if(e.includeRawChunks&&h.enqueue({type:"raw",rawValue:v.rawValue}),!v.success){u={unified:"error",raw:void 0},h.enqueue({type:"error",error:v.error});return}if(l?.processChunk(v.rawValue),"error"in v.value){u={unified:"error",raw:void 0},h.enqueue({type:"error",error:v.value.error});return}let D=v.value;i&&(i=!1,h.enqueue({type:"response-metadata",...ve(D)})),D.usage!=null&&(a=D.usage);let U=D.choices[0];if(U?.finish_reason!=null&&(u={unified:_e(U.finish_reason),raw:(w=U.finish_reason)!=null?w:void 0}),U?.delta==null)return;let J=U.delta,le=(C=J.reasoning_content)!=null?C:J.reasoning;if(le&&(_||(h.enqueue({type:"reasoning-start",id:"reasoning-0"}),_=!0),h.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:le})),J.content&&(_&&(h.enqueue({type:"reasoning-end",id:"reasoning-0"}),_=!1),b||(h.enqueue({type:"text-start",id:"txt-0"}),b=!0),h.enqueue({type:"text-delta",id:"txt-0",delta:J.content})),J.tool_calls!=null){_&&(h.enqueue({type:"reasoning-end",id:"reasoning-0"}),_=!1);for(let R of J.tool_calls){let L=(x=R.index)!=null?x:n.length;if(n[L]==null){if(R.id==null)throw new Q({data:R,message:"Expected 'id' to be a string."});if(((S=R.function)==null?void 0:S.name)==null)throw new Q({data:R,message:"Expected 'function.name' to be a string."});h.enqueue({type:"tool-input-start",id:R.id,toolName:R.function.name}),n[L]={id:R.id,type:"function",function:{name:R.function.name,arguments:(y=R.function.arguments)!=null?y:""},hasFinished:!1,thoughtSignature:(G=(E=(k=R.extra_content)==null?void 0:k.google)==null?void 0:E.thought_signature)!=null?G:void 0};let j=n[L];((z=j.function)==null?void 0:z.name)!=null&&((Z=j.function)==null?void 0:Z.arguments)!=null&&(j.function.arguments.length>0&&h.enqueue({type:"tool-input-delta",id:j.id,delta:j.function.arguments}),X(j.function.arguments)&&(h.enqueue({type:"tool-input-end",id:j.id}),h.enqueue({type:"tool-call",toolCallId:(ee=j.id)!=null?ee:P(),toolName:j.function.name,input:j.function.arguments,...j.thoughtSignature?{providerMetadata:{[g]:{thoughtSignature:j.thoughtSignature}}}:{}}),j.hasFinished=!0));continue}let T=n[L];T.hasFinished||(((te=R.function)==null?void 0:te.arguments)!=null&&(T.function.arguments+=(oe=(ne=R.function)==null?void 0:ne.arguments)!=null?oe:""),h.enqueue({type:"tool-input-delta",id:T.id,delta:(se=R.function.arguments)!=null?se:""}),((ae=T.function)==null?void 0:ae.name)!=null&&((ie=T.function)==null?void 0:ie.arguments)!=null&&X(T.function.arguments)&&(h.enqueue({type:"tool-input-end",id:T.id}),h.enqueue({type:"tool-call",toolCallId:(re=T.id)!=null?re:P(),toolName:T.function.name,input:T.function.arguments,...T.thoughtSignature?{providerMetadata:{[g]:{thoughtSignature:T.thoughtSignature}}}:{}}),T.hasFinished=!0))}}},flush(v){var h,w,C,x,S;_&&v.enqueue({type:"reasoning-end",id:"reasoning-0"}),b&&v.enqueue({type:"text-end",id:"txt-0"});for(let k of n.filter(E=>!E.hasFinished))v.enqueue({type:"tool-input-end",id:k.id}),v.enqueue({type:"tool-call",toolCallId:(h=k.id)!=null?h:P(),toolName:k.function.name,input:k.function.arguments,...k.thoughtSignature?{providerMetadata:{[g]:{thoughtSignature:k.thoughtSignature}}}:{}});let y={[g]:{},...l?.buildMetadata()};((w=a?.completion_tokens_details)==null?void 0:w.accepted_prediction_tokens)!=null&&(y[g].acceptedPredictionTokens=(C=a?.completion_tokens_details)==null?void 0:C.accepted_prediction_tokens),((x=a?.completion_tokens_details)==null?void 0:x.rejected_prediction_tokens)!=null&&(y[g].rejectedPredictionTokens=(S=a?.completion_tokens_details)==null?void 0:S.rejected_prediction_tokens),v.enqueue({type:"finish",finishReason:u,usage:fe(a),providerMetadata:y})}})),request:{body:c},response:{headers:p}}}},Re=t.looseObject({prompt_tokens:t.number().nullish(),completion_tokens:t.number().nullish(),total_tokens:t.number().nullish(),prompt_tokens_details:t.object({cached_tokens:t.number().nullish()}).nullish(),completion_tokens_details:t.object({reasoning_tokens:t.number().nullish(),accepted_prediction_tokens:t.number().nullish(),rejected_prediction_tokens:t.number().nullish()}).nullish()}).nullish(),Ee=t.looseObject({id:t.string().nullish(),created:t.number().nullish(),model:t.string().nullish(),choices:t.array(t.object({message:t.object({role:t.literal("assistant").nullish(),content:t.string().nullish(),reasoning_content:t.string().nullish(),reasoning:t.string().nullish(),tool_calls:t.array(t.object({id:t.string().nullish(),function:t.object({name:t.string(),arguments:t.string()}),extra_content:t.object({google:t.object({thought_signature:t.string().nullish()}).nullish()}).nullish()})).nullish()}),finish_reason:t.string().nullish()})),usage:Re}),Ae=t.looseObject({id:t.string().nullish(),created:t.number().nullish(),model:t.string().nullish(),choices:t.array(t.object({delta:t.object({role:t.enum(["assistant"]).nullish(),content:t.string().nullish(),reasoning_content:t.string().nullish(),reasoning:t.string().nullish(),tool_calls:t.array(t.object({index:t.number().nullish(),id:t.string().nullish(),function:t.object({name:t.string().nullish(),arguments:t.string().nullish()}),extra_content:t.object({google:t.object({thought_signature:t.string().nullish()}).nullish()}).nullish()})).nullish()}).nullish(),finish_reason:t.string().nullish()})),usage:Re}),Me=m(e=>t.union([Ae,e]),"createOpenAICompatibleChatChunkSchema");function be(e){var o,s;if(e==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let r=(o=e.prompt_tokens)!=null?o:0,d=(s=e.completion_tokens)!=null?s:0;return{inputTokens:{total:r,noCache:r,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:d,text:d,reasoning:void 0},raw:e}}m(be,"convertOpenAICompatibleCompletionUsage");function Ue({prompt:e,user:o="user",assistant:s="assistant"}){let r="";e[0].role==="system"&&(r+=`${e[0].content}
19
+
20
+ `,e=e.slice(1));for(let{role:d,content:c}of e)switch(d){case"system":throw new ue({message:"Unexpected system message in prompt: ${content}",prompt:e});case"user":{let l=c.map(p=>{if(p.type==="text")return p.text}).filter(Boolean).join("");r+=`${o}:
21
+ ${l}
22
+
23
+ `;break}case"assistant":{let l=c.map(p=>{switch(p.type){case"text":return p.text;case"tool-call":throw new H({functionality:"tool-call messages"})}}).join("");r+=`${s}:
24
+ ${l}
25
+
26
+ `;break}case"tool":throw new H({functionality:"tool messages"});default:{let l=d;throw new Error(`Unsupported role: ${l}`)}}return r+=`${s}:
27
+ `,{prompt:r,stopSequences:[`
28
+ ${o}:`]}}m(Ue,"convertToOpenAICompatibleCompletionPrompt");function ye({id:e,model:o,created:s}){return{id:e??void 0,modelId:o??void 0,timestamp:s!=null?new Date(s*1e3):void 0}}m(ye,"getResponseMetadata2");function we(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"other"}}m(we,"mapOpenAICompatibleFinishReason2");var xe=t.object({echo:t.boolean().optional(),logitBias:t.record(t.string(),t.number()).optional(),suffix:t.string().optional(),user:t.string().optional()}),Je=class{static{m(this,"OpenAICompatibleCompletionLanguageModel")}constructor(e,o){this.specificationVersion="v3";var s;this.modelId=e,this.config=o;let r=(s=o.errorStructure)!=null?s:V;this.chunkSchema=Pe(r.errorSchema),this.failedResponseHandler=A(r)}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get supportedUrls(){var e,o,s;return(s=(o=(e=this.config).supportedUrls)==null?void 0:o.call(e))!=null?s:{}}async getArgs({prompt:e,maxOutputTokens:o,temperature:s,topP:r,topK:d,frequencyPenalty:c,presencePenalty:l,stopSequences:p,responseFormat:f,seed:n,providerOptions:u,tools:a,toolChoice:i}){var g,_;let b=[],v=Object.assign((g=await I({provider:this.providerOptionsName,providerOptions:u,schema:xe}))!=null?g:{},(_=await I({provider:N(this.providerOptionsName),providerOptions:u,schema:xe}))!=null?_:{});d!=null&&b.push({type:"unsupported",feature:"topK"}),a?.length&&b.push({type:"unsupported",feature:"tools"}),i!=null&&b.push({type:"unsupported",feature:"toolChoice"}),f!=null&&f.type!=="text"&&b.push({type:"unsupported",feature:"responseFormat",details:"JSON response format is not supported."});let{prompt:h,stopSequences:w}=Ue({prompt:e}),C=[...w??[],...p??[]];return{args:{model:this.modelId,echo:v.echo,logit_bias:v.logitBias,suffix:v.suffix,user:v.user,max_tokens:o,temperature:s,top_p:r,frequency_penalty:c,presence_penalty:l,seed:n,...u?.[this.providerOptionsName],...u?.[N(this.providerOptionsName)],prompt:h,stop:C.length>0?C:void 0},warnings:b}}async doGenerate(e){let{args:o,warnings:s}=await this.getArgs(e),{responseHeaders:r,value:d,rawValue:c}=await q({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:O(this.config.headers(),e.headers),body:o,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:M(Ne),abortSignal:e.abortSignal,fetch:this.config.fetch}),l=d.choices[0],p=[];return l.text!=null&&l.text.length>0&&p.push({type:"text",text:l.text}),{content:p,usage:be(d.usage),finishReason:{unified:we(l.finish_reason),raw:l.finish_reason},request:{body:o},response:{...ye(d),headers:r,body:c},warnings:s}}async doStream(e){let{args:o,warnings:s}=await this.getArgs(e),r={...o,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0},{responseHeaders:d,value:c}=await q({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:O(this.config.headers(),e.headers),body:r,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:W(this.chunkSchema),abortSignal:e.abortSignal,fetch:this.config.fetch}),l={unified:"other",raw:void 0},p,f=!0;return{stream:c.pipeThrough(new TransformStream({start(n){n.enqueue({type:"stream-start",warnings:s})},transform(n,u){var a;if(e.includeRawChunks&&u.enqueue({type:"raw",rawValue:n.rawValue}),!n.success){l={unified:"error",raw:void 0},u.enqueue({type:"error",error:n.error});return}let i=n.value;if("error"in i){l={unified:"error",raw:void 0},u.enqueue({type:"error",error:i.error});return}f&&(f=!1,u.enqueue({type:"response-metadata",...ye(i)}),u.enqueue({type:"text-start",id:"0"})),i.usage!=null&&(p=i.usage);let g=i.choices[0];g?.finish_reason!=null&&(l={unified:we(g.finish_reason),raw:(a=g.finish_reason)!=null?a:void 0}),g?.text!=null&&u.enqueue({type:"text-delta",id:"0",delta:g.text})},flush(n){f||n.enqueue({type:"text-end",id:"0"}),n.enqueue({type:"finish",finishReason:l,usage:be(p)})}})),request:{body:r},response:{headers:d}}}},Se=t.object({prompt_tokens:t.number(),completion_tokens:t.number(),total_tokens:t.number()}),Ne=t.object({id:t.string().nullish(),created:t.number().nullish(),model:t.string().nullish(),choices:t.array(t.object({text:t.string(),finish_reason:t.string()})),usage:Se.nullish()}),Pe=m(e=>t.union([t.object({id:t.string().nullish(),created:t.number().nullish(),model:t.string().nullish(),choices:t.array(t.object({text:t.string(),finish_reason:t.string().nullish(),index:t.number()})),usage:Se.nullish()}),e]),"createOpenAICompatibleCompletionChunkSchema"),Y=t.object({dimensions:t.number().optional(),user:t.string().optional()}),$e=class{static{m(this,"OpenAICompatibleEmbeddingModel")}constructor(e,o){this.specificationVersion="v3",this.modelId=e,this.config=o}get provider(){return this.config.provider}get maxEmbeddingsPerCall(){var e;return(e=this.config.maxEmbeddingsPerCall)!=null?e:2048}get supportsParallelCalls(){var e;return(e=this.config.supportsParallelCalls)!=null?e:!0}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}async doEmbed({values:e,headers:o,abortSignal:s,providerOptions:r}){var d,c,l;let p=[],f=await I({provider:"openai-compatible",providerOptions:r,schema:Y});f!=null&&p.push({type:"other",message:"The 'openai-compatible' key in providerOptions is deprecated. Use 'openaiCompatible' instead."});let n=Object.assign(f??{},(d=await I({provider:"openaiCompatible",providerOptions:r,schema:Y}))!=null?d:{},(c=await I({provider:this.providerOptionsName,providerOptions:r,schema:Y}))!=null?c:{});if(e.length>this.maxEmbeddingsPerCall)throw new de({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:e});let{responseHeaders:u,value:a,rawValue:i}=await q({url:this.config.url({path:"/embeddings",modelId:this.modelId}),headers:O(this.config.headers(),o),body:{model:this.modelId,input:e,encoding_format:"float",dimensions:n.dimensions,user:n.user},failedResponseHandler:A((l=this.config.errorStructure)!=null?l:V),successfulResponseHandler:M(Be),abortSignal:s,fetch:this.config.fetch});return{warnings:p,embeddings:a.data.map(g=>g.embedding),usage:a.usage?{tokens:a.usage.prompt_tokens}:void 0,providerMetadata:a.providerMetadata,response:{headers:u,body:i}}}},Be=t.object({data:t.array(t.object({embedding:t.array(t.number())})),usage:t.object({prompt_tokens:t.number()}).nullish(),providerMetadata:t.record(t.string(),t.record(t.string(),t.any())).optional()}),Ve=class{static{m(this,"OpenAICompatibleImageModel")}constructor(e,o){this.modelId=e,this.config=o,this.specificationVersion="v3",this.maxImagesPerCall=10}get provider(){return this.config.provider}get providerOptionsKey(){return this.config.provider.split(".")[0].trim()}getArgs(e){return{...e[this.providerOptionsKey],...e[N(this.providerOptionsKey)]}}async doGenerate({prompt:e,n:o,size:s,aspectRatio:r,seed:d,providerOptions:c,headers:l,abortSignal:p,files:f,mask:n}){var u,a,i,g,_;let b=[];r!=null&&b.push({type:"unsupported",feature:"aspectRatio",details:"This model does not support aspect ratio. Use `size` instead."}),d!=null&&b.push({type:"unsupported",feature:"seed"});let v=(i=(a=(u=this.config._internal)==null?void 0:u.currentDate)==null?void 0:a.call(u))!=null?i:new Date,h=this.getArgs(c);if(f!=null&&f.length>0){let{value:x,responseHeaders:S}=await me({url:this.config.url({path:"/images/edits",modelId:this.modelId}),headers:O(this.config.headers(),l),formData:ce({model:this.modelId,prompt:e,image:await Promise.all(f.map(y=>ke(y))),mask:n!=null?await ke(n):void 0,n:o,size:s,...h}),failedResponseHandler:A((g=this.config.errorStructure)!=null?g:V),successfulResponseHandler:M(Ce),abortSignal:p,fetch:this.config.fetch});return{images:x.data.map(y=>y.b64_json),warnings:b,response:{timestamp:v,modelId:this.modelId,headers:S}}}let{value:w,responseHeaders:C}=await q({url:this.config.url({path:"/images/generations",modelId:this.modelId}),headers:O(this.config.headers(),l),body:{model:this.modelId,prompt:e,n:o,size:s,...h,response_format:"b64_json"},failedResponseHandler:A((_=this.config.errorStructure)!=null?_:V),successfulResponseHandler:M(Ce),abortSignal:p,fetch:this.config.fetch});return{images:w.data.map(x=>x.b64_json),warnings:b,response:{timestamp:v,modelId:this.modelId,headers:C}}}},Ce=t.object({data:t.array(t.object({b64_json:t.string()}))});async function ke(e){if(e.type==="url")return pe(e.url);let o=e.data instanceof Uint8Array?e.data:F(e.data);return new Blob([o],{type:e.mediaType})}m(ke,"fileToBlob");var ze="2.0.41";function ut(e){let o=ge(e.baseURL),s=e.name,r={...e.apiKey&&{Authorization:`Bearer ${e.apiKey}`},...e.headers},d=m(()=>he(r,`ai-sdk/openai-compatible/${ze}`),"getHeaders"),c=m(i=>({provider:`${s}.${i}`,url:m(({path:g})=>{let _=new URL(`${o}${g}`);return e.queryParams&&(_.search=new URLSearchParams(e.queryParams).toString()),_.toString()},"url"),headers:d,fetch:e.fetch}),"getCommonModelConfig"),l=m(i=>p(i),"createLanguageModel"),p=m(i=>new qe(i,{...c("chat"),includeUsage:e.includeUsage,supportsStructuredOutputs:e.supportsStructuredOutputs,transformRequestBody:e.transformRequestBody,metadataExtractor:e.metadataExtractor}),"createChatModel"),f=m(i=>new Je(i,{...c("completion"),includeUsage:e.includeUsage}),"createCompletionModel"),n=m(i=>new $e(i,{...c("embedding")}),"createEmbeddingModel"),u=m(i=>new Ve(i,c("image")),"createImageModel"),a=m(i=>l(i),"provider");return a.specificationVersion="v3",a.languageModel=l,a.chatModel=p,a.completionModel=f,a.embeddingModel=n,a.textEmbeddingModel=n,a.imageModel=u,a}m(ut,"createOpenAICompatible");export{qe as a,Je as b,$e as c,Ve as d,ze as e,ut as f};
@@ -0,0 +1,18 @@
1
+ // Built by esbuild from opencode-server source
2
+ if (typeof globalThis.Bun === 'undefined') {
3
+ globalThis.Bun = {
4
+ version: '0.0.0-node-compat',
5
+ stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
+ which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
+ };
8
+ }
9
+ if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
+ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
+ import { createRequire as __alchemyCreateRequire } from 'node:module';
12
+ const require = __alchemyCreateRequire(import.meta.url);
13
+ import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
14
+ import { dirname as __alchemyDirname } from 'node:path';
15
+ const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
16
+ const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
17
+
18
+ import{a as Z,b as $,d as ae}from"./chunk-V6HERYFV.js";import{h as X}from"./chunk-DO2UZ6NY.js";import{a as ne}from"./chunk-AZUMH3TO.js";import{Aj as _,Ce as J,E as k,Hc as w,Ka as P,Kc as m,Md as E,O as N,Oa as d,P as U,Rc as B,S as M,Ua as l,V as F,Yc as G,Zd as W,bd as Y,cd as j,he as H,n as I,o as S,rj as q,sb as V,tb as D,uj as z,vb as K,vj as Q}from"./chunk-ELPXQ32J.js";import{a as s,g as h}from"./chunk-2MRHL4B2.js";ae();var i=h(X(),1);var f=class extends d()("@effect/opentelemetry/Resource"){static{s(this,"Resource")}};var xe=s(e=>{let t={...e.attributes??void 0,[i.ATTR_SERVICE_NAME]:e.serviceName,[i.ATTR_TELEMETRY_SDK_NAME]:"@effect/opentelemetry",[i.ATTR_TELEMETRY_SDK_LANGUAGE]:typeof globalThis.document>"u"?i.TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS:i.TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS};return e.serviceVersion&&(t[i.ATTR_SERVICE_VERSION]=e.serviceVersion),t},"configToAttributes"),Oe=s(e=>m(f,E(function*(){let t=yield*Q(_("OTEL_SERVICE_NAME")),r=yield*_("OTEL_RESOURCE_ATTRIBUTES").pipe(z(""),q(a=>{let o=a.split(",");return P(o,{},(c,p)=>{let u=p.split("=");return u.length!==2||(c[u[0].trim()]=u[1].trim()),c})}));return t._tag==="Some"&&(r[i.ATTR_SERVICE_NAME]=t.value),e&&Object.assign(r,e),Z(r)}).pipe(H)),"layerFromEnv"),Ce=w(f,$());var n=h(ne(),1),b=h(X(),1);var ee=BigInt(1e9),g=s(e=>[Number(e/ee),Number(e%ee)],"nanosToHrTime"),T=s(e=>{let t={};for(let[r,a]of Object.entries(e))t[r]=R(a);return t},"recordToAttributes"),R=s(e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:typeof e=="bigint"?e.toString():k(e),"unknownToAttributeValue");var x=class extends d()("@effect/opentelemetry/Tracer"){static{s(this,"OtelTracer")}},A=class extends d()("@effect/opentelemetry/Tracer/OtelTracerProvider"){static{s(this,"OtelTracerProvider")}},O=class extends d()("@effect/opentelemetry/Tracer/OtelTraceFlags"){static{s(this,"OtelTraceFlags")}},C=class extends d()("@effect/opentelemetry/Tracer/OtelTraceState"){static{s(this,"OtelTraceState")}},ce=W(J(x),e=>V({span(t){return new y(n.context,n.trace,e,t)},context(t,r){let a=r.currentSpan;return a===void 0?t["~effect/Effect/evaluate"](r):n.context.with(re(n.context.active(),a),()=>t["~effect/Effect/evaluate"](r))}}));var de=m(x,E(function*(){let e=yield*f;return(yield*A).getTracer(e.attributes[b.ATTR_SERVICE_NAME],e.attributes[b.ATTR_SERVICE_VERSION])}));var ue=m(K,ce),Ge=ue.pipe(B(de));var v="~@effect/opentelemetry/Tracer/OtelSpan",fe={internal:n.SpanKind.INTERNAL,client:n.SpanKind.CLIENT,server:n.SpanKind.SERVER,producer:n.SpanKind.PRODUCER,consumer:n.SpanKind.CONSUMER},y=class{static{s(this,"OtelSpan")}[v];_tag="Span";name;kind;annotations;links;span;spanId;traceId;attributes=new Map;sampled;parent;status;constructor(t,r,a,o){this[v]=v,this.name=o.name,this.annotations=o.annotations,this.links=o.links,this.kind=o.kind;let c=t.active();this.parent=o.root!==!0?F(o.parent,()=>le(r,c,o.annotations)):o.parent,this.span=a.startSpan(o.name,{startTime:g(o.startTime),links:o.links.length>0?o.links.map(u=>({context:L(u.span),attributes:T(u.attributes)})):void 0,kind:fe[this.kind]},M(this.parent)?re(c,this.parent.value,o.annotations):n.trace.deleteSpan(c));let p=this.span.spanContext();this.spanId=p.spanId,this.traceId=p.traceId,this.status={_tag:"Started",startTime:o.startTime},this.sampled=pe(p.traceFlags)}attribute(t,r){this.span.setAttribute(t,R(r)),this.attributes.set(t,r)}addLinks(t){this.links.push(...t),this.span.addLinks(t.map(r=>({context:L(r.span),attributes:T(r.attributes)})))}end(t,r){let a=g(t);if(this.status={_tag:"Ended",endTime:t,exit:r,startTime:this.status.startTime},r._tag==="Success")this.span.setStatus({code:n.SpanStatusCode.OK});else if(G(r.cause))this.span.setStatus({code:n.SpanStatusCode.OK,message:j(r.cause)}),this.span.setAttribute("span.label","\u26A0\uFE0E Interrupted"),this.span.setAttribute("status.interrupted",!0);else{let o=Y(r.cause);if(o.length>0){for(let c of o)this.span.recordException(c,a);this.span.setStatus({code:n.SpanStatusCode.ERROR,message:o[0].message})}else this.span.setStatus({code:n.SpanStatusCode.OK})}this.span.end(a)}event(t,r,a){this.span.addEvent(t,a?T(a):void 0,g(r))}},pe=s(e=>(e&n.TraceFlags.SAMPLED)===n.TraceFlags.SAMPLED,"isSampled"),le=s((e,t,r)=>{let a=e.getSpan(t)?.spanContext();return a?U(D({spanId:a.spanId,traceId:a.traceId,sampled:(a.traceFlags&1)===1,annotations:r})):N()},"getOtelParent"),L=s((e,t)=>{let r=me(e,t),a=Se(e,t);return{spanId:e.spanId,traceId:e.traceId,isRemote:e._tag==="ExternalSpan",traceFlags:r,traceState:a}},"makeSpanContext"),me=s((e,t)=>{let r;return S(t)&&(r=te(e,t,O),I(r)&&(r=l(e.annotations,O))),r??n.TraceFlags.SAMPLED},"makeTraceFlags"),Se=s((e,t)=>{let r;return S(t)&&(r=te(e,t,C),I(r)&&(r=l(e.annotations,C))),r},"makeTraceState"),te=s((e,t,r)=>{let a=l(t,r);return S(a)?a:l(e.annotations,r)},"extractTraceService"),re=s((e,t,r)=>t instanceof y?n.trace.setSpan(e,t.span):n.trace.setSpanContext(e,L(t,r)),"populateContext");export{g as a,R as b,f as c,xe as d,Oe as e,Ce as f,x as g,A as h,Ge as i};
@@ -0,0 +1,18 @@
1
+ // Built by esbuild from opencode-server source
2
+ if (typeof globalThis.Bun === 'undefined') {
3
+ globalThis.Bun = {
4
+ version: '0.0.0-node-compat',
5
+ stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
+ which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
+ };
8
+ }
9
+ if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
+ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
+ import { createRequire as __alchemyCreateRequire } from 'node:module';
12
+ const require = __alchemyCreateRequire(import.meta.url);
13
+ import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
14
+ import { dirname as __alchemyDirname } from 'node:path';
15
+ const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
16
+ const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
17
+
18
+ import{c as K}from"./chunk-OCWGUTZJ.js";import{f as N,j as H}from"./chunk-CYRZU5QM.js";import{a as d,g as y}from"./chunk-2MRHL4B2.js";var F=y(K()),p=y(N());var f=y(N()),b=y(H());import{createHash as v,createPrivateKey as _,createPublicKey as B,sign as q}from"node:crypto";import{promises as D}from"node:fs";import{homedir as U}from"node:os";import{dirname as j,join as R}from"node:path";var m=class a{static{d(this,"LoginCredentialsFetcher")}profileData;init;callerClientConfig;static REFRESH_THRESHOLD=300*1e3;constructor(e,t,s){this.profileData=e,this.init=t,this.callerClientConfig=s}async loadCredentials(){let e=await this.loadToken();if(!e)throw new f.CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`,{tryNextLink:!1,logger:this.logger});let t=e.accessToken,s=Date.now();return new Date(t.expiresAt).getTime()-s<=a.REFRESH_THRESHOLD?this.refresh(e):this.toCredentials(e.accessToken)}get logger(){return this.init?.logger}get loginSession(){return this.profileData.login_session}toCredentials(e){return{accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken,accountId:e.accountId,expiration:new Date(e.expiresAt)}}async refresh(e){let t=await this.loadToken().catch(()=>e),s=Date.now(),r=new Date(t.accessToken.expiresAt).getTime(),i=new Date(e.accessToken.expiresAt).getTime(),o=r<=s&&i>s?e:t;if(new Date(o.accessToken.expiresAt).getTime()-Date.now()>a.REFRESH_THRESHOLD)return this.toCredentials(o.accessToken);let{SigninClient:h,CreateOAuth2TokenCommand:T}=await import("./signin-OCIW23YM.js"),{logger:x,userAgentAppId:E}=this.callerClientConfig??{},S=d(n=>n?.metadata?.handlerProtocol==="h2","isH2")(this.callerClientConfig?.requestHandler)?void 0:this.callerClientConfig?.requestHandler,u=this.profileData.region??await this.callerClientConfig?.region?.()??process.env.AWS_REGION,k=new h({credentials:{accessKeyId:"",secretAccessKey:""},region:u,requestHandler:S,logger:x,userAgentAppId:E,...this.init?.clientConfig});this.createDPoPInterceptor(k.middlewareStack);let I={tokenInput:{clientId:o.clientId,refreshToken:o.refreshToken,grantType:"refresh_token"}};try{let n=await k.send(new T(I)),{accessKeyId:l,secretAccessKey:w,sessionToken:g}=n.tokenOutput?.accessToken??{},{refreshToken:P,expiresIn:L}=n.tokenOutput??{};if(!l||!w||!g||!P)throw new f.CredentialsProviderError("Token refresh response missing required fields",{logger:this.logger,tryNextLink:!1});let O=(L??900)*1e3,$=new Date(Date.now()+O),A={...o,accessToken:{...o.accessToken,accessKeyId:l,secretAccessKey:w,sessionToken:g,expiresAt:$.toISOString()},refreshToken:P};return await this.saveToken(A),this.toCredentials(A.accessToken)}catch(n){if(n.name==="AccessDeniedException"){let w=n.error,g;switch(w){case"TOKEN_EXPIRED":g="Your session has expired. Please reauthenticate.";break;case"USER_CREDENTIALS_CHANGED":g="Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";break;case"INSUFFICIENT_PERMISSIONS":g="Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";break;default:g=`Failed to refresh token: ${String(n)}. Please re-authenticate using \`aws login\``}throw new f.CredentialsProviderError(g,{logger:this.logger,tryNextLink:!1})}if(new Date(o.accessToken.expiresAt).getTime()>Date.now())return this.logger?.warn?.(`Failed to refresh token: ${String(n)}. Using existing token until expiry.`),this.toCredentials(o.accessToken);throw new f.CredentialsProviderError(`Failed to refresh token: ${String(n)}. Please re-authenticate using aws login`,{logger:this.logger})}}async loadToken(){let e=this.getTokenFilePath();try{let t=await D.readFile(e,"utf8"),s=JSON.parse(t),r=["accessToken","clientId","refreshToken","dpopKey"].filter(i=>!s[i]);if(s.accessToken?.accountId||r.push("accountId"),r.length>0)throw new f.CredentialsProviderError(`Token validation failed, missing fields: ${r.join(", ")}`,{logger:this.logger,tryNextLink:!1});return s}catch(t){throw new f.CredentialsProviderError(`Failed to load token from ${e}: ${String(t)}`,{logger:this.logger,tryNextLink:!1})}}async saveToken(e){let t=this.getTokenFilePath(),s=j(t);try{await D.mkdir(s,{recursive:!0})}catch{}await D.writeFile(t,JSON.stringify(e,null,2),"utf8")}getTokenFilePath(){let e=process.env.AWS_LOGIN_CACHE_DIRECTORY??R(U(),".aws","login","cache"),t=Buffer.from(this.loginSession,"utf8"),s=v("sha256").update(t).digest("hex");return R(e,`${s}.json`)}derToRawSignature(e){let t=2;if(e[t]!==2)throw new Error("Invalid DER signature");t++;let s=e[t++],r=e.subarray(t,t+s);if(t+=s,e[t]!==2)throw new Error("Invalid DER signature");t++;let i=e[t++],o=e.subarray(t,t+i);r=r[0]===0?r.subarray(1):r,o=o[0]===0?o.subarray(1):o;let c=Buffer.concat([Buffer.alloc(32-r.length),r]),h=Buffer.concat([Buffer.alloc(32-o.length),o]);return Buffer.concat([c,h])}createDPoPInterceptor(e){e.add(t=>async s=>{if(b.HttpRequest.isInstance(s.request)){let r=s.request,i=`${r.protocol}//${r.hostname}${r.port?`:${r.port}`:""}${r.path}`,o=await this.generateDpop(r.method,i);r.headers={...r.headers,DPoP:o}}return t(s)},{step:"finalizeRequest",name:"dpopInterceptor",override:!0})}async generateDpop(e="POST",t){let s=await this.loadToken();try{let r=_({key:s.dpopKey,format:"pem",type:"sec1"}),o=B(r).export({format:"der",type:"spki"}),c=-1;for(let l=0;l<o.length;l++)if(o[l]===4){c=l;break}let h=o.slice(c+1,c+33),T=o.slice(c+33,c+65),x={alg:"ES256",typ:"dpop+jwt",jwk:{kty:"EC",crv:"P-256",x:h.toString("base64url"),y:T.toString("base64url")}},E={jti:crypto.randomUUID(),htm:e,htu:t,iat:Math.floor(Date.now()/1e3)},C=Buffer.from(JSON.stringify(x)).toString("base64url"),S=Buffer.from(JSON.stringify(E)).toString("base64url"),u=`${C}.${S}`,k=q("sha256",Buffer.from(u),r),n=this.derToRawSignature(k).toString("base64url");return`${u}.${n}`}catch(r){throw new f.CredentialsProviderError(`Failed to generate Dpop proof: ${r instanceof Error?r.message:String(r)}`,{logger:this.logger,tryNextLink:!1})}}};var G=d(a=>async({callerClientConfig:e}={})=>{a?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");let t=await(0,p.parseKnownFiles)(a||{}),s=(0,p.getProfileName)({profile:a?.profile??e?.profile}),r=t[s];if(!r?.login_session)throw new p.CredentialsProviderError(`Profile ${s} does not contain login_session.`,{tryNextLink:!0,logger:a?.logger});let o=await new m(r,a,e).loadCredentials();return(0,F.setCredentialFeature)(o,"CREDENTIALS_LOGIN","AD")},"fromLoginCredentials");export{G as a};