@openchamber/web 1.15.0 → 1.16.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 (102) hide show
  1. package/README.md +5 -5
  2. package/dist/assets/{DiagramView-HR2xZxJ8.js → DiagramView-Elkp8b4l.js} +1 -1
  3. package/dist/assets/{MarkdownRendererImpl-sm01Q7R7.js → MarkdownRendererImpl-DLhrL6oX.js} +3 -3
  4. package/dist/assets/{MultiRunWindow-DlFUaNQK.js → MultiRunWindow-DVpNCqnE.js} +1 -1
  5. package/dist/assets/{OnboardingScreen-DVRz82mJ.js → OnboardingScreen-CpcR0gyq.js} +1 -1
  6. package/dist/assets/SessionSwitcherDropdown-DHO5Je6v.js +1 -0
  7. package/dist/assets/{SettingsWindow-CkInZcj7.js → SettingsWindow-Bewo7vwh.js} +1 -1
  8. package/dist/assets/{TerminalView-D_9BAjtv.js → TerminalView-D9C7fNLm.js} +3 -3
  9. package/dist/assets/es-D9nOo8Wx.js +15 -0
  10. package/dist/assets/fr-DEF71lgt.js +13 -0
  11. package/dist/assets/index-BklNmnVr.js +2 -0
  12. package/dist/assets/index-C3uMIExE.css +1 -0
  13. package/dist/assets/ja-CpNfaEje.js +15 -0
  14. package/dist/assets/ko-DLS_rnE-.js +15 -0
  15. package/dist/assets/main-B0CxEOP5.js +237 -0
  16. package/dist/assets/{main-DzNa8r0N.js → main-Ck3ZNw8-.js} +2 -2
  17. package/dist/assets/miniChat-BAJj2Ome.js +2 -0
  18. package/dist/assets/mobile-CJoX4Cdj.js +2 -0
  19. package/dist/assets/pl-BjtFn5-n.js +15 -0
  20. package/dist/assets/pt-BR-C0_4Rnzn.js +15 -0
  21. package/dist/assets/renderElectronMiniChatApp-D4-OXCXM.js +2 -0
  22. package/dist/assets/renderMobileApp-DHWdI195.js +16 -0
  23. package/dist/assets/runtimeEndpointReset-B0P2DED1.js +167 -0
  24. package/dist/assets/uk-BDu4E0s0.js +15 -0
  25. package/dist/assets/{useAppFontEffects-DzBg8hrC.js → useAppFontEffects-9LFMCKYW.js} +195 -136
  26. package/dist/assets/zh-CN-BcwMqxIR.js +15 -0
  27. package/dist/assets/zh-TW-bNDQjKEu.js +15 -0
  28. package/dist/index.html +3 -3
  29. package/dist/mini-chat.html +3 -3
  30. package/dist/mobile.html +3 -3
  31. package/package.json +1 -1
  32. package/server/index.js +106 -1
  33. package/server/lib/notifications/DOCUMENTATION.md +1 -1
  34. package/server/lib/notifications/apns-runtime.js +3 -1
  35. package/server/lib/notifications/runtime.js +135 -33
  36. package/server/lib/opencode/DOCUMENTATION.md +1 -0
  37. package/server/lib/opencode/agents.js +3 -0
  38. package/server/lib/opencode/bootstrap-runtime.js +5 -0
  39. package/server/lib/opencode/core-routes.js +75 -2
  40. package/server/lib/opencode/core-routes.test.js +81 -0
  41. package/server/lib/opencode/feature-routes-runtime.js +6 -0
  42. package/server/lib/opencode/settings-helpers.js +30 -0
  43. package/server/lib/opencode/settings-helpers.test.js +14 -0
  44. package/server/lib/opencode/settings-normalization-runtime.js +19 -4
  45. package/server/lib/opencode/settings-normalization-runtime.test.js +21 -0
  46. package/server/lib/opencode/settings-runtime.js +25 -0
  47. package/server/lib/opencode/shutdown-runtime.js +2 -0
  48. package/server/lib/opencode/tunnel-auth.js +4 -9
  49. package/server/lib/package-manager.js +1 -1
  50. package/server/lib/permission-auto-accept/DOCUMENTATION.md +34 -0
  51. package/server/lib/permission-auto-accept/runtime.js +263 -0
  52. package/server/lib/permission-auto-accept/runtime.test.js +137 -0
  53. package/server/lib/projects/project-config.js +8 -0
  54. package/server/lib/quota/DOCUMENTATION.md +5 -2
  55. package/server/lib/quota/credentials/providers.js +43 -0
  56. package/server/lib/quota/credentials/store.js +48 -0
  57. package/server/lib/quota/credentials/store.test.js +26 -0
  58. package/server/lib/quota/opencode-go-credentials.js +11 -0
  59. package/server/lib/quota/opencode-go-credentials.test.js +32 -0
  60. package/server/lib/quota/providers/codex.js +7 -4
  61. package/server/lib/quota/providers/codex.test.js +48 -0
  62. package/server/lib/quota/providers/cursor.js +28 -39
  63. package/server/lib/quota/providers/index.js +7 -0
  64. package/server/lib/quota/providers/ollama-cloud.js +23 -42
  65. package/server/lib/quota/providers/ollama-cloud.test.js +12 -0
  66. package/server/lib/quota/providers/opencode-go.js +70 -0
  67. package/server/lib/quota/providers/opencode-go.test.js +17 -0
  68. package/server/lib/quota/routes.js +78 -7
  69. package/server/lib/quota/routes.test.js +40 -0
  70. package/server/lib/relay/DOCUMENTATION.md +20 -0
  71. package/server/lib/relay/host-lock.js +101 -0
  72. package/server/lib/relay/host-lock.test.js +129 -0
  73. package/server/lib/relay/identity.js +24 -4
  74. package/server/lib/relay/service.js +95 -8
  75. package/server/lib/relay/signing-key.js +30 -7
  76. package/server/lib/scheduled-tasks/runtime.js +104 -0
  77. package/server/lib/session-goal/DOCUMENTATION.md +176 -0
  78. package/server/lib/session-goal/objectives.js +61 -0
  79. package/server/lib/session-goal/routes.js +36 -0
  80. package/server/lib/session-goal/runtime.js +764 -0
  81. package/server/lib/small-model/DOCUMENTATION.md +3 -1
  82. package/server/lib/small-model/call.js +45 -8
  83. package/server/lib/small-model/call.test.js +338 -0
  84. package/server/lib/small-model/index.js +1 -0
  85. package/dist/assets/SessionSwitcherDropdown-DvoOalMY.js +0 -1
  86. package/dist/assets/es-cjUissX4.js +0 -15
  87. package/dist/assets/fr-DqbXnTdK.js +0 -13
  88. package/dist/assets/index-Dg0nmvQU.css +0 -1
  89. package/dist/assets/index-ltrmNGAf.js +0 -2
  90. package/dist/assets/ja-Cetyq6Eg.js +0 -15
  91. package/dist/assets/ko-DtunWisP.js +0 -15
  92. package/dist/assets/main-BC0m8s1v.js +0 -236
  93. package/dist/assets/miniChat-BRYDE-Se.js +0 -2
  94. package/dist/assets/mobile-C3QJVA97.js +0 -2
  95. package/dist/assets/pl-DctGLgve.js +0 -15
  96. package/dist/assets/pt-BR-CXPhf78S.js +0 -15
  97. package/dist/assets/renderElectronMiniChatApp-CVFbDC5A.js +0 -2
  98. package/dist/assets/renderMobileApp-wkBjh5WR.js +0 -16
  99. package/dist/assets/runtimeEndpointReset-C42u8PvG.js +0 -167
  100. package/dist/assets/uk-Bdrc-kqF.js +0 -15
  101. package/dist/assets/zh-CN-CeCVKrHP.js +0 -15
  102. package/dist/assets/zh-TW-CoqiQING.js +0 -15
@@ -67,10 +67,29 @@ export const registerServerStatusRoutes = (app, dependencies) => {
67
67
  serverStartedAt,
68
68
  gracefulShutdown,
69
69
  getHealthSnapshot,
70
+ // Stable server identity (hash of the public signing key — not a secret).
71
+ // Exposed on /health and /api/version so a client can verify that a
72
+ // learned/probed address belongs to the expected server BEFORE sending its
73
+ // bearer token there. Optional: older wiring omits it.
74
+ getServerId = async () => null,
70
75
  tunnelAuthController = null,
71
76
  uiAuthController = null,
72
77
  } = dependencies;
73
78
 
79
+ // The identity is immutable for the process lifetime; resolve once, and never
80
+ // let an identity failure break health reporting.
81
+ let cachedServerId = null;
82
+ const resolveServerId = async () => {
83
+ if (cachedServerId) return cachedServerId;
84
+ try {
85
+ const value = await getServerId();
86
+ cachedServerId = typeof value === 'string' && value.trim() ? value.trim() : null;
87
+ } catch {
88
+ cachedServerId = null;
89
+ }
90
+ return cachedServerId;
91
+ };
92
+
74
93
  const allocateLoopbackPort = async () => {
75
94
  const net = await import('node:net');
76
95
  return await new Promise((resolve, reject) => {
@@ -213,24 +232,28 @@ export const registerServerStatusRoutes = (app, dependencies) => {
213
232
  }
214
233
  };
215
234
 
216
- app.get('/health', (_req, res) => {
235
+ app.get('/health', async (_req, res) => {
236
+ const serverId = await resolveServerId();
217
237
  res.json({
218
238
  status: 'ok',
219
239
  timestamp: new Date().toISOString(),
220
240
  openchamberVersion,
221
241
  runtime: runtimeName,
222
242
  compatibility,
243
+ ...(serverId ? { serverId } : {}),
223
244
  ...getHealthSnapshot(),
224
245
  });
225
246
  });
226
247
 
227
- app.get('/api/version', (_req, res) => {
248
+ app.get('/api/version', async (_req, res) => {
249
+ const serverId = await resolveServerId();
228
250
  res.json({
229
251
  status: 'ok',
230
252
  openchamberVersion,
231
253
  runtime: runtimeName,
232
254
  startedAt: serverStartedAt,
233
255
  compatibility,
256
+ ...(serverId ? { serverId } : {}),
234
257
  });
235
258
  });
236
259
 
@@ -371,6 +394,12 @@ export const registerAuthAndAccessRoutes = (app, dependencies) => {
371
394
  // server can actually be reached on (LAN derived from the server bind, not
372
395
  // the UI origin), for the create-device dialog.
373
396
  getPairingTransports = () => ({ local: null, lan: null, relayAvailable: true }),
397
+ // Returns ALL direct LAN URLs the server is currently reachable on (client-
398
+ // reached address first, then interface scan) for the candidates-refresh
399
+ // endpoint. Empty when the server is loopback-only.
400
+ getDirectCandidateUrls = () => [],
401
+ // Stable server identity for client-side verification of learned addresses.
402
+ getServerId = async () => null,
374
403
  // Display name a paired device shows for THIS server (issuing machine's
375
404
  // hostname), distinct from the per-device pairing label typed by the operator.
376
405
  getServerLabel = () => 'OpenChamber',
@@ -796,6 +825,48 @@ export const registerAuthAndAccessRoutes = (app, dependencies) => {
796
825
  });
797
826
  });
798
827
 
828
+ // Current reachable transports for an ALREADY-PAIRED device. Pairing-payload
829
+ // candidates are a snapshot: when DHCP hands this machine a new address, the
830
+ // device's saved LAN candidate goes stale and it is stuck on the relay forever.
831
+ // A client that connected over any live transport calls this to learn the
832
+ // server's present LAN URLs (plus the relay candidate when enabled) and update
833
+ // its saved candidate set. `serverId` lets the client bind the response — and
834
+ // later /health probes of the learned addresses — to this server's identity
835
+ // before trusting them with its bearer token.
836
+ // Auth: UI session or client bearer; never the short-lived URL token.
837
+ app.get('/api/client-auth/connection/candidates', async (req, res, next) => {
838
+ await runWithClientManagementAuth(req, res, next, async () => {
839
+ const candidates = [];
840
+ const directUrls = (() => {
841
+ try {
842
+ const urls = getDirectCandidateUrls(req);
843
+ return Array.isArray(urls) ? urls : [];
844
+ } catch {
845
+ return [];
846
+ }
847
+ })();
848
+ for (const url of directUrls) {
849
+ const normalized = normalizeCandidateUrl(url);
850
+ if (normalized) candidates.push({ type: 'lan', url: normalized, priority: 10 });
851
+ }
852
+ try {
853
+ const relayCandidate = await getRelayPairingCandidate({ ensureEnabled: false });
854
+ if (relayCandidate) candidates.push(relayCandidate);
855
+ } catch {
856
+ // Relay status failure must not break the direct-candidate refresh.
857
+ }
858
+ let serverId = null;
859
+ try {
860
+ const value = await getServerId();
861
+ serverId = typeof value === 'string' && value.trim() ? value.trim() : null;
862
+ } catch {
863
+ serverId = null;
864
+ }
865
+ res.setHeader('Cache-Control', 'no-store');
866
+ res.json({ label: getServerLabel(), ...(serverId ? { serverId } : {}), candidates });
867
+ });
868
+ });
869
+
799
870
  // Direct transports the server can be reached on (for the create-device dialog).
800
871
  app.get('/api/client-auth/pairing/transports', async (req, res, next) => {
801
872
  await runWithClientCreateAuth(req, res, next, async () => {
@@ -998,8 +1069,10 @@ export const registerCommonRequestMiddleware = (app, dependencies) => {
998
1069
  req.path.startsWith('/api/opencode') ||
999
1070
  req.path.startsWith('/api/push') ||
1000
1071
  req.path.startsWith('/api/notifications') ||
1072
+ req.path.startsWith('/api/permission-auto-accept') ||
1001
1073
  req.path.startsWith('/api/session-folders') ||
1002
1074
  req.path.startsWith('/api/small-model') ||
1075
+ req.path.startsWith('/api/goals') ||
1003
1076
  req.path.startsWith('/api/text') ||
1004
1077
  req.path.startsWith('/api/voice') ||
1005
1078
  req.path.startsWith('/api/tts') ||
@@ -1,6 +1,7 @@
1
1
  import { describe, it, expect, vi, afterEach } from 'vitest';
2
2
  import express from 'express';
3
3
  import request from 'supertest';
4
+ import { createTunnelAuth } from './tunnel-auth.js';
4
5
  import { registerAuthAndAccessRoutes, registerCommonRequestMiddleware, registerServerStatusRoutes } from './core-routes.js';
5
6
 
6
7
  describe('core-routes', () => {
@@ -570,6 +571,56 @@ describe('client auth routes', () => {
570
571
  expect(listedAfterPurge.body.clients).toHaveLength(0);
571
572
  });
572
573
 
574
+ it('reports current connection candidates with server identity for paired devices', async () => {
575
+ const app = express();
576
+ const relayCandidate = {
577
+ type: 'relay',
578
+ relayUrl: 'wss://relay.example/ws',
579
+ serverId: 'server-abc',
580
+ hostEncPubJwk: { kty: 'EC', crv: 'P-256', x: 'x', y: 'y' },
581
+ priority: 30,
582
+ };
583
+ const dependencies = {
584
+ ...createDependencies({ resolveAuthContext: async () => ({ type: 'client', clientId: 'client-1' }) }),
585
+ getDirectCandidateUrls: () => ['http://192.168.1.20:3000', 'http://10.0.0.5:3000', 'not-a-url'],
586
+ getRelayPairingCandidate: async () => relayCandidate,
587
+ getServerId: async () => 'server-abc',
588
+ getServerLabel: () => 'my-host',
589
+ };
590
+ registerAuthAndAccessRoutes(app, dependencies);
591
+
592
+ const response = await request(app).get('/api/client-auth/connection/candidates');
593
+ expect(response.status).toBe(200);
594
+ expect(response.headers['cache-control']).toBe('no-store');
595
+ expect(response.body.serverId).toBe('server-abc');
596
+ expect(response.body.label).toBe('my-host');
597
+ expect(response.body.candidates).toEqual([
598
+ { type: 'lan', url: 'http://192.168.1.20:3000', priority: 10 },
599
+ { type: 'lan', url: 'http://10.0.0.5:3000', priority: 10 },
600
+ relayCandidate,
601
+ ]);
602
+ });
603
+
604
+ it('omits serverId and relay candidate when unavailable and survives failures', async () => {
605
+ const app = express();
606
+ const dependencies = {
607
+ ...createDependencies(),
608
+ getDirectCandidateUrls: () => {
609
+ throw new Error('scan failed');
610
+ },
611
+ getRelayPairingCandidate: async () => {
612
+ throw new Error('relay status failed');
613
+ },
614
+ getServerId: async () => null,
615
+ };
616
+ registerAuthAndAccessRoutes(app, dependencies);
617
+
618
+ const response = await request(app).get('/api/client-auth/connection/candidates');
619
+ expect(response.status).toBe(200);
620
+ expect(response.body).not.toHaveProperty('serverId');
621
+ expect(response.body.candidates).toEqual([]);
622
+ });
623
+
573
624
  it('scopes non-desktop client credentials to list and revoke only themselves', async () => {
574
625
  const app = express();
575
626
  let authContext = { type: 'session' };
@@ -679,4 +730,34 @@ describe('client auth routes', () => {
679
730
  expect(dependencies.testHooks.requireSessionAuth).toHaveBeenCalledTimes(2);
680
731
  expect(dependencies.testHooks.requireAuth).not.toHaveBeenCalled();
681
732
  });
733
+
734
+ it('treats private LAN hosts as local even when a tunnel is active', async () => {
735
+ const app = express();
736
+ const dependencies = createDependencies();
737
+ const tunnelAuthController = createTunnelAuth();
738
+ tunnelAuthController.setActiveTunnel({ tunnelId: 'tunnel-1', publicUrl: 'https://tunnel.example.com' });
739
+ dependencies.tunnelAuthController = tunnelAuthController;
740
+ dependencies.uiAuthController.handlePasskeyStatus = vi.fn((_req, res) => {
741
+ res.json({ enabled: true, hasPasskeys: true, passkeyCount: 1, rpID: 'example.com' });
742
+ });
743
+
744
+ registerAuthAndAccessRoutes(app, dependencies);
745
+
746
+ await request(app)
747
+ .get('/auth/passkey/status')
748
+ .set('Host', '192.168.1.5:57123')
749
+ .expect(200, { enabled: true, hasPasskeys: true, passkeyCount: 1, rpID: 'example.com' });
750
+
751
+ expect(dependencies.uiAuthController.handlePasskeyStatus).toHaveBeenCalledTimes(1);
752
+ });
753
+
754
+ it('does not trust a private Host header from a public socket peer', () => {
755
+ const tunnelAuthController = createTunnelAuth();
756
+ tunnelAuthController.setActiveTunnel({ tunnelId: 'tunnel-1', publicUrl: 'https://tunnel.example.com' });
757
+
758
+ expect(tunnelAuthController.classifyRequestScope({
759
+ headers: { host: '192.168.1.5:57123' },
760
+ socket: { remoteAddress: '203.0.113.10' },
761
+ })).toBe('unknown-public');
762
+ });
682
763
  });
@@ -1,10 +1,12 @@
1
1
  import { registerFsRoutes } from '../fs/routes.js';
2
2
  import { registerQuotaRoutes } from '../quota/routes.js';
3
3
  import { registerSmallModelRoutes } from '../small-model/routes.js';
4
+ import { registerSessionGoalRoutes } from '../session-goal/routes.js';
4
5
  import { registerGitHubRoutes } from '../github/routes.js';
5
6
  import { registerGitRoutes } from '../git/routes.js';
6
7
  import { registerMagicPromptRoutes } from '../magic-prompts/routes.js';
7
8
  import { registerSessionFoldersRoutes } from '../session-folders/routes.js';
9
+ import { registerPermissionAutoAcceptRoutes } from '../permission-auto-accept/runtime.js';
8
10
  import { registerConfigEntityRoutes } from './config-entity-routes.js';
9
11
  import { registerSettingsUtilityRoutes } from './core-routes.js';
10
12
  import { registerProjectIconRoutes } from './project-icon-routes.js';
@@ -97,6 +99,7 @@ export const createFeatureRoutesRuntime = (dependencies) => {
97
99
  scheduledTasksRuntime,
98
100
  getOpenChamberEventClients,
99
101
  writeSseEvent,
102
+ permissionAutoAcceptRuntime,
100
103
  } = routeDependencies;
101
104
 
102
105
  registerSettingsUtilityRoutes(app, {
@@ -105,6 +108,8 @@ export const createFeatureRoutesRuntime = (dependencies) => {
105
108
  clientReloadDelayMs,
106
109
  });
107
110
 
111
+ registerPermissionAutoAcceptRoutes(app, permissionAutoAcceptRuntime);
112
+
108
113
  registerOpenCodeRoutes(app, {
109
114
  crypto,
110
115
  clientReloadDelayMs,
@@ -236,6 +241,7 @@ export const createFeatureRoutesRuntime = (dependencies) => {
236
241
 
237
242
  registerQuotaRoutes(app, { getQuotaProviders });
238
243
  registerSmallModelRoutes(app, { getSmallModelService });
244
+ registerSessionGoalRoutes(app);
239
245
  registerGitHubRoutes(app);
240
246
  registerGitRoutes(app);
241
247
  registerMagicPromptRoutes(app, {
@@ -184,6 +184,24 @@ export const createSettingsHelpers = (dependencies) => {
184
184
  if (typeof candidate.desktopMinimizeToTrayEnabled === 'boolean') {
185
185
  result.desktopMinimizeToTrayEnabled = candidate.desktopMinimizeToTrayEnabled;
186
186
  }
187
+ if (typeof candidate.desktopWindowControlsPosition === 'string') {
188
+ const mode = candidate.desktopWindowControlsPosition.trim();
189
+ if (mode === 'auto' || mode === 'left' || mode === 'right') {
190
+ result.desktopWindowControlsPosition = mode;
191
+ }
192
+ }
193
+ if (candidate.permissionAutoAccept && typeof candidate.permissionAutoAccept === 'object' && !Array.isArray(candidate.permissionAutoAccept)) {
194
+ const sessions = {};
195
+ const sourceSessions = candidate.permissionAutoAccept.sessions;
196
+ if (sourceSessions && typeof sourceSessions === 'object' && !Array.isArray(sourceSessions)) {
197
+ for (const [sessionId, enabled] of Object.entries(sourceSessions)) {
198
+ if (sessionId && typeof enabled === 'boolean') sessions[sessionId] = enabled;
199
+ }
200
+ }
201
+ result.permissionAutoAccept = {
202
+ sessions,
203
+ };
204
+ }
187
205
  if (typeof candidate.desktopUiPassword === 'string') {
188
206
  result.desktopUiPassword = candidate.desktopUiPassword.trim();
189
207
  }
@@ -254,6 +272,15 @@ export const createSettingsHelpers = (dependencies) => {
254
272
  if (typeof candidate.sessionSuggestionEnabled === 'boolean') {
255
273
  result.sessionSuggestionEnabled = candidate.sessionSuggestionEnabled;
256
274
  }
275
+ if (typeof candidate.sessionGoalEnabled === 'boolean') {
276
+ result.sessionGoalEnabled = candidate.sessionGoalEnabled;
277
+ }
278
+ if (typeof candidate.sessionGoalDefaultBudgetEnabled === 'boolean') {
279
+ result.sessionGoalDefaultBudgetEnabled = candidate.sessionGoalDefaultBudgetEnabled;
280
+ }
281
+ if (typeof candidate.sessionGoalDefaultBudget === 'number' && Number.isFinite(candidate.sessionGoalDefaultBudget) && candidate.sessionGoalDefaultBudget > 0) {
282
+ result.sessionGoalDefaultBudget = Math.floor(candidate.sessionGoalDefaultBudget);
283
+ }
257
284
  if (typeof candidate.collapsibleThinkingBlocks === 'boolean') {
258
285
  result.collapsibleThinkingBlocks = candidate.collapsibleThinkingBlocks;
259
286
  }
@@ -505,6 +532,9 @@ export const createSettingsHelpers = (dependencies) => {
505
532
  if (typeof candidate.stickyUserHeader === 'boolean') {
506
533
  result.stickyUserHeader = candidate.stickyUserHeader;
507
534
  }
535
+ if (typeof candidate.promptNavigatorEnabled === 'boolean') {
536
+ result.promptNavigatorEnabled = candidate.promptNavigatorEnabled;
537
+ }
508
538
  if (typeof candidate.expandedEditorToolbar === 'boolean') {
509
539
  result.expandedEditorToolbar = candidate.expandedEditorToolbar;
510
540
  }
@@ -111,6 +111,20 @@ describe('settings helpers', () => {
111
111
  });
112
112
  });
113
113
 
114
+ it('sanitizes the persisted permission auto-accept policy', () => {
115
+ const helpers = createTestHelpers();
116
+
117
+ expect(helpers.sanitizeSettingsUpdate({
118
+ permissionAutoAccept: {
119
+ sessions: { root: true, child: false, invalid: 'true' },
120
+ },
121
+ })).toEqual({
122
+ permissionAutoAccept: {
123
+ sessions: { root: true, child: false },
124
+ },
125
+ });
126
+ });
127
+
114
128
  it('accepts desktopUiPassword as a persisted shared setting', () => {
115
129
  const helpers = createTestHelpers();
116
130
 
@@ -68,13 +68,28 @@ export const createSettingsNormalizationRuntime = (dependencies) => {
68
68
  return trimmed;
69
69
  }
70
70
 
71
- const resolved = options.resolveRealpath === false ? trimmed : safeRealpathSync(trimmed);
71
+ // Normalize Windows drive letter to uppercase to ensure consistent
72
+ // case across all path representations on Windows. NTFS is case-insensitive
73
+ // but case-preserving, so a path like "c:\\Users\\..." and "C:\\Users\\..."
74
+ // would be stored differently in settings.json across sessions.
75
+ const uppercaseDriveLetter = (p) =>
76
+ p.replace(/^([a-z]):/, (_, letter) => letter.toUpperCase() + ':');
72
77
 
73
- if (processLike.platform !== 'win32') {
74
- return resolved;
78
+ const isWindows = processLike.platform === 'win32';
79
+ const caseNormalized = isWindows ? uppercaseDriveLetter(trimmed) : trimmed;
80
+ const resolved = options.resolveRealpath === false ? caseNormalized : safeRealpathSync(caseNormalized);
81
+
82
+ // Re-normalize after realpath — safeRealpathSync may return a
83
+ // lowercase drive letter on some Windows environments.
84
+ const finalResolved = isWindows && typeof resolved === 'string'
85
+ ? uppercaseDriveLetter(resolved)
86
+ : resolved;
87
+
88
+ if (!isWindows) {
89
+ return finalResolved;
75
90
  }
76
91
 
77
- return resolved.replace(/\//g, '\\');
92
+ return finalResolved.replace(/\//g, '\\');
78
93
  };
79
94
 
80
95
  const areStringArraysEqual = (a, b) => {
@@ -52,6 +52,27 @@ describe('settings normalization runtime - symlink resolution', () => {
52
52
  const result = runtime.normalizePathForPersistence('/some/path');
53
53
  expect(result).toBe('/some/path');
54
54
  });
55
+
56
+ it('preserves lowercase colon-prefixed paths on non-Windows platforms', () => {
57
+ const runtime = createTestRuntime({ realpathSync: undefined });
58
+
59
+ expect(runtime.normalizePathForPersistence('c:project')).toBe('c:project');
60
+ });
61
+
62
+ it('uppercases Windows drive letter before and after realpath resolution', () => {
63
+ const runtime = createTestRuntime({
64
+ processLike: { platform: 'win32', env: {} },
65
+ realpathSync: (p) => {
66
+ // Simulate safeRealpathSync returning a lowercase drive letter
67
+ if (p === 'C:\\Users\\me\\project') return 'c:\\real\\project';
68
+ return p;
69
+ },
70
+ });
71
+
72
+ const result = runtime.normalizePathForPersistence('c:\\Users\\me\\project');
73
+ // Drive letter uppercased on input AND after realpath
74
+ expect(result).toBe('C:\\real\\project');
75
+ });
55
76
  });
56
77
 
57
78
  describe('sanitizeProjects', () => {
@@ -438,6 +438,30 @@ export const createSettingsRuntime = (deps) => {
438
438
  }
439
439
  };
440
440
 
441
+ // Strict variant for callers that REGENERATE persisted identity when a key is
442
+ // absent (relay signing/encryption keys). The lenient reader above maps every
443
+ // failure — corrupt JSON, EACCES, transient I/O — to `{}`, which such callers
444
+ // cannot distinguish from "first run": they would mint a NEW identity, orphan
445
+ // every paired device and push binding, and overwrite the settings file with
446
+ // the empty spread. Here only a genuinely missing file means "no settings";
447
+ // any other failure (including a non-object payload) throws.
448
+ const readSettingsFromDiskStrict = async () => {
449
+ let raw;
450
+ try {
451
+ raw = await fsPromises.readFile(SETTINGS_FILE_PATH, 'utf8');
452
+ } catch (error) {
453
+ if (error && typeof error === 'object' && error.code === 'ENOENT') {
454
+ return {};
455
+ }
456
+ throw error;
457
+ }
458
+ const parsed = JSON.parse(raw);
459
+ if (!parsed || typeof parsed !== 'object') {
460
+ throw new Error('Settings file is malformed (non-object payload)');
461
+ }
462
+ return parsed;
463
+ };
464
+
441
465
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
442
466
 
443
467
  const isTransientWindowsReplaceError = (error) => {
@@ -870,6 +894,7 @@ export const createSettingsRuntime = (deps) => {
870
894
 
871
895
  return {
872
896
  readSettingsFromDisk,
897
+ readSettingsFromDiskStrict,
873
898
  readSettingsFromDiskMigrated,
874
899
  writeSettingsToDisk,
875
900
  persistSettings,
@@ -9,6 +9,7 @@ export const createGracefulShutdownRuntime = (dependencies) => {
9
9
  openCodeWatcherRuntime,
10
10
  sessionRuntime,
11
11
  sessionAssistRuntime,
12
+ sessionGoalRuntime,
12
13
  scheduledTasksRuntime,
13
14
  getHealthCheckInterval,
14
15
  clearHealthCheckInterval,
@@ -43,6 +44,7 @@ export const createGracefulShutdownRuntime = (dependencies) => {
43
44
  openCodeWatcherRuntime.stop();
44
45
  sessionRuntime.dispose();
45
46
  sessionAssistRuntime?.stop?.();
47
+ sessionGoalRuntime?.stop?.();
46
48
  scheduledTasksRuntime?.stop?.();
47
49
 
48
50
  const healthCheckInterval = getHealthCheckInterval();
@@ -172,15 +172,10 @@ const isLocalHost = (host, req) => {
172
172
  return false;
173
173
  }
174
174
 
175
- if (host === 'localhost' || host === '127.0.0.1' || host === '::1' || host === '[::1]') {
176
- return true;
177
- }
178
-
179
- if (host === 'host.docker.internal') {
180
- return isPrivateOrLoopbackIp(getSocketRemoteIp(req));
181
- }
182
-
183
- return false;
175
+ const isLocalHostname = host === 'localhost'
176
+ || host === 'host.docker.internal'
177
+ || isPrivateOrLoopbackIp(host);
178
+ return isLocalHostname && isPrivateOrLoopbackIp(getSocketRemoteIp(req));
184
179
  };
185
180
 
186
181
  const getClientIp = (req) => {
@@ -11,7 +11,7 @@ const __dirname = path.dirname(__filename);
11
11
  const PACKAGE_NAME = '@openchamber/web';
12
12
  const PACKAGE_PATH_SEGMENTS = PACKAGE_NAME.split('/');
13
13
  const NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}`;
14
- const CHANGELOG_URL = 'https://raw.githubusercontent.com/btriapitsyn/openchamber/main/CHANGELOG.md';
14
+ const CHANGELOG_URL = 'https://raw.githubusercontent.com/openchamber/openchamber/main/CHANGELOG.md';
15
15
  const GITHUB_RELEASES_URL = 'https://github.com/openchamber/openchamber/releases';
16
16
  let cachedDetectedPm = null;
17
17
 
@@ -0,0 +1,34 @@
1
+ # Permission Auto-Accept
2
+
3
+ ## Purpose
4
+
5
+ This module owns the authoritative permission auto-accept policy for web, desktop, and mobile runtimes. Policy is persisted in OpenChamber settings so permission handling survives UI disconnects and server restarts.
6
+
7
+ ## Policy
8
+
9
+ `permissionAutoAccept.sessions` contains explicit per-session boolean policies.
10
+
11
+ Policy inheritance uses the nearest explicit session value. A child `false` therefore overrides a parent `true`; descendants without an explicit value inherit from their nearest configured ancestor.
12
+
13
+ ## Runtime
14
+
15
+ `createPermissionAutoAcceptRuntime` loads and serializes policy writes, subscribes to the global OpenCode event hub, caches session lineage, retries transient replies, and reconciles pending permissions after startup, reconnect, and policy enablement. Enabling Auto-Accept for a session immediately accepts matching pending requests and keeps handling future requests without requiring a connected UI.
16
+
17
+ Unknown lineage and failed policy loads fail closed. A failed pending-permission fetch is distinct from an empty successful response and never clears policy state.
18
+
19
+ ## Routes
20
+
21
+ - `GET /api/permission-auto-accept`
22
+ - `PUT /api/permission-auto-accept/sessions/:sessionId`
23
+
24
+ These are normal authenticated OpenChamber runtime routes. They must not be added to browser URL-token allowlists.
25
+
26
+ ## UI ownership
27
+
28
+ `packages/ui/src/stores/permissionStore.ts` is a projection of server policy and does not persist an independent policy. The server is the sole responder and the UI renders pending requests until the authoritative `permission.replied` event arrives.
29
+
30
+ VS Code retains its foreground-only implementation because it does not run the web server runtime.
31
+
32
+ ## Tests
33
+
34
+ `runtime.test.js` covers restart persistence, nearest explicit subagent inheritance, missing-lineage lookup, retry/deduplication, and reconnect reconciliation.