@yuriai/web 0.1.24 → 0.1.26

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.
Files changed (67) hide show
  1. package/dist/assets/{AssistantView-C6Kq4IeV.js → AssistantView-BpH66j_M.js} +3 -3
  2. package/dist/assets/{DiagramView-BWNMrLgm.js → DiagramView-BUSKNHpA.js} +1 -1
  3. package/dist/assets/{MarkdownRenderer-AHl_m1Rf.js → MarkdownRenderer-Cv0uQm6P.js} +2 -2
  4. package/dist/assets/{MarkdownRendererImpl-B3bYtK9r.js → MarkdownRendererImpl-DdA8OTyc.js} +1 -1
  5. package/dist/assets/{MarkstreamRendererImpl-B5rxhwTp.js → MarkstreamRendererImpl-C_pmUgRH.js} +1 -1
  6. package/dist/assets/{MobileDetailNavigation-CkdmjMHv.js → MobileDetailNavigation-C8ay670M.js} +1 -1
  7. package/dist/assets/{MobileShareBridge-D4h2_ZOI.js → MobileShareBridge-BRKIMBu6.js} +1 -1
  8. package/dist/assets/{MobileTabPageHeader-CgwEhDEc.js → MobileTabPageHeader-DFCwfVMX.js} +1 -1
  9. package/dist/assets/{MultiRunWindow-C8ifF6MX.js → MultiRunWindow-DnKgSNFU.js} +1 -1
  10. package/dist/assets/{OverlayScrollbar-eBG-DXgX.js → OverlayScrollbar-CWK4F7aC.js} +1 -1
  11. package/dist/assets/{SettingsView-DinNQMES.js → SettingsView-Ciha0BxW.js} +1 -1
  12. package/dist/assets/{SettingsWindow-BqQxUO8Z.js → SettingsWindow-DfZZulsn.js} +1 -1
  13. package/dist/assets/{TerminalView-LwaxVKh2.js → TerminalView-CIbymc9n.js} +1 -1
  14. package/dist/assets/{ToolOutputDialog-CrMx7040.js → ToolOutputDialog-Hdg-97em.js} +1 -1
  15. package/dist/assets/{appThemeRegistry-BrxlsRZv.js → appThemeRegistry-dIFOkzfO.js} +1 -1
  16. package/dist/assets/{capgoAdapter-DjiN4gU-.js → capgoAdapter-CophGZfT.js} +1 -1
  17. package/dist/assets/{dropdown-menu.styles-BqAI_N66.js → dropdown-menu.styles-3mrmi5fY.js} +1 -1
  18. package/dist/assets/{fileMentionTouchSelection-BSbG3aaI.js → fileMentionTouchSelection-D8FLYpv9.js} +1 -1
  19. package/dist/assets/{gitApi-BrFpwjIz.js → gitApi-CVqZBJOp.js} +1 -1
  20. package/dist/assets/{insertionBoundaries-jA5oY6Eg.js → insertionBoundaries-QcQpX59t.js} +1 -1
  21. package/dist/assets/{main-Vmy68zzS.js → main-BcPly9IC.js} +4 -4
  22. package/dist/assets/{main-sy9tIrXv.js → main-Di7p8GjN.js} +2 -2
  23. package/dist/assets/{mcpQueries-B6p3UNY7.js → mcpQueries-CW2h7NXI.js} +1 -1
  24. package/dist/assets/{miniChat-D9RYlfJj.js → miniChat-Cs-7LXyP.js} +2 -2
  25. package/dist/assets/{mobile-DJ8Ongip.js → mobile-CGsmrhgA.js} +2 -2
  26. package/dist/assets/{mobileBackNavigation-B8L0Vy1I.js → mobileBackNavigation-BX1Pz7aE.js} +1 -1
  27. package/dist/assets/{multirun-COWU8JRo.js → multirun-BX9ykMyO.js} +1 -1
  28. package/dist/assets/{native-config-DYPGnxUZ.js → native-config-FUMqP3sd.js} +1 -1
  29. package/dist/assets/{platform-CCTs9UKZ.js → platform-BT4vb0rs.js} +2 -2
  30. package/dist/assets/{projectMeta-BKzhp80G.js → projectMeta-BFtPKaOK.js} +1 -1
  31. package/dist/assets/{renderElectronMiniChatApp-DmmSvxer.js → renderElectronMiniChatApp-Bq0m9Qhc.js} +2 -2
  32. package/dist/assets/{renderMobileApp-B6mlgiIP.js → renderMobileApp-P5KrVIBw.js} +4 -4
  33. package/dist/assets/{runtimeConfig-D-qLdzVy.js → runtimeConfig-9HBA_MyT.js} +1 -1
  34. package/dist/assets/{runtimeEndpointReset-C2av6bqy.js → runtimeEndpointReset-DeytUJtO.js} +1 -1
  35. package/dist/assets/{scheduledTaskNavigation-FME9NQYP.js → scheduledTaskNavigation-meXpw7b3.js} +1 -1
  36. package/dist/assets/{sessionChangeSummary-DKOy397B.js → sessionChangeSummary-C9h6xZd8.js} +1 -1
  37. package/dist/assets/{sessionLookup-BxxDvke8.js → sessionLookup-D15ec6WY.js} +1 -1
  38. package/dist/assets/{sortable-tabs-strip-DiXAHgws.js → sortable-tabs-strip-Qxgcs21u.js} +1 -1
  39. package/dist/assets/{speechSettingsQueries-B3JrnqTj.js → speechSettingsQueries-BiiCAU-s.js} +1 -1
  40. package/dist/assets/{terminalApi-DhXTmxps.js → terminalApi-bFOdIit8.js} +1 -1
  41. package/dist/assets/{textarea-BZhmG_bD.js → textarea-bZ1VMrmO.js} +1 -1
  42. package/dist/assets/{types-D4VbzvCO.js → types-ziSFePSf.js} +1 -1
  43. package/dist/assets/{useAppFontEffects-lFrC_5Vj.js → useAppFontEffects-DSHn-okJ.js} +5 -5
  44. package/dist/assets/{useDesktopWindowControlsLayout-BPujMjYn.js → useDesktopWindowControlsLayout-BJfaVDLo.js} +1 -1
  45. package/dist/assets/{useEffectiveDirectory-DfD8BFNR.js → useEffectiveDirectory-D4M0iYdf.js} +1 -1
  46. package/dist/assets/{useFontPreferences-CMyrMAmq.js → useFontPreferences-Daujs94n.js} +1 -1
  47. package/dist/assets/{useMobileNavigationStore-DllieJnH.js → useMobileNavigationStore-B5EmTMWP.js} +5 -5
  48. package/dist/assets/{useWorkerHighlightedLines-mc6QKH2H.js → useWorkerHighlightedLines-BmZl_Azr.js} +1 -1
  49. package/dist/index.html +7 -7
  50. package/dist/mini-chat.html +7 -7
  51. package/dist/mobile.html +7 -7
  52. package/package.json +1 -1
  53. package/server/index.js +1 -12
  54. package/server/lib/content-search/DOCUMENTATION.md +12 -2
  55. package/server/lib/content-search/event-ingest.integration.test.js +52 -0
  56. package/server/lib/content-search/event-repair.test.js +48 -0
  57. package/server/lib/content-search/index.js +2 -2
  58. package/server/lib/content-search/runtime.js +4 -4
  59. package/server/lib/content-search/service.js +7 -1
  60. package/server/lib/opencode/lifecycle.js +19 -1
  61. package/server/lib/question-auto-delegate/DOCUMENTATION.md +5 -1
  62. package/server/lib/question-auto-delegate/core.d.ts +2 -2
  63. package/server/lib/question-auto-delegate/runtime.js +11 -27
  64. package/server/lib/question-auto-delegate/runtime.test.js +25 -0
  65. package/server/lib/scheduled-tasks/DOCUMENTATION.md +5 -0
  66. package/server/lib/scheduled-tasks/runtime.js +16 -0
  67. package/server/lib/scheduled-tasks/runtime.test.js +33 -0
@@ -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-AHl_m1Rf.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,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),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,`
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-Cv0uQm6P.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,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),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-sy9tIrXv.js"></script>
563
+ <script type="module" crossorigin src="/assets/main-Di7p8GjN.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-CCTs9UKZ.js">
584
- <link rel="modulepreload" crossorigin href="/assets/terminalApi-DhXTmxps.js">
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-D4VbzvCO.js">
587
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DjiN4gU-.js">
588
- <link rel="modulepreload" crossorigin href="/assets/native-config-DYPGnxUZ.js">
589
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D-qLdzVy.js">
586
+ <link rel="modulepreload" crossorigin href="/assets/types-ziSFePSf.js">
587
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-CophGZfT.js">
588
+ <link rel="modulepreload" crossorigin href="/assets/native-config-FUMqP3sd.js">
589
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-9HBA_MyT.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">
@@ -74,7 +74,7 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-D9RYlfJj.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-Cs-7LXyP.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-CCTs9UKZ.js">
98
- <link rel="modulepreload" crossorigin href="/assets/terminalApi-DhXTmxps.js">
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-D4VbzvCO.js">
101
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DjiN4gU-.js">
102
- <link rel="modulepreload" crossorigin href="/assets/native-config-DYPGnxUZ.js">
103
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D-qLdzVy.js">
100
+ <link rel="modulepreload" crossorigin href="/assets/types-ziSFePSf.js">
101
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-CophGZfT.js">
102
+ <link rel="modulepreload" crossorigin href="/assets/native-config-FUMqP3sd.js">
103
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-9HBA_MyT.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-DJ8Ongip.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-CGsmrhgA.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-CCTs9UKZ.js">
87
- <link rel="modulepreload" crossorigin href="/assets/terminalApi-DhXTmxps.js">
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-D4VbzvCO.js">
90
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DjiN4gU-.js">
91
- <link rel="modulepreload" crossorigin href="/assets/native-config-DYPGnxUZ.js">
92
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D-qLdzVy.js">
89
+ <link rel="modulepreload" crossorigin href="/assets/types-ziSFePSf.js">
90
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-CophGZfT.js">
91
+ <link rel="modulepreload" crossorigin href="/assets/native-config-FUMqP3sd.js">
92
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-9HBA_MyT.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuriai/web",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
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));
@@ -38,6 +38,13 @@ queue populated by live events. Each dirty session is read by ID and refreshes i
38
38
  own messages; unrelated sessions incur no upstream work. Initialization failures
39
39
  retry using committed per-session checkpoints. Explicit `sync()` remains deliberate
40
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.
41
48
  Already verified unchanged sessions are reused, including
42
49
  sessions with no searchable text. Each session now commits an `indexed_at`
43
50
  completion timestamp atomically with its projection, source update time and
@@ -88,8 +95,11 @@ during the fetch survives for another pass. Thirty-second retries are scheduled
88
95
  only for unfinished initialization or pending dirty sessions, never idle catalog
89
96
  polling. Deleted-session events and confirmed 404 remove that session; a time-bounded
90
97
  catalog is not authoritative absence for unvisited IDs. Indexing does not depend on
91
- any UI session being opened. Runtime identity is owned by the Host session index;
92
- in-flight results are rejected if it changes. Stop aborts reads and drains the
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
93
103
  active pass before closing SQLite.
94
104
 
95
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,10 @@ 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
10
  getSession: ({ sessionID, signal }) => client().session.get({ sessionID }, { signal: AbortSignal.any([signal, AbortSignal.timeout(30_000)]) }),
11
11
  listSessions: async ({ signal, ...query }) => {
12
12
  await waitForReady();
@@ -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, getSession, 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;
@@ -37,7 +37,7 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
37
37
  for (const id of revisions.keys()) dirty.add(id);
38
38
  const pendingDirty = new Set(dirty);
39
39
  const initialized = service.coverage(runtime).indexCompletedAt !== null;
40
- const scanCatalog = !incremental || !initialized;
40
+ const scanCatalog = !incremental || !initialized || service.needsEventIdentityRepair(runtime);
41
41
  const sessions = [];
42
42
  const ids = new Set();
43
43
  let cursor;
@@ -148,7 +148,7 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
148
148
  timer = setTimeout(async () => {
149
149
  timer = undefined;
150
150
  await sync({ incremental: true });
151
- if (service.coverage(getRuntimeKey()).indexCompletedAt === null || service.pending(getRuntimeKey()).length) schedule(30_000);
151
+ if (service.coverage(getRuntimeKey()).indexCompletedAt === null || service.needsEventIdentityRepair(getRuntimeKey()) || service.pending(getRuntimeKey()).length) schedule(30_000);
152
152
  }, delay);
153
153
  timer.unref?.();
154
154
  };
@@ -156,7 +156,7 @@ export function createContentSearchRuntime({ service, getRuntimeKey, listSession
156
156
  sync, status,
157
157
  start() { schedule(0); },
158
158
  observe(event) {
159
- if (event.runtimeIdentity?.runtimeKey && event.runtimeIdentity.runtimeKey !== getRuntimeKey()) return;
159
+ if (event.runtimeIdentity?.runtimeKey && event.runtimeIdentity.runtimeKey !== getEventRuntimeKey()) return;
160
160
  if (state.runtime !== getRuntimeKey()) schedule(0);
161
161
  const payload = event.payload?.payload ?? event.payload;
162
162
  const type = normalizeSessionEventType(payload?.type ?? '');
@@ -36,6 +36,9 @@ export function createContentSearchService({ dbPath }) {
36
36
  if (!sessionColumns.some((column) => column.name === 'indexed_at')) {
37
37
  db.exec('ALTER TABLE search_session ADD COLUMN indexed_at REAL');
38
38
  }
39
+ if (!db.prepare('PRAGMA table_info(search_coverage)').all().some((column) => column.name === 'event_identity_repaired')) {
40
+ db.exec('ALTER TABLE search_coverage ADD COLUMN event_identity_repaired INTEGER NOT NULL DEFAULT 0');
41
+ }
39
42
  const remove = db.prepare('DELETE FROM search_message WHERE runtime=? AND session=?');
40
43
  const write = db.prepare('INSERT INTO search_message(runtime,session,message,role,created,body) VALUES(?,?,?,?,?,?)');
41
44
  const removeSession = db.transaction((runtime, id) => {
@@ -57,12 +60,15 @@ export function createContentSearchService({ dbPath }) {
57
60
  return db.prepare('SELECT started_at AS indexStartedAt, completed_at AS indexCompletedAt, since AS coveredSince, verified_at AS verifiedAt FROM search_coverage WHERE runtime=?').get(runtime)
58
61
  ?? { indexStartedAt: null, indexCompletedAt: null, coveredSince: null, verifiedAt: null };
59
62
  },
63
+ needsEventIdentityRepair(runtime) {
64
+ return db.prepare('SELECT event_identity_repaired FROM search_coverage WHERE runtime=?').get(runtime)?.event_identity_repaired !== 1;
65
+ },
60
66
  beginInitialization(runtime, timestamp) {
61
67
  db.prepare(`INSERT INTO search_coverage(runtime,started_at) VALUES(?,?)
62
68
  ON CONFLICT(runtime) DO NOTHING`).run(runtime, timestamp);
63
69
  },
64
70
  completeInitialization(runtime, since, timestamp) {
65
- db.prepare(`UPDATE search_coverage SET completed_at=COALESCE(completed_at,?), since=?, verified_at=? WHERE runtime=?`)
71
+ db.prepare(`UPDATE search_coverage SET completed_at=COALESCE(completed_at,?), since=?, verified_at=?, event_identity_repaired=1 WHERE runtime=?`)
66
72
  .run(timestamp, since, timestamp, runtime);
67
73
  },
68
74
  replaceSession: db.transaction((runtime, session, records, since = null, indexedAt = Date.now()) => {
@@ -1,4 +1,5 @@
1
1
  import { spawn, spawnSync } from 'node:child_process';
2
+ import fs from 'node:fs';
2
3
  import net from 'node:net';
3
4
  import { registerManagedProcess, unregisterManagedProcess, reapOrphanedProcesses } from './managed-process-registry.js';
4
5
  import { evaluateOpenCodeHealthBody } from './opencode2-pin.js';
@@ -592,6 +593,23 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
592
593
  * @param {object | null | undefined} migrationGate
593
594
  * @param {number | null | undefined} expectedGeneration
594
595
  */
596
+ // Health checks run every 15s; spawnSync `--version` blocks the event loop.
597
+ // Re-read only when the binary file is replaced (upgrade changes mtime/size).
598
+ let cliVersionCache = { key: '', version: null };
599
+ const readCliVersionCached = (binaryPath) => {
600
+ let key;
601
+ try {
602
+ const stat = fs.statSync(binaryPath);
603
+ key = `${binaryPath}\0${stat.mtimeMs}\0${stat.size}`;
604
+ } catch {
605
+ return readOpenCode2BinaryVersion(binaryPath) || null;
606
+ }
607
+ if (cliVersionCache.key === key) return cliVersionCache.version;
608
+ const version = readOpenCode2BinaryVersion(binaryPath) || null;
609
+ if (version) cliVersionCache = { key, version };
610
+ return version;
611
+ };
612
+
595
613
  const refreshRuntimeContractFromProbe = (
596
614
  probe,
597
615
  migrationGate = state.v1Migration,
@@ -608,7 +626,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
608
626
  const binaryPath = typeof process.env.OPENCODE_BINARY === 'string'
609
627
  ? process.env.OPENCODE_BINARY.trim()
610
628
  : '';
611
- const cliVersion = binaryPath ? (readOpenCode2BinaryVersion(binaryPath) || null) : null;
629
+ const cliVersion = binaryPath ? readCliVersionCached(binaryPath) : null;
612
630
  const contract = evaluateRuntimeContract({
613
631
  serveVersion: probe?.version ?? null,
614
632
  cliVersion,
@@ -98,7 +98,11 @@ form IO and core, restoring `/api` for origin-only upstream URLs.
98
98
 
99
99
  ## Reconcile
100
100
 
101
- - Inventory = projects + session-index directories + observed request/event dirs.
101
+ - Inventory = live upstream Locations (`GET /api/debug/location`) + observed request/event dirs.
102
+ Forms live in Location memory, so other directories cannot hold pending forms;
103
+ a scoped `form.list` there would boot a Location that upstream never evicts.
104
+ Never enumerate settings projects or session-index directories. An unreadable
105
+ live set is an inventory failure, not an empty catalog.
102
106
  - Track `successfulDirectories`; only those may settle missing requests.
103
107
  - Unscoped list discovers unknowns only; never means “all directories empty”.
104
108
  - Unscoped / directory-less pending triggers `ensureSessionLineage(sessionID, hint, requestID)`
@@ -181,8 +181,8 @@ export interface QuestionAutoDelegateIO {
181
181
  body: unknown,
182
182
  sessionID: string,
183
183
  ): Promise<QuestionAutoDelegateUpstreamResult>;
184
- /** Project directories used for reconnect/start reconcile. */
185
- listDirectories(): Promise<string[]>;
184
+ /** Live upstream Location directories for reconnect/start reconcile; null when unreadable. */
185
+ listDirectories(): Promise<string[] | null>;
186
186
  /**
187
187
  * Persist-backed enabled flag.
188
188
  * - `true` / `false` when readable (absent key ⇒ default true)
@@ -28,9 +28,6 @@ export function createQuestionAutoDelegateRuntime({
28
28
  buildOpenCodeUrl,
29
29
  getOpenCodeAuthHeaders,
30
30
  readSettingsFromDiskMigrated,
31
- sanitizeProjects,
32
- /** Optional: session-index / worktree inventory directories. */
33
- listIndexedDirectories,
34
31
  broadcastGlobalUiEvent,
35
32
  broadcastYuriEvent,
36
33
  fetchImpl = fetch,
@@ -124,32 +121,19 @@ export function createQuestionAutoDelegateRuntime({
124
121
  return null;
125
122
  }
126
123
  },
124
+ /**
125
+ * Forms live in Location memory, so only live Locations can hold pending
126
+ * forms. A scoped `/form` on any other directory boots a full Location
127
+ * that upstream never evicts; never list projects or indexed directories.
128
+ * @returns {Promise<string[]|null>} null when the live set is unreadable.
129
+ */
127
130
  async listDirectories() {
131
+ const result = await upstream('/debug/location');
132
+ if (!result.ok || !Array.isArray(result.body)) return null;
128
133
  const dirs = new Set();
129
- try {
130
- const settings = await readSettingsFromDiskMigrated();
131
- const projects = typeof sanitizeProjects === 'function'
132
- ? (sanitizeProjects(settings?.projects ?? []) || [])
133
- : (Array.isArray(settings?.projects) ? settings.projects : []);
134
- for (const project of projects) {
135
- const path = asTrimmedString(project?.path);
136
- if (path) dirs.add(path);
137
- }
138
- } catch {
139
- // Project list failure is not fatal when index inventory exists.
140
- }
141
- if (typeof listIndexedDirectories === 'function') {
142
- try {
143
- const indexed = await listIndexedDirectories();
144
- if (Array.isArray(indexed)) {
145
- for (const directory of indexed) {
146
- const path = asTrimmedString(directory);
147
- if (path) dirs.add(path);
148
- }
149
- }
150
- } catch {
151
- // ignore index failures — core marks partial when inventory empty+failed
152
- }
134
+ for (const entry of result.body) {
135
+ const path = asTrimmedString(entry?.directory);
136
+ if (path) dirs.add(path);
153
137
  }
154
138
  return Array.from(dirs);
155
139
  },
@@ -26,6 +26,7 @@ const setup = async (pending = []) => {
26
26
  let onEvent;
27
27
  const fetchImpl = vi.fn(async (url, options) => {
28
28
  const path = url.pathname;
29
+ if (path === '/api/debug/location') return Response.json([{ directory: '/project' }]);
29
30
  if (path === '/api/form') return Response.json({ data: pending });
30
31
  if (path === '/api/session/ses_test') return Response.json({ data: { id: 'ses_test', location: { directory: '/project' } } });
31
32
  if (path === '/api/session/ses_test/form/frm_question') return Response.json({ data: form });
@@ -52,6 +53,30 @@ const setup = async (pending = []) => {
52
53
  };
53
54
  };
54
55
 
56
+ it('reconciles only live Locations and never boots project or indexed directories', async () => {
57
+ vi.useFakeTimers();
58
+ const fetchImpl = vi.fn(async (url) => {
59
+ if (url.pathname === '/api/debug/location') return Response.json([{ directory: '/live' }]);
60
+ if (url.pathname === '/api/form') return Response.json({ data: [] });
61
+ return Response.json({ error: 'Not found' }, { status: 404 });
62
+ });
63
+ const runtime = createQuestionAutoDelegateRuntime({
64
+ globalEventHub: { subscribeEvent: () => () => {} },
65
+ buildOpenCodeUrl: (path) => `http://opencode.test/api${path}`,
66
+ getOpenCodeAuthHeaders: () => ({}),
67
+ readSettingsFromDiskMigrated: async () => ({ projects: [{ path: '/project' }, { path: '/other' }] }),
68
+ fetchImpl,
69
+ pauseStore: createQuestionPauseStore(pauseDirectory),
70
+ });
71
+ runtimes.push(runtime);
72
+ runtime.start();
73
+ await vi.advanceTimersByTimeAsync(0);
74
+ const scoped = fetchImpl.mock.calls
75
+ .map(([url]) => url.searchParams.get('location[directory]'))
76
+ .filter(Boolean);
77
+ expect(scoped).toEqual(['/live']);
78
+ });
79
+
55
80
  it('auto-delegates a native question form after exactly 30 seconds without a UI', async () => {
56
81
  const { emit, posts, runtime } = await setup();
57
82
  emit('form.created', { sessionID: form.sessionID, form });
@@ -220,6 +220,7 @@ executions and rows without a session; missing session association is not proof
220
220
  of execution failure. Such rows remain unresolved rather than inventing a result.
221
221
  Recovery checks live `session.active` before examining terminal messages or Host
222
222
  goal state. Active, unavailable, malformed, and incomplete results remain pending.
223
+ A session OpenCode confirms deleted (`SessionNotFoundError`) settles as `error`.
223
224
  Only confirmed terminal evidence finalizes history, with duration through the
224
225
  time recovery observes completion. It neither dispatches a new prompt nor sends
225
226
  a second completion notification.
@@ -358,6 +359,10 @@ Every actual run (timer or manual):
358
359
  after multiple incomplete idle probes.
359
360
  - `session.active` / `message.list` failures stay **unknown** (keep
360
361
  polling under the watchdog); they never masquerade as idle success.
362
+ Exception: a declared `SessionNotFoundError` (or HTTP 404) from
363
+ `message.list` / `session.get` is confirmed terminal evidence and
364
+ finalizes as `error: 'session not found'`, so recovery stops polling
365
+ deleted sessions. Transport failures never match.
361
366
  - Assistant `error` (and terminal finish `error` / `length` /
362
367
  `content-filter`) finalizes as `error`.
363
368
  - Goal-enabled runs: settle via Host goal terminal status when the store
@@ -400,6 +400,15 @@ const extractGoalFromSession = (session) => {
400
400
  * must be a real terminal (finish tool-calls / incomplete / model-switch ≠
401
401
  * success). History rows are never rewritten here.
402
402
  */
403
+ const SESSION_NOT_FOUND_ERROR = 'session not found';
404
+
405
+ // Real `@opencode/client` throws declared errors by `_tag`; transport failures never match.
406
+ const isSessionNotFoundError = (error) => {
407
+ if (!error || typeof error !== 'object') return false;
408
+ if ((error._tag ?? error.name) === 'SessionNotFoundError') return true;
409
+ return Number(error.status ?? error.statusCode ?? error.response?.status) === 404;
410
+ };
411
+
403
412
  const snapshotSessionOutcome = async ({
404
413
  client,
405
414
  sessionID,
@@ -474,6 +483,9 @@ const snapshotSessionOutcome = async ({
474
483
  }
475
484
  } catch (error) {
476
485
  if (signal?.aborted) throw error;
486
+ if (isSessionNotFoundError(error)) {
487
+ return { outcome: 'error', error: SESSION_NOT_FOUND_ERROR };
488
+ }
477
489
  }
478
490
  }
479
491
  return { outcome: 'busy' };
@@ -490,6 +502,10 @@ const snapshotSessionOutcome = async ({
490
502
  }
491
503
  } catch (error) {
492
504
  if (signal?.aborted) throw error;
505
+ // Upstream confirmed the session is gone: terminal, or recovery polls it forever.
506
+ if (isSessionNotFoundError(error)) {
507
+ return { outcome: 'error', error: SESSION_NOT_FOUND_ERROR };
508
+ }
493
509
  }
494
510
 
495
511
  return { outcome: 'busy' };