@cortexkit/opencode-openai-auth 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +12 -60
  2. package/dist/bin.js +13 -0
  3. package/dist/index-2hch7e8n.js +8 -0
  4. package/dist/{index-766sfrh5.js → index-45qgkb0m.js} +1 -1
  5. package/dist/index-5dg931q0.js +65 -0
  6. package/dist/index-99esnzg0.js +157 -0
  7. package/dist/index-9reyazwh.js +2 -0
  8. package/dist/index-bgq9d21h.js +2 -0
  9. package/dist/index-dryydk6b.js +2 -0
  10. package/dist/index-egrty6tz.js +12 -0
  11. package/dist/index-envpbt0k.js +3 -0
  12. package/dist/index-jye6vccc.js +2 -0
  13. package/dist/index-k4eacw7x.js +2 -0
  14. package/dist/{index-hy9030jh.js → index-yeyp8t0k.js} +1 -1
  15. package/dist/index-yf6arn5w.js +2 -0
  16. package/dist/index.d.ts +2 -56
  17. package/dist/index.js +1 -1
  18. package/dist/map-CCbSZIhT.d.ts +56 -0
  19. package/dist/{pool-lifecycle-DbDmgabd.d.ts → pool-lifecycle-DqKq8Eej.d.ts} +104 -790
  20. package/dist/{port-file-Do3lQIEk.d.ts → port-file-CZ9MIdy2.d.ts} +1 -1
  21. package/dist/{protocol-BOBdkqqm.d.ts → protocol-CSIDDBDf.d.ts} +1 -1
  22. package/dist/rpc/port-file.d.ts +1 -1
  23. package/dist/rpc/port-file.js +1 -1
  24. package/dist/rpc/protocol.d.ts +1 -1
  25. package/dist/rpc/protocol.js +1 -1
  26. package/dist/rpc/rpc-client.d.ts +3 -3
  27. package/dist/rpc/rpc-client.js +1 -1
  28. package/dist/rpc/rpc-dir.js +1 -1
  29. package/dist/{sidebar-state-D6cUKgkm.d.ts → sidebar-state-BCxFpH68.d.ts} +5 -3
  30. package/dist/sidebar-state.d.ts +1 -1
  31. package/dist/sidebar-state.js +1 -1
  32. package/dist/token-util-gmn5yaqc.js +1 -0
  33. package/dist/{token-ypk61xj0.js → token-vykm9bxh.js} +1 -1
  34. package/dist/tui-preferences.d.ts +2 -1
  35. package/dist/tui-preferences.js +3 -3
  36. package/dist/tui.d.ts +2 -2
  37. package/dist/v2/server.d.ts +1 -1
  38. package/dist/v2/server.js +3 -4
  39. package/package.json +13 -8
  40. package/src/tui-compiled/raw/logger.js +10 -2
  41. package/src/tui-compiled/raw/shared/053cc17b5419261e-codec.js +2 -1
  42. package/src/tui-compiled/raw/shared/0766d78c6f481f18-watcher.js +26 -10
  43. package/src/tui-compiled/raw/shared/375d9cca2def037d-private-files.js +302 -0
  44. package/src/tui-compiled/raw/shared/39c3cb05738fcf6d-projection.js +3 -1
  45. package/src/tui-compiled/raw/shared/43fc9e6b994519c7-refresh-lock.js +5 -0
  46. package/src/tui-compiled/raw/shared/458b934e92490331-mutate.js +2 -2
  47. package/src/tui-compiled/raw/shared/4825e03209d6ae3e-with-lock.js +4 -0
  48. package/src/tui-compiled/raw/shared/4f36d333d081d040-merge.js +21 -5
  49. package/src/tui-compiled/raw/shared/7211cfec06a298bc-atomic-write.js +21 -0
  50. package/src/tui-compiled/raw/shared/905bffc0220f43d0-map.js +36 -1
  51. package/src/tui-compiled/raw/shared/a09b6a533c11858f-tui-preferences.js +6 -4
  52. package/src/tui-compiled/raw/shared/c14988621dc60a75-port-file.js +30 -8
  53. package/src/tui-compiled/raw/shared/c64d7afbc14ca125-sidebar-file.js +17 -8
  54. package/src/tui-compiled/raw/shared/c852a15cfe489d12-pool.js +3 -0
  55. package/src/tui-compiled/raw/shared/cd94316a888b0a8e-schema.js +3 -2
  56. package/src/tui-compiled/raw/shared/d5a8f1061ee2f114-index.js +1 -1
  57. package/src/tui-compiled/raw/shared/d7dcba96fea1685c-engine.js +126 -11
  58. package/src/tui-compiled/raw/shared/e8cd4929507508d8-refresh-file-lock.js +254 -37
  59. package/src/tui-compiled/raw/shared/ec971142548df90e-index.js +1 -0
  60. package/src/tui-compiled/raw/shared/fbcdcd0f925e74c0-rpc-client.js +15 -1
  61. package/src/tui-compiled/raw/sidebar-state.js +3 -3
  62. package/src/tui-compiled/runtime/logger.js +10 -2
  63. package/src/tui-compiled/runtime/shared/053cc17b5419261e-codec.js +2 -1
  64. package/src/tui-compiled/runtime/shared/0766d78c6f481f18-watcher.js +26 -10
  65. package/src/tui-compiled/runtime/shared/375d9cca2def037d-private-files.js +302 -0
  66. package/src/tui-compiled/runtime/shared/39c3cb05738fcf6d-projection.js +3 -1
  67. package/src/tui-compiled/runtime/shared/43fc9e6b994519c7-refresh-lock.js +5 -0
  68. package/src/tui-compiled/runtime/shared/458b934e92490331-mutate.js +2 -2
  69. package/src/tui-compiled/runtime/shared/4825e03209d6ae3e-with-lock.js +4 -0
  70. package/src/tui-compiled/runtime/shared/4f36d333d081d040-merge.js +21 -5
  71. package/src/tui-compiled/runtime/shared/7211cfec06a298bc-atomic-write.js +21 -0
  72. package/src/tui-compiled/runtime/shared/905bffc0220f43d0-map.js +36 -1
  73. package/src/tui-compiled/runtime/shared/a09b6a533c11858f-tui-preferences.js +6 -4
  74. package/src/tui-compiled/runtime/shared/c14988621dc60a75-port-file.js +30 -8
  75. package/src/tui-compiled/runtime/shared/c64d7afbc14ca125-sidebar-file.js +17 -8
  76. package/src/tui-compiled/runtime/shared/c852a15cfe489d12-pool.js +3 -0
  77. package/src/tui-compiled/runtime/shared/cd94316a888b0a8e-schema.js +3 -2
  78. package/src/tui-compiled/runtime/shared/d5a8f1061ee2f114-index.js +1 -1
  79. package/src/tui-compiled/runtime/shared/d7dcba96fea1685c-engine.js +126 -11
  80. package/src/tui-compiled/runtime/shared/e8cd4929507508d8-refresh-file-lock.js +254 -37
  81. package/src/tui-compiled/runtime/shared/ec971142548df90e-index.js +1 -0
  82. package/src/tui-compiled/runtime/shared/fbcdcd0f925e74c0-rpc-client.js +15 -1
  83. package/src/tui-compiled/runtime/sidebar-state.js +3 -3
  84. package/dist/index-8kj7sa1p.js +0 -12
  85. package/dist/index-b3q3j39x.js +0 -2
  86. package/dist/index-bmd7x5aq.js +0 -2
  87. package/dist/index-eqh53k8v.js +0 -2
  88. package/dist/index-jyr8y8k4.js +0 -7
  89. package/dist/index-m9d2bfkn.js +0 -222
  90. package/dist/index-rv08jmd4.js +0 -2
  91. package/dist/token-util-wdza526f.js +0 -1
@@ -1,2 +0,0 @@
1
- import{$b as h,Zb as D,_b as _}from"./index-8kj7sa1p.js";import{pc as R}from"./index-766sfrh5.js";class T extends Error{operation;constructor(f){super(`a ${f} on a strict notification scope needs a session id`);this.name="RpcSessionRequiredError",this.operation=f}}function F(f){return typeof f==="string"&&f.length>0}var S=new Map;function W(f){let x=JSON.stringify([f.rpcRoot,f.directoryPrefix,f.registrationSessionId,...f.requireSession===!0?["strict"]:[]]),z=S.get(x);if(!z)z={queue:[],nextId:1,lastDrainAtBySession:new Map,lastDrainAtAny:0},S.set(x,z);return z}var U=100,k=3000;function c(f,x,z){if(f.requireSession===!0&&!F(z))throw new T("push");let H=W(f);if(H.queue.push({id:H.nextId++,type:"open-dialog",payload:x,sessionId:z}),H.queue.length>U)H.queue=H.queue.slice(-U)}function d(f,x=0,z){if(f.requireSession===!0&&!F(z))throw new T("drain");let H=W(f),Y=Date.now();if(H.lastDrainAtAny=Y,z!==void 0)H.lastDrainAtBySession.set(z,Y);let Z=f.sessionlessDrain==="broadcast-only",V=(B)=>z===void 0?!Z||B.sessionId===void 0:B.sessionId===void 0||B.sessionId===z;if(x>0)H.queue=H.queue.filter((B)=>{if(B.id>x)return!0;if(z===void 0)return!Z||B.sessionId!==void 0;return B.sessionId!==z});return H.queue.filter((B)=>B.id>x&&V(B))}function i(f,x){let z=Date.now(),H=W(f),Y=x!==void 0?H.lastDrainAtBySession.get(x)??0:f.sessionlessDrain==="broadcast-only"?H.lastDrainAtAny:0;return Y>0&&z-Y<k}import{randomBytes as w,timingSafeEqual as j}from"node:crypto";import{readFile as t,unlink as q}from"node:fs/promises";import{createServer as v}from"node:http";import{join as u}from"node:path";class N extends Error{status;constructor(f,x){if(!Number.isInteger(f)||f<400||f>499)throw RangeError(`RpcRequestError status must be 4xx, got ${f}`);super(x);this.name="RpcRequestError",this.status=f}}var E=1e6;class g extends Error{declaredOversize;constructor(f){super("body too large");this.declaredOversize=f}}function I(f){return new Promise((x,z)=>{let H=(B=!1)=>{f.removeAllListeners("data"),f.on("data",()=>{}),f.resume(),z(new g(B))},Y=Number(f.headers["content-length"]);if(Number.isFinite(Y)&&Y>E){H(!0);return}let Z=[],V=0;f.on("data",(B)=>{if(V+=B.length,V>E){H();return}Z.push(B)}),f.on("end",()=>x(Buffer.concat(Z).toString("utf8"))),f.on("error",z)})}class m extends Error{}async function l(f,x){let z,H=new Promise((Y,Z)=>{z=setTimeout(()=>Z(new m("apply deadline exceeded")),x),z.unref?.()});f.catch(()=>{});try{return await Promise.race([f,H])}finally{clearTimeout(z)}}function p(f,x){if(!f?.startsWith("Bearer "))return!1;let z=Buffer.from(f.slice(7)),H=Buffer.from(x);return z.length===H.length&&j(z,H)}async function xf(f){if(typeof f.drain==="function"===(typeof f.drainAsync==="function"))throw TypeError("exactly one of drain or drainAsync must be provided");let x=f.log??{warn(){},debug(){}},z=w(32).toString("hex"),H=f.timeoutMs??90000,Y=f.receiptTimeoutMs??2000,Z=!1,V=new Set,B=v((G,K)=>{G.setTimeout(H,()=>{G.socket.destroy()}),M(G,K)});B.on("connection",(G)=>{V.add(G),G.once("close",()=>V.delete(G))}),B.requestTimeout=Y,B.headersTimeout=Y;async function M(G,K){let J=(X,Q,C={})=>{if(K.headersSent||K.writableEnded||K.destroyed)return;K.writeHead(X,{"content-type":"application/json",...C}),K.end(JSON.stringify(Q))};try{let X=new URL(G.url??"/","http://127.0.0.1").pathname;if(G.method==="GET"&&X==="/health")return J(200,{ok:!0});if(G.method!=="POST"||!X.startsWith("/rpc/"))return J(404,{error:"not found"});if(!p(G.headers.authorization,z))return J(401,{error:"unauthorized"});let Q=X.slice(5),C;try{C=await I(G)}catch($){if(!($ instanceof g))throw $;if($.declaredOversize){let y=G.socket;K.once("finish",()=>{y.end();let A=setTimeout(()=>y.destroy(),2000);if(A.unref(),G.once("end",()=>y.destroy()),y.once("close",()=>clearTimeout(A)),G.complete)y.destroy()})}return J(413,{error:"body too large"},{connection:"close"})}let b;try{b=JSON.parse(C||"{}")}catch{return J(400,{error:"invalid json"})}if(Q==="pending-notifications"){let $;try{if(f.parsePending)$=f.parsePending(b);else{if(!b||typeof b!=="object"||Array.isArray(b))throw Error("invalid params");let L=b;if(f.requireSession===!0&&!F(L.sessionId))return J(400,{error:"session required"});if("lastReceivedId"in L&&(typeof L.lastReceivedId!=="number"||!Number.isSafeInteger(L.lastReceivedId)||L.lastReceivedId<0)||"sessionId"in L&&typeof L.sessionId!=="string")throw Error("invalid params");$={lastReceivedId:Number(L.lastReceivedId??0),sessionId:typeof L.sessionId==="string"?L.sessionId:void 0}}}catch(L){if(L instanceof N)throw L;return J(400,{error:"invalid params"})}let{lastReceivedId:y,sessionId:A}=$;if(f.requireSession===!0&&!F(A))return J(400,{error:"session required"});if(A===void 0&&!Z)Z=!0,x.warn("rpc notification drain missing session id",{pid:process.pid});let O;if(f.drainAsync)try{O=await f.drainAsync(y,A)}catch(L){return x.warn("rpc notification drain failed",{pid:process.pid,error:L instanceof Error?L.message:String(L)}),J(500,{error:"drain failed"})}else O=f.drain?.(y,A);return J(200,{messages:O})}if(Q==="apply"){let $=Promise.resolve(f.apply(b)),y=f.applyDeadlineMs===void 0?await $:await l($,f.applyDeadlineMs);return J(200,y)}return J(404,{error:"unknown method"})}catch(X){if(X instanceof N)return x.debug("rpc request refused",{pid:process.pid,status:X.status}),J(X.status,{error:X.message});if(X instanceof m)return x.warn("rpc apply deadline exceeded",{pid:process.pid,deadlineMs:f.applyDeadlineMs}),J(504,{error:"handler deadline exceeded"});x.warn("rpc request failed",{pid:process.pid,error:X instanceof Error?X.message:String(X)}),J(500,{error:"internal error"})}}let P=await new Promise((G,K)=>{B.on("error",K),B.listen(0,"127.0.0.1",()=>{let J=B.address();if(J&&typeof J==="object")G(J.port);else K(Error("no port"))})});if(B.unref(),f.sweepRoot)try{await h(f.sweepRoot,f.dir,f.isManagedDir,x)}catch(G){x.warn("rpc state sweep failed",{pid:process.pid,error:G instanceof Error?G.message:String(G)})}try{await _(f.dir,{port:P,token:z,pid:process.pid},{secureDir:f.secureDir}),x.debug("rpc server pid",{pid:process.pid,rpcPort:P})}catch(G){throw await new Promise((K)=>B.close(()=>K())),G}return{port:P,token:z,async stop(){await new Promise((J)=>{B.closeAllConnections?.(),B.close(()=>J());for(let X of V)X.destroy()});let G=u(f.dir,`port-${process.pid}.json`),K=await t(G,"utf8").then((J)=>JSON.parse(J)).catch(()=>{return});if(K?.port===P&&K.token===z)await q(G).catch(()=>{})}}}async function Bf(f,x,z){let H=globalThis,Y=Symbol.for(f),Z=H[Y]??{servers:new Map,pending:new Map};H[Y]=Z;let{servers:V,pending:B}=Z,M=B.get(x)??Promise.resolve(),P,G=M.catch(()=>{}).then(async()=>{let J=V.get(x);if(J){if(await J.stop(),V.get(x)===J)V.delete(x)}P=await z(),V.set(x,P)});B.set(x,G);try{await G}finally{if(B.get(x)===G)B.delete(x)}let K=P;if(!K)throw Error("RPC server failed to start");return{server:K,release:async()=>{if(V.get(x)!==K)return;if(await K.stop(),V.get(x)===K)V.delete(x)}}}var yf=D(R);
2
- export{c as Tb,d as Ub,i as Vb,xf as Wb,Bf as Xb,yf as Yb};
@@ -1 +0,0 @@
1
- import{b as a}from"./index-hy9030jh.js";import"./index-b3q3j39x.js";export default a();