@sideboard-ai/core 0.1.347 → 0.1.349

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 (41) hide show
  1. package/dist/agents/cursor-runner.js +3 -3
  2. package/dist/{agents-5MFGVK7C.js → agents-AZ2PV6XP.js} +7 -7
  3. package/dist/{agents-T4XBZZDA.js → agents-DMPBFF3F.js} +5 -5
  4. package/dist/{chunk-UGUWFONI.js → chunk-2E2HMJDU.js} +1 -1
  5. package/dist/{chunk-NTY5WGRD.js → chunk-3DBL2C45.js} +1 -1
  6. package/dist/{chunk-MOUAM6ZC.js → chunk-6RIPZ73M.js} +132 -2
  7. package/dist/{chunk-6TV6L2DD.js → chunk-CATTIFSP.js} +6 -5
  8. package/dist/{chunk-IJNTTVFH.js → chunk-IRFBD6GU.js} +247 -66
  9. package/dist/{chunk-ORO4ENZR.js → chunk-LESWJ7L4.js} +1 -0
  10. package/dist/{chunk-XNGW4OYD.js → chunk-MHSBF3SO.js} +6 -5
  11. package/dist/{chunk-ZJMYCDYQ.js → chunk-MVFFLU5V.js} +47 -9
  12. package/dist/{chunk-OPXEJJBM.js → chunk-PWOFUPYM.js} +1 -0
  13. package/dist/{chunk-27XWAI7S.js → chunk-Q4I6KDOL.js} +251 -70
  14. package/dist/{chunk-2HPVGTHF.js → chunk-QHXZKHUL.js} +1 -1
  15. package/dist/{chunk-GAGTEI6B.js → chunk-ROXM6QZV.js} +48 -10
  16. package/dist/{chunk-ATS7SYHG.js → chunk-RPHH4FNK.js} +132 -2
  17. package/dist/{chunk-Y6VQX2LY.js → chunk-WHMLMCPU.js} +11 -5
  18. package/dist/{chunk-BIM24I3O.js → chunk-WWBPK7GB.js} +1 -1
  19. package/dist/{chunk-5YCKATG6.js → chunk-YVN7L4KG.js} +1 -1
  20. package/dist/{chunk-Q4TZA4MN.js → chunk-ZXI5DR5S.js} +12 -6
  21. package/dist/{conductor-EMGMDNHL.js → conductor-65VPUPOW.js} +6 -6
  22. package/dist/{conductor-LYQKONSA.js → conductor-NHC6X74J.js} +5 -5
  23. package/dist/{coordinator-prompt-DLY3FS2L.js → coordinator-prompt-5GZWIVSY.js} +3 -3
  24. package/dist/{coordinator-prompt-WALVMGKI.js → coordinator-prompt-R2PURZL3.js} +3 -3
  25. package/dist/{global-workspace-UG2A3CEM.js → global-workspace-64KC7PST.js} +3 -3
  26. package/dist/{global-workspace-7OQ5O6JT.js → global-workspace-UEECLWSX.js} +3 -3
  27. package/dist/index.cjs +1321 -858
  28. package/dist/index.d.cts +31 -8
  29. package/dist/index.d.ts +31 -8
  30. package/dist/index.js +446 -365
  31. package/dist/mcp/run-stdio.cjs +1055 -594
  32. package/dist/mcp/run-stdio.js +296 -216
  33. package/dist/{orchestrator-AJZNVREM.js → orchestrator-I5G5A5BV.js} +7 -7
  34. package/dist/{orchestrator-BUEPWNCF.js → orchestrator-Y5PYSMR6.js} +9 -9
  35. package/dist/{thread-store-R3G5VBII.js → thread-store-HZ4U4OXB.js} +1 -1
  36. package/dist/{thread-store-MEUWZDVV.js → thread-store-QKNU5CHM.js} +1 -1
  37. package/dist/{workspaces-KWGTP7DI.js → workspaces-6TIM2TM2.js} +3 -3
  38. package/dist/{workspaces-35T6FW57.js → workspaces-I2EHNTFE.js} +3 -3
  39. package/dist/{worktree-ROJXGBWS.js → worktree-7JFYDNUX.js} +2 -2
  40. package/dist/{worktree-5P7SCST3.js → worktree-M2GJGK2P.js} +2 -2
  41. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -222,7 +222,7 @@ import {
222
222
  worktreeCleanupSettings,
223
223
  writeAgentBlock,
224
224
  writeWorktreeFile
225
- } from "./chunk-IJNTTVFH.js";
225
+ } from "./chunk-IRFBD6GU.js";
226
226
  import {
227
227
  OPTIONAL_SERVICES,
228
228
  OPTIONAL_SERVICE_IDS,
@@ -383,7 +383,7 @@ import {
383
383
  userMcpNamesToDisable,
384
384
  worktreeMcpToolNames,
385
385
  writeInjectedMcpConfig
386
- } from "./chunk-Q4TZA4MN.js";
386
+ } from "./chunk-ZXI5DR5S.js";
387
387
  import {
388
388
  getAgentSetupInfo,
389
389
  installAgent,
@@ -442,6 +442,7 @@ import {
442
442
  buildWorkspaceScriptEnv,
443
443
  canReuseIdleWorktreeAgentForReview,
444
444
  captureLoginEnv,
445
+ classifyTurnFailure,
445
446
  compactArchiveProse,
446
447
  copyConfiguredFiles,
447
448
  createChatTab,
@@ -517,7 +518,7 @@ import {
517
518
  workspaceAgentChatSummaries,
518
519
  worktreeRunPortsPath,
519
520
  wrapReviewSkillMarkdown
520
- } from "./chunk-GAGTEI6B.js";
521
+ } from "./chunk-ROXM6QZV.js";
521
522
  import {
522
523
  STDERR_EVENT_MAX_CHARS,
523
524
  STDOUT_EVENT_MAX_CHARS,
@@ -559,7 +560,7 @@ import {
559
560
  visibleToolRowDetail,
560
561
  withEventParentId,
561
562
  withEventsParentId
562
- } from "./chunk-BIM24I3O.js";
563
+ } from "./chunk-WWBPK7GB.js";
563
564
  import "./chunk-7H655NEW.js";
564
565
  import {
565
566
  ABLETIME_OAUTH_CALLBACK_PATH,
@@ -660,7 +661,7 @@ import {
660
661
  stageBuffersAsAttachments,
661
662
  syncWorkspacesFromThreads,
662
663
  takenTeamSlugsForOrchestration
663
- } from "./chunk-XNGW4OYD.js";
664
+ } from "./chunk-MHSBF3SO.js";
664
665
  import {
665
666
  GITHUB_PR_BODY_MAX_CHARS,
666
667
  GITHUB_PR_BODY_SAFE_CHARS,
@@ -750,14 +751,16 @@ import {
750
751
  suggestSlug,
751
752
  switchWorktreeBranch,
752
753
  warmGithubAgentAuth
753
- } from "./chunk-NTY5WGRD.js";
754
+ } from "./chunk-3DBL2C45.js";
754
755
  import {
755
756
  FAMOUS_SOCCER_TEAMS,
756
757
  SCHEDULE_RUN_HISTORY_LIMIT,
757
758
  WEEKDAY_LABELS,
759
+ addChatFollowUp,
758
760
  allocateTeamName,
759
761
  appendMessage,
760
762
  branchDisplayLabel,
763
+ ciChecksSettled,
761
764
  computeNextRunAt,
762
765
  createEmptyThread,
763
766
  createSchedule,
@@ -778,6 +781,7 @@ import {
778
781
  listSchedules,
779
782
  listThreads,
780
783
  lookupSoccerTeam,
784
+ normalizeChatFollowUps,
781
785
  normalizeThread,
782
786
  normalizeWeekdays,
783
787
  normalizeWeeklyTime,
@@ -807,7 +811,7 @@ import {
807
811
  worktreeNameFromPath,
808
812
  worktreeSlugForTicket,
809
813
  writeThread
810
- } from "./chunk-ATS7SYHG.js";
814
+ } from "./chunk-RPHH4FNK.js";
811
815
  import "./chunk-BMRJNRQK.js";
812
816
  import {
813
817
  BRIGHTSY_OAUTH_CLIENT_ID,
@@ -858,7 +862,7 @@ import {
858
862
  import {
859
863
  clipMcpToolResult,
860
864
  cursorToolErrorText
861
- } from "./chunk-5YCKATG6.js";
865
+ } from "./chunk-YVN7L4KG.js";
862
866
  import "./chunk-AXQ4ZWHK.js";
863
867
  import {
864
868
  AGENT_RUNNER_MAX_OLD_SPACE_MB,
@@ -876,8 +880,8 @@ import {
876
880
  trustSystemCertificates,
877
881
  turnCostUsdFromCursorUsage,
878
882
  withMaxOldSpaceSize
879
- } from "./chunk-UGUWFONI.js";
880
- import "./chunk-OPXEJJBM.js";
883
+ } from "./chunk-2E2HMJDU.js";
884
+ import "./chunk-PWOFUPYM.js";
881
885
  import {
882
886
  ATTACHMENTS_DIR,
883
887
  CLI_DIR,
@@ -1397,16 +1401,16 @@ function concat(parts) {
1397
1401
  }
1398
1402
  return out;
1399
1403
  }
1400
- function utf8(text5) {
1401
- return new TextEncoder().encode(text5);
1404
+ function utf8(text6) {
1405
+ return new TextEncoder().encode(text6);
1402
1406
  }
1403
1407
  function bytesToB64url(bytes) {
1404
1408
  let binary = "";
1405
1409
  for (const byte of bytes) binary += String.fromCharCode(byte);
1406
1410
  return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
1407
1411
  }
1408
- function b64urlToBytes(text5) {
1409
- const padded = text5.replaceAll("-", "+").replaceAll("_", "/") + "=".repeat((4 - text5.length % 4) % 4);
1412
+ function b64urlToBytes(text6) {
1413
+ const padded = text6.replaceAll("-", "+").replaceAll("_", "/") + "=".repeat((4 - text6.length % 4) % 4);
1410
1414
  const binary = atob(padded);
1411
1415
  const out = new Uint8Array(binary.length);
1412
1416
  for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);
@@ -1597,18 +1601,18 @@ function lastVisibleMessage(messages) {
1597
1601
  const m = messages[i];
1598
1602
  if (!m) continue;
1599
1603
  if (m.role === "agent") {
1600
- const text5 = (lastAssistantMessageText(m.parts) || m.text || "").trim();
1601
- if (text5 && !isInternalAgentStatusText(text5)) return m;
1604
+ const text6 = (lastAssistantMessageText(m.parts) || m.text || "").trim();
1605
+ if (text6 && !isInternalAgentStatusText(text6)) return m;
1602
1606
  continue;
1603
1607
  }
1604
1608
  if (m.role === "user" && m.text?.trim()) return m;
1605
1609
  }
1606
1610
  return void 0;
1607
1611
  }
1608
- function agentStub(source, text5, usage) {
1612
+ function agentStub(source, text6, usage) {
1609
1613
  return {
1610
1614
  role: "agent",
1611
- text: text5,
1615
+ text: text6,
1612
1616
  ts: source.ts,
1613
1617
  ...usage ? { usage } : {}
1614
1618
  };
@@ -2668,11 +2672,11 @@ function fenceLanguage(path2, language) {
2668
2672
  }
2669
2673
  function buildCodeRefAttachment(input) {
2670
2674
  const path2 = input.path.trim();
2671
- const text5 = input.text.replace(/\n$/, "");
2675
+ const text6 = input.text.replace(/\n$/, "");
2672
2676
  if (!path2) {
2673
2677
  throw new Error("code reference requires a file path");
2674
2678
  }
2675
- if (!text5.trim()) {
2679
+ if (!text6.trim()) {
2676
2680
  throw new Error("code reference requires selected text");
2677
2681
  }
2678
2682
  if (input.startLine < 1 || input.endLine < 1 || input.endLine < input.startLine) {
@@ -2685,7 +2689,7 @@ function buildCodeRefAttachment(input) {
2685
2689
  `Referenced code from \`${path2}\` (${range}).`,
2686
2690
  "",
2687
2691
  fence,
2688
- text5,
2692
+ text6,
2689
2693
  "```"
2690
2694
  ].join("\n");
2691
2695
  return {
@@ -2833,9 +2837,9 @@ function isArtifactTool(name) {
2833
2837
  const short = name.split("__").pop() ?? name;
2834
2838
  return /^(present_artifact|create_artifact|update_artifact)$/i.test(short);
2835
2839
  }
2836
- function phoneArtifactText(text5, parts, limit = Number.POSITIVE_INFINITY) {
2840
+ function phoneArtifactText(text6, parts, limit = Number.POSITIVE_INFINITY) {
2837
2841
  const hints = /* @__PURE__ */ new Set();
2838
- const body = text5.replace(new RegExp(FENCE_RE.source, "g"), (full, language, content) => {
2842
+ const body = text6.replace(new RegExp(FENCE_RE.source, "g"), (full, language, content) => {
2839
2843
  const kind = kindFor(language, content);
2840
2844
  if (!kind) return full;
2841
2845
  const hint = artifactHint(content);
@@ -3089,11 +3093,11 @@ function parsePhoneCodeRefs(value) {
3089
3093
  const startLine = lineNumber(item, "startLine");
3090
3094
  const endLine = lineNumber(item, "endLine");
3091
3095
  const textRaw = item.text;
3092
- const text5 = typeof textRaw === "string" ? textRaw.replace(/\n$/, "").slice(0, MAX_TEXT) : "";
3093
- if (!path2 || !startLine || !endLine || endLine < startLine || !text5.trim()) return "invalid";
3094
- total += text5.length;
3096
+ const text6 = typeof textRaw === "string" ? textRaw.replace(/\n$/, "").slice(0, MAX_TEXT) : "";
3097
+ if (!path2 || !startLine || !endLine || endLine < startLine || !text6.trim()) return "invalid";
3098
+ total += text6.length;
3095
3099
  if (total > MAX_TOTAL) return "invalid";
3096
- refs.push({ path: path2, startLine, endLine, text: text5 });
3100
+ refs.push({ path: path2, startLine, endLine, text: text6 });
3097
3101
  }
3098
3102
  return refs;
3099
3103
  }
@@ -3253,9 +3257,9 @@ async function getGitHubStatus() {
3253
3257
  };
3254
3258
  }
3255
3259
  const status = await run("gh", ["auth", "status"], { reject: false });
3256
- const text5 = `${status.stdout}
3260
+ const text6 = `${status.stdout}
3257
3261
  ${status.stderr}`;
3258
- const loginMatch = text5.match(/Logged in to ([^\s]+) account (\S+)/i) ?? text5.match(/Logged in to ([^\s]+) as (\S+)/i);
3262
+ const loginMatch = text6.match(/Logged in to ([^\s]+) account (\S+)/i) ?? text6.match(/Logged in to ([^\s]+) as (\S+)/i);
3259
3263
  if (loginMatch) {
3260
3264
  return {
3261
3265
  connected: true,
@@ -3327,9 +3331,9 @@ function parsePhoneMcpUi(value, op, chatId) {
3327
3331
  }
3328
3332
  if (op === "mcp-ui-context") {
3329
3333
  const reqId2 = controlText(value, "reqId");
3330
- const text5 = controlText(value, "text");
3331
- if (!reqId2 || reqId2.length > 40 || !text5 || text5.length > 8e3) return "invalid";
3332
- return { op, chatId, reqId: reqId2, text: text5 };
3334
+ const text6 = controlText(value, "text");
3335
+ if (!reqId2 || reqId2.length > 40 || !text6 || text6.length > 8e3) return "invalid";
3336
+ return { op, chatId, reqId: reqId2, text: text6 };
3333
3337
  }
3334
3338
  if (op !== "mcp-ui-call" && op !== "mcp-ui-read") return "invalid";
3335
3339
  const reqId = controlText(value, "reqId");
@@ -3393,30 +3397,30 @@ var PHONE_USER_PREFIX = "Phone\n\n";
3393
3397
  var TRANSCRIPT_LIMIT = 40;
3394
3398
  var MESSAGE_LIMIT = 4e3;
3395
3399
  var CRASH_CONTINUE_PREFIX = "The previous agent process ended before it finished.";
3396
- function isHostContinuePrompt(text5) {
3397
- const trimmed = text5.trim();
3400
+ function isHostContinuePrompt(text6) {
3401
+ const trimmed = text6.trim();
3398
3402
  return isJobContinuePrompt(trimmed) || trimmed.startsWith(CRASH_CONTINUE_PREFIX);
3399
3403
  }
3400
- function phoneVisibleText(role, text5) {
3401
- const trimmed = text5.trim();
3404
+ function phoneVisibleText(role, text6) {
3405
+ const trimmed = text6.trim();
3402
3406
  if (role === "user" && trimmed.startsWith(PHONE_USER_PREFIX)) {
3403
3407
  return trimmed.slice(PHONE_USER_PREFIX.length).trim();
3404
3408
  }
3405
3409
  return trimmed;
3406
3410
  }
3407
- function clip(text5, limit) {
3408
- if (text5.length <= limit) return text5;
3409
- return `${text5.slice(0, limit - 1)}\u2026`;
3411
+ function clip(text6, limit) {
3412
+ if (text6.length <= limit) return text6;
3413
+ return `${text6.slice(0, limit - 1)}\u2026`;
3410
3414
  }
3411
3415
  function withLiveTail(thread, messages) {
3412
3416
  if (thread.status !== "running" && thread.status !== "queued") return messages;
3413
- const text5 = clip(phoneStreamFrame(readTurnLiveParts(thread.id)).text.trim(), MESSAGE_LIMIT);
3414
- if (!text5) return messages;
3417
+ const text6 = clip(phoneStreamFrame(readTurnLiveParts(thread.id)).text.trim(), MESSAGE_LIMIT);
3418
+ if (!text6) return messages;
3415
3419
  const last = messages[messages.length - 1];
3416
- if (last?.role === "agent" && last.text === text5) {
3420
+ if (last?.role === "agent" && last.text === text6) {
3417
3421
  return last.streaming ? messages : [...messages.slice(0, -1), { ...last, streaming: true }];
3418
3422
  }
3419
- return [...messages, { role: "agent", text: text5, streaming: true }];
3423
+ return [...messages, { role: "agent", text: text6, streaming: true }];
3420
3424
  }
3421
3425
  function listPhoneMessages(thread) {
3422
3426
  const out = [];
@@ -3427,16 +3431,16 @@ function listPhoneMessages(thread) {
3427
3431
  }
3428
3432
  const names = (message.attachments ?? []).map((item) => item.name.trim()).filter(Boolean);
3429
3433
  const visible = [phoneVisibleText(message.role, message.text), names.length ? names.join(", ") : ""].filter(Boolean).join("\n");
3430
- const text5 = message.role === "agent" ? phoneArtifactText(visible, message.parts, MESSAGE_LIMIT) : clip(visible, MESSAGE_LIMIT);
3434
+ const text6 = message.role === "agent" ? phoneArtifactText(visible, message.parts, MESSAGE_LIMIT) : clip(visible, MESSAGE_LIMIT);
3431
3435
  const apps = message.role === "agent" ? phoneMcpApps(thread.agent, message.parts) : [];
3432
- if (!text5 && apps.length === 0) continue;
3433
- out.push({ role: message.role, text: text5, ...apps.length ? { apps } : {} });
3436
+ if (!text6 && apps.length === 0) continue;
3437
+ out.push({ role: message.role, text: text6, ...apps.length ? { apps } : {} });
3434
3438
  }
3435
3439
  const live = withLiveTail(thread, out);
3436
3440
  for (const prompt of thread.queue) {
3437
3441
  if (isHostContinuePrompt(prompt)) continue;
3438
- const text5 = clip(phoneVisibleText("user", prompt), MESSAGE_LIMIT);
3439
- if (text5) live.push({ role: "user", text: text5 });
3442
+ const text6 = clip(phoneVisibleText("user", prompt), MESSAGE_LIMIT);
3443
+ if (text6) live.push({ role: "user", text: text6 });
3440
3444
  }
3441
3445
  return live.slice(-TRANSCRIPT_LIMIT);
3442
3446
  }
@@ -3508,11 +3512,11 @@ var MAX_DICTATION_CHARS = Math.ceil(12 * 1024 * 1024 * 4 / 3);
3508
3512
  function encodePhoneControl(payload) {
3509
3513
  return PHONE_CONTROL_PREFIX + JSON.stringify(payload);
3510
3514
  }
3511
- function takePhoneControl(text5) {
3512
- if (!text5.startsWith(PHONE_CONTROL_PREFIX)) return null;
3515
+ function takePhoneControl(text6) {
3516
+ if (!text6.startsWith(PHONE_CONTROL_PREFIX)) return null;
3513
3517
  let parsed;
3514
3518
  try {
3515
- parsed = JSON.parse(text5.slice(PHONE_CONTROL_PREFIX.length));
3519
+ parsed = JSON.parse(text6.slice(PHONE_CONTROL_PREFIX.length));
3516
3520
  } catch {
3517
3521
  return "invalid";
3518
3522
  }
@@ -3582,10 +3586,10 @@ function parsePhoneControl(value) {
3582
3586
  if (draft === "invalid") return "invalid";
3583
3587
  if (op === "options") return { op: "options", chatId, ...draft };
3584
3588
  if (op === "prompt") {
3585
- const text5 = typeof value.text === "string" ? value.text.trim() : "";
3586
- const hasPayload = Boolean(text5 || draft.files?.length || draft.links?.length || draft.refs?.length);
3589
+ const text6 = typeof value.text === "string" ? value.text.trim() : "";
3590
+ const hasPayload = Boolean(text6 || draft.files?.length || draft.links?.length || draft.refs?.length);
3587
3591
  if (!hasPayload) return "invalid";
3588
- return { op: "prompt", chatId, text: text5, ...draft };
3592
+ return { op: "prompt", chatId, text: text6, ...draft };
3589
3593
  }
3590
3594
  return "invalid";
3591
3595
  }
@@ -3982,8 +3986,8 @@ function outboundReplyFromTurn(result, copy) {
3982
3986
  case "working":
3983
3987
  return copy.failed(`turn still ${result.taskState}`);
3984
3988
  default: {
3985
- const text5 = result.text.trim();
3986
- return text5 || copy.completedEmpty(result.status);
3989
+ const text6 = result.text.trim();
3990
+ return text6 || copy.completedEmpty(result.status);
3987
3991
  }
3988
3992
  }
3989
3993
  }
@@ -4227,26 +4231,26 @@ var IMAGE_MIME = {
4227
4231
  bmp: "image/bmp"
4228
4232
  };
4229
4233
  function phoneWorktreeRelative(worktreePath, raw) {
4230
- let text5 = raw.trim();
4231
- if (!text5) return null;
4232
- if (/^file:\/\//i.test(text5)) {
4234
+ let text6 = raw.trim();
4235
+ if (!text6) return null;
4236
+ if (/^file:\/\//i.test(text6)) {
4233
4237
  try {
4234
- text5 = decodeURIComponent(new URL(text5).pathname);
4238
+ text6 = decodeURIComponent(new URL(text6).pathname);
4235
4239
  } catch {
4236
4240
  return null;
4237
4241
  }
4238
4242
  }
4239
- text5 = (text5.split("#")[0] ?? text5).replace(/\\/g, "/");
4240
- if (!text5 || text5.includes("\0") || text5.split("/").includes("..")) return null;
4243
+ text6 = (text6.split("#")[0] ?? text6).replace(/\\/g, "/");
4244
+ if (!text6 || text6.includes("\0") || text6.split("/").includes("..")) return null;
4241
4245
  const root = worktreePath.replace(/\/+$/, "");
4242
4246
  if (!root || root === "/") return null;
4243
- if (text5.startsWith("/")) {
4244
- if (text5 !== root && !text5.startsWith(`${root}/`)) return null;
4245
- text5 = text5 === root ? "" : text5.slice(root.length + 1);
4247
+ if (text6.startsWith("/")) {
4248
+ if (text6 !== root && !text6.startsWith(`${root}/`)) return null;
4249
+ text6 = text6 === root ? "" : text6.slice(root.length + 1);
4246
4250
  }
4247
- text5 = text5.replace(/^\.\//, "").replace(/\/+$/, "");
4248
- if (!text5 || text5 === "." || text5.startsWith("/")) return null;
4249
- return text5;
4251
+ text6 = text6.replace(/^\.\//, "").replace(/\/+$/, "");
4252
+ if (!text6 || text6 === "." || text6.startsWith("/")) return null;
4253
+ return text6;
4250
4254
  }
4251
4255
  function phoneImageMime(relativePath) {
4252
4256
  const ext = relativePath.split(".").pop()?.toLowerCase() ?? "";
@@ -4424,11 +4428,11 @@ function textField2(value, key) {
4424
4428
  const raw = value[key];
4425
4429
  return typeof raw === "string" ? raw.trim() : "";
4426
4430
  }
4427
- function takePhonePermission(text5) {
4428
- if (!text5.startsWith(PHONE_CONTROL_PREFIX2)) return null;
4431
+ function takePhonePermission(text6) {
4432
+ if (!text6.startsWith(PHONE_CONTROL_PREFIX2)) return null;
4429
4433
  let parsed;
4430
4434
  try {
4431
- parsed = JSON.parse(text5.slice(PHONE_CONTROL_PREFIX2.length));
4435
+ parsed = JSON.parse(text6.slice(PHONE_CONTROL_PREFIX2.length));
4432
4436
  } catch {
4433
4437
  return null;
4434
4438
  }
@@ -4440,8 +4444,8 @@ function takePhonePermission(text5) {
4440
4444
  if (!chatId || !id || !DECISIONS.has(decision)) return "invalid";
4441
4445
  return { op: "permission", chatId, id, decision };
4442
4446
  }
4443
- function dispatchPhonePermission(text5, emit) {
4444
- const cmd = takePhonePermission(text5);
4447
+ function dispatchPhonePermission(text6, emit) {
4448
+ const cmd = takePhonePermission(text6);
4445
4449
  if (cmd == null) return false;
4446
4450
  if (cmd === "invalid") {
4447
4451
  emit({ op: "error", message: "invalid phone command" });
@@ -4498,7 +4502,7 @@ function extractGitHubIssueAttachments(issue) {
4498
4502
  const texts = [issue.body ?? "", ...issue.comments.map((comment) => comment.body)];
4499
4503
  return mergeIssueAttachments(
4500
4504
  texts.flatMap(
4501
- (text5) => extractHttpUrls(text5).filter(isGitHubIssueAttachmentUrl).map((url) => ({
4505
+ (text6) => extractHttpUrls(text6).filter(isGitHubIssueAttachmentUrl).map((url) => ({
4502
4506
  id: url,
4503
4507
  name: url.split("/").pop() || "attachment",
4504
4508
  url
@@ -4529,11 +4533,11 @@ async function downloadGitHubIssueAttachment(input, opts) {
4529
4533
 
4530
4534
  // src/integrations/github-projects.ts
4531
4535
  function rewriteGitHubProjectReadError(detail) {
4532
- const text5 = detail.trim() || "gh could not read GitHub Projects";
4533
- if (/read:project|project scope|missing required scopes/i.test(text5)) {
4534
- return `${text5} \u2014 run \`gh auth refresh -s read:project\` so Sideboard can read GitHub Projects.`;
4536
+ const text6 = detail.trim() || "gh could not read GitHub Projects";
4537
+ if (/read:project|project scope|missing required scopes/i.test(text6)) {
4538
+ return `${text6} \u2014 run \`gh auth refresh -s read:project\` so Sideboard can read GitHub Projects.`;
4535
4539
  }
4536
- return text5;
4540
+ return text6;
4537
4541
  }
4538
4542
  function githubProjectsUnreadable(result) {
4539
4543
  return /project|scope|unknown json field/i.test(`${result.stderr}
@@ -5281,13 +5285,13 @@ async function listPhoneSources(repoPath, query) {
5281
5285
  }
5282
5286
 
5283
5287
  // src/remote/phone-turn.ts
5284
- function formatRemotePrompt(text5) {
5288
+ function formatRemotePrompt(text6) {
5285
5289
  return `Phone
5286
5290
 
5287
- ${text5.trim()}`;
5291
+ ${text6.trim()}`;
5288
5292
  }
5289
- function isRemoteStopCommand(text5) {
5290
- return text5.trim().toLowerCase() === "stop";
5293
+ function isRemoteStopCommand(text6) {
5294
+ return text6.trim().toLowerCase() === "stop";
5291
5295
  }
5292
5296
  function phoneFollowUpQueues(status) {
5293
5297
  return followUpBehavior() === "queue" && (status === "running" || status === "queued");
@@ -5494,7 +5498,7 @@ function handlePhoneControl(cmd, opts) {
5494
5498
  emitControl(opts, { op: "error", message: "Speech is not available on this Mac." });
5495
5499
  return;
5496
5500
  }
5497
- void transcribe(cmd.audioBase64).then((text5) => emitControl(opts, { op: "dictated", id, text: text5.trim() })).catch((err) => {
5501
+ void transcribe(cmd.audioBase64).then((text6) => emitControl(opts, { op: "dictated", id, text: text6.trim() })).catch((err) => {
5498
5502
  emitControl(opts, { op: "error", message: phoneError(err) });
5499
5503
  });
5500
5504
  return;
@@ -5774,8 +5778,8 @@ function runPhonePrompt(opts, cmd, chatId, generation) {
5774
5778
  const live = readPhoneThread(thread.id) ?? thread;
5775
5779
  const followUp = followUpBehavior();
5776
5780
  const staged = stagePhoneTurnFiles(live.worktreePath, cmd);
5777
- const text5 = cmd.text.trim() || (staged.length ? "See the attached files." : "");
5778
- await getOrchestrator().send(thread.id, formatRemotePrompt(text5), {
5781
+ const text6 = cmd.text.trim() || (staged.length ? "See the attached files." : "");
5782
+ await getOrchestrator().send(thread.id, formatRemotePrompt(text6), {
5779
5783
  attachments: staged,
5780
5784
  followUp
5781
5785
  });
@@ -5794,8 +5798,8 @@ function runPhonePrompt(opts, cmd, chatId, generation) {
5794
5798
  emitChatTurn(opts, chatId, thread.id);
5795
5799
  })();
5796
5800
  }
5797
- function handleRemoteInbound(text5, opts) {
5798
- const body = text5.trim();
5801
+ function handleRemoteInbound(text6, opts) {
5802
+ const body = text6.trim();
5799
5803
  if (dispatchPhonePermission(body, (reply) => emitControl(opts, reply))) return;
5800
5804
  const control = takePhoneControl(body);
5801
5805
  if (control) {
@@ -5966,6 +5970,7 @@ function pushNotes(input) {
5966
5970
  }
5967
5971
  const event = input.event;
5968
5972
  if (!event || event.type !== "turn_finished" && event.type !== "error") return notes;
5973
+ if (event.type === "turn_finished" && event.routineStop) return notes;
5969
5974
  if (fresh.has(event.threadId)) return notes;
5970
5975
  const finished = event.type === "turn_finished" && (event.exitCode === 0 || event.exitCode == null);
5971
5976
  notes.push({ chatId: event.threadId, kind: finished ? "finished" : "failed" });
@@ -6582,11 +6587,11 @@ async function slackApi(token, method, params, fetchImpl) {
6582
6587
  // src/slack/socket-mode.ts
6583
6588
  var BACKOFF_START_MS2 = 1e3;
6584
6589
  var BACKOFF_MAX_MS2 = 3e4;
6585
- function stripSlackMentions(text5) {
6586
- return text5.replace(/<@[^>]+>/g, "").replace(/\s+/g, " ").trim();
6590
+ function stripSlackMentions(text6) {
6591
+ return text6.replace(/<@[^>]+>/g, "").replace(/\s+/g, " ").trim();
6587
6592
  }
6588
- function isSlackStopCommand(text5) {
6589
- const t = stripSlackMentions(text5).toLowerCase();
6593
+ function isSlackStopCommand(text6) {
6594
+ const t = stripSlackMentions(text6).toLowerCase();
6590
6595
  return t === "stop" || t === "sideboard_force_stop";
6591
6596
  }
6592
6597
  function parseSlackSocketFrame(raw) {
@@ -6608,8 +6613,8 @@ function inboundFromSocketFrame(frame) {
6608
6613
  const ts = event.ts?.trim();
6609
6614
  if (!channelId || !ts) return null;
6610
6615
  const rawText = event.text?.trim() ?? "";
6611
- const text5 = stripSlackMentions(rawText);
6612
- if (!text5) return null;
6616
+ const text6 = stripSlackMentions(rawText);
6617
+ if (!text6) return null;
6613
6618
  const teamId = (frame.payload?.team_id || event.team || "").trim();
6614
6619
  if (!teamId) return null;
6615
6620
  const isDm = event.type === "message" && (event.channel_type === "im" || event.channel_type === "mpim" || !event.channel_type && channelId.startsWith("D"));
@@ -6621,7 +6626,7 @@ function inboundFromSocketFrame(frame) {
6621
6626
  ts,
6622
6627
  threadTs: event.thread_ts?.trim() || void 0,
6623
6628
  userId: event.user?.trim(),
6624
- text: text5,
6629
+ text: text6,
6625
6630
  kind: isMention ? "mention" : "dm"
6626
6631
  };
6627
6632
  }
@@ -6880,9 +6885,9 @@ var SlackEventDeduper = class {
6880
6885
  import { createCipheriv, createDecipheriv, randomBytes as randomBytes2 } from "crypto";
6881
6886
  var VERSION = "v1";
6882
6887
  function parseSlackTokenKey(raw) {
6883
- const text5 = raw.trim();
6884
- if (!text5) throw new Error("SIDEBOARD_SLACK_TOKEN_KEY is empty");
6885
- const buf = /^[0-9a-fA-F]{64}$/.test(text5) ? Buffer.from(text5, "hex") : Buffer.from(text5, "base64");
6888
+ const text6 = raw.trim();
6889
+ if (!text6) throw new Error("SIDEBOARD_SLACK_TOKEN_KEY is empty");
6890
+ const buf = /^[0-9a-fA-F]{64}$/.test(text6) ? Buffer.from(text6, "hex") : Buffer.from(text6, "base64");
6886
6891
  if (buf.length !== 32) {
6887
6892
  throw new Error("SIDEBOARD_SLACK_TOKEN_KEY must be 32 bytes (base64 or 64 hex characters)");
6888
6893
  }
@@ -7929,10 +7934,10 @@ async function publishSlackAppHome(opts) {
7929
7934
  }
7930
7935
 
7931
7936
  // src/slack/relay-hub.ts
7932
- function parseSlackDeviceDestination(text5) {
7933
- const m = text5.match(/^\s*(?:to\s+)?(?:@|#)?([A-Za-z][\w-]{0,63})\s*[::]\s*/);
7934
- if (!m) return { label: null, rest: text5 };
7935
- return { label: m[1], rest: text5.slice(m[0].length) };
7937
+ function parseSlackDeviceDestination(text6) {
7938
+ const m = text6.match(/^\s*(?:to\s+)?(?:@|#)?([A-Za-z][\w-]{0,63})\s*[::]\s*/);
7939
+ if (!m) return { label: null, rest: text6 };
7940
+ return { label: m[1], rest: text6.slice(m[0].length) };
7936
7941
  }
7937
7942
  var SlackRelayHub = class {
7938
7943
  sessions = /* @__PURE__ */ new Map();
@@ -9203,10 +9208,10 @@ function entireAuthorizeUrl(clientId, redirectUri, state, codeChallenge) {
9203
9208
  return url.toString();
9204
9209
  }
9205
9210
  async function readJson2(res) {
9206
- const text5 = await res.text();
9207
- if (!text5) return {};
9211
+ const text6 = await res.text();
9212
+ if (!text6) return {};
9208
9213
  try {
9209
- return JSON.parse(text5);
9214
+ return JSON.parse(text6);
9210
9215
  } catch {
9211
9216
  throw new Error("Entire returned a non-JSON response.");
9212
9217
  }
@@ -9356,10 +9361,10 @@ function relayAuthorizeUrl(provider, client, redirectUri, state, ctx = EMPTY_AUT
9356
9361
  return GIT_HOST_AUTH[provider].authorizeUrl(client, redirectUri, state, ctx);
9357
9362
  }
9358
9363
  async function readJson3(res) {
9359
- const text5 = await res.text();
9360
- if (!text5) return {};
9364
+ const text6 = await res.text();
9365
+ if (!text6) return {};
9361
9366
  try {
9362
- return JSON.parse(text5);
9367
+ return JSON.parse(text6);
9363
9368
  } catch {
9364
9369
  throw new Error("Sign-in provider returned a non-JSON response.");
9365
9370
  }
@@ -9416,9 +9421,9 @@ async function readBody2(req) {
9416
9421
  if (size > 8192) throw new Error("body too large");
9417
9422
  chunks.push(buf);
9418
9423
  }
9419
- const text5 = Buffer.concat(chunks).toString("utf8").trim();
9420
- if (!text5) return {};
9421
- return JSON.parse(text5);
9424
+ const text6 = Buffer.concat(chunks).toString("utf8").trim();
9425
+ if (!text6) return {};
9426
+ return JSON.parse(text6);
9422
9427
  }
9423
9428
  function sendJson2(res, status, body) {
9424
9429
  res.writeHead(status, { "Content-Type": "application/json", "Cache-Control": "no-store" });
@@ -9956,7 +9961,7 @@ async function startHeadlessHost(opts) {
9956
9961
  };
9957
9962
  const refreshRunning = async () => {
9958
9963
  try {
9959
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-BUEPWNCF.js");
9964
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-Y5PYSMR6.js");
9960
9965
  agentsRunning = getOrchestrator2().getRuntime().running;
9961
9966
  } catch {
9962
9967
  agentsRunning = 0;
@@ -10044,9 +10049,9 @@ function flatInterfaces() {
10044
10049
  }
10045
10050
 
10046
10051
  // src/integrations/cursor-git.ts
10047
- function parseOriginAuthStatus(text5) {
10048
- const account = text5.match(/^Account:\s+(.+)$/m)?.[1]?.trim() || null;
10049
- const authMethod = text5.match(/^Auth method:\s+(.+)$/m)?.[1]?.trim() || null;
10052
+ function parseOriginAuthStatus(text6) {
10053
+ const account = text6.match(/^Account:\s+(.+)$/m)?.[1]?.trim() || null;
10054
+ const authMethod = text6.match(/^Auth method:\s+(.+)$/m)?.[1]?.trim() || null;
10050
10055
  return { account, authMethod };
10051
10056
  }
10052
10057
  async function getCursorGitStatus() {
@@ -10061,9 +10066,9 @@ async function getCursorGitStatus() {
10061
10066
  };
10062
10067
  }
10063
10068
  const status = await run("origin", ["auth", "status"], { reject: false, timeoutMs: 15e3 });
10064
- const text5 = `${status.stdout}
10069
+ const text6 = `${status.stdout}
10065
10070
  ${status.stderr}`;
10066
- const parsed = parseOriginAuthStatus(text5);
10071
+ const parsed = parseOriginAuthStatus(text6);
10067
10072
  if (status.exitCode === 0 && parsed.account) {
10068
10073
  return {
10069
10074
  installed: true,
@@ -10115,8 +10120,8 @@ async function setupCursorGit() {
10115
10120
  }
10116
10121
 
10117
10122
  // src/integrations/entire-git.ts
10118
- function parseEntireAuthContexts(text5) {
10119
- for (const line of text5.split("\n")) {
10123
+ function parseEntireAuthContexts(text6) {
10124
+ for (const line of text6.split("\n")) {
10120
10125
  if (!/\(active\)/i.test(line)) continue;
10121
10126
  const cols = line.replace(/\(active\)/gi, "").trim().split(/\s{2,}/).map((part) => part.trim()).filter(Boolean);
10122
10127
  const handle = cols[1] || cols[0] || null;
@@ -10490,16 +10495,16 @@ var PASTE_ATTACH_MIN_CHARS = 1200;
10490
10495
  var PASTE_ATTACH_MIN_LINES = 15;
10491
10496
  var PASTED_NAME_RE = /^Pasted text #(\d+)\.txt$/i;
10492
10497
  var PASTED_NAME_ALT_RE = /^pasted-(\d+)\.txt$/i;
10493
- function pastedTextStats(text5) {
10494
- const chars = text5.length;
10498
+ function pastedTextStats(text6) {
10499
+ const chars = text6.length;
10495
10500
  if (chars === 0) return { chars: 0, lines: 0 };
10496
- const lines = text5.split(/\r\n|\r|\n/).length;
10501
+ const lines = text6.split(/\r\n|\r|\n/).length;
10497
10502
  return { chars, lines };
10498
10503
  }
10499
- function shouldAttachPastedText(text5) {
10500
- const trimmed = text5.trim();
10504
+ function shouldAttachPastedText(text6) {
10505
+ const trimmed = text6.trim();
10501
10506
  if (!trimmed) return false;
10502
- const { chars, lines } = pastedTextStats(text5);
10507
+ const { chars, lines } = pastedTextStats(text6);
10503
10508
  return chars >= PASTE_ATTACH_MIN_CHARS || lines >= PASTE_ATTACH_MIN_LINES;
10504
10509
  }
10505
10510
  function nextPastedTextName(existing) {
@@ -10510,13 +10515,13 @@ function nextPastedTextName(existing) {
10510
10515
  }
10511
10516
  return `Pasted text #${max + 1}.txt`;
10512
10517
  }
10513
- function buildPastedTextAttachment(text5, opts) {
10518
+ function buildPastedTextAttachment(text6, opts) {
10514
10519
  return {
10515
10520
  id: opts?.id ?? randomUUID5(),
10516
10521
  name: opts?.name ?? "Pasted text #1.txt",
10517
10522
  kind: "file",
10518
10523
  path: opts?.path,
10519
- content: text5
10524
+ content: text6
10520
10525
  };
10521
10526
  }
10522
10527
 
@@ -10536,8 +10541,8 @@ function parseChatLink(href) {
10536
10541
  const match = CHAT_LINK_RE.exec(href.trim());
10537
10542
  return match?.[1] ?? null;
10538
10543
  }
10539
- function linkifyChatUrls(text5) {
10540
- return text5.replace(BARE_CHAT_LINK_RE, (url) => {
10544
+ function linkifyChatUrls(text6) {
10545
+ return text6.replace(BARE_CHAT_LINK_RE, (url) => {
10541
10546
  const id = parseChatLink(url);
10542
10547
  if (!id) return url;
10543
10548
  const label = id.length > 8 ? id.slice(0, 8) : id;
@@ -10593,7 +10598,7 @@ function createClippedMcpServer() {
10593
10598
  }
10594
10599
 
10595
10600
  // src/mcp/server.ts
10596
- import { z as z9 } from "zod";
10601
+ import { z as z10 } from "zod";
10597
10602
  import { randomUUID as randomUUID8 } from "crypto";
10598
10603
  import { basename as basename3 } from "path";
10599
10604
 
@@ -10782,9 +10787,9 @@ async function createOrchChildThread(orch, args, resolveNewThreadOptions2) {
10782
10787
  function lastMessagePreview(messages, max = 160) {
10783
10788
  if (!messages?.length) return null;
10784
10789
  for (let i = messages.length - 1; i >= 0; i--) {
10785
- const text5 = messages[i]?.text?.trim();
10786
- if (!text5 || isInternalAgentStatusText(text5) || isInjectedNoticeText(text5)) continue;
10787
- const flat = text5.replace(/\s+/g, " ");
10790
+ const text6 = messages[i]?.text?.trim();
10791
+ if (!text6 || isInternalAgentStatusText(text6) || isInjectedNoticeText(text6)) continue;
10792
+ const flat = text6.replace(/\s+/g, " ");
10788
10793
  return flat.length > max ? `${flat.slice(0, max)}\u2026` : flat;
10789
10794
  }
10790
10795
  return null;
@@ -10814,15 +10819,15 @@ var CRUSH_COMMENT_MAX_CHARS = 16e3;
10814
10819
  var CRUSH_BODY_MIN_CHARS = 12e3;
10815
10820
  var CRUSH_BODY_MAX_CHARS = 8e3;
10816
10821
  var NEAR_DUP_JACCARD = 0.92;
10817
- function looksLikeMustKeep(text5) {
10818
- return MUST_KEEP_TEXT_RE.test(text5);
10822
+ function looksLikeMustKeep(text6) {
10823
+ return MUST_KEEP_TEXT_RE.test(text6);
10819
10824
  }
10820
- function normalizeText(text5) {
10821
- return text5.replace(/\s+/g, " ").trim().toLowerCase();
10825
+ function normalizeText(text6) {
10826
+ return text6.replace(/\s+/g, " ").trim().toLowerCase();
10822
10827
  }
10823
- function wordSet(text5) {
10828
+ function wordSet(text6) {
10824
10829
  return new Set(
10825
- text5.toLowerCase().split(/\W+/).filter((w) => w.length > 2)
10830
+ text6.toLowerCase().split(/\W+/).filter((w) => w.length > 2)
10826
10831
  );
10827
10832
  }
10828
10833
  function jaccard(a, b) {
@@ -10834,11 +10839,11 @@ function jaccard(a, b) {
10834
10839
  const union = a.size + b.size - inter;
10835
10840
  return union === 0 ? 0 : inter / union;
10836
10841
  }
10837
- function importance(text5) {
10838
- let score = text5.length;
10839
- if (/```/.test(text5)) score += 400;
10840
- if (/https?:\/\//.test(text5)) score += 50;
10841
- if (looksLikeMustKeep(text5)) score += 1e4;
10842
+ function importance(text6) {
10843
+ let score = text6.length;
10844
+ if (/```/.test(text6)) score += 400;
10845
+ if (/https?:\/\//.test(text6)) score += 50;
10846
+ if (looksLikeMustKeep(text6)) score += 1e4;
10842
10847
  return score;
10843
10848
  }
10844
10849
  function meanStd(values) {
@@ -10852,15 +10857,15 @@ function dedupTextItems(items, getText) {
10852
10857
  const keptNorm = [];
10853
10858
  const keptWords = [];
10854
10859
  for (const item of items) {
10855
- const text5 = getText(item);
10856
- const norm = normalizeText(text5);
10860
+ const text6 = getText(item);
10861
+ const norm = normalizeText(text6);
10857
10862
  if (!norm) {
10858
10863
  kept.push(item);
10859
10864
  keptNorm.push(norm);
10860
- keptWords.push(wordSet(text5));
10865
+ keptWords.push(wordSet(text6));
10861
10866
  continue;
10862
10867
  }
10863
- const words = wordSet(text5);
10868
+ const words = wordSet(text6);
10864
10869
  let dupAt = -1;
10865
10870
  for (let i = 0; i < kept.length; i++) {
10866
10871
  if (keptNorm[i] === norm) {
@@ -10878,7 +10883,7 @@ function dedupTextItems(items, getText) {
10878
10883
  keptWords.push(words);
10879
10884
  continue;
10880
10885
  }
10881
- if (text5.length > getText(kept[dupAt]).length) {
10886
+ if (text6.length > getText(kept[dupAt]).length) {
10882
10887
  kept[dupAt] = item;
10883
10888
  keptNorm[dupAt] = norm;
10884
10889
  keptWords[dupAt] = words;
@@ -10919,8 +10924,8 @@ function crushTextItems(items, getText, opts = {}) {
10919
10924
  const outlierFloor = mean + 2 * std;
10920
10925
  const mustKeep = /* @__PURE__ */ new Set();
10921
10926
  unique.forEach((item, i) => {
10922
- const text5 = getText(item);
10923
- if (looksLikeMustKeep(text5) || text5.length > outlierFloor) mustKeep.add(i);
10927
+ const text6 = getText(item);
10928
+ if (looksLikeMustKeep(text6) || text6.length > outlierFloor) mustKeep.add(i);
10924
10929
  });
10925
10930
  const remainingIdx = unique.map((_, i) => i).filter((i) => !mustKeep.has(i));
10926
10931
  let used = [...mustKeep].reduce((n, i) => n + lengths[i], 0);
@@ -10962,9 +10967,9 @@ function crushTextItems(items, getText, opts = {}) {
10962
10967
  reason: "budget"
10963
10968
  };
10964
10969
  }
10965
- function splitBlocks(text5) {
10966
- if (/\n\n/.test(text5)) return text5.split(/\n\n+/);
10967
- return text5.split("\n");
10970
+ function splitBlocks(text6) {
10971
+ if (/\n\n/.test(text6)) return text6.split(/\n\n+/);
10972
+ return text6.split("\n");
10968
10973
  }
10969
10974
  function capOversizedBlock(block, maxChars) {
10970
10975
  if (block.length <= maxChars) return block;
@@ -10976,8 +10981,8 @@ function capOversizedBlock(block, maxChars) {
10976
10981
 
10977
10982
  ${block.slice(-tail)}`;
10978
10983
  }
10979
- function crushMarkdown(text5, opts) {
10980
- const original = text5 ?? "";
10984
+ function crushMarkdown(text6, opts) {
10985
+ const original = text6 ?? "";
10981
10986
  const minChars = opts?.minChars ?? CRUSH_BODY_MIN_CHARS;
10982
10987
  const maxChars = opts?.maxChars ?? CRUSH_BODY_MAX_CHARS;
10983
10988
  if (original.length < minChars) {
@@ -11067,13 +11072,13 @@ function withComments(comments, meta) {
11067
11072
  }
11068
11073
  return { comments: crushed.items, meta };
11069
11074
  }
11070
- function withBody(text5, meta) {
11071
- const crushed = crushMarkdown(text5);
11075
+ function withBody(text6, meta) {
11076
+ const crushed = crushMarkdown(text6);
11072
11077
  if (crushed.truncated) {
11073
11078
  meta.body = { originalChars: crushed.originalChars };
11074
11079
  return { value: crushed.text, meta };
11075
11080
  }
11076
- return { value: text5, meta };
11081
+ return { value: text6, meta };
11077
11082
  }
11078
11083
  function attachCrush(payload, meta) {
11079
11084
  if (!meta.comments && !meta.body) return payload;
@@ -11785,9 +11790,9 @@ async function runPosthogApi(input) {
11785
11790
  body,
11786
11791
  signal: AbortSignal.timeout(POSTHOG_TIMEOUT_MS)
11787
11792
  });
11788
- const text5 = await res.text();
11789
- const truncated = text5.length > POSTHOG_RESPONSE_MAX_CHARS;
11790
- const slice = truncated ? text5.slice(0, POSTHOG_RESPONSE_MAX_CHARS) : text5;
11793
+ const text6 = await res.text();
11794
+ const truncated = text6.length > POSTHOG_RESPONSE_MAX_CHARS;
11795
+ const slice = truncated ? text6.slice(0, POSTHOG_RESPONSE_MAX_CHARS) : text6;
11791
11796
  let parsed = slice;
11792
11797
  if (slice.trim()) {
11793
11798
  try {
@@ -11930,7 +11935,7 @@ function registerArchiveTools(server, orch) {
11930
11935
  );
11931
11936
  server.tool(
11932
11937
  "archive_chat",
11933
- "Archive one agent chat: stop the turn and move that chat to Settings \u2192 History. Other agents on the workspace stay, and the worktree is removed only when this is the last agent. Orchestration chats archive without removing a project checkout. Refuses the cloud coordinator. To archive every agent on a checkout, use archive_workspace. Commit, push, and open PRs via ask_git before archiving when the work should be kept. Merge only when the user explicitly asked.",
11938
+ "Archive one agent chat: stop the turn and move that chat to Settings \u2192 History. Other agents on the workspace stay, and the worktree is removed only when this is the last agent. Uncommitted and untracked files are saved on a hidden git ref and put back uncommitted if that checkout is restored. If that snapshot fails, the checkout stays. History Delete does not keep the snapshot. Orchestration chats archive without removing a project checkout. Refuses the cloud coordinator. To archive every agent on a checkout, use archive_workspace. Commit, push, and open PRs via ask_git before archiving when the work should be kept. Merge only when the user explicitly asked.",
11934
11939
  { ref: z6.string().describe("Chat id to archive") },
11935
11940
  async ({ ref }) => {
11936
11941
  const t = orch.getThread(ref);
@@ -12233,10 +12238,82 @@ function registerScheduleTools(server) {
12233
12238
  );
12234
12239
  }
12235
12240
 
12236
- // src/mcp/order-tools.ts
12241
+ // src/mcp/follow-up-tools.ts
12237
12242
  import { z as z8 } from "zod";
12238
- var kindSchema = z8.enum(["pr", "issue", "workspace", "orchestration"]);
12243
+ function text5(payload, isError = false) {
12244
+ return mcpJson(payload, isError);
12245
+ }
12239
12246
  function callerThread() {
12247
+ const id = process.env[SIDEBOARD_THREAD_ID_ENV]?.trim() || "";
12248
+ if (!id) return null;
12249
+ return findThreadByRef(id);
12250
+ }
12251
+ async function baselineCi(thread) {
12252
+ const selector = resolvePrSelector(thread);
12253
+ if (!selector) return "none";
12254
+ try {
12255
+ const checks = await getPrCiChecks(thread.worktreePath, selector);
12256
+ return ciChecksSettled(checks);
12257
+ } catch {
12258
+ return "unknown";
12259
+ }
12260
+ }
12261
+ function registerFollowUpTools(server) {
12262
+ server.tool(
12263
+ "list_follow_ups",
12264
+ "List follow-ups on this chat. kind=ci wakes when GitHub checks finish. kind=at wakes at a time. A running turn is not interrupted.",
12265
+ {},
12266
+ async () => {
12267
+ const thread = callerThread();
12268
+ if (!thread) return text5({ error: "This chat id is missing" }, true);
12269
+ return text5({ followUps: normalizeChatFollowUps(thread.followUps) });
12270
+ }
12271
+ );
12272
+ server.tool(
12273
+ "create_follow_up",
12274
+ "Register a follow-up on THIS chat. kind=ci sends the prompt when GitHub checks on this chat\u2019s PR finish (pass or fail). Checks that are already finished do not send until a later run finishes. A failed checks read does not count as finished or in progress. A CI follow-up that is still pending at deadline (default 7 days) ends silently. kind=at sends at `30m`, `2h`, `1d`, or an ISO time and waits behind a turn that is already running. Cap 10.",
12275
+ {
12276
+ kind: z8.enum(["ci", "at"]),
12277
+ prompt: z8.string(),
12278
+ at: z8.string().optional(),
12279
+ deadline: z8.string().optional()
12280
+ },
12281
+ async ({ kind, prompt, at, deadline }) => {
12282
+ const thread = callerThread();
12283
+ if (!thread) return text5({ error: "This chat id is missing" }, true);
12284
+ if (thread.status === "archived") return text5({ error: "This chat is archived" }, true);
12285
+ const existing = normalizeChatFollowUps(thread.followUps);
12286
+ const ciBaseline = kind === "ci" ? await baselineCi(thread) : void 0;
12287
+ const added = addChatFollowUp(
12288
+ existing,
12289
+ { kind, prompt, at, deadline, ciBaseline },
12290
+ /* @__PURE__ */ new Date()
12291
+ );
12292
+ if (!added.ok) return text5({ error: added.error }, true);
12293
+ updateThread(thread.id, { followUps: added.followUps });
12294
+ return text5({ followUps: added.followUps });
12295
+ }
12296
+ );
12297
+ server.tool(
12298
+ "delete_follow_up",
12299
+ "Remove one follow-up from this chat by id.",
12300
+ { id: z8.string() },
12301
+ async ({ id }) => {
12302
+ const thread = callerThread();
12303
+ if (!thread) return text5({ error: "This chat id is missing" }, true);
12304
+ const existing = normalizeChatFollowUps(thread.followUps);
12305
+ const followUps = existing.filter((item) => item.id !== id.trim());
12306
+ if (followUps.length === existing.length) return text5({ error: "Follow-up not found" }, true);
12307
+ updateThread(thread.id, { followUps });
12308
+ return text5({ followUps });
12309
+ }
12310
+ );
12311
+ }
12312
+
12313
+ // src/mcp/order-tools.ts
12314
+ import { z as z9 } from "zod";
12315
+ var kindSchema = z9.enum(["pr", "issue", "workspace", "orchestration"]);
12316
+ function callerThread2() {
12240
12317
  const id = process.env[SIDEBOARD_THREAD_ID_ENV]?.trim();
12241
12318
  if (!id) return null;
12242
12319
  return readThread(id);
@@ -12249,7 +12326,7 @@ function readCheckoutPlan(caller) {
12249
12326
  return readPlanFile(root);
12250
12327
  }
12251
12328
  function orchestrationOwnerId(worktree) {
12252
- const caller = callerThread();
12329
+ const caller = callerThread2();
12253
12330
  if (!caller) {
12254
12331
  throw new Error(
12255
12332
  worktree ? "No worktree chat is bound to this tool." : "No orchestration chat is bound to this tool."
@@ -12285,10 +12362,10 @@ function registerOrderTools(server) {
12285
12362
  try {
12286
12363
  const owner = orchestrationOwnerId(worktree);
12287
12364
  const plan = getOrderPlan(owner);
12288
- const caller = callerThread();
12365
+ const caller = callerThread2();
12289
12366
  if (!plan) {
12290
- const text5 = worktree ? "This checkout's orchestrator has no plan yet." : "This chat has no plan. set_plan drafts one. Then show_plan so the user sees it.";
12291
- return { content: [{ type: "text", text: text5 }] };
12367
+ const text6 = worktree ? "This checkout's orchestrator has no plan yet." : "This chat has no plan. set_plan drafts one. Then show_plan so the user sees it.";
12368
+ return { content: [{ type: "text", text: text6 }] };
12292
12369
  }
12293
12370
  const rows = listOrderRows(plan.id);
12294
12371
  const place = worktree && caller ? `${formatOrderPlace(rows, orderSnapshotFromThread(caller))}
@@ -12307,16 +12384,16 @@ function registerOrderTools(server) {
12307
12384
  worktree ? "Change what this checkout waits on. Omit subject to mean this workspace (hold=merge uses this PR; hold=start on a ticket uses this issue). gate=in-main (met when that PR is merged) or in-prod (stays waiting until satisfy_dependency). hold=start means do not begin; hold=merge means do not merge. You cannot set a dependency for a different checkout. show_plan so the user sees the change." : "Record a step on this orchestration plan. waitsOn must reach gate before subject can hold. gate=in-main is met when that PR is merged; gate=in-prod stays waiting until satisfy_dependency. hold=start blocks starting the subject; hold=merge blocks merging it. Example: PR 1 in prod before PR 2 can merge; PR 3 in main before issue 4 can start. Pass repoPath when the same PR number exists in more than one project. Worktree agents set their own checkout and can omit subject. Then show_plan so the user sees it.",
12308
12385
  {
12309
12386
  waitsOnKind: kindSchema.describe("What must happen first: pr, issue, workspace, or orchestration"),
12310
- waitsOnRef: z8.string().describe("PR number (12), issue id (ENG-4), or workspace chat id / worktree path"),
12311
- waitsOnRepoPath: z8.string().optional().describe("Project path when a PR or issue number is not unique"),
12312
- waitsOnLabel: z8.string().optional().describe("Short label on the planner"),
12313
- gate: z8.enum(["in-main", "in-prod"]).describe("in-main: merged to the default branch. in-prod: deployed; mark with satisfy_dependency"),
12314
- hold: z8.enum(["start", "merge"]).describe("start: subject cannot begin. merge: subject cannot merge"),
12387
+ waitsOnRef: z9.string().describe("PR number (12), issue id (ENG-4), or workspace chat id / worktree path"),
12388
+ waitsOnRepoPath: z9.string().optional().describe("Project path when a PR or issue number is not unique"),
12389
+ waitsOnLabel: z9.string().optional().describe("Short label on the planner"),
12390
+ gate: z9.enum(["in-main", "in-prod"]).describe("in-main: merged to the default branch. in-prod: deployed; mark with satisfy_dependency"),
12391
+ hold: z9.enum(["start", "merge"]).describe("start: subject cannot begin. merge: subject cannot merge"),
12315
12392
  subjectKind: kindSchema.optional().describe("What is held. Required from orchestration. Omit on a worktree to mean this checkout."),
12316
- subjectRef: z8.string().optional().describe("PR number, issue id, or workspace ref for the subject"),
12317
- subjectRepoPath: z8.string().optional(),
12318
- subjectLabel: z8.string().optional(),
12319
- note: z8.string().optional().describe("Why this order matters")
12393
+ subjectRef: z9.string().optional().describe("PR number, issue id, or workspace ref for the subject"),
12394
+ subjectRepoPath: z9.string().optional(),
12395
+ subjectLabel: z9.string().optional(),
12396
+ note: z9.string().optional().describe("Why this order matters")
12320
12397
  },
12321
12398
  async (args) => {
12322
12399
  try {
@@ -12325,7 +12402,7 @@ function registerOrderTools(server) {
12325
12402
  if (hasKind !== hasRef) {
12326
12403
  throw new Error("Pass subjectKind and subjectRef together, or omit both on a worktree.");
12327
12404
  }
12328
- const caller = callerThread();
12405
+ const caller = callerThread2();
12329
12406
  let subject;
12330
12407
  const hold = parseOrderHold(args.hold);
12331
12408
  if (!hasKind) {
@@ -12380,9 +12457,9 @@ function registerOrderTools(server) {
12380
12457
  "set_plan",
12381
12458
  "Draft or retitle this chat's plan. It stays draft until execute_plan. Pass goal for the outcome the steps are trying to reach. Then set_dependency for each gate. A step may loop back to an earlier one. Call show_plan so the user sees it. Do not paste the diagram in chat. Do not start workspaces while it is draft.",
12382
12459
  {
12383
- title: z8.string().describe("Short name for the plan"),
12384
- summary: z8.string().optional().describe("What this order is for, in a sentence or two"),
12385
- goal: z8.string().optional().describe("Outcome the steps are trying to reach")
12460
+ title: z9.string().describe("Short name for the plan"),
12461
+ summary: z9.string().optional().describe("What this order is for, in a sentence or two"),
12462
+ goal: z9.string().optional().describe("Outcome the steps are trying to reach")
12386
12463
  },
12387
12464
  async ({ title, summary, goal }) => {
12388
12465
  try {
@@ -12402,7 +12479,7 @@ function registerOrderTools(server) {
12402
12479
  "execute_plan",
12403
12480
  "Mark the plan active after the user has seen it and told you to run it. Returns ready steps (start those with create_workspace or send_to_chat) and waiting steps (leave them alone). Does not create workspaces. Pass agreed: true only after they agree. Merge only if they asked.",
12404
12481
  {
12405
- agreed: z8.literal(true).describe("True only after the user has seen the plan and told you to run it")
12482
+ agreed: z9.literal(true).describe("True only after the user has seen the plan and told you to run it")
12406
12483
  },
12407
12484
  async () => {
12408
12485
  try {
@@ -12435,7 +12512,7 @@ function registerOrderTools(server) {
12435
12512
  worktree ? "Open the plans for this checkout in the side column. That is the orchestration diagram, with this checkout marked, and this checkout's implementation plan (plan.md) when the file exists. Does not write either plan. Change a step with set_dependency or clear_dependency, then show it again. Do not paste the diagram in chat." : "Open this chat's plan in the side column. Call it after set_plan or set_dependency so the user sees the plan. A worktree show_plan also opens that checkout's implementation plan (plan.md) when the file exists. Does not write either plan. Do not paste the diagram in chat.",
12436
12513
  {},
12437
12514
  async () => {
12438
- const caller = callerThread();
12515
+ const caller = callerThread2();
12439
12516
  let diagramHtml = null;
12440
12517
  let diagramTitle = "Planner";
12441
12518
  let diagramError = null;
@@ -12473,10 +12550,10 @@ function registerOrderTools(server) {
12473
12550
  server.tool(
12474
12551
  "clear_dependency",
12475
12552
  worktree ? "Remove a planner step this checkout is part of. Pass id from list_order. Then show_plan so the user sees it." : "Remove one planner step. Pass id from list_order. Then show_plan so the user sees it.",
12476
- { id: z8.string().describe("Step id from list_order") },
12553
+ { id: z9.string().describe("Step id from list_order") },
12477
12554
  async ({ id }) => {
12478
12555
  try {
12479
- const caller = callerThread();
12556
+ const caller = callerThread2();
12480
12557
  clearOrderDependency(
12481
12558
  id,
12482
12559
  worktree && caller ? orderSnapshotFromThread(caller) : null,
@@ -12492,8 +12569,8 @@ function registerOrderTools(server) {
12492
12569
  "satisfy_dependency",
12493
12570
  "Mark a planner gate met. Use this when a PR is in production \u2014 Sideboard cannot see deploys. in-main also clears on its own once that PR is merged. Pass satisfied=false to undo a manual mark. One mark covers every step waiting on that same gate.",
12494
12571
  {
12495
- id: z8.string().describe("Step id from list_order"),
12496
- satisfied: z8.boolean().optional().describe("false clears the manual mark. Default true.")
12572
+ id: z9.string().describe("Step id from list_order"),
12573
+ satisfied: z9.boolean().optional().describe("false clears the manual mark. Default true.")
12497
12574
  },
12498
12575
  async ({ id, satisfied }) => {
12499
12576
  try {
@@ -12503,7 +12580,7 @@ function registerOrderTools(server) {
12503
12580
  const rows = listOrderRows(plan.id);
12504
12581
  const hit = rows.find((row2) => row2.id === id || id.length >= 8 && row2.id.startsWith(id));
12505
12582
  if (!hit) throw new Error("That step is on another orchestration chat's plan.");
12506
- const caller = callerThread();
12583
+ const caller = callerThread2();
12507
12584
  if (worktree && caller && !orderEdgeTouches(hit, orderSnapshotFromThread(caller))) {
12508
12585
  throw new Error("This checkout can only change a step it is part of.");
12509
12586
  }
@@ -12690,7 +12767,7 @@ async function handleJobStop(params, _ctx) {
12690
12767
  return stopDetachedJob(jobCwd(rec), id, reason ? { reason } : void 0);
12691
12768
  }
12692
12769
  async function defaultTurnWait(ref, timeoutMs) {
12693
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-BUEPWNCF.js");
12770
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-Y5PYSMR6.js");
12694
12771
  const orch = getOrchestrator2();
12695
12772
  const thread = await orch.waitForTurn(ref, timeoutMs, {
12696
12773
  resolveIfStillRunning: true
@@ -12737,7 +12814,8 @@ async function handleTurnWait(params, ctx, waitFn = defaultTurnWait) {
12737
12814
  hint: "Child is still working after max hold. Call wait_for_turn again. Do not send_to_chat a check-in (that steers / interrupts).",
12738
12815
  incomplete: false,
12739
12816
  blockedReason: null,
12740
- blockedSource: null
12817
+ blockedSource: null,
12818
+ failureClass: null
12741
12819
  };
12742
12820
  }
12743
12821
  function createAgentRpcDispatcher() {
@@ -13127,16 +13205,16 @@ async function startMcpServer() {
13127
13205
  "list_board",
13128
13206
  "Home Kanban of workspaces (New, Draft, Review, Approved, Merged) \u2014 one card per checkout; sibling chats on that card are separate agents. Same cards as desktop Home. Path to merge: no PR \u2192 draft PR \u2192 open PR \u2192 approved \u2192 merged. Archive removes the card to Settings \u2192 History (list_archive to browse, restore_workspace to bring it back). Queued/running are activity on the card, not stages. Orchestration chats are not on the board. Filters: query, repoPath, kind (ticket/PR/branch source), ownership (mine = your PRs / WIP; reviewing = someone else's PR), column, limit (default 40). create_workspace adds a workspace (and a Home card), or returns the live checkout if that ticket/PR/named branch is already checked out. That reuse is one checkout, not one agent \u2014 fork_chat to add another.",
13129
13207
  {
13130
- query: z9.string().optional().describe("Case-insensitive token search across title, id, labels, workspace tags, repo"),
13131
- repoPath: z9.string().optional().describe("Limit to one project path from list_projects"),
13132
- kind: z9.enum(["all", "tickets", "prs", "branches", "threads"]).optional().describe("Filter by worktree source (default all)"),
13133
- ownership: z9.enum(["all", "mine", "reviewing"]).optional().describe(
13208
+ query: z10.string().optional().describe("Case-insensitive token search across title, id, labels, workspace tags, repo"),
13209
+ repoPath: z10.string().optional().describe("Limit to one project path from list_projects"),
13210
+ kind: z10.enum(["all", "tickets", "prs", "branches", "threads"]).optional().describe("Filter by worktree source (default all)"),
13211
+ ownership: z10.enum(["all", "mine", "reviewing"]).optional().describe(
13134
13212
  "Mine = PRs you authored or local WIP; reviewing = someone else's PR. Uses the gh login."
13135
13213
  ),
13136
- column: z9.enum(["new", "draft", "review", "approved", "done", "needs_you"]).optional().describe(
13214
+ column: z10.enum(["new", "draft", "review", "approved", "done", "needs_you"]).optional().describe(
13137
13215
  "Return cards for this column only (totals still include the rest). approved is an open PR GitHub has approved. needs_you is a legacy alias for new."
13138
13216
  ),
13139
- limit: z9.number().int().positive().optional().describe("Max cards per column (default 40). hidden counts the remainder.")
13217
+ limit: z10.number().int().positive().optional().describe("Max cards per column (default 40). hidden counts the remainder.")
13140
13218
  },
13141
13219
  async ({ query, repoPath, kind, ownership, column, limit }) => {
13142
13220
  const workspaces = orch.listWorkspaces();
@@ -13166,7 +13244,7 @@ async function startMcpServer() {
13166
13244
  server.tool(
13167
13245
  "get_chat",
13168
13246
  "Get a compact chat summary by id/ref. Includes last message preview, parentChatId, and child workspace chats (status + lastText). While running, includes progress (last tool/thinking) and lastActivityAt. Includes usage (billed token + costUsd totals when providers reported cost) and lastTurnUsage. blockedReason is why that agent is waiting on a person (question, plan approval, or a reported block).",
13169
- { ref: z9.string() },
13247
+ { ref: z10.string() },
13170
13248
  async ({ ref }) => {
13171
13249
  const t = orch.getThread(ref);
13172
13250
  if (!t) {
@@ -13213,17 +13291,17 @@ async function startMcpServer() {
13213
13291
  "present_artifact",
13214
13292
  "Show a document or live log in Sideboard\u2019s side column. For html/svg/markdown/react, pass the FULL document and do not also fence that same body in chat. For type=log, pass only NEW lines (same artifact_id appends). Prefer type=log for long-running job output \u2014 do not resend HTML. type=react is a single default-export component (JSX/TSX); only react/react-dom imports.",
13215
13293
  {
13216
- title: z9.string().describe("Short title shown in the artifact pane header"),
13217
- type: z9.enum(["html", "svg", "markdown", "react", "log"]).describe(
13294
+ title: z10.string().describe("Short title shown in the artifact pane header"),
13295
+ type: z10.enum(["html", "svg", "markdown", "react", "log"]).describe(
13218
13296
  "html/svg/markdown/react replace the pane. log appends content to the same artifact_id (new lines only)."
13219
13297
  ),
13220
- content: z9.string().describe(
13298
+ content: z10.string().describe(
13221
13299
  "html/svg/markdown/react: full document. log: only the new lines since the last call (empty is ok for a status-only update)."
13222
13300
  ),
13223
- artifact_id: z9.string().optional().describe("Stable id. Required for type=log so later calls append to the same pane."),
13224
- status: z9.enum(["running", "ok", "failed", "idle"]).optional().describe("Log header pill: running (working), ok (done), failed, idle"),
13225
- phase: z9.string().optional().describe("Log subtitle (Signing, Notarizing, \u2026)"),
13226
- mode: z9.enum(["append", "replace"]).optional().describe("log only: append (default) or replace the buffer")
13301
+ artifact_id: z10.string().optional().describe("Stable id. Required for type=log so later calls append to the same pane."),
13302
+ status: z10.enum(["running", "ok", "failed", "idle"]).optional().describe("Log header pill: running (working), ok (done), failed, idle"),
13303
+ phase: z10.string().optional().describe("Log subtitle (Signing, Notarizing, \u2026)"),
13304
+ mode: z10.enum(["append", "replace"]).optional().describe("log only: append (default) or replace the buffer")
13227
13305
  },
13228
13306
  async ({ title, type, artifact_id, status, phase, mode }) => {
13229
13307
  return mcpJson(
@@ -13236,15 +13314,15 @@ async function startMcpServer() {
13236
13314
  "ask_user",
13237
13315
  "Ask the user a clarifying multiple-choice question in Sideboard\u2019s composer. Call only when work is blocked on choosing among a few concrete options (approach fork, which API, auth vs cookies). Do not call for greetings, check-ins, \u201Chello\u201D, open-ended how-can-I-help, or to invent a menu of possible next tasks \u2014 reply in chat instead. If one option is the obvious default, proceed without asking. Before calling, write a short chat message explaining the decision and what each option means. Include a description on every option. After calling, stop and wait for answers. Not for \u201Cis the plan ready?\u201D.",
13238
13316
  {
13239
- questions: z9.array(
13240
- z9.object({
13241
- question: z9.string().describe("Full question text ending with ?"),
13242
- header: z9.string().max(24).optional().describe("Short label shown above the question"),
13243
- multiSelect: z9.boolean().optional().describe("Allow selecting multiple options"),
13244
- options: z9.array(
13245
- z9.object({
13246
- label: z9.string(),
13247
- description: z9.string().optional().describe("What this option means / when to choose it (strongly preferred)")
13317
+ questions: z10.array(
13318
+ z10.object({
13319
+ question: z10.string().describe("Full question text ending with ?"),
13320
+ header: z10.string().max(24).optional().describe("Short label shown above the question"),
13321
+ multiSelect: z10.boolean().optional().describe("Allow selecting multiple options"),
13322
+ options: z10.array(
13323
+ z10.object({
13324
+ label: z10.string(),
13325
+ description: z10.string().optional().describe("What this option means / when to choose it (strongly preferred)")
13248
13326
  })
13249
13327
  ).min(2).max(6).describe("2\u20136 choices (Sideboard also offers Other)")
13250
13328
  })
@@ -13270,9 +13348,9 @@ async function startMcpServer() {
13270
13348
  "present_plan",
13271
13349
  PRESENT_PLAN_TOOL_DESCRIPTION,
13272
13350
  {
13273
- title: z9.string().optional().describe("Short plan title (defaults to Plan)"),
13274
- content: z9.string().min(1).describe("Full plan markdown (headings, steps, risks, open questions)"),
13275
- thread_id: z9.string().optional().describe("Sideboard thread id when cwd is not the worktree")
13351
+ title: z10.string().optional().describe("Short plan title (defaults to Plan)"),
13352
+ content: z10.string().min(1).describe("Full plan markdown (headings, steps, risks, open questions)"),
13353
+ thread_id: z10.string().optional().describe("Sideboard thread id when cwd is not the worktree")
13276
13354
  },
13277
13355
  async ({ title, content, thread_id }) => {
13278
13356
  const { writePlanFile: writePlanFile2 } = await import("./plan-file-7MMIPV7Y.js");
@@ -13301,15 +13379,15 @@ async function startMcpServer() {
13301
13379
  "present_schema",
13302
13380
  "Open Sideboard\u2019s schema-driven side column (filterable table and/or form) when the user needs to filter, edit, publish, or persist records. Do not call this just to re-display rows you already wrote as a markdown table. If the user asks for an editable / interactive table, call this even if chat already showed those rows. Pass JSON Schema + optional schemaUi. Prefer datasource=inline with embedded resource/records. Use datasource=brightsy with resource_id only when the user is logged into Brightsy.",
13303
13381
  {
13304
- title: z9.string().describe("Pane title"),
13305
- mode: z9.enum(["table", "form"]).optional().describe("table = list/filter records; form = edit one record"),
13306
- datasource: z9.enum(["brightsy", "inline"]).optional().describe("brightsy resolves via login; inline uses embedded resource/records"),
13307
- resource_id: z9.string().optional().describe("Brightsy record type UUID (or generic resource id)"),
13308
- record_id: z9.string().optional().describe("Record id when opening form mode"),
13309
- resource: z9.record(z9.unknown()).optional().describe("Inline { id, title, schema, schemaUi?, slug? }"),
13310
- record: z9.record(z9.unknown()).optional().describe("Inline record { id, data, published_at? }"),
13311
- records: z9.array(z9.record(z9.unknown())).optional().describe("Inline records for table mode"),
13312
- pane_id: z9.string().optional().describe("Stable pane id across updates")
13382
+ title: z10.string().describe("Pane title"),
13383
+ mode: z10.enum(["table", "form"]).optional().describe("table = list/filter records; form = edit one record"),
13384
+ datasource: z10.enum(["brightsy", "inline"]).optional().describe("brightsy resolves via login; inline uses embedded resource/records"),
13385
+ resource_id: z10.string().optional().describe("Brightsy record type UUID (or generic resource id)"),
13386
+ record_id: z10.string().optional().describe("Record id when opening form mode"),
13387
+ resource: z10.record(z10.unknown()).optional().describe("Inline { id, title, schema, schemaUi?, slug? }"),
13388
+ record: z10.record(z10.unknown()).optional().describe("Inline record { id, data, published_at? }"),
13389
+ records: z10.array(z10.record(z10.unknown())).optional().describe("Inline records for table mode"),
13390
+ pane_id: z10.string().optional().describe("Stable pane id across updates")
13313
13391
  },
13314
13392
  async (args) => {
13315
13393
  const id = args.pane_id?.trim() || `schema_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
@@ -13330,10 +13408,10 @@ async function startMcpServer() {
13330
13408
  "present_files",
13331
13409
  "Open Sideboard\u2019s Files column (CMS-style file manager: browse, upload, pick). Use datasource=brightsy when the user is logged into Brightsy account storage; datasource=memory for a session-local demo store. Prefer this over claiming a file manager UI is unavailable. Pair with present_schema when editing records that need media.",
13332
13410
  {
13333
- title: z9.string().optional().describe("Pane title (default: Files)"),
13334
- datasource: z9.enum(["brightsy", "memory"]).optional().describe("brightsy = account storage via login; memory = session demo store"),
13335
- path: z9.string().optional().describe("Initial folder path (e.g. public)"),
13336
- pane_id: z9.string().optional().describe("Stable pane id across updates")
13411
+ title: z10.string().optional().describe("Pane title (default: Files)"),
13412
+ datasource: z10.enum(["brightsy", "memory"]).optional().describe("brightsy = account storage via login; memory = session demo store"),
13413
+ path: z10.string().optional().describe("Initial folder path (e.g. public)"),
13414
+ pane_id: z10.string().optional().describe("Stable pane id across updates")
13337
13415
  },
13338
13416
  async (args) => {
13339
13417
  const id = args.pane_id?.trim() || `files_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
@@ -13353,8 +13431,8 @@ async function startMcpServer() {
13353
13431
  "wait_for_job",
13354
13432
  "Wait on a detached long job (tests, pack, deploy, connector CLI) started with detached-job.cjs. MCP clients kill tools around 60s, so this returns within 45s. Sideboard opens a type=log pane from this result (artifact_id = job id, content = delta). stillRunning is the source of truth \u2014 if true, call wait_for_job again. If the job is hanging, producing no useful output, or doing the wrong thing, call stop_job instead of looping forever. Do not end the turn or tell the user you will let them know later. If false, ok/failed is the result.",
13355
13433
  {
13356
- id: z9.string().describe("Detached job id (same kebab-case id passed to detached-job.cjs start)"),
13357
- timeoutMs: z9.number().optional()
13434
+ id: z10.string().describe("Detached job id (same kebab-case id passed to detached-job.cjs start)"),
13435
+ timeoutMs: z10.number().optional()
13358
13436
  },
13359
13437
  async ({ id, timeoutMs }) => {
13360
13438
  const result = await waitForDetachedJob(process.cwd(), id, {
@@ -13367,8 +13445,8 @@ async function startMcpServer() {
13367
13445
  "stop_job",
13368
13446
  "Stop a detached job you started with detached-job.cjs when it is hanging, producing no useful output, buffering forever, or doing the wrong thing (wrong project, infinite watch, huge dump). Do not stop a pack/test/deploy that is clearly making progress. The type=log pane updates to status=failed with the last delta. Then decide the next step.",
13369
13447
  {
13370
- id: z9.string().describe("Detached job id (same kebab-case id passed to detached-job.cjs start)"),
13371
- reason: z9.string().optional().describe("Why you are stopping (hanging, no progress, wrong output, already have the answer)")
13448
+ id: z10.string().describe("Detached job id (same kebab-case id passed to detached-job.cjs start)"),
13449
+ reason: z10.string().optional().describe("Why you are stopping (hanging, no progress, wrong output, already have the answer)")
13372
13450
  },
13373
13451
  async ({ id, reason }) => {
13374
13452
  const result = await stopDetachedJob(process.cwd(), id, { reason });
@@ -13380,7 +13458,7 @@ async function startMcpServer() {
13380
13458
  "list_run_scripts",
13381
13459
  "List .sideboard/.conductor run scripts for this thread (same menu as the desktop Dev button) and which are active. Each script and active run includes preview: url (open http://localhost:<SIDEBOARD_PORT>) or window (Electron: native window is the app; url is renderer/HMR only). Never guess :3000. Worktree turns may omit ref (uses cwd).",
13382
13460
  {
13383
- ref: z9.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd).")
13461
+ ref: z10.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd).")
13384
13462
  },
13385
13463
  async ({ ref }) => {
13386
13464
  try {
@@ -13410,8 +13488,8 @@ async function startMcpServer() {
13410
13488
  "run_dev_script",
13411
13489
  "Start a .sideboard/.conductor run script (same as the desktop Dev / play button). Several named scripts can run at once; each gets its own port, and starting one does not stop the others. Logs and Stop appear in the thread UI \u2014 do not detached-job or shell-spawn the same command. Returns {port, ports, url, preview}. preview=url \u2192 open url (browser, curl, Playwright). preview=window \u2192 Electron: the native window is the app; url is renderer/HMR only (no preload/IPC in a browser). The port is allocated SIDEBOARD_PORT, not 3000. Worktree turns may omit ref (uses cwd). Omit name for the default script.",
13412
13490
  {
13413
- ref: z9.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd)."),
13414
- name: z9.string().optional().describe("Script name from list_run_scripts (default script if omitted).")
13491
+ ref: z10.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd)."),
13492
+ name: z10.string().optional().describe("Script name from list_run_scripts (default script if omitted).")
13415
13493
  },
13416
13494
  async ({ ref, name }) => {
13417
13495
  try {
@@ -13439,8 +13517,8 @@ async function startMcpServer() {
13439
13517
  "stop_dev_script",
13440
13518
  "Stop a run script started with run_dev_script or the desktop Dev button (same as UI Stop). Omit name to stop all scripts on this worktree. Worktree turns may omit ref (uses cwd).",
13441
13519
  {
13442
- ref: z9.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd)."),
13443
- name: z9.string().optional().describe("Script name to stop; omit to stop all active scripts.")
13520
+ ref: z10.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd)."),
13521
+ name: z10.string().optional().describe("Script name to stop; omit to stop all active scripts.")
13444
13522
  },
13445
13523
  async ({ ref, name }) => {
13446
13524
  try {
@@ -13457,9 +13535,9 @@ async function startMcpServer() {
13457
13535
  "get_run_log",
13458
13536
  "Read the Run-tab terminal for a worktree script (same stdout/stderr as the desktop Dev pane). Default is a tail \u2014 raise `tail` only if the error is missing. Worktree turns may omit ref (uses cwd). Omit name for the default script.",
13459
13537
  {
13460
- ref: z9.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd)."),
13461
- name: z9.string().optional().describe("Script name from list_run_scripts (default script if omitted)."),
13462
- tail: z9.number().int().min(1).max(MAX_RUN_LOG_CHARS).optional().describe(
13538
+ ref: z10.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd)."),
13539
+ name: z10.string().optional().describe("Script name from list_run_scripts (default script if omitted)."),
13540
+ tail: z10.number().int().min(1).max(MAX_RUN_LOG_CHARS).optional().describe(
13463
13541
  `Max characters to return from the end (default ${DEFAULT_RUN_LOG_TAIL_CHARS}). Do not request the full buffer unless the tail is truncated and you still need more.`
13464
13542
  )
13465
13543
  },
@@ -13513,8 +13591,8 @@ async function startMcpServer() {
13513
13591
  }
13514
13592
  });
13515
13593
  } catch (err) {
13516
- const text5 = err instanceof Error ? err.message : String(err);
13517
- return { content: [{ type: "text", text: text5 }], isError: true };
13594
+ const text6 = err instanceof Error ? err.message : String(err);
13595
+ return { content: [{ type: "text", text: text6 }], isError: true };
13518
13596
  }
13519
13597
  }
13520
13598
  );
@@ -13522,8 +13600,8 @@ async function startMcpServer() {
13522
13600
  "notify_orchestrator",
13523
13601
  "Wake the parent Global orchestrator with a short status so it does not have to poll wait_for_turn. Use when you are blocked and the parent may have moved on (missing access, waiting on something the coordinator must handle). The message is shown on the sidebar and board until the next user message in this chat. ask_user already notifies for input-required \u2014 do not call this for the same question. Information only: never a git command. Do not use this to steer other worktrees.",
13524
13602
  {
13525
- message: z9.string().min(1).max(1500).describe("Why you are blocked / what the parent should know (short)."),
13526
- reason: z9.enum(["input-required", "blocked"]).optional().describe(
13603
+ message: z10.string().min(1).max(1500).describe("Why you are blocked / what the parent should know (short)."),
13604
+ reason: z10.enum(["input-required", "blocked"]).optional().describe(
13527
13605
  "input-required = waiting on the user in this chat; blocked = need the coordinator (default)."
13528
13606
  )
13529
13607
  },
@@ -13549,23 +13627,24 @@ async function startMcpServer() {
13549
13627
  ...result.deduped ? { deduped: true } : {}
13550
13628
  });
13551
13629
  } catch (err) {
13552
- const text5 = err instanceof Error ? err.message : String(err);
13553
- return { content: [{ type: "text", text: text5 }], isError: true };
13630
+ const text6 = err instanceof Error ? err.message : String(err);
13631
+ return { content: [{ type: "text", text: text6 }], isError: true };
13554
13632
  }
13555
13633
  }
13556
13634
  );
13557
13635
  }
13558
13636
  registerScheduleTools(server);
13637
+ registerFollowUpTools(server);
13559
13638
  registerOrderTools(server);
13560
13639
  server.tool(
13561
13640
  "set_workspace_tags",
13562
13641
  worktreeProfile ? "Update tags on this workspace (the checkout you are in). Omit ref to use this chat. mode=replace (default), add, or remove. Short labels \u2014 the same ones the orchestrator used for this task. You cannot retag a different checkout." : "Label a project workspace so related checkouts stay recognizable in the sidebar and on the phone. Pass any chat id on that workspace. Use the same tags on every workspace from one task. mode=replace is the default; add and remove change the set. create_workspace tags= sets them at create time. Not for orchestration chats.",
13563
13642
  {
13564
- ref: z9.string().optional().describe(
13643
+ ref: z10.string().optional().describe(
13565
13644
  worktreeProfile ? "Omit for this chat. Another chat id only if it is on this same checkout." : "Chat id on the workspace to label."
13566
13645
  ),
13567
- tags: z9.union([z9.string(), z9.array(z9.string())]).describe("Labels to set. A string may be comma-separated."),
13568
- mode: z9.enum(["replace", "add", "remove"]).optional()
13646
+ tags: z10.union([z10.string(), z10.array(z10.string())]).describe("Labels to set. A string may be comma-separated."),
13647
+ mode: z10.enum(["replace", "add", "remove"]).optional()
13569
13648
  },
13570
13649
  async ({ ref, tags, mode }) => {
13571
13650
  try {
@@ -13593,10 +13672,10 @@ async function startMcpServer() {
13593
13672
  "set_wake_on_github_edges",
13594
13673
  worktreeProfile ? "Opt this checkout into orchestrator wakes when CI starts failing or GitHub requests a review. Omit ref. Only works after Settings \u2192 Advanced \u2192 Wake orchestrator on CI / review-requested is on. Do not change that Advanced switch." : "Opt a project workspace into CI and review-request wakes. Pass any chat id on that checkout. Only works after Settings \u2192 Advanced \u2192 Wake orchestrator on CI / review-requested is already on. Do not change that Advanced switch. Not for orchestration chats.",
13595
13674
  {
13596
- ref: z9.string().optional().describe(
13675
+ ref: z10.string().optional().describe(
13597
13676
  worktreeProfile ? "Omit for this chat. Another chat id only if it is on this same checkout." : "Chat id on the workspace."
13598
13677
  ),
13599
- enabled: z9.boolean().describe("True opts the checkout in. False turns it off.")
13678
+ enabled: z10.boolean().describe("True opts the checkout in. False turns it off.")
13600
13679
  },
13601
13680
  async ({ ref, enabled }) => {
13602
13681
  try {
@@ -13629,7 +13708,7 @@ async function startMcpServer() {
13629
13708
  "set_caffeinate",
13630
13709
  "Keep this Mac awake with caffeinate across turns \u2014 independent of Settings toggles. A connected phone already holds caffeinate (lid can close on power), so do not turn this on just because they are on the phone. Turn ON when the user will be away and no phone is connected, or they ask you to keep the machine awake. Turn OFF when they say they are done, wrapping up, going to sleep, or no longer need the Mac awake. Closing or archiving this orchestration chat also releases the hold. macOS only.",
13631
13710
  {
13632
- enabled: z9.boolean().describe("true = hold caffeinate on; false = release and let the Mac sleep")
13711
+ enabled: z10.boolean().describe("true = hold caffeinate on; false = release and let the Mac sleep")
13633
13712
  },
13634
13713
  async ({ enabled }) => {
13635
13714
  const threadId = process.env.SIDEBOARD_ORCHESTRATOR_THREAD_ID?.trim() || null;
@@ -13655,24 +13734,24 @@ async function startMcpServer() {
13655
13734
  "create_workspace",
13656
13735
  `Create a workspace (isolated git checkout + first chat) from branch, pr, or ticket. A ticket, PR, or named branch has one checkout \u2014 if one already matches, returns it (alreadyStarted=true) instead of a second checkout. That is not one agent: chats lists every agent on that checkout. Add another with fork_chat; send_to_chat only the chat that should do this job. Creating from the default branch still opens a new isolated checkout. Pass repoPath from list_projects. cowboy=true uses the project folder on the default branch (no isolated worktree; land is commit+push). From an orchestration chat, omit parentChatId (Sideboard binds the child to this chat) or pass the exact id from the turn reminder \u2014 never invent a uuid. Omit agent/model \u2014 Sideboard applies ${accountDefaultsHint}. Do not pass your own agent or agent=cursor; those are ignored. Setup (settings.toml, .cursor/worktrees.json, or script/setup) runs in the background in parallel with the first turn (skipped for cowboy). Pass the same tags on every workspace you open for one task (short labels such as "phone-sync") so they still match in the sidebar the next day. Reusing a checkout adds those tags. Each orchestration chat can create at most the Settings \u2192 Advanced \u201CMax orchestration threads\u201D cap of child workspaces (default 5). fork_chat on an existing checkout does not use a slot.`,
13657
13736
  {
13658
- sourceType: z9.enum(["branch", "pr", "ticket"]),
13659
- sourceRef: z9.string(),
13660
- agent: z9.enum(["claude", "codex", "opencode", "brightsy", "cursor"]).optional().describe(
13737
+ sourceType: z10.enum(["branch", "pr", "ticket"]),
13738
+ sourceRef: z10.string(),
13739
+ agent: z10.enum(["claude", "codex", "opencode", "brightsy", "cursor"]).optional().describe(
13661
13740
  `Usually omit. Sideboard uses Account default agent (${accountDefaults.agent}). Passing your own agent or cursor is ignored.`
13662
13741
  ),
13663
- model: z9.string().nullable().optional().describe(
13742
+ model: z10.string().nullable().optional().describe(
13664
13743
  `Usually omit to use Account default model (${accountDefaults.model?.trim() || "Auto"}). Pass null only to force Auto / agent-default.`
13665
13744
  ),
13666
- repoPath: z9.string(),
13667
- title: z9.string().optional(),
13668
- cowboy: z9.boolean().optional().describe(
13745
+ repoPath: z10.string(),
13746
+ title: z10.string().optional(),
13747
+ cowboy: z10.boolean().optional().describe(
13669
13748
  "If true, work in the project folder on the default branch (no thread/* worktree). Requires Settings \u2192 Advanced \u2192 Cowboy mode. Land is commit+push to that branch. Archive does not delete the folder."
13670
13749
  ),
13671
- parentChatId: z9.string().optional().describe(
13750
+ parentChatId: z10.string().optional().describe(
13672
13751
  "Orchestration: omit (preferred) or pass YOUR chat id from the turn reminder / AGENTS.md. Do not invent uuids."
13673
13752
  ),
13674
- parentThreadId: z9.string().optional().describe("Legacy alias for parentChatId."),
13675
- tags: z9.union([z9.string(), z9.array(z9.string())]).optional().describe(
13753
+ parentThreadId: z10.string().optional().describe("Legacy alias for parentChatId."),
13754
+ tags: z10.union([z10.string(), z10.array(z10.string())]).optional().describe(
13676
13755
  "Short labels for this workspace (or a comma-separated string). Use the same tags on every checkout for one task. Added when the checkout already exists."
13677
13756
  )
13678
13757
  },
@@ -13688,11 +13767,11 @@ async function startMcpServer() {
13688
13767
  "start_board_card",
13689
13768
  "Same as create_workspace for a ticket, PR, or named branch (attaches issue text when Sideboard can resolve it). Does not create a second checkout when one already matches \u2014 returns that workspace (alreadyStarted) and its chats. A workspace can have many agents. fork_chat to add one; send_to_chat only the chat that should do this job.",
13690
13769
  {
13691
- kind: z9.enum(["ticket", "pr", "branch"]),
13692
- ref: z9.string().describe("Ticket identifier (ENG-12), PR number (44), or branch name from list_board"),
13693
- repoPath: z9.string().describe("Project path from list_projects / list_board"),
13694
- title: z9.string().optional(),
13695
- tags: z9.union([z9.string(), z9.array(z9.string())]).optional().describe(
13770
+ kind: z10.enum(["ticket", "pr", "branch"]),
13771
+ ref: z10.string().describe("Ticket identifier (ENG-12), PR number (44), or branch name from list_board"),
13772
+ repoPath: z10.string().describe("Project path from list_projects / list_board"),
13773
+ title: z10.string().optional(),
13774
+ tags: z10.union([z10.string(), z10.array(z10.string())]).optional().describe(
13696
13775
  "Short labels for this workspace. Same tags on every checkout for one task. Added when the checkout already exists."
13697
13776
  )
13698
13777
  },
@@ -13795,11 +13874,11 @@ async function startMcpServer() {
13795
13874
  );
13796
13875
  server.tool(
13797
13876
  "send_to_chat",
13798
- 'Steer a prompt on a workspace chat (Settings \u2192 Follow-up, default steer: interrupt the in-flight turn and start now, same as the workspace composer). Use after create_workspace to start or continue a conversation. For commit/push/PR, prefer ask_git (canonical desktop-button phrases). Send "Merge PR." / ask_git merge only when the user explicitly asked to merge. force_stop=true kills the in-flight turn and clears the queue before this prompt \u2014 only when the current request is wrong and must be replaced. Do not send_to_chat to check in, resume after a halt notice, or because wait_for_turn returned stillRunning; that interrupts the child mid-thought. Call wait_for_turn again instead.',
13877
+ 'Send a prompt to a workspace chat. A second send joins that prompt only while it is still queued or not yet handed to the process. Once the process has started, the send waits behind the turn and does not stop it or change the prompt already running. force_stop=true kills the in-flight turn and clears the queue before this prompt \u2014 only when the current request is wrong and must be replaced. The workspace composer still follows Settings \u2192 Follow-up. Use after create_workspace to start or continue a conversation. For commit/push/PR, prefer ask_git (canonical desktop-button phrases). Send "Merge PR." / ask_git merge only when the user explicitly asked to merge. Do not send_to_chat to check in, resume after a halt notice, or because wait_for_turn returned stillRunning. Call wait_for_turn again instead.',
13799
13878
  {
13800
- ref: z9.string(),
13801
- prompt: z9.string(),
13802
- force_stop: z9.boolean().optional()
13879
+ ref: z10.string(),
13880
+ prompt: z10.string(),
13881
+ force_stop: z10.boolean().optional()
13803
13882
  },
13804
13883
  async ({ ref, prompt, force_stop }) => {
13805
13884
  if (force_stop) {
@@ -13809,7 +13888,7 @@ async function startMcpServer() {
13809
13888
  }
13810
13889
  }
13811
13890
  const thread = await orch.send(ref, prompt, {
13812
- followUp: resolveOrchChildFollowUp()
13891
+ followUp: force_stop ? "steer" : "join"
13813
13892
  });
13814
13893
  return mcpJson({
13815
13894
  id: thread.id,
@@ -13822,10 +13901,10 @@ async function startMcpServer() {
13822
13901
  if (shouldRegisterMcpWaitForTurn()) {
13823
13902
  server.tool(
13824
13903
  "wait_for_turn",
13825
- "Wait until the chat finishes its current/queued turn, or return early with a live progress snapshot. MCP clients often kill tools around 60s, so this returns within 45s even while the child is still working. taskState is the A2A-style lifecycle: submitted (queued, not started), working, input-required (ask_user), completed, failed, canceled. stillRunning is true only for submitted/working. blockedReason is why the child is waiting on a person (the question, plan approval, or a reported block) \u2014 read it and do not send_to_chat a check-in. If stillRunning, text and usage are empty (they would be the previous turn) \u2014 read progress and call wait_for_turn again. Do not send_to_chat a check-in (that steers / interrupts). On failed, lastError/text is the failure. On canceled, the child did not finish \u2014 resume with send_to_chat or tell the user. On input-required, wait for the user in that chat. When finished, text is this turn\u2019s assistant reply and usage is that turn\u2019s tokens + costUsd (this turn, not the Claude session total; sessionCostUsd is the provider session total when present).",
13904
+ "Wait until the chat finishes its current/queued turn, or return early with a live progress snapshot. MCP clients often kill tools around 60s, so this returns within 45s even while the child is still working. taskState is the A2A-style lifecycle: submitted (queued, not started), working, input-required (ask_user), completed, failed, canceled. stillRunning is true only for submitted/working. blockedReason is why the child is waiting on a person (the question, plan approval, or a reported block) \u2014 read it and do not send_to_chat a check-in. If stillRunning, text and usage are empty (they would be the previous turn) \u2014 read progress and call wait_for_turn again. Do not send_to_chat a check-in. On failed, read failureClass: auth, quota, and refused are not a retry; timeout or runner can be one. lastError/text is the failure. On canceled, the child did not finish \u2014 resume with send_to_chat or tell the user. On input-required, wait for the user in that chat. When finished, text is this turn\u2019s assistant reply and usage is that turn\u2019s tokens + costUsd (this turn, not the Claude session total; sessionCostUsd is the provider session total when present).",
13826
13905
  {
13827
- ref: z9.string(),
13828
- timeoutMs: z9.number().optional()
13906
+ ref: z10.string(),
13907
+ timeoutMs: z10.number().optional()
13829
13908
  },
13830
13909
  async ({ ref, timeoutMs }) => {
13831
13910
  const thread = await orch.waitForTurn(ref, mcpWaitForTurnTimeoutMs(timeoutMs), {
@@ -13852,14 +13931,16 @@ async function startMcpServer() {
13852
13931
  }
13853
13932
  server.tool(
13854
13933
  "get_turn_result",
13855
- "Assistant message and last-turn usage when the turn finished. While stillRunning (submitted/working), text and usage are empty so a previous reply cannot be mistaken for this turn \u2014 use progress for tools/thinking. Not the full transcript. Includes taskState (A2A lifecycle) and blockedReason (why the agent is waiting on a person).",
13856
- { ref: z9.string() },
13934
+ "Assistant message and last-turn usage when the turn finished. While stillRunning (submitted/working), text and usage are empty so a previous reply cannot be mistaken for this turn \u2014 use progress for tools/thinking. Not the full transcript. Includes taskState (A2A lifecycle), failureClass when the turn failed (auth, quota, refused, timeout, runner, other), and blockedReason (why the agent is waiting on a person).",
13935
+ { ref: z10.string() },
13857
13936
  async ({ ref }) => {
13858
13937
  const result = orch.getTurnResult(ref);
13859
- const hint = mcpWaitTaskHint(result.taskState, result.status, result.blockedReason);
13938
+ const failureClass = result.taskState === "failed" && result.status !== "broken" ? classifyTurnFailure(result.lastError || result.text) : null;
13939
+ const hint = mcpWaitTaskHint(result.taskState, result.status, result.blockedReason, failureClass);
13860
13940
  const waiting = Boolean(result.blockedReason) && !result.stillRunning && result.taskState !== "failed" && result.taskState !== "canceled";
13861
13941
  return mcpJson({
13862
13942
  ...result,
13943
+ failureClass,
13863
13944
  hint,
13864
13945
  incomplete: needsCoordinatorAction(result.taskState) || waiting
13865
13946
  });
@@ -13869,9 +13950,9 @@ async function startMcpServer() {
13869
13950
  "stop_chat",
13870
13951
  "Force-stop a thread: kill any in-flight agent turn AND clear queued prompts so drainQueue cannot continue. Does not archive the worktree. Optional force defaults to true. Pass reason \u2014 a short note on why this chat is stopping. It is stored on the thread and kept when the turn unwinds. If you omit it, Sideboard still records that the queue was cleared.",
13871
13952
  {
13872
- ref: z9.string(),
13873
- force: z9.boolean().optional(),
13874
- reason: z9.string().optional().describe("Why this chat is stopping. Stored on the thread for the next session.")
13953
+ ref: z10.string(),
13954
+ force: z10.boolean().optional(),
13955
+ reason: z10.string().optional().describe("Why this chat is stopping. Stored on the thread for the next session.")
13875
13956
  },
13876
13957
  async ({ ref, force, reason }) => {
13877
13958
  const t = orch.getThread(ref);
@@ -13897,8 +13978,8 @@ async function startMcpServer() {
13897
13978
  "get_diff",
13898
13979
  "Compact diff summary (capped hunks, paginated)",
13899
13980
  {
13900
- ref: z9.string(),
13901
- maxFiles: z9.number().optional()
13981
+ ref: z10.string(),
13982
+ maxFiles: z10.number().optional()
13902
13983
  },
13903
13984
  async ({ ref, maxFiles }) => {
13904
13985
  const summary = await orch.diffSummary(ref);
@@ -13911,7 +13992,7 @@ async function startMcpServer() {
13911
13992
  server.tool(
13912
13993
  "get_pr_checks",
13913
13994
  "Snapshot of GitHub PR checks for a worktree thread (`gh pr checks` plus merge/review gates). null = no PR. If the user gave a goal (Greptile 5/5, CI green), the worktree agent watches with `gh pr checks --watch` via /long-running \u2014 this tool is a snapshot, not a waiter. Coordinators: do not run gh from the orchestration cwd.",
13914
- { ref: z9.string().describe("Worktree thread id/ref") },
13995
+ { ref: z10.string().describe("Worktree thread id/ref") },
13915
13996
  async ({ ref }) => {
13916
13997
  try {
13917
13998
  const checks = await orch.getPrChecks(ref);
@@ -13925,7 +14006,7 @@ async function startMcpServer() {
13925
14006
  server.tool(
13926
14007
  "request_review",
13927
14008
  'Start a merge-readiness Review on a worktree agent thread (same as the desktop Review button). If that worktree has a single unused idle agent (no messages), runs the review there; otherwise opens a new Review chat tab. Attaches .claude/skills/review/SKILL.md when present (else copies .sideboard/review.md into .context/review.md, or seeds that file from the stock template), and sends "Review changes in this workspace." Expect Approve / Approve with nits / Request changes / Needs more information in that chat. The review stays there so the user can read it and type next steps \u2014 do not comment on or update the PR or ticket, and do not ask_user after the review, until they ask. Pass a worktree thread ref \u2014 not the orchestrator. Then wait_for_turn (loop while stillRunning) / get_turn_result on the returned review thread id.',
13928
- { ref: z9.string().describe("Worktree thread id/ref to review") },
14009
+ { ref: z10.string().describe("Worktree thread id/ref to review") },
13929
14010
  async ({ ref }) => {
13930
14011
  try {
13931
14012
  const tab = await orch.requestReview(ref);
@@ -13947,8 +14028,8 @@ async function startMcpServer() {
13947
14028
  "ask_git",
13948
14029
  "Commit & push, open a draft PR, mark ready for review, resolve conflicts, or merge \u2014 same prompts as the desktop git buttons (including Resolve). Always steers the worktree agent; does not push or open the PR locally. Then wait_for_turn (loop while stillRunning). Do not start a checks loop on a plain push \u2014 only if the user gave a goal (CI green, a review score, until checks pass). A push can wake a third-party PR review; the worktree agent acknowledges it only inside that goal. Pass a worktree thread ref (not the orchestrator). action=ready-for-review and action=merge only when the user explicitly asked (or clicked the desktop button). Do not run git or gh from the orchestration cwd.",
13949
14030
  {
13950
- ref: z9.string().describe("Worktree thread id/ref"),
13951
- action: z9.enum(AGENT_GIT_ACTIONS).describe(
14031
+ ref: z10.string().describe("Worktree thread id/ref"),
14032
+ action: z10.enum(AGENT_GIT_ACTIONS).describe(
13952
14033
  "commit-push | create-draft | create-web | resolve-conflicts | ready-for-review | merge"
13953
14034
  )
13954
14035
  },
@@ -13977,7 +14058,7 @@ async function startMcpServer() {
13977
14058
  }
13978
14059
  }
13979
14060
  );
13980
- const agentEnum = z9.enum(["claude", "codex", "opencode", "brightsy", "cursor"]);
14061
+ const agentEnum = z10.enum(["claude", "codex", "opencode", "brightsy", "cursor"]);
13981
14062
  server.tool(
13982
14063
  "list_models",
13983
14064
  "List models for an agent. Prefer Auto: do not call this unless you have a reason to pin a specific model (user request, cost/latency, capability). Omit agent to list all.",
@@ -13998,11 +14079,11 @@ async function startMcpServer() {
13998
14079
  "fork_workspace",
13999
14080
  "Fork a worktree agent chat into a NEW git worktree + chat (desktop \u201CFork to new workspace\u201D). Seeds a transcript (through through_index, default all). Optional agent override. Leave model unset for Auto (default) \u2014 only pass model when you have a reason. Not for the orchestrator. Then send_to_chat / wait_for_turn (loop while stillRunning) on the returned id.",
14000
14081
  {
14001
- ref: z9.string().describe("Worktree thread id/ref to fork"),
14002
- through_index: z9.number().optional().describe("Inclusive message index to include in the transcript (default: all)"),
14082
+ ref: z10.string().describe("Worktree thread id/ref to fork"),
14083
+ through_index: z10.number().optional().describe("Inclusive message index to include in the transcript (default: all)"),
14003
14084
  agent: agentEnum.optional().describe("Agent for the forked chat (default: same as source)"),
14004
- model: z9.string().nullable().optional().describe("Usually omit (Auto). Only set from list_models when you need a specific model"),
14005
- title: z9.string().optional()
14085
+ model: z10.string().nullable().optional().describe("Usually omit (Auto). Only set from list_models when you need a specific model"),
14086
+ title: z10.string().optional()
14006
14087
  },
14007
14088
  async ({ ref, through_index, agent, model, title }) => {
14008
14089
  try {
@@ -14036,11 +14117,11 @@ async function startMcpServer() {
14036
14117
  "fork_chat",
14037
14118
  "Add another agent chat on the SAME workspace (same files, Run, and git). Also forks a Global orchestration chat into a new orchestration tab. Pass agent when the new chat should use a different harness. Leave model unset for Auto unless you have a reason. Orchestration forks require an MCP-capable agent (claude, cursor, codex, opencode \u2014 not brightsy). Use this for a second agent on a checkout (review, another harness, parallel work on the same branch). Do not create_workspace again for that \u2014 it returns the existing checkout. Then send_to_chat / wait_for_turn (loop while stillRunning) on the returned id. Use fork_workspace only when the work needs its own git checkout.",
14038
14119
  {
14039
- ref: z9.string().describe("Thread id/ref to fork (worktree agent or orchestration chat)"),
14040
- through_index: z9.number().optional().describe("Inclusive message index to include in the transcript (default: all)"),
14120
+ ref: z10.string().describe("Thread id/ref to fork (worktree agent or orchestration chat)"),
14121
+ through_index: z10.number().optional().describe("Inclusive message index to include in the transcript (default: all)"),
14041
14122
  agent: agentEnum.optional().describe("Agent for the forked chat (default: same as source)"),
14042
- model: z9.string().nullable().optional().describe("Usually omit (Auto). Only set from list_models when you need a specific model"),
14043
- title: z9.string().optional()
14123
+ model: z10.string().nullable().optional().describe("Usually omit (Auto). Only set from list_models when you need a specific model"),
14124
+ title: z10.string().optional()
14044
14125
  },
14045
14126
  async ({ ref, through_index, agent, model, title }) => {
14046
14127
  try {
@@ -14078,7 +14159,7 @@ async function startMcpServer() {
14078
14159
  server.tool(
14079
14160
  "run_setup",
14080
14161
  "Re-run workspace setup (Sideboard/Conductor settings, .cursor/worktrees.json, or script/setup). New worktrees already run this automatically.",
14081
- { ref: z9.string() },
14162
+ { ref: z10.string() },
14082
14163
  async ({ ref }) => {
14083
14164
  const result = await orch.runSetup(ref);
14084
14165
  return mcpJson(result);
@@ -14087,7 +14168,7 @@ async function startMcpServer() {
14087
14168
  server.tool(
14088
14169
  "add_project",
14089
14170
  "Register a git repo as a Sideboard workspace",
14090
- { repoPath: z9.string() },
14171
+ { repoPath: z10.string() },
14091
14172
  async ({ repoPath }) => {
14092
14173
  const ws = await orch.addWorkspace(repoPath);
14093
14174
  return mcpJson(ws);
@@ -14096,7 +14177,7 @@ async function startMcpServer() {
14096
14177
  server.tool(
14097
14178
  "remove_project",
14098
14179
  "Unregister a Sideboard workspace and archive its chats",
14099
- { repoPath: z9.string() },
14180
+ { repoPath: z10.string() },
14100
14181
  async ({ repoPath }) => {
14101
14182
  await orch.removeWorkspace(repoPath);
14102
14183
  return { content: [{ type: "text", text: "ok" }] };
@@ -14106,12 +14187,12 @@ async function startMcpServer() {
14106
14187
  "fanout",
14107
14188
  "Best-of-n: create one thread per agent with the same prompt (parallel attempts)",
14108
14189
  {
14109
- prompt: z9.string(),
14110
- agents: z9.array(z9.enum(["claude", "codex", "opencode", "brightsy", "cursor"])),
14111
- repoPath: z9.string(),
14112
- sourceType: z9.enum(["branch", "pr", "ticket"]).optional(),
14113
- sourceRef: z9.string().optional(),
14114
- title: z9.string().optional()
14190
+ prompt: z10.string(),
14191
+ agents: z10.array(z10.enum(["claude", "codex", "opencode", "brightsy", "cursor"])),
14192
+ repoPath: z10.string(),
14193
+ sourceType: z10.enum(["branch", "pr", "ticket"]).optional(),
14194
+ sourceRef: z10.string().optional(),
14195
+ title: z10.string().optional()
14115
14196
  },
14116
14197
  async (args) => {
14117
14198
  const threads = await orch.bestOfN(args);
@@ -14129,8 +14210,8 @@ async function startMcpServer() {
14129
14210
  "list_branches",
14130
14211
  "List git branches in a registered workspace. Pass repoPath from list_projects (unmerged into the default branch by default \u2014 for create_workspace sourceType=branch).",
14131
14212
  {
14132
- repoPath: z9.string(),
14133
- unmergedOnly: z9.boolean().optional()
14213
+ repoPath: z10.string(),
14214
+ unmergedOnly: z10.boolean().optional()
14134
14215
  },
14135
14216
  async ({ repoPath, unmergedOnly }) => {
14136
14217
  const root = await resolveRepoRoot(repoPath);
@@ -14151,19 +14232,19 @@ async function startMcpServer() {
14151
14232
  "list_prs",
14152
14233
  `List GitHub PRs for a registered workspace (the review surface for assigned ticket work \u2014 not the tickets). Pass repoPath from list_projects. "Get me N tickets to review" \u2192 queue=review and limit=N: open non-draft PRs labeled with this project's ready-for-review GitHub label (Settings \u2192 Projects; default eng-review) with no individual user reviewer. Prefer teams that match Settings \u2192 Agents / Projects roles for this repo. A team like engineering-team is not a claim (you are on that team). Also: state (open|closed|merged|all|review), label, reviewer (me|unassigned|login), query, limit (default 40, max 250). Then create_workspace with sourceType=pr.`,
14153
14234
  {
14154
- repoPath: z9.string(),
14155
- query: z9.string().optional().describe("GitHub search tokens (title, draft:true, \u2026)"),
14156
- queue: z9.enum(["review", "mine", "approved", "changes"]).optional().describe(
14235
+ repoPath: z10.string(),
14236
+ query: z10.string().optional().describe("GitHub search tokens (title, draft:true, \u2026)"),
14237
+ queue: z10.enum(["review", "mine", "approved", "changes"]).optional().describe(
14157
14238
  "review = unclaimed ready-for-review inbox (Settings \u2192 Projects label, default eng-review). mine = review-requested:@me. approved / changes = eng-approved / eng-requested-changes."
14158
14239
  ),
14159
- state: z9.enum(["open", "closed", "merged", "all", "review"]).optional().describe("GitHub PR state (default open). review is an alias for queue=review."),
14160
- label: z9.string().optional().describe(
14240
+ state: z10.enum(["open", "closed", "merged", "all", "review"]).optional().describe("GitHub PR state (default open). review is an alias for queue=review."),
14241
+ label: z10.string().optional().describe(
14161
14242
  "GitHub label / workflow tag. Comma-separated AND. Examples: eng-review, eng-approved, eng-requested-changes"
14162
14243
  ),
14163
- reviewer: z9.string().optional().describe(
14244
+ reviewer: z10.string().optional().describe(
14164
14245
  "me (review requested of you), unassigned (no individual reviewer; team queues like engineering-team still count), all, or a GitHub login"
14165
14246
  ),
14166
- limit: z9.number().int().positive().max(250).optional().describe("Page size (default 40, max 250). Raise when truncated is true.")
14247
+ limit: z10.number().int().positive().max(250).optional().describe("Page size (default 40, max 250). Raise when truncated is true.")
14167
14248
  },
14168
14249
  async ({ repoPath, query, queue, state, label, reviewer, limit }) => {
14169
14250
  const root = await resolveRepoRoot(repoPath);
@@ -14196,7 +14277,7 @@ async function startMcpServer() {
14196
14277
  server.tool(
14197
14278
  "get_pr_stack",
14198
14279
  "Load the GitHub PR stack for a thread worktree (`gh stack view --json`). Returns null JSON when the branch is not stacked. Prefer this before ask_git merge on stacked PRs (and only merge when the user explicitly asked).",
14199
- { ref: z9.string() },
14280
+ { ref: z10.string() },
14200
14281
  async ({ ref }) => {
14201
14282
  const stack = await orch.getPrStack(ref);
14202
14283
  return mcpJson(stack);
@@ -14206,8 +14287,8 @@ async function startMcpServer() {
14206
14287
  "open_pr_stack_layers",
14207
14288
  "Materialize one worktree+thread per stack layer (or a single 1-based layer). Pass a thread ref already on the stack.",
14208
14289
  {
14209
- ref: z9.string(),
14210
- layer: z9.number().int().positive().optional()
14290
+ ref: z10.string(),
14291
+ layer: z10.number().int().positive().optional()
14211
14292
  },
14212
14293
  async ({ ref, layer }) => {
14213
14294
  const result = await orch.openPrStackLayers(ref, { layer });
@@ -14230,9 +14311,9 @@ async function startMcpServer() {
14230
14311
  "add_stack_layer",
14231
14312
  "Add a branch on top of the current stack (`gh stack add`) and open a worktree+thread for it.",
14232
14313
  {
14233
- ref: z9.string(),
14234
- branchName: z9.string(),
14235
- title: z9.string().optional()
14314
+ ref: z10.string(),
14315
+ branchName: z10.string(),
14316
+ title: z10.string().optional()
14236
14317
  },
14237
14318
  async ({ ref, branchName, title }) => {
14238
14319
  const result = await orch.addStackLayer(ref, branchName, { title });
@@ -14250,11 +14331,11 @@ async function startMcpServer() {
14250
14331
  "create_pr_stack",
14251
14332
  "Create a new GitHub PR stack with one Sideboard worktree per layer (bottom\u2192top branch names). Requires `gh extension install github/gh-stack`.",
14252
14333
  {
14253
- repoPath: z9.string(),
14254
- branches: z9.array(z9.string()).min(1),
14255
- agent: z9.enum(["claude", "codex", "opencode", "brightsy", "cursor"]),
14256
- base: z9.string().optional(),
14257
- title: z9.string().optional()
14334
+ repoPath: z10.string(),
14335
+ branches: z10.array(z10.string()).min(1),
14336
+ agent: z10.enum(["claude", "codex", "opencode", "brightsy", "cursor"]),
14337
+ base: z10.string().optional(),
14338
+ title: z10.string().optional()
14258
14339
  },
14259
14340
  async (args) => {
14260
14341
  const result = await orch.createPrStack({
@@ -14282,10 +14363,10 @@ async function startMcpServer() {
14282
14363
  "list_issues",
14283
14364
  "List or search issues (Linear, AbleTime, or GitHub; falls back to GitHub). Cursor Origin has no issue tracker \u2014 a Cursor repo returns unavailableReason unless Linear or AbleTime is the source. Entire tickets are Trails (`entire trail`), not GitHub Issues, so an Entire repo does the same unless Linear or AbleTime is the source. Use Settings \u2192 Agents / Projects notes and roles to pick tickets relevant to the viewer (query + assignee=me or unassigned as the notes say). Default 40; pass query and/or limit (max 250) when truncated. assignee: me (Linear default), unassigned, all, or a user id. Pass updatedSince for new/updated tickets and new comments (\u201Cany updates since yesterday?\u201D). Then create_workspace with sourceType=ticket.",
14284
14365
  {
14285
- repoPath: z9.string(),
14286
- query: z9.string().optional().describe("Search title, identifier, or description"),
14287
- assignee: z9.string().optional().describe("me (Linear default), unassigned, all, a user id, or a GitHub login"),
14288
- limit: z9.number().int().positive().max(250).optional().describe("Page size (default 40, max 250). Raise when truncated is true."),
14366
+ repoPath: z10.string(),
14367
+ query: z10.string().optional().describe("Search title, identifier, or description"),
14368
+ assignee: z10.string().optional().describe("me (Linear default), unassigned, all, a user id, or a GitHub login"),
14369
+ limit: z10.number().int().positive().max(250).optional().describe("Page size (default 40, max 250). Raise when truncated is true."),
14289
14370
  updatedSince: mcpIssueUpdatedSinceSchema
14290
14371
  },
14291
14372
  async ({ repoPath, query, assignee, limit, updatedSince }) => {
@@ -14897,8 +14978,8 @@ var BrightsySideboardApi = class {
14897
14978
  };
14898
14979
  function taskMessageText(task) {
14899
14980
  const parts = task.message?.parts ?? [];
14900
- const text5 = parts.find((p) => p.kind === "text")?.text ?? "";
14901
- return text5.trim();
14981
+ const text6 = parts.find((p) => p.kind === "text")?.text ?? "";
14982
+ return text6.trim();
14902
14983
  }
14903
14984
 
14904
14985
  // src/brightsy/cloud-connect.ts
@@ -15524,12 +15605,12 @@ function formatSlackInboundPrompt(msg) {
15524
15605
 
15525
15606
  ${msg.text}`;
15526
15607
  }
15527
- function isSlackInboundUserPrompt(text5) {
15528
- return text5.startsWith("Slack DM\n") || text5.startsWith("Slack @mention\n");
15608
+ function isSlackInboundUserPrompt(text6) {
15609
+ return text6.startsWith("Slack DM\n") || text6.startsWith("Slack @mention\n");
15529
15610
  }
15530
- function formatSlackSignedReply(deviceLabel, text5) {
15611
+ function formatSlackSignedReply(deviceLabel, text6) {
15531
15612
  const label = deviceLabel.trim();
15532
- const body = text5.trim();
15613
+ const body = text6.trim();
15533
15614
  if (!body) return body;
15534
15615
  if (!label) return body;
15535
15616
  const head = `${label}:`;
@@ -15538,8 +15619,8 @@ function formatSlackSignedReply(deviceLabel, text5) {
15538
15619
  }
15539
15620
  return `${label}: ${body}`;
15540
15621
  }
15541
- function signForThisMac(text5) {
15542
- return formatSlackSignedReply(ensureSlackDeviceIdentity().deviceLabel, text5);
15622
+ function signForThisMac(text6) {
15623
+ return formatSlackSignedReply(ensureSlackDeviceIdentity().deviceLabel, text6);
15543
15624
  }
15544
15625
  function slackReplyThreadTs(msg) {
15545
15626
  if (msg.threadTs && msg.threadTs !== msg.ts) return msg.threadTs;
@@ -15600,9 +15681,9 @@ function replyStub(target) {
15600
15681
  kind: "dm"
15601
15682
  };
15602
15683
  }
15603
- async function postSlackText(target, text5, opts) {
15684
+ async function postSlackText(target, text6, opts) {
15604
15685
  if (opts.postReply) {
15605
- const result = await opts.postReply(replyStub(target), text5);
15686
+ const result = await opts.postReply(replyStub(target), text6);
15606
15687
  const ts2 = result && typeof result === "object" && typeof result.ts === "string" ? result.ts.trim() : "";
15607
15688
  return ts2 ? { ts: ts2 } : null;
15608
15689
  }
@@ -15612,7 +15693,7 @@ async function postSlackText(target, text5, opts) {
15612
15693
  "chat.postMessage",
15613
15694
  {
15614
15695
  channel: target.channelId,
15615
- text: text5,
15696
+ text: text6,
15616
15697
  thread_ts: target.threadTs
15617
15698
  },
15618
15699
  opts.fetchImpl
@@ -15620,9 +15701,9 @@ async function postSlackText(target, text5, opts) {
15620
15701
  const ts = json.ts?.trim();
15621
15702
  return ts ? { ts } : null;
15622
15703
  }
15623
- async function updateSlackText(target, ts, text5, opts) {
15704
+ async function updateSlackText(target, ts, text6, opts) {
15624
15705
  if (opts.updateReply) {
15625
- await opts.updateReply(replyStub(target), ts, text5);
15706
+ await opts.updateReply(replyStub(target), ts, text6);
15626
15707
  return;
15627
15708
  }
15628
15709
  const token = writeTokenForTeam(target.teamId);
@@ -15632,7 +15713,7 @@ async function updateSlackText(target, ts, text5, opts) {
15632
15713
  {
15633
15714
  channel: target.channelId,
15634
15715
  ts,
15635
- text: text5
15716
+ text: text6
15636
15717
  },
15637
15718
  opts.fetchImpl
15638
15719
  );
@@ -15660,8 +15741,8 @@ function replyTargetOf(msg) {
15660
15741
  threadTs: slackReplyThreadTs(msg)
15661
15742
  };
15662
15743
  }
15663
- async function postSlackReply(msg, text5, opts) {
15664
- await postSlackText(replyTargetOf(msg), signForThisMac(text5), opts);
15744
+ async function postSlackReply(msg, text6, opts) {
15745
+ await postSlackText(replyTargetOf(msg), signForThisMac(text6), opts);
15665
15746
  }
15666
15747
  function startSlackTurnProgress(msg, threadId, opts) {
15667
15748
  const log = opts.onLog ?? (() => void 0);
@@ -15744,10 +15825,10 @@ function startSlackTurnProgress(msg, threadId, opts) {
15744
15825
  }
15745
15826
  });
15746
15827
  },
15747
- finishWith: (text5) => {
15828
+ finishWith: (text6) => {
15748
15829
  stop();
15749
15830
  return run2(async () => {
15750
- const signed2 = signForThisMac(text5.trim());
15831
+ const signed2 = signForThisMac(text6.trim());
15751
15832
  if (!signed2) {
15752
15833
  if (!postedTs) return;
15753
15834
  const ts = postedTs;
@@ -15775,11 +15856,11 @@ function startSlackTurnProgress(msg, threadId, opts) {
15775
15856
  };
15776
15857
  }
15777
15858
  var lastRelayed = /* @__PURE__ */ new Map();
15778
- function markRelayed(threadId, text5) {
15779
- lastRelayed.set(threadId, `${threadId}:${text5}`);
15859
+ function markRelayed(threadId, text6) {
15860
+ lastRelayed.set(threadId, `${threadId}:${text6}`);
15780
15861
  }
15781
- function alreadyRelayed(threadId, text5) {
15782
- return lastRelayed.get(threadId) === `${threadId}:${text5}`;
15862
+ function alreadyRelayed(threadId, text6) {
15863
+ return lastRelayed.get(threadId) === `${threadId}:${text6}`;
15783
15864
  }
15784
15865
  async function relayCoordinatorReplyToSlack(threadId, opts) {
15785
15866
  const target = getSlackReplyTarget(threadId);
@@ -15790,14 +15871,14 @@ async function relayCoordinatorReplyToSlack(threadId, opts) {
15790
15871
  return;
15791
15872
  }
15792
15873
  const result = getOrchestrator().getTurnResult(threadId);
15793
- const text5 = formatSlackTurnReply(result);
15794
- if (!text5) return;
15795
- if (alreadyRelayed(threadId, text5)) return;
15796
- markRelayed(threadId, text5);
15874
+ const text6 = formatSlackTurnReply(result);
15875
+ if (!text6) return;
15876
+ if (alreadyRelayed(threadId, text6)) return;
15877
+ markRelayed(threadId, text6);
15797
15878
  const log = opts.onLog ?? (() => void 0);
15798
15879
  try {
15799
- await postSlackText(target, signForThisMac(text5), opts);
15800
- log(`replied ${target.threadTs ?? target.channelId} (${text5.length} chars)`);
15880
+ await postSlackText(target, signForThisMac(text6), opts);
15881
+ log(`replied ${target.threadTs ?? target.channelId} (${text6.length} chars)`);
15801
15882
  } catch (err) {
15802
15883
  lastRelayed.delete(threadId);
15803
15884
  const errMsg = err instanceof Error ? err.message : String(err);
@@ -16242,8 +16323,8 @@ ${input.permalink}` : "";
16242
16323
 
16243
16324
  ${body}${link}`;
16244
16325
  }
16245
- function isSlackExternalReplyPrompt(text5) {
16246
- return isSlackExternalReplyText(text5);
16326
+ function isSlackExternalReplyPrompt(text6) {
16327
+ return isSlackExternalReplyText(text6);
16247
16328
  }
16248
16329
  function pendingSlackExternalReplies(messages) {
16249
16330
  return pendingInjectedNotices(messages, isSlackExternalReplyText);
@@ -16264,7 +16345,7 @@ async function continueSourceThread(threadId, prompt) {
16264
16345
  await continueOnReply(threadId, prompt);
16265
16346
  return;
16266
16347
  }
16267
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-BUEPWNCF.js");
16348
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-Y5PYSMR6.js");
16268
16349
  await getOrchestrator2().send(threadId, prompt);
16269
16350
  } catch {
16270
16351
  }
@@ -16272,9 +16353,9 @@ async function continueSourceThread(threadId, prompt) {
16272
16353
  function listSlackOutboundWatches() {
16273
16354
  return pruneWatches(readStore3());
16274
16355
  }
16275
- function formatOwnerSlackFyi(userName, text5) {
16356
+ function formatOwnerSlackFyi(userName, text6) {
16276
16357
  const who = userName.trim() || "Someone";
16277
- const body = text5.trim() || "(no text)";
16358
+ const body = text6.trim() || "(no text)";
16278
16359
  return `${who} replied in Slack:
16279
16360
  ${body}`;
16280
16361
  }
@@ -16289,7 +16370,7 @@ async function relayExternalReply(opts) {
16289
16370
  const thread = readThread(threadId);
16290
16371
  if (!thread || thread.status === "archived") return "ignored";
16291
16372
  try {
16292
- const text5 = formatSlackExternalReplyPrompt({
16373
+ const text6 = formatSlackExternalReplyPrompt({
16293
16374
  userName: opts.reply.userName,
16294
16375
  kind: opts.watch.kind,
16295
16376
  toLabel: opts.watch.toLabel,
@@ -16298,7 +16379,7 @@ async function relayExternalReply(opts) {
16298
16379
  });
16299
16380
  appendMessage(threadId, {
16300
16381
  role: "agent",
16301
- text: text5,
16382
+ text: text6,
16302
16383
  ts: (/* @__PURE__ */ new Date()).toISOString()
16303
16384
  });
16304
16385
  } catch {