@sideboard-ai/core 0.1.310 → 0.1.312

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.
@@ -27,10 +27,11 @@ import {
27
27
  parseSessionQuotaResetAt,
28
28
  planModeTurnInstruction,
29
29
  resolveQuotaFallbackAgent
30
- } from "./chunk-GQJOLTZU.js";
30
+ } from "./chunk-2P2HYXA2.js";
31
31
  import {
32
32
  REVIEW_TAB_TITLE,
33
33
  applyWorktreePkgCacheEnv,
34
+ askBlockStillWaiting,
34
35
  buildBrightsySessionSeed,
35
36
  buildForkTranscriptAttachment,
36
37
  buildSessionSeed,
@@ -68,7 +69,7 @@ import {
68
69
  worktreeDevProcessKey,
69
70
  worktreeRunProcessKey,
70
71
  worktreeSetupProcessKey
71
- } from "./chunk-AILQRQ26.js";
72
+ } from "./chunk-ZW7RSQHY.js";
72
73
  import {
73
74
  applyAgentEvent,
74
75
  clipAgentEventForPaint,
@@ -1499,6 +1500,15 @@ function thisProcessShouldDrainAgentQueues() {
1499
1500
  return !isDesktopHostAlive();
1500
1501
  }
1501
1502
 
1503
+ // src/mcp-ui/model-context.ts
1504
+ function takeMcpAppModelContext(threadId) {
1505
+ const thread = readThread(threadId);
1506
+ const text3 = thread?.mcpAppModelContext?.trim();
1507
+ if (!text3) return void 0;
1508
+ updateThread(threadId, { mcpAppModelContext: null });
1509
+ return text3;
1510
+ }
1511
+
1502
1512
  // src/agents/tool-permission.ts
1503
1513
  import { randomUUID } from "crypto";
1504
1514
  import { dirname } from "path";
@@ -1546,6 +1556,11 @@ function visibleAgentBlock(thread) {
1546
1556
  const block = thread.agentBlock;
1547
1557
  if (!block?.reason?.trim()) return null;
1548
1558
  if (isDismissedAskUserBlock(block, thread.dismissedQuestionSignature)) return null;
1559
+ if (block.source === "ask_user") {
1560
+ const inFlight = thread.status === "running" || thread.status === "queued";
1561
+ if (inFlight && !block.onScreen) return null;
1562
+ if (!askBlockStillWaiting(block, thread.messages)) return null;
1563
+ }
1549
1564
  return block;
1550
1565
  }
1551
1566
  function worktreeAgentBlock(group) {
@@ -1703,6 +1718,7 @@ function decisionBlockFromParts(parts, planMode, at = (/* @__PURE__ */ new Date(
1703
1718
  const reason = pending ? formatAskUserNotifyMessage(pending.questions) : "Waiting for an answer in that chat.";
1704
1719
  return {
1705
1720
  ...makeAgentBlock("ask_user", reason, at),
1721
+ onScreen: true,
1706
1722
  ...pending ? { questionSignature: pending.signature, questions: pending.questions } : {}
1707
1723
  };
1708
1724
  }
@@ -1760,6 +1776,38 @@ function dismissAskUserQuestion(threadId, signature) {
1760
1776
  ...clearBlock ? { agentBlock: null } : {}
1761
1777
  });
1762
1778
  }
1779
+ function askBlocksEqual(a, b) {
1780
+ if (a === b) return true;
1781
+ if (!a || !b) return false;
1782
+ return a.source === b.source && a.reason === b.reason && a.at === b.at && a.onScreen === b.onScreen && a.questionSignature === b.questionSignature;
1783
+ }
1784
+ function askBlockAfterLiveParts(existing, parts) {
1785
+ const last = lastTopLevelTool(parts);
1786
+ if (last?.type === "tool" && isAskUserToolName(last.name)) {
1787
+ if (existing?.source === "ask_user" && existing.onScreen) return existing;
1788
+ const pending = extractPendingPlanQuestions(parts);
1789
+ const questions = pending?.questions ?? existing?.questions;
1790
+ if (!questions?.length) {
1791
+ return existing?.source === "ask_user" ? { ...existing, onScreen: true } : existing ?? null;
1792
+ }
1793
+ const at = existing?.source === "ask_user" ? existing.at : void 0;
1794
+ return {
1795
+ ...makeAgentBlock("ask_user", formatAskUserNotifyMessage(questions), at),
1796
+ onScreen: true,
1797
+ questionSignature: pending?.signature ?? existing?.questionSignature,
1798
+ questions
1799
+ };
1800
+ }
1801
+ if (last && existing?.source === "ask_user") return null;
1802
+ return existing ?? null;
1803
+ }
1804
+ function syncAskUserBlockFromLive(threadId, parts) {
1805
+ const thread = readThread(threadId);
1806
+ if (!thread || thread.status === "archived") return;
1807
+ const next = askBlockAfterLiveParts(thread.agentBlock, parts);
1808
+ if (askBlocksEqual(thread.agentBlock, next)) return;
1809
+ updateThread(threadId, { agentBlock: next });
1810
+ }
1763
1811
  function writeAgentBlock(threadId, block) {
1764
1812
  const thread = readThread(threadId);
1765
1813
  if (!thread || thread.status === "archived") return;
@@ -3117,6 +3165,7 @@ function noteTurnLiveEvent(threadId, event) {
3117
3165
  const prev = buffers.get(threadId) ?? { parts: [], timer: null };
3118
3166
  prev.parts = trimParts(applyAgentEvent(prev.parts, event));
3119
3167
  buffers.set(threadId, prev);
3168
+ syncAskUserBlockFromLive(threadId, prev.parts);
3120
3169
  if (event.type === "exit") {
3121
3170
  flush(threadId);
3122
3171
  const cur = buffers.get(threadId);
@@ -6389,7 +6438,7 @@ function formatScheduledPrompt(name, prompt) {
6389
6438
  ${prompt}`;
6390
6439
  }
6391
6440
  async function defaultDeps() {
6392
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-7374OI7T.js");
6441
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-S44BMNN7.js");
6393
6442
  const orch = getOrchestrator2();
6394
6443
  return {
6395
6444
  findThread: (id) => findThreadByRef(id),
@@ -7476,6 +7525,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
7476
7525
  orchestrationReminder,
7477
7526
  prGateDirective,
7478
7527
  injectedNoticeContext,
7528
+ takeMcpAppModelContext(threadId),
7479
7529
  expandedPrompt
7480
7530
  ].filter(Boolean).join("\n\n");
7481
7531
  if (!autoContinue && sentAttachments) {
@@ -1288,6 +1288,19 @@ function isAskUserToolName(name) {
1288
1288
  const base = name.replace(/^mcp__sideboard__/i, "");
1289
1289
  return ASK_USER_TOOL_RE.test(name) || /^ask_user$/i.test(base);
1290
1290
  }
1291
+ function lastTopLevelToolIsAskUser(parts) {
1292
+ if (!parts?.length) return false;
1293
+ for (let i = parts.length - 1; i >= 0; i--) {
1294
+ const part = parts[i];
1295
+ if (part.type === "tool" && !part.parentId) {
1296
+ return isAskUserToolName(part.name);
1297
+ }
1298
+ }
1299
+ return false;
1300
+ }
1301
+ function hasTopLevelTool(parts) {
1302
+ return Boolean(parts?.some((part) => part.type === "tool" && !part.parentId));
1303
+ }
1291
1304
  function questionsFromToolPart(part) {
1292
1305
  const fromInput = parsePlanQuestionsInput(part.input);
1293
1306
  if (fromInput.length) return fromInput;
@@ -1330,6 +1343,7 @@ function pendingFromAskBlock(block, dismissedQuestionSignature) {
1330
1343
  };
1331
1344
  }
1332
1345
  function askBlockStillWaiting(block, messages) {
1346
+ if (!messages?.length) return Boolean(block?.at);
1333
1347
  const askedAt = block?.at;
1334
1348
  if (!askedAt) return false;
1335
1349
  for (let i = messages.length - 1; i >= 0; i--) {
@@ -1342,19 +1356,21 @@ function askBlockStillWaiting(block, messages) {
1342
1356
  }
1343
1357
  function latestPendingPlanQuestions(input) {
1344
1358
  if (input.userReplied) return null;
1345
- const fromLive = extractPendingPlanQuestions(input.liveParts);
1346
- if (fromLive) return fromLive;
1359
+ const fromBlock = () => pendingFromAskBlock(input.agentBlock, input.dismissedQuestionSignature);
1360
+ if (lastTopLevelToolIsAskUser(input.liveParts)) {
1361
+ return extractPendingPlanQuestions(input.liveParts) ?? fromBlock();
1362
+ }
1347
1363
  const last = input.messages[input.messages.length - 1];
1348
- if (last?.role === "agent") {
1349
- const fromParts = extractPendingPlanQuestions(last.parts);
1350
- if (fromParts) return fromParts;
1364
+ if (last?.role === "agent" && lastTopLevelToolIsAskUser(last.parts)) {
1365
+ return extractPendingPlanQuestions(last.parts) ?? fromBlock();
1351
1366
  }
1352
- const fromBlock = pendingFromAskBlock(
1353
- input.agentBlock,
1354
- input.dismissedQuestionSignature
1355
- );
1356
- if (fromBlock && askBlockStillWaiting(input.agentBlock, input.messages)) {
1357
- return fromBlock;
1367
+ if (hasTopLevelTool(input.liveParts) || last?.role === "agent" && hasTopLevelTool(last.parts)) {
1368
+ return null;
1369
+ }
1370
+ if (input.status === "running" || input.status === "queued") return null;
1371
+ const stamped = fromBlock();
1372
+ if (stamped && askBlockStillWaiting(input.agentBlock, input.messages)) {
1373
+ return stamped;
1358
1374
  }
1359
1375
  return null;
1360
1376
  }
@@ -1407,14 +1423,7 @@ function needsCoordinatorAction(state) {
1407
1423
  return isIncompleteTaskState(state) || state === "input-required";
1408
1424
  }
1409
1425
  function endedOnAskUser(parts) {
1410
- if (!parts?.length) return false;
1411
- for (let i = parts.length - 1; i >= 0; i--) {
1412
- const p = parts[i];
1413
- if (p.type === "tool" && !p.parentId) {
1414
- return isAskUserToolName(p.name);
1415
- }
1416
- }
1417
- return false;
1426
+ return lastTopLevelToolIsAskUser(parts);
1418
1427
  }
1419
1428
  function deriveTaskState(input) {
1420
1429
  if (input.stillRunning) {
@@ -1823,7 +1832,7 @@ var PORT_RANGE_SIZE = 10;
1823
1832
  var RECLAIM_RETRY_DELAY_MS = 40;
1824
1833
  var RECLAIM_TRIES = 8;
1825
1834
  async function killReclaimable(ports, worktreePath, signal) {
1826
- const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-OFXA5BST.js");
1835
+ const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-YOBSYPLT.js");
1827
1836
  if (worktreePath) killStaleWorktreeListeners2(ports, worktreePath, signal);
1828
1837
  else killListenersOnPorts2(ports);
1829
1838
  }
@@ -2507,7 +2516,9 @@ export {
2507
2516
  planQuestionsSignature,
2508
2517
  parsePlanQuestionsInput,
2509
2518
  isAskUserToolName,
2519
+ lastTopLevelToolIsAskUser,
2510
2520
  extractPendingPlanQuestions,
2521
+ askBlockStillWaiting,
2511
2522
  latestPendingPlanQuestions,
2512
2523
  PLAN_QUESTION_ANSWERS_PREFIX,
2513
2524
  isPlanQuestionAnswersMessage,
@@ -14,10 +14,11 @@ import {
14
14
  parseSessionQuotaResetAt,
15
15
  planModeTurnInstruction,
16
16
  resolveQuotaFallbackAgent
17
- } from "./chunk-4YBQBVYL.js";
17
+ } from "./chunk-4FZUUH6W.js";
18
18
  import {
19
19
  REVIEW_TAB_TITLE,
20
20
  applyWorktreePkgCacheEnv,
21
+ askBlockStillWaiting,
21
22
  buildBrightsySessionSeed,
22
23
  buildForkTranscriptAttachment,
23
24
  buildSessionSeed,
@@ -55,7 +56,7 @@ import {
55
56
  worktreeDevProcessKey,
56
57
  worktreeRunProcessKey,
57
58
  worktreeSetupProcessKey
58
- } from "./chunk-VBVSJUM2.js";
59
+ } from "./chunk-QC2TQMPJ.js";
59
60
  import {
60
61
  applyAgentEvent,
61
62
  clipAgentEventForPaint,
@@ -1484,6 +1485,20 @@ function thisProcessShouldDrainAgentQueues() {
1484
1485
  return !isDesktopHostAlive();
1485
1486
  }
1486
1487
 
1488
+ // src/mcp-ui/model-context.ts
1489
+ function stashMcpAppModelContext(threadId, text3) {
1490
+ const body = text3.trim().slice(0, 8e3);
1491
+ if (!body) return;
1492
+ updateThread(threadId, { mcpAppModelContext: body });
1493
+ }
1494
+ function takeMcpAppModelContext(threadId) {
1495
+ const thread = readThread(threadId);
1496
+ const text3 = thread?.mcpAppModelContext?.trim();
1497
+ if (!text3) return void 0;
1498
+ updateThread(threadId, { mcpAppModelContext: null });
1499
+ return text3;
1500
+ }
1501
+
1487
1502
  // src/agents/tool-permission.ts
1488
1503
  import { randomUUID } from "crypto";
1489
1504
  import { dirname } from "path";
@@ -1643,6 +1658,11 @@ function visibleAgentBlock(thread) {
1643
1658
  const block = thread.agentBlock;
1644
1659
  if (!block?.reason?.trim()) return null;
1645
1660
  if (isDismissedAskUserBlock(block, thread.dismissedQuestionSignature)) return null;
1661
+ if (block.source === "ask_user") {
1662
+ const inFlight = thread.status === "running" || thread.status === "queued";
1663
+ if (inFlight && !block.onScreen) return null;
1664
+ if (!askBlockStillWaiting(block, thread.messages)) return null;
1665
+ }
1646
1666
  return block;
1647
1667
  }
1648
1668
  function worktreeAgentBlock(group) {
@@ -1817,6 +1837,7 @@ function decisionBlockFromParts(parts, planMode, at = (/* @__PURE__ */ new Date(
1817
1837
  const reason = pending ? formatAskUserNotifyMessage(pending.questions) : "Waiting for an answer in that chat.";
1818
1838
  return {
1819
1839
  ...makeAgentBlock("ask_user", reason, at),
1840
+ onScreen: true,
1820
1841
  ...pending ? { questionSignature: pending.signature, questions: pending.questions } : {}
1821
1842
  };
1822
1843
  }
@@ -1874,6 +1895,38 @@ function dismissAskUserQuestion(threadId, signature) {
1874
1895
  ...clearBlock ? { agentBlock: null } : {}
1875
1896
  });
1876
1897
  }
1898
+ function askBlocksEqual(a, b) {
1899
+ if (a === b) return true;
1900
+ if (!a || !b) return false;
1901
+ return a.source === b.source && a.reason === b.reason && a.at === b.at && a.onScreen === b.onScreen && a.questionSignature === b.questionSignature;
1902
+ }
1903
+ function askBlockAfterLiveParts(existing, parts) {
1904
+ const last = lastTopLevelTool(parts);
1905
+ if (last?.type === "tool" && isAskUserToolName(last.name)) {
1906
+ if (existing?.source === "ask_user" && existing.onScreen) return existing;
1907
+ const pending = extractPendingPlanQuestions(parts);
1908
+ const questions = pending?.questions ?? existing?.questions;
1909
+ if (!questions?.length) {
1910
+ return existing?.source === "ask_user" ? { ...existing, onScreen: true } : existing ?? null;
1911
+ }
1912
+ const at = existing?.source === "ask_user" ? existing.at : void 0;
1913
+ return {
1914
+ ...makeAgentBlock("ask_user", formatAskUserNotifyMessage(questions), at),
1915
+ onScreen: true,
1916
+ questionSignature: pending?.signature ?? existing?.questionSignature,
1917
+ questions
1918
+ };
1919
+ }
1920
+ if (last && existing?.source === "ask_user") return null;
1921
+ return existing ?? null;
1922
+ }
1923
+ function syncAskUserBlockFromLive(threadId, parts) {
1924
+ const thread = readThread(threadId);
1925
+ if (!thread || thread.status === "archived") return;
1926
+ const next = askBlockAfterLiveParts(thread.agentBlock, parts);
1927
+ if (askBlocksEqual(thread.agentBlock, next)) return;
1928
+ updateThread(threadId, { agentBlock: next });
1929
+ }
1877
1930
  function writeAgentBlock(threadId, block) {
1878
1931
  const thread = readThread(threadId);
1879
1932
  if (!thread || thread.status === "archived") return;
@@ -3027,7 +3080,7 @@ async function createThread(input, _onSetupLine) {
3027
3080
  return readThread(thread.id) ?? thread;
3028
3081
  }
3029
3082
  async function listLinearIssues(agent, repoPath) {
3030
- const { getAdapter: getAdapter2 } = await import("./agents-XXXRQJJO.js");
3083
+ const { getAdapter: getAdapter2 } = await import("./agents-IOJRGGK3.js");
3031
3084
  await requireAgent(agent, { requireLinear: true });
3032
3085
  const adapter = getAdapter2(agent);
3033
3086
  if (!adapter.listLinearIssues) {
@@ -3419,6 +3472,7 @@ function noteTurnLiveEvent(threadId, event) {
3419
3472
  const prev = buffers.get(threadId) ?? { parts: [], timer: null };
3420
3473
  prev.parts = trimParts(applyAgentEvent(prev.parts, event));
3421
3474
  buffers.set(threadId, prev);
3475
+ syncAskUserBlockFromLive(threadId, prev.parts);
3422
3476
  if (event.type === "exit") {
3423
3477
  flush(threadId);
3424
3478
  const cur = buffers.get(threadId);
@@ -6741,7 +6795,7 @@ function formatScheduledPrompt(name, prompt) {
6741
6795
  ${prompt}`;
6742
6796
  }
6743
6797
  async function defaultDeps() {
6744
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-XFE3U3RP.js");
6798
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-BYTSILLH.js");
6745
6799
  const orch = getOrchestrator2();
6746
6800
  return {
6747
6801
  findThread: (id) => findThreadByRef(id),
@@ -7828,6 +7882,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
7828
7882
  orchestrationReminder,
7829
7883
  prGateDirective,
7830
7884
  injectedNoticeContext,
7885
+ takeMcpAppModelContext(threadId),
7831
7886
  expandedPrompt
7832
7887
  ].filter(Boolean).join("\n\n");
7833
7888
  if (!autoContinue && sentAttachments) {
@@ -9724,6 +9779,7 @@ export {
9724
9779
  shouldRunHistoryCleanup,
9725
9780
  applyThreadIntoMain,
9726
9781
  cloneRepoIntoSideboard,
9782
+ stashMcpAppModelContext,
9727
9783
  connectedOrchestrator,
9728
9784
  formatAskUserNotifyMessage,
9729
9785
  formatNotifyOrchestratorPrompt,
@@ -1235,6 +1235,16 @@ function isAskUserToolName(name) {
1235
1235
  const base = name.replace(/^mcp__sideboard__/i, "");
1236
1236
  return ASK_USER_TOOL_RE.test(name) || /^ask_user$/i.test(base);
1237
1237
  }
1238
+ function lastTopLevelToolIsAskUser(parts) {
1239
+ if (!parts?.length) return false;
1240
+ for (let i = parts.length - 1; i >= 0; i--) {
1241
+ const part = parts[i];
1242
+ if (part.type === "tool" && !part.parentId) {
1243
+ return isAskUserToolName(part.name);
1244
+ }
1245
+ }
1246
+ return false;
1247
+ }
1238
1248
  function questionsFromToolPart(part) {
1239
1249
  const fromInput = parsePlanQuestionsInput(part.input);
1240
1250
  if (fromInput.length) return fromInput;
@@ -1262,6 +1272,18 @@ function extractPendingPlanQuestions(parts) {
1262
1272
  }
1263
1273
  return null;
1264
1274
  }
1275
+ function askBlockStillWaiting(block, messages) {
1276
+ if (!messages?.length) return Boolean(block?.at);
1277
+ const askedAt = block?.at;
1278
+ if (!askedAt) return false;
1279
+ for (let i = messages.length - 1; i >= 0; i--) {
1280
+ const message = messages[i];
1281
+ if (message.role !== "user" || message.origin === "continue") continue;
1282
+ if (!message.ts) return true;
1283
+ return askedAt > message.ts;
1284
+ }
1285
+ return true;
1286
+ }
1265
1287
 
1266
1288
  // src/orchestrator/task-state.ts
1267
1289
  function isIncompleteTaskState(state) {
@@ -1271,14 +1293,7 @@ function needsCoordinatorAction(state) {
1271
1293
  return isIncompleteTaskState(state) || state === "input-required";
1272
1294
  }
1273
1295
  function endedOnAskUser(parts) {
1274
- if (!parts?.length) return false;
1275
- for (let i = parts.length - 1; i >= 0; i--) {
1276
- const p = parts[i];
1277
- if (p.type === "tool" && !p.parentId) {
1278
- return isAskUserToolName(p.name);
1279
- }
1280
- }
1281
- return false;
1296
+ return lastTopLevelToolIsAskUser(parts);
1282
1297
  }
1283
1298
  function deriveTaskState(input) {
1284
1299
  if (input.stillRunning) {
@@ -1687,7 +1702,7 @@ var PORT_RANGE_SIZE = 10;
1687
1702
  var RECLAIM_RETRY_DELAY_MS = 40;
1688
1703
  var RECLAIM_TRIES = 8;
1689
1704
  async function killReclaimable(ports, worktreePath, signal) {
1690
- const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-AMZ5SKG2.js");
1705
+ const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-CTWR6NH4.js");
1691
1706
  if (worktreePath) killStaleWorktreeListeners2(ports, worktreePath, signal);
1692
1707
  else killListenersOnPorts2(ports);
1693
1708
  }
@@ -2372,6 +2387,7 @@ export {
2372
2387
  parsePlanQuestionsInput,
2373
2388
  isAskUserToolName,
2374
2389
  extractPendingPlanQuestions,
2390
+ askBlockStillWaiting,
2375
2391
  needsCoordinatorAction,
2376
2392
  deriveTaskState,
2377
2393
  mcpWaitForTurnTimeoutMs,
@@ -34,7 +34,7 @@ import {
34
34
  tryReservePort,
35
35
  tryReservePorts,
36
36
  worktreeRunPortsPath
37
- } from "./chunk-AILQRQ26.js";
37
+ } from "./chunk-ZW7RSQHY.js";
38
38
  import "./chunk-I5TESHDN.js";
39
39
  import "./chunk-X3FSWWW2.js";
40
40
  import "./chunk-DLGGLV2M.js";
@@ -32,7 +32,7 @@ import {
32
32
  tryReservePort,
33
33
  tryReservePorts,
34
34
  worktreeRunPortsPath
35
- } from "./chunk-VBVSJUM2.js";
35
+ } from "./chunk-QC2TQMPJ.js";
36
36
  import "./chunk-7Q327QF2.js";
37
37
  import "./chunk-5QX2NYXL.js";
38
38
  import "./chunk-BIPXOHZI.js";