@sideboard-ai/core 0.1.196 → 0.1.197

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.
@@ -9341,6 +9341,11 @@ function parseDiffStat(result) {
9341
9341
  }
9342
9342
  return {};
9343
9343
  }
9344
+ function clipThinkingForStore(text7, max = THINKING_PART_MAX_CHARS) {
9345
+ if (text7.length <= max) return text7;
9346
+ const marker = "\u2026(earlier thinking trimmed)\n";
9347
+ return marker + text7.slice(text7.length - Math.max(1, max - marker.length));
9348
+ }
9344
9349
  function withPartTimes(next, prev) {
9345
9350
  const now = Date.now();
9346
9351
  const startedAt = prev && typeof prev.startedAt === "number" ? prev.startedAt : now;
@@ -9383,7 +9388,7 @@ function applyAgentEvent(parts, event) {
9383
9388
  next[i] = withPartTimes(
9384
9389
  {
9385
9390
  type: "thinking",
9386
- text: data,
9391
+ text: clipThinkingForStore(data),
9387
9392
  ...event.parentId ? { parentId: event.parentId } : {}
9388
9393
  },
9389
9394
  prev
@@ -9394,7 +9399,7 @@ function applyAgentEvent(parts, event) {
9394
9399
  next.push(
9395
9400
  withPartTimes({
9396
9401
  type: "thinking",
9397
- text: data,
9402
+ text: clipThinkingForStore(data),
9398
9403
  ...event.parentId ? { parentId: event.parentId } : {}
9399
9404
  })
9400
9405
  );
@@ -9405,7 +9410,7 @@ function applyAgentEvent(parts, event) {
9405
9410
  next[next.length - 1] = withPartTimes(
9406
9411
  {
9407
9412
  type: "thinking",
9408
- text: last.text + data,
9413
+ text: clipThinkingForStore(last.text + data),
9409
9414
  ...event.parentId ? { parentId: event.parentId } : {}
9410
9415
  },
9411
9416
  last
@@ -9556,12 +9561,13 @@ function normalizeParseResult(parsed) {
9556
9561
  if (!parsed) return [];
9557
9562
  return Array.isArray(parsed) ? parsed : [parsed];
9558
9563
  }
9559
- var CHAT_DETAIL_MAX;
9564
+ var CHAT_DETAIL_MAX, THINKING_PART_MAX_CHARS;
9560
9565
  var init_message_parts = __esm({
9561
9566
  "src/agents/message-parts.ts"() {
9562
9567
  "use strict";
9563
9568
  init_error_detail();
9564
9569
  CHAT_DETAIL_MAX = 72;
9570
+ THINKING_PART_MAX_CHARS = 64e3;
9565
9571
  }
9566
9572
  });
9567
9573
 
@@ -12797,7 +12803,7 @@ function formatToolPart(t, detail) {
12797
12803
  if (t.input && Object.keys(t.input).length > 0) {
12798
12804
  lines.push("Input:");
12799
12805
  lines.push("```json");
12800
- lines.push(JSON.stringify(t.input, null, 2));
12806
+ lines.push(clipToolResultForStore(JSON.stringify(t.input, null, 2)) ?? "");
12801
12807
  lines.push("```");
12802
12808
  } else if (t.detail) {
12803
12809
  lines.push(`Detail: ${t.detail}`);
@@ -12845,19 +12851,7 @@ ${m.text}`);
12845
12851
  }
12846
12852
  return bits.join("\n");
12847
12853
  }
12848
- function buildSessionSeed(messages, opts) {
12849
- if (messages.length === 0) return null;
12850
- const tools = opts?.tools ?? "full";
12851
- const fullCount = opts?.fullToolMessages ?? SEED_FULL_TOOL_MESSAGES;
12852
- const maxChars = opts?.maxChars ?? SEED_MAX_CHARS;
12853
- const olderTools = tools === "none" ? "none" : "summary";
12854
- const fullFrom = Math.max(0, messages.length - fullCount);
12855
- const blocks = messages.map(
12856
- (m, i) => formatMessageBlock(m, {
12857
- tools: i >= fullFrom ? tools : olderTools,
12858
- thinking: false
12859
- })
12860
- );
12854
+ function budgetSeedBlocks(messages, blocks, maxChars) {
12861
12855
  const keep = new Array(blocks.length).fill(false);
12862
12856
  let used = 0;
12863
12857
  for (let i = 0; i < blocks.length; i++) {
@@ -12874,20 +12868,34 @@ function buildSessionSeed(messages, opts) {
12874
12868
  used = next;
12875
12869
  }
12876
12870
  const dropped = keep.filter((k) => !k).length;
12871
+ const marker = `_(${dropped} older message${dropped === 1 ? "" : "s"} omitted for length)_`;
12877
12872
  const kept = [];
12878
12873
  let markerPlaced = false;
12879
12874
  for (let i = 0; i < blocks.length; i++) {
12880
12875
  if (!keep[i]) continue;
12881
12876
  if (dropped > 0 && !markerPlaced && messages[i].role !== "summary") {
12882
- kept.push(`_(${dropped} older message${dropped === 1 ? "" : "s"} omitted for length)_`);
12877
+ kept.push(marker);
12883
12878
  markerPlaced = true;
12884
12879
  }
12885
12880
  kept.push(blocks[i]);
12886
12881
  }
12887
- if (dropped > 0 && !markerPlaced) {
12888
- kept.push(`_(${dropped} older message${dropped === 1 ? "" : "s"} omitted for length)_`);
12889
- }
12890
- const body = kept.join("\n\n");
12882
+ if (dropped > 0 && !markerPlaced) kept.push(marker);
12883
+ return kept.join("\n\n");
12884
+ }
12885
+ function buildSessionSeed(messages, opts) {
12886
+ if (messages.length === 0) return null;
12887
+ const tools = opts?.tools ?? "full";
12888
+ const fullCount = opts?.fullToolMessages ?? SEED_FULL_TOOL_MESSAGES;
12889
+ const maxChars = opts?.maxChars ?? SEED_MAX_CHARS;
12890
+ const olderTools = tools === "none" ? "none" : "summary";
12891
+ const fullFrom = Math.max(0, messages.length - fullCount);
12892
+ const blocks = messages.map(
12893
+ (m, i) => formatMessageBlock(m, {
12894
+ tools: i >= fullFrom ? tools : olderTools,
12895
+ thinking: false
12896
+ })
12897
+ );
12898
+ const body = budgetSeedBlocks(messages, blocks, maxChars);
12891
12899
  if (!body.trim()) return null;
12892
12900
  return [
12893
12901
  "Sideboard conversation context (restored after compaction or a new session):",
@@ -12937,10 +12945,12 @@ function findLastBrightsyContextSummary(messages) {
12937
12945
  }
12938
12946
  return null;
12939
12947
  }
12940
- function buildBrightsySessionSeed(messages) {
12948
+ function buildBrightsySessionSeed(messages, opts) {
12941
12949
  const match = findLastBrightsyContextSummary(messages);
12942
12950
  const tail = match ? messages.slice(match.index + 1) : messages;
12943
- const body = formatMessagesAsTranscript(tail, { tools: "none", thinking: false });
12951
+ const budget = Math.max(1e3, (opts?.maxChars ?? SEED_MAX_CHARS) - (match?.text.length ?? 0));
12952
+ const tailBlocks = tail.map((m) => formatMessageBlock(m, { tools: "none", thinking: false }));
12953
+ const body = budgetSeedBlocks(tail, tailBlocks, budget);
12944
12954
  if (!match && !body.trim()) return null;
12945
12955
  const blocks = [
12946
12956
  "Sideboard conversation context (restored after compaction or a new session):",
@@ -13011,6 +13021,7 @@ var CONTEXT_COMPACT_CHARS, CONTEXT_KEEP_RECENT_CHARS, CONTEXT_KEEP_RECENT_MESSAG
13011
13021
  var init_context_compact = __esm({
13012
13022
  "src/composer/context-compact.ts"() {
13013
13023
  "use strict";
13024
+ init_error_detail();
13014
13025
  init_usage();
13015
13026
  init_context_estimate();
13016
13027
  init_summarize();
@@ -13061,6 +13072,10 @@ function pickRichestSetupLog(snaps) {
13061
13072
  }
13062
13073
  return best;
13063
13074
  }
13075
+ function resolveWorktreeSetupLog(shared, legacyChatLogs) {
13076
+ if (shared.output || shared.running || shared.exitCode != null) return shared;
13077
+ return pickRichestSetupLog(legacyChatLogs);
13078
+ }
13064
13079
  function mergeWorktreeActiveRuns(threads) {
13065
13080
  const byName = /* @__PURE__ */ new Map();
13066
13081
  let devPort = null;
@@ -13876,6 +13891,14 @@ var init_conductor = __esm({
13876
13891
  });
13877
13892
 
13878
13893
  // src/store/setup-log.ts
13894
+ function appendSetupOutput(prev, line, max = MAX_SETUP_LOG_CHARS) {
13895
+ const next = prev ? `${prev}
13896
+ ${line}` : line;
13897
+ if (next.length <= max) return next;
13898
+ const cut = next.slice(next.length - max);
13899
+ const nl = cut.indexOf("\n");
13900
+ return nl >= 0 && nl < cut.length - 1 ? cut.slice(nl + 1) : cut;
13901
+ }
13879
13902
  function setupLogPath(threadId) {
13880
13903
  return (0, import_node_path36.join)(threadsDir(), `${threadId}.setup.log.json`);
13881
13904
  }
@@ -13953,8 +13976,7 @@ function appendSetupLog(threadId, line) {
13953
13976
  const current = memory.get(threadId) ?? readSetupLog(threadId);
13954
13977
  const snap = {
13955
13978
  ...current,
13956
- output: current.output ? `${current.output}
13957
- ${line}` : line,
13979
+ output: appendSetupOutput(current.output, line),
13958
13980
  running: true
13959
13981
  };
13960
13982
  memory.set(threadId, snap);
@@ -13973,7 +13995,7 @@ function finishSetupLog(threadId, exitCode, source) {
13973
13995
  persistNow(threadId);
13974
13996
  return clone(snap);
13975
13997
  }
13976
- var import_node_crypto8, import_node_fs36, import_node_path36, EMPTY, memory, persistTimers;
13998
+ var import_node_crypto8, import_node_fs36, import_node_path36, EMPTY, MAX_SETUP_LOG_CHARS, memory, persistTimers;
13977
13999
  var init_setup_log = __esm({
13978
14000
  "src/store/setup-log.ts"() {
13979
14001
  "use strict";
@@ -13988,6 +14010,7 @@ var init_setup_log = __esm({
13988
14010
  exitCode: null,
13989
14011
  source: null
13990
14012
  };
14013
+ MAX_SETUP_LOG_CHARS = 256e3;
13991
14014
  memory = /* @__PURE__ */ new Map();
13992
14015
  persistTimers = /* @__PURE__ */ new Map();
13993
14016
  }
@@ -20310,6 +20333,7 @@ var init_orchestrator = __esm({
20310
20333
  return true;
20311
20334
  });
20312
20335
  if (!promoted) return this.requireThread(thread.id);
20336
+ if (!thisProcessShouldDrainAgentQueues()) return this.requireThread(thread.id);
20313
20337
  const current = this.requireThread(thread.id);
20314
20338
  const inFlight = this.activeTurns.has(thread.id) || this.startingTurns.has(thread.id);
20315
20339
  const livePid = current.agentPid;
@@ -21050,10 +21074,10 @@ var init_orchestrator = __esm({
21050
21074
  thread.id,
21051
21075
  ...threadsSharingWorktree(thread.worktreePath).map((t) => t.id)
21052
21076
  ];
21053
- const snap = pickRichestSetupLog([
21077
+ const snap = resolveWorktreeSetupLog(
21054
21078
  readSetupLog(setupLogKeyForWorktree(thread.worktreePath)),
21055
- ...[...new Set(siblingIds)].map((id) => readSetupLog(id))
21056
- ]) ?? readSetupLog(thread.id);
21079
+ [...new Set(siblingIds)].map((id) => readSetupLog(id))
21080
+ ) ?? readSetupLog(thread.id);
21057
21081
  if (snap.running && !this.hasWorktreeSetupProcess(thread.worktreePath)) {
21058
21082
  return { ...snap, running: false };
21059
21083
  }
@@ -26204,7 +26228,7 @@ async function startMcpServer() {
26204
26228
  );
26205
26229
  server.tool(
26206
26230
  "send_to_thread",
26207
- 'Steer a prompt on a worktree thread chat (Settings \u2192 Follow-up, default steer: interrupt and start now, skip the inbox). Use after create_thread to start or continue a conversation. For commit/push/PR, prefer ask_git (canonical desktop-button phrases). Send "Merge PR." / ask_git merge only when the user explicitly asked to merge. force_stop=true kills the in-flight turn and clears the queue before this prompt \u2014 only when the current request is wrong and must be replaced. Do not send_to_thread to check in, resume after a halt notice, or because wait_for_turn returned stillRunning; that interrupts the child mid-thought. Call wait_for_turn again instead.',
26231
+ 'Steer a prompt on a worktree thread chat (Settings \u2192 Follow-up, default steer: front of the queue, skips the inbox; while the desktop board is running it starts as soon as the in-flight turn yields). Use after create_thread to start or continue a conversation. For commit/push/PR, prefer ask_git (canonical desktop-button phrases). Send "Merge PR." / ask_git merge only when the user explicitly asked to merge. force_stop=true kills the in-flight turn and clears the queue before this prompt \u2014 only when the current request is wrong and must be replaced. Do not send_to_thread to check in, resume after a halt notice, or because wait_for_turn returned stillRunning; that interrupts the child mid-thought. Call wait_for_turn again instead.',
26208
26232
  {
26209
26233
  ref: import_zod9.z.string(),
26210
26234
  prompt: import_zod9.z.string(),
@@ -38,7 +38,7 @@ import {
38
38
  syncBoardPins,
39
39
  updateSchedule,
40
40
  waitForDetachedJob
41
- } from "../chunk-3IGCU4AT.js";
41
+ } from "../chunk-ZG7RONNQ.js";
42
42
  import "../chunk-YWI3IBP2.js";
43
43
  import {
44
44
  applySystemCaEnv,
@@ -48,7 +48,7 @@ import {
48
48
  materializeSystemCaBundle,
49
49
  sideboardMcpProfile,
50
50
  trustSystemCertificates
51
- } from "../chunk-5DY2QWVN.js";
51
+ } from "../chunk-PQBRCBIE.js";
52
52
  import {
53
53
  GLOBAL_WORKSPACE_ID,
54
54
  isCloudCoordinatorThread,
@@ -4353,7 +4353,7 @@ async function startMcpServer() {
4353
4353
  );
4354
4354
  server.tool(
4355
4355
  "send_to_thread",
4356
- 'Steer a prompt on a worktree thread chat (Settings \u2192 Follow-up, default steer: interrupt and start now, skip the inbox). Use after create_thread to start or continue a conversation. For commit/push/PR, prefer ask_git (canonical desktop-button phrases). Send "Merge PR." / ask_git merge only when the user explicitly asked to merge. force_stop=true kills the in-flight turn and clears the queue before this prompt \u2014 only when the current request is wrong and must be replaced. Do not send_to_thread to check in, resume after a halt notice, or because wait_for_turn returned stillRunning; that interrupts the child mid-thought. Call wait_for_turn again instead.',
4356
+ 'Steer a prompt on a worktree thread chat (Settings \u2192 Follow-up, default steer: front of the queue, skips the inbox; while the desktop board is running it starts as soon as the in-flight turn yields). Use after create_thread to start or continue a conversation. For commit/push/PR, prefer ask_git (canonical desktop-button phrases). Send "Merge PR." / ask_git merge only when the user explicitly asked to merge. force_stop=true kills the in-flight turn and clears the queue before this prompt \u2014 only when the current request is wrong and must be replaced. Do not send_to_thread to check in, resume after a halt notice, or because wait_for_turn returned stillRunning; that interrupts the child mid-thought. Call wait_for_turn again instead.',
4357
4357
  {
4358
4358
  ref: z9.string(),
4359
4359
  prompt: z9.string(),
@@ -7,9 +7,9 @@ import {
7
7
  resolveSendFollowUp,
8
8
  startOrchestration,
9
9
  waitForPidExit
10
- } from "./chunk-NXXJBRWQ.js";
10
+ } from "./chunk-SIIDQV2B.js";
11
11
  import "./chunk-DJU54RYW.js";
12
- import "./chunk-NWIBA5CP.js";
12
+ import "./chunk-N5JBG3BF.js";
13
13
  import "./chunk-HZTHWU6A.js";
14
14
  import "./chunk-S4QCBBXS.js";
15
15
  import "./chunk-6K64FJDD.js";
@@ -9,9 +9,9 @@ import {
9
9
  resolveSendFollowUp,
10
10
  startOrchestration,
11
11
  waitForPidExit
12
- } from "./chunk-3IGCU4AT.js";
12
+ } from "./chunk-ZG7RONNQ.js";
13
13
  import "./chunk-YWI3IBP2.js";
14
- import "./chunk-5DY2QWVN.js";
14
+ import "./chunk-PQBRCBIE.js";
15
15
  import "./chunk-6YTI2HBG.js";
16
16
  import "./chunk-3OHR73VK.js";
17
17
  import "./chunk-Y4MIXGPA.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sideboard-ai/core",
3
- "version": "0.1.196",
3
+ "version": "0.1.197",
4
4
  "description": "Sideboard core — orchestration, agents, git worktrees, MCP server",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",