@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.
- package/README.md +108 -4
- package/dist/{adapter-B9RwW6TO.d.ts → adapter-DQiPu8xF.d.ts} +2 -2
- package/dist/cli.js +1495 -135
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +11 -4
- package/dist/config.js +116 -21
- package/dist/config.js.map +1 -1
- package/dist/{destinations-DWOkVxV1.d.ts → destinations-DvqsPulb.d.ts} +12 -2
- package/dist/diagnostics.d.ts +1 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/{events-CSD_YiJ2.d.ts → events-fcomX6d5.d.ts} +22 -0
- package/dist/{export-destinations-lORbe25J.d.ts → export-destinations-CI7z4n3i.d.ts} +136 -6
- package/dist/{filesystem-store-DX3dGIgu.d.ts → filesystem-store-CmnUlj1O.d.ts} +1 -1
- package/dist/{hook-BAxXoKsp.d.ts → hook-vM_cgqS2.d.ts} +11 -5
- package/dist/index.d.ts +16 -16
- package/dist/index.js +1496 -183
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +4 -4
- package/dist/install.js +9 -1
- package/dist/install.js.map +1 -1
- package/dist/integration.d.ts +36 -12
- package/dist/integration.js +1464 -231
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.d.ts +55 -4
- package/dist/lifecycle.js +279 -5
- package/dist/lifecycle.js.map +1 -1
- package/dist/{memory-aJilVG4R.d.ts → memory-DdU1U91y.d.ts} +2 -2
- package/dist/{semconv-Dw7gcQcg.d.ts → metric-model-C9lLqqpI.d.ts} +157 -2
- package/dist/model.d.ts +1 -1
- package/dist/model.js +9 -1
- package/dist/model.js.map +1 -1
- package/dist/{payload-D7gc0-WQ.d.ts → payload-BT19hiVZ.d.ts} +1 -1
- package/dist/{ports-plO5MKrY.d.ts → ports-C3k_5eOQ.d.ts} +57 -2
- package/dist/providers.d.ts +10 -10
- package/dist/providers.js +10 -1
- package/dist/providers.js.map +1 -1
- package/dist/{registry-C7XO4DzD.d.ts → registry-gyJqaWmp.d.ts} +2 -2
- package/dist/runtime.d.ts +97 -9
- package/dist/runtime.js +312 -33
- package/dist/runtime.js.map +1 -1
- package/dist/{schema-CHb3GU1r.d.ts → schema-SpFM6YQY.d.ts} +87 -1
- package/dist/state.d.ts +4 -4
- package/dist/state.js +32 -1
- package/dist/state.js.map +1 -1
- package/dist/telemetry.d.ts +6 -6
- package/dist/telemetry.js +929 -31
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +11 -9
- package/dist/testing.js +164 -33
- package/dist/testing.js.map +1 -1
- package/package.json +3 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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-
|
|
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-
|
|
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,
|
|
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-
|
|
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-
|
|
5
|
-
import { b as CanonicalEvent, u as TargetHint } from './events-
|
|
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-
|
|
11
|
+
import './schema-SpFM6YQY.js';
|
|
12
12
|
import './identity-BrVBs901.js';
|
|
13
|
-
import './adapter-
|
|
13
|
+
import './adapter-DQiPu8xF.js';
|
|
14
14
|
import './policy-CimmCfRp.js';
|
|
15
15
|
import './content-M9xIKG7h.js';
|
|
16
|
-
import './registry-
|
|
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
|
-
|
|
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 };
|