@osfactory/otel-hook 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.
Files changed (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1020 -0
  3. package/dist/adapter-DIgRACtL.d.ts +303 -0
  4. package/dist/cli.js +12607 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/config.d.ts +233 -0
  7. package/dist/config.js +996 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/content-CoB7aNP1.d.ts +118 -0
  10. package/dist/diagnostics.d.ts +58 -0
  11. package/dist/diagnostics.js +46 -0
  12. package/dist/diagnostics.js.map +1 -0
  13. package/dist/errors.d.ts +91 -0
  14. package/dist/errors.js +322 -0
  15. package/dist/errors.js.map +1 -0
  16. package/dist/events-VxBnDFaO.d.ts +2044 -0
  17. package/dist/filesystem-store-J8jjDMTh.d.ts +65 -0
  18. package/dist/hook-CGpo-vks.d.ts +292 -0
  19. package/dist/identity-BrVBs901.d.ts +227 -0
  20. package/dist/index.d.ts +44 -0
  21. package/dist/index.js +11798 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/install.d.ts +1021 -0
  24. package/dist/install.js +3271 -0
  25. package/dist/install.js.map +1 -0
  26. package/dist/integration.d.ts +303 -0
  27. package/dist/integration.js +5942 -0
  28. package/dist/integration.js.map +1 -0
  29. package/dist/keys-Dej5bN3L.d.ts +7 -0
  30. package/dist/lifecycle.d.ts +428 -0
  31. package/dist/lifecycle.js +1077 -0
  32. package/dist/lifecycle.js.map +1 -0
  33. package/dist/memory-DXVBc8V9.d.ts +94 -0
  34. package/dist/model.d.ts +45 -0
  35. package/dist/model.js +1023 -0
  36. package/dist/model.js.map +1 -0
  37. package/dist/otlp-log-sink-CeIFDDpn.d.ts +457 -0
  38. package/dist/payload-CHr53E_v.d.ts +201 -0
  39. package/dist/policy-D1CrlYn3.d.ts +73 -0
  40. package/dist/ports-Q8x0ODhs.d.ts +200 -0
  41. package/dist/primitives-CJ8-rn-f.d.ts +75 -0
  42. package/dist/privacy.d.ts +51 -0
  43. package/dist/privacy.js +633 -0
  44. package/dist/privacy.js.map +1 -0
  45. package/dist/providers.d.ts +257 -0
  46. package/dist/providers.js +4398 -0
  47. package/dist/providers.js.map +1 -0
  48. package/dist/registry-BzYmC9OC.d.ts +49 -0
  49. package/dist/runtime.d.ts +32 -0
  50. package/dist/runtime.js +2907 -0
  51. package/dist/runtime.js.map +1 -0
  52. package/dist/schema-Cn0-xz8L.d.ts +224 -0
  53. package/dist/semconv-Baoz-0OI.d.ts +188 -0
  54. package/dist/service-j4jEO6cZ.d.ts +68 -0
  55. package/dist/state.d.ts +36 -0
  56. package/dist/state.js +710 -0
  57. package/dist/state.js.map +1 -0
  58. package/dist/taxonomy-DwhTtuWd.d.ts +87 -0
  59. package/dist/telemetry.d.ts +77 -0
  60. package/dist/telemetry.js +2294 -0
  61. package/dist/telemetry.js.map +1 -0
  62. package/dist/testing.d.ts +155 -0
  63. package/dist/testing.js +6513 -0
  64. package/dist/testing.js.map +1 -0
  65. package/package.json +124 -0
package/dist/model.js ADDED
@@ -0,0 +1,1023 @@
1
+ // src/model/version.ts
2
+ import { z } from "zod";
3
+ var CANONICAL_SCHEMA_VERSION = 1;
4
+ var canonicalSchemaVersionSchema = z.literal(CANONICAL_SCHEMA_VERSION);
5
+
6
+ // src/model/primitives.ts
7
+ import { z as z2 } from "zod";
8
+ var MAX_IDENTIFIER_LENGTH = 256;
9
+ var MAX_ATTRIBUTE_STRING_LENGTH = 4096;
10
+ var MAX_ATTRIBUTE_ARRAY_LENGTH = 128;
11
+ var nonEmptyStringSchema = z2.string().min(1).max(MAX_IDENTIFIER_LENGTH);
12
+ var epochMillisSchema = z2.number().int().min(0).max(864e13);
13
+ var durationMillisSchema = z2.number().min(0).finite();
14
+ var tokenCountSchema = z2.number().int().min(0);
15
+ var sequenceNumberSchema = z2.number().int().min(0);
16
+ var brandedIdSchema = () => z2.string().min(1).max(MAX_IDENTIFIER_LENGTH);
17
+ var invocationIdSchema = brandedIdSchema().brand();
18
+ var sessionIdSchema = brandedIdSchema().brand();
19
+ var eventIdSchema = brandedIdSchema().brand();
20
+ var WORKSPACE_ID_PATTERN = /^[a-z][a-z0-9]{0,15}:[A-Za-z0-9_-]{8,128}$/;
21
+ var workspaceIdSchema = z2.string().regex(WORKSPACE_ID_PATTERN, "workspace id must be an opaque `<scheme>:<token>` handle").brand();
22
+ var PROVIDER_ID_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
23
+ var providerIdSchema = z2.string().min(1).max(64).regex(PROVIDER_ID_PATTERN, "provider id must be lowercase and hyphenated").brand();
24
+ var UNKNOWN_PROVIDER_ID = "unknown";
25
+ var resolvedProviderIdSchema = z2.union([
26
+ providerIdSchema,
27
+ z2.literal(UNKNOWN_PROVIDER_ID)
28
+ ]);
29
+ var isUnknownProvider = (value) => value === UNKNOWN_PROVIDER_ID;
30
+ var attributePrimitiveSchema = z2.union([
31
+ z2.string().max(MAX_ATTRIBUTE_STRING_LENGTH),
32
+ z2.number().finite(),
33
+ z2.boolean()
34
+ ]);
35
+ var attributeValueSchema = z2.union([
36
+ attributePrimitiveSchema,
37
+ z2.array(attributePrimitiveSchema).max(MAX_ATTRIBUTE_ARRAY_LENGTH)
38
+ ]);
39
+ var attributesSchema = z2.record(z2.string().min(1).max(MAX_IDENTIFIER_LENGTH), attributeValueSchema);
40
+ var detectionConfidenceSchema = z2.enum(["none", "weak", "strong", "exact"]);
41
+ var DETECTION_CONFIDENCE_RANK = Object.freeze({
42
+ none: 0,
43
+ weak: 1,
44
+ strong: 2,
45
+ exact: 3
46
+ });
47
+ var compareDetectionConfidence = (a, b) => DETECTION_CONFIDENCE_RANK[a] - DETECTION_CONFIDENCE_RANK[b];
48
+ var sourceTransportSchema = z2.enum([
49
+ "hook-stdin",
50
+ "cli-argument",
51
+ "library-call",
52
+ "test-fixture"
53
+ ]);
54
+
55
+ // src/model/extensions.ts
56
+ import { z as z3 } from "zod";
57
+ var EXTENSION_KEY_PATTERN = /^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*(?:\.[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*)+$/;
58
+ var RESERVED_EXTENSION_NAMESPACES = Object.freeze([
59
+ "otelhook",
60
+ "otel",
61
+ "telemetry"
62
+ ]);
63
+ var MAX_EXTENSION_ENTRIES = 64;
64
+ var extensionKeyNamespace = (key) => key.slice(0, key.indexOf("."));
65
+ var isReservedExtensionNamespace = (key) => RESERVED_EXTENSION_NAMESPACES.includes(extensionKeyNamespace(key));
66
+ var isValidExtensionKey = (key) => EXTENSION_KEY_PATTERN.test(key) && !isReservedExtensionNamespace(key);
67
+ var extensionsSchema = z3.record(z3.string(), attributeValueSchema).check((ctx) => {
68
+ const keys = Object.keys(ctx.value);
69
+ if (keys.length > MAX_EXTENSION_ENTRIES) {
70
+ ctx.issues.push({
71
+ code: "custom",
72
+ input: ctx.value,
73
+ message: `extensions may contain at most ${MAX_EXTENSION_ENTRIES} entries`
74
+ });
75
+ }
76
+ for (const key of keys) {
77
+ if (!EXTENSION_KEY_PATTERN.test(key)) {
78
+ ctx.issues.push({
79
+ code: "custom",
80
+ input: ctx.value,
81
+ path: [key],
82
+ message: `extension key ${JSON.stringify(key)} must be namespaced, e.g. "acme.tier"`
83
+ });
84
+ continue;
85
+ }
86
+ if (isReservedExtensionNamespace(key)) {
87
+ ctx.issues.push({
88
+ code: "custom",
89
+ input: ctx.value,
90
+ path: [key],
91
+ message: `extension namespace ${JSON.stringify(extensionKeyNamespace(key))} is reserved`
92
+ });
93
+ }
94
+ }
95
+ });
96
+ var EMPTY_EXTENSIONS = Object.freeze({});
97
+ var emptyExtensions = () => ({});
98
+
99
+ // src/model/content.ts
100
+ import { z as z4 } from "zod";
101
+ var contentKindSchema = z4.enum([
102
+ "prompt",
103
+ "response",
104
+ "reasoning",
105
+ "tool-input",
106
+ "tool-output",
107
+ "error-message",
108
+ "system-instruction",
109
+ "attachment"
110
+ ]);
111
+ var contentRoleSchema = z4.enum(["user", "assistant", "system", "tool", "unknown"]);
112
+ var contentDisclosureSchema = z4.enum(["omitted", "masked", "redacted", "raw"]);
113
+ var CONTENT_HASH_PATTERN = /^sha256:[0-9a-f]{64}$/;
114
+ var contentFactSchema = z4.strictObject({
115
+ kind: contentKindSchema,
116
+ role: contentRoleSchema.optional(),
117
+ /** Unicode code point count of the original content. */
118
+ characterLength: z4.number().int().min(0),
119
+ /** UTF-8 byte length of the original content. */
120
+ byteLength: z4.number().int().min(0),
121
+ /** Stable salted digest of the original content. */
122
+ contentHash: z4.string().regex(CONTENT_HASH_PATTERN),
123
+ disclosure: contentDisclosureSchema,
124
+ /** Disclosed text, bounded by the privacy policy. Absent when omitted. */
125
+ text: z4.string().optional(),
126
+ /** True when `text` was cut short by the configured string bound. */
127
+ truncated: z4.boolean(),
128
+ /** Number of secret-looking spans replaced while producing `text`. */
129
+ secretsRedacted: z4.number().int().min(0),
130
+ /** Optional non-sensitive label, e.g. a MIME type or tool name. */
131
+ label: nonEmptyStringSchema.optional()
132
+ });
133
+ var contentFactsSchema = z4.array(contentFactSchema).max(64);
134
+ var isContentFactConsistent = (fact) => fact.disclosure === "omitted" ? fact.text === void 0 : fact.text !== void 0;
135
+
136
+ // src/model/usage.ts
137
+ import { z as z5 } from "zod";
138
+ var usageTemporalitySchema = z5.enum(["delta", "cumulative"]);
139
+ var cacheCreationAccountingSchema = z5.enum([
140
+ "included-in-input",
141
+ "disjoint-from-input",
142
+ "not-reported"
143
+ ]);
144
+ var providerTotalAgreementSchema = z5.enum(["unreported", "agrees", "disagrees"]);
145
+ var usageReportSchema = z5.strictObject({
146
+ temporality: usageTemporalitySchema,
147
+ /** Inclusive input tokens. */
148
+ inputTokens: tokenCountSchema.optional(),
149
+ /** Subset of `inputTokens` served from a prompt cache. */
150
+ cachedInputTokens: tokenCountSchema.optional(),
151
+ /** Tokens written to a prompt cache. */
152
+ cacheCreationInputTokens: tokenCountSchema.optional(),
153
+ /** Required when `cacheCreationInputTokens` is present and non-zero. */
154
+ cacheCreationAccounting: cacheCreationAccountingSchema.optional(),
155
+ /** Inclusive output tokens. */
156
+ outputTokens: tokenCountSchema.optional(),
157
+ /** Subset of `outputTokens` spent on reasoning. */
158
+ reasoningOutputTokens: tokenCountSchema.optional(),
159
+ /** Total exactly as the provider reported it, if it reported one. */
160
+ providerTotalTokens: tokenCountSchema.optional()
161
+ });
162
+ var canonicalUsageSchema = z5.strictObject({
163
+ temporality: usageTemporalitySchema,
164
+ inputTokens: tokenCountSchema,
165
+ cachedInputTokens: tokenCountSchema,
166
+ cacheCreationInputTokens: tokenCountSchema,
167
+ cacheCreationAccounting: cacheCreationAccountingSchema,
168
+ outputTokens: tokenCountSchema,
169
+ reasoningOutputTokens: tokenCountSchema,
170
+ /** Derived: input tokens that were neither cache reads nor cache writes. */
171
+ uncachedInputTokens: tokenCountSchema,
172
+ /** Derived: canonical billable total. */
173
+ totalTokens: tokenCountSchema,
174
+ providerTotalTokens: tokenCountSchema.optional(),
175
+ providerTotalAgreement: providerTotalAgreementSchema
176
+ }).check((ctx) => {
177
+ const usage = ctx.value;
178
+ const push = (message) => {
179
+ ctx.issues.push({ code: "custom", input: usage, message });
180
+ };
181
+ if (usage.cachedInputTokens > usage.inputTokens) {
182
+ push("cachedInputTokens must not exceed inputTokens (it is a subset)");
183
+ }
184
+ if (usage.reasoningOutputTokens > usage.outputTokens) {
185
+ push("reasoningOutputTokens must not exceed outputTokens (it is a subset)");
186
+ }
187
+ if (usage.cacheCreationAccounting === "not-reported" && usage.cacheCreationInputTokens !== 0) {
188
+ push("cacheCreationInputTokens must be 0 when cacheCreationAccounting is not-reported");
189
+ }
190
+ const creationInsideInput = usage.cacheCreationAccounting === "included-in-input" ? usage.cacheCreationInputTokens : 0;
191
+ if (usage.cachedInputTokens + creationInsideInput > usage.inputTokens) {
192
+ push(
193
+ "cachedInputTokens + cacheCreationInputTokens must not exceed inputTokens when cache creation is included in input"
194
+ );
195
+ }
196
+ const expectedUncached = usage.inputTokens - usage.cachedInputTokens - creationInsideInput;
197
+ if (expectedUncached >= 0 && usage.uncachedInputTokens !== expectedUncached) {
198
+ push(`uncachedInputTokens must equal ${expectedUncached}`);
199
+ }
200
+ const creationOutsideInput = usage.cacheCreationAccounting === "disjoint-from-input" ? usage.cacheCreationInputTokens : 0;
201
+ const expectedTotal = usage.inputTokens + creationOutsideInput + usage.outputTokens;
202
+ if (usage.totalTokens !== expectedTotal) {
203
+ push(`totalTokens must equal ${expectedTotal}`);
204
+ }
205
+ const expectedAgreement = usage.providerTotalTokens === void 0 ? "unreported" : usage.providerTotalTokens === expectedTotal ? "agrees" : "disagrees";
206
+ if (usage.providerTotalAgreement !== expectedAgreement) {
207
+ push(`providerTotalAgreement must be ${expectedAgreement}`);
208
+ }
209
+ });
210
+ var normalizeUsage = (report) => {
211
+ const parsed = usageReportSchema.safeParse(report);
212
+ if (!parsed.success) {
213
+ return {
214
+ status: "invalid",
215
+ issues: parsed.error.issues.map((issue) => ({
216
+ code: "invalid-report",
217
+ message: `${issue.path.join(".") || "<root>"}: ${issue.message}`
218
+ }))
219
+ };
220
+ }
221
+ const input = parsed.data;
222
+ const issues = [];
223
+ const notes = [];
224
+ const inputTokens = input.inputTokens ?? 0;
225
+ const cachedInputTokens = input.cachedInputTokens ?? 0;
226
+ const cacheCreationInputTokens = input.cacheCreationInputTokens ?? 0;
227
+ const outputTokens = input.outputTokens ?? 0;
228
+ const reasoningOutputTokens = input.reasoningOutputTokens ?? 0;
229
+ let accounting;
230
+ if (cacheCreationInputTokens === 0) {
231
+ accounting = input.cacheCreationAccounting ?? "not-reported";
232
+ if (accounting !== "not-reported") {
233
+ notes.push(
234
+ `cacheCreationAccounting=${accounting} retained with zero cache-creation tokens`
235
+ );
236
+ }
237
+ } else if (input.cacheCreationAccounting === void 0) {
238
+ issues.push({
239
+ code: "cache-creation-accounting-missing",
240
+ message: "cacheCreationAccounting is required when cacheCreationInputTokens is non-zero; it cannot be inferred"
241
+ });
242
+ accounting = "not-reported";
243
+ } else if (input.cacheCreationAccounting === "not-reported") {
244
+ issues.push({
245
+ code: "cache-creation-accounting-missing",
246
+ message: "cacheCreationAccounting=not-reported conflicts with non-zero cacheCreationInputTokens"
247
+ });
248
+ accounting = "not-reported";
249
+ } else {
250
+ accounting = input.cacheCreationAccounting;
251
+ }
252
+ if (cachedInputTokens > inputTokens) {
253
+ issues.push({
254
+ code: "cached-exceeds-input",
255
+ message: `cachedInputTokens (${cachedInputTokens}) exceeds inclusive inputTokens (${inputTokens})`
256
+ });
257
+ }
258
+ if (reasoningOutputTokens > outputTokens) {
259
+ issues.push({
260
+ code: "reasoning-exceeds-output",
261
+ message: `reasoningOutputTokens (${reasoningOutputTokens}) exceeds inclusive outputTokens (${outputTokens})`
262
+ });
263
+ }
264
+ const creationInsideInput = accounting === "included-in-input" ? cacheCreationInputTokens : 0;
265
+ if (cachedInputTokens + creationInsideInput > inputTokens) {
266
+ issues.push({
267
+ code: "cache-creation-exceeds-input",
268
+ message: `cachedInputTokens + cacheCreationInputTokens (${cachedInputTokens + creationInsideInput}) exceeds inclusive inputTokens (${inputTokens})`
269
+ });
270
+ }
271
+ if (issues.length > 0) {
272
+ return { status: "invalid", issues };
273
+ }
274
+ const creationOutsideInput = accounting === "disjoint-from-input" ? cacheCreationInputTokens : 0;
275
+ const totalTokens = inputTokens + creationOutsideInput + outputTokens;
276
+ const providerTotalAgreement = input.providerTotalTokens === void 0 ? "unreported" : input.providerTotalTokens === totalTokens ? "agrees" : "disagrees";
277
+ if (providerTotalAgreement === "disagrees") {
278
+ notes.push(
279
+ `providerTotalTokens (${input.providerTotalTokens ?? 0}) disagrees with canonical total (${totalTokens}); both retained`
280
+ );
281
+ }
282
+ const usage = {
283
+ temporality: input.temporality,
284
+ inputTokens,
285
+ cachedInputTokens,
286
+ cacheCreationInputTokens,
287
+ cacheCreationAccounting: accounting,
288
+ outputTokens,
289
+ reasoningOutputTokens,
290
+ uncachedInputTokens: inputTokens - cachedInputTokens - creationInsideInput,
291
+ totalTokens,
292
+ ...input.providerTotalTokens === void 0 ? {} : { providerTotalTokens: input.providerTotalTokens },
293
+ providerTotalAgreement
294
+ };
295
+ return { status: "ok", usage, notes };
296
+ };
297
+ var UsageNormalizationError = class extends Error {
298
+ issues;
299
+ constructor(issues) {
300
+ super(`invalid usage report: ${issues.map((issue) => issue.message).join("; ")}`);
301
+ this.name = "UsageNormalizationError";
302
+ this.issues = issues;
303
+ }
304
+ };
305
+ var normalizeUsageOrThrow = (report) => {
306
+ const result = normalizeUsage(report);
307
+ if (result.status === "invalid") {
308
+ throw new UsageNormalizationError(result.issues);
309
+ }
310
+ return result.usage;
311
+ };
312
+ var EMPTY_DELTA_USAGE = Object.freeze(
313
+ normalizeUsageOrThrow({ temporality: "delta" })
314
+ );
315
+ var requireCumulative = (usage, label) => {
316
+ if (usage.temporality !== "cumulative") {
317
+ throw new UsageNormalizationError([
318
+ { code: "invalid-report", message: `${label} must have cumulative temporality` }
319
+ ]);
320
+ }
321
+ };
322
+ var cumulativeToDelta = (previous, current) => {
323
+ requireCumulative(previous, "previous usage");
324
+ requireCumulative(current, "current usage");
325
+ if (previous.cacheCreationAccounting !== current.cacheCreationAccounting && previous.cacheCreationInputTokens !== 0 && current.cacheCreationInputTokens !== 0) {
326
+ throw new UsageNormalizationError([
327
+ {
328
+ code: "cache-creation-accounting-missing",
329
+ message: "cannot diff cumulative usage across differing cacheCreationAccounting modes"
330
+ }
331
+ ]);
332
+ }
333
+ const resetDetected = current.inputTokens < previous.inputTokens || current.cachedInputTokens < previous.cachedInputTokens || current.cacheCreationInputTokens < previous.cacheCreationInputTokens || current.outputTokens < previous.outputTokens || current.reasoningOutputTokens < previous.reasoningOutputTokens;
334
+ if (resetDetected) {
335
+ return {
336
+ usage: normalizeUsageOrThrow({ ...toReport(current), temporality: "delta" }),
337
+ resetDetected: true
338
+ };
339
+ }
340
+ const usage = normalizeUsageOrThrow({
341
+ temporality: "delta",
342
+ inputTokens: current.inputTokens - previous.inputTokens,
343
+ cachedInputTokens: current.cachedInputTokens - previous.cachedInputTokens,
344
+ cacheCreationInputTokens: current.cacheCreationInputTokens - previous.cacheCreationInputTokens,
345
+ cacheCreationAccounting: current.cacheCreationAccounting,
346
+ outputTokens: current.outputTokens - previous.outputTokens,
347
+ reasoningOutputTokens: current.reasoningOutputTokens - previous.reasoningOutputTokens
348
+ });
349
+ return { usage, resetDetected: false };
350
+ };
351
+ var toReport = (usage) => ({
352
+ temporality: usage.temporality,
353
+ inputTokens: usage.inputTokens,
354
+ cachedInputTokens: usage.cachedInputTokens,
355
+ cacheCreationInputTokens: usage.cacheCreationInputTokens,
356
+ cacheCreationAccounting: usage.cacheCreationAccounting,
357
+ outputTokens: usage.outputTokens,
358
+ reasoningOutputTokens: usage.reasoningOutputTokens,
359
+ ...usage.providerTotalTokens === void 0 ? {} : { providerTotalTokens: usage.providerTotalTokens }
360
+ });
361
+ var addUsage = (a, b) => {
362
+ if (a.temporality !== "delta" || b.temporality !== "delta") {
363
+ throw new UsageNormalizationError([
364
+ { code: "invalid-report", message: "only delta usage may be summed" }
365
+ ]);
366
+ }
367
+ const accounting = a.cacheCreationInputTokens === 0 && a.cacheCreationAccounting === "not-reported" ? b.cacheCreationAccounting : b.cacheCreationInputTokens === 0 && b.cacheCreationAccounting === "not-reported" ? a.cacheCreationAccounting : a.cacheCreationAccounting;
368
+ if (a.cacheCreationInputTokens !== 0 && b.cacheCreationInputTokens !== 0 && a.cacheCreationAccounting !== b.cacheCreationAccounting) {
369
+ throw new UsageNormalizationError([
370
+ {
371
+ code: "cache-creation-accounting-missing",
372
+ message: "cannot sum usage across differing cacheCreationAccounting modes"
373
+ }
374
+ ]);
375
+ }
376
+ const providerTotal = a.providerTotalTokens === void 0 && b.providerTotalTokens === void 0 ? void 0 : (a.providerTotalTokens ?? 0) + (b.providerTotalTokens ?? 0);
377
+ return normalizeUsageOrThrow({
378
+ temporality: "delta",
379
+ inputTokens: a.inputTokens + b.inputTokens,
380
+ cachedInputTokens: a.cachedInputTokens + b.cachedInputTokens,
381
+ cacheCreationInputTokens: a.cacheCreationInputTokens + b.cacheCreationInputTokens,
382
+ cacheCreationAccounting: accounting,
383
+ outputTokens: a.outputTokens + b.outputTokens,
384
+ reasoningOutputTokens: a.reasoningOutputTokens + b.reasoningOutputTokens,
385
+ ...providerTotal === void 0 ? {} : { providerTotalTokens: providerTotal }
386
+ });
387
+ };
388
+
389
+ // src/model/identity.ts
390
+ import { z as z6 } from "zod";
391
+ var workspaceKeySourceSchema = z6.enum([
392
+ "git-remote",
393
+ "git-root",
394
+ "working-directory",
395
+ "explicit",
396
+ "unknown"
397
+ ]);
398
+ var workspaceIdentitySchema = z6.strictObject({
399
+ workspaceId: workspaceIdSchema,
400
+ keySource: workspaceKeySourceSchema,
401
+ /** Repository name only; never an owner path or URL with credentials. */
402
+ repositoryName: nonEmptyStringSchema.optional(),
403
+ vcsBranchName: nonEmptyStringSchema.optional(),
404
+ /** Opaque handle for the checked-out revision. */
405
+ vcsRevisionId: nonEmptyStringSchema.optional()
406
+ }).readonly();
407
+ var UNKNOWN_WORKSPACE_ID = "unknown:0000000000000000";
408
+ var unknownWorkspaceIdentity = () => workspaceIdentitySchema.parse({
409
+ workspaceId: UNKNOWN_WORKSPACE_ID,
410
+ keySource: "unknown"
411
+ });
412
+ var sourceProvenanceSchema = z6.strictObject({
413
+ providerId: resolvedProviderIdSchema,
414
+ providerVersion: nonEmptyStringSchema.optional(),
415
+ adapterId: nonEmptyStringSchema,
416
+ adapterVersion: nonEmptyStringSchema,
417
+ detectionConfidence: detectionConfidenceSchema,
418
+ /** The provider's own name for the source event, e.g. a hook event name. */
419
+ sourceEventName: nonEmptyStringSchema.optional(),
420
+ transport: sourceTransportSchema
421
+ }).readonly();
422
+ var consumerAttributesSchema = attributesSchema.readonly();
423
+ var invocationIdentitySchema = z6.strictObject({
424
+ invocationId: invocationIdSchema,
425
+ sessionId: sessionIdSchema,
426
+ /** Set when this invocation runs beneath another agent invocation. */
427
+ parentInvocationId: invocationIdSchema.optional(),
428
+ /** Root of the session tree when the provider exposes one. */
429
+ rootSessionId: sessionIdSchema.optional(),
430
+ /** Stable handle for the agent process/instance, when available. */
431
+ agentInstanceId: nonEmptyStringSchema.optional(),
432
+ provenance: sourceProvenanceSchema,
433
+ workspace: workspaceIdentitySchema,
434
+ startedAt: epochMillisSchema,
435
+ consumerAttributes: consumerAttributesSchema
436
+ }).readonly();
437
+ var identityClaimFieldsSchema = z6.strictObject({
438
+ invocationId: invocationIdSchema.optional(),
439
+ sessionId: sessionIdSchema.optional(),
440
+ parentInvocationId: invocationIdSchema.optional(),
441
+ rootSessionId: sessionIdSchema.optional(),
442
+ agentInstanceId: nonEmptyStringSchema.optional(),
443
+ workspace: workspaceIdentitySchema.optional(),
444
+ startedAt: epochMillisSchema.optional()
445
+ });
446
+ var identityClaimSchema = z6.strictObject({
447
+ /** Non-sensitive label, e.g. `adapter:acme-cli` or `env:OTEL_HOOK_SESSION_ID`. */
448
+ source: nonEmptyStringSchema,
449
+ confidence: detectionConfidenceSchema,
450
+ fields: identityClaimFieldsSchema
451
+ });
452
+ var CLAIM_FIELDS = [
453
+ "invocationId",
454
+ "sessionId",
455
+ "parentInvocationId",
456
+ "rootSessionId",
457
+ "agentInstanceId",
458
+ "workspace",
459
+ "startedAt"
460
+ ];
461
+ var renderClaimValue = (value) => {
462
+ if (typeof value === "string") {
463
+ return value;
464
+ }
465
+ if (typeof value === "number" || typeof value === "boolean") {
466
+ return String(value);
467
+ }
468
+ if (value !== null && typeof value === "object" && "workspaceId" in value) {
469
+ const { workspaceId } = value;
470
+ return typeof workspaceId === "string" ? workspaceId : "<workspace>";
471
+ }
472
+ return "<opaque>";
473
+ };
474
+ var resolveInvocationIdentity = (input) => {
475
+ const parsedClaims = [];
476
+ const issues = [];
477
+ for (const [index, claim] of input.claims.entries()) {
478
+ const parsed2 = identityClaimSchema.safeParse(claim);
479
+ if (parsed2.success) {
480
+ parsedClaims.push(parsed2.data);
481
+ } else {
482
+ issues.push(
483
+ `claim[${index}]: ${parsed2.error.issues.map((issue) => `${issue.path.join(".") || "<root>"} ${issue.message}`).join(", ")}`
484
+ );
485
+ }
486
+ }
487
+ if (issues.length > 0) {
488
+ return { status: "invalid", issues };
489
+ }
490
+ const conflicts = [];
491
+ const selected = {};
492
+ for (const field of CLAIM_FIELDS) {
493
+ const contributors = parsedClaims.filter((claim) => claim.fields[field] !== void 0);
494
+ if (contributors.length === 0) {
495
+ continue;
496
+ }
497
+ const bestRank = Math.max(
498
+ ...contributors.map((claim) => DETECTION_CONFIDENCE_RANK[claim.confidence])
499
+ );
500
+ const best = contributors.filter(
501
+ (claim) => DETECTION_CONFIDENCE_RANK[claim.confidence] === bestRank
502
+ );
503
+ const rendered = /* @__PURE__ */ new Map();
504
+ for (const claim of best) {
505
+ const key = JSON.stringify(claim.fields[field]);
506
+ const sources = rendered.get(key) ?? [];
507
+ sources.push(claim.source);
508
+ rendered.set(key, sources);
509
+ }
510
+ if (rendered.size > 1) {
511
+ const [firstBest] = best;
512
+ conflicts.push({
513
+ field,
514
+ confidence: firstBest?.confidence ?? "none",
515
+ values: best.map((claim) => renderClaimValue(claim.fields[field])),
516
+ sources: best.map((claim) => claim.source)
517
+ });
518
+ continue;
519
+ }
520
+ const [winner] = best;
521
+ if (winner !== void 0) {
522
+ selected[field] = winner.fields[field];
523
+ }
524
+ }
525
+ if (conflicts.length > 0) {
526
+ return { status: "conflict", conflicts };
527
+ }
528
+ const missing = [];
529
+ if (selected.invocationId === void 0) {
530
+ missing.push("invocationId");
531
+ }
532
+ if (selected.sessionId === void 0) {
533
+ missing.push("sessionId");
534
+ }
535
+ if (missing.length > 0) {
536
+ return { status: "incomplete", missing };
537
+ }
538
+ const startedAt = selected.startedAt ?? input.fallback?.startedAt;
539
+ if (startedAt === void 0) {
540
+ return { status: "incomplete", missing: ["startedAt"] };
541
+ }
542
+ const workspace = selected.workspace ?? input.fallback?.workspace ?? unknownWorkspaceIdentity();
543
+ const candidate = {
544
+ invocationId: selected.invocationId,
545
+ sessionId: selected.sessionId,
546
+ ...selected.parentInvocationId === void 0 ? {} : { parentInvocationId: selected.parentInvocationId },
547
+ ...selected.rootSessionId === void 0 ? {} : { rootSessionId: selected.rootSessionId },
548
+ ...selected.agentInstanceId === void 0 ? {} : { agentInstanceId: selected.agentInstanceId },
549
+ provenance: input.provenance,
550
+ workspace,
551
+ startedAt,
552
+ consumerAttributes: input.consumerAttributes ?? {}
553
+ };
554
+ const parsed = invocationIdentitySchema.safeParse(candidate);
555
+ if (!parsed.success) {
556
+ return {
557
+ status: "invalid",
558
+ issues: parsed.error.issues.map(
559
+ (issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`
560
+ )
561
+ };
562
+ }
563
+ return { status: "resolved", identity: parsed.data };
564
+ };
565
+
566
+ // src/model/events.ts
567
+ import { z as z8 } from "zod";
568
+
569
+ // src/errors/taxonomy.ts
570
+ import { z as z7 } from "zod";
571
+ var otelHookErrorCodeSchema = z7.enum([
572
+ /** Input was not usable at all (empty stdin, unparsable JSON). */
573
+ "invalid-input",
574
+ /** Input parsed but failed canonical schema validation. */
575
+ "schema-validation-failed",
576
+ /** No adapter claimed the input with sufficient confidence. */
577
+ "provider-unknown",
578
+ /** Several adapters claimed the input at the same confidence. */
579
+ "provider-detection-ambiguous",
580
+ /** An adapter threw or returned a malformed result. */
581
+ "provider-adapter-failure",
582
+ /** Two identity claims disagreed at equal confidence. */
583
+ "identity-conflict",
584
+ /** Required identity fields were absent. */
585
+ "identity-incomplete",
586
+ /** A usage report violated the canonical usage invariants. */
587
+ "usage-invalid",
588
+ /** The state store could not be read or written. */
589
+ "state-store-failure",
590
+ /** The telemetry sink rejected or could not deliver a batch. */
591
+ "telemetry-export-failure",
592
+ /** Content reached the sink boundary in a state the policy forbids. */
593
+ "privacy-policy-violation",
594
+ /** Configuration could not be resolved. */
595
+ "configuration-invalid",
596
+ /** A configured bound (events, batch size) dropped data. */
597
+ "limit-exceeded",
598
+ /**
599
+ * No replay-stable delivery identifier was available for a callback while
600
+ * deduplication was required.
601
+ */
602
+ "delivery-identifier-unavailable",
603
+ "delivery-claim-superseded",
604
+ /** Anything unanticipated. Always reported, never fatal to the host. */
605
+ "internal-error"
606
+ ]);
607
+ var errorSeveritySchema = z7.enum(["warning", "error"]);
608
+ var errorPhaseSchema = z7.enum([
609
+ "configuration",
610
+ "detection",
611
+ "identity",
612
+ "parsing",
613
+ "normalization",
614
+ "privacy",
615
+ "state",
616
+ "export",
617
+ "shutdown"
618
+ ]);
619
+ var failurePostureSchema = z7.enum(["fail-open", "fail-closed-attribution"]);
620
+ var ERROR_TAXONOMY = Object.freeze({
621
+ "invalid-input": {
622
+ code: "invalid-input",
623
+ severity: "warning",
624
+ posture: "fail-open",
625
+ retryable: false,
626
+ summary: "Input could not be read or decoded."
627
+ },
628
+ "schema-validation-failed": {
629
+ code: "schema-validation-failed",
630
+ severity: "error",
631
+ posture: "fail-closed-attribution",
632
+ retryable: false,
633
+ summary: "A canonical event failed schema validation and was dropped."
634
+ },
635
+ "provider-unknown": {
636
+ code: "provider-unknown",
637
+ severity: "warning",
638
+ posture: "fail-closed-attribution",
639
+ retryable: false,
640
+ summary: "No adapter recognized the source provider; the input stays unattributed."
641
+ },
642
+ "provider-detection-ambiguous": {
643
+ code: "provider-detection-ambiguous",
644
+ severity: "warning",
645
+ posture: "fail-closed-attribution",
646
+ retryable: false,
647
+ summary: "Multiple adapters claimed the input at equal confidence."
648
+ },
649
+ "provider-adapter-failure": {
650
+ code: "provider-adapter-failure",
651
+ severity: "error",
652
+ posture: "fail-open",
653
+ retryable: false,
654
+ summary: "A provider adapter failed while parsing."
655
+ },
656
+ "identity-conflict": {
657
+ code: "identity-conflict",
658
+ severity: "error",
659
+ posture: "fail-closed-attribution",
660
+ retryable: false,
661
+ summary: "Identity claims disagreed; attribution was declined."
662
+ },
663
+ "identity-incomplete": {
664
+ code: "identity-incomplete",
665
+ severity: "warning",
666
+ posture: "fail-closed-attribution",
667
+ retryable: false,
668
+ summary: "Required identity fields were missing; attribution was declined."
669
+ },
670
+ "usage-invalid": {
671
+ code: "usage-invalid",
672
+ severity: "error",
673
+ posture: "fail-open",
674
+ retryable: false,
675
+ summary: "A usage report violated the canonical usage invariants."
676
+ },
677
+ "state-store-failure": {
678
+ code: "state-store-failure",
679
+ severity: "warning",
680
+ posture: "fail-open",
681
+ retryable: true,
682
+ summary: "State could not be read or written; derived values may be incomplete."
683
+ },
684
+ "telemetry-export-failure": {
685
+ code: "telemetry-export-failure",
686
+ severity: "warning",
687
+ posture: "fail-open",
688
+ retryable: true,
689
+ summary: "The telemetry sink could not accept a batch."
690
+ },
691
+ "privacy-policy-violation": {
692
+ code: "privacy-policy-violation",
693
+ severity: "error",
694
+ posture: "fail-closed-attribution",
695
+ retryable: false,
696
+ summary: "Content violated the resolved privacy policy and was dropped."
697
+ },
698
+ "configuration-invalid": {
699
+ code: "configuration-invalid",
700
+ severity: "error",
701
+ posture: "fail-open",
702
+ retryable: false,
703
+ summary: "Configuration could not be resolved; defaults apply."
704
+ },
705
+ "limit-exceeded": {
706
+ code: "limit-exceeded",
707
+ severity: "warning",
708
+ posture: "fail-open",
709
+ retryable: false,
710
+ summary: "A configured bound was reached and data was dropped."
711
+ },
712
+ "delivery-identifier-unavailable": {
713
+ code: "delivery-identifier-unavailable",
714
+ severity: "warning",
715
+ // Fail-open: the observation is still attributed and exported. Only the
716
+ // at-most-once guarantee is missing, and refusing the telemetry to protect
717
+ // a duplicate count would trade a certain loss for a possible one.
718
+ posture: "fail-open",
719
+ retryable: false,
720
+ summary: "No replay-stable delivery identifier was available; this callback was exported without deduplication."
721
+ },
722
+ "delivery-claim-superseded": {
723
+ code: "delivery-claim-superseded",
724
+ severity: "warning",
725
+ // Fail-open, and specifically *not* silent. A peer reclaimed this callback's
726
+ // claim while this process was still working on it, which means the
727
+ // configured stale window is shorter than this installation's real worst
728
+ // case. Both processes may now have exported the callback, so the
729
+ // at-most-once guarantee did not hold for it — the only honest response is
730
+ // to say so and let the operator raise the window.
731
+ posture: "fail-open",
732
+ retryable: false,
733
+ summary: "A delivery claim was reclaimed by another process before this one committed; the callback may have been exported twice."
734
+ },
735
+ "internal-error": {
736
+ code: "internal-error",
737
+ severity: "error",
738
+ posture: "fail-open",
739
+ retryable: false,
740
+ summary: "An unexpected failure was contained."
741
+ }
742
+ });
743
+ var attributionOutcomeSchema = z7.enum([
744
+ /** Identity resolved; events carry provider and session identity. */
745
+ "attributed",
746
+ /** Identity could not be established safely; nothing was attributed. */
747
+ "declined",
748
+ /** Attribution was attempted and failed unexpectedly. */
749
+ "failed",
750
+ /** Input was recognized but intentionally carried no telemetry. */
751
+ "not-applicable"
752
+ ]);
753
+ var attributionReasonSchema = z7.enum([
754
+ "provider-unknown",
755
+ "provider-detection-ambiguous",
756
+ "identity-conflict",
757
+ "identity-incomplete",
758
+ "adapter-ignored-input",
759
+ "adapter-failure",
760
+ "invalid-input",
761
+ "internal-error"
762
+ ]);
763
+
764
+ // src/model/events.ts
765
+ var modelDescriptorSchema = z8.strictObject({
766
+ modelId: nonEmptyStringSchema,
767
+ /** Vendor of the model, e.g. `anthropic`. Distinct from the agent provider. */
768
+ vendor: nonEmptyStringSchema.optional(),
769
+ family: nonEmptyStringSchema.optional()
770
+ });
771
+ var costFactsSchema = z8.strictObject({
772
+ /** ISO 4217 code. */
773
+ currency: z8.string().length(3),
774
+ amount: z8.number().min(0).finite(),
775
+ source: z8.enum(["provider-reported", "computed"])
776
+ });
777
+ var canonicalEventTypeSchema = z8.enum([
778
+ "session.start",
779
+ "session.end",
780
+ "prompt.submitted",
781
+ "generation.start",
782
+ "generation.end",
783
+ "tool.start",
784
+ "tool.end",
785
+ "subagent.start",
786
+ "subagent.end",
787
+ "compaction.performed",
788
+ "error.raised"
789
+ ]);
790
+ var CANONICAL_EVENT_TYPES = canonicalEventTypeSchema.options;
791
+ var outcomeSchema = z8.enum(["ok", "error", "cancelled", "timeout", "denied", "unknown"]);
792
+ var baseEventFields = {
793
+ schemaVersion: canonicalSchemaVersionSchema,
794
+ eventId: eventIdSchema,
795
+ invocationId: invocationIdSchema,
796
+ sessionId: sessionIdSchema,
797
+ /** Per-invocation ordering key. Stable across replays of the same input. */
798
+ sequence: sequenceNumberSchema,
799
+ occurredAt: epochMillisSchema,
800
+ provenance: sourceProvenanceSchema,
801
+ workspace: workspaceIdentitySchema,
802
+ extensions: extensionsSchema.default(emptyExtensions)
803
+ };
804
+ var event = (shape) => z8.strictObject({ ...baseEventFields, ...shape });
805
+ var sessionStartEventSchema = event({
806
+ type: z8.literal("session.start"),
807
+ sessionKind: z8.enum(["interactive", "non-interactive", "unknown"]),
808
+ agentName: nonEmptyStringSchema.optional(),
809
+ agentVersion: nonEmptyStringSchema.optional(),
810
+ model: modelDescriptorSchema.optional()
811
+ });
812
+ var sessionEndEventSchema = event({
813
+ type: z8.literal("session.end"),
814
+ reason: z8.enum(["completed", "aborted", "error", "timeout", "unknown"]),
815
+ durationMillis: durationMillisSchema.optional(),
816
+ /** Session totals, typically cumulative. */
817
+ usage: canonicalUsageSchema.optional(),
818
+ cost: costFactsSchema.optional()
819
+ });
820
+ var promptSubmittedEventSchema = event({
821
+ type: z8.literal("prompt.submitted"),
822
+ promptSource: z8.enum(["user", "automation", "resumed", "unknown"]),
823
+ content: contentFactSchema.optional(),
824
+ turnIndex: z8.number().int().min(0).optional()
825
+ });
826
+ var generationStartEventSchema = event({
827
+ type: z8.literal("generation.start"),
828
+ generationId: nonEmptyStringSchema,
829
+ model: modelDescriptorSchema,
830
+ requestedMaxOutputTokens: tokenCountSchema.optional(),
831
+ inputContent: contentFactsSchema.optional()
832
+ });
833
+ var generationEndEventSchema = event({
834
+ type: z8.literal("generation.end"),
835
+ generationId: nonEmptyStringSchema,
836
+ model: modelDescriptorSchema,
837
+ outcome: outcomeSchema,
838
+ stopReason: nonEmptyStringSchema.optional(),
839
+ durationMillis: durationMillisSchema.optional(),
840
+ usage: canonicalUsageSchema.optional(),
841
+ cost: costFactsSchema.optional(),
842
+ outputContent: contentFactsSchema.optional()
843
+ });
844
+ var toolKindSchema = z8.enum([
845
+ "read",
846
+ "write",
847
+ "execute",
848
+ "search",
849
+ "network",
850
+ "delegate",
851
+ "other",
852
+ "unknown"
853
+ ]);
854
+ var toolStartEventSchema = event({
855
+ type: z8.literal("tool.start"),
856
+ toolCallId: nonEmptyStringSchema,
857
+ toolName: nonEmptyStringSchema,
858
+ toolKind: toolKindSchema,
859
+ generationId: nonEmptyStringSchema.optional(),
860
+ input: contentFactSchema.optional()
861
+ });
862
+ var toolEndEventSchema = event({
863
+ type: z8.literal("tool.end"),
864
+ toolCallId: nonEmptyStringSchema,
865
+ toolName: nonEmptyStringSchema,
866
+ outcome: outcomeSchema,
867
+ durationMillis: durationMillisSchema.optional(),
868
+ /** Present when the host asked for or recorded a permission decision. */
869
+ permissionDecision: z8.enum(["allowed", "denied", "deferred", "not-required"]).optional(),
870
+ output: contentFactSchema.optional()
871
+ });
872
+ var subagentStartEventSchema = event({
873
+ type: z8.literal("subagent.start"),
874
+ subagentInvocationId: invocationIdSchema,
875
+ subagentType: nonEmptyStringSchema.optional(),
876
+ /** 0 for the top-level agent; 1 for its direct children. */
877
+ delegationDepth: z8.number().int().min(0).max(64),
878
+ model: modelDescriptorSchema.optional()
879
+ });
880
+ var subagentEndEventSchema = event({
881
+ type: z8.literal("subagent.end"),
882
+ subagentInvocationId: invocationIdSchema,
883
+ outcome: outcomeSchema,
884
+ durationMillis: durationMillisSchema.optional(),
885
+ usage: canonicalUsageSchema.optional()
886
+ });
887
+ var compactionPerformedEventSchema = event({
888
+ type: z8.literal("compaction.performed"),
889
+ trigger: z8.enum(["automatic", "manual", "unknown"]),
890
+ /** Provider-reported context size before and after compaction, if known. */
891
+ contextTokensBefore: tokenCountSchema.optional(),
892
+ contextTokensAfter: tokenCountSchema.optional(),
893
+ droppedMessageCount: z8.number().int().min(0).optional(),
894
+ usage: canonicalUsageSchema.optional()
895
+ });
896
+ var errorRaisedEventSchema = event({
897
+ type: z8.literal("error.raised"),
898
+ errorCode: otelHookErrorCodeSchema,
899
+ severity: errorSeveritySchema,
900
+ phase: errorPhaseSchema,
901
+ retryable: z8.boolean(),
902
+ /** Error text is content: it is described, never embedded verbatim by default. */
903
+ message: contentFactSchema.optional(),
904
+ /** Non-sensitive, provider-agnostic short label. */
905
+ detail: nonEmptyStringSchema.optional()
906
+ });
907
+ var canonicalEventSchema = z8.discriminatedUnion("type", [
908
+ sessionStartEventSchema,
909
+ sessionEndEventSchema,
910
+ promptSubmittedEventSchema,
911
+ generationStartEventSchema,
912
+ generationEndEventSchema,
913
+ toolStartEventSchema,
914
+ toolEndEventSchema,
915
+ subagentStartEventSchema,
916
+ subagentEndEventSchema,
917
+ compactionPerformedEventSchema,
918
+ errorRaisedEventSchema
919
+ ]);
920
+ var validateCanonicalEvent = (value) => {
921
+ const parsed = canonicalEventSchema.safeParse(value);
922
+ if (parsed.success) {
923
+ return { status: "ok", event: parsed.data };
924
+ }
925
+ return {
926
+ status: "invalid",
927
+ issues: parsed.error.issues.map(
928
+ (issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`
929
+ )
930
+ };
931
+ };
932
+ var parseCanonicalEvent = (value) => canonicalEventSchema.parse(value);
933
+ var eventUsage = (event2) => "usage" in event2 ? event2.usage : void 0;
934
+ var compareEvents = (a, b) => a.sequence - b.sequence || a.occurredAt - b.occurredAt || a.eventId.localeCompare(b.eventId);
935
+ export {
936
+ CANONICAL_EVENT_TYPES,
937
+ CANONICAL_SCHEMA_VERSION,
938
+ CONTENT_HASH_PATTERN,
939
+ DETECTION_CONFIDENCE_RANK,
940
+ EMPTY_DELTA_USAGE,
941
+ EMPTY_EXTENSIONS,
942
+ EXTENSION_KEY_PATTERN,
943
+ MAX_ATTRIBUTE_ARRAY_LENGTH,
944
+ MAX_ATTRIBUTE_STRING_LENGTH,
945
+ MAX_EXTENSION_ENTRIES,
946
+ MAX_IDENTIFIER_LENGTH,
947
+ PROVIDER_ID_PATTERN,
948
+ RESERVED_EXTENSION_NAMESPACES,
949
+ UNKNOWN_PROVIDER_ID,
950
+ UNKNOWN_WORKSPACE_ID,
951
+ UsageNormalizationError,
952
+ WORKSPACE_ID_PATTERN,
953
+ addUsage,
954
+ attributePrimitiveSchema,
955
+ attributeValueSchema,
956
+ attributesSchema,
957
+ cacheCreationAccountingSchema,
958
+ canonicalEventSchema,
959
+ canonicalEventTypeSchema,
960
+ canonicalSchemaVersionSchema,
961
+ canonicalUsageSchema,
962
+ compactionPerformedEventSchema,
963
+ compareDetectionConfidence,
964
+ compareEvents,
965
+ consumerAttributesSchema,
966
+ contentDisclosureSchema,
967
+ contentFactSchema,
968
+ contentFactsSchema,
969
+ contentKindSchema,
970
+ contentRoleSchema,
971
+ costFactsSchema,
972
+ cumulativeToDelta,
973
+ detectionConfidenceSchema,
974
+ durationMillisSchema,
975
+ emptyExtensions,
976
+ epochMillisSchema,
977
+ errorRaisedEventSchema,
978
+ eventIdSchema,
979
+ eventUsage,
980
+ extensionKeyNamespace,
981
+ extensionsSchema,
982
+ generationEndEventSchema,
983
+ generationStartEventSchema,
984
+ identityClaimFieldsSchema,
985
+ identityClaimSchema,
986
+ invocationIdSchema,
987
+ invocationIdentitySchema,
988
+ isContentFactConsistent,
989
+ isReservedExtensionNamespace,
990
+ isUnknownProvider,
991
+ isValidExtensionKey,
992
+ modelDescriptorSchema,
993
+ nonEmptyStringSchema,
994
+ normalizeUsage,
995
+ normalizeUsageOrThrow,
996
+ parseCanonicalEvent,
997
+ promptSubmittedEventSchema,
998
+ providerIdSchema,
999
+ providerTotalAgreementSchema,
1000
+ resolveInvocationIdentity,
1001
+ resolvedProviderIdSchema,
1002
+ sequenceNumberSchema,
1003
+ sessionEndEventSchema,
1004
+ sessionIdSchema,
1005
+ sessionStartEventSchema,
1006
+ sourceProvenanceSchema,
1007
+ sourceTransportSchema,
1008
+ subagentEndEventSchema,
1009
+ subagentStartEventSchema,
1010
+ toReport,
1011
+ tokenCountSchema,
1012
+ toolEndEventSchema,
1013
+ toolKindSchema,
1014
+ toolStartEventSchema,
1015
+ unknownWorkspaceIdentity,
1016
+ usageReportSchema,
1017
+ usageTemporalitySchema,
1018
+ validateCanonicalEvent,
1019
+ workspaceIdSchema,
1020
+ workspaceIdentitySchema,
1021
+ workspaceKeySourceSchema
1022
+ };
1023
+ //# sourceMappingURL=model.js.map