@alisio/plugin-telemetry 0.1.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/.agents/skills/telemetry/SKILL.md +52 -0
- package/LICENSE +21 -0
- package/README.md +188 -0
- package/cover.svg +54 -0
- package/dist/commands.d.ts +19 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +298 -0
- package/dist/commands.js.map +1 -0
- package/dist/config.d.ts +145 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +524 -0
- package/dist/config.js.map +1 -0
- package/dist/database.d.ts +16 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +67 -0
- package/dist/database.js.map +1 -0
- package/dist/events.d.ts +135 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +255 -0
- package/dist/events.js.map +1 -0
- package/dist/format.d.ts +36 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +49 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/otlp.d.ts +69 -0
- package/dist/otlp.d.ts.map +1 -0
- package/dist/otlp.js +616 -0
- package/dist/otlp.js.map +1 -0
- package/dist/redact.d.ts +36 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/redact.js +163 -0
- package/dist/redact.js.map +1 -0
- package/dist/runtime.d.ts +80 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +290 -0
- package/dist/runtime.js.map +1 -0
- package/dist/store.d.ts +188 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +539 -0
- package/dist/store.js.map +1 -0
- package/dist/tools.d.ts +21 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +292 -0
- package/dist/tools.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +54 -0
package/dist/store.js
ADDED
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The local SQLite store: the primary sink and the source of truth.
|
|
3
|
+
*
|
|
4
|
+
* REMOTE EXPORT NEVER OWNS THE DATA. Every record lands here first; OTLP batches
|
|
5
|
+
* are derived from these rows and tracked in `otlp_batches` so a failed export
|
|
6
|
+
* can be retried idempotently. Remote failures never delete or mutate rows.
|
|
7
|
+
*
|
|
8
|
+
* FULL-TEXT SEARCH IS CONTENT-ONLY AND OPT-IN. The `content_fts` shadow tables
|
|
9
|
+
* can retain fragments after rows are deleted. Deletion therefore also clears
|
|
10
|
+
* the FTS index, runs `optimize`, and vacuums; the README states plainly that
|
|
11
|
+
* forensic traces in a copied file cannot be guaranteed gone.
|
|
12
|
+
*/
|
|
13
|
+
const SCHEMA = `
|
|
14
|
+
CREATE TABLE IF NOT EXISTS meta (
|
|
15
|
+
key TEXT PRIMARY KEY,
|
|
16
|
+
value TEXT NOT NULL
|
|
17
|
+
);
|
|
18
|
+
CREATE TABLE IF NOT EXISTS runs (
|
|
19
|
+
run_id TEXT PRIMARY KEY,
|
|
20
|
+
session_id TEXT NOT NULL,
|
|
21
|
+
started_at TEXT NOT NULL,
|
|
22
|
+
ended_at TEXT,
|
|
23
|
+
model TEXT,
|
|
24
|
+
input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
25
|
+
output_tokens INTEGER NOT NULL DEFAULT 0,
|
|
26
|
+
cached_input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
27
|
+
total_tokens INTEGER,
|
|
28
|
+
turns INTEGER NOT NULL DEFAULT 0,
|
|
29
|
+
tool_calls INTEGER NOT NULL DEFAULT 0,
|
|
30
|
+
tool_errors INTEGER NOT NULL DEFAULT 0,
|
|
31
|
+
status TEXT NOT NULL DEFAULT 'running',
|
|
32
|
+
truncated INTEGER NOT NULL DEFAULT 0
|
|
33
|
+
);
|
|
34
|
+
CREATE INDEX IF NOT EXISTS runs_session ON runs(session_id);
|
|
35
|
+
CREATE INDEX IF NOT EXISTS runs_started ON runs(started_at);
|
|
36
|
+
CREATE TABLE IF NOT EXISTS turns (
|
|
37
|
+
run_id TEXT NOT NULL,
|
|
38
|
+
turn INTEGER NOT NULL,
|
|
39
|
+
session_id TEXT NOT NULL,
|
|
40
|
+
model TEXT,
|
|
41
|
+
input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
42
|
+
output_tokens INTEGER NOT NULL DEFAULT 0,
|
|
43
|
+
cached_input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
44
|
+
calls INTEGER NOT NULL DEFAULT 0,
|
|
45
|
+
duration_ms INTEGER,
|
|
46
|
+
created_at TEXT NOT NULL,
|
|
47
|
+
PRIMARY KEY (run_id, turn)
|
|
48
|
+
);
|
|
49
|
+
CREATE INDEX IF NOT EXISTS turns_created ON turns(created_at);
|
|
50
|
+
CREATE INDEX IF NOT EXISTS turns_model ON turns(model);
|
|
51
|
+
CREATE TABLE IF NOT EXISTS tool_calls (
|
|
52
|
+
run_id TEXT NOT NULL,
|
|
53
|
+
call_id TEXT NOT NULL,
|
|
54
|
+
session_id TEXT NOT NULL,
|
|
55
|
+
name TEXT NOT NULL,
|
|
56
|
+
effect TEXT,
|
|
57
|
+
started_at TEXT,
|
|
58
|
+
finished_at TEXT,
|
|
59
|
+
duration_ms INTEGER,
|
|
60
|
+
is_error INTEGER NOT NULL DEFAULT 0,
|
|
61
|
+
args_bytes INTEGER,
|
|
62
|
+
result_bytes INTEGER,
|
|
63
|
+
PRIMARY KEY (run_id, call_id)
|
|
64
|
+
);
|
|
65
|
+
CREATE INDEX IF NOT EXISTS tool_calls_name ON tool_calls(name);
|
|
66
|
+
CREATE INDEX IF NOT EXISTS tool_calls_started ON tool_calls(started_at);
|
|
67
|
+
CREATE TABLE IF NOT EXISTS content (
|
|
68
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
69
|
+
run_id TEXT,
|
|
70
|
+
session_id TEXT,
|
|
71
|
+
kind TEXT NOT NULL,
|
|
72
|
+
ref TEXT,
|
|
73
|
+
text TEXT NOT NULL,
|
|
74
|
+
created_at TEXT NOT NULL
|
|
75
|
+
);
|
|
76
|
+
CREATE INDEX IF NOT EXISTS content_created ON content(created_at);
|
|
77
|
+
CREATE TABLE IF NOT EXISTS otlp_batches (
|
|
78
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
79
|
+
batch_key TEXT NOT NULL UNIQUE,
|
|
80
|
+
signal TEXT NOT NULL,
|
|
81
|
+
payload TEXT NOT NULL,
|
|
82
|
+
created_at TEXT NOT NULL,
|
|
83
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
84
|
+
last_attempt_at TEXT,
|
|
85
|
+
status TEXT NOT NULL DEFAULT 'pending',
|
|
86
|
+
last_error TEXT
|
|
87
|
+
);
|
|
88
|
+
CREATE INDEX IF NOT EXISTS otlp_batches_status ON otlp_batches(status);
|
|
89
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS content_fts USING fts5(
|
|
90
|
+
text,
|
|
91
|
+
kind UNINDEXED,
|
|
92
|
+
ref UNINDEXED,
|
|
93
|
+
tokenize = 'unicode61'
|
|
94
|
+
);
|
|
95
|
+
`;
|
|
96
|
+
function number(value) {
|
|
97
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
98
|
+
return value;
|
|
99
|
+
if (typeof value === "bigint")
|
|
100
|
+
return Number(value);
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
function maybeNumber(value) {
|
|
104
|
+
if (value === null || value === undefined)
|
|
105
|
+
return null;
|
|
106
|
+
const numeric = number(value);
|
|
107
|
+
return Number.isFinite(numeric) ? numeric : null;
|
|
108
|
+
}
|
|
109
|
+
function stringOrNull(value) {
|
|
110
|
+
return typeof value === "string" ? value : null;
|
|
111
|
+
}
|
|
112
|
+
function stringOf(value, fallback = "") {
|
|
113
|
+
return typeof value === "string" ? value : fallback;
|
|
114
|
+
}
|
|
115
|
+
export function createStore(database) {
|
|
116
|
+
const { prepare } = database;
|
|
117
|
+
const recordRunAggregates = (runId) => {
|
|
118
|
+
prepare(`UPDATE runs SET
|
|
119
|
+
turns = (SELECT COUNT(*) FROM turns WHERE run_id = ?),
|
|
120
|
+
tool_calls = (SELECT COUNT(*) FROM tool_calls WHERE run_id = ?),
|
|
121
|
+
tool_errors = (SELECT COUNT(*) FROM tool_calls WHERE run_id = ? AND is_error = 1),
|
|
122
|
+
input_tokens = (SELECT COALESCE(SUM(input_tokens), 0) FROM turns WHERE run_id = ?),
|
|
123
|
+
output_tokens = (SELECT COALESCE(SUM(output_tokens), 0) FROM turns WHERE run_id = ?),
|
|
124
|
+
cached_input_tokens = (SELECT COALESCE(SUM(cached_input_tokens), 0) FROM turns WHERE run_id = ?)
|
|
125
|
+
WHERE run_id = ?`).run(runId, runId, runId, runId, runId, runId, runId);
|
|
126
|
+
};
|
|
127
|
+
const insertContent = (runId, sessionId, kind, ref, text, createdAt) => {
|
|
128
|
+
const result = prepare("INSERT INTO content (run_id, session_id, kind, ref, text, created_at) VALUES (?, ?, ?, ?, ?, ?)").run(runId, sessionId, kind, ref, text, createdAt);
|
|
129
|
+
const rowId = result.lastInsertRowid;
|
|
130
|
+
prepare("INSERT INTO content_fts (rowid, text, kind, ref) VALUES (?, ?, ?, ?)").run(typeof rowId === "bigint" ? rowId : number(rowId), text, kind, ref);
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
migrate() {
|
|
134
|
+
database.exec(SCHEMA);
|
|
135
|
+
prepare("INSERT OR IGNORE INTO meta (key, value) VALUES ('schema_version', '1')").run();
|
|
136
|
+
},
|
|
137
|
+
writeRecords(records) {
|
|
138
|
+
let contentWrites = 0;
|
|
139
|
+
database.transaction(() => {
|
|
140
|
+
for (const record of records) {
|
|
141
|
+
switch (record.kind) {
|
|
142
|
+
case "run_start": {
|
|
143
|
+
prepare(`INSERT INTO runs (run_id, session_id, started_at, model, status)
|
|
144
|
+
VALUES (?, ?, ?, ?, 'running')
|
|
145
|
+
ON CONFLICT(run_id) DO UPDATE SET
|
|
146
|
+
session_id = excluded.session_id,
|
|
147
|
+
model = COALESCE(excluded.model, runs.model)`).run(record.runId, record.sessionId, record.timestamp, record.model ?? null);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
case "run_end": {
|
|
151
|
+
prepare(`INSERT INTO runs (run_id, session_id, started_at, ended_at, status, total_tokens, truncated)
|
|
152
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
153
|
+
ON CONFLICT(run_id) DO UPDATE SET
|
|
154
|
+
ended_at = excluded.ended_at,
|
|
155
|
+
status = excluded.status,
|
|
156
|
+
total_tokens = COALESCE(excluded.total_tokens, runs.total_tokens),
|
|
157
|
+
truncated = excluded.truncated`).run(record.runId, record.sessionId, record.timestamp, record.timestamp, record.status, record.totalTokens ?? null, record.truncated ? 1 : 0);
|
|
158
|
+
if (record.text !== null) {
|
|
159
|
+
insertContent(record.runId, record.sessionId, "completion", record.runId, record.text, record.timestamp);
|
|
160
|
+
contentWrites += 1;
|
|
161
|
+
}
|
|
162
|
+
recordRunAggregates(record.runId);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
case "turn": {
|
|
166
|
+
prepare(`INSERT INTO turns (run_id, turn, session_id, model, input_tokens, output_tokens, cached_input_tokens, calls, duration_ms, created_at)
|
|
167
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
168
|
+
ON CONFLICT(run_id, turn) DO UPDATE SET
|
|
169
|
+
session_id = excluded.session_id,
|
|
170
|
+
model = COALESCE(excluded.model, turns.model),
|
|
171
|
+
input_tokens = excluded.input_tokens,
|
|
172
|
+
output_tokens = excluded.output_tokens,
|
|
173
|
+
cached_input_tokens = excluded.cached_input_tokens,
|
|
174
|
+
calls = excluded.calls,
|
|
175
|
+
duration_ms = COALESCE(excluded.duration_ms, turns.duration_ms)`).run(record.runId, record.turn, record.sessionId, record.model ?? null, record.inputTokens, record.outputTokens, record.cachedInputTokens, record.calls, record.durationMs ?? null, record.timestamp);
|
|
176
|
+
prepare(`INSERT INTO runs (run_id, session_id, started_at, model, status)
|
|
177
|
+
VALUES (?, ?, ?, ?, 'running')
|
|
178
|
+
ON CONFLICT(run_id) DO UPDATE SET model = COALESCE(excluded.model, runs.model)`).run(record.runId, record.sessionId, record.timestamp, record.model ?? null);
|
|
179
|
+
recordRunAggregates(record.runId);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "tool_start": {
|
|
183
|
+
prepare(`INSERT INTO tool_calls (run_id, call_id, session_id, name, effect, started_at, args_bytes)
|
|
184
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
185
|
+
ON CONFLICT(run_id, call_id) DO UPDATE SET
|
|
186
|
+
name = excluded.name,
|
|
187
|
+
effect = COALESCE(excluded.effect, tool_calls.effect),
|
|
188
|
+
started_at = COALESCE(tool_calls.started_at, excluded.started_at),
|
|
189
|
+
args_bytes = COALESCE(excluded.args_bytes, tool_calls.args_bytes)`).run(record.runId, record.callId, record.sessionId, record.name, record.effect ?? null, record.timestamp, record.argsBytes);
|
|
190
|
+
if (record.args !== null) {
|
|
191
|
+
insertContent(record.runId, record.sessionId, "tool_arguments", record.callId, record.args, record.timestamp);
|
|
192
|
+
contentWrites += 1;
|
|
193
|
+
}
|
|
194
|
+
recordRunAggregates(record.runId);
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
case "tool_end": {
|
|
198
|
+
prepare(`INSERT INTO tool_calls (run_id, call_id, session_id, name, finished_at, duration_ms, is_error, result_bytes)
|
|
199
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
200
|
+
ON CONFLICT(run_id, call_id) DO UPDATE SET
|
|
201
|
+
name = COALESCE(excluded.name, tool_calls.name),
|
|
202
|
+
finished_at = excluded.finished_at,
|
|
203
|
+
duration_ms = COALESCE(excluded.duration_ms, tool_calls.duration_ms),
|
|
204
|
+
is_error = excluded.is_error,
|
|
205
|
+
result_bytes = COALESCE(excluded.result_bytes, tool_calls.result_bytes)`).run(record.runId, record.callId, record.sessionId, record.name ?? null, record.timestamp, record.durationMs ?? null, record.isError ? 1 : 0, record.resultBytes);
|
|
206
|
+
if (record.preview !== null) {
|
|
207
|
+
insertContent(record.runId, record.sessionId, "tool_result", record.callId, record.preview, record.timestamp);
|
|
208
|
+
contentWrites += 1;
|
|
209
|
+
}
|
|
210
|
+
recordRunAggregates(record.runId);
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
return { written: records.length, content: contentWrites };
|
|
217
|
+
},
|
|
218
|
+
summary(range) {
|
|
219
|
+
const runs = prepare(`SELECT COUNT(*) AS runs,
|
|
220
|
+
COALESCE(SUM(turns), 0) AS turns,
|
|
221
|
+
COALESCE(SUM(tool_calls), 0) AS toolCalls,
|
|
222
|
+
COALESCE(SUM(tool_errors), 0) AS toolErrors,
|
|
223
|
+
COALESCE(SUM(input_tokens), 0) AS inputTokens,
|
|
224
|
+
COALESCE(SUM(output_tokens), 0) AS outputTokens,
|
|
225
|
+
COALESCE(SUM(cached_input_tokens), 0) AS cachedInputTokens,
|
|
226
|
+
COALESCE(SUM(total_tokens), 0) AS totalTokens,
|
|
227
|
+
MIN(started_at) AS firstAt,
|
|
228
|
+
MAX(COALESCE(ended_at, started_at)) AS lastAt
|
|
229
|
+
FROM runs WHERE started_at >= ? AND started_at <= ?`).get(range.from, range.to);
|
|
230
|
+
const sessions = prepare("SELECT COUNT(DISTINCT session_id) AS sessions FROM runs WHERE started_at >= ? AND started_at <= ?").get(range.from, range.to);
|
|
231
|
+
const durations = prepare(`SELECT AVG(duration_ms) AS avg, MAX(duration_ms) AS max
|
|
232
|
+
FROM tool_calls
|
|
233
|
+
WHERE COALESCE(started_at, finished_at) >= ? AND COALESCE(started_at, finished_at) <= ?`).get(range.from, range.to);
|
|
234
|
+
return {
|
|
235
|
+
sessions: number(sessions?.sessions),
|
|
236
|
+
runs: number(runs?.runs),
|
|
237
|
+
turns: number(runs?.turns),
|
|
238
|
+
toolCalls: number(runs?.toolCalls),
|
|
239
|
+
toolErrors: number(runs?.toolErrors),
|
|
240
|
+
inputTokens: number(runs?.inputTokens),
|
|
241
|
+
outputTokens: number(runs?.outputTokens),
|
|
242
|
+
cachedInputTokens: number(runs?.cachedInputTokens),
|
|
243
|
+
totalTokens: number(runs?.totalTokens),
|
|
244
|
+
avgToolDurationMs: maybeNumber(durations?.avg),
|
|
245
|
+
maxToolDurationMs: maybeNumber(durations?.max),
|
|
246
|
+
firstAt: stringOrNull(runs?.firstAt),
|
|
247
|
+
lastAt: stringOrNull(runs?.lastAt),
|
|
248
|
+
};
|
|
249
|
+
},
|
|
250
|
+
models(range, limit) {
|
|
251
|
+
const rows = prepare(`SELECT COALESCE(model, '(unknown)') AS model,
|
|
252
|
+
COUNT(*) AS turns,
|
|
253
|
+
COALESCE(SUM(input_tokens), 0) AS inputTokens,
|
|
254
|
+
COALESCE(SUM(output_tokens), 0) AS outputTokens,
|
|
255
|
+
COALESCE(SUM(cached_input_tokens), 0) AS cachedInputTokens,
|
|
256
|
+
COALESCE(SUM(calls), 0) AS calls,
|
|
257
|
+
AVG(duration_ms) AS avgTurnDurationMs
|
|
258
|
+
FROM turns WHERE created_at >= ? AND created_at <= ?
|
|
259
|
+
GROUP BY COALESCE(model, '(unknown)')
|
|
260
|
+
ORDER BY (COALESCE(SUM(input_tokens), 0) + COALESCE(SUM(output_tokens), 0)) DESC, model ASC
|
|
261
|
+
LIMIT ?`).all(range.from, range.to, Math.max(1, Math.trunc(limit)));
|
|
262
|
+
return rows.map((row) => ({
|
|
263
|
+
model: stringOf(row.model, "(unknown)"),
|
|
264
|
+
turns: number(row.turns),
|
|
265
|
+
inputTokens: number(row.inputTokens),
|
|
266
|
+
outputTokens: number(row.outputTokens),
|
|
267
|
+
cachedInputTokens: number(row.cachedInputTokens),
|
|
268
|
+
calls: number(row.calls),
|
|
269
|
+
avgTurnDurationMs: maybeNumber(row.avgTurnDurationMs),
|
|
270
|
+
}));
|
|
271
|
+
},
|
|
272
|
+
tools(range, limit) {
|
|
273
|
+
const rows = prepare(`SELECT name,
|
|
274
|
+
COUNT(*) AS calls,
|
|
275
|
+
COALESCE(SUM(is_error), 0) AS errors,
|
|
276
|
+
AVG(duration_ms) AS avgDurationMs,
|
|
277
|
+
MAX(duration_ms) AS maxDurationMs,
|
|
278
|
+
GROUP_CONCAT(DISTINCT effect) AS effects
|
|
279
|
+
FROM tool_calls
|
|
280
|
+
WHERE COALESCE(started_at, finished_at) >= ? AND COALESCE(started_at, finished_at) <= ?
|
|
281
|
+
GROUP BY name
|
|
282
|
+
ORDER BY calls DESC, name ASC
|
|
283
|
+
LIMIT ?`).all(range.from, range.to, Math.max(1, Math.trunc(limit)));
|
|
284
|
+
return rows.map((row) => {
|
|
285
|
+
const calls = number(row.calls);
|
|
286
|
+
const errors = number(row.errors);
|
|
287
|
+
const effects = stringOf(row.effects)
|
|
288
|
+
.split(",")
|
|
289
|
+
.map((value) => value.trim())
|
|
290
|
+
.filter((value) => value !== "");
|
|
291
|
+
return {
|
|
292
|
+
name: stringOf(row.name, "(unknown)"),
|
|
293
|
+
calls,
|
|
294
|
+
errors,
|
|
295
|
+
errorRate: calls === 0 ? 0 : errors / calls,
|
|
296
|
+
avgDurationMs: maybeNumber(row.avgDurationMs),
|
|
297
|
+
maxDurationMs: maybeNumber(row.maxDurationMs),
|
|
298
|
+
effects,
|
|
299
|
+
};
|
|
300
|
+
});
|
|
301
|
+
},
|
|
302
|
+
sessions(range, limit) {
|
|
303
|
+
const rows = prepare(`SELECT session_id,
|
|
304
|
+
COUNT(*) AS runs,
|
|
305
|
+
COALESCE(SUM(turns), 0) AS turns,
|
|
306
|
+
COALESCE(SUM(input_tokens), 0) AS inputTokens,
|
|
307
|
+
COALESCE(SUM(output_tokens), 0) AS outputTokens,
|
|
308
|
+
MAX(COALESCE(ended_at, started_at)) AS lastAt,
|
|
309
|
+
GROUP_CONCAT(DISTINCT model) AS models
|
|
310
|
+
FROM runs WHERE started_at >= ? AND started_at <= ?
|
|
311
|
+
GROUP BY session_id
|
|
312
|
+
ORDER BY lastAt DESC
|
|
313
|
+
LIMIT ?`).all(range.from, range.to, Math.max(1, Math.trunc(limit)));
|
|
314
|
+
return rows.map((row) => ({
|
|
315
|
+
sessionId: stringOf(row.session_id, "(unknown)"),
|
|
316
|
+
runs: number(row.runs),
|
|
317
|
+
turns: number(row.turns),
|
|
318
|
+
inputTokens: number(row.inputTokens),
|
|
319
|
+
outputTokens: number(row.outputTokens),
|
|
320
|
+
lastAt: stringOrNull(row.lastAt),
|
|
321
|
+
models: stringOf(row.models)
|
|
322
|
+
.split(",")
|
|
323
|
+
.map((value) => value.trim())
|
|
324
|
+
.filter((value) => value !== ""),
|
|
325
|
+
}));
|
|
326
|
+
},
|
|
327
|
+
series(range, bucketSeconds) {
|
|
328
|
+
const bucket = Math.max(1, Math.trunc(bucketSeconds));
|
|
329
|
+
const rows = prepare(`SELECT (CAST(strftime('%s', created_at) AS INTEGER) / ?) * ? AS bucket,
|
|
330
|
+
COUNT(*) AS turns,
|
|
331
|
+
COALESCE(SUM(input_tokens), 0) AS inputTokens,
|
|
332
|
+
COALESCE(SUM(output_tokens), 0) AS outputTokens
|
|
333
|
+
FROM turns WHERE created_at >= ? AND created_at <= ?
|
|
334
|
+
AND strftime('%s', created_at) IS NOT NULL
|
|
335
|
+
GROUP BY bucket ORDER BY bucket ASC`).all(bucket, bucket, range.from, range.to);
|
|
336
|
+
return rows.map((row) => ({
|
|
337
|
+
bucketStart: new Date(number(row.bucket) * 1000).toISOString(),
|
|
338
|
+
runs: 0,
|
|
339
|
+
turns: number(row.turns),
|
|
340
|
+
toolCalls: 0,
|
|
341
|
+
inputTokens: number(row.inputTokens),
|
|
342
|
+
outputTokens: number(row.outputTokens),
|
|
343
|
+
}));
|
|
344
|
+
},
|
|
345
|
+
search(query, range, limit) {
|
|
346
|
+
const match = toMatchQuery(query);
|
|
347
|
+
if (match === "")
|
|
348
|
+
return { hits: [], total: 0 };
|
|
349
|
+
try {
|
|
350
|
+
const totalRow = prepare("SELECT COUNT(*) AS total FROM content_fts WHERE content_fts MATCH ?").get(match);
|
|
351
|
+
const rows = prepare(`SELECT c.id AS id, c.kind AS kind, c.ref AS ref,
|
|
352
|
+
c.created_at AS createdAt,
|
|
353
|
+
snippet(content_fts, 0, '[', ']', '…', 12) AS snippet
|
|
354
|
+
FROM content_fts JOIN content c ON c.id = content_fts.rowid
|
|
355
|
+
WHERE content_fts MATCH ? AND c.created_at >= ? AND c.created_at <= ?
|
|
356
|
+
ORDER BY c.created_at DESC, c.id DESC
|
|
357
|
+
LIMIT ?`).all(match, range.from, range.to, Math.max(1, Math.trunc(limit)));
|
|
358
|
+
return {
|
|
359
|
+
total: number(totalRow?.total),
|
|
360
|
+
hits: rows.map((row) => ({
|
|
361
|
+
id: number(row.id),
|
|
362
|
+
kind: stringOf(row.kind),
|
|
363
|
+
ref: stringOrNull(row.ref),
|
|
364
|
+
snippet: stringOf(row.snippet),
|
|
365
|
+
createdAt: stringOf(row.createdAt),
|
|
366
|
+
})),
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
catch {
|
|
370
|
+
// A malformed MATCH expression must never crash the tool.
|
|
371
|
+
return { hits: [], total: 0 };
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
snapshot(range, limit) {
|
|
375
|
+
const bound = Math.max(1, Math.trunc(limit));
|
|
376
|
+
const runRows = prepare(`SELECT run_id, session_id, model, started_at, ended_at, status,
|
|
377
|
+
input_tokens, output_tokens, cached_input_tokens, total_tokens,
|
|
378
|
+
truncated, turns, tool_calls, tool_errors
|
|
379
|
+
FROM runs WHERE started_at >= ? AND started_at <= ?
|
|
380
|
+
ORDER BY started_at ASC LIMIT ?`).all(range.from, range.to, bound);
|
|
381
|
+
const turnRows = prepare(`SELECT run_id, session_id, turn, model, input_tokens, output_tokens,
|
|
382
|
+
cached_input_tokens, duration_ms, created_at
|
|
383
|
+
FROM turns WHERE created_at >= ? AND created_at <= ?
|
|
384
|
+
ORDER BY created_at ASC LIMIT ?`).all(range.from, range.to, bound);
|
|
385
|
+
const toolRows = prepare(`SELECT run_id, call_id, session_id, name, effect, started_at, finished_at, duration_ms, is_error
|
|
386
|
+
FROM tool_calls WHERE COALESCE(started_at, finished_at) >= ? AND COALESCE(started_at, finished_at) <= ?
|
|
387
|
+
ORDER BY COALESCE(started_at, finished_at) ASC LIMIT ?`).all(range.from, range.to, bound);
|
|
388
|
+
return {
|
|
389
|
+
runs: runRows.map((row) => ({
|
|
390
|
+
runId: stringOf(row.run_id),
|
|
391
|
+
sessionId: stringOf(row.session_id),
|
|
392
|
+
model: stringOrNull(row.model),
|
|
393
|
+
startedAt: stringOf(row.started_at),
|
|
394
|
+
endedAt: stringOrNull(row.ended_at),
|
|
395
|
+
status: stringOf(row.status, "running"),
|
|
396
|
+
inputTokens: number(row.input_tokens),
|
|
397
|
+
outputTokens: number(row.output_tokens),
|
|
398
|
+
cachedInputTokens: number(row.cached_input_tokens),
|
|
399
|
+
totalTokens: maybeNumber(row.total_tokens),
|
|
400
|
+
truncated: number(row.truncated) === 1,
|
|
401
|
+
turns: number(row.turns),
|
|
402
|
+
toolCalls: number(row.tool_calls),
|
|
403
|
+
toolErrors: number(row.tool_errors),
|
|
404
|
+
})),
|
|
405
|
+
turns: turnRows.map((row) => ({
|
|
406
|
+
runId: stringOf(row.run_id),
|
|
407
|
+
sessionId: stringOf(row.session_id),
|
|
408
|
+
turn: number(row.turn),
|
|
409
|
+
model: stringOrNull(row.model),
|
|
410
|
+
inputTokens: number(row.input_tokens),
|
|
411
|
+
outputTokens: number(row.output_tokens),
|
|
412
|
+
cachedInputTokens: number(row.cached_input_tokens),
|
|
413
|
+
durationMs: maybeNumber(row.duration_ms),
|
|
414
|
+
createdAt: stringOf(row.created_at),
|
|
415
|
+
})),
|
|
416
|
+
tools: toolRows.map((row) => ({
|
|
417
|
+
runId: stringOf(row.run_id),
|
|
418
|
+
callId: stringOf(row.call_id),
|
|
419
|
+
sessionId: stringOf(row.session_id),
|
|
420
|
+
name: stringOf(row.name, "(unknown)"),
|
|
421
|
+
effect: stringOrNull(row.effect),
|
|
422
|
+
startedAt: stringOrNull(row.started_at),
|
|
423
|
+
finishedAt: stringOrNull(row.finished_at),
|
|
424
|
+
durationMs: maybeNumber(row.duration_ms),
|
|
425
|
+
isError: number(row.is_error) === 1,
|
|
426
|
+
})),
|
|
427
|
+
};
|
|
428
|
+
},
|
|
429
|
+
totals(range) {
|
|
430
|
+
const row = prepare(`SELECT
|
|
431
|
+
(SELECT COUNT(DISTINCT COALESCE(model, '(unknown)')) FROM turns WHERE created_at >= ? AND created_at <= ?) AS models,
|
|
432
|
+
(SELECT COUNT(DISTINCT name) FROM tool_calls WHERE COALESCE(started_at, finished_at) >= ? AND COALESCE(started_at, finished_at) <= ?) AS tools,
|
|
433
|
+
(SELECT COUNT(DISTINCT session_id) FROM runs WHERE started_at >= ? AND started_at <= ?) AS sessions`).get(range.from, range.to, range.from, range.to, range.from, range.to);
|
|
434
|
+
return {
|
|
435
|
+
models: number(row?.models),
|
|
436
|
+
tools: number(row?.tools),
|
|
437
|
+
sessions: number(row?.sessions),
|
|
438
|
+
};
|
|
439
|
+
},
|
|
440
|
+
recordContent(records) {
|
|
441
|
+
let written = 0;
|
|
442
|
+
database.transaction(() => {
|
|
443
|
+
for (const record of records) {
|
|
444
|
+
insertContent(record.runId, record.sessionId, record.kind, record.ref, record.text, record.createdAt);
|
|
445
|
+
written += 1;
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
return written;
|
|
449
|
+
},
|
|
450
|
+
counts() {
|
|
451
|
+
const scalar = (sql) => {
|
|
452
|
+
const row = prepare(sql).get();
|
|
453
|
+
return number(row?.value);
|
|
454
|
+
};
|
|
455
|
+
return {
|
|
456
|
+
runs: scalar("SELECT COUNT(*) AS value FROM runs"),
|
|
457
|
+
turns: scalar("SELECT COUNT(*) AS value FROM turns"),
|
|
458
|
+
toolCalls: scalar("SELECT COUNT(*) AS value FROM tool_calls"),
|
|
459
|
+
content: scalar("SELECT COUNT(*) AS value FROM content"),
|
|
460
|
+
pendingBatches: scalar("SELECT COUNT(*) AS value FROM otlp_batches WHERE status = 'pending'"),
|
|
461
|
+
deadBatches: scalar("SELECT COUNT(*) AS value FROM otlp_batches WHERE status = 'dead'"),
|
|
462
|
+
};
|
|
463
|
+
},
|
|
464
|
+
pruneBefore(iso) {
|
|
465
|
+
return database.transaction(() => {
|
|
466
|
+
const contentIds = prepare("SELECT id FROM content WHERE created_at < ?").all(iso);
|
|
467
|
+
let content = 0;
|
|
468
|
+
if (contentIds.length > 0) {
|
|
469
|
+
const ids = contentIds.map((row) => number(row.id));
|
|
470
|
+
const placeholders = ids.map(() => "?").join(", ");
|
|
471
|
+
const params = ids;
|
|
472
|
+
prepare(`DELETE FROM content_fts WHERE rowid IN (${placeholders})`).run(...params);
|
|
473
|
+
const deleted = prepare(`DELETE FROM content WHERE id IN (${placeholders})`).run(...params);
|
|
474
|
+
content = number(deleted.changes);
|
|
475
|
+
}
|
|
476
|
+
const toolCalls = number(prepare("DELETE FROM tool_calls WHERE COALESCE(started_at, finished_at) < ?").run(iso)
|
|
477
|
+
.changes);
|
|
478
|
+
const turns = number(prepare("DELETE FROM turns WHERE created_at < ?").run(iso).changes);
|
|
479
|
+
const runs = number(prepare("DELETE FROM runs WHERE started_at < ?").run(iso).changes);
|
|
480
|
+
return { runs, turns, toolCalls, content };
|
|
481
|
+
});
|
|
482
|
+
},
|
|
483
|
+
optimize() {
|
|
484
|
+
database.exec("PRAGMA optimize");
|
|
485
|
+
try {
|
|
486
|
+
database.exec("INSERT INTO content_fts(content_fts) VALUES('optimize')");
|
|
487
|
+
}
|
|
488
|
+
catch {
|
|
489
|
+
// FTS optimize is best-effort.
|
|
490
|
+
}
|
|
491
|
+
try {
|
|
492
|
+
database.exec("VACUUM");
|
|
493
|
+
}
|
|
494
|
+
catch {
|
|
495
|
+
// VACUUM can fail inside an open transaction; never fatal.
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
enqueueBatch(key, signal, payload, createdAt) {
|
|
499
|
+
const result = prepare("INSERT OR IGNORE INTO otlp_batches (batch_key, signal, payload, created_at, status) VALUES (?, ?, ?, ?, 'pending')").run(key, signal, payload, createdAt);
|
|
500
|
+
return number(result.changes) > 0;
|
|
501
|
+
},
|
|
502
|
+
pendingBatches(limit) {
|
|
503
|
+
const rows = prepare("SELECT id, batch_key, signal, payload, attempts, created_at FROM otlp_batches WHERE status = 'pending' ORDER BY id ASC LIMIT ?").all(Math.max(1, Math.trunc(limit)));
|
|
504
|
+
return rows.map((row) => ({
|
|
505
|
+
id: number(row.id),
|
|
506
|
+
batchKey: stringOf(row.batch_key),
|
|
507
|
+
signal: stringOf(row.signal),
|
|
508
|
+
payload: stringOf(row.payload),
|
|
509
|
+
attempts: number(row.attempts),
|
|
510
|
+
createdAt: stringOf(row.created_at),
|
|
511
|
+
}));
|
|
512
|
+
},
|
|
513
|
+
markBatchSent(id, at) {
|
|
514
|
+
prepare("UPDATE otlp_batches SET status = 'sent', attempts = attempts + 1, last_attempt_at = ?, last_error = NULL WHERE id = ?").run(at, id);
|
|
515
|
+
},
|
|
516
|
+
markBatchRetry(id, error, at) {
|
|
517
|
+
prepare("UPDATE otlp_batches SET attempts = attempts + 1, last_attempt_at = ?, last_error = ? WHERE id = ?").run(at, error.slice(0, 500), id);
|
|
518
|
+
},
|
|
519
|
+
markBatchDead(id, error, at) {
|
|
520
|
+
prepare("UPDATE otlp_batches SET status = 'dead', attempts = attempts + 1, last_attempt_at = ?, last_error = ? WHERE id = ?").run(at, error.slice(0, 500), id);
|
|
521
|
+
},
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Turn free text into a safe FTS5 MATCH expression: each whitespace token is
|
|
526
|
+
* quoted as a phrase, so FTS operators in the query cannot cause a syntax error.
|
|
527
|
+
*/
|
|
528
|
+
export function toMatchQuery(query) {
|
|
529
|
+
const tokens = query
|
|
530
|
+
.trim()
|
|
531
|
+
.split(/\s+/)
|
|
532
|
+
.map((token) => token.replace(/["*^:()]/g, "").trim())
|
|
533
|
+
.filter((token) => token.length > 0 && token.length <= 64)
|
|
534
|
+
.slice(0, 12);
|
|
535
|
+
if (tokens.length === 0)
|
|
536
|
+
return "";
|
|
537
|
+
return tokens.map((token) => `"${token}"`).join(" ");
|
|
538
|
+
}
|
|
539
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAiLH,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkFd,CAAC;AAEF,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACvD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACnD,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAA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AC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,MAAM,MAAM,GAAG,KAAK;SACjB,IAAI,EAAE;SACN,KAAK,CAAC,KAAK,CAAC;SACZ,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;SACrD,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;SACzD,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACnC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only, bounded, privacy-preserving agent tools.
|
|
3
|
+
*
|
|
4
|
+
* Every tool queries the LOCAL database only and returns an aggregate or a
|
|
5
|
+
* bounded slice, never a raw event dump. All five tools declare `read`: they
|
|
6
|
+
* have no local side effects. Writing, pruning and remote export are separate
|
|
7
|
+
* `write`/`external` operations exposed as commands, not tools.
|
|
8
|
+
*/
|
|
9
|
+
import { type ToolDefinition } from "@alisio/sdk";
|
|
10
|
+
import type { TelemetryConfig } from "./config.js";
|
|
11
|
+
import type { Store } from "./store.js";
|
|
12
|
+
export declare const TOOL_NAMES: readonly ["telemetry_summary", "telemetry_models", "telemetry_tools", "telemetry_sessions", "telemetry_search"];
|
|
13
|
+
export interface ToolRuntime {
|
|
14
|
+
store: Store | null;
|
|
15
|
+
config: TelemetryConfig | null;
|
|
16
|
+
/** Actionable message explaining why the store is unavailable, when it is. */
|
|
17
|
+
configError: string | null;
|
|
18
|
+
now: () => number;
|
|
19
|
+
}
|
|
20
|
+
export declare function createTelemetryTools(runtime: ToolRuntime): ToolDefinition[];
|
|
21
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,cAAc,EAA+B,MAAM,aAAa,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,YAAY,CAAC;AAEnD,eAAO,MAAM,UAAU,YACrB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,CACV,CAAC;AAEX,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IAC/B,8EAA8E;IAC9E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,GAAG,EAAE,MAAM,MAAM,CAAC;CACnB;AAqGD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,EAAE,CAiR3E"}
|