@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.
Files changed (48) hide show
  1. package/README.md +31 -12
  2. package/lib/cli.js +0 -2
  3. package/lib/client.js +69 -93
  4. package/lib/config/index.d.ts +11 -4
  5. package/lib/config/index.js +26 -9
  6. package/lib/config/service.d.ts +2 -2
  7. package/lib/config/service.js +2 -2
  8. package/lib/debug-agent.js +1 -1
  9. package/lib/paths.d.ts +8 -0
  10. package/lib/paths.js +22 -0
  11. package/lib/plugin.d.ts +21 -1
  12. package/lib/plugin.js +153 -42
  13. package/lib/restart-guards.js +1 -1
  14. package/lib/restart-tool.js +13 -4
  15. package/lib/resume-log.d.ts +4 -0
  16. package/lib/resume-log.js +13 -4
  17. package/lib/snapshot.d.ts +3 -2
  18. package/lib/snapshot.js +3 -2
  19. package/lib/store/index.js +119 -45
  20. package/lib/supervisor.js +5 -7
  21. package/lib/types/client/config/MaestroSettings.d.ts.map +1 -1
  22. package/package.json +4 -2
  23. package/scripts/build-client.mjs +53 -0
  24. package/scripts/install-systemd.sh +55 -0
  25. package/scripts/sync/bench-preview.mjs +43 -0
  26. package/scripts/sync/cdp-sync-probe.mjs +200 -0
  27. package/scripts/sync/cdp-sync-verify.mjs +169 -0
  28. package/scripts/vendor-store.mjs +104 -0
  29. package/skills/dsh-safe-restart/SKILL.md +2 -2
  30. package/skills/dsh-safe-restart/scripts/restart-dsh-web.sh +2 -2
  31. package/src/client/config/MaestroSettings.tsx +8 -139
  32. package/src/client/sync/SyncPanel.tsx +1 -1
  33. package/src/client/sync/index.tsx +4 -4
  34. package/src/host/cli.ts +0 -2
  35. package/src/host/config/index.ts +27 -10
  36. package/src/host/config/service.ts +2 -2
  37. package/src/host/debug-agent.ts +1 -1
  38. package/src/host/paths.ts +21 -0
  39. package/src/host/plugin.ts +140 -30
  40. package/src/host/restart-guards.ts +1 -1
  41. package/src/host/restart-tool.ts +12 -4
  42. package/src/host/resume-log.ts +20 -5
  43. package/src/host/snapshot.ts +3 -2
  44. package/src/host/store/index.ts +120 -33
  45. package/src/host/supervisor.ts +6 -8
  46. package/systemd/dsh-web-keepalive.service.template +12 -0
  47. package/systemd/dsh-web-supervisor.service.template +20 -0
  48. package/systemd/dsh-web.service.template +30 -0
@@ -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-08-28-supervisor-planned-restart-design.md): a down poll
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 maestroPath = path.join(os.homedir(), '.dsh/maestro/settings.json')
210
- if (fs.existsSync(maestroPath)) {
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 maestroPath = path.join(os.homedir(), '.dsh/maestro/settings.json')
251
- if (fs.existsSync(maestroPath)) {
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