@cortexkit/opencode-openai-auth 1.17.0 → 1.18.0

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 (61) hide show
  1. package/dist/bin.js +8 -8
  2. package/dist/{codex-request-DYqSE0ti.d.ts → codex-request-CTIOw2EZ.d.ts} +322 -322
  3. package/dist/index-177kc3f1.js +64 -0
  4. package/dist/{index-k2f9vrcr.js → index-1r7zznds.js} +1 -1
  5. package/dist/{index-0mhdyzax.js → index-2ecf254a.js} +21 -21
  6. package/dist/index-5czcaan0.js +101 -0
  7. package/dist/index-5vh4jgb7.js +12 -0
  8. package/dist/index-96p0myg1.js +2 -0
  9. package/dist/{index-1m3vv9rh.js → index-9sh2xnwr.js} +2 -2
  10. package/dist/{index-d7bsrp0m.js → index-h7xxfm12.js} +1 -1
  11. package/dist/{index-vmcmpezd.js → index-hrv1msdb.js} +1 -1
  12. package/dist/index-m6sq5g7q.js +8 -0
  13. package/dist/{index-99c2fepe.js → index-nkgxq9a6.js} +1 -1
  14. package/dist/{index-fxqghceg.js → index-raj3tyyz.js} +1 -1
  15. package/dist/{index-6ts9w66n.js → index-rs8z3per.js} +1 -1
  16. package/dist/index-smekt6zv.js +2 -0
  17. package/dist/index.d.ts +24 -24
  18. package/dist/index.js +1 -1
  19. package/dist/rpc/port-file.js +1 -1
  20. package/dist/rpc/protocol.js +1 -1
  21. package/dist/rpc/rpc-client.js +1 -1
  22. package/dist/rpc/rpc-dir.js +1 -1
  23. package/dist/sidebar-state.js +1 -1
  24. package/dist/{token-r3vbz9pw.js → token-kdjmv82a.js} +1 -1
  25. package/dist/token-util-71r7z2vr.js +1 -0
  26. package/dist/tui-preferences.js +1 -1
  27. package/dist/tui.d.ts +1 -1
  28. package/dist/v2/server.d.ts +1 -1
  29. package/dist/v2/server.js +3 -2
  30. package/package.json +2 -2
  31. package/src/tui-compiled/raw/shared/0766d78c6f481f18-watcher.js +9 -2
  32. package/src/tui-compiled/raw/shared/0f77ebc3c914c9c6-custody.js +1 -1
  33. package/src/tui-compiled/raw/shared/375d9cca2def037d-private-files.js +3 -1
  34. package/src/tui-compiled/raw/shared/44449e891fab9fbc-edit.js +48 -2
  35. package/src/tui-compiled/raw/shared/54eba94fd64c8c3c-index.js +1 -1
  36. package/src/tui-compiled/raw/shared/5f4bc45522ab9bc6-update.js +19 -18
  37. package/src/tui-compiled/raw/shared/6948d70969aa7a55-fs.js +1 -0
  38. package/src/tui-compiled/raw/shared/836fc615de6afbd9-settings.js +14 -4
  39. package/src/tui-compiled/raw/shared/94f53cfd572ba4bb-availability.js +1 -1
  40. package/src/tui-compiled/raw/shared/c14988621dc60a75-port-file.js +55 -49
  41. package/src/tui-compiled/raw/shared/cf4c37f3975c3a8d-canonical-file-path.js +57 -0
  42. package/src/tui-compiled/raw/shared/ec971142548df90e-index.js +3 -0
  43. package/src/tui-compiled/runtime/shared/0766d78c6f481f18-watcher.js +9 -2
  44. package/src/tui-compiled/runtime/shared/0f77ebc3c914c9c6-custody.js +1 -1
  45. package/src/tui-compiled/runtime/shared/375d9cca2def037d-private-files.js +3 -1
  46. package/src/tui-compiled/runtime/shared/44449e891fab9fbc-edit.js +48 -2
  47. package/src/tui-compiled/runtime/shared/54eba94fd64c8c3c-index.js +1 -1
  48. package/src/tui-compiled/runtime/shared/5f4bc45522ab9bc6-update.js +19 -18
  49. package/src/tui-compiled/runtime/shared/6948d70969aa7a55-fs.js +1 -0
  50. package/src/tui-compiled/runtime/shared/836fc615de6afbd9-settings.js +14 -4
  51. package/src/tui-compiled/runtime/shared/94f53cfd572ba4bb-availability.js +1 -1
  52. package/src/tui-compiled/runtime/shared/c14988621dc60a75-port-file.js +55 -49
  53. package/src/tui-compiled/runtime/shared/cf4c37f3975c3a8d-canonical-file-path.js +57 -0
  54. package/src/tui-compiled/runtime/shared/ec971142548df90e-index.js +3 -0
  55. package/dist/index-3dv16qvb.js +0 -101
  56. package/dist/index-dqxk628t.js +0 -12
  57. package/dist/index-rm4zt5dv.js +0 -64
  58. package/dist/index-v9p38mg5.js +0 -2
  59. package/dist/index-xx2z6bs3.js +0 -2
  60. package/dist/index-ydtpn6ma.js +0 -8
  61. package/dist/token-util-vks3kgse.js +0 -1
@@ -1,12 +0,0 @@
1
- import{Kg as U,Lg as E,Pg as F,Qg as p,Rg as L,Vg as c}from"./index-xx2z6bs3.js";import{createHash as Cz,randomUUID as y}from"node:crypto";import{chmod as zz,mkdir as Gz,open as Jz,readdir as b,rename as Kz,rmdir as Nz,stat as S,unlink as T}from"node:fs/promises";import{uptime as Qz}from"node:os";import{join as R,resolve as g}from"node:path";function x(z){return(z.now??Date.now)()-(z.uptime??Qz)()*1000-300000}function k(z,G,Q){let V=z.startedAt===void 0?G?.mtimeMs:z.startedAt;return typeof V==="number"&&Number.isFinite(V)&&V<Q}async function Vz(z,G,Q,V){if(!Q)return;await V?.(z);try{let J=await L(z),K=await S(z);if(J===G&&K.dev===Q.dev&&K.ino===Q.ino&&K.mtimeMs===Q.mtimeMs&&K.size===Q.size)await T(z).catch(()=>{})}catch(J){if(J instanceof E&&J.code!=="ENOENT")throw J}}function a(z){return typeof z==="number"&&Number.isSafeInteger(z)&&z>0}function u(z){if(!a(z))return!1;try{return process.kill(z,0),!0}catch(G){return G.code==="EPERM"}}function Uz(z){return(G)=>Wz(G,z)}function Wz(z,G){if(/^[0-9a-f]{16}$/.test(z))return!0;return z.startsWith(G)&&/^[0-9a-f]{16}$/.test(z.slice(G.length))}function Xz(z){let G=/^port-(\d+)\.json$/.exec(z);return G?Number(G[1]):void 0}function s(z,G){if(z===null||typeof z!=="object"||Array.isArray(z))return!1;let{pid:Q,port:V,token:J}=z;return a(Q)&&Xz(G)===Q&&typeof V==="number"&&Number.isInteger(V)&&V>=1&&V<=65535&&typeof J==="string"&&J.length>0}async function l(z,G){G?.debug("rpc corrupt port file",{pid:process.pid,portFile:z}),await T(z).catch(()=>{})}async function Ez(z,G,Q={}){let V=async()=>{let J=R(z,`port-${G.pid}.json`);if(U)return await p(z,Q.secureDir??!1),await Q.beforeWrite?.(),await c(J,JSON.stringify({...G,startedAt:Date.now()}),{stagePath:`${J}.${(Q.stageName??y)()}.tmp`}),J;if(await Gz(z,{recursive:!0,mode:Q.secureDir?448:void 0}),Q.secureDir)await zz(z,448);await Q.beforeWrite?.();let K={...G,startedAt:Date.now()},Y=`${J}.${(Q.stageName??y)()}.tmp`,W,N=!1;try{W=await Jz(Y,"wx",384),N=!0,await W.writeFile(JSON.stringify(K),"utf8"),await W.chmod(384),await W.close(),W=void 0,await Kz(Y,J),N=!1}finally{if(await W?.close().catch(()=>{}),N)await T(Y).catch(()=>{})}return J};try{return await V()}catch(J){if(J.code==="ENOENT")return await V();throw J}}async function Lz(z,G,Q,V,J={}){let K=x(J),Y;try{Y=await b(z,{withFileTypes:!0})}catch(N){if(N.code==="ENOENT")return;throw N}let W=g(G);for(let N of Y){if(!N.isDirectory()||!Q(N.name))continue;let X=R(z,N.name),Z;try{Z=await b(X)}catch($){if($.code==="ENOENT")continue;throw $}for(let $ of Z){if(!$.startsWith("port-")||!$.endsWith(".json"))continue;let H=R(X,$),C=await S(H).catch(()=>{return}),q;try{q=await L(H)}catch(O){if(O instanceof E&&O.code!=="ENOENT")throw O;continue}if(q===void 0)continue;let A;try{A=JSON.parse(q)}catch{await l(H,V);continue}if(!s(A,$)){await l(H,V);continue}let I=A;if(!u(I.pid))await T(H).catch(()=>{});else if(k(I,C,K))await Vz(H,q,C,J.beforeRemove)}if(g(X)!==W)await Nz(X).catch(()=>{})}}async function d(z,G,Q={}){let V=x(Q);if(!u(G.pid))return null;let J=R(g(z),`port-${G.pid}.json`);try{if(U)await F(J,"file");let K=await S(J);if(k(G,K,V))return null;return`${J}:${K.dev}:${K.ino}:${K.mtimeMs}:${K.size}`}catch(K){if(K instanceof E&&K.code!=="ENOENT")throw K;return null}}async function n(z,G,Q={}){let V=x(Q),J;try{if(U)await F(z,"directory");J=await b(z)}catch(X){if(X instanceof E&&X.code!=="ENOENT")throw X;return null}let K=[];for(let X of J){if(!X.startsWith("port-")||!X.endsWith(".json"))continue;try{let Z=JSON.parse(await L(R(z,X)));if(s(Z,X))if(u(Z.pid)){let $=Z.startedAt===void 0?await S(R(z,X)).catch(()=>{return}):void 0;if(!k(Z,$,V))K.push(Z)}else await T(R(z,X)).catch(()=>{})}catch(Z){if(Z instanceof E&&Z.code!=="ENOENT")throw Z}}if(K.length===0)return null;let Y=G!==void 0&&G>=1?K.filter((X)=>X.pid===G):[];if(Q.exactPid===!0&&Y.length===0)return null;let W=Y.length>0?Y:K,N=(X)=>typeof X.startedAt==="number"&&Number.isFinite(X.startedAt)?X.startedAt:-1/0;return W.sort((X,Z)=>N(Z)-N(X))[0]??null}import{open as Yz}from"node:fs/promises";import{connect as Zz}from"node:net";import{join as $z,resolve as t}from"node:path";var e=2000,_=new Map,B=new Map;async function Hz(z,G){let Q=$z(t(z),`port-${G.pid}.json`);if(U){let J=JSON.parse(await L(Q));if(J.pid!==G.pid||J.port!==G.port||J.token!==G.token)return null;return null}let V;try{V=await Yz(Q,"r");let J=await V.stat(),K=JSON.parse(await V.readFile("utf8"));if(K.pid!==G.pid||K.port!==G.port||K.token!==G.token)return null;return`${Q}:${J.dev}:${J.ino}:${J.mtimeMs}:${J.size}`}catch{return null}finally{await V?.close().catch(()=>{})}}async function i(z,G,Q,V){let J=_.get(z);if(!U&&J&&await d(G,J.entry)===J.identity)return J;_.delete(z);let K=B.get(z);if(K)return K;let Y=(async()=>{let W=await(V.discover??n)(G,Q,V);if(!W)return null;let N=await Hz(G,W);if(!N)return{entry:W,identity:""};let X={entry:W,identity:N};return _.set(z,X),X})();B.set(z,Y);try{return await Y}finally{if(B.get(z)===Y)B.delete(z)}}async function o(z,G,Q,V=e){return new Promise((J)=>{let K,Y=!1,W=!1,N=(Z,$=!1)=>{if(Y)return;Y=!0,clearTimeout(X),K?.destroy(),J({value:Z,stale:$})},X=setTimeout(()=>N(null),V);try{let Z=JSON.stringify(Q);K=Zz({host:"127.0.0.1",port:z.port}),K.on("connect",()=>{W=!0,K?.write(`POST /rpc/${G} HTTP/1.0\r
2
- Host: 127.0.0.1:${z.port}\r
3
- Connection: close\r
4
- Content-Type: application/json\r
5
- Content-Length: ${Buffer.byteLength(Z)}\r
6
- Authorization: Bearer ${z.token}\r
7
- \r
8
- `+Z)});let $=[],H=0,C,q,A=Buffer.alloc(0),I=()=>{if(C===void 0)return N(null);try{let O=Buffer.concat($).subarray(C);N(JSON.parse(O.toString("utf8")))}catch{N(null)}};K.on("data",(O)=>{if(Y)return;if(H+=O.length,$.push(O),C===void 0){A=Buffer.concat([A,O]);let D=A.indexOf(`\r
9
- \r
10
- `);if(D>=0)C=D+4;if((C??A.length)>16384)return N(null);if(C!==void 0){let P=A.subarray(0,D).toString("latin1").split(`\r
11
- `),f=/^HTTP\/1\.[01] (\d{3})(?: |$)/.exec(P[0]??"");if(!f)return N(null);let j=Number(f[1]);if(j<200||j>=300)return N(null,[401,403,404,410].includes(j));for(let w of P.slice(1)){let v=w.indexOf(":"),h=w.slice(0,v).toLowerCase(),m=w.slice(v+1).trim();if(h==="transfer-encoding")return N(null);if(h==="content-length"){if(q!==void 0||!/^\d+$/.test(m))return N(null);if(q=Number(m),!Number.isSafeInteger(q)||q>8388608)return N(null)}}A=Buffer.alloc(0)}}let M=H-(C??H);if(M>8388608)return N(null);if(q!==void 0){if(M>q)return N(null);if(M===q)I()}}),K.on("end",()=>{if(q!==void 0&&H-(C??0)!==q)return N(null);I()}),K.on("error",()=>N(null,!W)),K.on("close",()=>N(null))}catch{N(null,!W)}})}async function r(z,G,Q,V,J,K,Y=e){let W=JSON.stringify([t(z),G??null,Q.exactPid===!0]),N=await i(W,z,G,Q);if(V(N?.entry??null),!N)return null;let X=Date.now()+Y,Z=await o(N.entry,J,K,Y);if(!Z.stale)return Z.value;if(_.get(W)===N)_.delete(W);let $=await i(W,z,G,Q);if(!$||Date.now()>=X)return null;if($.entry.port===N.entry.port&&$.entry.pid===N.entry.pid&&$.entry.token===N.entry.token){if(_.get(W)===$)_.delete(W);return null}let H=await o($.entry,J,K,X-Date.now());if(H.stale&&_.get(W)===$)_.delete(W);return H.value}function jz(z,G,Q,V={}){let J={exactPid:V.exactPid,discover:V.discover},K=!1,Y=(W)=>{if(K)return;Q?.(W),K=!0};return{async pending(W,N,X){return(await r(z,G,J,Y,"pending-notifications",{lastReceivedId:W,sessionId:N},X))?.messages??[]},async apply(W,N){return await r(z,G,J,Y,"apply",{...W},N)??{text:"apply failed",knobs:{}}}}}
12
- export{Uz as qg,Ez as rg,Lz as sg,n as tg,e as ug,jz as vg};