@openchamber/web 1.20.0 → 1.21.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-C36E738Y.js → CodeMirrorCommentWidgets-C2BopIs3.js} +1 -1
- package/dist/assets/CommitSection-HJeMUAWb.js +1 -0
- package/dist/assets/DiffView-D5cvbEPb.js +4 -0
- package/dist/assets/FilesView-DPU8aNPL.js +17 -0
- package/dist/assets/GitView-Ct6xWrVH.js +6 -0
- package/dist/assets/{JsonTreeView-KnXFN2A-.js → JsonTreeView-osju7J70.js} +1 -1
- package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +12 -0
- package/dist/assets/OnboardingScreen-w2VG4fWY.js +1 -0
- package/dist/assets/{PatchDiff-BzVOVog8.js → PatchDiff-Dan3mADn.js} +1 -1
- package/dist/assets/PierreDiffViewer-CGoI2v0q.js +157 -0
- package/dist/assets/PlanView-Dgg-WTEc.js +4 -0
- package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +1 -0
- package/dist/assets/SettingsView-D9yRuFZw.js +28 -0
- package/dist/assets/SettingsWindow-DXF-MTHG.js +1 -0
- package/dist/assets/{ToolOutputDialog-BB1c--Zr.js → ToolOutputDialog-DrCa1JRk.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-DaOIDISD.js → ToolPartDiffPreview-B_tfvlNF.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-lESMT-2b.js → VirtualizedFileDiff-CN_BctrR.js} +4 -4
- package/dist/assets/{Virtualizer-X_7XPoTH.js → Virtualizer-CZlLSacm.js} +1 -1
- package/dist/assets/Virtualizer-D_a8gKmg.js +1 -0
- package/dist/assets/{WalkthroughView-CaSYE0lw.js → WalkthroughView-D9Q4lr5x.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-DkRR5b75.js → computeVirtualFileMetrics-Gi1d5eU1.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-CpzVNWAv.js +1 -0
- package/dist/assets/de-B_LdJwEM.js +9 -0
- package/dist/assets/es-CubfsAYV.js +15 -0
- package/dist/assets/fr-5qJM0nFS.js +13 -0
- package/dist/assets/index-BW82eK5v.css +1 -0
- package/dist/assets/index-Brm3X9rs.js +1 -0
- package/dist/assets/index-rlLjZUM5.js +7 -0
- package/dist/assets/{isDiffPlainText-BG53Ixxy.js → isDiffPlainText-pH9kAJQH.js} +1 -1
- package/dist/assets/{isFilePlainText-BbV-39jl.js → isFilePlainText-CVKy_dgB.js} +1 -1
- package/dist/assets/ja-DJYIBUlH.js +15 -0
- package/dist/assets/ko-DcUBkB7y.js +15 -0
- package/dist/assets/main-DLBxKIoX.js +926 -0
- package/dist/assets/main-vUCh0VB0.js +2 -0
- package/dist/assets/markdownCore-DG6GHLF4.js +3 -0
- package/dist/assets/{miniChat-ldEghBLB.js → miniChat-BlzGEYgE.js} +2 -2
- package/dist/assets/mobile-CkX6H-IT.js +2 -0
- package/dist/assets/{patchFileDiff-BcFaMtMu.js → patchFileDiff-BCTsE43U.js} +3 -3
- package/dist/assets/pl-rB6BLcio.js +15 -0
- package/dist/assets/pt-BR-DcwtlO-o.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-CJYe_KOL.js +2 -0
- package/dist/assets/renderMobileApp-hQJTnr8B.js +25 -0
- package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +15 -0
- package/dist/assets/scheduledTasksApi-CAGPh_gZ.js +1 -0
- package/dist/assets/{shikiHighlight-DCT2Sq_z.js → shikiHighlight-BgTPSITe.js} +1 -1
- package/dist/assets/uk-INZlFD9A.js +15 -0
- package/dist/assets/{useAppFontEffects-B53Rb6m7.js → useAppFontEffects-Cll4gnsh.js} +170 -180
- package/dist/assets/useInlineCommentController-DFFv0hae.js +2 -0
- package/dist/assets/{vendor-base-ui-DsHmyMwp.js → vendor-base-ui-_6j2xOWl.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-vch3tJ4c.js → vendor-codemirror-language-data-DkQX2EBa.js} +2 -2
- package/dist/assets/{vendor-framer-motion-CRSgBxjL.js → vendor-framer-motion-livSKyyV.js} +1 -1
- package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +1 -0
- package/dist/assets/{vendor-motion-dom-DJLgZh4Q.js → vendor-motion-dom-D_o3BTI3.js} +1 -1
- package/dist/assets/vendor-zod-BLfBSgBh.js +39 -0
- package/dist/assets/{web-components-pcwCTWjC.js → web-components-DLnGY4fs.js} +4 -4
- package/dist/assets/zh-CN-Dzda8xa1.js +15 -0
- package/dist/assets/zh-TW-Cwn3rNYZ.js +15 -0
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +4 -4
- package/server/index.js +8 -0
- package/server/lib/client-auth/pairing.js +8 -7
- package/server/lib/client-auth/pairing.test.js +5 -1
- package/server/lib/client-auth/remote-clients.js +9 -1
- package/server/lib/client-auth/remote-clients.test.js +17 -0
- package/server/lib/github/pr-status.js +10 -1
- package/server/lib/quota/providers/index.js +4 -18
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/service.js +34 -2
- package/server/lib/relay/service.test.js +69 -0
- package/server/lib/session-goal/runtime.js +2 -1
- package/server/lib/session-goal/runtime.test.js +4 -2
- package/server/lib/terminal/DOCUMENTATION.md +2 -0
- package/server/lib/terminal/runtime.js +29 -1
- package/server/lib/terminal/runtime.test.js +26 -0
- package/server/lib/ui-auth/ui-auth.js +2 -2
- package/server/lib/ui-auth/ui-auth.test.js +2 -2
- package/dist/assets/CommitSection-C-F3AX6D.js +0 -1
- package/dist/assets/DiagramEditor-BPECg1jS.js +0 -1
- package/dist/assets/DiagramView-D0YNMix8.js +0 -1
- package/dist/assets/DiffView-BHWaMYCC.js +0 -4
- package/dist/assets/FilesView-NMBCW2Tm.js +0 -14
- package/dist/assets/GitView-Rp8P1KEI.js +0 -6
- package/dist/assets/MarkdownImageGallery-BMn3mtor.js +0 -1
- package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +0 -12
- package/dist/assets/OnboardingScreen-CenIeD4v.js +0 -1
- package/dist/assets/PierreDiffViewer-Dlby4XqT.js +0 -136
- package/dist/assets/PlanView-Czu1KMJa.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +0 -1
- package/dist/assets/SettingsView-B6vmuf-c.js +0 -28
- package/dist/assets/SettingsWindow-CauZpdD3.js +0 -1
- package/dist/assets/contextPanelEmbeddedChat-BEARQjgn.js +0 -1
- package/dist/assets/de-DFdX3ABv.js +0 -9
- package/dist/assets/es-iC-FKvV9.js +0 -15
- package/dist/assets/fr-BBbi_1AL.js +0 -13
- package/dist/assets/index-BiEgzzkg.js +0 -1
- package/dist/assets/index-Cwmuwk3V.js +0 -7
- package/dist/assets/index-GNm1wgUH.css +0 -1
- package/dist/assets/ja-DQLQJL2J.js +0 -15
- package/dist/assets/ko-BeElEB4Y.js +0 -15
- package/dist/assets/main-Dpzo18z7.js +0 -2
- package/dist/assets/main-WMjtYzJs.js +0 -921
- package/dist/assets/markdownCore--tDmyI_v.js +0 -2
- package/dist/assets/mobile-Dk-VGreF.js +0 -2
- package/dist/assets/pl-CLHt2_vV.js +0 -15
- package/dist/assets/pt-BR-C_MPUq7e.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +0 -2
- package/dist/assets/renderMobileApp-CDfHS5rr.js +0 -25
- package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +0 -15
- package/dist/assets/scheduledTasksApi-BFSlqgnG.js +0 -1
- package/dist/assets/uk-PhsC-c4-.js +0 -15
- package/dist/assets/useInlineCommentController-DSfrIBKT.js +0 -2
- package/dist/assets/vendor-zod-C9ioTTSo.js +0 -39
- package/dist/assets/zh-CN-wF-NOFHM.js +0 -15
- package/dist/assets/zh-TW-4m4-A7rT.js +0 -15
- package/server/lib/quota/providers/command-code.js +0 -90
- package/server/lib/quota/providers/command-code.test.js +0 -85
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { readAuthFile } from '../../opencode/auth.js';
|
|
2
|
-
import { asObject, buildResult, getAuthEntry, normalizeAuthEntry, toNumber, toUsageWindow } from '../utils/index.js';
|
|
3
|
-
|
|
4
|
-
export const providerId = 'command-code';
|
|
5
|
-
export const providerName = 'Command Code';
|
|
6
|
-
export const aliases = ['command-code', 'commandcode', 'command_code', 'command code'];
|
|
7
|
-
|
|
8
|
-
const API_BASE_URL = 'https://api.commandcode.ai';
|
|
9
|
-
|
|
10
|
-
const getApiKey = (auth = readAuthFile()) => {
|
|
11
|
-
const entry = normalizeAuthEntry(getAuthEntry(auth, aliases));
|
|
12
|
-
const stored = entry?.key ?? entry?.access ?? entry?.token;
|
|
13
|
-
return (typeof stored === 'string' ? stored.trim() : '') || process.env.COMMAND_CODE_API_KEY?.trim() || null;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const requestJson = async (path, apiKey, fetchImpl) => {
|
|
17
|
-
const response = await fetchImpl(`${API_BASE_URL}${path}`, {
|
|
18
|
-
headers: {
|
|
19
|
-
Accept: 'application/json',
|
|
20
|
-
Authorization: `Bearer ${apiKey}`,
|
|
21
|
-
'User-Agent': 'OpenChamber quota provider',
|
|
22
|
-
},
|
|
23
|
-
signal: AbortSignal.timeout(15_000),
|
|
24
|
-
});
|
|
25
|
-
if (response.status === 401 || response.status === 403) throw new Error('Command Code authentication failed');
|
|
26
|
-
if (!response.ok) throw new Error(`Command Code usage API returned HTTP ${response.status}`);
|
|
27
|
-
return response.json().catch(() => null);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const formatCredits = (value) => String(Math.round((value + Number.EPSILON) * 100) / 100);
|
|
31
|
-
|
|
32
|
-
const toBalanceWindow = (value) => toUsageWindow({
|
|
33
|
-
usedPercent: null,
|
|
34
|
-
windowSeconds: null,
|
|
35
|
-
resetAt: null,
|
|
36
|
-
valueLabel: formatCredits(value),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export const parseCommandCodeCredits = (payload) => {
|
|
40
|
-
const root = asObject(payload);
|
|
41
|
-
const credits = asObject(root?.credits);
|
|
42
|
-
const limits = asObject(root?.windowLimits);
|
|
43
|
-
const windows = {};
|
|
44
|
-
|
|
45
|
-
for (const [label, field] of [['monthly_credits', 'monthlyCredits'], ['purchased_credits', 'purchasedCredits'], ['free_credits', 'freeCredits']]) {
|
|
46
|
-
const value = toNumber(credits?.[field]);
|
|
47
|
-
if (value !== null) windows[label] = toBalanceWindow(value);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
for (const [label, field, windowSeconds] of [['5h', 'fiveHour', 5 * 60 * 60], ['weekly', 'weekly', 7 * 24 * 60 * 60]]) {
|
|
51
|
-
const limit = asObject(limits?.[field]);
|
|
52
|
-
const used = toNumber(limit?.used);
|
|
53
|
-
const cap = toNumber(limit?.cap);
|
|
54
|
-
if (used === null || cap === null || cap <= 0) continue;
|
|
55
|
-
const resetAt = toNumber(limit?.resetAt);
|
|
56
|
-
windows[label] = toUsageWindow({
|
|
57
|
-
usedPercent: Math.min(100, Math.max(0, used / cap * 100)),
|
|
58
|
-
windowSeconds,
|
|
59
|
-
resetAt: resetAt === null ? null : resetAt < 1_000_000_000_000 ? resetAt * 1000 : resetAt,
|
|
60
|
-
valueLabel: `${formatCredits(used)} / ${formatCredits(cap)}`,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return windows;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const fetchCommandCodeUsage = async (apiKey, fetchImpl = fetch) => {
|
|
68
|
-
const identity = asObject(await requestJson('/alpha/whoami', apiKey, fetchImpl));
|
|
69
|
-
const org = asObject(identity?.org);
|
|
70
|
-
const orgId = typeof org?.id === 'string' ? org.id.trim() : '';
|
|
71
|
-
const creditsPath = orgId
|
|
72
|
-
? `/alpha/billing/credits?orgId=${encodeURIComponent(orgId)}`
|
|
73
|
-
: '/alpha/billing/credits';
|
|
74
|
-
const credits = await requestJson(creditsPath, apiKey, fetchImpl);
|
|
75
|
-
const windows = parseCommandCodeCredits(credits);
|
|
76
|
-
if (Object.keys(windows).length === 0) throw new Error('Command Code usage data could not be parsed');
|
|
77
|
-
return windows;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export const isConfigured = () => Boolean(getApiKey());
|
|
81
|
-
|
|
82
|
-
export const fetchQuota = async (auth = readAuthFile()) => {
|
|
83
|
-
const apiKey = getApiKey(auth);
|
|
84
|
-
if (!apiKey) return buildResult({ providerId, providerName, ok: false, configured: false, error: 'Not configured' });
|
|
85
|
-
try {
|
|
86
|
-
return buildResult({ providerId, providerName, ok: true, configured: true, usage: { windows: await fetchCommandCodeUsage(apiKey) } });
|
|
87
|
-
} catch (error) {
|
|
88
|
-
return buildResult({ providerId, providerName, ok: false, configured: true, error: error instanceof Error ? error.message : 'Request failed' });
|
|
89
|
-
}
|
|
90
|
-
};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { fetchCommandCodeUsage, fetchQuota, parseCommandCodeCredits } from './command-code.js';
|
|
4
|
-
|
|
5
|
-
const creditsPayload = {
|
|
6
|
-
credits: { monthlyCredits: 120, purchasedCredits: 30, freeCredits: 5 },
|
|
7
|
-
windowLimits: {
|
|
8
|
-
fiveHour: { used: 25, cap: 100, resetAt: 1_776_000_000 },
|
|
9
|
-
weekly: { used: 70, cap: 200, resetAt: 1_776_604_800 },
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
describe('Command Code quota provider', () => {
|
|
14
|
-
it('parses balances and rate-limit windows', () => {
|
|
15
|
-
const windows = parseCommandCodeCredits(creditsPayload);
|
|
16
|
-
expect(windows.monthly_credits).toMatchObject({ usedPercent: null, valueLabel: '120' });
|
|
17
|
-
expect(windows.purchased_credits).toMatchObject({ usedPercent: null, valueLabel: '30' });
|
|
18
|
-
expect(windows.free_credits).toMatchObject({ usedPercent: null, valueLabel: '5' });
|
|
19
|
-
expect(windows['5h']).toMatchObject({ usedPercent: 25, valueLabel: '25 / 100', resetAt: 1_776_000_000_000 });
|
|
20
|
-
expect(windows.weekly.usedPercent).toBe(35);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('formats fractional credit values for display', () => {
|
|
24
|
-
const windows = parseCommandCodeCredits({
|
|
25
|
-
credits: { monthlyCredits: 69.7947070034 },
|
|
26
|
-
windowLimits: { fiveHour: { used: 0.2052929966, cap: 14 } },
|
|
27
|
-
});
|
|
28
|
-
expect(windows.monthly_credits.valueLabel).toBe('69.79');
|
|
29
|
-
expect(windows['5h'].valueLabel).toBe('0.21 / 14');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('resolves the organization before fetching credits', async () => {
|
|
33
|
-
const requests = [];
|
|
34
|
-
const windows = await fetchCommandCodeUsage('secret', async (url, options) => {
|
|
35
|
-
requests.push({ url, options });
|
|
36
|
-
return new Response(JSON.stringify(url.endsWith('/alpha/whoami') ? { org: { id: 'org/a' } } : creditsPayload));
|
|
37
|
-
});
|
|
38
|
-
expect(requests.map(({ url }) => url)).toEqual([
|
|
39
|
-
'https://api.commandcode.ai/alpha/whoami',
|
|
40
|
-
'https://api.commandcode.ai/alpha/billing/credits?orgId=org%2Fa',
|
|
41
|
-
]);
|
|
42
|
-
expect(requests[0].options.headers.Authorization).toBe('Bearer secret');
|
|
43
|
-
expect(windows['5h'].usedPercent).toBe(25);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('fetches account-scoped credits without orgId for personal accounts', async () => {
|
|
47
|
-
const urls = [];
|
|
48
|
-
await fetchCommandCodeUsage('secret', async (url) => {
|
|
49
|
-
urls.push(url);
|
|
50
|
-
return new Response(JSON.stringify(url.endsWith('/alpha/whoami') ? { user: { id: 'user-1' }, org: null } : creditsPayload));
|
|
51
|
-
});
|
|
52
|
-
expect(urls).toEqual([
|
|
53
|
-
'https://api.commandcode.ai/alpha/whoami',
|
|
54
|
-
'https://api.commandcode.ai/alpha/billing/credits',
|
|
55
|
-
]);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('does not expose credentials in authentication errors', async () => {
|
|
59
|
-
await expect(fetchCommandCodeUsage('secret', async () => new Response('', { status: 401 }))).rejects.toThrow('authentication failed');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('reads OAuth access credentials from the OpenCode auth file', async () => {
|
|
63
|
-
const fetchMock = vi.fn()
|
|
64
|
-
.mockResolvedValueOnce(new Response(JSON.stringify({ org: { id: 'org-1' } })))
|
|
65
|
-
.mockResolvedValueOnce(new Response(JSON.stringify(creditsPayload)));
|
|
66
|
-
vi.stubGlobal('fetch', fetchMock);
|
|
67
|
-
const result = await fetchQuota({ 'command-code': { type: 'oauth', access: 'test-token' } });
|
|
68
|
-
expect(result).toMatchObject({ providerId: 'command-code', ok: true, configured: true });
|
|
69
|
-
expect(fetchMock.mock.calls[0][1].headers.Authorization).toBe('Bearer test-token');
|
|
70
|
-
vi.unstubAllGlobals();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('recognizes Command Code auth entries under supported provider ID variants', async () => {
|
|
74
|
-
for (const providerId of ['commandcode', 'command_code', 'command code']) {
|
|
75
|
-
const fetchMock = vi.fn()
|
|
76
|
-
.mockResolvedValueOnce(new Response(JSON.stringify({ org: { id: 'org-1' } })))
|
|
77
|
-
.mockResolvedValueOnce(new Response(JSON.stringify(creditsPayload)));
|
|
78
|
-
vi.stubGlobal('fetch', fetchMock);
|
|
79
|
-
|
|
80
|
-
const result = await fetchQuota({ [providerId]: { type: 'oauth', access: 'test-token' } });
|
|
81
|
-
expect(result).toMatchObject({ providerId: 'command-code', ok: true, configured: true });
|
|
82
|
-
vi.unstubAllGlobals();
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|