@sideboard-ai/core 0.1.342 → 0.1.343
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/{chunk-DZF25KTX.js → chunk-EDEYEYU6.js} +139 -69
- package/dist/{chunk-5HUR77ZH.js → chunk-KCZM7WZ3.js} +133 -65
- package/dist/index.cjs +140 -67
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +8 -4
- package/dist/mcp/run-stdio.cjs +136 -67
- package/dist/mcp/run-stdio.js +1 -1
- package/dist/{orchestrator-BPCM4OP3.js → orchestrator-RLFBFRAG.js} +1 -1
- package/dist/{orchestrator-HIWWPWL5.js → orchestrator-Y5JCAJGV.js} +1 -1
- package/package.json +1 -1
|
@@ -6253,49 +6253,6 @@ function expandComposerPrompt(worktreePath, prompt, opts) {
|
|
|
6253
6253
|
};
|
|
6254
6254
|
}
|
|
6255
6255
|
|
|
6256
|
-
// src/composer/agent-has-replied.ts
|
|
6257
|
-
function joinSteerPrompt(base, addition) {
|
|
6258
|
-
const next = addition.trim();
|
|
6259
|
-
if (!next) return base;
|
|
6260
|
-
const head = base.replace(/\s+$/, "");
|
|
6261
|
-
if (!head) return next;
|
|
6262
|
-
return `${head}
|
|
6263
|
-
${next}`;
|
|
6264
|
-
}
|
|
6265
|
-
function messagesWithRewrittenUserPrompt(messages, from, to) {
|
|
6266
|
-
if (from === to) return null;
|
|
6267
|
-
const next = messages.slice();
|
|
6268
|
-
for (let i = next.length - 1; i >= 0; i--) {
|
|
6269
|
-
const message = next[i];
|
|
6270
|
-
if (!message || message.origin === "continue" || message.role === "summary") continue;
|
|
6271
|
-
if (message.role !== "user") continue;
|
|
6272
|
-
if (message.text !== from) return null;
|
|
6273
|
-
next[i] = { ...message, text: to };
|
|
6274
|
-
return next;
|
|
6275
|
-
}
|
|
6276
|
-
return null;
|
|
6277
|
-
}
|
|
6278
|
-
function trailingUnansweredUserText(messages) {
|
|
6279
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
6280
|
-
const message = messages[i];
|
|
6281
|
-
if (!message || message.origin === "continue" || message.role === "summary") continue;
|
|
6282
|
-
if (message.role === "agent") {
|
|
6283
|
-
const text3 = (message.text ?? "").trim();
|
|
6284
|
-
if (text3 || (message.parts?.length ?? 0) > 0) return null;
|
|
6285
|
-
continue;
|
|
6286
|
-
}
|
|
6287
|
-
if (message.role === "user") return message.text;
|
|
6288
|
-
}
|
|
6289
|
-
return null;
|
|
6290
|
-
}
|
|
6291
|
-
function livePartsShowAgentReply(parts) {
|
|
6292
|
-
for (const part of parts) {
|
|
6293
|
-
if (part.type === "tool") return true;
|
|
6294
|
-
if ((part.type === "text" || part.type === "thinking") && part.text.trim()) return true;
|
|
6295
|
-
}
|
|
6296
|
-
return false;
|
|
6297
|
-
}
|
|
6298
|
-
|
|
6299
6256
|
// src/composer/consume-attachments.ts
|
|
6300
6257
|
function consumeComposerAttachments(thread) {
|
|
6301
6258
|
return {
|
|
@@ -6306,6 +6263,22 @@ function consumeComposerAttachments(thread) {
|
|
|
6306
6263
|
function takePendingTurnAttachments(thread) {
|
|
6307
6264
|
return [...thread.pendingTurnAttachments ?? []];
|
|
6308
6265
|
}
|
|
6266
|
+
function mergeTurnAttachments(base, extra) {
|
|
6267
|
+
const next = [];
|
|
6268
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6269
|
+
for (const att of [...base ?? [], ...extra ?? []]) {
|
|
6270
|
+
if (seen.has(att.id)) continue;
|
|
6271
|
+
seen.add(att.id);
|
|
6272
|
+
next.push(att);
|
|
6273
|
+
}
|
|
6274
|
+
return next;
|
|
6275
|
+
}
|
|
6276
|
+
function sameTurnAttachments(a, b) {
|
|
6277
|
+
const left = a ?? [];
|
|
6278
|
+
const right = b ?? [];
|
|
6279
|
+
if (left.length !== right.length) return false;
|
|
6280
|
+
return left.every((att, i) => att.id === right[i]?.id);
|
|
6281
|
+
}
|
|
6309
6282
|
function alignQueueAttachments(queueLength, existing) {
|
|
6310
6283
|
const next = (existing ?? []).slice(0, queueLength).map((slot) => [...slot ?? []]);
|
|
6311
6284
|
while (next.length < queueLength) next.push([]);
|
|
@@ -6348,15 +6321,95 @@ function shiftQueuedItem(queue, queueAttachments) {
|
|
|
6348
6321
|
};
|
|
6349
6322
|
}
|
|
6350
6323
|
|
|
6324
|
+
// src/composer/agent-has-replied.ts
|
|
6325
|
+
function joinSteerPrompt(base, addition) {
|
|
6326
|
+
const next = addition.trim();
|
|
6327
|
+
if (!next) return base;
|
|
6328
|
+
const head = base.replace(/\s+$/, "");
|
|
6329
|
+
if (!head) return next;
|
|
6330
|
+
return `${head}
|
|
6331
|
+
${next}`;
|
|
6332
|
+
}
|
|
6333
|
+
function messagesWithRewrittenUserPrompt(messages, from, to, attachments) {
|
|
6334
|
+
const extra = attachments ?? [];
|
|
6335
|
+
if (from === to && extra.length === 0) return null;
|
|
6336
|
+
const next = messages.slice();
|
|
6337
|
+
for (let i = next.length - 1; i >= 0; i--) {
|
|
6338
|
+
const message = next[i];
|
|
6339
|
+
if (!message || message.origin === "continue" || message.role === "summary") continue;
|
|
6340
|
+
if (message.role !== "user") continue;
|
|
6341
|
+
if (message.text !== from) return null;
|
|
6342
|
+
const merged = mergeTurnAttachments(message.attachments, extra);
|
|
6343
|
+
if (from === to && merged.length === (message.attachments?.length ?? 0)) return null;
|
|
6344
|
+
next[i] = {
|
|
6345
|
+
...message,
|
|
6346
|
+
text: to,
|
|
6347
|
+
...merged.length > 0 ? { attachments: merged } : {}
|
|
6348
|
+
};
|
|
6349
|
+
return next;
|
|
6350
|
+
}
|
|
6351
|
+
return null;
|
|
6352
|
+
}
|
|
6353
|
+
function trailingUnansweredUserText(messages) {
|
|
6354
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
6355
|
+
const message = messages[i];
|
|
6356
|
+
if (!message || message.origin === "continue" || message.role === "summary") continue;
|
|
6357
|
+
if (message.role === "agent") {
|
|
6358
|
+
const text3 = (message.text ?? "").trim();
|
|
6359
|
+
if (text3 || (message.parts?.length ?? 0) > 0) return null;
|
|
6360
|
+
continue;
|
|
6361
|
+
}
|
|
6362
|
+
if (message.role === "user") return message.text;
|
|
6363
|
+
}
|
|
6364
|
+
return null;
|
|
6365
|
+
}
|
|
6366
|
+
function livePartsShowAgentReply(parts) {
|
|
6367
|
+
for (const part of parts) {
|
|
6368
|
+
if (part.type === "tool") return true;
|
|
6369
|
+
if ((part.type === "text" || part.type === "thinking") && part.text.trim()) return true;
|
|
6370
|
+
}
|
|
6371
|
+
return false;
|
|
6372
|
+
}
|
|
6373
|
+
|
|
6351
6374
|
// src/orchestrator/enqueue-thread-send.ts
|
|
6352
6375
|
function resolveSendFollowUp(thread, requested) {
|
|
6353
6376
|
if (requested === "steer" || requested === "queue") return requested;
|
|
6354
6377
|
return isOrchestratorThread(thread) ? followUpBehavior() : "queue";
|
|
6355
6378
|
}
|
|
6356
|
-
function
|
|
6379
|
+
function beginOpenSteerDraft(text3) {
|
|
6380
|
+
return { text: text3, spawned: false, attachments: [] };
|
|
6381
|
+
}
|
|
6382
|
+
function seedOpenSteerAttachments(draft, sent) {
|
|
6383
|
+
if (!draft) return [...sent ?? []];
|
|
6384
|
+
draft.attachments = mergeTurnAttachments(sent, draft.attachments);
|
|
6385
|
+
return draft.attachments ?? [];
|
|
6386
|
+
}
|
|
6387
|
+
function openSteerTurnAttachments(draft, fallback, autoContinue) {
|
|
6388
|
+
if (autoContinue) return [];
|
|
6389
|
+
return [...draft?.attachments ?? fallback];
|
|
6390
|
+
}
|
|
6391
|
+
function promptAfterJoinedSteer(input) {
|
|
6392
|
+
if (input.draft) input.draft.spawned = true;
|
|
6393
|
+
return promptForJoinedSteer({
|
|
6394
|
+
threadId: input.threadId,
|
|
6395
|
+
promptText: input.promptText,
|
|
6396
|
+
latestPrompt: input.draft?.text ?? input.promptText,
|
|
6397
|
+
agentPrompt: input.agentPrompt,
|
|
6398
|
+
expandedPrompt: input.expandedPrompt,
|
|
6399
|
+
worktreePath: input.worktreePath,
|
|
6400
|
+
attachments: input.expandedAttachments,
|
|
6401
|
+
latestAttachments: openSteerTurnAttachments(
|
|
6402
|
+
input.draft,
|
|
6403
|
+
input.expandedAttachments,
|
|
6404
|
+
input.autoContinue
|
|
6405
|
+
),
|
|
6406
|
+
gitForge: input.gitForge
|
|
6407
|
+
});
|
|
6408
|
+
}
|
|
6409
|
+
function rewriteTrailingUserPrompt(threadId, from, to, attachments) {
|
|
6357
6410
|
const thread = readThread(threadId);
|
|
6358
6411
|
if (!thread) return;
|
|
6359
|
-
const messages = messagesWithRewrittenUserPrompt(thread.messages, from, to);
|
|
6412
|
+
const messages = messagesWithRewrittenUserPrompt(thread.messages, from, to, attachments);
|
|
6360
6413
|
if (!messages) return;
|
|
6361
6414
|
updateThread(threadId, { messages });
|
|
6362
6415
|
}
|
|
@@ -6371,12 +6424,18 @@ function reuseJoinedUserBubble(reused, threadId, messages, promptText) {
|
|
|
6371
6424
|
return false;
|
|
6372
6425
|
}
|
|
6373
6426
|
function promptForJoinedSteer(input) {
|
|
6374
|
-
|
|
6375
|
-
|
|
6427
|
+
const latestAttachments = input.latestAttachments ?? input.attachments;
|
|
6428
|
+
const textSame = input.latestPrompt === input.promptText;
|
|
6429
|
+
if (textSame && sameTurnAttachments(input.attachments, latestAttachments)) {
|
|
6430
|
+
return input.agentPrompt;
|
|
6431
|
+
}
|
|
6432
|
+
if (!textSame) {
|
|
6433
|
+
rewriteTrailingUserPrompt(input.threadId, input.promptText, input.latestPrompt);
|
|
6434
|
+
}
|
|
6376
6435
|
const { agentPrompt: expandedLatest } = expandComposerPrompt(
|
|
6377
6436
|
input.worktreePath,
|
|
6378
6437
|
expandCanonicalGitRequest(input.latestPrompt, { forge: input.gitForge }),
|
|
6379
|
-
{ attachments:
|
|
6438
|
+
{ attachments: latestAttachments }
|
|
6380
6439
|
);
|
|
6381
6440
|
return input.expandedPrompt && input.agentPrompt.endsWith(input.expandedPrompt) ? input.agentPrompt.slice(0, -input.expandedPrompt.length) + expandedLatest : `${input.agentPrompt}
|
|
6382
6441
|
|
|
@@ -6412,7 +6471,13 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
|
|
|
6412
6471
|
const combined = joinSteerPrompt(unanswered, prompt);
|
|
6413
6472
|
if (draft && !draft.spawned) {
|
|
6414
6473
|
draft.text = combined;
|
|
6415
|
-
|
|
6474
|
+
if (consumed.consumed.length > 0) {
|
|
6475
|
+
draft.attachments = mergeTurnAttachments(draft.attachments, consumed.consumed);
|
|
6476
|
+
}
|
|
6477
|
+
rewriteTrailingUserPrompt(current.id, unanswered, combined, consumed.consumed);
|
|
6478
|
+
if (explicit === void 0 && consumed.consumed.length > 0) {
|
|
6479
|
+
updateThread(current.id, { attachments: consumed.attachments });
|
|
6480
|
+
}
|
|
6416
6481
|
} else {
|
|
6417
6482
|
const queue = current.queue.slice();
|
|
6418
6483
|
queue[0] = combined;
|
|
@@ -6434,8 +6499,13 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
|
|
|
6434
6499
|
}
|
|
6435
6500
|
const promptToQueue = unanswered != null ? joinSteerPrompt(unanswered, prompt) : prompt;
|
|
6436
6501
|
if (unanswered != null) {
|
|
6437
|
-
if (draft)
|
|
6438
|
-
|
|
6502
|
+
if (draft) {
|
|
6503
|
+
draft.text = promptToQueue;
|
|
6504
|
+
if (consumed.consumed.length > 0) {
|
|
6505
|
+
draft.attachments = mergeTurnAttachments(draft.attachments, consumed.consumed);
|
|
6506
|
+
}
|
|
6507
|
+
}
|
|
6508
|
+
rewriteTrailingUserPrompt(current.id, unanswered, promptToQueue, consumed.consumed);
|
|
6439
6509
|
host.reusedUserPrompt.add(current.id);
|
|
6440
6510
|
}
|
|
6441
6511
|
const queued = appendQueuedItem(
|
|
@@ -7807,11 +7877,11 @@ function realDeps() {
|
|
|
7807
7877
|
parentIdForThread,
|
|
7808
7878
|
designatedId: designatedOrchestratorId,
|
|
7809
7879
|
send: async (threadId, prompt) => {
|
|
7810
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
7880
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-Y5JCAJGV.js");
|
|
7811
7881
|
await getOrchestrator2().send(threadId, prompt, { followUp: "queue" });
|
|
7812
7882
|
},
|
|
7813
7883
|
startOrchestration: async (prompt) => {
|
|
7814
|
-
const { startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
7884
|
+
const { startOrchestration: startOrchestration2 } = await import("./orchestrator-Y5JCAJGV.js");
|
|
7815
7885
|
const defaults = resolveOrchestratorDefaults();
|
|
7816
7886
|
await startOrchestration2({
|
|
7817
7887
|
goal: prompt,
|
|
@@ -7838,7 +7908,7 @@ function formatScheduledPrompt(name, prompt) {
|
|
|
7838
7908
|
${prompt}`;
|
|
7839
7909
|
}
|
|
7840
7910
|
async function defaultDeps() {
|
|
7841
|
-
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
7911
|
+
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-Y5JCAJGV.js");
|
|
7842
7912
|
const orch = getOrchestrator2();
|
|
7843
7913
|
return {
|
|
7844
7914
|
findThread: (id) => findThreadByRef(id),
|
|
@@ -8817,10 +8887,7 @@ var Orchestrator = class {
|
|
|
8817
8887
|
this.emit({ type: "status_changed", threadId, status: "running" });
|
|
8818
8888
|
this.emit({ type: "turn_started", threadId, prompt });
|
|
8819
8889
|
try {
|
|
8820
|
-
this.openSteerPrompt.set(threadId,
|
|
8821
|
-
text: typeof prompt === "string" ? prompt : "",
|
|
8822
|
-
spawned: false
|
|
8823
|
-
});
|
|
8890
|
+
this.openSteerPrompt.set(threadId, beginOpenSteerDraft(typeof prompt === "string" ? prompt : ""));
|
|
8824
8891
|
try {
|
|
8825
8892
|
const baseline = await captureTurnBaseline(thread.worktreePath);
|
|
8826
8893
|
if (baseline) this.turnBaselines.set(threadId, baseline);
|
|
@@ -8850,13 +8917,14 @@ var Orchestrator = class {
|
|
|
8850
8917
|
const autoContinue = isJobContinuePrompt(promptText) || promptText.startsWith("The previous agent process ended before it finished.");
|
|
8851
8918
|
const parked = takePendingTurnAttachments(thread);
|
|
8852
8919
|
const sentAttachments = !autoContinue && parked.length > 0 ? parked : void 0;
|
|
8920
|
+
const turnAttachments = seedOpenSteerAttachments(this.openSteerPrompt.get(threadId), sentAttachments);
|
|
8853
8921
|
if (!autoContinue) clearAgentBlock(threadId);
|
|
8854
8922
|
const shown = this.requireThread(threadId).messages;
|
|
8855
8923
|
if (!reuseJoinedUserBubble(this.reusedUserPrompt, threadId, shown, promptText)) {
|
|
8856
8924
|
appendMessage(threadId, {
|
|
8857
8925
|
role: "user",
|
|
8858
8926
|
text: promptText,
|
|
8859
|
-
...
|
|
8927
|
+
...turnAttachments.length > 0 ? { attachments: turnAttachments } : {},
|
|
8860
8928
|
...autoContinue ? { origin: "continue" } : {},
|
|
8861
8929
|
ts: (/* @__PURE__ */ new Date()).toISOString()
|
|
8862
8930
|
});
|
|
@@ -8886,11 +8954,12 @@ var Orchestrator = class {
|
|
|
8886
8954
|
thread = this.requireThread(threadId);
|
|
8887
8955
|
const turnOrigin = thread.worktreePath?.trim() ? await resolveOriginRemote(thread.worktreePath).catch(() => null) : null;
|
|
8888
8956
|
const gitPrompt = expandCanonicalGitRequest(promptText, { forge: turnOrigin?.forge });
|
|
8957
|
+
const expandedAttachments = openSteerTurnAttachments(this.openSteerPrompt.get(threadId), turnAttachments, autoContinue);
|
|
8889
8958
|
const { agentPrompt: expandedPrompt } = expandComposerPrompt(
|
|
8890
8959
|
thread.worktreePath,
|
|
8891
8960
|
gitPrompt,
|
|
8892
8961
|
{
|
|
8893
|
-
attachments:
|
|
8962
|
+
attachments: expandedAttachments
|
|
8894
8963
|
}
|
|
8895
8964
|
);
|
|
8896
8965
|
const slackInbound = /^(Slack DM|Slack @mention)(?:\n|$)/.test(
|
|
@@ -9058,16 +9127,15 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9058
9127
|
].filter(Boolean).join("\n\n---\n\n");
|
|
9059
9128
|
const stderrTail = [];
|
|
9060
9129
|
traceTurn("runTurn.beforeSpawn", { threadId, agent: fresh.agent });
|
|
9061
|
-
const
|
|
9062
|
-
|
|
9063
|
-
|
|
9130
|
+
const promptForAgent = promptAfterJoinedSteer({
|
|
9131
|
+
draft: this.openSteerPrompt.get(threadId),
|
|
9132
|
+
autoContinue,
|
|
9133
|
+
expandedAttachments,
|
|
9064
9134
|
threadId,
|
|
9065
9135
|
promptText,
|
|
9066
|
-
latestPrompt: steerDraft?.text ?? promptText,
|
|
9067
9136
|
agentPrompt,
|
|
9068
9137
|
expandedPrompt,
|
|
9069
9138
|
worktreePath: fresh.worktreePath,
|
|
9070
|
-
attachments: autoContinue ? [] : sentAttachments ?? [],
|
|
9071
9139
|
gitForge: turnOrigin?.forge
|
|
9072
9140
|
});
|
|
9073
9141
|
const handle = await spawnAgentTurn(
|
|
@@ -10935,18 +11003,20 @@ export {
|
|
|
10935
11003
|
discoverSkills,
|
|
10936
11004
|
readSkillBody,
|
|
10937
11005
|
expandComposerPrompt,
|
|
10938
|
-
joinSteerPrompt,
|
|
10939
|
-
messagesWithRewrittenUserPrompt,
|
|
10940
|
-
trailingUnansweredUserText,
|
|
10941
|
-
livePartsShowAgentReply,
|
|
10942
11006
|
consumeComposerAttachments,
|
|
10943
11007
|
takePendingTurnAttachments,
|
|
11008
|
+
mergeTurnAttachments,
|
|
11009
|
+
sameTurnAttachments,
|
|
10944
11010
|
alignQueueAttachments,
|
|
10945
11011
|
appendQueuedItem,
|
|
10946
11012
|
prependQueuedItem,
|
|
10947
11013
|
removeQueuedItem,
|
|
10948
11014
|
moveQueuedItemToFront,
|
|
10949
11015
|
shiftQueuedItem,
|
|
11016
|
+
joinSteerPrompt,
|
|
11017
|
+
messagesWithRewrittenUserPrompt,
|
|
11018
|
+
trailingUnansweredUserText,
|
|
11019
|
+
livePartsShowAgentReply,
|
|
10950
11020
|
resolveSendFollowUp,
|
|
10951
11021
|
formatCursorGitDirective,
|
|
10952
11022
|
formatEntireGitDirective,
|
|
@@ -5925,49 +5925,6 @@ function expandComposerPrompt(worktreePath, prompt, opts) {
|
|
|
5925
5925
|
};
|
|
5926
5926
|
}
|
|
5927
5927
|
|
|
5928
|
-
// src/composer/agent-has-replied.ts
|
|
5929
|
-
function joinSteerPrompt(base, addition) {
|
|
5930
|
-
const next = addition.trim();
|
|
5931
|
-
if (!next) return base;
|
|
5932
|
-
const head = base.replace(/\s+$/, "");
|
|
5933
|
-
if (!head) return next;
|
|
5934
|
-
return `${head}
|
|
5935
|
-
${next}`;
|
|
5936
|
-
}
|
|
5937
|
-
function messagesWithRewrittenUserPrompt(messages, from, to) {
|
|
5938
|
-
if (from === to) return null;
|
|
5939
|
-
const next = messages.slice();
|
|
5940
|
-
for (let i = next.length - 1; i >= 0; i--) {
|
|
5941
|
-
const message = next[i];
|
|
5942
|
-
if (!message || message.origin === "continue" || message.role === "summary") continue;
|
|
5943
|
-
if (message.role !== "user") continue;
|
|
5944
|
-
if (message.text !== from) return null;
|
|
5945
|
-
next[i] = { ...message, text: to };
|
|
5946
|
-
return next;
|
|
5947
|
-
}
|
|
5948
|
-
return null;
|
|
5949
|
-
}
|
|
5950
|
-
function trailingUnansweredUserText(messages) {
|
|
5951
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
5952
|
-
const message = messages[i];
|
|
5953
|
-
if (!message || message.origin === "continue" || message.role === "summary") continue;
|
|
5954
|
-
if (message.role === "agent") {
|
|
5955
|
-
const text3 = (message.text ?? "").trim();
|
|
5956
|
-
if (text3 || (message.parts?.length ?? 0) > 0) return null;
|
|
5957
|
-
continue;
|
|
5958
|
-
}
|
|
5959
|
-
if (message.role === "user") return message.text;
|
|
5960
|
-
}
|
|
5961
|
-
return null;
|
|
5962
|
-
}
|
|
5963
|
-
function livePartsShowAgentReply(parts) {
|
|
5964
|
-
for (const part of parts) {
|
|
5965
|
-
if (part.type === "tool") return true;
|
|
5966
|
-
if ((part.type === "text" || part.type === "thinking") && part.text.trim()) return true;
|
|
5967
|
-
}
|
|
5968
|
-
return false;
|
|
5969
|
-
}
|
|
5970
|
-
|
|
5971
5928
|
// src/composer/consume-attachments.ts
|
|
5972
5929
|
function consumeComposerAttachments(thread) {
|
|
5973
5930
|
return {
|
|
@@ -5978,6 +5935,22 @@ function consumeComposerAttachments(thread) {
|
|
|
5978
5935
|
function takePendingTurnAttachments(thread) {
|
|
5979
5936
|
return [...thread.pendingTurnAttachments ?? []];
|
|
5980
5937
|
}
|
|
5938
|
+
function mergeTurnAttachments(base, extra) {
|
|
5939
|
+
const next = [];
|
|
5940
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5941
|
+
for (const att of [...base ?? [], ...extra ?? []]) {
|
|
5942
|
+
if (seen.has(att.id)) continue;
|
|
5943
|
+
seen.add(att.id);
|
|
5944
|
+
next.push(att);
|
|
5945
|
+
}
|
|
5946
|
+
return next;
|
|
5947
|
+
}
|
|
5948
|
+
function sameTurnAttachments(a, b) {
|
|
5949
|
+
const left = a ?? [];
|
|
5950
|
+
const right = b ?? [];
|
|
5951
|
+
if (left.length !== right.length) return false;
|
|
5952
|
+
return left.every((att, i) => att.id === right[i]?.id);
|
|
5953
|
+
}
|
|
5981
5954
|
function alignQueueAttachments(queueLength, existing) {
|
|
5982
5955
|
const next = (existing ?? []).slice(0, queueLength).map((slot) => [...slot ?? []]);
|
|
5983
5956
|
while (next.length < queueLength) next.push([]);
|
|
@@ -6020,15 +5993,95 @@ function shiftQueuedItem(queue, queueAttachments) {
|
|
|
6020
5993
|
};
|
|
6021
5994
|
}
|
|
6022
5995
|
|
|
5996
|
+
// src/composer/agent-has-replied.ts
|
|
5997
|
+
function joinSteerPrompt(base, addition) {
|
|
5998
|
+
const next = addition.trim();
|
|
5999
|
+
if (!next) return base;
|
|
6000
|
+
const head = base.replace(/\s+$/, "");
|
|
6001
|
+
if (!head) return next;
|
|
6002
|
+
return `${head}
|
|
6003
|
+
${next}`;
|
|
6004
|
+
}
|
|
6005
|
+
function messagesWithRewrittenUserPrompt(messages, from, to, attachments) {
|
|
6006
|
+
const extra = attachments ?? [];
|
|
6007
|
+
if (from === to && extra.length === 0) return null;
|
|
6008
|
+
const next = messages.slice();
|
|
6009
|
+
for (let i = next.length - 1; i >= 0; i--) {
|
|
6010
|
+
const message = next[i];
|
|
6011
|
+
if (!message || message.origin === "continue" || message.role === "summary") continue;
|
|
6012
|
+
if (message.role !== "user") continue;
|
|
6013
|
+
if (message.text !== from) return null;
|
|
6014
|
+
const merged = mergeTurnAttachments(message.attachments, extra);
|
|
6015
|
+
if (from === to && merged.length === (message.attachments?.length ?? 0)) return null;
|
|
6016
|
+
next[i] = {
|
|
6017
|
+
...message,
|
|
6018
|
+
text: to,
|
|
6019
|
+
...merged.length > 0 ? { attachments: merged } : {}
|
|
6020
|
+
};
|
|
6021
|
+
return next;
|
|
6022
|
+
}
|
|
6023
|
+
return null;
|
|
6024
|
+
}
|
|
6025
|
+
function trailingUnansweredUserText(messages) {
|
|
6026
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
6027
|
+
const message = messages[i];
|
|
6028
|
+
if (!message || message.origin === "continue" || message.role === "summary") continue;
|
|
6029
|
+
if (message.role === "agent") {
|
|
6030
|
+
const text3 = (message.text ?? "").trim();
|
|
6031
|
+
if (text3 || (message.parts?.length ?? 0) > 0) return null;
|
|
6032
|
+
continue;
|
|
6033
|
+
}
|
|
6034
|
+
if (message.role === "user") return message.text;
|
|
6035
|
+
}
|
|
6036
|
+
return null;
|
|
6037
|
+
}
|
|
6038
|
+
function livePartsShowAgentReply(parts) {
|
|
6039
|
+
for (const part of parts) {
|
|
6040
|
+
if (part.type === "tool") return true;
|
|
6041
|
+
if ((part.type === "text" || part.type === "thinking") && part.text.trim()) return true;
|
|
6042
|
+
}
|
|
6043
|
+
return false;
|
|
6044
|
+
}
|
|
6045
|
+
|
|
6023
6046
|
// src/orchestrator/enqueue-thread-send.ts
|
|
6024
6047
|
function resolveSendFollowUp(thread, requested) {
|
|
6025
6048
|
if (requested === "steer" || requested === "queue") return requested;
|
|
6026
6049
|
return isOrchestratorThread(thread) ? followUpBehavior() : "queue";
|
|
6027
6050
|
}
|
|
6028
|
-
function
|
|
6051
|
+
function beginOpenSteerDraft(text3) {
|
|
6052
|
+
return { text: text3, spawned: false, attachments: [] };
|
|
6053
|
+
}
|
|
6054
|
+
function seedOpenSteerAttachments(draft, sent) {
|
|
6055
|
+
if (!draft) return [...sent ?? []];
|
|
6056
|
+
draft.attachments = mergeTurnAttachments(sent, draft.attachments);
|
|
6057
|
+
return draft.attachments ?? [];
|
|
6058
|
+
}
|
|
6059
|
+
function openSteerTurnAttachments(draft, fallback, autoContinue) {
|
|
6060
|
+
if (autoContinue) return [];
|
|
6061
|
+
return [...draft?.attachments ?? fallback];
|
|
6062
|
+
}
|
|
6063
|
+
function promptAfterJoinedSteer(input) {
|
|
6064
|
+
if (input.draft) input.draft.spawned = true;
|
|
6065
|
+
return promptForJoinedSteer({
|
|
6066
|
+
threadId: input.threadId,
|
|
6067
|
+
promptText: input.promptText,
|
|
6068
|
+
latestPrompt: input.draft?.text ?? input.promptText,
|
|
6069
|
+
agentPrompt: input.agentPrompt,
|
|
6070
|
+
expandedPrompt: input.expandedPrompt,
|
|
6071
|
+
worktreePath: input.worktreePath,
|
|
6072
|
+
attachments: input.expandedAttachments,
|
|
6073
|
+
latestAttachments: openSteerTurnAttachments(
|
|
6074
|
+
input.draft,
|
|
6075
|
+
input.expandedAttachments,
|
|
6076
|
+
input.autoContinue
|
|
6077
|
+
),
|
|
6078
|
+
gitForge: input.gitForge
|
|
6079
|
+
});
|
|
6080
|
+
}
|
|
6081
|
+
function rewriteTrailingUserPrompt(threadId, from, to, attachments) {
|
|
6029
6082
|
const thread = readThread(threadId);
|
|
6030
6083
|
if (!thread) return;
|
|
6031
|
-
const messages = messagesWithRewrittenUserPrompt(thread.messages, from, to);
|
|
6084
|
+
const messages = messagesWithRewrittenUserPrompt(thread.messages, from, to, attachments);
|
|
6032
6085
|
if (!messages) return;
|
|
6033
6086
|
updateThread(threadId, { messages });
|
|
6034
6087
|
}
|
|
@@ -6043,12 +6096,18 @@ function reuseJoinedUserBubble(reused, threadId, messages, promptText) {
|
|
|
6043
6096
|
return false;
|
|
6044
6097
|
}
|
|
6045
6098
|
function promptForJoinedSteer(input) {
|
|
6046
|
-
|
|
6047
|
-
|
|
6099
|
+
const latestAttachments = input.latestAttachments ?? input.attachments;
|
|
6100
|
+
const textSame = input.latestPrompt === input.promptText;
|
|
6101
|
+
if (textSame && sameTurnAttachments(input.attachments, latestAttachments)) {
|
|
6102
|
+
return input.agentPrompt;
|
|
6103
|
+
}
|
|
6104
|
+
if (!textSame) {
|
|
6105
|
+
rewriteTrailingUserPrompt(input.threadId, input.promptText, input.latestPrompt);
|
|
6106
|
+
}
|
|
6048
6107
|
const { agentPrompt: expandedLatest } = expandComposerPrompt(
|
|
6049
6108
|
input.worktreePath,
|
|
6050
6109
|
expandCanonicalGitRequest(input.latestPrompt, { forge: input.gitForge }),
|
|
6051
|
-
{ attachments:
|
|
6110
|
+
{ attachments: latestAttachments }
|
|
6052
6111
|
);
|
|
6053
6112
|
return input.expandedPrompt && input.agentPrompt.endsWith(input.expandedPrompt) ? input.agentPrompt.slice(0, -input.expandedPrompt.length) + expandedLatest : `${input.agentPrompt}
|
|
6054
6113
|
|
|
@@ -6084,7 +6143,13 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
|
|
|
6084
6143
|
const combined = joinSteerPrompt(unanswered, prompt);
|
|
6085
6144
|
if (draft && !draft.spawned) {
|
|
6086
6145
|
draft.text = combined;
|
|
6087
|
-
|
|
6146
|
+
if (consumed.consumed.length > 0) {
|
|
6147
|
+
draft.attachments = mergeTurnAttachments(draft.attachments, consumed.consumed);
|
|
6148
|
+
}
|
|
6149
|
+
rewriteTrailingUserPrompt(current.id, unanswered, combined, consumed.consumed);
|
|
6150
|
+
if (explicit === void 0 && consumed.consumed.length > 0) {
|
|
6151
|
+
updateThread(current.id, { attachments: consumed.attachments });
|
|
6152
|
+
}
|
|
6088
6153
|
} else {
|
|
6089
6154
|
const queue = current.queue.slice();
|
|
6090
6155
|
queue[0] = combined;
|
|
@@ -6106,8 +6171,13 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
|
|
|
6106
6171
|
}
|
|
6107
6172
|
const promptToQueue = unanswered != null ? joinSteerPrompt(unanswered, prompt) : prompt;
|
|
6108
6173
|
if (unanswered != null) {
|
|
6109
|
-
if (draft)
|
|
6110
|
-
|
|
6174
|
+
if (draft) {
|
|
6175
|
+
draft.text = promptToQueue;
|
|
6176
|
+
if (consumed.consumed.length > 0) {
|
|
6177
|
+
draft.attachments = mergeTurnAttachments(draft.attachments, consumed.consumed);
|
|
6178
|
+
}
|
|
6179
|
+
}
|
|
6180
|
+
rewriteTrailingUserPrompt(current.id, unanswered, promptToQueue, consumed.consumed);
|
|
6111
6181
|
host.reusedUserPrompt.add(current.id);
|
|
6112
6182
|
}
|
|
6113
6183
|
const queued = appendQueuedItem(
|
|
@@ -7457,11 +7527,11 @@ function realDeps() {
|
|
|
7457
7527
|
parentIdForThread,
|
|
7458
7528
|
designatedId: designatedOrchestratorId,
|
|
7459
7529
|
send: async (threadId, prompt) => {
|
|
7460
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
7530
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-RLFBFRAG.js");
|
|
7461
7531
|
await getOrchestrator2().send(threadId, prompt, { followUp: "queue" });
|
|
7462
7532
|
},
|
|
7463
7533
|
startOrchestration: async (prompt) => {
|
|
7464
|
-
const { startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
7534
|
+
const { startOrchestration: startOrchestration2 } = await import("./orchestrator-RLFBFRAG.js");
|
|
7465
7535
|
const defaults = resolveOrchestratorDefaults();
|
|
7466
7536
|
await startOrchestration2({
|
|
7467
7537
|
goal: prompt,
|
|
@@ -7488,7 +7558,7 @@ function formatScheduledPrompt(name, prompt) {
|
|
|
7488
7558
|
${prompt}`;
|
|
7489
7559
|
}
|
|
7490
7560
|
async function defaultDeps() {
|
|
7491
|
-
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
7561
|
+
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-RLFBFRAG.js");
|
|
7492
7562
|
const orch = getOrchestrator2();
|
|
7493
7563
|
return {
|
|
7494
7564
|
findThread: (id) => findThreadByRef(id),
|
|
@@ -8467,10 +8537,7 @@ var Orchestrator = class {
|
|
|
8467
8537
|
this.emit({ type: "status_changed", threadId, status: "running" });
|
|
8468
8538
|
this.emit({ type: "turn_started", threadId, prompt });
|
|
8469
8539
|
try {
|
|
8470
|
-
this.openSteerPrompt.set(threadId,
|
|
8471
|
-
text: typeof prompt === "string" ? prompt : "",
|
|
8472
|
-
spawned: false
|
|
8473
|
-
});
|
|
8540
|
+
this.openSteerPrompt.set(threadId, beginOpenSteerDraft(typeof prompt === "string" ? prompt : ""));
|
|
8474
8541
|
try {
|
|
8475
8542
|
const baseline = await captureTurnBaseline(thread.worktreePath);
|
|
8476
8543
|
if (baseline) this.turnBaselines.set(threadId, baseline);
|
|
@@ -8500,13 +8567,14 @@ var Orchestrator = class {
|
|
|
8500
8567
|
const autoContinue = isJobContinuePrompt(promptText) || promptText.startsWith("The previous agent process ended before it finished.");
|
|
8501
8568
|
const parked = takePendingTurnAttachments(thread);
|
|
8502
8569
|
const sentAttachments = !autoContinue && parked.length > 0 ? parked : void 0;
|
|
8570
|
+
const turnAttachments = seedOpenSteerAttachments(this.openSteerPrompt.get(threadId), sentAttachments);
|
|
8503
8571
|
if (!autoContinue) clearAgentBlock(threadId);
|
|
8504
8572
|
const shown = this.requireThread(threadId).messages;
|
|
8505
8573
|
if (!reuseJoinedUserBubble(this.reusedUserPrompt, threadId, shown, promptText)) {
|
|
8506
8574
|
appendMessage(threadId, {
|
|
8507
8575
|
role: "user",
|
|
8508
8576
|
text: promptText,
|
|
8509
|
-
...
|
|
8577
|
+
...turnAttachments.length > 0 ? { attachments: turnAttachments } : {},
|
|
8510
8578
|
...autoContinue ? { origin: "continue" } : {},
|
|
8511
8579
|
ts: (/* @__PURE__ */ new Date()).toISOString()
|
|
8512
8580
|
});
|
|
@@ -8536,11 +8604,12 @@ var Orchestrator = class {
|
|
|
8536
8604
|
thread = this.requireThread(threadId);
|
|
8537
8605
|
const turnOrigin = thread.worktreePath?.trim() ? await resolveOriginRemote(thread.worktreePath).catch(() => null) : null;
|
|
8538
8606
|
const gitPrompt = expandCanonicalGitRequest(promptText, { forge: turnOrigin?.forge });
|
|
8607
|
+
const expandedAttachments = openSteerTurnAttachments(this.openSteerPrompt.get(threadId), turnAttachments, autoContinue);
|
|
8539
8608
|
const { agentPrompt: expandedPrompt } = expandComposerPrompt(
|
|
8540
8609
|
thread.worktreePath,
|
|
8541
8610
|
gitPrompt,
|
|
8542
8611
|
{
|
|
8543
|
-
attachments:
|
|
8612
|
+
attachments: expandedAttachments
|
|
8544
8613
|
}
|
|
8545
8614
|
);
|
|
8546
8615
|
const slackInbound = /^(Slack DM|Slack @mention)(?:\n|$)/.test(
|
|
@@ -8708,16 +8777,15 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
8708
8777
|
].filter(Boolean).join("\n\n---\n\n");
|
|
8709
8778
|
const stderrTail = [];
|
|
8710
8779
|
traceTurn("runTurn.beforeSpawn", { threadId, agent: fresh.agent });
|
|
8711
|
-
const
|
|
8712
|
-
|
|
8713
|
-
|
|
8780
|
+
const promptForAgent = promptAfterJoinedSteer({
|
|
8781
|
+
draft: this.openSteerPrompt.get(threadId),
|
|
8782
|
+
autoContinue,
|
|
8783
|
+
expandedAttachments,
|
|
8714
8784
|
threadId,
|
|
8715
8785
|
promptText,
|
|
8716
|
-
latestPrompt: steerDraft?.text ?? promptText,
|
|
8717
8786
|
agentPrompt,
|
|
8718
8787
|
expandedPrompt,
|
|
8719
8788
|
worktreePath: fresh.worktreePath,
|
|
8720
|
-
attachments: autoContinue ? [] : sentAttachments ?? [],
|
|
8721
8789
|
gitForge: turnOrigin?.forge
|
|
8722
8790
|
});
|
|
8723
8791
|
const handle = await spawnAgentTurn(
|