@cachly-dev/mcp-server 0.10.175 → 0.10.176

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 @@
1
+ import{readFileSync as p,writeFileSync as g,renameSync as m,mkdirSync as S,rmSync as y}from"node:fs";import{dirname as d}from"node:path";const o=3,c=10*6e4,h={fehlschlaege:0,offenBis:0};function f(){return["0","off","aus","false"].includes(String(process.env.CACHLY_LESER_SICHERUNG??"").toLowerCase())}function E(e){return e===503?"abgeschaltet":e>=500?"fehlschlag":"neutral"}function b(e){return e?.name==="SyntaxError"?"neutral":"fehlschlag"}function l(e){const t=e??{},r=s=>typeof s=="number"&&Number.isFinite(s)&&s>0?s:0;return{fehlschlaege:Math.floor(r(t.fehlschlaege)),offenBis:r(t.offenBis)}}class A{speicher;jetzt;constructor(t,r=()=>Date.now()){this.speicher=t,this.jetzt=r}offen(){if(f())return!1;const t=this.speicher.lies();if(t.fehlschlaege<o)return!1;const r=this.jetzt();return r<t.offenBis&&t.offenBis-r<=c}darfFragen(){if(f())return!0;if(this.offen())return!1;const t=this.speicher.lies();return t.fehlschlaege>=o&&this.speicher.schreib({fehlschlaege:t.fehlschlaege,offenBis:this.jetzt()+c}),!0}melde(t){if(t==="neutral"||f())return;const r=this.speicher.lies();if(t==="erfolg"){(r.fehlschlaege!==0||r.offenBis!==0)&&this.speicher.schreib({...h});return}const s=t==="abgeschaltet"?Math.max(r.fehlschlaege+1,o):r.fehlschlaege+1;this.speicher.schreib({fehlschlaege:s,offenBis:s>=o?this.jetzt()+c:0})}}const a={art:"ohne"};async function N(e,t){if(!t.darfFragen())return{art:"uebersprungen"};const r=e.fetchFn??fetch;try{const s=await r(e.url,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.jwt}`,...e.zusatzKopf??{}},body:JSON.stringify({query:e.frage,texts:e.texte,instance_id:e.instanceId}),signal:AbortSignal.timeout(e.zeitlimitMs)});if(!s.ok)return t.melde(E(s.status)),a;const i=await s.json(),n=Array.isArray(i?.scores)?i.scores:null;return!n||n.length!==e.texte.length||!n.every(u=>typeof u=="number"&&Number.isFinite(u))?a:(t.melde("erfolg"),{art:"punkte",scores:n,provider:typeof i.provider=="string"?i.provider:"?",ms:Number(i.ms)||0})}catch(s){return t.melde(b(s)),a}}function j(){let e={...h};return{lies:()=>({...e}),schreib:t=>{e=l(t)}}}function B(e){return{lies:()=>{try{return l(JSON.parse(p(e,"utf8")))}catch{return{...h}}},schreib:t=>{const r=`${e}.${process.pid}.tmp`;try{S(d(e),{recursive:!0}),g(r,JSON.stringify(l(t)),{mode:384}),m(r,e)}catch{try{y(r,{force:!0})}catch{}}}}}export{o as LESER_SICHERUNG_FEHLSCHLAEGE,c as LESER_SICHERUNG_PAUSE_MS,A as LeserSicherung,B as dateiSpeicher,N as frageLeser,b as leserErgebnisAusFehler,E as leserErgebnisAusStatus,f as sicherungAbgeschaltet,j as speicherImProzess};
package/dist/src/leser.js CHANGED
@@ -1 +1 @@
1
- import{embedConfig as u}from"./embeddings.js";import{LESER_GEWICHT as f,LESER_ZEITLIMIT_MS as m}from"./rangfolge-stellschrauben.js";const h=10*6e4;let c=0;function y(){return f<=0||(process.env.CACHLY_LESER??"").toLowerCase()in{0:1,off:1,aus:1,false:1}||!u.jwt?!1:Date.now()>=c}function g(){c=0}async function L(o,r,n){if(!y()||r.length===0)return null;const a=n?.zeitlimitMs??m,l=n?.fetchFn??fetch;try{const i=await l(`${u.apiUrl}/api/v1/rerank`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u.jwt}`,...n?.zusatzKopf??{}},body:JSON.stringify({query:o,texts:r,instance_id:n?.instanceId}),signal:AbortSignal.timeout(a)});if(i.status===503)return c=Date.now()+h,null;if(!i.ok)return null;const t=await i.json(),e=Array.isArray(t.scores)?t.scores:null;return!e||e.length!==r.length||!e.every(s=>typeof s=="number"&&Number.isFinite(s))?null:e}catch{return null}}function _(o,r,n=f){const a=t=>{const e=Math.min(...t),s=Math.max(...t);return s>e?t.map(p=>(p-e)/(s-e)):t.map(()=>0)},l=a(o),i=a(r);return o.map((t,e)=>({i:e,p:l[e]+n*i[e]})).sort((t,e)=>e.p-t.p||t.i-e.i).map(t=>t.i)}export{y as leserAktiv,L as leserPunkte,g as leserSperreLoeschen,_ as mischeMitLeser};
1
+ import{embedConfig as o}from"./embeddings.js";import{LESER_GEWICHT as f,LESER_ZEITLIMIT_MS as h}from"./rangfolge-stellschrauben.js";import{LeserSicherung as L,frageLeser as I,speicherImProzess as z}from"./leser-sicherung.js";const c=new Map;function u(t){const s=t??"";let e=c.get(s);return e||(e=new L(z()),c.set(s,e)),e}function E(t){return f<=0||(process.env.CACHLY_LESER??"").toLowerCase()in{0:1,off:1,aus:1,false:1}||!o.jwt?!1:!u(t).offen()}function d(){c.clear()}async function w(t,s,e){if(!E(e?.instanceId)||s.length===0)return null;const i=await I({url:`${o.apiUrl}/api/v1/rerank`,jwt:o.jwt,frage:t,texte:s,instanceId:e?.instanceId,zeitlimitMs:e?.zeitlimitMs??h,fetchFn:e?.fetchFn,zusatzKopf:e?.zusatzKopf},u(e?.instanceId));return i.art==="punkte"?i.scores:null}function C(t,s,e=f){const i=n=>{const r=Math.min(...n),a=Math.max(...n);return a>r?n.map(m=>(m-r)/(a-r)):n.map(()=>0)},l=i(t),p=i(s);return t.map((n,r)=>({i:r,p:l[r]+e*p[r]})).sort((n,r)=>r.p-n.p||n.i-r.i).map(n=>n.i)}export{E as leserAktiv,w as leserPunkte,d as leserSperreLoeschen,C as mischeMitLeser};
package/glama.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://glama.ai/mcp/schemas/server.json",
3
- "version": "0.10.175",
3
+ "version": "0.10.176",
4
4
  "maintainers": [
5
5
  "HeinrichNebula"
6
6
  ],