@yuriai/web 0.2.6 → 0.2.8-beta.1

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 (73) hide show
  1. package/README.md +7 -0
  2. package/dist/assets/{AssistantView-Ct7V8lpF.js → AssistantView-Df-G2DX8.js} +3 -3
  3. package/dist/assets/{DiagramView-Ch2D2gUQ.js → DiagramView-BoVqJRQb.js} +1 -1
  4. package/dist/assets/{GuiPluginSurface-sdtt33qQ.js → GuiPluginSurface-DxLoeTDb.js} +1 -1
  5. package/dist/assets/MarkdownRenderer-DYi_qpYy.js +2 -0
  6. package/dist/assets/{MarkdownRendererImpl-CtfnAdo-.js → MarkdownRendererImpl-CMxRMFqp.js} +1 -1
  7. package/dist/assets/{MarkstreamRendererImpl-CWtvbZSX.js → MarkstreamRendererImpl-DQ4urBZW.js} +1 -1
  8. package/dist/assets/{MobileDetailNavigation-CUx-H4fe.js → MobileDetailNavigation-C4fJlKdu.js} +1 -1
  9. package/dist/assets/{MobileShareBridge-DUwPWQNz.js → MobileShareBridge-DLC-TdRy.js} +1 -1
  10. package/dist/assets/{MobileTabPageHeader-BtLdnDa3.js → MobileTabPageHeader-CMbbtHh7.js} +1 -1
  11. package/dist/assets/{MultiRunWindow-Gs-5PM3Z.js → MultiRunWindow-Cwp8-_Wh.js} +1 -1
  12. package/dist/assets/{SettingsView-BJy3bKbz.js → SettingsView-CYDk0wpN.js} +1 -1
  13. package/dist/assets/{SettingsWindow-w3K1Dbo1.js → SettingsWindow-Vuzphf9b.js} +1 -1
  14. package/dist/assets/{TerminalView-DnmN2KHj.js → TerminalView-Dhalx6_Z.js} +1 -1
  15. package/dist/assets/{ToolOutputDialog-Ctr_rqwb.js → ToolOutputDialog-DBxSxWNh.js} +1 -1
  16. package/dist/assets/{appThemeRegistry-3MgV1x6f.js → appThemeRegistry-JEhMXHGF.js} +1 -1
  17. package/dist/assets/{capgoAdapter-CpthNQYY.js → capgoAdapter-BgD0wyhC.js} +1 -1
  18. package/dist/assets/{fileMentionTouchSelection-1havvnZN.js → fileMentionTouchSelection-BQdfRBkk.js} +1 -1
  19. package/dist/assets/{gitApi-Bw4AQDuA.js → gitApi-DhDVqj9b.js} +1 -1
  20. package/dist/assets/{insertionBoundaries-_8AmjaTs.js → insertionBoundaries-BMe1F3uB.js} +1 -1
  21. package/dist/assets/{main-C09TKUe7.js → main-CfOYzhn0.js} +4 -4
  22. package/dist/assets/{main-C5PgzX4P.js → main-DXlMu2LF.js} +2 -2
  23. package/dist/assets/{mcpQueries-B-cYFZaO.js → mcpQueries-vxcQAIGB.js} +1 -1
  24. package/dist/assets/{miniChat-C_az-fSk.js → miniChat-D48iGEEW.js} +2 -2
  25. package/dist/assets/{mobile-CnXTR6QC.js → mobile-Cy5qSiDY.js} +2 -2
  26. package/dist/assets/{mobileBackNavigation-DSDlOhh6.js → mobileBackNavigation-QtBK9OSb.js} +1 -1
  27. package/dist/assets/{multirun-DgLVkagL.js → multirun-BR9a6EBo.js} +1 -1
  28. package/dist/assets/{native-config-w5ntuSb5.js → native-config-CHySeHif.js} +1 -1
  29. package/dist/assets/{projectMeta-OMvGIxob.js → projectMeta-Bn2vBNDe.js} +1 -1
  30. package/dist/assets/{readiness-6XMJtgLY.js → readiness-BAssoNVf.js} +1 -1
  31. package/dist/assets/{renderElectronMiniChatApp-rvO-rcnc.js → renderElectronMiniChatApp-B9Kci_8q.js} +2 -2
  32. package/dist/assets/{renderMobileApp-DheZQr5N.js → renderMobileApp-CBivL8Ps.js} +4 -4
  33. package/dist/assets/{runtimeConfig-cAbdKbv6.js → runtimeConfig-COdEwlK-.js} +1 -1
  34. package/dist/assets/{runtimeEndpointReset-CPsJLvK2.js → runtimeEndpointReset-D3x76Qpf.js} +3 -3
  35. package/dist/assets/{sessionChangeSummary-BEB6JZpN.js → sessionChangeSummary-Dtgq0CWg.js} +1 -1
  36. package/dist/assets/{sessionLookup-BI5wTzCJ.js → sessionLookup--Wlr3e8X.js} +1 -1
  37. package/dist/assets/{speechSettingsQueries-DZ9a20QR.js → speechSettingsQueries-D3fc_4Iy.js} +1 -1
  38. package/dist/assets/types-D8_26ZKT.js +2 -0
  39. package/dist/assets/{useAppFontEffects-CKCYZ3VJ.js → useAppFontEffects-DLT9jVl1.js} +6 -6
  40. package/dist/assets/{useDesktopWindowControlsLayout-CloJ_VZ3.js → useDesktopWindowControlsLayout-BNAZWH9L.js} +1 -1
  41. package/dist/assets/{useEffectiveDirectory-CuajC8G4.js → useEffectiveDirectory-D2_-KCB7.js} +1 -1
  42. package/dist/assets/{useMobileNavigationStore-07uYrwvK.js → useMobileNavigationStore-DJwk64Po.js} +3 -3
  43. package/dist/assets/{useWorkerHighlightedLines-2Vw7Hzud.js → useWorkerHighlightedLines-k48txabk.js} +1 -1
  44. package/dist/index.html +5 -5
  45. package/dist/mini-chat.html +5 -5
  46. package/dist/mobile.html +5 -5
  47. package/package.json +9 -4
  48. package/server/index.js +3 -3
  49. package/server/lib/assistants/DOCUMENTATION.md +12 -1
  50. package/server/lib/assistants/contact-tools.js +2 -2
  51. package/server/lib/assistants/harness.js +21 -17
  52. package/server/lib/assistants/harness.test.js +19 -23
  53. package/server/lib/assistants/memory.http.test.js +2 -2
  54. package/server/lib/assistants/routes.js +1 -3
  55. package/server/lib/llm/DOCUMENTATION.md +116 -161
  56. package/server/lib/llm/bridge-client.js +60 -0
  57. package/server/lib/llm/bridge-client.test.js +35 -0
  58. package/server/lib/llm/bridge-contract.js +24 -0
  59. package/server/lib/llm/bridge-plugin.bundle.js +1136 -0
  60. package/server/lib/llm/bridge-plugin.js +127 -0
  61. package/server/lib/llm/bridge-plugin.test.js +164 -0
  62. package/server/lib/llm/completions.js +42 -18
  63. package/server/lib/llm/completions.test.js +8 -4
  64. package/server/lib/llm/generate.js +43 -728
  65. package/server/lib/llm/generate.test.js +62 -1063
  66. package/server/lib/llm/routes.js +0 -2
  67. package/server/lib/package-manager.js +1 -1
  68. package/server/lib/small-model/DOCUMENTATION.md +11 -17
  69. package/server/lib/small-model/index.js +5 -4
  70. package/dist/assets/MarkdownRenderer-C1giOHSB.js +0 -2
  71. package/dist/assets/types-BihDq7ZW.js +0 -2
  72. package/server/lib/llm/temp-directory.js +0 -58
  73. package/server/lib/llm/temp-directory.test.js +0 -57
@@ -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-BSFWH-Ok.js";import{n as c}from"./useThemeSystem-8jhE4Zyk.js";import{n as l}from"./Icon-BjiyvtB2.js";import{i as u,n as d,t as f}from"./tooltip-DygQ-2xe.js";import{n as p}from"./MarkdownRenderer-C1giOHSB.js";import{n as m,r as h}from"./toolHelpers-DL452NVK.js";import{t as g}from"./vendor-tanstack-react-virtual-B_EO--9t.js";import{n as _}from"./markdownTheme-DHoKvD6O.js";import{n as v,t as y}from"./markdown-worker-oBGEB9Eg.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=_(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 y(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):h(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-BSFWH-Ok.js";import{n as c}from"./useThemeSystem-8jhE4Zyk.js";import{n as l}from"./Icon-BjiyvtB2.js";import{i as u,n as d,t as f}from"./tooltip-DygQ-2xe.js";import{n as p}from"./MarkdownRenderer-DYi_qpYy.js";import{n as m,r as h}from"./toolHelpers-DL452NVK.js";import{t as g}from"./vendor-tanstack-react-virtual-B_EO--9t.js";import{n as _}from"./markdownTheme-DHoKvD6O.js";import{n as v,t as y}from"./markdown-worker-oBGEB9Eg.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=_(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 y(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):h(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-C5PgzX4P.js"></script>
563
+ <script type="module" crossorigin src="/assets/main-DXlMu2LF.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">
@@ -591,10 +591,10 @@
591
591
  <link rel="modulepreload" crossorigin href="/assets/platform-DXeTzJHG.js">
592
592
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-CIbkfDkE.js">
593
593
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-BzblfnMx.js">
594
- <link rel="modulepreload" crossorigin href="/assets/types-BihDq7ZW.js">
595
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-CpthNQYY.js">
596
- <link rel="modulepreload" crossorigin href="/assets/native-config-w5ntuSb5.js">
597
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-cAbdKbv6.js">
594
+ <link rel="modulepreload" crossorigin href="/assets/types-D8_26ZKT.js">
595
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-BgD0wyhC.js">
596
+ <link rel="modulepreload" crossorigin href="/assets/native-config-CHySeHif.js">
597
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-COdEwlK-.js">
598
598
  <link rel="stylesheet" crossorigin href="/assets/src-NlrSCyPZ.css">
599
599
  </head>
600
600
  <body class="h-full bg-background text-foreground">
@@ -77,7 +77,7 @@
77
77
  .dark #initial-loading img { filter: invert(1); }
78
78
  </style>
79
79
 
80
- <script type="module" crossorigin src="/assets/miniChat-C_az-fSk.js"></script>
80
+ <script type="module" crossorigin src="/assets/miniChat-D48iGEEW.js"></script>
81
81
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
82
82
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
83
83
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -108,10 +108,10 @@
108
108
  <link rel="modulepreload" crossorigin href="/assets/platform-DXeTzJHG.js">
109
109
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-CIbkfDkE.js">
110
110
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-BzblfnMx.js">
111
- <link rel="modulepreload" crossorigin href="/assets/types-BihDq7ZW.js">
112
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-CpthNQYY.js">
113
- <link rel="modulepreload" crossorigin href="/assets/native-config-w5ntuSb5.js">
114
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-cAbdKbv6.js">
111
+ <link rel="modulepreload" crossorigin href="/assets/types-D8_26ZKT.js">
112
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-BgD0wyhC.js">
113
+ <link rel="modulepreload" crossorigin href="/assets/native-config-CHySeHif.js">
114
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-COdEwlK-.js">
115
115
  <link rel="stylesheet" crossorigin href="/assets/src-NlrSCyPZ.css">
116
116
  </head>
117
117
  <body class="h-full bg-background text-foreground">
package/dist/mobile.html CHANGED
@@ -64,7 +64,7 @@
64
64
  </script>
65
65
 
66
66
  <style>.dark #mobile-startup-logo img { filter: invert(1); }</style>
67
- <script type="module" crossorigin src="/assets/mobile-CnXTR6QC.js"></script>
67
+ <script type="module" crossorigin src="/assets/mobile-Cy5qSiDY.js"></script>
68
68
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
70
70
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -95,10 +95,10 @@
95
95
  <link rel="modulepreload" crossorigin href="/assets/platform-DXeTzJHG.js">
96
96
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-CIbkfDkE.js">
97
97
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-BzblfnMx.js">
98
- <link rel="modulepreload" crossorigin href="/assets/types-BihDq7ZW.js">
99
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-CpthNQYY.js">
100
- <link rel="modulepreload" crossorigin href="/assets/native-config-w5ntuSb5.js">
101
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-cAbdKbv6.js">
98
+ <link rel="modulepreload" crossorigin href="/assets/types-D8_26ZKT.js">
99
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-BgD0wyhC.js">
100
+ <link rel="modulepreload" crossorigin href="/assets/native-config-CHySeHif.js">
101
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-COdEwlK-.js">
102
102
  <link rel="stylesheet" crossorigin href="/assets/src-NlrSCyPZ.css">
103
103
  </head>
104
104
  <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.2.6",
3
+ "version": "0.2.8-beta.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -13,9 +13,11 @@
13
13
  },
14
14
  "scripts": {
15
15
  "dev": "bun run build:watch",
16
- "dev:server": "node ../../scripts/ensure-node-better-sqlite3.mjs && node server/index.js --port ${YURI_PORT:-3001}",
17
- "dev:server:watch": "nodemon --exitcrash --watch server --ext js --exec \"node ../../scripts/ensure-node-better-sqlite3.mjs && node server/index.js --port ${YURI_PORT:-3001}\"",
18
- "build": "vite build",
16
+ "dev:server": "bun run build:llm-bridge && node ../../scripts/ensure-node-better-sqlite3.mjs && node server/index.js --port ${YURI_PORT:-3001}",
17
+ "dev:server:watch": "bun run build:llm-bridge && nodemon --exitcrash --watch server --ext js --exec \"node ../../scripts/ensure-node-better-sqlite3.mjs && node server/index.js --port ${YURI_PORT:-3001}\"",
18
+ "build": "bun run build:llm-bridge && vite build",
19
+ "build:llm-bridge": "bun scripts/build-llm-bridge.mjs",
20
+ "prepack": "bun run build:llm-bridge",
19
21
  "build:watch": "vite build --watch",
20
22
  "type-check": "tsc --noEmit",
21
23
  "lint": "eslint \"./src/**/*.{ts,tsx}\" --config ../../eslint.config.js",
@@ -26,7 +28,9 @@
26
28
  "@clack/prompts": "^1.1.0",
27
29
  "@earendil-works/pi-agent-core": "0.84.4",
28
30
  "@octokit/rest": "^22.0.1",
31
+ "@opencode/ai": "2.2.1",
29
32
  "@opencode/client": "^2.0.23",
33
+ "@opencode/core": "2.2.1",
30
34
  "@opencode/schema": "^2.0.23",
31
35
  "@simplewebauthn/server": "13.3.1",
32
36
  "adm-zip": "^0.5.16",
@@ -34,6 +38,7 @@
34
38
  "bun-pty": "^0.4.5",
35
39
  "compression": "^1.8.1",
36
40
  "cron-parser": "^4.9.0",
41
+ "effect": "4.0.1",
37
42
  "express": "^5.1.0",
38
43
  "http-proxy-middleware": "^3.0.5",
39
44
  "jose": "^6.1.3",
package/server/index.js CHANGED
@@ -2242,10 +2242,10 @@ async function main(options = {}) {
2242
2242
  // best-effort shutdown of the dictation worker
2243
2243
  }
2244
2244
  try {
2245
- const { stopLlmTempDirectory } = await import('./lib/llm/temp-directory.js');
2246
- await stopLlmTempDirectory();
2245
+ const { stopLlmBridgeDirectory } = await import('./lib/llm/bridge-client.js');
2246
+ await stopLlmBridgeDirectory();
2247
2247
  } catch {
2248
- // best-effort cleanup of the LLM generator temp OpenCode directory
2248
+ // best-effort cleanup of the isolated LLM bridge directory
2249
2249
  }
2250
2250
  return gracefulShutdown({
2251
2251
  exitProcess: shutdownOptions.exitProcess ?? false,
@@ -174,8 +174,19 @@ and keep their existing error result handling.
174
174
 
175
175
  **Workspace response and loop protocol**
176
176
 
177
+ - Inference uses the external OpenCode clean RPC bridge (`../llm/DOCUMENTATION.md`),
178
+ never session.generate/session.prompt. Actual JSON schemas, native assistant
179
+ tool_calls and tool-role results retain their call IDs across turns. Textless
180
+ native tool calls continue the existing sequential pi loop. Progress/final
181
+ declarations remain application text; older text-call records are still parsed
182
+ by the existing validator but are no longer the requested tool transport.
183
+ - The contact's own explicit system prompt still includes its selected persona,
184
+ workspace tools and discovered skill instructions. This is application-owned
185
+ context, not hidden OpenCode Agent context. Summaries receive only their explicit
186
+ system/prompt. Native inference is currently one-shot, not token-streaming.
187
+
177
188
  - Public progress uses leading `yuri-message` fences containing single-line JSON `{ "text": "..." }`. A complete, valid public record emits a `done:true` bubble immediately during generation, before the following tool/final output completes. Incomplete records and ordinary raw tokens stay private. Each public record is capped at 2,000 text characters and the incomplete-record buffer at 8 KiB. The parser reads only consecutive prefix records, so quoted tool examples cannot become public events.
178
- - The model is prompted to announce its next action and report verified milestones during execution, then give a short final outcome. Public messages share the existing SSE, durable contact rows, and turn-global indices across web, desktop, VS Code, hosted mobile, and Capacitor. No timer narration, tool logs, progress widgets, or synthetic chat messages are added. Timing of model-authored milestones remains model policy; the transport guarantees immediate delivery once an explicit public record arrives.
189
+ - The model is prompted to send a progress message only when it adds information the user does not already have (a direction worth correcting, a meaningful finding, a blocker, or expected long work), then give a short final outcome. A message is not required before each tool call, and successful lookups need no separate confirmation. Public messages share the existing SSE, durable contact rows, and turn-global indices across web, desktop, VS Code, hosted mobile, and Capacitor. No timer narration, tool logs, progress widgets, or synthetic chat messages are added. Timing of model-authored milestones remains model policy; the transport guarantees immediate delivery once an explicit public record arrives.
179
190
  - Completion notifications use the latest spoken message, keeping earlier progress out of the final notification body. Transcript persistence reconciles by stable bubble IDs and adds only remaining messages.
180
191
  - Tool results remain model context for every tool. The outcome projector uses assistant-authored text only. Terminal operations retain the mutation stop gate, followed by a tools-disabled completion on the same provider/model to communicate the actual result. A failed/empty summary surfaces a turn error; a completed side effect stays committed and is never replayed by that summary pass.
181
192
  - Reset summaries receive only the successful reset tool result, excluding prior messages and attachments. The service retains one model-generated confirmation and discards pre-reset output for that turn. Failures emit temporary live error feedback outside assistant speech bubbles, without a persisted failure row.
@@ -782,10 +782,10 @@ export function formatContactToolsPrompt(tools) {
782
782
  'schedule_task writes the same payload as PUT /api/projects/:id/scheduled-tasks onto a registered project.',
783
783
  'message_assistant is read-only: it inserts into the other contact transcript. It never runs promptAsync or mutates sessions or files. Never assign through a peer message.',
784
784
  'A reply without the tool call does nothing — agreeing in Chinese (好的 / 我来创建 / 我去说一声) is not sending.',
785
- 'Before starting work, publish a short natural-language yuri-message prefix describing the next action, followed by the tool fence. Publish verified milestones as the work proceeds. Keep private reasoning, tool names, and raw traces out of public messages. After each actual result, decide whether the user needs a progress message or the final outcome.',
785
+ 'A yuri-message prefix is not required before a tool fence; publish one only when it tells the user something new. Keep private reasoning, tool names, and raw traces out of public messages.',
786
786
  'Never say 已创建, 已发送, 已停止, created, scheduled, opened, watched, stopped, or sent unless the tool already returned success.',
787
787
  'With an empty registered catalog, first discover the relevant existing workspace through list_sessions and directory lookups, then ask the user to register that workspace in Settings before assignment.',
788
- 'After a successful tool, confirm in one short bubble. The user sees a contact card, not tool traces. After successful assign_session or watch_session the session card plus that short confirm is enough — stop.',
788
+ 'After a tool that changes state succeeds, confirm in one short bubble; lookups need no separate confirmation. The user sees a contact card, not tool traces. After successful assign_session or watch_session the session card plus that short confirm is enough — stop.',
789
789
  'These are application-owned Yuri contact tools (not OpenCode native tools, not MCP, not skill directory entries). Use only the names and argument schemas below:',
790
790
  'Available Yuri tools:',
791
791
  ...list.map((tool) => formatApplicationToolCatalogEntry(tool)).filter(Boolean),
@@ -1,4 +1,5 @@
1
1
  import { Agent } from '@earendil-works/pi-agent-core';
2
+ import { randomUUID } from 'node:crypto';
2
3
  import { isContactSpokenPreamble, splitContactBubbles } from './bubbles.js';
3
4
  import {
4
5
  contactTurnClearedChatHistory,
@@ -103,8 +104,8 @@ export const CONTACT_SYSTEM_PROMPT = [
103
104
  'Reply in short chat bubbles: a few sentences each, separated by a blank line.',
104
105
  'Talk like a person in the user\'s language. One short spoken bubble at a time — never a wall of paragraphs.',
105
106
  'Reply in the language of the user\'s messages, unless they explicitly request another language. Infer it from their latest substantive message and conversation context, never from the app interface locale. For ambiguous messages or background follow-ups, continue the established conversation language.',
106
- 'Keep private reasoning and tool traces private. Communicate your next concrete action, verified milestones, and blockers in short natural messages in the same conversation language.',
107
- 'Before starting work, send a short message explaining the next action. During multi-step work, send a message when a meaningful result arrives or the direction changes. Publish these messages during execution; keep the final answer to the remaining outcome instead of repeating earlier updates.',
107
+ 'Keep private reasoning and tool traces private.',
108
+ 'Send a progress message when it tells the user something they do not already know: a direction they may want to correct, a finding that matters, a blocker, or that the work will take a while. Skip messages that would only repeat the plan or narrate a step. Keep the final answer to the remaining outcome instead of repeating earlier updates.',
108
109
  'Public message protocol: put each user-facing progress message at the START of your response in its own yuri-message JSON fence, with a single-line JSON object {"text":"Your short message"}. Then emit the next tool call or final answer. A closed message fence is delivered immediately while you are still generating. Include only text intended for the user. Tool results are evidence for you to summarize in your own words; never copy their stock confirmation wording into your reply.',
109
110
  'Do not expose tool traces, Activity, or editor actions.',
110
111
  'You have bash, read, write, and edit in the working directory. Use them for pwd, files, and shell. Never say you have no terminal or cannot read files. Ignore any temporary generator workspace in the environment.',
@@ -369,6 +370,7 @@ export function createContactStreamFn(createChatCompletion, {
369
370
  turnMessageStart = 0,
370
371
  variant = null,
371
372
  allowSilent = false,
373
+ cacheKey = randomUUID(),
372
374
  } = {}) {
373
375
  let callSequence = 0;
374
376
  const turnStart = Number.isFinite(Number(turnMessageStart)) ? Math.max(0, Number(turnMessageStart)) : 0;
@@ -403,14 +405,9 @@ export function createContactStreamFn(createChatCompletion, {
403
405
  }];
404
406
  }
405
407
  if (message.role === 'assistant') {
406
- const content = (message.content || []).map((part) => {
407
- if (part?.type === 'text') return part.text;
408
- if (part?.type !== 'toolCall') return '';
409
- return '```yuri-tool\n' + JSON.stringify({
410
- id: part.id, name: part.name, arguments: part.arguments,
411
- }) + '\n```';
412
- }).filter(Boolean).join('\n\n');
413
- return content ? [{ role: 'assistant', content }] : [];
408
+ const content = (message.content || []).filter(part => part?.type === 'text').map(part => part.text).join('\n\n');
409
+ const calls = (message.content || []).filter(part => part?.type === 'toolCall').map(part => ({ id: part.id, type: 'function', function: { name: part.name, arguments: JSON.stringify(part.arguments) } }));
410
+ return content || calls.length ? [{ role: 'assistant', content, ...(calls.length ? { tool_calls: calls } : {}) }] : [];
414
411
  }
415
412
  if (message.role === 'toolResult') {
416
413
  const content = (message.content || [])
@@ -423,10 +420,7 @@ export function createContactStreamFn(createChatCompletion, {
423
420
  const callId = typeof message.toolCallId === 'string' && message.toolCallId.trim()
424
421
  ? message.toolCallId.trim()
425
422
  : (typeof message.id === 'string' && message.id.trim() ? message.id.trim() : '');
426
- const label = callId
427
- ? `Yuri tool result name=${toolName} call=${callId}`
428
- : `Yuri tool result name=${toolName}`;
429
- return [{ role: 'user', content: `${label}: ${JSON.stringify({ isError: message.isError === true, content })}` }];
423
+ return [{ role: 'tool', name: toolName, tool_call_id: callId, content: JSON.stringify({ isError: message.isError === true, content }) }];
430
424
  }
431
425
  return [];
432
426
  });
@@ -455,7 +449,7 @@ export function createContactStreamFn(createChatCompletion, {
455
449
  signal,
456
450
  timeoutMs: 0,
457
451
  retryEmptyTextUntilCancelled: true,
458
- textEnvelope: true,
452
+ cacheKey,
459
453
  body: {
460
454
  model: `${model.provider === 'yuri' ? '' : `${model.provider}/`}${model.id}`.replace(/^\//, '') || model.name,
461
455
  providerID: typeof model.name === 'string' && model.name.includes('/')
@@ -464,6 +458,7 @@ export function createContactStreamFn(createChatCompletion, {
464
458
  modelID: model.id,
465
459
  ...(variant ? { variant } : {}),
466
460
  messages: [...messages],
461
+ tools: (context.tools || []).map(tool => ({ type: 'function', function: { name: tool.name, description: tool.description || tool.name, parameters: JSON.parse(JSON.stringify(tool.parameters ?? { type: 'object', properties: {} })) } })),
467
462
  },
468
463
  onTextDelta: (delta) => {
469
464
  if (signal?.aborted) return;
@@ -488,7 +483,12 @@ export function createContactStreamFn(createChatCompletion, {
488
483
  silent = finalResponse?.status === 'silent';
489
484
  finalText = finalResponse?.text ?? null;
490
485
  // A final answer is opaque text; quoted tool examples in it cannot run.
491
- parsed = finalText === null ? parseContactToolCalls(text, allowedNames) : { toolCalls: [], chatText: finalText };
486
+ const nativeCalls = result?.completion?.choices?.[0]?.message?.tool_calls ?? [];
487
+ parsed = nativeCalls.length ? {
488
+ toolCalls: nativeCalls.map(call => ({ id: call.id, name: call.function.name, arguments: JSON.parse(call.function.arguments) })),
489
+ chatText: text,
490
+ protocolError: finalText !== null ? 'Do not mix native tool calls with a final declaration.' : nativeCalls.some(call => !allowedNames.includes(call.function.name)) ? 'The requested tool is unavailable.' : '',
491
+ } : finalText === null ? parseContactToolCalls(text, allowedNames) : { toolCalls: [], chatText: finalText };
492
492
  const mixedBatch = parsed.toolCalls.length > 1 && parsed.toolCalls.some((call) => !isPiCodingToolName(call.name));
493
493
  const malformedFinal = finalText === null && /```yuri-final/u.test(parsed.chatText);
494
494
  const skippedRejectedWork = rejectedCodingCalls.length > 0 && finalResponse?.status === 'complete';
@@ -517,7 +517,7 @@ export function createContactStreamFn(createChatCompletion, {
517
517
  if (parsed.toolCalls.length > 0) {
518
518
  const toolCalls = parsed.toolCalls.map((call) => ({
519
519
  type: 'toolCall',
520
- id: `call_${Date.now().toString(36)}_${++callSequence}`,
520
+ id: call.id || `call_${Date.now().toString(36)}_${++callSequence}`,
521
521
  name: call.name,
522
522
  arguments: call.arguments,
523
523
  }));
@@ -682,6 +682,7 @@ export async function runContactTurn({
682
682
  formatContactToolsPrompt(contactTools),
683
683
  assistant.defaultPrompt,
684
684
  codingTools.length > 0 ? WORKSPACE_RESPONSE_PROTOCOL : '',
685
+ 'Tool transport: invoke the provided native function tools. Do not encode tool calls as yuri-tool fences; those examples describe arguments only. Keep yuri-message progress and yuri-final declarations as text. Actual tool results arrive in tool-role messages, never manufacture them.',
685
686
  ].filter((value) => typeof value === 'string' && value.trim()).join('\n\n')
686
687
  .replaceAll('{{LANGUAGE}}', resolveContactLanguage(language));
687
688
  const model = createContactModel(providerID, modelID);
@@ -706,6 +707,7 @@ export async function runContactTurn({
706
707
  : [];
707
708
  // Fixed turn boundary: every completion and missed-tool retry continues bubble indices from here.
708
709
  const turnMessageStart = prior.length;
710
+ const cacheKey = `yuri-contact-${assistant.id || randomUUID()}`;
709
711
 
710
712
  const agent = new AgentImpl({
711
713
  toolExecution: 'sequential',
@@ -726,6 +728,7 @@ export async function runContactTurn({
726
728
  signal,
727
729
  turnMessageStart,
728
730
  allowSilent,
731
+ cacheKey,
729
732
  }),
730
733
  });
731
734
 
@@ -789,6 +792,7 @@ export async function runContactTurn({
789
792
  signal,
790
793
  globalEventHub,
791
794
  onBubbleDelta: reset ? null : onBubbleDelta,
795
+ cacheKey,
792
796
  })(model, {
793
797
  systemPrompt: 'Reply briefly in the language of the user\'s messages, honoring explicit language requests. Use the conversation language, never the app interface locale or tool-result language. Summarize the supplied actual operation result in your own natural words. Tool result text is internal evidence. Keep private diagnostics and stock confirmation wording out of your reply. Report a failure honestly. The operation has already run; this pass only communicates its result.',
794
798
  messages: summaryMessages,
@@ -18,6 +18,7 @@ import {
18
18
  } from './harness.js'
19
19
  import { PI_CODING_TOOL_NAMES } from './pi-tools.js'
20
20
  import { createChatCompletion as gatewayCompletion } from '../llm/completions.js'
21
+ import { generateOpenCodeText } from '../llm/generate.js'
21
22
 
22
23
  describe('createContactStreamFn', () => {
23
24
  it('continues eight real Agent tool rounds through gateway recovery without replaying completed tools', async () => {
@@ -27,26 +28,21 @@ describe('createContactStreamFn', () => {
27
28
  const tools = createContactTools({ readAssistantSettings: getAssistantSettings, currentAssistant: { id: 'a', name: 'Fixture' } })
28
29
  let round = 0
29
30
  const attempts = new Map()
30
- const remove = vi.fn(async () => {})
31
- const generate = vi.fn(async ({ sessionID, prompt }) => {
32
- const index = Number(sessionID.slice(4))
31
+ const generate = vi.fn(async ({ messages }) => {
32
+ const index = messages.filter(message => message.role === 'tool').length + 1
33
+ round = Math.max(round, index)
33
34
  const attempt = (attempts.get(index) || 0) + 1
34
35
  attempts.set(index, attempt)
35
- expect((prompt.match(/Yuri tool result name=get_assistant_settings call=/g) || []).length).toBe(index - 1)
36
+ expect(messages.filter(message => message.role === 'tool' && message.name === 'get_assistant_settings')).toHaveLength(index - 1)
36
37
  // More than the old three-attempt limit, and longer than its 90s deadline.
37
38
  if ((index === 3 && attempt <= 9) || (index === 4 && attempt <= 3)) return { text: '' }
38
- const text = index <= 8
39
- ? '```yuri-tool\n{"name":"get_assistant_settings","arguments":{}}\n```'
40
- : '```yuri-final\n{"status":"complete","text":"Verified all eight steps."}\n```'
41
- return { text: JSON.stringify({ text }) }
39
+ return index <= 8
40
+ ? { text: '', toolCalls: [{ id: `call_${index}`, name: 'get_assistant_settings', arguments: {} }], finishReason: 'tool-calls' }
41
+ : { text: '```yuri-final\n{"status":"complete","text":"Verified all eight steps."}\n```', toolCalls: [], finishReason: 'stop' }
42
42
  })
43
- const client = {
44
- agent: { get: async () => ({ data: { id: 'yuri-text', permissions: [{ action: '*', resource: '*', effect: 'deny' }] } }) },
45
- session: { create: async () => ({ id: `ses_${++round}` }), generate, remove, interrupt: vi.fn() },
46
- }
47
43
  const completion = (input) => gatewayCompletion({
48
44
  ...input, buildOpenCodeUrl: () => 'http://127.0.0.1:4096', getOpenCodeAuthHeaders: () => ({}),
49
- clientFactory: () => client, ensureTempDirectory: async () => '/tmp/yuri-text',
45
+ generateText: (input) => generateOpenCodeText({ ...input, generateCompletion: generate }),
50
46
  loadCatalog: async () => ({ models: [{ providerID: 'p', modelID: 'm' }] }),
51
47
  })
52
48
  const outcome = runContactTurn({
@@ -58,7 +54,6 @@ describe('createContactStreamFn', () => {
58
54
  expect(getAssistantSettings).toHaveBeenCalledTimes(8)
59
55
  expect(round).toBe(9)
60
56
  expect(generate).toHaveBeenCalledTimes(21)
61
- expect(remove).toHaveBeenCalledTimes(9)
62
57
  expect(vi.getTimerCount()).toBe(0)
63
58
  } finally { vi.useRealTimers() }
64
59
  })
@@ -76,7 +71,8 @@ describe('createContactStreamFn', () => {
76
71
  expect(completion.mock.calls.length).toBeGreaterThan(0);
77
72
  for (const [request] of completion.mock.calls) {
78
73
  expect(request.body.variant).toBe('high');
79
- expect(request).toMatchObject({ timeoutMs: 0, retryEmptyTextUntilCancelled: true, textEnvelope: true });
74
+ expect(request).toMatchObject({ timeoutMs: 0, retryEmptyTextUntilCancelled: true });
75
+ expect(typeof request.cacheKey).toBe('string');
80
76
  }
81
77
  expect(result.bubbles).toEqual(['已完成。']);
82
78
  expect(JSON.stringify(onBubbleDelta.mock.calls)).not.toContain('Private reasoning');
@@ -128,7 +124,7 @@ describe('createContactStreamFn', () => {
128
124
  currentAssistant: { id: 'a', name: 'Config' },
129
125
  })
130
126
  const completion = vi.fn(async ({ body }) => {
131
- const result = body.messages.find((m) => m.content.includes('Yuri tool result name=update_default_prompt'))
127
+ const result = body.messages.find((m) => m.role === 'tool' && m.name === 'update_default_prompt')
132
128
  if (result) {
133
129
  expect(result.content).toContain('Default prompt saved.')
134
130
  return { text: '```yuri-final\n{"status":"complete","text":"提示词已保存,接下来的对话会按这个设置回复。"}\n```' }
@@ -233,7 +229,7 @@ describe('createContactStreamFn', () => {
233
229
  expect(system).toContain('small, clearly scoped configuration changes directly')
234
230
  expect(system).toContain('walk its parent directories')
235
231
  expect(system).toContain('Look up existing OpenCode conversations with list_sessions')
236
- const result = body.messages.find((message) => typeof message.content === 'string' && message.content.includes('tool result name=read'))
232
+ const result = body.messages.find((message) => message.role === 'tool' && message.name === 'read')
237
233
  if (result) {
238
234
  expect(result.content).toContain('configured value')
239
235
  return { completion: { choices: [{ message: { content: '```yuri-final\n{"status":"complete","text":"configured value"}\n```' } }] } }
@@ -607,7 +603,7 @@ describe('runContactTurn', () => {
607
603
  expect(result.text).toBe(example)
608
604
  expect(createChatCompletion).toHaveBeenCalledTimes(3)
609
605
  const messages = createChatCompletion.mock.calls[1][0].body.messages
610
- const emptyResult = messages.find((message) => message.content.includes('tool result name=bash'))
606
+ const emptyResult = messages.find((message) => message.role === 'tool' && message.name === 'bash')
611
607
  expect(emptyResult).toBeTruthy()
612
608
  expect(emptyResult.content).toContain('"isError":false')
613
609
  } finally {
@@ -639,11 +635,11 @@ describe('runContactTurn', () => {
639
635
  expect(result.text).toBe('已写入并验证。')
640
636
  expect(createChatCompletion).toHaveBeenCalledTimes(4)
641
637
  const lastRequest = createChatCompletion.mock.calls.at(-1)[0].body.messages
642
- const calls = lastRequest.filter((m) => m.role === 'assistant').map((m) => m.content).join('\n')
638
+ const calls = JSON.stringify(lastRequest.filter((m) => m.role === 'assistant'))
643
639
  expect(calls).toContain('"name":"read"')
644
640
  expect(calls).toContain('"name":"write"')
645
- expect(calls).toContain('"path":"result.txt"')
646
- const results = lastRequest.filter((m) => m.role === 'user' && m.content.includes('tool result name='))
641
+ expect(lastRequest.flatMap(message => message.tool_calls ?? []).map(call => JSON.parse(call.function.arguments))).toContainEqual(expect.objectContaining({ path: 'result.txt' }))
642
+ const results = lastRequest.filter((m) => m.role === 'tool')
647
643
  expect(results).toHaveLength(3)
648
644
  expect(results.at(-1).content).toContain('verified note')
649
645
  expect(onBubbleDelta.mock.calls.map((call) => call[1]).join('')).not.toContain('我先')
@@ -744,7 +740,7 @@ describe('runContactTurn', () => {
744
740
  // Tool call/result association: after read, the next completion sees a named tool result.
745
741
  const secondMessages = createChatCompletion.mock.calls[1][0].body.messages
746
742
  const toolResultTurn = secondMessages.find((message) => (
747
- message.role === 'user' && typeof message.content === 'string' && message.content.includes('tool result name=read')
743
+ message.role === 'tool' && message.name === 'read'
748
744
  ))
749
745
  expect(toolResultTurn).toBeTruthy()
750
746
  expect(toolResultTurn.content).toMatch(/Read project docs|documentation/i)
@@ -814,7 +810,7 @@ describe('runContactTurn', () => {
814
810
  }
815
811
  const last = body.messages.at(-1)
816
812
  const lastText = typeof last?.content === 'string' ? last.content : ''
817
- if (lastText.includes('tool result name=list_projects') || lastText.includes('Registered projects')) {
813
+ if (body.messages.at(-1)?.name === 'list_projects' || lastText.includes('Registered projects')) {
818
814
  return {
819
815
  completion: {
820
816
  choices: [{
@@ -23,9 +23,9 @@ const listen = async (app) => {
23
23
  const final = (text) => ({ text: '```yuri-final\n' + JSON.stringify({ status: 'complete', text }) + '\n```' });
24
24
  const call = (name, args) => ({ text: '```yuri-tool\n' + JSON.stringify({ name, arguments: args }) + '\n```' });
25
25
  const resultFor = (body, name) => {
26
- const row = body.messages.findLast((m) => m.content?.startsWith(`Yuri tool result name=${name} `));
26
+ const row = body.messages.findLast((m) => m.role === 'tool' && m.name === name);
27
27
  if (!row) return null;
28
- return JSON.parse(row.content.slice(row.content.indexOf(': ') + 2));
28
+ return JSON.parse(row.content);
29
29
  };
30
30
  const setup = async (existingDirectory = null) => {
31
31
  const directory = existingDirectory || fs.mkdtempSync(path.join(os.tmpdir(), 'yuri-memory-http-'));
@@ -1,7 +1,6 @@
1
1
  import { AssistantError, createAssistantsService } from './service.js';
2
2
  import { isSafeInlineImageMime } from './contact-attachments.js';
3
3
  import { createChatCompletion } from '../llm/completions.js';
4
- import { ensureLlmTempDirectory } from '../llm/temp-directory.js';
5
4
  import { setAssignedSessionSettleHandler } from '../session-goal/runtime.js';
6
5
  import { makeOpenCodeV2Client } from '../opencode/v2-client.js';
7
6
 
@@ -17,8 +16,7 @@ export const registerAssistantRoutes = (app, dependencies) => {
17
16
  baseUrl: dependencies.buildOpenCodeUrl('/', '').replace(/\/$/, ''),
18
17
  authHeaders: dependencies.getOpenCodeAuthHeaders(),
19
18
  }),
20
- ensureTempDirectory: ensureLlmTempDirectory,
21
- // Attachment-session generate may subscribe for session.text.delta (contact harness).
19
+ // Contact activity continues through the existing event hub; inference executes no OpenCode tools.
22
20
  globalEventHub: input?.globalEventHub ?? dependencies.globalEventHub,
23
21
  persistSessionMetadata: dependencies.persistSessionMetadata,
24
22
  onSystemSessionPersisted: dependencies.onSystemSessionPersisted,