@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
@@ -25,8 +25,39 @@ export function completionEvent(payload) {
25
25
  return null;
26
26
  }
27
27
 
28
+ /** Read process activity and its authoritative ancestry once, with bounded metadata concurrency. */
29
+ export async function readSessionFamilyActivity({ loadActiveSessionIds, loadParent }) {
30
+ const membership = await loadActiveSessionIds();
31
+ if (!membership || typeof membership[Symbol.iterator] !== 'function') throw new Error('Unknown session activity');
32
+ const parents = new Map();
33
+ const parentOf = (id) => {
34
+ if (!parents.has(id)) parents.set(id, Promise.resolve().then(() => loadParent(id)).then((parent) => {
35
+ if (parent !== null && (typeof parent !== 'string' || !parent)) throw new Error('Unknown session ancestry');
36
+ return parent;
37
+ }));
38
+ return parents.get(id);
39
+ };
40
+ const activeRoots = new Set();
41
+ const activeSessions = new Set(membership);
42
+ const ids = [...activeSessions];
43
+ let cursor = 0;
44
+ await Promise.all(Array.from({ length: Math.min(4, ids.length) }, async () => {
45
+ while (cursor < ids.length) {
46
+ let id = ids[cursor++];
47
+ const seen = new Set();
48
+ while (id) {
49
+ if (seen.has(id)) throw new Error('Cyclic session ancestry');
50
+ seen.add(id);
51
+ activeRoots.add(id);
52
+ id = await parentOf(id);
53
+ }
54
+ }
55
+ }));
56
+ return { activeRoots, activeSessions, parentOf };
57
+ }
58
+
28
59
  /** Runtime-local completion barrier shared by Host fanout and VS Code. */
29
- export function createFamilyCompletionGate({ loadActiveSessionIds, loadParent, onReady, retryMs = 2000 }) {
60
+ export function createFamilyCompletionGate({ loadActiveSessionIds, loadParent, onReady, retryMs = 2000, rootsOnly = true, deduplicate = true }) {
30
61
  const pending = new Map();
31
62
  const delivered = new Set();
32
63
  const running = new Set();
@@ -50,39 +81,13 @@ export function createFamilyCompletionGate({ loadActiveSessionIds, loadParent, o
50
81
  const version = revision;
51
82
  const generation = epoch;
52
83
  const current = () => !disposed && epoch === generation && revision === version;
53
- const membership = await loadActiveSessionIds();
54
- if (!membership || typeof membership[Symbol.iterator] !== 'function') throw new Error('Unknown session activity');
55
- const active = new Set(membership);
56
- if (!current()) return;
57
- const parents = new Map();
58
- const parentOf = (id) => {
59
- if (!parents.has(id)) parents.set(id, Promise.resolve().then(() => loadParent(id)).then((parent) => {
60
- if (parent !== null && (typeof parent !== 'string' || !parent)) throw new Error('Unknown session ancestry');
61
- return parent;
62
- }));
63
- return parents.get(id);
64
- };
65
84
  // A running ID can belong to any pending root, including through idle ancestors.
66
- const activeRoots = new Set();
67
- const ids = [...active];
68
- let cursor = 0;
69
- await Promise.all(Array.from({ length: Math.min(4, ids.length) }, async () => {
70
- while (cursor < ids.length) {
71
- let id = ids[cursor++];
72
- const seen = new Set();
73
- while (id) {
74
- if (seen.has(id)) throw new Error('Cyclic session ancestry');
75
- seen.add(id);
76
- activeRoots.add(id);
77
- id = await parentOf(id);
78
- }
79
- }
80
- }));
85
+ const { activeRoots, parentOf } = await readSessionFamilyActivity({ loadActiveSessionIds, loadParent });
81
86
  for (const [id, candidate] of pending) {
82
87
  if (!current()) return;
83
88
  const parent = await parentOf(id);
84
89
  if (!current() || pending.get(id) !== candidate) continue;
85
- if (parent) { pending.delete(id); continue; }
90
+ if (rootsOnly && parent) { pending.delete(id); continue; }
86
91
  if (activeRoots.has(id)) continue;
87
92
  const isCurrent = () => current() && pending.get(id) === candidate;
88
93
  const handled = await onReady(candidate.payload, isCurrent);
@@ -90,7 +95,7 @@ export function createFamilyCompletionGate({ loadActiveSessionIds, loadParent, o
90
95
  // fanout must not make that same completion eligible a second time.
91
96
  if (handled === false || pending.get(id) !== candidate) continue;
92
97
  pending.delete(id);
93
- delivered.add(id);
98
+ if (deduplicate) delivered.add(id);
94
99
  running.delete(id);
95
100
  }
96
101
  };
@@ -122,6 +127,7 @@ export function createFamilyCompletionGate({ loadActiveSessionIds, loadParent, o
122
127
  };
123
128
 
124
129
  return {
130
+ flush: drain,
125
131
  observe(event, payload) {
126
132
  if (disposed || !event) return Promise.resolve();
127
133
  revision += 1;
@@ -135,7 +141,7 @@ export function createFamilyCompletionGate({ loadActiveSessionIds, loadParent, o
135
141
  } else if (kind === 'cancel') {
136
142
  running.delete(sessionId);
137
143
  pending.delete(sessionId);
138
- delivered.add(sessionId);
144
+ if (deduplicate) delivered.add(sessionId);
139
145
  } else if (kind === 'complete') {
140
146
  running.delete(sessionId);
141
147
  if (!delivered.has(sessionId)) {
@@ -17,6 +17,38 @@ const setup = (overrides = {}) => {
17
17
  };
18
18
 
19
19
  describe('family completion authority', () => {
20
+ it('bounds ancestor reads to four and deduplicates a shared parent across 40 active children', async () => {
21
+ const children = Array.from({ length: 40 }, (_, index) => `child-${index}`);
22
+ let concurrent = 0;
23
+ let peak = 0;
24
+ const loadActiveSessionIds = vi.fn(async () => children);
25
+ const loadParent = vi.fn(async (id) => {
26
+ concurrent += 1;
27
+ peak = Math.max(peak, concurrent);
28
+ await Promise.resolve();
29
+ concurrent -= 1;
30
+ return id === 'root' ? null : 'root';
31
+ });
32
+ const { onReady } = setup({ loadActiveSessionIds, loadParent });
33
+ await gate.observe(event('complete', 'root'), {});
34
+ expect(onReady).not.toHaveBeenCalled();
35
+ expect(loadActiveSessionIds).toHaveBeenCalledTimes(1);
36
+ expect(loadParent).toHaveBeenCalledTimes(41);
37
+ expect(loadParent.mock.calls.filter(([id]) => id === 'root')).toHaveLength(1);
38
+ expect(peak).toBeLessThanOrEqual(4);
39
+ });
40
+
41
+ it('can monitor an explicitly watched child subtree without notifying its ancestors', async () => {
42
+ const { state, onReady } = setup({ rootsOnly: false });
43
+ state.active = ['root', 'nested'];
44
+ await gate.observe(event('complete', 'child'), { id: 'child' });
45
+ expect(onReady).not.toHaveBeenCalled();
46
+ state.active = ['root'];
47
+ await gate.observe(event('changed', 'nested'), {});
48
+ expect(onReady).toHaveBeenCalledTimes(1);
49
+ expect(onReady.mock.calls[0][0]).toEqual({ id: 'child' });
50
+ });
51
+
20
52
  it('waits for an idle parent and all nested descendants, then emits only the parent once', async () => {
21
53
  const { state, onReady } = setup();
22
54
  state.active = ['child', 'nested', 'other'];
@@ -3,6 +3,12 @@
3
3
  ## Purpose
4
4
  This module provides OpenCode server integration utilities for the web server runtime, including configuration management and provider authentication.
5
5
 
6
+ OpenCode upstream calls are V2-only: startup/readiness probes use `/api/info`
7
+ without a legacy health fallback. Both Host SSE entrypoints forward upstream
8
+ to `/api/event`; the Host-owned global WebSocket route is unchanged. Status
9
+ diagnostics use provider/location/session-active V2 routes and location query
10
+ encoding, not removed V1 endpoints.
11
+
6
12
  ## Entrypoints and structure
7
13
  - Pairing transport discovery includes the serving host's `serverName` (OS
8
14
  hostname), not the browser's machine name. The pairing form uses it as an
@@ -0,0 +1,56 @@
1
+ import fs from 'node:fs';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ import { execFile } from 'node:child_process';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { promisify } from 'node:util';
7
+ import { expect, it } from 'vitest';
8
+
9
+ const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../..');
10
+ const run = promisify(execFile);
11
+
12
+ it.each([false, true])('HMR isolates Yuri state with private OpenCode: %s', async (isolated) => {
13
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'hmr-isolation-'));
14
+ const hmrData = path.join(directory, 'hmr');
15
+ const sharedData = path.join(directory, 'shared-yuri');
16
+ const capture = path.join(directory, 'api-env.json');
17
+ const preload = path.join(directory, 'capture-spawn.cjs');
18
+ fs.writeFileSync(preload, `
19
+ const fs = require('node:fs');
20
+ const { EventEmitter } = require('node:events');
21
+ require('node:child_process').spawn = (_command, args, options) => {
22
+ if (args.includes('dev:server:watch')) {
23
+ fs.writeFileSync(process.env.TEST_HMR_CAPTURE, JSON.stringify({
24
+ yuriData: options.env.YURI_DATA_DIR,
25
+ index: options.env.YURI_SESSION_INDEX_DB_PATH,
26
+ sharedService: options.env.YURI_OPENCODE_SHARED_SERVICE,
27
+ }));
28
+ }
29
+ return new EventEmitter();
30
+ };
31
+ require('node:module').syncBuiltinESMExports();
32
+ `);
33
+ try {
34
+ await run(process.execPath, ['--require', preload, path.join(repoRoot, 'scripts/dev-web-hmr.mjs')], {
35
+ cwd: repoRoot,
36
+ env: {
37
+ ...process.env,
38
+ YURI_HMR_ISOLATED_OPENCODE: isolated ? '1' : '0',
39
+ YURI_HMR_DATA_DIR: hmrData,
40
+ YURI_DATA_DIR: sharedData,
41
+ YURI_OPENCODE_SHARED_SERVICE: '1',
42
+ YURI_VITE_FORCE: '0',
43
+ XDG_DATA_HOME: path.join(directory, 'xdg-data'),
44
+ TEST_HMR_CAPTURE: capture,
45
+ },
46
+ });
47
+ expect(JSON.parse(fs.readFileSync(capture, 'utf8'))).toEqual({
48
+ yuriData: isolated ? path.join(hmrData, 'yuri') : sharedData,
49
+ index: path.join(hmrData, 'session-index.sqlite'),
50
+ sharedService: isolated ? '0' : '1',
51
+ });
52
+ expect(fs.existsSync(sharedData)).toBe(false);
53
+ } finally {
54
+ fs.rmSync(directory, { recursive: true, force: true });
55
+ }
56
+ });
@@ -23,7 +23,6 @@ const HEALTH_CHECK_INTERVAL_OVERRIDE_MS = parsePositiveInt(process.env.YURI_OPEN
23
23
  const HEALTH_CHECK_RESULT_CACHE_MS = parsePositiveInt(process.env.YURI_OPENCODE_HEALTH_CACHE_MS, 750);
24
24
  // Official OpenCode 2.x exposes ServerInfo at GET /api/info (client.server.info).
25
25
  const OPENCODE_HEALTH_PATH = '/api/info';
26
- const OPENCODE_HEALTH_FALLBACK_PATH = '/global/health';
27
26
  const DEFAULT_OPENCODE_SERVE_PORT = 4096;
28
27
  // Polite SIGTERM window before SIGKILL for managed children (restart/OAuth/reload
29
28
  // need enough time for clean flush; do not shorten globally for Quit latency).
@@ -511,8 +510,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
511
510
  return false;
512
511
  };
513
512
 
514
- // v2 readiness lives at /api/info (ServerInfo.version); /global/health remains
515
- // a probe fallback for older sidecars. Both require Basic auth from
513
+ // v2 readiness lives at /api/info (ServerInfo.version), with Basic auth from
516
514
  // getOpenCodeAuthHeaders(). Version admission rejects 1.x / missing / noise.
517
515
  // Health ok is reachability only — execution semantics live on runtimeContract.
518
516
  const fetchOpenCodeHealthResult = async (urlForPath, signal, options = {}) => {
@@ -526,31 +524,29 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
526
524
  let lastGate = null;
527
525
  for (const headerCandidate of headerCandidates) {
528
526
  const { authenticated, ...headers } = headerCandidate;
529
- for (const healthPath of [OPENCODE_HEALTH_PATH, OPENCODE_HEALTH_FALLBACK_PATH]) {
530
- try {
531
- const response = await fetch(urlForPath(healthPath), {
532
- method: 'GET',
533
- headers,
534
- signal,
535
- });
536
- if (response.status === 401 || response.status === 403) {
537
- sawUnauthorized = true;
538
- continue;
539
- }
540
- if (!response.ok) continue;
541
- const body = await response.json().catch(() => null);
542
- const gate = evaluateOpenCodeHealthBody(body);
543
- lastGate = gate;
544
- if (gate.ok) {
545
- return {
546
- ok: true,
547
- version: gate.version,
548
- authenticated: authenticated !== false,
549
- healthOk: true,
550
- };
551
- }
552
- } catch {
527
+ try {
528
+ const response = await fetch(urlForPath(OPENCODE_HEALTH_PATH), {
529
+ method: 'GET',
530
+ headers,
531
+ signal,
532
+ });
533
+ if (response.status === 401 || response.status === 403) {
534
+ sawUnauthorized = true;
535
+ continue;
553
536
  }
537
+ if (!response.ok) continue;
538
+ const body = await response.json().catch(() => null);
539
+ const gate = evaluateOpenCodeHealthBody(body);
540
+ lastGate = gate;
541
+ if (gate.ok) {
542
+ return {
543
+ ok: true,
544
+ version: gate.version,
545
+ authenticated: authenticated !== false,
546
+ healthOk: true,
547
+ };
548
+ }
549
+ } catch {
554
550
  }
555
551
  }
556
552
  if (sawUnauthorized && !lastGate?.ok) {
@@ -53,20 +53,14 @@ export const createOpenCodeNetworkRuntime = (deps) => {
53
53
  Accept: 'application/json',
54
54
  ...getOpenCodeAuthHeaders(),
55
55
  };
56
- for (const healthPath of ['/api/info', '/global/health']) {
57
- const response = await fetch(`${baseUrl}${healthPath}`, {
58
- method: 'GET',
59
- headers,
60
- signal: controller.signal,
61
- });
62
- if (response.ok) {
63
- const body = await response.json().catch(() => null);
64
- // Official 2.x /api/info is ServerInfo (version, no healthy);
65
- // /global/health may still return { healthy, version }.
66
- if (evaluateOpenCodeHealthBody(body).ok) {
67
- return true;
68
- }
69
- }
56
+ const response = await fetch(`${baseUrl}/api/info`, {
57
+ method: 'GET',
58
+ headers,
59
+ signal: controller.signal,
60
+ });
61
+ if (response.ok) {
62
+ const body = await response.json().catch(() => null);
63
+ if (evaluateOpenCodeHealthBody(body).ok) return true;
70
64
  }
71
65
  } catch {
72
66
  } finally {
@@ -49,7 +49,7 @@ describe('OpenCode network runtime', () => {
49
49
  expect(String(fetchMock.mock.calls[0][0])).toContain('/api/info');
50
50
  });
51
51
 
52
- it('falls back to /global/health when /api/info is not healthy', async () => {
52
+ it('never falls back to a removed health route when /api/info is unavailable', async () => {
53
53
  const fetchMock = vi.fn(async (url) => {
54
54
  if (String(url).includes('/api/info')) {
55
55
  return new Response('not found', { status: 404 });
@@ -75,9 +75,9 @@ describe('OpenCode network runtime', () => {
75
75
  getOpenCodeAuthHeaders: () => ({ Authorization: 'Basic Zml4dHVyZQ==' }),
76
76
  });
77
77
 
78
- await expect(runtime.waitForReady('http://127.0.0.1:4096', 1000)).resolves.toBe(true);
79
- expect(String(fetchMock.mock.calls[0][0])).toContain('/api/info');
80
- expect(String(fetchMock.mock.calls[1][0])).toContain('/global/health');
78
+ await expect(runtime.waitForReady('http://127.0.0.1:4096', 1)).resolves.toBe(false);
79
+ expect(fetchMock).toHaveBeenCalled();
80
+ expect(fetchMock.mock.calls.every(([url]) => new URL(url).pathname === '/api/info')).toBe(true);
81
81
  });
82
82
 
83
83
  it('returns false when readiness fetch rejects', async () => {
@@ -634,7 +634,8 @@ export const registerOpenCodeProxy = (app, deps) => {
634
634
  try {
635
635
  // Strip includeReasoning before building the upstream OpenCode path.
636
636
  const strippedUrl = stripIncludeReasoningParam(requestUrl);
637
- const upstreamPath = toUpstreamOpenCodeApiPath(strippedUrl);
637
+ const eventUrl = new URL(strippedUrl, 'http://yuri.invalid');
638
+ const upstreamPath = `/api/event${eventUrl.search}`;
638
639
  const headers = normalizeForwardedDirectoryHeaders(
639
640
  collectForwardProxyHeaders(req.headers, getOpenCodeAuthHeaders())
640
641
  );
@@ -118,6 +118,7 @@ describe('Host events on proxied SSE', () => {
118
118
  }, cancel: async () => {}, releaseLock() {},
119
119
  }) } }));
120
120
  const response = await request(mountProxy({ subscribeGlobalUiEvent })).get(route).expect(200);
121
+ expect(new URL(globalThis.fetch.mock.calls[0][0]).pathname).toBe('/api/event');
121
122
  const events = response.text.trim().split('\n\n').map((block) => JSON.parse(block.slice(6)));
122
123
  expect(events).toEqual([{ directory: '/repo', payload: title }, { directory: '/repo', payload: metadata }, upstream]);
123
124
  expect(unsubscribe).toHaveBeenCalledTimes(1);
@@ -6,6 +6,13 @@ The private relay lets an Yuri client (mobile app, browser, or another desktop)
6
6
 
7
7
  Traffic is **end-to-end encrypted between the two endpoints** (client and host instance). The relay infrastructure forwards opaque ciphertext and cannot read application traffic — it is an untrusted transport, not a trusted middlebox.
8
8
 
9
+ `packages/relay-server/src/core.js` is the common Layer 1 implementation for the
10
+ Node/Docker server and Cloudflare Workers (`src/worker.js`, one Durable Object per
11
+ deployment). Workers preserves the Host/Client wire protocol and E2EE boundary;
12
+ it currently uses ordinary accepted sockets, not Hibernation, and does not host
13
+ APNs Push. See the Relay package README for deployment, separate Push URL and
14
+ Workers-specific billing/backpressure limits.
15
+
9
16
  This module (`packages/web/server/lib/relay/`) is the **Host side** of the private relay. **Only the Electron desktop runtime or an SSH-managed remote server may act as a relay host** (`YURI_RUNTIME=desktop` or `ssh-remote`). Electron sets `desktop` before it starts the in-process web server; SSH manager sets `ssh-remote` when launching a managed remote `yuri serve` (optionally with `--relay-host`). Plain `node` / `dev:web:hmr` / ordinary CLI / VS Code web servers must not open the host-control socket, claim `relay-host.lock`, or advertise a host pairing candidate — even when they share the same data dir as desktop. Those processes may still run the API that *clients* use; mobile and other desktops remain **relay clients**. The **Client side** lives in `packages/ui/src/lib/relay/`. Hosted Relay instances may run in a Worker. The self-hosted **Relay server** belongs to `packages/relay-server/` and brokers Layer 1 connections.
10
17
 
11
18
  ## The three layers
@@ -18,7 +25,7 @@ Traffic is modeled as three stacked layers. The relay understands only Layer 1;
18
25
 
19
26
  ## Entrypoints and structure
20
27
 
21
- The Host and pairing UI default to `wss://relay.openchamber.dev/ws`. Host endpoint precedence is `YURI_RELAY_URL`, saved `privateRelay.relayUrl`, then the product default. Existing saved pairing endpoints remain authoritative for reconnects.
28
+ The Host and pairing UI default to `wss://relay.useyuri.top/ws`. Host endpoint precedence is `YURI_RELAY_URL`, saved `privateRelay.relayUrl`, then the product default. Existing saved pairing endpoints remain authoritative for reconnects; the default change does not rewrite saved Host endpoints or client preferences. The default Workers Relay has no APNs Push service: set `YURI_PUSH_RELAY_URL` independently. Custom Relay endpoints retain same-origin Push derivation when that override is absent.
22
29
 
23
30
  Host side (`packages/web/server/lib/relay/`):
24
31
  - `service.js` — thin entrypoint: relay config (enabled flag + endpoints), the management routes (`GET/POST /api/yuri/relay/{status,enable,disable}`, `POST /api/yuri/relay/endpoints`), a `getPairingCandidate()` accessor (the relay transport candidate folded into pairing-v2 links when enabled, consumed by the pairing-session route in `core-routes.js`), and lifecycle wiring. **Multi-relay:** `settings.privateRelay = { enabled, relayUrl, extraRelayUrls }` — the host dials EVERY configured endpoint simultaneously with one identity (same serverId); clients treat `serverId + relayUrl` as the instance identity, so the same machine exposed via two domains appears as two separately named instances. The primary (`relayUrl`) owns push registration and stays the default pairing candidate. A pairing link created for an endpoint the host does not have yet APPENDS it as an extra endpoint instead of replacing the primary, so devices paired over the old domain keep working. `POST /relay/endpoints` (owner session / `desktop-local` only) replaces the extra-endpoint list wholesale and starts/stops host connections incrementally. Paired desktop operators may also add an endpoint through pairing creation. Host lifecycle is gated by `isRelayHostRuntime()` (`desktop` or `ssh-remote`): other runtimes (`bun run dev`, `dev:web:hmr`, ordinary CLI `serve`, VS Code, plain `node server`) report `state: 'unavailable'`, refuse `/relay/enable`, `/relay/disable`, `/relay/endpoints`, and relay pairing with 403, never mint a relay identity, never advertise `relayAvailable`, and never call `startRelayHost`. Direct `node server/index.js` forces `YURI_RUNTIME=web` unless it is already `ssh-remote`, so a leftover desktop env cannot open the host-control socket. On host runtimes, started from `packages/web/server/index.js` when demand/opt-in enables the relay. Desktop auto-clears `privateRelay.enabled` when demand drops; `ssh-remote` keeps an explicit opt-in (e.g. `yuri serve --relay-host`) sticky until disabled. The relay endpoint has no hosted default and must be configured in settings or pinned via the `YURI_RELAY_URL` env var; when set it overrides the stored setting for the host connection, the pairing candidate, and status, so paired clients inherit the endpoint automatically. Endpoint identity is scheme/host/path only: accepted schemes are `ws://` and `wss://`; URLs with userinfo are rejected (no silent default fallback); query and fragment are stripped before persistence and pairing candidates. Custom endpoint persistence and Host control-connection switching are explicit authenticated management actions. Pairing creation with `relayUrl` requires an owner UI session, local `desktop-local` shell client, or paired `desktop` operator; `/relay/enable` follows its API auth gate. `derivePushSendUrlFromRelayUrl` maps a canonical Relay `wss://`/`ws://` URL to the same host's `https://`/`http://` `/v1/push/send` path (register is `/v1/push/register-token`); `YURI_PUSH_RELAY_URL` on the Host overrides that derivation. The isolated Push process lives in `packages/relay-server/src/push/` and does not share Layer 1 credentials or tunnel state.
@@ -39,12 +39,16 @@ import { requestSpeechSession } from '../../../../ui/src/lib/voice/direct-sessio
39
39
  import { createGuiClient } from '../../../../ui/src/lib/opencode/gui.ts';
40
40
  import { createWebFilesAPI } from '../../../src/api/files.ts';
41
41
  import { createEventPipeline } from '../../../../ui/src/sync/event-pipeline.ts';
42
+ import { uploadAssistantAttachment } from '../../../../ui/src/lib/assistant-attachment-upload.ts';
43
+ import { registerAssistantRoutes } from '../assistants/routes.js';
44
+ import { registerCommonRequestMiddleware } from '../opencode/core-routes.js';
42
45
 
43
46
  // Web's source aliases are not exported Node package subpaths. Forward them to
44
47
  // the real implementations so this Node E2E exercises the same transport singleton.
45
48
  vi.mock('@yuriai/ui/lib/runtime-fetch', () => import('../../../../ui/src/lib/runtime-fetch.ts'));
46
49
  vi.mock('@yuriai/ui/lib/runtime-file-resource', () => import('../../../../ui/src/lib/runtime-file-resource.ts'));
47
50
  vi.mock('@yuriai/ui/lib/runtime-file-download', () => import('../../../../ui/src/lib/runtime-file-download.ts'));
51
+ vi.mock('@yuriai/ui/lib/opencode/client', () => import('../../../../ui/src/lib/opencode/client.ts'));
48
52
 
49
53
  const timeoutMs = 10_000;
50
54
  const previewPng = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+aD1sAAAAASUVORK5CYII=', 'base64');
@@ -200,6 +204,16 @@ const startOrigin = async (options: { recoveryEvents?: boolean } = {}) => {
200
204
  const requestSecurity = createRequestSecurityRuntime({ readSettingsFromDiskMigrated: async () => ({}) });
201
205
  const wss = new WebSocketServer({ noServer: true });
202
206
  const proxy = express();
207
+ const assistants = express();
208
+ registerCommonRequestMiddleware(assistants, { express });
209
+ const assistantRuntime = registerAssistantRoutes(assistants, {
210
+ dbPath: path.join(mediaDirectory, 'assistants.sqlite'),
211
+ yuriDataDir: mediaDirectory,
212
+ buildOpenCodeUrl: () => 'http://127.0.0.1:1',
213
+ getOpenCodeAuthHeaders: () => ({}),
214
+ getAllowedRoots: () => [mediaDirectory],
215
+ });
216
+ const attachmentAssistant = assistantRuntime.service.createAssistant({ name: 'Relay upload', providerID: 'fixture', modelID: 'fixture' });
203
217
  const speech = express();
204
218
  speech.use(express.json());
205
219
  registerTtsRoutes(speech, { sayTTSCapability: null });
@@ -260,6 +274,10 @@ const startOrigin = async (options: { recoveryEvents?: boolean } = {}) => {
260
274
  });
261
275
  return;
262
276
  }
277
+ if (pathname.startsWith('/api/yuri/assistants/')) {
278
+ await uiAuth.requireAuth(req, res, () => assistants(req, rawRes));
279
+ return;
280
+ }
263
281
  if (pathname === '/api/e2e/initialization' && req.method === 'GET') {
264
282
  await uiAuth.requireAuth(req, res, () => res.json(initializationSnapshot));
265
283
  return;
@@ -348,9 +366,10 @@ const startOrigin = async (options: { recoveryEvents?: boolean } = {}) => {
348
366
  await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve));
349
367
  const port = (server.address() as net.AddressInfo).port;
350
368
  return {
351
- port, videoPath, previewPath, previewContent, guiBundle, pluginInventory, guiRequests, bearerRequests, observedOrigins, getHostSubscriptions: () => hostSubscriptions,
369
+ port, videoPath, previewPath, previewContent, guiBundle, pluginInventory, guiRequests, bearerRequests, observedOrigins, attachmentAssistant, getHostSubscriptions: () => hostSubscriptions,
352
370
  advanceRecoveryRevision: () => { recoveryRevision += 1; return `ses_recovery_${recoveryRevision}`; },
353
371
  stop: async () => {
372
+ assistantRuntime.close();
354
373
  dictation.stop();
355
374
  for (const client of wss.clients) client.terminate();
356
375
  for (const socket of sockets) socket.destroy();
@@ -493,6 +512,56 @@ describe('private relay compiled-process boundary', () => {
493
512
  socket.close();
494
513
  });
495
514
 
515
+ it.skipIf(!process.env.YURI_RELAY_WORKER_TEST_URL)('carries real encrypted Host/Client HTTP, SSE and authenticated WebSockets across Workers', { timeout: 30_000 }, async () => {
516
+ const relayUrl = process.env.YURI_RELAY_WORKER_TEST_URL;
517
+ if (!relayUrl) throw new Error('Worker test endpoint required');
518
+ const temp = await mkdtemp(path.join(os.tmpdir(), 'yuri-worker-e2e-'));
519
+ vi.stubEnv('YURI_DATA_DIR', temp);
520
+ let origin: Awaited<ReturnType<typeof startOrigin>> | undefined;
521
+ let host: ReturnType<typeof startRelayHost> | undefined;
522
+ let client: ReturnType<typeof createRelayTunnelClient> | undefined;
523
+ cleanup = async () => {
524
+ client?.close(); host?.stop(); await origin?.stop();
525
+ await rm(temp, { recursive: true, force: true });
526
+ };
527
+ origin = await startOrigin();
528
+ const identity = await buildIdentity();
529
+ host = startRelayHost({ relayUrl, identity, getLocalPort: () => origin!.port,
530
+ batchWindowMs: 5, onStatus() {}, logger: { warn() {}, info() {} } });
531
+ client = createRelayTunnelClient({ relayUrl, serverId: identity.serverId, hostEncPubJwk: identity.hostEncPubJwk,
532
+ batchWindowMs: 5, helloRetryMs: 50 });
533
+ await eventually(() => host!.getStatus().state === 'connected' && client!.getStatus().state === 'connected', 'Worker E2EE tunnel did not connect');
534
+
535
+ expect((await client.fetch('/api/event')).status).toBe(401);
536
+ const headers = { authorization: 'Bearer client-token' };
537
+ const httpResponse = await client.fetch('/api/e2e/http', { method: 'POST', headers, body: 'worker-stream-body' });
538
+ expect(await httpResponse.json()).toEqual({ body: 'worker-stream-body', hasRelayConnection: true });
539
+ const snapshot = await client.fetch('/api/e2e/initialization', { headers });
540
+ expect(await snapshot.json()).toEqual(initializationSnapshot);
541
+ const sse = await client.fetch('/api/e2e/sse', { headers });
542
+ const reader = sse.body!.getReader(); const chunks: Uint8Array[] = [];
543
+ while (true) { const item = await reader.read(); if (item.done) break; chunks.push(item.value); }
544
+ expect(chunks.length).toBeGreaterThan(1);
545
+ expect(Buffer.concat(chunks).toString()).toBe('data: one\n\ndata: two\n\ndata: three\n\n');
546
+
547
+ const denied = client.openWebSocket('/api/remote-desktop/ws');
548
+ await expect(waitSocketOpen(denied)).rejects.toThrow();
549
+ const tokenResponse = await client.fetch('/auth/url-token', { method: 'POST', headers });
550
+ const { token } = await tokenResponse.json() as { token: string };
551
+ const socket = client.openWebSocket(`/api/remote-desktop/ws?yuri_url_token=${encodeURIComponent(token)}`);
552
+ await waitSocketOpen(socket);
553
+ const messages: Array<string | ArrayBuffer> = [];
554
+ socket.onmessage = ({ data }) => { messages.push(data); };
555
+ for (let index = 0; index < 50; index += 1) socket.send(`input:${index}`);
556
+ const image = new Uint8Array(1024 * 1024).fill(7);
557
+ socket.send(image); image.fill(0);
558
+ await eventually(() => messages.length === 51, 'Worker dropped or reordered encrypted remote desktop frames');
559
+ expect(messages.slice(0, 50)).toEqual(Array.from({ length: 50 }, (_, index) => `input:${index}`));
560
+ expect(new Uint8Array(messages[50] as ArrayBuffer)).toEqual(new Uint8Array(1024 * 1024).fill(7));
561
+ expect(origin.observedOrigins).toEqual([`http://127.0.0.1:${origin.port}`]);
562
+ socket.close();
563
+ });
564
+
496
565
  it('recovers HTTP and the retained SDK event pipeline after phone, Host, and combined disconnects', { timeout: 60_000 }, async () => {
497
566
  const temp = await mkdtemp(path.join(os.tmpdir(), 'yuri-relay-recovery-'));
498
567
  const binary = path.join(temp, 'yuri-relay');
@@ -749,6 +818,38 @@ describe('private relay compiled-process boundary', () => {
749
818
  adoptRelayTunnel({ relayUrl: relay.url, serverId: identity.serverId, hostEncPubJwk: identity.hostEncPubJwk }, client);
750
819
  vi.stubGlobal('window', { location: new URL('https://relay-runtime.example'), addEventListener() {}, removeEventListener() {} });
751
820
  try {
821
+ const assistantID = origin.attachmentAssistant.id;
822
+ const uploadPath = `/api/yuri/assistants/${assistantID}/contact/attachments`;
823
+ for (const headers of [{}, { authorization: 'Bearer invalid-token' }]) {
824
+ expect((await client.fetch(`${uploadPath}/denied`, { method: 'PUT', headers, body: previewPng })).status).toBe(401);
825
+ }
826
+ const attachmentParts: Awaited<ReturnType<typeof uploadAssistantAttachment>>[] = [];
827
+ for (const [index, file] of [
828
+ new File([previewPng], '截图.png', { type: 'image/png' }),
829
+ new File([JSON.stringify({ text: '附件原始字节', padding: 'x'.repeat(128 * 1024) })], '附件.json', { type: 'application/json' }),
830
+ ].entries()) {
831
+ const uploadID = `relay-upload-${index}`;
832
+ const descriptor = await uploadAssistantAttachment(assistantID, file, uploadID);
833
+ attachmentParts.push(descriptor);
834
+ expect(descriptor).toMatchObject({
835
+ type: 'file', filename: file.name, mime: file.type, size: file.size,
836
+ sha256: crypto.createHash('sha256').update(Buffer.from(await file.arrayBuffer())).digest('hex'),
837
+ });
838
+ expect(await uploadAssistantAttachment(assistantID, file, uploadID)).toEqual(descriptor);
839
+ const download = await runtimeFetch(`${uploadPath}/${descriptor.attachmentID}`);
840
+ expect(download.status).toBe(200);
841
+ expect(Buffer.from(await download.arrayBuffer())).toEqual(Buffer.from(await file.arrayBuffer()));
842
+ expect((await client.fetch(`${uploadPath}/${descriptor.attachmentID}`)).status).toBe(401);
843
+ }
844
+ const admission = await runtimeFetch(`/api/yuri/assistants/${assistantID}/messages`, {
845
+ method: 'POST', headers: { 'Content-Type': 'application/json' },
846
+ body: JSON.stringify({ messageID: 'relay-attachment-message', parts: [{ type: 'text', text: 'Check these attachments' }, ...attachmentParts] }),
847
+ });
848
+ expect(admission.status, await admission.text()).toBe(202);
849
+ const contactPage = await runtimeFetch(`/api/yuri/assistants/${assistantID}/contact/messages?messageID=relay-attachment-message`);
850
+ expect(contactPage.status).toBe(200);
851
+ const contactJson = await contactPage.text();
852
+ for (const part of attachmentParts) expect(contactJson).toContain(part.attachmentID);
752
853
  const gui = createGuiClient(new AbortController().signal);
753
854
  const files = createWebFilesAPI({ getDirectory: () => path.dirname(origin.previewPath) });
754
855
  expect(Buffer.byteLength(origin.guiBundle.code)).toBeGreaterThan(2_270_000);
@@ -23,7 +23,7 @@ import express from 'express';
23
23
  import { createRelayIdentityRuntime } from './identity.js';
24
24
  import { startRelayHost } from './host-client.js';
25
25
 
26
- export const DEFAULT_RELAY_URL = 'wss://relay.openchamber.dev/ws';
26
+ export const DEFAULT_RELAY_URL = 'wss://relay.useyuri.top/ws';
27
27
 
28
28
  export const RELAY_HOST_DESKTOP_ONLY_MESSAGE =
29
29
  'Relay host is only available in the Yuri desktop app or an SSH-managed remote server';
@@ -92,7 +92,7 @@ describe('resolveEffectiveRelayUrl', () => {
92
92
 
93
93
  it('prefers a valid env URL, then settings, then the default', () => {
94
94
  expect(resolveEffectiveRelayUrl()).toBe(PRODUCT_RELAY_URL);
95
- expect(PRODUCT_RELAY_URL).toBe('wss://relay.openchamber.dev/ws');
95
+ expect(PRODUCT_RELAY_URL).toBe('wss://relay.useyuri.top/ws');
96
96
  expect(
97
97
  resolveEffectiveRelayUrl({
98
98
  settings: { privateRelay: { relayUrl: 'wss://settings.example/ws' } },
@@ -138,6 +138,19 @@ describe('relay service pairing endpoint', () => {
138
138
  expect(relayMocks.stops).toEqual(relayMocks.starts);
139
139
  });
140
140
 
141
+ it('persists the product default for first pairing when no endpoint was saved', async () => {
142
+ const { service, settings } = createTestRelayService();
143
+ await settings.write({});
144
+ try {
145
+ const candidate = await service.ensureEnabledForPairing();
146
+ expect(candidate.relayUrl).toBe(PRODUCT_RELAY_URL);
147
+ expect(settings.current()).toMatchObject({ privateRelay: { enabled: true, relayUrl: PRODUCT_RELAY_URL } });
148
+ expect(relayMocks.starts).toEqual([PRODUCT_RELAY_URL]);
149
+ } finally {
150
+ service.stop();
151
+ }
152
+ });
153
+
141
154
  it('appends a new pairing endpoint (multi-relay) while keeping the primary', async () => {
142
155
  const { service, settings } = createTestRelayService();
143
156
 
@@ -4,7 +4,7 @@ export const applyRuntimeCorsHeaders = ({ origin, setHeader }) => {
4
4
  setHeader('Access-Control-Allow-Origin', origin);
5
5
  setHeader('Access-Control-Allow-Credentials', 'true');
6
6
  setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,PATCH,DELETE,OPTIONS');
7
- setHeader('Access-Control-Allow-Headers', 'Content-Type,Authorization,Accept,X-Requested-With,Cache-Control,X-OpenCode-Directory,X-OpenCode-Directory-Encoding,X-Message-Queue-Upload-Token,X-Message-Queue-Sha256,X-Message-Queue-Content-Length,X-Yuri-Content-Length,X-Yuri-Sha256,X-Yuri-Mime,X-Yuri-Filename,X-Yuri-Gui-Revision');
7
+ setHeader('Access-Control-Allow-Headers', 'Content-Type,Authorization,Accept,X-Requested-With,Cache-Control,X-OpenCode-Directory,X-OpenCode-Directory-Encoding,X-Message-Queue-Upload-Token,X-Message-Queue-Sha256,X-Message-Queue-Content-Length,X-Yuri-Content-Length,X-Yuri-Sha256,X-Yuri-Mime,X-Yuri-Filename,X-Yuri-Gui-Revision,X-Content-SHA256,X-Content-Size,X-Attachment-Filename');
8
8
  // Packaged clients (Electron yuri-ui://app, Capacitor, Vite HMR) are
9
9
  // cross-origin to the runtime API. Without an expose list, browsers hide
10
10
  // custom response headers from JS — including the optional-read existence
@@ -1,8 +1,20 @@
1
- import { describe, expect, it } from 'bun:test';
1
+ import { describe, expect, it } from 'vitest';
2
2
 
3
3
  import { applyRuntimeCorsHeaders } from './request-cors.js';
4
4
 
5
5
  describe('applyRuntimeCorsHeaders', () => {
6
+ it.each(['yuri-ui://app', 'capacitor://localhost', 'http://localhost:5180'])(
7
+ 'allows assistant attachment upload preflights from %s', (origin) => {
8
+ const headers = new Map();
9
+ applyRuntimeCorsHeaders({ origin, setHeader: (name, value) => headers.set(name, value) });
10
+ const allowed = headers.get('Access-Control-Allow-Headers').toLowerCase().split(',').map((name) => name.trim());
11
+ expect(headers.get('Access-Control-Allow-Methods').split(',')).toContain('PUT');
12
+ for (const name of ['content-type', 'authorization', 'x-content-sha256', 'x-content-size', 'x-attachment-filename']) {
13
+ expect(allowed, `Browser blocks assistant attachment upload header: ${name}`).toContain(name);
14
+ }
15
+ },
16
+ );
17
+
6
18
  it('gives packaged clients a reusable preflight cache window', () => {
7
19
  const headers = new Map();
8
20
  applyRuntimeCorsHeaders({
@@ -41,6 +41,9 @@ synthetic `session.updated` so the loop can arm.
41
41
 
42
42
  ## Goal payload (`metadata.yuri.goal`)
43
43
 
44
+ Live activity reads the V2 `session.active` client only. A failed active-session
45
+ read remains unknown; it never calls the removed session-status endpoint.
46
+
44
47
  ```
45
48
  {
46
49
  id, // opaque per-logical-goal id; stale-write guard
@@ -825,10 +825,6 @@ export const createSessionGoalRuntime = ({
825
825
  } catch {
826
826
  // Fall through.
827
827
  }
828
- const statusMap = await openCodeFetch('/session/status', { directory }).catch(() => null);
829
- const status = statusMap?.[sessionId];
830
- const type = typeof status?.type === 'string' ? status.type.trim() : '';
831
- if (type === 'idle' || type === 'busy' || type === 'retry') return type;
832
828
  return null;
833
829
  };
834
830