@osfactory/otel-hook 0.10.0 → 0.12.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 (51) hide show
  1. package/README.md +108 -4
  2. package/dist/{adapter-B9RwW6TO.d.ts → adapter-DQiPu8xF.d.ts} +2 -2
  3. package/dist/cli.js +1495 -135
  4. package/dist/cli.js.map +1 -1
  5. package/dist/config.d.ts +11 -4
  6. package/dist/config.js +116 -21
  7. package/dist/config.js.map +1 -1
  8. package/dist/{destinations-DWOkVxV1.d.ts → destinations-DvqsPulb.d.ts} +12 -2
  9. package/dist/diagnostics.d.ts +1 -1
  10. package/dist/diagnostics.js.map +1 -1
  11. package/dist/{events-CSD_YiJ2.d.ts → events-fcomX6d5.d.ts} +22 -0
  12. package/dist/{export-destinations-lORbe25J.d.ts → export-destinations-CI7z4n3i.d.ts} +136 -6
  13. package/dist/{filesystem-store-DX3dGIgu.d.ts → filesystem-store-CmnUlj1O.d.ts} +1 -1
  14. package/dist/{hook-BAxXoKsp.d.ts → hook-vM_cgqS2.d.ts} +11 -5
  15. package/dist/index.d.ts +16 -16
  16. package/dist/index.js +1496 -183
  17. package/dist/index.js.map +1 -1
  18. package/dist/install.d.ts +4 -4
  19. package/dist/install.js +9 -1
  20. package/dist/install.js.map +1 -1
  21. package/dist/integration.d.ts +36 -12
  22. package/dist/integration.js +1464 -231
  23. package/dist/integration.js.map +1 -1
  24. package/dist/lifecycle.d.ts +55 -4
  25. package/dist/lifecycle.js +279 -5
  26. package/dist/lifecycle.js.map +1 -1
  27. package/dist/{memory-aJilVG4R.d.ts → memory-DdU1U91y.d.ts} +2 -2
  28. package/dist/{semconv-Dw7gcQcg.d.ts → metric-model-C9lLqqpI.d.ts} +157 -2
  29. package/dist/model.d.ts +1 -1
  30. package/dist/model.js +9 -1
  31. package/dist/model.js.map +1 -1
  32. package/dist/{payload-D7gc0-WQ.d.ts → payload-BT19hiVZ.d.ts} +1 -1
  33. package/dist/{ports-plO5MKrY.d.ts → ports-C3k_5eOQ.d.ts} +57 -2
  34. package/dist/providers.d.ts +10 -10
  35. package/dist/providers.js +10 -1
  36. package/dist/providers.js.map +1 -1
  37. package/dist/{registry-C7XO4DzD.d.ts → registry-gyJqaWmp.d.ts} +2 -2
  38. package/dist/runtime.d.ts +97 -9
  39. package/dist/runtime.js +312 -33
  40. package/dist/runtime.js.map +1 -1
  41. package/dist/{schema-CHb3GU1r.d.ts → schema-SpFM6YQY.d.ts} +87 -1
  42. package/dist/state.d.ts +4 -4
  43. package/dist/state.js +32 -1
  44. package/dist/state.js.map +1 -1
  45. package/dist/telemetry.d.ts +6 -6
  46. package/dist/telemetry.js +929 -31
  47. package/dist/telemetry.js.map +1 -1
  48. package/dist/testing.d.ts +11 -9
  49. package/dist/testing.js +164 -33
  50. package/dist/testing.js.map +1 -1
  51. package/package.json +3 -1
@@ -1,6 +1,6 @@
1
- import { f as DetectionPolicy } from './schema-CHb3GU1r.js';
1
+ import { g as DetectionPolicy } from './schema-SpFM6YQY.js';
2
2
  import { OtelHookErrorInfo } from './errors.js';
3
- import { P as ProviderAdapter, h as ProviderDetection, i as ProviderDetectionInput, e as ProviderContext } from './adapter-B9RwW6TO.js';
3
+ import { P as ProviderAdapter, h as ProviderDetection, i as ProviderDetectionInput, e as ProviderContext } from './adapter-DQiPu8xF.js';
4
4
 
5
5
  type DetectionCandidate = {
6
6
  readonly adapter: ProviderAdapter;
package/dist/runtime.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- import { c as LogLevel, d as Logger, W as WorktreeLocator } from './ports-plO5MKrY.js';
2
- export { A as AppliedDelivery, C as Clock, E as EventIdSeed, I as IdGenerator, a as InvocationIdSeed, L as LOG_LEVEL_RANK, b as LocatedWorktree, P as PayloadEnricher, e as PayloadEnrichment, f as PayloadEnrichmentInput, R as ReadCursor, S as StateRecord, g as StateStore, h as StateValue, T as TelemetryEmitResult, i as TelemetrySink, j as appliedDeliverySchema, l as logLevelSchema, s as stateRecordSchema, k as stateValueSchema } from './ports-plO5MKrY.js';
3
- export { D as DeterministicIdOptions, F as FixedClock, a as FixedClockOptions, I as InMemoryStateStore, b as InMemoryStateStoreOptions, L as LogRecord, R as RecordingLogger, c as RecordingTelemetrySink, d as RecordingTelemetrySinkOptions, e as createDeterministicIdGenerator, f as createFixedClock, g as createInMemoryStateStore, h as createNullTelemetrySink, i as createRandomIdGenerator, j as createRecordingLogger, k as createRecordingTelemetrySink, l as createSystemClock } from './memory-aJilVG4R.js';
4
- export { C as CumulativeUsageSeries, D as DeliveryDurability, a as DeliveryOrigin, b as DeliveryResolution, c as DeliveryUnavailableReason, H as HookIngestInput, d as HookIngestOptions, e as HookIngestOutcome, O as OtelHook, f as OtelHookDependencies, R as ResolvedDeliveryIdentity, U as UsageObservation, g as UsageScope, h as classifyDurability, i as createOtelHook, j as hostDeliveryIdentity, k as isCommittable, r as resolveDeliveryIdentity, u as usageScopeSchema } from './hook-BAxXoKsp.js';
5
- import { b as CanonicalEvent, u as TargetHint } from './events-CSD_YiJ2.js';
1
+ import { c as LogLevel, d as Logger, W as WorktreeLocator, S as SessionContextReader, h as SessionContextSegment } from './ports-C3k_5eOQ.js';
2
+ export { A as AppliedDelivery, C as Clock, E as EventIdSeed, I as IdGenerator, a as InvocationIdSeed, L as LOG_LEVEL_RANK, b as LocatedWorktree, P as PayloadEnricher, e as PayloadEnrichment, f as PayloadEnrichmentInput, R as ReadCursor, g as SessionContextRequest, i as StateRecord, j as StateStore, k as StateValue, T as TelemetryEmitResult, l as TelemetrySink, m as appliedDeliverySchema, n as logLevelSchema, s as stateRecordSchema, o as stateValueSchema } from './ports-C3k_5eOQ.js';
3
+ export { D as DeterministicIdOptions, F as FixedClock, a as FixedClockOptions, I as InMemoryStateStore, b as InMemoryStateStoreOptions, L as LogRecord, R as RecordingLogger, c as RecordingTelemetrySink, d as RecordingTelemetrySinkOptions, e as createDeterministicIdGenerator, f as createFixedClock, g as createInMemoryStateStore, h as createNullTelemetrySink, i as createRandomIdGenerator, j as createRecordingLogger, k as createRecordingTelemetrySink, l as createSystemClock } from './memory-DdU1U91y.js';
4
+ export { C as CumulativeUsageSeries, D as DeliveryDurability, a as DeliveryOrigin, b as DeliveryResolution, c as DeliveryUnavailableReason, H as HookIngestInput, d as HookIngestOptions, e as HookIngestOutcome, O as OtelHook, f as OtelHookDependencies, R as ResolvedDeliveryIdentity, U as UsageObservation, g as UsageScope, h as classifyDurability, i as createOtelHook, j as hostDeliveryIdentity, k as isCommittable, r as resolveDeliveryIdentity, u as usageScopeSchema } from './hook-vM_cgqS2.js';
5
+ import { b as CanonicalEvent, u as TargetHint } from './events-fcomX6d5.js';
6
6
  import { d as EventId } from './primitives-CJ8-rn-f.js';
7
7
  import { P as PrivacyService } from './service-CbI9CObT.js';
8
8
  import 'zod';
9
9
  import './errors.js';
10
10
  import './taxonomy-DwhTtuWd.js';
11
- import './schema-CHb3GU1r.js';
11
+ import './schema-SpFM6YQY.js';
12
12
  import './identity-BrVBs901.js';
13
- import './adapter-B9RwW6TO.js';
13
+ import './adapter-DQiPu8xF.js';
14
14
  import './policy-CimmCfRp.js';
15
15
  import './content-M9xIKG7h.js';
16
- import './registry-C7XO4DzD.js';
16
+ import './registry-gyJqaWmp.js';
17
17
 
18
18
  declare const createNullLogger: () => Logger;
19
19
  type StderrLoggerOptions = {
@@ -121,4 +121,92 @@ type ResolveEventTargetsResult = {
121
121
  */
122
122
  declare const resolveEventTargets: (input: ResolveEventTargetsInput) => Promise<ResolveEventTargetsResult>;
123
123
 
124
- export { DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS, DEFAULT_WORKTREE_CACHE_TTL_MILLIS, type FilesystemWorktreeLocatorOptions, LogLevel, Logger, MAX_WORKTREE_WALK_DEPTH, type ResolveEventTargetsInput, type ResolveEventTargetsResult, type StderrLoggerOptions, WorktreeLocator, createFilesystemWorktreeLocator, createNullLogger, createStderrLogger, parseCommonDirFile, parseGitDirFile, parseHeadBranch, resolveEventTargets };
124
+ /**
125
+ * Session context: attributes a harness wants on every record of one agent
126
+ * session, for a window of time.
127
+ *
128
+ * A harness (HAR, or anything else) writes one JSON file per agent session:
129
+ *
130
+ * ```text
131
+ * <dir>/<agent-tool>/<session-id>.json
132
+ * { "version": 1, "agentTool": "claude_code", "sessionId": "…",
133
+ * "segments": [ { "from": "<ISO-8601>", "to": "<ISO-8601>" | null,
134
+ * "reason": "launch", "attributes": { "k": "v" } } ] }
135
+ * ```
136
+ *
137
+ * On every hook event the core reads the one file for the event's session,
138
+ * picks the segment in force at each event's time, and stamps its attributes on
139
+ * every record the event produces. otel-hook knows nothing about what the
140
+ * attributes mean: it applies an attribute map. See `docs/session-context.md`.
141
+ *
142
+ * Fail-open throughout: a missing, unreadable, oversized, invalid, or
143
+ * wrong-version file — or no segment in force — stamps nothing and never fails
144
+ * the hook.
145
+ */
146
+ /** The only file format version this build reads. Any other is ignored whole. */
147
+ declare const SESSION_CONTEXT_FILE_VERSION: 1;
148
+ /** Largest file read; anything bigger is ignored rather than truncated. */
149
+ declare const DEFAULT_SESSION_CONTEXT_MAX_BYTES: number;
150
+ /** Ceiling on one read; a slow filesystem costs the stamp, never the hook. */
151
+ declare const DEFAULT_SESSION_CONTEXT_BUDGET_MILLIS = 100;
152
+ /** Upper bound on segments considered in one file. */
153
+ declare const MAX_SESSION_CONTEXT_SEGMENTS = 1024;
154
+ /**
155
+ * otel-hook provider id → the agent-tool directory a harness writes under.
156
+ *
157
+ * The names are the ones HAR derives from the agent process it finds
158
+ * (`claude_code`, `codex`, `cursor`). A provider absent from this table has no
159
+ * session context: nothing is read for it.
160
+ */
161
+ declare const SESSION_CONTEXT_AGENT_TOOLS: Readonly<Record<string, string>>;
162
+ declare const sessionContextAgentTool: (providerId: string) => string | undefined;
163
+ declare const isSessionContextFileName: (sessionId: string) => boolean;
164
+ /**
165
+ * Where the context of one session lives, or `undefined` when the provider has
166
+ * no agent-tool directory or the session id cannot be a file name.
167
+ */
168
+ declare const sessionContextFilePath: (dir: string, providerId: string, sessionId: string) => string | undefined;
169
+ declare const isReservedSessionContextKey: (key: string) => boolean;
170
+ /**
171
+ * Screen one segment's attribute map: primitive values only, bounded, and no
172
+ * reserved or unsafe key. Dropped entries are dropped silently, one by one; the
173
+ * rest of the map still applies.
174
+ */
175
+ declare const sanitizeSessionContextAttributes: (attributes: Readonly<Record<string, unknown>>) => Readonly<Record<string, string | number | boolean>>;
176
+ /**
177
+ * Parse a decoded context file into screened segments.
178
+ *
179
+ * `expected` guards against a file that names another session or tool than the
180
+ * one it was read for (a copy, a misplaced write): such a file applies to
181
+ * nobody. Returns `undefined` for anything invalid; never throws.
182
+ */
183
+ declare const parseSessionContextFile: (value: unknown, expected?: {
184
+ readonly agentTool?: string;
185
+ readonly sessionId?: string;
186
+ }) => readonly SessionContextSegment[] | undefined;
187
+ /**
188
+ * The segment in force at `at`: `from <= at` and (`to` is null or `at < to`).
189
+ * Should a writer ever leave two overlapping, the one that started last wins,
190
+ * because it is the more recent statement.
191
+ */
192
+ declare const segmentInForce: (segments: readonly SessionContextSegment[], at: number) => SessionContextSegment | undefined;
193
+ /**
194
+ * Stamp each event with the attributes of the segment in force at its own
195
+ * `occurredAt`, and strip any `contextAttributes` an event already carried: only
196
+ * this core step may set them. An event with no segment in force, or one whose
197
+ * segment has no usable attribute, carries none.
198
+ */
199
+ declare const stampSessionContext: (events: readonly CanonicalEvent[], segments: readonly SessionContextSegment[] | undefined) => readonly CanonicalEvent[];
200
+ type DirectorySessionContextReaderOptions = {
201
+ /** Absolute directory holding `<agent-tool>/<session-id>.json`. */
202
+ readonly dir: string;
203
+ readonly maxBytes?: number;
204
+ readonly budgetMillis?: number;
205
+ };
206
+ /**
207
+ * The filesystem {@link SessionContextReader}: one bounded read of one file per
208
+ * call, never a directory scan. Never throws.
209
+ */
210
+ declare const createDirectorySessionContextReader: (options: DirectorySessionContextReaderOptions) => SessionContextReader;
211
+
212
+ export { DEFAULT_SESSION_CONTEXT_BUDGET_MILLIS, DEFAULT_SESSION_CONTEXT_MAX_BYTES, DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS, DEFAULT_WORKTREE_CACHE_TTL_MILLIS, type DirectorySessionContextReaderOptions, type FilesystemWorktreeLocatorOptions, LogLevel, Logger, MAX_SESSION_CONTEXT_SEGMENTS, MAX_WORKTREE_WALK_DEPTH, type ResolveEventTargetsInput, type ResolveEventTargetsResult, SESSION_CONTEXT_AGENT_TOOLS, SESSION_CONTEXT_FILE_VERSION, SessionContextReader, SessionContextSegment, type StderrLoggerOptions, WorktreeLocator, createDirectorySessionContextReader, createFilesystemWorktreeLocator, createNullLogger, createStderrLogger, isReservedSessionContextKey, isSessionContextFileName, parseCommonDirFile, parseGitDirFile, parseHeadBranch, parseSessionContextFile, resolveEventTargets, sanitizeSessionContextAttributes, segmentInForce, sessionContextAgentTool, sessionContextFilePath, stampSessionContext };