@sideboard-ai/core 0.1.337 → 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 +231 -41
  18. package/dist/index.d.cts +2 -5
  19. package/dist/index.d.ts +2 -5
  20. package/dist/index.js +93 -28
  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
@@ -14,7 +14,7 @@ import {
14
14
  parseSessionQuotaResetAt,
15
15
  planModeTurnInstruction,
16
16
  resolveQuotaFallbackAgent
17
- } from "./chunk-54GBJC6J.js";
17
+ } from "./chunk-X3W3HBLK.js";
18
18
  import {
19
19
  applyWorktreePkgCacheEnv,
20
20
  askBlockStillWaiting,
@@ -39,6 +39,7 @@ import {
39
39
  listRunningDetachedJobs,
40
40
  maybeCompactContext,
41
41
  mergeWorktreeActiveRuns,
42
+ orchestratorPromisedLaterReport,
42
43
  parsePlanQuestionsInput,
43
44
  planJobContinue,
44
45
  planQuestionsSignature,
@@ -53,7 +54,7 @@ import {
53
54
  worktreeDevProcessKey,
54
55
  worktreeRunProcessKey,
55
56
  worktreeSetupProcessKey
56
- } from "./chunk-4O7436ZH.js";
57
+ } from "./chunk-QJGAWDAX.js";
57
58
  import {
58
59
  applyAgentEvent,
59
60
  clipAgentEventForPaint,
@@ -118,7 +119,7 @@ import {
118
119
  stageAbsolutePathsAsAttachments,
119
120
  stageBuffersAsAttachments,
120
121
  syncWorkspacesFromThreads
121
- } from "./chunk-MGEUXR6E.js";
122
+ } from "./chunk-BR3C3EX5.js";
122
123
  import {
123
124
  addPrStackLayer,
124
125
  allocateTeamSlug,
@@ -561,9 +562,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
561
562
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
562
563
  );
563
564
  }
564
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-B5IHENCP.js");
565
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-WRME3OJ5.js");
565
566
  if (isGlobalThread2(thread)) {
566
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-WVVC2TLP.js");
567
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-AHR54RWJ.js");
567
568
  ensureGlobalCoordinatorCwd2(
568
569
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
569
570
  );
@@ -2133,6 +2134,69 @@ function notifyParentOfChildHalt(child, status, send) {
2133
2134
  return true;
2134
2135
  }
2135
2136
 
2137
+ // src/orchestrator/child-report.ts
2138
+ var MAX_REPORT_WAKES = 2;
2139
+ var sentForReply = /* @__PURE__ */ new Set();
2140
+ var wakesByParent = /* @__PURE__ */ new Map();
2141
+ function clearParentReportWake(parentId) {
2142
+ wakesByParent.delete(parentId);
2143
+ const prefix = `${parentId}:`;
2144
+ for (const key of sentForReply) {
2145
+ if (key.startsWith(prefix)) sentForReply.delete(key);
2146
+ }
2147
+ }
2148
+ function parentOwesDeferredReport(parent) {
2149
+ if (!parent || parent.status === "archived") return false;
2150
+ if (!isOrchestratorThread(parent)) return false;
2151
+ if (parent.status !== "idle") return false;
2152
+ if (parent.queue.length > 0) return false;
2153
+ const last = lastAgentReply(parent.messages);
2154
+ return orchestratorPromisedLaterReport(last?.text);
2155
+ }
2156
+ function childFinishedReportPrompt(child) {
2157
+ const title = child.title?.trim() || "Untitled";
2158
+ const link = `[${title}](sideboard://chat/${child.id})`;
2159
+ return [
2160
+ `Sideboard: child worktree ${link} finished (status=idle).`,
2161
+ "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.",
2162
+ "Read get_turn_result for this child and any siblings. If any are still running (stillRunning true), loop wait_for_turn until they finish.",
2163
+ "Then reply with the outcome. Do not promise a later update.",
2164
+ "This is information \u2014 not a new user request."
2165
+ ].join("\n");
2166
+ }
2167
+ function replyKey(parent) {
2168
+ const last = lastAgentReply(parent.messages);
2169
+ if (!last) return null;
2170
+ return `${parent.id}:${last.ts}`;
2171
+ }
2172
+ function notifyParentOfChildReport(child, send) {
2173
+ if (!child.parentThreadId) return false;
2174
+ const parent = readThread(child.parentThreadId);
2175
+ if (!parentOwesDeferredReport(parent)) return false;
2176
+ const key = replyKey(parent);
2177
+ if (!key || sentForReply.has(key)) return false;
2178
+ const wakes = wakesByParent.get(parent.id) ?? 0;
2179
+ if (wakes >= MAX_REPORT_WAKES) return false;
2180
+ sentForReply.add(key);
2181
+ wakesByParent.set(parent.id, wakes + 1);
2182
+ const parentId = parent.id;
2183
+ void send(parentId, childFinishedReportPrompt(child)).catch(() => {
2184
+ sentForReply.delete(key);
2185
+ const current = wakesByParent.get(parentId) ?? 1;
2186
+ if (current <= 1) wakesByParent.delete(parentId);
2187
+ else wakesByParent.set(parentId, current - 1);
2188
+ });
2189
+ return true;
2190
+ }
2191
+ function settleChildReportAfterTurn(thread, chatText, send) {
2192
+ if (!thread) return;
2193
+ if (isOrchestratorThread(thread)) {
2194
+ if (!orchestratorPromisedLaterReport(chatText)) clearParentReportWake(thread.id);
2195
+ return;
2196
+ }
2197
+ notifyParentOfChildReport(thread, send);
2198
+ }
2199
+
2136
2200
  // src/orchestrator/stop-reason.ts
2137
2201
  var STOP_REASON_MAX = 500;
2138
2202
  function resolveStopReason(opts) {
@@ -3864,7 +3928,7 @@ async function adoptThread(input) {
3864
3928
  messages: input.messages ?? []
3865
3929
  });
3866
3930
  writeThread(thread);
3867
- const { addWorkspace: addWorkspace2 } = await import("./workspaces-VXE2MBKD.js");
3931
+ const { addWorkspace: addWorkspace2 } = await import("./workspaces-7ZB6GUXB.js");
3868
3932
  await addWorkspace2(repoPath);
3869
3933
  const { ensureWorktreeSideboardIgnored } = await import("./worktree-exclude-KMZQXZKP.js");
3870
3934
  await ensureWorktreeSideboardIgnored(input.worktreePath);
@@ -6818,7 +6882,7 @@ function formatScheduledPrompt(name, prompt) {
6818
6882
  ${prompt}`;
6819
6883
  }
6820
6884
  async function defaultDeps() {
6821
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-BOLYQZO7.js");
6885
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-NXLV3FF4.js");
6822
6886
  const orch = getOrchestrator2();
6823
6887
  return {
6824
6888
  findThread: (id) => findThreadByRef(id),
@@ -7484,11 +7548,7 @@ var Orchestrator = class {
7484
7548
  this.emit({ type: "queue_changed", threadId, queue: next.queue });
7485
7549
  this.haltDrain.delete(threadId);
7486
7550
  }
7487
- /**
7488
- * Worktree agent ended the turn after “I’ll let you know” (or left a
7489
- * detached test/pack job running). Queue a continue so the chat does not
7490
- * go idle with nobody watching the log.
7491
- */
7551
+ /** Queue a continue when a turn promised a later report or left a detached job running. */
7492
7552
  maybeEnqueueJobContinue(threadId, chatText, parts = []) {
7493
7553
  if (this.haltDrain.has(threadId)) return;
7494
7554
  const thread = readThread(threadId);
@@ -7885,7 +7945,7 @@ var Orchestrator = class {
7885
7945
  goal: thread.sourceRef || thread.title
7886
7946
  }),
7887
7947
  slackInbound ? [
7888
- "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.",
7948
+ "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.",
7889
7949
  SLACK_REPLY_FORMATTING
7890
7950
  ].join("\n") : null
7891
7951
  ].filter(Boolean).join("\n") : null;
@@ -8292,6 +8352,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8292
8352
  if (exitCode === 0) {
8293
8353
  this.crashContinued.delete(threadId);
8294
8354
  this.maybeEnqueueJobContinue(threadId, chatText, parts);
8355
+ settleChildReportAfterTurn(readThread(threadId), chatText, (id, prompt2) => this.send(id, prompt2));
8295
8356
  } else {
8296
8357
  const blob = [chatText, detail].filter(Boolean).join("\n");
8297
8358
  const failedOver = await isolateQuotaFailover(
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-5MXLDDYF.js";
13
13
  import {
14
14
  isOrchestratorThread
15
- } from "./chunk-MGEUXR6E.js";
15
+ } from "./chunk-BR3C3EX5.js";
16
16
  import {
17
17
  codexUnattendedGitConfigArgs,
18
18
  mergeAgentGitAuthEnv,
@@ -2966,7 +2966,7 @@ var claudeAdapter = {
2966
2966
  );
2967
2967
  }
2968
2968
  const mode = permissionMode(thread);
2969
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-B5IHENCP.js");
2969
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-WRME3OJ5.js");
2970
2970
  const isOrchestrator = isOrchestratorThread2(thread);
2971
2971
  const rpc = worktreeAgentRpc(isOrchestrator);
2972
2972
  const injectedServers = await buildInjectedMcpServers({
@@ -32,9 +32,9 @@ import {
32
32
  tryReservePort,
33
33
  tryReservePorts,
34
34
  worktreeRunPortsPath
35
- } from "./chunk-B6TPN624.js";
35
+ } from "./chunk-2QN74PVY.js";
36
36
  import "./chunk-OOXRMTU6.js";
37
- import "./chunk-CDRGQ6GX.js";
37
+ import "./chunk-T76WCIQN.js";
38
38
  import "./chunk-4OVQGZEI.js";
39
39
  import "./chunk-BDQFZAE6.js";
40
40
  import "./chunk-BMRJNRQK.js";
@@ -34,9 +34,9 @@ import {
34
34
  tryReservePort,
35
35
  tryReservePorts,
36
36
  worktreeRunPortsPath
37
- } from "./chunk-4O7436ZH.js";
37
+ } from "./chunk-QJGAWDAX.js";
38
38
  import "./chunk-5MXLDDYF.js";
39
- import "./chunk-MGEUXR6E.js";
39
+ import "./chunk-BR3C3EX5.js";
40
40
  import "./chunk-ERCYQTJU.js";
41
41
  import "./chunk-N2WW62LF.js";
42
42
  import "./chunk-GK7H3SY7.js";
@@ -9,7 +9,7 @@ import {
9
9
  enrichWorkspacesWithGithub,
10
10
  ensureGlobalCoordinatorCwd,
11
11
  formatWorkspaceInventory
12
- } from "./chunk-MGEUXR6E.js";
12
+ } from "./chunk-BR3C3EX5.js";
13
13
  import "./chunk-ERCYQTJU.js";
14
14
  import "./chunk-N2WW62LF.js";
15
15
  import "./chunk-GK7H3SY7.js";
@@ -7,7 +7,7 @@ import {
7
7
  enrichWorkspacesWithGithub,
8
8
  ensureGlobalCoordinatorCwd,
9
9
  formatWorkspaceInventory
10
- } from "./chunk-CDRGQ6GX.js";
10
+ } from "./chunk-T76WCIQN.js";
11
11
  import "./chunk-4OVQGZEI.js";
12
12
  import "./chunk-BDQFZAE6.js";
13
13
  import "./chunk-BMRJNRQK.js";
@@ -18,7 +18,7 @@ import {
18
18
  remoteCoordinatorSourceRef,
19
19
  slackCoordinatorSourceRef,
20
20
  takenTeamSlugsForOrchestration
21
- } from "./chunk-CDRGQ6GX.js";
21
+ } from "./chunk-T76WCIQN.js";
22
22
  import "./chunk-4OVQGZEI.js";
23
23
  import "./chunk-BDQFZAE6.js";
24
24
  import "./chunk-BMRJNRQK.js";
@@ -20,7 +20,7 @@ import {
20
20
  remoteCoordinatorSourceRef,
21
21
  slackCoordinatorSourceRef,
22
22
  takenTeamSlugsForOrchestration
23
- } from "./chunk-MGEUXR6E.js";
23
+ } from "./chunk-BR3C3EX5.js";
24
24
  import "./chunk-ERCYQTJU.js";
25
25
  import "./chunk-N2WW62LF.js";
26
26
  import "./chunk-GK7H3SY7.js";
package/dist/index.cjs CHANGED
@@ -13099,7 +13099,7 @@ function coordinatorTurnReminder(opts) {
13099
13099
  goal ? `- Goal / title: ${goal}` : null,
13100
13100
  accountDefaultsPlaybookLine(),
13101
13101
  accountContextReminderLine() || null,
13102
- "- 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."
13102
+ "- 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."
13103
13103
  ].filter(Boolean).join("\n");
13104
13104
  }
13105
13105
  function ensureGlobalCoordinatorCwd(opts) {
@@ -13173,6 +13173,7 @@ function coordinatorSystemPrompt(opts) {
13173
13173
  ] : audience === "slack" ? [
13174
13174
  "You are a Sideboard coordinator responding to a Slack DM or @mention via the Sideboard Slack app.",
13175
13175
  "Your reply will be posted back in Slack \u2014 be concise and actionable.",
13176
+ "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.",
13176
13177
  "Sideboard signs the Slack reply with this Mac's destination name (Personal / Work). Do not prefix that name yourself.",
13177
13178
  "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.",
13178
13179
  SLACK_REPLY_FORMATTING
@@ -13233,7 +13234,7 @@ var init_coordinator_prompt = __esm({
13233
13234
  "- 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.",
13234
13235
  "- 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)",
13235
13236
  "- 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.",
13236
- "- 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.",
13237
+ "- 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.",
13237
13238
  "- stop_chat \u2014 force-stop: kill in-flight turn AND clear queued prompts (do not leave stale queue after an interrupt)",
13238
13239
  "- 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.",
13239
13240
  "- 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.",
@@ -24124,6 +24125,57 @@ var init_job_process = __esm({
24124
24125
  }
24125
24126
  });
24126
24127
 
24128
+ // src/orchestrator/deferred-report.ts
24129
+ function looksLikeDeferredDonePromise(text7) {
24130
+ const t = (text7 ?? "").trim();
24131
+ if (!t || t.length > DEFERRED_DONE_MAX_CHARS) return false;
24132
+ const unquoted = t.replace(/`[^`]*`/g, " ").replace(/["“”][^"“”]*["“”]/g, " ").replace(/\s+/g, " ").trim();
24133
+ if (!unquoted) return false;
24134
+ 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(
24135
+ unquoted
24136
+ ) || /\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);
24137
+ }
24138
+ function orchestratorPromisedLaterReport(text7) {
24139
+ if (looksLikeDeferredDonePromise(text7)) return true;
24140
+ const t = (text7 ?? "").trim();
24141
+ if (!t || t.length <= DEFERRED_DONE_MAX_CHARS) return false;
24142
+ const lines = t.split("\n").map((line) => line.trim()).filter(Boolean);
24143
+ const closing = [];
24144
+ let size = 0;
24145
+ for (let i = lines.length - 1; i >= 0; i--) {
24146
+ const line = lines[i];
24147
+ if (closing.length === 0 && line.length > DEFERRED_DONE_MAX_CHARS) {
24148
+ closing.push(line.slice(-DEFERRED_DONE_MAX_CHARS));
24149
+ break;
24150
+ }
24151
+ if (closing.length > 0 && size + line.length + 1 > DEFERRED_DONE_MAX_CHARS) break;
24152
+ closing.unshift(line);
24153
+ size += line.length + 1;
24154
+ if (closing.length >= 4) break;
24155
+ }
24156
+ const slice = closing.join("\n");
24157
+ if (!slice || slice === t) return false;
24158
+ return looksLikeDeferredDonePromise(slice);
24159
+ }
24160
+ function formatOrchestratorDeferredContinuePrompt() {
24161
+ return [
24162
+ "You ended the turn after promising to report later.",
24163
+ "This chat does not resume on its own. Slack and the desktop only see a reply when you finish a turn with the outcome.",
24164
+ "list_chats for the child agents on this orchestration chat.",
24165
+ "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.",
24166
+ "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",
24167
+ "Then reply with what happened. Do not promise a later update.",
24168
+ "If you have not started the work yet, start it in this turn and wait until it finishes before you reply."
24169
+ ].join(" ");
24170
+ }
24171
+ var DEFERRED_DONE_MAX_CHARS;
24172
+ var init_deferred_report = __esm({
24173
+ "src/orchestrator/deferred-report.ts"() {
24174
+ "use strict";
24175
+ DEFERRED_DONE_MAX_CHARS = 480;
24176
+ }
24177
+ });
24178
+
24127
24179
  // src/mcp/wait-for-job.ts
24128
24180
  function mcpWaitForJobTimeoutMs(requested) {
24129
24181
  return mcpWaitForTurnTimeoutMs(requested);
@@ -24170,15 +24222,6 @@ function listRunningDetachedJobs(worktreePath) {
24170
24222
  }
24171
24223
  return running2.sort();
24172
24224
  }
24173
- function looksLikeDeferredDonePromise(text7) {
24174
- const t = (text7 ?? "").trim();
24175
- if (!t || t.length > DEFERRED_DONE_MAX_CHARS) return false;
24176
- const unquoted = t.replace(/`[^`]*`/g, " ").replace(/["“”][^"“”]*["“”]/g, " ").replace(/\s+/g, " ").trim();
24177
- if (!unquoted) return false;
24178
- 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(
24179
- unquoted
24180
- ) || /\bi(?:['’]ll| will)\s+come back when\b/i.test(unquoted);
24181
- }
24182
24225
  function isJobContinuePrompt(text7) {
24183
24226
  if (typeof text7 !== "string") return false;
24184
24227
  const t = text7.trim();
@@ -24233,10 +24276,15 @@ function turnWatchedDetachedJob(parts) {
24233
24276
  });
24234
24277
  }
24235
24278
  function planJobContinue(opts) {
24236
- if (opts.isOrchestrator) return { action: "none" };
24237
24279
  if (opts.agent === "brightsy") return { action: "none" };
24238
24280
  if (opts.queueLength > 0) return { action: "none" };
24239
24281
  if (opts.continueCount >= MAX_JOB_CONTINUES) return { action: "none" };
24282
+ if (opts.isOrchestrator) {
24283
+ if (orchestratorPromisedLaterReport(opts.chatText) && !opts.alreadyNudged) {
24284
+ return { action: "nudge", prompt: formatOrchestratorDeferredContinuePrompt() };
24285
+ }
24286
+ return { action: "none" };
24287
+ }
24240
24288
  const farewell = looksLikeDeferredDonePromise(opts.chatText);
24241
24289
  if (opts.runningJobIds.length > 0 && (farewell || opts.watchedJob)) {
24242
24290
  return {
@@ -24437,7 +24485,7 @@ async function stopDetachedJob(cwd, id, opts) {
24437
24485
  hint: stopped ? MCP_STOP_JOB_HINT : MCP_WAIT_JOB_STILL_RUNNING_HINT
24438
24486
  };
24439
24487
  }
24440
- var import_node_fs54, import_node_path56, MAX_JOB_CONTINUES, MAX_JOB_DELTA_LINES, MAX_JOB_DELTA_CHARS, DEFERRED_DONE_MAX_CHARS, GH_WATCH_REFRESH, MCP_WAIT_JOB_STILL_RUNNING_HINT, MCP_STOP_JOB_HINT, JOB_ID_RE;
24488
+ var import_node_fs54, import_node_path56, MAX_JOB_CONTINUES, MAX_JOB_DELTA_LINES, MAX_JOB_DELTA_CHARS, GH_WATCH_REFRESH, MCP_WAIT_JOB_STILL_RUNNING_HINT, MCP_STOP_JOB_HINT, JOB_ID_RE;
24441
24489
  var init_wait_for_job = __esm({
24442
24490
  "src/mcp/wait-for-job.ts"() {
24443
24491
  "use strict";
@@ -24446,10 +24494,11 @@ var init_wait_for_job = __esm({
24446
24494
  init_workspace_scratch();
24447
24495
  init_job_process();
24448
24496
  init_wait_for_turn();
24497
+ init_deferred_report();
24498
+ init_deferred_report();
24449
24499
  MAX_JOB_CONTINUES = 8;
24450
24500
  MAX_JOB_DELTA_LINES = 80;
24451
24501
  MAX_JOB_DELTA_CHARS = 4e3;
24452
- DEFERRED_DONE_MAX_CHARS = 480;
24453
24502
  GH_WATCH_REFRESH = "Refreshing run status every 3 seconds.";
24454
24503
  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.";
24455
24504
  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.";
@@ -26057,6 +26106,79 @@ var init_child_halt = __esm({
26057
26106
  }
26058
26107
  });
26059
26108
 
26109
+ // src/orchestrator/child-report.ts
26110
+ function clearParentReportWake(parentId) {
26111
+ wakesByParent.delete(parentId);
26112
+ const prefix = `${parentId}:`;
26113
+ for (const key of sentForReply) {
26114
+ if (key.startsWith(prefix)) sentForReply.delete(key);
26115
+ }
26116
+ }
26117
+ function parentOwesDeferredReport(parent) {
26118
+ if (!parent || parent.status === "archived") return false;
26119
+ if (!isOrchestratorThread(parent)) return false;
26120
+ if (parent.status !== "idle") return false;
26121
+ if (parent.queue.length > 0) return false;
26122
+ const last = lastAgentReply(parent.messages);
26123
+ return orchestratorPromisedLaterReport(last?.text);
26124
+ }
26125
+ function childFinishedReportPrompt(child) {
26126
+ const title = child.title?.trim() || "Untitled";
26127
+ const link = `[${title}](sideboard://chat/${child.id})`;
26128
+ return [
26129
+ `Sideboard: child worktree ${link} finished (status=idle).`,
26130
+ "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.",
26131
+ "Read get_turn_result for this child and any siblings. If any are still running (stillRunning true), loop wait_for_turn until they finish.",
26132
+ "Then reply with the outcome. Do not promise a later update.",
26133
+ "This is information \u2014 not a new user request."
26134
+ ].join("\n");
26135
+ }
26136
+ function replyKey(parent) {
26137
+ const last = lastAgentReply(parent.messages);
26138
+ if (!last) return null;
26139
+ return `${parent.id}:${last.ts}`;
26140
+ }
26141
+ function notifyParentOfChildReport(child, send3) {
26142
+ if (!child.parentThreadId) return false;
26143
+ const parent = readThread(child.parentThreadId);
26144
+ if (!parentOwesDeferredReport(parent)) return false;
26145
+ const key = replyKey(parent);
26146
+ if (!key || sentForReply.has(key)) return false;
26147
+ const wakes = wakesByParent.get(parent.id) ?? 0;
26148
+ if (wakes >= MAX_REPORT_WAKES) return false;
26149
+ sentForReply.add(key);
26150
+ wakesByParent.set(parent.id, wakes + 1);
26151
+ const parentId = parent.id;
26152
+ void send3(parentId, childFinishedReportPrompt(child)).catch(() => {
26153
+ sentForReply.delete(key);
26154
+ const current = wakesByParent.get(parentId) ?? 1;
26155
+ if (current <= 1) wakesByParent.delete(parentId);
26156
+ else wakesByParent.set(parentId, current - 1);
26157
+ });
26158
+ return true;
26159
+ }
26160
+ function settleChildReportAfterTurn(thread, chatText, send3) {
26161
+ if (!thread) return;
26162
+ if (isOrchestratorThread(thread)) {
26163
+ if (!orchestratorPromisedLaterReport(chatText)) clearParentReportWake(thread.id);
26164
+ return;
26165
+ }
26166
+ notifyParentOfChildReport(thread, send3);
26167
+ }
26168
+ var MAX_REPORT_WAKES, sentForReply, wakesByParent;
26169
+ var init_child_report = __esm({
26170
+ "src/orchestrator/child-report.ts"() {
26171
+ "use strict";
26172
+ init_wait_for_job();
26173
+ init_global_workspace();
26174
+ init_thread_store();
26175
+ init_injected_notices();
26176
+ MAX_REPORT_WAKES = 2;
26177
+ sentForReply = /* @__PURE__ */ new Set();
26178
+ wakesByParent = /* @__PURE__ */ new Map();
26179
+ }
26180
+ });
26181
+
26060
26182
  // src/orchestrator/stop-reason.ts
26061
26183
  function resolveStopReason(opts) {
26062
26184
  const explicit = opts?.reason?.trim();
@@ -32864,6 +32986,7 @@ var init_orchestrator = __esm({
32864
32986
  init_model_context();
32865
32987
  init_agent_block();
32866
32988
  init_child_halt();
32989
+ init_child_report();
32867
32990
  init_stop_reason();
32868
32991
  init_steer_request();
32869
32992
  init_ephemeral_automation();
@@ -33412,11 +33535,7 @@ var init_orchestrator = __esm({
33412
33535
  this.emit({ type: "queue_changed", threadId, queue: next.queue });
33413
33536
  this.haltDrain.delete(threadId);
33414
33537
  }
33415
- /**
33416
- * Worktree agent ended the turn after “I’ll let you know” (or left a
33417
- * detached test/pack job running). Queue a continue so the chat does not
33418
- * go idle with nobody watching the log.
33419
- */
33538
+ /** Queue a continue when a turn promised a later report or left a detached job running. */
33420
33539
  maybeEnqueueJobContinue(threadId, chatText, parts = []) {
33421
33540
  if (this.haltDrain.has(threadId)) return;
33422
33541
  const thread = readThread(threadId);
@@ -33813,7 +33932,7 @@ var init_orchestrator = __esm({
33813
33932
  goal: thread.sourceRef || thread.title
33814
33933
  }),
33815
33934
  slackInbound ? [
33816
- "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.",
33935
+ "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.",
33817
33936
  SLACK_REPLY_FORMATTING
33818
33937
  ].join("\n") : null
33819
33938
  ].filter(Boolean).join("\n") : null;
@@ -34220,6 +34339,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
34220
34339
  if (exitCode === 0) {
34221
34340
  this.crashContinued.delete(threadId);
34222
34341
  this.maybeEnqueueJobContinue(threadId, chatText, parts);
34342
+ settleChildReportAfterTurn(readThread(threadId), chatText, (id, prompt2) => this.send(id, prompt2));
34223
34343
  } else {
34224
34344
  const blob = [chatText, detail].filter(Boolean).join("\n");
34225
34345
  const failedOver = await isolateQuotaFailover(
@@ -38074,7 +38194,8 @@ function row(resolved) {
38074
38194
  function phoneAccountDefaults() {
38075
38195
  return {
38076
38196
  orchestration: row(resolveOrchestratorDefaults()),
38077
- worktree: row(resolveThreadDefaults())
38197
+ worktree: row(resolveThreadDefaults()),
38198
+ followUp: followUpBehavior()
38078
38199
  };
38079
38200
  }
38080
38201
 
@@ -40740,7 +40861,10 @@ function phoneBoardKey(sidebar) {
40740
40861
  ${trees}`;
40741
40862
  }).join("\n---\n");
40742
40863
  const defaults = sidebar.defaults;
40743
- const defaultsKey = defaults ? [defaults.orchestration, defaults.worktree].map((row2) => [row2.agent, row2.model ?? "", row2.effort, row2.fast ? "1" : "0"].join(" ")).join("\n") : "";
40864
+ const defaultsKey = defaults ? [
40865
+ defaults.followUp,
40866
+ [defaults.orchestration, defaults.worktree].map((row2) => [row2.agent, row2.model ?? "", row2.effort, row2.fast ? "1" : "0"].join(" ")).join("\n")
40867
+ ].join("\n") : "";
40744
40868
  return `${orchestration}
40745
40869
  ===
40746
40870
  ${projects}
@@ -49532,6 +49656,76 @@ init_orchestrator();
49532
49656
  init_coordinator_prompt();
49533
49657
  init_app_settings();
49534
49658
  init_global_workspace();
49659
+ init_wait_for_job();
49660
+
49661
+ // src/slack/deferred-reply.ts
49662
+ init_wait_for_job();
49663
+ init_deferred_report();
49664
+ init_thread_store();
49665
+ var SLACK_LISTEN_STOPPED_REPLY = "Sideboard stopped the in-progress turn. Send another message when you want to continue.";
49666
+ var SLACK_LISTEN_TIMEOUT_REPLY = [
49667
+ "Sideboard timed out waiting for the local agent turn to finish.",
49668
+ 'Send another message to interrupt and retry, or send "stop".'
49669
+ ].join(" ");
49670
+ var SLACK_LISTEN_INPUT_REQUIRED_REPLY = [
49671
+ "Sideboard is waiting for an answer on the Mac (the coordinator called ask_user).",
49672
+ "The picker is in the Sideboard app \u2014 not in Slack.",
49673
+ 'Reply here after you answer it on the Mac, or send "stop".'
49674
+ ].join(" ");
49675
+ function slackShouldHoldDeferredReply(opts) {
49676
+ if (!orchestratorPromisedLaterReport(opts.reply)) return false;
49677
+ if (opts.queue.some((item) => isJobContinuePrompt(item))) return true;
49678
+ return opts.status === "running" || opts.status === "queued";
49679
+ }
49680
+ var SLACK_DEFERRED_HOLD_LIMIT = 3;
49681
+ async function waitUntilOrchestratorContinueSettles(orch, threadId, timeoutMs) {
49682
+ const start = Date.now();
49683
+ while (Date.now() - start < timeoutMs) {
49684
+ const thread = readThread(threadId);
49685
+ if (!thread || thread.status === "stopped" || thread.status === "archived") return;
49686
+ if (thread.status === "running" || thread.status === "queued") {
49687
+ const remaining = Math.max(1, timeoutMs - (Date.now() - start));
49688
+ await orch.waitForTurn(threadId, remaining);
49689
+ return;
49690
+ }
49691
+ if (!thread.queue.some((item) => isJobContinuePrompt(item))) return;
49692
+ await new Promise((resolve3) => setTimeout(resolve3, 40));
49693
+ }
49694
+ throw new Error("wait_for_turn timed out");
49695
+ }
49696
+ async function awaitDeferredOrchestratorReply(orch, threadId, initial, timeoutMs, aborted) {
49697
+ let reply = initial;
49698
+ const deadline = Date.now() + timeoutMs;
49699
+ for (let i = 0; i < SLACK_DEFERRED_HOLD_LIMIT; i++) {
49700
+ if (aborted?.()) return { reply: "", interrupted: true };
49701
+ const thread = readThread(threadId);
49702
+ if (!thread || thread.status === "stopped" || thread.status === "archived") {
49703
+ return { reply: "", interrupted: true };
49704
+ }
49705
+ if (!slackShouldHoldDeferredReply({ reply, queue: thread.queue, status: thread.status })) {
49706
+ return { reply, interrupted: false };
49707
+ }
49708
+ const remaining = deadline - Date.now();
49709
+ if (remaining <= 0) return { reply, interrupted: false };
49710
+ await waitUntilOrchestratorContinueSettles(orch, threadId, remaining);
49711
+ const latest = readThread(threadId);
49712
+ if (!latest || latest.status === "stopped" || latest.status === "archived") {
49713
+ return { reply: "", interrupted: true };
49714
+ }
49715
+ reply = formatSlackTurnReply(orch.getTurnResult(threadId));
49716
+ }
49717
+ return { reply, interrupted: false };
49718
+ }
49719
+ function formatSlackTurnReply(result) {
49720
+ return outboundReplyFromTurn(result, {
49721
+ inputRequired: SLACK_LISTEN_INPUT_REQUIRED_REPLY,
49722
+ canceled: SLACK_LISTEN_STOPPED_REPLY,
49723
+ completedEmpty: () => "",
49724
+ failed: (detail) => detail ? `Sideboard coordinator failed: ${detail}` : "Sideboard coordinator failed before producing a result."
49725
+ });
49726
+ }
49727
+
49728
+ // src/slack/listen.ts
49535
49729
  init_turn_live();
49536
49730
  init_thread_store();
49537
49731
 
@@ -49797,24 +49991,6 @@ function connectSession2(ws, opts, log) {
49797
49991
  }
49798
49992
 
49799
49993
  // src/slack/listen.ts
49800
- var SLACK_LISTEN_STOPPED_REPLY = "Sideboard stopped the in-progress turn. Send another message when you want to continue.";
49801
- var SLACK_LISTEN_TIMEOUT_REPLY = [
49802
- "Sideboard timed out waiting for the local agent turn to finish.",
49803
- 'Send another message to interrupt and retry, or send "stop".'
49804
- ].join(" ");
49805
- var SLACK_LISTEN_INPUT_REQUIRED_REPLY = [
49806
- "Sideboard is waiting for an answer on the Mac (the coordinator called ask_user).",
49807
- "The picker is in the Sideboard app \u2014 not in Slack.",
49808
- 'Reply here after you answer it on the Mac, or send "stop".'
49809
- ].join(" ");
49810
- function formatSlackTurnReply(result) {
49811
- return outboundReplyFromTurn(result, {
49812
- inputRequired: SLACK_LISTEN_INPUT_REQUIRED_REPLY,
49813
- canceled: SLACK_LISTEN_STOPPED_REPLY,
49814
- completedEmpty: () => "",
49815
- failed: (detail) => detail ? `Sideboard coordinator failed: ${detail}` : "Sideboard coordinator failed before producing a result."
49816
- });
49817
- }
49818
49994
  var handleChain2 = Promise.resolve();
49819
49995
  function enqueueHandle(fn) {
49820
49996
  const run2 = handleChain2.then(fn, fn);
@@ -50124,7 +50300,9 @@ async function relayCoordinatorReplyToSlack(threadId, opts) {
50124
50300
  if (!target) return;
50125
50301
  const thread = readThread(threadId);
50126
50302
  const lastUser = thread ? [...thread.messages].reverse().find((m) => m.role === "user") : void 0;
50127
- if (lastUser && isSlackInboundUserPrompt(lastUser.text)) return;
50303
+ if (lastUser && (isSlackInboundUserPrompt(lastUser.text) || isJobContinuePrompt(lastUser.text))) {
50304
+ return;
50305
+ }
50128
50306
  const result = getOrchestrator().getTurnResult(threadId);
50129
50307
  const text7 = formatSlackTurnReply(result);
50130
50308
  if (!text7) return;
@@ -50248,6 +50426,18 @@ async function handleSlackInbound(msg, opts) {
50248
50426
  }
50249
50427
  }
50250
50428
  reply = formatSlackTurnReply(orch.getTurnResult(fresh.id));
50429
+ const held = await awaitDeferredOrchestratorReply(
50430
+ orch,
50431
+ fresh.id,
50432
+ reply,
50433
+ 14 * 60 * 1e3,
50434
+ () => slackInboundSuperseded(opts)
50435
+ );
50436
+ if (held.interrupted) {
50437
+ await dropProgress(`turn finished ${msg.ts} (deferred reply interrupted)`);
50438
+ return;
50439
+ }
50440
+ reply = held.reply;
50251
50441
  } catch (err) {
50252
50442
  if (slackInboundSuperseded(opts)) {
50253
50443
  await dropProgress(`turn error ${msg.ts} (superseded)`);