@yuriai/web 0.2.8-beta.2 → 0.2.8-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/assets/{AgentAvatar-MzDm6uBf.js → AgentAvatar--DsfGfhZ.js} +1 -1
  2. package/dist/assets/{AssistantView-BjpY2u0c.js → AssistantView-Bf19-qvJ.js} +3 -3
  3. package/dist/assets/{DiagramView-7j0sZC_P.js → DiagramView-UvYyjtWA.js} +1 -1
  4. package/dist/assets/{FadeInOnReveal-DkmfVoTO.js → FadeInOnReveal-NAFOww9Y.js} +1 -1
  5. package/dist/assets/{GuiPluginSurface-D_TK-2vZ.js → GuiPluginSurface-DNzJNcMh.js} +1 -1
  6. package/dist/assets/{GuiPluginWindow-dDG5Uyqb.js → GuiPluginWindow-C73klYx3.js} +1 -1
  7. package/dist/assets/{Icon-BjiyvtB2.js → Icon-Cy25fgQb.js} +1 -1
  8. package/dist/assets/{ImageLoadingPlaceholder-CUKFQTAG.js → ImageLoadingPlaceholder-DGRjdn_K.js} +1 -1
  9. package/dist/assets/{LoadingImage-B7cT_4Oe.js → LoadingImage-2pPdTFHh.js} +1 -1
  10. package/dist/assets/{MarkdownRenderer-B8zgOCfr.js → MarkdownRenderer-GuwP9qiJ.js} +2 -2
  11. package/dist/assets/{MarkdownRendererImpl-Dh7XVDLd.js → MarkdownRendererImpl-tHItN1IG.js} +1 -1
  12. package/dist/assets/{MarkstreamRendererImpl-D-qtRrvg.js → MarkstreamRendererImpl-Dh13e1UE.js} +1 -1
  13. package/dist/assets/{MobileDetailNavigation-LkTVYLZX.js → MobileDetailNavigation-CSxBgVuQ.js} +1 -1
  14. package/dist/assets/{MobileResizableSheet-C9YzOQis.js → MobileResizableSheet-BN07cmQQ.js} +1 -1
  15. package/dist/assets/{MobileShareBridge-CsTyKMtN.js → MobileShareBridge-7SAELdqu.js} +1 -1
  16. package/dist/assets/MobileTabPageHeader-Bbb36BtD.js +2 -0
  17. package/dist/assets/{MultiRunWindow-hMpjV7so.js → MultiRunWindow-DbI9KTph.js} +1 -1
  18. package/dist/assets/{OnboardingScreen-D6iQ5qjF.js → OnboardingScreen-rp0qwvgz.js} +1 -1
  19. package/dist/assets/{OverlayScrollbar-Dbx1atD-.js → OverlayScrollbar-B--v-oQW.js} +1 -1
  20. package/dist/assets/{SettingsView-D8qpss-X.js → SettingsView-C1AQoEIQ.js} +1 -1
  21. package/dist/assets/{SettingsWindow-B1VuFkFq.js → SettingsWindow-6M0ssWHM.js} +1 -1
  22. package/dist/assets/{TerminalView-CLcaJh2M.js → TerminalView-bhL6Ccen.js} +1 -1
  23. package/dist/assets/{ToolOutputDialog-BuZo3XvN.js → ToolOutputDialog-BaLKI3Yc.js} +1 -1
  24. package/dist/assets/{YuriLogo-DvRSd5NN.js → YuriLogo-kwLWc5Hi.js} +1 -1
  25. package/dist/assets/{appThemeRegistry-B7sp1Hw8.js → appThemeRegistry-Bk_N8btz.js} +1 -1
  26. package/dist/assets/{button-BSFWH-Ok.js → button-Dodw6LWV.js} +1 -1
  27. package/dist/assets/{capgoAdapter-vxOdqloD.js → capgoAdapter-DqHX7fkj.js} +1 -1
  28. package/dist/assets/{collapsible-DaevjAvt.js → collapsible-C9kOfVDe.js} +1 -1
  29. package/dist/assets/{diagram-7OgmyecX.js → diagram-CfBQ9Icg.js} +1 -1
  30. package/dist/assets/{dialog-D1pXn_b9.js → dialog-D0bq7nr2.js} +1 -1
  31. package/dist/assets/{dropdown-menu.styles-CGHPvEgD.js → dropdown-menu.styles-CLxDPSrk.js} +1 -1
  32. package/dist/assets/{es-DJzbuYpv.js → es-Diy_UpPF.js} +1 -1
  33. package/dist/assets/{fileMentionTouchSelection-DspnKU8D.js → fileMentionTouchSelection-C16Q21Ht.js} +1 -1
  34. package/dist/assets/{fr-YDYbYIZQ.js → fr-CPRTMaky.js} +1 -1
  35. package/dist/assets/{gitApi-BLYdWaG8.js → gitApi-_yKaBF0a.js} +1 -1
  36. package/dist/assets/{input-BhHXFla6.js → input-HddqDhRi.js} +1 -1
  37. package/dist/assets/{insertionBoundaries-DqlfZVY9.js → insertionBoundaries-CHqJLwJg.js} +1 -1
  38. package/dist/assets/{ja-SjX3NBJz.js → ja-Cc1jn0Ag.js} +1 -1
  39. package/dist/assets/{ko-BxcUEWjB.js → ko-CfHUuNNe.js} +1 -1
  40. package/dist/assets/{main-DA7z198b.js → main-Bja5DG1P.js} +2 -2
  41. package/dist/assets/{main-Qw23QJ7L.js → main-njE9rVzm.js} +4 -4
  42. package/dist/assets/{markdownHeightCache-DV2j4PlS.js → markdownHeightCache-BQiIj0aM.js} +1 -1
  43. package/dist/assets/{mcpQueries-C6Tu2cF3.js → mcpQueries-uM1Chfdc.js} +1 -1
  44. package/dist/assets/{miniChat-HafcB3H-.js → miniChat-DAwBa-3U.js} +2 -2
  45. package/dist/assets/{mobile-DwXoGpxm.js → mobile-BQmrdXmD.js} +2 -2
  46. package/dist/assets/{mobileBackNavigation-9MR5h5K6.js → mobileBackNavigation-DsU3qQ8W.js} +1 -1
  47. package/dist/assets/{multirun-D-je_w02.js → multirun-DRL1Wf-K.js} +1 -1
  48. package/dist/assets/{native-config-Bb3pPQPD.js → native-config-BMflOjo8.js} +1 -1
  49. package/dist/assets/{pl-vh0XFuDb.js → pl-mUyhvp8O.js} +1 -1
  50. package/dist/assets/{projectMeta-DaCyZW_D.js → projectMeta-DK-kl6vM.js} +1 -1
  51. package/dist/assets/{pt-BR-Cv5tssQz.js → pt-BR-D3E4Wxao.js} +1 -1
  52. package/dist/assets/{readiness-BHqz_NPS.js → readiness-CMHDs1YN.js} +1 -1
  53. package/dist/assets/{renderElectronMiniChatApp-COaMALRh.js → renderElectronMiniChatApp-CkSP0eQz.js} +2 -2
  54. package/dist/assets/{renderMobileApp-BOGntDSu.js → renderMobileApp-wELnHLDT.js} +4 -4
  55. package/dist/assets/{runtimeConfig-BiSluBXe.js → runtimeConfig-KpW0l510.js} +1 -1
  56. package/dist/assets/{runtimeEndpointReset-CJwlI_R-.js → runtimeEndpointReset-BBxpXfkE.js} +3 -3
  57. package/dist/assets/{scheduledTaskNavigation-BZ3B5bpN.js → scheduledTaskNavigation-CyPkVBKs.js} +1 -1
  58. package/dist/assets/{sessionChangeSummary-BAv8zzro.js → sessionChangeSummary-Bb7dqAie.js} +1 -1
  59. package/dist/assets/{sessionLookup-DOw7g15p.js → sessionLookup-D_P3C7rX.js} +1 -1
  60. package/dist/assets/{sortable-tabs-strip-BnTV_KYG.js → sortable-tabs-strip-C-qSUWlr.js} +1 -1
  61. package/dist/assets/{speechSettingsQueries-B8zEN5QM.js → speechSettingsQueries-BSBjx3wG.js} +1 -1
  62. package/dist/assets/src-CbY9YJrh.css +2 -0
  63. package/dist/assets/{store-CgQdmzpX.js → store-FxBFwq--.js} +2 -2
  64. package/dist/assets/{textarea-Deh9E1KP.js → textarea-BvfW0tsL.js} +1 -1
  65. package/dist/assets/{tooltip-DygQ-2xe.js → tooltip-BmKpb74n.js} +1 -1
  66. package/dist/assets/{types-BiP0jssb.js → types-rJezumB4.js} +1 -1
  67. package/dist/assets/{uk-3a9vdLJ-.js → uk-D9iQbGbr.js} +1 -1
  68. package/dist/assets/{useAppFontEffects-De1qI6c-.js → useAppFontEffects-DZ1W3_cy.js} +5 -5
  69. package/dist/assets/{useDesktopWindowControlsLayout-BzXi6Wf1.js → useDesktopWindowControlsLayout-D_1DLCOD.js} +1 -1
  70. package/dist/assets/{useEffectiveDirectory-BcbBl_6y.js → useEffectiveDirectory-joUiryc3.js} +1 -1
  71. package/dist/assets/{useMobileNavigationStore-DqDCVXO1.js → useMobileNavigationStore-BaQ7TIpx.js} +6 -6
  72. package/dist/assets/{useWorkerHighlightedLines-CDVleuma.js → useWorkerHighlightedLines-CiU1xPjX.js} +1 -1
  73. package/dist/assets/{zh-CN-kwaUr5W5.js → zh-CN-mNVX6pMK.js} +1 -1
  74. package/dist/assets/{zh-TW-BBs44W7l.js → zh-TW-B7T0e-Qv.js} +1 -1
  75. package/dist/index.html +6 -6
  76. package/dist/mini-chat.html +6 -6
  77. package/dist/mobile.html +6 -6
  78. package/package.json +1 -1
  79. package/server/lib/assistants/DOCUMENTATION.md +16 -16
  80. package/server/lib/assistants/bubbles.js +0 -14
  81. package/server/lib/assistants/bubbles.test.js +1 -18
  82. package/server/lib/assistants/contact-tools.js +64 -231
  83. package/server/lib/assistants/contact-tools.test.js +29 -164
  84. package/server/lib/assistants/harness.js +72 -237
  85. package/server/lib/assistants/harness.test.js +199 -280
  86. package/server/lib/assistants/memory.http.test.js +2 -2
  87. package/server/lib/assistants/pi-tools.js +1 -54
  88. package/server/lib/assistants/pi-tools.test.js +5 -9
  89. package/server/lib/assistants/service.test.js +23 -42
  90. package/server/lib/scheduled-tasks/runtime.test.js +3 -3
  91. package/dist/assets/MobileTabPageHeader-xz9RMXg4.js +0 -2
  92. package/dist/assets/src-NlrSCyPZ.css +0 -2
@@ -20,8 +20,8 @@ const listen = async (app) => {
20
20
  closers.push(() => new Promise((resolve) => { server.close(resolve); server.closeAllConnections(); }));
21
21
  return `http://127.0.0.1:${server.address().port}`;
22
22
  };
23
- const final = (text) => ({ text: '```yuri-final\n' + JSON.stringify({ status: 'complete', text }) + '\n```' });
24
- const call = (name, args) => ({ text: '```yuri-tool\n' + JSON.stringify({ name, arguments: args }) + '\n```' });
23
+ const final = (text) => ({ text });
24
+ const call = (name, args) => ({ completion: { choices: [{ message: { content: '', tool_calls: [{ id: `call_${name}`, type: 'function', function: { name, arguments: JSON.stringify(args) } }] } }] } });
25
25
  const resultFor = (body, name) => {
26
26
  const row = body.messages.findLast((m) => m.role === 'tool' && m.name === name);
27
27
  if (!row) return null;
@@ -71,46 +71,8 @@ const bindHarnessTool = (tool, context) => ({
71
71
  ),
72
72
  });
73
73
 
74
- /**
75
- * Serialize a tool parameter schema for the contact system prompt.
76
- * Mirrors contact-tools.serializeToolParametersForPrompt without a circular import.
77
- */
78
- const serializeParameters = (parameters) => {
79
- if (parameters == null) return '{"type":"object","properties":{}}';
80
- try {
81
- const text = JSON.stringify(parameters, (_key, value) => {
82
- if (typeof value === 'function' || typeof value === 'symbol') return undefined;
83
- return value;
84
- });
85
- if (typeof text === 'string' && text.trim() && text !== 'undefined') return text;
86
- } catch {
87
- // Fall through.
88
- }
89
- return '{"type":"object","properties":{}}';
90
- };
91
-
92
- const formatCodingToolEntry = (tool) => {
93
- if (!tool || typeof tool.name !== 'string' || !tool.name.trim()) return '';
94
- const name = tool.name.trim();
95
- const description = typeof tool.description === 'string' && tool.description.trim()
96
- ? tool.description.trim()
97
- : name;
98
- return `- ${name}: ${description}\n arguments schema: ${serializeParameters(tool.parameters)}`;
99
- };
100
-
101
- export function formatPiCodingPrompt({ cwd, skillsPrompt = '', tools = [] } = {}) {
74
+ export function formatPiCodingPrompt({ cwd, skillsPrompt = '' } = {}) {
102
75
  if (typeof cwd !== 'string' || !cwd.trim()) return '';
103
- const codingTools = Array.isArray(tools)
104
- ? tools.filter((tool) => isPiCodingToolName(tool?.name))
105
- : [];
106
- const catalog = codingTools.length > 0
107
- ? codingTools.map(formatCodingToolEntry).filter(Boolean)
108
- : [
109
- '- bash: Execute a bash command in the working directory.\n arguments schema: {"type":"object","required":["command"],"properties":{"command":{"type":"string"},"timeout":{"type":"number"}}}',
110
- '- read: Read a file (path required; optional offset/limit).\n arguments schema: {"type":"object","required":["path"],"properties":{"path":{"type":"string"},"offset":{"type":"number"},"limit":{"type":"number"}}}',
111
- '- write: Write/create a file (path + content required).\n arguments schema: {"type":"object","required":["path","content"],"properties":{"path":{"type":"string"},"content":{"type":"string"}}}',
112
- '- edit: Exact text replacement (path + edits[{oldText,newText}] required).\n arguments schema: {"type":"object","required":["path","edits"],"properties":{"path":{"type":"string"},"edits":{"type":"array","items":{"type":"object","required":["oldText","newText"],"properties":{"oldText":{"type":"string"},"newText":{"type":"string"}}}}}}',
113
- ];
114
76
  return [
115
77
  `Working directory: ${cwd}`,
116
78
  'You have application-owned pi coding tools in this directory: read, write, edit, bash.',
@@ -119,21 +81,6 @@ export function formatPiCodingPrompt({ cwd, skillsPrompt = '', tools = [] } = {}
119
81
  'This is your working directory. Ignore any other cwd from the environment, including temporary generator workspaces under /var/folders or os.tmpdir.',
120
82
  'When the user asks pwd, the current directory, or to look at files, call bash/read yourself. Never say you have no terminal or cannot read or write files.',
121
83
  'Skills are merged from ~/.claude/skills, ~/.agents/skills, and this project\'s .claude/skills plus .agents/skills (project wins on name). Read a skill file when the task matches its description.',
122
- 'Call these tools with the same fenced JSON as other tools. Match the argument schemas exactly:',
123
- '```yuri-tool',
124
- '{"name":"bash","arguments":{"command":"pwd"}}',
125
- '```',
126
- '```yuri-tool',
127
- '{"name":"read","arguments":{"path":".agents/skills/example/SKILL.md"}}',
128
- '```',
129
- '```yuri-tool',
130
- '{"name":"write","arguments":{"path":"notes.txt","content":"hello"}}',
131
- '```',
132
- '```yuri-tool',
133
- '{"name":"edit","arguments":{"path":"notes.txt","edits":[{"oldText":"hello","newText":"hello world"}]}}',
134
- '```',
135
- 'Available pi coding tools (full argument schemas):',
136
- ...catalog,
137
84
  typeof skillsPrompt === 'string' && skillsPrompt.trim() ? skillsPrompt.trim() : '',
138
85
  ].filter(Boolean).join('\n');
139
86
  }
@@ -86,22 +86,18 @@ describe('mergeSkillsByName', () => {
86
86
  });
87
87
 
88
88
  describe('formatPiCodingPrompt', () => {
89
- it('includes full pi tool argument schemas and distinguishes skills from tools', async () => {
89
+ it('names the pi coding tools without a schema catalog and distinguishes skills from tools', async () => {
90
90
  const cwd = temp();
91
91
  const home = temp();
92
92
  const runtime = await createPiCodingRuntime(cwd, { homeDir: home });
93
93
  const prompt = formatPiCodingPrompt({
94
94
  cwd: runtime.cwd,
95
95
  skillsPrompt: runtime.skillsPrompt,
96
- tools: runtime.tools,
97
96
  });
98
- expect(prompt).toContain('arguments schema:');
99
- expect(prompt).toContain('"path"');
100
- expect(prompt).toContain('"content"');
101
- expect(prompt).toContain('"edits"');
102
- expect(prompt).toContain('"oldText"');
103
- expect(prompt).toContain('"newText"');
104
- expect(prompt).toContain('"command"');
97
+ expect(prompt).toContain('read, write, edit, bash');
98
+ expect(prompt).not.toContain('arguments schema:');
99
+ expect(prompt).not.toContain('"oldText"');
100
+ expect(prompt).not.toContain('yuri-tool');
105
101
  expect(prompt).toContain('not OpenCode native tools and not MCP');
106
102
  expect(prompt).toContain('never invent skill or MCP tool names');
107
103
  expect(prompt).toContain('context7');
@@ -114,6 +114,8 @@ const settleSend = async (service, assistantID, body) => {
114
114
  return { ...sent, settled };
115
115
  };
116
116
  const assistantInput = { name: 'A', providerID: 'p', modelID: 'm' };
117
+ const toolBatch = (calls, content = '') => ({ completion: { choices: [{ message: { content, tool_calls: calls.map(([name, args, id = `call_${name}`]) => ({ id, type: 'function', function: { name, arguments: JSON.stringify(args) } })) } }] } });
118
+ const sayThen = (text, name, args) => toolBatch([['notify_user', { text }], [name, args]]);
117
119
 
118
120
  describe('assistants service', () => {
119
121
  it('migrates legacy avatar seeds and persists edits without changing identity', async () => {
@@ -3308,9 +3310,9 @@ describe('assistants service', () => {
3308
3310
  backgroundTurns.push(input);
3309
3311
  return realRunContactTurn({
3310
3312
  ...input,
3311
- createChatCompletion: async () => ({ text: silent
3312
- ? '```yuri-final\n{"status":"silent","text":""}\n```'
3313
- : '资料已整理:本周有两项相关更新。' }),
3313
+ createChatCompletion: async () => (silent
3314
+ ? toolBatch([['stay_silent', {}]])
3315
+ : { text: '资料已整理:本周有两项相关更新。' }),
3314
3316
  });
3315
3317
  }
3316
3318
  await input.tools.find((tool) => tool.name === 'schedule_task').execute('schedule', {
@@ -3747,7 +3749,7 @@ describe('assistants service', () => {
3747
3749
  backgroundTurns.push(input);
3748
3750
  return realRunContactTurn({
3749
3751
  ...input,
3750
- createChatCompletion: async () => ({ text: '```yuri-message\n{"text":"正在查看该会话的执行结果"}\n```\n```yuri-final\n{"status":"silent","text":""}\n```' }),
3752
+ createChatCompletion: async () => toolBatch([['stay_silent', {}]], '正在查看该会话的执行结果'),
3751
3753
  });
3752
3754
  },
3753
3755
  });
@@ -4901,15 +4903,12 @@ describe('read_session referenced conversation', () => {
4901
4903
  it('real harness two read_session preambles: SSE done bubbles match SQLite 1:1 including duplicates', async () => {
4902
4904
  const directory = root();
4903
4905
  const events = [];
4904
- const fence = (name, args) => '```yuri-tool\n' + JSON.stringify({ name, arguments: args }) + '\n```';
4905
4906
  const replies = [
4906
- `我去读一下\n\n${fence('read_session', { sessionID: 'ses_a' })}`,
4907
- `我再读一下\n\n${fence('read_session', { sessionID: 'ses_b' })}`,
4908
- '```yuri-final\n{"status":"complete","text":"办好了"}\n```',
4907
+ sayThen('我去读一下', 'read_session', { sessionID: 'ses_a' }),
4908
+ sayThen('我再读一下', 'read_session', { sessionID: 'ses_b' }),
4909
+ { text: '办好了' },
4909
4910
  ];
4910
- const createChatCompletion = vi.fn(async () => ({
4911
- completion: { choices: [{ message: { content: replies.shift() || '' } }] },
4912
- }));
4911
+ const createChatCompletion = vi.fn(async () => replies.shift() || { text: '' });
4913
4912
  const service = setup(directory, {
4914
4913
  get: async ({ sessionID }) => ({
4915
4914
  data: { id: sessionID, directory, title: sessionID },
@@ -4956,15 +4955,11 @@ describe('read_session referenced conversation', () => {
4956
4955
  service.close();
4957
4956
  });
4958
4957
 
4959
- it('persists public model messages before generation and tool completion, with no final replay', async () => {
4958
+ it('persists notify_user messages before tool completion, with no final replay', async () => {
4960
4959
  const directory = root();
4961
4960
  const events = [];
4962
- let releaseGeneration;
4963
4961
  let releaseTool;
4964
- const generationGate = new Promise((resolve) => { releaseGeneration = resolve; });
4965
4962
  const toolGate = new Promise((resolve) => { releaseTool = resolve; });
4966
- const prefix = '```yuri-message\n{"text":"我先读一下会话,确认目前的进展。"}\n```\n';
4967
- const tool = '```yuri-tool\n{"name":"read_session","arguments":{"sessionID":"ses_progress"}}\n```';
4968
4963
  let calls = 0;
4969
4964
  const read = vi.fn(async () => {
4970
4965
  await toolGate;
@@ -4975,25 +4970,17 @@ describe('read_session referenced conversation', () => {
4975
4970
  }, {
4976
4971
  onContactTurnEvent: (event) => events.push(event),
4977
4972
  runContactTurn: realRunContactTurn,
4978
- createChatCompletion: async ({ onTextDelta }) => {
4979
- if (++calls === 1) {
4980
- onTextDelta(prefix);
4981
- await generationGate;
4982
- onTextDelta(tool);
4983
- return { text: prefix + tool };
4984
- }
4985
- return { text: '```yuri-final\n{"status":"complete","text":"这个会话目前为空。"}\n```' };
4973
+ createChatCompletion: async () => {
4974
+ if (++calls === 1) return sayThen('我先读一下会话,确认目前的进展。', 'read_session', { sessionID: 'ses_progress' });
4975
+ return { text: '这个会话目前为空。' };
4986
4976
  },
4987
4977
  });
4988
4978
  const assistant = service.createAssistant(assistantInput);
4989
4979
  try {
4990
4980
  await service.send(assistant.id, { messageID: 'live_public', parts: [{ type: 'text', text: '读一下会话' }] });
4991
- await vi.waitFor(() => expect(service.contactMessages(assistant.id).messages.some((m) => m.text === '我先读一下会话,确认目前的进展。')).toBe(true));
4992
- expect(read).not.toHaveBeenCalled();
4981
+ await vi.waitFor(() => expect(read).toHaveBeenCalledTimes(1));
4993
4982
  expect(service.snapshot().assistants.find((a) => a.id === assistant.id).working).toBe(true);
4994
4983
  expect(events.some((e) => e.type === 'yuri:contact-turn-end')).toBe(false);
4995
- releaseGeneration();
4996
- await vi.waitFor(() => expect(read).toHaveBeenCalledTimes(1));
4997
4984
  // A fresh snapshot/history read while the actual tool is pending restores the same message.
4998
4985
  expect(service.contactMessages(assistant.id).messages.filter((m) => m.role === 'assistant').map((m) => m.text)).toEqual(['我先读一下会话,确认目前的进展。']);
4999
4986
  releaseTool();
@@ -5002,18 +4989,17 @@ describe('read_session referenced conversation', () => {
5002
4989
  const deltas = events.filter((e) => e.type === 'yuri:contact-bubble-delta' && e.properties.done);
5003
4990
  expect(deltas.map((e) => e.properties.bubbleIndex)).toEqual([0, 1]);
5004
4991
  } finally {
5005
- releaseGeneration(); releaseTool(); service.close();
4992
+ releaseTool(); service.close();
5006
4993
  }
5007
4994
  });
5008
4995
 
5009
4996
  it('real harness duplicate preambles keep both lines in SSE and SQLite', async () => {
5010
4997
  const directory = root();
5011
4998
  const events = [];
5012
- const fence = (name, args) => '```yuri-tool\n' + JSON.stringify({ name, arguments: args }) + '\n```';
5013
4999
  const replies = [
5014
- `我去读一下\n\n${fence('read_session', { sessionID: 'ses_dup_a' })}`,
5015
- `我去读一下\n\n${fence('read_session', { sessionID: 'ses_dup_b' })}`,
5016
- '```yuri-final\n{"status":"complete","text":"办好了"}\n```',
5000
+ sayThen('我去读一下', 'read_session', { sessionID: 'ses_dup_a' }),
5001
+ sayThen('我去读一下', 'read_session', { sessionID: 'ses_dup_b' }),
5002
+ { text: '办好了' },
5017
5003
  ];
5018
5004
  const service = setup(directory, {
5019
5005
  get: async ({ sessionID }) => ({ data: { id: sessionID, directory, title: sessionID } }),
@@ -5023,9 +5009,7 @@ describe('read_session referenced conversation', () => {
5023
5009
  }, {
5024
5010
  onContactTurnEvent: (event) => events.push(event),
5025
5011
  runContactTurn: realRunContactTurn,
5026
- createChatCompletion: vi.fn(async () => ({
5027
- completion: { choices: [{ message: { content: replies.shift() || '' } }] },
5028
- })),
5012
+ createChatCompletion: vi.fn(async () => replies.shift() || { text: '' }),
5029
5013
  });
5030
5014
  const assistant = service.createAssistant(assistantInput);
5031
5015
  await settleSend(service, assistant.id, {
@@ -5046,17 +5030,14 @@ describe('read_session referenced conversation', () => {
5046
5030
  it('real harness missed-tool retry keeps pre-retry spoken in SSE and SQLite', async () => {
5047
5031
  const directory = root();
5048
5032
  const events = [];
5049
- const fence = (name, args) => '```yuri-tool\n' + JSON.stringify({ name, arguments: args }) + '\n```';
5050
5033
  const replies = [
5051
- '```yuri-final\n{"status":"complete","text":"好的,我来创建。"}\n```',
5052
- `这就建好\n\n${fence('create_assistant', { name: 'MissSvc', model: 'p/m' })}`,
5034
+ { text: '好的,我来创建。' },
5035
+ sayThen('这就建好', 'create_assistant', { name: 'MissSvc', model: 'p/m' }),
5053
5036
  ];
5054
5037
  const service = setup(directory, {}, {
5055
5038
  onContactTurnEvent: (event) => events.push(event),
5056
5039
  runContactTurn: realRunContactTurn,
5057
- createChatCompletion: vi.fn(async () => ({
5058
- completion: { choices: [{ message: { content: replies.shift() || '' } }] },
5059
- })),
5040
+ createChatCompletion: vi.fn(async () => replies.shift() || { text: '' }),
5060
5041
  });
5061
5042
  const assistant = service.createAssistant(assistantInput);
5062
5043
  await settleSend(service, assistant.id, {
@@ -387,9 +387,9 @@ describe('scheduled task result handoff', () => {
387
387
  expect(input.userText).toContain(task.execution.prompt);
388
388
  if (mode === 'failure') expect(input.userText).toContain('upstream failed');
389
389
  else expect(input.userText).toContain('Actual research findings');
390
- return reviewTaskResult({ ...input, createChatCompletion: async () => ({ text: mode === 'silent'
391
- ? '```yuri-final\n{"status":"silent","text":""}\n```'
392
- : mode === 'failure' ? '任务执行失败,需要检查服务。' : '资料汇总:有两项值得关注的更新。' }) });
390
+ return reviewTaskResult({ ...input, createChatCompletion: async () => (mode === 'silent'
391
+ ? { completion: { choices: [{ message: { content: '', tool_calls: [{ id: 'call_silent', type: 'function', function: { name: 'stay_silent', arguments: '{}' } }] } }] } }
392
+ : { text: mode === 'failure' ? '任务执行失败,需要检查服务。' : '资料汇总:有两项值得关注的更新。' }) });
393
393
  });
394
394
  const runtime = createRuntime(null, {
395
395
  projectConfigRuntime, listProjects, runHistoryStore: store, notifyTaskRun,