@cortexkit/opencode-anthropic-auth 2.0.1 → 2.0.3
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/README.md +35 -845
- package/dist/cli-failure.d.ts +6 -5
- package/dist/cli.js +57 -103
- package/dist/custody-mode.d.ts +1 -0
- package/dist/{index-52r2e1h9.js → index-5hyennzm.js} +1 -1
- package/dist/{index-p4wvcwhh.js → index-fncp6r0j.js} +1 -1
- package/dist/index-jmjevtm1.js +2 -0
- package/dist/index-kd89hcr3.js +2 -0
- package/dist/index-mdpyfkv3.js +464 -0
- package/dist/index-nfcp0m1t.js +42 -0
- package/dist/index-qttfa42y.js +2 -0
- package/dist/{index-3xqv3rw3.js → index-rftced5v.js} +1 -1
- package/dist/{index-zdgceztz.js → index-vjehtqnb.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/quota-preflight.d.ts +1 -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/setup/command.d.ts +5 -14
- package/dist/setup/native-activation.d.ts +14 -6
- package/dist/setup/native-enrollment.d.ts +15 -0
- package/dist/setup/native-local.d.ts +31 -1
- package/dist/setup/process-fence.d.ts +0 -6
- package/dist/setup/types.d.ts +9 -0
- package/dist/sidebar-state.d.ts +20 -2
- package/dist/sidebar-state.js +1 -1
- package/dist/transform.d.ts +17 -2
- package/dist/tui-preferences.js +1 -1
- package/dist/tui.d.ts +0 -2
- package/dist/v2/activation.d.ts +2 -0
- package/dist/v2/adapter.d.ts +8 -2
- package/dist/v2/cachekeep.d.ts +19 -0
- package/dist/v2/menu.d.ts +2 -1
- package/dist/v2/server.js +4 -4
- package/dist/v2/setup.d.ts +2 -0
- package/dist/v2/source.d.ts +1 -0
- package/dist/v2/tui.js +1 -1
- package/package.json +5 -5
- package/src/sidebar-state.ts +165 -29
- package/src/tui-compiled/sidebar-state.ts +165 -29
- package/src/tui-compiled/tui.tsx +363 -239
- package/src/tui.tsx +149 -48
- package/dist/index-04syas8a.js +0 -2
- package/dist/index-b3mxpp4w.js +0 -2
- package/dist/index-ynq181e8.js +0 -42
- package/dist/index-yxtdke11.js +0 -449
- package/dist/setup/activation.d.ts +0 -7
- package/dist/setup/command.test.d.ts +0 -1
- package/dist/setup/detect.d.ts +0 -8
- package/dist/setup/host-executable.d.ts +0 -3
- package/dist/setup/jsonc.d.ts +0 -9
- package/dist/setup/opencode-config.d.ts +0 -18
- package/dist/setup/pi.d.ts +0 -18
package/dist/custody-mode.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{mkdir as l,readdir as u,readFile as c,rename as p,unlink as m,writeFile as d}from"node:fs/promises";import{join as a}from"node:path";function f(t){try{return process.kill(t,0),!0}catch(r){return r.code==="EPERM"}}async function b(t,r){await l(t,{recursive:!0});let s={...r,startedAt:Date.now()},e=a(t,`port-${r.pid}.json`),i=`${e}.${process.pid}.tmp`;return await d(i,JSON.stringify(s),{encoding:"utf8",mode:384}),await p(i,e),e}async function h(t,r){let s;try{s=await u(t)}catch{return null}let e=[];for(let n of s){if(!n.startsWith("port-")||!n.endsWith(".json"))continue;try{let o=JSON.parse(await c(a(t,n),"utf8"));if(Number.isFinite(o.port))if(f(o.pid))e.push(o);else m(a(t,n)).catch(()=>{})}catch{}}if(e.length===0)return null;let i=r&&r>=1?e.filter((n)=>n.pid===r):[];return(i.length>0?i:e).sort((n,o)=>o.startedAt-n.startedAt)[0]??null}
|
|
2
|
-
export{b as
|
|
2
|
+
export{b as lf,h as mf};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import{constants as X}from"node:fs";import{chmod as y,lstat as G,mkdir as v,open as N}from"node:fs/promises";import{createRequire as j}from"node:module";class H extends Error{code="ERR_PRIVATE_FILES_UNAVAILABLE"}function x(_,T){if(_!=="x64"&&_!=="arm64")throw new H(`Windows private files do not support ${_}; use x64 or ARM64 Node 24. No mode-only fallback is safe.`);if(_==="arm64"&&T&&!F(T))throw new H("Windows ARM64 requires Bun >= 1.3.10 with native ARM64 support; use ARM64 Node 24 or upgrade Bun. No mode-only fallback is safe.");return`private-files-win32-${_}.node`}function F(_){let T=/^(\d+)\.(\d+)\.(\d+)$/.exec(_);if(!T)return!1;let L=Number(T[1]),A=Number(T[2]),S=Number(T[3]);return L>1||L===1&&(A>3||A===3&&S>=10)}var z;function M(){if(z)return z;let _=x(process.arch,process.versions.bun);try{if(z=j(import.meta.url)(`../prebuilds/${_}`),!z||["create","read","verify","secure","verifySafeParent"].some((T)=>typeof z?.[T]!=="function"))throw Error("Invalid private-files N-API interface");return z}catch(T){throw new H(`Cannot load ${_}. Install @cortexkit/private-files with the matching Windows N-API v8 prebuild, or rebuild private-files/native with MSVC. Use local NTFS. No mode-only fallback is safe. Cause: ${String(T)}`)}}import*as O from"node:fs";import*as W from"node:fs/promises";import{posix as Q}from"node:path";function*P(_){return yield{kind:"realpath",path:_}}function*J(_,T){return yield{kind:_,path:T}}function*g(_){return yield{kind:"readFile",path:_}}function C(_,T){return{ok:!1,reason:T,path:_}}function $(_){return _?.code==="ENOENT"}function*f(_,T){if(!_||_.includes("\x00"))throw Error("invalid path");let L=T.isAbsolute(_)?_:`${process.cwd()}${T.sep}${_}`,A=[];for(;;)try{let S=yield*P(L);if(A.length&&!(yield*J("stat",S)).isDirectory())throw Error("nearest existing ancestor is not a directory");return{resolved:T.join(S,...A),existing:S,missing:A.length>0}}catch(S){if(!$(S))throw S;try{yield*J("lstat",L)}catch(R){if(!$(R))throw R;let E=T.dirname(L);if(E===L)throw S;A.unshift(T.basename(L)),L=E;continue}throw S}}function b(_,T){let L=new TextDecoder("utf-8",{fatal:!0}).decode(_),A=(S)=>S!==void 0&&/^\d+$/.test(S)&&Number.isSafeInteger(Number(S))&&Number(S)<=4294967295;return L.split(`
|
|
2
2
|
`).filter((S)=>S.trim()!==""&&!S.trimStart().startsWith("#")).map((S)=>{let R=S.split(":");if(R.length!==T||!R[0]||/\s/.test(R[0])||!A(R[2])||T===7&&!A(R[3]))throw Error("malformed account record");if(T===4&&R[3]!==""&&R[3].split(",").some((E)=>!E||/\s/.test(E)))throw Error("malformed group members");return R})}function*k(_,T){let L=[];for(let[D,K]of[["/etc/passwd",7],["/etc/group",4]]){let I;try{I=yield*g(D)}catch{return`could not read ${D} to establish a user-private group`}try{L.push(b(I,K))}catch{return`could not parse ${D} to establish a user-private group`}}let[A,S]=L,R=A.filter((D)=>Number(D[2])===_),E=S.filter((D)=>Number(D[2])===T);if(R.length!==1||E.length!==1)return"group-writable ancestor (effective user or group is absent or ambiguous in account files)";let Y=R[0][0];if(E[0][3]!==""&&E[0][3].split(",").some((D)=>D!==Y))return"group-writable ancestor (other group members)";if(A.some((D)=>Number(D[2])!==_&&Number(D[3])===T))return"group-writable ancestor (another user's primary group)";return}function*m(_,T,L,A=!1){if(T==null)return C(_,"could not determine effective uid");let S;try{let D=yield*f(_,Q);if(A&&(D.missing||!(yield*J("stat",D.existing)).isDirectory()))return C(_,"ancestor is not a directory");S=D.missing||(yield*J("stat",D.existing)).isDirectory()?D.existing:Q.dirname(D.existing)}catch{return C(_,"could not resolve target or its nearest existing ancestor")}let R,E,Y=!1;for(;;){let D;try{D=[yield*J("lstat",S),yield*J("stat",S)]}catch{return C(S,"could not inspect ancestor")}for(let I of D){if(!I.isDirectory())return C(S,"ancestor is not a directory");if(I.uid!==T&&I.uid!==0)return C(S,"foreign owner");if((I.mode&18)===0)continue;if(I.uid===0&&(I.mode&512)!==0){if(R?.every((Z)=>Z.uid===T&&(Z.mode&18)===0))continue;return C(S,"sticky ancestor without an owner-only child")}if((I.mode&2)!==0)return C(S,"world-writable ancestor");if((I.mode&512)!==0||I.uid!==T||L==null||I.gid!==L)return C(S,"group-writable ancestor (not a non-sticky user-private group)");if(!Y)E=yield*k(T,L),Y=!0;if(E)return C(S,E)}let K=Q.dirname(S);if(K===S)return{ok:!0};R=D,S=K}}function q(_,T){return m(_,T.euid===void 0?process.geteuid?.():T.euid,T.egid===void 0?process.getegid?.():T.egid,T.directoryOnly)}function w(_,T={}){let L={realpathSync:O.realpathSync.native,lstatSync:O.lstatSync,statSync:O.statSync,readFileSync:O.readFileSync,...T.fs},A=q(_,T),S=A.next();while(!S.done){let{kind:R,path:E}=S.value,Y;try{switch(R){case"realpath":Y=L.realpathSync(E);break;case"lstat":Y=L.lstatSync(E);break;case"stat":Y=L.statSync(E);break;case"readFile":Y=L.readFileSync(E);break}}catch(D){S=A.throw(D);continue}S=A.next(Y)}return S.value}async function B(_,T={}){let L={realpath:W.realpath,lstat:W.lstat,stat:W.stat,readFile:W.readFile,...T.fs},A=q(_,T),S=A.next();while(!S.done){let{kind:R,path:E}=S.value,Y;try{Y=await L[R](E)}catch(D){S=A.throw(D);continue}S=A.next(Y)}return S.value}function U(_,T){let L=_.aces?.[0];return(_.owner===_.currentUser||_.owner==="S-1-5-32-544"||_.owner==="S-1-5-18")&&_.kind===T&&!_.reparse&&_.daclPresent&&(_.daclProtected&&L?.flags===(T==="directory"?3:0)||T==="file"&&!_.daclProtected&&L?.flags===16&&!!_.parent&&_.parent.currentUser===_.currentUser&&U(_.parent,"directory"))&&_.aces?.length===1&&L?.type===0&&L.mask===2032127&&L.sid===_.currentUser}var n="wrong-owner",r="extra-ace",i="not-protected",a="null-dacl",t="empty-dacl",e="reparse-point",__="unsupported-filesystem",T_="mode",L_="writable-by-others";function V(_,T){if(T.ok)return T;return{ok:!1,reason:/writable|sticky|user-private group/.test(T.reason)?"writable-by-others":T.reason==="foreign owner"?"wrong-owner":T.reason==="ancestor is not a directory"?"wrong-kind":"io-error",path:_,level:T.path}}function Y_(_,T={}){if(process.platform==="win32")return{ok:!1,reason:"unsupported-filesystem",path:_};return V(_,w(_,{...T,directoryOnly:!0}))}async function I_(_,T={}){if(process.platform!=="win32")return V(_,await B(_,{...T,directoryOnly:!0}));try{return await M().verifySafeParent(_),{ok:!0}}catch(L){if(L instanceof H)return{ok:!1,reason:"unsupported-filesystem",path:_};let A=L;if(A.code!=="ERR_PRIVATE_FILES_SECURITY")throw L;return{ok:!1,reason:A.reason??"io-error",path:_,...A.level?{level:A.level}:{},...A.sid||A.ownerSid?{sid:A.sid??A.ownerSid}:{},...A.mask!==void 0?{mask:A.mask}:{}}}}async function c(_,T=""){if(process.platform==="win32")return M().create(_,"file",typeof T==="string"?Buffer.from(T):T);let L=await N(_,"wx",384);try{await L.writeFile(T)}finally{await L.close()}}async function l(_){if(process.platform==="win32")return M().create(_,"directory",Buffer.alloc(0));await v(_,{mode:448})}async function C_(_,T){if(process.platform==="win32")return M().verify(_,T);let L=await G(_);if((T==="file"?!L.isFile():!L.isDirectory())||(L.mode&511)!==(T==="file"?384:448)||L.uid!==process.getuid?.())throw Error(`Private ${T} requires current-user ownership and ${T==="file"?"0600":"0700"}: ${_}`)}async function h(_){if(process.platform==="win32")return M().read(_);let T=await N(_,X.O_RDONLY|X.O_NOFOLLOW|X.O_NONBLOCK);try{let L=await T.stat();if(!L.isFile()||(L.mode&511)!==384||L.uid!==process.getuid?.())throw Error(`Private file requires current-user ownership and 0600: ${_}`);return await T.readFile()}finally{await T.close()}}async function H_(_,T){if(process.platform==="win32")return M().secure(_,T);await y(_,T==="file"?384:448)}async function M_(_,T){if(T.kind==="dir")return l(_);return c(_)}async function O_(_){if(process.platform!=="win32"){let T=await G(_),L=T.isDirectory()?448:384;if(!T.isFile()&&!T.isDirectory())return{ok:!1,refusal:{reason:"wrong-kind",message:"Expected a regular file or directory"}};if(T.uid!==process.getuid?.())return{ok:!1,refusal:{reason:"wrong-owner",ownerSid:`uid:${T.uid}`}};let A=T.mode&511;return A===L?{ok:!0}:{ok:!1,refusal:{reason:"mode",actual:A,expected:L}}}try{return await M().verify(_,"auto"),{ok:!0}}catch(T){if(T instanceof H)return{ok:!1,refusal:{reason:"unsupported-filesystem",message:T.message}};let L=T;if(L.code!=="ERR_PRIVATE_FILES_SECURITY")throw T;if(L.reason==="wrong-owner")return{ok:!1,refusal:{reason:"wrong-owner",ownerSid:L.ownerSid??"unknown"}};if(L.reason==="extra-ace")return{ok:!1,refusal:{reason:"extra-ace",sid:L.sid??"unknown",mask:L.mask??0}};return{ok:!1,refusal:{reason:L.reason&&L.reason!=="mode"?L.reason:"io-error",message:L.message}}}}var W_=h;
|
|
3
|
-
export{H as
|
|
3
|
+
export{H as Qe,w as Re,B as Se,U as Te,n as Ue,r as Ve,i as We,a as Xe,t as Ye,e as Ze,__ as _e,T_ as $e,L_ as af,Y_ as bf,I_ as cf,c as df,l as ef,C_ as ff,h as gf,H_ as hf,M_ as if,O_ as jf,W_ as kf};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{existsSync as $,readFileSync as F}from"node:fs";import{homedir as Y}from"node:os";import{dirname as X,join as J,resolve as V}from"node:path";import{fileURLToPath as Z}from"node:url";var b="@cortexkit/opencode-anthropic-auth",G="@cortexkit/pi-anthropic-auth";function W(q=process.env,w=process.platform){return(w==="win32"?q.USERPROFILE||q.HOME:q.HOME)||Y()}function K(q=process.env,w=process.platform){let B=q.OPENCODE_CONFIG_DIR?.trim();if(B)return V(B);return J(q.XDG_CONFIG_HOME||J(W(q,w),".config"),"opencode")}function I(q=process.env){let w=q.XDG_DATA_HOME?.trim();if(w)return J(V(w),"opencode");return J(Y(),".local","share","opencode")}function M(q=process.env){return J(I(q),"auth.json")}function R(q=process.env,w=process.platform){let B=q.PI_CODING_AGENT_DIR?.trim()||q.PI_AGENT_DIR?.trim();if(B)return V(B);return J(W(q,w),".pi","agent")}function k(q=process.env){let w=q.PI_CODING_AGENT_DIR,B=W(q),z=w||J(B,".pi","agent");if(z==="~")z=B;else if(z.startsWith("~/")||process.platform==="win32"&&z.startsWith("~\\"))z=J(B,z.slice(2));if(z.startsWith("file://"))z=Z(z);return J(z,"auth.json")}async function x(){let q=X(Z(import.meta.url));for(let w=0;w<5;w++){let B=J(q,"package.json");if($(B))try{let Q=JSON.parse(F(B,"utf8"));if(typeof Q.version==="string"&&Q.version.trim())return Q.version.trim()}catch{}let z=X(q);if(z===q)break;q=z}return"1.22.0"}
|
|
2
|
+
export{b as y,G as z,K as A,M as B,R as C,k as D,x as E};
|