alchemylab-opencode 2.0.1 → 2.0.3

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-ND6UHXWL.js +18 -0
  43. package/dist/app-runtime-ZWWQ4JTM.js +18 -0
  44. package/dist/chunk-2MRHL4B2.js +18 -0
  45. package/dist/chunk-2XWBNI3L.js +1490 -0
  46. package/dist/chunk-4MBUHJHY.js +22 -0
  47. package/dist/chunk-6MAPFAXY.js +190 -0
  48. package/dist/chunk-7XX6TY62.js +259 -0
  49. package/dist/chunk-ANF3QA3Z.js +48 -0
  50. package/dist/chunk-AUB2TEYJ.js +55 -0
  51. package/dist/chunk-AZUMH3TO.js +18 -0
  52. package/dist/chunk-BQ4IEPN3.js +19 -0
  53. package/dist/chunk-CYRZU5QM.js +33 -0
  54. package/dist/chunk-DGJQZN2Q.js +18 -0
  55. package/dist/chunk-DO2UZ6NY.js +18 -0
  56. package/dist/chunk-DZ6G4VSD.js +19 -0
  57. package/dist/chunk-EK6FQQHY.js +20 -0
  58. package/dist/chunk-ELPXQ32J.js +90 -0
  59. package/dist/chunk-F5PY52BY.js +18 -0
  60. package/dist/chunk-FGLPSSRK.js +19 -0
  61. package/dist/chunk-FV7U6PVP.js +18 -0
  62. package/dist/chunk-FYYAOZPU.js +18 -0
  63. package/dist/chunk-GDWO6EXN.js +22 -0
  64. package/dist/chunk-GW3ZRKAI.js +20 -0
  65. package/dist/chunk-IQSFXWDQ.js +18 -0
  66. package/dist/chunk-IYUSBBGY.js +35 -0
  67. package/dist/chunk-JPOFLMNH.js +18 -0
  68. package/dist/{chunk-VURLSDCB.js → chunk-K5LKDIVU.js} +4 -0
  69. package/dist/chunk-KS4WLVK5.js +19 -0
  70. package/dist/chunk-L3CE2Y3L.js +55 -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-OCWGUTZJ.js +36 -0
  78. package/dist/chunk-OGDRUXMJ.js +18 -0
  79. package/dist/chunk-OGJKLJC7.js +29 -0
  80. package/dist/chunk-P5RLCJUV.js +18 -0
  81. package/dist/chunk-Q3WIUQXB.js +18 -0
  82. package/dist/{20260227213759_add_session_workspace_id-ROENWPKA.js → chunk-QCRIXKIC.js} +5 -1
  83. package/dist/chunk-QD24DLUD.js +18 -0
  84. package/dist/chunk-R2GWBJEP.js +18 -0
  85. package/dist/chunk-RIA6SDOY.js +780 -0
  86. package/dist/chunk-RPAXSOGH.js +18 -0
  87. package/dist/chunk-TK5R7QUN.js +18 -0
  88. package/dist/chunk-TNQWZFIZ.js +28 -0
  89. package/dist/chunk-UCLPBO4I.js +18 -0
  90. package/dist/chunk-V6FDDNGV.js +117 -0
  91. package/dist/chunk-V6HERYFV.js +18 -0
  92. package/dist/chunk-V7XKKJ7X.js +24 -0
  93. package/dist/chunk-VHDYUBBS.js +23 -0
  94. package/dist/chunk-VWLJXTZ5.js +18 -0
  95. package/dist/chunk-VXAPFOIL.js +22 -0
  96. package/dist/chunk-WKZYINC7.js +29 -0
  97. package/dist/chunk-WL33KE3H.js +920 -0
  98. package/dist/chunk-WPMP2ZFE.js +40 -0
  99. package/dist/chunk-WRTNIOI3.js +18 -0
  100. package/dist/chunk-WZ4237YY.js +19 -0
  101. package/dist/chunk-X5F46HR5.js +18 -0
  102. package/dist/chunk-XPS7TQZG.js +22 -0
  103. package/dist/chunk-XSKT4AXR.js +878 -0
  104. package/dist/chunk-YJPP6IQ3.js +23 -0
  105. package/dist/chunk-ZYQWFC55.js +22 -0
  106. package/dist/code-mode-H3HRSD24.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/dist-HXJTF22W.js +32 -0
  112. package/dist/dist-JFXI53ZF.js +22 -0
  113. package/dist/dist-KBYKWVT5.js +22 -0
  114. package/dist/dist-KGNO5AP7.js +35 -0
  115. package/dist/dist-KTNLTEHB.js +18 -0
  116. package/dist/dist-KZ5R5QM5.js +24 -0
  117. package/dist/{20260605042240_add_context_epoch_agent-W6IQYZXE.js → dist-LOXU6IEM.js} +5 -1
  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-WZJ3LNRG.js +28 -0
  129. package/dist/dist-XAFENVUS.js +22 -0
  130. package/dist/dist-XPFB35TX.js +32 -0
  131. package/dist/dist-es-43ZM44MP.js +18 -0
  132. package/dist/dist-es-CH2YKBKX.js +18 -0
  133. package/dist/{20260428004200_add_session_path-LGW75WYA.js → dist-es-DHCTZZ2E.js} +5 -1
  134. package/dist/dist-es-EVVG3KDV.js +26 -0
  135. package/dist/dist-es-HRCONNGK.js +18 -0
  136. package/dist/dist-es-L2GU465G.js +18 -0
  137. package/dist/dist-es-RGEIM2BP.js +18 -0
  138. package/dist/dist-es-RZ25XEH6.js +18 -0
  139. package/dist/dist-es-SITTNOGV.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-7VH6D2QJ.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-GSWEOYZ5.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-XRUYBM7W.js +21 -0
  163. package/dist/session-4BXV4JJH.js +18 -0
  164. package/dist/signin-DKBWDEYP.js +18 -0
  165. package/dist/src-JODD73WX.js +18 -0
  166. package/dist/src-QJHT5SCV.js +18 -0
  167. package/dist/src-SMM4U63G.js +18 -0
  168. package/dist/src-WDYKISPD.js +20 -0
  169. package/dist/sso-oidc-S3P64MCY.js +18 -0
  170. package/dist/sts-RG44NMOQ.js +18 -0
  171. package/dist/token-2V62AM3G.js +18 -0
  172. package/dist/token-util-VXONHEUD.js +18 -0
  173. package/dist/unified-W3ZKZ4HG.js +18 -0
  174. package/dist/worktree-B2LROS2B.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{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};