@osfactory/otel-hook 0.14.0 → 0.14.1

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 (37) hide show
  1. package/README.md +17 -3
  2. package/dist/{adapter-D5R8lhfl.d.ts → adapter-But5fFCk.d.ts} +8 -1
  3. package/dist/cli.js +210 -45
  4. package/dist/cli.js.map +1 -1
  5. package/dist/{export-destinations-DvoH4QOe.d.ts → export-destinations-8tNkIC8a.d.ts} +12 -4
  6. package/dist/{filesystem-store-B3CpiIRl.d.ts → filesystem-store-Z8XgDtFj.d.ts} +1 -1
  7. package/dist/{hook-DVK8Don-.d.ts → hook-D7XABd4f.d.ts} +17 -3
  8. package/dist/index.d.ts +10 -10
  9. package/dist/index.js +211 -45
  10. package/dist/index.js.map +1 -1
  11. package/dist/install.d.ts +3 -3
  12. package/dist/install.js.map +1 -1
  13. package/dist/integration.d.ts +6 -6
  14. package/dist/integration.js +188 -40
  15. package/dist/integration.js.map +1 -1
  16. package/dist/lifecycle.d.ts +1 -1
  17. package/dist/lifecycle.js +1 -1
  18. package/dist/lifecycle.js.map +1 -1
  19. package/dist/{memory-B3r6sZtC.d.ts → memory-gipZUiXP.d.ts} +1 -1
  20. package/dist/{payload-D4r71EL-.d.ts → payload-DWdx9yk3.d.ts} +1 -1
  21. package/dist/{ports-DhpSDIkp.d.ts → ports-qZTwK-z2.d.ts} +22 -2
  22. package/dist/providers.d.ts +7 -7
  23. package/dist/providers.js +22 -5
  24. package/dist/providers.js.map +1 -1
  25. package/dist/{registry-DOJh9mzB.d.ts → registry-D9rmMYxw.d.ts} +1 -1
  26. package/dist/runtime.d.ts +22 -7
  27. package/dist/runtime.js +154 -28
  28. package/dist/runtime.js.map +1 -1
  29. package/dist/state.d.ts +3 -3
  30. package/dist/state.js.map +1 -1
  31. package/dist/telemetry.d.ts +2 -2
  32. package/dist/telemetry.js +26 -9
  33. package/dist/telemetry.js.map +1 -1
  34. package/dist/testing.d.ts +6 -6
  35. package/dist/testing.js +57 -8
  36. package/dist/testing.js.map +1 -1
  37. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { e as DestinationScope, E as ExportDestination } from './destinations-2KrcRslo.js';
2
2
  import { E as ExporterPolicy } from './schema-oRsbo7WO.js';
3
3
  import { b as CanonicalEvent, e as CanonicalEventType } from './events-fcomX6d5.js';
4
- import { C as Clock, d as Logger, l as TelemetrySink } from './ports-DhpSDIkp.js';
4
+ import { C as Clock, d as Logger, m as TelemetrySink } from './ports-qZTwK-z2.js';
5
5
  import { Attributes } from '@opentelemetry/api';
6
6
  import { S as StoreNamespace } from './keys-Dej5bN3L.js';
7
7
  import { n as SpanCorrelationResolver, m as SpanCorrelation, k as MetricPoint } from './metric-model-B4lIuk6i.js';
@@ -799,6 +799,11 @@ type ScopedBatch = {
799
799
  type RouteEventsOptions = {
800
800
  /** Repository key of the exporter Resource, for events with no stamp of their own. */
801
801
  readonly resourceRepositoryKey?: string;
802
+ /**
803
+ * Repository key of the session directory's `origin` remote; for events with no
804
+ * stamp of their own, ahead of {@link resourceRepositoryKey}. Never exported.
805
+ */
806
+ readonly workspaceRepositoryKey?: string;
802
807
  readonly restrict: ContentRestrictor;
803
808
  };
804
809
  /**
@@ -821,7 +826,7 @@ declare const routeEventsToScopes: (events: readonly CanonicalEvent[], scopes: r
821
826
  * destinations.
822
827
  */
823
828
  declare const routePointsToScopes: (scopes: readonly DestinationScope[], pointsFor: (includeSessionId: boolean) => readonly MetricPoint[] | undefined, options: {
824
- /** Repository key for points with no stamp of their own (context, then Resource). */
829
+ /** Repository key for points with no stamp of their own (workspace remote, then Resource). */
825
830
  readonly fallbackKey: string | undefined;
826
831
  /** The installation's `exporter.metrics.includeSessionId`; a scope can only turn it off. */
827
832
  readonly includeSessionId: boolean;
@@ -865,8 +870,11 @@ type ExportDestinationSinks = {
865
870
  * destination is sent every record, exactly as before scopes existed.
866
871
  */
867
872
  readonly scopes?: readonly DestinationScope[];
868
- /** Splits a batch by {@link scopes}; present exactly when they are. */
869
- readonly route?: (events: readonly CanonicalEvent[]) => ScopedBatch;
873
+ /**
874
+ * Splits a batch by {@link scopes}; present exactly when they are. The workspace
875
+ * key is the batch's `TelemetryEmitOptions.workspaceRepositoryKey`.
876
+ */
877
+ readonly route?: (events: readonly CanonicalEvent[], workspaceRepositoryKey?: string) => ScopedBatch;
870
878
  };
871
879
  /** A destination left out of this invocation, and why — by name only. */
872
880
  type SkippedExportDestination = {
@@ -1,4 +1,4 @@
1
- import { j as StateStore, C as Clock, d as Logger } from './ports-DhpSDIkp.js';
1
+ import { j as StateStore, C as Clock, d as Logger } from './ports-qZTwK-z2.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-DySC7KQM.js';
8
- import { b as DeliveryIdentifierSupport, f as ProviderDeliveryClaim, j as ProviderHookResponse } from './adapter-D5R8lhfl.js';
9
- import { P as ProviderRegistry } from './registry-DOJh9mzB.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';
8
+ import { b as DeliveryIdentifierSupport, f as ProviderDeliveryClaim, j as ProviderHookResponse } from './adapter-But5fFCk.js';
9
+ import { P as ProviderRegistry } from './registry-D9rmMYxw.js';
10
+ import { I as IdGenerator, m as TelemetrySink, j as StateStore, C as Clock, d as Logger, W as WorktreeLocator, P as PayloadEnricher, S as SessionContextReader } from './ports-qZTwK-z2.js';
11
11
  import { A as AttributionOutcome, a as AttributionReason } from './taxonomy-DwhTtuWd.js';
12
12
 
13
13
  /**
@@ -224,6 +224,13 @@ type HookIngestOutcome = {
224
224
  readonly dropped: number;
225
225
  readonly hookResponse: ProviderHookResponse;
226
226
  readonly diagnostics: readonly OtelHookErrorInfo[];
227
+ /**
228
+ * Repository key of the session workspace's `origin` remote, when
229
+ * `routeByWorkspaceRepository` asked for it and one was found. Routing only —
230
+ * what the batch's records were routed by when no context stamp named a
231
+ * repository; never exported. The metrics of this callback route by it too.
232
+ */
233
+ readonly workspaceRepositoryKey?: string;
227
234
  };
228
235
  type HookIngestOptions = {
229
236
  /**
@@ -298,6 +305,13 @@ type OtelHookDependencies = {
298
305
  * implementation is `createDirectorySessionContextReader`.
299
306
  */
300
307
  readonly sessionContext?: SessionContextReader;
308
+ /**
309
+ * Read the `origin` remote of the session directory's repository through the
310
+ * {@link worktreeLocator}, and hand its key to the sink as
311
+ * `TelemetryEmitOptions.workspaceRepositoryKey`. Set when a destination has
312
+ * scopes; off, nothing extra is read.
313
+ */
314
+ readonly routeByWorkspaceRepository?: boolean;
301
315
  };
302
316
  /**
303
317
  * Minimal orchestrator wiring detection, identity, parsing, privacy checks,
package/dist/index.d.ts CHANGED
@@ -10,20 +10,20 @@ export { WorkspaceKeyInput, WorkspaceLabels, canonicalizeGitRemote, deriveWorksp
10
10
  export { ATTR_VCS_REPOSITORY_URL_FULL, CONFIG_SOURCE_PRECEDENCE, ConfigLayer, ConfigProvenance, ConfigResolution, ConfigSource, EMPTY_RESOURCE_ATTRIBUTES, ENVIRONMENT_VARIABLES, EnvironmentConfigResult, EnvironmentRecord, MAX_OTLP_HEADERS, MAX_REPOSITORY_REFERENCE_LENGTH, 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, normalizeRepositoryKey, 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_ENDPOINT_DOWN_MILLIS, d as DEFAULT_EXPORTER_POLICY, e as DEFAULT_EXPORT_BUDGET_MILLIS, f as DEFAULT_LOGS_POLICY, g as DEFAULT_METRICS_POLICY, h as DEFAULT_PROVIDERS_POLICY, i as DetectionPolicy, j as DiagnosticsPolicy, E as ExporterPolicy, L as LogsPolicy, M as MetricsPolicy, O as OtelHookConfig, k as OtelHookConfigPatch, P as ProvidersPolicy, S as SessionContextPolicy, l as detectionPolicySchema, m as diagnosticsPolicySchema, n as effectiveExportTimeoutMillis, o as effectiveMetricsPolicy, p as exporterPolicySchema, q as logsPolicySchema, r as metricsPolicySchema, s as otelHookConfigPatchSchema, t as otelHookConfigSchema, u as providersPolicySchema, v as readsClaudeTranscriptUsage, w as readsCodexRolloutUsage, x as sessionContextDir, y as sessionContextPolicySchema } from './schema-oRsbo7WO.js';
12
12
  export { A as ALL_REPOSITORIES, 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 DestinationScope, f as DestinationScopeConfig, g as DestinationScopeDescription, E as ExportDestination, h as ExportDestinationConfig, i as ExportSignal, H as HEADER_ENV_REFERENCE_PREFIX, j as HeaderValueReference, M as MAX_DESTINATION_HEADERS, k as MAX_DESTINATION_SCOPES, l as MAX_EXPORT_DESTINATIONS, m as MAX_SCOPE_REPOSITORIES, R as ResolvedDestinationHeaders, S as SignalFlags, n as SpoolPolicy, o as describeExportDestinations, p as destinationScopeSchema, q as effectiveSpoolPolicy, r as endpointOrigin, s as exportDestinationSchema, t as exportDestinationsSchema, u as exportSignalSchema, v as hasConfiguredDestinations, w as matchDestinationScope, x as parseHeaderValueReference, y as resolveDestinationHeaders, z as resolveDestinationScopes, B as resolveExportDestinations, C as spoolPolicySchema } from './destinations-2KrcRslo.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-D5R8lhfl.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-But5fFCk.js';
14
14
  export { ANTIGRAVITY_PROMOTION_GATES, ANTIGRAVITY_PROVIDER_MATURITY, AntigravityProviderMaturity, CLAUDE_CODE_CAPABILITIES, CLAUDE_TRANSCRIPT_USAGE_ENRICHER_ID, CODEX_CAPABILITIES, CODEX_ROLLOUT_USAGE_ENRICHER_ID, CURSOR_ADAPTER_VERSION, CURSOR_CAPABILITIES, CanonicalEventDraft, ClaudeCodeAdapterOptions, ClaudeTranscriptRange, ClaudeTranscriptTurn, ClaudeTranscriptUsageEnricherOptions, CodexRolloutSnapshot, CodexRolloutUsageEnricherOptions, CursorAdapterOptions, DEFAULT_CLAUDE_TRANSCRIPT_RANGE_BYTES, DEFAULT_CLAUDE_TRANSCRIPT_RANGE_TIMEOUT_MILLIS, DEFAULT_CLAUDE_TRANSCRIPT_TAIL_BYTES, DEFAULT_CLAUDE_TRANSCRIPT_TIMEOUT_MILLIS, DEFAULT_CODEX_ROLLOUT_RANGE_BYTES, DEFAULT_CODEX_ROLLOUT_SETTLE_MILLIS, DEFAULT_CODEX_ROLLOUT_TAIL_BYTES, DEFAULT_CODEX_ROLLOUT_TIMEOUT_MILLIS, DELIVERY_IDENTIFIER_SUMMARY, DefaultRegistryOptions, EXPERIMENTAL_PROVIDER_IDS, EventFactory, EventFactoryInput, PROVIDER_DESCRIPTORS, ProviderCatalogEntry, ProviderDescriptor, ProviderMaturity, ReadClaudeTranscriptRangeOptions, ReadClaudeTranscriptTurnOptions, attachClaudeTranscriptTurn, createClaudeCodeAdapter, createClaudeTranscriptUsageEnricher, createCodexAdapter, createCodexRolloutUsageEnricher, createCursorAdapter, createDefaultProviderRegistry, createEventFactory, describeProviderCatalog, findProviderDescriptor, isExperimentalProvider, readClaudeTranscriptRange, readClaudeTranscriptTurn, readCodexRolloutUsage } from './providers.js';
15
- export { B as BUILT_IN_PROVIDERS, D as DetectionCandidate, P as ProviderRegistry, R as RegistryDetectionResult, c as createProviderRegistry } from './registry-DOJh9mzB.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-D4r71EL-.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
- 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-DVK8Don-.js';
15
+ export { B as BUILT_IN_PROVIDERS, D as DetectionCandidate, P as ProviderRegistry, R as RegistryDetectionResult, c as createProviderRegistry } from './registry-D9rmMYxw.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-DWdx9yk3.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 TelemetryEmitOptions, l as TelemetryEmitResult, m as TelemetrySink, W as WorktreeLocator, n as appliedDeliverySchema, o as logLevelSchema, s as stateRecordSchema, p as stateValueSchema } from './ports-qZTwK-z2.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-gipZUiXP.js';
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, parseOriginRemoteUrl, 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-D7XABd4f.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-B3CpiIRl.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-Z8XgDtFj.js';
24
24
  export { BoundedMemoryStateStore, BoundedMemoryStateStoreOptions, createBoundedMemoryStateStore } from './state.js';
25
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-B4lIuk6i.js';
26
- export { C as ContentRestrictor, a as ContentWithholdingReason, D as DestinationFanoutOptions, b as DurableLogSpool, c as DurableLogSpoolOptions, d as DurableMetricSpool, e as DurableMetricSpoolOptions, f as DurableSpool, g as DurableSpoolOptions, E as ExportDestinationSinks, h as ExportDestinationsOptions, L as LOG_MAPPING_VERSION, i as LOG_SIGNALS, j as LogContentPolicy, k as LogMappingOptions, l as LogMappingResult, m as LogSignal, n as LogSpoolBatch, o as LogsDeliverability, M as MAX_LOG_BODY_CHARACTERS, p as MAX_LOG_RECORDS_PER_BATCH, q as MAX_LOG_RECORDS_PER_EVENT, r as MCP_TOOL_NAME_PATTERN, s as MetricExportResult, t as MetricSpoolBatch, u as MetricsDeliverability, N as NO_LOG_CONTENT, O as OtlpLogSinkOptions, v as OtlpLogTelemetrySink, w as OtlpMetricSinkOptions, x as OtlpMetricTelemetrySink, y as OtlpTelemetrySink, z as OtlpTraceSinkOptions, R as RouteEventsOptions, S as ScopedBatch, A as SerializedLogRecord, B as SerializedSpan, F as SharedCorrelationResolver, G as SignalFanoutOptions, H as SignalFanoutSink, I as SkippedExportDestination, J as SpoolBatch, K as SpoolDrainResult, P as SpoolDropCounts, Q as SpoolDropReason, T as SpoolEnqueueResult, U as SpoolOverflowPolicy, V as SpoolSendOutcome, W as SpoolStats, X as canonicalEventsToLogRecords, Y as createDestinationFanout, Z as createExportDestinationSinks, _ as createFileDurableLogSpool, $ as createFileDurableMetricSpool, a0 as createFileDurableSpool, a1 as createOtlpLogSink, a2 as createOtlpMetricSink, a3 as createOtlpTraceSink, a4 as createSignalFanout, a5 as describeLogsDeliverability, a6 as describeMetricsDeliverability, a7 as eventRepositoryKey, a8 as exporterPolicyForDestination, a9 as logSignalOf, aa as logSignalsForLifecycleEvents, ab as omitRestrictedContent, ac as pointRepositoryKey, ad as resolveLogsEndpoint, ae as resolveMetricsEndpoint, af as resourceRepositoryKey, ag as restrictEventContent, ah as routeEventsToScopes, ai as routePointsToScopes, aj as sessionIdVariantsFor, ak as shareCorrelationPerBatch, al as spoolQueueNamesFor, am as validateMetricSpoolBatch } from './export-destinations-DvoH4QOe.js';
26
+ export { C as ContentRestrictor, a as ContentWithholdingReason, D as DestinationFanoutOptions, b as DurableLogSpool, c as DurableLogSpoolOptions, d as DurableMetricSpool, e as DurableMetricSpoolOptions, f as DurableSpool, g as DurableSpoolOptions, E as ExportDestinationSinks, h as ExportDestinationsOptions, L as LOG_MAPPING_VERSION, i as LOG_SIGNALS, j as LogContentPolicy, k as LogMappingOptions, l as LogMappingResult, m as LogSignal, n as LogSpoolBatch, o as LogsDeliverability, M as MAX_LOG_BODY_CHARACTERS, p as MAX_LOG_RECORDS_PER_BATCH, q as MAX_LOG_RECORDS_PER_EVENT, r as MCP_TOOL_NAME_PATTERN, s as MetricExportResult, t as MetricSpoolBatch, u as MetricsDeliverability, N as NO_LOG_CONTENT, O as OtlpLogSinkOptions, v as OtlpLogTelemetrySink, w as OtlpMetricSinkOptions, x as OtlpMetricTelemetrySink, y as OtlpTelemetrySink, z as OtlpTraceSinkOptions, R as RouteEventsOptions, S as ScopedBatch, A as SerializedLogRecord, B as SerializedSpan, F as SharedCorrelationResolver, G as SignalFanoutOptions, H as SignalFanoutSink, I as SkippedExportDestination, J as SpoolBatch, K as SpoolDrainResult, P as SpoolDropCounts, Q as SpoolDropReason, T as SpoolEnqueueResult, U as SpoolOverflowPolicy, V as SpoolSendOutcome, W as SpoolStats, X as canonicalEventsToLogRecords, Y as createDestinationFanout, Z as createExportDestinationSinks, _ as createFileDurableLogSpool, $ as createFileDurableMetricSpool, a0 as createFileDurableSpool, a1 as createOtlpLogSink, a2 as createOtlpMetricSink, a3 as createOtlpTraceSink, a4 as createSignalFanout, a5 as describeLogsDeliverability, a6 as describeMetricsDeliverability, a7 as eventRepositoryKey, a8 as exporterPolicyForDestination, a9 as logSignalOf, aa as logSignalsForLifecycleEvents, ab as omitRestrictedContent, ac as pointRepositoryKey, ad as resolveLogsEndpoint, ae as resolveMetricsEndpoint, af as resourceRepositoryKey, ag as restrictEventContent, ah as routeEventsToScopes, ai as routePointsToScopes, aj as sessionIdVariantsFor, ak as shareCorrelationPerBatch, al as spoolQueueNamesFor, am as validateMetricSpoolBatch } from './export-destinations-8tNkIC8a.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.14.0";
45
+ declare const VERSION = "0.14.1";
46
46
 
47
47
  export { VERSION };
package/dist/index.js CHANGED
@@ -4278,7 +4278,8 @@ var parseClaudeCode = (input, context) => {
4278
4278
  status: "parsed",
4279
4279
  events: factory.events(),
4280
4280
  ...warnings.length === 0 ? {} : { warnings },
4281
- ...targetHints.size === 0 ? {} : { targetHints }
4281
+ ...targetHints.size === 0 ? {} : { targetHints },
4282
+ ...payload.cwd === void 0 || payload.cwd.length === 0 ? {} : { workspaceDirectory: payload.cwd }
4282
4283
  };
4283
4284
  };
4284
4285
 
@@ -5143,6 +5144,13 @@ var deriveWorkspace = (context, payload) => {
5143
5144
  }
5144
5145
  return void 0;
5145
5146
  };
5147
+ var workspaceDirectoryOf = (payload) => {
5148
+ const roots = (payload.workspace_roots ?? []).filter((root) => root.length > 0);
5149
+ if (roots.length > 0) {
5150
+ return roots.length === 1 ? roots[0] : void 0;
5151
+ }
5152
+ return payload.cwd !== void 0 && payload.cwd.length > 0 ? payload.cwd : void 0;
5153
+ };
5146
5154
  var invocationDiscriminator = (payload) => {
5147
5155
  switch (payload.hook_event_name) {
5148
5156
  case "sessionStart":
@@ -5602,11 +5610,13 @@ var createCursorAdapter = (options = {}) => {
5602
5610
  }
5603
5611
  }
5604
5612
  const targetHints = factory.targetHints();
5613
+ const workspaceDirectory = workspaceDirectoryOf(payload);
5605
5614
  return {
5606
5615
  status: "parsed",
5607
5616
  events: factory.events(),
5608
5617
  ...warnings.length === 0 ? {} : { warnings },
5609
- ...targetHints.size === 0 ? {} : { targetHints }
5618
+ ...targetHints.size === 0 ? {} : { targetHints },
5619
+ ...workspaceDirectory === void 0 ? {} : { workspaceDirectory }
5610
5620
  };
5611
5621
  };
5612
5622
  const hookResponse2 = (input) => {
@@ -6281,7 +6291,8 @@ var parse = (input, context) => {
6281
6291
  status: "parsed",
6282
6292
  events: factory.events(),
6283
6293
  ...warnings.length === 0 ? {} : { warnings },
6284
- ...targetHints.size === 0 ? {} : { targetHints }
6294
+ ...targetHints.size === 0 ? {} : { targetHints },
6295
+ ...payload.cwd === void 0 || payload.cwd.length === 0 ? {} : { workspaceDirectory: payload.cwd }
6285
6296
  };
6286
6297
  };
6287
6298
  var hookResponse = () => SILENT_HOOK_RESPONSE;
@@ -7206,7 +7217,8 @@ var createGeminiCliAdapter = (options = {}) => {
7206
7217
  return {
7207
7218
  status: "parsed",
7208
7219
  events: factory.events(),
7209
- ...warnings.length === 0 ? {} : { warnings }
7220
+ ...warnings.length === 0 ? {} : { warnings },
7221
+ ...payload.cwd === void 0 || payload.cwd.length === 0 ? {} : { workspaceDirectory: payload.cwd }
7210
7222
  };
7211
7223
  };
7212
7224
  const hookResponse2 = () => SILENT_HOOK_RESPONSE;
@@ -7475,7 +7487,12 @@ var createAntigravityAdapter = (options = {}) => {
7475
7487
  reason: payload.fullyIdle ? "Stop signals execution/turn completion (fullyIdle=true) but exposes no session or generation identity, so it cannot become session.end or generation.end without inventing one" : "Stop received while the agent is not fully idle; the conversation continues and the hook exposes no lifecycle fact the canonical model can represent"
7476
7488
  };
7477
7489
  }
7478
- return { status: "parsed", events: factory.events() };
7490
+ const [onlyWorkspacePath, ...otherWorkspacePaths] = payload.workspacePaths;
7491
+ return {
7492
+ status: "parsed",
7493
+ events: factory.events(),
7494
+ ...onlyWorkspacePath === void 0 || onlyWorkspacePath.length === 0 || otherWorkspacePaths.length > 0 ? {} : { workspaceDirectory: onlyWorkspacePath }
7495
+ };
7479
7496
  };
7480
7497
  const hookResponse2 = () => SILENT_HOOK_RESPONSE;
7481
7498
  return {
@@ -8322,6 +8339,28 @@ var classifyDurability = (input) => {
8322
8339
  };
8323
8340
  var isCommittable = (durability) => durability !== "lost";
8324
8341
  var MAX_ERROR_EVENTS = 8;
8342
+ var resolveWorkspaceRepositoryKey = async (locator, directory, budgetMillis) => {
8343
+ if (locator?.originRepositoryKey === void 0) {
8344
+ return void 0;
8345
+ }
8346
+ let timer;
8347
+ const deadline = new Promise((resolve5) => {
8348
+ timer = setTimeout(() => resolve5(void 0), Math.max(0, budgetMillis));
8349
+ timer.unref?.();
8350
+ });
8351
+ try {
8352
+ return await Promise.race([
8353
+ locator.originRepositoryKey(directory).catch(() => void 0),
8354
+ deadline
8355
+ ]);
8356
+ } catch {
8357
+ return void 0;
8358
+ } finally {
8359
+ if (timer !== void 0) {
8360
+ clearTimeout(timer);
8361
+ }
8362
+ }
8363
+ };
8325
8364
  var collectContentFacts = (event3) => {
8326
8365
  const facts = [];
8327
8366
  const push = (fact) => {
@@ -8965,7 +9004,8 @@ var createOtelHook = (deps) => {
8965
9004
  kind: "ready",
8966
9005
  batch: batch2,
8967
9006
  dropped: screened.dropped,
8968
- ...parsed.targetHints === void 0 ? {} : { targetHints: parsed.targetHints }
9007
+ ...parsed.targetHints === void 0 ? {} : { targetHints: parsed.targetHints },
9008
+ ...parsed.workspaceDirectory === void 0 ? {} : { workspaceDirectory: parsed.workspaceDirectory }
8969
9009
  };
8970
9010
  };
8971
9011
  let prepared;
@@ -9033,11 +9073,19 @@ var createOtelHook = (deps) => {
9033
9073
  batch,
9034
9074
  !suppress && batch.length > 0 && deps.sessionContext !== void 0 ? await readSessionContext(deps.sessionContext, detection.providerId, identity.sessionId) : void 0
9035
9075
  );
9076
+ const workspaceRepositoryKey = !suppress && batch.length > 0 && deps.routeByWorkspaceRepository === true && prepared.workspaceDirectory !== void 0 ? await resolveWorkspaceRepositoryKey(
9077
+ deps.worktreeLocator,
9078
+ prepared.workspaceDirectory,
9079
+ deps.targetResolutionBudgetMillis ?? DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS
9080
+ ) : void 0;
9036
9081
  let emitted = 0;
9037
9082
  let exportRejected = 0;
9038
9083
  if (!suppress && batch.length > 0) {
9039
9084
  try {
9040
- const result = await deps.sink.emit(batch);
9085
+ const result = await deps.sink.emit(
9086
+ batch,
9087
+ workspaceRepositoryKey === void 0 ? void 0 : { workspaceRepositoryKey }
9088
+ );
9041
9089
  emitted = result.accepted;
9042
9090
  exportRejected = result.rejected;
9043
9091
  diagnostics.push(...result.errors);
@@ -9096,7 +9144,8 @@ var createOtelHook = (deps) => {
9096
9144
  durability,
9097
9145
  dropped,
9098
9146
  hookResponse: hookResponseFor(adapter, detection, "attributed", void 0, emitted, diagnostics),
9099
- diagnostics
9147
+ diagnostics,
9148
+ ...workspaceRepositoryKey === void 0 ? {} : { workspaceRepositoryKey }
9100
9149
  };
9101
9150
  } catch (thrown) {
9102
9151
  const info = errorInfoFromThrown(thrown, { code: "internal-error", phase: "parsing" });
@@ -9195,15 +9244,16 @@ var MAX_WORKTREE_WALK_DEPTH = 128;
9195
9244
  var MAX_GIT_FILE_BYTES = 4096;
9196
9245
  var MAX_CACHE_ENTRIES = 1024;
9197
9246
  var DEFAULT_WORKTREE_CACHE_TTL_MILLIS = 5e3;
9247
+ var MAX_GIT_CONFIG_BYTES = 64 * 1024;
9198
9248
  var MAX_BRANCH_NAME_LENGTH = 255;
9199
9249
  var ABSENT = Object.freeze({ kind: "absent" });
9200
9250
  var INVALID = Object.freeze({ kind: "invalid" });
9201
- var readBounded2 = async (filePath) => {
9251
+ var readBounded2 = async (filePath, maxBytes = MAX_GIT_FILE_BYTES) => {
9202
9252
  let handle;
9203
9253
  try {
9204
9254
  handle = await open4(filePath, "r");
9205
- const buffer = Buffer.alloc(MAX_GIT_FILE_BYTES);
9206
- const { bytesRead } = await handle.read(buffer, 0, MAX_GIT_FILE_BYTES, 0);
9255
+ const buffer = Buffer.alloc(maxBytes);
9256
+ const { bytesRead } = await handle.read(buffer, 0, maxBytes, 0);
9207
9257
  return buffer.subarray(0, bytesRead).toString("utf8");
9208
9258
  } catch {
9209
9259
  return void 0;
@@ -9231,6 +9281,60 @@ var parseGitDirFile = (content, worktreeRoot) => {
9231
9281
  );
9232
9282
  };
9233
9283
  var parseCommonDirFile = (content, gitDir) => resolveGitPath(firstLine(content), gitDir);
9284
+ var unquoteConfigValue = (raw) => {
9285
+ let value = "";
9286
+ let quoted = false;
9287
+ for (let index = 0; index < raw.length; index += 1) {
9288
+ const char = raw[index];
9289
+ if (char === "\\") {
9290
+ const next = raw[index + 1];
9291
+ if (next === void 0) {
9292
+ return void 0;
9293
+ }
9294
+ value += next === "n" ? "\n" : next === "t" ? " " : next;
9295
+ index += 1;
9296
+ } else if (char === '"') {
9297
+ quoted = !quoted;
9298
+ } else if (!quoted && (char === "#" || char === ";")) {
9299
+ break;
9300
+ } else {
9301
+ value += char;
9302
+ }
9303
+ }
9304
+ return quoted ? void 0 : value.trim();
9305
+ };
9306
+ var parseOriginRemoteUrl = (content) => {
9307
+ const lines = content.split(/\r?\n/);
9308
+ if (!content.endsWith("\n")) {
9309
+ lines.pop();
9310
+ }
9311
+ let inOrigin = false;
9312
+ for (const rawLine of lines) {
9313
+ const line = rawLine.trim();
9314
+ if (line.startsWith("[")) {
9315
+ const close = line.indexOf("]");
9316
+ const header = close === -1 ? "" : line.slice(1, close).trim();
9317
+ const rest = close === -1 ? "" : line.slice(close + 1).trim();
9318
+ inOrigin = /^remote\s+"origin"$/i.test(header) && header.endsWith('"origin"') || header.toLowerCase() === "remote.origin";
9319
+ if (!inOrigin || rest.length === 0 || rest.startsWith("#") || rest.startsWith(";")) {
9320
+ continue;
9321
+ }
9322
+ const entry2 = /^url\s*=(.*)$/i.exec(rest);
9323
+ if (entry2 !== null) {
9324
+ return unquoteConfigValue(entry2[1] ?? "");
9325
+ }
9326
+ continue;
9327
+ }
9328
+ if (!inOrigin) {
9329
+ continue;
9330
+ }
9331
+ const entry = /^url\s*=(.*)$/i.exec(line);
9332
+ if (entry !== null) {
9333
+ return unquoteConfigValue(entry[1] ?? "");
9334
+ }
9335
+ }
9336
+ return void 0;
9337
+ };
9234
9338
  var isMissing = async (filePath) => {
9235
9339
  try {
9236
9340
  await lstat(filePath);
@@ -9251,11 +9355,15 @@ var repositoryOf = async (worktreeRoot, gitDir) => {
9251
9355
  const commonDirFile = path5.join(gitDir, "commondir");
9252
9356
  const content = await readBounded2(commonDirFile);
9253
9357
  if (content === void 0) {
9254
- return await isMissing(commonDirFile) ? { kind: "main", mainRoot: worktreeRoot } : { kind: "linked" };
9358
+ return await isMissing(commonDirFile) ? { kind: "main", mainRoot: worktreeRoot, configDir: gitDir } : { kind: "linked" };
9255
9359
  }
9256
9360
  const commonDir = parseCommonDirFile(content, gitDir);
9257
9361
  const mainRoot = commonDir !== void 0 && path5.basename(commonDir) === ".git" && await isDirectory(commonDir) ? path5.dirname(commonDir) : void 0;
9258
- return { kind: "linked", ...mainRoot === void 0 ? {} : { mainRoot } };
9362
+ return {
9363
+ kind: "linked",
9364
+ ...mainRoot === void 0 ? {} : { mainRoot },
9365
+ ...commonDir === void 0 ? {} : { configDir: commonDir }
9366
+ };
9259
9367
  };
9260
9368
  var probeDirectory = async (directory) => {
9261
9369
  const dotGit = path5.join(directory, ".git");
@@ -9280,12 +9388,21 @@ var probeDirectory = async (directory) => {
9280
9388
  return INVALID;
9281
9389
  }
9282
9390
  const branch = parseHeadBranch(head);
9283
- const repository = info.isDirectory() ? { kind: "main", mainRoot: directory } : await repositoryOf(directory, gitDir);
9391
+ const { configDir, ...repository } = info.isDirectory() ? { kind: "main", mainRoot: directory, configDir: gitDir } : await repositoryOf(directory, gitDir);
9284
9392
  return {
9285
9393
  kind: "worktree",
9286
- located: { root: directory, ...branch === void 0 ? {} : { branch }, ...repository }
9394
+ located: { root: directory, ...branch === void 0 ? {} : { branch }, ...repository },
9395
+ configDir: configDir ?? ""
9287
9396
  };
9288
9397
  };
9398
+ var readOriginRepositoryKey = async (configDir) => {
9399
+ if (configDir.length === 0) {
9400
+ return void 0;
9401
+ }
9402
+ const content = await readBounded2(path5.join(configDir, "config"), MAX_GIT_CONFIG_BYTES);
9403
+ const url = content === void 0 ? void 0 : parseOriginRemoteUrl(content);
9404
+ return url === void 0 ? void 0 : normalizeRepositoryKey(url);
9405
+ };
9289
9406
  var createFilesystemWorktreeLocator = (options = {}) => {
9290
9407
  const now = options.monotonicMillis ?? (() => performance.now());
9291
9408
  const ttl = options.cacheTtlMillis ?? DEFAULT_WORKTREE_CACHE_TTL_MILLIS;
@@ -9303,32 +9420,57 @@ var createFilesystemWorktreeLocator = (options = {}) => {
9303
9420
  cache.set(directory, { at, probe });
9304
9421
  return probe;
9305
9422
  };
9306
- const locate = async (absolutePath) => {
9307
- try {
9308
- if (!path5.isAbsolute(absolutePath) || absolutePath.includes("\0")) {
9423
+ const remoteCache = /* @__PURE__ */ new Map();
9424
+ const cachedOriginKey = (configDir) => {
9425
+ const hit = remoteCache.get(configDir);
9426
+ const at = now();
9427
+ if (hit !== void 0 && at - hit.at <= ttl) {
9428
+ return hit.key;
9429
+ }
9430
+ if (remoteCache.size >= MAX_CACHE_ENTRIES) {
9431
+ remoteCache.clear();
9432
+ }
9433
+ const key = readOriginRepositoryKey(configDir).catch(() => void 0);
9434
+ remoteCache.set(configDir, { at, key });
9435
+ return key;
9436
+ };
9437
+ const findWorktree = async (absolutePath) => {
9438
+ if (!path5.isAbsolute(absolutePath) || absolutePath.includes("\0")) {
9439
+ return void 0;
9440
+ }
9441
+ let directory = path5.resolve(absolutePath);
9442
+ for (let depth = 0; depth < MAX_WORKTREE_WALK_DEPTH; depth += 1) {
9443
+ const probe = await cachedProbe(directory);
9444
+ if (probe.kind === "worktree") {
9445
+ return probe;
9446
+ }
9447
+ if (probe.kind === "invalid") {
9309
9448
  return void 0;
9310
9449
  }
9311
- let directory = path5.resolve(absolutePath);
9312
- for (let depth = 0; depth < MAX_WORKTREE_WALK_DEPTH; depth += 1) {
9313
- const probe = await cachedProbe(directory);
9314
- if (probe.kind === "worktree") {
9315
- return probe.located;
9316
- }
9317
- if (probe.kind === "invalid") {
9318
- return void 0;
9319
- }
9320
- const parent = path5.dirname(directory);
9321
- if (parent === directory) {
9322
- return void 0;
9323
- }
9324
- directory = parent;
9450
+ const parent = path5.dirname(directory);
9451
+ if (parent === directory) {
9452
+ return void 0;
9325
9453
  }
9454
+ directory = parent;
9455
+ }
9456
+ return void 0;
9457
+ };
9458
+ const locate = async (absolutePath) => {
9459
+ try {
9460
+ return (await findWorktree(absolutePath))?.located;
9461
+ } catch {
9326
9462
  return void 0;
9463
+ }
9464
+ };
9465
+ const originRepositoryKey = async (absolutePath) => {
9466
+ try {
9467
+ const probe = await findWorktree(absolutePath);
9468
+ return probe === void 0 ? void 0 : await cachedOriginKey(probe.configDir);
9327
9469
  } catch {
9328
9470
  return void 0;
9329
9471
  }
9330
9472
  };
9331
- return { locate };
9473
+ return { locate, originRepositoryKey };
9332
9474
  };
9333
9475
 
9334
9476
  // src/lifecycle/dedup.ts
@@ -9548,7 +9690,7 @@ import {
9548
9690
  } from "@opentelemetry/semantic-conventions/incubating";
9549
9691
 
9550
9692
  // src/version.ts
9551
- var VERSION = "0.14.0";
9693
+ var VERSION = "0.14.1";
9552
9694
 
9553
9695
  // src/telemetry/export-identity.ts
9554
9696
  import { ATTR_SESSION_ID } from "@opentelemetry/semantic-conventions/incubating";
@@ -13821,6 +13963,12 @@ var omitRestrictedContent = (fact, mode) => {
13821
13963
  };
13822
13964
  var keyOfValue = (value) => typeof value === "string" ? normalizeRepositoryKey(value) : void 0;
13823
13965
  var resourceRepositoryKey = (attributes) => keyOfValue(attributes[ATTR_VCS_REPOSITORY_URL_FULL]);
13966
+ var repositoryUrlForKey = (key) => `https://${key}`;
13967
+ var hasOwnStamp = (attributes) => attributes?.[ATTR_VCS_REPOSITORY_URL_FULL] !== void 0;
13968
+ var withRoutedRepository = (event3, key) => hasOwnStamp(event3.contextAttributes) ? event3 : {
13969
+ ...event3,
13970
+ contextAttributes: { ...event3.contextAttributes, [ATTR_VCS_REPOSITORY_URL_FULL]: repositoryUrlForKey(key) }
13971
+ };
13824
13972
  var eventRepositoryKey = (event3, fallbackKey) => {
13825
13973
  const stamped = event3.contextAttributes?.[ATTR_VCS_REPOSITORY_URL_FULL];
13826
13974
  return stamped === void 0 ? fallbackKey : keyOfValue(stamped);
@@ -13854,19 +14002,21 @@ var restrictEventContent = (event3, mode, restrict) => {
13854
14002
  };
13855
14003
  var routeEventsToScopes = (events, scopes, options) => {
13856
14004
  const ends = spanEndEdgesOf(events);
14005
+ const fallbackKey = options.workspaceRepositoryKey ?? options.resourceRepositoryKey;
13857
14006
  const traces = [];
13858
14007
  const logs = [];
13859
14008
  let unchanged = true;
13860
14009
  for (const event3 of events) {
13861
14010
  const anchor = ends.get(event3.eventId) ?? event3;
13862
- const scope = matchDestinationScope(scopes, eventRepositoryKey(anchor, options.resourceRepositoryKey));
14011
+ const scope = matchDestinationScope(scopes, eventRepositoryKey(anchor, fallbackKey));
13863
14012
  if (scope === void 0 || !scope.signals.traces || !scope.signals.logs) {
13864
14013
  unchanged = false;
13865
14014
  }
13866
14015
  if (scope === void 0) {
13867
14016
  continue;
13868
14017
  }
13869
- const restricted = scope.contentMode === void 0 ? event3 : restrictEventContent(event3, scope.contentMode, options.restrict);
14018
+ const lowered = scope.contentMode === void 0 ? event3 : restrictEventContent(event3, scope.contentMode, options.restrict);
14019
+ const restricted = hasOwnStamp(anchor.contextAttributes) || fallbackKey === void 0 ? lowered : withRoutedRepository(lowered, fallbackKey);
13870
14020
  if (restricted !== event3) {
13871
14021
  unchanged = false;
13872
14022
  }
@@ -13889,7 +14039,15 @@ var routePointsToScopes = (scopes, pointsFor, options) => {
13889
14039
  for (const point of pointsFor(variant) ?? []) {
13890
14040
  const scope = matchDestinationScope(scopes, pointRepositoryKey(point, options.fallbackKey));
13891
14041
  if (scope?.signals.metrics === true && effective(scope) === variant) {
13892
- kept.push(point);
14042
+ kept.push(
14043
+ hasOwnStamp(point.attributes) || options.fallbackKey === void 0 ? point : {
14044
+ ...point,
14045
+ attributes: {
14046
+ ...point.attributes,
14047
+ [ATTR_VCS_REPOSITORY_URL_FULL]: repositoryUrlForKey(options.fallbackKey)
14048
+ }
14049
+ }
14050
+ );
13893
14051
  }
13894
14052
  }
13895
14053
  }
@@ -14059,8 +14217,9 @@ var createExportDestinationSinks = (options) => {
14059
14217
  ...metricSpool === void 0 ? {} : { metricSpool },
14060
14218
  ...destination.scopes === void 0 ? {} : {
14061
14219
  scopes: destination.scopes,
14062
- route: (events) => routeEventsToScopes(events, destination.scopes ?? [], {
14220
+ route: (events, workspaceRepositoryKey) => routeEventsToScopes(events, destination.scopes ?? [], {
14063
14221
  ...scopedResourceKey === void 0 ? {} : { resourceRepositoryKey: scopedResourceKey },
14222
+ ...workspaceRepositoryKey === void 0 ? {} : { workspaceRepositoryKey },
14064
14223
  restrict
14065
14224
  })
14066
14225
  }
@@ -14077,8 +14236,8 @@ var createScopedFanout = (destination, correlate) => {
14077
14236
  const none2 = { accepted: 0, rejected: 0, errors: [] };
14078
14237
  return {
14079
14238
  ...unscoped,
14080
- emit: async (events) => {
14081
- const batch = route(events);
14239
+ emit: async (events, emitOptions) => {
14240
+ const batch = route(events, emitOptions?.workspaceRepositoryKey);
14082
14241
  if (correlate !== void 0 && (batch.traces.length > 0 || batch.logs.length > 0)) {
14083
14242
  await correlate(events);
14084
14243
  correlate.alias(batch.traces, events);
@@ -14104,10 +14263,10 @@ var createDestinationFanout = (destinations, options = {}) => {
14104
14263
  if (only !== void 0) {
14105
14264
  return only.sink;
14106
14265
  }
14107
- const emit = async (events) => {
14266
+ const emit = async (events, emitOptions) => {
14108
14267
  const results = await Promise.all(
14109
14268
  fanouts.map(
14110
- (fanout) => fanout.sink.emit(events).catch(
14269
+ (fanout) => fanout.sink.emit(events, emitOptions).catch(
14111
14270
  (thrown) => ({
14112
14271
  accepted: 0,
14113
14272
  rejected: events.length,
@@ -14269,7 +14428,12 @@ var createHookRuntime = (options) => {
14269
14428
  })(),
14270
14429
  ...options.worktreeLocator === null ? {} : {
14271
14430
  worktreeLocator: options.worktreeLocator ?? createFilesystemWorktreeLocator({ monotonicMillis: () => clock.monotonicMillis() })
14272
- }
14431
+ },
14432
+ // Only a scoped destination routes by repository, so only then is the session
14433
+ // directory's remote read at all.
14434
+ routeByWorkspaceRepository: exportDestinations.destinations.some(
14435
+ (destination) => destination.scopes !== void 0
14436
+ )
14273
14437
  };
14274
14438
  const hook = createOtelHook({ ...hookDeps, sink });
14275
14439
  const deduplicator = createCallbackDeduplicator({ stateStore, clock });
@@ -14347,9 +14511,10 @@ var createHookRuntime = (options) => {
14347
14511
  turnStarts.set(event3.sessionId, await metricSeries.readTurnStart(event3.sessionId));
14348
14512
  }
14349
14513
  }
14350
- const scopedRepositoryFallback = scopedMetricDestinations.length === 0 ? void 0 : resourceRepositoryKey(metricResource.attributes);
14514
+ const resourceFallback = scopedMetricDestinations.length === 0 ? void 0 : resourceRepositoryKey(metricResource.attributes);
14515
+ const scopedRepositoryFallback = scopedMetricDestinations.length === 0 ? void 0 : ingest.workspaceRepositoryKey ?? resourceFallback;
14351
14516
  const resourceRepository = metricResource.attributes[ATTR_VCS_REPOSITORY_URL_FULL];
14352
- const metricEvents = scopedRepositoryFallback === void 0 || typeof resourceRepository !== "string" ? ingest.events : ingest.events.map(
14517
+ const metricEvents = resourceFallback === void 0 || ingest.workspaceRepositoryKey !== void 0 || typeof resourceRepository !== "string" ? ingest.events : ingest.events.map(
14353
14518
  (event3) => event3.contextAttributes?.[ATTR_VCS_REPOSITORY_URL_FULL] === void 0 ? {
14354
14519
  ...event3,
14355
14520
  contextAttributes: {
@@ -16513,6 +16678,7 @@ export {
16513
16678
  parseGitDirFile,
16514
16679
  parseHeadBranch,
16515
16680
  parseHeaderValueReference,
16681
+ parseOriginRemoteUrl,
16516
16682
  parseOtlpHeadersValue,
16517
16683
  parseResourceAttributesValue,
16518
16684
  parseSessionContextFile,