@openchambery/web 1.19.0-beta.1 → 1.19.0-beta.11
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/{AssistantView-fgbPUmLq.js → AssistantView-BeBw472q.js} +1 -1
- package/dist/assets/{ChatContainer-BrvW2pRr.js → ChatContainer-TY9tpKf9.js} +27 -27
- package/dist/assets/{ContextPanel-Cq6HKUN0.js → ContextPanel-ep3Fquk1.js} +3 -3
- package/dist/assets/{DiagramView-x7-TIiNx.js → DiagramView-Bjt6rxvb.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-n2XtPnMO.js → MarkdownRendererImpl-DMGUdAy4.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-COj9KWnI.js → MobileDetailNavigation-pEE5zGyy.js} +1 -1
- package/dist/assets/{MobileShareBridge-BnZWX1ie.js → MobileShareBridge-GTxpH17f.js} +1 -1
- package/dist/assets/MobileSurface-CHWAIHNh.js +2 -0
- package/dist/assets/{MultiRunWindow-irLhgR05.js → MultiRunWindow-bT4TOLN_.js} +1 -1
- package/dist/assets/{OnboardingScreen-BKmuT7AL.js → OnboardingScreen-BF8BuaBh.js} +1 -1
- package/dist/assets/{SettingsView-DHz0g2EA.js → SettingsView-Bl2D8WfD.js} +10 -10
- package/dist/assets/{SettingsWindow-PFd2-jT1.js → SettingsWindow-eFl9nJkB.js} +1 -1
- package/dist/assets/{TerminalView-BdB9nY10.js → TerminalView-Dv9BvZYh.js} +1 -1
- package/dist/assets/{ToolOutputDialog-YY1neh1P.js → ToolOutputDialog-ng-s_Cva.js} +1 -1
- package/dist/assets/appThemeRegistry-BBuG9Kcb.js +2 -0
- package/dist/assets/{clipboard-DWuULPzo.js → clipboard-O3XtpG2j.js} +1 -1
- package/dist/assets/{dialog-DPS0W9eS.js → dialog-BBR8o-ss.js} +1 -1
- package/dist/assets/{es-BX0Vm3Ac.js → es-Dhnp9uFc.js} +1 -1
- package/dist/assets/{fr-CuPzXTYx.js → fr-BSDdgLmw.js} +1 -1
- package/dist/assets/{gitApi-DhXlBW5_.js → gitApi-U6GG9LGB.js} +1 -1
- package/dist/assets/{insertionBoundaries-CaPEgRhz.js → insertionBoundaries-BWUegiqY.js} +1 -1
- package/dist/assets/{ja-DGtzjrFO.js → ja-DSiOtWVF.js} +1 -1
- package/dist/assets/{ko-DZ9Di0je.js → ko-BHzG9D00.js} +1 -1
- package/dist/assets/{main-CAFEHmFO.js → main-CCSoX-f8.js} +2 -2
- package/dist/assets/main-D8bAiz4N.js +29 -0
- package/dist/assets/{miniChat-CaoA6FTj.js → miniChat-ByP4lmB2.js} +2 -2
- package/dist/assets/{mobile-BmT1oGJE.js → mobile-itPS85I5.js} +2 -2
- package/dist/assets/{multirun-DCb9fu9k.js → multirun-Nnd8tBP2.js} +1 -1
- package/dist/assets/{pl-BuCO3qb1.js → pl-3z6483I9.js} +1 -1
- package/dist/assets/{projectMeta-Bz0ubQem.js → projectMeta-C_qnltm2.js} +1 -1
- package/dist/assets/{pt-BR-Brf4RMsw.js → pt-BR-DPAxb5uf.js} +1 -1
- package/dist/assets/{radio-BTBrz5my.js → radio-bWyp7L6m.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DYLSB3rK.js → renderElectronMiniChatApp-ZL-YcVlr.js} +2 -2
- package/dist/assets/{renderMobileApp-B8lK4pah.js → renderMobileApp-DDkW1KFx.js} +5 -5
- package/dist/assets/{runtimeConfig-Ir8clpcX.js → runtimeConfig-BusKIsc-.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-Bf0Z1IVx.js → runtimeEndpointReset-B1oBONYR.js} +1 -1
- package/dist/assets/{shikiHighlight-7F8n-5Rx.js → shikiHighlight-Do5wDaEE.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-nLsPC06f.js → sortable-tabs-strip-D9PYWV2n.js} +1 -1
- package/dist/assets/{src-BDOLh3pc.css → src-RGaBtbGz.css} +1 -1
- package/dist/assets/{store-DQY8Fkb0.js → store-CXHGSKbF.js} +2 -2
- package/dist/assets/{uk-C-wmaPTi.js → uk-CI6xwBAp.js} +1 -1
- package/dist/assets/{useAppFontEffects-D5D78tij.js → useAppFontEffects-BRTJumeq.js} +3 -3
- package/dist/assets/{useDesktopWindowControlsLayout-sxtQ4Ong.js → useDesktopWindowControlsLayout-B2FNcpm1.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-BS3smPk4.js → useEffectiveDirectory-BPldUO4X.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-CcRPuv-k.js → useMobileNavigationStore-BhJUnrg7.js} +4 -4
- package/dist/assets/useSessionAutoCleanup-BA9LlYGp.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-BSfxD_92.js → useWorkerHighlightedLines-0EaZpSvX.js} +1 -1
- package/dist/assets/{zh-CN-DueRrIql.js → zh-CN-DHgsAmCO.js} +1 -1
- package/dist/assets/{zh-TW-6875X80V.js → zh-TW-CZ_DZMCi.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/config-sync/DOCUMENTATION.md +6 -7
- package/server/lib/config-sync/engine.js +0 -8
- package/server/lib/config-sync/index.js +0 -7
- package/server/lib/config-sync/receiver.js +0 -35
- package/server/lib/config-sync/routes.js +8 -41
- package/server/lib/config-sync/routes.test.js +1 -38
- package/server/lib/opencode/openchamber-routes.js +1 -7
- package/dist/assets/MobileSurface-CRAv1y7h.js +0 -2
- package/dist/assets/appThemeRegistry-D_EwFuiP.js +0 -2
- package/dist/assets/main-DN1sgFqr.js +0 -29
- package/dist/assets/useSessionAutoCleanup-BbzRTsYQ.js +0 -1
- package/server/lib/config-sync/credential-auth.js +0 -39
package/dist/index.html
CHANGED
|
@@ -552,7 +552,7 @@
|
|
|
552
552
|
opacity: 0.72;
|
|
553
553
|
}
|
|
554
554
|
</style>
|
|
555
|
-
<script type="module" crossorigin src="/assets/main-
|
|
555
|
+
<script type="module" crossorigin src="/assets/main-CCSoX-f8.js"></script>
|
|
556
556
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
|
|
557
557
|
<link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
|
|
558
558
|
<link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
|
|
@@ -569,8 +569,8 @@
|
|
|
569
569
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-BpPeXWIu.js">
|
|
570
570
|
<link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
|
|
571
571
|
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
|
|
572
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
573
|
-
<link rel="stylesheet" crossorigin href="/assets/src-
|
|
572
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BusKIsc-.js">
|
|
573
|
+
<link rel="stylesheet" crossorigin href="/assets/src-RGaBtbGz.css">
|
|
574
574
|
</head>
|
|
575
575
|
<body class="h-full bg-background text-foreground">
|
|
576
576
|
<!-- Keep the startup layer outside #root. React replaces every child of
|
package/dist/mini-chat.html
CHANGED
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
}
|
|
75
75
|
</style>
|
|
76
76
|
|
|
77
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
77
|
+
<script type="module" crossorigin src="/assets/miniChat-ByP4lmB2.js"></script>
|
|
78
78
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
|
|
79
79
|
<link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
|
|
80
80
|
<link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-BpPeXWIu.js">
|
|
92
92
|
<link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
|
|
93
93
|
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
|
|
94
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
95
|
-
<link rel="stylesheet" crossorigin href="/assets/src-
|
|
94
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BusKIsc-.js">
|
|
95
|
+
<link rel="stylesheet" crossorigin href="/assets/src-RGaBtbGz.css">
|
|
96
96
|
</head>
|
|
97
97
|
<body class="h-full bg-background text-foreground">
|
|
98
98
|
<div id="root" class="h-full">
|
package/dist/mobile.html
CHANGED
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
})();
|
|
64
64
|
</script>
|
|
65
65
|
|
|
66
|
-
<script type="module" crossorigin src="/assets/mobile-
|
|
66
|
+
<script type="module" crossorigin src="/assets/mobile-itPS85I5.js"></script>
|
|
67
67
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
|
|
68
68
|
<link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
|
|
69
69
|
<link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-BpPeXWIu.js">
|
|
81
81
|
<link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
|
|
82
82
|
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
|
|
83
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
84
|
-
<link rel="stylesheet" crossorigin href="/assets/src-
|
|
83
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-BusKIsc-.js">
|
|
84
|
+
<link rel="stylesheet" crossorigin href="/assets/src-RGaBtbGz.css">
|
|
85
85
|
</head>
|
|
86
86
|
<body class="h-full bg-background text-foreground">
|
|
87
87
|
<div id="root" class="h-full"></div>
|
package/package.json
CHANGED
|
@@ -17,7 +17,6 @@ Own the direction-agnostic OpenCode config sync contract: allowlist planning on
|
|
|
17
17
|
| `local-backup.js` | Local (pull destination) generational backup + tar extract |
|
|
18
18
|
| `tar.js` | `collectLocalTarBuffer` (buffered) |
|
|
19
19
|
| `engine.js` | `applyConfigSyncPlan` orchestration for **push** (prepare → putTar* → finalize) |
|
|
20
|
-
| `credential-auth.js` | Credential grant enforcement helpers |
|
|
21
20
|
| `target-id.js` | `ssh:<instanceId>` namespace helper |
|
|
22
21
|
|
|
23
22
|
## Contract shape
|
|
@@ -28,6 +27,7 @@ Own the direction-agnostic OpenCode config sync contract: allowlist planning on
|
|
|
28
27
|
- **Plan** (source-computed): `{ direction: 'push' | 'pull', syncRunId?, sourceTargetId?, targetId?, files, directories, agentsRoot, authFile, deletes, totalBytes, selections? }`
|
|
29
28
|
- **Selections**: `{ fileGroups: boolean[], singleFiles: boolean[], directories: boolean[], agentsRoot: boolean, authFile: boolean }`
|
|
30
29
|
- Preview and apply must share one selections snapshot so the confirmed scope cannot drift.
|
|
30
|
+
- `authFile` defaults unchecked like an opt-in ordinary selection; once checked it syncs the same way as other allowlisted files (no extra grant).
|
|
31
31
|
|
|
32
32
|
## Direction flow
|
|
33
33
|
|
|
@@ -45,7 +45,7 @@ Switching direction in the wizard **must** discard the previous preview and re-c
|
|
|
45
45
|
- Prepare (remote or local) writes generational backups under `<backupRoot>/<syncRunId>/` and prunes older than `OPENCODE_CONFIG_SYNC_BACKUP_GENERATIONS`. Failed runs keep their scene until pruned.
|
|
46
46
|
- Finalize confirms the run's backup directory exists.
|
|
47
47
|
- Run records (Electron `sync-run-store`) persist `direction` alongside `syncRunId` / summary; they are not stored in `settings.json`.
|
|
48
|
-
-
|
|
48
|
+
- **`auth.json` sync:** treated like any other selected allowlist item. Default selection leaves it unchecked; when selected, push/pull transfer it under the dedicated auth backup directory with no separate credential grant.
|
|
49
49
|
|
|
50
50
|
## HTTP receive protocol (direct / later relay)
|
|
51
51
|
|
|
@@ -53,18 +53,17 @@ Routes under `/api/openchamber/config-sync/*` (global `/api` auth gate: session
|
|
|
53
53
|
|
|
54
54
|
| Method | Path | Role |
|
|
55
55
|
|--------|------|------|
|
|
56
|
-
| POST | `/probe` | Inventory + existence vs plan
|
|
56
|
+
| POST | `/probe` | Inventory + existence vs plan |
|
|
57
57
|
| POST | `/prepare` | Generational local backup + deletes; one inflight `syncRunId` |
|
|
58
58
|
| PUT | `/put/:kind?syncRunId=` | Stream tar.gz (`config` \| `agents` \| `auth`) |
|
|
59
59
|
| GET | `/download/:kind` | Stream tar.gz for pull source |
|
|
60
60
|
| POST | `/finalize` | Confirm backup generation + success receipt |
|
|
61
61
|
| POST | `/abort` | Clear inflight |
|
|
62
|
-
| GET/PUT | `/credential-auth` | Host inbound credential grant (`configSyncInboundCredentialAuthorized`) |
|
|
63
62
|
|
|
64
|
-
`auth` put/download
|
|
63
|
+
`auth` put/download follows the same selection/plan rules as other kinds. Concurrent prepare → `sync_in_progress`.
|
|
65
64
|
|
|
66
65
|
## Composition
|
|
67
66
|
|
|
68
67
|
- Electron SSH: `TargetExecutor` push + inventory/tar pull.
|
|
69
|
-
- Electron direct hosts: `direct-config-sync.mjs` calls these HTTP routes
|
|
70
|
-
- **Relay hosts (ticket 06):** UI opens an E2EE tunnel (`packages/ui/src/lib/relay/relay-config-sync.ts`) and calls the same HTTP routes via `tunnel.fetch`. Target id is `relay:<serverId>` (signing-key fingerprint). Preview/apply refresh candidates and refuse on `serverId` mismatch (`relay_identity_changed`) with no fallback identity.
|
|
68
|
+
- Electron direct hosts: `direct-config-sync.mjs` calls these HTTP routes.
|
|
69
|
+
- **Relay hosts (ticket 06):** UI opens an E2EE tunnel (`packages/ui/src/lib/relay/relay-config-sync.ts`) and calls the same HTTP routes via `tunnel.fetch`. Target id is `relay:<serverId>` (signing-key fingerprint). Preview/apply refresh candidates and refuse on `serverId` mismatch (`relay_identity_changed`) with no fallback identity. Auth remains the global `/api` bearer gate; selected `auth.json` transfers without a separate credential grant.
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
|
|
3
3
|
import { assertPlanDirection } from './contract.js';
|
|
4
|
-
import { assertCredentialSyncAuthorized } from './credential-auth.js';
|
|
5
4
|
import { collectLocalTarBuffer } from './tar.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Run a source-side plan against a TargetExecutor (probe → prepare → putTar* → finalize).
|
|
9
8
|
* Direction-agnostic orchestration; ticket 02 only drives push from a local home snapshot.
|
|
10
|
-
* Credential-bearing plans require an explicit per-target grant (ticket 03).
|
|
11
9
|
*
|
|
12
10
|
* @param {{
|
|
13
11
|
* plan: object,
|
|
@@ -15,7 +13,6 @@ import { collectLocalTarBuffer } from './tar.js';
|
|
|
15
13
|
* syncRunId: string,
|
|
16
14
|
* sourceHomedir: string,
|
|
17
15
|
* collectTar?: typeof collectLocalTarBuffer,
|
|
18
|
-
* credentialSyncAuthorized?: boolean,
|
|
19
16
|
* }} args
|
|
20
17
|
*/
|
|
21
18
|
export const applyConfigSyncPlan = async ({
|
|
@@ -24,13 +21,8 @@ export const applyConfigSyncPlan = async ({
|
|
|
24
21
|
syncRunId,
|
|
25
22
|
sourceHomedir,
|
|
26
23
|
collectTar = collectLocalTarBuffer,
|
|
27
|
-
credentialSyncAuthorized = false,
|
|
28
24
|
}) => {
|
|
29
25
|
assertPlanDirection(plan);
|
|
30
|
-
assertCredentialSyncAuthorized(plan, {
|
|
31
|
-
targetId: plan?.targetId || 'unknown',
|
|
32
|
-
authorized: credentialSyncAuthorized === true,
|
|
33
|
-
});
|
|
34
26
|
const home = String(sourceHomedir || '');
|
|
35
27
|
const configDir = path.join(home, '.config', 'opencode');
|
|
36
28
|
const tarEntries = [
|
|
@@ -48,13 +48,6 @@ export {
|
|
|
48
48
|
} from './scripts.js';
|
|
49
49
|
export { collectLocalTarBuffer } from './tar.js';
|
|
50
50
|
export { applyConfigSyncPlan, probePathsForPlan } from './engine.js';
|
|
51
|
-
export {
|
|
52
|
-
CREDENTIAL_SYNC_UNAUTHORIZED_CODE,
|
|
53
|
-
CREDENTIAL_SYNC_GRANT_CHANNEL_INSTANCE_SETTINGS,
|
|
54
|
-
CredentialSyncUnauthorizedError,
|
|
55
|
-
planIncludesCredentials,
|
|
56
|
-
assertCredentialSyncAuthorized,
|
|
57
|
-
} from './credential-auth.js';
|
|
58
51
|
export {
|
|
59
52
|
buildDefaultSyncSelections,
|
|
60
53
|
normalizeSyncSelections,
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
OPENCODE_CONFIG_SYNC_MAX_BYTES,
|
|
12
12
|
OPENCODE_CONFIG_SYNC_MAX_FILES,
|
|
13
13
|
} from './constants.js';
|
|
14
|
-
import { CREDENTIAL_SYNC_UNAUTHORIZED_CODE } from './credential-auth.js';
|
|
15
14
|
import {
|
|
16
15
|
extractTarGzBuffer,
|
|
17
16
|
finalizeLocalSyncDestination,
|
|
@@ -20,8 +19,6 @@ import {
|
|
|
20
19
|
import { walkAllowlistDirectory } from './plan.js';
|
|
21
20
|
import { sanitizeSyncRunIdForPath } from './scripts.js';
|
|
22
21
|
|
|
23
|
-
const INBOUND_CREDENTIAL_SETTINGS_KEY = 'configSyncInboundCredentialAuthorized';
|
|
24
|
-
|
|
25
22
|
/**
|
|
26
23
|
* In-process receiver for HTTP config-sync (direct/relay hosts).
|
|
27
24
|
* One inflight sync at a time; backups use the same local generational helpers as pull.
|
|
@@ -29,8 +26,6 @@ const INBOUND_CREDENTIAL_SETTINGS_KEY = 'configSyncInboundCredentialAuthorized';
|
|
|
29
26
|
export const createConfigSyncReceiver = (deps = {}) => {
|
|
30
27
|
const {
|
|
31
28
|
homedir = () => os.homedir(),
|
|
32
|
-
readSettings = async () => ({}),
|
|
33
|
-
writeSettingsPatch = async () => {},
|
|
34
29
|
} = deps;
|
|
35
30
|
|
|
36
31
|
let inflight = null;
|
|
@@ -148,18 +143,6 @@ export const createConfigSyncReceiver = (deps = {}) => {
|
|
|
148
143
|
};
|
|
149
144
|
};
|
|
150
145
|
|
|
151
|
-
const isInboundCredentialAuthorized = async () => {
|
|
152
|
-
const settings = await readSettings();
|
|
153
|
-
return settings?.[INBOUND_CREDENTIAL_SETTINGS_KEY] === true;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const setInboundCredentialAuthorized = async (authorized) => {
|
|
157
|
-
await writeSettingsPatch({
|
|
158
|
-
[INBOUND_CREDENTIAL_SETTINGS_KEY]: authorized === true,
|
|
159
|
-
});
|
|
160
|
-
return { authorized: authorized === true };
|
|
161
|
-
};
|
|
162
|
-
|
|
163
146
|
const probe = async (plan) => {
|
|
164
147
|
const snapshot = buildInventory();
|
|
165
148
|
const existing = new Set(snapshot.remoteExisting);
|
|
@@ -171,7 +154,6 @@ export const createConfigSyncReceiver = (deps = {}) => {
|
|
|
171
154
|
return {
|
|
172
155
|
...snapshot,
|
|
173
156
|
remoteExisting: [...new Set(planPaths.filter((rel) => existing.has(rel)))],
|
|
174
|
-
inboundCredentialAuthorized: await isInboundCredentialAuthorized(),
|
|
175
157
|
};
|
|
176
158
|
};
|
|
177
159
|
|
|
@@ -211,14 +193,6 @@ export const createConfigSyncReceiver = (deps = {}) => {
|
|
|
211
193
|
error.code = 'sync_not_prepared';
|
|
212
194
|
throw error;
|
|
213
195
|
}
|
|
214
|
-
if (kind === 'auth') {
|
|
215
|
-
const authorized = await isInboundCredentialAuthorized();
|
|
216
|
-
if (!authorized) {
|
|
217
|
-
const error = new Error('Credential sync is not authorized on this host');
|
|
218
|
-
error.code = CREDENTIAL_SYNC_UNAUTHORIZED_CODE;
|
|
219
|
-
throw error;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
196
|
const buffer = await readStreamToBuffer(stream, { maxBytes: OPENCODE_CONFIG_SYNC_MAX_BYTES });
|
|
223
197
|
const home = homedir();
|
|
224
198
|
if (kind === 'config') {
|
|
@@ -279,12 +253,6 @@ export const createConfigSyncReceiver = (deps = {}) => {
|
|
|
279
253
|
return collectTarGz(home, ['.agents']);
|
|
280
254
|
}
|
|
281
255
|
if (kind === 'auth') {
|
|
282
|
-
const authorized = await isInboundCredentialAuthorized();
|
|
283
|
-
if (!authorized) {
|
|
284
|
-
const error = new Error('Credential sync is not authorized on this host');
|
|
285
|
-
error.code = CREDENTIAL_SYNC_UNAUTHORIZED_CODE;
|
|
286
|
-
throw error;
|
|
287
|
-
}
|
|
288
256
|
return collectTarGz(path.join(home, '.local', 'share', 'opencode'), ['auth.json']);
|
|
289
257
|
}
|
|
290
258
|
const error = new Error(`Unsupported download kind: ${String(kind)}`);
|
|
@@ -315,7 +283,6 @@ export const createConfigSyncReceiver = (deps = {}) => {
|
|
|
315
283
|
};
|
|
316
284
|
|
|
317
285
|
return {
|
|
318
|
-
INBOUND_CREDENTIAL_SETTINGS_KEY,
|
|
319
286
|
probe,
|
|
320
287
|
prepare,
|
|
321
288
|
put,
|
|
@@ -323,8 +290,6 @@ export const createConfigSyncReceiver = (deps = {}) => {
|
|
|
323
290
|
finalize,
|
|
324
291
|
abort,
|
|
325
292
|
getInflight: () => inflight,
|
|
326
|
-
isInboundCredentialAuthorized,
|
|
327
|
-
setInboundCredentialAuthorized,
|
|
328
293
|
buildInventory,
|
|
329
294
|
};
|
|
330
295
|
};
|
|
@@ -2,43 +2,29 @@ import { createConfigSyncReceiver } from './receiver.js';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Register HTTP config-sync receive/download routes for direct (and later relay) hosts.
|
|
5
|
-
* Auth is the global `/api` UI/client-token gate.
|
|
6
|
-
*
|
|
5
|
+
* Auth is the global `/api` UI/client-token gate. Selected kinds (including auth)
|
|
6
|
+
* sync when present in the plan — no extra credential grant checks.
|
|
7
7
|
*
|
|
8
8
|
* @param {import('express').Express} app
|
|
9
9
|
* @param {{
|
|
10
10
|
* receiver?: ReturnType<typeof createConfigSyncReceiver>,
|
|
11
|
-
* readSettingsFromDiskMigrated?: () => Promise<object>,
|
|
12
|
-
* persistSettings?: (changes: object) => Promise<object>,
|
|
13
11
|
* express?: typeof import('express'),
|
|
14
12
|
* }} deps
|
|
15
13
|
*/
|
|
16
14
|
export const registerConfigSyncRoutes = (app, deps = {}) => {
|
|
17
15
|
const {
|
|
18
|
-
readSettingsFromDiskMigrated,
|
|
19
|
-
persistSettings,
|
|
20
16
|
express,
|
|
21
17
|
} = deps;
|
|
22
18
|
|
|
23
|
-
const receiver = deps.receiver || createConfigSyncReceiver(
|
|
24
|
-
readSettings: async () => (typeof readSettingsFromDiskMigrated === 'function'
|
|
25
|
-
? readSettingsFromDiskMigrated()
|
|
26
|
-
: {}),
|
|
27
|
-
writeSettingsPatch: async (patch) => {
|
|
28
|
-
if (typeof persistSettings === 'function') {
|
|
29
|
-
await persistSettings(patch);
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
});
|
|
19
|
+
const receiver = deps.receiver || createConfigSyncReceiver();
|
|
33
20
|
|
|
34
21
|
const sendError = (res, error, fallbackStatus = 500) => {
|
|
35
22
|
const code = typeof error?.code === 'string' ? error.code : undefined;
|
|
36
|
-
const status = code === '
|
|
37
|
-
: code === '
|
|
38
|
-
: code === '
|
|
39
|
-
: code === '
|
|
40
|
-
:
|
|
41
|
-
: fallbackStatus;
|
|
23
|
+
const status = code === 'sync_in_progress' ? 409
|
|
24
|
+
: code === 'sync_not_prepared' ? 409
|
|
25
|
+
: code === 'sync_payload_too_large' || code === 'sync_too_many_files' ? 413
|
|
26
|
+
: code === 'sync_invalid_kind' ? 400
|
|
27
|
+
: fallbackStatus;
|
|
42
28
|
res.status(status).json({
|
|
43
29
|
error: error instanceof Error ? error.message : String(error),
|
|
44
30
|
...(code ? { code } : {}),
|
|
@@ -118,24 +104,5 @@ export const registerConfigSyncRoutes = (app, deps = {}) => {
|
|
|
118
104
|
}
|
|
119
105
|
});
|
|
120
106
|
|
|
121
|
-
app.get('/api/openchamber/config-sync/credential-auth', async (_req, res) => {
|
|
122
|
-
try {
|
|
123
|
-
const authorized = await receiver.isInboundCredentialAuthorized();
|
|
124
|
-
res.json({ authorized });
|
|
125
|
-
} catch (error) {
|
|
126
|
-
sendError(res, error);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
app.put('/api/openchamber/config-sync/credential-auth', express?.json?.({ limit: '16kb' }) || ((req, _res, next) => next()), async (req, res) => {
|
|
131
|
-
try {
|
|
132
|
-
const authorized = req.body?.authorized === true;
|
|
133
|
-
const result = await receiver.setInboundCredentialAuthorized(authorized);
|
|
134
|
-
res.json(result);
|
|
135
|
-
} catch (error) {
|
|
136
|
-
sendError(res, error);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
107
|
return { receiver };
|
|
141
108
|
};
|
|
@@ -8,7 +8,6 @@ import request from 'supertest';
|
|
|
8
8
|
|
|
9
9
|
import { createConfigSyncReceiver } from './receiver.js';
|
|
10
10
|
import { registerConfigSyncRoutes } from './routes.js';
|
|
11
|
-
import { CREDENTIAL_SYNC_UNAUTHORIZED_CODE } from './credential-auth.js';
|
|
12
11
|
|
|
13
12
|
const tempDirs = [];
|
|
14
13
|
|
|
@@ -31,18 +30,13 @@ const createApp = async () => {
|
|
|
31
30
|
await fsp.writeFile(path.join(configDir, 'opencode.jsonc'), '{}\n');
|
|
32
31
|
await fsp.writeFile(path.join(configDir, 'AGENTS.md'), 'hi\n');
|
|
33
32
|
|
|
34
|
-
let settings = {};
|
|
35
33
|
const receiver = createConfigSyncReceiver({
|
|
36
34
|
homedir: () => home,
|
|
37
|
-
readSettings: async () => ({ ...settings }),
|
|
38
|
-
writeSettingsPatch: async (patch) => {
|
|
39
|
-
settings = { ...settings, ...patch };
|
|
40
|
-
},
|
|
41
35
|
});
|
|
42
36
|
|
|
43
37
|
const app = express();
|
|
44
38
|
registerConfigSyncRoutes(app, { receiver, express });
|
|
45
|
-
return { app, home, receiver
|
|
39
|
+
return { app, home, receiver };
|
|
46
40
|
};
|
|
47
41
|
|
|
48
42
|
describe('config-sync HTTP routes', () => {
|
|
@@ -79,27 +73,6 @@ describe('config-sync HTTP routes', () => {
|
|
|
79
73
|
await expect(fsp.stat(backup)).resolves.toMatchObject({ });
|
|
80
74
|
});
|
|
81
75
|
|
|
82
|
-
it('rejects auth put without inbound credential authorization', async () => {
|
|
83
|
-
const { app } = await createApp();
|
|
84
|
-
const plan = {
|
|
85
|
-
direction: 'push',
|
|
86
|
-
files: [],
|
|
87
|
-
directories: [],
|
|
88
|
-
deletes: [],
|
|
89
|
-
agentsRoot: null,
|
|
90
|
-
authFile: { bytes: 2 },
|
|
91
|
-
totalBytes: 2,
|
|
92
|
-
};
|
|
93
|
-
await request(app).post('/api/openchamber/config-sync/prepare').send({ plan, syncRunId: 'run-auth' });
|
|
94
|
-
const put = await request(app)
|
|
95
|
-
.put('/api/openchamber/config-sync/put/auth?syncRunId=run-auth')
|
|
96
|
-
.set('Content-Type', 'application/gzip')
|
|
97
|
-
.send(Buffer.from('xx'));
|
|
98
|
-
expect(put.status).toBe(403);
|
|
99
|
-
expect(put.body.code).toBe(CREDENTIAL_SYNC_UNAUTHORIZED_CODE);
|
|
100
|
-
await request(app).post('/api/openchamber/config-sync/abort').send({ syncRunId: 'run-auth' });
|
|
101
|
-
});
|
|
102
|
-
|
|
103
76
|
it('rejects a second concurrent prepare', async () => {
|
|
104
77
|
const { app } = await createApp();
|
|
105
78
|
const plan = {
|
|
@@ -131,7 +104,6 @@ describe('config-sync HTTP routes', () => {
|
|
|
131
104
|
totalBytes: 0,
|
|
132
105
|
};
|
|
133
106
|
await request(app).post('/api/openchamber/config-sync/prepare').send({ plan, syncRunId: 'run-stream' });
|
|
134
|
-
await receiver.setInboundCredentialAuthorized(true);
|
|
135
107
|
|
|
136
108
|
// Tiny invalid tar still proves chunk aggregation reached extract.
|
|
137
109
|
await expect(receiver.put({
|
|
@@ -142,13 +114,4 @@ describe('config-sync HTTP routes', () => {
|
|
|
142
114
|
|
|
143
115
|
await request(app).post('/api/openchamber/config-sync/abort').send({ syncRunId: 'run-stream' });
|
|
144
116
|
});
|
|
145
|
-
|
|
146
|
-
it('persists inbound credential authorization flag', async () => {
|
|
147
|
-
const { app, getSettings } = await createApp();
|
|
148
|
-
const before = await request(app).get('/api/openchamber/config-sync/credential-auth');
|
|
149
|
-
expect(before.body.authorized).toBe(false);
|
|
150
|
-
const after = await request(app).put('/api/openchamber/config-sync/credential-auth').send({ authorized: true });
|
|
151
|
-
expect(after.body.authorized).toBe(true);
|
|
152
|
-
expect(getSettings().configSyncInboundCredentialAuthorized).toBe(true);
|
|
153
|
-
});
|
|
154
117
|
});
|
|
@@ -10,8 +10,6 @@ export const registerOpenChamberRoutes = (app, dependencies) => {
|
|
|
10
10
|
server,
|
|
11
11
|
__dirname,
|
|
12
12
|
openchamberDataDir,
|
|
13
|
-
readSettingsFromDiskMigrated,
|
|
14
|
-
persistSettings,
|
|
15
13
|
fetchFreeZenModels,
|
|
16
14
|
getCachedZenModels,
|
|
17
15
|
sessionIndexService,
|
|
@@ -22,11 +20,7 @@ export const registerOpenChamberRoutes = (app, dependencies) => {
|
|
|
22
20
|
|
|
23
21
|
registerSessionIndexRoutes(app, { sessionIndexService, sessionIndexSyncRuntime });
|
|
24
22
|
registerTranscriptCacheRoutes(app, { transcriptCacheService });
|
|
25
|
-
registerConfigSyncRoutes(app, {
|
|
26
|
-
readSettingsFromDiskMigrated,
|
|
27
|
-
persistSettings,
|
|
28
|
-
express,
|
|
29
|
-
});
|
|
23
|
+
registerConfigSyncRoutes(app, { express });
|
|
30
24
|
|
|
31
25
|
app.get('/api/openchamber/update-check', async (req, res) => {
|
|
32
26
|
try {
|