@osfactory/otel-hook 0.2.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 (52) hide show
  1. package/dist/{adapter-DIgRACtL.d.ts → adapter-BgqtlADe.d.ts} +12 -5
  2. package/dist/cli.js +1439 -626
  3. package/dist/cli.js.map +1 -1
  4. package/dist/config.d.ts +2 -2
  5. package/dist/config.js +5 -1
  6. package/dist/config.js.map +1 -1
  7. package/dist/{content-CoB7aNP1.d.ts → content-M9xIKG7h.d.ts} +8 -1
  8. package/dist/{events-VxBnDFaO.d.ts → events-C3h3GvHj.d.ts} +58 -0
  9. package/dist/{filesystem-store-J8jjDMTh.d.ts → filesystem-store-BAq3VGVv.d.ts} +1 -1
  10. package/dist/{hook-CGpo-vks.d.ts → hook-CQiNa88Q.d.ts} +13 -5
  11. package/dist/index.d.ts +16 -15
  12. package/dist/index.js +1569 -741
  13. package/dist/index.js.map +1 -1
  14. package/dist/install.d.ts +8 -7
  15. package/dist/install.js +132 -68
  16. package/dist/install.js.map +1 -1
  17. package/dist/integration.d.ts +18 -11
  18. package/dist/integration.js +618 -158
  19. package/dist/integration.js.map +1 -1
  20. package/dist/lifecycle.d.ts +3 -3
  21. package/dist/lifecycle.js +27 -4
  22. package/dist/lifecycle.js.map +1 -1
  23. package/dist/{memory-DXVBc8V9.d.ts → memory-kflYgZbg.d.ts} +2 -2
  24. package/dist/model.d.ts +3 -2
  25. package/dist/model.js +81 -41
  26. package/dist/model.js.map +1 -1
  27. package/dist/{otlp-log-sink-CeIFDDpn.d.ts → otlp-log-sink-BZIgYPKN.d.ts} +4 -4
  28. package/dist/{payload-CHr53E_v.d.ts → payload-DpyU8F-z.d.ts} +1 -1
  29. package/dist/{policy-D1CrlYn3.d.ts → policy-CimmCfRp.d.ts} +1 -1
  30. package/dist/{ports-Q8x0ODhs.d.ts → ports-B_iwJQPQ.d.ts} +20 -2
  31. package/dist/privacy.d.ts +4 -4
  32. package/dist/privacy.js +11 -0
  33. package/dist/privacy.js.map +1 -1
  34. package/dist/providers.d.ts +30 -12
  35. package/dist/providers.js +983 -552
  36. package/dist/providers.js.map +1 -1
  37. package/dist/{registry-BzYmC9OC.d.ts → registry-BSBS8t7S.d.ts} +1 -1
  38. package/dist/runtime.d.ts +88 -12
  39. package/dist/runtime.js +392 -68
  40. package/dist/runtime.js.map +1 -1
  41. package/dist/{semconv-Baoz-0OI.d.ts → semconv-BeUPQ7_q.d.ts} +2 -1
  42. package/dist/{service-j4jEO6cZ.d.ts → service-CbI9CObT.d.ts} +8 -2
  43. package/dist/state.d.ts +4 -4
  44. package/dist/state.js.map +1 -1
  45. package/dist/target-8RfaVxp8.d.ts +83 -0
  46. package/dist/telemetry.d.ts +7 -7
  47. package/dist/telemetry.js +186 -46
  48. package/dist/telemetry.js.map +1 -1
  49. package/dist/testing.d.ts +17 -10
  50. package/dist/testing.js +1149 -593
  51. package/dist/testing.js.map +1 -1
  52. package/package.json +4 -1
package/dist/install.d.ts CHANGED
@@ -1,15 +1,16 @@
1
- import { d as AntigravityHookEventName, m as ClaudeHookEventName, n as CodexHookEventName, o as CursorHookEventName, s as GeminiHookEventName, q as GEMINI_PROVIDER_ID, b as ANTIGRAVITY_PROVIDER_ID, C as CLAUDE_CODE_PROVIDER_ID, h as CODEX_PROVIDER_ID, k as CURSOR_PROVIDER_ID } from './payload-CHr53E_v.js';
2
- import { C as Clock } from './ports-Q8x0ODhs.js';
1
+ import { d as AntigravityHookEventName, m as ClaudeHookEventName, n as CodexHookEventName, o as CursorHookEventName, s as GeminiHookEventName, q as GEMINI_PROVIDER_ID, b as ANTIGRAVITY_PROVIDER_ID, C as CLAUDE_CODE_PROVIDER_ID, h as CODEX_PROVIDER_ID, k as CURSOR_PROVIDER_ID } from './payload-DpyU8F-z.js';
2
+ import { C as Clock } from './ports-B_iwJQPQ.js';
3
3
  import 'zod';
4
4
  import './primitives-CJ8-rn-f.js';
5
- import './adapter-DIgRACtL.js';
5
+ import './adapter-BgqtlADe.js';
6
6
  import './errors.js';
7
7
  import './taxonomy-DwhTtuWd.js';
8
- import './events-VxBnDFaO.js';
8
+ import './events-C3h3GvHj.js';
9
9
  import './identity-BrVBs901.js';
10
- import './policy-D1CrlYn3.js';
11
- import './content-CoB7aNP1.js';
12
- import './service-j4jEO6cZ.js';
10
+ import './target-8RfaVxp8.js';
11
+ import './policy-CimmCfRp.js';
12
+ import './content-M9xIKG7h.js';
13
+ import './service-CbI9CObT.js';
13
14
 
14
15
  /**
15
16
  * Pure merge/removal engine for the "nested command hooks" configuration family.
package/dist/install.js CHANGED
@@ -498,7 +498,14 @@ var postCompactPayloadSchema = z2.object({
498
498
  var stopPayloadSchema2 = z2.object({
499
499
  ...commonFields2,
500
500
  hook_event_name: z2.literal("Stop"),
501
+ /**
502
+ * Interactive Stop field (Claude Code ≥ 2.1.47). Print / `-p` / Agent SDK
503
+ * result messages use `result` instead; `events.ts` reads both (and camelCase
504
+ * `lastAssistantMessage`) through `extractClaudeAssistantText`.
505
+ */
501
506
  last_assistant_message: z2.string().optional(),
507
+ /** Print / `-p` JSON result field; accepted so a harness can attach it as-is. */
508
+ result: z2.string().optional(),
502
509
  /**
503
510
  * True when this stop fired because a hook continued the turn.
504
511
  *
@@ -1017,7 +1024,7 @@ var CURSOR_UNREGISTERED_HOOK_EVENTS = Object.freeze({
1017
1024
  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",
1018
1025
  beforeMCPExecution: "an MCP call also fires preToolUse/postToolUse, which additionally carry tool_use_id; registering this one duplicates the tool call",
1019
1026
  afterMCPExecution: "the same MCP call also fires postToolUse, which duplicates this tool end and, unlike this callback, reports a success/failure signal",
1020
- beforeReadFile: "no completion callback exists for it, so a tool.start emitted here would never close",
1027
+ 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",
1021
1028
  subagentStart: "subagentStop carries no subagent id to pair with, so no closable delegation lifecycle can be produced",
1022
1029
  subagentStop: "it carries no subagent id, so it cannot be paired with the subagentStart it ends",
1023
1030
  beforeTabFileRead: "a Tab (inline-completion) hook, not an agent-session hook; not modelled by this adapter",
@@ -1628,10 +1635,10 @@ var identityClaimSchema = z9.strictObject({
1628
1635
  });
1629
1636
 
1630
1637
  // src/providers/adapter.ts
1631
- import { z as z15 } from "zod";
1638
+ import { z as z16 } from "zod";
1632
1639
 
1633
1640
  // src/model/events.ts
1634
- import { z as z14 } from "zod";
1641
+ import { z as z15 } from "zod";
1635
1642
 
1636
1643
  // src/model/content.ts
1637
1644
  import { z as z10 } from "zod";
@@ -1712,16 +1719,37 @@ var extensionsSchema = z11.record(z11.string(), attributeValueSchema).check((ctx
1712
1719
  var EMPTY_EXTENSIONS = Object.freeze({});
1713
1720
  var emptyExtensions = () => ({});
1714
1721
 
1715
- // src/model/usage.ts
1722
+ // src/model/target.ts
1716
1723
  import { z as z12 } from "zod";
1717
- var usageTemporalitySchema = z12.enum(["delta", "cumulative"]);
1718
- var cacheCreationAccountingSchema = z12.enum([
1724
+ var targetSourceSchema = z12.enum(["tool-path", "shell-cwd", "session-cwd"]);
1725
+ var MAX_TARGET_HINT_PATHS = 8;
1726
+ var MAX_TARGET_PATH_LENGTH = 4096;
1727
+ var localPathSchema = z12.string().min(1).max(MAX_TARGET_PATH_LENGTH).refine((value) => !value.includes("\0"), "path must not contain NUL");
1728
+ var targetHintSchema = z12.strictObject({
1729
+ source: targetSourceSchema,
1730
+ paths: z12.array(localPathSchema).min(1).max(MAX_TARGET_HINT_PATHS).readonly(),
1731
+ /** Absolute directory that relative `paths` resolve against. */
1732
+ baseDirectory: localPathSchema.optional()
1733
+ }).readonly();
1734
+ var workspaceTargetSchema = z12.strictObject({
1735
+ workspaceId: workspaceIdSchema,
1736
+ /** Branch checked out in that worktree; absent on a detached HEAD. */
1737
+ vcsBranchName: nonEmptyStringSchema.optional(),
1738
+ source: targetSourceSchema
1739
+ }).readonly();
1740
+ var SUBAGENT_ID_PATTERN = /^[A-Za-z0-9_.:@+=-]{1,256}$/;
1741
+ var subagentIdSchema = z12.string().regex(SUBAGENT_ID_PATTERN);
1742
+
1743
+ // src/model/usage.ts
1744
+ import { z as z13 } from "zod";
1745
+ var usageTemporalitySchema = z13.enum(["delta", "cumulative"]);
1746
+ var cacheCreationAccountingSchema = z13.enum([
1719
1747
  "included-in-input",
1720
1748
  "disjoint-from-input",
1721
1749
  "not-reported"
1722
1750
  ]);
1723
- var providerTotalAgreementSchema = z12.enum(["unreported", "agrees", "disagrees"]);
1724
- var usageReportSchema = z12.strictObject({
1751
+ var providerTotalAgreementSchema = z13.enum(["unreported", "agrees", "disagrees"]);
1752
+ var usageReportSchema = z13.strictObject({
1725
1753
  temporality: usageTemporalitySchema,
1726
1754
  /** Inclusive input tokens. */
1727
1755
  inputTokens: tokenCountSchema.optional(),
@@ -1738,7 +1766,7 @@ var usageReportSchema = z12.strictObject({
1738
1766
  /** Total exactly as the provider reported it, if it reported one. */
1739
1767
  providerTotalTokens: tokenCountSchema.optional()
1740
1768
  });
1741
- var canonicalUsageSchema = z12.strictObject({
1769
+ var canonicalUsageSchema = z13.strictObject({
1742
1770
  temporality: usageTemporalitySchema,
1743
1771
  inputTokens: tokenCountSchema,
1744
1772
  cachedInputTokens: tokenCountSchema,
@@ -1893,24 +1921,24 @@ var EMPTY_DELTA_USAGE = Object.freeze(
1893
1921
  );
1894
1922
 
1895
1923
  // src/model/version.ts
1896
- import { z as z13 } from "zod";
1924
+ import { z as z14 } from "zod";
1897
1925
  var CANONICAL_SCHEMA_VERSION = 1;
1898
- var canonicalSchemaVersionSchema = z13.literal(CANONICAL_SCHEMA_VERSION);
1926
+ var canonicalSchemaVersionSchema = z14.literal(CANONICAL_SCHEMA_VERSION);
1899
1927
 
1900
1928
  // src/model/events.ts
1901
- var modelDescriptorSchema = z14.strictObject({
1929
+ var modelDescriptorSchema = z15.strictObject({
1902
1930
  modelId: nonEmptyStringSchema,
1903
1931
  /** Vendor of the model, e.g. `anthropic`. Distinct from the agent provider. */
1904
1932
  vendor: nonEmptyStringSchema.optional(),
1905
1933
  family: nonEmptyStringSchema.optional()
1906
1934
  });
1907
- var costFactsSchema = z14.strictObject({
1935
+ var costFactsSchema = z15.strictObject({
1908
1936
  /** ISO 4217 code. */
1909
- currency: z14.string().length(3),
1910
- amount: z14.number().min(0).finite(),
1911
- source: z14.enum(["provider-reported", "computed"])
1937
+ currency: z15.string().length(3),
1938
+ amount: z15.number().min(0).finite(),
1939
+ source: z15.enum(["provider-reported", "computed"])
1912
1940
  });
1913
- var canonicalEventTypeSchema = z14.enum([
1941
+ var canonicalEventTypeSchema = z15.enum([
1914
1942
  "session.start",
1915
1943
  "session.end",
1916
1944
  "prompt.submitted",
@@ -1924,7 +1952,7 @@ var canonicalEventTypeSchema = z14.enum([
1924
1952
  "error.raised"
1925
1953
  ]);
1926
1954
  var CANONICAL_EVENT_TYPES = canonicalEventTypeSchema.options;
1927
- var outcomeSchema = z14.enum(["ok", "error", "cancelled", "timeout", "denied", "unknown"]);
1955
+ var outcomeSchema = z15.enum(["ok", "error", "cancelled", "timeout", "denied", "unknown"]);
1928
1956
  var baseEventFields = {
1929
1957
  schemaVersion: canonicalSchemaVersionSchema,
1930
1958
  eventId: eventIdSchema,
@@ -1935,39 +1963,45 @@ var baseEventFields = {
1935
1963
  occurredAt: epochMillisSchema,
1936
1964
  provenance: sourceProvenanceSchema,
1937
1965
  workspace: workspaceIdentitySchema,
1966
+ /**
1967
+ * The provider's own id for the subagent this event was emitted inside (e.g.
1968
+ * Claude Code's `agent_id`). Absent for the top-level agent. Set by the event
1969
+ * factory, never by hand.
1970
+ */
1971
+ subagentId: subagentIdSchema.optional(),
1938
1972
  extensions: extensionsSchema.default(emptyExtensions)
1939
1973
  };
1940
- var event2 = (shape) => z14.strictObject({ ...baseEventFields, ...shape });
1974
+ var event2 = (shape) => z15.strictObject({ ...baseEventFields, ...shape });
1941
1975
  var sessionStartEventSchema = event2({
1942
- type: z14.literal("session.start"),
1943
- sessionKind: z14.enum(["interactive", "non-interactive", "unknown"]),
1976
+ type: z15.literal("session.start"),
1977
+ sessionKind: z15.enum(["interactive", "non-interactive", "unknown"]),
1944
1978
  agentName: nonEmptyStringSchema.optional(),
1945
1979
  agentVersion: nonEmptyStringSchema.optional(),
1946
1980
  model: modelDescriptorSchema.optional()
1947
1981
  });
1948
1982
  var sessionEndEventSchema = event2({
1949
- type: z14.literal("session.end"),
1950
- reason: z14.enum(["completed", "aborted", "error", "timeout", "unknown"]),
1983
+ type: z15.literal("session.end"),
1984
+ reason: z15.enum(["completed", "aborted", "error", "timeout", "unknown"]),
1951
1985
  durationMillis: durationMillisSchema.optional(),
1952
1986
  /** Session totals, typically cumulative. */
1953
1987
  usage: canonicalUsageSchema.optional(),
1954
1988
  cost: costFactsSchema.optional()
1955
1989
  });
1956
1990
  var promptSubmittedEventSchema = event2({
1957
- type: z14.literal("prompt.submitted"),
1958
- promptSource: z14.enum(["user", "automation", "resumed", "unknown"]),
1991
+ type: z15.literal("prompt.submitted"),
1992
+ promptSource: z15.enum(["user", "automation", "resumed", "unknown"]),
1959
1993
  content: contentFactSchema.optional(),
1960
- turnIndex: z14.number().int().min(0).optional()
1994
+ turnIndex: z15.number().int().min(0).optional()
1961
1995
  });
1962
1996
  var generationStartEventSchema = event2({
1963
- type: z14.literal("generation.start"),
1997
+ type: z15.literal("generation.start"),
1964
1998
  generationId: nonEmptyStringSchema,
1965
1999
  model: modelDescriptorSchema,
1966
2000
  requestedMaxOutputTokens: tokenCountSchema.optional(),
1967
2001
  inputContent: contentFactsSchema.optional()
1968
2002
  });
1969
2003
  var generationEndEventSchema = event2({
1970
- type: z14.literal("generation.end"),
2004
+ type: z15.literal("generation.end"),
1971
2005
  generationId: nonEmptyStringSchema,
1972
2006
  model: modelDescriptorSchema,
1973
2007
  outcome: outcomeSchema,
@@ -1977,7 +2011,7 @@ var generationEndEventSchema = event2({
1977
2011
  cost: costFactsSchema.optional(),
1978
2012
  outputContent: contentFactsSchema.optional()
1979
2013
  });
1980
- var toolKindSchema = z14.enum([
2014
+ var toolKindSchema = z15.enum([
1981
2015
  "read",
1982
2016
  "write",
1983
2017
  "execute",
@@ -1988,59 +2022,63 @@ var toolKindSchema = z14.enum([
1988
2022
  "unknown"
1989
2023
  ]);
1990
2024
  var toolStartEventSchema = event2({
1991
- type: z14.literal("tool.start"),
2025
+ type: z15.literal("tool.start"),
1992
2026
  toolCallId: nonEmptyStringSchema,
1993
2027
  toolName: nonEmptyStringSchema,
1994
2028
  toolKind: toolKindSchema,
1995
2029
  generationId: nonEmptyStringSchema.optional(),
1996
- input: contentFactSchema.optional()
2030
+ input: contentFactSchema.optional(),
2031
+ /** The git worktree this call targeted, resolved by the core (ADR 0008). */
2032
+ target: workspaceTargetSchema.optional()
1997
2033
  });
1998
2034
  var toolEndEventSchema = event2({
1999
- type: z14.literal("tool.end"),
2035
+ type: z15.literal("tool.end"),
2000
2036
  toolCallId: nonEmptyStringSchema,
2001
2037
  toolName: nonEmptyStringSchema,
2002
2038
  outcome: outcomeSchema,
2003
2039
  durationMillis: durationMillisSchema.optional(),
2004
2040
  /** Present when the host asked for or recorded a permission decision. */
2005
- permissionDecision: z14.enum(["allowed", "denied", "deferred", "not-required"]).optional(),
2006
- output: contentFactSchema.optional()
2041
+ permissionDecision: z15.enum(["allowed", "denied", "deferred", "not-required"]).optional(),
2042
+ output: contentFactSchema.optional(),
2043
+ /** The git worktree this call targeted, resolved by the core (ADR 0008). */
2044
+ target: workspaceTargetSchema.optional()
2007
2045
  });
2008
2046
  var subagentStartEventSchema = event2({
2009
- type: z14.literal("subagent.start"),
2047
+ type: z15.literal("subagent.start"),
2010
2048
  subagentInvocationId: invocationIdSchema,
2011
2049
  subagentType: nonEmptyStringSchema.optional(),
2012
2050
  /** 0 for the top-level agent; 1 for its direct children. */
2013
- delegationDepth: z14.number().int().min(0).max(64),
2051
+ delegationDepth: z15.number().int().min(0).max(64),
2014
2052
  model: modelDescriptorSchema.optional()
2015
2053
  });
2016
2054
  var subagentEndEventSchema = event2({
2017
- type: z14.literal("subagent.end"),
2055
+ type: z15.literal("subagent.end"),
2018
2056
  subagentInvocationId: invocationIdSchema,
2019
2057
  outcome: outcomeSchema,
2020
2058
  durationMillis: durationMillisSchema.optional(),
2021
2059
  usage: canonicalUsageSchema.optional()
2022
2060
  });
2023
2061
  var compactionPerformedEventSchema = event2({
2024
- type: z14.literal("compaction.performed"),
2025
- trigger: z14.enum(["automatic", "manual", "unknown"]),
2062
+ type: z15.literal("compaction.performed"),
2063
+ trigger: z15.enum(["automatic", "manual", "unknown"]),
2026
2064
  /** Provider-reported context size before and after compaction, if known. */
2027
2065
  contextTokensBefore: tokenCountSchema.optional(),
2028
2066
  contextTokensAfter: tokenCountSchema.optional(),
2029
- droppedMessageCount: z14.number().int().min(0).optional(),
2067
+ droppedMessageCount: z15.number().int().min(0).optional(),
2030
2068
  usage: canonicalUsageSchema.optional()
2031
2069
  });
2032
2070
  var errorRaisedEventSchema = event2({
2033
- type: z14.literal("error.raised"),
2071
+ type: z15.literal("error.raised"),
2034
2072
  errorCode: otelHookErrorCodeSchema,
2035
2073
  severity: errorSeveritySchema,
2036
2074
  phase: errorPhaseSchema,
2037
- retryable: z14.boolean(),
2075
+ retryable: z15.boolean(),
2038
2076
  /** Error text is content: it is described, never embedded verbatim by default. */
2039
2077
  message: contentFactSchema.optional(),
2040
2078
  /** Non-sensitive, provider-agnostic short label. */
2041
2079
  detail: nonEmptyStringSchema.optional()
2042
2080
  });
2043
- var canonicalEventSchema = z14.discriminatedUnion("type", [
2081
+ var canonicalEventSchema = z15.discriminatedUnion("type", [
2044
2082
  sessionStartEventSchema,
2045
2083
  sessionEndEventSchema,
2046
2084
  promptSubmittedEventSchema,
@@ -2055,26 +2093,26 @@ var canonicalEventSchema = z14.discriminatedUnion("type", [
2055
2093
  ]);
2056
2094
 
2057
2095
  // src/providers/adapter.ts
2058
- var providerDetectionSchema = z15.strictObject({
2096
+ var providerDetectionSchema = z16.strictObject({
2059
2097
  providerId: resolvedProviderIdSchema,
2060
2098
  confidence: detectionConfidenceSchema,
2061
2099
  /**
2062
2100
  * Short, non-sensitive justifications, e.g. `"payload.hook_event_name present"`.
2063
2101
  * Reasons are exported in diagnostics, so they must not quote payload values.
2064
2102
  */
2065
- reasons: z15.array(z15.string().min(1).max(160)).max(8),
2103
+ reasons: z16.array(z16.string().min(1).max(160)).max(8),
2066
2104
  providerVersion: nonEmptyStringSchema.optional(),
2067
2105
  /** The provider's own name for this event, when the payload states one. */
2068
2106
  sourceEventName: nonEmptyStringSchema.optional()
2069
2107
  });
2070
- var deliveryIdentifierSupportSchema = z15.enum(["none", "partial", "all"]);
2108
+ var deliveryIdentifierSupportSchema = z16.enum(["none", "partial", "all"]);
2071
2109
  var DELIVERY_COMPONENT_PATTERN = /^[A-Za-z0-9_.:@+=-]{1,256}$/;
2072
- var deliveryComponentSchema = z15.string().regex(
2110
+ var deliveryComponentSchema = z16.string().regex(
2073
2111
  DELIVERY_COMPONENT_PATTERN,
2074
2112
  "delivery component must be identifier-shaped: no whitespace, no path separators"
2075
2113
  );
2076
2114
  var MAX_DELIVERY_COMPONENTS = 8;
2077
- var providerDeliveryClaimSchema = z15.strictObject({
2115
+ var providerDeliveryClaimSchema = z16.strictObject({
2078
2116
  /**
2079
2117
  * The provider's own session/conversation id. Scopes the callback identity, so
2080
2118
  * two sessions reusing one tool-call id never collide.
@@ -2086,26 +2124,26 @@ var providerDeliveryClaimSchema = z15.strictObject({
2086
2124
  * Identifier-shaped payload fields that, together with `sourceEventName`,
2087
2125
  * name this callback within the session exactly once.
2088
2126
  */
2089
- components: z15.array(deliveryComponentSchema).min(1).max(MAX_DELIVERY_COMPONENTS).readonly(),
2127
+ components: z16.array(deliveryComponentSchema).min(1).max(MAX_DELIVERY_COMPONENTS).readonly(),
2090
2128
  /**
2091
2129
  * Short, non-sensitive justifications, e.g. `"payload.tool_use_id names one
2092
2130
  * tool call"`. Evidence reaches diagnostics, so it must name fields, never
2093
2131
  * quote their values.
2094
2132
  */
2095
- evidence: z15.array(z15.string().min(1).max(160)).min(1).max(4).readonly()
2133
+ evidence: z16.array(z16.string().min(1).max(160)).min(1).max(4).readonly()
2096
2134
  });
2097
2135
  var DELIVERY_GAP_REASON_PATTERN = /^[^\n\r\t\\/]{1,240}$/;
2098
- var deliveryGapReasonSchema = z15.string().regex(
2136
+ var deliveryGapReasonSchema = z16.string().regex(
2099
2137
  DELIVERY_GAP_REASON_PATTERN,
2100
2138
  "delivery gap reason must be one line of prose: no path separators, no control characters"
2101
2139
  );
2102
2140
  var MAX_DELIVERY_GAPS = 48;
2103
- var providerDeliveryGapsSchema = z15.record(deliveryComponentSchema, deliveryGapReasonSchema).refine((gaps) => Object.keys(gaps).length <= MAX_DELIVERY_GAPS, {
2141
+ var providerDeliveryGapsSchema = z16.record(deliveryComponentSchema, deliveryGapReasonSchema).refine((gaps) => Object.keys(gaps).length <= MAX_DELIVERY_GAPS, {
2104
2142
  message: `at most ${String(MAX_DELIVERY_GAPS)} delivery gaps may be declared`
2105
2143
  });
2106
- var providerCapabilitiesSchema = z15.strictObject({
2144
+ var providerCapabilitiesSchema = z16.strictObject({
2107
2145
  /** Event types the adapter can produce. */
2108
- lifecycleEvents: z15.array(canonicalEventTypeSchema).max(32).readonly(),
2146
+ lifecycleEvents: z16.array(canonicalEventTypeSchema).max(32).readonly(),
2109
2147
  usageTemporality: usageTemporalitySchema,
2110
2148
  /**
2111
2149
  * Which accumulator series a `cumulative` report continues — that is, which
@@ -2124,32 +2162,32 @@ var providerCapabilitiesSchema = z15.strictObject({
2124
2162
  * Subagent snapshots keep their own series regardless: a delegated agent's
2125
2163
  * counter is not a point on the parent session's curve.
2126
2164
  */
2127
- cumulativeUsageSeries: z15.enum(["event-scope", "session-lifetime"]).optional(),
2128
- reportsCachedInput: z15.boolean(),
2129
- reportsCacheCreation: z15.boolean(),
2165
+ cumulativeUsageSeries: z16.enum(["event-scope", "session-lifetime"]).optional(),
2166
+ reportsCachedInput: z16.boolean(),
2167
+ reportsCacheCreation: z16.boolean(),
2130
2168
  cacheCreationAccounting: cacheCreationAccountingSchema,
2131
- reportsReasoningOutput: z15.boolean(),
2132
- reportsProviderTotal: z15.boolean(),
2133
- reportsCost: z15.boolean(),
2134
- emitsSubagentEvents: z15.boolean(),
2135
- emitsCompactionEvents: z15.boolean(),
2169
+ reportsReasoningOutput: z16.boolean(),
2170
+ reportsProviderTotal: z16.boolean(),
2171
+ reportsCost: z16.boolean(),
2172
+ emitsSubagentEvents: z16.boolean(),
2173
+ emitsCompactionEvents: z16.boolean(),
2136
2174
  /** True when the provider reads a structured response from stdout. */
2137
- requiresHookResponse: z15.boolean(),
2175
+ requiresHookResponse: z16.boolean(),
2138
2176
  /** How much of this provider's hook traffic is replay-identifiable. */
2139
2177
  deliveryIdentifier: deliveryIdentifierSupportSchema
2140
2178
  });
2141
- var providerHookResponseSchema = z15.strictObject({
2179
+ var providerHookResponseSchema = z16.strictObject({
2142
2180
  /**
2143
2181
  * Always 0. A telemetry hook that can fail the host agent is a liability, so
2144
2182
  * the type forbids expressing anything else (ADR 0004).
2145
2183
  */
2146
- exitCode: z15.literal(0),
2184
+ exitCode: z16.literal(0),
2147
2185
  /** Protocol response text. Omit to write nothing at all. */
2148
- stdout: z15.string().max(8192).optional(),
2186
+ stdout: z16.string().max(8192).optional(),
2149
2187
  /** Non-sensitive diagnostic text for stderr. */
2150
- stderr: z15.string().max(8192).optional(),
2188
+ stderr: z16.string().max(8192).optional(),
2151
2189
  /** Declares which of the two stdout contracts this response follows. */
2152
- contract: z15.enum(["silent", "provider-protocol"])
2190
+ contract: z16.enum(["silent", "provider-protocol"])
2153
2191
  });
2154
2192
  var SILENT_HOOK_RESPONSE = Object.freeze({
2155
2193
  exitCode: 0,
@@ -2181,6 +2219,32 @@ var ANTIGRAVITY_CAPABILITIES = Object.freeze({
2181
2219
  deliveryIdentifier: "partial"
2182
2220
  });
2183
2221
 
2222
+ // src/providers/claude/usage.ts
2223
+ var CLAUDE_EXCLUDED_USAGE_COUNTERS = Object.freeze({
2224
+ total_tokens: `usage.total_tokens is outside Claude Code's usage contract (capability reportsProviderTotal=false): it is not read, so providerTotalAgreement stays "unreported"`,
2225
+ reasoning_output_tokens: "usage.reasoning_output_tokens is outside Claude Code's usage contract (capability reportsReasoningOutput=false): Anthropic bills thinking tokens inside output_tokens with no separate counter, so it is not read and reasoningOutputTokens stays 0"
2226
+ });
2227
+
2228
+ // src/providers/claude/payload-normalize.ts
2229
+ var FIELD_ALIASES = Object.freeze({
2230
+ hookEventName: "hook_event_name",
2231
+ sessionId: "session_id",
2232
+ lastAssistantMessage: "last_assistant_message",
2233
+ transcriptPath: "transcript_path",
2234
+ promptId: "prompt_id",
2235
+ toolUseId: "tool_use_id",
2236
+ toolName: "tool_name",
2237
+ toolInput: "tool_input",
2238
+ toolResponse: "tool_response",
2239
+ toolError: "tool_error",
2240
+ stopHookActive: "stop_hook_active",
2241
+ agentId: "agent_id",
2242
+ agentType: "agent_type",
2243
+ errorType: "error_type",
2244
+ errorMessage: "error_message",
2245
+ tokenUsage: "token_usage"
2246
+ });
2247
+
2184
2248
  // src/providers/claude/detect.ts
2185
2249
  var CLAUDE_CODE_PROVIDER_ID = asProviderId("claude-code");
2186
2250
  var KNOWN_EVENT_NAMES = new Set(CLAUDE_HOOK_EVENT_NAMES);