@bli-cockpit/telemetry-core 0.1.75 → 0.1.77
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/evidence-upload.d.ts +40 -0
- package/dist/evidence-upload.js +10 -0
- package/dist/image-marker-resolver.js +31 -22
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/log-digest/digest-source.js +33 -23
- package/dist/log-digest/digest.d.ts +4 -0
- package/dist/log-digest/digest.js +44 -35
- package/dist/log-digest/index.d.ts +1 -1
- package/dist/log-digest/judge.js +15 -10
- package/dist/log-digest/log-projects.d.ts +15 -1
- package/dist/log-digest/log-projects.js +3 -0
- package/dist/log-digest/merge.js +49 -35
- package/dist/log-digest/render.js +11 -6
- package/dist/log-digest/sources/process.js +38 -19
- package/dist/log-digest/sources/vercel.js +62 -47
- package/dist/log-digest/stored.js +31 -24
- package/dist/node-daemon-http-client.js +23 -23
- package/dist/session-client-app.d.ts +21 -0
- package/dist/session-client-app.js +51 -0
- package/dist/session-facts-active.d.ts +7 -0
- package/dist/session-facts-active.js +18 -0
- package/dist/session-facts-spawn.d.ts +36 -0
- package/dist/session-facts-spawn.js +50 -2
- package/dist/session-facts.d.ts +18 -10
- package/dist/session-facts.js +17 -12
- package/package.json +1 -1
package/dist/session-facts.d.ts
CHANGED
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
* Session facts: everything deterministic about one transcript, counted once,
|
|
3
3
|
* where the file already is.
|
|
4
4
|
*
|
|
5
|
-
* BLI-4341 part A.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the same bytes at harvest time and had already read every line, so the
|
|
9
|
-
* download was pure re-work, and a session with no analysis run had no token
|
|
10
|
-
* count at all.
|
|
5
|
+
* BLI-4341 part A. Token totals used to be computed only on the server, which downloaded the transcript back out of
|
|
6
|
+
* Storage and summed it (`det.v5`), though the collector holds the same bytes at harvest time and had already read
|
|
7
|
+
* every line; a session with no analysis run had no token count at all.
|
|
11
8
|
*
|
|
12
9
|
* This module is the ONE implementation of those rules. The collector feeds it
|
|
13
10
|
* at upload; the server extractor feeds it the same records during its own
|
|
@@ -72,6 +69,8 @@ export interface SessionFacts {
|
|
|
72
69
|
first_timestamp: string | null;
|
|
73
70
|
last_timestamp: string | null;
|
|
74
71
|
wall_duration_seconds: number | null;
|
|
72
|
+
/** Ticket 19258: seconds in use (`session-facts-active.ts`). Absent from a block counted before this field. */
|
|
73
|
+
active_seconds?: number;
|
|
75
74
|
transcript_bytes: number;
|
|
76
75
|
transcript_lines: number;
|
|
77
76
|
/** Main plus any sidecars the caller fed in. */
|
|
@@ -80,10 +79,7 @@ export interface SessionFacts {
|
|
|
80
79
|
truncated_models: number;
|
|
81
80
|
/** Distinct tool names dropped by the cap. */
|
|
82
81
|
truncated_tool_names: number;
|
|
83
|
-
/**
|
|
84
|
-
* BLI-13056: skills used, by the person (typed) and by the agent (tool call).
|
|
85
|
-
* Names and counts only. Absent from a block a CLI published before this field.
|
|
86
|
-
*/
|
|
82
|
+
/** BLI-13056: skills used, by the person (typed) and by the agent (tool call); names and counts only. Absent from a block a CLI published before this field. */
|
|
87
83
|
skill_use?: SkillUseCount[];
|
|
88
84
|
/** BLI-13066: who started the session (`session-facts-spawn.ts`). Absent from a block a CLI published before this field. */
|
|
89
85
|
spawn?: SessionSpawn;
|
|
@@ -98,6 +94,7 @@ export interface SessionFactsAccumulator {
|
|
|
98
94
|
tool_calls_by_name: Record<string, number>;
|
|
99
95
|
first_timestamp_ms: number | null;
|
|
100
96
|
last_timestamp_ms: number | null;
|
|
97
|
+
timestamps_ms: number[];
|
|
101
98
|
transcript_bytes: number;
|
|
102
99
|
transcript_lines: number;
|
|
103
100
|
transcript_files: number;
|
|
@@ -179,6 +176,7 @@ export declare const SessionFactsSchema: z.ZodObject<{
|
|
|
179
176
|
first_timestamp: z.ZodNullable<z.ZodString>;
|
|
180
177
|
last_timestamp: z.ZodNullable<z.ZodString>;
|
|
181
178
|
wall_duration_seconds: z.ZodNullable<z.ZodNumber>;
|
|
179
|
+
active_seconds: z.ZodOptional<z.ZodNumber>;
|
|
182
180
|
transcript_bytes: z.ZodNumber;
|
|
183
181
|
transcript_lines: z.ZodNumber;
|
|
184
182
|
transcript_files: z.ZodNumber;
|
|
@@ -196,6 +194,16 @@ export declare const SessionFactsSchema: z.ZodObject<{
|
|
|
196
194
|
worker: "worker";
|
|
197
195
|
subagent: "subagent";
|
|
198
196
|
}>;
|
|
197
|
+
client_app: z.ZodOptional<z.ZodEnum<{
|
|
198
|
+
unknown: "unknown";
|
|
199
|
+
claude_cli: "claude_cli";
|
|
200
|
+
claude_desktop: "claude_desktop";
|
|
201
|
+
claude_ide: "claude_ide";
|
|
202
|
+
codex_cli: "codex_cli";
|
|
203
|
+
codex_desktop: "codex_desktop";
|
|
204
|
+
codex_ide: "codex_ide";
|
|
205
|
+
codex_exec: "codex_exec";
|
|
206
|
+
}>>;
|
|
199
207
|
parent_session_id: z.ZodOptional<z.ZodString>;
|
|
200
208
|
}, z.core.$strict>>;
|
|
201
209
|
}, z.core.$strict>;
|
package/dist/session-facts.js
CHANGED
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
* Session facts: everything deterministic about one transcript, counted once,
|
|
3
3
|
* where the file already is.
|
|
4
4
|
*
|
|
5
|
-
* BLI-4341 part A.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the same bytes at harvest time and had already read every line, so the
|
|
9
|
-
* download was pure re-work, and a session with no analysis run had no token
|
|
10
|
-
* count at all.
|
|
5
|
+
* BLI-4341 part A. Token totals used to be computed only on the server, which downloaded the transcript back out of
|
|
6
|
+
* Storage and summed it (`det.v5`), though the collector holds the same bytes at harvest time and had already read
|
|
7
|
+
* every line; a session with no analysis run had no token count at all.
|
|
11
8
|
*
|
|
12
9
|
* This module is the ONE implementation of those rules. The collector feeds it
|
|
13
10
|
* at upload; the server extractor feeds it the same records during its own
|
|
@@ -36,6 +33,7 @@
|
|
|
36
33
|
*/
|
|
37
34
|
import { z } from "zod";
|
|
38
35
|
import { claudeAssistantText, claudeUserTurnText, codexAssistantText, codexUserTurnText } from "./session-facts-text.js";
|
|
36
|
+
import { activeSeconds } from "./session-facts-active.js";
|
|
39
37
|
import { claudeSpawn, codexSpawn, SessionSpawnSchema } from "./session-facts-spawn.js";
|
|
40
38
|
import { observeClaudeSkillUse, observeCodexSkillUse, SKILL_USE_MAX_SKILLS, SkillUseCountSchema, SkillUseTally } from "./session-facts-skills.js";
|
|
41
39
|
/** Bump when a counting rule changes, never when a field is added. */
|
|
@@ -56,6 +54,7 @@ export function newSessionFactsAccumulator(source) {
|
|
|
56
54
|
tool_calls_by_name: {},
|
|
57
55
|
first_timestamp_ms: null,
|
|
58
56
|
last_timestamp_ms: null,
|
|
57
|
+
timestamps_ms: [],
|
|
59
58
|
transcript_bytes: 0,
|
|
60
59
|
transcript_lines: 0,
|
|
61
60
|
transcript_files: 0,
|
|
@@ -76,6 +75,7 @@ export function observeSessionFactsRecord(acc, record) {
|
|
|
76
75
|
acc.record_count += 1;
|
|
77
76
|
const ms = parseTimestampMs(record["timestamp"]);
|
|
78
77
|
if (ms != null) {
|
|
78
|
+
acc.timestamps_ms.push(ms);
|
|
79
79
|
acc.first_timestamp_ms =
|
|
80
80
|
acc.first_timestamp_ms == null ? ms : Math.min(acc.first_timestamp_ms, ms);
|
|
81
81
|
acc.last_timestamp_ms =
|
|
@@ -216,12 +216,7 @@ export function finalizeSessionFacts(acc) {
|
|
|
216
216
|
const keptTools = toolEntries.slice(0, SESSION_FACTS_MAX_TOOL_NAMES);
|
|
217
217
|
const usage_by_model = Object.fromEntries(keptUsage);
|
|
218
218
|
const tool_calls_by_name = Object.fromEntries(keptTools);
|
|
219
|
-
const totals = keptUsage.
|
|
220
|
-
input_tokens: sum.input_tokens + usage.input_tokens,
|
|
221
|
-
output_tokens: sum.output_tokens + usage.output_tokens,
|
|
222
|
-
cache_read_input_tokens: sum.cache_read_input_tokens + usage.cache_read_input_tokens,
|
|
223
|
-
cache_creation_input_tokens: sum.cache_creation_input_tokens + usage.cache_creation_input_tokens,
|
|
224
|
-
}), emptyUsage());
|
|
219
|
+
const totals = sumUsage(keptUsage.map(([, usage]) => usage));
|
|
225
220
|
const first = acc.first_timestamp_ms;
|
|
226
221
|
const last = acc.last_timestamp_ms;
|
|
227
222
|
return {
|
|
@@ -250,6 +245,7 @@ export function finalizeSessionFacts(acc) {
|
|
|
250
245
|
truncated_tool_names: toolEntries.length - keptTools.length,
|
|
251
246
|
skill_use: acc.skill_tally.toList().slice(0, SKILL_USE_MAX_SKILLS),
|
|
252
247
|
...(acc.spawn ? { spawn: acc.spawn } : {}),
|
|
248
|
+
active_seconds: activeSeconds(acc.timestamps_ms),
|
|
253
249
|
};
|
|
254
250
|
}
|
|
255
251
|
/**
|
|
@@ -299,6 +295,14 @@ function usageTotal(usage) {
|
|
|
299
295
|
usage.cache_read_input_tokens +
|
|
300
296
|
usage.cache_creation_input_tokens);
|
|
301
297
|
}
|
|
298
|
+
function sumUsage(usages) {
|
|
299
|
+
return usages.reduce((sum, usage) => ({
|
|
300
|
+
input_tokens: sum.input_tokens + usage.input_tokens,
|
|
301
|
+
output_tokens: sum.output_tokens + usage.output_tokens,
|
|
302
|
+
cache_read_input_tokens: sum.cache_read_input_tokens + usage.cache_read_input_tokens,
|
|
303
|
+
cache_creation_input_tokens: sum.cache_creation_input_tokens + usage.cache_creation_input_tokens,
|
|
304
|
+
}), emptyUsage());
|
|
305
|
+
}
|
|
302
306
|
function emptyUsage() {
|
|
303
307
|
return {
|
|
304
308
|
input_tokens: 0,
|
|
@@ -359,6 +363,7 @@ export const SessionFactsSchema = z
|
|
|
359
363
|
first_timestamp: z.string().datetime({ offset: true }).nullable(),
|
|
360
364
|
last_timestamp: z.string().datetime({ offset: true }).nullable(),
|
|
361
365
|
wall_duration_seconds: z.number().int().nonnegative().nullable(),
|
|
366
|
+
active_seconds: z.number().int().nonnegative().optional(),
|
|
362
367
|
transcript_bytes: z.number().int().nonnegative(),
|
|
363
368
|
transcript_lines: z.number().int().nonnegative(),
|
|
364
369
|
transcript_files: z.number().int().nonnegative(),
|