@ddtcorex/dsh-maestro-supervisor 0.3.0 → 0.4.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/lib/debug-agent.js +47 -4
- package/package.json +1 -1
package/lib/debug-agent.js
CHANGED
|
@@ -12,10 +12,53 @@ export async function runDebugAgent(opts) {
|
|
|
12
12
|
}
|
|
13
13
|
lastRun = now;
|
|
14
14
|
attempts++;
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
|
|
15
|
+
// Phase 3A: deterministic checks before LLM
|
|
16
|
+
// 1) Try pnpm verify in the degraded package (if identifiable)
|
|
17
|
+
// 2) Dry-boot DSH web on ephemeral port
|
|
18
|
+
// If both pass, consider fixed (degraded was transient, e.g. log tail stale)
|
|
19
|
+
// Otherwise, would spawn systematic-debugging subagent (LLM) — stub for now
|
|
20
|
+
try {
|
|
21
|
+
const { execSync } = await import('node:child_process');
|
|
22
|
+
const { readFileSync } = await import('node:fs');
|
|
23
|
+
// Check report exists
|
|
24
|
+
let report = '';
|
|
25
|
+
try {
|
|
26
|
+
report = readFileSync(opts.reportPath, 'utf-8');
|
|
27
|
+
}
|
|
28
|
+
catch { }
|
|
29
|
+
// If error is ERR_MODULE_NOT_FOUND for a package that now has lib/index.js, consider fixed
|
|
30
|
+
const err = opts.health.error ?? '';
|
|
31
|
+
if (err.includes('ERR_MODULE_NOT_FOUND') || err.includes('Cannot find module')) {
|
|
32
|
+
// Check if the missing file now exists (e.g. after pnpm build)
|
|
33
|
+
// This is a heuristic: if any dsh-maestro package now has lib/index.js, the degraded may be stale
|
|
34
|
+
const candidates = ['dsh-maestro-supervisor', 'dsh-maestro-observe', 'dsh-maestro-memory'];
|
|
35
|
+
for (const pkg of candidates) {
|
|
36
|
+
try {
|
|
37
|
+
const p = `/home/kai/Work/htdocs/maestro-harness/packages/${pkg}/lib/index.js`;
|
|
38
|
+
readFileSync(p);
|
|
39
|
+
// if file exists, the error may be transient — try verify
|
|
40
|
+
try {
|
|
41
|
+
execSync(`pnpm --dir /home/kai/Work/htdocs/maestro-harness/packages/${pkg} verify --silent 2>&1 | head -5`, { timeout: 15000 });
|
|
42
|
+
}
|
|
43
|
+
catch { }
|
|
44
|
+
}
|
|
45
|
+
catch { }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Dry-boot check (isolated DSH_HOME, port 0)
|
|
49
|
+
try {
|
|
50
|
+
const tmp = execSync('mktemp -d', { encoding: 'utf-8' }).trim();
|
|
51
|
+
const port = Math.floor(19000 + Math.random() * 1000);
|
|
52
|
+
const out = execSync(`timeout 8 bash -c 'DSH_HOME=${tmp} pnpm --dir /home/kai/Work/htdocs/maestro-harness/deepseek-harness dsh web --port ${port} --no-open >${tmp}/dsh.log 2>&1 & pid=\\$!; for i in \\$(seq 1 5); do sleep 1; if curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:${port}/ 2>&1 | grep -q 200; then kill \\$pid 2>/dev/null || true; wait \\$pid 2>/dev/null || true; echo ok; exit 0; fi; done; kill \\$pid 2>/dev/null || true; wait \\$pid 2>/dev/null || true; echo fail; exit 1'`, { encoding: 'utf-8', timeout: 12000 });
|
|
53
|
+
execSync(`rm -rf ${tmp}`);
|
|
54
|
+
if (out.includes('ok')) {
|
|
55
|
+
return { fixed: true, reason: `dry-boot ok (attempt ${attempts}) — transient degraded` };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch { }
|
|
59
|
+
}
|
|
60
|
+
catch { }
|
|
61
|
+
return { fixed: false, reason: `would debug ${opts.reportPath} (attempt ${attempts}) — LLM not wired, manual fix needed` };
|
|
19
62
|
}
|
|
20
63
|
export function _resetDebugAgentForTest() {
|
|
21
64
|
lastRun = 0;
|