alran 0.9.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/ALRAN_TOOLS_NOTICES.md +11 -0
  2. package/README.md +11 -16
  3. package/assets/agents/alran/skills/alran-code-product/SKILL.md +3 -3
  4. package/assets/agents/alran/skills/alran-code-product/references/account-models.md +19 -16
  5. package/chunks/{account-commands-JZ6NXTTK.js → account-commands-GW7N3MYC.js} +1 -1
  6. package/chunks/{anthropic-MN33DP4E.js → anthropic-63VE6MAE.js} +1 -1
  7. package/chunks/{application-ITGAJ4HC.js → application-WPPTE6LU.js} +1 -1
  8. package/chunks/{auth-command-V3RVPLZO.js → auth-command-36RMNQZW.js} +1 -1
  9. package/chunks/azure-openai-responses-OIP3KVKJ.js +2 -0
  10. package/chunks/chunk-2K5H5GA7.js +2 -0
  11. package/chunks/chunk-3GGKARES.js +2 -0
  12. package/chunks/chunk-5RIMHTEU.js +207 -0
  13. package/chunks/{chunk-EYK25HWR.js → chunk-5Y76VFHY.js} +1 -1
  14. package/chunks/{chunk-QIN5ZBE2.js → chunk-6DOVXX7W.js} +1 -1
  15. package/chunks/{chunk-E3GLGDGC.js → chunk-6PFI65C6.js} +1 -1
  16. package/chunks/{chunk-4PDIO3M6.js → chunk-6UXSIWCB.js} +1 -1
  17. package/chunks/{chunk-OQNU3VPS.js → chunk-C6LAAFG2.js} +2 -2
  18. package/chunks/{chunk-33CNY6GP.js → chunk-CUG7F2FN.js} +1 -1
  19. package/chunks/chunk-DFMYLGVU.js +249 -0
  20. package/chunks/{chunk-IIE366LR.js → chunk-G5MOGPZ3.js} +490 -485
  21. package/chunks/{chunk-FC4M2B7E.js → chunk-IC6A323Q.js} +1 -1
  22. package/chunks/{chunk-4X22UJQH.js → chunk-IN2Z5SSJ.js} +1 -1
  23. package/chunks/chunk-JSTSFMGK.js +70 -0
  24. package/chunks/{chunk-WWNUAU4P.js → chunk-LCC45PCZ.js} +1 -1
  25. package/chunks/{chunk-7QLAXRD2.js → chunk-MPQ6G7LH.js} +254 -254
  26. package/chunks/{chunk-FUERW2DW.js → chunk-MUXNNOSQ.js} +1 -1
  27. package/chunks/{chunk-44VPC5LA.js → chunk-NBONSNQZ.js} +1 -1
  28. package/chunks/chunk-NMKRNU5O.js +2 -0
  29. package/chunks/chunk-NVPGGFT3.js +2 -0
  30. package/chunks/chunk-NZXJAHTO.js +9 -0
  31. package/chunks/{chunk-6255CZPL.js → chunk-PCL2CVVE.js} +1 -1
  32. package/chunks/chunk-PXH4SBCS.js +3 -0
  33. package/chunks/chunk-RLJVY75P.js +28 -0
  34. package/chunks/{chunk-WYANV3IX.js → chunk-RLND4AYL.js} +1 -1
  35. package/chunks/chunk-TJC4LPRQ.js +2 -0
  36. package/chunks/chunk-U4PFHJ7Z.js +27 -0
  37. package/chunks/chunk-V2SB4U4D.js +2 -0
  38. package/chunks/chunk-VGKKKM2W.js +6 -0
  39. package/chunks/{chunk-XFCC2CI2.js → chunk-VUISZDXX.js} +1 -1
  40. package/chunks/chunk-XVGPB7TW.js +21 -0
  41. package/chunks/{chunk-CJM7ZJ6W.js → chunk-ZDI22NOK.js} +1 -1
  42. package/chunks/{data-dir-LDVKDCJ2.js → data-dir-OEPRRIOO.js} +1 -1
  43. package/chunks/{dist-2BRD4JFU.js → dist-VKYZJYR6.js} +1 -1
  44. package/chunks/{dist-EXKHRFQO.js → dist-WGTMUM3E.js} +1 -1
  45. package/chunks/{ffi-OUPK6AY6.js → ffi-EFLUAAVX.js} +1 -1
  46. package/chunks/{ffi-M5UP5J6C.js → ffi-QKKA5HYI.js} +1 -1
  47. package/chunks/{google-UJAPMFAB.js → google-RCR46TTQ.js} +1 -1
  48. package/chunks/{google-vertex-VLSF55PW.js → google-vertex-Y26T7YYR.js} +1 -1
  49. package/chunks/{install-source-JTIUC4G4.js → install-source-63OVVBMK.js} +1 -1
  50. package/chunks/launcher-2UG3JPYF.js +63 -0
  51. package/chunks/lifecycle-5IPJRP2V.js +2 -0
  52. package/chunks/{main-TQGGRHTS.js → main-7SGOQBHZ.js} +2 -2
  53. package/chunks/{mistral-ZJZUEF2X.js → mistral-NEBDKUEI.js} +1 -1
  54. package/chunks/{module-6F3E5H7Y-BN7QWGYB.js → module-6F3E5H7Y-FIMLNSCK.js} +1 -1
  55. package/chunks/{module-asyncify-R6PWJ6ZV-P4FWSBAY.js → module-asyncify-R6PWJ6ZV-Q2HJ3NOC.js} +1 -1
  56. package/chunks/{multipart-parser-L6M455MS.js → multipart-parser-JVSLI2CL.js} +1 -1
  57. package/chunks/{network-proxy-U72JCK2I.js → network-proxy-AJO7ZW3O.js} +1 -1
  58. package/chunks/openai-codex-responses-L2CIGCKO.js +2 -0
  59. package/chunks/openai-completions-C4PHW6MD.js +2 -0
  60. package/chunks/openai-responses-5NVFOW4Y.js +2 -0
  61. package/chunks/{openrouter-G2EHY5BD.js → openrouter-BKUGQT7Z.js} +1 -1
  62. package/chunks/{otel-OHXIZ666.js → otel-DRJM2PIX.js} +1 -1
  63. package/chunks/plugin-command-CIDTOPNB.js +2 -0
  64. package/chunks/provider-command-UZ7KQFAC.js +2 -0
  65. package/chunks/run-acp-command-AKDLHKMR.js +59 -0
  66. package/chunks/{run-exec-command-5ADSQR2Z.js → run-exec-command-UXTPS7LC.js} +1 -1
  67. package/chunks/{skills-command-XXXEZAG6.js → skills-command-57TF53NO.js} +1 -1
  68. package/chunks/src-5PSNGHHD.js +2 -0
  69. package/chunks/{src-IBHIRTD7.js → src-YZ26EVSY.js} +1 -1
  70. package/chunks/telemetry-3NXMCOVD.js +2 -0
  71. package/chunks/{telemetry-command-COQG2AKK.js → telemetry-command-CMDERYNN.js} +1 -1
  72. package/chunks/{tools-WDBB2JKV.js → tools-CRJR35HS.js} +1 -1
  73. package/chunks/{undici-TUGHZJSA.js → undici-O4OQVZ6I.js} +1 -1
  74. package/chunks/{update-NB6OD572.js → update-ACFAGV6F.js} +1 -1
  75. package/cli.js +2 -3
  76. package/embedded/alran-tools/cli.mjs +1 -5
  77. package/embedded/alran-tools/manifest.json +1 -1
  78. package/image-preview-worker.js +1 -1
  79. package/matrix-mcp-stdio.js +1 -1
  80. package/package.json +1 -1
  81. package/quickjs-worker.js +1 -1
  82. package/chunks/azure-openai-responses-OWHMUNKC.js +0 -2
  83. package/chunks/chunk-C3CMJAAV.js +0 -3
  84. package/chunks/chunk-ENHOPPS7.js +0 -16
  85. package/chunks/chunk-FSNYOJPJ.js +0 -2
  86. package/chunks/chunk-FXOH6TEQ.js +0 -21
  87. package/chunks/chunk-GRXX6I72.js +0 -2
  88. package/chunks/chunk-GSYHBK5Q.js +0 -6
  89. package/chunks/chunk-IWK7PZP7.js +0 -207
  90. package/chunks/chunk-KCLRJQ53.js +0 -59
  91. package/chunks/chunk-M7GW4VMR.js +0 -27
  92. package/chunks/chunk-QFUV5PX6.js +0 -2
  93. package/chunks/chunk-TW23QKAD.js +0 -3
  94. package/chunks/chunk-U7U3DJHF.js +0 -2
  95. package/chunks/chunk-WTAJMYF2.js +0 -249
  96. package/chunks/chunk-YLQXZBEL.js +0 -2
  97. package/chunks/chunk-Z6BHCXKT.js +0 -25
  98. package/chunks/chunk-Z6HBNJCA.js +0 -8
  99. package/chunks/launcher-FCZ3EDBF.js +0 -61
  100. package/chunks/lifecycle-GY435YMF.js +0 -2
  101. package/chunks/openai-codex-responses-FPCDNRL5.js +0 -2
  102. package/chunks/openai-completions-D32YW6KL.js +0 -2
  103. package/chunks/openai-responses-ZCGSENM4.js +0 -2
  104. package/chunks/plugin-command-OSAFHS7C.js +0 -2
  105. package/chunks/provider-command-SKTCHD4E.js +0 -2
  106. package/chunks/run-acp-command-SG2BDMFJ.js +0 -2
  107. package/chunks/src-DNIDEMVV.js +0 -2
  108. package/chunks/telemetry-J7ZLGF5X.js +0 -2
  109. /package/chunks/{chunk-EOR6EDNR.js → chunk-2AYWJZ72.js} +0 -0
  110. /package/chunks/{chunk-YPV2X2RG.js → chunk-4XP5XUIZ.js} +0 -0
  111. /package/chunks/{chunk-NWB7LFOK.js → chunk-5DQTVSQV.js} +0 -0
  112. /package/chunks/{chunk-OIQ336YE.js → chunk-EJN3SE5B.js} +0 -0
  113. /package/chunks/{chunk-A7GMJNA2.js → chunk-K5DTFR6D.js} +0 -0
  114. /package/chunks/{chunk-ZQOALVGL.js → chunk-R44C5DM6.js} +0 -0
  115. /package/chunks/{chunk-PNXZWSWT.js → chunk-UJCAE7SG.js} +0 -0
  116. /package/chunks/{chunk-J3KCPYZT.js → chunk-W5ZOLW7T.js} +0 -0
  117. /package/chunks/{chunk-XAGZ6ZEU.js → chunk-XLVABFJC.js} +0 -0
  118. /package/chunks/{chunk-N5SVBCUB.js → chunk-XSEU4WQD.js} +0 -0
  119. /package/chunks/{chunk-CSOUJVKM.js → chunk-Z5HOCNTZ.js} +0 -0
  120. /package/chunks/{emscripten-module-ZS3PMSDF.js → emscripten-module-3WGSFZYF.js} +0 -0
  121. /package/chunks/{emscripten-module-XPTEOIWW.js → emscripten-module-74WUXTHL.js} +0 -0
  122. /package/chunks/{emscripten-module-WYNDFH3N.js → emscripten-module-MCN4Y3N4.js} +0 -0
  123. /package/chunks/{emscripten-module-RD6P2XH5.js → emscripten-module-NEAT5LGD.js} +0 -0
  124. /package/chunks/{ffi-ORLOPBB3.js → ffi-JIGPPPF7.js} +0 -0
  125. /package/chunks/{ffi-IO7WZQNG.js → ffi-RLX77WFG.js} +0 -0
  126. /package/chunks/{pdfjs-SHZAF7PF.js → pdfjs-2UOWBGC2.js} +0 -0
  127. /package/chunks/{photon_rs-C52RL4CI.js → photon_rs-MVWYTYTO.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
- import{a as rt,b as nt}from"./chunk-IIE366LR.js";import"./chunk-GP52JZMY.js";import"./chunk-QPGTKSIQ.js";import"./chunk-BQ3CF3KE.js";import{a as Ve,b as Be,d as Ge,e as fe,f as Je,g as ze,h as W}from"./chunk-QIN5ZBE2.js";import{d as N,e as p,f as je,g as V,h as $e,i as Fe,n as Ne}from"./chunk-OIQ336YE.js";import"./chunk-7QLAXRD2.js";import{e as Ue,f as Le,g as me,h as C,i as qe}from"./chunk-LU4RPLJ3.js";import"./chunk-KCLRJQ53.js";import{c as Xe,d as ge,e as Ke,f as Ye,i as Qe,l as Ze}from"./chunk-MACBL5HF.js";import{c as We,q as pe}from"./chunk-2TF6JAQM.js";import{a as De}from"./chunk-AGUSPIUP.js";import"./chunk-TW23QKAD.js";import"./chunk-U3RMPDXU.js";import"./chunk-XAGZ6ZEU.js";import"./chunk-PNXZWSWT.js";import"./chunk-WTAJMYF2.js";import"./chunk-FSNYOJPJ.js";import{a as He}from"./chunk-D66ZSHXR.js";import{a as et,c as tt}from"./chunk-6P4UKHGR.js";import"./chunk-FC4M2B7E.js";import"./chunk-4CN3IJFH.js";import"./chunk-F46IELF5.js";import{a as Nt}from"./chunk-ENHOPPS7.js";import"./chunk-GSYHBK5Q.js";import"./chunk-M7GW4VMR.js";import"./chunk-WHD2XVT2.js";import"./chunk-WWNUAU4P.js";import"./chunk-N6W7ZL26.js";import"./chunk-U7U3DJHF.js";import"./chunk-QKBN5CGI.js";import"./chunk-J3KCPYZT.js";import"./chunk-3AODGLMF.js";import"./chunk-VLXX22YO.js";import"./chunk-7XYOYZX2.js";import"./chunk-NWB7LFOK.js";import"./chunk-EOR6EDNR.js";import"./chunk-ZQOALVGL.js";import{d as Ce}from"./chunk-4PDIO3M6.js";import"./chunk-IWK7PZP7.js";import"./chunk-EYK25HWR.js";import{kc as Oe,lc as _e}from"./chunk-FXOH6TEQ.js";import"./chunk-XFCC2CI2.js";import"./chunk-N5SVBCUB.js";import"./chunk-HNWBFJNO.js";import{e as Ft}from"./chunk-XQK7JM66.js";async function st(e,t){try{return _e(e,t)}catch(r){const n=r instanceof Oe?r.message:`Config is invalid: ${e}${r instanceof Error?` (${r.message})`:""}`;throw new p("config",n,{cause:r})}}var ot=`${Le} Lower the effort level, then retry.`;function B(e){if(e.kind==="invocation"||e.kind==="config"||e.kind==="cancelled"||e.kind==="brokenPipe"){return C(e)}if(e.kind==="runtime"){if(me(e.message))return ot;if(!e.retryable)return at(`The run failed: ${C(e)}`);return`The run failed: ${C(e)}. Retry after the connection recovers.`}return`Alran encountered an internal error: ${C(e)}. Retry; if it keeps happening, report it through an available support channel.`}function it(e){if(e.status==="timeout"){return"The run timed out. Increase --timeout or retry."}if(e.status==="limit_exceeded"){return"The run reached its step limit. Increase --max-steps or narrow the task."}if(e.status==="cancelled")return"The run was cancelled.";if(e.error?.category==="config"){const r=e.error.message?`: ${C(e.error.message)}`:"";return`The run could not start with the current configuration${r}. Open Alran and run /doctor.`}if(e.error?.category==="internal"){const r=e.error.message?`: ${C(e.error.message)}`:"";return`Alran encountered an internal error${r}. Retry; if it keeps happening, report it through an available support channel.`}if(me(e.error?.message))return ot;const t=e.error?.message?`: ${C(e.error.message)}`:"";if(e.error?.retryable===false)return at(`The run failed${t}`);return`The run failed${t}. Retry after the connection recovers.`}function at(e){return/[.!?…]$/u.test(e)?e:`${e}.`}import{readFile as nr,realpath as Te,stat as re}from"node:fs/promises";import{homedir as yt}from"node:os";import{basename as wt,dirname as sr,extname as or,isAbsolute as ir,resolve as te}from"node:path";var ye=Ft(Nt(),1);function he(e,t){if(!t)return{ok:true,value:e??null};if(!e?.trim()){return{ok:false,kind:"empty",message:"Structured output was empty."}}let r;try{r=JSON.parse(e)}catch{return{ok:false,kind:"invalid_json",message:"Structured output was not valid JSON."}}const n=new ye.Ajv({allErrors:true,strict:false});const s=n.compile(t);if(!s(r)){return{ok:false,kind:"schema_mismatch",message:`Structured output did not match --output-schema: ${n.errorsText(s.errors,{separator:"; "})}`}}return{ok:true,value:r}}function ut(e,t){const r=e.status==="succeeded"?t.validation??he(e.answer,t.outputSchema):void 0;const n=Ut(e,r);return{schemaVersion:1,type:"exec.result",runId:t.runId,sessionId:n.sessionId,turnId:n.turnId,status:n.status==="awaiting-user-continuation"?"failed":n.status,...n.status==="succeeded"&&r?.ok?{output:r.value}:{},...n.error?{error:{...n.error}}:{},...t.model?{model:{...t.model}}:{},...t.usage?{usage:{...t.usage}}:{},...t.usageSource!==void 0?{usageSource:t.usageSource}:{},...t.usageIncomplete!==void 0?{usageIncomplete:t.usageIncomplete}:{},durationMs:n.durationMs}}function ct(e){if(!Q(e))return false;return e.schemaVersion===1&&e.type==="exec.result"&&typeof e.runId==="string"&&typeof e.sessionId==="string"&&typeof e.turnId==="string"&&typeof e.durationMs==="number"&&Number.isFinite(e.durationMs)&&Lt(e.status)&&qt(e.model)&&Ht(e.usage)&&(e.usageSource===void 0||e.usageSource==="completed_responses"||e.usageSource==="analytics_fallback"||e.usageSource==="unavailable")&&(e.usageIncomplete===void 0||typeof e.usageIncomplete==="boolean")&&Vt(e.error)}function Ut(e,t){if(e.status==="awaiting-user-continuation"){return{...e,status:"failed",error:e.error??{category:"runtime",code:"INTERACTION_NOT_AVAILABLE",message:"The Runtime requested interaction from a non-interactive Exec host.",retryable:false}}}if(e.status!=="succeeded"||!t||t.ok)return e;return{...e,status:"failed",error:{category:"runtime",code:"STRUCTURED_OUTPUT_INVALID",message:t.message,retryable:true}}}function dt(e){new ye.Ajv({allErrors:true,strict:false}).compile(e)}function Lt(e){return e==="succeeded"||e==="failed"||e==="timeout"||e==="cancelled"||e==="limit_exceeded"}function qt(e){if(e===void 0)return true;if(!Q(e))return false;return typeof e.providerId==="string"&&typeof e.modelId==="string"&&G(e.variant)&&G(e.providerSource)&&G(e.providerKind)&&G(e.protocol)&&(e.structuredOutputMode===void 0||e.structuredOutputMode==="native_strict")}function Ht(e){if(e===void 0)return true;if(!Q(e))return false;return Object.values(e).every(t=>t===void 0||typeof t==="number"&&Number.isFinite(t))}function Vt(e){if(e===void 0)return true;if(!Q(e))return false;return(e.category==="config"||e.category==="runtime"||e.category==="internal")&&G(e.code)&&typeof e.message==="string"&&(e.retryable===void 0||typeof e.retryable==="boolean")}function G(e){return e===void 0||typeof e==="string"}function Q(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}import{createHash as Wt,randomUUID as Bt}from"node:crypto";import{access as Gt,constants as Jt,lstat as lt,mkdir as zt,open as Xt,readdir as mt,rename as Kt,unlink as Yt,writeFile as Qt}from"node:fs/promises";import{join as Z,resolve as Zt}from"node:path";var we=256*1024;var er=4*1024*1024;var tr=5e3;function ft(e){return qe(e.replace(/("(?:authorization|api[-_ ]?key|access[-_ ]?token|refresh[-_ ]?token|token|password|secret)"\s*:\s*)"(?:\\.|[^"\\])*"/giu,'$1"[redacted]"'))}function rr(e){if(e.length<=we)return e;const t=Buffer.from("\n[diagnostic answer truncated: middle omitted]\n");const r=Math.floor((we-t.length)/2);let n=r;let s=e.length-r;while(((e[n]??0)&192)===128)n-=1;while(((e[s]??0)&192)===128)s+=1;return Buffer.concat([e.subarray(0,n),t,e.subarray(s)])}async function pt(e,t){const r=Zt(t,e);await zt(r,{recursive:true,mode:448});if(!(await lt(r)).isDirectory())throw new Error("Diagnostics path must be a real directory.");await Gt(r,Jt.W_OK);if((await mt(r)).length>0)throw new Error("Diagnostics directory must be empty.");return r}function gt(e){return e?Wt("sha256").update(JSON.stringify(e)).digest("hex"):void 0}function J(e){if(typeof e==="string")return ft(e);if(Array.isArray(e))return e.map(J);if(e&&typeof e==="object"){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,/^(authorization|api[-_ ]?key|access[-_ ]?token|refresh[-_ ]?token|token|password|secret)$/iu.test(t)?"[redacted]":J(r)]))}return e}var ee=class e{constructor(t,r,n){this.directory=t;this.warn=r;this.progressFile=n}directory;warn;progressFile;pending=Promise.resolve();bytes=0;droppedEvents=0;closed=false;failed=false;static async create(t,r){if((await mt(t)).length>0){throw Object.assign(new Error("Diagnostics directory must be empty."),{code:"EEXIST"})}const n=await Xt(Z(t,"progress.jsonl"),"wx",384);return new e(t,r,n)}record(t){if(this.closed)return;const r=`${JSON.stringify(J({timestampMs:Date.now(),...t}))}
2
+ import{a as rt,b as nt}from"./chunk-G5MOGPZ3.js";import"./chunk-GP52JZMY.js";import"./chunk-QPGTKSIQ.js";import"./chunk-BQ3CF3KE.js";import{a as Ve,b as Be,d as Ge,e as fe,f as Je,g as ze,h as W}from"./chunk-6DOVXX7W.js";import{d as N,e as p,f as je,g as V,h as $e,i as Fe,n as Ne}from"./chunk-EJN3SE5B.js";import"./chunk-MPQ6G7LH.js";import{e as Ue,f as Le,g as me,h as C,i as qe}from"./chunk-LU4RPLJ3.js";import{c as Xe,d as ge,e as Ke,f as Ye,i as Qe,l as Ze}from"./chunk-MACBL5HF.js";import{c as We,q as pe}from"./chunk-2TF6JAQM.js";import{a as De}from"./chunk-AGUSPIUP.js";import"./chunk-PXH4SBCS.js";import"./chunk-U3RMPDXU.js";import"./chunk-XLVABFJC.js";import"./chunk-UJCAE7SG.js";import"./chunk-3GGKARES.js";import"./chunk-DFMYLGVU.js";import{a as He}from"./chunk-D66ZSHXR.js";import{a as et,c as tt}from"./chunk-6P4UKHGR.js";import"./chunk-IC6A323Q.js";import"./chunk-4CN3IJFH.js";import"./chunk-F46IELF5.js";import{a as Nt}from"./chunk-JSTSFMGK.js";import"./chunk-VGKKKM2W.js";import"./chunk-WHD2XVT2.js";import"./chunk-LCC45PCZ.js";import"./chunk-N6W7ZL26.js";import"./chunk-NVPGGFT3.js";import"./chunk-QKBN5CGI.js";import"./chunk-NMKRNU5O.js";import"./chunk-W5ZOLW7T.js";import"./chunk-3AODGLMF.js";import"./chunk-VLXX22YO.js";import"./chunk-7XYOYZX2.js";import"./chunk-5DQTVSQV.js";import"./chunk-2AYWJZ72.js";import"./chunk-R44C5DM6.js";import{d as Ce}from"./chunk-6UXSIWCB.js";import"./chunk-5RIMHTEU.js";import"./chunk-5Y76VFHY.js";import{ic as Oe,jc as _e}from"./chunk-XVGPB7TW.js";import"./chunk-VUISZDXX.js";import"./chunk-XSEU4WQD.js";import"./chunk-HNWBFJNO.js";import{e as Ft}from"./chunk-XQK7JM66.js";async function st(e,t){try{return _e(e,t)}catch(r){const n=r instanceof Oe?r.message:`Config is invalid: ${e}${r instanceof Error?` (${r.message})`:""}`;throw new p("config",n,{cause:r})}}var ot=`${Le} Lower the effort level, then retry.`;function B(e){if(e.kind==="invocation"||e.kind==="config"||e.kind==="cancelled"||e.kind==="brokenPipe"){return C(e)}if(e.kind==="runtime"){if(me(e.message))return ot;if(!e.retryable)return at(`The run failed: ${C(e)}`);return`The run failed: ${C(e)}. Retry after the connection recovers.`}return`Alran encountered an internal error: ${C(e)}. Retry; if it keeps happening, report it through an available support channel.`}function it(e){if(e.status==="timeout"){return"The run timed out. Increase --timeout or retry."}if(e.status==="limit_exceeded"){return"The run reached its step limit. Increase --max-steps or narrow the task."}if(e.status==="cancelled")return"The run was cancelled.";if(e.error?.category==="config"){const r=e.error.message?`: ${C(e.error.message)}`:"";return`The run could not start with the current configuration${r}. Open Alran and run /doctor.`}if(e.error?.category==="internal"){const r=e.error.message?`: ${C(e.error.message)}`:"";return`Alran encountered an internal error${r}. Retry; if it keeps happening, report it through an available support channel.`}if(me(e.error?.message))return ot;const t=e.error?.message?`: ${C(e.error.message)}`:"";if(e.error?.retryable===false)return at(`The run failed${t}`);return`The run failed${t}. Retry after the connection recovers.`}function at(e){return/[.!?…]$/u.test(e)?e:`${e}.`}import{readFile as nr,realpath as Te,stat as re}from"node:fs/promises";import{homedir as yt}from"node:os";import{basename as wt,dirname as sr,extname as or,isAbsolute as ir,resolve as te}from"node:path";var ye=Ft(Nt(),1);function he(e,t){if(!t)return{ok:true,value:e??null};if(!e?.trim()){return{ok:false,kind:"empty",message:"Structured output was empty."}}let r;try{r=JSON.parse(e)}catch{return{ok:false,kind:"invalid_json",message:"Structured output was not valid JSON."}}const n=new ye.Ajv({allErrors:true,strict:false});const s=n.compile(t);if(!s(r)){return{ok:false,kind:"schema_mismatch",message:`Structured output did not match --output-schema: ${n.errorsText(s.errors,{separator:"; "})}`}}return{ok:true,value:r}}function ut(e,t){const r=e.status==="succeeded"?t.validation??he(e.answer,t.outputSchema):void 0;const n=Ut(e,r);return{schemaVersion:1,type:"exec.result",runId:t.runId,sessionId:n.sessionId,turnId:n.turnId,status:n.status==="awaiting-user-continuation"?"failed":n.status,...n.status==="succeeded"&&r?.ok?{output:r.value}:{},...n.error?{error:{...n.error}}:{},...t.model?{model:{...t.model}}:{},...t.usage?{usage:{...t.usage}}:{},...t.usageSource!==void 0?{usageSource:t.usageSource}:{},...t.usageIncomplete!==void 0?{usageIncomplete:t.usageIncomplete}:{},durationMs:n.durationMs}}function ct(e){if(!Q(e))return false;return e.schemaVersion===1&&e.type==="exec.result"&&typeof e.runId==="string"&&typeof e.sessionId==="string"&&typeof e.turnId==="string"&&typeof e.durationMs==="number"&&Number.isFinite(e.durationMs)&&Lt(e.status)&&qt(e.model)&&Ht(e.usage)&&(e.usageSource===void 0||e.usageSource==="completed_responses"||e.usageSource==="analytics_fallback"||e.usageSource==="unavailable")&&(e.usageIncomplete===void 0||typeof e.usageIncomplete==="boolean")&&Vt(e.error)}function Ut(e,t){if(e.status==="awaiting-user-continuation"){return{...e,status:"failed",error:e.error??{category:"runtime",code:"INTERACTION_NOT_AVAILABLE",message:"The Runtime requested interaction from a non-interactive Exec host.",retryable:false}}}if(e.status!=="succeeded"||!t||t.ok)return e;return{...e,status:"failed",error:{category:"runtime",code:"STRUCTURED_OUTPUT_INVALID",message:t.message,retryable:true}}}function dt(e){new ye.Ajv({allErrors:true,strict:false}).compile(e)}function Lt(e){return e==="succeeded"||e==="failed"||e==="timeout"||e==="cancelled"||e==="limit_exceeded"}function qt(e){if(e===void 0)return true;if(!Q(e))return false;return typeof e.providerId==="string"&&typeof e.modelId==="string"&&G(e.variant)&&G(e.providerSource)&&G(e.providerKind)&&G(e.protocol)&&(e.structuredOutputMode===void 0||e.structuredOutputMode==="native_strict")}function Ht(e){if(e===void 0)return true;if(!Q(e))return false;return Object.values(e).every(t=>t===void 0||typeof t==="number"&&Number.isFinite(t))}function Vt(e){if(e===void 0)return true;if(!Q(e))return false;return(e.category==="config"||e.category==="runtime"||e.category==="internal")&&G(e.code)&&typeof e.message==="string"&&(e.retryable===void 0||typeof e.retryable==="boolean")}function G(e){return e===void 0||typeof e==="string"}function Q(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}import{createHash as Wt,randomUUID as Bt}from"node:crypto";import{access as Gt,constants as Jt,lstat as lt,mkdir as zt,open as Xt,readdir as mt,rename as Kt,unlink as Yt,writeFile as Qt}from"node:fs/promises";import{join as Z,resolve as Zt}from"node:path";var we=256*1024;var er=4*1024*1024;var tr=5e3;function ft(e){return qe(e.replace(/("(?:authorization|api[-_ ]?key|access[-_ ]?token|refresh[-_ ]?token|token|password|secret)"\s*:\s*)"(?:\\.|[^"\\])*"/giu,'$1"[redacted]"'))}function rr(e){if(e.length<=we)return e;const t=Buffer.from("\n[diagnostic answer truncated: middle omitted]\n");const r=Math.floor((we-t.length)/2);let n=r;let s=e.length-r;while(((e[n]??0)&192)===128)n-=1;while(((e[s]??0)&192)===128)s+=1;return Buffer.concat([e.subarray(0,n),t,e.subarray(s)])}async function pt(e,t){const r=Zt(t,e);await zt(r,{recursive:true,mode:448});if(!(await lt(r)).isDirectory())throw new Error("Diagnostics path must be a real directory.");await Gt(r,Jt.W_OK);if((await mt(r)).length>0)throw new Error("Diagnostics directory must be empty.");return r}function gt(e){return e?Wt("sha256").update(JSON.stringify(e)).digest("hex"):void 0}function J(e){if(typeof e==="string")return ft(e);if(Array.isArray(e))return e.map(J);if(e&&typeof e==="object"){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,/^(authorization|api[-_ ]?key|access[-_ ]?token|refresh[-_ ]?token|token|password|secret)$/iu.test(t)?"[redacted]":J(r)]))}return e}var ee=class e{constructor(t,r,n){this.directory=t;this.warn=r;this.progressFile=n}directory;warn;progressFile;pending=Promise.resolve();bytes=0;droppedEvents=0;closed=false;failed=false;static async create(t,r){if((await mt(t)).length>0){throw Object.assign(new Error("Diagnostics directory must be empty."),{code:"EEXIST"})}const n=await Xt(Z(t,"progress.jsonl"),"wx",384);return new e(t,r,n)}record(t){if(this.closed)return;const r=`${JSON.stringify(J({timestampMs:Date.now(),...t}))}
3
3
  `;const n=Buffer.byteLength(r);if(this.bytes+n>er){this.droppedEvents+=1;return}this.bytes+=n;this.enqueue(()=>this.progressFile.appendFile(r))}execution(t){this.json("execution.json",{schemaVersion:1,...t})}failure(t,r){const n=Buffer.from(ft(t??""));const s=n.length>we;const i=rr(n);this.json("failure.json",{schemaVersion:1,...r,answerBytes:Buffer.byteLength(t??""),savedBytes:i.length,truncated:s,redacted:true});this.enqueue(()=>this.replaceFile("failure-answer.txt",i))}async flush(t={}){this.enqueue(async()=>{const[s,i]=await Promise.all([lt(Z(this.directory,"progress.jsonl")),this.progressFile.stat()]);if(!s.isFile()||s.ino!==i.ino||s.dev!==i.dev){throw new Error("Diagnostics progress file was replaced.")}});this.enqueue(()=>this.progressFile.close());this.enqueue(()=>this.replaceFile("diagnostics-status.json",`${JSON.stringify(J({...t,recoveryReady:t.recoveryReady===true&&!this.failed,diagnosticsComplete:!this.failed,droppedEventCount:this.droppedEvents}),null,2)}
4
4
  `));let r;const n=await Promise.race([this.pending.then(()=>true),new Promise(s=>{r=setTimeout(()=>s(false),tr)})]);if(r)clearTimeout(r);this.closed=true;if(!n)this.reportFailure("diagnostics flush deadline exceeded");void this.pending.finally(()=>this.progressFile.close()).catch(()=>void 0);return n&&!this.failed}json(t,r){const n=`${JSON.stringify(J(r),null,2)}
5
5
  `;this.enqueue(()=>this.replaceFile(t,n))}async replaceFile(t,r){const n=Z(this.directory,`.${t}.${Bt()}.tmp`);try{await Qt(n,r,{mode:384,flag:"wx"});if(!this.closed)await Kt(n,Z(this.directory,t))}finally{await Yt(n).catch(()=>void 0)}}enqueue(t){if(this.closed)return;this.pending=this.pending.then(async()=>{if(!this.closed)await t()}).catch(()=>this.reportFailure("could not write execution diagnostics"))}reportFailure(t){if(!this.failed)this.warn(`alran diagnostics warning: ${t}
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
- import{a,b as n,c as i,d as o,e as m,f as c,j as u}from"./chunk-E3GLGDGC.js";import{d as s}from"./chunk-WYANV3IX.js";import{d as l}from"./chunk-4PDIO3M6.js";import"./chunk-IWK7PZP7.js";import"./chunk-EYK25HWR.js";import"./chunk-FXOH6TEQ.js";import"./chunk-XFCC2CI2.js";import"./chunk-N5SVBCUB.js";import"./chunk-HNWBFJNO.js";import"./chunk-XQK7JM66.js";async function S(r){const t=r.host??u(new s({dataDir:r.dataDir??await l()}));const e=r.request;switch(e.action){case"list":return a(t,"skill",{installed:e.installed,json:e.json});case"search":return n(t,"skill",e);case"info":return i(t,"skill",e.selector,e.json);case"add":return o(t,"skill",e.selector,e);case"update":return m(t,"skill",e);case"remove":return c(t,"skill",e.selector,e.json)}}export{S as runAlranSkillCommand};
2
+ import{a,b as n,c as i,d as o,e as m,f as c,j as u}from"./chunk-6PFI65C6.js";import{d as s}from"./chunk-RLND4AYL.js";import{d as l}from"./chunk-6UXSIWCB.js";import"./chunk-5RIMHTEU.js";import"./chunk-5Y76VFHY.js";import"./chunk-XVGPB7TW.js";import"./chunk-VUISZDXX.js";import"./chunk-XSEU4WQD.js";import"./chunk-HNWBFJNO.js";import"./chunk-XQK7JM66.js";async function S(r){const t=r.host??u(new s({dataDir:r.dataDir??await l()}));const e=r.request;switch(e.action){case"list":return a(t,"skill",{installed:e.installed,json:e.json});case"search":return n(t,"skill",e);case"info":return i(t,"skill",e.selector,e.json);case"add":return o(t,"skill",e.selector,e);case"update":return m(t,"skill",e);case"remove":return c(t,"skill",e.selector,e.json)}}export{S as runAlranSkillCommand};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
+ import{$ as Y,$a as Wa,$b as dc,A as y,Aa as xa,Ab as vb,B as z,Ba as ya,Bb as wb,C as A,Ca as za,Cb as xb,D as B,Da as Aa,Db as yb,E as C,Ea as Ba,Eb as zb,F as D,Fa as Ca,Fb as Ab,G as E,Ga as Da,Gb as Bb,H as F,Ha as Ea,Hb as Cb,I as G,Ia as Fa,Ib as Db,J as H,Ja as Ga,Jb as Eb,K as I,Ka as Ha,Kb as Fb,L as J,La as Ia,Lb as Gb,M as K,Mb as Hb,N as L,Nb as Ib,O as M,Oa as Ja,Ob as Jb,P as N,Pa as Ka,Pb as Kb,Q as O,Qa as La,Qb as Lb,R as P,Ra as Ma,Rb as Mb,S as Q,Sa as Na,Sb as Nb,T as R,Ta as Oa,Tb as Ob,U as S,Ua as Pa,Ub as Pb,V as T,Va as Qa,Vb as Zb,W as U,Wa as Ra,Wb as _b,Xa as Sa,Xb as $b,Y as V,Ya as Ta,Yb as ac,Z as W,Za as Ua,Zb as bc,_ as X,_a as Va,_b as cc,aa as Z,ab as Xa,ac as ec,b as a,ba as _,bb as Ya,bc as fc,c as b,ca as $,cb as Za,cc as gc,d as c,da as aa,db as _a,dc as hc,e as d,ea as ba,eb as $a,ec as ic,f as e,fa as ca,fb as ab,fc as jc,ga as da,gb as bb,gc as kc,h as f,ha as ea,hb as cb,hc as lc,i as g,ia as fa,ib as db,ic as mc,j as h,ja as ga,jb as eb,jc as nc,k as i,ka as ha,kb as fb,kc as oc,l as j,la as ia,lb as gb,m as k,ma as ja,mb as hb,n as l,na as ka,nb as ib,o as m,oa as la,ob as jb,p as n,pa as ma,pb as kb,q as o,qa as na,qb as lb,r as p,ra as oa,rb as mb,s as q,sa as pa,sb as nb,t as r,ta as qa,tb as ob,u as s,ua as ra,ub as pb,v as t,va as sa,vb as qb,w as u,wa as ta,wb as rb,x as v,xa as ua,xb as sb,y as w,ya as va,yb as tb,z as x,za as wa,zb as ub}from"./chunk-XVGPB7TW.js";import"./chunk-VUISZDXX.js";import"./chunk-XSEU4WQD.js";import{a as Qb,b as Rb,c as Sb,d as Tb,e as Ub,f as Vb,g as Wb,h as Xb,i as Yb}from"./chunk-HNWBFJNO.js";import"./chunk-XQK7JM66.js";export{t as AGENT_BUILTIN_MCP_TOOL_IDS,u as AGENT_BUILTIN_SKILL_IDS,s as AGENT_BUILTIN_TOOL_IDS,v as AGENT_CAPABILITY_OWNED_SKILL_IDS,l as AGENT_RUNTIME_FRAMEWORKS,Eb as ALRAN_API_PROVIDER_ID,a as ALRAN_MODELS,tb as ALRAN_MODEL_TO_GATEWAY_ID,Ub as ASR_PROXY_AUTH_ENV_KEYS,Z as ATTRIBUTION_DEFAULTS,$ as ATTRIBUTION_EMAIL,_ as ATTRIBUTION_NAME,aa as ATTRIBUTION_URL,pa as BRAND,T as BROWSER_CONFIG_DEFAULTS,ca as COMMIT_TRAILER_ENV,Pa as CONVERSATION_STOP_CONFIG_DEFAULTS,Gb as CUSTOM_PROVIDER_ID_PREFIX,mc as ConfigFileError,p as DATA_DIR_BASENAME,m as DEFAULT_AGENT_RUNTIME_FRAMEWORK,g as DEFAULT_CU_BACKEND,za as DEFAULT_MODEL_PRESETS,xb as DEFAULT_OTTILI_MODEL_TIER,ra as DEFAULT_PORT,i as DEFAULT_SKILLS_CONFIG,Fb as EXTERNAL_ALRAN_PROVIDER_ID,k as EXTERNAL_SOURCE_KIND_LIST,H as GOAL_CONFIG_DEFAULTS,I as GOAL_CONFIG_LIMITS,E as GOAL_EVALUATOR_MODEL_POLICIES,G as GOAL_SUBAGENT_PROFILES,D as GOAL_VERIFICATION_EVIDENCE_MODES,C as GOAL_VERIFICATION_MODES,F as GOAL_VERIFIER_READONLY_PROFILE,Rb as LEGACY_RUNTIME_ENV_KEYS,ac as LOCAL_RUNTIME_AUTH_CONTEXT_FILE,Db as MANAGED_ALRAN_PROVIDER_ID,Qb as MANAGED_RUNTIME_KEYS,sa as OPENCODE_PORT_OFFSET,Ta as OTTILI_AI_PLATFORM_BASE_URL,Wa as OTTILI_API_BASE_ENV,Ya as OTTILI_API_KEY_CONSOLE_ENV,Va as OTTILI_API_KEY_ENV,Ua as OTTILI_API_KEY_PREFIX,rb as OTTILI_MODEL_IDS,ub as OTTILI_MODEL_SHORT_NAMES,sb as OTTILI_PARTNER_MODEL_IDS,Sa as OTTILI_PLATFORM_URL,Xa as OTTILI_PLATFORM_URL_ENV,Tb as PARENT_HINT_KEYS,d as PRIVATE_CONFIG_FILE_MODE,ba as PULL_REQUEST_ATTRIBUTION,R as REQUEST_MEDIA_DEFAULTS,L as RETRY_CONFIG_DEFAULTS,M as RETRY_CONFIG_LIMITS,K as RETRY_REASONS,qa as RUNTIME_ENV_PREFIX,Sb as RUNTIME_IDENTITY_KEYS,W as SANDBOX_CONFIG_DEFAULTS,hc as TEST_PORT_ROLE_FLOOR,gc as TEST_PORT_ROLE_OFFSET,P as TOOL_RESULT_COMPACTION_DEFAULTS,ya as allowsManagedAlranProviderOverride,f as alranApiModels,lc as assertCuBackendSupported,ea as attributionModelLabel,ha as buildAttributionReminder,Vb as buildChildEnv,fc as clearLocalRuntimeAuthContextFile,kb as clearStoredPlatformSession,fa as commitTrailer,ga as commitTrailerFor,Pb as compareAndSetLocalModelContext,Ea as currentBetaResolutionContext,ua as detectGitPortInfo,$b as detectPidOwner,Yb as findLegacyRuntimeEnvKeys,_b as formatPidFile,Da as getConfig,xa as getConfigPath,jc as getCuBackend,wa as getDataDir,q as getDataDirPath,Ha as getOpenCodePort,va as getProfile,ja as getRuntimeBuildEnv,la as getRuntimePresetKey,ia as getRuntimeRegion,V as getSandboxConfigDefaults,A as isAgentBuiltinMcpToolEnabled,B as isAgentBuiltinSkillEnabled,z as isAgentBuiltinToolEnabled,na as isBetaFeatureProdReady,wb as isByokOttiliModel,Hb as isFirstPartyAlranRoute,oa as isInternalBuild,Ab as isLegacyManagedAlranProvider,Ja as isLocalSourceProvenanceEnabled,Bb as isManagedProviderBaseUrl,ka as isManagedRuntime,cb as isOttiliApiKey,yb as isOttiliModelId,Y as isProposalEligibleAgent,Ka as isPtcTurnEnabled,Ia as isTelemetryChannelEnabled,Jb as listRouteModelIds,nc as loadConfigFromFile,bc as normalizeLocalRuntimeAuthContext,Za as normalizeOttiliApiBaseUrl,ob as ottiliAccountPreferencesPath,x as parseAgentCapabilityConfig,o as parseAgentRuntimeConfig,n as parseAgentRuntimeFramework,w as parseAgentsConfig,da as parseAttributionConfig,U as parseBrowserConfig,Qa as parseConversationStopConfig,h as parseCuBackend,J as parseGoalConfig,Zb as parsePidFile,Ma as parsePromptSuggestionRemotePolicy,S as parseRequestMediaConfig,N as parseRetryConfig,b as parseRunawayGuardOverride,X as parseSandboxConfig,j as parseSkillsConfig,Q as parseToolResultCompactionConfig,ic as pickTestPort,lb as platformEnvironmentOrder,hb as platformSessionDir,ib as platformSessionPath,Ra as readConversationStopConfig,oc as readExplicitBetaFeatureFromFile,dc as readLocalRuntimeAuthContext,pb as readOttiliAccountPreferences,jb as readStoredPlatformSession,Lb as removeLocalProviderConfig,Mb as replaceLocalManagedAlranProvider,Ca as resetConfig,ta as resetGitDetect,y as resolveAgentCapabilities,ma as resolveBetaFeature,r as resolveDataDir,cc as resolveLocalRuntimeAuthContextPath,Kb as resolveModelAvailability,Ib as resolveModelCallRoute,$a as resolveOttiliApiBaseUrl,bb as resolveOttiliApiKey,eb as resolveOttiliApiKeyConsoleUrl,db as resolveOttiliApiKeyConsoleUrlFor,vb as resolveOttiliCatalogModelId,fb as resolveOttiliEnvironment,ab as resolveOttiliGatewayBaseUrl,zb as resolveOttiliModelId,_a as resolveOttiliPlatformUrl,gb as resolvePlatformEnvironmentForBuild,Ga as resolvePort,Fa as resolvePromptConfig,Na as resolvePromptSuggestionEnabled,Cb as resolveProviderAuthMode,c as resolveRunawayGuardConfig,mb as resolveStoredPlatformSession,O as retryPolicyFromConfig,kc as setCuBackend,Aa as setLegacyByokProviderMigrationEnabled,Ba as setManagedPresetBaseUrlSyncEnabled,Wb as stripManagedRuntimeEnv,Xb as stripRuntimeBoundaryKeysFrom,Nb as updateLocalByokConfig,Ob as updateLocalModelSelection,Oa as withEffectivePromptSuggestion,ec as writeLocalRuntimeAuthContext,qb as writeOttiliProjectPreference,e as writePrivateConfigFileSync,nb as writeStoredPlatformSession,La as writeTuiStatusLineSetting};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
- import{a as j,b as Ie,c as ze,d as I,e as ae,f as fe,g as Ne,h as De,i as Me,j as We,k as Ve}from"./chunk-A7GMJNA2.js";import{b as y}from"./chunk-XQK7JM66.js";function Ge(r){if(!/^data:/i.test(r)){throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")')}r=r.replace(/\r?\n/g,"");const e=r.indexOf(",");if(e===-1||e<=4){throw new TypeError("malformed data: URI")}const t=r.substring(5,e).split(";");let n="";let o=false;const s=t[0]||"text/plain";let i=s;for(let R=1;R<t.length;R++){if(t[R]==="base64"){o=true}else if(t[R]){i+=`;${t[R]}`;if(t[R].indexOf("charset=")===0){n=t[R].substring(8)}}}if(!t[0]&&!n.length){i+=";charset=US-ASCII";n="US-ASCII"}const c=o?"base64":"ascii";const l=unescape(r.substring(e+1));const a=Buffer.from(l,c);a.type=s;a.typeFull=i;a.charset=n;return a}var ce;var le=y(()=>{ce=Ge});var U;var M=y(()=>{U=class extends Error{constructor(e,t){super(e);Error.captureStackTrace(this,this.constructor);this.type=t}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}}});var p;var q=y(()=>{M();p=class extends U{constructor(e,t,n){super(e,t);if(n){this.code=this.errno=n.code;this.erroredSysCall=n.syscall}}}});var W,ee,z,ue,he,de;var V=y(()=>{W=Symbol.toStringTag;ee=r=>{return typeof r==="object"&&typeof r.append==="function"&&typeof r.delete==="function"&&typeof r.get==="function"&&typeof r.getAll==="function"&&typeof r.has==="function"&&typeof r.set==="function"&&typeof r.sort==="function"&&r[W]==="URLSearchParams"};z=r=>{return r&&typeof r==="object"&&typeof r.arrayBuffer==="function"&&typeof r.type==="string"&&typeof r.stream==="function"&&typeof r.constructor==="function"&&/^(Blob|File)$/.test(r[W])};ue=r=>{return typeof r==="object"&&(r[W]==="AbortSignal"||r[W]==="EventTarget")};he=(r,e)=>{const t=new URL(e).hostname;const n=new URL(r).hostname;return t===n||t.endsWith(`.${n}`)};de=(r,e)=>{const t=new URL(e).protocol;const n=new URL(r).protocol;return t===n}});import v,{PassThrough as pe}from"node:stream";import{types as me,deprecate as te,promisify as Ke}from"node:util";import{Buffer as b}from"node:buffer";async function re(r){if(r[m].disturbed){throw new TypeError(`body used already for: ${r.url}`)}r[m].disturbed=true;if(r[m].error){throw r[m].error}const{body:e}=r;if(e===null){return b.alloc(0)}if(!(e instanceof v)){return b.alloc(0)}const t=[];let n=0;try{for await(const o of e){if(r.size>0&&n+o.length>r.size){const s=new p(`content size at ${r.url} over limit: ${r.size}`,"max-size");e.destroy(s);throw s}n+=o.length;t.push(o)}}catch(o){const s=o instanceof U?o:new p(`Invalid response body while trying to fetch ${r.url}: ${o.message}`,"system",o);throw s}if(e.readableEnded===true||e._readableState.ended===true){try{if(t.every(o=>typeof o==="string")){return b.from(t.join(""))}return b.concat(t,n)}catch(o){throw new p(`Could not create Buffer from response body for ${r.url}: ${o.message}`,"system",o)}}else{throw new p(`Premature close of server response while trying to fetch ${r.url}`)}}var Ye,m,E,F,Je,G,ye,ge;var K=y(()=>{Ie();fe();q();M();V();Ye=Ke(v.pipeline);m=Symbol("Body internals");E=class{constructor(e,{size:t=0}={}){let n=null;if(e===null){e=null}else if(ee(e)){e=b.from(e.toString())}else if(z(e)){}else if(b.isBuffer(e)){}else if(me.isAnyArrayBuffer(e)){e=b.from(e)}else if(ArrayBuffer.isView(e)){e=b.from(e.buffer,e.byteOffset,e.byteLength)}else if(e instanceof v){}else if(e instanceof I){e=ae(e);n=e.type.split("=")[1]}else{e=b.from(String(e))}let o=e;if(b.isBuffer(e)){o=v.Readable.from(e)}else if(z(e)){o=v.Readable.from(e.stream())}this[m]={body:e,stream:o,boundary:n,disturbed:false,error:null};this.size=t;if(e instanceof v){e.on("error",s=>{const i=s instanceof U?s:new p(`Invalid response body while trying to fetch ${this.url}: ${s.message}`,"system",s);this[m].error=i})}}get body(){return this[m].stream}get bodyUsed(){return this[m].disturbed}async arrayBuffer(){const{buffer:e,byteOffset:t,byteLength:n}=await re(this);return e.slice(t,t+n)}async formData(){const e=this.headers.get("content-type");if(e.startsWith("application/x-www-form-urlencoded")){const n=new I;const o=new URLSearchParams(await this.text());for(const[s,i]of o){n.append(s,i)}return n}const{toFormData:t}=await import("./multipart-parser-L6M455MS.js");return t(this.body,e)}async blob(){const e=this.headers&&this.headers.get("content-type")||this[m].body&&this[m].body.type||"";const t=await this.arrayBuffer();return new j([t],{type:e})}async json(){const e=await this.text();return JSON.parse(e)}async text(){const e=await re(this);return new TextDecoder().decode(e)}buffer(){return re(this)}};E.prototype.buffer=te(E.prototype.buffer,"Please use 'response.arrayBuffer()' instead of 'response.buffer()'","node-fetch#buffer");Object.defineProperties(E.prototype,{body:{enumerable:true},bodyUsed:{enumerable:true},arrayBuffer:{enumerable:true},blob:{enumerable:true},json:{enumerable:true},text:{enumerable:true},data:{get:te(()=>{},"data doesn't exist, use json(), text(), arrayBuffer(), or body instead","https://github.com/node-fetch/node-fetch/issues/1000 (response)")}});F=(r,e)=>{let t;let n;let{body:o}=r[m];if(r.bodyUsed){throw new Error("cannot clone body after it is used")}if(o instanceof v&&typeof o.getBoundary!=="function"){t=new pe({highWaterMark:e});n=new pe({highWaterMark:e});o.pipe(t);o.pipe(n);r[m].stream=t;o=n}return o};Je=te(r=>r.getBoundary(),"form-data doesn't follow the spec and requires special treatment. Use alternative package","https://github.com/node-fetch/node-fetch/issues/1167");G=(r,e)=>{if(r===null){return null}if(typeof r==="string"){return"text/plain;charset=UTF-8"}if(ee(r)){return"application/x-www-form-urlencoded;charset=UTF-8"}if(z(r)){return r.type||null}if(b.isBuffer(r)||me.isAnyArrayBuffer(r)||ArrayBuffer.isView(r)){return null}if(r instanceof I){return`multipart/form-data; boundary=${e[m].boundary}`}if(r&&typeof r.getBoundary==="function"){return`multipart/form-data;boundary=${Je(r)}`}if(r instanceof v){return null}return"text/plain;charset=UTF-8"};ye=r=>{const{body:e}=r[m];if(e===null){return 0}if(z(e)){return e.size}if(b.isBuffer(e)){return e.length}if(e&&typeof e.getLengthSync==="function"){return e.hasKnownLength&&e.hasKnownLength()?e.getLengthSync():null}return null};ge=async(r,{body:e})=>{if(e===null){r.end()}else{await Ye(e,r)}}});import{types as we}from"node:util";import J from"node:http";function be(r=[]){return new g(r.reduce((e,t,n,o)=>{if(n%2===0){e.push(o.slice(n,n+2))}return e},[]).filter(([e,t])=>{try{Y(e);oe(e,String(t));return true}catch{return false}}))}var Y,oe,g;var Z=y(()=>{Y=typeof J.validateHeaderName==="function"?J.validateHeaderName:r=>{if(!/^[\^`\-\w!#$%&'*+.|~]+$/.test(r)){const e=new TypeError(`Header name must be a valid HTTP token [${r}]`);Object.defineProperty(e,"code",{value:"ERR_INVALID_HTTP_TOKEN"});throw e}};oe=typeof J.validateHeaderValue==="function"?J.validateHeaderValue:(r,e)=>{if(/[^\t\u0020-\u007E\u0080-\u00FF]/.test(e)){const t=new TypeError(`Invalid character in header content ["${r}"]`);Object.defineProperty(t,"code",{value:"ERR_INVALID_CHAR"});throw t}};g=class r extends URLSearchParams{constructor(e){let t=[];if(e instanceof r){const n=e.raw();for(const[o,s]of Object.entries(n)){t.push(...s.map(i=>[o,i]))}}else if(e==null){}else if(typeof e==="object"&&!we.isBoxedPrimitive(e)){const n=e[Symbol.iterator];if(n==null){t.push(...Object.entries(e))}else{if(typeof n!=="function"){throw new TypeError("Header pairs must be iterable")}t=[...e].map(o=>{if(typeof o!=="object"||we.isBoxedPrimitive(o)){throw new TypeError("Each header pair must be an iterable object")}return[...o]}).map(o=>{if(o.length!==2){throw new TypeError("Each header pair must be a name/value tuple")}return[...o]})}}else{throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)")}t=t.length>0?t.map(([n,o])=>{Y(n);oe(n,String(o));return[String(n).toLowerCase(),String(o)]}):void 0;super(t);return new Proxy(this,{get(n,o,s){switch(o){case"append":case"set":return(i,c)=>{Y(i);oe(i,String(c));return URLSearchParams.prototype[o].call(n,String(i).toLowerCase(),String(c))};case"delete":case"has":case"getAll":return i=>{Y(i);return URLSearchParams.prototype[o].call(n,String(i).toLowerCase())};case"keys":return()=>{n.sort();return new Set(URLSearchParams.prototype.keys.call(n)).keys()};default:return Reflect.get(n,o,s)}}})}get[Symbol.toStringTag](){return this.constructor.name}toString(){return Object.prototype.toString.call(this)}get(e){const t=this.getAll(e);if(t.length===0){return null}let n=t.join(", ");if(/^content-encoding$/i.test(e)){n=n.toLowerCase()}return n}forEach(e,t=void 0){for(const n of this.keys()){Reflect.apply(e,t,[this.get(n),n,this])}}*values(){for(const e of this.keys()){yield this.get(e)}}*entries(){for(const e of this.keys()){yield[e,this.get(e)]}}[Symbol.iterator](){return this.entries()}raw(){return[...this.keys()].reduce((e,t)=>{e[t]=this.getAll(t);return e},{})}[Symbol.for("nodejs.util.inspect.custom")](){return[...this.keys()].reduce((e,t)=>{const n=this.getAll(t);if(t==="host"){e[t]=n[0]}else{e[t]=n.length>1?n:n[0]}return e},{})}};Object.defineProperties(g.prototype,["get","entries","forEach","values"].reduce((r,e)=>{r[e]={enumerable:true};return r},{}))});var Ze,_;var ne=y(()=>{Ze=new Set([301,302,303,307,308]);_=r=>{return Ze.has(r)}});var T,S;var Se=y(()=>{Z();K();ne();T=Symbol("Response internals");S=class r extends E{constructor(e=null,t={}){super(e,t);const n=t.status!=null?t.status:200;const o=new g(t.headers);if(e!==null&&!o.has("Content-Type")){const s=G(e,this);if(s){o.append("Content-Type",s)}}this[T]={type:"default",url:t.url,status:n,statusText:t.statusText||"",headers:o,counter:t.counter,highWaterMark:t.highWaterMark}}get type(){return this[T].type}get url(){return this[T].url||""}get status(){return this[T].status}get ok(){return this[T].status>=200&&this[T].status<300}get redirected(){return this[T].counter>0}get statusText(){return this[T].statusText}get headers(){return this[T].headers}get highWaterMark(){return this[T].highWaterMark}clone(){return new r(F(this,this.highWaterMark),{type:this.type,url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected,size:this.size,highWaterMark:this.highWaterMark})}static redirect(e,t=302){if(!_(t)){throw new RangeError('Failed to execute "redirect" on "response": Invalid status code')}return new r(null,{headers:{location:new URL(e).toString()},status:t})}static error(){const e=new r(null,{status:0,statusText:""});e[T].type="error";return e}static json(e=void 0,t={}){const n=JSON.stringify(e);if(n===void 0){throw new TypeError("data is not JSON serializable")}const o=new g(t&&t.headers);if(!o.has("content-type")){o.set("content-type","application/json")}return new r(n,{...t,headers:o})}get[Symbol.toStringTag](){return"Response"}};Object.defineProperties(S.prototype,{type:{enumerable:true},url:{enumerable:true},status:{enumerable:true},ok:{enumerable:true},redirected:{enumerable:true},statusText:{enumerable:true},headers:{enumerable:true},clone:{enumerable:true}})});var Te;var Re=y(()=>{Te=r=>{if(r.search){return r.search}const e=r.href.length-1;const t=r.hash||(r.href[e]==="#"?"#":"");return r.href[e-t.length]==="?"?"?":""}});import{isIP as _e}from"node:net";function xe(r,e=false){if(r==null){return"no-referrer"}r=new URL(r);if(/^(about|blob|data):$/.test(r.protocol)){return"no-referrer"}r.username="";r.password="";r.hash="";if(e){r.pathname="";r.search=""}return r}function Le(r){if(!Ee.has(r)){throw new TypeError(`Invalid referrerPolicy: ${r}`)}return r}function Qe(r){if(/^(http|ws)s:$/.test(r.protocol)){return true}const e=r.host.replace(/(^\[)|(]$)/g,"");const t=_e(e);if(t===4&&/^127\./.test(e)){return true}if(t===6&&/^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(e)){return true}if(r.host==="localhost"||r.host.endsWith(".localhost")){return false}if(r.protocol==="file:"){return true}return false}function k(r){if(/^about:(blank|srcdoc)$/.test(r)){return true}if(r.protocol==="data:"){return true}if(/^(blob|filesystem):$/.test(r.protocol)){return true}return Qe(r)}function Ue(r,{referrerURLCallback:e,referrerOriginCallback:t}={}){if(r.referrer==="no-referrer"||r.referrerPolicy===""){return null}const n=r.referrerPolicy;if(r.referrer==="about:client"){return"no-referrer"}const o=r.referrer;let s=xe(o);let i=xe(o,true);if(s.toString().length>4096){s=i}if(e){s=e(s)}if(t){i=t(i)}const c=new URL(r.url);switch(n){case"no-referrer":return"no-referrer";case"origin":return i;case"unsafe-url":return s;case"strict-origin":if(k(s)&&!k(c)){return"no-referrer"}return i.toString();case"strict-origin-when-cross-origin":if(s.origin===c.origin){return s}if(k(s)&&!k(c)){return"no-referrer"}return i;case"same-origin":if(s.origin===c.origin){return s}return"no-referrer";case"origin-when-cross-origin":if(s.origin===c.origin){return s}return i;case"no-referrer-when-downgrade":if(k(s)&&!k(c)){return"no-referrer"}return s;default:throw new TypeError(`Invalid referrerPolicy: ${n}`)}}function ve(r){const e=(r.get("referrer-policy")||"").split(/[,\s]+/);let t="";for(const n of e){if(n&&Ee.has(n)){t=n}}return t}var Ee,Pe;var se=y(()=>{Ee=new Set(["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"]);Pe="strict-origin-when-cross-origin"});import{format as Xe}from"node:url";import{deprecate as je}from"node:util";var u,N,qe,C,Be;var Ae=y(()=>{Z();K();V();Re();se();u=Symbol("Request internals");N=r=>{return typeof r==="object"&&typeof r[u]==="object"};qe=je(()=>{},".data is not a valid RequestInit property, use .body instead","https://github.com/node-fetch/node-fetch/issues/1000 (request)");C=class r extends E{constructor(e,t={}){let n;if(N(e)){n=new URL(e.url)}else{n=new URL(e);e={}}if(n.username!==""||n.password!==""){throw new TypeError(`${n} is an url with embedded credentials.`)}let o=t.method||e.method||"GET";if(/^(delete|get|head|options|post|put)$/i.test(o)){o=o.toUpperCase()}if(!N(t)&&"data"in t){qe()}if((t.body!=null||N(e)&&e.body!==null)&&(o==="GET"||o==="HEAD")){throw new TypeError("Request with GET/HEAD method cannot have body")}const s=t.body?t.body:N(e)&&e.body!==null?F(e):null;super(s,{size:t.size||e.size||0});const i=new g(t.headers||e.headers||{});if(s!==null&&!i.has("Content-Type")){const a=G(s,this);if(a){i.set("Content-Type",a)}}let c=N(e)?e.signal:null;if("signal"in t){c=t.signal}if(c!=null&&!ue(c)){throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget")}let l=t.referrer==null?e.referrer:t.referrer;if(l===""){l="no-referrer"}else if(l){const a=new URL(l);l=/^about:(\/\/)?client$/.test(a)?"client":a}else{l=void 0}this[u]={method:o,redirect:t.redirect||e.redirect||"follow",headers:i,parsedURL:n,signal:c,referrer:l};this.follow=t.follow===void 0?e.follow===void 0?20:e.follow:t.follow;this.compress=t.compress===void 0?e.compress===void 0?true:e.compress:t.compress;this.counter=t.counter||e.counter||0;this.agent=t.agent||e.agent;this.highWaterMark=t.highWaterMark||e.highWaterMark||16384;this.insecureHTTPParser=t.insecureHTTPParser||e.insecureHTTPParser||false;this.referrerPolicy=t.referrerPolicy||e.referrerPolicy||""}get method(){return this[u].method}get url(){return Xe(this[u].parsedURL)}get headers(){return this[u].headers}get redirect(){return this[u].redirect}get signal(){return this[u].signal}get referrer(){if(this[u].referrer==="no-referrer"){return""}if(this[u].referrer==="client"){return"about:client"}if(this[u].referrer){return this[u].referrer.toString()}return void 0}get referrerPolicy(){return this[u].referrerPolicy}set referrerPolicy(e){this[u].referrerPolicy=Le(e)}clone(){return new r(this)}get[Symbol.toStringTag](){return"Request"}};Object.defineProperties(C.prototype,{method:{enumerable:true},url:{enumerable:true},headers:{enumerable:true},redirect:{enumerable:true},clone:{enumerable:true},signal:{enumerable:true},referrer:{enumerable:true},referrerPolicy:{enumerable:true}});Be=r=>{const{parsedURL:e}=r[u];const t=new g(r[u].headers);if(!t.has("Accept")){t.set("Accept","*/*")}let n=null;if(r.body===null&&/^(post|put)$/i.test(r.method)){n="0"}if(r.body!==null){const c=ye(r);if(typeof c==="number"&&!Number.isNaN(c)){n=String(c)}}if(n){t.set("Content-Length",n)}if(r.referrerPolicy===""){r.referrerPolicy=Pe}if(r.referrer&&r.referrer!=="no-referrer"){r[u].referrer=Ue(r)}else{r[u].referrer="no-referrer"}if(r[u].referrer instanceof URL){t.set("Referer",r.referrer)}if(!t.has("User-Agent")){t.set("User-Agent","node-fetch")}if(r.compress&&!t.has("Accept-Encoding")){t.set("Accept-Encoding","gzip, deflate, br")}let{agent:o}=r;if(typeof o==="function"){o=o(e)}const s=Te(e);const i={path:e.pathname+s,method:r.method,headers:t[Symbol.for("nodejs.util.inspect.custom")](),insecureHTTPParser:r.insecureHTTPParser,agent:o};return{parsedURL:e,options:i}}});var Q;var Ce=y(()=>{M();Q=class extends U{constructor(e,t="aborted"){super(e,t)}}});import er from"node:http";import rr from"node:https";import O from"node:zlib";import $e,{PassThrough as Fe,pipeline as H}from"node:stream";import{Buffer as X}from"node:buffer";async function ke(r,e){return new Promise((t,n)=>{const o=new C(r,e);const{parsedURL:s,options:i}=Be(o);if(!tr.has(s.protocol)){throw new TypeError(`node-fetch cannot load ${r}. URL scheme "${s.protocol.replace(/:$/,"")}" is not supported.`)}if(s.protocol==="data:"){const f=ce(o.url);const P=new S(f,{headers:{"Content-Type":f.typeFull}});t(P);return}const c=(s.protocol==="https:"?rr:er).request;const{signal:l}=o;let a=null;const R=()=>{const f=new Q("The operation was aborted.");n(f);if(o.body&&o.body instanceof $e.Readable){o.body.destroy(f)}if(!a||!a.body){return}a.body.emit("error",f)};if(l&&l.aborted){R();return}const D=()=>{R();A()};const B=c(s.toString(),i);if(l){l.addEventListener("abort",D)}const A=()=>{B.abort();if(l){l.removeEventListener("abort",D)}};B.on("error",f=>{n(new p(`request to ${o.url} failed, reason: ${f.message}`,"system",f));A()});or(B,f=>{if(a&&a.body){a.body.destroy(f)}});if(process.version<"v14"){B.on("socket",f=>{let P;f.prependListener("end",()=>{P=f._eventsCount});f.prependListener("close",h=>{if(a&&P<f._eventsCount&&!h){const L=new Error("Premature close");L.code="ERR_STREAM_PREMATURE_CLOSE";a.body.emit("error",L)}})})}B.on("response",f=>{B.setTimeout(0);const P=be(f.rawHeaders);if(_(f.statusCode)){const d=P.get("Location");let x=null;try{x=d===null?null:new URL(d,o.url)}catch{if(o.redirect!=="manual"){n(new p(`uri requested responds with an invalid redirect URL: ${d}`,"invalid-redirect"));A();return}}switch(o.redirect){case"error":n(new p(`uri requested responds with a redirect, redirect mode is set to error: ${o.url}`,"no-redirect"));A();return;case"manual":break;case"follow":{if(x===null){break}if(o.counter>=o.follow){n(new p(`maximum redirect reached at: ${o.url}`,"max-redirect"));A();return}const w={headers:new g(o.headers),follow:o.follow,counter:o.counter+1,agent:o.agent,compress:o.compress,method:o.method,body:F(o),signal:o.signal,size:o.size,referrer:o.referrer,referrerPolicy:o.referrerPolicy};if(!he(o.url,x)||!de(o.url,x)){for(const He of["authorization","www-authenticate","cookie","cookie2"]){w.headers.delete(He)}}if(f.statusCode!==303&&o.body&&e.body instanceof $e.Readable){n(new p("Cannot follow redirect with body being a readable stream","unsupported-redirect"));A();return}if(f.statusCode===303||(f.statusCode===301||f.statusCode===302)&&o.method==="POST"){w.method="GET";w.body=void 0;w.headers.delete("content-length")}const ie=ve(P);if(ie){w.referrerPolicy=ie}t(ke(new C(x,w)));A();return}default:return n(new TypeError(`Redirect option '${o.redirect}' is not a valid value of RequestRedirect`))}}if(l){f.once("end",()=>{l.removeEventListener("abort",D)})}let h=H(f,new Fe,d=>{if(d){n(d)}});if(process.version<"v12.10"){f.on("aborted",D)}const L={url:o.url,status:f.statusCode,statusText:f.statusMessage,headers:P,size:o.size,counter:o.counter,highWaterMark:o.highWaterMark};const $=P.get("Content-Encoding");if(!o.compress||o.method==="HEAD"||$===null||f.statusCode===204||f.statusCode===304){a=new S(h,L);t(a);return}const Oe={flush:O.Z_SYNC_FLUSH,finishFlush:O.Z_SYNC_FLUSH};if($==="gzip"||$==="x-gzip"){h=H(h,O.createGunzip(Oe),d=>{if(d){n(d)}});a=new S(h,L);t(a);return}if($==="deflate"||$==="x-deflate"){const d=H(f,new Fe,x=>{if(x){n(x)}});d.once("data",x=>{if((x[0]&15)===8){h=H(h,O.createInflate(),w=>{if(w){n(w)}})}else{h=H(h,O.createInflateRaw(),w=>{if(w){n(w)}})}a=new S(h,L);t(a)});d.once("end",()=>{if(!a){a=new S(h,L);t(a)}});return}if($==="br"){h=H(h,O.createBrotliDecompress(),d=>{if(d){n(d)}});a=new S(h,L);t(a);return}a=new S(h,L);t(a)});ge(B,o).catch(n)})}function or(r,e){const t=X.from("0\r\n\r\n");let n=false;let o=false;let s;r.on("response",i=>{const{headers:c}=i;n=c["transfer-encoding"]==="chunked"&&!c["content-length"]});r.on("socket",i=>{const c=()=>{if(n&&!o){const a=new Error("Premature close");a.code="ERR_STREAM_PREMATURE_CLOSE";e(a)}};const l=a=>{o=X.compare(a.slice(-5),t)===0;if(!o&&s){o=X.compare(s.slice(-3),t.slice(0,3))===0&&X.compare(a.slice(-2),t.slice(3))===0}s=a};i.prependListener("close",c);i.on("data",l);r.on("close",()=>{i.removeListener("close",c);i.removeListener("data",l)})})}var tr;var nr=y(()=>{le();K();Se();Z();Ae();q();Ce();ne();fe();V();se();Ve();tr=new Set(["data:","http:","https:"])});nr();export{Q as AbortError,j as Blob,p as FetchError,ze as File,I as FormData,g as Headers,C as Request,S as Response,De as blobFrom,Ne as blobFromSync,ke as default,Me as fileFrom,We as fileFromSync,_ as isRedirect};
2
+ import{a as j,b as Ie,c as ze,d as I,e as ae,f as fe,g as Ne,h as De,i as Me,j as We,k as Ve}from"./chunk-K5DTFR6D.js";import{b as y}from"./chunk-XQK7JM66.js";function Ge(r){if(!/^data:/i.test(r)){throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")')}r=r.replace(/\r?\n/g,"");const e=r.indexOf(",");if(e===-1||e<=4){throw new TypeError("malformed data: URI")}const t=r.substring(5,e).split(";");let n="";let o=false;const s=t[0]||"text/plain";let i=s;for(let R=1;R<t.length;R++){if(t[R]==="base64"){o=true}else if(t[R]){i+=`;${t[R]}`;if(t[R].indexOf("charset=")===0){n=t[R].substring(8)}}}if(!t[0]&&!n.length){i+=";charset=US-ASCII";n="US-ASCII"}const c=o?"base64":"ascii";const l=unescape(r.substring(e+1));const a=Buffer.from(l,c);a.type=s;a.typeFull=i;a.charset=n;return a}var ce;var le=y(()=>{ce=Ge});var U;var M=y(()=>{U=class extends Error{constructor(e,t){super(e);Error.captureStackTrace(this,this.constructor);this.type=t}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}}});var p;var q=y(()=>{M();p=class extends U{constructor(e,t,n){super(e,t);if(n){this.code=this.errno=n.code;this.erroredSysCall=n.syscall}}}});var W,ee,z,ue,he,de;var V=y(()=>{W=Symbol.toStringTag;ee=r=>{return typeof r==="object"&&typeof r.append==="function"&&typeof r.delete==="function"&&typeof r.get==="function"&&typeof r.getAll==="function"&&typeof r.has==="function"&&typeof r.set==="function"&&typeof r.sort==="function"&&r[W]==="URLSearchParams"};z=r=>{return r&&typeof r==="object"&&typeof r.arrayBuffer==="function"&&typeof r.type==="string"&&typeof r.stream==="function"&&typeof r.constructor==="function"&&/^(Blob|File)$/.test(r[W])};ue=r=>{return typeof r==="object"&&(r[W]==="AbortSignal"||r[W]==="EventTarget")};he=(r,e)=>{const t=new URL(e).hostname;const n=new URL(r).hostname;return t===n||t.endsWith(`.${n}`)};de=(r,e)=>{const t=new URL(e).protocol;const n=new URL(r).protocol;return t===n}});import v,{PassThrough as pe}from"node:stream";import{types as me,deprecate as te,promisify as Ke}from"node:util";import{Buffer as b}from"node:buffer";async function re(r){if(r[m].disturbed){throw new TypeError(`body used already for: ${r.url}`)}r[m].disturbed=true;if(r[m].error){throw r[m].error}const{body:e}=r;if(e===null){return b.alloc(0)}if(!(e instanceof v)){return b.alloc(0)}const t=[];let n=0;try{for await(const o of e){if(r.size>0&&n+o.length>r.size){const s=new p(`content size at ${r.url} over limit: ${r.size}`,"max-size");e.destroy(s);throw s}n+=o.length;t.push(o)}}catch(o){const s=o instanceof U?o:new p(`Invalid response body while trying to fetch ${r.url}: ${o.message}`,"system",o);throw s}if(e.readableEnded===true||e._readableState.ended===true){try{if(t.every(o=>typeof o==="string")){return b.from(t.join(""))}return b.concat(t,n)}catch(o){throw new p(`Could not create Buffer from response body for ${r.url}: ${o.message}`,"system",o)}}else{throw new p(`Premature close of server response while trying to fetch ${r.url}`)}}var Ye,m,E,F,Je,G,ye,ge;var K=y(()=>{Ie();fe();q();M();V();Ye=Ke(v.pipeline);m=Symbol("Body internals");E=class{constructor(e,{size:t=0}={}){let n=null;if(e===null){e=null}else if(ee(e)){e=b.from(e.toString())}else if(z(e)){}else if(b.isBuffer(e)){}else if(me.isAnyArrayBuffer(e)){e=b.from(e)}else if(ArrayBuffer.isView(e)){e=b.from(e.buffer,e.byteOffset,e.byteLength)}else if(e instanceof v){}else if(e instanceof I){e=ae(e);n=e.type.split("=")[1]}else{e=b.from(String(e))}let o=e;if(b.isBuffer(e)){o=v.Readable.from(e)}else if(z(e)){o=v.Readable.from(e.stream())}this[m]={body:e,stream:o,boundary:n,disturbed:false,error:null};this.size=t;if(e instanceof v){e.on("error",s=>{const i=s instanceof U?s:new p(`Invalid response body while trying to fetch ${this.url}: ${s.message}`,"system",s);this[m].error=i})}}get body(){return this[m].stream}get bodyUsed(){return this[m].disturbed}async arrayBuffer(){const{buffer:e,byteOffset:t,byteLength:n}=await re(this);return e.slice(t,t+n)}async formData(){const e=this.headers.get("content-type");if(e.startsWith("application/x-www-form-urlencoded")){const n=new I;const o=new URLSearchParams(await this.text());for(const[s,i]of o){n.append(s,i)}return n}const{toFormData:t}=await import("./multipart-parser-JVSLI2CL.js");return t(this.body,e)}async blob(){const e=this.headers&&this.headers.get("content-type")||this[m].body&&this[m].body.type||"";const t=await this.arrayBuffer();return new j([t],{type:e})}async json(){const e=await this.text();return JSON.parse(e)}async text(){const e=await re(this);return new TextDecoder().decode(e)}buffer(){return re(this)}};E.prototype.buffer=te(E.prototype.buffer,"Please use 'response.arrayBuffer()' instead of 'response.buffer()'","node-fetch#buffer");Object.defineProperties(E.prototype,{body:{enumerable:true},bodyUsed:{enumerable:true},arrayBuffer:{enumerable:true},blob:{enumerable:true},json:{enumerable:true},text:{enumerable:true},data:{get:te(()=>{},"data doesn't exist, use json(), text(), arrayBuffer(), or body instead","https://github.com/node-fetch/node-fetch/issues/1000 (response)")}});F=(r,e)=>{let t;let n;let{body:o}=r[m];if(r.bodyUsed){throw new Error("cannot clone body after it is used")}if(o instanceof v&&typeof o.getBoundary!=="function"){t=new pe({highWaterMark:e});n=new pe({highWaterMark:e});o.pipe(t);o.pipe(n);r[m].stream=t;o=n}return o};Je=te(r=>r.getBoundary(),"form-data doesn't follow the spec and requires special treatment. Use alternative package","https://github.com/node-fetch/node-fetch/issues/1167");G=(r,e)=>{if(r===null){return null}if(typeof r==="string"){return"text/plain;charset=UTF-8"}if(ee(r)){return"application/x-www-form-urlencoded;charset=UTF-8"}if(z(r)){return r.type||null}if(b.isBuffer(r)||me.isAnyArrayBuffer(r)||ArrayBuffer.isView(r)){return null}if(r instanceof I){return`multipart/form-data; boundary=${e[m].boundary}`}if(r&&typeof r.getBoundary==="function"){return`multipart/form-data;boundary=${Je(r)}`}if(r instanceof v){return null}return"text/plain;charset=UTF-8"};ye=r=>{const{body:e}=r[m];if(e===null){return 0}if(z(e)){return e.size}if(b.isBuffer(e)){return e.length}if(e&&typeof e.getLengthSync==="function"){return e.hasKnownLength&&e.hasKnownLength()?e.getLengthSync():null}return null};ge=async(r,{body:e})=>{if(e===null){r.end()}else{await Ye(e,r)}}});import{types as we}from"node:util";import J from"node:http";function be(r=[]){return new g(r.reduce((e,t,n,o)=>{if(n%2===0){e.push(o.slice(n,n+2))}return e},[]).filter(([e,t])=>{try{Y(e);oe(e,String(t));return true}catch{return false}}))}var Y,oe,g;var Z=y(()=>{Y=typeof J.validateHeaderName==="function"?J.validateHeaderName:r=>{if(!/^[\^`\-\w!#$%&'*+.|~]+$/.test(r)){const e=new TypeError(`Header name must be a valid HTTP token [${r}]`);Object.defineProperty(e,"code",{value:"ERR_INVALID_HTTP_TOKEN"});throw e}};oe=typeof J.validateHeaderValue==="function"?J.validateHeaderValue:(r,e)=>{if(/[^\t\u0020-\u007E\u0080-\u00FF]/.test(e)){const t=new TypeError(`Invalid character in header content ["${r}"]`);Object.defineProperty(t,"code",{value:"ERR_INVALID_CHAR"});throw t}};g=class r extends URLSearchParams{constructor(e){let t=[];if(e instanceof r){const n=e.raw();for(const[o,s]of Object.entries(n)){t.push(...s.map(i=>[o,i]))}}else if(e==null){}else if(typeof e==="object"&&!we.isBoxedPrimitive(e)){const n=e[Symbol.iterator];if(n==null){t.push(...Object.entries(e))}else{if(typeof n!=="function"){throw new TypeError("Header pairs must be iterable")}t=[...e].map(o=>{if(typeof o!=="object"||we.isBoxedPrimitive(o)){throw new TypeError("Each header pair must be an iterable object")}return[...o]}).map(o=>{if(o.length!==2){throw new TypeError("Each header pair must be a name/value tuple")}return[...o]})}}else{throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)")}t=t.length>0?t.map(([n,o])=>{Y(n);oe(n,String(o));return[String(n).toLowerCase(),String(o)]}):void 0;super(t);return new Proxy(this,{get(n,o,s){switch(o){case"append":case"set":return(i,c)=>{Y(i);oe(i,String(c));return URLSearchParams.prototype[o].call(n,String(i).toLowerCase(),String(c))};case"delete":case"has":case"getAll":return i=>{Y(i);return URLSearchParams.prototype[o].call(n,String(i).toLowerCase())};case"keys":return()=>{n.sort();return new Set(URLSearchParams.prototype.keys.call(n)).keys()};default:return Reflect.get(n,o,s)}}})}get[Symbol.toStringTag](){return this.constructor.name}toString(){return Object.prototype.toString.call(this)}get(e){const t=this.getAll(e);if(t.length===0){return null}let n=t.join(", ");if(/^content-encoding$/i.test(e)){n=n.toLowerCase()}return n}forEach(e,t=void 0){for(const n of this.keys()){Reflect.apply(e,t,[this.get(n),n,this])}}*values(){for(const e of this.keys()){yield this.get(e)}}*entries(){for(const e of this.keys()){yield[e,this.get(e)]}}[Symbol.iterator](){return this.entries()}raw(){return[...this.keys()].reduce((e,t)=>{e[t]=this.getAll(t);return e},{})}[Symbol.for("nodejs.util.inspect.custom")](){return[...this.keys()].reduce((e,t)=>{const n=this.getAll(t);if(t==="host"){e[t]=n[0]}else{e[t]=n.length>1?n:n[0]}return e},{})}};Object.defineProperties(g.prototype,["get","entries","forEach","values"].reduce((r,e)=>{r[e]={enumerable:true};return r},{}))});var Ze,_;var ne=y(()=>{Ze=new Set([301,302,303,307,308]);_=r=>{return Ze.has(r)}});var T,S;var Se=y(()=>{Z();K();ne();T=Symbol("Response internals");S=class r extends E{constructor(e=null,t={}){super(e,t);const n=t.status!=null?t.status:200;const o=new g(t.headers);if(e!==null&&!o.has("Content-Type")){const s=G(e,this);if(s){o.append("Content-Type",s)}}this[T]={type:"default",url:t.url,status:n,statusText:t.statusText||"",headers:o,counter:t.counter,highWaterMark:t.highWaterMark}}get type(){return this[T].type}get url(){return this[T].url||""}get status(){return this[T].status}get ok(){return this[T].status>=200&&this[T].status<300}get redirected(){return this[T].counter>0}get statusText(){return this[T].statusText}get headers(){return this[T].headers}get highWaterMark(){return this[T].highWaterMark}clone(){return new r(F(this,this.highWaterMark),{type:this.type,url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected,size:this.size,highWaterMark:this.highWaterMark})}static redirect(e,t=302){if(!_(t)){throw new RangeError('Failed to execute "redirect" on "response": Invalid status code')}return new r(null,{headers:{location:new URL(e).toString()},status:t})}static error(){const e=new r(null,{status:0,statusText:""});e[T].type="error";return e}static json(e=void 0,t={}){const n=JSON.stringify(e);if(n===void 0){throw new TypeError("data is not JSON serializable")}const o=new g(t&&t.headers);if(!o.has("content-type")){o.set("content-type","application/json")}return new r(n,{...t,headers:o})}get[Symbol.toStringTag](){return"Response"}};Object.defineProperties(S.prototype,{type:{enumerable:true},url:{enumerable:true},status:{enumerable:true},ok:{enumerable:true},redirected:{enumerable:true},statusText:{enumerable:true},headers:{enumerable:true},clone:{enumerable:true}})});var Te;var Re=y(()=>{Te=r=>{if(r.search){return r.search}const e=r.href.length-1;const t=r.hash||(r.href[e]==="#"?"#":"");return r.href[e-t.length]==="?"?"?":""}});import{isIP as _e}from"node:net";function xe(r,e=false){if(r==null){return"no-referrer"}r=new URL(r);if(/^(about|blob|data):$/.test(r.protocol)){return"no-referrer"}r.username="";r.password="";r.hash="";if(e){r.pathname="";r.search=""}return r}function Le(r){if(!Ee.has(r)){throw new TypeError(`Invalid referrerPolicy: ${r}`)}return r}function Qe(r){if(/^(http|ws)s:$/.test(r.protocol)){return true}const e=r.host.replace(/(^\[)|(]$)/g,"");const t=_e(e);if(t===4&&/^127\./.test(e)){return true}if(t===6&&/^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(e)){return true}if(r.host==="localhost"||r.host.endsWith(".localhost")){return false}if(r.protocol==="file:"){return true}return false}function k(r){if(/^about:(blank|srcdoc)$/.test(r)){return true}if(r.protocol==="data:"){return true}if(/^(blob|filesystem):$/.test(r.protocol)){return true}return Qe(r)}function Ue(r,{referrerURLCallback:e,referrerOriginCallback:t}={}){if(r.referrer==="no-referrer"||r.referrerPolicy===""){return null}const n=r.referrerPolicy;if(r.referrer==="about:client"){return"no-referrer"}const o=r.referrer;let s=xe(o);let i=xe(o,true);if(s.toString().length>4096){s=i}if(e){s=e(s)}if(t){i=t(i)}const c=new URL(r.url);switch(n){case"no-referrer":return"no-referrer";case"origin":return i;case"unsafe-url":return s;case"strict-origin":if(k(s)&&!k(c)){return"no-referrer"}return i.toString();case"strict-origin-when-cross-origin":if(s.origin===c.origin){return s}if(k(s)&&!k(c)){return"no-referrer"}return i;case"same-origin":if(s.origin===c.origin){return s}return"no-referrer";case"origin-when-cross-origin":if(s.origin===c.origin){return s}return i;case"no-referrer-when-downgrade":if(k(s)&&!k(c)){return"no-referrer"}return s;default:throw new TypeError(`Invalid referrerPolicy: ${n}`)}}function ve(r){const e=(r.get("referrer-policy")||"").split(/[,\s]+/);let t="";for(const n of e){if(n&&Ee.has(n)){t=n}}return t}var Ee,Pe;var se=y(()=>{Ee=new Set(["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"]);Pe="strict-origin-when-cross-origin"});import{format as Xe}from"node:url";import{deprecate as je}from"node:util";var u,N,qe,C,Be;var Ae=y(()=>{Z();K();V();Re();se();u=Symbol("Request internals");N=r=>{return typeof r==="object"&&typeof r[u]==="object"};qe=je(()=>{},".data is not a valid RequestInit property, use .body instead","https://github.com/node-fetch/node-fetch/issues/1000 (request)");C=class r extends E{constructor(e,t={}){let n;if(N(e)){n=new URL(e.url)}else{n=new URL(e);e={}}if(n.username!==""||n.password!==""){throw new TypeError(`${n} is an url with embedded credentials.`)}let o=t.method||e.method||"GET";if(/^(delete|get|head|options|post|put)$/i.test(o)){o=o.toUpperCase()}if(!N(t)&&"data"in t){qe()}if((t.body!=null||N(e)&&e.body!==null)&&(o==="GET"||o==="HEAD")){throw new TypeError("Request with GET/HEAD method cannot have body")}const s=t.body?t.body:N(e)&&e.body!==null?F(e):null;super(s,{size:t.size||e.size||0});const i=new g(t.headers||e.headers||{});if(s!==null&&!i.has("Content-Type")){const a=G(s,this);if(a){i.set("Content-Type",a)}}let c=N(e)?e.signal:null;if("signal"in t){c=t.signal}if(c!=null&&!ue(c)){throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget")}let l=t.referrer==null?e.referrer:t.referrer;if(l===""){l="no-referrer"}else if(l){const a=new URL(l);l=/^about:(\/\/)?client$/.test(a)?"client":a}else{l=void 0}this[u]={method:o,redirect:t.redirect||e.redirect||"follow",headers:i,parsedURL:n,signal:c,referrer:l};this.follow=t.follow===void 0?e.follow===void 0?20:e.follow:t.follow;this.compress=t.compress===void 0?e.compress===void 0?true:e.compress:t.compress;this.counter=t.counter||e.counter||0;this.agent=t.agent||e.agent;this.highWaterMark=t.highWaterMark||e.highWaterMark||16384;this.insecureHTTPParser=t.insecureHTTPParser||e.insecureHTTPParser||false;this.referrerPolicy=t.referrerPolicy||e.referrerPolicy||""}get method(){return this[u].method}get url(){return Xe(this[u].parsedURL)}get headers(){return this[u].headers}get redirect(){return this[u].redirect}get signal(){return this[u].signal}get referrer(){if(this[u].referrer==="no-referrer"){return""}if(this[u].referrer==="client"){return"about:client"}if(this[u].referrer){return this[u].referrer.toString()}return void 0}get referrerPolicy(){return this[u].referrerPolicy}set referrerPolicy(e){this[u].referrerPolicy=Le(e)}clone(){return new r(this)}get[Symbol.toStringTag](){return"Request"}};Object.defineProperties(C.prototype,{method:{enumerable:true},url:{enumerable:true},headers:{enumerable:true},redirect:{enumerable:true},clone:{enumerable:true},signal:{enumerable:true},referrer:{enumerable:true},referrerPolicy:{enumerable:true}});Be=r=>{const{parsedURL:e}=r[u];const t=new g(r[u].headers);if(!t.has("Accept")){t.set("Accept","*/*")}let n=null;if(r.body===null&&/^(post|put)$/i.test(r.method)){n="0"}if(r.body!==null){const c=ye(r);if(typeof c==="number"&&!Number.isNaN(c)){n=String(c)}}if(n){t.set("Content-Length",n)}if(r.referrerPolicy===""){r.referrerPolicy=Pe}if(r.referrer&&r.referrer!=="no-referrer"){r[u].referrer=Ue(r)}else{r[u].referrer="no-referrer"}if(r[u].referrer instanceof URL){t.set("Referer",r.referrer)}if(!t.has("User-Agent")){t.set("User-Agent","node-fetch")}if(r.compress&&!t.has("Accept-Encoding")){t.set("Accept-Encoding","gzip, deflate, br")}let{agent:o}=r;if(typeof o==="function"){o=o(e)}const s=Te(e);const i={path:e.pathname+s,method:r.method,headers:t[Symbol.for("nodejs.util.inspect.custom")](),insecureHTTPParser:r.insecureHTTPParser,agent:o};return{parsedURL:e,options:i}}});var Q;var Ce=y(()=>{M();Q=class extends U{constructor(e,t="aborted"){super(e,t)}}});import er from"node:http";import rr from"node:https";import O from"node:zlib";import $e,{PassThrough as Fe,pipeline as H}from"node:stream";import{Buffer as X}from"node:buffer";async function ke(r,e){return new Promise((t,n)=>{const o=new C(r,e);const{parsedURL:s,options:i}=Be(o);if(!tr.has(s.protocol)){throw new TypeError(`node-fetch cannot load ${r}. URL scheme "${s.protocol.replace(/:$/,"")}" is not supported.`)}if(s.protocol==="data:"){const f=ce(o.url);const P=new S(f,{headers:{"Content-Type":f.typeFull}});t(P);return}const c=(s.protocol==="https:"?rr:er).request;const{signal:l}=o;let a=null;const R=()=>{const f=new Q("The operation was aborted.");n(f);if(o.body&&o.body instanceof $e.Readable){o.body.destroy(f)}if(!a||!a.body){return}a.body.emit("error",f)};if(l&&l.aborted){R();return}const D=()=>{R();A()};const B=c(s.toString(),i);if(l){l.addEventListener("abort",D)}const A=()=>{B.abort();if(l){l.removeEventListener("abort",D)}};B.on("error",f=>{n(new p(`request to ${o.url} failed, reason: ${f.message}`,"system",f));A()});or(B,f=>{if(a&&a.body){a.body.destroy(f)}});if(process.version<"v14"){B.on("socket",f=>{let P;f.prependListener("end",()=>{P=f._eventsCount});f.prependListener("close",h=>{if(a&&P<f._eventsCount&&!h){const L=new Error("Premature close");L.code="ERR_STREAM_PREMATURE_CLOSE";a.body.emit("error",L)}})})}B.on("response",f=>{B.setTimeout(0);const P=be(f.rawHeaders);if(_(f.statusCode)){const d=P.get("Location");let x=null;try{x=d===null?null:new URL(d,o.url)}catch{if(o.redirect!=="manual"){n(new p(`uri requested responds with an invalid redirect URL: ${d}`,"invalid-redirect"));A();return}}switch(o.redirect){case"error":n(new p(`uri requested responds with a redirect, redirect mode is set to error: ${o.url}`,"no-redirect"));A();return;case"manual":break;case"follow":{if(x===null){break}if(o.counter>=o.follow){n(new p(`maximum redirect reached at: ${o.url}`,"max-redirect"));A();return}const w={headers:new g(o.headers),follow:o.follow,counter:o.counter+1,agent:o.agent,compress:o.compress,method:o.method,body:F(o),signal:o.signal,size:o.size,referrer:o.referrer,referrerPolicy:o.referrerPolicy};if(!he(o.url,x)||!de(o.url,x)){for(const He of["authorization","www-authenticate","cookie","cookie2"]){w.headers.delete(He)}}if(f.statusCode!==303&&o.body&&e.body instanceof $e.Readable){n(new p("Cannot follow redirect with body being a readable stream","unsupported-redirect"));A();return}if(f.statusCode===303||(f.statusCode===301||f.statusCode===302)&&o.method==="POST"){w.method="GET";w.body=void 0;w.headers.delete("content-length")}const ie=ve(P);if(ie){w.referrerPolicy=ie}t(ke(new C(x,w)));A();return}default:return n(new TypeError(`Redirect option '${o.redirect}' is not a valid value of RequestRedirect`))}}if(l){f.once("end",()=>{l.removeEventListener("abort",D)})}let h=H(f,new Fe,d=>{if(d){n(d)}});if(process.version<"v12.10"){f.on("aborted",D)}const L={url:o.url,status:f.statusCode,statusText:f.statusMessage,headers:P,size:o.size,counter:o.counter,highWaterMark:o.highWaterMark};const $=P.get("Content-Encoding");if(!o.compress||o.method==="HEAD"||$===null||f.statusCode===204||f.statusCode===304){a=new S(h,L);t(a);return}const Oe={flush:O.Z_SYNC_FLUSH,finishFlush:O.Z_SYNC_FLUSH};if($==="gzip"||$==="x-gzip"){h=H(h,O.createGunzip(Oe),d=>{if(d){n(d)}});a=new S(h,L);t(a);return}if($==="deflate"||$==="x-deflate"){const d=H(f,new Fe,x=>{if(x){n(x)}});d.once("data",x=>{if((x[0]&15)===8){h=H(h,O.createInflate(),w=>{if(w){n(w)}})}else{h=H(h,O.createInflateRaw(),w=>{if(w){n(w)}})}a=new S(h,L);t(a)});d.once("end",()=>{if(!a){a=new S(h,L);t(a)}});return}if($==="br"){h=H(h,O.createBrotliDecompress(),d=>{if(d){n(d)}});a=new S(h,L);t(a);return}a=new S(h,L);t(a)});ge(B,o).catch(n)})}function or(r,e){const t=X.from("0\r\n\r\n");let n=false;let o=false;let s;r.on("response",i=>{const{headers:c}=i;n=c["transfer-encoding"]==="chunked"&&!c["content-length"]});r.on("socket",i=>{const c=()=>{if(n&&!o){const a=new Error("Premature close");a.code="ERR_STREAM_PREMATURE_CLOSE";e(a)}};const l=a=>{o=X.compare(a.slice(-5),t)===0;if(!o&&s){o=X.compare(s.slice(-3),t.slice(0,3))===0&&X.compare(a.slice(-2),t.slice(3))===0}s=a};i.prependListener("close",c);i.on("data",l);r.on("close",()=>{i.removeListener("close",c);i.removeListener("data",l)})})}var tr;var nr=y(()=>{le();K();Se();Z();Ae();q();Ce();ne();fe();V();se();Ve();tr=new Set(["data:","http:","https:"])});nr();export{Q as AbortError,j as Blob,p as FetchError,ze as File,I as FormData,g as Headers,C as Request,S as Response,De as blobFrom,Ne as blobFromSync,ke as default,Me as fileFrom,We as fileFromSync,_ as isRedirect};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
+ import{a as L,c as M}from"./chunk-2K5H5GA7.js";import{b as E}from"./chunk-RLJVY75P.js";import"./chunk-XQK7JM66.js";var m="[REDACTED]";function w(){return new v}var f=class{redactSpanName(t){return t}redactStatusDescription(t){return t}};var B=[/bearer\s+[a-z0-9._-]+/gi,/\bgh[pousr]_[A-Za-z0-9_]{20,}\b/g,/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g,/\bsk-[A-Za-z0-9]{20,}\b/g,/\bAKIA[0-9A-Z]{16}\b/g,/\bAIza[0-9A-Za-z_-]{35}\b/g,/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,/-----BEGIN [A-Z ]*PRIVATE KEY-----/g,/\b[sr]k_(?:live|test)_[0-9A-Za-z]{10,}\b/g,/\bsk-ant-[A-Za-z0-9\-_]{20,}\b/g,/\bsk-proj-[A-Za-z0-9\-_]{20,}\b/g,/\bhf_[A-Za-z0-9]{30,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{22,}\b/g,/\bglpat-[A-Za-z0-9\-=_]{20,22}\b/g,/\bshp(?:at|ca|pa|ss)_[a-fA-F0-9]{32}\b/g,/\bsq0(?:atp|csp|idp)-[0-9A-Za-z\-_]{22,43}\b/g,/\bPMAK-[a-zA-Z0-9]{24,59}\b/g,/\bphc_[a-zA-Z0-9_]{43}\b/g,/\brubygems_[a-f0-9]{48}\b/g,/\blin_api_[0-9A-Za-z]{40}\b/g,/pypi-AgEIcHlwaS5vcmc[A-Za-z0-9\-_]{50,}/g,/\bsecret_[A-Za-z0-9]{43}\b/g,/[A-Za-z0-9]{14}\.atlasv1\.[A-Za-z0-9]{60,}/g,/\bSG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}\b/g,/\bpk_(?:live|test)_[0-9a-zA-Z]{24}\b/g,/https:\/\/hooks\.slack\.com\/services\/[A-Za-z0-9/+]{40,}/g,/https:\/\/discord(?:app)?\.com\/api\/webhooks\/[0-9]{17,}\/[A-Za-z0-9\-_]{60,}/g,/https:\/\/hooks\.zapier\.com\/hooks\/catch\/[A-Za-z0-9/]{16,}/g];var q=[...B,/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,/\b(?:\d[ -]?){13,16}\b/g,/\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g];var v=class extends f{patterns;redactedValue;constructor(t=q,r={}){super();this.patterns=t;this.redactedValue=r.redactedValue??m}redactAttributes(t){const r={};if(t==null){return r}for(const[n,a]of Object.entries(t)){if(a===void 0){continue}r[n]=Y(a,this.patterns,this.redactedValue)}return r}redactSpanName(t){return D(t,this.patterns,this.redactedValue)}redactStatusDescription(t){if(t==null){return t}return D(t,this.patterns,this.redactedValue)}};var _=class extends f{maskFunction;constructor(t){super();this.maskFunction=t}redactAttributes(t){const r={};if(t==null){return r}for(const[n,a]of Object.entries(t)){if(a===void 0){continue}const i=this.maskFunction(n,a);if(i===void 0){continue}r[n]=i}return r}};function Y(e,t,r=m){return $(e,t,r)[0]}function $(e,t,r=m){if(typeof e==="string"){return P(e,t,r)}if(Array.isArray(e)){let n=0;const a=e.map(i=>{if(typeof i==="string"){const[u,p]=P(i,t,r);n+=p;return u}return i});return[a,n]}return[e,0]}function D(e,t,r=m){return P(e,t,r)[0]}function P(e,t,r=m){let n=e;let a=0;for(const i of t){n=n.replace(i,()=>{a+=1;return r})}return[n,a]}function K(e){if(e===false){return void 0}if(e===true){return w()}return V(e)}function V(e){if(e==null){return w()}if(e instanceof f){return e}if(typeof e==="function"){return new _(e)}throw new TypeError(`redaction policy must be a RedactionPolicy, a callable, or undefined; got ${typeof e}.`)}var g=class{exporter;policy;constructor(t,r){this.exporter=t;this.policy=V(r)}export(t,r){const n=t.map(a=>G(a,this.policy));this.exporter.export(n,r)}shutdown(){return this.exporter.shutdown()}forceFlush(){return this.exporter.forceFlush?.()??Promise.resolve()}};function o(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}function T(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function G(e,t){const r=T(e);o(r,"name",t.redactSpanName(e.name));o(r,"attributes",t.redactAttributes(e.attributes));o(r,"events",j(e.events,t));o(r,"links",H(e.links,t));o(r,"resource",J(e.resource,t));o(r,"status",W(e.status,t));return r}function j(e,t){if(e==null){return[]}return e.map(r=>{const n=T(r);o(n,"attributes",t.redactAttributes(r.attributes));return n})}function H(e,t){if(e==null){return[]}return e.map(r=>{const n=T(r);o(n,"attributes",t.redactAttributes(r.attributes));return n})}function J(e,t){if(e==null){return e}const r=T(e);o(r,"attributes",t.redactAttributes(e.attributes));return r}function W(e,t){if(e==null){return e}const r=t.redactStatusDescription(e.message);const n={code:e.code};if(r!==void 0){n.message=r}return n}var Z="MISTRAL_SDK_TELEMETRY";var X="https://api.mistral.ai";var Q="/telemetry/v1/traces";var ee=N(X);var te="MISTRAL_OTLP_TRACES_ENDPOINT";var d="dedicated";var c="global";var re="false";var s=class extends Error{constructor(t){super(t);this.name="TelemetryConfigurationError"}};async function ne(e,t=d,r={}){const n=h(e);const a=r.redaction;if(typeof t==="string"){const i=ue(t);if(i===c){O(a,c);return U(n,{replaceExisting:true})}return ae(n,{baseURL:e._baseURL,options:e._options},{telemetry:i,replaceExisting:true,redaction:a})}O(a,"custom");b(n);await _e(n,t);return true}function O(e,t){if(e===false){return}Te(`Telemetry redaction is only applied in 'dedicated' provider mode, where the Mistral SDK owns the exporter. In '${t}' mode the application owns the export pipeline; wrap your exporter with RedactingSpanExporter to redact spans. Ignoring the redaction argument.`)}async function Se(e,t){return ne(e,t)}async function Ie(e){const t=h(e);await t._autoTelemetryProvider?.forceFlush?.()}async function ze(e){const t=h(e);await y(t)}function Le(e,t,r,n){const a=h(e);const i=F();return ce(a,i===c).getTracer(t,r,n)}async function ae(e,t,r={}){const n=r.telemetry;const a=n!=null;const i=r.replaceExisting===true;if(!a&&me(e)){return true}if(!a&&e._telemetryAutoDisabled){return false}const u=a?C(n):F();if(e._telemetryInitialization!==void 0){if(!i&&u===d){return e._telemetryInitialization}try{await e._telemetryInitialization}catch{}}if(u==null){b(e);await y(e);ye(e);return false}if(u===c){return U(e,{replaceExisting:i||a})}if(e._autoTelemetryProvider!==void 0){return true}if(e.tracerProvider!==void 0){if(!i){return false}e.tracerProvider=void 0}if(E()!==void 0&&!i){return false}const p=b(e);const l=ie(e,t,r,p);e._telemetryInitialization=l;try{return await l}finally{if(e._telemetryInitialization===l){e._telemetryInitialization=void 0}}}async function ie(e,t,r,n){const a=r.createTelemetryTracerProvider??oe;const i=await a({apiKey:await de(t),baseURL:t.baseURL??t.options?.serverURL,redaction:r.redaction});if(e._telemetryConfigurationVersion!==n){await i.shutdown?.();return false}await pe(e,i);return true}async function oe(e){if(e.apiKey==null||e.apiKey===""){throw new s("Mistral telemetry requires an API key. Pass apiKey to the client or set MISTRAL_API_KEY.")}const t=e.moduleLoader??be;let r;let n;let a;try{[r,n,a]=await Promise.all([t("@opentelemetry/sdk-trace-base"),t("@opentelemetry/exporter-trace-otlp-http"),t("@opentelemetry/resources")])}catch{throw new s("Mistral telemetry requires optional OpenTelemetry SDK/exporter dependencies. Install @opentelemetry/sdk-trace-base, @opentelemetry/exporter-trace-otlp-http, and @opentelemetry/resources with your package manager.")}const i=x(r,"BasicTracerProvider","@opentelemetry/sdk-trace-base");const u=x(r,"BatchSpanProcessor","@opentelemetry/sdk-trace-base");const p=x(n,"OTLPTraceExporter","@opentelemetry/exporter-trace-otlp-http");const l=new p({url:fe(e.baseURL),headers:{Authorization:ge(e.apiKey)}});const S=K(e.redaction??true);const k=S?new g(l,S):l;const I=new u(k);const z=he(a,{"service.name":M});const A=new i({resource:z});if(typeof A.addSpanProcessor==="function"){A.addSpanProcessor(I);return A}return new i({resource:z,spanProcessors:[I]})}function h(e){const t=e._options?.hooks;const r=t?.beforeRequestHooks;if(!Array.isArray(r)){throw new Error("Cannot configure telemetry: SDK hooks not initialised.")}const n=r.find(se);if(n===void 0){throw new Error("Cannot configure telemetry: TracingHook not found in the client's hooks.")}return n}function se(e){return Boolean(e&&typeof e==="object"&&e._mistralTracingHook===true)}function ce(e,t){if(e.tracerProvider!==void 0){return e.tracerProvider}if(!t&&!e._telemetryUseGlobalProvider){const r=E();if(r!==void 0){return r}}return L.getTracerProvider()}function C(e){if(typeof e==="boolean"){return e?d:null}const t=e.trim().toLowerCase();switch(t){case d:return d;case c:return c;case re:return null}throw new s(`Invalid telemetry setting ${JSON.stringify(e)}. Expected one of: dedicated, false, global.`)}function ue(e){const t=e.trim().toLowerCase();switch(t){case d:return d;case c:return c}throw new s(`Invalid telemetry provider ${JSON.stringify(e)}. Expected one of: dedicated, global.`)}function F(){const e=R(Z);if(e==null||e===""){return null}try{return C(e)}catch{throw new s(`Invalid ${Z}=${JSON.stringify(e)}. Expected one of: dedicated, false, global.`)}}async function de(e){const t=e.resolvedSecurity?.headers?.["Authorization"];if(t){return t}const r=await le(e.options?.apiKey);if(r){return r}const n=R("MISTRAL_API_KEY");if(n){return n}throw new s("Mistral telemetry requires an API key. Pass apiKey to the client or set MISTRAL_API_KEY.")}async function le(e){if(e==null){return void 0}return typeof e==="function"?e():e}function fe(e){const t=R(te)?.trim();if(t){return t}if(e!=null&&`${e}`.trim()!==""){return N(e)}return ee}function N(e){return new URL(Q,e).toString()}async function pe(e,t){await y(e);e.tracerProvider=t;e._autoTelemetryProvider=t;e._telemetryUseGlobalProvider=false;e._telemetryAutoDisabled=false}function me(e){return e._autoTelemetryProvider!==void 0||e._telemetryUseGlobalProvider}function ye(e){e._telemetryUseGlobalProvider=false;e._telemetryAutoDisabled=true}function b(e){e._telemetryConfigurationVersion+=1;return e._telemetryConfigurationVersion}async function _e(e,t){await y(e);e.tracerProvider=t;e._telemetryUseGlobalProvider=false;e._telemetryAutoDisabled=false}async function U(e,t){if(e.tracerProvider!==void 0&&e._autoTelemetryProvider===void 0&&!t.replaceExisting){return false}b(e);await y(e);e.tracerProvider=void 0;e._telemetryUseGlobalProvider=true;e._telemetryAutoDisabled=true;return true}async function y(e){const t=e._autoTelemetryProvider;if(t===void 0){return}e._autoTelemetryProvider=void 0;if(e.tracerProvider===t){e.tracerProvider=void 0}await t.shutdown?.()}function ge(e){return e.toLowerCase().startsWith("bearer ")?e:`Bearer ${e}`}function R(e){try{const t=globalThis.Deno?.env;const r=t?.get?.(e);if(r!==void 0){return r}}catch{}try{return globalThis.process?.env?.[e]}catch{return void 0}}function Te(e){try{globalThis.console?.warn?.(e)}catch{}}async function be(e){return await import(e)}function x(e,t,r){const n=e[t];if(typeof n!=="function"){throw new s(`Mistral telemetry expected ${r} to export ${t}.`)}return n}function he(e,t){const r=e["resourceFromAttributes"];if(typeof r==="function"){return r(t)}const n=e["Resource"];if(typeof n!=="function"){return{attributes:t}}const a=new n(t);const i=n.default?.();return i?.merge?.(a)??a}export{te as MISTRAL_OTLP_TRACES_ENDPOINT_ENV,Z as MISTRAL_SDK_TELEMETRY_ENV,X as MISTRAL_TELEMETRY_BASE_URL,ee as MISTRAL_TELEMETRY_ENDPOINT,Q as MISTRAL_TELEMETRY_TRACES_PATH,d as TELEMETRY_PROVIDER_DEDICATED,c as TELEMETRY_PROVIDER_GLOBAL,s as TelemetryConfigurationError,oe as _createTelemetryTracerProvider,ne as configureTelemetry,ae as configureTelemetryForHook,Ie as flushTelemetry,Le as getTelemetryTracer,Se as setTracerProvider,ze as shutdownTelemetry};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
- import{a as u,c}from"./chunk-SIOLUFGG.js";import{c as m}from"./chunk-EYK25HWR.js";import{Fa as a,za as s}from"./chunk-FXOH6TEQ.js";import"./chunk-XFCC2CI2.js";import"./chunk-N5SVBCUB.js";import"./chunk-HNWBFJNO.js";import"./chunk-XQK7JM66.js";function C(t,d,e={}){const r=e.environment??process.env;const o=(e.readConfig??a)();const i=g=>u({configEnabled:g,environment:r});const n=i(o.telemetry.enabled);const l={enabled:n.enabled,configured:n.configured,blockedBy:n.blockedBy??null,configFile:(e.readConfigPath??s)(),channels:{usage:n,metrics:i(o.telemetry.metrics),diagnostics:i(o.telemetry.diagnostics)},optInSetting:{telemetry:{enabled:true,metrics:true,diagnostics:true}},optOutEnvironment:["ALRAN_DISABLE_TELEMETRY=1","DO_NOT_TRACK=1"]};if(t==="status")return`${JSON.stringify(l,null,2)}
2
+ import{a as u,c}from"./chunk-SIOLUFGG.js";import{c as m}from"./chunk-5Y76VFHY.js";import{Aa as s,Ga as a}from"./chunk-XVGPB7TW.js";import"./chunk-VUISZDXX.js";import"./chunk-XSEU4WQD.js";import"./chunk-HNWBFJNO.js";import"./chunk-XQK7JM66.js";function C(t,d,e={}){const r=e.environment??process.env;const o=(e.readConfig??a)();const i=g=>u({configEnabled:g,environment:r});const n=i(o.telemetry.enabled);const l={enabled:n.enabled,configured:n.configured,blockedBy:n.blockedBy??null,configFile:(e.readConfigPath??s)(),channels:{usage:n,metrics:i(o.telemetry.metrics),diagnostics:i(o.telemetry.diagnostics)},optInSetting:{telemetry:{enabled:true,metrics:true,diagnostics:true}},optOutEnvironment:["ALRAN_DISABLE_TELEMETRY=1","DO_NOT_TRACK=1"]};if(t==="status")return`${JSON.stringify(l,null,2)}
3
3
  `;if(!n.enabled){return`${JSON.stringify({...l,request:null,message:"Usage telemetry is disabled. No business telemetry request will be sent."},null,2)}
4
4
  `}const y=(e.resolveEnvironment??f)(r);return`${JSON.stringify({...l,request:c("tui_launch",{launch_type:"cold"},{...y,version:d,now:e.now,randomId:e.randomId,environment:r})},null,2)}
5
5
  `}function f(t){return m({runtimeRegion:t.ALRAN_REGION==="cn"?"cn":"en"})}export{C as runAlranTelemetryCommand};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
- import{A as r,B as s,C as t,D as u,E as v,F as w,G as x,H as y,I as z,J as A,K as B,L as C,M as D,N as E,O as F,P as G,Q as H,g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,t as k,u as l,v as m,w as n,x as o,y as p,z as q}from"./chunk-WTAJMYF2.js";import"./chunk-FSNYOJPJ.js";import"./chunk-FC4M2B7E.js";import"./chunk-EOR6EDNR.js";import"./chunk-ZQOALVGL.js";import"./chunk-XQK7JM66.js";export{g as BashExecutionError,b as DEFAULT_MAX_BYTES,a as DEFAULT_MAX_LINES,z as allToolNames,E as createAllToolDefinitions,H as createAllTools,j as createBashTool,i as createBashToolDefinition,C as createCodingToolDefinitions,F as createCodingTools,o as createEditTool,n as createEditToolDefinition,q as createFindTool,p as createFindToolDefinition,s as createGrepTool,r as createGrepToolDefinition,h as createLocalBashOperations,u as createLsTool,t as createLsToolDefinition,D as createReadOnlyToolDefinitions,G as createReadOnlyTools,w as createReadTool,v as createReadToolDefinition,B as createTool,A as createToolDefinition,y as createWriteTool,x as createWriteToolDefinition,c as formatSize,k as normalizeToLF,l as stripBom,d as truncateHead,f as truncateLine,e as truncateTail,m as withFileMutationQueue};
2
+ import{A as r,B as s,C as t,D as u,E as v,F as w,G as x,H as y,I as z,J as A,K as B,L as C,M as D,N as E,O as F,P as G,Q as H,g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,t as k,u as l,v as m,w as n,x as o,y as p,z as q}from"./chunk-DFMYLGVU.js";import"./chunk-IC6A323Q.js";import"./chunk-2AYWJZ72.js";import"./chunk-R44C5DM6.js";import"./chunk-XQK7JM66.js";export{g as BashExecutionError,b as DEFAULT_MAX_BYTES,a as DEFAULT_MAX_LINES,z as allToolNames,E as createAllToolDefinitions,H as createAllTools,j as createBashTool,i as createBashToolDefinition,C as createCodingToolDefinitions,F as createCodingTools,o as createEditTool,n as createEditToolDefinition,q as createFindTool,p as createFindToolDefinition,s as createGrepTool,r as createGrepToolDefinition,h as createLocalBashOperations,u as createLsTool,t as createLsToolDefinition,D as createReadOnlyToolDefinitions,G as createReadOnlyTools,w as createReadTool,v as createReadToolDefinition,B as createTool,A as createToolDefinition,y as createWriteTool,x as createWriteToolDefinition,c as formatSize,k as normalizeToLF,l as stripBom,d as truncateHead,f as truncateLine,e as truncateTail,m as withFileMutationQueue};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
- import{a}from"./chunk-NWB7LFOK.js";import"./chunk-XQK7JM66.js";export default a();
2
+ import{a}from"./chunk-5DQTVSQV.js";import"./chunk-XQK7JM66.js";export default a();
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
- import{a as h,b as f,c as g}from"./chunk-44VPC5LA.js";import"./chunk-LZJYNT32.js";import"./chunk-GP52JZMY.js";import{d as m}from"./chunk-4X22UJQH.js";import"./chunk-6255CZPL.js";import"./chunk-ZQKVUPKA.js";import"./chunk-ZQOALVGL.js";import"./chunk-XFCC2CI2.js";import"./chunk-N5SVBCUB.js";import"./chunk-XQK7JM66.js";import{createInterface as w}from"node:readline/promises";import{stripVTControlCharacters as $}from"node:util";var T=80;var y=15e3;var u=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];var v=72;async function _(t,e={}){const a=e.application??new g({currentVersion:t});const r=e.interactive??Boolean(process.stdin.isTTY&&process.stdout.isTTY);const i=e.write??(s=>process.stdout.write(s));const l=e.schedulePendingPrefixUpdate??(()=>m());if(await l()){i(`${h()}
2
+ import{a as h,b as f,c as g}from"./chunk-NBONSNQZ.js";import"./chunk-LZJYNT32.js";import"./chunk-GP52JZMY.js";import{d as m}from"./chunk-IN2Z5SSJ.js";import"./chunk-PCL2CVVE.js";import"./chunk-ZQKVUPKA.js";import"./chunk-R44C5DM6.js";import"./chunk-VUISZDXX.js";import"./chunk-XSEU4WQD.js";import"./chunk-XQK7JM66.js";import{createInterface as w}from"node:readline/promises";import{stripVTControlCharacters as $}from"node:util";var T=80;var y=15e3;var u=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];var v=72;async function _(t,e={}){const a=e.application??new g({currentVersion:t});const r=e.interactive??Boolean(process.stdin.isTTY&&process.stdout.isTTY);const i=e.write??(s=>process.stdout.write(s));const l=e.schedulePendingPrefixUpdate??(()=>m());if(await l()){i(`${h()}
3
3
  `);return}const n=await a.inspect();if(n.kind==="current"){i(n.source==="managed-installer"?`Alran ${n.currentVersion} is current on ${n.channel}.
4
4
  `:`Alran ${n.currentVersion} is current on @${n.packageTag}.
5
5
  `);return}if(n.kind==="ahead"){i(`Alran ${n.currentVersion} is newer than ${n.source==="managed-installer"?n.channel:`@${n.packageTag}`} ${n.latestVersion}; no update was applied.
package/cli.js CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
3
- import{g as c}from"./chunks/chunk-4X22UJQH.js";import"./chunks/chunk-6255CZPL.js";import"./chunks/chunk-ZQKVUPKA.js";import"./chunks/chunk-ZQOALVGL.js";import{x as a,z as s}from"./chunks/chunk-IWK7PZP7.js";import"./chunks/chunk-EYK25HWR.js";import{Qb as i,Rb as o}from"./chunks/chunk-FXOH6TEQ.js";import"./chunks/chunk-XFCC2CI2.js";import"./chunks/chunk-N5SVBCUB.js";import"./chunks/chunk-HNWBFJNO.js";import"./chunks/chunk-XQK7JM66.js";async function l(){const n=o(i(process.env));if(n)process.stderr.write(`${n}
4
- `);const t=false;let e;try{e=s(process.argv.slice(2),t)}catch(r){process.stderr.write(`${r instanceof Error?r.message:String(r)}
5
- `);process.exitCode=1;return}const{getTuiDataDirPath:p}=await import("./chunks/data-dir-LDVKDCJ2.js");a({dataDir:p(),...e?{startupBuildEnvironment:e}:{}});const m=await c();try{const{runTuiCli:r}=await import("./chunks/main-TQGGRHTS.js");await r({allowStartupEnvironmentSelection:t})}finally{m.remove()}}await l();
3
+ import{g as o}from"./chunks/chunk-IN2Z5SSJ.js";import"./chunks/chunk-PCL2CVVE.js";import"./chunks/chunk-ZQKVUPKA.js";import"./chunks/chunk-R44C5DM6.js";import{w as i,y as n}from"./chunks/chunk-5RIMHTEU.js";import"./chunks/chunk-5Y76VFHY.js";import"./chunks/chunk-XVGPB7TW.js";import"./chunks/chunk-VUISZDXX.js";import"./chunks/chunk-XSEU4WQD.js";import"./chunks/chunk-HNWBFJNO.js";import"./chunks/chunk-XQK7JM66.js";async function c(){const e=false;let t;try{t=n(process.argv.slice(2),e)}catch(r){process.stderr.write(`${r instanceof Error?r.message:String(r)}
4
+ `);process.exitCode=1;return}const{getTuiDataDirPath:a}=await import("./chunks/data-dir-OEPRRIOO.js");i({dataDir:a(),...t?{startupBuildEnvironment:t}:{}});const s=await o();try{const{runTuiCli:r}=await import("./chunks/main-7SGOQBHZ.js");await r({allowStartupEnvironmentSelection:e})}finally{s.remove()}}await c();
@@ -3621,10 +3621,6 @@ function bedrockLaneHeaders(lane) {
3621
3621
  var PROFILE = ENV_PROFILES[BUILD_ENV];
3622
3622
  var DEFAULT_CLIENT_ID = PROFILE.clientId;
3623
3623
  var DEFAULT_SCOPE = PROFILE.scope;
3624
- var TEST_SANDBOX_API_BASE_URLS = {
3625
- cn: "http://matrix-archon-biz-default.xingye-test.svc.cluster.local:8080",
3626
- en: "http://matrix-archon-biz-default.weaver.svc.cluster.local:8080"
3627
- };
3628
3624
  var DEFAULT_EXTRA_HEADERS = PROFILE.useBedrockLane ? bedrockLaneHeaders(BEDROCK_LANE) : {};
3629
3625
  function stripTrailingSlash(url) {
3630
3626
  return url.replace(/\/+$/, "");
@@ -3724,7 +3720,7 @@ function loadConfig() {
3724
3720
  );
3725
3721
  }
3726
3722
  const apiBaseUrl = stripTrailingSlash(
3727
- apiBaseUrlOverride || (BUILD_ENV === "test" && isSandbox ? TEST_SANDBOX_API_BASE_URLS[region] : PROFILE.apiBaseUrls[region])
3723
+ apiBaseUrlOverride || PROFILE.apiBaseUrls[region]
3728
3724
  );
3729
3725
  const clientId = process.env.ALRAN_CLIENT_ID?.trim() || DEFAULT_CLIENT_ID;
3730
3726
  const scope = process.env.ALRAN_SCOPE?.trim() || DEFAULT_SCOPE;
@@ -19,7 +19,7 @@
19
19
  "resources": [
20
20
  {
21
21
  "path": "cli.mjs",
22
- "sha256": "74d4c136d7b44ab6a1667916fdcaaf16c1b89244fd24064e2c82d29ab1d56f15"
22
+ "sha256": "c2ddaf8f3ef3ea1801d4490f9e5d778aea59ad1e9c2d4bd44de0a4b574d056ac"
23
23
  }
24
24
  ]
25
25
  }
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
- import{b as t}from"./chunks/chunk-FC4M2B7E.js";import"./chunks/chunk-XQK7JM66.js";import{parentPort as m,workerData as n}from"node:worker_threads";var e=n;if(typeof e!=="object"||e===null||!("bytes"in e)||!(e.bytes instanceof Uint8Array)||!("mimeType"in e)||typeof e.mimeType!=="string"||!("maxWidth"in e)||typeof e.maxWidth!=="number"){throw new Error("Invalid image preview input")}var i=await t(e.bytes,e.mimeType,{maxWidth:e.maxWidth,maxHeight:640,maxBytes:4*1024*1024});m?.postMessage(i?.mimeType==="image/png"?i.data:void 0);
2
+ import{b as t}from"./chunks/chunk-IC6A323Q.js";import"./chunks/chunk-XQK7JM66.js";import{parentPort as m,workerData as n}from"node:worker_threads";var e=n;if(typeof e!=="object"||e===null||!("bytes"in e)||!(e.bytes instanceof Uint8Array)||!("mimeType"in e)||typeof e.mimeType!=="string"||!("maxWidth"in e)||typeof e.maxWidth!=="number"){throw new Error("Invalid image preview input")}var i=await t(e.bytes,e.mimeType,{maxWidth:e.maxWidth,maxHeight:640,maxBytes:4*1024*1024});m?.postMessage(i?.mimeType==="image/png"?i.data:void 0);
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
3
- import{R as e}from"./chunks/chunk-ENHOPPS7.js";import"./chunks/chunk-GSYHBK5Q.js";import"./chunks/chunk-M7GW4VMR.js";import"./chunks/chunk-WHD2XVT2.js";import"./chunks/chunk-WWNUAU4P.js";import"./chunks/chunk-N6W7ZL26.js";import"./chunks/chunk-U7U3DJHF.js";import"./chunks/chunk-QKBN5CGI.js";import"./chunks/chunk-J3KCPYZT.js";import"./chunks/chunk-3AODGLMF.js";import"./chunks/chunk-VLXX22YO.js";import"./chunks/chunk-7XYOYZX2.js";import"./chunks/chunk-NWB7LFOK.js";import"./chunks/chunk-EOR6EDNR.js";import"./chunks/chunk-XQK7JM66.js";try{await e()}catch(r){const t=r instanceof Error?r.stack||r.message:String(r);process.stderr.write(`[alran-matrix-mcp-server] fatal ${t}
3
+ import{Na as e}from"./chunks/chunk-JSTSFMGK.js";import"./chunks/chunk-VGKKKM2W.js";import"./chunks/chunk-WHD2XVT2.js";import"./chunks/chunk-LCC45PCZ.js";import"./chunks/chunk-N6W7ZL26.js";import"./chunks/chunk-NVPGGFT3.js";import"./chunks/chunk-QKBN5CGI.js";import"./chunks/chunk-NMKRNU5O.js";import"./chunks/chunk-W5ZOLW7T.js";import"./chunks/chunk-3AODGLMF.js";import"./chunks/chunk-VLXX22YO.js";import"./chunks/chunk-7XYOYZX2.js";import"./chunks/chunk-5DQTVSQV.js";import"./chunks/chunk-2AYWJZ72.js";import"./chunks/chunk-XQK7JM66.js";try{await e()}catch(r){const t=r instanceof Error?r.stack||r.message:String(r);process.stderr.write(`[alran-matrix-mcp-server] fatal ${t}
4
4
  `);process.exitCode=1}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alran",
3
- "version": "0.9.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Alran Code — the AI coding agent of the Ottili AI Platform, in your terminal.",
package/quickjs-worker.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
- import"./chunks/chunk-33CNY6GP.js";import"./chunks/chunk-CJM7ZJ6W.js";import"./chunks/chunk-YPV2X2RG.js";import{e as W}from"./chunks/chunk-4CN3IJFH.js";import"./chunks/chunk-XQK7JM66.js";import{parentPort as R}from"node:worker_threads";async function H(e){let t=J(await e),[o,n,{QuickJSWASMModule:r}]=await Promise.all([t.importModuleLoader().then(J),t.importFFI(),import("./chunks/module-6F3E5H7Y-BN7QWGYB.js").then(J)]),i=await o();i.type="sync";let l=new n(i);return new r(i,l)}function J(e){return e&&"default"in e&&e.default?e.default&&"default"in e.default&&e.default.default?e.default.default:e.default:e}var ae={type:"sync",importFFI:()=>import("./chunks/ffi-IO7WZQNG.js").then(e=>e.QuickJSFFI),importModuleLoader:()=>import("./chunks/emscripten-module-ZS3PMSDF.js").then(e=>e.default)};var M=ae;async function $(e=M){return H(e)}var le;var x;async function U(){return x??(x=$().then(e=>(le=e,e))),await x}function B(e,t){const o=new TextEncoder;let n=0;let r=false;return i=>{if(r)return;const l=o.encode(`${i}
2
+ import"./chunks/chunk-CUG7F2FN.js";import"./chunks/chunk-ZDI22NOK.js";import"./chunks/chunk-4XP5XUIZ.js";import{e as W}from"./chunks/chunk-4CN3IJFH.js";import"./chunks/chunk-XQK7JM66.js";import{parentPort as R}from"node:worker_threads";async function H(e){let t=J(await e),[o,n,{QuickJSWASMModule:r}]=await Promise.all([t.importModuleLoader().then(J),t.importFFI(),import("./chunks/module-6F3E5H7Y-FIMLNSCK.js").then(J)]),i=await o();i.type="sync";let l=new n(i);return new r(i,l)}function J(e){return e&&"default"in e&&e.default?e.default&&"default"in e.default&&e.default.default?e.default.default:e.default:e}var ae={type:"sync",importFFI:()=>import("./chunks/ffi-RLX77WFG.js").then(e=>e.QuickJSFFI),importModuleLoader:()=>import("./chunks/emscripten-module-3WGSFZYF.js").then(e=>e.default)};var M=ae;async function $(e=M){return H(e)}var le;var x;async function U(){return x??(x=$().then(e=>(le=e,e))),await x}function B(e,t){const o=new TextEncoder;let n=0;let r=false;return i=>{if(r)return;const l=o.encode(`${i}
3
3
  `);if(n+l.byteLength<=e){n+=l.byteLength;t(`${i}
4
4
  `,false);return}r=true;const g=new TextDecoder().decode(l.slice(0,Math.max(0,e-n)),{stream:true});n=e;t(g,true)}}var z=5;async function V(e){const t=await U();const o=t.newRuntime();const n=o.newContext();const r=new Map;const i=new Map;const l=new Map;let g;let C;let c=e.signal.aborted;let j=0;let h;let L=0;let P=false;const X=()=>{if(c||e.signal.aborted)return true;return N()>=e.maxComputeMs};const v=()=>{if(P||c)return;P=true;try{S(()=>{const s=o.executePendingJobs();if("error"in s&&s.error)s.error.dispose()})}finally{P=false}};const O=s=>{for(const a of r.values()){if(!a.alive)continue;const u=n.newError(s);a.reject(u);u.dispose()}v()};const F=()=>{c=true;O("PTC execution stopped.")};o.setMemoryLimit(e.maxHeapBytes);o.setInterruptHandler(X);e.signal.addEventListener("abort",F,{once:true});try{const s=new Set(e.tools.map(f=>f.name));const a=n.newFunction("__ptcCall",(f,re)=>{const m=n.newPromise();try{const w=n.getString(f);const b=n.getString(re);if(!s.has(w))throw new Error(`Tool is not available to PTC: ${w}`);if(c||e.signal.aborted)throw new Error("PTC execution stopped.");const p=`ptc-${++L}`;if(L>e.maxToolCalls){e.onLimitExceeded?.("tool_calls");i.set(p,m);queueMicrotask(()=>ee(p));return m.handle}r.set(p,m);const ie=(async()=>{try{D(p,m,await e.callTool({requestId:p,name:w,argsJson:b}))}catch(se){te(p,m,se)}finally{l.delete(p)}})();l.set(p,ie)}catch(w){const b=G(n,w);m.reject(b);b.dispose()}return m.handle});n.setProp(n.global,"__ptcCall",a);a.dispose();const u=n.newFunction("__ptcConsole",f=>{if(!c)e.onConsole?.(de(n,f))});n.setProp(n.global,"__ptcConsole",u);u.dispose();const _=S(()=>T(n,fe(e.tools.map(f=>f.name)),"ptc_runtime.js"));_.dispose();C=n.getProp(n.global,"__ptcDecodeForHost");T(n,"delete globalThis.__ptcDecodeForHost;","ptc_runtime.js").dispose();g=S(()=>T(n,ye(e.code),"run_code.js"));const ne=n.resolvePromise(g);v();const oe=await ne;const I=Y(n,oe);try{return{ok:true,...me(n,I),pendingRequestIds:[...r.keys()]}}finally{I.dispose()}}catch(s){return{ok:false,error:ge(s,c||e.signal.aborted,N()>=e.maxComputeMs),pendingRequestIds:[...r.keys()]}}finally{e.signal.removeEventListener("abort",F);c=true;l.clear();O("PTC execution ended.");g?.dispose();C?.dispose();for(const s of r.values())if(s.alive)s.dispose();for(const s of i.values())if(s.alive)s.dispose();i.clear();n.dispose();o.dispose()}function ee(s){const a=i.get(s);if(!a)return;i.delete(s);if(c){a.dispose();return}const u=W(s,e.maxToolCalls);D(s,a,JSON.stringify(u))}function D(s,a,u){r.delete(s);if(c||!a.alive)return;S(()=>ue(n,C,a,u));a.dispose();queueMicrotask(v)}function te(s,a,u){r.delete(s);if(c||!a.alive)return;const _=G(n,u);a.reject(_);_.dispose();a.dispose();queueMicrotask(v)}function S(s){const a=performance.now();h=a;e.onActivityChange?.(true);try{return s()}finally{j+=performance.now()-a;h=void 0;e.onActivityChange?.(false)}}function N(){return j+(h===void 0?0:performance.now()-h)}}function T(e,t,o){return Y(e,e.evalCode(t,o))}function ue(e,t,o,n){if(!t)throw new Error("PTC result decoder is not ready.");const r=e.newString(n);let i;try{i=e.callFunction(t,e.undefined,r)}finally{r.dispose()}if("value"in i){o.resolve(i.value);i.value.dispose();return}o.reject(i.error);i.error.dispose()}var ce="[PTC dropped a console line that was not a string]";function de(e,t){return e.typeof(t)==="string"?e.getString(t):ce}function Y(e,t){if("value"in t)return t.value;const o=t.error;if(!o)throw new Error("QuickJS returned an empty failure.");try{throw new Error(Z(e.dump(o)))}finally{o.dispose()}}var pe={"<":"\\u003C",">":"\\u003E","/":"\\u002F","\u2028":"\\u2028","\u2029":"\\u2029"};function q(e){return JSON.stringify(e).replace(/[<>/\u2028\u2029]/gu,t=>pe[t]??t)}function fe(e){const t=e.map(o=>`Object.defineProperty(__ptcTools, ${q(o)}, { enumerable: true, value: (args) => __ptcCall(${q(o)}, __ptcEncodeArgs(args)) });`).join("\n");return`
5
5
  const __ptcTools = Object.create(null);
@@ -1,2 +0,0 @@
1
- import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
- import{a as h}from"./chunk-U3RMPDXU.js";import{b as c}from"./chunk-XAGZ6ZEU.js";import{a as R,b as E,c as O}from"./chunk-U7U3DJHF.js";import"./chunk-QKBN5CGI.js";import"./chunk-J3KCPYZT.js";import{a as f}from"./chunk-3AODGLMF.js";import{e as l,f as d,h as g,j as A}from"./chunk-VLXX22YO.js";import"./chunk-7XYOYZX2.js";import"./chunk-XQK7JM66.js";var S="v1";var I=new Set(["openai","openai-codex","opencode","azure-openai-responses"]);function w(r){const n=new Map;if(!r)return n;for(const e of r.split(",")){const t=e.trim();if(!t)continue;const[a,s]=t.split("=",2);if(!a||!s)continue;n.set(a.trim(),s.trim())}return n}function N(r,n){if(n?.azureDeploymentName){return n.azureDeploymentName}const e=w(process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(r.id);return e||r.id}function U(r){if(r instanceof Error){const n=r.status;const e=typeof n==="number"?n:void 0;if(e!==void 0){return`Azure OpenAI API error (${e}): ${r.message}`}return r.message}try{return JSON.stringify(r)}catch{return String(r)}}var _=(r,n,e)=>{const t=new d;(async()=>{const a=N(r,e);const s={role:"assistant",content:[],api:"azure-openai-responses",provider:r.provider,model:r.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const o=e?.apiKey;if(!o){throw new Error(`No API key for provider: ${r.provider}`)}const i=P(r,o,e);let p=x(r,n,e,a);const u=await e?.onPayload?.(p,r);if(u!==void 0){p=u}const z={...e?.signal?{signal:e.signal}:{},...e?.timeoutMs!==void 0?{timeout:e.timeoutMs}:{},maxRetries:e?.maxRetries??0};const{data:y,response:m}=await i.responses.create(p,z).withResponse();await e?.onResponse?.({status:m.status,headers:f(m.headers)},r);t.push({type:"start",partial:s});await O(y,s,t,r);if(e?.signal?.aborted){throw new Error("Request was aborted")}if(s.stopReason==="aborted"||s.stopReason==="error"){throw new Error("An unknown error occurred")}t.push({type:"done",reason:s.stopReason,message:s});t.end()}catch(o){g(e?.onProviderError,o,r);for(const i of s.content){delete i.index;delete i.partialJson}s.stopReason=e?.signal?.aborted?"aborted":"error";s.errorMessage=U(o);t.push({type:"error",reason:s.stopReason,error:s});t.end()}})();return t};var Z=(r,n,e)=>{const t=e?.apiKey;if(!t){throw new Error(`No API key for provider: ${r.provider}`)}const a=A(r,e,t);const s=e?.reasoning?l(r,e.reasoning):void 0;const o=s==="off"?void 0:s;return _(r,n,{...a,reasoningEffort:o})};function v(r){const n=r.trim().replace(/\/+$/,"");let e;try{e=new URL(n)}catch{throw new Error(`Invalid Azure OpenAI base URL: ${r}`)}const t=e.hostname.endsWith(".openai.azure.com")||e.hostname.endsWith(".cognitiveservices.azure.com");const a=e.pathname.replace(/\/+$/,"");if(t&&(a===""||a==="/"||a==="/openai")){e.pathname="/openai/v1";e.search=""}return e.toString().replace(/\/+$/,"")}function M(r){return`https://${r}.openai.azure.com/openai/v1`}function b(r,n){const e=n?.azureApiVersion||process.env.AZURE_OPENAI_API_VERSION||S;const t=n?.azureBaseUrl?.trim()||process.env.AZURE_OPENAI_BASE_URL?.trim()||void 0;const a=n?.azureResourceName||process.env.AZURE_OPENAI_RESOURCE_NAME;let s=t;if(!s&&a){s=M(a)}if(!s&&r.baseUrl){s=r.baseUrl}if(!s){throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.")}return{baseUrl:v(s),apiVersion:e}}function P(r,n,e){const t={...r.headers};if(e?.headers){Object.assign(t,e.headers)}const{baseUrl:a,apiVersion:s}=b(r,e);return new c({apiKey:n,apiVersion:s,dangerouslyAllowBrowser:true,defaultHeaders:t,baseURL:a})}function x(r,n,e,t){const a=R(r,n,I);const s={model:t,input:a,stream:true,prompt_cache_key:h(e?.sessionId),store:false};if(e?.maxTokens){s.max_output_tokens=e?.maxTokens}if(e?.temperature!==void 0){s.temperature=e?.temperature}if(n.tools&&n.tools.length>0){s.tools=E(n.tools)}if(r.reasoning){if(e?.reasoningEffort||e?.reasoningSummary){const o=e?.reasoningEffort?r.thinkingLevelMap?.[e.reasoningEffort]??e.reasoningEffort:"medium";s.reasoning={effort:o,summary:e?.reasoningSummary||"auto"};s.include=["reasoning.encrypted_content"]}else if(r.thinkingLevelMap?.off!==null){s.reasoning={effort:r.thinkingLevelMap?.off??"none"}}}return s}export{_ as streamAzureOpenAIResponses,Z as streamSimpleAzureOpenAIResponses};
@@ -1,3 +0,0 @@
1
- import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
2
- import{a as B,b as W,c as V,f as t,h as s,i as E,k as z,l as U,o as d,p as n,r as N,u as b,w as r,y as a}from"./chunk-M7GW4VMR.js";var Z;function je(e){Z=e}function Ie(){return Z}function l(e,o){let i={};if(!Object.keys(o).length){i=e;return i}for(const[c,m]of Object.entries(e)){const p=o[c];if(p===null){continue}i[p??c]=m}return i}function Ee(e){const o={};for(const[i,c]of Object.entries(e)){if(typeof c!=="undefined"){o[i]=c}}return o}var j=class extends Error{rawValue;rawMessage;static[Symbol.hasInstance](o){if(!(o instanceof Error))return false;if(!("rawValue"in o))return false;if(!("rawMessage"in o))return false;if(!("pretty"in o))return false;if(typeof o.pretty!=="function")return false;return true}constructor(o,i,c){super(`${o}: ${i}`);this.name="SDKValidationError";this.cause=i;this.rawValue=c;this.rawMessage=o}pretty(){if(this.cause instanceof W){return`${this.rawMessage}
3
- ${$e(this.cause)}`}else{return this.toString()}}};function $e(e){return V(e)}function q(e){return{ok:true,value:e}}function G(e){return{ok:false,error:e}}async function Ae(e){const o=await e;if(!o.ok){throw o.error}return o.value}function H(e,o,i){try{return q(o(e))}catch(c){return G(new j(i,c,e))}}var Q=n({prompt_tokens:s().default(0),completion_tokens:s().default(0),total_tokens:s().default(0),prompt_audio_seconds:a(s()).optional(),service_tier:a(t()).optional()}).catchall(z()).transform(e=>{return l(e,{"prompt_tokens":"promptTokens","completion_tokens":"completionTokens","total_tokens":"totalTokens","prompt_audio_seconds":"promptAudioSeconds","service_tier":"serviceTier"})});var We=n({promptTokens:s().default(0),completionTokens:s().default(0),totalTokens:s().default(0),promptAudioSeconds:a(s()).optional(),serviceTier:a(t()).optional()}).catchall(z()).transform(e=>{return{...l(e,{promptTokens:"prompt_tokens",completionTokens:"completion_tokens",totalTokens:"total_tokens",promptAudioSeconds:"prompt_audio_seconds",serviceTier:"service_tier"})}});function D(e){y++;return e}var y=0;var X=0;function J(){X++;const e=y;return{end:o=>{const i=y-e;y=e+(o??i);if(--X===0)y=0;return i}}}function S(e){const o=Object.values(e);return N([...o.map(i=>r(i)),t().transform(i=>D(i))])}function Ge(e){const o=Object.values(e).filter(i=>typeof i==="number");return N([...o.map(i=>r(i)),s().transform(i=>D(i))])}function k(e){return t()}function He(e){return s()}var ee=Symbol("UNKNOWN");function te(e){return typeof e==="object"&&e!==null&&ee in e}function ne(e,o,i={}){const{unknownValue:c="UNKNOWN",outputPropertyName:m}=i;return U().transform(p=>{const h=Object.defineProperties({raw:p,[m??e]:c,isUnknown:true},{[ee]:{value:true,enumerable:false,configurable:false}});const g=typeof p==="object"&&p!==null;if(!g)return h;const x=p[e];if(typeof x!=="string")return h;if(!(x in o))return h;const F=o[x];if(!F)return h;const C=J();const O=F.safeParse(p);if(!O.success){C.end(0);return h}C.end();if(m){O.data[m]=x}return O.data})}var oe=/^\d{4}-\d{2}-\d{2}$/;var w=class e{serialized;static today(){return new e(new Date)}constructor(o){if(typeof o==="string"&&!oe.test(o)){throw new RangeError("RFCDate: date strings must be in the format YYYY-MM-DD: "+o)}const i=new Date(o);if(isNaN(+i)){throw new RangeError("RFCDate: invalid date provided: "+o)}this.serialized=i.toISOString().slice(0,"YYYY-MM-DD".length);if(!oe.test(this.serialized)){throw new TypeError(`RFCDate: failed to build valid date with given value: ${o} serialized to ${this.serialized}`)}}toJSON(){return this.toString()}toString(){return this.serialized}};function u(e){return U().transform((o,i)=>{const c=[];const m=e.map(()=>[]);const p=J();for(const[g,x]of e.entries()){const F=J();const C=x.safeParse(o);const O=F.end();const Je=0;if(C.success){c.push({data:C.data,inexactCount:O,zeroDefaultCount:Je,fieldCount:-1});continue}m[g].push(...C.error.issues)}if(c.length===0){p.end(0);i.addIssue({input:o,code:"invalid_union",errors:m});return B}let h=c[0];for(const g of c){if(c.length>1){g.fieldCount=_e(g.data)}h=Te(g,h)}p.end(h.inexactCount);return h.data})}function Te(e,o){const i=e.inexactCount===0;const c=o.inexactCount===0;if(i!==c){return i?e:o}const m=e.fieldCount-e.zeroDefaultCount;const p=o.fieldCount-o.zeroDefaultCount;if(m!==p){return m>p?e:o}return e.inexactCount<o.inexactCount?e:o}function _e(e){let o=0;const i=[e];let c=0;while(c<i.length){const m=i[c++];if(m===void 0||te(m)){continue}const p=typeof m;if(m===null||p==="number"||p==="string"||p==="boolean"||p==="bigint"||m instanceof Date||m instanceof w){o++;continue}if(Array.isArray(m)){i.push(...m);continue}if(p==="object"){i.push(...Object.values(m))}}return o}var re=n({type:r("input_audio"),input_audio:t()}).transform(e=>{return l(e,{"input_audio":"inputAudio"})});var ie=n({type:r("input_audio"),inputAudio:t()}).transform(e=>{return l(e,{inputAudio:"input_audio"})});var ae=n({type:r("document_url").default("document_url"),document_url:t(),document_name:a(t()).optional()}).transform(e=>{return l(e,{"document_url":"documentUrl","document_name":"documentName"})});var ue=n({type:r("document_url").default("document_url"),documentUrl:t(),documentName:a(t()).optional()}).transform(e=>{return l(e,{documentUrl:"document_url",documentName:"document_name"})});var se=n({type:r("file").default("file"),file_id:t()}).transform(e=>{return l(e,{"file_id":"fileId"})});var ce=n({type:r("file").default("file"),fileId:t()}).transform(e=>{return l(e,{fileId:"file_id"})});var le={Low:"low",Auto:"auto",High:"high"};var me=S(le);var pe=k(le);var v=n({url:t(),detail:a(me).optional()});var L=n({url:t(),detail:a(pe).optional()});var St=u([v,t()]);var gt=u([L,t()]);var fe=n({type:r("image_url").default("image_url"),image_url:u([v,t()])}).transform(e=>{return l(e,{"image_url":"imageUrl"})});var de=n({type:r("image_url").default("image_url"),imageUrl:u([L,t()])}).transform(e=>{return l(e,{imageUrl:"image_url"})});var kt=u([s(),t()]);var Ot=u([s(),t()]);var $=n({type:r("reference").default("reference"),reference_ids:d(u([s(),t()]))}).transform(e=>{return l(e,{"reference_ids":"referenceIds"})});var T=n({type:r("reference").default("reference"),referenceIds:d(u([s(),t()]))}).transform(e=>{return l(e,{referenceIds:"reference_ids"})});var _=n({type:r("text").default("text"),text:t()});var R=n({type:r("text").default("text"),text:t()});var he={WebSearch:"web_search",WebSearchPremium:"web_search_premium",CodeInterpreter:"code_interpreter",ImageGeneration:"image_generation",DocumentLibrary:"document_library"};var A=S(he);var P=k(he);var _t=u([A,t()]);var Rt=u([P,t()]);var M=n({type:r("tool_reference").default("tool_reference"),tool:u([A,t()]),title:t(),url:a(t()).optional(),favicon:a(t()).optional(),description:a(t()).optional()});var Y=n({type:r("tool_reference").default("tool_reference"),tool:u([P,t()]),title:t(),url:a(t()).optional(),favicon:a(t()).optional(),description:a(t()).optional()});var Et=u([M,_,$]);var Dt=u([Y,R,T]);var ze=n({type:r("thinking").default("thinking"),thinking:d(u([M,_,$])),signature:a(t()).optional(),closed:E().optional()});var Se=n({type:r("thinking").default("thinking"),thinking:d(u([Y,R,T])),signature:a(t()).optional(),closed:E().optional()});var K=ne("type",{image_url:fe.and(n({type:r("image_url")})),document_url:ae.and(n({type:r("document_url")})),text:_.and(n({type:r("text")})),reference:$.and(n({type:r("reference")})),file:se.and(n({type:r("file")})),thinking:ze.and(n({type:r("thinking")})),input_audio:re});var Vt=N([de.and(n({type:r("image_url")})),ue.and(n({type:r("document_url")})),R.and(n({type:r("text")})),T.and(n({type:r("reference")})),ce.and(n({type:r("file")})),Se.and(n({type:r("thinking")})),ie]);var Gt=u([b(t(),z()),t()]);var Ht=u([b(t(),z()),t()]);var ge=n({name:t(),arguments:u([b(t(),z()),t()])});var be=n({name:t(),arguments:u([b(t(),z()),t()])});var xe={Function:"function"};var Ce=S(xe);var ke=k(xe);var Oe=n({id:t().default("null"),type:Ce.default("function"),function:ge,index:s().default(0)});var nn=n({id:t().default("null"),type:ke.default("function"),function:be,index:s().default(0)});var cn=u([t(),d(K)]);var Ne=n({role:a(t()).optional(),content:a(u([t(),d(K)])).optional(),tool_calls:a(d(Oe)).optional(),tool_call_id:a(t()).optional(),index:a(s()).optional(),metadata:a(b(t(),z())).optional()}).transform(e=>{return l(e,{"tool_calls":"toolCalls","tool_call_id":"toolCallId"})});var Re={Stop:"stop",Length:"length",Error:"error",ToolCalls:"tool_calls"};var Fe=S(Re);var ye=n({index:s(),delta:Ne,finish_reason:a(Fe)}).transform(e=>{return l(e,{"finish_reason":"finishReason"})});var Ue=n({id:t(),object:t().optional(),created:s().optional(),model:t(),usage:Q.optional(),choices:d(ye)});function Sn(e){return H(e,o=>Ue.parse(JSON.parse(o)),`Failed to parse 'CompletionChunk' from JSON`)}export{je as a,Ie as b,$e as c,q as d,G as e,Ae as f,H as g,l as h,Ee as i,S as j,Ge as k,k as l,He as m,ne as n,u as o,ae as p,ue as q,ce as r,fe as s,de as t,_ as u,R as v,A as w,P as x,M as y,Y as z,ze as A,Se as B,K as C,Vt as D,Ce as E,ke as F,Oe as G,nn as H,Ne as I,Q as J,We as K,Ue as L,Sn as M};