Add tool telemetry tracking for LLM calls and vault searches

Introduces TelemetryManager to record tool calls, LLM token usage
(prompt_eval_count, eval_count), and vault search queries with timing.
Wires telemetry through ChatView, ToolExecutor, and OllamaClient with
configurable limits and enable/disable toggle.
This commit is contained in:
2026-05-20 22:32:15 +02:00
parent fbb744ba6b
commit f98afcd6b0
9 changed files with 698 additions and 44 deletions
+22 -22
View File
@@ -76,6 +76,10 @@ const mockSettings: PluginSettings = {
maxPreferences: 20,
maxFacts: 50,
},
toolTelemetryConfig: {
enabled: true,
maxEntries: 100,
},
};
describe('ChatView', () => {
@@ -360,17 +364,15 @@ describe('ChatView', () => {
view['inputEl'] = document.createElement('textarea');
(view['inputEl'] as HTMLTextAreaElement).value = 'search query';
const searchSpy = jest
.spyOn(view['noteContextBuilder'], 'buildContext')
.mockResolvedValue({
explicitMentions: [],
openNote: undefined,
selectedText: undefined,
backlinks: [],
outlinks: [],
relatedNotes: [],
searchResults: [],
});
const searchSpy = jest.spyOn(view['noteContextBuilder'], 'buildContext').mockResolvedValue({
explicitMentions: [],
openNote: undefined,
selectedText: undefined,
backlinks: [],
outlinks: [],
relatedNotes: [],
searchResults: [],
});
const chatSpy = jest.spyOn(view['ollamaClient'], 'streamChat').mockReturnValue(
(async function* () {
yield { role: 'assistant', content: 'response' };
@@ -815,17 +817,15 @@ describe('ChatView', () => {
view['inputEl'] = document.createElement('textarea');
(view['inputEl'] as HTMLTextAreaElement).value = 'search query';
const searchSpy = jest
.spyOn(view['noteContextBuilder'], 'buildContext')
.mockResolvedValue({
explicitMentions: [],
openNote: undefined,
selectedText: undefined,
backlinks: [],
outlinks: [],
relatedNotes: [],
searchResults: [],
});
const searchSpy = jest.spyOn(view['noteContextBuilder'], 'buildContext').mockResolvedValue({
explicitMentions: [],
openNote: undefined,
selectedText: undefined,
backlinks: [],
outlinks: [],
relatedNotes: [],
searchResults: [],
});
const chatSpy = jest.spyOn(view['ollamaClient'], 'streamChat').mockReturnValue(
(async function* () {
yield { role: 'assistant', content: 'response' };