@osfactory/otel-hook 0.1.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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1020 -0
  3. package/dist/adapter-DIgRACtL.d.ts +303 -0
  4. package/dist/cli.js +12607 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/config.d.ts +233 -0
  7. package/dist/config.js +996 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/content-CoB7aNP1.d.ts +118 -0
  10. package/dist/diagnostics.d.ts +58 -0
  11. package/dist/diagnostics.js +46 -0
  12. package/dist/diagnostics.js.map +1 -0
  13. package/dist/errors.d.ts +91 -0
  14. package/dist/errors.js +322 -0
  15. package/dist/errors.js.map +1 -0
  16. package/dist/events-VxBnDFaO.d.ts +2044 -0
  17. package/dist/filesystem-store-J8jjDMTh.d.ts +65 -0
  18. package/dist/hook-CGpo-vks.d.ts +292 -0
  19. package/dist/identity-BrVBs901.d.ts +227 -0
  20. package/dist/index.d.ts +44 -0
  21. package/dist/index.js +11798 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/install.d.ts +1021 -0
  24. package/dist/install.js +3271 -0
  25. package/dist/install.js.map +1 -0
  26. package/dist/integration.d.ts +303 -0
  27. package/dist/integration.js +5942 -0
  28. package/dist/integration.js.map +1 -0
  29. package/dist/keys-Dej5bN3L.d.ts +7 -0
  30. package/dist/lifecycle.d.ts +428 -0
  31. package/dist/lifecycle.js +1077 -0
  32. package/dist/lifecycle.js.map +1 -0
  33. package/dist/memory-DXVBc8V9.d.ts +94 -0
  34. package/dist/model.d.ts +45 -0
  35. package/dist/model.js +1023 -0
  36. package/dist/model.js.map +1 -0
  37. package/dist/otlp-log-sink-CeIFDDpn.d.ts +457 -0
  38. package/dist/payload-CHr53E_v.d.ts +201 -0
  39. package/dist/policy-D1CrlYn3.d.ts +73 -0
  40. package/dist/ports-Q8x0ODhs.d.ts +200 -0
  41. package/dist/primitives-CJ8-rn-f.d.ts +75 -0
  42. package/dist/privacy.d.ts +51 -0
  43. package/dist/privacy.js +633 -0
  44. package/dist/privacy.js.map +1 -0
  45. package/dist/providers.d.ts +257 -0
  46. package/dist/providers.js +4398 -0
  47. package/dist/providers.js.map +1 -0
  48. package/dist/registry-BzYmC9OC.d.ts +49 -0
  49. package/dist/runtime.d.ts +32 -0
  50. package/dist/runtime.js +2907 -0
  51. package/dist/runtime.js.map +1 -0
  52. package/dist/schema-Cn0-xz8L.d.ts +224 -0
  53. package/dist/semconv-Baoz-0OI.d.ts +188 -0
  54. package/dist/service-j4jEO6cZ.d.ts +68 -0
  55. package/dist/state.d.ts +36 -0
  56. package/dist/state.js +710 -0
  57. package/dist/state.js.map +1 -0
  58. package/dist/taxonomy-DwhTtuWd.d.ts +87 -0
  59. package/dist/telemetry.d.ts +77 -0
  60. package/dist/telemetry.js +2294 -0
  61. package/dist/telemetry.js.map +1 -0
  62. package/dist/testing.d.ts +155 -0
  63. package/dist/testing.js +6513 -0
  64. package/dist/testing.js.map +1 -0
  65. package/package.json +124 -0
@@ -0,0 +1,155 @@
1
+ import { O as OtelHookConfig, g as OtelHookConfigPatch } from './schema-Cn0-xz8L.js';
2
+ import { b as CanonicalEvent } from './events-VxBnDFaO.js';
3
+ import { I as IdentityClaim, d as InvocationIdentity, S as SourceProvenance } from './identity-BrVBs901.js';
4
+ import { P as PrivacyService } from './service-j4jEO6cZ.js';
5
+ import { d as ProviderCapabilities, h as ProviderDetection, i as ProviderDetectionInput, e as ProviderContext, l as ProviderIdentityInput, f as ProviderDeliveryClaim, k as ProviderHookResponseInput, j as ProviderHookResponse, P as ProviderAdapter } from './adapter-DIgRACtL.js';
6
+ import { P as ProviderRegistry } from './registry-BzYmC9OC.js';
7
+ import { c as RecordingTelemetrySink, I as InMemoryStateStore, F as FixedClock, R as RecordingLogger } from './memory-DXVBc8V9.js';
8
+ export { e as createDeterministicIdGenerator, f as createFixedClock, g as createInMemoryStateStore, j as createRecordingLogger, k as createRecordingTelemetrySink } from './memory-DXVBc8V9.js';
9
+ import { O as OtelHook } from './hook-CGpo-vks.js';
10
+ import { I as IdGenerator } from './ports-Q8x0ODhs.js';
11
+ import { z } from 'zod';
12
+ import { a as ContentDisclosure, b as ContentFact } from './content-CoB7aNP1.js';
13
+ import './primitives-CJ8-rn-f.js';
14
+ import './policy-D1CrlYn3.js';
15
+ import './errors.js';
16
+ import './taxonomy-DwhTtuWd.js';
17
+
18
+ /**
19
+ * Synthetic hook payload used by the reference adapter.
20
+ *
21
+ * Provenance: invented for this repository. It resembles no real provider's
22
+ * protocol and contains no captured transcript, path, or credential.
23
+ */
24
+ declare const syntheticPayloadSchema: z.ZodObject<{
25
+ provider: z.ZodString;
26
+ sessionId: z.ZodString;
27
+ event: z.ZodEnum<{
28
+ prompt: "prompt";
29
+ tool: "tool";
30
+ "session.start": "session.start";
31
+ "session.end": "session.end";
32
+ subagent: "subagent";
33
+ generation: "generation";
34
+ compaction: "compaction";
35
+ noop: "noop";
36
+ }>;
37
+ requestId: z.ZodOptional<z.ZodString>;
38
+ model: z.ZodOptional<z.ZodString>;
39
+ promptText: z.ZodOptional<z.ZodString>;
40
+ toolName: z.ZodOptional<z.ZodString>;
41
+ toolInput: z.ZodOptional<z.ZodUnknown>;
42
+ workspaceKey: z.ZodOptional<z.ZodString>;
43
+ occurredAt: z.ZodOptional<z.ZodNumber>;
44
+ usage: z.ZodOptional<z.ZodObject<{
45
+ temporality: z.ZodEnum<{
46
+ delta: "delta";
47
+ cumulative: "cumulative";
48
+ }>;
49
+ inputTokens: z.ZodOptional<z.ZodNumber>;
50
+ cachedInputTokens: z.ZodOptional<z.ZodNumber>;
51
+ cacheCreationInputTokens: z.ZodOptional<z.ZodNumber>;
52
+ cacheCreationAccounting: z.ZodOptional<z.ZodEnum<{
53
+ "included-in-input": "included-in-input";
54
+ "disjoint-from-input": "disjoint-from-input";
55
+ "not-reported": "not-reported";
56
+ }>>;
57
+ outputTokens: z.ZodOptional<z.ZodNumber>;
58
+ reasoningOutputTokens: z.ZodOptional<z.ZodNumber>;
59
+ providerTotalTokens: z.ZodOptional<z.ZodNumber>;
60
+ }, z.core.$strict>>;
61
+ agentVersion: z.ZodOptional<z.ZodString>;
62
+ }, z.core.$strip>;
63
+ type SyntheticPayload = z.infer<typeof syntheticPayloadSchema>;
64
+ declare const SYNTHETIC_PROVIDER_ID: "fixture";
65
+ declare const DEFAULT_FIXTURE_CAPABILITIES: ProviderCapabilities;
66
+ type FixtureAdapterOptions = {
67
+ readonly id?: string;
68
+ readonly version?: string;
69
+ readonly capabilities?: Partial<ProviderCapabilities>;
70
+ /** Confidence reported when the payload matches this adapter's provider id. */
71
+ readonly confidence?: ProviderDetection["confidence"];
72
+ /** Replace detection entirely, e.g. to simulate an ambiguous registry. */
73
+ readonly detect?: (input: ProviderDetectionInput, context: ProviderContext) => ProviderDetection;
74
+ /** Extra claims merged after the adapter's own, e.g. to force a conflict. */
75
+ readonly extraClaims?: readonly IdentityClaim[];
76
+ /** Throw from the named method, to exercise containment. */
77
+ readonly throwOn?: "detect" | "identify" | "parse" | "hookResponse" | "deliveryIdentity";
78
+ /**
79
+ * Replace the delivery claim entirely, e.g. to return one the contract's own
80
+ * component guard must reject.
81
+ */
82
+ readonly deliveryIdentity?: (input: ProviderIdentityInput, context: ProviderContext) => ProviderDeliveryClaim | undefined;
83
+ /** Emit a provider-protocol stdout response instead of staying silent. */
84
+ readonly hookResponse?: (input: ProviderHookResponseInput, context: ProviderContext) => ProviderHookResponse;
85
+ };
86
+ /**
87
+ * Reference adapter over the synthetic payload above.
88
+ *
89
+ * Provider agents can use it to exercise the core contract — registry
90
+ * arbitration, identity resolution, privacy screening, usage derivation — without
91
+ * depending on any real provider protocol.
92
+ */
93
+ declare const createFixtureAdapter: (options?: FixtureAdapterOptions) => ProviderAdapter;
94
+
95
+ /** Every content fact attached to an event, regardless of field name. */
96
+ declare const collectEventContentFacts: (event: CanonicalEvent) => readonly ContentFact[];
97
+ /** Disclosed text across a batch, for assertions about what escaped. */
98
+ declare const collectContentText: (events: readonly CanonicalEvent[]) => readonly string[];
99
+ type ContentDisclosureViolation = {
100
+ readonly eventId: string;
101
+ readonly eventType: string;
102
+ readonly kind: string;
103
+ readonly disclosure: ContentDisclosure;
104
+ readonly reason: "unexpected-disclosure" | "inconsistent-fact";
105
+ };
106
+ /**
107
+ * Find content facts that disclose more than the expected mode allows.
108
+ *
109
+ * Provider suites are expected to assert this returns nothing under the default
110
+ * `omit` policy.
111
+ */
112
+ declare const findDisclosureViolations: (events: readonly CanonicalEvent[], expected?: ContentDisclosure) => readonly ContentDisclosureViolation[];
113
+ /**
114
+ * Search a serialized batch for a literal substring.
115
+ *
116
+ * Used to prove a secret or prompt fragment is absent from everything a sink
117
+ * would receive, including attributes and extensions.
118
+ */
119
+ declare const batchContains: (events: readonly CanonicalEvent[], needle: string) => boolean;
120
+
121
+ /** Deterministic provenance for hand-built events. */
122
+ declare const createTestProvenance: (overrides?: Partial<SourceProvenance>) => SourceProvenance;
123
+ /** Deterministic identity for hand-built events. */
124
+ declare const createTestIdentity: (overrides?: Partial<InvocationIdentity>) => InvocationIdentity;
125
+ declare const createTestPrivacyService: (patch?: Partial<OtelHookConfig["privacy"]>) => PrivacyService;
126
+ type TestHarnessOptions = {
127
+ readonly adapters?: readonly ProviderAdapter[];
128
+ readonly registry?: ProviderRegistry;
129
+ /** Shallow-merged over {@link DEFAULT_CONFIG}, then validated. */
130
+ readonly config?: OtelHookConfigPatch;
131
+ readonly clock?: FixedClock;
132
+ readonly ids?: IdGenerator;
133
+ readonly startMillis?: number;
134
+ readonly tickMillis?: number;
135
+ };
136
+ type TestHarness = {
137
+ readonly hook: OtelHook;
138
+ readonly sink: RecordingTelemetrySink;
139
+ readonly stateStore: InMemoryStateStore;
140
+ readonly clock: FixedClock;
141
+ readonly ids: IdGenerator;
142
+ readonly privacy: PrivacyService;
143
+ readonly logger: RecordingLogger;
144
+ readonly registry: ProviderRegistry;
145
+ readonly config: OtelHookConfig;
146
+ };
147
+ /**
148
+ * Fully wired hook backed by in-memory doubles and a deterministic clock.
149
+ *
150
+ * Nothing here reads the process environment, the filesystem, or the wall clock,
151
+ * so a provider test is reproducible on any machine.
152
+ */
153
+ declare const createTestHook: (options?: TestHarnessOptions) => TestHarness;
154
+
155
+ export { CanonicalEvent, type ContentDisclosureViolation, DEFAULT_FIXTURE_CAPABILITIES, FixedClock, type FixtureAdapterOptions, InMemoryStateStore, RecordingLogger, RecordingTelemetrySink, SYNTHETIC_PROVIDER_ID, type SyntheticPayload, type TestHarness, type TestHarnessOptions, batchContains, collectContentText, collectEventContentFacts, createFixtureAdapter, createTestHook, createTestIdentity, createTestPrivacyService, createTestProvenance, findDisclosureViolations, syntheticPayloadSchema };