@pi-chamber/web 1.0.0 → 1.0.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 (69) hide show
  1. package/README.md +3 -1
  2. package/bin/cli.js +7 -32
  3. package/bin/dev-server.js +185 -0
  4. package/bin/dev-server.test.js +252 -0
  5. package/bin/lib/DOCUMENTATION.md +19 -0
  6. package/bin/lib/cli-startup.js +9 -1
  7. package/bin/lib/cli-startup.test.js +30 -0
  8. package/bin/lib/commands-serve.js +9 -5
  9. package/bin/lib/server-runtime.js +6 -0
  10. package/bin/lib/server-runtime.test.js +313 -0
  11. package/dist/assets/{DiagramView-CbSxUe1D.js → DiagramView-COHSzZ9Z.js} +1 -1
  12. package/dist/assets/{DiffView-VyBf4ilo.js → DiffView-BA4LWExp.js} +1 -1
  13. package/dist/assets/{FileSaveConflictDialog-BCvbQ234.js → FileSaveConflictDialog-hRumcJ2e.js} +1 -1
  14. package/dist/assets/{FilesView-DasA5EU2.js → FilesView-CIx6Bq8l.js} +1 -1
  15. package/dist/assets/{GitView-DU3mOECp.js → GitView-3Hgk_pVS.js} +3 -3
  16. package/dist/assets/{JsonTreeView-xZiWDwua.js → JsonTreeView-CVLGj7jk.js} +1 -1
  17. package/dist/assets/{MarkdownRendererImpl-BBwdI2OF.js → MarkdownRendererImpl-CWeQW9_O.js} +1 -1
  18. package/dist/assets/{PatchDiff-BhKm_JPT.js → PatchDiff-367QPDDL.js} +1 -1
  19. package/dist/assets/{SessionSwitcherContent-DTGSP_RB.js → SessionSwitcherContent-CbgywSHr.js} +1 -1
  20. package/dist/assets/{SessionSwitcherDropdown-CedOB-xC.js → SessionSwitcherDropdown-BAHhqkBZ.js} +2 -2
  21. package/dist/assets/{SessionUnreadDot-CZSNKram.js → SessionUnreadDot-CvIWGgIi.js} +1 -1
  22. package/dist/assets/SettingsView-BpGtnBKt.js +2 -0
  23. package/dist/assets/{SettingsWindow-y33YrpBE.js → SettingsWindow-CN0wm-Fv.js} +1 -1
  24. package/dist/assets/{ToolOutputDialog-JqIXJWAH.js → ToolOutputDialog-Bkh0DWJn.js} +1 -1
  25. package/dist/assets/{ToolPartDiffPreview-CRi_33jE.js → ToolPartDiffPreview-C_V9k2ob.js} +1 -1
  26. package/dist/assets/{VirtualizedFileDiff-ehLQSR5W.js → VirtualizedFileDiff-CFToyUp4.js} +1 -1
  27. package/dist/assets/{collapsible-Vypq-nMP.js → collapsible-BXBoS1M4.js} +1 -1
  28. package/dist/assets/{computeVirtualFileMetrics-BTfrj_fR.js → computeVirtualFileMetrics-BpbB2xiE.js} +1 -1
  29. package/dist/assets/{contextFileOpenGuard-Dl6mFfD1.js → contextFileOpenGuard-DsdrIBIY.js} +1 -1
  30. package/dist/assets/{gitStatusPredicates-LAsJAhCL.js → gitStatusPredicates-KYx0Vs9h.js} +1 -1
  31. package/dist/assets/{index-OveFsNBm.js → index-CVZfC79h.js} +1 -1
  32. package/dist/assets/{index-BXX8l7mM.css → index-Ci9OMaKW.css} +1 -1
  33. package/dist/assets/{index-DvNeSFO9.js → index-DyeT2dc_.js} +7 -7
  34. package/dist/assets/{isDiffPlainText-CNZohQ4q.js → isDiffPlainText-dBQiDlRy.js} +1 -1
  35. package/dist/assets/{isFilePlainText-Dz8UubRT.js → isFilePlainText-DWMzO-Ms.js} +1 -1
  36. package/dist/assets/{main-BsDkATRV.js → main-DkXvFwTR.js} +3 -3
  37. package/dist/assets/{main-C393Ywhx.js → main-DukaBOy3.js} +2 -2
  38. package/dist/assets/{markdownCore-Bz9-Y75q.js → markdownCore-BH61OrJ2.js} +1 -1
  39. package/dist/assets/{miniChat-CWEerp3c.js → miniChat-B1uBoxSn.js} +2 -2
  40. package/dist/assets/{mobile-YxV9KcxF.js → mobile-DV_RYy3x.js} +2 -2
  41. package/dist/assets/{renderElectronMiniChatApp-GrLmBQRb.js → renderElectronMiniChatApp-CA6co_Lh.js} +2 -2
  42. package/dist/assets/renderMobileApp-CyhFZ_4g.js +11 -0
  43. package/dist/assets/runtimeEndpointReset-CVoKFaRw.js +53 -0
  44. package/dist/assets/{runtimeSurface-DUXw4-oa.js → runtimeSurface-CxbVCK7k.js} +1 -1
  45. package/dist/assets/{useAppFontEffects-ad-lZJ6o.js → useAppFontEffects-HCEusnq7.js} +77 -77
  46. package/dist/assets/{useFilesViewSearch-C4oOHPml.js → useFilesViewSearch-Cq7IOB7l.js} +1 -1
  47. package/dist/assets/{usePushVisibilityBeacon-xd8Q10cI.js → usePushVisibilityBeacon-Tvi9uL7v.js} +1 -1
  48. package/dist/assets/{useSwitcherItems-B6VC7tug.js → useSwitcherItems-DLA7kskG.js} +1 -1
  49. package/dist/assets/{vendor-codemirror-language-data-B4j3gkaT.js → vendor-codemirror-language-data-zF3O85ti.js} +2 -2
  50. package/dist/assets/{web-components-B0RFakat.js → web-components-C7g3Hi85.js} +1 -1
  51. package/dist/index.html +4 -4
  52. package/dist/mini-chat.html +3 -3
  53. package/dist/mobile.html +3 -3
  54. package/package.json +8 -3
  55. package/server/index.js +40 -6
  56. package/server/lib/notifications/DOCUMENTATION.md +39 -0
  57. package/server/lib/notifications/delivery-runtime.js +314 -0
  58. package/server/lib/notifications/delivery-runtime.test.js +85 -0
  59. package/server/lib/notifications/pi-notification-watcher.js +154 -0
  60. package/server/lib/notifications/pi-notification-watcher.test.js +84 -0
  61. package/server/lib/notifications/routes.js +74 -0
  62. package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -0
  63. package/server/lib/pi/session-daemon/pi-runtime-smoke.test.js +466 -0
  64. package/server/lib/pi/ui-settings-store.js +3 -2
  65. package/server/lib/server/runtime-requirements.js +193 -0
  66. package/server/lib/server/runtime-requirements.test.js +295 -0
  67. package/dist/assets/SettingsView-B5nmu8x4.js +0 -2
  68. package/dist/assets/renderMobileApp-C29wquBe.js +0 -11
  69. package/dist/assets/runtimeEndpointReset-DHARMv9w.js +0 -53
@@ -0,0 +1,295 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import {
4
+ NO_SUPPORTED_RUNTIME_MESSAGE,
5
+ assertCurrentRuntimeSupported,
6
+ getBunBinary,
7
+ isSupportedBunVersion,
8
+ isSupportedNodeVersion,
9
+ resolveServerExecutable,
10
+ } from './runtime-requirements.js';
11
+
12
+ function fakeSpawnSync({ nodeVersion = null, nodeStatus = 0, bunVersion = '1.4.2', bunStatus = 0 } = {}) {
13
+ return (bin, _args, _options) => {
14
+ const normalized = String(bin);
15
+ if (normalized === 'node' || normalized.endsWith('/node') || normalized === '/mock/node') {
16
+ if (nodeVersion === null || nodeStatus !== 0) return { status: 1, stdout: '' };
17
+ return { status: 0, stdout: `${nodeVersion}\n` };
18
+ }
19
+ if (normalized.includes('bun')) {
20
+ if (bunStatus !== 0 || bunVersion === null) return { status: 1, stdout: '' };
21
+ return { status: 0, stdout: `${bunVersion}\n` };
22
+ }
23
+ return { status: 1, stdout: '' };
24
+ };
25
+ }
26
+
27
+ describe('stable version validation', () => {
28
+ it('enforces stable Node >= 22.19.0', () => {
29
+ expect(isSupportedNodeVersion('v22.19.0')).toBe(true);
30
+ expect(isSupportedNodeVersion('22.19.0')).toBe(true);
31
+ expect(isSupportedNodeVersion('v22.19.1')).toBe(true);
32
+ expect(isSupportedNodeVersion('v24.14.1')).toBe(true);
33
+ expect(isSupportedNodeVersion('v22.18.9')).toBe(false);
34
+ expect(isSupportedNodeVersion('v22.14.0')).toBe(false);
35
+ expect(isSupportedNodeVersion('v20.19.0')).toBe(false);
36
+ });
37
+
38
+ it('enforces stable Bun >= 1.4.0', () => {
39
+ expect(isSupportedBunVersion('1.4.0')).toBe(true);
40
+ expect(isSupportedBunVersion('1.4.2')).toBe(true);
41
+ expect(isSupportedBunVersion('2.0.0')).toBe(true);
42
+ expect(isSupportedBunVersion('1.3.14')).toBe(false);
43
+ });
44
+
45
+ it('rejects malformed, prerelease, and build metadata', () => {
46
+ for (const malformed of [
47
+ '',
48
+ ' ',
49
+ 'v22',
50
+ '22.19',
51
+ 'latest',
52
+ 'not-a-version',
53
+ 'v22.19.0-rc.1',
54
+ '1.4.2-canary',
55
+ 'v22.19.0+build',
56
+ '1.4.2+meta',
57
+ ]) {
58
+ expect(isSupportedNodeVersion(malformed)).toBe(false);
59
+ expect(isSupportedBunVersion(malformed)).toBe(false);
60
+ }
61
+ for (const nonString of [null, undefined, 42, {}, []]) {
62
+ expect(isSupportedNodeVersion(nonString)).toBe(false);
63
+ expect(isSupportedBunVersion(nonString)).toBe(false);
64
+ }
65
+ });
66
+ });
67
+
68
+ describe('Bun binary resolution', () => {
69
+ it('resolves BUN_BINARY and BUN_INSTALL with precedence', () => {
70
+ expect(getBunBinary({ BUN_BINARY: '/custom/bun' })).toBe('/custom/bun');
71
+ expect(getBunBinary({ BUN_INSTALL: '/home/user/.bun' })).toBe('/home/user/.bun/bin/bun');
72
+ expect(getBunBinary({ BUN_BINARY: '/custom/bun', BUN_INSTALL: '/home/user/.bun' })).toBe('/custom/bun');
73
+ expect(getBunBinary({})).toBe('bun');
74
+ });
75
+ });
76
+
77
+ describe('Node-first automatic resolution', () => {
78
+ it('prefers the current Node executable without probing PATH', () => {
79
+ const spawnSyncFn = () => {
80
+ throw new Error('should not probe when current Node is supported');
81
+ };
82
+ expect(resolveServerExecutable({
83
+ isBun: false,
84
+ nodeVersion: 'v24.14.1',
85
+ execPath: '/usr/bin/node',
86
+ spawnSyncFn,
87
+ env: {},
88
+ })).toEqual({ runtime: 'node', executable: '/usr/bin/node' });
89
+ });
90
+
91
+ it('prefers PATH Node when running under Bun', () => {
92
+ const spawnSyncFn = fakeSpawnSync({ nodeVersion: 'v24.14.1', bunVersion: '1.4.2' });
93
+ expect(resolveServerExecutable({
94
+ isBun: true,
95
+ nodeVersion: 'v26.3.0',
96
+ bunVersion: '1.4.2',
97
+ execPath: '/mock/bun',
98
+ bunBin: '/mock/bun',
99
+ spawnSyncFn,
100
+ env: {},
101
+ })).toEqual({ runtime: 'node', executable: 'node' });
102
+ });
103
+
104
+ it('falls back to the current Bun executable with no runtimes on PATH', () => {
105
+ const spawnSyncFn = () => ({ status: 1, stdout: '' });
106
+ expect(resolveServerExecutable({
107
+ isBun: true,
108
+ nodeVersion: 'v26.3.0',
109
+ bunVersion: '1.4.2',
110
+ execPath: '/mock/current-bun',
111
+ spawnSyncFn,
112
+ env: {},
113
+ })).toEqual({ runtime: 'bun', executable: '/mock/current-bun' });
114
+ });
115
+
116
+ it('falls back to PATH Bun when not running under Bun', () => {
117
+ const spawnSyncFn = fakeSpawnSync({ nodeVersion: null, bunVersion: '1.4.2' });
118
+ expect(resolveServerExecutable({
119
+ isBun: false,
120
+ nodeVersion: 'v20.19.0',
121
+ execPath: '/usr/bin/node',
122
+ bunBin: '/mock/bun',
123
+ spawnSyncFn,
124
+ env: {},
125
+ })).toEqual({ runtime: 'bun', executable: '/mock/bun' });
126
+ });
127
+
128
+ it('fails deterministically when neither runtime is usable', () => {
129
+ const spawnSyncFn = fakeSpawnSync({ nodeVersion: null, bunStatus: 1, bunVersion: null });
130
+ expect(() => resolveServerExecutable({
131
+ isBun: false,
132
+ nodeVersion: 'v20.19.0',
133
+ execPath: '/usr/bin/node',
134
+ bunBin: '/mock/bun',
135
+ spawnSyncFn,
136
+ env: {},
137
+ })).toThrow(NO_SUPPORTED_RUNTIME_MESSAGE);
138
+ });
139
+
140
+ it('rejects old probe output during resolution', () => {
141
+ const spawnSyncFn = fakeSpawnSync({ nodeVersion: 'v20.19.0', bunVersion: null, bunStatus: 1 });
142
+ expect(() => resolveServerExecutable({
143
+ isBun: false,
144
+ nodeVersion: 'v20.19.0',
145
+ execPath: '/usr/bin/node',
146
+ spawnSyncFn,
147
+ env: {},
148
+ })).toThrow(NO_SUPPORTED_RUNTIME_MESSAGE);
149
+ });
150
+
151
+ it('bounds Node probe errors to Bun fallback', () => {
152
+ const spawnSyncFn = (bin) => {
153
+ if (String(bin).includes('bun')) return { status: 0, stdout: '1.4.2\n' };
154
+ throw new Error('spawn ENOENT');
155
+ };
156
+ expect(resolveServerExecutable({
157
+ isBun: false,
158
+ nodeVersion: 'v20.19.0',
159
+ execPath: '/usr/bin/node',
160
+ bunBin: '/mock/bun',
161
+ spawnSyncFn,
162
+ env: {},
163
+ })).toEqual({ runtime: 'bun', executable: '/mock/bun' });
164
+ });
165
+ });
166
+
167
+ describe('explicit Bun overrides', () => {
168
+ it('fails instead of falling back when explicit BUN_BINARY is old', () => {
169
+ const spawnSyncFn = fakeSpawnSync({ nodeVersion: null, bunVersion: '1.3.14' });
170
+ expect(() => resolveServerExecutable({
171
+ isBun: true,
172
+ nodeVersion: 'v26.3.0',
173
+ bunVersion: '1.4.2',
174
+ execPath: '/mock/current-bun',
175
+ bunBin: '/mock/old-bun',
176
+ spawnSyncFn,
177
+ env: { BUN_BINARY: '/mock/old-bun' },
178
+ })).toThrow(NO_SUPPORTED_RUNTIME_MESSAGE);
179
+ });
180
+
181
+ it('honors a supported explicit BUN_BINARY', () => {
182
+ const spawnSyncFn = fakeSpawnSync({ nodeVersion: null, bunVersion: '1.4.2' });
183
+ expect(resolveServerExecutable({
184
+ isBun: false,
185
+ nodeVersion: 'v20.19.0',
186
+ execPath: '/usr/bin/node',
187
+ bunBin: '/mock/new-bun',
188
+ spawnSyncFn,
189
+ env: { BUN_BINARY: '/mock/new-bun' },
190
+ })).toEqual({ runtime: 'bun', executable: '/mock/new-bun' });
191
+ });
192
+ });
193
+
194
+ describe('old Bun emulating new Node', () => {
195
+ it('rejects old Bun even though emulated Node looks new', () => {
196
+ expect(() => assertCurrentRuntimeSupported({
197
+ isBun: true,
198
+ nodeVersion: 'v26.3.0',
199
+ bunVersion: '1.3.14',
200
+ execPath: '/mock/bun',
201
+ })).toThrow(/Bun 1\.3\.14/);
202
+ });
203
+
204
+ it('never reuses the current executable as Node when running under Bun', () => {
205
+ const spawnSyncFn = fakeSpawnSync({ nodeVersion: 'v24.14.1', bunVersion: '1.4.2' });
206
+ expect(resolveServerExecutable({
207
+ isBun: true,
208
+ nodeVersion: 'v26.3.0',
209
+ bunVersion: '1.3.14',
210
+ execPath: '/mock/bun-old',
211
+ bunBin: '/mock/bun',
212
+ spawnSyncFn,
213
+ env: {},
214
+ })).toEqual({ runtime: 'node', executable: 'node' });
215
+ });
216
+ });
217
+
218
+ describe('resolver probe timeout', () => {
219
+ it('passes a bounded timeout to spawnSync', () => {
220
+ const calls = [];
221
+ const spawnSyncFn = (bin, args, options) => {
222
+ calls.push(options);
223
+ return fakeSpawnSync({ nodeVersion: null, bunVersion: '1.4.2' })(bin, args, options);
224
+ };
225
+ resolveServerExecutable({
226
+ isBun: false,
227
+ nodeVersion: 'v20.19.0',
228
+ execPath: '/usr/bin/node',
229
+ bunBin: '/mock/bun',
230
+ spawnSyncFn,
231
+ env: {},
232
+ });
233
+ expect(calls.length).toBeGreaterThan(0);
234
+ for (const options of calls) {
235
+ expect(Number.isFinite(options.timeout)).toBe(true);
236
+ expect(options.timeout).toBeGreaterThan(0);
237
+ expect(options.windowsHide).toBe(true);
238
+ }
239
+ });
240
+
241
+ it('honors an explicit probe timeout', () => {
242
+ const calls = [];
243
+ const spawnSyncFn = (bin, args, options) => {
244
+ calls.push(options);
245
+ return { status: 1, stdout: '' };
246
+ };
247
+ expect(() => resolveServerExecutable({
248
+ isBun: false,
249
+ nodeVersion: 'v20.19.0',
250
+ execPath: '/usr/bin/node',
251
+ bunBin: '/mock/bun',
252
+ spawnSyncFn,
253
+ env: {},
254
+ probeTimeoutMs: 1234,
255
+ })).toThrow(NO_SUPPORTED_RUNTIME_MESSAGE);
256
+ expect(calls.length).toBeGreaterThan(0);
257
+ for (const options of calls) {
258
+ expect(options.timeout).toBe(1234);
259
+ }
260
+ });
261
+ });
262
+
263
+ describe('current runtime validation without PATH probing', () => {
264
+ it('validates supported Node and Bun executables', () => {
265
+ expect(assertCurrentRuntimeSupported({
266
+ isBun: false,
267
+ nodeVersion: 'v24.14.1',
268
+ execPath: '/usr/bin/node',
269
+ })).toEqual({ runtime: 'node', executable: '/usr/bin/node' });
270
+ expect(assertCurrentRuntimeSupported({
271
+ isBun: true,
272
+ nodeVersion: 'v26.3.0',
273
+ bunVersion: '1.4.2',
274
+ execPath: '/mock/bun',
275
+ })).toEqual({ runtime: 'bun', executable: '/mock/bun' });
276
+ });
277
+
278
+ it('rejects old, malformed, and prerelease current runtimes', () => {
279
+ expect(() => assertCurrentRuntimeSupported({
280
+ isBun: false, nodeVersion: 'v20.19.0', execPath: '/usr/bin/node',
281
+ })).toThrow(/Node\.js v20\.19\.0/);
282
+ expect(() => assertCurrentRuntimeSupported({
283
+ isBun: false, nodeVersion: 'not-a-version', execPath: '/usr/bin/node',
284
+ })).toThrow(/Unsupported server runtime/);
285
+ expect(() => assertCurrentRuntimeSupported({
286
+ isBun: false, nodeVersion: 'v22.19.0-rc.1', execPath: '/usr/bin/node',
287
+ })).toThrow(/Unsupported server runtime/);
288
+ expect(() => assertCurrentRuntimeSupported({
289
+ isBun: true, nodeVersion: 'v26.3.0', bunVersion: 'bad', execPath: '/mock/bun',
290
+ })).toThrow(/Unsupported server runtime/);
291
+ expect(() => assertCurrentRuntimeSupported({
292
+ isBun: false, nodeVersion: 'v24.14.1', execPath: ' ',
293
+ })).toThrow(/missing runtime executable/);
294
+ });
295
+ });