pi-smart-compact 9.0.0 → 9.1.0
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/ARCHITECTURE.md +45 -35
- package/CHANGELOG.md +17 -0
- package/dist/app/native-continuity-bridge.d.ts.map +1 -1
- package/dist/app/pending-slot.d.ts.map +1 -1
- package/dist/app/preflight.d.ts +3 -3
- package/dist/app/preflight.d.ts.map +1 -1
- package/dist/app/run-smart-compact.d.ts.map +1 -1
- package/dist/app/session-run-lock.d.ts.map +1 -1
- package/dist/app/steps/extract.d.ts.map +1 -1
- package/dist/app/steps/metrics.d.ts +4 -4
- package/dist/app/steps/metrics.d.ts.map +1 -1
- package/dist/app/steps/persist.d.ts.map +1 -1
- package/dist/app/steps/synthesize.d.ts.map +1 -1
- package/dist/app/steps/window.d.ts +1 -1
- package/dist/app/steps/window.d.ts.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/domain/scrub.d.ts.map +1 -1
- package/dist/domain/summary-parse.d.ts.map +1 -1
- package/dist/domain/tool-semantics.d.ts +6 -9
- package/dist/domain/tool-semantics.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1109 -347
- package/dist/infra/ai-messages.d.ts +6 -0
- package/dist/infra/ai-messages.d.ts.map +1 -1
- package/dist/infra/context-graph.d.ts.map +1 -1
- package/dist/infra/fs.d.ts +2 -0
- package/dist/infra/fs.d.ts.map +1 -1
- package/dist/phases/explore.d.ts +2 -1
- package/dist/phases/explore.d.ts.map +1 -1
- package/dist/phases/synthesize.d.ts.map +1 -1
- package/dist/phases/verify.d.ts.map +1 -1
- package/dist/provider-eval.js +214 -33
- package/dist/provider-scenario-eval.js +277 -57
- package/dist/telemetry-report.js +214 -33
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/cache.d.ts +2 -2
- package/dist/utils/cache.d.ts.map +1 -1
- package/dist/utils/extraction.d.ts +2 -1
- package/dist/utils/extraction.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +14 -2
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/session-log.d.ts +1 -1
- package/dist/utils/session-log.d.ts.map +1 -1
- package/dist/utils/state.d.ts.map +1 -1
- package/dist/utils/tokens.d.ts +2 -0
- package/dist/utils/tokens.d.ts.map +1 -1
- package/dist/utils/type-guards.d.ts +2 -0
- package/dist/utils/type-guards.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import type { Message } from "@earendil-works/pi-ai";
|
|
19
19
|
import type { LlmMessage } from "../types.ts";
|
|
20
|
+
import type { SecretScrubber } from "../domain/scrub.ts";
|
|
20
21
|
/**
|
|
21
22
|
* Upcast a raw branch entry's `message` to a `Message` for `convertToLlm`.
|
|
22
23
|
*
|
|
@@ -37,4 +38,9 @@ export declare function asBranchMessage(message: unknown): Message;
|
|
|
37
38
|
* `role` + `content` to render text, so the upcast is sound.
|
|
38
39
|
*/
|
|
39
40
|
export declare function asSerializableMessages(msgs: LlmMessage[]): Message[];
|
|
41
|
+
/**
|
|
42
|
+
* Clone and structurally redact messages before any host serializer flattens
|
|
43
|
+
* secret-bearing argument keys into ordinary text.
|
|
44
|
+
*/
|
|
45
|
+
export declare function scrubLlmMessages(msgs: LlmMessage[], scrubber: SecretScrubber): LlmMessage[];
|
|
40
46
|
//# sourceMappingURL=ai-messages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-messages.d.ts","sourceRoot":"","sources":["../../src/infra/ai-messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-messages.d.ts","sourceRoot":"","sources":["../../src/infra/ai-messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAEpE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,cAAc,GAAG,UAAU,EAAE,CAE3F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-graph.d.ts","sourceRoot":"","sources":["../../src/infra/context-graph.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,aAAa,CAAC;AAcvE,MAAM,MAAM,iBAAiB,GACzB,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,OAAO,GAAG,MAAM,GACrD,aAAa,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,GAC7C,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAEvD,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACtC;AAED,MAAM,WA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AED,gEAAgE;AAChE,wBAAgB,2BAA2B,IAAI,IAAI,CAGlD;AAED,0FAA0F;AAC1F,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAChC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,GAAG,YAAY,GAChC,MAAM,CAqBR;AAED,wDAAwD;AACxD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,GAAG,kBAAkB,CAiDtH;AA4ED,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,mBAAmB,EAAE,CAuEhI;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,mBAAmB,EAAE,EAAE,QAAQ,SAAQ,GAAG,MAAM,CAyB5F;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,CAsBzE"}
|
package/dist/infra/fs.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ export declare function acquireLock(target: string): Promise<() => void>;
|
|
|
51
51
|
* Retention therefore happens synchronously, but only when the cap is crossed.
|
|
52
52
|
*/
|
|
53
53
|
export declare function appendLineLocked(target: string, line: string, maxBytes?: number): void;
|
|
54
|
+
/** Async append/retention variant for event-loop-sensitive telemetry paths. */
|
|
55
|
+
export declare function appendLineLockedAsync(target: string, line: string, maxBytes?: number): Promise<void>;
|
|
54
56
|
/** Read the newest valid JSONL records without loading an entire bounded log. */
|
|
55
57
|
export declare function readJsonlTail<T>(target: string, limit: number, maxBytes?: number): T[];
|
|
56
58
|
/** Keep only complete trailing lines that fit within `maxBytes`. */
|
package/dist/infra/fs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["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AAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBxF;AAGD,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CASxD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,UAAQ,GAAG,IAAI,CAElF"}
|
package/dist/phases/explore.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { Model, Api, ProviderHeaders } from "@earendil-works/pi-ai";
|
|
5
5
|
import type { LlmMessage, StructuredExtraction, ExplorationReport } from "../types.ts";
|
|
6
6
|
import type { SmartCompactServices } from "../infra/services.ts";
|
|
7
|
+
import { SecretScrubber } from "../domain/scrub.ts";
|
|
7
8
|
/**
|
|
8
9
|
* Determine whether exploration is worthwhile based on session complexity.
|
|
9
10
|
* Simple sessions (few topics, few errors, few decisions) skip exploration
|
|
@@ -13,7 +14,7 @@ export declare function shouldExplore(extraction: StructuredExtraction): boolean
|
|
|
13
14
|
export declare function executeExplorationTool(call: {
|
|
14
15
|
name: string;
|
|
15
16
|
arguments: Record<string, unknown>;
|
|
16
|
-
}, llmMessages: LlmMessage[]): string;
|
|
17
|
+
}, llmMessages: LlmMessage[], scrubber?: SecretScrubber): string;
|
|
17
18
|
export declare function parseExplorationReport(text: string, llmMessages: LlmMessage[]): ExplorationReport;
|
|
18
19
|
export declare function buildExplorationReportFromParsed(parsed: unknown, llmMessages: LlmMessage[]): ExplorationReport;
|
|
19
20
|
export declare function fallbackExplorationReport(llmMessages: LlmMessage[]): ExplorationReport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explore.d.ts","sourceRoot":"","sources":["../../src/phases/explore.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAwC,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE/G,OAAO,KAAK,EA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O,CAAC,iBAAiB,CAAC,CAsB5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synthesize.d.ts","sourceRoot":"","sources":["../../src/phases/synthesize.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EACV,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EACxD,iBAAiB,EAAE,aAAa,EACjC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAuC,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAK9F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAWjE,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAO9D;
|
|
1
|
+
{"version":3,"file":"synthesize.d.ts","sourceRoot":"","sources":["../../src/phases/synthesize.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EACV,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EACxD,iBAAiB,EAAE,aAAa,EACjC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAuC,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAK9F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAWjE,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAO9D;AAgHD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAAE,EAClB,UAAU,EAAE,OAAO,aAAa,EAAE,aAAa,EAAE,EACjD,EAAE,EAAE,aAAa,EACjB,SAAS,GAAE,cAAqC,EAChD,KAAK,CAAC,EAAE,MA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AAQ,CAAC,EAAE,oBAAoB,EAAE,KAAK,CAAC,EAAE,MAAM,GACzF,OAAO,CAAC,MAAM,CAAC,CAuBjB;AAED,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,YAAY,EAAE,EACzB,UAAU,EAAE,oBAAoB,EAChC,QAAQ,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/C,MAAM,CAkDR;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,GAAG,YAAY,CAM7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/phases/verify.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/phases/verify.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,eAAe,EAAe,MAAM,uBAAuB,CAAC;AACtF,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,eAAe,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAa1H,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC,QAAQ,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9C;AAiHD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAelE;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,GAAG,IAAI,CAOpF;A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CAAE,EAAE,MAAM,CAAC,EAAE,WAAW,EAC5F,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAyBjB"}
|
package/dist/provider-eval.js
CHANGED
|
@@ -156,7 +156,7 @@ function formatProviderEvaluation(report) {
|
|
|
156
156
|
import fs2 from "fs";
|
|
157
157
|
|
|
158
158
|
// src/constants.ts
|
|
159
|
-
var VERSION = "9.
|
|
159
|
+
var VERSION = "9.1.0";
|
|
160
160
|
var COMPACT_SYSTEM_PREFIX = "You are an expert conversation summarizer for a coding agent. " + "Produce structured markdown summaries. " + "Follow output format exactly. " + "Use EXACT names \u2014 never paraphrase code identifiers. " + "Trust deterministic extraction data over intuition.";
|
|
161
161
|
var PROFILES = {
|
|
162
162
|
light: {
|
|
@@ -312,6 +312,14 @@ var FIVE_MINUTES_MS = 5 * 60 * 1000;
|
|
|
312
312
|
var ONE_HOUR_MS = 60 * 60 * 1000;
|
|
313
313
|
var SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000;
|
|
314
314
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1000;
|
|
315
|
+
var ID_PREFIX = {
|
|
316
|
+
PROJECT: "proj-",
|
|
317
|
+
COMPACT_SESSION: "sc-",
|
|
318
|
+
MULTI_TOOL_USE_SYNTHETIC: "mtu_",
|
|
319
|
+
OPEN_LOOP: "loop-",
|
|
320
|
+
DECISION: "decision-",
|
|
321
|
+
ERROR: "error-"
|
|
322
|
+
};
|
|
315
323
|
var TUNING = {
|
|
316
324
|
EMA_PREV: 0.7,
|
|
317
325
|
EMA_SAMPLE: 0.3,
|
|
@@ -427,8 +435,14 @@ function calibrationKey(provider, model) {
|
|
|
427
435
|
}
|
|
428
436
|
|
|
429
437
|
// src/utils/type-guards.ts
|
|
438
|
+
function isRecord(value) {
|
|
439
|
+
return typeof value === "object" && value !== null;
|
|
440
|
+
}
|
|
430
441
|
function isTextBlock(c) {
|
|
431
|
-
return
|
|
442
|
+
return isRecord(c) && c.type === "text" && typeof c.text === "string";
|
|
443
|
+
}
|
|
444
|
+
function isToolCallBlock(c) {
|
|
445
|
+
return isRecord(c) && c.type === "toolCall" && typeof c.name === "string" && isRecord(c.arguments);
|
|
432
446
|
}
|
|
433
447
|
var KNOWN_METHODS = new Set(["eesv", "single-pass", "heuristic"]);
|
|
434
448
|
var KNOWN_PROFILES = new Set(["light", "balanced", "aggressive"]);
|
|
@@ -449,9 +463,37 @@ var GENERIC_BASENAMES = new Set([
|
|
|
449
463
|
"lib.rs",
|
|
450
464
|
"__init__.py"
|
|
451
465
|
]);
|
|
466
|
+
var MIN_BARE_BASENAME_LEN = 5;
|
|
452
467
|
function normalizePath(filePath) {
|
|
453
468
|
return filePath.replace(/\\/g, "/").replace(/^\.\//, "").toLowerCase();
|
|
454
469
|
}
|
|
470
|
+
function buildPathNeedles(filePath) {
|
|
471
|
+
const parts = normalizePath(filePath).split("/").filter(Boolean);
|
|
472
|
+
if (parts.length === 0)
|
|
473
|
+
return [];
|
|
474
|
+
const needles = [];
|
|
475
|
+
const basename = parts[parts.length - 1];
|
|
476
|
+
if (!GENERIC_BASENAMES.has(basename) && basename.length >= MIN_BARE_BASENAME_LEN) {
|
|
477
|
+
needles.push(basename);
|
|
478
|
+
}
|
|
479
|
+
for (let j = parts.length - 2;j >= 0; j--) {
|
|
480
|
+
needles.push(parts.slice(j).join("/"));
|
|
481
|
+
}
|
|
482
|
+
return needles;
|
|
483
|
+
}
|
|
484
|
+
function buildUniquePathNeedles(filePath, allPaths) {
|
|
485
|
+
const normalized = allPaths.map(normalizePath);
|
|
486
|
+
return buildPathNeedles(filePath).filter((needle) => {
|
|
487
|
+
let owners = 0;
|
|
488
|
+
for (const candidate of normalized) {
|
|
489
|
+
if (candidate === needle || candidate.endsWith("/" + needle))
|
|
490
|
+
owners++;
|
|
491
|
+
if (owners > 1)
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
return owners === 1;
|
|
495
|
+
});
|
|
496
|
+
}
|
|
455
497
|
function isKnownPathReference(ref, knownPaths) {
|
|
456
498
|
const normalizedRef = normalizePath(ref);
|
|
457
499
|
return knownPaths.some((path) => {
|
|
@@ -460,6 +502,74 @@ function isKnownPathReference(ref, knownPaths) {
|
|
|
460
502
|
});
|
|
461
503
|
}
|
|
462
504
|
|
|
505
|
+
// src/domain/tool-semantics.ts
|
|
506
|
+
var PATH_KEYS = [
|
|
507
|
+
"path",
|
|
508
|
+
"file_path",
|
|
509
|
+
"filePath",
|
|
510
|
+
"filename",
|
|
511
|
+
"file",
|
|
512
|
+
"target_file",
|
|
513
|
+
"file_uri",
|
|
514
|
+
"absolute_path"
|
|
515
|
+
];
|
|
516
|
+
var PAYLOAD_KEYS = [
|
|
517
|
+
"content",
|
|
518
|
+
"newText",
|
|
519
|
+
"oldText",
|
|
520
|
+
"new_str",
|
|
521
|
+
"old_str",
|
|
522
|
+
"new_string",
|
|
523
|
+
"old_string",
|
|
524
|
+
"edits",
|
|
525
|
+
"patch",
|
|
526
|
+
"replacement"
|
|
527
|
+
];
|
|
528
|
+
var COMMAND_KEYS = ["command", "cmd", "script"];
|
|
529
|
+
function hasPresent(args, keys) {
|
|
530
|
+
return keys.some((k) => args[k] != null);
|
|
531
|
+
}
|
|
532
|
+
function extractToolPath(args) {
|
|
533
|
+
if (!args || typeof args !== "object")
|
|
534
|
+
return;
|
|
535
|
+
const a = args;
|
|
536
|
+
for (const k of PATH_KEYS) {
|
|
537
|
+
const v = a[k];
|
|
538
|
+
if (typeof v === "string" && v.length > 0)
|
|
539
|
+
return v;
|
|
540
|
+
}
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
function normalizeToolName(name) {
|
|
544
|
+
if (typeof name !== "string")
|
|
545
|
+
return "";
|
|
546
|
+
return name.replace(/^functions[.:/_-]+/i, "").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
547
|
+
}
|
|
548
|
+
function nameHas(name, hints) {
|
|
549
|
+
const words = name.split("_");
|
|
550
|
+
return hints.some((hint) => words.includes(hint));
|
|
551
|
+
}
|
|
552
|
+
function classifyToolOperation(args, toolName) {
|
|
553
|
+
const a = args && typeof args === "object" ? args : {};
|
|
554
|
+
const name = normalizeToolName(toolName);
|
|
555
|
+
const hasPath = extractToolPath(a) !== undefined;
|
|
556
|
+
if (hasPath && hasPresent(a, PAYLOAD_KEYS))
|
|
557
|
+
return "mutate";
|
|
558
|
+
if (hasPresent(a, COMMAND_KEYS))
|
|
559
|
+
return "execute";
|
|
560
|
+
if (hasPath && hasPresent(a, ["text"]) && nameHas(name, ["write", "edit", "patch", "replace", "append", "create", "update", "insert"]))
|
|
561
|
+
return "mutate";
|
|
562
|
+
if (hasPath && nameHas(name, ["delete", "remove", "unlink"]))
|
|
563
|
+
return "delete";
|
|
564
|
+
if (hasPresent(a, ["pattern", "query", "glob"]) || nameHas(name, ["grep", "search", "find", "glob", "rg"]))
|
|
565
|
+
return "search";
|
|
566
|
+
if (nameHas(name, ["list", "ls", "tree"]))
|
|
567
|
+
return "list";
|
|
568
|
+
if (hasPath || nameHas(name, ["read"]))
|
|
569
|
+
return "read";
|
|
570
|
+
return "unknown";
|
|
571
|
+
}
|
|
572
|
+
|
|
463
573
|
// src/utils/file-ref-detect.ts
|
|
464
574
|
var CODE_EXT_RE = /\.(ts|tsx|js|jsx|mjs|cjs|rs|py|go|java|rb|cs|cpp|c|h|hpp|swift|kt|scala|php|css|scss|html|json|yaml|yml|toml|md|mdx|sh|sql|tf|ini|env|lock|gradle|xml)$/i;
|
|
465
575
|
var VERSION_RE = /^v?\d+(?:\.\d+)+(?:[-+][\w.-]+)?$/i;
|
|
@@ -530,6 +640,7 @@ function parseSummary(markdown) {
|
|
|
530
640
|
let currentHeading = "";
|
|
531
641
|
let currentKind = "unknown";
|
|
532
642
|
let bodyLines = [];
|
|
643
|
+
let fence = null;
|
|
533
644
|
let started = false;
|
|
534
645
|
const flush = () => {
|
|
535
646
|
if (!started)
|
|
@@ -543,16 +654,31 @@ function parseSummary(markdown) {
|
|
|
543
654
|
sections.push({ kind: currentKind, heading: currentHeading.trim(), body });
|
|
544
655
|
};
|
|
545
656
|
for (const line of lines) {
|
|
546
|
-
const
|
|
547
|
-
if (
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
657
|
+
const fenceMatch = line.match(/^\s{0,3}(`{3,}|~{3,})(.*)$/);
|
|
658
|
+
if (fenceMatch) {
|
|
659
|
+
const marker = fenceMatch[1][0];
|
|
660
|
+
const markerLength = fenceMatch[1].length;
|
|
661
|
+
if (!fence) {
|
|
662
|
+
fence = { marker, length: markerLength };
|
|
663
|
+
} else if (marker === fence.marker && markerLength >= fence.length && !fenceMatch[2].trim()) {
|
|
664
|
+
fence = null;
|
|
665
|
+
}
|
|
666
|
+
if (started)
|
|
667
|
+
bodyLines.push(line);
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
670
|
+
if (!fence) {
|
|
671
|
+
const heading = line.match(HEADING_RE);
|
|
672
|
+
if (heading) {
|
|
673
|
+
const kind = classifyHeading(heading[2]);
|
|
674
|
+
if (heading[1].length <= 2 || kind !== "unknown") {
|
|
675
|
+
flush();
|
|
676
|
+
currentHeading = "## " + heading[2].trim();
|
|
677
|
+
currentKind = kind;
|
|
678
|
+
bodyLines = [];
|
|
679
|
+
started = true;
|
|
680
|
+
continue;
|
|
681
|
+
}
|
|
556
682
|
}
|
|
557
683
|
}
|
|
558
684
|
if (started)
|
|
@@ -567,6 +693,24 @@ function findSection(summary, kind) {
|
|
|
567
693
|
}
|
|
568
694
|
|
|
569
695
|
// src/utils/extraction.ts
|
|
696
|
+
function nestedToolCallId(wrapperId, messageIndex, toolIndex, nestedId) {
|
|
697
|
+
return typeof nestedId === "string" ? nestedId : wrapperId ? wrapperId + "_" + toolIndex : ID_PREFIX.MULTI_TOOL_USE_SYNTHETIC + messageIndex + "_" + toolIndex;
|
|
698
|
+
}
|
|
699
|
+
function flattenToolCallBlock(b) {
|
|
700
|
+
if (!isToolCallBlock(b))
|
|
701
|
+
return [];
|
|
702
|
+
if (b.name === "multi_tool_use.parallel" && Array.isArray(b.arguments?.tool_uses)) {
|
|
703
|
+
return b.arguments.tool_uses.map((u) => {
|
|
704
|
+
const recipient = u?.recipient_name ?? "";
|
|
705
|
+
return {
|
|
706
|
+
name: recipient.replace(/^functions\./, ""),
|
|
707
|
+
id: u?.id ?? undefined,
|
|
708
|
+
arguments: u?.parameters ?? {}
|
|
709
|
+
};
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
return [{ name: b.name, id: b.id, arguments: b.arguments }];
|
|
713
|
+
}
|
|
570
714
|
function extractText(content) {
|
|
571
715
|
if (typeof content === "string")
|
|
572
716
|
return content;
|
|
@@ -580,6 +724,31 @@ function extractText(content) {
|
|
|
580
724
|
return "";
|
|
581
725
|
}).join("");
|
|
582
726
|
}
|
|
727
|
+
function buildToolCallIndex(msgs) {
|
|
728
|
+
const idx = new Map;
|
|
729
|
+
for (let i = 0;i < msgs.length; i++) {
|
|
730
|
+
const m = msgs[i];
|
|
731
|
+
if (m.role !== "assistant")
|
|
732
|
+
continue;
|
|
733
|
+
const blocks = Array.isArray(m.content) ? m.content : [];
|
|
734
|
+
for (const b of blocks) {
|
|
735
|
+
if (!isToolCallBlock(b))
|
|
736
|
+
continue;
|
|
737
|
+
if (b.id) {
|
|
738
|
+
idx.set(b.id, { name: b.name, arguments: b.arguments, msgIndex: i });
|
|
739
|
+
}
|
|
740
|
+
if (b.name === "multi_tool_use.parallel" && Array.isArray(b.arguments?.tool_uses)) {
|
|
741
|
+
const nested = flattenToolCallBlock(b);
|
|
742
|
+
for (let t = 0;t < nested.length; t++) {
|
|
743
|
+
const tool = nested[t];
|
|
744
|
+
const id = nestedToolCallId(b.id, i, t, tool.id);
|
|
745
|
+
idx.set(id, { name: tool.name, arguments: tool.arguments, msgIndex: i });
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return idx;
|
|
751
|
+
}
|
|
583
752
|
var CONSTRAINT_PATTERNS = [
|
|
584
753
|
{ re: /\b(?:must|need|require|has to|important)\b.*\b(?:be|use|have|include|support)\b/i, cat: "requirement", conf: TUNING.CONFIDENCE_HIGH },
|
|
585
754
|
{ re: /\b(?:don't|never|avoid|shouldn't|must not|do not|no\s+(?:need|want))\b/i, cat: "prohibition", conf: TUNING.CONFIDENCE_MEDIUM },
|
|
@@ -873,30 +1042,41 @@ function mergeFindings(target, findings) {
|
|
|
873
1042
|
for (const finding of findings)
|
|
874
1043
|
target.set(finding.kind, (target.get(finding.kind) ?? 0) + finding.count);
|
|
875
1044
|
}
|
|
876
|
-
var SECRET_KEY_NAMES =
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
1045
|
+
var SECRET_KEY_NAMES = {
|
|
1046
|
+
api_key: true,
|
|
1047
|
+
apikey: true,
|
|
1048
|
+
access_token: true,
|
|
1049
|
+
auth_token: true,
|
|
1050
|
+
authorization: true,
|
|
1051
|
+
password: true,
|
|
1052
|
+
passwd: true,
|
|
1053
|
+
secret: true,
|
|
1054
|
+
secret_key: true,
|
|
1055
|
+
secret_access_key: true,
|
|
1056
|
+
client_secret: true,
|
|
1057
|
+
private_key: true,
|
|
1058
|
+
database_url: true,
|
|
1059
|
+
connection_string: true,
|
|
1060
|
+
token: true,
|
|
1061
|
+
refresh_token: true,
|
|
1062
|
+
session_token: true,
|
|
1063
|
+
credential: true,
|
|
1064
|
+
credentials: true,
|
|
1065
|
+
cookie: true,
|
|
1066
|
+
set_cookie: true,
|
|
1067
|
+
otp: true,
|
|
1068
|
+
one_time_password: true,
|
|
1069
|
+
pin: true,
|
|
1070
|
+
passcode: true
|
|
1071
|
+
};
|
|
892
1072
|
function normalizeObjectKey(key) {
|
|
893
1073
|
return key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
894
1074
|
}
|
|
895
1075
|
function isSecretBearingKey(key) {
|
|
896
1076
|
const normalized = normalizeObjectKey(key);
|
|
897
|
-
if (SECRET_KEY_NAMES
|
|
1077
|
+
if (SECRET_KEY_NAMES[normalized])
|
|
898
1078
|
return true;
|
|
899
|
-
return /(?:^|_)(?:api_key|access_token|auth_token|password|passwd|secret_access_key|client_secret|private_key)(?:_|$)/.test(normalized);
|
|
1079
|
+
return /(?:^|_)(?:api_key|access_token|auth_token|password|passwd|secret_access_key|client_secret|private_key|refresh_token|session_token|one_time_password|passcode)(?:_|$)/.test(normalized);
|
|
900
1080
|
}
|
|
901
1081
|
|
|
902
1082
|
class SecretScrubber {
|
|
@@ -952,7 +1132,8 @@ class SecretScrubber {
|
|
|
952
1132
|
const output = {};
|
|
953
1133
|
seen.set(value2, output);
|
|
954
1134
|
for (const [key, item] of Object.entries(value2)) {
|
|
955
|
-
|
|
1135
|
+
const carriesSecret = typeof item === "string" ? item.length > 0 : item != null;
|
|
1136
|
+
if (this.secretsEnabled && isSecretBearingKey(key) && carriesSecret) {
|
|
956
1137
|
output[key] = "[REDACTED:credential]";
|
|
957
1138
|
recordCredential();
|
|
958
1139
|
} else {
|
|
@@ -1217,8 +1398,8 @@ function readMetricsLog(limit = 100) {
|
|
|
1217
1398
|
const fd = fs2.openSync(logPath, "r");
|
|
1218
1399
|
try {
|
|
1219
1400
|
const buf = Buffer.alloc(wantBytes);
|
|
1220
|
-
fs2.readSync(fd, buf, 0, wantBytes, startPos);
|
|
1221
|
-
let text = buf.toString("utf8");
|
|
1401
|
+
const bytesRead = fs2.readSync(fd, buf, 0, wantBytes, startPos);
|
|
1402
|
+
let text = buf.subarray(0, bytesRead).toString("utf8");
|
|
1222
1403
|
if (startPos > 0) {
|
|
1223
1404
|
const nl = text.indexOf(`
|
|
1224
1405
|
`);
|