@osfactory/otel-hook 0.12.0 → 0.13.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 (39) hide show
  1. package/README.md +6 -4
  2. package/dist/{adapter-DQiPu8xF.d.ts → adapter-DyCb7y1N.d.ts} +1 -1
  3. package/dist/cli.js +137 -44
  4. package/dist/cli.js.map +1 -1
  5. package/dist/{export-destinations-CI7z4n3i.d.ts → export-destinations-Bey2djRk.d.ts} +2 -2
  6. package/dist/{filesystem-store-CmnUlj1O.d.ts → filesystem-store-B3CpiIRl.d.ts} +1 -1
  7. package/dist/{hook-vM_cgqS2.d.ts → hook-D5imE0Qc.d.ts} +3 -3
  8. package/dist/index.d.ts +10 -10
  9. package/dist/index.js +137 -44
  10. package/dist/index.js.map +1 -1
  11. package/dist/install.d.ts +3 -3
  12. package/dist/install.js +10 -1
  13. package/dist/install.js.map +1 -1
  14. package/dist/integration.d.ts +7 -7
  15. package/dist/integration.js +107 -41
  16. package/dist/integration.js.map +1 -1
  17. package/dist/lifecycle.d.ts +2 -2
  18. package/dist/lifecycle.js +1 -1
  19. package/dist/lifecycle.js.map +1 -1
  20. package/dist/{memory-DdU1U91y.d.ts → memory-B3r6sZtC.d.ts} +1 -1
  21. package/dist/{metric-model-C9lLqqpI.d.ts → metric-model-CFIeUwqd.d.ts} +2 -1
  22. package/dist/{payload-BT19hiVZ.d.ts → payload-CdDKeRpH.d.ts} +1 -1
  23. package/dist/{ports-C3k_5eOQ.d.ts → ports-DhpSDIkp.d.ts} +8 -1
  24. package/dist/providers.d.ts +27 -11
  25. package/dist/providers.js +121 -41
  26. package/dist/providers.js.map +1 -1
  27. package/dist/{registry-gyJqaWmp.d.ts → registry-BKQhhIO3.d.ts} +1 -1
  28. package/dist/runtime.d.ts +6 -6
  29. package/dist/runtime.js +12 -2
  30. package/dist/runtime.js.map +1 -1
  31. package/dist/state.d.ts +3 -3
  32. package/dist/state.js.map +1 -1
  33. package/dist/telemetry.d.ts +3 -3
  34. package/dist/telemetry.js +4 -1
  35. package/dist/telemetry.js.map +1 -1
  36. package/dist/testing.d.ts +6 -6
  37. package/dist/testing.js +52 -6
  38. package/dist/testing.js.map +1 -1
  39. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  import { E as ExportDestination } from './destinations-DvqsPulb.js';
2
2
  import { E as ExporterPolicy } from './schema-SpFM6YQY.js';
3
- import { C as Clock, d as Logger, l as TelemetrySink } from './ports-C3k_5eOQ.js';
3
+ import { C as Clock, d as Logger, l as TelemetrySink } from './ports-DhpSDIkp.js';
4
4
  import { Attributes } from '@opentelemetry/api';
5
5
  import { S as StoreNamespace } from './keys-Dej5bN3L.js';
6
- import { n as SpanCorrelationResolver, m as SpanCorrelation, k as MetricPoint } from './metric-model-C9lLqqpI.js';
6
+ import { n as SpanCorrelationResolver, m as SpanCorrelation, k as MetricPoint } from './metric-model-CFIeUwqd.js';
7
7
  import { InstrumentationScope } from '@opentelemetry/core';
8
8
  import { Resource } from '@opentelemetry/resources';
9
9
  import { ReadableLogRecord } from '@opentelemetry/sdk-logs';
@@ -1,4 +1,4 @@
1
- import { j as StateStore, C as Clock, d as Logger } from './ports-C3k_5eOQ.js';
1
+ import { j as StateStore, C as Clock, d as Logger } from './ports-DhpSDIkp.js';
2
2
  import { S as StoreNamespace } from './keys-Dej5bN3L.js';
3
3
 
4
4
  /**
@@ -5,9 +5,9 @@ import { b as CanonicalEvent, I as UsageTemporality, f as CanonicalUsage } from
5
5
  import { I as IdentityClaim, W as WorkspaceIdentity, d as InvocationIdentity } from './identity-BrVBs901.js';
6
6
  import { h as SourceTransport, R as ResolvedProviderId, c as DetectionConfidence, d as EventId } from './primitives-CJ8-rn-f.js';
7
7
  import { P as PrivacyService } from './service-CbI9CObT.js';
8
- import { b as DeliveryIdentifierSupport, f as ProviderDeliveryClaim, j as ProviderHookResponse } from './adapter-DQiPu8xF.js';
9
- import { P as ProviderRegistry } from './registry-gyJqaWmp.js';
10
- import { I as IdGenerator, l as TelemetrySink, j as StateStore, C as Clock, d as Logger, W as WorktreeLocator, P as PayloadEnricher, S as SessionContextReader } from './ports-C3k_5eOQ.js';
8
+ import { b as DeliveryIdentifierSupport, f as ProviderDeliveryClaim, j as ProviderHookResponse } from './adapter-DyCb7y1N.js';
9
+ import { P as ProviderRegistry } from './registry-BKQhhIO3.js';
10
+ import { I as IdGenerator, l as TelemetrySink, j as StateStore, C as Clock, d as Logger, W as WorktreeLocator, P as PayloadEnricher, S as SessionContextReader } from './ports-DhpSDIkp.js';
11
11
  import { A as AttributionOutcome, a as AttributionReason } from './taxonomy-DwhTtuWd.js';
12
12
 
13
13
  /**
package/dist/index.d.ts CHANGED
@@ -10,20 +10,20 @@ export { WorkspaceKeyInput, WorkspaceLabels, canonicalizeGitRemote, deriveWorksp
10
10
  export { CONFIG_SOURCE_PRECEDENCE, ConfigLayer, ConfigProvenance, ConfigResolution, ConfigSource, EMPTY_RESOURCE_ATTRIBUTES, ENVIRONMENT_VARIABLES, EnvironmentConfigResult, EnvironmentRecord, MAX_OTLP_HEADERS, MAX_RESOURCE_ATTRIBUTES, MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH, MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH, OTLP_ENDPOINT_VARIABLES, OTLP_HEADER_VARIABLES, OtlpSignal, ParsedOtlpHeaders, ParsedResourceAttributes, RESERVED_RESOURCE_ATTRIBUTE_KEYS, RESOURCE_ATTRIBUTE_KEY_PATTERN, RESOURCE_ATTRIBUTE_KEY_REJECTION_DETAIL, ResolvedOtlpHeaders, ResourceAttributeKeyRejection, ResourceAttributeValue, ResourceAttributes, checkResourceAttributeKey, configSourceSchema, describeOtlpHeaderNames, describeResolvedConfig, describeResourceAttributeNames, isReservedResourceAttributeKey, isSecretResourceAttributeKey, mergeOtlpHeaders, otlpSignalEndpointFromBase, parseEnvironmentConfig, parseOtlpHeadersValue, parseResourceAttributesValue, resolveConfig, resolveOtlpHeaders, resourceAttributeValueSchema, resourceAttributesSchema, sanitizeResourceAttributes, unionOtlpHeaderNames } from './config.js';
11
11
  export { D as DEFAULT_CONFIG, a as DEFAULT_DETECTION_POLICY, b as DEFAULT_DIAGNOSTICS_POLICY, c as DEFAULT_EXPORTER_POLICY, d as DEFAULT_LOGS_POLICY, e as DEFAULT_METRICS_POLICY, f as DEFAULT_PROVIDERS_POLICY, g as DetectionPolicy, h as DiagnosticsPolicy, E as ExporterPolicy, L as LogsPolicy, M as MetricsPolicy, O as OtelHookConfig, i as OtelHookConfigPatch, P as ProvidersPolicy, S as SessionContextPolicy, j as detectionPolicySchema, k as diagnosticsPolicySchema, l as effectiveMetricsPolicy, m as exporterPolicySchema, n as logsPolicySchema, o as metricsPolicySchema, p as otelHookConfigPatchSchema, q as otelHookConfigSchema, r as providersPolicySchema, s as readsClaudeTranscriptUsage, t as sessionContextDir, u as sessionContextPolicySchema } from './schema-SpFM6YQY.js';
12
12
  export { D as DEFAULT_DESTINATION_NAME, a as DEFAULT_DESTINATION_SIGNALS, b as DEFAULT_SPOOL_POLICY, c as DESTINATION_NAME_PATTERN, d as DestinationDescription, E as ExportDestination, e as ExportDestinationConfig, f as ExportSignal, H as HEADER_ENV_REFERENCE_PREFIX, g as HeaderValueReference, M as MAX_DESTINATION_HEADERS, h as MAX_EXPORT_DESTINATIONS, R as ResolvedDestinationHeaders, S as SpoolPolicy, i as describeExportDestinations, j as effectiveSpoolPolicy, k as endpointOrigin, l as exportDestinationSchema, m as exportDestinationsSchema, n as exportSignalSchema, o as hasConfiguredDestinations, p as parseHeaderValueReference, r as resolveDestinationHeaders, q as resolveExportDestinations, s as spoolPolicySchema } from './destinations-DvqsPulb.js';
13
- export { A as AdapterDescription, D as DELIVERY_COMPONENT_PATTERN, a as DELIVERY_GAP_REASON_PATTERN, b as DeliveryIdentifierSupport, M as MAX_DELIVERY_COMPONENTS, c as MAX_DELIVERY_GAPS, P as ProviderAdapter, d as ProviderCapabilities, e as ProviderContext, f as ProviderDeliveryClaim, g as ProviderDeliveryGaps, h as ProviderDetection, i as ProviderDetectionInput, j as ProviderHookResponse, k as ProviderHookResponseInput, l as ProviderIdentityInput, m as ProviderParseInput, n as ProviderParseResult, S as SILENT_HOOK_RESPONSE, o as adapterSupports, p as asProviderId, q as deliveryComponentSchema, r as deliveryGapReasonSchema, s as deliveryIdentifierSupportSchema, t as describeAdapter, u as providerCapabilitiesSchema, v as providerDeliveryClaimSchema, w as providerDeliveryGapsSchema, x as providerDetectionSchema, y as providerHookResponseSchema, z as readDeliveryClaim, B as readDeliveryGap, C as unknownDetection } from './adapter-DQiPu8xF.js';
13
+ export { A as AdapterDescription, D as DELIVERY_COMPONENT_PATTERN, a as DELIVERY_GAP_REASON_PATTERN, b as DeliveryIdentifierSupport, M as MAX_DELIVERY_COMPONENTS, c as MAX_DELIVERY_GAPS, P as ProviderAdapter, d as ProviderCapabilities, e as ProviderContext, f as ProviderDeliveryClaim, g as ProviderDeliveryGaps, h as ProviderDetection, i as ProviderDetectionInput, j as ProviderHookResponse, k as ProviderHookResponseInput, l as ProviderIdentityInput, m as ProviderParseInput, n as ProviderParseResult, S as SILENT_HOOK_RESPONSE, o as adapterSupports, p as asProviderId, q as deliveryComponentSchema, r as deliveryGapReasonSchema, s as deliveryIdentifierSupportSchema, t as describeAdapter, u as providerCapabilitiesSchema, v as providerDeliveryClaimSchema, w as providerDeliveryGapsSchema, x as providerDetectionSchema, y as providerHookResponseSchema, z as readDeliveryClaim, B as readDeliveryGap, C as unknownDetection } from './adapter-DyCb7y1N.js';
14
14
  export { ANTIGRAVITY_PROMOTION_GATES, ANTIGRAVITY_PROVIDER_MATURITY, AntigravityProviderMaturity, CLAUDE_CODE_CAPABILITIES, CLAUDE_TRANSCRIPT_USAGE_ENRICHER_ID, CODEX_CAPABILITIES, CURSOR_ADAPTER_VERSION, CURSOR_CAPABILITIES, CanonicalEventDraft, ClaudeCodeAdapterOptions, ClaudeTranscriptRange, ClaudeTranscriptTurn, ClaudeTranscriptUsageEnricherOptions, CursorAdapterOptions, DEFAULT_CLAUDE_TRANSCRIPT_RANGE_BYTES, DEFAULT_CLAUDE_TRANSCRIPT_RANGE_TIMEOUT_MILLIS, DEFAULT_CLAUDE_TRANSCRIPT_TAIL_BYTES, DEFAULT_CLAUDE_TRANSCRIPT_TIMEOUT_MILLIS, DELIVERY_IDENTIFIER_SUMMARY, DefaultRegistryOptions, EXPERIMENTAL_PROVIDER_IDS, EventFactory, EventFactoryInput, PROVIDER_DESCRIPTORS, ProviderCatalogEntry, ProviderDescriptor, ProviderMaturity, ReadClaudeTranscriptRangeOptions, ReadClaudeTranscriptTurnOptions, attachClaudeTranscriptTurn, createClaudeCodeAdapter, createClaudeTranscriptUsageEnricher, createCodexAdapter, createCursorAdapter, createDefaultProviderRegistry, createEventFactory, describeProviderCatalog, findProviderDescriptor, isExperimentalProvider, readClaudeTranscriptRange, readClaudeTranscriptTurn } from './providers.js';
15
- export { B as BUILT_IN_PROVIDERS, D as DetectionCandidate, P as ProviderRegistry, R as RegistryDetectionResult, c as createProviderRegistry } from './registry-gyJqaWmp.js';
16
- export { A as ANTIGRAVITY_CAPABILITIES, a as ANTIGRAVITY_HOOK_EVENT_NAMES, b as ANTIGRAVITY_PROVIDER_ID, c as AntigravityAdapterOptions, d as AntigravityHookEventName, C as CLAUDE_CODE_PROVIDER_ID, e as CLAUDE_HOOK_EVENT_NAMES, f as CODEX_ADAPTER_VERSION, g as CODEX_HOOK_EVENT_NAMES, h as CODEX_PROVIDER_ID, i as CURSOR_DECISION_EVENTS, j as CURSOR_HOOK_EVENT_NAMES, k as CURSOR_PROVIDER_ID, l as CURSOR_UNMODELLED_HOOK_EVENT_NAMES, m as ClaudeHookEventName, n as CodexHookEventName, o as CursorHookEventName, D as DEFAULT_GEMINI_CAPABILITIES, G as GEMINI_ADAPTER_VERSION, p as GEMINI_HOOK_EVENT_NAMES, q as GEMINI_PROVIDER_ID, r as GeminiAdapterOptions, s as GeminiHookEventName, t as createAntigravityAdapter, u as createGeminiCliAdapter } from './payload-BT19hiVZ.js';
17
- export { A as AppliedDelivery, C as Clock, E as EventIdSeed, I as IdGenerator, a as InvocationIdSeed, L as LOG_LEVEL_RANK, b as LocatedWorktree, c as LogLevel, d as Logger, P as PayloadEnricher, e as PayloadEnrichment, f as PayloadEnrichmentInput, R as ReadCursor, S as SessionContextReader, g as SessionContextRequest, h as SessionContextSegment, i as StateRecord, j as StateStore, k as StateValue, T as TelemetryEmitResult, l as TelemetrySink, W as WorktreeLocator, m as appliedDeliverySchema, n as logLevelSchema, s as stateRecordSchema, o as stateValueSchema } from './ports-C3k_5eOQ.js';
18
- 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-DdU1U91y.js';
15
+ export { B as BUILT_IN_PROVIDERS, D as DetectionCandidate, P as ProviderRegistry, R as RegistryDetectionResult, c as createProviderRegistry } from './registry-BKQhhIO3.js';
16
+ export { A as ANTIGRAVITY_CAPABILITIES, a as ANTIGRAVITY_HOOK_EVENT_NAMES, b as ANTIGRAVITY_PROVIDER_ID, c as AntigravityAdapterOptions, d as AntigravityHookEventName, C as CLAUDE_CODE_PROVIDER_ID, e as CLAUDE_HOOK_EVENT_NAMES, f as CODEX_ADAPTER_VERSION, g as CODEX_HOOK_EVENT_NAMES, h as CODEX_PROVIDER_ID, i as CURSOR_DECISION_EVENTS, j as CURSOR_HOOK_EVENT_NAMES, k as CURSOR_PROVIDER_ID, l as CURSOR_UNMODELLED_HOOK_EVENT_NAMES, m as ClaudeHookEventName, n as CodexHookEventName, o as CursorHookEventName, D as DEFAULT_GEMINI_CAPABILITIES, G as GEMINI_ADAPTER_VERSION, p as GEMINI_HOOK_EVENT_NAMES, q as GEMINI_PROVIDER_ID, r as GeminiAdapterOptions, s as GeminiHookEventName, t as createAntigravityAdapter, u as createGeminiCliAdapter } from './payload-CdDKeRpH.js';
17
+ export { A as AppliedDelivery, C as Clock, E as EventIdSeed, I as IdGenerator, a as InvocationIdSeed, L as LOG_LEVEL_RANK, b as LocatedWorktree, c as LogLevel, d as Logger, P as PayloadEnricher, e as PayloadEnrichment, f as PayloadEnrichmentInput, R as ReadCursor, S as SessionContextReader, g as SessionContextRequest, h as SessionContextSegment, i as StateRecord, j as StateStore, k as StateValue, T as TelemetryEmitResult, l as TelemetrySink, W as WorktreeLocator, m as appliedDeliverySchema, n as logLevelSchema, s as stateRecordSchema, o as stateValueSchema } from './ports-DhpSDIkp.js';
18
+ 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-B3r6sZtC.js';
19
19
  export { DEFAULT_SESSION_CONTEXT_BUDGET_MILLIS, DEFAULT_SESSION_CONTEXT_MAX_BYTES, DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS, DEFAULT_WORKTREE_CACHE_TTL_MILLIS, DirectorySessionContextReaderOptions, FilesystemWorktreeLocatorOptions, MAX_SESSION_CONTEXT_SEGMENTS, MAX_WORKTREE_WALK_DEPTH, ResolveEventTargetsInput, ResolveEventTargetsResult, SESSION_CONTEXT_AGENT_TOOLS, SESSION_CONTEXT_FILE_VERSION, StderrLoggerOptions, createDirectorySessionContextReader, createFilesystemWorktreeLocator, createNullLogger, createStderrLogger, isReservedSessionContextKey, isSessionContextFileName, parseCommonDirFile, parseGitDirFile, parseHeadBranch, parseSessionContextFile, resolveEventTargets, sanitizeSessionContextAttributes, segmentInForce, sessionContextAgentTool, sessionContextFilePath, stampSessionContext } from './runtime.js';
20
- 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-vM_cgqS2.js';
20
+ 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-D5imE0Qc.js';
21
21
  export { CallbackDeduplicator, CallbackDeduplicatorDependencies, DedupCheckResult, DedupCleanupResult, DeliveryClaimOptions, DeliveryClaimOutcome, DeliveryClaimResult, LifecycleCleanupReport, LifecycleJanitor, LifecycleJanitorOptions, LifecycleScope, LifecycleSweepStats, MetricSeriesCleanupResult, MetricSeriesStore, MetricSeriesStoreDependencies, RecordCumulativeOptions, RollupCleanupResult, SPAN_RECORD_VERSION, SpanCleanupResult, SpanCorrelationFacts, SpanCorrelator, SpanCorrelatorDependencies, SpanEndInput, SpanEndOrphanReason, SpanEndResult, SpanStartInput, SpanStartResult, UsageAccumulator, UsageAccumulatorDependencies, UsageAccumulatorKey, UsageAccumulatorSnapshot, createCallbackDeduplicator, createLifecycleJanitor, createMetricSeriesStore, createSpanCorrelator, createUsageAccumulator } from './lifecycle.js';
22
22
  export { S as StoreNamespace } from './keys-Dej5bN3L.js';
23
- export { F as FilesystemStateStore, a as FilesystemStateStoreOptions, L as LockingStateStore, S as StateStoreDependencies, c as createFilesystemStateStore, i as isLockingStateStore, w as withOptionalSessionLock } from './filesystem-store-CmnUlj1O.js';
23
+ export { F as FilesystemStateStore, a as FilesystemStateStoreOptions, L as LockingStateStore, S as StateStoreDependencies, c as createFilesystemStateStore, i as isLockingStateStore, w as withOptionalSessionLock } from './filesystem-store-B3CpiIRl.js';
24
24
  export { BoundedMemoryStateStore, BoundedMemoryStateStoreOptions, createBoundedMemoryStateStore } from './state.js';
25
- export { D as DEFAULT_INSTRUMENTATION_SCOPE, a as DeriveMetricObservationsInput, E as EventTraceIdentity, M as MAX_RECOVERED_START_ATTRIBUTES, b as METRIC_COST_USAGE, c as METRIC_INSTRUMENTS, d as METRIC_OPERATION_DURATION, e as METRIC_SESSIONS, f as METRIC_TOKEN_USAGE, g as METRIC_TOOL_CALLS, h as MetricInstrument, i as MetricInstrumentName, j as MetricObservation, k as MetricPoint, l as MetricsTemporality, O as OPERATION_DURATION_BUCKETS, S as SemanticMappingOptions, m as SpanCorrelation, n as SpanCorrelationResolver, o as SpanDisposition, p as SpanFamily, q as SpanOrphanClassification, r as SpanPairing, s as SpanScopeRef, T as TOKEN_USAGE_BUCKETS, t as TokenType, u as aggregateDeltaPoints, v as canonicalEventTraceIdentities, w as canonicalEventsToReadableSpans, x as deriveMetricObservations, y as parentScopeRefOf, z as spanScopeRefOf, A as startOnlySpanAttributes } from './metric-model-C9lLqqpI.js';
26
- export { C as ContentWithholdingReason, D as DurableLogSpool, a as DurableLogSpoolOptions, b as DurableMetricSpool, c as DurableMetricSpoolOptions, d as DurableSpool, e as DurableSpoolOptions, E as ExportDestinationSinks, f as ExportDestinationsOptions, L as LOG_MAPPING_VERSION, g as LOG_SIGNALS, h as LogContentPolicy, i as LogMappingOptions, j as LogMappingResult, k as LogSignal, l as LogSpoolBatch, m as LogsDeliverability, M as MAX_LOG_BODY_CHARACTERS, n as MAX_LOG_RECORDS_PER_BATCH, o as MAX_LOG_RECORDS_PER_EVENT, p as MCP_TOOL_NAME_PATTERN, q as MetricExportResult, r as MetricSpoolBatch, s as MetricsDeliverability, N as NO_LOG_CONTENT, O as OtlpLogSinkOptions, t as OtlpLogTelemetrySink, u as OtlpMetricSinkOptions, v as OtlpMetricTelemetrySink, w as OtlpTelemetrySink, x as OtlpTraceSinkOptions, S as SerializedLogRecord, y as SerializedSpan, z as SignalFanoutOptions, A as SignalFanoutSink, B as SkippedExportDestination, F as SpoolBatch, G as SpoolDrainResult, H as SpoolDropCounts, I as SpoolDropReason, J as SpoolEnqueueResult, K as SpoolOverflowPolicy, P as SpoolSendOutcome, Q as SpoolStats, R as canonicalEventsToLogRecords, T as createDestinationFanout, U as createExportDestinationSinks, V as createFileDurableLogSpool, W as createFileDurableMetricSpool, X as createFileDurableSpool, Y as createOtlpLogSink, Z as createOtlpMetricSink, _ as createOtlpTraceSink, $ as createSignalFanout, a0 as describeLogsDeliverability, a1 as describeMetricsDeliverability, a2 as exporterPolicyForDestination, a3 as logSignalOf, a4 as logSignalsForLifecycleEvents, a5 as resolveLogsEndpoint, a6 as resolveMetricsEndpoint, a7 as shareCorrelationPerBatch, a8 as spoolQueueNamesFor, a9 as validateMetricSpoolBatch } from './export-destinations-CI7z4n3i.js';
25
+ export { D as DEFAULT_INSTRUMENTATION_SCOPE, a as DeriveMetricObservationsInput, E as EventTraceIdentity, M as MAX_RECOVERED_START_ATTRIBUTES, b as METRIC_COST_USAGE, c as METRIC_INSTRUMENTS, d as METRIC_OPERATION_DURATION, e as METRIC_SESSIONS, f as METRIC_TOKEN_USAGE, g as METRIC_TOOL_CALLS, h as MetricInstrument, i as MetricInstrumentName, j as MetricObservation, k as MetricPoint, l as MetricsTemporality, O as OPERATION_DURATION_BUCKETS, S as SemanticMappingOptions, m as SpanCorrelation, n as SpanCorrelationResolver, o as SpanDisposition, p as SpanFamily, q as SpanOrphanClassification, r as SpanPairing, s as SpanScopeRef, T as TOKEN_USAGE_BUCKETS, t as TokenType, u as aggregateDeltaPoints, v as canonicalEventTraceIdentities, w as canonicalEventsToReadableSpans, x as deriveMetricObservations, y as parentScopeRefOf, z as spanScopeRefOf, A as startOnlySpanAttributes } from './metric-model-CFIeUwqd.js';
26
+ export { C as ContentWithholdingReason, D as DurableLogSpool, a as DurableLogSpoolOptions, b as DurableMetricSpool, c as DurableMetricSpoolOptions, d as DurableSpool, e as DurableSpoolOptions, E as ExportDestinationSinks, f as ExportDestinationsOptions, L as LOG_MAPPING_VERSION, g as LOG_SIGNALS, h as LogContentPolicy, i as LogMappingOptions, j as LogMappingResult, k as LogSignal, l as LogSpoolBatch, m as LogsDeliverability, M as MAX_LOG_BODY_CHARACTERS, n as MAX_LOG_RECORDS_PER_BATCH, o as MAX_LOG_RECORDS_PER_EVENT, p as MCP_TOOL_NAME_PATTERN, q as MetricExportResult, r as MetricSpoolBatch, s as MetricsDeliverability, N as NO_LOG_CONTENT, O as OtlpLogSinkOptions, t as OtlpLogTelemetrySink, u as OtlpMetricSinkOptions, v as OtlpMetricTelemetrySink, w as OtlpTelemetrySink, x as OtlpTraceSinkOptions, S as SerializedLogRecord, y as SerializedSpan, z as SignalFanoutOptions, A as SignalFanoutSink, B as SkippedExportDestination, F as SpoolBatch, G as SpoolDrainResult, H as SpoolDropCounts, I as SpoolDropReason, J as SpoolEnqueueResult, K as SpoolOverflowPolicy, P as SpoolSendOutcome, Q as SpoolStats, R as canonicalEventsToLogRecords, T as createDestinationFanout, U as createExportDestinationSinks, V as createFileDurableLogSpool, W as createFileDurableMetricSpool, X as createFileDurableSpool, Y as createOtlpLogSink, Z as createOtlpMetricSink, _ as createOtlpTraceSink, $ as createSignalFanout, a0 as describeLogsDeliverability, a1 as describeMetricsDeliverability, a2 as exporterPolicyForDestination, a3 as logSignalOf, a4 as logSignalsForLifecycleEvents, a5 as resolveLogsEndpoint, a6 as resolveMetricsEndpoint, a7 as shareCorrelationPerBatch, a8 as spoolQueueNamesFor, a9 as validateMetricSpoolBatch } from './export-destinations-Bey2djRk.js';
27
27
  export { isPermanentExportFailure } from './telemetry.js';
28
28
  export { DeliveryHealthSnapshot, DeliverySubsystem, HealthTracker, HealthTrackerOptions, OverallHealth, createHealthTracker, summarizeHealth } from './diagnostics.js';
29
29
  export { DeliveryReport, HookProcessInput, HookProcessOutcome, HookRuntime, HookRuntimeDelivery, HookRuntimeOptions, HookShutdownReport, MetricsReport, UsageRollup, createHookRuntime, minimumStaleClaimMillis } from './integration.js';
@@ -42,6 +42,6 @@ import '@opentelemetry/sdk-logs';
42
42
  *
43
43
  * Updated by `scripts/release/sync-version.mjs` during semantic-release.
44
44
  */
45
- declare const VERSION = "0.12.0";
45
+ declare const VERSION = "0.13.0";
46
46
 
47
47
  export { VERSION };
package/dist/index.js CHANGED
@@ -3163,7 +3163,16 @@ var subagentStopPayloadSchema = z17.object({
3163
3163
  last_assistant_message: z17.string().optional(),
3164
3164
  /** True when this stop fired because a hook continued the subagent's turn. */
3165
3165
  stop_hook_active: z17.boolean().optional(),
3166
- usage: claudeUsageSchema.optional()
3166
+ /**
3167
+ * The subagent run's tokens since its previous stop — harness- or
3168
+ * enricher-supplied, never upstream. Reported on the subagent's own
3169
+ * generation, never on the parent turn (issue #68).
3170
+ */
3171
+ usage: claudeUsageSchema.optional(),
3172
+ /** Harness-supplied, never upstream: the subagent's model, from its transcript. */
3173
+ model: z17.string().min(1).max(256).optional().catch(void 0),
3174
+ /** Harness-supplied, never upstream: see `stopPayloadSchema.usage_partial`. */
3175
+ usage_partial: z17.boolean().optional().catch(void 0)
3167
3176
  });
3168
3177
  var preCompactPayloadSchema = z17.object({
3169
3178
  ...commonFields,
@@ -3761,6 +3770,8 @@ var BUILT_IN_TOOL_KIND = Object.freeze({
3761
3770
  WebFetch: "network",
3762
3771
  WebSearch: "network",
3763
3772
  Task: "delegate",
3773
+ // Current Claude Code releases (observed on 2.1.332) name the subagent tool `Agent`.
3774
+ Agent: "delegate",
3764
3775
  TodoWrite: "other",
3765
3776
  ExitPlanMode: "other",
3766
3777
  AskUserQuestion: "other",
@@ -3934,14 +3945,39 @@ var parseClaudeCode = (input, context) => {
3934
3945
  delegationDepth: 1
3935
3946
  });
3936
3947
  break;
3937
- case "SubagentStop":
3948
+ case "SubagentStop": {
3949
+ const usage = withPartialUsage(extractedUsage ?? payload.usage, payload.usage_partial);
3950
+ if (usage.usage !== void 0 || payload.model !== void 0) {
3951
+ const generationId = context.ids.newOpaqueId([
3952
+ "claude-subagent-generation",
3953
+ payload.session_id,
3954
+ payload.agent_id,
3955
+ ...payload.stop_hook_active === true ? [String(input.sequenceBase)] : []
3956
+ ]);
3957
+ const models = generationModels(payload.model, void 0);
3958
+ factory.build({ type: "generation.start", generationId, model: models.request });
3959
+ factory.build({
3960
+ type: "generation.end",
3961
+ generationId,
3962
+ model: models.response,
3963
+ outcome: "ok",
3964
+ outputContent: [
3965
+ payload.last_assistant_message === void 0 ? context.privacy.describeUnavailableContent({ kind: "response", role: "assistant" }) : context.privacy.describeContent({
3966
+ kind: "response",
3967
+ role: "assistant",
3968
+ text: payload.last_assistant_message
3969
+ })
3970
+ ],
3971
+ ...usage
3972
+ });
3973
+ }
3938
3974
  factory.build({
3939
3975
  type: "subagent.end",
3940
3976
  subagentInvocationId: subagentInvocationIdFor(context, payload.session_id, payload.agent_id),
3941
- outcome: "ok",
3942
- ...withUsage(payload.usage)
3977
+ outcome: "ok"
3943
3978
  });
3944
3979
  break;
3980
+ }
3945
3981
  case "PreCompact":
3946
3982
  return {
3947
3983
  status: "ignored",
@@ -4061,7 +4097,8 @@ var clamp = (value, fallback, min, max) => {
4061
4097
  };
4062
4098
  var asRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
4063
4099
  var isTranscriptPath = (transcriptPath) => typeof transcriptPath === "string" && transcriptPath.length > 0 && !transcriptPath.includes("\0") && path.isAbsolute(transcriptPath) && path.extname(transcriptPath) === ".jsonl";
4064
- var assistantRecordOf = (line) => {
4100
+ var isRecordOfAgent = (record, agentId) => record.isSidechain === true && (typeof record.agentId !== "string" || record.agentId === agentId);
4101
+ var assistantRecordOf = (line, agentId) => {
4065
4102
  if (!line.includes('"assistant"')) {
4066
4103
  return void 0;
4067
4104
  }
@@ -4072,7 +4109,10 @@ var assistantRecordOf = (line) => {
4072
4109
  return void 0;
4073
4110
  }
4074
4111
  const record = asRecord5(parsed);
4075
- if (record === void 0 || record.type !== "assistant" || record.isSidechain === true) {
4112
+ if (record === void 0 || record.type !== "assistant") {
4113
+ return void 0;
4114
+ }
4115
+ if (agentId === void 0 ? record.isSidechain === true : !isRecordOfAgent(record, agentId)) {
4076
4116
  return void 0;
4077
4117
  }
4078
4118
  const message = asRecord5(record.message);
@@ -4165,7 +4205,7 @@ var completeLinesEnd = (bytes, start) => {
4165
4205
  const lastNewline = bytes.lastIndexOf(10);
4166
4206
  return lastNewline < 0 ? start : start + lastNewline + 1;
4167
4207
  };
4168
- var readTail = (transcriptPath, maxTailBytes) => withRegularFile(transcriptPath, async (handle, size) => {
4208
+ var readTail = (transcriptPath, maxTailBytes, agentId) => withRegularFile(transcriptPath, async (handle, size) => {
4169
4209
  const length = Math.min(size, maxTailBytes);
4170
4210
  const start = size - length;
4171
4211
  const bytes = await readBytes(handle, start, length);
@@ -4175,7 +4215,7 @@ var readTail = (transcriptPath, maxTailBytes) => withRegularFile(transcriptPath,
4175
4215
  lines.shift();
4176
4216
  }
4177
4217
  for (let index = lines.length - 1; index >= 0; index -= 1) {
4178
- const record = assistantRecordOf((lines[index] ?? "").trim());
4218
+ const record = assistantRecordOf((lines[index] ?? "").trim(), agentId);
4179
4219
  if (record !== void 0) {
4180
4220
  return {
4181
4221
  turn: {
@@ -4189,10 +4229,11 @@ var readTail = (transcriptPath, maxTailBytes) => withRegularFile(transcriptPath,
4189
4229
  }
4190
4230
  return { turn: { status: "unavailable", reason: "no-assistant-message" }, endOffset };
4191
4231
  });
4192
- var boundedTail = async (transcriptPath, options) => withTimeout(
4232
+ var boundedTail = async (transcriptPath, options, agentId) => withTimeout(
4193
4233
  readTail(
4194
4234
  transcriptPath,
4195
- clamp(options.maxTailBytes, DEFAULT_CLAUDE_TRANSCRIPT_TAIL_BYTES, MIN_TAIL_BYTES, MAX_TAIL_BYTES)
4235
+ clamp(options.maxTailBytes, DEFAULT_CLAUDE_TRANSCRIPT_TAIL_BYTES, MIN_TAIL_BYTES, MAX_TAIL_BYTES),
4236
+ agentId
4196
4237
  ),
4197
4238
  clamp(options.timeoutMillis, DEFAULT_CLAUDE_TRANSCRIPT_TIMEOUT_MILLIS, MIN_TIMEOUT_MILLIS, MAX_TIMEOUT_MILLIS),
4198
4239
  { status: "unavailable", reason: "unreadable" }
@@ -4232,7 +4273,7 @@ var readClaudeTranscriptRange = async (transcriptPath, fromOffset, options = {})
4232
4273
  let anonymous = 0;
4233
4274
  let model;
4234
4275
  for (const line of complete.split("\n")) {
4235
- const record = assistantRecordOf(line.trim());
4276
+ const record = assistantRecordOf(line.trim(), options.agentId);
4236
4277
  if (record === void 0) {
4237
4278
  continue;
4238
4279
  }
@@ -4294,6 +4335,20 @@ var attachClaudeTranscriptTurn = async (payload, options = {}) => {
4294
4335
  };
4295
4336
  var CLAUDE_TRANSCRIPT_USAGE_ENRICHER_ID = "claude-transcript-usage";
4296
4337
  var sourceDigest = (transcriptPath) => createHash2("sha256").update(transcriptPath, "utf8").digest("hex").slice(0, 32);
4338
+ var SUBAGENT_STOP = "SubagentStop";
4339
+ var agentIdOf = (record) => {
4340
+ const agentId = record.agent_id ?? record.agentId;
4341
+ return typeof agentId === "string" && agentId.length > 0 && agentId.length <= 256 ? agentId : void 0;
4342
+ };
4343
+ var agentTranscriptPathOf = (record) => record.agent_transcript_path ?? record.agentTranscriptPath;
4344
+ var subagentCursorScope = (payload) => {
4345
+ const record = asRecord5(payload);
4346
+ if (record === void 0 || eventNameOf(record) !== SUBAGENT_STOP) {
4347
+ return void 0;
4348
+ }
4349
+ const agentId = agentIdOf(record);
4350
+ return agentId === void 0 ? void 0 : `agent-${createHash2("sha256").update(agentId, "utf8").digest("hex").slice(0, 32)}`;
4351
+ };
4297
4352
  var createClaudeTranscriptUsageEnricher = (options = {}) => {
4298
4353
  const fileSize = async (transcriptPath) => {
4299
4354
  try {
@@ -4303,6 +4358,46 @@ var createClaudeTranscriptUsageEnricher = (options = {}) => {
4303
4358
  return thrown?.code === "ENOENT" ? "absent" : void 0;
4304
4359
  }
4305
4360
  };
4361
+ const readOptions = (agentId) => ({
4362
+ ...options.maxRangeBytes === void 0 ? {} : { maxRangeBytes: options.maxRangeBytes },
4363
+ ...options.rangeTimeoutMillis === void 0 ? {} : { rangeTimeoutMillis: options.rangeTimeoutMillis },
4364
+ ...agentId === void 0 ? {} : { agentId }
4365
+ });
4366
+ const attachSince = async (record, transcriptPath, fromOffset, agentId) => {
4367
+ const source = sourceDigest(transcriptPath);
4368
+ const attach = (model, usage, partial) => ({
4369
+ ...record,
4370
+ ...record.model === void 0 && model !== void 0 ? { model } : {},
4371
+ ...usage === void 0 ? {} : { usage, usage_partial: partial }
4372
+ });
4373
+ if (fromOffset !== void 0) {
4374
+ const range = await readClaudeTranscriptRange(transcriptPath, fromOffset, readOptions(agentId));
4375
+ if (range.status === "found") {
4376
+ return {
4377
+ payload: attach(range.model, range.usage, false),
4378
+ cursor: { source, offset: range.endOffset },
4379
+ notes: [`summed ${String(range.requestCount)} request(s) since the last stop`]
4380
+ };
4381
+ }
4382
+ if (range.reason !== "truncated" && range.reason !== "over-cap") {
4383
+ return { payload: record, notes: [`transcript range not read (${range.reason}); cursor kept`] };
4384
+ }
4385
+ }
4386
+ const tail = await boundedTail(transcriptPath, options, agentId);
4387
+ if (tail === TIMED_OUT || !("turn" in tail)) {
4388
+ return { payload: record, notes: [`transcript tail not read (${tail === TIMED_OUT ? "timeout" : tail.reason})`] };
4389
+ }
4390
+ const why = fromOffset === void 0 ? "no cursor for this transcript" : "range not summable within bounds";
4391
+ return {
4392
+ payload: tail.turn.status === "found" ? attach(tail.turn.model, tail.turn.usage, true) : record,
4393
+ cursor: { source, offset: tail.endOffset },
4394
+ notes: [`${why}; attached the last request only (usage_partial)`]
4395
+ };
4396
+ };
4397
+ const skipAttached = async (payload, transcriptPath) => {
4398
+ const size = await fileSize(transcriptPath);
4399
+ return typeof size === "number" ? { payload, cursor: { source: sourceDigest(transcriptPath), offset: size } } : { payload };
4400
+ };
4306
4401
  const enrich = async (input) => {
4307
4402
  const unchanged = { payload: input.payload };
4308
4403
  const record = asRecord5(input.payload);
@@ -4310,6 +4405,18 @@ var createClaudeTranscriptUsageEnricher = (options = {}) => {
4310
4405
  return unchanged;
4311
4406
  }
4312
4407
  const eventName = eventNameOf(record);
4408
+ if (eventName === SUBAGENT_STOP) {
4409
+ const agentTranscriptPath = agentTranscriptPathOf(record);
4410
+ const agentId = agentIdOf(record);
4411
+ if (agentId === void 0 || !isTranscriptPath(agentTranscriptPath)) {
4412
+ return unchanged;
4413
+ }
4414
+ if (hasUsage(record)) {
4415
+ return skipAttached(input.payload, agentTranscriptPath);
4416
+ }
4417
+ const cursor2 = input.cursor?.source === sourceDigest(agentTranscriptPath) ? input.cursor : void 0;
4418
+ return attachSince(record, agentTranscriptPath, cursor2?.offset ?? 0, agentId);
4419
+ }
4313
4420
  const transcriptPath = transcriptPathOf(record);
4314
4421
  if (typeof eventName !== "string" || !isTranscriptPath(transcriptPath)) {
4315
4422
  return unchanged;
@@ -4330,41 +4437,14 @@ var createClaudeTranscriptUsageEnricher = (options = {}) => {
4330
4437
  return unchanged;
4331
4438
  }
4332
4439
  if (hasUsage(record)) {
4333
- const size = await fileSize(transcriptPath);
4334
- return typeof size === "number" ? { payload: input.payload, cursor: { source, offset: size } } : unchanged;
4440
+ return skipAttached(input.payload, transcriptPath);
4335
4441
  }
4336
- const attach = (model, usage, partial) => ({
4337
- ...record,
4338
- ...record.model === void 0 && model !== void 0 ? { model } : {},
4339
- ...usage === void 0 ? {} : { usage, usage_partial: partial }
4340
- });
4341
- if (cursor !== void 0) {
4342
- const range = await readClaudeTranscriptRange(transcriptPath, cursor.offset, options);
4343
- if (range.status === "found") {
4344
- return {
4345
- payload: attach(range.model, range.usage, false),
4346
- cursor: { source, offset: range.endOffset },
4347
- notes: [`summed ${String(range.requestCount)} request(s) since the last stop`]
4348
- };
4349
- }
4350
- if (range.reason !== "truncated" && range.reason !== "over-cap") {
4351
- return { ...unchanged, notes: [`transcript range not read (${range.reason}); cursor kept`] };
4352
- }
4353
- }
4354
- const tail = await boundedTail(transcriptPath, options);
4355
- if (tail === TIMED_OUT || !("turn" in tail)) {
4356
- return { ...unchanged, notes: [`transcript tail not read (${tail === TIMED_OUT ? "timeout" : tail.reason})`] };
4357
- }
4358
- const why = cursor === void 0 ? "no cursor for this transcript" : "range not summable within bounds";
4359
- return {
4360
- payload: tail.turn.status === "found" ? attach(tail.turn.model, tail.turn.usage, true) : input.payload,
4361
- cursor: { source, offset: tail.endOffset },
4362
- notes: [`${why}; attached the last request only (usage_partial)`]
4363
- };
4442
+ return attachSince(record, transcriptPath, cursor?.offset, void 0);
4364
4443
  };
4365
4444
  return Object.freeze({
4366
4445
  id: CLAUDE_TRANSCRIPT_USAGE_ENRICHER_ID,
4367
4446
  providerId: CLAUDE_CODE_PROVIDER_ID,
4447
+ cursorScope: subagentCursorScope,
4368
4448
  enrich
4369
4449
  });
4370
4450
  };
@@ -7775,7 +7855,7 @@ var usageScopeOf = (event3) => {
7775
7855
  };
7776
7856
  var sequenceKey = (sessionId) => `sequence:${sessionId}`;
7777
7857
  var sessionModelKey = (sessionId) => `model:${sessionId}`;
7778
- var readCursorKey = (enricherId, sessionId) => `cursor:${enricherId}:${sessionId}`;
7858
+ var readCursorKey = (enricherId, sessionId, scope) => scope === void 0 ? `cursor:${enricherId}:${sessionId}` : `cursor:${enricherId}:${sessionId}:${scope}`;
7779
7859
  var UNKNOWN_MODEL_ID = "unknown";
7780
7860
  var latestSessionModel = (events) => {
7781
7861
  let latest;
@@ -7843,7 +7923,17 @@ var createOtelHook = (deps) => {
7843
7923
  if (enricher.providerId !== providerId) {
7844
7924
  continue;
7845
7925
  }
7846
- const key = readCursorKey(enricher.id, sessionId);
7926
+ let scope;
7927
+ try {
7928
+ scope = enricher.cursorScope?.(current);
7929
+ } catch (thrown) {
7930
+ logger.warn("payload enricher failed; parsing the payload as delivered", {
7931
+ "enricher.id": enricher.id,
7932
+ "error.name": thrown instanceof Error ? thrown.name : typeof thrown
7933
+ });
7934
+ continue;
7935
+ }
7936
+ const key = readCursorKey(enricher.id, sessionId, scope);
7847
7937
  let cursor;
7848
7938
  try {
7849
7939
  const record = await deps.stateStore.read(key);
@@ -8944,7 +9034,7 @@ import {
8944
9034
  } from "@opentelemetry/semantic-conventions/incubating";
8945
9035
 
8946
9036
  // src/version.ts
8947
- var VERSION = "0.12.0";
9037
+ var VERSION = "0.13.0";
8948
9038
 
8949
9039
  // src/telemetry/export-identity.ts
8950
9040
  import { ATTR_SESSION_ID } from "@opentelemetry/semantic-conventions/incubating";
@@ -10214,6 +10304,9 @@ var deriveMetricObservations = (input) => {
10214
10304
  if (recovered !== void 0) {
10215
10305
  return end.occurredAt - recovered.startMillis;
10216
10306
  }
10307
+ if (end.subagentId !== void 0) {
10308
+ return void 0;
10309
+ }
10217
10310
  const turn = lastPromptInBatch?.get(end.sessionId) ?? input.turnStart?.(end.sessionId);
10218
10311
  return turn === void 0 || turn > end.occurredAt ? void 0 : end.occurredAt - turn;
10219
10312
  };