@sideboard-ai/core 0.1.324 → 0.1.326

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 (83) hide show
  1. package/dist/{abletime-CU2UPMJF.js → abletime-RDHYSZL2.js} +5 -4
  2. package/dist/{abletime-5ZY3ZUUO.js → abletime-RYYFGKMU.js} +6 -5
  3. package/dist/{abletime-oauth-7EOSBEFM.js → abletime-oauth-OYGS2DAU.js} +3 -3
  4. package/dist/{abletime-oauth-4TTCR3CT.js → abletime-oauth-QR2QDVMK.js} +3 -3
  5. package/dist/{abletime-rest-KOKE7V4B.js → abletime-rest-BKYKNPTC.js} +3 -3
  6. package/dist/{abletime-rest-3TG4G7LW.js → abletime-rest-QDPTWNS4.js} +3 -3
  7. package/dist/agents/claude-runner.cjs +59 -22
  8. package/dist/agents/claude-runner.js +39 -16
  9. package/dist/agents/cursor-runner.cjs +97 -32
  10. package/dist/agents/cursor-runner.js +74 -24
  11. package/dist/{agents-YK65UDLT.js → agents-HANWZNI6.js} +9 -8
  12. package/dist/{agents-LUSTCMDN.js → agents-QO7GKBYT.js} +12 -11
  13. package/dist/{app-settings-XIF4EC4K.js → app-settings-RXBH7KY4.js} +1 -1
  14. package/dist/{app-settings-I5HM5RMP.js → app-settings-TUVLZNDE.js} +1 -1
  15. package/dist/{chunk-7MQSYPAY.js → chunk-2EOLWHXH.js} +206 -188
  16. package/dist/{chunk-QOS4465Y.js → chunk-3Q4XNYHY.js} +1 -1
  17. package/dist/{chunk-RR4WCGNB.js → chunk-46FECFZU.js} +18 -15
  18. package/dist/{chunk-5GDJSFCT.js → chunk-4H5MWZ6J.js} +2 -2
  19. package/dist/{chunk-EQ52JR3Q.js → chunk-5MXLDDYF.js} +1 -1
  20. package/dist/{chunk-NCHOTN3C.js → chunk-5YCKATG6.js} +4 -3
  21. package/dist/{chunk-ROOZDDFA.js → chunk-75RPUXJS.js} +7 -8
  22. package/dist/{chunk-INBUV7HY.js → chunk-B244TJWC.js} +2 -2
  23. package/dist/{chunk-JH5SMVM5.js → chunk-BBNWKL4I.js} +268 -235
  24. package/dist/{chunk-ODH3XHMI.js → chunk-C7HUCBX7.js} +5 -5
  25. package/dist/{chunk-OIHRC2ZJ.js → chunk-D744HOI5.js} +25 -3
  26. package/dist/chunk-DBKHL7NC.js +214 -0
  27. package/dist/chunk-F6GE7V3Q.js +216 -0
  28. package/dist/{chunk-JE3JLHMO.js → chunk-FWVUGLBG.js} +3 -3
  29. package/dist/{chunk-DF5BM5OY.js → chunk-GP3RLZ6A.js} +207 -186
  30. package/dist/{chunk-FR3SAYUL.js → chunk-JM2TGOHP.js} +5 -5
  31. package/dist/{chunk-Y3WREIPQ.js → chunk-K7M7MIWL.js} +12 -210
  32. package/dist/{chunk-FUFNMUNR.js → chunk-KECHK3ZT.js} +7 -8
  33. package/dist/{chunk-EKU7FQVG.js → chunk-KXRF6RNL.js} +2 -2
  34. package/dist/chunk-LRHUBGEM.js +1259 -0
  35. package/dist/{chunk-MZIZTSR2.js → chunk-MAW7DIG7.js} +2 -2
  36. package/dist/{chunk-ZHGMRBSC.js → chunk-NURZOXGN.js} +4 -4
  37. package/dist/{chunk-QIC2JXHW.js → chunk-OOXRMTU6.js} +1 -1
  38. package/dist/{chunk-5XNT6BCG.js → chunk-OPXEJJBM.js} +1 -1
  39. package/dist/chunk-OYRN356W.js +80 -0
  40. package/dist/{chunk-7PVT73H6.js → chunk-PB6HW7SA.js} +12 -210
  41. package/dist/{chunk-B4CDSSRN.js → chunk-Q3FHTGIW.js} +2 -0
  42. package/dist/{chunk-7D5QIU3N.js → chunk-QG4CYRA3.js} +301 -268
  43. package/dist/{chunk-EJ66LEKH.js → chunk-QPSKQP6E.js} +24 -3
  44. package/dist/{chunk-Q3YJZPQI.js → chunk-RZVOX2MT.js} +3 -3
  45. package/dist/chunk-SO7G6O24.js +1445 -0
  46. package/dist/{chunk-YDUHLWI5.js → chunk-SUZOPJZC.js} +21 -7
  47. package/dist/chunk-TMCK5TLA.js +25 -0
  48. package/dist/chunk-W3ZLE4PO.js +77 -0
  49. package/dist/chunk-WUCAVIIP.js +28 -0
  50. package/dist/{chunk-BYUCNIXK.js → chunk-XLVLMQKN.js} +13 -9
  51. package/dist/{chunk-ZIRQZUZY.js → chunk-YGVGXQA7.js} +3 -3
  52. package/dist/{chunk-NXUN4U5P.js → chunk-YWQF7WAG.js} +2 -2
  53. package/dist/{chunk-IFWGG2M2.js → chunk-ZSHS46V5.js} +2 -0
  54. package/dist/{chunk-74OPNF7U.js → chunk-ZUAYA57W.js} +2 -2
  55. package/dist/{conductor-SPZOTC7W.js → conductor-4GVTHUUB.js} +7 -7
  56. package/dist/{conductor-JFABMXDA.js → conductor-TGWI6ETZ.js} +6 -6
  57. package/dist/{coordinator-prompt-K66RGNWK.js → coordinator-prompt-3E6SIDTM.js} +4 -4
  58. package/dist/{coordinator-prompt-Z6UFHFDH.js → coordinator-prompt-WEYJREV6.js} +4 -4
  59. package/dist/{cursor-recover-TEBFKAZ4.js → cursor-recover-7F46PAJ5.js} +1 -1
  60. package/dist/{cursor-recover-OWPQUHFH.js → cursor-recover-BDIAZIE3.js} +1 -1
  61. package/dist/{global-workspace-A6UO6PJV.js → global-workspace-FPDZKUPF.js} +4 -4
  62. package/dist/{global-workspace-RHEO55B4.js → global-workspace-UIEXAG2B.js} +4 -4
  63. package/dist/index.cjs +21094 -20840
  64. package/dist/index.d.cts +36 -17
  65. package/dist/index.d.ts +36 -17
  66. package/dist/index.js +343 -1678
  67. package/dist/linear-6S7MK5YK.js +69 -0
  68. package/dist/linear-Z2T4KUAQ.js +67 -0
  69. package/dist/linear-list-A37WLUBO.js +6 -0
  70. package/dist/linear-list-Q4M7AZO2.js +8 -0
  71. package/dist/mcp/run-stdio.cjs +15903 -15640
  72. package/dist/mcp/run-stdio.js +67 -1247
  73. package/dist/{optional-cli-RMMS5L6F.js → optional-cli-AANBL4U5.js} +3 -3
  74. package/dist/{optional-cli-Y3Z3GIPZ.js → optional-cli-CA4LL322.js} +4 -4
  75. package/dist/{orchestrator-7VTAUY24.js → orchestrator-7FVDBE7Y.js} +15 -13
  76. package/dist/{orchestrator-2O6OJQLX.js → orchestrator-RQXRZW7Z.js} +14 -12
  77. package/dist/{thread-store-3F7GR64A.js → thread-store-4ZN3DS2W.js} +1 -1
  78. package/dist/{thread-store-JRSL4HQY.js → thread-store-IC4BQXDW.js} +1 -1
  79. package/dist/{workspaces-NRKEXOYR.js → workspaces-LEW4UP56.js} +4 -4
  80. package/dist/{workspaces-42E6AGXD.js → workspaces-QONNLHNR.js} +4 -4
  81. package/dist/{worktree-ZDA2UJ7C.js → worktree-6GIONDQO.js} +3 -3
  82. package/dist/{worktree-4NGXCCUO.js → worktree-KFEJAQ2H.js} +3 -3
  83. package/package.json +1 -1
@@ -1,18 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import {
4
- titleFromPrompt
5
- } from "./chunk-LX5R5JOR.js";
6
- import {
7
- formatOptionalServicesDirectiveForTurn,
8
- formatOptionalServicesReminderForTurn
9
- } from "./chunk-QOS4465Y.js";
10
- import {
11
- extractPresentedPlan,
12
- isPresentPlanToolName,
13
- readPlanFile,
14
- writePlanFile
15
- } from "./chunk-4GK32AYX.js";
16
3
  import {
17
4
  releaseCaffeinateHoldForThread
18
5
  } from "./chunk-DC3VZXMA.js";
@@ -27,7 +14,7 @@ import {
27
14
  parseSessionQuotaResetAt,
28
15
  planModeTurnInstruction,
29
16
  resolveQuotaFallbackAgent
30
- } from "./chunk-7D5QIU3N.js";
17
+ } from "./chunk-QG4CYRA3.js";
31
18
  import {
32
19
  applyWorktreePkgCacheEnv,
33
20
  askBlockStillWaiting,
@@ -65,7 +52,7 @@ import {
65
52
  worktreeDevProcessKey,
66
53
  worktreeRunProcessKey,
67
54
  worktreeSetupProcessKey
68
- } from "./chunk-BYUCNIXK.js";
55
+ } from "./chunk-XLVLMQKN.js";
69
56
  import {
70
57
  applyAgentEvent,
71
58
  clipAgentEventForPaint,
@@ -92,7 +79,20 @@ import {
92
79
  summarizeTurnStderr,
93
80
  toolDescription,
94
81
  turnFailChatText
95
- } from "./chunk-EQ52JR3Q.js";
82
+ } from "./chunk-5MXLDDYF.js";
83
+ import {
84
+ titleFromPrompt
85
+ } from "./chunk-LX5R5JOR.js";
86
+ import {
87
+ formatOptionalServicesDirectiveForTurn,
88
+ formatOptionalServicesReminderForTurn
89
+ } from "./chunk-3Q4XNYHY.js";
90
+ import {
91
+ extractPresentedPlan,
92
+ isPresentPlanToolName,
93
+ readPlanFile,
94
+ writePlanFile
95
+ } from "./chunk-4GK32AYX.js";
96
96
  import {
97
97
  SLACK_REPLY_FORMATTING,
98
98
  addWorkspace,
@@ -117,7 +117,7 @@ import {
117
117
  stageAbsolutePathsAsAttachments,
118
118
  stageBuffersAsAttachments,
119
119
  syncWorkspacesFromThreads
120
- } from "./chunk-ZIRQZUZY.js";
120
+ } from "./chunk-YGVGXQA7.js";
121
121
  import {
122
122
  addPrStackLayer,
123
123
  allocateTeamSlug,
@@ -166,7 +166,10 @@ import {
166
166
  resolveRepoRoot,
167
167
  switchWorktreeBranch,
168
168
  withRepoGitLock
169
- } from "./chunk-ROOZDDFA.js";
169
+ } from "./chunk-75RPUXJS.js";
170
+ import {
171
+ issueActivityKind
172
+ } from "./chunk-OYRN356W.js";
170
173
  import {
171
174
  clearStaleIndexLocks,
172
175
  enrichPathWithNpmGlobalBin,
@@ -204,13 +207,14 @@ import {
204
207
  resolveNewThreadOptions,
205
208
  resolveOrchestratorDefaults,
206
209
  resolveViewerProfileForRepo,
210
+ subtractUsage,
207
211
  sumUsageList,
208
212
  updateAdvancedSettings,
209
213
  updateAppEnvironment,
210
214
  usageOnLimit,
211
215
  withTurnScopedCost,
212
216
  writeViewerContext
213
- } from "./chunk-OIHRC2ZJ.js";
217
+ } from "./chunk-D744HOI5.js";
214
218
  import {
215
219
  writePrivateFile
216
220
  } from "./chunk-NSTQ6QKD.js";
@@ -251,7 +255,7 @@ import {
251
255
  worktreeNameFromPath,
252
256
  worktreeSlugForTicket,
253
257
  writeThread
254
- } from "./chunk-B4CDSSRN.js";
258
+ } from "./chunk-Q3FHTGIW.js";
255
259
  import {
256
260
  normalizeThinkingEffort
257
261
  } from "./chunk-KGZBYWZ3.js";
@@ -312,9 +316,50 @@ import { randomUUID as randomUUID5 } from "crypto";
312
316
  import { existsSync as existsSync14 } from "fs";
313
317
 
314
318
  // src/agents/spawn.ts
319
+ import { rmSync } from "fs";
315
320
  import { createInterface } from "readline";
316
321
  import { execa } from "execa";
317
322
 
323
+ // src/orchestrator/agent-pid.ts
324
+ import { execFileSync } from "child_process";
325
+ function pidStartedAt(pid) {
326
+ if (!Number.isFinite(pid) || pid <= 0 || process.platform === "win32") return null;
327
+ try {
328
+ const out = execFileSync("ps", ["-o", "lstart=", "-p", String(pid)], {
329
+ encoding: "utf8",
330
+ timeout: 1e3,
331
+ stdio: ["ignore", "pipe", "ignore"]
332
+ }).trim();
333
+ return out || null;
334
+ } catch {
335
+ return null;
336
+ }
337
+ }
338
+ function isSameAgentProcess(pid, startedAt, alive) {
339
+ if (!alive) return false;
340
+ if (!startedAt) return true;
341
+ const now = pidStartedAt(pid);
342
+ if (!now) return true;
343
+ return now === startedAt;
344
+ }
345
+ function isPidAlive(pid) {
346
+ if (!Number.isFinite(pid) || pid <= 0) return false;
347
+ try {
348
+ process.kill(pid, 0);
349
+ return true;
350
+ } catch {
351
+ return false;
352
+ }
353
+ }
354
+ async function waitForPidExit(pid, timeoutMs) {
355
+ const start = Date.now();
356
+ while (isPidAlive(pid)) {
357
+ if (Date.now() - start >= timeoutMs) return false;
358
+ await new Promise((r) => setTimeout(r, 80));
359
+ }
360
+ return true;
361
+ }
362
+
318
363
  // src/agents/turn-trace.ts
319
364
  import { appendFileSync } from "fs";
320
365
  import { join } from "path";
@@ -519,9 +564,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
519
564
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
520
565
  );
521
566
  }
522
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-A6UO6PJV.js");
567
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-FPDZKUPF.js");
523
568
  if (isGlobalThread2(thread)) {
524
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-Z6UFHFDH.js");
569
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-WEYJREV6.js");
525
570
  ensureGlobalCoordinatorCwd2(
526
571
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
527
572
  );
@@ -596,8 +641,13 @@ async function spawnAgentTurn(thread, input, onEvent) {
596
641
  cwd: cmd.cwd,
597
642
  env,
598
643
  reject: false,
644
+ // readline consumes both streams. The default buffer (100 MB) keeps a
645
+ // second copy and SIGTERMs the agent when a long stream-json turn exceeds it.
646
+ buffer: false,
599
647
  stdout: "pipe",
600
648
  stderr: "pipe",
649
+ // Own process group so Stop can signal MCP servers and shells the CLI spawned.
650
+ detached: process.platform !== "win32",
601
651
  // Claude stream-json turns write a user message to stdin; otherwise ignore
602
652
  // so Claude doesn't wait ~3s for an empty pipe.
603
653
  stdin: cmd.stdin != null ? "pipe" : "ignore"
@@ -611,50 +661,66 @@ async function spawnAgentTurn(thread, input, onEvent) {
611
661
  let assistantText = "";
612
662
  let parts = [];
613
663
  let usage = null;
664
+ const usageByMessageId = /* @__PURE__ */ new Map();
614
665
  const outbound = createAgentStreamCoalescer(onEvent);
615
666
  const consume = (stream, kind) => {
616
667
  if (!stream) return;
617
668
  const rl = createInterface({ input: stream, crlfDelay: Infinity });
618
669
  rl.on("line", (line) => {
619
- if (kind === "stderr") {
620
- outbound.push({ type: "stderr", data: line });
621
- return;
622
- }
623
- let events = normalizeParseResult(adapter.parseEvent(line));
624
- if (thread.agent === "brightsy" && kind === "stdout" && isBrightsyNdjsonLine(line)) {
625
- const dumped = events.some(
626
- (e) => e.type === "stdout" && isBrightsyNdjsonLine(e.data)
627
- );
628
- if (events.length === 0 || dumped) {
629
- events = normalizeParseResult(parseBrightsyCliLine(line));
630
- }
631
- }
632
- for (const event of events) {
633
- let parsed = event;
634
- if (parsed.type === "session_id") {
635
- sessionId = parsed.data;
636
- outbound.push(parsed);
637
- continue;
670
+ try {
671
+ if (kind === "stderr") {
672
+ outbound.push({ type: "stderr", data: line });
673
+ return;
638
674
  }
639
- if (parsed.type === "usage") {
640
- const data = parsed.scope === "turn" ? withTurnScopedCost(parsed.data, thread.messages) : parsed.data;
641
- usage = applyTurnUsage(usage, data, parsed.scope ?? "request");
642
- outbound.push({ ...parsed, data });
643
- continue;
675
+ let events = normalizeParseResult(adapter.parseEvent(line));
676
+ if (thread.agent === "brightsy" && kind === "stdout" && isBrightsyNdjsonLine(line)) {
677
+ const dumped = events.some(
678
+ (e) => e.type === "stdout" && isBrightsyNdjsonLine(e.data)
679
+ );
680
+ if (events.length === 0 || dumped) {
681
+ events = normalizeParseResult(parseBrightsyCliLine(line));
682
+ }
644
683
  }
645
- if (parsed.type === "stdout") {
646
- if (thread.agent === "brightsy" && isBrightsyNdjsonLine(parsed.data)) {
684
+ for (const event of events) {
685
+ let parsed = event;
686
+ if (parsed.type === "session_id") {
687
+ sessionId = parsed.data;
688
+ outbound.push(parsed);
647
689
  continue;
648
690
  }
649
- const folded = foldDuplicateStdout(textSoFar(parts, parsed.parentId), parsed.data);
650
- if (folded == null) continue;
651
- if (folded !== parsed.data) parsed = { ...parsed, data: folded };
652
- }
653
- parts = applyAgentEvent(parts, parsed);
654
- if (parsed.type === "stdout") {
655
- assistantText = partsToAssistantText(parts);
691
+ if (parsed.type === "usage") {
692
+ const data = parsed.scope === "turn" ? withTurnScopedCost(parsed.data, thread.messages) : parsed.data;
693
+ let base = usage;
694
+ const messageId = parsed.messageId;
695
+ if (messageId && parsed.scope !== "turn") {
696
+ const prev = usageByMessageId.get(messageId);
697
+ if (prev) base = subtractUsage(base, prev);
698
+ usageByMessageId.set(messageId, data);
699
+ }
700
+ usage = applyTurnUsage(base, data, parsed.scope ?? "request");
701
+ outbound.push({ ...parsed, data });
702
+ continue;
703
+ }
704
+ if (parsed.type === "stdout") {
705
+ if (thread.agent === "brightsy" && isBrightsyNdjsonLine(parsed.data)) {
706
+ continue;
707
+ }
708
+ const folded = foldDuplicateStdout(textSoFar(parts, parsed.parentId), parsed.data);
709
+ if (folded == null) continue;
710
+ if (folded !== parsed.data) parsed = { ...parsed, data: folded };
711
+ }
712
+ parts = applyAgentEvent(parts, parsed);
713
+ if (parsed.type === "stdout") {
714
+ assistantText = partsToAssistantText(parts);
715
+ }
716
+ outbound.push(parsed);
656
717
  }
657
- outbound.push(parsed);
718
+ } catch (err) {
719
+ const detail = err instanceof Error ? err.message : String(err);
720
+ outbound.push({
721
+ type: "stderr",
722
+ data: `sideboard: failed to parse agent output: ${detail}`
723
+ });
658
724
  }
659
725
  });
660
726
  };
@@ -668,14 +734,39 @@ async function spawnAgentTurn(thread, input, onEvent) {
668
734
  const exitCode = thread.agent === "brightsy" ? adjustBrightsyTurnExit(result.exitCode ?? null, text3) : result.exitCode ?? null;
669
735
  onEvent({ type: "exit", data: exitCode });
670
736
  return { exitCode, sessionId, assistantText: text3, parts: finalized, usage };
737
+ }).finally(() => {
738
+ for (const dir of cmd.cleanupDirs ?? []) {
739
+ try {
740
+ rmSync(dir, { recursive: true, force: true });
741
+ } catch {
742
+ }
743
+ }
671
744
  });
672
745
  return {
673
746
  pid: child.pid,
674
747
  kill: () => {
675
- try {
676
- child.kill("SIGTERM");
677
- } catch {
678
- }
748
+ const pid = child.pid;
749
+ const startedAt = typeof pid === "number" && pid > 0 ? pidStartedAt(pid) : null;
750
+ const signal = (sig) => {
751
+ if (sig === "SIGKILL" && typeof pid === "number" && pid > 0 && !isSameAgentProcess(pid, startedAt, isPidAlive(pid))) {
752
+ return;
753
+ }
754
+ if (pid && process.platform !== "win32") {
755
+ try {
756
+ process.kill(-pid, sig);
757
+ return;
758
+ } catch {
759
+ }
760
+ }
761
+ try {
762
+ child.kill(sig);
763
+ } catch {
764
+ }
765
+ };
766
+ signal("SIGTERM");
767
+ const timer = setTimeout(() => signal("SIGKILL"), 5e3);
768
+ timer.unref?.();
769
+ child.once("exit", () => clearTimeout(timer));
679
770
  },
680
771
  done
681
772
  };
@@ -2771,7 +2862,7 @@ async function createThread(input, _onSetupLine) {
2771
2862
  });
2772
2863
  await requireAgent(resolved.agent);
2773
2864
  if (input.cowboy) {
2774
- const { cowboyModeEnabled } = await import("./app-settings-I5HM5RMP.js");
2865
+ const { cowboyModeEnabled } = await import("./app-settings-TUVLZNDE.js");
2775
2866
  if (!cowboyModeEnabled()) {
2776
2867
  throw new Error(
2777
2868
  "Cowboy mode is off. Enable it in Settings \u2192 Advanced."
@@ -2830,7 +2921,7 @@ async function createThread(input, _onSetupLine) {
2830
2921
  let sourceIsFork = false;
2831
2922
  if (!input.cowboy && sourceType === "branch" && (!sourceRef || sourceRef === "HEAD" || sourceRef === "default")) {
2832
2923
  if (isAbleTimeConnected() && getIssueSource() === "abletime") {
2833
- const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-5ZY3ZUUO.js");
2924
+ const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-RYYFGKMU.js");
2834
2925
  const task = await ensureAbleTimeTask({
2835
2926
  title: title?.trim() || "Untitled work",
2836
2927
  description: input.prompt?.trim() || void 0
@@ -3615,14 +3706,14 @@ function createQuotaFailoverChat(from, fallbackAgent, limitText, opts) {
3615
3706
  }
3616
3707
 
3617
3708
  // src/threads/adopt.ts
3618
- import { execFileSync } from "child_process";
3709
+ import { execFileSync as execFileSync2 } from "child_process";
3619
3710
  import {
3620
3711
  copyFileSync,
3621
3712
  existsSync as existsSync7,
3622
3713
  mkdtempSync,
3623
3714
  readdirSync as readdirSync2,
3624
3715
  readFileSync as readFileSync5,
3625
- rmSync
3716
+ rmSync as rmSync2
3626
3717
  } from "fs";
3627
3718
  import { tmpdir } from "os";
3628
3719
  import { join as join7 } from "path";
@@ -3712,7 +3803,7 @@ async function adoptThread(input) {
3712
3803
  messages: input.messages ?? []
3713
3804
  });
3714
3805
  writeThread(thread);
3715
- const { addWorkspace: addWorkspace2 } = await import("./workspaces-NRKEXOYR.js");
3806
+ const { addWorkspace: addWorkspace2 } = await import("./workspaces-LEW4UP56.js");
3716
3807
  await addWorkspace2(repoPath);
3717
3808
  const { ensureWorktreeSideboardIgnored } = await import("./worktree-exclude-P5NJODWP.js");
3718
3809
  await ensureWorktreeSideboardIgnored(input.worktreePath);
@@ -3806,7 +3897,7 @@ function listConductorWorkspaces() {
3806
3897
  db.close();
3807
3898
  }
3808
3899
  } finally {
3809
- rmSync(tmp, { recursive: true, force: true });
3900
+ rmSync2(tmp, { recursive: true, force: true });
3810
3901
  }
3811
3902
  }
3812
3903
  function importConductorWorkspace(workspaceId) {
@@ -3879,7 +3970,7 @@ function importConductorWorkspace(workspaceId) {
3879
3970
  }
3880
3971
  let repoPath = worktreePath;
3881
3972
  try {
3882
- repoPath = execFileSync("git", ["rev-parse", "--show-toplevel"], {
3973
+ repoPath = execFileSync2("git", ["rev-parse", "--show-toplevel"], {
3883
3974
  cwd: worktreePath,
3884
3975
  encoding: "utf8"
3885
3976
  }).trim();
@@ -3902,7 +3993,7 @@ function importConductorWorkspace(workspaceId) {
3902
3993
  db.close();
3903
3994
  }
3904
3995
  } finally {
3905
- rmSync(tmp, { recursive: true, force: true });
3996
+ rmSync2(tmp, { recursive: true, force: true });
3906
3997
  }
3907
3998
  }
3908
3999
  async function importConductorWorkspaceAsync(workspaceId) {
@@ -6259,78 +6350,6 @@ import { z as z2 } from "zod";
6259
6350
 
6260
6351
  // src/mcp/issue-list.ts
6261
6352
  import { z } from "zod";
6262
-
6263
- // src/integrations/issue-since.ts
6264
- var ISSUE_SINCE_ERROR = "updatedSince must be an ISO datetime, YYYY-MM-DD, or relative time (yesterday, 2d, 3 hours ago)";
6265
- var DATE_ONLY_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
6266
- var DATE_TIME_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;
6267
- var RELATIVE_RE = /^(\d+)\s*(hours?|hrs?|h|days?|d|weeks?|wks?|w)(?:\s+ago)?$/i;
6268
- function startOfLocalDay(date) {
6269
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6270
- }
6271
- function addLocalDays(date, days) {
6272
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);
6273
- }
6274
- function parseIssueSince(input, now = /* @__PURE__ */ new Date()) {
6275
- const raw = input.trim();
6276
- if (!raw) throw new Error(ISSUE_SINCE_ERROR);
6277
- const dateOnly = raw.match(DATE_ONLY_RE);
6278
- if (dateOnly) {
6279
- const year = Number(dateOnly[1]);
6280
- const month = Number(dateOnly[2]);
6281
- const day = Number(dateOnly[3]);
6282
- const local = new Date(year, month - 1, day);
6283
- if (local.getFullYear() !== year || local.getMonth() !== month - 1 || local.getDate() !== day) {
6284
- throw new Error(ISSUE_SINCE_ERROR);
6285
- }
6286
- return startOfLocalDay(local).toISOString();
6287
- }
6288
- if (DATE_TIME_RE.test(raw)) {
6289
- const ms = Date.parse(raw);
6290
- if (!Number.isFinite(ms)) throw new Error(ISSUE_SINCE_ERROR);
6291
- return new Date(ms).toISOString();
6292
- }
6293
- const lower = raw.toLowerCase();
6294
- if (lower === "today") return startOfLocalDay(now).toISOString();
6295
- if (lower === "yesterday") return addLocalDays(startOfLocalDay(now), -1).toISOString();
6296
- if (lower === "last week" || lower === "lastweek") {
6297
- return addLocalDays(startOfLocalDay(now), -7).toISOString();
6298
- }
6299
- const relative = lower.match(RELATIVE_RE);
6300
- if (relative) {
6301
- const n = Number(relative[1]);
6302
- if (!Number.isInteger(n) || n < 1) throw new Error(ISSUE_SINCE_ERROR);
6303
- const unit = relative[2];
6304
- if (unit.startsWith("h")) return new Date(now.getTime() - n * 36e5).toISOString();
6305
- if (unit.startsWith("w")) return addLocalDays(startOfLocalDay(now), -7 * n).toISOString();
6306
- return addLocalDays(startOfLocalDay(now), -n).toISOString();
6307
- }
6308
- throw new Error(ISSUE_SINCE_ERROR);
6309
- }
6310
- function formatGitHubSearchUpdatedSince(iso) {
6311
- return iso.replace(/\.\d{3}Z$/, "Z");
6312
- }
6313
- function issueMatchesUpdatedSince(issue, sinceIso) {
6314
- const ts = issue.updatedAt || issue.createdAt;
6315
- if (!ts) return false;
6316
- const value = Date.parse(ts);
6317
- const since = Date.parse(sinceIso);
6318
- return Number.isFinite(value) && Number.isFinite(since) && value >= since;
6319
- }
6320
- var ISSUE_COMMENT_PREVIEW_CHARS = 240;
6321
- function previewIssueCommentBody(body) {
6322
- const flat = body.replace(/\s+/g, " ").trim();
6323
- if (flat.length <= ISSUE_COMMENT_PREVIEW_CHARS) return flat;
6324
- return `${flat.slice(0, ISSUE_COMMENT_PREVIEW_CHARS - 1).trimEnd()}\u2026`;
6325
- }
6326
- function issueActivityKind(issue, sinceIso) {
6327
- const created = issue.createdAt ? Date.parse(issue.createdAt) : Number.NaN;
6328
- const since = Date.parse(sinceIso);
6329
- if (Number.isFinite(created) && Number.isFinite(since) && created >= since) return "created";
6330
- return "updated";
6331
- }
6332
-
6333
- // src/mcp/issue-list.ts
6334
6353
  var MCP_ISSUE_LIST_DEFAULT_LIMIT = 40;
6335
6354
  var MCP_ISSUE_LIST_MAX_LIMIT = 250;
6336
6355
  function clampMcpIssueLimit(limit) {
@@ -7122,7 +7141,7 @@ function formatScheduledPrompt(name, prompt) {
7122
7141
  ${prompt}`;
7123
7142
  }
7124
7143
  async function defaultDeps() {
7125
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-2O6OJQLX.js");
7144
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-RQXRZW7Z.js");
7126
7145
  const orch = getOrchestrator2();
7127
7146
  return {
7128
7147
  findThread: (id) => findThreadByRef(id),
@@ -7268,23 +7287,6 @@ function armSchedules() {
7268
7287
  // src/orchestrator/orchestrator.ts
7269
7288
  var LIVE_TURN_SPAWN_GRACE_MS = 15e3;
7270
7289
  var RUN_SCRIPT_DESKTOP_ADOPT_MS = 2e4;
7271
- function isPidAlive(pid) {
7272
- if (!Number.isFinite(pid) || pid <= 0) return false;
7273
- try {
7274
- process.kill(pid, 0);
7275
- return true;
7276
- } catch {
7277
- return false;
7278
- }
7279
- }
7280
- async function waitForPidExit(pid, timeoutMs) {
7281
- const start = Date.now();
7282
- while (isPidAlive(pid)) {
7283
- if (Date.now() - start >= timeoutMs) return false;
7284
- await new Promise((r) => setTimeout(r, 80));
7285
- }
7286
- return true;
7287
- }
7288
7290
  function resolveOrchChildFollowUp(requested) {
7289
7291
  if (requested === "steer" || requested === "queue") return requested;
7290
7292
  return followUpBehavior();
@@ -7490,7 +7492,7 @@ var Orchestrator = class {
7490
7492
  orphans: orphans.map((o) => ({ path: o.path, repoPath: o.repoPath }))
7491
7493
  });
7492
7494
  }
7493
- const { autoCleanupOrphansEnabled } = await import("./app-settings-I5HM5RMP.js");
7495
+ const { autoCleanupOrphansEnabled } = await import("./app-settings-TUVLZNDE.js");
7494
7496
  if (autoCleanupOrphansEnabled() && shouldRunWorktreeCleanup() && orphans.length > 0) {
7495
7497
  await cleanupOrphanWorktrees({ repoPaths });
7496
7498
  }
@@ -7511,7 +7513,7 @@ var Orchestrator = class {
7511
7513
  const pid = thread.agentPid;
7512
7514
  const deadPid = typeof pid === "number" && pid > 0 && !isPidAlive(pid) ? true : false;
7513
7515
  if (deadPid) {
7514
- updateThread(thread.id, { agentPid: null });
7516
+ updateThread(thread.id, { agentPid: null, agentPidStartedAt: null });
7515
7517
  }
7516
7518
  if (thread.status === "queued" && thread.queue.length === 0) {
7517
7519
  if (!this.activeTurns.has(thread.id) && !this.startingTurns.has(thread.id)) {
@@ -7884,7 +7886,7 @@ var Orchestrator = class {
7884
7886
  }
7885
7887
  await setup;
7886
7888
  if (skipSetup) return;
7887
- const { autoRunAfterSetupEnabled } = await import("./app-settings-I5HM5RMP.js");
7889
+ const { autoRunAfterSetupEnabled } = await import("./app-settings-TUVLZNDE.js");
7888
7890
  if (autoRunAfterSetupEnabled()) {
7889
7891
  try {
7890
7892
  await this.startDev(threadId);
@@ -8064,19 +8066,26 @@ var Orchestrator = class {
8064
8066
  }
8065
8067
  const livePid = thread.agentPid;
8066
8068
  if (typeof livePid === "number" && livePid > 0 && isPidAlive(livePid)) {
8067
- const exited = await waitForPidExit(livePid, STALE_AGENT_PID_WAIT_MS);
8068
- if (!exited && isPidAlive(livePid)) {
8069
+ if (!isSameAgentProcess(livePid, thread.agentPidStartedAt, true)) {
8069
8070
  try {
8070
- process.kill(livePid, "SIGKILL");
8071
+ updateThread(threadId, { agentPid: null, agentPidStartedAt: null });
8071
8072
  } catch {
8072
8073
  }
8073
- await waitForPidExit(livePid, 400);
8074
- try {
8075
- updateThread(threadId, { agentPid: null });
8076
- } catch {
8074
+ } else {
8075
+ const exited = await waitForPidExit(livePid, STALE_AGENT_PID_WAIT_MS);
8076
+ if (!exited && isPidAlive(livePid)) {
8077
+ try {
8078
+ process.kill(livePid, "SIGKILL");
8079
+ } catch {
8080
+ }
8081
+ await waitForPidExit(livePid, 400);
8082
+ try {
8083
+ updateThread(threadId, { agentPid: null, agentPidStartedAt: null });
8084
+ } catch {
8085
+ }
8077
8086
  }
8087
+ continue;
8078
8088
  }
8079
- continue;
8080
8089
  }
8081
8090
  const shifted = shiftQueuedItem(thread.queue, thread.queueAttachments);
8082
8091
  if (!shifted) break;
@@ -8251,7 +8260,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8251
8260
  }
8252
8261
  const adapter = getAdapter(thread.agent);
8253
8262
  const resolved = await adapter.resolveSessionId(thread.worktreePath, thread.sessionId);
8254
- if (resolved && resolved !== thread.sessionId) {
8263
+ if (resolved !== thread.sessionId) {
8255
8264
  updateThread(threadId, { sessionId: resolved });
8256
8265
  }
8257
8266
  const fresh = this.requireThread(threadId);
@@ -8262,7 +8271,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8262
8271
  }
8263
8272
  const isBrightsy = fresh.agent === "brightsy";
8264
8273
  const isOrchestration = isOrchestratorThread(fresh);
8265
- const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-I5HM5RMP.js");
8274
+ const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-TUVLZNDE.js");
8266
8275
  const gitAuthMode = getGithubGitAuthMode();
8267
8276
  const worktreeDirective = isBrightsy || isOrchestration ? null : formatWorktreeDirective(fresh, {
8268
8277
  githubSlug: turnOrigin?.forge === "github" ? turnOrigin.slug : await withTimeout(resolveGithubRepoSlug(fresh.worktreePath), 8e3, "resolveGithubRepoSlug").catch(() => null),
@@ -8399,7 +8408,10 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8399
8408
  this.activeTurns.set(threadId, handle);
8400
8409
  this.startingTurns.delete(threadId);
8401
8410
  if (typeof handle.pid === "number" && handle.pid > 0) {
8402
- updateThread(threadId, { agentPid: handle.pid });
8411
+ updateThread(threadId, {
8412
+ agentPid: handle.pid,
8413
+ agentPidStartedAt: pidStartedAt(handle.pid)
8414
+ });
8403
8415
  }
8404
8416
  if (this.stoppedTurns.has(threadId)) {
8405
8417
  handle.kill();
@@ -8427,7 +8439,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8427
8439
  if (!this.stoppedTurns.has(threadId) && this.requireThread(threadId).agent === "cursor" && exitCode !== 0 && !assistantText && parts.length === 0) {
8428
8440
  const sessionId = result.sessionId || this.requireThread(threadId).sessionId || "";
8429
8441
  if (sessionId) {
8430
- const { recoverFinishedCursorRun } = await import("./cursor-recover-TEBFKAZ4.js");
8442
+ const { recoverFinishedCursorRun } = await import("./cursor-recover-7F46PAJ5.js");
8431
8443
  for (let i = 0; i < 8; i++) {
8432
8444
  const recovered = recoverFinishedCursorRun({
8433
8445
  agentId: sessionId,
@@ -8512,7 +8524,10 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8512
8524
  );
8513
8525
  this.activeTurns.set(threadId, retryHandle);
8514
8526
  if (typeof retryHandle.pid === "number" && retryHandle.pid > 0) {
8515
- updateThread(threadId, { agentPid: retryHandle.pid });
8527
+ updateThread(threadId, {
8528
+ agentPid: retryHandle.pid,
8529
+ agentPidStartedAt: pidStartedAt(retryHandle.pid)
8530
+ });
8516
8531
  }
8517
8532
  this.processes.set(`${threadId}:agent`, {
8518
8533
  kind: "agent",
@@ -8661,7 +8676,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8661
8676
  this.runningCount = Math.max(0, this.runningCount - 1);
8662
8677
  clearTurnLive(threadId);
8663
8678
  try {
8664
- updateThread(threadId, { agentPid: null });
8679
+ updateThread(threadId, { agentPid: null, agentPidStartedAt: null });
8665
8680
  } catch {
8666
8681
  }
8667
8682
  }
@@ -8699,9 +8714,16 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8699
8714
  if (proc) proc.kill();
8700
8715
  const pid = thread.agentPid;
8701
8716
  if (typeof pid === "number" && pid > 0 && isPidAlive(pid)) {
8702
- try {
8703
- process.kill(pid, "SIGTERM");
8704
- } catch {
8717
+ if (!isSameAgentProcess(pid, thread.agentPidStartedAt, true)) {
8718
+ try {
8719
+ updateThread(thread.id, { agentPid: null, agentPidStartedAt: null });
8720
+ } catch {
8721
+ }
8722
+ } else {
8723
+ try {
8724
+ process.kill(pid, "SIGTERM");
8725
+ } catch {
8726
+ }
8705
8727
  }
8706
8728
  }
8707
8729
  const stopped = writeStoppedStatus(thread.id, resolveStopReason(opts)) ?? readThread(thread.id) ?? thread;
@@ -9589,7 +9611,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9589
9611
  if (Object.keys(patch).length === 0) continue;
9590
9612
  updateThread(t.id, patch);
9591
9613
  }
9592
- const { autoArchiveOnMergeEnabled } = await import("./app-settings-I5HM5RMP.js");
9614
+ const { autoArchiveOnMergeEnabled } = await import("./app-settings-TUVLZNDE.js");
9593
9615
  const latest = this.requireThread(thread.id);
9594
9616
  if (!shouldAutoArchiveOnPrMerge({
9595
9617
  previousPrState: prevState || null,
@@ -9913,7 +9935,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9913
9935
  await runArchiveScript(thread.repoPath, thread.worktreePath);
9914
9936
  } catch {
9915
9937
  }
9916
- const { deleteBranchOnPurgeEnabled } = await import("./app-settings-I5HM5RMP.js");
9938
+ const { deleteBranchOnPurgeEnabled } = await import("./app-settings-TUVLZNDE.js");
9917
9939
  const deleteBranch = opts?.deleteBranch ?? deleteBranchOnPurgeEnabled();
9918
9940
  await removeWorktree(thread.repoPath, thread.worktreePath, {
9919
9941
  deleteBranch: deleteBranch ? thread.branchName : void 0
@@ -10051,7 +10073,7 @@ async function startOrchestration(opts) {
10051
10073
  sourceRef: "default",
10052
10074
  ...createOpts
10053
10075
  }).catch(async () => {
10054
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-4NGXCCUO.js");
10076
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-KFEJAQ2H.js");
10055
10077
  const repo = await resolveRepoRoot2(repoPath);
10056
10078
  const def = await resolveDefaultBranch2(repo);
10057
10079
  return orch.createThread({
@@ -10061,7 +10083,7 @@ async function startOrchestration(opts) {
10061
10083
  repoPath: repo
10062
10084
  });
10063
10085
  });
10064
- const { updateThread: upd } = await import("./thread-store-3F7GR64A.js");
10086
+ const { updateThread: upd } = await import("./thread-store-4ZN3DS2W.js");
10065
10087
  const updated = upd(thread.id, {
10066
10088
  sourceType: "orchestration",
10067
10089
  sourceRef: goal
@@ -10075,6 +10097,8 @@ async function startOrchestration(opts) {
10075
10097
 
10076
10098
  export {
10077
10099
  isInjectedNoticeText,
10100
+ isPidAlive,
10101
+ waitForPidExit,
10078
10102
  AGENT_GIT_ACTIONS,
10079
10103
  MAX_RUN_LOG_CHARS,
10080
10104
  DEFAULT_RUN_LOG_TAIL_CHARS,
@@ -10110,10 +10134,6 @@ export {
10110
10134
  readTurnLive,
10111
10135
  resolveSendFollowUp,
10112
10136
  localhostPreviewUrl,
10113
- parseIssueSince,
10114
- formatGitHubSearchUpdatedSince,
10115
- issueMatchesUpdatedSince,
10116
- previewIssueCommentBody,
10117
10137
  clampMcpIssueLimit,
10118
10138
  applyIssueListWindow,
10119
10139
  mcpIssueUpdatedSinceSchema,
@@ -10131,8 +10151,6 @@ export {
10131
10151
  fireSchedule,
10132
10152
  LIVE_TURN_SPAWN_GRACE_MS,
10133
10153
  RUN_SCRIPT_DESKTOP_ADOPT_MS,
10134
- isPidAlive,
10135
- waitForPidExit,
10136
10154
  resolveOrchChildFollowUp,
10137
10155
  LIGHT_RECONCILE_THROTTLE_MS,
10138
10156
  Orchestrator,