@yuriai/web 0.1.23 → 0.1.25
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/assets/{AssistantView-Cl8dtJE-.js → AssistantView-DkkL7s7i.js} +3 -3
- package/dist/assets/{DiagramView-zXlQky2c.js → DiagramView-DOMsCmU-.js} +1 -1
- package/dist/assets/{MarkdownRenderer-C1PXw_8U.js → MarkdownRenderer-AN4GlC9h.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-CWVOJcvk.js → MarkdownRendererImpl-CsUiqm29.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-BwkPAY1P.js → MarkstreamRendererImpl-DjXQ9X9C.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-B4ZBK4cl.js → MobileDetailNavigation-DFB8rg9g.js} +1 -1
- package/dist/assets/{MobileShareBridge-B5LUJJ99.js → MobileShareBridge-C_jmYsbd.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-CkUhuZP6.js → MobileTabPageHeader-CMBzNZBy.js} +1 -1
- package/dist/assets/{MultiRunWindow-CqNrUij5.js → MultiRunWindow-DxMv9jKP.js} +1 -1
- package/dist/assets/{OverlayScrollbar-eBG-DXgX.js → OverlayScrollbar-CWK4F7aC.js} +1 -1
- package/dist/assets/{SettingsView-vZx4AKc1.js → SettingsView-BEq5cvqg.js} +1 -1
- package/dist/assets/{SettingsWindow-Rqxks-AG.js → SettingsWindow-9bYkuKIe.js} +1 -1
- package/dist/assets/{TerminalView-CGYEbWpv.js → TerminalView-COipduNh.js} +1 -1
- package/dist/assets/{ToolOutputDialog-B24XEhve.js → ToolOutputDialog-BjDrr974.js} +1 -1
- package/dist/assets/{appThemeRegistry-DD8LRHDT.js → appThemeRegistry-iidW7at3.js} +1 -1
- package/dist/assets/{capgoAdapter-BCy22KX-.js → capgoAdapter-0DA9TWMV.js} +1 -1
- package/dist/assets/{dropdown-menu.styles-BqAI_N66.js → dropdown-menu.styles-3mrmi5fY.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-CnxrRlNO.js → fileMentionTouchSelection-EkYevl92.js} +1 -1
- package/dist/assets/{gitApi-D3cHH50Y.js → gitApi-VD_SyM5W.js} +1 -1
- package/dist/assets/{insertionBoundaries-19EJsmCA.js → insertionBoundaries-ClmJX_-D.js} +1 -1
- package/dist/assets/{main-BO2UnYBd.js → main--YSyKf8-.js} +2 -2
- package/dist/assets/{main-b2a4ZRXC.js → main-Bsg4OQ34.js} +4 -4
- package/dist/assets/{mcpQueries-BBt1ELI8.js → mcpQueries-DYzvdfmI.js} +1 -1
- package/dist/assets/{miniChat-BpvsuSKB.js → miniChat-kz5eiEfP.js} +2 -2
- package/dist/assets/{mobile-CyklTbWh.js → mobile-hiPGrOul.js} +2 -2
- package/dist/assets/{mobileBackNavigation-Df81BnZ5.js → mobileBackNavigation-COcmVsJC.js} +1 -1
- package/dist/assets/{multirun-BrpKcjYv.js → multirun-Ra40sNkO.js} +1 -1
- package/dist/assets/{native-config-C3EM05Jz.js → native-config-lUVS3vdZ.js} +1 -1
- package/dist/assets/{platform-CCTs9UKZ.js → platform-BT4vb0rs.js} +2 -2
- package/dist/assets/{projectMeta-DOs0HlSf.js → projectMeta-DViOvoUL.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DaeIwT-e.js → renderElectronMiniChatApp-BWISO2T9.js} +2 -2
- package/dist/assets/{renderMobileApp-C-Rhiqyk.js → renderMobileApp-ucbAF6Ej.js} +4 -4
- package/dist/assets/{runtimeConfig-CQ3TyMLm.js → runtimeConfig-BdRmjg3v.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-CINPdy23.js → runtimeEndpointReset-D6LiKcAj.js} +1 -1
- package/dist/assets/{scheduledTaskNavigation-FME9NQYP.js → scheduledTaskNavigation-meXpw7b3.js} +1 -1
- package/dist/assets/{sessionChangeSummary-DYp-0K8f.js → sessionChangeSummary-DNE_sFSd.js} +1 -1
- package/dist/assets/{sessionLookup-BMSCT9Y1.js → sessionLookup-76lCzcL6.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-DiXAHgws.js → sortable-tabs-strip-Qxgcs21u.js} +1 -1
- package/dist/assets/{speechSettingsQueries-Ci2kILTe.js → speechSettingsQueries-DIrdNQ5r.js} +1 -1
- package/dist/assets/{terminalApi-DhXTmxps.js → terminalApi-bFOdIit8.js} +1 -1
- package/dist/assets/{textarea-BZhmG_bD.js → textarea-bZ1VMrmO.js} +1 -1
- package/dist/assets/{types-Du8LnIGl.js → types-CjeWmPyo.js} +1 -1
- package/dist/assets/{useAppFontEffects-C-CZuq33.js → useAppFontEffects-BO_mYJwk.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-C8BGnh2S.js → useDesktopWindowControlsLayout-Xmk-iiF6.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-B85HOZow.js → useEffectiveDirectory-i9j_KNIu.js} +1 -1
- package/dist/assets/{useFontPreferences-CMyrMAmq.js → useFontPreferences-Daujs94n.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-_8410bpu.js → useMobileNavigationStore-_DBQumPX.js} +4 -4
- package/dist/assets/{useWorkerHighlightedLines-D4HmbcHr.js → useWorkerHighlightedLines-DqPxA031.js} +1 -1
- package/dist/index.html +7 -7
- package/dist/mini-chat.html +7 -7
- package/dist/mobile.html +7 -7
- package/package.json +1 -1
- package/server/index.js +1 -12
- package/server/lib/content-search/DOCUMENTATION.md +29 -13
- package/server/lib/content-search/event-ingest.integration.test.js +52 -0
- package/server/lib/content-search/event-repair.test.js +48 -0
- package/server/lib/content-search/index.js +3 -2
- package/server/lib/content-search/runtime.js +51 -10
- package/server/lib/content-search/runtime.test.js +72 -1
- package/server/lib/content-search/service.js +19 -2
- package/server/lib/opencode/lifecycle.js +19 -1
- package/server/lib/question-auto-delegate/DOCUMENTATION.md +5 -1
- package/server/lib/question-auto-delegate/core.d.ts +2 -2
- package/server/lib/question-auto-delegate/runtime.js +11 -27
- package/server/lib/question-auto-delegate/runtime.test.js +25 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +5 -0
- package/server/lib/scheduled-tasks/runtime.js +16 -0
- package/server/lib/scheduled-tasks/runtime.test.js +33 -0
package/dist/assets/{useWorkerHighlightedLines-D4HmbcHr.js → useWorkerHighlightedLines-DqPxA031.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{v as r}from"./useUIStore-NMQx_cnG.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{f as a,r as o,t as s}from"./button-LPikURUk.js";import{n as c}from"./useThemeSystem-8jhE4Zyk.js";import{n as l}from"./Icon-DKFfVCeK.js";import{i as u,n as d,t as f}from"./tooltip-CFuO3PUH.js";import{n as p}from"./MarkdownRenderer-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{v as r}from"./useUIStore-NMQx_cnG.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{f as a,r as o,t as s}from"./button-LPikURUk.js";import{n as c}from"./useThemeSystem-8jhE4Zyk.js";import{n as l}from"./Icon-DKFfVCeK.js";import{i as u,n as d,t as f}from"./tooltip-CFuO3PUH.js";import{n as p}from"./MarkdownRenderer-AN4GlC9h.js";import{n as m,o as h,s as g,t as _}from"./markdown-worker-7FvUo2nm.js";import{t as v}from"./vendor-tanstack-react-virtual-B_EO--9t.js";import{n as y}from"./markdownTheme-DHoKvD6O.js";var b=e(t(),1),x=i(),S=n(),C=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,w={maxWidth:`min(28rem, calc(100cqw - 4ch))`,backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`},T=`flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] px-3 py-2.5`,E=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,D=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,O=`m-0 list-none divide-y divide-[var(--surface-subtle)] p-0`,k=`${O} max-h-[min(22rem,50vh)] overflow-y-auto`,A=`${O} w-full`,ee={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},j=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,M=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,te=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,ne=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,re=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,ie={in_progress:`text-foreground`,pending:`text-foreground`,completed:`text-muted-foreground line-through`,cancelled:`text-muted-foreground line-through`},ae={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},N=e=>{let t=(0,x.c)(26),{todo:n,isActive:r,activeRef:i}=e,{t:s}=a(),c=oe.has(n.status)?n.status:`pending`,p=ae[c],m;t[0]!==s||t[1]!==p?(m=s(p),t[0]=s,t[1]=p,t[2]=m):m=t[2];let h=m,g;t[3]===c?g=t[4]:(g=c===`in_progress`?(0,S.jsx)(l,{name:`record-circle`,className:`h-3.5 w-3.5 text-[var(--status-info)]`,"aria-hidden":`true`}):c===`completed`?(0,S.jsx)(l,{name:`checkbox-circle`,className:`h-3.5 w-3.5 text-[var(--status-success)]`,"aria-hidden":`true`}):(0,S.jsx)(l,{name:`time`,className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),t[3]=c,t[4]=g);let _=g,v=r?`step`:void 0,y=r&&`bg-[var(--surface-muted)] before:absolute before:inset-y-2 before:left-0 before:w-0.5 before:rounded-full before:bg-[var(--status-info)]`,b;t[5]===y?b=t[6]:(b=o(`group relative grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] items-start gap-2.5`,j,y),t[5]=y,t[6]=b);let C;t[7]!==_||t[8]!==h?(C=(0,S.jsx)(u,{asChild:!0,children:(0,S.jsx)(`span`,{className:`flex size-4 items-center justify-center`,"aria-label":h,children:_})}),t[7]=_,t[8]=h,t[9]=C):C=t[9];let w;t[10]===h?w=t[11]:(w=(0,S.jsx)(d,{side:`left`,sideOffset:6,children:h}),t[10]=h,t[11]=w);let T;t[12]!==C||t[13]!==w?(T=(0,S.jsxs)(f,{children:[C,w]}),t[12]=C,t[13]=w,t[14]=T):T=t[14];let E=ie[c],D;t[15]===E?D=t[16]:(D=o(`block whitespace-normal break-words`,E),t[15]=E,t[16]=D);let O;t[17]!==D||t[18]!==n.content?(O=(0,S.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,S.jsx)(`span`,{className:D,children:n.content})}),t[17]=D,t[18]=n.content,t[19]=O):O=t[19];let k;return t[20]!==i||t[21]!==O||t[22]!==v||t[23]!==b||t[24]!==T?(k=(0,S.jsxs)(`li`,{ref:i,"aria-current":v,className:b,children:[T,O]}),t[20]=i,t[21]=O,t[22]=v,t[23]=b,t[24]=T,t[25]=k):k=t[25],k},oe=new Set([`in_progress`,`pending`,`completed`,`cancelled`]),P=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),F=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,I=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=F(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},L=e=>`<pre><code>${P(e)}</code></pre>`,R=e=>{let t=(0,x.c)(21),{code:n,language:r,className:i,style:a,codeStyle:s,wrap:l}=e,u=l!==void 0&&l,{currentTheme:d}=c(),f=b.useRef(null),p;t[0]===d?p=t[1]:(p=y(d),t[0]=d,t[1]=p);let m=p,h,g;t[2]!==n||t[3]!==s||t[4]!==u?(h=()=>{let e=f.current;e&&(e.innerHTML=L(n),I(e,u,s))},g=[n,u,s],t[2]=n,t[3]=s,t[4]=u,t[5]=h,t[6]=g):(h=t[5],g=t[6]),b.useLayoutEffect(h,g);let v,C;t[7]!==n||t[8]!==s||t[9]!==r||t[10]!==u?(v=()=>{let e=f.current;if(!e)return;let t=!0,i=new AbortController;return _(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,I(e,u,s))}),()=>{t=!1,i.abort()}},C=[n,r,u,s],t[7]=n,t[8]=s,t[9]=r,t[10]=u,t[11]=v,t[12]=C):(v=t[11],C=t[12]),b.useEffect(v,C);let w;t[13]===i?w=t[14]:(w=o(`typography-code`,i),t[13]=i,t[14]=w);let T=m,E;t[15]!==a||t[16]!==T?(E={...T,...a},t[15]=a,t[16]=T,t[17]=E):E=t[17];let D;return t[18]!==w||t[19]!==E?(D=(0,S.jsx)(`div`,{ref:f,className:w,style:E}),t[18]=w,t[19]=E,t[20]=D):D=t[20],D},z=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},B=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},V=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,H=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,U=(e,t)=>!e||typeof e!=`object`?String(e):g(e,t||``),W=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},G=e=>{if(!e||typeof e!=`object`)return;let t=W(e.patch)??W(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=W(e.patch)??W(e.diff);if(t)return t}},K=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},q=(e,t,n)=>{let r=z(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&V(r)&&(r=H(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=G(n);if(e)return e}return r},se=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),r=e=>/\(\s*File has more lines\..*offset.*\)/i.test(e.trim());return{type:t,lines:n.map(e=>{let n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);if(t!==`directory`){let t=e.match(/^(\d+):\s?(.*)$/);if(t){let e=t[2],n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);return{lineNumber:i?null:Number(t[1]),text:e,isInfo:i}}}return{lineNumber:null,text:e,isInfo:i}}).filter((e,t,n)=>{if(e.text.trim().length>0)return!0;let r=n[t-1],i=n[t+1],a=!!(r?.isInfo||i?.isInfo),o=e.lineNumber!==null;return!(a&&o)})}},ce=(e,t)=>{try{let n=e.trim().split(`
|
|
4
4
|
`).filter(Boolean);if(n.length===0)return null;let i=[];return n.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,r=Math.floor(e.length/2),a=!n.endsWith(`/`);i.push({name:n.replace(/\/$/,``),depth:r,isFile:a})}}),(0,S.jsx)(`div`,{className:o(`w-full min-w-0 font-mono space-y-0.5`,t?.unstyled?null:`p-3 bg-muted/20 rounded-xl border border-border/30`),style:r.tool.popup,children:i.map((e,t)=>(0,S.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,S.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,S.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},le={backgroundColor:`var(--status-info)`,opacity:.6},ue=(e,t,n)=>{try{let i=e.trim().split(`
|
package/dist/index.html
CHANGED
|
@@ -560,7 +560,7 @@
|
|
|
560
560
|
opacity: 0.72;
|
|
561
561
|
}
|
|
562
562
|
</style>
|
|
563
|
-
<script type="module" crossorigin src="/assets/main
|
|
563
|
+
<script type="module" crossorigin src="/assets/main--YSyKf8-.js"></script>
|
|
564
564
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
565
565
|
<link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
|
|
566
566
|
<link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
|
|
@@ -580,13 +580,13 @@
|
|
|
580
580
|
<link rel="modulepreload" crossorigin href="/assets/vendor-tanstack-react-query-CdqCAt40.js">
|
|
581
581
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
|
582
582
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-resource-C1k5nbWb.js">
|
|
583
|
-
<link rel="modulepreload" crossorigin href="/assets/platform-
|
|
584
|
-
<link rel="modulepreload" crossorigin href="/assets/terminalApi-
|
|
583
|
+
<link rel="modulepreload" crossorigin href="/assets/platform-BT4vb0rs.js">
|
|
584
|
+
<link rel="modulepreload" crossorigin href="/assets/terminalApi-bFOdIit8.js">
|
|
585
585
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DAOam_oV.js">
|
|
586
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
587
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
588
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
589
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
586
|
+
<link rel="modulepreload" crossorigin href="/assets/types-CjeWmPyo.js">
|
|
587
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-0DA9TWMV.js">
|
|
588
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-lUVS3vdZ.js">
|
|
589
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BdRmjg3v.js">
|
|
590
590
|
<link rel="stylesheet" crossorigin href="/assets/src-DlJVKekb.css">
|
|
591
591
|
</head>
|
|
592
592
|
<body class="h-full bg-background text-foreground">
|
package/dist/mini-chat.html
CHANGED
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
}
|
|
75
75
|
</style>
|
|
76
76
|
|
|
77
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
77
|
+
<script type="module" crossorigin src="/assets/miniChat-kz5eiEfP.js"></script>
|
|
78
78
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
79
79
|
<link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
|
|
80
80
|
<link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
|
|
@@ -94,13 +94,13 @@
|
|
|
94
94
|
<link rel="modulepreload" crossorigin href="/assets/vendor-tanstack-react-query-CdqCAt40.js">
|
|
95
95
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
|
96
96
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-resource-C1k5nbWb.js">
|
|
97
|
-
<link rel="modulepreload" crossorigin href="/assets/platform-
|
|
98
|
-
<link rel="modulepreload" crossorigin href="/assets/terminalApi-
|
|
97
|
+
<link rel="modulepreload" crossorigin href="/assets/platform-BT4vb0rs.js">
|
|
98
|
+
<link rel="modulepreload" crossorigin href="/assets/terminalApi-bFOdIit8.js">
|
|
99
99
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DAOam_oV.js">
|
|
100
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
101
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
102
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
103
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
100
|
+
<link rel="modulepreload" crossorigin href="/assets/types-CjeWmPyo.js">
|
|
101
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-0DA9TWMV.js">
|
|
102
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-lUVS3vdZ.js">
|
|
103
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BdRmjg3v.js">
|
|
104
104
|
<link rel="stylesheet" crossorigin href="/assets/src-DlJVKekb.css">
|
|
105
105
|
</head>
|
|
106
106
|
<body class="h-full bg-background text-foreground">
|
package/dist/mobile.html
CHANGED
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
})();
|
|
64
64
|
</script>
|
|
65
65
|
|
|
66
|
-
<script type="module" crossorigin src="/assets/mobile-
|
|
66
|
+
<script type="module" crossorigin src="/assets/mobile-hiPGrOul.js"></script>
|
|
67
67
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
68
68
|
<link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
|
|
69
69
|
<link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
|
|
@@ -83,13 +83,13 @@
|
|
|
83
83
|
<link rel="modulepreload" crossorigin href="/assets/vendor-tanstack-react-query-CdqCAt40.js">
|
|
84
84
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
|
85
85
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-resource-C1k5nbWb.js">
|
|
86
|
-
<link rel="modulepreload" crossorigin href="/assets/platform-
|
|
87
|
-
<link rel="modulepreload" crossorigin href="/assets/terminalApi-
|
|
86
|
+
<link rel="modulepreload" crossorigin href="/assets/platform-BT4vb0rs.js">
|
|
87
|
+
<link rel="modulepreload" crossorigin href="/assets/terminalApi-bFOdIit8.js">
|
|
88
88
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DAOam_oV.js">
|
|
89
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
90
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
91
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
92
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
89
|
+
<link rel="modulepreload" crossorigin href="/assets/types-CjeWmPyo.js">
|
|
90
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-0DA9TWMV.js">
|
|
91
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-lUVS3vdZ.js">
|
|
92
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BdRmjg3v.js">
|
|
93
93
|
<link rel="stylesheet" crossorigin href="/assets/src-DlJVKekb.css">
|
|
94
94
|
</head>
|
|
95
95
|
<body class="h-full bg-background text-foreground">
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -1019,18 +1019,6 @@ questionAutoDelegateRuntime = createQuestionAutoDelegateRuntime({
|
|
|
1019
1019
|
buildOpenCodeUrl,
|
|
1020
1020
|
getOpenCodeAuthHeaders,
|
|
1021
1021
|
readSettingsFromDiskMigrated,
|
|
1022
|
-
sanitizeProjects,
|
|
1023
|
-
listIndexedDirectories: async () => {
|
|
1024
|
-
try {
|
|
1025
|
-
const snap = sessionIndexServiceRef?.snapshot?.();
|
|
1026
|
-
const directories = Array.isArray(snap?.directories) ? snap.directories : [];
|
|
1027
|
-
return directories
|
|
1028
|
-
.map((entry) => (typeof entry?.directory === 'string' ? entry.directory.trim() : ''))
|
|
1029
|
-
.filter(Boolean);
|
|
1030
|
-
} catch {
|
|
1031
|
-
return [];
|
|
1032
|
-
}
|
|
1033
|
-
},
|
|
1034
1022
|
broadcastGlobalUiEvent,
|
|
1035
1023
|
broadcastYuriEvent: broadcastQuestionAutoDelegateTip,
|
|
1036
1024
|
onUserTakeover: ({ sessionID, directory }) => {
|
|
@@ -1600,6 +1588,7 @@ async function main(options = {}) {
|
|
|
1600
1588
|
const contentSearch = createGlobalContentSearch({
|
|
1601
1589
|
dataDir: path.dirname(resolveSessionIndexDbPath({ sessionIndexDbPath }, YURI_DATA_DIR)),
|
|
1602
1590
|
getRuntimeKey: () => sessionIndexService.getRuntimeKey(),
|
|
1591
|
+
getEventRuntimeKey: () => messageQueueService?.getRuntimeKey() ?? null,
|
|
1603
1592
|
buildOpenCodeUrl, getOpenCodeAuthHeaders, waitForReady: waitForOpenCodeReady,
|
|
1604
1593
|
});
|
|
1605
1594
|
const unsubscribeContentSearch = globalMessageStreamHub.subscribeEvent((event) => contentSearch.runtime.observe(event));
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
The Host owns `content-search.sqlite` alongside the session index. This index is
|
|
4
4
|
independent of browser transcript caches and includes all projects exposed by the
|
|
5
5
|
active OpenCode runtime. `session.list` is called without a project/directory
|
|
6
|
-
filter
|
|
6
|
+
filter during initial backfill; descending opaque cursors stop at the thirty-day
|
|
7
|
+
boundary or exhaustion. The default coverage is
|
|
7
8
|
messages created in the last thirty days in recently updated root sessions.
|
|
8
9
|
Sessions with a non-empty `parentID` (subagents) are excluded before message
|
|
9
10
|
fetching and progress counting. Only root IDs enter the authoritative pruning
|
|
10
|
-
set, so a
|
|
11
|
+
set, so a fully exhausted catalog scan also removes previously indexed subagent
|
|
11
12
|
messages, FTS entries and checkpoints. Failed catalog reads preserve the old index.
|
|
12
13
|
|
|
13
14
|
Two workers page native `message.list` directly, normalize via the shared server
|
|
@@ -31,12 +32,20 @@ and checkpoint until a complete replacement succeeds.
|
|
|
31
32
|
`search_coverage` durably records each runtime's `indexStartedAt`,
|
|
32
33
|
`indexCompletedAt`, `coveredSince`, and `verifiedAt`. These are index operation
|
|
33
34
|
timestamps, not installation/version timestamps or browser onboarding flags.
|
|
34
|
-
An absent completion marker requires initialization.
|
|
35
|
-
the
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
An absent completion marker requires initialization. A completed runtime does not
|
|
36
|
+
walk the catalog on startup or on a timer. It resumes only the durable dirty-session
|
|
37
|
+
queue populated by live events. Each dirty session is read by ID and refreshes its
|
|
38
|
+
own messages; unrelated sessions incur no upstream work. Initialization failures
|
|
39
|
+
retry using committed per-session checkpoints. Explicit `sync()` remains deliberate
|
|
40
|
+
catalog reconciliation; automatic scheduling uses incremental mode.
|
|
41
|
+
The event-identity hotfix adds `search_coverage.event_identity_repaired` without
|
|
42
|
+
changing existing runtime keys or deleting results. Older completed indexes perform
|
|
43
|
+
one bounded thirty-day catalog reconciliation to recover updates dropped by the
|
|
44
|
+
old event fence. Unchanged checkpoints are reused; changed/missing sessions are
|
|
45
|
+
refetched with the same two-worker limit. Partial failures preserve old hits and
|
|
46
|
+
retry after thirty seconds, including after restart. Only successful reconciliation
|
|
47
|
+
sets the durable repair marker; subsequent warm starts resume dirty work only.
|
|
48
|
+
Already verified unchanged sessions are reused, including
|
|
40
49
|
sessions with no searchable text. Each session now commits an `indexed_at`
|
|
41
50
|
completion timestamp atomically with its projection, source update time and
|
|
42
51
|
coverage boundary. Existing databases gain this nullable column and the coverage
|
|
@@ -60,7 +69,7 @@ coverage (for example after a system-clock correction).
|
|
|
60
69
|
The status response adds `initializationRequired` and these durable timestamps.
|
|
61
70
|
`updatedAt` remains the current process's latest completed pass, including partial
|
|
62
71
|
passes; clients must not confuse it with successful durable completion. A warm
|
|
63
|
-
startup may be `pending` with `initializationRequired: false`;
|
|
72
|
+
startup may be `pending` with `initializationRequired: false`; queued dirty sessions
|
|
64
73
|
remain background work. `initializationRequired` indicates unfinished first-time
|
|
65
74
|
initialization, not whether the latest incremental pass has caught up. No
|
|
66
75
|
UI-triggered import or OpenCode database conversion is needed:
|
|
@@ -80,10 +89,17 @@ dismissal; runtime changes recheck. Older Hosts without the new status fields
|
|
|
80
89
|
keep their existing behavior. VS Code's direct OpenCode connection has no Host
|
|
81
90
|
FTS service and does not mount this step.
|
|
82
91
|
|
|
83
|
-
Global upstream events mark sessions dirty and coalesce
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
Global upstream events durably mark sessions dirty and coalesce work within one
|
|
93
|
+
second. Successful writes acknowledge only the captured dirty revision, so an event
|
|
94
|
+
during the fetch survives for another pass. Thirty-second retries are scheduled
|
|
95
|
+
only for unfinished initialization or pending dirty sessions, never idle catalog
|
|
96
|
+
polling. Deleted-session events and confirmed 404 remove that session; a time-bounded
|
|
97
|
+
catalog is not authoritative absence for unvisited IDs. Indexing does not depend on
|
|
98
|
+
any UI session being opened. The persisted partition is owned by the Host session
|
|
99
|
+
index; the incoming event fence is checked against the message queue's runtime key,
|
|
100
|
+
the same provider used by the global hub. These are distinct hash namespaces and
|
|
101
|
+
must never be compared to each other. Old-runtime events remain rejected;
|
|
102
|
+
in-flight results are rejected if the index partition changes. Stop aborts reads and drains the
|
|
87
103
|
active pass before closing SQLite.
|
|
88
104
|
|
|
89
105
|
`GET /api/yuri/content-search?q=...&limit=30` returns `{hits,index}`.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { expect, test, vi } from 'vitest';
|
|
2
|
+
import { createSessionIndexService } from '../session-index/service.js';
|
|
3
|
+
import { createMessageQueueService } from '../message-queue/service.js';
|
|
4
|
+
import { createGlobalMessageStreamHub } from '../event-stream/global-hub.js';
|
|
5
|
+
import { createContentSearchService } from './service.js';
|
|
6
|
+
import { createContentSearchRuntime } from './runtime.js';
|
|
7
|
+
|
|
8
|
+
test('real hub runtime identity admits completed replies into search and rejects a previous runtime', async () => {
|
|
9
|
+
let config = { apiBaseUrl: 'http://runtime-a' };
|
|
10
|
+
const getRuntimeConfig = () => config;
|
|
11
|
+
const index = createSessionIndexService({ dbPath: ':memory:', getRuntimeConfig });
|
|
12
|
+
const queue = createMessageQueueService({ dbPath: ':memory:', getRuntimeConfig });
|
|
13
|
+
const service = createContentSearchService({ dbPath: ':memory:' });
|
|
14
|
+
const key = index.getRuntimeKey();
|
|
15
|
+
service.beginInitialization(key, 1);
|
|
16
|
+
service.completeInitialization(key, 0, 2);
|
|
17
|
+
const listSessions = vi.fn();
|
|
18
|
+
const listMessages = vi.fn(async () => ({ data: [{
|
|
19
|
+
id: 'reply', sessionID: 's', type: 'assistant', time: { created: 10, completed: 20 },
|
|
20
|
+
finish: 'stop', content: [{ type: 'text', text: '卡顿和高资源占用属实' }],
|
|
21
|
+
}], cursor: {} }));
|
|
22
|
+
const runtime = createContentSearchRuntime({ service, getRuntimeKey: () => index.getRuntimeKey(),
|
|
23
|
+
getEventRuntimeKey: () => queue.getRuntimeKey(), now: () => 100, listSessions, listMessages,
|
|
24
|
+
getSession: async () => ({ id: 's', time: { updated: 20 } }),
|
|
25
|
+
});
|
|
26
|
+
let captured;
|
|
27
|
+
let stream;
|
|
28
|
+
const hub = createGlobalMessageStreamHub({
|
|
29
|
+
buildOpenCodeUrl: (pathname) => `http://runtime-a${pathname}`, getOpenCodeAuthHeaders: () => ({}),
|
|
30
|
+
getRuntimeIdentity: () => ({ runtimeKey: queue.getRuntimeKey() }),
|
|
31
|
+
fetchImpl: async () => new Response(new ReadableStream({ start(controller) {
|
|
32
|
+
stream = controller;
|
|
33
|
+
controller.enqueue(new TextEncoder().encode('id: event-1\ndata: {"type":"session.execution.succeeded","data":{"sessionID":"s"}}\n\n'));
|
|
34
|
+
} })),
|
|
35
|
+
});
|
|
36
|
+
hub.subscribeEvent((event) => { captured = event; runtime.observe(event); });
|
|
37
|
+
try {
|
|
38
|
+
hub.start();
|
|
39
|
+
await vi.waitFor(() => expect(captured).toBeDefined());
|
|
40
|
+
expect(queue.getRuntimeKey()).not.toBe(key);
|
|
41
|
+
expect(service.pending(key)).toHaveLength(1);
|
|
42
|
+
await runtime.sync({ incremental: true });
|
|
43
|
+
expect(service.search(key, '卡顿和高资源占用属实')).toMatchObject([{ sessionID: 's', messageID: 'reply' }]);
|
|
44
|
+
expect(listSessions).not.toHaveBeenCalled();
|
|
45
|
+
expect(listMessages).toHaveBeenCalledTimes(1);
|
|
46
|
+
config = { apiBaseUrl: 'http://runtime-b' };
|
|
47
|
+
runtime.observe(captured);
|
|
48
|
+
expect(service.pending(index.getRuntimeKey())).toEqual([]);
|
|
49
|
+
} finally {
|
|
50
|
+
hub.stop(); stream?.close(); await runtime.stop(); service.close(); index.close(); queue.close();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { expect, test, vi } from 'vitest';
|
|
2
|
+
import Database from 'better-sqlite3';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { createContentSearchService } from './service.js';
|
|
7
|
+
import { createContentSearchRuntime } from './runtime.js';
|
|
8
|
+
|
|
9
|
+
test('old completed indexes repair missed updates once, preserve failed results and resume after restart', async () => {
|
|
10
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'content-event-repair-'));
|
|
11
|
+
const dbPath = path.join(dir, 'search.sqlite');
|
|
12
|
+
const old = new Database(dbPath);
|
|
13
|
+
old.exec(`CREATE TABLE search_coverage(runtime TEXT PRIMARY KEY, started_at REAL NOT NULL, completed_at REAL, since REAL, verified_at REAL);
|
|
14
|
+
INSERT INTO search_coverage VALUES('host',1,2,0,3);`);
|
|
15
|
+
old.close();
|
|
16
|
+
let service = createContentSearchService({ dbPath });
|
|
17
|
+
const now = 40 * 86400000;
|
|
18
|
+
const record = (id, text) => ({ info: { id, role: 'user', time: { created: now } }, parts: [{ type: 'text', text }] });
|
|
19
|
+
for (const id of ['unchanged', 'missed', 'failed']) service.replaceSession('host', { id, time: { updated: 10 } }, [record(id, 'previous result')], 0);
|
|
20
|
+
let fail = true;
|
|
21
|
+
const listSessions = vi.fn(async () => ({ data: [
|
|
22
|
+
{ id: 'missed', time: { updated: now } }, { id: 'failed', time: { updated: now } },
|
|
23
|
+
{ id: 'unchanged', time: { updated: 10 } },
|
|
24
|
+
], cursor: { next: 'older' } }));
|
|
25
|
+
const listMessages = vi.fn(async ({ sessionID }) => {
|
|
26
|
+
if (sessionID === 'failed' && fail) throw new Error('offline');
|
|
27
|
+
return { data: [{ type: 'user', id: sessionID, sessionID, time: { created: now }, text: 'recovered result' }], cursor: {} };
|
|
28
|
+
});
|
|
29
|
+
const create = () => createContentSearchRuntime({ service, getRuntimeKey: () => 'host', now: () => now, listSessions, listMessages });
|
|
30
|
+
let runtime = create();
|
|
31
|
+
try {
|
|
32
|
+
await runtime.sync({ incremental: true });
|
|
33
|
+
expect(service.search('host', 'recovered')).toHaveLength(1);
|
|
34
|
+
expect(service.search('host', 'previous').map((hit) => hit.sessionID).sort()).toEqual(['failed', 'unchanged']);
|
|
35
|
+
expect(runtime.status()).toMatchObject({ phase: 'partial', initializationRequired: false, indexCompletedAt: 2 });
|
|
36
|
+
await runtime.stop(); service.close();
|
|
37
|
+
service = createContentSearchService({ dbPath }); runtime = create(); fail = false;
|
|
38
|
+
await runtime.sync({ incremental: true });
|
|
39
|
+
expect(service.search('host', 'recovered')).toHaveLength(2);
|
|
40
|
+
expect(listMessages.mock.calls.map(([q]) => q.sessionID)).toEqual(['missed', 'failed', 'failed']);
|
|
41
|
+
expect(listSessions).toHaveBeenCalledTimes(2);
|
|
42
|
+
await runtime.stop(); service.close();
|
|
43
|
+
service = createContentSearchService({ dbPath }); runtime = create();
|
|
44
|
+
await runtime.sync({ incremental: true });
|
|
45
|
+
expect(listSessions).toHaveBeenCalledTimes(2);
|
|
46
|
+
expect(listMessages).toHaveBeenCalledTimes(3);
|
|
47
|
+
} finally { await runtime.stop(); service.close(); fs.rmSync(dir, { recursive: true, force: true }); }
|
|
48
|
+
});
|
|
@@ -3,10 +3,11 @@ import { makeOpenCodeV2Client } from '../opencode/v2-client.js';
|
|
|
3
3
|
import { createContentSearchService } from './service.js';
|
|
4
4
|
import { createContentSearchRuntime } from './runtime.js';
|
|
5
5
|
|
|
6
|
-
export function createGlobalContentSearch({ dataDir, getRuntimeKey, buildOpenCodeUrl, getOpenCodeAuthHeaders, waitForReady }) {
|
|
6
|
+
export function createGlobalContentSearch({ dataDir, getRuntimeKey, getEventRuntimeKey, buildOpenCodeUrl, getOpenCodeAuthHeaders, waitForReady }) {
|
|
7
7
|
const service = createContentSearchService({ dbPath: path.join(dataDir, 'content-search.sqlite') });
|
|
8
8
|
const client = () => makeOpenCodeV2Client({ baseUrl: buildOpenCodeUrl('/', ''), authHeaders: getOpenCodeAuthHeaders() });
|
|
9
|
-
const runtime = createContentSearchRuntime({ service, getRuntimeKey,
|
|
9
|
+
const runtime = createContentSearchRuntime({ service, getRuntimeKey, getEventRuntimeKey,
|
|
10
|
+
getSession: ({ sessionID, signal }) => client().session.get({ sessionID }, { signal: AbortSignal.any([signal, AbortSignal.timeout(30_000)]) }),
|
|
10
11
|
listSessions: async ({ signal, ...query }) => {
|
|
11
12
|
await waitForReady();
|
|
12
13
|
return client().session.list(query, { signal: AbortSignal.any([signal, AbortSignal.timeout(30_000)]) });
|
|
@@ -5,7 +5,7 @@ import { normalizeSessionEventType } from '../session-metadata/session-projectio
|
|
|
5
5
|
const RETENTION = 30 * 24 * 60 * 60 * 1000;
|
|
6
6
|
const nextCursor = (page) => typeof page?.cursor?.next === 'string' ? page.cursor.next : null;
|
|
7
7
|
|
|
8
|
-
export function createContentSearchRuntime({ service, getRuntimeKey, listSessions, listMessages, now = Date.now }) {
|
|
8
|
+
export function createContentSearchRuntime({ service, getRuntimeKey, getEventRuntimeKey = getRuntimeKey, listSessions, getSession, listMessages, now = Date.now }) {
|
|
9
9
|
let stopped = false;
|
|
10
10
|
let flight;
|
|
11
11
|
let timer;
|
|
@@ -16,11 +16,12 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
|
|
|
16
16
|
const deleted = new Set();
|
|
17
17
|
const status = () => {
|
|
18
18
|
const runtime = getRuntimeKey();
|
|
19
|
+
if (!stopped && state.runtime !== runtime) schedule(0);
|
|
19
20
|
const coverage = service.coverage(runtime);
|
|
20
21
|
return { ...(state.runtime === runtime ? state : { runtime, phase: 'pending', since: now() - RETENTION, total: 0, completed: 0, failed: 0, updatedAt: null }),
|
|
21
22
|
...coverage, initializationRequired: coverage.indexCompletedAt === null, ...service.stats(runtime) };
|
|
22
23
|
};
|
|
23
|
-
const sync = () => {
|
|
24
|
+
const sync = ({ incremental = false } = {}) => {
|
|
24
25
|
if (stopped) return Promise.resolve();
|
|
25
26
|
if (flight) return flight;
|
|
26
27
|
const runtime = getRuntimeKey();
|
|
@@ -32,13 +33,37 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
|
|
|
32
33
|
state = { runtime, phase: previous ? 'ready' : 'indexing', since: now() - RETENTION, total: state.total, completed: 0, failed: 0, updatedAt: previous };
|
|
33
34
|
flight = (async () => {
|
|
34
35
|
if (service.coverage(runtime).indexCompletedAt === null) service.beginInitialization(runtime, now());
|
|
36
|
+
const revisions = new Map(service.pending(runtime).map(({ id, revision }) => [id, revision]));
|
|
37
|
+
for (const id of revisions.keys()) dirty.add(id);
|
|
35
38
|
const pendingDirty = new Set(dirty);
|
|
39
|
+
const initialized = service.coverage(runtime).indexCompletedAt !== null;
|
|
40
|
+
const scanCatalog = !incremental || !initialized || service.needsEventIdentityRepair(runtime);
|
|
36
41
|
const sessions = [];
|
|
37
42
|
const ids = new Set();
|
|
38
43
|
let cursor;
|
|
44
|
+
let completeCatalog = scanCatalog;
|
|
39
45
|
const cursors = new Set();
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
if (!scanCatalog) {
|
|
47
|
+
for (const sessionID of pendingDirty) {
|
|
48
|
+
try {
|
|
49
|
+
const session = await getSession({ sessionID, signal });
|
|
50
|
+
if (!current()) return;
|
|
51
|
+
if (!session?.id || !Number.isFinite(session.time?.updated)) throw new Error('Invalid dirty session');
|
|
52
|
+
if (!session.parentID && session.time.updated >= state.since && !deleted.has(sessionID)) sessions.push(session);
|
|
53
|
+
else {
|
|
54
|
+
service.removeSession(runtime, sessionID);
|
|
55
|
+
dirty.delete(sessionID);
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (!current()) return;
|
|
59
|
+
if ((error?.status ?? error?.response?.status) === 404) {
|
|
60
|
+
service.removeSession(runtime, sessionID);
|
|
61
|
+
dirty.delete(sessionID);
|
|
62
|
+
} else state.failed++;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} else do {
|
|
66
|
+
const page = await listSessions({ limit: 100, ...(cursor ? { cursor } : { order: 'desc' }), signal });
|
|
42
67
|
if (!current()) return;
|
|
43
68
|
if (!Array.isArray(page?.data)) throw new Error('Invalid global session page');
|
|
44
69
|
for (const session of page.data) {
|
|
@@ -51,11 +76,18 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
|
|
|
51
76
|
cursor = nextCursor(page);
|
|
52
77
|
if (cursor && cursors.has(cursor)) throw new Error('Repeated session cursor');
|
|
53
78
|
if (cursor) cursors.add(cursor);
|
|
79
|
+
if (page.data.some((session) => session.time.updated < state.since)) {
|
|
80
|
+
completeCatalog = !cursor;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
54
83
|
} while (cursor && current());
|
|
55
84
|
state.total = sessions.length;
|
|
56
85
|
state.completed = 0;
|
|
57
86
|
const recentIDs = new Set(sessions.map((session) => session.id));
|
|
58
|
-
for (const id of pendingDirty) if (!recentIDs.has(id))
|
|
87
|
+
if (scanCatalog && completeCatalog) for (const id of pendingDirty) if (!recentIDs.has(id)) {
|
|
88
|
+
dirty.delete(id);
|
|
89
|
+
service.acknowledge(runtime, id, revisions.get(id));
|
|
90
|
+
}
|
|
59
91
|
if (service.coverage(runtime).indexCompletedAt === null) state.phase = 'indexing';
|
|
60
92
|
let index = 0;
|
|
61
93
|
const worker = async () => {
|
|
@@ -85,7 +117,10 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
|
|
|
85
117
|
// Native pages are newest-first, including control records.
|
|
86
118
|
if (page.data.length && page.data.every((record) => Number(record.time?.created) < state.since)) break;
|
|
87
119
|
} while (before && current());
|
|
88
|
-
if (current() && !deleted.has(session.id))
|
|
120
|
+
if (current() && !deleted.has(session.id)) {
|
|
121
|
+
service.replaceSession(runtime, session, [...records.values()], state.since, now());
|
|
122
|
+
if (revisions.has(session.id)) service.acknowledge(runtime, session.id, revisions.get(session.id));
|
|
123
|
+
}
|
|
89
124
|
state.completed++;
|
|
90
125
|
} catch {
|
|
91
126
|
if (!current()) return;
|
|
@@ -96,7 +131,7 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
|
|
|
96
131
|
};
|
|
97
132
|
await Promise.all([worker(), worker()]);
|
|
98
133
|
if (current()) {
|
|
99
|
-
service.prune(runtime, state.since, ids);
|
|
134
|
+
service.prune(runtime, state.since, completeCatalog ? ids : undefined);
|
|
100
135
|
state.phase = state.failed ? 'partial' : 'ready';
|
|
101
136
|
state.updatedAt = now();
|
|
102
137
|
if (!state.failed && !dirty.size) service.completeInitialization(runtime, state.since, state.updatedAt);
|
|
@@ -110,14 +145,19 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
|
|
|
110
145
|
if (stopped || (timer && due <= Date.now() + delay)) return;
|
|
111
146
|
if (timer) clearTimeout(timer);
|
|
112
147
|
due = Date.now() + delay;
|
|
113
|
-
timer = setTimeout(async () => {
|
|
148
|
+
timer = setTimeout(async () => {
|
|
149
|
+
timer = undefined;
|
|
150
|
+
await sync({ incremental: true });
|
|
151
|
+
if (service.coverage(getRuntimeKey()).indexCompletedAt === null || service.needsEventIdentityRepair(getRuntimeKey()) || service.pending(getRuntimeKey()).length) schedule(30_000);
|
|
152
|
+
}, delay);
|
|
114
153
|
timer.unref?.();
|
|
115
154
|
};
|
|
116
155
|
return {
|
|
117
156
|
sync, status,
|
|
118
157
|
start() { schedule(0); },
|
|
119
158
|
observe(event) {
|
|
120
|
-
if (event.runtimeIdentity?.runtimeKey && event.runtimeIdentity.runtimeKey !==
|
|
159
|
+
if (event.runtimeIdentity?.runtimeKey && event.runtimeIdentity.runtimeKey !== getEventRuntimeKey()) return;
|
|
160
|
+
if (state.runtime !== getRuntimeKey()) schedule(0);
|
|
121
161
|
const payload = event.payload?.payload ?? event.payload;
|
|
122
162
|
const type = normalizeSessionEventType(payload?.type ?? '');
|
|
123
163
|
if (!(type.startsWith('message.') || type.startsWith('session.'))) return;
|
|
@@ -125,7 +165,8 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
|
|
|
125
165
|
const data = payload.properties ?? payload.data ?? {};
|
|
126
166
|
const id = data.sessionID ?? data.info?.sessionID ?? data.session?.id ?? (type.startsWith('session.') ? data.id ?? data.info?.id : undefined);
|
|
127
167
|
if (id && type === 'session.deleted') { dirty.delete(id); deleted.add(id); service.removeSession(getRuntimeKey(), id); }
|
|
128
|
-
else if (id) dirty.add(id);
|
|
168
|
+
else if (id) { dirty.add(id); service.markDirty(getRuntimeKey(), id); }
|
|
169
|
+
if (!id) return;
|
|
129
170
|
// Coalesce bursts; ongoing scans retain dirty IDs for the next pass.
|
|
130
171
|
schedule(1000);
|
|
131
172
|
},
|
|
@@ -1,7 +1,78 @@
|
|
|
1
|
-
import { expect, test } from 'vitest';
|
|
1
|
+
import { expect, test, vi } from 'vitest';
|
|
2
2
|
import { createContentSearchService } from './service.js';
|
|
3
3
|
import { createContentSearchRuntime } from './runtime.js';
|
|
4
4
|
|
|
5
|
+
test('warm startup and idle time do not scan history; durable dirty events refresh only their session', async () => {
|
|
6
|
+
vi.useFakeTimers();
|
|
7
|
+
const service = createContentSearchService({ dbPath: ':memory:' });
|
|
8
|
+
service.beginInitialization('host', 1);
|
|
9
|
+
service.completeInitialization('host', 0, 2);
|
|
10
|
+
const listSessions = vi.fn(async () => ({ data: [], cursor: {} }));
|
|
11
|
+
const getSession = vi.fn(async ({ sessionID }) => ({ id: sessionID, time: { updated: Date.now() } }));
|
|
12
|
+
const listMessages = vi.fn(async () => ({ data: [], cursor: {} }));
|
|
13
|
+
let runtime = createContentSearchRuntime({ service, getRuntimeKey: () => 'host', listSessions, getSession, listMessages });
|
|
14
|
+
try {
|
|
15
|
+
runtime.start();
|
|
16
|
+
await vi.advanceTimersByTimeAsync(120_000);
|
|
17
|
+
expect(listSessions).not.toHaveBeenCalled();
|
|
18
|
+
expect(listMessages).not.toHaveBeenCalled();
|
|
19
|
+
runtime.observe({ payload: { type: 'message.updated', data: { sessionID: 'one' } } });
|
|
20
|
+
await runtime.stop();
|
|
21
|
+
runtime = createContentSearchRuntime({ service, getRuntimeKey: () => 'host', listSessions, getSession, listMessages });
|
|
22
|
+
runtime.start();
|
|
23
|
+
await vi.advanceTimersByTimeAsync(120_000);
|
|
24
|
+
expect(listSessions).not.toHaveBeenCalled();
|
|
25
|
+
expect(getSession).toHaveBeenCalledTimes(1);
|
|
26
|
+
expect(getSession.mock.calls[0][0].sessionID).toBe('one');
|
|
27
|
+
expect(listMessages).toHaveBeenCalledTimes(1);
|
|
28
|
+
} finally { await runtime.stop(); service.close(); vi.useRealTimers(); }
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('initial history stops at thirty days without pruning unseen sessions as deleted', async () => {
|
|
32
|
+
const service = createContentSearchService({ dbPath: ':memory:' });
|
|
33
|
+
const day = 86400000;
|
|
34
|
+
const now = 40 * day;
|
|
35
|
+
service.replaceSession('host', { id: 'unseen', time: { updated: now } }, [], 0);
|
|
36
|
+
const listSessions = vi.fn(async () => ({ data: [
|
|
37
|
+
{ id: 'recent', time: { updated: now } },
|
|
38
|
+
{ id: 'old', time: { updated: now - 31 * day } },
|
|
39
|
+
], cursor: { next: 'older-history' } }));
|
|
40
|
+
const listMessages = vi.fn(async () => ({ data: [], cursor: {} }));
|
|
41
|
+
const runtime = createContentSearchRuntime({ service, getRuntimeKey: () => 'host', now: () => now, listSessions, listMessages });
|
|
42
|
+
try {
|
|
43
|
+
await runtime.sync();
|
|
44
|
+
expect(listSessions).toHaveBeenCalledTimes(1);
|
|
45
|
+
expect(listMessages).toHaveBeenCalledTimes(1);
|
|
46
|
+
expect(listMessages.mock.calls[0][0].sessionID).toBe('recent');
|
|
47
|
+
expect(service.updated('host', 'unseen')).toBe(now);
|
|
48
|
+
expect(runtime.status().initializationRequired).toBe(false);
|
|
49
|
+
} finally { await runtime.stop(); service.close(); }
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('an event received while indexing survives acknowledgement and retries only that session', async () => {
|
|
53
|
+
const service = createContentSearchService({ dbPath: ':memory:' });
|
|
54
|
+
service.beginInitialization('host', 1);
|
|
55
|
+
service.completeInitialization('host', 0, 2);
|
|
56
|
+
const listSessions = vi.fn();
|
|
57
|
+
let reads = 0;
|
|
58
|
+
const runtime = createContentSearchRuntime({ service, getRuntimeKey: () => 'host', now: () => 100,
|
|
59
|
+
listSessions, getSession: async ({ sessionID }) => ({ id: sessionID, time: { updated: 10 } }),
|
|
60
|
+
listMessages: async () => {
|
|
61
|
+
if (++reads === 1) runtime.observe({ payload: { type: 'message.updated', data: { sessionID: 's' } } });
|
|
62
|
+
return { data: [], cursor: {} };
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
try {
|
|
66
|
+
runtime.observe({ payload: { type: 'message.updated', data: { sessionID: 's' } } });
|
|
67
|
+
await runtime.sync({ incremental: true });
|
|
68
|
+
expect(service.pending('host')).toHaveLength(1);
|
|
69
|
+
await runtime.sync({ incremental: true });
|
|
70
|
+
expect(reads).toBe(2);
|
|
71
|
+
expect(service.pending('host')).toEqual([]);
|
|
72
|
+
expect(listSessions).not.toHaveBeenCalled();
|
|
73
|
+
} finally { await runtime.stop(); service.close(); }
|
|
74
|
+
});
|
|
75
|
+
|
|
5
76
|
test('indexes only roots and prunes legacy subagents after a complete catalog, including dirty children', async () => {
|
|
6
77
|
const service = createContentSearchService({ dbPath: ':memory:' });
|
|
7
78
|
const root = { id: 'root', time: { updated: 10 } };
|