PageSourceSearch

https://zencap.ai/_next/static/chunks/pages/admin/forge-memory-dc190ac29384f2e0.js

js zencap.ai collected 2026-10-05 15:15:25 UTC 13,373 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[12739],{22506:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>x});var r=t(37876),a=t(14232),l=t(77328),c=t.n(l),n=t(88867);function d(e){return"$".concat(e.toFixed(4))}function i(e){if(!e)return"—";let s=new Date(e);return isNaN(s.getTime())?e:s.toLocaleString()}function o(e,s){return e?e.length>s?"".concat(e.slice(0,s),"…"):e:"—"}function x(){let[e,s]=(0,a.useState)(null),[t,l]=(0,a.useState)(null),[x,p]=(0,a.useState)(!0);async function y(){p(!0),l(null);try{let e=await fetch("/api/admin/forge-memory-stats",{credentials:"include"});if(!e.ok)throw Error("HTTP ".concat(e.status));s(await e.json())}catch(e){l(e.message)}finally{p(!1)}}return(0,a.useEffect)(()=>{y()},[]),(0,r.jsxs)(n.m,{title:"FORGE Memory",children:[(0,r.jsx)(c(),{children:(0,r.jsx)("title",{children:"FORGE Memory — ZenCap Admin"})}),(0,r.jsxs)("div",{className:"p-6 space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-2xl font-semibold text-navy-900 dark:text-white",children:"FORGE Memory"}),(0,r.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Live H1.1 web memory corpus (skills + sessions + reflections)"})]}),(0,r.jsx)("button",{onClick:y,disabled:x,className:"px-4 py-2 bg-teal-600 hover:bg-teal-700 disabled:bg-gray-400 text-white rounded text-sm font-medium",children:x?"Refreshing…":"Refresh"})]}),t&&(0,r.jsxs)("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-300 dark:border-red-700 rounded text-red-800 dark:text-red-300 text-sm",children:["Failed to load: ",t]}),e&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"p-4 rounded border ".concat(e.enabled?"bg-green-50 dark:bg-green-900/20 border-green-300 dark:border-green-700":"bg-yellow-50 dark:bg-yellow-900/20 border-yellow-300 dark:border-yellow-700"),children:[(0,r.jsxs)("div",{className:"font-medium",children:["FORGE_MEMORY_PG_ENABLED:"," ",(0,r.jsx)("span",{className:e.enabled?"text-green-700 dark:text-green-300":"text-yellow-700 dark:text-yellow-300",children:e.enabled?"ON":"OFF"})]}),(0,r.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1",children:e.enabled?"chat.ts post-loop UPSERTs to forge_sessions; reflect-cron generates reflections hourly; extract-skills-cron mines new skills daily 04:00 UTC.":"Set FORGE_MEMORY_PG_ENABLED=1 in Vercel env to activate the memory loop."})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[(0,r.jsx)(h,{label:"Skills",value:e.skills.total,sub:"".concat(e.skills.never_used," never used")}),(0,r.jsx)(h,{label:"Sessions",value:e.sessions.total,sub:"".concat(e.sessions.last_24h," in 24h \xb7 ").concat(e.sessions.last_7d," in 7d")}),(0,r.jsx)(h,{label:"Reflections",value:e.reflections.total,sub:"".concat(e.reflections.prompt_bearing," prompt-bearing \xb7 ").concat(e.reflections.last_24h," in 24h")}),(0,r.jsx)(h,{label:"GEPA threshold (≥50)",value:e.reflections.gepa_threshold_met?"✓ MET":"".concat(e.reflections.prompt_bearing,"/50"),sub:e.reflections.gepa_threshold_met?"Wave 2 RSI corpus unblocked":"".concat(50-e.reflections.prompt_bearing," more prompt-bearing reflections needed")})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Reflection corpus breakdown"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,r.jsx)(m,{title:"By outcome",data:e.reflections.by_outcome}),(0,r.jsx)(m,{title:"By source",data:e.reflections.by_source}),(0,r.jsx)(m,{title:"By narrator model",data:e.reflections.by_model})]})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Skill corpus breakdown"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(m,{title:"By source (Voyager discovery vs CLI)",data:e.skills.by_source}),(0,r.jsxs)("div",{className:"p-4 bg-gray-50 dark:bg-gray-900/40 rounded",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-500 mb-2",children:"Auto-discovered skills"}),(0,r.jsxs)("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:["Skills with source = ",(0,r.jsx)("code",{children:"web-extractor"})," were learned automatically from FORGE's reflection corpus. Other sources are manual or CLI-synced."]}),(0,r.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-2",children:"Cadence: extraction runs daily at 04:00 UTC. Idempotent at the skill-name level."})]})]})]}),e.skills.effectiveness&&e.skills.effectiveness.length>0&&(0,r.jsxs)("section",{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Skill effectiveness (Wave 2 RSI self-correction signal)"}),(0,r.jsxs)("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-3",children:["JOINs ",(0,r.jsx)("code",{children:"forge_sessions.metadata.injected_skill_ids"})," with"," ",(0,r.jsx)("code",{children:"forge_reflections.outcome"}),". A skill is a"," ",(0,r.jsx)("span",{className:"font-semibold text-orange-700 dark:text-orange-300",children:"retirement candidate"})," ",'if reflected_sessions ≥ 5 AND success_rate < 30%. Skills with no reflected sessions yet are shown as "—" (not yet enough signal).']}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"min-w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-left text-xs uppercase text-gray-500 border-b",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"py-2 pr-4",children:"Name"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Source"}),(0,r.jsx)("th",{className:"py-2 pr-4 text-right",children:"Use count"}),(0,r.jsx)("th",{className:"py-2 pr-4 text-right",children:"Sessions"}),(0,r.jsx)("th",{className:"py-2 pr-4 text-right",children:"Reflected"}),(0,r.jsx)("th",{className:"py-2 pr-4 text-right",children:"✓ S"}),(0,r.jsx)("th",{className:"py-2 pr-4 text-right",children:"~ P"}),(0,r.jsx)("th",{className:"py-2 pr-4 text-right",children:"✗ F"}),(0,r.jsx)("th",{className:"py-2 pr-4 text-right",children:"Success %"})]})}),(0,r.jsx)("tbody",{children:e.skills.effectiveness.map(e=>{var s,t;let a=e.total_reflected_sessions>=5&&null!==e.success_rate_pct&&e.success_rate_pct<30,l=0===e.total_reflected_sessions;return(0,r.jsxs)("tr",{className:"border-b border-gray-100 dark:border-gray-800 ".concat(a?"bg-orange-50 dark:bg-orange-900/20":""),children:[(0,r.jsxs)("td",{className:"py-2 pr-4 font-mono text-xs",children:[e.name,a&&(0,r.jsx)("span",{className:"ml-2 text-xs text-orange-700 dark:text-orange-300 font-semibold",children:"← retire c
1andidate"})]}),(0,r.jsx)("td",{className:"py-2 pr-4 text-xs text-gray-500",children:null!=(t=e.source)?t:"(unset)"}),(0,r.jsx)("td",{className:"py-2 pr-4 text-right",children:e.use_count}),(0,r.jsx)("td",{className:"py-2 pr-4 text-right",children:e.total_sessions_with_skill}),(0,r.jsx)("td",{className:"py-2 pr-4 text-right",children:e.total_reflected_sessions}),(0,r.jsx)("td",{className:"py-2 pr-4 text-right text-green-700 dark:text-green-300",children:e.success_count}),(0,r.jsx)("td",{className:"py-2 pr-4 text-right text-yellow-700 dark:text-yellow-300",children:e.partial_count}),(0,r.jsx)("td",{className:"py-2 pr-4 text-right text-red-700 dark:text-red-300",children:e.failure_count}),(0,r.jsx)("td",{className:"py-2 pr-4 text-right font-semibold",children:l?(0,r.jsx)("span",{className:"text-gray-400",children:"—"}):(0,r.jsxs)("span",{className:null!==e.success_rate_pct&&e.success_rate_pct<50?"text-red-700 dark:text-red-300":null!==e.success_rate_pct&&e.success_rate_pct<75?"text-yellow-700 dark:text-yellow-300":"text-green-700 dark:text-green-300",children:[null==(s=e.success_rate_pct)?void 0:s.toFixed(1),"%"]})})]},e.skill_id)})})]})})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Top skills by use count"}),0===e.skills.top_by_use_count.length?(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No skills used yet."}):(0,r.jsxs)("table",{className:"min-w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-left text-xs uppercase text-gray-500 border-b",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"py-2 pr-4",children:"Name"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Description"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Use count"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Last used"})]})}),(0,r.jsx)("tbody",{children:e.skills.top_by_use_count.map(e=>(0,r.jsxs)("tr",{className:"border-b border-gray-100 dark:border-gray-800",children:[(0,r.jsx)("td",{className:"py-2 pr-4 font-mono text-xs",children:e.name}),(0,r.jsx)("td",{className:"py-2 pr-4",children:o(e.description,80)}),(0,r.jsx)("td",{className:"py-2 pr-4",children:e.use_count}),(0,r.jsx)("td",{className:"py-2 pr-4 text-xs text-gray-500",children:e.last_used_at?i(e.last_used_at):"—"})]},e.name))})]})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Recent sessions"}),0===e.sessions.recent.length?(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No sessions yet."}):(0,r.jsxs)("table",{className:"min-w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-left text-xs uppercase text-gray-500 border-b",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"py-2 pr-4",children:"Session"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Mode"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Model"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Turns"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Tools"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Cost"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Last active"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Task"})]})}),(0,r.jsx)("tbody",{children:e.sessions.recent.map(e=>{var s,t;return(0,r.jsxs)("tr",{className:"border-b border-gray-100 dark:border-gray-800",children:[(0,r.jsxs)("td",{className:"py-2 pr-4 font-mono text-xs",children:[e.session_id.slice(0,12),"…"]}),(0,r.jsx)("td",{className:"py-2 pr-4",children:null!=(s=e.mode)?s:"—"}),(0,r.jsx)("td",{className:"py-2 pr-4 text-xs",children:null!=(t=e.model)?t:"—"}),(0,r.jsx)("td",{className:"py-2 pr-4",children:e.turn_count}),(0,r.jsx)("td",{className:"py-2 pr-4",children:e.tool_call_count}),(0,r.jsx)("td",{className:"py-2 pr-4 font-mono text-xs",children:d(e.total_cost_usd)}),(0,r.jsx)("td",{className:"py-2 pr-4 text-xs text-gray-500",children:i(e.last_active_at)}),(0,r.jsx)("td",{className:"py-2 pr-4",children:o(e.task_summary,60)})]},e.session_id)})})]})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Daily session activity (14d)"}),0===e.sessions.daily.length?(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No activity in the last 14 days."}):(0,r.jsxs)("table",{className:"min-w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-left text-xs uppercase text-gray-500 border-b",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"py-2 pr-4",children:"Day"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Sessions"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Turns"}),(0,r.jsx)("th",{className:"py-2 pr-4",children:"Cost"})]})}),(0,r.jsx)("tbody",{children:e.sessions.daily.map(e=>(0,r.jsxs)("tr",{className:"border-b border-gray-100 dark:border-gray-800",children:[(0,r.jsx)("td",{className:"py-2 pr-4",children:e.day}),(0,r.jsx)("td",{className:"py-2 pr-4",children:e.sessions}),(0,r.jsx)("td",{className:"py-2 pr-4",children:e.turns}
1),(0,r.jsx)("td",{className:"py-2 pr-4 font-mono text-xs",children:d(Number(e.cost_usd)||0)})]},e.day))})]})]})]})]})]})}function h(e){let{label:s,value:t,sub:a}=e;return(0,r.jsxs)("div",{className:"p-4 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded",children:[(0,r.jsx)("div",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:s}),(0,r.jsx)("div",{className:"text-2xl font-semibold mt-1 text-navy-900 dark:text-white",children:t}),a&&(0,r.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:a})]})}function m(e){let{title:s,data:t}=e,a=Object.entries(t).sort((e,s)=>s[1]-e[1]),l=a.reduce((e,s)=>{let[,t]=s;return e+t},0);return(0,r.jsxs)("div",{className:"p-4 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded",children:[(0,r.jsx)("div",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400 mb-2",children:s}),0===a.length?(0,r.jsx)("div",{className:"text-sm text-gray-500",children:"no data yet"}):(0,r.jsx)("div",{className:"space-y-1 text-sm",children:a.map(e=>{let[s,t]=e;return(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{className:"font-mono text-xs truncate pr-2",children:s}),(0,r.jsxs)("span",{className:"text-gray-600 dark:text-gray-400",children:[t," ",(0,r.jsxs)("span",{className:"text-xs text-gray-500",children:["(",l>0?Math.round(t/l*100):0,"%)"]})]})]},s)})})]})}},40354:(e,s,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/forge-memory",function(){return t(22506)}])}},e=>{e.O(0,[12762,14596,76552,67632,65353,59896,18874,88867,10353,6584,36896,38625,43857,74567,56158,83585,16153,91263,90636,82216,38792],()=>e(e.s=40354)),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.