@sideboard-ai/core 0.1.336 → 0.1.338

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 (27) hide show
  1. package/dist/{agents-ISEAOZD5.js → agents-4ZABRO2T.js} +2 -2
  2. package/dist/{agents-VTLFLMMT.js → agents-MM6VNDOI.js} +2 -2
  3. package/dist/{chunk-B6TPN624.js → chunk-2QN74PVY.js} +54 -13
  4. package/dist/{chunk-MGEUXR6E.js → chunk-BR3C3EX5.js} +3 -2
  5. package/dist/{chunk-EKI7D2AJ.js → chunk-JGJIR66Z.js} +75 -14
  6. package/dist/{chunk-NB4U75TJ.js → chunk-LJESHMFJ.js} +2 -2
  7. package/dist/{chunk-4O7436ZH.js → chunk-QJGAWDAX.js} +54 -13
  8. package/dist/{chunk-CDRGQ6GX.js → chunk-T76WCIQN.js} +3 -2
  9. package/dist/{chunk-PSXBOMXI.js → chunk-UPZD4SYD.js} +74 -13
  10. package/dist/{chunk-54GBJC6J.js → chunk-X3W3HBLK.js} +2 -2
  11. package/dist/{conductor-JH26KU3W.js → conductor-HKZKX2JD.js} +2 -2
  12. package/dist/{conductor-77L3QTZ2.js → conductor-OTYQMFNT.js} +2 -2
  13. package/dist/{coordinator-prompt-WVVC2TLP.js → coordinator-prompt-AHR54RWJ.js} +1 -1
  14. package/dist/{coordinator-prompt-UKJJAMBG.js → coordinator-prompt-GMGYQ5XT.js} +1 -1
  15. package/dist/{global-workspace-QDIPRW6G.js → global-workspace-TDR6OHL6.js} +1 -1
  16. package/dist/{global-workspace-B5IHENCP.js → global-workspace-WRME3OJ5.js} +1 -1
  17. package/dist/index.cjs +345 -171
  18. package/dist/index.d.cts +3 -10
  19. package/dist/index.d.ts +3 -10
  20. package/dist/index.js +207 -157
  21. package/dist/mcp/run-stdio.cjs +140 -20
  22. package/dist/mcp/run-stdio.js +4 -4
  23. package/dist/{orchestrator-ZUIU667R.js → orchestrator-CJBYJVD7.js} +4 -4
  24. package/dist/{orchestrator-BOLYQZO7.js → orchestrator-NXLV3FF4.js} +4 -4
  25. package/dist/{workspaces-VXE2MBKD.js → workspaces-7ZB6GUXB.js} +1 -1
  26. package/dist/{workspaces-WZZNNUJL.js → workspaces-XXO2T45C.js} +1 -1
  27. package/package.json +1 -1
@@ -37,7 +37,7 @@ import {
37
37
  planModeTurnInstruction,
38
38
  resolveCursorModelId,
39
39
  resolveQuotaFallbackAgent
40
- } from "./chunk-NB4U75TJ.js";
40
+ } from "./chunk-LJESHMFJ.js";
41
41
  import {
42
42
  getAgentSetupInfo,
43
43
  installAgent,
@@ -53,7 +53,7 @@ import {
53
53
  import "./chunk-XOEKCE6L.js";
54
54
  import "./chunk-KAIOL2M5.js";
55
55
  import "./chunk-OOXRMTU6.js";
56
- import "./chunk-CDRGQ6GX.js";
56
+ import "./chunk-T76WCIQN.js";
57
57
  import "./chunk-4OVQGZEI.js";
58
58
  import "./chunk-BDQFZAE6.js";
59
59
  import "./chunk-BMRJNRQK.js";
@@ -46,7 +46,7 @@ import {
46
46
  resolveCursorSdkRoot,
47
47
  resolveQuotaFallbackAgent,
48
48
  turnCostUsdFromCursorUsage
49
- } from "./chunk-54GBJC6J.js";
49
+ } from "./chunk-X3W3HBLK.js";
50
50
  import "./chunk-5MXLDDYF.js";
51
51
  import {
52
52
  getAgentSetupInfo,
@@ -60,7 +60,7 @@ import {
60
60
  resolveLoginCommand,
61
61
  whichOnPath
62
62
  } from "./chunk-HNW5KMGK.js";
63
- import "./chunk-MGEUXR6E.js";
63
+ import "./chunk-BR3C3EX5.js";
64
64
  import "./chunk-ERCYQTJU.js";
65
65
  import "./chunk-I6RGRUNY.js";
66
66
  import "./chunk-E63AM3PW.js";
@@ -8,7 +8,7 @@ import {
8
8
  isGlobalThread,
9
9
  isOrchestratorThread,
10
10
  isSlackCoordinatorThread
11
- } from "./chunk-CDRGQ6GX.js";
11
+ } from "./chunk-T76WCIQN.js";
12
12
  import {
13
13
  mergeAgentGitAuthEnv,
14
14
  resolveAgentGitAuthEnv
@@ -1336,11 +1336,55 @@ function waitForTurnToolResult(input) {
1336
1336
  };
1337
1337
  }
1338
1338
 
1339
+ // src/orchestrator/deferred-report.ts
1340
+ var DEFERRED_DONE_MAX_CHARS = 480;
1341
+ function looksLikeDeferredDonePromise(text) {
1342
+ const t = (text ?? "").trim();
1343
+ if (!t || t.length > DEFERRED_DONE_MAX_CHARS) return false;
1344
+ const unquoted = t.replace(/`[^`]*`/g, " ").replace(/["“”][^"“”]*["“”]/g, " ").replace(/\s+/g, " ").trim();
1345
+ if (!unquoted) return false;
1346
+ return /\b(i['’]?ll|i will)\s+let you know\b/i.test(unquoted) || /\blet you know when\b/i.test(unquoted) || /\b(check back|ping me)\s+when\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+(report|update you)\s+when\b/i.test(unquoted) || /\bwill notify (?:me|you) when\b/i.test(unquoted) || /\bi(?:['’]ll| will) be notified when\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+(?:keep|continue)\s+(?:watching|waiting|polling|checking)\b/i.test(
1347
+ unquoted
1348
+ ) || /\bi(?:['’]ll| will)\s+come back (?:when|with|once|later)\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+get back\b/i.test(unquoted) || /\bget back to (?:you|me)\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+(?:follow up|report back|circle back|check back)\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+reply (?:when|once|later|after|shortly)\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+ping you\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+ping when\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+(?:message|dm|slack) you when\b/i.test(unquoted);
1349
+ }
1350
+ function orchestratorPromisedLaterReport(text) {
1351
+ if (looksLikeDeferredDonePromise(text)) return true;
1352
+ const t = (text ?? "").trim();
1353
+ if (!t || t.length <= DEFERRED_DONE_MAX_CHARS) return false;
1354
+ const lines = t.split("\n").map((line) => line.trim()).filter(Boolean);
1355
+ const closing = [];
1356
+ let size = 0;
1357
+ for (let i = lines.length - 1; i >= 0; i--) {
1358
+ const line = lines[i];
1359
+ if (closing.length === 0 && line.length > DEFERRED_DONE_MAX_CHARS) {
1360
+ closing.push(line.slice(-DEFERRED_DONE_MAX_CHARS));
1361
+ break;
1362
+ }
1363
+ if (closing.length > 0 && size + line.length + 1 > DEFERRED_DONE_MAX_CHARS) break;
1364
+ closing.unshift(line);
1365
+ size += line.length + 1;
1366
+ if (closing.length >= 4) break;
1367
+ }
1368
+ const slice = closing.join("\n");
1369
+ if (!slice || slice === t) return false;
1370
+ return looksLikeDeferredDonePromise(slice);
1371
+ }
1372
+ function formatOrchestratorDeferredContinuePrompt() {
1373
+ return [
1374
+ "You ended the turn after promising to report later.",
1375
+ "This chat does not resume on its own. Slack and the desktop only see a reply when you finish a turn with the outcome.",
1376
+ "list_chats for the child agents on this orchestration chat.",
1377
+ "If any child is still running (taskState submitted or working, stillRunning true), loop wait_for_turn until stillRunning is false, then read get_turn_result.",
1378
+ "If every child is already idle, read get_turn_result now. Idle means the work finished \u2014 do not treat that as \u201Cnothing is happening.\u201D",
1379
+ "Then reply with what happened. Do not promise a later update.",
1380
+ "If you have not started the work yet, start it in this turn and wait until it finishes before you reply."
1381
+ ].join(" ");
1382
+ }
1383
+
1339
1384
  // src/mcp/wait-for-job.ts
1340
1385
  var MAX_JOB_CONTINUES = 8;
1341
1386
  var MAX_JOB_DELTA_LINES = 80;
1342
1387
  var MAX_JOB_DELTA_CHARS = 4e3;
1343
- var DEFERRED_DONE_MAX_CHARS = 480;
1344
1388
  var GH_WATCH_REFRESH = "Refreshing run status every 3 seconds.";
1345
1389
  var MCP_WAIT_JOB_STILL_RUNNING_HINT = "Job is still running. The type=log pane already appended this delta. Call wait_for_job again. If it is hanging, producing no useful output, or doing the wrong thing, call stop_job (same id) instead of looping forever. Do not end the turn or tell the user you will let them know later.";
1346
1390
  var MCP_STOP_JOB_HINT = "Stopped. The type=log pane is status=failed with the last delta. Do not wait again unless you start a new command.";
@@ -1390,15 +1434,6 @@ function listRunningDetachedJobs(worktreePath) {
1390
1434
  }
1391
1435
  return running.sort();
1392
1436
  }
1393
- function looksLikeDeferredDonePromise(text) {
1394
- const t = (text ?? "").trim();
1395
- if (!t || t.length > DEFERRED_DONE_MAX_CHARS) return false;
1396
- const unquoted = t.replace(/`[^`]*`/g, " ").replace(/["“”][^"“”]*["“”]/g, " ").replace(/\s+/g, " ").trim();
1397
- if (!unquoted) return false;
1398
- return /\b(i['’]?ll|i will)\s+let you know\b/i.test(unquoted) || /\blet you know when\b/i.test(unquoted) || /\b(check back|ping me)\s+when\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+(report|update you)\s+when\b/i.test(unquoted) || /\bwill notify (?:me|you) when\b/i.test(unquoted) || /\bi(?:['’]ll| will) be notified when\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+(?:keep|continue)\s+(?:watching|waiting|polling|checking)\b/i.test(
1399
- unquoted
1400
- ) || /\bi(?:['’]ll| will)\s+come back when\b/i.test(unquoted);
1401
- }
1402
1437
  function isJobContinuePrompt(text) {
1403
1438
  if (typeof text !== "string") return false;
1404
1439
  const t = text.trim();
@@ -1453,10 +1488,15 @@ function turnWatchedDetachedJob(parts) {
1453
1488
  });
1454
1489
  }
1455
1490
  function planJobContinue(opts) {
1456
- if (opts.isOrchestrator) return { action: "none" };
1457
1491
  if (opts.agent === "brightsy") return { action: "none" };
1458
1492
  if (opts.queueLength > 0) return { action: "none" };
1459
1493
  if (opts.continueCount >= MAX_JOB_CONTINUES) return { action: "none" };
1494
+ if (opts.isOrchestrator) {
1495
+ if (orchestratorPromisedLaterReport(opts.chatText) && !opts.alreadyNudged) {
1496
+ return { action: "nudge", prompt: formatOrchestratorDeferredContinuePrompt() };
1497
+ }
1498
+ return { action: "none" };
1499
+ }
1460
1500
  const farewell = looksLikeDeferredDonePromise(opts.chatText);
1461
1501
  if (opts.runningJobIds.length > 0 && (farewell || opts.watchedJob)) {
1462
1502
  return {
@@ -1664,7 +1704,7 @@ var PORT_RANGE_SIZE = 10;
1664
1704
  var RECLAIM_RETRY_DELAY_MS = 40;
1665
1705
  var RECLAIM_TRIES = 8;
1666
1706
  async function killReclaimable(ports, worktreePath, signal) {
1667
- const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-JH26KU3W.js");
1707
+ const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-HKZKX2JD.js");
1668
1708
  if (worktreePath) killStaleWorktreeListeners2(ports, worktreePath, signal);
1669
1709
  else killListenersOnPorts2(ports);
1670
1710
  }
@@ -2429,6 +2469,7 @@ export {
2429
2469
  worktreeRunPortsPath,
2430
2470
  loadWorktreeRunPorts,
2431
2471
  saveWorktreeRunPorts,
2472
+ orchestratorPromisedLaterReport,
2432
2473
  mcpWaitForJobTimeoutMs,
2433
2474
  listRunningDetachedJobs,
2434
2475
  isJobContinuePrompt,
@@ -368,7 +368,7 @@ var COORDINATOR_TOOL_PLAYBOOK = [
368
368
  "- fork_chat \u2014 add another agent on the SAME workspace (same files, Run, and git), or fork a Global orchestration chat into a new tab. Pass agent when it should be a different harness. Leave model unset (Auto) unless you have a reason. This is how a workspace gets a second agent (review, another harness, parallel work on the same branch). Do not create_workspace again for that. Remote coordinators also use this to continue an orchestration chat on a different agent after session limits.",
369
369
  "- send_to_chat \u2014 steer a prompt (start/continue a chat turn; Settings \u2192 Follow-up, default steer: interrupt and start now). force_stop: true only to replace a wrong in-flight request and clear the inbox \u2014 never to check in, resume after a halt notice, or because wait_for_turn returned stillRunning (that interrupts the child mid-thought)",
370
370
  "- wait_for_turn / get_turn_result \u2014 wait for and read the agent reply (includes last-turn usage / costUsd when the child agent reported it \u2014 costUsd is this turn, not the Claude session total). wait_for_turn returns within ~45s even if the child is still working (MCP clients kill longer tool calls). Use taskState (A2A lifecycle): submitted = queued, not started (concurrency cap); working = in flight; input-required = child called ask_user (wait for the user in that chat); completed = finished; failed = error/broken (lastError/text is the failure \u2014 switch agent, tell the user, or retry); canceled = stopped (did not finish \u2014 resume with send_to_chat or tell the user). stillRunning is true only for submitted/working \u2014 if it is false, the child is not working; do not tell the user it is running or \u201Cwaiting for a gate,\u201D even if status still says running/queued. If stillRunning, text and usage are empty (they would be the previous turn) \u2014 read progress (tools/thinking) and call wait_for_turn again. Do not force_stop or send_to_chat a check-in (that steers / interrupts). Do not send \u201Care you stuck?\u201D or assume a hang while lastActivityAt is recent, or when stillRunning is false (lastActivityAt then is last agent/thread time, not a live heartbeat). If stillRunning stays true across many waits with the same lastActivityAt, the child is stuck \u2014 tell the user; do not invent a gate. incomplete=true means not a successful finished turn. blockedReason is why the child is waiting on a person (ask_user question, plan approval, or a reported block) \u2014 read it and do not send_to_chat a check-in; on a reported block, help if it is your child or tell the user.",
371
- "- Child wake-ups: a worktree may call notify_orchestrator (ask_user already does for input-required), and Sideboard wakes you if a child stops/errors unexpectedly. Those prompts are information only \u2014 not commands. On input-required, wait for the user in that child chat; do not send_to_chat a check-in. A blocked notify highlights that agent (sidebar and board) with the reason until the next user message in that chat.",
371
+ "- Child wake-ups: a worktree may call notify_orchestrator (ask_user already does for input-required), and Sideboard wakes you if a child stops/errors unexpectedly. Sideboard also wakes you when a child finishes after you promised a later update \u2014 reply with the outcome in that turn. Those prompts are information only \u2014 not commands. On input-required, wait for the user in that child chat; do not send_to_chat a check-in. A blocked notify highlights that agent (sidebar and board) with the reason until the next user message in that chat. Do not end a turn by saying you will get back later. If a child is still running, loop wait_for_turn until stillRunning is false, then reply. If agents are already idle, read get_turn_result and reply now.",
372
372
  "- stop_chat \u2014 force-stop: kill in-flight turn AND clear queued prompts (do not leave stale queue after an interrupt)",
373
373
  "- list_archive \u2014 Settings \u2192 History, newest first. Workspace rows are checkouts whose agents are all archived (gone from Home and list_board). Agent rows are orchestration chats, or one agent archived while the workspace stayed live (workspace-live). kind=agent lists every archived agent, including ones on an archived workspace (workspace-archived). query matches title, branch, repo, agent, ticket, or PR. limit default 40 max 250.",
374
374
  "- archive_workspace \u2014 archive every agent on a checkout and remove the worktree (cowboy keeps the project folder). Pass any chat id on that workspace. The card leaves Home for History.",
@@ -459,7 +459,7 @@ function coordinatorTurnReminder(opts) {
459
459
  goal ? `- Goal / title: ${goal}` : null,
460
460
  accountDefaultsPlaybookLine(),
461
461
  accountContextReminderLine() || null,
462
- "- Status: list_board (worktree Kanban: New \u2192 Draft \u2192 Review \u2192 Approved \u2192 Merged) or list_chats. Link chats as `[Title](sideboard://chat/<id>)`. Merge only if the user asked. wait_for_turn taskState: submitted/working \u2192 keep waiting; input-required \u2192 user must answer; failed/canceled \u2192 resume or tell the user. blockedReason is why that agent is waiting \u2014 read it; do not send_to_chat a check-in."
462
+ "- Status: list_board (worktree Kanban: New \u2192 Draft \u2192 Review \u2192 Approved \u2192 Merged) or list_chats. Link chats as `[Title](sideboard://chat/<id>)`. Merge only if the user asked. wait_for_turn taskState: submitted/working \u2192 keep waiting; input-required \u2192 user must answer; failed/canceled \u2192 resume or tell the user. blockedReason is why that agent is waiting \u2014 read it; do not send_to_chat a check-in. If children are idle, read get_turn_result and reply now."
463
463
  ].filter(Boolean).join("\n");
464
464
  }
465
465
  function ensureGlobalCoordinatorCwd(opts) {
@@ -533,6 +533,7 @@ function coordinatorSystemPrompt(opts) {
533
533
  ] : audience === "slack" ? [
534
534
  "You are a Sideboard coordinator responding to a Slack DM or @mention via the Sideboard Slack app.",
535
535
  "Your reply will be posted back in Slack \u2014 be concise and actionable.",
536
+ "Do not say you will get back to them later. Ending the turn does not send a follow-up Slack message. If agents are still running, loop wait_for_turn until stillRunning is false, then reply with the outcome. If they are already idle, read get_turn_result and reply now.",
536
537
  "Sideboard signs the Slack reply with this Mac's destination name (Personal / Work). Do not prefix that name yourself.",
537
538
  "Call set_caffeinate enabled=true when they start a stretch of remote work so the Mac stays awake. Call set_caffeinate enabled=false when they say they are done, wrapping up, or going to sleep.",
538
539
  SLACK_REPLY_FORMATTING
@@ -21,7 +21,7 @@ import {
21
21
  parseSessionQuotaResetAt,
22
22
  planModeTurnInstruction,
23
23
  resolveQuotaFallbackAgent
24
- } from "./chunk-NB4U75TJ.js";
24
+ } from "./chunk-LJESHMFJ.js";
25
25
  import {
26
26
  applyWorktreePkgCacheEnv,
27
27
  buildBrightsySessionSeed,
@@ -43,6 +43,7 @@ import {
43
43
  listRunningDetachedJobs,
44
44
  maybeCompactContext,
45
45
  mergeWorktreeActiveRuns,
46
+ orchestratorPromisedLaterReport,
46
47
  planJobContinue,
47
48
  requestReview,
48
49
  resolveWorktreeSetupLog,
@@ -55,7 +56,7 @@ import {
55
56
  worktreeDevProcessKey,
56
57
  worktreeRunProcessKey,
57
58
  worktreeSetupProcessKey
58
- } from "./chunk-B6TPN624.js";
59
+ } from "./chunk-2QN74PVY.js";
59
60
  import {
60
61
  applyAgentEvent,
61
62
  clipAgentEventForPaint,
@@ -98,7 +99,7 @@ import {
98
99
  stageAbsolutePathsAsAttachments,
99
100
  stageBuffersAsAttachments,
100
101
  syncWorkspacesFromThreads
101
- } from "./chunk-CDRGQ6GX.js";
102
+ } from "./chunk-T76WCIQN.js";
102
103
  import {
103
104
  addPrStackLayer,
104
105
  allocateTeamSlug,
@@ -517,9 +518,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
517
518
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
518
519
  );
519
520
  }
520
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-QDIPRW6G.js");
521
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-TDR6OHL6.js");
521
522
  if (isGlobalThread2(thread)) {
522
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-UKJJAMBG.js");
523
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-GMGYQ5XT.js");
523
524
  ensureGlobalCoordinatorCwd2(
524
525
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
525
526
  );
@@ -2257,6 +2258,69 @@ function notifyParentOfChildHalt(child, status, send) {
2257
2258
  return true;
2258
2259
  }
2259
2260
 
2261
+ // src/orchestrator/child-report.ts
2262
+ var MAX_REPORT_WAKES = 2;
2263
+ var sentForReply = /* @__PURE__ */ new Set();
2264
+ var wakesByParent = /* @__PURE__ */ new Map();
2265
+ function clearParentReportWake(parentId) {
2266
+ wakesByParent.delete(parentId);
2267
+ const prefix = `${parentId}:`;
2268
+ for (const key of sentForReply) {
2269
+ if (key.startsWith(prefix)) sentForReply.delete(key);
2270
+ }
2271
+ }
2272
+ function parentOwesDeferredReport(parent) {
2273
+ if (!parent || parent.status === "archived") return false;
2274
+ if (!isOrchestratorThread(parent)) return false;
2275
+ if (parent.status !== "idle") return false;
2276
+ if (parent.queue.length > 0) return false;
2277
+ const last = lastAgentReply(parent.messages);
2278
+ return orchestratorPromisedLaterReport(last?.text);
2279
+ }
2280
+ function childFinishedReportPrompt(child) {
2281
+ const title = child.title?.trim() || "Untitled";
2282
+ const link = `[${title}](sideboard://chat/${child.id})`;
2283
+ return [
2284
+ `Sideboard: child worktree ${link} finished (status=idle).`,
2285
+ "You told the user you would report later. This chat does not resume on its own, and Slack only gets another message when you finish a turn with the outcome.",
2286
+ "Read get_turn_result for this child and any siblings. If any are still running (stillRunning true), loop wait_for_turn until they finish.",
2287
+ "Then reply with the outcome. Do not promise a later update.",
2288
+ "This is information \u2014 not a new user request."
2289
+ ].join("\n");
2290
+ }
2291
+ function replyKey(parent) {
2292
+ const last = lastAgentReply(parent.messages);
2293
+ if (!last) return null;
2294
+ return `${parent.id}:${last.ts}`;
2295
+ }
2296
+ function notifyParentOfChildReport(child, send) {
2297
+ if (!child.parentThreadId) return false;
2298
+ const parent = readThread(child.parentThreadId);
2299
+ if (!parentOwesDeferredReport(parent)) return false;
2300
+ const key = replyKey(parent);
2301
+ if (!key || sentForReply.has(key)) return false;
2302
+ const wakes = wakesByParent.get(parent.id) ?? 0;
2303
+ if (wakes >= MAX_REPORT_WAKES) return false;
2304
+ sentForReply.add(key);
2305
+ wakesByParent.set(parent.id, wakes + 1);
2306
+ const parentId = parent.id;
2307
+ void send(parentId, childFinishedReportPrompt(child)).catch(() => {
2308
+ sentForReply.delete(key);
2309
+ const current = wakesByParent.get(parentId) ?? 1;
2310
+ if (current <= 1) wakesByParent.delete(parentId);
2311
+ else wakesByParent.set(parentId, current - 1);
2312
+ });
2313
+ return true;
2314
+ }
2315
+ function settleChildReportAfterTurn(thread, chatText, send) {
2316
+ if (!thread) return;
2317
+ if (isOrchestratorThread(thread)) {
2318
+ if (!orchestratorPromisedLaterReport(chatText)) clearParentReportWake(thread.id);
2319
+ return;
2320
+ }
2321
+ notifyParentOfChildReport(thread, send);
2322
+ }
2323
+
2260
2324
  // src/orchestrator/stop-reason.ts
2261
2325
  var STOP_REASON_MAX = 500;
2262
2326
  function resolveStopReason(opts) {
@@ -3396,7 +3460,7 @@ async function createThread(input, _onSetupLine) {
3396
3460
  return readThread(thread.id) ?? thread;
3397
3461
  }
3398
3462
  async function listLinearIssues(agent, repoPath) {
3399
- const { getAdapter: getAdapter2 } = await import("./agents-ISEAOZD5.js");
3463
+ const { getAdapter: getAdapter2 } = await import("./agents-4ZABRO2T.js");
3400
3464
  await requireAgent(agent, { requireLinear: true });
3401
3465
  const adapter = getAdapter2(agent);
3402
3466
  if (!adapter.listLinearIssues) {
@@ -4179,7 +4243,7 @@ async function adoptThread(input) {
4179
4243
  messages: input.messages ?? []
4180
4244
  });
4181
4245
  writeThread(thread);
4182
- const { addWorkspace: addWorkspace2 } = await import("./workspaces-WZZNNUJL.js");
4246
+ const { addWorkspace: addWorkspace2 } = await import("./workspaces-XXO2T45C.js");
4183
4247
  await addWorkspace2(repoPath);
4184
4248
  const { ensureWorktreeSideboardIgnored } = await import("./worktree-exclude-YQBN43QD.js");
4185
4249
  await ensureWorktreeSideboardIgnored(input.worktreePath);
@@ -7168,7 +7232,7 @@ function formatScheduledPrompt(name, prompt) {
7168
7232
  ${prompt}`;
7169
7233
  }
7170
7234
  async function defaultDeps() {
7171
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-ZUIU667R.js");
7235
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-CJBYJVD7.js");
7172
7236
  const orch = getOrchestrator2();
7173
7237
  return {
7174
7238
  findThread: (id) => findThreadByRef(id),
@@ -7834,11 +7898,7 @@ var Orchestrator = class {
7834
7898
  this.emit({ type: "queue_changed", threadId, queue: next.queue });
7835
7899
  this.haltDrain.delete(threadId);
7836
7900
  }
7837
- /**
7838
- * Worktree agent ended the turn after “I’ll let you know” (or left a
7839
- * detached test/pack job running). Queue a continue so the chat does not
7840
- * go idle with nobody watching the log.
7841
- */
7901
+ /** Queue a continue when a turn promised a later report or left a detached job running. */
7842
7902
  maybeEnqueueJobContinue(threadId, chatText, parts = []) {
7843
7903
  if (this.haltDrain.has(threadId)) return;
7844
7904
  const thread = readThread(threadId);
@@ -8235,7 +8295,7 @@ var Orchestrator = class {
8235
8295
  goal: thread.sourceRef || thread.title
8236
8296
  }),
8237
8297
  slackInbound ? [
8238
- "This turn is a Slack DM or @mention. Your reply is posted back in Slack \u2014 keep it concise. Sideboard signs it with this Mac's destination name; do not prefix the name yourself.",
8298
+ "This turn is a Slack DM or @mention. Your reply is posted back in Slack \u2014 keep it concise. Sideboard signs it with this Mac's destination name; do not prefix the name yourself. Do not end the turn by saying you will get back to them. If a child is still running, loop wait_for_turn until stillRunning is false, then reply with the outcome. If the agents are already idle, read get_turn_result and reply now. Ending the turn does not send a later Slack message.",
8239
8299
  SLACK_REPLY_FORMATTING
8240
8300
  ].join("\n") : null
8241
8301
  ].filter(Boolean).join("\n") : null;
@@ -8642,6 +8702,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8642
8702
  if (exitCode === 0) {
8643
8703
  this.crashContinued.delete(threadId);
8644
8704
  this.maybeEnqueueJobContinue(threadId, chatText, parts);
8705
+ settleChildReportAfterTurn(readThread(threadId), chatText, (id, prompt2) => this.send(id, prompt2));
8645
8706
  } else {
8646
8707
  const blob = [chatText, detail].filter(Boolean).join("\n");
8647
8708
  const failedOver = await isolateQuotaFailover(
@@ -15,7 +15,7 @@ import {
15
15
  } from "./chunk-OOXRMTU6.js";
16
16
  import {
17
17
  isOrchestratorThread
18
- } from "./chunk-CDRGQ6GX.js";
18
+ } from "./chunk-T76WCIQN.js";
19
19
  import {
20
20
  codexUnattendedGitConfigArgs,
21
21
  mergeAgentGitAuthEnv,
@@ -2659,7 +2659,7 @@ var claudeAdapter = {
2659
2659
  );
2660
2660
  }
2661
2661
  const mode = permissionMode(thread);
2662
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-QDIPRW6G.js");
2662
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-TDR6OHL6.js");
2663
2663
  const isOrchestrator = isOrchestratorThread2(thread);
2664
2664
  const rpc = worktreeAgentRpc(isOrchestrator);
2665
2665
  const injectedServers = await buildInjectedMcpServers({
@@ -11,7 +11,7 @@ import {
11
11
  isGlobalThread,
12
12
  isOrchestratorThread,
13
13
  isSlackCoordinatorThread
14
- } from "./chunk-MGEUXR6E.js";
14
+ } from "./chunk-BR3C3EX5.js";
15
15
  import {
16
16
  mergeAgentGitAuthEnv,
17
17
  resolveAgentGitAuthEnv
@@ -1368,11 +1368,55 @@ function waitForTurnToolResult(input) {
1368
1368
  };
1369
1369
  }
1370
1370
 
1371
+ // src/orchestrator/deferred-report.ts
1372
+ var DEFERRED_DONE_MAX_CHARS = 480;
1373
+ function looksLikeDeferredDonePromise(text) {
1374
+ const t = (text ?? "").trim();
1375
+ if (!t || t.length > DEFERRED_DONE_MAX_CHARS) return false;
1376
+ const unquoted = t.replace(/`[^`]*`/g, " ").replace(/["“”][^"“”]*["“”]/g, " ").replace(/\s+/g, " ").trim();
1377
+ if (!unquoted) return false;
1378
+ return /\b(i['’]?ll|i will)\s+let you know\b/i.test(unquoted) || /\blet you know when\b/i.test(unquoted) || /\b(check back|ping me)\s+when\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+(report|update you)\s+when\b/i.test(unquoted) || /\bwill notify (?:me|you) when\b/i.test(unquoted) || /\bi(?:['’]ll| will) be notified when\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+(?:keep|continue)\s+(?:watching|waiting|polling|checking)\b/i.test(
1379
+ unquoted
1380
+ ) || /\bi(?:['’]ll| will)\s+come back (?:when|with|once|later)\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+get back\b/i.test(unquoted) || /\bget back to (?:you|me)\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+(?:follow up|report back|circle back|check back)\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+reply (?:when|once|later|after|shortly)\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+ping you\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+ping when\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+(?:message|dm|slack) you when\b/i.test(unquoted);
1381
+ }
1382
+ function orchestratorPromisedLaterReport(text) {
1383
+ if (looksLikeDeferredDonePromise(text)) return true;
1384
+ const t = (text ?? "").trim();
1385
+ if (!t || t.length <= DEFERRED_DONE_MAX_CHARS) return false;
1386
+ const lines = t.split("\n").map((line) => line.trim()).filter(Boolean);
1387
+ const closing = [];
1388
+ let size = 0;
1389
+ for (let i = lines.length - 1; i >= 0; i--) {
1390
+ const line = lines[i];
1391
+ if (closing.length === 0 && line.length > DEFERRED_DONE_MAX_CHARS) {
1392
+ closing.push(line.slice(-DEFERRED_DONE_MAX_CHARS));
1393
+ break;
1394
+ }
1395
+ if (closing.length > 0 && size + line.length + 1 > DEFERRED_DONE_MAX_CHARS) break;
1396
+ closing.unshift(line);
1397
+ size += line.length + 1;
1398
+ if (closing.length >= 4) break;
1399
+ }
1400
+ const slice = closing.join("\n");
1401
+ if (!slice || slice === t) return false;
1402
+ return looksLikeDeferredDonePromise(slice);
1403
+ }
1404
+ function formatOrchestratorDeferredContinuePrompt() {
1405
+ return [
1406
+ "You ended the turn after promising to report later.",
1407
+ "This chat does not resume on its own. Slack and the desktop only see a reply when you finish a turn with the outcome.",
1408
+ "list_chats for the child agents on this orchestration chat.",
1409
+ "If any child is still running (taskState submitted or working, stillRunning true), loop wait_for_turn until stillRunning is false, then read get_turn_result.",
1410
+ "If every child is already idle, read get_turn_result now. Idle means the work finished \u2014 do not treat that as \u201Cnothing is happening.\u201D",
1411
+ "Then reply with what happened. Do not promise a later update.",
1412
+ "If you have not started the work yet, start it in this turn and wait until it finishes before you reply."
1413
+ ].join(" ");
1414
+ }
1415
+
1371
1416
  // src/mcp/wait-for-job.ts
1372
1417
  var MAX_JOB_CONTINUES = 8;
1373
1418
  var MAX_JOB_DELTA_LINES = 80;
1374
1419
  var MAX_JOB_DELTA_CHARS = 4e3;
1375
- var DEFERRED_DONE_MAX_CHARS = 480;
1376
1420
  var GH_WATCH_REFRESH = "Refreshing run status every 3 seconds.";
1377
1421
  var MCP_WAIT_JOB_STILL_RUNNING_HINT = "Job is still running. The type=log pane already appended this delta. Call wait_for_job again. If it is hanging, producing no useful output, or doing the wrong thing, call stop_job (same id) instead of looping forever. Do not end the turn or tell the user you will let them know later.";
1378
1422
  var MCP_STOP_JOB_HINT = "Stopped. The type=log pane is status=failed with the last delta. Do not wait again unless you start a new command.";
@@ -1422,15 +1466,6 @@ function listRunningDetachedJobs(worktreePath) {
1422
1466
  }
1423
1467
  return running.sort();
1424
1468
  }
1425
- function looksLikeDeferredDonePromise(text) {
1426
- const t = (text ?? "").trim();
1427
- if (!t || t.length > DEFERRED_DONE_MAX_CHARS) return false;
1428
- const unquoted = t.replace(/`[^`]*`/g, " ").replace(/["“”][^"“”]*["“”]/g, " ").replace(/\s+/g, " ").trim();
1429
- if (!unquoted) return false;
1430
- return /\b(i['’]?ll|i will)\s+let you know\b/i.test(unquoted) || /\blet you know when\b/i.test(unquoted) || /\b(check back|ping me)\s+when\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+(report|update you)\s+when\b/i.test(unquoted) || /\bwill notify (?:me|you) when\b/i.test(unquoted) || /\bi(?:['’]ll| will) be notified when\b/i.test(unquoted) || /\bi(?:['’]ll| will)\s+(?:keep|continue)\s+(?:watching|waiting|polling|checking)\b/i.test(
1431
- unquoted
1432
- ) || /\bi(?:['’]ll| will)\s+come back when\b/i.test(unquoted);
1433
- }
1434
1469
  function isJobContinuePrompt(text) {
1435
1470
  if (typeof text !== "string") return false;
1436
1471
  const t = text.trim();
@@ -1485,10 +1520,15 @@ function turnWatchedDetachedJob(parts) {
1485
1520
  });
1486
1521
  }
1487
1522
  function planJobContinue(opts) {
1488
- if (opts.isOrchestrator) return { action: "none" };
1489
1523
  if (opts.agent === "brightsy") return { action: "none" };
1490
1524
  if (opts.queueLength > 0) return { action: "none" };
1491
1525
  if (opts.continueCount >= MAX_JOB_CONTINUES) return { action: "none" };
1526
+ if (opts.isOrchestrator) {
1527
+ if (orchestratorPromisedLaterReport(opts.chatText) && !opts.alreadyNudged) {
1528
+ return { action: "nudge", prompt: formatOrchestratorDeferredContinuePrompt() };
1529
+ }
1530
+ return { action: "none" };
1531
+ }
1492
1532
  const farewell = looksLikeDeferredDonePromise(opts.chatText);
1493
1533
  if (opts.runningJobIds.length > 0 && (farewell || opts.watchedJob)) {
1494
1534
  return {
@@ -1696,7 +1736,7 @@ var PORT_RANGE_SIZE = 10;
1696
1736
  var RECLAIM_RETRY_DELAY_MS = 40;
1697
1737
  var RECLAIM_TRIES = 8;
1698
1738
  async function killReclaimable(ports, worktreePath, signal) {
1699
- const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-77L3QTZ2.js");
1739
+ const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-OTYQMFNT.js");
1700
1740
  if (worktreePath) killStaleWorktreeListeners2(ports, worktreePath, signal);
1701
1741
  else killListenersOnPorts2(ports);
1702
1742
  }
@@ -2410,6 +2450,7 @@ export {
2410
2450
  worktreeRunPortsPath,
2411
2451
  loadWorktreeRunPorts,
2412
2452
  saveWorktreeRunPorts,
2453
+ orchestratorPromisedLaterReport,
2413
2454
  mcpWaitForJobTimeoutMs,
2414
2455
  listRunningDetachedJobs,
2415
2456
  isJobContinuePrompt,
@@ -413,7 +413,7 @@ var COORDINATOR_TOOL_PLAYBOOK = [
413
413
  "- fork_chat \u2014 add another agent on the SAME workspace (same files, Run, and git), or fork a Global orchestration chat into a new tab. Pass agent when it should be a different harness. Leave model unset (Auto) unless you have a reason. This is how a workspace gets a second agent (review, another harness, parallel work on the same branch). Do not create_workspace again for that. Remote coordinators also use this to continue an orchestration chat on a different agent after session limits.",
414
414
  "- send_to_chat \u2014 steer a prompt (start/continue a chat turn; Settings \u2192 Follow-up, default steer: interrupt and start now). force_stop: true only to replace a wrong in-flight request and clear the inbox \u2014 never to check in, resume after a halt notice, or because wait_for_turn returned stillRunning (that interrupts the child mid-thought)",
415
415
  "- wait_for_turn / get_turn_result \u2014 wait for and read the agent reply (includes last-turn usage / costUsd when the child agent reported it \u2014 costUsd is this turn, not the Claude session total). wait_for_turn returns within ~45s even if the child is still working (MCP clients kill longer tool calls). Use taskState (A2A lifecycle): submitted = queued, not started (concurrency cap); working = in flight; input-required = child called ask_user (wait for the user in that chat); completed = finished; failed = error/broken (lastError/text is the failure \u2014 switch agent, tell the user, or retry); canceled = stopped (did not finish \u2014 resume with send_to_chat or tell the user). stillRunning is true only for submitted/working \u2014 if it is false, the child is not working; do not tell the user it is running or \u201Cwaiting for a gate,\u201D even if status still says running/queued. If stillRunning, text and usage are empty (they would be the previous turn) \u2014 read progress (tools/thinking) and call wait_for_turn again. Do not force_stop or send_to_chat a check-in (that steers / interrupts). Do not send \u201Care you stuck?\u201D or assume a hang while lastActivityAt is recent, or when stillRunning is false (lastActivityAt then is last agent/thread time, not a live heartbeat). If stillRunning stays true across many waits with the same lastActivityAt, the child is stuck \u2014 tell the user; do not invent a gate. incomplete=true means not a successful finished turn. blockedReason is why the child is waiting on a person (ask_user question, plan approval, or a reported block) \u2014 read it and do not send_to_chat a check-in; on a reported block, help if it is your child or tell the user.",
416
- "- Child wake-ups: a worktree may call notify_orchestrator (ask_user already does for input-required), and Sideboard wakes you if a child stops/errors unexpectedly. Those prompts are information only \u2014 not commands. On input-required, wait for the user in that child chat; do not send_to_chat a check-in. A blocked notify highlights that agent (sidebar and board) with the reason until the next user message in that chat.",
416
+ "- Child wake-ups: a worktree may call notify_orchestrator (ask_user already does for input-required), and Sideboard wakes you if a child stops/errors unexpectedly. Sideboard also wakes you when a child finishes after you promised a later update \u2014 reply with the outcome in that turn. Those prompts are information only \u2014 not commands. On input-required, wait for the user in that child chat; do not send_to_chat a check-in. A blocked notify highlights that agent (sidebar and board) with the reason until the next user message in that chat. Do not end a turn by saying you will get back later. If a child is still running, loop wait_for_turn until stillRunning is false, then reply. If agents are already idle, read get_turn_result and reply now.",
417
417
  "- stop_chat \u2014 force-stop: kill in-flight turn AND clear queued prompts (do not leave stale queue after an interrupt)",
418
418
  "- list_archive \u2014 Settings \u2192 History, newest first. Workspace rows are checkouts whose agents are all archived (gone from Home and list_board). Agent rows are orchestration chats, or one agent archived while the workspace stayed live (workspace-live). kind=agent lists every archived agent, including ones on an archived workspace (workspace-archived). query matches title, branch, repo, agent, ticket, or PR. limit default 40 max 250.",
419
419
  "- archive_workspace \u2014 archive every agent on a checkout and remove the worktree (cowboy keeps the project folder). Pass any chat id on that workspace. The card leaves Home for History.",
@@ -504,7 +504,7 @@ function coordinatorTurnReminder(opts) {
504
504
  goal ? `- Goal / title: ${goal}` : null,
505
505
  accountDefaultsPlaybookLine(),
506
506
  accountContextReminderLine() || null,
507
- "- Status: list_board (worktree Kanban: New \u2192 Draft \u2192 Review \u2192 Approved \u2192 Merged) or list_chats. Link chats as `[Title](sideboard://chat/<id>)`. Merge only if the user asked. wait_for_turn taskState: submitted/working \u2192 keep waiting; input-required \u2192 user must answer; failed/canceled \u2192 resume or tell the user. blockedReason is why that agent is waiting \u2014 read it; do not send_to_chat a check-in."
507
+ "- Status: list_board (worktree Kanban: New \u2192 Draft \u2192 Review \u2192 Approved \u2192 Merged) or list_chats. Link chats as `[Title](sideboard://chat/<id>)`. Merge only if the user asked. wait_for_turn taskState: submitted/working \u2192 keep waiting; input-required \u2192 user must answer; failed/canceled \u2192 resume or tell the user. blockedReason is why that agent is waiting \u2014 read it; do not send_to_chat a check-in. If children are idle, read get_turn_result and reply now."
508
508
  ].filter(Boolean).join("\n");
509
509
  }
510
510
  function ensureGlobalCoordinatorCwd(opts) {
@@ -578,6 +578,7 @@ function coordinatorSystemPrompt(opts) {
578
578
  ] : audience === "slack" ? [
579
579
  "You are a Sideboard coordinator responding to a Slack DM or @mention via the Sideboard Slack app.",
580
580
  "Your reply will be posted back in Slack \u2014 be concise and actionable.",
581
+ "Do not say you will get back to them later. Ending the turn does not send a follow-up Slack message. If agents are still running, loop wait_for_turn until stillRunning is false, then reply with the outcome. If they are already idle, read get_turn_result and reply now.",
581
582
  "Sideboard signs the Slack reply with this Mac's destination name (Personal / Work). Do not prefix that name yourself.",
582
583
  "Call set_caffeinate enabled=true when they start a stretch of remote work so the Mac stays awake. Call set_caffeinate enabled=false when they say they are done, wrapping up, or going to sleep.",
583
584
  SLACK_REPLY_FORMATTING