@cortexkit/opencode-openai-auth 1.14.1 → 1.15.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.
- package/dist/bin.js +9 -9
- package/dist/{codex-request-Cl6zEfsR.d.ts → codex-request-DYqSE0ti.d.ts} +373 -2
- package/dist/{index-wma2ggn9.js → index-14x5shtc.js} +2 -2
- package/dist/index-1wcg7g9d.js +2 -0
- package/dist/index-50p400eg.js +8 -0
- package/dist/index-98q3mydm.js +64 -0
- package/dist/{index-yygzbxjk.js → index-bhkycxbm.js} +1 -1
- package/dist/{index-k5av4j8p.js → index-dzpjz8hv.js} +2 -2
- package/dist/{index-cxnrd85v.js → index-f7kmsdfk.js} +1 -1
- package/dist/{index-z9cj13z7.js → index-hnfqppx9.js} +1 -1
- package/dist/{index-2f330s35.js → index-m8m7rakq.js} +2 -2
- package/dist/index-mjsmvmt4.js +76 -0
- package/dist/{index-gkye2xh1.js → index-s8ghhc9z.js} +2 -2
- package/dist/{index-94b345dw.js → index-t65axpta.js} +1 -1
- package/dist/index-xjtbg7sx.js +101 -0
- package/dist/index.d.ts +1 -372
- package/dist/index.js +1 -1
- package/dist/openai-auth.schema.json +400 -0
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.js +1 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/sidebar-state.js +1 -1
- package/dist/{token-sgwxn4xg.js → token-j34j1zhm.js} +1 -1
- package/dist/token-util-bf619nmg.js +1 -0
- package/dist/tui-preferences.js +3 -3
- package/dist/v2/server.d.ts +1 -1
- package/dist/v2/server.js +2 -2
- package/package.json +3 -3
- package/src/tui-compiled/raw/logger.js +8 -1
- package/src/tui-compiled/raw/shared/061e741c052de9c1-paths.js +48 -0
- package/src/tui-compiled/raw/shared/0766d78c6f481f18-watcher.js +41 -18
- package/src/tui-compiled/raw/shared/23300c068d0b2ffc-parse.js +65 -0
- package/src/tui-compiled/raw/shared/3000be4f79f20eb6-write.js +88 -0
- package/src/tui-compiled/raw/shared/44449e891fab9fbc-edit.js +229 -0
- package/src/tui-compiled/raw/shared/4825e03209d6ae3e-with-lock.js +1 -1
- package/src/tui-compiled/raw/shared/5803fadb30af0ec0-descriptors.js +81 -0
- package/src/tui-compiled/raw/shared/58bc35a3cd459085-define.js +52 -0
- package/src/tui-compiled/raw/shared/5f4bc45522ab9bc6-update.js +139 -0
- package/src/tui-compiled/raw/shared/6948d70969aa7a55-fs.js +19 -0
- package/src/tui-compiled/raw/shared/754d6017f8e419cf-builtins.js +28 -12
- package/src/tui-compiled/raw/shared/81758f9fe7c2a576-handle.js +228 -0
- package/src/tui-compiled/raw/shared/87f6e22d4fc34918-resolve.js +51 -0
- package/src/tui-compiled/raw/shared/8a18abe4fa2977c8-menu.js +1 -0
- package/src/tui-compiled/raw/shared/8ab1f5794e677151-move.js +351 -0
- package/src/tui-compiled/raw/shared/92e38944b51b2405-file-read-cache.js +9 -5
- package/src/tui-compiled/raw/shared/9865a4fa45882c6f-settings-decisions.js +13 -0
- package/src/tui-compiled/raw/shared/cc0f2d1963547799-index.js +7 -0
- package/src/tui-compiled/raw/shared/dbc61cd405941828-accounts.js +48 -5
- package/src/tui-compiled/raw/shared/e0ed4a490e4eaa4f-schema.js +81 -0
- package/src/tui-compiled/raw/shared/e8cd4929507508d8-refresh-file-lock.js +146 -2
- package/src/tui-compiled/raw/shared/eac0bed49f3d4110-lock-errors.js +15 -0
- package/src/tui-compiled/raw/shared/facfd8afc431d68a-refusal.js +15 -0
- package/src/tui-compiled/raw/shared/fc7db0c5aa764565-settings-install.js +85 -0
- package/src/tui-compiled/raw/shared/fcd26e77bc538838-snapshot.js +150 -0
- package/src/tui-compiled/runtime/logger.js +8 -1
- package/src/tui-compiled/runtime/shared/061e741c052de9c1-paths.js +48 -0
- package/src/tui-compiled/runtime/shared/0766d78c6f481f18-watcher.js +41 -18
- package/src/tui-compiled/runtime/shared/23300c068d0b2ffc-parse.js +65 -0
- package/src/tui-compiled/runtime/shared/3000be4f79f20eb6-write.js +88 -0
- package/src/tui-compiled/runtime/shared/44449e891fab9fbc-edit.js +229 -0
- package/src/tui-compiled/runtime/shared/4825e03209d6ae3e-with-lock.js +1 -1
- package/src/tui-compiled/runtime/shared/5803fadb30af0ec0-descriptors.js +81 -0
- package/src/tui-compiled/runtime/shared/58bc35a3cd459085-define.js +52 -0
- package/src/tui-compiled/runtime/shared/5f4bc45522ab9bc6-update.js +139 -0
- package/src/tui-compiled/runtime/shared/6948d70969aa7a55-fs.js +19 -0
- package/src/tui-compiled/runtime/shared/754d6017f8e419cf-builtins.js +28 -12
- package/src/tui-compiled/runtime/shared/81758f9fe7c2a576-handle.js +228 -0
- package/src/tui-compiled/runtime/shared/87f6e22d4fc34918-resolve.js +51 -0
- package/src/tui-compiled/runtime/shared/8a18abe4fa2977c8-menu.js +1 -0
- package/src/tui-compiled/runtime/shared/8ab1f5794e677151-move.js +351 -0
- package/src/tui-compiled/runtime/shared/92e38944b51b2405-file-read-cache.js +9 -5
- package/src/tui-compiled/runtime/shared/9865a4fa45882c6f-settings-decisions.js +13 -0
- package/src/tui-compiled/runtime/shared/cc0f2d1963547799-index.js +7 -0
- package/src/tui-compiled/runtime/shared/dbc61cd405941828-accounts.js +48 -5
- package/src/tui-compiled/runtime/shared/e0ed4a490e4eaa4f-schema.js +81 -0
- package/src/tui-compiled/runtime/shared/e8cd4929507508d8-refresh-file-lock.js +146 -2
- package/src/tui-compiled/runtime/shared/eac0bed49f3d4110-lock-errors.js +15 -0
- package/src/tui-compiled/runtime/shared/facfd8afc431d68a-refusal.js +15 -0
- package/src/tui-compiled/runtime/shared/fc7db0c5aa764565-settings-install.js +85 -0
- package/src/tui-compiled/runtime/shared/fcd26e77bc538838-snapshot.js +150 -0
- package/dist/index-3mbw88h7.js +0 -91
- package/dist/index-999nwa9p.js +0 -76
- package/dist/index-pc4vrrex.js +0 -2
- package/dist/index-snq7bwr6.js +0 -8
- package/dist/index-xk7f1aef.js +0 -64
- package/dist/token-util-8mrnmkge.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{i as
|
|
1
|
+
import{ng as w,og as O,pg as k}from"./index-14x5shtc.js";import{Hg as h,Ng as D}from"./index-m8m7rakq.js";import{Tg as j}from"./index-t65axpta.js";class g extends Error{operation;constructor(f){super(`a ${f} on a strict notification scope needs a session id`);this.name="RpcSessionRequiredError",this.operation=f}}function M(f){return typeof f==="string"&&f.length>0}var U=new Map;function y(f){let x=JSON.stringify([f.rpcRoot,f.directoryPrefix,f.registrationSessionId,...f.requireSession===!0?["strict"]:[]]),z=U.get(x);if(!z)z={queue:[],nextId:1,lastDrainAtBySession:new Map,lastDrainAtAny:0},U.set(x,z);return z}var m=100,t=3000;function i(f,x,z){if(f.requireSession===!0&&!M(z))throw new g("push");let H=y(f);if(H.queue.push({id:H.nextId++,type:"open-dialog",payload:x,sessionId:z}),H.queue.length>m)H.queue=H.queue.slice(-m)}function n(f,x=0,z){if(f.requireSession===!0&&!M(z))throw new g("drain");let H=y(f),Y=Date.now();if(H.lastDrainAtAny=Y,z!==void 0)H.lastDrainAtBySession.set(z,Y);let Z=f.sessionlessDrain==="broadcast-only",L=(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&&L(B))}function a(f,x){let z=Date.now(),H=y(f),Y=x!==void 0?H.lastDrainAtBySession.get(x)??0:f.sessionlessDrain==="broadcast-only"?H.lastDrainAtAny:0;return Y>0&&z-Y<t}import{randomBytes as v,timingSafeEqual as q}from"node:crypto";import{unlink as u}from"node:fs/promises";import{createServer as I}from"node:http";import{join as l}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 _ extends Error{declaredOversize;constructor(f){super("body too large");this.declaredOversize=f}}function p(f){return new Promise((x,z)=>{let H=(B=!1)=>{f.removeAllListeners("data"),f.on("data",()=>{}),f.resume(),z(new _(B))},Y=Number(f.headers["content-length"]);if(Number.isFinite(Y)&&Y>E){H(!0);return}let Z=[],L=0;f.on("data",(B)=>{if(L+=B.length,L>E){H();return}Z.push(B)}),f.on("end",()=>x(Buffer.concat(Z).toString("utf8"))),f.on("error",z)})}class S extends Error{}async function c(f,x){let z,H=new Promise((Y,Z)=>{z=setTimeout(()=>Z(new S("apply deadline exceeded")),x),z.unref?.()});f.catch(()=>{});try{return await Promise.race([f,H])}finally{clearTimeout(z)}}function d(f,x){if(!f?.startsWith("Bearer "))return!1;let z=Buffer.from(f.slice(7)),H=Buffer.from(x);return z.length===H.length&&q(z,H)}async function Bf(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=v(32).toString("hex"),H=f.timeoutMs??90000,Y=f.receiptTimeoutMs??2000,Z=!1,L=new Set,B=I((V,J)=>{V.setTimeout(H,()=>{V.socket.destroy()}),T(V,J)});B.on("connection",(V)=>{L.add(V),V.once("close",()=>L.delete(V))}),B.requestTimeout=Y,B.headersTimeout=Y;async function T(V,J){let G=(X,b,C={})=>{if(J.headersSent||J.writableEnded||J.destroyed)return;J.writeHead(X,{"content-type":"application/json",...C}),J.end(JSON.stringify(b))};try{let X=new URL(V.url??"/","http://127.0.0.1").pathname;if(V.method==="GET"&&X==="/health")return G(200,{ok:!0});if(V.method!=="POST"||!X.startsWith("/rpc/"))return G(404,{error:"not found"});if(!d(V.headers.authorization,z))return G(401,{error:"unauthorized"});let b=X.slice(5),C;try{C=await p(V)}catch($){if(!($ instanceof _))throw $;let P=V.socket;if(J.once("finish",()=>{P.end();let A=setTimeout(()=>P.destroy(),2000);if(A.unref(),V.once("end",()=>P.destroy()),P.once("close",()=>clearTimeout(A)),V.complete)P.destroy()}),!$.declaredOversize&&!V.complete){if(J.headersSent||J.writableEnded||J.destroyed)return;let A=JSON.stringify({error:"body too large"});J.writeHead(413,{"content-type":"application/json","content-length":Buffer.byteLength(A),connection:"close"}),J.write(A),V.once("end",()=>J.end());return}return G(413,{error:"body too large"},{connection:"close"})}let F;try{F=JSON.parse(C||"{}")}catch{return G(400,{error:"invalid json"})}if(b==="pending-notifications"){let $;try{if(f.parsePending)$=f.parsePending(F);else{if(!F||typeof F!=="object"||Array.isArray(F))throw Error("invalid params");let K=F;if(f.requireSession===!0&&!M(K.sessionId))return G(400,{error:"session required"});if("lastReceivedId"in K&&(typeof K.lastReceivedId!=="number"||!Number.isSafeInteger(K.lastReceivedId)||K.lastReceivedId<0)||"sessionId"in K&&typeof K.sessionId!=="string")throw Error("invalid params");$={lastReceivedId:Number(K.lastReceivedId??0),sessionId:typeof K.sessionId==="string"?K.sessionId:void 0}}}catch(K){if(K instanceof N)throw K;return G(400,{error:"invalid params"})}let{lastReceivedId:P,sessionId:A}=$;if(f.requireSession===!0&&!M(A))return G(400,{error:"session required"});if(A===void 0&&!Z)Z=!0,x.warn("rpc notification drain missing session id",{pid:process.pid});let W;if(f.drainAsync)try{W=await f.drainAsync(P,A)}catch(K){return x.warn("rpc notification drain failed",{pid:process.pid,error:K instanceof Error?K.message:String(K)}),G(500,{error:"drain failed"})}else W=f.drain?.(P,A);return G(200,{messages:W})}if(b==="apply"){let $=Promise.resolve(f.apply(F)),P=f.applyDeadlineMs===void 0?await $:await c($,f.applyDeadlineMs);return G(200,P)}return G(404,{error:"unknown method"})}catch(X){if(X instanceof N)return x.debug("rpc request refused",{pid:process.pid,status:X.status}),G(X.status,{error:X.message});if(X instanceof S)return x.warn("rpc apply deadline exceeded",{pid:process.pid,deadlineMs:f.applyDeadlineMs}),G(504,{error:"handler deadline exceeded"});x.warn("rpc request failed",{pid:process.pid,error:X instanceof Error?X.message:String(X)}),G(500,{error:"internal error"})}}let Q=await new Promise((V,J)=>{B.on("error",J),B.listen(0,"127.0.0.1",()=>{let G=B.address();if(G&&typeof G==="object")V(G.port);else J(Error("no port"))})});if(B.unref(),f.sweepRoot)try{await k(f.sweepRoot,f.dir,f.isManagedDir,x)}catch(V){x.warn("rpc state sweep failed",{pid:process.pid,error:V instanceof Error?V.message:String(V)})}try{await O(f.dir,{port:Q,token:z,pid:process.pid},{secureDir:f.secureDir}),x.debug("rpc server pid",{pid:process.pid,rpcPort:Q})}catch(V){throw await new Promise((J)=>B.close(()=>J())),V}return{port:Q,token:z,async stop(){await new Promise((G)=>{B.closeAllConnections?.(),B.close(()=>G());for(let X of L)X.destroy()});let V=l(f.dir,`port-${process.pid}.json`),J=await D(V).then((G)=>JSON.parse(G)).catch((G)=>{if(G instanceof h&&G.code!=="ENOENT")throw G;return});if(J?.port===Q&&J.token===z)await u(V).catch(()=>{})}}}async function Hf(f,x,z){let H=globalThis,Y=Symbol.for(f),Z=H[Y]??{servers:new Map,pending:new Map};H[Y]=Z;let{servers:L,pending:B}=Z,T=B.get(x)??Promise.resolve(),Q,V=T.catch(()=>{}).then(async()=>{let G=L.get(x);if(G){if(await G.stop(),L.get(x)===G)L.delete(x)}Q=await z(),L.set(x,Q)});B.set(x,V);try{await V}finally{if(B.get(x)===V)B.delete(x)}let J=Q;if(!J)throw Error("RPC server failed to start");return{server:J,release:async()=>{if(L.get(x)!==J)return;if(await J.stop(),L.get(x)===J)L.delete(x)}}}var R="1.15.0";function bf(f,x,z){let H={...x,version:R};return O(f,H,z)}var Cf=w(j);
|
|
2
|
+
export{i as fg,n as gg,a as hg,Bf as ig,Hf as jg,R as kg,bf as lg,Cf as mg};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash as B}from"node:crypto";import{homedir as G,tmpdir as W}from"node:os";import{dirname as J,join as w,resolve as z}from"node:path";var A="OPENCODE_OPENAI_AUTH_RPC_DIR",K="openai-auth-";function L(k){return B("sha256").update(k).digest("hex").slice(0,16)}function M(){let k=process.env.XDG_STATE_HOME||w(G(),".local","state");return w(k,"cortexkit","openai-auth","rpc")}function Q(k){let q=process.env[A]?.trim();if(q)return z(k,q);return w(M(),`${K}${L(k)}`)}async function $(k){let q=process.env[A]?.trim();if(q)return{dir:z(k,q),secureDir:!1};let x=Q(k);return{dir:x,secureDir:!0,sweepRoot:J(x)}}export{W as
|
|
1
|
+
import{createHash as B}from"node:crypto";import{homedir as G,tmpdir as W}from"node:os";import{dirname as J,join as w,resolve as z}from"node:path";var A="OPENCODE_OPENAI_AUTH_RPC_DIR",K="openai-auth-";function L(k){return B("sha256").update(k).digest("hex").slice(0,16)}function M(){let k=process.env.XDG_STATE_HOME||w(G(),".local","state");return w(k,"cortexkit","openai-auth","rpc")}function Q(k){let q=process.env[A]?.trim();if(q)return z(k,q);return w(M(),`${K}${L(k)}`)}async function $(k){let q=process.env[A]?.trim();if(q)return{dir:z(k,q),secureDir:!1};let x=Q(k);return{dir:x,secureDir:!0,sweepRoot:J(x)}}export{W as Sg,K as Tg,Q as Ug,$ as Vg};
|