@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.
- package/dist/{agents-CT4T6HA3.js → agents-BGT5DUGU.js} +1 -1
- package/dist/{agents-2JBVL66D.js → agents-IVDCAG7T.js} +1 -1
- package/dist/{chunk-NWIBA5CP.js → chunk-N5JBG3BF.js} +21 -6
- package/dist/{chunk-5DY2QWVN.js → chunk-PQBRCBIE.js} +10 -3
- package/dist/{chunk-NXXJBRWQ.js → chunk-SIIDQV2B.js} +48 -30
- package/dist/{chunk-3IGCU4AT.js → chunk-ZG7RONNQ.js} +47 -29
- package/dist/index.cjs +70 -35
- package/dist/index.d.cts +15 -5
- package/dist/index.d.ts +15 -5
- package/dist/index.js +7 -3
- package/dist/mcp/run-stdio.cjs +56 -32
- package/dist/mcp/run-stdio.js +3 -3
- package/dist/{orchestrator-CT7VSL7B.js → orchestrator-HB4LZ2AA.js} +2 -2
- package/dist/{orchestrator-2FTS55SG.js → orchestrator-SANGGLQV.js} +2 -2
- package/package.json +1 -1
|
@@ -605,11 +605,18 @@ function clipChatLine(value, max = CHAT_DETAIL_MAX) {
|
|
|
605
605
|
if (line.length <= max) return line;
|
|
606
606
|
return `${line.slice(0, Math.max(1, max - 1))}\u2026`;
|
|
607
607
|
}
|
|
608
|
+
var SHELL_BIN_DIR = /^(?:\/usr\/local\/bin|\/usr\/bin|\/bin|\/opt\/homebrew\/bin|\/sbin|\/usr\/sbin)\//;
|
|
609
|
+
function rootedPathWithSpaces(trimmed) {
|
|
610
|
+
const [head = "", ...rest] = trimmed.split(/\s+/);
|
|
611
|
+
if (SHELL_BIN_DIR.test(head)) return false;
|
|
612
|
+
return rest.every((tok) => !/^[-/~$]/.test(tok) && !tok.includes("="));
|
|
613
|
+
}
|
|
608
614
|
function looksLikeFilePath(value) {
|
|
609
615
|
const trimmed = value.trim();
|
|
610
|
-
if (!trimmed || /[\
|
|
611
|
-
|
|
612
|
-
if (
|
|
616
|
+
if (!trimmed || /[\r\n;|&<>]/.test(trimmed)) return false;
|
|
617
|
+
const rooted = trimmed.startsWith("/") || trimmed.startsWith("~/") || /^[A-Za-z]:[\\/]/.test(trimmed);
|
|
618
|
+
if (/\s/.test(trimmed)) return rooted && rootedPathWithSpaces(trimmed);
|
|
619
|
+
if (rooted) return true;
|
|
613
620
|
return trimmed.includes("/") || trimmed.includes("\\");
|
|
614
621
|
}
|
|
615
622
|
function stripWorktreePrefix(path, worktreePath) {
|
|
@@ -934,6 +941,12 @@ function parseDiffStat(result) {
|
|
|
934
941
|
}
|
|
935
942
|
return {};
|
|
936
943
|
}
|
|
944
|
+
var THINKING_PART_MAX_CHARS = 64e3;
|
|
945
|
+
function clipThinkingForStore(text, max = THINKING_PART_MAX_CHARS) {
|
|
946
|
+
if (text.length <= max) return text;
|
|
947
|
+
const marker = "\u2026(earlier thinking trimmed)\n";
|
|
948
|
+
return marker + text.slice(text.length - Math.max(1, max - marker.length));
|
|
949
|
+
}
|
|
937
950
|
function withPartTimes(next, prev) {
|
|
938
951
|
const now = Date.now();
|
|
939
952
|
const startedAt = prev && typeof prev.startedAt === "number" ? prev.startedAt : now;
|
|
@@ -976,7 +989,7 @@ function applyAgentEvent(parts, event) {
|
|
|
976
989
|
next[i] = withPartTimes(
|
|
977
990
|
{
|
|
978
991
|
type: "thinking",
|
|
979
|
-
text: data,
|
|
992
|
+
text: clipThinkingForStore(data),
|
|
980
993
|
...event.parentId ? { parentId: event.parentId } : {}
|
|
981
994
|
},
|
|
982
995
|
prev
|
|
@@ -987,7 +1000,7 @@ function applyAgentEvent(parts, event) {
|
|
|
987
1000
|
next.push(
|
|
988
1001
|
withPartTimes({
|
|
989
1002
|
type: "thinking",
|
|
990
|
-
text: data,
|
|
1003
|
+
text: clipThinkingForStore(data),
|
|
991
1004
|
...event.parentId ? { parentId: event.parentId } : {}
|
|
992
1005
|
})
|
|
993
1006
|
);
|
|
@@ -998,7 +1011,7 @@ function applyAgentEvent(parts, event) {
|
|
|
998
1011
|
next[next.length - 1] = withPartTimes(
|
|
999
1012
|
{
|
|
1000
1013
|
type: "thinking",
|
|
1001
|
-
text: last.text + data,
|
|
1014
|
+
text: clipThinkingForStore(last.text + data),
|
|
1002
1015
|
...event.parentId ? { parentId: event.parentId } : {}
|
|
1003
1016
|
},
|
|
1004
1017
|
last
|
|
@@ -3684,6 +3697,8 @@ export {
|
|
|
3684
3697
|
withEventParentId,
|
|
3685
3698
|
withEventsParentId,
|
|
3686
3699
|
toolFilePath,
|
|
3700
|
+
THINKING_PART_MAX_CHARS,
|
|
3701
|
+
clipThinkingForStore,
|
|
3687
3702
|
applyAgentEvent,
|
|
3688
3703
|
partsToAssistantText,
|
|
3689
3704
|
lastAssistantMessageText,
|
|
@@ -1101,6 +1101,12 @@ function parseDiffStat(result) {
|
|
|
1101
1101
|
}
|
|
1102
1102
|
return {};
|
|
1103
1103
|
}
|
|
1104
|
+
var THINKING_PART_MAX_CHARS = 64e3;
|
|
1105
|
+
function clipThinkingForStore(text, max = THINKING_PART_MAX_CHARS) {
|
|
1106
|
+
if (text.length <= max) return text;
|
|
1107
|
+
const marker = "\u2026(earlier thinking trimmed)\n";
|
|
1108
|
+
return marker + text.slice(text.length - Math.max(1, max - marker.length));
|
|
1109
|
+
}
|
|
1104
1110
|
function withPartTimes(next, prev) {
|
|
1105
1111
|
const now = Date.now();
|
|
1106
1112
|
const startedAt = prev && typeof prev.startedAt === "number" ? prev.startedAt : now;
|
|
@@ -1143,7 +1149,7 @@ function applyAgentEvent(parts, event) {
|
|
|
1143
1149
|
next[i] = withPartTimes(
|
|
1144
1150
|
{
|
|
1145
1151
|
type: "thinking",
|
|
1146
|
-
text: data,
|
|
1152
|
+
text: clipThinkingForStore(data),
|
|
1147
1153
|
...event.parentId ? { parentId: event.parentId } : {}
|
|
1148
1154
|
},
|
|
1149
1155
|
prev
|
|
@@ -1154,7 +1160,7 @@ function applyAgentEvent(parts, event) {
|
|
|
1154
1160
|
next.push(
|
|
1155
1161
|
withPartTimes({
|
|
1156
1162
|
type: "thinking",
|
|
1157
|
-
text: data,
|
|
1163
|
+
text: clipThinkingForStore(data),
|
|
1158
1164
|
...event.parentId ? { parentId: event.parentId } : {}
|
|
1159
1165
|
})
|
|
1160
1166
|
);
|
|
@@ -1165,7 +1171,7 @@ function applyAgentEvent(parts, event) {
|
|
|
1165
1171
|
next[next.length - 1] = withPartTimes(
|
|
1166
1172
|
{
|
|
1167
1173
|
type: "thinking",
|
|
1168
|
-
text: last.text + data,
|
|
1174
|
+
text: clipThinkingForStore(last.text + data),
|
|
1169
1175
|
...event.parentId ? { parentId: event.parentId } : {}
|
|
1170
1176
|
},
|
|
1171
1177
|
last
|
|
@@ -4341,6 +4347,7 @@ export {
|
|
|
4341
4347
|
applySystemCaEnv,
|
|
4342
4348
|
trustSystemCertificates,
|
|
4343
4349
|
pushTurnStderr,
|
|
4350
|
+
clipToolResultForStore,
|
|
4344
4351
|
looksLikeV8Oom,
|
|
4345
4352
|
summarizeTurnStderr,
|
|
4346
4353
|
looksLikeInvalidAgentSession,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
stripBrightsyNdjsonNoise,
|
|
25
25
|
sumUsageList,
|
|
26
26
|
toolDescription
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-N5JBG3BF.js";
|
|
28
28
|
import {
|
|
29
29
|
SLACK_REPLY_FORMATTING,
|
|
30
30
|
addWorkspace,
|
|
@@ -115,6 +115,7 @@ import {
|
|
|
115
115
|
} from "./chunk-AXQ4ZWHK.js";
|
|
116
116
|
import {
|
|
117
117
|
applyAgentRunnerHeapEnv,
|
|
118
|
+
clipToolResultForStore,
|
|
118
119
|
fallbackTurnFailDetail,
|
|
119
120
|
formatAgentErrorContinuePrompt,
|
|
120
121
|
formatTurnExitError,
|
|
@@ -471,7 +472,7 @@ async function continueSourceThread(threadId, prompt) {
|
|
|
471
472
|
await continueOnReply(threadId, prompt);
|
|
472
473
|
return;
|
|
473
474
|
}
|
|
474
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
475
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-HB4LZ2AA.js");
|
|
475
476
|
await getOrchestrator2().send(threadId, prompt);
|
|
476
477
|
} catch {
|
|
477
478
|
}
|
|
@@ -1256,7 +1257,7 @@ function formatToolPart(t, detail) {
|
|
|
1256
1257
|
if (t.input && Object.keys(t.input).length > 0) {
|
|
1257
1258
|
lines.push("Input:");
|
|
1258
1259
|
lines.push("```json");
|
|
1259
|
-
lines.push(JSON.stringify(t.input, null, 2));
|
|
1260
|
+
lines.push(clipToolResultForStore(JSON.stringify(t.input, null, 2)) ?? "");
|
|
1260
1261
|
lines.push("```");
|
|
1261
1262
|
} else if (t.detail) {
|
|
1262
1263
|
lines.push(`Detail: ${t.detail}`);
|
|
@@ -1306,19 +1307,7 @@ ${m.text}`);
|
|
|
1306
1307
|
}
|
|
1307
1308
|
var SEED_MAX_CHARS = 6e4;
|
|
1308
1309
|
var SEED_FULL_TOOL_MESSAGES = 6;
|
|
1309
|
-
function
|
|
1310
|
-
if (messages.length === 0) return null;
|
|
1311
|
-
const tools = opts?.tools ?? "full";
|
|
1312
|
-
const fullCount = opts?.fullToolMessages ?? SEED_FULL_TOOL_MESSAGES;
|
|
1313
|
-
const maxChars = opts?.maxChars ?? SEED_MAX_CHARS;
|
|
1314
|
-
const olderTools = tools === "none" ? "none" : "summary";
|
|
1315
|
-
const fullFrom = Math.max(0, messages.length - fullCount);
|
|
1316
|
-
const blocks = messages.map(
|
|
1317
|
-
(m, i) => formatMessageBlock(m, {
|
|
1318
|
-
tools: i >= fullFrom ? tools : olderTools,
|
|
1319
|
-
thinking: false
|
|
1320
|
-
})
|
|
1321
|
-
);
|
|
1310
|
+
function budgetSeedBlocks(messages, blocks, maxChars) {
|
|
1322
1311
|
const keep = new Array(blocks.length).fill(false);
|
|
1323
1312
|
let used = 0;
|
|
1324
1313
|
for (let i = 0; i < blocks.length; i++) {
|
|
@@ -1335,20 +1324,34 @@ function buildSessionSeed(messages, opts) {
|
|
|
1335
1324
|
used = next;
|
|
1336
1325
|
}
|
|
1337
1326
|
const dropped = keep.filter((k) => !k).length;
|
|
1327
|
+
const marker = `_(${dropped} older message${dropped === 1 ? "" : "s"} omitted for length)_`;
|
|
1338
1328
|
const kept = [];
|
|
1339
1329
|
let markerPlaced = false;
|
|
1340
1330
|
for (let i = 0; i < blocks.length; i++) {
|
|
1341
1331
|
if (!keep[i]) continue;
|
|
1342
1332
|
if (dropped > 0 && !markerPlaced && messages[i].role !== "summary") {
|
|
1343
|
-
kept.push(
|
|
1333
|
+
kept.push(marker);
|
|
1344
1334
|
markerPlaced = true;
|
|
1345
1335
|
}
|
|
1346
1336
|
kept.push(blocks[i]);
|
|
1347
1337
|
}
|
|
1348
|
-
if (dropped > 0 && !markerPlaced)
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1338
|
+
if (dropped > 0 && !markerPlaced) kept.push(marker);
|
|
1339
|
+
return kept.join("\n\n");
|
|
1340
|
+
}
|
|
1341
|
+
function buildSessionSeed(messages, opts) {
|
|
1342
|
+
if (messages.length === 0) return null;
|
|
1343
|
+
const tools = opts?.tools ?? "full";
|
|
1344
|
+
const fullCount = opts?.fullToolMessages ?? SEED_FULL_TOOL_MESSAGES;
|
|
1345
|
+
const maxChars = opts?.maxChars ?? SEED_MAX_CHARS;
|
|
1346
|
+
const olderTools = tools === "none" ? "none" : "summary";
|
|
1347
|
+
const fullFrom = Math.max(0, messages.length - fullCount);
|
|
1348
|
+
const blocks = messages.map(
|
|
1349
|
+
(m, i) => formatMessageBlock(m, {
|
|
1350
|
+
tools: i >= fullFrom ? tools : olderTools,
|
|
1351
|
+
thinking: false
|
|
1352
|
+
})
|
|
1353
|
+
);
|
|
1354
|
+
const body = budgetSeedBlocks(messages, blocks, maxChars);
|
|
1352
1355
|
if (!body.trim()) return null;
|
|
1353
1356
|
return [
|
|
1354
1357
|
"Sideboard conversation context (restored after compaction or a new session):",
|
|
@@ -1404,10 +1407,12 @@ function messagesSinceLastBrightsyContextSummary(messages) {
|
|
|
1404
1407
|
if (!match) return messages;
|
|
1405
1408
|
return messages.slice(match.index + 1);
|
|
1406
1409
|
}
|
|
1407
|
-
function buildBrightsySessionSeed(messages) {
|
|
1410
|
+
function buildBrightsySessionSeed(messages, opts) {
|
|
1408
1411
|
const match = findLastBrightsyContextSummary(messages);
|
|
1409
1412
|
const tail = match ? messages.slice(match.index + 1) : messages;
|
|
1410
|
-
const
|
|
1413
|
+
const budget = Math.max(1e3, (opts?.maxChars ?? SEED_MAX_CHARS) - (match?.text.length ?? 0));
|
|
1414
|
+
const tailBlocks = tail.map((m) => formatMessageBlock(m, { tools: "none", thinking: false }));
|
|
1415
|
+
const body = budgetSeedBlocks(tail, tailBlocks, budget);
|
|
1411
1416
|
if (!match && !body.trim()) return null;
|
|
1412
1417
|
const blocks = [
|
|
1413
1418
|
"Sideboard conversation context (restored after compaction or a new session):",
|
|
@@ -1510,6 +1515,10 @@ function pickRichestSetupLog(snaps) {
|
|
|
1510
1515
|
}
|
|
1511
1516
|
return best;
|
|
1512
1517
|
}
|
|
1518
|
+
function resolveWorktreeSetupLog(shared, legacyChatLogs) {
|
|
1519
|
+
if (shared.output || shared.running || shared.exitCode != null) return shared;
|
|
1520
|
+
return pickRichestSetupLog(legacyChatLogs);
|
|
1521
|
+
}
|
|
1513
1522
|
function mergeWorktreeActiveRuns(threads) {
|
|
1514
1523
|
const byName = /* @__PURE__ */ new Map();
|
|
1515
1524
|
let devPort = null;
|
|
@@ -2301,6 +2310,15 @@ var EMPTY = {
|
|
|
2301
2310
|
exitCode: null,
|
|
2302
2311
|
source: null
|
|
2303
2312
|
};
|
|
2313
|
+
var MAX_SETUP_LOG_CHARS = 256e3;
|
|
2314
|
+
function appendSetupOutput(prev, line, max = MAX_SETUP_LOG_CHARS) {
|
|
2315
|
+
const next = prev ? `${prev}
|
|
2316
|
+
${line}` : line;
|
|
2317
|
+
if (next.length <= max) return next;
|
|
2318
|
+
const cut = next.slice(next.length - max);
|
|
2319
|
+
const nl = cut.indexOf("\n");
|
|
2320
|
+
return nl >= 0 && nl < cut.length - 1 ? cut.slice(nl + 1) : cut;
|
|
2321
|
+
}
|
|
2304
2322
|
var memory = /* @__PURE__ */ new Map();
|
|
2305
2323
|
var persistTimers = /* @__PURE__ */ new Map();
|
|
2306
2324
|
function setupLogPath(threadId) {
|
|
@@ -2388,8 +2406,7 @@ function appendSetupLog(threadId, line) {
|
|
|
2388
2406
|
const current = memory.get(threadId) ?? readSetupLog(threadId);
|
|
2389
2407
|
const snap = {
|
|
2390
2408
|
...current,
|
|
2391
|
-
output: current.output
|
|
2392
|
-
${line}` : line,
|
|
2409
|
+
output: appendSetupOutput(current.output, line),
|
|
2393
2410
|
running: true
|
|
2394
2411
|
};
|
|
2395
2412
|
memory.set(threadId, snap);
|
|
@@ -3870,7 +3887,7 @@ async function createThread(input, _onSetupLine) {
|
|
|
3870
3887
|
return readThread(thread.id) ?? thread;
|
|
3871
3888
|
}
|
|
3872
3889
|
async function listLinearIssues(agent, repoPath) {
|
|
3873
|
-
const { getAdapter: getAdapter2 } = await import("./agents-
|
|
3890
|
+
const { getAdapter: getAdapter2 } = await import("./agents-IVDCAG7T.js");
|
|
3874
3891
|
await requireAgent(agent, { requireLinear: true });
|
|
3875
3892
|
const adapter = getAdapter2(agent);
|
|
3876
3893
|
if (!adapter.listLinearIssues) {
|
|
@@ -6876,7 +6893,7 @@ function formatScheduledPrompt(name, prompt) {
|
|
|
6876
6893
|
${prompt}`;
|
|
6877
6894
|
}
|
|
6878
6895
|
async function defaultDeps() {
|
|
6879
|
-
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
6896
|
+
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-HB4LZ2AA.js");
|
|
6880
6897
|
const orch = getOrchestrator2();
|
|
6881
6898
|
return {
|
|
6882
6899
|
findThread: (id) => findThreadByRef(id),
|
|
@@ -7571,6 +7588,7 @@ var Orchestrator = class {
|
|
|
7571
7588
|
return true;
|
|
7572
7589
|
});
|
|
7573
7590
|
if (!promoted) return this.requireThread(thread.id);
|
|
7591
|
+
if (!thisProcessShouldDrainAgentQueues()) return this.requireThread(thread.id);
|
|
7574
7592
|
const current = this.requireThread(thread.id);
|
|
7575
7593
|
const inFlight = this.activeTurns.has(thread.id) || this.startingTurns.has(thread.id);
|
|
7576
7594
|
const livePid = current.agentPid;
|
|
@@ -8311,10 +8329,10 @@ var Orchestrator = class {
|
|
|
8311
8329
|
thread.id,
|
|
8312
8330
|
...threadsSharingWorktree(thread.worktreePath).map((t) => t.id)
|
|
8313
8331
|
];
|
|
8314
|
-
const snap =
|
|
8332
|
+
const snap = resolveWorktreeSetupLog(
|
|
8315
8333
|
readSetupLog(setupLogKeyForWorktree(thread.worktreePath)),
|
|
8316
|
-
|
|
8317
|
-
|
|
8334
|
+
[...new Set(siblingIds)].map((id) => readSetupLog(id))
|
|
8335
|
+
) ?? readSetupLog(thread.id);
|
|
8318
8336
|
if (snap.running && !this.hasWorktreeSetupProcess(thread.worktreePath)) {
|
|
8319
8337
|
return { ...snap, running: false };
|
|
8320
8338
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
applyAgentEvent,
|
|
9
9
|
applyAgentRunnerHeapEnv,
|
|
10
10
|
applyTurnUsage,
|
|
11
|
+
clipToolResultForStore,
|
|
11
12
|
contextTokens,
|
|
12
13
|
fallbackTurnFailDetail,
|
|
13
14
|
finalizeParts,
|
|
@@ -36,7 +37,7 @@ import {
|
|
|
36
37
|
summarizeTurnStderr,
|
|
37
38
|
toolDescription,
|
|
38
39
|
turnFailChatText
|
|
39
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-PQBRCBIE.js";
|
|
40
41
|
import {
|
|
41
42
|
SLACK_REPLY_FORMATTING,
|
|
42
43
|
addWorkspace,
|
|
@@ -406,7 +407,7 @@ async function continueSourceThread(threadId, prompt) {
|
|
|
406
407
|
await continueOnReply(threadId, prompt);
|
|
407
408
|
return;
|
|
408
409
|
}
|
|
409
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
410
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-SANGGLQV.js");
|
|
410
411
|
await getOrchestrator2().send(threadId, prompt);
|
|
411
412
|
} catch {
|
|
412
413
|
}
|
|
@@ -1230,7 +1231,7 @@ function formatToolPart(t, detail) {
|
|
|
1230
1231
|
if (t.input && Object.keys(t.input).length > 0) {
|
|
1231
1232
|
lines.push("Input:");
|
|
1232
1233
|
lines.push("```json");
|
|
1233
|
-
lines.push(JSON.stringify(t.input, null, 2));
|
|
1234
|
+
lines.push(clipToolResultForStore(JSON.stringify(t.input, null, 2)) ?? "");
|
|
1234
1235
|
lines.push("```");
|
|
1235
1236
|
} else if (t.detail) {
|
|
1236
1237
|
lines.push(`Detail: ${t.detail}`);
|
|
@@ -1280,19 +1281,7 @@ ${m.text}`);
|
|
|
1280
1281
|
}
|
|
1281
1282
|
var SEED_MAX_CHARS = 6e4;
|
|
1282
1283
|
var SEED_FULL_TOOL_MESSAGES = 6;
|
|
1283
|
-
function
|
|
1284
|
-
if (messages.length === 0) return null;
|
|
1285
|
-
const tools = opts?.tools ?? "full";
|
|
1286
|
-
const fullCount = opts?.fullToolMessages ?? SEED_FULL_TOOL_MESSAGES;
|
|
1287
|
-
const maxChars = opts?.maxChars ?? SEED_MAX_CHARS;
|
|
1288
|
-
const olderTools = tools === "none" ? "none" : "summary";
|
|
1289
|
-
const fullFrom = Math.max(0, messages.length - fullCount);
|
|
1290
|
-
const blocks = messages.map(
|
|
1291
|
-
(m, i) => formatMessageBlock(m, {
|
|
1292
|
-
tools: i >= fullFrom ? tools : olderTools,
|
|
1293
|
-
thinking: false
|
|
1294
|
-
})
|
|
1295
|
-
);
|
|
1284
|
+
function budgetSeedBlocks(messages, blocks, maxChars) {
|
|
1296
1285
|
const keep = new Array(blocks.length).fill(false);
|
|
1297
1286
|
let used = 0;
|
|
1298
1287
|
for (let i = 0; i < blocks.length; i++) {
|
|
@@ -1309,20 +1298,34 @@ function buildSessionSeed(messages, opts) {
|
|
|
1309
1298
|
used = next;
|
|
1310
1299
|
}
|
|
1311
1300
|
const dropped = keep.filter((k) => !k).length;
|
|
1301
|
+
const marker = `_(${dropped} older message${dropped === 1 ? "" : "s"} omitted for length)_`;
|
|
1312
1302
|
const kept = [];
|
|
1313
1303
|
let markerPlaced = false;
|
|
1314
1304
|
for (let i = 0; i < blocks.length; i++) {
|
|
1315
1305
|
if (!keep[i]) continue;
|
|
1316
1306
|
if (dropped > 0 && !markerPlaced && messages[i].role !== "summary") {
|
|
1317
|
-
kept.push(
|
|
1307
|
+
kept.push(marker);
|
|
1318
1308
|
markerPlaced = true;
|
|
1319
1309
|
}
|
|
1320
1310
|
kept.push(blocks[i]);
|
|
1321
1311
|
}
|
|
1322
|
-
if (dropped > 0 && !markerPlaced)
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1312
|
+
if (dropped > 0 && !markerPlaced) kept.push(marker);
|
|
1313
|
+
return kept.join("\n\n");
|
|
1314
|
+
}
|
|
1315
|
+
function buildSessionSeed(messages, opts) {
|
|
1316
|
+
if (messages.length === 0) return null;
|
|
1317
|
+
const tools = opts?.tools ?? "full";
|
|
1318
|
+
const fullCount = opts?.fullToolMessages ?? SEED_FULL_TOOL_MESSAGES;
|
|
1319
|
+
const maxChars = opts?.maxChars ?? SEED_MAX_CHARS;
|
|
1320
|
+
const olderTools = tools === "none" ? "none" : "summary";
|
|
1321
|
+
const fullFrom = Math.max(0, messages.length - fullCount);
|
|
1322
|
+
const blocks = messages.map(
|
|
1323
|
+
(m, i) => formatMessageBlock(m, {
|
|
1324
|
+
tools: i >= fullFrom ? tools : olderTools,
|
|
1325
|
+
thinking: false
|
|
1326
|
+
})
|
|
1327
|
+
);
|
|
1328
|
+
const body = budgetSeedBlocks(messages, blocks, maxChars);
|
|
1326
1329
|
if (!body.trim()) return null;
|
|
1327
1330
|
return [
|
|
1328
1331
|
"Sideboard conversation context (restored after compaction or a new session):",
|
|
@@ -1373,10 +1376,12 @@ function findLastBrightsyContextSummary(messages) {
|
|
|
1373
1376
|
}
|
|
1374
1377
|
return null;
|
|
1375
1378
|
}
|
|
1376
|
-
function buildBrightsySessionSeed(messages) {
|
|
1379
|
+
function buildBrightsySessionSeed(messages, opts) {
|
|
1377
1380
|
const match = findLastBrightsyContextSummary(messages);
|
|
1378
1381
|
const tail = match ? messages.slice(match.index + 1) : messages;
|
|
1379
|
-
const
|
|
1382
|
+
const budget = Math.max(1e3, (opts?.maxChars ?? SEED_MAX_CHARS) - (match?.text.length ?? 0));
|
|
1383
|
+
const tailBlocks = tail.map((m) => formatMessageBlock(m, { tools: "none", thinking: false }));
|
|
1384
|
+
const body = budgetSeedBlocks(tail, tailBlocks, budget);
|
|
1380
1385
|
if (!match && !body.trim()) return null;
|
|
1381
1386
|
const blocks = [
|
|
1382
1387
|
"Sideboard conversation context (restored after compaction or a new session):",
|
|
@@ -1479,6 +1484,10 @@ function pickRichestSetupLog(snaps) {
|
|
|
1479
1484
|
}
|
|
1480
1485
|
return best;
|
|
1481
1486
|
}
|
|
1487
|
+
function resolveWorktreeSetupLog(shared, legacyChatLogs) {
|
|
1488
|
+
if (shared.output || shared.running || shared.exitCode != null) return shared;
|
|
1489
|
+
return pickRichestSetupLog(legacyChatLogs);
|
|
1490
|
+
}
|
|
1482
1491
|
function mergeWorktreeActiveRuns(threads) {
|
|
1483
1492
|
const byName = /* @__PURE__ */ new Map();
|
|
1484
1493
|
let devPort = null;
|
|
@@ -2242,6 +2251,15 @@ var EMPTY = {
|
|
|
2242
2251
|
exitCode: null,
|
|
2243
2252
|
source: null
|
|
2244
2253
|
};
|
|
2254
|
+
var MAX_SETUP_LOG_CHARS = 256e3;
|
|
2255
|
+
function appendSetupOutput(prev, line, max = MAX_SETUP_LOG_CHARS) {
|
|
2256
|
+
const next = prev ? `${prev}
|
|
2257
|
+
${line}` : line;
|
|
2258
|
+
if (next.length <= max) return next;
|
|
2259
|
+
const cut = next.slice(next.length - max);
|
|
2260
|
+
const nl = cut.indexOf("\n");
|
|
2261
|
+
return nl >= 0 && nl < cut.length - 1 ? cut.slice(nl + 1) : cut;
|
|
2262
|
+
}
|
|
2245
2263
|
var memory = /* @__PURE__ */ new Map();
|
|
2246
2264
|
var persistTimers = /* @__PURE__ */ new Map();
|
|
2247
2265
|
function setupLogPath(threadId) {
|
|
@@ -2321,8 +2339,7 @@ function appendSetupLog(threadId, line) {
|
|
|
2321
2339
|
const current = memory.get(threadId) ?? readSetupLog(threadId);
|
|
2322
2340
|
const snap = {
|
|
2323
2341
|
...current,
|
|
2324
|
-
output: current.output
|
|
2325
|
-
${line}` : line,
|
|
2342
|
+
output: appendSetupOutput(current.output, line),
|
|
2326
2343
|
running: true
|
|
2327
2344
|
};
|
|
2328
2345
|
memory.set(threadId, snap);
|
|
@@ -6529,7 +6546,7 @@ function formatScheduledPrompt(name, prompt) {
|
|
|
6529
6546
|
${prompt}`;
|
|
6530
6547
|
}
|
|
6531
6548
|
async function defaultDeps() {
|
|
6532
|
-
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
6549
|
+
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-SANGGLQV.js");
|
|
6533
6550
|
const orch = getOrchestrator2();
|
|
6534
6551
|
return {
|
|
6535
6552
|
findThread: (id) => findThreadByRef(id),
|
|
@@ -7224,6 +7241,7 @@ var Orchestrator = class {
|
|
|
7224
7241
|
return true;
|
|
7225
7242
|
});
|
|
7226
7243
|
if (!promoted) return this.requireThread(thread.id);
|
|
7244
|
+
if (!thisProcessShouldDrainAgentQueues()) return this.requireThread(thread.id);
|
|
7227
7245
|
const current = this.requireThread(thread.id);
|
|
7228
7246
|
const inFlight = this.activeTurns.has(thread.id) || this.startingTurns.has(thread.id);
|
|
7229
7247
|
const livePid = current.agentPid;
|
|
@@ -7964,10 +7982,10 @@ var Orchestrator = class {
|
|
|
7964
7982
|
thread.id,
|
|
7965
7983
|
...threadsSharingWorktree(thread.worktreePath).map((t) => t.id)
|
|
7966
7984
|
];
|
|
7967
|
-
const snap =
|
|
7985
|
+
const snap = resolveWorktreeSetupLog(
|
|
7968
7986
|
readSetupLog(setupLogKeyForWorktree(thread.worktreePath)),
|
|
7969
|
-
|
|
7970
|
-
|
|
7987
|
+
[...new Set(siblingIds)].map((id) => readSetupLog(id))
|
|
7988
|
+
) ?? readSetupLog(thread.id);
|
|
7971
7989
|
if (snap.running && !this.hasWorktreeSetupProcess(thread.worktreePath)) {
|
|
7972
7990
|
return { ...snap, running: false };
|
|
7973
7991
|
}
|