Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
TypeScript aiai-agentsai-memoryanthropicartificial-intelligencechromadbclaudeclaude-agent-sdkclaude-agentsclaude-codeclaude-code-pluginclaude-skillsembeddingslong-term-memorymem0memory-engineopenmemoryragsqlitesupermemory
import{D as e,E as t,N as n,O as r,S as i,a,b as o,j as s,k as c,r as l}from"./served-from-8DzM0VAM.js";import{A as u,at as d}from"./local-source-emarjVnA.js";import{a as f,c as p,i as m,s as h}from"./brand-DA3Kl5y4.js";import{S as g,a as _,c as v,g as y,o as b}from"./focus-overview-CQWF43T3.js";import{t as x}from"./monitor-DWQlfYB9.js";import{$ as S,P as ee,k as C}from"./parse-sse-frame-DXl4zDFf.js";import{c as w,l as T,o as E,t as D,u as O}from"./req-DRjqKS_G.js";import{D as te,E as k,Gt as ne,Kt as A,O as j,Sn as M,Ut as re,Wt as N,Zn as P,_n as F,or as I,tn as L,vn as R,xn as z}from"./index-Dknlc6p6.js";import{n as B,t as V}from"./work-view-refresh-reasons-CoqqWOr-.js";var H={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};H.node;var U=r(H),W=n(s(),1);function G(e){return e?e.enabled?e.error||e.files?.length||e.conflicts?.length||e.invalid||e.unsupported?{state:`attention`,label:`My Work needs attention`,attention:!0,detail:`Some shared My Work changes could not be accepted. The previous complete state is retained.`}:e.pending?{state:`pending`,label:`My Work receiving`,attention:!1,detail:`Shared My Work records are still arriving. The previous complete state remains visible.`}:{state:`enabled`,label:`My Work sharing on`,attention:!1,detail:`This installation publishes My Work records. Cloud freshness is shown separately.`}:{state:`disabled`,label:`My Work sharing off`,attention:!1,detail:`Shared My Work state is not enabled. Replicated facts can be displayed, but this installation does not publish new My Work records.`}:null}var K=`/api/version`;function q(e){return e===null}var J=(e,t)=>{let n=e&&typeof e==`object`?e[t]:null;return typeof n==`string`&&n.trim()?n.trim():null};async function Y(e){let t;try{t=await e(K,{headers:{Accept:`application/json`}})}catch(e){return{state:`failed`,cause:e instanceof Error?e.message:String(e)}}let n=await t.text().catch(()=>``),r=null;try{r=JSON.parse(n)}catch{}if(!t.ok)return{state:`refused`,status:t.status,reason:J(r,`error`)};let i=J(r,`version`);return i?{state:`read`,version:i}:{state:`failed`,cause:`The worker answered ${t.status} without a version: ${n||`(empty)`}`}}var X=c(),ie=`https://docs.claude-mem.ai/cloud-sync`,ae={local:e=>e(`Local worker`),cloud:e=>e(`Cloud viewer`),sample:e=>e(`Sample data`)},oe={realtime:e=>e(`Realtime`),polling:e=>e(`HTTP polling`)},se={reading:(e,t)=>t(`Reading…`),read:e=>e.state===`read`?e.version:``,refused:(e,t)=>e.state===`refused`?e.reason?S(t(`Not read here: {reason}`),{reason:t(e.reason)}):S(t(`Not read: the server answered {status}.`),{status:e.status}):``,failed:(e,t)=>t(`Couldn’t read it.`),"not-read-here":(e,t)=>t(`Not read here: cmem.ai shows your synced work and runs no worker.`)},ce={neutral:`text-foreground`,positive:`text-foreground`,warning:`text-attention-foreground`};function Z({children:e}){let{t:n}=i();return(0,X.jsxs)(_,{className:`mt-2`,children:[(0,X.jsx)(v,{asChild:!0,children:(0,X.jsxs)(a,{variant:`ghost`,size:`sm`,className:`group/details -ml-2 text-accent-foreground`,children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`transition-transform group-aria-expanded/details:rotate-90 motion-reduce:transition-none`}),n(`Details`)]})}),(0,X.jsx)(b,{className:`space-y-1.5 pt-1 text-sm text-muted-foreground`,children:e})]})}function le(e){let t=q(d()),[n,r]=(0,W.useState)(t?{state:`reading`}:{state:`not-read-here`});return(0,W.useEffect)(()=>{if(!e||!t)return;let n=!0;return Y((e,t)=>fetch(e,t)).then(e=>{n&&r(e)}),()=>{n=!1}},[e,t]),e?n:null}function Q({label:e,children:t,tone:n=`neutral`,fact:r}){return(0,X.jsxs)(`div`,{"data-fact":r,className:`flex items-baseline justify-between gap-4 border-b border-border py-2.5 text-sm text-muted-foreground last:border-b-0`,children:[(0,X.jsx)(`dt`,{children:e}),(0,X.jsx)(`dd`,{className:o(`min-w-0 text-right font-medium [overflow-wrap:anywhere]`,ce[n]),children:t})]})}function ue({version:e}){let{t}=i(),{mode:n}=O(),{sourceKind:r,sourceHealth:a,unlinkedWorkCount:o}=T(),s=E(),c=r===`sample`,u=l(window.location.hostname);return(0,X.jsx)(D,{ids:[`R6.4`,`R13.1`,`R6.1`],children:(0,X.jsxs)(k,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-10 items-center justify-center rounded-lg bg-working text-working-foreground`,children:(0,X.jsx)(x,{className:`size-5`})}),(0,X.jsx)(j,{className:`mt-3`,children:t(u?`Cloud viewer`:`This computer`)}),(0,X.jsx)(`p`,{"data-source-status":``,className:`text-muted-foreground`,children:c?t(`Sample data · not your work`):a.connected?t(u?`Your synced work is available.`:`Local work is available.`):t(`The worker answered, but could not read your saved work. It may be busy; try again in a moment.`)}),!c&&!a.connected&&a.error&&(0,X.jsx)(F,{cause:a.error}),(0,X.jsxs)(`dl`,{className:`mt-4 border-t border-border pt-1`,children:[(0,X.jsx)(Q,{label:t(`Memory source`),fact:`source`,children:ae[r](t)}),(0,X.jsx)(Q,{label:t(`Live feed`),fact:`feed`,tone:c?`neutral`:s.tone,children:c?t(n===`home`?`Streams from the local worker, localhost:37777 (demonstration)`:`Checks cmem.ai for new sync changes every few seconds (demonstration)`):(0,X.jsx)(`span`,{"data-connection-state":s.state,children:t(s.label)})}),!c&&s.lastSuccessfulCheckAt&&(0,X.jsx)(Q,{label:t(`Last checked`),fact:`checked`,children:(0,X.jsx)(R,{iso:s.lastSuccessfulCheckAt})}),e&&(0,X.jsx)(Q,{label:t(`Worker version`),fact:`version`,tone:e.state===`refused`||e.state===`failed`?`warning`:`neutral`,children:(0,X.jsx)(`span`,{"data-version-read":e.state,children:se[e.state](e,t)})})]}),e?.state===`failed`&&(0,X.jsx)(F,{cause:e.cause}),o>0&&(0,X.jsx)(`p`,{"data-unlinked-work":``,className:`mt-3 text-sm text-muted-foreground`,children:S(t(o===1?`{count} work record isn't linked to a request yet.`:`{count} work records aren't linked to a request yet.`),{count:o})}),!c&&(0,X.jsxs)(Z,{children:[(0,X.jsx)(`p`,{children:t(s.detail)}),s.activityCheckedAt&&(0,X.jsx)(`p`,{children:A(t(`Activity last inspected {time}`),`time`,(0,X.jsx)(R,{iso:s.activityCheckedAt}))}),s.clockSkew&&(0,X.jsx)(`p`,{children:t(`Source and browser clocks differ; freshness uses received heartbeats.`)}),(0,X.jsx)(`p`,{children:t(`Connection status does not indicate an agent is running.`)})]})]})})}function de(){let{t:e}=i(),{sourceKind:t,sharedState:n}=T(),r=E(),o=t===`sample`,s=o?void 0:r.sync,c=o?null:G(n),l=s?.detailParts?.mode??null,d=s?.detailParts?.remaining??null,f=s?.pendingUpload??null;return(0,X.jsxs)(k,{title:e(`Cloud sync`),children:[s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{"data-sync-sentence":``,className:`text-muted-foreground`,children:e(s.detailParts?.sentence??s.detail)}),(0,X.jsxs)(`dl`,{className:`mt-3`,children:[(0,X.jsx)(Q,{label:e(`State`),fact:`sync-state`,tone:s.tone,children:e(s.label)}),f!==null&&(0,X.jsx)(Q,{label:e(`Waiting to upload`),fact:`upload`,children:S(e(f===1?`{count} item`:`{count} items`),{count:f})}),l&&(0,X.jsx)(Q,{label:e(`Mode`),fact:`mode`,children:oe[l](e)}),d!==null&&(0,X.jsx)(Q,{label:e(`Changes remaining`),fact:`remaining`,children:(0,X.jsx)(`span`,{className:`tabular`,children:d})}),c&&(0,X.jsx)(Q,{label:e(`Sharing`),fact:`sharing`,tone:c.attention?`warning`:`neutral`,children:e(c.label)})]}),(0,X.jsxs)(Z,{children:[(0,X.jsx)(`p`,{"data-sync-detail":``,children:u(s,e)}),c&&(0,X.jsx)(`p`,{children:e(c.detail)})]})]}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:e(`Checks cmem.ai for new sync changes every few seconds (demonstration)`)}),(0,X.jsx)(a,{asChild:!0,variant:`ghost`,size:`sm`,className:`-ml-2 text-accent-foreground`,children:(0,X.jsxs)(`a`,{href:ie,target:`_blank`,rel:`noreferrer`,children:[e(`Sync details`),(0,X.jsx)(I,{"aria-hidden":`true`})]})})]})}function fe(){let e=w(e=>e.refreshWork),[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(null);return{start:async t=>{n(!0),i(null),o(null);try{let{state:n}=await e();o({state:n,atIso:new Date().toISOString(),recordAtPress:t})}catch(e){i({cause:e,recordAtPress:t})}finally{n(!1)}},pending:t,failure:r,answer:a}}function pe(e,t){return e instanceof C?V(e.workerReason)?{words:S(t(`The review could not start: {reason}`),{reason:t(e.workerReason)}),details:null}:{words:t(`The review could not start. The worker refused it.`),details:e.workerReason??S(t(`The worker answered {status}.`),{status:e.status})}:{words:t(`The review could not start. The worker did not answer; it may be restarting.`),details:e instanceof Error?e.message:String(e)}}var $={"up-to-date":()=>(0,X.jsx)(e,{"aria-hidden":`true`,className:`size-4.5 shrink-0`}),updating:()=>(0,X.jsx)(m,{className:`size-4.5`}),failed:()=>(0,X.jsx)(g,{"aria-hidden":`true`,className:`size-4.5 shrink-0`}),"waiting-for-agent":()=>(0,X.jsx)(U,{"aria-hidden":`true`,className:`size-4.5 shrink-0`})},me={"up-to-date":(e,t)=>t?A(e(`Last reviewed at {time}.`),`time`,t):e(`No review has finished yet.`),updating:e=>e(`Reviewing your goals and progress now…`),failed:(e,t)=>t?A(e(`The {time} review failed.`),`time`,t):e(`The last review failed.`),"waiting-for-agent":(e,t,n)=>n?S(e(`Waiting to review: {reason}`),{reason:e(n)}):e(`Waiting for an agent to run the review. The next check tries again by itself.`)},he={"up-to-date":`text-foreground`,updating:`text-foreground`,failed:`text-attention-foreground`,"waiting-for-agent":`text-attention-foreground`};function ge({learning:e,run:t,earlier:n}){let{t:r,locale:a}=i(),o=e.preferencesFound-e.newSuggestions;return(0,X.jsxs)(`div`,{"data-slot":`learning-run-numbers`,className:`space-y-2 text-sm`,children:[(0,X.jsx)(`table`,{className:`w-full`,children:(0,X.jsxs)(`tbody`,{className:`divide-y`,children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{scope:`row`,className:`py-2 text-left font-normal text-muted-foreground`,children:r(`Request reviews read`)}),(0,X.jsx)(`td`,{className:`mono-number py-2 text-right`,children:e.reviewsRead.toLocaleString(a)})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{scope:`row`,className:`py-2 text-left font-normal text-muted-foreground`,children:r(`Preferences found`)}),(0,X.jsx)(`td`,{className:`mono-number py-2 text-right`,children:e.preferencesFound.toLocaleString(a)})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{scope:`row`,className:`py-2 text-left font-normal text-muted-foreground`,children:r(n?`Waiting for your decision after it`:`Waiting for your decision`)}),(0,X.jsx)(`td`,{className:`mono-number py-2 text-right text-attention-foreground`,children:e.newSuggestions.toLocaleString(a)})]})]})}),o>0&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:S(r(o===1?`The other {count} is already decided.`:`The other {count} are already decided.`),{count:o.toLocaleString(a)})}),(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:S(r(`Ran on {device}.`),{device:t.deviceName})})]})}function _e({run:e,readError:t}){let{t:n}=i();return(0,X.jsx)(`div`,{"data-goals-run":t?`unreadable`:e?`read`:`none`,className:`space-y-1.5 border-t pt-3 text-sm`,children:t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`font-medium text-attention-foreground`,children:n(`The last goals run could not be read.`)}),(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n(`Suggested and Past focus wait until it can be read.`)}),(0,X.jsx)(L,{cause:t})]}):e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`font-medium`,children:[n(`Last goals run`),` `,(0,X.jsx)(`span`,{className:`mono-number font-normal text-muted-foreground`,children:y(e.lastRunAtIso,e.lastRunAt)})]}),(0,X.jsxs)(`p`,{className:`text-muted-foreground`,children:[n(`Suggested and Past focus come from it.`),` `,S(n(`Ran on {device}.`),{device:e.deviceName})]})]}):(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n(`No goals run has finished yet.`)})})}function ve({refresh:e,run:t,learning:n,goalsRun:r,goalsReadError:s}){let{t:c}=i(),l=fe(),u=w(e=>e.work.sourceKind),d=ne(e,l.answer),m=d.state,g=re(u),_=e?.finishedAt?(0,X.jsx)(z,{iso:e.finishedAtIso,words:e.finishedAt}):null,v=t?(0,X.jsx)(z,{iso:t.lastRunAtIso,words:t.lastRunAt}):null,b=m===`failed`?d.failedAtIso?(0,X.jsx)(R,{iso:d.failedAtIso}):_:m===`up-to-date`?e?.state===`ok`&&_?_:v:null,x=e?.error??null,C=m===`waiting-for-agent`&&B(x)?x:null,T=m===`failed`&&!d.failedAtIso||m===`waiting-for-agent`&&!C?x:null,E=l.failure&&l.failure.recordAtPress===N(e)?pe(l.failure.cause,c):null;return(0,X.jsx)(D,{ids:[`R14.10`,`R14.12`,`R14.13`],children:(0,X.jsxs)(k,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{"data-focus-review":m,className:`space-y-2`,children:[(0,X.jsxs)(`p`,{role:`status`,className:o(`flex items-start gap-2.5 font-medium`,he[m]),children:[(0,X.jsx)(`span`,{className:`mt-0.5 flex`,children:$[m]()}),(0,X.jsx)(`span`,{className:`min-w-0`,children:me[m](c,b,C)})]}),m===`failed`&&v&&(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:A(c(`Your last reviewed view is from {time}.`),`time`,v)}),m===`waiting-for-agent`&&(0,X.jsx)(a,{asChild:!0,variant:`link`,size:`sm`,className:`h-auto px-0`,children:(0,X.jsxs)(`a`,{href:`https://docs.claude-mem.ai/configuration#my-work-refresh-models`,target:`_blank`,rel:`noopener noreferrer`,children:[c(`Configure My Work to use an API provider`),(0,X.jsx)(I,{"aria-hidden":`true`})]})}),u===`cloud`&&(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c(`claude-mem learns again on its own whenever new work is due, using the agent you are logged in to.`)})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[g&&(0,X.jsxs)(a,{variant:`outline`,onClick:()=>void l.start(N(e)),busy:l.pending,"aria-disabled":m===`updating`||void 0,busyLabel:c(`Reviewing…`),children:[(0,X.jsx)(P,{}),c(m===`failed`?`Try review again`:`Review now`)]}),u===`sample`&&(0,X.jsx)(M,{run:ee.progress,ids:[`R14.12`]}),T&&(0,X.jsx)(L,{cause:T}),d.nothingNew&&(0,X.jsx)(`span`,{role:`status`,className:`text-sm text-muted-foreground`,children:c(`Nothing new to review`)})]}),E&&(0,X.jsxs)(f,{variant:`attention`,role:`alert`,className:`py-2.5 text-sm`,children:[(0,X.jsx)(p,{className:`font-normal`,children:E.words}),E.details&&(0,X.jsx)(h,{children:(0,X.jsx)(F,{cause:E.details})})]}),(0,X.jsx)(_e,{run:r,readError:s}),n&&t&&(0,X.jsx)(D,{ids:[`R7.3`],children:(0,X.jsxs)(`div`,{className:`space-y-2 border-t pt-3`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:m===`failed`?S(c(`The last learning run that finished, {date}`),{date:y(t.lastRunAtIso,t.lastRunAt)}):(0,X.jsxs)(X.Fragment,{children:[c(`Last learning run`),` `,(0,X.jsx)(`span`,{className:`mono-number font-normal text-muted-foreground`,children:y(t.lastRunAtIso,t.lastRunAt)})]})}),(0,X.jsx)(ge,{learning:n,run:t,earlier:m===`failed`})]})})]})})}function ye(e,t,n){return n(e===`sample`?`Sample data: nothing here is read from a computer.`:t?`This page reads your cloud viewer, which your computers sync to.`:`This page reads the worker on this computer.`)}function be(){let{t:e}=i(),{sourceKind:t,refresh:n,lastRuns:r,rulesLearning:a,sharedState:o,goalsReadError:s}=T(),c=E(),u=t===`sample`,d=l(window.location.hostname),f=le(!u),p=u?null:G(o),m=u?``:[e(c.label),c.sync?e(c.sync.label):null,p?e(p.label):null].filter(Boolean).join(`. `);return(0,X.jsxs)(`div`,{className:`space-y-6 md:space-y-8`,children:[(0,X.jsx)(`p`,{className:`text-base text-muted-foreground md:text-lg`,children:ye(t,d,e)}),(0,X.jsxs)(te,{children:[(0,X.jsx)(ue,{version:f}),(0,X.jsx)(de,{})]}),(0,X.jsxs)(`section`,{className:`space-y-3 md:space-y-4`,children:[(0,X.jsx)(`h2`,{className:`text-section-title-phone md:text-section-title`,children:e(`Focus review`)}),(0,X.jsx)(ve,{refresh:n,run:r.progress,learning:a,goalsRun:r.goals,goalsReadError:s})]}),(0,X.jsx)(`span`,{role:`status`,className:`sr-only`,"data-sync-state":u?void 0:c.sync?.state,children:m})]})}export{be as MachineAndSync};