@yuriai/web 0.2.7 → 0.2.8-beta.2
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-BjpY2u0c.js} +3 -3
- package/dist/assets/{DiagramView-Rpb6oenk.js → DiagramView-7j0sZC_P.js} +1 -1
- package/dist/assets/{GuiPluginSurface-DTH9jNDf.js → GuiPluginSurface-D_TK-2vZ.js} +1 -1
- package/dist/assets/MarkdownRenderer-B8zgOCfr.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-CZ9lU4VJ.js → MarkdownRendererImpl-Dh7XVDLd.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-DastQdu7.js → MarkstreamRendererImpl-D-qtRrvg.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-CittPDZ0.js → MobileDetailNavigation-LkTVYLZX.js} +1 -1
- package/dist/assets/{MobileShareBridge-BxsoZnUJ.js → MobileShareBridge-CsTyKMtN.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-BEgQ3L4u.js → MobileTabPageHeader-xz9RMXg4.js} +1 -1
- package/dist/assets/{MultiRunWindow-1o528NZE.js → MultiRunWindow-hMpjV7so.js} +1 -1
- package/dist/assets/{SettingsView-BGEaQC4R.js → SettingsView-D8qpss-X.js} +1 -1
- package/dist/assets/{SettingsWindow-MuJFADe3.js → SettingsWindow-B1VuFkFq.js} +1 -1
- package/dist/assets/{TerminalView-CHDyibi_.js → TerminalView-CLcaJh2M.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Bcry3eoE.js → ToolOutputDialog-BuZo3XvN.js} +1 -1
- package/dist/assets/{appThemeRegistry-CJoBy_eP.js → appThemeRegistry-B7sp1Hw8.js} +1 -1
- package/dist/assets/{capgoAdapter-_oWtDrgf.js → capgoAdapter-vxOdqloD.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-7KLhnK1O.js → fileMentionTouchSelection-DspnKU8D.js} +1 -1
- package/dist/assets/{gitApi-BEXddXMX.js → gitApi-BLYdWaG8.js} +1 -1
- package/dist/assets/{insertionBoundaries-HkddYmJd.js → insertionBoundaries-DqlfZVY9.js} +1 -1
- package/dist/assets/{main-BKkCvf3L.js → main-DA7z198b.js} +2 -2
- package/dist/assets/{main-CXE9lij2.js → main-Qw23QJ7L.js} +4 -4
- package/dist/assets/{mcpQueries-xfKOWrAa.js → mcpQueries-C6Tu2cF3.js} +1 -1
- package/dist/assets/{miniChat-BKr-HXzy.js → miniChat-HafcB3H-.js} +2 -2
- package/dist/assets/{mobile-CGL4wWLz.js → mobile-DwXoGpxm.js} +2 -2
- package/dist/assets/{mobileBackNavigation-VzxRWLxN.js → mobileBackNavigation-9MR5h5K6.js} +1 -1
- package/dist/assets/{multirun-BmF58wXR.js → multirun-D-je_w02.js} +1 -1
- package/dist/assets/{native-config-CYjStyIM.js → native-config-Bb3pPQPD.js} +1 -1
- package/dist/assets/{projectMeta-DhdEWvmC.js → projectMeta-DaCyZW_D.js} +1 -1
- package/dist/assets/{readiness-uM7foMQ8.js → readiness-BHqz_NPS.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CYjZYsCZ.js → renderElectronMiniChatApp-COaMALRh.js} +2 -2
- package/dist/assets/{renderMobileApp-Dy2bPXrM.js → renderMobileApp-BOGntDSu.js} +4 -4
- package/dist/assets/{runtimeConfig-Cjjf4017.js → runtimeConfig-BiSluBXe.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-CNyugOcU.js → runtimeEndpointReset-CJwlI_R-.js} +3 -3
- package/dist/assets/{sessionChangeSummary-5npOjhNG.js → sessionChangeSummary-BAv8zzro.js} +1 -1
- package/dist/assets/{sessionLookup-ClhS_rqE.js → sessionLookup-DOw7g15p.js} +1 -1
- package/dist/assets/{speechSettingsQueries-CpOY2X9w.js → speechSettingsQueries-B8zEN5QM.js} +1 -1
- package/dist/assets/types-BiP0jssb.js +2 -0
- package/dist/assets/{useAppFontEffects-BMXDDJtn.js → useAppFontEffects-De1qI6c-.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-l2q0zXMx.js → useDesktopWindowControlsLayout-BzXi6Wf1.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-rDw8BJo1.js → useEffectiveDirectory-BcbBl_6y.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-EmnPOl61.js → useMobileNavigationStore-DqDCVXO1.js} +3 -3
- package/dist/assets/{useWorkerHighlightedLines-up7t7cwh.js → useWorkerHighlightedLines-CDVleuma.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 +14 -0
- package/server/lib/assistants/contact-tools.js +145 -10
- package/server/lib/assistants/contact-tools.test.js +11 -2
- package/server/lib/assistants/harness.js +23 -16
- package/server/lib/assistants/harness.test.js +76 -23
- package/server/lib/assistants/memory.http.test.js +2 -2
- package/server/lib/assistants/routes.js +2 -3
- package/server/lib/assistants/service.js +66 -1
- package/server/lib/assistants/service.test.js +37 -0
- package/server/lib/llm/DOCUMENTATION.md +119 -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 +43 -18
- package/server/lib/llm/completions.test.js +17 -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/opencode/feature-routes-runtime.js +1 -0
- 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-CDVleuma.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-B8zgOCfr.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-DA7z198b.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-BiP0jssb.js">
|
|
595
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-vxOdqloD.js">
|
|
596
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-Bb3pPQPD.js">
|
|
597
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BiSluBXe.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-HafcB3H-.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-BiP0jssb.js">
|
|
112
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-vxOdqloD.js">
|
|
113
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-Bb3pPQPD.js">
|
|
114
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BiSluBXe.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-DwXoGpxm.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-BiP0jssb.js">
|
|
99
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-vxOdqloD.js">
|
|
100
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-Bb3pPQPD.js">
|
|
101
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BiSluBXe.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.2",
|
|
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.
|
|
@@ -243,6 +254,9 @@ Reply language follows the user's latest substantive message and conversation co
|
|
|
243
254
|
|
|
244
255
|
- `create_assistant` calls the same in-process `createAssistant` (`name`, connected OpenCode `providerID`/`modelID`, `mode: 'continuous'`). It emits an `assistant` card that opens that contact.
|
|
245
256
|
- `schedule_task` calls in-process `projectConfigRuntime.upsertScheduledTask` with the same payload as `PUT /api/projects/:id/scheduled-tasks` (`name`, `schedule.kind/time/timezone`, `execution.prompt` + provider/model) on a registered project, then best-effort `scheduledTasksRuntime.syncProject`. It emits a `schedule` card.
|
|
257
|
+
- `list_scheduled_tasks` lists registered projects' tasks with exact task/project IDs, schedule, model and a bounded prompt preview. Failed project reads remain explicit partial failures. Read-only background turns may list but cannot modify tasks.
|
|
258
|
+
- `update_scheduled_task` uses the existing project-config patch operation and scheduler sync, changing only supplied fields and validating explicit models against the connected catalog. It emits the existing schedule card; it can edit tasks created outside the Assistant.
|
|
259
|
+
- Native and legacy text calls share the same tool-name validation and shell-alias normalization. `shell`, `powershell`, `grep`, `glob`, `find` and `ls` may resolve to the existing `bash` tool only when it is available. Native call IDs survive normalization. Unknown tool corrections identify the rejected name and available tools, without executing a rejected prefix. The contact harness owns bounded correction; generic completion callers retain strict tool-name validation.
|
|
246
260
|
- Successful `schedule_task` also writes an assistants-owned mapping row in `assistants.sqlite` (`assistant_scheduled_task`: assistantID + projectID + taskID). Project-config execution strips unknown fields, so ownership stays out of the task payload. `GET /api/yuri/assistants/:id/scheduled-tasks` returns those mappings joined with live `listScheduledTasks` records when possible; failed project lookups keep the mapping with `task: null`.
|
|
247
261
|
- `CONTACT_SYSTEM_PROMPT` + `formatContactToolsPrompt` + `formatPiCodingPrompt` tell the model to call these from natural language (开新对话 / 找项目 / 现有对话 / 查看助手设定·默认提示词 / 改默认提示词·设置人设 / 建助理 / 建会话·继续会话 / 监听会话 / 停止会话 / 排定时任务 / 给 X 说一声). Catalog lines include each tool's JSON argument schema (pi `write`/`edit` require `path`+`content` / `path`+`edits[{oldText,newText}]`). A reply without the tool call does nothing; never say 已创建 / 已发送 / 已停止 unless the tool returned. Completions are messages-only (no native tools), so `parseContactToolCalls` accepts a fence, a whole-message JSON object, or a bare `{name, arguments}` object anywhere in the reply. Tool results are re-injected as user turns labeled `Yuri tool result name=<tool> call=<id>` with JSON `{ isError, content }`; assistant calls and their arguments/IDs are also retained so multi-step turns keep call/result association. The harness replaces every `{{LANGUAGE}}` token — in the built-in prompt and in `defaultPrompt` — with the UI locale sent on the composer payload (`language` field, whitelisted locale code → display name). Background/settle turns recall the last locale seen for that assistant; unknown or missing locales resolve to `the user's interface language`, so the token never leaks into the prompt.
|
|
248
262
|
- If the user asked for `new_conversation` / `clear_chat_history` / `list_projects` / `list_sessions` / `get_assistant_settings` / `update_default_prompt` / `create_assistant` / `schedule_task` / `message_assistant` / `watch_session` / `stop_session` / `assign_session` and the first completion has no tool call, the harness runs **one** follow-up completion whose user content is only `emit the fence now, do not claim success.` If still no tool, the turn replies that it could not complete and does not fake a card. No slash commands. No second store.
|
|
@@ -30,6 +30,8 @@ export const ARCHIVE_SESSION_TOOL_NAME = 'archive_session';
|
|
|
30
30
|
export const DELETE_SESSION_TOOL_NAME = 'delete_session';
|
|
31
31
|
export const CREATE_ASSISTANT_TOOL_NAME = 'create_assistant';
|
|
32
32
|
export const SCHEDULE_TASK_TOOL_NAME = 'schedule_task';
|
|
33
|
+
const LIST_SCHEDULED_TASKS_TOOL_NAME = 'list_scheduled_tasks';
|
|
34
|
+
const UPDATE_SCHEDULED_TASK_TOOL_NAME = 'update_scheduled_task';
|
|
33
35
|
export const MESSAGE_ASSISTANT_TOOL_NAME = 'message_assistant';
|
|
34
36
|
export const NEW_CONVERSATION_TOOL_NAME = 'new_conversation';
|
|
35
37
|
export const CLEAR_CHAT_HISTORY_TOOL_NAME = 'clear_chat_history';
|
|
@@ -90,11 +92,38 @@ export function normalizeAssignRequestKey(params = {}) {
|
|
|
90
92
|
});
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
|
|
95
|
+
// Common shell-style tool names that models emit from other harnesses. They run
|
|
96
|
+
// through the real bash tool instead of being rejected.
|
|
97
|
+
const BASH_ALIAS_TOOLS = new Set(['shell', 'powershell', 'grep', 'glob', 'find', 'ls']);
|
|
98
|
+
const shellQuote = (value) => `'${String(value).replace(/'/g, `'\\''`)}'`;
|
|
99
|
+
const aliasString = (args, ...keys) => {
|
|
100
|
+
for (const key of keys) {
|
|
101
|
+
if (typeof args?.[key] === 'string' && args[key].trim()) return args[key].trim();
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
};
|
|
105
|
+
const bashAliasCommand = (name, args = {}) => {
|
|
106
|
+
const command = aliasString(args, 'command', 'cmd', 'script');
|
|
107
|
+
if (command) return command;
|
|
108
|
+
const target = shellQuote(aliasString(args, 'path', 'directory', 'dir', 'cwd') || '.');
|
|
109
|
+
const pattern = aliasString(args, 'pattern', 'query', 'regex', 'name', 'glob');
|
|
110
|
+
if (name === 'ls') return `ls -la ${target}`;
|
|
111
|
+
if (!pattern) return null;
|
|
112
|
+
if (name === 'grep') {
|
|
113
|
+
const include = aliasString(args, 'include', 'glob', 'filePattern');
|
|
114
|
+
const quoted = shellQuote(pattern);
|
|
115
|
+
return include && include !== pattern
|
|
116
|
+
? `if command -v rg >/dev/null 2>&1; then rg -n -g ${shellQuote(include)} -e ${quoted} ${target}; else grep -rnE --include=${shellQuote(include)} -e ${quoted} ${target}; fi`
|
|
117
|
+
: `if command -v rg >/dev/null 2>&1; then rg -n -e ${quoted} ${target}; else grep -rnE -e ${quoted} ${target}; fi`;
|
|
118
|
+
}
|
|
119
|
+
return `if command -v rg >/dev/null 2>&1; then rg --files -g ${shellQuote(pattern)} ${target}; else find ${target} -name ${shellQuote(pattern)}; fi`;
|
|
120
|
+
};
|
|
94
121
|
|
|
95
122
|
export const MISSED_FENCE_RETRY_USER_TEXT = 'emit the fence now, do not claim success.';
|
|
96
123
|
|
|
97
124
|
const CREATE_ASSISTANT_INTENT = /建助理|新建[^。\n!]{0,24}助理|创建[^。\n!]{0,24}助理|加一个助理|create (?:an |a new )?assistant|new assistant/iu;
|
|
125
|
+
// Changing or reviewing existing tasks starts with list_scheduled_tasks, not schedule_task.
|
|
126
|
+
const UPDATE_SCHEDULED_TASK_INTENT = /(?:改|修改|更新|换|切换|暂停|停用|启用|查看|看看|列出)[^。\n]{0,24}定时任务|定时任务[^。\n]{0,40}(?:改|换成|换为|切换|暂停|停用|启用|有哪些|列表)|(?:update|change|edit|pause|disable|enable|list)[^.\n]{0,24}scheduled tasks?/iu;
|
|
98
127
|
const SCHEDULE_TASK_INTENT = /排定时任务|排个?定时任务|定时任务|schedule (?:a )?(?:daily )?(?:task|ping)|scheduled task|排个?(?:每日)?(?:任务|ping)/iu;
|
|
99
128
|
const ASSIGN_SESSION_INTENT = /(?:建|开)(?:一个|个)?(?:新)?(?:编码\s*)?(?:session|会话)|继续(?:这个|该|那个)?(?:编码\s*)?(?:session|会话)|open (?:a )?(?:coding )?session|continue (?:the |this |that )?(?:coding )?session|assign_session/giu;
|
|
100
129
|
const WATCH_SESSION_INTENT = /监听(?:这个|该|那个)?(?:编码\s*)?(?:session|会话)|关注(?:这个|该|那个)?(?:编码\s*)?(?:session|会话)|watch (?:the |this |that )?(?:coding )?session|monitor (?:the |this |that )?(?:coding )?session|watch_session/giu;
|
|
@@ -170,6 +199,28 @@ const scheduleTaskParameters = typeboxObject({
|
|
|
170
199
|
model: typeboxOptional(typeboxString('Optional provider/model string such as opencode-go/deepseek-v4-flash.')),
|
|
171
200
|
});
|
|
172
201
|
|
|
202
|
+
const listScheduledTasksParameters = typeboxObject({
|
|
203
|
+
projectPath: typeboxOptional(typeboxString('Registered project path or id to limit the listing. Omit to list every registered project.')),
|
|
204
|
+
query: typeboxOptional(typeboxString('Optional filter against task name, id, prompt, or provider/model.')),
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const updateScheduledTaskParameters = typeboxObject({
|
|
208
|
+
taskID: typeboxString('Exact task id from list_scheduled_tasks.'),
|
|
209
|
+
projectID: typeboxString('Exact project id from list_scheduled_tasks.'),
|
|
210
|
+
name: typeboxOptional(typeboxString('New task name.')),
|
|
211
|
+
enabled: typeboxOptional(typeboxString('"true" or "false" to enable or pause the task.')),
|
|
212
|
+
prompt: typeboxOptional(typeboxString('New prompt for the scheduled run.')),
|
|
213
|
+
providerID: typeboxOptional(typeboxString('New OpenCode provider ID from the connected catalog.')),
|
|
214
|
+
modelID: typeboxOptional(typeboxString('New OpenCode model ID from the connected catalog.')),
|
|
215
|
+
model: typeboxOptional(typeboxString('New provider/model string from the connected catalog.')),
|
|
216
|
+
kind: typeboxOptional(typeboxString('New schedule kind: daily, weekly, once, or cron.')),
|
|
217
|
+
time: typeboxOptional(typeboxString('New HH:mm local time.')),
|
|
218
|
+
timezone: typeboxOptional(typeboxString('New IANA timezone.')),
|
|
219
|
+
date: typeboxOptional(typeboxString('YYYY-MM-DD for kind=once.')),
|
|
220
|
+
weekdays: typeboxOptional(typeboxString('Comma-separated 0-6 weekdays for kind=weekly.')),
|
|
221
|
+
cron: typeboxOptional(typeboxString('Cron expression for kind=cron.')),
|
|
222
|
+
});
|
|
223
|
+
|
|
173
224
|
const messageAssistantParameters = typeboxObject({
|
|
174
225
|
text: typeboxString('Read-only message to insert into the other assistant contact transcript.'),
|
|
175
226
|
to: typeboxOptional(typeboxString('Recipient assistant display name, e.g. PeerQA.')),
|
|
@@ -349,8 +400,8 @@ export function boundSessionListLimit(value) {
|
|
|
349
400
|
const allowedToolName = (name, allowedNames) => {
|
|
350
401
|
if (typeof name !== 'string' || !name.trim()) return false;
|
|
351
402
|
const next = name.trim();
|
|
352
|
-
if (
|
|
353
|
-
return
|
|
403
|
+
if (allowedNames.has(next)) return true;
|
|
404
|
+
return BASH_ALIAS_TOOLS.has(next) && allowedNames.has('bash');
|
|
354
405
|
};
|
|
355
406
|
|
|
356
407
|
const parseToolPayload = (raw, allowedNames) => {
|
|
@@ -365,9 +416,43 @@ const parseToolPayload = (raw, allowedNames) => {
|
|
|
365
416
|
if (!allowedToolName(name, allowedNames)) return null;
|
|
366
417
|
const args = parsed.arguments;
|
|
367
418
|
if (args != null && (typeof args !== 'object' || Array.isArray(args))) return null;
|
|
368
|
-
|
|
419
|
+
const normalizedArgs = args && typeof args === 'object' ? args : {};
|
|
420
|
+
if (!allowedNames.has(name) && BASH_ALIAS_TOOLS.has(name)) {
|
|
421
|
+
const command = bashAliasCommand(name, normalizedArgs);
|
|
422
|
+
if (!command) return null;
|
|
423
|
+
const timeout = typeof normalizedArgs.timeout === 'number' ? { timeout: normalizedArgs.timeout } : {};
|
|
424
|
+
return { name: 'bash', arguments: { command, ...timeout } };
|
|
425
|
+
}
|
|
426
|
+
return { name, arguments: normalizedArgs };
|
|
369
427
|
};
|
|
370
428
|
|
|
429
|
+
const describeRejectedToolPayload = (raw, allowedNames) => {
|
|
430
|
+
const fallback = 'Invalid or unavailable tool in yuri-tool fence';
|
|
431
|
+
let parsed;
|
|
432
|
+
try { parsed = JSON.parse(raw); }
|
|
433
|
+
catch { return `${fallback}: the payload is not valid JSON.`; }
|
|
434
|
+
const name = typeof parsed?.name === 'string' ? parsed.name.trim() : '';
|
|
435
|
+
if (name && !allowedToolName(name, allowedNames)) {
|
|
436
|
+
return `${fallback}: "${name.slice(0, 80)}" is not an available tool. Use only: ${[...allowedNames].join(', ')}. If no available tool can do the task, say so in a final answer.`;
|
|
437
|
+
}
|
|
438
|
+
return `${fallback}: expected {"name":"<tool>","arguments":{...}}.`;
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
export function parseContactNativeToolCalls(calls, allowedNames) {
|
|
442
|
+
const allowed = new Set(allowedNames);
|
|
443
|
+
const toolCalls = [];
|
|
444
|
+
for (const call of calls) {
|
|
445
|
+
let args;
|
|
446
|
+
try { args = JSON.parse(call.function.arguments); }
|
|
447
|
+
catch { return { toolCalls: [], protocolError: 'Tool arguments must be valid JSON.' }; }
|
|
448
|
+
const raw = JSON.stringify({ name: call.function.name, arguments: args });
|
|
449
|
+
const parsed = parseToolPayload(raw, allowed);
|
|
450
|
+
if (!parsed) return { toolCalls: [], protocolError: describeRejectedToolPayload(raw, allowed) };
|
|
451
|
+
toolCalls.push({ ...parsed, id: call.id });
|
|
452
|
+
}
|
|
453
|
+
return { toolCalls, protocolError: '' };
|
|
454
|
+
}
|
|
455
|
+
|
|
371
456
|
const extractJsonObjectAt = (text, start) => {
|
|
372
457
|
if (text[start] !== '{') return null;
|
|
373
458
|
let depth = 0;
|
|
@@ -426,7 +511,7 @@ export function stripContactToolFences(text) {
|
|
|
426
511
|
export function parseContactToolCalls(text, allowedNames = []) {
|
|
427
512
|
const allowed = new Set(
|
|
428
513
|
(Array.isArray(allowedNames) ? allowedNames : [])
|
|
429
|
-
.filter((name) => typeof name === 'string' && name.trim()
|
|
514
|
+
.filter((name) => typeof name === 'string' && name.trim())
|
|
430
515
|
.map((name) => name.trim()),
|
|
431
516
|
);
|
|
432
517
|
const raw = typeof text === 'string' ? text : '';
|
|
@@ -451,7 +536,7 @@ export function parseContactToolCalls(text, allowedNames = []) {
|
|
|
451
536
|
}
|
|
452
537
|
const toolCall = parseToolPayload(raw.slice(payloadStart, end).trim(), allowed);
|
|
453
538
|
if (!toolCall) {
|
|
454
|
-
return { chatText: '', toolCalls: [], protocolError:
|
|
539
|
+
return { chatText: '', toolCalls: [], protocolError: describeRejectedToolPayload(raw.slice(payloadStart, end).trim(), allowed) };
|
|
455
540
|
}
|
|
456
541
|
toolCalls.push(toolCall);
|
|
457
542
|
visible.push(raw.slice(visibleStart, index));
|
|
@@ -524,7 +609,7 @@ const hasNewConversationIntent = (text) => hasIntentMatch(NEW_CONVERSATION_INTEN
|
|
|
524
609
|
export function detectRequestedContactTools(userText, allowedNames = []) {
|
|
525
610
|
const allowed = new Set(
|
|
526
611
|
(Array.isArray(allowedNames) ? allowedNames : [])
|
|
527
|
-
.filter((name) => typeof name === 'string' && name.trim()
|
|
612
|
+
.filter((name) => typeof name === 'string' && name.trim())
|
|
528
613
|
.map((name) => name.trim()),
|
|
529
614
|
);
|
|
530
615
|
const text = typeof userText === 'string' ? userText : '';
|
|
@@ -558,7 +643,9 @@ export function detectRequestedContactTools(userText, allowedNames = []) {
|
|
|
558
643
|
if (allowed.has(CREATE_ASSISTANT_TOOL_NAME) && CREATE_ASSISTANT_INTENT.test(text)) {
|
|
559
644
|
requested.push(CREATE_ASSISTANT_TOOL_NAME);
|
|
560
645
|
}
|
|
561
|
-
if (allowed.has(
|
|
646
|
+
if (allowed.has(LIST_SCHEDULED_TASKS_TOOL_NAME) && UPDATE_SCHEDULED_TASK_INTENT.test(text)) {
|
|
647
|
+
requested.push(LIST_SCHEDULED_TASKS_TOOL_NAME);
|
|
648
|
+
} else if (allowed.has(SCHEDULE_TASK_TOOL_NAME) && SCHEDULE_TASK_INTENT.test(text)) {
|
|
562
649
|
requested.push(SCHEDULE_TASK_TOOL_NAME);
|
|
563
650
|
}
|
|
564
651
|
// Prefer explicit stop/watch over generic continue/assign when both could match.
|
|
@@ -592,6 +679,17 @@ const trim = (value, max = 10_000) => {
|
|
|
592
679
|
return next;
|
|
593
680
|
};
|
|
594
681
|
|
|
682
|
+
/** Model-facing scheduled-task summary: identity, schedule, model, bounded prompt preview. */
|
|
683
|
+
export function summarizeScheduledTask(task, projectID) {
|
|
684
|
+
const prompt = typeof task?.execution?.prompt === 'string' ? task.execution.prompt : '';
|
|
685
|
+
return {
|
|
686
|
+
id: task?.id ?? null, projectID, name: task?.name ?? null,
|
|
687
|
+
enabled: task?.enabled !== false, schedule: task?.schedule ?? null,
|
|
688
|
+
providerID: task?.execution?.providerID ?? null, modelID: task?.execution?.modelID ?? null,
|
|
689
|
+
promptPreview: prompt.length > 200 ? `${prompt.slice(0, 200)}…` : prompt,
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
|
|
595
693
|
/** Resolve OpenCode provider/model from tool args or the current contact. */
|
|
596
694
|
export function resolveContactProviderModel(params = {}, fallback = {}) {
|
|
597
695
|
const providerID = trim(params.providerID, 256);
|
|
@@ -710,7 +808,7 @@ export function formatApplicationToolCatalogEntry(tool) {
|
|
|
710
808
|
|
|
711
809
|
export function formatContactToolsPrompt(tools) {
|
|
712
810
|
const list = Array.isArray(tools)
|
|
713
|
-
? tools.filter((tool) => tool?.name && !
|
|
811
|
+
? tools.filter((tool) => tool?.name && !isPiCodingToolName(tool.name))
|
|
714
812
|
: [];
|
|
715
813
|
if (list.length === 0) return '';
|
|
716
814
|
return [
|
|
@@ -779,7 +877,8 @@ export function formatContactToolsPrompt(tools) {
|
|
|
779
877
|
'steer_session sends text into an existing session with delivery=steer, preserving its model. archive_session archives an existing session; delete_session permanently deletes it. Use exact sessionID from history, references or list_sessions; ask if the target is ambiguous. Only delete when the user requested deletion. These operations call real APIs; never claim success from a spoken promise. assign_session creates a new session when sessionID is omitted, or continues an existing session when supplied.',
|
|
780
878
|
'stop_session calls real OpenCode session.abort for that sessionID and returns the true result. Directory comes from authoritative session metadata. A failure is not a silent success. Do not claim stopped unless the tool returned success.',
|
|
781
879
|
'create_assistant reuses already-connected OpenCode providers (providerID/modelID). Mode is continuous.',
|
|
782
|
-
'schedule_task writes the same payload as PUT /api/projects/:id/scheduled-tasks onto a registered project.',
|
|
880
|
+
'schedule_task writes the same payload as PUT /api/projects/:id/scheduled-tasks onto a registered project. It only creates new tasks.',
|
|
881
|
+
'To review or change existing scheduled tasks, call list_scheduled_tasks, then update_scheduled_task with the exact taskID and projectID it returned. Update one task per call and pass only the fields to change.',
|
|
783
882
|
'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
883
|
'A reply without the tool call does nothing — agreeing in Chinese (好的 / 我来创建 / 我去说一声) is not sending.',
|
|
785
884
|
'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.',
|
|
@@ -917,6 +1016,8 @@ export function createContactTools({
|
|
|
917
1016
|
deleteSession,
|
|
918
1017
|
createAssistant,
|
|
919
1018
|
scheduleTask,
|
|
1019
|
+
listScheduledTasks,
|
|
1020
|
+
updateScheduledTask,
|
|
920
1021
|
deliverPeerMessage,
|
|
921
1022
|
clearContactMemory,
|
|
922
1023
|
resetContact,
|
|
@@ -1410,6 +1511,40 @@ export function createContactTools({
|
|
|
1410
1511
|
}
|
|
1411
1512
|
},
|
|
1412
1513
|
},
|
|
1514
|
+
{
|
|
1515
|
+
name: LIST_SCHEDULED_TASKS_TOOL_NAME,
|
|
1516
|
+
label: 'List scheduled tasks',
|
|
1517
|
+
description: 'List scheduled tasks across registered projects with id, projectID, name, enabled, schedule, provider/model, and a prompt preview. Partial failures list failed projects.',
|
|
1518
|
+
parameters: listScheduledTasksParameters,
|
|
1519
|
+
execute: async (_toolCallId, params) => {
|
|
1520
|
+
try {
|
|
1521
|
+
if (typeof listScheduledTasks !== 'function') throw new AssignError('upstream_error', 'Listing scheduled tasks is unavailable.');
|
|
1522
|
+
const result = await listScheduledTasks(params || {});
|
|
1523
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }], details: result, terminate: false };
|
|
1524
|
+
} catch (error) { return toolFailure(error, 'list_scheduled_tasks_failed', 'Could not list scheduled tasks.'); }
|
|
1525
|
+
},
|
|
1526
|
+
},
|
|
1527
|
+
{
|
|
1528
|
+
name: UPDATE_SCHEDULED_TASK_TOOL_NAME,
|
|
1529
|
+
label: 'Update scheduled task',
|
|
1530
|
+
description: 'Update one existing scheduled task by exact taskID + projectID from list_scheduled_tasks. Pass only fields to change. An explicit model must exist in the connected catalog. Emits a schedule card.',
|
|
1531
|
+
parameters: updateScheduledTaskParameters,
|
|
1532
|
+
execute: async (_toolCallId, params) => {
|
|
1533
|
+
try {
|
|
1534
|
+
if (typeof updateScheduledTask !== 'function') throw new AssignError('upstream_error', 'Updating a scheduled task is unavailable.');
|
|
1535
|
+
const taskID = trim(params?.taskID, 256);
|
|
1536
|
+
const projectID = trim(params?.projectID, 256);
|
|
1537
|
+
if (!taskID || !projectID) throw new AssignError('validation_error', 'update_scheduled_task requires taskID and projectID from list_scheduled_tasks.');
|
|
1538
|
+
const updated = await updateScheduledTask({ ...params, taskID, projectID });
|
|
1539
|
+
const task = updated?.task || {};
|
|
1540
|
+
const card = createScheduleCardPart({ taskID: task.id || taskID, projectID, name: task.name || taskID,
|
|
1541
|
+
kind: task.schedule?.kind, time: task.schedule?.time || task.schedule?.times?.[0],
|
|
1542
|
+
timezone: task.schedule?.timezone, prompt: task.execution?.prompt });
|
|
1543
|
+
emitCard(card);
|
|
1544
|
+
return { content: [{ type: 'text', text: JSON.stringify({ updated: true, task: summarizeScheduledTask(task, projectID) }) }], details: { card, updated }, terminate: false };
|
|
1545
|
+
} catch (error) { return toolFailure(error, 'update_scheduled_task_failed', 'Could not update that scheduled task.'); }
|
|
1546
|
+
},
|
|
1547
|
+
},
|
|
1413
1548
|
{
|
|
1414
1549
|
name: MESSAGE_ASSISTANT_TOOL_NAME,
|
|
1415
1550
|
label: 'Message assistant',
|
|
@@ -38,6 +38,13 @@ import {
|
|
|
38
38
|
import { attachmentScopeKey } from './assign.js';
|
|
39
39
|
|
|
40
40
|
describe('contact tool protocol', () => {
|
|
41
|
+
it('recovers shell aliases and names unavailable tools without enabling bash in read-only contexts', () => {
|
|
42
|
+
const parsed = parseContactToolCalls('```yuri-tool\n{"name":"grep","arguments":{"pattern":"it\u0027s","path":"src"}}\n```', ['bash']);
|
|
43
|
+
expect(parsed.toolCalls[0]).toMatchObject({ name: 'bash' });
|
|
44
|
+
expect(parsed.toolCalls[0].arguments.command).toContain("-e 'it'\\''s' 'src'");
|
|
45
|
+
expect(parseContactToolCalls('```yuri-tool\n{"name":"grep","arguments":{"pattern":"x"}}\n```', ['read']).protocolError).toContain('"grep" is not an available tool');
|
|
46
|
+
expect(detectRequestedContactTools('把定时任务里的模型换成新的', ['schedule_task', 'list_scheduled_tasks'])).toEqual(['list_scheduled_tasks']);
|
|
47
|
+
});
|
|
41
48
|
it('shows current-instance models with ordered favorites and recents using exact ids', () => {
|
|
42
49
|
const prompt = formatConnectedModelsPrompt([
|
|
43
50
|
{ providerID: 'p', providerName: 'Connected Provider', modelID: 'claude-sonnet-4-6', name: 'Claude Sonnet 4.6' },
|
|
@@ -282,8 +289,8 @@ describe('contact tool protocol', () => {
|
|
|
282
289
|
});
|
|
283
290
|
expect(parseContactToolCalls(
|
|
284
291
|
'```yuri-tool\n{"name":"glob","arguments":{"pattern":"*"}}\n```',
|
|
285
|
-
['
|
|
286
|
-
).toolCalls).
|
|
292
|
+
['bash'],
|
|
293
|
+
).toolCalls[0]).toMatchObject({ name: 'bash' });
|
|
287
294
|
});
|
|
288
295
|
|
|
289
296
|
it('tells DeepSeek to call tools from natural language, not slash commands', () => {
|
|
@@ -438,6 +445,8 @@ describe('createContactTools', () => {
|
|
|
438
445
|
UPDATE_DEFAULT_PROMPT_TOOL_NAME,
|
|
439
446
|
CREATE_ASSISTANT_TOOL_NAME,
|
|
440
447
|
SCHEDULE_TASK_TOOL_NAME,
|
|
448
|
+
'list_scheduled_tasks',
|
|
449
|
+
'update_scheduled_task',
|
|
441
450
|
MESSAGE_ASSISTANT_TOOL_NAME,
|
|
442
451
|
ASSIGN_SESSION_TOOL_NAME,
|
|
443
452
|
WATCH_SESSION_TOOL_NAME,
|