@openchamber/web 1.13.3 → 1.13.5
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/bin/cli-output.js +2 -7
- package/bin/cli-output.test.js +36 -0
- package/bin/cli.js +132 -5548
- package/bin/cli.test.js +686 -0
- package/bin/lib/DOCUMENTATION.md +121 -0
- package/bin/lib/cli-args.js +726 -0
- package/bin/lib/cli-errors.js +18 -0
- package/bin/lib/cli-executables.js +54 -0
- package/bin/lib/cli-http.js +216 -0
- package/bin/lib/cli-lifecycle.js +421 -0
- package/bin/lib/cli-log-files.js +93 -0
- package/bin/lib/cli-network.js +154 -0
- package/bin/lib/cli-paths.js +113 -0
- package/bin/lib/cli-ports.js +51 -0
- package/bin/lib/cli-process.js +292 -0
- package/bin/lib/cli-startup.js +370 -0
- package/bin/lib/cli-tunnel-capabilities.js +9 -0
- package/bin/lib/cli-tunnel-profiles.js +366 -0
- package/bin/lib/cli-tunnel-utils.js +300 -0
- package/bin/lib/commands-connect-url.js +173 -0
- package/bin/lib/commands-lifecycle.js +396 -0
- package/bin/lib/commands-logs.js +110 -0
- package/bin/lib/commands-serve.js +396 -0
- package/bin/lib/commands-startup.js +64 -0
- package/bin/lib/commands-status.js +114 -0
- package/bin/lib/commands-tunnel.js +1761 -0
- package/bin/lib/commands-update.js +141 -0
- package/dist/assets/{DiagramView-BmHROYsX.js → DiagramView-Bbj-QI7h.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DiJE-v5Q.js → MarkdownRendererImpl-BNr_9Jsb.js} +3 -3
- package/dist/assets/MultiRunWindow-DMMu53kw.js +1 -0
- package/dist/assets/NewWorktreeDialog-5TYBoMMA.js +167 -0
- package/dist/assets/{OnboardingScreen-DpBF8dKJ.js → OnboardingScreen-BucKVBD7.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-1xaHUxPK.js → SessionSwitcherDropdown-B6kvduse.js} +1 -1
- package/dist/assets/{SettingsWindow-ChwLyQAe.js → SettingsWindow-BEfDro9b.js} +1 -1
- package/dist/assets/{TerminalView-DGEBNuAp.js → TerminalView-CMdqMpTy.js} +1 -1
- package/dist/assets/es-Bk-yR0w-.js +15 -0
- package/dist/assets/fr-f1ibV7QU.js +13 -0
- package/dist/assets/index-B82A6jBD.css +1 -0
- package/dist/assets/index-BsXkdBYx.js +3 -0
- package/dist/assets/ja-D9mS3zWP.js +15 -0
- package/dist/assets/ko-Cpl1IA3D.js +15 -0
- package/dist/assets/main-DOdUrt3s.js +214 -0
- package/dist/assets/{main-fm_8J7Lk.js → main-KEVf2Yak.js} +2 -2
- package/dist/assets/miniChat-Nlzqr3Df.js +2 -0
- package/dist/assets/mobile-BIhOFhia.js +2 -0
- package/dist/assets/pl-CYke_fxL.js +15 -0
- package/dist/assets/pt-BR-Clb6Z8up.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-Cb1iUq8M.js +2 -0
- package/dist/assets/{renderMobileApp-6s0G1iIJ.js → renderMobileApp-7chEBHPK.js} +5 -5
- package/dist/assets/uk-CXn8cxXa.js +15 -0
- package/dist/assets/{useAppFontEffects-CV5C5O0r.js → useAppFontEffects-Bd0ks39c.js} +124 -119
- package/dist/assets/{vendor-.bun-CC_Xso_s.js → vendor-.bun-By2L9XvG.js} +1 -1
- package/dist/assets/zh-CN-BRwwlEdG.js +15 -0
- package/dist/assets/zh-TW-D5pg5Z8l.js +15 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +1 -1
- package/server/lib/cloudflare-tunnel.js +2 -2
- package/server/lib/event-stream/global-hub.js +1 -1
- package/server/lib/event-stream/index.js +0 -12
- package/server/lib/event-stream/runtime.js +1 -1
- package/server/lib/git/routes.test.js +4 -4
- package/server/lib/git/service.js +18 -0
- package/server/lib/git/service.test.js +48 -0
- package/server/lib/github/routes.js +1 -0
- package/server/lib/notifications/index.js +1 -4
- package/server/lib/opencode/agents.js +0 -6
- package/server/lib/opencode/commands.js +0 -5
- package/server/lib/opencode/config-entity-routes.js +39 -21
- package/server/lib/opencode/feature-routes-runtime.js +27 -62
- package/server/lib/opencode/lifecycle.js +13 -1
- package/server/lib/opencode/npm-registry.js +3 -3
- package/server/lib/opencode/proxy.js +3 -3
- package/server/lib/opencode/shared.js +0 -6
- package/server/lib/opencode/skills.js +0 -2
- package/server/lib/opencode/snippets.js +0 -2
- package/server/lib/package-manager.js +4 -4
- package/server/lib/package-manager.test.js +8 -1
- package/server/lib/projects/project-config.js +0 -8
- package/server/lib/quota/DOCUMENTATION.md +3 -1
- package/server/lib/quota/providers/claude.js +1 -1
- package/server/lib/quota/providers/codex.js +1 -1
- package/server/lib/quota/providers/copilot.js +1 -1
- package/server/lib/quota/providers/cursor.js +1 -1
- package/server/lib/quota/providers/google/auth.js +2 -2
- package/server/lib/quota/providers/google/index.js +14 -33
- package/server/lib/quota/providers/google/transforms.js +1 -1
- package/server/lib/quota/providers/index.js +4 -4
- package/server/lib/quota/providers/index.test.js +17 -0
- package/server/lib/quota/providers/kimi.js +1 -1
- package/server/lib/quota/providers/minimax-cn-coding-plan.js +1 -1
- package/server/lib/quota/providers/minimax-coding-plan.js +1 -1
- package/server/lib/quota/providers/nanogpt.js +1 -1
- package/server/lib/quota/providers/ollama-cloud.js +1 -1
- package/server/lib/quota/providers/openai.js +4 -4
- package/server/lib/quota/providers/openrouter.js +1 -1
- package/server/lib/quota/providers/wafer.js +1 -1
- package/server/lib/quota/providers/zai.js +1 -1
- package/server/lib/quota/providers/zhipuai-coding-plan.js +1 -1
- package/server/lib/skills-catalog/cache.js +0 -4
- package/server/lib/skills-catalog/clawdhub/api.js +0 -32
- package/server/lib/skills-catalog/clawdhub/scan.js +0 -52
- package/server/lib/skills-catalog/curated-sources.js +1 -1
- package/server/lib/skills-catalog/source.js +5 -0
- package/server/lib/terminal/runtime.js +11 -9
- package/server/lib/text/summarization.js +1 -1
- package/server/lib/tunnels/types.js +2 -2
- package/dist/assets/MultiRunWindow-yZoCT7F7.js +0 -1
- package/dist/assets/NewWorktreeDialog-CTMiE7Xd.js +0 -167
- package/dist/assets/es-CTE-E8we.js +0 -15
- package/dist/assets/fr-TVkZpyEo.js +0 -13
- package/dist/assets/index-B4pCDMbq.css +0 -1
- package/dist/assets/index-D9uMvTQF.js +0 -3
- package/dist/assets/ko-D_UCJIIL.js +0 -15
- package/dist/assets/main-eAd3a6tx.js +0 -214
- package/dist/assets/miniChat-Bbjg31IC.js +0 -2
- package/dist/assets/mobile-B3_j_DsB.js +0 -2
- package/dist/assets/pl-nDEkk-GZ.js +0 -15
- package/dist/assets/pt-BR-B_g2RcgU.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-CB13zs6N.js +0 -2
- package/dist/assets/uk-CWLhnPGW.js +0 -15
- package/dist/assets/zh-CN-BFxe1b5m.js +0 -15
- package/dist/assets/zh-TW-n-d-xbGV.js +0 -15
- package/server/lib/opencode/index.js +0 -95
- package/server/lib/quota/providers/interface.js +0 -55
- package/server/lib/skills-catalog/clawdhub/index.js +0 -30
- package/server/lib/skills-catalog/index.js +0 -42
- package/server/lib/terminal/index.js +0 -31
package/dist/index.html
CHANGED
|
@@ -515,12 +515,12 @@
|
|
|
515
515
|
pointer-events: none;
|
|
516
516
|
}
|
|
517
517
|
</style>
|
|
518
|
-
<script type="module" crossorigin src="/assets/main-
|
|
519
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-
|
|
520
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
518
|
+
<script type="module" crossorigin src="/assets/main-KEVf2Yak.js"></script>
|
|
519
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-By2L9XvG.js">
|
|
520
|
+
<link rel="modulepreload" crossorigin href="/assets/index-BsXkdBYx.js">
|
|
521
521
|
<link rel="modulepreload" crossorigin href="/assets/mobileLayoutPreference-Dio-WWkI.js">
|
|
522
522
|
<link rel="stylesheet" crossorigin href="/assets/vendor--Dwc_TRgJ.css">
|
|
523
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
523
|
+
<link rel="stylesheet" crossorigin href="/assets/index-B82A6jBD.css">
|
|
524
524
|
</head>
|
|
525
525
|
<body class="h-full bg-background text-foreground">
|
|
526
526
|
<div id="root" class="h-full">
|
package/dist/mini-chat.html
CHANGED
|
@@ -74,11 +74,11 @@
|
|
|
74
74
|
}
|
|
75
75
|
</style>
|
|
76
76
|
|
|
77
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
78
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-
|
|
79
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
77
|
+
<script type="module" crossorigin src="/assets/miniChat-Nlzqr3Df.js"></script>
|
|
78
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-By2L9XvG.js">
|
|
79
|
+
<link rel="modulepreload" crossorigin href="/assets/index-BsXkdBYx.js">
|
|
80
80
|
<link rel="stylesheet" crossorigin href="/assets/vendor--Dwc_TRgJ.css">
|
|
81
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
81
|
+
<link rel="stylesheet" crossorigin href="/assets/index-B82A6jBD.css">
|
|
82
82
|
</head>
|
|
83
83
|
<body class="h-full bg-background text-foreground">
|
|
84
84
|
<div id="root" class="h-full">
|
package/dist/mobile.html
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
|
|
6
6
|
<title>OpenChamber Mobile</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/mobile-
|
|
8
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-
|
|
9
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/mobile-BIhOFhia.js"></script>
|
|
8
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-By2L9XvG.js">
|
|
9
|
+
<link rel="modulepreload" crossorigin href="/assets/index-BsXkdBYx.js">
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/vendor--Dwc_TRgJ.css">
|
|
11
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
11
|
+
<link rel="stylesheet" crossorigin href="/assets/index-B82A6jBD.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body class="h-full bg-background text-foreground">
|
|
14
14
|
<div id="root" class="h-full"></div>
|
package/package.json
CHANGED
|
@@ -41,7 +41,7 @@ export async function checkCloudflaredAvailable() {
|
|
|
41
41
|
return { available: false, path: null, version: null };
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
function printCloudflareTunnelInstallHelp() {
|
|
45
45
|
const platform = process.platform;
|
|
46
46
|
let installCmd = '';
|
|
47
47
|
|
|
@@ -600,7 +600,7 @@ export async function startCloudflareManagedLocalTunnel({ configPath, hostname }
|
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
602
|
|
|
603
|
-
|
|
603
|
+
async function startCloudflareTunnel({ originUrl, port }) {
|
|
604
604
|
void port;
|
|
605
605
|
return startCloudflareQuickTunnel({ originUrl });
|
|
606
606
|
}
|
|
@@ -2,7 +2,7 @@ import { createUpstreamSseReader } from './upstream-reader.js';
|
|
|
2
2
|
|
|
3
3
|
// Raised from 512 → 2048 to improve recovery after brief disconnects during
|
|
4
4
|
// long-running agent sessions where many events accumulate quickly.
|
|
5
|
-
|
|
5
|
+
const MESSAGE_STREAM_GLOBAL_REPLAY_LIMIT = 2048;
|
|
6
6
|
|
|
7
7
|
export function createGlobalMessageStreamHub({
|
|
8
8
|
buildOpenCodeUrl,
|
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
export {
|
|
2
|
-
MESSAGE_STREAM_GLOBAL_WS_PATH,
|
|
3
|
-
MESSAGE_STREAM_DIRECTORY_WS_PATH,
|
|
4
|
-
MESSAGE_STREAM_WS_HEARTBEAT_INTERVAL_MS,
|
|
5
|
-
parseSseEventEnvelope,
|
|
6
|
-
sendMessageStreamWsFrame,
|
|
7
|
-
sendMessageStreamWsEvent,
|
|
8
|
-
} from './protocol.js';
|
|
9
|
-
|
|
10
1
|
export {
|
|
11
2
|
createGlobalUiEventBroadcaster,
|
|
12
3
|
createMessageStreamWsRuntime,
|
|
13
4
|
} from './runtime.js';
|
|
14
5
|
|
|
15
6
|
export {
|
|
16
|
-
MESSAGE_STREAM_GLOBAL_REPLAY_LIMIT,
|
|
17
7
|
createGlobalMessageStreamHub,
|
|
18
8
|
} from './global-hub.js';
|
|
19
9
|
|
|
20
10
|
export {
|
|
21
|
-
DEFAULT_UPSTREAM_RECONNECT_DELAY_MS,
|
|
22
11
|
DEFAULT_UPSTREAM_STALL_TIMEOUT_MS,
|
|
23
12
|
UPSTREAM_STALL_TIMEOUT_CONCURRENT_MS,
|
|
24
|
-
createUpstreamSseReader,
|
|
25
13
|
} from './upstream-reader.js';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it,
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
|
|
3
3
|
const gitLibraries = {
|
|
4
|
-
stageFiles:
|
|
5
|
-
unstageFiles:
|
|
4
|
+
stageFiles: vi.fn(),
|
|
5
|
+
unstageFiles: vi.fn(),
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
mock
|
|
8
|
+
vi.mock('./index.js', () => ({
|
|
9
9
|
stageFiles: gitLibraries.stageFiles,
|
|
10
10
|
unstageFiles: gitLibraries.unstageFiles,
|
|
11
11
|
}));
|
|
@@ -3550,6 +3550,19 @@ export async function validateWorktreeCreate(directory, input = {}) {
|
|
|
3550
3550
|
}
|
|
3551
3551
|
}
|
|
3552
3552
|
|
|
3553
|
+
const assertWorktreeCreatePreflight = async (directory, input = {}) => {
|
|
3554
|
+
const validation = await validateWorktreeCreate(directory, input);
|
|
3555
|
+
if (validation?.ok) {
|
|
3556
|
+
return;
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
const message = validation?.errors
|
|
3560
|
+
?.map((error) => error?.message)
|
|
3561
|
+
.filter(Boolean)
|
|
3562
|
+
.join('\n') || 'Failed to validate worktree creation';
|
|
3563
|
+
throw new Error(message);
|
|
3564
|
+
};
|
|
3565
|
+
|
|
3553
3566
|
export async function previewWorktreeCreate(directory, input = {}) {
|
|
3554
3567
|
const mode = input?.mode === 'existing' ? 'existing' : 'new';
|
|
3555
3568
|
const context = await resolveWorktreeProjectContext(directory);
|
|
@@ -3698,6 +3711,11 @@ async function attachGitWorktreeToCandidate(context, candidate, input = {}) {
|
|
|
3698
3711
|
export async function createWorktree(directory, input = {}) {
|
|
3699
3712
|
const mode = input?.mode === 'existing' ? 'existing' : 'new';
|
|
3700
3713
|
const context = await resolveWorktreeProjectContext(directory);
|
|
3714
|
+
|
|
3715
|
+
if (input?.returnAfterDirectoryCreated === true) {
|
|
3716
|
+
await assertWorktreeCreatePreflight(directory, input);
|
|
3717
|
+
}
|
|
3718
|
+
|
|
3701
3719
|
await fsp.mkdir(context.worktreeRoot, { recursive: true });
|
|
3702
3720
|
|
|
3703
3721
|
const preferredName = String(input?.worktreeName || input?.name || '').trim();
|
|
@@ -8,6 +8,7 @@ import simpleGit from 'simple-git';
|
|
|
8
8
|
import {
|
|
9
9
|
checkoutCommit,
|
|
10
10
|
cherryPick,
|
|
11
|
+
createWorktree,
|
|
11
12
|
getStatus,
|
|
12
13
|
removeWorktree,
|
|
13
14
|
resolvePrimaryWorktreeRoot,
|
|
@@ -315,6 +316,53 @@ describe('worktree root resolution', () => {
|
|
|
315
316
|
});
|
|
316
317
|
});
|
|
317
318
|
|
|
319
|
+
// ---------------------------------------------------------------------------
|
|
320
|
+
// createWorktree
|
|
321
|
+
// ---------------------------------------------------------------------------
|
|
322
|
+
|
|
323
|
+
describe('createWorktree', () => {
|
|
324
|
+
it('preflights fast create branch-in-use failures before creating the candidate directory', async () => {
|
|
325
|
+
if (!canRunGit()) return;
|
|
326
|
+
|
|
327
|
+
const previousXdgDataHome = process.env.XDG_DATA_HOME;
|
|
328
|
+
const dataHome = createTempDir();
|
|
329
|
+
process.env.XDG_DATA_HOME = dataHome;
|
|
330
|
+
|
|
331
|
+
try {
|
|
332
|
+
const repo = createTempDir();
|
|
333
|
+
const worktree = createTempDir();
|
|
334
|
+
runGit(repo, ['init', '-b', 'main']);
|
|
335
|
+
runGit(repo, ['config', 'user.email', 'test@example.com']);
|
|
336
|
+
runGit(repo, ['config', 'user.name', 'Test User']);
|
|
337
|
+
fs.writeFileSync(path.join(repo, 'README.md'), '# Test\n');
|
|
338
|
+
runGit(repo, ['add', 'README.md']);
|
|
339
|
+
runGit(repo, ['commit', '-m', 'Initial commit']);
|
|
340
|
+
const projectID = runGit(repo, ['rev-list', '--max-parents=0', '--all']).trim();
|
|
341
|
+
|
|
342
|
+
fs.rmSync(worktree, { recursive: true, force: true });
|
|
343
|
+
runGit(repo, ['worktree', 'add', '-b', 'feature/in-use', worktree, 'HEAD']);
|
|
344
|
+
const canonicalWorktree = fs.realpathSync(worktree);
|
|
345
|
+
|
|
346
|
+
await expect(createWorktree(repo, {
|
|
347
|
+
mode: 'existing',
|
|
348
|
+
existingBranch: 'feature/in-use',
|
|
349
|
+
branchName: 'feature/in-use',
|
|
350
|
+
worktreeName: 'feature-in-use',
|
|
351
|
+
returnAfterDirectoryCreated: true,
|
|
352
|
+
})).rejects.toThrow(`Branch is already checked out in ${canonicalWorktree}`);
|
|
353
|
+
|
|
354
|
+
const candidateDirectory = path.join(dataHome, 'opencode', 'worktree', projectID, 'feature-in-use');
|
|
355
|
+
expect(fs.existsSync(candidateDirectory)).toBe(false);
|
|
356
|
+
} finally {
|
|
357
|
+
if (previousXdgDataHome === undefined) {
|
|
358
|
+
delete process.env.XDG_DATA_HOME;
|
|
359
|
+
} else {
|
|
360
|
+
process.env.XDG_DATA_HOME = previousXdgDataHome;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
|
|
318
366
|
// ---------------------------------------------------------------------------
|
|
319
367
|
// removeWorktree
|
|
320
368
|
// ---------------------------------------------------------------------------
|
|
@@ -982,6 +982,7 @@ export function registerGitHubRoutes(app) {
|
|
|
982
982
|
if (upstream) {
|
|
983
983
|
try {
|
|
984
984
|
const { getRemotes } = await import('../git/index.js');
|
|
985
|
+
const { resolveGitHubRepoFromDirectory } = await import('./index.js');
|
|
985
986
|
const remotes = await getRemotes(directory);
|
|
986
987
|
for (const r of remotes) {
|
|
987
988
|
if (r?.name) {
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { createNotificationTriggerRuntime } from './runtime.js';
|
|
3
|
-
export { createPushRuntime } from './push-runtime.js';
|
|
4
|
-
export { createNotificationTemplateRuntime } from './template-runtime.js';
|
|
1
|
+
export { prepareNotificationLastMessage } from './message.js';
|
|
@@ -685,12 +685,6 @@ function deleteAgent(agentName, workingDirectory, scope) {
|
|
|
685
685
|
}
|
|
686
686
|
|
|
687
687
|
export {
|
|
688
|
-
ensureProjectAgentDir,
|
|
689
|
-
getProjectAgentPath,
|
|
690
|
-
getUserAgentPath,
|
|
691
|
-
getAgentScope,
|
|
692
|
-
getAgentWritePath,
|
|
693
|
-
getAgentPermissionSource,
|
|
694
688
|
getAgentSources,
|
|
695
689
|
getAgentConfig,
|
|
696
690
|
createAgent,
|
|
@@ -327,11 +327,6 @@ function deleteCommand(commandName, workingDirectory) {
|
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
export {
|
|
330
|
-
ensureProjectCommandDir,
|
|
331
|
-
getProjectCommandPath,
|
|
332
|
-
getUserCommandPath,
|
|
333
|
-
getCommandScope,
|
|
334
|
-
getCommandWritePath,
|
|
335
330
|
getCommandSources,
|
|
336
331
|
createCommand,
|
|
337
332
|
updateCommand,
|
|
@@ -26,6 +26,30 @@ export const registerConfigEntityRoutes = (app, dependencies) => {
|
|
|
26
26
|
expandSnippets,
|
|
27
27
|
} = dependencies;
|
|
28
28
|
|
|
29
|
+
// Build the response for a config mutation based on whether OpenCode actually
|
|
30
|
+
// reloaded the change. When connected to an external OpenCode server that
|
|
31
|
+
// OpenChamber cannot restart, the change is persisted to disk but the running
|
|
32
|
+
// server will not serve it until the user restarts that server. We must not
|
|
33
|
+
// report a clean "reloading" success in that case, otherwise the UI silently
|
|
34
|
+
// reverts the edit to the stale value on the next refresh.
|
|
35
|
+
const buildConfigMutationResponse = (refreshResult, { liveMessage, manualRestartMessage }) => {
|
|
36
|
+
if (refreshResult && refreshResult.external) {
|
|
37
|
+
return {
|
|
38
|
+
success: true,
|
|
39
|
+
requiresReload: false,
|
|
40
|
+
requiresManualRestart: true,
|
|
41
|
+
message: manualRestartMessage,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
success: true,
|
|
47
|
+
requiresReload: true,
|
|
48
|
+
message: liveMessage,
|
|
49
|
+
reloadDelayMs: clientReloadDelayMs,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
29
53
|
const completeMcpMutation = async (res, action, name, applyChange) => {
|
|
30
54
|
applyChange();
|
|
31
55
|
|
|
@@ -104,16 +128,14 @@ export const registerConfigEntityRoutes = (app, dependencies) => {
|
|
|
104
128
|
console.log('[Server] Scope:', scope, 'Working directory:', directory);
|
|
105
129
|
|
|
106
130
|
createAgent(agentName, config, directory, scope);
|
|
107
|
-
await refreshOpenCodeAfterConfigChange('agent creation', {
|
|
131
|
+
const refreshResult = await refreshOpenCodeAfterConfigChange('agent creation', {
|
|
108
132
|
agentName
|
|
109
133
|
});
|
|
110
134
|
|
|
111
|
-
res.json({
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
reloadDelayMs: clientReloadDelayMs,
|
|
116
|
-
});
|
|
135
|
+
res.json(buildConfigMutationResponse(refreshResult, {
|
|
136
|
+
liveMessage: `Agent ${agentName} created successfully. Reloading interface…`,
|
|
137
|
+
manualRestartMessage: `Agent ${agentName} saved. Restart your connected OpenCode server to apply the change.`,
|
|
138
|
+
}));
|
|
117
139
|
} catch (error) {
|
|
118
140
|
console.error('Failed to create agent:', error);
|
|
119
141
|
res.status(500).json({ error: error.message || 'Failed to create agent' });
|
|
@@ -134,16 +156,14 @@ export const registerConfigEntityRoutes = (app, dependencies) => {
|
|
|
134
156
|
console.log('[Server] Working directory:', directory);
|
|
135
157
|
|
|
136
158
|
updateAgent(agentName, updates, directory);
|
|
137
|
-
await refreshOpenCodeAfterConfigChange('agent update');
|
|
159
|
+
const refreshResult = await refreshOpenCodeAfterConfigChange('agent update');
|
|
138
160
|
|
|
139
161
|
console.log(`[Server] Agent ${agentName} updated successfully`);
|
|
140
162
|
|
|
141
|
-
res.json({
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
reloadDelayMs: clientReloadDelayMs,
|
|
146
|
-
});
|
|
163
|
+
res.json(buildConfigMutationResponse(refreshResult, {
|
|
164
|
+
liveMessage: `Agent ${agentName} updated successfully. Reloading interface…`,
|
|
165
|
+
manualRestartMessage: `Agent ${agentName} saved. Restart your connected OpenCode server to apply the change.`,
|
|
166
|
+
}));
|
|
147
167
|
} catch (error) {
|
|
148
168
|
console.error('[Server] Failed to update agent:', error);
|
|
149
169
|
console.error('[Server] Error stack:', error.stack);
|
|
@@ -161,14 +181,12 @@ export const registerConfigEntityRoutes = (app, dependencies) => {
|
|
|
161
181
|
|
|
162
182
|
const scope = req.body?.scope;
|
|
163
183
|
deleteAgent(agentName, directory, scope);
|
|
164
|
-
await refreshOpenCodeAfterConfigChange('agent deletion');
|
|
184
|
+
const refreshResult = await refreshOpenCodeAfterConfigChange('agent deletion');
|
|
165
185
|
|
|
166
|
-
res.json({
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
reloadDelayMs: clientReloadDelayMs,
|
|
171
|
-
});
|
|
186
|
+
res.json(buildConfigMutationResponse(refreshResult, {
|
|
187
|
+
liveMessage: `Agent ${agentName} deleted successfully. Reloading interface…`,
|
|
188
|
+
manualRestartMessage: `Agent ${agentName} deleted. Restart your connected OpenCode server to apply the change.`,
|
|
189
|
+
}));
|
|
172
190
|
} catch (error) {
|
|
173
191
|
console.error('Failed to delete agent:', error);
|
|
174
192
|
res.status(500).json({ error: error.message || 'Failed to delete agent' });
|
|
@@ -13,6 +13,33 @@ import { registerPluginRoutes } from './plugin-routes.js';
|
|
|
13
13
|
import { getNpmInfo, clearCache as clearNpmCache } from './npm-registry.js';
|
|
14
14
|
import { parseNpmSpec, parsePathSpec, isExactSemver } from './plugin-spec.js';
|
|
15
15
|
import { registerOpenCodeRoutes } from './routes.js';
|
|
16
|
+
import { getProviderSources, removeProviderConfig } from './providers.js';
|
|
17
|
+
import { getAgentSources, getAgentConfig, createAgent, updateAgent, deleteAgent } from './agents.js';
|
|
18
|
+
import { getCommandSources, createCommand, updateCommand, deleteCommand } from './commands.js';
|
|
19
|
+
import { listMcpConfigs, getMcpConfig, createMcpConfig, updateMcpConfig, deleteMcpConfig } from './mcp.js';
|
|
20
|
+
import { listSnippets, getSnippet, createSnippet, updateSnippet, deleteSnippet, expandSnippets } from './snippets.js';
|
|
21
|
+
import {
|
|
22
|
+
listPluginEntries,
|
|
23
|
+
getPluginEntry,
|
|
24
|
+
createPluginEntry,
|
|
25
|
+
updatePluginEntry,
|
|
26
|
+
deletePluginEntry,
|
|
27
|
+
listPluginDirFiles,
|
|
28
|
+
readPluginDirFile,
|
|
29
|
+
writePluginDirFile,
|
|
30
|
+
deletePluginDirFile,
|
|
31
|
+
encodePluginId,
|
|
32
|
+
decodePluginId,
|
|
33
|
+
} from './plugins.js';
|
|
34
|
+
import { SKILL_DIR, SKILL_SCOPE, readSkillSupportingFile, writeSkillSupportingFile, deleteSkillSupportingFile } from './shared.js';
|
|
35
|
+
import { getSkillSources, discoverSkills, mergeDiscoveredSkills, createSkill, updateSkill, deleteSkill } from './skills.js';
|
|
36
|
+
import { getCuratedSkillsSources } from '../skills-catalog/curated-sources.js';
|
|
37
|
+
import { getCacheKey, getCachedScan, setCachedScan } from '../skills-catalog/cache.js';
|
|
38
|
+
import { isClawdHubSource, parseSkillRepoSource } from '../skills-catalog/source.js';
|
|
39
|
+
import { scanSkillsRepository } from '../skills-catalog/scan.js';
|
|
40
|
+
import { installSkillsFromRepository } from '../skills-catalog/install.js';
|
|
41
|
+
import { scanClawdHubPage } from '../skills-catalog/clawdhub/scan.js';
|
|
42
|
+
import { installSkillsFromClawdHub } from '../skills-catalog/clawdhub/install.js';
|
|
16
43
|
|
|
17
44
|
export const createFeatureRoutesRuntime = (dependencies) => {
|
|
18
45
|
const {
|
|
@@ -63,8 +90,6 @@ export const createFeatureRoutesRuntime = (dependencies) => {
|
|
|
63
90
|
writeSseEvent,
|
|
64
91
|
} = routeDependencies;
|
|
65
92
|
|
|
66
|
-
const { getProviderSources, removeProviderConfig } = await import('./index.js');
|
|
67
|
-
|
|
68
93
|
registerSettingsUtilityRoutes(app, {
|
|
69
94
|
readCustomThemesFromDisk,
|
|
70
95
|
refreshOpenCodeAfterConfigChange,
|
|
@@ -111,40 +136,6 @@ export const createFeatureRoutesRuntime = (dependencies) => {
|
|
|
111
136
|
writeSseEvent,
|
|
112
137
|
});
|
|
113
138
|
|
|
114
|
-
const {
|
|
115
|
-
getAgentSources,
|
|
116
|
-
getAgentConfig,
|
|
117
|
-
createAgent,
|
|
118
|
-
updateAgent,
|
|
119
|
-
deleteAgent,
|
|
120
|
-
getCommandSources,
|
|
121
|
-
createCommand,
|
|
122
|
-
updateCommand,
|
|
123
|
-
deleteCommand,
|
|
124
|
-
listMcpConfigs,
|
|
125
|
-
getMcpConfig,
|
|
126
|
-
createMcpConfig,
|
|
127
|
-
updateMcpConfig,
|
|
128
|
-
deleteMcpConfig,
|
|
129
|
-
listSnippets,
|
|
130
|
-
getSnippet,
|
|
131
|
-
createSnippet,
|
|
132
|
-
updateSnippet,
|
|
133
|
-
deleteSnippet,
|
|
134
|
-
expandSnippets,
|
|
135
|
-
listPluginEntries,
|
|
136
|
-
getPluginEntry,
|
|
137
|
-
createPluginEntry,
|
|
138
|
-
updatePluginEntry,
|
|
139
|
-
deletePluginEntry,
|
|
140
|
-
listPluginDirFiles,
|
|
141
|
-
readPluginDirFile,
|
|
142
|
-
writePluginDirFile,
|
|
143
|
-
deletePluginDirFile,
|
|
144
|
-
encodePluginId,
|
|
145
|
-
decodePluginId,
|
|
146
|
-
} = await import('./index.js');
|
|
147
|
-
|
|
148
139
|
registerConfigEntityRoutes(app, {
|
|
149
140
|
resolveProjectDirectory,
|
|
150
141
|
resolveOptionalProjectDirectory,
|
|
@@ -193,32 +184,6 @@ export const createFeatureRoutesRuntime = (dependencies) => {
|
|
|
193
184
|
isExactSemver,
|
|
194
185
|
});
|
|
195
186
|
|
|
196
|
-
const {
|
|
197
|
-
getSkillSources,
|
|
198
|
-
discoverSkills,
|
|
199
|
-
mergeDiscoveredSkills,
|
|
200
|
-
createSkill,
|
|
201
|
-
updateSkill,
|
|
202
|
-
deleteSkill,
|
|
203
|
-
readSkillSupportingFile,
|
|
204
|
-
writeSkillSupportingFile,
|
|
205
|
-
deleteSkillSupportingFile,
|
|
206
|
-
SKILL_SCOPE,
|
|
207
|
-
SKILL_DIR,
|
|
208
|
-
} = await import('./index.js');
|
|
209
|
-
|
|
210
|
-
const {
|
|
211
|
-
getCuratedSkillsSources,
|
|
212
|
-
getCacheKey,
|
|
213
|
-
getCachedScan,
|
|
214
|
-
setCachedScan,
|
|
215
|
-
parseSkillRepoSource,
|
|
216
|
-
scanSkillsRepository,
|
|
217
|
-
installSkillsFromRepository,
|
|
218
|
-
scanClawdHubPage,
|
|
219
|
-
installSkillsFromClawdHub,
|
|
220
|
-
isClawdHubSource,
|
|
221
|
-
} = await import('../skills-catalog/index.js');
|
|
222
187
|
const { getProfiles, getProfile } = await import('../git/index.js');
|
|
223
188
|
|
|
224
189
|
registerSkillRoutes(app, {
|
|
@@ -753,12 +753,22 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|
|
753
753
|
|
|
754
754
|
await restartOpenCode();
|
|
755
755
|
|
|
756
|
+
// A managed OpenCode process is restarted (and thus re-reads config from
|
|
757
|
+
// disk) by restartOpenCode(). An external OpenCode server is NOT owned by
|
|
758
|
+
// OpenChamber: restartOpenCode() only re-probes its health, so the freshly
|
|
759
|
+
// written config is on disk but the running server keeps serving its old,
|
|
760
|
+
// startup-cached config until the user restarts it themselves. Report this
|
|
761
|
+
// honestly so callers don't claim the change is live.
|
|
762
|
+
const external = state.isExternalOpenCode === true;
|
|
763
|
+
|
|
756
764
|
try {
|
|
757
765
|
await waitForOpenCodeReady();
|
|
758
766
|
state.isOpenCodeReady = true;
|
|
759
767
|
state.openCodeNotReadySince = 0;
|
|
760
768
|
|
|
761
|
-
|
|
769
|
+
// Waiting for the agent to appear only makes sense when we actually
|
|
770
|
+
// reloaded config. An external server will never surface it here.
|
|
771
|
+
if (agentName && !external) {
|
|
762
772
|
await waitForAgentPresence(agentName);
|
|
763
773
|
}
|
|
764
774
|
|
|
@@ -770,6 +780,8 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|
|
770
780
|
console.error(`Failed to refresh OpenCode after ${reason}:`, error.message);
|
|
771
781
|
throw error;
|
|
772
782
|
}
|
|
783
|
+
|
|
784
|
+
return { reloaded: !external, external };
|
|
773
785
|
};
|
|
774
786
|
|
|
775
787
|
const bootstrapOpenCodeAtStartup = async () => {
|
|
@@ -2,9 +2,9 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const NPM_CACHE_TTL_MS = 3_600_000;
|
|
6
|
+
const NPM_FETCH_TIMEOUT_MS = 5_000;
|
|
7
|
+
const NPM_REGISTRY_BASE = 'https://registry.npmjs.org';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {Object} NpmPackagePayload
|
|
@@ -50,7 +50,7 @@ export const normalizeForwardedDirectoryHeaders = (headers) => {
|
|
|
50
50
|
return headers;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
const waitForSseDrain = (res, signal) => new Promise((resolve) => {
|
|
54
54
|
if (signal?.aborted || res.writableEnded || res.destroyed) {
|
|
55
55
|
resolve();
|
|
56
56
|
return;
|
|
@@ -132,7 +132,7 @@ const SESSION_LIST_ALLOWED_FIELDS = [
|
|
|
132
132
|
'project',
|
|
133
133
|
];
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
const sanitizeSessionListItem = (session) => {
|
|
136
136
|
if (!session || typeof session !== 'object' || Array.isArray(session)) {
|
|
137
137
|
return session;
|
|
138
138
|
}
|
|
@@ -168,7 +168,7 @@ export const sanitizeSessionListItem = (session) => {
|
|
|
168
168
|
return sanitized;
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
const sanitizeSessionListPayload = (payload) => {
|
|
172
172
|
if (!Array.isArray(payload)) {
|
|
173
173
|
return payload;
|
|
174
174
|
}
|
|
@@ -507,20 +507,14 @@ export {
|
|
|
507
507
|
COMMAND_DIR,
|
|
508
508
|
SKILL_DIR,
|
|
509
509
|
CONFIG_FILE,
|
|
510
|
-
CUSTOM_CONFIG_FILE,
|
|
511
|
-
PROMPT_FILE_PATTERN,
|
|
512
510
|
AGENT_SCOPE,
|
|
513
511
|
COMMAND_SCOPE,
|
|
514
512
|
SKILL_SCOPE,
|
|
515
513
|
ensureDirs,
|
|
516
514
|
parseMdFile,
|
|
517
515
|
writeMdFile,
|
|
518
|
-
getProjectConfigCandidates,
|
|
519
|
-
getProjectConfigPath,
|
|
520
|
-
getConfigPaths,
|
|
521
516
|
readConfigFile,
|
|
522
517
|
isPlainObject,
|
|
523
|
-
mergeConfigs,
|
|
524
518
|
readConfigLayers,
|
|
525
519
|
readConfig,
|
|
526
520
|
getConfigForPath,
|
|
@@ -240,5 +240,3 @@ export function expandSnippets(text, workingDirectory) {
|
|
|
240
240
|
const expanded = expandText(text || '', registry, new Map(), collector).trim();
|
|
241
241
|
return [...collector.prepend, expanded, ...collector.append].filter(Boolean).join('\n\n');
|
|
242
242
|
}
|
|
243
|
-
|
|
244
|
-
export { assertValidSnippetName };
|
|
@@ -483,7 +483,7 @@ export function detectPackageManagerDetails() {
|
|
|
483
483
|
};
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
-
|
|
486
|
+
function detectPackageManager() {
|
|
487
487
|
return detectPackageManagerDetails().packageManager;
|
|
488
488
|
}
|
|
489
489
|
|
|
@@ -634,7 +634,7 @@ export function getCurrentVersion() {
|
|
|
634
634
|
/**
|
|
635
635
|
* Fetch latest version from npm registry
|
|
636
636
|
*/
|
|
637
|
-
|
|
637
|
+
async function getLatestVersion() {
|
|
638
638
|
try {
|
|
639
639
|
const response = await fetch(NPM_REGISTRY_URL, {
|
|
640
640
|
headers: { Accept: 'application/json' },
|
|
@@ -690,7 +690,7 @@ function compareVersions(left, right) {
|
|
|
690
690
|
/**
|
|
691
691
|
* Fetch changelog notes between versions
|
|
692
692
|
*/
|
|
693
|
-
|
|
693
|
+
async function fetchChangelogNotes(fromVersion, toVersion) {
|
|
694
694
|
try {
|
|
695
695
|
const response = await fetch(CHANGELOG_URL, {
|
|
696
696
|
signal: AbortSignal.timeout(10000),
|
|
@@ -769,7 +769,7 @@ export async function checkForUpdates(options = {}) {
|
|
|
769
769
|
/**
|
|
770
770
|
* Execute the update (used by CLI)
|
|
771
771
|
*/
|
|
772
|
-
|
|
772
|
+
function executeUpdate(pm = detectPackageManager(), options = {}) {
|
|
773
773
|
const command = getUpdateCommand(pm);
|
|
774
774
|
if (!options?.silent) {
|
|
775
775
|
console.log(`Updating ${PACKAGE_NAME} using ${pm}...`);
|
|
@@ -6,7 +6,7 @@ vi.mock('node:child_process', () => ({
|
|
|
6
6
|
spawnSync: vi.fn(() => ({ status: 0, stdout: '/usr/local/bin', stderr: '' })),
|
|
7
7
|
}));
|
|
8
8
|
|
|
9
|
-
const { checkForUpdates } = await import('./package-manager.js');
|
|
9
|
+
const { checkForUpdates, getCurrentVersion } = await import('./package-manager.js');
|
|
10
10
|
|
|
11
11
|
/** Helper: create a fetch mock that routes by URL pattern */
|
|
12
12
|
function createFetchMock() {
|
|
@@ -244,3 +244,10 @@ describe('checkForUpdates', () => {
|
|
|
244
244
|
expect(result.available).toBe(false);
|
|
245
245
|
});
|
|
246
246
|
});
|
|
247
|
+
|
|
248
|
+
describe('getCurrentVersion', () => {
|
|
249
|
+
it('is exported for the CLI update command', () => {
|
|
250
|
+
expect(typeof getCurrentVersion).toBe('function');
|
|
251
|
+
expect(getCurrentVersion()).toMatch(/^\d+\.\d+\.\d+|unknown$/);
|
|
252
|
+
});
|
|
253
|
+
});
|