@sideboard-ai/core 0.1.279 → 0.1.280

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.cjs CHANGED
@@ -25270,6 +25270,51 @@ var init_land = __esm({
25270
25270
  }
25271
25271
  });
25272
25272
 
25273
+ // src/diff/read-worktree-tail.ts
25274
+ function readWorktreeFileTail(worktreePath, relativePath, maxBytes = WORKTREE_TAIL_BYTES) {
25275
+ if (!relativePath || relativePath.includes("..") || relativePath.startsWith("/")) {
25276
+ throw new Error("Invalid path");
25277
+ }
25278
+ const abs = (0, import_node_path57.join)(worktreePath, relativePath);
25279
+ const fd = (0, import_node_fs60.openSync)(abs, "r");
25280
+ try {
25281
+ const st = (0, import_node_fs60.fstatSync)(fd);
25282
+ if (!st.isFile()) throw new Error(`Not a file: ${relativePath}`);
25283
+ const size = st.size;
25284
+ const start = Math.max(0, size - maxBytes);
25285
+ const length = size - start;
25286
+ const buf = Buffer.alloc(length);
25287
+ if (length > 0) (0, import_node_fs60.readSync)(fd, buf, 0, length, start);
25288
+ if (buf.subarray(0, Math.min(buf.length, 8e3)).includes(0)) {
25289
+ return {
25290
+ path: relativePath,
25291
+ content: `(binary file, ${size} bytes)`,
25292
+ truncated: false,
25293
+ binary: true,
25294
+ encoding: "utf8"
25295
+ };
25296
+ }
25297
+ let content = buf.toString("utf8");
25298
+ const truncated = start > 0;
25299
+ if (truncated) {
25300
+ const nl = content.indexOf("\n");
25301
+ if (nl >= 0) content = content.slice(nl + 1);
25302
+ }
25303
+ return { path: relativePath, content, truncated, binary: false, encoding: "utf8" };
25304
+ } finally {
25305
+ (0, import_node_fs60.closeSync)(fd);
25306
+ }
25307
+ }
25308
+ var import_node_fs60, import_node_path57, WORKTREE_TAIL_BYTES;
25309
+ var init_read_worktree_tail = __esm({
25310
+ "src/diff/read-worktree-tail.ts"() {
25311
+ "use strict";
25312
+ import_node_fs60 = require("fs");
25313
+ import_node_path57 = require("path");
25314
+ WORKTREE_TAIL_BYTES = 2e5;
25315
+ }
25316
+ });
25317
+
25273
25318
  // src/skills/bundled/long-running.ts
25274
25319
  var LONG_RUNNING_SKILL_COMMAND, LONG_RUNNING_SKILL_NAME, BUNDLED_LONG_RUNNING_PATH, LONG_RUNNING_SKILL_DESCRIPTION, LONG_RUNNING_SKILL_BODY;
25275
25320
  var init_long_running = __esm({
@@ -25414,7 +25459,7 @@ function parseFrontmatter(content) {
25414
25459
  }
25415
25460
  function readSkill(skillMd, source) {
25416
25461
  try {
25417
- const content = (0, import_node_fs60.readFileSync)(skillMd, "utf8");
25462
+ const content = (0, import_node_fs61.readFileSync)(skillMd, "utf8");
25418
25463
  const { name: fmName, description } = parseFrontmatter(content);
25419
25464
  const dirName = skillMd.split("/").slice(-2, -1)[0] || "skill";
25420
25465
  const name = fmName || dirName;
@@ -25433,19 +25478,19 @@ function readSkill(skillMd, source) {
25433
25478
  }
25434
25479
  }
25435
25480
  function scanSkillsDir(dir, source, out) {
25436
- if (!(0, import_node_fs60.existsSync)(dir)) return;
25481
+ if (!(0, import_node_fs61.existsSync)(dir)) return;
25437
25482
  let entries;
25438
25483
  try {
25439
- entries = (0, import_node_fs60.readdirSync)(dir);
25484
+ entries = (0, import_node_fs61.readdirSync)(dir);
25440
25485
  } catch {
25441
25486
  return;
25442
25487
  }
25443
25488
  for (const entry of entries) {
25444
25489
  if (entry.startsWith(".")) continue;
25445
- const skillMd = (0, import_node_path57.join)(dir, entry, "SKILL.md");
25446
- if (!(0, import_node_fs60.existsSync)(skillMd)) continue;
25490
+ const skillMd = (0, import_node_path58.join)(dir, entry, "SKILL.md");
25491
+ if (!(0, import_node_fs61.existsSync)(skillMd)) continue;
25447
25492
  try {
25448
- if (!(0, import_node_fs60.statSync)(skillMd).isFile()) continue;
25493
+ if (!(0, import_node_fs61.statSync)(skillMd).isFile()) continue;
25449
25494
  } catch {
25450
25495
  continue;
25451
25496
  }
@@ -25454,24 +25499,24 @@ function scanSkillsDir(dir, source, out) {
25454
25499
  }
25455
25500
  }
25456
25501
  function scanClaudePluginSkills(pluginsRoot, out) {
25457
- if (!(0, import_node_fs60.existsSync)(pluginsRoot)) return;
25502
+ if (!(0, import_node_fs61.existsSync)(pluginsRoot)) return;
25458
25503
  const walk = (dir, depth, lookingForSkillsDir) => {
25459
25504
  if (depth > 7) return;
25460
25505
  let entries;
25461
25506
  try {
25462
- entries = (0, import_node_fs60.readdirSync)(dir);
25507
+ entries = (0, import_node_fs61.readdirSync)(dir);
25463
25508
  } catch {
25464
25509
  return;
25465
25510
  }
25466
25511
  if (lookingForSkillsDir && entries.includes("SKILL.md")) {
25467
- const skill = readSkill((0, import_node_path57.join)(dir, "SKILL.md"), "cli");
25512
+ const skill = readSkill((0, import_node_path58.join)(dir, "SKILL.md"), "cli");
25468
25513
  if (skill) out.push(skill);
25469
25514
  }
25470
25515
  for (const entry of entries) {
25471
25516
  if (entry === "node_modules" || entry === ".git") continue;
25472
- const full = (0, import_node_path57.join)(dir, entry);
25517
+ const full = (0, import_node_path58.join)(dir, entry);
25473
25518
  try {
25474
- if (!(0, import_node_fs60.statSync)(full).isDirectory()) continue;
25519
+ if (!(0, import_node_fs61.statSync)(full).isDirectory()) continue;
25475
25520
  } catch {
25476
25521
  continue;
25477
25522
  }
@@ -25489,17 +25534,17 @@ function discoverSkills(worktreePath) {
25489
25534
  const home = (0, import_node_os17.homedir)();
25490
25535
  const collected = [];
25491
25536
  for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
25492
- scanSkillsDir((0, import_node_path57.join)(worktreePath, rel), "workspace", collected);
25537
+ scanSkillsDir((0, import_node_path58.join)(worktreePath, rel), "workspace", collected);
25493
25538
  }
25494
25539
  for (const abs of [
25495
- (0, import_node_path57.join)(home, ".claude/skills"),
25496
- (0, import_node_path57.join)(home, ".cursor/skills"),
25497
- (0, import_node_path57.join)(home, ".sideboard/skills"),
25498
- (0, import_node_path57.join)(home, ".brightsy/skills")
25540
+ (0, import_node_path58.join)(home, ".claude/skills"),
25541
+ (0, import_node_path58.join)(home, ".cursor/skills"),
25542
+ (0, import_node_path58.join)(home, ".sideboard/skills"),
25543
+ (0, import_node_path58.join)(home, ".brightsy/skills")
25499
25544
  ]) {
25500
25545
  scanSkillsDir(abs, "user", collected);
25501
25546
  }
25502
- scanClaudePluginSkills((0, import_node_path57.join)(home, ".claude/plugins"), collected);
25547
+ scanClaudePluginSkills((0, import_node_path58.join)(home, ".claude/plugins"), collected);
25503
25548
  collected.push(...bundledSkills());
25504
25549
  const rank = {
25505
25550
  workspace: 0,
@@ -25525,7 +25570,7 @@ function readSkillBody(skillPath, maxChars = 12e3) {
25525
25570
  \u2026(truncated)` : body;
25526
25571
  }
25527
25572
  }
25528
- const raw = (0, import_node_fs60.readFileSync)(skillPath, "utf8");
25573
+ const raw = (0, import_node_fs61.readFileSync)(skillPath, "utf8");
25529
25574
  if (raw.startsWith("---")) {
25530
25575
  const end = raw.indexOf("\n---", 3);
25531
25576
  if (end >= 0) {
@@ -25539,13 +25584,13 @@ function readSkillBody(skillPath, maxChars = 12e3) {
25539
25584
 
25540
25585
  \u2026(truncated)` : raw;
25541
25586
  }
25542
- var import_node_fs60, import_node_os17, import_node_path57, BUNDLED_SKILL_PREFIX;
25587
+ var import_node_fs61, import_node_os17, import_node_path58, BUNDLED_SKILL_PREFIX;
25543
25588
  var init_discover = __esm({
25544
25589
  "src/skills/discover.ts"() {
25545
25590
  "use strict";
25546
- import_node_fs60 = require("fs");
25591
+ import_node_fs61 = require("fs");
25547
25592
  import_node_os17 = require("os");
25548
- import_node_path57 = require("path");
25593
+ import_node_path58 = require("path");
25549
25594
  init_long_running();
25550
25595
  BUNDLED_SKILL_PREFIX = "bundled:";
25551
25596
  }
@@ -25700,7 +25745,7 @@ function compiledModuleDir() {
25700
25745
  try {
25701
25746
  const url = import_meta5.url;
25702
25747
  if (typeof url === "string" && url.length > 0) {
25703
- return (0, import_node_path58.dirname)((0, import_node_url5.fileURLToPath)(url));
25748
+ return (0, import_node_path59.dirname)((0, import_node_url5.fileURLToPath)(url));
25704
25749
  }
25705
25750
  } catch {
25706
25751
  }
@@ -25708,8 +25753,8 @@ function compiledModuleDir() {
25708
25753
  }
25709
25754
  function detachedJobScriptIn(dir) {
25710
25755
  for (const name of DETACHED_JOB_FILENAMES) {
25711
- const script = (0, import_node_path58.join)(dir, "scripts", name);
25712
- if ((0, import_node_fs61.existsSync)(script)) return script;
25756
+ const script = (0, import_node_path59.join)(dir, "scripts", name);
25757
+ if ((0, import_node_fs62.existsSync)(script)) return script;
25713
25758
  }
25714
25759
  return null;
25715
25760
  }
@@ -25726,7 +25771,7 @@ function resolveDetachedJobScript() {
25726
25771
  for (let i = 0; i < 8; i++) {
25727
25772
  const candidate = detachedJobScriptIn(dir);
25728
25773
  if (candidate) return candidate;
25729
- const parent = (0, import_node_path58.dirname)(dir);
25774
+ const parent = (0, import_node_path59.dirname)(dir);
25730
25775
  if (parent === dir) break;
25731
25776
  dir = parent;
25732
25777
  }
@@ -25737,12 +25782,12 @@ function formatDetachedJobInvoke(scriptPath) {
25737
25782
  if (resolved) return `node ${JSON.stringify(resolved)}`;
25738
25783
  return "node scripts/detached-job.cjs";
25739
25784
  }
25740
- var import_node_fs61, import_node_path58, import_node_url5, import_meta5, DETACHED_JOB_FILENAMES;
25785
+ var import_node_fs62, import_node_path59, import_node_url5, import_meta5, DETACHED_JOB_FILENAMES;
25741
25786
  var init_detached_job_path = __esm({
25742
25787
  "src/skills/detached-job-path.ts"() {
25743
25788
  "use strict";
25744
- import_node_fs61 = require("fs");
25745
- import_node_path58 = require("path");
25789
+ import_node_fs62 = require("fs");
25790
+ import_node_path59 = require("path");
25746
25791
  import_node_url5 = require("url");
25747
25792
  init_packaged_runtime();
25748
25793
  import_meta5 = {};
@@ -25958,9 +26003,9 @@ function formatPrGateDirective() {
25958
26003
  }
25959
26004
  function formatProcessGuideDirective(opts) {
25960
26005
  const worktree = opts?.worktreePath?.trim();
25961
- const hasGraphSkill = !!worktree && (0, import_node_fs62.existsSync)((0, import_node_path59.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
25962
- const hasReviewSkill = !!worktree && (0, import_node_fs62.existsSync)((0, import_node_path59.join)(worktree, ".claude/skills/review/SKILL.md"));
25963
- const hasInstallSkill = !!worktree && (0, import_node_fs62.existsSync)((0, import_node_path59.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
26006
+ const hasGraphSkill = !!worktree && (0, import_node_fs63.existsSync)((0, import_node_path60.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
26007
+ const hasReviewSkill = !!worktree && (0, import_node_fs63.existsSync)((0, import_node_path60.join)(worktree, ".claude/skills/review/SKILL.md"));
26008
+ const hasInstallSkill = !!worktree && (0, import_node_fs63.existsSync)((0, import_node_path60.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
25964
26009
  return [
25965
26010
  "Process guides (recurring work only):",
25966
26011
  hasGraphSkill ? "- Migrations, ports, batch fixes, and other fan-out: follow `.claude/skills/graph-engineering/SKILL.md` (`/graph-engineering`). Judge first; state on disk; grow the rulebook; do not patch around it." : null,
@@ -25999,12 +26044,12 @@ function formatArtifactDirective() {
25999
26044
  function formatUiReminder() {
26000
26045
  return "Sideboard UI: markdown table is enough to read data; present_schema if they ask to edit/filter (even after markdown); present_files for the file manager. html fence or present_artifact, not both for the same document. type=log appends (same artifact_id, new lines only). ask_user only for a real multiple-choice (not hellos, \u201Cwhat next?\u201D, or after a review) \u2014 reply in chat. ask_user wakes the parent orchestrator; notify_orchestrator if blocked without a picker. Do not say artifacts/CMS UI are unavailable. Dev / preview: run_dev_script (same as the Dev button; pass name \u2014 several scripts can run at once) returns {url, port, preview} (SIDEBOARD_PORT \u2014 never guess :3000). preview=url \u2192 open url; preview=window \u2192 Electron window is the app, url is renderer/HMR only. list_run_scripts active[].url if already running; get_run_log for that script\u2019s Run-tab terminal; stop_dev_script to stop one.";
26001
26046
  }
26002
- var import_node_fs62, import_node_path59, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
26047
+ var import_node_fs63, import_node_path60, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
26003
26048
  var init_instructions = __esm({
26004
26049
  "src/agents/instructions.ts"() {
26005
26050
  "use strict";
26006
- import_node_fs62 = require("fs");
26007
- import_node_path59 = require("path");
26051
+ import_node_fs63 = require("fs");
26052
+ import_node_path60 = require("path");
26008
26053
  init_git_auth_mode();
26009
26054
  init_branch_prefix();
26010
26055
  init_worktree_labels();
@@ -26306,40 +26351,40 @@ __export(plan_file_exports, {
26306
26351
  writePlanFile: () => writePlanFile
26307
26352
  });
26308
26353
  function ensureAttachmentsGitignore(worktreePath) {
26309
- const gitignoreAbs = (0, import_node_path60.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
26310
- if ((0, import_node_fs63.existsSync)(gitignoreAbs)) return;
26311
- (0, import_node_fs63.mkdirSync)((0, import_node_path60.dirname)(gitignoreAbs), { recursive: true });
26312
- (0, import_node_fs63.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
26354
+ const gitignoreAbs = (0, import_node_path61.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
26355
+ if ((0, import_node_fs64.existsSync)(gitignoreAbs)) return;
26356
+ (0, import_node_fs64.mkdirSync)((0, import_node_path61.dirname)(gitignoreAbs), { recursive: true });
26357
+ (0, import_node_fs64.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
26313
26358
  }
26314
26359
  function planFileAbs(worktreePath) {
26315
- return (0, import_node_path60.join)(worktreePath, PLAN_FILE_REL);
26360
+ return (0, import_node_path61.join)(worktreePath, PLAN_FILE_REL);
26316
26361
  }
26317
26362
  function readTextIfPresent2(abs) {
26318
- if (!(0, import_node_fs63.existsSync)(abs)) return null;
26363
+ if (!(0, import_node_fs64.existsSync)(abs)) return null;
26319
26364
  try {
26320
- const content = (0, import_node_fs63.readFileSync)(abs, "utf8");
26365
+ const content = (0, import_node_fs64.readFileSync)(abs, "utf8");
26321
26366
  return content.trim() ? content : null;
26322
26367
  } catch {
26323
26368
  return null;
26324
26369
  }
26325
26370
  }
26326
26371
  function readPlanFile(worktreePath) {
26327
- return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path60.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path60.join)(worktreePath, LEGACY_PLAN_FILE_REL));
26372
+ return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path61.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path61.join)(worktreePath, LEGACY_PLAN_FILE_REL));
26328
26373
  }
26329
26374
  function writePlanFile(worktreePath, content) {
26330
26375
  ensureAttachmentsGitignore(worktreePath);
26331
26376
  const abs = planFileAbs(worktreePath);
26332
- (0, import_node_fs63.mkdirSync)((0, import_node_path60.dirname)(abs), { recursive: true });
26377
+ (0, import_node_fs64.mkdirSync)((0, import_node_path61.dirname)(abs), { recursive: true });
26333
26378
  const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
26334
- (0, import_node_fs63.writeFileSync)(abs, body, "utf8");
26379
+ (0, import_node_fs64.writeFileSync)(abs, body, "utf8");
26335
26380
  return PLAN_FILE_REL;
26336
26381
  }
26337
- var import_node_fs63, import_node_path60;
26382
+ var import_node_fs64, import_node_path61;
26338
26383
  var init_plan_file = __esm({
26339
26384
  "src/plan/plan-file.ts"() {
26340
26385
  "use strict";
26341
- import_node_fs63 = require("fs");
26342
- import_node_path60 = require("path");
26386
+ import_node_fs64 = require("fs");
26387
+ import_node_path61 = require("path");
26343
26388
  init_workspace_scratch();
26344
26389
  init_plan_present();
26345
26390
  init_plan_present();
@@ -26390,9 +26435,9 @@ function recoverFinishedCursorRun(opts) {
26390
26435
  return best;
26391
26436
  }
26392
26437
  function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
26393
- if (!(0, import_node_fs64.existsSync)(runsPath)) return null;
26438
+ if (!(0, import_node_fs65.existsSync)(runsPath)) return null;
26394
26439
  try {
26395
- const lines = (0, import_node_fs64.readFileSync)(runsPath, "utf8").split("\n");
26440
+ const lines = (0, import_node_fs65.readFileSync)(runsPath, "utf8").split("\n");
26396
26441
  let best = null;
26397
26442
  for (const line of lines) {
26398
26443
  const trimmed = line.trim();
@@ -26418,11 +26463,11 @@ function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
26418
26463
  return null;
26419
26464
  }
26420
26465
  }
26421
- var import_node_fs64;
26466
+ var import_node_fs65;
26422
26467
  var init_cursor_recover = __esm({
26423
26468
  "src/agents/cursor-recover.ts"() {
26424
26469
  "use strict";
26425
- import_node_fs64 = require("fs");
26470
+ import_node_fs65 = require("fs");
26426
26471
  init_cursor_store();
26427
26472
  }
26428
26473
  });
@@ -26545,7 +26590,7 @@ async function startOrchestration(opts) {
26545
26590
  }
26546
26591
  return updated;
26547
26592
  }
26548
- var import_node_events, import_node_crypto15, import_node_fs65, LIVE_TURN_SPAWN_GRACE_MS, RUN_SCRIPT_DESKTOP_ADOPT_MS, STALE_AGENT_PID_WAIT_MS, LIGHT_RECONCILE_THROTTLE_MS, Orchestrator, singleton;
26593
+ var import_node_events, import_node_crypto15, import_node_fs66, LIVE_TURN_SPAWN_GRACE_MS, RUN_SCRIPT_DESKTOP_ADOPT_MS, STALE_AGENT_PID_WAIT_MS, LIGHT_RECONCILE_THROTTLE_MS, Orchestrator, singleton;
26549
26594
  var init_orchestrator = __esm({
26550
26595
  "src/orchestrator/orchestrator.ts"() {
26551
26596
  "use strict";
@@ -26554,7 +26599,7 @@ var init_orchestrator = __esm({
26554
26599
  init_task_state();
26555
26600
  init_wait_for_turn();
26556
26601
  import_node_crypto15 = require("crypto");
26557
- import_node_fs65 = require("fs");
26602
+ import_node_fs66 = require("fs");
26558
26603
  init_error_detail();
26559
26604
  init_run();
26560
26605
  init_stale_lock();
@@ -26603,6 +26648,7 @@ var init_orchestrator = __esm({
26603
26648
  init_stack_layers();
26604
26649
  init_land();
26605
26650
  init_diff();
26651
+ init_read_worktree_tail();
26606
26652
  init_discover();
26607
26653
  init_expand();
26608
26654
  init_consume_attachments();
@@ -26736,7 +26782,7 @@ var init_orchestrator = __esm({
26736
26782
  this.lightReconcileAt.set(repoPath, Date.now());
26737
26783
  for (const thread of listThreads()) {
26738
26784
  if (isGlobalThread(thread) || thread.repoPath !== repoPath) continue;
26739
- if (!(0, import_node_fs65.existsSync)(thread.worktreePath)) {
26785
+ if (!(0, import_node_fs66.existsSync)(thread.worktreePath)) {
26740
26786
  setStatus(thread.id, "broken", "Worktree missing on disk");
26741
26787
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
26742
26788
  }
@@ -26765,7 +26811,7 @@ var init_orchestrator = __esm({
26765
26811
  }
26766
26812
  continue;
26767
26813
  }
26768
- if (!(0, import_node_fs65.existsSync)(thread.worktreePath)) {
26814
+ if (!(0, import_node_fs66.existsSync)(thread.worktreePath)) {
26769
26815
  setStatus(thread.id, "broken", "Worktree missing on disk");
26770
26816
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
26771
26817
  continue;
@@ -28712,12 +28758,12 @@ var init_orchestrator = __esm({
28712
28758
  return "missing";
28713
28759
  }
28714
28760
  }
28715
- async readFile(threadRef, relativePath) {
28761
+ async readFile(threadRef, relativePath, tail) {
28716
28762
  const thread = this.requireThread(threadRef);
28717
28763
  if (relativePath.includes("..") || relativePath.startsWith("/")) {
28718
28764
  throw new Error("Invalid path");
28719
28765
  }
28720
- return readWorktreeFile(thread.worktreePath, relativePath);
28766
+ return (tail ? readWorktreeFileTail : readWorktreeFile)(thread.worktreePath, relativePath);
28721
28767
  }
28722
28768
  async readFileForUpload(threadRef, relativePath) {
28723
28769
  const thread = this.requireThread(threadRef);
@@ -29226,7 +29272,7 @@ var init_orchestrator = __esm({
29226
29272
  this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
29227
29273
  return restored2;
29228
29274
  }
29229
- if (!(0, import_node_fs65.existsSync)(thread.worktreePath)) {
29275
+ if (!(0, import_node_fs66.existsSync)(thread.worktreePath)) {
29230
29276
  if (isCowboyThread(thread) || isPrimaryCheckoutThread(thread)) {
29231
29277
  throw new Error(
29232
29278
  `Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
@@ -33149,22 +33195,22 @@ var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
33149
33195
  var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
33150
33196
 
33151
33197
  // src/agents/tool-result-clip.ts
33152
- var import_node_fs66 = require("fs");
33153
- var import_node_path61 = require("path");
33198
+ var import_node_fs67 = require("fs");
33199
+ var import_node_path62 = require("path");
33154
33200
  init_workspace_scratch();
33155
33201
  init_error_detail();
33156
33202
  function spillPath(cwd, prefix) {
33157
33203
  const stamp = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
33158
33204
  const safe = prefix.replace(/[^a-zA-Z0-9_-]+/g, "-").slice(0, 40) || "tool";
33159
- return (0, import_node_path61.join)(cwd, CLI_DIR, `${safe}-${stamp}.txt`);
33205
+ return (0, import_node_path62.join)(cwd, CLI_DIR, `${safe}-${stamp}.txt`);
33160
33206
  }
33161
33207
  function spillToolResultToCli(content, opts) {
33162
33208
  const cwd = opts?.cwd?.trim();
33163
33209
  if (!cwd || !content) return null;
33164
33210
  const file = spillPath(cwd, opts?.prefix ?? "tool-result");
33165
33211
  try {
33166
- (0, import_node_fs66.mkdirSync)((0, import_node_path61.join)(cwd, CLI_DIR), { recursive: true });
33167
- (0, import_node_fs66.writeFileSync)(file, content, "utf8");
33212
+ (0, import_node_fs67.mkdirSync)((0, import_node_path62.join)(cwd, CLI_DIR), { recursive: true });
33213
+ (0, import_node_fs67.writeFileSync)(file, content, "utf8");
33168
33214
  return file;
33169
33215
  } catch {
33170
33216
  return null;
@@ -33232,7 +33278,7 @@ function createClippedMcpServer() {
33232
33278
  // src/mcp/server.ts
33233
33279
  var import_zod8 = require("zod");
33234
33280
  var import_node_crypto20 = require("crypto");
33235
- var import_node_path65 = require("path");
33281
+ var import_node_path66 = require("path");
33236
33282
  init_orchestrator();
33237
33283
  init_task_state();
33238
33284
  init_worktree();
@@ -34530,7 +34576,7 @@ function registerScheduleTools(server) {
34530
34576
 
34531
34577
  // src/agent-rpc/handlers.ts
34532
34578
  var import_node_crypto18 = require("crypto");
34533
- var import_node_path62 = require("path");
34579
+ var import_node_path63 = require("path");
34534
34580
  init_wait_for_job();
34535
34581
  init_wait_for_turn();
34536
34582
  init_protocol();
@@ -34560,7 +34606,7 @@ function invalidParams(message) {
34560
34606
  function jobCwd(rec) {
34561
34607
  const raw = str4(rec.cwd).trim();
34562
34608
  if (!raw) throw invalidParams("cwd is required");
34563
- if (!(0, import_node_path62.isAbsolute)(raw)) throw invalidParams("cwd must be an absolute path");
34609
+ if (!(0, import_node_path63.isAbsolute)(raw)) throw invalidParams("cwd must be an absolute path");
34564
34610
  return raw;
34565
34611
  }
34566
34612
  async function handleRuntimePing(_params, _ctx) {
@@ -34692,27 +34738,27 @@ init_gh_errors();
34692
34738
  init_git_auth_mode();
34693
34739
 
34694
34740
  // src/board/load-home-board.ts
34695
- var import_node_fs68 = require("fs");
34696
- var import_node_path64 = require("path");
34741
+ var import_node_fs69 = require("fs");
34742
+ var import_node_path65 = require("path");
34697
34743
  init_worktree();
34698
34744
  init_paths();
34699
34745
 
34700
34746
  // src/board/board-pins.ts
34701
34747
  var import_node_crypto19 = require("crypto");
34702
- var import_node_fs67 = require("fs");
34703
- var import_node_path63 = require("path");
34748
+ var import_node_fs68 = require("fs");
34749
+ var import_node_path64 = require("path");
34704
34750
  init_paths();
34705
34751
  init_home_board();
34706
34752
  var FILE = "home-board-pins.json";
34707
34753
  var VERSION = 1;
34708
34754
  function pinsFile() {
34709
- return (0, import_node_path63.join)(appDataDir(), FILE);
34755
+ return (0, import_node_path64.join)(appDataDir(), FILE);
34710
34756
  }
34711
34757
  function readDisk() {
34712
34758
  const path2 = pinsFile();
34713
- if (!(0, import_node_fs67.existsSync)(path2)) return [];
34759
+ if (!(0, import_node_fs68.existsSync)(path2)) return [];
34714
34760
  try {
34715
- const raw = JSON.parse((0, import_node_fs67.readFileSync)(path2, "utf8"));
34761
+ const raw = JSON.parse((0, import_node_fs68.readFileSync)(path2, "utf8"));
34716
34762
  if (raw?.version !== VERSION || !Array.isArray(raw.items)) return [];
34717
34763
  return raw.items.filter((item) => item?.id && item.kind && item.ref);
34718
34764
  } catch {
@@ -34720,8 +34766,8 @@ function readDisk() {
34720
34766
  }
34721
34767
  }
34722
34768
  function writeDisk(items) {
34723
- (0, import_node_fs67.mkdirSync)(appDataDir(), { recursive: true });
34724
- (0, import_node_fs67.writeFileSync)(pinsFile(), JSON.stringify({ version: VERSION, items }, null, 2), "utf8");
34769
+ (0, import_node_fs68.mkdirSync)(appDataDir(), { recursive: true });
34770
+ (0, import_node_fs68.writeFileSync)(pinsFile(), JSON.stringify({ version: VERSION, items }, null, 2), "utf8");
34725
34771
  }
34726
34772
  function listBoardPins() {
34727
34773
  return readDisk();
@@ -34773,7 +34819,7 @@ function replaceBoardPins(items) {
34773
34819
  }
34774
34820
  function clearBoardPins() {
34775
34821
  try {
34776
- (0, import_node_fs67.unlinkSync)(pinsFile());
34822
+ (0, import_node_fs68.unlinkSync)(pinsFile());
34777
34823
  } catch {
34778
34824
  }
34779
34825
  }
@@ -34790,7 +34836,7 @@ function homeBoardWorkspaceKey(workspaces) {
34790
34836
  return workspaces.map((w) => w.path).filter(Boolean).sort().join("\n");
34791
34837
  }
34792
34838
  function cacheFile() {
34793
- return (0, import_node_path64.join)(appDataDir(), "home-board-cache.json");
34839
+ return (0, import_node_path65.join)(appDataDir(), "home-board-cache.json");
34794
34840
  }
34795
34841
  function emptyInputs() {
34796
34842
  return {
@@ -34816,9 +34862,9 @@ function shouldCacheHomeBoardInputs(inputs) {
34816
34862
  }
34817
34863
  function readDiskCache() {
34818
34864
  const path2 = cacheFile();
34819
- if (!(0, import_node_fs68.existsSync)(path2)) return null;
34865
+ if (!(0, import_node_fs69.existsSync)(path2)) return null;
34820
34866
  try {
34821
- const raw = JSON.parse((0, import_node_fs68.readFileSync)(path2, "utf8"));
34867
+ const raw = JSON.parse((0, import_node_fs69.readFileSync)(path2, "utf8"));
34822
34868
  if (raw?.version !== CACHE_VERSION || typeof raw.fetchedAt !== "number") {
34823
34869
  return null;
34824
34870
  }
@@ -34832,14 +34878,14 @@ function readDiskCache() {
34832
34878
  }
34833
34879
  function writeDiskCache(entry) {
34834
34880
  try {
34835
- (0, import_node_fs68.mkdirSync)(appDataDir(), { recursive: true });
34836
- (0, import_node_fs68.writeFileSync)(cacheFile(), JSON.stringify(entry), "utf8");
34881
+ (0, import_node_fs69.mkdirSync)(appDataDir(), { recursive: true });
34882
+ (0, import_node_fs69.writeFileSync)(cacheFile(), JSON.stringify(entry), "utf8");
34837
34883
  } catch {
34838
34884
  }
34839
34885
  }
34840
34886
  function deleteDiskCache() {
34841
34887
  try {
34842
- (0, import_node_fs68.unlinkSync)(cacheFile());
34888
+ (0, import_node_fs69.unlinkSync)(cacheFile());
34843
34889
  } catch {
34844
34890
  }
34845
34891
  }
@@ -35204,7 +35250,7 @@ async function startMcpServer() {
35204
35250
  async () => {
35205
35251
  const threads = orch.getThreads(true);
35206
35252
  const lines = threads.map((t) => {
35207
- const repo = t.repoPath === GLOBAL_WORKSPACE_ID2 ? "Orchestration" : (0, import_node_path65.basename)(t.repoPath) || t.repoPath;
35253
+ const repo = t.repoPath === GLOBAL_WORKSPACE_ID2 ? "Orchestration" : (0, import_node_path66.basename)(t.repoPath) || t.repoPath;
35208
35254
  const live = orch.threadLooksLive(t) ? readTurnLive(t.id) : null;
35209
35255
  const parent = t.parentThreadId ? ` parent:${t.parentThreadId.slice(0, 8)}` : "";
35210
35256
  const preview = lastMessagePreview(t.messages, 80);
@@ -36885,7 +36931,7 @@ init_user_mcp_config();
36885
36931
  init_orch_mcp_isolation();
36886
36932
 
36887
36933
  // src/slack/workspaces.ts
36888
- var import_node_path66 = require("path");
36934
+ var import_node_path67 = require("path");
36889
36935
  init_paths();
36890
36936
  init_secure_file();
36891
36937
 
@@ -36930,7 +36976,7 @@ async function slackAuthTest(token) {
36930
36976
 
36931
36977
  // src/slack/workspaces.ts
36932
36978
  function storePath2() {
36933
- return (0, import_node_path66.join)(appDataDir(), "slack-workspaces.json");
36979
+ return (0, import_node_path67.join)(appDataDir(), "slack-workspaces.json");
36934
36980
  }
36935
36981
  function readStore2() {
36936
36982
  try {
@@ -37543,19 +37589,19 @@ function connectSession(ws, opts, log) {
37543
37589
  }
37544
37590
 
37545
37591
  // src/slack/reply-target.ts
37546
- var import_node_fs69 = require("fs");
37547
- var import_node_path67 = require("path");
37592
+ var import_node_fs70 = require("fs");
37593
+ var import_node_path68 = require("path");
37548
37594
  init_paths();
37549
37595
  init_private_file();
37550
37596
  init_secure_file();
37551
37597
  function storePath3() {
37552
- return (0, import_node_path67.join)(appDataDir(), "slack-reply-to.json");
37598
+ return (0, import_node_path68.join)(appDataDir(), "slack-reply-to.json");
37553
37599
  }
37554
37600
  function readStore3() {
37555
37601
  const path2 = storePath3();
37556
- if (!(0, import_node_fs69.existsSync)(path2)) return {};
37602
+ if (!(0, import_node_fs70.existsSync)(path2)) return {};
37557
37603
  try {
37558
- const parsed = isSecureFileEncrypted(path2) ? readSecureJson(path2) : JSON.parse((0, import_node_fs69.readFileSync)(path2, "utf8"));
37604
+ const parsed = isSecureFileEncrypted(path2) ? readSecureJson(path2) : JSON.parse((0, import_node_fs70.readFileSync)(path2, "utf8"));
37559
37605
  return parsed?.targets && typeof parsed.targets === "object" ? parsed.targets : {};
37560
37606
  } catch {
37561
37607
  return {};
@@ -40302,7 +40348,7 @@ function handleRemoteInbound(text6, opts) {
40302
40348
  }
40303
40349
 
40304
40350
  // src/remote/phone-board-sync.ts
40305
- var import_node_path68 = require("path");
40351
+ var import_node_path69 = require("path");
40306
40352
  var import_chokidar = require("chokidar");
40307
40353
  init_orchestrator();
40308
40354
  init_paths();
@@ -40341,7 +40387,7 @@ function subscribePhoneBoard(notify) {
40341
40387
  threads.on("error", () => void 0);
40342
40388
  const data = (0, import_chokidar.watch)(appDataDir(), { ignoreInitial: true, depth: 0 });
40343
40389
  const onData = (changed) => {
40344
- const name = (0, import_node_path68.basename)(changed);
40390
+ const name = (0, import_node_path69.basename)(changed);
40345
40391
  if (name !== "workspaces.json" && name !== "removed-workspaces.json") return;
40346
40392
  notify();
40347
40393
  };
@@ -40637,14 +40683,14 @@ var import_node_crypto27 = require("crypto");
40637
40683
 
40638
40684
  // src/relay/accounts.ts
40639
40685
  var import_node_crypto26 = require("crypto");
40640
- var import_node_fs70 = require("fs");
40686
+ var import_node_fs71 = require("fs");
40641
40687
  var import_node_module7 = require("module");
40642
- var import_node_path69 = require("path");
40688
+ var import_node_path70 = require("path");
40643
40689
  var GITHUB_ACCOUNT_ISSUER = "https://github.com";
40644
40690
  var RELAY_DEVICE_CAP = 3;
40645
40691
  function thisModuleFile3() {
40646
40692
  const cjsFile = typeof __filename !== "undefined" ? __filename : "";
40647
- return cjsFile || process.argv[1] || (0, import_node_path69.join)(process.cwd(), "package.json");
40693
+ return cjsFile || process.argv[1] || (0, import_node_path70.join)(process.cwd(), "package.json");
40648
40694
  }
40649
40695
  function openDatabase(filePath) {
40650
40696
  const req = (0, import_node_module7.createRequire)(thisModuleFile3());
@@ -40681,8 +40727,8 @@ function assertRelayAccountsDurable(filePath) {
40681
40727
  if (process.env.SIDEBOARD_RELAY_ACCOUNTS_EPHEMERAL === "1") return;
40682
40728
  if (process.env.NODE_ENV !== "production") return;
40683
40729
  if (process.platform !== "linux") return;
40684
- const dir = (0, import_node_fs70.realpathSync)((0, import_node_path69.dirname)(filePath));
40685
- const mounts = (0, import_node_fs70.readFileSync)("/proc/mounts", "utf8");
40730
+ const dir = (0, import_node_fs71.realpathSync)((0, import_node_path70.dirname)(filePath));
40731
+ const mounts = (0, import_node_fs71.readFileSync)("/proc/mounts", "utf8");
40686
40732
  const point = longestMountPoint(dir, mounts);
40687
40733
  if (point === "/") {
40688
40734
  throw new Error(
@@ -40693,7 +40739,7 @@ function assertRelayAccountsDurable(filePath) {
40693
40739
  var RelayAccountStore = class {
40694
40740
  db;
40695
40741
  constructor(filePath) {
40696
- (0, import_node_fs70.mkdirSync)((0, import_node_path69.dirname)(filePath), { recursive: true });
40742
+ (0, import_node_fs71.mkdirSync)((0, import_node_path70.dirname)(filePath), { recursive: true });
40697
40743
  this.db = openDatabase(filePath);
40698
40744
  this.db.exec(`
40699
40745
  CREATE TABLE IF NOT EXISTS accounts (
@@ -41678,9 +41724,9 @@ var import_node_http5 = require("http");
41678
41724
  var import_ws6 = require("ws");
41679
41725
 
41680
41726
  // src/relay/static.ts
41681
- var import_node_fs71 = require("fs");
41727
+ var import_node_fs72 = require("fs");
41682
41728
  var import_promises = require("fs/promises");
41683
- var import_node_path70 = __toESM(require("path"), 1);
41729
+ var import_node_path71 = __toESM(require("path"), 1);
41684
41730
  var TYPES = {
41685
41731
  ".css": "text/css; charset=utf-8",
41686
41732
  ".html": "text/html; charset=utf-8",
@@ -41711,9 +41757,9 @@ function resolveStaticPath(root, requestUrl) {
41711
41757
  return null;
41712
41758
  }
41713
41759
  if (!pathname.startsWith("/") || pathname.includes("\0")) return null;
41714
- const rootResolved = import_node_path70.default.resolve(root);
41715
- const candidate = import_node_path70.default.resolve(rootResolved, `.${pathname}`);
41716
- if (candidate !== rootResolved && !candidate.startsWith(rootResolved + import_node_path70.default.sep)) {
41760
+ const rootResolved = import_node_path71.default.resolve(root);
41761
+ const candidate = import_node_path71.default.resolve(rootResolved, `.${pathname}`);
41762
+ if (candidate !== rootResolved && !candidate.startsWith(rootResolved + import_node_path71.default.sep)) {
41717
41763
  return null;
41718
41764
  }
41719
41765
  return candidate;
@@ -41727,7 +41773,7 @@ async function fileSize(file) {
41727
41773
  }
41728
41774
  }
41729
41775
  function sendFile(req, res, file, size) {
41730
- const ext = import_node_path70.default.extname(file).toLowerCase();
41776
+ const ext = import_node_path71.default.extname(file).toLowerCase();
41731
41777
  res.writeHead(200, {
41732
41778
  "Content-Type": TYPES[ext] ?? "application/octet-stream",
41733
41779
  "Content-Length": size,
@@ -41737,7 +41783,7 @@ function sendFile(req, res, file, size) {
41737
41783
  res.end();
41738
41784
  return true;
41739
41785
  }
41740
- (0, import_node_fs71.createReadStream)(file).pipe(res);
41786
+ (0, import_node_fs72.createReadStream)(file).pipe(res);
41741
41787
  return true;
41742
41788
  }
41743
41789
  async function tryServeStatic(req, res, root) {
@@ -41746,7 +41792,7 @@ async function tryServeStatic(req, res, root) {
41746
41792
  if (!candidate) return false;
41747
41793
  const direct = await fileSize(candidate);
41748
41794
  if (direct != null) return sendFile(req, res, candidate, direct);
41749
- const asIndex = import_node_path70.default.join(candidate, "index.html");
41795
+ const asIndex = import_node_path71.default.join(candidate, "index.html");
41750
41796
  const indexSize = await fileSize(asIndex);
41751
41797
  if (indexSize != null) return sendFile(req, res, asIndex, indexSize);
41752
41798
  return false;
@@ -42107,8 +42153,8 @@ async function startRelayServer(opts) {
42107
42153
  }
42108
42154
 
42109
42155
  // src/slack/outbound-watch.ts
42110
- var import_node_fs72 = require("fs");
42111
- var import_node_path71 = require("path");
42156
+ var import_node_fs73 = require("fs");
42157
+ var import_node_path72 = require("path");
42112
42158
  init_paths();
42113
42159
  init_private_file();
42114
42160
  init_secure_file();
@@ -42121,7 +42167,7 @@ var POLL_INTERVAL_MS = 12e3;
42121
42167
  var lastPollMs = 0;
42122
42168
  var nameCache = /* @__PURE__ */ new Map();
42123
42169
  function storePath4() {
42124
- return (0, import_node_path71.join)(appDataDir(), "slack-outbound-watch.json");
42170
+ return (0, import_node_path72.join)(appDataDir(), "slack-outbound-watch.json");
42125
42171
  }
42126
42172
  function watchId(teamId, channelId, ts) {
42127
42173
  return `${teamId}:${channelId}:${ts}`;
@@ -42134,9 +42180,9 @@ function tsNewer(a, b) {
42134
42180
  }
42135
42181
  function readStore4() {
42136
42182
  const path2 = storePath4();
42137
- if (!(0, import_node_fs72.existsSync)(path2)) return [];
42183
+ if (!(0, import_node_fs73.existsSync)(path2)) return [];
42138
42184
  try {
42139
- const parsed = isSecureFileEncrypted(path2) ? readSecureJson(path2) : JSON.parse((0, import_node_fs72.readFileSync)(path2, "utf8"));
42185
+ const parsed = isSecureFileEncrypted(path2) ? readSecureJson(path2) : JSON.parse((0, import_node_fs73.readFileSync)(path2, "utf8"));
42140
42186
  return Array.isArray(parsed?.watches) ? parsed.watches : [];
42141
42187
  } catch {
42142
42188
  return [];