@yuriai/web 0.2.25 → 0.2.27-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.
Files changed (207) hide show
  1. package/README.md +21 -1
  2. package/dist/assets/AgentAvatar-BW4Zg8bo.js +1 -0
  3. package/dist/assets/AssistantView-Cl0ZeXwr.js +3 -0
  4. package/dist/assets/{DiagramView-DN_rHdr9.js → DiagramView-D6wdXRzu.js} +1 -1
  5. package/dist/assets/{FadeInOnReveal-555z1y1N.js → FadeInOnReveal-gOsILpSk.js} +1 -1
  6. package/dist/assets/{GuiPluginSurface-BPMATuPa.js → GuiPluginSurface-DOZAQKX0.js} +1 -1
  7. package/dist/assets/{GuiPluginWindow-CAmfr79x.js → GuiPluginWindow-tGvc4_0g.js} +1 -1
  8. package/dist/assets/Icon-DvUDsV1z.js +1 -0
  9. package/dist/assets/{ImageLoadingPlaceholder-BMsQLN_b.js → ImageLoadingPlaceholder-9xYbKqtf.js} +1 -1
  10. package/dist/assets/{LoadingImage-DI7sb_H_.js → LoadingImage-CiOcKPfb.js} +1 -1
  11. package/dist/assets/MarkdownRenderer-DZkP4UNr.js +2 -0
  12. package/dist/assets/{MarkdownRendererImpl-B9K5q0Lc.js → MarkdownRendererImpl-BXzPUEEo.js} +1 -1
  13. package/dist/assets/{MarkstreamRendererImpl-9gUEVQck.js → MarkstreamRendererImpl-B-NWd069.js} +1 -1
  14. package/dist/assets/MobileDetailNavigation-5U28hfYf.js +1 -0
  15. package/dist/assets/{MobileResizableSheet-_6OvPSMI.js → MobileResizableSheet-ZL-zPa3W.js} +1 -1
  16. package/dist/assets/{MobileShareBridge-BrdOiu_r.js → MobileShareBridge-JSH_Y8Ps.js} +3 -3
  17. package/dist/assets/MobileTabPageHeader-Bj9MIS38.js +2 -0
  18. package/dist/assets/MultiRunWindow-ZPz62Aqg.js +1 -0
  19. package/dist/assets/{OnboardingScreen-g8PDztN3.js → OnboardingScreen-BQNoy9o1.js} +1 -1
  20. package/dist/assets/{OverlayScrollbar-COv8rH_z.js → OverlayScrollbar-BwCFalSw.js} +1 -1
  21. package/dist/assets/SettingsView-B17qt8dh.js +29 -0
  22. package/dist/assets/SettingsWindow-CIFNHb-F.js +1 -0
  23. package/dist/assets/{TerminalView-BLer-ZhM.js → TerminalView-BZZ8LW4d.js} +1 -1
  24. package/dist/assets/{ToolOutputDialog-DI-s2TBb.js → ToolOutputDialog-BKuVpgEu.js} +2 -2
  25. package/dist/assets/{YuriLogo-BP4j1iqV.js → YuriLogo-C1Ty-RTB.js} +1 -1
  26. package/dist/assets/appThemeRegistry-DqGuzMaH.js +1 -0
  27. package/dist/assets/{assistant-attachment-cache-Cis9yYGt.js → assistant-attachment-cache-B9iHLlm2.js} +1 -1
  28. package/dist/assets/{button-Be1cqulG.js → button-DuHjvKJJ.js} +1 -1
  29. package/dist/assets/{capgoAdapter-B31jIkD8.js → capgoAdapter-B-tddboe.js} +1 -1
  30. package/dist/assets/collapsible-B8eL5nLo.js +1 -0
  31. package/dist/assets/{device-hj359GjJ.js → device-BjRYYXNT.js} +1 -1
  32. package/dist/assets/{diagram-hEIRiKol.js → diagram-ChoQDKzy.js} +1 -1
  33. package/dist/assets/dialog-CTYD3Sbr.css +1 -0
  34. package/dist/assets/dialog-CVhqZux0.js +1 -0
  35. package/dist/assets/{dropdown-menu.styles-xxM2ofOp.js → dropdown-menu.styles-DGvlOX_5.js} +1 -1
  36. package/dist/assets/{es-Clj7CS2r.js → es-B8sAsuo5.js} +3 -3
  37. package/dist/assets/{fileMentionTouchSelection-CTh0Mc2g.js → fileMentionTouchSelection-Dd-iSIe2.js} +2 -2
  38. package/dist/assets/{fileQueries-COS23nLq.js → fileQueries-5a1jkme2.js} +1 -1
  39. package/dist/assets/{fileReferenceActions-Cus9oSW7.js → fileReferenceActions-BAoEu4z8.js} +1 -1
  40. package/dist/assets/{fr-dmrFQLCO.js → fr-BPpW8T-l.js} +3 -3
  41. package/dist/assets/{gitApi-deADOzlN.js → gitApi-D43bAQh1.js} +1 -1
  42. package/dist/assets/{gitApiHttp-BBRKl9WX.js → gitApiHttp-DHrRqnYh.js} +3 -3
  43. package/dist/assets/{gui-BHEKelUx.js → gui-9enrif_1.js} +1 -1
  44. package/dist/assets/{host-DrqLUbqt.js → host-D1EpSUMR.js} +1 -1
  45. package/dist/assets/image-loading-Dq1g_wpm.js +1 -0
  46. package/dist/assets/{input-DTdHYZ6r.js → input-E_oYiXZT.js} +1 -1
  47. package/dist/assets/insertionBoundaries-BQjiZAmZ.js +1 -0
  48. package/dist/assets/{ja-Co0dxiN_.js → ja-DEoFDi7P.js} +3 -3
  49. package/dist/assets/{ko-BltElAGq.js → ko-B45xHN6I.js} +3 -3
  50. package/dist/assets/main-C6MDfyZy.js +2 -0
  51. package/dist/assets/main-u5iQScJs.js +169 -0
  52. package/dist/assets/{markdownHeightCache-DnR01ECa.js → markdownHeightCache-heNXHdzb.js} +1 -1
  53. package/dist/assets/{markdownTheme-DHoKvD6O.js → markdownTheme-hpURsgju.js} +1 -1
  54. package/dist/assets/{mcpQueries-Cpb22_60.js → mcpQueries-BqKVe4Su.js} +1 -1
  55. package/dist/assets/miniChat-Dhfn71Re.js +2 -0
  56. package/dist/assets/mobile-DSVdPfcG.js +2 -0
  57. package/dist/assets/{mobileBackNavigation-BibkyIeB.js → mobileBackNavigation-DHxFQ7SY.js} +1 -1
  58. package/dist/assets/{multirun-CPvUnP91.js → multirun-CPOzaEQj.js} +2 -2
  59. package/dist/assets/{native-BMAEg2E6.js → native-De1DIkLZ.js} +1 -1
  60. package/dist/assets/{native-config-DA8S8EqV.js → native-config-oauL2ekt.js} +1 -1
  61. package/dist/assets/{persistence-CBL0OOdj.js → persistence-JyLTFv27.js} +1 -1
  62. package/dist/assets/{pl-qd6Wnl7H.js → pl-Bm3Je_AX.js} +3 -3
  63. package/dist/assets/projectMeta-YDMdD3AP.js +1 -0
  64. package/dist/assets/{pt-BR-CsOFfQXS.js → pt-BR-BiQwFHhL.js} +3 -3
  65. package/dist/assets/{react-BYRXYlGz.js → react-CURmDhtB.js} +1 -1
  66. package/dist/assets/{readiness-RiznV1AX.js → readiness-BveVUOIb.js} +1 -1
  67. package/dist/assets/{renderElectronMiniChatApp-DdGqTh4X.js → renderElectronMiniChatApp-NC8iRPyy.js} +2 -2
  68. package/dist/assets/renderMobileApp-D5ai1i6y.js +28 -0
  69. package/dist/assets/{runtime-file-download-B_c7JBoS.js → runtime-file-download-CcNIVp7u.js} +1 -1
  70. package/dist/assets/{runtime-file-resource-DpTxBCsp.js → runtime-file-resource-6np6lzoV.js} +1 -1
  71. package/dist/assets/runtimeConfig-BpcgdIV9.js +2 -0
  72. package/dist/assets/runtimeEndpointReset-BL9hV6J1.css +1 -0
  73. package/dist/assets/runtimeEndpointReset-ByKa_0nu.js +149 -0
  74. package/dist/assets/scheduledTaskNavigation-CZfAnPD-.js +1 -0
  75. package/dist/assets/sessionChangeSummary-8C8nv-EP.css +1 -0
  76. package/dist/assets/sessionChangeSummary-D6NlE_5k.js +1 -0
  77. package/dist/assets/{sessionLookup-B7kUOIpO.js → sessionLookup-C70EoX-V.js} +1 -1
  78. package/dist/assets/{sortable-tabs-strip-CQZ16rbO.js → sortable-tabs-strip-aKussO2c.js} +1 -1
  79. package/dist/assets/speechSettingsQueries-B6qf-mCh.js +4 -0
  80. package/dist/assets/src-NKCZI3Lg.css +2 -0
  81. package/dist/assets/{store-7wItZZ7_.js → store-BeD2keas.js} +4 -4
  82. package/dist/assets/{terminalApi-C0_GUlPR.js → terminalApi-B5o8UqWA.js} +1 -1
  83. package/dist/assets/{textarea-BU8JtaSQ.js → textarea-DmKaqHSb.js} +1 -1
  84. package/dist/assets/{tooltip-C8DhNU1d.js → tooltip-DUKu4nC6.js} +1 -1
  85. package/dist/assets/{touch-gestures-zegXCZEP.js → touch-gestures-K2_ZOkKW.js} +1 -1
  86. package/dist/assets/types-DRTMRW4R.js +2 -0
  87. package/dist/assets/{uk-BNrdZFvK.js → uk-CYZXWdd7.js} +3 -3
  88. package/dist/assets/{useAppFontEffects-Bs6kVjrE.js → useAppFontEffects-BiQf6tgZ.js} +55 -51
  89. package/dist/assets/useAppFontEffects-RpgNbjA4.css +1 -0
  90. package/dist/assets/{useAssistantUIStore-NlYBroMc.js → useAssistantUIStore-C9FPlYQz.js} +1 -1
  91. package/dist/assets/{useDesktopWindowControlsLayout-COBTly74.js → useDesktopWindowControlsLayout-DJxNmCWb.js} +1 -1
  92. package/dist/assets/useEffectiveDirectory-B8q00InF.js +1 -0
  93. package/dist/assets/{useFontPreferences-DQAS94Z4.js → useFontPreferences-DMiP_Yy-.js} +1 -1
  94. package/dist/assets/useMobileNavigationStore-Bn4SaalY.js +418 -0
  95. package/dist/assets/{useThemeSystem-8jhE4Zyk.js → useThemeSystem-CGF5jnIh.js} +1 -1
  96. package/dist/assets/{useUIStore-96W41KFb.js → useUIStore-DI7va1HH.js} +1 -1
  97. package/dist/assets/{useWorkerHighlightedLines-BZUO0Si5.js → useWorkerHighlightedLines-B6lWNk01.js} +1 -1
  98. package/dist/assets/{vendor-base-ui-CdzJ6My_.js → vendor-base-ui-BQjbsJ43.js} +1 -1
  99. package/dist/assets/{vendor-cmdk-RDxC-9Iz.js → vendor-cmdk-C3oBVL9X.js} +1 -1
  100. package/dist/assets/{vendor-dnd-kit-accessibility-COSwgjFs.js → vendor-dnd-kit-accessibility-DxpFzZhi.js} +1 -1
  101. package/dist/assets/{vendor-dnd-kit-core-5pNnzVdw.js → vendor-dnd-kit-core-B3g3zWQd.js} +1 -1
  102. package/dist/assets/{vendor-dnd-kit-sortable-Dm50I0m7.js → vendor-dnd-kit-sortable-BKewx0Py.js} +1 -1
  103. package/dist/assets/{vendor-framer-motion-BQ3-sJMO.js → vendor-framer-motion-C1twy-GF.js} +1 -1
  104. package/dist/assets/{vendor-markstream-react-Bm0cO70Z.js → vendor-markstream-react-BlbOg72y.js} +3 -3
  105. package/dist/assets/vendor-motion-BmLx2V78.js +1 -0
  106. package/dist/assets/{vendor-opencode-client-fxfj4IA_.js → vendor-opencode-client-UL_TecvQ.js} +1 -1
  107. package/dist/assets/{vendor-opencode-plugin-CQ5ogY33.js → vendor-opencode-plugin-Bw7Q6Nv9.js} +1 -1
  108. package/dist/assets/{vendor-pierre-diffs-DPBtNDJ5.js → vendor-pierre-diffs-Bj9Nqn6w.js} +1 -1
  109. package/dist/assets/{vendor-react-BP2cRVqX.js → vendor-react-D5d-V1vN.js} +1 -1
  110. package/dist/assets/{vendor-react-drawio-Ck9ZKdNN.js → vendor-react-drawio-C-iPmmED.js} +1 -1
  111. package/dist/assets/{vendor-reactuses-core-BJ-jJ4YM.js → vendor-reactuses-core-BcebBLwF.js} +1 -1
  112. package/dist/assets/{vendor-solid-js-Dmt4_-Zk.js → vendor-solid-js-0T254UHG.js} +1 -1
  113. package/dist/assets/{vendor-sonner-ZS8XIOVl.js → vendor-sonner-r2EJnfoo.js} +1 -1
  114. package/dist/assets/{vendor-stream-diffs-TgIdH4lX.js → vendor-stream-diffs-BnLmeqg2.js} +2 -2
  115. package/dist/assets/{vendor-tanstack-react-query-CdqCAt40.js → vendor-tanstack-react-query-C4SG3JZB.js} +1 -1
  116. package/dist/assets/vendor-tanstack-react-virtual-BeZn51tF.js +1 -0
  117. package/dist/assets/{vendor-zustand-o69pgTEK.js → vendor-zustand-B43HCgwC.js} +1 -1
  118. package/dist/assets/{zh-CN-DMvJXS23.js → zh-CN-CMLBHipA.js} +3 -3
  119. package/dist/assets/{zh-TW-D0wsKLs1.js → zh-TW-CJlmnnhK.js} +3 -3
  120. package/dist/index.html +18 -18
  121. package/dist/mini-chat.html +18 -18
  122. package/dist/mobile.html +18 -18
  123. package/package.json +1 -1
  124. package/server/lib/assistants/DOCUMENTATION.md +58 -37
  125. package/server/lib/assistants/cards.js +4 -0
  126. package/server/lib/assistants/cards.test.js +11 -1
  127. package/server/lib/assistants/contact-attachments.http.test.js +31 -7
  128. package/server/lib/assistants/contact-store.js +54 -27
  129. package/server/lib/assistants/contact-store.test.js +69 -8
  130. package/server/lib/assistants/contact-tools.js +68 -84
  131. package/server/lib/assistants/contact-tools.test.js +85 -42
  132. package/server/lib/assistants/harness.js +6 -3
  133. package/server/lib/assistants/harness.test.js +25 -10
  134. package/server/lib/assistants/service.js +276 -145
  135. package/server/lib/assistants/service.test.js +954 -54
  136. package/server/lib/assistants/yuri-project.http.test.js +47 -0
  137. package/server/lib/assistants/yuri-tools.js +1 -1
  138. package/server/lib/assistants/yuri-tools.test.js +3 -2
  139. package/server/lib/git/DOCUMENTATION.md +6 -0
  140. package/server/lib/git/branches.test.js +18 -0
  141. package/server/lib/git/service.js +6 -3
  142. package/server/lib/llm/DOCUMENTATION.md +15 -7
  143. package/server/lib/llm/bridge-client.js +58 -34
  144. package/server/lib/llm/bridge-client.test.js +123 -16
  145. package/server/lib/notifications/APNS.md +7 -4
  146. package/server/lib/notifications/DOCUMENTATION.md +3 -1
  147. package/server/lib/notifications/apns-runtime.js +14 -8
  148. package/server/lib/notifications/apns-runtime.test.js +28 -0
  149. package/server/lib/notifications/family-completion-gate.js +37 -31
  150. package/server/lib/notifications/family-completion-gate.test.js +32 -0
  151. package/server/lib/opencode/DOCUMENTATION.md +6 -0
  152. package/server/lib/opencode/hmr-isolation.test.js +56 -0
  153. package/server/lib/opencode/lifecycle.js +23 -27
  154. package/server/lib/opencode/network-runtime.js +8 -14
  155. package/server/lib/opencode/network-runtime.test.js +4 -4
  156. package/server/lib/opencode/proxy.js +2 -1
  157. package/server/lib/opencode/proxy.test.js +1 -0
  158. package/server/lib/relay/DOCUMENTATION.md +8 -1
  159. package/server/lib/relay/relay-server.e2e.test.ts +102 -1
  160. package/server/lib/relay/service.js +1 -1
  161. package/server/lib/relay/service.test.js +14 -1
  162. package/server/lib/request-cors.js +1 -1
  163. package/server/lib/request-cors.test.js +13 -1
  164. package/server/lib/session-goal/DOCUMENTATION.md +3 -0
  165. package/server/lib/session-goal/runtime.js +0 -4
  166. package/server/lib/session-index/DOCUMENTATION.md +18 -4
  167. package/server/lib/session-index/event-ingest.js +6 -0
  168. package/server/lib/session-index/event-ingest.test.js +10 -0
  169. package/server/lib/session-index/service.js +89 -13
  170. package/server/lib/session-index/service.test.js +144 -1
  171. package/server/lib/session-metadata/routes.test.js +44 -0
  172. package/server/lib/tts/DOCUMENTATION.md +24 -2
  173. package/server/lib/tts/direct-speech.test.js +28 -3
  174. package/server/opencode-proxy.test.js +5 -5
  175. package/dist/assets/AgentAvatar--wjVXk3I.js +0 -1
  176. package/dist/assets/AssistantView-CSpW-4g6.js +0 -3
  177. package/dist/assets/Icon-Bn4Eec3Y.js +0 -1
  178. package/dist/assets/MarkdownRenderer-DP2a0lfG.js +0 -2
  179. package/dist/assets/MobileDetailNavigation-C9NHt08G.js +0 -1
  180. package/dist/assets/MobileTabPageHeader-qe23xT2-.js +0 -2
  181. package/dist/assets/MultiRunWindow-CvHADKf9.js +0 -1
  182. package/dist/assets/SettingsView-DK8Jkkhd.js +0 -29
  183. package/dist/assets/SettingsWindow-EP8KZok8.js +0 -1
  184. package/dist/assets/appThemeRegistry-BnQF2GlY.js +0 -1
  185. package/dist/assets/collapsible-DqfguRMp.js +0 -1
  186. package/dist/assets/dialog-BS-KgM5J.js +0 -1
  187. package/dist/assets/image-loading-DJZLvhMd.js +0 -1
  188. package/dist/assets/insertionBoundaries-h2be7xbf.js +0 -1
  189. package/dist/assets/main-BpBrYqtJ.js +0 -169
  190. package/dist/assets/main-C2QklNP4.js +0 -2
  191. package/dist/assets/miniChat-C-9deNrt.js +0 -2
  192. package/dist/assets/mobile-DW7tEL-k.js +0 -2
  193. package/dist/assets/projectMeta-BwAS96mf.js +0 -1
  194. package/dist/assets/renderMobileApp-Bipi0hKv.js +0 -28
  195. package/dist/assets/runtimeConfig-Dx7Y6Yvp.js +0 -2
  196. package/dist/assets/runtimeEndpointReset-0buInzjw.js +0 -149
  197. package/dist/assets/runtimeEndpointReset-HYSytKO-.css +0 -1
  198. package/dist/assets/scheduledTaskNavigation-CYozx15H.js +0 -1
  199. package/dist/assets/sessionChangeSummary-BGisROOB.js +0 -1
  200. package/dist/assets/sessionChangeSummary-CRYRvpy7.css +0 -1
  201. package/dist/assets/speechSettingsQueries-CWXTghOr.js +0 -4
  202. package/dist/assets/src-BFsc_2gs.css +0 -2
  203. package/dist/assets/types-C9aO7yfx.js +0 -2
  204. package/dist/assets/useEffectiveDirectory-Bg0LmEqP.js +0 -1
  205. package/dist/assets/useMobileNavigationStore-hhiMBg5n.js +0 -418
  206. package/dist/assets/vendor-motion-B4xmxmaP.js +0 -1
  207. package/dist/assets/vendor-tanstack-react-virtual-B_EO--9t.js +0 -1
@@ -21,6 +21,53 @@ import { createProjectRegistry } from '../projects/registry.js';
21
21
  const call = (name, args) => ({ completion: { choices: [{ message: { content: '', tool_calls: [{ id: `call_${name}`, type: 'function', function: { name, arguments: JSON.stringify(args) } }] } }] } });
22
22
 
23
23
  describe('HTTP → real contact Agent → project registry → worker admission', () => {
24
+ it('delivers a sourced peer message over HTTP and wakes only the recipient without worker or relay tools', async () => {
25
+ const directory = await fs.mkdtemp(path.join(os.tmpdir(), 'yuri-peer-http-'));
26
+ const createWorker = vi.fn();
27
+ const promptWorker = vi.fn();
28
+ external.client = { session: { create: createWorker, prompt: promptWorker } };
29
+ const complete = vi.fn(async ({ body }) => {
30
+ expect(body.tools.map((tool) => tool.function.name)).not.toContain('message_assistant');
31
+ expect(body.tools.map((tool) => tool.function.name)).not.toContain('assign_session');
32
+ expect(JSON.stringify(body.messages)).toContain('老大你好');
33
+ return { completion: { choices: [{ message: { content: '小小白你好,收到了。' } }] } };
34
+ });
35
+ external.complete = complete;
36
+ const app = express(); app.use(express.json());
37
+ const runtime = registerAssistantRoutes(app, {
38
+ dbPath: path.join(directory, 'assistants.sqlite'), yuriDataDir: directory,
39
+ buildOpenCodeUrl: (pathname) => `http://upstream.invalid${pathname}`, getOpenCodeAuthHeaders: () => ({}),
40
+ });
41
+ const server = http.createServer(app);
42
+ await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
43
+ const base = `http://127.0.0.1:${server.address().port}`;
44
+ const post = (route, body) => fetch(`${base}${route}`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
45
+ try {
46
+ const sender = await (await post('/api/yuri/assistants', { name: '小小白', providerID: 'p', modelID: 'm' })).json();
47
+ const recipient = await (await post('/api/yuri/assistants', { name: '大白', providerID: 'p', modelID: 'm' })).json();
48
+ const input = { messageID: 'http_peer_hello', toAssistantID: recipient.id, text: '老大你好' };
49
+ const response = await post(`/api/yuri/assistants/${sender.id}/contact/dm`, input);
50
+ expect(response.status).toBe(201);
51
+ const admitted = await response.json();
52
+ expect(admitted).toMatchObject({ admitted: true, fromAssistantID: sender.id, toAssistantID: recipient.id });
53
+ expect(await runtime.service.whenContactTurnSettled(admitted.messageID)).toMatchObject({ status: 'complete' });
54
+ const page = await (await fetch(`${base}/api/yuri/assistants/${recipient.id}/contact/messages`)).json();
55
+ expect(page.messages.map((message) => message.role)).toEqual(['assistant', 'peer', 'assistant']);
56
+ expect(page.messages[1]).toMatchObject({ fromAssistantName: '小小白', text: '老大你好' });
57
+ expect(page.messages[2].text).toBe('小小白你好,收到了。');
58
+ expect((await (await post(`/api/yuri/assistants/${sender.id}/contact/dm`, input)).json()).replayed).toBe(true);
59
+ expect((await post(`/api/yuri/assistants/${sender.id}/contact/dm`, { ...input, text: 'changed' })).status).toBe(409);
60
+ expect(complete).toHaveBeenCalledTimes(1);
61
+ expect(createWorker).not.toHaveBeenCalled();
62
+ expect(promptWorker).not.toHaveBeenCalled();
63
+ } finally {
64
+ runtime.close(); server.closeAllConnections();
65
+ await new Promise((resolve) => server.close(resolve));
66
+ external.complete = null; external.client = null;
67
+ await fs.rm(directory, { recursive: true, force: true });
68
+ }
69
+ });
70
+
24
71
  it('registers a cloned directory, sends hello and persists a real session card without manual Settings', async () => {
25
72
  const directory = await fs.mkdtemp(path.join(os.tmpdir(), 'yuri-project-http-'));
26
73
  const workspace = path.join(directory, 'cloned-app');
@@ -1,7 +1,7 @@
1
1
  export function createYuriContactToolGroups(tools) {
2
2
  return [
3
3
  { id: 'yuri.projects', description: 'Register an existing workspace before opening a coding session.', names: ['register_project'] },
4
- { id: 'yuri.assistants', description: 'Create a Bot or change its avatar.', names: ['create_assistant', 'update_avatar'] },
4
+ { id: 'yuri.assistants', description: 'Create another Bot.', names: ['create_assistant'] },
5
5
  { id: 'yuri.tasks', description: 'Create or update scheduled tasks (including pause/resume).', names: ['schedule_task', 'update_scheduled_task'] },
6
6
  ].map(({ id, description, names }) => ({ id, description, tools: tools.filter((tool) => names.includes(tool.name)) }))
7
7
  .filter((group) => group.tools.length > 0);
@@ -67,7 +67,8 @@ describe('assistant-only progressive business tools', () => {
67
67
  if (round === 1) {
68
68
  expect(names(body)).toContain('assign_session');
69
69
  expect(names(body)).toContain('load_tools');
70
- for (const name of ['register_project', 'create_assistant', 'update_avatar', 'schedule_task', 'update_scheduled_task']) expect(names(body)).not.toContain(name);
70
+ for (const name of ['register_project', 'create_assistant', 'schedule_task', 'update_scheduled_task']) expect(names(body)).not.toContain(name);
71
+ expect(names(body)).toContain('update_assistant_settings');
71
72
  expect(JSON.stringify(body)).not.toContain('register_project');
72
73
  return call('load_tools', { domain: 'yuri.projects' });
73
74
  }
@@ -143,7 +144,7 @@ describe('assistant-only progressive business tools', () => {
143
144
  const tools = [...createContactTools({}), ...createYuriContactTools({ registerProject })];
144
145
  await turn(tools, async ({ body }) => {
145
146
  expect(names(body)).toContain('list_scheduled_tasks');
146
- for (const name of ['load_tools', 'register_project', 'create_assistant', 'schedule_task', 'update_avatar']) expect(names(body)).not.toContain(name);
147
+ for (const name of ['load_tools', 'register_project', 'create_assistant', 'schedule_task', 'update_assistant_settings']) expect(names(body)).not.toContain(name);
147
148
  return { text: 'Reviewed.' };
148
149
  }, { readOnly: true });
149
150
  expect(registerProject).not.toHaveBeenCalled();
@@ -43,6 +43,12 @@ The following functions are exported and used by the web server:
43
43
 
44
44
  ### Branch Operations
45
45
  - `getBranches(directory)`: Read local branches and locally known remote-tracking refs, excluding remote HEAD aliases from `all`. This is an offline read: it never runs `ls-remote` or waits for remote authentication/network. Explicit Fetch updates remote-tracking refs; pruning is controlled by that operation. The returned `current` and `branches` metadata retain the Git snapshot shape.
46
+ `current` is empty for detached HEAD, not simple-git's pseudo branch label.
47
+ Unborn repositories resolve their actual symbolic HEAD name (no assumed
48
+ `main`/`master`). A confirmed non-repository returns an empty snapshot;
49
+ permission, unavailable-directory and other failures still reject so Query
50
+ refreshes retain their last valid data. Shared Web/Electron/mobile callers use
51
+ this contract; VS Code owns the equivalent native/raw Git projection.
46
52
  - `createBranch(directory, branchName, options)`: Create and checkout a new branch.
47
53
  - `checkoutBranch(directory, branchName)`: Checkout an existing branch.
48
54
  - `deleteBranch(directory, branch, options)`: Delete a branch (supports force flag).
@@ -37,3 +37,21 @@ test('branch failures remain errors instead of an authoritative empty list', asy
37
37
  git.branch.mockRejectedValue(new Error('repository unavailable'));
38
38
  await expect(getBranches('/repo')).rejects.toThrow('repository unavailable');
39
39
  });
40
+
41
+ test('detached HEAD has no current branch even when simple-git returns a pseudo label', async () => {
42
+ git.raw.mockResolvedValue('/repo\n');
43
+ git.branch.mockResolvedValue({ all: ['main'], current: 'HEAD detached at abc123', detached: true, branches: {} });
44
+ expect(await getBranches('/repo')).toEqual({ all: ['main'], current: '', branches: {} });
45
+ });
46
+
47
+ test('a confirmed non-repository returns an empty snapshot, not a transport failure', async () => {
48
+ git.raw.mockRejectedValue(new Error('fatal: not a git repository (or any of the parent directories): .git'));
49
+ git.branch.mockRejectedValue(new Error('fatal: not a git repository'));
50
+ expect(await getBranches('/plain')).toEqual({ all: [], current: '', branches: {} });
51
+ });
52
+
53
+ test('an unborn branch uses its real symbolic HEAD name without inventing a default', async () => {
54
+ git.raw.mockImplementation(async (args) => args[0] === 'symbolic-ref' ? 'trunk\n' : '/repo\n');
55
+ git.branch.mockResolvedValue({ all: [], current: '', detached: false, branches: {} });
56
+ expect(await getBranches('/repo')).toEqual({ all: [], current: 'trunk', branches: {} });
57
+ });
@@ -3232,10 +3232,10 @@ export async function commit(directory, message, options = {}) {
3232
3232
  }
3233
3233
 
3234
3234
  export async function getBranches(directory) {
3235
- const { git } = await createRepositoryGitContext(directory);
3236
-
3237
3235
  try {
3236
+ const { git } = await createRepositoryGitContext(directory);
3238
3237
  const result = await git.branch();
3238
+ const current = result.detached ? '' : result.current || (await git.raw(['symbolic-ref', '--quiet', '--short', 'HEAD'])).trim();
3239
3239
 
3240
3240
  // Listing branches is a local read. Explicit fetch updates remote-tracking
3241
3241
  // refs; startup must not wait on ls-remote or hide refs when a remote is offline.
@@ -3243,10 +3243,13 @@ export async function getBranches(directory) {
3243
3243
 
3244
3244
  return {
3245
3245
  all: filteredAll,
3246
- current: result.current,
3246
+ current,
3247
3247
  branches: result.branches
3248
3248
  };
3249
3249
  } catch (error) {
3250
+ if (isNotGitRepositoryError(error)) {
3251
+ return { all: [], current: '', branches: {} };
3252
+ }
3250
3253
  console.error('Failed to get branches:', error);
3251
3254
  throw error;
3252
3255
  }
@@ -15,14 +15,21 @@ start or replace OpenCode to provide inference.
15
15
  restarts and concurrent hosts running the same bundle reuse one directory and
16
16
  one Location instead of adding one per process. The plugin file is replaced
17
17
  atomically only when its content differs. Shutdown never deletes this shared
18
- directory. On first use per process, cleanup removes other `yuri-inference-*`
19
- directories (older bundles and the former per-process layout) unless upstream
20
- `debug.location.list` reports them loaded; an unreadable inventory skips the
21
- pass. Cleanup is best effort and never delays inference.
18
+ directory. The Host never automatically deletes other `yuri-inference-*`
19
+ directories: one service's `debug.location.list` cannot establish that another
20
+ service is not using them. Older bundles remain for OS/operator cleanup.
21
+ Each use checks that the staged plugin still exists; a missing file is
22
+ restaged through one shared preparation flight without rereading bundles on
23
+ the normal warm path.
22
24
  - Calls use the official authenticated `client.rpc(LlmBridge)` transport, scoped
23
25
  to that directory. `ready` verifies protocol version 2 and runtime service availability; only RPC-not-ready
24
- startup errors receive a bounded readiness retry. Generation is not rerun for
25
- arbitrary transport errors, because a response may already have been produced.
26
+ startup errors receive a bounded readiness retry. Persistent `rpc.unavailable`
27
+ restages the plugin and evicts/reloads only that isolated Location once, then
28
+ repeats the bounded readiness check. Concurrent callers on one upstream share
29
+ that reload; cancelling one caller does not cancel another caller's repair.
30
+ Other Locations, user sessions and global configuration are untouched.
31
+ Generation is never replayed by this recovery, including ambiguous transport
32
+ failures, because a response may already have been produced.
26
33
  - `bridge-plugin.js` runs **inside external OpenCode**. It reads that Location's
27
34
  live `ModelResolver.Service` through the RPC caller's Location context. The
28
35
  external service itself resolves the selected model/variant, active integration
@@ -79,7 +86,8 @@ files. Web build, prepack and development API scripts build it. At runtime the
79
86
  Host copies its bytes into the temporary directory, including when the Host
80
87
  source lives in Electron ASAR; external OpenCode needs no access to ASAR or
81
88
  Yuri's node_modules. The bundle has no machine-specific source directory.
82
- Shutdown removes the owned directory; a failed staging operation cleans up.
89
+ Shutdown forgets the cached directory without deleting it; failed staging only
90
+ removes its own incomplete temporary file.
83
91
 
84
92
  ## Completion contract
85
93
 
@@ -32,66 +32,89 @@ export async function prepareLlmBridgeDirectory({ pluginPath = BRIDGE_PLUGIN_PAT
32
32
  return directory;
33
33
  }
34
34
 
35
- /**
36
- * Removes bridge directories left by earlier builds or by the former per-process
37
- * temporary layout. A directory whose Location is still loaded upstream may be
38
- * in use by another host, so it stays until the upstream idle sweep unloads it.
39
- * Only failure to read the live inventory skips the whole pass.
40
- */
41
- export async function pruneStaleLlmBridgeDirectories({ client, keep, root = os.tmpdir(), fsLike = fs, signal }) {
42
- const entries = await Promise.resolve().then(() => client.debug.location.list(signal ? { signal } : undefined)).catch(() => null);
43
- if (!Array.isArray(entries)) return [];
44
- const live = new Set(entries.map((entry) => entry?.directory && path.resolve(entry.directory)).filter(Boolean));
45
- const names = await fsLike.readdir(root).catch(() => []);
46
- const removed = [];
47
- for (const name of names) {
48
- if (!name.startsWith('yuri-inference-')) continue;
49
- const directory = path.join(root, name);
50
- if (directory === keep || live.has(directory)) continue;
51
- const resolved = await fsLike.realpath(directory).catch(() => directory);
52
- if (live.has(resolved)) continue;
53
- await fsLike.rm(directory, { recursive: true, force: true }).then(() => removed.push(directory), () => undefined);
54
- }
55
- return removed;
56
- }
57
-
58
35
  let directoryPromise;
59
- let pruneStarted = false;
60
- export async function ensureLlmBridgeDirectory({ client } = {}) {
36
+ export async function ensureLlmBridgeDirectory() {
61
37
  if (!directoryPromise) directoryPromise = prepareLlmBridgeDirectory()
62
38
  .catch(error => { directoryPromise = undefined; throw error; });
63
- const directory = await directoryPromise;
64
- if (client && !pruneStarted) {
65
- pruneStarted = true;
66
- // Cleanup is best effort and never delays inference.
67
- void pruneStaleLlmBridgeDirectories({ client, keep: directory }).catch(() => undefined);
39
+ const pending = directoryPromise;
40
+ const directory = await pending;
41
+ try {
42
+ await fs.access(path.join(directory, '.opencode', 'plugins', 'yuri-llm.js'));
43
+ return directory;
44
+ } catch (error) {
45
+ if (error?.code !== 'ENOENT') throw error;
46
+ if (directoryPromise === pending) {
47
+ directoryPromise = prepareLlmBridgeDirectory()
48
+ .catch(error => { directoryPromise = undefined; throw error; });
49
+ }
50
+ return directoryPromise;
68
51
  }
69
- return directory;
70
52
  }
71
53
 
72
54
  // The content-addressed directory may be shared with other hosts, so shutdown
73
55
  // only forgets it and never deletes it.
74
56
  export async function stopLlmBridgeDirectory() {
75
57
  directoryPromise = undefined;
76
- pruneStarted = false;
77
58
  }
78
59
 
60
+ // A Location inventory describes one OpenCode service, not every service using
61
+ // this temporary root. Never delete peer directories based on that inventory.
62
+ const bridgeReloads = new Map();
63
+ const reloadBridgeLocation = ({ key, client, directory, ensureBridgeDirectory }) => {
64
+ const current = bridgeReloads.get(key);
65
+ if (current?.directory === directory) return current.promise;
66
+ const entry = { directory, promise: null };
67
+ entry.promise = Promise.resolve().then(async () => {
68
+ await ensureBridgeDirectory({ client });
69
+ await client.debug.location.evict({ location: { directory } });
70
+ await client.plugin.list({ location: { directory } });
71
+ }).finally(() => {
72
+ if (bridgeReloads.get(key) === entry) bridgeReloads.delete(key);
73
+ });
74
+ // A caller may cancel before subscribing; a shared repair can still finish.
75
+ void entry.promise.catch(() => undefined);
76
+ bridgeReloads.set(key, entry);
77
+ return entry.promise;
78
+ };
79
+
80
+ const awaitBridgeReload = async (promise, signal) => {
81
+ signal?.throwIfAborted();
82
+ if (!signal) return promise;
83
+ let abort;
84
+ const cancelled = new Promise((_, reject) => {
85
+ abort = () => reject(signal.reason);
86
+ signal.addEventListener('abort', abort, { once: true });
87
+ });
88
+ try { return await Promise.race([promise, cancelled]); }
89
+ finally { signal.removeEventListener('abort', abort); }
90
+ };
91
+
79
92
  export async function generateCleanCompletion({ buildOpenCodeUrl, getOpenCodeAuthHeaders, clientFactory,
80
93
  providerID, modelID, variant, messages, tools, cacheKey = randomUUID(), maxOutputTokens, signal,
81
94
  ensureBridgeDirectory = ensureLlmBridgeDirectory,
82
95
  }) {
83
96
  signal?.throwIfAborted();
84
- const client = clientFactory?.() ?? OpenCode.make({ baseUrl: buildOpenCodeUrl('/', '').replace(/\/$/, ''), headers: getOpenCodeAuthHeaders() });
97
+ const providedClient = clientFactory?.();
98
+ const baseUrl = providedClient ? null : buildOpenCodeUrl('/', '').replace(/\/$/, '');
99
+ const client = providedClient ?? OpenCode.make({ baseUrl, headers: getOpenCodeAuthHeaders() });
85
100
  const directory = await ensureBridgeDirectory({ client });
86
101
  const options = { location: { directory }, signal };
87
102
  const rpc = client.rpc(LlmBridge);
88
103
  // Loading this isolated Location activates only its own plugin file, without global config writes.
89
104
  await client.plugin.list({ location: { directory } }, { signal });
90
105
  let ready;
106
+ let reloaded = false;
91
107
  for (let attempt = 0; ; attempt++) {
92
108
  try { ready = await rpc.ready({}, options); break; }
93
109
  catch (error) {
94
- if (signal?.aborted || error?.type !== 'rpc.unavailable' || attempt >= 20) throw error;
110
+ if (signal?.aborted || error?.type !== 'rpc.unavailable') throw error;
111
+ if (attempt >= 20) {
112
+ if (reloaded || typeof client.debug?.location?.evict !== 'function') throw error;
113
+ reloaded = true;
114
+ await awaitBridgeReload(reloadBridgeLocation({ key: baseUrl ?? client, client, directory, ensureBridgeDirectory }), signal);
115
+ attempt = -1;
116
+ continue;
117
+ }
95
118
  await new Promise((resolve, reject) => {
96
119
  const abort = () => { clearTimeout(timer); signal.removeEventListener('abort', abort); reject(signal.reason); };
97
120
  const timer = setTimeout(() => { signal?.removeEventListener('abort', abort); resolve(); }, 250);
@@ -100,6 +123,7 @@ export async function generateCleanCompletion({ buildOpenCodeUrl, getOpenCodeAut
100
123
  });
101
124
  }
102
125
  }
126
+ signal?.throwIfAborted();
103
127
  if (ready.version !== LLM_BRIDGE_VERSION) throw new Error('Incompatible Yuri LLM bridge');
104
128
  const result = await rpc.generate({ providerID, modelID, ...(variant ? { variant } : {}), messages,
105
129
  ...(tools ? { tools } : {}), cacheKey, ...(maxOutputTokens ? { maxOutputTokens } : {}),
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
2
2
  import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  import { afterEach, describe, expect, it, vi } from 'vitest';
5
- import { generateCleanCompletion, prepareLlmBridgeDirectory, pruneStaleLlmBridgeDirectories } from './bridge-client.js';
5
+ import { ensureLlmBridgeDirectory, generateCleanCompletion, prepareLlmBridgeDirectory, stopLlmBridgeDirectory } from './bridge-client.js';
6
6
  import { LLM_BRIDGE_VERSION } from './bridge-contract.js';
7
7
 
8
8
  describe('external OpenCode inference bridge', () => {
@@ -36,12 +36,102 @@ describe('external OpenCode inference bridge', () => {
36
36
  } finally { vi.useRealTimers(); }
37
37
  });
38
38
 
39
- it('passes the client to directory preparation so stale bridge cleanup can consult upstream', async () => {
39
+ it('passes the current client to the injected directory preparation', async () => {
40
40
  const client = { plugin: { list: async () => [] }, rpc: () => ({ ready: async () => ({ version: LLM_BRIDGE_VERSION }), generate: async () => ({ text: '', toolCalls: [] }) }) };
41
41
  const ensureBridgeDirectory = vi.fn(async () => '/isolated');
42
42
  await generateCleanCompletion({ clientFactory: () => client, ensureBridgeDirectory });
43
43
  expect(ensureBridgeDirectory).toHaveBeenCalledWith({ client });
44
44
  });
45
+
46
+ it('reloads only the isolated Location when a recreated plugin is absent from the loaded runtime', async () => {
47
+ vi.useFakeTimers();
48
+ try {
49
+ let loaded = false;
50
+ const ready = vi.fn(async () => {
51
+ if (!loaded) throw { type: 'rpc.unavailable' };
52
+ return { version: LLM_BRIDGE_VERSION };
53
+ });
54
+ const generate = vi.fn(async () => ({ text: 'recovered', toolCalls: [] }));
55
+ const evict = vi.fn(async () => { loaded = true; });
56
+ const client = {
57
+ plugin: { list: vi.fn(async () => ({ data: [] })) },
58
+ debug: { location: { evict } },
59
+ rpc: () => ({ ready, generate }),
60
+ };
61
+ const ensureBridgeDirectory = vi.fn(async () => '/isolated/bridge');
62
+ const result = generateCleanCompletion({ clientFactory: () => client, ensureBridgeDirectory }).catch(error => error);
63
+ await vi.runAllTimersAsync();
64
+ expect(await result).toMatchObject({ text: 'recovered' });
65
+ expect(evict).toHaveBeenCalledExactlyOnceWith({ location: { directory: '/isolated/bridge' } });
66
+ expect(ensureBridgeDirectory).toHaveBeenCalledTimes(2);
67
+ expect(generate).toHaveBeenCalledTimes(1);
68
+ } finally { vi.useRealTimers(); }
69
+ });
70
+
71
+ it('bounds readiness recovery and never generates while RPC remains unavailable', async () => {
72
+ vi.useFakeTimers();
73
+ try {
74
+ const ready = vi.fn(async () => { throw { type: 'rpc.unavailable' }; });
75
+ const generate = vi.fn();
76
+ const evict = vi.fn(async () => {});
77
+ const client = { plugin: { list: async () => [] }, debug: { location: { evict } }, rpc: () => ({ ready, generate }) };
78
+ const result = generateCleanCompletion({ clientFactory: () => client, ensureBridgeDirectory: async () => '/isolated' }).catch(error => error);
79
+ await vi.runAllTimersAsync();
80
+ expect(await result).toMatchObject({ type: 'rpc.unavailable' });
81
+ expect(ready).toHaveBeenCalledTimes(42);
82
+ expect(evict).toHaveBeenCalledTimes(1);
83
+ expect(generate).not.toHaveBeenCalled();
84
+ expect(vi.getTimerCount()).toBe(0);
85
+ } finally { vi.useRealTimers(); }
86
+ });
87
+
88
+ it('shares recovery without letting a cancelled caller abort its peer or generate late', async () => {
89
+ vi.useFakeTimers();
90
+ try {
91
+ let loaded = false;
92
+ let release;
93
+ const ready = vi.fn(async () => {
94
+ if (!loaded) throw { type: 'rpc.unavailable' };
95
+ return { version: LLM_BRIDGE_VERSION };
96
+ });
97
+ const generate = vi.fn(async () => ({ text: 'recovered' }));
98
+ const evict = vi.fn(() => new Promise(resolve => { release = () => { loaded = true; resolve(); }; }));
99
+ const client = { plugin: { list: async () => [] }, debug: { location: { evict } }, rpc: () => ({ ready, generate }) };
100
+ const controller = new AbortController();
101
+ const input = { clientFactory: () => client, ensureBridgeDirectory: async () => '/isolated' };
102
+ const first = generateCleanCompletion({ ...input, signal: controller.signal }).catch(error => error);
103
+ const second = generateCleanCompletion(input);
104
+ await vi.advanceTimersByTimeAsync(5_000);
105
+ expect(evict).toHaveBeenCalledTimes(1);
106
+ const reason = new Error('user cancelled');
107
+ controller.abort(reason);
108
+ expect(await first).toBe(reason);
109
+ release();
110
+ expect(await second).toMatchObject({ text: 'recovered' });
111
+ expect(generate).toHaveBeenCalledTimes(1);
112
+ expect(vi.getTimerCount()).toBe(0);
113
+ } finally { vi.useRealTimers(); }
114
+ });
115
+
116
+ it.each(['authentication_required', 'transport'])('does not reload a Location for %s readiness errors', async (type) => {
117
+ const error = { type };
118
+ const evict = vi.fn();
119
+ const generate = vi.fn();
120
+ const client = { plugin: { list: async () => [] }, debug: { location: { evict } }, rpc: () => ({ ready: async () => { throw error; }, generate }) };
121
+ await expect(generateCleanCompletion({ clientFactory: () => client, ensureBridgeDirectory: async () => '/isolated' })).rejects.toBe(error);
122
+ expect(evict).not.toHaveBeenCalled();
123
+ expect(generate).not.toHaveBeenCalled();
124
+ });
125
+
126
+ it('never replays generation even when it returns rpc.unavailable after readiness', async () => {
127
+ const error = { type: 'rpc.unavailable' };
128
+ const evict = vi.fn();
129
+ const generate = vi.fn(async () => { throw error; });
130
+ const client = { plugin: { list: async () => [] }, debug: { location: { evict } }, rpc: () => ({ ready: async () => ({ version: LLM_BRIDGE_VERSION }), generate }) };
131
+ await expect(generateCleanCompletion({ clientFactory: () => client, ensureBridgeDirectory: async () => '/isolated' })).rejects.toBe(error);
132
+ expect(generate).toHaveBeenCalledTimes(1);
133
+ expect(evict).not.toHaveBeenCalled();
134
+ });
45
135
  });
46
136
 
47
137
  describe('bridge directory lifecycle', () => {
@@ -52,6 +142,8 @@ describe('bridge directory lifecycle', () => {
52
142
  return root;
53
143
  };
54
144
  afterEach(async () => {
145
+ await stopLlmBridgeDirectory();
146
+ vi.restoreAllMocks();
55
147
  await Promise.all(roots.splice(0).map((root) => fs.rm(root, { recursive: true, force: true })));
56
148
  });
57
149
 
@@ -74,23 +166,38 @@ describe('bridge directory lifecycle', () => {
74
166
  expect((await fs.readdir(path.join(second, '.opencode', 'plugins')))).toEqual(['yuri-llm.js']);
75
167
  });
76
168
 
77
- it('prunes stale bridge directories except the current and upstream-loaded ones', async () => {
169
+ it('never deletes another upstream service\'s bridge directory', async () => {
170
+ const root = await makeRoot();
171
+ vi.spyOn(os, 'tmpdir').mockReturnValue(root);
172
+ const peer = path.join(root, 'yuri-inference-other-service');
173
+ await fs.mkdir(peer);
174
+ const list = vi.fn(async () => []);
175
+ await ensureLlmBridgeDirectory({ client: { debug: { location: { list } } } });
176
+ expect(list).not.toHaveBeenCalled();
177
+ expect(await fs.stat(peer)).toBeDefined();
178
+ });
179
+
180
+ it('restages a deleted plugin instead of trusting a cached directory path', async () => {
78
181
  const root = await makeRoot();
79
- const make = async (name) => { const dir = path.join(root, name); await fs.mkdir(dir); return dir; };
80
- const keep = await make('yuri-inference-current');
81
- const loaded = await make('yuri-inference-loaded');
82
- const stale = await make('yuri-inference-AbC123');
83
- const unrelated = await make('other-dir');
84
- const client = { debug: { location: { list: vi.fn(async () => [{ directory: loaded }]) } } };
85
- expect(await pruneStaleLlmBridgeDirectories({ client, keep, root })).toEqual([stale]);
86
- expect((await fs.readdir(root)).sort()).toEqual([path.basename(unrelated), path.basename(keep), path.basename(loaded)].sort());
182
+ vi.spyOn(os, 'tmpdir').mockReturnValue(root);
183
+ const directory = await ensureLlmBridgeDirectory();
184
+ const target = path.join(directory, '.opencode', 'plugins', 'yuri-llm.js');
185
+ const code = await fs.readFile(target);
186
+ await fs.rm(directory, { recursive: true });
187
+ expect(await ensureLlmBridgeDirectory()).toBe(directory);
188
+ expect(await fs.readFile(target)).toEqual(code);
87
189
  });
88
190
 
89
- it('skips pruning when the upstream inventory cannot be read', async () => {
191
+ it('checks warm staged assets without rereading the bundle or rewriting files', async () => {
90
192
  const root = await makeRoot();
91
- await fs.mkdir(path.join(root, 'yuri-inference-stale'));
92
- const client = { debug: { location: { list: vi.fn(async () => { throw new Error('503'); }) } } };
93
- expect(await pruneStaleLlmBridgeDirectories({ client, keep: '/none', root })).toEqual([]);
94
- expect(await fs.readdir(root)).toEqual(['yuri-inference-stale']);
193
+ vi.spyOn(os, 'tmpdir').mockReturnValue(root);
194
+ const directory = await ensureLlmBridgeDirectory();
195
+ const read = vi.spyOn(fs, 'readFile');
196
+ const write = vi.spyOn(fs, 'writeFile');
197
+ const access = vi.spyOn(fs, 'access');
198
+ for (let index = 0; index < 50; index++) expect(await ensureLlmBridgeDirectory()).toBe(directory);
199
+ expect(access).toHaveBeenCalledTimes(50);
200
+ expect(read).not.toHaveBeenCalled();
201
+ expect(write).not.toHaveBeenCalled();
95
202
  });
96
203
  });
@@ -138,10 +138,13 @@ is server-global, so every device token of a server sees the same badge.
138
138
 
139
139
  ## Modes
140
140
 
141
- - **Relay (default):** Host has no Apple key. Unless `YURI_PUSH_RELAY_URL` is set, the
142
- Host maps the effective Relay `wss://`/`ws://` URL to the same host as `https://`/`http://`
143
- `/v1/push/send` (register URL is `/v1/push/register-token`). A Relay switch re-registers
144
- persisted tokens and binds them again before the first send.
141
+ - **Relay (default):** Host has no Apple key. `YURI_PUSH_RELAY_URL` selects the Push
142
+ send URL independently. Without that override, a custom effective Relay `wss://`/`ws://`
143
+ URL maps to same-host `https://`/`http://` `/v1/push/send` (register URL is
144
+ `/v1/push/register-token`). The product default Workers Relay provides data transport
145
+ only: APNs and Live Activity delivery require a separate Push URL or direct credentials,
146
+ and no device tokens are sent to that Worker. A Push origin switch re-registers persisted
147
+ tokens and binds them again before the first send. Resolver failure leaves Push unavailable.
145
148
  - **Direct (fallback):** set `YURI_PUSH_RELAY_DISABLED=true` + `YURI_APNS_KEY_ID/
146
149
  TEAM_ID/P8` to sign+send from the server itself (HTTP/2 + ES256 JWT); no relay binding needed.
147
150
 
@@ -14,7 +14,7 @@ Android notification-only subscriptions send the App locale in `Accept-Language`
14
14
  - `packages/web/server/lib/notifications/index.js`: public entrypoint imported by `packages/web/server/index.js`.
15
15
  - `packages/web/server/lib/notifications/routes.js`: route registration for push, visibility, and session status/attention endpoints.
16
16
  - `packages/web/server/lib/notifications/push-runtime.js`: push subscription persistence, VAPID initialization, and UI visibility runtime.
17
- - `packages/web/server/lib/notifications/apns-runtime.js`: native iOS APNs device-token persistence + delivery, plus a separate Live Activity token store and `end` send path. Two modes: **relay** (default — sign + POST tokens + generic text to the isolated Push Relay in `packages/relay-server/src/push/`, which holds the project APNs key) and **direct** (fallback — sign ES256 JWT with Node crypto + HTTP/2, when `YURI_PUSH_RELAY_DISABLED=true`). Unless `YURI_PUSH_RELAY_URL` is set, the Host maps the effective Relay `wss`/`ws` URL to the same host as `https`/`http` `/v1/push/send`. Before each relay send, the runtime checks an in-memory registration success cache (keyed by current register URL + token + platform) and only POSTs `/v1/push/register-token` for cache misses; only successfully bound tokens are sent. Switching Relay/Push URL clears that cache so persisted tokens re-bind to the new origin on the next send or `reRegisterAllTokens()`. Each server has an auto-generated ECDSA P-256 keypair (`getOrCreateRelayKeypair`, persisted in settings); it binds tokens on the relay (`/v1/push/register-token`) and signs every relay request, so the relay only delivers to tokens bound to that server. APNs is the iOS app's sole notification channel (no local notifications) and is NOT gated on UI visibility — iOS suppresses the foreground banner instead. APNs push carries only generic text (scenario title + session name) — see `APNS.md`. Android uses the separate native notification stream described above. Live Activity tokens are persisted beside alert tokens in the same file (`version` 2, `liveActivityTokensBySession`) without mixing the two token types; v1 files remain readable. Live Activity relay bind/send uses `/v1/push/register-live-activity-token`, `/v1/push/unregister-live-activity-token`, and `/v1/push/live-activity`.
17
+ - `packages/web/server/lib/notifications/apns-runtime.js`: native iOS APNs device-token persistence + delivery, plus a separate Live Activity token store and `end` send path. Two modes: **relay** (default — sign + POST tokens + generic text to the isolated Push Relay in `packages/relay-server/src/push/`, which holds the project APNs key) and **direct** (fallback — sign ES256 JWT with Node crypto + HTTP/2, when `YURI_PUSH_RELAY_DISABLED=true`). `YURI_PUSH_RELAY_URL` explicitly selects an independent Push service. Otherwise, only a custom effective Relay `wss`/`ws` URL maps to same-host `https`/`http` `/v1/push/send`; the product default Workers Relay has no Push service and receives no device tokens. An invalid or failed Relay resolver leaves Push unavailable rather than falling back to a hosted origin. Before each relay send, the runtime checks an in-memory registration success cache (keyed by current register URL + token + platform) and only POSTs `/v1/push/register-token` for cache misses; only successfully bound tokens are sent. Switching Relay/Push URL clears that cache so persisted tokens re-bind to the new origin on the next send or `reRegisterAllTokens()`. Each server has an auto-generated ECDSA P-256 keypair (`getOrCreateRelayKeypair`, persisted in settings); it binds tokens on the relay (`/v1/push/register-token`) and signs every relay request, so the relay only delivers to tokens bound to that server. APNs is the iOS app's sole notification channel (no local notifications) and is NOT gated on UI visibility — iOS suppresses the foreground banner instead. APNs push carries only generic text (scenario title + session name) — see `APNS.md`. Android uses the separate native notification stream described above. Live Activity tokens are persisted beside alert tokens in the same file (`version` 2, `liveActivityTokensBySession`) without mixing the two token types; v1 files remain readable. Live Activity relay bind/send uses `/v1/push/register-live-activity-token`, `/v1/push/unregister-live-activity-token`, and `/v1/push/live-activity`.
18
18
  - `packages/web/server/lib/notifications/emitter-runtime.js`: desktop/stdout + UI SSE notification emission runtime.
19
19
  - `packages/web/server/lib/notifications/runtime.js`: trigger runtime for OpenCode event-driven notification fanout.
20
20
  - Assistant-owned scheduled results first enter the assistant's read-only result
@@ -63,6 +63,8 @@ Ordinary completion means the whole root-session family has stopped. An assistan
63
63
 
64
64
  Failed/malformed activity or unknown/cyclic ancestry defers completion rather than treating it as empty. While candidates exist, a single two-second retry timer recovers failed reads and missed child terminal events; no candidates means no polling. Execution/retry/step starts invalidate in-flight eligibility, and a new root run cancels its older candidate. Parent failures, deletion and user interruption cancel success. Event revisions fence stale reads and notification-template enrichment. Successful handling deduplicates terminal events for that root until a new execution starts, replacing the old five-second cooldown so a legitimate short next task can notify. Pending/dedup state is in-memory for the runtime lifetime; historical completions are not replayed after Host restart. `dispose()` clears completion retries and question/permission timers; VS Code also resets its gate on runtime switches.
65
65
 
66
+ Assistant worker watches reuse this gate and its `readSessionFamilyActivity` reader. Their `rootsOnly: false` mode supports explicitly watched child subtrees; `deduplicate: false` delegates one-shot consumption to the Assistant SQLite watch transaction instead of retaining parallel lifetime state. Defaults preserve ordinary Host/VS Code root-only notification deduplication. `flush()` lets Assistant reconciliation await currently admitted checks. Parent reads are deduplicated within each family snapshot with concurrency capped at four.
67
+
66
68
  Desktop, UI SSE, web-push, APNs and completion-triggered Live Activity end all pass this barrier. Existing visibility/settings, root/system-session suppression, goal-specific notifications and channel failure isolation remain delivery-owned. Error Live Activity updates and question/permission prompts remain immediate under their existing policies.
67
69
  - `createNotificationTriggerRuntime(dependencies)`: creates runtime-owned debounced trigger handling for OpenCode events.
68
70
  - Returned API:
@@ -2,9 +2,10 @@
2
2
  //
3
3
  // Device tokens are persisted per UI session (mirrors push-runtime.js). Delivery has two
4
4
  // modes, chosen at send time:
5
- // - Relay (default): POST tokens + generic text to the same-origin Push service
6
- // (`/v1/push/*` on the effective Relay host). The isolated Push process holds the
7
- // project APNs key and signs+sends — so users configure nothing.
5
+ // - Relay (default): POST tokens + generic text to a configured Push service
6
+ // (`YURI_PUSH_RELAY_URL`, or `/v1/push/*` on a custom Relay host). The product
7
+ // default Workers Relay has no Push service. The isolated Push process holds
8
+ // the project APNs key and signs+sends.
8
9
  // - Direct (fallback): sign an ES256 JWT with Node crypto and send over HTTP/2 ourselves,
9
10
  // for self-hosters who set YURI_APNS_* and YURI_PUSH_RELAY_DISABLED=true.
10
11
  // Wired into the same trigger fanout as web push (see runtime.js); the relay carries only
@@ -784,8 +785,8 @@ export const createApnsRuntime = (deps) => {
784
785
  req.end(body);
785
786
  });
786
787
 
787
- // Relay mode (default): the single APNs key lives in the isolated Push process on the same
788
- // Relay origin (`/v1/push/*`), not on each user's server — so users configure nothing. The
788
+ // Relay mode (default): the single APNs key lives in the isolated Push process, not on
789
+ // each user's server. Custom Relay origins may serve Push at `/v1/push/*`. The
789
790
  // server just POSTs device tokens + generic text; Push signs + sends and reports which tokens
790
791
  // to drop. Direct mode (below) is the fallback for self-hosters who set YURI_APNS_*
791
792
  // and disable the relay.
@@ -812,14 +813,19 @@ export const createApnsRuntime = (deps) => {
812
813
  const resolved = await resolveEffectiveRelayUrl();
813
814
  if (typeof resolved === 'string' && resolved.trim()) {
814
815
  if (derivePushSendUrlFromRelayUrl(resolved)) relayWsUrl = resolved.trim();
815
- else console.warn('[Push relay] resolver returned a non-WebSocket URL; Push Relay unavailable');
816
+ else {
817
+ console.warn('[Push relay] resolver returned a non-WebSocket URL; Push Relay unavailable');
818
+ return null;
819
+ }
816
820
  }
817
821
  } catch {
818
822
  console.warn('[Push relay] resolver failed; Push Relay unavailable');
823
+ return null;
819
824
  }
820
825
  }
821
- const url = derivePushSendUrlFromRelayUrl(relayWsUrl) || derivePushSendUrlFromRelayUrl(DEFAULT_RELAY_URL);
822
- if (!url) return null;
826
+ const url = derivePushSendUrlFromRelayUrl(relayWsUrl);
827
+ // The product Worker only forwards encrypted data; never send device tokens to it.
828
+ if (!url || url === derivePushSendUrlFromRelayUrl(DEFAULT_RELAY_URL)) return null;
823
829
  return buildRelayConfig(url);
824
830
  };
825
831
 
@@ -463,6 +463,34 @@ describe('apns runtime push relay derivation and re-register', () => {
463
463
  expect(registerUrls(fetchMock)).toEqual([]);
464
464
  });
465
465
 
466
+ it.each(['settings', 'env'])('does not derive Push from the product Worker selected through %s', async (source) => {
467
+ const relayUrl = 'wss://relay.useyuri.top/ws';
468
+ if (source === 'env') process.env.YURI_RELAY_URL = relayUrl;
469
+ let settings = source === 'settings' ? { privateRelay: { relayUrl } } : {};
470
+ const fetchMock = vi.fn(async () => jsonResponse({ ok: true, results: [] }));
471
+ vi.stubGlobal('fetch', fetchMock);
472
+ const runtime = createApnsRuntime(makeDeps({
473
+ readSettingsFromDiskMigrated: async () => settings,
474
+ writeSettingsToDisk: async (next) => { settings = next; },
475
+ resolveEffectiveRelayUrl: async () => resolveEffectiveRelayUrl({ settings }),
476
+ }));
477
+ await runtime.addOrUpdateApnsToken('s1', 'tokenA');
478
+ await runtime.sendApnsToAllUiSessions({ title: 'Ready' });
479
+ await expect(runtime.reRegisterAllTokens()).resolves.toEqual({ attempted: 0, succeeded: 0, failed: 0 });
480
+ expect(fetchMock).not.toHaveBeenCalled();
481
+ });
482
+
483
+ it('uses a separately configured Push service with the default Workers data Relay', async () => {
484
+ process.env.YURI_PUSH_RELAY_URL = 'https://push.example/v1/push/send';
485
+ const fetchMock = vi.fn(async () => jsonResponse({ ok: true, results: [] }));
486
+ vi.stubGlobal('fetch', fetchMock);
487
+ const runtime = createApnsRuntime(makeDeps());
488
+ await runtime.addOrUpdateApnsToken('s1', 'tokenA');
489
+ await runtime.sendApnsToAllUiSessions({ title: 'Ready' });
490
+ expect(registerUrls(fetchMock)).toEqual(['https://push.example/v1/push/register-token']);
491
+ expect(sendUrls(fetchMock)).toEqual(['https://push.example/v1/push/send']);
492
+ });
493
+
466
494
  it('re-registers persisted tokens against the current relay', async () => {
467
495
  process.env.YURI_PUSH_RELAY_URL = 'https://relay-a.test/v1/push/send';
468
496
  const fetchMock = vi.fn(async () => jsonResponse({ ok: true, results: [] }));