PageSourceSearch

https://www.app.openhelm.ai/assets/memory-view-CxW88llM.js

js openhelm.ai collected 2026-10-05 12:22:25 UTC 6,090 bytes, 1 lines download raw bytes

1import{b as l,j as e}from"./world-Csv-JtD3.js";import{E as q}from"./empty-state-dI1eHMpy.js";import{o as L,t as x,cN as d,k as B,fj as $,cZ as g,B as h,bA as p,aV as E,cE as A,eb as z,cQ as O}from"./index-oNVOm43g.js";import{P as U}from"./page-header-3FQ-ghNe.js";import{P as W,a as D}from"./plugin-required-dialog-CtXKUoS7.js";import"./plugin-icon-DaPHsHkl.js";const F=L((r,i)=>({memories:[],query:"",dropped:0,resolved:!1,error:null,loading:!1,writing:!1,async search(a,n){const s=n.trim();if(!a||!s){r({memories:[],query:"",dropped:0,error:null,resolved:!1});return}r({loading:!0,error:null,query:s});try{const o=await x.request("memories.search",{productId:a,query:s});r({memories:o.memories??[],dropped:o.dropped??0,resolved:!0,error:null,loading:!1})}catch(o){r({error:o instanceof Error?o.message:String(o),loading:!1})}},async remember(a,n){r({writing:!0});try{await x.request("memories.create",{productId:a,content:n});const{query:s}=i();r({writing:!1}),s&&await i().search(a,s)}catch(s){throw r({writing:!1}),d.error(`Could not remember that: ${s instanceof Error?s.message:String(s)}`),s}},async forget(a,n){r({writing:!0});try{await x.request("memories.delete",{productId:a,id:n}),r(s=>({memories:s.memories.filter(o=>o.id!==n),writing:!1}))}catch(s){throw r({writing:!1}),d.error(`Could not forget that: ${s instanceof Error?s.message:String(s)}`),s}},clear(){r({memories:[],query:"",dropped:0,resolved:!1,error:null})}}));function I({memory:r,productId:i}){const a=F(m=>m.forget),[n,s]=l.useState(!1),o=l.useCallback(async()=>{s(!0);try{await a(i,r.id),d.success("Forgotten. It will no longer be retrieved.")}catch{s(!1)}},[a,i,r.id]);return e.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/40 p-4",children:[e.jsx("p",{className:"text-sm leading-relaxed",children:r.summary}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[r.sourceName?e.jsx("span",{children:r.sourceName}):null,r.citationUrl?e.jsxs("a",{href:r.citationUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 hover:text-foreground",children:["Source ",e.jsx(z,{className:"size-3"})]}):null,r.freshness==="stale"?e.jsx("span",{className:"text-warning",children:"Source last refreshed a while ago"}):null,e.jsxs(h,{variant:"ghost",size:"sm",className:"ml-auto h-7 px-2 text-muted-foreground hover:text-destructive",onClick:o,disabled:n,children:[n?e.jsx(p,{className:"size-3 animate-spin"}):e.jsx(O,{className:"size-3"}),e.jsx("span",{className:"ml-1",children:"Forget"})]})]})]})}function G(){const{activeProjectId:r}=B(),i=$("memory"),{memories:a,query:n,dropped:s,resolved:o,error:m,loading:b,writing:f,search:j,remember:y,clear:w}=F(),[u,N]=l.useState(""),[c,v]=l.useState(""),[k,S]=l.useState(!1);l.useEffect(()=>{w(),N("")},[r,w]);const P=l.useCallback(t=>{t.preventDefault(),r&&j(r,u)},[r,u,j]),R=l.useCallback(async()=>{if(!(!r||!c.trim()))try{await y(r,c.trim()),v(""),d.success("Remembered. It is now part of this product's memory.")}catch{}},[r,c,y]),M=l.useCallback(async()=>{S(!0);try{const{url:t}=await x.request("plugins.vendorLoginUrl",{pluginId:"contextely",path:"memory"});window.open(t,"_blank","noopener,noreferrer")}catch(t){d.error(`Could not open Contextely: ${t instanceof Error?t.message:String(t)}`)}finally{S(!1)}},[]),C=e.jsx(U,{title:"Memory",icon:g,subtitle:"What this product knows, and what your agents read before every run."});return i?e.jsxs("div",{className:"flex h-full flex-col",children:[C,e.jsx(W,{lock:i,icon:g,blurb:"What this product has learned: facts, decisions and the sources behind them."}),e.jsx(D,{lock:i})]}):e.jsxs("div",{className:"flex h-full flex-col",children:[C,e.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto px-6 pb-8",children:[e.jsxs("form",{onSubmit:P,className:"flex gap-2",children:[e.jsx("input",{value:u,onChange:t=>N(t.target.value),placeholder:"Ask what this product knows…","aria-label":"Search memory",className:"flex-1 rounded-md border border-border/60 bg-background px-3 py-2 text-sm"}),e.jsxs(h,{type:"submit",disabled:b||!u.trim(),children:[b?e.jsx(p,{className:"size-4 animate-spin"}):e.jsx(E,{className:"size-4"}),e.jsx("span",{className:"ml-2",children:"Search"})]})]}),m?e.jsx(A,{message:m}):null,s>0?e.jsxs("p",{className:"text-xs text-warning",children:[s," ",s===1?"result":"results"," could not be read and ",s===1?"is":"are"," not shown."]}):null,a.length>0?e.jsx("div",{className:"space-y-3",children:a.map(t=>e.jsx(I,{memory:t,productId:r??""},t.id))}):o&&n?e.jsx(q,{icon:E,title:"Nothing matched that",description:`This product's memory holds nothing about “${n}”.`}):e.jsx(q,{icon:g,title:"Search what this product remembers",description:"Memory is a retrieval store rather than a list, so ask it a question and it returns what it knows."}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-border/60 p-4",children:[e.jsx("label",{htmlFor:"remember",className:"text-sm font-medium",children:"Remember something"}),e.jsx("textarea",{id:"remember",value:c,onChange:t=>v(t.target.value),rows:3,placeholder:"One fact, in a sentence or tw
1o.",className:"w-full rounded-md border border-border/60 bg-background px-3 py-2 text-sm"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Stored in Contextely, and read by every run of this product."}),e.jsxs(h,{onClick:R,disabled:f||!c.trim(),children:[f?e.jsx(p,{className:"size-4 animate-spin"}):null,e.jsx("span",{className:f?"ml-2":"",children:"Remember"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-border/60 pt-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Memory lives in your Contextely account, where you can browse and organise it in full."}),e.jsxs(h,{variant:"outline",size:"sm",onClick:M,disabled:k,children:[k?e.jsx(p,{className:"size-3 animate-spin"}):e.jsx(z,{className:"size-3"}),e.jsx("span",{className:"ml-2",children:"Open Contextely"})]})]})]})]})}export{G as MemoryView};

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.