terminal-smart-cli 0.97.9 → 0.97.10
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/lib/agent.js +5 -0
- package/lib/mission-tool-cache.js +3 -1
- package/package.json +1 -1
package/lib/agent.js
CHANGED
|
@@ -979,6 +979,7 @@ async function run(task, opts = {}) {
|
|
|
979
979
|
if (_cached) {
|
|
980
980
|
const _visible = messages.some(m => m && m.role === 'tool' && m.tool_call_id === _cached.toolCallId);
|
|
981
981
|
_cachedContent = cacheReference(_cached, name, _visible);
|
|
982
|
+
if (_visible) _missionCache.recordSavings(Math.max(0, String(_cached.content || '').length - _cachedContent.length));
|
|
982
983
|
result = { cached: true, tool: name };
|
|
983
984
|
onStep({ name, detail: 'cache da missão: ' + argsShort(name, input) });
|
|
984
985
|
}
|
|
@@ -1142,6 +1143,10 @@ async function run(task, opts = {}) {
|
|
|
1142
1143
|
const _syncTasks = [
|
|
1143
1144
|
_memoryBus.recordContext(token, _snapshot),
|
|
1144
1145
|
_memoryBus.saveHandoff(token, _handoff),
|
|
1146
|
+
api('/api/telemetry/mission-cache', {
|
|
1147
|
+
method: 'POST', token, timeoutMs: 3000, retry: false,
|
|
1148
|
+
body: Object.assign({ surface: 'cli', model: usedModel }, _missionCache.stats()),
|
|
1149
|
+
}),
|
|
1145
1150
|
];
|
|
1146
1151
|
if (usedModel && usedModel !== 'smart') _syncTasks.push(api('/api/intelligence/observe', {
|
|
1147
1152
|
method: 'POST',
|
|
@@ -20,6 +20,7 @@ class MissionToolCache {
|
|
|
20
20
|
this.entries = new Map();
|
|
21
21
|
this.hits = 0;
|
|
22
22
|
this.invalidations = 0;
|
|
23
|
+
this.charactersSaved = 0;
|
|
23
24
|
}
|
|
24
25
|
get(tool, input) {
|
|
25
26
|
const key = signature(tool, input);
|
|
@@ -39,7 +40,8 @@ class MissionToolCache {
|
|
|
39
40
|
if (this.entries.size) this.invalidations++;
|
|
40
41
|
this.entries.clear();
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
recordSavings(characters) { this.charactersSaved += Math.max(0, Number(characters) || 0); }
|
|
44
|
+
stats() { return { entries: this.entries.size, hits: this.hits, invalidations: this.invalidations, charactersSaved: this.charactersSaved, estimatedTokensSaved: Math.ceil(this.charactersSaved / 4) }; }
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
function cacheReference(entry, tool, originalStillVisible) {
|