@yuriai/web 0.2.7 → 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.
- package/README.md +7 -0
- package/dist/assets/{AssistantView-Be0OKo5o.js → AssistantView-Df-G2DX8.js} +3 -3
- package/dist/assets/{DiagramView-Rpb6oenk.js → DiagramView-BoVqJRQb.js} +1 -1
- package/dist/assets/{GuiPluginSurface-DTH9jNDf.js → GuiPluginSurface-DxLoeTDb.js} +1 -1
- package/dist/assets/MarkdownRenderer-DYi_qpYy.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-CZ9lU4VJ.js → MarkdownRendererImpl-CMxRMFqp.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-DastQdu7.js → MarkstreamRendererImpl-DQ4urBZW.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-CittPDZ0.js → MobileDetailNavigation-C4fJlKdu.js} +1 -1
- package/dist/assets/{MobileShareBridge-BxsoZnUJ.js → MobileShareBridge-DLC-TdRy.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-BEgQ3L4u.js → MobileTabPageHeader-CMbbtHh7.js} +1 -1
- package/dist/assets/{MultiRunWindow-1o528NZE.js → MultiRunWindow-Cwp8-_Wh.js} +1 -1
- package/dist/assets/{SettingsView-BGEaQC4R.js → SettingsView-CYDk0wpN.js} +1 -1
- package/dist/assets/{SettingsWindow-MuJFADe3.js → SettingsWindow-Vuzphf9b.js} +1 -1
- package/dist/assets/{TerminalView-CHDyibi_.js → TerminalView-Dhalx6_Z.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Bcry3eoE.js → ToolOutputDialog-DBxSxWNh.js} +1 -1
- package/dist/assets/{appThemeRegistry-CJoBy_eP.js → appThemeRegistry-JEhMXHGF.js} +1 -1
- package/dist/assets/{capgoAdapter-_oWtDrgf.js → capgoAdapter-BgD0wyhC.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-7KLhnK1O.js → fileMentionTouchSelection-BQdfRBkk.js} +1 -1
- package/dist/assets/{gitApi-BEXddXMX.js → gitApi-DhDVqj9b.js} +1 -1
- package/dist/assets/{insertionBoundaries-HkddYmJd.js → insertionBoundaries-BMe1F3uB.js} +1 -1
- package/dist/assets/{main-CXE9lij2.js → main-CfOYzhn0.js} +4 -4
- package/dist/assets/{main-BKkCvf3L.js → main-DXlMu2LF.js} +2 -2
- package/dist/assets/{mcpQueries-xfKOWrAa.js → mcpQueries-vxcQAIGB.js} +1 -1
- package/dist/assets/{miniChat-BKr-HXzy.js → miniChat-D48iGEEW.js} +2 -2
- package/dist/assets/{mobile-CGL4wWLz.js → mobile-Cy5qSiDY.js} +2 -2
- package/dist/assets/{mobileBackNavigation-VzxRWLxN.js → mobileBackNavigation-QtBK9OSb.js} +1 -1
- package/dist/assets/{multirun-BmF58wXR.js → multirun-BR9a6EBo.js} +1 -1
- package/dist/assets/{native-config-CYjStyIM.js → native-config-CHySeHif.js} +1 -1
- package/dist/assets/{projectMeta-DhdEWvmC.js → projectMeta-Bn2vBNDe.js} +1 -1
- package/dist/assets/{readiness-uM7foMQ8.js → readiness-BAssoNVf.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CYjZYsCZ.js → renderElectronMiniChatApp-B9Kci_8q.js} +2 -2
- package/dist/assets/{renderMobileApp-Dy2bPXrM.js → renderMobileApp-CBivL8Ps.js} +4 -4
- package/dist/assets/{runtimeConfig-Cjjf4017.js → runtimeConfig-COdEwlK-.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-CNyugOcU.js → runtimeEndpointReset-D3x76Qpf.js} +3 -3
- package/dist/assets/{sessionChangeSummary-5npOjhNG.js → sessionChangeSummary-Dtgq0CWg.js} +1 -1
- package/dist/assets/{sessionLookup-ClhS_rqE.js → sessionLookup--Wlr3e8X.js} +1 -1
- package/dist/assets/{speechSettingsQueries-CpOY2X9w.js → speechSettingsQueries-D3fc_4Iy.js} +1 -1
- package/dist/assets/types-D8_26ZKT.js +2 -0
- package/dist/assets/{useAppFontEffects-BMXDDJtn.js → useAppFontEffects-DLT9jVl1.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-l2q0zXMx.js → useDesktopWindowControlsLayout-BNAZWH9L.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-rDw8BJo1.js → useEffectiveDirectory-D2_-KCB7.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-EmnPOl61.js → useMobileNavigationStore-DJwk64Po.js} +3 -3
- package/dist/assets/{useWorkerHighlightedLines-up7t7cwh.js → useWorkerHighlightedLines-k48txabk.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +9 -4
- package/server/index.js +3 -3
- package/server/lib/assistants/DOCUMENTATION.md +11 -0
- package/server/lib/assistants/harness.js +19 -15
- package/server/lib/assistants/harness.test.js +19 -23
- package/server/lib/assistants/memory.http.test.js +2 -2
- package/server/lib/assistants/routes.js +1 -3
- package/server/lib/llm/DOCUMENTATION.md +116 -161
- package/server/lib/llm/bridge-client.js +60 -0
- package/server/lib/llm/bridge-client.test.js +35 -0
- package/server/lib/llm/bridge-contract.js +24 -0
- package/server/lib/llm/bridge-plugin.bundle.js +1136 -0
- package/server/lib/llm/bridge-plugin.js +127 -0
- package/server/lib/llm/bridge-plugin.test.js +164 -0
- package/server/lib/llm/completions.js +42 -18
- package/server/lib/llm/completions.test.js +8 -4
- package/server/lib/llm/generate.js +43 -728
- package/server/lib/llm/generate.test.js +62 -1063
- package/server/lib/llm/routes.js +0 -2
- package/server/lib/small-model/DOCUMENTATION.md +11 -17
- package/server/lib/small-model/index.js +5 -4
- package/dist/assets/MarkdownRenderer-Dk1A4sLM.js +0 -2
- package/dist/assets/types-C2ml30_A.js +0 -2
- package/server/lib/llm/temp-directory.js +0 -58
- package/server/lib/llm/temp-directory.test.js +0 -57
package/dist/assets/{useWorkerHighlightedLines-up7t7cwh.js → useWorkerHighlightedLines-k48txabk.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{v as r}from"./useUIStore-NMQx_cnG.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{f as a,r as o,t as s}from"./button-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-
|
|
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,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),F=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,I=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=F(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},L=e=>`<pre><code>${P(e)}</code></pre>`,R=e=>{let t=(0,x.c)(21),{code:n,language:r,className:i,style:a,codeStyle:s,wrap:l}=e,u=l!==void 0&&l,{currentTheme:d}=c(),f=b.useRef(null),p;t[0]===d?p=t[1]:(p=_(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-
|
|
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-
|
|
595
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
596
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
597
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
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">
|
package/dist/mini-chat.html
CHANGED
|
@@ -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-
|
|
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-
|
|
112
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
113
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
114
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
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-
|
|
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-
|
|
99
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
100
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
101
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
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.
|
|
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 {
|
|
2246
|
-
await
|
|
2245
|
+
const { stopLlmBridgeDirectory } = await import('./lib/llm/bridge-client.js');
|
|
2246
|
+
await stopLlmBridgeDirectory();
|
|
2247
2247
|
} catch {
|
|
2248
|
-
// best-effort cleanup of the LLM
|
|
2248
|
+
// best-effort cleanup of the isolated LLM bridge directory
|
|
2249
2249
|
}
|
|
2250
2250
|
return gracefulShutdown({
|
|
2251
2251
|
exitProcess: shutdownOptions.exitProcess ?? false,
|
|
@@ -174,6 +174,17 @@ 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
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.
|
|
@@ -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,
|
|
@@ -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(
|
|
407
|
-
|
|
408
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
31
|
-
|
|
32
|
-
|
|
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(
|
|
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
|
-
|
|
39
|
-
? '
|
|
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
|
-
|
|
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
|
|
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.
|
|
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) =>
|
|
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.
|
|
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')
|
|
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(
|
|
646
|
-
const results = lastRequest.filter((m) => m.role === '
|
|
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 === '
|
|
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 (
|
|
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.
|
|
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
|
|
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
|
-
|
|
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,
|