@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,224 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Policy for the OTLP logs signal.
5
+ *
6
+ * Two switches rather than one, because they answer different questions and an
7
+ * operator needs to be able to answer them differently:
8
+ *
9
+ * - `enabled` — whether a second signal leaves this host at all. Off by default:
10
+ * an installation that upgrades must not silently start sending a new stream to a
11
+ * collector whose receivers, quotas, and retention were sized for traces.
12
+ * - `includeContent` — whether *disclosed* text may appear in a log body. Also off
13
+ * by default, and deliberately not the same knob as `privacy.contentMode`: spans
14
+ * carry no content in any content mode, so an installation that set
15
+ * `contentMode` to get a hash and a length has never had content on the wire.
16
+ * Reusing that setting to also mean "publish prompts" would change what an
17
+ * existing configuration discloses without anybody editing it.
18
+ *
19
+ * `raw` content additionally requires the pre-existing `privacy.allowRawContent`
20
+ * opt-in, which the privacy service enforces before a fact is ever built and the
21
+ * log mapping re-checks at the wire.
22
+ */
23
+ declare const logsPolicySchema: z.ZodObject<{
24
+ enabled: z.ZodBoolean;
25
+ endpoint: z.ZodOptional<z.ZodString>;
26
+ includeContent: z.ZodBoolean;
27
+ maxBatchSize: z.ZodNumber;
28
+ }, z.core.$strict>;
29
+ type LogsPolicy = z.infer<typeof logsPolicySchema>;
30
+ declare const DEFAULT_LOGS_POLICY: LogsPolicy;
31
+ /**
32
+ * Runtime exporter policy.
33
+ *
34
+ * This describes *where and how* telemetry goes. It deliberately contains no
35
+ * session, invocation, or workspace field: see ADR 0001. Mixing the two would
36
+ * make identity globally reachable through configuration.
37
+ */
38
+ declare const exporterPolicySchema: z.ZodObject<{
39
+ enabled: z.ZodBoolean;
40
+ protocol: z.ZodEnum<{
41
+ none: "none";
42
+ "http/protobuf": "http/protobuf";
43
+ "http/json": "http/json";
44
+ }>;
45
+ endpoint: z.ZodOptional<z.ZodString>;
46
+ headerNames: z.ZodReadonly<z.ZodArray<z.ZodString>>;
47
+ timeoutMillis: z.ZodNumber;
48
+ maxBatchSize: z.ZodNumber;
49
+ maxQueueSize: z.ZodNumber;
50
+ maxRetryAttempts: z.ZodNumber;
51
+ serviceName: z.ZodString;
52
+ serviceNamespace: z.ZodOptional<z.ZodString>;
53
+ resourceAttributes: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
54
+ logs: z.ZodObject<{
55
+ enabled: z.ZodBoolean;
56
+ endpoint: z.ZodOptional<z.ZodString>;
57
+ includeContent: z.ZodBoolean;
58
+ maxBatchSize: z.ZodNumber;
59
+ }, z.core.$strict>;
60
+ }, z.core.$strict>;
61
+ type ExporterPolicy = z.infer<typeof exporterPolicySchema>;
62
+ declare const detectionPolicySchema: z.ZodObject<{
63
+ minimumConfidence: z.ZodEnum<{
64
+ none: "none";
65
+ weak: "weak";
66
+ strong: "strong";
67
+ exact: "exact";
68
+ }>;
69
+ allowAmbiguousFallback: z.ZodBoolean;
70
+ allowedProviderIds: z.ZodReadonly<z.ZodArray<z.ZodString>>;
71
+ }, z.core.$strict>;
72
+ type DetectionPolicy = z.infer<typeof detectionPolicySchema>;
73
+ declare const diagnosticsPolicySchema: z.ZodObject<{
74
+ logLevel: z.ZodEnum<{
75
+ error: "error";
76
+ silent: "silent";
77
+ warn: "warn";
78
+ info: "info";
79
+ debug: "debug";
80
+ }>;
81
+ emitErrorEvents: z.ZodBoolean;
82
+ }, z.core.$strict>;
83
+ type DiagnosticsPolicy = z.infer<typeof diagnosticsPolicySchema>;
84
+ declare const otelHookConfigSchema: z.ZodObject<{
85
+ exporter: z.ZodObject<{
86
+ enabled: z.ZodBoolean;
87
+ protocol: z.ZodEnum<{
88
+ none: "none";
89
+ "http/protobuf": "http/protobuf";
90
+ "http/json": "http/json";
91
+ }>;
92
+ endpoint: z.ZodOptional<z.ZodString>;
93
+ headerNames: z.ZodReadonly<z.ZodArray<z.ZodString>>;
94
+ timeoutMillis: z.ZodNumber;
95
+ maxBatchSize: z.ZodNumber;
96
+ maxQueueSize: z.ZodNumber;
97
+ maxRetryAttempts: z.ZodNumber;
98
+ serviceName: z.ZodString;
99
+ serviceNamespace: z.ZodOptional<z.ZodString>;
100
+ resourceAttributes: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
101
+ logs: z.ZodObject<{
102
+ enabled: z.ZodBoolean;
103
+ endpoint: z.ZodOptional<z.ZodString>;
104
+ includeContent: z.ZodBoolean;
105
+ maxBatchSize: z.ZodNumber;
106
+ }, z.core.$strict>;
107
+ }, z.core.$strict>;
108
+ privacy: z.ZodObject<{
109
+ contentMode: z.ZodEnum<{
110
+ raw: "raw";
111
+ omit: "omit";
112
+ mask: "mask";
113
+ redact: "redact";
114
+ }>;
115
+ allowRawContent: z.ZodBoolean;
116
+ hashSalt: z.ZodString;
117
+ maskCharacter: z.ZodString;
118
+ redactionPlaceholder: z.ZodString;
119
+ secretKeyPatterns: z.ZodReadonly<z.ZodArray<z.ZodString>>;
120
+ secretValuePatterns: z.ZodReadonly<z.ZodArray<z.ZodString>>;
121
+ limits: z.ZodObject<{
122
+ maxStringLength: z.ZodNumber;
123
+ maxDepth: z.ZodNumber;
124
+ maxArrayLength: z.ZodNumber;
125
+ maxEventsPerInvocation: z.ZodNumber;
126
+ maxObjectKeys: z.ZodNumber;
127
+ }, z.core.$strict>;
128
+ }, z.core.$strict>;
129
+ detection: z.ZodObject<{
130
+ minimumConfidence: z.ZodEnum<{
131
+ none: "none";
132
+ weak: "weak";
133
+ strong: "strong";
134
+ exact: "exact";
135
+ }>;
136
+ allowAmbiguousFallback: z.ZodBoolean;
137
+ allowedProviderIds: z.ZodReadonly<z.ZodArray<z.ZodString>>;
138
+ }, z.core.$strict>;
139
+ diagnostics: z.ZodObject<{
140
+ logLevel: z.ZodEnum<{
141
+ error: "error";
142
+ silent: "silent";
143
+ warn: "warn";
144
+ info: "info";
145
+ debug: "debug";
146
+ }>;
147
+ emitErrorEvents: z.ZodBoolean;
148
+ }, z.core.$strict>;
149
+ }, z.core.$strict>;
150
+ type OtelHookConfig = z.infer<typeof otelHookConfigSchema>;
151
+ /** Partial overlay accepted from a configuration layer. */
152
+ declare const otelHookConfigPatchSchema: z.ZodObject<{
153
+ exporter: z.ZodOptional<z.ZodObject<{
154
+ serviceName: z.ZodOptional<z.ZodString>;
155
+ serviceNamespace: z.ZodOptional<z.ZodOptional<z.ZodString>>;
156
+ enabled: z.ZodOptional<z.ZodBoolean>;
157
+ protocol: z.ZodOptional<z.ZodEnum<{
158
+ none: "none";
159
+ "http/protobuf": "http/protobuf";
160
+ "http/json": "http/json";
161
+ }>>;
162
+ endpoint: z.ZodOptional<z.ZodOptional<z.ZodString>>;
163
+ maxBatchSize: z.ZodOptional<z.ZodNumber>;
164
+ headerNames: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
165
+ timeoutMillis: z.ZodOptional<z.ZodNumber>;
166
+ maxQueueSize: z.ZodOptional<z.ZodNumber>;
167
+ maxRetryAttempts: z.ZodOptional<z.ZodNumber>;
168
+ resourceAttributes: z.ZodOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
169
+ logs: z.ZodOptional<z.ZodObject<{
170
+ enabled: z.ZodOptional<z.ZodBoolean>;
171
+ endpoint: z.ZodOptional<z.ZodOptional<z.ZodString>>;
172
+ includeContent: z.ZodOptional<z.ZodBoolean>;
173
+ maxBatchSize: z.ZodOptional<z.ZodNumber>;
174
+ }, z.core.$strict>>;
175
+ }, z.core.$strict>>;
176
+ privacy: z.ZodOptional<z.ZodObject<{
177
+ contentMode: z.ZodOptional<z.ZodEnum<{
178
+ raw: "raw";
179
+ omit: "omit";
180
+ mask: "mask";
181
+ redact: "redact";
182
+ }>>;
183
+ allowRawContent: z.ZodOptional<z.ZodBoolean>;
184
+ hashSalt: z.ZodOptional<z.ZodString>;
185
+ maskCharacter: z.ZodOptional<z.ZodString>;
186
+ redactionPlaceholder: z.ZodOptional<z.ZodString>;
187
+ secretKeyPatterns: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
188
+ secretValuePatterns: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
189
+ limits: z.ZodOptional<z.ZodObject<{
190
+ maxStringLength: z.ZodOptional<z.ZodNumber>;
191
+ maxDepth: z.ZodOptional<z.ZodNumber>;
192
+ maxArrayLength: z.ZodOptional<z.ZodNumber>;
193
+ maxEventsPerInvocation: z.ZodOptional<z.ZodNumber>;
194
+ maxObjectKeys: z.ZodOptional<z.ZodNumber>;
195
+ }, z.core.$strict>>;
196
+ }, z.core.$strict>>;
197
+ detection: z.ZodOptional<z.ZodObject<{
198
+ minimumConfidence: z.ZodOptional<z.ZodEnum<{
199
+ none: "none";
200
+ weak: "weak";
201
+ strong: "strong";
202
+ exact: "exact";
203
+ }>>;
204
+ allowAmbiguousFallback: z.ZodOptional<z.ZodBoolean>;
205
+ allowedProviderIds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
206
+ }, z.core.$strict>>;
207
+ diagnostics: z.ZodOptional<z.ZodObject<{
208
+ logLevel: z.ZodOptional<z.ZodEnum<{
209
+ error: "error";
210
+ silent: "silent";
211
+ warn: "warn";
212
+ info: "info";
213
+ debug: "debug";
214
+ }>>;
215
+ emitErrorEvents: z.ZodOptional<z.ZodBoolean>;
216
+ }, z.core.$strict>>;
217
+ }, z.core.$strict>;
218
+ type OtelHookConfigPatch = z.infer<typeof otelHookConfigPatchSchema>;
219
+ declare const DEFAULT_EXPORTER_POLICY: ExporterPolicy;
220
+ declare const DEFAULT_DETECTION_POLICY: DetectionPolicy;
221
+ declare const DEFAULT_DIAGNOSTICS_POLICY: DiagnosticsPolicy;
222
+ declare const DEFAULT_CONFIG: OtelHookConfig;
223
+
224
+ export { DEFAULT_CONFIG as D, type ExporterPolicy as E, type LogsPolicy as L, type OtelHookConfig as O, DEFAULT_DETECTION_POLICY as a, DEFAULT_DIAGNOSTICS_POLICY as b, DEFAULT_EXPORTER_POLICY as c, DEFAULT_LOGS_POLICY as d, type DetectionPolicy as e, type DiagnosticsPolicy as f, type OtelHookConfigPatch as g, detectionPolicySchema as h, diagnosticsPolicySchema as i, exporterPolicySchema as j, otelHookConfigSchema as k, logsPolicySchema as l, otelHookConfigPatchSchema as o };
@@ -0,0 +1,188 @@
1
+ import { Attributes } from '@opentelemetry/api';
2
+ import { InstrumentationScope } from '@opentelemetry/core';
3
+ import { Resource } from '@opentelemetry/resources';
4
+ import { ReadableSpan } from '@opentelemetry/sdk-trace';
5
+ import { b as CanonicalEvent } from './events-VxBnDFaO.js';
6
+
7
+ declare const DEFAULT_INSTRUMENTATION_SCOPE: InstrumentationScope;
8
+ /** Lifecycle scopes that pair a `*.start` edge with a later `*.end` edge. */
9
+ type SpanFamily = "session" | "generation" | "tool" | "subagent";
10
+ /** Identifies one lifecycle span within a session. */
11
+ type SpanScopeRef = {
12
+ readonly family: SpanFamily;
13
+ readonly scopeKey: string;
14
+ };
15
+ /**
16
+ * Why a lifecycle span is, or is not, a complete pair.
17
+ *
18
+ * Deliberately explicit rather than a bare boolean: "we never saw the start",
19
+ * "we saw it but it aged out of state", and "state could not be read at all"
20
+ * are different operational facts, and a dashboard that cannot tell them apart
21
+ * cannot tell a broken host from a broken exporter.
22
+ */
23
+ type SpanOrphanClassification =
24
+ /** Both edges are known — from this batch, or from persisted state. */
25
+ "none"
26
+ /** The start is known; its end has not arrived yet. */
27
+ | "missing-end"
28
+ /** An end arrived and no start was ever recorded for this scope. */
29
+ | "missing-start"
30
+ /** A start was recorded but aged past the retention window before the end arrived. */
31
+ | "expired-start"
32
+ /** A start exists but was recorded by a different provider; pairing it would be a guess. */
33
+ | "provider-mismatch"
34
+ /** A second, distinct end arrived for a scope that was already closed. */
35
+ | "already-closed"
36
+ /** The persisted record was written by an incompatible version and was discarded. */
37
+ | "state-incompatible"
38
+ /** The persisted record could not be understood. */
39
+ | "state-corrupt"
40
+ /** State could not be consulted at all; the mapping degraded rather than failing. */
41
+ | "state-unavailable";
42
+ type SpanPairing =
43
+ /** Both edges were present in this batch. */
44
+ "in-batch"
45
+ /** The other edge came from state written by an earlier process. */
46
+ | "cross-process" | "unpaired";
47
+ /**
48
+ * Whether this scope should produce an OTLP record now.
49
+ *
50
+ * OTLP has no notion of updating a span: a span is exported once, when it ends,
51
+ * and a second record carrying the same trace and span id is not a revision of
52
+ * the first — it is a duplicate that backends variously drop, keep the older of,
53
+ * or display twice. Since every lifecycle span id here is *derived* from
54
+ * `(provider, session, family, scopeKey)`, a `*.start` edge and its later `*.end`
55
+ * edge compute the identical id, so exporting on both is precisely that
56
+ * duplicate.
57
+ *
58
+ * `defer` is therefore the answer for a start whose end has not arrived: the
59
+ * start is durable in the state store, and the end edge exports the one complete
60
+ * span using the times recovered from it. Nothing is lost by waiting, and what is
61
+ * gained is that the record a collector receives has a real duration.
62
+ */
63
+ type SpanDisposition =
64
+ /** Export a record for this scope now. */
65
+ "emit"
66
+ /** Hold: the start is recorded, and the end edge will export the complete span. */
67
+ | "defer";
68
+ /**
69
+ * One scope's correlation facts, resolved from persisted state by the caller.
70
+ *
71
+ * Plain data on purpose: the telemetry layer must not reach into the state
72
+ * store itself (ADR 0006), so it declares what it needs and the lifecycle layer
73
+ * supplies it.
74
+ */
75
+ type SpanCorrelation = {
76
+ readonly providerId: string;
77
+ readonly sessionId: string;
78
+ readonly ref: SpanScopeRef;
79
+ readonly pairing: SpanPairing;
80
+ readonly orphan: SpanOrphanClassification;
81
+ /**
82
+ * Whether to export a record for this scope now. Defaults to `emit` when a
83
+ * correlation is supplied without one.
84
+ */
85
+ readonly disposition?: SpanDisposition;
86
+ /**
87
+ * Extra component mixed into the derived span id.
88
+ *
89
+ * Set only when this record is a genuinely *additional* observation of a scope
90
+ * that has already been exported once — a second, distinct end for a scope that
91
+ * was already closed. Both records are real, so neither is dropped, and the
92
+ * discriminator keeps them from claiming the same span id.
93
+ */
94
+ readonly spanIdDiscriminator?: string;
95
+ /** Start recovered from state; authoritative over the batch's own start edge. */
96
+ readonly startMillis?: number;
97
+ /** End recovered from state; authoritative so a redelivered end re-exports an identical span. */
98
+ readonly endMillis?: number;
99
+ /** Parent recorded at start time, so an end-only process hangs the span in the same place. */
100
+ readonly parent?: SpanScopeRef;
101
+ /** Attributes only the start edge could supply, recovered for an end-only span. */
102
+ readonly attributes?: Attributes;
103
+ };
104
+ /**
105
+ * Resolves persisted correlation for one batch.
106
+ *
107
+ * Must never reject: a state failure is a degraded span, never a lost export.
108
+ */
109
+ type SpanCorrelationResolver = (events: readonly CanonicalEvent[]) => Promise<readonly SpanCorrelation[]>;
110
+ /**
111
+ * Upper bound on how many start-edge attributes the correlator may carry
112
+ * forward, so persisted state cannot grow with provider-controlled input.
113
+ */
114
+ declare const MAX_RECOVERED_START_ATTRIBUTES = 16;
115
+ /** The lifecycle span an event is an edge of, or undefined for a point-in-time event. */
116
+ declare const spanScopeRefOf: (event: CanonicalEvent) => SpanScopeRef | undefined;
117
+ /**
118
+ * Where a span hangs in the trace, judged from this event alone.
119
+ *
120
+ * Everything in a session descends from the session span. A tool call names its
121
+ * generation only on `tool.start`, which is exactly why the correlator persists
122
+ * the parent: the `tool.end` process would otherwise reparent the same span to
123
+ * the session and produce a tree whose shape depends on which edge happened to
124
+ * be exported last.
125
+ */
126
+ declare const parentScopeRefOf: (event: CanonicalEvent) => SpanScopeRef | undefined;
127
+ /**
128
+ * Span attributes that only a `*.start` edge can supply.
129
+ *
130
+ * The correlator persists these verbatim so an end-only span in a later process
131
+ * still carries the tool kind, requested model, delegation depth, or agent name
132
+ * the start process saw. An allowlist, and bounded, so persisted state can
133
+ * never become a second route for provider payload content to escape.
134
+ */
135
+ declare const startOnlySpanAttributes: (event: CanonicalEvent) => Attributes;
136
+ type SemanticMappingOptions = {
137
+ readonly resource: Resource;
138
+ readonly instrumentationScope?: InstrumentationScope;
139
+ /**
140
+ * Cross-process pairing facts, at most one entry per lifecycle scope in
141
+ * `events`. Omitted entirely, the mapping degrades to in-batch pairing only —
142
+ * the behavior of a host that wired no state store.
143
+ */
144
+ readonly correlations?: readonly SpanCorrelation[];
145
+ /**
146
+ * Whether a correlator was consulted at all, and whether it answered.
147
+ *
148
+ * This is what separates "the state store is holding this start, so the end edge
149
+ * will publish it" from "nothing recorded this start". Both look like an empty
150
+ * `correlations` list, and only the first is safe to drop — dropping the second
151
+ * would discard an observation that was neither persisted nor exported, while a
152
+ * caller that saw zero rejections went on to mark the callback handled.
153
+ *
154
+ * - `true` — the correlator ran; an absent or non-`defer` entry means emit.
155
+ * - `false` — the correlator failed; every unpaired start is emitted as an
156
+ * explicitly labelled, uniquely identified fallback.
157
+ * - omitted — no correlator is wired, so cross-process pairing was never on
158
+ * offer and an unpaired start is deferred (the documented no-state-root
159
+ * degradation).
160
+ */
161
+ readonly correlationAvailable?: boolean;
162
+ };
163
+ /** Trace and span a record derived from one canonical event belongs to. */
164
+ type EventTraceIdentity = {
165
+ readonly traceId: string;
166
+ readonly spanId: string;
167
+ };
168
+ /**
169
+ * Resolve the trace and span identity of every event in one batch.
170
+ *
171
+ * Exposed for signals other than traces — a log record correlates by carrying
172
+ * the *same* derived ids the span mapping would compute, including the deferred
173
+ * and discriminated cases. Whole batch at once because a start's identity
174
+ * depends on whether its end is in the same batch.
175
+ *
176
+ * Both ids come from the event's own `(providerId, sessionId)`, never from a
177
+ * batch-level or module-level value, which is what makes cross-session
178
+ * contamination structurally impossible: two sessions in one batch derive two
179
+ * different trace ids.
180
+ */
181
+ declare const canonicalEventTraceIdentities: (events: readonly CanonicalEvent[], options?: {
182
+ readonly correlations?: readonly SpanCorrelation[];
183
+ readonly correlationAvailable?: boolean;
184
+ }) => ReadonlyMap<string, EventTraceIdentity>;
185
+ /** Maps one invocation's canonical event batch into OTLP-ready spans. */
186
+ declare const canonicalEventsToReadableSpans: (events: readonly CanonicalEvent[], options: SemanticMappingOptions) => readonly ReadableSpan[];
187
+
188
+ export { DEFAULT_INSTRUMENTATION_SCOPE as D, type EventTraceIdentity as E, MAX_RECOVERED_START_ATTRIBUTES as M, type SemanticMappingOptions as S, type SpanCorrelation as a, type SpanCorrelationResolver as b, type SpanDisposition as c, type SpanFamily as d, type SpanOrphanClassification as e, type SpanPairing as f, type SpanScopeRef as g, canonicalEventTraceIdentities as h, canonicalEventsToReadableSpans as i, startOnlySpanAttributes as j, parentScopeRefOf as p, spanScopeRefOf as s };
@@ -0,0 +1,68 @@
1
+ import { c as ContentKind, d as ContentRole, b as ContentFact } from './content-CoB7aNP1.js';
2
+ import { b as Attributes, a as AttributeValue } from './primitives-CJ8-rn-f.js';
3
+ import { f as PrivacyPolicy } from './policy-D1CrlYn3.js';
4
+
5
+ type SanitizedValue = string | number | boolean | null | readonly SanitizedValue[] | {
6
+ readonly [key: string]: SanitizedValue;
7
+ };
8
+ type SanitizeStats = {
9
+ readonly truncatedStrings: number;
10
+ readonly truncatedArrays: number;
11
+ readonly truncatedObjects: number;
12
+ readonly redactedKeys: number;
13
+ readonly depthExceeded: number;
14
+ readonly droppedValues: number;
15
+ readonly circularReferences: number;
16
+ };
17
+ type SanitizeResult = {
18
+ readonly value: SanitizedValue;
19
+ readonly stats: SanitizeStats;
20
+ };
21
+ type DescribeContentInput = {
22
+ readonly kind: ContentKind;
23
+ readonly text: string;
24
+ readonly role?: ContentRole;
25
+ readonly label?: string;
26
+ };
27
+ type DescribeStructuredInput = {
28
+ readonly kind: ContentKind;
29
+ readonly value: unknown;
30
+ readonly role?: ContentRole;
31
+ readonly label?: string;
32
+ };
33
+ type SanitizeExtensionsResult = {
34
+ readonly extensions: Record<string, AttributeValue>;
35
+ readonly droppedKeys: readonly string[];
36
+ };
37
+ /**
38
+ * Single point through which every piece of potentially sensitive data passes.
39
+ *
40
+ * Provider adapters receive this service and are expected to describe content
41
+ * with it rather than copying text into events themselves. That keeps the
42
+ * disclosure decision in one auditable place.
43
+ */
44
+ interface PrivacyService {
45
+ readonly policy: PrivacyPolicy;
46
+ /** Notes about deterministic policy downgrades applied at construction. */
47
+ readonly policyNotes: readonly string[];
48
+ /** Stable salted digest, formatted `sha256:<hex>`. */
49
+ hash(value: string): string;
50
+ /** Opaque namespaced handle suitable for a workspace or resource id. */
51
+ deriveOpaqueId(namespace: string, value: string): string;
52
+ describeContent(input: DescribeContentInput): ContentFact;
53
+ describeStructured(input: DescribeStructuredInput): ContentFact;
54
+ isSecretKey(key: string): boolean;
55
+ sanitizeStructured(value: unknown): SanitizeResult;
56
+ /** Attribute-safe projection of a sanitized value, with dotted paths. */
57
+ flattenToAttributes(value: SanitizedValue, prefix: string): Attributes;
58
+ sanitizeAttributes(value: Readonly<Record<string, unknown>>): Attributes;
59
+ sanitizeExtensions(value: Readonly<Record<string, unknown>>): SanitizeExtensionsResult;
60
+ /** Bound a string to the policy limit, reporting whether it was cut. */
61
+ boundString(value: string): {
62
+ readonly text: string;
63
+ readonly truncated: boolean;
64
+ };
65
+ }
66
+ declare const createPrivacyService: (policyInput: PrivacyPolicy) => PrivacyService;
67
+
68
+ export { type DescribeContentInput as D, type PrivacyService as P, type SanitizeExtensionsResult as S, type DescribeStructuredInput as a, type SanitizeResult as b, type SanitizeStats as c, type SanitizedValue as d, createPrivacyService as e };
@@ -0,0 +1,36 @@
1
+ export { S as StoreNamespace } from './keys-Dej5bN3L.js';
2
+ import { L as LockingStateStore } from './filesystem-store-J8jjDMTh.js';
3
+ export { F as FilesystemStateStore, a as FilesystemStateStoreOptions, S as StateStoreDependencies, c as createFilesystemStateStore, i as isLockingStateStore, w as withOptionalSessionLock } from './filesystem-store-J8jjDMTh.js';
4
+ import { C as Clock } from './ports-Q8x0ODhs.js';
5
+ import 'zod';
6
+ import './errors.js';
7
+ import './primitives-CJ8-rn-f.js';
8
+ import './taxonomy-DwhTtuWd.js';
9
+ import './events-VxBnDFaO.js';
10
+
11
+ type BoundedMemoryStateStoreOptions = {
12
+ readonly clock: Clock;
13
+ /** Oldest entry is evicted once this many keys are held. Default 10,000. */
14
+ readonly maxEntries?: number;
15
+ /** When set, a record older than this is treated as absent and dropped lazily. */
16
+ readonly ttlMillis?: number;
17
+ /** Bounds how long a `withSessionLock` call waits before rejecting. Default 5,000ms. */
18
+ readonly lockTimeoutMillis?: number;
19
+ };
20
+ interface BoundedMemoryStateStore extends LockingStateStore {
21
+ size(): number;
22
+ /** Actively removes expired entries; returns the count removed. */
23
+ pruneExpired(now?: number): number;
24
+ }
25
+ /**
26
+ * Production in-memory {@link StateStore}.
27
+ *
28
+ * Unlike the unbounded test double in `runtime/memory.ts`, this store is
29
+ * meant to back a long-lived host process: it bounds its own size and can
30
+ * expire entries by age, so a process that embeds many sessions over its
31
+ * lifetime cannot grow without limit. State does not survive a process
32
+ * restart; hosts that need it to should use the filesystem store instead.
33
+ */
34
+ declare const createBoundedMemoryStateStore: (options: BoundedMemoryStateStoreOptions) => BoundedMemoryStateStore;
35
+
36
+ export { type BoundedMemoryStateStore, type BoundedMemoryStateStoreOptions, LockingStateStore, createBoundedMemoryStateStore };