@cortexkit/opencode-openai-auth 1.8.6 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/bin.js +2 -2
  2. package/dist/{index-byz2j6hz.js → index-2f9w48sc.js} +1 -1
  3. package/dist/{index-zah8t2d2.js → index-5sgqz46z.js} +2 -2
  4. package/dist/{index-jh90fx7y.js → index-6j3059fy.js} +2 -2
  5. package/dist/index-6r27fz5a.js +91 -0
  6. package/dist/{index-kphzmgq6.js → index-96971sba.js} +1 -1
  7. package/dist/{index-pnvp8hvs.js → index-b79fxcrc.js} +1 -1
  8. package/dist/{index-5wgxt362.js → index-bvswyxpt.js} +1 -1
  9. package/dist/index-fqt90tbq.js +76 -0
  10. package/dist/{index-95s2mw9w.js → index-hpb6k6st.js} +2 -2
  11. package/dist/{index-25p8t63g.js → index-hyjrm2vw.js} +2 -2
  12. package/dist/{index-zf649dj2.js → index-k1dfzavn.js} +2 -2
  13. package/dist/index-mtf8pv2w.js +8 -0
  14. package/dist/index-mw7fqra8.js +63 -0
  15. package/dist/index.js +1 -1
  16. package/dist/rpc/port-file.js +1 -1
  17. package/dist/rpc/protocol.js +1 -1
  18. package/dist/rpc/rpc-client.js +1 -1
  19. package/dist/rpc/rpc-dir.js +1 -1
  20. package/dist/sidebar-state.js +1 -1
  21. package/dist/token-util-ybe08zph.js +1 -0
  22. package/dist/{token-j2jmx8k7.js → token-y2zkdr5m.js} +1 -1
  23. package/dist/tui-preferences.js +1 -1
  24. package/dist/v2/server.js +2 -2
  25. package/package.json +2 -2
  26. package/src/tui-compiled/raw/shared/0332701351b3eeec-format.js +45 -26
  27. package/src/tui-compiled/raw/shared/0f77ebc3c914c9c6-custody.js +25 -0
  28. package/src/tui-compiled/raw/shared/352d228be2832bd4-hub.js +20 -1
  29. package/src/tui-compiled/raw/shared/4825e03209d6ae3e-with-lock.js +37 -10
  30. package/src/tui-compiled/raw/shared/549daf371622c304-index.tsx +288 -131
  31. package/src/tui-compiled/raw/shared/7c97ac0cec074ae7-format.js +30 -17
  32. package/src/tui-compiled/raw/shared/d0f0b6be200311af-insula.js +6 -0
  33. package/src/tui-compiled/raw/shared/e8cd4929507508d8-refresh-file-lock.js +2 -2
  34. package/src/tui-compiled/runtime/shared/0332701351b3eeec-format.js +45 -26
  35. package/src/tui-compiled/runtime/shared/0f77ebc3c914c9c6-custody.js +25 -0
  36. package/src/tui-compiled/runtime/shared/352d228be2832bd4-hub.js +20 -1
  37. package/src/tui-compiled/runtime/shared/4825e03209d6ae3e-with-lock.js +37 -10
  38. package/src/tui-compiled/runtime/shared/549daf371622c304-index.js +358 -225
  39. package/src/tui-compiled/runtime/shared/7c97ac0cec074ae7-format.js +30 -17
  40. package/src/tui-compiled/runtime/shared/d0f0b6be200311af-insula.js +6 -0
  41. package/src/tui-compiled/runtime/shared/e8cd4929507508d8-refresh-file-lock.js +2 -2
  42. package/dist/index-a8wbqm6a.js +0 -74
  43. package/dist/index-n12zjwh9.js +0 -8
  44. package/dist/index-v6jcz0hz.js +0 -63
  45. package/dist/index-zne9tzy9.js +0 -91
  46. package/dist/token-util-7n2nfbyc.js +0 -1
@@ -1,8 +0,0 @@
1
- import{jf as H,kf as j,lf as F0,nf as q,of as w,pf as C,qf as h,rf as V0,tf as O}from"./index-95s2mw9w.js";import{randomUUID as M}from"node:crypto";import{lstat as v,mkdir as Y0,open as X0,readFile as Z0,rename as _0,rm as T,stat as L}from"node:fs/promises";import{dirname as P,join as x0}from"node:path";function Q0($,f){return`${$}.${f}.lock`}class W0 extends Error{details;constructor($){super(`Timed out acquiring ${$.name} lock for ${$.target}`);this.name="LockContentionError",this.details=$}}class I extends Error{details;constructor($){super(`Lost ${$.name} lock for ${$.target}`);this.name="LockOwnershipError",this.details=$}}async function y0($,f,B){let G=performance.now();for(;;){f.signal?.throwIfAborted();let Y=await H0({path:$,name:f.name,ttlMs:f.ttlMs,renew:f.renew??!1,...f.onStep?{onStep:f.onStep}:{},...f.onRenewalTimer?{onRenewalTimer:f.onRenewalTimer}:{}});if(Y)try{return f.signal?.throwIfAborted(),await B(Y)}finally{await Y.release(f.signal)}let Z=f.timeoutMs-(performance.now()-G);if(Z<=0)throw new W0({target:$,name:f.name,timeoutMs:f.timeoutMs});await new Promise((_)=>setTimeout(_,Math.min(25,Math.ceil(Z))))}}async function J0($,f){let B=await X0($,"wx",384),G;try{G=await B.stat()}catch{G=void 0}try{await B.writeFile(f,"utf8")}catch(Y){try{let Z=await v($).catch(()=>{return});if(G&&Z&&Z.dev===G.dev&&Z.ino===G.ino)await T($,{force:!0}).catch(()=>{})}catch{}throw Y}finally{await B.close()}}var C0=globalThis.setTimeout.bind(globalThis),R0=globalThis.clearTimeout.bind(globalThis);function S0($){let f=$?.code;return f==="ENOENT"||!H&&(f==="EINVAL"||f==="ENOTDIR")}var D0;function I0($,f){if($.dev!==f.dev||$.ino!==f.ino)return!1;if($.ino===0&&$.birthtimeMs!==f.birthtimeMs)return!1;return!0}var T0=1000;function H0($){return A0({...$,now:Date.now})}async function A0($){let f=Q0($.path,$.name),B=x0(f,"owner.json"),G=M(),Y=$.now??Date.now,Z=null,_=!1,U=!1,J,c,g0=new Promise((z)=>{c=z});function d(z){try{let K=$.onRenewalTimer?.(z);if(K&&(typeof K==="object"||typeof K==="function")&&"then"in K&&typeof K.then==="function")Promise.resolve(K).catch(()=>{})}catch{}}function a(){if(!Z)return;R0(Z),Z=null,d("cancelled")}function V(z,K){if(J||_)return;J=Object.freeze({reason:z,expectedOwnerId:G,...typeof K?.ownerId==="string"?{observedOwnerId:K.ownerId}:{},...typeof K?.expiresAt==="number"?{observedExpiresAt:K.expiresAt}:{}}),a(),c(J)}let E,A=null,x=`${f}.evicting`,X=x0(x,"owner.json"),i=M(),s=5000,n=8;async function F(){if(H)try{return JSON.parse(await C(f,!0))}catch(z){if(z.code!=="EISDIR"&&z.reason!=="wrong-kind")throw z;return await q(f,"directory",!0),JSON.parse(await C(B,!0))}try{return JSON.parse(await Z0(f,"utf8"))}catch(z){if(z.code!=="EISDIR")throw z;return JSON.parse(await Z0(B,"utf8"))}}async function j0(){if(H){let Q=await F(),W=Number(Q?.expiresAt)-Y();await O(f,`${JSON.stringify({ownerId:G,expiresAt:Y()+$.ttlMs})}
2
- `,{deadline:performance.now()+Math.max(0,W),beforeRename:async()=>{let S=await F();if(S?.ownerId!==G||!(Number(S?.expiresAt)>Y())||!await D())throw new I({target:$.path,name:$.name})}});return}let z=`${f}.${M()}.tmp`,K,N=!1;try{K=await X0(z,"wx",384),N=!0,await K.writeFile(`${JSON.stringify({ownerId:G,expiresAt:Y()+$.ttlMs})}
3
- `,"utf8"),await K.chmod(384),await K.close(),K=void 0;let Q=await F();if(Q?.ownerId!==G||!(Number(Q?.expiresAt)>Y())||!await D())throw new I({target:$.path,name:$.name});await _0(z,f),N=!1}finally{if(await K?.close().catch(()=>{}),N)await T(z,{force:!0}).catch(()=>{})}}async function t(){let z=`${JSON.stringify({ownerId:G,expiresAt:Y()+$.ttlMs})}
4
- `;if(H)await h(f,z);else await J0(f,z)}async function o(z){let K=z.code;if(K!=="EEXIST"&&K!=="EISDIR")return!1;if(H){if($.onStep)await $.onStep("lease-contention-read-ready");try{if(K==="EISDIR")await q(f,"directory",!0),await C(B,!0);else await F()}catch(N){if(N.code!=="ENOENT")throw N}}return!0}async function y(){if(H)await w(P(f));try{return await t(),!0}catch(z){let K=z.code;if(await o(z))return!1;if(K==="ENOENT"){if(H)await w(P(f));else await Y0(P(f),{recursive:!0});try{return await t(),!0}catch(N){if(await o(N))return!1;throw N}}throw z}}async function m(){await new Promise((z)=>setTimeout(z,Math.floor(Math.random()*4)))}async function k(z=!0){if(z&&$.onStep)await $.onStep("lock-read-ready");let K;try{K=await F()}catch(Q){if(H&&Q.code!=="ENOENT")throw Q}let N=Number(K?.expiresAt);if(Number.isFinite(N)&&N>Y())return{status:"live"};if(typeof K?.ownerId==="string"&&Number.isFinite(N))return{status:"stale",identity:{kind:"owner",ownerId:K.ownerId,expiresAt:N}};try{let Q=await L(f),W=Number.isFinite(N)?N:Q.mtimeMs+$.ttlMs;if(W>Y())return{status:"live"};return{status:"stale",identity:{kind:"stat",dev:Q.dev,ino:Q.ino,mtimeMs:Q.mtimeMs,expiresAt:W}}}catch(Q){if(Q.code==="ENOENT"){if($.onStep)await $.onStep("lock-missing");return{status:"missing"}}throw Q}}function r(z,K){if(K.status!=="stale")return!1;let N=K.identity;if(z.kind==="owner"&&N.kind==="owner")return z.ownerId===N.ownerId&&z.expiresAt===N.expiresAt;return z.kind==="stat"&&N.kind==="stat"&&z.dev===N.dev&&z.ino===N.ino&&z.mtimeMs===N.mtimeMs&&z.expiresAt===N.expiresAt}async function D(){try{return JSON.parse(await C(X,H))?.ownerId===i}catch(z){if(H&&z.code!=="ENOENT")throw z;return!1}}async function R(z){if(H)await F0(z,"remove",()=>T(z,{recursive:!0,force:!0}));else await T(z,{recursive:!0,force:!0}).catch(()=>{})}async function u(){if(await D())await R(x)}async function q0(z){if(!z)return!1;let K;try{let N=await v(x);K={dev:N.dev,ino:N.ino,birthtimeMs:N.birthtimeMs}}catch{return!1}if(!I0(z,K))return!1;try{return await L(X),!0}catch(N){if(N.code!=="ENOENT")return!0}try{await R(x)}catch{}return!0}async function e(){if(H)await V0(x);else await Y0(x);let z;try{let K=await v(x);z={dev:K.dev,ino:K.ino,birthtimeMs:K.birthtimeMs}}catch{z=void 0}try{await D0?.beforeOwnerWrite?.(x,X);let K=await D0?.failOwnerWrite?.(x,X);if(K!==void 0)throw K;let N=`${JSON.stringify({ownerId:i,createdAt:Y()})}
5
- `;if(H)await h(X,N);else await J0(X,N)}catch(K){let N=await q0(z);if(S0(K)&&!N)return!1;try{await u()}catch{}throw K}if($.onStep)await $.onStep("eviction-marker-acquired");return!0}async function $0(){let z;try{z=await L(x)}catch(N){if(N.code==="ENOENT")return"missing";throw N}if(H)try{await q(x,"directory",!0)}catch(N){if(N.code==="ENOENT")return"missing";throw N}if(z.mtimeMs+s>Y()){let N=!0;try{await L(X)}catch(Q){if(Q.code==="ENOENT")N=!1;else return"fresh"}if(N)return"fresh";if(z.mtimeMs+T0>Y())return"fresh"}if($.onStep)await $.onStep("stale-marker-stat");let K=`${x}.${M()}`;try{await _0(x,K)}catch(N){if(N.code==="ENOENT")return"missing";throw N}if($.onStep)await $.onStep("stale-marker-claimed");return await R(K),"recovered"}async function z0(z){try{if(!await e())return!1}catch(K){if(K.code==="EEXIST"){if(H)try{await q(x,"directory",!0),await C(X,!0)}catch(N){if(N.code!=="ENOENT")throw N}return!1}throw K}try{await z()}finally{await u()}return!0}async function K0(){for(let z=0;z<n;z++){if($.onStep)await $.onStep("relinquish-read");let K;try{K=await F()}catch(N){if(H)throw N;return}if(K?.ownerId!==G)return;try{await T(f,{recursive:!0,force:!0});return}catch(N){if(H)throw N;await m()}}}function N0(){if(!$.renew||_||J)return;let z=$.renewIntervalMs??Math.max(1000,Math.floor($.ttlMs/3));if(Z=C0(()=>{Z=null;let K=(async()=>{let N=!_;try{if(!await z0(async()=>{let W=await F(),S=Y();if(_||J){N=!1;return}if(W?.ownerId!==G){V("taken-over",W),N=!1;return}if(!(Number(W?.expiresAt)>S)){V("expired",W),N=!1;return}if($.onStep)await $.onStep("renewal-owner-confirmed");if(_||J){N=!1;return}if(!await D())return;if($.onStep)await $.onStep("renewal-write-fenced");if(_||J){N=!1;return}if(!await D())return;if($.onStep)await $.onStep("renewal-write-ready");if(_||J){N=!1;return}if(await j0(),$.onStep)await $.onStep("renewal-write-finished");if(!await D()){V("marker-lost"),N=!1,await K0();return}})&&$.onStep)await $.onStep("renewal-marker-unavailable")}catch(Q){if(H&&Q instanceof j)E=Q,V("renewal-failed"),N=!1;try{let W=await F();if(W?.ownerId!==G)V("taken-over",W);else if(!(Number(W?.expiresAt)>Y()))V("expired",W)}catch{V("renewal-failed")}}finally{if($.onStep)try{await $.onStep("renewal-finished")}catch{}if(N&&!_&&!J)N0()}})();A=K,K.finally(()=>{if(A===K)A=null})},z),"unref"in Z)Z.unref();d("scheduled")}function f0(){try{let z=$.onContended?.();if(z&&(typeof z==="object"||typeof z==="function")&&"then"in z&&typeof z.then==="function")Promise.resolve(z).catch(()=>{})}catch{}return null}let g=await y();if(!g)for(let z=0;z<n;z++){if(g=await y(),g)break;let K=await k();if(K.status==="live")return f0();if(K.status==="missing")continue;if($.onStep)await $.onStep("stale-lock-observed");try{if(!await e()){await m();continue}}catch(N){if(N.code!=="EEXIST")throw N;if(await $0()==="fresh")return null;await m();continue}try{let N=await k();if(N.status==="live")return f0();if(!r(K.identity,N))continue;if(!await D())return null;if($.onStep)await $.onStep("stale-lock-confirmed");if(!await D())return null;let Q=await k(!1);if(!r(K.identity,Q))continue;if(await R(f),!await D())return null;if($.onStep)await $.onStep("stale-lock-removed");if(g=await y(),!g)return null;if($.onStep)await $.onStep("stale-lock-recreated");if(!await D())return await K0(),g=!1,null;break}finally{await u()}}if(!g)return null;return N0(),{ownerId:G,whenLost:()=>g0,hasLost:()=>J!==void 0,assertOwned:async()=>{if(E)throw E;let z;try{let K=await F();if(z=K,!_&&!J&&K?.ownerId===G&&Number(K?.expiresAt)>Y())return;V(K?.ownerId!==G?"taken-over":"expired",K)}catch(K){if(V("unreadable"),H&&K instanceof j)throw K}throw new I({target:$.path,name:$.name,expectedOwnerId:G,...typeof z?.ownerId==="string"?{observedOwnerId:z.ownerId}:{},...typeof z?.expiresAt==="number"?{observedExpiresAt:z.expiresAt}:{}})},release:async(z)=>{if(H&&U)return;_=!0,a(),await A;let K=performance.now()+s+1000,N=5;for(;;){try{let W=!1;if(await z0(async()=>{let B0;try{B0=await F()}catch(G0){if(H&&G0.code==="ENOENT"){W=!0;return}throw G0}if(B0?.ownerId!==G){W=!0;return}if($.onStep)await $.onStep("release-owner-confirmed");if(!await D())return;await R(f),W=!0})){if(H&&!W)throw new j(f,"release-not-confirmed",{code:"EIO"});U=W;return}if(z?.aborted)return;await $0()}catch(W){if(H)throw W;return}let Q=K-performance.now();if(Q<=0)break;await new Promise((W)=>setTimeout(W,Math.min(N,Q))),N=Math.min(N*2,50)}if(H)throw new j(f,"release-not-confirmed",{code:"ETIMEDOUT"})}}}import{randomUUID as U0}from"node:crypto";import{mkdir as M0,open as b,rename as L0,rm as O0}from"node:fs/promises";import{dirname as p}from"node:path";class l extends Error{constructor($){super("file or directory sync failed",{cause:$});this.name="AtomicSyncError"}}async function a0($,f,B={}){await b0($,f,B)}async function b0($,f,B,G){if(H)return O($,B.serialize?B.serialize(f):`${JSON.stringify(f,null,2)}
6
- `,{beforeRename:B.beforeRename,stagePath:`${$}.${(B.stageName??U0)()}.tmp`,onRenamed:G,durable:B.durable,durability:B.durability,onOutcome:B.onOutcome});await M0(p($),{recursive:!0});let Y=`${$}.${(B.stageName??U0)()}.tmp`,Z,_=!1;try{if(Z=await b(Y,"wx",384),_=!0,await Z.writeFile(B.serialize?B.serialize(f):`${JSON.stringify(f,null,2)}
7
- `,"utf8"),await Z.chmod(384),B.durable)try{await Z.sync()}catch(U){throw new l(U)}if(await Z.close(),Z=void 0,await B.beforeRename?.(),await L0(Y,$),_=!1,G?.(),B.durable){let U=await b(p($),"r");try{await U.sync()}catch(J){throw new l(J)}finally{await U.close()}}}finally{if(await Z?.close().catch(()=>{}),_)await O0(Y,{force:!0}).catch(()=>{})}}async function i0($){if(H){await q($,"file");let G=new j($,"directory-sync-unsupported",{code:"ENOTSUP"});throw G.published=!0,G}let f=await b($,"r");try{await f.sync()}finally{await f.close()}let B=await b(p($),"r");try{await B.sync()}finally{await B.close()}}var n0=Object.freeze({sidebar:Object.freeze({name:"sidebar-write",ttlMs:1e4,timeoutMs:15000,renew:!0}),preferences:Object.freeze({name:"preferences",ttlMs:1e4,timeoutMs:2000,renew:!0})});
8
- export{l as Ae,a0 as Be,b0 as Ce,i0 as De,H0 as Ee,Q0 as Fe,W0 as Ge,I as He,y0 as Ie,n0 as Je};