@bli-cockpit/telemetry-core 0.1.67 → 0.1.68
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 +15 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/session-facts-skills.d.ts +72 -0
- package/dist/session-facts-skills.js +201 -0
- package/dist/session-facts.d.ts +13 -0
- package/dist/session-facts.js +8 -0
- package/package.json +1 -1
|
@@ -239,8 +239,8 @@ export declare const RawEvidenceUploadBeginRequestSchema: z.ZodObject<{
|
|
|
239
239
|
}, z.core.$strict>;
|
|
240
240
|
export type RawEvidenceUploadBeginRequest = z.infer<typeof RawEvidenceUploadBeginRequestSchema>;
|
|
241
241
|
export declare const RawEvidenceUploadDispositionSchema: z.ZodEnum<{
|
|
242
|
-
new: "new";
|
|
243
242
|
resume: "resume";
|
|
243
|
+
new: "new";
|
|
244
244
|
already_committed: "already_committed";
|
|
245
245
|
conflict: "conflict";
|
|
246
246
|
}>;
|
|
@@ -249,8 +249,8 @@ export declare const RawEvidenceUploadBeginResponseObjectSchema: z.ZodObject<{
|
|
|
249
249
|
object_key: z.ZodString;
|
|
250
250
|
raw_evidence_pointer_id: z.ZodString;
|
|
251
251
|
disposition: z.ZodEnum<{
|
|
252
|
-
new: "new";
|
|
253
252
|
resume: "resume";
|
|
253
|
+
new: "new";
|
|
254
254
|
already_committed: "already_committed";
|
|
255
255
|
conflict: "conflict";
|
|
256
256
|
}>;
|
|
@@ -266,8 +266,8 @@ export declare const RawEvidenceUploadBeginResponseSchema: z.ZodObject<{
|
|
|
266
266
|
object_key: z.ZodString;
|
|
267
267
|
raw_evidence_pointer_id: z.ZodString;
|
|
268
268
|
disposition: z.ZodEnum<{
|
|
269
|
-
new: "new";
|
|
270
269
|
resume: "resume";
|
|
270
|
+
new: "new";
|
|
271
271
|
already_committed: "already_committed";
|
|
272
272
|
conflict: "conflict";
|
|
273
273
|
}>;
|
|
@@ -584,6 +584,12 @@ export declare const CodexSessionAttributionSchema: z.ZodObject<{
|
|
|
584
584
|
transcript_files: z.ZodNumber;
|
|
585
585
|
truncated_models: z.ZodNumber;
|
|
586
586
|
truncated_tool_names: z.ZodNumber;
|
|
587
|
+
skill_use: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
588
|
+
skill: z.ZodString;
|
|
589
|
+
plugin: z.ZodNullable<z.ZodString>;
|
|
590
|
+
by_person: z.ZodNumber;
|
|
591
|
+
by_agent: z.ZodNumber;
|
|
592
|
+
}, z.core.$strict>>>;
|
|
587
593
|
}, z.core.$strict>>;
|
|
588
594
|
session_file_mtime: z.ZodOptional<z.ZodString>;
|
|
589
595
|
repo_fingerprint: z.ZodOptional<z.ZodString>;
|
|
@@ -693,6 +699,12 @@ export declare const CodexSessionAttributionReportRequestSchema: z.ZodObject<{
|
|
|
693
699
|
transcript_files: z.ZodNumber;
|
|
694
700
|
truncated_models: z.ZodNumber;
|
|
695
701
|
truncated_tool_names: z.ZodNumber;
|
|
702
|
+
skill_use: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
703
|
+
skill: z.ZodString;
|
|
704
|
+
plugin: z.ZodNullable<z.ZodString>;
|
|
705
|
+
by_person: z.ZodNumber;
|
|
706
|
+
by_agent: z.ZodNumber;
|
|
707
|
+
}, z.core.$strict>>>;
|
|
696
708
|
}, z.core.$strict>>;
|
|
697
709
|
session_file_mtime: z.ZodOptional<z.ZodString>;
|
|
698
710
|
repo_fingerprint: z.ZodOptional<z.ZodString>;
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export * from "./risk-flags.js";
|
|
|
25
25
|
export * from "./run-verdict.js";
|
|
26
26
|
export * from "./secret-guards.js";
|
|
27
27
|
export * from "./session-facts.js";
|
|
28
|
+
export * from "./session-facts-skills.js";
|
|
28
29
|
export * from "./source-adapter.js";
|
|
29
30
|
export * from "./ticket-id.js";
|
|
30
31
|
export * from "./trace-sink.js";
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export * from "./risk-flags.js";
|
|
|
25
25
|
export * from "./run-verdict.js";
|
|
26
26
|
export * from "./secret-guards.js";
|
|
27
27
|
export * from "./session-facts.js";
|
|
28
|
+
export * from "./session-facts-skills.js";
|
|
28
29
|
export * from "./source-adapter.js";
|
|
29
30
|
export * from "./ticket-id.js";
|
|
30
31
|
export * from "./trace-sink.js";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BLI-13056: which skills a session used, and who invoked them. Lives beside
|
|
3
|
+
* `session-facts` because the collector (at upload) and the server (harvest,
|
|
4
|
+
* ladder) must count it by the same rules, and an upload-time `session_metrics`
|
|
5
|
+
* row that lacked it would shadow every extracted row that had it.
|
|
6
|
+
*
|
|
7
|
+
* Two kinds, because "installed" and "used" are different and so are "I typed
|
|
8
|
+
* it" and "the agent reached for it":
|
|
9
|
+
* by_person: the person typed a slash command (Claude Code) or named the
|
|
10
|
+
* skill so Codex injected it into the turn.
|
|
11
|
+
* by_agent: the model called the Skill tool (Claude Code) or opened the
|
|
12
|
+
* skill's SKILL.md (Codex has no Skill tool).
|
|
13
|
+
*
|
|
14
|
+
* Names and counts only. Arguments (`<command-args>`) are never read.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from "zod";
|
|
17
|
+
export declare const SKILL_USE_VERSION = "skills.v1";
|
|
18
|
+
/** One session names at most this many distinct skills; the rest are dropped. */
|
|
19
|
+
export declare const SKILL_USE_MAX_SKILLS = 100;
|
|
20
|
+
export declare const SkillUseCountSchema: z.ZodObject<{
|
|
21
|
+
skill: z.ZodString;
|
|
22
|
+
plugin: z.ZodNullable<z.ZodString>;
|
|
23
|
+
by_person: z.ZodNumber;
|
|
24
|
+
by_agent: z.ZodNumber;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
export interface SkillUseCount {
|
|
27
|
+
/** Name with any plugin prefix and leading `/` or `$` removed. */
|
|
28
|
+
skill: string;
|
|
29
|
+
/** The plugin the name was prefixed with (`plugin:skill`), else null. */
|
|
30
|
+
plugin: string | null;
|
|
31
|
+
by_person: number;
|
|
32
|
+
by_agent: number;
|
|
33
|
+
}
|
|
34
|
+
/** What a `session_metrics` row stores under `scores.skill_use`. */
|
|
35
|
+
export interface SkillUseScore {
|
|
36
|
+
version: typeof SKILL_USE_VERSION;
|
|
37
|
+
skills: SkillUseCount[];
|
|
38
|
+
}
|
|
39
|
+
export declare function skillUseScore(skills: SkillUseCount[]): SkillUseScore;
|
|
40
|
+
export declare function normalizeSkillName(raw: string): {
|
|
41
|
+
skill: string;
|
|
42
|
+
plugin: string | null;
|
|
43
|
+
} | null;
|
|
44
|
+
export declare class SkillUseTally {
|
|
45
|
+
private readonly counts;
|
|
46
|
+
addByPerson(raw: string): void;
|
|
47
|
+
addByAgent(raw: string): void;
|
|
48
|
+
/** Most used first, ties by name, so the stored list is stable. */
|
|
49
|
+
toList(): SkillUseCount[];
|
|
50
|
+
private entry;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The skill a person typed, from a Claude Code user turn. A typed command is
|
|
54
|
+
* recorded as `<command-message>x</command-message><command-name>/x</command-name>
|
|
55
|
+
* <command-args>…</command-args>` in a user record. Returns null for plain text,
|
|
56
|
+
* for the bare names that skill-listing attachments carry, and for built-ins.
|
|
57
|
+
*/
|
|
58
|
+
export declare function claudeTypedSkill(content: unknown): string | null;
|
|
59
|
+
/** The skill the model invoked through Claude Code's `Skill` tool. */
|
|
60
|
+
export declare function claudeAgentSkill(input: unknown): string | null;
|
|
61
|
+
/** The skill Codex injected into a user turn (the person named it). */
|
|
62
|
+
export declare function codexTypedSkill(content: unknown): string | null;
|
|
63
|
+
/**
|
|
64
|
+
* The skills a Codex tool call opened. Codex has no Skill tool: the model
|
|
65
|
+
* reads `.../skills/<name>/SKILL.md` with a shell command, so the path is the
|
|
66
|
+
* receipt. One name counts once per call, however many times the path repeats.
|
|
67
|
+
*/
|
|
68
|
+
export declare function codexAgentSkills(callArguments: unknown): string[];
|
|
69
|
+
/** Feeds one Claude Code record to the tally: a typed command (user turn) or a `Skill` tool call (assistant turn). */
|
|
70
|
+
export declare function observeClaudeSkillUse(tally: SkillUseTally, record: Record<string, unknown>): void;
|
|
71
|
+
/** Feeds one Codex `response_item` payload to the tally: an injected `<skill>` user turn or a tool call that opened a SKILL.md. */
|
|
72
|
+
export declare function observeCodexSkillUse(tally: SkillUseTally, payload: Record<string, unknown>): void;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BLI-13056: which skills a session used, and who invoked them. Lives beside
|
|
3
|
+
* `session-facts` because the collector (at upload) and the server (harvest,
|
|
4
|
+
* ladder) must count it by the same rules, and an upload-time `session_metrics`
|
|
5
|
+
* row that lacked it would shadow every extracted row that had it.
|
|
6
|
+
*
|
|
7
|
+
* Two kinds, because "installed" and "used" are different and so are "I typed
|
|
8
|
+
* it" and "the agent reached for it":
|
|
9
|
+
* by_person: the person typed a slash command (Claude Code) or named the
|
|
10
|
+
* skill so Codex injected it into the turn.
|
|
11
|
+
* by_agent: the model called the Skill tool (Claude Code) or opened the
|
|
12
|
+
* skill's SKILL.md (Codex has no Skill tool).
|
|
13
|
+
*
|
|
14
|
+
* Names and counts only. Arguments (`<command-args>`) are never read.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from "zod";
|
|
17
|
+
export const SKILL_USE_VERSION = "skills.v1";
|
|
18
|
+
/** One session names at most this many distinct skills; the rest are dropped. */
|
|
19
|
+
export const SKILL_USE_MAX_SKILLS = 100;
|
|
20
|
+
export const SkillUseCountSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
skill: z.string().min(1).max(200),
|
|
23
|
+
plugin: z.string().min(1).max(200).nullable(),
|
|
24
|
+
by_person: z.number().int().nonnegative(),
|
|
25
|
+
by_agent: z.number().int().nonnegative(),
|
|
26
|
+
})
|
|
27
|
+
.strict();
|
|
28
|
+
export function skillUseScore(skills) {
|
|
29
|
+
return { version: SKILL_USE_VERSION, skills };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Typed slash commands that are Claude Code's own controls, not skills.
|
|
33
|
+
* A transcript records them with the same `<command-name>` tag as a skill, so
|
|
34
|
+
* the only way to keep `/clear` out of a skill ranking is to name them.
|
|
35
|
+
*/
|
|
36
|
+
const CLAUDE_BUILT_IN_COMMANDS = new Set([
|
|
37
|
+
"add-dir", "agents", "bashes", "bug", "clear", "compact", "config", "context", "cost", "doctor", "effort", "exit",
|
|
38
|
+
"export", "fast", "feedback", "help", "hooks", "ide", "init", "install-github-app", "login", "logout", "mcp",
|
|
39
|
+
"memory", "model", "output-style", "permissions", "plugin", "plugins", "pr-comments", "privacy-settings", "quit",
|
|
40
|
+
"rate-limit-options", "recap", "release-notes", "reload-plugins", "remote-control", "rename", "resume", "rewind",
|
|
41
|
+
"settings", "status", "statusline", "team-onboarding", "terminal-setup", "theme", "todos", "upgrade", "usage", "vim",
|
|
42
|
+
"extra-usage", "stats", "tasks", "keybindings", "mobile", "desktop", "chrome", "skills", "branch", "copy", "diff",
|
|
43
|
+
]);
|
|
44
|
+
export function normalizeSkillName(raw) {
|
|
45
|
+
const bare = raw.trim().replace(/^[/$]+/, "").trim();
|
|
46
|
+
if (!bare || bare.length > 200 || /\s/.test(bare))
|
|
47
|
+
return null;
|
|
48
|
+
const colon = bare.lastIndexOf(":");
|
|
49
|
+
if (colon < 0)
|
|
50
|
+
return { skill: bare, plugin: null };
|
|
51
|
+
const plugin = bare.slice(0, colon);
|
|
52
|
+
const skill = bare.slice(colon + 1);
|
|
53
|
+
return skill ? { skill, plugin: plugin || null } : null;
|
|
54
|
+
}
|
|
55
|
+
export class SkillUseTally {
|
|
56
|
+
counts = new Map();
|
|
57
|
+
addByPerson(raw) {
|
|
58
|
+
const entry = this.entry(raw);
|
|
59
|
+
if (entry)
|
|
60
|
+
entry.by_person += 1;
|
|
61
|
+
}
|
|
62
|
+
addByAgent(raw) {
|
|
63
|
+
const entry = this.entry(raw);
|
|
64
|
+
if (entry)
|
|
65
|
+
entry.by_agent += 1;
|
|
66
|
+
}
|
|
67
|
+
/** Most used first, ties by name, so the stored list is stable. */
|
|
68
|
+
toList() {
|
|
69
|
+
return [...this.counts.values()]
|
|
70
|
+
.filter((c) => c.by_person + c.by_agent > 0)
|
|
71
|
+
.sort((a, b) => b.by_person + b.by_agent - (a.by_person + a.by_agent) || a.skill.localeCompare(b.skill));
|
|
72
|
+
}
|
|
73
|
+
entry(raw) {
|
|
74
|
+
const name = normalizeSkillName(raw);
|
|
75
|
+
if (!name)
|
|
76
|
+
return null;
|
|
77
|
+
const key = `${name.plugin ?? ""}:${name.skill}`;
|
|
78
|
+
let entry = this.counts.get(key);
|
|
79
|
+
if (!entry) {
|
|
80
|
+
entry = { skill: name.skill, plugin: name.plugin, by_person: 0, by_agent: 0 };
|
|
81
|
+
this.counts.set(key, entry);
|
|
82
|
+
}
|
|
83
|
+
return entry;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const CLAUDE_COMMAND_RE = /^\s*(?:<command-message>[^<]{0,200}<\/command-message>\s*)?<command-name>([^<]{1,200})<\/command-name>/;
|
|
87
|
+
/**
|
|
88
|
+
* The skill a person typed, from a Claude Code user turn. A typed command is
|
|
89
|
+
* recorded as `<command-message>x</command-message><command-name>/x</command-name>
|
|
90
|
+
* <command-args>…</command-args>` in a user record. Returns null for plain text,
|
|
91
|
+
* for the bare names that skill-listing attachments carry, and for built-ins.
|
|
92
|
+
*/
|
|
93
|
+
export function claudeTypedSkill(content) {
|
|
94
|
+
const text = firstText(content);
|
|
95
|
+
if (!text)
|
|
96
|
+
return null;
|
|
97
|
+
const match = CLAUDE_COMMAND_RE.exec(text.slice(0, 600));
|
|
98
|
+
const name = match?.[1]?.trim();
|
|
99
|
+
if (!name?.startsWith("/"))
|
|
100
|
+
return null;
|
|
101
|
+
const parsed = normalizeSkillName(name);
|
|
102
|
+
if (!parsed)
|
|
103
|
+
return null;
|
|
104
|
+
if (!parsed.plugin && CLAUDE_BUILT_IN_COMMANDS.has(parsed.skill))
|
|
105
|
+
return null;
|
|
106
|
+
return name;
|
|
107
|
+
}
|
|
108
|
+
function firstText(content) {
|
|
109
|
+
if (typeof content === "string")
|
|
110
|
+
return content;
|
|
111
|
+
if (!Array.isArray(content))
|
|
112
|
+
return null;
|
|
113
|
+
for (const block of content) {
|
|
114
|
+
const kind = block && typeof block === "object" ? block["type"] : null;
|
|
115
|
+
if (kind === "text" || kind === "input_text") {
|
|
116
|
+
const text = block["text"];
|
|
117
|
+
if (typeof text === "string")
|
|
118
|
+
return text;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
/** The skill the model invoked through Claude Code's `Skill` tool. */
|
|
124
|
+
export function claudeAgentSkill(input) {
|
|
125
|
+
if (!input || typeof input !== "object")
|
|
126
|
+
return null;
|
|
127
|
+
const skill = input["skill"];
|
|
128
|
+
return typeof skill === "string" ? skill : null;
|
|
129
|
+
}
|
|
130
|
+
const CODEX_INJECTED_SKILL_RE = /^\s*<skill>\s*<name>([^<]{1,200})<\/name>/;
|
|
131
|
+
/** The skill Codex injected into a user turn (the person named it). */
|
|
132
|
+
export function codexTypedSkill(content) {
|
|
133
|
+
const text = firstText(content);
|
|
134
|
+
if (!text)
|
|
135
|
+
return null;
|
|
136
|
+
return CODEX_INJECTED_SKILL_RE.exec(text.slice(0, 400))?.[1]?.trim() ?? null;
|
|
137
|
+
}
|
|
138
|
+
const CODEX_SKILL_FILE_RE = /\/skills\/(?:\.system\/)?([^/\s"'\\]+)\/SKILL\.md/g;
|
|
139
|
+
const CODEX_PLUGIN_SKILL_RE = /\/plugins\/cache\/[^/\s"'\\]+\/([^/\s"'\\]+)\/[^/\s"'\\]+\/skills\/([^/\s"'\\]+)\/SKILL\.md/g;
|
|
140
|
+
/**
|
|
141
|
+
* The skills a Codex tool call opened. Codex has no Skill tool: the model
|
|
142
|
+
* reads `.../skills/<name>/SKILL.md` with a shell command, so the path is the
|
|
143
|
+
* receipt. One name counts once per call, however many times the path repeats.
|
|
144
|
+
*/
|
|
145
|
+
export function codexAgentSkills(callArguments) {
|
|
146
|
+
const text = typeof callArguments === "string" ? callArguments : callArguments == null ? "" : safeStringify(callArguments);
|
|
147
|
+
if (!text.includes("SKILL.md"))
|
|
148
|
+
return [];
|
|
149
|
+
const found = new Set();
|
|
150
|
+
for (const m of text.matchAll(CODEX_PLUGIN_SKILL_RE))
|
|
151
|
+
found.add(`${m[1]}:${m[2]}`);
|
|
152
|
+
for (const m of text.matchAll(CODEX_SKILL_FILE_RE)) {
|
|
153
|
+
const name = m[1];
|
|
154
|
+
if (![...found].some((f) => f.endsWith(`:${name}`)))
|
|
155
|
+
found.add(name);
|
|
156
|
+
}
|
|
157
|
+
return [...found];
|
|
158
|
+
}
|
|
159
|
+
function safeStringify(value) {
|
|
160
|
+
try {
|
|
161
|
+
return JSON.stringify(value);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return "";
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/** Feeds one Claude Code record to the tally: a typed command (user turn) or a `Skill` tool call (assistant turn). */
|
|
168
|
+
export function observeClaudeSkillUse(tally, record) {
|
|
169
|
+
const message = record["message"];
|
|
170
|
+
if (record["type"] === "user") {
|
|
171
|
+
const typed = claudeTypedSkill(message?.["content"]);
|
|
172
|
+
if (typed)
|
|
173
|
+
tally.addByPerson(typed);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const content = message?.["content"];
|
|
177
|
+
if (record["type"] !== "assistant" || !Array.isArray(content))
|
|
178
|
+
return;
|
|
179
|
+
for (const block of content) {
|
|
180
|
+
if (!block || typeof block !== "object" || block["type"] !== "tool_use")
|
|
181
|
+
continue;
|
|
182
|
+
if (block["name"] !== "Skill")
|
|
183
|
+
continue;
|
|
184
|
+
const skill = claudeAgentSkill(block["input"]);
|
|
185
|
+
if (skill)
|
|
186
|
+
tally.addByAgent(skill);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/** Feeds one Codex `response_item` payload to the tally: an injected `<skill>` user turn or a tool call that opened a SKILL.md. */
|
|
190
|
+
export function observeCodexSkillUse(tally, payload) {
|
|
191
|
+
const itemType = String(payload["type"] ?? "");
|
|
192
|
+
if ((itemType === "message" || itemType === "user_message") && payload["role"] === "user") {
|
|
193
|
+
const typed = codexTypedSkill(payload["content"]);
|
|
194
|
+
if (typed)
|
|
195
|
+
tally.addByPerson(typed);
|
|
196
|
+
}
|
|
197
|
+
else if (itemType === "function_call" || itemType === "custom_tool_call") {
|
|
198
|
+
for (const skill of codexAgentSkills(payload["arguments"] ?? payload["input"]))
|
|
199
|
+
tally.addByAgent(skill);
|
|
200
|
+
}
|
|
201
|
+
}
|
package/dist/session-facts.d.ts
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
* Anthropic-shaped usage the price table expects.
|
|
36
36
|
*/
|
|
37
37
|
import { z } from "zod";
|
|
38
|
+
import { SkillUseTally, type SkillUseCount } from "./session-facts-skills.js";
|
|
38
39
|
/** Bump when a counting rule changes, never when a field is added. */
|
|
39
40
|
export declare const SESSION_FACTS_VERSION = "det.v6";
|
|
40
41
|
/** How many distinct models and tool names one session may report. */
|
|
@@ -77,6 +78,11 @@ export interface SessionFacts {
|
|
|
77
78
|
truncated_models: number;
|
|
78
79
|
/** Distinct tool names dropped by the cap. */
|
|
79
80
|
truncated_tool_names: number;
|
|
81
|
+
/**
|
|
82
|
+
* BLI-13056: skills used, by the person (typed) and by the agent (tool call).
|
|
83
|
+
* Names and counts only. Absent from a block a CLI published before this field.
|
|
84
|
+
*/
|
|
85
|
+
skill_use?: SkillUseCount[];
|
|
80
86
|
}
|
|
81
87
|
export interface SessionFactsAccumulator {
|
|
82
88
|
source: SessionFactsSource;
|
|
@@ -94,6 +100,7 @@ export interface SessionFactsAccumulator {
|
|
|
94
100
|
/** Codex only: the newest cumulative total and the model to attribute it to. */
|
|
95
101
|
codex_total_usage: Record<string, unknown> | null;
|
|
96
102
|
codex_model_hint: string | null;
|
|
103
|
+
skill_tally: SkillUseTally;
|
|
97
104
|
}
|
|
98
105
|
export declare function newSessionFactsAccumulator(source: SessionFactsSource): SessionFactsAccumulator;
|
|
99
106
|
/** One transcript file's size, for callers that never hold its whole text. */
|
|
@@ -172,6 +179,12 @@ export declare const SessionFactsSchema: z.ZodObject<{
|
|
|
172
179
|
transcript_files: z.ZodNumber;
|
|
173
180
|
truncated_models: z.ZodNumber;
|
|
174
181
|
truncated_tool_names: z.ZodNumber;
|
|
182
|
+
skill_use: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
183
|
+
skill: z.ZodString;
|
|
184
|
+
plugin: z.ZodNullable<z.ZodString>;
|
|
185
|
+
by_person: z.ZodNumber;
|
|
186
|
+
by_agent: z.ZodNumber;
|
|
187
|
+
}, z.core.$strict>>>;
|
|
175
188
|
}, z.core.$strict>;
|
|
176
189
|
export type SessionFactsWire = z.infer<typeof SessionFactsSchema>;
|
|
177
190
|
export { claudeAssistantText, claudeUserTurnText, codexAssistantText, codexUserTurnText, normalizeTurnText, textFromPlainTextBlocks, } from "./session-facts-text.js";
|
package/dist/session-facts.js
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
*/
|
|
37
37
|
import { z } from "zod";
|
|
38
38
|
import { claudeAssistantText, claudeUserTurnText, codexAssistantText, codexUserTurnText, } from "./session-facts-text.js";
|
|
39
|
+
import { observeClaudeSkillUse, observeCodexSkillUse, SKILL_USE_MAX_SKILLS, SkillUseCountSchema, SkillUseTally, } from "./session-facts-skills.js";
|
|
39
40
|
/** Bump when a counting rule changes, never when a field is added. */
|
|
40
41
|
export const SESSION_FACTS_VERSION = "det.v6";
|
|
41
42
|
/** How many distinct models and tool names one session may report. */
|
|
@@ -59,6 +60,7 @@ export function newSessionFactsAccumulator(source) {
|
|
|
59
60
|
transcript_files: 0,
|
|
60
61
|
codex_total_usage: null,
|
|
61
62
|
codex_model_hint: null,
|
|
63
|
+
skill_tally: new SkillUseTally(),
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
/** One transcript file's size, for callers that never hold its whole text. */
|
|
@@ -90,6 +92,7 @@ function observeClaudeRecord(acc, record) {
|
|
|
90
92
|
const text = claudeUserTurnText(record);
|
|
91
93
|
if (text?.trim())
|
|
92
94
|
acc.user_prompt_count += 1;
|
|
95
|
+
observeClaudeSkillUse(acc.skill_tally, record);
|
|
93
96
|
return;
|
|
94
97
|
}
|
|
95
98
|
if (type !== "assistant")
|
|
@@ -122,6 +125,7 @@ function observeClaudeRecord(acc, record) {
|
|
|
122
125
|
continue;
|
|
123
126
|
countTool(acc, typeof b["name"] === "string" ? b["name"] : "unknown");
|
|
124
127
|
}
|
|
128
|
+
observeClaudeSkillUse(acc.skill_tally, record);
|
|
125
129
|
}
|
|
126
130
|
function observeCodexRecord(acc, record) {
|
|
127
131
|
const type = String(record["type"] ?? "");
|
|
@@ -137,6 +141,7 @@ function observeCodexRecord(acc, record) {
|
|
|
137
141
|
if ((itemType === "message" || itemType === "user_message") && p["role"] === "user") {
|
|
138
142
|
if (codexUserTurnText(p)?.trim())
|
|
139
143
|
acc.user_prompt_count += 1;
|
|
144
|
+
observeCodexSkillUse(acc.skill_tally, p);
|
|
140
145
|
return;
|
|
141
146
|
}
|
|
142
147
|
if (itemType === "message" && p["role"] === "assistant") {
|
|
@@ -147,6 +152,7 @@ function observeCodexRecord(acc, record) {
|
|
|
147
152
|
if (itemType === "function_call") {
|
|
148
153
|
countTool(acc, typeof p["name"] === "string" ? p["name"] : "unknown");
|
|
149
154
|
}
|
|
155
|
+
observeCodexSkillUse(acc.skill_tally, p);
|
|
150
156
|
return;
|
|
151
157
|
}
|
|
152
158
|
if (type !== "event_msg")
|
|
@@ -237,6 +243,7 @@ export function finalizeSessionFacts(acc) {
|
|
|
237
243
|
transcript_files: acc.transcript_files,
|
|
238
244
|
truncated_models: usageEntries.length - keptUsage.length,
|
|
239
245
|
truncated_tool_names: toolEntries.length - keptTools.length,
|
|
246
|
+
skill_use: acc.skill_tally.toList().slice(0, SKILL_USE_MAX_SKILLS),
|
|
240
247
|
};
|
|
241
248
|
}
|
|
242
249
|
/**
|
|
@@ -351,6 +358,7 @@ export const SessionFactsSchema = z
|
|
|
351
358
|
transcript_files: z.number().int().nonnegative(),
|
|
352
359
|
truncated_models: z.number().int().nonnegative(),
|
|
353
360
|
truncated_tool_names: z.number().int().nonnegative(),
|
|
361
|
+
skill_use: z.array(SkillUseCountSchema).max(SKILL_USE_MAX_SKILLS).optional(),
|
|
354
362
|
})
|
|
355
363
|
.strict();
|
|
356
364
|
export { claudeAssistantText, claudeUserTurnText, codexAssistantText, codexUserTurnText, normalizeTurnText, textFromPlainTextBlocks, } from "./session-facts-text.js";
|