@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
package/dist/index.html CHANGED
@@ -509,16 +509,16 @@
509
509
  pointer-events: none;
510
510
  }
511
511
  </style>
512
- <script type="module" crossorigin src="/assets/main-D7fwjW2z.js"></script>
512
+ <script type="module" crossorigin src="/assets/main-DCB4JgVe.js"></script>
513
513
  <link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
514
514
  <link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
515
515
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
516
516
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
517
- <link rel="modulepreload" crossorigin href="/assets/vendor-zod-BLfBSgBh.js">
517
+ <link rel="modulepreload" crossorigin href="/assets/vendor-zod-DVWEh-IS.js">
518
518
  <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
519
- <link rel="modulepreload" crossorigin href="/assets/index-b0zDkWyg.js">
520
- <link rel="modulepreload" crossorigin href="/assets/contextPanelEmbeddedChat-BK78t3M_.js">
521
- <link rel="stylesheet" crossorigin href="/assets/index-C57jT0Sa.css">
519
+ <link rel="modulepreload" crossorigin href="/assets/index-DDInLQDd.js">
520
+ <link rel="modulepreload" crossorigin href="/assets/contextPanelEmbeddedChat-CV-DwAiX.js">
521
+ <link rel="stylesheet" crossorigin href="/assets/index-CHUT_bDS.css">
522
522
  </head>
523
523
  <body class="h-full bg-background text-foreground">
524
524
  <div id="root" class="h-full">
@@ -74,15 +74,15 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-D5rraz-g.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-BtV7N5OF.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
81
81
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
82
- <link rel="modulepreload" crossorigin href="/assets/vendor-zod-BLfBSgBh.js">
82
+ <link rel="modulepreload" crossorigin href="/assets/vendor-zod-DVWEh-IS.js">
83
83
  <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
84
- <link rel="modulepreload" crossorigin href="/assets/index-b0zDkWyg.js">
85
- <link rel="stylesheet" crossorigin href="/assets/index-C57jT0Sa.css">
84
+ <link rel="modulepreload" crossorigin href="/assets/index-DDInLQDd.js">
85
+ <link rel="stylesheet" crossorigin href="/assets/index-CHUT_bDS.css">
86
86
  </head>
87
87
  <body class="h-full bg-background text-foreground">
88
88
  <div id="root" class="h-full">
package/dist/mobile.html CHANGED
@@ -63,15 +63,15 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-Cg_DE3KL.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-DZV_sfX7.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
70
70
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
71
- <link rel="modulepreload" crossorigin href="/assets/vendor-zod-BLfBSgBh.js">
71
+ <link rel="modulepreload" crossorigin href="/assets/vendor-zod-DVWEh-IS.js">
72
72
  <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
73
- <link rel="modulepreload" crossorigin href="/assets/index-b0zDkWyg.js">
74
- <link rel="stylesheet" crossorigin href="/assets/index-C57jT0Sa.css">
73
+ <link rel="modulepreload" crossorigin href="/assets/index-DDInLQDd.js">
74
+ <link rel="stylesheet" crossorigin href="/assets/index-CHUT_bDS.css">
75
75
  </head>
76
76
  <body class="h-full bg-background text-foreground">
77
77
  <div id="root" class="h-full"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openchamber/web",
3
- "version": "1.22.0",
3
+ "version": "1.22.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@clack/prompts": "^1.1.0",
27
27
  "@octokit/rest": "^22.0.1",
28
- "@opencode-ai/sdk": "1.18.25",
28
+ "@opencode-ai/sdk": "1.18.28",
29
29
  "@simplewebauthn/server": "13.3.1",
30
30
  "bun-pty": "^0.4.5",
31
31
  "compression": "^1.8.1",
package/server/index.js CHANGED
@@ -91,6 +91,7 @@ import { createPushRuntime } from './lib/notifications/push-runtime.js';
91
91
  import { createApnsRuntime } from './lib/notifications/apns-runtime.js';
92
92
  import { createNotificationTemplateRuntime } from './lib/notifications/template-runtime.js';
93
93
  import { createPermissionAutoAcceptRuntime } from './lib/permission-auto-accept/runtime.js';
94
+ import { createMessageQueueRuntime } from './lib/message-queue/runtime.js';
94
95
  import { createGracefulShutdownRuntime } from './lib/opencode/shutdown-runtime.js';
95
96
  import { createProjectConfigRuntime } from './lib/projects/project-config.js';
96
97
  import { createProjectContextRuntime } from './lib/project-context/runtime.js';
@@ -110,6 +111,7 @@ import { createDevServerScanner } from './lib/dev-servers/routes.js';
110
111
  import { createDevTunnelRuntime } from './lib/dev-tunnel/runtime.js';
111
112
  import { registerBrowserControlRoutes } from './lib/browser-control/routes.js';
112
113
  import { createSystemPromptRuntime } from './lib/system-prompt/runtime.js';
114
+ import { createMcpReconnectRuntime } from './lib/mcp-reconnect/runtime.js';
113
115
  import { createOpenChamberSessionService } from './lib/openchamber-sessions/routes.js';
114
116
  import { createScheduledTaskService } from './lib/scheduled-tasks/service.js';
115
117
  import { createOpenChamberControlService } from './lib/openchamber-control/service.js';
@@ -284,6 +286,7 @@ const readCustomThemesFromDisk = (...args) => themeRuntime.readCustomThemesFromD
284
286
  let notificationTemplateRuntime = null;
285
287
  let agentToolRuntime = null;
286
288
  let systemPromptRuntime = null;
289
+ let mcpReconnectRuntime = null;
287
290
 
288
291
  const createTimeoutSignal = (...args) => notificationTemplateRuntime.createTimeoutSignal(...args);
289
292
  const formatProjectLabel = (...args) => notificationTemplateRuntime.formatProjectLabel(...args);
@@ -878,6 +881,19 @@ notificationTriggerRuntime.setGetIsSessionAutoAccepting(
878
881
  (sessionId, directory) => permissionAutoAcceptRuntime.isSessionAutoAccepting(sessionId, directory),
879
882
  );
880
883
 
884
+ // Queued follow-up messages are delivered by the server so a closed tab or a
885
+ // dropped connection no longer strands them (VS Code keeps its UI-side queue).
886
+ const messageQueueRuntime = createMessageQueueRuntime({
887
+ globalEventHub: globalMessageStreamHub,
888
+ buildOpenCodeUrl,
889
+ getOpenCodeAuthHeaders,
890
+ sessionKnowledgeRuntime,
891
+ broadcastGlobalUiEvent,
892
+ onPromptSent: (sessionId) => sessionRuntime.markUserMessageSent(sessionId),
893
+ dataDir: OPENCHAMBER_DATA_DIR,
894
+ });
895
+ messageQueueRuntime.start();
896
+
881
897
  const openCodeWatcherRuntime = createOpenCodeWatcherRuntime({
882
898
  waitForOpenCodePort: (...args) => waitForOpenCodePort(...args),
883
899
  buildOpenCodeUrl,
@@ -1208,11 +1224,15 @@ const openCodeLifecycleRuntime = createOpenCodeLifecycleRuntime({
1208
1224
  const managedEnv = includeControl || includeWeb || includeMemory
1209
1225
  ? await (agentToolRuntime?.prepareManagedOpenCodeEnv({ includeControl, includeWeb, includeMemory }) || {})
1210
1226
  : {};
1211
- if (settings?.optimizeSystemPrompt !== true) return managedEnv;
1212
1227
 
1213
- const configContent = managedEnv.OPENCODE_CONFIG_CONTENT ?? process.env.OPENCODE_CONFIG_CONTENT;
1214
- const systemPromptEnv = await systemPromptRuntime.prepareManagedOpenCodeEnv(configContent);
1215
- return { ...managedEnv, ...systemPromptEnv };
1228
+ // Each managed plugin appends itself to the config the previous one produced.
1229
+ let configContent = managedEnv.OPENCODE_CONFIG_CONTENT ?? process.env.OPENCODE_CONFIG_CONTENT;
1230
+ if (settings?.optimizeSystemPrompt === true) {
1231
+ ({ OPENCODE_CONFIG_CONTENT: configContent } = await systemPromptRuntime.prepareManagedOpenCodeEnv(configContent));
1232
+ }
1233
+ // Always on for managed OpenCode: it only retries servers OpenCode gave up on.
1234
+ const mcpReconnectEnv = await mcpReconnectRuntime.prepareManagedOpenCodeEnv(configContent);
1235
+ return { ...managedEnv, ...mcpReconnectEnv };
1216
1236
  },
1217
1237
  });
1218
1238
 
@@ -1427,6 +1447,7 @@ const gracefulShutdownRuntime = createGracefulShutdownRuntime({
1427
1447
  sessionAssistRuntime,
1428
1448
  sessionGoalRuntime,
1429
1449
  contextObligatoryRuntime,
1450
+ messageQueueRuntime,
1430
1451
  sessionRuntime,
1431
1452
  getHealthCheckInterval: () => healthCheckInterval,
1432
1453
  clearHealthCheckInterval: (value) => clearInterval(value),
@@ -1485,6 +1506,11 @@ async function main(options = {}) {
1485
1506
  path,
1486
1507
  dataDir: OPENCHAMBER_DATA_DIR,
1487
1508
  });
1509
+ mcpReconnectRuntime = createMcpReconnectRuntime({
1510
+ fsPromises,
1511
+ path,
1512
+ dataDir: OPENCHAMBER_DATA_DIR,
1513
+ });
1488
1514
 
1489
1515
  // Pairing transports advertised to the create-device dialog. LAN reachability is
1490
1516
  // derived from the SERVER's actual bind (a wildcard bind → the machine's LAN IP;
@@ -1914,6 +1940,7 @@ async function main(options = {}) {
1914
1940
  getOpenChamberEventClients: () => uiOpenChamberEventClients,
1915
1941
  writeSseEvent,
1916
1942
  permissionAutoAcceptRuntime,
1943
+ messageQueueRuntime,
1917
1944
  });
1918
1945
 
1919
1946
  const startupPipelineResult = await startupPipelineRuntime.run({
@@ -1,5 +1,5 @@
1
- import { parse as parseJsonc } from 'jsonc-parser';
2
1
  import { pathToFileURL } from 'node:url';
2
+ import { appendManagedPlugin } from '../opencode/managed-plugin-config.js';
3
3
  import {
4
4
  OPENCHAMBER_AGENT_TOOL_ACTION_DEFINITIONS,
5
5
  OPENCHAMBER_AGENT_TOOL_ACTIONS,
@@ -252,23 +252,6 @@ ${entries.join('')} },
252
252
  `;
253
253
  };
254
254
 
255
- const mergePluginConfig = (rawConfig, pluginUrl) => {
256
- const errors = [];
257
- const parsed = asNonEmptyString(rawConfig) ? parseJsonc(rawConfig, errors, { allowTrailingComma: true }) : {};
258
- if (errors.length > 0 || !parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
259
- throw new Error('OPENCODE_CONFIG_CONTENT must contain a valid JSON object before OpenChamber can inject its managed tool');
260
- }
261
- if (parsed.plugin !== undefined && !Array.isArray(parsed.plugin)) {
262
- throw new Error('OPENCODE_CONFIG_CONTENT plugin must be an array before OpenChamber can inject its managed tool');
263
- }
264
- const configured = Array.isArray(parsed.plugin) ? parsed.plugin : [];
265
- parsed.plugin = [
266
- ...configured.filter((value) => value !== pluginUrl && (!Array.isArray(value) || value[0] !== pluginUrl)),
267
- pluginUrl,
268
- ];
269
- return JSON.stringify(parsed);
270
- };
271
-
272
255
  export const createAgentToolRuntime = (dependencies) => {
273
256
  const {
274
257
  crypto,
@@ -296,7 +279,7 @@ export const createAgentToolRuntime = (dependencies) => {
296
279
  activeToken = crypto.randomBytes(32).toString('base64url');
297
280
  const pluginUrl = pathToFileURL(pluginPath).href;
298
281
  return {
299
- OPENCODE_CONFIG_CONTENT: mergePluginConfig(env.OPENCODE_CONFIG_CONTENT, pluginUrl),
282
+ OPENCODE_CONFIG_CONTENT: appendManagedPlugin(env.OPENCODE_CONFIG_CONTENT, pluginUrl, 'managed tool'),
300
283
  OPENCHAMBER_AGENT_TOOL_URL: `http://127.0.0.1:${port}/api/openchamber/agent-tool`,
301
284
  OPENCHAMBER_AGENT_TOOL_TOKEN: activeToken,
302
285
  };
@@ -20,7 +20,13 @@ and what made it fragile per framework.
20
20
  - `client.js` is the local end: it binds a loopback listener on the user's
21
21
  machine and pipes each accepted connection through one WebSocket. It lives in
22
22
  this package because it needs a WebSocket client the package already depends
23
- on; the desktop shell drives it over IPC.
23
+ on; the desktop shell drives it over IPC for directly reachable HTTP(S)
24
+ runtimes.
25
+ - Relay-only runtimes use `packages/electron/relay-dev-tunnel.mjs` for the local
26
+ listener. Each accepted connection gets an Electron `MessagePort`; the trusted
27
+ renderer carries its bytes through the active E2EE relay. This keeps relay
28
+ credentials and encryption in their existing renderer owner instead of
29
+ duplicating them in Electron main.
24
30
  - Port discovery is not owned here. `runtime.js` is given the reachable set by
25
31
  the same dev-server discovery the user's own list is built from.
26
32
  - The browser panel decides when to tunnel; this module never chooses a target.
@@ -40,9 +46,12 @@ and what made it fragile per framework.
40
46
  usual origin allowlist applies unchanged. That check is a CSRF defence: a
41
47
  hostile page can make a browser open a WebSocket carrying ambient cookies,
42
48
  and the origin is what exposes it.
43
- - With no `Origin` the request must carry client-token auth. A browser cannot
44
- reach this path — the WebSocket API always sends an origin and never lets a
45
- page set an `Authorization` header — so this case is the desktop shell.
49
+ - With no `Origin` the request must carry client-token auth or a short-lived
50
+ URL token. The bearer case is the desktop main process. The URL-token case
51
+ is the trusted renderer carrying the socket through the E2EE relay.
52
+ - Through the E2EE relay, the trusted renderer mints a short-lived URL token
53
+ and includes it in the virtual WebSocket URL. The relay host and URL-token
54
+ allowlists accept exactly `/api/dev-tunnel`, not subpaths.
46
55
  - Concurrency is capped per host, not per page, because one page load opens
47
56
  many sockets.
48
57
  - A connection that cannot be established fails the socket rather than holding
@@ -20,9 +20,9 @@
20
20
  *
21
21
  * - With an `Origin` header, the request came from a browser context and the
22
22
  * usual origin check applies unchanged.
23
- * - With no `Origin`, the request must carry client-token auth. A browser
24
- * cannot reach this path: the WebSocket API always sends an origin and never
25
- * lets a page set an `Authorization` header.
23
+ * - With no `Origin`, the request must carry client-token auth or a short-lived
24
+ * URL token. The URL-token case is used only by the trusted renderer through
25
+ * the E2EE relay; the UI-auth allowlist limits it to this exact path.
26
26
  */
27
27
  import net from 'node:net';
28
28
  import { WebSocketServer } from 'ws';
@@ -133,7 +133,7 @@ export function createDevTunnelRuntime({
133
133
  void (async () => {
134
134
  try {
135
135
  if (uiAuthController?.enabled) {
136
- const auth = await uiAuthController.resolveAuthContext(req, null, { allowUrlToken: false });
136
+ const auth = await uiAuthController.resolveAuthContext(req, null, { allowUrlToken: true });
137
137
  if (!auth) {
138
138
  rejectWebSocketUpgrade(socket, 401, 'UI authentication required');
139
139
  return;
@@ -1,6 +1,7 @@
1
1
  import { afterEach, describe, expect, test } from 'bun:test';
2
2
  import http from 'node:http';
3
3
  import net from 'node:net';
4
+ import WebSocket from 'ws';
4
5
 
5
6
  import { createDevTunnelClient } from './client.js';
6
7
  import { createDevTunnelRuntime, isDevTunnelPath } from './runtime.js';
@@ -228,6 +229,12 @@ describe('dev tunnel authentication', () => {
228
229
  enabled: true,
229
230
  resolveAuthContext: async () => ({ type: 'session' }),
230
231
  };
232
+ const urlTokenAuth = {
233
+ enabled: true,
234
+ resolveAuthContext: async (req, _res, options) => (
235
+ options?.allowUrlToken === true && req.url.includes('oc_url_token=good') ? { type: 'client', token: 'url:authenticated' } : null
236
+ ),
237
+ };
231
238
 
232
239
  test('accepts a bearer-authenticated client that sends no origin', async () => {
233
240
  const devPort = await startDevServer((_req, res) => res.end('ok'));
@@ -243,6 +250,19 @@ describe('dev tunnel authentication', () => {
243
250
  expect((await httpGet(localPort, '/')).body).toBe('ok');
244
251
  });
245
252
 
253
+ test('accepts a URL-token client carried by the E2EE relay', async () => {
254
+ const devPort = await startDevServer((_req, res) => res.end('relay-ok'));
255
+ const host = await startHost({ allowedPorts: [devPort], auth: urlTokenAuth });
256
+
257
+ const body = await new Promise((resolve, reject) => {
258
+ const socket = new WebSocket(`ws://127.0.0.1:${host.port}/api/dev-tunnel?port=${devPort}&oc_url_token=good`);
259
+ socket.on('open', () => socket.send('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n'));
260
+ socket.on('message', (data) => resolve(Buffer.from(data).toString()));
261
+ socket.on('error', reject);
262
+ });
263
+ expect(body).toContain('relay-ok');
264
+ });
265
+
246
266
  test('rejects a client with no credentials', async () => {
247
267
  const devPort = await startDevServer((_req, res) => res.end('ok'));
248
268
  const host = await startHost({ allowedPorts: [devPort], auth: clientAuth });
@@ -39,6 +39,7 @@ The following functions are exported and used by the web server:
39
39
 
40
40
  ### Branch Operations
41
41
  - `getBranches(directory)`: Get list of local and remote branches (filtered to active remote branches).
42
+ - `getUnpushedBranchCounts(directory, branchNames)`: Count commits ahead of each locally known upstream for up to five supplied local branches. This reads local refs only and omits branches without an upstream.
42
43
  - `createBranch(directory, branchName, options)`: Create and checkout a new branch.
43
44
  - `checkoutBranch(directory, branchName)`: Checkout an existing branch. A remote-tracking name (`origin/main`, or the `remotes/`-prefixed form) resolves to the local branch of that name, created with `--track` when it does not exist yet, because the branch selector offers remote branches as places to work rather than commits to inspect — a literal checkout of the remote ref would detach HEAD. A local branch whose own name looks like a remote ref wins over that resolution, and anything unresolvable is checked out as requested. The returned `branch` is the branch that was actually checked out, which callers should report instead of the requested name.
44
45
  - `deleteBranch(directory, branch, options)`: Delete a branch (supports force flag).
@@ -48,7 +49,7 @@ The following functions are exported and used by the web server:
48
49
  ### Worktree Operations
49
50
  - `getWorktrees(directory)`: List all git worktrees for a repository.
50
51
  - `validateWorktreeCreate(directory, input)`: Validate worktree creation parameters (mode, branchName, startRef, upstream config).
51
- - `createWorktree(directory, input)`: Create a new worktree (supports 'new' and 'existing' modes, upstream setup). After populating the worktree, the repository's `post-checkout` hook runs once with git's standard arguments (null ref as previous HEAD, the checked-out HEAD, and flag `1`) from the worktree directory, mirroring `git worktree add` without `--no-checkout`; a missing or non-executable hook is skipped and a failing hook is logged as a warning, never failing worktree creation or the session bootstrap.
52
+ - `createWorktree(directory, input)`: Create a new worktree (supports 'new' and 'existing' modes, upstream setup). When the current tracked branch has no unpublished commits, the UI supplies its remote-tracking ref and this operation fetches that branch once before creating the worktree. A failed fetch falls back to the local branch and reports `sourceFetchFailed`; other remote start refs still require an existing local ref when their fetch fails. After populating the worktree, the repository's `post-checkout` hook runs once with git's standard arguments (null ref as previous HEAD, the checked-out HEAD, and flag `1`) from the worktree directory, mirroring `git worktree add` without `--no-checkout`; a missing or non-executable hook is skipped and a failing hook is logged as a warning, never failing worktree creation or the session bootstrap.
52
53
  - `removeWorktree(directory, input)`: Remove a worktree (optionally delete local branch).
53
54
  - `isLinkedWorktree(directory)`: Check if directory is a linked worktree (not primary).
54
55
 
@@ -142,6 +143,7 @@ The following functions are internal helpers used by exported functions:
142
143
  - `path`: Absolute path to worktree directory.
143
144
  - `directoryCreated`: Present when create returned after the target directory exists while background Git/bootstrap work continues.
144
145
  - `bootstrapStatus`: Background setup state. The legacy `status` remains `pending`, `ready`, or `failed`, while `phase` reports `directory-created`, `git-ready`, or `setup-ready`. Fast create starts at `pending`/`directory-created`; population and upstream Git completion advances to `pending`/`git-ready` before setup/start scripts; completed setup is `ready`/`setup-ready`. A missing in-memory state falls back to `ready`/`setup-ready`; clients continue to accept legacy status responses that omit `phase`.
146
+ - `sourceFetchFailed`: Present when the automatic source-branch fetch failed and creation fell back to the tracked local branch.
145
147
  - Fast-create background failures remove OpenCode sandbox metadata for directories that never became Git worktrees, and remove the pre-created directory only if it is still empty. User-created files are never recursively deleted by this cleanup.
146
148
  - Worktree removal waits for any active create/bootstrap task for that directory before deleting it, preventing a background Git or setup task from restoring removed state or racing filesystem cleanup.
147
149
  - Worktree bootstrap retries transient `index.lock` conflicts. If the lock remains byte-for-byte and metadata-identical across the retry window, it is treated as stale, removed, and population continues automatically; changing locks are left untouched and reported as failures.
@@ -873,6 +873,22 @@ export function registerGitRoutes(app) {
873
873
  }
874
874
  });
875
875
 
876
+ app.post('/api/git/branch-push-status', async (req, res) => {
877
+ const { getUnpushedBranchCounts } = await getGitLibraries();
878
+ try {
879
+ const directory = req.query.directory;
880
+ const branches = req.body?.branches;
881
+ if (!directory) return res.status(400).json({ error: 'directory parameter is required' });
882
+ if (!Array.isArray(branches) || branches.some((branch) => typeof branch !== 'string')) {
883
+ return res.status(400).json({ error: 'branches must be an array of branch names' });
884
+ }
885
+ res.json(await getUnpushedBranchCounts(directory, branches));
886
+ } catch (error) {
887
+ console.error('Failed to get branch push status:', error);
888
+ res.status(500).json({ error: error.message || 'Failed to get branch push status' });
889
+ }
890
+ });
891
+
876
892
  app.post('/api/git/branches', async (req, res) => {
877
893
  const { createBranch } = await getGitLibraries();
878
894
  try {
@@ -3687,6 +3687,35 @@ export async function getBranches(directory) {
3687
3687
  }
3688
3688
  }
3689
3689
 
3690
+ /**
3691
+ * Counts locally unpushed commits for a small caller-supplied set of local
3692
+ * branches. This deliberately reads only local refs: the branch picker calls
3693
+ * it when opened, never polls, and never fetches a remote behind the user's
3694
+ * back. Unknown, remote, and upstream-less branches are omitted.
3695
+ */
3696
+ export async function getUnpushedBranchCounts(directory, branchNames) {
3697
+ const { git } = await createRepositoryGitContext(directory);
3698
+ const requested = [...new Set(Array.isArray(branchNames) ? branchNames : [])]
3699
+ .filter((name) => typeof name === 'string' && name.length > 0)
3700
+ .slice(0, 5);
3701
+ if (requested.length === 0) return { counts: {} };
3702
+
3703
+ const local = new Set((await git.branchLocal()).all);
3704
+ const counts = {};
3705
+ await Promise.all(requested.map(async (branch) => {
3706
+ if (!local.has(branch)) return;
3707
+ const upstream = await git.raw(['rev-parse', '--abbrev-ref', '--symbolic-full-name', `${branch}@{upstream}`])
3708
+ .then((value) => value.trim())
3709
+ .catch(() => '');
3710
+ if (!upstream) return;
3711
+ const count = await git.raw(['rev-list', '--count', `${upstream}..${branch}`])
3712
+ .then((value) => Number.parseInt(value.trim(), 10))
3713
+ .catch(() => 0);
3714
+ if (Number.isFinite(count) && count > 0) counts[branch] = count;
3715
+ }));
3716
+ return { counts };
3717
+ }
3718
+
3690
3719
  async function getRemoteDefaultBranches(git) {
3691
3720
  let defaults = {};
3692
3721
 
@@ -4266,6 +4295,7 @@ async function attachGitWorktreeToCandidate(context, candidate, input = {}) {
4266
4295
 
4267
4296
  const parsedRemoteStartRef = await resolveRemoteBranchRef(context.primaryWorktree, startRef);
4268
4297
  if (parsedRemoteStartRef) {
4298
+ worktreeAddArgs.splice(2, 0, '--no-track');
4269
4299
  inferredUpstream = {
4270
4300
  remote: parsedRemoteStartRef.remote,
4271
4301
  branch: parsedRemoteStartRef.branch,
@@ -4273,24 +4303,17 @@ async function attachGitWorktreeToCandidate(context, candidate, input = {}) {
4273
4303
  }
4274
4304
  }
4275
4305
 
4276
- if (ensureRemoteName && ensureRemoteUrl) {
4306
+ if (mode === 'existing' && ensureRemoteName && ensureRemoteUrl) {
4277
4307
  await ensureRemoteWithUrl(context.primaryWorktree, ensureRemoteName, ensureRemoteUrl);
4278
4308
  }
4279
4309
 
4280
- if (mode === 'new') {
4281
- const parsedRemoteStartRef = await resolveRemoteBranchRef(context.primaryWorktree, startRef);
4282
- if (parsedRemoteStartRef) {
4283
- await fetchRemoteBranchRef(context.primaryWorktree, parsedRemoteStartRef.remote, parsedRemoteStartRef.branch);
4284
- }
4285
- }
4286
-
4287
4310
  await runGitCommandOrThrow(context.primaryWorktree, worktreeAddArgs, 'Failed to create git worktree');
4288
4311
 
4289
4312
  const upstreamRemote = shouldSetUpstream
4290
- ? String(inferredUpstream?.remote || input?.upstreamRemote || '').trim()
4313
+ ? String(input?.upstreamRemote || inferredUpstream?.remote || '').trim()
4291
4314
  : '';
4292
4315
  const upstreamBranch = shouldSetUpstream
4293
- ? String(inferredUpstream?.branch || input?.upstreamBranch || '').trim()
4316
+ ? String(input?.upstreamBranch || inferredUpstream?.branch || '').trim()
4294
4317
  : '';
4295
4318
 
4296
4319
  const bootstrapStatus = setWorktreeBootstrapState(
@@ -4325,6 +4348,50 @@ async function attachGitWorktreeToCandidate(context, candidate, input = {}) {
4325
4348
  };
4326
4349
  }
4327
4350
 
4351
+ const prepareWorktreeCreateSource = async (context, input = {}) => {
4352
+ if (input?.mode === 'existing') {
4353
+ return { input, sourceFetchFailed: false };
4354
+ }
4355
+
4356
+ const startRef = normalizeStartRef(input?.startRef);
4357
+ const remoteStartRef = await resolveRemoteBranchRef(context.primaryWorktree, startRef);
4358
+ if (!remoteStartRef) {
4359
+ return { input, sourceFetchFailed: false };
4360
+ }
4361
+
4362
+ const status = await getStatus(context.primaryWorktree, { mode: 'light' }).catch(() => null);
4363
+ const trackingRef = status?.tracking
4364
+ ? await resolveRemoteBranchRef(context.primaryWorktree, status.tracking)
4365
+ : null;
4366
+ const canFallbackToLocal = Boolean(
4367
+ status?.current
4368
+ && status.ahead === 0
4369
+ && trackingRef?.fullRef === remoteStartRef.fullRef
4370
+ );
4371
+
4372
+ try {
4373
+ await fetchRemoteBranchRef(context.primaryWorktree, remoteStartRef.remote, remoteStartRef.branch);
4374
+ return { input, sourceFetchFailed: false };
4375
+ } catch (error) {
4376
+ if (canFallbackToLocal) {
4377
+ return {
4378
+ input: { ...input, startRef: status.current },
4379
+ sourceFetchFailed: true,
4380
+ };
4381
+ }
4382
+
4383
+ const refExists = await runGitCommand(
4384
+ context.primaryWorktree,
4385
+ ['show-ref', '--verify', '--quiet', remoteStartRef.fullRef]
4386
+ );
4387
+ if (!refExists.success) {
4388
+ throw error;
4389
+ }
4390
+ console.warn(`Worktree create: failed to refresh ${remoteStartRef.remote}/${remoteStartRef.branch}, proceeding with the existing remote-tracking ref`);
4391
+ return { input, sourceFetchFailed: false };
4392
+ }
4393
+ };
4394
+
4328
4395
  export async function createWorktree(directory, input = {}) {
4329
4396
  const mode = input?.mode === 'existing' ? 'existing' : 'new';
4330
4397
  const context = await resolveWorktreeProjectContext(directory);
@@ -4333,10 +4400,18 @@ export async function createWorktree(directory, input = {}) {
4333
4400
  await assertWorktreeCreatePreflight(directory, input);
4334
4401
  }
4335
4402
 
4403
+ const ensureRemoteName = String(input?.ensureRemoteName || '').trim();
4404
+ const ensureRemoteUrl = String(input?.ensureRemoteUrl || '').trim();
4405
+ if (ensureRemoteName && ensureRemoteUrl) {
4406
+ await ensureRemoteWithUrl(context.primaryWorktree, ensureRemoteName, ensureRemoteUrl);
4407
+ }
4408
+ const prepared = await prepareWorktreeCreateSource(context, input);
4409
+ const preparedInput = prepared.input;
4410
+
4336
4411
  await fsp.mkdir(context.worktreeRoot, { recursive: true });
4337
4412
 
4338
- const preferredName = String(input?.worktreeName || input?.name || '').trim();
4339
- const preferredBranchName = cleanBranchName(String(input?.branchName || '').trim());
4413
+ const preferredName = String(preparedInput?.worktreeName || preparedInput?.name || '').trim();
4414
+ const preferredBranchName = cleanBranchName(String(preparedInput?.branchName || '').trim());
4340
4415
 
4341
4416
  const candidate = await resolveCandidateDirectory(
4342
4417
  context.worktreeRoot,
@@ -4345,7 +4420,7 @@ export async function createWorktree(directory, input = {}) {
4345
4420
  context.primaryWorktree
4346
4421
  );
4347
4422
 
4348
- if (input?.returnAfterDirectoryCreated === true) {
4423
+ if (preparedInput?.returnAfterDirectoryCreated === true) {
4349
4424
  await fsp.mkdir(candidate.directory, { recursive: false });
4350
4425
 
4351
4426
  const bootstrapStatus = setWorktreeBootstrapState(
@@ -4354,10 +4429,10 @@ export async function createWorktree(directory, input = {}) {
4354
4429
  WORKTREE_BOOTSTRAP_PHASE_DIRECTORY_CREATED
4355
4430
  );
4356
4431
  const localBranch = mode === 'existing'
4357
- ? cleanBranchName(String(input?.branchName || input?.existingBranch || candidate.branch || '').trim())
4432
+ ? cleanBranchName(String(preparedInput?.branchName || preparedInput?.existingBranch || candidate.branch || '').trim())
4358
4433
  : candidate.branch;
4359
4434
 
4360
- const task = attachGitWorktreeToCandidate(context, candidate, input).catch(async (error) => {
4435
+ const task = attachGitWorktreeToCandidate(context, candidate, preparedInput).catch(async (error) => {
4361
4436
  setWorktreeBootstrapState(
4362
4437
  candidate.directory,
4363
4438
  WORKTREE_BOOTSTRAP_FAILED,
@@ -4369,7 +4444,7 @@ export async function createWorktree(directory, input = {}) {
4369
4444
  });
4370
4445
  trackWorktreeBootstrapTask(candidate.directory, task);
4371
4446
 
4372
- return {
4447
+ const result = {
4373
4448
  head: '',
4374
4449
  name: candidate.name,
4375
4450
  branch: localBranch,
@@ -4377,9 +4452,14 @@ export async function createWorktree(directory, input = {}) {
4377
4452
  directoryCreated: true,
4378
4453
  bootstrapStatus,
4379
4454
  };
4455
+ if (prepared.sourceFetchFailed) {
4456
+ result.sourceFetchFailed = true;
4457
+ }
4458
+ return result;
4380
4459
  }
4381
4460
 
4382
- return attachGitWorktreeToCandidate(context, candidate, input);
4461
+ const result = await attachGitWorktreeToCandidate(context, candidate, preparedInput);
4462
+ return prepared.sourceFetchFailed ? { ...result, sourceFetchFailed: true } : result;
4383
4463
  }
4384
4464
 
4385
4465
  export async function getWorktreeBootstrapStatus(directory) {