@sideboard-ai/core 0.1.340 → 0.1.342

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 (69) hide show
  1. package/dist/{abletime-OGOHNRVB.js → abletime-MSIMJKKQ.js} +4 -4
  2. package/dist/{abletime-TNONAVJG.js → abletime-ZIYFR4SI.js} +4 -4
  3. package/dist/{abletime-oauth-DAZEUQJI.js → abletime-oauth-2RUKRZYZ.js} +3 -3
  4. package/dist/{abletime-oauth-TYDQ73GK.js → abletime-oauth-IQZ3LOB2.js} +3 -3
  5. package/dist/{abletime-rest-B4VI46MI.js → abletime-rest-7YAO5B74.js} +3 -3
  6. package/dist/{abletime-rest-3FWZGTX6.js → abletime-rest-UBLSGMSA.js} +3 -3
  7. package/dist/{agents-QFXIBIKJ.js → agents-7DCNOMFP.js} +8 -8
  8. package/dist/{agents-6MSZHZOM.js → agents-LNZ465IM.js} +8 -8
  9. package/dist/{app-settings-KOSVLMO5.js → app-settings-FS7TM55D.js} +11 -1
  10. package/dist/{app-settings-YS5AUJTF.js → app-settings-Q2F57NVK.js} +11 -1
  11. package/dist/{chunk-BD7QARIJ.js → chunk-2BLJ726H.js} +6 -5
  12. package/dist/{chunk-SYTTUNX6.js → chunk-3DMRQB4Y.js} +1 -1
  13. package/dist/{chunk-OMKTX7ZW.js → chunk-3J3XOIHF.js} +3 -3
  14. package/dist/{chunk-W6J3ZWLJ.js → chunk-4HELMBYR.js} +2 -2
  15. package/dist/{chunk-HNW5KMGK.js → chunk-4PXHJA5K.js} +2 -2
  16. package/dist/{chunk-QWFNKOGA.js → chunk-4TTTEKNV.js} +2 -2
  17. package/dist/{chunk-EVYOONTE.js → chunk-5BFEHSHO.js} +6 -5
  18. package/dist/{chunk-EZZY3EAZ.js → chunk-5HUR77ZH.js} +666 -62
  19. package/dist/{chunk-5TVRPOVS.js → chunk-5SJGR3VS.js} +1 -1
  20. package/dist/{chunk-I2C5ZRVO.js → chunk-5TS3KVGI.js} +1 -1
  21. package/dist/{chunk-5FGQTB2Z.js → chunk-6RO2AOE5.js} +2 -2
  22. package/dist/{chunk-FEGRY7NL.js → chunk-A4ZI7SA3.js} +3 -3
  23. package/dist/{chunk-DYUAVL5S.js → chunk-BIM24I3O.js} +1 -0
  24. package/dist/{chunk-KAIOL2M5.js → chunk-D7US5R4H.js} +1 -1
  25. package/dist/{chunk-NHLTTT5G.js → chunk-DEQLDEYR.js} +7 -6
  26. package/dist/{chunk-ELDHERAD.js → chunk-DZF25KTX.js} +661 -56
  27. package/dist/{chunk-4OVQGZEI.js → chunk-G3UV3GXJ.js} +48 -26
  28. package/dist/{chunk-Q73I6I2K.js → chunk-GUIJMZQG.js} +1 -1
  29. package/dist/{chunk-AFSLMWQK.js → chunk-JHT3CYLT.js} +42 -3
  30. package/dist/{chunk-BDQFZAE6.js → chunk-JX3OWNOT.js} +43 -3
  31. package/dist/{chunk-6ABL7HZN.js → chunk-LDJT3TLN.js} +10 -8
  32. package/dist/{chunk-LYJ5AVK4.js → chunk-LHU6ZBFB.js} +2 -2
  33. package/dist/{chunk-WSZIJNAR.js → chunk-NDBMDHQ5.js} +5 -5
  34. package/dist/{chunk-PEJ3N5VE.js → chunk-NGIGRAZB.js} +7 -6
  35. package/dist/{chunk-4BRO5LNX.js → chunk-O2IRQAFB.js} +3 -3
  36. package/dist/{chunk-5KH3EQ2C.js → chunk-ORO4ENZR.js} +1 -0
  37. package/dist/{chunk-ERCYQTJU.js → chunk-RTZO2YJC.js} +48 -26
  38. package/dist/{chunk-VHHEQP5V.js → chunk-S3DTEGMK.js} +11 -9
  39. package/dist/{chunk-N6TGSJVC.js → chunk-S3UGLMGE.js} +31 -0
  40. package/dist/{chunk-FCBUDWP6.js → chunk-SLLTEMIL.js} +2 -2
  41. package/dist/{chunk-23KYDM2U.js → chunk-TKEYXNXY.js} +31 -0
  42. package/dist/{chunk-4SP26Z6H.js → chunk-WO7VF4FG.js} +5 -5
  43. package/dist/{conductor-LEPTWN2U.js → conductor-4SWJM5FS.js} +6 -6
  44. package/dist/{conductor-AUUXCJZT.js → conductor-Q433HU77.js} +6 -6
  45. package/dist/{coordinator-prompt-VO42IZWS.js → coordinator-prompt-5QHWCO7V.js} +4 -4
  46. package/dist/{coordinator-prompt-CIWWP2P6.js → coordinator-prompt-Z7PPP45X.js} +4 -4
  47. package/dist/{global-workspace-FKXLFKYX.js → global-workspace-DL4K4K7O.js} +4 -4
  48. package/dist/{global-workspace-MCAREQI7.js → global-workspace-VDCZMFCZ.js} +4 -4
  49. package/dist/index.cjs +1018 -188
  50. package/dist/index.d.cts +57 -7
  51. package/dist/index.d.ts +57 -7
  52. package/dist/index.js +135 -30
  53. package/dist/{linear-P3LP455O.js → linear-JE4WAZ3W.js} +2 -2
  54. package/dist/{linear-5E2WI4QQ.js → linear-UXMDJAD4.js} +2 -2
  55. package/dist/{linear-list-Y3INIBYH.js → linear-list-I4NAOWPN.js} +1 -1
  56. package/dist/{linear-list-AXK62DPW.js → linear-list-KDLU7QWX.js} +1 -1
  57. package/dist/mcp/run-stdio.cjs +922 -114
  58. package/dist/mcp/run-stdio.js +119 -27
  59. package/dist/{optional-cli-6J6C4I3X.js → optional-cli-7QXXPEN6.js} +3 -3
  60. package/dist/{optional-cli-X6I35UNI.js → optional-cli-RUUCLNSM.js} +4 -4
  61. package/dist/{orchestrator-JTFCNXVR.js → orchestrator-BPCM4OP3.js} +11 -11
  62. package/dist/{orchestrator-NOQDMYLB.js → orchestrator-HIWWPWL5.js} +11 -11
  63. package/dist/{thread-store-DCO5MZWJ.js → thread-store-HETUMDVA.js} +2 -2
  64. package/dist/{thread-store-QGBPSZU2.js → thread-store-ILM2ZJCB.js} +2 -2
  65. package/dist/{workspaces-D6FQCZRK.js → workspaces-EIIHHH4S.js} +4 -4
  66. package/dist/{workspaces-Y25L2EPV.js → workspaces-MX4W4SSB.js} +4 -4
  67. package/dist/{worktree-S4YOAYRA.js → worktree-BD3EJE24.js} +5 -3
  68. package/dist/{worktree-GWS77LWX.js → worktree-QBVLKACU.js} +5 -3
  69. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  formatOptionalServicesDirectiveForTurn,
3
3
  formatOptionalServicesReminderForTurn
4
- } from "./chunk-QWFNKOGA.js";
4
+ } from "./chunk-4TTTEKNV.js";
5
5
  import {
6
6
  extractPresentedPlan,
7
7
  isPresentPlanToolName,
@@ -21,7 +21,7 @@ import {
21
21
  parseSessionQuotaResetAt,
22
22
  planModeTurnInstruction,
23
23
  resolveQuotaFallbackAgent
24
- } from "./chunk-6ABL7HZN.js";
24
+ } from "./chunk-LDJT3TLN.js";
25
25
  import {
26
26
  applyWorktreePkgCacheEnv,
27
27
  buildBrightsySessionSeed,
@@ -56,7 +56,7 @@ import {
56
56
  worktreeDevProcessKey,
57
57
  worktreeRunProcessKey,
58
58
  worktreeSetupProcessKey
59
- } from "./chunk-PEJ3N5VE.js";
59
+ } from "./chunk-NGIGRAZB.js";
60
60
  import {
61
61
  applyAgentEvent,
62
62
  clipAgentEventForPaint,
@@ -71,7 +71,7 @@ import {
71
71
  partsToAssistantText,
72
72
  stripBrightsyNdjsonNoise,
73
73
  toolDescription
74
- } from "./chunk-DYUAVL5S.js";
74
+ } from "./chunk-BIM24I3O.js";
75
75
  import {
76
76
  titleFromPrompt
77
77
  } from "./chunk-7H655NEW.js";
@@ -88,10 +88,12 @@ import {
88
88
  ensureGlobalCoordinatorCwd,
89
89
  ensureWorkspace,
90
90
  healOrchestrationSoccerTitles,
91
+ isCloudCoordinatorThread,
91
92
  isGlobalRepoPath,
92
93
  isGlobalThread,
93
94
  isOrchestratorThread,
94
95
  isRemovedWorkspace,
96
+ listGlobalThreads,
95
97
  listWorkspaces,
96
98
  orchestratorSessionPoisonedByBuiltins,
97
99
  persistPendingFileAttachments,
@@ -99,7 +101,7 @@ import {
99
101
  stageAbsolutePathsAsAttachments,
100
102
  stageBuffersAsAttachments,
101
103
  syncWorkspacesFromThreads
102
- } from "./chunk-BD7QARIJ.js";
104
+ } from "./chunk-2BLJ726H.js";
103
105
  import {
104
106
  addPrStackLayer,
105
107
  allocateTeamSlug,
@@ -124,6 +126,7 @@ import {
124
126
  formatGitAuthModeDirective,
125
127
  getPr,
126
128
  getPrChecks,
129
+ getPrCiChecks,
127
130
  getPrDetails,
128
131
  getPrForHeadBranch,
129
132
  getPrMeta,
@@ -134,6 +137,7 @@ import {
134
137
  isDirty,
135
138
  isGhRateLimitError,
136
139
  isSideboardScratchPath,
140
+ listPrs,
137
141
  listWorktrees,
138
142
  markPrReady,
139
143
  mergeAgentGitAuthEnv,
@@ -150,7 +154,7 @@ import {
150
154
  resolveRepoRoot,
151
155
  switchWorktreeBranch,
152
156
  withRepoGitLock
153
- } from "./chunk-4OVQGZEI.js";
157
+ } from "./chunk-G3UV3GXJ.js";
154
158
  import {
155
159
  REVIEW_TAB_TITLE,
156
160
  agentNicknameFromWorktreePath,
@@ -182,7 +186,7 @@ import {
182
186
  worktreeNameFromPath,
183
187
  worktreeSlugForTicket,
184
188
  writeThread
185
- } from "./chunk-BDQFZAE6.js";
189
+ } from "./chunk-JX3OWNOT.js";
186
190
  import {
187
191
  askBlockStillWaiting,
188
192
  extractPendingPlanQuestions,
@@ -250,15 +254,17 @@ import {
250
254
  resolveEffectiveIssueSource,
251
255
  resolveNewThreadOptions,
252
256
  resolveOrchestratorDefaults,
257
+ resolveProjectReviewLabel,
253
258
  resolveViewerProfileForRepo,
254
259
  subtractUsage,
255
260
  sumUsageList,
256
261
  updateAdvancedSettings,
257
262
  updateAppEnvironment,
258
263
  usageOnLimit,
264
+ wakeOrchestratorOnGithubEdgesEnabled,
259
265
  withTurnScopedCost,
260
266
  writeViewerContext
261
- } from "./chunk-23KYDM2U.js";
267
+ } from "./chunk-TKEYXNXY.js";
262
268
  import {
263
269
  examplePrefixedBranch,
264
270
  sanitizeGitBranchPrefix
@@ -272,6 +278,9 @@ import {
272
278
  import {
273
279
  releaseCaffeinateHoldForThread
274
280
  } from "./chunk-LAWLUOWQ.js";
281
+ import {
282
+ writePrivateFile
283
+ } from "./chunk-JT7R45JB.js";
275
284
  import {
276
285
  annotateDevAccessRuns,
277
286
  appDataDir,
@@ -326,7 +335,7 @@ function formatInjectedNoticesForTurn(notices) {
326
335
 
327
336
  // src/orchestrator/orchestrator.ts
328
337
  import { randomUUID as randomUUID4 } from "crypto";
329
- import { existsSync as existsSync13 } from "fs";
338
+ import { existsSync as existsSync14 } from "fs";
330
339
 
331
340
  // src/agents/spawn.ts
332
341
  import { rmSync } from "fs";
@@ -385,19 +394,19 @@ function traceTurn(phase, extra) {
385
394
  }
386
395
  }
387
396
  async function withTimeout(promise, ms, label) {
388
- let timer;
397
+ let timer2;
389
398
  try {
390
399
  return await Promise.race([
391
400
  promise,
392
401
  new Promise((_, reject) => {
393
- timer = setTimeout(
402
+ timer2 = setTimeout(
394
403
  () => reject(new Error(`${label} timed out after ${ms}ms`)),
395
404
  ms
396
405
  );
397
406
  })
398
407
  ]);
399
408
  } finally {
400
- if (timer) clearTimeout(timer);
409
+ if (timer2) clearTimeout(timer2);
401
410
  }
402
411
  }
403
412
 
@@ -518,9 +527,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
518
527
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
519
528
  );
520
529
  }
521
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-MCAREQI7.js");
530
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-VDCZMFCZ.js");
522
531
  if (isGlobalThread2(thread)) {
523
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-VO42IZWS.js");
532
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-5QHWCO7V.js");
524
533
  ensureGlobalCoordinatorCwd2(
525
534
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
526
535
  );
@@ -718,9 +727,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
718
727
  }
719
728
  };
720
729
  signal("SIGTERM");
721
- const timer = setTimeout(() => signal("SIGKILL"), 5e3);
722
- timer.unref?.();
723
- child.once("exit", () => clearTimeout(timer));
730
+ const timer2 = setTimeout(() => signal("SIGKILL"), 5e3);
731
+ timer2.unref?.();
732
+ child.once("exit", () => clearTimeout(timer2));
724
733
  },
725
734
  done
726
735
  };
@@ -1070,9 +1079,9 @@ function mergeSetupOutput(prev, incoming) {
1070
1079
  }
1071
1080
  var PERSIST_DEBOUNCE_MS = 500;
1072
1081
  function persistNow(threadId) {
1073
- const timer = persistTimers.get(threadId);
1074
- if (timer) {
1075
- clearTimeout(timer);
1082
+ const timer2 = persistTimers.get(threadId);
1083
+ if (timer2) {
1084
+ clearTimeout(timer2);
1076
1085
  persistTimers.delete(threadId);
1077
1086
  }
1078
1087
  const mem = memory.get(threadId);
@@ -1221,9 +1230,9 @@ function sliceRunLogOutput(output, tailChars = DEFAULT_RUN_LOG_TAIL_CHARS) {
1221
1230
  }
1222
1231
  var PERSIST_DEBOUNCE_MS2 = 500;
1223
1232
  function persistNow2(key) {
1224
- const timer = persistTimers2.get(key);
1225
- if (timer) {
1226
- clearTimeout(timer);
1233
+ const timer2 = persistTimers2.get(key);
1234
+ if (timer2) {
1235
+ clearTimeout(timer2);
1227
1236
  persistTimers2.delete(key);
1228
1237
  }
1229
1238
  const mem = memory2.get(key);
@@ -3290,7 +3299,7 @@ async function createThread(input, _onSetupLine) {
3290
3299
  });
3291
3300
  await requireAgent(resolved.agent);
3292
3301
  if (input.cowboy) {
3293
- const { cowboyModeEnabled } = await import("./app-settings-KOSVLMO5.js");
3302
+ const { cowboyModeEnabled } = await import("./app-settings-FS7TM55D.js");
3294
3303
  if (!cowboyModeEnabled()) {
3295
3304
  throw new Error(
3296
3305
  "Cowboy mode is off. Enable it in Settings \u2192 Advanced."
@@ -3349,7 +3358,7 @@ async function createThread(input, _onSetupLine) {
3349
3358
  let sourceIsFork = false;
3350
3359
  if (!input.cowboy && sourceType === "branch" && (!sourceRef || sourceRef === "HEAD" || sourceRef === "default")) {
3351
3360
  if (isAbleTimeConnected() && getIssueSource() === "abletime") {
3352
- const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-TNONAVJG.js");
3361
+ const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-ZIYFR4SI.js");
3353
3362
  const task = await ensureAbleTimeTask({
3354
3363
  title: title?.trim() || "Untitled work",
3355
3364
  description: input.prompt?.trim() || void 0
@@ -3460,7 +3469,7 @@ async function createThread(input, _onSetupLine) {
3460
3469
  return readThread(thread.id) ?? thread;
3461
3470
  }
3462
3471
  async function listLinearIssues(agent, repoPath) {
3463
- const { getAdapter: getAdapter2 } = await import("./agents-QFXIBIKJ.js");
3472
+ const { getAdapter: getAdapter2 } = await import("./agents-7DCNOMFP.js");
3464
3473
  await requireAgent(agent, { requireLinear: true });
3465
3474
  const adapter = getAdapter2(agent);
3466
3475
  if (!adapter.listLinearIssues) {
@@ -3762,11 +3771,11 @@ function createLineCoalescer(onChunk, opts) {
3762
3771
  const delayMs = opts?.delayMs ?? 50;
3763
3772
  const maxLines = opts?.maxLines ?? 200;
3764
3773
  let buffer = [];
3765
- let timer = null;
3774
+ let timer2 = null;
3766
3775
  const flush2 = () => {
3767
- if (timer) {
3768
- clearTimeout(timer);
3769
- timer = null;
3776
+ if (timer2) {
3777
+ clearTimeout(timer2);
3778
+ timer2 = null;
3770
3779
  }
3771
3780
  if (buffer.length === 0) return;
3772
3781
  const chunk = buffer.join("\n");
@@ -3779,7 +3788,7 @@ function createLineCoalescer(onChunk, opts) {
3779
3788
  flush2();
3780
3789
  return;
3781
3790
  }
3782
- if (!timer) timer = setTimeout(flush2, delayMs);
3791
+ if (!timer2) timer2 = setTimeout(flush2, delayMs);
3783
3792
  };
3784
3793
  return { push, flush: flush2 };
3785
3794
  }
@@ -4243,7 +4252,7 @@ async function adoptThread(input) {
4243
4252
  messages: input.messages ?? []
4244
4253
  });
4245
4254
  writeThread(thread);
4246
- const { addWorkspace: addWorkspace2 } = await import("./workspaces-Y25L2EPV.js");
4255
+ const { addWorkspace: addWorkspace2 } = await import("./workspaces-MX4W4SSB.js");
4247
4256
  await addWorkspace2(repoPath);
4248
4257
  const { ensureWorktreeSideboardIgnored } = await import("./worktree-exclude-YQBN43QD.js");
4249
4258
  await ensureWorktreeSideboardIgnored(input.worktreePath);
@@ -6652,7 +6661,7 @@ function formatWorktreeDirective(thread, opts) {
6652
6661
  );
6653
6662
  }
6654
6663
  lines.push(
6655
- '- Sideboard git buttons send short phrases ("Commit and push.", "Ready for review.", "Merge PR.", \u2026) with their meaning attached \u2014 act on them without asking for clarification. If the user gives a goal (Greptile 5/5, CI green, until checks pass), you get the watch-fix-push playbook with that request.'
6664
+ '- Sideboard git buttons send short phrases ("Commit and push.", "Ready for review.", "Merge PR.", \u2026) with their meaning attached \u2014 act on them without asking. A named goal includes the watch-fix-push playbook.'
6656
6665
  );
6657
6666
  lines.push("");
6658
6667
  lines.push(formatDevAccessHint(opts?.activeRuns));
@@ -6661,7 +6670,7 @@ function formatWorktreeDirective(thread, opts) {
6661
6670
  "Automations (sidebar, after Board): `create_schedule` / `list_schedules` (`at` / `every` / `cron` / `time`+`days`). `archiveChat=false` keeps the new chat. `chatId=self` is removed when this chat is archived. Fires only while Sideboard.app is running. Future jobs turn on Caffeinate."
6662
6671
  );
6663
6672
  lines.push(
6664
- "`set_workspace_tags` labels this checkout (omit ref; replace, add, or remove). Not another checkout."
6673
+ "`set_workspace_tags` labels this checkout (omit ref). `set_wake_on_github_edges` opts this checkout in when Advanced is already on (omit ref)."
6665
6674
  );
6666
6675
  lines.push(
6667
6676
  "Orchestration: `show_plan` opens the diagram and plan.md. `list_order` / `set_dependency`"
@@ -7225,6 +7234,600 @@ async function syncThreadBranchFromGit(threadId) {
7225
7234
  }
7226
7235
  }
7227
7236
 
7237
+ // src/orchestrator/github-edge-watch.ts
7238
+ import { existsSync as existsSync13, readFileSync as readFileSync8 } from "fs";
7239
+ import { join as join14 } from "path";
7240
+
7241
+ // src/orchestrator/github-edge.ts
7242
+ var GITHUB_EDGE_COOLDOWN_MS = 30 * 6e4;
7243
+ var GITHUB_EDGE_POLL_MS = 6e4;
7244
+ var LAST_FIRED_KEEP_MS = 7 * 24 * 60 * 6e4;
7245
+ function emptyGithubEdgeSnapshot() {
7246
+ return { primed: false, ciFailed: [], reviewRequested: [], lastFiredAt: {} };
7247
+ }
7248
+ function normalizePrUrl(raw) {
7249
+ const trimmed = (raw ?? "").trim();
7250
+ if (!trimmed) return "";
7251
+ try {
7252
+ const url = new URL(trimmed);
7253
+ url.hash = "";
7254
+ url.search = "";
7255
+ const path = url.pathname.replace(/\/+$/, "");
7256
+ return `${url.protocol}//${url.host.toLowerCase()}${path}`;
7257
+ } catch {
7258
+ return trimmed.replace(/\/+$/, "");
7259
+ }
7260
+ }
7261
+ function githubEdgeKey(kind, prUrl) {
7262
+ return `${kind}:${normalizePrUrl(prUrl)}`;
7263
+ }
7264
+ function acceptOpenReadyPr(row) {
7265
+ if (!normalizePrUrl(row.prUrl)) return false;
7266
+ if (row.draft === true) return false;
7267
+ const state = (row.state ?? "").trim().toUpperCase();
7268
+ return state !== "MERGED" && state !== "CLOSED";
7269
+ }
7270
+ function mergeCiLatch(prev, failing, unknown) {
7271
+ const out = /* @__PURE__ */ new Set();
7272
+ for (const url of failing) {
7273
+ const normalized = normalizePrUrl(url);
7274
+ if (normalized) out.add(normalized);
7275
+ }
7276
+ const unknownSet = new Set(unknown.map((url) => normalizePrUrl(url)).filter(Boolean));
7277
+ for (const url of prev) {
7278
+ const normalized = normalizePrUrl(url);
7279
+ if (normalized && unknownSet.has(normalized)) out.add(normalized);
7280
+ }
7281
+ return [...out];
7282
+ }
7283
+ function mergeReviewLatch(prev, fetched, successfulRepos) {
7284
+ const ok = new Set(successfulRepos);
7285
+ const map = /* @__PURE__ */ new Map();
7286
+ for (const row of prev) {
7287
+ const prUrl = normalizePrUrl(row.prUrl);
7288
+ if (!prUrl) continue;
7289
+ if (row.repoPath && ok.has(row.repoPath)) continue;
7290
+ if (!row.repoPath) continue;
7291
+ map.set(prUrl, { prUrl, repoPath: row.repoPath });
7292
+ }
7293
+ for (const row of fetched) {
7294
+ const prUrl = normalizePrUrl(row.prUrl);
7295
+ if (!prUrl) continue;
7296
+ map.set(prUrl, { prUrl, repoPath: row.repoPath });
7297
+ }
7298
+ return [...map.values()];
7299
+ }
7300
+ function coerceGithubEdgeSnapshot(raw) {
7301
+ if (!raw || typeof raw !== "object") return emptyGithubEdgeSnapshot();
7302
+ const row = raw;
7303
+ const ciFailed = [];
7304
+ const seenCi = /* @__PURE__ */ new Set();
7305
+ if (Array.isArray(row.ciFailed)) {
7306
+ for (const item of row.ciFailed) {
7307
+ const prUrl = normalizePrUrl(typeof item === "string" ? item : "");
7308
+ if (!prUrl || seenCi.has(prUrl)) continue;
7309
+ seenCi.add(prUrl);
7310
+ ciFailed.push(prUrl);
7311
+ }
7312
+ }
7313
+ const reviewRequested = [];
7314
+ const seenReview = /* @__PURE__ */ new Set();
7315
+ if (Array.isArray(row.reviewRequested)) {
7316
+ for (const item of row.reviewRequested) {
7317
+ if (!item || typeof item !== "object") continue;
7318
+ const record = item;
7319
+ const prUrl = normalizePrUrl(typeof record.prUrl === "string" ? record.prUrl : "");
7320
+ const repoPath = typeof record.repoPath === "string" ? record.repoPath.trim() : "";
7321
+ if (!prUrl || !repoPath || seenReview.has(prUrl)) continue;
7322
+ seenReview.add(prUrl);
7323
+ reviewRequested.push({ prUrl, repoPath });
7324
+ }
7325
+ }
7326
+ const ciSeen = [];
7327
+ const seenCiUrls = /* @__PURE__ */ new Set();
7328
+ if (Array.isArray(row.ciSeen)) {
7329
+ for (const item of row.ciSeen) {
7330
+ const prUrl = normalizePrUrl(typeof item === "string" ? item : "");
7331
+ if (!prUrl || seenCiUrls.has(prUrl)) continue;
7332
+ seenCiUrls.add(prUrl);
7333
+ ciSeen.push(prUrl);
7334
+ }
7335
+ }
7336
+ const reviewReposSeen = [];
7337
+ const seenRepos = /* @__PURE__ */ new Set();
7338
+ if (Array.isArray(row.reviewReposSeen)) {
7339
+ for (const item of row.reviewReposSeen) {
7340
+ const repo = typeof item === "string" ? item.trim() : "";
7341
+ if (!repo || seenRepos.has(repo)) continue;
7342
+ seenRepos.add(repo);
7343
+ reviewReposSeen.push(repo);
7344
+ }
7345
+ }
7346
+ const lastFiredAt = {};
7347
+ if (row.lastFiredAt && typeof row.lastFiredAt === "object") {
7348
+ for (const [key, value] of Object.entries(row.lastFiredAt)) {
7349
+ if (typeof value === "number" && Number.isFinite(value) && value > 0) {
7350
+ lastFiredAt[key] = value;
7351
+ }
7352
+ }
7353
+ }
7354
+ return {
7355
+ primed: row.primed === true,
7356
+ ciFailed,
7357
+ reviewRequested,
7358
+ lastFiredAt,
7359
+ ...reviewReposSeen.length ? { reviewReposSeen } : {},
7360
+ ...ciSeen.length ? { ciSeen } : {}
7361
+ };
7362
+ }
7363
+ function dedupeSubjects(items) {
7364
+ const map = /* @__PURE__ */ new Map();
7365
+ for (const item of items) {
7366
+ if (!acceptOpenReadyPr(item)) continue;
7367
+ const prUrl = normalizePrUrl(item.prUrl);
7368
+ if (!prUrl) continue;
7369
+ const next = { ...item, prUrl };
7370
+ const prev = map.get(prUrl);
7371
+ if (!prev) {
7372
+ map.set(prUrl, next);
7373
+ continue;
7374
+ }
7375
+ if (!prev.threadId && next.threadId) {
7376
+ map.set(prUrl, {
7377
+ ...prev,
7378
+ ...next,
7379
+ prUrl,
7380
+ title: next.title.trim() || prev.title
7381
+ });
7382
+ }
7383
+ }
7384
+ return [...map.values()];
7385
+ }
7386
+ function diffGithubEdges(input) {
7387
+ if (!input.prev.primed) return [];
7388
+ const cooldown = input.cooldownMs ?? GITHUB_EDGE_COOLDOWN_MS;
7389
+ const edges = [];
7390
+ const consider = (kind, items, latched) => {
7391
+ for (const item of dedupeSubjects(items)) {
7392
+ if (latched.has(item.prUrl)) continue;
7393
+ const firedAt = input.prev.lastFiredAt[githubEdgeKey(kind, item.prUrl)] ?? 0;
7394
+ if (firedAt && input.now - firedAt < cooldown) continue;
7395
+ edges.push({ ...item, kind });
7396
+ }
7397
+ };
7398
+ consider("ci-failed", input.ciFailed, new Set(input.prev.ciFailed.map((url) => normalizePrUrl(url))));
7399
+ consider(
7400
+ "review-requested",
7401
+ input.reviewRequested,
7402
+ new Set(input.prev.reviewRequested.map((row) => normalizePrUrl(row.prUrl)))
7403
+ );
7404
+ return edges;
7405
+ }
7406
+ function commitGithubEdgeSnapshot(input) {
7407
+ const deliveredCi = new Set(
7408
+ input.delivered.filter((edge) => edge.kind === "ci-failed").map((edge) => normalizePrUrl(edge.prUrl)).filter(Boolean)
7409
+ );
7410
+ const deliveredReview = new Set(
7411
+ input.delivered.filter((edge) => edge.kind === "review-requested").map((edge) => normalizePrUrl(edge.prUrl)).filter(Boolean)
7412
+ );
7413
+ const ciObserved = dedupeSubjects(input.ciFailed).map((item) => item.prUrl);
7414
+ const ciFailed = nextUrls(input.prev.primed, input.prev.ciFailed, ciObserved, deliveredCi);
7415
+ const reviewRequested = nextReviewLatch(
7416
+ input.prev.primed,
7417
+ input.reviewRequested,
7418
+ input.prev.reviewRequested,
7419
+ deliveredReview
7420
+ );
7421
+ const lastFiredAt = {};
7422
+ for (const [key, at] of Object.entries(input.prev.lastFiredAt)) {
7423
+ if (input.now - at <= LAST_FIRED_KEEP_MS) lastFiredAt[key] = at;
7424
+ }
7425
+ for (const edge of input.delivered) {
7426
+ const prUrl = normalizePrUrl(edge.prUrl);
7427
+ if (!prUrl) continue;
7428
+ lastFiredAt[githubEdgeKey(edge.kind, prUrl)] = input.now;
7429
+ }
7430
+ return { primed: true, ciFailed, reviewRequested, lastFiredAt };
7431
+ }
7432
+ function nextUrls(primed, prev, observed, delivered) {
7433
+ const prevSet = new Set(prev.map((url) => normalizePrUrl(url)).filter(Boolean));
7434
+ const out = [];
7435
+ const seen = /* @__PURE__ */ new Set();
7436
+ for (const url of observed) {
7437
+ if (!url || seen.has(url)) continue;
7438
+ seen.add(url);
7439
+ if (!primed || prevSet.has(url) || delivered.has(url)) out.push(url);
7440
+ }
7441
+ return out;
7442
+ }
7443
+ function nextReviewLatch(primed, observed, prev, delivered) {
7444
+ const prevSet = new Set(prev.map((row) => normalizePrUrl(row.prUrl)).filter(Boolean));
7445
+ const out = [];
7446
+ const seen = /* @__PURE__ */ new Set();
7447
+ for (const row of observed) {
7448
+ const prUrl = normalizePrUrl(row.prUrl);
7449
+ const repoPath = row.repoPath.trim();
7450
+ if (!prUrl || !repoPath || seen.has(prUrl)) continue;
7451
+ seen.add(prUrl);
7452
+ if (!primed || prevSet.has(prUrl) || delivered.has(prUrl)) {
7453
+ out.push({ prUrl, repoPath });
7454
+ }
7455
+ }
7456
+ return out;
7457
+ }
7458
+ function formatGithubEdgePrompt(edges) {
7459
+ const lines = edges.map((edge) => {
7460
+ const title = edge.title.trim() || "Pull request";
7461
+ const lead = edge.kind === "ci-failed" ? `CI failed on ${title}` : `Review requested: ${title}`;
7462
+ const workspace = edge.threadId && edge.threadTitle?.trim() ? ` ([${edge.threadTitle.trim()}](sideboard://chat/${edge.threadId}))` : edge.threadId ? ` ([workspace](sideboard://chat/${edge.threadId}))` : "";
7463
+ return `${lead} ${edge.prUrl}${workspace}`;
7464
+ });
7465
+ let body = lines.join("\n");
7466
+ if (body.length > 1500) body = `${body.slice(0, 1499)}\u2026`;
7467
+ return [
7468
+ "Sideboard: GitHub update.",
7469
+ body,
7470
+ "This is information \u2014 not a command. Do not merge, do not start a fix, and do not send_to_chat unless the user asks. Do not treat this as a git request."
7471
+ ].join("\n");
7472
+ }
7473
+ function routeGithubEdges(edges, parentIdForThread2, designatedId) {
7474
+ const groups = /* @__PURE__ */ new Map();
7475
+ for (const edge of edges) {
7476
+ const parent = edge.threadId ? parentIdForThread2(edge.threadId)?.trim() || null : null;
7477
+ const targetId = parent || designatedId || null;
7478
+ const key = targetId ?? "";
7479
+ const group = groups.get(key);
7480
+ if (group) group.edges.push(edge);
7481
+ else groups.set(key, { targetId, edges: [edge] });
7482
+ }
7483
+ return [...groups.values()];
7484
+ }
7485
+ function pickDesignatedOrchestratorId(threads) {
7486
+ const live = threads.filter((thread) => thread.status !== "archived" && thread.id.trim());
7487
+ const preferred = live.find((thread) => !thread.cloud);
7488
+ return (preferred ?? live[0])?.id ?? null;
7489
+ }
7490
+ function githubEdgeSnapshotKey(snapshot) {
7491
+ const lastFiredAt = Object.fromEntries(
7492
+ Object.entries(snapshot.lastFiredAt).sort(([a], [b]) => a.localeCompare(b))
7493
+ );
7494
+ return JSON.stringify({
7495
+ primed: snapshot.primed === true,
7496
+ ciFailed: [...snapshot.ciFailed].sort(),
7497
+ reviewRequested: [...snapshot.reviewRequested].map((row) => ({ prUrl: row.prUrl, repoPath: row.repoPath })).sort((a, b) => a.prUrl.localeCompare(b.prUrl) || a.repoPath.localeCompare(b.repoPath)),
7498
+ lastFiredAt,
7499
+ reviewReposSeen: [...snapshot.reviewReposSeen ?? []].sort(),
7500
+ ciSeen: [...snapshot.ciSeen ?? []].sort()
7501
+ });
7502
+ }
7503
+
7504
+ // src/orchestrator/github-edge-watch.ts
7505
+ var timer = null;
7506
+ var polling = false;
7507
+ var needsBaseline = true;
7508
+ function githubEdgeSnapshotPath() {
7509
+ return join14(appDataDir(), "github-edge-watch.json");
7510
+ }
7511
+ function loadGithubEdgeSnapshot() {
7512
+ try {
7513
+ const path = githubEdgeSnapshotPath();
7514
+ if (!existsSync13(path)) return emptyGithubEdgeSnapshot();
7515
+ return coerceGithubEdgeSnapshot(JSON.parse(readFileSync8(path, "utf8")));
7516
+ } catch {
7517
+ return emptyGithubEdgeSnapshot();
7518
+ }
7519
+ }
7520
+ function saveGithubEdgeSnapshot(snapshot) {
7521
+ writePrivateFile(githubEdgeSnapshotPath(), `${JSON.stringify(snapshot, null, 2)}
7522
+ `);
7523
+ }
7524
+ function stopGithubEdgeWatch() {
7525
+ if (timer) clearInterval(timer);
7526
+ timer = null;
7527
+ }
7528
+ function armGithubEdgeWatch() {
7529
+ if (!isThisProcessDesktopHost()) return;
7530
+ if (!wakeOrchestratorOnGithubEdgesEnabled()) {
7531
+ stopGithubEdgeWatch();
7532
+ needsBaseline = true;
7533
+ return;
7534
+ }
7535
+ if (timer) return;
7536
+ const tick = () => {
7537
+ if (polling) return;
7538
+ polling = true;
7539
+ const baseline = needsBaseline;
7540
+ needsBaseline = false;
7541
+ void pollGithubEdges(realDeps(), { baseline }).catch(() => {
7542
+ if (baseline) needsBaseline = true;
7543
+ }).finally(() => {
7544
+ polling = false;
7545
+ });
7546
+ };
7547
+ timer = setInterval(tick, GITHUB_EDGE_POLL_MS);
7548
+ timer.unref?.();
7549
+ tick();
7550
+ }
7551
+ async function pollGithubEdges(deps = realDeps(), opts) {
7552
+ if (!deps.enabled()) return { fired: 0, primed: false, skipped: "disabled" };
7553
+ const loaded = deps.load();
7554
+ const prev = opts?.baseline ? { ...loaded, primed: false } : loaded;
7555
+ const now = deps.now();
7556
+ const cards = indexCiCards(deps.listCiCards(), (threadId) => deps.parentIdForThread(threadId));
7557
+ const failing = [];
7558
+ const unknown = [];
7559
+ const observed = [];
7560
+ const failingSubjects = /* @__PURE__ */ new Map();
7561
+ for (const card of cards.values()) {
7562
+ const prUrl = normalizePrUrl(card.prUrl);
7563
+ let failed;
7564
+ try {
7565
+ failed = await deps.fetchCiFailed(card);
7566
+ } catch {
7567
+ failed = null;
7568
+ }
7569
+ if (failed == null) {
7570
+ unknown.push(prUrl);
7571
+ continue;
7572
+ }
7573
+ observed.push(prUrl);
7574
+ if (!failed) continue;
7575
+ failing.push(prUrl);
7576
+ failingSubjects.set(prUrl, subjectFromCard(card, prUrl));
7577
+ }
7578
+ const ciUrls = mergeCiLatch(
7579
+ prev.ciFailed,
7580
+ prev.primed ? failing : [...failing, ...unknown],
7581
+ unknown
7582
+ );
7583
+ const ciFailed = ciUrls.map(
7584
+ (prUrl) => failingSubjects.get(prUrl) ?? { prUrl, title: prUrl }
7585
+ );
7586
+ const repos = [...new Set(deps.listRepoPaths().map((path) => path.trim()).filter(Boolean))].sort();
7587
+ const fetchedReviews = [];
7588
+ const reviewSubjects = /* @__PURE__ */ new Map();
7589
+ const successfulRepos = [];
7590
+ for (const repoPath of repos) {
7591
+ let rows;
7592
+ try {
7593
+ rows = await deps.listReviewRequested(repoPath);
7594
+ } catch {
7595
+ rows = null;
7596
+ }
7597
+ if (!rows) continue;
7598
+ successfulRepos.push(repoPath);
7599
+ for (const row of rows) {
7600
+ if (!acceptOpenReadyPr(row)) continue;
7601
+ const prUrl = normalizePrUrl(row.prUrl);
7602
+ if (!prUrl) continue;
7603
+ const card = cards.get(prUrl);
7604
+ fetchedReviews.push({ prUrl, repoPath });
7605
+ reviewSubjects.set(prUrl, {
7606
+ prUrl,
7607
+ title: row.title.trim() || card?.prTitle || prUrl,
7608
+ threadId: card?.threadId,
7609
+ threadTitle: card?.threadTitle,
7610
+ repoPath
7611
+ });
7612
+ }
7613
+ }
7614
+ const seenRepos = new Set(prev.reviewReposSeen ?? []);
7615
+ const freshRepos = new Set(
7616
+ prev.primed ? successfulRepos.filter((repo) => !seenRepos.has(repo)) : []
7617
+ );
7618
+ const reviewLatch = repos.length ? mergeReviewLatch(prev.reviewRequested, fetchedReviews, successfulRepos) : prev.reviewRequested;
7619
+ const reviewRequested = reviewLatch.filter((row) => !freshRepos.has(row.repoPath)).map(
7620
+ (row) => reviewSubjects.get(row.prUrl) ?? {
7621
+ prUrl: row.prUrl,
7622
+ title: row.prUrl,
7623
+ repoPath: row.repoPath
7624
+ }
7625
+ );
7626
+ const baseline = reviewLatch.filter((row) => freshRepos.has(row.repoPath));
7627
+ const seenCi = new Set((prev.ciSeen ?? []).map((url) => normalizePrUrl(url)).filter(Boolean));
7628
+ const freshCi = new Set(prev.primed ? observed.filter((url) => !seenCi.has(url)) : []);
7629
+ const ciForDiff = ciFailed.filter((subject) => !freshCi.has(subject.prUrl));
7630
+ const edges = diffGithubEdges({ prev, ciFailed: ciForDiff, reviewRequested, now });
7631
+ const delivered = prev.primed && edges.length ? await deliverGithubEdges(edges, deps) : [];
7632
+ const freshFailing = [...freshCi].filter((url) => failing.includes(url));
7633
+ const prevForCommit = freshFailing.length || baseline.length ? {
7634
+ ...prev,
7635
+ ...freshFailing.length ? {
7636
+ ciFailed: [
7637
+ .../* @__PURE__ */ new Set([
7638
+ ...prev.ciFailed.map((url) => normalizePrUrl(url)).filter(Boolean),
7639
+ ...freshFailing
7640
+ ])
7641
+ ]
7642
+ } : {},
7643
+ ...baseline.length ? { reviewRequested: mergeReviewLatch(prev.reviewRequested, baseline, [...freshRepos]) } : {}
7644
+ } : prev;
7645
+ const committed = commitGithubEdgeSnapshot({
7646
+ prev: prevForCommit,
7647
+ ciFailed,
7648
+ reviewRequested: reviewLatch,
7649
+ delivered,
7650
+ now
7651
+ });
7652
+ const watched = new Set(repos);
7653
+ const reviewReposSeen = [
7654
+ .../* @__PURE__ */ new Set([
7655
+ ...(prev.reviewReposSeen ?? []).filter((repo) => watched.has(repo)),
7656
+ ...successfulRepos
7657
+ ])
7658
+ ].sort();
7659
+ const cardUrls = new Set(cards.keys());
7660
+ const ciSeen = [
7661
+ .../* @__PURE__ */ new Set([
7662
+ ...(prev.ciSeen ?? []).map((url) => normalizePrUrl(url)).filter((url) => url && cardUrls.has(url)),
7663
+ ...observed
7664
+ ])
7665
+ ].sort();
7666
+ const next = {
7667
+ ...committed,
7668
+ ...reviewReposSeen.length ? { reviewReposSeen } : {},
7669
+ ...ciSeen.length ? { ciSeen } : {}
7670
+ };
7671
+ if (githubEdgeSnapshotKey(prev) !== githubEdgeSnapshotKey(next)) deps.save(next);
7672
+ return { fired: delivered.length, primed: next.primed };
7673
+ }
7674
+ async function deliverGithubEdges(edges, deps) {
7675
+ const delivered = [];
7676
+ for (const group of routeGithubEdges(edges, (threadId) => deps.parentIdForThread(threadId), deps.designatedId())) {
7677
+ const prompt = formatGithubEdgePrompt(group.edges);
7678
+ try {
7679
+ if (group.targetId) await deps.send(group.targetId, prompt);
7680
+ else await deps.startOrchestration(prompt);
7681
+ delivered.push(...group.edges);
7682
+ } catch {
7683
+ }
7684
+ }
7685
+ return delivered;
7686
+ }
7687
+ function indexCiCards(cards, parentIdForThread2) {
7688
+ const byUrl = /* @__PURE__ */ new Map();
7689
+ for (const card of cards) {
7690
+ if (!acceptOpenReadyPr(card)) continue;
7691
+ const prUrl = normalizePrUrl(card.prUrl);
7692
+ if (!prUrl) continue;
7693
+ const existing = byUrl.get(prUrl);
7694
+ if (!existing) {
7695
+ byUrl.set(prUrl, card);
7696
+ continue;
7697
+ }
7698
+ const existingParent = parentIdForThread2(existing.threadId);
7699
+ const nextParent = parentIdForThread2(card.threadId);
7700
+ if (!existingParent && nextParent) byUrl.set(prUrl, card);
7701
+ }
7702
+ return byUrl;
7703
+ }
7704
+ function subjectFromCard(card, prUrl) {
7705
+ return {
7706
+ prUrl,
7707
+ title: card.prTitle.trim() || card.threadTitle.trim() || prUrl,
7708
+ threadId: card.threadId,
7709
+ threadTitle: card.threadTitle,
7710
+ repoPath: card.repoPath,
7711
+ draft: card.draft,
7712
+ state: card.state
7713
+ };
7714
+ }
7715
+ function liveWorktreeThreads() {
7716
+ return listThreads().filter(
7717
+ (thread) => !isGlobalThread(thread) && !isOrchestratorThread(thread) && thread.wakeOnGithubEdges === true && Boolean(thread.worktreePath?.trim()) && Boolean(thread.repoPath?.trim())
7718
+ );
7719
+ }
7720
+ function listCiCardsFromStore() {
7721
+ const cards = [];
7722
+ for (const thread of liveWorktreeThreads()) {
7723
+ const prUrl = thread.prUrl?.trim() ?? "";
7724
+ if (!prUrl) continue;
7725
+ cards.push({
7726
+ threadId: thread.id,
7727
+ threadTitle: thread.title?.trim() || "Workspace",
7728
+ worktreePath: thread.worktreePath,
7729
+ repoPath: thread.repoPath,
7730
+ prUrl,
7731
+ prTitle: thread.prTitle?.trim() || thread.title?.trim() || prUrl,
7732
+ draft: thread.prIsDraft,
7733
+ state: thread.prState
7734
+ });
7735
+ }
7736
+ return cards;
7737
+ }
7738
+ function listLiveRepoPaths() {
7739
+ return [...new Set(liveWorktreeThreads().map((thread) => thread.repoPath.trim()).filter(Boolean))];
7740
+ }
7741
+ async function fetchCiFailedFromGh(card) {
7742
+ try {
7743
+ const checks = await getPrCiChecks(card.worktreePath, card.prUrl);
7744
+ if (!checks) return null;
7745
+ const failed = ciChecksFailed(checks);
7746
+ persistChecksFailed(card, failed);
7747
+ return failed;
7748
+ } catch {
7749
+ return null;
7750
+ }
7751
+ }
7752
+ function persistChecksFailed(card, failed) {
7753
+ const siblings = threadsSharingWorktree(card.worktreePath);
7754
+ const self = readThread(card.threadId);
7755
+ const targets = siblings.length > 0 ? siblings : self ? [self] : [];
7756
+ for (const thread of targets) {
7757
+ const patch = threadPrChecksFailedPatch(thread, failed);
7758
+ if (Object.keys(patch).length === 0) continue;
7759
+ try {
7760
+ updateThread(thread.id, patch);
7761
+ } catch {
7762
+ }
7763
+ }
7764
+ }
7765
+ async function listMineFromGh(repoPath) {
7766
+ try {
7767
+ const reviewLabel = resolveProjectReviewLabel(loadAppSettings(), repoPath);
7768
+ const rows = await listPrs(repoPath, {
7769
+ queue: "mine",
7770
+ limit: 30,
7771
+ strict: true,
7772
+ ...reviewLabel ? { reviewLabel } : {}
7773
+ });
7774
+ return rows.map((row) => ({
7775
+ prUrl: row.url,
7776
+ title: row.title,
7777
+ draft: row.isDraft,
7778
+ state: row.state
7779
+ }));
7780
+ } catch {
7781
+ return null;
7782
+ }
7783
+ }
7784
+ function parentIdForThread(threadId) {
7785
+ const thread = readThread(threadId);
7786
+ if (!thread || thread.status === "archived") return null;
7787
+ const parent = connectedOrchestrator(thread, (id) => readThread(id));
7788
+ if (!parent || parent.status === "archived") return null;
7789
+ return parent.id;
7790
+ }
7791
+ function designatedOrchestratorId() {
7792
+ return pickDesignatedOrchestratorId(
7793
+ listGlobalThreads().map((thread) => ({
7794
+ id: thread.id,
7795
+ status: thread.status,
7796
+ cloud: isCloudCoordinatorThread(thread)
7797
+ }))
7798
+ );
7799
+ }
7800
+ function realDeps() {
7801
+ return {
7802
+ enabled: () => wakeOrchestratorOnGithubEdgesEnabled(),
7803
+ listCiCards: listCiCardsFromStore,
7804
+ fetchCiFailed: fetchCiFailedFromGh,
7805
+ listRepoPaths: listLiveRepoPaths,
7806
+ listReviewRequested: listMineFromGh,
7807
+ parentIdForThread,
7808
+ designatedId: designatedOrchestratorId,
7809
+ send: async (threadId, prompt) => {
7810
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-HIWWPWL5.js");
7811
+ await getOrchestrator2().send(threadId, prompt, { followUp: "queue" });
7812
+ },
7813
+ startOrchestration: async (prompt) => {
7814
+ const { startOrchestration: startOrchestration2 } = await import("./orchestrator-HIWWPWL5.js");
7815
+ const defaults = resolveOrchestratorDefaults();
7816
+ await startOrchestration2({
7817
+ goal: prompt,
7818
+ agent: defaults.agent,
7819
+ model: defaults.model,
7820
+ effort: defaults.effort,
7821
+ fast: defaults.fast,
7822
+ autonomy: defaults.autonomy
7823
+ });
7824
+ },
7825
+ load: loadGithubEdgeSnapshot,
7826
+ save: saveGithubEdgeSnapshot,
7827
+ now: () => Date.now()
7828
+ };
7829
+ }
7830
+
7228
7831
  // src/orchestrator/schedule-runner.ts
7229
7832
  var SET_TIMEOUT_MAX = 2147483647;
7230
7833
  var fireHooks = null;
@@ -7235,7 +7838,7 @@ function formatScheduledPrompt(name, prompt) {
7235
7838
  ${prompt}`;
7236
7839
  }
7237
7840
  async function defaultDeps() {
7238
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-NOQDMYLB.js");
7841
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-HIWWPWL5.js");
7239
7842
  const orch = getOrchestrator2();
7240
7843
  return {
7241
7844
  findThread: (id) => findThreadByRef(id),
@@ -7335,8 +7938,8 @@ async function fireSchedule(id) {
7335
7938
  }
7336
7939
  }
7337
7940
  function clearTimer(id) {
7338
- const timer = timers.get(id);
7339
- if (timer) clearTimeout(timer);
7941
+ const timer2 = timers.get(id);
7942
+ if (timer2) clearTimeout(timer2);
7340
7943
  timers.delete(id);
7341
7944
  }
7342
7945
  function armOne(schedule) {
@@ -7352,7 +7955,7 @@ function armOne(schedule) {
7352
7955
  return;
7353
7956
  }
7354
7957
  const capped = Math.min(delay, SET_TIMEOUT_MAX);
7355
- const timer = setTimeout(() => {
7958
+ const timer2 = setTimeout(() => {
7356
7959
  timers.delete(schedule.id);
7357
7960
  const live = getSchedule(schedule.id);
7358
7961
  if (!live?.enabled) return;
@@ -7365,7 +7968,7 @@ function armOne(schedule) {
7365
7968
  if (isThisProcessDesktopHost()) armSchedules();
7366
7969
  });
7367
7970
  }, capped);
7368
- timers.set(schedule.id, timer);
7971
+ timers.set(schedule.id, timer2);
7369
7972
  }
7370
7973
  function armSchedules() {
7371
7974
  if (!isThisProcessDesktopHost()) return;
@@ -7524,7 +8127,7 @@ var Orchestrator = class {
7524
8127
  this.lightReconcileAt.set(repoPath, Date.now());
7525
8128
  for (const thread of listThreads()) {
7526
8129
  if (isGlobalThread(thread) || thread.repoPath !== repoPath) continue;
7527
- if (!existsSync13(thread.worktreePath)) {
8130
+ if (!existsSync14(thread.worktreePath)) {
7528
8131
  setStatus(thread.id, "broken", "Worktree missing on disk");
7529
8132
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
7530
8133
  }
@@ -7553,7 +8156,7 @@ var Orchestrator = class {
7553
8156
  }
7554
8157
  continue;
7555
8158
  }
7556
- if (!existsSync13(thread.worktreePath)) {
8159
+ if (!existsSync14(thread.worktreePath)) {
7557
8160
  setStatus(thread.id, "broken", "Worktree missing on disk");
7558
8161
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
7559
8162
  continue;
@@ -7579,6 +8182,7 @@ var Orchestrator = class {
7579
8182
  }
7580
8183
  this.schedulePendingQuotaResumes();
7581
8184
  armSchedules();
8185
+ armGithubEdgeWatch();
7582
8186
  }
7583
8187
  /** Surface (and, when enabled, clean up) worktrees git knows about but no thread owns. */
7584
8188
  async reconcileOrphans(repoPaths) {
@@ -7590,7 +8194,7 @@ var Orchestrator = class {
7590
8194
  orphans: orphans.map((o) => ({ path: o.path, repoPath: o.repoPath }))
7591
8195
  });
7592
8196
  }
7593
- const { autoCleanupOrphansEnabled } = await import("./app-settings-KOSVLMO5.js");
8197
+ const { autoCleanupOrphansEnabled } = await import("./app-settings-FS7TM55D.js");
7594
8198
  if (autoCleanupOrphansEnabled() && shouldRunWorktreeCleanup() && orphans.length > 0) {
7595
8199
  await cleanupOrphanWorktrees({ repoPaths });
7596
8200
  }
@@ -7717,8 +8321,8 @@ var Orchestrator = class {
7717
8321
  }
7718
8322
  }
7719
8323
  clearQuotaResumeTimer(threadId) {
7720
- const timer = this.quotaResumeTimers.get(threadId);
7721
- if (timer) clearTimeout(timer);
8324
+ const timer2 = this.quotaResumeTimers.get(threadId);
8325
+ if (timer2) clearTimeout(timer2);
7722
8326
  this.quotaResumeTimers.delete(threadId);
7723
8327
  }
7724
8328
  /** Schedule (or fire) auto-retry after a provider session/usage limit reset. */
@@ -7727,11 +8331,11 @@ var Orchestrator = class {
7727
8331
  updateThread(threadId, { quotaResumeAt: resumeAt.toISOString() });
7728
8332
  const delay = Math.max(5e3, resumeAt.getTime() - Date.now());
7729
8333
  const capped = Math.min(delay, 2147483647);
7730
- const timer = setTimeout(() => {
8334
+ const timer2 = setTimeout(() => {
7731
8335
  this.quotaResumeTimers.delete(threadId);
7732
8336
  void this.resumeAfterQuotaWait(threadId);
7733
8337
  }, capped);
7734
- this.quotaResumeTimers.set(threadId, timer);
8338
+ this.quotaResumeTimers.set(threadId, timer2);
7735
8339
  }
7736
8340
  schedulePendingQuotaResumes() {
7737
8341
  for (const thread of listThreads({ includeArchived: false })) {
@@ -7980,7 +8584,7 @@ var Orchestrator = class {
7980
8584
  }
7981
8585
  await setup;
7982
8586
  if (skipSetup) return;
7983
- const { autoRunAfterSetupEnabled } = await import("./app-settings-KOSVLMO5.js");
8587
+ const { autoRunAfterSetupEnabled } = await import("./app-settings-FS7TM55D.js");
7984
8588
  if (autoRunAfterSetupEnabled()) {
7985
8589
  try {
7986
8590
  await this.startDev(threadId);
@@ -8365,7 +8969,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8365
8969
  }
8366
8970
  const isBrightsy = fresh.agent === "brightsy";
8367
8971
  const isOrchestration = isOrchestratorThread(fresh);
8368
- const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-KOSVLMO5.js");
8972
+ const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-FS7TM55D.js");
8369
8973
  const gitAuthMode = getGithubGitAuthMode();
8370
8974
  const worktreeDirective = isBrightsy || isOrchestration ? null : formatWorktreeDirective(fresh, {
8371
8975
  githubSlug: turnOrigin?.forge === "github" ? turnOrigin.slug : await withTimeout(resolveGithubRepoSlug(fresh.worktreePath), 8e3, "resolveGithubRepoSlug").catch(() => null),
@@ -9379,11 +9983,11 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9379
9983
  const start = Date.now();
9380
9984
  return new Promise((resolve, reject) => {
9381
9985
  let settled = false;
9382
- let timer;
9986
+ let timer2;
9383
9987
  const finish2 = (fn) => {
9384
9988
  if (settled) return;
9385
9989
  settled = true;
9386
- if (timer) clearInterval(timer);
9990
+ if (timer2) clearInterval(timer2);
9387
9991
  off();
9388
9992
  fn();
9389
9993
  };
@@ -9409,7 +10013,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9409
10013
  }
9410
10014
  }
9411
10015
  });
9412
- timer = setInterval(() => {
10016
+ timer2 = setInterval(() => {
9413
10017
  const raw = readThread(thread.id);
9414
10018
  if (!raw) {
9415
10019
  finish2(() => reject(new Error(`Thread not found: ${thread.id}`)));
@@ -9708,7 +10312,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9708
10312
  if (Object.keys(patch).length === 0) continue;
9709
10313
  updateThread(t.id, patch);
9710
10314
  }
9711
- const { autoArchiveOnMergeEnabled } = await import("./app-settings-KOSVLMO5.js");
10315
+ const { autoArchiveOnMergeEnabled } = await import("./app-settings-FS7TM55D.js");
9712
10316
  const latest = this.requireThread(thread.id);
9713
10317
  if (!shouldAutoArchiveOnPrMerge({
9714
10318
  previousPrState: prevState || null,
@@ -10032,7 +10636,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10032
10636
  await runArchiveScript(thread.repoPath, thread.worktreePath);
10033
10637
  } catch {
10034
10638
  }
10035
- const { deleteBranchOnPurgeEnabled } = await import("./app-settings-KOSVLMO5.js");
10639
+ const { deleteBranchOnPurgeEnabled } = await import("./app-settings-FS7TM55D.js");
10036
10640
  const deleteBranch = opts?.deleteBranch ?? deleteBranchOnPurgeEnabled();
10037
10641
  await removeWorktree(thread.repoPath, thread.worktreePath, {
10038
10642
  deleteBranch: deleteBranch ? thread.branchName : void 0
@@ -10054,7 +10658,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10054
10658
  this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
10055
10659
  return restored2;
10056
10660
  }
10057
- if (!existsSync13(thread.worktreePath)) {
10661
+ if (!existsSync14(thread.worktreePath)) {
10058
10662
  if (isCowboyThread(thread) || isPrimaryCheckoutThread(thread)) {
10059
10663
  throw new Error(
10060
10664
  `Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
@@ -10170,7 +10774,7 @@ async function startOrchestration(opts) {
10170
10774
  sourceRef: "default",
10171
10775
  ...createOpts
10172
10776
  }).catch(async () => {
10173
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-GWS77LWX.js");
10777
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-QBVLKACU.js");
10174
10778
  const repo = await resolveRepoRoot2(repoPath);
10175
10779
  const def = await resolveDefaultBranch2(repo);
10176
10780
  return orch.createThread({
@@ -10180,7 +10784,7 @@ async function startOrchestration(opts) {
10180
10784
  repoPath: repo
10181
10785
  });
10182
10786
  });
10183
- const { updateThread: upd } = await import("./thread-store-QGBPSZU2.js");
10787
+ const { updateThread: upd } = await import("./thread-store-ILM2ZJCB.js");
10184
10788
  const updated = upd(thread.id, {
10185
10789
  sourceType: "orchestration",
10186
10790
  sourceRef: goal
@@ -10377,6 +10981,7 @@ export {
10377
10981
  formatListedIssuesForMcp,
10378
10982
  mcpJson,
10379
10983
  registerViewerContextTools,
10984
+ armGithubEdgeWatch,
10380
10985
  LIVE_TURN_SPAWN_GRACE_MS,
10381
10986
  RUN_SCRIPT_DESKTOP_ADOPT_MS,
10382
10987
  resolveOrchChildFollowUp,