@openchamber/web 1.23.2 → 1.24.0
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-DdNGwbBw.js → CodeMirrorCommentWidgets-C9kV-n7r.js} +1 -1
- package/dist/assets/DiffView-B7YkbY-u.js +4 -0
- package/dist/assets/DirtyBranchSwitchDialog-CU0A93Zx.js +1 -0
- package/dist/assets/FilesView-vjJx7VaM.js +13 -0
- package/dist/assets/GitView-BLhlMYEY.js +6 -0
- package/dist/assets/GuestAttachDialog-B-fwE8r3.js +3 -0
- package/dist/assets/{JsonTreeView-Chzx5Y6N.js → JsonTreeView-D_4G5X6-.js} +1 -1
- package/dist/assets/LinearIssuesView-1uKhePfH.js +1 -0
- package/dist/assets/{MarkdownImageGallery-CugnrZ6f.js → MarkdownImageGallery-Ix7N_2wp.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-Deel_y5S.js +12 -0
- package/dist/assets/{OnboardingScreen-hH9xcTjA.js → OnboardingScreen-ToIakxb_.js} +1 -1
- package/dist/assets/{PatchDiff-DRgNYc9l.js → PatchDiff-BjMgezr1.js} +1 -1
- package/dist/assets/{PierreDiffViewer-ZT2CKuzJ.js → PierreDiffViewer-53Ghfnlr.js} +5 -5
- package/dist/assets/PlanView-BGAzxDwD.js +5 -0
- package/dist/assets/SettingsView-n2X-jfBB.js +29 -0
- package/dist/assets/SettingsWindow-Bi8LE9XI.js +1 -0
- package/dist/assets/SubmoduleDiffSummary--YFqK6Ih.js +1 -0
- package/dist/assets/ToolOutputDialog-DRWBvdaJ.js +15 -0
- package/dist/assets/{ToolPartDiffPreview-oWxWCu-4.js → ToolPartDiffPreview-BxZJCU28.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-CiyrAq_I.js → VirtualizedFileDiff-DCXjBGRf.js} +3 -3
- package/dist/assets/{WalkthroughView-CKTevaea.js → WalkthroughView-CfIPvWWa.js} +2 -2
- package/dist/assets/appThemeRegistry-DDROzcUO.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-SUWoTyPe.js → computeVirtualFileMetrics-DHgQIkUq.js} +1 -1
- package/dist/assets/de-CX_f-T5U.js +10 -0
- package/dist/assets/es-BERmWNn_.js +16 -0
- package/dist/assets/fr-BjYYE_-z.js +14 -0
- package/dist/assets/index-DpzTz2UH.css +1 -0
- package/dist/assets/index-Dy8xgawx.js +40 -0
- package/dist/assets/{index-C4jJ3Ur5.js → index-WjufPkIV.js} +1 -1
- package/dist/assets/{isDiffPlainText-DfG0cZxr.js → isDiffPlainText-D9faP70y.js} +1 -1
- package/dist/assets/{isFilePlainText-CyNivOCU.js → isFilePlainText-6qOcz5Ky.js} +1 -1
- package/dist/assets/ja-DxqeAk9N.js +16 -0
- package/dist/assets/ko-Dty1aUod.js +16 -0
- package/dist/assets/main-BOYSXfYn.js +896 -0
- package/dist/assets/{main-B8cGozKr.js → main-Bjcre_GE.js} +2 -2
- package/dist/assets/{markdown-shiki.worker-D5fBU-lw.js → markdown-shiki.worker-CahLvHIq.js} +5 -5
- package/dist/assets/{markdownCore-kyGrWGsn.js → markdownCore-DPrwM1rU.js} +5 -5
- package/dist/assets/{miniChat-Cay99IxR.js → miniChat-Dz_bPgMc.js} +2 -2
- package/dist/assets/{mobile-Zfhix7nz.js → mobile-BbZPBJrK.js} +2 -2
- package/dist/assets/{patchFileDiff-CJ5AN9Ql.js → patchFileDiff-BvU6KOQC.js} +3 -3
- package/dist/assets/pl-CX-_ROkr.js +16 -0
- package/dist/assets/{pt-BR-CLosVawq.js → pt-BR-DhRR1arx.js} +4 -4
- package/dist/assets/renderElectronMiniChatApp-uNEUkeAI.js +2 -0
- package/dist/assets/renderMobileApp-BK1kFlcJ.js +25 -0
- package/dist/assets/runtimeEndpointReset-BULHvOwb.js +25 -0
- package/dist/assets/{scheduledTasksApi-CGFV4Pap.js → scheduledTasksApi-DW3xqMQ8.js} +1 -1
- package/dist/assets/shikiHighlight-DsxD9QEa.js +1 -0
- package/dist/assets/textMateThemeFromAppTheme-Da7ed8qM.js +1 -0
- package/dist/assets/tr-cIQtYBpg.js +7 -0
- package/dist/assets/uk-CD21CXFV.js +16 -0
- package/dist/assets/{useAppFontEffects-DgCHy6Mr.js → useAppFontEffects-hfv2s6mZ.js} +198 -147
- package/dist/assets/useInlineCommentController-BmtfVbo8.js +2 -0
- package/dist/assets/useRootScrollLock-Cwc4kSl2.js +1 -0
- package/dist/assets/{vendor-base-ui-BY_5qla_.js → vendor-base-ui-CsXYnR5c.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-ES33GhKK.js → vendor-codemirror-language-data-BPMJpOpT.js} +2 -2
- package/dist/assets/vendor-framer-motion-Bq3iTZ6r.js +1 -0
- package/dist/assets/{vendor-motion-dom-D_o3BTI3.js → vendor-motion-dom-DcCgeG69.js} +1 -1
- package/dist/assets/vendor-strip-json-comments-5dJlOkP1.js +4 -0
- package/dist/assets/{vendor-zod-B6551dwG.js → vendor-zod-fZppILAM.js} +4 -4
- package/dist/assets/{web-components-CJZwV5BE.js → web-components-U-hWbgJo.js} +2 -2
- package/dist/assets/zh-CN-BWvlPHY-.js +16 -0
- package/dist/assets/zh-TW-CRp5dJU2.js +16 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +7 -5
- package/server/built-in-extensions/registry.json +4 -0
- package/server/index.d.ts +2 -0
- package/server/index.js +15 -3
- package/server/lib/fs/DOCUMENTATION.md +8 -0
- package/server/lib/fs/git-process.test.js +77 -0
- package/server/lib/fs/routes.js +2 -1
- package/server/lib/fs/search.js +2 -1
- package/server/lib/git/DOCUMENTATION.md +3 -1
- package/server/lib/git/routes.js +16 -3
- package/server/lib/git/service.js +112 -8
- package/server/lib/git/service.test.js +127 -0
- package/server/lib/guests/DOCUMENTATION.md +66 -0
- package/server/lib/guests/auth-store.js +184 -0
- package/server/lib/guests/auth-store.test.js +112 -0
- package/server/lib/guests/builtins.js +34 -0
- package/server/lib/guests/builtins.test.js +174 -0
- package/server/lib/guests/catalog.js +466 -0
- package/server/lib/guests/catalog.test.js +390 -0
- package/server/lib/guests/clone.js +297 -0
- package/server/lib/guests/extract-zip.js +136 -0
- package/server/lib/guests/extract-zip.test.js +109 -0
- package/server/lib/guests/files.js +308 -0
- package/server/lib/guests/files.test.js +262 -0
- package/server/lib/guests/grant-scope.js +81 -0
- package/server/lib/guests/grant-scope.test.js +75 -0
- package/server/lib/guests/host-session.js +73 -0
- package/server/lib/guests/host-session.test.js +30 -0
- package/server/lib/guests/html-styles.js +6 -0
- package/server/lib/guests/html-styles.test.js +45 -0
- package/server/lib/guests/html-tokens.js +73 -0
- package/server/lib/guests/html-tokens.test.js +53 -0
- package/server/lib/guests/install.js +406 -0
- package/server/lib/guests/install.test.js +338 -0
- package/server/lib/guests/oauth.js +501 -0
- package/server/lib/guests/oauth.test.js +481 -0
- package/server/lib/guests/persist.js +336 -0
- package/server/lib/guests/persist.test.js +288 -0
- package/server/lib/guests/request.js +112 -0
- package/server/lib/guests/request.test.js +206 -0
- package/server/lib/guests/routes.js +838 -0
- package/server/lib/guests/service.js +538 -0
- package/server/lib/guests/service.test.js +277 -0
- package/server/lib/guests/sockets.js +129 -0
- package/server/lib/guests/sockets.test.js +110 -0
- package/server/lib/guests/ssh-install.test.js +188 -0
- package/server/lib/guests/storage.js +68 -0
- package/server/lib/guests/storage.test.js +59 -0
- package/server/lib/guests/updates.js +294 -0
- package/server/lib/guests/updates.test.js +334 -0
- package/server/lib/guests/upload.js +50 -0
- package/server/lib/guests/upload.test.js +131 -0
- package/server/lib/linear/DOCUMENTATION.md +1 -1
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -0
- package/server/lib/openchamber-sessions/routes.js +44 -11
- package/server/lib/openchamber-sessions/routes.test.js +47 -0
- package/server/lib/opencode/DOCUMENTATION.md +40 -0
- package/server/lib/opencode/core-routes.js +39 -1
- package/server/lib/opencode/feature-routes-runtime.js +10 -0
- package/server/lib/opencode/lifecycle-process.test.js +84 -0
- package/server/lib/opencode/lifecycle.js +54 -67
- package/server/lib/opencode/settings-normalization-runtime.js +2 -0
- package/server/lib/opencode/settings-normalization-runtime.test.js +13 -0
- package/server/lib/opencode/settings-registry.json +4 -0
- package/server/lib/opencode/shutdown-runtime.js +3 -0
- package/server/lib/opencode/shutdown-runtime.test.js +24 -0
- package/server/lib/opencode/theme-archive.js +53 -0
- package/server/lib/opencode/theme-catalog.js +171 -0
- package/server/lib/opencode/theme-catalog.test.js +125 -0
- package/server/lib/opencode/theme-import.test.js +144 -0
- package/server/lib/opencode/theme-runtime.js +100 -28
- package/server/lib/opencode/theme-runtime.test.js +15 -0
- package/server/lib/quota/DOCUMENTATION.md +0 -1
- package/server/lib/quota/providers/index.js +0 -7
- package/server/lib/terminal/DOCUMENTATION.md +2 -0
- package/server/lib/terminal/runtime.js +17 -2
- package/server/lib/terminal/runtime.test.js +45 -0
- package/server/lib/ui-auth/ui-auth.js +43 -8
- package/server/lib/ui-auth/ui-auth.test.js +40 -0
- package/dist/assets/DiffView-GYriC0Wk.js +0 -4
- package/dist/assets/DirtyBranchSwitchDialog-Bv0C99hc.js +0 -1
- package/dist/assets/FilesView-2Lin13wx.js +0 -13
- package/dist/assets/GitView-9wKba3UO.js +0 -6
- package/dist/assets/LinearIssuesView-DXS9QJiR.js +0 -1
- package/dist/assets/MarkdownRendererImpl-CaMyct2Q.js +0 -12
- package/dist/assets/PlanView-DiTBm2BD.js +0 -5
- package/dist/assets/SettingsView-CN8VeM99.js +0 -28
- package/dist/assets/SettingsWindow-DisOghhD.js +0 -1
- package/dist/assets/ToolOutputDialog-BqiKydxR.js +0 -15
- package/dist/assets/appThemeRegistry-BK0dHKa6.js +0 -1
- package/dist/assets/de-DQWC94VK.js +0 -10
- package/dist/assets/es-DixFUD3m.js +0 -16
- package/dist/assets/fr-D6u8tvfA.js +0 -14
- package/dist/assets/index-BvpFzhLs.js +0 -40
- package/dist/assets/index-n5p3SnES.css +0 -1
- package/dist/assets/ja-4u4pCorB.js +0 -16
- package/dist/assets/ko-C27-LW_b.js +0 -16
- package/dist/assets/main-tEA-fFPg.js +0 -930
- package/dist/assets/pl-FtCjsNdW.js +0 -16
- package/dist/assets/registerCustomTheme-BBXUCRnG.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-CuHOGlF4.js +0 -2
- package/dist/assets/renderMobileApp-C4X_KUH8.js +0 -25
- package/dist/assets/runtimeEndpointReset-CMg-KUx3.js +0 -41
- package/dist/assets/shikiHighlight-DdKWYWrV.js +0 -1
- package/dist/assets/tr-D2j6wUez.js +0 -7
- package/dist/assets/uk-C6IzmwM_.js +0 -16
- package/dist/assets/useGitComparison-BIaI0WZI.js +0 -1
- package/dist/assets/useInlineCommentController-2wcCtpM3.js +0 -2
- package/dist/assets/useRootScrollLock-CbWA03xR.js +0 -1
- package/dist/assets/vendor-framer-motion-livSKyyV.js +0 -1
- package/dist/assets/zh-CN-Wl6tIDz1.js +0 -16
- package/dist/assets/zh-TW-hgphoWSN.js +0 -16
- package/server/lib/quota/providers/crof.js +0 -96
- package/server/lib/quota/providers/crof.test.js +0 -98
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
|
|
7
|
+
import { findInstalledGuest, listInstalledGuests } from './catalog.js';
|
|
8
|
+
import { isGitRef, parseGitInstallUrl } from './clone.js';
|
|
9
|
+
import { installGuestFromGitSource } from './install.js';
|
|
10
|
+
import { readExtensionStore } from './persist.js';
|
|
11
|
+
import {
|
|
12
|
+
UPDATE_CHECK_TTL_MS,
|
|
13
|
+
checkAllGuestUpdates,
|
|
14
|
+
checkGuestUpdate,
|
|
15
|
+
clearGuestUpdateCache,
|
|
16
|
+
compareSemver,
|
|
17
|
+
getCachedGuestUpdate,
|
|
18
|
+
updateGuest,
|
|
19
|
+
} from './updates.js';
|
|
20
|
+
|
|
21
|
+
const git = (cwd, args) => {
|
|
22
|
+
const result = spawnSync('git', args, {
|
|
23
|
+
cwd,
|
|
24
|
+
encoding: 'utf8',
|
|
25
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
26
|
+
});
|
|
27
|
+
if (result.status !== 0) {
|
|
28
|
+
throw new Error(result.stderr || `git ${args.join(' ')} failed`);
|
|
29
|
+
}
|
|
30
|
+
return result.stdout;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const manifest = (id, version, extra = {}) => JSON.stringify({
|
|
34
|
+
name: `@openchamber/${id}`,
|
|
35
|
+
version,
|
|
36
|
+
openchamber: {
|
|
37
|
+
apiVersion: 1,
|
|
38
|
+
contributes: {
|
|
39
|
+
panel: { id, name: id, icon: 'window', entry: 'panel/index.html' },
|
|
40
|
+
...extra,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const writeGuest = async (root, id, version, extra) => {
|
|
46
|
+
await fs.mkdir(path.join(root, 'panel'), { recursive: true });
|
|
47
|
+
await fs.writeFile(path.join(root, 'panel', 'index.html'), '<html></html>');
|
|
48
|
+
await fs.writeFile(path.join(root, 'package.json'), manifest(id, version, extra));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const commit = (cwd, message) => {
|
|
52
|
+
git(cwd, ['add', '.']);
|
|
53
|
+
git(cwd, ['-c', 'user.name=test', '-c', 'user.email=test@example.com', 'commit', '-q', '-m', message]);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A working repo plus a bare "remote" the install clones from, the way a
|
|
58
|
+
* hosted repository behaves: the bare repo has no working tree and gets new
|
|
59
|
+
* commits pushed to it.
|
|
60
|
+
*/
|
|
61
|
+
const setupRemote = async (dir, id, version = '1.0.0') => {
|
|
62
|
+
const work = path.join(dir, 'work');
|
|
63
|
+
const bare = path.join(dir, 'remote.git');
|
|
64
|
+
await writeGuest(work, id, version);
|
|
65
|
+
git(work, ['init', '-q', '--template=', '-b', 'main']);
|
|
66
|
+
commit(work, 'init');
|
|
67
|
+
// The bare repo's HEAD must name the branch that gets pushed; without -b
|
|
68
|
+
// it follows the machine's init.defaultBranch (master on CI), and a clone
|
|
69
|
+
// of a bare repo whose HEAD points at a missing branch checks out nothing.
|
|
70
|
+
git(dir, ['init', '-q', '--bare', '--template=', '-b', 'main', bare]);
|
|
71
|
+
git(work, ['remote', 'add', 'origin', bare]);
|
|
72
|
+
git(work, ['push', '-q', 'origin', 'main']);
|
|
73
|
+
return { work, bare };
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const pushVersion = async (work, id, version, extra) => {
|
|
77
|
+
await fs.writeFile(path.join(work, 'package.json'), manifest(id, version, extra));
|
|
78
|
+
commit(work, `v${version}`);
|
|
79
|
+
git(work, ['push', '-q', 'origin', 'HEAD']);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const installFrom = async (bare, persistPath, ref) => {
|
|
83
|
+
const installed = await installGuestFromGitSource(bare, persistPath, { openchamberVersion: '1.30.0', ref });
|
|
84
|
+
if (!installed.ok) {
|
|
85
|
+
throw new Error(`install failed: ${installed.code}`);
|
|
86
|
+
}
|
|
87
|
+
return installed.guest;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const loadGuest = async (id, persistPath) => {
|
|
91
|
+
const guest = await findInstalledGuest(id, persistPath);
|
|
92
|
+
if (!guest) {
|
|
93
|
+
throw new Error(`guest ${id} missing`);
|
|
94
|
+
}
|
|
95
|
+
return guest;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
describe('compareSemver', () => {
|
|
99
|
+
test('orders releases and puts prereleases below their release', () => {
|
|
100
|
+
expect(compareSemver('1.0.0', '1.0.0')).toBe(0);
|
|
101
|
+
expect(compareSemver('1.0.0', '1.0.1')).toBe(-1);
|
|
102
|
+
expect(compareSemver('1.10.0', '1.9.0')).toBe(1);
|
|
103
|
+
expect(compareSemver('2.0.0', '1.99.99')).toBe(1);
|
|
104
|
+
expect(compareSemver('1.1.0-beta.1', '1.1.0')).toBe(-1);
|
|
105
|
+
expect(compareSemver('1.1.0', '1.1.0-rc.1')).toBe(1);
|
|
106
|
+
expect(compareSemver('1.1.0-alpha', '1.1.0-beta')).toBe(-1);
|
|
107
|
+
expect(compareSemver('1.1.0-beta.2', '1.1.0-beta.10')).toBe(-1);
|
|
108
|
+
expect(compareSemver('1.1.0-beta', '1.1.0-beta.1')).toBe(-1);
|
|
109
|
+
expect(compareSemver('1.0.0+build.1', '1.0.0')).toBe(0);
|
|
110
|
+
expect(compareSemver('v1.0.0', '1.0.0')).toBeNull();
|
|
111
|
+
expect(compareSemver('1.0', '1.0.0')).toBeNull();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('parseGitInstallUrl', () => {
|
|
116
|
+
test('splits a #ref and refuses unusable refs', () => {
|
|
117
|
+
expect(parseGitInstallUrl('https://github.com/acme/panel.git')).toEqual({ url: 'https://github.com/acme/panel.git' });
|
|
118
|
+
expect(parseGitInstallUrl('https://github.com/acme/panel.git#v1.2.0')).toEqual({
|
|
119
|
+
url: 'https://github.com/acme/panel.git',
|
|
120
|
+
ref: 'v1.2.0',
|
|
121
|
+
});
|
|
122
|
+
expect(parseGitInstallUrl('https://github.com/acme/panel#release/2.x')).toEqual({
|
|
123
|
+
url: 'https://github.com/acme/panel',
|
|
124
|
+
ref: 'release/2.x',
|
|
125
|
+
});
|
|
126
|
+
expect(parseGitInstallUrl('https://github.com/acme/panel.git#')).toBeNull();
|
|
127
|
+
expect(parseGitInstallUrl('https://github.com/acme/panel.git#--upload-pack=evil')).toBeNull();
|
|
128
|
+
expect(parseGitInstallUrl('https://github.com/acme/panel.git#a..b')).toBeNull();
|
|
129
|
+
expect(parseGitInstallUrl('https://localhost/panel.git#main')).toBeNull();
|
|
130
|
+
expect(parseGitInstallUrl('http://github.com/acme/panel.git#main')).toBeNull();
|
|
131
|
+
expect(isGitRef('main')).toBe(true);
|
|
132
|
+
expect(isGitRef('-x')).toBe(false);
|
|
133
|
+
expect(isGitRef('feature/')).toBe(false);
|
|
134
|
+
expect(isGitRef('a//b')).toBe(false);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('checkGuestUpdate', () => {
|
|
139
|
+
test('reports a newer remote version and stays quiet on the same one', async () => {
|
|
140
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-upd-'));
|
|
141
|
+
const persistPath = path.join(dir, 'data', 'extensions.json');
|
|
142
|
+
const { work, bare } = await setupRemote(dir, 'upd-hello');
|
|
143
|
+
await installFrom(bare, persistPath);
|
|
144
|
+
const guest = await loadGuest('upd-hello', persistPath);
|
|
145
|
+
expect(guest.gitOrigin).toEqual({ url: bare });
|
|
146
|
+
expect((await readExtensionStore(persistPath)).gitOrigins).toEqual({ [guest.packageRoot]: { url: bare } });
|
|
147
|
+
|
|
148
|
+
const same = await checkGuestUpdate({ guest, origin: guest.gitOrigin });
|
|
149
|
+
expect(same).toEqual({ available: false, version: '1.0.0' });
|
|
150
|
+
|
|
151
|
+
await pushVersion(work, 'upd-hello', '1.1.0', { capabilities: ['prompt'], filesystem: ['~/notes/**'] });
|
|
152
|
+
const newer = await checkGuestUpdate({ guest, origin: guest.gitOrigin });
|
|
153
|
+
expect(newer).toEqual({ available: true, version: '1.1.0', requested: ['prompt', 'filesystem'] });
|
|
154
|
+
|
|
155
|
+
await pushVersion(work, 'upd-hello', '1.0.1');
|
|
156
|
+
const older = await checkGuestUpdate({ guest: { ...guest, version: '1.2.0' }, origin: guest.gitOrigin });
|
|
157
|
+
expect(older).toEqual({ available: false, version: '1.0.1' });
|
|
158
|
+
|
|
159
|
+
await pushVersion(work, 'upd-hello', '2.0.0-beta.1');
|
|
160
|
+
const pre = await checkGuestUpdate({ guest, origin: guest.gitOrigin });
|
|
161
|
+
expect(pre).toEqual({ available: true, version: '2.0.0-beta.1', requested: [] });
|
|
162
|
+
|
|
163
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('follows a pinned tag and never throws on a broken remote', async () => {
|
|
167
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-upd-'));
|
|
168
|
+
const persistPath = path.join(dir, 'data', 'extensions.json');
|
|
169
|
+
const { work, bare } = await setupRemote(dir, 'upd-tag');
|
|
170
|
+
git(work, ['tag', 'stable']);
|
|
171
|
+
git(work, ['push', '-q', 'origin', 'stable']);
|
|
172
|
+
await installFrom(bare, persistPath, 'stable');
|
|
173
|
+
const guest = await loadGuest('upd-tag', persistPath);
|
|
174
|
+
expect(guest.gitOrigin).toEqual({ url: bare, ref: 'stable' });
|
|
175
|
+
|
|
176
|
+
// main moves ahead; the tag does not.
|
|
177
|
+
await pushVersion(work, 'upd-tag', '1.5.0');
|
|
178
|
+
expect(await checkGuestUpdate({ guest, origin: guest.gitOrigin })).toEqual({ available: false, version: '1.0.0' });
|
|
179
|
+
|
|
180
|
+
git(work, ['tag', '-f', 'stable']);
|
|
181
|
+
git(work, ['push', '-q', '-f', 'origin', 'stable']);
|
|
182
|
+
expect(await checkGuestUpdate({ guest, origin: guest.gitOrigin })).toEqual({ available: true, version: '1.5.0', requested: [] });
|
|
183
|
+
|
|
184
|
+
await fs.rm(bare, { recursive: true, force: true });
|
|
185
|
+
expect(await checkGuestUpdate({ guest, origin: guest.gitOrigin })).toEqual({ available: false, error: 'fetch-failed' });
|
|
186
|
+
expect(await checkGuestUpdate({ guest, origin: undefined })).toEqual({ available: false, error: 'not-git' });
|
|
187
|
+
expect(await checkGuestUpdate({ guest, origin: { url: bare }, gitBinary: '/nonexistent/git' })).toEqual({ available: false, error: 'fetch-failed' });
|
|
188
|
+
|
|
189
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
describe('checkAllGuestUpdates', () => {
|
|
194
|
+
test('caches per guest for an hour unless forced and feeds the catalog row', async () => {
|
|
195
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-upd-'));
|
|
196
|
+
const persistPath = path.join(dir, 'data', 'extensions.json');
|
|
197
|
+
const { work, bare } = await setupRemote(dir, 'upd-cache');
|
|
198
|
+
await installFrom(bare, persistPath);
|
|
199
|
+
const start = Date.now();
|
|
200
|
+
|
|
201
|
+
expect(await checkAllGuestUpdates({ persistPath, now: start })).toEqual({});
|
|
202
|
+
await pushVersion(work, 'upd-cache', '1.1.0');
|
|
203
|
+
// Inside the hour: the stale answer stands.
|
|
204
|
+
expect(await checkAllGuestUpdates({ persistPath, now: start + UPDATE_CHECK_TTL_MS - 1 })).toEqual({});
|
|
205
|
+
expect(getCachedGuestUpdate(persistPath, 'upd-cache')).toBeNull();
|
|
206
|
+
// Forced: the network is asked again.
|
|
207
|
+
expect(await checkAllGuestUpdates({ persistPath, force: true, now: start + 1 })).toEqual({ 'upd-cache': { version: '1.1.0' } });
|
|
208
|
+
expect(getCachedGuestUpdate(persistPath, 'upd-cache')).toEqual({ version: '1.1.0' });
|
|
209
|
+
// After the hour: refreshed on its own.
|
|
210
|
+
await pushVersion(work, 'upd-cache', '1.2.0');
|
|
211
|
+
expect(await checkAllGuestUpdates({ persistPath, now: start + 1 + UPDATE_CHECK_TTL_MS })).toEqual({ 'upd-cache': { version: '1.2.0' } });
|
|
212
|
+
|
|
213
|
+
clearGuestUpdateCache(persistPath, 'upd-cache');
|
|
214
|
+
expect(getCachedGuestUpdate(persistPath, 'upd-cache')).toBeNull();
|
|
215
|
+
|
|
216
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
describe('updateGuest', () => {
|
|
221
|
+
test('swaps in the new clone and keeps grants, then reports a new version', async () => {
|
|
222
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-upd-'));
|
|
223
|
+
const persistPath = path.join(dir, 'data', 'extensions.json');
|
|
224
|
+
const { work, bare } = await setupRemote(dir, 'upd-swap');
|
|
225
|
+
await installFrom(bare, persistPath);
|
|
226
|
+
const before = await loadGuest('upd-swap', persistPath);
|
|
227
|
+
const store = await readExtensionStore(persistPath);
|
|
228
|
+
await fs.writeFile(persistPath, `${JSON.stringify({
|
|
229
|
+
paths: store.paths,
|
|
230
|
+
sources: store.sources,
|
|
231
|
+
gitOrigins: store.gitOrigins,
|
|
232
|
+
capabilityGrants: { 'upd-swap': ['prompt'] },
|
|
233
|
+
disabledGuests: { 'upd-swap': true },
|
|
234
|
+
})}\n`);
|
|
235
|
+
|
|
236
|
+
await pushVersion(work, 'upd-swap', '1.1.0', { capabilities: ['prompt', 'sessions'] });
|
|
237
|
+
await checkAllGuestUpdates({ persistPath, force: true });
|
|
238
|
+
expect(getCachedGuestUpdate(persistPath, 'upd-swap')).toEqual({ version: '1.1.0' });
|
|
239
|
+
|
|
240
|
+
const updated = await updateGuest({ guest: before, origin: before.gitOrigin, persistPath, openchamberVersion: '1.30.0' });
|
|
241
|
+
expect(updated).toEqual({ ok: true, id: 'upd-swap' });
|
|
242
|
+
|
|
243
|
+
const after = await loadGuest('upd-swap', persistPath);
|
|
244
|
+
expect(after.version).toBe('1.1.0');
|
|
245
|
+
expect(after.packageRoot).toBe(before.packageRoot);
|
|
246
|
+
expect(after.gitOrigin).toEqual({ url: bare });
|
|
247
|
+
expect(after.capabilityGrants).toEqual(['prompt']);
|
|
248
|
+
expect(after.enabled).toBe(false);
|
|
249
|
+
expect(after.capabilities).toEqual(['prompt', 'sessions']);
|
|
250
|
+
expect(getCachedGuestUpdate(persistPath, 'upd-swap')).toBeNull();
|
|
251
|
+
const leftovers = (await fs.readdir(path.dirname(before.packageRoot))).filter((name) => name.startsWith('.'));
|
|
252
|
+
expect(leftovers).toEqual([]);
|
|
253
|
+
expect((await readExtensionStore(persistPath)).paths).toEqual([before.packageRoot]);
|
|
254
|
+
|
|
255
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
test('a failure before the swap leaves the install untouched', async () => {
|
|
259
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-upd-'));
|
|
260
|
+
const persistPath = path.join(dir, 'data', 'extensions.json');
|
|
261
|
+
const { work, bare } = await setupRemote(dir, 'upd-keep');
|
|
262
|
+
await installFrom(bare, persistPath);
|
|
263
|
+
const guest = await loadGuest('upd-keep', persistPath);
|
|
264
|
+
const copiesDir = path.dirname(guest.packageRoot);
|
|
265
|
+
const noLeftovers = async () => {
|
|
266
|
+
const names = (await fs.readdir(copiesDir)).filter((name) => name.startsWith('.'));
|
|
267
|
+
expect(names).toEqual([]);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
// Remote now needs a host this build does not have.
|
|
271
|
+
await fs.writeFile(path.join(work, 'package.json'), JSON.stringify({
|
|
272
|
+
name: '@openchamber/upd-keep',
|
|
273
|
+
version: '1.1.0',
|
|
274
|
+
openchamber: {
|
|
275
|
+
apiVersion: 1,
|
|
276
|
+
engines: { openchamber: '>=9.9.9' },
|
|
277
|
+
contributes: { panel: { id: 'upd-keep', name: 'Keep', icon: 'window', entry: 'panel/index.html' } },
|
|
278
|
+
},
|
|
279
|
+
}));
|
|
280
|
+
commit(work, 'needs newer host');
|
|
281
|
+
git(work, ['push', '-q', 'origin', 'HEAD']);
|
|
282
|
+
expect(await updateGuest({ guest, origin: guest.gitOrigin, persistPath, openchamberVersion: '1.30.0' })).toEqual({
|
|
283
|
+
ok: false,
|
|
284
|
+
code: 'host-too-old',
|
|
285
|
+
required: '9.9.9',
|
|
286
|
+
});
|
|
287
|
+
await noLeftovers();
|
|
288
|
+
expect((await loadGuest('upd-keep', persistPath)).version).toBe('1.0.0');
|
|
289
|
+
|
|
290
|
+
// Remote now ships an unbuilt panel.
|
|
291
|
+
await fs.writeFile(path.join(work, 'package.json'), manifest('upd-keep', '1.2.0'));
|
|
292
|
+
await fs.writeFile(path.join(work, 'panel', 'index.html'), '<script src="./main.js"></script>');
|
|
293
|
+
commit(work, 'unbuilt');
|
|
294
|
+
git(work, ['push', '-q', 'origin', 'HEAD']);
|
|
295
|
+
expect(await updateGuest({ guest, origin: guest.gitOrigin, persistPath, openchamberVersion: '1.30.0' })).toEqual({
|
|
296
|
+
ok: false,
|
|
297
|
+
code: 'missing-build',
|
|
298
|
+
});
|
|
299
|
+
await noLeftovers();
|
|
300
|
+
|
|
301
|
+
// Remote renamed the panel: not an update of this extension.
|
|
302
|
+
await fs.writeFile(path.join(work, 'package.json'), manifest('other-id', '1.3.0'));
|
|
303
|
+
await fs.writeFile(path.join(work, 'panel', 'index.html'), '<html></html>');
|
|
304
|
+
commit(work, 'renamed');
|
|
305
|
+
git(work, ['push', '-q', 'origin', 'HEAD']);
|
|
306
|
+
expect(await updateGuest({ guest, origin: guest.gitOrigin, persistPath, openchamberVersion: '1.30.0' })).toEqual({
|
|
307
|
+
ok: false,
|
|
308
|
+
code: 'invalid-manifest',
|
|
309
|
+
});
|
|
310
|
+
await noLeftovers();
|
|
311
|
+
|
|
312
|
+
// Remote is gone.
|
|
313
|
+
await fs.rm(bare, { recursive: true, force: true });
|
|
314
|
+
expect(await updateGuest({ guest, origin: guest.gitOrigin, persistPath, openchamberVersion: '1.30.0' })).toEqual({
|
|
315
|
+
ok: false,
|
|
316
|
+
code: 'clone-failed',
|
|
317
|
+
});
|
|
318
|
+
await noLeftovers();
|
|
319
|
+
|
|
320
|
+
// Folder installs never update.
|
|
321
|
+
expect(await updateGuest({ guest: { ...guest, source: 'path' }, origin: guest.gitOrigin, persistPath })).toEqual({
|
|
322
|
+
ok: false,
|
|
323
|
+
code: 'not-git',
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
const still = await loadGuest('upd-keep', persistPath);
|
|
327
|
+
expect(still.version).toBe('1.0.0');
|
|
328
|
+
expect(still.packageRoot).toBe(guest.packageRoot);
|
|
329
|
+
expect(await fs.readFile(path.join(guest.packageRoot, 'panel', 'index.html'), 'utf8')).toBe('<html></html>');
|
|
330
|
+
expect((await listInstalledGuests({ persistPath })).map((entry) => entry.id)).toEqual(['upd-keep']);
|
|
331
|
+
|
|
332
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
333
|
+
});
|
|
334
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Body handling for `POST /api/guests/upload`: a raw zip sent as
|
|
3
|
+
* `application/octet-stream`. The archive is collected into memory (the
|
|
4
|
+
* install path works on a buffer) under a configurable cap, so a remote or
|
|
5
|
+
* web user can add an extension without a path on the server. Nothing from
|
|
6
|
+
* the archive is ever logged.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const DEFAULT_UPLOAD_MAX_BYTES = 50 * 1024 * 1024;
|
|
10
|
+
|
|
11
|
+
export const guestUploadMaxBytes = () => {
|
|
12
|
+
const raw = Number(process.env.OPENCHAMBER_GUEST_UPLOAD_MAX_BYTES);
|
|
13
|
+
if (Number.isFinite(raw) && raw > 0) return Math.floor(raw);
|
|
14
|
+
return DEFAULT_UPLOAD_MAX_BYTES;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const isOctetStream = (contentType) => (
|
|
18
|
+
String(contentType || '').toLowerCase().startsWith('application/octet-stream')
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reads the upload body. `req` is the Express request (headers plus an
|
|
23
|
+
* async-iterable body). Answers `{ ok: true, buffer }`, or `{ ok: false,
|
|
24
|
+
* status, error }` with 415 for a wrong content type and 413 when either the
|
|
25
|
+
* declared `Content-Length` or the bytes actually received pass `maxBytes`.
|
|
26
|
+
* The declared-size refusal drains the request so the socket stays reusable.
|
|
27
|
+
*/
|
|
28
|
+
export const readGuestUploadBody = async (req, maxBytes) => {
|
|
29
|
+
if (!isOctetStream(req.headers?.['content-type'])) {
|
|
30
|
+
req.resume?.();
|
|
31
|
+
return { ok: false, status: 415, error: 'unsupported-media-type' };
|
|
32
|
+
}
|
|
33
|
+
const declaredSize = Number(req.headers?.['content-length']);
|
|
34
|
+
if (Number.isFinite(declaredSize) && declaredSize > maxBytes) {
|
|
35
|
+
req.resume?.();
|
|
36
|
+
return { ok: false, status: 413, error: 'too-large' };
|
|
37
|
+
}
|
|
38
|
+
const chunks = [];
|
|
39
|
+
let received = 0;
|
|
40
|
+
for await (const chunk of req) {
|
|
41
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
42
|
+
received += buffer.length;
|
|
43
|
+
if (received > maxBytes) {
|
|
44
|
+
req.resume?.();
|
|
45
|
+
return { ok: false, status: 413, error: 'too-large' };
|
|
46
|
+
}
|
|
47
|
+
chunks.push(buffer);
|
|
48
|
+
}
|
|
49
|
+
return { ok: true, buffer: Buffer.concat(chunks, received) };
|
|
50
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { listInstalledGuests } from './catalog.js';
|
|
7
|
+
import { buildStoreZip } from './extract-zip.test.js';
|
|
8
|
+
import { installGuestFromZipBuffer } from './install.js';
|
|
9
|
+
import { guestCopiesDir } from './persist.js';
|
|
10
|
+
import { guestUploadMaxBytes, readGuestUploadBody } from './upload.js';
|
|
11
|
+
|
|
12
|
+
const fakeRequest = ({ headers = {}, chunks = [] } = {}) => {
|
|
13
|
+
let resumed = false;
|
|
14
|
+
return {
|
|
15
|
+
headers: { 'content-type': 'application/octet-stream', ...headers },
|
|
16
|
+
resume: () => {
|
|
17
|
+
resumed = true;
|
|
18
|
+
},
|
|
19
|
+
wasResumed: () => resumed,
|
|
20
|
+
async *[Symbol.asyncIterator]() {
|
|
21
|
+
for (const chunk of chunks) {
|
|
22
|
+
yield chunk;
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const guestZip = (id) => buildStoreZip([
|
|
29
|
+
{ name: 'package.json', data: JSON.stringify({
|
|
30
|
+
name: `@openchamber/${id}`,
|
|
31
|
+
version: '1.0.0',
|
|
32
|
+
openchamber: {
|
|
33
|
+
apiVersion: 1,
|
|
34
|
+
contributes: {
|
|
35
|
+
panel: { id, name: 'Uploaded', icon: 'window', entry: 'panel/index.html' },
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}) },
|
|
39
|
+
{ name: 'panel/index.html', data: '<html></html>' },
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
describe('readGuestUploadBody', () => {
|
|
43
|
+
test('collects an octet-stream body under the cap', async () => {
|
|
44
|
+
const req = fakeRequest({ chunks: [Buffer.from('ab'), Buffer.from('cd')] });
|
|
45
|
+
const body = await readGuestUploadBody(req, 10);
|
|
46
|
+
expect(body).toEqual({ ok: true, buffer: Buffer.from('abcd') });
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('refuses a wrong content type without reading the body', async () => {
|
|
50
|
+
const req = fakeRequest({ headers: { 'content-type': 'multipart/form-data' }, chunks: [Buffer.from('abcd')] });
|
|
51
|
+
const body = await readGuestUploadBody(req, 10);
|
|
52
|
+
expect(body).toEqual({ ok: false, status: 415, error: 'unsupported-media-type' });
|
|
53
|
+
expect(req.wasResumed()).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('refuses a declared size over the cap before reading', async () => {
|
|
57
|
+
const req = fakeRequest({ headers: { 'content-length': '11' }, chunks: [Buffer.from('abcd')] });
|
|
58
|
+
const body = await readGuestUploadBody(req, 10);
|
|
59
|
+
expect(body).toEqual({ ok: false, status: 413, error: 'too-large' });
|
|
60
|
+
expect(req.wasResumed()).toBe(true);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('stops a body that grows past the cap without a declared size', async () => {
|
|
64
|
+
const req = fakeRequest({ chunks: [Buffer.from('12345'), Buffer.from('678901')] });
|
|
65
|
+
const body = await readGuestUploadBody(req, 10);
|
|
66
|
+
expect(body).toEqual({ ok: false, status: 413, error: 'too-large' });
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('reads the cap from the environment', () => {
|
|
70
|
+
const previous = process.env.OPENCHAMBER_GUEST_UPLOAD_MAX_BYTES;
|
|
71
|
+
try {
|
|
72
|
+
delete process.env.OPENCHAMBER_GUEST_UPLOAD_MAX_BYTES;
|
|
73
|
+
expect(guestUploadMaxBytes()).toBe(50 * 1024 * 1024);
|
|
74
|
+
process.env.OPENCHAMBER_GUEST_UPLOAD_MAX_BYTES = '1234';
|
|
75
|
+
expect(guestUploadMaxBytes()).toBe(1234);
|
|
76
|
+
process.env.OPENCHAMBER_GUEST_UPLOAD_MAX_BYTES = 'nope';
|
|
77
|
+
expect(guestUploadMaxBytes()).toBe(50 * 1024 * 1024);
|
|
78
|
+
} finally {
|
|
79
|
+
if (previous === undefined) delete process.env.OPENCHAMBER_GUEST_UPLOAD_MAX_BYTES;
|
|
80
|
+
else process.env.OPENCHAMBER_GUEST_UPLOAD_MAX_BYTES = previous;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('installGuestFromZipBuffer', () => {
|
|
86
|
+
test('installs from bytes, lists with source zip, and reinstalls only with replace', async () => {
|
|
87
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-ext-upload-'));
|
|
88
|
+
const persistPath = path.join(dir, 'extensions.json');
|
|
89
|
+
const buffer = guestZip('upload-hello');
|
|
90
|
+
|
|
91
|
+
const installed = await installGuestFromZipBuffer(buffer, persistPath);
|
|
92
|
+
expect(installed.ok).toBe(true);
|
|
93
|
+
if (!installed.ok) {
|
|
94
|
+
throw new Error('expected upload install');
|
|
95
|
+
}
|
|
96
|
+
expect(installed.guest.id).toBe('upload-hello');
|
|
97
|
+
expect(installed.guest.source).toBe('zip');
|
|
98
|
+
expect(installed.replaced).toBe(false);
|
|
99
|
+
const copy = path.join(guestCopiesDir(persistPath), 'upload-hello');
|
|
100
|
+
expect(await fs.stat(path.join(copy, 'package.json')).then((stat) => stat.isFile())).toBe(true);
|
|
101
|
+
|
|
102
|
+
const listed = await listInstalledGuests({ persistPath });
|
|
103
|
+
expect(listed.map((guest) => [guest.id, guest.source])).toEqual([['upload-hello', 'zip']]);
|
|
104
|
+
|
|
105
|
+
const again = await installGuestFromZipBuffer(buffer, persistPath);
|
|
106
|
+
expect(again).toEqual({ ok: false, code: 'already-installed', id: 'upload-hello' });
|
|
107
|
+
|
|
108
|
+
const replaced = await installGuestFromZipBuffer(buffer, persistPath, { replace: true });
|
|
109
|
+
expect(replaced.ok).toBe(true);
|
|
110
|
+
if (!replaced.ok) {
|
|
111
|
+
throw new Error('expected replace');
|
|
112
|
+
}
|
|
113
|
+
expect(replaced.replaced).toBe(true);
|
|
114
|
+
expect((await listInstalledGuests({ persistPath })).length).toBe(1);
|
|
115
|
+
|
|
116
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('answers extract-failed for bytes that are not a zip and leaves nothing behind', async () => {
|
|
120
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-ext-upload-'));
|
|
121
|
+
const persistPath = path.join(dir, 'extensions.json');
|
|
122
|
+
|
|
123
|
+
const result = await installGuestFromZipBuffer(Buffer.from('this is a text file, not a zip'), persistPath);
|
|
124
|
+
expect(result).toEqual({ ok: false, code: 'extract-failed' });
|
|
125
|
+
expect(await listInstalledGuests({ persistPath })).toEqual([]);
|
|
126
|
+
const leftovers = await fs.readdir(guestCopiesDir(persistPath)).catch(() => []);
|
|
127
|
+
expect(leftovers).toEqual([]);
|
|
128
|
+
|
|
129
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -28,7 +28,7 @@ VS Code omits Linear (`RuntimeAPIs.linear` is optional). Hide Linear UI when the
|
|
|
28
28
|
- `POST /api/linear/auth/activate`: body `{ organizationId }`. Makes that stored workspace current. 400 if the id is missing, 404 if it is not stored.
|
|
29
29
|
- `DELETE /api/linear/auth`: revokes the current workspace refresh token when present, then drops that workspace only. Other stored workspaces stay. Mapping is kept.
|
|
30
30
|
- `GET /api/linear/issues/list?query=&cursor=&status=&assignee=&teamId=&priority=`: issues from the current workspace. Omitted `status` is incomplete states (same as the chat picker). The panel sends `all`, `backlog`, `todo` (Linear `unstarted`), `started` (In Progress, excluding the In Review name), `inReview` (state name In Review), `completed` (Done), `canceled` (excluding the Duplicate name), or `duplicate` (state type or name Duplicate). `assignee` is `any` (default) or `me`. `teamId` limits the list to that Linear team. `priority` is `all` (default), `none`, `urgent`, `high`, `medium`, or `low`. An identifier or Linear URL returns that issue even if it is completed and ignores the other filters. Each issue includes `state.id` when Linear sends it, plus `priority` (0 none through 4 low) and `labels`. Never returns tokens.
|
|
31
|
-
- `GET /api/linear/issues/get?id=`: one issue by UUID or identifier, including description, comments, team, `state.id`, priority, and labels.
|
|
31
|
+
- `GET /api/linear/issues/get?id=`: one issue by UUID or identifier, including description, comments, team, `state.id`, priority, and labels. The host Linear guest panel uses this route for the issue card so comment images keep public file URLs. Guest request does not add Linear headers.
|
|
32
32
|
- `GET /api/linear/issues/states?teamId=`: workflow states for that Linear team (`id`, `name`, `type`, `position`), ordered like Linear's workflow: type (backlog, unstarted, started, completed, canceled) then position. Missing `teamId` is 400. Linear not-found or validation errors are 400 with Linear's presentable message. Disconnected is `{ connected: false }` with HTTP 200.
|
|
33
33
|
- `POST /api/linear/issues/update`: body `{ id, stateId }`. `id` may be a UUID, identifier, or Linear URL; identifiers are resolved before `issueUpdate` because Linear's mutation requires a UUID. Returns the updated issue. Closing an issue is this same call with the team's first `type: completed` state. Missing `id` or `stateId` is 400. Linear validation (for example a non-UUID `stateId`) is 400 with Linear's presentable message. A GraphQL 401 clears that workspace only. Disconnected is `{ connected: false }` with HTTP 200.
|
|
34
34
|
- `GET /api/linear/mapping`: stored default project plus live Linear teams with their mapped paths. Missing file is empty mapping. Malformed file is 500, not empty success. Disconnected is `{ connected: false }` with HTTP 200.
|
|
@@ -44,6 +44,12 @@ other.
|
|
|
44
44
|
- Send and fork dispatches without an explicit model/agent/variant reuse the
|
|
45
45
|
target session's last user-message selection before falling back to the
|
|
46
46
|
configured defaults; only session creation resolves defaults directly.
|
|
47
|
+
- Default agents resolve from the owning project before global settings and
|
|
48
|
+
OpenCode defaults. Directory-based requests identify the project before
|
|
49
|
+
creating a worktree; existing linked worktrees resolve through Git's primary
|
|
50
|
+
worktree root. Send/fork fallback uses that same owner. Configured model IDs
|
|
51
|
+
and effort preferences survive missing catalog entries rather than silently
|
|
52
|
+
dispatching with a different model.
|
|
47
53
|
- Usage errors name the missing or conflicting input so CLI and agent-tool
|
|
48
54
|
callers can correct an invalid request without an upfront usage manual.
|
|
49
55
|
- Explicit `projectId` or `directory` scope takes precedence over the managed
|