squadrant 0.11.3 → 0.12.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.
@@ -56,9 +56,9 @@ var init_snapshot = __esm({
56
56
  }
57
57
  });
58
58
 
59
- // packages/cli/src/control/squadrantd.ts
60
- import { join as join13, dirname as dirname5 } from "path";
61
- import { homedir as homedir8 } from "os";
59
+ // packages/cli/src/squadrantd.ts
60
+ import { join as join15, dirname as dirname5 } from "path";
61
+ import { homedir as homedir10 } from "os";
62
62
  import { fileURLToPath as fileURLToPath3 } from "url";
63
63
  import { readFileSync as readFileSync9 } from "fs";
64
64
 
@@ -227,22 +227,22 @@ var MINIMAL_TEMPLATE = [
227
227
  ``
228
228
  ].join("\n");
229
229
  function ensureSocketAutomation(opts = {}) {
230
- const path16 = opts.path ?? defaultCmuxConfigPath();
231
- if (!existsSync(path16)) {
232
- mkdirSync(dirname(path16), { recursive: true });
233
- writeFileSync(path16, MINIMAL_TEMPLATE);
234
- return { path: path16, changed: true, alreadySet: false };
230
+ const path17 = opts.path ?? defaultCmuxConfigPath();
231
+ if (!existsSync(path17)) {
232
+ mkdirSync(dirname(path17), { recursive: true });
233
+ writeFileSync(path17, MINIMAL_TEMPLATE);
234
+ return { path: path17, changed: true, alreadySet: false };
235
235
  }
236
- const text = readFileSync(path16, "utf-8");
236
+ const text = readFileSync(path17, "utf-8");
237
237
  const current = parse(text)?.automation?.socketControlMode;
238
238
  if (current === AUTOMATION_MODE) {
239
- return { path: path16, changed: false, alreadySet: true };
239
+ return { path: path17, changed: false, alreadySet: true };
240
240
  }
241
241
  const edits = modify(text, [...SOCKET_CONTROL_MODE_PATH], AUTOMATION_MODE, {
242
242
  formattingOptions: { insertSpaces: true, tabSize: 2 }
243
243
  });
244
- writeFileSync(path16, applyEdits(text, edits));
245
- return { path: path16, changed: true, alreadySet: false };
244
+ writeFileSync(path17, applyEdits(text, edits));
245
+ return { path: path17, changed: true, alreadySet: false };
246
246
  }
247
247
 
248
248
  // packages/shared/dist/lib/cmux-probe.js
@@ -364,9 +364,9 @@ function sleep(ms) {
364
364
  function defaultStatePath() {
365
365
  return join4(homedir3(), ".config", "squadrant", "state", "cmux-autoconfig.json");
366
366
  }
367
- function readState(path16) {
367
+ function readState(path17) {
368
368
  try {
369
- return JSON.parse(readFileSync4(path16, "utf-8"));
369
+ return JSON.parse(readFileSync4(path17, "utf-8"));
370
370
  } catch {
371
371
  return {};
372
372
  }
@@ -577,7 +577,7 @@ function recoverStall(rec, now) {
577
577
  return { ...rec, state: "working", lastHeartbeat: now, lastEvent: "watchdog.recover", pendingTool: void 0 };
578
578
  }
579
579
 
580
- // packages/core/dist/daemon.js
580
+ // packages/core/dist/daemon/reduce.js
581
581
  var DEFAULT_TASK_TIMEOUT_MS = 8 * 60 * 60 * 1e3;
582
582
  var TERMINAL_RECORD_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
583
583
  var ATTENTION_STATES = /* @__PURE__ */ new Set(["done", "blocked", "failed", "stalled", "awaiting-input"]);
@@ -1913,7 +1913,7 @@ var CaptainDelivery = class {
1913
1913
  }
1914
1914
  };
1915
1915
 
1916
- // packages/core/dist/daemon/delivery.js
1916
+ // packages/core/dist/daemon/delivery-loop.js
1917
1917
  var CURSOR_SUBSCRIBER = "captain";
1918
1918
  var CAPTAIN_GONE_STREAK_K = 3;
1919
1919
  function discoverCaptainSurface(surfaces, captainTitle) {
@@ -2120,10 +2120,10 @@ function distBuiltAt() {
2120
2120
  return 0;
2121
2121
  }
2122
2122
  }
2123
- function gatherLogStats(path16, now, windowMs) {
2123
+ function gatherLogStats(path17, now, windowMs) {
2124
2124
  let sizeBytes = 0;
2125
2125
  try {
2126
- sizeBytes = statSync2(path16).size;
2126
+ sizeBytes = statSync2(path17).size;
2127
2127
  } catch {
2128
2128
  return { errorCount: 0, sizeBytes: 0, windowMs };
2129
2129
  }
@@ -2134,7 +2134,7 @@ function gatherLogStats(path16, now, windowMs) {
2134
2134
  const len = sizeBytes - start;
2135
2135
  let text = "";
2136
2136
  try {
2137
- const fd = openSync2(path16, "r");
2137
+ const fd = openSync2(path17, "r");
2138
2138
  try {
2139
2139
  const buf = Buffer.alloc(len);
2140
2140
  readSync(fd, buf, 0, len, start);
@@ -2575,6 +2575,53 @@ function parseCommand(text) {
2575
2575
  return entry.build(args);
2576
2576
  }
2577
2577
 
2578
+ // packages/core/dist/telegram/control.js
2579
+ import { execFile } from "child_process";
2580
+ import { promisify } from "util";
2581
+ var pExecFile = promisify(execFile);
2582
+ var MAX_OUTPUT = 3500;
2583
+ function capOutput(stdout, stderr, max = MAX_OUTPUT) {
2584
+ const out = stdout.trim();
2585
+ const err = stderr.trim();
2586
+ let combined = out;
2587
+ if (err)
2588
+ combined = combined ? `${combined}
2589
+ [stderr] ${err}` : `[stderr] ${err}`;
2590
+ if (!combined)
2591
+ combined = "(no output)";
2592
+ if (combined.length > max)
2593
+ combined = combined.slice(0, max) + "\n\u2026[truncated]";
2594
+ return combined;
2595
+ }
2596
+ var COMMAND_TIMEOUT_MS = 6e4;
2597
+ function createRunCommand(cliBin) {
2598
+ return async (argv) => {
2599
+ try {
2600
+ const { stdout, stderr } = await pExecFile(process.execPath, [cliBin, ...argv], { timeout: COMMAND_TIMEOUT_MS, maxBuffer: 4 * 1024 * 1024 });
2601
+ return capOutput(stdout ?? "", stderr ?? "");
2602
+ } catch (e) {
2603
+ const err = e;
2604
+ return capOutput(err.stdout ?? "", err.stderr ?? err.message ?? "command failed");
2605
+ }
2606
+ };
2607
+ }
2608
+ function createIsCaptainAlive(sock) {
2609
+ return async (project) => {
2610
+ try {
2611
+ const health = await sendRequest(sock, { kind: "health", project }, 5e3);
2612
+ const captain = health?.find((h) => h.kind === "captain" && h.project === project);
2613
+ return captain != null && captain.state !== "gone" && captain.state !== "unknown";
2614
+ } catch {
2615
+ return false;
2616
+ }
2617
+ };
2618
+ }
2619
+ function createLaunch(cliBin) {
2620
+ return async (project) => {
2621
+ await pExecFile(process.execPath, [cliBin, "launch", project], { timeout: 3e4 });
2622
+ };
2623
+ }
2624
+
2578
2625
  // packages/core/dist/telegram/ensure-captain.js
2579
2626
  var DEFAULT_WARMUP_TIMEOUT_MS = 12e4;
2580
2627
  var DEFAULT_POLL_MS = 1e3;
@@ -2746,6 +2793,12 @@ function createTelegramClient(opts) {
2746
2793
  },
2747
2794
  async setMyCommands(commands) {
2748
2795
  await call("setMyCommands", { commands });
2796
+ },
2797
+ async sendChatAction(chatId, threadId, action) {
2798
+ const body = { chat_id: chatId, action };
2799
+ if (threadId !== void 0)
2800
+ body.message_thread_id = threadId;
2801
+ await call("sendChatAction", body);
2749
2802
  }
2750
2803
  };
2751
2804
  }
@@ -3098,6 +3151,9 @@ function createTelegramBridge(opts) {
3098
3151
  await runChannelCommand(text, fromId, threadId);
3099
3152
  return;
3100
3153
  }
3154
+ void client.sendChatAction(cfg.supergroupId, threadId, "typing").catch((e) => {
3155
+ log(`telegram sendChatAction failed: ${e.message}`);
3156
+ });
3101
3157
  setNotify(stateRoot, resolved.project, true);
3102
3158
  if (ensureCaptainAlive && isControlEnabled(cfg) && isAuthorized(fromId, cfg)) {
3103
3159
  try {
@@ -3183,53 +3239,28 @@ function createTelegramBridge(opts) {
3183
3239
  // packages/core/dist/telegram/setup.js
3184
3240
  import fs10 from "fs";
3185
3241
 
3186
- // packages/cli/src/control/telegram-control.ts
3187
- import { execFile } from "child_process";
3188
- import { promisify } from "util";
3189
- var pExecFile = promisify(execFile);
3190
- var MAX_OUTPUT = 3500;
3191
- function capOutput(stdout, stderr, max = MAX_OUTPUT) {
3192
- const out = stdout.trim();
3193
- const err = stderr.trim();
3194
- let combined = out;
3195
- if (err) combined = combined ? `${combined}
3196
- [stderr] ${err}` : `[stderr] ${err}`;
3197
- if (!combined) combined = "(no output)";
3198
- if (combined.length > max) combined = combined.slice(0, max) + "\n\u2026[truncated]";
3199
- return combined;
3200
- }
3201
- var COMMAND_TIMEOUT_MS = 6e4;
3202
- function createRunCommand(cliBin) {
3203
- return async (argv) => {
3204
- try {
3205
- const { stdout, stderr } = await pExecFile(
3206
- process.execPath,
3207
- [cliBin, ...argv],
3208
- { timeout: COMMAND_TIMEOUT_MS, maxBuffer: 4 * 1024 * 1024 }
3209
- );
3210
- return capOutput(stdout ?? "", stderr ?? "");
3211
- } catch (e) {
3212
- const err = e;
3213
- return capOutput(err.stdout ?? "", err.stderr ?? err.message ?? "command failed");
3214
- }
3215
- };
3216
- }
3217
- function createIsCaptainAlive(sock) {
3218
- return async (project) => {
3219
- try {
3220
- const health = await sendRequest(sock, { kind: "health", project }, 5e3);
3221
- const captain = health?.find((h) => h.kind === "captain" && h.project === project);
3222
- return captain != null && captain.state !== "gone" && captain.state !== "unknown";
3223
- } catch {
3224
- return false;
3225
- }
3226
- };
3227
- }
3228
- function createLaunch(cliBin) {
3229
- return async (project) => {
3230
- await pExecFile(process.execPath, [cliBin, "launch", project], { timeout: 3e4 });
3231
- };
3232
- }
3242
+ // packages/core/dist/restart-daemon.js
3243
+ import { execFileSync as execFileSync4 } from "child_process";
3244
+ import { existsSync as existsSync8 } from "fs";
3245
+ import { homedir as homedir6 } from "os";
3246
+ import { join as join11 } from "path";
3247
+ var DEFAULT_SOCK_PATH = join11(homedir6(), ".config", "squadrant", "squadrant.sock");
3248
+
3249
+ // packages/core/dist/group-dispatch.js
3250
+ import { randomUUID as randomUUID3 } from "crypto";
3251
+ import { homedir as homedir7 } from "os";
3252
+ import { join as join12 } from "path";
3253
+ var DEFAULT_SOCK_PATH2 = join12(homedir7(), ".config", "squadrant", "squadrant.sock");
3254
+
3255
+ // packages/core/dist/side-session.js
3256
+ import fs11 from "fs";
3257
+
3258
+ // packages/core/dist/crew-spawn.js
3259
+ import fs12 from "fs";
3260
+ import os4 from "os";
3261
+ import path10 from "path";
3262
+ var TEMPLATES_DIR = path10.join(os4.homedir(), ".config", "squadrant", "templates");
3263
+ var STATE_ROOT = path10.join(os4.homedir(), ".config", "squadrant", "state");
3233
3264
 
3234
3265
  // packages/agents/dist/drivers/claude.js
3235
3266
  import { execSync as execSync2 } from "child_process";
@@ -3244,28 +3275,28 @@ import { execSync as execSync4 } from "child_process";
3244
3275
  import { execSync as execSync5 } from "child_process";
3245
3276
 
3246
3277
  // packages/agents/dist/drivers/launch-cmd.js
3247
- import fs11 from "fs";
3248
- import path10 from "path";
3278
+ import fs13 from "fs";
3279
+ import path11 from "path";
3249
3280
 
3250
3281
  // packages/agents/dist/projection/cursor.js
3251
3282
  import { mkdir, readFile, writeFile } from "fs/promises";
3252
- import path11 from "path";
3253
- import os4 from "os";
3283
+ import path12 from "path";
3284
+ import os5 from "os";
3254
3285
 
3255
3286
  // packages/agents/dist/projection/codex.js
3256
3287
  import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
3257
- import path12 from "path";
3258
- import os5 from "os";
3288
+ import path13 from "path";
3289
+ import os6 from "os";
3259
3290
 
3260
3291
  // packages/agents/dist/projection/gemini.js
3261
3292
  import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
3262
- import path13 from "path";
3263
- import os6 from "os";
3293
+ import path14 from "path";
3294
+ import os7 from "os";
3264
3295
 
3265
3296
  // packages/agents/dist/projection/opencode.js
3266
3297
  import { mkdir as mkdir4, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
3267
- import path14 from "path";
3268
- import os7 from "os";
3298
+ import path15 from "path";
3299
+ import os8 from "os";
3269
3300
 
3270
3301
  // packages/agents/dist/codex/app-server-client.js
3271
3302
  import { EventEmitter } from "events";
@@ -3451,11 +3482,11 @@ function defaultSpawn() {
3451
3482
 
3452
3483
  // packages/agents/dist/codex/config.js
3453
3484
  import { readFile as readFile5 } from "fs/promises";
3454
- import { homedir as homedir6 } from "os";
3455
- import { join as join11 } from "path";
3485
+ import { homedir as homedir8 } from "os";
3486
+ import { join as join13 } from "path";
3456
3487
  async function resolveCodexModel() {
3457
- const home = process.env["CODEX_HOME"] ?? join11(homedir6(), ".codex");
3458
- const configPath = join11(home, "config.toml");
3488
+ const home = process.env["CODEX_HOME"] ?? join13(homedir8(), ".codex");
3489
+ const configPath = join13(home, "config.toml");
3459
3490
  let text;
3460
3491
  try {
3461
3492
  text = await readFile5(configPath, "utf8");
@@ -3945,8 +3976,8 @@ var OpencodeSseBridge = class {
3945
3976
  // packages/agents/dist/interactive/claude.js
3946
3977
  import { execSync as execSync6 } from "child_process";
3947
3978
  import { readFileSync as readFileSync8 } from "fs";
3948
- import { homedir as homedir7 } from "os";
3949
- import { join as join12 } from "path";
3979
+ import { homedir as homedir9 } from "os";
3980
+ import { join as join14 } from "path";
3950
3981
 
3951
3982
  // packages/agents/dist/headless/types.js
3952
3983
  var HEADLESS_ERROR_TAIL = 2e3;
@@ -4109,7 +4140,7 @@ function runHeadless(opts) {
4109
4140
  }
4110
4141
 
4111
4142
  // packages/workspaces/dist/runtimes/cmux.js
4112
- import { execFile as execFile2, execFileSync as execFileSync4 } from "child_process";
4143
+ import { execFile as execFile2, execFileSync as execFileSync5 } from "child_process";
4113
4144
  var CMUX_TIMEOUT = 15e3;
4114
4145
  var CmuxTimeoutError = class extends Error {
4115
4146
  constructor(cmd) {
@@ -4478,14 +4509,14 @@ function createCmuxDriver() {
4478
4509
  }
4479
4510
 
4480
4511
  // packages/workspaces/dist/notifiers/cmux.js
4481
- import { execFileSync as execFileSync5, execSync as execSync7 } from "child_process";
4512
+ import { execFileSync as execFileSync6, execSync as execSync7 } from "child_process";
4482
4513
 
4483
4514
  // packages/workspaces/dist/workspaces/obsidian.js
4484
- import fs12 from "fs/promises";
4485
- import { existsSync as existsSync8 } from "fs";
4486
- import path15 from "path";
4515
+ import fs14 from "fs/promises";
4516
+ import { existsSync as existsSync9 } from "fs";
4517
+ import path16 from "path";
4487
4518
 
4488
- // packages/workspaces/dist/cmux/events-bridge.js
4519
+ // packages/workspaces/dist/cmux-daemon/events-bridge.js
4489
4520
  import { spawn as nodeSpawn2 } from "child_process";
4490
4521
  function deriveRunState(eventName) {
4491
4522
  switch (eventName) {
@@ -4619,7 +4650,7 @@ var CmuxEventsBridge = class {
4619
4650
  }
4620
4651
  };
4621
4652
 
4622
- // packages/workspaces/dist/cmux/daemon-cmux.js
4653
+ // packages/workspaces/dist/cmux-daemon/daemon-cmux.js
4623
4654
  var DaemonCmux = class {
4624
4655
  driver;
4625
4656
  constructor(driver) {
@@ -4675,13 +4706,13 @@ var DaemonCmux = class {
4675
4706
  // packages/workspaces/dist/crew-pane.js
4676
4707
  import net from "net";
4677
4708
 
4678
- // packages/cli/src/control/squadrantd.ts
4709
+ // packages/cli/src/squadrantd.ts
4679
4710
  var SELF_PATH2 = fileURLToPath3(import.meta.url);
4680
- var CLI_BIN = join13(dirname5(SELF_PATH2), "index.js");
4681
- var DAEMON_SOCK = join13(homedir8(), ".config", "squadrant", "squadrant.sock");
4711
+ var CLI_BIN = join15(dirname5(SELF_PATH2), "index.js");
4712
+ var DAEMON_SOCK = join15(homedir10(), ".config", "squadrant", "squadrant.sock");
4682
4713
  function readPkgVersion() {
4683
4714
  try {
4684
- const pkgPath = join13(dirname5(SELF_PATH2), "..", "package.json");
4715
+ const pkgPath = join15(dirname5(SELF_PATH2), "..", "package.json");
4685
4716
  return JSON.parse(readFileSync9(pkgPath, "utf-8")).version ?? "unknown";
4686
4717
  } catch {
4687
4718
  return "unknown";
@@ -4763,7 +4794,7 @@ function startSquadrantd(opts = {}) {
4763
4794
  (r) => r.mode === "interactive" && !TERMINAL_STATES.has(r.state) && r.cwd === hook.cwd
4764
4795
  );
4765
4796
  },
4766
- cursorFile: join13(stateRoot, "cmux-events.seq"),
4797
+ cursorFile: join15(stateRoot, "cmux-events.seq"),
4767
4798
  log
4768
4799
  });
4769
4800
  ctx.codexDriver = codexDriver;
@@ -4802,7 +4833,7 @@ if (process.argv[1] && process.argv[1].endsWith("squadrantd.js")) {
4802
4833
  process.stdout.write("squadrantd: launchd-managed daemon entry (no CLI args). Use `squadrant` for commands.\n");
4803
4834
  process.exit(0);
4804
4835
  }
4805
- const sock = join13(homedir8(), ".config", "squadrant", "squadrant.sock");
4836
+ const sock = join15(homedir10(), ".config", "squadrant", "squadrant.sock");
4806
4837
  if (await isDaemonSocketLive(sock)) {
4807
4838
  process.stderr.write(`[squadrantd] refusing to start: a live daemon already owns ${sock}
4808
4839
  `);