@invictus-group-ai/hooks 0.7.0 → 0.7.1

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.
@@ -8,207 +8,40 @@
8
8
  */
9
9
  import { z } from 'zod';
10
10
  export declare const tokenCountsSchema: z.ZodObject<{
11
- /** input tokens */ i: z.ZodNumber;
12
- /** output tokens */ o: z.ZodNumber;
13
- /** cache-read tokens */ cr: z.ZodNumber;
14
- /** cache-write (creation) tokens */ cw: z.ZodNumber;
15
- }, "strict", z.ZodTypeAny, {
16
- i: number;
17
- o: number;
18
- cr: number;
19
- cw: number;
20
- }, {
21
- i: number;
22
- o: number;
23
- cr: number;
24
- cw: number;
25
- }>;
11
+ i: z.ZodNumber;
12
+ o: z.ZodNumber;
13
+ cr: z.ZodNumber;
14
+ cw: z.ZodNumber;
15
+ }, z.core.$strict>;
26
16
  export type TokenCounts = z.infer<typeof tokenCountsSchema>;
27
17
  /**
28
18
  * `data` of a `session.end` event. `.passthrough()` keeps unknown fields so
29
19
  * newer producers do not break older consumers (forward compatibility).
30
20
  */
31
21
  export declare const sessionEndDataSchema: z.ZodObject<{
32
- /**
33
- * Which hook event produced this entry. `PreCommit` is the snapshot taken
34
- * on PreToolUse just before the agent runs `git commit`: without it a
35
- * commit made mid-session found no snapshot yet and shipped no trailer.
36
- */
37
- event: z.ZodEnum<["SessionEnd", "SubagentStop", "PreCommit"]>;
38
- /** Claude Code SessionEnd `reason` (e.g. `clear`, `logout`), if any. */
39
- reason: z.ZodOptional<z.ZodString>;
40
- /** Token counts summed over the transcript. */
41
- t: z.ZodObject<{
42
- /** input tokens */ i: z.ZodNumber;
43
- /** output tokens */ o: z.ZodNumber;
44
- /** cache-read tokens */ cr: z.ZodNumber;
45
- /** cache-write (creation) tokens */ cw: z.ZodNumber;
46
- }, "strict", z.ZodTypeAny, {
47
- i: number;
48
- o: number;
49
- cr: number;
50
- cw: number;
51
- }, {
52
- i: number;
53
- o: number;
54
- cr: number;
55
- cw: number;
56
- }>;
57
- /** Model mix, percent by short model tag (≤16 chars per tag). */
58
- m: z.ZodRecord<z.ZodString, z.ZodNumber>;
59
- /** Full id of the dominant model (for the Assisted-by trailer). */
60
- model: z.ZodOptional<z.ZodString>;
61
- /** Agent CLI at `name@version` (e.g. `claude-code@2.1.200`). */
62
- tool: z.ZodOptional<z.ZodString>;
63
- /** Estimated cost in integer cents (0 when the transcript has no costUSD). */
64
- usdCents: z.ZodNumber;
65
- /** User prompts observed in the transcript. */
66
- prompts: z.ZodNumber;
67
- /** Tool calls observed in the transcript. */
68
- toolCalls: z.ZodNumber;
69
- /**
70
- * Edit-tool (Write|Edit|MultiEdit|NotebookEdit) calls that completed —
71
- * their `tool_use` got a `tool_result` that is not a denial. Optional:
72
- * entries written by hooks ≤0.2.0 predate the field.
73
- */
74
- acc: z.ZodOptional<z.ZodNumber>;
75
- /**
76
- * Edit-tool calls denied before running: `tool_result` with
77
- * `is_error: true` carrying a user-rejection / permission-denial text
78
- * (or a `toolDenialKind` on the transcript line), plus edits killed by
79
- * an explicit `[Request interrupted by user for tool use]` marker.
80
- */
81
- rej: z.ZodOptional<z.ZodNumber>;
82
- /**
83
- * Active seconds: sum of consecutive transcript-timestamp gaps < 5 min
84
- * (gaps ≥ 5 min count as idle). Always ≤ durSec. Optional: entries
85
- * written by hooks ≤0.2.0 predate the field (consumers fall back to
86
- * durSec — the old `act = dur` behavior).
87
- */
88
- actSec: z.ZodOptional<z.ZodNumber>;
89
- /** Wall-clock seconds between the first and last transcript timestamps. */
90
- durSec: z.ZodNumber;
91
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
92
- /**
93
- * Which hook event produced this entry. `PreCommit` is the snapshot taken
94
- * on PreToolUse just before the agent runs `git commit`: without it a
95
- * commit made mid-session found no snapshot yet and shipped no trailer.
96
- */
97
- event: z.ZodEnum<["SessionEnd", "SubagentStop", "PreCommit"]>;
98
- /** Claude Code SessionEnd `reason` (e.g. `clear`, `logout`), if any. */
99
- reason: z.ZodOptional<z.ZodString>;
100
- /** Token counts summed over the transcript. */
101
- t: z.ZodObject<{
102
- /** input tokens */ i: z.ZodNumber;
103
- /** output tokens */ o: z.ZodNumber;
104
- /** cache-read tokens */ cr: z.ZodNumber;
105
- /** cache-write (creation) tokens */ cw: z.ZodNumber;
106
- }, "strict", z.ZodTypeAny, {
107
- i: number;
108
- o: number;
109
- cr: number;
110
- cw: number;
111
- }, {
112
- i: number;
113
- o: number;
114
- cr: number;
115
- cw: number;
22
+ event: z.ZodEnum<{
23
+ SessionEnd: "SessionEnd";
24
+ SubagentStop: "SubagentStop";
25
+ PreCommit: "PreCommit";
116
26
  }>;
117
- /** Model mix, percent by short model tag (≤16 chars per tag). */
118
- m: z.ZodRecord<z.ZodString, z.ZodNumber>;
119
- /** Full id of the dominant model (for the Assisted-by trailer). */
120
- model: z.ZodOptional<z.ZodString>;
121
- /** Agent CLI at `name@version` (e.g. `claude-code@2.1.200`). */
122
- tool: z.ZodOptional<z.ZodString>;
123
- /** Estimated cost in integer cents (0 when the transcript has no costUSD). */
124
- usdCents: z.ZodNumber;
125
- /** User prompts observed in the transcript. */
126
- prompts: z.ZodNumber;
127
- /** Tool calls observed in the transcript. */
128
- toolCalls: z.ZodNumber;
129
- /**
130
- * Edit-tool (Write|Edit|MultiEdit|NotebookEdit) calls that completed —
131
- * their `tool_use` got a `tool_result` that is not a denial. Optional:
132
- * entries written by hooks ≤0.2.0 predate the field.
133
- */
134
- acc: z.ZodOptional<z.ZodNumber>;
135
- /**
136
- * Edit-tool calls denied before running: `tool_result` with
137
- * `is_error: true` carrying a user-rejection / permission-denial text
138
- * (or a `toolDenialKind` on the transcript line), plus edits killed by
139
- * an explicit `[Request interrupted by user for tool use]` marker.
140
- */
141
- rej: z.ZodOptional<z.ZodNumber>;
142
- /**
143
- * Active seconds: sum of consecutive transcript-timestamp gaps < 5 min
144
- * (gaps ≥ 5 min count as idle). Always ≤ durSec. Optional: entries
145
- * written by hooks ≤0.2.0 predate the field (consumers fall back to
146
- * durSec — the old `act = dur` behavior).
147
- */
148
- actSec: z.ZodOptional<z.ZodNumber>;
149
- /** Wall-clock seconds between the first and last transcript timestamps. */
150
- durSec: z.ZodNumber;
151
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
152
- /**
153
- * Which hook event produced this entry. `PreCommit` is the snapshot taken
154
- * on PreToolUse just before the agent runs `git commit`: without it a
155
- * commit made mid-session found no snapshot yet and shipped no trailer.
156
- */
157
- event: z.ZodEnum<["SessionEnd", "SubagentStop", "PreCommit"]>;
158
- /** Claude Code SessionEnd `reason` (e.g. `clear`, `logout`), if any. */
159
27
  reason: z.ZodOptional<z.ZodString>;
160
- /** Token counts summed over the transcript. */
161
28
  t: z.ZodObject<{
162
- /** input tokens */ i: z.ZodNumber;
163
- /** output tokens */ o: z.ZodNumber;
164
- /** cache-read tokens */ cr: z.ZodNumber;
165
- /** cache-write (creation) tokens */ cw: z.ZodNumber;
166
- }, "strict", z.ZodTypeAny, {
167
- i: number;
168
- o: number;
169
- cr: number;
170
- cw: number;
171
- }, {
172
- i: number;
173
- o: number;
174
- cr: number;
175
- cw: number;
176
- }>;
177
- /** Model mix, percent by short model tag (≤16 chars per tag). */
29
+ i: z.ZodNumber;
30
+ o: z.ZodNumber;
31
+ cr: z.ZodNumber;
32
+ cw: z.ZodNumber;
33
+ }, z.core.$strict>;
178
34
  m: z.ZodRecord<z.ZodString, z.ZodNumber>;
179
- /** Full id of the dominant model (for the Assisted-by trailer). */
180
35
  model: z.ZodOptional<z.ZodString>;
181
- /** Agent CLI at `name@version` (e.g. `claude-code@2.1.200`). */
182
36
  tool: z.ZodOptional<z.ZodString>;
183
- /** Estimated cost in integer cents (0 when the transcript has no costUSD). */
184
37
  usdCents: z.ZodNumber;
185
- /** User prompts observed in the transcript. */
186
38
  prompts: z.ZodNumber;
187
- /** Tool calls observed in the transcript. */
188
39
  toolCalls: z.ZodNumber;
189
- /**
190
- * Edit-tool (Write|Edit|MultiEdit|NotebookEdit) calls that completed —
191
- * their `tool_use` got a `tool_result` that is not a denial. Optional:
192
- * entries written by hooks ≤0.2.0 predate the field.
193
- */
194
40
  acc: z.ZodOptional<z.ZodNumber>;
195
- /**
196
- * Edit-tool calls denied before running: `tool_result` with
197
- * `is_error: true` carrying a user-rejection / permission-denial text
198
- * (or a `toolDenialKind` on the transcript line), plus edits killed by
199
- * an explicit `[Request interrupted by user for tool use]` marker.
200
- */
201
41
  rej: z.ZodOptional<z.ZodNumber>;
202
- /**
203
- * Active seconds: sum of consecutive transcript-timestamp gaps < 5 min
204
- * (gaps ≥ 5 min count as idle). Always ≤ durSec. Optional: entries
205
- * written by hooks ≤0.2.0 predate the field (consumers fall back to
206
- * durSec — the old `act = dur` behavior).
207
- */
208
42
  actSec: z.ZodOptional<z.ZodNumber>;
209
- /** Wall-clock seconds between the first and last transcript timestamps. */
210
43
  durSec: z.ZodNumber;
211
- }, z.ZodTypeAny, "passthrough">>;
44
+ }, z.core.$loose>;
212
45
  export type SessionEndData = z.infer<typeof sessionEndDataSchema>;
213
46
  /** Shorten a model id to a trailer-safe tag: strip `claude-`, date suffix, cap 16. */
214
47
  export declare function modelTag(modelId: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"metrics-schema.d.ts","sourceRoot":"","sources":["../src/metrics-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,iBAAiB;IAE1B,mBAAmB;IACnB,oBAAoB;IACpB,wBAAwB;IACxB,oCAAoC;;;;;;;;;;;EAE7B,CAAC;AAEZ,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,oBAAoB;IAE7B;;;;OAIG;;IAEH,wEAAwE;;IAExE,+CAA+C;;QAvB/C,mBAAmB;QACnB,oBAAoB;QACpB,wBAAwB;QACxB,oCAAoC;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AE5D;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;iBAmDjB,CAAC;AAEjB,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,sFAAsF;AACtF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMhD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invictus-group-ai/hooks",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Invictus AI hook engine: the hook set for Claude Code events plus the git-side commit-metrics encoder. Fail-open in-session; the fail-closed net is .githooks/ + CI.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -60,8 +60,8 @@
60
60
  "test": "vitest run"
61
61
  },
62
62
  "dependencies": {
63
- "@invictus-group-ai/core": "^0.7.0",
64
- "zod": "^3.24.1"
63
+ "@invictus-group-ai/core": "^0.7.1",
64
+ "zod": "^4.6.6"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/node": "^22.10.0",