@tekmidian/pai 0.44.0 → 0.45.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/dist/cli/index.mjs +2 -2
- package/dist/cli/program.mjs +2 -2
- package/dist/daemon/index.mjs +3 -3
- package/dist/{daemon-ebLDoKM3.mjs → daemon-DNBEFHaj.mjs} +5 -5
- package/dist/{daemon-ebLDoKM3.mjs.map → daemon-DNBEFHaj.mjs.map} +1 -1
- package/dist/{daemon-BVbvL8IA.mjs → daemon-Dq2ZSdex.mjs} +3 -3
- package/dist/hooks/context-compression-hook.mjs.map +2 -2
- package/dist/hooks/load-project-context.mjs +28 -12
- package/dist/hooks/load-project-context.mjs.map +2 -2
- package/dist/hooks/post-compact-inject.mjs.map +2 -2
- package/dist/{program-cr5U1-DK.mjs → program-DvuMelhj.mjs} +36 -4
- package/dist/program-DvuMelhj.mjs.map +1 -0
- package/dist/{tools-DiRC5glA.mjs → tools-B77WHeVZ.mjs} +2 -2
- package/dist/{tools-DiRC5glA.mjs.map → tools-B77WHeVZ.mjs.map} +1 -1
- package/dist/{tools-CAG2sUjf.mjs → tools-NnR_n-Ja.mjs} +2 -2
- package/dist/{wakeup-BfElduEU.mjs → wakeup-UrhiW-KU.mjs} +27 -14
- package/dist/wakeup-UrhiW-KU.mjs.map +1 -0
- package/package.json +1 -1
- package/src/hooks/ts/lib/context-fill.ts +12 -6
- package/src/hooks/ts/session-start/load-project-context.ts +5 -1
- package/dist/program-cr5U1-DK.mjs.map +0 -1
- package/dist/wakeup-BfElduEU.mjs.map +0 -1
|
@@ -15,7 +15,7 @@ import { A as DEFAULT_CONTEXT_WINDOW, C as inlineWorkersYamlKeys, D as relocateW
|
|
|
15
15
|
import { A as loadStatus, B as describeMcp, F as setWorkerLabel, I as waitForTerminalStatus, L as longInlinePromptHint, P as saveStatus, R as parseRunnerArgs, S as appendLedger, V as expandMcpNames, a as projectLaunchConfig, c as discardWorker, f as sayToWorker, g as openPaneForWorker, h as openFollowPane, i as usageContextTokens, j as loadStatuses, k as isChatPane, l as mergeWorker, m as checkPaneForWorker, n as runWorker, o as parseWorkerReport, r as testProvider, u as handoffFromInside, w as UNLABELED } from "./run-BgExF8Xg.mjs";
|
|
16
16
|
import { t as PaiClient } from "./ipc-client-C6NryMMb.mjs";
|
|
17
17
|
import { r as humanDuration, t as createStorageBackend } from "./factory-DNYAqjH0.mjs";
|
|
18
|
-
import { n as migrateIdentityFile } from "./wakeup-
|
|
18
|
+
import { n as migrateIdentityFile } from "./wakeup-UrhiW-KU.mjs";
|
|
19
19
|
import { a as renderDedupedSessions, c as probeResume, d as fmtAge, f as migrateSessionScanCache, h as scanSessions, i as normalizeName$2, l as restoreTopLevel, m as scanCacheFilePath, o as hasConversation, p as resolveSessionByNameOrId, r as buildDeduped, s as launchInDir, t as cmdMain, u as printExitDir } from "./main-resolver-DvYu9jbl.mjs";
|
|
20
20
|
import { n as queriesDirPath, t as migrateQueriesDir } from "./query-feedback-CYyOGi3y.mjs";
|
|
21
21
|
import { s as kgQuery } from "./kg-entity-BSjM5xZh.mjs";
|
|
@@ -5906,7 +5906,7 @@ function cmdLogs(opts) {
|
|
|
5906
5906
|
}
|
|
5907
5907
|
function registerDaemonCommands(daemonCmd) {
|
|
5908
5908
|
daemonCmd.command("serve").description("Start the PAI daemon in the foreground").action(async () => {
|
|
5909
|
-
const { serve } = await import("./daemon-
|
|
5909
|
+
const { serve } = await import("./daemon-Dq2ZSdex.mjs");
|
|
5910
5910
|
const { loadConfig: lc, ensureConfigDir } = await import("./config-DeqFqa1N.mjs");
|
|
5911
5911
|
ensureConfigDir();
|
|
5912
5912
|
await serve(lc());
|
|
@@ -9966,6 +9966,23 @@ function emptyTotals() {
|
|
|
9966
9966
|
};
|
|
9967
9967
|
}
|
|
9968
9968
|
/**
|
|
9969
|
+
* `type:"system"` `subtype:"compact_boundary"` lines mark a compaction.
|
|
9970
|
+
* turnIndex is the count of assistant turns already folded when it fired,
|
|
9971
|
+
* so it lines up with the turn numbering the text/JSON report prints.
|
|
9972
|
+
*/
|
|
9973
|
+
function isCompactBoundary(line) {
|
|
9974
|
+
return line.type === "system" && line.subtype === "compact_boundary";
|
|
9975
|
+
}
|
|
9976
|
+
function parseCompactionEvent(line, turnIndex) {
|
|
9977
|
+
const meta = line.compactMetadata;
|
|
9978
|
+
if (!meta || typeof meta.preTokens !== "number") return null;
|
|
9979
|
+
return {
|
|
9980
|
+
trigger: meta.trigger ?? "unknown",
|
|
9981
|
+
preTokens: meta.preTokens,
|
|
9982
|
+
turnIndex
|
|
9983
|
+
};
|
|
9984
|
+
}
|
|
9985
|
+
/**
|
|
9969
9986
|
* Fold one already-parsed JSONL line into a report being accumulated.
|
|
9970
9987
|
* Exported separately so both the streaming file reader below and tests
|
|
9971
9988
|
* (which build fixtures as arrays of objects, not files) share one path.
|
|
@@ -10033,7 +10050,8 @@ async function parseSessionUsage(path, threshold = 2e5) {
|
|
|
10033
10050
|
maxContext: null,
|
|
10034
10051
|
turnsAboveThreshold: 0,
|
|
10035
10052
|
cacheRebuildTurns: 0,
|
|
10036
|
-
userPrompts: 0
|
|
10053
|
+
userPrompts: 0,
|
|
10054
|
+
compactions: []
|
|
10037
10055
|
};
|
|
10038
10056
|
const seenIds = /* @__PURE__ */ new Set();
|
|
10039
10057
|
let contextSum = 0;
|
|
@@ -10053,6 +10071,11 @@ async function parseSessionUsage(path, threshold = 2e5) {
|
|
|
10053
10071
|
if (isRealUserPrompt(obj)) report.userPrompts++;
|
|
10054
10072
|
continue;
|
|
10055
10073
|
}
|
|
10074
|
+
if (isCompactBoundary(obj)) {
|
|
10075
|
+
const event = parseCompactionEvent(obj, report.turns);
|
|
10076
|
+
if (event) report.compactions.push(event);
|
|
10077
|
+
continue;
|
|
10078
|
+
}
|
|
10056
10079
|
const context = foldAssistantLine(report, seenIds, obj, threshold);
|
|
10057
10080
|
if (context !== null) contextSum += context;
|
|
10058
10081
|
}
|
|
@@ -11010,6 +11033,13 @@ function buildFindings(input) {
|
|
|
11010
11033
|
severity,
|
|
11011
11034
|
evidence: `avg ${avg}, max ${max}, ${input.session.turnsAboveThreshold} turns > ${input.ctxThreshold}, ${input.session.turns} turns`
|
|
11012
11035
|
});
|
|
11036
|
+
const compactions = input.session.compactions;
|
|
11037
|
+
const overshoots = compactions.filter((c) => c.trigger === "auto").filter((c) => c.preTokens > 1.25 * input.ctxThreshold);
|
|
11038
|
+
findings.push({
|
|
11039
|
+
finding: "compaction trigger",
|
|
11040
|
+
severity: overshoots.length > 0 ? "RED" : "GREEN",
|
|
11041
|
+
evidence: overshoots.length > 0 ? `override not honoured: ${overshoots.map((c) => `preTokens=${c.preTokens}`).join(", ")} vs configured ${input.ctxThreshold}` : compactions.length === 0 ? `0 compactions in ${input.session.turns} turns` : `${compactions.length} compaction(s), all within 25% of configured ${input.ctxThreshold}`
|
|
11042
|
+
});
|
|
11013
11043
|
}
|
|
11014
11044
|
return sortFindings(findings);
|
|
11015
11045
|
}
|
|
@@ -11557,6 +11587,8 @@ function printSession(report) {
|
|
|
11557
11587
|
console.log(`cache_creation split: ephemeral_5m=${report.cacheCreationSplit.ephemeral5m}, ephemeral_1h=${report.cacheCreationSplit.ephemeral1h}`);
|
|
11558
11588
|
console.log(dim$1(`models: ${JSON.stringify(report.models)}`));
|
|
11559
11589
|
console.log(`avg context: ${report.avgContext ?? "n/a"}, max context: ${report.maxContext ?? "n/a"}, turns above threshold: ${report.turnsAboveThreshold}, cache-rebuild turns: ${report.cacheRebuildTurns}, user prompts: ${report.userPrompts}`);
|
|
11590
|
+
console.log(`compactions: ${report.compactions.length}`);
|
|
11591
|
+
for (const c of report.compactions) console.log(dim$1(` ${c.trigger} at turn ${c.turnIndex}: preTokens=${c.preTokens}`));
|
|
11560
11592
|
}
|
|
11561
11593
|
async function cmdSession(path, opts) {
|
|
11562
11594
|
const report = await auditSession(path, opts.ctxThreshold ? parseInt(opts.ctxThreshold, 10) : void 0);
|
|
@@ -19912,4 +19944,4 @@ claude() {
|
|
|
19912
19944
|
|
|
19913
19945
|
//#endregion
|
|
19914
19946
|
export { drainStdio as n, buildProgram as t };
|
|
19915
|
-
//# sourceMappingURL=program-
|
|
19947
|
+
//# sourceMappingURL=program-DvuMelhj.mjs.map
|