micro-models-agent 0.28.3 → 0.28.5
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/main.js +38 -13
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2231,7 +2231,9 @@ var init_defaults = __esm(() => {
|
|
|
2231
2231
|
ui: {
|
|
2232
2232
|
spinner: true,
|
|
2233
2233
|
toolStyle: "inline",
|
|
2234
|
-
toolComments: true
|
|
2234
|
+
toolComments: true,
|
|
2235
|
+
showContextStats: false,
|
|
2236
|
+
showCompaction: true
|
|
2235
2237
|
},
|
|
2236
2238
|
mcpServers: {
|
|
2237
2239
|
context7: {
|
|
@@ -9703,6 +9705,7 @@ class Agent {
|
|
|
9703
9705
|
systemPromptAdded = false;
|
|
9704
9706
|
shutdownRequested = false;
|
|
9705
9707
|
abortController = null;
|
|
9708
|
+
lastCompactionShown = 0;
|
|
9706
9709
|
constructor(deps) {
|
|
9707
9710
|
this.deps = deps;
|
|
9708
9711
|
}
|
|
@@ -10087,19 +10090,30 @@ ${taskReminder}</system-summary>`
|
|
|
10087
10090
|
content: `<system-summary>${summaries.join(`
|
|
10088
10091
|
`)}</system-summary>`
|
|
10089
10092
|
});
|
|
10090
|
-
const
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10093
|
+
const ui = this.deps.config.ui;
|
|
10094
|
+
if (ui?.showContextStats) {
|
|
10095
|
+
const ctxTokens = contextManager.getEstimatedTokens();
|
|
10096
|
+
const ctxBudget = contextManager.getBudget();
|
|
10097
|
+
const ctxPct = Math.min(100, Math.round(ctxTokens / ctxBudget.history * 100));
|
|
10098
|
+
const barLen = 10;
|
|
10099
|
+
const filled = Math.round(ctxPct / 100 * barLen);
|
|
10100
|
+
const ctxBar = pc2.green("█".repeat(filled)) + pc2.dim("░".repeat(barLen - filled));
|
|
10101
|
+
const pctColor = ctxPct >= 75 ? pc2.yellow : pc2.dim;
|
|
10102
|
+
const compCount = contextManager.getCompactionCount();
|
|
10103
|
+
const quality2 = contextManager.getQuality();
|
|
10104
|
+
const qualityColor = quality2 >= 70 ? pc2.green : quality2 >= 40 ? pc2.yellow : pc2.red;
|
|
10105
|
+
onMeta?.(`
|
|
10101
10106
|
${ctxBar} ${pctColor(`${ctxPct}%`)} ${pc2.dim(`ctx: ${ctxTokens}/${ctxBudget.history}`)} ${pc2.dim(`compactions: ${compCount}`)} ${qualityColor(`quality: ${quality2}%`)}
|
|
10102
10107
|
`);
|
|
10108
|
+
} else if (ui?.showCompaction) {
|
|
10109
|
+
const compCount = contextManager.getCompactionCount();
|
|
10110
|
+
if (compCount > this.lastCompactionShown) {
|
|
10111
|
+
this.lastCompactionShown = compCount;
|
|
10112
|
+
onMeta?.(pc2.dim(`
|
|
10113
|
+
⟳ Context compacted (${compCount})
|
|
10114
|
+
`));
|
|
10115
|
+
}
|
|
10116
|
+
}
|
|
10103
10117
|
continue;
|
|
10104
10118
|
}
|
|
10105
10119
|
hallucinationDetector.getConfidenceCheck().setPreviousResponse(lastText);
|
|
@@ -27366,8 +27380,13 @@ ${t("image.clipboard_empty")}`));
|
|
|
27366
27380
|
console.log();
|
|
27367
27381
|
}
|
|
27368
27382
|
}
|
|
27383
|
+
lastCompactionShown = 0;
|
|
27369
27384
|
showContextBar(result) {
|
|
27370
|
-
if (result.contextUsed
|
|
27385
|
+
if (result.contextUsed === undefined || result.contextLimit === undefined || result.contextLimit <= 0) {
|
|
27386
|
+
return;
|
|
27387
|
+
}
|
|
27388
|
+
const ui = this.config.ui;
|
|
27389
|
+
if (ui?.showContextStats) {
|
|
27371
27390
|
console.log();
|
|
27372
27391
|
const ctxLine = formatContextBar(result.contextUsed, result.contextLimit, result.compactionCount, result.contextQuality);
|
|
27373
27392
|
console.log(ctxLine);
|
|
@@ -27375,6 +27394,12 @@ ${t("image.clipboard_empty")}`));
|
|
|
27375
27394
|
const apiLine = pc2.dim(` API: ${result.promptTokens} prompt + ${result.completionTokens} completion = ${result.totalTokens} total`);
|
|
27376
27395
|
console.log(apiLine);
|
|
27377
27396
|
}
|
|
27397
|
+
} else if (ui?.showCompaction && result.compactionCount !== undefined) {
|
|
27398
|
+
if (result.compactionCount > this.lastCompactionShown) {
|
|
27399
|
+
this.lastCompactionShown = result.compactionCount;
|
|
27400
|
+
console.log(pc2.dim(`
|
|
27401
|
+
⟳ Context compacted (${result.compactionCount})`));
|
|
27402
|
+
}
|
|
27378
27403
|
}
|
|
27379
27404
|
}
|
|
27380
27405
|
start() {
|