@osfactory/otel-hook 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/{adapter-DXpNtnaf.d.ts → adapter-BgqtlADe.d.ts} +10 -3
  2. package/dist/cli.js +1001 -487
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{events-VxBnDFaO.d.ts → events-C3h3GvHj.d.ts} +58 -0
  5. package/dist/{filesystem-store-J8jjDMTh.d.ts → filesystem-store-BAq3VGVv.d.ts} +1 -1
  6. package/dist/{hook-_mlO3akA.d.ts → hook-CQiNa88Q.d.ts} +12 -4
  7. package/dist/index.d.ts +13 -12
  8. package/dist/index.js +1127 -599
  9. package/dist/index.js.map +1 -1
  10. package/dist/install.d.ts +5 -4
  11. package/dist/install.js +99 -68
  12. package/dist/install.js.map +1 -1
  13. package/dist/integration.d.ts +15 -8
  14. package/dist/integration.js +505 -121
  15. package/dist/integration.js.map +1 -1
  16. package/dist/lifecycle.d.ts +3 -3
  17. package/dist/lifecycle.js +23 -2
  18. package/dist/lifecycle.js.map +1 -1
  19. package/dist/{memory-DXVBc8V9.d.ts → memory-kflYgZbg.d.ts} +2 -2
  20. package/dist/model.d.ts +2 -1
  21. package/dist/model.js +79 -41
  22. package/dist/model.js.map +1 -1
  23. package/dist/{otlp-log-sink-DTSa0KRF.d.ts → otlp-log-sink-BZIgYPKN.d.ts} +3 -3
  24. package/dist/{payload-BWV5-4n3.d.ts → payload-DpyU8F-z.d.ts} +1 -1
  25. package/dist/{ports-Q8x0ODhs.d.ts → ports-B_iwJQPQ.d.ts} +20 -2
  26. package/dist/providers.d.ts +27 -9
  27. package/dist/providers.js +664 -452
  28. package/dist/providers.js.map +1 -1
  29. package/dist/{registry-Dqr3VNmT.d.ts → registry-BSBS8t7S.d.ts} +1 -1
  30. package/dist/runtime.d.ts +87 -11
  31. package/dist/runtime.js +379 -67
  32. package/dist/runtime.js.map +1 -1
  33. package/dist/{semconv-CIU-2kGO.d.ts → semconv-BeUPQ7_q.d.ts} +1 -1
  34. package/dist/state.d.ts +4 -4
  35. package/dist/state.js.map +1 -1
  36. package/dist/target-8RfaVxp8.d.ts +83 -0
  37. package/dist/telemetry.d.ts +6 -6
  38. package/dist/telemetry.js +86 -10
  39. package/dist/telemetry.js.map +1 -1
  40. package/dist/testing.d.ts +14 -7
  41. package/dist/testing.js +814 -492
  42. package/dist/testing.js.map +1 -1
  43. package/package.json +4 -1
package/dist/index.js CHANGED
@@ -564,12 +564,33 @@ 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 workspaceTargetSchema = z7.strictObject({
580
+ workspaceId: workspaceIdSchema,
581
+ /** Branch checked out in that worktree; absent on a detached HEAD. */
582
+ vcsBranchName: nonEmptyStringSchema.optional(),
583
+ source: targetSourceSchema
584
+ }).readonly();
585
+ var SUBAGENT_ID_PATTERN = /^[A-Za-z0-9_.:@+=-]{1,256}$/;
586
+ var subagentIdSchema = z7.string().regex(SUBAGENT_ID_PATTERN);
587
+
567
588
  // src/model/events.ts
568
- import { z as z8 } from "zod";
589
+ import { z as z9 } from "zod";
569
590
 
570
591
  // src/errors/taxonomy.ts
571
- import { z as z7 } from "zod";
572
- var otelHookErrorCodeSchema = z7.enum([
592
+ import { z as z8 } from "zod";
593
+ var otelHookErrorCodeSchema = z8.enum([
573
594
  /** Input was not usable at all (empty stdin, unparsable JSON). */
574
595
  "invalid-input",
575
596
  /** Input parsed but failed canonical schema validation. */
@@ -605,8 +626,8 @@ var otelHookErrorCodeSchema = z7.enum([
605
626
  /** Anything unanticipated. Always reported, never fatal to the host. */
606
627
  "internal-error"
607
628
  ]);
608
- var errorSeveritySchema = z7.enum(["warning", "error"]);
609
- var errorPhaseSchema = z7.enum([
629
+ var errorSeveritySchema = z8.enum(["warning", "error"]);
630
+ var errorPhaseSchema = z8.enum([
610
631
  "configuration",
611
632
  "detection",
612
633
  "identity",
@@ -617,7 +638,7 @@ var errorPhaseSchema = z7.enum([
617
638
  "export",
618
639
  "shutdown"
619
640
  ]);
620
- var failurePostureSchema = z7.enum(["fail-open", "fail-closed-attribution"]);
641
+ var failurePostureSchema = z8.enum(["fail-open", "fail-closed-attribution"]);
621
642
  var ERROR_TAXONOMY = Object.freeze({
622
643
  "invalid-input": {
623
644
  code: "invalid-input",
@@ -742,7 +763,7 @@ var ERROR_TAXONOMY = Object.freeze({
742
763
  }
743
764
  });
744
765
  var describeErrorCode = (code) => ERROR_TAXONOMY[code];
745
- var attributionOutcomeSchema = z7.enum([
766
+ var attributionOutcomeSchema = z8.enum([
746
767
  /** Identity resolved; events carry provider and session identity. */
747
768
  "attributed",
748
769
  /** Identity could not be established safely; nothing was attributed. */
@@ -752,7 +773,7 @@ var attributionOutcomeSchema = z7.enum([
752
773
  /** Input was recognized but intentionally carried no telemetry. */
753
774
  "not-applicable"
754
775
  ]);
755
- var attributionReasonSchema = z7.enum([
776
+ var attributionReasonSchema = z8.enum([
756
777
  "provider-unknown",
757
778
  "provider-detection-ambiguous",
758
779
  "identity-conflict",
@@ -764,19 +785,19 @@ var attributionReasonSchema = z7.enum([
764
785
  ]);
765
786
 
766
787
  // src/model/events.ts
767
- var modelDescriptorSchema = z8.strictObject({
788
+ var modelDescriptorSchema = z9.strictObject({
768
789
  modelId: nonEmptyStringSchema,
769
790
  /** Vendor of the model, e.g. `anthropic`. Distinct from the agent provider. */
770
791
  vendor: nonEmptyStringSchema.optional(),
771
792
  family: nonEmptyStringSchema.optional()
772
793
  });
773
- var costFactsSchema = z8.strictObject({
794
+ var costFactsSchema = z9.strictObject({
774
795
  /** ISO 4217 code. */
775
- currency: z8.string().length(3),
776
- amount: z8.number().min(0).finite(),
777
- source: z8.enum(["provider-reported", "computed"])
796
+ currency: z9.string().length(3),
797
+ amount: z9.number().min(0).finite(),
798
+ source: z9.enum(["provider-reported", "computed"])
778
799
  });
779
- var canonicalEventTypeSchema = z8.enum([
800
+ var canonicalEventTypeSchema = z9.enum([
780
801
  "session.start",
781
802
  "session.end",
782
803
  "prompt.submitted",
@@ -790,7 +811,7 @@ var canonicalEventTypeSchema = z8.enum([
790
811
  "error.raised"
791
812
  ]);
792
813
  var CANONICAL_EVENT_TYPES = canonicalEventTypeSchema.options;
793
- var outcomeSchema = z8.enum(["ok", "error", "cancelled", "timeout", "denied", "unknown"]);
814
+ var outcomeSchema = z9.enum(["ok", "error", "cancelled", "timeout", "denied", "unknown"]);
794
815
  var baseEventFields = {
795
816
  schemaVersion: canonicalSchemaVersionSchema,
796
817
  eventId: eventIdSchema,
@@ -801,39 +822,45 @@ var baseEventFields = {
801
822
  occurredAt: epochMillisSchema,
802
823
  provenance: sourceProvenanceSchema,
803
824
  workspace: workspaceIdentitySchema,
825
+ /**
826
+ * The provider's own id for the subagent this event was emitted inside (e.g.
827
+ * Claude Code's `agent_id`). Absent for the top-level agent. Set by the event
828
+ * factory, never by hand.
829
+ */
830
+ subagentId: subagentIdSchema.optional(),
804
831
  extensions: extensionsSchema.default(emptyExtensions)
805
832
  };
806
- var event = (shape) => z8.strictObject({ ...baseEventFields, ...shape });
833
+ var event = (shape) => z9.strictObject({ ...baseEventFields, ...shape });
807
834
  var sessionStartEventSchema = event({
808
- type: z8.literal("session.start"),
809
- sessionKind: z8.enum(["interactive", "non-interactive", "unknown"]),
835
+ type: z9.literal("session.start"),
836
+ sessionKind: z9.enum(["interactive", "non-interactive", "unknown"]),
810
837
  agentName: nonEmptyStringSchema.optional(),
811
838
  agentVersion: nonEmptyStringSchema.optional(),
812
839
  model: modelDescriptorSchema.optional()
813
840
  });
814
841
  var sessionEndEventSchema = event({
815
- type: z8.literal("session.end"),
816
- reason: z8.enum(["completed", "aborted", "error", "timeout", "unknown"]),
842
+ type: z9.literal("session.end"),
843
+ reason: z9.enum(["completed", "aborted", "error", "timeout", "unknown"]),
817
844
  durationMillis: durationMillisSchema.optional(),
818
845
  /** Session totals, typically cumulative. */
819
846
  usage: canonicalUsageSchema.optional(),
820
847
  cost: costFactsSchema.optional()
821
848
  });
822
849
  var promptSubmittedEventSchema = event({
823
- type: z8.literal("prompt.submitted"),
824
- promptSource: z8.enum(["user", "automation", "resumed", "unknown"]),
850
+ type: z9.literal("prompt.submitted"),
851
+ promptSource: z9.enum(["user", "automation", "resumed", "unknown"]),
825
852
  content: contentFactSchema.optional(),
826
- turnIndex: z8.number().int().min(0).optional()
853
+ turnIndex: z9.number().int().min(0).optional()
827
854
  });
828
855
  var generationStartEventSchema = event({
829
- type: z8.literal("generation.start"),
856
+ type: z9.literal("generation.start"),
830
857
  generationId: nonEmptyStringSchema,
831
858
  model: modelDescriptorSchema,
832
859
  requestedMaxOutputTokens: tokenCountSchema.optional(),
833
860
  inputContent: contentFactsSchema.optional()
834
861
  });
835
862
  var generationEndEventSchema = event({
836
- type: z8.literal("generation.end"),
863
+ type: z9.literal("generation.end"),
837
864
  generationId: nonEmptyStringSchema,
838
865
  model: modelDescriptorSchema,
839
866
  outcome: outcomeSchema,
@@ -843,7 +870,7 @@ var generationEndEventSchema = event({
843
870
  cost: costFactsSchema.optional(),
844
871
  outputContent: contentFactsSchema.optional()
845
872
  });
846
- var toolKindSchema = z8.enum([
873
+ var toolKindSchema = z9.enum([
847
874
  "read",
848
875
  "write",
849
876
  "execute",
@@ -854,59 +881,63 @@ var toolKindSchema = z8.enum([
854
881
  "unknown"
855
882
  ]);
856
883
  var toolStartEventSchema = event({
857
- type: z8.literal("tool.start"),
884
+ type: z9.literal("tool.start"),
858
885
  toolCallId: nonEmptyStringSchema,
859
886
  toolName: nonEmptyStringSchema,
860
887
  toolKind: toolKindSchema,
861
888
  generationId: nonEmptyStringSchema.optional(),
862
- input: contentFactSchema.optional()
889
+ input: contentFactSchema.optional(),
890
+ /** The git worktree this call targeted, resolved by the core (ADR 0008). */
891
+ target: workspaceTargetSchema.optional()
863
892
  });
864
893
  var toolEndEventSchema = event({
865
- type: z8.literal("tool.end"),
894
+ type: z9.literal("tool.end"),
866
895
  toolCallId: nonEmptyStringSchema,
867
896
  toolName: nonEmptyStringSchema,
868
897
  outcome: outcomeSchema,
869
898
  durationMillis: durationMillisSchema.optional(),
870
899
  /** 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()
900
+ permissionDecision: z9.enum(["allowed", "denied", "deferred", "not-required"]).optional(),
901
+ output: contentFactSchema.optional(),
902
+ /** The git worktree this call targeted, resolved by the core (ADR 0008). */
903
+ target: workspaceTargetSchema.optional()
873
904
  });
874
905
  var subagentStartEventSchema = event({
875
- type: z8.literal("subagent.start"),
906
+ type: z9.literal("subagent.start"),
876
907
  subagentInvocationId: invocationIdSchema,
877
908
  subagentType: nonEmptyStringSchema.optional(),
878
909
  /** 0 for the top-level agent; 1 for its direct children. */
879
- delegationDepth: z8.number().int().min(0).max(64),
910
+ delegationDepth: z9.number().int().min(0).max(64),
880
911
  model: modelDescriptorSchema.optional()
881
912
  });
882
913
  var subagentEndEventSchema = event({
883
- type: z8.literal("subagent.end"),
914
+ type: z9.literal("subagent.end"),
884
915
  subagentInvocationId: invocationIdSchema,
885
916
  outcome: outcomeSchema,
886
917
  durationMillis: durationMillisSchema.optional(),
887
918
  usage: canonicalUsageSchema.optional()
888
919
  });
889
920
  var compactionPerformedEventSchema = event({
890
- type: z8.literal("compaction.performed"),
891
- trigger: z8.enum(["automatic", "manual", "unknown"]),
921
+ type: z9.literal("compaction.performed"),
922
+ trigger: z9.enum(["automatic", "manual", "unknown"]),
892
923
  /** Provider-reported context size before and after compaction, if known. */
893
924
  contextTokensBefore: tokenCountSchema.optional(),
894
925
  contextTokensAfter: tokenCountSchema.optional(),
895
- droppedMessageCount: z8.number().int().min(0).optional(),
926
+ droppedMessageCount: z9.number().int().min(0).optional(),
896
927
  usage: canonicalUsageSchema.optional()
897
928
  });
898
929
  var errorRaisedEventSchema = event({
899
- type: z8.literal("error.raised"),
930
+ type: z9.literal("error.raised"),
900
931
  errorCode: otelHookErrorCodeSchema,
901
932
  severity: errorSeveritySchema,
902
933
  phase: errorPhaseSchema,
903
- retryable: z8.boolean(),
934
+ retryable: z9.boolean(),
904
935
  /** Error text is content: it is described, never embedded verbatim by default. */
905
936
  message: contentFactSchema.optional(),
906
937
  /** Non-sensitive, provider-agnostic short label. */
907
938
  detail: nonEmptyStringSchema.optional()
908
939
  });
909
- var canonicalEventSchema = z8.discriminatedUnion("type", [
940
+ var canonicalEventSchema = z9.discriminatedUnion("type", [
910
941
  sessionStartEventSchema,
911
942
  sessionEndEventSchema,
912
943
  promptSubmittedEventSchema,
@@ -936,14 +967,14 @@ var eventUsage = (event3) => "usage" in event3 ? event3.usage : void 0;
936
967
  var compareEvents = (a, b) => a.sequence - b.sequence || a.occurredAt - b.occurredAt || a.eventId.localeCompare(b.eventId);
937
968
 
938
969
  // src/errors/index.ts
939
- import { z as z9 } from "zod";
940
- var otelHookErrorInfoSchema = z9.strictObject({
970
+ import { z as z10 } from "zod";
971
+ var otelHookErrorInfoSchema = z10.strictObject({
941
972
  code: otelHookErrorCodeSchema,
942
973
  severity: errorSeveritySchema,
943
974
  phase: errorPhaseSchema,
944
975
  posture: failurePostureSchema,
945
- retryable: z9.boolean(),
946
- message: z9.string().min(1).max(512),
976
+ retryable: z10.boolean(),
977
+ message: z10.string().min(1).max(512),
947
978
  details: attributesSchema.optional(),
948
979
  occurredAt: epochMillisSchema.optional()
949
980
  });
@@ -997,8 +1028,8 @@ var errorInfoFromThrown = (thrown, input) => {
997
1028
  };
998
1029
 
999
1030
  // src/privacy/policy.ts
1000
- import { z as z10 } from "zod";
1001
- var contentModeSchema = z10.enum(["omit", "mask", "redact", "raw"]);
1031
+ import { z as z11 } from "zod";
1032
+ var contentModeSchema = z11.enum(["omit", "mask", "redact", "raw"]);
1002
1033
  var CONTENT_MODE_DISCLOSURE = Object.freeze({
1003
1034
  omit: "omitted",
1004
1035
  mask: "masked",
@@ -1024,35 +1055,35 @@ var DEFAULT_SECRET_VALUE_PATTERNS = Object.freeze([
1024
1055
  "eyJ[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}",
1025
1056
  "(?:Bearer|Basic)\\s+[A-Za-z0-9._~+/=-]{12,}"
1026
1057
  ]);
1027
- var privacyLimitsSchema = z10.strictObject({
1058
+ var privacyLimitsSchema = z11.strictObject({
1028
1059
  /** Maximum characters of disclosed text per content fact or string value. */
1029
- maxStringLength: z10.number().int().min(0).max(65536),
1060
+ maxStringLength: z11.number().int().min(0).max(65536),
1030
1061
  /** Maximum nesting depth walked when sanitizing structured values. */
1031
- maxDepth: z10.number().int().min(1).max(32),
1062
+ maxDepth: z11.number().int().min(1).max(32),
1032
1063
  /** Maximum array entries retained when sanitizing structured values. */
1033
- maxArrayLength: z10.number().int().min(1).max(4096),
1064
+ maxArrayLength: z11.number().int().min(1).max(4096),
1034
1065
  /** Maximum canonical events emitted per invocation. */
1035
- maxEventsPerInvocation: z10.number().int().min(1).max(1e4),
1066
+ maxEventsPerInvocation: z11.number().int().min(1).max(1e4),
1036
1067
  /** Maximum object keys retained per level when sanitizing. */
1037
- maxObjectKeys: z10.number().int().min(1).max(1024)
1068
+ maxObjectKeys: z11.number().int().min(1).max(1024)
1038
1069
  });
1039
- var privacyPolicySchema = z10.strictObject({
1070
+ var privacyPolicySchema = z11.strictObject({
1040
1071
  contentMode: contentModeSchema,
1041
1072
  /**
1042
1073
  * `raw` mode is refused unless this is also true, so a single mistyped
1043
1074
  * environment variable cannot start exporting prompts.
1044
1075
  */
1045
- allowRawContent: z10.boolean(),
1076
+ allowRawContent: z11.boolean(),
1046
1077
  /**
1047
1078
  * Salt mixed into every hash. A per-deployment salt makes hashes
1048
1079
  * non-correlatable across deployments; an empty salt makes them globally
1049
1080
  * comparable. Both are legitimate; the choice is explicit.
1050
1081
  */
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(),
1082
+ hashSalt: z11.string().max(256),
1083
+ maskCharacter: z11.string().length(1),
1084
+ redactionPlaceholder: z11.string().min(1).max(64),
1085
+ secretKeyPatterns: z11.array(z11.string().min(1)).max(128).readonly(),
1086
+ secretValuePatterns: z11.array(z11.string().min(1)).max(128).readonly(),
1056
1087
  limits: privacyLimitsSchema
1057
1088
  });
1058
1089
  var DEFAULT_PRIVACY_LIMITS = Object.freeze({
@@ -1302,11 +1333,11 @@ var createPrivacyService = (policyInput) => {
1302
1333
  };
1303
1334
  const flattenToAttributes = (value, prefix) => {
1304
1335
  const attributes = {};
1305
- const walk = (current, path7) => {
1336
+ const walk = (current, path9) => {
1306
1337
  if (typeof current === "string" || typeof current === "number" || typeof current === "boolean") {
1307
1338
  const primitive = toAttributePrimitive(current);
1308
1339
  if (primitive !== void 0) {
1309
- attributes[path7] = primitive;
1340
+ attributes[path9] = primitive;
1310
1341
  }
1311
1342
  return;
1312
1343
  }
@@ -1325,16 +1356,16 @@ var createPrivacyService = (policyInput) => {
1325
1356
  primitives.push(entryPrimitive);
1326
1357
  }
1327
1358
  if (uniform) {
1328
- attributes[path7] = primitives.slice(0, MAX_ATTRIBUTE_ARRAY_LENGTH);
1359
+ attributes[path9] = primitives.slice(0, MAX_ATTRIBUTE_ARRAY_LENGTH);
1329
1360
  return;
1330
1361
  }
1331
1362
  for (const [index, entry] of current.entries()) {
1332
- walk(entry, `${path7}.${index}`);
1363
+ walk(entry, `${path9}.${index}`);
1333
1364
  }
1334
1365
  return;
1335
1366
  }
1336
1367
  for (const [key, entry] of Object.entries(current)) {
1337
- walk(entry, path7 === "" ? key : `${path7}.${key}`);
1368
+ walk(entry, path9 === "" ? key : `${path9}.${key}`);
1338
1369
  }
1339
1370
  };
1340
1371
  walk(value, prefix);
@@ -1474,7 +1505,7 @@ var deriveWorkspaceIdentity = (privacy, input, labels = {}) => {
1474
1505
  };
1475
1506
 
1476
1507
  // src/config/resource-attributes.ts
1477
- import { z as z11 } from "zod";
1508
+ import { z as z12 } from "zod";
1478
1509
  var MAX_RESOURCE_ATTRIBUTES = 64;
1479
1510
  var MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH = 255;
1480
1511
  var MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH = 2048;
@@ -1519,12 +1550,12 @@ var checkResourceAttributeKey = (key) => {
1519
1550
  }
1520
1551
  return void 0;
1521
1552
  };
1522
- var resourceAttributeValueSchema = z11.union([
1523
- z11.string().max(MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH),
1524
- z11.number().finite(),
1525
- z11.boolean()
1553
+ var resourceAttributeValueSchema = z12.union([
1554
+ z12.string().max(MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH),
1555
+ z12.number().finite(),
1556
+ z12.boolean()
1526
1557
  ]);
1527
- var resourceAttributesSchema = z11.record(z11.string(), resourceAttributeValueSchema).superRefine((value, ctx) => {
1558
+ var resourceAttributesSchema = z12.record(z12.string(), resourceAttributeValueSchema).superRefine((value, ctx) => {
1528
1559
  const keys = Object.keys(value);
1529
1560
  if (keys.length > MAX_RESOURCE_ATTRIBUTES) {
1530
1561
  ctx.addIssue({
@@ -1633,37 +1664,37 @@ var sanitizeResourceAttributes = (attributes) => {
1633
1664
  var describeResourceAttributeNames = (attributes) => Object.keys(attributes).sort();
1634
1665
 
1635
1666
  // src/config/schema.ts
1636
- import { z as z12 } from "zod";
1637
- var logsPolicySchema = z12.strictObject({
1638
- enabled: z12.boolean(),
1667
+ import { z as z13 } from "zod";
1668
+ var logsPolicySchema = z13.strictObject({
1669
+ enabled: z13.boolean(),
1639
1670
  /**
1640
1671
  * Full URL for the logs signal.
1641
1672
  *
1642
1673
  * Absent, it is derived from `endpoint`: a trailing `/v1/traces` becomes
1643
1674
  * `/v1/logs`, and an endpoint with no signal path has `/v1/logs` appended.
1644
1675
  */
1645
- endpoint: z12.string().url().max(2048).optional(),
1646
- includeContent: z12.boolean(),
1647
- maxBatchSize: z12.number().int().min(1).max(4096)
1676
+ endpoint: z13.string().url().max(2048).optional(),
1677
+ includeContent: z13.boolean(),
1678
+ maxBatchSize: z13.number().int().min(1).max(4096)
1648
1679
  });
1649
1680
  var DEFAULT_LOGS_POLICY = Object.freeze({
1650
1681
  enabled: false,
1651
1682
  includeContent: false,
1652
1683
  maxBatchSize: 128
1653
1684
  });
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(),
1685
+ var exporterPolicySchema = z13.strictObject({
1686
+ enabled: z13.boolean(),
1687
+ protocol: z13.enum(["http/protobuf", "http/json", "none"]),
1688
+ endpoint: z13.string().url().max(2048).optional(),
1658
1689
  /**
1659
1690
  * Header names only. Values are supplied separately at construction time and
1660
1691
  * are never part of a resolved-config snapshot, which is logged and exported.
1661
1692
  */
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),
1693
+ headerNames: z13.array(nonEmptyStringSchema).max(32).readonly(),
1694
+ timeoutMillis: z13.number().int().min(1).max(6e5),
1695
+ maxBatchSize: z13.number().int().min(1).max(4096),
1696
+ maxQueueSize: z13.number().int().min(1).max(65536),
1697
+ maxRetryAttempts: z13.number().int().min(0).max(10),
1667
1698
  serviceName: nonEmptyStringSchema,
1668
1699
  serviceNamespace: nonEmptyStringSchema.optional(),
1669
1700
  /**
@@ -1682,26 +1713,26 @@ var exporterPolicySchema = z12.strictObject({
1682
1713
  */
1683
1714
  logs: logsPolicySchema
1684
1715
  });
1685
- var detectionPolicySchema = z12.strictObject({
1716
+ var detectionPolicySchema = z13.strictObject({
1686
1717
  /** Detections below this confidence resolve to the unknown provider. */
1687
1718
  minimumConfidence: detectionConfidenceSchema,
1688
1719
  /** When false, an ambiguous detection is an error rather than unknown. */
1689
- allowAmbiguousFallback: z12.boolean(),
1720
+ allowAmbiguousFallback: z13.boolean(),
1690
1721
  /** Optional allow-list of provider ids; empty means "any registered". */
1691
- allowedProviderIds: z12.array(nonEmptyStringSchema).max(32).readonly()
1722
+ allowedProviderIds: z13.array(nonEmptyStringSchema).max(32).readonly()
1692
1723
  });
1693
- var diagnosticsPolicySchema = z12.strictObject({
1694
- logLevel: z12.enum(["silent", "error", "warn", "info", "debug"]),
1724
+ var diagnosticsPolicySchema = z13.strictObject({
1725
+ logLevel: z13.enum(["silent", "error", "warn", "info", "debug"]),
1695
1726
  /** Emit `error.raised` events for contained failures. */
1696
- emitErrorEvents: z12.boolean()
1727
+ emitErrorEvents: z13.boolean()
1697
1728
  });
1698
- var otelHookConfigSchema = z12.strictObject({
1729
+ var otelHookConfigSchema = z13.strictObject({
1699
1730
  exporter: exporterPolicySchema,
1700
1731
  privacy: privacyPolicySchema,
1701
1732
  detection: detectionPolicySchema,
1702
1733
  diagnostics: diagnosticsPolicySchema
1703
1734
  });
1704
- var otelHookConfigPatchSchema = z12.strictObject({
1735
+ var otelHookConfigPatchSchema = z13.strictObject({
1705
1736
  // `logs` is unwrapped and re-partialled for the same reason `privacy.limits` is:
1706
1737
  // merging happens per leaf, so a layer must be able to set `logs.enabled` alone
1707
1738
  // without also restating the endpoint and the batch size.
@@ -1739,16 +1770,16 @@ var DEFAULT_CONFIG = Object.freeze({
1739
1770
  });
1740
1771
 
1741
1772
  // src/config/resolve.ts
1742
- import { z as z13 } from "zod";
1773
+ import { z as z14 } from "zod";
1743
1774
  var CONFIG_SOURCE_PRECEDENCE = ["defaults", "file", "environment", "inline-override"];
1744
- var configSourceSchema = z13.enum(CONFIG_SOURCE_PRECEDENCE);
1775
+ var configSourceSchema = z14.enum(CONFIG_SOURCE_PRECEDENCE);
1745
1776
  var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1746
- var mergeLeaf = (target, patch, source, provenance, path7) => {
1777
+ var mergeLeaf = (target, patch, source, provenance, path9) => {
1747
1778
  for (const [key, value] of Object.entries(patch)) {
1748
1779
  if (value === void 0) {
1749
1780
  continue;
1750
1781
  }
1751
- const childPath = path7 === "" ? key : `${path7}.${key}`;
1782
+ const childPath = path9 === "" ? key : `${path9}.${key}`;
1752
1783
  const existing = target[key];
1753
1784
  if (isPlainObject(value) && isPlainObject(existing)) {
1754
1785
  const child = { ...existing };
@@ -1762,14 +1793,14 @@ var mergeLeaf = (target, patch, source, provenance, path7) => {
1762
1793
  };
1763
1794
  var initialProvenance = (config) => {
1764
1795
  const provenance = {};
1765
- const walk = (value, path7) => {
1796
+ const walk = (value, path9) => {
1766
1797
  if (isPlainObject(value)) {
1767
1798
  for (const [key, child] of Object.entries(value)) {
1768
- walk(child, path7 === "" ? key : `${path7}.${key}`);
1799
+ walk(child, path9 === "" ? key : `${path9}.${key}`);
1769
1800
  }
1770
1801
  return;
1771
1802
  }
1772
- provenance[path7] = "defaults";
1803
+ provenance[path9] = "defaults";
1773
1804
  };
1774
1805
  walk(config, "");
1775
1806
  return provenance;
@@ -2086,27 +2117,27 @@ var parseEnvironmentConfig = (env) => {
2086
2117
  };
2087
2118
 
2088
2119
  // src/providers/adapter.ts
2089
- import { z as z14 } from "zod";
2090
- var providerDetectionSchema = z14.strictObject({
2120
+ import { z as z15 } from "zod";
2121
+ var providerDetectionSchema = z15.strictObject({
2091
2122
  providerId: resolvedProviderIdSchema,
2092
2123
  confidence: detectionConfidenceSchema,
2093
2124
  /**
2094
2125
  * Short, non-sensitive justifications, e.g. `"payload.hook_event_name present"`.
2095
2126
  * Reasons are exported in diagnostics, so they must not quote payload values.
2096
2127
  */
2097
- reasons: z14.array(z14.string().min(1).max(160)).max(8),
2128
+ reasons: z15.array(z15.string().min(1).max(160)).max(8),
2098
2129
  providerVersion: nonEmptyStringSchema.optional(),
2099
2130
  /** The provider's own name for this event, when the payload states one. */
2100
2131
  sourceEventName: nonEmptyStringSchema.optional()
2101
2132
  });
2102
- var deliveryIdentifierSupportSchema = z14.enum(["none", "partial", "all"]);
2133
+ var deliveryIdentifierSupportSchema = z15.enum(["none", "partial", "all"]);
2103
2134
  var DELIVERY_COMPONENT_PATTERN = /^[A-Za-z0-9_.:@+=-]{1,256}$/;
2104
- var deliveryComponentSchema = z14.string().regex(
2135
+ var deliveryComponentSchema = z15.string().regex(
2105
2136
  DELIVERY_COMPONENT_PATTERN,
2106
2137
  "delivery component must be identifier-shaped: no whitespace, no path separators"
2107
2138
  );
2108
2139
  var MAX_DELIVERY_COMPONENTS = 8;
2109
- var providerDeliveryClaimSchema = z14.strictObject({
2140
+ var providerDeliveryClaimSchema = z15.strictObject({
2110
2141
  /**
2111
2142
  * The provider's own session/conversation id. Scopes the callback identity, so
2112
2143
  * two sessions reusing one tool-call id never collide.
@@ -2118,26 +2149,26 @@ var providerDeliveryClaimSchema = z14.strictObject({
2118
2149
  * Identifier-shaped payload fields that, together with `sourceEventName`,
2119
2150
  * name this callback within the session exactly once.
2120
2151
  */
2121
- components: z14.array(deliveryComponentSchema).min(1).max(MAX_DELIVERY_COMPONENTS).readonly(),
2152
+ components: z15.array(deliveryComponentSchema).min(1).max(MAX_DELIVERY_COMPONENTS).readonly(),
2122
2153
  /**
2123
2154
  * Short, non-sensitive justifications, e.g. `"payload.tool_use_id names one
2124
2155
  * tool call"`. Evidence reaches diagnostics, so it must name fields, never
2125
2156
  * quote their values.
2126
2157
  */
2127
- evidence: z14.array(z14.string().min(1).max(160)).min(1).max(4).readonly()
2158
+ evidence: z15.array(z15.string().min(1).max(160)).min(1).max(4).readonly()
2128
2159
  });
2129
2160
  var DELIVERY_GAP_REASON_PATTERN = /^[^\n\r\t\\/]{1,240}$/;
2130
- var deliveryGapReasonSchema = z14.string().regex(
2161
+ var deliveryGapReasonSchema = z15.string().regex(
2131
2162
  DELIVERY_GAP_REASON_PATTERN,
2132
2163
  "delivery gap reason must be one line of prose: no path separators, no control characters"
2133
2164
  );
2134
2165
  var MAX_DELIVERY_GAPS = 48;
2135
- var providerDeliveryGapsSchema = z14.record(deliveryComponentSchema, deliveryGapReasonSchema).refine((gaps) => Object.keys(gaps).length <= MAX_DELIVERY_GAPS, {
2166
+ var providerDeliveryGapsSchema = z15.record(deliveryComponentSchema, deliveryGapReasonSchema).refine((gaps) => Object.keys(gaps).length <= MAX_DELIVERY_GAPS, {
2136
2167
  message: `at most ${String(MAX_DELIVERY_GAPS)} delivery gaps may be declared`
2137
2168
  });
2138
- var providerCapabilitiesSchema = z14.strictObject({
2169
+ var providerCapabilitiesSchema = z15.strictObject({
2139
2170
  /** Event types the adapter can produce. */
2140
- lifecycleEvents: z14.array(canonicalEventTypeSchema).max(32).readonly(),
2171
+ lifecycleEvents: z15.array(canonicalEventTypeSchema).max(32).readonly(),
2141
2172
  usageTemporality: usageTemporalitySchema,
2142
2173
  /**
2143
2174
  * Which accumulator series a `cumulative` report continues — that is, which
@@ -2156,32 +2187,32 @@ var providerCapabilitiesSchema = z14.strictObject({
2156
2187
  * Subagent snapshots keep their own series regardless: a delegated agent's
2157
2188
  * counter is not a point on the parent session's curve.
2158
2189
  */
2159
- cumulativeUsageSeries: z14.enum(["event-scope", "session-lifetime"]).optional(),
2160
- reportsCachedInput: z14.boolean(),
2161
- reportsCacheCreation: z14.boolean(),
2190
+ cumulativeUsageSeries: z15.enum(["event-scope", "session-lifetime"]).optional(),
2191
+ reportsCachedInput: z15.boolean(),
2192
+ reportsCacheCreation: z15.boolean(),
2162
2193
  cacheCreationAccounting: cacheCreationAccountingSchema,
2163
- reportsReasoningOutput: z14.boolean(),
2164
- reportsProviderTotal: z14.boolean(),
2165
- reportsCost: z14.boolean(),
2166
- emitsSubagentEvents: z14.boolean(),
2167
- emitsCompactionEvents: z14.boolean(),
2194
+ reportsReasoningOutput: z15.boolean(),
2195
+ reportsProviderTotal: z15.boolean(),
2196
+ reportsCost: z15.boolean(),
2197
+ emitsSubagentEvents: z15.boolean(),
2198
+ emitsCompactionEvents: z15.boolean(),
2168
2199
  /** True when the provider reads a structured response from stdout. */
2169
- requiresHookResponse: z14.boolean(),
2200
+ requiresHookResponse: z15.boolean(),
2170
2201
  /** How much of this provider's hook traffic is replay-identifiable. */
2171
2202
  deliveryIdentifier: deliveryIdentifierSupportSchema
2172
2203
  });
2173
- var providerHookResponseSchema = z14.strictObject({
2204
+ var providerHookResponseSchema = z15.strictObject({
2174
2205
  /**
2175
2206
  * Always 0. A telemetry hook that can fail the host agent is a liability, so
2176
2207
  * the type forbids expressing anything else (ADR 0004).
2177
2208
  */
2178
- exitCode: z14.literal(0),
2209
+ exitCode: z15.literal(0),
2179
2210
  /** Protocol response text. Omit to write nothing at all. */
2180
- stdout: z14.string().max(8192).optional(),
2211
+ stdout: z15.string().max(8192).optional(),
2181
2212
  /** Non-sensitive diagnostic text for stderr. */
2182
- stderr: z14.string().max(8192).optional(),
2213
+ stderr: z15.string().max(8192).optional(),
2183
2214
  /** Declares which of the two stdout contracts this response follows. */
2184
- contract: z14.enum(["silent", "provider-protocol"])
2215
+ contract: z15.enum(["silent", "provider-protocol"])
2185
2216
  });
2186
2217
  var SILENT_HOOK_RESPONSE = Object.freeze({
2187
2218
  exitCode: 0,
@@ -2238,10 +2269,15 @@ var createEventFactory = (input) => {
2238
2269
  const { identity, context } = input;
2239
2270
  const built = [];
2240
2271
  const dropped = [];
2272
+ const hints = /* @__PURE__ */ new Map();
2241
2273
  let sequence = input.sequenceBase;
2274
+ const subagentId = input.subagentId !== void 0 && subagentIdSchema.safeParse(input.subagentId).success ? input.subagentId : void 0;
2242
2275
  return {
2243
2276
  build: (draft) => {
2244
- const { occurredAt, extensions, idDiscriminator, ...rest } = draft;
2277
+ const { occurredAt, extensions, idDiscriminator, targetHint, ...drafted } = draft;
2278
+ const rest = { ...drafted };
2279
+ delete rest.target;
2280
+ delete rest.subagentId;
2245
2281
  const sanitized = extensions === void 0 ? { extensions: {}, droppedKeys: [] } : context.privacy.sanitizeExtensions(extensions);
2246
2282
  dropped.push(...sanitized.droppedKeys);
2247
2283
  const currentSequence = sequence;
@@ -2261,6 +2297,7 @@ var createEventFactory = (input) => {
2261
2297
  occurredAt: occurredAt ?? context.clock.now(),
2262
2298
  provenance: identity.provenance,
2263
2299
  workspace: identity.workspace,
2300
+ ...subagentId === void 0 ? {} : { subagentId },
2264
2301
  extensions: sanitized.extensions
2265
2302
  };
2266
2303
  const parsed = canonicalEventSchema.safeParse(candidate);
@@ -2273,11 +2310,18 @@ var createEventFactory = (input) => {
2273
2310
  });
2274
2311
  }
2275
2312
  built.push(parsed.data);
2313
+ if (targetHint !== void 0 && (parsed.data.type === "tool.start" || parsed.data.type === "tool.end")) {
2314
+ const hint = targetHintSchema.safeParse(targetHint);
2315
+ if (hint.success) {
2316
+ hints.set(parsed.data.eventId, hint.data);
2317
+ }
2318
+ }
2276
2319
  return parsed.data;
2277
2320
  },
2278
2321
  events: () => [...built],
2279
2322
  nextSequence: () => sequence,
2280
- droppedExtensionKeys: () => [...dropped]
2323
+ droppedExtensionKeys: () => [...dropped],
2324
+ targetHints: () => new Map(hints)
2281
2325
  };
2282
2326
  };
2283
2327
 
@@ -2437,35 +2481,35 @@ var CLAUDE_CODE_CAPABILITIES = Object.freeze({
2437
2481
  });
2438
2482
 
2439
2483
  // src/providers/claude/schema.ts
2440
- import { z as z15 } from "zod";
2484
+ import { z as z16 } from "zod";
2441
2485
  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(),
2486
+ session_id: z16.string().min(1),
2487
+ transcript_path: z16.string().min(1).optional(),
2488
+ cwd: z16.string().min(1).optional(),
2489
+ permission_mode: z16.string().min(1).optional(),
2446
2490
  /** Correlates a hook firing with the user prompt that triggered it (Claude Code v2.1.196+). */
2447
- prompt_id: z15.string().min(1).optional(),
2491
+ prompt_id: z16.string().min(1).optional(),
2448
2492
  /** 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(),
2493
+ agent_id: z16.string().min(1).optional(),
2494
+ agent_type: z16.string().min(1).optional()
2495
+ };
2496
+ var claudeCacheCreationSchema = z16.object({
2497
+ ephemeral_5m_input_tokens: z16.number().int().min(0).optional(),
2498
+ ephemeral_1h_input_tokens: z16.number().int().min(0).optional()
2499
+ });
2500
+ var claudeUsageIterationSchema = z16.object({
2501
+ input_tokens: z16.number().int().min(0).optional(),
2502
+ output_tokens: z16.number().int().min(0).optional(),
2503
+ cache_creation_input_tokens: z16.number().int().min(0).optional(),
2504
+ cache_read_input_tokens: z16.number().int().min(0).optional()
2505
+ });
2506
+ var claudeUsageSchema = z16.object({
2507
+ input_tokens: z16.number().int().min(0),
2508
+ output_tokens: z16.number().int().min(0),
2509
+ cache_creation_input_tokens: z16.number().int().min(0).optional(),
2510
+ cache_read_input_tokens: z16.number().int().min(0).optional(),
2467
2511
  cache_creation: claudeCacheCreationSchema.optional(),
2468
- iterations: z15.array(claudeUsageIterationSchema).optional(),
2512
+ iterations: z16.array(claudeUsageIterationSchema).optional(),
2469
2513
  /**
2470
2514
  * Counters the canonical model has a home for but Claude Code never reports:
2471
2515
  * 0 of 4,999 real usage objects carried either (finding 5).
@@ -2474,112 +2518,112 @@ var claudeUsageSchema = z15.object({
2474
2518
  * that a harness attaching one gets told it was excluded, instead of watching
2475
2519
  * it vanish. See `CLAUDE_EXCLUDED_USAGE_COUNTERS`.
2476
2520
  */
2477
- total_tokens: z15.number().int().min(0).optional(),
2478
- reasoning_output_tokens: z15.number().int().min(0).optional()
2521
+ total_tokens: z16.number().int().min(0).optional(),
2522
+ reasoning_output_tokens: z16.number().int().min(0).optional()
2479
2523
  });
2480
- var sessionStartPayloadSchema = z15.object({
2524
+ var sessionStartPayloadSchema = z16.object({
2481
2525
  ...commonFields,
2482
- hook_event_name: z15.literal("SessionStart"),
2526
+ hook_event_name: z16.literal("SessionStart"),
2483
2527
  /** 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()
2528
+ source: z16.string().min(1).optional(),
2529
+ model: z16.string().min(1).optional(),
2530
+ session_title: z16.string().min(1).optional()
2487
2531
  });
2488
- var sessionEndPayloadSchema = z15.object({
2532
+ var sessionEndPayloadSchema = z16.object({
2489
2533
  ...commonFields,
2490
- hook_event_name: z15.literal("SessionEnd"),
2534
+ hook_event_name: z16.literal("SessionEnd"),
2491
2535
  /** Current Claude Code field; values include clear, logout, prompt_input_exit, and other. */
2492
- reason: z15.string().min(1).optional(),
2536
+ reason: z16.string().min(1).optional(),
2493
2537
  /** Compatibility alias emitted by older wrappers and hook integrations. */
2494
- end_reason: z15.string().min(1).optional()
2538
+ end_reason: z16.string().min(1).optional()
2495
2539
  });
2496
- var userPromptSubmitPayloadSchema = z15.object({
2540
+ var userPromptSubmitPayloadSchema = z16.object({
2497
2541
  ...commonFields,
2498
- hook_event_name: z15.literal("UserPromptSubmit"),
2499
- prompt: z15.string()
2542
+ hook_event_name: z16.literal("UserPromptSubmit"),
2543
+ prompt: z16.string()
2500
2544
  });
2501
- var preToolUsePayloadSchema = z15.object({
2545
+ var preToolUsePayloadSchema = z16.object({
2502
2546
  ...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)
2547
+ hook_event_name: z16.literal("PreToolUse"),
2548
+ tool_name: z16.string().min(1),
2549
+ tool_input: z16.unknown(),
2550
+ tool_use_id: z16.string().min(1)
2507
2551
  });
2508
- var postToolUsePayloadSchema = z15.object({
2552
+ var postToolUsePayloadSchema = z16.object({
2509
2553
  ...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)
2554
+ hook_event_name: z16.literal("PostToolUse"),
2555
+ tool_name: z16.string().min(1),
2556
+ tool_input: z16.unknown().optional(),
2557
+ tool_response: z16.unknown(),
2558
+ tool_use_id: z16.string().min(1)
2515
2559
  });
2516
- var postToolUseFailurePayloadSchema = z15.object({
2560
+ var postToolUseFailurePayloadSchema = z16.object({
2517
2561
  ...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)
2562
+ hook_event_name: z16.literal("PostToolUseFailure"),
2563
+ tool_name: z16.string().min(1),
2564
+ tool_input: z16.unknown().optional(),
2565
+ tool_error: z16.unknown(),
2566
+ tool_use_id: z16.string().min(1)
2523
2567
  });
2524
- var permissionRequestPayloadSchema = z15.object({
2568
+ var permissionRequestPayloadSchema = z16.object({
2525
2569
  ...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)
2570
+ hook_event_name: z16.literal("PermissionRequest"),
2571
+ tool_name: z16.string().min(1),
2572
+ tool_input: z16.unknown().optional(),
2573
+ tool_use_id: z16.string().min(1)
2530
2574
  });
2531
- var subagentStartPayloadSchema = z15.object({
2575
+ var subagentStartPayloadSchema = z16.object({
2532
2576
  ...commonFields,
2533
- hook_event_name: z15.literal("SubagentStart"),
2534
- agent_type: z15.string().min(1),
2535
- agent_id: z15.string().min(1)
2577
+ hook_event_name: z16.literal("SubagentStart"),
2578
+ agent_type: z16.string().min(1),
2579
+ agent_id: z16.string().min(1)
2536
2580
  });
2537
- var subagentStopPayloadSchema = z15.object({
2581
+ var subagentStopPayloadSchema = z16.object({
2538
2582
  ...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(),
2583
+ hook_event_name: z16.literal("SubagentStop"),
2584
+ agent_type: z16.string().min(1),
2585
+ agent_id: z16.string().min(1),
2586
+ last_assistant_message: z16.string().optional(),
2543
2587
  /** True when this stop fired because a hook continued the subagent's turn. */
2544
- stop_hook_active: z15.boolean().optional(),
2588
+ stop_hook_active: z16.boolean().optional(),
2545
2589
  usage: claudeUsageSchema.optional()
2546
2590
  });
2547
- var preCompactPayloadSchema = z15.object({
2591
+ var preCompactPayloadSchema = z16.object({
2548
2592
  ...commonFields,
2549
- hook_event_name: z15.literal("PreCompact"),
2593
+ hook_event_name: z16.literal("PreCompact"),
2550
2594
  /** Upstream values: manual | auto. Forward-compatible: any string. */
2551
- trigger: z15.string().min(1).optional(),
2595
+ trigger: z16.string().min(1).optional(),
2552
2596
  /** Compatibility alias emitted by older wrappers and hook integrations. */
2553
- compact_trigger: z15.string().min(1).optional(),
2597
+ compact_trigger: z16.string().min(1).optional(),
2554
2598
  /**
2555
2599
  * Harness-supplied, never upstream. Reported as an explicit exclusion rather
2556
2600
  * than carried across the process boundary: see `events.ts`.
2557
2601
  */
2558
- context_tokens_before: z15.number().int().min(0).optional(),
2559
- estimated_tokens_removed: z15.number().int().min(0).optional()
2602
+ context_tokens_before: z16.number().int().min(0).optional(),
2603
+ estimated_tokens_removed: z16.number().int().min(0).optional()
2560
2604
  });
2561
- var postCompactPayloadSchema = z15.object({
2605
+ var postCompactPayloadSchema = z16.object({
2562
2606
  ...commonFields,
2563
- hook_event_name: z15.literal("PostCompact"),
2564
- trigger: z15.string().min(1).optional(),
2565
- compact_trigger: z15.string().min(1).optional(),
2607
+ hook_event_name: z16.literal("PostCompact"),
2608
+ trigger: z16.string().min(1).optional(),
2609
+ compact_trigger: z16.string().min(1).optional(),
2566
2610
  /** 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(),
2611
+ context_tokens_before: z16.number().int().min(0).optional(),
2612
+ context_tokens_after: z16.number().int().min(0).optional(),
2613
+ dropped_message_count: z16.number().int().min(0).optional(),
2570
2614
  usage: claudeUsageSchema.optional()
2571
2615
  });
2572
- var stopPayloadSchema = z15.object({
2616
+ var stopPayloadSchema = z16.object({
2573
2617
  ...commonFields,
2574
- hook_event_name: z15.literal("Stop"),
2618
+ hook_event_name: z16.literal("Stop"),
2575
2619
  /**
2576
2620
  * Interactive Stop field (Claude Code ≥ 2.1.47). Print / `-p` / Agent SDK
2577
2621
  * result messages use `result` instead; `events.ts` reads both (and camelCase
2578
2622
  * `lastAssistantMessage`) through `extractClaudeAssistantText`.
2579
2623
  */
2580
- last_assistant_message: z15.string().optional(),
2624
+ last_assistant_message: z16.string().optional(),
2581
2625
  /** Print / `-p` JSON result field; accepted so a harness can attach it as-is. */
2582
- result: z15.string().optional(),
2626
+ result: z16.string().optional(),
2583
2627
  /**
2584
2628
  * True when this stop fired because a hook continued the turn.
2585
2629
  *
@@ -2587,22 +2631,22 @@ var stopPayloadSchema = z15.object({
2587
2631
  * stop from a continuation stop, which is what lets `delivery.ts` deduplicate
2588
2632
  * the former without suppressing the latter.
2589
2633
  */
2590
- stop_hook_active: z15.boolean().optional(),
2634
+ stop_hook_active: z16.boolean().optional(),
2591
2635
  usage: claudeUsageSchema.optional()
2592
2636
  });
2593
- var stopFailurePayloadSchema = z15.object({
2637
+ var stopFailurePayloadSchema = z16.object({
2594
2638
  ...commonFields,
2595
- hook_event_name: z15.literal("StopFailure"),
2639
+ hook_event_name: z16.literal("StopFailure"),
2596
2640
  /**
2597
2641
  * Matcher values: rate_limit | overloaded | authentication_failed |
2598
2642
  * oauth_org_not_allowed | billing_error | invalid_request | model_not_found
2599
2643
  * | server_error | max_output_tokens | unknown.
2600
2644
  */
2601
- error_type: z15.string().min(1),
2602
- error_message: z15.string().optional(),
2645
+ error_type: z16.string().min(1),
2646
+ error_message: z16.string().optional(),
2603
2647
  usage: claudeUsageSchema.optional()
2604
2648
  });
2605
- var claudeHookPayloadSchema = z15.discriminatedUnion("hook_event_name", [
2649
+ var claudeHookPayloadSchema = z16.discriminatedUnion("hook_event_name", [
2606
2650
  sessionStartPayloadSchema,
2607
2651
  sessionEndPayloadSchema,
2608
2652
  userPromptSubmitPayloadSchema,
@@ -2632,15 +2676,15 @@ var CLAUDE_HOOK_EVENT_NAMES = [
2632
2676
  "Stop",
2633
2677
  "StopFailure"
2634
2678
  ];
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(),
2679
+ var claudeIdentityFieldsSchema = z16.object({
2680
+ session_id: z16.string().min(1),
2681
+ hook_event_name: z16.string().min(1),
2682
+ cwd: z16.string().min(1).optional(),
2683
+ prompt_id: z16.string().min(1).optional(),
2684
+ agent_id: z16.string().min(1).optional(),
2685
+ tool_use_id: z16.string().min(1).optional(),
2642
2686
  /** Read by `delivery.ts` to tell a once-per-prompt stop from a continuation. */
2643
- stop_hook_active: z15.boolean().optional()
2687
+ stop_hook_active: z16.boolean().optional()
2644
2688
  });
2645
2689
 
2646
2690
  // src/providers/claude/usage.ts
@@ -3071,6 +3115,37 @@ var extractClaudeAssistantText = (payload) => {
3071
3115
  return void 0;
3072
3116
  };
3073
3117
 
3118
+ // src/providers/claude/target.ts
3119
+ var PATH_FIELDS = Object.freeze({
3120
+ Read: ["file_path"],
3121
+ Write: ["file_path"],
3122
+ Edit: ["file_path"],
3123
+ MultiEdit: ["file_path"],
3124
+ NotebookEdit: ["notebook_path"],
3125
+ NotebookRead: ["notebook_path"],
3126
+ // Optional on both: absent means "search the session's directory".
3127
+ Glob: ["path"],
3128
+ Grep: ["path"]
3129
+ });
3130
+ var asRecord4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
3131
+ var claudeTargetHint = (toolName, toolInput, cwd) => {
3132
+ const fields = Object.hasOwn(PATH_FIELDS, toolName) ? PATH_FIELDS[toolName] : void 0;
3133
+ const input = asRecord4(toolInput);
3134
+ if (fields !== void 0 && input !== void 0) {
3135
+ for (const field of fields) {
3136
+ const candidate = input[field];
3137
+ if (typeof candidate === "string" && candidate.length > 0) {
3138
+ return {
3139
+ source: "tool-path",
3140
+ paths: [candidate],
3141
+ ...cwd === void 0 ? {} : { baseDirectory: cwd }
3142
+ };
3143
+ }
3144
+ }
3145
+ }
3146
+ return cwd === void 0 ? void 0 : { source: "session-cwd", paths: [cwd] };
3147
+ };
3148
+
3074
3149
  // src/providers/claude/tool-kind.ts
3075
3150
  var BUILT_IN_TOOL_KIND = Object.freeze({
3076
3151
  Bash: "execute",
@@ -3150,9 +3225,16 @@ var parseClaudeCode = (input, context) => {
3150
3225
  const factory = createEventFactory({
3151
3226
  identity: input.identity,
3152
3227
  sequenceBase: input.sequenceBase,
3153
- context
3228
+ context,
3229
+ // Present exactly when the hook fired inside a subagent (or describes one,
3230
+ // on SubagentStart/SubagentStop).
3231
+ ...payload.agent_id === void 0 ? {} : { subagentId: payload.agent_id }
3154
3232
  });
3155
3233
  const warnings = [];
3234
+ const targetHintFor = (toolName, toolInput) => {
3235
+ const hint = claudeTargetHint(toolName, toolInput, payload.cwd);
3236
+ return hint === void 0 ? {} : { targetHint: hint };
3237
+ };
3156
3238
  const withUsage = (usage) => {
3157
3239
  const normalized = normalizeClaudeUsage(usage);
3158
3240
  warnings.push(...normalized.warnings);
@@ -3187,6 +3269,7 @@ var parseClaudeCode = (input, context) => {
3187
3269
  toolCallId: payload.tool_use_id,
3188
3270
  toolName: payload.tool_name,
3189
3271
  toolKind: inferToolKind(payload.tool_name),
3272
+ ...targetHintFor(payload.tool_name, payload.tool_input),
3190
3273
  ...payload.tool_input === void 0 ? {} : {
3191
3274
  input: context.privacy.describeStructured({
3192
3275
  kind: "tool-input",
@@ -3202,6 +3285,7 @@ var parseClaudeCode = (input, context) => {
3202
3285
  toolCallId: payload.tool_use_id,
3203
3286
  toolName: payload.tool_name,
3204
3287
  outcome: "ok",
3288
+ ...targetHintFor(payload.tool_name, payload.tool_input),
3205
3289
  output: context.privacy.describeStructured({
3206
3290
  kind: "tool-output",
3207
3291
  value: payload.tool_response,
@@ -3215,6 +3299,7 @@ var parseClaudeCode = (input, context) => {
3215
3299
  toolCallId: payload.tool_use_id,
3216
3300
  toolName: payload.tool_name,
3217
3301
  outcome: "error",
3302
+ ...targetHintFor(payload.tool_name, payload.tool_input),
3218
3303
  output: context.privacy.describeStructured({
3219
3304
  kind: "tool-output",
3220
3305
  value: payload.tool_error,
@@ -3313,10 +3398,12 @@ var parseClaudeCode = (input, context) => {
3313
3398
  break;
3314
3399
  }
3315
3400
  }
3401
+ const targetHints = factory.targetHints();
3316
3402
  return {
3317
3403
  status: "parsed",
3318
3404
  events: factory.events(),
3319
- ...warnings.length === 0 ? {} : { warnings }
3405
+ ...warnings.length === 0 ? {} : { warnings },
3406
+ ...targetHints.size === 0 ? {} : { targetHints }
3320
3407
  };
3321
3408
  };
3322
3409
 
@@ -3334,7 +3421,7 @@ var createClaudeCodeAdapter = (options = {}) => ({
3334
3421
  });
3335
3422
 
3336
3423
  // src/providers/cursor/payload.ts
3337
- import { z as z16 } from "zod";
3424
+ import { z as z17 } from "zod";
3338
3425
  var CURSOR_PROVIDER_ID = "cursor";
3339
3426
  var CURSOR_HOOK_EVENT_NAMES = [
3340
3427
  "sessionStart",
@@ -3369,23 +3456,23 @@ var CURSOR_DECISION_EVENTS = Object.freeze({
3369
3456
  subagentStart: "permission",
3370
3457
  beforeSubmitPrompt: "continue"
3371
3458
  });
3372
- var modelParamSchema = z16.object({
3373
- id: z16.string(),
3374
- value: z16.string()
3459
+ var modelParamSchema = z17.object({
3460
+ id: z17.string(),
3461
+ value: z17.string()
3375
3462
  });
3376
- var attachmentSchema = z16.object({
3377
- type: z16.string().optional(),
3378
- file_path: z16.string().optional()
3463
+ var attachmentSchema = z17.object({
3464
+ type: z17.string().optional(),
3465
+ file_path: z17.string().optional()
3379
3466
  });
3380
- var fileEditSchema = z16.object({
3381
- old_string: z16.string().optional(),
3382
- new_string: z16.string().optional()
3467
+ var fileEditSchema = z17.object({
3468
+ old_string: z17.string().optional(),
3469
+ new_string: z17.string().optional()
3383
3470
  });
3384
3471
  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()
3472
+ input_tokens: z17.number().int().min(0).optional(),
3473
+ output_tokens: z17.number().int().min(0).optional(),
3474
+ cache_read_tokens: z17.number().int().min(0).optional(),
3475
+ cache_write_tokens: z17.number().int().min(0).optional()
3389
3476
  };
3390
3477
  var envelopeShape = {
3391
3478
  // Not `.min(1)`: see `cursorSessionId`. A payload naming neither
@@ -3393,136 +3480,136 @@ var envelopeShape = {
3393
3480
  // `recognizeCursorPayload`'s post-parse check — but rejecting it here would
3394
3481
  // fail the whole discriminated union on a field the adapter can source from
3395
3482
  // 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(),
3483
+ conversation_id: z17.string().optional(),
3484
+ generation_id: z17.string().optional(),
3485
+ session_id: z17.string().optional(),
3486
+ model: z17.string().optional(),
3487
+ model_id: z17.string().optional(),
3488
+ model_params: z17.array(modelParamSchema).max(64).optional(),
3489
+ cursor_version: z17.string().optional(),
3490
+ workspace_roots: z17.array(z17.string()).max(64).optional(),
3491
+ cwd: z17.string().optional(),
3405
3492
  /** Never propagated. */
3406
- user_email: z16.string().nullish(),
3493
+ user_email: z17.string().nullish(),
3407
3494
  /** Never propagated. */
3408
- transcript_path: z16.string().nullish()
3495
+ transcript_path: z17.string().nullish()
3409
3496
  };
3410
- var event2 = (name, shape) => z16.object({ ...envelopeShape, hook_event_name: z16.literal(name), ...shape });
3497
+ var event2 = (name, shape) => z17.object({ ...envelopeShape, hook_event_name: z17.literal(name), ...shape });
3411
3498
  var sessionStartPayloadSchema2 = event2("sessionStart", {
3412
- is_background_agent: z16.boolean().optional(),
3413
- composer_mode: z16.string().optional()
3499
+ is_background_agent: z17.boolean().optional(),
3500
+ composer_mode: z17.string().optional()
3414
3501
  });
3415
3502
  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()
3503
+ reason: z17.string().optional(),
3504
+ duration_ms: z17.number().min(0).optional(),
3505
+ is_background_agent: z17.boolean().optional(),
3506
+ final_status: z17.string().optional(),
3507
+ error_message: z17.string().optional()
3421
3508
  });
3422
3509
  var beforeSubmitPromptPayloadSchema = event2("beforeSubmitPrompt", {
3423
- prompt: z16.string().optional(),
3424
- attachments: z16.array(attachmentSchema).max(256).optional(),
3425
- composer_mode: z16.string().optional()
3510
+ prompt: z17.string().optional(),
3511
+ attachments: z17.array(attachmentSchema).max(256).optional(),
3512
+ composer_mode: z17.string().optional()
3426
3513
  });
3427
3514
  var afterAgentResponsePayloadSchema = event2("afterAgentResponse", {
3428
- text: z16.string().optional(),
3515
+ text: z17.string().optional(),
3429
3516
  ...usageFields
3430
3517
  });
3431
3518
  var afterAgentThoughtPayloadSchema = event2("afterAgentThought", {
3432
- text: z16.string().optional(),
3433
- duration_ms: z16.number().min(0).optional()
3519
+ text: z17.string().optional(),
3520
+ duration_ms: z17.number().min(0).optional()
3434
3521
  });
3435
3522
  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()
3523
+ tool_name: z17.string().min(1),
3524
+ tool_input: z17.unknown().optional(),
3525
+ tool_use_id: z17.string().optional(),
3526
+ agent_message: z17.string().optional()
3440
3527
  });
3441
3528
  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()
3529
+ tool_name: z17.string().min(1),
3530
+ tool_input: z17.unknown().optional(),
3531
+ tool_output: z17.unknown().optional(),
3532
+ tool_use_id: z17.string().optional(),
3533
+ duration: z17.number().min(0).optional()
3447
3534
  });
3448
3535
  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()
3536
+ tool_name: z17.string().min(1),
3537
+ tool_input: z17.unknown().optional(),
3538
+ tool_use_id: z17.string().optional(),
3539
+ error_message: z17.string().optional(),
3540
+ failure_type: z17.string().optional(),
3541
+ duration: z17.number().min(0).optional(),
3542
+ is_interrupt: z17.boolean().optional()
3456
3543
  });
3457
3544
  var beforeShellExecutionPayloadSchema = event2("beforeShellExecution", {
3458
- command: z16.string(),
3459
- sandbox: z16.boolean().optional()
3545
+ command: z17.string(),
3546
+ sandbox: z17.boolean().optional()
3460
3547
  });
3461
3548
  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()
3549
+ command: z17.string(),
3550
+ output: z17.string().optional(),
3551
+ duration: z17.number().min(0).optional(),
3552
+ sandbox: z17.boolean().optional()
3466
3553
  });
3467
3554
  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()
3555
+ tool_name: z17.string().min(1),
3556
+ tool_input: z17.unknown().optional(),
3557
+ url: z17.string().optional(),
3558
+ command: z17.string().optional()
3472
3559
  });
3473
3560
  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()
3561
+ tool_name: z17.string().min(1),
3562
+ tool_input: z17.unknown().optional(),
3563
+ result_json: z17.string().optional(),
3564
+ duration: z17.number().min(0).optional()
3478
3565
  });
3479
3566
  var beforeReadFilePayloadSchema = event2("beforeReadFile", {
3480
- file_path: z16.string(),
3481
- content: z16.string().optional(),
3482
- attachments: z16.array(attachmentSchema).max(256).optional()
3567
+ file_path: z17.string(),
3568
+ content: z17.string().optional(),
3569
+ attachments: z17.array(attachmentSchema).max(256).optional()
3483
3570
  });
3484
3571
  var afterFileEditPayloadSchema = event2("afterFileEdit", {
3485
- file_path: z16.string(),
3486
- edits: z16.array(fileEditSchema).max(1024).optional()
3572
+ file_path: z17.string(),
3573
+ edits: z17.array(fileEditSchema).max(1024).optional()
3487
3574
  });
3488
3575
  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()
3576
+ subagent_id: z17.string().optional(),
3577
+ subagent_type: z17.string().optional(),
3578
+ task: z17.string().optional(),
3579
+ parent_conversation_id: z17.string().optional(),
3580
+ tool_call_id: z17.string().optional(),
3581
+ subagent_model: z17.string().optional(),
3582
+ is_parallel_worker: z17.boolean().optional(),
3583
+ git_branch: z17.string().optional()
3497
3584
  });
3498
3585
  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()
3586
+ subagent_type: z17.string().optional(),
3587
+ status: z17.string().optional(),
3588
+ task: z17.string().optional(),
3589
+ description: z17.string().optional(),
3590
+ summary: z17.string().optional(),
3591
+ duration_ms: z17.number().min(0).optional(),
3592
+ message_count: z17.number().int().min(0).optional(),
3593
+ tool_call_count: z17.number().int().min(0).optional(),
3594
+ loop_count: z17.number().int().min(0).optional(),
3595
+ modified_files: z17.array(z17.string()).max(1024).optional(),
3596
+ agent_transcript_path: z17.string().nullish()
3510
3597
  });
3511
3598
  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()
3599
+ trigger: z17.string().optional(),
3600
+ context_usage_percent: z17.number().optional(),
3601
+ context_tokens: z17.number().int().min(0).optional(),
3602
+ context_window_size: z17.number().int().min(0).optional(),
3603
+ message_count: z17.number().int().min(0).optional(),
3604
+ messages_to_compact: z17.number().int().min(0).optional(),
3605
+ is_first_compaction: z17.boolean().optional()
3519
3606
  });
3520
3607
  var stopPayloadSchema2 = event2("stop", {
3521
- status: z16.string().optional(),
3522
- loop_count: z16.number().int().min(0).optional(),
3608
+ status: z17.string().optional(),
3609
+ loop_count: z17.number().int().min(0).optional(),
3523
3610
  ...usageFields
3524
3611
  });
3525
- var cursorPayloadSchema = z16.discriminatedUnion("hook_event_name", [
3612
+ var cursorPayloadSchema = z17.discriminatedUnion("hook_event_name", [
3526
3613
  sessionStartPayloadSchema2,
3527
3614
  sessionEndPayloadSchema2,
3528
3615
  beforeSubmitPromptPayloadSchema,
@@ -3659,6 +3746,33 @@ var cursorDeliveryIdentity = (input) => {
3659
3746
  };
3660
3747
  };
3661
3748
 
3749
+ // src/providers/cursor/target.ts
3750
+ var singleWorkspaceRoot = (payload) => {
3751
+ const roots = (payload.workspace_roots ?? []).filter((root) => root.length > 0);
3752
+ return roots.length === 1 ? roots[0] : void 0;
3753
+ };
3754
+ var sessionHint = (root) => root === void 0 ? void 0 : { source: "session-cwd", paths: [root] };
3755
+ var cursorTargetHint = (payload) => {
3756
+ const root = singleWorkspaceRoot(payload);
3757
+ const base = root === void 0 ? {} : { baseDirectory: root };
3758
+ switch (payload.hook_event_name) {
3759
+ case "afterFileEdit":
3760
+ case "beforeReadFile":
3761
+ return payload.file_path.length === 0 ? sessionHint(root) : { source: "tool-path", paths: [payload.file_path], ...base };
3762
+ case "beforeShellExecution":
3763
+ case "afterShellExecution":
3764
+ return payload.cwd !== void 0 && payload.cwd.length > 0 ? { source: "shell-cwd", paths: [payload.cwd], ...base } : sessionHint(root);
3765
+ case "preToolUse":
3766
+ case "postToolUse":
3767
+ case "postToolUseFailure":
3768
+ case "beforeMCPExecution":
3769
+ case "afterMCPExecution":
3770
+ return sessionHint(root);
3771
+ default:
3772
+ return void 0;
3773
+ }
3774
+ };
3775
+
3662
3776
  // src/providers/cursor/usage.ts
3663
3777
  var normalizeCursorUsage = (raw) => {
3664
3778
  const inputTokens = raw.input_tokens;
@@ -3914,12 +4028,6 @@ var createCursorAdapter = (options = {}) => {
3914
4028
  reason: "afterAgentThought is a reasoning notification, not a generation lifecycle event; no canonical event type represents it and thought text is never exported"
3915
4029
  };
3916
4030
  }
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
4031
  if (payload.hook_event_name === "subagentStart" || payload.hook_event_name === "subagentStop") {
3924
4032
  return {
3925
4033
  status: "ignored",
@@ -3934,6 +4042,8 @@ var createCursorAdapter = (options = {}) => {
3934
4042
  const warnings = [];
3935
4043
  const sessionId = input.identity.sessionId;
3936
4044
  const model = toModelDescriptor(payload);
4045
+ const targetHint = cursorTargetHint(payload);
4046
+ const targetHintField = targetHint === void 0 ? {} : { targetHint };
3937
4047
  switch (payload.hook_event_name) {
3938
4048
  case "sessionStart":
3939
4049
  factory.build({
@@ -3986,6 +4096,7 @@ var createCursorAdapter = (options = {}) => {
3986
4096
  case "preToolUse":
3987
4097
  factory.build({
3988
4098
  type: "tool.start",
4099
+ ...targetHintField,
3989
4100
  toolCallId: payload.tool_use_id ?? derivedToolCallId(context, sessionId, [
3990
4101
  "tool",
3991
4102
  payload.generation_id ?? "",
@@ -4009,6 +4120,7 @@ var createCursorAdapter = (options = {}) => {
4009
4120
  case "postToolUse":
4010
4121
  factory.build({
4011
4122
  type: "tool.end",
4123
+ ...targetHintField,
4012
4124
  toolCallId: payload.tool_use_id ?? derivedToolCallId(context, sessionId, [
4013
4125
  "tool",
4014
4126
  payload.generation_id ?? "",
@@ -4031,6 +4143,7 @@ var createCursorAdapter = (options = {}) => {
4031
4143
  case "postToolUseFailure":
4032
4144
  factory.build({
4033
4145
  type: "tool.end",
4146
+ ...targetHintField,
4034
4147
  toolCallId: payload.tool_use_id ?? derivedToolCallId(context, sessionId, [
4035
4148
  "tool",
4036
4149
  payload.generation_id ?? "",
@@ -4051,6 +4164,7 @@ var createCursorAdapter = (options = {}) => {
4051
4164
  case "beforeShellExecution":
4052
4165
  factory.build({
4053
4166
  type: "tool.start",
4167
+ ...targetHintField,
4054
4168
  toolCallId: derivedToolCallId(context, sessionId, [
4055
4169
  "shell",
4056
4170
  payload.generation_id ?? "",
@@ -4070,6 +4184,7 @@ var createCursorAdapter = (options = {}) => {
4070
4184
  case "afterShellExecution":
4071
4185
  factory.build({
4072
4186
  type: "tool.end",
4187
+ ...targetHintField,
4073
4188
  toolCallId: derivedToolCallId(context, sessionId, [
4074
4189
  "shell",
4075
4190
  payload.generation_id ?? "",
@@ -4094,6 +4209,7 @@ var createCursorAdapter = (options = {}) => {
4094
4209
  case "beforeMCPExecution":
4095
4210
  factory.build({
4096
4211
  type: "tool.start",
4212
+ ...targetHintField,
4097
4213
  toolCallId: derivedToolCallId(context, sessionId, [
4098
4214
  "mcp",
4099
4215
  payload.generation_id ?? "",
@@ -4114,6 +4230,7 @@ var createCursorAdapter = (options = {}) => {
4114
4230
  case "afterMCPExecution":
4115
4231
  factory.build({
4116
4232
  type: "tool.end",
4233
+ ...targetHintField,
4117
4234
  toolCallId: derivedToolCallId(context, sessionId, [
4118
4235
  "mcp",
4119
4236
  payload.generation_id ?? "",
@@ -4141,6 +4258,7 @@ var createCursorAdapter = (options = {}) => {
4141
4258
  ]);
4142
4259
  factory.build({
4143
4260
  type: "tool.start",
4261
+ ...targetHintField,
4144
4262
  toolCallId,
4145
4263
  toolName: "edit_file",
4146
4264
  toolKind: "write",
@@ -4153,6 +4271,7 @@ var createCursorAdapter = (options = {}) => {
4153
4271
  });
4154
4272
  factory.build({
4155
4273
  type: "tool.end",
4274
+ ...targetHintField,
4156
4275
  toolCallId,
4157
4276
  toolName: "edit_file",
4158
4277
  outcome: "ok",
@@ -4162,6 +4281,34 @@ var createCursorAdapter = (options = {}) => {
4162
4281
  });
4163
4282
  break;
4164
4283
  }
4284
+ case "beforeReadFile": {
4285
+ const toolCallId = derivedToolCallId(context, sessionId, [
4286
+ "read-file",
4287
+ payload.generation_id ?? "",
4288
+ payload.file_path
4289
+ ]);
4290
+ factory.build({
4291
+ type: "tool.start",
4292
+ ...targetHintField,
4293
+ toolCallId,
4294
+ toolName: "read_file",
4295
+ toolKind: "read",
4296
+ ...payload.generation_id === void 0 || payload.generation_id.length === 0 ? {} : { generationId: payload.generation_id },
4297
+ input: context.privacy.describeContent({
4298
+ kind: "tool-input",
4299
+ text: payload.file_path,
4300
+ label: "read_file"
4301
+ })
4302
+ });
4303
+ factory.build({
4304
+ type: "tool.end",
4305
+ ...targetHintField,
4306
+ toolCallId,
4307
+ toolName: "read_file",
4308
+ outcome: "unknown"
4309
+ });
4310
+ break;
4311
+ }
4165
4312
  case "preCompact":
4166
4313
  factory.build({
4167
4314
  type: "compaction.performed",
@@ -4199,10 +4346,12 @@ var createCursorAdapter = (options = {}) => {
4199
4346
  break;
4200
4347
  }
4201
4348
  }
4349
+ const targetHints = factory.targetHints();
4202
4350
  return {
4203
4351
  status: "parsed",
4204
4352
  events: factory.events(),
4205
- ...warnings.length === 0 ? {} : { warnings }
4353
+ ...warnings.length === 0 ? {} : { warnings },
4354
+ ...targetHints.size === 0 ? {} : { targetHints }
4206
4355
  };
4207
4356
  };
4208
4357
  const hookResponse2 = (input) => {
@@ -4233,105 +4382,105 @@ var createCursorAdapter = (options = {}) => {
4233
4382
  };
4234
4383
 
4235
4384
  // src/providers/codex/payload.ts
4236
- import { z as z17 } from "zod";
4237
- var permissionModeSchema = z17.enum([
4385
+ import { z as z18 } from "zod";
4386
+ var permissionModeSchema = z18.enum([
4238
4387
  "default",
4239
4388
  "acceptEdits",
4240
4389
  "plan",
4241
4390
  "dontAsk",
4242
4391
  "bypassPermissions"
4243
4392
  ]);
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()
4393
+ var codexUsageSchema = z18.object({
4394
+ input_tokens: z18.number().int().min(0).optional(),
4395
+ cached_input_tokens: z18.number().int().min(0).optional(),
4396
+ output_tokens: z18.number().int().min(0).optional(),
4397
+ reasoning_output_tokens: z18.number().int().min(0).optional(),
4398
+ total_tokens: z18.number().int().min(0).optional()
4250
4399
  });
4251
4400
  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(),
4401
+ session_id: z18.string().min(1).max(256),
4402
+ cwd: z18.string().min(1).max(4096).optional(),
4403
+ model: z18.string().min(1).max(256).optional(),
4255
4404
  permission_mode: permissionModeSchema.optional(),
4256
- transcript_path: z17.string().min(1).max(4096).optional(),
4257
- codex_version: z17.string().min(1).max(64).optional(),
4405
+ transcript_path: z18.string().min(1).max(4096).optional(),
4406
+ codex_version: z18.string().min(1).max(64).optional(),
4258
4407
  /** Not part of the documented protocol; lets tests and replay stay deterministic. */
4259
- occurred_at: z17.number().int().min(0).optional()
4408
+ occurred_at: z18.number().int().min(0).optional()
4260
4409
  };
4261
- var codexSessionStartPayloadSchema = z17.object({
4410
+ var codexSessionStartPayloadSchema = z18.object({
4262
4411
  ...baseFields,
4263
- hook_event_name: z17.literal("SessionStart"),
4264
- source: z17.enum(["startup", "resume", "clear", "compact"]).optional()
4412
+ hook_event_name: z18.literal("SessionStart"),
4413
+ source: z18.enum(["startup", "resume", "clear", "compact"]).optional()
4265
4414
  });
4266
- var codexUserPromptSubmitPayloadSchema = z17.object({
4415
+ var codexUserPromptSubmitPayloadSchema = z18.object({
4267
4416
  ...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()
4417
+ hook_event_name: z18.literal("UserPromptSubmit"),
4418
+ turn_id: z18.string().min(1).max(256).optional(),
4419
+ prompt: z18.string().max(1e6).optional()
4271
4420
  });
4272
- var codexPreToolUsePayloadSchema = z17.object({
4421
+ var codexPreToolUsePayloadSchema = z18.object({
4273
4422
  ...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()
4423
+ hook_event_name: z18.literal("PreToolUse"),
4424
+ turn_id: z18.string().min(1).max(256).optional(),
4425
+ tool_name: z18.string().min(1).max(256),
4426
+ tool_call_id: z18.string().min(1).max(256).optional(),
4427
+ tool_input: z18.unknown().optional()
4279
4428
  });
4280
- var codexPermissionRequestPayloadSchema = z17.object({
4429
+ var codexPermissionRequestPayloadSchema = z18.object({
4281
4430
  ...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()
4431
+ hook_event_name: z18.literal("PermissionRequest"),
4432
+ turn_id: z18.string().min(1).max(256).optional(),
4433
+ tool_name: z18.string().min(1).max(256).optional(),
4434
+ tool_call_id: z18.string().min(1).max(256).optional(),
4435
+ tool_input: z18.unknown().optional()
4287
4436
  });
4288
- var codexPostToolUsePayloadSchema = z17.object({
4437
+ var codexPostToolUsePayloadSchema = z18.object({
4289
4438
  ...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()
4439
+ hook_event_name: z18.literal("PostToolUse"),
4440
+ turn_id: z18.string().min(1).max(256).optional(),
4441
+ tool_name: z18.string().min(1).max(256),
4442
+ tool_call_id: z18.string().min(1).max(256).optional(),
4443
+ tool_input: z18.unknown().optional(),
4444
+ tool_response: z18.unknown().optional(),
4445
+ permission_decision: z18.enum(["allowed", "denied", "deferred"]).optional(),
4446
+ duration_ms: z18.number().min(0).optional()
4298
4447
  });
4299
- var codexPreCompactPayloadSchema = z17.object({
4448
+ var codexPreCompactPayloadSchema = z18.object({
4300
4449
  ...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()
4450
+ hook_event_name: z18.literal("PreCompact"),
4451
+ trigger: z18.enum(["auto", "manual"]).optional(),
4452
+ context_tokens_before: z18.number().int().min(0).optional()
4304
4453
  });
4305
- var codexPostCompactPayloadSchema = z17.object({
4454
+ var codexPostCompactPayloadSchema = z18.object({
4306
4455
  ...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(),
4456
+ hook_event_name: z18.literal("PostCompact"),
4457
+ trigger: z18.enum(["auto", "manual"]).optional(),
4458
+ context_tokens_after: z18.number().int().min(0).optional(),
4459
+ dropped_message_count: z18.number().int().min(0).optional(),
4311
4460
  usage: codexUsageSchema.optional()
4312
4461
  });
4313
- var codexSubagentStartPayloadSchema = z17.object({
4462
+ var codexSubagentStartPayloadSchema = z18.object({
4314
4463
  ...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()
4464
+ hook_event_name: z18.literal("SubagentStart"),
4465
+ turn_id: z18.string().min(1).max(256).optional(),
4466
+ subagent_id: z18.string().min(1).max(256),
4467
+ subagent_type: z18.string().min(1).max(256).optional()
4319
4468
  });
4320
- var codexSubagentStopPayloadSchema = z17.object({
4469
+ var codexSubagentStopPayloadSchema = z18.object({
4321
4470
  ...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(),
4471
+ hook_event_name: z18.literal("SubagentStop"),
4472
+ turn_id: z18.string().min(1).max(256).optional(),
4473
+ subagent_id: z18.string().min(1).max(256),
4474
+ status: z18.enum(["completed", "failed", "cancelled"]).optional(),
4326
4475
  usage: codexUsageSchema.optional()
4327
4476
  });
4328
- var codexStopPayloadSchema = z17.object({
4477
+ var codexStopPayloadSchema = z18.object({
4329
4478
  ...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(),
4479
+ hook_event_name: z18.literal("Stop"),
4480
+ turn_id: z18.string().min(1).max(256).optional(),
4481
+ stop_reason: z18.string().min(1).max(256).optional(),
4333
4482
  usage: codexUsageSchema.optional(),
4334
- duration_ms: z17.number().min(0).optional()
4483
+ duration_ms: z18.number().min(0).optional()
4335
4484
  });
4336
4485
  var CODEX_HOOK_EVENT_NAMES = [
4337
4486
  "SessionStart",
@@ -4345,7 +4494,7 @@ var CODEX_HOOK_EVENT_NAMES = [
4345
4494
  "SubagentStop",
4346
4495
  "Stop"
4347
4496
  ];
4348
- var codexHookPayloadSchema = z17.discriminatedUnion("hook_event_name", [
4497
+ var codexHookPayloadSchema = z18.discriminatedUnion("hook_event_name", [
4349
4498
  codexSessionStartPayloadSchema,
4350
4499
  codexUserPromptSubmitPayloadSchema,
4351
4500
  codexPreToolUsePayloadSchema,
@@ -4357,9 +4506,9 @@ var codexHookPayloadSchema = z17.discriminatedUnion("hook_event_name", [
4357
4506
  codexSubagentStopPayloadSchema,
4358
4507
  codexStopPayloadSchema
4359
4508
  ]);
4360
- var codexHookEnvelopeSchema = z17.object({
4361
- session_id: z17.string().min(1),
4362
- hook_event_name: z17.enum(CODEX_HOOK_EVENT_NAMES)
4509
+ var codexHookEnvelopeSchema = z18.object({
4510
+ session_id: z18.string().min(1),
4511
+ hook_event_name: z18.enum(CODEX_HOOK_EVENT_NAMES)
4363
4512
  });
4364
4513
 
4365
4514
  // src/providers/codex/delivery.ts
@@ -4420,6 +4569,61 @@ var codexDeliveryIdentity = (input) => {
4420
4569
  };
4421
4570
  };
4422
4571
 
4572
+ // src/providers/codex/target.ts
4573
+ var PATCH_HEADER = /^\*\*\* (?:Add File|Update File|Delete File|Move to): (.+)$/;
4574
+ var asRecord5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
4575
+ var nonEmptyString2 = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
4576
+ var commandText = (input) => {
4577
+ const command = input?.command ?? input?.cmd;
4578
+ if (typeof command === "string") {
4579
+ return command;
4580
+ }
4581
+ if (Array.isArray(command) && command.every((part) => typeof part === "string")) {
4582
+ return command.join(" ");
4583
+ }
4584
+ return void 0;
4585
+ };
4586
+ var patchHeaderPaths = (patch) => {
4587
+ const paths = /* @__PURE__ */ new Set();
4588
+ for (const line of patch.split(/\r?\n/)) {
4589
+ const match = PATCH_HEADER.exec(line.trimEnd());
4590
+ const named = match?.[1]?.trim();
4591
+ if (named !== void 0 && named.length > 0) {
4592
+ paths.add(named);
4593
+ }
4594
+ }
4595
+ return paths.size === 0 || paths.size > MAX_TARGET_HINT_PATHS ? void 0 : [...paths];
4596
+ };
4597
+ var patchTextOf = (toolName, input) => {
4598
+ if (typeof input === "string") {
4599
+ return /^apply[_-]?patch$/i.test(toolName) ? input : void 0;
4600
+ }
4601
+ const record = asRecord5(input);
4602
+ if (/^apply[_-]?patch$/i.test(toolName)) {
4603
+ return nonEmptyString2(record?.patch) ?? nonEmptyString2(record?.input) ?? commandText(record);
4604
+ }
4605
+ const command = commandText(record);
4606
+ return command !== void 0 && /^\s*apply_patch\b/.test(command) ? command : void 0;
4607
+ };
4608
+ var codexTargetHint = (toolName, toolInput, cwd) => {
4609
+ const record = asRecord5(toolInput);
4610
+ const workdir = nonEmptyString2(record?.workdir);
4611
+ const base = workdir ?? cwd;
4612
+ const patch = patchTextOf(toolName, toolInput);
4613
+ if (patch !== void 0) {
4614
+ const paths = patchHeaderPaths(patch);
4615
+ return paths === void 0 ? void 0 : { source: "tool-path", paths, ...base === void 0 ? {} : { baseDirectory: base } };
4616
+ }
4617
+ if (workdir !== void 0) {
4618
+ return {
4619
+ source: "shell-cwd",
4620
+ paths: [workdir],
4621
+ ...cwd === void 0 ? {} : { baseDirectory: cwd }
4622
+ };
4623
+ }
4624
+ return cwd === void 0 ? void 0 : { source: "session-cwd", paths: [cwd] };
4625
+ };
4626
+
4423
4627
  // src/providers/codex/tool-kind.ts
4424
4628
  var PATTERNS = [
4425
4629
  [/^(apply[_-]?patch|patch)$/i, "write"],
@@ -4484,7 +4688,7 @@ var CODEX_CAPABILITIES = Object.freeze({
4484
4688
  // compaction callbacks do not. See `./delivery.ts` for which and why.
4485
4689
  deliveryIdentifier: "partial"
4486
4690
  });
4487
- var asRecord4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
4691
+ var asRecord6 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
4488
4692
  var hasExactMarker = (payload) => {
4489
4693
  if (payload.codex_version !== void 0) {
4490
4694
  return true;
@@ -4577,7 +4781,7 @@ var outcomeFromToolResponse = (toolResponse) => {
4577
4781
  if (toolResponse === void 0) {
4578
4782
  return "unknown";
4579
4783
  }
4580
- const record = asRecord4(toolResponse);
4784
+ const record = asRecord6(toolResponse);
4581
4785
  if (record === void 0) {
4582
4786
  return "ok";
4583
4787
  }
@@ -4649,6 +4853,10 @@ var parse = (input, context) => {
4649
4853
  context
4650
4854
  });
4651
4855
  const warnings = [];
4856
+ const targetHintFor = (toolName, toolInput) => {
4857
+ const hint = codexTargetHint(toolName, toolInput, payload.cwd);
4858
+ return hint === void 0 ? {} : { targetHint: hint };
4859
+ };
4652
4860
  const buildUsage = (usage) => {
4653
4861
  if (usage === void 0) {
4654
4862
  return void 0;
@@ -4693,6 +4901,7 @@ var parse = (input, context) => {
4693
4901
  toolName: payload.tool_name,
4694
4902
  toolKind: classifyCodexToolKind(payload.tool_name),
4695
4903
  occurredAt,
4904
+ ...targetHintFor(payload.tool_name, payload.tool_input),
4696
4905
  ...payload.tool_input === void 0 ? {} : {
4697
4906
  input: context.privacy.describeStructured({
4698
4907
  kind: "tool-input",
@@ -4719,6 +4928,7 @@ var parse = (input, context) => {
4719
4928
  outcome,
4720
4929
  permissionDecision,
4721
4930
  occurredAt,
4931
+ ...targetHintFor(payload.tool_name, payload.tool_input),
4722
4932
  ...payload.duration_ms === void 0 ? {} : { durationMillis: payload.duration_ms },
4723
4933
  ...payload.tool_response === void 0 ? {} : {
4724
4934
  output: context.privacy.describeStructured({
@@ -4801,10 +5011,12 @@ var parse = (input, context) => {
4801
5011
  break;
4802
5012
  }
4803
5013
  }
5014
+ const targetHints = factory.targetHints();
4804
5015
  return {
4805
5016
  status: "parsed",
4806
5017
  events: factory.events(),
4807
- ...warnings.length === 0 ? {} : { warnings }
5018
+ ...warnings.length === 0 ? {} : { warnings },
5019
+ ...targetHints.size === 0 ? {} : { targetHints }
4808
5020
  };
4809
5021
  };
4810
5022
  var hookResponse = () => SILENT_HOOK_RESPONSE;
@@ -4911,7 +5123,7 @@ var geminiCorrelationSeed = (input) => {
4911
5123
  };
4912
5124
 
4913
5125
  // src/providers/gemini/schema.ts
4914
- import { z as z18 } from "zod";
5126
+ import { z as z19 } from "zod";
4915
5127
  var GEMINI_HOOK_EVENT_NAMES = [
4916
5128
  "SessionStart",
4917
5129
  "SessionEnd",
@@ -4925,113 +5137,113 @@ var GEMINI_HOOK_EVENT_NAMES = [
4925
5137
  "PreCompress",
4926
5138
  "Notification"
4927
5139
  ];
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()
5140
+ var baseHookInputSchema = z19.object({
5141
+ session_id: z19.string().min(1),
5142
+ transcript_path: z19.string().optional(),
5143
+ cwd: z19.string().optional(),
5144
+ timestamp: z19.string().min(1).optional()
5145
+ });
5146
+ var llmMessageSchema = z19.object({
5147
+ role: z19.enum(["user", "model", "system"]).optional(),
5148
+ content: z19.union([z19.string(), z19.array(z19.unknown())]).optional()
4937
5149
  }).loose();
4938
- var llmRequestConfigSchema = z18.object({
4939
- temperature: z18.number().optional(),
4940
- maxOutputTokens: z18.number().int().min(0).optional()
5150
+ var llmRequestConfigSchema = z19.object({
5151
+ temperature: z19.number().optional(),
5152
+ maxOutputTokens: z19.number().int().min(0).optional()
4941
5153
  }).loose();
4942
- var geminiLlmRequestSchema = z18.object({
4943
- model: z18.string().min(1).optional(),
4944
- messages: z18.array(llmMessageSchema).optional(),
5154
+ var geminiLlmRequestSchema = z19.object({
5155
+ model: z19.string().min(1).optional(),
5156
+ messages: z19.array(llmMessageSchema).optional(),
4945
5157
  config: llmRequestConfigSchema.optional(),
4946
- toolConfig: z18.unknown().optional()
5158
+ toolConfig: z19.unknown().optional()
4947
5159
  }).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()
5160
+ var geminiUsageMetadataSchema = z19.object({
5161
+ promptTokenCount: z19.number().int().min(0).optional(),
5162
+ cachedContentTokenCount: z19.number().int().min(0).optional(),
5163
+ candidatesTokenCount: z19.number().int().min(0).optional(),
5164
+ thoughtsTokenCount: z19.number().int().min(0).optional(),
5165
+ totalTokenCount: z19.number().int().min(0).optional()
4954
5166
  }).loose();
4955
- var geminiCandidateSchema = z18.object({
4956
- content: z18.object({
4957
- role: z18.string().optional(),
4958
- parts: z18.array(z18.unknown()).optional()
5167
+ var geminiCandidateSchema = z19.object({
5168
+ content: z19.object({
5169
+ role: z19.string().optional(),
5170
+ parts: z19.array(z19.unknown()).optional()
4959
5171
  }).loose().optional(),
4960
- finishReason: z18.string().optional(),
4961
- index: z18.number().int().min(0).optional()
5172
+ finishReason: z19.string().optional(),
5173
+ index: z19.number().int().min(0).optional()
4962
5174
  }).loose();
4963
- var geminiLlmResponseSchema = z18.object({
5175
+ var geminiLlmResponseSchema = z19.object({
4964
5176
  /** Whole-response text, set by the translator from `getResponseText`. */
4965
- text: z18.string().optional(),
4966
- candidates: z18.array(geminiCandidateSchema).optional(),
5177
+ text: z19.string().optional(),
5178
+ candidates: z19.array(geminiCandidateSchema).optional(),
4967
5179
  usageMetadata: geminiUsageMetadataSchema.optional()
4968
5180
  }).loose();
4969
- var geminiMcpContextSchema = z18.object({
4970
- server_name: z18.string().optional(),
4971
- tool_name: z18.string().optional()
5181
+ var geminiMcpContextSchema = z19.object({
5182
+ server_name: z19.string().optional(),
5183
+ tool_name: z19.string().optional()
4972
5184
  }).loose();
4973
- var geminiToolResponseSchema = z18.object({
4974
- llmContent: z18.unknown().optional(),
4975
- returnDisplay: z18.unknown().optional(),
4976
- error: z18.unknown().optional()
5185
+ var geminiToolResponseSchema = z19.object({
5186
+ llmContent: z19.unknown().optional(),
5187
+ returnDisplay: z19.unknown().optional(),
5188
+ error: z19.unknown().optional()
4977
5189
  }).loose();
4978
5190
  var sessionStartInputSchema = baseHookInputSchema.extend({
4979
- hook_event_name: z18.literal("SessionStart"),
4980
- source: z18.enum(["startup", "resume", "clear"]).optional()
5191
+ hook_event_name: z19.literal("SessionStart"),
5192
+ source: z19.enum(["startup", "resume", "clear"]).optional()
4981
5193
  });
4982
5194
  var sessionEndInputSchema = baseHookInputSchema.extend({
4983
- hook_event_name: z18.literal("SessionEnd"),
4984
- reason: z18.enum(["exit", "clear", "logout", "prompt_input_exit", "other"]).optional()
5195
+ hook_event_name: z19.literal("SessionEnd"),
5196
+ reason: z19.enum(["exit", "clear", "logout", "prompt_input_exit", "other"]).optional()
4985
5197
  });
4986
5198
  var beforeAgentInputSchema = baseHookInputSchema.extend({
4987
- hook_event_name: z18.literal("BeforeAgent"),
4988
- prompt: z18.string().optional()
5199
+ hook_event_name: z19.literal("BeforeAgent"),
5200
+ prompt: z19.string().optional()
4989
5201
  });
4990
5202
  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()
5203
+ hook_event_name: z19.literal("AfterAgent"),
5204
+ prompt: z19.string().optional(),
5205
+ prompt_response: z19.string().optional(),
5206
+ stop_hook_active: z19.boolean().optional()
4995
5207
  });
4996
5208
  var beforeModelInputSchema = baseHookInputSchema.extend({
4997
- hook_event_name: z18.literal("BeforeModel"),
5209
+ hook_event_name: z19.literal("BeforeModel"),
4998
5210
  llm_request: geminiLlmRequestSchema
4999
5211
  });
5000
5212
  var afterModelInputSchema = baseHookInputSchema.extend({
5001
- hook_event_name: z18.literal("AfterModel"),
5213
+ hook_event_name: z19.literal("AfterModel"),
5002
5214
  llm_request: geminiLlmRequestSchema,
5003
5215
  llm_response: geminiLlmResponseSchema
5004
5216
  });
5005
5217
  var beforeToolSelectionInputSchema = baseHookInputSchema.extend({
5006
- hook_event_name: z18.literal("BeforeToolSelection"),
5218
+ hook_event_name: z19.literal("BeforeToolSelection"),
5007
5219
  llm_request: geminiLlmRequestSchema
5008
5220
  });
5009
5221
  var beforeToolInputSchema = baseHookInputSchema.extend({
5010
- hook_event_name: z18.literal("BeforeTool"),
5011
- tool_name: z18.string().min(1),
5012
- tool_input: z18.unknown().optional(),
5222
+ hook_event_name: z19.literal("BeforeTool"),
5223
+ tool_name: z19.string().min(1),
5224
+ tool_input: z19.unknown().optional(),
5013
5225
  mcp_context: geminiMcpContextSchema.optional(),
5014
- original_request_name: z18.string().min(1).optional()
5226
+ original_request_name: z19.string().min(1).optional()
5015
5227
  });
5016
5228
  var afterToolInputSchema = baseHookInputSchema.extend({
5017
- hook_event_name: z18.literal("AfterTool"),
5018
- tool_name: z18.string().min(1),
5019
- tool_input: z18.unknown().optional(),
5229
+ hook_event_name: z19.literal("AfterTool"),
5230
+ tool_name: z19.string().min(1),
5231
+ tool_input: z19.unknown().optional(),
5020
5232
  tool_response: geminiToolResponseSchema.optional(),
5021
5233
  mcp_context: geminiMcpContextSchema.optional(),
5022
- original_request_name: z18.string().min(1).optional()
5234
+ original_request_name: z19.string().min(1).optional()
5023
5235
  });
5024
5236
  var preCompressInputSchema = baseHookInputSchema.extend({
5025
- hook_event_name: z18.literal("PreCompress"),
5026
- trigger: z18.enum(["auto", "manual"]).optional()
5237
+ hook_event_name: z19.literal("PreCompress"),
5238
+ trigger: z19.enum(["auto", "manual"]).optional()
5027
5239
  });
5028
5240
  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()
5241
+ hook_event_name: z19.literal("Notification"),
5242
+ notification_type: z19.string().optional(),
5243
+ message: z19.string().optional(),
5244
+ details: z19.unknown().optional()
5033
5245
  });
5034
- var geminiHookInputSchema = z18.discriminatedUnion("hook_event_name", [
5246
+ var geminiHookInputSchema = z19.discriminatedUnion("hook_event_name", [
5035
5247
  sessionStartInputSchema,
5036
5248
  sessionEndInputSchema,
5037
5249
  beforeAgentInputSchema,
@@ -5476,7 +5688,7 @@ var normalizeUsageOrWarn = (usage, warnings) => {
5476
5688
  };
5477
5689
 
5478
5690
  // src/providers/antigravity/payload.ts
5479
- import { z as z19 } from "zod";
5691
+ import { z as z20 } from "zod";
5480
5692
  var ANTIGRAVITY_HOOK_EVENT_NAMES = [
5481
5693
  "PreInvocation",
5482
5694
  "PostInvocation",
@@ -5484,48 +5696,48 @@ var ANTIGRAVITY_HOOK_EVENT_NAMES = [
5484
5696
  "PostToolUse",
5485
5697
  "Stop"
5486
5698
  ];
5487
- var hookEventNameSchema = z19.enum(ANTIGRAVITY_HOOK_EVENT_NAMES);
5488
- var antigravityWeakShapeSchema = z19.object({ hookEventName: hookEventNameSchema }).passthrough();
5699
+ var hookEventNameSchema = z20.enum(ANTIGRAVITY_HOOK_EVENT_NAMES);
5700
+ var antigravityWeakShapeSchema = z20.object({ hookEventName: hookEventNameSchema }).passthrough();
5489
5701
  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),
5702
+ conversationId: z20.string().min(1),
5703
+ workspacePaths: z20.array(z20.string().min(1)).max(64),
5704
+ invocationNum: z20.number().int().min(0),
5493
5705
  /** Never disclosed: a real filesystem path. Accepted, never propagated. */
5494
- transcriptPath: z19.string().min(1).optional(),
5706
+ transcriptPath: z20.string().min(1).optional(),
5495
5707
  /** Never disclosed: a real filesystem path. Accepted, never propagated. */
5496
- artifactDirectoryPath: z19.string().min(1).optional()
5708
+ artifactDirectoryPath: z20.string().min(1).optional()
5497
5709
  };
5498
- var preInvocationPayloadSchema = z19.object({
5499
- hookEventName: z19.literal("PreInvocation"),
5710
+ var preInvocationPayloadSchema = z20.object({
5711
+ hookEventName: z20.literal("PreInvocation"),
5500
5712
  ...commonFields2,
5501
- agentVersion: z19.string().min(1).optional()
5713
+ agentVersion: z20.string().min(1).optional()
5502
5714
  });
5503
- var postInvocationPayloadSchema = z19.object({
5504
- hookEventName: z19.literal("PostInvocation"),
5715
+ var postInvocationPayloadSchema = z20.object({
5716
+ hookEventName: z20.literal("PostInvocation"),
5505
5717
  ...commonFields2,
5506
- agentVersion: z19.string().min(1).optional()
5718
+ agentVersion: z20.string().min(1).optional()
5507
5719
  });
5508
- var preToolUsePayloadSchema3 = z19.object({
5509
- hookEventName: z19.literal("PreToolUse"),
5720
+ var preToolUsePayloadSchema3 = z20.object({
5721
+ hookEventName: z20.literal("PreToolUse"),
5510
5722
  ...commonFields2,
5511
- stepIdx: z19.number().int().min(0),
5512
- toolName: z19.string().min(1),
5513
- toolInput: z19.unknown().optional()
5723
+ stepIdx: z20.number().int().min(0),
5724
+ toolName: z20.string().min(1),
5725
+ toolInput: z20.unknown().optional()
5514
5726
  });
5515
- var postToolUsePayloadSchema3 = z19.object({
5516
- hookEventName: z19.literal("PostToolUse"),
5727
+ var postToolUsePayloadSchema3 = z20.object({
5728
+ hookEventName: z20.literal("PostToolUse"),
5517
5729
  ...commonFields2,
5518
- stepIdx: z19.number().int().min(0),
5519
- toolName: z19.string().min(1),
5520
- toolResponse: z19.unknown().optional(),
5521
- isError: z19.boolean().optional()
5730
+ stepIdx: z20.number().int().min(0),
5731
+ toolName: z20.string().min(1),
5732
+ toolResponse: z20.unknown().optional(),
5733
+ isError: z20.boolean().optional()
5522
5734
  });
5523
- var stopPayloadSchema3 = z19.object({
5524
- hookEventName: z19.literal("Stop"),
5735
+ var stopPayloadSchema3 = z20.object({
5736
+ hookEventName: z20.literal("Stop"),
5525
5737
  ...commonFields2,
5526
- fullyIdle: z19.boolean()
5738
+ fullyIdle: z20.boolean()
5527
5739
  });
5528
- var antigravityHookPayloadSchema = z19.discriminatedUnion("hookEventName", [
5740
+ var antigravityHookPayloadSchema = z20.discriminatedUnion("hookEventName", [
5529
5741
  preInvocationPayloadSchema,
5530
5742
  postInvocationPayloadSchema,
5531
5743
  preToolUsePayloadSchema3,
@@ -5839,15 +6051,15 @@ var describeProviderCatalog = (options = {}) => {
5839
6051
  };
5840
6052
 
5841
6053
  // 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}$/),
6054
+ import { z as z21 } from "zod";
6055
+ var appliedDeliverySchema = z21.strictObject({
6056
+ callbackId: z21.string().regex(/^[A-Za-z0-9_-]{1,128}$/),
5845
6057
  /** How many of that delivery's observations are folded in, counted from one. */
5846
- applications: z20.number().int().min(1).max(4096)
6058
+ applications: z21.number().int().min(1).max(4096)
5847
6059
  });
5848
- var stateValueSchema = z20.discriminatedUnion("kind", [
5849
- z20.strictObject({
5850
- kind: z20.literal("usage-cumulative"),
6060
+ var stateValueSchema = z21.discriminatedUnion("kind", [
6061
+ z21.strictObject({
6062
+ kind: z21.literal("usage-cumulative"),
5851
6063
  usage: canonicalUsageSchema,
5852
6064
  /**
5853
6065
  * Optional: absent on every record written before this field existed, which
@@ -5856,22 +6068,22 @@ var stateValueSchema = z20.discriminatedUnion("kind", [
5856
6068
  */
5857
6069
  appliedDelivery: appliedDeliverySchema.optional()
5858
6070
  }),
5859
- z20.strictObject({
5860
- kind: z20.literal("sequence"),
6071
+ z21.strictObject({
6072
+ kind: z21.literal("sequence"),
5861
6073
  next: sequenceNumberSchema
5862
6074
  }),
5863
- z20.strictObject({
5864
- kind: z20.literal("attributes"),
6075
+ z21.strictObject({
6076
+ kind: z21.literal("attributes"),
5865
6077
  attributes: attributesSchema
5866
6078
  })
5867
6079
  ]);
5868
- var stateRecordSchema = z20.strictObject({
6080
+ var stateRecordSchema = z21.strictObject({
5869
6081
  /** Incremented on each write; lets callers detect lost updates. */
5870
- revision: z20.number().int().min(0),
6082
+ revision: z21.number().int().min(0),
5871
6083
  updatedAt: epochMillisSchema,
5872
6084
  value: stateValueSchema
5873
6085
  });
5874
- var logLevelSchema = z20.enum(["silent", "error", "warn", "info", "debug"]);
6086
+ var logLevelSchema = z21.enum(["silent", "error", "warn", "info", "debug"]);
5875
6087
  var LOG_LEVEL_RANK = Object.freeze({
5876
6088
  silent: 0,
5877
6089
  error: 1,
@@ -6143,7 +6355,94 @@ var resolveDeliveryIdentity = (input) => {
6143
6355
  };
6144
6356
 
6145
6357
  // src/runtime/hook.ts
6146
- import { z as z21 } from "zod";
6358
+ import { z as z22 } from "zod";
6359
+
6360
+ // src/runtime/target-resolution.ts
6361
+ import * as path from "path";
6362
+ var DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS = 50;
6363
+ var absolutePathsOf = (hint) => {
6364
+ const base = hint.baseDirectory !== void 0 && path.isAbsolute(hint.baseDirectory) ? hint.baseDirectory : void 0;
6365
+ const resolved = [];
6366
+ for (const candidate of hint.paths) {
6367
+ if (path.isAbsolute(candidate)) {
6368
+ resolved.push(path.resolve(candidate));
6369
+ } else if (base !== void 0) {
6370
+ resolved.push(path.resolve(base, candidate));
6371
+ } else {
6372
+ return void 0;
6373
+ }
6374
+ }
6375
+ return resolved;
6376
+ };
6377
+ var resolveHint = async (hint, locator, privacy) => {
6378
+ const paths = absolutePathsOf(hint);
6379
+ if (paths === void 0) {
6380
+ return void 0;
6381
+ }
6382
+ const located = await Promise.all(
6383
+ [...new Set(paths)].map((candidate) => locator.locate(candidate))
6384
+ );
6385
+ const [first] = located;
6386
+ if (first === void 0 || located.some((entry) => entry?.root !== first.root)) {
6387
+ return void 0;
6388
+ }
6389
+ const identity = deriveWorkspaceIdentity(
6390
+ privacy,
6391
+ { kind: "git-root", absolutePath: first.root },
6392
+ first.branch === void 0 ? {} : { vcsBranchName: first.branch }
6393
+ );
6394
+ if (identity.keySource !== "git-root") {
6395
+ return void 0;
6396
+ }
6397
+ const parsed = workspaceTargetSchema.safeParse({
6398
+ workspaceId: identity.workspaceId,
6399
+ ...identity.vcsBranchName === void 0 ? {} : { vcsBranchName: identity.vcsBranchName },
6400
+ source: hint.source
6401
+ });
6402
+ return parsed.success ? parsed.data : void 0;
6403
+ };
6404
+ var resolveEventTargets = async (input) => {
6405
+ const pending = input.events.filter(
6406
+ (event3) => (event3.type === "tool.start" || event3.type === "tool.end") && input.hints.has(event3.eventId)
6407
+ );
6408
+ if (pending.length === 0) {
6409
+ return { events: input.events, resolved: 0, timedOut: false };
6410
+ }
6411
+ const targets = /* @__PURE__ */ new Map();
6412
+ const work = Promise.all(
6413
+ pending.map(async (event3) => {
6414
+ const hint = input.hints.get(event3.eventId);
6415
+ if (hint === void 0) {
6416
+ return;
6417
+ }
6418
+ try {
6419
+ const target = await resolveHint(hint, input.locator, input.privacy);
6420
+ if (target !== void 0) {
6421
+ targets.set(event3.eventId, target);
6422
+ }
6423
+ } catch {
6424
+ }
6425
+ })
6426
+ ).then(() => "done");
6427
+ let timer;
6428
+ const deadline = new Promise((resolve5) => {
6429
+ timer = setTimeout(() => resolve5("timeout"), Math.max(0, input.budgetMillis));
6430
+ timer.unref?.();
6431
+ });
6432
+ const finished = await Promise.race([work, deadline]);
6433
+ if (timer !== void 0) {
6434
+ clearTimeout(timer);
6435
+ }
6436
+ const settled = new Map(targets);
6437
+ const events = input.events.map((event3) => {
6438
+ const target = settled.get(event3.eventId);
6439
+ if (target === void 0 || event3.type !== "tool.start" && event3.type !== "tool.end") {
6440
+ return event3;
6441
+ }
6442
+ return { ...event3, target };
6443
+ });
6444
+ return { events, resolved: settled.size, timedOut: finished === "timeout" };
6445
+ };
6147
6446
 
6148
6447
  // src/state/async-lock.ts
6149
6448
  var LockWaitTimeoutError = class extends Error {
@@ -6225,7 +6524,7 @@ var withOptionalSessionLock = async (store, sessionId, fn, options) => {
6225
6524
  };
6226
6525
 
6227
6526
  // src/runtime/hook.ts
6228
- var usageScopeSchema = z21.enum(["session", "generation", "subagent"]);
6527
+ var usageScopeSchema = z22.enum(["session", "generation", "subagent"]);
6229
6528
  var classifyDurability = (input) => {
6230
6529
  if (!input.attempted) {
6231
6530
  return "nothing-to-deliver";
@@ -6764,7 +7063,12 @@ var createOtelHook = (deps) => {
6764
7063
  );
6765
7064
  }
6766
7065
  }
6767
- return { kind: "ready", batch: batch2, dropped: screened.dropped };
7066
+ return {
7067
+ kind: "ready",
7068
+ batch: batch2,
7069
+ dropped: screened.dropped,
7070
+ ...parsed.targetHints === void 0 ? {} : { targetHints: parsed.targetHints }
7071
+ };
6768
7072
  };
6769
7073
  let prepared;
6770
7074
  try {
@@ -6809,7 +7113,24 @@ var createOtelHook = (deps) => {
6809
7113
  if (prepared.kind === "early") {
6810
7114
  return prepared.outcome;
6811
7115
  }
6812
- const { batch, dropped } = prepared;
7116
+ const { dropped } = prepared;
7117
+ let batch = prepared.batch;
7118
+ if (!suppress && deps.worktreeLocator !== void 0 && prepared.targetHints !== void 0 && prepared.targetHints.size > 0) {
7119
+ const targeted = await resolveEventTargets({
7120
+ events: batch,
7121
+ hints: prepared.targetHints,
7122
+ locator: deps.worktreeLocator,
7123
+ privacy,
7124
+ budgetMillis: deps.targetResolutionBudgetMillis ?? DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS
7125
+ });
7126
+ batch = targeted.events;
7127
+ if (targeted.timedOut) {
7128
+ logger.debug("worktree target resolution exceeded its budget", {
7129
+ "provider.id": detection.providerId,
7130
+ "target.resolved": targeted.resolved
7131
+ });
7132
+ }
7133
+ }
6813
7134
  let emitted = 0;
6814
7135
  let exportRejected = 0;
6815
7136
  if (!suppress && batch.length > 0) {
@@ -6958,6 +7279,120 @@ var buildErrorEvents = (diagnostics, identity, sequenceBase, ids, privacy) => {
6958
7279
  return events;
6959
7280
  };
6960
7281
 
7282
+ // src/runtime/git-worktree.ts
7283
+ import { open, stat } from "fs/promises";
7284
+ import * as path2 from "path";
7285
+ var MAX_WORKTREE_WALK_DEPTH = 128;
7286
+ var MAX_GIT_FILE_BYTES = 4096;
7287
+ var MAX_CACHE_ENTRIES = 1024;
7288
+ var DEFAULT_WORKTREE_CACHE_TTL_MILLIS = 5e3;
7289
+ var MAX_BRANCH_NAME_LENGTH = 255;
7290
+ var ABSENT = Object.freeze({ kind: "absent" });
7291
+ var INVALID = Object.freeze({ kind: "invalid" });
7292
+ var readBounded = async (filePath) => {
7293
+ let handle;
7294
+ try {
7295
+ handle = await open(filePath, "r");
7296
+ const buffer = Buffer.alloc(MAX_GIT_FILE_BYTES);
7297
+ const { bytesRead } = await handle.read(buffer, 0, MAX_GIT_FILE_BYTES, 0);
7298
+ return buffer.subarray(0, bytesRead).toString("utf8");
7299
+ } catch {
7300
+ return void 0;
7301
+ } finally {
7302
+ await handle?.close().catch(() => void 0);
7303
+ }
7304
+ };
7305
+ var parseHeadBranch = (head) => {
7306
+ const line = head.split(/\r?\n/, 1)[0]?.trim() ?? "";
7307
+ const match = /^ref:\s*refs\/heads\/(.+)$/.exec(line);
7308
+ const branch = match?.[1];
7309
+ 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.
7310
+ [...branch].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127) || /[ ~^:?*[\\]/.test(branch)) {
7311
+ return void 0;
7312
+ }
7313
+ return branch;
7314
+ };
7315
+ var parseGitDirFile = (content, worktreeRoot) => {
7316
+ const line = content.split(/\r?\n/, 1)[0]?.trim() ?? "";
7317
+ const target = line.startsWith("gitdir:") ? line.slice("gitdir:".length).trim() : void 0;
7318
+ if (target === void 0 || target.length === 0 || target.includes("\0")) {
7319
+ return void 0;
7320
+ }
7321
+ return path2.resolve(worktreeRoot, target);
7322
+ };
7323
+ var probeDirectory = async (directory) => {
7324
+ const dotGit = path2.join(directory, ".git");
7325
+ let info;
7326
+ try {
7327
+ info = await stat(dotGit);
7328
+ } catch {
7329
+ return ABSENT;
7330
+ }
7331
+ let gitDir;
7332
+ if (info.isDirectory()) {
7333
+ gitDir = dotGit;
7334
+ } else if (info.isFile()) {
7335
+ const content = await readBounded(dotGit);
7336
+ gitDir = content === void 0 ? void 0 : parseGitDirFile(content, directory);
7337
+ }
7338
+ if (gitDir === void 0) {
7339
+ return INVALID;
7340
+ }
7341
+ const head = await readBounded(path2.join(gitDir, "HEAD"));
7342
+ if (head === void 0) {
7343
+ return INVALID;
7344
+ }
7345
+ const branch = parseHeadBranch(head);
7346
+ return {
7347
+ kind: "worktree",
7348
+ located: { root: directory, ...branch === void 0 ? {} : { branch } }
7349
+ };
7350
+ };
7351
+ var createFilesystemWorktreeLocator = (options = {}) => {
7352
+ const now = options.monotonicMillis ?? (() => performance.now());
7353
+ const ttl = options.cacheTtlMillis ?? DEFAULT_WORKTREE_CACHE_TTL_MILLIS;
7354
+ const cache = /* @__PURE__ */ new Map();
7355
+ const cachedProbe = (directory) => {
7356
+ const hit = cache.get(directory);
7357
+ const at = now();
7358
+ if (hit !== void 0 && at - hit.at <= ttl) {
7359
+ return hit.probe;
7360
+ }
7361
+ if (cache.size >= MAX_CACHE_ENTRIES) {
7362
+ cache.clear();
7363
+ }
7364
+ const probe = probeDirectory(directory).catch(() => INVALID);
7365
+ cache.set(directory, { at, probe });
7366
+ return probe;
7367
+ };
7368
+ const locate = async (absolutePath) => {
7369
+ try {
7370
+ if (!path2.isAbsolute(absolutePath) || absolutePath.includes("\0")) {
7371
+ return void 0;
7372
+ }
7373
+ let directory = path2.resolve(absolutePath);
7374
+ for (let depth = 0; depth < MAX_WORKTREE_WALK_DEPTH; depth += 1) {
7375
+ const probe = await cachedProbe(directory);
7376
+ if (probe.kind === "worktree") {
7377
+ return probe.located;
7378
+ }
7379
+ if (probe.kind === "invalid") {
7380
+ return void 0;
7381
+ }
7382
+ const parent = path2.dirname(directory);
7383
+ if (parent === directory) {
7384
+ return void 0;
7385
+ }
7386
+ directory = parent;
7387
+ }
7388
+ return void 0;
7389
+ } catch {
7390
+ return void 0;
7391
+ }
7392
+ };
7393
+ return { locate };
7394
+ };
7395
+
6961
7396
  // src/lifecycle/dedup.ts
6962
7397
  import { randomBytes } from "crypto";
6963
7398
 
@@ -7193,7 +7628,7 @@ import {
7193
7628
  } from "@opentelemetry/semantic-conventions/incubating";
7194
7629
 
7195
7630
  // src/version.ts
7196
- var VERSION = "0.3.0";
7631
+ var VERSION = "0.4.1";
7197
7632
 
7198
7633
  // src/telemetry/export-identity.ts
7199
7634
  import { ATTR_SESSION_ID } from "@opentelemetry/semantic-conventions/incubating";
@@ -7209,6 +7644,23 @@ var ATTR_OTELHOOK_PROVIDER_ID = "otelhook.provider.id";
7209
7644
  var ATTR_OTELHOOK_PROVIDER_VERSION = "otelhook.provider.version";
7210
7645
  var ATTR_OTELHOOK_WORKSPACE_ID = "otelhook.workspace.id";
7211
7646
  var HAR_SESSION_KEY = "har.session_key";
7647
+ var ATTR_OTELHOOK_SUBAGENT_ID = "otelhook.subagent.id";
7648
+ var ATTR_VCS_REF_HEAD_NAME = "vcs.ref.head.name";
7649
+ var ATTR_OTELHOOK_TARGET_WORKSPACE_ID = "otelhook.target.workspace.id";
7650
+ var ATTR_OTELHOOK_TARGET_SOURCE = "otelhook.target.source";
7651
+ var ATTR_OTELHOOK_USAGE_TEMPORALITY = "otelhook.usage.temporality";
7652
+ var targetAttributes = (event3) => {
7653
+ if (event3.type !== "tool.start" && event3.type !== "tool.end" || event3.target === void 0) {
7654
+ return {};
7655
+ }
7656
+ const { target } = event3;
7657
+ return {
7658
+ [ATTR_OTELHOOK_TARGET_WORKSPACE_ID]: target.workspaceId,
7659
+ [ATTR_OTELHOOK_TARGET_SOURCE]: target.source,
7660
+ ...target.vcsBranchName === void 0 ? {} : { [ATTR_VCS_REF_HEAD_NAME]: target.vcsBranchName }
7661
+ };
7662
+ };
7663
+ var usageTemporalityAttributes = (usage) => usage === void 0 ? {} : { [ATTR_OTELHOOK_USAGE_TEMPORALITY]: usage.temporality };
7212
7664
  var isPrimitiveAttribute = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean";
7213
7665
  var passthroughHarAttributes = (resource) => {
7214
7666
  const attributes = {};
@@ -7244,6 +7696,7 @@ var exportIdentityAttributes = (event3, resource, ids) => {
7244
7696
  [ATTR_OTELHOOK_PROVIDER_ID]: event3.provenance.providerId,
7245
7697
  ...event3.provenance.providerVersion === void 0 ? {} : { [ATTR_OTELHOOK_PROVIDER_VERSION]: event3.provenance.providerVersion },
7246
7698
  [ATTR_OTELHOOK_WORKSPACE_ID]: event3.workspace.workspaceId,
7699
+ ...event3.subagentId === void 0 ? {} : { [ATTR_OTELHOOK_SUBAGENT_ID]: event3.subagentId },
7247
7700
  ...passthroughHarAttributes(resource),
7248
7701
  ...hexTraceAttributes(ids)
7249
7702
  };
@@ -7265,6 +7718,7 @@ var ATTR_OTELHOOK_DELEGATION_DEPTH = "otelhook.delegation_depth";
7265
7718
  var ATTR_OTELHOOK_COMPACTION_TRIGGER = "otelhook.compaction.trigger";
7266
7719
  var ATTR_OTELHOOK_AGENT_NAME = "otelhook.agent.name";
7267
7720
  var ATTR_OTELHOOK_AGENT_VERSION = "otelhook.agent.version";
7721
+ var ATTR_OTELHOOK_GENERATION_ID = "otelhook.generation.id";
7268
7722
  var FIELD_SEPARATOR = "\0";
7269
7723
  var digestHex = (parts, length) => createHash3("sha256").update(parts.join(FIELD_SEPARATOR)).digest("hex").slice(0, length);
7270
7724
  var MAX_RECOVERED_START_ATTRIBUTES = 16;
@@ -7331,8 +7785,10 @@ var startOnlySpanAttributes = (event3) => {
7331
7785
  };
7332
7786
  // `toolName` and `toolCallId` are on both tool edges, so they are not
7333
7787
  // start-only and persisting them would just pad every record.
7788
+ // The target is carried forward too: an end-only process may see a payload
7789
+ // with less to go on (no tool input), and the start's evidence still holds.
7334
7790
  case "tool.start":
7335
- return { [ATTR_OTELHOOK_TOOL_KIND]: event3.toolKind };
7791
+ return { [ATTR_OTELHOOK_TOOL_KIND]: event3.toolKind, ...targetAttributes(event3) };
7336
7792
  case "subagent.start":
7337
7793
  return { [ATTR_OTELHOOK_DELEGATION_DEPTH]: event3.delegationDepth };
7338
7794
  default:
@@ -7363,9 +7819,52 @@ var usageAttributes = (usage, resetDetected) => {
7363
7819
  [ATTR_GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS]: usage.cachedInputTokens,
7364
7820
  [ATTR_GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS]: usage.cacheCreationInputTokens,
7365
7821
  [ATTR_GEN_AI_USAGE_REASONING_OUTPUT_TOKENS]: usage.reasoningOutputTokens,
7822
+ ...usageTemporalityAttributes(usage),
7366
7823
  ...resetDetected ? { [ATTR_OTELHOOK_RESET_DETECTED]: true } : {}
7367
7824
  };
7368
7825
  };
7826
+ var TARGET_SOURCE_RANK = Object.freeze({
7827
+ "tool-path": 3,
7828
+ "shell-cwd": 2,
7829
+ "session-cwd": 1
7830
+ });
7831
+ var TARGET_KEYS = [
7832
+ ATTR_OTELHOOK_TARGET_WORKSPACE_ID,
7833
+ ATTR_OTELHOOK_TARGET_SOURCE,
7834
+ ATTR_VCS_REF_HEAD_NAME
7835
+ ];
7836
+ var pickTarget = (attributes) => {
7837
+ const picked = {};
7838
+ for (const key of TARGET_KEYS) {
7839
+ if (attributes[key] !== void 0) {
7840
+ picked[key] = attributes[key];
7841
+ }
7842
+ }
7843
+ return picked;
7844
+ };
7845
+ var withoutTarget = (attributes) => {
7846
+ const rest = { ...attributes };
7847
+ for (const key of TARGET_KEYS) {
7848
+ delete rest[key];
7849
+ }
7850
+ return rest;
7851
+ };
7852
+ var rankOf = (candidate) => {
7853
+ const source = candidate[ATTR_OTELHOOK_TARGET_SOURCE];
7854
+ return typeof source === "string" && Object.hasOwn(TARGET_SOURCE_RANK, source) ? TARGET_SOURCE_RANK[source] ?? 0 : 0;
7855
+ };
7856
+ var strongestTarget = (candidates) => {
7857
+ let best = {};
7858
+ let bestRank = 0;
7859
+ for (const candidate of candidates) {
7860
+ const rank = rankOf(candidate);
7861
+ if (rank > 0 && rank >= bestRank) {
7862
+ best = candidate;
7863
+ bestRank = rank;
7864
+ }
7865
+ }
7866
+ return best;
7867
+ };
7369
7868
  var buildSpanContext = (traceId, spanId) => ({
7370
7869
  traceId,
7371
7870
  spanId,
@@ -7476,6 +7975,9 @@ var buildLifecycleSpan = (plan, resource, scope) => {
7476
7975
  ...model?.vendor === void 0 ? {} : { [ATTR_GEN_AI_SYSTEM]: model.vendor },
7477
7976
  ...start?.model?.modelId === void 0 ? {} : { [ATTR_GEN_AI_REQUEST_MODEL]: start.model.modelId },
7478
7977
  ...end?.model?.modelId === void 0 ? {} : { [ATTR_GEN_AI_RESPONSE_MODEL]: end.model.modelId },
7978
+ // The provider's own id for this unit of work (Cursor generation,
7979
+ // Codex turn): the key a consumer stores a usage observation under.
7980
+ [ATTR_OTELHOOK_GENERATION_ID]: group.ref.scopeKey,
7479
7981
  ...end?.outcome === void 0 ? {} : { [ATTR_OTELHOOK_OUTCOME]: end.outcome },
7480
7982
  ...usageAttributes(end?.usage, false)
7481
7983
  };
@@ -7489,11 +7991,17 @@ var buildLifecycleSpan = (plan, resource, scope) => {
7489
7991
  name = `tool ${toolName}`;
7490
7992
  kind = SpanKind.CLIENT;
7491
7993
  attributes = {
7492
- ...attributes,
7994
+ // Target keys are re-chosen below as one unit, never mixed across edges.
7995
+ ...withoutTarget(attributes),
7493
7996
  [ATTR_GEN_AI_TOOL_NAME]: toolName,
7494
7997
  [ATTR_GEN_AI_TOOL_CALL_ID]: start?.toolCallId ?? end?.toolCallId ?? group.ref.scopeKey,
7495
7998
  ...start?.toolKind === void 0 ? {} : { [ATTR_OTELHOOK_TOOL_KIND]: start.toolKind },
7496
- ...end?.outcome === void 0 ? {} : { [ATTR_OTELHOOK_OUTCOME]: end.outcome }
7999
+ ...end?.outcome === void 0 ? {} : { [ATTR_OTELHOOK_OUTCOME]: end.outcome },
8000
+ ...strongestTarget([
8001
+ pickTarget(resolved.recovered),
8002
+ start === void 0 ? {} : targetAttributes(start),
8003
+ end === void 0 ? {} : targetAttributes(end)
8004
+ ])
7497
8005
  };
7498
8006
  status = outcomeStatus(end?.outcome);
7499
8007
  break;
@@ -8324,8 +8832,8 @@ var createBoundedMemoryStateStore = (options) => {
8324
8832
 
8325
8833
  // src/state/filesystem-store.ts
8326
8834
  import { randomBytes as randomBytes2 } from "crypto";
8327
- import { mkdir, open, readFile, readdir, rename, unlink, writeFile } from "fs/promises";
8328
- import * as path from "path";
8835
+ import { mkdir, open as open2, readFile, readdir, rename, unlink, writeFile } from "fs/promises";
8836
+ import * as path3 from "path";
8329
8837
 
8330
8838
  // src/state/keys.ts
8331
8839
  import { createHash as createHash4 } from "crypto";
@@ -8345,8 +8853,8 @@ var keyDigest = (key) => createHash4("sha256").update(key, "utf8").digest("hex")
8345
8853
 
8346
8854
  // src/state/filesystem-store.ts
8347
8855
  var isErrnoException = (thrown, code) => thrown instanceof Error && thrown.code === code;
8348
- var sleep = (millis) => new Promise((resolve3) => {
8349
- const timer = setTimeout(resolve3, millis);
8856
+ var sleep = (millis) => new Promise((resolve5) => {
8857
+ const timer = setTimeout(resolve5, millis);
8350
8858
  timer.unref?.();
8351
8859
  });
8352
8860
  var wrapFsError = (thrown, operation) => {
@@ -8357,10 +8865,10 @@ var wrapFsError = (thrown, operation) => {
8357
8865
  };
8358
8866
  var createFilesystemStateStore = (options) => {
8359
8867
  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");
8868
+ const baseDir = path3.join(options.rootDir, providerSegment, installationSegment);
8869
+ const recordsDir = path3.join(baseDir, "records");
8870
+ const quarantineDir = path3.join(baseDir, "quarantine");
8871
+ const locksDir = path3.join(baseDir, "locks");
8364
8872
  const lockTimeoutMillis = options.lockTimeoutMillis ?? 5e3;
8365
8873
  const lockStaleMillis = options.lockStaleMillis ?? 3e4;
8366
8874
  const lockPollIntervalMillis = options.lockPollIntervalMillis ?? 25;
@@ -8384,11 +8892,11 @@ var createFilesystemStateStore = (options) => {
8384
8892
  throw wrapFsError(thrown, "ensure-dirs");
8385
8893
  }
8386
8894
  };
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`);
8895
+ const recordPath = (key) => path3.join(recordsDir, `${keyDigest(key)}.json`);
8896
+ const tempPath = (key) => path3.join(recordsDir, `.tmp-${keyDigest(key)}-${randomBytes2(6).toString("hex")}.json`);
8897
+ const lockPath = (sessionId) => path3.join(locksDir, `${sanitizeSegment(sessionId)}.lock`);
8390
8898
  const quarantine = async (filePath, key, reason) => {
8391
- const dest = path.join(quarantineDir, `${options.clock.now()}-${keyDigest(key)}-${reason}.json`);
8899
+ const dest = path3.join(quarantineDir, `${options.clock.now()}-${keyDigest(key)}-${reason}.json`);
8392
8900
  try {
8393
8901
  await rename(filePath, dest);
8394
8902
  } catch {
@@ -8452,7 +8960,7 @@ var createFilesystemStateStore = (options) => {
8452
8960
  const startedAt = options.clock.monotonicMillis();
8453
8961
  for (; ; ) {
8454
8962
  try {
8455
- const handle = await open(filePath, "wx");
8963
+ const handle = await open2(filePath, "wx");
8456
8964
  try {
8457
8965
  await handle.writeFile(JSON.stringify({ pid: process.pid, acquiredAt: options.clock.now() }));
8458
8966
  } finally {
@@ -8520,7 +9028,7 @@ var createFilesystemStateStore = (options) => {
8520
9028
  }
8521
9029
  let raw;
8522
9030
  try {
8523
- raw = await readFile(path.join(recordsDir, entry), "utf8");
9031
+ raw = await readFile(path3.join(recordsDir, entry), "utf8");
8524
9032
  } catch {
8525
9033
  continue;
8526
9034
  }
@@ -8573,7 +9081,7 @@ var createFilesystemStateStore = (options) => {
8573
9081
  continue;
8574
9082
  }
8575
9083
  scanned += 1;
8576
- const filePath = path.join(recordsDir, entry);
9084
+ const filePath = path3.join(recordsDir, entry);
8577
9085
  try {
8578
9086
  const raw = await readFile(filePath, "utf8");
8579
9087
  const envelope = JSON.parse(raw);
@@ -8593,7 +9101,7 @@ var createFilesystemStateStore = (options) => {
8593
9101
  lockEntries = [];
8594
9102
  }
8595
9103
  for (const entry of lockEntries) {
8596
- const filePath = path.join(locksDir, entry);
9104
+ const filePath = path3.join(locksDir, entry);
8597
9105
  try {
8598
9106
  const raw = await readFile(filePath, "utf8");
8599
9107
  const parsed = JSON.parse(raw);
@@ -8612,13 +9120,13 @@ var createFilesystemStateStore = (options) => {
8612
9120
  // src/telemetry/spool-queue.ts
8613
9121
  import { randomBytes as randomBytes3 } from "crypto";
8614
9122
  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";
9123
+ import * as path4 from "path";
8616
9124
  var DEFAULT_DRAIN_MAX_BATCHES = 20;
8617
9125
  var isErrnoException2 = (thrown, code) => thrown instanceof Error && thrown.code === code;
8618
9126
  var createSpoolQueue = (options) => {
8619
9127
  const [providerSegment, installationSegment] = namespaceSegments(options);
8620
- const queueDir = path2.join(options.rootDir, providerSegment, installationSegment, options.queueName);
8621
- const corruptDir = path2.join(
9128
+ const queueDir = path4.join(options.rootDir, providerSegment, installationSegment, options.queueName);
9129
+ const corruptDir = path4.join(
8622
9130
  options.rootDir,
8623
9131
  providerSegment,
8624
9132
  installationSegment,
@@ -8664,8 +9172,8 @@ var createSpoolQueue = (options) => {
8664
9172
  return { spooled: false, reason: "capacity-exceeded" };
8665
9173
  }
8666
9174
  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`);
9175
+ const target = path4.join(queueDir, fileName);
9176
+ const tmp = path4.join(queueDir, `.tmp-${randomBytes3(6).toString("hex")}.json`);
8669
9177
  await writeFile2(tmp, JSON.stringify(batch), "utf8");
8670
9178
  await rename2(tmp, target);
8671
9179
  return { spooled: true };
@@ -8683,7 +9191,7 @@ var createSpoolQueue = (options) => {
8683
9191
  if (fileName === void 0) {
8684
9192
  break;
8685
9193
  }
8686
- const filePath = path2.join(queueDir, fileName);
9194
+ const filePath = path4.join(queueDir, fileName);
8687
9195
  const quarantine = async (rejection) => {
8688
9196
  quarantined += 1;
8689
9197
  options.logger?.error("durable spool quarantined an unusable batch", {
@@ -8692,7 +9200,7 @@ var createSpoolQueue = (options) => {
8692
9200
  "spool.queue": options.queueName
8693
9201
  });
8694
9202
  try {
8695
- await rename2(filePath, path2.join(corruptDir, fileName));
9203
+ await rename2(filePath, path4.join(corruptDir, fileName));
8696
9204
  } catch {
8697
9205
  await unlink2(filePath).catch(() => void 0);
8698
9206
  }
@@ -8983,8 +9491,8 @@ var createOtlpTraceSink = (options) => {
8983
9491
  timeoutMillis: options.exporter.timeoutMillis
8984
9492
  });
8985
9493
  let shutdownCompleted = false;
8986
- const exportSpans = (spans) => new Promise((resolve3) => {
8987
- exporter.export([...spans], (result) => resolve3(result));
9494
+ const exportSpans = (spans) => new Promise((resolve5) => {
9495
+ exporter.export([...spans], (result) => resolve5(result));
8988
9496
  });
8989
9497
  const toSpoolBatch = (spans) => ({
8990
9498
  providerId: options.providerId,
@@ -9146,7 +9654,7 @@ var ATTR_OTELHOOK_AGENT_VERSION2 = "otelhook.agent.version";
9146
9654
  var ATTR_OTELHOOK_SESSION_KIND = "otelhook.session.kind";
9147
9655
  var ATTR_OTELHOOK_PROMPT_SOURCE = "otelhook.prompt.source";
9148
9656
  var ATTR_OTELHOOK_PROMPT_TURN_INDEX = "otelhook.prompt.turn_index";
9149
- var ATTR_OTELHOOK_GENERATION_ID = "otelhook.generation.id";
9657
+ var ATTR_OTELHOOK_GENERATION_ID2 = "otelhook.generation.id";
9150
9658
  var ATTR_OTELHOOK_STOP_REASON = "otelhook.generation.stop_reason";
9151
9659
  var ATTR_OTELHOOK_COMPACTION_TRIGGER2 = "otelhook.compaction.trigger";
9152
9660
  var ATTR_OTELHOOK_CONTEXT_TOKENS_BEFORE = "otelhook.compaction.context_tokens_before";
@@ -9305,14 +9813,14 @@ var eventAttributes = (event3) => {
9305
9813
  case "generation.start":
9306
9814
  return {
9307
9815
  [ATTR_GEN_AI_OPERATION_NAME2]: "chat",
9308
- [ATTR_OTELHOOK_GENERATION_ID]: event3.generationId,
9816
+ [ATTR_OTELHOOK_GENERATION_ID2]: event3.generationId,
9309
9817
  [ATTR_GEN_AI_REQUEST_MODEL2]: event3.model.modelId,
9310
9818
  ...event3.model.vendor === void 0 ? {} : { [ATTR_GEN_AI_SYSTEM2]: event3.model.vendor }
9311
9819
  };
9312
9820
  case "generation.end":
9313
9821
  return {
9314
9822
  [ATTR_GEN_AI_OPERATION_NAME2]: "chat",
9315
- [ATTR_OTELHOOK_GENERATION_ID]: event3.generationId,
9823
+ [ATTR_OTELHOOK_GENERATION_ID2]: event3.generationId,
9316
9824
  [ATTR_GEN_AI_RESPONSE_MODEL2]: event3.model.modelId,
9317
9825
  ...event3.model.vendor === void 0 ? {} : { [ATTR_GEN_AI_SYSTEM2]: event3.model.vendor },
9318
9826
  [ATTR_OTELHOOK_OUTCOME2]: event3.outcome,
@@ -9324,14 +9832,16 @@ var eventAttributes = (event3) => {
9324
9832
  [ATTR_GEN_AI_TOOL_NAME2]: event3.toolName,
9325
9833
  [ATTR_GEN_AI_TOOL_CALL_ID2]: event3.toolCallId,
9326
9834
  [ATTR_OTELHOOK_TOOL_KIND2]: event3.toolKind,
9327
- ...event3.generationId === void 0 ? {} : { [ATTR_OTELHOOK_GENERATION_ID]: event3.generationId }
9835
+ ...event3.generationId === void 0 ? {} : { [ATTR_OTELHOOK_GENERATION_ID2]: event3.generationId },
9836
+ ...targetAttributes(event3)
9328
9837
  };
9329
9838
  case "tool.end":
9330
9839
  return {
9331
9840
  [ATTR_GEN_AI_TOOL_NAME2]: event3.toolName,
9332
9841
  [ATTR_GEN_AI_TOOL_CALL_ID2]: event3.toolCallId,
9333
9842
  [ATTR_OTELHOOK_OUTCOME2]: event3.outcome,
9334
- ...event3.permissionDecision === void 0 ? {} : { [ATTR_OTELHOOK_TOOL_PERMISSION]: event3.permissionDecision }
9843
+ ...event3.permissionDecision === void 0 ? {} : { [ATTR_OTELHOOK_TOOL_PERMISSION]: event3.permissionDecision },
9844
+ ...targetAttributes(event3)
9335
9845
  };
9336
9846
  case "subagent.start":
9337
9847
  return {
@@ -9365,7 +9875,8 @@ var usageAttributes2 = (usage) => usage === void 0 ? {} : {
9365
9875
  [ATTR_GEN_AI_USAGE_INPUT_TOKENS2]: usage.inputTokens,
9366
9876
  [ATTR_GEN_AI_USAGE_OUTPUT_TOKENS2]: usage.outputTokens,
9367
9877
  [ATTR_GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS2]: usage.cachedInputTokens,
9368
- [ATTR_GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS2]: usage.cacheCreationInputTokens
9878
+ [ATTR_GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS2]: usage.cacheCreationInputTokens,
9879
+ ...usageTemporalityAttributes(usage)
9369
9880
  };
9370
9881
  var contentFactsOf = (event3) => {
9371
9882
  switch (event3.type) {
@@ -9757,8 +10268,8 @@ var createOtlpLogSink = (options) => {
9757
10268
  timeoutMillis: options.exporter.timeoutMillis
9758
10269
  });
9759
10270
  let shutdownCompleted = false;
9760
- const exportRecords = (records) => new Promise((resolve3) => {
9761
- exporter.export([...records], (result) => resolve3(result));
10271
+ const exportRecords = (records) => new Promise((resolve5) => {
10272
+ exporter.export([...records], (result) => resolve5(result));
9762
10273
  });
9763
10274
  const toSpoolBatch = (records) => ({
9764
10275
  providerId: options.providerId,
@@ -9937,8 +10448,8 @@ var DEFAULT_FLUSH_TIMEOUT_MILLIS = 2e3;
9937
10448
  var DEFAULT_STATE_LOCK_TIMEOUT_MILLIS = 1e3;
9938
10449
  var DEFAULT_LIFECYCLE_MAX_AGE_MILLIS = 24 * 60 * 60 * 1e3;
9939
10450
  var DEFAULT_STALE_CLAIM_MILLIS2 = 6e4;
9940
- var delay = (millis) => new Promise((resolve3) => {
9941
- const timer = setTimeout(() => resolve3("timeout"), millis);
10451
+ var delay = (millis) => new Promise((resolve5) => {
10452
+ const timer = setTimeout(() => resolve5("timeout"), millis);
9942
10453
  timer.unref?.();
9943
10454
  });
9944
10455
  var containsSessionEnd = (events) => events.some((event3) => event3.type === "session.end");
@@ -10050,7 +10561,10 @@ var createHookRuntime = (options) => {
10050
10561
  ids,
10051
10562
  privacy,
10052
10563
  logger,
10053
- installationId: options.installationId
10564
+ installationId: options.installationId,
10565
+ ...options.worktreeLocator === null ? {} : {
10566
+ worktreeLocator: options.worktreeLocator ?? createFilesystemWorktreeLocator({ monotonicMillis: () => clock.monotonicMillis() })
10567
+ }
10054
10568
  };
10055
10569
  const hook = createOtelHook({ ...hookDeps, sink });
10056
10570
  const deduplicator = createCallbackDeduplicator({ stateStore, clock });
@@ -10739,7 +11253,7 @@ var CURSOR_UNREGISTERED_HOOK_EVENTS = Object.freeze({
10739
11253
  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
11254
  beforeMCPExecution: "an MCP call also fires preToolUse/postToolUse, which additionally carry tool_use_id; registering this one duplicates the tool call",
10741
11255
  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",
11256
+ 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
11257
  subagentStart: "subagentStop carries no subagent id to pair with, so no closable delegation lifecycle can be produced",
10744
11258
  subagentStop: "it carries no subagent id, so it cannot be paired with the subagentStart it ends",
10745
11259
  beforeTabFileRead: "a Tab (inline-completion) hook, not an agent-session hook; not modelled by this adapter",
@@ -11179,7 +11693,7 @@ var SUPPORTED_REGISTRATION_PROVIDER_IDS = Object.freeze(
11179
11693
  );
11180
11694
 
11181
11695
  // src/install/scopes.ts
11182
- import * as path3 from "path";
11696
+ import * as path5 from "path";
11183
11697
  var REGISTRATION_SCOPES = Object.freeze([
11184
11698
  "global",
11185
11699
  "project"
@@ -11247,15 +11761,15 @@ var PROVIDERS_WITH_VERIFIED_LOCATION = Object.freeze([
11247
11761
  var findInstallLocation = (providerId, scope) => PROVIDER_INSTALL_LOCATIONS.find(
11248
11762
  (entry) => entry.providerId === providerId && entry.scope === scope
11249
11763
  );
11250
- var resolveInstallPath = (location, roots) => path3.resolve(
11764
+ var resolveInstallPath = (location, roots) => path5.resolve(
11251
11765
  location.scope === "global" ? roots.homeDir : roots.projectDir,
11252
11766
  ...location.segments
11253
11767
  );
11254
11768
 
11255
11769
  // src/install/document.ts
11256
11770
  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";
11771
+ import { chmod, mkdir as mkdir3, open as open3, readFile as readFile3, rename as rename3, stat as stat2, unlink as unlink3 } from "fs/promises";
11772
+ import * as path6 from "path";
11259
11773
  var DEFAULT_DOCUMENT_FORMAT = Object.freeze({
11260
11774
  indent: " ",
11261
11775
  eol: "\n",
@@ -11305,8 +11819,8 @@ var readJsonDocument = async (filePath) => {
11305
11819
  }
11306
11820
  };
11307
11821
  var RENAME_RETRY_DELAYS_MILLIS = [10, 25, 50, 100];
11308
- var delay2 = (millis) => new Promise((resolve3) => {
11309
- setTimeout(resolve3, millis);
11822
+ var delay2 = (millis) => new Promise((resolve5) => {
11823
+ setTimeout(resolve5, millis);
11310
11824
  });
11311
11825
  var renameWithRetry = async (from, to) => {
11312
11826
  for (let attempt = 0; ; attempt += 1) {
@@ -11326,15 +11840,15 @@ var renameWithRetry = async (from, to) => {
11326
11840
  var NEW_DOCUMENT_MODE = 384;
11327
11841
  var TEMPORARY_DOCUMENT_MODE = 384;
11328
11842
  var writeDocumentAtomically = async (filePath, contents) => {
11329
- const directory = path4.dirname(filePath);
11843
+ const directory = path6.dirname(filePath);
11330
11844
  await mkdir3(directory, { recursive: true });
11331
- const temporary = path4.join(
11845
+ const temporary = path6.join(
11332
11846
  directory,
11333
- `.${path4.basename(filePath)}.${randomBytes4(6).toString("hex")}.tmp`
11847
+ `.${path6.basename(filePath)}.${randomBytes4(6).toString("hex")}.tmp`
11334
11848
  );
11335
11849
  let existingMode;
11336
11850
  try {
11337
- existingMode = (await stat(filePath)).mode & 4095;
11851
+ existingMode = (await stat2(filePath)).mode & 4095;
11338
11852
  } catch (thrown) {
11339
11853
  if (!isErrnoException3(thrown, "ENOENT")) {
11340
11854
  throw thrown;
@@ -11342,7 +11856,7 @@ var writeDocumentAtomically = async (filePath, contents) => {
11342
11856
  }
11343
11857
  const targetMode = existingMode ?? NEW_DOCUMENT_MODE;
11344
11858
  try {
11345
- const handle = await open2(temporary, "wx", TEMPORARY_DOCUMENT_MODE);
11859
+ const handle = await open3(temporary, "wx", TEMPORARY_DOCUMENT_MODE);
11346
11860
  try {
11347
11861
  await handle.writeFile(contents, "utf8");
11348
11862
  await handle.sync();
@@ -11359,12 +11873,12 @@ var writeDocumentAtomically = async (filePath, contents) => {
11359
11873
 
11360
11874
  // src/install/file-lock.ts
11361
11875
  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";
11876
+ import { mkdir as mkdir4, open as open4, readFile as readFile4, rename as rename4, stat as stat3, unlink as unlink4 } from "fs/promises";
11877
+ import * as path7 from "path";
11364
11878
  var FileLockTimeoutError = class extends Error {
11365
11879
  constructor(lockPath, timeoutMillis) {
11366
11880
  super(
11367
- `timed out after ${String(timeoutMillis)}ms waiting for the lock on ${path5.basename(lockPath)}`
11881
+ `timed out after ${String(timeoutMillis)}ms waiting for the lock on ${path7.basename(lockPath)}`
11368
11882
  );
11369
11883
  this.name = "FileLockTimeoutError";
11370
11884
  }
@@ -11403,8 +11917,8 @@ var releaseIfOwned = async (lockPath, token) => {
11403
11917
  await unlink4(tombstone).catch(() => void 0);
11404
11918
  return true;
11405
11919
  };
11406
- var delay3 = (millis) => new Promise((resolve3) => {
11407
- setTimeout(resolve3, millis);
11920
+ var delay3 = (millis) => new Promise((resolve5) => {
11921
+ setTimeout(resolve5, millis);
11408
11922
  });
11409
11923
  var isStale = async (lockPath, clock, staleMillis) => {
11410
11924
  let raw;
@@ -11424,7 +11938,7 @@ var isStale = async (lockPath, clock, staleMillis) => {
11424
11938
  } catch {
11425
11939
  }
11426
11940
  try {
11427
- const stats = await stat2(lockPath);
11941
+ const stats = await stat3(lockPath);
11428
11942
  return { stale: clock.now() - stats.mtimeMs > staleMillis };
11429
11943
  } catch (thrown) {
11430
11944
  return { stale: !isErrnoException4(thrown, "ENOENT") };
@@ -11436,12 +11950,12 @@ var withFileLock = async (filePath, options, fn) => {
11436
11950
  const pollIntervalMillis = options.pollIntervalMillis ?? 25;
11437
11951
  const lockPath = lockPathFor(filePath);
11438
11952
  const startedAt = options.clock.monotonicMillis();
11439
- await mkdir4(path5.dirname(filePath), { recursive: true });
11953
+ await mkdir4(path7.dirname(filePath), { recursive: true });
11440
11954
  for (; ; ) {
11441
11955
  const token = randomBytes5(16).toString("hex");
11442
11956
  let acquired = false;
11443
11957
  try {
11444
- const handle = await open3(lockPath, "wx", 384);
11958
+ const handle = await open4(lockPath, "wx", 384);
11445
11959
  try {
11446
11960
  const contents = {
11447
11961
  token,
@@ -11484,7 +11998,7 @@ var withFileLock = async (filePath, options, fn) => {
11484
11998
 
11485
11999
  // src/install/lifecycle.ts
11486
12000
  import { readFile as readFile5 } from "fs/promises";
11487
- import * as path6 from "path";
12001
+ import * as path8 from "path";
11488
12002
  var defaultHookCommand = (providerId) => `otel-hook run --provider ${providerId}`;
11489
12003
  var unsupportedOutcome = (providerId, scope, reason) => ({
11490
12004
  providerId,
@@ -11501,7 +12015,7 @@ var unsupportedOutcome = (providerId, scope, reason) => ({
11501
12015
  var resolveTarget = (providerId, scope, request) => {
11502
12016
  if (request.configFile !== void 0) {
11503
12017
  return {
11504
- configPath: path6.resolve(request.configFile),
12018
+ configPath: path8.resolve(request.configFile),
11505
12019
  evidence: "path supplied by the caller with --settings-file"
11506
12020
  };
11507
12021
  }
@@ -11518,14 +12032,14 @@ var resolveTarget = (providerId, scope, request) => {
11518
12032
  };
11519
12033
  };
11520
12034
  var codexFeatureNote = async (configPath) => {
11521
- const tomlPath = path6.join(path6.dirname(configPath), "config.toml");
12035
+ const tomlPath = path8.join(path8.dirname(configPath), "config.toml");
11522
12036
  let raw;
11523
12037
  try {
11524
12038
  raw = await readFile5(tomlPath, "utf8");
11525
12039
  } catch {
11526
12040
  return void 0;
11527
12041
  }
11528
- return readCodexHooksFeatureFlag(raw) === "disabled" ? `${path6.basename(tomlPath)} sets [features] hooks = false; registered hooks will not fire until that is removed` : void 0;
12042
+ return readCodexHooksFeatureFlag(raw) === "disabled" ? `${path8.basename(tomlPath)} sets [features] hooks = false; registered hooks will not fire until that is removed` : void 0;
11529
12043
  };
11530
12044
  var readState = async (configPath) => {
11531
12045
  const read = await readJsonDocument(configPath);
@@ -11537,12 +12051,12 @@ var readState = async (configPath) => {
11537
12051
  case "unparseable":
11538
12052
  return {
11539
12053
  status: "blocked",
11540
- problem: `${path6.basename(configPath)} is not well-formed JSON (${read.detail}); it was left untouched`
12054
+ problem: `${path8.basename(configPath)} is not well-formed JSON (${read.detail}); it was left untouched`
11541
12055
  };
11542
12056
  case "unreadable":
11543
12057
  return {
11544
12058
  status: "failed",
11545
- problem: `${path6.basename(configPath)} could not be read (${read.detail})`
12059
+ problem: `${path8.basename(configPath)} could not be read (${read.detail})`
11546
12060
  };
11547
12061
  }
11548
12062
  };
@@ -11654,7 +12168,7 @@ var runOneTarget = async (providerId, scope, request, command) => {
11654
12168
  missingEvents: [],
11655
12169
  notes,
11656
12170
  problems: planned.conflicts.map(
11657
- (conflict) => `${path6.basename(configPath)} has an unexpected shape at ${conflict.location}: ${conflict.detail}; it was left untouched`
12171
+ (conflict) => `${path8.basename(configPath)} has an unexpected shape at ${conflict.location}: ${conflict.detail}; it was left untouched`
11658
12172
  )
11659
12173
  };
11660
12174
  }
@@ -11665,7 +12179,7 @@ var runOneTarget = async (providerId, scope, request, command) => {
11665
12179
  changed: false,
11666
12180
  registeredEvents: [],
11667
12181
  missingEvents: [],
11668
- notes: [...notes, `${path6.basename(configPath)} does not exist; nothing to remove`],
12182
+ notes: [...notes, `${path8.basename(configPath)} does not exist; nothing to remove`],
11669
12183
  problems: []
11670
12184
  };
11671
12185
  }
@@ -11708,7 +12222,7 @@ var runOneTarget = async (providerId, scope, request, command) => {
11708
12222
  missingEvents: [],
11709
12223
  notes,
11710
12224
  problems: [
11711
- `could not write ${path6.basename(configPath)} (${thrown instanceof Error ? thrown.name : typeof thrown})`
12225
+ `could not write ${path8.basename(configPath)} (${thrown instanceof Error ? thrown.name : typeof thrown})`
11712
12226
  ]
11713
12227
  };
11714
12228
  }
@@ -11735,7 +12249,7 @@ var runOneTarget = async (providerId, scope, request, command) => {
11735
12249
  missingEvents: [],
11736
12250
  notes,
11737
12251
  problems: [
11738
- thrown instanceof Error ? `${path6.basename(configPath)}: ${thrown.message}` : `${path6.basename(configPath)}: the configuration file could not be locked`
12252
+ thrown instanceof Error ? `${path8.basename(configPath)}: ${thrown.message}` : `${path8.basename(configPath)}: the configuration file could not be locked`
11739
12253
  ]
11740
12254
  };
11741
12255
  }
@@ -11862,6 +12376,8 @@ export {
11862
12376
  DEFAULT_PRIVACY_POLICY,
11863
12377
  DEFAULT_SECRET_KEY_PATTERNS,
11864
12378
  DEFAULT_SECRET_VALUE_PATTERNS,
12379
+ DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS,
12380
+ DEFAULT_WORKTREE_CACHE_TTL_MILLIS,
11865
12381
  DELIVERY_COMPONENT_PATTERN,
11866
12382
  DELIVERY_GAP_REASON_PATTERN,
11867
12383
  DELIVERY_IDENTIFIER_SUMMARY,
@@ -11896,6 +12412,9 @@ export {
11896
12412
  MAX_RESOURCE_ATTRIBUTES,
11897
12413
  MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH,
11898
12414
  MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH,
12415
+ MAX_TARGET_HINT_PATHS,
12416
+ MAX_TARGET_PATH_LENGTH,
12417
+ MAX_WORKTREE_WALK_DEPTH,
11899
12418
  MCP_TOOL_NAME_PATTERN,
11900
12419
  NO_LOG_CONTENT,
11901
12420
  OtelHookError,
@@ -11913,6 +12432,7 @@ export {
11913
12432
  RESOURCE_ATTRIBUTE_KEY_REJECTION_DETAIL,
11914
12433
  SILENT_HOOK_RESPONSE,
11915
12434
  SPAN_RECORD_VERSION,
12435
+ SUBAGENT_ID_PATTERN,
11916
12436
  SUPPORTED_REGISTRATION_PROVIDER_IDS,
11917
12437
  UNKNOWN_PROVIDER_ID,
11918
12438
  UNKNOWN_WORKSPACE_ID,
@@ -11965,6 +12485,7 @@ export {
11965
12485
  createFileDurableLogSpool,
11966
12486
  createFileDurableSpool,
11967
12487
  createFilesystemStateStore,
12488
+ createFilesystemWorktreeLocator,
11968
12489
  createFixedClock,
11969
12490
  createGeminiCliAdapter,
11970
12491
  createHealthTracker,
@@ -12062,6 +12583,8 @@ export {
12062
12583
  parentScopeRefOf,
12063
12584
  parseCanonicalEvent,
12064
12585
  parseEnvironmentConfig,
12586
+ parseGitDirFile,
12587
+ parseHeadBranch,
12065
12588
  parseResourceAttributesValue,
12066
12589
  planProviderRegistration,
12067
12590
  privacyLimitsSchema,
@@ -12093,6 +12616,7 @@ export {
12093
12616
  renderJsonDocument,
12094
12617
  resolveConfig,
12095
12618
  resolveDeliveryIdentity,
12619
+ resolveEventTargets,
12096
12620
  resolveInstallPath,
12097
12621
  resolveInvocationIdentity,
12098
12622
  resolveLogsEndpoint,
@@ -12114,8 +12638,11 @@ export {
12114
12638
  stateRecordSchema,
12115
12639
  stateValueSchema,
12116
12640
  subagentEndEventSchema,
12641
+ subagentIdSchema,
12117
12642
  subagentStartEventSchema,
12118
12643
  summarizeHealth,
12644
+ targetHintSchema,
12645
+ targetSourceSchema,
12119
12646
  toReport,
12120
12647
  tokenCountSchema,
12121
12648
  toolEndEventSchema,
@@ -12132,6 +12659,7 @@ export {
12132
12659
  workspaceIdSchema,
12133
12660
  workspaceIdentitySchema,
12134
12661
  workspaceKeySourceSchema,
12662
+ workspaceTargetSchema,
12135
12663
  writeDocumentAtomically
12136
12664
  };
12137
12665
  //# sourceMappingURL=index.js.map