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.
- package/ALRAN_TOOLS_NOTICES.md +11 -0
- package/README.md +11 -16
- package/assets/agents/alran/skills/alran-code-product/SKILL.md +3 -3
- package/assets/agents/alran/skills/alran-code-product/references/account-models.md +19 -16
- package/chunks/{account-commands-JZ6NXTTK.js → account-commands-GW7N3MYC.js} +1 -1
- package/chunks/{anthropic-MN33DP4E.js → anthropic-63VE6MAE.js} +1 -1
- package/chunks/{application-ITGAJ4HC.js → application-WPPTE6LU.js} +1 -1
- package/chunks/{auth-command-V3RVPLZO.js → auth-command-36RMNQZW.js} +1 -1
- package/chunks/azure-openai-responses-OIP3KVKJ.js +2 -0
- package/chunks/chunk-2K5H5GA7.js +2 -0
- package/chunks/chunk-3GGKARES.js +2 -0
- package/chunks/chunk-5RIMHTEU.js +207 -0
- package/chunks/{chunk-EYK25HWR.js → chunk-5Y76VFHY.js} +1 -1
- package/chunks/{chunk-QIN5ZBE2.js → chunk-6DOVXX7W.js} +1 -1
- package/chunks/{chunk-E3GLGDGC.js → chunk-6PFI65C6.js} +1 -1
- package/chunks/{chunk-4PDIO3M6.js → chunk-6UXSIWCB.js} +1 -1
- package/chunks/{chunk-OQNU3VPS.js → chunk-C6LAAFG2.js} +2 -2
- package/chunks/{chunk-33CNY6GP.js → chunk-CUG7F2FN.js} +1 -1
- package/chunks/chunk-DFMYLGVU.js +249 -0
- package/chunks/{chunk-IIE366LR.js → chunk-G5MOGPZ3.js} +490 -485
- package/chunks/{chunk-FC4M2B7E.js → chunk-IC6A323Q.js} +1 -1
- package/chunks/{chunk-4X22UJQH.js → chunk-IN2Z5SSJ.js} +1 -1
- package/chunks/chunk-JSTSFMGK.js +70 -0
- package/chunks/{chunk-WWNUAU4P.js → chunk-LCC45PCZ.js} +1 -1
- package/chunks/{chunk-7QLAXRD2.js → chunk-MPQ6G7LH.js} +254 -254
- package/chunks/{chunk-FUERW2DW.js → chunk-MUXNNOSQ.js} +1 -1
- package/chunks/{chunk-44VPC5LA.js → chunk-NBONSNQZ.js} +1 -1
- package/chunks/chunk-NMKRNU5O.js +2 -0
- package/chunks/chunk-NVPGGFT3.js +2 -0
- package/chunks/chunk-NZXJAHTO.js +9 -0
- package/chunks/{chunk-6255CZPL.js → chunk-PCL2CVVE.js} +1 -1
- package/chunks/chunk-PXH4SBCS.js +3 -0
- package/chunks/chunk-RLJVY75P.js +28 -0
- package/chunks/{chunk-WYANV3IX.js → chunk-RLND4AYL.js} +1 -1
- package/chunks/chunk-TJC4LPRQ.js +2 -0
- package/chunks/chunk-U4PFHJ7Z.js +27 -0
- package/chunks/chunk-V2SB4U4D.js +2 -0
- package/chunks/chunk-VGKKKM2W.js +6 -0
- package/chunks/{chunk-XFCC2CI2.js → chunk-VUISZDXX.js} +1 -1
- package/chunks/chunk-XVGPB7TW.js +21 -0
- package/chunks/{chunk-CJM7ZJ6W.js → chunk-ZDI22NOK.js} +1 -1
- package/chunks/{data-dir-LDVKDCJ2.js → data-dir-OEPRRIOO.js} +1 -1
- package/chunks/{dist-2BRD4JFU.js → dist-VKYZJYR6.js} +1 -1
- package/chunks/{dist-EXKHRFQO.js → dist-WGTMUM3E.js} +1 -1
- package/chunks/{ffi-OUPK6AY6.js → ffi-EFLUAAVX.js} +1 -1
- package/chunks/{ffi-M5UP5J6C.js → ffi-QKKA5HYI.js} +1 -1
- package/chunks/{google-UJAPMFAB.js → google-RCR46TTQ.js} +1 -1
- package/chunks/{google-vertex-VLSF55PW.js → google-vertex-Y26T7YYR.js} +1 -1
- package/chunks/{install-source-JTIUC4G4.js → install-source-63OVVBMK.js} +1 -1
- package/chunks/launcher-2UG3JPYF.js +63 -0
- package/chunks/lifecycle-5IPJRP2V.js +2 -0
- package/chunks/{main-TQGGRHTS.js → main-7SGOQBHZ.js} +2 -2
- package/chunks/{mistral-ZJZUEF2X.js → mistral-NEBDKUEI.js} +1 -1
- package/chunks/{module-6F3E5H7Y-BN7QWGYB.js → module-6F3E5H7Y-FIMLNSCK.js} +1 -1
- package/chunks/{module-asyncify-R6PWJ6ZV-P4FWSBAY.js → module-asyncify-R6PWJ6ZV-Q2HJ3NOC.js} +1 -1
- package/chunks/{multipart-parser-L6M455MS.js → multipart-parser-JVSLI2CL.js} +1 -1
- package/chunks/{network-proxy-U72JCK2I.js → network-proxy-AJO7ZW3O.js} +1 -1
- package/chunks/openai-codex-responses-L2CIGCKO.js +2 -0
- package/chunks/openai-completions-C4PHW6MD.js +2 -0
- package/chunks/openai-responses-5NVFOW4Y.js +2 -0
- package/chunks/{openrouter-G2EHY5BD.js → openrouter-BKUGQT7Z.js} +1 -1
- package/chunks/{otel-OHXIZ666.js → otel-DRJM2PIX.js} +1 -1
- package/chunks/plugin-command-CIDTOPNB.js +2 -0
- package/chunks/provider-command-UZ7KQFAC.js +2 -0
- package/chunks/run-acp-command-AKDLHKMR.js +59 -0
- package/chunks/{run-exec-command-5ADSQR2Z.js → run-exec-command-UXTPS7LC.js} +1 -1
- package/chunks/{skills-command-XXXEZAG6.js → skills-command-57TF53NO.js} +1 -1
- package/chunks/src-5PSNGHHD.js +2 -0
- package/chunks/{src-IBHIRTD7.js → src-YZ26EVSY.js} +1 -1
- package/chunks/telemetry-3NXMCOVD.js +2 -0
- package/chunks/{telemetry-command-COQG2AKK.js → telemetry-command-CMDERYNN.js} +1 -1
- package/chunks/{tools-WDBB2JKV.js → tools-CRJR35HS.js} +1 -1
- package/chunks/{undici-TUGHZJSA.js → undici-O4OQVZ6I.js} +1 -1
- package/chunks/{update-NB6OD572.js → update-ACFAGV6F.js} +1 -1
- package/cli.js +2 -3
- package/embedded/alran-tools/cli.mjs +1 -5
- package/embedded/alran-tools/manifest.json +1 -1
- package/image-preview-worker.js +1 -1
- package/matrix-mcp-stdio.js +1 -1
- package/package.json +1 -1
- package/quickjs-worker.js +1 -1
- package/chunks/azure-openai-responses-OWHMUNKC.js +0 -2
- package/chunks/chunk-C3CMJAAV.js +0 -3
- package/chunks/chunk-ENHOPPS7.js +0 -16
- package/chunks/chunk-FSNYOJPJ.js +0 -2
- package/chunks/chunk-FXOH6TEQ.js +0 -21
- package/chunks/chunk-GRXX6I72.js +0 -2
- package/chunks/chunk-GSYHBK5Q.js +0 -6
- package/chunks/chunk-IWK7PZP7.js +0 -207
- package/chunks/chunk-KCLRJQ53.js +0 -59
- package/chunks/chunk-M7GW4VMR.js +0 -27
- package/chunks/chunk-QFUV5PX6.js +0 -2
- package/chunks/chunk-TW23QKAD.js +0 -3
- package/chunks/chunk-U7U3DJHF.js +0 -2
- package/chunks/chunk-WTAJMYF2.js +0 -249
- package/chunks/chunk-YLQXZBEL.js +0 -2
- package/chunks/chunk-Z6BHCXKT.js +0 -25
- package/chunks/chunk-Z6HBNJCA.js +0 -8
- package/chunks/launcher-FCZ3EDBF.js +0 -61
- package/chunks/lifecycle-GY435YMF.js +0 -2
- package/chunks/openai-codex-responses-FPCDNRL5.js +0 -2
- package/chunks/openai-completions-D32YW6KL.js +0 -2
- package/chunks/openai-responses-ZCGSENM4.js +0 -2
- package/chunks/plugin-command-OSAFHS7C.js +0 -2
- package/chunks/provider-command-SKTCHD4E.js +0 -2
- package/chunks/run-acp-command-SG2BDMFJ.js +0 -2
- package/chunks/src-DNIDEMVV.js +0 -2
- package/chunks/telemetry-J7ZLGF5X.js +0 -2
- /package/chunks/{chunk-EOR6EDNR.js → chunk-2AYWJZ72.js} +0 -0
- /package/chunks/{chunk-YPV2X2RG.js → chunk-4XP5XUIZ.js} +0 -0
- /package/chunks/{chunk-NWB7LFOK.js → chunk-5DQTVSQV.js} +0 -0
- /package/chunks/{chunk-OIQ336YE.js → chunk-EJN3SE5B.js} +0 -0
- /package/chunks/{chunk-A7GMJNA2.js → chunk-K5DTFR6D.js} +0 -0
- /package/chunks/{chunk-ZQOALVGL.js → chunk-R44C5DM6.js} +0 -0
- /package/chunks/{chunk-PNXZWSWT.js → chunk-UJCAE7SG.js} +0 -0
- /package/chunks/{chunk-J3KCPYZT.js → chunk-W5ZOLW7T.js} +0 -0
- /package/chunks/{chunk-XAGZ6ZEU.js → chunk-XLVABFJC.js} +0 -0
- /package/chunks/{chunk-N5SVBCUB.js → chunk-XSEU4WQD.js} +0 -0
- /package/chunks/{chunk-CSOUJVKM.js → chunk-Z5HOCNTZ.js} +0 -0
- /package/chunks/{emscripten-module-ZS3PMSDF.js → emscripten-module-3WGSFZYF.js} +0 -0
- /package/chunks/{emscripten-module-XPTEOIWW.js → emscripten-module-74WUXTHL.js} +0 -0
- /package/chunks/{emscripten-module-WYNDFH3N.js → emscripten-module-MCN4Y3N4.js} +0 -0
- /package/chunks/{emscripten-module-RD6P2XH5.js → emscripten-module-NEAT5LGD.js} +0 -0
- /package/chunks/{ffi-ORLOPBB3.js → ffi-JIGPPPF7.js} +0 -0
- /package/chunks/{ffi-IO7WZQNG.js → ffi-RLX77WFG.js} +0 -0
- /package/chunks/{pdfjs-SHZAF7PF.js → pdfjs-2UOWBGC2.js} +0 -0
- /package/chunks/{photon_rs-C52RL4CI.js → photon_rs-MVWYTYTO.js} +0 -0
|
@@ -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{h as l,i as o,j as p,k as e}from"./chunk-
|
|
2
|
+
import{h as l,i as o,j as p,k as e}from"./chunk-ZDI22NOK.js";import"./chunk-4XP5XUIZ.js";import"./chunk-XQK7JM66.js";export{l as QuickJSModuleCallbacks,e as QuickJSWASMModule,o as applyBaseRuntimeOptions,p as applyModuleEvalRuntimeOptions};
|
package/chunks/{module-asyncify-R6PWJ6ZV-P4FWSBAY.js → module-asyncify-R6PWJ6ZV-Q2HJ3NOC.js}
RENAMED
|
@@ -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 o}from"./chunk-
|
|
2
|
+
import{a as o}from"./chunk-CUG7F2FN.js";import"./chunk-ZDI22NOK.js";import"./chunk-4XP5XUIZ.js";import"./chunk-XQK7JM66.js";export{o as QuickJSAsyncWASMModule};
|
|
@@ -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{c as F,d as U,f as V,k as Y}from"./chunk-
|
|
2
|
+
import{c as F,d as U,f as V,k as Y}from"./chunk-K5DTFR6D.js";import{b as B}from"./chunk-XQK7JM66.js";function v(u){const o=u.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!o){return}const n=o[2]||o[3]||"";let r=n.slice(n.lastIndexOf("\\")+1);r=r.replace(/%22/g,'"');r=r.replace(/&#(\d{4});/g,(E,l)=>{return String.fromCharCode(l)});return r}async function z(u,o){if(!/multipart/i.test(o)){throw new TypeError("Failed to fetch")}const n=o.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!n){throw new TypeError("no or bad content-type header, no multipart boundary")}const r=new y(n[1]||n[2]);let E;let l;let d;let H;let e;let i;const A=[];const b=new U;const p=s=>{d+=h.decode(s,{stream:true})};const N=s=>{A.push(s)};const a=()=>{const s=new F(A,i,{type:e});b.append(H,s)};const S=()=>{b.append(H,d)};const h=new TextDecoder("utf-8");h.decode();r.onPartBegin=function(){r.onPartData=p;r.onPartEnd=S;E="";l="";d="";H="";e="";i=null;A.length=0};r.onHeaderField=function(s){E+=h.decode(s,{stream:true})};r.onHeaderValue=function(s){l+=h.decode(s,{stream:true})};r.onHeaderEnd=function(){l+=h.decode();E=E.toLowerCase();if(E==="content-disposition"){const s=l.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);if(s){H=s[2]||s[3]||""}i=v(l);if(i){r.onPartData=N;r.onPartEnd=a}}else if(E==="content-type"){e=l}l="";E=""};for await(const s of u){r.write(s)}r.end();return b}var f,t,w,_,O,g,x,m,C,I,M,$,R,y;var Z=B(()=>{Y();V();f=0;t={START_BOUNDARY:f++,HEADER_FIELD_START:f++,HEADER_FIELD:f++,HEADER_VALUE_START:f++,HEADER_VALUE:f++,HEADER_VALUE_ALMOST_DONE:f++,HEADERS_ALMOST_DONE:f++,PART_DATA_START:f++,PART_DATA:f++,END:f++};w=1;_={PART_BOUNDARY:w,LAST_BOUNDARY:w*=2};O=10;g=13;x=32;m=45;C=58;I=97;M=122;$=u=>u|32;R=()=>{};y=class{constructor(o){this.index=0;this.flags=0;this.onHeaderEnd=R;this.onHeaderField=R;this.onHeadersEnd=R;this.onHeaderValue=R;this.onPartBegin=R;this.onPartData=R;this.onPartEnd=R;this.boundaryChars={};o="\r\n--"+o;const n=new Uint8Array(o.length);for(let r=0;r<o.length;r++){n[r]=o.charCodeAt(r);this.boundaryChars[n[r]]=true}this.boundary=n;this.lookbehind=new Uint8Array(this.boundary.length+8);this.state=t.START_BOUNDARY}write(o){let n=0;const r=o.length;let E=this.index;let{lookbehind:l,boundary:d,boundaryChars:H,index:e,state:i,flags:A}=this;const b=this.boundary.length;const p=b-1;const N=o.length;let a;let S;const h=c=>{this[c+"Mark"]=n};const s=c=>{delete this[c+"Mark"]};const D=(c,P,T,k)=>{if(P===void 0||P!==T){this[c](k&&k.subarray(P,T))}};const L=(c,P)=>{const T=c+"Mark";if(!(T in this)){return}if(P){D(c,this[T],n,o);delete this[T]}else{D(c,this[T],o.length,o);this[T]=0}};for(n=0;n<r;n++){a=o[n];switch(i){case t.START_BOUNDARY:if(e===d.length-2){if(a===m){A|=_.LAST_BOUNDARY}else if(a!==g){return}e++;break}else if(e-1===d.length-2){if(A&_.LAST_BOUNDARY&&a===m){i=t.END;A=0}else if(!(A&_.LAST_BOUNDARY)&&a===O){e=0;D("onPartBegin");i=t.HEADER_FIELD_START}else{return}break}if(a!==d[e+2]){e=-2}if(a===d[e+2]){e++}break;case t.HEADER_FIELD_START:i=t.HEADER_FIELD;h("onHeaderField");e=0;case t.HEADER_FIELD:if(a===g){s("onHeaderField");i=t.HEADERS_ALMOST_DONE;break}e++;if(a===m){break}if(a===C){if(e===1){return}L("onHeaderField",true);i=t.HEADER_VALUE_START;break}S=$(a);if(S<I||S>M){return}break;case t.HEADER_VALUE_START:if(a===x){break}h("onHeaderValue");i=t.HEADER_VALUE;case t.HEADER_VALUE:if(a===g){L("onHeaderValue",true);D("onHeaderEnd");i=t.HEADER_VALUE_ALMOST_DONE}break;case t.HEADER_VALUE_ALMOST_DONE:if(a!==O){return}i=t.HEADER_FIELD_START;break;case t.HEADERS_ALMOST_DONE:if(a!==O){return}D("onHeadersEnd");i=t.PART_DATA_START;break;case t.PART_DATA_START:i=t.PART_DATA;h("onPartData");case t.PART_DATA:E=e;if(e===0){n+=p;while(n<N&&!(o[n]in H)){n+=b}n-=p;a=o[n]}if(e<d.length){if(d[e]===a){if(e===0){L("onPartData",true)}e++}else{e=0}}else if(e===d.length){e++;if(a===g){A|=_.PART_BOUNDARY}else if(a===m){A|=_.LAST_BOUNDARY}else{e=0}}else if(e-1===d.length){if(A&_.PART_BOUNDARY){e=0;if(a===O){A&=~_.PART_BOUNDARY;D("onPartEnd");D("onPartBegin");i=t.HEADER_FIELD_START;break}}else if(A&_.LAST_BOUNDARY){if(a===m){D("onPartEnd");i=t.END;A=0}else{e=0}}else{e=0}}if(e>0){l[e-1]=a}else if(E>0){const c=new Uint8Array(l.buffer,l.byteOffset,l.byteLength);D("onPartData",0,E,c);E=0;h("onPartData");n--}break;case t.END:break;default:throw new Error(`Unexpected state entered: ${i}`)}}L("onHeaderField");L("onHeaderValue");L("onPartData");this.index=e;this.state=i;this.flags=A}end(){if(this.state===t.HEADER_FIELD_START&&this.index===0||this.state===t.PART_DATA&&this.index===this.boundary.length){this.onPartEnd()}else if(this.state!==t.END){throw new Error("MultipartParser.end(): stream ended unexpectedly")}}}});Z();export{z as toFormData};
|
|
@@ -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,c,d,e,f}from"./chunk-
|
|
2
|
+
import{a,b,c,d,e,f}from"./chunk-MUXNNOSQ.js";import"./chunk-5DQTVSQV.js";import"./chunk-XQK7JM66.js";export{b as configureTuiNetworkProxy,c as createTuiNetworkDispatcher,d as redactProxyUrl,a as resolveTuiProxyConfiguration,f as shouldBypassTuiProxy,e as withoutSocks5ExperimentalWarning};
|
|
@@ -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 X}from"./chunk-U3RMPDXU.js";import{a as Y,b as O,c as V,d as z}from"./chunk-WHD2XVT2.js";import{a as P,b as G,c as D}from"./chunk-NVPGGFT3.js";import"./chunk-QKBN5CGI.js";import"./chunk-NMKRNU5O.js";import"./chunk-W5ZOLW7T.js";import{a as q}from"./chunk-3AODGLMF.js";import{e as H,f as J,h as K,j}from"./chunk-VLXX22YO.js";import"./chunk-7XYOYZX2.js";import"./chunk-XQK7JM66.js";function Q(e){const n=e.filter(r=>r!==void 0);if(n.length===0){return{cleanup:()=>{}}}if(n.length===1){return{signal:n[0],cleanup:()=>{}}}const t=new AbortController;const s=[];const o=r=>{if(!t.signal.aborted){t.abort(r.reason)}};for(const r of n){if(r.aborted){o(r);break}const i=()=>o(r);r.addEventListener("abort",i,{once:true});s.push({signal:r,listener:i})}return{signal:t.signal,cleanup:()=>{for(const{signal:r,listener:i}of s){r.removeEventListener("abort",i)}}}}var x=null;var ie=e=>import(e);var ye="node:os";if(typeof process!=="undefined"&&(process.versions?.node||process.versions?.bun)){ie(ye).then(e=>{x=e})}var Se="https://chatgpt.com/backend-api";var we="https://api.openai.com/auth";var ke=0;var Z=1e3;var he=6e4;var ee=3e4;var Ee=15e3;var ae=new Set(["openai","openai-codex","opencode"]);var Re=1009;var ve=new Set(["completed","incomplete","failed","cancelled","queued","in_progress"]);function Ce(e){return/GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(e)}function xe(e,n){if(e===429&&Ce(n)){return false}if(e===429||e===500||e===502||e===503||e===504){return true}return/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(n)}function _e(e){const n=e.get("retry-after-ms");if(n!==null){const r=Number(n);if(Number.isFinite(r)){return Math.max(0,r)}}const t=e.get("retry-after");if(!t){return void 0}const s=Number(t);if(Number.isFinite(s)){return Math.max(0,s*1e3)}const o=Date.parse(t);if(!Number.isNaN(o)){return Math.max(0,o-Date.now())}return void 0}function Ae(e,n){const t=n?.maxRetryDelayMs??he;return t>0?Math.min(e,t):e}function te(e,n){return new Promise((t,s)=>{if(n?.aborted){s(new Error("Request was aborted"));return}const o=setTimeout(t,e);n?.addEventListener("abort",()=>{clearTimeout(o);s(new Error("Request was aborted"))})})}function ne(e){if(e===void 0)return void 0;if(!Number.isFinite(e)||e<0){throw new Error(`Invalid timeoutMs: ${String(e)}`)}return Math.floor(e)}function Te(e){const n=e?.transport??"auto";return n==="auto"&&e?.fetch?"sse":n}function We(){const e=new AbortController;let n;const t=setTimeout(()=>{n=new Error(`Codex SSE response headers timed out after ${ee}ms`);e.abort(n)},ee);return{signal:e.signal,clear:()=>clearTimeout(t),error:()=>n}}var Oe=(e,n,t)=>{const s=new J;(async()=>{const o={role:"assistant",content:[],api:"openai-codex-responses",provider:e.provider,model:e.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 r=t?.apiKey;if(!r){throw new Error(`No API key for provider: ${e.provider}`)}const i=tt(r);let u=Ie(e,n,t);const a=await t?.onPayload?.(u,e);if(a!==void 0){u=a}const d=t?.sessionId||nt();const m=rt(e.headers,t?.headers,i,r,t?.sessionId);const l=st(e.headers,t?.headers,i,r,d);const w=JSON.stringify(u);const f=ne(t?.timeoutMs);const k=ne(t?.websocketConnectTimeoutMs);const g=Te(t);const b=g!=="sse"&&fe(t?.sessionId);if(b){re(t?.sessionId)}if(g!=="sse"&&!b){let y=false;try{await Ze(Me(e.baseUrl),u,l,o,s,e,()=>{y=true},f,k,t);if(t?.signal?.aborted){throw new Error("Request was aborted")}s.push({type:"done",reason:o.stopReason,message:o});s.end();return}catch(S){const v=t?.signal?.aborted;if(v||Pe(S)){throw S}z(o,V("provider_transport_failure",S,{configuredTransport:g,fallbackTransport:y?void 0:"sse",eventsEmitted:y,phase:y?"after_message_stream_start":"before_message_stream_start",requestBytes:new TextEncoder().encode(w).byteLength}));$e(t?.sessionId,S);if(y){throw S}re(t?.sessionId)}}let c;let p;const E=t?.maxRetries??ke;for(let y=0;y<=E;y++){if(t?.signal?.aborted){throw new Error("Request was aborted")}try{const S=We();const v=Q([t?.signal,S.signal]);try{c=await(t?.fetch??fetch)(de(e.baseUrl),{method:"POST",headers:m,body:w,signal:v.signal})}catch(C){const W=S.error();throw W&&!t?.signal?.aborted?W:C}finally{v.cleanup();S.clear()}await t?.onResponse?.({status:c.status,headers:q(c.headers)},e);if(c.ok){break}const U=await c.text();if(y<E&&xe(c.status,U)){const C=_e(c.headers);const W=C===void 0?Z*2**y:c.status===429?Ae(C,t):C;await te(W,t?.signal);continue}const be=new Response(U,{status:c.status,statusText:c.statusText});const $=await et(be);throw new Error($.friendlyMessage||$.message)}catch(S){if(S instanceof Error){if(S.name==="AbortError"||S.message==="Request was aborted"){throw new Error("Request was aborted")}}p=S instanceof Error?S:new Error(String(S));if(y<E&&!p.message.includes("usage limit")){const v=Z*2**y;await te(v,t?.signal);continue}throw p}}if(!c?.ok){throw p??new Error("Failed after retries")}if(!c.body){throw new Error("No response body")}s.push({type:"start",partial:o});await qe(c,o,s,e,t);if(t?.signal?.aborted){throw new Error("Request was aborted")}s.push({type:"done",reason:o.stopReason,message:o});s.end()}catch(r){K(t?.onProviderError,r,e);for(const i of o.content){delete i.partialJson}o.stopReason=t?.signal?.aborted?"aborted":"error";o.errorMessage=r instanceof Error?r.message:String(r);s.push({type:"error",reason:o.stopReason,error:o});s.end()}})();return s};var bt=(e,n,t)=>{const s=t?.apiKey;if(!s){throw new Error(`No API key for provider: ${e.provider}`)}const o=j(e,t,s);const r=t?.reasoning?H(e,t.reasoning):void 0;const i=r==="off"?void 0:r;return Oe(e,n,{...o,reasoningEffort:i})};function Ie(e,n,t){const s=P(e,n,ae,{includeSystemPrompt:false});const o={model:e.id,store:false,stream:true,instructions:n.systemPrompt||"You are a helpful assistant.",input:s,text:{verbosity:t?.textVerbosity||"low"},include:["reasoning.encrypted_content"],prompt_cache_key:X(t?.sessionId),tool_choice:"auto",parallel_tool_calls:true};if(t?.temperature!==void 0){o.temperature=t.temperature}if(t?.serviceTier!==void 0){o.service_tier=t.serviceTier}if(n.tools&&n.tools.length>0){o.tools=G(n.tools,{strict:null})}if(t?.reasoningEffort!==void 0){const r=t.reasoningEffort==="none"?e.thinkingLevelMap?.off??"none":e.thinkingLevelMap?.[t.reasoningEffort]??t.reasoningEffort;if(r!==null){o.reasoning={effort:r,summary:t.reasoningSummary??"auto"}}}return o}function Le(e,n){switch(n){case"flex":return .5;case"priority":return e.id==="gpt-5.5"?2.5:2;default:return 1}}function ce(e,n,t){const s=Le(t,n);if(s===1)return;e.cost.input*=s;e.cost.output*=s;e.cost.cacheRead*=s;e.cost.cacheWrite*=s;e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite}function ue(e,n){if(e==="default"&&(n==="flex"||n==="priority")){return n}return e??n}function de(e){const n=e&&e.trim().length>0?e:Se;const t=n.replace(/\/+$/,"");if(t.endsWith("/codex/responses"))return t;if(t.endsWith("/codex"))return`${t}/responses`;return`${t}/codex/responses`}function Me(e){const n=new URL(de(e));if(n.protocol==="https:")n.protocol="wss:";if(n.protocol==="http:")n.protocol="ws:";return n.toString()}async function qe(e,n,t,s,o){await D(le(Be(e,o?.signal)),n,t,s,{serviceTier:o?.serviceTier,resolveServiceTier:ue,applyServiceTierPricing:(r,i)=>ce(r,i,s),onProviderStreamEvent:o?.onProviderStreamEvent})}var _=class extends Error{code;payload;constructor(n,t){super(n);this.name="CodexApiError";this.code=t?.code;this.payload=t?.payload;this.cause=t?.cause}};var A=class extends Error{payload;constructor(n,t){super(n);this.name="CodexProtocolError";this.payload=t?.payload;this.cause=t?.cause}};function Pe(e){return e instanceof _||e instanceof A}async function*le(e){for await(const n of e){const t=typeof n.type==="string"?n.type:void 0;if(!t)continue;if(t==="error"){const s=n.code||"";const o=n.message||"";throw new _(`Codex error: ${o||s||JSON.stringify(n)}`,{code:s||void 0,payload:n})}if(t==="response.failed"){const s=n.response;const o=s?.error?.code;const r=s?.error?.message;throw new _(r||"Codex response failed",{code:o,payload:n})}if(t==="response.done"||t==="response.completed"||t==="response.incomplete"){const s=n.response;const o=s?{...s,status:De(s.status)}:s;yield{...n,type:"response.completed",response:o};return}yield n}}function De(e){if(typeof e!=="string")return void 0;return ve.has(e)?e:void 0}async function*Be(e,n){if(!e.body)return;const t=e.body.getReader();const s=new TextDecoder;let o="";const r=()=>{void t.cancel().catch(()=>{})};n?.addEventListener("abort",r,{once:true});try{while(true){if(n?.aborted){throw new Error("Request was aborted")}const{done:i,value:u}=await t.read();if(n?.aborted){throw new Error("Request was aborted")}if(i)break;o+=s.decode(u,{stream:true});let a=o.indexOf("\n\n");while(a!==-1){const d=o.slice(0,a);o=o.slice(a+2);const m=d.split("\n").filter(l=>l.startsWith("data:")).map(l=>l.slice(5).trim());if(m.length>0){const l=m.join("\n").trim();if(l&&l!=="[DONE]"){try{yield JSON.parse(l)}catch(w){throw new A(`Invalid Codex SSE JSON: ${O(w)}`,{cause:w,payload:l})}}}a=o.indexOf("\n\n")}}}finally{n?.removeEventListener("abort",r);try{await t.cancel()}catch{}try{t.releaseLock()}catch{}}}var Ne="responses_websockets=2026-02-06";var Fe=5*60*1e3;var h=new Map;var T=new Map;var M=new Set;function F(e){let n=T.get(e);if(!n){n={requests:0,connectionsCreated:0,connectionsReused:0,cachedContextRequests:0,storeTrueRequests:0,fullContextRequests:0,deltaRequests:0,lastInputItems:0,websocketFailures:0,sseFallbacks:0};T.set(e,n)}return n}function yt(e){const n=T.get(e);return n?{...n}:void 0}function St(e){if(e){T.delete(e);M.delete(e);return}T.clear();M.clear()}function Ue(e){const n=t=>{if(t.idleTimer)clearTimeout(t.idleTimer);R(t.socket,1e3,"debug_close")};if(e){const t=h.get(e);if(t)n(t);h.delete(e);return}for(const t of h.values()){n(t)}h.clear()}Y(Ue);function fe(e){return e?M.has(e):false}function re(e){if(!e)return;const n=F(e);n.sseFallbacks++;n.websocketFallbackActive=fe(e)}function $e(e,n){if(!e)return;M.add(e);const t=F(e);t.websocketFailures++;t.lastWebSocketError=O(n);t.websocketFallbackActive=true}var I=null;async function He(){if(I)return I;if(process?.versions?.bun&&(process.env.HTTP_PROXY||process.env.HTTPS_PROXY||process.env.http_proxy||process.env.https_proxy)){const n=await ie("proxy-from-env");const t=n.getProxyForUrl;I=class extends WebSocket{constructor(s,o){let r={};if(Array.isArray(o)||typeof o==="string"){r={protocols:o}}else{r={...o}}const i=t(s.toString().replace(/^wss:/,"https:").replace(/^ws:/,"http:"));super(s,{...r,...i?{proxy:i}:{}})}};return I}const e=globalThis.WebSocket;if(typeof e!=="function")return null;return e}var N=class extends Error{code;reason;wasClean;constructor(n,t){super(n);this.name="WebSocketCloseError";this.code=t?.code;this.reason=t?.reason;this.wasClean=t?.wasClean}};function Je(e){const n=e.readyState;return typeof n==="number"?n:void 0}function L(e){const n=Je(e);return n===void 0||n===1}function R(e,n=1e3,t="done"){try{e.close(n,t)}catch{}}function se(e,n){if(n.idleTimer){clearTimeout(n.idleTimer)}n.idleTimer=setTimeout(()=>{if(n.busy)return;R(n.socket,1e3,"idle_timeout");h.delete(e)},Fe)}async function B(e,n,t,s=Ee){const o=await He();if(!o){throw new Error("WebSocket transport is not available in this runtime")}const r=q(n);delete r["OpenAI-Beta"];return new Promise((i,u)=>{let a=false;let d;let m;try{m=new o(e,{headers:r})}catch(c){u(c instanceof Error?c:new Error(String(c)));return}const l=()=>{if(d){clearTimeout(d);d=void 0}m.removeEventListener("open",f);m.removeEventListener("error",k);m.removeEventListener("close",g);t?.removeEventListener("abort",b)};const w=(c,p)=>{if(a)return;a=true;l();if(p){R(m,1e3,p)}u(c)};const f=()=>{if(a)return;a=true;l();i(m)};const k=c=>{w(pe(c))};const g=c=>{w(me(c))};const b=()=>{w(new Error("Request was aborted"),"aborted")};m.addEventListener("open",f);m.addEventListener("error",k);m.addEventListener("close",g);t?.addEventListener("abort",b);if(s>0){d=setTimeout(()=>{w(new Error(`WebSocket connect timeout after ${s}ms`),"connect_timeout")},s)}if(t?.aborted){b()}})}async function Ke(e,n,t,s,o){if(!t){const a=await B(e,n,s,o);return{socket:a,reused:false,release:()=>R(a)}}const r=h.get(t);if(r){if(r.idleTimer){clearTimeout(r.idleTimer);r.idleTimer=void 0}if(!r.busy&&L(r.socket)){r.busy=true;return{socket:r.socket,entry:r,reused:true,release:({keep:a}={})=>{if(!a||!L(r.socket)){R(r.socket);h.delete(t);return}r.busy=false;se(t,r)}}}if(r.busy){const a=await B(e,n,s,o);return{socket:a,reused:false,release:()=>{R(a)}}}if(!L(r.socket)){R(r.socket);h.delete(t)}}const i=await B(e,n,s,o);const u={socket:i,busy:true};h.set(t,u);return{socket:i,entry:u,reused:false,release:({keep:a}={})=>{if(!a||!L(u.socket)){R(u.socket);if(u.idleTimer)clearTimeout(u.idleTimer);if(h.get(t)===u){h.delete(t)}return}u.busy=false;se(t,u)}}}function pe(e){if(e&&typeof e==="object"){const n="message"in e?e.message:void 0;if(typeof n==="string"&&n.length>0){return new Error(n)}const t="error"in e?e.error:void 0;if(t instanceof Error&&t.message.length>0){return t}if(t&&typeof t==="object"&&"message"in t){const s=t.message;if(typeof s==="string"&&s.length>0){return new Error(s)}}}return new Error("WebSocket error")}function me(e){if(e&&typeof e==="object"){const n="code"in e?e.code:void 0;const t="reason"in e?e.reason:void 0;const s="wasClean"in e?e.wasClean:void 0;const o=typeof n==="number"?` ${n}`:"";let r=typeof t==="string"&&t.length>0?` ${t}`:"";if(!r&&n===Re){r=" message too big"}return new N(`WebSocket closed${o}${r}`.trim(),{code:typeof n==="number"?n:void 0,reason:typeof t==="string"&&t.length>0?t:void 0,wasClean:typeof s==="boolean"?s:void 0})}return new Error("WebSocket closed")}async function je(e){if(typeof e==="string")return e;if(e instanceof ArrayBuffer){return new TextDecoder().decode(new Uint8Array(e))}if(ArrayBuffer.isView(e)){const n=e;return new TextDecoder().decode(new Uint8Array(n.buffer,n.byteOffset,n.byteLength))}if(e&&typeof e==="object"&&"arrayBuffer"in e){const n=e;const t=await n.arrayBuffer();return new TextDecoder().decode(new Uint8Array(t))}return null}async function*Ge(e,n,t){const s=[];let o=null;let r=false;let i=null;let u=false;const a=()=>{if(!o)return;const f=o;o=null;f()};const d=f=>{void(async()=>{let k=null;try{if(!f||typeof f!=="object"||!("data"in f))return;k=await je(f.data);if(!k)return;const g=JSON.parse(k);const b=typeof g.type==="string"?g.type:"";if(b==="response.completed"||b==="response.done"||b==="response.incomplete"){u=true;r=true}s.push(g);a()}catch(g){i=new A(`Invalid Codex WebSocket JSON: ${O(g)}`,{cause:g,payload:k});r=true;a()}})()};const m=f=>{i=pe(f);r=true;a()};const l=f=>{if(u){r=true;a();return}if(!i){i=me(f)}r=true;a()};const w=()=>{i=new Error("Request was aborted");r=true;a()};e.addEventListener("message",d);e.addEventListener("error",m);e.addEventListener("close",l);n?.addEventListener("abort",w);try{while(true){if(n?.aborted){throw new Error("Request was aborted")}if(s.length>0){yield s.shift();continue}if(r)break;let f;await new Promise((k,g)=>{o=k;if(t!==void 0&&t>0){f=setTimeout(()=>{const b=new Error(`WebSocket idle timeout after ${t}ms`);i=b;r=true;o=null;R(e,1e3,"idle_timeout");g(b)},t)}}).finally(()=>{if(f){clearTimeout(f)}})}if(i){throw i}if(!u){throw new Error("WebSocket stream closed before response.completed")}}finally{e.removeEventListener("message",d);e.removeEventListener("error",m);e.removeEventListener("close",l);n?.removeEventListener("abort",w)}}function oe(e){const{input:n,previous_response_id:t,...s}=e;return s}function Xe(e,n){return JSON.stringify(e??[])===JSON.stringify(n??[])}function Ye(e,n){return JSON.stringify(oe(e))===JSON.stringify(oe(n))}function Ve(e,n){if(!Ye(e,n.lastRequestBody)){return void 0}const t=e.input??[];const s=[...n.lastRequestBody.input??[],...n.lastResponseItems];if(t.length<s.length){return void 0}const o=t.slice(0,s.length);if(!Xe(o,s)){return void 0}return t.slice(s.length)}function ze(e,n){const t=e.continuation;if(!t){return n}const s=Ve(n,t);if(!s||!t.lastResponseId){e.continuation=void 0;return n}return{...n,previous_response_id:t.lastResponseId,input:s}}async function*Qe(e,n,t,s){let o=false;for await(const r of e){if(!o){o=true;s();t.push({type:"start",partial:n})}yield r}}async function Ze(e,n,t,s,o,r,i,u,a,d){const{socket:m,entry:l,reused:w,release:f}=await Ke(e,t,d?.sessionId,d?.signal,a);let k=true;const g=d?.transport==="websocket-cached"||d?.transport==="auto";const b=n;const c=g&&l?ze(l,b):b;const p=d?.sessionId?F(d.sessionId):void 0;if(p){p.requests++;if(w)p.connectionsReused++;else p.connectionsCreated++;if(g)p.cachedContextRequests++;if(c.store===true)p.storeTrueRequests++;p.lastInputItems=c.input?.length??0;if(c.previous_response_id){p.deltaRequests++;p.lastDeltaInputItems=c.input?.length??0;p.lastPreviousResponseId=c.previous_response_id}else{p.fullContextRequests++;p.lastDeltaInputItems=void 0;p.lastPreviousResponseId=void 0}}try{m.send(JSON.stringify({type:"response.create",...c}));await D(Qe(le(Ge(m,d?.signal,u)),s,o,i),s,o,r,{serviceTier:d?.serviceTier,resolveServiceTier:ue,applyServiceTierPricing:(E,y)=>ce(E,y,r),onProviderStreamEvent:d?.onProviderStreamEvent});if(d?.signal?.aborted){k=false}else if(g&&l&&s.responseId){const E=P(r,{messages:[s]},ae,{includeSystemPrompt:false}).filter(y=>y.type!=="function_call_output");l.continuation={lastRequestBody:b,lastResponseId:s.responseId,lastResponseItems:E}}}catch(E){if(l){l.continuation=void 0}k=false;throw E}finally{f({keep:k})}}async function et(e){const n=await e.text();let t=n||e.statusText||"Request failed";let s;try{const o=JSON.parse(n);const r=o?.error;if(r){const i=r.code||r.type||"";if(/usage_limit_reached|usage_not_included|rate_limit_exceeded/i.test(i)||e.status===429){const u=r.plan_type?` (${r.plan_type.toLowerCase()} plan)`:"";const a=r.resets_at?Math.max(0,Math.round((r.resets_at*1e3-Date.now())/6e4)):void 0;const d=a!==void 0?` Try again in ~${a} min.`:"";s=`You have hit your ChatGPT usage limit${u}.${d}`.trim()}t=r.message||s||t}}catch{}return{message:t,friendlyMessage:s}}function tt(e){try{const n=e.split(".");if(n.length!==3)throw new Error("Invalid token");const t=JSON.parse(atob(n[1]));const s=t?.[we]?.chatgpt_account_id;if(!s)throw new Error("No account ID in token");return s}catch{throw new Error("Failed to extract accountId from token")}}function nt(){if(typeof globalThis.crypto?.randomUUID==="function"){return globalThis.crypto.randomUUID()}return`codex_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function ge(e,n,t,s){const o=new Headers(e);for(const[i,u]of Object.entries(n||{})){o.set(i,u)}o.set("Authorization",`Bearer ${s}`);o.set("chatgpt-account-id",t);o.set("originator","pi");const r=x?`pi (${x.platform()} ${x.release()}; ${x.arch()})`:"pi (browser)";o.set("User-Agent",r);return o}function rt(e,n,t,s,o){const r=ge(e,n,t,s);r.set("OpenAI-Beta","responses=experimental");r.set("accept","text/event-stream");r.set("content-type","application/json");if(o){r.set("session-id",o);r.set("x-client-request-id",o)}return r}function st(e,n,t,s,o){const r=ge(e,n,t,s);r.delete("accept");r.delete("content-type");r.delete("OpenAI-Beta");r.delete("openai-beta");r.set("OpenAI-Beta",Ne);r.set("x-client-request-id",o);r.set("session-id",o);return r}export{Ue as closeOpenAICodexWebSocketSessions,yt as getOpenAICodexWebSocketDebugStats,St as resetOpenAICodexWebSocketDebugStats,Oe as streamOpenAICodexResponses,bt as streamSimpleOpenAICodexResponses};
|
|
@@ -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,b,c}from"./chunk-PXH4SBCS.js";import"./chunk-U3RMPDXU.js";import"./chunk-XLVABFJC.js";import"./chunk-N6W7ZL26.js";import"./chunk-NMKRNU5O.js";import"./chunk-W5ZOLW7T.js";import"./chunk-3AODGLMF.js";import"./chunk-VLXX22YO.js";import"./chunk-7XYOYZX2.js";import"./chunk-XQK7JM66.js";export{c as convertMessages,a as streamOpenAICompletions,b as streamSimpleOpenAICompletions};
|
|
@@ -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 w}from"./chunk-U3RMPDXU.js";import{a as m}from"./chunk-XLVABFJC.js";import{a as R,b as v,c as S,d as C}from"./chunk-N6W7ZL26.js";import{a as y,b as A,c as I}from"./chunk-NVPGGFT3.js";import"./chunk-QKBN5CGI.js";import"./chunk-NMKRNU5O.js";import"./chunk-W5ZOLW7T.js";import{a as d}from"./chunk-3AODGLMF.js";import{e as l,f as g,h,j as O}from"./chunk-VLXX22YO.js";import"./chunk-7XYOYZX2.js";import"./chunk-XQK7JM66.js";var T=new Set(["openai","openai-codex","opencode"]);function P(e){if(e){return e}if(typeof process!=="undefined"&&process.env.PI_CACHE_RETENTION==="long"){return"long"}return"short"}function E(e){return{supportsDeveloperRole:e.compat?.supportsDeveloperRole??true,sendSessionIdHeader:e.compat?.sendSessionIdHeader??true,supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??true}}function _(e,t){return t==="long"&&e.supportsLongCacheRetention?"24h":void 0}function L(e){if(e instanceof Error){const t=e.status;const r=typeof t==="number"?t:void 0;if(r!==void 0){return`OpenAI API error (${r}): ${e.message}`}return e.message}try{return JSON.stringify(e)}catch{return String(e)}}var N=(e,t,r)=>{const n=new g;(async()=>{const s={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.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 a=r?.apiKey;if(!a){throw new Error(`No API key for provider: ${e.provider}`)}const o=P(r?.cacheRetention);const i=o==="none"?void 0:r?.sessionId;const u=H(e,t,a,r?.headers,i,r?.fetch);let p=q(e,t,r);const c=await r?.onPayload?.(p,e);if(c!==void 0){p=c}const b={...r?.signal?{signal:r.signal}:{},...r?.timeoutMs!==void 0?{timeout:r.timeoutMs}:{},maxRetries:r?.maxRetries??0};const{data:M,response:f}=await u.responses.create(p,b).withResponse();await r?.onResponse?.({status:f.status,headers:d(f.headers)},e);n.push({type:"start",partial:s});await I(M,s,n,e,{serviceTier:r?.serviceTier,applyServiceTierPricing:(k,x)=>U(k,x,e),onProviderStreamEvent:r?.onProviderStreamEvent});if(r?.signal?.aborted){throw new Error("Request was aborted")}if(s.stopReason==="aborted"||s.stopReason==="error"){throw new Error("An unknown error occurred")}n.push({type:"done",reason:s.stopReason,message:s});n.end()}catch(a){h(r?.onProviderError,a,e);for(const o of s.content){delete o.index;delete o.partialJson}s.stopReason=r?.signal?.aborted?"aborted":"error";s.errorMessage=L(a);n.push({type:"error",reason:s.stopReason,error:s});n.end()}})();return n};var Q=(e,t,r)=>{const n=r?.apiKey;if(!n){throw new Error(`No API key for provider: ${e.provider}`)}const s=O(e,r,n);const a=r?.reasoning?l(e,r.reasoning):void 0;const o=a==="off"?void 0:a;return N(e,t,{...s,reasoningEffort:o})};function H(e,t,r,n,s,a){const o=E(e);const i={...e.headers};if(e.provider==="github-copilot"){const p=S(t.messages);const c=C({messages:t.messages,hasImages:p});Object.assign(i,c)}if(s){if(o.sendSessionIdHeader){i.session_id=s}i["x-client-request-id"]=s}if(n){Object.assign(i,n)}const u=e.provider==="cloudflare-ai-gateway"?{...i,Authorization:i.Authorization??null,"cf-aig-authorization":`Bearer ${r}`}:i;return new m({apiKey:r,baseURL:R(e.provider)?v(e):e.baseUrl,dangerouslyAllowBrowser:true,...a?{fetch:a}:{},defaultHeaders:u})}function q(e,t,r){const n=y(e,t,T);const s=P(r?.cacheRetention);const a=E(e);const o={model:e.id,input:n,stream:true,prompt_cache_key:s==="none"?void 0:w(r?.sessionId),prompt_cache_retention:_(a,s),store:false};if(r?.maxTokens){o.max_output_tokens=r?.maxTokens}if(r?.temperature!==void 0){o.temperature=r?.temperature}if(r?.serviceTier!==void 0){o.service_tier=r.serviceTier}if(t.tools&&t.tools.length>0){o.tools=A(t.tools)}if(e.reasoning){if(r?.reasoningEffort||r?.reasoningSummary){const i=r?.reasoningEffort?e.thinkingLevelMap?.[r.reasoningEffort]??r.reasoningEffort:"medium";o.reasoning={effort:i,summary:r?.reasoningSummary||"auto"};o.include=["reasoning.encrypted_content"]}else if(e.provider!=="github-copilot"&&e.thinkingLevelMap?.off!==null){o.reasoning={effort:e.thinkingLevelMap?.off??"none"}}}return o}function D(e,t){switch(t){case"flex":return .5;case"priority":return e.id==="gpt-5.5"?2.5:2;default:return 1}}function U(e,t,r){const n=D(r,t);if(n===1)return;e.cost.input*=n;e.cost.output*=n;e.cost.cacheRead*=n;e.cost.cacheWrite*=n;e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite}export{N as streamOpenAIResponses,Q as streamSimpleOpenAIResponses};
|
|
@@ -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 d}from"./chunk-
|
|
2
|
+
import{a as d}from"./chunk-XLVABFJC.js";import{a as I}from"./chunk-3AODGLMF.js";import{a as f}from"./chunk-7XYOYZX2.js";import"./chunk-XQK7JM66.js";var b=async(e,o,a)=>{const t={api:e.api,provider:e.provider,model:e.id,output:[],stopReason:"stop",timestamp:Date.now()};try{const s=a?.apiKey;if(!s){throw new Error(`No API key for provider: ${e.provider}`)}const i=y(e,s,a?.headers,a?.fetch);let r=x(e,o);const m=await a?.onPayload?.(r,e);if(m!==void 0){r=m}const n={...a?.signal?{signal:a.signal}:{},...a?.timeoutMs!==void 0?{timeout:a.timeoutMs}:{},maxRetries:a?.maxRetries??0};const{data:R,response:C}=await i.chat.completions.create(r,n).withResponse();await a?.onResponse?.({status:C.status,headers:I(C.headers)},e);const p=R;t.responseId=p.id;if(p.usage){t.usage=_(p.usage,e)}const c=p.choices[0];if(c){const u=c.message.content;if(typeof u==="string"&&u.length>0){t.output.push({type:"text",text:u})}for(const g of c.message.images??[]){const l=typeof g.image_url==="string"?g.image_url:g.image_url?.url;if(!l?.startsWith("data:"))continue;const h=l.match(/^data:([^;]+);base64,(.+)$/);if(!h)continue;t.output.push({type:"image",mimeType:h[1],data:h[2]})}}return t}catch(s){t.stopReason=a?.signal?.aborted?"aborted":"error";t.errorMessage=s instanceof Error?s.message:JSON.stringify(s);return t}};function y(e,o,a,t){return new d({apiKey:o,baseURL:e.baseUrl,dangerouslyAllowBrowser:true,...t?{fetch:t}:{},defaultHeaders:{...e.headers,...a}})}function x(e,o){const a=o.input.map(t=>{if(t.type==="text"){return{type:"text",text:f(t.text)}}return{type:"image_url",image_url:{url:`data:${t.mimeType};base64,${t.data}`}}});return{model:e.id,messages:[{role:"user",content:a}],stream:false,modalities:e.output.includes("text")?["image","text"]:["image"]}}function _(e,o){const a=e.prompt_tokens||0;const t=e.prompt_tokens_details?.cached_tokens||0;const s=e.prompt_tokens_details?.cache_write_tokens||0;const i=s>0?Math.max(0,t-s):t;const r=Math.max(0,a-i-s);const m=e.completion_tokens||0;const n={input:r,output:m,cacheRead:i,cacheWrite:s,totalTokens:r+m+i+s,cost:{input:o.cost.input/1e6*r,output:o.cost.output/1e6*m,cacheRead:o.cost.cacheRead/1e6*i,cacheWrite:o.cost.cacheWrite/1e6*s,total:0}};n.cost.total=n.cost.input+n.cost.output+n.cost.cacheRead+n.cost.cacheWrite;return n}export{b as generateImagesOpenRouter};
|
|
@@ -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 c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q}from"./chunk-
|
|
2
|
+
import{b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q}from"./chunk-2K5H5GA7.js";import{a,b}from"./chunk-RLJVY75P.js";import"./chunk-XQK7JM66.js";export{e as MISTRAL_SDK_OTEL_TRACER_NAME,f as MistralAIAttributes,d as OTEL_SERVICE_NAME,g as TracingErrors,h as enrichSpanFromRequest,i as enrichSpanFromResponse,j as getOrCreateOtelTracer,b as getRegisteredTracerProvider,p as getResponseAndError,k as getSpanContext,n as getTracedRequestAndSpan,o as getTracedResponse,m as recordRequestError,a as registerTracerProvider,l as runWithContext,c as semConvAttributes,q as traceAsync};
|
|
@@ -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{b,c as h,d as y,e as k,f as v,g as C,h as $,i as S,j as V}from"./chunk-6PFI65C6.js";import{a as m,d as P}from"./chunk-RLND4AYL.js";import{a as w,b as A}from"./chunk-G5MOGPZ3.js";import"./chunk-GP52JZMY.js";import"./chunk-QPGTKSIQ.js";import"./chunk-BQ3CF3KE.js";import"./chunk-MPQ6G7LH.js";import"./chunk-LU4RPLJ3.js";import"./chunk-2TF6JAQM.js";import"./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"./chunk-IC6A323Q.js";import"./chunk-4CN3IJFH.js";import"./chunk-F46IELF5.js";import"./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 g}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";var d=class{constructor(a){this.access=a}access;async catalog(a){if(!a.includeAvailable){return{installed:await this.access.listInstalledPlugins({marketplace:a.marketplace}),available:[]}}const n=a.marketplace?[a.marketplace]:["official","local"];const[t,r]=await Promise.all([this.access.listInstalledPlugins({marketplace:a.marketplace}),Promise.allSettled(n.map(o=>this.access.listMarketplacePlugins({marketplace:o})))]);const i=[];const l=[];r.forEach((o,c)=>{if(o.status==="fulfilled")l.push(o.value);else i.push({marketplace:n[c],reason:E(o.reason)})});if(a.marketplace&&i.length>0){throw new Error(p(i[0]))}const u=new Map(l.flat().map(o=>[o.pluginId,o]));for(const o of t)u.set(o.pluginId,o);const s=j([...u.values()]);return i.length>0?{...s,unavailable:i}:s}install(a){return this.mutate(a,"install")}remove(a){return this.mutate(a,"remove")}setEnabled(a,n){return this.mutate(a,n?"enable":"disable")}refresh(){return this.access.refreshPlugins()}async mutate(a,n){const t=await this.access.mutatePlugin({action:n,plugin:{name:a.name,marketplace:a.marketplace}});return{...a,...t}}};function j(e){const a=[];const n=[];for(const t of e){(t.installed?a:n).push(t)}return{installed:a,available:n}}function E(e){return e instanceof Error?e.message:String(e)}function p(e){return e.marketplace==="official"?`The Ottili Plugin registry is not reachable (${e.reason}). Set ALRAN_PLUGIN_REGISTRY_URL to a registry you run, or add a Plugin from a directory: copy the Plugin's folder into the local Plugin directory (\`alran plugins marketplace list\` shows where); a Plugin there is installed and enabled.`:`The local Plugin directory could not be read (${e.reason}).`}function D(e){return e.action==="search"||e.action==="marketplace-list"||e.action==="marketplace-add"||e.action==="marketplace-remove"}async function K(e){const a=e.request;if(D(a)){const t=e.dataDir??await g();const r=(e.createHost??I)({dataDir:t});return x(a,r,t)}const n=e.createContext?await e.createContext(e.lane):await U(e.version,e.lane);try{const t=(e.createHost??I)({dataDir:n.dataDir,...n.access?{access:n.access}:{}});if(a.action==="marketplace-upgrade"){await n.application.refresh();await t.store.catalog({refresh:true});const c={marketplace:"all",refreshed:true};return a.json?JSON.stringify(c,null,2):"Refreshed all Plugin sources."}if(a.action==="info")return h(t,"plugin",a.selector,a.json);if(a.action==="update"){return k(t,"plugin",{selector:a.selector,yes:a.yes,json:a.json})}if(a.action==="list")return O(t,a);if(a.action!=="marketplace-list"&&a.action!=="marketplace-add"&&a.action!=="marketplace-remove"&&a.action!=="search"){const c=await M(t,a);if(c!==void 0)return c}if(a.action!=="add"&&a.action!=="remove"&&a.action!=="enable"&&a.action!=="disable"){throw new Error(`Unhandled Plugin action: ${a.action}`)}const{name:r,marketplace:i}=T(a.selector,a.marketplace);const l=await n.application.catalog({includeAvailable:a.action==="add",marketplace:i});const u=a.action==="add"?[...l.installed,...l.available]:l.installed;if(l.unavailable?.length&&!u.some(c=>c.name===r||c.pluginId===r)){throw new Error(p(l.unavailable[0]))}const s=J(u,r,i);if(a.action==="add"&&s.marketplace==="local"&&s.installed){return a.json?JSON.stringify(N(s),null,2):R(s)}const o=a.action==="add"?await n.application.install(s):a.action==="remove"?await n.application.remove(s):await n.application.setEnabled(s,a.action==="enable");return a.json?JSON.stringify(N(o),null,2):R(o)}finally{await n.shutdown()}}function I(e){return V(new P({dataDir:e.dataDir,...e.access?{plugins:e.access}:{}}))}async function x(e,a,n){switch(e.action){case"search":return b(a,"plugin",e);case"marketplace-list":return C(a,n,e.json);case"marketplace-add":return $(a,e);case"marketplace-remove":return S(a,e.name,e.json);default:throw new Error(`Not a store-only Plugin action: ${e.action}`)}}async function M(e,a){if(a.marketplace||/@(official|local)$/u.test(a.selector))return void 0;const n=a.action==="remove"||a.action==="enable"||a.action==="disable";const t=await e.store.catalog({offline:n});let r;try{r=e.store.resolve(t,"plugin",a.selector)}catch(l){if(l instanceof m&&l.code==="NOT_FOUND")return void 0;throw l}if(r.origin==="local"||r.origin==="official")return void 0;if(a.action==="add"){return y(e,"plugin",a.selector,{yes:a.yes,json:a.json})}if(a.action==="remove"){return v(e,"plugin",a.selector,a.json)}if(!r.installed){throw new m("NOT_FOUND",`Plugin ${r.name}@${r.origin} is not installed.`)}await e.store.setEnabled(r,a.action==="enable");const i=e.store.resolve(await e.store.catalog({offline:true}),"plugin",`${r.name}@${r.origin}`);return a.json?JSON.stringify(f(i),null,2):`${i.enabled?"[*]":"[-]"} ${i.name}@${i.origin} ${i.enabled?"enabled":"disabled"}`}async function O(e,a){const n=await e.store.catalog({offline:!a.available||a.marketplace!==void 0});const t=n.items.filter(l=>l.kind==="plugin"&&(a.available||l.installed)&&(!a.marketplace||(l.plugin?l.plugin.marketplace:l.origin)===a.marketplace));const r=n.sources.flatMap(l=>l.error?[`store "${l.source.id}" ${l.index?"is unreachable, showing a cached copy":"could not be read"}: ${l.error}`]:[]);if(a.json){return JSON.stringify({installed:t.filter(l=>l.installed).map(f),available:t.filter(l=>!l.installed).map(f),...r.length?{notes:r}:{}},null,2)}const i=t.map(l=>{const u=l.enabled?"[*]":l.installed?"[-]":"[ ]";const s=l.installed?l.enabled?"enabled":"disabled":"available";const o=l.updateAvailable?" (update available)":"";return`${u} ${l.name}@${l.origin} ${s}${o}`}).join("\n");return[i,...r.map(l=>`note: ${l}`)].filter(Boolean).join("\n")}function f(e){const a=e.entry?.kind==="plugin"?e.entry.contents:void 0;return{pluginId:`${e.name}@${e.origin}`,name:e.name,displayName:e.displayName,marketplaceName:e.origin,...e.version?{version:e.version}:{},...e.description?{description:e.description}:{},...e.author?{author:e.author}:{},installed:e.installed,enabled:e.enabled,...e.updateAvailable?{updateAvailable:true}:{},capabilities:e.plugin?.capabilities??{appCount:a?.apps.length??0,mcpServerCount:a?.mcpServers.length??0,skillCount:a?.skills.length??0}}}function N(e){return{pluginId:e.pluginId,name:e.name,displayName:e.displayName,marketplaceName:e.marketplace,...e.version?{version:e.version}:{},...e.description?{description:e.description}:{},...e.author?{author:e.author}:{},installed:e.installed,enabled:e.enabled,capabilities:e.capabilities}}function H(e){return[...e.installed,...e.available].map(a=>{const n=a.enabled?"[*]":a.installed?"[-]":"[ ]";const t=a.installed?a.enabled?"enabled":"disabled":"available";return`${n} ${a.pluginId} ${t}`}).join("\n")}function R(e){return H({installed:e.installed?[e]:[],available:e.installed?[]:[e]})}function T(e,a){const n=/^([^@]+?)(?:@(official|local))?$/.exec(e.trim());if(!n?.[1])throw new Error(`Invalid Plugin selector: ${e}`);const t=n[2];if(t&&a&&t!==a){throw new Error(`Plugin selector marketplace conflicts with --marketplace ${a}.`)}return{name:n[1],marketplace:t??a}}function J(e,a,n){const t=e.filter(r=>r.name===a&&(n===void 0||r.marketplace===n));if(t.length===0)throw new Error(`Plugin not found: ${a}${n?`@${n}`:""}`);if(t.length>1){throw new Error(`Plugin ${a} matches multiple marketplaces; use ${a}@official or ${a}@local.`)}return t[0]}async function U(e="unknown",a){const n=await g();const t=await w({dataDir:n,workspaceDir:process.cwd(),version:e,surface:"headless",...a?{lane:a}:{}});return{application:new d(t.adapter),access:t.adapter,dataDir:n,shutdown:async()=>{await A(t)}}}export{K as runAlranPluginCommand};
|
|
@@ -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 m}from"./chunk-D7MGU75P.js";import"./chunk-N5NTXCJI.js";import{a as c,b as u}from"./chunk-G5MOGPZ3.js";import"./chunk-GP52JZMY.js";import"./chunk-QPGTKSIQ.js";import"./chunk-BQ3CF3KE.js";import"./chunk-MPQ6G7LH.js";import{e as s}from"./chunk-LU4RPLJ3.js";import"./chunk-2TF6JAQM.js";import"./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"./chunk-IC6A323Q.js";import"./chunk-4CN3IJFH.js";import"./chunk-F46IELF5.js";import"./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 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 P(r){const t=r.createContext?await r.createContext(r.lane):await p(r.version,r.workspaceDir,r.lane);try{const{request:e}=r;if(e.action==="list"){return y(await t.application.snapshot(),Boolean(e.json))}if(e.action==="add"){const n=e.apiKeyEnv?.trim()||"ALRAN_PROVIDER_API_KEY";const a=(r.environment??process.env)[n]?.trim();if(!a){throw new Error(`Provider API key is missing. Set ${n} or pass --api-key-env <name>.`)}const o={name:e.name,baseUrl:e.baseUrl,apiKey:a,apiFormat:e.apiFormat,models:e.models.map(i=>({modelId:i,...e.supportImage?{capabilities:{support_image:true}}:{},...e.contextLimit!==void 0||e.outputLimit!==void 0?{limit:{...e.contextLimit!==void 0?{context:e.contextLimit}:{},...e.outputLimit!==void 0?{output:e.outputLimit}:{}}}:{}}))};if(e.saveAndUse){const i=e.models[0];if(!i)throw new Error("At least one --model <id> is required.");const d=await t.application.saveCandidate({...o,modelId:i,saveAndUse:true});if(!d.success){throw new Error(s(d.status?.lastErrorMessage??d.status?.state??"Connection unavailable",{summary:"Provider connection test failed. Nothing was saved or selected.",nextStep:"Check the URL, API key, and first model ID, then retry; omit --use to save without testing."}))}return`Provider added and selected: ${e.name}`}await t.application.create(o);return`Provider added: ${e.name}`}if(e.action==="remove"){if(!e.confirmed){throw new Error("Refusing to remove a provider without --yes.")}await t.application.remove(e.providerId);return`Provider removed: ${e.providerId}`}if(e.action==="test"){if(e.providerId==="alran_oauth"){const a="Alran OAuth sign-in and connectivity are managed by /login.";if(e.json){return JSON.stringify({success:false,status:{state:"unsupported",lastErrorMessage:a}},null,2)}return s(a,{summary:"Alran OAuth provider test skipped.",nextStep:"Run /login to manage Token Plan sign-in."})}const n=await t.application.test(e.providerId,e.modelId);if(e.json)return JSON.stringify(n,null,2);return n.success?`Provider available: ${e.providerId}${e.modelId?`/${e.modelId}`:""}`:s(n.status.lastErrorMessage??n.status.state,{summary:"Provider test failed.",nextStep:"Check the URL, API key, and model ID, then retry."})}if(e.action==="set-alran-key"){const n=e.apiKeyEnv?.trim()||"ALRAN_PROVIDER_API_KEY";const a=(r.environment??process.env)[n]?.trim();if(!a){throw new Error(`Alran API key is missing. Set ${n} or pass --api-key-env <name>.`)}await t.application.setAlranApiKey(a);return"Alran API Key saved and selected."}await t.application.setAlranSource(e.source);return e.source==="token_plan"?"Using Alran Token Plan.":"Using Alran API Key."}finally{await t.shutdown()}}async function p(r,t=process.cwd(),e){const n=await c({dataDir:await l(),workspaceDir:t,version:r,surface:"headless",...e?{lane:e}:{}});return{application:new m(n.adapter),shutdown:async()=>{await u(n)}}}function y(r,t){if(t)return JSON.stringify(r,null,2);const e=r.providers.map(n=>{const a=n.active?"active":n.enabled?"enabled":"disabled";const o=n.kind==="alran-oauth"?"managed login":n.hasApiKey?n.maskedApiKey??"key saved":"no key";return`${n.active?"*":" "} ${n.providerId} ${a} ${o}`});return e.join("\n")}export{P as runAlranProviderCommand};
|