@osfactory/otel-hook 0.3.0 → 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 (42) hide show
  1. package/dist/{adapter-DXpNtnaf.d.ts → adapter-BS7xHKGQ.d.ts} +9 -3
  2. package/dist/cli.js +1043 -487
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{events-VxBnDFaO.d.ts → events-CzZ5kukS.d.ts} +177 -1
  5. package/dist/{filesystem-store-J8jjDMTh.d.ts → filesystem-store-BcOveJYY.d.ts} +1 -1
  6. package/dist/{hook-_mlO3akA.d.ts → hook-DxTakjAD.d.ts} +12 -4
  7. package/dist/index.d.ts +12 -12
  8. package/dist/index.js +1171 -599
  9. package/dist/index.js.map +1 -1
  10. package/dist/install.d.ts +4 -4
  11. package/dist/install.js +103 -68
  12. package/dist/install.js.map +1 -1
  13. package/dist/integration.d.ts +14 -8
  14. package/dist/integration.js +547 -121
  15. package/dist/integration.js.map +1 -1
  16. package/dist/lifecycle.d.ts +3 -3
  17. package/dist/lifecycle.js +27 -2
  18. package/dist/lifecycle.js.map +1 -1
  19. package/dist/{memory-DXVBc8V9.d.ts → memory-DkTohdIa.d.ts} +2 -2
  20. package/dist/model.d.ts +1 -1
  21. package/dist/model.js +84 -41
  22. package/dist/model.js.map +1 -1
  23. package/dist/{otlp-log-sink-DTSa0KRF.d.ts → otlp-log-sink-DaZDPKnR.d.ts} +3 -3
  24. package/dist/{payload-BWV5-4n3.d.ts → payload-2lnpKodw.d.ts} +1 -1
  25. package/dist/{ports-Q8x0ODhs.d.ts → ports-B0rC49b3.d.ts} +28 -2
  26. package/dist/providers.d.ts +26 -9
  27. package/dist/providers.js +668 -452
  28. package/dist/providers.js.map +1 -1
  29. package/dist/{registry-Dqr3VNmT.d.ts → registry-DVnPA_b6.d.ts} +1 -1
  30. package/dist/runtime.d.ts +103 -11
  31. package/dist/runtime.js +416 -67
  32. package/dist/runtime.js.map +1 -1
  33. package/dist/{semconv-CIU-2kGO.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 +92 -10
  38. package/dist/telemetry.js.map +1 -1
  39. package/dist/testing.d.ts +13 -7
  40. package/dist/testing.js +821 -492
  41. package/dist/testing.js.map +1 -1
  42. package/package.json +4 -1
package/dist/index.js CHANGED
@@ -564,12 +564,37 @@ var resolveInvocationIdentity = (input) => {
564
564
  return { status: "resolved", identity: parsed.data };
565
565
  };
566
566
 
567
+ // src/model/target.ts
568
+ import { z as z7 } from "zod";
569
+ var targetSourceSchema = z7.enum(["tool-path", "shell-cwd", "session-cwd"]);
570
+ var MAX_TARGET_HINT_PATHS = 8;
571
+ var MAX_TARGET_PATH_LENGTH = 4096;
572
+ var localPathSchema = z7.string().min(1).max(MAX_TARGET_PATH_LENGTH).refine((value) => !value.includes("\0"), "path must not contain NUL");
573
+ var targetHintSchema = z7.strictObject({
574
+ source: targetSourceSchema,
575
+ paths: z7.array(localPathSchema).min(1).max(MAX_TARGET_HINT_PATHS).readonly(),
576
+ /** Absolute directory that relative `paths` resolve against. */
577
+ baseDirectory: localPathSchema.optional()
578
+ }).readonly();
579
+ var worktreeKindSchema = z7.enum(["main", "linked"]);
580
+ var workspaceTargetSchema = z7.strictObject({
581
+ workspaceId: workspaceIdSchema,
582
+ /** Branch checked out in that worktree; absent on a detached HEAD. */
583
+ vcsBranchName: nonEmptyStringSchema.optional(),
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()
588
+ }).readonly();
589
+ var SUBAGENT_ID_PATTERN = /^[A-Za-z0-9_.:@+=-]{1,256}$/;
590
+ var subagentIdSchema = z7.string().regex(SUBAGENT_ID_PATTERN);
591
+
567
592
  // src/model/events.ts
568
- import { z as z8 } from "zod";
593
+ import { z as z9 } from "zod";
569
594
 
570
595
  // src/errors/taxonomy.ts
571
- import { z as z7 } from "zod";
572
- var otelHookErrorCodeSchema = z7.enum([
596
+ import { z as z8 } from "zod";
597
+ var otelHookErrorCodeSchema = z8.enum([
573
598
  /** Input was not usable at all (empty stdin, unparsable JSON). */
574
599
  "invalid-input",
575
600
  /** Input parsed but failed canonical schema validation. */
@@ -605,8 +630,8 @@ var otelHookErrorCodeSchema = z7.enum([
605
630
  /** Anything unanticipated. Always reported, never fatal to the host. */
606
631
  "internal-error"
607
632
  ]);
608
- var errorSeveritySchema = z7.enum(["warning", "error"]);
609
- var errorPhaseSchema = z7.enum([
633
+ var errorSeveritySchema = z8.enum(["warning", "error"]);
634
+ var errorPhaseSchema = z8.enum([
610
635
  "configuration",
611
636
  "detection",
612
637
  "identity",
@@ -617,7 +642,7 @@ var errorPhaseSchema = z7.enum([
617
642
  "export",
618
643
  "shutdown"
619
644
  ]);
620
- var failurePostureSchema = z7.enum(["fail-open", "fail-closed-attribution"]);
645
+ var failurePostureSchema = z8.enum(["fail-open", "fail-closed-attribution"]);
621
646
  var ERROR_TAXONOMY = Object.freeze({
622
647
  "invalid-input": {
623
648
  code: "invalid-input",
@@ -742,7 +767,7 @@ var ERROR_TAXONOMY = Object.freeze({
742
767
  }
743
768
  });
744
769
  var describeErrorCode = (code) => ERROR_TAXONOMY[code];
745
- var attributionOutcomeSchema = z7.enum([
770
+ var attributionOutcomeSchema = z8.enum([
746
771
  /** Identity resolved; events carry provider and session identity. */
747
772
  "attributed",
748
773
  /** Identity could not be established safely; nothing was attributed. */
@@ -752,7 +777,7 @@ var attributionOutcomeSchema = z7.enum([
752
777
  /** Input was recognized but intentionally carried no telemetry. */
753
778
  "not-applicable"
754
779
  ]);
755
- var attributionReasonSchema = z7.enum([
780
+ var attributionReasonSchema = z8.enum([
756
781
  "provider-unknown",
757
782
  "provider-detection-ambiguous",
758
783
  "identity-conflict",
@@ -764,19 +789,19 @@ var attributionReasonSchema = z7.enum([
764
789
  ]);
765
790
 
766
791
  // src/model/events.ts
767
- var modelDescriptorSchema = z8.strictObject({
792
+ var modelDescriptorSchema = z9.strictObject({
768
793
  modelId: nonEmptyStringSchema,
769
794
  /** Vendor of the model, e.g. `anthropic`. Distinct from the agent provider. */
770
795
  vendor: nonEmptyStringSchema.optional(),
771
796
  family: nonEmptyStringSchema.optional()
772
797
  });
773
- var costFactsSchema = z8.strictObject({
798
+ var costFactsSchema = z9.strictObject({
774
799
  /** ISO 4217 code. */
775
- currency: z8.string().length(3),
776
- amount: z8.number().min(0).finite(),
777
- source: z8.enum(["provider-reported", "computed"])
800
+ currency: z9.string().length(3),
801
+ amount: z9.number().min(0).finite(),
802
+ source: z9.enum(["provider-reported", "computed"])
778
803
  });
779
- var canonicalEventTypeSchema = z8.enum([
804
+ var canonicalEventTypeSchema = z9.enum([
780
805
  "session.start",
781
806
  "session.end",
782
807
  "prompt.submitted",
@@ -790,7 +815,7 @@ var canonicalEventTypeSchema = z8.enum([
790
815
  "error.raised"
791
816
  ]);
792
817
  var CANONICAL_EVENT_TYPES = canonicalEventTypeSchema.options;
793
- var outcomeSchema = z8.enum(["ok", "error", "cancelled", "timeout", "denied", "unknown"]);
818
+ var outcomeSchema = z9.enum(["ok", "error", "cancelled", "timeout", "denied", "unknown"]);
794
819
  var baseEventFields = {
795
820
  schemaVersion: canonicalSchemaVersionSchema,
796
821
  eventId: eventIdSchema,
@@ -801,39 +826,45 @@ var baseEventFields = {
801
826
  occurredAt: epochMillisSchema,
802
827
  provenance: sourceProvenanceSchema,
803
828
  workspace: workspaceIdentitySchema,
829
+ /**
830
+ * The provider's own id for the subagent this event was emitted inside (e.g.
831
+ * Claude Code's `agent_id`). Absent for the top-level agent. Set by the event
832
+ * factory, never by hand.
833
+ */
834
+ subagentId: subagentIdSchema.optional(),
804
835
  extensions: extensionsSchema.default(emptyExtensions)
805
836
  };
806
- var event = (shape) => z8.strictObject({ ...baseEventFields, ...shape });
837
+ var event = (shape) => z9.strictObject({ ...baseEventFields, ...shape });
807
838
  var sessionStartEventSchema = event({
808
- type: z8.literal("session.start"),
809
- sessionKind: z8.enum(["interactive", "non-interactive", "unknown"]),
839
+ type: z9.literal("session.start"),
840
+ sessionKind: z9.enum(["interactive", "non-interactive", "unknown"]),
810
841
  agentName: nonEmptyStringSchema.optional(),
811
842
  agentVersion: nonEmptyStringSchema.optional(),
812
843
  model: modelDescriptorSchema.optional()
813
844
  });
814
845
  var sessionEndEventSchema = event({
815
- type: z8.literal("session.end"),
816
- reason: z8.enum(["completed", "aborted", "error", "timeout", "unknown"]),
846
+ type: z9.literal("session.end"),
847
+ reason: z9.enum(["completed", "aborted", "error", "timeout", "unknown"]),
817
848
  durationMillis: durationMillisSchema.optional(),
818
849
  /** Session totals, typically cumulative. */
819
850
  usage: canonicalUsageSchema.optional(),
820
851
  cost: costFactsSchema.optional()
821
852
  });
822
853
  var promptSubmittedEventSchema = event({
823
- type: z8.literal("prompt.submitted"),
824
- promptSource: z8.enum(["user", "automation", "resumed", "unknown"]),
854
+ type: z9.literal("prompt.submitted"),
855
+ promptSource: z9.enum(["user", "automation", "resumed", "unknown"]),
825
856
  content: contentFactSchema.optional(),
826
- turnIndex: z8.number().int().min(0).optional()
857
+ turnIndex: z9.number().int().min(0).optional()
827
858
  });
828
859
  var generationStartEventSchema = event({
829
- type: z8.literal("generation.start"),
860
+ type: z9.literal("generation.start"),
830
861
  generationId: nonEmptyStringSchema,
831
862
  model: modelDescriptorSchema,
832
863
  requestedMaxOutputTokens: tokenCountSchema.optional(),
833
864
  inputContent: contentFactsSchema.optional()
834
865
  });
835
866
  var generationEndEventSchema = event({
836
- type: z8.literal("generation.end"),
867
+ type: z9.literal("generation.end"),
837
868
  generationId: nonEmptyStringSchema,
838
869
  model: modelDescriptorSchema,
839
870
  outcome: outcomeSchema,
@@ -843,7 +874,7 @@ var generationEndEventSchema = event({
843
874
  cost: costFactsSchema.optional(),
844
875
  outputContent: contentFactsSchema.optional()
845
876
  });
846
- var toolKindSchema = z8.enum([
877
+ var toolKindSchema = z9.enum([
847
878
  "read",
848
879
  "write",
849
880
  "execute",
@@ -854,59 +885,63 @@ var toolKindSchema = z8.enum([
854
885
  "unknown"
855
886
  ]);
856
887
  var toolStartEventSchema = event({
857
- type: z8.literal("tool.start"),
888
+ type: z9.literal("tool.start"),
858
889
  toolCallId: nonEmptyStringSchema,
859
890
  toolName: nonEmptyStringSchema,
860
891
  toolKind: toolKindSchema,
861
892
  generationId: nonEmptyStringSchema.optional(),
862
- input: contentFactSchema.optional()
893
+ input: contentFactSchema.optional(),
894
+ /** The git worktree this call targeted, resolved by the core (ADR 0008). */
895
+ target: workspaceTargetSchema.optional()
863
896
  });
864
897
  var toolEndEventSchema = event({
865
- type: z8.literal("tool.end"),
898
+ type: z9.literal("tool.end"),
866
899
  toolCallId: nonEmptyStringSchema,
867
900
  toolName: nonEmptyStringSchema,
868
901
  outcome: outcomeSchema,
869
902
  durationMillis: durationMillisSchema.optional(),
870
903
  /** Present when the host asked for or recorded a permission decision. */
871
- permissionDecision: z8.enum(["allowed", "denied", "deferred", "not-required"]).optional(),
872
- output: contentFactSchema.optional()
904
+ permissionDecision: z9.enum(["allowed", "denied", "deferred", "not-required"]).optional(),
905
+ output: contentFactSchema.optional(),
906
+ /** The git worktree this call targeted, resolved by the core (ADR 0008). */
907
+ target: workspaceTargetSchema.optional()
873
908
  });
874
909
  var subagentStartEventSchema = event({
875
- type: z8.literal("subagent.start"),
910
+ type: z9.literal("subagent.start"),
876
911
  subagentInvocationId: invocationIdSchema,
877
912
  subagentType: nonEmptyStringSchema.optional(),
878
913
  /** 0 for the top-level agent; 1 for its direct children. */
879
- delegationDepth: z8.number().int().min(0).max(64),
914
+ delegationDepth: z9.number().int().min(0).max(64),
880
915
  model: modelDescriptorSchema.optional()
881
916
  });
882
917
  var subagentEndEventSchema = event({
883
- type: z8.literal("subagent.end"),
918
+ type: z9.literal("subagent.end"),
884
919
  subagentInvocationId: invocationIdSchema,
885
920
  outcome: outcomeSchema,
886
921
  durationMillis: durationMillisSchema.optional(),
887
922
  usage: canonicalUsageSchema.optional()
888
923
  });
889
924
  var compactionPerformedEventSchema = event({
890
- type: z8.literal("compaction.performed"),
891
- trigger: z8.enum(["automatic", "manual", "unknown"]),
925
+ type: z9.literal("compaction.performed"),
926
+ trigger: z9.enum(["automatic", "manual", "unknown"]),
892
927
  /** Provider-reported context size before and after compaction, if known. */
893
928
  contextTokensBefore: tokenCountSchema.optional(),
894
929
  contextTokensAfter: tokenCountSchema.optional(),
895
- droppedMessageCount: z8.number().int().min(0).optional(),
930
+ droppedMessageCount: z9.number().int().min(0).optional(),
896
931
  usage: canonicalUsageSchema.optional()
897
932
  });
898
933
  var errorRaisedEventSchema = event({
899
- type: z8.literal("error.raised"),
934
+ type: z9.literal("error.raised"),
900
935
  errorCode: otelHookErrorCodeSchema,
901
936
  severity: errorSeveritySchema,
902
937
  phase: errorPhaseSchema,
903
- retryable: z8.boolean(),
938
+ retryable: z9.boolean(),
904
939
  /** Error text is content: it is described, never embedded verbatim by default. */
905
940
  message: contentFactSchema.optional(),
906
941
  /** Non-sensitive, provider-agnostic short label. */
907
942
  detail: nonEmptyStringSchema.optional()
908
943
  });
909
- var canonicalEventSchema = z8.discriminatedUnion("type", [
944
+ var canonicalEventSchema = z9.discriminatedUnion("type", [
910
945
  sessionStartEventSchema,
911
946
  sessionEndEventSchema,
912
947
  promptSubmittedEventSchema,
@@ -936,14 +971,14 @@ var eventUsage = (event3) => "usage" in event3 ? event3.usage : void 0;
936
971
  var compareEvents = (a, b) => a.sequence - b.sequence || a.occurredAt - b.occurredAt || a.eventId.localeCompare(b.eventId);
937
972
 
938
973
  // src/errors/index.ts
939
- import { z as z9 } from "zod";
940
- var otelHookErrorInfoSchema = z9.strictObject({
974
+ import { z as z10 } from "zod";
975
+ var otelHookErrorInfoSchema = z10.strictObject({
941
976
  code: otelHookErrorCodeSchema,
942
977
  severity: errorSeveritySchema,
943
978
  phase: errorPhaseSchema,
944
979
  posture: failurePostureSchema,
945
- retryable: z9.boolean(),
946
- message: z9.string().min(1).max(512),
980
+ retryable: z10.boolean(),
981
+ message: z10.string().min(1).max(512),
947
982
  details: attributesSchema.optional(),
948
983
  occurredAt: epochMillisSchema.optional()
949
984
  });
@@ -997,8 +1032,8 @@ var errorInfoFromThrown = (thrown, input) => {
997
1032
  };
998
1033
 
999
1034
  // src/privacy/policy.ts
1000
- import { z as z10 } from "zod";
1001
- var contentModeSchema = z10.enum(["omit", "mask", "redact", "raw"]);
1035
+ import { z as z11 } from "zod";
1036
+ var contentModeSchema = z11.enum(["omit", "mask", "redact", "raw"]);
1002
1037
  var CONTENT_MODE_DISCLOSURE = Object.freeze({
1003
1038
  omit: "omitted",
1004
1039
  mask: "masked",
@@ -1024,35 +1059,35 @@ var DEFAULT_SECRET_VALUE_PATTERNS = Object.freeze([
1024
1059
  "eyJ[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}",
1025
1060
  "(?:Bearer|Basic)\\s+[A-Za-z0-9._~+/=-]{12,}"
1026
1061
  ]);
1027
- var privacyLimitsSchema = z10.strictObject({
1062
+ var privacyLimitsSchema = z11.strictObject({
1028
1063
  /** Maximum characters of disclosed text per content fact or string value. */
1029
- maxStringLength: z10.number().int().min(0).max(65536),
1064
+ maxStringLength: z11.number().int().min(0).max(65536),
1030
1065
  /** Maximum nesting depth walked when sanitizing structured values. */
1031
- maxDepth: z10.number().int().min(1).max(32),
1066
+ maxDepth: z11.number().int().min(1).max(32),
1032
1067
  /** Maximum array entries retained when sanitizing structured values. */
1033
- maxArrayLength: z10.number().int().min(1).max(4096),
1068
+ maxArrayLength: z11.number().int().min(1).max(4096),
1034
1069
  /** Maximum canonical events emitted per invocation. */
1035
- maxEventsPerInvocation: z10.number().int().min(1).max(1e4),
1070
+ maxEventsPerInvocation: z11.number().int().min(1).max(1e4),
1036
1071
  /** Maximum object keys retained per level when sanitizing. */
1037
- maxObjectKeys: z10.number().int().min(1).max(1024)
1072
+ maxObjectKeys: z11.number().int().min(1).max(1024)
1038
1073
  });
1039
- var privacyPolicySchema = z10.strictObject({
1074
+ var privacyPolicySchema = z11.strictObject({
1040
1075
  contentMode: contentModeSchema,
1041
1076
  /**
1042
1077
  * `raw` mode is refused unless this is also true, so a single mistyped
1043
1078
  * environment variable cannot start exporting prompts.
1044
1079
  */
1045
- allowRawContent: z10.boolean(),
1080
+ allowRawContent: z11.boolean(),
1046
1081
  /**
1047
1082
  * Salt mixed into every hash. A per-deployment salt makes hashes
1048
1083
  * non-correlatable across deployments; an empty salt makes them globally
1049
1084
  * comparable. Both are legitimate; the choice is explicit.
1050
1085
  */
1051
- hashSalt: z10.string().max(256),
1052
- maskCharacter: z10.string().length(1),
1053
- redactionPlaceholder: z10.string().min(1).max(64),
1054
- secretKeyPatterns: z10.array(z10.string().min(1)).max(128).readonly(),
1055
- secretValuePatterns: z10.array(z10.string().min(1)).max(128).readonly(),
1086
+ hashSalt: z11.string().max(256),
1087
+ maskCharacter: z11.string().length(1),
1088
+ redactionPlaceholder: z11.string().min(1).max(64),
1089
+ secretKeyPatterns: z11.array(z11.string().min(1)).max(128).readonly(),
1090
+ secretValuePatterns: z11.array(z11.string().min(1)).max(128).readonly(),
1056
1091
  limits: privacyLimitsSchema
1057
1092
  });
1058
1093
  var DEFAULT_PRIVACY_LIMITS = Object.freeze({
@@ -1302,11 +1337,11 @@ var createPrivacyService = (policyInput) => {
1302
1337
  };
1303
1338
  const flattenToAttributes = (value, prefix) => {
1304
1339
  const attributes = {};
1305
- const walk = (current, path7) => {
1340
+ const walk = (current, path9) => {
1306
1341
  if (typeof current === "string" || typeof current === "number" || typeof current === "boolean") {
1307
1342
  const primitive = toAttributePrimitive(current);
1308
1343
  if (primitive !== void 0) {
1309
- attributes[path7] = primitive;
1344
+ attributes[path9] = primitive;
1310
1345
  }
1311
1346
  return;
1312
1347
  }
@@ -1325,16 +1360,16 @@ var createPrivacyService = (policyInput) => {
1325
1360
  primitives.push(entryPrimitive);
1326
1361
  }
1327
1362
  if (uniform) {
1328
- attributes[path7] = primitives.slice(0, MAX_ATTRIBUTE_ARRAY_LENGTH);
1363
+ attributes[path9] = primitives.slice(0, MAX_ATTRIBUTE_ARRAY_LENGTH);
1329
1364
  return;
1330
1365
  }
1331
1366
  for (const [index, entry] of current.entries()) {
1332
- walk(entry, `${path7}.${index}`);
1367
+ walk(entry, `${path9}.${index}`);
1333
1368
  }
1334
1369
  return;
1335
1370
  }
1336
1371
  for (const [key, entry] of Object.entries(current)) {
1337
- walk(entry, path7 === "" ? key : `${path7}.${key}`);
1372
+ walk(entry, path9 === "" ? key : `${path9}.${key}`);
1338
1373
  }
1339
1374
  };
1340
1375
  walk(value, prefix);
@@ -1474,7 +1509,7 @@ var deriveWorkspaceIdentity = (privacy, input, labels = {}) => {
1474
1509
  };
1475
1510
 
1476
1511
  // src/config/resource-attributes.ts
1477
- import { z as z11 } from "zod";
1512
+ import { z as z12 } from "zod";
1478
1513
  var MAX_RESOURCE_ATTRIBUTES = 64;
1479
1514
  var MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH = 255;
1480
1515
  var MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH = 2048;
@@ -1519,12 +1554,12 @@ var checkResourceAttributeKey = (key) => {
1519
1554
  }
1520
1555
  return void 0;
1521
1556
  };
1522
- var resourceAttributeValueSchema = z11.union([
1523
- z11.string().max(MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH),
1524
- z11.number().finite(),
1525
- z11.boolean()
1557
+ var resourceAttributeValueSchema = z12.union([
1558
+ z12.string().max(MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH),
1559
+ z12.number().finite(),
1560
+ z12.boolean()
1526
1561
  ]);
1527
- var resourceAttributesSchema = z11.record(z11.string(), resourceAttributeValueSchema).superRefine((value, ctx) => {
1562
+ var resourceAttributesSchema = z12.record(z12.string(), resourceAttributeValueSchema).superRefine((value, ctx) => {
1528
1563
  const keys = Object.keys(value);
1529
1564
  if (keys.length > MAX_RESOURCE_ATTRIBUTES) {
1530
1565
  ctx.addIssue({
@@ -1633,37 +1668,37 @@ var sanitizeResourceAttributes = (attributes) => {
1633
1668
  var describeResourceAttributeNames = (attributes) => Object.keys(attributes).sort();
1634
1669
 
1635
1670
  // src/config/schema.ts
1636
- import { z as z12 } from "zod";
1637
- var logsPolicySchema = z12.strictObject({
1638
- enabled: z12.boolean(),
1671
+ import { z as z13 } from "zod";
1672
+ var logsPolicySchema = z13.strictObject({
1673
+ enabled: z13.boolean(),
1639
1674
  /**
1640
1675
  * Full URL for the logs signal.
1641
1676
  *
1642
1677
  * Absent, it is derived from `endpoint`: a trailing `/v1/traces` becomes
1643
1678
  * `/v1/logs`, and an endpoint with no signal path has `/v1/logs` appended.
1644
1679
  */
1645
- endpoint: z12.string().url().max(2048).optional(),
1646
- includeContent: z12.boolean(),
1647
- maxBatchSize: z12.number().int().min(1).max(4096)
1680
+ endpoint: z13.string().url().max(2048).optional(),
1681
+ includeContent: z13.boolean(),
1682
+ maxBatchSize: z13.number().int().min(1).max(4096)
1648
1683
  });
1649
1684
  var DEFAULT_LOGS_POLICY = Object.freeze({
1650
1685
  enabled: false,
1651
1686
  includeContent: false,
1652
1687
  maxBatchSize: 128
1653
1688
  });
1654
- var exporterPolicySchema = z12.strictObject({
1655
- enabled: z12.boolean(),
1656
- protocol: z12.enum(["http/protobuf", "http/json", "none"]),
1657
- endpoint: z12.string().url().max(2048).optional(),
1689
+ var exporterPolicySchema = z13.strictObject({
1690
+ enabled: z13.boolean(),
1691
+ protocol: z13.enum(["http/protobuf", "http/json", "none"]),
1692
+ endpoint: z13.string().url().max(2048).optional(),
1658
1693
  /**
1659
1694
  * Header names only. Values are supplied separately at construction time and
1660
1695
  * are never part of a resolved-config snapshot, which is logged and exported.
1661
1696
  */
1662
- headerNames: z12.array(nonEmptyStringSchema).max(32).readonly(),
1663
- timeoutMillis: z12.number().int().min(1).max(6e5),
1664
- maxBatchSize: z12.number().int().min(1).max(4096),
1665
- maxQueueSize: z12.number().int().min(1).max(65536),
1666
- maxRetryAttempts: z12.number().int().min(0).max(10),
1697
+ headerNames: z13.array(nonEmptyStringSchema).max(32).readonly(),
1698
+ timeoutMillis: z13.number().int().min(1).max(6e5),
1699
+ maxBatchSize: z13.number().int().min(1).max(4096),
1700
+ maxQueueSize: z13.number().int().min(1).max(65536),
1701
+ maxRetryAttempts: z13.number().int().min(0).max(10),
1667
1702
  serviceName: nonEmptyStringSchema,
1668
1703
  serviceNamespace: nonEmptyStringSchema.optional(),
1669
1704
  /**
@@ -1682,26 +1717,26 @@ var exporterPolicySchema = z12.strictObject({
1682
1717
  */
1683
1718
  logs: logsPolicySchema
1684
1719
  });
1685
- var detectionPolicySchema = z12.strictObject({
1720
+ var detectionPolicySchema = z13.strictObject({
1686
1721
  /** Detections below this confidence resolve to the unknown provider. */
1687
1722
  minimumConfidence: detectionConfidenceSchema,
1688
1723
  /** When false, an ambiguous detection is an error rather than unknown. */
1689
- allowAmbiguousFallback: z12.boolean(),
1724
+ allowAmbiguousFallback: z13.boolean(),
1690
1725
  /** Optional allow-list of provider ids; empty means "any registered". */
1691
- allowedProviderIds: z12.array(nonEmptyStringSchema).max(32).readonly()
1726
+ allowedProviderIds: z13.array(nonEmptyStringSchema).max(32).readonly()
1692
1727
  });
1693
- var diagnosticsPolicySchema = z12.strictObject({
1694
- logLevel: z12.enum(["silent", "error", "warn", "info", "debug"]),
1728
+ var diagnosticsPolicySchema = z13.strictObject({
1729
+ logLevel: z13.enum(["silent", "error", "warn", "info", "debug"]),
1695
1730
  /** Emit `error.raised` events for contained failures. */
1696
- emitErrorEvents: z12.boolean()
1731
+ emitErrorEvents: z13.boolean()
1697
1732
  });
1698
- var otelHookConfigSchema = z12.strictObject({
1733
+ var otelHookConfigSchema = z13.strictObject({
1699
1734
  exporter: exporterPolicySchema,
1700
1735
  privacy: privacyPolicySchema,
1701
1736
  detection: detectionPolicySchema,
1702
1737
  diagnostics: diagnosticsPolicySchema
1703
1738
  });
1704
- var otelHookConfigPatchSchema = z12.strictObject({
1739
+ var otelHookConfigPatchSchema = z13.strictObject({
1705
1740
  // `logs` is unwrapped and re-partialled for the same reason `privacy.limits` is:
1706
1741
  // merging happens per leaf, so a layer must be able to set `logs.enabled` alone
1707
1742
  // without also restating the endpoint and the batch size.
@@ -1739,16 +1774,16 @@ var DEFAULT_CONFIG = Object.freeze({
1739
1774
  });
1740
1775
 
1741
1776
  // src/config/resolve.ts
1742
- import { z as z13 } from "zod";
1777
+ import { z as z14 } from "zod";
1743
1778
  var CONFIG_SOURCE_PRECEDENCE = ["defaults", "file", "environment", "inline-override"];
1744
- var configSourceSchema = z13.enum(CONFIG_SOURCE_PRECEDENCE);
1779
+ var configSourceSchema = z14.enum(CONFIG_SOURCE_PRECEDENCE);
1745
1780
  var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1746
- var mergeLeaf = (target, patch, source, provenance, path7) => {
1781
+ var mergeLeaf = (target, patch, source, provenance, path9) => {
1747
1782
  for (const [key, value] of Object.entries(patch)) {
1748
1783
  if (value === void 0) {
1749
1784
  continue;
1750
1785
  }
1751
- const childPath = path7 === "" ? key : `${path7}.${key}`;
1786
+ const childPath = path9 === "" ? key : `${path9}.${key}`;
1752
1787
  const existing = target[key];
1753
1788
  if (isPlainObject(value) && isPlainObject(existing)) {
1754
1789
  const child = { ...existing };
@@ -1762,14 +1797,14 @@ var mergeLeaf = (target, patch, source, provenance, path7) => {
1762
1797
  };
1763
1798
  var initialProvenance = (config) => {
1764
1799
  const provenance = {};
1765
- const walk = (value, path7) => {
1800
+ const walk = (value, path9) => {
1766
1801
  if (isPlainObject(value)) {
1767
1802
  for (const [key, child] of Object.entries(value)) {
1768
- walk(child, path7 === "" ? key : `${path7}.${key}`);
1803
+ walk(child, path9 === "" ? key : `${path9}.${key}`);
1769
1804
  }
1770
1805
  return;
1771
1806
  }
1772
- provenance[path7] = "defaults";
1807
+ provenance[path9] = "defaults";
1773
1808
  };
1774
1809
  walk(config, "");
1775
1810
  return provenance;
@@ -2086,27 +2121,27 @@ var parseEnvironmentConfig = (env) => {
2086
2121
  };
2087
2122
 
2088
2123
  // src/providers/adapter.ts
2089
- import { z as z14 } from "zod";
2090
- var providerDetectionSchema = z14.strictObject({
2124
+ import { z as z15 } from "zod";
2125
+ var providerDetectionSchema = z15.strictObject({
2091
2126
  providerId: resolvedProviderIdSchema,
2092
2127
  confidence: detectionConfidenceSchema,
2093
2128
  /**
2094
2129
  * Short, non-sensitive justifications, e.g. `"payload.hook_event_name present"`.
2095
2130
  * Reasons are exported in diagnostics, so they must not quote payload values.
2096
2131
  */
2097
- reasons: z14.array(z14.string().min(1).max(160)).max(8),
2132
+ reasons: z15.array(z15.string().min(1).max(160)).max(8),
2098
2133
  providerVersion: nonEmptyStringSchema.optional(),
2099
2134
  /** The provider's own name for this event, when the payload states one. */
2100
2135
  sourceEventName: nonEmptyStringSchema.optional()
2101
2136
  });
2102
- var deliveryIdentifierSupportSchema = z14.enum(["none", "partial", "all"]);
2137
+ var deliveryIdentifierSupportSchema = z15.enum(["none", "partial", "all"]);
2103
2138
  var DELIVERY_COMPONENT_PATTERN = /^[A-Za-z0-9_.:@+=-]{1,256}$/;
2104
- var deliveryComponentSchema = z14.string().regex(
2139
+ var deliveryComponentSchema = z15.string().regex(
2105
2140
  DELIVERY_COMPONENT_PATTERN,
2106
2141
  "delivery component must be identifier-shaped: no whitespace, no path separators"
2107
2142
  );
2108
2143
  var MAX_DELIVERY_COMPONENTS = 8;
2109
- var providerDeliveryClaimSchema = z14.strictObject({
2144
+ var providerDeliveryClaimSchema = z15.strictObject({
2110
2145
  /**
2111
2146
  * The provider's own session/conversation id. Scopes the callback identity, so
2112
2147
  * two sessions reusing one tool-call id never collide.
@@ -2118,26 +2153,26 @@ var providerDeliveryClaimSchema = z14.strictObject({
2118
2153
  * Identifier-shaped payload fields that, together with `sourceEventName`,
2119
2154
  * name this callback within the session exactly once.
2120
2155
  */
2121
- components: z14.array(deliveryComponentSchema).min(1).max(MAX_DELIVERY_COMPONENTS).readonly(),
2156
+ components: z15.array(deliveryComponentSchema).min(1).max(MAX_DELIVERY_COMPONENTS).readonly(),
2122
2157
  /**
2123
2158
  * Short, non-sensitive justifications, e.g. `"payload.tool_use_id names one
2124
2159
  * tool call"`. Evidence reaches diagnostics, so it must name fields, never
2125
2160
  * quote their values.
2126
2161
  */
2127
- evidence: z14.array(z14.string().min(1).max(160)).min(1).max(4).readonly()
2162
+ evidence: z15.array(z15.string().min(1).max(160)).min(1).max(4).readonly()
2128
2163
  });
2129
2164
  var DELIVERY_GAP_REASON_PATTERN = /^[^\n\r\t\\/]{1,240}$/;
2130
- var deliveryGapReasonSchema = z14.string().regex(
2165
+ var deliveryGapReasonSchema = z15.string().regex(
2131
2166
  DELIVERY_GAP_REASON_PATTERN,
2132
2167
  "delivery gap reason must be one line of prose: no path separators, no control characters"
2133
2168
  );
2134
2169
  var MAX_DELIVERY_GAPS = 48;
2135
- var providerDeliveryGapsSchema = z14.record(deliveryComponentSchema, deliveryGapReasonSchema).refine((gaps) => Object.keys(gaps).length <= MAX_DELIVERY_GAPS, {
2170
+ var providerDeliveryGapsSchema = z15.record(deliveryComponentSchema, deliveryGapReasonSchema).refine((gaps) => Object.keys(gaps).length <= MAX_DELIVERY_GAPS, {
2136
2171
  message: `at most ${String(MAX_DELIVERY_GAPS)} delivery gaps may be declared`
2137
2172
  });
2138
- var providerCapabilitiesSchema = z14.strictObject({
2173
+ var providerCapabilitiesSchema = z15.strictObject({
2139
2174
  /** Event types the adapter can produce. */
2140
- lifecycleEvents: z14.array(canonicalEventTypeSchema).max(32).readonly(),
2175
+ lifecycleEvents: z15.array(canonicalEventTypeSchema).max(32).readonly(),
2141
2176
  usageTemporality: usageTemporalitySchema,
2142
2177
  /**
2143
2178
  * Which accumulator series a `cumulative` report continues — that is, which
@@ -2156,32 +2191,32 @@ var providerCapabilitiesSchema = z14.strictObject({
2156
2191
  * Subagent snapshots keep their own series regardless: a delegated agent's
2157
2192
  * counter is not a point on the parent session's curve.
2158
2193
  */
2159
- cumulativeUsageSeries: z14.enum(["event-scope", "session-lifetime"]).optional(),
2160
- reportsCachedInput: z14.boolean(),
2161
- reportsCacheCreation: z14.boolean(),
2194
+ cumulativeUsageSeries: z15.enum(["event-scope", "session-lifetime"]).optional(),
2195
+ reportsCachedInput: z15.boolean(),
2196
+ reportsCacheCreation: z15.boolean(),
2162
2197
  cacheCreationAccounting: cacheCreationAccountingSchema,
2163
- reportsReasoningOutput: z14.boolean(),
2164
- reportsProviderTotal: z14.boolean(),
2165
- reportsCost: z14.boolean(),
2166
- emitsSubagentEvents: z14.boolean(),
2167
- emitsCompactionEvents: z14.boolean(),
2198
+ reportsReasoningOutput: z15.boolean(),
2199
+ reportsProviderTotal: z15.boolean(),
2200
+ reportsCost: z15.boolean(),
2201
+ emitsSubagentEvents: z15.boolean(),
2202
+ emitsCompactionEvents: z15.boolean(),
2168
2203
  /** True when the provider reads a structured response from stdout. */
2169
- requiresHookResponse: z14.boolean(),
2204
+ requiresHookResponse: z15.boolean(),
2170
2205
  /** How much of this provider's hook traffic is replay-identifiable. */
2171
2206
  deliveryIdentifier: deliveryIdentifierSupportSchema
2172
2207
  });
2173
- var providerHookResponseSchema = z14.strictObject({
2208
+ var providerHookResponseSchema = z15.strictObject({
2174
2209
  /**
2175
2210
  * Always 0. A telemetry hook that can fail the host agent is a liability, so
2176
2211
  * the type forbids expressing anything else (ADR 0004).
2177
2212
  */
2178
- exitCode: z14.literal(0),
2213
+ exitCode: z15.literal(0),
2179
2214
  /** Protocol response text. Omit to write nothing at all. */
2180
- stdout: z14.string().max(8192).optional(),
2215
+ stdout: z15.string().max(8192).optional(),
2181
2216
  /** Non-sensitive diagnostic text for stderr. */
2182
- stderr: z14.string().max(8192).optional(),
2217
+ stderr: z15.string().max(8192).optional(),
2183
2218
  /** Declares which of the two stdout contracts this response follows. */
2184
- contract: z14.enum(["silent", "provider-protocol"])
2219
+ contract: z15.enum(["silent", "provider-protocol"])
2185
2220
  });
2186
2221
  var SILENT_HOOK_RESPONSE = Object.freeze({
2187
2222
  exitCode: 0,
@@ -2238,10 +2273,15 @@ var createEventFactory = (input) => {
2238
2273
  const { identity, context } = input;
2239
2274
  const built = [];
2240
2275
  const dropped = [];
2276
+ const hints = /* @__PURE__ */ new Map();
2241
2277
  let sequence = input.sequenceBase;
2278
+ const subagentId = input.subagentId !== void 0 && subagentIdSchema.safeParse(input.subagentId).success ? input.subagentId : void 0;
2242
2279
  return {
2243
2280
  build: (draft) => {
2244
- const { occurredAt, extensions, idDiscriminator, ...rest } = draft;
2281
+ const { occurredAt, extensions, idDiscriminator, targetHint, ...drafted } = draft;
2282
+ const rest = { ...drafted };
2283
+ delete rest.target;
2284
+ delete rest.subagentId;
2245
2285
  const sanitized = extensions === void 0 ? { extensions: {}, droppedKeys: [] } : context.privacy.sanitizeExtensions(extensions);
2246
2286
  dropped.push(...sanitized.droppedKeys);
2247
2287
  const currentSequence = sequence;
@@ -2261,6 +2301,7 @@ var createEventFactory = (input) => {
2261
2301
  occurredAt: occurredAt ?? context.clock.now(),
2262
2302
  provenance: identity.provenance,
2263
2303
  workspace: identity.workspace,
2304
+ ...subagentId === void 0 ? {} : { subagentId },
2264
2305
  extensions: sanitized.extensions
2265
2306
  };
2266
2307
  const parsed = canonicalEventSchema.safeParse(candidate);
@@ -2273,11 +2314,18 @@ var createEventFactory = (input) => {
2273
2314
  });
2274
2315
  }
2275
2316
  built.push(parsed.data);
2317
+ if (targetHint !== void 0 && (parsed.data.type === "tool.start" || parsed.data.type === "tool.end")) {
2318
+ const hint = targetHintSchema.safeParse(targetHint);
2319
+ if (hint.success) {
2320
+ hints.set(parsed.data.eventId, hint.data);
2321
+ }
2322
+ }
2276
2323
  return parsed.data;
2277
2324
  },
2278
2325
  events: () => [...built],
2279
2326
  nextSequence: () => sequence,
2280
- droppedExtensionKeys: () => [...dropped]
2327
+ droppedExtensionKeys: () => [...dropped],
2328
+ targetHints: () => new Map(hints)
2281
2329
  };
2282
2330
  };
2283
2331
 
@@ -2437,35 +2485,35 @@ var CLAUDE_CODE_CAPABILITIES = Object.freeze({
2437
2485
  });
2438
2486
 
2439
2487
  // src/providers/claude/schema.ts
2440
- import { z as z15 } from "zod";
2488
+ import { z as z16 } from "zod";
2441
2489
  var commonFields = {
2442
- session_id: z15.string().min(1),
2443
- transcript_path: z15.string().min(1).optional(),
2444
- cwd: z15.string().min(1).optional(),
2445
- permission_mode: z15.string().min(1).optional(),
2490
+ session_id: z16.string().min(1),
2491
+ transcript_path: z16.string().min(1).optional(),
2492
+ cwd: z16.string().min(1).optional(),
2493
+ permission_mode: z16.string().min(1).optional(),
2446
2494
  /** Correlates a hook firing with the user prompt that triggered it (Claude Code v2.1.196+). */
2447
- prompt_id: z15.string().min(1).optional(),
2495
+ prompt_id: z16.string().min(1).optional(),
2448
2496
  /** Present when the hook fired while running inside a subagent. */
2449
- agent_id: z15.string().min(1).optional(),
2450
- agent_type: z15.string().min(1).optional()
2451
- };
2452
- var claudeCacheCreationSchema = z15.object({
2453
- ephemeral_5m_input_tokens: z15.number().int().min(0).optional(),
2454
- ephemeral_1h_input_tokens: z15.number().int().min(0).optional()
2455
- });
2456
- var claudeUsageIterationSchema = z15.object({
2457
- input_tokens: z15.number().int().min(0).optional(),
2458
- output_tokens: z15.number().int().min(0).optional(),
2459
- cache_creation_input_tokens: z15.number().int().min(0).optional(),
2460
- cache_read_input_tokens: z15.number().int().min(0).optional()
2461
- });
2462
- var claudeUsageSchema = z15.object({
2463
- input_tokens: z15.number().int().min(0),
2464
- output_tokens: z15.number().int().min(0),
2465
- cache_creation_input_tokens: z15.number().int().min(0).optional(),
2466
- cache_read_input_tokens: z15.number().int().min(0).optional(),
2497
+ agent_id: z16.string().min(1).optional(),
2498
+ agent_type: z16.string().min(1).optional()
2499
+ };
2500
+ var claudeCacheCreationSchema = z16.object({
2501
+ ephemeral_5m_input_tokens: z16.number().int().min(0).optional(),
2502
+ ephemeral_1h_input_tokens: z16.number().int().min(0).optional()
2503
+ });
2504
+ var claudeUsageIterationSchema = z16.object({
2505
+ input_tokens: z16.number().int().min(0).optional(),
2506
+ output_tokens: z16.number().int().min(0).optional(),
2507
+ cache_creation_input_tokens: z16.number().int().min(0).optional(),
2508
+ cache_read_input_tokens: z16.number().int().min(0).optional()
2509
+ });
2510
+ var claudeUsageSchema = z16.object({
2511
+ input_tokens: z16.number().int().min(0),
2512
+ output_tokens: z16.number().int().min(0),
2513
+ cache_creation_input_tokens: z16.number().int().min(0).optional(),
2514
+ cache_read_input_tokens: z16.number().int().min(0).optional(),
2467
2515
  cache_creation: claudeCacheCreationSchema.optional(),
2468
- iterations: z15.array(claudeUsageIterationSchema).optional(),
2516
+ iterations: z16.array(claudeUsageIterationSchema).optional(),
2469
2517
  /**
2470
2518
  * Counters the canonical model has a home for but Claude Code never reports:
2471
2519
  * 0 of 4,999 real usage objects carried either (finding 5).
@@ -2474,112 +2522,112 @@ var claudeUsageSchema = z15.object({
2474
2522
  * that a harness attaching one gets told it was excluded, instead of watching
2475
2523
  * it vanish. See `CLAUDE_EXCLUDED_USAGE_COUNTERS`.
2476
2524
  */
2477
- total_tokens: z15.number().int().min(0).optional(),
2478
- reasoning_output_tokens: z15.number().int().min(0).optional()
2525
+ total_tokens: z16.number().int().min(0).optional(),
2526
+ reasoning_output_tokens: z16.number().int().min(0).optional()
2479
2527
  });
2480
- var sessionStartPayloadSchema = z15.object({
2528
+ var sessionStartPayloadSchema = z16.object({
2481
2529
  ...commonFields,
2482
- hook_event_name: z15.literal("SessionStart"),
2530
+ hook_event_name: z16.literal("SessionStart"),
2483
2531
  /** Matcher values: startup | resume | clear | compact | fork. Forward-compatible: any string. */
2484
- source: z15.string().min(1).optional(),
2485
- model: z15.string().min(1).optional(),
2486
- session_title: z15.string().min(1).optional()
2532
+ source: z16.string().min(1).optional(),
2533
+ model: z16.string().min(1).optional(),
2534
+ session_title: z16.string().min(1).optional()
2487
2535
  });
2488
- var sessionEndPayloadSchema = z15.object({
2536
+ var sessionEndPayloadSchema = z16.object({
2489
2537
  ...commonFields,
2490
- hook_event_name: z15.literal("SessionEnd"),
2538
+ hook_event_name: z16.literal("SessionEnd"),
2491
2539
  /** Current Claude Code field; values include clear, logout, prompt_input_exit, and other. */
2492
- reason: z15.string().min(1).optional(),
2540
+ reason: z16.string().min(1).optional(),
2493
2541
  /** Compatibility alias emitted by older wrappers and hook integrations. */
2494
- end_reason: z15.string().min(1).optional()
2542
+ end_reason: z16.string().min(1).optional()
2495
2543
  });
2496
- var userPromptSubmitPayloadSchema = z15.object({
2544
+ var userPromptSubmitPayloadSchema = z16.object({
2497
2545
  ...commonFields,
2498
- hook_event_name: z15.literal("UserPromptSubmit"),
2499
- prompt: z15.string()
2546
+ hook_event_name: z16.literal("UserPromptSubmit"),
2547
+ prompt: z16.string()
2500
2548
  });
2501
- var preToolUsePayloadSchema = z15.object({
2549
+ var preToolUsePayloadSchema = z16.object({
2502
2550
  ...commonFields,
2503
- hook_event_name: z15.literal("PreToolUse"),
2504
- tool_name: z15.string().min(1),
2505
- tool_input: z15.unknown(),
2506
- tool_use_id: z15.string().min(1)
2551
+ hook_event_name: z16.literal("PreToolUse"),
2552
+ tool_name: z16.string().min(1),
2553
+ tool_input: z16.unknown(),
2554
+ tool_use_id: z16.string().min(1)
2507
2555
  });
2508
- var postToolUsePayloadSchema = z15.object({
2556
+ var postToolUsePayloadSchema = z16.object({
2509
2557
  ...commonFields,
2510
- hook_event_name: z15.literal("PostToolUse"),
2511
- tool_name: z15.string().min(1),
2512
- tool_input: z15.unknown().optional(),
2513
- tool_response: z15.unknown(),
2514
- tool_use_id: z15.string().min(1)
2558
+ hook_event_name: z16.literal("PostToolUse"),
2559
+ tool_name: z16.string().min(1),
2560
+ tool_input: z16.unknown().optional(),
2561
+ tool_response: z16.unknown(),
2562
+ tool_use_id: z16.string().min(1)
2515
2563
  });
2516
- var postToolUseFailurePayloadSchema = z15.object({
2564
+ var postToolUseFailurePayloadSchema = z16.object({
2517
2565
  ...commonFields,
2518
- hook_event_name: z15.literal("PostToolUseFailure"),
2519
- tool_name: z15.string().min(1),
2520
- tool_input: z15.unknown().optional(),
2521
- tool_error: z15.unknown(),
2522
- tool_use_id: z15.string().min(1)
2566
+ hook_event_name: z16.literal("PostToolUseFailure"),
2567
+ tool_name: z16.string().min(1),
2568
+ tool_input: z16.unknown().optional(),
2569
+ tool_error: z16.unknown(),
2570
+ tool_use_id: z16.string().min(1)
2523
2571
  });
2524
- var permissionRequestPayloadSchema = z15.object({
2572
+ var permissionRequestPayloadSchema = z16.object({
2525
2573
  ...commonFields,
2526
- hook_event_name: z15.literal("PermissionRequest"),
2527
- tool_name: z15.string().min(1),
2528
- tool_input: z15.unknown().optional(),
2529
- tool_use_id: z15.string().min(1)
2574
+ hook_event_name: z16.literal("PermissionRequest"),
2575
+ tool_name: z16.string().min(1),
2576
+ tool_input: z16.unknown().optional(),
2577
+ tool_use_id: z16.string().min(1)
2530
2578
  });
2531
- var subagentStartPayloadSchema = z15.object({
2579
+ var subagentStartPayloadSchema = z16.object({
2532
2580
  ...commonFields,
2533
- hook_event_name: z15.literal("SubagentStart"),
2534
- agent_type: z15.string().min(1),
2535
- agent_id: z15.string().min(1)
2581
+ hook_event_name: z16.literal("SubagentStart"),
2582
+ agent_type: z16.string().min(1),
2583
+ agent_id: z16.string().min(1)
2536
2584
  });
2537
- var subagentStopPayloadSchema = z15.object({
2585
+ var subagentStopPayloadSchema = z16.object({
2538
2586
  ...commonFields,
2539
- hook_event_name: z15.literal("SubagentStop"),
2540
- agent_type: z15.string().min(1),
2541
- agent_id: z15.string().min(1),
2542
- last_assistant_message: z15.string().optional(),
2587
+ hook_event_name: z16.literal("SubagentStop"),
2588
+ agent_type: z16.string().min(1),
2589
+ agent_id: z16.string().min(1),
2590
+ last_assistant_message: z16.string().optional(),
2543
2591
  /** True when this stop fired because a hook continued the subagent's turn. */
2544
- stop_hook_active: z15.boolean().optional(),
2592
+ stop_hook_active: z16.boolean().optional(),
2545
2593
  usage: claudeUsageSchema.optional()
2546
2594
  });
2547
- var preCompactPayloadSchema = z15.object({
2595
+ var preCompactPayloadSchema = z16.object({
2548
2596
  ...commonFields,
2549
- hook_event_name: z15.literal("PreCompact"),
2597
+ hook_event_name: z16.literal("PreCompact"),
2550
2598
  /** Upstream values: manual | auto. Forward-compatible: any string. */
2551
- trigger: z15.string().min(1).optional(),
2599
+ trigger: z16.string().min(1).optional(),
2552
2600
  /** Compatibility alias emitted by older wrappers and hook integrations. */
2553
- compact_trigger: z15.string().min(1).optional(),
2601
+ compact_trigger: z16.string().min(1).optional(),
2554
2602
  /**
2555
2603
  * Harness-supplied, never upstream. Reported as an explicit exclusion rather
2556
2604
  * than carried across the process boundary: see `events.ts`.
2557
2605
  */
2558
- context_tokens_before: z15.number().int().min(0).optional(),
2559
- estimated_tokens_removed: z15.number().int().min(0).optional()
2606
+ context_tokens_before: z16.number().int().min(0).optional(),
2607
+ estimated_tokens_removed: z16.number().int().min(0).optional()
2560
2608
  });
2561
- var postCompactPayloadSchema = z15.object({
2609
+ var postCompactPayloadSchema = z16.object({
2562
2610
  ...commonFields,
2563
- hook_event_name: z15.literal("PostCompact"),
2564
- trigger: z15.string().min(1).optional(),
2565
- compact_trigger: z15.string().min(1).optional(),
2611
+ hook_event_name: z16.literal("PostCompact"),
2612
+ trigger: z16.string().min(1).optional(),
2613
+ compact_trigger: z16.string().min(1).optional(),
2566
2614
  /** Harness-supplied, never upstream; accepted here because one callback carries both. */
2567
- context_tokens_before: z15.number().int().min(0).optional(),
2568
- context_tokens_after: z15.number().int().min(0).optional(),
2569
- dropped_message_count: z15.number().int().min(0).optional(),
2615
+ context_tokens_before: z16.number().int().min(0).optional(),
2616
+ context_tokens_after: z16.number().int().min(0).optional(),
2617
+ dropped_message_count: z16.number().int().min(0).optional(),
2570
2618
  usage: claudeUsageSchema.optional()
2571
2619
  });
2572
- var stopPayloadSchema = z15.object({
2620
+ var stopPayloadSchema = z16.object({
2573
2621
  ...commonFields,
2574
- hook_event_name: z15.literal("Stop"),
2622
+ hook_event_name: z16.literal("Stop"),
2575
2623
  /**
2576
2624
  * Interactive Stop field (Claude Code ≥ 2.1.47). Print / `-p` / Agent SDK
2577
2625
  * result messages use `result` instead; `events.ts` reads both (and camelCase
2578
2626
  * `lastAssistantMessage`) through `extractClaudeAssistantText`.
2579
2627
  */
2580
- last_assistant_message: z15.string().optional(),
2628
+ last_assistant_message: z16.string().optional(),
2581
2629
  /** Print / `-p` JSON result field; accepted so a harness can attach it as-is. */
2582
- result: z15.string().optional(),
2630
+ result: z16.string().optional(),
2583
2631
  /**
2584
2632
  * True when this stop fired because a hook continued the turn.
2585
2633
  *
@@ -2587,22 +2635,22 @@ var stopPayloadSchema = z15.object({
2587
2635
  * stop from a continuation stop, which is what lets `delivery.ts` deduplicate
2588
2636
  * the former without suppressing the latter.
2589
2637
  */
2590
- stop_hook_active: z15.boolean().optional(),
2638
+ stop_hook_active: z16.boolean().optional(),
2591
2639
  usage: claudeUsageSchema.optional()
2592
2640
  });
2593
- var stopFailurePayloadSchema = z15.object({
2641
+ var stopFailurePayloadSchema = z16.object({
2594
2642
  ...commonFields,
2595
- hook_event_name: z15.literal("StopFailure"),
2643
+ hook_event_name: z16.literal("StopFailure"),
2596
2644
  /**
2597
2645
  * Matcher values: rate_limit | overloaded | authentication_failed |
2598
2646
  * oauth_org_not_allowed | billing_error | invalid_request | model_not_found
2599
2647
  * | server_error | max_output_tokens | unknown.
2600
2648
  */
2601
- error_type: z15.string().min(1),
2602
- error_message: z15.string().optional(),
2649
+ error_type: z16.string().min(1),
2650
+ error_message: z16.string().optional(),
2603
2651
  usage: claudeUsageSchema.optional()
2604
2652
  });
2605
- var claudeHookPayloadSchema = z15.discriminatedUnion("hook_event_name", [
2653
+ var claudeHookPayloadSchema = z16.discriminatedUnion("hook_event_name", [
2606
2654
  sessionStartPayloadSchema,
2607
2655
  sessionEndPayloadSchema,
2608
2656
  userPromptSubmitPayloadSchema,
@@ -2632,15 +2680,15 @@ var CLAUDE_HOOK_EVENT_NAMES = [
2632
2680
  "Stop",
2633
2681
  "StopFailure"
2634
2682
  ];
2635
- var claudeIdentityFieldsSchema = z15.object({
2636
- session_id: z15.string().min(1),
2637
- hook_event_name: z15.string().min(1),
2638
- cwd: z15.string().min(1).optional(),
2639
- prompt_id: z15.string().min(1).optional(),
2640
- agent_id: z15.string().min(1).optional(),
2641
- tool_use_id: z15.string().min(1).optional(),
2683
+ var claudeIdentityFieldsSchema = z16.object({
2684
+ session_id: z16.string().min(1),
2685
+ hook_event_name: z16.string().min(1),
2686
+ cwd: z16.string().min(1).optional(),
2687
+ prompt_id: z16.string().min(1).optional(),
2688
+ agent_id: z16.string().min(1).optional(),
2689
+ tool_use_id: z16.string().min(1).optional(),
2642
2690
  /** Read by `delivery.ts` to tell a once-per-prompt stop from a continuation. */
2643
- stop_hook_active: z15.boolean().optional()
2691
+ stop_hook_active: z16.boolean().optional()
2644
2692
  });
2645
2693
 
2646
2694
  // src/providers/claude/usage.ts
@@ -3071,6 +3119,37 @@ var extractClaudeAssistantText = (payload) => {
3071
3119
  return void 0;
3072
3120
  };
3073
3121
 
3122
+ // src/providers/claude/target.ts
3123
+ var PATH_FIELDS = Object.freeze({
3124
+ Read: ["file_path"],
3125
+ Write: ["file_path"],
3126
+ Edit: ["file_path"],
3127
+ MultiEdit: ["file_path"],
3128
+ NotebookEdit: ["notebook_path"],
3129
+ NotebookRead: ["notebook_path"],
3130
+ // Optional on both: absent means "search the session's directory".
3131
+ Glob: ["path"],
3132
+ Grep: ["path"]
3133
+ });
3134
+ var asRecord4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
3135
+ var claudeTargetHint = (toolName, toolInput, cwd) => {
3136
+ const fields = Object.hasOwn(PATH_FIELDS, toolName) ? PATH_FIELDS[toolName] : void 0;
3137
+ const input = asRecord4(toolInput);
3138
+ if (fields !== void 0 && input !== void 0) {
3139
+ for (const field of fields) {
3140
+ const candidate = input[field];
3141
+ if (typeof candidate === "string" && candidate.length > 0) {
3142
+ return {
3143
+ source: "tool-path",
3144
+ paths: [candidate],
3145
+ ...cwd === void 0 ? {} : { baseDirectory: cwd }
3146
+ };
3147
+ }
3148
+ }
3149
+ }
3150
+ return cwd === void 0 ? void 0 : { source: "session-cwd", paths: [cwd] };
3151
+ };
3152
+
3074
3153
  // src/providers/claude/tool-kind.ts
3075
3154
  var BUILT_IN_TOOL_KIND = Object.freeze({
3076
3155
  Bash: "execute",
@@ -3150,9 +3229,16 @@ var parseClaudeCode = (input, context) => {
3150
3229
  const factory = createEventFactory({
3151
3230
  identity: input.identity,
3152
3231
  sequenceBase: input.sequenceBase,
3153
- context
3232
+ context,
3233
+ // Present exactly when the hook fired inside a subagent (or describes one,
3234
+ // on SubagentStart/SubagentStop).
3235
+ ...payload.agent_id === void 0 ? {} : { subagentId: payload.agent_id }
3154
3236
  });
3155
3237
  const warnings = [];
3238
+ const targetHintFor = (toolName, toolInput) => {
3239
+ const hint = claudeTargetHint(toolName, toolInput, payload.cwd);
3240
+ return hint === void 0 ? {} : { targetHint: hint };
3241
+ };
3156
3242
  const withUsage = (usage) => {
3157
3243
  const normalized = normalizeClaudeUsage(usage);
3158
3244
  warnings.push(...normalized.warnings);
@@ -3187,6 +3273,7 @@ var parseClaudeCode = (input, context) => {
3187
3273
  toolCallId: payload.tool_use_id,
3188
3274
  toolName: payload.tool_name,
3189
3275
  toolKind: inferToolKind(payload.tool_name),
3276
+ ...targetHintFor(payload.tool_name, payload.tool_input),
3190
3277
  ...payload.tool_input === void 0 ? {} : {
3191
3278
  input: context.privacy.describeStructured({
3192
3279
  kind: "tool-input",
@@ -3202,6 +3289,7 @@ var parseClaudeCode = (input, context) => {
3202
3289
  toolCallId: payload.tool_use_id,
3203
3290
  toolName: payload.tool_name,
3204
3291
  outcome: "ok",
3292
+ ...targetHintFor(payload.tool_name, payload.tool_input),
3205
3293
  output: context.privacy.describeStructured({
3206
3294
  kind: "tool-output",
3207
3295
  value: payload.tool_response,
@@ -3215,6 +3303,7 @@ var parseClaudeCode = (input, context) => {
3215
3303
  toolCallId: payload.tool_use_id,
3216
3304
  toolName: payload.tool_name,
3217
3305
  outcome: "error",
3306
+ ...targetHintFor(payload.tool_name, payload.tool_input),
3218
3307
  output: context.privacy.describeStructured({
3219
3308
  kind: "tool-output",
3220
3309
  value: payload.tool_error,
@@ -3313,10 +3402,12 @@ var parseClaudeCode = (input, context) => {
3313
3402
  break;
3314
3403
  }
3315
3404
  }
3405
+ const targetHints = factory.targetHints();
3316
3406
  return {
3317
3407
  status: "parsed",
3318
3408
  events: factory.events(),
3319
- ...warnings.length === 0 ? {} : { warnings }
3409
+ ...warnings.length === 0 ? {} : { warnings },
3410
+ ...targetHints.size === 0 ? {} : { targetHints }
3320
3411
  };
3321
3412
  };
3322
3413
 
@@ -3334,7 +3425,7 @@ var createClaudeCodeAdapter = (options = {}) => ({
3334
3425
  });
3335
3426
 
3336
3427
  // src/providers/cursor/payload.ts
3337
- import { z as z16 } from "zod";
3428
+ import { z as z17 } from "zod";
3338
3429
  var CURSOR_PROVIDER_ID = "cursor";
3339
3430
  var CURSOR_HOOK_EVENT_NAMES = [
3340
3431
  "sessionStart",
@@ -3369,23 +3460,23 @@ var CURSOR_DECISION_EVENTS = Object.freeze({
3369
3460
  subagentStart: "permission",
3370
3461
  beforeSubmitPrompt: "continue"
3371
3462
  });
3372
- var modelParamSchema = z16.object({
3373
- id: z16.string(),
3374
- value: z16.string()
3463
+ var modelParamSchema = z17.object({
3464
+ id: z17.string(),
3465
+ value: z17.string()
3375
3466
  });
3376
- var attachmentSchema = z16.object({
3377
- type: z16.string().optional(),
3378
- file_path: z16.string().optional()
3467
+ var attachmentSchema = z17.object({
3468
+ type: z17.string().optional(),
3469
+ file_path: z17.string().optional()
3379
3470
  });
3380
- var fileEditSchema = z16.object({
3381
- old_string: z16.string().optional(),
3382
- new_string: z16.string().optional()
3471
+ var fileEditSchema = z17.object({
3472
+ old_string: z17.string().optional(),
3473
+ new_string: z17.string().optional()
3383
3474
  });
3384
3475
  var usageFields = {
3385
- input_tokens: z16.number().int().min(0).optional(),
3386
- output_tokens: z16.number().int().min(0).optional(),
3387
- cache_read_tokens: z16.number().int().min(0).optional(),
3388
- cache_write_tokens: z16.number().int().min(0).optional()
3476
+ input_tokens: z17.number().int().min(0).optional(),
3477
+ output_tokens: z17.number().int().min(0).optional(),
3478
+ cache_read_tokens: z17.number().int().min(0).optional(),
3479
+ cache_write_tokens: z17.number().int().min(0).optional()
3389
3480
  };
3390
3481
  var envelopeShape = {
3391
3482
  // Not `.min(1)`: see `cursorSessionId`. A payload naming neither
@@ -3393,136 +3484,136 @@ var envelopeShape = {
3393
3484
  // `recognizeCursorPayload`'s post-parse check — but rejecting it here would
3394
3485
  // fail the whole discriminated union on a field the adapter can source from
3395
3486
  // either name.
3396
- conversation_id: z16.string().optional(),
3397
- generation_id: z16.string().optional(),
3398
- session_id: z16.string().optional(),
3399
- model: z16.string().optional(),
3400
- model_id: z16.string().optional(),
3401
- model_params: z16.array(modelParamSchema).max(64).optional(),
3402
- cursor_version: z16.string().optional(),
3403
- workspace_roots: z16.array(z16.string()).max(64).optional(),
3404
- cwd: z16.string().optional(),
3487
+ conversation_id: z17.string().optional(),
3488
+ generation_id: z17.string().optional(),
3489
+ session_id: z17.string().optional(),
3490
+ model: z17.string().optional(),
3491
+ model_id: z17.string().optional(),
3492
+ model_params: z17.array(modelParamSchema).max(64).optional(),
3493
+ cursor_version: z17.string().optional(),
3494
+ workspace_roots: z17.array(z17.string()).max(64).optional(),
3495
+ cwd: z17.string().optional(),
3405
3496
  /** Never propagated. */
3406
- user_email: z16.string().nullish(),
3497
+ user_email: z17.string().nullish(),
3407
3498
  /** Never propagated. */
3408
- transcript_path: z16.string().nullish()
3499
+ transcript_path: z17.string().nullish()
3409
3500
  };
3410
- var event2 = (name, shape) => z16.object({ ...envelopeShape, hook_event_name: z16.literal(name), ...shape });
3501
+ var event2 = (name, shape) => z17.object({ ...envelopeShape, hook_event_name: z17.literal(name), ...shape });
3411
3502
  var sessionStartPayloadSchema2 = event2("sessionStart", {
3412
- is_background_agent: z16.boolean().optional(),
3413
- composer_mode: z16.string().optional()
3503
+ is_background_agent: z17.boolean().optional(),
3504
+ composer_mode: z17.string().optional()
3414
3505
  });
3415
3506
  var sessionEndPayloadSchema2 = event2("sessionEnd", {
3416
- reason: z16.string().optional(),
3417
- duration_ms: z16.number().min(0).optional(),
3418
- is_background_agent: z16.boolean().optional(),
3419
- final_status: z16.string().optional(),
3420
- error_message: z16.string().optional()
3507
+ reason: z17.string().optional(),
3508
+ duration_ms: z17.number().min(0).optional(),
3509
+ is_background_agent: z17.boolean().optional(),
3510
+ final_status: z17.string().optional(),
3511
+ error_message: z17.string().optional()
3421
3512
  });
3422
3513
  var beforeSubmitPromptPayloadSchema = event2("beforeSubmitPrompt", {
3423
- prompt: z16.string().optional(),
3424
- attachments: z16.array(attachmentSchema).max(256).optional(),
3425
- composer_mode: z16.string().optional()
3514
+ prompt: z17.string().optional(),
3515
+ attachments: z17.array(attachmentSchema).max(256).optional(),
3516
+ composer_mode: z17.string().optional()
3426
3517
  });
3427
3518
  var afterAgentResponsePayloadSchema = event2("afterAgentResponse", {
3428
- text: z16.string().optional(),
3519
+ text: z17.string().optional(),
3429
3520
  ...usageFields
3430
3521
  });
3431
3522
  var afterAgentThoughtPayloadSchema = event2("afterAgentThought", {
3432
- text: z16.string().optional(),
3433
- duration_ms: z16.number().min(0).optional()
3523
+ text: z17.string().optional(),
3524
+ duration_ms: z17.number().min(0).optional()
3434
3525
  });
3435
3526
  var preToolUsePayloadSchema2 = event2("preToolUse", {
3436
- tool_name: z16.string().min(1),
3437
- tool_input: z16.unknown().optional(),
3438
- tool_use_id: z16.string().optional(),
3439
- agent_message: z16.string().optional()
3527
+ tool_name: z17.string().min(1),
3528
+ tool_input: z17.unknown().optional(),
3529
+ tool_use_id: z17.string().optional(),
3530
+ agent_message: z17.string().optional()
3440
3531
  });
3441
3532
  var postToolUsePayloadSchema2 = event2("postToolUse", {
3442
- tool_name: z16.string().min(1),
3443
- tool_input: z16.unknown().optional(),
3444
- tool_output: z16.unknown().optional(),
3445
- tool_use_id: z16.string().optional(),
3446
- duration: z16.number().min(0).optional()
3533
+ tool_name: z17.string().min(1),
3534
+ tool_input: z17.unknown().optional(),
3535
+ tool_output: z17.unknown().optional(),
3536
+ tool_use_id: z17.string().optional(),
3537
+ duration: z17.number().min(0).optional()
3447
3538
  });
3448
3539
  var postToolUseFailurePayloadSchema2 = event2("postToolUseFailure", {
3449
- tool_name: z16.string().min(1),
3450
- tool_input: z16.unknown().optional(),
3451
- tool_use_id: z16.string().optional(),
3452
- error_message: z16.string().optional(),
3453
- failure_type: z16.string().optional(),
3454
- duration: z16.number().min(0).optional(),
3455
- is_interrupt: z16.boolean().optional()
3540
+ tool_name: z17.string().min(1),
3541
+ tool_input: z17.unknown().optional(),
3542
+ tool_use_id: z17.string().optional(),
3543
+ error_message: z17.string().optional(),
3544
+ failure_type: z17.string().optional(),
3545
+ duration: z17.number().min(0).optional(),
3546
+ is_interrupt: z17.boolean().optional()
3456
3547
  });
3457
3548
  var beforeShellExecutionPayloadSchema = event2("beforeShellExecution", {
3458
- command: z16.string(),
3459
- sandbox: z16.boolean().optional()
3549
+ command: z17.string(),
3550
+ sandbox: z17.boolean().optional()
3460
3551
  });
3461
3552
  var afterShellExecutionPayloadSchema = event2("afterShellExecution", {
3462
- command: z16.string(),
3463
- output: z16.string().optional(),
3464
- duration: z16.number().min(0).optional(),
3465
- sandbox: z16.boolean().optional()
3553
+ command: z17.string(),
3554
+ output: z17.string().optional(),
3555
+ duration: z17.number().min(0).optional(),
3556
+ sandbox: z17.boolean().optional()
3466
3557
  });
3467
3558
  var beforeMcpExecutionPayloadSchema = event2("beforeMCPExecution", {
3468
- tool_name: z16.string().min(1),
3469
- tool_input: z16.unknown().optional(),
3470
- url: z16.string().optional(),
3471
- command: z16.string().optional()
3559
+ tool_name: z17.string().min(1),
3560
+ tool_input: z17.unknown().optional(),
3561
+ url: z17.string().optional(),
3562
+ command: z17.string().optional()
3472
3563
  });
3473
3564
  var afterMcpExecutionPayloadSchema = event2("afterMCPExecution", {
3474
- tool_name: z16.string().min(1),
3475
- tool_input: z16.unknown().optional(),
3476
- result_json: z16.string().optional(),
3477
- duration: z16.number().min(0).optional()
3565
+ tool_name: z17.string().min(1),
3566
+ tool_input: z17.unknown().optional(),
3567
+ result_json: z17.string().optional(),
3568
+ duration: z17.number().min(0).optional()
3478
3569
  });
3479
3570
  var beforeReadFilePayloadSchema = event2("beforeReadFile", {
3480
- file_path: z16.string(),
3481
- content: z16.string().optional(),
3482
- attachments: z16.array(attachmentSchema).max(256).optional()
3571
+ file_path: z17.string(),
3572
+ content: z17.string().optional(),
3573
+ attachments: z17.array(attachmentSchema).max(256).optional()
3483
3574
  });
3484
3575
  var afterFileEditPayloadSchema = event2("afterFileEdit", {
3485
- file_path: z16.string(),
3486
- edits: z16.array(fileEditSchema).max(1024).optional()
3576
+ file_path: z17.string(),
3577
+ edits: z17.array(fileEditSchema).max(1024).optional()
3487
3578
  });
3488
3579
  var subagentStartPayloadSchema2 = event2("subagentStart", {
3489
- subagent_id: z16.string().optional(),
3490
- subagent_type: z16.string().optional(),
3491
- task: z16.string().optional(),
3492
- parent_conversation_id: z16.string().optional(),
3493
- tool_call_id: z16.string().optional(),
3494
- subagent_model: z16.string().optional(),
3495
- is_parallel_worker: z16.boolean().optional(),
3496
- git_branch: z16.string().optional()
3580
+ subagent_id: z17.string().optional(),
3581
+ subagent_type: z17.string().optional(),
3582
+ task: z17.string().optional(),
3583
+ parent_conversation_id: z17.string().optional(),
3584
+ tool_call_id: z17.string().optional(),
3585
+ subagent_model: z17.string().optional(),
3586
+ is_parallel_worker: z17.boolean().optional(),
3587
+ git_branch: z17.string().optional()
3497
3588
  });
3498
3589
  var subagentStopPayloadSchema2 = event2("subagentStop", {
3499
- subagent_type: z16.string().optional(),
3500
- status: z16.string().optional(),
3501
- task: z16.string().optional(),
3502
- description: z16.string().optional(),
3503
- summary: z16.string().optional(),
3504
- duration_ms: z16.number().min(0).optional(),
3505
- message_count: z16.number().int().min(0).optional(),
3506
- tool_call_count: z16.number().int().min(0).optional(),
3507
- loop_count: z16.number().int().min(0).optional(),
3508
- modified_files: z16.array(z16.string()).max(1024).optional(),
3509
- agent_transcript_path: z16.string().nullish()
3590
+ subagent_type: z17.string().optional(),
3591
+ status: z17.string().optional(),
3592
+ task: z17.string().optional(),
3593
+ description: z17.string().optional(),
3594
+ summary: z17.string().optional(),
3595
+ duration_ms: z17.number().min(0).optional(),
3596
+ message_count: z17.number().int().min(0).optional(),
3597
+ tool_call_count: z17.number().int().min(0).optional(),
3598
+ loop_count: z17.number().int().min(0).optional(),
3599
+ modified_files: z17.array(z17.string()).max(1024).optional(),
3600
+ agent_transcript_path: z17.string().nullish()
3510
3601
  });
3511
3602
  var preCompactPayloadSchema2 = event2("preCompact", {
3512
- trigger: z16.string().optional(),
3513
- context_usage_percent: z16.number().optional(),
3514
- context_tokens: z16.number().int().min(0).optional(),
3515
- context_window_size: z16.number().int().min(0).optional(),
3516
- message_count: z16.number().int().min(0).optional(),
3517
- messages_to_compact: z16.number().int().min(0).optional(),
3518
- is_first_compaction: z16.boolean().optional()
3603
+ trigger: z17.string().optional(),
3604
+ context_usage_percent: z17.number().optional(),
3605
+ context_tokens: z17.number().int().min(0).optional(),
3606
+ context_window_size: z17.number().int().min(0).optional(),
3607
+ message_count: z17.number().int().min(0).optional(),
3608
+ messages_to_compact: z17.number().int().min(0).optional(),
3609
+ is_first_compaction: z17.boolean().optional()
3519
3610
  });
3520
3611
  var stopPayloadSchema2 = event2("stop", {
3521
- status: z16.string().optional(),
3522
- loop_count: z16.number().int().min(0).optional(),
3612
+ status: z17.string().optional(),
3613
+ loop_count: z17.number().int().min(0).optional(),
3523
3614
  ...usageFields
3524
3615
  });
3525
- var cursorPayloadSchema = z16.discriminatedUnion("hook_event_name", [
3616
+ var cursorPayloadSchema = z17.discriminatedUnion("hook_event_name", [
3526
3617
  sessionStartPayloadSchema2,
3527
3618
  sessionEndPayloadSchema2,
3528
3619
  beforeSubmitPromptPayloadSchema,
@@ -3659,6 +3750,33 @@ var cursorDeliveryIdentity = (input) => {
3659
3750
  };
3660
3751
  };
3661
3752
 
3753
+ // src/providers/cursor/target.ts
3754
+ var singleWorkspaceRoot = (payload) => {
3755
+ const roots = (payload.workspace_roots ?? []).filter((root) => root.length > 0);
3756
+ return roots.length === 1 ? roots[0] : void 0;
3757
+ };
3758
+ var sessionHint = (root) => root === void 0 ? void 0 : { source: "session-cwd", paths: [root] };
3759
+ var cursorTargetHint = (payload) => {
3760
+ const root = singleWorkspaceRoot(payload);
3761
+ const base = root === void 0 ? {} : { baseDirectory: root };
3762
+ switch (payload.hook_event_name) {
3763
+ case "afterFileEdit":
3764
+ case "beforeReadFile":
3765
+ return payload.file_path.length === 0 ? sessionHint(root) : { source: "tool-path", paths: [payload.file_path], ...base };
3766
+ case "beforeShellExecution":
3767
+ case "afterShellExecution":
3768
+ return payload.cwd !== void 0 && payload.cwd.length > 0 ? { source: "shell-cwd", paths: [payload.cwd], ...base } : sessionHint(root);
3769
+ case "preToolUse":
3770
+ case "postToolUse":
3771
+ case "postToolUseFailure":
3772
+ case "beforeMCPExecution":
3773
+ case "afterMCPExecution":
3774
+ return sessionHint(root);
3775
+ default:
3776
+ return void 0;
3777
+ }
3778
+ };
3779
+
3662
3780
  // src/providers/cursor/usage.ts
3663
3781
  var normalizeCursorUsage = (raw) => {
3664
3782
  const inputTokens = raw.input_tokens;
@@ -3914,12 +4032,6 @@ var createCursorAdapter = (options = {}) => {
3914
4032
  reason: "afterAgentThought is a reasoning notification, not a generation lifecycle event; no canonical event type represents it and thought text is never exported"
3915
4033
  };
3916
4034
  }
3917
- if (payload.hook_event_name === "beforeReadFile") {
3918
- return {
3919
- status: "ignored",
3920
- reason: "beforeReadFile has no completion callback in the cursor hook protocol, so emitting tool.start here would leave a tool lifecycle that never closes"
3921
- };
3922
- }
3923
4035
  if (payload.hook_event_name === "subagentStart" || payload.hook_event_name === "subagentStop") {
3924
4036
  return {
3925
4037
  status: "ignored",
@@ -3934,6 +4046,8 @@ var createCursorAdapter = (options = {}) => {
3934
4046
  const warnings = [];
3935
4047
  const sessionId = input.identity.sessionId;
3936
4048
  const model = toModelDescriptor(payload);
4049
+ const targetHint = cursorTargetHint(payload);
4050
+ const targetHintField = targetHint === void 0 ? {} : { targetHint };
3937
4051
  switch (payload.hook_event_name) {
3938
4052
  case "sessionStart":
3939
4053
  factory.build({
@@ -3986,6 +4100,7 @@ var createCursorAdapter = (options = {}) => {
3986
4100
  case "preToolUse":
3987
4101
  factory.build({
3988
4102
  type: "tool.start",
4103
+ ...targetHintField,
3989
4104
  toolCallId: payload.tool_use_id ?? derivedToolCallId(context, sessionId, [
3990
4105
  "tool",
3991
4106
  payload.generation_id ?? "",
@@ -4009,6 +4124,7 @@ var createCursorAdapter = (options = {}) => {
4009
4124
  case "postToolUse":
4010
4125
  factory.build({
4011
4126
  type: "tool.end",
4127
+ ...targetHintField,
4012
4128
  toolCallId: payload.tool_use_id ?? derivedToolCallId(context, sessionId, [
4013
4129
  "tool",
4014
4130
  payload.generation_id ?? "",
@@ -4031,6 +4147,7 @@ var createCursorAdapter = (options = {}) => {
4031
4147
  case "postToolUseFailure":
4032
4148
  factory.build({
4033
4149
  type: "tool.end",
4150
+ ...targetHintField,
4034
4151
  toolCallId: payload.tool_use_id ?? derivedToolCallId(context, sessionId, [
4035
4152
  "tool",
4036
4153
  payload.generation_id ?? "",
@@ -4051,6 +4168,7 @@ var createCursorAdapter = (options = {}) => {
4051
4168
  case "beforeShellExecution":
4052
4169
  factory.build({
4053
4170
  type: "tool.start",
4171
+ ...targetHintField,
4054
4172
  toolCallId: derivedToolCallId(context, sessionId, [
4055
4173
  "shell",
4056
4174
  payload.generation_id ?? "",
@@ -4070,6 +4188,7 @@ var createCursorAdapter = (options = {}) => {
4070
4188
  case "afterShellExecution":
4071
4189
  factory.build({
4072
4190
  type: "tool.end",
4191
+ ...targetHintField,
4073
4192
  toolCallId: derivedToolCallId(context, sessionId, [
4074
4193
  "shell",
4075
4194
  payload.generation_id ?? "",
@@ -4094,6 +4213,7 @@ var createCursorAdapter = (options = {}) => {
4094
4213
  case "beforeMCPExecution":
4095
4214
  factory.build({
4096
4215
  type: "tool.start",
4216
+ ...targetHintField,
4097
4217
  toolCallId: derivedToolCallId(context, sessionId, [
4098
4218
  "mcp",
4099
4219
  payload.generation_id ?? "",
@@ -4114,6 +4234,7 @@ var createCursorAdapter = (options = {}) => {
4114
4234
  case "afterMCPExecution":
4115
4235
  factory.build({
4116
4236
  type: "tool.end",
4237
+ ...targetHintField,
4117
4238
  toolCallId: derivedToolCallId(context, sessionId, [
4118
4239
  "mcp",
4119
4240
  payload.generation_id ?? "",
@@ -4141,6 +4262,7 @@ var createCursorAdapter = (options = {}) => {
4141
4262
  ]);
4142
4263
  factory.build({
4143
4264
  type: "tool.start",
4265
+ ...targetHintField,
4144
4266
  toolCallId,
4145
4267
  toolName: "edit_file",
4146
4268
  toolKind: "write",
@@ -4153,6 +4275,7 @@ var createCursorAdapter = (options = {}) => {
4153
4275
  });
4154
4276
  factory.build({
4155
4277
  type: "tool.end",
4278
+ ...targetHintField,
4156
4279
  toolCallId,
4157
4280
  toolName: "edit_file",
4158
4281
  outcome: "ok",
@@ -4162,6 +4285,34 @@ var createCursorAdapter = (options = {}) => {
4162
4285
  });
4163
4286
  break;
4164
4287
  }
4288
+ case "beforeReadFile": {
4289
+ const toolCallId = derivedToolCallId(context, sessionId, [
4290
+ "read-file",
4291
+ payload.generation_id ?? "",
4292
+ payload.file_path
4293
+ ]);
4294
+ factory.build({
4295
+ type: "tool.start",
4296
+ ...targetHintField,
4297
+ toolCallId,
4298
+ toolName: "read_file",
4299
+ toolKind: "read",
4300
+ ...payload.generation_id === void 0 || payload.generation_id.length === 0 ? {} : { generationId: payload.generation_id },
4301
+ input: context.privacy.describeContent({
4302
+ kind: "tool-input",
4303
+ text: payload.file_path,
4304
+ label: "read_file"
4305
+ })
4306
+ });
4307
+ factory.build({
4308
+ type: "tool.end",
4309
+ ...targetHintField,
4310
+ toolCallId,
4311
+ toolName: "read_file",
4312
+ outcome: "unknown"
4313
+ });
4314
+ break;
4315
+ }
4165
4316
  case "preCompact":
4166
4317
  factory.build({
4167
4318
  type: "compaction.performed",
@@ -4199,10 +4350,12 @@ var createCursorAdapter = (options = {}) => {
4199
4350
  break;
4200
4351
  }
4201
4352
  }
4353
+ const targetHints = factory.targetHints();
4202
4354
  return {
4203
4355
  status: "parsed",
4204
4356
  events: factory.events(),
4205
- ...warnings.length === 0 ? {} : { warnings }
4357
+ ...warnings.length === 0 ? {} : { warnings },
4358
+ ...targetHints.size === 0 ? {} : { targetHints }
4206
4359
  };
4207
4360
  };
4208
4361
  const hookResponse2 = (input) => {
@@ -4233,105 +4386,105 @@ var createCursorAdapter = (options = {}) => {
4233
4386
  };
4234
4387
 
4235
4388
  // src/providers/codex/payload.ts
4236
- import { z as z17 } from "zod";
4237
- var permissionModeSchema = z17.enum([
4389
+ import { z as z18 } from "zod";
4390
+ var permissionModeSchema = z18.enum([
4238
4391
  "default",
4239
4392
  "acceptEdits",
4240
4393
  "plan",
4241
4394
  "dontAsk",
4242
4395
  "bypassPermissions"
4243
4396
  ]);
4244
- var codexUsageSchema = z17.object({
4245
- input_tokens: z17.number().int().min(0).optional(),
4246
- cached_input_tokens: z17.number().int().min(0).optional(),
4247
- output_tokens: z17.number().int().min(0).optional(),
4248
- reasoning_output_tokens: z17.number().int().min(0).optional(),
4249
- total_tokens: z17.number().int().min(0).optional()
4397
+ var codexUsageSchema = z18.object({
4398
+ input_tokens: z18.number().int().min(0).optional(),
4399
+ cached_input_tokens: z18.number().int().min(0).optional(),
4400
+ output_tokens: z18.number().int().min(0).optional(),
4401
+ reasoning_output_tokens: z18.number().int().min(0).optional(),
4402
+ total_tokens: z18.number().int().min(0).optional()
4250
4403
  });
4251
4404
  var baseFields = {
4252
- session_id: z17.string().min(1).max(256),
4253
- cwd: z17.string().min(1).max(4096).optional(),
4254
- model: z17.string().min(1).max(256).optional(),
4405
+ session_id: z18.string().min(1).max(256),
4406
+ cwd: z18.string().min(1).max(4096).optional(),
4407
+ model: z18.string().min(1).max(256).optional(),
4255
4408
  permission_mode: permissionModeSchema.optional(),
4256
- transcript_path: z17.string().min(1).max(4096).optional(),
4257
- codex_version: z17.string().min(1).max(64).optional(),
4409
+ transcript_path: z18.string().min(1).max(4096).optional(),
4410
+ codex_version: z18.string().min(1).max(64).optional(),
4258
4411
  /** Not part of the documented protocol; lets tests and replay stay deterministic. */
4259
- occurred_at: z17.number().int().min(0).optional()
4412
+ occurred_at: z18.number().int().min(0).optional()
4260
4413
  };
4261
- var codexSessionStartPayloadSchema = z17.object({
4414
+ var codexSessionStartPayloadSchema = z18.object({
4262
4415
  ...baseFields,
4263
- hook_event_name: z17.literal("SessionStart"),
4264
- source: z17.enum(["startup", "resume", "clear", "compact"]).optional()
4416
+ hook_event_name: z18.literal("SessionStart"),
4417
+ source: z18.enum(["startup", "resume", "clear", "compact"]).optional()
4265
4418
  });
4266
- var codexUserPromptSubmitPayloadSchema = z17.object({
4419
+ var codexUserPromptSubmitPayloadSchema = z18.object({
4267
4420
  ...baseFields,
4268
- hook_event_name: z17.literal("UserPromptSubmit"),
4269
- turn_id: z17.string().min(1).max(256).optional(),
4270
- prompt: z17.string().max(1e6).optional()
4421
+ hook_event_name: z18.literal("UserPromptSubmit"),
4422
+ turn_id: z18.string().min(1).max(256).optional(),
4423
+ prompt: z18.string().max(1e6).optional()
4271
4424
  });
4272
- var codexPreToolUsePayloadSchema = z17.object({
4425
+ var codexPreToolUsePayloadSchema = z18.object({
4273
4426
  ...baseFields,
4274
- hook_event_name: z17.literal("PreToolUse"),
4275
- turn_id: z17.string().min(1).max(256).optional(),
4276
- tool_name: z17.string().min(1).max(256),
4277
- tool_call_id: z17.string().min(1).max(256).optional(),
4278
- tool_input: z17.unknown().optional()
4427
+ hook_event_name: z18.literal("PreToolUse"),
4428
+ turn_id: z18.string().min(1).max(256).optional(),
4429
+ tool_name: z18.string().min(1).max(256),
4430
+ tool_call_id: z18.string().min(1).max(256).optional(),
4431
+ tool_input: z18.unknown().optional()
4279
4432
  });
4280
- var codexPermissionRequestPayloadSchema = z17.object({
4433
+ var codexPermissionRequestPayloadSchema = z18.object({
4281
4434
  ...baseFields,
4282
- hook_event_name: z17.literal("PermissionRequest"),
4283
- turn_id: z17.string().min(1).max(256).optional(),
4284
- tool_name: z17.string().min(1).max(256).optional(),
4285
- tool_call_id: z17.string().min(1).max(256).optional(),
4286
- tool_input: z17.unknown().optional()
4435
+ hook_event_name: z18.literal("PermissionRequest"),
4436
+ turn_id: z18.string().min(1).max(256).optional(),
4437
+ tool_name: z18.string().min(1).max(256).optional(),
4438
+ tool_call_id: z18.string().min(1).max(256).optional(),
4439
+ tool_input: z18.unknown().optional()
4287
4440
  });
4288
- var codexPostToolUsePayloadSchema = z17.object({
4441
+ var codexPostToolUsePayloadSchema = z18.object({
4289
4442
  ...baseFields,
4290
- hook_event_name: z17.literal("PostToolUse"),
4291
- turn_id: z17.string().min(1).max(256).optional(),
4292
- tool_name: z17.string().min(1).max(256),
4293
- tool_call_id: z17.string().min(1).max(256).optional(),
4294
- tool_input: z17.unknown().optional(),
4295
- tool_response: z17.unknown().optional(),
4296
- permission_decision: z17.enum(["allowed", "denied", "deferred"]).optional(),
4297
- duration_ms: z17.number().min(0).optional()
4443
+ hook_event_name: z18.literal("PostToolUse"),
4444
+ turn_id: z18.string().min(1).max(256).optional(),
4445
+ tool_name: z18.string().min(1).max(256),
4446
+ tool_call_id: z18.string().min(1).max(256).optional(),
4447
+ tool_input: z18.unknown().optional(),
4448
+ tool_response: z18.unknown().optional(),
4449
+ permission_decision: z18.enum(["allowed", "denied", "deferred"]).optional(),
4450
+ duration_ms: z18.number().min(0).optional()
4298
4451
  });
4299
- var codexPreCompactPayloadSchema = z17.object({
4452
+ var codexPreCompactPayloadSchema = z18.object({
4300
4453
  ...baseFields,
4301
- hook_event_name: z17.literal("PreCompact"),
4302
- trigger: z17.enum(["auto", "manual"]).optional(),
4303
- context_tokens_before: z17.number().int().min(0).optional()
4454
+ hook_event_name: z18.literal("PreCompact"),
4455
+ trigger: z18.enum(["auto", "manual"]).optional(),
4456
+ context_tokens_before: z18.number().int().min(0).optional()
4304
4457
  });
4305
- var codexPostCompactPayloadSchema = z17.object({
4458
+ var codexPostCompactPayloadSchema = z18.object({
4306
4459
  ...baseFields,
4307
- hook_event_name: z17.literal("PostCompact"),
4308
- trigger: z17.enum(["auto", "manual"]).optional(),
4309
- context_tokens_after: z17.number().int().min(0).optional(),
4310
- dropped_message_count: z17.number().int().min(0).optional(),
4460
+ hook_event_name: z18.literal("PostCompact"),
4461
+ trigger: z18.enum(["auto", "manual"]).optional(),
4462
+ context_tokens_after: z18.number().int().min(0).optional(),
4463
+ dropped_message_count: z18.number().int().min(0).optional(),
4311
4464
  usage: codexUsageSchema.optional()
4312
4465
  });
4313
- var codexSubagentStartPayloadSchema = z17.object({
4466
+ var codexSubagentStartPayloadSchema = z18.object({
4314
4467
  ...baseFields,
4315
- hook_event_name: z17.literal("SubagentStart"),
4316
- turn_id: z17.string().min(1).max(256).optional(),
4317
- subagent_id: z17.string().min(1).max(256),
4318
- subagent_type: z17.string().min(1).max(256).optional()
4468
+ hook_event_name: z18.literal("SubagentStart"),
4469
+ turn_id: z18.string().min(1).max(256).optional(),
4470
+ subagent_id: z18.string().min(1).max(256),
4471
+ subagent_type: z18.string().min(1).max(256).optional()
4319
4472
  });
4320
- var codexSubagentStopPayloadSchema = z17.object({
4473
+ var codexSubagentStopPayloadSchema = z18.object({
4321
4474
  ...baseFields,
4322
- hook_event_name: z17.literal("SubagentStop"),
4323
- turn_id: z17.string().min(1).max(256).optional(),
4324
- subagent_id: z17.string().min(1).max(256),
4325
- status: z17.enum(["completed", "failed", "cancelled"]).optional(),
4475
+ hook_event_name: z18.literal("SubagentStop"),
4476
+ turn_id: z18.string().min(1).max(256).optional(),
4477
+ subagent_id: z18.string().min(1).max(256),
4478
+ status: z18.enum(["completed", "failed", "cancelled"]).optional(),
4326
4479
  usage: codexUsageSchema.optional()
4327
4480
  });
4328
- var codexStopPayloadSchema = z17.object({
4481
+ var codexStopPayloadSchema = z18.object({
4329
4482
  ...baseFields,
4330
- hook_event_name: z17.literal("Stop"),
4331
- turn_id: z17.string().min(1).max(256).optional(),
4332
- stop_reason: z17.string().min(1).max(256).optional(),
4483
+ hook_event_name: z18.literal("Stop"),
4484
+ turn_id: z18.string().min(1).max(256).optional(),
4485
+ stop_reason: z18.string().min(1).max(256).optional(),
4333
4486
  usage: codexUsageSchema.optional(),
4334
- duration_ms: z17.number().min(0).optional()
4487
+ duration_ms: z18.number().min(0).optional()
4335
4488
  });
4336
4489
  var CODEX_HOOK_EVENT_NAMES = [
4337
4490
  "SessionStart",
@@ -4345,7 +4498,7 @@ var CODEX_HOOK_EVENT_NAMES = [
4345
4498
  "SubagentStop",
4346
4499
  "Stop"
4347
4500
  ];
4348
- var codexHookPayloadSchema = z17.discriminatedUnion("hook_event_name", [
4501
+ var codexHookPayloadSchema = z18.discriminatedUnion("hook_event_name", [
4349
4502
  codexSessionStartPayloadSchema,
4350
4503
  codexUserPromptSubmitPayloadSchema,
4351
4504
  codexPreToolUsePayloadSchema,
@@ -4357,9 +4510,9 @@ var codexHookPayloadSchema = z17.discriminatedUnion("hook_event_name", [
4357
4510
  codexSubagentStopPayloadSchema,
4358
4511
  codexStopPayloadSchema
4359
4512
  ]);
4360
- var codexHookEnvelopeSchema = z17.object({
4361
- session_id: z17.string().min(1),
4362
- hook_event_name: z17.enum(CODEX_HOOK_EVENT_NAMES)
4513
+ var codexHookEnvelopeSchema = z18.object({
4514
+ session_id: z18.string().min(1),
4515
+ hook_event_name: z18.enum(CODEX_HOOK_EVENT_NAMES)
4363
4516
  });
4364
4517
 
4365
4518
  // src/providers/codex/delivery.ts
@@ -4420,6 +4573,61 @@ var codexDeliveryIdentity = (input) => {
4420
4573
  };
4421
4574
  };
4422
4575
 
4576
+ // src/providers/codex/target.ts
4577
+ var PATCH_HEADER = /^\*\*\* (?:Add File|Update File|Delete File|Move to): (.+)$/;
4578
+ var asRecord5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
4579
+ var nonEmptyString2 = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
4580
+ var commandText = (input) => {
4581
+ const command = input?.command ?? input?.cmd;
4582
+ if (typeof command === "string") {
4583
+ return command;
4584
+ }
4585
+ if (Array.isArray(command) && command.every((part) => typeof part === "string")) {
4586
+ return command.join(" ");
4587
+ }
4588
+ return void 0;
4589
+ };
4590
+ var patchHeaderPaths = (patch) => {
4591
+ const paths = /* @__PURE__ */ new Set();
4592
+ for (const line of patch.split(/\r?\n/)) {
4593
+ const match = PATCH_HEADER.exec(line.trimEnd());
4594
+ const named = match?.[1]?.trim();
4595
+ if (named !== void 0 && named.length > 0) {
4596
+ paths.add(named);
4597
+ }
4598
+ }
4599
+ return paths.size === 0 || paths.size > MAX_TARGET_HINT_PATHS ? void 0 : [...paths];
4600
+ };
4601
+ var patchTextOf = (toolName, input) => {
4602
+ if (typeof input === "string") {
4603
+ return /^apply[_-]?patch$/i.test(toolName) ? input : void 0;
4604
+ }
4605
+ const record = asRecord5(input);
4606
+ if (/^apply[_-]?patch$/i.test(toolName)) {
4607
+ return nonEmptyString2(record?.patch) ?? nonEmptyString2(record?.input) ?? commandText(record);
4608
+ }
4609
+ const command = commandText(record);
4610
+ return command !== void 0 && /^\s*apply_patch\b/.test(command) ? command : void 0;
4611
+ };
4612
+ var codexTargetHint = (toolName, toolInput, cwd) => {
4613
+ const record = asRecord5(toolInput);
4614
+ const workdir = nonEmptyString2(record?.workdir);
4615
+ const base = workdir ?? cwd;
4616
+ const patch = patchTextOf(toolName, toolInput);
4617
+ if (patch !== void 0) {
4618
+ const paths = patchHeaderPaths(patch);
4619
+ return paths === void 0 ? void 0 : { source: "tool-path", paths, ...base === void 0 ? {} : { baseDirectory: base } };
4620
+ }
4621
+ if (workdir !== void 0) {
4622
+ return {
4623
+ source: "shell-cwd",
4624
+ paths: [workdir],
4625
+ ...cwd === void 0 ? {} : { baseDirectory: cwd }
4626
+ };
4627
+ }
4628
+ return cwd === void 0 ? void 0 : { source: "session-cwd", paths: [cwd] };
4629
+ };
4630
+
4423
4631
  // src/providers/codex/tool-kind.ts
4424
4632
  var PATTERNS = [
4425
4633
  [/^(apply[_-]?patch|patch)$/i, "write"],
@@ -4484,7 +4692,7 @@ var CODEX_CAPABILITIES = Object.freeze({
4484
4692
  // compaction callbacks do not. See `./delivery.ts` for which and why.
4485
4693
  deliveryIdentifier: "partial"
4486
4694
  });
4487
- var asRecord4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
4695
+ var asRecord6 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
4488
4696
  var hasExactMarker = (payload) => {
4489
4697
  if (payload.codex_version !== void 0) {
4490
4698
  return true;
@@ -4577,7 +4785,7 @@ var outcomeFromToolResponse = (toolResponse) => {
4577
4785
  if (toolResponse === void 0) {
4578
4786
  return "unknown";
4579
4787
  }
4580
- const record = asRecord4(toolResponse);
4788
+ const record = asRecord6(toolResponse);
4581
4789
  if (record === void 0) {
4582
4790
  return "ok";
4583
4791
  }
@@ -4649,6 +4857,10 @@ var parse = (input, context) => {
4649
4857
  context
4650
4858
  });
4651
4859
  const warnings = [];
4860
+ const targetHintFor = (toolName, toolInput) => {
4861
+ const hint = codexTargetHint(toolName, toolInput, payload.cwd);
4862
+ return hint === void 0 ? {} : { targetHint: hint };
4863
+ };
4652
4864
  const buildUsage = (usage) => {
4653
4865
  if (usage === void 0) {
4654
4866
  return void 0;
@@ -4693,6 +4905,7 @@ var parse = (input, context) => {
4693
4905
  toolName: payload.tool_name,
4694
4906
  toolKind: classifyCodexToolKind(payload.tool_name),
4695
4907
  occurredAt,
4908
+ ...targetHintFor(payload.tool_name, payload.tool_input),
4696
4909
  ...payload.tool_input === void 0 ? {} : {
4697
4910
  input: context.privacy.describeStructured({
4698
4911
  kind: "tool-input",
@@ -4719,6 +4932,7 @@ var parse = (input, context) => {
4719
4932
  outcome,
4720
4933
  permissionDecision,
4721
4934
  occurredAt,
4935
+ ...targetHintFor(payload.tool_name, payload.tool_input),
4722
4936
  ...payload.duration_ms === void 0 ? {} : { durationMillis: payload.duration_ms },
4723
4937
  ...payload.tool_response === void 0 ? {} : {
4724
4938
  output: context.privacy.describeStructured({
@@ -4801,10 +5015,12 @@ var parse = (input, context) => {
4801
5015
  break;
4802
5016
  }
4803
5017
  }
5018
+ const targetHints = factory.targetHints();
4804
5019
  return {
4805
5020
  status: "parsed",
4806
5021
  events: factory.events(),
4807
- ...warnings.length === 0 ? {} : { warnings }
5022
+ ...warnings.length === 0 ? {} : { warnings },
5023
+ ...targetHints.size === 0 ? {} : { targetHints }
4808
5024
  };
4809
5025
  };
4810
5026
  var hookResponse = () => SILENT_HOOK_RESPONSE;
@@ -4911,7 +5127,7 @@ var geminiCorrelationSeed = (input) => {
4911
5127
  };
4912
5128
 
4913
5129
  // src/providers/gemini/schema.ts
4914
- import { z as z18 } from "zod";
5130
+ import { z as z19 } from "zod";
4915
5131
  var GEMINI_HOOK_EVENT_NAMES = [
4916
5132
  "SessionStart",
4917
5133
  "SessionEnd",
@@ -4925,113 +5141,113 @@ var GEMINI_HOOK_EVENT_NAMES = [
4925
5141
  "PreCompress",
4926
5142
  "Notification"
4927
5143
  ];
4928
- var baseHookInputSchema = z18.object({
4929
- session_id: z18.string().min(1),
4930
- transcript_path: z18.string().optional(),
4931
- cwd: z18.string().optional(),
4932
- timestamp: z18.string().min(1).optional()
4933
- });
4934
- var llmMessageSchema = z18.object({
4935
- role: z18.enum(["user", "model", "system"]).optional(),
4936
- content: z18.union([z18.string(), z18.array(z18.unknown())]).optional()
5144
+ var baseHookInputSchema = z19.object({
5145
+ session_id: z19.string().min(1),
5146
+ transcript_path: z19.string().optional(),
5147
+ cwd: z19.string().optional(),
5148
+ timestamp: z19.string().min(1).optional()
5149
+ });
5150
+ var llmMessageSchema = z19.object({
5151
+ role: z19.enum(["user", "model", "system"]).optional(),
5152
+ content: z19.union([z19.string(), z19.array(z19.unknown())]).optional()
4937
5153
  }).loose();
4938
- var llmRequestConfigSchema = z18.object({
4939
- temperature: z18.number().optional(),
4940
- maxOutputTokens: z18.number().int().min(0).optional()
5154
+ var llmRequestConfigSchema = z19.object({
5155
+ temperature: z19.number().optional(),
5156
+ maxOutputTokens: z19.number().int().min(0).optional()
4941
5157
  }).loose();
4942
- var geminiLlmRequestSchema = z18.object({
4943
- model: z18.string().min(1).optional(),
4944
- messages: z18.array(llmMessageSchema).optional(),
5158
+ var geminiLlmRequestSchema = z19.object({
5159
+ model: z19.string().min(1).optional(),
5160
+ messages: z19.array(llmMessageSchema).optional(),
4945
5161
  config: llmRequestConfigSchema.optional(),
4946
- toolConfig: z18.unknown().optional()
5162
+ toolConfig: z19.unknown().optional()
4947
5163
  }).loose();
4948
- var geminiUsageMetadataSchema = z18.object({
4949
- promptTokenCount: z18.number().int().min(0).optional(),
4950
- cachedContentTokenCount: z18.number().int().min(0).optional(),
4951
- candidatesTokenCount: z18.number().int().min(0).optional(),
4952
- thoughtsTokenCount: z18.number().int().min(0).optional(),
4953
- totalTokenCount: z18.number().int().min(0).optional()
5164
+ var geminiUsageMetadataSchema = z19.object({
5165
+ promptTokenCount: z19.number().int().min(0).optional(),
5166
+ cachedContentTokenCount: z19.number().int().min(0).optional(),
5167
+ candidatesTokenCount: z19.number().int().min(0).optional(),
5168
+ thoughtsTokenCount: z19.number().int().min(0).optional(),
5169
+ totalTokenCount: z19.number().int().min(0).optional()
4954
5170
  }).loose();
4955
- var geminiCandidateSchema = z18.object({
4956
- content: z18.object({
4957
- role: z18.string().optional(),
4958
- parts: z18.array(z18.unknown()).optional()
5171
+ var geminiCandidateSchema = z19.object({
5172
+ content: z19.object({
5173
+ role: z19.string().optional(),
5174
+ parts: z19.array(z19.unknown()).optional()
4959
5175
  }).loose().optional(),
4960
- finishReason: z18.string().optional(),
4961
- index: z18.number().int().min(0).optional()
5176
+ finishReason: z19.string().optional(),
5177
+ index: z19.number().int().min(0).optional()
4962
5178
  }).loose();
4963
- var geminiLlmResponseSchema = z18.object({
5179
+ var geminiLlmResponseSchema = z19.object({
4964
5180
  /** Whole-response text, set by the translator from `getResponseText`. */
4965
- text: z18.string().optional(),
4966
- candidates: z18.array(geminiCandidateSchema).optional(),
5181
+ text: z19.string().optional(),
5182
+ candidates: z19.array(geminiCandidateSchema).optional(),
4967
5183
  usageMetadata: geminiUsageMetadataSchema.optional()
4968
5184
  }).loose();
4969
- var geminiMcpContextSchema = z18.object({
4970
- server_name: z18.string().optional(),
4971
- tool_name: z18.string().optional()
5185
+ var geminiMcpContextSchema = z19.object({
5186
+ server_name: z19.string().optional(),
5187
+ tool_name: z19.string().optional()
4972
5188
  }).loose();
4973
- var geminiToolResponseSchema = z18.object({
4974
- llmContent: z18.unknown().optional(),
4975
- returnDisplay: z18.unknown().optional(),
4976
- error: z18.unknown().optional()
5189
+ var geminiToolResponseSchema = z19.object({
5190
+ llmContent: z19.unknown().optional(),
5191
+ returnDisplay: z19.unknown().optional(),
5192
+ error: z19.unknown().optional()
4977
5193
  }).loose();
4978
5194
  var sessionStartInputSchema = baseHookInputSchema.extend({
4979
- hook_event_name: z18.literal("SessionStart"),
4980
- source: z18.enum(["startup", "resume", "clear"]).optional()
5195
+ hook_event_name: z19.literal("SessionStart"),
5196
+ source: z19.enum(["startup", "resume", "clear"]).optional()
4981
5197
  });
4982
5198
  var sessionEndInputSchema = baseHookInputSchema.extend({
4983
- hook_event_name: z18.literal("SessionEnd"),
4984
- reason: z18.enum(["exit", "clear", "logout", "prompt_input_exit", "other"]).optional()
5199
+ hook_event_name: z19.literal("SessionEnd"),
5200
+ reason: z19.enum(["exit", "clear", "logout", "prompt_input_exit", "other"]).optional()
4985
5201
  });
4986
5202
  var beforeAgentInputSchema = baseHookInputSchema.extend({
4987
- hook_event_name: z18.literal("BeforeAgent"),
4988
- prompt: z18.string().optional()
5203
+ hook_event_name: z19.literal("BeforeAgent"),
5204
+ prompt: z19.string().optional()
4989
5205
  });
4990
5206
  var afterAgentInputSchema = baseHookInputSchema.extend({
4991
- hook_event_name: z18.literal("AfterAgent"),
4992
- prompt: z18.string().optional(),
4993
- prompt_response: z18.string().optional(),
4994
- stop_hook_active: z18.boolean().optional()
5207
+ hook_event_name: z19.literal("AfterAgent"),
5208
+ prompt: z19.string().optional(),
5209
+ prompt_response: z19.string().optional(),
5210
+ stop_hook_active: z19.boolean().optional()
4995
5211
  });
4996
5212
  var beforeModelInputSchema = baseHookInputSchema.extend({
4997
- hook_event_name: z18.literal("BeforeModel"),
5213
+ hook_event_name: z19.literal("BeforeModel"),
4998
5214
  llm_request: geminiLlmRequestSchema
4999
5215
  });
5000
5216
  var afterModelInputSchema = baseHookInputSchema.extend({
5001
- hook_event_name: z18.literal("AfterModel"),
5217
+ hook_event_name: z19.literal("AfterModel"),
5002
5218
  llm_request: geminiLlmRequestSchema,
5003
5219
  llm_response: geminiLlmResponseSchema
5004
5220
  });
5005
5221
  var beforeToolSelectionInputSchema = baseHookInputSchema.extend({
5006
- hook_event_name: z18.literal("BeforeToolSelection"),
5222
+ hook_event_name: z19.literal("BeforeToolSelection"),
5007
5223
  llm_request: geminiLlmRequestSchema
5008
5224
  });
5009
5225
  var beforeToolInputSchema = baseHookInputSchema.extend({
5010
- hook_event_name: z18.literal("BeforeTool"),
5011
- tool_name: z18.string().min(1),
5012
- tool_input: z18.unknown().optional(),
5226
+ hook_event_name: z19.literal("BeforeTool"),
5227
+ tool_name: z19.string().min(1),
5228
+ tool_input: z19.unknown().optional(),
5013
5229
  mcp_context: geminiMcpContextSchema.optional(),
5014
- original_request_name: z18.string().min(1).optional()
5230
+ original_request_name: z19.string().min(1).optional()
5015
5231
  });
5016
5232
  var afterToolInputSchema = baseHookInputSchema.extend({
5017
- hook_event_name: z18.literal("AfterTool"),
5018
- tool_name: z18.string().min(1),
5019
- tool_input: z18.unknown().optional(),
5233
+ hook_event_name: z19.literal("AfterTool"),
5234
+ tool_name: z19.string().min(1),
5235
+ tool_input: z19.unknown().optional(),
5020
5236
  tool_response: geminiToolResponseSchema.optional(),
5021
5237
  mcp_context: geminiMcpContextSchema.optional(),
5022
- original_request_name: z18.string().min(1).optional()
5238
+ original_request_name: z19.string().min(1).optional()
5023
5239
  });
5024
5240
  var preCompressInputSchema = baseHookInputSchema.extend({
5025
- hook_event_name: z18.literal("PreCompress"),
5026
- trigger: z18.enum(["auto", "manual"]).optional()
5241
+ hook_event_name: z19.literal("PreCompress"),
5242
+ trigger: z19.enum(["auto", "manual"]).optional()
5027
5243
  });
5028
5244
  var notificationInputSchema = baseHookInputSchema.extend({
5029
- hook_event_name: z18.literal("Notification"),
5030
- notification_type: z18.string().optional(),
5031
- message: z18.string().optional(),
5032
- details: z18.unknown().optional()
5245
+ hook_event_name: z19.literal("Notification"),
5246
+ notification_type: z19.string().optional(),
5247
+ message: z19.string().optional(),
5248
+ details: z19.unknown().optional()
5033
5249
  });
5034
- var geminiHookInputSchema = z18.discriminatedUnion("hook_event_name", [
5250
+ var geminiHookInputSchema = z19.discriminatedUnion("hook_event_name", [
5035
5251
  sessionStartInputSchema,
5036
5252
  sessionEndInputSchema,
5037
5253
  beforeAgentInputSchema,
@@ -5476,7 +5692,7 @@ var normalizeUsageOrWarn = (usage, warnings) => {
5476
5692
  };
5477
5693
 
5478
5694
  // src/providers/antigravity/payload.ts
5479
- import { z as z19 } from "zod";
5695
+ import { z as z20 } from "zod";
5480
5696
  var ANTIGRAVITY_HOOK_EVENT_NAMES = [
5481
5697
  "PreInvocation",
5482
5698
  "PostInvocation",
@@ -5484,48 +5700,48 @@ var ANTIGRAVITY_HOOK_EVENT_NAMES = [
5484
5700
  "PostToolUse",
5485
5701
  "Stop"
5486
5702
  ];
5487
- var hookEventNameSchema = z19.enum(ANTIGRAVITY_HOOK_EVENT_NAMES);
5488
- var antigravityWeakShapeSchema = z19.object({ hookEventName: hookEventNameSchema }).passthrough();
5703
+ var hookEventNameSchema = z20.enum(ANTIGRAVITY_HOOK_EVENT_NAMES);
5704
+ var antigravityWeakShapeSchema = z20.object({ hookEventName: hookEventNameSchema }).passthrough();
5489
5705
  var commonFields2 = {
5490
- conversationId: z19.string().min(1),
5491
- workspacePaths: z19.array(z19.string().min(1)).max(64),
5492
- invocationNum: z19.number().int().min(0),
5706
+ conversationId: z20.string().min(1),
5707
+ workspacePaths: z20.array(z20.string().min(1)).max(64),
5708
+ invocationNum: z20.number().int().min(0),
5493
5709
  /** Never disclosed: a real filesystem path. Accepted, never propagated. */
5494
- transcriptPath: z19.string().min(1).optional(),
5710
+ transcriptPath: z20.string().min(1).optional(),
5495
5711
  /** Never disclosed: a real filesystem path. Accepted, never propagated. */
5496
- artifactDirectoryPath: z19.string().min(1).optional()
5712
+ artifactDirectoryPath: z20.string().min(1).optional()
5497
5713
  };
5498
- var preInvocationPayloadSchema = z19.object({
5499
- hookEventName: z19.literal("PreInvocation"),
5714
+ var preInvocationPayloadSchema = z20.object({
5715
+ hookEventName: z20.literal("PreInvocation"),
5500
5716
  ...commonFields2,
5501
- agentVersion: z19.string().min(1).optional()
5717
+ agentVersion: z20.string().min(1).optional()
5502
5718
  });
5503
- var postInvocationPayloadSchema = z19.object({
5504
- hookEventName: z19.literal("PostInvocation"),
5719
+ var postInvocationPayloadSchema = z20.object({
5720
+ hookEventName: z20.literal("PostInvocation"),
5505
5721
  ...commonFields2,
5506
- agentVersion: z19.string().min(1).optional()
5722
+ agentVersion: z20.string().min(1).optional()
5507
5723
  });
5508
- var preToolUsePayloadSchema3 = z19.object({
5509
- hookEventName: z19.literal("PreToolUse"),
5724
+ var preToolUsePayloadSchema3 = z20.object({
5725
+ hookEventName: z20.literal("PreToolUse"),
5510
5726
  ...commonFields2,
5511
- stepIdx: z19.number().int().min(0),
5512
- toolName: z19.string().min(1),
5513
- toolInput: z19.unknown().optional()
5727
+ stepIdx: z20.number().int().min(0),
5728
+ toolName: z20.string().min(1),
5729
+ toolInput: z20.unknown().optional()
5514
5730
  });
5515
- var postToolUsePayloadSchema3 = z19.object({
5516
- hookEventName: z19.literal("PostToolUse"),
5731
+ var postToolUsePayloadSchema3 = z20.object({
5732
+ hookEventName: z20.literal("PostToolUse"),
5517
5733
  ...commonFields2,
5518
- stepIdx: z19.number().int().min(0),
5519
- toolName: z19.string().min(1),
5520
- toolResponse: z19.unknown().optional(),
5521
- isError: z19.boolean().optional()
5734
+ stepIdx: z20.number().int().min(0),
5735
+ toolName: z20.string().min(1),
5736
+ toolResponse: z20.unknown().optional(),
5737
+ isError: z20.boolean().optional()
5522
5738
  });
5523
- var stopPayloadSchema3 = z19.object({
5524
- hookEventName: z19.literal("Stop"),
5739
+ var stopPayloadSchema3 = z20.object({
5740
+ hookEventName: z20.literal("Stop"),
5525
5741
  ...commonFields2,
5526
- fullyIdle: z19.boolean()
5742
+ fullyIdle: z20.boolean()
5527
5743
  });
5528
- var antigravityHookPayloadSchema = z19.discriminatedUnion("hookEventName", [
5744
+ var antigravityHookPayloadSchema = z20.discriminatedUnion("hookEventName", [
5529
5745
  preInvocationPayloadSchema,
5530
5746
  postInvocationPayloadSchema,
5531
5747
  preToolUsePayloadSchema3,
@@ -5839,15 +6055,15 @@ var describeProviderCatalog = (options = {}) => {
5839
6055
  };
5840
6056
 
5841
6057
  // src/runtime/ports.ts
5842
- import { z as z20 } from "zod";
5843
- var appliedDeliverySchema = z20.strictObject({
5844
- callbackId: z20.string().regex(/^[A-Za-z0-9_-]{1,128}$/),
6058
+ import { z as z21 } from "zod";
6059
+ var appliedDeliverySchema = z21.strictObject({
6060
+ callbackId: z21.string().regex(/^[A-Za-z0-9_-]{1,128}$/),
5845
6061
  /** How many of that delivery's observations are folded in, counted from one. */
5846
- applications: z20.number().int().min(1).max(4096)
6062
+ applications: z21.number().int().min(1).max(4096)
5847
6063
  });
5848
- var stateValueSchema = z20.discriminatedUnion("kind", [
5849
- z20.strictObject({
5850
- kind: z20.literal("usage-cumulative"),
6064
+ var stateValueSchema = z21.discriminatedUnion("kind", [
6065
+ z21.strictObject({
6066
+ kind: z21.literal("usage-cumulative"),
5851
6067
  usage: canonicalUsageSchema,
5852
6068
  /**
5853
6069
  * Optional: absent on every record written before this field existed, which
@@ -5856,22 +6072,22 @@ var stateValueSchema = z20.discriminatedUnion("kind", [
5856
6072
  */
5857
6073
  appliedDelivery: appliedDeliverySchema.optional()
5858
6074
  }),
5859
- z20.strictObject({
5860
- kind: z20.literal("sequence"),
6075
+ z21.strictObject({
6076
+ kind: z21.literal("sequence"),
5861
6077
  next: sequenceNumberSchema
5862
6078
  }),
5863
- z20.strictObject({
5864
- kind: z20.literal("attributes"),
6079
+ z21.strictObject({
6080
+ kind: z21.literal("attributes"),
5865
6081
  attributes: attributesSchema
5866
6082
  })
5867
6083
  ]);
5868
- var stateRecordSchema = z20.strictObject({
6084
+ var stateRecordSchema = z21.strictObject({
5869
6085
  /** Incremented on each write; lets callers detect lost updates. */
5870
- revision: z20.number().int().min(0),
6086
+ revision: z21.number().int().min(0),
5871
6087
  updatedAt: epochMillisSchema,
5872
6088
  value: stateValueSchema
5873
6089
  });
5874
- var logLevelSchema = z20.enum(["silent", "error", "warn", "info", "debug"]);
6090
+ var logLevelSchema = z21.enum(["silent", "error", "warn", "info", "debug"]);
5875
6091
  var LOG_LEVEL_RANK = Object.freeze({
5876
6092
  silent: 0,
5877
6093
  error: 1,
@@ -6143,7 +6359,97 @@ var resolveDeliveryIdentity = (input) => {
6143
6359
  };
6144
6360
 
6145
6361
  // src/runtime/hook.ts
6146
- import { z as z21 } from "zod";
6362
+ import { z as z22 } from "zod";
6363
+
6364
+ // src/runtime/target-resolution.ts
6365
+ import * as path from "path";
6366
+ var DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS = 50;
6367
+ var absolutePathsOf = (hint) => {
6368
+ const base = hint.baseDirectory !== void 0 && path.isAbsolute(hint.baseDirectory) ? hint.baseDirectory : void 0;
6369
+ const resolved = [];
6370
+ for (const candidate of hint.paths) {
6371
+ if (path.isAbsolute(candidate)) {
6372
+ resolved.push(path.resolve(candidate));
6373
+ } else if (base !== void 0) {
6374
+ resolved.push(path.resolve(base, candidate));
6375
+ } else {
6376
+ return void 0;
6377
+ }
6378
+ }
6379
+ return resolved;
6380
+ };
6381
+ var resolveHint = async (hint, locator, privacy) => {
6382
+ const paths = absolutePathsOf(hint);
6383
+ if (paths === void 0) {
6384
+ return void 0;
6385
+ }
6386
+ const located = await Promise.all(
6387
+ [...new Set(paths)].map((candidate) => locator.locate(candidate))
6388
+ );
6389
+ const [first] = located;
6390
+ if (first === void 0 || located.some((entry) => entry?.root !== first.root)) {
6391
+ return void 0;
6392
+ }
6393
+ const identity = deriveWorkspaceIdentity(
6394
+ privacy,
6395
+ { kind: "git-root", absolutePath: first.root },
6396
+ first.branch === void 0 ? {} : { vcsBranchName: first.branch }
6397
+ );
6398
+ if (identity.keySource !== "git-root") {
6399
+ return void 0;
6400
+ }
6401
+ const repository = first.mainRoot === void 0 ? void 0 : deriveWorkspaceIdentity(privacy, { kind: "git-root", absolutePath: first.mainRoot });
6402
+ const parsed = workspaceTargetSchema.safeParse({
6403
+ workspaceId: identity.workspaceId,
6404
+ ...identity.vcsBranchName === void 0 ? {} : { vcsBranchName: identity.vcsBranchName },
6405
+ source: hint.source,
6406
+ ...repository?.keySource === "git-root" ? { repositoryId: repository.workspaceId } : {},
6407
+ ...first.kind === void 0 ? {} : { worktreeKind: first.kind }
6408
+ });
6409
+ return parsed.success ? parsed.data : void 0;
6410
+ };
6411
+ var resolveEventTargets = async (input) => {
6412
+ const pending = input.events.filter(
6413
+ (event3) => (event3.type === "tool.start" || event3.type === "tool.end") && input.hints.has(event3.eventId)
6414
+ );
6415
+ if (pending.length === 0) {
6416
+ return { events: input.events, resolved: 0, timedOut: false };
6417
+ }
6418
+ const targets = /* @__PURE__ */ new Map();
6419
+ const work = Promise.all(
6420
+ pending.map(async (event3) => {
6421
+ const hint = input.hints.get(event3.eventId);
6422
+ if (hint === void 0) {
6423
+ return;
6424
+ }
6425
+ try {
6426
+ const target = await resolveHint(hint, input.locator, input.privacy);
6427
+ if (target !== void 0) {
6428
+ targets.set(event3.eventId, target);
6429
+ }
6430
+ } catch {
6431
+ }
6432
+ })
6433
+ ).then(() => "done");
6434
+ let timer;
6435
+ const deadline = new Promise((resolve5) => {
6436
+ timer = setTimeout(() => resolve5("timeout"), Math.max(0, input.budgetMillis));
6437
+ timer.unref?.();
6438
+ });
6439
+ const finished = await Promise.race([work, deadline]);
6440
+ if (timer !== void 0) {
6441
+ clearTimeout(timer);
6442
+ }
6443
+ const settled = new Map(targets);
6444
+ const events = input.events.map((event3) => {
6445
+ const target = settled.get(event3.eventId);
6446
+ if (target === void 0 || event3.type !== "tool.start" && event3.type !== "tool.end") {
6447
+ return event3;
6448
+ }
6449
+ return { ...event3, target };
6450
+ });
6451
+ return { events, resolved: settled.size, timedOut: finished === "timeout" };
6452
+ };
6147
6453
 
6148
6454
  // src/state/async-lock.ts
6149
6455
  var LockWaitTimeoutError = class extends Error {
@@ -6225,7 +6531,7 @@ var withOptionalSessionLock = async (store, sessionId, fn, options) => {
6225
6531
  };
6226
6532
 
6227
6533
  // src/runtime/hook.ts
6228
- var usageScopeSchema = z21.enum(["session", "generation", "subagent"]);
6534
+ var usageScopeSchema = z22.enum(["session", "generation", "subagent"]);
6229
6535
  var classifyDurability = (input) => {
6230
6536
  if (!input.attempted) {
6231
6537
  return "nothing-to-deliver";
@@ -6764,7 +7070,12 @@ var createOtelHook = (deps) => {
6764
7070
  );
6765
7071
  }
6766
7072
  }
6767
- return { kind: "ready", batch: batch2, dropped: screened.dropped };
7073
+ return {
7074
+ kind: "ready",
7075
+ batch: batch2,
7076
+ dropped: screened.dropped,
7077
+ ...parsed.targetHints === void 0 ? {} : { targetHints: parsed.targetHints }
7078
+ };
6768
7079
  };
6769
7080
  let prepared;
6770
7081
  try {
@@ -6809,7 +7120,24 @@ var createOtelHook = (deps) => {
6809
7120
  if (prepared.kind === "early") {
6810
7121
  return prepared.outcome;
6811
7122
  }
6812
- const { batch, dropped } = prepared;
7123
+ const { dropped } = prepared;
7124
+ let batch = prepared.batch;
7125
+ if (!suppress && deps.worktreeLocator !== void 0 && prepared.targetHints !== void 0 && prepared.targetHints.size > 0) {
7126
+ const targeted = await resolveEventTargets({
7127
+ events: batch,
7128
+ hints: prepared.targetHints,
7129
+ locator: deps.worktreeLocator,
7130
+ privacy,
7131
+ budgetMillis: deps.targetResolutionBudgetMillis ?? DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS
7132
+ });
7133
+ batch = targeted.events;
7134
+ if (targeted.timedOut) {
7135
+ logger.debug("worktree target resolution exceeded its budget", {
7136
+ "provider.id": detection.providerId,
7137
+ "target.resolved": targeted.resolved
7138
+ });
7139
+ }
7140
+ }
6813
7141
  let emitted = 0;
6814
7142
  let exportRejected = 0;
6815
7143
  if (!suppress && batch.length > 0) {
@@ -6958,6 +7286,149 @@ var buildErrorEvents = (diagnostics, identity, sequenceBase, ids, privacy) => {
6958
7286
  return events;
6959
7287
  };
6960
7288
 
7289
+ // src/runtime/git-worktree.ts
7290
+ import { lstat, open, stat } from "fs/promises";
7291
+ import * as path2 from "path";
7292
+ var MAX_WORKTREE_WALK_DEPTH = 128;
7293
+ var MAX_GIT_FILE_BYTES = 4096;
7294
+ var MAX_CACHE_ENTRIES = 1024;
7295
+ var DEFAULT_WORKTREE_CACHE_TTL_MILLIS = 5e3;
7296
+ var MAX_BRANCH_NAME_LENGTH = 255;
7297
+ var ABSENT = Object.freeze({ kind: "absent" });
7298
+ var INVALID = Object.freeze({ kind: "invalid" });
7299
+ var readBounded = async (filePath) => {
7300
+ let handle;
7301
+ try {
7302
+ handle = await open(filePath, "r");
7303
+ const buffer = Buffer.alloc(MAX_GIT_FILE_BYTES);
7304
+ const { bytesRead } = await handle.read(buffer, 0, MAX_GIT_FILE_BYTES, 0);
7305
+ return buffer.subarray(0, bytesRead).toString("utf8");
7306
+ } catch {
7307
+ return void 0;
7308
+ } finally {
7309
+ await handle?.close().catch(() => void 0);
7310
+ }
7311
+ };
7312
+ var parseHeadBranch = (head) => {
7313
+ const line = head.split(/\r?\n/, 1)[0]?.trim() ?? "";
7314
+ const match = /^ref:\s*refs\/heads\/(.+)$/.exec(line);
7315
+ const branch = match?.[1];
7316
+ if (branch === void 0 || branch.length === 0 || branch.length > MAX_BRANCH_NAME_LENGTH || // git forbids these in ref names; their presence means this is not one.
7317
+ [...branch].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127) || /[ ~^:?*[\\]/.test(branch)) {
7318
+ return void 0;
7319
+ }
7320
+ return branch;
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);
7324
+ var parseGitDirFile = (content, worktreeRoot) => {
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" };
7353
+ }
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 } };
7357
+ };
7358
+ var probeDirectory = async (directory) => {
7359
+ const dotGit = path2.join(directory, ".git");
7360
+ let info;
7361
+ try {
7362
+ info = await stat(dotGit);
7363
+ } catch {
7364
+ return ABSENT;
7365
+ }
7366
+ let gitDir;
7367
+ if (info.isDirectory()) {
7368
+ gitDir = dotGit;
7369
+ } else if (info.isFile()) {
7370
+ const content = await readBounded(dotGit);
7371
+ gitDir = content === void 0 ? void 0 : parseGitDirFile(content, directory);
7372
+ }
7373
+ if (gitDir === void 0) {
7374
+ return INVALID;
7375
+ }
7376
+ const head = await readBounded(path2.join(gitDir, "HEAD"));
7377
+ if (head === void 0) {
7378
+ return INVALID;
7379
+ }
7380
+ const branch = parseHeadBranch(head);
7381
+ const repository = info.isDirectory() ? { kind: "main", mainRoot: directory } : await repositoryOf(directory, gitDir);
7382
+ return {
7383
+ kind: "worktree",
7384
+ located: { root: directory, ...branch === void 0 ? {} : { branch }, ...repository }
7385
+ };
7386
+ };
7387
+ var createFilesystemWorktreeLocator = (options = {}) => {
7388
+ const now = options.monotonicMillis ?? (() => performance.now());
7389
+ const ttl = options.cacheTtlMillis ?? DEFAULT_WORKTREE_CACHE_TTL_MILLIS;
7390
+ const cache = /* @__PURE__ */ new Map();
7391
+ const cachedProbe = (directory) => {
7392
+ const hit = cache.get(directory);
7393
+ const at = now();
7394
+ if (hit !== void 0 && at - hit.at <= ttl) {
7395
+ return hit.probe;
7396
+ }
7397
+ if (cache.size >= MAX_CACHE_ENTRIES) {
7398
+ cache.clear();
7399
+ }
7400
+ const probe = probeDirectory(directory).catch(() => INVALID);
7401
+ cache.set(directory, { at, probe });
7402
+ return probe;
7403
+ };
7404
+ const locate = async (absolutePath) => {
7405
+ try {
7406
+ if (!path2.isAbsolute(absolutePath) || absolutePath.includes("\0")) {
7407
+ return void 0;
7408
+ }
7409
+ let directory = path2.resolve(absolutePath);
7410
+ for (let depth = 0; depth < MAX_WORKTREE_WALK_DEPTH; depth += 1) {
7411
+ const probe = await cachedProbe(directory);
7412
+ if (probe.kind === "worktree") {
7413
+ return probe.located;
7414
+ }
7415
+ if (probe.kind === "invalid") {
7416
+ return void 0;
7417
+ }
7418
+ const parent = path2.dirname(directory);
7419
+ if (parent === directory) {
7420
+ return void 0;
7421
+ }
7422
+ directory = parent;
7423
+ }
7424
+ return void 0;
7425
+ } catch {
7426
+ return void 0;
7427
+ }
7428
+ };
7429
+ return { locate };
7430
+ };
7431
+
6961
7432
  // src/lifecycle/dedup.ts
6962
7433
  import { randomBytes } from "crypto";
6963
7434
 
@@ -7193,7 +7664,7 @@ import {
7193
7664
  } from "@opentelemetry/semantic-conventions/incubating";
7194
7665
 
7195
7666
  // src/version.ts
7196
- var VERSION = "0.3.0";
7667
+ var VERSION = "0.5.0";
7197
7668
 
7198
7669
  // src/telemetry/export-identity.ts
7199
7670
  import { ATTR_SESSION_ID } from "@opentelemetry/semantic-conventions/incubating";
@@ -7209,6 +7680,27 @@ var ATTR_OTELHOOK_PROVIDER_ID = "otelhook.provider.id";
7209
7680
  var ATTR_OTELHOOK_PROVIDER_VERSION = "otelhook.provider.version";
7210
7681
  var ATTR_OTELHOOK_WORKSPACE_ID = "otelhook.workspace.id";
7211
7682
  var HAR_SESSION_KEY = "har.session_key";
7683
+ var ATTR_OTELHOOK_SUBAGENT_ID = "otelhook.subagent.id";
7684
+ var ATTR_VCS_REF_HEAD_NAME = "vcs.ref.head.name";
7685
+ var ATTR_OTELHOOK_TARGET_WORKSPACE_ID = "otelhook.target.workspace.id";
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";
7689
+ var ATTR_OTELHOOK_USAGE_TEMPORALITY = "otelhook.usage.temporality";
7690
+ var targetAttributes = (event3) => {
7691
+ if (event3.type !== "tool.start" && event3.type !== "tool.end" || event3.target === void 0) {
7692
+ return {};
7693
+ }
7694
+ const { target } = event3;
7695
+ return {
7696
+ [ATTR_OTELHOOK_TARGET_WORKSPACE_ID]: target.workspaceId,
7697
+ [ATTR_OTELHOOK_TARGET_SOURCE]: target.source,
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 }
7701
+ };
7702
+ };
7703
+ var usageTemporalityAttributes = (usage) => usage === void 0 ? {} : { [ATTR_OTELHOOK_USAGE_TEMPORALITY]: usage.temporality };
7212
7704
  var isPrimitiveAttribute = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean";
7213
7705
  var passthroughHarAttributes = (resource) => {
7214
7706
  const attributes = {};
@@ -7244,6 +7736,7 @@ var exportIdentityAttributes = (event3, resource, ids) => {
7244
7736
  [ATTR_OTELHOOK_PROVIDER_ID]: event3.provenance.providerId,
7245
7737
  ...event3.provenance.providerVersion === void 0 ? {} : { [ATTR_OTELHOOK_PROVIDER_VERSION]: event3.provenance.providerVersion },
7246
7738
  [ATTR_OTELHOOK_WORKSPACE_ID]: event3.workspace.workspaceId,
7739
+ ...event3.subagentId === void 0 ? {} : { [ATTR_OTELHOOK_SUBAGENT_ID]: event3.subagentId },
7247
7740
  ...passthroughHarAttributes(resource),
7248
7741
  ...hexTraceAttributes(ids)
7249
7742
  };
@@ -7265,6 +7758,7 @@ var ATTR_OTELHOOK_DELEGATION_DEPTH = "otelhook.delegation_depth";
7265
7758
  var ATTR_OTELHOOK_COMPACTION_TRIGGER = "otelhook.compaction.trigger";
7266
7759
  var ATTR_OTELHOOK_AGENT_NAME = "otelhook.agent.name";
7267
7760
  var ATTR_OTELHOOK_AGENT_VERSION = "otelhook.agent.version";
7761
+ var ATTR_OTELHOOK_GENERATION_ID = "otelhook.generation.id";
7268
7762
  var FIELD_SEPARATOR = "\0";
7269
7763
  var digestHex = (parts, length) => createHash3("sha256").update(parts.join(FIELD_SEPARATOR)).digest("hex").slice(0, length);
7270
7764
  var MAX_RECOVERED_START_ATTRIBUTES = 16;
@@ -7331,8 +7825,10 @@ var startOnlySpanAttributes = (event3) => {
7331
7825
  };
7332
7826
  // `toolName` and `toolCallId` are on both tool edges, so they are not
7333
7827
  // start-only and persisting them would just pad every record.
7828
+ // The target is carried forward too: an end-only process may see a payload
7829
+ // with less to go on (no tool input), and the start's evidence still holds.
7334
7830
  case "tool.start":
7335
- return { [ATTR_OTELHOOK_TOOL_KIND]: event3.toolKind };
7831
+ return { [ATTR_OTELHOOK_TOOL_KIND]: event3.toolKind, ...targetAttributes(event3) };
7336
7832
  case "subagent.start":
7337
7833
  return { [ATTR_OTELHOOK_DELEGATION_DEPTH]: event3.delegationDepth };
7338
7834
  default:
@@ -7363,9 +7859,54 @@ var usageAttributes = (usage, resetDetected) => {
7363
7859
  [ATTR_GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS]: usage.cachedInputTokens,
7364
7860
  [ATTR_GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS]: usage.cacheCreationInputTokens,
7365
7861
  [ATTR_GEN_AI_USAGE_REASONING_OUTPUT_TOKENS]: usage.reasoningOutputTokens,
7862
+ ...usageTemporalityAttributes(usage),
7366
7863
  ...resetDetected ? { [ATTR_OTELHOOK_RESET_DETECTED]: true } : {}
7367
7864
  };
7368
7865
  };
7866
+ var TARGET_SOURCE_RANK = Object.freeze({
7867
+ "tool-path": 3,
7868
+ "shell-cwd": 2,
7869
+ "session-cwd": 1
7870
+ });
7871
+ var TARGET_KEYS = [
7872
+ ATTR_OTELHOOK_TARGET_WORKSPACE_ID,
7873
+ ATTR_OTELHOOK_TARGET_SOURCE,
7874
+ ATTR_VCS_REF_HEAD_NAME,
7875
+ ATTR_OTELHOOK_TARGET_REPOSITORY_ID,
7876
+ ATTR_OTELHOOK_TARGET_WORKTREE_KIND
7877
+ ];
7878
+ var pickTarget = (attributes) => {
7879
+ const picked = {};
7880
+ for (const key of TARGET_KEYS) {
7881
+ if (attributes[key] !== void 0) {
7882
+ picked[key] = attributes[key];
7883
+ }
7884
+ }
7885
+ return picked;
7886
+ };
7887
+ var withoutTarget = (attributes) => {
7888
+ const rest = { ...attributes };
7889
+ for (const key of TARGET_KEYS) {
7890
+ delete rest[key];
7891
+ }
7892
+ return rest;
7893
+ };
7894
+ var rankOf = (candidate) => {
7895
+ const source = candidate[ATTR_OTELHOOK_TARGET_SOURCE];
7896
+ return typeof source === "string" && Object.hasOwn(TARGET_SOURCE_RANK, source) ? TARGET_SOURCE_RANK[source] ?? 0 : 0;
7897
+ };
7898
+ var strongestTarget = (candidates) => {
7899
+ let best = {};
7900
+ let bestRank = 0;
7901
+ for (const candidate of candidates) {
7902
+ const rank = rankOf(candidate);
7903
+ if (rank > 0 && rank >= bestRank) {
7904
+ best = candidate;
7905
+ bestRank = rank;
7906
+ }
7907
+ }
7908
+ return best;
7909
+ };
7369
7910
  var buildSpanContext = (traceId, spanId) => ({
7370
7911
  traceId,
7371
7912
  spanId,
@@ -7476,6 +8017,9 @@ var buildLifecycleSpan = (plan, resource, scope) => {
7476
8017
  ...model?.vendor === void 0 ? {} : { [ATTR_GEN_AI_SYSTEM]: model.vendor },
7477
8018
  ...start?.model?.modelId === void 0 ? {} : { [ATTR_GEN_AI_REQUEST_MODEL]: start.model.modelId },
7478
8019
  ...end?.model?.modelId === void 0 ? {} : { [ATTR_GEN_AI_RESPONSE_MODEL]: end.model.modelId },
8020
+ // The provider's own id for this unit of work (Cursor generation,
8021
+ // Codex turn): the key a consumer stores a usage observation under.
8022
+ [ATTR_OTELHOOK_GENERATION_ID]: group.ref.scopeKey,
7479
8023
  ...end?.outcome === void 0 ? {} : { [ATTR_OTELHOOK_OUTCOME]: end.outcome },
7480
8024
  ...usageAttributes(end?.usage, false)
7481
8025
  };
@@ -7489,11 +8033,17 @@ var buildLifecycleSpan = (plan, resource, scope) => {
7489
8033
  name = `tool ${toolName}`;
7490
8034
  kind = SpanKind.CLIENT;
7491
8035
  attributes = {
7492
- ...attributes,
8036
+ // Target keys are re-chosen below as one unit, never mixed across edges.
8037
+ ...withoutTarget(attributes),
7493
8038
  [ATTR_GEN_AI_TOOL_NAME]: toolName,
7494
8039
  [ATTR_GEN_AI_TOOL_CALL_ID]: start?.toolCallId ?? end?.toolCallId ?? group.ref.scopeKey,
7495
8040
  ...start?.toolKind === void 0 ? {} : { [ATTR_OTELHOOK_TOOL_KIND]: start.toolKind },
7496
- ...end?.outcome === void 0 ? {} : { [ATTR_OTELHOOK_OUTCOME]: end.outcome }
8041
+ ...end?.outcome === void 0 ? {} : { [ATTR_OTELHOOK_OUTCOME]: end.outcome },
8042
+ ...strongestTarget([
8043
+ pickTarget(resolved.recovered),
8044
+ start === void 0 ? {} : targetAttributes(start),
8045
+ end === void 0 ? {} : targetAttributes(end)
8046
+ ])
7497
8047
  };
7498
8048
  status = outcomeStatus(end?.outcome);
7499
8049
  break;
@@ -8324,8 +8874,8 @@ var createBoundedMemoryStateStore = (options) => {
8324
8874
 
8325
8875
  // src/state/filesystem-store.ts
8326
8876
  import { randomBytes as randomBytes2 } from "crypto";
8327
- import { mkdir, open, readFile, readdir, rename, unlink, writeFile } from "fs/promises";
8328
- import * as path from "path";
8877
+ import { mkdir, open as open2, readFile, readdir, rename, unlink, writeFile } from "fs/promises";
8878
+ import * as path3 from "path";
8329
8879
 
8330
8880
  // src/state/keys.ts
8331
8881
  import { createHash as createHash4 } from "crypto";
@@ -8345,8 +8895,8 @@ var keyDigest = (key) => createHash4("sha256").update(key, "utf8").digest("hex")
8345
8895
 
8346
8896
  // src/state/filesystem-store.ts
8347
8897
  var isErrnoException = (thrown, code) => thrown instanceof Error && thrown.code === code;
8348
- var sleep = (millis) => new Promise((resolve3) => {
8349
- const timer = setTimeout(resolve3, millis);
8898
+ var sleep = (millis) => new Promise((resolve5) => {
8899
+ const timer = setTimeout(resolve5, millis);
8350
8900
  timer.unref?.();
8351
8901
  });
8352
8902
  var wrapFsError = (thrown, operation) => {
@@ -8357,10 +8907,10 @@ var wrapFsError = (thrown, operation) => {
8357
8907
  };
8358
8908
  var createFilesystemStateStore = (options) => {
8359
8909
  const [providerSegment, installationSegment] = namespaceSegments(options);
8360
- const baseDir = path.join(options.rootDir, providerSegment, installationSegment);
8361
- const recordsDir = path.join(baseDir, "records");
8362
- const quarantineDir = path.join(baseDir, "quarantine");
8363
- const locksDir = path.join(baseDir, "locks");
8910
+ const baseDir = path3.join(options.rootDir, providerSegment, installationSegment);
8911
+ const recordsDir = path3.join(baseDir, "records");
8912
+ const quarantineDir = path3.join(baseDir, "quarantine");
8913
+ const locksDir = path3.join(baseDir, "locks");
8364
8914
  const lockTimeoutMillis = options.lockTimeoutMillis ?? 5e3;
8365
8915
  const lockStaleMillis = options.lockStaleMillis ?? 3e4;
8366
8916
  const lockPollIntervalMillis = options.lockPollIntervalMillis ?? 25;
@@ -8384,11 +8934,11 @@ var createFilesystemStateStore = (options) => {
8384
8934
  throw wrapFsError(thrown, "ensure-dirs");
8385
8935
  }
8386
8936
  };
8387
- const recordPath = (key) => path.join(recordsDir, `${keyDigest(key)}.json`);
8388
- const tempPath = (key) => path.join(recordsDir, `.tmp-${keyDigest(key)}-${randomBytes2(6).toString("hex")}.json`);
8389
- const lockPath = (sessionId) => path.join(locksDir, `${sanitizeSegment(sessionId)}.lock`);
8937
+ const recordPath = (key) => path3.join(recordsDir, `${keyDigest(key)}.json`);
8938
+ const tempPath = (key) => path3.join(recordsDir, `.tmp-${keyDigest(key)}-${randomBytes2(6).toString("hex")}.json`);
8939
+ const lockPath = (sessionId) => path3.join(locksDir, `${sanitizeSegment(sessionId)}.lock`);
8390
8940
  const quarantine = async (filePath, key, reason) => {
8391
- const dest = path.join(quarantineDir, `${options.clock.now()}-${keyDigest(key)}-${reason}.json`);
8941
+ const dest = path3.join(quarantineDir, `${options.clock.now()}-${keyDigest(key)}-${reason}.json`);
8392
8942
  try {
8393
8943
  await rename(filePath, dest);
8394
8944
  } catch {
@@ -8452,7 +9002,7 @@ var createFilesystemStateStore = (options) => {
8452
9002
  const startedAt = options.clock.monotonicMillis();
8453
9003
  for (; ; ) {
8454
9004
  try {
8455
- const handle = await open(filePath, "wx");
9005
+ const handle = await open2(filePath, "wx");
8456
9006
  try {
8457
9007
  await handle.writeFile(JSON.stringify({ pid: process.pid, acquiredAt: options.clock.now() }));
8458
9008
  } finally {
@@ -8520,7 +9070,7 @@ var createFilesystemStateStore = (options) => {
8520
9070
  }
8521
9071
  let raw;
8522
9072
  try {
8523
- raw = await readFile(path.join(recordsDir, entry), "utf8");
9073
+ raw = await readFile(path3.join(recordsDir, entry), "utf8");
8524
9074
  } catch {
8525
9075
  continue;
8526
9076
  }
@@ -8573,7 +9123,7 @@ var createFilesystemStateStore = (options) => {
8573
9123
  continue;
8574
9124
  }
8575
9125
  scanned += 1;
8576
- const filePath = path.join(recordsDir, entry);
9126
+ const filePath = path3.join(recordsDir, entry);
8577
9127
  try {
8578
9128
  const raw = await readFile(filePath, "utf8");
8579
9129
  const envelope = JSON.parse(raw);
@@ -8593,7 +9143,7 @@ var createFilesystemStateStore = (options) => {
8593
9143
  lockEntries = [];
8594
9144
  }
8595
9145
  for (const entry of lockEntries) {
8596
- const filePath = path.join(locksDir, entry);
9146
+ const filePath = path3.join(locksDir, entry);
8597
9147
  try {
8598
9148
  const raw = await readFile(filePath, "utf8");
8599
9149
  const parsed = JSON.parse(raw);
@@ -8612,13 +9162,13 @@ var createFilesystemStateStore = (options) => {
8612
9162
  // src/telemetry/spool-queue.ts
8613
9163
  import { randomBytes as randomBytes3 } from "crypto";
8614
9164
  import { mkdir as mkdir2, readFile as readFile2, readdir as readdir2, rename as rename2, unlink as unlink2, writeFile as writeFile2 } from "fs/promises";
8615
- import * as path2 from "path";
9165
+ import * as path4 from "path";
8616
9166
  var DEFAULT_DRAIN_MAX_BATCHES = 20;
8617
9167
  var isErrnoException2 = (thrown, code) => thrown instanceof Error && thrown.code === code;
8618
9168
  var createSpoolQueue = (options) => {
8619
9169
  const [providerSegment, installationSegment] = namespaceSegments(options);
8620
- const queueDir = path2.join(options.rootDir, providerSegment, installationSegment, options.queueName);
8621
- const corruptDir = path2.join(
9170
+ const queueDir = path4.join(options.rootDir, providerSegment, installationSegment, options.queueName);
9171
+ const corruptDir = path4.join(
8622
9172
  options.rootDir,
8623
9173
  providerSegment,
8624
9174
  installationSegment,
@@ -8664,8 +9214,8 @@ var createSpoolQueue = (options) => {
8664
9214
  return { spooled: false, reason: "capacity-exceeded" };
8665
9215
  }
8666
9216
  const fileName = `${String(options.clock.now()).padStart(16, "0")}-${randomBytes3(6).toString("hex")}.json`;
8667
- const target = path2.join(queueDir, fileName);
8668
- const tmp = path2.join(queueDir, `.tmp-${randomBytes3(6).toString("hex")}.json`);
9217
+ const target = path4.join(queueDir, fileName);
9218
+ const tmp = path4.join(queueDir, `.tmp-${randomBytes3(6).toString("hex")}.json`);
8669
9219
  await writeFile2(tmp, JSON.stringify(batch), "utf8");
8670
9220
  await rename2(tmp, target);
8671
9221
  return { spooled: true };
@@ -8683,7 +9233,7 @@ var createSpoolQueue = (options) => {
8683
9233
  if (fileName === void 0) {
8684
9234
  break;
8685
9235
  }
8686
- const filePath = path2.join(queueDir, fileName);
9236
+ const filePath = path4.join(queueDir, fileName);
8687
9237
  const quarantine = async (rejection) => {
8688
9238
  quarantined += 1;
8689
9239
  options.logger?.error("durable spool quarantined an unusable batch", {
@@ -8692,7 +9242,7 @@ var createSpoolQueue = (options) => {
8692
9242
  "spool.queue": options.queueName
8693
9243
  });
8694
9244
  try {
8695
- await rename2(filePath, path2.join(corruptDir, fileName));
9245
+ await rename2(filePath, path4.join(corruptDir, fileName));
8696
9246
  } catch {
8697
9247
  await unlink2(filePath).catch(() => void 0);
8698
9248
  }
@@ -8983,8 +9533,8 @@ var createOtlpTraceSink = (options) => {
8983
9533
  timeoutMillis: options.exporter.timeoutMillis
8984
9534
  });
8985
9535
  let shutdownCompleted = false;
8986
- const exportSpans = (spans) => new Promise((resolve3) => {
8987
- exporter.export([...spans], (result) => resolve3(result));
9536
+ const exportSpans = (spans) => new Promise((resolve5) => {
9537
+ exporter.export([...spans], (result) => resolve5(result));
8988
9538
  });
8989
9539
  const toSpoolBatch = (spans) => ({
8990
9540
  providerId: options.providerId,
@@ -9146,7 +9696,7 @@ var ATTR_OTELHOOK_AGENT_VERSION2 = "otelhook.agent.version";
9146
9696
  var ATTR_OTELHOOK_SESSION_KIND = "otelhook.session.kind";
9147
9697
  var ATTR_OTELHOOK_PROMPT_SOURCE = "otelhook.prompt.source";
9148
9698
  var ATTR_OTELHOOK_PROMPT_TURN_INDEX = "otelhook.prompt.turn_index";
9149
- var ATTR_OTELHOOK_GENERATION_ID = "otelhook.generation.id";
9699
+ var ATTR_OTELHOOK_GENERATION_ID2 = "otelhook.generation.id";
9150
9700
  var ATTR_OTELHOOK_STOP_REASON = "otelhook.generation.stop_reason";
9151
9701
  var ATTR_OTELHOOK_COMPACTION_TRIGGER2 = "otelhook.compaction.trigger";
9152
9702
  var ATTR_OTELHOOK_CONTEXT_TOKENS_BEFORE = "otelhook.compaction.context_tokens_before";
@@ -9305,14 +9855,14 @@ var eventAttributes = (event3) => {
9305
9855
  case "generation.start":
9306
9856
  return {
9307
9857
  [ATTR_GEN_AI_OPERATION_NAME2]: "chat",
9308
- [ATTR_OTELHOOK_GENERATION_ID]: event3.generationId,
9858
+ [ATTR_OTELHOOK_GENERATION_ID2]: event3.generationId,
9309
9859
  [ATTR_GEN_AI_REQUEST_MODEL2]: event3.model.modelId,
9310
9860
  ...event3.model.vendor === void 0 ? {} : { [ATTR_GEN_AI_SYSTEM2]: event3.model.vendor }
9311
9861
  };
9312
9862
  case "generation.end":
9313
9863
  return {
9314
9864
  [ATTR_GEN_AI_OPERATION_NAME2]: "chat",
9315
- [ATTR_OTELHOOK_GENERATION_ID]: event3.generationId,
9865
+ [ATTR_OTELHOOK_GENERATION_ID2]: event3.generationId,
9316
9866
  [ATTR_GEN_AI_RESPONSE_MODEL2]: event3.model.modelId,
9317
9867
  ...event3.model.vendor === void 0 ? {} : { [ATTR_GEN_AI_SYSTEM2]: event3.model.vendor },
9318
9868
  [ATTR_OTELHOOK_OUTCOME2]: event3.outcome,
@@ -9324,14 +9874,16 @@ var eventAttributes = (event3) => {
9324
9874
  [ATTR_GEN_AI_TOOL_NAME2]: event3.toolName,
9325
9875
  [ATTR_GEN_AI_TOOL_CALL_ID2]: event3.toolCallId,
9326
9876
  [ATTR_OTELHOOK_TOOL_KIND2]: event3.toolKind,
9327
- ...event3.generationId === void 0 ? {} : { [ATTR_OTELHOOK_GENERATION_ID]: event3.generationId }
9877
+ ...event3.generationId === void 0 ? {} : { [ATTR_OTELHOOK_GENERATION_ID2]: event3.generationId },
9878
+ ...targetAttributes(event3)
9328
9879
  };
9329
9880
  case "tool.end":
9330
9881
  return {
9331
9882
  [ATTR_GEN_AI_TOOL_NAME2]: event3.toolName,
9332
9883
  [ATTR_GEN_AI_TOOL_CALL_ID2]: event3.toolCallId,
9333
9884
  [ATTR_OTELHOOK_OUTCOME2]: event3.outcome,
9334
- ...event3.permissionDecision === void 0 ? {} : { [ATTR_OTELHOOK_TOOL_PERMISSION]: event3.permissionDecision }
9885
+ ...event3.permissionDecision === void 0 ? {} : { [ATTR_OTELHOOK_TOOL_PERMISSION]: event3.permissionDecision },
9886
+ ...targetAttributes(event3)
9335
9887
  };
9336
9888
  case "subagent.start":
9337
9889
  return {
@@ -9365,7 +9917,8 @@ var usageAttributes2 = (usage) => usage === void 0 ? {} : {
9365
9917
  [ATTR_GEN_AI_USAGE_INPUT_TOKENS2]: usage.inputTokens,
9366
9918
  [ATTR_GEN_AI_USAGE_OUTPUT_TOKENS2]: usage.outputTokens,
9367
9919
  [ATTR_GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS2]: usage.cachedInputTokens,
9368
- [ATTR_GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS2]: usage.cacheCreationInputTokens
9920
+ [ATTR_GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS2]: usage.cacheCreationInputTokens,
9921
+ ...usageTemporalityAttributes(usage)
9369
9922
  };
9370
9923
  var contentFactsOf = (event3) => {
9371
9924
  switch (event3.type) {
@@ -9757,8 +10310,8 @@ var createOtlpLogSink = (options) => {
9757
10310
  timeoutMillis: options.exporter.timeoutMillis
9758
10311
  });
9759
10312
  let shutdownCompleted = false;
9760
- const exportRecords = (records) => new Promise((resolve3) => {
9761
- exporter.export([...records], (result) => resolve3(result));
10313
+ const exportRecords = (records) => new Promise((resolve5) => {
10314
+ exporter.export([...records], (result) => resolve5(result));
9762
10315
  });
9763
10316
  const toSpoolBatch = (records) => ({
9764
10317
  providerId: options.providerId,
@@ -9937,8 +10490,8 @@ var DEFAULT_FLUSH_TIMEOUT_MILLIS = 2e3;
9937
10490
  var DEFAULT_STATE_LOCK_TIMEOUT_MILLIS = 1e3;
9938
10491
  var DEFAULT_LIFECYCLE_MAX_AGE_MILLIS = 24 * 60 * 60 * 1e3;
9939
10492
  var DEFAULT_STALE_CLAIM_MILLIS2 = 6e4;
9940
- var delay = (millis) => new Promise((resolve3) => {
9941
- const timer = setTimeout(() => resolve3("timeout"), millis);
10493
+ var delay = (millis) => new Promise((resolve5) => {
10494
+ const timer = setTimeout(() => resolve5("timeout"), millis);
9942
10495
  timer.unref?.();
9943
10496
  });
9944
10497
  var containsSessionEnd = (events) => events.some((event3) => event3.type === "session.end");
@@ -10050,7 +10603,10 @@ var createHookRuntime = (options) => {
10050
10603
  ids,
10051
10604
  privacy,
10052
10605
  logger,
10053
- installationId: options.installationId
10606
+ installationId: options.installationId,
10607
+ ...options.worktreeLocator === null ? {} : {
10608
+ worktreeLocator: options.worktreeLocator ?? createFilesystemWorktreeLocator({ monotonicMillis: () => clock.monotonicMillis() })
10609
+ }
10054
10610
  };
10055
10611
  const hook = createOtelHook({ ...hookDeps, sink });
10056
10612
  const deduplicator = createCallbackDeduplicator({ stateStore, clock });
@@ -10739,7 +11295,7 @@ var CURSOR_UNREGISTERED_HOOK_EVENTS = Object.freeze({
10739
11295
  afterShellExecution: "the same shell call also fires postToolUse, which duplicates this tool end and \u2014 unlike this callback \u2014 carries both a tool_use_id and a success/failure signal",
10740
11296
  beforeMCPExecution: "an MCP call also fires preToolUse/postToolUse, which additionally carry tool_use_id; registering this one duplicates the tool call",
10741
11297
  afterMCPExecution: "the same MCP call also fires postToolUse, which duplicates this tool end and, unlike this callback, reports a success/failure signal",
10742
- beforeReadFile: "no completion callback exists for it, so a tool.start emitted here would never close",
11298
+ beforeReadFile: "an agent read also fires preToolUse/postToolUse, so registering it by default would report one read twice; opt in with --event for its file_path target evidence",
10743
11299
  subagentStart: "subagentStop carries no subagent id to pair with, so no closable delegation lifecycle can be produced",
10744
11300
  subagentStop: "it carries no subagent id, so it cannot be paired with the subagentStart it ends",
10745
11301
  beforeTabFileRead: "a Tab (inline-completion) hook, not an agent-session hook; not modelled by this adapter",
@@ -11179,7 +11735,7 @@ var SUPPORTED_REGISTRATION_PROVIDER_IDS = Object.freeze(
11179
11735
  );
11180
11736
 
11181
11737
  // src/install/scopes.ts
11182
- import * as path3 from "path";
11738
+ import * as path5 from "path";
11183
11739
  var REGISTRATION_SCOPES = Object.freeze([
11184
11740
  "global",
11185
11741
  "project"
@@ -11247,15 +11803,15 @@ var PROVIDERS_WITH_VERIFIED_LOCATION = Object.freeze([
11247
11803
  var findInstallLocation = (providerId, scope) => PROVIDER_INSTALL_LOCATIONS.find(
11248
11804
  (entry) => entry.providerId === providerId && entry.scope === scope
11249
11805
  );
11250
- var resolveInstallPath = (location, roots) => path3.resolve(
11806
+ var resolveInstallPath = (location, roots) => path5.resolve(
11251
11807
  location.scope === "global" ? roots.homeDir : roots.projectDir,
11252
11808
  ...location.segments
11253
11809
  );
11254
11810
 
11255
11811
  // src/install/document.ts
11256
11812
  import { randomBytes as randomBytes4 } from "crypto";
11257
- import { chmod, mkdir as mkdir3, open as open2, readFile as readFile3, rename as rename3, stat, unlink as unlink3 } from "fs/promises";
11258
- import * as path4 from "path";
11813
+ import { chmod, mkdir as mkdir3, open as open3, readFile as readFile3, rename as rename3, stat as stat2, unlink as unlink3 } from "fs/promises";
11814
+ import * as path6 from "path";
11259
11815
  var DEFAULT_DOCUMENT_FORMAT = Object.freeze({
11260
11816
  indent: " ",
11261
11817
  eol: "\n",
@@ -11305,8 +11861,8 @@ var readJsonDocument = async (filePath) => {
11305
11861
  }
11306
11862
  };
11307
11863
  var RENAME_RETRY_DELAYS_MILLIS = [10, 25, 50, 100];
11308
- var delay2 = (millis) => new Promise((resolve3) => {
11309
- setTimeout(resolve3, millis);
11864
+ var delay2 = (millis) => new Promise((resolve5) => {
11865
+ setTimeout(resolve5, millis);
11310
11866
  });
11311
11867
  var renameWithRetry = async (from, to) => {
11312
11868
  for (let attempt = 0; ; attempt += 1) {
@@ -11326,15 +11882,15 @@ var renameWithRetry = async (from, to) => {
11326
11882
  var NEW_DOCUMENT_MODE = 384;
11327
11883
  var TEMPORARY_DOCUMENT_MODE = 384;
11328
11884
  var writeDocumentAtomically = async (filePath, contents) => {
11329
- const directory = path4.dirname(filePath);
11885
+ const directory = path6.dirname(filePath);
11330
11886
  await mkdir3(directory, { recursive: true });
11331
- const temporary = path4.join(
11887
+ const temporary = path6.join(
11332
11888
  directory,
11333
- `.${path4.basename(filePath)}.${randomBytes4(6).toString("hex")}.tmp`
11889
+ `.${path6.basename(filePath)}.${randomBytes4(6).toString("hex")}.tmp`
11334
11890
  );
11335
11891
  let existingMode;
11336
11892
  try {
11337
- existingMode = (await stat(filePath)).mode & 4095;
11893
+ existingMode = (await stat2(filePath)).mode & 4095;
11338
11894
  } catch (thrown) {
11339
11895
  if (!isErrnoException3(thrown, "ENOENT")) {
11340
11896
  throw thrown;
@@ -11342,7 +11898,7 @@ var writeDocumentAtomically = async (filePath, contents) => {
11342
11898
  }
11343
11899
  const targetMode = existingMode ?? NEW_DOCUMENT_MODE;
11344
11900
  try {
11345
- const handle = await open2(temporary, "wx", TEMPORARY_DOCUMENT_MODE);
11901
+ const handle = await open3(temporary, "wx", TEMPORARY_DOCUMENT_MODE);
11346
11902
  try {
11347
11903
  await handle.writeFile(contents, "utf8");
11348
11904
  await handle.sync();
@@ -11359,12 +11915,12 @@ var writeDocumentAtomically = async (filePath, contents) => {
11359
11915
 
11360
11916
  // src/install/file-lock.ts
11361
11917
  import { randomBytes as randomBytes5 } from "crypto";
11362
- import { mkdir as mkdir4, open as open3, readFile as readFile4, rename as rename4, stat as stat2, unlink as unlink4 } from "fs/promises";
11363
- import * as path5 from "path";
11918
+ import { mkdir as mkdir4, open as open4, readFile as readFile4, rename as rename4, stat as stat3, unlink as unlink4 } from "fs/promises";
11919
+ import * as path7 from "path";
11364
11920
  var FileLockTimeoutError = class extends Error {
11365
11921
  constructor(lockPath, timeoutMillis) {
11366
11922
  super(
11367
- `timed out after ${String(timeoutMillis)}ms waiting for the lock on ${path5.basename(lockPath)}`
11923
+ `timed out after ${String(timeoutMillis)}ms waiting for the lock on ${path7.basename(lockPath)}`
11368
11924
  );
11369
11925
  this.name = "FileLockTimeoutError";
11370
11926
  }
@@ -11403,8 +11959,8 @@ var releaseIfOwned = async (lockPath, token) => {
11403
11959
  await unlink4(tombstone).catch(() => void 0);
11404
11960
  return true;
11405
11961
  };
11406
- var delay3 = (millis) => new Promise((resolve3) => {
11407
- setTimeout(resolve3, millis);
11962
+ var delay3 = (millis) => new Promise((resolve5) => {
11963
+ setTimeout(resolve5, millis);
11408
11964
  });
11409
11965
  var isStale = async (lockPath, clock, staleMillis) => {
11410
11966
  let raw;
@@ -11424,7 +11980,7 @@ var isStale = async (lockPath, clock, staleMillis) => {
11424
11980
  } catch {
11425
11981
  }
11426
11982
  try {
11427
- const stats = await stat2(lockPath);
11983
+ const stats = await stat3(lockPath);
11428
11984
  return { stale: clock.now() - stats.mtimeMs > staleMillis };
11429
11985
  } catch (thrown) {
11430
11986
  return { stale: !isErrnoException4(thrown, "ENOENT") };
@@ -11436,12 +11992,12 @@ var withFileLock = async (filePath, options, fn) => {
11436
11992
  const pollIntervalMillis = options.pollIntervalMillis ?? 25;
11437
11993
  const lockPath = lockPathFor(filePath);
11438
11994
  const startedAt = options.clock.monotonicMillis();
11439
- await mkdir4(path5.dirname(filePath), { recursive: true });
11995
+ await mkdir4(path7.dirname(filePath), { recursive: true });
11440
11996
  for (; ; ) {
11441
11997
  const token = randomBytes5(16).toString("hex");
11442
11998
  let acquired = false;
11443
11999
  try {
11444
- const handle = await open3(lockPath, "wx", 384);
12000
+ const handle = await open4(lockPath, "wx", 384);
11445
12001
  try {
11446
12002
  const contents = {
11447
12003
  token,
@@ -11484,7 +12040,7 @@ var withFileLock = async (filePath, options, fn) => {
11484
12040
 
11485
12041
  // src/install/lifecycle.ts
11486
12042
  import { readFile as readFile5 } from "fs/promises";
11487
- import * as path6 from "path";
12043
+ import * as path8 from "path";
11488
12044
  var defaultHookCommand = (providerId) => `otel-hook run --provider ${providerId}`;
11489
12045
  var unsupportedOutcome = (providerId, scope, reason) => ({
11490
12046
  providerId,
@@ -11501,7 +12057,7 @@ var unsupportedOutcome = (providerId, scope, reason) => ({
11501
12057
  var resolveTarget = (providerId, scope, request) => {
11502
12058
  if (request.configFile !== void 0) {
11503
12059
  return {
11504
- configPath: path6.resolve(request.configFile),
12060
+ configPath: path8.resolve(request.configFile),
11505
12061
  evidence: "path supplied by the caller with --settings-file"
11506
12062
  };
11507
12063
  }
@@ -11518,14 +12074,14 @@ var resolveTarget = (providerId, scope, request) => {
11518
12074
  };
11519
12075
  };
11520
12076
  var codexFeatureNote = async (configPath) => {
11521
- const tomlPath = path6.join(path6.dirname(configPath), "config.toml");
12077
+ const tomlPath = path8.join(path8.dirname(configPath), "config.toml");
11522
12078
  let raw;
11523
12079
  try {
11524
12080
  raw = await readFile5(tomlPath, "utf8");
11525
12081
  } catch {
11526
12082
  return void 0;
11527
12083
  }
11528
- return readCodexHooksFeatureFlag(raw) === "disabled" ? `${path6.basename(tomlPath)} sets [features] hooks = false; registered hooks will not fire until that is removed` : void 0;
12084
+ return readCodexHooksFeatureFlag(raw) === "disabled" ? `${path8.basename(tomlPath)} sets [features] hooks = false; registered hooks will not fire until that is removed` : void 0;
11529
12085
  };
11530
12086
  var readState = async (configPath) => {
11531
12087
  const read = await readJsonDocument(configPath);
@@ -11537,12 +12093,12 @@ var readState = async (configPath) => {
11537
12093
  case "unparseable":
11538
12094
  return {
11539
12095
  status: "blocked",
11540
- problem: `${path6.basename(configPath)} is not well-formed JSON (${read.detail}); it was left untouched`
12096
+ problem: `${path8.basename(configPath)} is not well-formed JSON (${read.detail}); it was left untouched`
11541
12097
  };
11542
12098
  case "unreadable":
11543
12099
  return {
11544
12100
  status: "failed",
11545
- problem: `${path6.basename(configPath)} could not be read (${read.detail})`
12101
+ problem: `${path8.basename(configPath)} could not be read (${read.detail})`
11546
12102
  };
11547
12103
  }
11548
12104
  };
@@ -11654,7 +12210,7 @@ var runOneTarget = async (providerId, scope, request, command) => {
11654
12210
  missingEvents: [],
11655
12211
  notes,
11656
12212
  problems: planned.conflicts.map(
11657
- (conflict) => `${path6.basename(configPath)} has an unexpected shape at ${conflict.location}: ${conflict.detail}; it was left untouched`
12213
+ (conflict) => `${path8.basename(configPath)} has an unexpected shape at ${conflict.location}: ${conflict.detail}; it was left untouched`
11658
12214
  )
11659
12215
  };
11660
12216
  }
@@ -11665,7 +12221,7 @@ var runOneTarget = async (providerId, scope, request, command) => {
11665
12221
  changed: false,
11666
12222
  registeredEvents: [],
11667
12223
  missingEvents: [],
11668
- notes: [...notes, `${path6.basename(configPath)} does not exist; nothing to remove`],
12224
+ notes: [...notes, `${path8.basename(configPath)} does not exist; nothing to remove`],
11669
12225
  problems: []
11670
12226
  };
11671
12227
  }
@@ -11708,7 +12264,7 @@ var runOneTarget = async (providerId, scope, request, command) => {
11708
12264
  missingEvents: [],
11709
12265
  notes,
11710
12266
  problems: [
11711
- `could not write ${path6.basename(configPath)} (${thrown instanceof Error ? thrown.name : typeof thrown})`
12267
+ `could not write ${path8.basename(configPath)} (${thrown instanceof Error ? thrown.name : typeof thrown})`
11712
12268
  ]
11713
12269
  };
11714
12270
  }
@@ -11735,7 +12291,7 @@ var runOneTarget = async (providerId, scope, request, command) => {
11735
12291
  missingEvents: [],
11736
12292
  notes,
11737
12293
  problems: [
11738
- thrown instanceof Error ? `${path6.basename(configPath)}: ${thrown.message}` : `${path6.basename(configPath)}: the configuration file could not be locked`
12294
+ thrown instanceof Error ? `${path8.basename(configPath)}: ${thrown.message}` : `${path8.basename(configPath)}: the configuration file could not be locked`
11739
12295
  ]
11740
12296
  };
11741
12297
  }
@@ -11862,6 +12418,8 @@ export {
11862
12418
  DEFAULT_PRIVACY_POLICY,
11863
12419
  DEFAULT_SECRET_KEY_PATTERNS,
11864
12420
  DEFAULT_SECRET_VALUE_PATTERNS,
12421
+ DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS,
12422
+ DEFAULT_WORKTREE_CACHE_TTL_MILLIS,
11865
12423
  DELIVERY_COMPONENT_PATTERN,
11866
12424
  DELIVERY_GAP_REASON_PATTERN,
11867
12425
  DELIVERY_IDENTIFIER_SUMMARY,
@@ -11896,6 +12454,9 @@ export {
11896
12454
  MAX_RESOURCE_ATTRIBUTES,
11897
12455
  MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH,
11898
12456
  MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH,
12457
+ MAX_TARGET_HINT_PATHS,
12458
+ MAX_TARGET_PATH_LENGTH,
12459
+ MAX_WORKTREE_WALK_DEPTH,
11899
12460
  MCP_TOOL_NAME_PATTERN,
11900
12461
  NO_LOG_CONTENT,
11901
12462
  OtelHookError,
@@ -11913,6 +12474,7 @@ export {
11913
12474
  RESOURCE_ATTRIBUTE_KEY_REJECTION_DETAIL,
11914
12475
  SILENT_HOOK_RESPONSE,
11915
12476
  SPAN_RECORD_VERSION,
12477
+ SUBAGENT_ID_PATTERN,
11916
12478
  SUPPORTED_REGISTRATION_PROVIDER_IDS,
11917
12479
  UNKNOWN_PROVIDER_ID,
11918
12480
  UNKNOWN_WORKSPACE_ID,
@@ -11965,6 +12527,7 @@ export {
11965
12527
  createFileDurableLogSpool,
11966
12528
  createFileDurableSpool,
11967
12529
  createFilesystemStateStore,
12530
+ createFilesystemWorktreeLocator,
11968
12531
  createFixedClock,
11969
12532
  createGeminiCliAdapter,
11970
12533
  createHealthTracker,
@@ -12061,7 +12624,10 @@ export {
12061
12624
  otelHookErrorInfoSchema,
12062
12625
  parentScopeRefOf,
12063
12626
  parseCanonicalEvent,
12627
+ parseCommonDirFile,
12064
12628
  parseEnvironmentConfig,
12629
+ parseGitDirFile,
12630
+ parseHeadBranch,
12065
12631
  parseResourceAttributesValue,
12066
12632
  planProviderRegistration,
12067
12633
  privacyLimitsSchema,
@@ -12093,6 +12659,7 @@ export {
12093
12659
  renderJsonDocument,
12094
12660
  resolveConfig,
12095
12661
  resolveDeliveryIdentity,
12662
+ resolveEventTargets,
12096
12663
  resolveInstallPath,
12097
12664
  resolveInvocationIdentity,
12098
12665
  resolveLogsEndpoint,
@@ -12114,8 +12681,11 @@ export {
12114
12681
  stateRecordSchema,
12115
12682
  stateValueSchema,
12116
12683
  subagentEndEventSchema,
12684
+ subagentIdSchema,
12117
12685
  subagentStartEventSchema,
12118
12686
  summarizeHealth,
12687
+ targetHintSchema,
12688
+ targetSourceSchema,
12119
12689
  toReport,
12120
12690
  tokenCountSchema,
12121
12691
  toolEndEventSchema,
@@ -12132,6 +12702,8 @@ export {
12132
12702
  workspaceIdSchema,
12133
12703
  workspaceIdentitySchema,
12134
12704
  workspaceKeySourceSchema,
12705
+ workspaceTargetSchema,
12706
+ worktreeKindSchema,
12135
12707
  writeDocumentAtomically
12136
12708
  };
12137
12709
  //# sourceMappingURL=index.js.map