agy-delegate-mcp 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/turn-state.js CHANGED
@@ -1,8 +1,5 @@
1
- // Everything describing the turn in progress, in one object because it has to be wiped as one:
2
- // session/load replays the previous turn as ordinary update frames, so anything left behind
3
- // leaks into the next result. Fields are declared in exactly one place, freshFields(), which is
4
- // also what reset() applies — a field added there is reset for free, and one that is missed is a
5
- // silent stale-data bug on resume.
1
+ // Everything describing the turn in progress, reset as one before the prompt. freshFields() is the
2
+ // single declaration reset() applies, so a field added there is reset too.
6
3
 
7
4
  const isTerminalToolStatus = (status) =>
8
5
  status === "completed" || status === "failed" || status === "cancelled";
@@ -46,33 +43,27 @@ function progressStream(prefix, onProgress, throttleMs) {
46
43
  function freshFields() {
47
44
  return {
48
45
  resultChunks: [],
49
- // Text superseded by a later tool call is normally a preamble ("Inspecting the
50
- // implementation."), but the rule cannot tell a preamble from the whole answer: an agent
51
- // that replies and then runs one more command has its entire reply discarded, leaving the
52
- // caller "" with stopReason end_turn and no error. Kept so it can be handed back when
53
- // nothing survived — labelled, never blended with a real final message.
46
+ // Text a later tool call superseded: usually a preamble, but it can be the whole answer when
47
+ // agy replies and then runs one more command. Handed back, labelled, only when nothing else is.
54
48
  discardedResult: "",
55
- // Message text sent while a tool call was still running, since that call started. Not part of
56
- // the result: it is handed back only when the turn ends with the call still unfinished, which
57
- // is how agy reports moving a long shell command to the background.
49
+ // Message text sent since a still-running tool call started; handed back only when the turn
50
+ // ends with the call unfinished (a backgrounded command or ask_question).
58
51
  unfinishedToolText: "",
59
52
  sawToolCall: false,
60
53
  collectingPostToolResult: false,
61
54
  activeToolCalls: new Set(),
62
- // Tool name per call id (agy's `name`, else its title), so an unfinished ask_question, which
63
- // waits on the caller, can be told from a backgrounded command, which finishes by itself.
55
+ // Tool name per call id, to tell an ask_question (waits on the caller) from a backgrounded
56
+ // command (finishes by itself).
64
57
  toolNames: new Map(),
65
- // Set by a usage_update and cleared by any other frame: agy closes a turn, prompted or not,
66
- // with a usage_update after its last message.
58
+ // Set by a usage_update, cleared by any other frame: agy closes every turn with one.
67
59
  usageAfterActivity: false,
60
+ // The newest usage_update's { used, size }; unlike the reply's usage it covers a continuation.
61
+ contextUsage: undefined,
68
62
  lastFrameAt: 0,
69
- // Ids observed terminal, so a stale non-terminal re-send for one is recognized and dropped
70
- // instead of restarting collection — which would demote an already-collected final message
71
- // to discardedResult and mislabel it pre-tool-fallback.
63
+ // Ids seen terminal, so a stale non-terminal re-send cannot discard a collected final message.
72
64
  finishedToolCalls: new Set(),
73
- // agy writes its plan as an artifact: a write_file call carrying ArtifactMetadata, saved
74
- // under ~/.gemini/antigravity-cli/brain/<sessionId>/. Keyed by path, so a rewrite of the
75
- // same artifact replaces the earlier entry.
65
+ // agy's artifacts (the plan): write_file calls carrying ArtifactMetadata, under
66
+ // ~/.gemini/antigravity-cli/brain/<sessionId>/. Keyed by path, so a rewrite replaces.
76
67
  artifacts: new Map(),
77
68
  touched: new Set(),
78
69
  lastToolLabel: null,
@@ -104,8 +95,7 @@ export function makeTurnState({ onProgress, progressThrottleMs = 2000 } = {}) {
104
95
  state.resultChunks.length = 0;
105
96
  },
106
97
 
107
- // The stream is the model's own message, bounded by its output limit; a byte cap
108
- // here would hand back a partial answer as if it were the whole one.
98
+ // Uncapped: a cap would return a partial answer as the whole one.
109
99
  appendResult(text) {
110
100
  state.resultChunks.push(text);
111
101
  },
@@ -138,8 +128,8 @@ export function makeTurnState({ onProgress, progressThrottleMs = 2000 } = {}) {
138
128
  state.finishedToolCalls.add(toolCallId);
139
129
  }
140
130
  if (state.activeToolCalls.size === 0 && !state.collectingPostToolResult) {
141
- // Discard any message text emitted while tools were still running.
142
- // A duplicate or late terminal update must not wipe an already-collected final message.
131
+ // Drop text sent while tools ran; the guard above keeps a late duplicate from wiping a
132
+ // collected final message.
143
133
  state.resetResult();
144
134
  state.collectingPostToolResult = true;
145
135
  }
package/src/version.js CHANGED
@@ -8,13 +8,11 @@ function readVersion() {
8
8
  return JSON.parse(readFileSync(PKG_PATH, "utf8")).version;
9
9
  }
10
10
 
11
- // Captured once, for the ACP/MCP identity handshake that is sent at connect and never re-read.
11
+ // Captured once, for the ACP and MCP identity sent at connect.
12
12
  export const VERSION = readVersion();
13
13
 
14
- // doctor reads fresh rather than using the constant: the MCP child is long-lived and
15
- // /reload-plugins does not restart it, so a version captured at process start goes stale after
16
- // an in-place upgrade — exactly when doctor is run to confirm the new version shipped. An
17
- // un-restarted child running old code stays a gap, but no in-process value can close that.
14
+ // Read fresh for doctor: /reload-plugins does not restart the server, so the constant goes stale
15
+ // after an in-place upgrade.
18
16
  export function readPackageVersion() {
19
17
  try {
20
18
  return readVersion();