@osfactory/otel-hook 0.3.0 → 0.5.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 (42) hide show
  1. package/dist/{adapter-DXpNtnaf.d.ts → adapter-BS7xHKGQ.d.ts} +9 -3
  2. package/dist/cli.js +1043 -487
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{events-VxBnDFaO.d.ts → events-CzZ5kukS.d.ts} +177 -1
  5. package/dist/{filesystem-store-J8jjDMTh.d.ts → filesystem-store-BcOveJYY.d.ts} +1 -1
  6. package/dist/{hook-_mlO3akA.d.ts → hook-DxTakjAD.d.ts} +12 -4
  7. package/dist/index.d.ts +12 -12
  8. package/dist/index.js +1171 -599
  9. package/dist/index.js.map +1 -1
  10. package/dist/install.d.ts +4 -4
  11. package/dist/install.js +103 -68
  12. package/dist/install.js.map +1 -1
  13. package/dist/integration.d.ts +14 -8
  14. package/dist/integration.js +547 -121
  15. package/dist/integration.js.map +1 -1
  16. package/dist/lifecycle.d.ts +3 -3
  17. package/dist/lifecycle.js +27 -2
  18. package/dist/lifecycle.js.map +1 -1
  19. package/dist/{memory-DXVBc8V9.d.ts → memory-DkTohdIa.d.ts} +2 -2
  20. package/dist/model.d.ts +1 -1
  21. package/dist/model.js +84 -41
  22. package/dist/model.js.map +1 -1
  23. package/dist/{otlp-log-sink-DTSa0KRF.d.ts → otlp-log-sink-DaZDPKnR.d.ts} +3 -3
  24. package/dist/{payload-BWV5-4n3.d.ts → payload-2lnpKodw.d.ts} +1 -1
  25. package/dist/{ports-Q8x0ODhs.d.ts → ports-B0rC49b3.d.ts} +28 -2
  26. package/dist/providers.d.ts +26 -9
  27. package/dist/providers.js +668 -452
  28. package/dist/providers.js.map +1 -1
  29. package/dist/{registry-Dqr3VNmT.d.ts → registry-DVnPA_b6.d.ts} +1 -1
  30. package/dist/runtime.d.ts +103 -11
  31. package/dist/runtime.js +416 -67
  32. package/dist/runtime.js.map +1 -1
  33. package/dist/{semconv-CIU-2kGO.d.ts → semconv-CtnDdsPk.d.ts} +1 -1
  34. package/dist/state.d.ts +4 -4
  35. package/dist/state.js.map +1 -1
  36. package/dist/telemetry.d.ts +6 -6
  37. package/dist/telemetry.js +92 -10
  38. package/dist/telemetry.js.map +1 -1
  39. package/dist/testing.d.ts +13 -7
  40. package/dist/testing.js +821 -492
  41. package/dist/testing.js.map +1 -1
  42. package/package.json +4 -1
@@ -1,6 +1,6 @@
1
1
  import { e as DetectionPolicy } from './schema-Cn0-xz8L.js';
2
2
  import { OtelHookErrorInfo } from './errors.js';
3
- import { P as ProviderAdapter, h as ProviderDetection, i as ProviderDetectionInput, e as ProviderContext } from './adapter-DXpNtnaf.js';
3
+ import { P as ProviderAdapter, h as ProviderDetection, i as ProviderDetectionInput, e as ProviderContext } from './adapter-BS7xHKGQ.js';
4
4
 
5
5
  type DetectionCandidate = {
6
6
  readonly adapter: ProviderAdapter;
package/dist/runtime.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- import { b as LogLevel, c as Logger } from './ports-Q8x0ODhs.js';
2
- export { A as AppliedDelivery, C as Clock, E as EventIdSeed, I as IdGenerator, a as InvocationIdSeed, L as LOG_LEVEL_RANK, S as StateRecord, d as StateStore, e as StateValue, T as TelemetryEmitResult, f as TelemetrySink, g as appliedDeliverySchema, l as logLevelSchema, s as stateRecordSchema, h as stateValueSchema } from './ports-Q8x0ODhs.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-DXVBc8V9.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-_mlO3akA.js';
1
+ import { c as LogLevel, d as Logger, W as WorktreeLocator } from './ports-B0rC49b3.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, S as StateRecord, e as StateStore, f as StateValue, T as TelemetryEmitResult, g as TelemetrySink, h as appliedDeliverySchema, l as logLevelSchema, s as stateRecordSchema, i as stateValueSchema } from './ports-B0rC49b3.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-DkTohdIa.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-DxTakjAD.js';
5
+ import { b as CanonicalEvent, T as TargetHint } from './events-CzZ5kukS.js';
6
+ import { d as EventId } from './primitives-CJ8-rn-f.js';
7
+ import { P as PrivacyService } from './service-CbI9CObT.js';
5
8
  import 'zod';
6
9
  import './errors.js';
7
- import './primitives-CJ8-rn-f.js';
8
10
  import './taxonomy-DwhTtuWd.js';
9
- import './events-VxBnDFaO.js';
10
11
  import './schema-Cn0-xz8L.js';
11
12
  import './identity-BrVBs901.js';
12
- import './service-CbI9CObT.js';
13
- import './content-M9xIKG7h.js';
13
+ import './adapter-BS7xHKGQ.js';
14
14
  import './policy-CimmCfRp.js';
15
- import './adapter-DXpNtnaf.js';
16
- import './registry-Dqr3VNmT.js';
15
+ import './content-M9xIKG7h.js';
16
+ import './registry-DVnPA_b6.js';
17
17
 
18
18
  declare const createNullLogger: () => Logger;
19
19
  type StderrLoggerOptions = {
@@ -29,4 +29,96 @@ type StderrLoggerOptions = {
29
29
  */
30
30
  declare const createStderrLogger: (options?: StderrLoggerOptions) => Logger;
31
31
 
32
- export { LogLevel, Logger, type StderrLoggerOptions, createNullLogger, createStderrLogger };
32
+ /**
33
+ * Filesystem {@link WorktreeLocator}: finds the git worktree containing a path
34
+ * by reading the files git itself reads, without spawning `git` (ADR 0008).
35
+ *
36
+ * From the path upward, the first directory holding a `.git` entry is the
37
+ * worktree root:
38
+ *
39
+ * - `.git` is a **directory** — the main worktree; its git dir is that directory.
40
+ * - `.git` is a **file** — a linked worktree (or a submodule): it holds
41
+ * `gitdir: <path>`, relative to the worktree root when not absolute.
42
+ *
43
+ * The branch is read from `<gitdir>/HEAD`: `ref: refs/heads/<name>` names a
44
+ * branch; anything else (a detached commit id) names none.
45
+ *
46
+ * Which repository the worktree belongs to is read the same way git reads it:
47
+ *
48
+ * - A git dir holding a `commondir` file is a **linked** worktree's; that file
49
+ * names the repository's common git dir, relative to the git dir. When the
50
+ * common dir is a directory named `.git`, its parent is the main worktree —
51
+ * the path `git worktree list` prints first. Any other common dir (a bare
52
+ * repository, a `--separate-git-dir` repository, a submodule's
53
+ * `.git/modules/<name>`) or one that no longer exists names no main worktree.
54
+ * - A git dir without one is a **main** worktree's, including a submodule's
55
+ * (`gitdir: <super>/.git/modules/<name>`): a submodule is its own repository,
56
+ * not a linked worktree of the superproject.
57
+ *
58
+ * A `.git` entry that cannot be read, points nowhere, or has no readable `HEAD`
59
+ * makes the answer `undefined` — a broken worktree is not evidence, and the walk
60
+ * does not skip past it to an enclosing repository that the event did not
61
+ * target. A repository that cannot be named costs only `mainRoot`.
62
+ *
63
+ * Everything is bounded: walk depth, bytes read per file, and cache size. Every
64
+ * failure is `undefined`; nothing throws.
65
+ */
66
+ /** Deepest directory chain walked before giving up. */
67
+ declare const MAX_WORKTREE_WALK_DEPTH = 128;
68
+ /** Default lifetime of a cached probe. Short: a branch can be switched. */
69
+ declare const DEFAULT_WORKTREE_CACHE_TTL_MILLIS = 5000;
70
+ /** `ref: refs/heads/<name>` → `<name>`; anything else → no branch. */
71
+ declare const parseHeadBranch: (head: string) => string | undefined;
72
+ /** `gitdir: <path>` → the path, resolved against the worktree root. */
73
+ declare const parseGitDirFile: (content: string, worktreeRoot: string) => string | undefined;
74
+ /** A `commondir` file → the common git dir it names, resolved against the git dir. */
75
+ declare const parseCommonDirFile: (content: string, gitDir: string) => string | undefined;
76
+ type FilesystemWorktreeLocatorOptions = {
77
+ /** Monotonic milliseconds for cache expiry. Defaults to `performance.now()`. */
78
+ readonly monotonicMillis?: () => number;
79
+ readonly cacheTtlMillis?: number;
80
+ };
81
+ /**
82
+ * Create a locator with its own cache. The cache is instance state, never
83
+ * module state: two hooks in one process do not share it.
84
+ */
85
+ declare const createFilesystemWorktreeLocator: (options?: FilesystemWorktreeLocatorOptions) => WorktreeLocator;
86
+
87
+ /**
88
+ * Turns adapters' target hints into exported worktree targets (ADR 0008).
89
+ *
90
+ * This is where local paths stop. A hint's paths are resolved to a worktree
91
+ * root, branch, and repository through the injected {@link WorktreeLocator};
92
+ * only salted `git-root` handles of the root and of its repository's main
93
+ * worktree, the worktree's kind, and the branch name survive onto the event.
94
+ *
95
+ * Fail-open in both directions that matter: a slow or failing filesystem costs
96
+ * the event its target, never the event — and never the host more than the
97
+ * time budget. Fail-closed on meaning: a hint whose paths land in two different
98
+ * worktrees, or that names a relative path with nothing to resolve it against,
99
+ * yields no target rather than a guess.
100
+ */
101
+ /** Default ceiling on target resolution per callback. */
102
+ declare const DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS = 50;
103
+ type ResolveEventTargetsInput = {
104
+ readonly events: readonly CanonicalEvent[];
105
+ readonly hints: ReadonlyMap<EventId, TargetHint>;
106
+ readonly locator: WorktreeLocator;
107
+ readonly privacy: PrivacyService;
108
+ readonly budgetMillis: number;
109
+ };
110
+ type ResolveEventTargetsResult = {
111
+ readonly events: readonly CanonicalEvent[];
112
+ /** Hints that produced a target. */
113
+ readonly resolved: number;
114
+ /** True when the time budget expired before every hint was answered. */
115
+ readonly timedOut: boolean;
116
+ };
117
+ /**
118
+ * Attach a `target` to each tool event that has a resolvable hint. Never
119
+ * throws or rejects; events without a hint, or whose hint does not resolve,
120
+ * are returned unchanged.
121
+ */
122
+ declare const resolveEventTargets: (input: ResolveEventTargetsInput) => Promise<ResolveEventTargetsResult>;
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 };