@bigduu/lotus-next 2026.11.8 → 2026.11.9
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/dist/asset-manifest.json +33 -33
- package/dist/assets/{AgentService-CbiK9l2V.js → AgentService-CsJ7WhuL.js} +1 -1
- package/dist/assets/{ConversationClearDialogContent-CnRp5OQv.js → ConversationClearDialogContent-CsrHs1Ze.js} +1 -1
- package/dist/assets/{JianduProjectMemories-CNc84eRQ.js → JianduProjectMemories-DRs5HQZd.js} +1 -1
- package/dist/assets/{Root-CHqHo7iU.js → Root-BI46na22.js} +4 -4
- package/dist/assets/{RunDiagnosticsDialogContent-DMY7ACIw.js → RunDiagnosticsDialogContent-D0z0OJGE.js} +1 -1
- package/dist/assets/{Settings-BbbU_Njx.js → Settings-BfIYlkg-.js} +3 -3
- package/dist/assets/{SidebarProjectDrag-BpmjjnNq.js → SidebarProjectDrag-voL3KpvK.js} +1 -1
- package/dist/assets/{SupervisorManagedSessions-nyTO2q-m.js → SupervisorManagedSessions-OHqd8Wiu.js} +1 -1
- package/dist/assets/{appStore-IHwYR1pI.js → appStore-DtSQC8LZ.js} +3 -3
- package/dist/assets/{command-C0HpmBO7.js → command-DGPzCE7j.js} +2 -2
- package/dist/assets/{index-DJxkEcWl.js → index-D7_pjoEW.js} +3 -3
- package/dist/assets/{managedSessions-BzJX94L7.js → managedSessions-BGFiZPYJ.js} +1 -1
- package/dist/assets/{managedSessions-s5CyZnF1.js → managedSessions-D4u69IPf.js} +1 -1
- package/dist/bundle-ownership.json +13 -13
- package/dist/index.html +1 -1
- package/dist/lotus-next-manifest.json +34 -34
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{u as r}from"./ui-C2RfJtHm.js";import{t as i}from"./input-DWysC80E.js";import{a,i as o,n as s,r as c,s as l,t as ee}from"./select-CBtmzEvB.js";import{i as te}from"./appStore-IHwYR1pI.js";import{t as u}from"./button-Cfb4l-V4.js";import{i as ne,n as re,r as ie,t as ae}from"./responsive-dialog-fYAouKrw.js";import{t as oe}from"./textarea-BKzYyWL5.js";import{a as d,c as se,i as ce,l as le,n as ue,o as de,s as fe,t as pe,u as f}from"./jianduMemoryApi-Bg3hZQEs.js";var p=e(t(),1),m=n(),h={title:``,type:`project`,content:``,tags:``,keywords:``,entities:``,granularity:``},g=e=>{if(!(e instanceof d))return`unavailable`;switch(e.code){case`invalid_input`:return`invalid`;case`context_unavailable`:return`context`;case`access_denied`:return`denied`;case`action_rejected`:return`rejected`;case`malformed_response`:return`malformed`;case`request_failed`:return`unavailable`}},_=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),me=e=>({title:e.title,type:e.type,content:e.content,tags:_(e.tags),keywords:_(e.keywords),entities:_(e.entities),...e.granularity?{granularity:e.granularity}:{}}),he=(e,t)=>{let n=new Map(e.map(e=>[e.id,e]));return t.forEach(e=>n.set(e.id,e)),[...n.values()]};function v({api:e=fe}){let{t}=r(),n=te(e=>e.currentSessionId),d=(0,p.useRef)(n);d.current=n;let _=(0,p.useRef)(0),v=(0,p.useRef)(0),y=(0,p.useRef)(0),b=(0,p.useRef)(0),x=(0,p.useRef)(0),[ge,_e]=(0,p.useState)(0),[S,ve]=(0,p.useState)(null),[ye,C]=(0,p.useState)(!1),[be,w]=(0,p.useState)(null),[xe,T]=(0,p.useState)(``),[E,Se]=(0,p.useState)(``),[Ce,we]=(0,p.useState)(`active`),[D,Te]=(0,p.useState)(`active`),[Ee,O]=(0,p.useState)([]),[k,A]=(0,p.useState)(null),[j,M]=(0,p.useState)(!1),[De,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(null),[Oe,I]=(0,p.useState)(null),[ke,L]=(0,p.useState)(null),[Ae,R]=(0,p.useState)(!1),[z,B]=(0,p.useState)(h),[V,H]=(0,p.useState)(null),[je,U]=(0,p.useState)(!1),[Me,W]=(0,p.useState)(null),[G,K]=(0,p.useState)(null),[Ne,q]=(0,p.useState)(null),[Pe,J]=(0,p.useState)(null),[Fe,Y]=(0,p.useState)(null),X=(0,p.useCallback)(async(t,n,r,i,a,o)=>{let s=++v.current;M(!0),N(null);try{let c=await e.queryProjectMemories(t,{query:n,filters:{status:[r]},...i?{cursor:i}:{}});return _.current!==o||v.current!==s?`stale`:(O(e=>a?he(e,c.items):c.items),A(c),`ok`)}catch(e){return _.current!==o||v.current!==s?`stale`:(N(g(e)),a||(O([]),A(null)),`failed`)}finally{_.current===o&&v.current===s&&M(!1)}},[e]),Ie=(0,p.useCallback)(e=>{let t=_.current;t===e&&(_.current=t+1)},[]);(0,p.useEffect)(()=>{let t=++_.current;if(++v.current,++y.current,++b.current,++x.current,ve(null),w(null),C(!!n),T(``),Se(``),we(`active`),Te(`active`),O([]),A(null),N(null),M(!1),F(null),I(null),L(null),R(!1),B(h),H(null),U(!1),W(null),K(null),q(null),J(null),Y(null),!n){w(`context`);return}return e.resolveProjectContext(n).then(e=>{_.current!==t||d.current!==n||(ve(e),C(!1),X(e,``,`active`,void 0,!1,t))}).catch(e=>{_.current!==t||d.current!==n||(C(!1),w(g(e)))}),()=>Ie(t)},[e,n,Ie,X,ge]);let Le=(0,p.useCallback)(e=>{++_.current,++v.current,++y.current,++b.current,++x.current,ve(null),T(``),Se(``),we(`active`),Te(`active`),O([]),A(null),M(!1),N(null),F(null),I(null),L(null),R(!1),B(h),H(null),U(!1),W(null),K(null),q(null),J(null),Y(null),w(e),C(!1)},[]),Re=(0,p.useCallback)(async(t,n)=>{let r=d.current;if(!r||_.current!==n)return null;try{let i=await e.resolveProjectContext(r);return _.current!==n||d.current!==r?null:le(t,i)?i:(Le(`context`),null)}catch(e){return _.current===n&&Le(g(e)),null}},[e,Le]),ze=()=>{if(!S)return;let e=xe.trim(),t=Ce;Se(e),Te(t),Y(null),X(S,e,t,void 0,!1,_.current)},Be=async t=>{if(!S)return;let n=++y.current,r=_.current;F(null),L(null),I(t.id);try{let i=await e.getProjectMemory(S,t.id);if(_.current!==r||y.current!==n)return;F(i)}catch(e){_.current===r&&y.current===n&&L(g(e))}finally{_.current===r&&y.current===n&&I(null)}},Ve=()=>{++y.current,F(null),L(null),I(null),q(null),J(null)},He=(0,p.useMemo)(()=>JSON.stringify(z),[z]),Z=(e,t)=>{++b.current,B(n=>({...n,[e]:t})),H(null),U(!1),W(null)},Ue=()=>{B(h),H(null),W(null),R(!0)},We=()=>{G!==`create`&&(++b.current,R(!1),B(h),H(null),W(null))},Ge=async()=>{if(!S||je||G)return;let t=me(z);try{se(t)}catch(e){W(g(e));return}let n=He,r=++b.current,i=_.current;U(!0),H(null),W(null);try{let a=await e.queryProjectMemories(S,{query:``,limit:1});if(_.current!==i||b.current!==r)return;let o=a.matchedCount===0?a:await e.queryProjectMemories(S,{query:de(t),limit:5});if(_.current!==i||b.current!==r)return;H({fingerprint:n,items:o.items,truncated:o.truncated})}catch(e){_.current===i&&b.current===r&&W(g(e))}finally{_.current===i&&b.current===r&&U(!1)}},Ke=async()=>{if(!S||G||!V||V.fingerprint!==He)return;let t=me(z);try{se(t)}catch(e){W(g(e));return}let n=_.current,r=++x.current;K(`create`),W(null);let i=await Re(S,n);if(!i||_.current!==n||x.current!==r){x.current===r&&K(null);return}try{let a=await e.createProjectMemory(i,t);if(_.current!==n||x.current!==r)return;R(!1),H(null),Y({kind:`created`,title:a.title}),await X(i,E,D,void 0,!1,n)===`failed`&&x.current===r&&Y({kind:`createdRefreshFailed`,title:a.title})}catch(e){_.current===n&&x.current===r&&W(g(e))}finally{_.current===n&&x.current===r&&K(null)}},qe=async()=>{let t=Ne;if(!S||!t||G)return;let n=_.current,r=++x.current;K(`archive`),J(null);let i=await Re(S,n);if(!i||_.current!==n||x.current!==r){x.current===r&&K(null);return}try{if(await e.archiveProjectMemory(i,t.id),_.current!==n||x.current!==r)return;q(null),Ve(),Y({kind:`archived`,title:t.title}),await X(i,E,D,void 0,!1,n)===`failed`&&x.current===r&&Y({kind:`archivedRefreshFailed`,title:t.title})}catch(e){_.current===n&&x.current===r&&J(g(e))}finally{_.current===n&&x.current===r&&K(null)}},Q=e=>t(`settings.jiandu.errors.${e}`),Je=e=>t(`settings.jiandu.types.${e}`),$=e=>t(`settings.jiandu.statuses.${e}`);return(0,m.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4`,children:[(0,m.jsx)(`header`,{className:`space-y-1`,children:(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h2`,{className:`text-lg font-semibold`,children:t(`settings.jiandu.title`)}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings.jiandu.description`)})]}),(0,m.jsx)(u,{onClick:Ue,disabled:!S||ye,children:t(`settings.jiandu.create.open`)})]})}),(0,m.jsxs)(`section`,{className:`rounded-lg border p-3`,"aria-label":t(`settings.jiandu.context.label`),children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:t(`settings.jiandu.context.label`)}),ye?(0,m.jsx)(`p`,{className:`mt-1 text-sm`,children:t(`settings.jiandu.context.loading`)}):S?(0,m.jsxs)(`dl`,{className:`mt-2 grid gap-2 text-sm sm:grid-cols-2`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.context.session`)}),(0,m.jsx)(`dd`,{className:`break-words font-medium`,children:S.activeSessionTitle})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.context.project`)}),(0,m.jsx)(`dd`,{className:`break-all font-mono text-xs`,children:S.projectId})]}),S.activeSessionId===S.authoritySessionId?null:(0,m.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,m.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.context.rootSession`)}),(0,m.jsx)(`dd`,{children:S.authoritySessionTitle})]})]}):(0,m.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(be??`context`)}),n?(0,m.jsx)(u,{variant:`outline`,size:`sm`,onClick:()=>_e(e=>e+1),children:t(`settings.jiandu.context.retry`)}):null]})]}),Fe?(0,m.jsx)(`p`,{role:`status`,className:`rounded-lg border border-primary/30 bg-primary/5 p-3 text-sm`,children:t(`settings.jiandu.notices.${Fe.kind}`,{title:Fe.title})}):null,S?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:e=>{e.preventDefault(),ze()},children:[(0,m.jsx)(i,{"aria-label":t(`settings.jiandu.search.label`),value:xe,maxLength:ue.queryChars,onChange:e=>T(e.target.value),placeholder:t(`settings.jiandu.search.placeholder`)}),(0,m.jsxs)(ee,{value:Ce,disabled:j,onValueChange:e=>we(e),children:[(0,m.jsx)(o,{className:`w-full sm:w-36`,"aria-label":t(`settings.jiandu.search.statusLabel`),children:(0,m.jsx)(a,{})}),(0,m.jsxs)(s,{className:`z-[150]`,children:[(0,m.jsx)(c,{value:`active`,children:$(`active`)}),(0,m.jsx)(c,{value:`archived`,children:$(`archived`)})]})]}),(0,m.jsx)(u,{type:`submit`,disabled:j,children:t(`settings.jiandu.search.action`)}),(0,m.jsx)(u,{type:`button`,variant:`outline`,disabled:j,onClick:()=>void X(S,E,D,void 0,!1,_.current),children:t(`settings.jiandu.search.refresh`)})]}),De?(0,m.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-destructive/40 p-3 text-sm text-destructive`,children:Q(De)}):null,k?(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,m.jsx)(`span`,{children:t(`settings.jiandu.list.count`,{visible:Ee.length,matched:k.matchedCount})}),k.truncated?(0,m.jsx)(`span`,{children:t(`settings.jiandu.list.truncated`)}):null,k.remainingCount>0?(0,m.jsx)(`span`,{children:t(`settings.jiandu.list.remaining`,{count:k.remainingCount})}):null]}):null,Ee.length>0?(0,m.jsx)(`ul`,{className:`space-y-2`,"aria-label":t(`settings.jiandu.list.label`),children:Ee.map(e=>(0,m.jsxs)(`li`,{className:`rounded-lg border p-3`,children:[(0,m.jsx)(`button`,{type:`button`,className:`max-w-full break-words text-left text-sm font-semibold hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,disabled:Oe===e.id,onClick:()=>void Be(e),children:e.title}),(0,m.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,m.jsx)(l,{variant:`outline`,children:Je(e.type)}),(0,m.jsx)(l,{variant:e.status===`archived`?`secondary`:`outline`,children:$(e.status)}),e.granularity?(0,m.jsx)(l,{variant:`outline`,children:e.granularity}):null]}),(0,m.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-muted-foreground`,children:e.summary})]},e.id))}):k&&!j?(0,m.jsx)(`p`,{className:`rounded-lg border p-4 text-sm text-muted-foreground`,children:t(`settings.jiandu.list.empty`)}):null,j?(0,m.jsx)(`p`,{role:`status`,children:t(`settings.jiandu.list.loading`)}):null,k?.nextCursor?(0,m.jsx)(u,{variant:`outline`,className:`w-full`,disabled:j,onClick:()=>void X(S,E,D,k.nextCursor,!0,_.current),children:t(`settings.jiandu.list.more`)}):null]}):null,(0,m.jsx)(ae,{open:!!(P||Oe||ke),onOpenChange:e=>e?null:Ve(),children:(0,m.jsxs)(re,{showCloseButton:!1,className:`gap-4 p-5 sm:max-w-2xl`,children:[(0,m.jsx)(ne,{children:P?.title??t(`settings.jiandu.detail.title`)}),Oe?(0,m.jsx)(`p`,{role:`status`,children:t(`settings.jiandu.detail.loading`)}):null,ke?(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(ke)}):null,P?(0,m.jsxs)(`div`,{className:`min-h-0 space-y-3 overflow-y-auto`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,m.jsx)(l,{variant:`outline`,children:Je(P.type)}),(0,m.jsx)(l,{variant:P.status===`archived`?`secondary`:`outline`,children:$(P.status)})]}),P.bodyTruncated||P.retrievalMetadataTruncated?(0,m.jsx)(`p`,{role:`status`,className:`text-xs text-amber-600 dark:text-amber-400`,children:P.bodyTruncated?t(`settings.jiandu.detail.bodyTruncated`):t(`settings.jiandu.detail.metadataTruncated`)}):null,(0,m.jsx)(`pre`,{className:`max-h-[50dvh] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 font-sans text-sm`,children:P.body})]}):null,(0,m.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[P&&P.status!==`archived`?(0,m.jsx)(u,{variant:`destructive`,onClick:()=>{J(null),q(P)},children:t(`settings.jiandu.archive.open`)}):null,(0,m.jsx)(u,{variant:`outline`,onClick:Ve,children:t(`settings.jiandu.detail.close`)})]})]})}),(0,m.jsx)(ae,{open:Ae,onOpenChange:e=>e?null:We(),children:(0,m.jsxs)(re,{showCloseButton:!1,dismissable:G!==`create`,className:`gap-4 p-5 sm:max-w-2xl`,children:[(0,m.jsx)(ne,{children:t(`settings.jiandu.create.title`)}),(0,m.jsx)(ie,{children:t(`settings.jiandu.create.description`)}),(0,m.jsxs)(`div`,{className:`min-h-0 space-y-3 overflow-y-auto pr-1`,children:[(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{htmlFor:`jiandu-title`,children:t(`settings.jiandu.create.titleLabel`)}),(0,m.jsx)(i,{id:`jiandu-title`,value:z.title,maxLength:ue.titleChars,disabled:!!G,onChange:e=>Z(`title`,e.target.value)})]}),(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{children:t(`settings.jiandu.create.typeLabel`)}),(0,m.jsxs)(ee,{value:z.type,disabled:!!G,onValueChange:e=>Z(`type`,e),children:[(0,m.jsx)(o,{className:`w-full`,"aria-label":t(`settings.jiandu.create.typeLabel`),children:(0,m.jsx)(a,{})}),(0,m.jsx)(s,{className:`z-[150]`,children:ce.map(e=>(0,m.jsx)(c,{value:e,children:Je(e)},e))})]})]}),(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{htmlFor:`jiandu-body`,children:t(`settings.jiandu.create.bodyLabel`)}),(0,m.jsx)(oe,{id:`jiandu-body`,rows:7,value:z.content,maxLength:ue.bodyChars,disabled:!!G,onChange:e=>Z(`content`,e.target.value)})]}),(0,m.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`tags`,`keywords`,`entities`].map(e=>(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{htmlFor:`jiandu-${e}`,children:t(`settings.jiandu.create.${e}Label`)}),(0,m.jsx)(i,{id:`jiandu-${e}`,value:z[e],disabled:!!G,onChange:t=>Z(e,t.target.value),placeholder:t(`settings.jiandu.create.csvHint`)})]},e)),(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{children:t(`settings.jiandu.create.granularityLabel`)}),(0,m.jsxs)(ee,{value:z.granularity||`none`,disabled:!!G,onValueChange:e=>Z(`granularity`,e===`none`?``:e),children:[(0,m.jsx)(o,{className:`w-full`,"aria-label":t(`settings.jiandu.create.granularityLabel`),children:(0,m.jsx)(a,{})}),(0,m.jsxs)(s,{className:`z-[150]`,children:[(0,m.jsx)(c,{value:`none`,children:t(`settings.jiandu.create.noGranularity`)}),pe.map(e=>(0,m.jsx)(c,{value:e,children:e},e))]})]})]})]}),Me?(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(Me)}):null,V?(0,m.jsxs)(`section`,{className:`rounded-lg border p-3`,"aria-label":t(`settings.jiandu.create.matchesLabel`),children:[(0,m.jsx)(`h3`,{className:`text-sm font-medium`,children:V.items.length>0?t(`settings.jiandu.create.matches`):t(`settings.jiandu.create.noMatches`)}),V.items.length>0?(0,m.jsx)(`ul`,{className:`mt-2 space-y-1 text-sm`,children:V.items.map(e=>(0,m.jsxs)(`li`,{children:[e.title,` · `,$(e.status)]},e.id))}):null,V.truncated?(0,m.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:t(`settings.jiandu.create.matchesTruncated`)}):null]}):null]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,m.jsx)(u,{variant:`outline`,disabled:G===`create`,onClick:We,children:t(`settings.jiandu.create.close`)}),(0,m.jsx)(u,{variant:`secondary`,disabled:je||!!G,onClick:()=>void Ge(),children:t(je?`settings.jiandu.create.lookingUp`:`settings.jiandu.create.lookup`)}),(0,m.jsx)(u,{disabled:G===`create`||!V||V.fingerprint!==He,onClick:()=>void Ke(),children:t(G===`create`?`settings.jiandu.create.creating`:`settings.jiandu.create.confirm`)})]})]})}),(0,m.jsx)(ae,{open:!!Ne,onOpenChange:e=>{!e&&G!==`archive`&&(q(null),J(null))},children:(0,m.jsxs)(re,{showCloseButton:!1,dismissable:G!==`archive`,className:`gap-4 p-5`,children:[(0,m.jsx)(ne,{children:t(`settings.jiandu.archive.title`,{title:Ne?.title??``})}),(0,m.jsx)(ie,{children:t(`settings.jiandu.archive.description`)}),Pe?(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(Pe)}):null,(0,m.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,m.jsx)(u,{variant:`outline`,disabled:G===`archive`,onClick:()=>{q(null),J(null)},children:t(`settings.jiandu.archive.cancel`)}),(0,m.jsx)(u,{variant:`destructive`,disabled:G===`archive`,onClick:()=>void qe(),children:t(G===`archive`?`settings.jiandu.archive.archiving`:`settings.jiandu.archive.confirm`)})]})]})})]})}export{v as JianduProjectMemories};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{u as r}from"./ui-C2RfJtHm.js";import{t as i}from"./input-DWysC80E.js";import{a,i as o,n as s,r as c,s as l,t as ee}from"./select-CBtmzEvB.js";import{i as te}from"./appStore-DtSQC8LZ.js";import{t as u}from"./button-Cfb4l-V4.js";import{i as ne,n as re,r as ie,t as ae}from"./responsive-dialog-fYAouKrw.js";import{t as oe}from"./textarea-BKzYyWL5.js";import{a as d,c as se,i as ce,l as le,n as ue,o as de,s as fe,t as pe,u as f}from"./jianduMemoryApi-Bg3hZQEs.js";var p=e(t(),1),m=n(),h={title:``,type:`project`,content:``,tags:``,keywords:``,entities:``,granularity:``},g=e=>{if(!(e instanceof d))return`unavailable`;switch(e.code){case`invalid_input`:return`invalid`;case`context_unavailable`:return`context`;case`access_denied`:return`denied`;case`action_rejected`:return`rejected`;case`malformed_response`:return`malformed`;case`request_failed`:return`unavailable`}},_=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),me=e=>({title:e.title,type:e.type,content:e.content,tags:_(e.tags),keywords:_(e.keywords),entities:_(e.entities),...e.granularity?{granularity:e.granularity}:{}}),he=(e,t)=>{let n=new Map(e.map(e=>[e.id,e]));return t.forEach(e=>n.set(e.id,e)),[...n.values()]};function v({api:e=fe}){let{t}=r(),n=te(e=>e.currentSessionId),d=(0,p.useRef)(n);d.current=n;let _=(0,p.useRef)(0),v=(0,p.useRef)(0),y=(0,p.useRef)(0),b=(0,p.useRef)(0),x=(0,p.useRef)(0),[ge,_e]=(0,p.useState)(0),[S,ve]=(0,p.useState)(null),[ye,C]=(0,p.useState)(!1),[be,w]=(0,p.useState)(null),[xe,T]=(0,p.useState)(``),[E,Se]=(0,p.useState)(``),[Ce,we]=(0,p.useState)(`active`),[D,Te]=(0,p.useState)(`active`),[Ee,O]=(0,p.useState)([]),[k,A]=(0,p.useState)(null),[j,M]=(0,p.useState)(!1),[De,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(null),[Oe,I]=(0,p.useState)(null),[ke,L]=(0,p.useState)(null),[Ae,R]=(0,p.useState)(!1),[z,B]=(0,p.useState)(h),[V,H]=(0,p.useState)(null),[je,U]=(0,p.useState)(!1),[Me,W]=(0,p.useState)(null),[G,K]=(0,p.useState)(null),[Ne,q]=(0,p.useState)(null),[Pe,J]=(0,p.useState)(null),[Fe,Y]=(0,p.useState)(null),X=(0,p.useCallback)(async(t,n,r,i,a,o)=>{let s=++v.current;M(!0),N(null);try{let c=await e.queryProjectMemories(t,{query:n,filters:{status:[r]},...i?{cursor:i}:{}});return _.current!==o||v.current!==s?`stale`:(O(e=>a?he(e,c.items):c.items),A(c),`ok`)}catch(e){return _.current!==o||v.current!==s?`stale`:(N(g(e)),a||(O([]),A(null)),`failed`)}finally{_.current===o&&v.current===s&&M(!1)}},[e]),Ie=(0,p.useCallback)(e=>{let t=_.current;t===e&&(_.current=t+1)},[]);(0,p.useEffect)(()=>{let t=++_.current;if(++v.current,++y.current,++b.current,++x.current,ve(null),w(null),C(!!n),T(``),Se(``),we(`active`),Te(`active`),O([]),A(null),N(null),M(!1),F(null),I(null),L(null),R(!1),B(h),H(null),U(!1),W(null),K(null),q(null),J(null),Y(null),!n){w(`context`);return}return e.resolveProjectContext(n).then(e=>{_.current!==t||d.current!==n||(ve(e),C(!1),X(e,``,`active`,void 0,!1,t))}).catch(e=>{_.current!==t||d.current!==n||(C(!1),w(g(e)))}),()=>Ie(t)},[e,n,Ie,X,ge]);let Le=(0,p.useCallback)(e=>{++_.current,++v.current,++y.current,++b.current,++x.current,ve(null),T(``),Se(``),we(`active`),Te(`active`),O([]),A(null),M(!1),N(null),F(null),I(null),L(null),R(!1),B(h),H(null),U(!1),W(null),K(null),q(null),J(null),Y(null),w(e),C(!1)},[]),Re=(0,p.useCallback)(async(t,n)=>{let r=d.current;if(!r||_.current!==n)return null;try{let i=await e.resolveProjectContext(r);return _.current!==n||d.current!==r?null:le(t,i)?i:(Le(`context`),null)}catch(e){return _.current===n&&Le(g(e)),null}},[e,Le]),ze=()=>{if(!S)return;let e=xe.trim(),t=Ce;Se(e),Te(t),Y(null),X(S,e,t,void 0,!1,_.current)},Be=async t=>{if(!S)return;let n=++y.current,r=_.current;F(null),L(null),I(t.id);try{let i=await e.getProjectMemory(S,t.id);if(_.current!==r||y.current!==n)return;F(i)}catch(e){_.current===r&&y.current===n&&L(g(e))}finally{_.current===r&&y.current===n&&I(null)}},Ve=()=>{++y.current,F(null),L(null),I(null),q(null),J(null)},He=(0,p.useMemo)(()=>JSON.stringify(z),[z]),Z=(e,t)=>{++b.current,B(n=>({...n,[e]:t})),H(null),U(!1),W(null)},Ue=()=>{B(h),H(null),W(null),R(!0)},We=()=>{G!==`create`&&(++b.current,R(!1),B(h),H(null),W(null))},Ge=async()=>{if(!S||je||G)return;let t=me(z);try{se(t)}catch(e){W(g(e));return}let n=He,r=++b.current,i=_.current;U(!0),H(null),W(null);try{let a=await e.queryProjectMemories(S,{query:``,limit:1});if(_.current!==i||b.current!==r)return;let o=a.matchedCount===0?a:await e.queryProjectMemories(S,{query:de(t),limit:5});if(_.current!==i||b.current!==r)return;H({fingerprint:n,items:o.items,truncated:o.truncated})}catch(e){_.current===i&&b.current===r&&W(g(e))}finally{_.current===i&&b.current===r&&U(!1)}},Ke=async()=>{if(!S||G||!V||V.fingerprint!==He)return;let t=me(z);try{se(t)}catch(e){W(g(e));return}let n=_.current,r=++x.current;K(`create`),W(null);let i=await Re(S,n);if(!i||_.current!==n||x.current!==r){x.current===r&&K(null);return}try{let a=await e.createProjectMemory(i,t);if(_.current!==n||x.current!==r)return;R(!1),H(null),Y({kind:`created`,title:a.title}),await X(i,E,D,void 0,!1,n)===`failed`&&x.current===r&&Y({kind:`createdRefreshFailed`,title:a.title})}catch(e){_.current===n&&x.current===r&&W(g(e))}finally{_.current===n&&x.current===r&&K(null)}},qe=async()=>{let t=Ne;if(!S||!t||G)return;let n=_.current,r=++x.current;K(`archive`),J(null);let i=await Re(S,n);if(!i||_.current!==n||x.current!==r){x.current===r&&K(null);return}try{if(await e.archiveProjectMemory(i,t.id),_.current!==n||x.current!==r)return;q(null),Ve(),Y({kind:`archived`,title:t.title}),await X(i,E,D,void 0,!1,n)===`failed`&&x.current===r&&Y({kind:`archivedRefreshFailed`,title:t.title})}catch(e){_.current===n&&x.current===r&&J(g(e))}finally{_.current===n&&x.current===r&&K(null)}},Q=e=>t(`settings.jiandu.errors.${e}`),Je=e=>t(`settings.jiandu.types.${e}`),$=e=>t(`settings.jiandu.statuses.${e}`);return(0,m.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4`,children:[(0,m.jsx)(`header`,{className:`space-y-1`,children:(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h2`,{className:`text-lg font-semibold`,children:t(`settings.jiandu.title`)}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings.jiandu.description`)})]}),(0,m.jsx)(u,{onClick:Ue,disabled:!S||ye,children:t(`settings.jiandu.create.open`)})]})}),(0,m.jsxs)(`section`,{className:`rounded-lg border p-3`,"aria-label":t(`settings.jiandu.context.label`),children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:t(`settings.jiandu.context.label`)}),ye?(0,m.jsx)(`p`,{className:`mt-1 text-sm`,children:t(`settings.jiandu.context.loading`)}):S?(0,m.jsxs)(`dl`,{className:`mt-2 grid gap-2 text-sm sm:grid-cols-2`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.context.session`)}),(0,m.jsx)(`dd`,{className:`break-words font-medium`,children:S.activeSessionTitle})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.context.project`)}),(0,m.jsx)(`dd`,{className:`break-all font-mono text-xs`,children:S.projectId})]}),S.activeSessionId===S.authoritySessionId?null:(0,m.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,m.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.context.rootSession`)}),(0,m.jsx)(`dd`,{children:S.authoritySessionTitle})]})]}):(0,m.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(be??`context`)}),n?(0,m.jsx)(u,{variant:`outline`,size:`sm`,onClick:()=>_e(e=>e+1),children:t(`settings.jiandu.context.retry`)}):null]})]}),Fe?(0,m.jsx)(`p`,{role:`status`,className:`rounded-lg border border-primary/30 bg-primary/5 p-3 text-sm`,children:t(`settings.jiandu.notices.${Fe.kind}`,{title:Fe.title})}):null,S?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:e=>{e.preventDefault(),ze()},children:[(0,m.jsx)(i,{"aria-label":t(`settings.jiandu.search.label`),value:xe,maxLength:ue.queryChars,onChange:e=>T(e.target.value),placeholder:t(`settings.jiandu.search.placeholder`)}),(0,m.jsxs)(ee,{value:Ce,disabled:j,onValueChange:e=>we(e),children:[(0,m.jsx)(o,{className:`w-full sm:w-36`,"aria-label":t(`settings.jiandu.search.statusLabel`),children:(0,m.jsx)(a,{})}),(0,m.jsxs)(s,{className:`z-[150]`,children:[(0,m.jsx)(c,{value:`active`,children:$(`active`)}),(0,m.jsx)(c,{value:`archived`,children:$(`archived`)})]})]}),(0,m.jsx)(u,{type:`submit`,disabled:j,children:t(`settings.jiandu.search.action`)}),(0,m.jsx)(u,{type:`button`,variant:`outline`,disabled:j,onClick:()=>void X(S,E,D,void 0,!1,_.current),children:t(`settings.jiandu.search.refresh`)})]}),De?(0,m.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-destructive/40 p-3 text-sm text-destructive`,children:Q(De)}):null,k?(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,m.jsx)(`span`,{children:t(`settings.jiandu.list.count`,{visible:Ee.length,matched:k.matchedCount})}),k.truncated?(0,m.jsx)(`span`,{children:t(`settings.jiandu.list.truncated`)}):null,k.remainingCount>0?(0,m.jsx)(`span`,{children:t(`settings.jiandu.list.remaining`,{count:k.remainingCount})}):null]}):null,Ee.length>0?(0,m.jsx)(`ul`,{className:`space-y-2`,"aria-label":t(`settings.jiandu.list.label`),children:Ee.map(e=>(0,m.jsxs)(`li`,{className:`rounded-lg border p-3`,children:[(0,m.jsx)(`button`,{type:`button`,className:`max-w-full break-words text-left text-sm font-semibold hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,disabled:Oe===e.id,onClick:()=>void Be(e),children:e.title}),(0,m.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,m.jsx)(l,{variant:`outline`,children:Je(e.type)}),(0,m.jsx)(l,{variant:e.status===`archived`?`secondary`:`outline`,children:$(e.status)}),e.granularity?(0,m.jsx)(l,{variant:`outline`,children:e.granularity}):null]}),(0,m.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-muted-foreground`,children:e.summary})]},e.id))}):k&&!j?(0,m.jsx)(`p`,{className:`rounded-lg border p-4 text-sm text-muted-foreground`,children:t(`settings.jiandu.list.empty`)}):null,j?(0,m.jsx)(`p`,{role:`status`,children:t(`settings.jiandu.list.loading`)}):null,k?.nextCursor?(0,m.jsx)(u,{variant:`outline`,className:`w-full`,disabled:j,onClick:()=>void X(S,E,D,k.nextCursor,!0,_.current),children:t(`settings.jiandu.list.more`)}):null]}):null,(0,m.jsx)(ae,{open:!!(P||Oe||ke),onOpenChange:e=>e?null:Ve(),children:(0,m.jsxs)(re,{showCloseButton:!1,className:`gap-4 p-5 sm:max-w-2xl`,children:[(0,m.jsx)(ne,{children:P?.title??t(`settings.jiandu.detail.title`)}),Oe?(0,m.jsx)(`p`,{role:`status`,children:t(`settings.jiandu.detail.loading`)}):null,ke?(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(ke)}):null,P?(0,m.jsxs)(`div`,{className:`min-h-0 space-y-3 overflow-y-auto`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,m.jsx)(l,{variant:`outline`,children:Je(P.type)}),(0,m.jsx)(l,{variant:P.status===`archived`?`secondary`:`outline`,children:$(P.status)})]}),P.bodyTruncated||P.retrievalMetadataTruncated?(0,m.jsx)(`p`,{role:`status`,className:`text-xs text-amber-600 dark:text-amber-400`,children:P.bodyTruncated?t(`settings.jiandu.detail.bodyTruncated`):t(`settings.jiandu.detail.metadataTruncated`)}):null,(0,m.jsx)(`pre`,{className:`max-h-[50dvh] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 font-sans text-sm`,children:P.body})]}):null,(0,m.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[P&&P.status!==`archived`?(0,m.jsx)(u,{variant:`destructive`,onClick:()=>{J(null),q(P)},children:t(`settings.jiandu.archive.open`)}):null,(0,m.jsx)(u,{variant:`outline`,onClick:Ve,children:t(`settings.jiandu.detail.close`)})]})]})}),(0,m.jsx)(ae,{open:Ae,onOpenChange:e=>e?null:We(),children:(0,m.jsxs)(re,{showCloseButton:!1,dismissable:G!==`create`,className:`gap-4 p-5 sm:max-w-2xl`,children:[(0,m.jsx)(ne,{children:t(`settings.jiandu.create.title`)}),(0,m.jsx)(ie,{children:t(`settings.jiandu.create.description`)}),(0,m.jsxs)(`div`,{className:`min-h-0 space-y-3 overflow-y-auto pr-1`,children:[(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{htmlFor:`jiandu-title`,children:t(`settings.jiandu.create.titleLabel`)}),(0,m.jsx)(i,{id:`jiandu-title`,value:z.title,maxLength:ue.titleChars,disabled:!!G,onChange:e=>Z(`title`,e.target.value)})]}),(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{children:t(`settings.jiandu.create.typeLabel`)}),(0,m.jsxs)(ee,{value:z.type,disabled:!!G,onValueChange:e=>Z(`type`,e),children:[(0,m.jsx)(o,{className:`w-full`,"aria-label":t(`settings.jiandu.create.typeLabel`),children:(0,m.jsx)(a,{})}),(0,m.jsx)(s,{className:`z-[150]`,children:ce.map(e=>(0,m.jsx)(c,{value:e,children:Je(e)},e))})]})]}),(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{htmlFor:`jiandu-body`,children:t(`settings.jiandu.create.bodyLabel`)}),(0,m.jsx)(oe,{id:`jiandu-body`,rows:7,value:z.content,maxLength:ue.bodyChars,disabled:!!G,onChange:e=>Z(`content`,e.target.value)})]}),(0,m.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`tags`,`keywords`,`entities`].map(e=>(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{htmlFor:`jiandu-${e}`,children:t(`settings.jiandu.create.${e}Label`)}),(0,m.jsx)(i,{id:`jiandu-${e}`,value:z[e],disabled:!!G,onChange:t=>Z(e,t.target.value),placeholder:t(`settings.jiandu.create.csvHint`)})]},e)),(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{children:t(`settings.jiandu.create.granularityLabel`)}),(0,m.jsxs)(ee,{value:z.granularity||`none`,disabled:!!G,onValueChange:e=>Z(`granularity`,e===`none`?``:e),children:[(0,m.jsx)(o,{className:`w-full`,"aria-label":t(`settings.jiandu.create.granularityLabel`),children:(0,m.jsx)(a,{})}),(0,m.jsxs)(s,{className:`z-[150]`,children:[(0,m.jsx)(c,{value:`none`,children:t(`settings.jiandu.create.noGranularity`)}),pe.map(e=>(0,m.jsx)(c,{value:e,children:e},e))]})]})]})]}),Me?(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(Me)}):null,V?(0,m.jsxs)(`section`,{className:`rounded-lg border p-3`,"aria-label":t(`settings.jiandu.create.matchesLabel`),children:[(0,m.jsx)(`h3`,{className:`text-sm font-medium`,children:V.items.length>0?t(`settings.jiandu.create.matches`):t(`settings.jiandu.create.noMatches`)}),V.items.length>0?(0,m.jsx)(`ul`,{className:`mt-2 space-y-1 text-sm`,children:V.items.map(e=>(0,m.jsxs)(`li`,{children:[e.title,` · `,$(e.status)]},e.id))}):null,V.truncated?(0,m.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:t(`settings.jiandu.create.matchesTruncated`)}):null]}):null]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,m.jsx)(u,{variant:`outline`,disabled:G===`create`,onClick:We,children:t(`settings.jiandu.create.close`)}),(0,m.jsx)(u,{variant:`secondary`,disabled:je||!!G,onClick:()=>void Ge(),children:t(je?`settings.jiandu.create.lookingUp`:`settings.jiandu.create.lookup`)}),(0,m.jsx)(u,{disabled:G===`create`||!V||V.fingerprint!==He,onClick:()=>void Ke(),children:t(G===`create`?`settings.jiandu.create.creating`:`settings.jiandu.create.confirm`)})]})]})}),(0,m.jsx)(ae,{open:!!Ne,onOpenChange:e=>{!e&&G!==`archive`&&(q(null),J(null))},children:(0,m.jsxs)(re,{showCloseButton:!1,dismissable:G!==`archive`,className:`gap-4 p-5`,children:[(0,m.jsx)(ne,{children:t(`settings.jiandu.archive.title`,{title:Ne?.title??``})}),(0,m.jsx)(ie,{children:t(`settings.jiandu.archive.description`)}),Pe?(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(Pe)}):null,(0,m.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,m.jsx)(u,{variant:`outline`,disabled:G===`archive`,onClick:()=>{q(null),J(null)},children:t(`settings.jiandu.archive.cancel`)}),(0,m.jsx)(u,{variant:`destructive`,disabled:G===`archive`,onClick:()=>void qe(),children:t(G===`archive`?`settings.jiandu.archive.archiving`:`settings.jiandu.archive.confirm`)})]})]})})]})}export{v as JianduProjectMemories};
|