@capybara-hq/plugin-memory 0.1.0-rc.0 → 0.1.0-rc.2
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/.capybara-plugin/plugin.json +6 -6
- package/dist/client/client.mjs +1 -1
- package/dist/client/styles/memory.css +45 -0
- package/dist/index.mjs +2 -2
- package/icon.svg +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://capybarahq.com/schemas/plugin.v1.schema.json",
|
|
3
3
|
"schemaVersion": 1,
|
|
4
4
|
"name": "memory",
|
|
5
|
-
"version": "0.1.0-rc.
|
|
5
|
+
"version": "0.1.0-rc.2",
|
|
6
6
|
"publisher": "Capybara",
|
|
7
7
|
"description": {
|
|
8
8
|
"en": "Memory for agents: each agent remembers each member across conversations, with an index at run start, memory tools, hybrid search and a memory page",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"entry": "./dist/index.mjs",
|
|
19
19
|
"manifest": {
|
|
20
20
|
"name": "memory",
|
|
21
|
-
"version": "0.1.0-rc.
|
|
21
|
+
"version": "0.1.0-rc.2",
|
|
22
22
|
"sdk": "^0.1.0-rc.19",
|
|
23
23
|
"provides": [
|
|
24
24
|
"context@1"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"client": true,
|
|
30
30
|
"ui": {
|
|
31
31
|
"components": [
|
|
32
|
-
"
|
|
32
|
+
"overview"
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
35
|
"tools": [
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"ui": [
|
|
63
63
|
{
|
|
64
|
-
"id": "
|
|
64
|
+
"id": "overview",
|
|
65
65
|
"title": {
|
|
66
66
|
"zh": "记忆",
|
|
67
67
|
"en": "Memory"
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"./dist/client/styles/memory.css"
|
|
80
80
|
],
|
|
81
81
|
"integrity": {
|
|
82
|
-
"./dist/client/client.mjs": "sha384-
|
|
83
|
-
"./dist/client/styles/memory.css": "sha384-
|
|
82
|
+
"./dist/client/client.mjs": "sha384-39CF00+4BxW9NA/1lgHdooTHvsjSoUGrB1sler9LxvdALiV/pFBoyhOJO/e1Xx5L",
|
|
83
|
+
"./dist/client/styles/memory.css": "sha384-2kJzQZ84fDCzoeEsCBBIVXZcy8pzq+mUhMQZCOYt2shNPqxY0y+JeMCHqOuVIb8a"
|
|
84
84
|
},
|
|
85
85
|
"apiVersion": 1
|
|
86
86
|
}
|
package/dist/client/client.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineClientExtension as Dn,defineComponent as Ln}from"@capybara-hq/plugin-client";import{Badge as dn,Button as q,Icon as te,KeyValue as mn,Spinner as Ke,Stack as Ce,Text as W,useAccess as un,useAction as hn,useClientStorage as yn,useLocale as oe,usePrefersReducedMotion as gn,useView as pn}from"@capybara-hq/plugin-client";import{useCallback as U,useEffect as Z,useMemo as fn,useRef as G,useState as F}from"react";var me=["user","feedback","project","reference"],tn="agent",De=e=>`dir:${e}`;function rn(e){return Math.min(18,4+1.2*Math.sqrt(Math.max(0,e)))}function on(e,n){if(e===null)return .25;let t=Date.parse(e);if(Number.isNaN(t))return .25;let l=Math.max(0,(n-t)/864e5);return Math.max(.25,Math.exp(-l/30))}function ve(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0)/4294967296}var an=e=>e<=0?0:120+(e-1)*80;function Re(e,n){let t=[],l=new Map,d=[],a=o=>{let s=t.length;return t.push({...o,x:0,y:0,vx:0,vy:0,ring:0}),l.set(o.id,s),d.push([]),o.parent>=0&&d[o.parent]?.push(s),s};a({id:tn,kind:"agent",label:e.agentLabel,path:"",type:null,parent:-1,depth:0,pinned:!0,r:13,brightness:1,recent:!1,phase:0,memory:null});let i=o=>{let s=l.get(De(o));if(s!==void 0)return s;let g=o.lastIndexOf("/"),p=g===-1?0:i(o.slice(0,g)),w=o.split("/")[0];return a({id:De(o),kind:"dir",label:o.slice(g+1),path:o,type:me.includes(w)?w:null,parent:p,depth:o.split("/").length,pinned:!1,r:4.5,brightness:1,recent:!1,phase:ve(o),memory:null})};for(let o of me)i(o);let M=[...e.nodes].sort((o,s)=>o.path<s.path?-1:o.path>s.path?1:0);for(let o of M){if(l.has(o.id))continue;let s=o.dir===""?0:i(o.dir),g=o.path.slice(o.path.lastIndexOf("/")+1).replace(/\.md$/,""),p=on(o.lastRecalledAt,n.now),w=o.lastRecalledAt===null?Number.NaN:Date.parse(o.lastRecalledAt);a({id:o.id,kind:"memory",label:g,path:o.path,type:o.type,parent:s,depth:(t[s]?.depth??0)+1,pinned:!1,r:rn(o.recalls),brightness:p,recent:!Number.isNaN(w)&&n.now-w<7*864e5,phase:ve(o.id),memory:o})}let I=[];for(let o=1;o<t.length;o++){let s=t[o];I.push({a:s.parent,b:o,kind:"tree",phase:s.phase})}let x=new Set;for(let o of e.edges){let s=l.get(o.from),g=l.get(o.to);if(s===void 0||g===void 0||s===g)continue;let p=o.kind==="semantic"?`s${Math.min(s,g)}~${Math.max(s,g)}`:`l${s}>${g}`;x.has(p)||(x.add(p),I.push({a:s,b:g,kind:o.kind,phase:ve(p)}))}let P=t.map(()=>new Set);for(let o of I)P[o.a]?.add(o.b),P[o.b]?.add(o.a);let b=new Array(t.length).fill(0);for(let o=t.length-1;o>=0;o--){let s=t[o]?.kind==="memory"?1:0,g=(d[o]??[]).reduce((p,w)=>p+(b[w]??0),0);b[o]=Math.max(1,s+g)}let h=(o,s,g)=>{let p=t[o],w=d[o]??[],R=s,X=w.reduce((H,B)=>H+(b[B]??1),0);w.forEach((H,B)=>{let j=(g-s)*(b[H]??1)/Math.max(1,X),_=t[H],Q=R+j/2+(_.phase-.5)*j*.3;_.ring=_.kind==="dir"?an(_.depth):(p.kind==="agent"?70:p.ring)+46+B%3*20+_.r,_.x=Math.cos(Q)*_.ring,_.y=Math.sin(Q)*_.ring,h(H,R,R+j),R+=j})};h(0,-Math.PI/2,3*Math.PI/2);let r=n.previous??null;if(r!==null)for(let o of t){let s=r.index.get(o.id),g=s===void 0?void 0:r.nodes[s];g!==void 0&&(o.x=g.x,o.y=g.y)}return{nodes:t,edges:I,index:l,adjacency:P,alpha:r===null?1:.4}}function ke(e){let{nodes:n}=e,t=e.alpha,l=110,d=new Map;n.forEach((a,i)=>{let M=`${Math.floor(a.x/l)},${Math.floor(a.y/l)}`,I=d.get(M);I===void 0?d.set(M,[i]):I.push(i)});for(let a=0;a<n.length;a++){let i=n[a],M=Math.floor(i.x/l),I=Math.floor(i.y/l);for(let x=-1;x<=1;x++)for(let P=-1;P<=1;P++)for(let b of d.get(`${M+x},${I+P}`)??[]){if(b<=a)continue;let h=n[b],r=h.x-i.x,o=h.y-i.y,s=r*r+o*o;if(s===0&&(r=(i.phase-h.phase)*.1+.01,o=.01,s=r*r+o*o),s>l*l)continue;let g=Math.sqrt(s),p=60*t/g,w=i.r+h.r+6;g<w&&(p+=(w-g)*.5);let R=r/g*p,X=o/g*p;i.vx-=R,i.vy-=X,h.vx+=R,h.vy+=X}}for(let a of e.edges){if(a.kind==="semantic")continue;let i=n[a.a],M=n[a.b],I=M.x-i.x,x=M.y-i.y,P=Math.sqrt(I*I+x*x)||1,b=a.kind==="tree"?Math.max(30,M.ring-i.ring):90,h=(P-b)/P*t*(a.kind==="tree"?.12:.015);i.vx+=I*h*.5,i.vy+=x*h*.5,M.vx-=I*h*.5,M.vy-=x*h*.5}for(let a of n){if(a.kind==="agent")continue;let i=Math.sqrt(a.x*a.x+a.y*a.y)||1,M=(a.ring-i)/i*.08*t;a.vx+=a.x*M,a.vy+=a.y*M}for(let a of n){if(a.pinned){a.vx=0,a.vy=0,a.kind==="agent"&&(a.x=0,a.y=0);continue}a.vx*=.6,a.vy*=.6,a.x+=a.vx,a.y+=a.vy}return e.alpha+=(0-e.alpha)*.03,e.alpha}function Oe(e,n=240){for(let t=0;t<n&&e.alpha>=.005;t++)ke(e);e.alpha=0}function Ne(e,n,t,l=3){let d=-1,a=Number.POSITIVE_INFINITY;for(let i=e.nodes.length-1;i>=0;i--){let M=e.nodes[i],I=Math.hypot(M.x-n,M.y-t);I<=M.r+l&&I<a&&(d=i,a=I)}return d}var _e=.15,sn=4,ae=(e,n,t)=>({x:(n-e.x)/e.k,y:(t-e.y)/e.k});function Me(e,n,t,l=48){let d=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,M=Number.NEGATIVE_INFINITY;for(let b of e.nodes)d=Math.min(d,b.x-b.r),a=Math.min(a,b.y-b.r),i=Math.max(i,b.x+b.r),M=Math.max(M,b.y+b.r);let I=Math.max(1,i-d),x=Math.max(1,M-a),P=Math.min(1.6,Math.max(_e,Math.min((n-2*l)/I,(t-2*l)/x)));return{k:P,x:n/2-(d+i)/2*P,y:t/2-(a+M)/2*P}}function $e(e,n,t,l){let d=Math.min(sn,Math.max(_e,e.k*l)),a=ae(e,n,t);return{k:d,x:n-a.x*d,y:t-a.y*d}}function Ge(e){let n=getComputedStyle(e),t=(a,i)=>n.getPropertyValue(a).trim()||i,l=t("--cb-ink","CanvasText"),d=t("--cb-accent",l);return{type:{user:t("--cx-memory-type-user",d),feedback:t("--cx-memory-type-feedback",t("--cb-warn",l)),project:t("--cx-memory-type-project",t("--cb-ok",l)),reference:t("--cx-memory-type-reference",l)},agent:t("--cx-memory-agent",d),ink:l,muted:t("--cb-muted","GrayText"),faint:t("--cb-faint","GrayText"),bg:t("--cb-bg","Canvas"),font:t("--cb-font","monospace")}}function Le(e,n){let t=Math.hypot(e.x,e.y),l=Math.atan2(n.y,n.x);return t<1?{x:(e.x+n.x)/2,y:(e.y+n.y)/2}:{x:Math.cos(l)*t,y:Math.sin(l)*t}}function ln(e,n,t,l){let d=1-l;return{x:d*d*e.x+2*d*l*n.x+l*l*t.x,y:d*d*e.y+2*d*l*n.y+l*l*t.y}}var xe=(e,n)=>n.kind==="agent"?e.agent:n.type===null?e.muted:e.type[n.type];function Be(e,n,t,l,d){let{nodes:a}=n,i=t.k;e.setTransform(d.dpr,0,0,d.dpr,0,0),e.clearRect(0,0,d.width,d.height),e.translate(t.x,t.y),e.scale(i,i);let M=new Set;if(d.hover>=0){M.add(d.hover);for(let r of n.adjacency[d.hover]??[])M.add(r)}let I=r=>d.highlight===null||d.highlight.has(r.id),x=r=>{let o=a[r];return M.size>0?M.has(r)?1:.15:d.highlight!==null?o.kind!=="memory"||I(o)?1:.15:1},P=r=>{if(!d.motion||r.kind!=="memory")return{x:r.x,y:r.y};let o=r.phase*Math.PI*2;return{x:r.x+Math.sin(d.time/1700+o)*1.4,y:r.y+Math.cos(d.time/2100+o)*1.4}},b=a.map(P),h=1/i;e.setLineDash([3*h,4*h]),e.lineWidth=h,e.strokeStyle=l.muted;for(let r of n.edges){if(r.kind!=="semantic")continue;let o=b[r.a],s=b[r.b];e.globalAlpha=.28*Math.min(x(r.a),x(r.b)),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.stroke()}e.setLineDash([]);for(let r of n.edges){if(r.kind!=="tree")continue;let o=a[r.a],s=a[r.b],g=b[r.a],p=b[r.b],w=Le(o,s);e.globalAlpha=(s.kind==="dir"?.45:.22+.25*s.brightness)*Math.min(x(r.a),x(r.b)),e.strokeStyle=xe(l,s),e.lineWidth=(s.kind==="dir"?1.4:1)*h,e.beginPath(),e.moveTo(g.x,g.y),e.quadraticCurveTo(w.x,w.y,p.x,p.y),e.stroke()}e.strokeStyle=l.ink,e.lineWidth=1.2*h;for(let r of n.edges){if(r.kind!=="link")continue;let o=b[r.a],s=b[r.b];e.globalAlpha=.5*Math.min(x(r.a),x(r.b)),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.stroke()}if(d.motion)for(let r of n.edges){let o=a[r.b];if(r.kind==="semantic"||r.kind==="tree"&&!o.recent)continue;let s=(d.time/(r.kind==="link"?3200:2600)+r.phase)%1,g=b[r.a],p=b[r.b],w=r.kind==="tree"?ln(g,Le(a[r.a],o),p,s):{x:g.x+(p.x-g.x)*s,y:g.y+(p.y-g.y)*s};e.globalAlpha=Math.sin(Math.PI*s)*.9*Math.min(x(r.a),x(r.b)),e.fillStyle=r.kind==="link"?l.ink:xe(l,o),e.beginPath(),e.arc(w.x,w.y,1.8*h,0,Math.PI*2),e.fill()}if(a.forEach((r,o)=>{let s=b[o],g=x(o),p=xe(l,r);if(r.kind==="dir"){e.globalAlpha=g,e.fillStyle=l.bg,e.strokeStyle=p,e.lineWidth=1.4*h,e.beginPath(),e.arc(s.x,s.y,r.r,0,Math.PI*2),e.fill(),e.stroke();return}if(r.kind==="agent"){let w=d.motion?Math.sin(d.time/900)*2:0;e.fillStyle=p,e.globalAlpha=.12*g,e.beginPath(),e.arc(s.x,s.y,r.r*2.4+w,0,Math.PI*2),e.fill(),e.globalAlpha=.35*g,e.strokeStyle=p,e.lineWidth=h,e.beginPath(),e.arc(s.x,s.y,r.r+6+w/2,0,Math.PI*2),e.stroke(),e.globalAlpha=g,e.beginPath(),e.arc(s.x,s.y,r.r,0,Math.PI*2),e.fill();return}if(r.brightness>.4&&(e.globalAlpha=.14*r.brightness*g,e.fillStyle=p,e.beginPath(),e.arc(s.x,s.y,r.r*2.2,0,Math.PI*2),e.fill()),d.motion&&r.recent){let w=(d.time/2400+r.phase)%1;e.globalAlpha=(1-w)*.5*g,e.strokeStyle=p,e.lineWidth=h,e.beginPath(),e.arc(s.x,s.y,r.r+2+w*10,0,Math.PI*2),e.stroke()}e.globalAlpha=(.3+.7*r.brightness)*g,e.fillStyle=p,e.beginPath(),e.arc(s.x,s.y,r.r,0,Math.PI*2),e.fill(),d.highlight?.has(r.id)===!0&&(e.globalAlpha=.9,e.strokeStyle=p,e.lineWidth=1.5*h,e.beginPath(),e.arc(s.x,s.y,r.r+4,0,Math.PI*2),e.stroke()),r.id===d.selectedId&&(e.globalAlpha=1,e.strokeStyle=l.ink,e.lineWidth=2*h,e.beginPath(),e.arc(s.x,s.y,r.r+3.5,0,Math.PI*2),e.stroke())}),d.focus>=0){let r=a[d.focus],o=b[d.focus];r!==void 0&&o!==void 0&&(e.globalAlpha=1,e.strokeStyle=l.agent,e.setLineDash([3*h,3*h]),e.lineWidth=1.5*h,e.beginPath(),e.arc(o.x,o.y,r.r+7,0,Math.PI*2),e.stroke(),e.setLineDash([]))}e.textBaseline="middle",a.forEach((r,o)=>{let s=b[o],g=x(o);if(!(r.kind!=="memory"||i>=1.35||M.has(o)||o===d.focus||r.id===d.selectedId||(d.highlight?.has(r.id)??!1)))return;let w=r.kind==="agent"?12:11;if(e.font=`${r.kind==="dir"?"":"500 "}${w*h}px ${l.font}`,e.globalAlpha=(r.kind==="memory"?.9:r.kind==="dir"?.75:1)*g,e.fillStyle=r.kind==="dir"?l.muted:l.ink,r.kind==="agent")e.textAlign="center",e.fillText(r.label,s.x,s.y+r.r+18*h);else{e.textAlign="left";let R=r.kind==="dir"?`${r.label}/`:r.label;e.fillText(R,s.x+r.r+5*h,s.y)}}),e.globalAlpha=1}var Ye={zh:"已删除的记忆不会再出现在新的索引里,但之前对话中已出现的内容仍保留在那些对话的记录中。",en:"Deleted memories no longer appear in new indexes, but what earlier conversations already showed stays in those conversations' records."},we={user:{zh:"用户",en:"User"},feedback:{zh:"反馈",en:"Feedback"},project:{zh:"项目",en:"Project"},reference:{zh:"参考",en:"Reference"}},u={agent:{zh:"智能体",en:"Agent"},member:{zh:"成员",en:"Member"},search:{zh:"搜索记忆",en:"Search memories"},clearSearch:{zh:"清除搜索",en:"Clear search"},noHits:{zh:"没有找到相关的记忆。",en:"No matching memories."},graph:{zh:"图谱",en:"Graph"},list:{zh:"列表",en:"List"},view:{zh:"显示方式",en:"View"},fit:{zh:"适配视图",en:"Fit to view"},loading:{zh:"正在载入记忆…",en:"Loading memories…"},failed:{zh:"记忆载入失败。",en:"Could not load the memories."},retry:{zh:"重试",en:"Retry"},noAccess:{zh:"只有组织成员可以查看记忆。",en:"Only org members can see memories."},emptyTitle:{zh:"还没有记忆",en:"No memories yet"},emptyBody:{zh:"智能体在一对一对话中记下关于你的事情后,会出现在这里。",en:"When an agent remembers something about you in a one-to-one conversation, it shows up here."},emptyAgent:{zh:"这个智能体还没有关于你的记忆。",en:"This agent has no memories about you yet."},emptyOther:{zh:"这位成员和这个智能体之间还没有记忆。",en:"This member has no memories with this agent yet."},sizeLegend:{zh:"大小:被想起的次数",en:"Size: times recalled"},glowLegend:{zh:"亮度:最近一次被想起",en:"Brightness: last recalled"},linkLegend:{zh:"实线:记忆里写下的链接",en:"Solid: links written in memories"},semanticLegend:{zh:"虚线:语义相近",en:"Dashed: semantically close"},hint:{zh:"拖动节点 · 拖动空白处平移 · 滚轮缩放 · 方向键逐条浏览",en:"Drag nodes · drag the background to pan · scroll to zoom · arrow keys to step through"},path:{zh:"路径",en:"Path"},description:{zh:"描述",en:"Description"},body:{zh:"正文",en:"Body"},recalled:{zh:"被想起",en:"Recalled"},lastRecalled:{zh:"最近想起",en:"Last recalled"},never:{zh:"从未",en:"Never"},created:{zh:"创建于",en:"Created"},updated:{zh:"更新于",en:"Updated"},createdIn:{zh:"来自对话",en:"Written in"},openConversation:{zh:"打开对话",en:"Open the conversation"},links:{zh:"链接",en:"Links"},dangling:{zh:"尚未写下",en:"not written yet"},edit:{zh:"编辑",en:"Edit"},save:{zh:"保存",en:"Save"},cancel:{zh:"取消",en:"Cancel"},delete:{zh:"删除",en:"Delete"},close:{zh:"关闭",en:"Close"},confirmTitle:{zh:"删除这条记忆?",en:"Delete this memory?"},actionFailed:{zh:"操作没有完成:",en:"The action did not complete: "},readOnly:{zh:"管理员不能编辑其他成员的记忆。",en:"Admins cannot edit another member's memories."}},Se=e=>({zh:`${e} 条记忆`,en:e===1?"1 memory":`${e} memories`}),Fe=(e,n)=>({zh:`正在载入 ${e} / ${n}`,en:`Loading ${e} of ${n}`}),Ie=e=>({zh:`${e} 次`,en:e===1?"once":`${e} times`}),He=e=>({zh:`你正在查看 ${e} 的记忆。每次查看和删除都会记入审计日志;管理员不能编辑其他成员的记忆。`,en:`You are viewing ${e}'s memories. Every view and delete is recorded in the audit log; admins cannot edit another member's memories.`}),je=e=>({zh:`记忆图谱,共 ${e} 条记忆。用方向键逐条浏览,回车打开,Esc 关闭。`,en:`Memory graph with ${e} memories. Use the arrow keys to step through them, Enter to open one and Escape to close it.`}),Ve=(e,n)=>({zh:`${e} / ${n} 字节`,en:`${e} / ${n} bytes`});function ue(e,n,t=Date.now()){if(e===null)return u.never[n];let l=Date.parse(e);if(Number.isNaN(l))return u.never[n];let d=new Intl.RelativeTimeFormat(n==="zh"?"zh-CN":"en",{numeric:"auto"}),a=Math.round((l-t)/1e3),i=Math.abs(a);return i<60?d.format(a,"second"):i<3600?d.format(Math.round(a/60),"minute"):i<86400?d.format(Math.round(a/3600),"hour"):i<86400*30?d.format(Math.round(a/86400),"day"):i<86400*365?d.format(Math.round(a/(86400*30)),"month"):d.format(Math.round(a/(86400*365)),"year")}function Pe(e,n){let t=Date.parse(e);return Number.isNaN(t)?e:new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en",{dateStyle:"medium",timeStyle:"short"}).format(t)}import{Fragment as zn,jsx as c,jsxs as k}from"react/jsx-runtime";var Ae=8192,We=200,bn=300,vn=200,xn=300,re=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function he(e){return re(e)&&Array.isArray(e.nodes)&&Array.isArray(e.edges)&&Array.isArray(e.agents)&&typeof e.canAdmin=="boolean"&&re(e.selection)?e:null}function kn(e){return re(e)&&Array.isArray(e.nodes)&&Array.isArray(e.edges)&&!("selection"in e)?e:null}var Xe=e=>re(e)&&re(e.detail)?e.detail:null,Nn=e=>re(e)&&Array.isArray(e.hits)?e.hits:null,qe=e=>`${e.kind}:${e.from}>${e.to}`;function Mn(e,n){let t=new Map(e.map(l=>[l.id,l]));for(let l of n)t.set(l.id,l);return[...t.values()]}function wn(e,n){let t=new Map(e.map(l=>[qe(l),l]));for(let l of n)t.set(qe(l),l);return[...t.values()]}var Ue=(e,n)=>e.selection.agentId===n.selection.agentId&&e.selection.accountId===n.selection.accountId;function se(e){let n={accountId:e.selection.accountId};return e.selection.agentId!==null&&(n.agentId=e.selection.agentId),n}var Sn=e=>e instanceof Error?e.message:String(e);function Ze(){let{view:e,status:n,retry:t}=pn(),l=hn(),d=un(),{locale:a,t:i}=oe(),M=gn(),I=yn(),[x,P]=F(null),b=G(0),h=G(null);h.current=x;let[r,o]=F(!1),[s,g]=F(null),[p,w]=F(null),[R,X]=F(null),[H,B]=F(""),[j,_]=F(null),[Q,ie]=F(()=>{let m=I.get("view");return m==="graph"||m==="list"?m:null}),[pe,le]=F(0),K=U((m,z)=>{P(A=>A!==null&&A.source===m||!z&&A!==null&&!Ue(A.source,m)?A:(b.current+=1,{source:m,nodes:m.nodes,edges:m.edges,cursor:m.cursor,pages:1,gen:b.current}))},[]),ce=G(i);ce.current=i;let Y=U(m=>g(ce.current(u.actionFailed)+Sn(m)),[]),f=G(!1),v=G(void 0);Z(()=>{if(v.current===e&&e!==null)return;v.current=e;let m=he(e?.data);if(m!==null){K(m,!1);return}n==="ready"&&h.current===null&&!f.current&&(f.current=!0,l("select",{payload:{}}).then(z=>{let A=he(z.view?.data);A!==null&&K(A,!0)}).catch(Y))},[e,n,K,l,Y]);let N=x?.gen,S=x?.cursor??null;Z(()=>{let m=h.current;if(m===null||S===null||m.gen!==N)return;let z=!0,A=()=>P(D=>D!==null&&D.gen===m.gen?{...D,cursor:null}:D);return l("more",{payload:{...se(m.source),cursor:S}}).then(D=>{if(!z)return;let $=kn(D.view?.data);if($===null)return A();P(O=>{if(O===null||O.gen!==m.gen)return O;let ne=$.cursor===O.cursor||O.pages+1>=vn?null:$.cursor;return{...O,nodes:Mn(O.nodes,$.nodes),edges:wn(O.edges,$.edges),cursor:ne,pages:O.pages+1}})}).catch(D=>{z&&(Y(D),A())}),()=>{z=!1}},[N,S,l,Y]);let y=x?.source??null,T=y?.editable??!1,E=G(null),C=U(()=>{E.current=null,X(null),w(null)},[]),L=G(0),V=U(async m=>{L.current+=1,o(!0),g(null);try{let z=await l("select",{payload:m}),A=he(z.view?.data);A!==null&&(K(A,!0),C(),_(null),B(""),le(D=>D+1))}catch(z){Y(z)}finally{o(!1)}},[l,K,C,Y]),J=U(async m=>{let z=h.current;if(z!==null){E.current=m,X(m),g(null);try{let A=await l("open",{payload:{...se(z.source),memoryId:m}});if(E.current!==m)return;let D=Xe(A.view?.data);if(D===null){E.current=null,X(null);return}w(D)}catch(A){Y(A)}}},[l,Y]),Qe=U(async(m,z,A)=>{let D=h.current;if(D===null)return!1;try{let $=await l("edit",{payload:{...se(D.source),memoryId:m,description:z,body:A}}),O=Xe($.view?.data);return O===null?!1:(w(O),P(ne=>ne===null?ne:{...ne,nodes:ne.nodes.map(be=>be.id===O.id?{...be,description:O.description}:be)}),!0)}catch($){return Y($),!1}},[l,Y]),Je=U(async m=>{let z=h.current;if(z!==null)try{let A=await l("delete",{payload:{...se(z.source),memoryId:m}}),D=he(A.view?.data);if(D===null)return;K(D,!0),C(),_($=>$===null?$:$.filter(O=>O.id!==m))}catch(A){Y(A)}},[l,K,C,Y]),fe=U(async m=>{let z=h.current;if(z===null||z.source.selection.agentId===null)return;let A=++L.current;if(m.trim()===""){_(null);return}let D=()=>A!==L.current||h.current===null||!Ue(h.current.source,z.source);try{let $=await l("search",{payload:{...se(z.source),query:m}});if(D())return;let O=Nn($.view?.data);O!==null&&_(O)}catch($){D()||Y($)}},[l,Y]);if(Z(()=>{if(H.trim()===""){L.current+=1,_(null);return}let m=setTimeout(()=>{fe(H)},xn);return()=>clearTimeout(m)},[H,fe]),!d.atLeast("member"))return c(ye,{icon:"lock",title:i(u.noAccess)});if(x===null||y===null)return n==="failed"?c(ye,{icon:"circle-alert",title:i(u.failed),children:c(q,{onClick:t,children:i(u.retry)})}):k("div",{className:"cx-memory-state",children:[c(Ke,{label:i(u.loading)}),c(W,{tone:"muted",children:i(u.loading)})]});if(y.selection.agentId===null&&y.agents.length===0&&!y.canAdmin)return c(ye,{icon:"empty",title:i(u.emptyTitle),body:i(u.emptyBody)});let ee=x.nodes,de=Q??(y.total>bn?"list":"graph"),Te=m=>{ie(m),I.set("view",m)},en=y.agents.find(m=>m.id===y.selection.agentId)?.name??"",nn=y.members?.find(m=>m.id===y.selection.accountId)?.name??y.selection.accountId,Ee=j===null?null:new Set(j.map(m=>m.id)),ze=ee.length===0;return k("div",{className:"cx-memory-page","data-panel":R!==null?"open":"closed",children:[k("form",{className:"cx-memory-toolbar",onSubmit:m=>{m.preventDefault(),fe(H)},children:[k("label",{className:"cx-memory-field",children:[c("span",{className:"cx-memory-field-label",children:i(u.agent)}),k("select",{className:"cx-memory-select",value:y.selection.agentId??"",disabled:r||y.agents.length===0,onChange:m=>{V({agentId:m.target.value,accountId:y.selection.accountId})},children:[y.selection.agentId===null?c("option",{value:"",children:"—"}):null,y.agents.map(m=>c("option",{value:m.id,children:m.name},m.id))]})]}),y.canAdmin&&y.members!==void 0?k("label",{className:"cx-memory-field",children:[c("span",{className:"cx-memory-field-label",children:i(u.member)}),c("select",{className:"cx-memory-select","data-testid":"memory-member-select",value:y.selection.accountId,disabled:r,onChange:m=>{V({accountId:m.target.value})},children:y.members.map(m=>c("option",{value:m.id,children:m.name},m.id))})]}):null,k("div",{className:"cx-memory-search",children:[c(te,{name:"search",size:14}),c("input",{className:"cx-memory-input",type:"search",value:H,placeholder:i(u.search),"aria-label":i(u.search),maxLength:500,disabled:y.selection.agentId===null,onChange:m=>B(m.target.value),onKeyDown:m=>{m.key==="Escape"&&B("")}})]}),k("div",{className:"cx-memory-toolbar-end",children:[c(W,{variant:"small",tone:"muted",children:x.cursor!==null?i(Fe(ee.length,y.total)):i(Se(Math.max(y.total,ee.length)))}),k("fieldset",{className:"cx-memory-toggle",children:[c("legend",{className:"cx-memory-sr",children:i(u.view)}),c("button",{type:"button",className:"cx-memory-toggle-item","aria-pressed":de==="graph",onClick:()=>Te("graph"),children:i(u.graph)}),c("button",{type:"button",className:"cx-memory-toggle-item","aria-pressed":de==="list",onClick:()=>Te("list"),children:i(u.list)})]}),de==="graph"&&!ze?c(q,{variant:"ghost",title:i(u.fit),"aria-label":i(u.fit),onClick:()=>le(m=>m+1),children:c(te,{name:"maximize-2",size:14})}):null]})]}),T?null:k("div",{className:"cx-memory-banner",role:"note",children:[c(te,{name:"admin",size:14}),c(W,{variant:"small",children:i(He(nn))})]}),s!==null?c("div",{className:"cx-memory-banner","data-tone":"fail",role:"alert",children:c(W,{variant:"small",tone:"fail",children:s})}):null,k("div",{className:"cx-memory-body",children:[k("div",{className:"cx-memory-main",children:[j!==null?c(An,{hits:j,onOpen:J,onClear:()=>B("")}):null,ze?c(ye,{icon:"empty",title:i(u.emptyTitle),body:i(y.selection.agentId===null?u.emptyBody:T?u.emptyAgent:u.emptyOther)}):de==="graph"?c(Pn,{nodes:ee,edges:x.edges,agentLabel:en,motion:!M,selectedId:R,highlight:Ee,fitSignal:pe,onOpen:m=>{J(m)},onEscape:C,label:i(je(ee.length))}):c(Cn,{nodes:ee,highlight:Ee,selectedId:R,onOpen:m=>{J(m)}})]}),R!==null?c(En,{detail:p?.id===R?p:null,editable:T,canDelete:T||y.canAdmin,locale:a,onClose:C,onOpen:m=>{J(m)},onSave:Qe,onDelete:Je},R):null]})]})}function ye(e){return k("div",{className:"cx-memory-state",children:[c("span",{className:"cx-memory-state-icon","aria-hidden":"true",children:c(te,{name:e.icon,size:16})}),c(W,{variant:"h3",children:e.title}),e.body!==void 0?c(W,{tone:"muted",children:e.body}):null,e.children]})}function ge({type:e}){return c("span",{className:"cx-memory-dot","data-type":e,"aria-hidden":"true"})}function In(){let{t:e}=oe();return k("div",{className:"cx-memory-legend","aria-hidden":"true",children:[c("div",{className:"cx-memory-legend-row",children:me.map(n=>k("span",{className:"cx-memory-legend-item",children:[c(ge,{type:n}),e(we[n])]},n))}),k("div",{className:"cx-memory-legend-row",children:[k("span",{className:"cx-memory-legend-item",children:[c("span",{className:"cx-memory-legend-line","data-kind":"link"}),e(u.linkLegend)]}),k("span",{className:"cx-memory-legend-item",children:[c("span",{className:"cx-memory-legend-line","data-kind":"semantic"}),e(u.semanticLegend)]})]}),k("div",{className:"cx-memory-legend-row",children:[c("span",{className:"cx-memory-legend-item",children:e(u.sizeLegend)}),c("span",{className:"cx-memory-legend-item",children:e(u.glowLegend)})]})]})}function Pn(e){let{locale:n,t}=oe(),l=G(null),d=G(null),a=G(null),i=G({x:0,y:0,k:1}),M=G({w:0,h:0,dpr:1}),I=G(-1),x=G(-1),P=G(!1),b=G(null),h=G(e);h.current=e;let[r,o]=F(null),[s,g]=F(null),p=U((f=0)=>{let v=d.current,N=a.current;if(v===null||N===null)return;let S=v.getContext("2d");if(S===null)return;let{w:y,h:T,dpr:E}=M.current,C=h.current;Be(S,N,i.current,Ge(v),{width:y,height:T,dpr:E,time:f,motion:C.motion,hover:I.current>=0?I.current:x.current,focus:x.current,selectedId:C.selectedId,highlight:C.highlight})},[]),w=U(()=>{let f=a.current,{w:v,h:N}=M.current;f===null||v===0||N===0||(i.current=Me(f,v,N))},[]),{nodes:R,edges:X,agentLabel:H,motion:B}=e;Z(()=>{let f=a.current,v=Re({nodes:R,edges:X,agentLabel:H},{now:Date.now(),previous:f});B||Oe(v),a.current=v,I.current=-1,x.current=-1,(f===null||!P.current)&&w(),B||p()},[R,X,H,B,w,p]);let{fitSignal:j}=e;Z(()=>{j!==0&&(P.current=!1,w(),p())},[j,w,p]);let{selectedId:_,highlight:Q}=e;Z(()=>{B||p()},[_,Q,B,p]),Z(()=>{let f=l.current,v=d.current;if(f===null||v===null)return;let N=()=>{let y=Math.max(1,Math.min(3,globalThis.devicePixelRatio||1)),T=f.clientWidth,E=f.clientHeight;M.current={w:T,h:E,dpr:y},v.width=Math.round(T*y),v.height=Math.round(E*y),P.current||w(),p()};if(N(),typeof ResizeObserver>"u")return;let S=new ResizeObserver(N);return S.observe(f),()=>S.disconnect()},[w,p]),Z(()=>{if(!B)return;let f=0,v=N=>{let S=a.current;if(S!==null&&S.alpha>=.005){ke(S);let{w:y,h:T}=M.current;if(!P.current&&y>0&&T>0){let E=Me(S,y,T),C=i.current;i.current={x:C.x+(E.x-C.x)*.12,y:C.y+(E.y-C.y)*.12,k:C.k+(E.k-C.k)*.12}}}p(N),f=requestAnimationFrame(v)};return f=requestAnimationFrame(v),()=>cancelAnimationFrame(f)},[B,p]),Z(()=>{let f=d.current;if(f===null)return;let v=N=>{N.preventDefault();let S=f.getBoundingClientRect();P.current=!0,i.current=$e(i.current,N.clientX-S.left,N.clientY-S.top,Math.exp(-N.deltaY*.0015)),h.current.motion||p()};return f.addEventListener("wheel",v,{passive:!1}),()=>f.removeEventListener("wheel",v)},[p]);let ie=f=>{let v=f.currentTarget.getBoundingClientRect();return{sx:f.clientX-v.left,sy:f.clientY-v.top}},pe=f=>{let v=a.current;if(v===null)return;let{sx:N,sy:S}=ie(f),y=ae(i.current,N,S),T=Ne(v,y.x,y.y,4/i.current.k);b.current={node:T,sx:N,sy:S,lastX:N,lastY:S,moved:!1},f.currentTarget.setPointerCapture?.(f.pointerId)},le=f=>{let v=a.current;if(v===null)return;let{sx:N,sy:S}=ie(f),y=b.current,T=h.current.motion;if(y!==null){if(!y.moved&&Math.hypot(N-y.sx,S-y.sy)<4)return;y.moved=!0,o(null);let L=y.node>=0?v.nodes[y.node]:void 0;if(L!==void 0&&L.kind!=="agent"){let V=ae(i.current,N,S);L.x=V.x,L.y=V.y,L.pinned=!0,T&&(v.alpha=Math.max(v.alpha,.25))}else{P.current=!0;let V=i.current;i.current={...V,x:V.x+N-y.lastX,y:V.y+S-y.lastY}}y.lastX=N,y.lastY=S,T||p();return}let E=ae(i.current,N,S),C=Ne(v,E.x,E.y,4/i.current.k);if(C!==I.current){I.current=C;let L=C>=0?v.nodes[C]?.memory??null:null;o(L===null?null:{x:N,y:S,node:L}),T||p()}},K=f=>{let v=b.current;b.current=null;let N=a.current;if(v===null||N===null)return;let S=v.node>=0?N.nodes[v.node]:void 0;if(v.moved){S!==void 0&&S.kind!=="agent"&&h.current.motion&&(S.pinned=!1);return}S?.memory&&h.current.onOpen(S.memory.id)},ce=()=>{b.current===null&&(I.current=-1,o(null),h.current.motion||p())},Y=f=>{let v=a.current;if(v===null)return;let N=v.nodes.flatMap((E,C)=>E.kind==="memory"?[C]:[]);if(N.length===0)return;let S=N.indexOf(x.current),y=-1;if(f.key==="ArrowRight"||f.key==="ArrowDown")y=N[(S+1)%N.length]??-1;else if(f.key==="ArrowLeft"||f.key==="ArrowUp")y=N[(S-1+N.length)%N.length]??-1;else if(f.key==="Home")y=N[0]??-1;else if(f.key==="End")y=N[N.length-1]??-1;else if(f.key==="Enter"||f.key===" "){let E=v.nodes[x.current]?.memory;E&&(f.preventDefault(),h.current.onOpen(E.id));return}else if(f.key==="Escape"){h.current.onEscape();return}else return;f.preventDefault(),x.current=y;let T=v.nodes[y];if(g(T?.memory??null),T!==void 0){let{w:E,h:C}=M.current,L=i.current,V=T.x*L.k+L.x,J=T.y*L.k+L.y;E>0&&(V<40||J<40||V>E-40||J>C-40)&&(P.current=!0,i.current={...L,x:E/2-T.x*L.k,y:C/2-T.y*L.k})}h.current.motion||p()};return k("div",{className:"cx-memory-stage",ref:l,children:[c("canvas",{ref:d,className:"cx-memory-canvas",tabIndex:0,"aria-label":e.label,onPointerDown:pe,onPointerMove:le,onPointerUp:K,onPointerCancel:()=>{b.current=null},onPointerLeave:ce,onKeyDown:Y,onBlur:()=>{x.current=-1,g(null),h.current.motion||p()}}),c("div",{className:"cx-memory-sr cx-memory-live","aria-live":"polite",children:s!==null?`${s.path} — ${s.description}`:""}),r!==null?k("div",{className:"cx-memory-tip",style:{left:r.x+14,top:r.y+14},"aria-hidden":"true",children:[k("span",{className:"cx-memory-tip-path",children:[c(ge,{type:r.node.type}),r.node.path]}),c("span",{className:"cx-memory-tip-desc",children:r.node.description}),k("span",{className:"cx-memory-tip-meta",children:[t(u.recalled)," ",t(Ie(r.node.recalls))," · ",t(u.lastRecalled)," ",ue(r.node.lastRecalledAt,n)]})]}):null,c(In,{}),c("div",{className:"cx-memory-hint","aria-hidden":"true",children:t(u.hint)})]})}function Cn(e){let{locale:n,t}=oe(),l=fn(()=>[...e.nodes].sort((a,i)=>a.path<i.path?-1:a.path>i.path?1:0),[e.nodes]),d=e.highlight===null?l:l.filter(a=>e.highlight?.has(a.id));return k("div",{className:"cx-memory-list",children:[k("div",{className:"cx-memory-list-head","aria-hidden":"true",children:[c("span",{children:t(u.path)}),c("span",{children:t(u.description)}),c("span",{children:t(u.recalled)}),c("span",{children:t(u.lastRecalled)})]}),c("ul",{className:"cx-memory-rows",children:d.map(a=>c("li",{children:k("button",{type:"button",className:"cx-memory-row","data-memory-id":a.id,"aria-current":a.id===e.selectedId?"true":void 0,onClick:()=>e.onOpen(a.id),children:[k("span",{className:"cx-memory-row-path",children:[c(ge,{type:a.type}),a.path]}),c("span",{className:"cx-memory-row-desc",children:a.description}),c("span",{className:"cx-memory-row-num",children:a.recalls}),c("span",{className:"cx-memory-row-num",children:ue(a.lastRecalledAt,n)})]})},a.id))})]})}function An(e){let{t:n}=oe();return k("section",{className:"cx-memory-hits","aria-label":n(u.search),children:[k("div",{className:"cx-memory-hits-head",children:[c(W,{variant:"small",tone:"muted",children:e.hits.length===0?n(u.noHits):n(Se(e.hits.length))}),c(q,{variant:"ghost",onClick:e.onClear,children:n(u.clearSearch)})]}),e.hits.map(t=>k("button",{type:"button",className:"cx-memory-hit",onClick:()=>e.onOpen(t.id),children:[c("span",{className:"cx-memory-hit-path",children:t.path}),c("span",{className:"cx-memory-hit-desc",children:t.description}),t.snippet!==""?c("span",{className:"cx-memory-hit-snippet",children:t.snippet}):null]},t.id))]})}var Tn=e=>new TextEncoder().encode(e).length;function En(e){let{t:n}=oe(),{detail:t,locale:l}=e,[d,a]=F("view"),[i,M]=F(""),[I,x]=F(""),[P,b]=F(!1);if(t===null)return c("aside",{className:"cx-memory-panel","aria-busy":"true",children:k("div",{className:"cx-memory-panel-head",children:[c(Ke,{size:12}),c("span",{className:"cx-memory-grow"}),c(q,{variant:"ghost","aria-label":n(u.close),onClick:e.onClose,children:c(te,{name:"x",size:14})})]})});let h=s=>s[l],r=Tn(I),o=i.trim()===""||i.length>We||/[\r\n]/.test(i)||r>Ae;return k("aside",{className:"cx-memory-panel","aria-label":t.path,children:[k("div",{className:"cx-memory-panel-head",children:[c(ge,{type:t.type}),c("span",{className:"cx-memory-panel-path",children:t.path}),c(dn,{children:h(we[t.type])}),c("span",{className:"cx-memory-grow"}),c(q,{variant:"ghost","aria-label":n(u.close),onClick:e.onClose,children:c(te,{name:"x",size:14})})]}),c("div",{className:"cx-memory-panel-body",children:d==="edit"?k("form",{className:"cx-memory-edit",onSubmit:s=>{s.preventDefault(),!o&&(b(!0),e.onSave(t.id,i,I).then(g=>{b(!1),g&&a("view")}))},children:[k("label",{className:"cx-memory-field","data-block":"true",children:[c("span",{className:"cx-memory-field-label",children:n(u.description)}),c("input",{className:"cx-memory-input",value:i,maxLength:We,onChange:s=>M(s.target.value)})]}),k("label",{className:"cx-memory-field","data-block":"true",children:[c("span",{className:"cx-memory-field-label",children:n(u.body)}),c("textarea",{className:"cx-memory-textarea",value:I,rows:12,onChange:s=>x(s.target.value)}),c("span",{className:"cx-memory-field-note","data-over":r>Ae,children:n(Ve(r,Ae))})]}),k(Ce,{direction:"row",gap:8,justify:"end",children:[c(q,{onClick:()=>a("view"),children:n(u.cancel)}),c(q,{type:"submit",variant:"primary",loading:P,disabled:o,children:n(u.save)})]})]}):k(zn,{children:[c(W,{children:t.description}),c("div",{className:"cx-memory-markdown",children:t.body}),t.links.length>0?k("div",{className:"cx-memory-links",children:[c(W,{variant:"small",tone:"muted",children:n(u.links)}),t.links.map(s=>s.targetId!==null?k("button",{type:"button",className:"cx-memory-link",onClick:()=>e.onOpen(s.targetId),children:["[[",s.path,"]]"]},s.path):k("span",{className:"cx-memory-link","data-dangling":"true",children:["[[",s.path,"]] · ",n(u.dangling)]},s.path))]}):null,c(mn,{keyWidth:"12ch",rows:[{k:n(u.recalled),v:n(Ie(t.recalls))},{k:n(u.lastRecalled),v:ue(t.lastRecalledAt,l)},{k:n(u.created),v:Pe(t.createdAt,l)},{k:n(u.updated),v:Pe(t.updatedAt,l)},...t.createdIn!==null?[{k:n(u.createdIn),v:e.editable?c("a",{className:"cx-memory-anchor",href:`/chat/${encodeURIComponent(t.createdIn)}`,children:n(u.openConversation)}):t.createdIn}]:[]]}),d==="confirm"?k("div",{className:"cx-memory-confirm",role:"alertdialog","aria-label":n(u.confirmTitle),children:[c(W,{variant:"h3",children:n(u.confirmTitle)}),c(W,{variant:"small",children:n(Ye)}),k(Ce,{direction:"row",gap:8,justify:"end",children:[c(q,{onClick:()=>a("view"),children:n(u.cancel)}),c(q,{variant:"danger-solid",loading:P,onClick:()=>{b(!0),e.onDelete(t.id).finally(()=>b(!1))},children:n(u.delete)})]})]}):k(Ce,{direction:"row",gap:8,justify:"end",children:[e.editable?c(q,{onClick:()=>{M(t.description),x(t.body),a("edit")},children:n(u.edit)}):null,e.canDelete?c(q,{variant:"danger",onClick:()=>a("confirm"),children:n(u.delete)}):null]}),e.editable?null:c(W,{variant:"small",tone:"muted",children:n(u.readOnly)})]})})]})}var Vn=Dn({name:"memory",components:{"memory-page":Ln("org.page",Ze)}});export{Vn as default};
|
|
1
|
+
import{defineClientExtension as $n,defineComponent as Gn}from"@capybara-hq/plugin-client";import{Badge as gn,Button as V,Icon as Q,KeyValue as pn,Select as Ke,Spinner as nn,Stack as Te,Text as W,useAccess as fn,useAction as bn,useClientStorage as vn,useLocale as ae,usePrefersReducedMotion as xn,useView as kn}from"@capybara-hq/plugin-client";import{useCallback as q,useEffect as U,useMemo as Nn,useRef as $,useState as F}from"react";var ye=["user","feedback","project","reference"],ln="agent",_e=e=>`dir:${e}`;function cn(e){return Math.min(18,4+1.2*Math.sqrt(Math.max(0,e)))}function dn(e,n){if(e===null)return .25;let t=Date.parse(e);if(Number.isNaN(t))return .25;let l=Math.max(0,(n-t)/864e5);return Math.max(.25,Math.exp(-l/30))}function Me(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0)/4294967296}var un=e=>e<=0?0:120+(e-1)*80;function Ge(e,n){let t=[],l=new Map,d=[],a=o=>{let i=t.length;return t.push({...o,x:0,y:0,vx:0,vy:0,ring:0}),l.set(o.id,i),d.push([]),o.parent>=0&&d[o.parent]?.push(i),i};a({id:ln,kind:"agent",label:e.agentLabel,path:"",type:null,parent:-1,depth:0,pinned:!0,r:13,brightness:1,recent:!1,phase:0,memory:null});let s=o=>{let i=l.get(_e(o));if(i!==void 0)return i;let y=o.lastIndexOf("/"),g=y===-1?0:s(o.slice(0,y)),S=o.split("/")[0];return a({id:_e(o),kind:"dir",label:o.slice(y+1),path:o,type:ye.includes(S)?S:null,parent:g,depth:o.split("/").length,pinned:!1,r:4.5,brightness:1,recent:!1,phase:Me(o),memory:null})};for(let o of ye)s(o);let M=[...e.nodes].sort((o,i)=>o.path<i.path?-1:o.path>i.path?1:0);for(let o of M){if(l.has(o.id))continue;let i=o.dir===""?0:s(o.dir),y=o.path.slice(o.path.lastIndexOf("/")+1).replace(/\.md$/,""),g=dn(o.lastRecalledAt,n.now),S=o.lastRecalledAt===null?Number.NaN:Date.parse(o.lastRecalledAt);a({id:o.id,kind:"memory",label:y,path:o.path,type:o.type,parent:i,depth:(t[i]?.depth??0)+1,pinned:!1,r:cn(o.recalls),brightness:g,recent:!Number.isNaN(S)&&n.now-S<7*864e5,phase:Me(o.id),memory:o})}let I=[];for(let o=1;o<t.length;o++){let i=t[o];I.push({a:i.parent,b:o,kind:"tree",phase:i.phase})}let x=new Set;for(let o of e.edges){let i=l.get(o.from),y=l.get(o.to);if(i===void 0||y===void 0||i===y)continue;let g=o.kind==="semantic"?`s${Math.min(i,y)}~${Math.max(i,y)}`:`l${i}>${y}`;x.has(g)||(x.add(g),I.push({a:i,b:y,kind:o.kind,phase:Me(g)}))}let C=t.map(()=>new Set);for(let o of I)C[o.a]?.add(o.b),C[o.b]?.add(o.a);let v=new Array(t.length).fill(0);for(let o=t.length-1;o>=0;o--){let i=t[o]?.kind==="memory"?1:0,y=(d[o]??[]).reduce((g,S)=>g+(v[S]??0),0);v[o]=Math.max(1,i+y)}let h=(o,i,y)=>{let g=t[o],S=d[o]??[],R=i,X=S.reduce((Y,B)=>Y+(v[B]??1),0);S.forEach((Y,B)=>{let j=(y-i)*(v[Y]??1)/Math.max(1,X),_=t[Y],K=R+j/2+(_.phase-.5)*j*.3;_.ring=_.kind==="dir"?un(_.depth):(g.kind==="agent"?70:g.ring)+46+B%3*20+_.r,_.x=Math.cos(K)*_.ring,_.y=Math.sin(K)*_.ring,h(Y,R,R+j),R+=j})};h(0,-Math.PI/2,3*Math.PI/2);let r=n.previous??null;if(r!==null)for(let o of t){let i=r.index.get(o.id),y=i===void 0?void 0:r.nodes[i];y!==void 0&&(o.x=y.x,o.y=y.y)}return{nodes:t,edges:I,index:l,adjacency:C,alpha:r===null?1:.4}}function Se(e){let{nodes:n}=e,t=e.alpha,l=110,d=new Map;n.forEach((a,s)=>{let M=`${Math.floor(a.x/l)},${Math.floor(a.y/l)}`,I=d.get(M);I===void 0?d.set(M,[s]):I.push(s)});for(let a=0;a<n.length;a++){let s=n[a],M=Math.floor(s.x/l),I=Math.floor(s.y/l);for(let x=-1;x<=1;x++)for(let C=-1;C<=1;C++)for(let v of d.get(`${M+x},${I+C}`)??[]){if(v<=a)continue;let h=n[v],r=h.x-s.x,o=h.y-s.y,i=r*r+o*o;if(i===0&&(r=(s.phase-h.phase)*.1+.01,o=.01,i=r*r+o*o),i>l*l)continue;let y=Math.sqrt(i),g=60*t/y,S=s.r+h.r+6;y<S&&(g+=(S-y)*.5);let R=r/y*g,X=o/y*g;s.vx-=R,s.vy-=X,h.vx+=R,h.vy+=X}}for(let a of e.edges){if(a.kind==="semantic")continue;let s=n[a.a],M=n[a.b],I=M.x-s.x,x=M.y-s.y,C=Math.sqrt(I*I+x*x)||1,v=a.kind==="tree"?Math.max(30,M.ring-s.ring):90,h=(C-v)/C*t*(a.kind==="tree"?.12:.015);s.vx+=I*h*.5,s.vy+=x*h*.5,M.vx-=I*h*.5,M.vy-=x*h*.5}for(let a of n){if(a.kind==="agent")continue;let s=Math.sqrt(a.x*a.x+a.y*a.y)||1,M=(a.ring-s)/s*.08*t;a.vx+=a.x*M,a.vy+=a.y*M}for(let a of n){if(a.pinned){a.vx=0,a.vy=0,a.kind==="agent"&&(a.x=0,a.y=0);continue}a.vx*=.6,a.vy*=.6,a.x+=a.vx,a.y+=a.vy}return e.alpha+=(0-e.alpha)*.03,e.alpha}function Be(e,n=240){for(let t=0;t<n&&e.alpha>=.005;t++)Se(e);e.alpha=0}function Ie(e,n,t,l=3){let d=-1,a=Number.POSITIVE_INFINITY;for(let s=e.nodes.length-1;s>=0;s--){let M=e.nodes[s],I=Math.hypot(M.x-n,M.y-t);I<=M.r+l&&I<a&&(d=s,a=I)}return d}var Fe=.15,mn=4,ie=(e,n,t)=>({x:(n-e.x)/e.k,y:(t-e.y)/e.k});function Pe(e,n,t,l=48){let d=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,M=Number.NEGATIVE_INFINITY;for(let v of e.nodes)d=Math.min(d,v.x-v.r),a=Math.min(a,v.y-v.r),s=Math.max(s,v.x+v.r),M=Math.max(M,v.y+v.r);let I=Math.max(1,s-d),x=Math.max(1,M-a),C=Math.min(1.6,Math.max(Fe,Math.min((n-2*l)/I,(t-2*l)/x)));return{k:C,x:n/2-(d+s)/2*C,y:t/2-(a+M)/2*C}}function Ye(e,n,t,l){let d=Math.min(mn,Math.max(Fe,e.k*l)),a=ie(e,n,t);return{k:d,x:n-a.x*d,y:t-a.y*d}}function He(e){let n=getComputedStyle(e),t=(a,s)=>n.getPropertyValue(a).trim()||s,l=t("--cb-ink","CanvasText"),d=t("--cb-accent",l);return{type:{user:t("--cx-memory-type-user",d),feedback:t("--cx-memory-type-feedback",t("--cb-warn",l)),project:t("--cx-memory-type-project",t("--cb-ok",l)),reference:t("--cx-memory-type-reference",l)},agent:t("--cx-memory-agent",d),ink:l,muted:t("--cb-muted","GrayText"),faint:t("--cb-faint","GrayText"),bg:t("--cb-bg","Canvas"),font:t("--cb-font","monospace")}}function $e(e,n){let t=Math.hypot(e.x,e.y),l=Math.atan2(n.y,n.x);return t<1?{x:(e.x+n.x)/2,y:(e.y+n.y)/2}:{x:Math.cos(l)*t,y:Math.sin(l)*t}}function hn(e,n,t,l){let d=1-l;return{x:d*d*e.x+2*d*l*n.x+l*l*t.x,y:d*d*e.y+2*d*l*n.y+l*l*t.y}}var we=(e,n)=>n.kind==="agent"?e.agent:n.type===null?e.muted:e.type[n.type];function je(e,n,t,l,d){let{nodes:a}=n,s=t.k;e.setTransform(d.dpr,0,0,d.dpr,0,0),e.clearRect(0,0,d.width,d.height),e.translate(t.x,t.y),e.scale(s,s);let M=new Set;if(d.hover>=0){M.add(d.hover);for(let r of n.adjacency[d.hover]??[])M.add(r)}let I=r=>d.highlight===null||d.highlight.has(r.id),x=r=>{let o=a[r];return M.size>0?M.has(r)?1:.15:d.highlight!==null?o.kind!=="memory"||I(o)?1:.15:1},C=r=>{if(!d.motion||r.kind!=="memory")return{x:r.x,y:r.y};let o=r.phase*Math.PI*2;return{x:r.x+Math.sin(d.time/1700+o)*1.4,y:r.y+Math.cos(d.time/2100+o)*1.4}},v=a.map(C),h=1/s;e.setLineDash([3*h,4*h]),e.lineWidth=h,e.strokeStyle=l.muted;for(let r of n.edges){if(r.kind!=="semantic")continue;let o=v[r.a],i=v[r.b];e.globalAlpha=.28*Math.min(x(r.a),x(r.b)),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(i.x,i.y),e.stroke()}e.setLineDash([]);for(let r of n.edges){if(r.kind!=="tree")continue;let o=a[r.a],i=a[r.b],y=v[r.a],g=v[r.b],S=$e(o,i);e.globalAlpha=(i.kind==="dir"?.45:.22+.25*i.brightness)*Math.min(x(r.a),x(r.b)),e.strokeStyle=we(l,i),e.lineWidth=(i.kind==="dir"?1.4:1)*h,e.beginPath(),e.moveTo(y.x,y.y),e.quadraticCurveTo(S.x,S.y,g.x,g.y),e.stroke()}e.strokeStyle=l.ink,e.lineWidth=1.2*h;for(let r of n.edges){if(r.kind!=="link")continue;let o=v[r.a],i=v[r.b];e.globalAlpha=.5*Math.min(x(r.a),x(r.b)),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(i.x,i.y),e.stroke()}if(d.motion)for(let r of n.edges){let o=a[r.b];if(r.kind==="semantic"||r.kind==="tree"&&!o.recent)continue;let i=(d.time/(r.kind==="link"?3200:2600)+r.phase)%1,y=v[r.a],g=v[r.b],S=r.kind==="tree"?hn(y,$e(a[r.a],o),g,i):{x:y.x+(g.x-y.x)*i,y:y.y+(g.y-y.y)*i};e.globalAlpha=Math.sin(Math.PI*i)*.9*Math.min(x(r.a),x(r.b)),e.fillStyle=r.kind==="link"?l.ink:we(l,o),e.beginPath(),e.arc(S.x,S.y,1.8*h,0,Math.PI*2),e.fill()}if(a.forEach((r,o)=>{let i=v[o],y=x(o),g=we(l,r);if(r.kind==="dir"){e.globalAlpha=y,e.fillStyle=l.bg,e.strokeStyle=g,e.lineWidth=1.4*h,e.beginPath(),e.arc(i.x,i.y,r.r,0,Math.PI*2),e.fill(),e.stroke();return}if(r.kind==="agent"){let S=d.motion?Math.sin(d.time/900)*2:0;e.fillStyle=g,e.globalAlpha=.12*y,e.beginPath(),e.arc(i.x,i.y,r.r*2.4+S,0,Math.PI*2),e.fill(),e.globalAlpha=.35*y,e.strokeStyle=g,e.lineWidth=h,e.beginPath(),e.arc(i.x,i.y,r.r+6+S/2,0,Math.PI*2),e.stroke(),e.globalAlpha=y,e.beginPath(),e.arc(i.x,i.y,r.r,0,Math.PI*2),e.fill();return}if(r.brightness>.4&&(e.globalAlpha=.14*r.brightness*y,e.fillStyle=g,e.beginPath(),e.arc(i.x,i.y,r.r*2.2,0,Math.PI*2),e.fill()),d.motion&&r.recent){let S=(d.time/2400+r.phase)%1;e.globalAlpha=(1-S)*.5*y,e.strokeStyle=g,e.lineWidth=h,e.beginPath(),e.arc(i.x,i.y,r.r+2+S*10,0,Math.PI*2),e.stroke()}e.globalAlpha=(.3+.7*r.brightness)*y,e.fillStyle=g,e.beginPath(),e.arc(i.x,i.y,r.r,0,Math.PI*2),e.fill(),d.highlight?.has(r.id)===!0&&(e.globalAlpha=.9,e.strokeStyle=g,e.lineWidth=1.5*h,e.beginPath(),e.arc(i.x,i.y,r.r+4,0,Math.PI*2),e.stroke()),r.id===d.selectedId&&(e.globalAlpha=1,e.strokeStyle=l.ink,e.lineWidth=2*h,e.beginPath(),e.arc(i.x,i.y,r.r+3.5,0,Math.PI*2),e.stroke())}),d.focus>=0){let r=a[d.focus],o=v[d.focus];r!==void 0&&o!==void 0&&(e.globalAlpha=1,e.strokeStyle=l.agent,e.setLineDash([3*h,3*h]),e.lineWidth=1.5*h,e.beginPath(),e.arc(o.x,o.y,r.r+7,0,Math.PI*2),e.stroke(),e.setLineDash([]))}e.textBaseline="middle",a.forEach((r,o)=>{let i=v[o],y=x(o);if(!(r.kind!=="memory"||s>=1.35||M.has(o)||o===d.focus||r.id===d.selectedId||(d.highlight?.has(r.id)??!1)))return;let S=r.kind==="agent"?12:11;if(e.font=`${r.kind==="dir"?"":"500 "}${S*h}px ${l.font}`,e.globalAlpha=(r.kind==="memory"?.9:r.kind==="dir"?.75:1)*y,e.fillStyle=r.kind==="dir"?l.muted:l.ink,r.kind==="agent")e.textAlign="center",e.fillText(r.label,i.x,i.y+r.r+18*h);else{e.textAlign="left";let R=r.kind==="dir"?`${r.label}/`:r.label;e.fillText(R,i.x+r.r+5*h,i.y)}}),e.globalAlpha=1}var Ve={zh:"已删除的记忆不会再出现在新的索引里,但之前对话中已出现的内容仍保留在那些对话的记录中。",en:"Deleted memories no longer appear in new indexes, but what earlier conversations already showed stays in those conversations' records."},Ce={user:{zh:"用户",en:"User"},feedback:{zh:"反馈",en:"Feedback"},project:{zh:"项目",en:"Project"},reference:{zh:"参考",en:"Reference"}},m={agent:{zh:"智能体",en:"Agent"},member:{zh:"成员",en:"Member"},search:{zh:"搜索记忆",en:"Search memories"},clearSearch:{zh:"清除搜索",en:"Clear search"},noHits:{zh:"没有找到相关的记忆。",en:"No matching memories."},graph:{zh:"图谱",en:"Graph"},list:{zh:"列表",en:"List"},view:{zh:"显示方式",en:"View"},fit:{zh:"适配视图",en:"Fit to view"},fullscreen:{zh:"全屏",en:"Full screen"},exitFullscreen:{zh:"退出全屏",en:"Exit full screen"},loading:{zh:"正在载入记忆…",en:"Loading memories…"},failed:{zh:"记忆载入失败。",en:"Could not load the memories."},retry:{zh:"重试",en:"Retry"},noAccess:{zh:"只有组织成员可以查看记忆。",en:"Only org members can see memories."},emptyTitle:{zh:"还没有记忆",en:"No memories yet"},emptyBody:{zh:"智能体在一对一对话中记下关于你的事情后,会出现在这里。",en:"When an agent remembers something about you in a one-to-one conversation, it shows up here."},emptyAgent:{zh:"这个智能体还没有关于你的记忆。",en:"This agent has no memories about you yet."},emptyOther:{zh:"这位成员和这个智能体之间还没有记忆。",en:"This member has no memories with this agent yet."},sizeLegend:{zh:"大小:被想起的次数",en:"Size: times recalled"},glowLegend:{zh:"亮度:最近一次被想起",en:"Brightness: last recalled"},linkLegend:{zh:"实线:记忆里写下的链接",en:"Solid: links written in memories"},semanticLegend:{zh:"虚线:语义相近",en:"Dashed: semantically close"},hint:{zh:"拖动节点 · 拖动空白处平移 · 滚轮缩放 · 方向键逐条浏览",en:"Drag nodes · drag the background to pan · scroll to zoom · arrow keys to step through"},path:{zh:"路径",en:"Path"},description:{zh:"描述",en:"Description"},body:{zh:"正文",en:"Body"},recalled:{zh:"被想起",en:"Recalled"},lastRecalled:{zh:"最近想起",en:"Last recalled"},never:{zh:"从未",en:"Never"},created:{zh:"创建于",en:"Created"},updated:{zh:"更新于",en:"Updated"},createdIn:{zh:"来自对话",en:"Written in"},openConversation:{zh:"打开对话",en:"Open the conversation"},links:{zh:"链接",en:"Links"},dangling:{zh:"尚未写下",en:"not written yet"},edit:{zh:"编辑",en:"Edit"},save:{zh:"保存",en:"Save"},cancel:{zh:"取消",en:"Cancel"},delete:{zh:"删除",en:"Delete"},close:{zh:"关闭",en:"Close"},confirmTitle:{zh:"删除这条记忆?",en:"Delete this memory?"},actionFailed:{zh:"操作没有完成:",en:"The action did not complete: "},readOnly:{zh:"管理员不能编辑其他成员的记忆。",en:"Admins cannot edit another member's memories."}},Ee=e=>({zh:`${e} 条记忆`,en:e===1?"1 memory":`${e} memories`}),We=(e,n)=>({zh:`正在载入 ${e} / ${n}`,en:`Loading ${e} of ${n}`}),ze=e=>({zh:`${e} 次`,en:e===1?"once":`${e} times`}),Xe=e=>({zh:`你正在查看 ${e} 的记忆。每次查看和删除都会记入审计日志;管理员不能编辑其他成员的记忆。`,en:`You are viewing ${e}'s memories. Every view and delete is recorded in the audit log; admins cannot edit another member's memories.`}),qe=e=>({zh:`记忆图谱,共 ${e} 条记忆。用方向键逐条浏览,回车打开,Esc 关闭。`,en:`Memory graph with ${e} memories. Use the arrow keys to step through them, Enter to open one and Escape to close it.`}),Ue=(e,n)=>({zh:`${e} / ${n} 字节`,en:`${e} / ${n} bytes`});function ge(e,n,t=Date.now()){if(e===null)return m.never[n];let l=Date.parse(e);if(Number.isNaN(l))return m.never[n];let d=new Intl.RelativeTimeFormat(n==="zh"?"zh-CN":"en",{numeric:"auto"}),a=Math.round((l-t)/1e3),s=Math.abs(a);return s<60?d.format(a,"second"):s<3600?d.format(Math.round(a/60),"minute"):s<86400?d.format(Math.round(a/3600),"hour"):s<86400*30?d.format(Math.round(a/86400),"day"):s<86400*365?d.format(Math.round(a/(86400*30)),"month"):d.format(Math.round(a/(86400*365)),"year")}function Ae(e,n){let t=Date.parse(e);return Number.isNaN(t)?e:new Intl.DateTimeFormat(n==="zh"?"zh-CN":"en",{dateStyle:"medium",timeStyle:"short"}).format(t)}import{Fragment as _n,jsx as c,jsxs as N}from"react/jsx-runtime";var De=8192,Ze=200,Mn=300,wn=200,Sn=300,oe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function pe(e){return oe(e)&&Array.isArray(e.nodes)&&Array.isArray(e.edges)&&Array.isArray(e.agents)&&typeof e.canAdmin=="boolean"&&oe(e.selection)?e:null}function In(e){return oe(e)&&Array.isArray(e.nodes)&&Array.isArray(e.edges)&&!("selection"in e)?e:null}var Qe=e=>oe(e)&&oe(e.detail)?e.detail:null,Pn=e=>oe(e)&&Array.isArray(e.hits)?e.hits:null,Je=e=>`${e.kind}:${e.from}>${e.to}`;function Cn(e,n){let t=new Map(e.map(l=>[l.id,l]));for(let l of n)t.set(l.id,l);return[...t.values()]}function En(e,n){let t=new Map(e.map(l=>[Je(l),l]));for(let l of n)t.set(Je(l),l);return[...t.values()]}var en=(e,n)=>e.selection.agentId===n.selection.agentId&&e.selection.accountId===n.selection.accountId;function le(e){let n={accountId:e.selection.accountId};return e.selection.agentId!==null&&(n.agentId=e.selection.agentId),n}var zn=e=>e instanceof Error?e.message:String(e);function tn(){let{view:e,status:n,retry:t}=kn(),l=bn(),d=fn(),{locale:a,t:s}=ae(),M=xn(),I=vn(),[x,C]=F(null),v=$(0),h=$(null);h.current=x;let[r,o]=F(!1),[i,y]=F(null),[g,S]=F(null),[R,X]=F(null),[Y,B]=F(""),[j,_]=F(null),[K,ce]=F(()=>{let u=I.get("view");return u==="graph"||u==="list"?u:null}),[ve,de]=F(0),J=$(null),[ee,xe]=F(!1);U(()=>{let u=()=>xe(document.fullscreenElement===J.current);return document.addEventListener("fullscreenchange",u),()=>document.removeEventListener("fullscreenchange",u)},[]);let b=()=>{if(document.fullscreenElement===J.current){document.exitFullscreen();return}J.current?.requestFullscreen?.().catch(()=>{})},p=q((u,A)=>{C(E=>E!==null&&E.source===u||!A&&E!==null&&!en(E.source,u)?E:(v.current+=1,{source:u,nodes:u.nodes,edges:u.edges,cursor:u.cursor,pages:1,gen:v.current}))},[]),k=$(s);k.current=s;let f=q(u=>y(k.current(m.actionFailed)+zn(u)),[]),P=$(!1),T=$(void 0);U(()=>{if(T.current===e&&e!==null)return;T.current=e;let u=pe(e?.data);if(u!==null){p(u,!1);return}n==="ready"&&h.current===null&&!P.current&&(P.current=!0,l("select",{payload:{}}).then(A=>{let E=pe(A.view?.data);E!==null&&p(E,!0)}).catch(f))},[e,n,p,l,f]);let D=x?.gen,z=x?.cursor??null;U(()=>{let u=h.current;if(u===null||z===null||u.gen!==D)return;let A=!0,E=()=>C(L=>L!==null&&L.gen===u.gen?{...L,cursor:null}:L);return l("more",{payload:{...le(u.source),cursor:z}}).then(L=>{if(!A)return;let G=In(L.view?.data);if(G===null)return E();C(O=>{if(O===null||O.gen!==u.gen)return O;let re=G.cursor===O.cursor||O.pages+1>=wn?null:G.cursor;return{...O,nodes:Cn(O.nodes,G.nodes),edges:En(O.edges,G.edges),cursor:re,pages:O.pages+1}})}).catch(L=>{A&&(f(L),E())}),()=>{A=!1}},[D,z,l,f]);let w=x?.source??null,H=w?.editable??!1,Z=$(null),ne=q(()=>{Z.current=null,X(null),S(null)},[]),ue=$(0),Le=q(async u=>{ue.current+=1,o(!0),y(null);try{let A=await l("select",{payload:u}),E=pe(A.view?.data);E!==null&&(p(E,!0),ne(),_(null),B(""),de(L=>L+1))}catch(A){f(A)}finally{o(!1)}},[l,p,ne,f]),me=q(async u=>{let A=h.current;if(A!==null){Z.current=u,X(u),y(null);try{let E=await l("open",{payload:{...le(A.source),memoryId:u}});if(Z.current!==u)return;let L=Qe(E.view?.data);if(L===null){Z.current=null,X(null);return}S(L)}catch(E){f(E)}}},[l,f]),rn=q(async(u,A,E)=>{let L=h.current;if(L===null)return!1;try{let G=await l("edit",{payload:{...le(L.source),memoryId:u,description:A,body:E}}),O=Qe(G.view?.data);return O===null?!1:(S(O),C(re=>re===null?re:{...re,nodes:re.nodes.map(Ne=>Ne.id===O.id?{...Ne,description:O.description}:Ne)}),!0)}catch(G){return f(G),!1}},[l,f]),on=q(async u=>{let A=h.current;if(A!==null)try{let E=await l("delete",{payload:{...le(A.source),memoryId:u}}),L=pe(E.view?.data);if(L===null)return;p(L,!0),ne(),_(G=>G===null?G:G.filter(O=>O.id!==u))}catch(E){f(E)}},[l,p,ne,f]),ke=q(async u=>{let A=h.current;if(A===null||A.source.selection.agentId===null)return;let E=++ue.current;if(u.trim()===""){_(null);return}let L=()=>E!==ue.current||h.current===null||!en(h.current.source,A.source);try{let G=await l("search",{payload:{...le(A.source),query:u}});if(L())return;let O=Pn(G.view?.data);O!==null&&_(O)}catch(G){L()||f(G)}},[l,f]);if(U(()=>{if(Y.trim()===""){ue.current+=1,_(null);return}let u=setTimeout(()=>{ke(Y)},Sn);return()=>clearTimeout(u)},[Y,ke]),!d.atLeast("member"))return c(fe,{icon:"lock",title:s(m.noAccess)});if(x===null||w===null)return n==="failed"?c(fe,{icon:"circle-alert",title:s(m.failed),children:c(V,{onClick:t,children:s(m.retry)})}):N("div",{className:"cx-memory-state",children:[c(nn,{label:s(m.loading)}),c(W,{tone:"muted",children:s(m.loading)})]});if(w.selection.agentId===null&&w.agents.length===0&&!w.canAdmin)return c(fe,{icon:"empty",title:s(m.emptyTitle),body:s(m.emptyBody)});let te=x.nodes,he=K??(w.total>Mn?"list":"graph"),Re=u=>{ce(u),I.set("view",u)},an=w.agents.find(u=>u.id===w.selection.agentId)?.name??"",sn=w.members?.find(u=>u.id===w.selection.accountId)?.name??w.selection.accountId,Oe=j===null?null:new Set(j.map(u=>u.id)),se=te.length===0;return N("div",{ref:J,className:"cx-memory-page","data-panel":R!==null?"open":"closed","data-empty":se&&j===null?"true":"false","data-fullscreen":ee?"true":"false",children:[N("form",{className:"cx-memory-toolbar",onSubmit:u=>{u.preventDefault(),ke(Y)},children:[N("div",{className:"cx-memory-field",children:[c("span",{className:"cx-memory-field-label",children:s(m.agent)}),c(Ke,{value:w.selection.agentId??"","aria-label":s(m.agent),placeholder:"—",disabled:r||w.agents.length===0,options:w.agents.map(u=>({value:u.id,label:u.name})),onChange:u=>{Le({agentId:u.target.value,accountId:w.selection.accountId})}})]}),w.canAdmin&&w.members!==void 0?N("div",{className:"cx-memory-field",children:[c("span",{className:"cx-memory-field-label",children:s(m.member)}),c(Ke,{value:w.selection.accountId,"aria-label":s(m.member),disabled:r,options:w.members.map(u=>({value:u.id,label:u.name})),onChange:u=>{Le({accountId:u.target.value})}})]}):null,se?null:N("div",{className:"cx-memory-search",children:[c(Q,{name:"search",size:14}),c("input",{className:"cx-memory-input",type:"search",value:Y,placeholder:s(m.search),"aria-label":s(m.search),maxLength:500,disabled:w.selection.agentId===null,onChange:u=>B(u.target.value),onKeyDown:u=>{u.key==="Escape"&&B("")}})]}),N("div",{className:"cx-memory-toolbar-end",children:[c(W,{variant:"small",tone:"muted",children:x.cursor!==null?s(We(te.length,w.total)):s(Ee(Math.max(w.total,te.length)))}),se?null:N("fieldset",{className:"cx-memory-toggle",children:[c("legend",{className:"cx-memory-sr",children:s(m.view)}),c("button",{type:"button",className:"cx-memory-toggle-item","aria-pressed":he==="graph",onClick:()=>Re("graph"),children:s(m.graph)}),c("button",{type:"button",className:"cx-memory-toggle-item","aria-pressed":he==="list",onClick:()=>Re("list"),children:s(m.list)})]}),he==="graph"&&!se?c(V,{variant:"ghost",title:s(m.fit),"aria-label":s(m.fit),onClick:()=>de(u=>u+1),children:c(Q,{name:"zoom-in",size:14})}):null,c(V,{variant:"ghost",title:s(ee?m.exitFullscreen:m.fullscreen),"aria-label":s(ee?m.exitFullscreen:m.fullscreen),onClick:b,children:c(Q,{name:ee?"minimize-2":"maximize-2",size:14})})]})]}),H?null:N("div",{className:"cx-memory-banner",role:"note",children:[c(Q,{name:"admin",size:14}),c(W,{variant:"small",children:s(Xe(sn))})]}),i!==null?c("div",{className:"cx-memory-banner","data-tone":"fail",role:"alert",children:c(W,{variant:"small",tone:"fail",children:i})}):null,N("div",{className:"cx-memory-body",children:[N("div",{className:"cx-memory-main",children:[j!==null?c(Ln,{hits:j,onOpen:me,onClear:()=>B("")}):null,se?c(fe,{icon:"empty",title:s(m.emptyTitle),body:s(w.selection.agentId===null?m.emptyBody:H?m.emptyAgent:m.emptyOther)}):he==="graph"?c(Tn,{nodes:te,edges:x.edges,agentLabel:an,motion:!M,selectedId:R,highlight:Oe,fitSignal:ve,onOpen:u=>{me(u)},onEscape:ne,label:s(qe(te.length))}):c(Dn,{nodes:te,highlight:Oe,selectedId:R,onOpen:u=>{me(u)}})]}),R!==null?c(On,{detail:g?.id===R?g:null,editable:H,canDelete:H||w.canAdmin,locale:a,onClose:ne,onOpen:u=>{me(u)},onSave:rn,onDelete:on},R):null]})]})}function fe(e){return N("div",{className:"cx-memory-state",children:[c("span",{className:"cx-memory-state-icon","aria-hidden":"true",children:c(Q,{name:e.icon,size:16})}),c(W,{variant:"h3",children:e.title}),e.body!==void 0?c(W,{tone:"muted",children:e.body}):null,e.children]})}function be({type:e}){return c("span",{className:"cx-memory-dot","data-type":e,"aria-hidden":"true"})}function An(){let{t:e}=ae();return N("div",{className:"cx-memory-legend","aria-hidden":"true",children:[c("div",{className:"cx-memory-legend-row",children:ye.map(n=>N("span",{className:"cx-memory-legend-item",children:[c(be,{type:n}),e(Ce[n])]},n))}),N("div",{className:"cx-memory-legend-row",children:[N("span",{className:"cx-memory-legend-item",children:[c("span",{className:"cx-memory-legend-line","data-kind":"link"}),e(m.linkLegend)]}),N("span",{className:"cx-memory-legend-item",children:[c("span",{className:"cx-memory-legend-line","data-kind":"semantic"}),e(m.semanticLegend)]})]}),N("div",{className:"cx-memory-legend-row",children:[c("span",{className:"cx-memory-legend-item",children:e(m.sizeLegend)}),c("span",{className:"cx-memory-legend-item",children:e(m.glowLegend)})]})]})}function Tn(e){let{locale:n,t}=ae(),l=$(null),d=$(null),a=$(null),s=$({x:0,y:0,k:1}),M=$({w:0,h:0,dpr:1}),I=$(-1),x=$(-1),C=$(!1),v=$(null),h=$(e);h.current=e;let[r,o]=F(null),[i,y]=F(null),g=q((b=0)=>{let p=d.current,k=a.current;if(p===null||k===null)return;let f=p.getContext("2d");if(f===null)return;let{w:P,h:T,dpr:D}=M.current,z=h.current;je(f,k,s.current,He(p),{width:P,height:T,dpr:D,time:b,motion:z.motion,hover:I.current>=0?I.current:x.current,focus:x.current,selectedId:z.selectedId,highlight:z.highlight})},[]),S=q(()=>{let b=a.current,{w:p,h:k}=M.current;b===null||p===0||k===0||(s.current=Pe(b,p,k))},[]),{nodes:R,edges:X,agentLabel:Y,motion:B}=e;U(()=>{let b=a.current,p=Ge({nodes:R,edges:X,agentLabel:Y},{now:Date.now(),previous:b});B||Be(p),a.current=p,I.current=-1,x.current=-1,(b===null||!C.current)&&S(),B||g()},[R,X,Y,B,S,g]);let{fitSignal:j}=e;U(()=>{j!==0&&(C.current=!1,S(),g())},[j,S,g]);let{selectedId:_,highlight:K}=e;U(()=>{B||g()},[_,K,B,g]),U(()=>{let b=l.current,p=d.current;if(b===null||p===null)return;let k=()=>{let P=Math.max(1,Math.min(3,globalThis.devicePixelRatio||1)),T=b.clientWidth,D=b.clientHeight;M.current={w:T,h:D,dpr:P},p.width=Math.round(T*P),p.height=Math.round(D*P),C.current||S(),g()};if(k(),typeof ResizeObserver>"u")return;let f=new ResizeObserver(k);return f.observe(b),()=>f.disconnect()},[S,g]),U(()=>{if(!B)return;let b=0,p=k=>{let f=a.current;if(f!==null&&f.alpha>=.005){Se(f);let{w:P,h:T}=M.current;if(!C.current&&P>0&&T>0){let D=Pe(f,P,T),z=s.current;s.current={x:z.x+(D.x-z.x)*.12,y:z.y+(D.y-z.y)*.12,k:z.k+(D.k-z.k)*.12}}}g(k),b=requestAnimationFrame(p)};return b=requestAnimationFrame(p),()=>cancelAnimationFrame(b)},[B,g]),U(()=>{let b=d.current;if(b===null)return;let p=k=>{k.preventDefault();let f=b.getBoundingClientRect();C.current=!0,s.current=Ye(s.current,k.clientX-f.left,k.clientY-f.top,Math.exp(-k.deltaY*.0015)),h.current.motion||g()};return b.addEventListener("wheel",p,{passive:!1}),()=>b.removeEventListener("wheel",p)},[g]);let ce=b=>{let p=b.currentTarget.getBoundingClientRect();return{sx:b.clientX-p.left,sy:b.clientY-p.top}},ve=b=>{let p=a.current;if(p===null)return;let{sx:k,sy:f}=ce(b),P=ie(s.current,k,f),T=Ie(p,P.x,P.y,4/s.current.k);v.current={node:T,sx:k,sy:f,lastX:k,lastY:f,moved:!1},b.currentTarget.setPointerCapture?.(b.pointerId)},de=b=>{let p=a.current;if(p===null)return;let{sx:k,sy:f}=ce(b),P=v.current,T=h.current.motion;if(P!==null){if(!P.moved&&Math.hypot(k-P.sx,f-P.sy)<4)return;P.moved=!0,o(null);let w=P.node>=0?p.nodes[P.node]:void 0;if(w!==void 0&&w.kind!=="agent"){let H=ie(s.current,k,f);w.x=H.x,w.y=H.y,w.pinned=!0,T&&(p.alpha=Math.max(p.alpha,.25))}else{C.current=!0;let H=s.current;s.current={...H,x:H.x+k-P.lastX,y:H.y+f-P.lastY}}P.lastX=k,P.lastY=f,T||g();return}let D=ie(s.current,k,f),z=Ie(p,D.x,D.y,4/s.current.k);if(z!==I.current){I.current=z;let w=z>=0?p.nodes[z]?.memory??null:null;o(w===null?null:{x:k,y:f,node:w}),T||g()}},J=b=>{let p=v.current;v.current=null;let k=a.current;if(p===null||k===null)return;let f=p.node>=0?k.nodes[p.node]:void 0;if(p.moved){f!==void 0&&f.kind!=="agent"&&h.current.motion&&(f.pinned=!1);return}f?.memory&&h.current.onOpen(f.memory.id)},ee=()=>{v.current===null&&(I.current=-1,o(null),h.current.motion||g())},xe=b=>{let p=a.current;if(p===null)return;let k=p.nodes.flatMap((D,z)=>D.kind==="memory"?[z]:[]);if(k.length===0)return;let f=k.indexOf(x.current),P=-1;if(b.key==="ArrowRight"||b.key==="ArrowDown")P=k[(f+1)%k.length]??-1;else if(b.key==="ArrowLeft"||b.key==="ArrowUp")P=k[(f-1+k.length)%k.length]??-1;else if(b.key==="Home")P=k[0]??-1;else if(b.key==="End")P=k[k.length-1]??-1;else if(b.key==="Enter"||b.key===" "){let D=p.nodes[x.current]?.memory;D&&(b.preventDefault(),h.current.onOpen(D.id));return}else if(b.key==="Escape"){h.current.onEscape();return}else return;b.preventDefault(),x.current=P;let T=p.nodes[P];if(y(T?.memory??null),T!==void 0){let{w:D,h:z}=M.current,w=s.current,H=T.x*w.k+w.x,Z=T.y*w.k+w.y;D>0&&(H<40||Z<40||H>D-40||Z>z-40)&&(C.current=!0,s.current={...w,x:D/2-T.x*w.k,y:z/2-T.y*w.k})}h.current.motion||g()};return N("div",{className:"cx-memory-stage",ref:l,children:[c("canvas",{ref:d,className:"cx-memory-canvas",tabIndex:0,"aria-label":e.label,onPointerDown:ve,onPointerMove:de,onPointerUp:J,onPointerCancel:()=>{v.current=null},onPointerLeave:ee,onKeyDown:xe,onBlur:()=>{x.current=-1,y(null),h.current.motion||g()}}),c("div",{className:"cx-memory-sr cx-memory-live","aria-live":"polite",children:i!==null?`${i.path} — ${i.description}`:""}),r!==null?N("div",{className:"cx-memory-tip",style:{left:r.x+14,top:r.y+14},"aria-hidden":"true",children:[N("span",{className:"cx-memory-tip-path",children:[c(be,{type:r.node.type}),r.node.path]}),c("span",{className:"cx-memory-tip-desc",children:r.node.description}),N("span",{className:"cx-memory-tip-meta",children:[t(m.recalled)," ",t(ze(r.node.recalls))," · ",t(m.lastRecalled)," ",ge(r.node.lastRecalledAt,n)]})]}):null,c(An,{}),c("div",{className:"cx-memory-hint","aria-hidden":"true",children:t(m.hint)})]})}function Dn(e){let{locale:n,t}=ae(),l=Nn(()=>[...e.nodes].sort((a,s)=>a.path<s.path?-1:a.path>s.path?1:0),[e.nodes]),d=e.highlight===null?l:l.filter(a=>e.highlight?.has(a.id));return N("div",{className:"cx-memory-list",children:[N("div",{className:"cx-memory-list-head","aria-hidden":"true",children:[c("span",{children:t(m.path)}),c("span",{children:t(m.description)}),c("span",{children:t(m.recalled)}),c("span",{children:t(m.lastRecalled)})]}),c("ul",{className:"cx-memory-rows",children:d.map(a=>c("li",{children:N("button",{type:"button",className:"cx-memory-row","data-memory-id":a.id,"aria-current":a.id===e.selectedId?"true":void 0,onClick:()=>e.onOpen(a.id),children:[N("span",{className:"cx-memory-row-path",children:[c(be,{type:a.type}),a.path]}),c("span",{className:"cx-memory-row-desc",children:a.description}),c("span",{className:"cx-memory-row-num",children:a.recalls}),c("span",{className:"cx-memory-row-num",children:ge(a.lastRecalledAt,n)})]})},a.id))})]})}function Ln(e){let{t:n}=ae();return N("section",{className:"cx-memory-hits","aria-label":n(m.search),children:[N("div",{className:"cx-memory-hits-head",children:[c(W,{variant:"small",tone:"muted",children:e.hits.length===0?n(m.noHits):n(Ee(e.hits.length))}),c(V,{variant:"ghost",onClick:e.onClear,children:n(m.clearSearch)})]}),e.hits.map(t=>N("button",{type:"button",className:"cx-memory-hit",onClick:()=>e.onOpen(t.id),children:[c("span",{className:"cx-memory-hit-path",children:t.path}),c("span",{className:"cx-memory-hit-desc",children:t.description}),t.snippet!==""?c("span",{className:"cx-memory-hit-snippet",children:t.snippet}):null]},t.id))]})}var Rn=e=>new TextEncoder().encode(e).length;function On(e){let{t:n}=ae(),{detail:t,locale:l}=e,[d,a]=F("view"),[s,M]=F(""),[I,x]=F(""),[C,v]=F(!1);if(t===null)return c("aside",{className:"cx-memory-panel","aria-busy":"true",children:N("div",{className:"cx-memory-panel-head",children:[c(nn,{size:12}),c("span",{className:"cx-memory-grow"}),c(V,{variant:"ghost","aria-label":n(m.close),onClick:e.onClose,children:c(Q,{name:"x",size:14})})]})});let h=i=>i[l],r=Rn(I),o=s.trim()===""||s.length>Ze||/[\r\n]/.test(s)||r>De;return N("aside",{className:"cx-memory-panel","aria-label":t.path,children:[N("div",{className:"cx-memory-panel-head",children:[c(be,{type:t.type}),c("span",{className:"cx-memory-panel-path",children:t.path}),c(gn,{children:h(Ce[t.type])}),c("span",{className:"cx-memory-grow"}),c(V,{variant:"ghost","aria-label":n(m.close),onClick:e.onClose,children:c(Q,{name:"x",size:14})})]}),c("div",{className:"cx-memory-panel-body",children:d==="edit"?N("form",{className:"cx-memory-edit",onSubmit:i=>{i.preventDefault(),!o&&(v(!0),e.onSave(t.id,s,I).then(y=>{v(!1),y&&a("view")}))},children:[N("label",{className:"cx-memory-field","data-block":"true",children:[c("span",{className:"cx-memory-field-label",children:n(m.description)}),c("input",{className:"cx-memory-input",value:s,maxLength:Ze,onChange:i=>M(i.target.value)})]}),N("label",{className:"cx-memory-field","data-block":"true",children:[c("span",{className:"cx-memory-field-label",children:n(m.body)}),c("textarea",{className:"cx-memory-textarea",value:I,rows:12,onChange:i=>x(i.target.value)}),c("span",{className:"cx-memory-field-note","data-over":r>De,children:n(Ue(r,De))})]}),N(Te,{direction:"row",gap:8,justify:"end",children:[c(V,{onClick:()=>a("view"),children:n(m.cancel)}),c(V,{type:"submit",variant:"primary",loading:C,disabled:o,children:n(m.save)})]})]}):N(_n,{children:[c(W,{children:t.description}),c("div",{className:"cx-memory-markdown",children:t.body}),t.links.length>0?N("div",{className:"cx-memory-links",children:[c(W,{variant:"small",tone:"muted",children:n(m.links)}),t.links.map(i=>i.targetId!==null?N("button",{type:"button",className:"cx-memory-link",onClick:()=>e.onOpen(i.targetId),children:["[[",i.path,"]]"]},i.path):N("span",{className:"cx-memory-link","data-dangling":"true",children:["[[",i.path,"]] · ",n(m.dangling)]},i.path))]}):null,c(pn,{keyWidth:"12ch",rows:[{k:n(m.recalled),v:n(ze(t.recalls))},{k:n(m.lastRecalled),v:ge(t.lastRecalledAt,l)},{k:n(m.created),v:Ae(t.createdAt,l)},{k:n(m.updated),v:Ae(t.updatedAt,l)},...t.createdIn!==null?[{k:n(m.createdIn),v:e.editable?c("a",{className:"cx-memory-anchor",href:`/chat/${encodeURIComponent(t.createdIn)}`,children:n(m.openConversation)}):t.createdIn}]:[]]}),d==="confirm"?N("div",{className:"cx-memory-confirm",role:"alertdialog","aria-label":n(m.confirmTitle),children:[c(W,{variant:"h3",children:n(m.confirmTitle)}),c(W,{variant:"small",children:n(Ve)}),N(Te,{direction:"row",gap:8,justify:"end",children:[c(V,{onClick:()=>a("view"),children:n(m.cancel)}),c(V,{variant:"danger-solid",loading:C,onClick:()=>{v(!0),e.onDelete(t.id).finally(()=>v(!1))},children:n(m.delete)})]})]}):N(Te,{direction:"row",gap:8,justify:"end",children:[e.editable?c(V,{onClick:()=>{M(t.description),x(t.body),a("edit")},children:n(m.edit)}):null,e.canDelete?c(V,{variant:"danger",onClick:()=>a("confirm"),children:n(m.delete)}):null]}),e.editable?null:c(W,{variant:"small",tone:"muted",children:n(m.readOnly)})]})})]})}var Kn=$n({name:"memory",components:{overview:Gn("org.page",tn)}});export{Kn as default};
|
|
@@ -23,6 +23,18 @@
|
|
|
23
23
|
color: var(--cb-ink);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/* No memories: the page is as tall as what it shows, not a viewport-high empty box. */
|
|
27
|
+
.cx-memory-page[data-empty="true"] {
|
|
28
|
+
height: auto;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* 全屏: the page element is the fullscreen element and fills the screen. */
|
|
32
|
+
.cx-memory-page[data-fullscreen="true"] {
|
|
33
|
+
height: 100dvh;
|
|
34
|
+
padding: var(--cb-space-4);
|
|
35
|
+
background: var(--cb-bg);
|
|
36
|
+
}
|
|
37
|
+
|
|
26
38
|
/* ---------- Top bar ---------- */
|
|
27
39
|
|
|
28
40
|
.cx-memory-toolbar {
|
|
@@ -117,17 +129,45 @@
|
|
|
117
129
|
opacity: 0.55;
|
|
118
130
|
}
|
|
119
131
|
|
|
132
|
+
/* The search is one field: the icon and the input share the border, so the focus ring goes round
|
|
133
|
+
the whole field (a ring on the input alone was clipped by the field's edge). */
|
|
120
134
|
.cx-memory-search {
|
|
135
|
+
box-sizing: border-box;
|
|
121
136
|
display: flex;
|
|
122
137
|
flex: 1 1 220px;
|
|
123
138
|
align-items: center;
|
|
124
139
|
gap: var(--cb-space-2);
|
|
125
140
|
max-width: 420px;
|
|
141
|
+
height: var(--cb-field-height, 32px);
|
|
142
|
+
padding: 0 var(--cb-space-2);
|
|
143
|
+
border: 1px solid var(--cb-line);
|
|
144
|
+
border-radius: var(--cb-radius-sm);
|
|
145
|
+
background: var(--cb-panel);
|
|
126
146
|
color: var(--cb-muted);
|
|
147
|
+
transition: border-color var(--cb-motion) ease;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.cx-memory-search:hover {
|
|
151
|
+
border-color: var(--cb-line-strong);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.cx-memory-search:focus-within {
|
|
155
|
+
border-color: var(--cb-accent);
|
|
156
|
+
box-shadow: 0 0 0 3px var(--cb-focus-ring);
|
|
127
157
|
}
|
|
128
158
|
|
|
129
159
|
.cx-memory-search .cx-memory-input {
|
|
130
160
|
flex: 1;
|
|
161
|
+
height: 100%;
|
|
162
|
+
padding: 0;
|
|
163
|
+
border: 0;
|
|
164
|
+
background: transparent;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.cx-memory-search .cx-memory-input:hover,
|
|
168
|
+
.cx-memory-search .cx-memory-input:focus-visible {
|
|
169
|
+
border: 0;
|
|
170
|
+
box-shadow: none;
|
|
131
171
|
}
|
|
132
172
|
|
|
133
173
|
.cx-memory-toolbar-end {
|
|
@@ -191,6 +231,11 @@
|
|
|
191
231
|
text-align: center;
|
|
192
232
|
}
|
|
193
233
|
|
|
234
|
+
/* No memories: a compact empty state, not a viewport-high blank panel. */
|
|
235
|
+
.cx-memory-page[data-empty="true"] .cx-memory-state {
|
|
236
|
+
min-height: 220px;
|
|
237
|
+
}
|
|
238
|
+
|
|
194
239
|
.cx-memory-state-icon {
|
|
195
240
|
display: inline-flex;
|
|
196
241
|
align-items: center;
|
package/dist/index.mjs
CHANGED
|
@@ -4436,7 +4436,7 @@ async function search(ctx, db, owner, query, limit, opts = {}) {
|
|
|
4436
4436
|
}
|
|
4437
4437
|
|
|
4438
4438
|
// src/page.ts
|
|
4439
|
-
var PAGE = "
|
|
4439
|
+
var PAGE = "overview";
|
|
4440
4440
|
var MAX_NODES = 1e3;
|
|
4441
4441
|
var MAX_AGENTS = 100;
|
|
4442
4442
|
var MAX_MEMBERS = 200;
|
|
@@ -5060,7 +5060,7 @@ function registerTools(ctx, opts = {}) {
|
|
|
5060
5060
|
// src/index.ts
|
|
5061
5061
|
var index_default = defineExtension({
|
|
5062
5062
|
name: "memory",
|
|
5063
|
-
version: "0.1.0-rc.
|
|
5063
|
+
version: "0.1.0-rc.2",
|
|
5064
5064
|
sdk: "^0.1.0-rc.19",
|
|
5065
5065
|
provides: [CONTEXT_EXTENSION_POINT],
|
|
5066
5066
|
ui: [
|
package/icon.svg
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" shape-rendering="crispEdges"><title>Memory</title><style>@media (prefers-color-scheme: dark){path{fill:#FF6A13}}</style><path fill="#CC4609" d="M14 1.4h1.35v1.35h-1.35zM12.65 2.75h4.05v1.35h-4.05zM4.55 4.1h14.85v1.35h-14.85zM3.2 5.45h12.15v1.35h-12.15zM16.7 5.45h2.7v1.35h-2.7zM1.85 6.8h17.55v1.35h-17.55zM1.85 8.15h17.55v1.35h-17.55zM1.85 9.5h17.55v1.35h-17.55zM3.2 10.85h13.5v1.35h-13.5zM3.2 12.2h2.7v1.35h-2.7zM8.6 12.2h1.35v1.35h-1.35zM12.65 12.2h2.7v1.35h-2.7zM3.2 13.55h2.7v1.35h-2.7zM8.6 13.55h1.35v1.35h-1.35zM12.65 13.55h2.7v1.35h-2.7z"/><path fill="#CC4609" d="M17.1 15.1h3.45v1.15h-3.45zM17.1 16.25h3.45v1.15h-3.45zM14.8 18.55h2.3v1.15h-2.3zM20.55 18.55h2.3v1.15h-2.3zM14.8 19.7h2.3v1.15h-2.3zM20.55 19.7h2.3v1.15h-2.3z"/></svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/plugin-memory",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Memory for agents: each agent remembers each member across conversations, with an index at run start, memory tools, hybrid search and a memory page",
|