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,20 @@
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{h as J,j as ee}from"./chunk-CYRZU5QM.js";import{a as i,c as p,e as Se,g as I}from"./chunk-2MRHL4B2.js";function D(n){let e=n&&typeof n=="object"&&"reason"in n?n.reason:void 0;if(e){if(e instanceof Error){let o=new Error("Request aborted");return o.name="AbortError",o.cause=e,o}let r=new Error(String(e));return r.name="AbortError",r}let t=new Error("Request aborted");return t.name="AbortError",t}var G=p(()=>{i(D,"buildAbortError")});var te,oe=p(()=>{te=["ECONNRESET","EPIPE","ETIMEDOUT"]});var ne,N,X=p(()=>{ne=I(J()),N=i(n=>{let e={};for(let t in n){if(!(0,ne.hasOwn)(n,t))continue;let r=n[t];e[t]=Array.isArray(r)?r.join(","):r}return e},"getTransformedHeaders")});import L from"node:https";var re=p(()=>{});var u,v=p(()=>{u={setTimeout:i((n,e)=>setTimeout(n,e),"setTimeout"),clearTimeout:i(n=>clearTimeout(n),"clearTimeout")}});var se,ie,ce=p(()=>{v();se=1e3,ie=i((n,e,t=0)=>{if(!t)return-1;let r=i(o=>{let a=u.setTimeout(()=>{n.destroy(),e(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${t} ms.`),{name:"TimeoutError"}))},t-o),c=i(m=>{m?.connecting?m.on("connect",()=>{u.clearTimeout(a)}):u.clearTimeout(a)},"doWithSocket");n.socket?c(n.socket):n.on("socket",c)},"registerTimeout");return t<2e3?(r(0),0):u.setTimeout(r.bind(null,se),se)},"setConnectionTimeout")});var ae,fe=p(()=>{v();ae=i((n,e,t=0,r,o)=>t?u.setTimeout(()=>{let a=`@smithy/node-http-handler - [${r?"ERROR":"WARN"}] a request has exceeded the configured ${t} ms requestTimeout.`;if(r){let c=Object.assign(new Error(a),{name:"TimeoutError",code:"ETIMEDOUT"});n.destroy(c),e(c)}else a+=" Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.",o?.warn?.(a)},t):-1,"setRequestTimeout")});var _e,ue,me=p(()=>{v();_e=3e3,ue=i((n,{keepAlive:e,keepAliveMsecs:t},r=_e)=>{if(e!==!0)return-1;let o=i(()=>{n.socket?n.socket.setKeepAlive(e,t||0):n.on("socket",a=>{a.setKeepAlive(e,t||0)})},"registerListener");return r===0?(o(),0):u.setTimeout(o,r)},"setSocketKeepAlive")});var de,he,le=p(()=>{v();de=3e3,he=i((n,e,t=0)=>{let r=i(o=>{let a=t-o,c=i(()=>{n.destroy(),e(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${t} ms of inactivity (configured by client requestHandler).`),{name:"TimeoutError"}))},"onTimeout");n.socket?(n.socket.setTimeout(a,c),n.on("close",()=>n.socket?.removeListener("timeout",c))):n.setTimeout(a,c)},"registerTimeout");return 0<t&&t<6e3?(r(0),0):u.setTimeout(r.bind(null,t===0?0:de),de)},"setSocketTimeout")});import{Readable as He}from"node:stream";async function F(n,e,t=pe,r=!1){let o=e.headers,a=o?o.Expect||o.expect:void 0,c=-1,m=!0;!r&&a==="100-continue"&&(m=await Promise.race([new Promise(f=>{c=Number(u.setTimeout(()=>f(!0),Math.max(pe,t)))}),new Promise(f=>{n.on("continue",()=>{u.clearTimeout(c),f(!0)}),n.on("response",()=>{u.clearTimeout(c),f(!1)}),n.on("error",()=>{u.clearTimeout(c),f(!1)})})])),m&&De(n,e.body)}function De(n,e){if(e instanceof He){e.pipe(n);return}if(e){let t=Buffer.isBuffer(e);if(t||typeof e=="string"){t&&e.byteLength===0?n.end():n.end(e);return}let o=e;if(typeof o=="object"&&o.buffer&&typeof o.byteOffset=="number"&&typeof o.byteLength=="number"){n.end(Buffer.from(o.buffer,o.byteOffset,o.byteLength));return}n.end(Buffer.from(e));return}n.end()}var pe,Y=p(()=>{v();pe=6e3;i(F,"writeRequestBody");i(De,"writeBody")});var ye,W,Te,B,ge,j,Ee=p(()=>{ye=I(J()),W=I(ee());G();oe();X();re();ce();fe();me();le();v();Y();Te=0,j=class n{static{i(this,"NodeHttpHandler")}config;configProvider;socketWarningTimestamp=0;externalAgent=!1;metadata={handlerProtocol:"http/1.1"};static create(e){return typeof e?.handle=="function"?e:new n(e)}static checkSocketUsage(e,t,r=console){let{sockets:o,requests:a,maxSockets:c}=e;if(typeof c!="number"||c===1/0||Date.now()-15e3<t)return t;if(o&&a)for(let f in o){if(!(0,ye.hasOwn)(o,f))continue;let h=o[f]?.length??0,g=a[f]?.length??0;if(h>=c&&g>=2*c)return r?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${h} and ${g} additional requests are enqueued.
19
+ See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
20
+ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`),Date.now()}return t}constructor(e){this.configProvider=new Promise((t,r)=>{typeof e=="function"?e().then(o=>{t(this.resolveDefaultConfig(o))}).catch(r):t(this.resolveDefaultConfig(e))})}destroy(){this.config?.httpAgent?.destroy(),this.config?.httpsAgent?.destroy()}async handle(e,{abortSignal:t,requestTimeout:r}={}){this.config||(this.config=await this.configProvider);let o=this.config,a=o.logger,c=e.protocol==="https:";return!c&&!this.config.httpAgent&&(this.config.httpAgent=await this.config.httpAgentProvider()),new Promise((m,f)=>{let h,g=-1,y=-1,x=-1,P=-1,C=-1,O=i(()=>{u.clearTimeout(g),u.clearTimeout(y),u.clearTimeout(x),u.clearTimeout(P),u.clearTimeout(C)},"clearTimeouts"),V=i(async s=>{await h,O(),m(s)},"resolve"),w=i(async s=>{await h,O(),f(s)},"reject");if(t?.aborted){let s=D(t);w(s);return}let $=e.headers,M=$?($.Expect??$.expect)==="100-continue":!1,k=c?o.httpsAgent:o.httpAgent;M&&!this.externalAgent&&(k=new(c?L.Agent:B)({keepAlive:!1,maxSockets:1/0})),g=u.setTimeout(()=>{this.socketWarningTimestamp=n.checkSocketUsage(k,this.socketWarningTimestamp,a)},o.socketAcquisitionWarningTimeout??(o.requestTimeout??2e3)+(o.connectionTimeout??1e3));let U=e.query?(0,W.buildQueryString)(e.query):"",R;if(e.username!=null||e.password!=null){let s=e.username??"",d=e.password??"";R=`${s}:${d}`}let S=e.path;U&&(S+=`?${U}`),e.fragment&&(S+=`#${e.fragment}`);let T=e.hostname??"";T[0]==="["&&T.endsWith("]")?T=e.hostname.slice(1,-1):T=e.hostname;let _={headers:e.headers,host:T,method:e.method,path:S,port:e.port,agent:k,auth:R},E=(c?L.request:ge)(_,s=>{let d=new W.HttpResponse({statusCode:s.statusCode||-1,reason:s.statusMessage,headers:N(s.headers),body:s});V({response:d})});if(E.on("error",s=>{te.includes(s.code)?w(Object.assign(s,{name:"TimeoutError"})):w(s)}),t){let s=i(()=>{E.destroy();let d=D(t);w(d)},"onAbort");if(typeof t.addEventListener=="function"){let d=t;d.addEventListener("abort",s,{once:!0}),E.once("close",()=>d.removeEventListener("abort",s))}else t.onabort=s}let H=r??o.requestTimeout;y=ie(E,w,o.connectionTimeout),x=ae(E,w,H,o.throwOnRequestTimeout,a??console),P=he(E,w,o.socketTimeout);let l=_.agent;typeof l=="object"&&"keepAlive"in l&&(C=ue(E,{keepAlive:l.keepAlive,keepAliveMsecs:l.keepAliveMsecs})),h=F(E,e,H,this.externalAgent).catch(s=>(O(),f(s)))})}updateHttpClientConfig(e,t){this.config=void 0,this.configProvider=this.configProvider.then(r=>e===Symbol.for("logger")?{...r,logger:r.logger??t}:{...r,[e]:t})}httpHandlerConfigs(){return this.config??{}}resolveDefaultConfig(e){let{requestTimeout:t,connectionTimeout:r,socketTimeout:o,socketAcquisitionWarningTimeout:a,httpAgent:c,httpsAgent:m,throwOnRequestTimeout:f,logger:h}=e||{},g=!0,y=50;return{connectionTimeout:r,requestTimeout:t,socketTimeout:o,socketAcquisitionWarningTimeout:a,throwOnRequestTimeout:f,httpAgentProvider:i(async()=>{let x=await import("node:http"),{Agent:P,request:C}=x.default??x;return ge=C,B=P,c instanceof B||typeof c?.destroy=="function"?(this.externalAgent=!0,c):new B({keepAlive:g,maxSockets:y,...c})},"httpAgentProvider"),httpsAgent:m instanceof L.Agent||typeof m?.destroy=="function"?(this.externalAgent=!0,m):new L.Agent({keepAlive:g,maxSockets:y,...m}),logger:h}}}});import we from"node:http2";var xe=p(()=>{});var Oe,b,Z=p(()=>{Oe=new Uint16Array(1),b=class{static{i(this,"ClientHttp2SessionRef")}id=Oe[0]++;total=0;max=0;session;refs=0;constructor(e){e.unref(),this.session=e}retain(){if(this.session.destroyed)throw new Error("@smithy/node-http-handler - cannot acquire reference to destroyed session.");this.refs+=1,this.total+=1,this.max=Math.max(this.refs,this.max),this.session.ref()}free(){if(!this.session.destroyed&&(this.refs-=1,this.refs===0&&this.session.unref(),this.refs<0))throw new Error("@smithy/node-http-handler - ClientHttp2Session refcount at zero, cannot decrement.")}deref(){return this.session}close(){this.session.closed||this.session.close()}destroy(){this.refs=0,this.session.destroyed||(this.session.setTimeout(0),this.session.destroy())}useCount(){return this.refs}}});var q,Ce=p(()=>{Z();q=class{static{i(this,"NodeHttp2ConnectionPool")}sessions=[];maxConcurrency=0;constructor(e){this.sessions=(e??[]).map(t=>new b(t))}poll(){let e=!1;for(let t of this.sessions){if(t.deref().destroyed){e=!0;continue}if(!this.maxConcurrency||t.useCount()<this.maxConcurrency)return t}if(e)for(let t of this.sessions)t.deref().destroyed&&this.remove(t)}offerLast(e){this.sessions.push(e)}remove(e){let t=this.sessions.indexOf(e);t>-1&&this.sessions.splice(t,1)}[Symbol.iterator](){return this.sessions[Symbol.iterator]()}setMaxConcurrency(e){this.maxConcurrency=e}destroy(e){this.remove(e),e.destroy()}}});import Ae from"node:http2";var z,ve=p(()=>{Z();Ce();z=class{static{i(this,"NodeHttp2ConnectionManager")}config;connectOptions;connectionPools=new Map;constructor(e){if(this.config=e,this.config.maxConcurrency&&this.config.maxConcurrency<=0)throw new RangeError("maxConcurrency must be greater than zero.")}lease(e,t){let r=this.getUrlString(e),o=this.getPool(r);if(!this.config.disableConcurrency&&!t.isEventStream){let h=o.poll();if(h)return h.retain(),h}let a=new b(this.connect(r)),c=a.deref();this.config.maxConcurrency&&c.settings({maxConcurrentStreams:this.config.maxConcurrency},h=>{if(h)throw new Error("Fail to set maxConcurrentStreams to "+this.config.maxConcurrency+"when creating new session for "+e.destination.toString())});let m=i(()=>{this.removeFromPoolAndClose(r,a)},"graceful"),f=i(()=>{this.removeFromPoolAndCheckedDestroy(r,a)},"ensureDestroyed");return c.on("goaway",m),c.on("error",f),c.on("frameError",f),c.on("close",f),t.requestTimeout&&c.setTimeout(t.requestTimeout,f),o.offerLast(a),a.retain(),a}release(e,t){t.free()}createIsolatedSession(e,t){let r=this.getUrlString(e),o=new b(this.connect(r)),a=o.deref();a.settings({maxConcurrentStreams:1});let c=i(()=>{o.destroy()},"ensureDestroyed");a.on("error",c),a.on("frameError",c),a.on("close",c);let m=t.requestTimeout??3e5;return a.setTimeout(m,c),o.retain(),o}destroy(){for(let[e,t]of this.connectionPools){for(let r of[...t])r.destroy();this.connectionPools.delete(e)}}setMaxConcurrentStreams(e){if(e&&e<=0)throw new RangeError("maxConcurrentStreams must be greater than zero.");this.config.maxConcurrency=e;for(let t of this.connectionPools.values())t.setMaxConcurrency(e)}setDisableConcurrentStreams(e){this.config.disableConcurrency=e}setNodeHttp2ConnectOptions(e){this.connectOptions=e}debug(){let e={};for(let[t,r]of this.connectionPools){let o=[];for(let a of r)o.push({id:a.id,active:a.useCount(),maxConcurrent:a.max,totalRequests:a.total});e[t]={sessions:o}}return e}removeFromPoolAndClose(e,t){this.connectionPools.get(e)?.remove(t),t.close()}removeFromPoolAndCheckedDestroy(e,t){this.connectionPools.get(e)?.remove(t),t.destroy()}getPool(e){if(!this.connectionPools.has(e)){let t=new q;this.config.maxConcurrency&&t.setMaxConcurrency(this.config.maxConcurrency),this.connectionPools.set(e,t)}return this.connectionPools.get(e)}getUrlString(e){return e.destination.toString()}connect(e){return this.connectOptions===void 0?Ae.connect(e):Ae.connect(e,this.connectOptions)}}});var Q,be,K,Pe=p(()=>{Q=I(ee());G();X();xe();ve();Y();({constants:be}=we),K=class n{static{i(this,"NodeHttp2Handler")}config;configProvider;metadata={handlerProtocol:"h2"};connectionManager=new z({});static create(e){return typeof e?.handle=="function"?e:new n(e)}constructor(e){this.configProvider=new Promise((t,r)=>{typeof e=="function"?e().then(o=>{t(o||{})}).catch(r):t(e||{})})}destroy(){this.connectionManager.destroy()}async handle(e,{abortSignal:t,requestTimeout:r,isEventStream:o}={}){if(!this.config){this.config=await this.configProvider;let{disableConcurrentStreams:h,maxConcurrentStreams:g,nodeHttp2ConnectOptions:y}=this.config;this.connectionManager.setDisableConcurrentStreams(h??!1),g&&this.connectionManager.setMaxConcurrentStreams(g),y&&this.connectionManager.setNodeHttp2ConnectOptions(y)}let{requestTimeout:a,disableConcurrentStreams:c}=this.config,m=c||o,f=r??a;return new Promise((h,g)=>{let y=!1,x,P=i(async s=>{await x,h(s)},"resolve"),C=i(async s=>{await x,g(s)},"reject");if(t?.aborted){y=!0;let s=D(t);C(s);return}let{hostname:O,method:V,port:w,protocol:$,query:M}=e,k="";if(e.username!=null||e.password!=null){let s=e.username??"",d=e.password??"";k=`${s}:${d}@`}let U=`${$}//${k}${O}${w?`:${w}`:""}`,R={destination:new URL(U)},S={requestTimeout:this.config?.sessionTimeout,isEventStream:o},T=m?this.connectionManager.createIsolatedSession(R,S):this.connectionManager.lease(R,S),_=T.deref(),A=i(s=>{m&&T.destroy(),y=!0,C(s)},"rejectWithDestroy"),E=M?(0,Q.buildQueryString)(M):"",H=e.path;E&&(H+=`?${E}`),e.fragment&&(H+=`#${e.fragment}`);let l=_.request({...e.headers,[be.HTTP2_HEADER_PATH]:H,[be.HTTP2_HEADER_METHOD]:V});if(f&&l.setTimeout(f,()=>{l.close();let s=new Error(`Stream timed out because of no activity for ${f} ms`);s.name="TimeoutError",A(s)}),t){let s=i(()=>{l.close();let d=D(t);A(d)},"onAbort");if(typeof t.addEventListener=="function"){let d=t;d.addEventListener("abort",s,{once:!0}),l.once("close",()=>d.removeEventListener("abort",s))}else t.onabort=s}l.on("frameError",(s,d,Re)=>{A(new Error(`Frame type id ${s} in stream id ${Re} has failed with code ${d}.`))}),l.on("error",A),l.on("aborted",()=>{A(new Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${l.rstCode}.`))}),l.on("response",s=>{let d=new Q.HttpResponse({statusCode:s[":status"]??-1,headers:N(s),body:l});y=!0,P({response:d}),m&&(_.close(),l.on("end",()=>{T.destroy()}))}),l.on("close",()=>{if(m?T.destroy():this.connectionManager.release(R,T),!y){let s=new Error("Unexpected error: http2 request did not get a response");_.destroyed&&(s.name="TimeoutError"),A(s)}}),x=F(l,e,f)})}updateHttpClientConfig(e,t){this.config=void 0,this.configProvider=this.configProvider.then(r=>({...r,[e]:t}))}httpHandlerConfigs(){return this.config??{}}}});var $e={};Se($e,{DEFAULT_REQUEST_TIMEOUT:()=>Te,NodeHttp2Handler:()=>K,NodeHttpHandler:()=>j,streamCollector:()=>ke.streamCollector});var ke,Ie=p(()=>{Ee();Pe();ke=I(J())});export{j as a,$e as b,Ie as c};