@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
package/README.md CHANGED
@@ -286,7 +286,7 @@ otel-hook doctor --json
286
286
 
287
287
  Reports the version, an attribute-safe configuration snapshot, a real
288
288
  write/read/delete probe of the state directory, spool depth, exporter
289
- configuration, privacy mode, and the adapter count. With
289
+ configuration, privacy mode, [session context](docs/session-context.md), and the adapter count. With
290
290
  [multiple destinations](#multiple-destinations) it also reports each one: its
291
291
  signals and endpoint origins, the environment variables its headers reference (by
292
292
  name — never a value), any that are missing, and its spool depth and drops. Exits 1 when any check fails,
@@ -938,6 +938,28 @@ const enriched = await attachClaudeTranscriptTurn(hookPayload);
938
938
 
939
939
  See [finding 8](docs/claude-code-usage-contract.md#finding-8-the-model-is-on-sessionstart-and-in-the-transcript-never-on-stop).
940
940
 
941
+ #### Session context
942
+
943
+ A session's environment is fixed when the agent starts, but the work it does is
944
+ not: it can start in the main checkout and move into a slot later. A harness can
945
+ write what the session is working on to a **session context** file, and
946
+ otel-hook puts it on every span, log record and metric point from then on:
947
+
948
+ ```bash
949
+ otel-hook run --provider claude-code --session-context-dir /home/dev/.har/sessions
950
+ # or, in --config-file: { "sessionContext": { "dir": "/home/dev/.har/sessions" } }
951
+ ```
952
+
953
+ The hook reads `<dir>/<agent-tool>/<session-id>.json` (`claude_code`, `codex`,
954
+ `cursor`, …), picks the segment in force at each event's time, and applies its
955
+ attributes. They override the same keys from the Resource, on records and on the
956
+ Resource itself, so a stale `factory.attempt.id` from the environment is not
957
+ exported. Subagent events use their parent session's file. `factory.local.*` is
958
+ never applied. No file, an invalid one, or no segment in force: nothing is added,
959
+ and the hook never fails. There is no environment variable for it, because Claude
960
+ Code strips `OTEL_*` variables from hooks. Format and rules:
961
+ [docs/session-context.md](docs/session-context.md).
962
+
941
963
  ### Multiple destinations
942
964
 
943
965
  `exporter.destinations` sends every batch to several OTLP endpoints at once — a
@@ -1124,6 +1146,9 @@ these namespaces are therefore also copied onto every span and log record:
1124
1146
  described above, resolved (and trimmed) on its own. Other attributes, such as
1125
1147
  `deployment.environment`, stay on the Resource only.
1126
1148
 
1149
+ [Session context](#session-context) attributes are layered over these on every
1150
+ record, and override the same keys on the Resource.
1151
+
1127
1152
  Diagnostics report resource attribute **names** only — `doctor --json` shows
1128
1153
  `exporter.resource_attribute_names`. A name is already on the wire in every
1129
1154
  exported resource; a value is not disclosed anywhere a name would do.
@@ -1,11 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { OtelHookErrorInfo } from './errors.js';
3
- import { I as UsageTemporality, n as ModelDescriptor, b as CanonicalEvent, u as TargetHint, e as CanonicalEventType } from './events-CSD_YiJ2.js';
3
+ import { I as UsageTemporality, n as ModelDescriptor, b as CanonicalEvent, u as TargetHint, e as CanonicalEventType } from './events-fcomX6d5.js';
4
4
  import { I as IdentityClaim, d as InvocationIdentity } from './identity-BrVBs901.js';
5
5
  import { R as ResolvedProviderId, g as ProviderId, h as SourceTransport, d as EventId } from './primitives-CJ8-rn-f.js';
6
6
  import { e as PrivacyLimits } from './policy-CimmCfRp.js';
7
7
  import { P as PrivacyService } from './service-CbI9CObT.js';
8
- import { C as Clock, I as IdGenerator, d as Logger } from './ports-CeqLq31i.js';
8
+ import { C as Clock, I as IdGenerator, d as Logger } from './ports-C3k_5eOQ.js';
9
9
  import { A as AttributionOutcome, a as AttributionReason } from './taxonomy-DwhTtuWd.js';
10
10
 
11
11
  /** Raw input offered to adapters. `payload` is `unknown` on purpose. */