@nathapp/nax-agent-acp 0.92.6 → 0.92.8

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to `@nathapp/nax-agent-acp` are recorded here. Versions move in
4
4
  step with `@nathapp/nax-agent`.
5
5
 
6
+ ## [0.92.8] - 2026-11-19
7
+
8
+ - No changes in this package. Released in lockstep with the other nax packages.
9
+
10
+ ## [0.92.7] - 2026-11-17
11
+
12
+ - No changes in this package. Released in lockstep with the other nax packages.
13
+
6
14
  ## [0.92.6] - 2026-11-16
7
15
 
8
16
  - No changes in this package. Released in lockstep with the other nax packages.
@@ -4,7 +4,8 @@
4
4
  * values, holding back only the tail that could start a secret (D5-g); a delta of
5
5
  * one stream, and any tool event, first flushes what the other stream holds, so the
6
6
  * order is kept. Tool calls and results come from tool-events.ts (D5-c to D5-f);
7
- * usage_update costs feed the session's cost meter (D5-b). User chunks, plans, mode,
7
+ * usage_update costs feed the session's cost meter (D5-b); used/size emit separate
8
+ * context_usage snapshots, never billing totals. User chunks, plans, mode,
8
9
  * config and command updates, and anything unknown are dropped. finish() flushes
9
10
  * held text and answers unanswered tool calls; settle(response) does that and then
10
11
  * emits the turn's one usage event (D5-h). onReceipt fires once, on the first
@@ -108,6 +108,12 @@ export function createTurnCollector(emit, options = {}) {
108
108
  return;
109
109
  case "usage_update":
110
110
  meter.observe(update.cost);
111
+ if (Number.isSafeInteger(update.used) &&
112
+ update.used >= 0 &&
113
+ Number.isSafeInteger(update.size) &&
114
+ update.size > 0) {
115
+ send({ type: "context_usage", used: update.used, size: update.size });
116
+ }
111
117
  return;
112
118
  default:
113
119
  return;
@@ -45,6 +45,7 @@ function streamResetUpdate(event, notices) {
45
45
  export function createEventTranslator(deps) {
46
46
  const calls = new Map();
47
47
  const approvals = new Map();
48
+ let context;
48
49
  let compactions = 0;
49
50
  let sessionCostUsd = deps.priorCostUsd ?? 0;
50
51
  const describeCall = (toolCallId, call) => {
@@ -67,7 +68,8 @@ export function createEventTranslator(deps) {
67
68
  function usage(event) {
68
69
  if (event.costSource !== "unpriced")
69
70
  sessionCostUsd += event.costUsd;
70
- return usageUpdate(event, deps.contextWindow, sessionCostUsd);
71
+ const updates = usageUpdate(event, context?.size ?? deps.contextWindow, sessionCostUsd);
72
+ return context === undefined ? updates : updates.map((update) => ({ ...update, ...context }));
71
73
  }
72
74
  function compaction(event) {
73
75
  if (!deps.clientUpdates.compaction)
@@ -113,6 +115,9 @@ export function createEventTranslator(deps) {
113
115
  return [];
114
116
  case "approval_resolved":
115
117
  return resolved(event);
118
+ case "context_usage":
119
+ context = { used: event.used, size: event.size };
120
+ return [{ sessionUpdate: "usage_update", used: event.used, size: event.size }];
116
121
  case "turn_start":
117
122
  case "question":
118
123
  case "turn_end":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nathapp/nax-agent-acp",
3
- "version": "0.92.6",
3
+ "version": "0.92.8",
4
4
  "description": "ACP (Agent Client Protocol) backend for @nathapp/nax-agent sessions: drive Claude Code and other ACP agents through the nax-agent session API.",
5
5
  "license": "MIT",
6
6
  "author": "William Khoo",
@@ -49,7 +49,7 @@
49
49
  "zod": "^4.6.6"
50
50
  },
51
51
  "peerDependencies": {
52
- "@nathapp/nax-agent": "^0.92.6"
52
+ "@nathapp/nax-agent": "^0.92.8"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public",