@osfactory/otel-hook 0.8.0 → 0.10.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 (52) hide show
  1. package/README.md +159 -2
  2. package/dist/{adapter-BJiz6lqM.d.ts → adapter-B9RwW6TO.d.ts} +14 -2
  3. package/dist/cli.js +2514 -1238
  4. package/dist/cli.js.map +1 -1
  5. package/dist/config.d.ts +5 -2
  6. package/dist/config.js +479 -169
  7. package/dist/config.js.map +1 -1
  8. package/dist/destinations-DWOkVxV1.d.ts +169 -0
  9. package/dist/diagnostics.d.ts +8 -0
  10. package/dist/diagnostics.js +2 -1
  11. package/dist/diagnostics.js.map +1 -1
  12. package/dist/{events-B3MHoJTD.d.ts → events-CSD_YiJ2.d.ts} +2 -0
  13. package/dist/{otlp-log-sink-zuHojHSP.d.ts → export-destinations-lORbe25J.d.ts} +241 -9
  14. package/dist/{filesystem-store-r-nNA3BA.d.ts → filesystem-store-DX3dGIgu.d.ts} +1 -1
  15. package/dist/{hook-Dh8OO4Wa.d.ts → hook-BAxXoKsp.d.ts} +10 -5
  16. package/dist/index.d.ts +15 -14
  17. package/dist/index.js +1936 -730
  18. package/dist/index.js.map +1 -1
  19. package/dist/install.d.ts +4 -4
  20. package/dist/install.js +31 -2
  21. package/dist/install.js.map +1 -1
  22. package/dist/integration.d.ts +37 -12
  23. package/dist/integration.js +1942 -617
  24. package/dist/integration.js.map +1 -1
  25. package/dist/lifecycle.d.ts +3 -3
  26. package/dist/lifecycle.js +8 -1
  27. package/dist/lifecycle.js.map +1 -1
  28. package/dist/{memory-Bl9ANVff.d.ts → memory-aJilVG4R.d.ts} +2 -2
  29. package/dist/model.d.ts +1 -1
  30. package/dist/model.js +7 -0
  31. package/dist/model.js.map +1 -1
  32. package/dist/{payload-Ci8_ERm6.d.ts → payload-D7gc0-WQ.d.ts} +41 -2
  33. package/dist/{ports-n7KFOpKo.d.ts → ports-plO5MKrY.d.ts} +63 -2
  34. package/dist/providers.d.ts +146 -10
  35. package/dist/providers.js +397 -13
  36. package/dist/providers.js.map +1 -1
  37. package/dist/{registry-CIVvRlVK.d.ts → registry-C7XO4DzD.d.ts} +2 -2
  38. package/dist/runtime.d.ts +8 -8
  39. package/dist/runtime.js +1426 -1163
  40. package/dist/runtime.js.map +1 -1
  41. package/dist/{schema-Cn0-xz8L.d.ts → schema-CHb3GU1r.d.ts} +98 -3
  42. package/dist/{semconv-fPRb-dpU.d.ts → semconv-Dw7gcQcg.d.ts} +1 -1
  43. package/dist/state.d.ts +4 -4
  44. package/dist/state.js +607 -39
  45. package/dist/state.js.map +1 -1
  46. package/dist/telemetry.d.ts +23 -66
  47. package/dist/telemetry.js +637 -34
  48. package/dist/telemetry.js.map +1 -1
  49. package/dist/testing.d.ts +10 -8
  50. package/dist/testing.js +868 -560
  51. package/dist/testing.js.map +1 -1
  52. package/package.json +1 -1
@@ -57,6 +57,28 @@ declare const exporterPolicySchema: z.ZodObject<{
57
57
  includeContent: z.ZodBoolean;
58
58
  maxBatchSize: z.ZodNumber;
59
59
  }, z.core.$strict>;
60
+ destinations: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
61
+ name: z.ZodString;
62
+ enabled: z.ZodOptional<z.ZodBoolean>;
63
+ endpoint: z.ZodOptional<z.ZodString>;
64
+ tracesEndpoint: z.ZodOptional<z.ZodString>;
65
+ logsEndpoint: z.ZodOptional<z.ZodString>;
66
+ protocol: z.ZodOptional<z.ZodEnum<{
67
+ none: "none";
68
+ "http/protobuf": "http/protobuf";
69
+ "http/json": "http/json";
70
+ }>>;
71
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
72
+ signals: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
73
+ traces: "traces";
74
+ logs: "logs";
75
+ }>>>>;
76
+ }, z.core.$strict>>>>;
77
+ spool: z.ZodOptional<z.ZodObject<{
78
+ maxBytes: z.ZodOptional<z.ZodNumber>;
79
+ maxAgeMillis: z.ZodOptional<z.ZodNumber>;
80
+ maxBatches: z.ZodOptional<z.ZodNumber>;
81
+ }, z.core.$strict>>;
60
82
  }, z.core.$strict>;
61
83
  type ExporterPolicy = z.infer<typeof exporterPolicySchema>;
62
84
  declare const detectionPolicySchema: z.ZodObject<{
@@ -81,6 +103,22 @@ declare const diagnosticsPolicySchema: z.ZodObject<{
81
103
  emitErrorEvents: z.ZodBoolean;
82
104
  }, z.core.$strict>;
83
105
  type DiagnosticsPolicy = z.infer<typeof diagnosticsPolicySchema>;
106
+ /**
107
+ * Per-provider behaviour that is not part of an adapter's parse.
108
+ *
109
+ * `claudeCode.readTranscriptUsage` is the one sanctioned exception to "no
110
+ * transcript reads in the hook" (docs/claude-code-usage-contract.md, finding 8).
111
+ * When true, the hook runtime — never the adapter — reads the session transcript
112
+ * named by a Claude Code `Stop` / `StopFailure` payload, bounded, and attaches the
113
+ * turn's model and summed token usage before the adapter parses it. Off by
114
+ * default: without it, otel-hook reads no file a hook payload names.
115
+ */
116
+ declare const providersPolicySchema: z.ZodObject<{
117
+ claudeCode: z.ZodOptional<z.ZodObject<{
118
+ readTranscriptUsage: z.ZodBoolean;
119
+ }, z.core.$strict>>;
120
+ }, z.core.$strict>;
121
+ type ProvidersPolicy = z.infer<typeof providersPolicySchema>;
84
122
  declare const otelHookConfigSchema: z.ZodObject<{
85
123
  exporter: z.ZodObject<{
86
124
  enabled: z.ZodBoolean;
@@ -104,6 +142,28 @@ declare const otelHookConfigSchema: z.ZodObject<{
104
142
  includeContent: z.ZodBoolean;
105
143
  maxBatchSize: z.ZodNumber;
106
144
  }, z.core.$strict>;
145
+ destinations: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
146
+ name: z.ZodString;
147
+ enabled: z.ZodOptional<z.ZodBoolean>;
148
+ endpoint: z.ZodOptional<z.ZodString>;
149
+ tracesEndpoint: z.ZodOptional<z.ZodString>;
150
+ logsEndpoint: z.ZodOptional<z.ZodString>;
151
+ protocol: z.ZodOptional<z.ZodEnum<{
152
+ none: "none";
153
+ "http/protobuf": "http/protobuf";
154
+ "http/json": "http/json";
155
+ }>>;
156
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
157
+ signals: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
158
+ traces: "traces";
159
+ logs: "logs";
160
+ }>>>>;
161
+ }, z.core.$strict>>>>;
162
+ spool: z.ZodOptional<z.ZodObject<{
163
+ maxBytes: z.ZodOptional<z.ZodNumber>;
164
+ maxAgeMillis: z.ZodOptional<z.ZodNumber>;
165
+ maxBatches: z.ZodOptional<z.ZodNumber>;
166
+ }, z.core.$strict>>;
107
167
  }, z.core.$strict>;
108
168
  privacy: z.ZodObject<{
109
169
  contentMode: z.ZodEnum<{
@@ -146,6 +206,11 @@ declare const otelHookConfigSchema: z.ZodObject<{
146
206
  }>;
147
207
  emitErrorEvents: z.ZodBoolean;
148
208
  }, z.core.$strict>;
209
+ providers: z.ZodOptional<z.ZodObject<{
210
+ claudeCode: z.ZodOptional<z.ZodObject<{
211
+ readTranscriptUsage: z.ZodBoolean;
212
+ }, z.core.$strict>>;
213
+ }, z.core.$strict>>;
149
214
  }, z.core.$strict>;
150
215
  type OtelHookConfig = z.infer<typeof otelHookConfigSchema>;
151
216
  /** Partial overlay accepted from a configuration layer. */
@@ -153,25 +218,47 @@ declare const otelHookConfigPatchSchema: z.ZodObject<{
153
218
  exporter: z.ZodOptional<z.ZodObject<{
154
219
  serviceName: z.ZodOptional<z.ZodString>;
155
220
  serviceNamespace: z.ZodOptional<z.ZodOptional<z.ZodString>>;
156
- enabled: z.ZodOptional<z.ZodBoolean>;
157
221
  protocol: z.ZodOptional<z.ZodEnum<{
158
222
  none: "none";
159
223
  "http/protobuf": "http/protobuf";
160
224
  "http/json": "http/json";
161
225
  }>>;
226
+ enabled: z.ZodOptional<z.ZodBoolean>;
162
227
  endpoint: z.ZodOptional<z.ZodOptional<z.ZodString>>;
163
- maxBatchSize: z.ZodOptional<z.ZodNumber>;
164
228
  headerNames: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
165
229
  timeoutMillis: z.ZodOptional<z.ZodNumber>;
230
+ maxBatchSize: z.ZodOptional<z.ZodNumber>;
166
231
  maxQueueSize: z.ZodOptional<z.ZodNumber>;
167
232
  maxRetryAttempts: z.ZodOptional<z.ZodNumber>;
168
233
  resourceAttributes: z.ZodOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
234
+ destinations: z.ZodOptional<z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
235
+ name: z.ZodString;
236
+ enabled: z.ZodOptional<z.ZodBoolean>;
237
+ endpoint: z.ZodOptional<z.ZodString>;
238
+ tracesEndpoint: z.ZodOptional<z.ZodString>;
239
+ logsEndpoint: z.ZodOptional<z.ZodString>;
240
+ protocol: z.ZodOptional<z.ZodEnum<{
241
+ none: "none";
242
+ "http/protobuf": "http/protobuf";
243
+ "http/json": "http/json";
244
+ }>>;
245
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
246
+ signals: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
247
+ traces: "traces";
248
+ logs: "logs";
249
+ }>>>>;
250
+ }, z.core.$strict>>>>>;
169
251
  logs: z.ZodOptional<z.ZodObject<{
170
252
  enabled: z.ZodOptional<z.ZodBoolean>;
171
253
  endpoint: z.ZodOptional<z.ZodOptional<z.ZodString>>;
172
254
  includeContent: z.ZodOptional<z.ZodBoolean>;
173
255
  maxBatchSize: z.ZodOptional<z.ZodNumber>;
174
256
  }, z.core.$strict>>;
257
+ spool: z.ZodOptional<z.ZodObject<{
258
+ maxBytes: z.ZodOptional<z.ZodNumber>;
259
+ maxAgeMillis: z.ZodOptional<z.ZodNumber>;
260
+ maxBatches: z.ZodOptional<z.ZodNumber>;
261
+ }, z.core.$strict>>;
175
262
  }, z.core.$strict>>;
176
263
  privacy: z.ZodOptional<z.ZodObject<{
177
264
  contentMode: z.ZodOptional<z.ZodEnum<{
@@ -214,11 +301,19 @@ declare const otelHookConfigPatchSchema: z.ZodObject<{
214
301
  }>>;
215
302
  emitErrorEvents: z.ZodOptional<z.ZodBoolean>;
216
303
  }, z.core.$strict>>;
304
+ providers: z.ZodOptional<z.ZodObject<{
305
+ claudeCode: z.ZodOptional<z.ZodOptional<z.ZodObject<{
306
+ readTranscriptUsage: z.ZodOptional<z.ZodBoolean>;
307
+ }, z.core.$strict>>>;
308
+ }, z.core.$strict>>;
217
309
  }, z.core.$strict>;
218
310
  type OtelHookConfigPatch = z.infer<typeof otelHookConfigPatchSchema>;
219
311
  declare const DEFAULT_EXPORTER_POLICY: ExporterPolicy;
220
312
  declare const DEFAULT_DETECTION_POLICY: DetectionPolicy;
221
313
  declare const DEFAULT_DIAGNOSTICS_POLICY: DiagnosticsPolicy;
314
+ declare const DEFAULT_PROVIDERS_POLICY: ProvidersPolicy;
222
315
  declare const DEFAULT_CONFIG: OtelHookConfig;
316
+ /** Whether the runtime may read Claude Code transcripts at `Stop` (default false). */
317
+ declare const readsClaudeTranscriptUsage: (config: OtelHookConfig) => boolean;
223
318
 
224
- export { DEFAULT_CONFIG as D, type ExporterPolicy as E, type LogsPolicy as L, type OtelHookConfig as O, DEFAULT_DETECTION_POLICY as a, DEFAULT_DIAGNOSTICS_POLICY as b, DEFAULT_EXPORTER_POLICY as c, DEFAULT_LOGS_POLICY as d, type DetectionPolicy as e, type DiagnosticsPolicy as f, type OtelHookConfigPatch as g, detectionPolicySchema as h, diagnosticsPolicySchema as i, exporterPolicySchema as j, otelHookConfigSchema as k, logsPolicySchema as l, otelHookConfigPatchSchema as o };
319
+ export { DEFAULT_CONFIG as D, type ExporterPolicy as E, type LogsPolicy as L, type OtelHookConfig as O, type ProvidersPolicy as P, DEFAULT_DETECTION_POLICY as a, DEFAULT_DIAGNOSTICS_POLICY as b, DEFAULT_EXPORTER_POLICY as c, DEFAULT_LOGS_POLICY as d, DEFAULT_PROVIDERS_POLICY as e, type DetectionPolicy as f, type DiagnosticsPolicy as g, type OtelHookConfigPatch as h, detectionPolicySchema as i, diagnosticsPolicySchema as j, exporterPolicySchema as k, logsPolicySchema as l, otelHookConfigSchema as m, otelHookConfigPatchSchema as o, providersPolicySchema as p, readsClaudeTranscriptUsage as r };
@@ -2,7 +2,7 @@ import { Attributes } from '@opentelemetry/api';
2
2
  import { InstrumentationScope } from '@opentelemetry/core';
3
3
  import { Resource } from '@opentelemetry/resources';
4
4
  import { ReadableSpan } from '@opentelemetry/sdk-trace';
5
- import { b as CanonicalEvent } from './events-B3MHoJTD.js';
5
+ import { b as CanonicalEvent } from './events-CSD_YiJ2.js';
6
6
 
7
7
  declare const DEFAULT_INSTRUMENTATION_SCOPE: InstrumentationScope;
8
8
  /** Lifecycle scopes that pair a `*.start` edge with a later `*.end` edge. */
package/dist/state.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export { S as StoreNamespace } from './keys-Dej5bN3L.js';
2
- import { L as LockingStateStore } from './filesystem-store-r-nNA3BA.js';
3
- export { F as FilesystemStateStore, a as FilesystemStateStoreOptions, S as StateStoreDependencies, c as createFilesystemStateStore, i as isLockingStateStore, w as withOptionalSessionLock } from './filesystem-store-r-nNA3BA.js';
4
- import { C as Clock } from './ports-n7KFOpKo.js';
2
+ import { L as LockingStateStore } from './filesystem-store-DX3dGIgu.js';
3
+ export { F as FilesystemStateStore, a as FilesystemStateStoreOptions, S as StateStoreDependencies, c as createFilesystemStateStore, i as isLockingStateStore, w as withOptionalSessionLock } from './filesystem-store-DX3dGIgu.js';
4
+ import { C as Clock } from './ports-plO5MKrY.js';
5
5
  import 'zod';
6
6
  import './errors.js';
7
7
  import './primitives-CJ8-rn-f.js';
8
8
  import './taxonomy-DwhTtuWd.js';
9
- import './events-B3MHoJTD.js';
9
+ import './events-CSD_YiJ2.js';
10
10
 
11
11
  type BoundedMemoryStateStoreOptions = {
12
12
  readonly clock: Clock;