@cachly-dev/mcp-server 0.10.254 → 0.10.256

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 CHANGED
@@ -55,11 +55,11 @@ creates your Brain on first start. The [JetBrains plugin](https://plugins.jetbra
55
55
  brings it to IntelliJ IDEA, PyCharm, GoLand, WebStorm and Rider
56
56
  ([guide](https://cachly.dev/docs/jetbrains)).
57
57
 
58
- **Keep your test Brain** with `npx @cachly-dev/mcp-server@latest claim`. You sign in once,
59
- and the Brain moves into your account with all its lessons.
58
+ **Already have a test Brain?** Keep it with `npx @cachly-dev/mcp-server@latest claim`. You sign in
59
+ once, and the Brain moves into your account with all its lessons.
60
60
 
61
61
  <details>
62
- <summary><b>Claude Code in detail:</b> the three hooks, auto-update, and the test Brain</summary>
62
+ <summary><b>Claude Code in detail:</b> the three hooks, auto-update, and the sign-in</summary>
63
63
 
64
64
  The plugin adds three Claude Code hooks:
65
65
 
@@ -74,8 +74,8 @@ Claude Code leaves it off for marketplaces outside Anthropic's own. The MCP serv
74
74
  itself on every start; the hooks come with the plugin and update with it. If an update is
75
75
  waiting, the first `session_start` of a session says so in one line.
76
76
 
77
- The test Brain is created by the plugin hook at session start, or by the first tool call
78
- if the hook did not run. `claude mcp list` is the reliable check: `claude plugin details`
77
+ Without a key, the first tool call opens your browser once to sign in (GitHub, Google or
78
+ e-mail). `claude mcp list` is the reliable check: `claude plugin details`
79
79
  shows `MCP servers (0)` even while the server runs.
80
80
 
81
81
  `claim` revokes every test key and stores a new key where your editor and hooks look for
@@ -415,7 +415,7 @@ Manual snippets are in [Manual Setup](#manual-setup).
415
415
 
416
416
  | Editor / client | Auto-setup | Config file written | Global config | Notes |
417
417
  |---|---|---|---|---|
418
- | **Claude Code** | yes | `.mcp.json` | with the plugin | Without a key: test Brain at session start (plugin) or on the first tool call; browser sign-in only as fallback |
418
+ | **Claude Code** | yes | `.mcp.json` | with the plugin | Without a key: the first tool call opens the browser once to sign in |
419
419
  | **Cursor** | yes, detected via `.cursor/` | `.cursor/mcp.json`, hooks in `.cursor/hooks.json` | no | Project-level; restart Cursor after setup. Lessons arrive with the first tool call of a turn |
420
420
  | **Windsurf** | yes, detected via `.windsurf/` | `.windsurf/mcp.json` | no | Project-level; restart Windsurf after setup |
421
421
  | **VS Code + Copilot** | yes, detected via `.vscode/` | `.vscode/mcp.json`, hooks in `.github/hooks/cachly-ambient.json` | no | Needs the VS Code MCP support or Copilot chat. Briefing at session start, lessons before each prompt |
@@ -433,7 +433,7 @@ Manual snippets are in [Manual Setup](#manual-setup).
433
433
  |---|---|
434
434
  | `autosetup` or `autopilot` from a terminal (TTY) | OAuth device flow: one click in the browser, the API key is saved automatically |
435
435
  | `autosetup` from a VS Code task or CI (no TTY) | Detects the non-interactive run, opens the browser with a step-by-step guide, prints the `CACHLY_JWT=... autosetup` command |
436
- | First tool call without any key | Test Brain: an anonymous Brain on EU servers. The key is saved to `~/.cachly/credentials.json`, and the call goes through. If that fails (offline, rate limit), the inline device flow starts with a URL and a code |
436
+ | First tool call without any key | Inline device flow: the browser opens once with a URL and a code; sign in with GitHub, Google or e-mail. The key is saved to `~/.cachly/credentials.json` |
437
437
  | First tool call with `CACHLY_BRAIN_INSTANCE_ID` set but no key | Inline device flow. You already have a Brain, so no second account is created |
438
438
  | `CACHLY_JWT=cky_live_xxx npx ... autosetup` | Skips the sign-in step and uses the key you pass |
439
439
 
@@ -1,4 +1,4 @@
1
- import{readFileSync as z}from"node:fs";import{tmpdir as x}from"node:os";import{parseHookPayload as H,runEinblendung as C,stopLernanfrage as K,stopObservation as N}from"./ambient-cli.js";import{stopAntwort as j}from"./schreibbeleg.js";import{holeBestand as R,hookAusgabe as M,starteNebenlauf as G}from"./einblendung.js";import{STARTWISSEN_IMPORT as y,hookImportFuerAuftrag as B,importiereStartwissen as Y}from"./startwissen-hook.js";import{belohnungMelden as $}from"./lernen.js";import{appendLedgerEntry as D,reportLedgerEntry as J}from"./ambient-ledger.js";import{copilotHatHook as V,cursorHatHook as Q,findeInstanz as g,findeSchluessel as h,hookUmfeld as S,pluginVersion as W,projektHatHook as X}from"./hook-zugang.js";import{ABKUEHLUNG_HOOK_MS as q,schreibeAuftrag as O,sichereKonto as Z,startwissenEingeschaltet as tt}from"./konto-anlegen.js";import{istInstanzKennung as U,sofortTestHinweis as et}from"./zugang.js";import{CURSOR_FLAG as p,cursorEreignis as L,cursorHookAntwort as nt,cursorLeer as rt,istCursorNutzlast as P}from"./cursor-hook.js";import{COPILOT_FLAG as w,copilotEreignis as ot,copilotHookAntwort as it,istFremdeLaufzeit as T}from"./copilot-hook.js";import{CODEX_FLAG as v,codexHookAntwort as st}from"./codex-hook.js";import{GEMINI_FLAG as _,geminiEreignis as ct,geminiHookAntwort as at}from"./gemini-hook.js";const ut="https://api.cachly.dev",E=5e3,ft="ambient-auffrischen",F=new Set(["SessionStart","UserPromptSubmit","PreToolUse","Stop"]);async function lt(t,e){if(!t.args.includes(p)&&(L(e,t.args)!=="sessionStart"||Q(t.umfeld)))return"";const o=t.args.filter(r=>r==="--plugin");return nt({payload:e,args:t.args,claudeLauf:(r,a)=>I({...t,raw:r,args:[a,...o]}),ablageOrdner:t.cursorAblage})}function pt(t,e){const n=(o,r)=>I({...t,raw:o,args:[r]});return t.args.includes(w)?it({payload:e,args:t.args,claudeLauf:n,ablageOrdner:t.copilotAblage}):t.args.includes(v)?st({payload:e,args:t.args,claudeLauf:n}):t.args.includes(_)?at({payload:e,args:t.args,claudeLauf:n}):null}function dt(t,e){return t.includes(p)||P(e)?"cursor":t.includes(w)?"copilot":t.includes(v)?"codex":t.includes(_)?"gemini":T(e)?"vscode":"claude"}async function mt(t){const e=await Z({apiUrl:t.apiUrl,version:W(t.umfeld),home:t.umfeld.heim,env:{...t.umfeld.env,CACHLY_QUELLE:"claude-code-plugin"},fristMs:E,anfrageMs:E,abkuehlungMs:q,holen:t.fetchFn});if(e.art==="vorhanden")return{apiKey:e.apiKey,instanzId:e.instanzId,hinweis:""};if(e.art!=="angelegt")return null;if(tt(t.umfeld.env)){const n={apiUrl:t.apiUrl,jwt:e.test.apiKey,instanceId:e.test.instanzId};t.selbst&&(t.nebenlauf??G)(n,[t.selbst,y,t.umfeld.projekt],{zweck:y,ordner:x()})||O({instanzId:e.test.instanzId,projekt:t.umfeld.projekt},{home:t.umfeld.heim})}return{apiKey:e.test.apiKey,instanzId:e.test.instanzId,hinweis:et(e.test)}}function gt(t,e){const n=e.replace(/^\s+/,"");if(!t)return M("SessionStart",n);try{const o=JSON.parse(t),r=o.hookSpecificOutput?.additionalContext;return!o.hookSpecificOutput||typeof r!="string"?t:(o.hookSpecificOutput.additionalContext=`${n}
1
+ import{readFileSync as K}from"node:fs";import{tmpdir as y}from"node:os";import{parseHookPayload as O,runEinblendung as j,stopLernanfrage as N,stopObservation as R}from"./ambient-cli.js";import{stopAntwort as M}from"./schreibbeleg.js";import{holeBestand as G,hookAusgabe as B,starteNebenlauf as U}from"./einblendung.js";import{STARTWISSEN_IMPORT as p,hookImportFuerAuftrag as Y,importiereStartwissen as $}from"./startwissen-hook.js";import{belohnungMelden as D}from"./lernen.js";import{appendLedgerEntry as J,reportLedgerEntry as V}from"./ambient-ledger.js";import{copilotHatHook as Q,cursorHatHook as W,findeInstanz as S,findeSchluessel as w,hookUmfeld as _,pluginVersion as X,projektHatHook as q}from"./hook-zugang.js";import{ABKUEHLUNG_HOOK_MS as Z,schreibeAuftrag as L,sichereKonto as tt,startwissenEingeschaltet as v}from"./konto-anlegen.js";import{istInstanzKennung as P,sofortTestHinweis as et}from"./zugang.js";import{CURSOR_FLAG as d,cursorEreignis as T,cursorHookAntwort as nt,cursorLeer as rt,istCursorNutzlast as E}from"./cursor-hook.js";import{COPILOT_FLAG as b,copilotEreignis as ot,copilotHookAntwort as it,istFremdeLaufzeit as F}from"./copilot-hook.js";import{CODEX_FLAG as z,codexHookAntwort as st}from"./codex-hook.js";import{GEMINI_FLAG as k,geminiEreignis as ct,geminiHookAntwort as at}from"./gemini-hook.js";const ut="https://api.cachly.dev",x=5e3,ft="ambient-auffrischen",C=new Set(["SessionStart","UserPromptSubmit","PreToolUse","Stop"]);async function lt(t,e){if(!t.args.includes(d)&&(T(e,t.args)!=="sessionStart"||W(t.umfeld)))return"";const o=t.args.filter(r=>r==="--plugin");return nt({payload:e,args:t.args,claudeLauf:(r,u)=>I({...t,raw:r,args:[u,...o]}),ablageOrdner:t.cursorAblage})}function pt(t,e){const n=(o,r)=>I({...t,raw:o,args:[r]});return t.args.includes(b)?it({payload:e,args:t.args,claudeLauf:n,ablageOrdner:t.copilotAblage}):t.args.includes(z)?st({payload:e,args:t.args,claudeLauf:n}):t.args.includes(k)?at({payload:e,args:t.args,claudeLauf:n}):null}function dt(t,e){return t.includes(d)||E(e)?"cursor":t.includes(b)?"copilot":t.includes(z)?"codex":t.includes(k)?"gemini":F(e)?"vscode":"claude"}async function mt(t){const e=await tt({apiUrl:t.apiUrl,version:X(t.umfeld),home:t.umfeld.heim,env:{...t.umfeld.env,CACHLY_QUELLE:"claude-code-plugin"},fristMs:x,anfrageMs:x,abkuehlungMs:Z,holen:t.fetchFn});if(e.art==="vorhanden")return{apiKey:e.apiKey,instanzId:e.instanzId,hinweis:""};if(e.art!=="angelegt")return null;if(v(t.umfeld.env)){const n={apiUrl:t.apiUrl,jwt:e.test.apiKey,instanceId:e.test.instanzId};t.selbst&&(t.nebenlauf??U)(n,[t.selbst,p,t.umfeld.projekt],{zweck:p,ordner:y()})||L({instanzId:e.test.instanzId,projekt:t.umfeld.projekt},{home:t.umfeld.heim})}return{apiKey:e.test.apiKey,instanzId:e.test.instanzId,hinweis:et(e.test)}}function gt(t,e){const n=e.replace(/^\s+/,"");if(!t)return B("SessionStart",n);try{const o=JSON.parse(t),r=o.hookSpecificOutput?.additionalContext;return!o.hookSpecificOutput||typeof r!="string"?t:(o.hookSpecificOutput.additionalContext=`${n}
2
2
 
3
- ${r}`,JSON.stringify(o))}catch{return t}}async function I(t){try{const e=H(t.raw),n={...t,editor:t.editor??dt(t.args,e)};if(n.args.includes(p)||P(e))return await lt(n,e);const o=pt(n,e);if(o)return await o;const r=e?.hook_event_name??n.args.find(i=>F.has(i))??n.umfeld.env.CACHLY_HOOK_EVENT??"";if(T(e)&&(r!=="SessionStart"&&r!=="UserPromptSubmit"||V(n.umfeld))||n.args.includes("--plugin")&&r&&X(r,n.umfeld))return"";let a=null;if(r==="Stop"&&e?.transcript_path)try{a=z(e.transcript_path,"utf-8").split(`
4
- `);const i=j(a,e.stop_hook_active===!0);if(i)return i}catch{}let f=h(n.umfeld),c=g(n.umfeld),s="";if(!f&&r==="SessionStart"&&n.args.includes("--plugin")&&!U(c)){const i=await mt(n);i&&(f=i.apiKey,c=i.instanzId??c,s=i.hinweis)}if(!f||!c)return"";const u={apiUrl:n.apiUrl,jwt:f,instanceId:c};if(r==="Stop"){const i=e?N(e):null,m=i?(n.fetchFn??fetch)(`${u.apiUrl}/api/v1/instances/${u.instanceId}/learn`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u.jwt}`},body:JSON.stringify(K(i)),signal:AbortSignal.timeout(8e3)}).catch(()=>{}):void 0,l=$(u,e?.session_id??null,a,{fetchFn:n.fetchFn});return await Promise.all([m,l]),""}let d;const A=await(n.einblenden??C)(n.raw,{cfg:u,nebenlauf:n.selbst?[n.selbst,ft]:void 0,editor:n.editor,fetchFn:n.fetchFn,onInject:(i,m)=>{const l={ts:new Date().toISOString(),event:m,injected:i,prevented:0,instanz:u.instanceId};D(l),d=J(u,l,n.fetchFn)}});return d&&await Promise.race([d,new Promise(i=>setTimeout(i,500))]),s?gt(A,s):A}catch{return""}}async function ht(){if(process.stdin.isTTY)return"";const t=[];for await(const e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function b(){return process.env.CACHLY_API_URL||ut}const k={SessionStart:25e3,UserPromptSubmit:8e3,PreToolUse:8e3,Stop:5e4,sessionStart:25e3,beforeSubmitPrompt:8e3,postToolUse:3e3,userPromptSubmitted:8e3,PostToolUse:3e3,BeforeAgent:8e3};function St(t,e){return t.includes(p)?rt(L(e,t)):t.includes(w)?ot(e,t)?"{}":"":t.includes(_)&&ct(e,t)?"{}":""}async function Ft(t,e){try{const n=await ht(),o=H(n),r=o?.hook_event_name??t.find(s=>F.has(s)||Object.hasOwn(k,s))??"",a=Number(process.env.CACHLY_HOOK_FRIST_MS)||k[r]||k.UserPromptSubmit,f=St(t,o),c=await Promise.race([I({args:t,raw:n,umfeld:S(),apiUrl:b(),selbst:e}),new Promise(s=>setTimeout(()=>s(f),a))]);c&&await new Promise(s=>process.stdout.write(c,()=>s()))}catch{}process.exit(0)}async function zt(){try{const t=S(),e=h(t),n=g(t);e&&n&&await R({apiUrl:b(),jwt:e,instanceId:n},{force:!0,lernen:!0})}catch{}process.exit(0)}async function xt(t){try{const e=S(),n=h(e),o=g(e);if(n&&U(o)){const r=await Y({cfg:{apiUrl:b(),jwt:n,instanceId:o},projekt:t,env:e.env});r.art!=="aus"&&O({instanzId:o,projekt:t,vomHook:B(r)},{home:e.heim})}}catch{}process.exit(0)}export{ft as AUFFRISCHEN,k as HOOK_FRIST_MS,E as KONTO_FRIST_MS,ut as STANDARD_API_URL,zt as auffrischenHauptlauf,dt as editorVon,I as hookAntwort,Ft as hookHauptlauf,xt as startwissenImportHauptlauf};
3
+ ${r}`,JSON.stringify(o))}catch{return t}}async function I(t){try{const e=O(t.raw),n={...t,editor:t.editor??dt(t.args,e)};if(n.args.includes(d)||E(e))return await lt(n,e);const o=pt(n,e);if(o)return await o;const r=e?.hook_event_name??n.args.find(i=>C.has(i))??n.umfeld.env.CACHLY_HOOK_EVENT??"";if(F(e)&&(r!=="SessionStart"&&r!=="UserPromptSubmit"||Q(n.umfeld))||n.args.includes("--plugin")&&r&&q(r,n.umfeld))return"";let u=null;if(r==="Stop"&&e?.transcript_path)try{u=K(e.transcript_path,"utf-8").split(`
4
+ `);const i=M(u,e.stop_hook_active===!0);if(i)return i}catch{}let f=w(n.umfeld),c=S(n.umfeld),s="";if(!f&&r==="SessionStart"&&n.args.includes("--plugin")&&!P(c)){const i=await mt(n);i&&(f=i.apiKey,c=i.instanzId??c,s=i.hinweis)}if(!f||!c)return"";const a={apiUrl:n.apiUrl,jwt:f,instanceId:c};if(r==="Stop"){const i=e?R(e):null,h=i?(n.fetchFn??fetch)(`${a.apiUrl}/api/v1/instances/${a.instanceId}/learn`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.jwt}`},body:JSON.stringify(N(i)),signal:AbortSignal.timeout(8e3)}).catch(()=>{}):void 0,l=D(a,e?.session_id??null,u,{fetchFn:n.fetchFn});return await Promise.all([h,l]),""}let m;const g=await(n.einblenden??j)(n.raw,{cfg:a,nebenlauf:n.selbst?[n.selbst,ft]:void 0,editor:n.editor,fetchFn:n.fetchFn,onInject:(i,h)=>{const l={ts:new Date().toISOString(),event:h,injected:i,prevented:0,instanz:a.instanceId};J(l),m=V(a,l,n.fetchFn)}});return m&&await Promise.race([m,new Promise(i=>setTimeout(i,500))]),r==="SessionStart"&&!g&&!s&&n.selbst&&v(n.umfeld.env)&&(n.nebenlauf??U)(a,[n.selbst,p,n.umfeld.projekt],{zweck:p,ordner:y()}),s?gt(g,s):g}catch{return""}}async function ht(){if(process.stdin.isTTY)return"";const t=[];for await(const e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function A(){return process.env.CACHLY_API_URL||ut}const H={SessionStart:25e3,UserPromptSubmit:8e3,PreToolUse:8e3,Stop:5e4,sessionStart:25e3,beforeSubmitPrompt:8e3,postToolUse:3e3,userPromptSubmitted:8e3,PostToolUse:3e3,BeforeAgent:8e3};function St(t,e){return t.includes(d)?rt(T(e,t)):t.includes(b)?ot(e,t)?"{}":"":t.includes(k)&&ct(e,t)?"{}":""}async function Ft(t,e){try{const n=await ht(),o=O(n),r=o?.hook_event_name??t.find(s=>C.has(s)||Object.hasOwn(H,s))??"",u=Number(process.env.CACHLY_HOOK_FRIST_MS)||H[r]||H.UserPromptSubmit,f=St(t,o),c=await Promise.race([I({args:t,raw:n,umfeld:_(),apiUrl:A(),selbst:e}),new Promise(s=>setTimeout(()=>s(f),u))]);c&&await new Promise(s=>process.stdout.write(c,()=>s()))}catch{}process.exit(0)}async function zt(){try{const t=_(),e=w(t),n=S(t);e&&n&&await G({apiUrl:A(),jwt:e,instanceId:n},{force:!0,lernen:!0})}catch{}process.exit(0)}async function xt(t){try{const e=_(),n=w(e),o=S(e);if(n&&P(o)){const r=await $({cfg:{apiUrl:A(),jwt:n,instanceId:o},projekt:t,env:e.env});r.art!=="aus"&&L({instanzId:o,projekt:t,vomHook:Y(r)},{home:e.heim})}}catch{}process.exit(0)}export{ft as AUFFRISCHEN,H as HOOK_FRIST_MS,x as KONTO_FRIST_MS,ut as STANDARD_API_URL,zt as auffrischenHauptlauf,dt as editorVon,I as hookAntwort,Ft as hookHauptlauf,xt as startwissenImportHauptlauf};
@@ -1,8 +1,8 @@
1
- import{readFileSync as T,existsSync as C,writeFileSync as j,mkdirSync as F,statSync as W,appendFileSync as V}from"node:fs";import{dirname as R,join as _}from"node:path";import{tmpdir as b}from"node:os";import{createHash as X}from"node:crypto";import{spawn as Q}from"node:child_process";import{Einblendbestand as $,torWoerter as B}from"./einblendung-kern.js";import{rahmeEin as U,RAHMEN_HINWEIS as z}from"./einblendung-rahmen.js";import{istMarkiert as ee}from"./verdacht-marke.js";import{istTeamweit as te}from"./utils.js";import{istBlossesThema as re}from"./blosses-thema.js";import{leserText as ne}from"./seltenheitsbestand.js";import{mischeMitLeser as H}from"./leser.js";import{LeserSicherung as se,dateiSpeicher as oe,frageLeser as ie}from"./leser-sicherung.js";import{LESER_TIEFE_EINBLENDUNG as le,LESER_ZEITLIMIT_MS as ae}from"./rangfolge-stellschrauben.js";import{stufeEinblendungNachVersion as ce}from"./gueltigkeit-version.js";import{ARME as O,BASIS_MIN_BELEGE as ue,MERKMAL_KANDIDATEN as pe,OHNE_LERNEN as fe,entscheide as he,leseArmZaehlung as me,lernEinstellungen as de,lernenAuffrischen as ge,merkeEntscheidung as Ee,neuerSatz as _e,sitzungsKennung as be,zugKennung as Se}from"./lernen.js";export*from"./einblendung-kern.js";import{belohnungMelden as ht,lernenAuffrischen as mt,lernEinstellungen as dt,ARME as gt}from"./lernen.js";const ye=600*1e3,P=300*1e3,Ae=10*1e3,Ne=2e3,Ie=50,ve=60*1e3;function ke(e,t){return t<P?{ttlMs:Ae,sofort:!0}:e<Ie?{ttlMs:ve,sofort:!1}:{ttlMs:ye,sofort:!1}}const D=8e3,we=60*1e3,J=120,K=le,Me=1500,I=ae,Le=_(b(),"cachly-ambient-netlog.jsonl");function rt(e=process.cwd()){const t={apiUrl:process.env.CACHLY_API_URL||"https://api.cachly.dev",jwt:process.env.CACHLY_JWT||"",instanceId:process.env.CACHLY_BRAIN_INSTANCE_ID||""};if(t.jwt&&t.instanceId)return t;let r=e;for(let n=0;n<8;n++){const s=_(r,".mcp.json");if(C(s))try{const i=JSON.parse(T(s,"utf8"))?.mcpServers?.cachly?.env??{};if(t.apiUrl=t.apiUrl||i.CACHLY_API_URL||"https://api.cachly.dev",t.jwt=t.jwt||i.CACHLY_JWT||"",t.instanceId=t.instanceId||i.CACHLY_BRAIN_INSTANCE_ID||"",t.jwt&&t.instanceId)return t}catch{}const o=R(r);if(o===r)break;r=o}return t}function v(e){return X("sha1").update(e).digest("hex").slice(0,12)}function q(e){return _(b(),`cachly-ambient-bestand-${v(e)}.json`)}function xe(e){return _(b(),`cachly-leser-sicherung-${v(e)}.json`)}function Te(e,t="ambient-auffrischen"){return _(b(),`cachly-${t}-${v(e)}.lock`)}async function k(e,{fetchFn:t=fetch,zeitlimitMs:r=D}={}){try{const n=await t(`${e.apiUrl}/api/v1/instances/${e.instanceId}/export`,{headers:{Authorization:`Bearer ${e.jwt}`},signal:AbortSignal.timeout(r)});if(!n.ok)return null;const s=await n.json();return!Array.isArray(s?.lessons)||s.lessons.length===0&&typeof s.note=="string"&&s.note?null:s.lessons.map(o=>typeof o=="string"?Ce(o):o).filter(o=>!!o&&typeof o=="object")}catch{return null}}function Ce(e){try{return JSON.parse(e)}catch{return null}}function S(e,t,r="server"){const n=Date.now(),s=y(e),o=s?.seit??n;let i;r==="vorab"?i=t:r==="server"&&s?.vorab&&n-o<P&&(i=s.vorab);const a=r==="server"&&i?je(t,i):t;try{F(R(e),{recursive:!0}),j(e,JSON.stringify({at:n,seit:o,lessons:a,...i?{vorab:i}:{}}),{mode:384})}catch{}return a}function je(e,t){const r=new Set(e.map(n=>n.topic));return[...e,...t.filter(n=>!r.has(n.topic))]}function nt(e,t){if(!e||t.length===0)return!1;const r=q(e);return(y(r)?.lessons.length??0)>0?!1:(S(r,t,"vorab"),!0)}function y(e){try{const t=JSON.parse(T(e,"utf8"));if(Array.isArray(t?.lessons)){const r=Number(t.at)||0;return{at:r,seit:Number(t.seit)||r,lessons:t.lessons,...Array.isArray(t.vorab)?{vorab:t.vorab}:{}}}}catch{}return null}function Re(e,t,{zweck:r,ordner:n}={}){const s=Te(e.instanceId,r);try{if(C(s)&&Date.now()-W(s).mtimeMs<we)return!1;j(s,String(Date.now()),{mode:384})}catch{return!1}try{return Q(process.execPath,t,{detached:!0,stdio:"ignore",...n?{cwd:n}:{},env:{...process.env,CACHLY_API_URL:e.apiUrl,CACHLY_JWT:e.jwt,CACHLY_BRAIN_INSTANCE_ID:e.instanceId}}).unref(),!0}catch{return!1}}async function $e(e,{force:t=!1,nebenlauf:r,abrufMs:n=D,lernen:s=!1,vorabSchliessen:o=!1,fetchFn:i}={}){if(!e.jwt||!e.instanceId)return{lessons:[],quelle:"nicht-eingerichtet"};const a=q(e.instanceId);if(t){const[m]=await Promise.all([k(e,{fetchFn:i,zeitlimitMs:n}),s?ge(e,{fetchFn:i}):void 0]);if(m)return{lessons:S(a,m,o?"abschluss":"server"),quelle:"server"};const u=y(a);return u?{lessons:u.lessons,quelle:"platte-alt"}:{lessons:[],quelle:"server-nicht-erreichbar"}}const l=y(a);if(l){const m=Date.now(),u=ke(l.lessons.length,m-l.seit);if(m-l.at<u.ttlMs)return{lessons:l.lessons,quelle:"platte"};if(u.sofort){const h=await k(e,{fetchFn:i,zeitlimitMs:Math.min(n,Ne)});return h?{lessons:S(a,h),quelle:"server"}:{lessons:l.lessons,quelle:"platte-alt"}}return r&&Re(e,r),{lessons:l.lessons,quelle:"platte-alt"}}const c=await k(e,{fetchFn:i,zeitlimitMs:n});return c?{lessons:S(a,c),quelle:"server"}:{lessons:[],quelle:"server-nicht-erreichbar"}}function w(e){return Math.ceil(String(e).length/4)}function M(e){const t=e.severity?`[${e.severity}] `:"",r=String(e.what_worked??"").replace(/\s+/g," ").trim(),n=r.length>J?`${r.slice(0,J)}\u2026`:r,s=typeof e.versionshinweis=="string"?` [${e.versionshinweis}]`:"";return`- ${t}${e.topic}${s}: ${n}`}const A={lessons:[],tokens:0,topScore:0,belege:0};function L(e,t,r){if(e.length===0)return{...A};const n=[];let s=0;e=ce(e);for(const{lektion:o}of e.slice(0,t)){const i=w(M(o));if(s+i>r)break;n.push(o),s+=i}return{lessons:n,tokens:s,topScore:Math.round(e[0].punkte*100)/100,belege:e[0].belege}}function st(e,t,{minBelege:r=2,topK:n=3,tokenBudget:s=600}={}){if(!Array.isArray(t)||t.length===0)return{...A};if(B(e).length===0)return{...A};const o=new $(t).sortiere(e).filter(i=>i.belege>=r);return o.length===0?{...A}:L(o,n,s)}function Be(e){return ne(e,Me)}async function G(e,t,r,{zeitlimitMs:n=I,fetchFn:s}={}){if(!e?.jwt||!e?.instanceId||r.length===0)return{art:"ohne"};if(["0","off","aus","false"].includes(String(process.env.CACHLY_LESER||"").toLowerCase()))return{art:"ohne"};const o=new se(oe(xe(e.instanceId)));return ie({url:`${e.apiUrl}/api/v1/rerank`,jwt:e.jwt,frage:t,texte:r,instanceId:e.instanceId,zeitlimitMs:n,fetchFn:s},o)}async function ot(e,t,r,n={}){const s=await G(e,t,r,n);return s.art==="punkte"?{scores:s.scores,provider:s.provider,ms:s.ms}:null}async function Y(e,t,r,{minBelege:n,tiefe:s,zeitlimitMs:o,fetchFn:i}){const a={sortiert:[],leser:"aus",leserMs:0};if(!Array.isArray(t)||t.length===0||B(e).length===0)return a;let l=new $(t).sortiere(e).filter(u=>u.belege>=n);if(l.length===0)return a;let c="aus",m=0;if(l.length>1&&s>0){const u=l.slice(0,s),d=l.slice(s),h=await G(r,e,u.map(E=>Be(E.lektion)),{zeitlimitMs:o,fetchFn:i});h.art==="punkte"?(l=[...H(u.map(f=>f.punkte),h.scores,1).map(f=>({...u[f],leser:h.scores[f]})),...d],c=h.provider,m=h.ms):h.art==="uebersprungen"&&(c="uebersprungen")}return{sortiert:l,leser:c,leserMs:m}}async function it(e,t,r,{minBelege:n=2,topK:s=3,tokenBudget:o=600,tiefe:i=K,zeitlimitMs:a=I,fetchFn:l}={}){const c=await Y(e,t,r,{minBelege:n,tiefe:i,zeitlimitMs:a,fetchFn:l});return{...L(c.sortiert,s,o),leser:c.leser,leserMs:c.leserMs}}function Ue(e){if(!e.lessons.length)return"";const t=e.lessons.map(M).join(`
1
+ import{readFileSync as j,existsSync as C,writeFileSync as R,mkdirSync as F,statSync as W,appendFileSync as V}from"node:fs";import{dirname as $,join as _}from"node:path";import{tmpdir as b}from"node:os";import{createHash as X}from"node:crypto";import{spawn as Q}from"node:child_process";import{Einblendbestand as B,torWoerter as U}from"./einblendung-kern.js";import{rahmeEin as z,RAHMEN_HINWEIS as I}from"./einblendung-rahmen.js";import{istMarkiert as ee}from"./verdacht-marke.js";import{istTeamweit as te}from"./utils.js";import{istBlossesThema as re}from"./blosses-thema.js";import{leserText as ne}from"./seltenheitsbestand.js";import{mischeMitLeser as H}from"./leser.js";import{LeserSicherung as se,dateiSpeicher as oe,frageLeser as ie}from"./leser-sicherung.js";import{LESER_TIEFE_EINBLENDUNG as le,LESER_ZEITLIMIT_MS as ae}from"./rangfolge-stellschrauben.js";import{stufeEinblendungNachVersion as ce}from"./gueltigkeit-version.js";import{ARME as O,BASIS_MIN_BELEGE as ue,MERKMAL_KANDIDATEN as pe,OHNE_LERNEN as fe,entscheide as he,leseArmZaehlung as me,lernEinstellungen as de,lernenAuffrischen as ge,merkeEntscheidung as Ee,neuerSatz as _e,sitzungsKennung as be,zugKennung as ye}from"./lernen.js";export*from"./einblendung-kern.js";import{belohnungMelden as ht,lernenAuffrischen as mt,lernEinstellungen as dt,ARME as gt}from"./lernen.js";const Se=600*1e3,P=300*1e3,Ae=10*1e3,Ne=2e3,Ie=50,ve=60*1e3;function we(e,t){return t<P?{ttlMs:Ae,sofort:!0}:e<Ie?{ttlMs:ve,sofort:!1}:{ttlMs:Se,sofort:!1}}const D=8e3,ke=60*1e3,J=120,K=le,Me=1500,v=ae,Le=_(b(),"cachly-ambient-netlog.jsonl");function rt(e=process.cwd()){const t={apiUrl:process.env.CACHLY_API_URL||"https://api.cachly.dev",jwt:process.env.CACHLY_JWT||"",instanceId:process.env.CACHLY_BRAIN_INSTANCE_ID||""};if(t.jwt&&t.instanceId)return t;let r=e;for(let n=0;n<8;n++){const s=_(r,".mcp.json");if(C(s))try{const i=JSON.parse(j(s,"utf8"))?.mcpServers?.cachly?.env??{};if(t.apiUrl=t.apiUrl||i.CACHLY_API_URL||"https://api.cachly.dev",t.jwt=t.jwt||i.CACHLY_JWT||"",t.instanceId=t.instanceId||i.CACHLY_BRAIN_INSTANCE_ID||"",t.jwt&&t.instanceId)return t}catch{}const o=$(r);if(o===r)break;r=o}return t}function w(e){return X("sha1").update(e).digest("hex").slice(0,12)}function q(e){return _(b(),`cachly-ambient-bestand-${w(e)}.json`)}function xe(e){return _(b(),`cachly-leser-sicherung-${w(e)}.json`)}function Te(e,t="ambient-auffrischen"){return _(b(),`cachly-${t}-${w(e)}.lock`)}async function k(e,{fetchFn:t=fetch,zeitlimitMs:r=D}={}){try{const n=await t(`${e.apiUrl}/api/v1/instances/${e.instanceId}/export`,{headers:{Authorization:`Bearer ${e.jwt}`},signal:AbortSignal.timeout(r)});if(!n.ok)return null;const s=await n.json();return!Array.isArray(s?.lessons)||s.lessons.length===0&&typeof s.note=="string"&&s.note?null:s.lessons.map(o=>typeof o=="string"?je(o):o).filter(o=>!!o&&typeof o=="object")}catch{return null}}function je(e){try{return JSON.parse(e)}catch{return null}}function y(e,t,r="server"){const n=Date.now(),s=S(e),o=s?.seit??n;let i;r==="vorab"?i=t:r==="server"&&s?.vorab&&n-o<P&&(i=s.vorab);const c=r==="server"&&i?Ce(t,i):t;try{F($(e),{recursive:!0}),R(e,JSON.stringify({at:n,seit:o,lessons:c,...i?{vorab:i}:{}}),{mode:384})}catch{}return c}function Ce(e,t){const r=new Set(e.map(n=>n.topic));return[...e,...t.filter(n=>!r.has(n.topic))]}function nt(e,t){if(!e||t.length===0)return!1;const r=q(e);return(S(r)?.lessons.length??0)>0?!1:(y(r,t,"vorab"),!0)}function S(e){try{const t=JSON.parse(j(e,"utf8"));if(Array.isArray(t?.lessons)){const r=Number(t.at)||0;return{at:r,seit:Number(t.seit)||r,lessons:t.lessons,...Array.isArray(t.vorab)?{vorab:t.vorab}:{}}}}catch{}return null}function Re(e,t,{zweck:r,ordner:n}={}){const s=Te(e.instanceId,r);try{if(C(s)&&Date.now()-W(s).mtimeMs<ke)return!1;R(s,String(Date.now()),{mode:384})}catch{return!1}try{return Q(process.execPath,t,{detached:!0,stdio:"ignore",...n?{cwd:n}:{},env:{...process.env,CACHLY_API_URL:e.apiUrl,CACHLY_JWT:e.jwt,CACHLY_BRAIN_INSTANCE_ID:e.instanceId}}).unref(),!0}catch{return!1}}async function $e(e,{force:t=!1,nebenlauf:r,abrufMs:n=D,lernen:s=!1,vorabSchliessen:o=!1,fetchFn:i}={}){if(!e.jwt||!e.instanceId)return{lessons:[],quelle:"nicht-eingerichtet"};const c=q(e.instanceId);if(t){const[u]=await Promise.all([k(e,{fetchFn:i,zeitlimitMs:n}),s?ge(e,{fetchFn:i}):void 0]);if(u)return{lessons:y(c,u,o?"abschluss":"server"),quelle:"server"};const p=S(c);return p?{lessons:p.lessons,quelle:"platte-alt"}:{lessons:[],quelle:"server-nicht-erreichbar"}}const a=S(c);if(a){const u=Date.now(),p=we(a.lessons.length,u-a.seit);if(u-a.at<p.ttlMs)return{lessons:a.lessons,quelle:"platte"};if(p.sofort){const m=await k(e,{fetchFn:i,zeitlimitMs:Math.min(n,Ne)});return m?{lessons:y(c,m),quelle:"server"}:{lessons:a.lessons,quelle:"platte-alt"}}return r&&Re(e,r),{lessons:a.lessons,quelle:"platte-alt"}}const l=await k(e,{fetchFn:i,zeitlimitMs:n});return l?{lessons:y(c,l),quelle:"server"}:{lessons:[],quelle:"server-nicht-erreichbar"}}function M(e){return Math.ceil(String(e).length/4)}function L(e){const t=e.severity?`[${e.severity}] `:"",r=String(e.what_worked??"").replace(/\s+/g," ").trim(),n=r.length>J?`${r.slice(0,J)}\u2026`:r,s=typeof e.versionshinweis=="string"?` [${e.versionshinweis}]`:"";return`- ${t}${e.topic}${s}: ${n}`}const A={lessons:[],tokens:0,topScore:0,belege:0};function x(e,t,r){if(e.length===0)return{...A};const n=[];let s=0;e=ce(e);for(const{lektion:o}of e.slice(0,t)){const i=M(L(o));if(s+i>r)break;n.push(o),s+=i}return{lessons:n,tokens:s,topScore:Math.round(e[0].punkte*100)/100,belege:e[0].belege}}function st(e,t,{minBelege:r=2,topK:n=3,tokenBudget:s=600}={}){if(!Array.isArray(t)||t.length===0)return{...A};if(U(e).length===0)return{...A};const o=new B(t).sortiere(e).filter(i=>i.belege>=r);return o.length===0?{...A}:x(o,n,s)}function Be(e){return ne(e,Me)}async function G(e,t,r,{zeitlimitMs:n=v,fetchFn:s}={}){if(!e?.jwt||!e?.instanceId||r.length===0)return{art:"ohne"};if(["0","off","aus","false"].includes(String(process.env.CACHLY_LESER||"").toLowerCase()))return{art:"ohne"};const o=new se(oe(xe(e.instanceId)));return ie({url:`${e.apiUrl}/api/v1/rerank`,jwt:e.jwt,frage:t,texte:r,instanceId:e.instanceId,zeitlimitMs:n,fetchFn:s},o)}async function ot(e,t,r,n={}){const s=await G(e,t,r,n);return s.art==="punkte"?{scores:s.scores,provider:s.provider,ms:s.ms}:null}async function Y(e,t,r,{minBelege:n,tiefe:s,zeitlimitMs:o,fetchFn:i}){const c={sortiert:[],leser:"aus",leserMs:0};if(!Array.isArray(t)||t.length===0||U(e).length===0)return c;let a=new B(t).sortiere(e).filter(p=>p.belege>=n);if(a.length===0)return c;let l="aus",u=0;if(a.length>1&&s>0){const p=a.slice(0,s),d=a.slice(s),m=await G(r,e,p.map(E=>Be(E.lektion)),{zeitlimitMs:o,fetchFn:i});m.art==="punkte"?(a=[...H(p.map(h=>h.punkte),m.scores,1).map(h=>({...p[h],leser:m.scores[h]})),...d],l=m.provider,u=m.ms):m.art==="uebersprungen"&&(l="uebersprungen")}return{sortiert:a,leser:l,leserMs:u}}async function it(e,t,r,{minBelege:n=2,topK:s=3,tokenBudget:o=600,tiefe:i=K,zeitlimitMs:c=v,fetchFn:a}={}){const l=await Y(e,t,r,{minBelege:n,tiefe:i,zeitlimitMs:c,fetchFn:a});return{...x(l.sortiert,s,o),leser:l.leser,leserMs:l.leserMs}}function Ue(e){if(!e.lessons.length)return"";const t=e.lessons.map(L).join(`
2
2
  `);return`\u{1F9E0} Cachly Brain \u2014 relevant lessons for this task (auto-recall, ${e.lessons.length}):
3
- ${U(t)}
4
- (ambient-recall \xB7 ~${e.tokens} tokens \xB7 match score ${e.topScore})`}const ze=5;function lt(e){const t=e.filter(l=>!ee(l)&&te(l));if(!t.length)return"";const r=t.filter(l=>{const c=String(l.topic??"");return!(/^auto:/.test(c)||re(c))}),n=[...r.length?r:t].sort((l,c)=>(Number(c.recall_count)||0)-(Number(l.recall_count)||0)).slice(0,ze),s=n.map(M).join(`
5
- `),o=n.some(l=>(Number(l.recall_count)||0)>0),i=o?"Top by proven reuse":"Starter tips (not yet from your project)",a=o?z:z.replace("Stored notes from earlier sessions.","General starter notes, not yet from your project.");return`\u{1F9E0} Cachly Brain \u2014 ambient recall active (${t.length} lessons). ${i}:
6
- ${U(s,a)}
7
- (Relevant lessons for each task are auto-injected per prompt. ~${w(s)} tokens.)`}function at(e,t){return t?JSON.stringify({hookSpecificOutput:{hookEventName:e,additionalContext:t}}):""}function He(e,t){return e.map((r,n)=>({x:r,rang:n,gezeigt:t.includes(r.lektion)})).filter(({rang:r,gezeigt:n})=>r<pe||n).map(({x:r,rang:n,gezeigt:s})=>({thema:String(r.lektion.topic??""),rang:n,punkte:Math.round(r.punkte*1e3)/1e3,belege:r.belege,leser:typeof r.leser=="number"&&Number.isFinite(r.leser)?Math.round(r.leser*1e3)/1e3:null,gezeigt:s}))}async function ct(e,t,{nebenlauf:r,abrufMs:n,leser:s=!0,session:o=null,protokoll:i=!0,ereignis:a="UserPromptSubmit",editor:l="",lernen:c=!0,fetchFn:m}={}){const{lessons:u,quelle:d}=await $e(t,{nebenlauf:r,abrufMs:n,fetchFn:m}),h=de(),E=c&&h.aktiv&&a==="UserPromptSubmit"&&!!t.instanceId,f=E?he({instanceId:t.instanceId,sitzung:o,prompt:e,zaehlung:me(t.instanceId),einstellungen:h}):fe,x=O[f.arm]??O[0],g=await Y(e,u,t,{minBelege:ue,tiefe:s?K:0,zeitlimitMs:I,fetchFn:m}),p={...L(g.sortiert.filter(Z=>Z.belege>=x.minBelege),x.topK,600),leser:g.leser,leserMs:g.leserMs},N=f.kontrolle?"":Ue(p);if(E&&g.sortiert.length>0&&Ee(t.instanceId,o,_e({sitzung:be(o),zug:Se(e),ereignis:a,editor:l,arm:f.arm,kontrolle:f.kontrolle,erkundet:f.erkundet,ausgewaehlt:p.lessons.length,kandidatenZahl:g.sortiert.length,belege:p.belege,topScore:p.topScore,leser:p.leser,leserMs:p.leserMs,quelle:d,bestand:u.length,kandidaten:He(g.sortiert,p.lessons)})),i)try{V(Le,JSON.stringify({at:Date.now(),session:o,prompt_tokens:w(e),injected_tokens:N?p.tokens:0,matches:N?p.lessons.length:0,arm:f.arm,kontrolle:f.kontrolle,ausgewaehlt:p.lessons.length,top_score:p.topScore,belege:p.belege,leser:p.leser,leser_ms:p.leserMs,quelle:d,bestand:u.length})+`
8
- `)}catch{}return{kontext:N,auswahl:p,quelle:d,bestand:u.length,entscheidung:f}}export{D as ABRUF_TIMEOUT_MS,J as ANZEIGE_ZEICHEN,gt as ARME,Ae as BESTAND_TTL_JUNG_MS,ve as BESTAND_TTL_KLEIN_MS,ye as BESTAND_TTL_MS,Ne as JUNG_ABRUF_MS,P as JUNG_FENSTER_MS,Ie as KLEIN_LEKTIONEN,I as LESER_HOOK_ZEITLIMIT_MS,Me as LESER_MAX_ZEICHEN,K as LESER_TIEFE,Le as NETZ_PROTOKOLL,ze as SITZUNG_TOP_N,ht as belohnungMelden,ke as bestandFrist,q as bestandPfad,je as ergaenzeUmVorab,w as estimateTokens,$e as holeBestand,at as hookAusgabe,dt as lernEinstellungen,mt as lernenAuffrischen,G as leserAnfrageApi,ot as leserPunkteApi,Be as leserText,H as mischeMitLeser,ct as promptEinblendung,Ue as promptKontext,M as renderLesson,rt as resolveConfig,nt as schreibeVorabBestand,st as selectRelevant,it as selectRelevantMitLeser,xe as sicherungsPfad,lt as sitzungsKontext,Re as starteNebenlauf};
3
+ ${z(t)}
4
+ (ambient-recall \xB7 ~${e.tokens} tokens \xB7 match score ${e.topScore})`}const ze=5;function lt(e){const t=e.filter(l=>!ee(l)&&te(l));if(!t.length)return"";const r=t.filter(l=>{const u=String(l.topic??"");return!(/^auto:/.test(u)||re(u))}),n=[...r.length?r:t].sort((l,u)=>(Number(u.recall_count)||0)-(Number(l.recall_count)||0)).slice(0,ze),s=n.map(L).join(`
5
+ `),o=n.some(l=>(Number(l.recall_count)||0)>0),i=!o&&n.some(l=>l.source==="brain_from_git"||Array.isArray(l.tags)&&l.tags.includes("git-history")),c=o?"Top by proven reuse":i?"From this project's git history (not reused yet)":"Starter tips (not yet from your project)",a=o?I:i?I.replace("Stored notes from earlier sessions.","Notes drawn from this project's git history."):I.replace("Stored notes from earlier sessions.","General starter notes, not yet from your project.");return`\u{1F9E0} Cachly Brain \u2014 ambient recall active (${t.length} lessons). ${c}:
6
+ ${z(s,a)}
7
+ (Relevant lessons for each task are auto-injected per prompt. ~${M(s)} tokens.)`}function at(e,t){return t?JSON.stringify({hookSpecificOutput:{hookEventName:e,additionalContext:t}}):""}function He(e,t){return e.map((r,n)=>({x:r,rang:n,gezeigt:t.includes(r.lektion)})).filter(({rang:r,gezeigt:n})=>r<pe||n).map(({x:r,rang:n,gezeigt:s})=>({thema:String(r.lektion.topic??""),rang:n,punkte:Math.round(r.punkte*1e3)/1e3,belege:r.belege,leser:typeof r.leser=="number"&&Number.isFinite(r.leser)?Math.round(r.leser*1e3)/1e3:null,gezeigt:s}))}async function ct(e,t,{nebenlauf:r,abrufMs:n,leser:s=!0,session:o=null,protokoll:i=!0,ereignis:c="UserPromptSubmit",editor:a="",lernen:l=!0,fetchFn:u}={}){const{lessons:p,quelle:d}=await $e(t,{nebenlauf:r,abrufMs:n,fetchFn:u}),m=de(),E=l&&m.aktiv&&c==="UserPromptSubmit"&&!!t.instanceId,h=E?he({instanceId:t.instanceId,sitzung:o,prompt:e,zaehlung:me(t.instanceId),einstellungen:m}):fe,T=O[h.arm]??O[0],g=await Y(e,p,t,{minBelege:ue,tiefe:s?K:0,zeitlimitMs:v,fetchFn:u}),f={...x(g.sortiert.filter(Z=>Z.belege>=T.minBelege),T.topK,600),leser:g.leser,leserMs:g.leserMs},N=h.kontrolle?"":Ue(f);if(E&&g.sortiert.length>0&&Ee(t.instanceId,o,_e({sitzung:be(o),zug:ye(e),ereignis:c,editor:a,arm:h.arm,kontrolle:h.kontrolle,erkundet:h.erkundet,ausgewaehlt:f.lessons.length,kandidatenZahl:g.sortiert.length,belege:f.belege,topScore:f.topScore,leser:f.leser,leserMs:f.leserMs,quelle:d,bestand:p.length,kandidaten:He(g.sortiert,f.lessons)})),i)try{V(Le,JSON.stringify({at:Date.now(),session:o,prompt_tokens:M(e),injected_tokens:N?f.tokens:0,matches:N?f.lessons.length:0,arm:h.arm,kontrolle:h.kontrolle,ausgewaehlt:f.lessons.length,top_score:f.topScore,belege:f.belege,leser:f.leser,leser_ms:f.leserMs,quelle:d,bestand:p.length})+`
8
+ `)}catch{}return{kontext:N,auswahl:f,quelle:d,bestand:p.length,entscheidung:h}}export{D as ABRUF_TIMEOUT_MS,J as ANZEIGE_ZEICHEN,gt as ARME,Ae as BESTAND_TTL_JUNG_MS,ve as BESTAND_TTL_KLEIN_MS,Se as BESTAND_TTL_MS,Ne as JUNG_ABRUF_MS,P as JUNG_FENSTER_MS,Ie as KLEIN_LEKTIONEN,v as LESER_HOOK_ZEITLIMIT_MS,Me as LESER_MAX_ZEICHEN,K as LESER_TIEFE,Le as NETZ_PROTOKOLL,ze as SITZUNG_TOP_N,ht as belohnungMelden,we as bestandFrist,q as bestandPfad,Ce as ergaenzeUmVorab,M as estimateTokens,$e as holeBestand,at as hookAusgabe,dt as lernEinstellungen,mt as lernenAuffrischen,G as leserAnfrageApi,ot as leserPunkteApi,Be as leserText,H as mischeMitLeser,ct as promptEinblendung,Ue as promptKontext,L as renderLesson,rt as resolveConfig,nt as schreibeVorabBestand,st as selectRelevant,it as selectRelevantMitLeser,xe as sicherungsPfad,lt as sitzungsKontext,Re as starteNebenlauf};