@openchambery/web 1.18.4 → 1.18.6-beta.1

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 (114) hide show
  1. package/dist/assets/{AgentAvatar-DAnelAnB.js → AgentAvatar-DDcjamcJ.js} +1 -1
  2. package/dist/assets/AssistantView-LPfaliRV.js +1 -0
  3. package/dist/assets/{ChatContainer-BVPeKR-K.js → ChatContainer-BYdx_DXz.js} +40 -40
  4. package/dist/assets/ContextPanel-BwwT_VfC.js +288 -0
  5. package/dist/assets/DiagramView-DvFv9-nP.js +1 -0
  6. package/dist/assets/{FadeInOnReveal-QxF1vuqX.js → FadeInOnReveal-By2F9vcI.js} +1 -1
  7. package/dist/assets/{Icon-D-X70irR.js → Icon-DpjYnXxn.js} +1 -1
  8. package/dist/assets/{MarkdownRendererImpl-TCIXUwWr.js → MarkdownRendererImpl-Cm08lbud.js} +2 -2
  9. package/dist/assets/{MobileDetailNavigation-BVwAAhoU.js → MobileDetailNavigation-BB2pDQj8.js} +1 -1
  10. package/dist/assets/{MobileShareBridge-2J_Tfuji.js → MobileShareBridge-DlWPsLUN.js} +3 -3
  11. package/dist/assets/MobileSurface-CN0sClQE.js +2 -0
  12. package/dist/assets/{MultiRunWindow-UffGnrG2.js → MultiRunWindow-DB8M7hTi.js} +1 -1
  13. package/dist/assets/{OnboardingScreen-Cx79VlTN.js → OnboardingScreen-BKmuT7AL.js} +1 -1
  14. package/dist/assets/{OverlayScrollbar-CHXk_jvF.js → OverlayScrollbar-Ch3J6ASR.js} +1 -1
  15. package/dist/assets/{SettingsView-Da1ATyc8.js → SettingsView-DGLS2Mg6.js} +11 -11
  16. package/dist/assets/{SettingsWindow-nVdVW9KM.js → SettingsWindow-C30XBMKE.js} +1 -1
  17. package/dist/assets/{TerminalView-BTY7HznA.js → TerminalView-4tdrrTVF.js} +1 -1
  18. package/dist/assets/{ToolOutputDialog-BJfWelnd.js → ToolOutputDialog-CkkvQ6I2.js} +1 -1
  19. package/dist/assets/appThemeRegistry-BNiZ1vQk.js +2 -0
  20. package/dist/assets/{button-CwLFtUNT.js → button-C7OXr4ae.js} +1 -1
  21. package/dist/assets/{clipboard-BfgFef1i.js → clipboard-DWuULPzo.js} +1 -1
  22. package/dist/assets/{collapsible-CP1-_pY6.js → collapsible-DaEya6b6.js} +1 -1
  23. package/dist/assets/{desktopHosts-Cr3LE55y.js → desktopHosts-Txp4xOVQ.js} +1 -1
  24. package/dist/assets/desktopRelayRestore-C_FSEHKM.js +1 -0
  25. package/dist/assets/{dialog-GR7KoP1o.js → dialog-DPS0W9eS.js} +1 -1
  26. package/dist/assets/{es-Bi4m8Mm6.js → es-BX0Vm3Ac.js} +1 -1
  27. package/dist/assets/fileQueries-B_fTkH6s.js +1 -0
  28. package/dist/assets/{fr-B5UdepyS.js → fr-CuPzXTYx.js} +1 -1
  29. package/dist/assets/{gitApi-BfOQScwC.js → gitApi-DfuIaByA.js} +3 -3
  30. package/dist/assets/{input-D52Jicb1.js → input-BzYA603C.js} +1 -1
  31. package/dist/assets/insertionBoundaries-C642g-Iw.js +1 -0
  32. package/dist/assets/{ja-KtFuRjvm.js → ja-DGtzjrFO.js} +1 -1
  33. package/dist/assets/{ko-CWpFVSCH.js → ko-DZ9Di0je.js} +1 -1
  34. package/dist/assets/main-C0AmH89S.js +29 -0
  35. package/dist/assets/{main-CTzdOaGn.js → main-M0K2vB13.js} +2 -2
  36. package/dist/assets/{markdown-worker-N9d_Z-7s.js → markdown-worker-W06-MhF5.js} +1 -1
  37. package/dist/assets/{markdownTheme-Bl0Sy0Lf.js → markdownTheme-B89dbj3N.js} +1 -1
  38. package/dist/assets/{miniChat-CAbceO-F.js → miniChat-B3KVwxjN.js} +2 -2
  39. package/dist/assets/mobile-rzYyWvdR.js +2 -0
  40. package/dist/assets/{multirun-C2J5Yp8V.js → multirun-qDXHE6q-.js} +1 -1
  41. package/dist/assets/{persistence-vZ7H8WKh.js → persistence-6sclr7B6.js} +2 -2
  42. package/dist/assets/{pl-30X8TD5i.js → pl-BuCO3qb1.js} +1 -1
  43. package/dist/assets/{platform-CTaznShj.js → platform-CbeLpKPk.js} +1 -1
  44. package/dist/assets/projectMeta-CyhrgevV.js +3 -0
  45. package/dist/assets/{pt-BR-Cm-Klf0E.js → pt-BR-Brf4RMsw.js} +1 -1
  46. package/dist/assets/radio-J9GiJ7x9.js +1 -0
  47. package/dist/assets/renderElectronMiniChatApp-DASrZbVL.js +2 -0
  48. package/dist/assets/renderMobileApp-OOhkEOlN.js +23 -0
  49. package/dist/assets/{runtimeConfig-CCrS3B1v.js → runtimeConfig-D8mh3gFs.js} +1 -1
  50. package/dist/assets/runtimeEndpointReset-BSJKTLkz.js +4 -0
  51. package/dist/assets/shikiHighlight-BcXbHYOl.js +1 -0
  52. package/dist/assets/{sortable-tabs-strip-BYmWSdS9.js → sortable-tabs-strip-nLsPC06f.js} +1 -1
  53. package/dist/assets/src-BDOLh3pc.css +2 -0
  54. package/dist/assets/{store-Z1MxUaP4.js → store-DQY8Fkb0.js} +2 -2
  55. package/dist/assets/{terminalApi-KDUc5mh2.js → terminalApi-BpPeXWIu.js} +1 -1
  56. package/dist/assets/{tooltip-CaCe-GAm.js → tooltip-D_orJMYd.js} +1 -1
  57. package/dist/assets/{uk-Cgc5wXrs.js → uk-C-wmaPTi.js} +1 -1
  58. package/dist/assets/{url-B-FWrnxu.js → url-BsaBG5-1.js} +1 -1
  59. package/dist/assets/useAppFontEffects-Bgx8zwRg.js +7 -0
  60. package/dist/assets/{useAssistantUIStore-ifqNyja4.js → useAssistantUIStore-BHsHXCKE.js} +1 -1
  61. package/dist/assets/{useDesktopWindowControlsLayout-C7JocspE.js → useDesktopWindowControlsLayout-D8rr0PdL.js} +1 -1
  62. package/dist/assets/{useEffectiveDirectory-DMWATHLS.js → useEffectiveDirectory-Dfo_EXBo.js} +1 -1
  63. package/dist/assets/{useFontPreferences-D_LFFhFS.js → useFontPreferences-ckzpXQaJ.js} +1 -1
  64. package/dist/assets/useMobileNavigationStore-hrmD9bA5.js +475 -0
  65. package/dist/assets/useSessionAutoCleanup-B2TGbr2W.js +1 -0
  66. package/dist/assets/useUIStore-DzwCfRqr.js +1 -0
  67. package/dist/assets/{useWorkerHighlightedLines-NddS5-lr.js → useWorkerHighlightedLines-0_GDJima.js} +1 -1
  68. package/dist/assets/{utils-C2P0wcWO.js → utils-B1EK5zKa.js} +1 -1
  69. package/dist/assets/{zh-CN-BdRwDJuj.js → zh-CN-DueRrIql.js} +1 -1
  70. package/dist/assets/{zh-TW-C3LubKzZ.js → zh-TW-6875X80V.js} +1 -1
  71. package/dist/index.html +9 -9
  72. package/dist/mini-chat.html +9 -9
  73. package/dist/mobile.html +9 -9
  74. package/package.json +1 -1
  75. package/server/lib/config-sync/config-sync.test.js +52 -0
  76. package/server/lib/config-sync/scripts.js +10 -2
  77. package/server/lib/notifications/DOCUMENTATION.md +2 -1
  78. package/server/lib/notifications/emitter-runtime.js +78 -1
  79. package/server/lib/notifications/emitter-runtime.test.js +94 -1
  80. package/server/lib/scheduled-tasks/DOCUMENTATION.md +4 -1
  81. package/server/lib/scheduled-tasks/routes.js +51 -8
  82. package/server/lib/session-index/DOCUMENTATION.md +9 -3
  83. package/server/lib/session-index/service.js +45 -22
  84. package/server/lib/session-index/service.test.js +81 -0
  85. package/server/lib/session-title/DOCUMENTATION.md +15 -10
  86. package/server/lib/session-title/runtime.js +24 -0
  87. package/server/lib/session-title/runtime.test.js +143 -0
  88. package/server/lib/session-turn-pages/DOCUMENTATION.md +2 -1
  89. package/server/lib/session-turn-pages/service.js +14 -1
  90. package/server/lib/session-turn-pages/service.test.js +133 -0
  91. package/server/lib/ui-auth/ui-auth.js +3 -1
  92. package/server/lib/ui-auth/ui-auth.test.js +25 -0
  93. package/server/sse-routes.test.js +64 -1
  94. package/dist/assets/AssistantView-DM2dKfoR.js +0 -1
  95. package/dist/assets/DiagramView-Cmf-1RrR.js +0 -1
  96. package/dist/assets/MobileSurface-CDiflo1b.js +0 -2
  97. package/dist/assets/appThemeRegistry-BQGUOtTV.js +0 -2
  98. package/dist/assets/context-menu-BwxsmiaI.js +0 -1
  99. package/dist/assets/desktopRelayRestore-VfMK9fdk.js +0 -1
  100. package/dist/assets/diagram-rYL80jaS.js +0 -1
  101. package/dist/assets/fileQueries-CXaw4b1W.js +0 -1
  102. package/dist/assets/insertionBoundaries-Gk_rVlpX.js +0 -1
  103. package/dist/assets/main-7rfc5WXp.js +0 -172
  104. package/dist/assets/mobile-BX6ehEeM.js +0 -2
  105. package/dist/assets/projectMeta-mqvgqR8a.js +0 -3
  106. package/dist/assets/radio-nnW-6V1r.js +0 -1
  107. package/dist/assets/renderElectronMiniChatApp-C2Ya6FdB.js +0 -2
  108. package/dist/assets/renderMobileApp-BgDGLev_.js +0 -23
  109. package/dist/assets/runtimeEndpointReset-C1NE1NgZ.js +0 -147
  110. package/dist/assets/src-Dbdlm5x1.css +0 -2
  111. package/dist/assets/useAppFontEffects-BoCsqVCV.js +0 -7
  112. package/dist/assets/useMobileNavigationStore-CLiqmN1d.js +0 -476
  113. package/dist/assets/useSessionAutoCleanup-BPKBXJg4.js +0 -1
  114. package/dist/assets/useUIStore-NfqK-HA7.js +0 -1
package/dist/index.html CHANGED
@@ -552,25 +552,25 @@
552
552
  opacity: 0.72;
553
553
  }
554
554
  </style>
555
- <script type="module" crossorigin src="/assets/main-CTzdOaGn.js"></script>
555
+ <script type="module" crossorigin src="/assets/main-M0K2vB13.js"></script>
556
556
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
557
557
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
558
558
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
559
- <link rel="modulepreload" crossorigin href="/assets/useUIStore-NfqK-HA7.js">
559
+ <link rel="modulepreload" crossorigin href="/assets/useUIStore-DzwCfRqr.js">
560
560
  <link rel="modulepreload" crossorigin href="/assets/vendor-pathe-vBmvQE8f.js">
561
561
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-DLPElpoQ.js">
562
562
  <link rel="modulepreload" crossorigin href="/assets/vendor-tanstack-query-core-BWz0ose6.js">
563
- <link rel="modulepreload" crossorigin href="/assets/persistence-vZ7H8WKh.js">
564
- <link rel="modulepreload" crossorigin href="/assets/desktopHosts-Cr3LE55y.js">
565
- <link rel="modulepreload" crossorigin href="/assets/desktopRelayRestore-VfMK9fdk.js">
563
+ <link rel="modulepreload" crossorigin href="/assets/persistence-6sclr7B6.js">
564
+ <link rel="modulepreload" crossorigin href="/assets/desktopHosts-Txp4xOVQ.js">
565
+ <link rel="modulepreload" crossorigin href="/assets/desktopRelayRestore-C_FSEHKM.js">
566
566
  <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-C07HQypa.js">
567
567
  <link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js">
568
- <link rel="modulepreload" crossorigin href="/assets/platform-CTaznShj.js">
569
- <link rel="modulepreload" crossorigin href="/assets/terminalApi-KDUc5mh2.js">
568
+ <link rel="modulepreload" crossorigin href="/assets/platform-CbeLpKPk.js">
569
+ <link rel="modulepreload" crossorigin href="/assets/terminalApi-BpPeXWIu.js">
570
570
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
571
571
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
572
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CCrS3B1v.js">
573
- <link rel="stylesheet" crossorigin href="/assets/src-Dbdlm5x1.css">
572
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D8mh3gFs.js">
573
+ <link rel="stylesheet" crossorigin href="/assets/src-BDOLh3pc.css">
574
574
  </head>
575
575
  <body class="h-full bg-background text-foreground">
576
576
  <!-- Keep the startup layer outside #root. React replaces every child of
@@ -74,25 +74,25 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-CAbceO-F.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-B3KVwxjN.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
81
- <link rel="modulepreload" crossorigin href="/assets/useUIStore-NfqK-HA7.js">
81
+ <link rel="modulepreload" crossorigin href="/assets/useUIStore-DzwCfRqr.js">
82
82
  <link rel="modulepreload" crossorigin href="/assets/vendor-pathe-vBmvQE8f.js">
83
83
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-DLPElpoQ.js">
84
84
  <link rel="modulepreload" crossorigin href="/assets/vendor-tanstack-query-core-BWz0ose6.js">
85
- <link rel="modulepreload" crossorigin href="/assets/persistence-vZ7H8WKh.js">
86
- <link rel="modulepreload" crossorigin href="/assets/desktopHosts-Cr3LE55y.js">
87
- <link rel="modulepreload" crossorigin href="/assets/desktopRelayRestore-VfMK9fdk.js">
85
+ <link rel="modulepreload" crossorigin href="/assets/persistence-6sclr7B6.js">
86
+ <link rel="modulepreload" crossorigin href="/assets/desktopHosts-Txp4xOVQ.js">
87
+ <link rel="modulepreload" crossorigin href="/assets/desktopRelayRestore-C_FSEHKM.js">
88
88
  <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-C07HQypa.js">
89
89
  <link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js">
90
- <link rel="modulepreload" crossorigin href="/assets/platform-CTaznShj.js">
91
- <link rel="modulepreload" crossorigin href="/assets/terminalApi-KDUc5mh2.js">
90
+ <link rel="modulepreload" crossorigin href="/assets/platform-CbeLpKPk.js">
91
+ <link rel="modulepreload" crossorigin href="/assets/terminalApi-BpPeXWIu.js">
92
92
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
93
93
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
94
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CCrS3B1v.js">
95
- <link rel="stylesheet" crossorigin href="/assets/src-Dbdlm5x1.css">
94
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D8mh3gFs.js">
95
+ <link rel="stylesheet" crossorigin href="/assets/src-BDOLh3pc.css">
96
96
  </head>
97
97
  <body class="h-full bg-background text-foreground">
98
98
  <div id="root" class="h-full">
package/dist/mobile.html CHANGED
@@ -63,25 +63,25 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-BX6ehEeM.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-rzYyWvdR.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
70
- <link rel="modulepreload" crossorigin href="/assets/useUIStore-NfqK-HA7.js">
70
+ <link rel="modulepreload" crossorigin href="/assets/useUIStore-DzwCfRqr.js">
71
71
  <link rel="modulepreload" crossorigin href="/assets/vendor-pathe-vBmvQE8f.js">
72
72
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-DLPElpoQ.js">
73
73
  <link rel="modulepreload" crossorigin href="/assets/vendor-tanstack-query-core-BWz0ose6.js">
74
- <link rel="modulepreload" crossorigin href="/assets/persistence-vZ7H8WKh.js">
75
- <link rel="modulepreload" crossorigin href="/assets/desktopHosts-Cr3LE55y.js">
76
- <link rel="modulepreload" crossorigin href="/assets/desktopRelayRestore-VfMK9fdk.js">
74
+ <link rel="modulepreload" crossorigin href="/assets/persistence-6sclr7B6.js">
75
+ <link rel="modulepreload" crossorigin href="/assets/desktopHosts-Txp4xOVQ.js">
76
+ <link rel="modulepreload" crossorigin href="/assets/desktopRelayRestore-C_FSEHKM.js">
77
77
  <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-C07HQypa.js">
78
78
  <link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js">
79
- <link rel="modulepreload" crossorigin href="/assets/platform-CTaznShj.js">
80
- <link rel="modulepreload" crossorigin href="/assets/terminalApi-KDUc5mh2.js">
79
+ <link rel="modulepreload" crossorigin href="/assets/platform-CbeLpKPk.js">
80
+ <link rel="modulepreload" crossorigin href="/assets/terminalApi-BpPeXWIu.js">
81
81
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
82
82
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
83
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-CCrS3B1v.js">
84
- <link rel="stylesheet" crossorigin href="/assets/src-Dbdlm5x1.css">
83
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D8mh3gFs.js">
84
+ <link rel="stylesheet" crossorigin href="/assets/src-BDOLh3pc.css">
85
85
  </head>
86
86
  <body class="h-full bg-background text-foreground">
87
87
  <div id="root" class="h-full"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openchambery/web",
3
- "version": "1.18.4",
3
+ "version": "1.18.6-beta.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -14,6 +14,7 @@ import {
14
14
  assertTargetCapability,
15
15
  buildDefaultSyncSelections,
16
16
  buildRemoteSyncFinalizeScript,
17
+ buildRemoteSyncInventoryScript,
17
18
  buildRemoteSyncPrepareScript,
18
19
  createSshSyncTarget,
19
20
  filterPlanBySelections,
@@ -195,3 +196,54 @@ describe('generational prepare backups', () => {
195
196
  })).toThrow();
196
197
  });
197
198
  });
199
+
200
+ describe('remote inventory script', () => {
201
+ it('emits SYNC_INVENTORY as valid JSON with quoted path values (regression: bare quotes broke JSON.parse)', async () => {
202
+ const home = await makeTempDir();
203
+ const configDir = path.join(home, '.config', 'opencode');
204
+ await fsp.mkdir(path.join(configDir, 'agents'), { recursive: true });
205
+ await fsp.writeFile(path.join(configDir, 'opencode.jsonc'), '{"a":1}\n');
206
+ await fsp.writeFile(path.join(configDir, 'AGENTS.md'), '# agents\n');
207
+ await fsp.writeFile(path.join(configDir, 'agents', 'helper.md'), 'x'.repeat(7));
208
+ await fsp.mkdir(path.join(home, '.local', 'share', 'opencode'), { recursive: true });
209
+ await fsp.writeFile(path.join(home, '.local', 'share', 'opencode', 'auth.json'), '{}\n');
210
+
211
+ const stdout = execFileSync('sh', ['-c', buildRemoteSyncInventoryScript()], {
212
+ env: { ...process.env, HOME: home },
213
+ });
214
+ const line = stdout.toString().split(/\r?\n/).find((entry) => entry.startsWith('SYNC_INVENTORY='));
215
+ expect(line).toBeTruthy();
216
+
217
+ // This threw SyntaxError ("Unexpected token") before path values were
218
+ // escaped for the surrounding shell double-quoted string.
219
+ const inventory = JSON.parse(line.slice('SYNC_INVENTORY='.length));
220
+ const files = inventory.files.map((entry) => entry.path);
221
+ expect(files).toContain('opencode.jsonc');
222
+ expect(files).toContain('AGENTS.md');
223
+ const directories = inventory.directories.map((entry) => entry.path);
224
+ expect(directories).toContain('agents');
225
+ expect(inventory.authFile).toEqual({ bytes: 3 });
226
+ for (const entry of inventory.files) {
227
+ expect(typeof entry.path).toBe('string');
228
+ expect(typeof entry.bytes).toBe('number');
229
+ }
230
+ for (const entry of inventory.directories) {
231
+ expect(typeof entry.path).toBe('string');
232
+ expect(typeof entry.fileCount).toBe('number');
233
+ expect(typeof entry.bytes).toBe('number');
234
+ }
235
+ });
236
+
237
+ it('still parses when nothing exists on the remote', async () => {
238
+ const home = await makeTempDir();
239
+ const stdout = execFileSync('sh', ['-c', buildRemoteSyncInventoryScript()], {
240
+ env: { ...process.env, HOME: home },
241
+ });
242
+ const line = stdout.toString().split(/\r?\n/).find((entry) => entry.startsWith('SYNC_INVENTORY='));
243
+ const inventory = JSON.parse(line.slice('SYNC_INVENTORY='.length));
244
+ expect(inventory.files).toEqual([]);
245
+ expect(inventory.directories).toEqual([]);
246
+ expect(inventory.agentsRoot).toBeNull();
247
+ expect(inventory.authFile).toBeNull();
248
+ });
249
+ });
@@ -12,6 +12,14 @@ import {
12
12
 
13
13
  const shellQuote = (value) => `'${String(value).replace(/'/g, `'\\''`)}'`;
14
14
 
15
+ /**
16
+ * JSON.stringify yields bare double quotes, which terminate the surrounding
17
+ * shell double-quoted string in inventory lines. Escape them so the assembled
18
+ * SYNC_INVENTORY payload stays valid JSON after sh evaluation.
19
+ * @param {string} value
20
+ */
21
+ const jsonShellEscape = (value) => JSON.stringify(value).replace(/"/g, '\\"');
22
+
15
23
  /**
16
24
  * Sanitize syncRunId for use as a single path segment under backup roots.
17
25
  * @param {string} syncRunId
@@ -202,7 +210,7 @@ export const buildRemoteSyncInventoryScript = () => {
202
210
  const quoted = shellQuote(rel);
203
211
  lines.push(`if [ -f "$CFG"/${quoted} ]; then`);
204
212
  lines.push(` BYTES="$(wc -c < "$CFG"/${quoted} | tr -d ' ')"`);
205
- lines.push(` FILES="$FILES{\\"path\\":${JSON.stringify(rel)},\\"bytes\\":$BYTES},"`);
213
+ lines.push(` FILES="$FILES{\\"path\\":${jsonShellEscape(rel)},\\"bytes\\":$BYTES},"`);
206
214
  lines.push('fi');
207
215
  }
208
216
  for (const rel of dirPaths) {
@@ -210,7 +218,7 @@ export const buildRemoteSyncInventoryScript = () => {
210
218
  lines.push(`if [ -d "$CFG"/${quoted} ]; then`);
211
219
  lines.push(` COUNT="$(find "$CFG"/${quoted} -type f ! -path '*/node_modules/*' ! -name '*.backup' 2>/dev/null | wc -l | tr -d ' ')"`);
212
220
  lines.push(` BYTES="$(find "$CFG"/${quoted} -type f ! -path '*/node_modules/*' ! -name '*.backup' -exec wc -c {} + 2>/dev/null | awk 'END{print $1+0}')"`);
213
- lines.push(` DIRS="$DIRS{\\"path\\":${JSON.stringify(rel)},\\"fileCount\\":$COUNT,\\"bytes\\":$BYTES},"`);
221
+ lines.push(` DIRS="$DIRS{\\"path\\":${jsonShellEscape(rel)},\\"fileCount\\":$COUNT,\\"bytes\\":$BYTES},"`);
214
222
  lines.push('fi');
215
223
  }
216
224
  lines.push('AGENTS="null"');
@@ -77,9 +77,10 @@ This module provides notification message preparation utilities for the web serv
77
77
  ### Emitter runtime API (emitter-runtime.js)
78
78
  - `createNotificationEmitterRuntime(dependencies)`: creates runtime for unified notification emission channels.
79
79
  - Returned API:
80
- - `writeSseEvent(res, payload)`
80
+ - `writeSseEvent(res, payload)` — best-effort SSE write with backpressure: when `res.write` returns `false`, the client is marked paused and further writes are skipped until `drain`; buffered bytes above `SSE_CLIENT_MAX_BUFFERED_BYTES` (2 MiB, aligned with relay-server) destroy the response. Authoritative data remains HTTP pull.
81
81
  - `emitDesktopNotification(payload)`
82
82
  - `broadcastUiNotification(payload)`
83
+ - Exported constant: `SSE_CLIENT_MAX_BUFFERED_BYTES`
83
84
 
84
85
  ### Template runtime API (template-runtime.js)
85
86
  - `createNotificationTemplateRuntime(dependencies)`: creates shared notification/template runtime. Model-backed summarization was retired after the Zen provider became unavailable.
@@ -1,3 +1,41 @@
1
+ // Align with relay-server per-connection queue cap (2 MiB).
2
+ export const SSE_CLIENT_MAX_BUFFERED_BYTES = 2 * 1024 * 1024;
3
+
4
+ const isSseResponseClosed = (res) => Boolean(res?.writableEnded || res?.destroyed);
5
+
6
+ const getSseBufferedBytes = (res) => {
7
+ if (typeof res?.writableLength === 'number' && Number.isFinite(res.writableLength)) {
8
+ return res.writableLength;
9
+ }
10
+ const tracked = res?.__sseBufferedBytes;
11
+ return typeof tracked === 'number' && Number.isFinite(tracked) ? tracked : 0;
12
+ };
13
+
14
+ const attachSseDrainListener = (res) => {
15
+ if (res.__sseDrainAttached) {
16
+ return;
17
+ }
18
+ res.__sseDrainAttached = true;
19
+ res.once('drain', () => {
20
+ res.__ssePaused = false;
21
+ res.__sseBufferedBytes = 0;
22
+ res.__sseDrainAttached = false;
23
+ res.__ssePausedHeartbeatCycles = 0;
24
+ });
25
+ };
26
+
27
+ // Intentional resource protection for slow/zombie SSE clients.
28
+ // SSE is best-effort; authoritative data is fetched over HTTP.
29
+ const destroySseClientForBackpressure = (res) => {
30
+ try {
31
+ if (!res.destroyed) {
32
+ res.destroy();
33
+ }
34
+ } catch {
35
+ // ignore — cleanup must stay idempotent
36
+ }
37
+ };
38
+
1
39
  export const createNotificationEmitterRuntime = (dependencies) => {
2
40
  const {
3
41
  process,
@@ -23,7 +61,46 @@ export const createNotificationEmitterRuntime = (dependencies) => {
23
61
  };
24
62
 
25
63
  const writeSseEvent = (res, payload) => {
26
- res.write(`data: ${JSON.stringify(payload)}\n\n`);
64
+ if (!res || isSseResponseClosed(res)) {
65
+ throw new Error('SSE response closed');
66
+ }
67
+
68
+ // Drop while backpressured — SSE is best-effort; authoritative data is HTTP pull.
69
+ if (res.__ssePaused) {
70
+ return false;
71
+ }
72
+
73
+ const data = `data: ${JSON.stringify(payload)}\n\n`;
74
+ const byteLength = Buffer.byteLength(data);
75
+
76
+ let ok;
77
+ try {
78
+ ok = res.write(data);
79
+ } catch (error) {
80
+ destroySseClientForBackpressure(res);
81
+ throw error;
82
+ }
83
+
84
+ const bufferedBytes = ok === false
85
+ ? Math.max(getSseBufferedBytes(res), (res.__sseBufferedBytes || 0) + byteLength)
86
+ : getSseBufferedBytes(res);
87
+ res.__sseBufferedBytes = bufferedBytes;
88
+
89
+ if (bufferedBytes > SSE_CLIENT_MAX_BUFFERED_BYTES) {
90
+ // Intentional resource protection: a slow client must not unbounded-buffer
91
+ // response body in host memory. SSE is best-effort; authoritative data is
92
+ // fetched over HTTP.
93
+ destroySseClientForBackpressure(res);
94
+ throw new Error('SSE client buffer exceeded');
95
+ }
96
+
97
+ if (ok === false) {
98
+ res.__ssePaused = true;
99
+ attachSseDrainListener(res);
100
+ return false;
101
+ }
102
+
103
+ return true;
27
104
  };
28
105
 
29
106
  const emitDesktopNotification = (payload) => {
@@ -1,6 +1,9 @@
1
1
  import { describe, expect, it, vi } from 'vitest';
2
2
 
3
- import { createNotificationEmitterRuntime } from './emitter-runtime.js';
3
+ import {
4
+ createNotificationEmitterRuntime,
5
+ SSE_CLIENT_MAX_BUFFERED_BYTES,
6
+ } from './emitter-runtime.js';
4
7
 
5
8
  const createRuntime = (overrides = {}) => createNotificationEmitterRuntime({
6
9
  process: { stdout: { write: vi.fn() } },
@@ -11,6 +14,59 @@ const createRuntime = (overrides = {}) => createNotificationEmitterRuntime({
11
14
  ...overrides,
12
15
  });
13
16
 
17
+ const createMockSseResponse = ({ writeImpl } = {}) => {
18
+ const listeners = new Map();
19
+ let destroyed = false;
20
+ let writableEnded = false;
21
+ let bufferedBytes = 0;
22
+
23
+ const res = {
24
+ get destroyed() {
25
+ return destroyed;
26
+ },
27
+ get writableEnded() {
28
+ return writableEnded;
29
+ },
30
+ get writableLength() {
31
+ return bufferedBytes;
32
+ },
33
+ on(event, handler) {
34
+ listeners.set(event, handler);
35
+ return this;
36
+ },
37
+ once(event, handler) {
38
+ listeners.set(event, handler);
39
+ return this;
40
+ },
41
+ emit(event) {
42
+ const handler = listeners.get(event);
43
+ listeners.delete(event);
44
+ if (typeof handler === 'function') {
45
+ handler();
46
+ }
47
+ },
48
+ write(chunk) {
49
+ if (typeof writeImpl === 'function') {
50
+ return writeImpl(chunk, {
51
+ addBuffered(bytes) {
52
+ bufferedBytes += bytes;
53
+ },
54
+ getBuffered() {
55
+ return bufferedBytes;
56
+ },
57
+ });
58
+ }
59
+ return true;
60
+ },
61
+ destroy() {
62
+ destroyed = true;
63
+ this.emit('error');
64
+ },
65
+ };
66
+
67
+ return res;
68
+ };
69
+
14
70
  describe('notification emitter runtime', () => {
15
71
  it('reports desktop delivery through the injected native callback', () => {
16
72
  const onDesktopNotification = vi.fn();
@@ -44,4 +100,41 @@ describe('notification emitter runtime', () => {
44
100
  },
45
101
  });
46
102
  });
103
+
104
+ it('pauses slow SSE clients when write returns false and skips further buffering until drain', () => {
105
+ const runtime = createRuntime();
106
+ let writeCount = 0;
107
+ const res = createMockSseResponse({
108
+ writeImpl(chunk, { addBuffered }) {
109
+ writeCount += 1;
110
+ addBuffered(Buffer.byteLength(String(chunk)));
111
+ return false;
112
+ },
113
+ });
114
+
115
+ expect(runtime.writeSseEvent(res, { type: 'a' })).toBe(false);
116
+ expect(res.__ssePaused).toBe(true);
117
+ expect(writeCount).toBe(1);
118
+
119
+ expect(runtime.writeSseEvent(res, { type: 'b' })).toBe(false);
120
+ expect(writeCount).toBe(1);
121
+
122
+ res.emit('drain');
123
+ expect(res.__ssePaused).toBe(false);
124
+ expect(runtime.writeSseEvent(res, { type: 'c' })).toBe(false);
125
+ expect(writeCount).toBe(2);
126
+ });
127
+
128
+ it('destroys an SSE client whose buffered bytes exceed the per-client cap', () => {
129
+ const runtime = createRuntime();
130
+ const res = createMockSseResponse({
131
+ writeImpl(chunk, { addBuffered }) {
132
+ addBuffered(SSE_CLIENT_MAX_BUFFERED_BYTES + Buffer.byteLength(String(chunk)));
133
+ return false;
134
+ },
135
+ });
136
+
137
+ expect(() => runtime.writeSseEvent(res, { type: 'overflow' })).toThrow(/buffer exceeded/);
138
+ expect(res.destroyed).toBe(true);
139
+ });
47
140
  });
@@ -31,7 +31,10 @@ Server-owned scheduled task runtime and routes for OpenChamber-only automation.
31
31
  - Global run history list endpoint
32
32
  - Project scheduled task CRUD endpoints
33
33
  - Manual run endpoint
34
- - OpenChamber events SSE stream endpoint
34
+ - OpenChamber events SSE stream endpoint (`GET /api/openchamber/events`): 25s
35
+ heartbeat interval unchanged; half-open clients that stay paused across two
36
+ consecutive heartbeat cycles are destroyed and removed from the client set
37
+ (idempotent cleanup). SSE is best-effort; authoritative data is HTTP pull.
35
38
  - Returns persisted mutation results with `schedulerSynced`; a failed scheduler
36
39
  sync schedules one bounded retry while preserving the committed response
37
40
 
@@ -321,6 +321,33 @@ export const registerScheduledTaskRoutes = (app, dependencies) => {
321
321
  const clients = getOpenChamberEventClients();
322
322
  clients.add(res);
323
323
 
324
+ let closed = false;
325
+ let heartbeatTimer = null;
326
+ // Half-open / stalled-drain eviction: destroy after this many consecutive
327
+ // heartbeat cycles while the socket remains paused (no drain). Interval
328
+ // itself is unchanged — only failure cleanup was added.
329
+ // SSE is best-effort; authoritative data is fetched over HTTP.
330
+ const maxPausedHeartbeatCycles = 2;
331
+
332
+ const cleanup = () => {
333
+ if (closed) {
334
+ return;
335
+ }
336
+ closed = true;
337
+ if (heartbeatTimer) {
338
+ clearInterval(heartbeatTimer);
339
+ heartbeatTimer = null;
340
+ }
341
+ clients.delete(res);
342
+ try {
343
+ if (!res.destroyed && !res.writableEnded) {
344
+ res.destroy();
345
+ }
346
+ } catch {
347
+ // ignore — destroy + delete must stay idempotent
348
+ }
349
+ };
350
+
324
351
  try {
325
352
  writeSseEvent(res, {
326
353
  type: 'openchamber:event-stream-ready',
@@ -329,25 +356,41 @@ export const registerScheduledTaskRoutes = (app, dependencies) => {
329
356
  },
330
357
  });
331
358
  } catch {
359
+ cleanup();
360
+ return;
332
361
  }
333
362
 
334
- const heartbeat = setInterval(() => {
363
+ heartbeatTimer = setInterval(() => {
364
+ if (closed || res.writableEnded || res.destroyed) {
365
+ cleanup();
366
+ return;
367
+ }
368
+
335
369
  try {
336
- writeSseEvent(res, {
370
+ const ok = writeSseEvent(res, {
337
371
  type: 'openchamber:heartbeat',
338
372
  properties: {
339
373
  timestamp: Date.now(),
340
374
  },
341
375
  });
376
+ if (ok === false || res.__ssePaused) {
377
+ const cycles = (res.__ssePausedHeartbeatCycles || 0) + 1;
378
+ res.__ssePausedHeartbeatCycles = cycles;
379
+ if (cycles >= maxPausedHeartbeatCycles) {
380
+ // Intentional half-open cleanup: TCP may still look open while the
381
+ // relay tunnel is dead and drain never fires. SSE is best-effort;
382
+ // authoritative data is fetched over HTTP.
383
+ cleanup();
384
+ }
385
+ return;
386
+ }
387
+ res.__ssePausedHeartbeatCycles = 0;
342
388
  } catch {
343
- clearInterval(heartbeat);
344
- clients.delete(res);
389
+ cleanup();
345
390
  }
346
391
  }, 25_000);
347
392
 
348
- req.on('close', () => {
349
- clearInterval(heartbeat);
350
- clients.delete(res);
351
- });
393
+ req.on('close', cleanup);
394
+ res.on('error', cleanup);
352
395
  });
353
396
  };
@@ -20,13 +20,19 @@ the index excludes them from every snapshot and clears prior summaries when a
20
20
  `metadata.openchamber.smallModel.purpose`. Title prefixes are human labels and
21
21
  never participate in this filter. Metadata is the ownership/isolation signal;
22
22
  `time.archived` is archive state; `time.pinned` is OpenChamber-owned pin state
23
- (persisted as `pinned_at`, rescued across directory rebuilds, never overwritten
24
- by live OpenCode upserts); titles are for recognition. The index does
23
+ overlaid from the independent `session_pin` table (also mirrored onto in-window
24
+ `session_summary.pinned_at` for older readers). Pins are not subject to the
25
+ newest-20 summary bound: evicting or rebuilding a directory keeps pin
26
+ membership, and `setPinned` can target a session that is not currently in the
27
+ index. Archive or `remove` still clears the pin. Live OpenCode upserts never
28
+ overwrite pin membership. Titles are for recognition. The index does
25
29
  not cache system sessions, so cold-start and live upserts stay aligned with
26
30
  ordinary sidebar lists.
27
31
  Pin and unpin use `POST` / `DELETE`
28
- `/api/openchamber/session-index/session/:id/pin`, update `pinned_at`, then
32
+ `/api/openchamber/session-index/session/:id/pin`, write `session_pin`, then
29
33
  `publishChange()` so revision tips broadcast `openchamber:session-index-changed`.
34
+ Snapshots include `pinnedSessionIds` plus `time.pinned` on any matching
35
+ summary row.
30
36
 
31
37
  The server-side global OpenCode event subscriber writes session summary events
32
38
  directly into this index. User `message.updated` events and `session.idle`