@cachly-dev/mcp-server 0.10.177 → 0.10.179

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.
@@ -0,0 +1,2 @@
1
+ const l="https://auth.cachly.dev/realms/cachly/protocol/openid-connect",d="cachly-cli",p="X-Trial-Key";function h(e){return typeof e=="string"&&/^cky_trial_[A-Za-z0-9]{8,}$/.test(e.trim())}function g(e){return h(e.argument)?{schluessel:e.argument.trim(),quelle:"argument"}:h(e.credentials)?{schluessel:e.credentials.trim(),quelle:"credentials"}:null}async function f(e,r=l,t=Date.now()){const a=await e(`${r}/auth/device`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:d,scope:"openid"}).toString(),signal:AbortSignal.timeout(1e4)});if(!a.ok)throw new Error(`sign-in could not start (HTTP ${a.status})`);const n=await a.json();if(!n.device_code||!n.user_code)throw new Error("sign-in could not start (no device code)");return{deviceCode:n.device_code,userCode:n.user_code,adresse:n.verification_uri_complete??n.verification_uri??`${r.replace(/\/protocol\/openid-connect$/,"")}/device`,intervallMs:Math.max(1,n.interval??5)*1e3,frist:t+Math.max(60,n.expires_in??600)*1e3}}async function w(e,r,t=l){let a;try{a=await e(`${t}/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:d,grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:r.deviceCode}).toString(),signal:AbortSignal.timeout(1e4)})}catch{return{art:"warten"}}if(a.status>=500)return{art:"warten"};const n=await a.json().catch(()=>({}));return n.access_token?{art:"token",token:n.access_token}:n.error==="authorization_pending"?{art:"warten"}:n.error==="slow_down"?{art:"langsamer"}:{art:"fehler",grund:n.error??`HTTP ${a.status}`}}async function m(e,r,t={}){const a=t.schlafe??(s=>new Promise(c=>setTimeout(c,s))),n=t.jetzt??Date.now;let o=r.intervallMs;for(;n()<r.frist;){await a(o),t.puls?.();const s=await w(e,r,t.basis);if(s.art==="token")return s.token;if(s.art==="langsamer"&&(o=Math.min(o+5e3,3e4)),s.art==="fehler")throw new Error(`sign-in failed: ${s.grund}`)}throw new Error("sign-in timed out")}class u extends Error{status;reason;constructor(r,t,a){super(a),this.status=r,this.reason=t,this.name="UebernahmeFehler"}}async function y(e,r,t,a,n="mcp",o){if(t.startsWith("cky_"))throw new u(403,"sign_in_required","An API key is not a sign-in.");const s={"Content-Type":"application/json",Authorization:`Bearer ${t}`,[p]:a};o&&(s["User-Agent"]=o);const c=await e(`${r.replace(/\/+$/,"")}/auth/trial/claim`,{method:"POST",headers:s,body:JSON.stringify({client:n}),signal:AbortSignal.timeout(15e4)}),i=await c.json().catch(()=>({}));if(!c.ok||!i.api_key||!i.instance_id)throw new u(c.status,i.reason??"unknown",i.error??`HTTP ${c.status}`);return{apiKey:i.api_key,instanceId:i.instance_id,instances:i.instances??[i.instance_id],accountCreated:i.account_created===!0,revokedKeys:i.revoked_keys??0,brainRestarting:i.brain_restarting!==!1}}async function _(e,r,t,a){try{const n=await e(`${r.replace(/\/+$/,"")}/api/v1/instances/${encodeURIComponent(a)}`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"},signal:AbortSignal.timeout(1e4)});return n.ok?(await n.json().catch(()=>({}))).id===a:!1}catch{return!1}}function k(e,r){const t=r?["Your test Brain is now part of your account. Lessons kept."]:["Your test Brain was moved to your account, but the new key could not reach it yet. Run `npx @cachly-dev/mcp-server@latest status` in a minute to check."];return t.push(`Brain: ${e.instanceId}${e.accountCreated?" (a new cachly account was created for your sign-in)":""}`),t.push(`The test key no longer works (${e.revokedKeys} key${e.revokedKeys===1?"":"s"} revoked). The new key is stored for you.`),e.brainRestarting&&t.push("The Brain restarts once with a new password \u2014 about 20 seconds."),t.join(`
2
+ `)}function v(e){if(!(e instanceof u))return`The Brain was not moved: ${e?.message??String(e)}. Nothing was changed.`;switch(e.reason){case"trial_key_invalid":return"This test key is unknown or was already claimed. Nothing was changed.";case"not_a_test_account":return"This key belongs to a regular account, not to a test Brain. There is nothing to claim.";case"sign_in_required":return"The sign-in was not accepted. Run the command again and finish the sign-in in the browser.";case"claim_unavailable":return"Moving the Brain is not possible right now. Nothing was changed. Please try again later.";default:return`${e.message}${/nothing/i.test(e.message)?"":" Nothing was changed."}`}}function T(e,r,t){return!r||!e.includes(r)?{text:e,ersetzt:!1}:{text:e.split(r).join(t),ersetzt:!0}}export{d as CLI_CLIENT,l as KEYCLOAK_BASIS,p as TEST_KEY_KOPF,u as UebernahmeFehler,_ as brainImKonto,k as erfolgsText,T as ersetzeSchluessel,v as fehlerText,w as frageAnmeldungAb,h as istTestSchluessel,f as starteKeycloakAnmeldung,y as uebernimm,g as waehleTestSchluessel,m as warteAufKeycloakAnmeldung};
@@ -0,0 +1,2 @@
1
+ import{performance as r}from"node:perf_hooks";function t(e=process.env){return/^(1|true|on|an|ja|yes)$/i.test((e.CACHLY_ZEITMESSUNG??"").trim())}function o(e){t()&&process.stderr.write(`[zeit] +${Math.round(r.now())} ms ${e}
2
+ `)}export{t as zeitmessungAn,o as zeitpunkt};
@@ -1,6 +1,6 @@
1
- import{istPlatzhalter as a}from"./credentials.js";function o(e){if(typeof e!="string")return"";const t=e.trim();return t&&!a(t)?t:""}const c=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function i(e){return c.test(o(e))}function u(e){return["","","---",`\u2139\uFE0F **cachly:** no API key was found, so a test Brain was created on EU servers \u2014 no sign-up. Tell the user once: it keeps working without an account (${e.tarifEndetAm&&/^\d{4}-\d{2}-\d{2}/.test(e.tarifEndetAm)?`Dev tier until ${e.tarifEndetAm.slice(0,10)}`:"14 days of Dev tier"}, then the free tier, same key). To use their own cachly account instead, run \`npx @cachly-dev/mcp-server@latest autopilot\` \u2014 that account gets a new Brain; lessons from this test Brain do not move over yet.`].join(`
2
- `)}let r=null;function f(){r=null}async function d(e){if(e.schluessel)return e.werkzeug();if(i(e.konfigurierteInstanz)||i(e.aufrufInstanz))return e.anmelden();const t=r===null;t&&(r=e.holeSofortTest());const n=await r;if(!n)return e.anmelden();if(!t)return e.werkzeug();e.ablagen.setzeSchluessel(n.apiKey),e.ablagen.setEmbedJwt(n.apiKey),e.ablagen.saveApiKey(n.apiKey),e.ablagen.merkeInstanz(n.instanzId),await e.ablagen.persistApiKeyToConfig(n.apiKey),await e.ablagen.persistInstanceIdToConfig(n.instanzId),e.meldeEreignis("instant_trial_started",{tool:e.werkzeugName,instance_id:n.instanzId}),(e.protokoll??(s=>{process.stderr.write(s)}))(`
1
+ import{istPlatzhalter as o}from"./credentials.js";function c(e){if(typeof e!="string")return"";const t=e.trim();return t&&!o(t)?t:""}const u=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function s(e){return u.test(c(e))}const a="npx @cachly-dev/mcp-server@latest claim";function l(e){return["","","---",`\u2139\uFE0F **cachly:** no API key was found, so a test Brain was created on EU servers \u2014 no sign-up. Tell the user once: it keeps working without an account (${e.tarifEndetAm&&/^\d{4}-\d{2}-\d{2}/.test(e.tarifEndetAm)?`Dev tier until ${e.tarifEndetAm.slice(0,10)}`:"14 days of Dev tier"}, then the free tier, same key). To keep this Brain and its lessons in their own cachly account, they run \`${a}\` in a terminal and sign in \u2014 the Brain moves over and gets a new key.`].join(`
2
+ `)}let r=null;function d(){r=null}async function g(e){if(e.schluessel)return e.werkzeug();if(s(e.konfigurierteInstanz)||s(e.aufrufInstanz))return e.anmelden();const t=r===null;t&&(r=e.holeSofortTest());const n=await r;if(!n)return e.anmelden();if(!t)return e.werkzeug();e.ablagen.setzeSchluessel(n.apiKey),e.ablagen.setEmbedJwt(n.apiKey),e.ablagen.saveApiKey(n.apiKey),e.ablagen.merkeInstanz(n.instanzId),await e.ablagen.persistApiKeyToConfig(n.apiKey),await e.ablagen.persistInstanceIdToConfig(n.instanzId),e.meldeEreignis("instant_trial_started",{tool:e.werkzeugName,instance_id:n.instanzId}),(e.protokoll??(i=>{process.stderr.write(i)}))(`
3
3
  cachly: no API key found \u2014 created a test Brain on EU servers (instance ${n.instanzId}).
4
- cachly: the key is stored in ~/.cachly/credentials.json. Own account: npx @cachly-dev/mcp-server@latest autopilot
4
+ cachly: the key is stored in ~/.cachly/credentials.json. Keep this Brain in your own account: ${a}
5
5
 
6
- `);try{return await e.werkzeug()+u(n)}finally{try{e.neuesBrain?.(n.instanzId)}catch{}}}export{f as _zugangZuruecksetzen,o as echterWert,i as istInstanzKennung,d as sichereZugang,u as sofortTestHinweis};
6
+ `);try{return await e.werkzeug()+l(n)}finally{try{e.neuesBrain?.(n.instanzId)}catch{}}}export{a as CLAIM_BEFEHL,d as _zugangZuruecksetzen,c as echterWert,s as istInstanzKennung,g as sichereZugang,l as sofortTestHinweis};
package/glama.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://glama.ai/mcp/schemas/server.json",
3
- "version": "0.10.177",
3
+ "version": "0.10.179",
4
4
  "maintainers": [
5
5
  "HeinrichNebula"
6
6
  ],