@osfactory/otel-hook 0.13.1 → 0.14.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 (41) hide show
  1. package/README.md +94 -3
  2. package/dist/{adapter-DyCb7y1N.d.ts → adapter-D5R8lhfl.d.ts} +1 -1
  3. package/dist/cli.js +1240 -200
  4. package/dist/cli.js.map +1 -1
  5. package/dist/config.d.ts +32 -4
  6. package/dist/config.js +200 -14
  7. package/dist/config.js.map +1 -1
  8. package/dist/{destinations-DvqsPulb.d.ts → destinations-2KrcRslo.d.ts} +92 -2
  9. package/dist/{export-destinations-DUeQKr_C.d.ts → export-destinations-DvoH4QOe.d.ts} +135 -11
  10. package/dist/{hook-D5imE0Qc.d.ts → hook-DVK8Don-.d.ts} +4 -4
  11. package/dist/index.d.ts +11 -11
  12. package/dist/index.js +1262 -228
  13. package/dist/index.js.map +1 -1
  14. package/dist/install.d.ts +3 -3
  15. package/dist/install.js +1 -0
  16. package/dist/install.js.map +1 -1
  17. package/dist/integration.d.ts +16 -9
  18. package/dist/integration.js +1298 -205
  19. package/dist/integration.js.map +1 -1
  20. package/dist/lifecycle.js +1 -1
  21. package/dist/lifecycle.js.map +1 -1
  22. package/dist/{payload-CdDKeRpH.d.ts → payload-D4r71EL-.d.ts} +18 -2
  23. package/dist/privacy.d.ts +2 -2
  24. package/dist/privacy.js +42 -1
  25. package/dist/privacy.js.map +1 -1
  26. package/dist/providers.d.ts +94 -9
  27. package/dist/providers.js +300 -2
  28. package/dist/providers.js.map +1 -1
  29. package/dist/{registry-BKQhhIO3.d.ts → registry-DOJh9mzB.d.ts} +2 -2
  30. package/dist/runtime.d.ts +5 -5
  31. package/dist/runtime.js +151 -5
  32. package/dist/runtime.js.map +1 -1
  33. package/dist/{schema-SpFM6YQY.d.ts → schema-oRsbo7WO.d.ts} +77 -3
  34. package/dist/{service-CbI9CObT.d.ts → service-DySC7KQM.d.ts} +6 -1
  35. package/dist/telemetry.d.ts +5 -4
  36. package/dist/telemetry.js +1076 -476
  37. package/dist/telemetry.js.map +1 -1
  38. package/dist/testing.d.ts +5 -5
  39. package/dist/testing.js +178 -21
  40. package/dist/testing.js.map +1 -1
  41. package/package.json +1 -1
@@ -111,14 +111,37 @@ declare const exporterPolicySchema: z.ZodObject<{
111
111
  logs: "logs";
112
112
  metrics: "metrics";
113
113
  }>>>>;
114
+ scopes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
115
+ repositories: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodReadonly<z.ZodArray<z.ZodString>>]>;
116
+ signals: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
117
+ traces: "traces";
118
+ logs: "logs";
119
+ metrics: "metrics";
120
+ }>>>>;
121
+ contentMode: z.ZodOptional<z.ZodEnum<{
122
+ raw: "raw";
123
+ omit: "omit";
124
+ mask: "mask";
125
+ redact: "redact";
126
+ }>>;
127
+ includeSessionId: z.ZodOptional<z.ZodBoolean>;
128
+ }, z.core.$strict>>>>;
114
129
  }, z.core.$strict>>>>;
115
130
  spool: z.ZodOptional<z.ZodObject<{
116
131
  maxBytes: z.ZodOptional<z.ZodNumber>;
117
132
  maxAgeMillis: z.ZodOptional<z.ZodNumber>;
118
133
  maxBatches: z.ZodOptional<z.ZodNumber>;
119
134
  }, z.core.$strict>>;
135
+ exportBudgetMillis: z.ZodOptional<z.ZodNumber>;
136
+ endpointDownMillis: z.ZodOptional<z.ZodNumber>;
120
137
  }, z.core.$strict>;
121
138
  type ExporterPolicy = z.infer<typeof exporterPolicySchema>;
139
+ /** Default `exporter.exportBudgetMillis`. */
140
+ declare const DEFAULT_EXPORT_BUDGET_MILLIS = 1500;
141
+ /** Default `exporter.endpointDownMillis`. */
142
+ declare const DEFAULT_ENDPOINT_DOWN_MILLIS = 30000;
143
+ /** The per-request OTLP timeout a hook uses: `timeoutMillis`, capped by the export budget. */
144
+ declare const effectiveExportTimeoutMillis: (exporter: ExporterPolicy) => number;
122
145
  declare const detectionPolicySchema: z.ZodObject<{
123
146
  minimumConfidence: z.ZodEnum<{
124
147
  none: "none";
@@ -148,13 +171,22 @@ type DiagnosticsPolicy = z.infer<typeof diagnosticsPolicySchema>;
148
171
  * transcript reads in the hook" (docs/claude-code-usage-contract.md, finding 8).
149
172
  * When true, the hook runtime — never the adapter — reads the session transcript
150
173
  * named by a Claude Code `Stop` / `StopFailure` payload, bounded, and attaches the
151
- * turn's model and summed token usage before the adapter parses it. Off by
152
- * default: without it, otel-hook reads no file a hook payload names.
174
+ * turn's model and summed token usage before the adapter parses it.
175
+ *
176
+ * `codex.readRolloutUsage` is the same exception for Codex, which puts no token
177
+ * counters on any hook payload: at `Stop` the runtime reads the session's
178
+ * rollout (`transcript_path`) from a per-session cursor, bounded, and attaches
179
+ * the thread's running token total (docs/usage-semantics.md).
180
+ *
181
+ * Both off by default: without them, otel-hook reads no file a hook payload names.
153
182
  */
154
183
  declare const providersPolicySchema: z.ZodObject<{
155
184
  claudeCode: z.ZodOptional<z.ZodObject<{
156
185
  readTranscriptUsage: z.ZodBoolean;
157
186
  }, z.core.$strict>>;
187
+ codex: z.ZodOptional<z.ZodObject<{
188
+ readRolloutUsage: z.ZodBoolean;
189
+ }, z.core.$strict>>;
158
190
  }, z.core.$strict>;
159
191
  type ProvidersPolicy = z.infer<typeof providersPolicySchema>;
160
192
  /**
@@ -222,12 +254,29 @@ declare const otelHookConfigSchema: z.ZodObject<{
222
254
  logs: "logs";
223
255
  metrics: "metrics";
224
256
  }>>>>;
257
+ scopes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
258
+ repositories: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodReadonly<z.ZodArray<z.ZodString>>]>;
259
+ signals: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
260
+ traces: "traces";
261
+ logs: "logs";
262
+ metrics: "metrics";
263
+ }>>>>;
264
+ contentMode: z.ZodOptional<z.ZodEnum<{
265
+ raw: "raw";
266
+ omit: "omit";
267
+ mask: "mask";
268
+ redact: "redact";
269
+ }>>;
270
+ includeSessionId: z.ZodOptional<z.ZodBoolean>;
271
+ }, z.core.$strict>>>>;
225
272
  }, z.core.$strict>>>>;
226
273
  spool: z.ZodOptional<z.ZodObject<{
227
274
  maxBytes: z.ZodOptional<z.ZodNumber>;
228
275
  maxAgeMillis: z.ZodOptional<z.ZodNumber>;
229
276
  maxBatches: z.ZodOptional<z.ZodNumber>;
230
277
  }, z.core.$strict>>;
278
+ exportBudgetMillis: z.ZodOptional<z.ZodNumber>;
279
+ endpointDownMillis: z.ZodOptional<z.ZodNumber>;
231
280
  }, z.core.$strict>;
232
281
  privacy: z.ZodObject<{
233
282
  contentMode: z.ZodEnum<{
@@ -274,6 +323,9 @@ declare const otelHookConfigSchema: z.ZodObject<{
274
323
  claudeCode: z.ZodOptional<z.ZodObject<{
275
324
  readTranscriptUsage: z.ZodBoolean;
276
325
  }, z.core.$strict>>;
326
+ codex: z.ZodOptional<z.ZodObject<{
327
+ readRolloutUsage: z.ZodBoolean;
328
+ }, z.core.$strict>>;
277
329
  }, z.core.$strict>>;
278
330
  sessionContext: z.ZodOptional<z.ZodObject<{
279
331
  dir: z.ZodString;
@@ -316,7 +368,24 @@ declare const otelHookConfigPatchSchema: z.ZodObject<{
316
368
  logs: "logs";
317
369
  metrics: "metrics";
318
370
  }>>>>;
371
+ scopes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
372
+ repositories: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodReadonly<z.ZodArray<z.ZodString>>]>;
373
+ signals: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
374
+ traces: "traces";
375
+ logs: "logs";
376
+ metrics: "metrics";
377
+ }>>>>;
378
+ contentMode: z.ZodOptional<z.ZodEnum<{
379
+ raw: "raw";
380
+ omit: "omit";
381
+ mask: "mask";
382
+ redact: "redact";
383
+ }>>;
384
+ includeSessionId: z.ZodOptional<z.ZodBoolean>;
385
+ }, z.core.$strict>>>>;
319
386
  }, z.core.$strict>>>>>;
387
+ exportBudgetMillis: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
388
+ endpointDownMillis: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
320
389
  logs: z.ZodOptional<z.ZodObject<{
321
390
  enabled: z.ZodOptional<z.ZodBoolean>;
322
391
  endpoint: z.ZodOptional<z.ZodOptional<z.ZodString>>;
@@ -383,6 +452,9 @@ declare const otelHookConfigPatchSchema: z.ZodObject<{
383
452
  claudeCode: z.ZodOptional<z.ZodOptional<z.ZodObject<{
384
453
  readTranscriptUsage: z.ZodOptional<z.ZodBoolean>;
385
454
  }, z.core.$strict>>>;
455
+ codex: z.ZodOptional<z.ZodOptional<z.ZodObject<{
456
+ readRolloutUsage: z.ZodOptional<z.ZodBoolean>;
457
+ }, z.core.$strict>>>;
386
458
  }, z.core.$strict>>;
387
459
  sessionContext: z.ZodOptional<z.ZodObject<{
388
460
  dir: z.ZodOptional<z.ZodString>;
@@ -396,10 +468,12 @@ declare const DEFAULT_PROVIDERS_POLICY: ProvidersPolicy;
396
468
  declare const DEFAULT_CONFIG: OtelHookConfig;
397
469
  /** Whether the runtime may read Claude Code transcripts at `Stop` (default false). */
398
470
  declare const readsClaudeTranscriptUsage: (config: OtelHookConfig) => boolean;
471
+ /** Whether the runtime may read Codex rollouts at `Stop` (default false). */
472
+ declare const readsCodexRolloutUsage: (config: OtelHookConfig) => boolean;
399
473
  /** The session context directory in force, or `undefined` when none is configured. */
400
474
  declare const sessionContextDir: (config: OtelHookConfig) => string | undefined;
401
475
 
402
476
  /** The metrics policy in force, defaults filled in. */
403
477
  declare const effectiveMetricsPolicy: (exporter: ExporterPolicy) => MetricsPolicy;
404
478
 
405
- export { DEFAULT_CONFIG as D, type ExporterPolicy as E, type LogsPolicy as L, type MetricsPolicy as M, type OtelHookConfig as O, type ProvidersPolicy as P, type SessionContextPolicy as S, DEFAULT_DETECTION_POLICY as a, DEFAULT_DIAGNOSTICS_POLICY as b, DEFAULT_EXPORTER_POLICY as c, DEFAULT_LOGS_POLICY as d, DEFAULT_METRICS_POLICY as e, DEFAULT_PROVIDERS_POLICY as f, type DetectionPolicy as g, type DiagnosticsPolicy as h, type OtelHookConfigPatch as i, detectionPolicySchema as j, diagnosticsPolicySchema as k, effectiveMetricsPolicy as l, exporterPolicySchema as m, logsPolicySchema as n, metricsPolicySchema as o, otelHookConfigPatchSchema as p, otelHookConfigSchema as q, providersPolicySchema as r, readsClaudeTranscriptUsage as s, sessionContextDir as t, sessionContextPolicySchema as u };
479
+ export { DEFAULT_CONFIG as D, type ExporterPolicy as E, type LogsPolicy as L, type MetricsPolicy as M, type OtelHookConfig as O, type ProvidersPolicy as P, type SessionContextPolicy as S, DEFAULT_DETECTION_POLICY as a, DEFAULT_DIAGNOSTICS_POLICY as b, DEFAULT_ENDPOINT_DOWN_MILLIS as c, DEFAULT_EXPORTER_POLICY as d, DEFAULT_EXPORT_BUDGET_MILLIS as e, DEFAULT_LOGS_POLICY as f, DEFAULT_METRICS_POLICY as g, DEFAULT_PROVIDERS_POLICY as h, type DetectionPolicy as i, type DiagnosticsPolicy as j, type OtelHookConfigPatch as k, detectionPolicySchema as l, diagnosticsPolicySchema as m, effectiveExportTimeoutMillis as n, effectiveMetricsPolicy as o, exporterPolicySchema as p, logsPolicySchema as q, metricsPolicySchema as r, otelHookConfigPatchSchema as s, otelHookConfigSchema as t, providersPolicySchema as u, readsClaudeTranscriptUsage as v, readsCodexRolloutUsage as w, sessionContextDir as x, sessionContextPolicySchema as y };
@@ -1,6 +1,6 @@
1
1
  import { c as ContentKind, d as ContentRole, b as ContentFact } from './content-M9xIKG7h.js';
2
2
  import { b as Attributes, a as AttributeValue } from './primitives-CJ8-rn-f.js';
3
- import { f as PrivacyPolicy } from './policy-CimmCfRp.js';
3
+ import { f as PrivacyPolicy, a as ContentMode } from './policy-CimmCfRp.js';
4
4
 
5
5
  type SanitizedValue = string | number | boolean | null | readonly SanitizedValue[] | {
6
6
  readonly [key: string]: SanitizedValue;
@@ -68,6 +68,11 @@ interface PrivacyService {
68
68
  readonly text: string;
69
69
  readonly truncated: boolean;
70
70
  };
71
+ /**
72
+ * The same fact disclosed at most at `mode` (a per-destination restriction).
73
+ * Never raises disclosure: a fact already at or below `mode` is returned as is.
74
+ */
75
+ restrictContent(fact: ContentFact, mode: ContentMode): ContentFact;
71
76
  }
72
77
  declare const createPrivacyService: (policyInput: PrivacyPolicy) => PrivacyService;
73
78
 
@@ -1,20 +1,21 @@
1
1
  export { D as DEFAULT_INSTRUMENTATION_SCOPE, a as DeriveMetricObservationsInput, E as EventTraceIdentity, M as MAX_RECOVERED_START_ATTRIBUTES, b as METRIC_COST_USAGE, c as METRIC_INSTRUMENTS, d as METRIC_OPERATION_DURATION, e as METRIC_SESSIONS, f as METRIC_TOKEN_USAGE, g as METRIC_TOOL_CALLS, h as MetricInstrument, i as MetricInstrumentName, j as MetricObservation, k as MetricPoint, l as MetricsTemporality, O as OPERATION_DURATION_BUCKETS, S as SemanticMappingOptions, m as SpanCorrelation, n as SpanCorrelationResolver, o as SpanDisposition, p as SpanFamily, q as SpanOrphanClassification, r as SpanPairing, s as SpanScopeRef, T as TOKEN_USAGE_BUCKETS, t as TokenType, u as aggregateDeltaPoints, v as canonicalEventTraceIdentities, w as canonicalEventsToReadableSpans, x as deriveMetricObservations, y as parentScopeRefOf, z as spanScopeRefOf, A as startOnlySpanAttributes } from './metric-model-B4lIuk6i.js';
2
- export { C as ContentWithholdingReason, D as DurableLogSpool, a as DurableLogSpoolOptions, b as DurableMetricSpool, c as DurableMetricSpoolOptions, d as DurableSpool, e as DurableSpoolOptions, E as ExportDestinationSinks, f as ExportDestinationsOptions, L as LOG_MAPPING_VERSION, g as LOG_SIGNALS, h as LogContentPolicy, i as LogMappingOptions, j as LogMappingResult, k as LogSignal, l as LogSpoolBatch, m as LogsDeliverability, M as MAX_LOG_BODY_CHARACTERS, n as MAX_LOG_RECORDS_PER_BATCH, o as MAX_LOG_RECORDS_PER_EVENT, p as MCP_TOOL_NAME_PATTERN, q as MetricExportResult, r as MetricSpoolBatch, s as MetricsDeliverability, N as NO_LOG_CONTENT, O as OtlpLogSinkOptions, t as OtlpLogTelemetrySink, u as OtlpMetricSinkOptions, v as OtlpMetricTelemetrySink, w as OtlpTelemetrySink, x as OtlpTraceSinkOptions, S as SerializedLogRecord, y as SerializedSpan, z as SignalFanoutOptions, A as SignalFanoutSink, B as SkippedExportDestination, F as SpoolBatch, G as SpoolDrainResult, H as SpoolDropCounts, I as SpoolDropReason, J as SpoolEnqueueResult, K as SpoolOverflowPolicy, P as SpoolSendOutcome, Q as SpoolStats, R as canonicalEventsToLogRecords, T as createDestinationFanout, U as createExportDestinationSinks, V as createFileDurableLogSpool, W as createFileDurableMetricSpool, X as createFileDurableSpool, Y as createOtlpLogSink, Z as createOtlpMetricSink, _ as createOtlpTraceSink, $ as createSignalFanout, a0 as describeLogsDeliverability, a1 as describeMetricsDeliverability, a2 as exporterPolicyForDestination, a3 as logSignalOf, a4 as logSignalsForLifecycleEvents, a5 as resolveLogsEndpoint, a6 as resolveMetricsEndpoint, a7 as shareCorrelationPerBatch, a8 as spoolQueueNamesFor, a9 as validateMetricSpoolBatch } from './export-destinations-DUeQKr_C.js';
2
+ export { C as ContentRestrictor, a as ContentWithholdingReason, D as DestinationFanoutOptions, b as DurableLogSpool, c as DurableLogSpoolOptions, d as DurableMetricSpool, e as DurableMetricSpoolOptions, f as DurableSpool, g as DurableSpoolOptions, E as ExportDestinationSinks, h as ExportDestinationsOptions, L as LOG_MAPPING_VERSION, i as LOG_SIGNALS, j as LogContentPolicy, k as LogMappingOptions, l as LogMappingResult, m as LogSignal, n as LogSpoolBatch, o as LogsDeliverability, M as MAX_LOG_BODY_CHARACTERS, p as MAX_LOG_RECORDS_PER_BATCH, q as MAX_LOG_RECORDS_PER_EVENT, r as MCP_TOOL_NAME_PATTERN, s as MetricExportResult, t as MetricSpoolBatch, u as MetricsDeliverability, N as NO_LOG_CONTENT, O as OtlpLogSinkOptions, v as OtlpLogTelemetrySink, w as OtlpMetricSinkOptions, x as OtlpMetricTelemetrySink, y as OtlpTelemetrySink, z as OtlpTraceSinkOptions, R as RouteEventsOptions, S as ScopedBatch, A as SerializedLogRecord, B as SerializedSpan, F as SharedCorrelationResolver, G as SignalFanoutOptions, H as SignalFanoutSink, I as SkippedExportDestination, J as SpoolBatch, K as SpoolDrainResult, P as SpoolDropCounts, Q as SpoolDropReason, T as SpoolEnqueueResult, U as SpoolOverflowPolicy, V as SpoolSendOutcome, W as SpoolStats, X as canonicalEventsToLogRecords, Y as createDestinationFanout, Z as createExportDestinationSinks, _ as createFileDurableLogSpool, $ as createFileDurableMetricSpool, a0 as createFileDurableSpool, a1 as createOtlpLogSink, a2 as createOtlpMetricSink, a3 as createOtlpTraceSink, a4 as createSignalFanout, a5 as describeLogsDeliverability, a6 as describeMetricsDeliverability, a7 as eventRepositoryKey, a8 as exporterPolicyForDestination, a9 as logSignalOf, aa as logSignalsForLifecycleEvents, ab as omitRestrictedContent, ac as pointRepositoryKey, ad as resolveLogsEndpoint, ae as resolveMetricsEndpoint, af as resourceRepositoryKey, ag as restrictEventContent, ah as routeEventsToScopes, ai as routePointsToScopes, aj as sessionIdVariantsFor, ak as shareCorrelationPerBatch, al as spoolQueueNamesFor, am as validateMetricSpoolBatch } from './export-destinations-DvoH4QOe.js';
3
3
  import { ExportResult } from '@opentelemetry/core';
4
4
  import '@opentelemetry/api';
5
5
  import '@opentelemetry/resources';
6
6
  import '@opentelemetry/sdk-trace';
7
7
  import './events-fcomX6d5.js';
8
8
  import 'zod';
9
- import './destinations-DvqsPulb.js';
10
- import './schema-SpFM6YQY.js';
9
+ import './destinations-2KrcRslo.js';
10
+ import './policy-CimmCfRp.js';
11
+ import './content-M9xIKG7h.js';
12
+ import './schema-oRsbo7WO.js';
11
13
  import './ports-DhpSDIkp.js';
12
14
  import './errors.js';
13
15
  import './primitives-CJ8-rn-f.js';
14
16
  import './taxonomy-DwhTtuWd.js';
15
17
  import './keys-Dej5bN3L.js';
16
18
  import '@opentelemetry/sdk-logs';
17
- import './content-M9xIKG7h.js';
18
19
  import './diagnostics.js';
19
20
 
20
21
  /**