@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/cli.js
CHANGED
|
@@ -25631,7 +25631,7 @@ var {
|
|
|
25631
25631
|
} = import_index.default;
|
|
25632
25632
|
|
|
25633
25633
|
// src/cli-version.ts
|
|
25634
|
-
var CLI_VERSION = "0.1.
|
|
25634
|
+
var CLI_VERSION = "0.1.63".length > 0 ? "0.1.63" : "0.0.0-dev";
|
|
25635
25635
|
|
|
25636
25636
|
// src/cli/defaults.ts
|
|
25637
25637
|
var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
|
|
@@ -31955,7 +31955,6 @@ var StoryCheckpointSummarySchema = CheckpointSummarySchema.extend({
|
|
|
31955
31955
|
|
|
31956
31956
|
// ../types/src/sessions.ts
|
|
31957
31957
|
init_zod();
|
|
31958
|
-
var BUILTIN_SESSION_CHANGE_SUMMARY_FOLLOW_UP_CATALOG_PROMPT_ID = "__builtin_change_summary__";
|
|
31959
31958
|
var SessionMetaSchema = external_exports.object({
|
|
31960
31959
|
sessionId: external_exports.string(),
|
|
31961
31960
|
workspaceId: external_exports.string(),
|
|
@@ -32088,146 +32087,6 @@ function buildPlanningSessionFollowUpAgentPrompt(userPrompt, existingTodos) {
|
|
|
32088
32087
|
].join("\n");
|
|
32089
32088
|
}
|
|
32090
32089
|
|
|
32091
|
-
// ../types/src/change-summary-path.ts
|
|
32092
|
-
function normalizeRepoRelativePath(p) {
|
|
32093
|
-
let t = p.trim().replace(/\\/g, "/");
|
|
32094
|
-
while (t.startsWith("./")) t = t.slice(2);
|
|
32095
|
-
return t.replace(/\/+/g, "/");
|
|
32096
|
-
}
|
|
32097
|
-
function resolveChangeSummaryPathAgainstAllowed(rawPath, allowed) {
|
|
32098
|
-
const trimmed2 = rawPath.trim();
|
|
32099
|
-
if (!trimmed2) return null;
|
|
32100
|
-
if (allowed.has(trimmed2)) return trimmed2;
|
|
32101
|
-
const n = normalizeRepoRelativePath(trimmed2);
|
|
32102
|
-
if (allowed.has(n)) return n;
|
|
32103
|
-
for (const a of allowed) {
|
|
32104
|
-
if (normalizeRepoRelativePath(a) === n) return a;
|
|
32105
|
-
}
|
|
32106
|
-
return null;
|
|
32107
|
-
}
|
|
32108
|
-
|
|
32109
|
-
// ../types/src/parse-change-summary-json.ts
|
|
32110
|
-
function clampSummaryToAtMostTwoLines(summary) {
|
|
32111
|
-
const lines = summary.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
|
|
32112
|
-
return lines.slice(0, 2).join("\n");
|
|
32113
|
-
}
|
|
32114
|
-
function parseChangeSummaryJson(raw, allowedPaths, options) {
|
|
32115
|
-
if (raw == null || raw.trim() === "") return [];
|
|
32116
|
-
let text = raw.trim();
|
|
32117
|
-
const fence = text.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
32118
|
-
if (fence?.[1]) text = fence[1].trim();
|
|
32119
|
-
let parsed;
|
|
32120
|
-
try {
|
|
32121
|
-
parsed = JSON.parse(text);
|
|
32122
|
-
} catch {
|
|
32123
|
-
const start = text.indexOf("[");
|
|
32124
|
-
const end = text.lastIndexOf("]");
|
|
32125
|
-
if (start < 0 || end <= start) return [];
|
|
32126
|
-
try {
|
|
32127
|
-
parsed = JSON.parse(text.slice(start, end + 1));
|
|
32128
|
-
} catch {
|
|
32129
|
-
return [];
|
|
32130
|
-
}
|
|
32131
|
-
}
|
|
32132
|
-
const rows = [];
|
|
32133
|
-
let arr = [];
|
|
32134
|
-
if (Array.isArray(parsed)) {
|
|
32135
|
-
arr = parsed;
|
|
32136
|
-
} else if (parsed && typeof parsed === "object" && Array.isArray(parsed.files)) {
|
|
32137
|
-
arr = parsed.files;
|
|
32138
|
-
}
|
|
32139
|
-
const skip = options?.skipPathAllowlist === true;
|
|
32140
|
-
for (const item of arr) {
|
|
32141
|
-
if (!item || typeof item !== "object") continue;
|
|
32142
|
-
const o = item;
|
|
32143
|
-
const rawPath = typeof o.path === "string" ? o.path.trim() : "";
|
|
32144
|
-
const summary = typeof o.summary === "string" ? o.summary.trim() : "";
|
|
32145
|
-
if (!rawPath || !summary) continue;
|
|
32146
|
-
const path81 = skip ? normalizeRepoRelativePath(rawPath) || rawPath : resolveChangeSummaryPathAgainstAllowed(rawPath, allowedPaths);
|
|
32147
|
-
if (!path81) continue;
|
|
32148
|
-
rows.push({ path: path81, summary: clampSummaryToAtMostTwoLines(summary) });
|
|
32149
|
-
}
|
|
32150
|
-
return rows;
|
|
32151
|
-
}
|
|
32152
|
-
|
|
32153
|
-
// ../types/src/build-change-summary-prompt.ts
|
|
32154
|
-
var PATCH_PREVIEW_MAX = 12e3;
|
|
32155
|
-
function clip(s, max) {
|
|
32156
|
-
if (s.length <= max) return s;
|
|
32157
|
-
return `${s.slice(0, max)}
|
|
32158
|
-
|
|
32159
|
-
\u2026(truncated, ${s.length - max} more characters)`;
|
|
32160
|
-
}
|
|
32161
|
-
function buildSessionChangeSummaryPrompt(files) {
|
|
32162
|
-
const lines = [
|
|
32163
|
-
"You are the same agent that produced the changes below. Summarize **your own** edits so a reader can scan them quickly.",
|
|
32164
|
-
"",
|
|
32165
|
-
"Write in second person (you / your): what you changed in each path and why it matters.",
|
|
32166
|
-
"",
|
|
32167
|
-
"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.",
|
|
32168
|
-
"",
|
|
32169
|
-
"## How to format your reply (machine parsing)",
|
|
32170
|
-
"",
|
|
32171
|
-
"- 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.",
|
|
32172
|
-
"- Inside that fence: **nothing except** one valid JSON value \u2014 the array described below. No trailing commentary inside the fence.",
|
|
32173
|
-
"- **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.",
|
|
32174
|
-
"- If you add optional plain English before the fence (e.g. one short sentence), keep it **separate**: end that sentence, blank line, then ```json.",
|
|
32175
|
-
'- In each `"summary"` string, avoid raw double-quote characters, or escape them as `\\"` so the JSON parses.',
|
|
32176
|
-
"",
|
|
32177
|
-
"JSON shape **inside the fence** (array only):",
|
|
32178
|
-
'[{"path":"<file path exactly as given>","summary":"<one line, or two short lines separated by \\n>"}]',
|
|
32179
|
-
"",
|
|
32180
|
-
"Rules:",
|
|
32181
|
-
"- Include **exactly one** object per file path listed below (same path strings).",
|
|
32182
|
-
"- If a path is a removed directory, state briefly what you removed.",
|
|
32183
|
-
"- Do not invent paths; use only the paths provided.",
|
|
32184
|
-
"",
|
|
32185
|
-
"## Files you changed",
|
|
32186
|
-
""
|
|
32187
|
-
];
|
|
32188
|
-
for (const f of files) {
|
|
32189
|
-
lines.push(`### ${f.path}`);
|
|
32190
|
-
if (f.directoryRemoved) {
|
|
32191
|
-
lines.push("(directory removed)");
|
|
32192
|
-
lines.push("");
|
|
32193
|
-
continue;
|
|
32194
|
-
}
|
|
32195
|
-
if (f.patchContent && f.patchContent.trim() !== "") {
|
|
32196
|
-
lines.push("```diff");
|
|
32197
|
-
lines.push(clip(f.patchContent.trim(), PATCH_PREVIEW_MAX));
|
|
32198
|
-
lines.push("```");
|
|
32199
|
-
} else if (f.oldText != null || f.newText != null) {
|
|
32200
|
-
const oldT = (f.oldText ?? "").trim();
|
|
32201
|
-
const newT = (f.newText ?? "").trim();
|
|
32202
|
-
lines.push("Previous snippet:", clip(oldT, 6e3));
|
|
32203
|
-
lines.push("New snippet:", clip(newT, 6e3));
|
|
32204
|
-
} else {
|
|
32205
|
-
lines.push("(no diff body stored for this path)");
|
|
32206
|
-
}
|
|
32207
|
-
lines.push("");
|
|
32208
|
-
}
|
|
32209
|
-
return lines.join("\n");
|
|
32210
|
-
}
|
|
32211
|
-
|
|
32212
|
-
// ../types/src/dedupe-session-file-changes-by-path.ts
|
|
32213
|
-
function defaultRichness(c) {
|
|
32214
|
-
const patch = typeof c.patchContent === "string" ? c.patchContent.length : 0;
|
|
32215
|
-
const nt = typeof c.newText === "string" ? c.newText.length : 0;
|
|
32216
|
-
const ot = typeof c.oldText === "string" ? c.oldText.length : 0;
|
|
32217
|
-
const dir = c.directoryRemoved === true ? 8 : 0;
|
|
32218
|
-
return (patch > 0 ? 4 : 0) + (nt > 0 ? 2 : 0) + (ot > 0 ? 1 : 0) + dir;
|
|
32219
|
-
}
|
|
32220
|
-
function dedupeSessionFileChangesByPath(items, richness = (item) => defaultRichness(item)) {
|
|
32221
|
-
const byPath = /* @__PURE__ */ new Map();
|
|
32222
|
-
for (const item of items) {
|
|
32223
|
-
const p = typeof item.path === "string" ? item.path.trim() : "";
|
|
32224
|
-
if (!p) continue;
|
|
32225
|
-
const prev = byPath.get(p);
|
|
32226
|
-
if (!prev || richness(item) >= richness(prev)) byPath.set(p, item);
|
|
32227
|
-
}
|
|
32228
|
-
return Array.from(byPath.entries()).sort(([a], [b]) => a.localeCompare(b)).map(([, v]) => v);
|
|
32229
|
-
}
|
|
32230
|
-
|
|
32231
32090
|
// ../types/src/diff/line-diff.ts
|
|
32232
32091
|
function normalizeDiffLineText(line) {
|
|
32233
32092
|
return line.replace(/\r$/, "").replace(/\s*\\s*$/, "");
|
|
@@ -35836,102 +35695,6 @@ async function collectTurnGitDiffFromPreTurnSnapshot(options) {
|
|
|
35836
35695
|
});
|
|
35837
35696
|
}
|
|
35838
35697
|
|
|
35839
|
-
// src/agents/acp/put-summarize-change-summaries.ts
|
|
35840
|
-
async function putEncryptedChangeSummaryRows(params) {
|
|
35841
|
-
const base = params.apiBaseUrl.replace(/\/+$/, "");
|
|
35842
|
-
const entries = params.rows.map(({ path: path81, summary }) => {
|
|
35843
|
-
const enc = params.e2ee.encryptFields({ summary }, ["summary"]);
|
|
35844
|
-
return { path: path81, summary: JSON.stringify(enc) };
|
|
35845
|
-
});
|
|
35846
|
-
const res = await fetch(
|
|
35847
|
-
`${base}/internal/sessions/${encodeURIComponent(params.sessionId)}/follow-ups/summarize-changes`,
|
|
35848
|
-
{
|
|
35849
|
-
method: "PUT",
|
|
35850
|
-
headers: {
|
|
35851
|
-
Authorization: `Bearer ${params.authToken}`,
|
|
35852
|
-
"Content-Type": "application/json"
|
|
35853
|
-
},
|
|
35854
|
-
body: JSON.stringify({ entries })
|
|
35855
|
-
}
|
|
35856
|
-
);
|
|
35857
|
-
if (!res.ok) {
|
|
35858
|
-
const t = await res.text();
|
|
35859
|
-
throw new Error(`PUT summarize-changes summaries failed ${res.status}: ${t.slice(0, 500)}`);
|
|
35860
|
-
}
|
|
35861
|
-
}
|
|
35862
|
-
|
|
35863
|
-
// src/agents/acp/maybe-upload-e2ee-session-change-summaries.ts
|
|
35864
|
-
async function maybeUploadE2eeSessionChangeSummariesAfterAgentSuccess(params) {
|
|
35865
|
-
const {
|
|
35866
|
-
sessionId,
|
|
35867
|
-
runId,
|
|
35868
|
-
resultSuccess,
|
|
35869
|
-
output,
|
|
35870
|
-
e2ee,
|
|
35871
|
-
cloudApiBaseUrl,
|
|
35872
|
-
getCloudAccessToken,
|
|
35873
|
-
followUpCatalogPromptId,
|
|
35874
|
-
sessionChangeSummaryFilePaths,
|
|
35875
|
-
log: log2
|
|
35876
|
-
} = params;
|
|
35877
|
-
const outputStr = typeof output === "string" ? output : "";
|
|
35878
|
-
if (!sessionId) {
|
|
35879
|
-
return;
|
|
35880
|
-
}
|
|
35881
|
-
if (!runId) {
|
|
35882
|
-
return;
|
|
35883
|
-
}
|
|
35884
|
-
if (!resultSuccess) {
|
|
35885
|
-
return;
|
|
35886
|
-
}
|
|
35887
|
-
if (!e2ee) {
|
|
35888
|
-
return;
|
|
35889
|
-
}
|
|
35890
|
-
if (!cloudApiBaseUrl) {
|
|
35891
|
-
return;
|
|
35892
|
-
}
|
|
35893
|
-
if (!getCloudAccessToken) {
|
|
35894
|
-
return;
|
|
35895
|
-
}
|
|
35896
|
-
if (followUpCatalogPromptId !== BUILTIN_SESSION_CHANGE_SUMMARY_FOLLOW_UP_CATALOG_PROMPT_ID) {
|
|
35897
|
-
return;
|
|
35898
|
-
}
|
|
35899
|
-
if (!sessionChangeSummaryFilePaths || sessionChangeSummaryFilePaths.length === 0) {
|
|
35900
|
-
return;
|
|
35901
|
-
}
|
|
35902
|
-
if (outputStr.trim() === "") {
|
|
35903
|
-
return;
|
|
35904
|
-
}
|
|
35905
|
-
const allowed = /* @__PURE__ */ new Set();
|
|
35906
|
-
for (const p of sessionChangeSummaryFilePaths) {
|
|
35907
|
-
const t = p.trim();
|
|
35908
|
-
if (!t) continue;
|
|
35909
|
-
allowed.add(t);
|
|
35910
|
-
allowed.add(normalizeRepoRelativePath(t));
|
|
35911
|
-
}
|
|
35912
|
-
const rows = parseChangeSummaryJson(outputStr, allowed);
|
|
35913
|
-
if (rows.length === 0) {
|
|
35914
|
-
return;
|
|
35915
|
-
}
|
|
35916
|
-
const token = getCloudAccessToken();
|
|
35917
|
-
if (!token) {
|
|
35918
|
-
return;
|
|
35919
|
-
}
|
|
35920
|
-
try {
|
|
35921
|
-
await putEncryptedChangeSummaryRows({
|
|
35922
|
-
apiBaseUrl: cloudApiBaseUrl,
|
|
35923
|
-
authToken: token,
|
|
35924
|
-
sessionId,
|
|
35925
|
-
e2ee,
|
|
35926
|
-
rows
|
|
35927
|
-
});
|
|
35928
|
-
} catch (uploadErr) {
|
|
35929
|
-
log2(
|
|
35930
|
-
`[Agent] Encrypted change summary upload failed: ${uploadErr instanceof Error ? uploadErr.message : String(uploadErr)}`
|
|
35931
|
-
);
|
|
35932
|
-
}
|
|
35933
|
-
}
|
|
35934
|
-
|
|
35935
35698
|
// src/agents/planning/submit-planning-todos-for-turn.ts
|
|
35936
35699
|
async function submitPlanningTodosForTurn(params) {
|
|
35937
35700
|
const token = params.getCloudAccessToken();
|
|
@@ -36000,10 +35763,8 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
36000
35763
|
agentCwd,
|
|
36001
35764
|
isPlanningSession,
|
|
36002
35765
|
followUpCatalogPromptId,
|
|
36003
|
-
sessionChangeSummaryFilePaths,
|
|
36004
35766
|
cloudApiBaseUrl,
|
|
36005
35767
|
getCloudAccessToken,
|
|
36006
|
-
e2ee,
|
|
36007
35768
|
sendResult,
|
|
36008
35769
|
sendSessionUpdate,
|
|
36009
35770
|
log: log2
|
|
@@ -36017,18 +35778,6 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
36017
35778
|
log: log2
|
|
36018
35779
|
});
|
|
36019
35780
|
}
|
|
36020
|
-
await maybeUploadE2eeSessionChangeSummariesAfterAgentSuccess({
|
|
36021
|
-
sessionId,
|
|
36022
|
-
runId,
|
|
36023
|
-
resultSuccess: result.success === true,
|
|
36024
|
-
output: result.output,
|
|
36025
|
-
e2ee,
|
|
36026
|
-
cloudApiBaseUrl,
|
|
36027
|
-
getCloudAccessToken,
|
|
36028
|
-
followUpCatalogPromptId,
|
|
36029
|
-
sessionChangeSummaryFilePaths,
|
|
36030
|
-
log: log2
|
|
36031
|
-
});
|
|
36032
35781
|
const planningTodosSubmit = await maybeSubmitPlanningTodosAfterAgentSuccess({
|
|
36033
35782
|
sessionId,
|
|
36034
35783
|
runId,
|
|
@@ -36472,7 +36221,6 @@ async function sendPromptToAgent(options) {
|
|
|
36472
36221
|
sendSessionUpdate,
|
|
36473
36222
|
log: log2,
|
|
36474
36223
|
followUpCatalogPromptId,
|
|
36475
|
-
sessionChangeSummaryFilePaths,
|
|
36476
36224
|
cloudApiBaseUrl,
|
|
36477
36225
|
getCloudAccessToken,
|
|
36478
36226
|
e2ee,
|
|
@@ -36516,7 +36264,6 @@ async function sendPromptToAgent(options) {
|
|
|
36516
36264
|
agentCwd,
|
|
36517
36265
|
isPlanningSession,
|
|
36518
36266
|
followUpCatalogPromptId,
|
|
36519
|
-
sessionChangeSummaryFilePaths,
|
|
36520
36267
|
cloudApiBaseUrl,
|
|
36521
36268
|
getCloudAccessToken,
|
|
36522
36269
|
e2ee,
|
|
@@ -36587,7 +36334,6 @@ async function runAcpPrompt(ctx, runCtx, opts) {
|
|
|
36587
36334
|
sendResult,
|
|
36588
36335
|
sendSessionUpdate,
|
|
36589
36336
|
followUpCatalogPromptId,
|
|
36590
|
-
sessionChangeSummaryFilePaths,
|
|
36591
36337
|
cloudApiBaseUrl,
|
|
36592
36338
|
getCloudAccessToken,
|
|
36593
36339
|
e2ee,
|
|
@@ -36653,7 +36399,6 @@ async function runAcpPrompt(ctx, runCtx, opts) {
|
|
|
36653
36399
|
sendSessionUpdate,
|
|
36654
36400
|
log: ctx.log,
|
|
36655
36401
|
followUpCatalogPromptId,
|
|
36656
|
-
sessionChangeSummaryFilePaths,
|
|
36657
36402
|
cloudApiBaseUrl,
|
|
36658
36403
|
getCloudAccessToken,
|
|
36659
36404
|
e2ee,
|
|
@@ -47315,8 +47060,6 @@ function dispatchLocalPrompt(next, deps) {
|
|
|
47315
47060
|
...sessionParentPath ? { sessionParentPath } : {},
|
|
47316
47061
|
...worktreeBaseBranches && Object.keys(worktreeBaseBranches).length > 0 ? { worktreeBaseBranches } : {},
|
|
47317
47062
|
...typeof pl.followUpCatalogPromptId === "string" ? { followUpCatalogPromptId: pl.followUpCatalogPromptId } : {},
|
|
47318
|
-
...Array.isArray(pl.sessionChangeSummaryFilePaths) ? { sessionChangeSummaryFilePaths: pl.sessionChangeSummaryFilePaths } : {},
|
|
47319
|
-
...Array.isArray(pl.sessionChangeSummaryFileSnapshots) ? { sessionChangeSummaryFileSnapshots: pl.sessionChangeSummaryFileSnapshots } : {},
|
|
47320
47063
|
...typeof pl.agentType === "string" && pl.agentType.trim() ? { agentType: pl.agentType.trim() } : {},
|
|
47321
47064
|
...pl.agentConfig != null && typeof pl.agentConfig === "object" && !Array.isArray(pl.agentConfig) && Object.keys(pl.agentConfig).length > 0 ? { agentConfig: pl.agentConfig } : {},
|
|
47322
47065
|
...Array.isArray(pl.attachments) && pl.attachments.length > 0 ? { attachments: pl.attachments } : {}
|
|
@@ -47579,8 +47322,7 @@ function createBridgePromptSenders(deps, getWs) {
|
|
|
47579
47322
|
return true;
|
|
47580
47323
|
};
|
|
47581
47324
|
const sendResult = (result) => {
|
|
47582
|
-
const
|
|
47583
|
-
const encryptedFields = result.type === "prompt_result" && !skipEncryptForChangeSummaryFollowUp ? ["output", "error"] : [];
|
|
47325
|
+
const encryptedFields = result.type === "prompt_result" ? ["output", "error"] : [];
|
|
47584
47326
|
sendBridgeMessage(result, encryptedFields);
|
|
47585
47327
|
if (result.type === "prompt_result") {
|
|
47586
47328
|
const pr = result;
|
|
@@ -47644,61 +47386,6 @@ function parseWorktreeBaseBranches(msg) {
|
|
|
47644
47386
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
47645
47387
|
}
|
|
47646
47388
|
|
|
47647
|
-
// src/agents/acp/change-summary/decrypt-change-summary-file-input.ts
|
|
47648
|
-
function decryptChangeSummaryFileInput(row, e2ee) {
|
|
47649
|
-
if (!e2ee) return row;
|
|
47650
|
-
for (const field of ["path", "patchContent", "oldText", "newText"]) {
|
|
47651
|
-
const raw = row[field];
|
|
47652
|
-
if (typeof raw !== "string" || raw.trim() === "") continue;
|
|
47653
|
-
let o;
|
|
47654
|
-
try {
|
|
47655
|
-
o = JSON.parse(raw);
|
|
47656
|
-
} catch {
|
|
47657
|
-
continue;
|
|
47658
|
-
}
|
|
47659
|
-
if (!isE2eeEnvelope(o.ee)) continue;
|
|
47660
|
-
try {
|
|
47661
|
-
const d = e2ee.decryptMessage(o);
|
|
47662
|
-
const out = {
|
|
47663
|
-
path: typeof d.path === "string" ? d.path : row.path
|
|
47664
|
-
};
|
|
47665
|
-
if (d.directoryRemoved === true) out.directoryRemoved = true;
|
|
47666
|
-
else if (row.directoryRemoved === true) out.directoryRemoved = true;
|
|
47667
|
-
if (typeof d.patchContent === "string") out.patchContent = d.patchContent;
|
|
47668
|
-
else if (typeof row.patchContent === "string" && row.patchContent !== raw) out.patchContent = row.patchContent;
|
|
47669
|
-
if (typeof d.oldText === "string") out.oldText = d.oldText;
|
|
47670
|
-
else if (typeof row.oldText === "string") out.oldText = row.oldText;
|
|
47671
|
-
if (typeof d.newText === "string") out.newText = d.newText;
|
|
47672
|
-
else if (typeof row.newText === "string") out.newText = row.newText;
|
|
47673
|
-
return out;
|
|
47674
|
-
} catch {
|
|
47675
|
-
return row;
|
|
47676
|
-
}
|
|
47677
|
-
}
|
|
47678
|
-
return row;
|
|
47679
|
-
}
|
|
47680
|
-
|
|
47681
|
-
// src/agents/acp/change-summary/resolve-change-summary-prompt-for-agent.ts
|
|
47682
|
-
function hasSummarizePayload(f) {
|
|
47683
|
-
return f.directoryRemoved === true || f.patchContent != null && f.patchContent.trim() !== "" || f.oldText != null && f.oldText.trim() !== "" || f.newText != null && f.newText.trim() !== "";
|
|
47684
|
-
}
|
|
47685
|
-
function resolveChangeSummaryPromptForAgent(params) {
|
|
47686
|
-
const isBuiltin = params.followUpCatalogPromptId === BUILTIN_SESSION_CHANGE_SUMMARY_FOLLOW_UP_CATALOG_PROMPT_ID;
|
|
47687
|
-
const snaps = params.sessionChangeSummaryFileSnapshots;
|
|
47688
|
-
if (!isBuiltin || !snaps || snaps.length === 0) {
|
|
47689
|
-
return { promptText: params.bridgePromptText, sessionChangeSummaryFilePaths: void 0 };
|
|
47690
|
-
}
|
|
47691
|
-
const decrypted = dedupeSessionFileChangesByPath(snaps.map((row) => decryptChangeSummaryFileInput(row, params.e2ee)));
|
|
47692
|
-
const withPayload = decrypted.filter(hasSummarizePayload);
|
|
47693
|
-
if (withPayload.length === 0) {
|
|
47694
|
-
return { promptText: params.bridgePromptText, sessionChangeSummaryFilePaths: void 0 };
|
|
47695
|
-
}
|
|
47696
|
-
return {
|
|
47697
|
-
promptText: buildSessionChangeSummaryPrompt(withPayload),
|
|
47698
|
-
sessionChangeSummaryFilePaths: withPayload.map((f) => f.path)
|
|
47699
|
-
};
|
|
47700
|
-
}
|
|
47701
|
-
|
|
47702
47389
|
// src/agents/acp/from-bridge/bridge-prompt-preamble.ts
|
|
47703
47390
|
import { execFile as execFile8 } from "node:child_process";
|
|
47704
47391
|
import { promisify as promisify9 } from "node:util";
|
|
@@ -47745,29 +47432,9 @@ async function runBridgePromptPreamble(params) {
|
|
|
47745
47432
|
});
|
|
47746
47433
|
}
|
|
47747
47434
|
}
|
|
47748
|
-
function parseChangeSummarySnapshots(raw) {
|
|
47749
|
-
if (!Array.isArray(raw) || raw.length === 0) return void 0;
|
|
47750
|
-
const out = [];
|
|
47751
|
-
for (const item of raw) {
|
|
47752
|
-
if (!item || typeof item !== "object") continue;
|
|
47753
|
-
const o = item;
|
|
47754
|
-
const path81 = typeof o.path === "string" && o.path.trim() !== "" ? o.path.trim() : "";
|
|
47755
|
-
if (!path81) continue;
|
|
47756
|
-
const row = { path: path81 };
|
|
47757
|
-
if (typeof o.patchContent === "string") row.patchContent = o.patchContent;
|
|
47758
|
-
if (typeof o.oldText === "string") row.oldText = o.oldText;
|
|
47759
|
-
if (typeof o.newText === "string") row.newText = o.newText;
|
|
47760
|
-
if (o.directoryRemoved === true) row.directoryRemoved = true;
|
|
47761
|
-
out.push(row);
|
|
47762
|
-
}
|
|
47763
|
-
return out.length > 0 ? out : void 0;
|
|
47764
|
-
}
|
|
47765
47435
|
function parseFollowUpFieldsFromPromptMessage(msg) {
|
|
47766
47436
|
const followUpCatalogPromptId = typeof msg.followUpCatalogPromptId === "string" && msg.followUpCatalogPromptId.trim() !== "" ? msg.followUpCatalogPromptId.trim() : null;
|
|
47767
|
-
|
|
47768
|
-
const sessionChangeSummaryFilePaths = Array.isArray(rawPaths) ? rawPaths.filter((p) => typeof p === "string" && p.trim() !== "").map((p) => p.trim()) : void 0;
|
|
47769
|
-
const sessionChangeSummaryFileSnapshots = parseChangeSummarySnapshots(msg.sessionChangeSummaryFileSnapshots);
|
|
47770
|
-
return { followUpCatalogPromptId, sessionChangeSummaryFilePaths, sessionChangeSummaryFileSnapshots };
|
|
47437
|
+
return { followUpCatalogPromptId };
|
|
47771
47438
|
}
|
|
47772
47439
|
|
|
47773
47440
|
// src/agents/acp/from-bridge/handle-bridge-prompt/run-preamble-and-prompt.ts
|
|
@@ -47798,25 +47465,9 @@ async function runPreambleAndPrompt(params) {
|
|
|
47798
47465
|
runId,
|
|
47799
47466
|
effectiveCwd
|
|
47800
47467
|
});
|
|
47801
|
-
const {
|
|
47802
|
-
followUpCatalogPromptId,
|
|
47803
|
-
sessionChangeSummaryFilePaths: pathsFromBridge,
|
|
47804
|
-
sessionChangeSummaryFileSnapshots
|
|
47805
|
-
} = parseFollowUpFieldsFromPromptMessage(msg);
|
|
47806
|
-
const { promptText: resolvedPromptText, sessionChangeSummaryFilePaths } = resolveChangeSummaryPromptForAgent({
|
|
47807
|
-
followUpCatalogPromptId,
|
|
47808
|
-
sessionChangeSummaryFileSnapshots,
|
|
47809
|
-
bridgePromptText: promptText,
|
|
47810
|
-
e2ee: deps.e2ee
|
|
47811
|
-
});
|
|
47812
|
-
if (sessionChangeSummaryFileSnapshots && sessionChangeSummaryFileSnapshots.length > 0 && resolvedPromptText === promptText) {
|
|
47813
|
-
deps.log(
|
|
47814
|
-
"[Agent] Change-summary snapshots were present but the prompt was not rebuilt (decrypt failed or empty payloads); sending the bridge prompt as-is."
|
|
47815
|
-
);
|
|
47816
|
-
}
|
|
47817
|
-
const pathsForUpload = sessionChangeSummaryFilePaths ?? pathsFromBridge;
|
|
47468
|
+
const { followUpCatalogPromptId } = parseFollowUpFieldsFromPromptMessage(msg);
|
|
47818
47469
|
deps.acpManager.handlePrompt({
|
|
47819
|
-
promptText
|
|
47470
|
+
promptText,
|
|
47820
47471
|
promptId: msg.id,
|
|
47821
47472
|
sessionId,
|
|
47822
47473
|
runId,
|
|
@@ -47828,7 +47479,6 @@ async function runPreambleAndPrompt(params) {
|
|
|
47828
47479
|
sendResult,
|
|
47829
47480
|
sendSessionUpdate,
|
|
47830
47481
|
followUpCatalogPromptId,
|
|
47831
|
-
sessionChangeSummaryFilePaths: pathsForUpload,
|
|
47832
47482
|
cloudApiBaseUrl: deps.cloudApiBaseUrl,
|
|
47833
47483
|
getCloudAccessToken: deps.getCloudAccessToken,
|
|
47834
47484
|
e2ee: deps.e2ee,
|