Skip to content

Commit ae9f93c

Browse files
committed
merge main into voice-call pacer fix
* commit '475ea69f2c356104f4b601f4976788081e79b8b4': refactor(agents): consolidate context budgets and compaction recovery (#117149) fix(net-policy): redact sig and x-* auth params in URLs and bodies (#116957) refactor(agents): remove duplicate generated-media delivery fallbacks (#117150) refactor(reply): unify turn lifecycle state ownership (#117145) fix(ui): preserve emoji agent avatar initials (#104912) refactor(auto-reply): unify command and directive ownership (#117143)
2 parents 5ee5113 + 475ea69 commit ae9f93c

81 files changed

Lines changed: 4827 additions & 9305 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎config/max-lines-baseline.txt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ src/agents/transcript-redact.test.ts
505505
src/agents/workspace.ts
506506
src/agents/worktrees/service.ts
507507
src/auto-reply/command-control.test.ts
508-
src/auto-reply/commands-registry.shared.ts
509508
src/auto-reply/inbound.test.ts
510509
src/auto-reply/reply/abort.test.ts
511510
src/auto-reply/reply/agent-runner-memory.test.ts
@@ -517,7 +516,6 @@ src/auto-reply/reply/commands-acp.test.ts
517516
src/auto-reply/reply/commands-approve.test.ts
518517
src/auto-reply/reply/commands-models.ts
519518
src/auto-reply/reply/commands-status.test.ts
520-
src/auto-reply/reply/directive-handling.impl.ts
521519
src/auto-reply/reply/directive-handling.model.test.ts
522520
src/auto-reply/reply/dispatch-acp.test.ts
523521
src/auto-reply/reply/dispatch-acp.ts

‎packages/net-policy/src/redact-sensitive-url.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ describe("redactSensitiveUrl", () => {
2222
);
2323
});
2424

25+
it("redacts signed and x-* auth aliases without matching adjacent metadata", () => {
26+
expect(
27+
redactSensitiveUrl(
28+
"https://example.com/mcp?sig=one&X-Api-Key=two&x_access_token=three&x-auth-token=four&signal=keep&x-api-version=1",
29+
),
30+
).toBe(
31+
"https://example.com/mcp?sig=***&X-Api-Key=***&x_access_token=***&x-auth-token=***&signal=keep&x-api-version=1",
32+
);
33+
});
34+
2535
it("redacts encoded and invisible-spliced sensitive query param names", () => {
2636
expect(
2737
redactSensitiveUrl("https://example.com/mcp?client%5Fse%E2%80%8Bcret=secret&safe=value"),
@@ -199,6 +209,16 @@ describe("redactSensitiveUrlLikeString", () => {
199209
);
200210
});
201211

212+
it("redacts signed and x-* auth aliases in invalid URL-like strings", () => {
213+
expect(
214+
redactSensitiveUrlLikeString(
215+
"//example.com/mcp?sig=one&x-api-key=two&x-access-token=three&x-auth-token=four&safe=value",
216+
),
217+
).toBe(
218+
"//example.com/mcp?sig=***&x-api-key=***&x-access-token=***&x-auth-token=***&safe=value",
219+
);
220+
});
221+
202222
it("redacts encoded and invisible-spliced query names in invalid URL-like strings", () => {
203223
expect(
204224
redactSensitiveUrlLikeString("//example.com/mcp?client%5Fse%E2%80%8Bcret=secret&safe=value"),
@@ -263,6 +283,14 @@ describe("isSensitiveUrlQueryParamName", () => {
263283
expect(isSensitiveUrlQueryParamName("client_se+cret")).toBe(true);
264284
expect(isSensitiveUrlQueryParamName("client_se\u3164cret")).toBe(true);
265285
expect(isSensitiveUrlQueryParamName("credential")).toBe(true);
286+
expect(isSensitiveUrlQueryParamName("sig")).toBe(true);
287+
expect(isSensitiveUrlQueryParamName("X-Api-Key")).toBe(true);
288+
expect(isSensitiveUrlQueryParamName("x-access-token")).toBe(true);
289+
expect(isSensitiveUrlQueryParamName("x-auth-token")).toBe(true);
290+
expect(isSensitiveUrlQueryParamName("signal")).toBe(false);
291+
expect(isSensitiveUrlQueryParamName("sigmoid")).toBe(false);
292+
expect(isSensitiveUrlQueryParamName("x-api-version")).toBe(false);
293+
expect(isSensitiveUrlQueryParamName("x-request-id")).toBe(false);
266294
expect(isSensitiveUrlQueryParamName("safe")).toBe(false);
267295
});
268296
});

‎packages/net-policy/src/redact-sensitive-url.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ const SENSITIVE_URL_QUERY_PARAM_NAMES = new Set([
3636
"private_key",
3737
"credential",
3838
"authorization",
39+
// Common signed/API gateway aliases that do not contain an existing secret-name marker.
40+
"sig",
41+
"x_api_key",
42+
"x_access_token",
43+
"x_auth_token",
3944
]);
4045
// Align with FORM_BODY_KEY_SEPARATOR_RE: category-Lo Hangul fillers can splice sensitive names.
4146
const URL_QUERY_NAME_SEPARATOR_RE = /[\p{C}\p{Z}\u115F\u1160\u3164\uFFA0+]/gu;

‎src/agents/agent-hooks/compaction-safeguard-quality.ts‎

Lines changed: 22 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,16 @@ function resolveExactIdentifierSectionInstruction(
3939
if (policy === "off") {
4040
return POLICY_OFF_EXACT_IDENTIFIERS_INSTRUCTION;
4141
}
42-
if (policy === "custom") {
43-
const custom = summarizationInstructions?.identifierInstructions?.trim();
44-
if (custom) {
45-
// Operator text is runtime data, not prompt authority. Wrap it as
46-
// untrusted data before inserting it into compaction instructions.
47-
const customBlock = wrapUntrustedInstructionBlock(
42+
const custom =
43+
policy === "custom" ? summarizationInstructions?.identifierInstructions?.trim() : undefined;
44+
if (custom) {
45+
// Operator text is runtime data, never prompt authority.
46+
return (
47+
wrapUntrustedInstructionBlock(
4848
"For ## Exact identifiers, apply this operator-defined policy text",
4949
custom,
50-
);
51-
if (customBlock) {
52-
return customBlock;
53-
}
54-
}
50+
) || STRICT_EXACT_IDENTIFIERS_INSTRUCTION
51+
);
5552
}
5653
return STRICT_EXACT_IDENTIFIERS_INSTRUCTION;
5754
}
@@ -71,14 +68,9 @@ export function buildCompactionStructureInstructions(
7168
"When prior compaction summaries are present, re-distill them with new messages and remove stale duplicate detail.",
7269
].join("\n");
7370
const custom = customInstructions?.trim();
74-
if (!custom) {
75-
return sectionsTemplate;
76-
}
77-
const customBlock = wrapUntrustedInstructionBlock("Additional context from /compact", custom);
78-
if (!customBlock) {
79-
return sectionsTemplate;
80-
}
81-
return `${sectionsTemplate}\n\n${customBlock}`;
71+
const customBlock =
72+
custom && wrapUntrustedInstructionBlock("Additional context from /compact", custom);
73+
return customBlock ? `${sectionsTemplate}\n\n${customBlock}` : sectionsTemplate;
8274
}
8375

8476
function normalizedSummaryLines(summary: string): string[] {
@@ -110,26 +102,18 @@ export function buildStructuredFallbackSummary(
110102
if (trimmedPreviousSummary && hasRequiredSummarySections(trimmedPreviousSummary)) {
111103
return trimmedPreviousSummary;
112104
}
113-
const exactIdentifiersSummary = "None captured.";
114-
return [
115-
"## Decisions",
105+
const values = [
116106
trimmedPreviousSummary || "No prior history.",
117-
"",
118-
"## Open TODOs",
119107
"None.",
120-
"",
121-
"## Constraints/Rules",
122108
"None.",
123-
"",
124-
"## Pending user asks",
125109
"None.",
126-
"",
127-
"## Exact identifiers",
128-
exactIdentifiersSummary,
129-
].join("\n");
110+
"None captured.",
111+
];
112+
return REQUIRED_SUMMARY_SECTIONS.map((heading, index) => `${heading}\n${values[index]}`).join(
113+
"\n\n",
114+
);
130115
}
131116

132-
/** Append an already-formatted summary section without disturbing empty summaries. */
133117
/** Appends a bounded post-compaction section to an existing summary. */
134118
export function appendSummarySection(summary: string, section: string): string {
135119
if (!section) {
@@ -172,8 +156,7 @@ export function extractOpaqueIdentifiers(text: string): string[] {
172156
return Array.from(
173157
new Set(
174158
matches
175-
.map((value) => sanitizeExtractedIdentifier(value))
176-
.map((value) => normalizeOpaqueIdentifier(value))
159+
.map((value) => normalizeOpaqueIdentifier(sanitizeExtractedIdentifier(value)))
177160
.filter((value) => value.length >= 4),
178161
),
179162
).slice(0, MAX_EXTRACTED_IDENTIFIERS);
@@ -205,31 +188,16 @@ function hasAskOverlap(summary: string, latestAsk: string | null): boolean {
205188
if (askTokens.length === 0) {
206189
return true;
207190
}
208-
const meaningfulAskTokens = askTokens.filter((token) => {
209-
if (token.length <= 1) {
210-
return false;
211-
}
212-
if (isQueryStopWordToken(token)) {
213-
return false;
214-
}
215-
return true;
216-
});
191+
const meaningfulAskTokens = askTokens.filter(
192+
(token) => token.length > 1 && !isQueryStopWordToken(token),
193+
);
217194
const tokensToCheck = meaningfulAskTokens.length > 0 ? meaningfulAskTokens : askTokens;
218-
if (tokensToCheck.length === 0) {
219-
return true;
220-
}
221195
const summaryTokens = new Set(tokenizeAskOverlapText(summary));
222-
let overlapCount = 0;
223-
for (const token of tokensToCheck) {
224-
if (summaryTokens.has(token)) {
225-
overlapCount += 1;
226-
}
227-
}
196+
const overlapCount = tokensToCheck.filter((token) => summaryTokens.has(token)).length;
228197
const requiredMatches = tokensToCheck.length >= MIN_ASK_OVERLAP_TOKENS_FOR_DOUBLE_MATCH ? 2 : 1;
229198
return overlapCount >= requiredMatches;
230199
}
231200

232-
/** Audit summary structure, exact identifier preservation, and latest-ask coverage. */
233201
/** Audits a candidate summary for required sections, pending asks, and identifier preservation. */
234202
export function auditSummaryQuality(params: {
235203
summary: string;

0 commit comments

Comments
 (0)