anyray-connect 0.11.161 → 0.11.162
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
|
@@ -5,7 +5,7 @@ var yO="http://localhost:8787",cs="anyray-placeholder",_e=e=>{let t=e?.trim();re
|
|
|
5
5
|
`,{mode:384})}catch(a){throw await Zr(e,{recursive:!0,force:!0}).catch(()=>{}),a}return async()=>{try{JSON.parse(await us(t,"utf-8")).nonce===r&&await Zr(e,{recursive:!0,force:!0})}catch{}}}catch(a){if(a.code!=="EEXIST")throw a}if(!(await WO(e).catch(()=>!1)&&await Zr(e,{recursive:!0,force:!0}).then(()=>!0).catch(()=>!1))){if(Date.now()>=n)throw new Error("connect profile is busy; retry the command");await new Promise(a=>setTimeout(a,FO))}}},sw=async e=>{let t=Object.fromEntries(Object.entries(e).filter(([,o])=>o!==void 0)),n=await Ko(),r=`${n}.${process.pid}.${$O++}.tmp`;await Ic(r,`${JSON.stringify(t,null,2)}
|
|
6
6
|
`,{mode:384}),await rp(r,384);try{await ye(r,n)}catch(o){throw await Zr(r,{force:!0}).catch(()=>{}),o}},ne=async e=>{let t=await aw();try{await sw(e)}finally{await t()}},iw=async e=>{let t=await aw();try{let n=await D(),{next:r,result:o}=e(n);return r&&await sw(r),o}finally{await t()}},np=["clientKey","clientKeyExpiresAt","enrolledCert","enrolledCertExpiry","enrolledCertLifetimeMs","enrolledTokenHash"],nw="ssoLink",sp=async()=>{let e=await D();return np.some(t=>e[t]!==void 0)?!0:await He()!==void 0},Rc=async()=>{let e=await D(),t=np.some(a=>e[a]!==void 0),n=e[nw]!==void 0,r=e.byoUpstream!==void 0,o=await He()!==void 0;if(!t&&!n&&!r&&!o)return!1;if(t||n||r){let a={...e};for(let s of np)delete a[s];delete a[nw],delete a.byoUpstream,delete a.anyrayFleetManaged,await ne(a)}if(await ps(),await He())throw new Error(`could not remove the dev key from ${Q()}`);return!0},cw=["fallback-bundle.enc","fallback-key","fallback-usage-queue.jsonl"],Oc=async()=>{let e=Q();for(let t of cw)await Zr(Ln(e,t),{force:!0}).catch(()=>{})},ip=async()=>{let e=Q(),t=[];for(let n of cw){let r=Ln(e,n);try{await LO(r),t.push(r)}catch{}}return t},sr=async(e,t,n=!1)=>{let r=await D(),o=new Set(r.managedTools??[]),a=new Set(r.revertedTools??[]),s=r.offboardedAt;for(let h of e){let m=h.status==="configured"||h.status==="queued";!t&&m&&(o.add(h.id),a.delete(h.id),s=void 0),t&&(h.status==="reverted"||h.status==="queued")&&(o.delete(h.id),a.add(h.id))}n&&o.clear();let i=[...o].sort(),c=[...r.managedTools??[]].sort(),l=[...a].sort(),d=[...r.revertedTools??[]].sort();if(i.length===c.length&&i.every((h,m)=>h===c[m])&&r.revertedTools!=null&&l.length===d.length&&l.every((h,m)=>h===d[m])&&s===r.offboardedAt)return;let{offboardedAt:f,...p}=r;await ne({...p,...s!==void 0?{offboardedAt:s}:{},managedTools:i,revertedTools:l})},Tc=async(e=new Date().toISOString())=>{await ne({...await D(),offboardedAt:e})};var jo=e=>zO(e).replace(/\\/g,"/").toLowerCase(),lp=(e=process.platform)=>e==="win32"?"anyray-connect.exe":"anyray-connect",hs=e=>`${e}.source`,fw=e=>/(^|\/)_npx(\/|$)/.test(jo(e)),up=e=>/(^|\/)node_modules\/anyray-connect\/dist\/index\.js$/.test(jo(e)),pp=e=>{let t=jo(e),n=[XO(),"/tmp","/private/tmp","/var/folders","/private/var/folders"].map(jo);return fw(t)||n.some(r=>t===r||t.startsWith(`${r}/`))},yt=()=>({execPath:process.execPath,scriptPath:process.argv[1]}),ms=e=>/[\\/](node|node\.exe)$/i.test(e),ir=(e=yt())=>ms(e.execPath)&&e.scriptPath?e.scriptPath:e.execPath,dw=e=>{try{let t=uw(e);return t.isFile()?t.size:void 0}catch{return}},fp=e=>{let t=Ke(e);if(Vo(t)==="versions")return t;let n=Ke(t);return Vo(n)==="versions"?n:void 0},Pc=(e,t)=>t!==void 0&&(Ke(e)===t||Ke(Ke(e))===t),qO=e=>{let t=fp(e);if(!t)return;let n=Pe(Ke(t),"bin",lp());try{let r=fs(n);return r===fs(e)||Pc(r,fs(t))?n:void 0}catch{return}},Yo=(e=Q(),t=process.platform)=>{let n=Pe(e,"bin",lp(t));try{let r=fs(n),o=fs(Pe(e,"versions"));if(Pc(r,o))return n;if(t==="win32"){let a=KO(hs(n),"utf8").trim();if(!/^[0-9A-Za-z.-]+$/.test(a))return;let s=dw(Pe(o,a,lp(t)))??dw(Pe(o,a));if(s!==void 0&&s===uw(n).size)return n}}catch{return}},Jr=(e=yt())=>{let t=ir(e),n=up(t)||mp(t)?Yo():void 0;return qO(e.execPath)??n??t},hw=(e=yt())=>Jr(e)!==ir(e),hn=(e,t=yt())=>{let n=Jr(t);return ms(t.execPath)&&t.scriptPath!==void 0&&n===ir(t)?{command:t.execPath,args:[n,...e],entryPath:n}:{command:n,args:e,entryPath:n}},mw=(e=yt())=>{let t=Jr(e);return!ms(e.execPath)&&!pp(t)?Ke(t):Pe(Q(),"bin")},_c=async e=>{try{return await VO(e),!0}catch{return!1}},QO=async e=>{let t=await YO(e),n=Ke(t),r=Ke(n),o=Pe(r,"package.json"),a=await dp(o,"utf8"),s=JSON.parse(a);if(typeof s.version!="string"||!/^[0-9A-Za-z][0-9A-Za-z.-]*$/.test(s.version))throw new Error("published package has no safe version");if(!await _c(Pe(n,"index.js")))throw new Error("published package is missing dist/index.js");return{root:r,dist:n,packageJson:o,version:s.version}},eT=async(e,t)=>{let n=t;for(;;){let r=Pe(n,"node_modules",e);if(await _c(Pe(r,"package.json")))return r;let o=Ke(n);if(o===n)return;n=o}},tT=async(e,t)=>{let n=new Set,r=[e];for(;r.length>0;){let o=r.shift(),a=JSON.parse(await dp(Pe(o,"package.json"),"utf8"));for(let s of Object.keys(a.dependencies??{})){if(n.has(s))continue;n.add(s);let i=await eT(s,o);if(!i)throw new Error(`runtime dependency "${s}" is not installed`);await pw(i,Pe(t,s),{recursive:!0}),r.push(i)}}},nT=async(e=yt())=>{let t=Yo();if(t)return{command:t,args:[],entryPath:t};if(!ms(e.execPath)||!e.scriptPath)return{command:e.execPath,args:[],entryPath:e.execPath};let n=await QO(e.scriptPath);await vt();let r=Pe(Q(),"bin",`connect-runtime-${n.version}`),o=Pe(r,"dist","index.js");if(!await _c(o)){let a=`${r}.stage-${process.pid}-${Date.now()}`;await cp(a,{recursive:!0,force:!0}),await lw(a,{recursive:!0,mode:448});try{await pw(n.dist,Pe(a,"dist"),{recursive:!0}),await JO(Pe(a,"package.json"),await dp(n.packageJson),{mode:384}),await tT(n.root,Pe(a,"node_modules")),await lw(Ke(r),{recursive:!0,mode:448});try{await ZO(a,r)}catch(s){if(!await _c(o))throw s}}finally{await cp(a,{recursive:!0,force:!0})}}return{command:e.execPath,args:[o],entryPath:o}},hp=/^connect-runtime-(?!.*\.stage-)[0-9A-Za-z][0-9A-Za-z.-]*$/,rT=e=>{let t=Vo(Ke(Ke(e)));return hp.test(t)?t:void 0},mp=(e,t=Q())=>{let n=Ke(Ke(e));return jo(Ke(n))===jo(Pe(t,"bin"))&&hp.test(Vo(n))&&Vo(Ke(e))==="dist"&&Vo(e)==="index.js"},Lc=async(e=yt())=>{let t=Pe(Q(),"bin"),n=rT(ir(e)),r=[];for(let o of await jO(t).catch(()=>[])){if(!hp.test(o)||o===n)continue;let a=Pe(t,o);await cp(a,{recursive:!0,force:!0}).then(()=>!0,()=>!1)&&r.push(a)}return r},yw=async(e,t=yt())=>{let n=ir(t);if(!ms(t.execPath)||!fw(n)||Yo())return;let r=await nT(t),o=GO(r.command,[...r.args,...e],{stdio:"inherit",env:process.env});if(o.error)throw o.error;return o.status??1};var yp=e=>/^[A-Za-z0-9_./:=-]+$/.test(e)?e:`"${e.replace(/"/g,'\\"')}"`,ys=(e,t)=>[e,...t].map(yp).join(" "),Dn=(e,t={})=>({...t.matcher!==void 0?{matcher:t.matcher}:{},hooks:[{type:"command",command:e,...t.timeout!==void 0?{timeout:t.timeout}:{},...t.async!==void 0?{async:t.async}:{}}]}),cr=(e,t)=>{if(e===null||typeof e!="object")return!1;let n=e.hooks;return Array.isArray(n)&&n.some(r=>r!==null&&typeof r=="object"&&typeof r.command=="string"&&r.command.includes(t))},Dc=(e,t,n,r,o="append")=>{let a=e.hooks??{},i=(Array.isArray(a[t])?a[t]:[]).filter(c=>!cr(c,n));a[t]=o==="prepend"?[r,...i]:[...i,r],e.hooks=a},Zo=(e,t,n)=>{let r=e.hooks;if(!r||!Array.isArray(r[t]))return!1;let o=r[t],a=o.filter(s=>!cr(s,n));return a.length===o.length?!1:(a.length?r[t]=a:delete r[t],Object.keys(r).length===0&&delete e.hooks,!0)},gp=e=>{let t=e.hooks;if(!t)return!1;let n=!1;for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let a=o.filter(s=>!cr(s,"__anyray-"));a.length!==o.length&&(n=!0,a.length?t[r]=a:delete t[r])}return n&&Object.keys(t).length===0&&delete e.hooks,n};var Je="__anyray-hook",gw="__anyray-codex-hook",lr="__anyray-prompt-hook",ww="__anyray-shell-pretool",wp="__anyray-shell-run",bw="__anyray-read-pretool",dr="__anyray-refresh",gs=(e,t=[])=>{let{command:n,args:r}=hn([e,...t]);return{command:n,args:r}},Nt=(e,t=[])=>{let n=gs(e,t);return[n.command,...n.args].map(yp).join(" ")},Nc=(e,t,n=[])=>typeof e=="string"&&e.trim()===Nt(t,n),kw=()=>Nt("print-key"),Le=()=>Jr(),$e=pp,de=()=>!$e(Le()),Xr=async()=>{if(!de())return!1;try{return await oT(Le()),!0}catch{return!1}},ur="__anyray-mcp-server",Ve=e=>gs(ur,[e]),aT=(e,t)=>Array.isArray(e)&&e.length===t.length&&e.every((n,r)=>n===t[r]),$c=(e,t)=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e,r=Ve(t);return n.command===r.command&&aT(n.args,r.args)},en=(e,t)=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;if(typeof n.command!="string"||!Array.isArray(n.args)||!n.args.every(o=>typeof o=="string"))return!1;let r=n.args;return(r.length===2||r.length===3)&&r.at(-2)===ur&&r.at(-1)===t};var X=(e,t)=>e.authMode==="subscription"?!0:e.authMode==="placeholder"?!1:e.seat?.[t]??!1,ue=e=>{let t=Object.entries(e).filter(([,n])=>n);if(t.length!==0)return JSON.stringify(Object.fromEntries(t))};var zr=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN","ANTHROPIC_CUSTOM_HEADERS","ENABLE_TOOL_SEARCH","_CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL"],Aw=["ENABLE_TOOL_SEARCH","_CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL"],Mc=[...zr,"CLAUDE_CODE_MAX_CONTEXT_TOKENS","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX"],sT=(e,t,n,r)=>{let o=[];return(t||r)&&(o.push("x-anyray-provider: anthropic"),o.push("x-anyray-auth-mode: passthrough"),r&&o.push(`x-anyray-custom-host: ${r}`),n&&o.push(`x-anyray-api-key: ${n}`)),e&&o.push(`x-anyray-metadata: ${e}`),o.join(`
|
|
7
7
|
`)},mn=(e,t={})=>{let n=e.byoUpstream,r=!n&&X(e,"anthropic"),o=ue({...e.metadata,tool:e.metadata.tool??"claude-code"}),a=t.includeClientKey!==!1&&!((r||n)&&e.viaLocalProxy),s=t.includeAuthToken!==!1,{contextWindowTokens:i}=t,c=sT(o,r,a?e.clientKey:void 0,n?.url);return{env:{ANTHROPIC_BASE_URL:e.anthropicBaseUrl,...c?{ANTHROPIC_CUSTOM_HEADERS:c}:{},...n&&s?{ANTHROPIC_AUTH_TOKEN:n.key}:{},...r||n||!s?{}:{ANTHROPIC_AUTH_TOKEN:e.clientKey??e.placeholderKey},...n?{}:{ENABLE_TOOL_SEARCH:"true"},...n?{}:{_CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL:"1"},...i!==void 0?{CLAUDE_CODE_MAX_CONTEXT_TOKENS:String(i)}:{}},subscription:r,byoUpstream:!!n,meta:o,headers:c}};import{z as bp}from"zod";var iT=5e3,cT=1e3,lT=1e8,dT=bp.object({modelContext:bp.object({contextTokens:bp.number().int().min(cT).max(lT)}).optional()}),Cw=e=>{let t=e.model;if(typeof t!="string")return;let n=t.trim();return n.length>0?n:void 0},vw=async(e,t,n,r={})=>{if(!t||!n)return;let o=r.timeoutMs??iT,a=new AbortController,s=setTimeout(()=>a.abort(),o);try{let i=`${e}/connect/policy?model=${encodeURIComponent(n)}`,c=await fetch(i,{method:"GET",headers:{"x-anyray-api-key":t},signal:a.signal});if(!c.ok)return;let l=dT.safeParse(await c.json());return l.success?l.data.modelContext?.contextTokens:void 0}catch{return}finally{clearTimeout(s)}};var uT=1e6,ws="[1m]",pT=e=>{let t=e.trim().toLowerCase();return!(t.startsWith("claude-")||t.split(/[/.]/).some(r=>r.startsWith("claude-")))},Sw=(e,t)=>!e||t===void 0?{}:pT(e)?{envTokens:t}:t<uT?{}:e.toLowerCase().endsWith(ws)?{}:{model:`${e}${ws}`},Ew=(e,t)=>{if(!(!e||!e.toLowerCase().endsWith(ws))&&typeof t=="string"&&!t.trim().toLowerCase().endsWith(ws))return e.slice(0,-ws.length)};import{platform as fT}from"node:os";var $t=(e=fT())=>{switch(e){case"darwin":return"/Library/Application Support/ClaudeCode/managed-settings.json";case"win32":return"C:\\Program Files\\ClaudeCode\\managed-settings.json";default:return"/etc/claude-code/managed-settings.json"}};var Nn=[{name:"CLAUDE_CODE_USE_BEDROCK",cloud:"AWS Bedrock"},{name:"CLAUDE_CODE_USE_VERTEX",cloud:"Google Vertex AI"}],Bc=e=>typeof e=="string"&&e.trim()!=="",hT=(e,t)=>typeof e[t]=="string"&&!Bc(e[t]),Iw=e=>{let t=e.env;return t&&typeof t=="object"&&!Array.isArray(t)?t:{}},mT=()=>F($t()).catch(()=>({})),xw=async(e={})=>{let t=e.env??process.env,n=Iw(e.userSettings??{}),r=Iw(await(e.readManaged??mT)().catch(()=>({}))),o=[];for(let{name:a,cloud:s}of Nn)Bc(r[a])?o.push({name:a,cloud:s,kind:"managed",source:`managed settings (${$t()})`,repairable:!1}):Bc(n[a])?o.push({name:a,cloud:s,kind:"userSettings",source:"~/.claude/settings.json env block",repairable:!0}):!hT(n,a)&&Bc(t[a])&&o.push({name:a,cloud:s,kind:"shell",source:"shell environment",repairable:!0});return o},kp=e=>`${e.name} is set (${e.source}) \u2014 Claude Code sends requests straight to ${e.cloud} and ignores the gateway routing written here, so none of its traffic reaches Anyray until that setting is removed`,Ap=e=>"Fix: remove the setting where it is set"+(e.some(t=>t.kind==="managed")?" (the managed settings file is IT-owned \u2014 ask your admin)":"")+", then restart Claude Code. The gateway can serve Bedrock/Vertex itself once its provider is configured \u2014 see the Bedrock page in the Anyray docs.",Rw=e=>`Disabled direct ${e.cloud} mode: ${e.name} was set (${e.source}), which would bypass the gateway route entirely \u2014 pinned it empty in settings.json (the env block outranks shell exports, and '' is Claude Code's documented unset). Delete the original setting to drop the pin.`;var yT=Nn.map(e=>e.name),gT=Mc.filter(e=>!yT.includes(e)),Ow=e=>typeof e=="string"&&e.trim()!=="",Tw=e=>{let t=e.env;return t&&typeof t=="object"&&!Array.isArray(t)?t:{}},wT=(e,t,n)=>{if(typeof e!="string"||typeof t!="string")return!1;let r=o=>n?o.trim().replace(/\/+$/,""):o.trim();return r(e)===r(t)},bT=e=>{if(typeof e=="string")try{return new URL(e.trim()).origin}catch{return}},Cp=()=>F($t()).catch(()=>({})),_w=Cp,kT=e=>{let t=e.hooks;if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=t.PostToolUse;return Array.isArray(n)&&n.some(r=>cr(r,Je))},Pw=async(e={})=>{let t=await(e.readManaged??_w)().catch(()=>({}));return t.disableAllHooks===!0?{state:"disabled"}:t.allowManagedHooksOnly===!0&&!kT(t)?{state:"restricted_dropping_ours"}:{state:"fine"}},Fc=e=>e.state==="disabled"?`disableAllHooks is true in managed settings (${$t()}) \u2014 Claude Code skips every hook and the status line, including Anyray's savings hook`:e.state==="restricted_dropping_ours"?`allowManagedHooksOnly is true in managed settings (${$t()}), but that file does not carry the Anyray PostToolUse hook \u2014 Claude Code silently drops the user-scope hook Connect installed`:"Claude Code managed hook policy allows the Anyray hook lane",Uc=e=>e.state==="disabled"?"Fix: ask the MDM owner to drop `disableAllHooks`, then restart Claude Code. Connect never overrides machine policy.":e.state==="restricted_dropping_ours"?"Fix: ask the MDM owner to drop `allowManagedHooksOnly`, or add the Anyray hooks to the managed file. `anyray-connect managed --print --sso <link> --bin <path>` emits the credential-free block; then restart Claude Code.":"No action required.",Lw=async(e={})=>{let t=Tw(e.userSettings??{}),n=Tw(await(e.readManaged??_w)().catch(()=>({}))),r=[];for(let o of gT){if(!Ow(n[o])||!Ow(t[o]))continue;let a=o==="ANTHROPIC_BASE_URL";if(wT(n[o],t[o],a))continue;let s=a?bT(n[o]):void 0;r.push({name:o,source:`managed settings (${$t()})`,routing:a,...s?{managedOrigin:s}:{}})}return r},Dw=e=>e.routing?`${e.name} is set to a different value (${e.source}), which outranks the routing written in settings.json \u2014 Claude Code sends its traffic to ${e.managedOrigin??"that endpoint"} instead, so none of it reaches Anyray until the managed value changes`:`${e.name} is set to a different value (${e.source}), which outranks the value written in settings.json \u2014 Claude Code uses the managed one, so the behavior this key controls is not the one connect configured`,Nw=e=>"Fix: the managed settings file is IT-owned \u2014 ask your admin to "+(e.some(t=>t.routing)?"point it at the Anyray gateway (`anyray-connect managed --print` emits the block to deploy) or drop the key so per-user setup governs":"drop the key so per-user setup governs")+", then restart Claude Code.";import{homedir as AT}from"node:os";import{join as CT}from"node:path";import{readFile as vT}from"node:fs/promises";var rt=e=>!!e.keyRefreshEnabled;var ST=400,$w=async()=>{try{let e=CT(AT(),".claude","settings.json"),n=JSON.parse(await vT(e,"utf-8"))?.env,r=n?.ANTHROPIC_BASE_URL;if(!r)return null;let o=new URL(r).origin,a=n?.ANTHROPIC_CUSTOM_HEADERS??"",s=l=>{for(let d of a.split(`
|
|
8
|
-
`)){let u=d.indexOf(":");if(u>0&&d.slice(0,u).trim().toLowerCase()===l)return d.slice(u+1).trim()}},i=s("x-anyray-api-key"),c=n?.ANTHROPIC_AUTH_TOKEN;return{origin:o,metadata:s("x-anyray-metadata"),apiKey:i||(c?.startsWith("ark_")?c:void 0)}}catch{return null}},Mw=async()=>{try{let e=await D();return e.gateway?{origin:new URL(e.gateway).origin,metadata:ue({user:e.name,team:e.team}),apiKey:e.clientKey}:null}catch{return null}},ot=async(e="auto")=>e==="profile"?Mw():e==="claude"?$w():await $w()??await Mw(),Hc=async(e={})=>{let t=e.readTarget??ot,n=e.loadProfile??D,r;try{r=await n()}catch{return"unreadable"}if(!r.gateway)return"unreadable";let o;try{o=await t("claude")}catch{return"unreadable"}if(!o)return"missing";let a=new Set;try{a.add(new URL(r.gateway).origin)}catch{return"unreadable"}return rt(r)&&r.fallbackPort&&a.add(`http://${mt}:${r.fallbackPort}`),a.has(o.origin)?"owned":"foreign"},tn=e=>{let t={"content-type":"application/json"};return e.metadata&&(t["x-anyray-metadata"]=e.metadata),e.apiKey&&(t["x-anyray-api-key"]=e.apiKey),t},Wc=async(e,t,n,r)=>{if(!e)return;let o=new AbortController,a=setTimeout(()=>o.abort(),ST);try{await fetch(`${e.origin}/connect/hook-savings`,{method:"POST",headers:tn(e),body:JSON.stringify({source:t,...r?{tool:r}:{},...n}),signal:o.signal})}catch{}finally{clearTimeout(a)}};var $n=()=>Kc(Gc(),".claude","settings.json"),bs=()=>Kc(Gc(),".claude.json"),ET=Mc,pr="anyray",IT=()=>({type:"stdio",...Ve("claude"),alwaysLoad:!0}),qr=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),xT=e=>{if("mcpServers"in e&&!qr(e.mcpServers))return"conflict";let t=qr(e.mcpServers)?{...e.mcpServers}:{},n=t[pr];return n!==void 0&&!en(n,"claude")?"conflict":(t[pr]=IT(),e.mcpServers=t,"installed")},Bw=e=>{let t=e.mcpServers;return!t||!(pr in t)||!en(t[pr],"claude")?!1:(delete t[pr],Object.keys(t).length===0&&delete e.mcpServers,!0)},RT=e=>{Dc(e,"PostToolUse",Je,Dn(Nt(Je),{matcher:"*"})),Dc(e,"UserPromptSubmit",lr,Dn(Nt(lr)))},OT=e=>{Dc(e,"SessionStart",dr,Dn(Nt(dr),{async:!0}))},Hw=e=>Zo(e,"SessionStart",dr),Fw=e=>{let t=Zo(e,"PostToolUse",Je),n=Zo(e,"UserPromptSubmit",lr),r=Hw(e);return t||n||r},TT="print-key",_T=e=>e.includes("anyray-connect")||e.includes("connect-runtime")||e.includes(Le()),Qr=e=>{let t=e.apiKeyHelper;if(typeof t!="string")return!1;let n=t.trim().split(/\s+/);return n[n.length-1]===TT&&_T(t)},PT=async(e,t)=>{let n=(await Yr(e)).env,r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},o=[];for(let a of ET){let s=r[a];typeof s=="string"?(t[a]=s,o.push(a)):delete t[a]}return o},LT=e=>typeof e.apiKeyHelper=="string"&&!Qr(e),Ww=async e=>{let t=await Cp(),n=async()=>t,[r,o,a]=await Promise.all([xw({userSettings:e,readManaged:n}),Lw({userSettings:e,readManaged:n}).catch(()=>[]),Pw({readManaged:n})]);return{directOverrides:r,managedOverrides:o,hookPolicy:a}},Uw=async e=>{let{directOverrides:t,managedOverrides:n,hookPolicy:r}=await Ww(e),o=Ap(t),a=Nw(n);return{routingOverrides:[...t.map(i=>({problem:kp(i),fix:i.repairable?"Fix: run `anyray-connect doctor --repair` (or re-run `anyray-connect`) \u2014 apply disables this switch by pinning it empty in settings.json.":o,repairable:i.repairable})),...n.map(i=>({problem:Dw(i),fix:a,repairable:!1,bypass:i.routing}))],claudeCodeHookPolicy:r.state}},fr={id:"claude-code",title:"Claude Code",automatic:!0,async detect(){let e=Kc(Gc(),".claude"),t=await R(e);return{installed:t,detail:t?$n():"no ~/.claude directory"}},async apply(e,t){let n=$n(),r=await F(n),o=Cw(r),a=await vw(e.origin,e.clientKey,o),s=Sw(o,a),{env:i,subscription:c,byoUpstream:l,meta:d,headers:u}=mn(e,{contextWindowTokens:s.envTokens}),{directOverrides:f,hookPolicy:p}=await Ww(r),h=f.filter(x=>!x.repairable),m=f.filter(x=>x.repairable),w=[...h.map(x=>`WARNING: ${kp(x)}.`),...h.length?[Ap(h)]:[],...p.state==="fine"?[]:[`WARNING: ${Fc(p)}.`,Uc(p)],...m.map(x=>Rw(x)),`${n} \u2192 env.ANTHROPIC_BASE_URL = ${e.anthropicBaseUrl}`,l?`BYO-upstream mode: your personal upstream key passes through the gateway to ${e.byoUpstream.url} (never the org key).${e.clientKey?" Your personal gateway key rides x-anyray-api-key.":""}`:c?`Subscription mode: Claude Code keeps your seat sign-in; its OAuth token passes through the gateway (never stored).${e.clientKey?" Your personal gateway key rides x-anyray-api-key.":""}`:e.clientKey?"Auth: personal gateway key (not shown here; see below for where it lives)":"Auth: placeholder token (gateway swaps in the server-held key)",`Attribution: ${d??"(none)"}`,...l?[]:["Restored on-demand MCP tool loading (env.ENABLE_TOOL_SEARCH) that Claude Code otherwise disables behind a non-first-party gateway. Deferred servers stay out of context until used; the first-party AnyRay retrieval server stays always loaded so capability is visible per request."],...s.envTokens!==void 0?[`Context window: env.CLAUDE_CODE_MAX_CONTEXT_TOKENS = ${s.envTokens} \u2014 your model's real window, so Claude Code stops budgeting the 200k it assumes behind any custom base URL.`]:[],...s.model!==void 0?[`Context window: model = ${s.model} \u2014 same model, its long-context variant. Claude Code ignores CLAUDE_CODE_MAX_CONTEXT_TOKENS for claude-* ids, so the [1m] alias is what actually gets you your ${a} window back instead of the 200k it assumes behind any custom base URL. A --model flag on your launch command, or picking a model in-app, overrides this \u2014 add [1m] there too (quote it in zsh).`]:[],"Claude Code settings.json routing covers the CLI and VS Code extension. Claude Desktop is separate: its verified macOS automatic setup supports either the Claude Code subscription-backed Gateway lane or API billing; other Desktop lanes fail closed or use the documented API setup.","Restart Claude Code (or open a new session) to pick up the change."];if(t.dryRun)return{status:"configured",messages:w};s.model!==void 0&&(r.model=s.model);let y=r.env??{};r.env={...y,...i};let g=r.env;for(let{name:x}of Nn)m.some(P=>P.name===x)?g[x]="":g[x]===""&&(process.env[x]??"").trim()===""&&delete g[x];if(u||delete g.ANTHROPIC_CUSTOM_HEADERS,c&&(y.ANTHROPIC_AUTH_TOKEN&&w.push("Removed env.ANTHROPIC_AUTH_TOKEN \u2014 it would override your subscription sign-in."),delete g.ANTHROPIC_AUTH_TOKEN),l)for(let x of Aw)delete g[x];let b=!!e.clientKey,C=de(),S=LT(r);!c&&!l&&b&&C&&!S?(r.apiKeyHelper=kw(),g.ANTHROPIC_AUTH_TOKEN="",w.push("Installed an apiKeyHelper that reprints a fresh gateway key on demand \u2014 Claude Code refreshes it at startup and on any 401, so an idle session no longer 401s (no re-enrollment).")):Qr(r)&&delete r.apiKeyHelper,S&&!c&&!l&&b&&C&&w.push("Kept your existing apiKeyHelper; your gateway key stays in ANTHROPIC_AUTH_TOKEN (Anyray auto-refresh via the helper is off)."),(c||l)&&b&&C?(OT(r),w.push("Installed a SessionStart hook that refreshes your gateway key each session, so an idle subscription session no longer needs re-enrollment.")):Hw(r),de()?(RT(r),w.push("Installed a PostToolUse hook (trims oversized tool outputs, cache-safe) and a UserPromptSubmit hook (beacons oversized pasted-data prompts) \u2014 both content-free.")):(Fw(r),w.push(`Skipped the Anyray hooks \u2014 anyray-connect is running from a temporary path (${Le()}). Re-run via the installer (it persists the binary under ~/.anyray/bin) or a global install to enable cache-safe trimming and paste-savings beacons.`)),await Z(n,r);let I=[n],A=bs();try{let x=await F(A),P=!1;de()?xT(x)==="conflict"?w.push(`MCP name conflict in ${A}: mcpServers.${pr} is not owned by Anyray Connect, so it was left untouched.`):(P=!0,w.push("Registered the Anyray retrieval MCP server (anyray_retrieve) for explicit recovery of stashed context \u2014 always loaded so retrieval capability is visible on every request.")):P=Bw(x),P&&(await Z(A,x),I.push(A))}catch(x){w.push(`Could not register the Anyray MCP server in ${A} (${x instanceof Error?x.message:String(x)}); retrieval via anyray_retrieve is unavailable until this is fixed.`)}return{status:"configured",messages:w,changedFiles:I}},skillsDir(){return Kc(Gc(),".claude","skills")},async watchPaths(){return[$n(),bs()]},async pointsAt(e){let t=$n();if(!await R(t))return!1;try{let o=(await F(t)).env?.ANTHROPIC_BASE_URL;return typeof o=="string"&&o.replace(/\/+$/,"")===e}catch{return!1}},async runtimeDiagnostics(){let e=await F($n()).catch(()=>({}));return Uw(e)},async routingOverrides(){let e=await F($n()).catch(()=>({}));return(await Uw(e)).routingOverrides},async mcpStatus(){let e=bs();if(!await R(e))return{registered:!1,command:null};try{let r=(await F(e)).mcpServers?.[pr];return!r||!en(r,"claude")?{registered:!1,command:null}:{registered:!0,command:typeof r.command=="string"?r.command:null}}catch{return{registered:!1,command:null}}},async integrationStatus(){let e,t=!0,n=$n();if(!await R(n))e="missing";else try{let s=await F(n);if(s.hooks===void 0)e="missing";else if(!qr(s.hooks))e="unreadable";else{let i=s.hooks.PostToolUse;e=i===void 0?"missing":Array.isArray(i)?i.some(c=>cr(c,Je))?"owned":"missing":"unreadable",e==="owned"&&Array.isArray(i)&&(t=i.some(c=>cr(c,Je)&&qr(c)&&Array.isArray(c.hooks)&&c.hooks.some(l=>qr(l)&&Nc(l.command,Je))))}}catch{e="unreadable"}let r,o=!0,a=bs();if(!await R(a))r="missing";else try{let s=await F(a);if(s.mcpServers===void 0)r="missing";else if(!qr(s.mcpServers))r="unreadable";else{let i=s.mcpServers[pr];r=i===void 0?"missing":en(i,"claude")?"owned":"foreign",r==="owned"&&(o=$c(i,"claude"))}}catch{r="unreadable"}return{hook_registration:e,mcp_registration:r,hook_binary:t&&o&&await Xr()?"owned":"missing",beacon_target:await Hc().catch(()=>"unreadable")}},async inferenceAuthLanes(){try{let e=await F($n()),t=qr(e.env)?e.env:{},n=typeof t.ANTHROPIC_CUSTOM_HEADERS=="string"?t.ANTHROPIC_CUSTOM_HEADERS:"";if(/^x-anyray-custom-host:/m.test(n))return["byo"];if(/^x-anyray-auth-mode:\s*passthrough$/m.test(n))return["subscription"];if(typeof t.ANTHROPIC_AUTH_TOKEN=="string"||typeof e.apiKeyHelper=="string")return["api_key"]}catch{}return["unknown"]},async revert(e){let t=$n();if(!await R(t))return{status:"not-found",messages:["nothing to revert"]};if(e.dryRun)return{status:"reverted",messages:[`would remove Anyray keys from ${t}`]};let n=await F(t),r=n.env,o=Fw(n),a=Qr(n);a&&delete n.apiKeyHelper;let s=r?await PT(t,r):[],i=Ew(typeof n.model=="string"?n.model:void 0,(await Yr(t)).model);i!==void 0&&(n.model=i),r&&Object.keys(r).length===0&&delete n.env,(r||o||a||i!==void 0)&&await Z(t,n,{backup:!1});let c=[`removed Anyray keys from ${t}`];i!==void 0&&c.push(`Put model back to ${i} \u2014 dropped the [1m] alias Anyray added for your context window.`),o&&c.push("Removed the Anyray PostToolUse, UserPromptSubmit, and SessionStart hooks."),a&&c.push("Removed the Anyray apiKeyHelper."),s.length&&c.push(`Put back the ${s.join(" and ")} you had set before Anyray.`);let l=bs();try{let d=await F(l);Bw(d)&&(await Z(l,d,{backup:!1}),c.push("Removed the Anyray retrieval MCP server (anyray_retrieve)."))}catch{}return await se(t),{status:"reverted",messages:c,changedFiles:[t]}}};var Ae="0.11.161";var yn=e=>{let{command:t,args:n}=hn([e]);return{command:t,args:n}},gn=()=>Jr();import{homedir as vp,platform as Sp}from"node:os";import{join as Vc}from"node:path";import{mkdir as NT,rm as Kw,writeFile as $T,link as MT,copyFile as BT,readFile as FT}from"node:fs/promises";import{spawnSync as UT}from"node:child_process";import{homedir as Gw,userInfo as DT}from"node:os";var hr=()=>{try{return Gw()!==DT().homedir}catch{return!1}},Jo=e=>[`Skipped ${e} \u2014 HOME (${Gw()}) is not this account's home directory.`,"The OS registers a per-user service against the account, not against HOME, so","one installed from here would point at a path the real login session cannot use."];var As="ai.anyray.connect.app",ks="Anyray",Vw=(e=vp())=>Vc(e,"Applications",`${ks}.app`),jw="anyray-connect",HT=e=>`<?xml version="1.0" encoding="UTF-8"?>
|
|
8
|
+
`)){let u=d.indexOf(":");if(u>0&&d.slice(0,u).trim().toLowerCase()===l)return d.slice(u+1).trim()}},i=s("x-anyray-api-key"),c=n?.ANTHROPIC_AUTH_TOKEN;return{origin:o,metadata:s("x-anyray-metadata"),apiKey:i||(c?.startsWith("ark_")?c:void 0)}}catch{return null}},Mw=async()=>{try{let e=await D();return e.gateway?{origin:new URL(e.gateway).origin,metadata:ue({user:e.name,team:e.team}),apiKey:e.clientKey}:null}catch{return null}},ot=async(e="auto")=>e==="profile"?Mw():e==="claude"?$w():await $w()??await Mw(),Hc=async(e={})=>{let t=e.readTarget??ot,n=e.loadProfile??D,r;try{r=await n()}catch{return"unreadable"}if(!r.gateway)return"unreadable";let o;try{o=await t("claude")}catch{return"unreadable"}if(!o)return"missing";let a=new Set;try{a.add(new URL(r.gateway).origin)}catch{return"unreadable"}return rt(r)&&r.fallbackPort&&a.add(`http://${mt}:${r.fallbackPort}`),a.has(o.origin)?"owned":"foreign"},tn=e=>{let t={"content-type":"application/json"};return e.metadata&&(t["x-anyray-metadata"]=e.metadata),e.apiKey&&(t["x-anyray-api-key"]=e.apiKey),t},Wc=async(e,t,n,r)=>{if(!e)return;let o=new AbortController,a=setTimeout(()=>o.abort(),ST);try{await fetch(`${e.origin}/connect/hook-savings`,{method:"POST",headers:tn(e),body:JSON.stringify({source:t,...r?{tool:r}:{},...n}),signal:o.signal})}catch{}finally{clearTimeout(a)}};var $n=()=>Kc(Gc(),".claude","settings.json"),bs=()=>Kc(Gc(),".claude.json"),ET=Mc,pr="anyray",IT=()=>({type:"stdio",...Ve("claude"),alwaysLoad:!0}),qr=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),xT=e=>{if("mcpServers"in e&&!qr(e.mcpServers))return"conflict";let t=qr(e.mcpServers)?{...e.mcpServers}:{},n=t[pr];return n!==void 0&&!en(n,"claude")?"conflict":(t[pr]=IT(),e.mcpServers=t,"installed")},Bw=e=>{let t=e.mcpServers;return!t||!(pr in t)||!en(t[pr],"claude")?!1:(delete t[pr],Object.keys(t).length===0&&delete e.mcpServers,!0)},RT=e=>{Dc(e,"PostToolUse",Je,Dn(Nt(Je),{matcher:"*"})),Dc(e,"UserPromptSubmit",lr,Dn(Nt(lr)))},OT=e=>{Dc(e,"SessionStart",dr,Dn(Nt(dr),{async:!0}))},Hw=e=>Zo(e,"SessionStart",dr),Fw=e=>{let t=Zo(e,"PostToolUse",Je),n=Zo(e,"UserPromptSubmit",lr),r=Hw(e);return t||n||r},TT="print-key",_T=e=>e.includes("anyray-connect")||e.includes("connect-runtime")||e.includes(Le()),Qr=e=>{let t=e.apiKeyHelper;if(typeof t!="string")return!1;let n=t.trim().split(/\s+/);return n[n.length-1]===TT&&_T(t)},PT=async(e,t)=>{let n=(await Yr(e)).env,r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},o=[];for(let a of ET){let s=r[a];typeof s=="string"?(t[a]=s,o.push(a)):delete t[a]}return o},LT=e=>typeof e.apiKeyHelper=="string"&&!Qr(e),Ww=async e=>{let t=await Cp(),n=async()=>t,[r,o,a]=await Promise.all([xw({userSettings:e,readManaged:n}),Lw({userSettings:e,readManaged:n}).catch(()=>[]),Pw({readManaged:n})]);return{directOverrides:r,managedOverrides:o,hookPolicy:a}},Uw=async e=>{let{directOverrides:t,managedOverrides:n,hookPolicy:r}=await Ww(e),o=Ap(t),a=Nw(n);return{routingOverrides:[...t.map(i=>({problem:kp(i),fix:i.repairable?"Fix: run `anyray-connect doctor --repair` (or re-run `anyray-connect`) \u2014 apply disables this switch by pinning it empty in settings.json.":o,repairable:i.repairable})),...n.map(i=>({problem:Dw(i),fix:a,repairable:!1,bypass:i.routing}))],claudeCodeHookPolicy:r.state}},fr={id:"claude-code",title:"Claude Code",automatic:!0,async detect(){let e=Kc(Gc(),".claude"),t=await R(e);return{installed:t,detail:t?$n():"no ~/.claude directory"}},async apply(e,t){let n=$n(),r=await F(n),o=Cw(r),a=await vw(e.origin,e.clientKey,o),s=Sw(o,a),{env:i,subscription:c,byoUpstream:l,meta:d,headers:u}=mn(e,{contextWindowTokens:s.envTokens}),{directOverrides:f,hookPolicy:p}=await Ww(r),h=f.filter(x=>!x.repairable),m=f.filter(x=>x.repairable),w=[...h.map(x=>`WARNING: ${kp(x)}.`),...h.length?[Ap(h)]:[],...p.state==="fine"?[]:[`WARNING: ${Fc(p)}.`,Uc(p)],...m.map(x=>Rw(x)),`${n} \u2192 env.ANTHROPIC_BASE_URL = ${e.anthropicBaseUrl}`,l?`BYO-upstream mode: your personal upstream key passes through the gateway to ${e.byoUpstream.url} (never the org key).${e.clientKey?" Your personal gateway key rides x-anyray-api-key.":""}`:c?`Subscription mode: Claude Code keeps your seat sign-in; its OAuth token passes through the gateway (never stored).${e.clientKey?" Your personal gateway key rides x-anyray-api-key.":""}`:e.clientKey?"Auth: personal gateway key (not shown here; see below for where it lives)":"Auth: placeholder token (gateway swaps in the server-held key)",`Attribution: ${d??"(none)"}`,...l?[]:["Restored on-demand MCP tool loading (env.ENABLE_TOOL_SEARCH) that Claude Code otherwise disables behind a non-first-party gateway. Deferred servers stay out of context until used; the first-party AnyRay retrieval server stays always loaded so capability is visible per request."],...s.envTokens!==void 0?[`Context window: env.CLAUDE_CODE_MAX_CONTEXT_TOKENS = ${s.envTokens} \u2014 your model's real window, so Claude Code stops budgeting the 200k it assumes behind any custom base URL.`]:[],...s.model!==void 0?[`Context window: model = ${s.model} \u2014 same model, its long-context variant. Claude Code ignores CLAUDE_CODE_MAX_CONTEXT_TOKENS for claude-* ids, so the [1m] alias is what actually gets you your ${a} window back instead of the 200k it assumes behind any custom base URL. A --model flag on your launch command, or picking a model in-app, overrides this \u2014 add [1m] there too (quote it in zsh).`]:[],"Claude Code settings.json routing covers the CLI and VS Code extension. Claude Desktop is separate: its verified macOS automatic setup supports either the Claude Code subscription-backed Gateway lane or API billing; other Desktop lanes fail closed or use the documented API setup.","Restart Claude Code (or open a new session) to pick up the change."];if(t.dryRun)return{status:"configured",messages:w};s.model!==void 0&&(r.model=s.model);let y=r.env??{};r.env={...y,...i};let g=r.env;for(let{name:x}of Nn)m.some(P=>P.name===x)?g[x]="":g[x]===""&&(process.env[x]??"").trim()===""&&delete g[x];if(u||delete g.ANTHROPIC_CUSTOM_HEADERS,c&&(y.ANTHROPIC_AUTH_TOKEN&&w.push("Removed env.ANTHROPIC_AUTH_TOKEN \u2014 it would override your subscription sign-in."),delete g.ANTHROPIC_AUTH_TOKEN),l)for(let x of Aw)delete g[x];let b=!!e.clientKey,C=de(),S=LT(r);!c&&!l&&b&&C&&!S?(r.apiKeyHelper=kw(),g.ANTHROPIC_AUTH_TOKEN="",w.push("Installed an apiKeyHelper that reprints a fresh gateway key on demand \u2014 Claude Code refreshes it at startup and on any 401, so an idle session no longer 401s (no re-enrollment).")):Qr(r)&&delete r.apiKeyHelper,S&&!c&&!l&&b&&C&&w.push("Kept your existing apiKeyHelper; your gateway key stays in ANTHROPIC_AUTH_TOKEN (Anyray auto-refresh via the helper is off)."),(c||l)&&b&&C?(OT(r),w.push("Installed a SessionStart hook that refreshes your gateway key each session, so an idle subscription session no longer needs re-enrollment.")):Hw(r),de()?(RT(r),w.push("Installed a PostToolUse hook (trims oversized tool outputs, cache-safe) and a UserPromptSubmit hook (beacons oversized pasted-data prompts) \u2014 both content-free.")):(Fw(r),w.push(`Skipped the Anyray hooks \u2014 anyray-connect is running from a temporary path (${Le()}). Re-run via the installer (it persists the binary under ~/.anyray/bin) or a global install to enable cache-safe trimming and paste-savings beacons.`)),await Z(n,r);let I=[n],A=bs();try{let x=await F(A),P=!1;de()?xT(x)==="conflict"?w.push(`MCP name conflict in ${A}: mcpServers.${pr} is not owned by Anyray Connect, so it was left untouched.`):(P=!0,w.push("Registered the Anyray retrieval MCP server (anyray_retrieve) for explicit recovery of stashed context \u2014 always loaded so retrieval capability is visible on every request.")):P=Bw(x),P&&(await Z(A,x),I.push(A))}catch(x){w.push(`Could not register the Anyray MCP server in ${A} (${x instanceof Error?x.message:String(x)}); retrieval via anyray_retrieve is unavailable until this is fixed.`)}return{status:"configured",messages:w,changedFiles:I}},skillsDir(){return Kc(Gc(),".claude","skills")},async watchPaths(){return[$n(),bs()]},async pointsAt(e){let t=$n();if(!await R(t))return!1;try{let o=(await F(t)).env?.ANTHROPIC_BASE_URL;return typeof o=="string"&&o.replace(/\/+$/,"")===e}catch{return!1}},async runtimeDiagnostics(){let e=await F($n()).catch(()=>({}));return Uw(e)},async routingOverrides(){let e=await F($n()).catch(()=>({}));return(await Uw(e)).routingOverrides},async mcpStatus(){let e=bs();if(!await R(e))return{registered:!1,command:null};try{let r=(await F(e)).mcpServers?.[pr];return!r||!en(r,"claude")?{registered:!1,command:null}:{registered:!0,command:typeof r.command=="string"?r.command:null}}catch{return{registered:!1,command:null}}},async integrationStatus(){let e,t=!0,n=$n();if(!await R(n))e="missing";else try{let s=await F(n);if(s.hooks===void 0)e="missing";else if(!qr(s.hooks))e="unreadable";else{let i=s.hooks.PostToolUse;e=i===void 0?"missing":Array.isArray(i)?i.some(c=>cr(c,Je))?"owned":"missing":"unreadable",e==="owned"&&Array.isArray(i)&&(t=i.some(c=>cr(c,Je)&&qr(c)&&Array.isArray(c.hooks)&&c.hooks.some(l=>qr(l)&&Nc(l.command,Je))))}}catch{e="unreadable"}let r,o=!0,a=bs();if(!await R(a))r="missing";else try{let s=await F(a);if(s.mcpServers===void 0)r="missing";else if(!qr(s.mcpServers))r="unreadable";else{let i=s.mcpServers[pr];r=i===void 0?"missing":en(i,"claude")?"owned":"foreign",r==="owned"&&(o=$c(i,"claude"))}}catch{r="unreadable"}return{hook_registration:e,mcp_registration:r,hook_binary:t&&o&&await Xr()?"owned":"missing",beacon_target:await Hc().catch(()=>"unreadable")}},async inferenceAuthLanes(){try{let e=await F($n()),t=qr(e.env)?e.env:{},n=typeof t.ANTHROPIC_CUSTOM_HEADERS=="string"?t.ANTHROPIC_CUSTOM_HEADERS:"";if(/^x-anyray-custom-host:/m.test(n))return["byo"];if(/^x-anyray-auth-mode:\s*passthrough$/m.test(n))return["subscription"];if(typeof t.ANTHROPIC_AUTH_TOKEN=="string"||typeof e.apiKeyHelper=="string")return["api_key"]}catch{}return["unknown"]},async revert(e){let t=$n();if(!await R(t))return{status:"not-found",messages:["nothing to revert"]};if(e.dryRun)return{status:"reverted",messages:[`would remove Anyray keys from ${t}`]};let n=await F(t),r=n.env,o=Fw(n),a=Qr(n);a&&delete n.apiKeyHelper;let s=r?await PT(t,r):[],i=Ew(typeof n.model=="string"?n.model:void 0,(await Yr(t)).model);i!==void 0&&(n.model=i),r&&Object.keys(r).length===0&&delete n.env,(r||o||a||i!==void 0)&&await Z(t,n,{backup:!1});let c=[`removed Anyray keys from ${t}`];i!==void 0&&c.push(`Put model back to ${i} \u2014 dropped the [1m] alias Anyray added for your context window.`),o&&c.push("Removed the Anyray PostToolUse, UserPromptSubmit, and SessionStart hooks."),a&&c.push("Removed the Anyray apiKeyHelper."),s.length&&c.push(`Put back the ${s.join(" and ")} you had set before Anyray.`);let l=bs();try{let d=await F(l);Bw(d)&&(await Z(l,d,{backup:!1}),c.push("Removed the Anyray retrieval MCP server (anyray_retrieve)."))}catch{}return await se(t),{status:"reverted",messages:c,changedFiles:[t]}}};var Ae="0.11.162";var yn=e=>{let{command:t,args:n}=hn([e]);return{command:t,args:n}},gn=()=>Jr();import{homedir as vp,platform as Sp}from"node:os";import{join as Vc}from"node:path";import{mkdir as NT,rm as Kw,writeFile as $T,link as MT,copyFile as BT,readFile as FT}from"node:fs/promises";import{spawnSync as UT}from"node:child_process";import{homedir as Gw,userInfo as DT}from"node:os";var hr=()=>{try{return Gw()!==DT().homedir}catch{return!1}},Jo=e=>[`Skipped ${e} \u2014 HOME (${Gw()}) is not this account's home directory.`,"The OS registers a per-user service against the account, not against HOME, so","one installed from here would point at a path the real login session cannot use."];var As="ai.anyray.connect.app",ks="Anyray",Vw=(e=vp())=>Vc(e,"Applications",`${ks}.app`),jw="anyray-connect",HT=e=>`<?xml version="1.0" encoding="UTF-8"?>
|
|
9
9
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
10
10
|
<plist version="1.0">
|
|
11
11
|
<dict>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anyray-connect",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.162",
|
|
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": {
|