@ddtcorex/dsh-maestro-core 0.10.0 → 0.11.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/README.md +31 -12
- package/lib/cli.js +0 -2
- package/lib/client.js +58 -83
- package/lib/config/index.d.ts +11 -4
- package/lib/config/index.js +26 -9
- package/lib/config/service.d.ts +2 -2
- package/lib/config/service.js +2 -2
- package/lib/debug-agent.js +1 -1
- package/lib/paths.d.ts +8 -0
- package/lib/paths.js +22 -0
- package/lib/plugin.d.ts +21 -1
- package/lib/plugin.js +74 -6
- package/lib/restart-guards.js +1 -1
- package/lib/restart-tool.js +13 -4
- package/lib/resume-log.d.ts +4 -0
- package/lib/resume-log.js +13 -4
- package/lib/store/index.js +119 -45
- package/lib/supervisor.js +5 -7
- package/lib/types/client/config/MaestroSettings.d.ts.map +1 -1
- package/package.json +4 -2
- package/scripts/build-client.mjs +53 -0
- package/scripts/install-systemd.sh +55 -0
- package/scripts/sync/bench-preview.mjs +43 -0
- package/scripts/sync/cdp-sync-probe.mjs +200 -0
- package/scripts/sync/cdp-sync-verify.mjs +169 -0
- package/scripts/vendor-store.mjs +104 -0
- package/skills/dsh-safe-restart/SKILL.md +2 -2
- package/skills/dsh-safe-restart/scripts/restart-dsh-web.sh +2 -2
- package/src/client/config/MaestroSettings.tsx +4 -137
- package/src/host/cli.ts +0 -2
- package/src/host/config/index.ts +27 -10
- package/src/host/config/service.ts +2 -2
- package/src/host/debug-agent.ts +1 -1
- package/src/host/paths.ts +21 -0
- package/src/host/plugin.ts +79 -6
- package/src/host/restart-guards.ts +1 -1
- package/src/host/restart-tool.ts +12 -4
- package/src/host/resume-log.ts +20 -5
- package/src/host/store/index.ts +120 -33
- package/src/host/supervisor.ts +6 -8
- package/systemd/dsh-web-keepalive.service.template +12 -0
- package/systemd/dsh-web-supervisor.service.template +20 -0
- package/systemd/dsh-web.service.template +30 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Supervisor for DSH Web resilience — **Phase 1 Guard & Report + Phase 3 Auto-Re
|
|
|
5
5
|
Runs **outside** the `pnpm → sh → node` tree (systemd daemon) to survive tree crashes, plus **inside** `dsh web` as a host+client Cordis plugin to auto-resume interrupted sessions and auto-reload the browser after restart.
|
|
6
6
|
|
|
7
7
|
- **Daemon:** Polls `:3080` every 3s, keeps last-known-good (LKG) snapshots (`~/.dsh/.supervisor/lkg/`, `rotate 3`, `sha256` verify, `df` >500MB guard), auto-rollbacks on crash (`debounce 60s`, `flock` lock), writes `report-<ts>.md` (health + `git diff` + log tail), and notifies via Telegram (loose, never blocks).
|
|
8
|
-
- **Host plugin:** `runAutoResume()` 8s after boot — `findInterrupted` (tail 100) + `findDanglingOpenTurns` (full scan for recent sessions) within `autoResumeWithin` (default 5m) → `agents.resume({resumeSessionId, agentOptions: {provider,model}})` recovered from `request/context` → `followup('continue')`. Loopback RPC `POST /dsh-maestro-supervisor-resume/{scan,resume}` (
|
|
8
|
+
- **Host plugin:** `runAutoResume()` 8s after boot — `findInterrupted` (tail 100) + `findDanglingOpenTurns` (full scan for recent sessions) within `autoResumeWithin` (default 5m) → `agents.resume({resumeSessionId, agentOptions: {provider,model}})` recovered from `request/context` → `followup('continue')`. Loopback RPC `POST /dsh-maestro-supervisor-resume/{scan,resume}` (reachable from loopback; `connection.isLoopback` reports it) for the daemon (`resumeViaRpc`).
|
|
9
9
|
- **Client plugin:** Hybrid auto-reload — `fetch HEAD /` polling 1s on `offline`/`WebSocket close`/`visibilitychange` → `200` → `location.reload()`. Served as `window.__ModuleLoader__.load` bundle at `/plugins/@ddtcorex/dsh-maestro-core/client.js` via `dsh.client`.
|
|
10
10
|
|
|
11
11
|
## Modules
|
|
@@ -14,7 +14,7 @@ One package, four host rows and one client bundle.
|
|
|
14
14
|
|
|
15
15
|
| Module | Source | Row id | Channel | What it does |
|
|
16
16
|
|---|---|---|---|---|
|
|
17
|
-
| Supervisor | `src/host/*.ts` | `maestro-supervisor` | `/dsh-maestro-supervisor-resume` (loopback) | Crash polling, LKG snapshots, auto-resume, auto-reload |
|
|
17
|
+
| Supervisor | `src/host/*.ts` | `maestro-supervisor` | `/dsh-maestro-supervisor-resume` (loopback-reachable) | Crash polling, LKG snapshots, auto-resume, auto-reload |
|
|
18
18
|
| Store | `src/host/store/` | — | — | The namespaced `settings.json` every other module reads and writes |
|
|
19
19
|
| Config | `src/host/config/` | `maestro-config` | `/dsh-maestro-config` | `maestroConfig` service over the store, backing the Maestro settings card |
|
|
20
20
|
| Guard | `src/host/guard/` | `dsh-maestro-guard` | `/dsh-maestro-guard` | Rule classification, the approval gate and its journal |
|
|
@@ -24,6 +24,23 @@ Row `name`s for the absorbed modules are subpaths of this package (`@ddtcorex/ds
|
|
|
24
24
|
|
|
25
25
|
The store is also published on its own (`@ddtcorex/dsh-maestro-core/store`) and can be vendored into a consumer with `scripts/vendor-store.mjs`, which writes one self-verifying file with a body hash.
|
|
26
26
|
|
|
27
|
+
## Registered tools
|
|
28
|
+
|
|
29
|
+
Host tools registered with `ctx.tools.register`:
|
|
30
|
+
|
|
31
|
+
| Tool | Module | What it does |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| `dsh_web_restart` | supervisor | Schedule a supervised `dsh web` restart (consent-gated) |
|
|
34
|
+
| `dsh_web_restart_status` | supervisor | Report the state of the last restart request |
|
|
35
|
+
| `dsh_web_dryboot` | supervisor | Dry-boot on an ephemeral port with an isolated `DSH_HOME` |
|
|
36
|
+
| `dsh_web_gc` | supervisor | Preview, then reap, verified dry-boot orphans |
|
|
37
|
+
| `maestro_session_health` | supervisor | Session-log health scan (re-encode or quarantine) |
|
|
38
|
+
| `maestro_resume_tool_health` | supervisor | Tool-view health of a resumed session |
|
|
39
|
+
| `maestro_repair_session_preset` | supervisor | Re-link an agent that joined no preset |
|
|
40
|
+
| `maestro_guard_status`, `maestro_guard_stats`, `maestro_full_scan` | guard | Guard state, counters and a full rule scan |
|
|
41
|
+
| `maestro_sync_status`, `maestro_sync_check_machines`, `maestro_sync_preview`, `maestro_sync_apply`, `maestro_sync_pull`, `maestro_sync_push`, `maestro_sync_bidirectional_preview`, `maestro_sync_bidirectional_apply`, `maestro_sync_tunnel_restore` | sync | Two-machine sync, preview first |
|
|
42
|
+
| `maestro_backup_preview`, `maestro_backup_apply`, `maestro_backup_gc_preview`, `maestro_backup_gc_apply`, `maestro_restore_preview`, `maestro_restore_apply` | sync | Backup, retention GC and restore, preview first |
|
|
43
|
+
|
|
27
44
|
## Install
|
|
28
45
|
|
|
29
46
|
One package, one command:
|
|
@@ -77,7 +94,7 @@ To run without systemd (foreground, for debugging):
|
|
|
77
94
|
```bash
|
|
78
95
|
node packages/dsh-maestro-core/lib/index.js daemon # poll every 3s
|
|
79
96
|
node packages/dsh-maestro-core/lib/index.js status
|
|
80
|
-
node packages/dsh-maestro-core/lib/index.js
|
|
97
|
+
node packages/dsh-maestro-core/lib/index.js resume --within 5m # list interrupted sessions
|
|
81
98
|
```
|
|
82
99
|
|
|
83
100
|
## Configuration
|
|
@@ -87,7 +104,7 @@ All `autoResumeWithin` values are **minutes** when given as `number` (e.g. `5`
|
|
|
87
104
|
1. **Cordis config** (`cordis.patch.yml` `config:` or `apply(ctx, config)`) — explicit per-install.
|
|
88
105
|
2. **Env** `DSH_SUPERVISOR_AUTO_RESUME` / `DSH_SUPERVISOR_RESUME_WITHIN` (bare `5` in env → 5m for ergonomics).
|
|
89
106
|
3. **Supervisor config** `~/.dsh/.supervisor/config.json` (`autoResumeEnabled`, `autoResumeWithin`).
|
|
90
|
-
4. **Maestro settings** `~/.dsh/maestro/settings.json` (`domains.supervisor.*`).
|
|
107
|
+
4. **Maestro settings** `~/.dsh/dsh-maestro-config/settings.json` (`domains.supervisor.*`).
|
|
91
108
|
5. **Default:** `true` / `5`.
|
|
92
109
|
|
|
93
110
|
| Key | Type | Default | Env | File | Notes |
|
|
@@ -110,11 +127,13 @@ Example `~/.dsh/.supervisor/config.json`:
|
|
|
110
127
|
node packages/dsh-maestro-core/lib/index.js --help
|
|
111
128
|
node packages/dsh-maestro-core/lib/index.js status
|
|
112
129
|
node packages/dsh-maestro-core/lib/index.js daemon # poll 3s, debounce 60s
|
|
113
|
-
node packages/dsh-maestro-core/lib/index.js
|
|
114
|
-
node packages/dsh-maestro-core/lib/index.js
|
|
130
|
+
node packages/dsh-maestro-core/lib/index.js resume [--within <dur>] # list interrupted sessions, e.g. 5m, 30s, 1h
|
|
131
|
+
node packages/dsh-maestro-core/lib/index.js boot-guard acquire|release --pid <pid> # boot.lock + boot-boundary, used by the safe-restart script
|
|
115
132
|
```
|
|
116
133
|
|
|
117
|
-
|
|
134
|
+
The CLI has no `logs` or `rollback` command: rollback runs inside the daemon, and reports are files under `~/.dsh/.supervisor/reports/`.
|
|
135
|
+
|
|
136
|
+
## RPC (reachable from loopback, `connection.isLoopback`)
|
|
118
137
|
|
|
119
138
|
```bash
|
|
120
139
|
# Scan (findInterrupted only, tail 100)
|
|
@@ -131,7 +150,7 @@ curl -s http://127.0.0.1:3080/dsh-maestro-supervisor-resume/resume -X POST \
|
|
|
131
150
|
# or {"ok":false,"error":{"code":"bad-request","message":"resume requires at least one session id"}}
|
|
132
151
|
```
|
|
133
152
|
|
|
134
|
-
The daemon uses `resumeViaRpc()` (`supervisor.ts
|
|
153
|
+
The daemon uses `resumeViaRpc()` (`supervisor.ts`) which POSTs the same envelope to `http://127.0.0.1:3080/dsh-maestro-supervisor-resume/resume` with `fetch` and validates `server-response` + `rpcId` + `result.ok`.
|
|
135
154
|
|
|
136
155
|
## Auto-Resume Details
|
|
137
156
|
|
|
@@ -169,7 +188,7 @@ node --input-type=module -e "import {findDanglingOpenTurns} from './packages/dsh
|
|
|
169
188
|
|---------|-------|-----|
|
|
170
189
|
| `Cannot find package '.../dsh-maestro-core/index.js'` | `pnpm build` not run or `lib/` stale | `pnpm --dir packages/dsh-maestro-core build && pnpm --dir ~/.dsh/profiles/web install` |
|
|
171
190
|
| `exports no "./client" bundle` / `client bundle not found` | Missing `lib/client.js` or `exports["./client"]` | `pnpm build` (runs `tsc` + `tsc -p tsconfig.client.json` + `node scripts/build-client.mjs`), check `package.json` `exports` and `dsh.client`, `test -f lib/client.js`, `curl .../client.js` |
|
|
172
|
-
| `EADDRINUSE
|
|
191
|
+
| `EADDRINUSE` on a fixed port of `dsh web` | A previous `dsh web` still holds the listener tree: `:3080` (LAN proxy), `:3081` (public proxy), `:3082` (raw webserver); `:3000` is unbound | `ss -tlnp | grep -E ':308[012]'` → pid, hand the restart to the human or `dsh_web_restart`; never kill a live session's process yourself, and never `pkill -f "dsh web"`, it kills the invoking shell. |
|
|
173
192
|
| `uses .jsonl but backend is zstd` | Hand-written `session.jsonl` while backend is `zstd` | Use `zstd -c plain.jsonl > session.jsonl.zstd` or `JsonlSessionPersistence` API. Never hand-write opposite encoding — `listArtifacts` checks every project dir on boot and one stray file blocks all of `dsh web`. |
|
|
174
193
|
| `first frame is not exactly one header line` | zstd without `type: session` header | Use `toHeaderLine` + `compressZstdFrame(header)` + `compressZstdFrame(body)` as in `encodeMaterialization`. |
|
|
175
194
|
| `findDangling` 0 but subagent still open | Tail window too small (before `63b7719`) | Fixed: `findDangling` now full-scans recent sessions (mtime within window). `findInterrupted` stays tail 100. |
|
|
@@ -182,9 +201,9 @@ node --input-type=module -e "import {findDanglingOpenTurns} from './packages/dsh
|
|
|
182
201
|
|
|
183
202
|
- **Manual `session.jsonl` vs `zstd`:** One stray opposite-encoding file under `~/.dsh/sessions/` blocks the entire `workspace` `listArtifacts` on every boot (`encodingMismatch`). See Troubleshooting.
|
|
184
203
|
- **Tail vs full scan:** Before `63b7719`, `b6487e33` subagent missed because its only `turn/start` was at seq 6 at the very beginning of a 1906-line log. Fixed, but if you add a new scan variant, reuse `readSessionAllLines` with mtime pre-filter.
|
|
185
|
-
- **Port
|
|
204
|
+
- **Port map:** `:3080` is the LAN proxy (PIN login), `:3081` the public proxy, `:3082` the raw `dsh web` webserver; `:3000` is unbound. Inspect with `ss -tlnp`; never `pkill -f "dsh web"`.
|
|
186
205
|
- **Client bundling:** `lib/client.js` must be `window.__ModuleLoader__.load` wrapper via `scripts/build-client.mjs`, not bare `export`. Add new client files under `src/client/` and ensure `tsconfig.client.json` includes them, then `pnpm build`.
|
|
187
|
-
- **Config precedence:** `cordis.patch.yml` `config:` > env (`DSH_SUPERVISOR_RESUME_WITHIN` bare `5` → 5m) > `config.json` > `settings.json` > default. See `plugin.ts
|
|
206
|
+
- **Config precedence:** `cordis.patch.yml` `config:` > env (`DSH_SUPERVISOR_RESUME_WITHIN` bare `5` → 5m) > `config.json` > `settings.json` > default. See `getAutoResumeEnabled()` and `getResumeWithinMs()` in `plugin.ts` and `supervisor.ts`.
|
|
188
207
|
|
|
189
208
|
## Development
|
|
190
209
|
|
|
@@ -204,6 +223,6 @@ Hard mode (optional): `package.json` add `"@ddtcorex/dsh-maestro-notifier": "wor
|
|
|
204
223
|
|
|
205
224
|
## See Also
|
|
206
225
|
|
|
207
|
-
- Spec: `<workspace-root>/docs/specs/2026-
|
|
226
|
+
- Spec: `<workspace-root>/docs/specs/2026-09-13-supervisor-restart-resilience-design.md`
|
|
208
227
|
- Skill: `skills/dsh-safe-restart/` (`restart-dsh-web.sh` with `dry_boot_and_verify()` and `--auto`)
|
|
209
228
|
- Client bundling: `dsh-maestro-mobile` (`scripts/build-client.mjs` pattern)
|
package/lib/cli.js
CHANGED
|
@@ -165,8 +165,6 @@ export async function runCli(args) {
|
|
|
165
165
|
Commands:
|
|
166
166
|
daemon Run supervisor daemon (poll every 3s)
|
|
167
167
|
status Show health + LKG status
|
|
168
|
-
logs Tail supervisor reports
|
|
169
|
-
rollback --to <ts> Rollback to LKG <ts>
|
|
170
168
|
resume [--within <dur>] List interrupted sessions (filter by time, e.g. 5m, 30s, 1h)
|
|
171
169
|
boot-guard acquire|release --pid <pid> Take/release boot.lock + boot-boundary (used by the safe-restart script)
|
|
172
170
|
`);
|
package/lib/client.js
CHANGED
|
@@ -417,16 +417,6 @@ function FieldInput(props) {
|
|
|
417
417
|
})
|
|
418
418
|
);
|
|
419
419
|
}
|
|
420
|
-
var fieldLabelStyle = {
|
|
421
|
-
display: "flex",
|
|
422
|
-
flexDirection: "column",
|
|
423
|
-
gap: "6px",
|
|
424
|
-
fontSize: "12px",
|
|
425
|
-
lineHeight: "16px",
|
|
426
|
-
fontWeight: "500",
|
|
427
|
-
color: t.labelSecondary,
|
|
428
|
-
margin: "12px 0 0"
|
|
429
|
-
};
|
|
430
420
|
var captionStyle = {
|
|
431
421
|
fontSize: "12px",
|
|
432
422
|
lineHeight: "16px",
|
|
@@ -470,22 +460,6 @@ var rowDescStyle = {
|
|
|
470
460
|
lineHeight: "18px",
|
|
471
461
|
color: t.labelTertiary
|
|
472
462
|
};
|
|
473
|
-
var pillSelectorStyle = {
|
|
474
|
-
display: "inline-flex",
|
|
475
|
-
alignItems: "center",
|
|
476
|
-
gap: "12px",
|
|
477
|
-
height: "36px",
|
|
478
|
-
padding: "0 14px",
|
|
479
|
-
border: "none",
|
|
480
|
-
borderRadius: "18px",
|
|
481
|
-
background: "var(--dsw-alias-bg-module-platform, #F5F6F7)",
|
|
482
|
-
font: "inherit",
|
|
483
|
-
fontSize: "14px",
|
|
484
|
-
lineHeight: "22px",
|
|
485
|
-
color: t.labelPrimary,
|
|
486
|
-
cursor: "pointer",
|
|
487
|
-
whiteSpace: "nowrap"
|
|
488
|
-
};
|
|
489
463
|
function SettingRow({ title, description, control }) {
|
|
490
464
|
return (0, import_react2.createElement)(
|
|
491
465
|
"div",
|
|
@@ -603,6 +577,7 @@ function MaestroSettingsTab({ configRpcCall, supervisorRpcCall }) {
|
|
|
603
577
|
const [supervisorStatus, setSupervisorStatus] = (0, import_react2.useState)(null);
|
|
604
578
|
const [supervisorCfg, setSupervisorCfg] = (0, import_react2.useState)({});
|
|
605
579
|
const [activeTab, setActiveTab] = (0, import_react2.useState)("guard");
|
|
580
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
606
581
|
(0, import_react2.useEffect)(() => {
|
|
607
582
|
const css = `
|
|
608
583
|
/* Model override dropdown \u2014 prevent right-edge overlap */
|
|
@@ -1349,7 +1324,7 @@ function useSync(ctx) {
|
|
|
1349
1324
|
const [checking, setChecking] = React.useState(false);
|
|
1350
1325
|
const [busy, setBusy] = React.useState(false);
|
|
1351
1326
|
const [result, setResult] = React.useState(null);
|
|
1352
|
-
const [
|
|
1327
|
+
const [error, setError] = React.useState("");
|
|
1353
1328
|
const [preview, setPreview] = React.useState(null);
|
|
1354
1329
|
const [previewDirection, setPreviewDirection] = React.useState("pull");
|
|
1355
1330
|
const [confirmOpen, setConfirmOpen] = React.useState(false);
|
|
@@ -1397,13 +1372,13 @@ function useSync(ctx) {
|
|
|
1397
1372
|
[call]
|
|
1398
1373
|
);
|
|
1399
1374
|
const loadStatus = React.useCallback(async () => {
|
|
1400
|
-
|
|
1375
|
+
setError("");
|
|
1401
1376
|
setChecking(true);
|
|
1402
1377
|
setStatus(null);
|
|
1403
1378
|
try {
|
|
1404
1379
|
const res = await call("status", {});
|
|
1405
1380
|
if (res?.ok === false) {
|
|
1406
|
-
|
|
1381
|
+
setError(res?.error ?? "status failed");
|
|
1407
1382
|
return;
|
|
1408
1383
|
}
|
|
1409
1384
|
setStatus(res);
|
|
@@ -1412,7 +1387,7 @@ function useSync(ctx) {
|
|
|
1412
1387
|
else setConnection({ ok: true, host: res?.remoteHost ?? "kai@ssh.ddtcorex.com" });
|
|
1413
1388
|
if (typeof res?.remoteHost === "string" && res.remoteHost) setRemoteHost(res.remoteHost);
|
|
1414
1389
|
} catch (e) {
|
|
1415
|
-
|
|
1390
|
+
setError(e?.message ?? String(e));
|
|
1416
1391
|
} finally {
|
|
1417
1392
|
setChecking(false);
|
|
1418
1393
|
}
|
|
@@ -1439,7 +1414,7 @@ function useSync(ctx) {
|
|
|
1439
1414
|
const handlePreview = React.useCallback(
|
|
1440
1415
|
async (direction) => {
|
|
1441
1416
|
setBusy(true);
|
|
1442
|
-
|
|
1417
|
+
setError("");
|
|
1443
1418
|
setResult(null);
|
|
1444
1419
|
setActionLimit(5);
|
|
1445
1420
|
setProgress({ phase: "listing", current: 0, total: 1 });
|
|
@@ -1447,7 +1422,7 @@ function useSync(ctx) {
|
|
|
1447
1422
|
const start = await call("previewStart", { direction });
|
|
1448
1423
|
const jobId = start?.jobId;
|
|
1449
1424
|
if (!jobId) {
|
|
1450
|
-
|
|
1425
|
+
setError(start?.error ?? "Preview failed to start");
|
|
1451
1426
|
setProgress(null);
|
|
1452
1427
|
return;
|
|
1453
1428
|
}
|
|
@@ -1463,21 +1438,21 @@ function useSync(ctx) {
|
|
|
1463
1438
|
setPreviewDirection(direction);
|
|
1464
1439
|
setConfirmOpen(true);
|
|
1465
1440
|
} else {
|
|
1466
|
-
|
|
1441
|
+
setError("Preview finished without a result");
|
|
1467
1442
|
}
|
|
1468
1443
|
done = true;
|
|
1469
1444
|
} else if (st?.status === "error") {
|
|
1470
|
-
|
|
1445
|
+
setError(st.error ?? "Preview failed");
|
|
1471
1446
|
done = true;
|
|
1472
1447
|
} else if (st?.ok === false) {
|
|
1473
|
-
|
|
1448
|
+
setError(st.error ?? "Preview failed");
|
|
1474
1449
|
done = true;
|
|
1475
1450
|
} else {
|
|
1476
1451
|
await new Promise((r) => setTimeout(r, 700));
|
|
1477
1452
|
}
|
|
1478
1453
|
}
|
|
1479
1454
|
} catch (e) {
|
|
1480
|
-
|
|
1455
|
+
setError(e?.message ?? String(e));
|
|
1481
1456
|
} finally {
|
|
1482
1457
|
setBusy(false);
|
|
1483
1458
|
setProgress(null);
|
|
@@ -1488,7 +1463,7 @@ function useSync(ctx) {
|
|
|
1488
1463
|
const handleApply = React.useCallback(async () => {
|
|
1489
1464
|
if (!preview?.previewId) return;
|
|
1490
1465
|
setBusy(true);
|
|
1491
|
-
|
|
1466
|
+
setError("");
|
|
1492
1467
|
const previewId = preview.previewId;
|
|
1493
1468
|
const direction = previewDirection;
|
|
1494
1469
|
try {
|
|
@@ -1497,7 +1472,7 @@ function useSync(ctx) {
|
|
|
1497
1472
|
setPreview(null);
|
|
1498
1473
|
if (res?.ok === false) {
|
|
1499
1474
|
const label = typeof res.code === "string" ? res.code : "apply failed";
|
|
1500
|
-
|
|
1475
|
+
setError(`${label}: ${res?.error ?? "apply failed"}`);
|
|
1501
1476
|
setResult({ kind: "apply", ok: false, text: "Apply failed" });
|
|
1502
1477
|
return;
|
|
1503
1478
|
}
|
|
@@ -1507,7 +1482,7 @@ function useSync(ctx) {
|
|
|
1507
1482
|
} catch (e) {
|
|
1508
1483
|
setConfirmOpen(false);
|
|
1509
1484
|
setPreview(null);
|
|
1510
|
-
|
|
1485
|
+
setError(e?.message ?? String(e));
|
|
1511
1486
|
} finally {
|
|
1512
1487
|
setBusy(false);
|
|
1513
1488
|
}
|
|
@@ -1518,24 +1493,24 @@ function useSync(ctx) {
|
|
|
1518
1493
|
}, []);
|
|
1519
1494
|
const handleBidirectionalPreview = React.useCallback(async () => {
|
|
1520
1495
|
setBusy(true);
|
|
1521
|
-
|
|
1496
|
+
setError("");
|
|
1522
1497
|
setResult(null);
|
|
1523
1498
|
setActionLimit(5);
|
|
1524
1499
|
setProgress({ phase: "planning", current: 0, total: 1 });
|
|
1525
1500
|
try {
|
|
1526
1501
|
const combined = await call("bidirectionalPreview", {});
|
|
1527
1502
|
if (combined?.ok === false) {
|
|
1528
|
-
|
|
1503
|
+
setError(combined?.error ?? "Bidirectional preview failed");
|
|
1529
1504
|
return;
|
|
1530
1505
|
}
|
|
1531
1506
|
if (!combined?.previewId) {
|
|
1532
|
-
|
|
1507
|
+
setError("Bidirectional preview finished without a result");
|
|
1533
1508
|
return;
|
|
1534
1509
|
}
|
|
1535
1510
|
setBiPreview(combined);
|
|
1536
1511
|
setBiConfirmOpen(true);
|
|
1537
1512
|
} catch (e) {
|
|
1538
|
-
|
|
1513
|
+
setError(e?.message ?? String(e));
|
|
1539
1514
|
} finally {
|
|
1540
1515
|
setBusy(false);
|
|
1541
1516
|
setProgress(null);
|
|
@@ -1544,7 +1519,7 @@ function useSync(ctx) {
|
|
|
1544
1519
|
const handleBidirectionalApply = React.useCallback(async () => {
|
|
1545
1520
|
if (!biPreview?.previewId) return;
|
|
1546
1521
|
setBusy(true);
|
|
1547
|
-
|
|
1522
|
+
setError("");
|
|
1548
1523
|
const previewId = biPreview.previewId;
|
|
1549
1524
|
try {
|
|
1550
1525
|
const res = await call("bidirectionalApply", { previewId, confirm: true });
|
|
@@ -1552,7 +1527,7 @@ function useSync(ctx) {
|
|
|
1552
1527
|
setBiPreview(null);
|
|
1553
1528
|
if (res?.ok === false) {
|
|
1554
1529
|
const label = typeof res.code === "string" ? res.code : "apply failed";
|
|
1555
|
-
|
|
1530
|
+
setError(`${label}: ${res?.error ?? "apply failed"}`);
|
|
1556
1531
|
setResult({ kind: "bidirectional", ok: false, text: "Both-ways apply failed" });
|
|
1557
1532
|
return;
|
|
1558
1533
|
}
|
|
@@ -1570,7 +1545,7 @@ function useSync(ctx) {
|
|
|
1570
1545
|
} catch (e) {
|
|
1571
1546
|
setBiConfirmOpen(false);
|
|
1572
1547
|
setBiPreview(null);
|
|
1573
|
-
|
|
1548
|
+
setError(e?.message ?? String(e));
|
|
1574
1549
|
} finally {
|
|
1575
1550
|
setBusy(false);
|
|
1576
1551
|
}
|
|
@@ -1581,7 +1556,7 @@ function useSync(ctx) {
|
|
|
1581
1556
|
}, []);
|
|
1582
1557
|
const saveRemoteHost = React.useCallback(
|
|
1583
1558
|
async (host) => {
|
|
1584
|
-
|
|
1559
|
+
setError("");
|
|
1585
1560
|
setHostFieldError(null);
|
|
1586
1561
|
try {
|
|
1587
1562
|
const res = await call("saveRemoteHost", { host });
|
|
@@ -1618,7 +1593,7 @@ function useSync(ctx) {
|
|
|
1618
1593
|
}
|
|
1619
1594
|
}, [call]);
|
|
1620
1595
|
const checkConnection = React.useCallback(async () => {
|
|
1621
|
-
|
|
1596
|
+
setError("");
|
|
1622
1597
|
setResult(null);
|
|
1623
1598
|
setChecking(true);
|
|
1624
1599
|
try {
|
|
@@ -1641,23 +1616,23 @@ function useSync(ctx) {
|
|
|
1641
1616
|
}
|
|
1642
1617
|
}, [call, loadStatus, loadMachines, remoteHost]);
|
|
1643
1618
|
const handleTunnelRestorePreview = React.useCallback(async () => {
|
|
1644
|
-
|
|
1619
|
+
setError("");
|
|
1645
1620
|
setResult(null);
|
|
1646
1621
|
setBusy(true);
|
|
1647
1622
|
try {
|
|
1648
1623
|
const res = await call("tunnelRestorePreview", { side: "local" });
|
|
1649
1624
|
if (res?.ok === false) {
|
|
1650
|
-
|
|
1625
|
+
setError(res?.error ?? "tunnel restore preview failed");
|
|
1651
1626
|
return;
|
|
1652
1627
|
}
|
|
1653
1628
|
if (!res?.previewId) {
|
|
1654
|
-
|
|
1629
|
+
setError("Tunnel restore preview finished without a result");
|
|
1655
1630
|
return;
|
|
1656
1631
|
}
|
|
1657
1632
|
setTunnelPreview(res);
|
|
1658
1633
|
setTunnelConfirmOpen(true);
|
|
1659
1634
|
} catch (e) {
|
|
1660
|
-
|
|
1635
|
+
setError(e?.message ?? String(e));
|
|
1661
1636
|
} finally {
|
|
1662
1637
|
setBusy(false);
|
|
1663
1638
|
}
|
|
@@ -1665,7 +1640,7 @@ function useSync(ctx) {
|
|
|
1665
1640
|
const confirmTunnelRestore = React.useCallback(async () => {
|
|
1666
1641
|
const previewId = tunnelPreview?.previewId;
|
|
1667
1642
|
if (!previewId) return;
|
|
1668
|
-
|
|
1643
|
+
setError("");
|
|
1669
1644
|
setBusy(true);
|
|
1670
1645
|
try {
|
|
1671
1646
|
const res = await call("tunnelRestore", { side: "local", previewId, confirm: true });
|
|
@@ -1674,12 +1649,12 @@ function useSync(ctx) {
|
|
|
1674
1649
|
if (res && res.ok) {
|
|
1675
1650
|
setResult({ kind: "tunnel-restore", ok: true, text: `Tunnel restored from profile ${res.profile ?? "auto"} (local)` });
|
|
1676
1651
|
} else {
|
|
1677
|
-
|
|
1652
|
+
setError(res?.error ?? "tunnel restore failed");
|
|
1678
1653
|
}
|
|
1679
1654
|
} catch (e) {
|
|
1680
1655
|
setTunnelConfirmOpen(false);
|
|
1681
1656
|
setTunnelPreview(null);
|
|
1682
|
-
|
|
1657
|
+
setError(e?.message ?? String(e));
|
|
1683
1658
|
} finally {
|
|
1684
1659
|
setBusy(false);
|
|
1685
1660
|
}
|
|
@@ -1710,7 +1685,7 @@ function useSync(ctx) {
|
|
|
1710
1685
|
checking,
|
|
1711
1686
|
busy,
|
|
1712
1687
|
result,
|
|
1713
|
-
error
|
|
1688
|
+
error,
|
|
1714
1689
|
hostFieldError,
|
|
1715
1690
|
setHostFieldError,
|
|
1716
1691
|
preview,
|
|
@@ -1724,7 +1699,7 @@ function useSync(ctx) {
|
|
|
1724
1699
|
progress,
|
|
1725
1700
|
pages,
|
|
1726
1701
|
setActionLimit,
|
|
1727
|
-
setError
|
|
1702
|
+
setError,
|
|
1728
1703
|
setResult,
|
|
1729
1704
|
loadStatus,
|
|
1730
1705
|
loadPage,
|
|
@@ -1749,7 +1724,7 @@ function useBackupTarget(ctx) {
|
|
|
1749
1724
|
const [status, setStatus] = React2.useState(null);
|
|
1750
1725
|
const [checking, setChecking] = React2.useState(true);
|
|
1751
1726
|
const [busy, setBusy] = React2.useState(false);
|
|
1752
|
-
const [
|
|
1727
|
+
const [error, setError] = React2.useState("");
|
|
1753
1728
|
const [backupPreview, setBackupPreview] = React2.useState(null);
|
|
1754
1729
|
const [restorePreview, setRestorePreview] = React2.useState(null);
|
|
1755
1730
|
const [gcReport, setGcReport] = React2.useState(null);
|
|
@@ -1762,29 +1737,29 @@ function useBackupTarget(ctx) {
|
|
|
1762
1737
|
}, [ctx]);
|
|
1763
1738
|
const loadStatus = React2.useCallback(async () => {
|
|
1764
1739
|
setChecking(true);
|
|
1765
|
-
|
|
1740
|
+
setError("");
|
|
1766
1741
|
try {
|
|
1767
1742
|
const res = await call("backupStatus", {});
|
|
1768
1743
|
if (res.ok) setStatus(res.value);
|
|
1769
|
-
else
|
|
1744
|
+
else setError(res.error?.message ?? "backup status failed");
|
|
1770
1745
|
} catch (e) {
|
|
1771
|
-
|
|
1746
|
+
setError(e?.message ?? String(e));
|
|
1772
1747
|
} finally {
|
|
1773
1748
|
setChecking(false);
|
|
1774
1749
|
}
|
|
1775
1750
|
}, [call]);
|
|
1776
1751
|
const previewBackup = React2.useCallback(async () => {
|
|
1777
1752
|
setBusy(true);
|
|
1778
|
-
|
|
1753
|
+
setError("");
|
|
1779
1754
|
setBackupPreview(null);
|
|
1780
1755
|
try {
|
|
1781
1756
|
const res = await call("backupPreview", {});
|
|
1782
1757
|
if (res.ok) {
|
|
1783
1758
|
setBackupPreview(res.value);
|
|
1784
1759
|
setConfirmOpen("backup");
|
|
1785
|
-
} else
|
|
1760
|
+
} else setError(res.error?.message ?? "backup preview failed");
|
|
1786
1761
|
} catch (e) {
|
|
1787
|
-
|
|
1762
|
+
setError(e?.message ?? String(e));
|
|
1788
1763
|
} finally {
|
|
1789
1764
|
setBusy(false);
|
|
1790
1765
|
}
|
|
@@ -1796,10 +1771,10 @@ function useBackupTarget(ctx) {
|
|
|
1796
1771
|
const res = await call("backupApply", { previewId: backupPreview.previewId, confirm: true });
|
|
1797
1772
|
setConfirmOpen(null);
|
|
1798
1773
|
setBackupPreview(null);
|
|
1799
|
-
if (!res.ok)
|
|
1774
|
+
if (!res.ok) setError(res.error?.message ?? "backup apply failed");
|
|
1800
1775
|
void loadStatus();
|
|
1801
1776
|
} catch (e) {
|
|
1802
|
-
|
|
1777
|
+
setError(e?.message ?? String(e));
|
|
1803
1778
|
} finally {
|
|
1804
1779
|
setBusy(false);
|
|
1805
1780
|
}
|
|
@@ -1807,15 +1782,15 @@ function useBackupTarget(ctx) {
|
|
|
1807
1782
|
const previewRestore = React2.useCallback(
|
|
1808
1783
|
async (mode) => {
|
|
1809
1784
|
setBusy(true);
|
|
1810
|
-
|
|
1785
|
+
setError("");
|
|
1811
1786
|
try {
|
|
1812
1787
|
const res = await call("restorePreview", { mode });
|
|
1813
1788
|
if (res.ok) {
|
|
1814
1789
|
setRestorePreview(res.value);
|
|
1815
1790
|
setConfirmOpen("restore");
|
|
1816
|
-
} else
|
|
1791
|
+
} else setError(res.error?.message ?? "restore preview failed");
|
|
1817
1792
|
} catch (e) {
|
|
1818
|
-
|
|
1793
|
+
setError(e?.message ?? String(e));
|
|
1819
1794
|
} finally {
|
|
1820
1795
|
setBusy(false);
|
|
1821
1796
|
}
|
|
@@ -1830,10 +1805,10 @@ function useBackupTarget(ctx) {
|
|
|
1830
1805
|
const res = await call("restoreApply", { previewId: restorePreview.previewId, mode, destDir, confirm: true });
|
|
1831
1806
|
setConfirmOpen(null);
|
|
1832
1807
|
setRestorePreview(null);
|
|
1833
|
-
if (!res.ok)
|
|
1808
|
+
if (!res.ok) setError(res.error?.message ?? "restore apply failed");
|
|
1834
1809
|
if (mode === "in-place") void loadStatus();
|
|
1835
1810
|
} catch (e) {
|
|
1836
|
-
|
|
1811
|
+
setError(e?.message ?? String(e));
|
|
1837
1812
|
} finally {
|
|
1838
1813
|
setBusy(false);
|
|
1839
1814
|
}
|
|
@@ -1842,15 +1817,15 @@ function useBackupTarget(ctx) {
|
|
|
1842
1817
|
);
|
|
1843
1818
|
const previewGc = React2.useCallback(async () => {
|
|
1844
1819
|
setBusy(true);
|
|
1845
|
-
|
|
1820
|
+
setError("");
|
|
1846
1821
|
try {
|
|
1847
1822
|
const res = await call("backupGcPreview", {});
|
|
1848
1823
|
if (res.ok) {
|
|
1849
1824
|
setGcReport(res.value);
|
|
1850
1825
|
setConfirmOpen("gc");
|
|
1851
|
-
} else
|
|
1826
|
+
} else setError(res.error?.message ?? "gc preview failed");
|
|
1852
1827
|
} catch (e) {
|
|
1853
|
-
|
|
1828
|
+
setError(e?.message ?? String(e));
|
|
1854
1829
|
} finally {
|
|
1855
1830
|
setBusy(false);
|
|
1856
1831
|
}
|
|
@@ -1862,10 +1837,10 @@ function useBackupTarget(ctx) {
|
|
|
1862
1837
|
const res = await call("backupGcApply", { previewId: gcReport.previewId, confirm: true });
|
|
1863
1838
|
setConfirmOpen(null);
|
|
1864
1839
|
setGcReport(null);
|
|
1865
|
-
if (!res.ok)
|
|
1840
|
+
if (!res.ok) setError(res.error?.message ?? "gc apply failed");
|
|
1866
1841
|
void loadStatus();
|
|
1867
1842
|
} catch (e) {
|
|
1868
|
-
|
|
1843
|
+
setError(e?.message ?? String(e));
|
|
1869
1844
|
} finally {
|
|
1870
1845
|
setBusy(false);
|
|
1871
1846
|
}
|
|
@@ -1878,19 +1853,19 @@ function useBackupTarget(ctx) {
|
|
|
1878
1853
|
}, []);
|
|
1879
1854
|
const saveR2Config = React2.useCallback(
|
|
1880
1855
|
async (fields) => {
|
|
1881
|
-
|
|
1856
|
+
setError("");
|
|
1882
1857
|
try {
|
|
1883
1858
|
const res = await call("saveR2Config", fields);
|
|
1884
1859
|
if (!res.ok) {
|
|
1885
1860
|
const msg = res.error?.message ?? "save failed";
|
|
1886
|
-
|
|
1861
|
+
setError(msg);
|
|
1887
1862
|
return { ok: false, error: msg };
|
|
1888
1863
|
}
|
|
1889
1864
|
await loadStatus();
|
|
1890
1865
|
return { ok: true };
|
|
1891
1866
|
} catch (e) {
|
|
1892
1867
|
const msg = e?.message ?? String(e);
|
|
1893
|
-
|
|
1868
|
+
setError(msg);
|
|
1894
1869
|
return { ok: false, error: msg };
|
|
1895
1870
|
}
|
|
1896
1871
|
},
|
|
@@ -1904,7 +1879,7 @@ function useBackupTarget(ctx) {
|
|
|
1904
1879
|
status,
|
|
1905
1880
|
checking,
|
|
1906
1881
|
busy,
|
|
1907
|
-
error
|
|
1882
|
+
error,
|
|
1908
1883
|
backupPreview,
|
|
1909
1884
|
restorePreview,
|
|
1910
1885
|
gcReport,
|
|
@@ -2279,7 +2254,7 @@ function SyncPanel(props) {
|
|
|
2279
2254
|
const s = useSync(props.ctx);
|
|
2280
2255
|
const b = useBackupTarget(props.ctx);
|
|
2281
2256
|
const [tab, setTab] = React4.useState("remote");
|
|
2282
|
-
const { connection, checking, busy, error
|
|
2257
|
+
const { connection, checking, busy, error, result, status, remoteHost, remoteSource, lastSync, confirmOpen, preview, previewDirection, biPreview, biConfirmOpen, tunnelPreview, tunnelConfirmOpen, hostFieldError, actionLimit, pages } = s;
|
|
2283
2258
|
const st = b.status;
|
|
2284
2259
|
const isConnected = connection?.ok === true;
|
|
2285
2260
|
const isDisconnected = connection?.ok === false;
|
|
@@ -2496,11 +2471,11 @@ function SyncPanel(props) {
|
|
|
2496
2471
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-desc": "", children: isDisconnected ? "Fix the SSH target above and check again." : "Configure the SSH target above, then Check connection \u2014 everything below unlocks after a successful check." })
|
|
2497
2472
|
] })
|
|
2498
2473
|
] }),
|
|
2499
|
-
|
|
2474
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-sync-notice": "", "data-tone": "bad", role: "alert", children: [
|
|
2500
2475
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-icon": "", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "alert" }) }),
|
|
2501
2476
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { "data-sync-notice-main": "", children: [
|
|
2502
2477
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-title": "", children: "Something went wrong" }),
|
|
2503
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-desc": "", children:
|
|
2478
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-sync-notice-desc": "", children: error })
|
|
2504
2479
|
] })
|
|
2505
2480
|
] }) : null,
|
|
2506
2481
|
confirmOpen && preview ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
package/lib/config/index.d.ts
CHANGED
|
@@ -23,12 +23,19 @@ declare module '@deepseek-ai/cordis' {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Domains this channel may touch: exactly the ones the core Settings card reads
|
|
28
|
+
* and writes (Guard and Supervisor tabs). The store is shared with every other
|
|
29
|
+
* plugin (gitlab token, webhook secret, Telegram bot token, tunnel credentials
|
|
30
|
+
* path), and this channel is reachable from any logged-in browser session, so
|
|
31
|
+
* the allowlist is applied to ALL four endpoints, `list` included. Foreign
|
|
32
|
+
* domains are owned and validated by their own plugins.
|
|
33
|
+
*/
|
|
34
|
+
export declare const RPC_DOMAINS: readonly string[];
|
|
26
35
|
/**
|
|
27
36
|
* Publish maestroConfig over the shared store + loopback RPC for clients.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* Host also handles '/dsh-maestro-config/get' and '/dsh-maestro-config/set'
|
|
31
|
-
* style calls through the single channel with endpoint dispatch.
|
|
37
|
+
* The RPC serves only RPC_DOMAINS; in-process consumers of `ctx.maestroConfig`
|
|
38
|
+
* keep the full service. Validation is delegated to the store's domain validators.
|
|
32
39
|
*/
|
|
33
40
|
export declare function apply(ctx: Context): void;
|
|
34
41
|
export {};
|