@ddtcorex/dsh-maestro-core 0.10.0 → 0.11.1
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 +69 -93
- 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 +153 -42
- 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/snapshot.d.ts +3 -2
- package/lib/snapshot.js +3 -2
- 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 +8 -139
- package/src/client/sync/SyncPanel.tsx +1 -1
- package/src/client/sync/index.tsx +4 -4
- 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 +140 -30
- 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/snapshot.ts +3 -2
- 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/src/host/supervisor.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { findInterrupted as defaultFindInterrupted, parseDuration } from './resu
|
|
|
4
4
|
import * as fs from 'node:fs'
|
|
5
5
|
import * as path from 'node:path'
|
|
6
6
|
import * as os from 'node:os'
|
|
7
|
-
import { resolveHarnessRoot } from './paths.js'
|
|
7
|
+
import { resolveHarnessRoot, readSettingsDocSync } from './paths.js'
|
|
8
8
|
import { readSupervisorConfig } from './config.js'
|
|
9
9
|
import { writePlannedRestart as defaultWritePlannedRestart, checkPlannedRestart as defaultCheckPlannedRestart, clearPlannedRestart } from './restart-guards.js'
|
|
10
10
|
import type { RestartRequest } from './restart-guards.js'
|
|
@@ -42,7 +42,7 @@ export interface SupervisorDeps {
|
|
|
42
42
|
bootGraceMs?: number
|
|
43
43
|
getTime?: () => number
|
|
44
44
|
// Checks the dsh-safe-web-update marker (see
|
|
45
|
-
// docs/specs/2026-
|
|
45
|
+
// <workspace-root>/docs/specs/2026-09-13-supervisor-restart-resilience-design.md): a down poll
|
|
46
46
|
// while this resolves true is an intentional restart in progress, not a
|
|
47
47
|
// crash — skip rollback/restartWeb entirely rather than racing it.
|
|
48
48
|
isPlannedRestartActive?: () => boolean | Promise<boolean>
|
|
@@ -206,9 +206,8 @@ export class Supervisor {
|
|
|
206
206
|
if (['0','false','no','off'].includes(v)) return false
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
const
|
|
210
|
-
if (
|
|
211
|
-
const j = JSON.parse(fs.readFileSync(maestroPath, 'utf-8'))
|
|
209
|
+
const j = readSettingsDocSync()
|
|
210
|
+
if (j) {
|
|
212
211
|
const raw = j?.domains?.supervisor?.autoResumeEnabled ?? j?.supervisor?.autoResumeEnabled ?? j?.domains?.supervisor?.autoResume ?? j?.supervisor?.autoResume
|
|
213
212
|
if (typeof raw === 'boolean') return raw
|
|
214
213
|
if (typeof raw === 'string') {
|
|
@@ -247,9 +246,8 @@ export class Supervisor {
|
|
|
247
246
|
if (v !== undefined) return v
|
|
248
247
|
} else if (typeof raw === 'number') return raw * 60 * 1000 // number is MINUTES
|
|
249
248
|
}
|
|
250
|
-
const
|
|
251
|
-
if (
|
|
252
|
-
const j = JSON.parse(fs.readFileSync(maestroPath, 'utf-8'))
|
|
249
|
+
const j = readSettingsDocSync()
|
|
250
|
+
if (j) {
|
|
253
251
|
const raw = j?.domains?.supervisor?.autoResumeWithin ?? j?.supervisor?.autoResumeWithin
|
|
254
252
|
if (typeof raw === 'string') {
|
|
255
253
|
if (/^\d+$/.test(raw.trim())) return parseInt(raw.trim(), 10) * 60 * 1000
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=Keepalive for user manager linger — prevents systemd --user exit on manager session close
|
|
3
|
+
After=default.target
|
|
4
|
+
|
|
5
|
+
[Service]
|
|
6
|
+
Type=simple
|
|
7
|
+
ExecStart=/bin/sleep infinity
|
|
8
|
+
Restart=always
|
|
9
|
+
RestartSec=3
|
|
10
|
+
|
|
11
|
+
[Install]
|
|
12
|
+
WantedBy=default.target
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=DSH Web Supervisor — auto-rollback for dsh web crashes
|
|
3
|
+
After=network.target dsh-web.service
|
|
4
|
+
Wants=dsh-web.service
|
|
5
|
+
|
|
6
|
+
[Service]
|
|
7
|
+
Type=simple
|
|
8
|
+
# Portable: sources nvm directly (bash -lc alone fails — ~/.bashrc guard),
|
|
9
|
+
# then execs node (works for nvm, fnm, volta, system via PATH fallback)
|
|
10
|
+
ExecStart=/bin/bash -c 'export NVM_DIR="$HOME/.nvm"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"; exec node %MAESTRO_ROOT%/packages/dsh-maestro-core/lib/bin.js daemon'
|
|
11
|
+
Restart=always
|
|
12
|
+
RestartSec=2
|
|
13
|
+
Environment=DSH_HOME=%h/.dsh
|
|
14
|
+
# Optional Telegram — loose mode: set these if you want Telegram alerts, otherwise daemon logs only
|
|
15
|
+
# Environment=TELEGRAM_BOT_TOKEN=your_bot_token
|
|
16
|
+
# Environment=TELEGRAM_CHAT_ID=your_chat_id
|
|
17
|
+
# For hard dependency (workspace:^), ensure notifier is installed: pnpm add @ddtcorex/dsh-maestro-notifier
|
|
18
|
+
|
|
19
|
+
[Install]
|
|
20
|
+
WantedBy=default.target
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=DSH Web — main harness web UI + webhook (:3080/:3000)
|
|
3
|
+
After=network.target
|
|
4
|
+
Wants=network.target
|
|
5
|
+
# Cap boot crash loops: if the unit fails to start more than 3 times within 60s,
|
|
6
|
+
# systemd stops retrying until the interval elapses (avoids a tight restart storm).
|
|
7
|
+
StartLimitIntervalSec=60
|
|
8
|
+
StartLimitBurst=3
|
|
9
|
+
|
|
10
|
+
[Service]
|
|
11
|
+
Type=simple
|
|
12
|
+
WorkingDirectory=%MAESTRO_ROOT%/deepseek-harness
|
|
13
|
+
# Portable: sources nvm directly (bash -lc alone fails — ~/.bashrc exits early for
|
|
14
|
+
# non-interactive shells via `case $- in *i*) ;; *) return;; esac`, so nvm never loads).
|
|
15
|
+
# Falls back to system node for machines without nvm — no hardcoded /v24.19.0 version.
|
|
16
|
+
ExecStart=/bin/bash -c 'export NVM_DIR="$HOME/.nvm"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"; exec node --import tsx/esm apps/cli/src/bin.ts web --no-open'
|
|
17
|
+
Restart=always
|
|
18
|
+
RestartSec=5
|
|
19
|
+
# Wait (up to 30 x 5s) for the previous instance to release the raw webserver
|
|
20
|
+
# port before starting, so a restart never races its predecessor into EADDRINUSE.
|
|
21
|
+
# Fails the start (exit 1) if the port is still held after the wait.
|
|
22
|
+
ExecStartPre=/bin/bash -c "for i in {1..30}; do ss -tln 2>/dev/null | grep -q 127.0.0.1:3082 || exit 0; sleep 5; done; exit 1"
|
|
23
|
+
Environment=DSH_HOME=%h/.dsh
|
|
24
|
+
Environment=NODE_ENV=production
|
|
25
|
+
# Log to file for supervisor health tail (append keeps history across restarts)
|
|
26
|
+
StandardOutput=append:%h/.dsh/dsh-web.log
|
|
27
|
+
StandardError=append:%h/.dsh/dsh-web.log
|
|
28
|
+
|
|
29
|
+
[Install]
|
|
30
|
+
WantedBy=default.target
|