squadrant 0.16.6 → 0.17.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/dist/index.js +1511 -448
- package/dist/index.js.map +1 -1
- package/dist/squadrantd.js +111 -104
- package/dist/squadrantd.js.map +1 -1
- package/package.json +1 -1
- package/plugin/skills/captain-ops/SKILL.md +26 -7
- package/scripts/read-handoff.sh +16 -4
package/dist/squadrantd.js
CHANGED
|
@@ -60,10 +60,10 @@ var init_snapshot = __esm({
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
// packages/cli/src/squadrantd.ts
|
|
63
|
-
import { join as
|
|
64
|
-
import { homedir as
|
|
63
|
+
import { join as join19, dirname as dirname5 } from "path";
|
|
64
|
+
import { homedir as homedir14 } from "os";
|
|
65
65
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
66
|
-
import { readFileSync as
|
|
66
|
+
import { readFileSync as readFileSync14, statSync as statSync4 } from "fs";
|
|
67
67
|
|
|
68
68
|
// packages/shared/dist/config.js
|
|
69
69
|
import fs from "fs";
|
|
@@ -1409,9 +1409,9 @@ function startServer(sockPath, handlerOrCallbacks, onListenError = defaultListen
|
|
|
1409
1409
|
return server;
|
|
1410
1410
|
}
|
|
1411
1411
|
function isDaemonSocketLive(sockPath, timeoutMs = 500) {
|
|
1412
|
-
return new Promise((
|
|
1412
|
+
return new Promise((resolve3) => {
|
|
1413
1413
|
if (!existsSync5(sockPath)) {
|
|
1414
|
-
|
|
1414
|
+
resolve3(false);
|
|
1415
1415
|
return;
|
|
1416
1416
|
}
|
|
1417
1417
|
const conn = createConnection(sockPath);
|
|
@@ -1420,7 +1420,7 @@ function isDaemonSocketLive(sockPath, timeoutMs = 500) {
|
|
|
1420
1420
|
conn.destroy();
|
|
1421
1421
|
} catch {
|
|
1422
1422
|
}
|
|
1423
|
-
|
|
1423
|
+
resolve3(v);
|
|
1424
1424
|
};
|
|
1425
1425
|
const timer = setTimeout(() => finish(false), timeoutMs);
|
|
1426
1426
|
conn.on("connect", () => {
|
|
@@ -1434,7 +1434,7 @@ function isDaemonSocketLive(sockPath, timeoutMs = 500) {
|
|
|
1434
1434
|
});
|
|
1435
1435
|
}
|
|
1436
1436
|
function sendRequest(sockPath, msg, timeoutMs = 5e3) {
|
|
1437
|
-
return new Promise((
|
|
1437
|
+
return new Promise((resolve3, reject) => {
|
|
1438
1438
|
const conn = createConnection(sockPath);
|
|
1439
1439
|
const dec = createDecoder();
|
|
1440
1440
|
const timer = setTimeout(() => {
|
|
@@ -1450,7 +1450,7 @@ function sendRequest(sockPath, msg, timeoutMs = 5e3) {
|
|
|
1450
1450
|
if (m._v !== void 0 && m._v !== PROTOCOL_VERSION) {
|
|
1451
1451
|
reject(new Error(`squadrantd protocol v${m._v}, this client expects v${PROTOCOL_VERSION} \u2014 upgrade squadrantd or this CLI`));
|
|
1452
1452
|
} else if (m.ok) {
|
|
1453
|
-
|
|
1453
|
+
resolve3(m.reply);
|
|
1454
1454
|
} else {
|
|
1455
1455
|
reject(new Error(m.error));
|
|
1456
1456
|
}
|
|
@@ -1626,14 +1626,21 @@ function createStore(root) {
|
|
|
1626
1626
|
};
|
|
1627
1627
|
}
|
|
1628
1628
|
|
|
1629
|
+
// packages/core/dist/work-store.js
|
|
1630
|
+
import { homedir as homedir4 } from "os";
|
|
1631
|
+
import { join as join7, resolve as resolve2, sep as sep2 } from "path";
|
|
1632
|
+
import { randomBytes } from "crypto";
|
|
1633
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync6, readdirSync as readdirSync2, renameSync as renameSync2, writeFileSync as writeFileSync5, existsSync as existsSync7, rmSync as rmSync4, statSync as statSync2 } from "fs";
|
|
1634
|
+
var WORK_ITEM_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
1635
|
+
|
|
1629
1636
|
// packages/core/dist/index.js
|
|
1630
1637
|
init_snapshot();
|
|
1631
1638
|
|
|
1632
1639
|
// packages/core/dist/launchd.js
|
|
1633
1640
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
1634
|
-
import { mkdirSync as
|
|
1635
|
-
import { homedir as
|
|
1636
|
-
import { dirname as dirname3, join as
|
|
1641
|
+
import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync6, readFileSync as readFileSync7, existsSync as existsSync8, openSync, writeSync, closeSync, unlinkSync as unlinkSync2, constants } from "fs";
|
|
1642
|
+
import { homedir as homedir5 } from "os";
|
|
1643
|
+
import { dirname as dirname3, join as join8 } from "path";
|
|
1637
1644
|
import { fileURLToPath } from "url";
|
|
1638
1645
|
|
|
1639
1646
|
// packages/core/dist/crew-pane-reader.js
|
|
@@ -1701,13 +1708,13 @@ function makeGate(opts) {
|
|
|
1701
1708
|
}
|
|
1702
1709
|
|
|
1703
1710
|
// packages/core/dist/daemon/context.js
|
|
1704
|
-
import { homedir as
|
|
1705
|
-
import { join as
|
|
1711
|
+
import { homedir as homedir6 } from "os";
|
|
1712
|
+
import { join as join9 } from "path";
|
|
1706
1713
|
import { spawn as realSpawn } from "child_process";
|
|
1707
|
-
import { writeFileSync as
|
|
1714
|
+
import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync6 } from "fs";
|
|
1708
1715
|
|
|
1709
1716
|
// packages/core/dist/daemon/liveness-registry.js
|
|
1710
|
-
import { writeFileSync as
|
|
1717
|
+
import { writeFileSync as writeFileSync7, readFileSync as readFileSync8, renameSync as renameSync3 } from "fs";
|
|
1711
1718
|
var LivenessRegistry = class {
|
|
1712
1719
|
path;
|
|
1713
1720
|
readFile;
|
|
@@ -1717,14 +1724,14 @@ var LivenessRegistry = class {
|
|
|
1717
1724
|
this.path = opts.path;
|
|
1718
1725
|
this.readFile = opts.readFile ?? ((p) => {
|
|
1719
1726
|
try {
|
|
1720
|
-
return
|
|
1727
|
+
return readFileSync8(p, "utf-8");
|
|
1721
1728
|
} catch {
|
|
1722
1729
|
return void 0;
|
|
1723
1730
|
}
|
|
1724
1731
|
});
|
|
1725
1732
|
this.writeFile = opts.writeFile ?? ((p, c) => {
|
|
1726
|
-
|
|
1727
|
-
|
|
1733
|
+
writeFileSync7(`${p}.tmp`, c);
|
|
1734
|
+
renameSync3(`${p}.tmp`, p);
|
|
1728
1735
|
});
|
|
1729
1736
|
}
|
|
1730
1737
|
load() {
|
|
@@ -1780,18 +1787,18 @@ function defaultIsPidAlive(pid) {
|
|
|
1780
1787
|
}
|
|
1781
1788
|
}
|
|
1782
1789
|
function buildContext(opts) {
|
|
1783
|
-
const stateRoot = opts.stateRoot ??
|
|
1784
|
-
const sockPath = opts.sockPath ??
|
|
1790
|
+
const stateRoot = opts.stateRoot ?? join9(homedir6(), ".config", "squadrant", "state");
|
|
1791
|
+
const sockPath = opts.sockPath ?? join9(homedir6(), ".config", "squadrant", "squadrant.sock");
|
|
1785
1792
|
const store = createStore(stateRoot);
|
|
1786
1793
|
const bootedAt = Date.now();
|
|
1787
1794
|
const taskTimeoutMs = loadConfig().defaults.taskTimeoutMs;
|
|
1788
1795
|
const isPidAlive = opts.isPidAlive ?? defaultIsPidAlive;
|
|
1789
1796
|
const spawn2 = opts.spawn ?? realSpawn;
|
|
1790
|
-
const resultsDir =
|
|
1791
|
-
|
|
1797
|
+
const resultsDir = join9(stateRoot, "_results");
|
|
1798
|
+
mkdirSync6(resultsDir, { recursive: true });
|
|
1792
1799
|
const writeResult = (id, payload) => {
|
|
1793
|
-
const p =
|
|
1794
|
-
|
|
1800
|
+
const p = join9(resultsDir, `${id}.txt`);
|
|
1801
|
+
writeFileSync8(p, payload);
|
|
1795
1802
|
return p;
|
|
1796
1803
|
};
|
|
1797
1804
|
const log = (m) => process.stderr.write(`[squadrantd] ${(/* @__PURE__ */ new Date()).toISOString()} ${m}
|
|
@@ -1813,7 +1820,7 @@ function buildContext(opts) {
|
|
|
1813
1820
|
inFlightHeadlessIds: /* @__PURE__ */ new Set(),
|
|
1814
1821
|
activeHeadlessKills: /* @__PURE__ */ new Set(),
|
|
1815
1822
|
livenessRegistry: (() => {
|
|
1816
|
-
const r = new LivenessRegistry({ path:
|
|
1823
|
+
const r = new LivenessRegistry({ path: join9(stateRoot, "liveness.json") });
|
|
1817
1824
|
r.load();
|
|
1818
1825
|
return r;
|
|
1819
1826
|
})(),
|
|
@@ -1891,7 +1898,7 @@ function createAttach(ctx) {
|
|
|
1891
1898
|
}
|
|
1892
1899
|
|
|
1893
1900
|
// packages/core/dist/daemon/start.js
|
|
1894
|
-
import { join as
|
|
1901
|
+
import { join as join11, dirname as dirname4 } from "path";
|
|
1895
1902
|
import { readdir } from "fs/promises";
|
|
1896
1903
|
|
|
1897
1904
|
// packages/core/dist/daemon/interactive-probe.js
|
|
@@ -2484,12 +2491,12 @@ function createServer2(ctx, handlers) {
|
|
|
2484
2491
|
|
|
2485
2492
|
// packages/core/dist/daemon/snapshot-gather.js
|
|
2486
2493
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2487
|
-
import { join as
|
|
2488
|
-
import { statSync as
|
|
2494
|
+
import { join as join10 } from "path";
|
|
2495
|
+
import { statSync as statSync3, openSync as openSync2, readSync, closeSync as closeSync2, readdirSync as readdirSync3, readFileSync as readFileSync9 } from "fs";
|
|
2489
2496
|
var SELF_PATH = fileURLToPath2(import.meta.url);
|
|
2490
2497
|
function distBuiltAt() {
|
|
2491
2498
|
try {
|
|
2492
|
-
return
|
|
2499
|
+
return statSync3(SELF_PATH).mtimeMs;
|
|
2493
2500
|
} catch {
|
|
2494
2501
|
return 0;
|
|
2495
2502
|
}
|
|
@@ -2497,7 +2504,7 @@ function distBuiltAt() {
|
|
|
2497
2504
|
function gatherLogStats(path19, now, windowMs) {
|
|
2498
2505
|
let sizeBytes = 0;
|
|
2499
2506
|
try {
|
|
2500
|
-
sizeBytes =
|
|
2507
|
+
sizeBytes = statSync3(path19).size;
|
|
2501
2508
|
} catch {
|
|
2502
2509
|
return { errorCount: 0, sizeBytes: 0, windowMs };
|
|
2503
2510
|
}
|
|
@@ -2539,9 +2546,9 @@ function gatherStoreStats(store, stateRoot, project) {
|
|
|
2539
2546
|
for (const r of store.list(project))
|
|
2540
2547
|
byState[r.state] = (byState[r.state] ?? 0) + 1;
|
|
2541
2548
|
let corruptCount = 0;
|
|
2542
|
-
const dir =
|
|
2549
|
+
const dir = join10(stateRoot, project);
|
|
2543
2550
|
try {
|
|
2544
|
-
for (const n of
|
|
2551
|
+
for (const n of readdirSync3(dir)) {
|
|
2545
2552
|
if (n.includes(".corrupt.")) {
|
|
2546
2553
|
corruptCount++;
|
|
2547
2554
|
continue;
|
|
@@ -2549,7 +2556,7 @@ function gatherStoreStats(store, stateRoot, project) {
|
|
|
2549
2556
|
if (!n.endsWith(".json"))
|
|
2550
2557
|
continue;
|
|
2551
2558
|
try {
|
|
2552
|
-
JSON.parse(
|
|
2559
|
+
JSON.parse(readFileSync9(join10(dir, n), "utf-8"));
|
|
2553
2560
|
} catch {
|
|
2554
2561
|
corruptCount++;
|
|
2555
2562
|
}
|
|
@@ -2562,9 +2569,9 @@ function gatherResults(resultsDir) {
|
|
|
2562
2569
|
let fileCount = 0;
|
|
2563
2570
|
let totalBytes = 0;
|
|
2564
2571
|
try {
|
|
2565
|
-
for (const n of
|
|
2572
|
+
for (const n of readdirSync3(resultsDir)) {
|
|
2566
2573
|
try {
|
|
2567
|
-
const s =
|
|
2574
|
+
const s = statSync3(join10(resultsDir, n));
|
|
2568
2575
|
if (s.isFile()) {
|
|
2569
2576
|
fileCount++;
|
|
2570
2577
|
totalBytes += s.size;
|
|
@@ -2653,7 +2660,7 @@ function startDaemon(ctx, opts, pkgVersion) {
|
|
|
2653
2660
|
return out;
|
|
2654
2661
|
}
|
|
2655
2662
|
async function gatherSnapshotInputs(now) {
|
|
2656
|
-
const logPath2 =
|
|
2663
|
+
const logPath2 = join11(dirname4(stateRoot), "squadrantd.log");
|
|
2657
2664
|
const tier2Projects = opts.registeredProjects ?? Object.keys(loadConfig().projects);
|
|
2658
2665
|
const projects = await Promise.all(tier2Projects.map(async (project) => {
|
|
2659
2666
|
const cursor = await readCursor({ stateRoot, project, subscriber: CURSOR_SUBSCRIBER2 });
|
|
@@ -2787,7 +2794,7 @@ function startDaemon(ctx, opts, pkgVersion) {
|
|
|
2787
2794
|
};
|
|
2788
2795
|
let rotationTimer;
|
|
2789
2796
|
if (rotationInterval > 0) {
|
|
2790
|
-
const inboxPath =
|
|
2797
|
+
const inboxPath = join11(stateRoot, "inbox");
|
|
2791
2798
|
rotationTimer = setInterval(async () => {
|
|
2792
2799
|
try {
|
|
2793
2800
|
let entries;
|
|
@@ -2830,9 +2837,9 @@ function startDaemon(ctx, opts, pkgVersion) {
|
|
|
2830
2837
|
}
|
|
2831
2838
|
for (const kill of ctx.activeHeadlessKills)
|
|
2832
2839
|
kill();
|
|
2833
|
-
return new Promise((
|
|
2840
|
+
return new Promise((resolve3) => server.close(() => {
|
|
2834
2841
|
log(`exit-complete pid=${process.pid}`);
|
|
2835
|
-
|
|
2842
|
+
resolve3();
|
|
2836
2843
|
}));
|
|
2837
2844
|
},
|
|
2838
2845
|
tickDelivery: deliveryTick,
|
|
@@ -3021,7 +3028,7 @@ function createIsCaptainAlive(sock) {
|
|
|
3021
3028
|
};
|
|
3022
3029
|
}
|
|
3023
3030
|
function createLaunch(cliBin, log) {
|
|
3024
|
-
return (project) => new Promise((
|
|
3031
|
+
return (project) => new Promise((resolve3, reject) => {
|
|
3025
3032
|
execFile(process.execPath, [cliBin, "launch", project, "--headless"], { timeout: 3e4 }, (err, stdout, stderr) => {
|
|
3026
3033
|
const output = capOutput(stdout ?? "", stderr ?? "");
|
|
3027
3034
|
if (err) {
|
|
@@ -3031,7 +3038,7 @@ function createLaunch(cliBin, log) {
|
|
|
3031
3038
|
}
|
|
3032
3039
|
if (output !== "(no output)")
|
|
3033
3040
|
log?.(`launch ${project}: ${output}`);
|
|
3034
|
-
|
|
3041
|
+
resolve3();
|
|
3035
3042
|
});
|
|
3036
3043
|
});
|
|
3037
3044
|
}
|
|
@@ -3153,10 +3160,10 @@ function findProjectByThread(stateRoot, threadId) {
|
|
|
3153
3160
|
for (const [key, id] of Object.entries(s.topics)) {
|
|
3154
3161
|
if (id !== threadId)
|
|
3155
3162
|
continue;
|
|
3156
|
-
const
|
|
3157
|
-
if (
|
|
3163
|
+
const sep3 = key.indexOf("::");
|
|
3164
|
+
if (sep3 === -1)
|
|
3158
3165
|
continue;
|
|
3159
|
-
return { project: key.slice(0,
|
|
3166
|
+
return { project: key.slice(0, sep3), scope: key.slice(sep3 + 2) };
|
|
3160
3167
|
}
|
|
3161
3168
|
return null;
|
|
3162
3169
|
}
|
|
@@ -3682,16 +3689,16 @@ import fs12 from "fs";
|
|
|
3682
3689
|
|
|
3683
3690
|
// packages/core/dist/restart-daemon.js
|
|
3684
3691
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
3685
|
-
import { existsSync as
|
|
3686
|
-
import { homedir as
|
|
3687
|
-
import { join as
|
|
3688
|
-
var DEFAULT_SOCK_PATH =
|
|
3692
|
+
import { existsSync as existsSync9 } from "fs";
|
|
3693
|
+
import { homedir as homedir7 } from "os";
|
|
3694
|
+
import { join as join12 } from "path";
|
|
3695
|
+
var DEFAULT_SOCK_PATH = join12(homedir7(), ".config", "squadrant", "squadrant.sock");
|
|
3689
3696
|
|
|
3690
3697
|
// packages/core/dist/group-dispatch.js
|
|
3691
3698
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
3692
|
-
import { homedir as
|
|
3693
|
-
import { join as
|
|
3694
|
-
var DEFAULT_SOCK_PATH2 =
|
|
3699
|
+
import { homedir as homedir8 } from "os";
|
|
3700
|
+
import { join as join13 } from "path";
|
|
3701
|
+
var DEFAULT_SOCK_PATH2 = join13(homedir8(), ".config", "squadrant", "squadrant.sock");
|
|
3695
3702
|
|
|
3696
3703
|
// packages/core/dist/side-session.js
|
|
3697
3704
|
import fs13 from "fs";
|
|
@@ -3808,8 +3815,8 @@ var AppServerClient = class extends EventEmitter {
|
|
|
3808
3815
|
const info = this.opts.clientInfo ?? { name: "squadrant", version: "0" };
|
|
3809
3816
|
const id = this.nextId++;
|
|
3810
3817
|
const env = { jsonrpc: "2.0", id, method: "initialize", params: { clientInfo: info } };
|
|
3811
|
-
const res = await new Promise((
|
|
3812
|
-
this.pending.set(id, { resolve:
|
|
3818
|
+
const res = await new Promise((resolve3, reject) => {
|
|
3819
|
+
this.pending.set(id, { resolve: resolve3, reject });
|
|
3813
3820
|
this.proc.stdin.write(JSON.stringify(env) + "\n");
|
|
3814
3821
|
});
|
|
3815
3822
|
this.proc.stdin.write(JSON.stringify({ jsonrpc: "2.0", method: "initialized" }) + "\n");
|
|
@@ -3842,13 +3849,13 @@ var AppServerClient = class extends EventEmitter {
|
|
|
3842
3849
|
const turnId = ack?.turn?.id;
|
|
3843
3850
|
if (typeof turnId !== "string")
|
|
3844
3851
|
throw new Error(`turn/start: unexpected ack shape (no turn.id): ${JSON.stringify(ack).slice(0, 200)}`);
|
|
3845
|
-
return new Promise((
|
|
3852
|
+
return new Promise((resolve3, reject) => {
|
|
3846
3853
|
const onNote = (n) => {
|
|
3847
3854
|
if (n.params?.turn?.id !== turnId)
|
|
3848
3855
|
return;
|
|
3849
3856
|
if (n.method === "turn/completed") {
|
|
3850
3857
|
cleanup();
|
|
3851
|
-
|
|
3858
|
+
resolve3({ turnId });
|
|
3852
3859
|
}
|
|
3853
3860
|
if (n.method === "turn/failed") {
|
|
3854
3861
|
cleanup();
|
|
@@ -3899,8 +3906,8 @@ var AppServerClient = class extends EventEmitter {
|
|
|
3899
3906
|
throw new Error("AppServerClient not started");
|
|
3900
3907
|
const id = this.nextId++;
|
|
3901
3908
|
const env = { jsonrpc: "2.0", id, method, params: params ?? {} };
|
|
3902
|
-
return new Promise((
|
|
3903
|
-
this.pending.set(id, { resolve:
|
|
3909
|
+
return new Promise((resolve3, reject) => {
|
|
3910
|
+
this.pending.set(id, { resolve: resolve3, reject });
|
|
3904
3911
|
this.proc.stdin.write(JSON.stringify(env) + "\n");
|
|
3905
3912
|
});
|
|
3906
3913
|
}
|
|
@@ -4028,11 +4035,11 @@ function toSnapshot(ev) {
|
|
|
4028
4035
|
|
|
4029
4036
|
// packages/agents/dist/codex/config.js
|
|
4030
4037
|
import { readFile as readFile5 } from "fs/promises";
|
|
4031
|
-
import { homedir as
|
|
4032
|
-
import { join as
|
|
4038
|
+
import { homedir as homedir9 } from "os";
|
|
4039
|
+
import { join as join14 } from "path";
|
|
4033
4040
|
async function resolveCodexModel() {
|
|
4034
|
-
const home = process.env["CODEX_HOME"] ??
|
|
4035
|
-
const configPath =
|
|
4041
|
+
const home = process.env["CODEX_HOME"] ?? join14(homedir9(), ".codex");
|
|
4042
|
+
const configPath = join14(home, "config.toml");
|
|
4036
4043
|
let text;
|
|
4037
4044
|
try {
|
|
4038
4045
|
text = await readFile5(configPath, "utf8");
|
|
@@ -4345,11 +4352,11 @@ function buildCodexDeveloperInstructions(rec) {
|
|
|
4345
4352
|
${directive}` : directive;
|
|
4346
4353
|
}
|
|
4347
4354
|
function withTimeout(p, ms, msg) {
|
|
4348
|
-
return new Promise((
|
|
4355
|
+
return new Promise((resolve3, reject) => {
|
|
4349
4356
|
const t = setTimeout(() => reject(new Error(msg)), ms);
|
|
4350
4357
|
p.then((v) => {
|
|
4351
4358
|
clearTimeout(t);
|
|
4352
|
-
|
|
4359
|
+
resolve3(v);
|
|
4353
4360
|
}, (e) => {
|
|
4354
4361
|
clearTimeout(t);
|
|
4355
4362
|
reject(e);
|
|
@@ -4521,9 +4528,9 @@ var OpencodeSseBridge = class {
|
|
|
4521
4528
|
|
|
4522
4529
|
// packages/agents/dist/interactive/claude.js
|
|
4523
4530
|
import { execSync as execSync6 } from "child_process";
|
|
4524
|
-
import { readFileSync as
|
|
4525
|
-
import { homedir as
|
|
4526
|
-
import { join as
|
|
4531
|
+
import { readFileSync as readFileSync10 } from "fs";
|
|
4532
|
+
import { homedir as homedir10 } from "os";
|
|
4533
|
+
import { join as join15 } from "path";
|
|
4527
4534
|
var nextAskUserQuestionRequestId = Date.now();
|
|
4528
4535
|
|
|
4529
4536
|
// packages/agents/dist/headless/types.js
|
|
@@ -4656,14 +4663,14 @@ function runHeadless(opts) {
|
|
|
4656
4663
|
if (err.length > ERR_CAP)
|
|
4657
4664
|
err = err.slice(err.length - ERR_CAP);
|
|
4658
4665
|
});
|
|
4659
|
-
const result = new Promise((
|
|
4666
|
+
const result = new Promise((resolve3) => {
|
|
4660
4667
|
child.once("error", (e) => {
|
|
4661
4668
|
if (debounceTimer) {
|
|
4662
4669
|
clearTimeout(debounceTimer);
|
|
4663
4670
|
debounceTimer = null;
|
|
4664
4671
|
}
|
|
4665
4672
|
opts.emit({ type: "task.failed", id: opts.id, error: `spawn error: ${e.message}`, exitCode: void 0 });
|
|
4666
|
-
|
|
4673
|
+
resolve3();
|
|
4667
4674
|
});
|
|
4668
4675
|
child.on("close", (code) => {
|
|
4669
4676
|
if (chunksSinceProgress > 0)
|
|
@@ -4680,7 +4687,7 @@ function runHeadless(opts) {
|
|
|
4680
4687
|
const ref = opts.writeResult ? opts.writeResult(opts.id, res.payload ?? "") : "";
|
|
4681
4688
|
opts.emit({ type: "task.done", id: opts.id, resultRef: ref, parseWarning: res.parseWarning });
|
|
4682
4689
|
}
|
|
4683
|
-
|
|
4690
|
+
resolve3();
|
|
4684
4691
|
});
|
|
4685
4692
|
});
|
|
4686
4693
|
return { result, kill: () => child.kill("SIGTERM") };
|
|
@@ -4696,7 +4703,7 @@ var CmuxTimeoutError = class extends Error {
|
|
|
4696
4703
|
}
|
|
4697
4704
|
};
|
|
4698
4705
|
function cmux(args) {
|
|
4699
|
-
return new Promise((
|
|
4706
|
+
return new Promise((resolve3, reject) => {
|
|
4700
4707
|
execFile2(
|
|
4701
4708
|
resolveCmuxBin(),
|
|
4702
4709
|
args,
|
|
@@ -4710,19 +4717,19 @@ function cmux(args) {
|
|
|
4710
4717
|
reject(err.code === "ETIMEDOUT" ? new CmuxTimeoutError(args.join(" ")) : err);
|
|
4711
4718
|
return;
|
|
4712
4719
|
}
|
|
4713
|
-
|
|
4720
|
+
resolve3(stdout.trim());
|
|
4714
4721
|
}
|
|
4715
4722
|
);
|
|
4716
4723
|
});
|
|
4717
4724
|
}
|
|
4718
4725
|
function cmuxStdin(args, input) {
|
|
4719
|
-
return new Promise((
|
|
4726
|
+
return new Promise((resolve3, reject) => {
|
|
4720
4727
|
const child = execFile2(resolveCmuxBin(), args, { encoding: "utf-8", timeout: CMUX_TIMEOUT, env: { ...process.env, CMUX_QUIET: "1" } }, (err, stdout) => {
|
|
4721
4728
|
if (err) {
|
|
4722
4729
|
reject(err.code === "ETIMEDOUT" ? new CmuxTimeoutError(args.join(" ")) : err);
|
|
4723
4730
|
return;
|
|
4724
4731
|
}
|
|
4725
|
-
|
|
4732
|
+
resolve3(stdout.trim());
|
|
4726
4733
|
});
|
|
4727
4734
|
child.stdin.end(input);
|
|
4728
4735
|
});
|
|
@@ -5281,7 +5288,7 @@ var NotifierRegistry = class {
|
|
|
5281
5288
|
|
|
5282
5289
|
// packages/workspaces/dist/workspaces/obsidian.js
|
|
5283
5290
|
import fs16 from "fs/promises";
|
|
5284
|
-
import { existsSync as
|
|
5291
|
+
import { existsSync as existsSync10 } from "fs";
|
|
5285
5292
|
import path17 from "path";
|
|
5286
5293
|
|
|
5287
5294
|
// packages/workspaces/dist/cmux-daemon/events-bridge.js
|
|
@@ -5350,12 +5357,12 @@ var CmuxEventsBridge = class {
|
|
|
5350
5357
|
continue;
|
|
5351
5358
|
}
|
|
5352
5359
|
this.child = child;
|
|
5353
|
-
await new Promise((
|
|
5360
|
+
await new Promise((resolve3) => {
|
|
5354
5361
|
let settled = false;
|
|
5355
5362
|
const done = () => {
|
|
5356
5363
|
if (!settled) {
|
|
5357
5364
|
settled = true;
|
|
5358
|
-
|
|
5365
|
+
resolve3();
|
|
5359
5366
|
}
|
|
5360
5367
|
};
|
|
5361
5368
|
child.stdout?.on("data", (b) => this.onData(b));
|
|
@@ -5419,9 +5426,9 @@ var CmuxEventsBridge = class {
|
|
|
5419
5426
|
};
|
|
5420
5427
|
|
|
5421
5428
|
// packages/workspaces/dist/cmux-daemon/daemon-cmux.js
|
|
5422
|
-
import { readdirSync as
|
|
5423
|
-
import { join as
|
|
5424
|
-
import { homedir as
|
|
5429
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync11 } from "fs";
|
|
5430
|
+
import { join as join16 } from "path";
|
|
5431
|
+
import { homedir as homedir11 } from "os";
|
|
5425
5432
|
|
|
5426
5433
|
// packages/workspaces/dist/cmux-daemon/store-fingerprint.js
|
|
5427
5434
|
function roleFromTemplate(args) {
|
|
@@ -5540,22 +5547,22 @@ var DaemonCmux = class {
|
|
|
5540
5547
|
* file failed to read/parse — see the class doc above.
|
|
5541
5548
|
*/
|
|
5542
5549
|
async liveness() {
|
|
5543
|
-
const dir = process.env.CMUX_AGENT_HOOK_STATE_DIR ??
|
|
5550
|
+
const dir = process.env.CMUX_AGENT_HOOK_STATE_DIR ?? join16(homedir11(), ".cmuxterm");
|
|
5544
5551
|
const projects = loadConfig().projects;
|
|
5545
5552
|
let files;
|
|
5546
5553
|
try {
|
|
5547
|
-
files =
|
|
5554
|
+
files = readdirSync4(dir).filter((f) => f.endsWith("-hook-sessions.json") && !f.endsWith(".lock"));
|
|
5548
5555
|
} catch (e) {
|
|
5549
5556
|
throw new Error(`liveness: could not read cmux state dir ${dir}: ${e.message}`);
|
|
5550
5557
|
}
|
|
5551
|
-
return readLivenessSnapshot(files, (f) =>
|
|
5558
|
+
return readLivenessSnapshot(files, (f) => readFileSync11(join16(dir, f), "utf-8"), projects);
|
|
5552
5559
|
}
|
|
5553
5560
|
};
|
|
5554
5561
|
|
|
5555
5562
|
// packages/workspaces/dist/cmux-daemon/cmux-store-source.js
|
|
5556
|
-
import { join as
|
|
5557
|
-
import { homedir as
|
|
5558
|
-
import { watch, readdirSync as
|
|
5563
|
+
import { join as join17 } from "path";
|
|
5564
|
+
import { homedir as homedir12 } from "os";
|
|
5565
|
+
import { watch, readdirSync as readdirSync5, readFileSync as readFileSync12, existsSync as existsSync11 } from "fs";
|
|
5559
5566
|
var CmuxStoreSource = class {
|
|
5560
5567
|
name = "cmux-store";
|
|
5561
5568
|
stateDir;
|
|
@@ -5576,12 +5583,12 @@ var CmuxStoreSource = class {
|
|
|
5576
5583
|
active = false;
|
|
5577
5584
|
lastError = null;
|
|
5578
5585
|
constructor(opts = {}) {
|
|
5579
|
-
this.stateDir = opts.stateDir ?? process.env.CMUX_AGENT_HOOK_STATE_DIR ??
|
|
5586
|
+
this.stateDir = opts.stateDir ?? process.env.CMUX_AGENT_HOOK_STATE_DIR ?? join17(homedir12(), ".cmuxterm");
|
|
5580
5587
|
this.debounceMs = opts.debounceMs ?? 50;
|
|
5581
5588
|
this.isPidAlive = opts.isPidAlive ?? defaultIsPidAlive2;
|
|
5582
5589
|
this.listFiles = opts.listFiles ?? defaultListFiles;
|
|
5583
5590
|
this.readFile = opts.readFile ?? defaultReadFile;
|
|
5584
|
-
this.fileExists = opts.fileExists ??
|
|
5591
|
+
this.fileExists = opts.fileExists ?? existsSync11;
|
|
5585
5592
|
this.watchDir = opts.watchDir ?? defaultWatchDir;
|
|
5586
5593
|
this.scheduleTimer = opts.scheduleTimer ?? setTimeout;
|
|
5587
5594
|
this.cancelTimer = opts.cancelTimer ?? clearTimeout;
|
|
@@ -5638,7 +5645,7 @@ var CmuxStoreSource = class {
|
|
|
5638
5645
|
}
|
|
5639
5646
|
scanFile(filename) {
|
|
5640
5647
|
const deps = this.deps;
|
|
5641
|
-
const filePath =
|
|
5648
|
+
const filePath = join17(this.stateDir, filename);
|
|
5642
5649
|
const lockPath = `${filePath}.lock`;
|
|
5643
5650
|
if (this.fileExists(lockPath)) {
|
|
5644
5651
|
this.log(`cmux-store: skipping ${filename} (locked)`);
|
|
@@ -5704,14 +5711,14 @@ function defaultIsPidAlive2(pid) {
|
|
|
5704
5711
|
}
|
|
5705
5712
|
function defaultListFiles(dir) {
|
|
5706
5713
|
try {
|
|
5707
|
-
return
|
|
5714
|
+
return readdirSync5(dir).filter((f) => f.endsWith("-hook-sessions.json") && !f.endsWith(".lock"));
|
|
5708
5715
|
} catch {
|
|
5709
5716
|
return [];
|
|
5710
5717
|
}
|
|
5711
5718
|
}
|
|
5712
5719
|
function defaultReadFile(path19) {
|
|
5713
5720
|
try {
|
|
5714
|
-
return
|
|
5721
|
+
return readFileSync12(path19, "utf-8");
|
|
5715
5722
|
} catch {
|
|
5716
5723
|
return void 0;
|
|
5717
5724
|
}
|
|
@@ -5726,9 +5733,9 @@ function defaultWatchDir(dir, cb) {
|
|
|
5726
5733
|
}
|
|
5727
5734
|
|
|
5728
5735
|
// packages/workspaces/dist/native-hooks/native-hook-source.js
|
|
5729
|
-
import { join as
|
|
5730
|
-
import { homedir as
|
|
5731
|
-
import { mkdirSync as
|
|
5736
|
+
import { join as join18 } from "path";
|
|
5737
|
+
import { homedir as homedir13 } from "os";
|
|
5738
|
+
import { mkdirSync as mkdirSync7, readFileSync as readFileSync13, writeFileSync as writeFileSync9 } from "fs";
|
|
5732
5739
|
var CLAUDE_HOOK_EVENTS = [
|
|
5733
5740
|
["SessionStart", "session-start"],
|
|
5734
5741
|
["UserPromptSubmit", "prompt-submit"],
|
|
@@ -5740,7 +5747,7 @@ var CLAUDE_HOOK_EVENTS = [
|
|
|
5740
5747
|
];
|
|
5741
5748
|
var DEFAULT_HOOK_CMD = "squadrant hooks";
|
|
5742
5749
|
function installClaudeHooks(opts = {}) {
|
|
5743
|
-
const settingsPath = opts.settingsPath ??
|
|
5750
|
+
const settingsPath = opts.settingsPath ?? join18(homedir13(), ".claude", "settings.json");
|
|
5744
5751
|
const hookCmd = opts.hookCmd ?? DEFAULT_HOOK_CMD;
|
|
5745
5752
|
const readFile6 = opts.readFile ?? defaultReadFile2;
|
|
5746
5753
|
const writeFile5 = opts.writeFile ?? defaultWriteFile;
|
|
@@ -5910,14 +5917,14 @@ function extractDetail(sub, payload) {
|
|
|
5910
5917
|
}
|
|
5911
5918
|
function defaultReadFile2(path19) {
|
|
5912
5919
|
try {
|
|
5913
|
-
return
|
|
5920
|
+
return readFileSync13(path19, "utf-8");
|
|
5914
5921
|
} catch {
|
|
5915
5922
|
return void 0;
|
|
5916
5923
|
}
|
|
5917
5924
|
}
|
|
5918
5925
|
function defaultWriteFile(path19, content) {
|
|
5919
|
-
|
|
5920
|
-
|
|
5926
|
+
mkdirSync7(path19.replace(/\/[^/]+$/, ""), { recursive: true });
|
|
5927
|
+
writeFileSync9(path19, content, "utf-8");
|
|
5921
5928
|
}
|
|
5922
5929
|
|
|
5923
5930
|
// packages/workspaces/dist/crew-pane.js
|
|
@@ -6041,12 +6048,12 @@ async function maybeBroadcastDaemonRestart(opts) {
|
|
|
6041
6048
|
|
|
6042
6049
|
// packages/cli/src/squadrantd.ts
|
|
6043
6050
|
var SELF_PATH2 = fileURLToPath3(import.meta.url);
|
|
6044
|
-
var CLI_BIN =
|
|
6045
|
-
var DAEMON_SOCK =
|
|
6051
|
+
var CLI_BIN = join19(dirname5(SELF_PATH2), "index.js");
|
|
6052
|
+
var DAEMON_SOCK = join19(homedir14(), ".config", "squadrant", "squadrant.sock");
|
|
6046
6053
|
function readPkgVersion() {
|
|
6047
6054
|
try {
|
|
6048
|
-
const pkgPath =
|
|
6049
|
-
return JSON.parse(
|
|
6055
|
+
const pkgPath = join19(dirname5(SELF_PATH2), "..", "package.json");
|
|
6056
|
+
return JSON.parse(readFileSync14(pkgPath, "utf-8")).version ?? "unknown";
|
|
6050
6057
|
} catch {
|
|
6051
6058
|
return "unknown";
|
|
6052
6059
|
}
|
|
@@ -6139,7 +6146,7 @@ function startSquadrantd(opts = {}) {
|
|
|
6139
6146
|
(r) => r.mode === "interactive" && !TERMINAL_STATES.has(r.state) && r.cwd === hook.cwd
|
|
6140
6147
|
);
|
|
6141
6148
|
},
|
|
6142
|
-
cursorFile:
|
|
6149
|
+
cursorFile: join19(stateRoot, "cmux-events.seq"),
|
|
6143
6150
|
log
|
|
6144
6151
|
});
|
|
6145
6152
|
const cmuxStoreSource = new CmuxStoreSource({ log });
|
|
@@ -6298,7 +6305,7 @@ ${buildCompletionProtocol(rec.id, rec.project)}`;
|
|
|
6298
6305
|
}
|
|
6299
6306
|
if (!process.env.VITEST) {
|
|
6300
6307
|
try {
|
|
6301
|
-
const buildMtimeMs =
|
|
6308
|
+
const buildMtimeMs = statSync4(SELF_PATH2).mtimeMs;
|
|
6302
6309
|
const restartConfig = loadConfig();
|
|
6303
6310
|
const registry = new RuntimeRegistry({ cmux: createCmuxDriver() });
|
|
6304
6311
|
void maybeBroadcastDaemonRestart({
|
|
@@ -6351,7 +6358,7 @@ if (process.argv[1] && process.argv[1].endsWith("squadrantd.js")) {
|
|
|
6351
6358
|
process.stdout.write("squadrantd: launchd-managed daemon entry (no CLI args). Use `squadrant` for commands.\n");
|
|
6352
6359
|
process.exit(0);
|
|
6353
6360
|
}
|
|
6354
|
-
const sock =
|
|
6361
|
+
const sock = join19(homedir14(), ".config", "squadrant", "squadrant.sock");
|
|
6355
6362
|
if (await isDaemonSocketLive(sock)) {
|
|
6356
6363
|
process.stderr.write(`[squadrantd] refusing to start: a live daemon already owns ${sock}
|
|
6357
6364
|
`);
|