@osfactory/otel-hook 0.11.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 (49) hide show
  1. package/README.md +26 -1
  2. package/dist/{adapter-DiLknaTF.d.ts → adapter-DQiPu8xF.d.ts} +2 -2
  3. package/dist/cli.js +371 -65
  4. package/dist/cli.js.map +1 -1
  5. package/dist/config.d.ts +3 -3
  6. package/dist/config.js +16 -3
  7. package/dist/config.js.map +1 -1
  8. package/dist/{destinations-BIl3gGzx.d.ts → destinations-DvqsPulb.d.ts} +1 -1
  9. package/dist/{events-CSD_YiJ2.d.ts → events-fcomX6d5.d.ts} +22 -0
  10. package/dist/{export-destinations-QWKGGEjk.d.ts → export-destinations-CI7z4n3i.d.ts} +11 -6
  11. package/dist/{filesystem-store-D3SCNmbX.d.ts → filesystem-store-CmnUlj1O.d.ts} +1 -1
  12. package/dist/{hook-BOecWGSz.d.ts → hook-vM_cgqS2.d.ts} +11 -5
  13. package/dist/index.d.ts +14 -14
  14. package/dist/index.js +389 -100
  15. package/dist/index.js.map +1 -1
  16. package/dist/install.d.ts +4 -4
  17. package/dist/install.js +9 -1
  18. package/dist/install.js.map +1 -1
  19. package/dist/integration.d.ts +16 -10
  20. package/dist/integration.js +341 -71
  21. package/dist/integration.js.map +1 -1
  22. package/dist/lifecycle.d.ts +3 -3
  23. package/dist/lifecycle.js +10 -2
  24. package/dist/lifecycle.js.map +1 -1
  25. package/dist/{memory-Cs51jyRk.d.ts → memory-DdU1U91y.d.ts} +2 -2
  26. package/dist/{metric-model-DDnWxL9d.d.ts → metric-model-C9lLqqpI.d.ts} +4 -1
  27. package/dist/model.d.ts +1 -1
  28. package/dist/model.js +9 -1
  29. package/dist/model.js.map +1 -1
  30. package/dist/{payload-ChtrEX6A.d.ts → payload-BT19hiVZ.d.ts} +1 -1
  31. package/dist/{ports-CeqLq31i.d.ts → ports-C3k_5eOQ.d.ts} +33 -2
  32. package/dist/providers.d.ts +10 -10
  33. package/dist/providers.js +10 -1
  34. package/dist/providers.js.map +1 -1
  35. package/dist/{registry-CcJNF3WY.d.ts → registry-gyJqaWmp.d.ts} +2 -2
  36. package/dist/runtime.d.ts +97 -9
  37. package/dist/runtime.js +257 -24
  38. package/dist/runtime.js.map +1 -1
  39. package/dist/{schema-DMnoU1V_.d.ts → schema-SpFM6YQY.d.ts} +24 -1
  40. package/dist/state.d.ts +4 -4
  41. package/dist/state.js +9 -1
  42. package/dist/state.js.map +1 -1
  43. package/dist/telemetry.d.ts +6 -6
  44. package/dist/telemetry.js +77 -22
  45. package/dist/telemetry.js.map +1 -1
  46. package/dist/testing.d.ts +10 -8
  47. package/dist/testing.js +109 -24
  48. package/dist/testing.js.map +1 -1
  49. package/package.json +1 -1
@@ -157,6 +157,21 @@ declare const providersPolicySchema: z.ZodObject<{
157
157
  }, z.core.$strict>>;
158
158
  }, z.core.$strict>;
159
159
  type ProvidersPolicy = z.infer<typeof providersPolicySchema>;
160
+ /**
161
+ * Session context (`docs/session-context.md`): a directory a harness writes one
162
+ * JSON file per agent session into, laid out `<dir>/<agent-tool>/<session-id>.json`.
163
+ * With `dir` set, the hook reads that one file on every event and stamps the
164
+ * attributes of the segment in force on every span, log record and metric point.
165
+ * Absent (the default), nothing is read.
166
+ *
167
+ * Set in the configuration file or with `--session-context-dir`, never through
168
+ * the environment: some agents (Claude Code) strip `OTEL_*` variables from the
169
+ * hook processes they start.
170
+ */
171
+ declare const sessionContextPolicySchema: z.ZodObject<{
172
+ dir: z.ZodString;
173
+ }, z.core.$strict>;
174
+ type SessionContextPolicy = z.infer<typeof sessionContextPolicySchema>;
160
175
  declare const otelHookConfigSchema: z.ZodObject<{
161
176
  exporter: z.ZodObject<{
162
177
  enabled: z.ZodBoolean;
@@ -260,6 +275,9 @@ declare const otelHookConfigSchema: z.ZodObject<{
260
275
  readTranscriptUsage: z.ZodBoolean;
261
276
  }, z.core.$strict>>;
262
277
  }, z.core.$strict>>;
278
+ sessionContext: z.ZodOptional<z.ZodObject<{
279
+ dir: z.ZodString;
280
+ }, z.core.$strict>>;
263
281
  }, z.core.$strict>;
264
282
  type OtelHookConfig = z.infer<typeof otelHookConfigSchema>;
265
283
  /** Partial overlay accepted from a configuration layer. */
@@ -366,6 +384,9 @@ declare const otelHookConfigPatchSchema: z.ZodObject<{
366
384
  readTranscriptUsage: z.ZodOptional<z.ZodBoolean>;
367
385
  }, z.core.$strict>>>;
368
386
  }, z.core.$strict>>;
387
+ sessionContext: z.ZodOptional<z.ZodObject<{
388
+ dir: z.ZodOptional<z.ZodString>;
389
+ }, z.core.$strict>>;
369
390
  }, z.core.$strict>;
370
391
  type OtelHookConfigPatch = z.infer<typeof otelHookConfigPatchSchema>;
371
392
  declare const DEFAULT_EXPORTER_POLICY: ExporterPolicy;
@@ -375,8 +396,10 @@ declare const DEFAULT_PROVIDERS_POLICY: ProvidersPolicy;
375
396
  declare const DEFAULT_CONFIG: OtelHookConfig;
376
397
  /** Whether the runtime may read Claude Code transcripts at `Stop` (default false). */
377
398
  declare const readsClaudeTranscriptUsage: (config: OtelHookConfig) => boolean;
399
+ /** The session context directory in force, or `undefined` when none is configured. */
400
+ declare const sessionContextDir: (config: OtelHookConfig) => string | undefined;
378
401
 
379
402
  /** The metrics policy in force, defaults filled in. */
380
403
  declare const effectiveMetricsPolicy: (exporter: ExporterPolicy) => MetricsPolicy;
381
404
 
382
- export { DEFAULT_CONFIG as D, type ExporterPolicy as E, type LogsPolicy as L, type MetricsPolicy as M, type OtelHookConfig as O, type ProvidersPolicy as P, DEFAULT_DETECTION_POLICY as a, DEFAULT_DIAGNOSTICS_POLICY as b, DEFAULT_EXPORTER_POLICY as c, DEFAULT_LOGS_POLICY as d, DEFAULT_METRICS_POLICY as e, DEFAULT_PROVIDERS_POLICY as f, type DetectionPolicy as g, type DiagnosticsPolicy as h, type OtelHookConfigPatch as i, detectionPolicySchema as j, diagnosticsPolicySchema as k, effectiveMetricsPolicy as l, exporterPolicySchema as m, logsPolicySchema as n, metricsPolicySchema as o, otelHookConfigPatchSchema as p, otelHookConfigSchema as q, providersPolicySchema as r, readsClaudeTranscriptUsage as s };
405
+ export { DEFAULT_CONFIG as D, type ExporterPolicy as E, type LogsPolicy as L, type MetricsPolicy as M, type OtelHookConfig as O, type ProvidersPolicy as P, type SessionContextPolicy as S, DEFAULT_DETECTION_POLICY as a, DEFAULT_DIAGNOSTICS_POLICY as b, DEFAULT_EXPORTER_POLICY as c, DEFAULT_LOGS_POLICY as d, DEFAULT_METRICS_POLICY as e, DEFAULT_PROVIDERS_POLICY as f, type DetectionPolicy as g, type DiagnosticsPolicy as h, type OtelHookConfigPatch as i, detectionPolicySchema as j, diagnosticsPolicySchema as k, effectiveMetricsPolicy as l, exporterPolicySchema as m, logsPolicySchema as n, metricsPolicySchema as o, otelHookConfigPatchSchema as p, otelHookConfigSchema as q, providersPolicySchema as r, readsClaudeTranscriptUsage as s, sessionContextDir as t, sessionContextPolicySchema as u };
package/dist/state.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export { S as StoreNamespace } from './keys-Dej5bN3L.js';
2
- import { L as LockingStateStore } from './filesystem-store-D3SCNmbX.js';
3
- export { F as FilesystemStateStore, a as FilesystemStateStoreOptions, S as StateStoreDependencies, c as createFilesystemStateStore, i as isLockingStateStore, w as withOptionalSessionLock } from './filesystem-store-D3SCNmbX.js';
4
- import { C as Clock } from './ports-CeqLq31i.js';
2
+ import { L as LockingStateStore } from './filesystem-store-CmnUlj1O.js';
3
+ export { F as FilesystemStateStore, a as FilesystemStateStoreOptions, S as StateStoreDependencies, c as createFilesystemStateStore, i as isLockingStateStore, w as withOptionalSessionLock } from './filesystem-store-CmnUlj1O.js';
4
+ import { C as Clock } from './ports-C3k_5eOQ.js';
5
5
  import 'zod';
6
6
  import './errors.js';
7
7
  import './primitives-CJ8-rn-f.js';
8
8
  import './taxonomy-DwhTtuWd.js';
9
- import './events-CSD_YiJ2.js';
9
+ import './events-fcomX6d5.js';
10
10
 
11
11
  type BoundedMemoryStateStoreOptions = {
12
12
  readonly clock: Clock;
package/dist/state.js CHANGED
@@ -718,7 +718,15 @@ var baseEventFields = {
718
718
  * factory, never by hand.
719
719
  */
720
720
  subagentId: subagentIdSchema.optional(),
721
- extensions: extensionsSchema.default(emptyExtensions)
721
+ extensions: extensionsSchema.default(emptyExtensions),
722
+ /**
723
+ * Attributes of the session context segment in force when the event
724
+ * occurred (`docs/session-context.md`), stamped by the core from a file a
725
+ * harness wrote. Exported on every record of the event, over the same keys
726
+ * from the Resource. Absent when no context applies. Set by the core only,
727
+ * never by an adapter.
728
+ */
729
+ contextAttributes: z9.record(z9.string().min(1).max(255), z9.union([z9.string(), z9.number(), z9.boolean()])).optional()
722
730
  };
723
731
  var event = (shape) => z9.strictObject({ ...baseEventFields, ...shape });
724
732
  var sessionStartEventSchema = event({