@openchamber/web 2.0.0 → 2.0.2
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.
- package/dist/assets/{CodeMirrorCommentWidgets-hJbl3JX4.js → CodeMirrorCommentWidgets-CmKmyb9T.js} +1 -1
- package/dist/assets/DiffView-8-PFpZ2p.js +4 -0
- package/dist/assets/FilesView-0Ie20mEk.js +17 -0
- package/dist/assets/{GitView-DY4pelsO.js → GitView-DNUSu00w.js} +4 -4
- package/dist/assets/{GuestAttachDialog-D6mHDTB2.js → GuestAttachDialog-Cv6QzjHC.js} +1 -1
- package/dist/assets/GuestSurfacePane-Bt3jB_Ye.js +1 -0
- package/dist/assets/{JsonTreeView-DEXI2NvJ.js → JsonTreeView-BlyHTRhM.js} +1 -1
- package/dist/assets/{LinearIssuesView-BTNc-4dN.js → LinearIssuesView-CSl2MUfA.js} +1 -1
- package/dist/assets/MarkdownImageGallery-2UXJF-5B.js +1 -0
- package/dist/assets/MarkdownRendererImpl-DVHqZoug.js +12 -0
- package/dist/assets/{OnboardingScreen-FJUreEgI.js → OnboardingScreen-CIdXJpfc.js} +1 -1
- package/dist/assets/{PatchDiff-C0oOkKnO.js → PatchDiff-ByvnbG5T.js} +1 -1
- package/dist/assets/{PierreDiffViewer-asuSQAsf.js → PierreDiffViewer-BXieg0mH.js} +3 -3
- package/dist/assets/{PlanView-DGbasNHP.js → PlanView-DEIi3Q7M.js} +4 -4
- package/dist/assets/PluginPane-BEPUWVho.js +3 -0
- package/dist/assets/SettingsView-CiNh-RbW.js +30 -0
- package/dist/assets/{SettingsWindow-By4cqnqy.js → SettingsWindow-BIz224xs.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-C0P2tXLU.js → SubmoduleDiffSummary-CXKmlps9.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Cayc-yIM.js → ToolOutputDialog-BsgAK8xu.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-B0jmpPQz.js → ToolPartDiffPreview-vdPObXOf.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-DsOpvWZD.js → VirtualizedFileDiff-BkFNKWS5.js} +1 -1
- package/dist/assets/{WalkthroughView-CCakjyn9.js → WalkthroughView-6oE-MuDL.js} +2 -2
- package/dist/assets/{appThemeRegistry-Bw5oTm41.js → appThemeRegistry-aHUNHoqP.js} +1 -1
- package/dist/assets/changesTree-CePHbFcj.js +1 -0
- package/dist/assets/commitAndPush-Bon9r94r.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-B-4aLf4A.js → computeVirtualFileMetrics-DKqr_1AQ.js} +2 -2
- package/dist/assets/de-CgAJ51z7.js +10 -0
- package/dist/assets/es-zGi_ravM.js +16 -0
- package/dist/assets/fr-CPfogrWx.js +14 -0
- package/dist/assets/index-CHfphYL3.js +41 -0
- package/dist/assets/{index-B6r0Kv-B.js → index-DpFttslC.js} +1 -1
- package/dist/assets/index-DvMJ3w6V.css +1 -0
- package/dist/assets/{isDiffPlainText-Ok-kgtJA.js → isDiffPlainText-kzAgpIgi.js} +1 -1
- package/dist/assets/{isFilePlainText-0dLnkYm8.js → isFilePlainText-Uj6y-jzz.js} +1 -1
- package/dist/assets/ja-DMk6wd-U.js +16 -0
- package/dist/assets/ko-BFpzJ8jc.js +16 -0
- package/dist/assets/{main-CjXBM_Xe.js → main-CbfMxn-I.js} +2 -2
- package/dist/assets/main-anyZFMIs.js +896 -0
- package/dist/assets/{markdown-shiki.worker-CahLvHIq.js → markdown-shiki.worker-Bg8SoAJJ.js} +8 -5
- package/dist/assets/markdownCore-CmM47cAE.js +7 -0
- package/dist/assets/{miniChat-DZ3OAeLN.js → miniChat-CiAKBC10.js} +2 -2
- package/dist/assets/{mobile-CH0LOIF-.js → mobile-CsT4sJwC.js} +2 -2
- package/dist/assets/patchFileDiff-DeaE08W0.js +13 -0
- package/dist/assets/pl-VdRPcZrB.js +16 -0
- package/dist/assets/pt-BR-BRys_lOW.js +16 -0
- package/dist/assets/{renderElectronMiniChatApp-CB1uLYvh.js → renderElectronMiniChatApp-C5677jy0.js} +2 -2
- package/dist/assets/renderMobileApp-D4dBBAqQ.js +25 -0
- package/dist/assets/runtimeEndpointReset-5r0hkd-2.js +27 -0
- package/dist/assets/scheduledTasksApi-BZCNJ588.js +1 -0
- package/dist/assets/{shikiHighlight-CocY80VR.js → shikiHighlight-BSUEa3yF.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-CF77r8FA.js → textMateThemeFromAppTheme-CsATFZIV.js} +1 -1
- package/dist/assets/tr-CA9ckNnm.js +7 -0
- package/dist/assets/uk-byjR-y8D.js +16 -0
- package/dist/assets/{useAppFontEffects-Dc5nTHi8.js → useAppFontEffects-BWQZ5DeI.js} +161 -157
- package/dist/assets/{useInlineCommentController-Dbza5c8l.js → useInlineCommentController-DlFyVfBu.js} +2 -2
- package/dist/assets/{useRootScrollLock-CSCLv396.js → useRootScrollLock-Cp1eFoM2.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-CkmYWcRI.js → vendor-codemirror-language-data-BwwommM0.js} +2 -2
- package/dist/assets/{vendor-opencode-client-_BAHQo4R.js → vendor-opencode-client-DYdsLbCM.js} +2 -2
- package/dist/assets/vendor-zod-BSoePkpP.js +39 -0
- package/dist/assets/{web-components-nsStrYq9.js → web-components-D3Yjr4Zx.js} +1 -1
- package/dist/assets/zh-CN-DRabgxdG.js +16 -0
- package/dist/assets/zh-TW-rbY5c9UK.js +16 -0
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +4 -4
- package/server/index.js +82 -0
- package/server/lib/agent-tool/DOCUMENTATION.md +5 -0
- package/server/lib/agent-tool/runtime.js +34 -6
- package/server/lib/agent-tool/runtime.test.js +15 -0
- package/server/lib/browser-control/DOCUMENTATION.md +14 -2
- package/server/lib/event-stream/global-hub.js +23 -1
- package/server/lib/event-stream/global-hub.test.js +35 -0
- package/server/lib/event-stream/global-ws-bridge.js +3 -1
- package/server/lib/event-stream/upstream-reader.js +3 -2
- package/server/lib/git/DOCUMENTATION.md +1 -1
- package/server/lib/git/service.js +22 -0
- package/server/lib/git/service.test.js +8 -0
- package/server/lib/guests/DOCUMENTATION.md +4 -3
- package/server/lib/guests/catalog.js +19 -1
- package/server/lib/guests/catalog.test.js +22 -0
- package/server/lib/guests/html-styles.js +5 -3
- package/server/lib/guests/html-styles.test.js +3 -1
- package/server/lib/guests/routes.js +11 -3
- package/server/lib/guests/service.js +5 -0
- package/server/lib/guests/surface.js +55 -9
- package/server/lib/guests/surface.test.js +56 -6
- package/server/lib/notifications/DOCUMENTATION.md +10 -0
- package/server/lib/notifications/emit-route.js +118 -0
- package/server/lib/notifications/emit-route.test.js +112 -0
- package/server/lib/openchamber-control/actions.js +16 -2
- package/server/lib/openchamber-control/service.js +23 -0
- package/server/lib/openchamber-control/service.test.js +31 -0
- package/server/lib/openchamber-sessions/fork-inheritance.js +103 -0
- package/server/lib/openchamber-sessions/fork-inheritance.test.js +69 -0
- package/server/lib/openchamber-sessions/routes.js +11 -0
- package/server/lib/openchamber-sessions/routes.test.js +18 -0
- package/server/lib/opencode/DOCUMENTATION.md +37 -24
- package/server/lib/opencode/bootstrap-runtime.js +14 -1
- package/server/lib/opencode/compatibility.js +6 -3
- package/server/lib/opencode/compatibility.test.js +8 -0
- package/server/lib/opencode/config-entity-v2.test.js +27 -0
- package/server/lib/opencode/config-paths.test.js +12 -0
- package/server/lib/opencode/config-v2.d.ts +2 -0
- package/server/lib/opencode/config-v2.js +42 -0
- package/server/lib/opencode/config-v2.test.js +17 -0
- package/server/lib/opencode/core-routes.js +20 -4
- package/server/lib/opencode/core-routes.test.js +41 -0
- package/server/lib/opencode/env-runtime.js +1 -8
- package/server/lib/opencode/feature-routes-runtime.js +2 -1
- package/server/lib/opencode/lifecycle.js +30 -2
- package/server/lib/opencode/lifecycle.test.js +27 -0
- package/server/lib/opencode/managed-config-file.js +18 -6
- package/server/lib/opencode/managed-config-file.test.js +23 -7
- package/server/lib/opencode/mcp.js +7 -2
- package/server/lib/opencode/openchamber-routes.js +29 -11
- package/server/lib/opencode/openchamber-routes.test.js +18 -0
- package/server/lib/opencode/project-directory-runtime.js +8 -0
- package/server/lib/opencode/project-directory-runtime.test.js +13 -0
- package/server/lib/opencode/provider-source-route.test.js +59 -0
- package/server/lib/opencode/providers.js +3 -0
- package/server/lib/opencode/providers.test.js +62 -0
- package/server/lib/opencode/proxy.js +38 -2
- package/server/lib/opencode/routes-upgrade.test.js +1 -1
- package/server/lib/opencode/routes.js +36 -1
- package/server/lib/opencode/server-utils-runtime.js +5 -0
- package/server/lib/opencode/settings-helpers.js +10 -0
- package/server/lib/opencode/settings-helpers.test.js +2 -2
- package/server/lib/opencode/settings-registry.json +17 -0
- package/server/lib/opencode/settings-runtime.js +1 -0
- package/server/lib/opencode/shared.js +49 -4
- package/server/lib/opencode/shared.test.js +79 -1
- package/server/lib/opencode/shutdown-runtime.js +3 -0
- package/server/lib/opencode/skill-routes.js +28 -12
- package/server/lib/opencode/skill-routes.test.js +121 -1
- package/server/lib/opencode/upgrade-capability.js +0 -14
- package/server/lib/opencode/v1-migration-topup.js +21 -15
- package/server/lib/opencode/v1-migration-topup.test.js +14 -6
- package/server/lib/opencode/v2-install.d.ts +1 -0
- package/server/lib/opencode/v2-install.js +8 -7
- package/server/lib/opencode/v2-install.test.js +13 -4
- package/server/lib/opencode/watcher.js +3 -1
- package/server/lib/opencode/websearch-config.js +13 -1
- package/server/lib/quota/providers/kimi.js +1 -1
- package/server/lib/realtime-proxy.js +5 -1
- package/server/lib/realtime-proxy.test.js +29 -0
- package/server/lib/relay/tunnel-host.js +4 -1
- package/server/lib/relay/tunnel-host.test.js +11 -0
- package/server/lib/session-assist/DOCUMENTATION.md +17 -5
- package/server/lib/session-assist/runtime.js +19 -2
- package/server/lib/session-assist/runtime.test.js +8 -0
- package/server/lib/session-goal/DOCUMENTATION.md +11 -0
- package/server/lib/small-model/DOCUMENTATION.md +11 -10
- package/server/lib/small-model/index.js +27 -32
- package/server/lib/small-model/index.test.js +28 -16
- package/server/lib/spaces/DOCUMENTATION.md +381 -20
- package/server/lib/spaces/code-in-bait.js +145 -6
- package/server/lib/spaces/code-in.js +10 -150
- package/server/lib/spaces/code-in.test.js +7 -83
- package/server/lib/spaces/code-out.js +1819 -0
- package/server/lib/spaces/code-out.test.js +3945 -0
- package/server/lib/spaces/code-transfer.js +173 -0
- package/server/lib/spaces/command-stream.test.js +181 -0
- package/server/lib/spaces/dispatcher.js +670 -0
- package/server/lib/spaces/dispatcher.test.js +582 -0
- package/server/lib/spaces/gatekeeper-channel.js +2 -0
- package/server/lib/spaces/gatekeeper-channel.test.js +9 -3
- package/server/lib/spaces/gatekeeper-program.cjs +4 -1
- package/server/lib/spaces/gatekeeper-program.test.js +3 -0
- package/server/lib/spaces/hardening.js +20 -4
- package/server/lib/spaces/hardening.test.js +18 -3
- package/server/lib/spaces/host-git.js +7 -4
- package/server/lib/spaces/host-git.test.js +6 -2
- package/server/lib/spaces/host.js +304 -0
- package/server/lib/spaces/host.test.js +273 -0
- package/server/lib/spaces/journey.js +393 -0
- package/server/lib/spaces/journey.test.js +384 -0
- package/server/lib/spaces/layout.js +26 -2
- package/server/lib/spaces/manager.js +4 -3
- package/server/lib/spaces/manager.test.js +6 -0
- package/server/lib/spaces/places/code-out.docker.live.test.js +412 -0
- package/server/lib/spaces/places/contract-suite.js +36 -0
- package/server/lib/spaces/places/dispatcher.docker.live.test.js +296 -0
- package/server/lib/spaces/places/docker.js +15 -3
- package/server/lib/spaces/places/docker.test.js +33 -2
- package/server/lib/spaces/places/escape-suite.js +86 -14
- package/server/lib/spaces/places/memory-place.js +24 -1
- package/server/lib/spaces/places/registry.js +1 -1
- package/server/lib/spaces/places/server.docker.live.test.js +69 -33
- package/server/lib/spaces/places/sessions.docker.live.test.js +220 -0
- package/server/lib/spaces/routes.js +207 -0
- package/server/lib/spaces/routes.test.js +211 -0
- package/server/lib/spaces/run-command.js +261 -8
- package/server/lib/spaces/run-command.test.js +193 -3
- package/server/lib/spaces/space-events.js +153 -0
- package/server/lib/spaces/space-events.test.js +160 -0
- package/server/lib/spaces/space-records.js +98 -0
- package/server/lib/spaces/space-records.test.js +73 -0
- package/server/lib/spaces/space-sessions.js +210 -0
- package/server/lib/spaces/space-sessions.test.js +161 -0
- package/server/lib/spaces/websocket.js +329 -0
- package/server/lib/spaces/websocket.test.js +345 -0
- package/server/lib/ui-auth/ui-auth.js +8 -2
- package/server/lib/ui-auth/ui-auth.test.js +29 -0
- package/server/opencode-proxy.test.js +113 -0
- package/dist/assets/DiffView-BucGEJYa.js +0 -4
- package/dist/assets/FilesView-CQcaaAVP.js +0 -17
- package/dist/assets/GuestSurfacePane--DJ7rsmY.js +0 -1
- package/dist/assets/MarkdownImageGallery-wcUUcf8l.js +0 -1
- package/dist/assets/MarkdownRendererImpl-BPe2TVV2.js +0 -12
- package/dist/assets/PluginPane-DImv8hV2.js +0 -3
- package/dist/assets/SettingsView-DOjuOljf.js +0 -29
- package/dist/assets/commitAndPush-sGEelpjh.js +0 -1
- package/dist/assets/de-CD9utsNj.js +0 -10
- package/dist/assets/es-NNum2rX8.js +0 -16
- package/dist/assets/fr-CJLGmduQ.js +0 -14
- package/dist/assets/index-DjGPR5vW.js +0 -41
- package/dist/assets/index-fCXJ-8Qt.css +0 -1
- package/dist/assets/ja-BuddHNi6.js +0 -16
- package/dist/assets/ko-BrwMbHmf.js +0 -16
- package/dist/assets/main-CxVyUDU_.js +0 -896
- package/dist/assets/markdownCore-B6PpX409.js +0 -5
- package/dist/assets/patchFileDiff-BFRGKaGH.js +0 -13
- package/dist/assets/pl-BwN4TNlP.js +0 -16
- package/dist/assets/pt-BR-BhMtownO.js +0 -16
- package/dist/assets/renderMobileApp-nQ4sjQtb.js +0 -25
- package/dist/assets/runtimeEndpointReset-9ZGlXU4J.js +0 -27
- package/dist/assets/scheduledTasksApi-6DsL_SwM.js +0 -1
- package/dist/assets/tr-DRzvqMdi.js +0 -7
- package/dist/assets/uk-b2aYOSNh.js +0 -16
- package/dist/assets/vendor-zod-Gea9uBlY.js +0 -39
- package/dist/assets/zh-CN-DZeUThm_.js +0 -16
- package/dist/assets/zh-TW-2fRE7uc6.js +0 -16
|
@@ -2,6 +2,17 @@ import { appendManagedPlugin } from './managed-plugin-config.js';
|
|
|
2
2
|
|
|
3
3
|
export const MANAGED_CONFIG_FILE_NAME = 'opencode.managed.json';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Built-in OpenCode plugins OpenChamber switches off for its managed child.
|
|
7
|
+
*
|
|
8
|
+
* `opencode.browser` only works when OpenCode's own desktop app attaches a
|
|
9
|
+
* browser to the session; OpenChamber does not implement that protocol, so its
|
|
10
|
+
* tools always fail with `browser.disconnected` and agents conclude browsing is
|
|
11
|
+
* unavailable instead of using `openchamber_web`. A project config that lists
|
|
12
|
+
* `opencode.browser` still re-enables it, because that layer sits above ours.
|
|
13
|
+
*/
|
|
14
|
+
const DISABLED_BUILTIN_PLUGINS = ['-opencode.browser'];
|
|
15
|
+
|
|
5
16
|
/**
|
|
6
17
|
* The managed OpenCode config layer.
|
|
7
18
|
*
|
|
@@ -12,7 +23,8 @@ export const MANAGED_CONFIG_FILE_NAME = 'opencode.managed.json';
|
|
|
12
23
|
* process — where `OPENCODE_CONFIG_CONTENT` (an environment variable) could
|
|
13
24
|
* only ever change across a restart.
|
|
14
25
|
*
|
|
15
|
-
* The file is OpenChamber-owned and holds nothing but `plugins
|
|
26
|
+
* The file is OpenChamber-owned and holds nothing but `plugins`: the built-in
|
|
27
|
+
* plugins OpenChamber disables, then its own plugin directories. It sits above
|
|
16
28
|
* the user's global `opencode.json` and below their project config, so it never
|
|
17
29
|
* shadows a project-level choice.
|
|
18
30
|
*
|
|
@@ -46,7 +58,7 @@ export const createManagedConfigRuntime = ({
|
|
|
46
58
|
|
|
47
59
|
const writeConfigFile = async (pluginDirectories) => {
|
|
48
60
|
await fsPromises.mkdir(dataDir, { recursive: true });
|
|
49
|
-
const text = `${JSON.stringify({ plugins: pluginDirectories }, null, 2)}\n`;
|
|
61
|
+
const text = `${JSON.stringify({ plugins: [...DISABLED_BUILTIN_PLUGINS, ...pluginDirectories] }, null, 2)}\n`;
|
|
50
62
|
// Temp + rename: OpenCode reacts to the write immediately, and a partial
|
|
51
63
|
// read would make it drop every managed plugin until the next change.
|
|
52
64
|
const tmp = `${filePath}.tmp-${process.pid}-${Date.now()}`;
|
|
@@ -69,10 +81,11 @@ export const createManagedConfigRuntime = ({
|
|
|
69
81
|
const includeControl = settings?.agentControlToolEnabled !== false;
|
|
70
82
|
const includeWeb = settings?.agentWebToolEnabled !== false;
|
|
71
83
|
const includeMemory = isAgentMemoryAvailable() && settings?.agentMemoryToolEnabled === true;
|
|
84
|
+
const includeNotify = settings?.agentNotifyToolEnabled === true;
|
|
72
85
|
|
|
73
86
|
const directories = [];
|
|
74
|
-
if (agentToolRuntime && (includeControl || includeWeb || includeMemory)) {
|
|
75
|
-
directories.push(await agentToolRuntime.materializePlugin({ includeControl, includeWeb, includeMemory }));
|
|
87
|
+
if (agentToolRuntime && (includeControl || includeWeb || includeMemory || includeNotify)) {
|
|
88
|
+
directories.push(await agentToolRuntime.materializePlugin({ includeControl, includeWeb, includeMemory, includeNotify }));
|
|
76
89
|
}
|
|
77
90
|
return directories;
|
|
78
91
|
};
|
|
@@ -89,9 +102,8 @@ export const createManagedConfigRuntime = ({
|
|
|
89
102
|
await writeConfigFile(directories);
|
|
90
103
|
return { ...childEnv, OPENCODE_CONFIG: filePath };
|
|
91
104
|
}
|
|
92
|
-
if (directories.length === 0) return childEnv;
|
|
93
105
|
let content = env.OPENCODE_CONFIG_CONTENT;
|
|
94
|
-
for (const directory of directories) {
|
|
106
|
+
for (const directory of [...DISABLED_BUILTIN_PLUGINS, ...directories]) {
|
|
95
107
|
content = appendManagedPlugin(content, directory, 'managed plugin');
|
|
96
108
|
}
|
|
97
109
|
return { ...childEnv, OPENCODE_CONFIG_CONTENT: content };
|
|
@@ -52,7 +52,7 @@ describe('managed OpenCode config file', () => {
|
|
|
52
52
|
expect(childEnv.OPENCODE_CONFIG_CONTENT).toBeUndefined();
|
|
53
53
|
expect(childEnv.OPENCHAMBER_AGENT_TOOL_TOKEN).toBe('token');
|
|
54
54
|
expect(await readConfigFile()).toEqual({
|
|
55
|
-
plugins: [path.join(dataDir, 'agent-tool', 'openchamber-agent-tool')],
|
|
55
|
+
plugins: ['-opencode.browser', path.join(dataDir, 'agent-tool', 'openchamber-agent-tool')],
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
|
|
@@ -61,7 +61,7 @@ describe('managed OpenCode config file', () => {
|
|
|
61
61
|
|
|
62
62
|
await runtime.buildManagedChildEnv();
|
|
63
63
|
|
|
64
|
-
for (const directory of (await readConfigFile()).plugins) {
|
|
64
|
+
for (const directory of (await readConfigFile()).plugins.filter((entry) => !entry.startsWith('-'))) {
|
|
65
65
|
expect((await fs.stat(directory)).isDirectory()).toBe(true);
|
|
66
66
|
}
|
|
67
67
|
});
|
|
@@ -74,7 +74,7 @@ describe('managed OpenCode config file', () => {
|
|
|
74
74
|
const childEnv = await runtime.buildManagedChildEnv();
|
|
75
75
|
|
|
76
76
|
expect(agentToolRuntime.materializePlugin).not.toHaveBeenCalled();
|
|
77
|
-
expect(await readConfigFile()).toEqual({ plugins: [] });
|
|
77
|
+
expect(await readConfigFile()).toEqual({ plugins: ['-opencode.browser'] });
|
|
78
78
|
// A tool switched on later reaches a process that can already call back.
|
|
79
79
|
expect(childEnv.OPENCHAMBER_AGENT_TOOL_TOKEN).toBe('token');
|
|
80
80
|
});
|
|
@@ -89,7 +89,7 @@ describe('managed OpenCode config file', () => {
|
|
|
89
89
|
expect(await runtime.refreshManagedConfigFile()).toEqual({ updated: true });
|
|
90
90
|
|
|
91
91
|
const { plugins } = await readConfigFile();
|
|
92
|
-
expect(plugins).toEqual([]);
|
|
92
|
+
expect(plugins).toEqual(['-opencode.browser']);
|
|
93
93
|
expect(agentToolRuntime.createChildEnv).toHaveBeenCalledTimes(1);
|
|
94
94
|
});
|
|
95
95
|
|
|
@@ -102,11 +102,27 @@ describe('managed OpenCode config file', () => {
|
|
|
102
102
|
current.settings = { agentControlToolEnabled: false, agentWebToolEnabled: true };
|
|
103
103
|
await runtime.refreshManagedConfigFile();
|
|
104
104
|
|
|
105
|
-
expect((await readConfigFile()).plugins).toHaveLength(
|
|
105
|
+
expect((await readConfigFile()).plugins).toHaveLength(2);
|
|
106
106
|
expect(agentToolRuntime.materializePlugin).toHaveBeenCalledWith({
|
|
107
107
|
includeControl: false,
|
|
108
108
|
includeWeb: true,
|
|
109
109
|
includeMemory: false,
|
|
110
|
+
includeNotify: false,
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('injects the notify tool only when it is switched on', async () => {
|
|
115
|
+
const { runtime, agentToolRuntime } = await createHarness({
|
|
116
|
+
settings: { agentControlToolEnabled: false, agentWebToolEnabled: false, agentNotifyToolEnabled: true },
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
await runtime.buildManagedChildEnv();
|
|
120
|
+
|
|
121
|
+
expect(agentToolRuntime.materializePlugin).toHaveBeenCalledWith({
|
|
122
|
+
includeControl: false,
|
|
123
|
+
includeWeb: false,
|
|
124
|
+
includeMemory: false,
|
|
125
|
+
includeNotify: true,
|
|
110
126
|
});
|
|
111
127
|
});
|
|
112
128
|
|
|
@@ -121,7 +137,7 @@ describe('managed OpenCode config file', () => {
|
|
|
121
137
|
expect(childEnv.OPENCODE_CONFIG).toBeUndefined();
|
|
122
138
|
expect(JSON.parse(childEnv.OPENCODE_CONFIG_CONTENT)).toEqual({
|
|
123
139
|
model: 'test/model',
|
|
124
|
-
plugins: [path.join(dataDir, 'agent-tool', 'openchamber-agent-tool')],
|
|
140
|
+
plugins: ['-opencode.browser', path.join(dataDir, 'agent-tool', 'openchamber-agent-tool')],
|
|
125
141
|
});
|
|
126
142
|
await expect(fs.stat(path.join(dataDir, MANAGED_CONFIG_FILE_NAME))).rejects.toThrow();
|
|
127
143
|
expect(await runtime.refreshManagedConfigFile()).toEqual({ updated: false, reason: 'external-config' });
|
|
@@ -147,6 +163,6 @@ describe('managed OpenCode config file', () => {
|
|
|
147
163
|
await runtime.buildManagedChildEnv();
|
|
148
164
|
|
|
149
165
|
expect(agentToolRuntime.materializePlugin).not.toHaveBeenCalled();
|
|
150
|
-
expect(await readConfigFile()).toEqual({ plugins: [] });
|
|
166
|
+
expect(await readConfigFile()).toEqual({ plugins: ['-opencode.browser'] });
|
|
151
167
|
});
|
|
152
168
|
});
|
|
@@ -48,9 +48,14 @@ function ensureProjectMcpConfigPath(workingDirectory) {
|
|
|
48
48
|
return path.join(configDir, 'opencode.json');
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/** Same precedence as `getJsonEntrySource`: custom > project > user. */
|
|
51
|
+
/** Same precedence as `getJsonEntrySource`: custom > project > user override > user. */
|
|
52
52
|
function readMcpEntriesAcrossLayers(layers) {
|
|
53
|
-
return readLayeredMcpEntries([
|
|
53
|
+
return readLayeredMcpEntries([
|
|
54
|
+
layers?.userConfig,
|
|
55
|
+
layers?.userOverrideConfig,
|
|
56
|
+
layers?.projectConfig,
|
|
57
|
+
layers?.customConfig,
|
|
58
|
+
]);
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
function listMcpConfigs(workingDirectory) {
|
|
@@ -71,6 +71,26 @@ export const registerOpenChamberRoutes = (app, dependencies) => {
|
|
|
71
71
|
|
|
72
72
|
let desktopRestartError = null;
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* How this server was launched, read from its instance file. A foreground
|
|
76
|
+
* server outside systemd has no process that can restart it after an
|
|
77
|
+
* install, so it cannot update itself.
|
|
78
|
+
*/
|
|
79
|
+
const readLaunchState = async () => {
|
|
80
|
+
const currentPort = server.address()?.port || 3000;
|
|
81
|
+
const instanceFilePath = path.join(openchamberDataDir, 'run', `openchamber-${currentPort}.json`);
|
|
82
|
+
let storedOptions = { port: currentPort, daemon: true };
|
|
83
|
+
try {
|
|
84
|
+
const content = await fs.promises.readFile(instanceFilePath, 'utf8');
|
|
85
|
+
storedOptions = JSON.parse(content);
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
const launchMode = storedOptions.launchMode === 'foreground' ? 'foreground' : 'daemon';
|
|
89
|
+
const isForegroundService = launchMode === 'foreground';
|
|
90
|
+
const systemdServiceUnit = isForegroundService ? resolveSystemdServiceUnit(process.env) : null;
|
|
91
|
+
return { storedOptions, launchMode, isForegroundService, systemdServiceUnit };
|
|
92
|
+
};
|
|
93
|
+
|
|
74
94
|
app.get('/api/openchamber/update-check', async (req, res) => {
|
|
75
95
|
try {
|
|
76
96
|
const parseString = (value) => (typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined);
|
|
@@ -121,6 +141,14 @@ export const registerOpenChamberRoutes = (app, dependencies) => {
|
|
|
121
141
|
} else {
|
|
122
142
|
const { checkForUpdates } = await import('../package-manager.js');
|
|
123
143
|
updateInfo = await checkForUpdates(updateRequest);
|
|
144
|
+
// Tell clients up front that the install route will refuse, so they
|
|
145
|
+
// show the manual command instead of an Update button that fails.
|
|
146
|
+
if (updateInfo?.available && updateRequest.appType === 'web') {
|
|
147
|
+
const { isForegroundService, systemdServiceUnit } = await readLaunchState();
|
|
148
|
+
if (isForegroundService && !systemdServiceUnit) {
|
|
149
|
+
updateInfo = { ...updateInfo, installBlocked: 'service-manager' };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
124
152
|
}
|
|
125
153
|
res.json(updateInfo);
|
|
126
154
|
} catch (error) {
|
|
@@ -215,17 +243,7 @@ export const registerOpenChamberRoutes = (app, dependencies) => {
|
|
|
215
243
|
return;
|
|
216
244
|
}
|
|
217
245
|
|
|
218
|
-
const
|
|
219
|
-
const instanceFilePath = path.join(openchamberDataDir, 'run', `openchamber-${currentPort}.json`);
|
|
220
|
-
let storedOptions = { port: currentPort, daemon: true };
|
|
221
|
-
try {
|
|
222
|
-
const content = await fs.promises.readFile(instanceFilePath, 'utf8');
|
|
223
|
-
storedOptions = JSON.parse(content);
|
|
224
|
-
} catch {
|
|
225
|
-
}
|
|
226
|
-
const launchMode = storedOptions.launchMode === 'foreground' ? 'foreground' : 'daemon';
|
|
227
|
-
const isForegroundService = launchMode === 'foreground';
|
|
228
|
-
const systemdServiceUnit = isForegroundService ? resolveSystemdServiceUnit(process.env) : null;
|
|
246
|
+
const { storedOptions, launchMode, isForegroundService, systemdServiceUnit } = await readLaunchState();
|
|
229
247
|
|
|
230
248
|
if (isForegroundService) {
|
|
231
249
|
if (!systemdServiceUnit) {
|
|
@@ -203,6 +203,24 @@ describe('OpenChamber desktop host update route', () => {
|
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
describe('OpenChamber foreground update route', () => {
|
|
206
|
+
it('marks an available update as blocked when the foreground server has no service manager', async () => {
|
|
207
|
+
const { app } = createApp();
|
|
208
|
+
|
|
209
|
+
const response = await request(app).get('/api/openchamber/update-check?appType=web').expect(200);
|
|
210
|
+
|
|
211
|
+
expect(response.body).toMatchObject({ available: true, installBlocked: 'service-manager' });
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('leaves the update installable for a systemd-owned or daemon server', async () => {
|
|
215
|
+
const systemd = createApp({ environment: { INVOCATION_ID: 'systemd-invocation' } });
|
|
216
|
+
const daemon = createApp({ storedOptions: { launchMode: 'daemon' } });
|
|
217
|
+
|
|
218
|
+
for (const { app } of [systemd, daemon]) {
|
|
219
|
+
const response = await request(app).get('/api/openchamber/update-check?appType=web').expect(200);
|
|
220
|
+
expect(response.body.installBlocked).toBeUndefined();
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
206
224
|
it('rejects a foreground update when the server is not owned by systemd', async () => {
|
|
207
225
|
const { app } = createApp();
|
|
208
226
|
|
|
@@ -16,6 +16,10 @@ export const createProjectDirectoryRuntime = (dependencies) => {
|
|
|
16
16
|
readSettingsFromDiskMigrated,
|
|
17
17
|
getReadSettingsFromDiskMigrated,
|
|
18
18
|
sanitizeProjects,
|
|
19
|
+
// `refuseDirectory(candidate)` answers the reason a directory may not be used on this host,
|
|
20
|
+
// or null. It runs before the path is looked at, so a refused directory is never touched and
|
|
21
|
+
// never falls back to another one. The isolated-spaces host refuses `/spaces/...` with it.
|
|
22
|
+
refuseDirectory = () => null,
|
|
19
23
|
} = dependencies;
|
|
20
24
|
const realpathCache = createRealpathCache({
|
|
21
25
|
realpath: fsPromises.realpath.bind(fsPromises),
|
|
@@ -38,6 +42,10 @@ export const createProjectDirectoryRuntime = (dependencies) => {
|
|
|
38
42
|
if (!resolved) {
|
|
39
43
|
return { ok: false, error: 'Directory parameter is required' };
|
|
40
44
|
}
|
|
45
|
+
const refusal = refuseDirectory(resolved);
|
|
46
|
+
if (typeof refusal === 'string' && refusal.length > 0) {
|
|
47
|
+
return { ok: false, error: refusal };
|
|
48
|
+
}
|
|
41
49
|
try {
|
|
42
50
|
const stats = await fsPromises.stat(resolved);
|
|
43
51
|
if (!stats.isDirectory()) {
|
|
@@ -42,6 +42,19 @@ describe('project directory runtime', () => {
|
|
|
42
42
|
expect(result).toEqual({ ok: true, directory: '/real/path/to/project', requestedDirectory: '/symlink/path/to/project' });
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
it('refuses a directory the host says no to, before it looks at the disk', async () => {
|
|
46
|
+
let statCalls = 0;
|
|
47
|
+
const runtime = createTestRuntime({
|
|
48
|
+
fsPromises: { stat: async () => { statCalls += 1; return { isDirectory: () => true }; }, realpath: async (p) => p },
|
|
49
|
+
refuseDirectory: (candidate) => (candidate.startsWith('/spaces/') ? 'A directory under /spaces/ belongs to an isolated space' : null),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
expect(await runtime.validateDirectoryPath('/spaces/a1b2c3d4e5f6/repo')).toEqual({ ok: false, error: 'A directory under /spaces/ belongs to an isolated space' });
|
|
53
|
+
expect(statCalls).toBe(0);
|
|
54
|
+
expect(await runtime.validateDirectoryPath('/home/user/project')).toMatchObject({ ok: true });
|
|
55
|
+
expect(statCalls).toBe(1);
|
|
56
|
+
});
|
|
57
|
+
|
|
45
58
|
it('returns error when candidate is empty', async () => {
|
|
46
59
|
const runtime = createTestRuntime();
|
|
47
60
|
const result = await runtime.validateDirectoryPath('');
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import request from 'supertest';
|
|
4
|
+
import { registerOpenCodeRoutes } from './routes.js';
|
|
5
|
+
|
|
6
|
+
const createApp = (getProviderSources) => {
|
|
7
|
+
const app = express();
|
|
8
|
+
app.use(express.json());
|
|
9
|
+
registerOpenCodeRoutes(app, {
|
|
10
|
+
resolveProjectDirectory: vi.fn(async () => ({ directory: '/projects/app' })),
|
|
11
|
+
getProviderSources,
|
|
12
|
+
});
|
|
13
|
+
return app;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe('GET /api/provider/:providerId/source', () => {
|
|
17
|
+
it('returns the stored config entry next to the layer sources', async () => {
|
|
18
|
+
const stored = {
|
|
19
|
+
name: 'Stored',
|
|
20
|
+
package: 'aisdk:@ai-sdk/openai-compatible',
|
|
21
|
+
env: ['STORED_KEY'],
|
|
22
|
+
settings: { baseURL: 'https://stored.example.com/v1' },
|
|
23
|
+
models: { m: { modelID: 'm', name: 'M' } },
|
|
24
|
+
};
|
|
25
|
+
const getProviderSources = vi.fn(() => ({
|
|
26
|
+
sources: {
|
|
27
|
+
auth: { exists: false },
|
|
28
|
+
user: { exists: false, path: '/user.json' },
|
|
29
|
+
project: { exists: true, path: '/projects/app/opencode.json' },
|
|
30
|
+
custom: { exists: false, path: null },
|
|
31
|
+
},
|
|
32
|
+
config: stored,
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
const response = await request(createApp(getProviderSources))
|
|
36
|
+
.get('/api/provider/stored-llm/source?directory=/projects/app')
|
|
37
|
+
.expect(200);
|
|
38
|
+
|
|
39
|
+
expect(getProviderSources).toHaveBeenCalledWith('stored-llm', '/projects/app');
|
|
40
|
+
expect(response.body.config).toEqual(stored);
|
|
41
|
+
expect(response.body.sources.project.exists).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('returns null config when no layer defines the provider', async () => {
|
|
45
|
+
const response = await request(createApp(() => ({
|
|
46
|
+
sources: {
|
|
47
|
+
auth: { exists: false },
|
|
48
|
+
user: { exists: false, path: '/user.json' },
|
|
49
|
+
project: { exists: false, path: null },
|
|
50
|
+
custom: { exists: false, path: null },
|
|
51
|
+
},
|
|
52
|
+
config: null,
|
|
53
|
+
})))
|
|
54
|
+
.get('/api/provider/other/source')
|
|
55
|
+
.expect(200);
|
|
56
|
+
|
|
57
|
+
expect(response.body.config).toBeNull();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
deleteSectionEntry,
|
|
12
12
|
toModelVariants,
|
|
13
13
|
toProviderEntity,
|
|
14
|
+
readStoredProviderEntry,
|
|
14
15
|
toProviderPackage,
|
|
15
16
|
toNpmPackage,
|
|
16
17
|
} from './config-v2.js';
|
|
@@ -43,6 +44,8 @@ function getProviderSources(providerId, workingDirectory) {
|
|
|
43
44
|
project: { exists: providerExistsIn(projectConfig, providerId), path: paths.projectPath || null },
|
|
44
45
|
custom: { exists: providerExistsIn(customConfig, providerId), path: paths.customPath },
|
|
45
46
|
},
|
|
47
|
+
// Same precedence as the edit scope: custom > project > user.
|
|
48
|
+
config: readStoredProviderEntry([customConfig, projectConfig, userConfig], providerId),
|
|
46
49
|
};
|
|
47
50
|
}
|
|
48
51
|
|
|
@@ -436,6 +436,68 @@ describe('custom provider config persistence', () => {
|
|
|
436
436
|
}
|
|
437
437
|
});
|
|
438
438
|
|
|
439
|
+
test('getProviderSources returns the stored entry from a JSONC config, v2 shape, without the key', () => {
|
|
440
|
+
const configPath = path.join(projectDir, '.opencode', 'opencode.jsonc');
|
|
441
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
442
|
+
fs.writeFileSync(configPath, `{
|
|
443
|
+
// v1 spelling, still decoded by OpenCode 2
|
|
444
|
+
"provider": {
|
|
445
|
+
"stored-llm": {
|
|
446
|
+
"name": "Stored",
|
|
447
|
+
"npm": "@ai-sdk/openai-compatible",
|
|
448
|
+
"env": ["STORED_KEY"],
|
|
449
|
+
"options": { "baseURL": "https://stored.example.com/v1", "apiKey": "sk-secret", "timeout": 5 },
|
|
450
|
+
"models": { "m": { "name": "M", "variants": { "high": { "reasoningEffort": "high" } } } },
|
|
451
|
+
},
|
|
452
|
+
},
|
|
453
|
+
}`, 'utf8');
|
|
454
|
+
|
|
455
|
+
const { config } = getProviderSources('stored-llm', projectDir);
|
|
456
|
+
expect(config).toEqual({
|
|
457
|
+
name: 'Stored',
|
|
458
|
+
package: 'aisdk:@ai-sdk/openai-compatible',
|
|
459
|
+
env: ['STORED_KEY'],
|
|
460
|
+
settings: { baseURL: 'https://stored.example.com/v1', timeout: 5 },
|
|
461
|
+
models: { m: { name: 'M', variants: [{ id: 'high', settings: { reasoningEffort: 'high' } }] } },
|
|
462
|
+
});
|
|
463
|
+
expect(getProviderSources('missing-llm', projectDir).config).toBeNull();
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
test('saving the stored entry back keeps env, settings and model fields it does not edit', () => {
|
|
467
|
+
const providerId = 'keep-llm';
|
|
468
|
+
const configPath = path.join(projectDir, '.opencode', 'opencode.json');
|
|
469
|
+
writeJson(configPath, {
|
|
470
|
+
providers: {
|
|
471
|
+
[providerId]: {
|
|
472
|
+
name: 'Keep',
|
|
473
|
+
package: 'aisdk:@ai-sdk/openai-compatible',
|
|
474
|
+
env: ['KEEP_KEY'],
|
|
475
|
+
settings: { baseURL: 'https://keep.example.com/v1', timeout: 5 },
|
|
476
|
+
body: { store: false },
|
|
477
|
+
models: { m: { modelID: 'm', name: 'M', limit: { context: 1000 } } },
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
const { config } = getProviderSources(providerId, projectDir);
|
|
483
|
+
upsertProviderConfig(providerId, {
|
|
484
|
+
name: config.name,
|
|
485
|
+
package: config.package,
|
|
486
|
+
env: config.env,
|
|
487
|
+
settings: { baseURL: config.settings.baseURL },
|
|
488
|
+
models: { m: { name: 'M renamed' } },
|
|
489
|
+
}, projectDir, 'project', { hasStoredAuth: true });
|
|
490
|
+
|
|
491
|
+
expect(readJson(configPath).providers[providerId]).toEqual({
|
|
492
|
+
name: 'Keep',
|
|
493
|
+
package: 'aisdk:@ai-sdk/openai-compatible',
|
|
494
|
+
env: ['KEEP_KEY'],
|
|
495
|
+
settings: { baseURL: 'https://keep.example.com/v1', timeout: 5 },
|
|
496
|
+
body: { store: false },
|
|
497
|
+
models: { m: { modelID: 'm', name: 'M renamed', limit: { context: 1000 } } },
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
|
|
439
501
|
test('custom-scope edit updates custom layer without creating a user entry', () => {
|
|
440
502
|
const providerId = `custom-scope-${Date.now()}`;
|
|
441
503
|
const customPath = path.join(projectDir, 'custom-opencode.json');
|
|
@@ -236,7 +236,7 @@ const SESSION_LIST_ALLOWED_FIELDS = [
|
|
|
236
236
|
'fork',
|
|
237
237
|
];
|
|
238
238
|
|
|
239
|
-
const sanitizeSessionListItem = (session) => {
|
|
239
|
+
export const sanitizeSessionListItem = (session) => {
|
|
240
240
|
if (!session || typeof session !== 'object' || Array.isArray(session)) {
|
|
241
241
|
return session;
|
|
242
242
|
}
|
|
@@ -307,6 +307,11 @@ export const registerOpenCodeProxy = (app, deps) => {
|
|
|
307
307
|
// migrated.
|
|
308
308
|
getArchivedSessions = null,
|
|
309
309
|
getStoredSessionMetadata = null,
|
|
310
|
+
// Isolated spaces, when the feature's switch is on: the merged session list, and the hub
|
|
311
|
+
// whose space events the global SSE stream carries beside the host's. Both absent means
|
|
312
|
+
// the host's own answers go out exactly as before spaces.
|
|
313
|
+
mergeSpaceSessionList = null,
|
|
314
|
+
spaceEventHub = null,
|
|
310
315
|
} = deps;
|
|
311
316
|
|
|
312
317
|
/**
|
|
@@ -550,6 +555,7 @@ export const registerOpenCodeProxy = (app, deps) => {
|
|
|
550
555
|
let heartbeatTimer = null;
|
|
551
556
|
let upstreamStallTimer = null;
|
|
552
557
|
let didUpstreamStall = false;
|
|
558
|
+
let unsubscribeSpaceEvents = null;
|
|
553
559
|
let writeQueue = Promise.resolve(true);
|
|
554
560
|
const sseBoundary = createSseBoundaryTracker();
|
|
555
561
|
|
|
@@ -644,6 +650,26 @@ export const registerOpenCodeProxy = (app, deps) => {
|
|
|
644
650
|
return writeQueue;
|
|
645
651
|
};
|
|
646
652
|
|
|
653
|
+
// The events of isolated spaces ride the global stream too, one block each, written
|
|
654
|
+
// only between the upstream's own blocks so a block of the host's is never cut.
|
|
655
|
+
// A directory in the query or in the header scopes the stream to the host's one directory.
|
|
656
|
+
const isGlobalStream = !new URL(requestUrl, 'http://localhost').searchParams.get('directory') && !req.get('x-opencode-directory');
|
|
657
|
+
const pendingSpaceBlocks = [];
|
|
658
|
+
const flushSpaceBlocks = async () => {
|
|
659
|
+
while (pendingSpaceBlocks.length > 0 && sseBoundary.isAtBoundary() && !abortController.signal.aborted) {
|
|
660
|
+
const canContinue = await enqueueSseWrite(pendingSpaceBlocks.shift());
|
|
661
|
+
if (!canContinue) return false;
|
|
662
|
+
}
|
|
663
|
+
return true;
|
|
664
|
+
};
|
|
665
|
+
if (spaceEventHub && isGlobalStream) {
|
|
666
|
+
unsubscribeSpaceEvents = spaceEventHub.subscribeEvent((event) => {
|
|
667
|
+
if (event.spaceId === null) return;
|
|
668
|
+
pendingSpaceBlocks.push(`data: ${JSON.stringify(event.payload)}\n\n`);
|
|
669
|
+
void flushSpaceBlocks();
|
|
670
|
+
}, { spaces: true });
|
|
671
|
+
}
|
|
672
|
+
|
|
647
673
|
scheduleHeartbeat();
|
|
648
674
|
resetUpstreamStallTimer();
|
|
649
675
|
|
|
@@ -660,6 +686,9 @@ export const registerOpenCodeProxy = (app, deps) => {
|
|
|
660
686
|
if (!canContinue) {
|
|
661
687
|
break;
|
|
662
688
|
}
|
|
689
|
+
if (!await flushSpaceBlocks()) {
|
|
690
|
+
break;
|
|
691
|
+
}
|
|
663
692
|
}
|
|
664
693
|
}
|
|
665
694
|
|
|
@@ -679,6 +708,7 @@ export const registerOpenCodeProxy = (app, deps) => {
|
|
|
679
708
|
res.end();
|
|
680
709
|
}
|
|
681
710
|
} finally {
|
|
711
|
+
unsubscribeSpaceEvents?.();
|
|
682
712
|
if (heartbeatTimer) {
|
|
683
713
|
clearTimeout(heartbeatTimer);
|
|
684
714
|
heartbeatTimer = null;
|
|
@@ -763,7 +793,13 @@ export const registerOpenCodeProxy = (app, deps) => {
|
|
|
763
793
|
}
|
|
764
794
|
|
|
765
795
|
res.setHeader('content-type', result.contentType);
|
|
766
|
-
|
|
796
|
+
const hostList = await overlayOwnedStateOnList(sanitizeSessionListPayload(result.payload));
|
|
797
|
+
// The first page of the global list carries every space's sessions after the host's; a
|
|
798
|
+
// later page, and a list scoped to one directory, are the host's alone.
|
|
799
|
+
const listQuery = new URL(upstreamPath, 'http://localhost').searchParams;
|
|
800
|
+
const scopedToDirectory = Boolean(listQuery.get('directory') || req.get('x-opencode-directory'));
|
|
801
|
+
const wantsSpaces = typeof mergeSpaceSessionList === 'function' && !listQuery.get('cursor') && !scopedToDirectory;
|
|
802
|
+
res.json(wantsSpaces ? await mergeSpaceSessionList(hostList) : hostList);
|
|
767
803
|
} catch (error) {
|
|
768
804
|
if (isAbortError(error)) {
|
|
769
805
|
return;
|
|
@@ -86,7 +86,7 @@ describe('OpenCode upgrade routes', () => {
|
|
|
86
86
|
expect(globalThis.fetch).not.toHaveBeenCalled();
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
it.each(['external', 'unavailable'
|
|
89
|
+
it.each(['external', 'unavailable'])('rejects %s on the server', async (reason) => {
|
|
90
90
|
const { app, dependencies } = createApp({ getOpenCodeUpgradeCapability: () => ({ supported: false, reason }) });
|
|
91
91
|
await request(app).post('/api/opencode/upgrade').send({}).expect(409);
|
|
92
92
|
expect(dependencies.upgradeOpenCodeCli).not.toHaveBeenCalled();
|
|
@@ -10,7 +10,7 @@ import { getClaudeCliAuthStatus } from './claude-cli-auth.js';
|
|
|
10
10
|
import { OPENCODE_CONFIG_DIR } from './shared.js';
|
|
11
11
|
import { settingsSurfaceOf } from './settings-files.js';
|
|
12
12
|
import { parseWebSearchSelection } from './config-v2.js';
|
|
13
|
-
import { getWebSearchSource, setWebSearchSelection } from './websearch-config.js';
|
|
13
|
+
import { getWebSearchSource, setWarmingEnabled, setWebSearchSelection } from './websearch-config.js';
|
|
14
14
|
|
|
15
15
|
export const registerOpenCodeRoutes = (app, dependencies) => {
|
|
16
16
|
const {
|
|
@@ -287,6 +287,7 @@ export const registerOpenCodeRoutes = (app, dependencies) => {
|
|
|
287
287
|
return res.json({
|
|
288
288
|
providerId,
|
|
289
289
|
sources: sources.sources,
|
|
290
|
+
config: sources.config,
|
|
290
291
|
});
|
|
291
292
|
} catch (error) {
|
|
292
293
|
console.error('Failed to get provider sources:', error);
|
|
@@ -379,6 +380,22 @@ export const registerOpenCodeRoutes = (app, dependencies) => {
|
|
|
379
380
|
}
|
|
380
381
|
});
|
|
381
382
|
|
|
383
|
+
// Session warming (`warming` in OpenCode config), written like the web
|
|
384
|
+
// search choice above. Settings reads the effective value from OpenCode.
|
|
385
|
+
app.put('/api/config/warming', (req, res) => {
|
|
386
|
+
const enabled = req.body?.enabled;
|
|
387
|
+
if (typeof enabled !== 'boolean') {
|
|
388
|
+
return res.status(400).json({ error: 'enabled must be a boolean' });
|
|
389
|
+
}
|
|
390
|
+
try {
|
|
391
|
+
const result = setWarmingEnabled(enabled);
|
|
392
|
+
return res.json({ success: true, changed: result.changed });
|
|
393
|
+
} catch (error) {
|
|
394
|
+
console.error('Failed to save session warming:', error);
|
|
395
|
+
return res.status(500).json({ error: error.message || 'Failed to save session warming' });
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
|
|
382
399
|
app.delete('/api/provider/:providerId/auth', async (req, res) => {
|
|
383
400
|
try {
|
|
384
401
|
const { providerId } = req.params;
|
|
@@ -528,6 +545,24 @@ export const registerOpenCodeRoutes = (app, dependencies) => {
|
|
|
528
545
|
return res.status(413).json({ error: `Content exceeds maximum size of ${MAX_BEHAVIOR_PROMPT_SIZE} bytes` });
|
|
529
546
|
}
|
|
530
547
|
|
|
548
|
+
// `expectedContent` is what the editor loaded (null: no file). A file
|
|
549
|
+
// changed on disk since then is not overwritten with the stale copy.
|
|
550
|
+
if (req.body && Object.prototype.hasOwnProperty.call(req.body, 'expectedContent')) {
|
|
551
|
+
const expected = req.body.expectedContent;
|
|
552
|
+
let current = null;
|
|
553
|
+
try {
|
|
554
|
+
current = await fs.promises.readFile(AGENTS_MD_PATH, 'utf8');
|
|
555
|
+
} catch (error) {
|
|
556
|
+
if (error?.code !== 'ENOENT') throw error;
|
|
557
|
+
}
|
|
558
|
+
if (current !== expected) {
|
|
559
|
+
return res.status(409).json({
|
|
560
|
+
error: 'AGENTS.md changed on disk since it was loaded',
|
|
561
|
+
code: 'AGENTS_MD_CONFLICT',
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
531
566
|
// Ensure parent directory exists
|
|
532
567
|
const parentDir = path.dirname(AGENTS_MD_PATH);
|
|
533
568
|
try {
|
|
@@ -23,6 +23,8 @@ export const createServerUtilsRuntime = (dependencies) => {
|
|
|
23
23
|
clearLastOpenCodeError,
|
|
24
24
|
getLoginShellPath,
|
|
25
25
|
getArchivedSessions = null,
|
|
26
|
+
getMergeSpaceSessionList = null,
|
|
27
|
+
getSpaceEventHub = null,
|
|
26
28
|
getStoredSessionMetadata = null,
|
|
27
29
|
} = dependencies;
|
|
28
30
|
|
|
@@ -221,6 +223,9 @@ export const createServerUtilsRuntime = (dependencies) => {
|
|
|
221
223
|
getUiNotificationClients,
|
|
222
224
|
getArchivedSessions,
|
|
223
225
|
getStoredSessionMetadata,
|
|
226
|
+
// Read when the proxy is set up, after `main` decided whether the spaces host exists.
|
|
227
|
+
mergeSpaceSessionList: typeof getMergeSpaceSessionList === 'function' ? getMergeSpaceSessionList() : null,
|
|
228
|
+
spaceEventHub: typeof getSpaceEventHub === 'function' ? getSpaceEventHub() : null,
|
|
224
229
|
});
|
|
225
230
|
};
|
|
226
231
|
|
|
@@ -65,6 +65,7 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
65
65
|
const SIDEBAR_PROJECT_DISPLAY_MODE_VALUES = new Set(['all', 'single']);
|
|
66
66
|
const SIDEBAR_VIEW_MODE_VALUES = new Set(['projects', 'timeline']);
|
|
67
67
|
const SIDEBAR_PROJECT_SORT_ORDER_VALUES = new Set(['manual', 'a-z', 'z-a', 'date-added', 'recent']);
|
|
68
|
+
const SIDEBAR_WORKTREE_SORT_ORDER_VALUES = new Set(['recent', 'manual', 'a-z']);
|
|
68
69
|
const HIDDEN_MODELS_MAX = 1024;
|
|
69
70
|
const RECENT_EFFORTS_MAX_KEYS = 128;
|
|
70
71
|
const RECENT_EFFORTS_MAX_VARIANTS_PER_KEY = 5;
|
|
@@ -302,6 +303,9 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
302
303
|
if (SIDEBAR_PROJECT_SORT_ORDER_VALUES.has(candidate.sidebarProjectSortOrder)) {
|
|
303
304
|
result.sidebarProjectSortOrder = candidate.sidebarProjectSortOrder;
|
|
304
305
|
}
|
|
306
|
+
if (SIDEBAR_WORKTREE_SORT_ORDER_VALUES.has(candidate.sidebarWorktreeSortOrder)) {
|
|
307
|
+
result.sidebarWorktreeSortOrder = candidate.sidebarWorktreeSortOrder;
|
|
308
|
+
}
|
|
305
309
|
if (typeof candidate.sidebarShowRecentSection === 'boolean') {
|
|
306
310
|
result.sidebarShowRecentSection = candidate.sidebarShowRecentSection;
|
|
307
311
|
}
|
|
@@ -607,6 +611,12 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
607
611
|
if (typeof candidate.agentMemoryToolEnabled === 'boolean') {
|
|
608
612
|
result.agentMemoryToolEnabled = candidate.agentMemoryToolEnabled;
|
|
609
613
|
}
|
|
614
|
+
if (typeof candidate.agentNotifyToolEnabled === 'boolean') {
|
|
615
|
+
result.agentNotifyToolEnabled = candidate.agentNotifyToolEnabled;
|
|
616
|
+
}
|
|
617
|
+
if (typeof candidate.isolatedSpacesEnabled === 'boolean') {
|
|
618
|
+
result.isolatedSpacesEnabled = candidate.isolatedSpacesEnabled;
|
|
619
|
+
}
|
|
610
620
|
if (typeof candidate.openCodeUpdateToastDismissedVersion === 'string') {
|
|
611
621
|
const version = candidate.openCodeUpdateToastDismissedVersion.trim();
|
|
612
622
|
result.openCodeUpdateToastDismissedVersion = version.slice(0, VERSION_STRING_MAX_LENGTH);
|