anyray-connect 0.11.224 → 0.11.225
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/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var qW=Object.defineProperty;var W=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var sg=(e,t)=>{for(var n in t)qW(e,n,{get:t[n],enumerable:!0})};var QW,Al,oI,eF,tF,He,mr,Dt,ig,nF,aI,Yn,Me,$e=W(()=>{"use strict";QW="http://localhost:8787",Al="anyray-placeholder",oI=/^ark_[A-Za-z0-9_-]{20,512}$/,eF="ark_svc_",tF=/^ark_svc_[A-Za-z0-9_-]{20,512}$/,He=e=>{let t=e?.trim();return!!(t&&oI.test(t))},mr=e=>{let t=e?.trim();if(t){if(tF.test(t))return"service";if(!t.startsWith(eF))return oI.test(t)?"personal":void 0}},Dt=e=>{let t=e.trim().replace(/\/+$/,"");return t=t.replace(/\/v1$/,""),t},ig=(e,t)=>e?.trim()||process.env[t]?.trim()||void 0,nF=new Set(["localhost","127.0.0.1","::1","0.0.0.0"]),aI=e=>{try{let{protocol:t,hostname:n}=new URL(e);return t==="http:"&&!nF.has(n)}catch{return!1}},Yn=e=>{let t=Dt(e||process.env.ANYRAY_GATEWAY_URL||QW),n;try{n=new URL(t)}catch{throw new Error(`invalid gateway URL: "${t}" (expected e.g. http://localhost:8787)`)}if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error(`invalid gateway URL: "${t}" \u2014 must start with http:// or https://`);return t},Me=(e={})=>{let t=Yn(e.origin),n=e.placeholderKey?.trim()||Al,r=e.clientKey?.trim()||process.env.ANYRAY_CLIENT_KEY?.trim()||void 0,o={user:e.user?.trim()||void 0,team:e.team?.trim()||void 0,intent:ig(e.intent,"ANYRAY_METADATA_INTENT"),intentLabel:ig(e.intentLabel,"ANYRAY_METADATA_INTENT_LABEL"),session:ig(e.session,"ANYRAY_METADATA_SESSION")},a=e.subscription?"subscription":e.placeholder?"placeholder":e.seat?"auto":"placeholder";return{origin:t,anthropicBaseUrl:t,openaiBaseUrl:`${t}/v1`,placeholderKey:n,clientKey:r,keyKind:mr(r),authMode:a,byoUpstream:e.byoUpstream,seat:a==="auto"?e.seat:void 0,metadata:o}}});var sI,iI,dp,up=W(()=>{"use strict";sI="/connect/optimize-output",iI=e=>({matcher:"*",hooks:[{type:"http",url:`${e}${sI}`,timeout:2,headers:{"x-anyray-api-key":"$ANYRAY_CLIENT_KEY",Authorization:"Bearer $ANTHROPIC_AUTH_TOKEN"},allowedEnvVars:["ANYRAY_CLIENT_KEY","ANTHROPIC_AUTH_TOKEN"]}]}),dp=e=>{if(!e||typeof e!="object")return!1;let t=e;if(t.type!=="http"||typeof t.url!="string")return!1;try{let n=new URL(t.url);return["http:","https:"].includes(n.protocol)&&n.pathname===sI&&!n.search&&!n.hash}catch{return!1}}});import{randomUUID as rF}from"node:crypto";import{lstat as cg,open as oF,readFile as lg,rename as pp,rm as aF,writeFile as sF}from"node:fs/promises";import{platform as cI}from"node:os";var lI,iF,Zo,Ha,cF,Re,jt=W(()=>{"use strict";lI=e=>e?.code==="ENOENT",iF=new Set(["EBUSY","EXDEV","ETXTBSY"]),Zo=async(e,t=cI())=>{try{await e.sync()}catch(n){if(t!=="win32")throw n}},Ha=class extends Error{recoveryCopy;code="ANYRAY_PUBLISH_CONFLICT";constructor(t){super("destination changed before publication"),this.recoveryCopy=t,this.name="PublishConflictError"}},cF=async(e,t,n={})=>{let r=await lg(e),o;try{o=await lg(t)}catch(s){if(!lI(s))throw s;await sF(t,r);return}let a=async s=>{let i=await oF(t,"r+");try{await i.write(s,0,s.length,0),await i.truncate(s.length),await Zo(i)}finally{await i.close()}};try{if(await a(r),await n.corruptAfterWrite?.(t),!(await lg(t)).equals(r))throw Object.assign(new Error("in-place publication did not persist"),{code:"EIO"})}catch(s){throw await a(o).catch(()=>{}),s}},Re=async(e,t,n=cI(),r={})=>{let o=r.rename??pp;if(n!=="win32"){try{await o(e,t)}catch(i){if(!iF.has(i?.code??""))throw i;await cF(e,t,r)}return}let a=`${t}.anyray-old-${process.pid}-${rF()}`,s=!1;try{let i=await cg(t);if(!i.isFile()&&!i.isSymbolicLink())throw new Error("refusing to replace a non-file destination");await pp(t,a),s=!0}catch(i){if(!lI(i))throw i}if(s&&r.verifyDisplaced){let i=!1;try{i=await r.verifyDisplaced(a)}catch{i=!1}if(!i){let c=!1;try{await cg(t),c=!0}catch{c=!1}if(c)throw new Ha(a);try{await o(a,t)}catch(l){let d=l?.code==="EEXIST";if(!d)try{await cg(t),d=!0}catch{d=!1}throw d?new Ha(a):new Error(`destination changed before publication and could not be restored; recovery copy remains at ${a}`,{cause:l})}throw new Ha}}try{await pp(e,t)}catch(i){if(s)try{await pp(a,t)}catch{throw new Error(`failed to publish file and restore the previous destination; recovery copy remains at ${a}`)}throw i}s&&await aF(a,{force:!0})}});import{writeFile as mp,readFile as Sl,chmod as pg,stat as fg,mkdir as uI,rm as di}from"node:fs/promises";import{AsyncLocalStorage as lF}from"node:async_hooks";import{randomUUID as dF}from"node:crypto";import{homedir as pI}from"node:os";import{join as Ua}from"node:path";var q,hp,mg,Ne,yp,ut,Il,L,uF,pF,fI,fF,mF,fp,hF,yF,vl,hr,hg,Bt,dg,be,Yt,ug,dI,yg,gp,Ko,wp,te=W(()=>{"use strict";jt();q=()=>Ua(pI(),".anyray"),hp=async()=>{let e=q();try{if((await fg(e)).isDirectory())return Ua(e,"connect.json")}catch{}return e},mg=()=>Ua(q(),"dev-key.pem"),Ne=async()=>{let e=q(),t;try{if(!(await fg(e)).isDirectory())t=await Sl(e,"utf-8").catch(()=>{}),await di(e,{force:!0});else return}catch{}if(await uI(e,{recursive:!0,mode:448}),t!==void 0){let n=Ua(e,"connect.json");await mp(n,t,{mode:384}),await pg(n,384)}},yp=async e=>{await Ne();let t=mg();await mp(t,e,{mode:384}),await pg(t,384)},ut=async()=>{try{let e=await Sl(mg(),"utf-8");return e.trim()?e:void 0}catch{return}},Il=async()=>{await di(mg(),{force:!0}).catch(()=>{})},L=async()=>{try{let e=await Sl(await hp(),"utf-8"),t=JSON.parse(e);return t===null||typeof t!="object"||Array.isArray(t)?{}:t}catch{return{}}},uF=0,pF=3e4,fI=5e3,fF=25,mF=()=>Ua(pI(),".anyray-connect-profile.lock"),fp=new lF,hF=e=>{try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}},yF=async(e,t)=>{try{let n=JSON.parse(await Sl(Ua(e,"owner.json"),"utf-8"));if(typeof n.pid=="number"&&Number.isSafeInteger(n.pid)&&n.pid>0)return!hF(n.pid)}catch{}return Date.now()-(await fg(e)).mtimeMs>t},vl=class extends Error{constructor(t){super(t),this.name="LockBusyError"}},hr=async(e,t={})=>{let n=t.waitMs??fI,r=t.staleMs??pF,o=Ua(e,"owner.json"),a=Date.now()+n;for(;;){let s=dF();try{await uI(e,{mode:448});try{await mp(o,`${JSON.stringify({pid:process.pid,nonce:s})}
|
|
3
3
|
`,{mode:384})}catch(c){throw await di(e,{recursive:!0,force:!0}).catch(()=>{}),c}return async()=>{try{JSON.parse(await Sl(o,"utf-8")).nonce===s&&await di(e,{recursive:!0,force:!0})}catch{}}}catch(c){if(c.code!=="EEXIST")throw c}if(!(await yF(e,r).catch(()=>!1)&&await di(e,{recursive:!0,force:!0}).then(()=>!0).catch(()=>!1))){if(Date.now()>=a)throw new vl(t.busyMessage??`${e} is busy; retry the command`);await new Promise(c=>setTimeout(c,fF))}}},hg=(e=fI)=>hr(mF(),{waitMs:e,busyMessage:"connect profile is busy; retry the command"}),Bt=async(e,t={})=>{if(fp.getStore()===!0)return e();let n=await hg(t.waitMs);try{return await fp.run(!0,e)}finally{await n()}},dg=async e=>{let t=Object.fromEntries(Object.entries(e).filter(([,o])=>o!==void 0)),n=await hp(),r=`${n}.${process.pid}.${uF++}.tmp`;await mp(r,`${JSON.stringify(t,null,2)}
|
|
4
|
-
`,{mode:384}),await pg(r,384);try{await Re(r,n)}catch(o){throw await di(r,{force:!0}).catch(()=>{}),o}},be=async e=>{if(fp.getStore()===!0){await dg(e);return}let t=await hg();try{await dg(e)}finally{await t()}},Yt=async e=>{let t=async()=>{let r=await L(),{next:o,result:a}=e(r);return o&&await dg(o),a};if(fp.getStore()===!0)return t();let n=await hg();try{return await t()}finally{await n()}},ug=["clientKey","clientKeyExpiresAt","enrolledCert","enrolledCertExpiry","enrolledCertLifetimeMs","enrolledTokenHash"],dI="ssoLink",yg=async()=>{let e=await L();return ug.some(t=>e[t]!==void 0)?!0:await ut()!==void 0},gp=async()=>{let e=await L(),t=ug.some(a=>e[a]!==void 0),n=e[dI]!==void 0,r=e.byoUpstream!==void 0,o=await ut()!==void 0;if(t||n||r||e.managedEnrollmentDisabled!==!0){let a={...e};for(let s of ug)delete a[s];delete a[dI],delete a.byoUpstream,a.managedEnrollmentDisabled=!0,delete a.anyrayFleetManaged,await be(a)}if(await Il(),await ut())throw new Error(`could not remove the dev key from ${q()}`);return t||n||r||o},Ko=async(e,t,n=!1)=>{let r=await L(),o=new Set(r.managedTools??[]),a=new Set(r.revertedTools??[]),s=new Set(r.blockedTools??[]),i=r.offboardedAt;for(let w of e){let b=w.status==="configured"||w.status==="queued";!t&&b&&(o.add(w.id),a.delete(w.id),s.delete(w.id),i=void 0),!t&&w.refused===!0&&s.add(w.id),t&&(w.status==="reverted"||w.status==="queued")&&(o.delete(w.id),a.add(w.id),s.delete(w.id))}n&&(o.clear(),s.clear());let c=[...o].sort(),l=[...r.managedTools??[]].sort(),d=[...a].sort(),u=[...r.revertedTools??[]].sort(),p=[...s].sort(),f=[...r.blockedTools??[]].sort(),m=(w,b)=>w.length===b.length&&w.every((A,C)=>A===b[C]);if(m(c,l)&&r.revertedTools!=null&&m(d,u)&&m(p,f)&&i===r.offboardedAt)return;let{offboardedAt:g,...y}=r;await be({...y,...i!==void 0?{offboardedAt:i}:{},managedTools:c,revertedTools:d,blockedTools:p})},wp=async(e=new Date().toISOString())=>{await be({...await L(),offboardedAt:e})}});var Rn,mt,Xn,ui,On=W(()=>{"use strict";Rn=(e=process.env)=>e.CODESPACES==="true"||e.CODESPACE_NAME?"codespaces":e.REMOTE_CONTAINERS==="true"||e.REMOTE_CONTAINERS_IPC||e.DEVCONTAINER?"devcontainer":e.SSH_CONNECTION||e.SSH_TTY?"ssh":null,mt=(e=process.env)=>Rn(e)!==null,Xn=e=>e==="codespaces"||e==="devcontainer",ui=e=>{switch(e){case"codespaces":return"a GitHub Codespace";case"devcontainer":return"a dev container";case"ssh":return"an SSH session"}}});var Pe,Jn=W(()=>{"use strict";Pe="0.11.
|
|
4
|
+
`,{mode:384}),await pg(r,384);try{await Re(r,n)}catch(o){throw await di(r,{force:!0}).catch(()=>{}),o}},be=async e=>{if(fp.getStore()===!0){await dg(e);return}let t=await hg();try{await dg(e)}finally{await t()}},Yt=async e=>{let t=async()=>{let r=await L(),{next:o,result:a}=e(r);return o&&await dg(o),a};if(fp.getStore()===!0)return t();let n=await hg();try{return await t()}finally{await n()}},ug=["clientKey","clientKeyExpiresAt","enrolledCert","enrolledCertExpiry","enrolledCertLifetimeMs","enrolledTokenHash"],dI="ssoLink",yg=async()=>{let e=await L();return ug.some(t=>e[t]!==void 0)?!0:await ut()!==void 0},gp=async()=>{let e=await L(),t=ug.some(a=>e[a]!==void 0),n=e[dI]!==void 0,r=e.byoUpstream!==void 0,o=await ut()!==void 0;if(t||n||r||e.managedEnrollmentDisabled!==!0){let a={...e};for(let s of ug)delete a[s];delete a[dI],delete a.byoUpstream,a.managedEnrollmentDisabled=!0,delete a.anyrayFleetManaged,await be(a)}if(await Il(),await ut())throw new Error(`could not remove the dev key from ${q()}`);return t||n||r||o},Ko=async(e,t,n=!1)=>{let r=await L(),o=new Set(r.managedTools??[]),a=new Set(r.revertedTools??[]),s=new Set(r.blockedTools??[]),i=r.offboardedAt;for(let w of e){let b=w.status==="configured"||w.status==="queued";!t&&b&&(o.add(w.id),a.delete(w.id),s.delete(w.id),i=void 0),!t&&w.refused===!0&&s.add(w.id),t&&(w.status==="reverted"||w.status==="queued")&&(o.delete(w.id),a.add(w.id),s.delete(w.id))}n&&(o.clear(),s.clear());let c=[...o].sort(),l=[...r.managedTools??[]].sort(),d=[...a].sort(),u=[...r.revertedTools??[]].sort(),p=[...s].sort(),f=[...r.blockedTools??[]].sort(),m=(w,b)=>w.length===b.length&&w.every((A,C)=>A===b[C]);if(m(c,l)&&r.revertedTools!=null&&m(d,u)&&m(p,f)&&i===r.offboardedAt)return;let{offboardedAt:g,...y}=r;await be({...y,...i!==void 0?{offboardedAt:i}:{},managedTools:c,revertedTools:d,blockedTools:p})},wp=async(e=new Date().toISOString())=>{await be({...await L(),offboardedAt:e})}});var Rn,mt,Xn,ui,On=W(()=>{"use strict";Rn=(e=process.env)=>e.CODESPACES==="true"||e.CODESPACE_NAME?"codespaces":e.REMOTE_CONTAINERS==="true"||e.REMOTE_CONTAINERS_IPC||e.DEVCONTAINER?"devcontainer":e.SSH_CONNECTION||e.SSH_TTY?"ssh":null,mt=(e=process.env)=>Rn(e)!==null,Xn=e=>e==="codespaces"||e==="devcontainer",ui=e=>{switch(e){case"codespaces":return"a GitHub Codespace";case"devcontainer":return"a dev container";case"ssh":return"an SSH session"}}});var Pe,Jn=W(()=>{"use strict";Pe="0.11.225"});import{access as gF,chmod as wF,mkdir as gg,open as Ag,readFile as CI,rm as zn,stat as mI,utimes as bF}from"node:fs/promises";import{createHash as vg,randomUUID as AI}from"node:crypto";import{readFileSync as vI,statSync as hI}from"node:fs";import{dirname as Sg,join as kF}from"node:path";import{isDeepStrictEqual as pi}from"node:util";var jo,SI,yI,CF,_,U,mi,gI,II,Yo,bp,re,EI,wI,AF,vF,xI,SF,wg,bg,kg,bI,IF,Cg,fi,EF,RI,OI,_I,kp,kI,Cp,Va,le,we=W(()=>{"use strict";jt();jo=e=>`${e}.anyray-bak`,SI=async e=>{let t;try{t=await Ag(Sg(e),"r"),await t.sync()}catch(n){if(process.platform!=="win32")throw n}finally{await t?.close().catch(()=>{})}},yI=async(e,t)=>{let n,r;try{n=await Ag(e,"wx",384),await n.writeFile(t,"utf-8"),await Zo(n)}catch(o){r=o}finally{await n?.close().catch(()=>{})}if(r)throw n&&await zn(e,{force:!0}).catch(()=>{}),r;await SI(e)},CF=async e=>{let t;try{t=await Ag(e,"r"),await Zo(t)}finally{await t?.close().catch(()=>{})}await SI(e)},_=async e=>{try{return await gF(e),!0}catch{return!1}},U=async e=>{if(!await _(e))return{};let t=await CI(e,"utf-8");if(!t.trim())return{};let n=JSON.parse(t);if(n===null||typeof n!="object"||Array.isArray(n))throw new Error(`${e} is not a JSON object`);return n},mi=class extends Error{constructor(){super("repair deferred: configuration changed before publication")}},gI=e=>`${e.dev}:${e.ino}:${e.size}:${e.mtimeNs}:${e.ctimeNs}`,II=e=>{try{let t=gI(hI(e,{bigint:!0})),n=vI(e),r=gI(hI(e,{bigint:!0}));if(t!==r)throw new mi;return{raw:n.toString("utf8"),fingerprint:`${r}:${vg("sha256").update(n).digest("hex")}`}}catch(t){if(t.code==="ENOENT")return{raw:"",fingerprint:"missing"};throw t}},Yo=e=>{let{raw:t,fingerprint:n}=II(e),r=t.trim()?JSON.parse(t):{};if(r===null||typeof r!="object"||Array.isArray(r))throw new Error("configuration is not a JSON object");return{value:r,fingerprint:n}},bp=async(e,t,n={})=>{for(let r=0;r<3;r++)try{let o=Yo(e);if(n.requireExisting&&o.fingerprint==="missing")return"unchanged";let a=JSON.stringify(o.value);return t(o.value),JSON.stringify(o.value)===a?"unchanged":(await re(e,o.value,{backup:n.backup,expectedFingerprint:o.fingerprint}),"written")}catch(o){if(!(o instanceof mi))throw o}return"repair deferred"},re=async(e,t,n={})=>{await gg(Sg(e),{recursive:!0,mode:448});let r=jo(e);if(n.backup!==!1&&!await _(r)){let a=await _(e),s=a?await CI(e,"utf-8"):`{}
|
|
5
5
|
`;if(a||n.tombstoneAbsent!==!1)try{await yI(r,s)}catch(i){if(i.code!=="EEXIST")throw i}}let o=`${e}.anyray-tmp-${process.pid}-${AI()}`;try{if(await yI(o,`${JSON.stringify(t,null,2)}
|
|
6
6
|
`),n.expectedFingerprint!==void 0){if(II(e).fingerprint!==n.expectedFingerprint)throw new mi;let a=n.expectedFingerprint.slice(n.expectedFingerprint.lastIndexOf(":")+1);try{await Re(o,e,n.runtimePlatform,{verifyDisplaced:async s=>vg("sha256").update(vI(s)).digest("hex")===a})}catch(s){throw s instanceof Ha?new mi:s}return}await Re(o,e,n.runtimePlatform),await wF(e,384),await CF(e)}finally{await zn(o,{force:!0}).catch(()=>{})}},EI=1,wI=3e4,AF=5e3,vF=/^[a-f0-9]{64}$/,xI=e=>`${e}.pending`,SF=e=>`${e}.lock`,wg=e=>{if(e===void 0)return"null";if(e===null||typeof e!="object")return JSON.stringify(e)??"null";if(Array.isArray(e))return`[${e.map(n=>wg(n)).join(",")}]`;let t=e;return`{${Object.keys(t).sort().filter(n=>t[n]!==void 0).map(n=>`${JSON.stringify(n)}:${wg(t[n])}`).join(",")}}`},bg=(e,t)=>({exists:e,sha256:vg("sha256").update(wg(t)).digest("hex")}),kg=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),bI=e=>kg(e)&&typeof e.exists=="boolean"&&typeof e.sha256=="string"&&vF.test(e.sha256),IF=e=>kg(e)&&e.transactionVersion===EI&&bI(e.before)&&bI(e.after)&&kg(e.journal),Cg=(e,t)=>e.exists===t.exists&&e.sha256===t.sha256,fi=async(e,t)=>{try{return await U(e)}catch{throw new Error(`${t} is malformed; no configuration was changed`)}},EF=e=>{try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}},RI=async e=>{let t=SF(e),n=kF(t,"owner.json");await gg(Sg(t),{recursive:!0,mode:448});for(let r=0;r<2;r++){let o=AI();try{await gg(t,{mode:448})}catch(s){if(s.code!=="EEXIST")throw s;let i=!1;try{let c=await fi(n,"ownership journal");if(typeof c.pid!="number"||!Number.isSafeInteger(c.pid)||c.pid<=0)throw new Error("lock owner is missing or invalid");let l=Date.now()-(await mI(n)).mtimeMs;i=!EF(c.pid)||l>wI}catch{try{i=Date.now()-(await mI(t)).mtimeMs>wI}catch{i=!1}}if(!i||r>0)throw new Error("ownership transaction already in progress");await zn(t,{recursive:!0,force:!0});continue}try{await re(n,{pid:process.pid,nonce:o,createdAt:Date.now()},{backup:!1})}catch(s){throw await zn(t,{recursive:!0,force:!0}).catch(()=>{}),s}let a=setInterval(()=>{(async()=>{try{if((await fi(n,"ownership journal")).nonce!==o)return;let i=new Date;await bF(n,i,i)}catch{}})()},AF);return a.unref(),async()=>{clearInterval(a);try{(await fi(n,"ownership journal")).nonce===o&&await zn(t,{recursive:!0,force:!0})}catch{}}}throw new Error("ownership transaction already in progress")},OI=async e=>{let t=await _(e),n={};if(t)try{n=await U(e)}catch{throw new Error("configuration is malformed during ownership recovery; it was left unchanged")}return{exists:t,value:n,fingerprint:bg(t,n)}},_I=async(e,t)=>{let n=xI(t);if(!await _(n))return;let r=await fi(n,"prepared ownership transaction");if(!IF(r))throw new Error("prepared ownership transaction is invalid; no recovery write was attempted");let o=await OI(e),a=await _(t),s=await _(jo(e)),i=Cg(o.fingerprint,r.before),c=Cg(o.fingerprint,r.after),l=r.journal.fileExisted;if(c&&(a||l===!1||s)&&(!i||a||s)){await re(t,r.journal,{backup:!1}),await zn(n,{force:!0});return}if(i){await zn(n,{force:!0}),a||await le(e);return}throw new Error("configuration changed during an interrupted ownership transaction; recovery files were preserved")},kp=async(e,t,n)=>{let r=await RI(t);try{return await _I(e,t),await n()}finally{await r()}},kI=async(e,t,n,r)=>{if(!await _(e)){if(n)throw new Error("journaled JSON rollback found a missing prior file");return}let a=await fi(e,"ownership journal");if(!(n&&pi(a,t))){if(!pi(a,r))throw new Error("journaled JSON rollback found a concurrent file edit");n?await re(e,t,{backup:!1}):await zn(e,{force:!0})}},Cp=async(e,t={})=>{let{configPath:n,current:r,next:o,journalPath:a,journal:s,fileExisted:i}=e,c=await RI(a);try{await _I(n,a);let l=await OI(n),d=bg(i,r),u=await _(a),p=u?await fi(a,"ownership journal"):void 0,f=p&&typeof p.fileExisted=="boolean"?{...s,fileExisted:p.fileExisted}:s;if(!Cg(l.fingerprint,d)){if(pi(l.value,o)&&p&&pi(p,f))return;throw new Error("configuration changed before the ownership transaction acquired its lock; retry")}if(l.exists&&pi(l.value,o)&&p&&pi(p,f))return;let m=await _(jo(n));if(p?.fileExisted===!0&&!m)throw new Error("ownership backup is missing; configuration was left unchanged");if(m&&!p)throw new Error("an unjournaled ownership backup already exists; configuration was left unchanged");let h=xI(a),g={transactionVersion:EI,before:l.fingerprint,after:bg(!0,o),journal:f};await re(h,g,{backup:!1});try{await re(n,o,p?{backup:!1}:{tombstoneAbsent:!1}),await(t.writeJournal??re)(a,f,{backup:!1}),await zn(h,{force:!0})}catch(y){try{await kI(n,l.value,l.exists,o)}catch(w){throw new AggregateError([y,w],"ownership journal publication failed and config rollback was incomplete")}try{await kI(a,p??{},u,f),await zn(h,{force:!0}),!m&&!p&&await le(n)}catch(w){throw new AggregateError([y,w],"ownership journal publication failed after config rollback")}throw y}}finally{await c()}},Va=async e=>{try{return await U(jo(e))}catch{return{}}},le=async e=>{await zn(jo(e),{force:!0}).catch(()=>{})}});var El,PI,xF,TI,Xt,ao=W(()=>{"use strict";El=e=>{let t=e.enrolledCert?.payload.keyTtlSeconds;return typeof t=="number"&&Number.isFinite(t)&&t>0?t*1e3:void 0},PI=new Set(["claude-code","codex","opencode","cursor","copilot","copilot-cli","claude-desktop","jetbrains","windsurf","omp"]),xF=10080*60*1e3,TI=(e,t,n=Date.now())=>{let r=[],o=El(e);o!==void 0&&r.push(o);let a=Date.parse(t??e.clientKeyExpiresAt??"");Number.isFinite(a)&&r.push(a-n);let s=Date.parse(e.enrolledCertExpiry??e.enrolledCert?.payload.expiresAt??"");return Number.isFinite(s)&&r.push(s-n),r.length===0?!1:Math.min(...r)<=xF},Xt=(e,t={},n=Date.now())=>{if(!e.enrolledCert)return!1;let o=(t.toolIds??e.managedTools??[]).some(a=>PI.has(a));return TI(e,t.keyExpiresAt,n)||!o}});import{delimiter as RF,dirname as OF}from"node:path";var yr,Za,mn,qn=W(()=>{"use strict";ht();yr=e=>{let{command:t,args:n}=_n([e]);return{command:t,args:n}},Za=()=>Ka(),mn=(e="",t=process.env.PATH??"",n=Ap(),r=Ka())=>{let a=t.split(RF).filter(Boolean).some(s=>s===n)||OF(r)!==n?"anyray-connect":r;return e?`${a} ${e}`:a}});var vp,Pn,Eg,NI,_F,gr,hi,xl,xg,Ig,PF,TF,NF,LI,so=W(()=>{"use strict";vp="anyray-org",Pn="x-anyray-api-key",Eg=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),NI=e=>{try{return new URL(e).origin}catch{return}},_F=(e,t)=>{if(!Eg(e)||typeof e.url!="string")return!1;try{let n=new URL(e.url);return t.includes(n.origin)&&/\/mcp\/org\/?$/.test(n.pathname)}catch{return!1}},gr=(e,t,n,r)=>{let o=e[t];if(o!==void 0&&!Eg(o))return"conflict";let a=Eg(o)?o:{},s=a[vp];return s!==void 0&&!_F(s,n)?"conflict":r===void 0?s===void 0?"unchanged":(delete a[vp],Object.keys(a).length===0?delete e[t]:e[t]=a,"changed"):JSON.stringify(s)===JSON.stringify(r)?"unchanged":(a[vp]=r,e[t]=a,"changed")},hi="# >>> anyray org mcp >>>",xl="# <<< anyray org mcp <<<",xg=`[mcp_servers.${vp}]`,Ig=e=>JSON.stringify(e),PF=e=>[xg,`url = ${Ig(e.url)}`,`http_headers = { ${Ig(Pn)} = ${Ig(e.clientKey)} }`],TF=new RegExp(`\\n?${hi.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}[\\s\\S]*?${xl.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\n?`),NF=e=>{let t=e.indexOf(hi);if(t<0||e.indexOf(xl,t+hi.length)>=0)return e;let n=e.slice(t).split(`
|
|
7
7
|
`),r=1,o=!1,a=!1;for(;r<n.length;){let s=n[r].trim();if(s===xg){if(o)break;o=!0,r+=1;continue}if(s.startsWith("[")||(s.includes(Pn)&&(a=!0),s!==""&&!s.startsWith("#")&&!/^[\w."'-]+\s*=/.test(s)))break;r+=1}return!o||!a?e:e.slice(0,t)+n.slice(r).join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anyray-connect",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.225",
|
|
4
4
|
"description": "Anyray connect \u2014 points local coding tools (Claude Code, Cursor, Windsurf, SDKs) at the Anyray gateway through supported configuration and enrolled personal authentication.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|