@buildautomaton/cli 0.1.62 → 0.1.63
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/cli.js +5 -355
- package/dist/cli.js.map +4 -4
- package/dist/index.js +5 -355
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23514,7 +23514,6 @@ var StoryCheckpointSummarySchema = CheckpointSummarySchema.extend({
|
|
|
23514
23514
|
|
|
23515
23515
|
// ../types/src/sessions.ts
|
|
23516
23516
|
init_zod();
|
|
23517
|
-
var BUILTIN_SESSION_CHANGE_SUMMARY_FOLLOW_UP_CATALOG_PROMPT_ID = "__builtin_change_summary__";
|
|
23518
23517
|
var SessionMetaSchema = external_exports.object({
|
|
23519
23518
|
sessionId: external_exports.string(),
|
|
23520
23519
|
workspaceId: external_exports.string(),
|
|
@@ -23647,146 +23646,6 @@ function buildPlanningSessionFollowUpAgentPrompt(userPrompt, existingTodos) {
|
|
|
23647
23646
|
].join("\n");
|
|
23648
23647
|
}
|
|
23649
23648
|
|
|
23650
|
-
// ../types/src/change-summary-path.ts
|
|
23651
|
-
function normalizeRepoRelativePath(p) {
|
|
23652
|
-
let t = p.trim().replace(/\\/g, "/");
|
|
23653
|
-
while (t.startsWith("./")) t = t.slice(2);
|
|
23654
|
-
return t.replace(/\/+/g, "/");
|
|
23655
|
-
}
|
|
23656
|
-
function resolveChangeSummaryPathAgainstAllowed(rawPath, allowed) {
|
|
23657
|
-
const trimmed2 = rawPath.trim();
|
|
23658
|
-
if (!trimmed2) return null;
|
|
23659
|
-
if (allowed.has(trimmed2)) return trimmed2;
|
|
23660
|
-
const n = normalizeRepoRelativePath(trimmed2);
|
|
23661
|
-
if (allowed.has(n)) return n;
|
|
23662
|
-
for (const a of allowed) {
|
|
23663
|
-
if (normalizeRepoRelativePath(a) === n) return a;
|
|
23664
|
-
}
|
|
23665
|
-
return null;
|
|
23666
|
-
}
|
|
23667
|
-
|
|
23668
|
-
// ../types/src/parse-change-summary-json.ts
|
|
23669
|
-
function clampSummaryToAtMostTwoLines(summary) {
|
|
23670
|
-
const lines = summary.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
|
|
23671
|
-
return lines.slice(0, 2).join("\n");
|
|
23672
|
-
}
|
|
23673
|
-
function parseChangeSummaryJson(raw, allowedPaths, options) {
|
|
23674
|
-
if (raw == null || raw.trim() === "") return [];
|
|
23675
|
-
let text = raw.trim();
|
|
23676
|
-
const fence = text.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
23677
|
-
if (fence?.[1]) text = fence[1].trim();
|
|
23678
|
-
let parsed;
|
|
23679
|
-
try {
|
|
23680
|
-
parsed = JSON.parse(text);
|
|
23681
|
-
} catch {
|
|
23682
|
-
const start = text.indexOf("[");
|
|
23683
|
-
const end = text.lastIndexOf("]");
|
|
23684
|
-
if (start < 0 || end <= start) return [];
|
|
23685
|
-
try {
|
|
23686
|
-
parsed = JSON.parse(text.slice(start, end + 1));
|
|
23687
|
-
} catch {
|
|
23688
|
-
return [];
|
|
23689
|
-
}
|
|
23690
|
-
}
|
|
23691
|
-
const rows = [];
|
|
23692
|
-
let arr = [];
|
|
23693
|
-
if (Array.isArray(parsed)) {
|
|
23694
|
-
arr = parsed;
|
|
23695
|
-
} else if (parsed && typeof parsed === "object" && Array.isArray(parsed.files)) {
|
|
23696
|
-
arr = parsed.files;
|
|
23697
|
-
}
|
|
23698
|
-
const skip = options?.skipPathAllowlist === true;
|
|
23699
|
-
for (const item of arr) {
|
|
23700
|
-
if (!item || typeof item !== "object") continue;
|
|
23701
|
-
const o = item;
|
|
23702
|
-
const rawPath = typeof o.path === "string" ? o.path.trim() : "";
|
|
23703
|
-
const summary = typeof o.summary === "string" ? o.summary.trim() : "";
|
|
23704
|
-
if (!rawPath || !summary) continue;
|
|
23705
|
-
const path79 = skip ? normalizeRepoRelativePath(rawPath) || rawPath : resolveChangeSummaryPathAgainstAllowed(rawPath, allowedPaths);
|
|
23706
|
-
if (!path79) continue;
|
|
23707
|
-
rows.push({ path: path79, summary: clampSummaryToAtMostTwoLines(summary) });
|
|
23708
|
-
}
|
|
23709
|
-
return rows;
|
|
23710
|
-
}
|
|
23711
|
-
|
|
23712
|
-
// ../types/src/build-change-summary-prompt.ts
|
|
23713
|
-
var PATCH_PREVIEW_MAX = 12e3;
|
|
23714
|
-
function clip(s, max) {
|
|
23715
|
-
if (s.length <= max) return s;
|
|
23716
|
-
return `${s.slice(0, max)}
|
|
23717
|
-
|
|
23718
|
-
\u2026(truncated, ${s.length - max} more characters)`;
|
|
23719
|
-
}
|
|
23720
|
-
function buildSessionChangeSummaryPrompt(files) {
|
|
23721
|
-
const lines = [
|
|
23722
|
-
"You are the same agent that produced the changes below. Summarize **your own** edits so a reader can scan them quickly.",
|
|
23723
|
-
"",
|
|
23724
|
-
"Write in second person (you / your): what you changed in each path and why it matters.",
|
|
23725
|
-
"",
|
|
23726
|
-
"Each summary must be **very concise**: **one line** of plain text, or **at most two short lines** (use a single line break between the two if needed). No bullets, no paragraphs.",
|
|
23727
|
-
"",
|
|
23728
|
-
"## How to format your reply (machine parsing)",
|
|
23729
|
-
"",
|
|
23730
|
-
"- Put the machine-readable part **only** inside a **markdown fenced code block** whose opening fence is exactly ```json on its own line. Close the block with ``` on its own line after the JSON.",
|
|
23731
|
-
"- Inside that fence: **nothing except** one valid JSON value \u2014 the array described below. No trailing commentary inside the fence.",
|
|
23732
|
-
"- **Do not** attach prose to the JSON on the same line (wrong: `Only one file\u2026page.tsx.[{\u2026}]`). Wrong: any sentence that ends with `.` immediately before `[`. Put a blank line before the ```json line.",
|
|
23733
|
-
"- If you add optional plain English before the fence (e.g. one short sentence), keep it **separate**: end that sentence, blank line, then ```json.",
|
|
23734
|
-
'- In each `"summary"` string, avoid raw double-quote characters, or escape them as `\\"` so the JSON parses.',
|
|
23735
|
-
"",
|
|
23736
|
-
"JSON shape **inside the fence** (array only):",
|
|
23737
|
-
'[{"path":"<file path exactly as given>","summary":"<one line, or two short lines separated by \\n>"}]',
|
|
23738
|
-
"",
|
|
23739
|
-
"Rules:",
|
|
23740
|
-
"- Include **exactly one** object per file path listed below (same path strings).",
|
|
23741
|
-
"- If a path is a removed directory, state briefly what you removed.",
|
|
23742
|
-
"- Do not invent paths; use only the paths provided.",
|
|
23743
|
-
"",
|
|
23744
|
-
"## Files you changed",
|
|
23745
|
-
""
|
|
23746
|
-
];
|
|
23747
|
-
for (const f of files) {
|
|
23748
|
-
lines.push(`### ${f.path}`);
|
|
23749
|
-
if (f.directoryRemoved) {
|
|
23750
|
-
lines.push("(directory removed)");
|
|
23751
|
-
lines.push("");
|
|
23752
|
-
continue;
|
|
23753
|
-
}
|
|
23754
|
-
if (f.patchContent && f.patchContent.trim() !== "") {
|
|
23755
|
-
lines.push("```diff");
|
|
23756
|
-
lines.push(clip(f.patchContent.trim(), PATCH_PREVIEW_MAX));
|
|
23757
|
-
lines.push("```");
|
|
23758
|
-
} else if (f.oldText != null || f.newText != null) {
|
|
23759
|
-
const oldT = (f.oldText ?? "").trim();
|
|
23760
|
-
const newT = (f.newText ?? "").trim();
|
|
23761
|
-
lines.push("Previous snippet:", clip(oldT, 6e3));
|
|
23762
|
-
lines.push("New snippet:", clip(newT, 6e3));
|
|
23763
|
-
} else {
|
|
23764
|
-
lines.push("(no diff body stored for this path)");
|
|
23765
|
-
}
|
|
23766
|
-
lines.push("");
|
|
23767
|
-
}
|
|
23768
|
-
return lines.join("\n");
|
|
23769
|
-
}
|
|
23770
|
-
|
|
23771
|
-
// ../types/src/dedupe-session-file-changes-by-path.ts
|
|
23772
|
-
function defaultRichness(c) {
|
|
23773
|
-
const patch = typeof c.patchContent === "string" ? c.patchContent.length : 0;
|
|
23774
|
-
const nt = typeof c.newText === "string" ? c.newText.length : 0;
|
|
23775
|
-
const ot = typeof c.oldText === "string" ? c.oldText.length : 0;
|
|
23776
|
-
const dir = c.directoryRemoved === true ? 8 : 0;
|
|
23777
|
-
return (patch > 0 ? 4 : 0) + (nt > 0 ? 2 : 0) + (ot > 0 ? 1 : 0) + dir;
|
|
23778
|
-
}
|
|
23779
|
-
function dedupeSessionFileChangesByPath(items, richness = (item) => defaultRichness(item)) {
|
|
23780
|
-
const byPath = /* @__PURE__ */ new Map();
|
|
23781
|
-
for (const item of items) {
|
|
23782
|
-
const p = typeof item.path === "string" ? item.path.trim() : "";
|
|
23783
|
-
if (!p) continue;
|
|
23784
|
-
const prev = byPath.get(p);
|
|
23785
|
-
if (!prev || richness(item) >= richness(prev)) byPath.set(p, item);
|
|
23786
|
-
}
|
|
23787
|
-
return Array.from(byPath.entries()).sort(([a], [b]) => a.localeCompare(b)).map(([, v]) => v);
|
|
23788
|
-
}
|
|
23789
|
-
|
|
23790
23649
|
// ../types/src/diff/line-diff.ts
|
|
23791
23650
|
function normalizeDiffLineText(line) {
|
|
23792
23651
|
return line.replace(/\r$/, "").replace(/\s*\\s*$/, "");
|
|
@@ -25327,7 +25186,7 @@ function installBridgeProcessResilience() {
|
|
|
25327
25186
|
}
|
|
25328
25187
|
|
|
25329
25188
|
// src/cli-version.ts
|
|
25330
|
-
var CLI_VERSION = "0.1.
|
|
25189
|
+
var CLI_VERSION = "0.1.63".length > 0 ? "0.1.63" : "0.0.0-dev";
|
|
25331
25190
|
|
|
25332
25191
|
// src/connection/heartbeat/constants.ts
|
|
25333
25192
|
var BRIDGE_APP_HEARTBEAT_INTERVAL_MS = 1e4;
|
|
@@ -32852,102 +32711,6 @@ async function collectTurnGitDiffFromPreTurnSnapshot(options) {
|
|
|
32852
32711
|
});
|
|
32853
32712
|
}
|
|
32854
32713
|
|
|
32855
|
-
// src/agents/acp/put-summarize-change-summaries.ts
|
|
32856
|
-
async function putEncryptedChangeSummaryRows(params) {
|
|
32857
|
-
const base = params.apiBaseUrl.replace(/\/+$/, "");
|
|
32858
|
-
const entries = params.rows.map(({ path: path79, summary }) => {
|
|
32859
|
-
const enc = params.e2ee.encryptFields({ summary }, ["summary"]);
|
|
32860
|
-
return { path: path79, summary: JSON.stringify(enc) };
|
|
32861
|
-
});
|
|
32862
|
-
const res = await fetch(
|
|
32863
|
-
`${base}/internal/sessions/${encodeURIComponent(params.sessionId)}/follow-ups/summarize-changes`,
|
|
32864
|
-
{
|
|
32865
|
-
method: "PUT",
|
|
32866
|
-
headers: {
|
|
32867
|
-
Authorization: `Bearer ${params.authToken}`,
|
|
32868
|
-
"Content-Type": "application/json"
|
|
32869
|
-
},
|
|
32870
|
-
body: JSON.stringify({ entries })
|
|
32871
|
-
}
|
|
32872
|
-
);
|
|
32873
|
-
if (!res.ok) {
|
|
32874
|
-
const t = await res.text();
|
|
32875
|
-
throw new Error(`PUT summarize-changes summaries failed ${res.status}: ${t.slice(0, 500)}`);
|
|
32876
|
-
}
|
|
32877
|
-
}
|
|
32878
|
-
|
|
32879
|
-
// src/agents/acp/maybe-upload-e2ee-session-change-summaries.ts
|
|
32880
|
-
async function maybeUploadE2eeSessionChangeSummariesAfterAgentSuccess(params) {
|
|
32881
|
-
const {
|
|
32882
|
-
sessionId,
|
|
32883
|
-
runId,
|
|
32884
|
-
resultSuccess,
|
|
32885
|
-
output,
|
|
32886
|
-
e2ee,
|
|
32887
|
-
cloudApiBaseUrl,
|
|
32888
|
-
getCloudAccessToken,
|
|
32889
|
-
followUpCatalogPromptId,
|
|
32890
|
-
sessionChangeSummaryFilePaths,
|
|
32891
|
-
log: log2
|
|
32892
|
-
} = params;
|
|
32893
|
-
const outputStr = typeof output === "string" ? output : "";
|
|
32894
|
-
if (!sessionId) {
|
|
32895
|
-
return;
|
|
32896
|
-
}
|
|
32897
|
-
if (!runId) {
|
|
32898
|
-
return;
|
|
32899
|
-
}
|
|
32900
|
-
if (!resultSuccess) {
|
|
32901
|
-
return;
|
|
32902
|
-
}
|
|
32903
|
-
if (!e2ee) {
|
|
32904
|
-
return;
|
|
32905
|
-
}
|
|
32906
|
-
if (!cloudApiBaseUrl) {
|
|
32907
|
-
return;
|
|
32908
|
-
}
|
|
32909
|
-
if (!getCloudAccessToken) {
|
|
32910
|
-
return;
|
|
32911
|
-
}
|
|
32912
|
-
if (followUpCatalogPromptId !== BUILTIN_SESSION_CHANGE_SUMMARY_FOLLOW_UP_CATALOG_PROMPT_ID) {
|
|
32913
|
-
return;
|
|
32914
|
-
}
|
|
32915
|
-
if (!sessionChangeSummaryFilePaths || sessionChangeSummaryFilePaths.length === 0) {
|
|
32916
|
-
return;
|
|
32917
|
-
}
|
|
32918
|
-
if (outputStr.trim() === "") {
|
|
32919
|
-
return;
|
|
32920
|
-
}
|
|
32921
|
-
const allowed = /* @__PURE__ */ new Set();
|
|
32922
|
-
for (const p of sessionChangeSummaryFilePaths) {
|
|
32923
|
-
const t = p.trim();
|
|
32924
|
-
if (!t) continue;
|
|
32925
|
-
allowed.add(t);
|
|
32926
|
-
allowed.add(normalizeRepoRelativePath(t));
|
|
32927
|
-
}
|
|
32928
|
-
const rows = parseChangeSummaryJson(outputStr, allowed);
|
|
32929
|
-
if (rows.length === 0) {
|
|
32930
|
-
return;
|
|
32931
|
-
}
|
|
32932
|
-
const token = getCloudAccessToken();
|
|
32933
|
-
if (!token) {
|
|
32934
|
-
return;
|
|
32935
|
-
}
|
|
32936
|
-
try {
|
|
32937
|
-
await putEncryptedChangeSummaryRows({
|
|
32938
|
-
apiBaseUrl: cloudApiBaseUrl,
|
|
32939
|
-
authToken: token,
|
|
32940
|
-
sessionId,
|
|
32941
|
-
e2ee,
|
|
32942
|
-
rows
|
|
32943
|
-
});
|
|
32944
|
-
} catch (uploadErr) {
|
|
32945
|
-
log2(
|
|
32946
|
-
`[Agent] Encrypted change summary upload failed: ${uploadErr instanceof Error ? uploadErr.message : String(uploadErr)}`
|
|
32947
|
-
);
|
|
32948
|
-
}
|
|
32949
|
-
}
|
|
32950
|
-
|
|
32951
32714
|
// src/agents/planning/submit-planning-todos-for-turn.ts
|
|
32952
32715
|
async function submitPlanningTodosForTurn(params) {
|
|
32953
32716
|
const token = params.getCloudAccessToken();
|
|
@@ -33016,10 +32779,8 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
33016
32779
|
agentCwd,
|
|
33017
32780
|
isPlanningSession,
|
|
33018
32781
|
followUpCatalogPromptId,
|
|
33019
|
-
sessionChangeSummaryFilePaths,
|
|
33020
32782
|
cloudApiBaseUrl,
|
|
33021
32783
|
getCloudAccessToken,
|
|
33022
|
-
e2ee,
|
|
33023
32784
|
sendResult,
|
|
33024
32785
|
sendSessionUpdate,
|
|
33025
32786
|
log: log2
|
|
@@ -33033,18 +32794,6 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
33033
32794
|
log: log2
|
|
33034
32795
|
});
|
|
33035
32796
|
}
|
|
33036
|
-
await maybeUploadE2eeSessionChangeSummariesAfterAgentSuccess({
|
|
33037
|
-
sessionId,
|
|
33038
|
-
runId,
|
|
33039
|
-
resultSuccess: result.success === true,
|
|
33040
|
-
output: result.output,
|
|
33041
|
-
e2ee,
|
|
33042
|
-
cloudApiBaseUrl,
|
|
33043
|
-
getCloudAccessToken,
|
|
33044
|
-
followUpCatalogPromptId,
|
|
33045
|
-
sessionChangeSummaryFilePaths,
|
|
33046
|
-
log: log2
|
|
33047
|
-
});
|
|
33048
32797
|
const planningTodosSubmit = await maybeSubmitPlanningTodosAfterAgentSuccess({
|
|
33049
32798
|
sessionId,
|
|
33050
32799
|
runId,
|
|
@@ -33580,7 +33329,6 @@ async function sendPromptToAgent(options) {
|
|
|
33580
33329
|
sendSessionUpdate,
|
|
33581
33330
|
log: log2,
|
|
33582
33331
|
followUpCatalogPromptId,
|
|
33583
|
-
sessionChangeSummaryFilePaths,
|
|
33584
33332
|
cloudApiBaseUrl,
|
|
33585
33333
|
getCloudAccessToken,
|
|
33586
33334
|
e2ee,
|
|
@@ -33624,7 +33372,6 @@ async function sendPromptToAgent(options) {
|
|
|
33624
33372
|
agentCwd,
|
|
33625
33373
|
isPlanningSession,
|
|
33626
33374
|
followUpCatalogPromptId,
|
|
33627
|
-
sessionChangeSummaryFilePaths,
|
|
33628
33375
|
cloudApiBaseUrl,
|
|
33629
33376
|
getCloudAccessToken,
|
|
33630
33377
|
e2ee,
|
|
@@ -33695,7 +33442,6 @@ async function runAcpPrompt(ctx, runCtx, opts) {
|
|
|
33695
33442
|
sendResult,
|
|
33696
33443
|
sendSessionUpdate,
|
|
33697
33444
|
followUpCatalogPromptId,
|
|
33698
|
-
sessionChangeSummaryFilePaths,
|
|
33699
33445
|
cloudApiBaseUrl,
|
|
33700
33446
|
getCloudAccessToken,
|
|
33701
33447
|
e2ee,
|
|
@@ -33761,7 +33507,6 @@ async function runAcpPrompt(ctx, runCtx, opts) {
|
|
|
33761
33507
|
sendSessionUpdate,
|
|
33762
33508
|
log: ctx.log,
|
|
33763
33509
|
followUpCatalogPromptId,
|
|
33764
|
-
sessionChangeSummaryFilePaths,
|
|
33765
33510
|
cloudApiBaseUrl,
|
|
33766
33511
|
getCloudAccessToken,
|
|
33767
33512
|
e2ee,
|
|
@@ -44266,8 +44011,6 @@ function dispatchLocalPrompt(next, deps) {
|
|
|
44266
44011
|
...sessionParentPath ? { sessionParentPath } : {},
|
|
44267
44012
|
...worktreeBaseBranches && Object.keys(worktreeBaseBranches).length > 0 ? { worktreeBaseBranches } : {},
|
|
44268
44013
|
...typeof pl.followUpCatalogPromptId === "string" ? { followUpCatalogPromptId: pl.followUpCatalogPromptId } : {},
|
|
44269
|
-
...Array.isArray(pl.sessionChangeSummaryFilePaths) ? { sessionChangeSummaryFilePaths: pl.sessionChangeSummaryFilePaths } : {},
|
|
44270
|
-
...Array.isArray(pl.sessionChangeSummaryFileSnapshots) ? { sessionChangeSummaryFileSnapshots: pl.sessionChangeSummaryFileSnapshots } : {},
|
|
44271
44014
|
...typeof pl.agentType === "string" && pl.agentType.trim() ? { agentType: pl.agentType.trim() } : {},
|
|
44272
44015
|
...pl.agentConfig != null && typeof pl.agentConfig === "object" && !Array.isArray(pl.agentConfig) && Object.keys(pl.agentConfig).length > 0 ? { agentConfig: pl.agentConfig } : {},
|
|
44273
44016
|
...Array.isArray(pl.attachments) && pl.attachments.length > 0 ? { attachments: pl.attachments } : {}
|
|
@@ -44530,8 +44273,7 @@ function createBridgePromptSenders(deps, getWs) {
|
|
|
44530
44273
|
return true;
|
|
44531
44274
|
};
|
|
44532
44275
|
const sendResult = (result) => {
|
|
44533
|
-
const
|
|
44534
|
-
const encryptedFields = result.type === "prompt_result" && !skipEncryptForChangeSummaryFollowUp ? ["output", "error"] : [];
|
|
44276
|
+
const encryptedFields = result.type === "prompt_result" ? ["output", "error"] : [];
|
|
44535
44277
|
sendBridgeMessage(result, encryptedFields);
|
|
44536
44278
|
if (result.type === "prompt_result") {
|
|
44537
44279
|
const pr = result;
|
|
@@ -44595,61 +44337,6 @@ function parseWorktreeBaseBranches(msg) {
|
|
|
44595
44337
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
44596
44338
|
}
|
|
44597
44339
|
|
|
44598
|
-
// src/agents/acp/change-summary/decrypt-change-summary-file-input.ts
|
|
44599
|
-
function decryptChangeSummaryFileInput(row, e2ee) {
|
|
44600
|
-
if (!e2ee) return row;
|
|
44601
|
-
for (const field of ["path", "patchContent", "oldText", "newText"]) {
|
|
44602
|
-
const raw = row[field];
|
|
44603
|
-
if (typeof raw !== "string" || raw.trim() === "") continue;
|
|
44604
|
-
let o;
|
|
44605
|
-
try {
|
|
44606
|
-
o = JSON.parse(raw);
|
|
44607
|
-
} catch {
|
|
44608
|
-
continue;
|
|
44609
|
-
}
|
|
44610
|
-
if (!isE2eeEnvelope(o.ee)) continue;
|
|
44611
|
-
try {
|
|
44612
|
-
const d = e2ee.decryptMessage(o);
|
|
44613
|
-
const out = {
|
|
44614
|
-
path: typeof d.path === "string" ? d.path : row.path
|
|
44615
|
-
};
|
|
44616
|
-
if (d.directoryRemoved === true) out.directoryRemoved = true;
|
|
44617
|
-
else if (row.directoryRemoved === true) out.directoryRemoved = true;
|
|
44618
|
-
if (typeof d.patchContent === "string") out.patchContent = d.patchContent;
|
|
44619
|
-
else if (typeof row.patchContent === "string" && row.patchContent !== raw) out.patchContent = row.patchContent;
|
|
44620
|
-
if (typeof d.oldText === "string") out.oldText = d.oldText;
|
|
44621
|
-
else if (typeof row.oldText === "string") out.oldText = row.oldText;
|
|
44622
|
-
if (typeof d.newText === "string") out.newText = d.newText;
|
|
44623
|
-
else if (typeof row.newText === "string") out.newText = row.newText;
|
|
44624
|
-
return out;
|
|
44625
|
-
} catch {
|
|
44626
|
-
return row;
|
|
44627
|
-
}
|
|
44628
|
-
}
|
|
44629
|
-
return row;
|
|
44630
|
-
}
|
|
44631
|
-
|
|
44632
|
-
// src/agents/acp/change-summary/resolve-change-summary-prompt-for-agent.ts
|
|
44633
|
-
function hasSummarizePayload(f) {
|
|
44634
|
-
return f.directoryRemoved === true || f.patchContent != null && f.patchContent.trim() !== "" || f.oldText != null && f.oldText.trim() !== "" || f.newText != null && f.newText.trim() !== "";
|
|
44635
|
-
}
|
|
44636
|
-
function resolveChangeSummaryPromptForAgent(params) {
|
|
44637
|
-
const isBuiltin = params.followUpCatalogPromptId === BUILTIN_SESSION_CHANGE_SUMMARY_FOLLOW_UP_CATALOG_PROMPT_ID;
|
|
44638
|
-
const snaps = params.sessionChangeSummaryFileSnapshots;
|
|
44639
|
-
if (!isBuiltin || !snaps || snaps.length === 0) {
|
|
44640
|
-
return { promptText: params.bridgePromptText, sessionChangeSummaryFilePaths: void 0 };
|
|
44641
|
-
}
|
|
44642
|
-
const decrypted = dedupeSessionFileChangesByPath(snaps.map((row) => decryptChangeSummaryFileInput(row, params.e2ee)));
|
|
44643
|
-
const withPayload = decrypted.filter(hasSummarizePayload);
|
|
44644
|
-
if (withPayload.length === 0) {
|
|
44645
|
-
return { promptText: params.bridgePromptText, sessionChangeSummaryFilePaths: void 0 };
|
|
44646
|
-
}
|
|
44647
|
-
return {
|
|
44648
|
-
promptText: buildSessionChangeSummaryPrompt(withPayload),
|
|
44649
|
-
sessionChangeSummaryFilePaths: withPayload.map((f) => f.path)
|
|
44650
|
-
};
|
|
44651
|
-
}
|
|
44652
|
-
|
|
44653
44340
|
// src/agents/acp/from-bridge/bridge-prompt-preamble.ts
|
|
44654
44341
|
import { execFile as execFile8 } from "node:child_process";
|
|
44655
44342
|
import { promisify as promisify9 } from "node:util";
|
|
@@ -44696,29 +44383,9 @@ async function runBridgePromptPreamble(params) {
|
|
|
44696
44383
|
});
|
|
44697
44384
|
}
|
|
44698
44385
|
}
|
|
44699
|
-
function parseChangeSummarySnapshots(raw) {
|
|
44700
|
-
if (!Array.isArray(raw) || raw.length === 0) return void 0;
|
|
44701
|
-
const out = [];
|
|
44702
|
-
for (const item of raw) {
|
|
44703
|
-
if (!item || typeof item !== "object") continue;
|
|
44704
|
-
const o = item;
|
|
44705
|
-
const path79 = typeof o.path === "string" && o.path.trim() !== "" ? o.path.trim() : "";
|
|
44706
|
-
if (!path79) continue;
|
|
44707
|
-
const row = { path: path79 };
|
|
44708
|
-
if (typeof o.patchContent === "string") row.patchContent = o.patchContent;
|
|
44709
|
-
if (typeof o.oldText === "string") row.oldText = o.oldText;
|
|
44710
|
-
if (typeof o.newText === "string") row.newText = o.newText;
|
|
44711
|
-
if (o.directoryRemoved === true) row.directoryRemoved = true;
|
|
44712
|
-
out.push(row);
|
|
44713
|
-
}
|
|
44714
|
-
return out.length > 0 ? out : void 0;
|
|
44715
|
-
}
|
|
44716
44386
|
function parseFollowUpFieldsFromPromptMessage(msg) {
|
|
44717
44387
|
const followUpCatalogPromptId = typeof msg.followUpCatalogPromptId === "string" && msg.followUpCatalogPromptId.trim() !== "" ? msg.followUpCatalogPromptId.trim() : null;
|
|
44718
|
-
|
|
44719
|
-
const sessionChangeSummaryFilePaths = Array.isArray(rawPaths) ? rawPaths.filter((p) => typeof p === "string" && p.trim() !== "").map((p) => p.trim()) : void 0;
|
|
44720
|
-
const sessionChangeSummaryFileSnapshots = parseChangeSummarySnapshots(msg.sessionChangeSummaryFileSnapshots);
|
|
44721
|
-
return { followUpCatalogPromptId, sessionChangeSummaryFilePaths, sessionChangeSummaryFileSnapshots };
|
|
44388
|
+
return { followUpCatalogPromptId };
|
|
44722
44389
|
}
|
|
44723
44390
|
|
|
44724
44391
|
// src/agents/acp/from-bridge/handle-bridge-prompt/run-preamble-and-prompt.ts
|
|
@@ -44749,25 +44416,9 @@ async function runPreambleAndPrompt(params) {
|
|
|
44749
44416
|
runId,
|
|
44750
44417
|
effectiveCwd
|
|
44751
44418
|
});
|
|
44752
|
-
const {
|
|
44753
|
-
followUpCatalogPromptId,
|
|
44754
|
-
sessionChangeSummaryFilePaths: pathsFromBridge,
|
|
44755
|
-
sessionChangeSummaryFileSnapshots
|
|
44756
|
-
} = parseFollowUpFieldsFromPromptMessage(msg);
|
|
44757
|
-
const { promptText: resolvedPromptText, sessionChangeSummaryFilePaths } = resolveChangeSummaryPromptForAgent({
|
|
44758
|
-
followUpCatalogPromptId,
|
|
44759
|
-
sessionChangeSummaryFileSnapshots,
|
|
44760
|
-
bridgePromptText: promptText,
|
|
44761
|
-
e2ee: deps.e2ee
|
|
44762
|
-
});
|
|
44763
|
-
if (sessionChangeSummaryFileSnapshots && sessionChangeSummaryFileSnapshots.length > 0 && resolvedPromptText === promptText) {
|
|
44764
|
-
deps.log(
|
|
44765
|
-
"[Agent] Change-summary snapshots were present but the prompt was not rebuilt (decrypt failed or empty payloads); sending the bridge prompt as-is."
|
|
44766
|
-
);
|
|
44767
|
-
}
|
|
44768
|
-
const pathsForUpload = sessionChangeSummaryFilePaths ?? pathsFromBridge;
|
|
44419
|
+
const { followUpCatalogPromptId } = parseFollowUpFieldsFromPromptMessage(msg);
|
|
44769
44420
|
deps.acpManager.handlePrompt({
|
|
44770
|
-
promptText
|
|
44421
|
+
promptText,
|
|
44771
44422
|
promptId: msg.id,
|
|
44772
44423
|
sessionId,
|
|
44773
44424
|
runId,
|
|
@@ -44779,7 +44430,6 @@ async function runPreambleAndPrompt(params) {
|
|
|
44779
44430
|
sendResult,
|
|
44780
44431
|
sendSessionUpdate,
|
|
44781
44432
|
followUpCatalogPromptId,
|
|
44782
|
-
sessionChangeSummaryFilePaths: pathsForUpload,
|
|
44783
44433
|
cloudApiBaseUrl: deps.cloudApiBaseUrl,
|
|
44784
44434
|
getCloudAccessToken: deps.getCloudAccessToken,
|
|
44785
44435
|
e2ee: deps.e2ee,
|