@yuriai/web 0.2.15 → 0.2.20-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/assets/AgentAvatar-D5KPQI1N.js +1 -0
  2. package/dist/assets/AssistantView-huAUB-2Y.js +3 -0
  3. package/dist/assets/{DiagramView-C8uoLQ35.js → DiagramView-DWV04Xws.js} +1 -1
  4. package/dist/assets/{FadeInOnReveal-CxIQc2_J.js → FadeInOnReveal-CdoLG8fY.js} +1 -1
  5. package/dist/assets/{GuiPluginSurface-CFQNrorE.js → GuiPluginSurface-DhD8BqvL.js} +1 -1
  6. package/dist/assets/{GuiPluginWindow-pZqqyXGs.js → GuiPluginWindow-ezsy5l_y.js} +1 -1
  7. package/dist/assets/Icon-DvqOB4Dx.js +1 -0
  8. package/dist/assets/{ImageLoadingPlaceholder-B5t9zOYn.js → ImageLoadingPlaceholder-BVlgaa2r.js} +1 -1
  9. package/dist/assets/{LoadingImage-ByZs_EGY.js → LoadingImage-BSG8jmn5.js} +1 -1
  10. package/dist/assets/MarkdownRenderer-BiRplAST.js +2 -0
  11. package/dist/assets/{MarkdownRendererImpl-BEFLoojj.js → MarkdownRendererImpl-CH8TUMKZ.js} +1 -1
  12. package/dist/assets/{MarkstreamRendererImpl-BD0HFc5P.js → MarkstreamRendererImpl-Bmz56IzM.js} +1 -1
  13. package/dist/assets/{MobileDetailNavigation-BuQ4p5oW.js → MobileDetailNavigation-kKHM_dU3.js} +1 -1
  14. package/dist/assets/{MobileResizableSheet-BdOIJ61C.js → MobileResizableSheet-jHNytoyX.js} +1 -1
  15. package/dist/assets/{MobileShareBridge-UNsCJGaT.js → MobileShareBridge-CSDivsPk.js} +2 -2
  16. package/dist/assets/{MobileTabPageHeader-Bz9YF_Sc.js → MobileTabPageHeader-BkWvNBtr.js} +1 -1
  17. package/dist/assets/{MultiRunWindow-CNd8aJN7.js → MultiRunWindow-DbllgaJR.js} +1 -1
  18. package/dist/assets/{OnboardingScreen-CXIYe29y.js → OnboardingScreen-DONIcirJ.js} +1 -1
  19. package/dist/assets/{OverlayScrollbar-0_OUbhJe.js → OverlayScrollbar-DB2eeXFh.js} +1 -1
  20. package/dist/assets/{SettingsView-U_aHjrBx.js → SettingsView-6D55BNjw.js} +12 -12
  21. package/dist/assets/{SettingsWindow-C-FWiRJy.js → SettingsWindow-BrrnHfnR.js} +1 -1
  22. package/dist/assets/{TerminalView-Dl95RuIA.js → TerminalView-8JYW5f-c.js} +1 -1
  23. package/dist/assets/ToolOutputDialog-DZO89hKv.js +10 -0
  24. package/dist/assets/{YuriLogo-_lN4cqhJ.js → YuriLogo-CYdRUurL.js} +1 -1
  25. package/dist/assets/{appThemeRegistry-ByDzLana.js → appThemeRegistry-Nb-sUfbK.js} +1 -1
  26. package/dist/assets/{assistant-attachment-cache-lEUFn3mr.js → assistant-attachment-cache-C2SmtQG7.js} +1 -1
  27. package/dist/assets/{button-DFX-UCuQ.js → button-nola46HU.js} +1 -1
  28. package/dist/assets/{capgoAdapter-DB7INL7g.js → capgoAdapter-CHeo9q51.js} +1 -1
  29. package/dist/assets/{collapsible-CDkbWw1M.js → collapsible-BQaMLh6O.js} +1 -1
  30. package/dist/assets/{desktop-dp2Z0toS.js → desktop-CiqEZVr5.js} +1 -1
  31. package/dist/assets/{desktopHosts-CYKaLp1V.js → desktopHosts-B4HMNmrx.js} +1 -1
  32. package/dist/assets/{desktopRelayRestore-5yuHB356.js → desktopRelayRestore-CRl62mqn.js} +1 -1
  33. package/dist/assets/{device-DzWRCXhq.js → device-Coc5tapU.js} +1 -1
  34. package/dist/assets/{diagram-JdjLWkpD.js → diagram-COti_aKS.js} +1 -1
  35. package/dist/assets/{dialog-jQrYy1B7.js → dialog-B2CTTXwv.js} +1 -1
  36. package/dist/assets/{dropdown-menu.styles-EKni18O6.js → dropdown-menu.styles-BzpQaok_.js} +1 -1
  37. package/dist/assets/{es-BJGEAUsH.js → es-DklBd0ox.js} +1 -1
  38. package/dist/assets/{fileMentionTouchSelection-CkO5Pveg.js → fileMentionTouchSelection-CXepBNtQ.js} +1 -1
  39. package/dist/assets/{fileQueries-DbUx7NwP.js → fileQueries-Bd-OEFmO.js} +1 -1
  40. package/dist/assets/{fileReferenceActions-No7p4Kdo.js → fileReferenceActions-BnPPqYXw.js} +1 -1
  41. package/dist/assets/{fr-CFAAV_Hr.js → fr-CVUs46wM.js} +1 -1
  42. package/dist/assets/{gitApi-0Rr-brg2.js → gitApi-B7AeNXrj.js} +1 -1
  43. package/dist/assets/{gitApiHttp-BtI23x-7.js → gitApiHttp-CoNokuDM.js} +1 -1
  44. package/dist/assets/{gui-BCPFcL_m.js → gui-D3wrcUs6.js} +1 -1
  45. package/dist/assets/{host-BoCxB_x4.js → host-BCXyr41J.js} +1 -1
  46. package/dist/assets/{image-loading-FUFYiO1j.js → image-loading-DVZlFuU5.js} +1 -1
  47. package/dist/assets/{input-g3JXmugD.js → input-DGnhaqoc.js} +1 -1
  48. package/dist/assets/{insertionBoundaries-CLKaunvi.js → insertionBoundaries-Db0R1aBj.js} +1 -1
  49. package/dist/assets/{ja-1qFce7BA.js → ja-5reg09JK.js} +1 -1
  50. package/dist/assets/{ko-BDwpL-64.js → ko-DZdC6ooz.js} +1 -1
  51. package/dist/assets/main-DQ0F0yuL.js +169 -0
  52. package/dist/assets/{main-D0kTACo9.js → main-d2AaD_PZ.js} +2 -2
  53. package/dist/assets/{markdownHeightCache-BsFt9Iuh.js → markdownHeightCache-C_JI5qIR.js} +1 -1
  54. package/dist/assets/{mcpQueries-D0LNcR1q.js → mcpQueries-BgFj7wfO.js} +1 -1
  55. package/dist/assets/miniChat-BHdsTyJ3.js +2 -0
  56. package/dist/assets/mobile-BEhQq4tx.js +2 -0
  57. package/dist/assets/{mobileBackNavigation-DPmsYwPj.js → mobileBackNavigation-s9RsXUUH.js} +1 -1
  58. package/dist/assets/{multirun-BLDsdBIC.js → multirun-BZsBsBAj.js} +1 -1
  59. package/dist/assets/{native-config-ByqoltPf.js → native-config-BmrfOzkM.js} +1 -1
  60. package/dist/assets/{persistence-BfjCXjLZ.js → persistence-CNEHspb4.js} +1 -1
  61. package/dist/assets/{pl-COzHGIeC.js → pl-BerZSK-a.js} +1 -1
  62. package/dist/assets/{platform-syRnKuVU.js → platform-Q45KPuGv.js} +1 -1
  63. package/dist/assets/{projectMeta-UNs8fviv.js → projectMeta-BCGIXTbR.js} +1 -1
  64. package/dist/assets/{pt-BR-B6ps5NQH.js → pt-BR-ydmV6U49.js} +1 -1
  65. package/dist/assets/{queryRuntime-BuRnpVtK.js → queryRuntime-DWgXfxGx.js} +1 -1
  66. package/dist/assets/{readiness-Dl3hJelb.js → readiness-BxT5OBkk.js} +1 -1
  67. package/dist/assets/{renderElectronMiniChatApp-ShVOG0Py.js → renderElectronMiniChatApp-BbfF6SjM.js} +2 -2
  68. package/dist/assets/{renderMobileApp-Dda4hoGA.js → renderMobileApp-ulSQxT-l.js} +6 -6
  69. package/dist/assets/runtime-auth-BaBM02zI.js +1 -0
  70. package/dist/assets/{runtime-fetch-BAN5Gnnp.js → runtime-fetch-DfALP7-b.js} +1 -1
  71. package/dist/assets/{runtime-file-download-BzblfnMx.js → runtime-file-download-xvItwYMc.js} +1 -1
  72. package/dist/assets/{runtime-file-resource-D3k0hKDj.js → runtime-file-resource-DtsKbFf3.js} +1 -1
  73. package/dist/assets/{runtime-switch-CAZiOV2G.js → runtime-switch-DhMY9eiB.js} +1 -1
  74. package/dist/assets/{runtimeConfig-CijjWK-g.js → runtimeConfig-BHRHZbwI.js} +1 -1
  75. package/dist/assets/{runtimeEndpointReset-CB04brBn.js → runtimeEndpointReset-H2W1kxcO.js} +4 -4
  76. package/dist/assets/{scheduledTaskNavigation-DPl7XI48.js → scheduledTaskNavigation-CkBcoGV4.js} +1 -1
  77. package/dist/assets/{sessionChangeSummary-CRPfojF7.js → sessionChangeSummary-CAU-06Bu.js} +1 -1
  78. package/dist/assets/{sessionLookup-7qVMN2KO.js → sessionLookup-YvkfClst.js} +1 -1
  79. package/dist/assets/{sortable-tabs-strip-Bp_bMUwf.js → sortable-tabs-strip-pCvZjmMt.js} +1 -1
  80. package/dist/assets/{speechSettingsQueries-DkLz1lXd.js → speechSettingsQueries-1LD5eEHK.js} +2 -2
  81. package/dist/assets/src-DGCTlpkW.css +2 -0
  82. package/dist/assets/{store-CKaWYiP4.js → store-ClIuNNU7.js} +2 -2
  83. package/dist/assets/{terminalApi-Dw1h9m3h.js → terminalApi-DFhCeMya.js} +1 -1
  84. package/dist/assets/{textarea-BuvlUTo2.js → textarea-DSHEMw8t.js} +1 -1
  85. package/dist/assets/{tooltip-Byl6nrXB.js → tooltip-BwTvgqWG.js} +1 -1
  86. package/dist/assets/types-CiQgQf3s.js +2 -0
  87. package/dist/assets/{uk-StL0Y7Ti.js → uk-BnTevguX.js} +1 -1
  88. package/dist/assets/{useAppFontEffects-CL3-doYG.js → useAppFontEffects-Cz9eoInx.js} +53 -53
  89. package/dist/assets/{useAssistantUIStore-rdsbsVts.js → useAssistantUIStore-BZt-lLlW.js} +1 -1
  90. package/dist/assets/{useDesktopWindowControlsLayout-BCwpHdQs.js → useDesktopWindowControlsLayout-HpOlTBoV.js} +1 -1
  91. package/dist/assets/{useEffectiveDirectory-D2Yehntp.js → useEffectiveDirectory-DE-YccE8.js} +1 -1
  92. package/dist/assets/{useFontPreferences-B4LGrKaG.js → useFontPreferences-DmeLn0t9.js} +1 -1
  93. package/dist/assets/{useMobileNavigationStore-uTICFg9r.js → useMobileNavigationStore-DPE5LVui.js} +22 -22
  94. package/dist/assets/{useUIStore-NMQx_cnG.js → useUIStore-CEingF2z.js} +1 -1
  95. package/dist/assets/useWorkerHighlightedLines-o-elkNrd.js +7 -0
  96. package/dist/assets/{vendor-framer-motion-D8hQsul-.js → vendor-framer-motion-BQ3-sJMO.js} +1 -1
  97. package/dist/assets/vendor-motion-B4xmxmaP.js +1 -0
  98. package/dist/assets/{zh-CN-CxO7ZteK.js → zh-CN-DT6qIAPJ.js} +1 -1
  99. package/dist/assets/{zh-TW-9MJgbinh.js → zh-TW-CtLsIcFb.js} +1 -1
  100. package/dist/index.html +21 -21
  101. package/dist/mini-chat.html +21 -21
  102. package/dist/mobile.html +21 -21
  103. package/package.json +1 -1
  104. package/server/lib/assistants/DOCUMENTATION.md +205 -6
  105. package/server/lib/assistants/assign.js +2 -1
  106. package/server/lib/assistants/contact-attachments.http.test.js +1 -1
  107. package/server/lib/assistants/contact-greeting.js +18 -0
  108. package/server/lib/assistants/contact-tools.js +11 -10
  109. package/server/lib/assistants/harness.js +23 -7
  110. package/server/lib/assistants/harness.test.js +35 -7
  111. package/server/lib/assistants/opencode-tools.js +167 -0
  112. package/server/lib/assistants/opencode-tools.test.js +295 -0
  113. package/server/lib/assistants/progressive-tools.js +33 -0
  114. package/server/lib/assistants/progressive-tools.test.js +66 -0
  115. package/server/lib/assistants/routes.js +1 -0
  116. package/server/lib/assistants/service.js +40 -9
  117. package/server/lib/assistants/service.test.js +401 -26
  118. package/server/lib/assistants/yuri-project.http.test.js +126 -0
  119. package/server/lib/assistants/yuri-tools.js +42 -0
  120. package/server/lib/assistants/yuri-tools.test.js +151 -0
  121. package/server/lib/opencode/DOCUMENTATION.md +1 -0
  122. package/server/lib/opencode/feature-routes-runtime.js +9 -0
  123. package/server/lib/opencode/feature-routes-runtime.test.js +12 -0
  124. package/server/lib/opencode/routes.js +4 -32
  125. package/server/lib/opencode/settings-runtime.js +7 -2
  126. package/server/lib/projects/DOCUMENTATION.md +29 -0
  127. package/server/lib/projects/registry.js +36 -0
  128. package/server/lib/projects/registry.test.js +107 -0
  129. package/server/lib/quota/magpie.js +2 -2
  130. package/server/lib/quota/providers/index.js +6 -2
  131. package/server/lib/quota/providers/index.test.js +6 -1
  132. package/server/lib/relay/DOCUMENTATION.md +3 -3
  133. package/server/lib/relay/host-client.js +4 -6
  134. package/server/lib/relay/host-client.reconnect.test.js +3 -2
  135. package/server/lib/relay/relay-server.e2e.test.ts +144 -1
  136. package/dist/assets/AgentAvatar-DJCC3Aqe.js +0 -1
  137. package/dist/assets/AssistantView-C4PAEb1I.js +0 -3
  138. package/dist/assets/Icon-C1nXIg7J.js +0 -1
  139. package/dist/assets/MarkdownRenderer-BYncw2H5.js +0 -2
  140. package/dist/assets/ToolOutputDialog-CA3uzAb9.js +0 -10
  141. package/dist/assets/main-RLZoG0Uv.js +0 -169
  142. package/dist/assets/miniChat-DBqehQQO.js +0 -2
  143. package/dist/assets/mobile-CZ_s2Xj0.js +0 -2
  144. package/dist/assets/runtime-auth-ef9W7A43.js +0 -1
  145. package/dist/assets/src-dSUmXLC4.css +0 -2
  146. package/dist/assets/types-CbUh5q3D.js +0 -2
  147. package/dist/assets/useWorkerHighlightedLines-BzXvnL_U.js +0 -7
  148. package/dist/assets/vendor-motion-DufQFNcM.js +0 -1
@@ -46,7 +46,7 @@ export function projectMagpieQuotas(payload, source, now = Date.now()) {
46
46
  usedPercent: w.unlimited ? null : percent(w.used), remainingPercent: w.unlimited ? null : percent(w.remaining),
47
47
  resetAt, resetAfterSeconds: resetAt === null ? null : Math.max(0, Math.ceil((resetAt - now) / 1000)),
48
48
  valueLabel: w.unlimited ? '∞' : text(w.display) || (Number.isFinite(w.amount) && Number.isFinite(w.limit) && w.limit > 0 ? `${w.amount} / ${w.limit}${text(w.unit) ? ` ${w.unit}` : ''}` : null),
49
- label: w.name, disablePace: true,
49
+ label: w.name, accountName: account.name, disablePace: true,
50
50
  };
51
51
  account.windows[`${i}:${w.name}`] = window;
52
52
  // Magpie serializes this informational window as used: 0 without its
@@ -57,7 +57,7 @@ export function projectMagpieQuotas(payload, source, now = Date.now()) {
57
57
  result.usage.windows[key] = window;
58
58
  }
59
59
  if (account.balance) {
60
- const window = { ...emptyWindow(), valueLabel: account.balance, label: 'credits_balance', disablePace: true };
60
+ const window = { ...emptyWindow(), valueLabel: account.balance, label: 'credits_balance', accountName: account.name, disablePace: true };
61
61
  account.windows.balance = window;
62
62
  result.usage.windows[`${account.name} · ${q.kind} (${result.usage.accounts.length + 1})`] = window;
63
63
  }
@@ -158,12 +158,16 @@ export const fetchQuotaForProvider = async (providerId) => {
158
158
  try {
159
159
  return await provider.fetchQuota();
160
160
  } catch (error) {
161
+ const message = error instanceof Error ? error.message : 'Request failed';
162
+ // Credential source unreachable means we cannot know whether the provider is configured;
163
+ // never report it as a configured provider failure.
164
+ const credentialSourceUnavailable = message === 'Unable to read OpenCode credentials';
161
165
  return buildResult({
162
166
  providerId: provider.providerId,
163
167
  providerName: provider.providerName,
164
168
  ok: false,
165
- configured: true,
166
- error: error instanceof Error ? error.message : 'Request failed'
169
+ configured: !credentialSourceUnavailable,
170
+ error: message
167
171
  });
168
172
  }
169
173
  };
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
3
  import * as google from './google/index.js';
4
- import { listConfiguredQuotaProviders } from './index.js';
4
+ import { fetchQuotaForProvider, listConfiguredQuotaProviders } from './index.js';
5
5
 
6
6
  describe('quota provider registry', () => {
7
7
  it('exposes google provider configuration helpers through the provider module', () => {
@@ -14,4 +14,9 @@ describe('quota provider registry', () => {
14
14
  it('reports unavailable credentials instead of an empty configured-provider list', async () => {
15
15
  await expect(listConfiguredQuotaProviders()).rejects.toThrow('Unable to read OpenCode credentials');
16
16
  });
17
+
18
+ it('does not report a provider as configured when the credential source is unavailable', async () => {
19
+ const result = await fetchQuotaForProvider('claude');
20
+ expect(result).toMatchObject({ ok: false, configured: false, error: 'Unable to read OpenCode credentials' });
21
+ });
17
22
  });
@@ -24,7 +24,7 @@ Host side (`packages/web/server/lib/relay/`):
24
24
  - `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.
25
25
  - `identity.js` — the host's stable identity: the long-lived signing keypair (shared with the push relay, defines the routing id) plus a long-lived encryption keypair (the E2EE trust anchor). Reused across restarts; never rotated implicitly.
26
26
  - `signing-key.js` — storage/derivation of the signing keypair and the routing id, shared with the notifications runtime. Canonical public JWK hashing matches `packages/relay-server/src/push/crypto.js`.
27
- - `host-client.js` — the long-lived connection manager: one outbound control connection to the relay, a per-client data connection for each connected device, reconnect/backoff, and the E2EE responder handshake per connection. Control reconnect backoff does not reset on WebSocket `open`; `consecutiveFailures` clears only after the control socket stays up for `controlStableMs` (15s default), so an open-then-drop loop backs off to 30s instead of retrying every 1s.
27
+ - `host-client.js` — the long-lived connection manager: one outbound control connection to the relay, a per-client data connection for each connected device, reconnect, and the E2EE responder handshake per connection. Control reconnect keeps a fixed 3-second cadence until stopped; failure history clears only after the control socket stays up for `controlStableMs` (15s default), not on a brief WebSocket `open`.
28
28
  - `host-lock.js` — the per-machine host claim. Every local instance sharing the data dir shares the relay identity (same serverId), so concurrent relay hosts evict each other at the relay worker (`4001: Control replaced`) and paired devices land on whichever local process won last. The claim file (`<data-dir>/relay-host.lock`, `{ pid }`) makes this deterministic: `service.js` only starts the host when no LIVE process holds the claim (stale claims from dead pids are ignored), goes to `standby` otherwise, and a 30s watcher both takes over when the claimant dies and stands down when another process claims. Explicit user intent — creating a pairing link or hitting `/relay/enable` — force-claims; the previous holder's watcher sees the takeover and backs off instead of fighting. The claim is cooperative (the relay worker still enforces the single host slot); it only decides which process keeps retrying.
29
29
  - `tunnel-host.js` — the per-connection dispatcher: decrypts tunnel frames and forwards HTTP/SSE/WS to the local server over loopback, then streams responses back. Enforces a path allowlist and never injects credentials.
30
30
  - `e2ee.js`, `tunnel-codec.js` — host-side (JS) mirrors of the shared crypto and framing (see "Two implementations" below).
@@ -34,7 +34,7 @@ Client side (`packages/ui/src/lib/relay/`):
34
34
  - `protocol.ts` — the shared contract: constants, frame types, message shapes. The normative source both implementations follow.
35
35
  - `crypto.ts`, `handshake.ts` — the E2EE primitives and handshake state machines (initiator + responder).
36
36
  - `tunnel-codec.ts` — Layer 3 frame codec, fragmentation, and outbound frame batching.
37
- - `tunnel-client.ts` — the client tunnel: exposes a `fetch()`-compatible and a WebSocket-compatible surface backed by the encrypted tunnel.
37
+ - `tunnel-client.ts` — the client tunnel: exposes a `fetch()`-compatible and a WebSocket-compatible surface backed by the encrypted tunnel. Transient closures (including `4029` capacity/pending timeout and replacement) retry indefinitely at a fixed 3-second foreground cadence, or 60 seconds while hidden/offline. Online, visibility-visible and system-resume interrupt retry waits; an apparently connected tunnel is probed immediately. Authentication rejection stays terminal and later requests fail explicitly rather than waiting forever. Keepalive tracks send and receive separately: outbound requests cannot conceal a dead return path, and inbound-only SSE still sends pings so the Host idle reaper does not evict a healthy client. Reset fails every old stream; retries never replay mutation requests automatically.
38
38
  - `tunnel-payloads.ts`, `runtime-tunnel.ts`, `runtime-socket.ts` — payload helpers, the active-tunnel singleton, and the shared "open a runtime WebSocket the right way" helper.
39
39
 
40
40
  Relay is not a separate link format: it is one transport candidate inside the unified **pairing v2** payload (`packages/ui/src/lib/connectionPayload.ts`). A relay candidate is `{ type: 'relay', relayUrl, serverId, hostEncPubJwk }` — no embedded token; the client redeems the one-time pairing secret over the tunnel like any other candidate.
@@ -149,7 +149,7 @@ Catalog loaders (`loadProviders` / `loadAgents`) and assistant Query keys gate w
149
149
  - The host dispatcher never injects credentials; the server authenticates each tunneled request.
150
150
  - The tunnel is transparent to the app: adding relay support to a feature should not require the feature to know the relay exists — it goes through the shared runtime transport helpers.
151
151
  - The two implementations stay byte-compatible and the wire format is versioned/negotiated so mixed client/host app versions degrade gracefully rather than break. The Layer 1 Relay does not inspect application versions; unsupported Host/Client features are omitted at the endpoints.
152
- - Host-control reconnect storms are bounded at both ends: the Host does not reset backoff on a brief `open`, and the Relay rate-limits host-control upgrades per IP and per `serverId` (`4029`) without replacing a live control socket.
152
+ - Host-control reconnect storms are bounded at both ends: the Host keeps a fixed 3-second retry cadence, and the Relay rate-limits host-control upgrades per IP and per `serverId` (`4029`) without replacing a live control socket.
153
153
  - Concurrent service starts recheck the endpoint's active Host after awaiting identity, so each endpoint has one managed Host and stopping the service closes every started Host.
154
154
  - Tunneled HTTP/WS always dial `getLocalPort()` on loopback; there is no client-selected target-port override on the host dispatcher.
155
155
 
@@ -9,12 +9,10 @@ import { RELAY_PROTOCOL_VERSION, RelayCloseCode, createHostHandshake } from './e
9
9
  import { createOutboundFrameBatcher, decodeFrameBatch } from './tunnel-codec.js';
10
10
  import { createTunnelHost } from './tunnel-host.js';
11
11
 
12
- const BACKOFF_BASE_MS = 1000;
12
+ const BACKOFF_BASE_MS = 3000;
13
13
  const BACKOFF_CAP_MS = 30000;
14
- // Do not clear reconnect backoff on WebSocket `open`. A host that connects
15
- // then drops in ~1s (the observed control-channel storm) would otherwise retry
16
- // forever at 1s. Only a control socket that stays up this long is treated as
17
- // a healthy registration.
14
+ // Keep retry cadence fixed, and clear failure history only after the control
15
+ // socket remains stable rather than treating a brief open as healthy.
18
16
  const CONTROL_STABLE_MS = 15_000;
19
17
  const DATA_SOCKET_OPEN_TIMEOUT_MS = 15000;
20
18
  // Clients send a tunnel Ping at least every ~30s when idle, so a data socket
@@ -300,7 +298,7 @@ export const startRelayHost = ({ relayUrl, identity, localPort, getLocalPort, on
300
298
 
301
299
  const scheduleReconnect = () => {
302
300
  if (stopped || reconnectTimer) return;
303
- const delay = Math.min(backoffBaseMs * 2 ** consecutiveFailures, backoffCapMs);
301
+ const delay = Math.min(backoffBaseMs, backoffCapMs);
304
302
  consecutiveFailures += 1;
305
303
  setState('reconnecting');
306
304
  reconnectTimer = setTimeout(() => {
@@ -38,7 +38,7 @@ describe('relay host-client control reconnect', () => {
38
38
  relay = null;
39
39
  });
40
40
 
41
- it('does not reset control reconnect backoff on a brief open', async () => {
41
+ it('keeps retrying a brief-open control failure at a fixed interval', async () => {
42
42
  relay = await startDroppingRelay();
43
43
  host = startRelayHost({
44
44
  relayUrl: relay.url,
@@ -58,6 +58,7 @@ describe('relay host-client control reconnect', () => {
58
58
  const firstGap = relay.openedAt[1] - relay.openedAt[0];
59
59
  const secondGap = relay.openedAt[2] - relay.openedAt[1];
60
60
  expect(firstGap).toBeGreaterThanOrEqual(50);
61
- expect(secondGap).toBeGreaterThan(firstGap + 20);
61
+ expect(secondGap).toBeGreaterThanOrEqual(50);
62
+ expect(Math.abs(secondGap - firstGap)).toBeLessThan(60);
62
63
  });
63
64
  });
@@ -38,6 +38,7 @@ import { refreshRuntimeUrlAuthToken } from '../../../../ui/src/lib/runtime-auth.
38
38
  import { requestSpeechSession } from '../../../../ui/src/lib/voice/direct-session.ts';
39
39
  import { createGuiClient } from '../../../../ui/src/lib/opencode/gui.ts';
40
40
  import { createWebFilesAPI } from '../../../src/api/files.ts';
41
+ import { createEventPipeline } from '../../../../ui/src/sync/event-pipeline.ts';
41
42
 
42
43
  // Web's source aliases are not exported Node package subpaths. Forward them to
43
44
  // the real implementations so this Node E2E exercises the same transport singleton.
@@ -166,7 +167,7 @@ const readBody = async (req: http.IncomingMessage) => {
166
167
  return Buffer.concat(chunks).toString('utf8');
167
168
  };
168
169
 
169
- const startOrigin = async () => {
170
+ const startOrigin = async (options: { recoveryEvents?: boolean } = {}) => {
170
171
  const mediaDirectory = await mkdtemp(path.join(os.tmpdir(), 'relay-video-'));
171
172
  const videoPath = path.join(mediaDirectory, 'clip.mp4');
172
173
  await fsPromises.writeFile(videoPath, Buffer.from('0123456789'));
@@ -204,6 +205,7 @@ const startOrigin = async () => {
204
205
  registerTtsRoutes(speech, { sayTTSCapability: null });
205
206
  const broadcast = createGlobalUiEventBroadcaster({ sseClients: new Set(), wsClients: new Set(), writeSseEvent() {} });
206
207
  let hostSubscriptions = 0;
208
+ let recoveryRevision = 0;
207
209
  registerOpenCodeProxy(proxy, {
208
210
  fs: { promises: { realpath: async (value: string) => value } }, os: {}, path: {},
209
211
  getRuntime: () => ({ isOpenCodeReady: true, openCodePort: 4096 }),
@@ -222,6 +224,15 @@ const startOrigin = async () => {
222
224
  const pathname = new URL(req.url ?? '/', 'http://origin').pathname;
223
225
  if (pathname === '/fixture-event') {
224
226
  res.writeHead(200, { 'content-type': 'text/event-stream' });
227
+ if (options.recoveryEvents) {
228
+ const emit = () => res.write(`data: ${JSON.stringify({ type: 'session.status', properties: {
229
+ sessionID: `ses_recovery_${recoveryRevision}`, status: { type: 'idle' },
230
+ } })}\n\n`);
231
+ emit();
232
+ const timer = setInterval(emit, 30);
233
+ res.on('close', () => clearInterval(timer));
234
+ return;
235
+ }
225
236
  res.write('data: {"type":"session.execution.started","data":{"sessionID":"ses_relay"}}\n\n');
226
237
  await wait(70);
227
238
  broadcast({ type: 'session.updated', properties: { info: { id: 'ses_relay', title: 'Relay title', time: { created: 1, updated: 2 } } } }, { directory: '/repo' });
@@ -338,6 +349,7 @@ const startOrigin = async () => {
338
349
  const port = (server.address() as net.AddressInfo).port;
339
350
  return {
340
351
  port, videoPath, previewPath, previewContent, guiBundle, pluginInventory, guiRequests, bearerRequests, observedOrigins, getHostSubscriptions: () => hostSubscriptions,
352
+ advanceRecoveryRevision: () => { recoveryRevision += 1; return `ses_recovery_${recoveryRevision}`; },
341
353
  stop: async () => {
342
354
  dictation.stop();
343
355
  for (const client of wss.clients) client.terminate();
@@ -430,6 +442,137 @@ describe('private relay compiled-process boundary', () => {
430
442
  let cleanup: (() => Promise<void>) | undefined;
431
443
  afterEach(async () => { try { await cleanup?.(); } finally { cleanup = undefined; vi.unstubAllEnvs(); } });
432
444
 
445
+ it('recovers HTTP and the retained SDK event pipeline after phone, Host, and combined disconnects', { timeout: 60_000 }, async () => {
446
+ const temp = await mkdtemp(path.join(os.tmpdir(), 'yuri-relay-recovery-'));
447
+ const binary = path.join(temp, 'yuri-relay');
448
+ let relay: Awaited<ReturnType<typeof startCompiledRelay>> | undefined;
449
+ let origin: Awaited<ReturnType<typeof startOrigin>> | undefined = undefined;
450
+ let host: ReturnType<typeof startRelayHost> | undefined;
451
+ let client: ReturnType<typeof createRelayTunnelClient> | undefined = undefined;
452
+ let pipeline: ReturnType<typeof createEventPipeline> | undefined = undefined;
453
+ let phoneWire: WebSocket | undefined;
454
+ let capacityBlocker: WebSocket | undefined = undefined;
455
+ let discardWireMessages = false;
456
+ const previousResolver = getRuntimeUrlResolver();
457
+ const runtimeWindow = Object.assign(new EventTarget(), { location: new URL('https://relay-runtime.example') });
458
+ const runtimeDocument = Object.assign(new EventTarget(), { visibilityState: 'visible' });
459
+ vi.stubGlobal('window', runtimeWindow);
460
+ vi.stubGlobal('document', runtimeDocument);
461
+ cleanup = async () => {
462
+ pipeline?.cleanup();
463
+ deactivateRelayTunnel();
464
+ client?.close();
465
+ capacityBlocker?.terminate();
466
+ host?.stop();
467
+ setRuntimeBearerToken(null);
468
+ setRuntimeUrlResolver(previousResolver);
469
+ vi.unstubAllGlobals();
470
+ await Promise.all([origin?.stop(), stopRelay(relay)]);
471
+ await rm(temp, { recursive: true, force: true });
472
+ };
473
+ const entrypoint = fileURLToPath(new URL('../../../../relay-server/bin/yuri-relay.js', import.meta.url));
474
+ const compile = spawn('bun', ['build', '--compile', entrypoint, '--outfile', binary], { stdio: 'ignore' });
475
+ expect((await once(compile, 'exit'))[0]).toBe(0);
476
+ const port = await freePort();
477
+ vi.stubEnv('YURI_RELAY_SERVER_MAX_CLIENTS_PER_HOST', '1');
478
+ relay = await startCompiledRelay(binary, port);
479
+ origin = await startOrigin({ recoveryEvents: true });
480
+ const identity = await buildIdentity();
481
+ const startHost = () => startRelayHost({ relayUrl: relay!.url, identity, getLocalPort: () => origin!.port,
482
+ onStatus() {}, logger: { warn() {}, info() {} }, reconnectBaseDelayMs: 30, reconnectMaxDelayMs: 100 });
483
+ host = startHost();
484
+ await eventually(() => host!.getStatus().state === 'connected', 'Host did not register');
485
+ capacityBlocker = new WebSocket(`${relay.url}?v=1&role=client&serverId=${identity.serverId}`);
486
+ await once(capacityBlocker, 'open');
487
+ client = createRelayTunnelClient({ relayUrl: relay.url, serverId: identity.serverId, hostEncPubJwk: identity.hostEncPubJwk,
488
+ helloRetryMs: 20, helloTimeoutMs: 500, pingIntervalMs: 100, pingTimeoutMs: 50,
489
+ reconnectBaseDelayMs: 20, reconnectMaxDelayMs: 100, batchWindowMs: 0,
490
+ createWireSocket: (url) => {
491
+ const socket = new WebSocket(url);
492
+ phoneWire = socket;
493
+ const wire = {
494
+ get readyState() { return socket.readyState; },
495
+ send: (data: string | ArrayBuffer | Uint8Array) => socket.send(data),
496
+ close: (code?: number, reason?: string) => socket.close(code, reason),
497
+ onopen: null as (() => void) | null,
498
+ onmessage: null as ((event: { data: unknown }) => void) | null,
499
+ onclose: null as ((event: { code: number; reason: string }) => void) | null,
500
+ onerror: null as (() => void) | null,
501
+ };
502
+ socket.on('open', () => wire.onopen?.());
503
+ socket.on('message', (data, binary) => {
504
+ if (!discardWireMessages) wire.onmessage?.({ data: binary ? new Uint8Array(data as Buffer) : data.toString() });
505
+ });
506
+ socket.on('close', (code, reason) => wire.onclose?.({ code, reason: reason.toString() }));
507
+ socket.on('error', () => wire.onerror?.());
508
+ return wire;
509
+ },
510
+ });
511
+ await eventually(() => client!.getStatus().lastError === 'relay connection limit reached', 'real Relay did not reject the capacity-limited client');
512
+ capacityBlocker.terminate();
513
+ configureRuntimeUrlResolver({ apiBaseUrl: 'https://relay-runtime.example' });
514
+ setRuntimeBearerToken('client-token');
515
+ adoptRelayTunnel({ relayUrl: relay.url, serverId: identity.serverId, hostEncPubJwk: identity.hostEncPubJwk }, client);
516
+ opencodeClient.reconnectToRuntimeBaseUrl();
517
+ const observed = new Set<string>();
518
+ let compensations = 0;
519
+ pipeline = createEventPipeline({ sdk: opencodeClient.getSdkClient(), transport: 'sse', heartbeatTimeoutMs: 300,
520
+ reconnectDelayMs: 20, onCompensation: () => { compensations += 1; },
521
+ onEvent: (_directory, payload) => {
522
+ if (payload.type === 'session.status') observed.add(payload.properties.sessionID);
523
+ },
524
+ });
525
+ await eventually(() => observed.has('ses_recovery_0'), 'initial session event was not received');
526
+ for (const scenario of ['phone', 'host', 'phone-then-host', 'host-then-phone', 'relay-restart', 'lock-screen', 'silent-return-path'] as const) {
527
+ const before = compensations;
528
+ const expected = origin.advanceRecoveryRevision();
529
+ if (scenario === 'phone' || scenario === 'phone-then-host') phoneWire!.terminate();
530
+ if (scenario === 'host' || scenario === 'phone-then-host' || scenario === 'host-then-phone') {
531
+ host.stop();
532
+ if (scenario === 'host-then-phone') phoneWire!.terminate();
533
+ await wait(60);
534
+ host = startHost();
535
+ }
536
+ if (scenario === 'relay-restart') {
537
+ const old = relay;
538
+ relay = undefined;
539
+ await stopRelay(old);
540
+ relay = await startCompiledRelay(binary, port);
541
+ }
542
+ if (scenario === 'lock-screen') {
543
+ runtimeDocument.visibilityState = 'hidden';
544
+ runtimeDocument.dispatchEvent(new Event('visibilitychange'));
545
+ discardWireMessages = true;
546
+ phoneWire!.terminate();
547
+ await wait(100);
548
+ discardWireMessages = false;
549
+ runtimeDocument.visibilityState = 'visible';
550
+ runtimeDocument.dispatchEvent(new Event('visibilitychange'));
551
+ runtimeWindow.dispatchEvent(new Event('yuri:system-resume'));
552
+ }
553
+ if (scenario === 'silent-return-path') {
554
+ const staleWire = phoneWire;
555
+ discardWireMessages = true;
556
+ const traffic = setInterval(() => {
557
+ void client!.fetch('/api/e2e/http', { method: 'POST', headers: { authorization: 'Bearer client-token' }, body: 'still-sending' })
558
+ .catch(() => undefined);
559
+ }, 10);
560
+ try {
561
+ await eventually(() => phoneWire !== staleWire, 'outbound traffic concealed the dead return path');
562
+ } finally {
563
+ clearInterval(traffic);
564
+ discardWireMessages = false;
565
+ }
566
+ }
567
+ await eventually(() => client!.getStatus().state === 'connected' && compensations > before,
568
+ `${scenario}: tunnel or SDK event subscription did not reconnect`);
569
+ const response = await client.fetch('/api/e2e/http', { method: 'POST', headers: { authorization: 'Bearer client-token' }, body: scenario });
570
+ expect(await response.json()).toEqual({ body: scenario, hasRelayConnection: true });
571
+ await eventually(() => observed.has(expected) && compensations > before, `${scenario}: HTTP recovered but session events or compensation remained stuck`);
572
+ expect(origin.getHostSubscriptions()).toBe(1);
573
+ }
574
+ });
575
+
433
576
  it('carries authenticated HTTP, SSE, URL-token WebSocket, restart recovery, and cleanup across compiled Relay', { timeout: 60_000 }, async () => {
434
577
  const temp = await mkdtemp(path.join(os.tmpdir(), 'yuri-relay-e2e-'));
435
578
  vi.stubEnv('YURI_DATA_DIR', path.join(temp, 'host-data'));