@sideboard-ai/core 0.1.136 → 0.1.139
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-QNTTLMG2.js → agents-665S7Z3R.js} +5 -5
- package/dist/{agents-ELWR7A2T.js → agents-OC3XM7UE.js} +5 -5
- package/dist/{chunk-JPBRMUM6.js → chunk-23KCPND2.js} +43 -4
- package/dist/{chunk-K5YT5GX2.js → chunk-5XH5M6RA.js} +3 -3
- package/dist/{chunk-IFZ4MOTN.js → chunk-7SYFWPOZ.js} +3 -3
- package/dist/{chunk-CYM5DCHI.js → chunk-CDJISVKN.js} +43 -4
- package/dist/{chunk-QAV3HGVS.js → chunk-DJJ3DTT4.js} +1 -1
- package/dist/{chunk-HQQNLDVC.js → chunk-DKXZCIB2.js} +1 -1
- package/dist/{chunk-GSKRGF7B.js → chunk-E2RE7P2S.js} +3 -3
- package/dist/{chunk-J5IBSVB3.js → chunk-EUXOHTUK.js} +42 -25
- package/dist/{chunk-4XKUHP6G.js → chunk-HLIHBGVO.js} +2 -2
- package/dist/{chunk-TQ4S5AGJ.js → chunk-RTX3AY42.js} +3 -3
- package/dist/{chunk-MDCKV2NF.js → chunk-SSBM4GZX.js} +2 -2
- package/dist/{chunk-PM3C2J6K.js → chunk-TUGKX5BD.js} +42 -25
- package/dist/{chunk-WS5LFFU3.js → chunk-YZQEJOAU.js} +67 -44
- package/dist/{chunk-TIGKDMIA.js → chunk-ZCLHAOFR.js} +85 -46
- package/dist/{coordinator-prompt-IPL4Z6SL.js → coordinator-prompt-43O6EPA2.js} +3 -3
- package/dist/{coordinator-prompt-2OWSUAUR.js → coordinator-prompt-4TXU6Q3R.js} +3 -3
- package/dist/{global-workspace-JDUCUL7S.js → global-workspace-VIU57E3Y.js} +4 -4
- package/dist/{global-workspace-NIKZAKOO.js → global-workspace-ZDYKHQ4O.js} +4 -4
- package/dist/index.cjs +197 -61
- package/dist/index.d.cts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +50 -12
- package/dist/mcp/run-stdio.cjs +176 -61
- package/dist/mcp/run-stdio.js +40 -12
- package/dist/{orchestrator-6I47JMU2.js → orchestrator-WEFXUHFX.js} +7 -7
- package/dist/{orchestrator-KK3CUW37.js → orchestrator-ZCMYSDTC.js} +7 -7
- package/dist/{thread-store-FADXSMEJ.js → thread-store-57ZLHR3A.js} +1 -1
- package/dist/{thread-store-CRLQJ2HM.js → thread-store-WGASXXXR.js} +1 -1
- package/dist/{workspaces-5EWNNALF.js → workspaces-4HYGNH4B.js} +5 -5
- package/dist/{workspaces-KZA3TCEE.js → workspaces-ALCTB65T.js} +5 -5
- package/dist/{worktree-MX7XBX6Z.js → worktree-GXD2NGOZ.js} +2 -2
- package/dist/{worktree-BC6XDMQK.js → worktree-NSNZODAM.js} +2 -2
- package/package.json +1 -1
|
@@ -31,13 +31,13 @@ import {
|
|
|
31
31
|
summarizeTurnStderr,
|
|
32
32
|
toolDescription,
|
|
33
33
|
turnFailChatText
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-23KCPND2.js";
|
|
35
35
|
import {
|
|
36
36
|
addWorkspace,
|
|
37
37
|
ensureWorkspace,
|
|
38
38
|
removeWorkspace,
|
|
39
39
|
syncWorkspacesFromThreads
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-HLIHBGVO.js";
|
|
41
41
|
import {
|
|
42
42
|
extractPresentedPlan,
|
|
43
43
|
readPlanFile,
|
|
@@ -62,14 +62,14 @@ import {
|
|
|
62
62
|
persistPendingFileAttachments,
|
|
63
63
|
stageAbsolutePathsAsAttachments,
|
|
64
64
|
stageBuffersAsAttachments
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-5XH5M6RA.js";
|
|
66
66
|
import {
|
|
67
67
|
SLACK_REPLY_FORMATTING,
|
|
68
68
|
coordinatorSystemPrompt,
|
|
69
69
|
coordinatorTurnReminder,
|
|
70
70
|
enrichWorkspacesWithGithub,
|
|
71
71
|
ensureGlobalCoordinatorCwd
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-RTX3AY42.js";
|
|
73
73
|
import {
|
|
74
74
|
addPrStackLayer,
|
|
75
75
|
allocateTeamName,
|
|
@@ -114,7 +114,7 @@ import {
|
|
|
114
114
|
withRepoGitLock,
|
|
115
115
|
worktreeDisplayLabelForGroup,
|
|
116
116
|
worktreeNameFromPath
|
|
117
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-DJJ3DTT4.js";
|
|
118
118
|
import {
|
|
119
119
|
ATTACHMENTS_DIR,
|
|
120
120
|
LEGACY_ATTACHMENTS_DIR
|
|
@@ -130,7 +130,7 @@ import {
|
|
|
130
130
|
updateThread,
|
|
131
131
|
withThreadLock,
|
|
132
132
|
writeThread
|
|
133
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-EUXOHTUK.js";
|
|
134
134
|
import {
|
|
135
135
|
clearStaleIndexLocks,
|
|
136
136
|
enrichPathWithNpmGlobalBin,
|
|
@@ -387,7 +387,7 @@ async function continueSourceThread(threadId, prompt) {
|
|
|
387
387
|
await continueOnReply(threadId, prompt);
|
|
388
388
|
return;
|
|
389
389
|
}
|
|
390
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
390
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-ZCMYSDTC.js");
|
|
391
391
|
await getOrchestrator2().send(threadId, prompt);
|
|
392
392
|
} catch {
|
|
393
393
|
}
|
|
@@ -728,9 +728,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
|
|
|
728
728
|
`Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
|
|
729
729
|
);
|
|
730
730
|
}
|
|
731
|
-
const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-
|
|
731
|
+
const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-VIU57E3Y.js");
|
|
732
732
|
if (isGlobalThread2(thread)) {
|
|
733
|
-
const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-
|
|
733
|
+
const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-4TXU6Q3R.js");
|
|
734
734
|
ensureGlobalCoordinatorCwd2(
|
|
735
735
|
isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
|
|
736
736
|
);
|
|
@@ -977,6 +977,49 @@ import { dirname, join as join4 } from "path";
|
|
|
977
977
|
// src/threads/chat-tabs.ts
|
|
978
978
|
import { randomUUID } from "crypto";
|
|
979
979
|
|
|
980
|
+
// src/composer/context-estimate.ts
|
|
981
|
+
var CHARS_PER_CONTEXT_TOKEN = 4;
|
|
982
|
+
function estimateMessageChars(message) {
|
|
983
|
+
let n = message.text.length + 16;
|
|
984
|
+
for (const part of message.parts ?? []) {
|
|
985
|
+
n += estimatePartChars(part);
|
|
986
|
+
}
|
|
987
|
+
return n;
|
|
988
|
+
}
|
|
989
|
+
function estimatePartChars(part) {
|
|
990
|
+
switch (part.type) {
|
|
991
|
+
case "text":
|
|
992
|
+
case "thinking":
|
|
993
|
+
return part.text.length;
|
|
994
|
+
case "tool": {
|
|
995
|
+
const input = part.input ? JSON.stringify(part.input) : "";
|
|
996
|
+
return part.name.length + (part.description?.length ?? 0) + (part.detail?.length ?? 0) + (part.result?.length ?? 0) + input.length + 32;
|
|
997
|
+
}
|
|
998
|
+
default:
|
|
999
|
+
return 0;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
function estimateThreadChars(messages) {
|
|
1003
|
+
return messages.reduce((sum, m) => sum + estimateMessageChars(m), 0);
|
|
1004
|
+
}
|
|
1005
|
+
function estimateOccupancyTokens(messages) {
|
|
1006
|
+
return Math.ceil(estimateThreadChars(messages) / CHARS_PER_CONTEXT_TOKEN);
|
|
1007
|
+
}
|
|
1008
|
+
function applyForwardOccupancy(messages) {
|
|
1009
|
+
const tokens = estimateOccupancyTokens(messages);
|
|
1010
|
+
if (tokens <= 0) return messages;
|
|
1011
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
1012
|
+
const m = messages[i];
|
|
1013
|
+
if (m?.role !== "agent" || !m.usage) continue;
|
|
1014
|
+
const current = contextTokens(m.usage);
|
|
1015
|
+
if (tokens >= current) return messages;
|
|
1016
|
+
const next = messages.slice();
|
|
1017
|
+
next[i] = { ...m, usage: { ...m.usage, lastRequestTokens: tokens } };
|
|
1018
|
+
return next;
|
|
1019
|
+
}
|
|
1020
|
+
return messages;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
980
1023
|
// src/composer/summarize.ts
|
|
981
1024
|
var MAX_TRANSCRIPT_CHARS = 12e4;
|
|
982
1025
|
var MAX_SUMMARY_CHARS = 6e3;
|
|
@@ -1085,29 +1128,6 @@ var CONTEXT_KEEP_RECENT_CHARS = 24e3;
|
|
|
1085
1128
|
var CONTEXT_KEEP_RECENT_MESSAGES = 12;
|
|
1086
1129
|
var CONTEXT_MIN_MESSAGES = 10;
|
|
1087
1130
|
var SESSION_RESET_OCCUPANCY_TOKENS = 75e4;
|
|
1088
|
-
function estimateMessageChars(message) {
|
|
1089
|
-
let n = message.text.length + 16;
|
|
1090
|
-
for (const part of message.parts ?? []) {
|
|
1091
|
-
n += estimatePartChars(part);
|
|
1092
|
-
}
|
|
1093
|
-
return n;
|
|
1094
|
-
}
|
|
1095
|
-
function estimatePartChars(part) {
|
|
1096
|
-
switch (part.type) {
|
|
1097
|
-
case "text":
|
|
1098
|
-
case "thinking":
|
|
1099
|
-
return part.text.length;
|
|
1100
|
-
case "tool": {
|
|
1101
|
-
const input = part.input ? JSON.stringify(part.input) : "";
|
|
1102
|
-
return part.name.length + (part.description?.length ?? 0) + (part.detail?.length ?? 0) + (part.result?.length ?? 0) + input.length + 32;
|
|
1103
|
-
}
|
|
1104
|
-
default:
|
|
1105
|
-
return 0;
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
function estimateThreadChars(messages) {
|
|
1109
|
-
return messages.reduce((sum, m) => sum + estimateMessageChars(m), 0);
|
|
1110
|
-
}
|
|
1111
1131
|
function shouldCompactContext(messages, thresholds = {}) {
|
|
1112
1132
|
const maxChars = thresholds.maxChars ?? CONTEXT_COMPACT_CHARS;
|
|
1113
1133
|
const minMessages = thresholds.minMessages ?? CONTEXT_MIN_MESSAGES;
|
|
@@ -1244,8 +1264,11 @@ async function maybeCompactContext(thread, thresholds = {}, summarize = summariz
|
|
|
1244
1264
|
const { summary, method } = await summarize(transcript, {
|
|
1245
1265
|
cwd: thread.worktreePath
|
|
1246
1266
|
});
|
|
1247
|
-
|
|
1267
|
+
let messages = applyCompaction(thread.messages, summary, thresholds);
|
|
1248
1268
|
const resetSession = shouldResetSessionForOccupancy({ messages: thread.messages });
|
|
1269
|
+
if (resetSession) {
|
|
1270
|
+
messages = applyForwardOccupancy(messages);
|
|
1271
|
+
}
|
|
1249
1272
|
const next = {
|
|
1250
1273
|
...thread,
|
|
1251
1274
|
messages,
|
|
@@ -2916,7 +2939,7 @@ async function createThread(input, _onSetupLine) {
|
|
|
2916
2939
|
return readThread(thread.id) ?? thread;
|
|
2917
2940
|
}
|
|
2918
2941
|
async function listLinearIssues(agent, repoPath) {
|
|
2919
|
-
const { getAdapter: getAdapter2 } = await import("./agents-
|
|
2942
|
+
const { getAdapter: getAdapter2 } = await import("./agents-OC3XM7UE.js");
|
|
2920
2943
|
await requireAgent(agent, { requireLinear: true });
|
|
2921
2944
|
const adapter = getAdapter2(agent);
|
|
2922
2945
|
if (!adapter.listLinearIssues) {
|
|
@@ -3313,7 +3336,7 @@ async function adoptThread(input) {
|
|
|
3313
3336
|
messages: input.messages ?? []
|
|
3314
3337
|
});
|
|
3315
3338
|
writeThread(thread);
|
|
3316
|
-
const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-
|
|
3339
|
+
const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-4HYGNH4B.js");
|
|
3317
3340
|
await ensureWorkspace2(repoPath);
|
|
3318
3341
|
return thread;
|
|
3319
3342
|
}
|
|
@@ -5277,7 +5300,7 @@ function formatScheduledPrompt(name, prompt) {
|
|
|
5277
5300
|
${prompt}`;
|
|
5278
5301
|
}
|
|
5279
5302
|
async function defaultDeps() {
|
|
5280
|
-
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
5303
|
+
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-ZCMYSDTC.js");
|
|
5281
5304
|
const orch = getOrchestrator2();
|
|
5282
5305
|
return {
|
|
5283
5306
|
findThread: (id) => findThreadByRef(id),
|
|
@@ -5553,7 +5576,7 @@ var Orchestrator = class {
|
|
|
5553
5576
|
if (thread.status === "archived") continue;
|
|
5554
5577
|
const handle = this.activeTurns.get(thread.id);
|
|
5555
5578
|
if (handle) {
|
|
5556
|
-
const pid =
|
|
5579
|
+
const pid = handle.pid;
|
|
5557
5580
|
if (typeof pid === "number" && pid > 0 && !isPidAlive(pid)) {
|
|
5558
5581
|
handle.kill();
|
|
5559
5582
|
}
|
|
@@ -6377,7 +6400,7 @@ var Orchestrator = class {
|
|
|
6377
6400
|
const stopped = writeLiveStatus(thread.id, "stopped") ?? readThread(thread.id) ?? thread;
|
|
6378
6401
|
if (stopped.status === "stopped") {
|
|
6379
6402
|
this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
|
|
6380
|
-
if (opts?.notifyParent !== false) {
|
|
6403
|
+
if (inFlight && opts?.notifyParent !== false) {
|
|
6381
6404
|
notifyParentOfChildHalt(stopped, "stopped", (id, prompt) => this.send(id, prompt));
|
|
6382
6405
|
}
|
|
6383
6406
|
}
|
|
@@ -7136,7 +7159,7 @@ var Orchestrator = class {
|
|
|
7136
7159
|
}
|
|
7137
7160
|
async archiveUnlocked(threadRef) {
|
|
7138
7161
|
const thread = this.requireThread(threadRef);
|
|
7139
|
-
this.stop(thread.id);
|
|
7162
|
+
this.stop(thread.id, { notifyParent: false });
|
|
7140
7163
|
this.releaseOrchestratorCaffeinate(thread);
|
|
7141
7164
|
if (isGlobalThread(thread)) {
|
|
7142
7165
|
const archived2 = setStatus(thread.id, "archived");
|
|
@@ -7164,7 +7187,7 @@ var Orchestrator = class {
|
|
|
7164
7187
|
this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
|
|
7165
7188
|
if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
|
|
7166
7189
|
try {
|
|
7167
|
-
const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-
|
|
7190
|
+
const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-4HYGNH4B.js");
|
|
7168
7191
|
await ensureWorkspace2(thread.repoPath);
|
|
7169
7192
|
} catch {
|
|
7170
7193
|
}
|
|
@@ -7177,7 +7200,7 @@ var Orchestrator = class {
|
|
|
7177
7200
|
}
|
|
7178
7201
|
async purgeUnlocked(threadRef, opts) {
|
|
7179
7202
|
const thread = this.requireThread(threadRef);
|
|
7180
|
-
this.stop(thread.id);
|
|
7203
|
+
this.stop(thread.id, { notifyParent: false });
|
|
7181
7204
|
this.releaseOrchestratorCaffeinate(thread);
|
|
7182
7205
|
if (isGlobalThread(thread)) {
|
|
7183
7206
|
deleteThreadRecord(thread.id);
|
|
@@ -7218,7 +7241,7 @@ var Orchestrator = class {
|
|
|
7218
7241
|
`Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
|
|
7219
7242
|
);
|
|
7220
7243
|
}
|
|
7221
|
-
const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-
|
|
7244
|
+
const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-NSNZODAM.js");
|
|
7222
7245
|
const slug = thread.worktreePath.split("/").pop();
|
|
7223
7246
|
const dest = thread.worktreePath;
|
|
7224
7247
|
await withRepoGitLock(thread.repoPath, async () => {
|
|
@@ -7326,7 +7349,7 @@ async function startOrchestration(opts) {
|
|
|
7326
7349
|
sourceRef: "default",
|
|
7327
7350
|
...createOpts
|
|
7328
7351
|
}).catch(async () => {
|
|
7329
|
-
const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-
|
|
7352
|
+
const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-NSNZODAM.js");
|
|
7330
7353
|
const repo = await resolveRepoRoot2(repoPath);
|
|
7331
7354
|
const def = await resolveDefaultBranch2(repo);
|
|
7332
7355
|
return orch.createThread({
|
|
@@ -7336,7 +7359,7 @@ async function startOrchestration(opts) {
|
|
|
7336
7359
|
repoPath: repo
|
|
7337
7360
|
});
|
|
7338
7361
|
});
|
|
7339
|
-
const { updateThread: upd } = await import("./thread-store-
|
|
7362
|
+
const { updateThread: upd } = await import("./thread-store-57ZLHR3A.js");
|
|
7340
7363
|
const updated = upd(thread.id, {
|
|
7341
7364
|
sourceType: "orchestration",
|
|
7342
7365
|
sourceRef: goal
|
|
@@ -18,13 +18,13 @@ import {
|
|
|
18
18
|
stripBrightsyNdjsonNoise,
|
|
19
19
|
sumUsageList,
|
|
20
20
|
toolDescription
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-CDJISVKN.js";
|
|
22
22
|
import {
|
|
23
23
|
addWorkspace,
|
|
24
24
|
ensureWorkspace,
|
|
25
25
|
removeWorkspace,
|
|
26
26
|
syncWorkspacesFromThreads
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-SSBM4GZX.js";
|
|
28
28
|
import {
|
|
29
29
|
assertOrchestratorCapableAgent,
|
|
30
30
|
attachmentsFromWorktreePaths,
|
|
@@ -41,14 +41,14 @@ import {
|
|
|
41
41
|
persistPendingFileAttachments,
|
|
42
42
|
stageAbsolutePathsAsAttachments,
|
|
43
43
|
stageBuffersAsAttachments
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-E2RE7P2S.js";
|
|
45
45
|
import {
|
|
46
46
|
SLACK_REPLY_FORMATTING,
|
|
47
47
|
coordinatorSystemPrompt,
|
|
48
48
|
coordinatorTurnReminder,
|
|
49
49
|
enrichWorkspacesWithGithub,
|
|
50
50
|
ensureGlobalCoordinatorCwd
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-7SYFWPOZ.js";
|
|
52
52
|
import {
|
|
53
53
|
extractPresentedPlan,
|
|
54
54
|
readPlanFile,
|
|
@@ -118,7 +118,7 @@ import {
|
|
|
118
118
|
withRepoGitLock,
|
|
119
119
|
worktreeDisplayLabelForGroup,
|
|
120
120
|
worktreeNameFromPath
|
|
121
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-DKXZCIB2.js";
|
|
122
122
|
import {
|
|
123
123
|
ATTACHMENTS_DIR,
|
|
124
124
|
LEGACY_ATTACHMENTS_DIR
|
|
@@ -155,7 +155,7 @@ import {
|
|
|
155
155
|
updateThread,
|
|
156
156
|
withThreadLock,
|
|
157
157
|
writeThread
|
|
158
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-TUGKX5BD.js";
|
|
159
159
|
import {
|
|
160
160
|
appDataDir,
|
|
161
161
|
findConventionSetup,
|
|
@@ -448,7 +448,7 @@ async function continueSourceThread(threadId, prompt) {
|
|
|
448
448
|
await continueOnReply(threadId, prompt);
|
|
449
449
|
return;
|
|
450
450
|
}
|
|
451
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
451
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-WEFXUHFX.js");
|
|
452
452
|
await getOrchestrator2().send(threadId, prompt);
|
|
453
453
|
} catch {
|
|
454
454
|
}
|
|
@@ -728,9 +728,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
|
|
|
728
728
|
`Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
|
|
729
729
|
);
|
|
730
730
|
}
|
|
731
|
-
const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-
|
|
731
|
+
const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-ZDYKHQ4O.js");
|
|
732
732
|
if (isGlobalThread2(thread)) {
|
|
733
|
-
const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-
|
|
733
|
+
const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-43O6EPA2.js");
|
|
734
734
|
ensureGlobalCoordinatorCwd2(
|
|
735
735
|
isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
|
|
736
736
|
);
|
|
@@ -977,6 +977,60 @@ import { dirname, join as join4 } from "path";
|
|
|
977
977
|
// src/threads/chat-tabs.ts
|
|
978
978
|
import { randomUUID } from "crypto";
|
|
979
979
|
|
|
980
|
+
// src/composer/context-estimate.ts
|
|
981
|
+
var CHARS_PER_CONTEXT_TOKEN = 4;
|
|
982
|
+
function estimateMessageChars(message) {
|
|
983
|
+
let n = message.text.length + 16;
|
|
984
|
+
for (const part of message.parts ?? []) {
|
|
985
|
+
n += estimatePartChars(part);
|
|
986
|
+
}
|
|
987
|
+
return n;
|
|
988
|
+
}
|
|
989
|
+
function estimatePartChars(part) {
|
|
990
|
+
switch (part.type) {
|
|
991
|
+
case "text":
|
|
992
|
+
case "thinking":
|
|
993
|
+
return part.text.length;
|
|
994
|
+
case "tool": {
|
|
995
|
+
const input = part.input ? JSON.stringify(part.input) : "";
|
|
996
|
+
return part.name.length + (part.description?.length ?? 0) + (part.detail?.length ?? 0) + (part.result?.length ?? 0) + input.length + 32;
|
|
997
|
+
}
|
|
998
|
+
default:
|
|
999
|
+
return 0;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
function estimateThreadChars(messages) {
|
|
1003
|
+
return messages.reduce((sum, m) => sum + estimateMessageChars(m), 0);
|
|
1004
|
+
}
|
|
1005
|
+
function estimateOccupancyTokens(messages) {
|
|
1006
|
+
return Math.ceil(estimateThreadChars(messages) / CHARS_PER_CONTEXT_TOKEN);
|
|
1007
|
+
}
|
|
1008
|
+
function threadHasCompactedContext(messages) {
|
|
1009
|
+
return messages.some((m) => m.role === "summary");
|
|
1010
|
+
}
|
|
1011
|
+
function forwardContextUsage(usage, messages) {
|
|
1012
|
+
if (!usage) return null;
|
|
1013
|
+
if (!threadHasCompactedContext(messages)) return usage;
|
|
1014
|
+
const remaining = estimateOccupancyTokens(messages);
|
|
1015
|
+
const current = contextTokens(usage);
|
|
1016
|
+
if (remaining <= 0 || remaining >= current) return usage;
|
|
1017
|
+
return { ...usage, lastRequestTokens: remaining };
|
|
1018
|
+
}
|
|
1019
|
+
function applyForwardOccupancy(messages) {
|
|
1020
|
+
const tokens = estimateOccupancyTokens(messages);
|
|
1021
|
+
if (tokens <= 0) return messages;
|
|
1022
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
1023
|
+
const m = messages[i];
|
|
1024
|
+
if (m?.role !== "agent" || !m.usage) continue;
|
|
1025
|
+
const current = contextTokens(m.usage);
|
|
1026
|
+
if (tokens >= current) return messages;
|
|
1027
|
+
const next = messages.slice();
|
|
1028
|
+
next[i] = { ...m, usage: { ...m.usage, lastRequestTokens: tokens } };
|
|
1029
|
+
return next;
|
|
1030
|
+
}
|
|
1031
|
+
return messages;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
980
1034
|
// src/composer/summarize.ts
|
|
981
1035
|
var MAX_TRANSCRIPT_CHARS = 12e4;
|
|
982
1036
|
var MAX_SUMMARY_CHARS = 6e3;
|
|
@@ -1085,29 +1139,6 @@ var CONTEXT_KEEP_RECENT_CHARS = 24e3;
|
|
|
1085
1139
|
var CONTEXT_KEEP_RECENT_MESSAGES = 12;
|
|
1086
1140
|
var CONTEXT_MIN_MESSAGES = 10;
|
|
1087
1141
|
var SESSION_RESET_OCCUPANCY_TOKENS = 75e4;
|
|
1088
|
-
function estimateMessageChars(message) {
|
|
1089
|
-
let n = message.text.length + 16;
|
|
1090
|
-
for (const part of message.parts ?? []) {
|
|
1091
|
-
n += estimatePartChars(part);
|
|
1092
|
-
}
|
|
1093
|
-
return n;
|
|
1094
|
-
}
|
|
1095
|
-
function estimatePartChars(part) {
|
|
1096
|
-
switch (part.type) {
|
|
1097
|
-
case "text":
|
|
1098
|
-
case "thinking":
|
|
1099
|
-
return part.text.length;
|
|
1100
|
-
case "tool": {
|
|
1101
|
-
const input = part.input ? JSON.stringify(part.input) : "";
|
|
1102
|
-
return part.name.length + (part.description?.length ?? 0) + (part.detail?.length ?? 0) + (part.result?.length ?? 0) + input.length + 32;
|
|
1103
|
-
}
|
|
1104
|
-
default:
|
|
1105
|
-
return 0;
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
function estimateThreadChars(messages) {
|
|
1109
|
-
return messages.reduce((sum, m) => sum + estimateMessageChars(m), 0);
|
|
1110
|
-
}
|
|
1111
1142
|
function shouldCompactContext(messages, thresholds = {}) {
|
|
1112
1143
|
const maxChars = thresholds.maxChars ?? CONTEXT_COMPACT_CHARS;
|
|
1113
1144
|
const minMessages = thresholds.minMessages ?? CONTEXT_MIN_MESSAGES;
|
|
@@ -1244,8 +1275,11 @@ async function maybeCompactContext(thread, thresholds = {}, summarize = summariz
|
|
|
1244
1275
|
const { summary, method } = await summarize(transcript, {
|
|
1245
1276
|
cwd: thread.worktreePath
|
|
1246
1277
|
});
|
|
1247
|
-
|
|
1278
|
+
let messages = applyCompaction(thread.messages, summary, thresholds);
|
|
1248
1279
|
const resetSession = shouldResetSessionForOccupancy({ messages: thread.messages });
|
|
1280
|
+
if (resetSession) {
|
|
1281
|
+
messages = applyForwardOccupancy(messages);
|
|
1282
|
+
}
|
|
1249
1283
|
const next = {
|
|
1250
1284
|
...thread,
|
|
1251
1285
|
messages,
|
|
@@ -2955,7 +2989,7 @@ async function createThread(input, _onSetupLine) {
|
|
|
2955
2989
|
return readThread(thread.id) ?? thread;
|
|
2956
2990
|
}
|
|
2957
2991
|
async function listLinearIssues(agent, repoPath) {
|
|
2958
|
-
const { getAdapter: getAdapter2 } = await import("./agents-
|
|
2992
|
+
const { getAdapter: getAdapter2 } = await import("./agents-665S7Z3R.js");
|
|
2959
2993
|
await requireAgent(agent, { requireLinear: true });
|
|
2960
2994
|
const adapter = getAdapter2(agent);
|
|
2961
2995
|
if (!adapter.listLinearIssues) {
|
|
@@ -3352,7 +3386,7 @@ async function adoptThread(input) {
|
|
|
3352
3386
|
messages: input.messages ?? []
|
|
3353
3387
|
});
|
|
3354
3388
|
writeThread(thread);
|
|
3355
|
-
const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-
|
|
3389
|
+
const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-ALCTB65T.js");
|
|
3356
3390
|
await ensureWorkspace2(repoPath);
|
|
3357
3391
|
return thread;
|
|
3358
3392
|
}
|
|
@@ -5403,7 +5437,7 @@ function formatScheduledPrompt(name, prompt) {
|
|
|
5403
5437
|
${prompt}`;
|
|
5404
5438
|
}
|
|
5405
5439
|
async function defaultDeps() {
|
|
5406
|
-
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
5440
|
+
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-WEFXUHFX.js");
|
|
5407
5441
|
const orch = getOrchestrator2();
|
|
5408
5442
|
return {
|
|
5409
5443
|
findThread: (id) => findThreadByRef(id),
|
|
@@ -5679,7 +5713,7 @@ var Orchestrator = class {
|
|
|
5679
5713
|
if (thread.status === "archived") continue;
|
|
5680
5714
|
const handle = this.activeTurns.get(thread.id);
|
|
5681
5715
|
if (handle) {
|
|
5682
|
-
const pid =
|
|
5716
|
+
const pid = handle.pid;
|
|
5683
5717
|
if (typeof pid === "number" && pid > 0 && !isPidAlive(pid)) {
|
|
5684
5718
|
handle.kill();
|
|
5685
5719
|
}
|
|
@@ -6503,7 +6537,7 @@ var Orchestrator = class {
|
|
|
6503
6537
|
const stopped = writeLiveStatus(thread.id, "stopped") ?? readThread(thread.id) ?? thread;
|
|
6504
6538
|
if (stopped.status === "stopped") {
|
|
6505
6539
|
this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
|
|
6506
|
-
if (opts?.notifyParent !== false) {
|
|
6540
|
+
if (inFlight && opts?.notifyParent !== false) {
|
|
6507
6541
|
notifyParentOfChildHalt(stopped, "stopped", (id, prompt) => this.send(id, prompt));
|
|
6508
6542
|
}
|
|
6509
6543
|
}
|
|
@@ -7262,7 +7296,7 @@ var Orchestrator = class {
|
|
|
7262
7296
|
}
|
|
7263
7297
|
async archiveUnlocked(threadRef) {
|
|
7264
7298
|
const thread = this.requireThread(threadRef);
|
|
7265
|
-
this.stop(thread.id);
|
|
7299
|
+
this.stop(thread.id, { notifyParent: false });
|
|
7266
7300
|
this.releaseOrchestratorCaffeinate(thread);
|
|
7267
7301
|
if (isGlobalThread(thread)) {
|
|
7268
7302
|
const archived2 = setStatus(thread.id, "archived");
|
|
@@ -7290,7 +7324,7 @@ var Orchestrator = class {
|
|
|
7290
7324
|
this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
|
|
7291
7325
|
if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
|
|
7292
7326
|
try {
|
|
7293
|
-
const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-
|
|
7327
|
+
const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-ALCTB65T.js");
|
|
7294
7328
|
await ensureWorkspace2(thread.repoPath);
|
|
7295
7329
|
} catch {
|
|
7296
7330
|
}
|
|
@@ -7303,7 +7337,7 @@ var Orchestrator = class {
|
|
|
7303
7337
|
}
|
|
7304
7338
|
async purgeUnlocked(threadRef, opts) {
|
|
7305
7339
|
const thread = this.requireThread(threadRef);
|
|
7306
|
-
this.stop(thread.id);
|
|
7340
|
+
this.stop(thread.id, { notifyParent: false });
|
|
7307
7341
|
this.releaseOrchestratorCaffeinate(thread);
|
|
7308
7342
|
if (isGlobalThread(thread)) {
|
|
7309
7343
|
deleteThreadRecord(thread.id);
|
|
@@ -7344,7 +7378,7 @@ var Orchestrator = class {
|
|
|
7344
7378
|
`Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
|
|
7345
7379
|
);
|
|
7346
7380
|
}
|
|
7347
|
-
const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-
|
|
7381
|
+
const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-GXD2NGOZ.js");
|
|
7348
7382
|
const slug = thread.worktreePath.split("/").pop();
|
|
7349
7383
|
const dest = thread.worktreePath;
|
|
7350
7384
|
await withRepoGitLock(thread.repoPath, async () => {
|
|
@@ -7452,7 +7486,7 @@ async function startOrchestration(opts) {
|
|
|
7452
7486
|
sourceRef: "default",
|
|
7453
7487
|
...createOpts
|
|
7454
7488
|
}).catch(async () => {
|
|
7455
|
-
const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-
|
|
7489
|
+
const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-GXD2NGOZ.js");
|
|
7456
7490
|
const repo = await resolveRepoRoot2(repoPath);
|
|
7457
7491
|
const def = await resolveDefaultBranch2(repo);
|
|
7458
7492
|
return orch.createThread({
|
|
@@ -7462,7 +7496,7 @@ async function startOrchestration(opts) {
|
|
|
7462
7496
|
repoPath: repo
|
|
7463
7497
|
});
|
|
7464
7498
|
});
|
|
7465
|
-
const { updateThread: upd } = await import("./thread-store-
|
|
7499
|
+
const { updateThread: upd } = await import("./thread-store-WGASXXXR.js");
|
|
7466
7500
|
const updated = upd(thread.id, {
|
|
7467
7501
|
sourceType: "orchestration",
|
|
7468
7502
|
sourceRef: goal
|
|
@@ -7518,6 +7552,13 @@ export {
|
|
|
7518
7552
|
spawnAgentTurn,
|
|
7519
7553
|
AGENT_GIT_ACTIONS,
|
|
7520
7554
|
agentGitPrompt,
|
|
7555
|
+
CHARS_PER_CONTEXT_TOKEN,
|
|
7556
|
+
estimateMessageChars,
|
|
7557
|
+
estimateThreadChars,
|
|
7558
|
+
estimateOccupancyTokens,
|
|
7559
|
+
threadHasCompactedContext,
|
|
7560
|
+
forwardContextUsage,
|
|
7561
|
+
applyForwardOccupancy,
|
|
7521
7562
|
summarizeConversation,
|
|
7522
7563
|
extractiveSummary,
|
|
7523
7564
|
CONTEXT_COMPACT_CHARS,
|
|
@@ -7525,8 +7566,6 @@ export {
|
|
|
7525
7566
|
CONTEXT_KEEP_RECENT_MESSAGES,
|
|
7526
7567
|
CONTEXT_MIN_MESSAGES,
|
|
7527
7568
|
SESSION_RESET_OCCUPANCY_TOKENS,
|
|
7528
|
-
estimateMessageChars,
|
|
7529
|
-
estimateThreadChars,
|
|
7530
7569
|
shouldCompactContext,
|
|
7531
7570
|
splitForCompaction,
|
|
7532
7571
|
formatMessagesAsTranscript,
|
|
@@ -7,13 +7,13 @@ import {
|
|
|
7
7
|
enrichWorkspacesWithGithub,
|
|
8
8
|
ensureGlobalCoordinatorCwd,
|
|
9
9
|
formatWorkspaceInventory
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-7SYFWPOZ.js";
|
|
11
|
+
import "./chunk-DKXZCIB2.js";
|
|
12
12
|
import "./chunk-FKOIHGKV.js";
|
|
13
13
|
import "./chunk-GJBHOJCZ.js";
|
|
14
14
|
import "./chunk-4TR3HZFT.js";
|
|
15
15
|
import "./chunk-JT7R45JB.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-TUGKX5BD.js";
|
|
17
17
|
import "./chunk-77WWLBCI.js";
|
|
18
18
|
import "./chunk-QZQEXME2.js";
|
|
19
19
|
import "./chunk-DVM4ID64.js";
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
enrichWorkspacesWithGithub,
|
|
10
10
|
ensureGlobalCoordinatorCwd,
|
|
11
11
|
formatWorkspaceInventory
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-RTX3AY42.js";
|
|
13
|
+
import "./chunk-DJJ3DTT4.js";
|
|
14
14
|
import "./chunk-B3SJXYIJ.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-EUXOHTUK.js";
|
|
16
16
|
import "./chunk-KPIYENTF.js";
|
|
17
17
|
import "./chunk-GKKHXZCT.js";
|
|
18
18
|
import "./chunk-NSTQ6QKD.js";
|
|
@@ -17,11 +17,11 @@ import {
|
|
|
17
17
|
orchestratorSessionPoisonedByBuiltins,
|
|
18
18
|
slackCoordinatorSourceRef,
|
|
19
19
|
takenTeamSlugsForOrchestration
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-5XH5M6RA.js";
|
|
21
|
+
import "./chunk-RTX3AY42.js";
|
|
22
|
+
import "./chunk-DJJ3DTT4.js";
|
|
23
23
|
import "./chunk-B3SJXYIJ.js";
|
|
24
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-EUXOHTUK.js";
|
|
25
25
|
import "./chunk-KPIYENTF.js";
|
|
26
26
|
import "./chunk-GKKHXZCT.js";
|
|
27
27
|
import "./chunk-NSTQ6QKD.js";
|
|
@@ -15,14 +15,14 @@ import {
|
|
|
15
15
|
orchestratorSessionPoisonedByBuiltins,
|
|
16
16
|
slackCoordinatorSourceRef,
|
|
17
17
|
takenTeamSlugsForOrchestration
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-E2RE7P2S.js";
|
|
19
|
+
import "./chunk-7SYFWPOZ.js";
|
|
20
|
+
import "./chunk-DKXZCIB2.js";
|
|
21
21
|
import "./chunk-FKOIHGKV.js";
|
|
22
22
|
import "./chunk-GJBHOJCZ.js";
|
|
23
23
|
import "./chunk-4TR3HZFT.js";
|
|
24
24
|
import "./chunk-JT7R45JB.js";
|
|
25
|
-
import "./chunk-
|
|
25
|
+
import "./chunk-TUGKX5BD.js";
|
|
26
26
|
import "./chunk-77WWLBCI.js";
|
|
27
27
|
import {
|
|
28
28
|
globalAgentCwd
|