pi-smart-compact 9.0.0 → 9.2.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 +61 -36
- package/CHANGELOG.md +28 -0
- package/README.md +30 -5
- 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/settled-auto-trigger.d.ts +20 -0
- package/dist/app/settled-auto-trigger.d.ts.map +1 -0
- 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 +8 -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 +1216 -364
- 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 +3 -2
- package/dist/phases/verify.d.ts.map +1 -1
- package/dist/provider-eval.js +216 -33
- package/dist/provider-scenario-eval.js +279 -57
- package/dist/telemetry-report.js +216 -33
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/dashboard-format.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,oBAA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AAK,EAAE,eAAe,GAAG,OAAO,CAsFvF;AA+BD,uFAAuF;AACvF,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAa/F;AAED,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":["../../src/infra/fs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAYH,0EAA0E;AAC1E,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAG3C;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG/D;AAMD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAYnF;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAW9F;AAmCD,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,CAI1D;AAYD,+EAA+E;AAC/E,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CASrE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAoCtF;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAa,GAAG,CAAC,EAAE,CAoB1F;AAED,oEAAoE;AACpE,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBxF;AAGD,wBAAgB,YAAY,CAAC,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,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAa,GAAG,CAAC,EAAE,CAoB1F;AAED,oEAAoE;AACpE,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,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":["../../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,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC7D,MAAM,CAAC,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,OAAO,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,IAA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AAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,eAAe,CAAA;CAAE,EAAE,MAAM,EAAE,MAAM,EACtF,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,QAAQ,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"}
|
package/dist/phases/verify.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* boundary; repair logic switches on `kind` and never reparses its own prose.
|
|
6
6
|
*/
|
|
7
7
|
import type { Model, Api, ProviderHeaders } from "@earendil-works/pi-ai";
|
|
8
|
-
import type { CompactionState, StructuredExtraction, VerificationGap, VerificationResult, LlmMessage } from "../types.ts";
|
|
8
|
+
import type { CompactionState, StructuredExtraction, VerificationGap, VerificationGateStage, VerificationResult, LlmMessage } from "../types.ts";
|
|
9
9
|
import type { SmartCompactServices } from "../infra/services.ts";
|
|
10
10
|
export interface VerificationEvidence {
|
|
11
11
|
sourceMessages?: readonly LlmMessage[];
|
|
@@ -21,8 +21,9 @@ export declare class VerificationGateError extends Error {
|
|
|
21
21
|
readonly score: number;
|
|
22
22
|
readonly initialScore: number;
|
|
23
23
|
readonly gapKinds: VerificationGap["kind"][];
|
|
24
|
+
readonly stage: VerificationGateStage;
|
|
24
25
|
readonly gapCount: number;
|
|
25
|
-
constructor(result: VerificationResult, initialScore: number);
|
|
26
|
+
constructor(result: VerificationResult, initialScore: number, stage: VerificationGateStage);
|
|
26
27
|
}
|
|
27
28
|
export declare function isDeterministicallyPatchable(gap: VerificationGap): boolean;
|
|
28
29
|
/** Apply safe repairs to a fixed point; newly introduced patchable gaps get another bounded pass. */
|
|
@@ -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,qBAAqB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAajJ,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;AAED,wFAAwF;AACxF,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;IAC7C,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;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|
|
|
156
156
|
import fs2 from "fs";
|
|
157
157
|
|
|
158
158
|
// src/constants.ts
|
|
159
|
-
var VERSION = "9.
|
|
159
|
+
var VERSION = "9.2.0";
|
|
160
|
+
var SETTLED_TRIGGER_COOLDOWN_MS = 10 * 60000;
|
|
160
161
|
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
162
|
var PROFILES = {
|
|
162
163
|
light: {
|
|
@@ -194,6 +195,7 @@ var DEFAULT_CONFIG = {
|
|
|
194
195
|
summaryThinkingLevel: "minimal",
|
|
195
196
|
segmentationThinkingLevel: "minimal",
|
|
196
197
|
autoTrigger: true,
|
|
198
|
+
autoTriggerStrategy: "native-hook",
|
|
197
199
|
autoTriggerTimeoutMs: 120000,
|
|
198
200
|
backupEnabled: true,
|
|
199
201
|
backupDir: "",
|
|
@@ -312,6 +314,14 @@ var FIVE_MINUTES_MS = 5 * 60 * 1000;
|
|
|
312
314
|
var ONE_HOUR_MS = 60 * 60 * 1000;
|
|
313
315
|
var SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000;
|
|
314
316
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1000;
|
|
317
|
+
var ID_PREFIX = {
|
|
318
|
+
PROJECT: "proj-",
|
|
319
|
+
COMPACT_SESSION: "sc-",
|
|
320
|
+
MULTI_TOOL_USE_SYNTHETIC: "mtu_",
|
|
321
|
+
OPEN_LOOP: "loop-",
|
|
322
|
+
DECISION: "decision-",
|
|
323
|
+
ERROR: "error-"
|
|
324
|
+
};
|
|
315
325
|
var TUNING = {
|
|
316
326
|
EMA_PREV: 0.7,
|
|
317
327
|
EMA_SAMPLE: 0.3,
|
|
@@ -427,8 +437,14 @@ function calibrationKey(provider, model) {
|
|
|
427
437
|
}
|
|
428
438
|
|
|
429
439
|
// src/utils/type-guards.ts
|
|
440
|
+
function isRecord(value) {
|
|
441
|
+
return typeof value === "object" && value !== null;
|
|
442
|
+
}
|
|
430
443
|
function isTextBlock(c) {
|
|
431
|
-
return
|
|
444
|
+
return isRecord(c) && c.type === "text" && typeof c.text === "string";
|
|
445
|
+
}
|
|
446
|
+
function isToolCallBlock(c) {
|
|
447
|
+
return isRecord(c) && c.type === "toolCall" && typeof c.name === "string" && isRecord(c.arguments);
|
|
432
448
|
}
|
|
433
449
|
var KNOWN_METHODS = new Set(["eesv", "single-pass", "heuristic"]);
|
|
434
450
|
var KNOWN_PROFILES = new Set(["light", "balanced", "aggressive"]);
|
|
@@ -449,9 +465,37 @@ var GENERIC_BASENAMES = new Set([
|
|
|
449
465
|
"lib.rs",
|
|
450
466
|
"__init__.py"
|
|
451
467
|
]);
|
|
468
|
+
var MIN_BARE_BASENAME_LEN = 5;
|
|
452
469
|
function normalizePath(filePath) {
|
|
453
470
|
return filePath.replace(/\\/g, "/").replace(/^\.\//, "").toLowerCase();
|
|
454
471
|
}
|
|
472
|
+
function buildPathNeedles(filePath) {
|
|
473
|
+
const parts = normalizePath(filePath).split("/").filter(Boolean);
|
|
474
|
+
if (parts.length === 0)
|
|
475
|
+
return [];
|
|
476
|
+
const needles = [];
|
|
477
|
+
const basename = parts[parts.length - 1];
|
|
478
|
+
if (!GENERIC_BASENAMES.has(basename) && basename.length >= MIN_BARE_BASENAME_LEN) {
|
|
479
|
+
needles.push(basename);
|
|
480
|
+
}
|
|
481
|
+
for (let j = parts.length - 2;j >= 0; j--) {
|
|
482
|
+
needles.push(parts.slice(j).join("/"));
|
|
483
|
+
}
|
|
484
|
+
return needles;
|
|
485
|
+
}
|
|
486
|
+
function buildUniquePathNeedles(filePath, allPaths) {
|
|
487
|
+
const normalized = allPaths.map(normalizePath);
|
|
488
|
+
return buildPathNeedles(filePath).filter((needle) => {
|
|
489
|
+
let owners = 0;
|
|
490
|
+
for (const candidate of normalized) {
|
|
491
|
+
if (candidate === needle || candidate.endsWith("/" + needle))
|
|
492
|
+
owners++;
|
|
493
|
+
if (owners > 1)
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
return owners === 1;
|
|
497
|
+
});
|
|
498
|
+
}
|
|
455
499
|
function isKnownPathReference(ref, knownPaths) {
|
|
456
500
|
const normalizedRef = normalizePath(ref);
|
|
457
501
|
return knownPaths.some((path) => {
|
|
@@ -460,6 +504,74 @@ function isKnownPathReference(ref, knownPaths) {
|
|
|
460
504
|
});
|
|
461
505
|
}
|
|
462
506
|
|
|
507
|
+
// src/domain/tool-semantics.ts
|
|
508
|
+
var PATH_KEYS = [
|
|
509
|
+
"path",
|
|
510
|
+
"file_path",
|
|
511
|
+
"filePath",
|
|
512
|
+
"filename",
|
|
513
|
+
"file",
|
|
514
|
+
"target_file",
|
|
515
|
+
"file_uri",
|
|
516
|
+
"absolute_path"
|
|
517
|
+
];
|
|
518
|
+
var PAYLOAD_KEYS = [
|
|
519
|
+
"content",
|
|
520
|
+
"newText",
|
|
521
|
+
"oldText",
|
|
522
|
+
"new_str",
|
|
523
|
+
"old_str",
|
|
524
|
+
"new_string",
|
|
525
|
+
"old_string",
|
|
526
|
+
"edits",
|
|
527
|
+
"patch",
|
|
528
|
+
"replacement"
|
|
529
|
+
];
|
|
530
|
+
var COMMAND_KEYS = ["command", "cmd", "script"];
|
|
531
|
+
function hasPresent(args, keys) {
|
|
532
|
+
return keys.some((k) => args[k] != null);
|
|
533
|
+
}
|
|
534
|
+
function extractToolPath(args) {
|
|
535
|
+
if (!args || typeof args !== "object")
|
|
536
|
+
return;
|
|
537
|
+
const a = args;
|
|
538
|
+
for (const k of PATH_KEYS) {
|
|
539
|
+
const v = a[k];
|
|
540
|
+
if (typeof v === "string" && v.length > 0)
|
|
541
|
+
return v;
|
|
542
|
+
}
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
function normalizeToolName(name) {
|
|
546
|
+
if (typeof name !== "string")
|
|
547
|
+
return "";
|
|
548
|
+
return name.replace(/^functions[.:/_-]+/i, "").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
549
|
+
}
|
|
550
|
+
function nameHas(name, hints) {
|
|
551
|
+
const words = name.split("_");
|
|
552
|
+
return hints.some((hint) => words.includes(hint));
|
|
553
|
+
}
|
|
554
|
+
function classifyToolOperation(args, toolName) {
|
|
555
|
+
const a = args && typeof args === "object" ? args : {};
|
|
556
|
+
const name = normalizeToolName(toolName);
|
|
557
|
+
const hasPath = extractToolPath(a) !== undefined;
|
|
558
|
+
if (hasPath && hasPresent(a, PAYLOAD_KEYS))
|
|
559
|
+
return "mutate";
|
|
560
|
+
if (hasPresent(a, COMMAND_KEYS))
|
|
561
|
+
return "execute";
|
|
562
|
+
if (hasPath && hasPresent(a, ["text"]) && nameHas(name, ["write", "edit", "patch", "replace", "append", "create", "update", "insert"]))
|
|
563
|
+
return "mutate";
|
|
564
|
+
if (hasPath && nameHas(name, ["delete", "remove", "unlink"]))
|
|
565
|
+
return "delete";
|
|
566
|
+
if (hasPresent(a, ["pattern", "query", "glob"]) || nameHas(name, ["grep", "search", "find", "glob", "rg"]))
|
|
567
|
+
return "search";
|
|
568
|
+
if (nameHas(name, ["list", "ls", "tree"]))
|
|
569
|
+
return "list";
|
|
570
|
+
if (hasPath || nameHas(name, ["read"]))
|
|
571
|
+
return "read";
|
|
572
|
+
return "unknown";
|
|
573
|
+
}
|
|
574
|
+
|
|
463
575
|
// src/utils/file-ref-detect.ts
|
|
464
576
|
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
577
|
var VERSION_RE = /^v?\d+(?:\.\d+)+(?:[-+][\w.-]+)?$/i;
|
|
@@ -530,6 +642,7 @@ function parseSummary(markdown) {
|
|
|
530
642
|
let currentHeading = "";
|
|
531
643
|
let currentKind = "unknown";
|
|
532
644
|
let bodyLines = [];
|
|
645
|
+
let fence = null;
|
|
533
646
|
let started = false;
|
|
534
647
|
const flush = () => {
|
|
535
648
|
if (!started)
|
|
@@ -543,16 +656,31 @@ function parseSummary(markdown) {
|
|
|
543
656
|
sections.push({ kind: currentKind, heading: currentHeading.trim(), body });
|
|
544
657
|
};
|
|
545
658
|
for (const line of lines) {
|
|
546
|
-
const
|
|
547
|
-
if (
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
659
|
+
const fenceMatch = line.match(/^\s{0,3}(`{3,}|~{3,})(.*)$/);
|
|
660
|
+
if (fenceMatch) {
|
|
661
|
+
const marker = fenceMatch[1][0];
|
|
662
|
+
const markerLength = fenceMatch[1].length;
|
|
663
|
+
if (!fence) {
|
|
664
|
+
fence = { marker, length: markerLength };
|
|
665
|
+
} else if (marker === fence.marker && markerLength >= fence.length && !fenceMatch[2].trim()) {
|
|
666
|
+
fence = null;
|
|
667
|
+
}
|
|
668
|
+
if (started)
|
|
669
|
+
bodyLines.push(line);
|
|
670
|
+
continue;
|
|
671
|
+
}
|
|
672
|
+
if (!fence) {
|
|
673
|
+
const heading = line.match(HEADING_RE);
|
|
674
|
+
if (heading) {
|
|
675
|
+
const kind = classifyHeading(heading[2]);
|
|
676
|
+
if (heading[1].length <= 2 || kind !== "unknown") {
|
|
677
|
+
flush();
|
|
678
|
+
currentHeading = "## " + heading[2].trim();
|
|
679
|
+
currentKind = kind;
|
|
680
|
+
bodyLines = [];
|
|
681
|
+
started = true;
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
556
684
|
}
|
|
557
685
|
}
|
|
558
686
|
if (started)
|
|
@@ -567,6 +695,24 @@ function findSection(summary, kind) {
|
|
|
567
695
|
}
|
|
568
696
|
|
|
569
697
|
// src/utils/extraction.ts
|
|
698
|
+
function nestedToolCallId(wrapperId, messageIndex, toolIndex, nestedId) {
|
|
699
|
+
return typeof nestedId === "string" ? nestedId : wrapperId ? wrapperId + "_" + toolIndex : ID_PREFIX.MULTI_TOOL_USE_SYNTHETIC + messageIndex + "_" + toolIndex;
|
|
700
|
+
}
|
|
701
|
+
function flattenToolCallBlock(b) {
|
|
702
|
+
if (!isToolCallBlock(b))
|
|
703
|
+
return [];
|
|
704
|
+
if (b.name === "multi_tool_use.parallel" && Array.isArray(b.arguments?.tool_uses)) {
|
|
705
|
+
return b.arguments.tool_uses.map((u) => {
|
|
706
|
+
const recipient = u?.recipient_name ?? "";
|
|
707
|
+
return {
|
|
708
|
+
name: recipient.replace(/^functions\./, ""),
|
|
709
|
+
id: u?.id ?? undefined,
|
|
710
|
+
arguments: u?.parameters ?? {}
|
|
711
|
+
};
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
return [{ name: b.name, id: b.id, arguments: b.arguments }];
|
|
715
|
+
}
|
|
570
716
|
function extractText(content) {
|
|
571
717
|
if (typeof content === "string")
|
|
572
718
|
return content;
|
|
@@ -580,6 +726,31 @@ function extractText(content) {
|
|
|
580
726
|
return "";
|
|
581
727
|
}).join("");
|
|
582
728
|
}
|
|
729
|
+
function buildToolCallIndex(msgs) {
|
|
730
|
+
const idx = new Map;
|
|
731
|
+
for (let i = 0;i < msgs.length; i++) {
|
|
732
|
+
const m = msgs[i];
|
|
733
|
+
if (m.role !== "assistant")
|
|
734
|
+
continue;
|
|
735
|
+
const blocks = Array.isArray(m.content) ? m.content : [];
|
|
736
|
+
for (const b of blocks) {
|
|
737
|
+
if (!isToolCallBlock(b))
|
|
738
|
+
continue;
|
|
739
|
+
if (b.id) {
|
|
740
|
+
idx.set(b.id, { name: b.name, arguments: b.arguments, msgIndex: i });
|
|
741
|
+
}
|
|
742
|
+
if (b.name === "multi_tool_use.parallel" && Array.isArray(b.arguments?.tool_uses)) {
|
|
743
|
+
const nested = flattenToolCallBlock(b);
|
|
744
|
+
for (let t = 0;t < nested.length; t++) {
|
|
745
|
+
const tool = nested[t];
|
|
746
|
+
const id = nestedToolCallId(b.id, i, t, tool.id);
|
|
747
|
+
idx.set(id, { name: tool.name, arguments: tool.arguments, msgIndex: i });
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
return idx;
|
|
753
|
+
}
|
|
583
754
|
var CONSTRAINT_PATTERNS = [
|
|
584
755
|
{ re: /\b(?:must|need|require|has to|important)\b.*\b(?:be|use|have|include|support)\b/i, cat: "requirement", conf: TUNING.CONFIDENCE_HIGH },
|
|
585
756
|
{ 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 +1044,41 @@ function mergeFindings(target, findings) {
|
|
|
873
1044
|
for (const finding of findings)
|
|
874
1045
|
target.set(finding.kind, (target.get(finding.kind) ?? 0) + finding.count);
|
|
875
1046
|
}
|
|
876
|
-
var SECRET_KEY_NAMES =
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
1047
|
+
var SECRET_KEY_NAMES = {
|
|
1048
|
+
api_key: true,
|
|
1049
|
+
apikey: true,
|
|
1050
|
+
access_token: true,
|
|
1051
|
+
auth_token: true,
|
|
1052
|
+
authorization: true,
|
|
1053
|
+
password: true,
|
|
1054
|
+
passwd: true,
|
|
1055
|
+
secret: true,
|
|
1056
|
+
secret_key: true,
|
|
1057
|
+
secret_access_key: true,
|
|
1058
|
+
client_secret: true,
|
|
1059
|
+
private_key: true,
|
|
1060
|
+
database_url: true,
|
|
1061
|
+
connection_string: true,
|
|
1062
|
+
token: true,
|
|
1063
|
+
refresh_token: true,
|
|
1064
|
+
session_token: true,
|
|
1065
|
+
credential: true,
|
|
1066
|
+
credentials: true,
|
|
1067
|
+
cookie: true,
|
|
1068
|
+
set_cookie: true,
|
|
1069
|
+
otp: true,
|
|
1070
|
+
one_time_password: true,
|
|
1071
|
+
pin: true,
|
|
1072
|
+
passcode: true
|
|
1073
|
+
};
|
|
892
1074
|
function normalizeObjectKey(key) {
|
|
893
1075
|
return key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
894
1076
|
}
|
|
895
1077
|
function isSecretBearingKey(key) {
|
|
896
1078
|
const normalized = normalizeObjectKey(key);
|
|
897
|
-
if (SECRET_KEY_NAMES
|
|
1079
|
+
if (SECRET_KEY_NAMES[normalized])
|
|
898
1080
|
return true;
|
|
899
|
-
return /(?:^|_)(?:api_key|access_token|auth_token|password|passwd|secret_access_key|client_secret|private_key)(?:_|$)/.test(normalized);
|
|
1081
|
+
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
1082
|
}
|
|
901
1083
|
|
|
902
1084
|
class SecretScrubber {
|
|
@@ -952,7 +1134,8 @@ class SecretScrubber {
|
|
|
952
1134
|
const output = {};
|
|
953
1135
|
seen.set(value2, output);
|
|
954
1136
|
for (const [key, item] of Object.entries(value2)) {
|
|
955
|
-
|
|
1137
|
+
const carriesSecret = typeof item === "string" ? item.length > 0 : item != null;
|
|
1138
|
+
if (this.secretsEnabled && isSecretBearingKey(key) && carriesSecret) {
|
|
956
1139
|
output[key] = "[REDACTED:credential]";
|
|
957
1140
|
recordCredential();
|
|
958
1141
|
} else {
|
|
@@ -1217,8 +1400,8 @@ function readMetricsLog(limit = 100) {
|
|
|
1217
1400
|
const fd = fs2.openSync(logPath, "r");
|
|
1218
1401
|
try {
|
|
1219
1402
|
const buf = Buffer.alloc(wantBytes);
|
|
1220
|
-
fs2.readSync(fd, buf, 0, wantBytes, startPos);
|
|
1221
|
-
let text = buf.toString("utf8");
|
|
1403
|
+
const bytesRead = fs2.readSync(fd, buf, 0, wantBytes, startPos);
|
|
1404
|
+
let text = buf.subarray(0, bytesRead).toString("utf8");
|
|
1222
1405
|
if (startPos > 0) {
|
|
1223
1406
|
const nl = text.indexOf(`
|
|
1224
1407
|
`);
|