@osfactory/otel-hook 0.4.1 → 0.5.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 (43) hide show
  1. package/dist/{adapter-BgqtlADe.d.ts → adapter-BS7xHKGQ.d.ts} +2 -3
  2. package/dist/cli.js +54 -12
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{events-C3h3GvHj.d.ts → events-CzZ5kukS.d.ts} +119 -1
  5. package/dist/{filesystem-store-BAq3VGVv.d.ts → filesystem-store-BcOveJYY.d.ts} +1 -1
  6. package/dist/{hook-CQiNa88Q.d.ts → hook-DxTakjAD.d.ts} +4 -4
  7. package/dist/index.d.ts +12 -13
  8. package/dist/index.js +56 -12
  9. package/dist/index.js.map +1 -1
  10. package/dist/install.d.ts +4 -5
  11. package/dist/install.js +5 -1
  12. package/dist/install.js.map +1 -1
  13. package/dist/integration.d.ts +8 -9
  14. package/dist/integration.js +54 -12
  15. package/dist/integration.js.map +1 -1
  16. package/dist/lifecycle.d.ts +3 -3
  17. package/dist/lifecycle.js +6 -2
  18. package/dist/lifecycle.js.map +1 -1
  19. package/dist/{memory-kflYgZbg.d.ts → memory-DkTohdIa.d.ts} +2 -2
  20. package/dist/model.d.ts +1 -2
  21. package/dist/model.js +7 -2
  22. package/dist/model.js.map +1 -1
  23. package/dist/{otlp-log-sink-BZIgYPKN.d.ts → otlp-log-sink-DaZDPKnR.d.ts} +3 -3
  24. package/dist/{payload-DpyU8F-z.d.ts → payload-2lnpKodw.d.ts} +1 -1
  25. package/dist/{ports-B_iwJQPQ.d.ts → ports-B0rC49b3.d.ts} +9 -1
  26. package/dist/providers.d.ts +7 -8
  27. package/dist/providers.js +5 -1
  28. package/dist/providers.js.map +1 -1
  29. package/dist/{registry-BSBS8t7S.d.ts → registry-DVnPA_b6.d.ts} +1 -1
  30. package/dist/runtime.d.ts +31 -15
  31. package/dist/runtime.js +46 -9
  32. package/dist/runtime.js.map +1 -1
  33. package/dist/{semconv-BeUPQ7_q.d.ts → semconv-CtnDdsPk.d.ts} +1 -1
  34. package/dist/state.d.ts +4 -4
  35. package/dist/state.js.map +1 -1
  36. package/dist/telemetry.d.ts +6 -6
  37. package/dist/telemetry.js +9 -3
  38. package/dist/telemetry.js.map +1 -1
  39. package/dist/testing.d.ts +7 -8
  40. package/dist/testing.js +9 -2
  41. package/dist/testing.js.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/target-8RfaVxp8.d.ts +0 -83
@@ -155,6 +155,104 @@ declare const toReport: (usage: CanonicalUsage) => UsageReport;
155
155
  */
156
156
  declare const addUsage: (a: CanonicalUsage, b: CanonicalUsage) => CanonicalUsage;
157
157
 
158
+ /**
159
+ * Per-event workspace targeting (ADR 0008).
160
+ *
161
+ * A session's `workspace` is where the agent was *started*. An agent routinely
162
+ * works somewhere else — in a linked git worktree beside the checkout it was
163
+ * launched from — and the session-level identity cannot show that. A tool event
164
+ * can: the file it edited, or the directory its shell command ran in, names the
165
+ * worktree it actually touched.
166
+ *
167
+ * Two values model that, and the split between them is the privacy boundary:
168
+ *
169
+ * - {@link TargetHint} is what an adapter observed — local paths. It is an
170
+ * in-process value only: it is never part of a {@link CanonicalEvent}, never
171
+ * persisted, never exported. The core resolves it and drops it.
172
+ * - {@link WorkspaceTarget} is what the core resolved — salted handles of the
173
+ * worktree and its repository, the worktree's kind, the checked-out branch, and
174
+ * what the evidence was. It travels on the event.
175
+ */
176
+ /**
177
+ * What a target was derived from, strongest evidence first.
178
+ *
179
+ * - `tool-path` — a path the tool call itself named (an edited or read file, a
180
+ * patch header).
181
+ * - `shell-cwd` — the working directory the provider reports a shell command ran in.
182
+ * - `session-cwd` — only the session's own directory was known; the event may
183
+ * have reached elsewhere (e.g. a shell `cd`) without the provider saying so.
184
+ */
185
+ declare const targetSourceSchema: z.ZodEnum<{
186
+ "tool-path": "tool-path";
187
+ "shell-cwd": "shell-cwd";
188
+ "session-cwd": "session-cwd";
189
+ }>;
190
+ type TargetSource = z.infer<typeof targetSourceSchema>;
191
+ /** Most paths one hint may name; a bound, not a sampling rule (all must agree). */
192
+ declare const MAX_TARGET_HINT_PATHS = 8;
193
+ /** Longest local path a hint may carry. Longer input is dropped, never truncated. */
194
+ declare const MAX_TARGET_PATH_LENGTH = 4096;
195
+ /**
196
+ * An adapter's observation of where a tool event pointed. **Carries local paths**
197
+ * — in-process only, see the module note.
198
+ *
199
+ * Every path in one hint must resolve to the same worktree, or the event gets no
200
+ * target at all: a patch touching two worktrees did not target either of them.
201
+ */
202
+ declare const targetHintSchema: z.ZodReadonly<z.ZodObject<{
203
+ source: z.ZodEnum<{
204
+ "tool-path": "tool-path";
205
+ "shell-cwd": "shell-cwd";
206
+ "session-cwd": "session-cwd";
207
+ }>;
208
+ paths: z.ZodReadonly<z.ZodArray<z.ZodString>>;
209
+ baseDirectory: z.ZodOptional<z.ZodString>;
210
+ }, z.core.$strict>>;
211
+ type TargetHint = z.infer<typeof targetHintSchema>;
212
+ /**
213
+ * Whether a worktree is its repository's main checkout (`main`) or one added
214
+ * beside it with `git worktree add` (`linked`).
215
+ */
216
+ declare const worktreeKindSchema: z.ZodEnum<{
217
+ main: "main";
218
+ linked: "linked";
219
+ }>;
220
+ type WorktreeKind = z.infer<typeof worktreeKindSchema>;
221
+ /**
222
+ * The git worktree a tool event targeted. Exported; carries no path.
223
+ *
224
+ * `workspaceId` is derived exactly like a `git-root` workspace identity, so a
225
+ * consumer holding the same salt can match it against one it derived itself.
226
+ * `repositoryId` is the same derivation applied to the repository's main
227
+ * worktree, so every worktree of one repository shares it — and for a main
228
+ * worktree it equals `workspaceId`.
229
+ */
230
+ declare const workspaceTargetSchema: z.ZodReadonly<z.ZodObject<{
231
+ workspaceId: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
232
+ vcsBranchName: z.ZodOptional<z.ZodString>;
233
+ source: z.ZodEnum<{
234
+ "tool-path": "tool-path";
235
+ "shell-cwd": "shell-cwd";
236
+ "session-cwd": "session-cwd";
237
+ }>;
238
+ repositoryId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">>;
239
+ worktreeKind: z.ZodOptional<z.ZodEnum<{
240
+ main: "main";
241
+ linked: "linked";
242
+ }>>;
243
+ }, z.core.$strict>>;
244
+ type WorkspaceTarget = z.infer<typeof workspaceTargetSchema>;
245
+ /**
246
+ * Shape a provider's own subagent identifier must have to be exported.
247
+ *
248
+ * Identifier-shaped on purpose — no whitespace, no path separators — so a
249
+ * malformed payload field cannot carry prose or a path onto the wire under an id
250
+ * attribute. A value that does not fit is dropped, not repaired.
251
+ */
252
+ declare const SUBAGENT_ID_PATTERN: RegExp;
253
+ declare const subagentIdSchema: z.ZodString;
254
+ type SubagentId = z.infer<typeof subagentIdSchema>;
255
+
158
256
  /** Model being invoked. Model identifiers are not treated as sensitive. */
159
257
  declare const modelDescriptorSchema: z.ZodObject<{
160
258
  modelId: z.ZodString;
@@ -726,6 +824,11 @@ declare const toolStartEventSchema: z.ZodObject<{
726
824
  "shell-cwd": "shell-cwd";
727
825
  "session-cwd": "session-cwd";
728
826
  }>;
827
+ repositoryId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">>;
828
+ worktreeKind: z.ZodOptional<z.ZodEnum<{
829
+ main: "main";
830
+ linked: "linked";
831
+ }>>;
729
832
  }, z.core.$strict>>>;
730
833
  }, z.core.$strict>;
731
834
  declare const toolEndEventSchema: z.ZodObject<{
@@ -827,6 +930,11 @@ declare const toolEndEventSchema: z.ZodObject<{
827
930
  "shell-cwd": "shell-cwd";
828
931
  "session-cwd": "session-cwd";
829
932
  }>;
933
+ repositoryId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">>;
934
+ worktreeKind: z.ZodOptional<z.ZodEnum<{
935
+ main: "main";
936
+ linked: "linked";
937
+ }>>;
830
938
  }, z.core.$strict>>>;
831
939
  }, z.core.$strict>;
832
940
  declare const subagentStartEventSchema: z.ZodObject<{
@@ -1657,6 +1765,11 @@ declare const canonicalEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1657
1765
  "shell-cwd": "shell-cwd";
1658
1766
  "session-cwd": "session-cwd";
1659
1767
  }>;
1768
+ repositoryId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">>;
1769
+ worktreeKind: z.ZodOptional<z.ZodEnum<{
1770
+ main: "main";
1771
+ linked: "linked";
1772
+ }>>;
1660
1773
  }, z.core.$strict>>>;
1661
1774
  }, z.core.$strict>, z.ZodObject<{
1662
1775
  schemaVersion: z.ZodLiteral<1>;
@@ -1757,6 +1870,11 @@ declare const canonicalEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1757
1870
  "shell-cwd": "shell-cwd";
1758
1871
  "session-cwd": "session-cwd";
1759
1872
  }>;
1873
+ repositoryId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">>;
1874
+ worktreeKind: z.ZodOptional<z.ZodEnum<{
1875
+ main: "main";
1876
+ linked: "linked";
1877
+ }>>;
1760
1878
  }, z.core.$strict>>>;
1761
1879
  }, z.core.$strict>, z.ZodObject<{
1762
1880
  schemaVersion: z.ZodLiteral<1>;
@@ -2099,4 +2217,4 @@ declare const eventUsage: (event: CanonicalEvent) => CanonicalUsage | undefined;
2099
2217
  /** Stable ordering: by sequence, then by timestamp, then by event id. */
2100
2218
  declare const compareEvents: (a: CanonicalEvent, b: CanonicalEvent) => number;
2101
2219
 
2102
- export { subagentStartEventSchema as $, canonicalEventTypeSchema as A, canonicalUsageSchema as B, CANONICAL_EVENT_TYPES as C, compactionPerformedEventSchema as D, EMPTY_DELTA_USAGE as E, compareEvents as F, type GenerationEndEvent as G, costFactsSchema as H, cumulativeToDelta as I, errorRaisedEventSchema as J, eventUsage as K, generationEndEventSchema as L, type ModelDescriptor as M, generationStartEventSchema as N, modelDescriptorSchema as O, type PromptSubmittedEvent as P, normalizeUsage as Q, normalizeUsageOrThrow as R, type SessionEndEvent as S, type ToolEndEvent as T, type UsageDeltaResult as U, parseCanonicalEvent as V, promptSubmittedEventSchema as W, providerTotalAgreementSchema as X, sessionEndEventSchema as Y, sessionStartEventSchema as Z, subagentEndEventSchema as _, type CacheCreationAccounting as a, toReport as a0, toolEndEventSchema as a1, toolKindSchema as a2, toolStartEventSchema as a3, usageReportSchema as a4, usageTemporalitySchema as a5, validateCanonicalEvent as a6, type CanonicalEvent as b, type CanonicalEventInput as c, type CanonicalEventOfType as d, type CanonicalEventType as e, type CanonicalUsage as f, type CompactionPerformedEvent as g, type CostFacts as h, type ErrorRaisedEvent as i, type EventOutcome as j, type EventValidationResult as k, type GenerationStartEvent as l, type ProviderTotalAgreement as m, type SessionStartEvent as n, type SubagentEndEvent as o, type SubagentStartEvent as p, type ToolKind as q, type ToolStartEvent as r, UsageNormalizationError as s, type UsageNormalizationIssue as t, type UsageNormalizationResult as u, type UsageReport as v, type UsageTemporality as w, addUsage as x, cacheCreationAccountingSchema as y, canonicalEventSchema as z };
2220
+ export { normalizeUsage as $, type UsageNormalizationResult as A, type UsageReport as B, CANONICAL_EVENT_TYPES as C, type UsageTemporality as D, EMPTY_DELTA_USAGE as E, type WorktreeKind as F, type GenerationEndEvent as G, addUsage as H, cacheCreationAccountingSchema as I, canonicalEventSchema as J, canonicalEventTypeSchema as K, canonicalUsageSchema as L, MAX_TARGET_HINT_PATHS as M, compactionPerformedEventSchema as N, compareEvents as O, type PromptSubmittedEvent as P, costFactsSchema as Q, cumulativeToDelta as R, SUBAGENT_ID_PATTERN as S, type TargetHint as T, type UsageDeltaResult as U, errorRaisedEventSchema as V, type WorkspaceTarget as W, eventUsage as X, generationEndEventSchema as Y, generationStartEventSchema as Z, modelDescriptorSchema as _, type CacheCreationAccounting as a, normalizeUsageOrThrow as a0, parseCanonicalEvent as a1, promptSubmittedEventSchema as a2, providerTotalAgreementSchema as a3, sessionEndEventSchema as a4, sessionStartEventSchema as a5, subagentEndEventSchema as a6, subagentIdSchema as a7, subagentStartEventSchema as a8, targetHintSchema as a9, targetSourceSchema as aa, toReport as ab, toolEndEventSchema as ac, toolKindSchema as ad, toolStartEventSchema as ae, usageReportSchema as af, usageTemporalitySchema as ag, validateCanonicalEvent as ah, workspaceTargetSchema as ai, worktreeKindSchema as aj, type CanonicalEvent as b, type CanonicalEventInput as c, type CanonicalEventOfType as d, type CanonicalEventType as e, type CanonicalUsage as f, type CompactionPerformedEvent as g, type CostFacts as h, type ErrorRaisedEvent as i, type EventOutcome as j, type EventValidationResult as k, type GenerationStartEvent as l, MAX_TARGET_PATH_LENGTH as m, type ModelDescriptor as n, type ProviderTotalAgreement as o, type SessionEndEvent as p, type SessionStartEvent as q, type SubagentEndEvent as r, type SubagentId as s, type SubagentStartEvent as t, type TargetSource as u, type ToolEndEvent as v, type ToolKind as w, type ToolStartEvent as x, UsageNormalizationError as y, type UsageNormalizationIssue as z };
@@ -1,4 +1,4 @@
1
- import { e as StateStore, C as Clock, d as Logger } from './ports-B_iwJQPQ.js';
1
+ import { e as StateStore, C as Clock, d as Logger } from './ports-B0rC49b3.js';
2
2
  import { S as StoreNamespace } from './keys-Dej5bN3L.js';
3
3
 
4
4
  /**
@@ -1,13 +1,13 @@
1
1
  import { z } from 'zod';
2
2
  import { O as OtelHookConfig } from './schema-Cn0-xz8L.js';
3
3
  import { OtelHookErrorInfo } from './errors.js';
4
- import { b as CanonicalEvent, w as UsageTemporality, f as CanonicalUsage } from './events-C3h3GvHj.js';
4
+ import { b as CanonicalEvent, D as UsageTemporality, f as CanonicalUsage } from './events-CzZ5kukS.js';
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-BgqtlADe.js';
9
- import { P as ProviderRegistry } from './registry-BSBS8t7S.js';
10
- import { I as IdGenerator, g as TelemetrySink, e as StateStore, C as Clock, d as Logger, W as WorktreeLocator } from './ports-B_iwJQPQ.js';
8
+ import { b as DeliveryIdentifierSupport, f as ProviderDeliveryClaim, j as ProviderHookResponse } from './adapter-BS7xHKGQ.js';
9
+ import { P as ProviderRegistry } from './registry-DVnPA_b6.js';
10
+ import { I as IdGenerator, g as TelemetrySink, e as StateStore, C as Clock, d as Logger, W as WorktreeLocator } from './ports-B0rC49b3.js';
11
11
  import { A as AttributionOutcome, a as AttributionReason } from './taxonomy-DwhTtuWd.js';
12
12
 
13
13
  /**
package/dist/index.d.ts CHANGED
@@ -1,29 +1,28 @@
1
1
  export { CANONICAL_SCHEMA_VERSION, CanonicalSchemaVersion, EMPTY_EXTENSIONS, EXTENSION_KEY_PATTERN, Extensions, MAX_EXTENSION_ENTRIES, RESERVED_EXTENSION_NAMESPACES, canonicalSchemaVersionSchema, emptyExtensions, extensionKeyNamespace, extensionsSchema, isReservedExtensionNamespace, isValidExtensionKey } from './model.js';
2
2
  export { A as AttributePrimitive, a as AttributeValue, b as Attributes, D as DETECTION_CONFIDENCE_RANK, c as DetectionConfidence, E as EpochMillis, d as EventId, I as InvocationId, M as MAX_ATTRIBUTE_ARRAY_LENGTH, e as MAX_ATTRIBUTE_STRING_LENGTH, f as MAX_IDENTIFIER_LENGTH, P as PROVIDER_ID_PATTERN, g as ProviderId, R as ResolvedProviderId, S as SessionId, h as SourceTransport, U as UNKNOWN_PROVIDER_ID, i as UnknownProviderId, W as WORKSPACE_ID_PATTERN, j as WorkspaceId, k as attributePrimitiveSchema, l as attributeValueSchema, m as attributesSchema, n as compareDetectionConfidence, o as detectionConfidenceSchema, p as durationMillisSchema, q as epochMillisSchema, r as eventIdSchema, s as invocationIdSchema, t as isUnknownProvider, u as nonEmptyStringSchema, v as providerIdSchema, w as resolvedProviderIdSchema, x as sequenceNumberSchema, y as sessionIdSchema, z as sourceTransportSchema, B as tokenCountSchema, C as workspaceIdSchema } from './primitives-CJ8-rn-f.js';
3
3
  export { C as CONTENT_HASH_PATTERN, a as ContentDisclosure, b as ContentFact, c as ContentKind, d as ContentRole, e as contentDisclosureSchema, f as contentFactSchema, g as contentFactsSchema, h as contentKindSchema, i as contentRoleSchema, j as isContentFactConsistent, k as isUnavailableContentFact } from './content-M9xIKG7h.js';
4
- export { C as CANONICAL_EVENT_TYPES, a as CacheCreationAccounting, b as CanonicalEvent, c as CanonicalEventInput, d as CanonicalEventOfType, e as CanonicalEventType, f as CanonicalUsage, g as CompactionPerformedEvent, h as CostFacts, E as EMPTY_DELTA_USAGE, i as ErrorRaisedEvent, j as EventOutcome, k as EventValidationResult, G as GenerationEndEvent, l as GenerationStartEvent, M as ModelDescriptor, P as PromptSubmittedEvent, m as ProviderTotalAgreement, S as SessionEndEvent, n as SessionStartEvent, o as SubagentEndEvent, p as SubagentStartEvent, T as ToolEndEvent, q as ToolKind, r as ToolStartEvent, U as UsageDeltaResult, s as UsageNormalizationError, t as UsageNormalizationIssue, u as UsageNormalizationResult, v as UsageReport, w as UsageTemporality, x as addUsage, y as cacheCreationAccountingSchema, z as canonicalEventSchema, A as canonicalEventTypeSchema, B as canonicalUsageSchema, D as compactionPerformedEventSchema, F as compareEvents, H as costFactsSchema, I as cumulativeToDelta, J as errorRaisedEventSchema, K as eventUsage, L as generationEndEventSchema, N as generationStartEventSchema, O as modelDescriptorSchema, Q as normalizeUsage, R as normalizeUsageOrThrow, V as parseCanonicalEvent, W as promptSubmittedEventSchema, X as providerTotalAgreementSchema, Y as sessionEndEventSchema, Z as sessionStartEventSchema, _ as subagentEndEventSchema, $ as subagentStartEventSchema, a0 as toReport, a1 as toolEndEventSchema, a2 as toolKindSchema, a3 as toolStartEventSchema, a4 as usageReportSchema, a5 as usageTemporalitySchema, a6 as validateCanonicalEvent } from './events-C3h3GvHj.js';
4
+ export { C as CANONICAL_EVENT_TYPES, a as CacheCreationAccounting, b as CanonicalEvent, c as CanonicalEventInput, d as CanonicalEventOfType, e as CanonicalEventType, f as CanonicalUsage, g as CompactionPerformedEvent, h as CostFacts, E as EMPTY_DELTA_USAGE, i as ErrorRaisedEvent, j as EventOutcome, k as EventValidationResult, G as GenerationEndEvent, l as GenerationStartEvent, M as MAX_TARGET_HINT_PATHS, m as MAX_TARGET_PATH_LENGTH, n as ModelDescriptor, P as PromptSubmittedEvent, o as ProviderTotalAgreement, S as SUBAGENT_ID_PATTERN, p as SessionEndEvent, q as SessionStartEvent, r as SubagentEndEvent, s as SubagentId, t as SubagentStartEvent, T as TargetHint, u as TargetSource, v as ToolEndEvent, w as ToolKind, x as ToolStartEvent, U as UsageDeltaResult, y as UsageNormalizationError, z as UsageNormalizationIssue, A as UsageNormalizationResult, B as UsageReport, D as UsageTemporality, W as WorkspaceTarget, F as WorktreeKind, H as addUsage, I as cacheCreationAccountingSchema, J as canonicalEventSchema, K as canonicalEventTypeSchema, L as canonicalUsageSchema, N as compactionPerformedEventSchema, O as compareEvents, Q as costFactsSchema, R as cumulativeToDelta, V as errorRaisedEventSchema, X as eventUsage, Y as generationEndEventSchema, Z as generationStartEventSchema, _ as modelDescriptorSchema, $ as normalizeUsage, a0 as normalizeUsageOrThrow, a1 as parseCanonicalEvent, a2 as promptSubmittedEventSchema, a3 as providerTotalAgreementSchema, a4 as sessionEndEventSchema, a5 as sessionStartEventSchema, a6 as subagentEndEventSchema, a7 as subagentIdSchema, a8 as subagentStartEventSchema, a9 as targetHintSchema, aa as targetSourceSchema, ab as toReport, ac as toolEndEventSchema, ad as toolKindSchema, ae as toolStartEventSchema, af as usageReportSchema, ag as usageTemporalitySchema, ah as validateCanonicalEvent, ai as workspaceTargetSchema, aj as worktreeKindSchema } from './events-CzZ5kukS.js';
5
5
  export { C as ConsumerAttributes, I as IdentityClaim, a as IdentityClaimFields, b as IdentityConflict, c as IdentityResolution, d as InvocationIdentity, R as ResolveIdentityInput, S as SourceProvenance, U as UNKNOWN_WORKSPACE_ID, W as WorkspaceIdentity, e as WorkspaceKeySource, f as consumerAttributesSchema, i as identityClaimFieldsSchema, g as identityClaimSchema, h as invocationIdentitySchema, r as resolveInvocationIdentity, s as sourceProvenanceSchema, u as unknownWorkspaceIdentity, w as workspaceIdentitySchema, j as workspaceKeySourceSchema } from './identity-BrVBs901.js';
6
- export { M as MAX_TARGET_HINT_PATHS, a as MAX_TARGET_PATH_LENGTH, S as SUBAGENT_ID_PATTERN, b as SubagentId, T as TargetHint, c as TargetSource, W as WorkspaceTarget, s as subagentIdSchema, t as targetHintSchema, d as targetSourceSchema, w as workspaceTargetSchema } from './target-8RfaVxp8.js';
7
6
  export { CreateErrorInfoInput, OtelHookError, OtelHookErrorInfo, createErrorInfo, describeThrown, errorInfoFromThrown, isOtelHookError, otelHookErrorInfoSchema } from './errors.js';
8
7
  export { C as CONTENT_MODE_DISCLOSURE, a as ContentMode, D as DEFAULT_PRIVACY_LIMITS, b as DEFAULT_PRIVACY_POLICY, c as DEFAULT_SECRET_KEY_PATTERNS, d as DEFAULT_SECRET_VALUE_PATTERNS, P as PolicyResolution, e as PrivacyLimits, f as PrivacyPolicy, g as contentModeSchema, p as privacyLimitsSchema, h as privacyPolicySchema, r as resolvePrivacyPolicy } from './policy-CimmCfRp.js';
9
8
  export { D as DescribeContentInput, a as DescribeStructuredInput, P as PrivacyService, S as SanitizeExtensionsResult, b as SanitizeResult, c as SanitizeStats, d as SanitizedValue, e as createPrivacyService } from './service-CbI9CObT.js';
10
9
  export { WorkspaceKeyInput, WorkspaceLabels, canonicalizeGitRemote, deriveWorkspaceIdentity } from './privacy.js';
11
10
  export { CONFIG_SOURCE_PRECEDENCE, ConfigLayer, ConfigProvenance, ConfigResolution, ConfigSource, EMPTY_RESOURCE_ATTRIBUTES, ENVIRONMENT_VARIABLES, EnvironmentConfigResult, EnvironmentRecord, MAX_RESOURCE_ATTRIBUTES, MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH, MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH, ParsedResourceAttributes, RESERVED_RESOURCE_ATTRIBUTE_KEYS, RESOURCE_ATTRIBUTE_KEY_PATTERN, RESOURCE_ATTRIBUTE_KEY_REJECTION_DETAIL, ResourceAttributeKeyRejection, ResourceAttributeValue, ResourceAttributes, checkResourceAttributeKey, configSourceSchema, describeResolvedConfig, describeResourceAttributeNames, isReservedResourceAttributeKey, isSecretResourceAttributeKey, parseEnvironmentConfig, parseResourceAttributesValue, resolveConfig, resourceAttributeValueSchema, resourceAttributesSchema, sanitizeResourceAttributes } from './config.js';
12
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 DetectionPolicy, f as DiagnosticsPolicy, E as ExporterPolicy, L as LogsPolicy, O as OtelHookConfig, g as OtelHookConfigPatch, h as detectionPolicySchema, i as diagnosticsPolicySchema, j as exporterPolicySchema, l as logsPolicySchema, o as otelHookConfigPatchSchema, k as otelHookConfigSchema } from './schema-Cn0-xz8L.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-BgqtlADe.js';
12
+ 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-BS7xHKGQ.js';
14
13
  export { ANTIGRAVITY_PROMOTION_GATES, ANTIGRAVITY_PROVIDER_MATURITY, AntigravityProviderMaturity, CLAUDE_CODE_CAPABILITIES, CODEX_CAPABILITIES, CURSOR_ADAPTER_VERSION, CURSOR_CAPABILITIES, CanonicalEventDraft, ClaudeCodeAdapterOptions, CursorAdapterOptions, DELIVERY_IDENTIFIER_SUMMARY, DefaultRegistryOptions, EXPERIMENTAL_PROVIDER_IDS, EventFactory, EventFactoryInput, PROVIDER_DESCRIPTORS, ProviderCatalogEntry, ProviderDescriptor, ProviderMaturity, createClaudeCodeAdapter, createCodexAdapter, createCursorAdapter, createDefaultProviderRegistry, createEventFactory, describeProviderCatalog, findProviderDescriptor, isExperimentalProvider } from './providers.js';
15
- export { B as BUILT_IN_PROVIDERS, D as DetectionCandidate, P as ProviderRegistry, R as RegistryDetectionResult, c as createProviderRegistry } from './registry-BSBS8t7S.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-DpyU8F-z.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, S as StateRecord, e as StateStore, f as StateValue, T as TelemetryEmitResult, g as TelemetrySink, W as WorktreeLocator, h as appliedDeliverySchema, l as logLevelSchema, s as stateRecordSchema, i as stateValueSchema } from './ports-B_iwJQPQ.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-kflYgZbg.js';
19
- export { DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS, DEFAULT_WORKTREE_CACHE_TTL_MILLIS, FilesystemWorktreeLocatorOptions, MAX_WORKTREE_WALK_DEPTH, ResolveEventTargetsInput, ResolveEventTargetsResult, StderrLoggerOptions, createFilesystemWorktreeLocator, createNullLogger, createStderrLogger, parseGitDirFile, parseHeadBranch, resolveEventTargets } 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-CQiNa88Q.js';
14
+ export { B as BUILT_IN_PROVIDERS, D as DetectionCandidate, P as ProviderRegistry, R as RegistryDetectionResult, c as createProviderRegistry } from './registry-DVnPA_b6.js';
15
+ 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-2lnpKodw.js';
16
+ 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, S as StateRecord, e as StateStore, f as StateValue, T as TelemetryEmitResult, g as TelemetrySink, W as WorktreeLocator, h as appliedDeliverySchema, l as logLevelSchema, s as stateRecordSchema, i as stateValueSchema } from './ports-B0rC49b3.js';
17
+ 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-DkTohdIa.js';
18
+ export { DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS, DEFAULT_WORKTREE_CACHE_TTL_MILLIS, FilesystemWorktreeLocatorOptions, MAX_WORKTREE_WALK_DEPTH, ResolveEventTargetsInput, ResolveEventTargetsResult, StderrLoggerOptions, createFilesystemWorktreeLocator, createNullLogger, createStderrLogger, parseCommonDirFile, parseGitDirFile, parseHeadBranch, resolveEventTargets } from './runtime.js';
19
+ 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-DxTakjAD.js';
21
20
  export { CallbackDeduplicator, CallbackDeduplicatorDependencies, DedupCheckResult, DedupCleanupResult, DeliveryClaimOptions, DeliveryClaimOutcome, DeliveryClaimResult, LifecycleCleanupReport, LifecycleJanitor, LifecycleJanitorOptions, LifecycleScope, LifecycleSweepStats, RollupCleanupResult, SPAN_RECORD_VERSION, SpanCleanupResult, SpanCorrelationFacts, SpanCorrelator, SpanCorrelatorDependencies, SpanEndInput, SpanEndOrphanReason, SpanEndResult, SpanStartInput, SpanStartResult, UsageAccumulator, UsageAccumulatorDependencies, UsageAccumulatorKey, UsageAccumulatorSnapshot, createCallbackDeduplicator, createLifecycleJanitor, createSpanCorrelator, createUsageAccumulator } from './lifecycle.js';
22
21
  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-BAq3VGVv.js';
22
+ 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-BcOveJYY.js';
24
23
  export { BoundedMemoryStateStore, BoundedMemoryStateStoreOptions, createBoundedMemoryStateStore } from './state.js';
25
- export { D as DEFAULT_INSTRUMENTATION_SCOPE, E as EventTraceIdentity, M as MAX_RECOVERED_START_ATTRIBUTES, S as SemanticMappingOptions, a as SpanCorrelation, b as SpanCorrelationResolver, c as SpanDisposition, d as SpanFamily, e as SpanOrphanClassification, f as SpanPairing, g as SpanScopeRef, h as canonicalEventTraceIdentities, i as canonicalEventsToReadableSpans, p as parentScopeRefOf, s as spanScopeRefOf, j as startOnlySpanAttributes } from './semconv-BeUPQ7_q.js';
26
- export { C as ContentWithholdingReason, D as DurableLogSpool, a as DurableLogSpoolOptions, b as DurableSpool, c as DurableSpoolOptions, L as LOG_MAPPING_VERSION, d as LOG_SIGNALS, e as LogContentPolicy, f as LogMappingOptions, g as LogMappingResult, h as LogSignal, i as LogSpoolBatch, j as LogsDeliverability, M as MAX_LOG_BODY_CHARACTERS, k as MAX_LOG_RECORDS_PER_BATCH, l as MAX_LOG_RECORDS_PER_EVENT, m as MCP_TOOL_NAME_PATTERN, N as NO_LOG_CONTENT, O as OtlpLogSinkOptions, n as OtlpLogTelemetrySink, o as OtlpTelemetrySink, p as OtlpTraceSinkOptions, S as SerializedLogRecord, q as SerializedSpan, r as SpoolBatch, s as SpoolDrainResult, t as SpoolEnqueueResult, u as canonicalEventsToLogRecords, v as createFileDurableLogSpool, w as createFileDurableSpool, x as createOtlpLogSink, y as createOtlpTraceSink, z as describeLogsDeliverability, A as logSignalOf, B as logSignalsForLifecycleEvents, E as resolveLogsEndpoint } from './otlp-log-sink-BZIgYPKN.js';
24
+ export { D as DEFAULT_INSTRUMENTATION_SCOPE, E as EventTraceIdentity, M as MAX_RECOVERED_START_ATTRIBUTES, S as SemanticMappingOptions, a as SpanCorrelation, b as SpanCorrelationResolver, c as SpanDisposition, d as SpanFamily, e as SpanOrphanClassification, f as SpanPairing, g as SpanScopeRef, h as canonicalEventTraceIdentities, i as canonicalEventsToReadableSpans, p as parentScopeRefOf, s as spanScopeRefOf, j as startOnlySpanAttributes } from './semconv-CtnDdsPk.js';
25
+ export { C as ContentWithholdingReason, D as DurableLogSpool, a as DurableLogSpoolOptions, b as DurableSpool, c as DurableSpoolOptions, L as LOG_MAPPING_VERSION, d as LOG_SIGNALS, e as LogContentPolicy, f as LogMappingOptions, g as LogMappingResult, h as LogSignal, i as LogSpoolBatch, j as LogsDeliverability, M as MAX_LOG_BODY_CHARACTERS, k as MAX_LOG_RECORDS_PER_BATCH, l as MAX_LOG_RECORDS_PER_EVENT, m as MCP_TOOL_NAME_PATTERN, N as NO_LOG_CONTENT, O as OtlpLogSinkOptions, n as OtlpLogTelemetrySink, o as OtlpTelemetrySink, p as OtlpTraceSinkOptions, S as SerializedLogRecord, q as SerializedSpan, r as SpoolBatch, s as SpoolDrainResult, t as SpoolEnqueueResult, u as canonicalEventsToLogRecords, v as createFileDurableLogSpool, w as createFileDurableSpool, x as createOtlpLogSink, y as createOtlpTraceSink, z as describeLogsDeliverability, A as logSignalOf, B as logSignalsForLifecycleEvents, E as resolveLogsEndpoint } from './otlp-log-sink-DaZDPKnR.js';
27
26
  export { SignalFanoutOptions, SignalFanoutSink, createSignalFanout, shareCorrelationPerBatch } from './telemetry.js';
28
27
  export { DeliveryHealthSnapshot, DeliverySubsystem, HealthTracker, HealthTrackerOptions, OverallHealth, createHealthTracker, summarizeHealth } from './diagnostics.js';
29
28
  export { DeliveryReport, HookProcessInput, HookProcessOutcome, HookRuntime, HookRuntimeDelivery, HookRuntimeOptions, HookShutdownReport, UsageRollup, createHookRuntime, minimumStaleClaimMillis } from './integration.js';
@@ -42,6 +41,6 @@ import '@opentelemetry/sdk-logs';
42
41
  *
43
42
  * Updated by `scripts/release/sync-version.mjs` during semantic-release.
44
43
  */
45
- declare const VERSION = "0.4.1";
44
+ declare const VERSION = "0.5.0";
46
45
 
47
46
  export { VERSION };
package/dist/index.js CHANGED
@@ -576,11 +576,15 @@ var targetHintSchema = z7.strictObject({
576
576
  /** Absolute directory that relative `paths` resolve against. */
577
577
  baseDirectory: localPathSchema.optional()
578
578
  }).readonly();
579
+ var worktreeKindSchema = z7.enum(["main", "linked"]);
579
580
  var workspaceTargetSchema = z7.strictObject({
580
581
  workspaceId: workspaceIdSchema,
581
582
  /** Branch checked out in that worktree; absent on a detached HEAD. */
582
583
  vcsBranchName: nonEmptyStringSchema.optional(),
583
- source: targetSourceSchema
584
+ source: targetSourceSchema,
585
+ /** `git-root` handle of the repository's main worktree; absent when there is none to name. */
586
+ repositoryId: workspaceIdSchema.optional(),
587
+ worktreeKind: worktreeKindSchema.optional()
584
588
  }).readonly();
585
589
  var SUBAGENT_ID_PATTERN = /^[A-Za-z0-9_.:@+=-]{1,256}$/;
586
590
  var subagentIdSchema = z7.string().regex(SUBAGENT_ID_PATTERN);
@@ -6394,10 +6398,13 @@ var resolveHint = async (hint, locator, privacy) => {
6394
6398
  if (identity.keySource !== "git-root") {
6395
6399
  return void 0;
6396
6400
  }
6401
+ const repository = first.mainRoot === void 0 ? void 0 : deriveWorkspaceIdentity(privacy, { kind: "git-root", absolutePath: first.mainRoot });
6397
6402
  const parsed = workspaceTargetSchema.safeParse({
6398
6403
  workspaceId: identity.workspaceId,
6399
6404
  ...identity.vcsBranchName === void 0 ? {} : { vcsBranchName: identity.vcsBranchName },
6400
- source: hint.source
6405
+ source: hint.source,
6406
+ ...repository?.keySource === "git-root" ? { repositoryId: repository.workspaceId } : {},
6407
+ ...first.kind === void 0 ? {} : { worktreeKind: first.kind }
6401
6408
  });
6402
6409
  return parsed.success ? parsed.data : void 0;
6403
6410
  };
@@ -7280,7 +7287,7 @@ var buildErrorEvents = (diagnostics, identity, sequenceBase, ids, privacy) => {
7280
7287
  };
7281
7288
 
7282
7289
  // src/runtime/git-worktree.ts
7283
- import { open, stat } from "fs/promises";
7290
+ import { lstat, open, stat } from "fs/promises";
7284
7291
  import * as path2 from "path";
7285
7292
  var MAX_WORKTREE_WALK_DEPTH = 128;
7286
7293
  var MAX_GIT_FILE_BYTES = 4096;
@@ -7312,13 +7319,41 @@ var parseHeadBranch = (head) => {
7312
7319
  }
7313
7320
  return branch;
7314
7321
  };
7322
+ var firstLine = (content) => content.split(/\r?\n/, 1)[0]?.trim() ?? "";
7323
+ var resolveGitPath = (target, base) => target === void 0 || target.length === 0 || target.includes("\0") ? void 0 : path2.resolve(base, target);
7315
7324
  var parseGitDirFile = (content, worktreeRoot) => {
7316
- const line = content.split(/\r?\n/, 1)[0]?.trim() ?? "";
7317
- const target = line.startsWith("gitdir:") ? line.slice("gitdir:".length).trim() : void 0;
7318
- if (target === void 0 || target.length === 0 || target.includes("\0")) {
7319
- return void 0;
7325
+ const line = firstLine(content);
7326
+ return resolveGitPath(
7327
+ line.startsWith("gitdir:") ? line.slice("gitdir:".length).trim() : void 0,
7328
+ worktreeRoot
7329
+ );
7330
+ };
7331
+ var parseCommonDirFile = (content, gitDir) => resolveGitPath(firstLine(content), gitDir);
7332
+ var isMissing = async (filePath) => {
7333
+ try {
7334
+ await lstat(filePath);
7335
+ return false;
7336
+ } catch (error) {
7337
+ const code = error.code;
7338
+ return code === "ENOENT" || code === "ENOTDIR";
7339
+ }
7340
+ };
7341
+ var isDirectory = async (directory) => {
7342
+ try {
7343
+ return (await stat(directory)).isDirectory();
7344
+ } catch {
7345
+ return false;
7346
+ }
7347
+ };
7348
+ var repositoryOf = async (worktreeRoot, gitDir) => {
7349
+ const commonDirFile = path2.join(gitDir, "commondir");
7350
+ const content = await readBounded(commonDirFile);
7351
+ if (content === void 0) {
7352
+ return await isMissing(commonDirFile) ? { kind: "main", mainRoot: worktreeRoot } : { kind: "linked" };
7320
7353
  }
7321
- return path2.resolve(worktreeRoot, target);
7354
+ const commonDir = parseCommonDirFile(content, gitDir);
7355
+ const mainRoot = commonDir !== void 0 && path2.basename(commonDir) === ".git" && await isDirectory(commonDir) ? path2.dirname(commonDir) : void 0;
7356
+ return { kind: "linked", ...mainRoot === void 0 ? {} : { mainRoot } };
7322
7357
  };
7323
7358
  var probeDirectory = async (directory) => {
7324
7359
  const dotGit = path2.join(directory, ".git");
@@ -7343,9 +7378,10 @@ var probeDirectory = async (directory) => {
7343
7378
  return INVALID;
7344
7379
  }
7345
7380
  const branch = parseHeadBranch(head);
7381
+ const repository = info.isDirectory() ? { kind: "main", mainRoot: directory } : await repositoryOf(directory, gitDir);
7346
7382
  return {
7347
7383
  kind: "worktree",
7348
- located: { root: directory, ...branch === void 0 ? {} : { branch } }
7384
+ located: { root: directory, ...branch === void 0 ? {} : { branch }, ...repository }
7349
7385
  };
7350
7386
  };
7351
7387
  var createFilesystemWorktreeLocator = (options = {}) => {
@@ -7628,7 +7664,7 @@ import {
7628
7664
  } from "@opentelemetry/semantic-conventions/incubating";
7629
7665
 
7630
7666
  // src/version.ts
7631
- var VERSION = "0.4.1";
7667
+ var VERSION = "0.5.0";
7632
7668
 
7633
7669
  // src/telemetry/export-identity.ts
7634
7670
  import { ATTR_SESSION_ID } from "@opentelemetry/semantic-conventions/incubating";
@@ -7648,6 +7684,8 @@ var ATTR_OTELHOOK_SUBAGENT_ID = "otelhook.subagent.id";
7648
7684
  var ATTR_VCS_REF_HEAD_NAME = "vcs.ref.head.name";
7649
7685
  var ATTR_OTELHOOK_TARGET_WORKSPACE_ID = "otelhook.target.workspace.id";
7650
7686
  var ATTR_OTELHOOK_TARGET_SOURCE = "otelhook.target.source";
7687
+ var ATTR_OTELHOOK_TARGET_REPOSITORY_ID = "otelhook.target.repository.id";
7688
+ var ATTR_OTELHOOK_TARGET_WORKTREE_KIND = "otelhook.target.worktree.kind";
7651
7689
  var ATTR_OTELHOOK_USAGE_TEMPORALITY = "otelhook.usage.temporality";
7652
7690
  var targetAttributes = (event3) => {
7653
7691
  if (event3.type !== "tool.start" && event3.type !== "tool.end" || event3.target === void 0) {
@@ -7657,7 +7695,9 @@ var targetAttributes = (event3) => {
7657
7695
  return {
7658
7696
  [ATTR_OTELHOOK_TARGET_WORKSPACE_ID]: target.workspaceId,
7659
7697
  [ATTR_OTELHOOK_TARGET_SOURCE]: target.source,
7660
- ...target.vcsBranchName === void 0 ? {} : { [ATTR_VCS_REF_HEAD_NAME]: target.vcsBranchName }
7698
+ ...target.vcsBranchName === void 0 ? {} : { [ATTR_VCS_REF_HEAD_NAME]: target.vcsBranchName },
7699
+ ...target.repositoryId === void 0 ? {} : { [ATTR_OTELHOOK_TARGET_REPOSITORY_ID]: target.repositoryId },
7700
+ ...target.worktreeKind === void 0 ? {} : { [ATTR_OTELHOOK_TARGET_WORKTREE_KIND]: target.worktreeKind }
7661
7701
  };
7662
7702
  };
7663
7703
  var usageTemporalityAttributes = (usage) => usage === void 0 ? {} : { [ATTR_OTELHOOK_USAGE_TEMPORALITY]: usage.temporality };
@@ -7831,7 +7871,9 @@ var TARGET_SOURCE_RANK = Object.freeze({
7831
7871
  var TARGET_KEYS = [
7832
7872
  ATTR_OTELHOOK_TARGET_WORKSPACE_ID,
7833
7873
  ATTR_OTELHOOK_TARGET_SOURCE,
7834
- ATTR_VCS_REF_HEAD_NAME
7874
+ ATTR_VCS_REF_HEAD_NAME,
7875
+ ATTR_OTELHOOK_TARGET_REPOSITORY_ID,
7876
+ ATTR_OTELHOOK_TARGET_WORKTREE_KIND
7835
7877
  ];
7836
7878
  var pickTarget = (attributes) => {
7837
7879
  const picked = {};
@@ -12582,6 +12624,7 @@ export {
12582
12624
  otelHookErrorInfoSchema,
12583
12625
  parentScopeRefOf,
12584
12626
  parseCanonicalEvent,
12627
+ parseCommonDirFile,
12585
12628
  parseEnvironmentConfig,
12586
12629
  parseGitDirFile,
12587
12630
  parseHeadBranch,
@@ -12660,6 +12703,7 @@ export {
12660
12703
  workspaceIdentitySchema,
12661
12704
  workspaceKeySourceSchema,
12662
12705
  workspaceTargetSchema,
12706
+ worktreeKindSchema,
12663
12707
  writeDocumentAtomically
12664
12708
  };
12665
12709
  //# sourceMappingURL=index.js.map