@openchamber/web 1.22.0 → 1.22.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 (122) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-CPvfxh0N.js → CodeMirrorCommentWidgets-BO_2OW4E.js} +1 -1
  2. package/dist/assets/{DiffView-6xGdyI0n.js → DiffView-CNnDxRmO.js} +2 -2
  3. package/dist/assets/DirtyBranchSwitchDialog-jADfXQnR.js +1 -0
  4. package/dist/assets/{FilesView-Bm3vT63N.js → FilesView-8wdiG2mj.js} +8 -8
  5. package/dist/assets/GitView-Cv2xH-S6.js +6 -0
  6. package/dist/assets/{JsonTreeView-rwHz84MX.js → JsonTreeView-DUiIpERC.js} +1 -1
  7. package/dist/assets/LinearIssuesView-CoZ7pQN5.js +1 -0
  8. package/dist/assets/{MarkdownImageGallery-sGilV9Hs.js → MarkdownImageGallery-DffjmciG.js} +1 -1
  9. package/dist/assets/{MarkdownRendererImpl--4sRsKBn.js → MarkdownRendererImpl-DxqdYDAx.js} +2 -2
  10. package/dist/assets/{OnboardingScreen-CECL_Cms.js → OnboardingScreen-CTZe6HZn.js} +1 -1
  11. package/dist/assets/{PatchDiff-BGPl1s-U.js → PatchDiff-BymkP9JA.js} +1 -1
  12. package/dist/assets/{PierreDiffViewer-Cvz9Z-io.js → PierreDiffViewer-BvwtCxW4.js} +2 -2
  13. package/dist/assets/{PlanView-BFMsnHk3.js → PlanView-C1qvAm7m.js} +4 -4
  14. package/dist/assets/SettingsView-xGONHFGS.js +28 -0
  15. package/dist/assets/{SettingsWindow-C1Qa09YO.js → SettingsWindow-COzgfFxM.js} +1 -1
  16. package/dist/assets/{ToolOutputDialog-DzQlzMF4.js → ToolOutputDialog-Dlhh_-oe.js} +6 -6
  17. package/dist/assets/ToolPartDiffPreview-b9joNtXH.js +8 -0
  18. package/dist/assets/{VirtualizedFileDiff-DT5MDv-u.js → VirtualizedFileDiff-vqW3KKo5.js} +1 -1
  19. package/dist/assets/{WalkthroughView-D8sLH_M8.js → WalkthroughView-D-HFgdmM.js} +1 -1
  20. package/dist/assets/{computeVirtualFileMetrics-DmpLWhll.js → computeVirtualFileMetrics-DUnyszhW.js} +1 -1
  21. package/dist/assets/{contextPanelEmbeddedChat-BK78t3M_.js → contextPanelEmbeddedChat-CV-DwAiX.js} +1 -1
  22. package/dist/assets/{de-C3luvSd_.js → de-Cv_4FoXm.js} +6 -5
  23. package/dist/assets/{es-CmU4HLv9.js → es-BIWNEbnS.js} +6 -5
  24. package/dist/assets/{fr-Bgyni40l.js → fr-SD3OfMHJ.js} +6 -5
  25. package/dist/assets/index-CHUT_bDS.css +1 -0
  26. package/dist/assets/index-DDInLQDd.js +40 -0
  27. package/dist/assets/{index-CWYs7sMK.js → index-DLiD86ge.js} +1 -1
  28. package/dist/assets/{isDiffPlainText-BO_q5ezD.js → isDiffPlainText-TNageFjy.js} +1 -1
  29. package/dist/assets/{isFilePlainText-D8qPqUAf.js → isFilePlainText-JPmZOYSp.js} +1 -1
  30. package/dist/assets/{ja-C1ImKinT.js → ja-D7I9HofF.js} +7 -6
  31. package/dist/assets/{ko-CP7OdxYH.js → ko-BsVJM_PQ.js} +7 -6
  32. package/dist/assets/{main-D7fwjW2z.js → main-DCB4JgVe.js} +2 -2
  33. package/dist/assets/main-De8Z5w49.js +928 -0
  34. package/dist/assets/{markdownCore-BcmkWZPO.js → markdownCore-BoQVG5-a.js} +1 -1
  35. package/dist/assets/{miniChat-D5rraz-g.js → miniChat-BtV7N5OF.js} +2 -2
  36. package/dist/assets/{mobile-Cg_DE3KL.js → mobile-DZV_sfX7.js} +2 -2
  37. package/dist/assets/{patchFileDiff-Bpql0QGw.js → patchFileDiff-Chmiz6hq.js} +5 -5
  38. package/dist/assets/{pl-DQYSiGYX.js → pl-XR9Bs8Be.js} +6 -5
  39. package/dist/assets/{pt-BR-DytpsW4M.js → pt-BR-Due4be8g.js} +6 -5
  40. package/dist/assets/{renderElectronMiniChatApp-B_Bn7BbN.js → renderElectronMiniChatApp-8tXADjfl.js} +2 -2
  41. package/dist/assets/renderMobileApp-Cji7Hma5.js +25 -0
  42. package/dist/assets/runtimeEndpointReset-gWt3Lb5D.js +16 -0
  43. package/dist/assets/{scheduledTasksApi-BPvxrynl.js → scheduledTasksApi-9e-UX6im.js} +1 -1
  44. package/dist/assets/{shikiHighlight-CFAVs_lu.js → shikiHighlight-CRpCl7UT.js} +1 -1
  45. package/dist/assets/tr-DBJcAv4y.js +7 -0
  46. package/dist/assets/{uk-DwnRxJZd.js → uk-COYh2BaN.js} +6 -5
  47. package/dist/assets/{useAppFontEffects-DWXGRUPZ.js → useAppFontEffects-CCgvcQ6u.js} +145 -177
  48. package/dist/assets/{useInlineCommentController-Cc0OCXr0.js → useInlineCommentController-BkfXnjNZ.js} +2 -2
  49. package/dist/assets/{useRootScrollLock-BFZtfciC.js → useRootScrollLock-KzOUytpn.js} +1 -1
  50. package/dist/assets/{vendor-codemirror-language-data-BGFszm8n.js → vendor-codemirror-language-data-BxpoC5Fp.js} +2 -2
  51. package/dist/assets/vendor-zod-DVWEh-IS.js +39 -0
  52. package/dist/assets/{web-components-CD-GFayc.js → web-components-B6QgbmTo.js} +1 -1
  53. package/dist/assets/{zh-CN-UDNMxm7r.js → zh-CN-Cjk6lzhc.js} +6 -5
  54. package/dist/assets/{zh-TW-BsswdYL-.js → zh-TW-Dk0dOg03.js} +6 -5
  55. package/dist/index.html +5 -5
  56. package/dist/mini-chat.html +4 -4
  57. package/dist/mobile.html +4 -4
  58. package/package.json +2 -2
  59. package/server/index.js +31 -4
  60. package/server/lib/agent-tool/runtime.js +2 -19
  61. package/server/lib/dev-tunnel/DOCUMENTATION.md +13 -4
  62. package/server/lib/dev-tunnel/runtime.js +4 -4
  63. package/server/lib/dev-tunnel/tunnel.test.js +20 -0
  64. package/server/lib/git/DOCUMENTATION.md +3 -1
  65. package/server/lib/git/routes.js +16 -0
  66. package/server/lib/git/service.js +97 -17
  67. package/server/lib/git/service.test.js +153 -0
  68. package/server/lib/mcp-reconnect/DOCUMENTATION.md +55 -0
  69. package/server/lib/mcp-reconnect/runtime.js +122 -0
  70. package/server/lib/mcp-reconnect/runtime.test.js +140 -0
  71. package/server/lib/message-queue/DOCUMENTATION.md +148 -0
  72. package/server/lib/message-queue/runtime.js +818 -0
  73. package/server/lib/message-queue/runtime.test.js +426 -0
  74. package/server/lib/openchamber-sessions/routes.js +102 -0
  75. package/server/lib/openchamber-sessions/routes.test.js +88 -0
  76. package/server/lib/opencode/DOCUMENTATION.md +5 -1
  77. package/server/lib/opencode/core-routes.js +1 -0
  78. package/server/lib/opencode/feature-routes-runtime.js +3 -0
  79. package/server/lib/opencode/managed-plugin-config.js +35 -0
  80. package/server/lib/opencode/settings-runtime.js +2 -2
  81. package/server/lib/opencode/settings-runtime.test.js +29 -0
  82. package/server/lib/opencode/shutdown-runtime.js +2 -0
  83. package/server/lib/quota/DOCUMENTATION.md +2 -1
  84. package/server/lib/quota/credentials/providers.js +4 -0
  85. package/server/lib/quota/credentials/store.js +1 -1
  86. package/server/lib/quota/credentials/store.test.js +4 -4
  87. package/server/lib/quota/providers/exe-dev.js +75 -0
  88. package/server/lib/quota/providers/exe-dev.test.js +47 -0
  89. package/server/lib/quota/providers/index.js +7 -0
  90. package/server/lib/quota/providers/opencode-go.js +1 -0
  91. package/server/lib/quota/providers/opencode-go.test.js +5 -1
  92. package/server/lib/quota/routes.js +2 -0
  93. package/server/lib/relay/DOCUMENTATION.md +1 -1
  94. package/server/lib/relay/tunnel-host.js +3 -1
  95. package/server/lib/relay/tunnel-host.test.js +9 -1
  96. package/server/lib/security/request-security.js +21 -6
  97. package/server/lib/security/request-security.test.js +42 -8
  98. package/server/lib/session-assist/runtime.js +1 -0
  99. package/server/lib/session-goal/create.js +3 -1
  100. package/server/lib/session-goal/runtime.js +1 -0
  101. package/server/lib/small-model/DOCUMENTATION.md +4 -0
  102. package/server/lib/small-model/call.js +8 -2
  103. package/server/lib/small-model/call.test.js +23 -0
  104. package/server/lib/small-model/index.js +2 -1
  105. package/server/lib/small-model/routes.js +2 -1
  106. package/server/lib/system-prompt/runtime.js +2 -21
  107. package/server/lib/terminal/runtime.js +30 -7
  108. package/server/lib/ui-auth/ui-auth.js +4 -1
  109. package/server/lib/ui-auth/ui-auth.test.js +16 -0
  110. package/server/lib/walkthrough/index.js +1 -0
  111. package/dist/assets/CommitSection-CC5mFzO2.js +0 -1
  112. package/dist/assets/GitView-B6y1Y69c.js +0 -6
  113. package/dist/assets/LinearIssuesView-B0UM_Rkx.js +0 -1
  114. package/dist/assets/SettingsView-_Gtn5SdT.js +0 -28
  115. package/dist/assets/ToolPartDiffPreview-DfVOfwHy.js +0 -8
  116. package/dist/assets/index-C57jT0Sa.css +0 -1
  117. package/dist/assets/index-b0zDkWyg.js +0 -7
  118. package/dist/assets/main-D4rd8Hy5.js +0 -928
  119. package/dist/assets/renderMobileApp-DLfxMzGJ.js +0 -25
  120. package/dist/assets/runtimeEndpointReset-HlRmXFGW.js +0 -16
  121. package/dist/assets/tr-aizaUvft.js +0 -6
  122. package/dist/assets/vendor-zod-BLfBSgBh.js +0 -39
@@ -34,6 +34,8 @@ This module provides OpenCode server integration utilities for the web server ru
34
34
  - `packages/web/server/lib/opencode/startup-performance.js`: opt-in startup phase diagnostics with fixed labels and numeric metadata allowlists.
35
35
  - `packages/web/server/lib/agent-tool/runtime.js`: managed OpenCode custom-tool materialization, environment injection, loopback authentication, and fixed CLI action dispatch.
36
36
  - `packages/web/server/lib/system-prompt/runtime.js`: opt-in managed OpenCode system-prompt optimizer materialization and plugin injection.
37
+ - `packages/web/server/lib/mcp-reconnect/runtime.js`: always-on managed OpenCode plugin that reconnects MCP servers OpenCode marked `failed`, with per-server backoff.
38
+ - `packages/web/server/lib/opencode/managed-plugin-config.js`: the one `OPENCODE_CONFIG_CONTENT` merge every managed plugin (agent tools, system prompt optimizer, MCP reconnect) appends itself through.
37
39
  - `packages/web/server/lib/opencode/server-utils-runtime.js`: shared server runtime utilities for OpenCode proxy wiring, OpenCode port/readiness helpers, and snapshot fetchers.
38
40
  - `packages/web/server/lib/opencode/openchamber-routes.js`: OpenChamber update and models metadata route registration.
39
41
  - `packages/web/server/lib/opencode/pwa-manifest-routes.js`: PWA manifest route registration with recent-session shortcut resolution and short-lived caching.
@@ -130,7 +132,8 @@ The runtime maintains active-session count incrementally from idempotent activit
130
132
  - `killProcessOnPort(port)`
131
133
 
132
134
  Managed OpenCode launch also merges the environment returned by the agent-tool
133
- runtime. PATH and `OPENCODE_SERVER_PASSWORD` remain lifecycle-owned and cannot
135
+ runtime, the opt-in system prompt optimizer, and the always-on MCP reconnect
136
+ plugin, each appending its `file://` entry to the previous one's config. PATH and `OPENCODE_SERVER_PASSWORD` remain lifecycle-owned and cannot
134
137
  be replaced by injected values. External OpenCode processes receive no
135
138
  OpenChamber tool injection. Managed launch env strips AppImage `ARGV0` before
136
139
  spawn so zsh-backed OpenCode tools do not rewrite child argv[0] to the AppImage
@@ -208,6 +211,7 @@ Managed health failures are classified as `timeout`, `connection_refused`, `conn
208
211
  - `writeSettingsToDisk(settings)`
209
212
  - `persistSettings(changes)`
210
213
  - Persistent permission auto-accept policy is stored under `permissionAutoAccept`; execution ownership lives in `lib/permission-auto-accept/`.
214
+ - Queued follow-up messages live in `<data-dir>/message-queue.json`, not in settings; execution ownership lives in `lib/message-queue/`.
211
215
  - Shared sidebar preferences are stored as validated top-level fields: `sidebarProjectDisplayMode`, `sidebarSessionGroupingMode`, `sidebarProjectSortOrder`, and `sidebarShowRecentSection`. Device-local picker selection and sticky-header state do not enter `settings.json`.
212
216
 
213
217
  ## Public exports (settings-helpers.js)
@@ -1065,6 +1065,7 @@ export const registerCommonRequestMiddleware = (app, dependencies) => {
1065
1065
  req.path.startsWith('/api/push') ||
1066
1066
  req.path.startsWith('/api/notifications') ||
1067
1067
  req.path.startsWith('/api/permission-auto-accept') ||
1068
+ req.path.startsWith('/api/message-queue') ||
1068
1069
  req.path.startsWith('/api/provider') ||
1069
1070
  req.path.startsWith('/api/session-folders') ||
1070
1071
  req.path.startsWith('/api/small-model') ||
@@ -13,6 +13,7 @@ import { registerProjectContextRoutes } from '../project-context/routes.js';
13
13
  import { registerAgentMemoryRoutes } from '../agent-memory/routes.js';
14
14
  import { registerSessionKnowledgeRoutes } from '../session-knowledge/routes.js';
15
15
  import { registerPermissionAutoAcceptRoutes } from '../permission-auto-accept/runtime.js';
16
+ import { registerMessageQueueRoutes } from '../message-queue/runtime.js';
16
17
  import { registerConfigEntityRoutes } from './config-entity-routes.js';
17
18
  import { registerSettingsUtilityRoutes } from './core-routes.js';
18
19
  import { registerProjectIconRoutes } from './project-icon-routes.js';
@@ -132,6 +133,7 @@ export const createFeatureRoutesRuntime = (dependencies) => {
132
133
  writeSseEvent,
133
134
  emitSessionCreatedEvent,
134
135
  permissionAutoAcceptRuntime,
136
+ messageQueueRuntime,
135
137
  } = routeDependencies;
136
138
 
137
139
  registerSettingsUtilityRoutes(app, {
@@ -141,6 +143,7 @@ export const createFeatureRoutesRuntime = (dependencies) => {
141
143
  });
142
144
 
143
145
  registerPermissionAutoAcceptRoutes(app, permissionAutoAcceptRuntime);
146
+ registerMessageQueueRoutes(app, messageQueueRuntime);
144
147
 
145
148
  registerOpenCodeRoutes(app, {
146
149
  crypto,
@@ -0,0 +1,35 @@
1
+ import { parse as parseJsonc } from 'jsonc-parser';
2
+
3
+ const isJsonObject = (value) => value !== null && value !== undefined && Object.getPrototypeOf(value) === Object.prototype;
4
+
5
+ /**
6
+ * Append a managed OpenChamber plugin to the `plugin` list of an
7
+ * `OPENCODE_CONFIG_CONTENT` value.
8
+ *
9
+ * Existing entries are preserved; an earlier entry for the same URL is dropped
10
+ * so a restart never registers the same plugin twice. Every managed plugin
11
+ * (agent tools, system prompt optimizer, MCP reconnect) goes through this one
12
+ * merge so they compose in any order.
13
+ *
14
+ * @param {string | undefined} rawConfig the current `OPENCODE_CONFIG_CONTENT`, JSONC or unset
15
+ * @param {string} pluginUrl `file://` URL of the materialized plugin
16
+ * @param {string} purpose short noun phrase for the error message, e.g. "managed tool"
17
+ * @returns {string} the merged config as JSON
18
+ */
19
+ export const appendManagedPlugin = (rawConfig, pluginUrl, purpose) => {
20
+ const errors = [];
21
+ const text = (rawConfig ?? '').trim();
22
+ const parsed = text ? parseJsonc(text, errors, { allowTrailingComma: true }) : {};
23
+ if (errors.length > 0 || !isJsonObject(parsed)) {
24
+ throw new Error(`OPENCODE_CONFIG_CONTENT must contain a valid JSON object before OpenChamber can inject its ${purpose}`);
25
+ }
26
+ if (parsed.plugin !== undefined && !Array.isArray(parsed.plugin)) {
27
+ throw new Error(`OPENCODE_CONFIG_CONTENT plugin must be an array before OpenChamber can inject its ${purpose}`);
28
+ }
29
+ const configured = Array.isArray(parsed.plugin) ? parsed.plugin : [];
30
+ parsed.plugin = [
31
+ ...configured.filter((value) => value !== pluginUrl && (!Array.isArray(value) || value[0] !== pluginUrl)),
32
+ pluginUrl,
33
+ ];
34
+ return JSON.stringify(parsed);
35
+ };
@@ -692,8 +692,8 @@ export const createSettingsRuntime = (deps) => {
692
692
  return { settings, changed: false };
693
693
  }
694
694
 
695
- const defaultLight = 'flexoki-light';
696
- const defaultDark = 'flexoki-dark';
695
+ const defaultLight = 'openchamber-light';
696
+ const defaultDark = 'openchamber-dark';
697
697
 
698
698
  let nextLightThemeId = hasLight ? settings.lightThemeId : undefined;
699
699
  let nextDarkThemeId = hasDark ? settings.darkThemeId : undefined;
@@ -39,6 +39,35 @@ const createRuntime = async () => {
39
39
  };
40
40
 
41
41
  describe('settings runtime', () => {
42
+ it('uses OpenChamber themes when a new install has no theme preferences', async () => {
43
+ const { runtime, cleanup } = await createRuntime();
44
+ try {
45
+ await expect(runtime.readSettingsFromDiskMigrated()).resolves.toMatchObject({
46
+ lightThemeId: 'openchamber-light',
47
+ darkThemeId: 'openchamber-dark',
48
+ });
49
+ } finally {
50
+ await cleanup();
51
+ }
52
+ });
53
+
54
+ it('preserves existing theme preferences during theme migration', async () => {
55
+ const { runtime, settingsFilePath, cleanup } = await createRuntime();
56
+ try {
57
+ await fsPromises.writeFile(settingsFilePath, JSON.stringify({
58
+ lightThemeId: 'flexoki-light',
59
+ darkThemeId: 'flexoki-dark',
60
+ }), 'utf8');
61
+
62
+ await expect(runtime.readSettingsFromDiskMigrated()).resolves.toMatchObject({
63
+ lightThemeId: 'flexoki-light',
64
+ darkThemeId: 'flexoki-dark',
65
+ });
66
+ } finally {
67
+ await cleanup();
68
+ }
69
+ });
70
+
42
71
  it('round-trips shared sidebar preferences through settings.json', async () => {
43
72
  const { runtime, settingsFilePath, cleanup } = await createRuntime();
44
73
  const preferences = {
@@ -11,6 +11,7 @@ export const createGracefulShutdownRuntime = (dependencies) => {
11
11
  sessionAssistRuntime,
12
12
  sessionGoalRuntime,
13
13
  contextObligatoryRuntime,
14
+ messageQueueRuntime,
14
15
  scheduledTasksRuntime,
15
16
  getHealthCheckInterval,
16
17
  clearHealthCheckInterval,
@@ -47,6 +48,7 @@ export const createGracefulShutdownRuntime = (dependencies) => {
47
48
  sessionAssistRuntime?.stop?.();
48
49
  sessionGoalRuntime?.stop?.();
49
50
  contextObligatoryRuntime?.stop?.();
51
+ messageQueueRuntime?.stop?.();
50
52
  scheduledTasksRuntime?.stop?.();
51
53
 
52
54
  const healthCheckInterval = getHealthCheckInterval();
@@ -23,6 +23,7 @@ These provider IDs are currently dispatchable via `fetchQuotaForProvider(provide
23
23
  | `cursor` | Cursor | `providers/cursor.js` | Environment/token files, OpenChamber-managed credentials, or explicit one-time Cursor import |
24
24
  | `crof` | CrofAI | `providers/crof.js` | `crof` (API key under `key` or `token`) |
25
25
  | `deepseek` | DeepSeek | `providers/deepseek.js` | `deepseek` (API key under `key` or `token`) |
26
+ | `exe-dev` | exe.dev | `providers/exe-dev.js` | Usage API token stored under `~/.config/openchamber/quota/` |
26
27
  | `google` | Google | `providers/google/index.js` | `google`, `google.oauth`, Antigravity accounts file |
27
28
  | `github-copilot` | GitHub Copilot | `providers/copilot.js` | `github-copilot`, `copilot` |
28
29
  | `github-copilot-addon` | GitHub Copilot Add-on | `providers/copilot.js` | `github-copilot`, `copilot` |
@@ -51,7 +52,7 @@ All providers should return results via shared helpers to preserve API shape:
51
52
  Provider modules must export `providerId`, `providerName`, `aliases`, `isConfigured(auth?)`, and `fetchQuota()`.
52
53
  `fetchQuota()` should return a quota result with `usage.windows` keyed by window name (for example `5h`, `7d`, `daily`) and optional provider-specific `usage.models` data.
53
54
 
54
- Ollama Cloud and Cursor credentials are explicitly managed through Settings. OpenCode Go usage uses `GET https://opencode.ai/zen/go/v1/usage` with the `opencode-go` API key from OpenCode `auth.json` as a bearer token. The server validates managed credentials before atomic `0600` writes and never returns secrets through its API. OpenChamber never scans browser cookie stores or automatically reads Cursor storage; Cursor import is an explicit one-time user action and never modifies Cursor's database.
55
+ exe.dev, Ollama Cloud, and Cursor credentials are explicitly managed through Settings. exe.dev usage uses a separately generated HTTPS API token restricted to `billing credits usage` and aggregates every `exe-*` model provider into one monthly credit window. Generate the token with `ssh exe.dev "ssh-key generate-api-key --label=openchamber --exp=30d --cmds='billing credits usage'"`. OpenCode Go usage uses `GET https://opencode.ai/zen/go/v1/usage` with the `opencode-go` API key from OpenCode `auth.json` as a bearer token and the stable `x-opencode-session: openchamber-usage` workload id. The server validates managed credentials before atomic `0600` writes and never returns secrets through its API. OpenChamber never scans browser cookie stores or automatically reads Cursor storage; Cursor import is an explicit one-time user action and never modifies Cursor's database.
55
56
 
56
57
  Command Code usage resolves account scope through `GET /alpha/whoami`, then reads server-backed credit balances and five-hour/weekly limits from `GET /alpha/billing/credits?orgId=...`. Personal accounts return `org: null` and use `/alpha/billing/credits` without an `orgId`; organization accounts include their organization id. Web/Electron and VS Code read the standard `command-code` OpenCode auth entry (including OAuth `access`) or `COMMAND_CODE_API_KEY`; credentials remain in the owning runtime and are never returned to shared UI.
57
58
 
@@ -3,6 +3,10 @@ import { deleteQuotaCredential, readQuotaCredential, writeQuotaCredential } from
3
3
  const clean = (value) => typeof value === 'string' && !/[\r\n]/.test(value) ? value.trim() : '';
4
4
 
5
5
  export const normalizers = {
6
+ 'exe-dev': (value) => {
7
+ const usageToken = clean(value?.usageToken);
8
+ return usageToken ? { usageToken } : null;
9
+ },
6
10
  'ollama-cloud': (value) => {
7
11
  const cookie = clean(value?.cookie);
8
12
  return cookie ? { cookie } : null;
@@ -2,7 +2,7 @@ import fs from 'node:fs';
2
2
  import os from 'node:os';
3
3
  import path from 'node:path';
4
4
 
5
- const MANAGED_QUOTA_PROVIDERS = new Set(['ollama-cloud', 'cursor']);
5
+ const MANAGED_QUOTA_PROVIDERS = new Set(['exe-dev', 'ollama-cloud', 'cursor']);
6
6
 
7
7
  const credentialsDirectory = () => path.join(
8
8
  process.env.OPENCHAMBER_DATA_DIR
@@ -10,12 +10,12 @@ process.env.OPENCHAMBER_DATA_DIR = temporaryDirectory;
10
10
 
11
11
  describe('quota credential store', () => {
12
12
  it('uses owner-only permissions and rejects arbitrary provider paths', () => {
13
- writeQuotaCredential('ollama-cloud', { cookie: 'secret' });
13
+ writeQuotaCredential('exe-dev', { usageToken: 'secret' });
14
14
  expect(fs.statSync(path.join(temporaryDirectory, 'quota')).mode & 0o777).toBe(0o700);
15
- expect(fs.statSync(path.join(temporaryDirectory, 'quota', 'ollama-cloud.json')).mode & 0o777).toBe(0o600);
16
- expect(readQuotaCredential('ollama-cloud', (value) => value)).toEqual({ cookie: 'secret' });
15
+ expect(fs.statSync(path.join(temporaryDirectory, 'quota', 'exe-dev.json')).mode & 0o777).toBe(0o600);
16
+ expect(readQuotaCredential('exe-dev', (value) => value)).toEqual({ usageToken: 'secret' });
17
17
  expect(() => writeQuotaCredential('../escape', {})).toThrow('Unsupported credential provider');
18
- deleteQuotaCredential('ollama-cloud');
18
+ deleteQuotaCredential('exe-dev');
19
19
  });
20
20
 
21
21
  it('removes the obsolete OpenCode Go credential without parsing it', () => {
@@ -0,0 +1,75 @@
1
+ import { readManagedCredential } from '../credentials/providers.js';
2
+ import { asObject, buildResult, formatMoney, toNumber, toTimestamp, toUsageWindow } from '../utils/index.js';
3
+
4
+ export const providerId = 'exe-dev';
5
+ export const providerName = 'exe.dev';
6
+ export const aliases = ['exe-dev'];
7
+ const EXEC_URL = 'https://exe.dev/exec';
8
+ const USAGE_COMMAND = 'billing credits usage --group=day --json';
9
+
10
+ export const parseExeDevUsage = (payload) => {
11
+ const data = asObject(payload);
12
+ if (!data) return null;
13
+
14
+ const totalCost = toNumber(data.total_cost_usd);
15
+ const monthlyAllowance = toNumber(data.monthly_allowance_usd);
16
+ const resetAt = toTimestamp(data.period_end);
17
+ if (totalCost === null || monthlyAllowance === null || monthlyAllowance < 0 || resetAt === null) return null;
18
+
19
+ const usedPercent = monthlyAllowance > 0
20
+ ? Math.min(100, Math.max(0, (totalCost / monthlyAllowance) * 100))
21
+ : null;
22
+ const spent = formatMoney(totalCost);
23
+ const allowance = formatMoney(monthlyAllowance);
24
+ if (spent === null || allowance === null) return null;
25
+
26
+ return {
27
+ monthly: toUsageWindow({
28
+ usedPercent,
29
+ windowSeconds: null,
30
+ resetAt,
31
+ valueLabel: `$${spent} / $${allowance}`,
32
+ }),
33
+ };
34
+ };
35
+
36
+ export const fetchExeDevUsage = async (credential, fetchImpl = fetch) => {
37
+ const response = await fetchImpl(EXEC_URL, {
38
+ method: 'POST',
39
+ headers: {
40
+ Accept: 'application/json',
41
+ Authorization: `Bearer ${credential.usageToken}`,
42
+ 'Content-Type': 'text/plain',
43
+ 'User-Agent': 'OpenChamber quota provider',
44
+ },
45
+ body: USAGE_COMMAND,
46
+ signal: AbortSignal.timeout(15_000),
47
+ });
48
+ if (response.status === 401 || response.status === 403) throw new Error('exe.dev authentication failed');
49
+ if (!response.ok) throw new Error(`exe.dev usage API returned HTTP ${response.status}`);
50
+ const windows = parseExeDevUsage(await response.json().catch(() => null));
51
+ if (!windows) throw new Error('exe.dev usage data could not be parsed');
52
+ return windows;
53
+ };
54
+
55
+ export const isConfigured = () => Boolean(readManagedCredential(providerId));
56
+
57
+ export const fetchQuota = async () => {
58
+ const credential = readManagedCredential(providerId);
59
+ if (!credential) {
60
+ return buildResult({ providerId, providerName, ok: false, configured: false, error: 'Not configured' });
61
+ }
62
+
63
+ try {
64
+ const windows = await fetchExeDevUsage(credential);
65
+ return buildResult({ providerId, providerName, ok: true, configured: true, usage: { windows } });
66
+ } catch (error) {
67
+ return buildResult({
68
+ providerId,
69
+ providerName,
70
+ ok: false,
71
+ configured: true,
72
+ error: error instanceof Error ? error.message : 'Request failed',
73
+ });
74
+ }
75
+ };
@@ -0,0 +1,47 @@
1
+ import { describe, expect, it } from 'bun:test';
2
+ import { fetchExeDevUsage, parseExeDevUsage } from './exe-dev.js';
3
+
4
+ const payload = {
5
+ allowance_spend_usd: 0.11,
6
+ extra_spend_usd: 0,
7
+ group: 'day',
8
+ month: '2026-09',
9
+ monthly_allowance_usd: 20,
10
+ period_end: '2026-10-01T00:00:00Z',
11
+ period_start: '2026-09-01T00:00:00Z',
12
+ total_cost_usd: 0.11,
13
+ total_requests: 17,
14
+ };
15
+
16
+ describe('exe.dev quota provider', () => {
17
+ it('parses monthly credit usage', () => {
18
+ const windows = parseExeDevUsage(payload);
19
+ expect(windows?.monthly.usedPercent).toBeCloseTo(0.55);
20
+ expect(windows?.monthly.valueLabel).toBe('$0.11 / $20.00');
21
+ expect(windows?.monthly.resetAt).toBe(Date.parse('2026-10-01T00:00:00Z'));
22
+ });
23
+
24
+ it('sends the scoped billing command without exposing the token elsewhere', async () => {
25
+ const requests = [];
26
+ const windows = await fetchExeDevUsage({ usageToken: 'test-token' }, async (url, init) => {
27
+ requests.push({ url, init });
28
+ return Response.json(payload);
29
+ });
30
+ expect(windows.monthly.valueLabel).toBe('$0.11 / $20.00');
31
+ expect(requests).toHaveLength(1);
32
+ expect(requests[0].url).toBe('https://exe.dev/exec');
33
+ expect(requests[0].init.method).toBe('POST');
34
+ expect(requests[0].init.body).toBe('billing credits usage --group=day --json');
35
+ expect(requests[0].init.headers.Authorization).toBe('Bearer test-token');
36
+ });
37
+
38
+ it('rejects malformed successful responses', async () => {
39
+ await expect(fetchExeDevUsage({ usageToken: 'test-token' }, async () => Response.json({})))
40
+ .rejects.toThrow('could not be parsed');
41
+ });
42
+
43
+ it('reports authentication failure without including the token', async () => {
44
+ await expect(fetchExeDevUsage({ usageToken: 'test-token' }, async () => new Response('', { status: 401 })))
45
+ .rejects.toThrow('exe.dev authentication failed');
46
+ });
47
+ });
@@ -13,6 +13,7 @@ import * as copilot from './copilot.js';
13
13
  import * as crof from './crof.js';
14
14
  import * as cursor from './cursor.js';
15
15
  import * as deepseek from './deepseek.js';
16
+ import * as exeDev from './exe-dev.js';
16
17
  import * as google from './google/index.js';
17
18
  import * as kimi from './kimi.js';
18
19
  import * as nanogpt from './nanogpt.js';
@@ -59,6 +60,12 @@ const registry = {
59
60
  isConfigured: deepseek.isConfigured,
60
61
  fetchQuota: deepseek.fetchQuota
61
62
  },
63
+ 'exe-dev': {
64
+ providerId: exeDev.providerId,
65
+ providerName: exeDev.providerName,
66
+ isConfigured: exeDev.isConfigured,
67
+ fetchQuota: exeDev.fetchQuota
68
+ },
62
69
  google: {
63
70
  providerId: google.providerId,
64
71
  providerName: google.providerName,
@@ -37,6 +37,7 @@ export const fetchOpenCodeGoUsage = async (apiKey, fetchImpl = fetch) => {
37
37
  headers: {
38
38
  Accept: 'application/json',
39
39
  Authorization: `Bearer ${apiKey}`,
40
+ 'x-opencode-session': 'openchamber-usage',
40
41
  'User-Agent': 'OpenChamber quota provider',
41
42
  },
42
43
  signal: AbortSignal.timeout(15_000),
@@ -43,7 +43,11 @@ describe('OpenCode Go quota provider', () => {
43
43
  return new Response(JSON.stringify({ usage: { rolling: { percent: 25, resetsAt: '2026-08-12T12:00:00.000Z' } } }));
44
44
  });
45
45
  expect(request.url).toBe('https://opencode.ai/zen/go/v1/usage');
46
- expect(request.options.headers).toMatchObject({ Accept: 'application/json', Authorization: 'Bearer secret' });
46
+ expect(request.options.headers).toMatchObject({
47
+ Accept: 'application/json',
48
+ Authorization: 'Bearer secret',
49
+ 'x-opencode-session': 'openchamber-usage',
50
+ });
47
51
  expect(request.options.headers.Cookie).toBeUndefined();
48
52
  expect(usage['5h'].usedPercent).toBe(25);
49
53
  });
@@ -2,8 +2,10 @@ import express from 'express';
2
2
  import { deleteManagedCredential, getManagedCredentialStatus, normalizers, readManagedCredential, writeManagedCredential } from './credentials/providers.js';
3
3
  import { fetchOllamaCloudUsage } from './providers/ollama-cloud.js';
4
4
  import { importCursorCredential, validateCursorCredential } from './providers/cursor.js';
5
+ import { fetchExeDevUsage } from './providers/exe-dev.js';
5
6
 
6
7
  const validators = {
8
+ 'exe-dev': fetchExeDevUsage,
7
9
  'ollama-cloud': fetchOllamaCloudUsage,
8
10
  cursor: validateCursorCredential,
9
11
  };
@@ -41,7 +41,7 @@ Relay is not a separate link format: it is one transport candidate inside the un
41
41
  Everything a client normally sends to the single OpenChamber origin:
42
42
  - **HTTP** — REST endpoints and proxied OpenCode SDK calls under `/api/*`, plus `/auth/*` and `/health`.
43
43
  - **SSE** — long-lived streamed responses (the event stream and notifications). These are just HTTP responses whose body streams; the tunnel needs no special SSE handling.
44
- - **WebSocket** — the endpoints that use a real socket (the global event stream on platforms that support WS, terminal I/O, dictation).
44
+ - **WebSocket** — the endpoints that use a real socket (the global event stream on platforms that support WS, terminal I/O, dictation, and desktop dev-server previews).
45
45
 
46
46
  The host dispatcher restricts tunneled traffic to explicit path allowlists (one for HTTP, one for WS).
47
47
 
@@ -33,7 +33,9 @@ const ALLOWED_WS_PATHS = new Set([
33
33
  '/api/event/ws',
34
34
  '/api/terminal/ws',
35
35
  '/api/dictation/ws',
36
+ '/api/dev-tunnel',
36
37
  ]);
38
+ export const isAllowedRelayWebSocketPath = (pathname) => ALLOWED_WS_PATHS.has(pathname);
37
39
 
38
40
  // Hop-by-hop headers stripped from tunneled requests; `host` is set by fetch
39
41
  // to the loopback origin. content-length is dropped too because the body is
@@ -425,7 +427,7 @@ export const createTunnelHost = ({ connectionId, getLocalPort, sendFrame, getBuf
425
427
  void sendAbort(streamId, error?.message ?? 'malformed ws open');
426
428
  return;
427
429
  }
428
- if (!ALLOWED_WS_PATHS.has(open.path)) {
430
+ if (!isAllowedRelayWebSocketPath(open.path)) {
429
431
  void sendAbort(streamId, 'Path is not allowed through the relay');
430
432
  return;
431
433
  }
@@ -1,7 +1,7 @@
1
1
  import { describe, test, expect } from 'bun:test';
2
2
  import http from 'node:http';
3
3
 
4
- import { createTunnelHost } from './tunnel-host.js';
4
+ import { createTunnelHost, isAllowedRelayWebSocketPath } from './tunnel-host.js';
5
5
  import { decodeTunnelFrame, encodeTunnelFrame, encodeJsonPayload, TunnelFrameType } from './tunnel-codec.js';
6
6
 
7
7
  const startLoopback = () =>
@@ -145,3 +145,11 @@ describe('tunnel-host HTTP body forwarding', () => {
145
145
  await loopback.stop();
146
146
  });
147
147
  });
148
+
149
+ describe('relay host WebSocket allowlist', () => {
150
+ test('allows only the exact dev-server tunnel path', () => {
151
+ expect(isAllowedRelayWebSocketPath('/api/dev-tunnel')).toBe(true);
152
+ expect(isAllowedRelayWebSocketPath('/api/dev-tunnel/')).toBe(false);
153
+ expect(isAllowedRelayWebSocketPath('/api/database/ws')).toBe(false);
154
+ });
155
+ });
@@ -67,6 +67,7 @@ export const createRequestSecurityRuntime = (deps) => {
67
67
 
68
68
  const getRequestOriginCandidates = async (req) => {
69
69
  const origins = new Set();
70
+ const hosts = new Set();
70
71
  const forwardedProto = typeof req.headers['x-forwarded-proto'] === 'string'
71
72
  ? req.headers['x-forwarded-proto'].split(',')[0].trim().toLowerCase()
72
73
  : '';
@@ -78,6 +79,7 @@ export const createRequestSecurityRuntime = (deps) => {
78
79
  const host = forwardedHost || (typeof req.headers.host === 'string' ? req.headers.host.trim() : '');
79
80
 
80
81
  if (host) {
82
+ hosts.add(host.toLowerCase());
81
83
  origins.add(`${protocol}://${host}`);
82
84
  const [hostname, port] = host.split(':');
83
85
  const normalizedHost = typeof hostname === 'string' ? hostname.toLowerCase() : '';
@@ -98,10 +100,10 @@ export const createRequestSecurityRuntime = (deps) => {
98
100
  } catch {
99
101
  }
100
102
 
101
- return origins;
103
+ return { origins, hosts };
102
104
  };
103
105
 
104
- const isRequestOriginAllowed = async (req) => {
106
+ const isRequestOriginAllowed = (req) => {
105
107
  const originHeader = typeof req.headers.origin === 'string' ? req.headers.origin.trim() : '';
106
108
  if (!originHeader) {
107
109
  return false;
@@ -111,15 +113,28 @@ export const createRequestSecurityRuntime = (deps) => {
111
113
  return true;
112
114
  }
113
115
 
114
- let normalizedOrigin = '';
116
+ let origin;
115
117
  try {
116
- normalizedOrigin = new URL(originHeader).origin;
118
+ origin = new URL(originHeader);
117
119
  } catch {
118
120
  return false;
119
121
  }
120
122
 
121
- const allowedOrigins = await getRequestOriginCandidates(req);
122
- return allowedOrigins.has(normalizedOrigin);
123
+ const forwardedHostHeader = req.headers['x-forwarded-host'];
124
+ const forwardedHost = (Array.isArray(forwardedHostHeader) ? forwardedHostHeader[0] : forwardedHostHeader || '')
125
+ .split(',')[0].trim().toLowerCase();
126
+ const hostHeader = req.headers.host;
127
+ const host = forwardedHost || (Array.isArray(hostHeader) ? hostHeader[0] : hostHeader || '').trim().toLowerCase();
128
+ if (host && host === origin.host.toLowerCase()) return true;
129
+
130
+ // TLS commonly ends at a cloud edge before an HTTP hop to OpenChamber.
131
+ // In that setup the browser's Origin is https while a generic reverse
132
+ // proxy reports the upstream request as http. The external host remains
133
+ // authoritative, so compare it directly instead of requiring the proxy to
134
+ // preserve the browser-facing protocol.
135
+ return getRequestOriginCandidates(req).then((candidates) => (
136
+ candidates.origins.has(origin.origin) || candidates.hosts.has(origin.host.toLowerCase())
137
+ ));
123
138
  };
124
139
 
125
140
  return {
@@ -9,41 +9,75 @@ describe('request security runtime', () => {
9
9
  test('allows packaged client origins for remote client transports', async () => {
10
10
  const runtime = createRuntime();
11
11
 
12
- await expect(runtime.isRequestOriginAllowed({
12
+ expect(await runtime.isRequestOriginAllowed({
13
13
  headers: {
14
14
  origin: 'openchamber-ui://app',
15
15
  host: '192.168.1.130:1202',
16
16
  },
17
17
  socket: {},
18
- })).resolves.toBe(true);
18
+ })).toBe(true);
19
19
 
20
- await expect(runtime.isRequestOriginAllowed({
20
+ expect(await runtime.isRequestOriginAllowed({
21
21
  headers: {
22
22
  origin: 'capacitor://localhost',
23
23
  host: '192.168.1.130:1202',
24
24
  },
25
25
  socket: {},
26
- })).resolves.toBe(true);
26
+ })).toBe(true);
27
27
 
28
28
  // Android Capacitor WebView (androidScheme 'https') reports this origin.
29
- await expect(runtime.isRequestOriginAllowed({
29
+ expect(await runtime.isRequestOriginAllowed({
30
30
  headers: {
31
31
  origin: 'https://localhost',
32
32
  host: '192.168.1.130:1202',
33
33
  },
34
34
  socket: {},
35
- })).resolves.toBe(true);
35
+ })).toBe(true);
36
36
  });
37
37
 
38
38
  test('rejects unknown origins', async () => {
39
39
  const runtime = createRuntime();
40
40
 
41
- await expect(runtime.isRequestOriginAllowed({
41
+ expect(await runtime.isRequestOriginAllowed({
42
42
  headers: {
43
43
  origin: 'https://evil.example.com',
44
44
  host: '192.168.1.130:1202',
45
45
  },
46
46
  socket: {},
47
- })).resolves.toBe(false);
47
+ })).toBe(false);
48
+ });
49
+
50
+ test('allows the external host when TLS terminates before an HTTP proxy hop', async () => {
51
+ const runtime = createRuntime();
52
+
53
+ expect(await runtime.isRequestOriginAllowed({
54
+ headers: {
55
+ origin: 'https://devchamber.example.com',
56
+ host: 'devchamber.example.com',
57
+ 'x-forwarded-proto': 'http',
58
+ },
59
+ socket: {},
60
+ })).toBe(true);
61
+ });
62
+
63
+ test('uses the forwarded external host without trusting a different origin', async () => {
64
+ const runtime = createRuntime();
65
+ const request = {
66
+ headers: {
67
+ host: '127.0.0.1:3000',
68
+ 'x-forwarded-host': 'devchamber.example.com',
69
+ 'x-forwarded-proto': 'http',
70
+ },
71
+ socket: {},
72
+ };
73
+
74
+ expect(await runtime.isRequestOriginAllowed({
75
+ ...request,
76
+ headers: { ...request.headers, origin: 'https://devchamber.example.com' },
77
+ })).toBe(true);
78
+ expect(await runtime.isRequestOriginAllowed({
79
+ ...request,
80
+ headers: { ...request.headers, origin: 'https://evil.example.com' },
81
+ })).toBe(false);
48
82
  });
49
83
  });
@@ -257,6 +257,7 @@ export const createSessionAssistRuntime = ({
257
257
  prompt: `The latest exchange in the conversation:\n\n${transcript}\n\nWrite ${requestedFields} in the SAME language as this sample from the conversation: "${languageSample}"`,
258
258
  system: buildAssistSystemPrompt(targets),
259
259
  directory,
260
+ sessionID: sessionId,
260
261
  preferredProviderID: typeof lastAssistantInfo.providerID === 'string' ? lastAssistantInfo.providerID : undefined,
261
262
  preferredModelID: typeof lastAssistantInfo.modelID === 'string' ? lastAssistantInfo.modelID : undefined,
262
263
  });
@@ -14,7 +14,7 @@ export const buildGoalIntroText = (tokenBudget) => {
14
14
  + '\n</system-reminder>';
15
15
  };
16
16
 
17
- const fitObjective = async ({ objective, directory, providerID, modelID, warn }) => {
17
+ const fitObjective = async ({ objective, directory, sessionID, providerID, modelID, warn }) => {
18
18
  if (objective.length <= GOAL_OBJECTIVE_CHAR_LIMIT) return objective;
19
19
 
20
20
  let distilled = null;
@@ -32,6 +32,7 @@ const fitObjective = async ({ objective, directory, providerID, modelID, warn })
32
32
  'Write in the same language as the task text.',
33
33
  ].join('\n'),
34
34
  directory,
35
+ sessionID,
35
36
  preferredProviderID: providerID,
36
37
  preferredModelID: modelID,
37
38
  });
@@ -66,6 +67,7 @@ export const createSessionGoal = async ({
66
67
  const objectiveText = await fitObjective({
67
68
  objective: String(objective ?? '').trim(),
68
69
  directory,
70
+ sessionID,
69
71
  providerID,
70
72
  modelID,
71
73
  warn,
@@ -378,6 +378,7 @@ export const createSessionGoalRuntime = ({
378
378
  prompt: `The goal objective:\n\n<objective>\n${goal.objective}\n</objective>\n\nThe agent's latest turn:\n\n${assistantText}\n\nReturn the verdict JSON. Write the note in the SAME language as this sample from the objective: "${goal.objective.slice(0, 200).replace(/\s+/g, ' ').trim()}"`,
379
379
  system: buildAuditSystemPrompt(),
380
380
  directory,
381
+ sessionID: typeof lastAssistantInfo?.sessionID === 'string' ? lastAssistantInfo.sessionID : undefined,
381
382
  preferredProviderID: typeof lastAssistantInfo?.providerID === 'string' ? lastAssistantInfo.providerID : undefined,
382
383
  preferredModelID: typeof lastAssistantInfo?.modelID === 'string' ? lastAssistantInfo.modelID : undefined,
383
384
  });