@cachly-dev/mcp-server 0.10.191 → 0.10.192
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 +4 -3
- package/dist/src/ambient-hook.js +4 -2
- package/dist/src/einblendung.js +6 -6
- package/dist/src/hook-zugang.js +1 -1
- package/dist/src/index.js +131 -131
- package/dist/src/konto-anlegen.js +1 -0
- package/dist/src/sofort-test.js +1 -1
- package/glama.json +1 -1
- package/hooks/cachly-ambient-einblendung.mjs +29 -26
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{closeSync as w,existsSync as x,mkdirSync as y,openSync as _,readFileSync as M,renameSync as I,statSync as R,unlinkSync as z,writeFileSync as K,writeSync as F}from"node:fs";import{dirname as f,join as c}from"node:path";import{credentialsPath as j,readInstanceId as L,readSavedApiKey as b,saveApiKey as O,saveInstanceId as $}from"./credentials.js";import{holeSofortTest as D,SOFORT_TEST_FRIST_MS as U}from"./sofort-test.js";const A=15e3,H=100,Q=600*1e3,N=1440*60*1e3,T="anlegen.lock",G="anlegen.fehler",h="startwissen-auftrag.json";function Z(e=process.env){return!/^(0|false|off|no|nein)$/i.test((e.CACHLY_STARTWISSEN??"").trim())}function o(e){return f(j(e))}const P=e=>new Promise(n=>setTimeout(n,e));function k(e){return{apiKey:b(e),instanzId:L(e)}}function C(e,n){try{y(f(e),{recursive:!0})}catch{return"kein-zugriff"}try{const t=_(e,"wx",384);try{F(t,`${process.pid} ${n}`)}finally{w(t)}return"ja"}catch(t){return t?.code==="EEXIST"?"belegt":"kein-zugriff"}}function g(e,n){try{return n-R(e).mtimeMs}catch{return null}}function p(e){try{z(e)}catch{}}function J(e,n=Date.now()){const t=g(c(o(e),T),n);return t!==null&&t<A}function V(e,n,t){if(n<=0)return!1;const r=g(e,t);return r!==null&&r>=0&&r<n}function W(e){try{y(f(e),{recursive:!0}),K(e,String(Date.now()),{mode:384})}catch{}}async function ee(e){const n=e.jetzt??Date.now,t=e.schlafen??P,r=n()+e.fristMs,i=o(e),s=c(i,T),l=c(i,G);try{for(;;){const a=k(e);if(a.apiKey&&(a.instanzId||!J(e,n())))return{art:"vorhanden",apiKey:a.apiKey,instanzId:a.instanzId};if(!a.apiKey){const m=C(s,n());if(m==="kein-zugriff")return{art:"gescheitert",grund:"kein-schreibzugriff"};if(m==="ja")try{const d=k(e);if(d.apiKey)return{art:"vorhanden",apiKey:d.apiKey,instanzId:d.instanzId};if(V(l,e.abkuehlungMs??0,n()))return{art:"gescheitert",grund:"abgekuehlt"};const E=Math.max(500,r-n()),u=await D({apiUrl:e.apiUrl,version:e.version,holen:e.holen,env:e.env,fristMs:Math.min(E,e.anfrageMs??U),speichern:v=>O(v,e)});return u?($(u.instanzId,{...e,apiKey:u.apiKey}),p(l),{art:"angelegt",test:u}):(W(l),{art:"gescheitert",grund:"kein-test"})}finally{p(s)}const S=g(s,n());S!==null&&S>=A&&p(s)}if(n()>=r)return a.apiKey?{art:"vorhanden",apiKey:a.apiKey,instanzId:a.instanzId}:{art:"gescheitert",grund:"sperre-belegt"};await t(H)}}catch{return{art:"gescheitert",grund:"kein-test"}}}function ne(e,n={}){try{const t=c(o(n),h);y(f(t),{recursive:!0});const r=`${t}.${process.pid}.tmp`;K(r,JSON.stringify({...e,am:new Date().toISOString()}),{mode:384}),I(r,t)}catch{}}function te(e={}){return x(c(o(e),h))}function re(e={},n=Date.now()){const t=c(o(e),h),r=`${t}.${process.pid}.genommen`;try{I(t,r)}catch{return null}try{const i=JSON.parse(M(r,"utf8")),s=Date.parse(String(i?.am??""));return!i||typeof i.instanzId!="string"||!i.instanzId||!Number.isFinite(s)||n-s>N?null:{instanzId:i.instanzId,projekt:typeof i.projekt=="string"?i.projekt:"",am:String(i.am)}}catch{return null}finally{try{z(r)}catch{}}}export{Q as ABKUEHLUNG_HOOK_MS,N as AUFTRAG_VERFAELLT_MS,A as SPERRE_VERALTET_MS,H as WARTE_TAKT_MS,te as auftragLiegt,re as nimmAuftrag,ne as schreibeAuftrag,ee as sichereKonto,J as sperreLiegt,Z as startwissenEingeschaltet};
|
package/dist/src/sofort-test.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{saveApiKey as o}from"./credentials.js";function
|
|
1
|
+
import{saveApiKey as o}from"./credentials.js";function c(e,t=process.env){const n=t.CACHLY_QUELLE?.trim();return`${n&&/^[a-z0-9-]{1,40}$/.test(n)?`cachly-${n}`:"cachly-mcp"}/${e}`}function a(e){return`${e.replace(/\/+$/,"")}/auth/instant-trial`}function l(e){if(!e||typeof e!="object")return null;const t=e,n=typeof t.api_key=="string"?t.api_key:"",r=typeof t.instance_id=="string"?t.instance_id:"";return!n||!r?null:{apiKey:n,instanzId:r,tarifEndetAm:typeof t.trial_ends_at=="string"?t.trial_ends_at:void 0}}const u=8e3;let i=!1;function f(){i=!1}async function y(e){if(i)return null;i=!0;const t=e.holen??fetch,n=e.speichern??o;try{const r=await t(a(e.apiUrl),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":c(e.version,e.env??process.env)},body:"{}",signal:AbortSignal.timeout(e.fristMs??u)});if(!r.ok)return null;const s=l(await r.json());return s?(n(s.apiKey),s):null}catch{return null}}export{u as SOFORT_TEST_FRIST_MS,f as _sperreZuruecksetzen,y as holeSofortTest,l as leseAntwort,a as sofortTestUrl,c as userAgent};
|