@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
package/dist/index.d.cts CHANGED
@@ -6068,11 +6068,7 @@ declare class Orchestrator {
6068
6068
  * next prompt so the same agent can continue instead of sitting on lastError.
6069
6069
  */
6070
6070
  private maybeEnqueueCrashContinue;
6071
- /**
6072
- * Worktree agent ended the turn after “I’ll let you know” (or left a
6073
- * detached test/pack job running). Queue a continue so the chat does not
6074
- * go idle with nobody watching the log.
6075
- */
6071
+ /** Queue a continue when a turn promised a later report or left a detached job running. */
6076
6072
  private maybeEnqueueJobContinue;
6077
6073
  getThreads(includeArchived?: boolean): Thread[];
6078
6074
  getThread(idOrRef: string): Thread | null;
@@ -8507,6 +8503,7 @@ declare const SLACK_LISTEN_TIMEOUT_REPLY: string;
8507
8503
  */
8508
8504
  declare const SLACK_LISTEN_INPUT_REQUIRED_REPLY: string;
8509
8505
  declare function formatSlackTurnReply(result: OutboundTurnSnapshot): string;
8506
+
8510
8507
  interface SlackListenOptions {
8511
8508
  agent?: AgentKind;
8512
8509
  signal?: AbortSignal;
package/dist/index.d.ts CHANGED
@@ -6068,11 +6068,7 @@ declare class Orchestrator {
6068
6068
  * next prompt so the same agent can continue instead of sitting on lastError.
6069
6069
  */
6070
6070
  private maybeEnqueueCrashContinue;
6071
- /**
6072
- * Worktree agent ended the turn after “I’ll let you know” (or left a
6073
- * detached test/pack job running). Queue a continue so the chat does not
6074
- * go idle with nobody watching the log.
6075
- */
6071
+ /** Queue a continue when a turn promised a later report or left a detached job running. */
6076
6072
  private maybeEnqueueJobContinue;
6077
6073
  getThreads(includeArchived?: boolean): Thread[];
6078
6074
  getThread(idOrRef: string): Thread | null;
@@ -8507,6 +8503,7 @@ declare const SLACK_LISTEN_TIMEOUT_REPLY: string;
8507
8503
  */
8508
8504
  declare const SLACK_LISTEN_INPUT_REQUIRED_REPLY: string;
8509
8505
  declare function formatSlackTurnReply(result: OutboundTurnSnapshot): string;
8506
+
8510
8507
  interface SlackListenOptions {
8511
8508
  agent?: AgentKind;
8512
8509
  signal?: AbortSignal;
package/dist/index.js CHANGED
@@ -219,7 +219,7 @@ import {
219
219
  worktreeCleanupSettings,
220
220
  writeAgentBlock,
221
221
  writeWorktreeFile
222
- } from "./chunk-EKI7D2AJ.js";
222
+ } from "./chunk-JGJIR66Z.js";
223
223
  import {
224
224
  OPTIONAL_SERVICES,
225
225
  OPTIONAL_SERVICE_IDS,
@@ -380,7 +380,7 @@ import {
380
380
  userMcpNamesToDisable,
381
381
  worktreeMcpToolNames,
382
382
  writeInjectedMcpConfig
383
- } from "./chunk-NB4U75TJ.js";
383
+ } from "./chunk-LJESHMFJ.js";
384
384
  import {
385
385
  getAgentSetupInfo,
386
386
  installAgent,
@@ -483,6 +483,7 @@ import {
483
483
  messagesForCompactArchive,
484
484
  messagesSinceLastBrightsyContextSummary,
485
485
  needsCoordinatorAction,
486
+ orchestratorPromisedLaterReport,
486
487
  readExistingReviewRequestFile,
487
488
  readWorktreeInclude,
488
489
  requestReview,
@@ -513,7 +514,7 @@ import {
513
514
  workspaceAgentChatSummaries,
514
515
  worktreeRunPortsPath,
515
516
  wrapReviewSkillMarkdown
516
- } from "./chunk-B6TPN624.js";
517
+ } from "./chunk-2QN74PVY.js";
517
518
  import {
518
519
  STDERR_EVENT_MAX_CHARS,
519
520
  STDOUT_EVENT_MAX_CHARS,
@@ -656,7 +657,7 @@ import {
656
657
  stageBuffersAsAttachments,
657
658
  syncWorkspacesFromThreads,
658
659
  takenTeamSlugsForOrchestration
659
- } from "./chunk-CDRGQ6GX.js";
660
+ } from "./chunk-T76WCIQN.js";
660
661
  import {
661
662
  GITHUB_PR_BODY_MAX_CHARS,
662
663
  GITHUB_PR_BODY_SAFE_CHARS,
@@ -2233,7 +2234,8 @@ function row(resolved) {
2233
2234
  function phoneAccountDefaults() {
2234
2235
  return {
2235
2236
  orchestration: row(resolveOrchestratorDefaults()),
2236
- worktree: row(resolveThreadDefaults())
2237
+ worktree: row(resolveThreadDefaults()),
2238
+ followUp: followUpBehavior()
2237
2239
  };
2238
2240
  }
2239
2241
 
@@ -4843,7 +4845,10 @@ function phoneBoardKey(sidebar) {
4843
4845
  ${trees}`;
4844
4846
  }).join("\n---\n");
4845
4847
  const defaults = sidebar.defaults;
4846
- const defaultsKey = defaults ? [defaults.orchestration, defaults.worktree].map((row2) => [row2.agent, row2.model ?? "", row2.effort, row2.fast ? "1" : "0"].join(" ")).join("\n") : "";
4848
+ const defaultsKey = defaults ? [
4849
+ defaults.followUp,
4850
+ [defaults.orchestration, defaults.worktree].map((row2) => [row2.agent, row2.model ?? "", row2.effort, row2.fast ? "1" : "0"].join(" ")).join("\n")
4851
+ ].join("\n") : "";
4847
4852
  return `${orchestration}
4848
4853
  ===
4849
4854
  ${projects}
@@ -8752,7 +8757,7 @@ async function startHeadlessHost(opts) {
8752
8757
  };
8753
8758
  const refreshRunning = async () => {
8754
8759
  try {
8755
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-ZUIU667R.js");
8760
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-CJBYJVD7.js");
8756
8761
  agentsRunning = getOrchestrator2().getRuntime().running;
8757
8762
  } catch {
8758
8763
  agentsRunning = 0;
@@ -10903,7 +10908,7 @@ async function handleJobStop(params, _ctx) {
10903
10908
  return stopDetachedJob(jobCwd(rec), id, reason ? { reason } : void 0);
10904
10909
  }
10905
10910
  async function defaultTurnWait(ref, timeoutMs) {
10906
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-ZUIU667R.js");
10911
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-CJBYJVD7.js");
10907
10912
  const orch = getOrchestrator2();
10908
10913
  const thread = await orch.waitForTurn(ref, timeoutMs, {
10909
10914
  resolveIfStillRunning: true
@@ -13337,6 +13342,70 @@ async function saveSlackOrgCredentials(opts) {
13337
13342
  if (!res.ok) throw new Error(await readError(res));
13338
13343
  }
13339
13344
 
13345
+ // src/slack/deferred-reply.ts
13346
+ var SLACK_LISTEN_STOPPED_REPLY = "Sideboard stopped the in-progress turn. Send another message when you want to continue.";
13347
+ var SLACK_LISTEN_TIMEOUT_REPLY = [
13348
+ "Sideboard timed out waiting for the local agent turn to finish.",
13349
+ 'Send another message to interrupt and retry, or send "stop".'
13350
+ ].join(" ");
13351
+ var SLACK_LISTEN_INPUT_REQUIRED_REPLY = [
13352
+ "Sideboard is waiting for an answer on the Mac (the coordinator called ask_user).",
13353
+ "The picker is in the Sideboard app \u2014 not in Slack.",
13354
+ 'Reply here after you answer it on the Mac, or send "stop".'
13355
+ ].join(" ");
13356
+ function slackShouldHoldDeferredReply(opts) {
13357
+ if (!orchestratorPromisedLaterReport(opts.reply)) return false;
13358
+ if (opts.queue.some((item) => isJobContinuePrompt(item))) return true;
13359
+ return opts.status === "running" || opts.status === "queued";
13360
+ }
13361
+ var SLACK_DEFERRED_HOLD_LIMIT = 3;
13362
+ async function waitUntilOrchestratorContinueSettles(orch, threadId, timeoutMs) {
13363
+ const start = Date.now();
13364
+ while (Date.now() - start < timeoutMs) {
13365
+ const thread = readThread(threadId);
13366
+ if (!thread || thread.status === "stopped" || thread.status === "archived") return;
13367
+ if (thread.status === "running" || thread.status === "queued") {
13368
+ const remaining = Math.max(1, timeoutMs - (Date.now() - start));
13369
+ await orch.waitForTurn(threadId, remaining);
13370
+ return;
13371
+ }
13372
+ if (!thread.queue.some((item) => isJobContinuePrompt(item))) return;
13373
+ await new Promise((resolve) => setTimeout(resolve, 40));
13374
+ }
13375
+ throw new Error("wait_for_turn timed out");
13376
+ }
13377
+ async function awaitDeferredOrchestratorReply(orch, threadId, initial, timeoutMs, aborted) {
13378
+ let reply = initial;
13379
+ const deadline = Date.now() + timeoutMs;
13380
+ for (let i = 0; i < SLACK_DEFERRED_HOLD_LIMIT; i++) {
13381
+ if (aborted?.()) return { reply: "", interrupted: true };
13382
+ const thread = readThread(threadId);
13383
+ if (!thread || thread.status === "stopped" || thread.status === "archived") {
13384
+ return { reply: "", interrupted: true };
13385
+ }
13386
+ if (!slackShouldHoldDeferredReply({ reply, queue: thread.queue, status: thread.status })) {
13387
+ return { reply, interrupted: false };
13388
+ }
13389
+ const remaining = deadline - Date.now();
13390
+ if (remaining <= 0) return { reply, interrupted: false };
13391
+ await waitUntilOrchestratorContinueSettles(orch, threadId, remaining);
13392
+ const latest = readThread(threadId);
13393
+ if (!latest || latest.status === "stopped" || latest.status === "archived") {
13394
+ return { reply: "", interrupted: true };
13395
+ }
13396
+ reply = formatSlackTurnReply(orch.getTurnResult(threadId));
13397
+ }
13398
+ return { reply, interrupted: false };
13399
+ }
13400
+ function formatSlackTurnReply(result) {
13401
+ return outboundReplyFromTurn(result, {
13402
+ inputRequired: SLACK_LISTEN_INPUT_REQUIRED_REPLY,
13403
+ canceled: SLACK_LISTEN_STOPPED_REPLY,
13404
+ completedEmpty: () => "",
13405
+ failed: (detail) => detail ? `Sideboard coordinator failed: ${detail}` : "Sideboard coordinator failed before producing a result."
13406
+ });
13407
+ }
13408
+
13340
13409
  // src/slack/reply-target.ts
13341
13410
  import { existsSync as existsSync4, readFileSync as readFileSync6 } from "fs";
13342
13411
  import { join as join9 } from "path";
@@ -13595,24 +13664,6 @@ function connectSession2(ws, opts, log) {
13595
13664
  }
13596
13665
 
13597
13666
  // src/slack/listen.ts
13598
- var SLACK_LISTEN_STOPPED_REPLY = "Sideboard stopped the in-progress turn. Send another message when you want to continue.";
13599
- var SLACK_LISTEN_TIMEOUT_REPLY = [
13600
- "Sideboard timed out waiting for the local agent turn to finish.",
13601
- 'Send another message to interrupt and retry, or send "stop".'
13602
- ].join(" ");
13603
- var SLACK_LISTEN_INPUT_REQUIRED_REPLY = [
13604
- "Sideboard is waiting for an answer on the Mac (the coordinator called ask_user).",
13605
- "The picker is in the Sideboard app \u2014 not in Slack.",
13606
- 'Reply here after you answer it on the Mac, or send "stop".'
13607
- ].join(" ");
13608
- function formatSlackTurnReply(result) {
13609
- return outboundReplyFromTurn(result, {
13610
- inputRequired: SLACK_LISTEN_INPUT_REQUIRED_REPLY,
13611
- canceled: SLACK_LISTEN_STOPPED_REPLY,
13612
- completedEmpty: () => "",
13613
- failed: (detail) => detail ? `Sideboard coordinator failed: ${detail}` : "Sideboard coordinator failed before producing a result."
13614
- });
13615
- }
13616
13667
  var handleChain2 = Promise.resolve();
13617
13668
  function enqueueHandle(fn) {
13618
13669
  const run2 = handleChain2.then(fn, fn);
@@ -13922,7 +13973,9 @@ async function relayCoordinatorReplyToSlack(threadId, opts) {
13922
13973
  if (!target) return;
13923
13974
  const thread = readThread(threadId);
13924
13975
  const lastUser = thread ? [...thread.messages].reverse().find((m) => m.role === "user") : void 0;
13925
- if (lastUser && isSlackInboundUserPrompt(lastUser.text)) return;
13976
+ if (lastUser && (isSlackInboundUserPrompt(lastUser.text) || isJobContinuePrompt(lastUser.text))) {
13977
+ return;
13978
+ }
13926
13979
  const result = getOrchestrator().getTurnResult(threadId);
13927
13980
  const text5 = formatSlackTurnReply(result);
13928
13981
  if (!text5) return;
@@ -14046,6 +14099,18 @@ async function handleSlackInbound(msg, opts) {
14046
14099
  }
14047
14100
  }
14048
14101
  reply = formatSlackTurnReply(orch.getTurnResult(fresh.id));
14102
+ const held = await awaitDeferredOrchestratorReply(
14103
+ orch,
14104
+ fresh.id,
14105
+ reply,
14106
+ 14 * 60 * 1e3,
14107
+ () => slackInboundSuperseded(opts)
14108
+ );
14109
+ if (held.interrupted) {
14110
+ await dropProgress(`turn finished ${msg.ts} (deferred reply interrupted)`);
14111
+ return;
14112
+ }
14113
+ reply = held.reply;
14049
14114
  } catch (err) {
14050
14115
  if (slackInboundSuperseded(opts)) {
14051
14116
  await dropProgress(`turn error ${msg.ts} (superseded)`);
@@ -14386,7 +14451,7 @@ async function continueSourceThread(threadId, prompt) {
14386
14451
  await continueOnReply(threadId, prompt);
14387
14452
  return;
14388
14453
  }
14389
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-ZUIU667R.js");
14454
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-CJBYJVD7.js");
14390
14455
  await getOrchestrator2().send(threadId, prompt);
14391
14456
  } catch {
14392
14457
  }
@@ -11005,7 +11005,7 @@ function coordinatorTurnReminder(opts) {
11005
11005
  goal ? `- Goal / title: ${goal}` : null,
11006
11006
  accountDefaultsPlaybookLine(),
11007
11007
  accountContextReminderLine() || null,
11008
- "- 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."
11008
+ "- 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."
11009
11009
  ].filter(Boolean).join("\n");
11010
11010
  }
11011
11011
  function ensureGlobalCoordinatorCwd(opts) {
@@ -11079,6 +11079,7 @@ function coordinatorSystemPrompt(opts) {
11079
11079
  ] : audience === "slack" ? [
11080
11080
  "You are a Sideboard coordinator responding to a Slack DM or @mention via the Sideboard Slack app.",
11081
11081
  "Your reply will be posted back in Slack \u2014 be concise and actionable.",
11082
+ "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.",
11082
11083
  "Sideboard signs the Slack reply with this Mac's destination name (Personal / Work). Do not prefix that name yourself.",
11083
11084
  "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.",
11084
11085
  SLACK_REPLY_FORMATTING
@@ -11139,7 +11140,7 @@ var init_coordinator_prompt = __esm({
11139
11140
  "- 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.",
11140
11141
  "- 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)",
11141
11142
  "- 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.",
11142
- "- 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.",
11143
+ "- 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.",
11143
11144
  "- stop_chat \u2014 force-stop: kill in-flight turn AND clear queued prompts (do not leave stale queue after an interrupt)",
11144
11145
  "- 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.",
11145
11146
  "- 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.",
@@ -20399,6 +20400,57 @@ var init_job_process = __esm({
20399
20400
  }
20400
20401
  });
20401
20402
 
20403
+ // src/orchestrator/deferred-report.ts
20404
+ function looksLikeDeferredDonePromise(text7) {
20405
+ const t = (text7 ?? "").trim();
20406
+ if (!t || t.length > DEFERRED_DONE_MAX_CHARS) return false;
20407
+ const unquoted = t.replace(/`[^`]*`/g, " ").replace(/["“”][^"“”]*["“”]/g, " ").replace(/\s+/g, " ").trim();
20408
+ if (!unquoted) return false;
20409
+ 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(
20410
+ unquoted
20411
+ ) || /\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);
20412
+ }
20413
+ function orchestratorPromisedLaterReport(text7) {
20414
+ if (looksLikeDeferredDonePromise(text7)) return true;
20415
+ const t = (text7 ?? "").trim();
20416
+ if (!t || t.length <= DEFERRED_DONE_MAX_CHARS) return false;
20417
+ const lines = t.split("\n").map((line) => line.trim()).filter(Boolean);
20418
+ const closing = [];
20419
+ let size = 0;
20420
+ for (let i = lines.length - 1; i >= 0; i--) {
20421
+ const line = lines[i];
20422
+ if (closing.length === 0 && line.length > DEFERRED_DONE_MAX_CHARS) {
20423
+ closing.push(line.slice(-DEFERRED_DONE_MAX_CHARS));
20424
+ break;
20425
+ }
20426
+ if (closing.length > 0 && size + line.length + 1 > DEFERRED_DONE_MAX_CHARS) break;
20427
+ closing.unshift(line);
20428
+ size += line.length + 1;
20429
+ if (closing.length >= 4) break;
20430
+ }
20431
+ const slice = closing.join("\n");
20432
+ if (!slice || slice === t) return false;
20433
+ return looksLikeDeferredDonePromise(slice);
20434
+ }
20435
+ function formatOrchestratorDeferredContinuePrompt() {
20436
+ return [
20437
+ "You ended the turn after promising to report later.",
20438
+ "This chat does not resume on its own. Slack and the desktop only see a reply when you finish a turn with the outcome.",
20439
+ "list_chats for the child agents on this orchestration chat.",
20440
+ "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.",
20441
+ "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",
20442
+ "Then reply with what happened. Do not promise a later update.",
20443
+ "If you have not started the work yet, start it in this turn and wait until it finishes before you reply."
20444
+ ].join(" ");
20445
+ }
20446
+ var DEFERRED_DONE_MAX_CHARS;
20447
+ var init_deferred_report = __esm({
20448
+ "src/orchestrator/deferred-report.ts"() {
20449
+ "use strict";
20450
+ DEFERRED_DONE_MAX_CHARS = 480;
20451
+ }
20452
+ });
20453
+
20402
20454
  // src/mcp/wait-for-job.ts
20403
20455
  function mcpWaitForJobTimeoutMs(requested) {
20404
20456
  return mcpWaitForTurnTimeoutMs(requested);
@@ -20445,15 +20497,6 @@ function listRunningDetachedJobs(worktreePath) {
20445
20497
  }
20446
20498
  return running.sort();
20447
20499
  }
20448
- function looksLikeDeferredDonePromise(text7) {
20449
- const t = (text7 ?? "").trim();
20450
- if (!t || t.length > DEFERRED_DONE_MAX_CHARS) return false;
20451
- const unquoted = t.replace(/`[^`]*`/g, " ").replace(/["“”][^"“”]*["“”]/g, " ").replace(/\s+/g, " ").trim();
20452
- if (!unquoted) return false;
20453
- 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(
20454
- unquoted
20455
- ) || /\bi(?:['’]ll| will)\s+come back when\b/i.test(unquoted);
20456
- }
20457
20500
  function isJobContinuePrompt(text7) {
20458
20501
  if (typeof text7 !== "string") return false;
20459
20502
  const t = text7.trim();
@@ -20508,10 +20551,15 @@ function turnWatchedDetachedJob(parts) {
20508
20551
  });
20509
20552
  }
20510
20553
  function planJobContinue(opts) {
20511
- if (opts.isOrchestrator) return { action: "none" };
20512
20554
  if (opts.agent === "brightsy") return { action: "none" };
20513
20555
  if (opts.queueLength > 0) return { action: "none" };
20514
20556
  if (opts.continueCount >= MAX_JOB_CONTINUES) return { action: "none" };
20557
+ if (opts.isOrchestrator) {
20558
+ if (orchestratorPromisedLaterReport(opts.chatText) && !opts.alreadyNudged) {
20559
+ return { action: "nudge", prompt: formatOrchestratorDeferredContinuePrompt() };
20560
+ }
20561
+ return { action: "none" };
20562
+ }
20515
20563
  const farewell = looksLikeDeferredDonePromise(opts.chatText);
20516
20564
  if (opts.runningJobIds.length > 0 && (farewell || opts.watchedJob)) {
20517
20565
  return {
@@ -20712,7 +20760,7 @@ async function stopDetachedJob(cwd, id, opts) {
20712
20760
  hint: stopped ? MCP_STOP_JOB_HINT : MCP_WAIT_JOB_STILL_RUNNING_HINT
20713
20761
  };
20714
20762
  }
20715
- var import_node_fs50, import_node_path51, 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;
20763
+ var import_node_fs50, import_node_path51, 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;
20716
20764
  var init_wait_for_job = __esm({
20717
20765
  "src/mcp/wait-for-job.ts"() {
20718
20766
  "use strict";
@@ -20721,10 +20769,11 @@ var init_wait_for_job = __esm({
20721
20769
  init_workspace_scratch();
20722
20770
  init_job_process();
20723
20771
  init_wait_for_turn();
20772
+ init_deferred_report();
20773
+ init_deferred_report();
20724
20774
  MAX_JOB_CONTINUES = 8;
20725
20775
  MAX_JOB_DELTA_LINES = 80;
20726
20776
  MAX_JOB_DELTA_CHARS = 4e3;
20727
- DEFERRED_DONE_MAX_CHARS = 480;
20728
20777
  GH_WATCH_REFRESH = "Refreshing run status every 3 seconds.";
20729
20778
  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.";
20730
20779
  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.";
@@ -22761,6 +22810,79 @@ var init_child_halt = __esm({
22761
22810
  }
22762
22811
  });
22763
22812
 
22813
+ // src/orchestrator/child-report.ts
22814
+ function clearParentReportWake(parentId) {
22815
+ wakesByParent.delete(parentId);
22816
+ const prefix = `${parentId}:`;
22817
+ for (const key of sentForReply) {
22818
+ if (key.startsWith(prefix)) sentForReply.delete(key);
22819
+ }
22820
+ }
22821
+ function parentOwesDeferredReport(parent) {
22822
+ if (!parent || parent.status === "archived") return false;
22823
+ if (!isOrchestratorThread(parent)) return false;
22824
+ if (parent.status !== "idle") return false;
22825
+ if (parent.queue.length > 0) return false;
22826
+ const last = lastAgentReply(parent.messages);
22827
+ return orchestratorPromisedLaterReport(last?.text);
22828
+ }
22829
+ function childFinishedReportPrompt(child) {
22830
+ const title = child.title?.trim() || "Untitled";
22831
+ const link = `[${title}](sideboard://chat/${child.id})`;
22832
+ return [
22833
+ `Sideboard: child worktree ${link} finished (status=idle).`,
22834
+ "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.",
22835
+ "Read get_turn_result for this child and any siblings. If any are still running (stillRunning true), loop wait_for_turn until they finish.",
22836
+ "Then reply with the outcome. Do not promise a later update.",
22837
+ "This is information \u2014 not a new user request."
22838
+ ].join("\n");
22839
+ }
22840
+ function replyKey(parent) {
22841
+ const last = lastAgentReply(parent.messages);
22842
+ if (!last) return null;
22843
+ return `${parent.id}:${last.ts}`;
22844
+ }
22845
+ function notifyParentOfChildReport(child, send) {
22846
+ if (!child.parentThreadId) return false;
22847
+ const parent = readThread(child.parentThreadId);
22848
+ if (!parentOwesDeferredReport(parent)) return false;
22849
+ const key = replyKey(parent);
22850
+ if (!key || sentForReply.has(key)) return false;
22851
+ const wakes = wakesByParent.get(parent.id) ?? 0;
22852
+ if (wakes >= MAX_REPORT_WAKES) return false;
22853
+ sentForReply.add(key);
22854
+ wakesByParent.set(parent.id, wakes + 1);
22855
+ const parentId = parent.id;
22856
+ void send(parentId, childFinishedReportPrompt(child)).catch(() => {
22857
+ sentForReply.delete(key);
22858
+ const current = wakesByParent.get(parentId) ?? 1;
22859
+ if (current <= 1) wakesByParent.delete(parentId);
22860
+ else wakesByParent.set(parentId, current - 1);
22861
+ });
22862
+ return true;
22863
+ }
22864
+ function settleChildReportAfterTurn(thread, chatText, send) {
22865
+ if (!thread) return;
22866
+ if (isOrchestratorThread(thread)) {
22867
+ if (!orchestratorPromisedLaterReport(chatText)) clearParentReportWake(thread.id);
22868
+ return;
22869
+ }
22870
+ notifyParentOfChildReport(thread, send);
22871
+ }
22872
+ var MAX_REPORT_WAKES, sentForReply, wakesByParent;
22873
+ var init_child_report = __esm({
22874
+ "src/orchestrator/child-report.ts"() {
22875
+ "use strict";
22876
+ init_wait_for_job();
22877
+ init_global_workspace();
22878
+ init_thread_store();
22879
+ init_injected_notices();
22880
+ MAX_REPORT_WAKES = 2;
22881
+ sentForReply = /* @__PURE__ */ new Set();
22882
+ wakesByParent = /* @__PURE__ */ new Map();
22883
+ }
22884
+ });
22885
+
22764
22886
  // src/orchestrator/stop-reason.ts
22765
22887
  function resolveStopReason(opts) {
22766
22888
  const explicit = opts?.reason?.trim();
@@ -30269,6 +30391,7 @@ var init_orchestrator = __esm({
30269
30391
  init_model_context();
30270
30392
  init_agent_block();
30271
30393
  init_child_halt();
30394
+ init_child_report();
30272
30395
  init_stop_reason();
30273
30396
  init_steer_request();
30274
30397
  init_ephemeral_automation();
@@ -30817,11 +30940,7 @@ var init_orchestrator = __esm({
30817
30940
  this.emit({ type: "queue_changed", threadId, queue: next.queue });
30818
30941
  this.haltDrain.delete(threadId);
30819
30942
  }
30820
- /**
30821
- * Worktree agent ended the turn after “I’ll let you know” (or left a
30822
- * detached test/pack job running). Queue a continue so the chat does not
30823
- * go idle with nobody watching the log.
30824
- */
30943
+ /** Queue a continue when a turn promised a later report or left a detached job running. */
30825
30944
  maybeEnqueueJobContinue(threadId, chatText, parts = []) {
30826
30945
  if (this.haltDrain.has(threadId)) return;
30827
30946
  const thread = readThread(threadId);
@@ -31218,7 +31337,7 @@ var init_orchestrator = __esm({
31218
31337
  goal: thread.sourceRef || thread.title
31219
31338
  }),
31220
31339
  slackInbound ? [
31221
- "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.",
31340
+ "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.",
31222
31341
  SLACK_REPLY_FORMATTING
31223
31342
  ].join("\n") : null
31224
31343
  ].filter(Boolean).join("\n") : null;
@@ -31625,6 +31744,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
31625
31744
  if (exitCode === 0) {
31626
31745
  this.crashContinued.delete(threadId);
31627
31746
  this.maybeEnqueueJobContinue(threadId, chatText, parts);
31747
+ settleChildReportAfterTurn(readThread(threadId), chatText, (id, prompt2) => this.send(id, prompt2));
31628
31748
  } else {
31629
31749
  const blob = [chatText, detail].filter(Boolean).join("\n");
31630
31750
  const failedOver = await isolateQuotaFailover(
@@ -45,7 +45,7 @@ import {
45
45
  syncBoardPins,
46
46
  workspaceTagTargetRef,
47
47
  writeAgentBlock
48
- } from "../chunk-PSXBOMXI.js";
48
+ } from "../chunk-UPZD4SYD.js";
49
49
  import "../chunk-DC3VZXMA.js";
50
50
  import {
51
51
  SIDEBOARD_THREAD_ID_ENV,
@@ -55,7 +55,7 @@ import {
55
55
  shouldRegisterMcpWaitForTurn,
56
56
  sideboardMcpProfile,
57
57
  worktreeMcpToolNames
58
- } from "../chunk-54GBJC6J.js";
58
+ } from "../chunk-X3W3HBLK.js";
59
59
  import {
60
60
  mcpWaitForJobTimeoutMs,
61
61
  mcpWaitForTurnTimeoutMs,
@@ -66,7 +66,7 @@ import {
66
66
  waitForDetachedJob,
67
67
  waitForTurnToolResult,
68
68
  workspaceAgentChatSummaries
69
- } from "../chunk-4O7436ZH.js";
69
+ } from "../chunk-QJGAWDAX.js";
70
70
  import {
71
71
  HUGE_TOOL_RESULT_SUMMARY,
72
72
  clipToolResultForStore,
@@ -103,7 +103,7 @@ import {
103
103
  import {
104
104
  GLOBAL_WORKSPACE_ID,
105
105
  isCloudCoordinatorThread
106
- } from "../chunk-MGEUXR6E.js";
106
+ } from "../chunk-BR3C3EX5.js";
107
107
  import {
108
108
  canonicalizeRepoPath,
109
109
  formatGhLandError,
@@ -9,18 +9,18 @@ import {
9
9
  resolveSendFollowUp,
10
10
  startOrchestration,
11
11
  waitForPidExit
12
- } from "./chunk-EKI7D2AJ.js";
12
+ } from "./chunk-JGJIR66Z.js";
13
13
  import "./chunk-QWFNKOGA.js";
14
14
  import "./chunk-PGPSIEMW.js";
15
15
  import "./chunk-W3ZLE4PO.js";
16
- import "./chunk-NB4U75TJ.js";
16
+ import "./chunk-LJESHMFJ.js";
17
17
  import "./chunk-5FGQTB2Z.js";
18
18
  import "./chunk-XOEKCE6L.js";
19
19
  import "./chunk-KAIOL2M5.js";
20
- import "./chunk-B6TPN624.js";
20
+ import "./chunk-2QN74PVY.js";
21
21
  import "./chunk-OOXRMTU6.js";
22
22
  import "./chunk-7H655NEW.js";
23
- import "./chunk-CDRGQ6GX.js";
23
+ import "./chunk-T76WCIQN.js";
24
24
  import "./chunk-4OVQGZEI.js";
25
25
  import "./chunk-BDQFZAE6.js";
26
26
  import "./chunk-BMRJNRQK.js";
@@ -11,16 +11,16 @@ import {
11
11
  resolveSendFollowUp,
12
12
  startOrchestration,
13
13
  waitForPidExit
14
- } from "./chunk-PSXBOMXI.js";
14
+ } from "./chunk-UPZD4SYD.js";
15
15
  import "./chunk-DC3VZXMA.js";
16
- import "./chunk-54GBJC6J.js";
17
- import "./chunk-4O7436ZH.js";
16
+ import "./chunk-X3W3HBLK.js";
17
+ import "./chunk-QJGAWDAX.js";
18
18
  import "./chunk-5MXLDDYF.js";
19
19
  import "./chunk-LX5R5JOR.js";
20
20
  import "./chunk-5TVRPOVS.js";
21
21
  import "./chunk-HNW5KMGK.js";
22
22
  import "./chunk-4GK32AYX.js";
23
- import "./chunk-MGEUXR6E.js";
23
+ import "./chunk-BR3C3EX5.js";
24
24
  import "./chunk-ERCYQTJU.js";
25
25
  import "./chunk-I6RGRUNY.js";
26
26
  import "./chunk-E63AM3PW.js";
@@ -11,7 +11,7 @@ import {
11
11
  removeWorkspace,
12
12
  sameWorkspacePath,
13
13
  syncWorkspacesFromThreads
14
- } from "./chunk-MGEUXR6E.js";
14
+ } from "./chunk-BR3C3EX5.js";
15
15
  import "./chunk-ERCYQTJU.js";
16
16
  import "./chunk-N2WW62LF.js";
17
17
  import "./chunk-GK7H3SY7.js";
@@ -9,7 +9,7 @@ import {
9
9
  removeWorkspace,
10
10
  sameWorkspacePath,
11
11
  syncWorkspacesFromThreads
12
- } from "./chunk-CDRGQ6GX.js";
12
+ } from "./chunk-T76WCIQN.js";
13
13
  import "./chunk-4OVQGZEI.js";
14
14
  import "./chunk-BDQFZAE6.js";
15
15
  import "./chunk-BMRJNRQK.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sideboard-ai/core",
3
- "version": "0.1.337",
3
+ "version": "0.1.338",
4
4
  "description": "Sideboard core — orchestration, agents, git worktrees, MCP server",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",