@qlairoslabs/acp-client 0.4.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts CHANGED
@@ -21,16 +21,35 @@ export interface InternalSessionCommandInput {
21
21
  readonly hint: string;
22
22
  }
23
23
 
24
- /** Token accounting for a turn. Nullable per-field — not all providers report all of it. */
25
- export interface Usage {
24
+ /**
25
+ * Normalized ACP token counters, using the ACP field names verbatim.
26
+ *
27
+ * These are NOT guaranteed per-turn. The ACP SDK documents `PromptResponse.usage` as
28
+ * usage "for this turn" while documenting the individual fields as totals across all
29
+ * turns/the session, and exposes no discriminator. The library reads them as cumulative
30
+ * internal-session counters and stamps that choice into metering provenance; callers
31
+ * must not sum successive reports. See 9-6-SPEC-metering.md §4.
32
+ *
33
+ * An absent optional counter means the harness did not report the category. It does NOT
34
+ * mean the category was zero.
35
+ */
36
+ export interface TokenUsage {
37
+ totalTokens: number;
26
38
  inputTokens: number;
27
39
  outputTokens: number;
28
- cacheReadTokens?: number;
29
- cacheWriteTokens?: number;
40
+ cachedReadTokens?: number;
41
+ cachedWriteTokens?: number;
30
42
  /** Only providers that do extended thinking report this. */
31
43
  thoughtTokens?: number;
32
44
  }
33
45
 
46
+ /**
47
+ * @deprecated Renamed to {@link TokenUsage}. The old shape used non-ACP field names
48
+ * (`cacheReadTokens`/`cacheWriteTokens`), omitted `totalTokens`, and was described as
49
+ * per-turn. Pre-1.0 rename — see the changelog.
50
+ */
51
+ export type Usage = TokenUsage;
52
+
34
53
  /**
35
54
  * The result of a single prompt turn.
36
55
  *
@@ -46,7 +65,11 @@ export interface PromptResult {
46
65
  /** Raw protocol stop reason: "end_turn" | "cancelled" | "max_tokens" | ... */
47
66
  stopReason: string;
48
67
  status: "completed" | "cancelled" | "error";
49
- usage: Usage | null;
68
+ /**
69
+ * Normalized cumulative counters, or null when the harness reported none or reported
70
+ * something malformed. Null is "unknown", never "zero".
71
+ */
72
+ usage: TokenUsage | null;
50
73
  }
51
74
 
52
75
  /** One boundary-aware delta from an ACP `agent_message_chunk`. */