@ycodium-ai/agent-antigravity 0.2.3598 → 0.2.3608

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 (2) hide show
  1. package/dist/index.js +660 -191
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1623,9 +1623,6 @@ function registerAntigravityAuthCommands(ctx) {
1623
1623
  });
1624
1624
  }
1625
1625
 
1626
- // src/antigravityInstance.ts
1627
- import * as NodeCrypto6 from "node:crypto";
1628
-
1629
1626
  // ../../packages/ycodium-acp-executor/src/executor.ts
1630
1627
  import * as NodeCrypto from "node:crypto";
1631
1628
 
@@ -2113,13 +2110,14 @@ function extractToolCallCommand(rawInput, title) {
2113
2110
  }
2114
2111
  var TOOL_CALL_CONTENT_MAX_CHARS = 8e3;
2115
2112
  var TOOL_CALL_CONTENT_TRUNCATION_MARKER = "[Earlier output truncated]\n\n";
2116
- function boundToolCallOutputText(text) {
2117
- if (text.length <= TOOL_CALL_CONTENT_MAX_CHARS) {
2113
+ function boundTailText(text, limit = TOOL_CALL_CONTENT_MAX_CHARS) {
2114
+ if (text.length <= limit) {
2118
2115
  return text;
2119
2116
  }
2120
- const tail = text.slice(text.length - TOOL_CALL_CONTENT_MAX_CHARS);
2117
+ const tail = text.slice(text.length - limit);
2121
2118
  return `${TOOL_CALL_CONTENT_TRUNCATION_MARKER}${tail}`;
2122
2119
  }
2120
+ var boundToolCallOutputText = (text) => boundTailText(text);
2123
2121
  var RAW_OUTPUT_TEXT_FIELDS = ["content", "stdout", "stderr", "output"];
2124
2122
  function boundToolCallRawOutput(rawOutput) {
2125
2123
  if (!isRecord(rawOutput)) {
@@ -2231,6 +2229,7 @@ function makeToolCallState(input2, options2) {
2231
2229
  ...status ? { status } : {},
2232
2230
  ...command ? { command } : {},
2233
2231
  ...presentation?.detail ? { detail: presentation.detail } : {},
2232
+ ...textContent ? { contentText: textContent } : {},
2234
2233
  data
2235
2234
  };
2236
2235
  }
@@ -2241,6 +2240,7 @@ function mergeToolCallState(previous, next) {
2241
2240
  const status = next.status ?? previous?.status;
2242
2241
  const command = next.command ?? previous?.command;
2243
2242
  const detail = next.detail ?? previous?.detail;
2243
+ const contentText = "content" in next.data ? next.contentText : previous?.contentText;
2244
2244
  return {
2245
2245
  toolCallId: next.toolCallId,
2246
2246
  ...kind ? { kind } : {},
@@ -2248,6 +2248,7 @@ function mergeToolCallState(previous, next) {
2248
2248
  ...status ? { status } : {},
2249
2249
  ...command ? { command } : {},
2250
2250
  ...detail ? { detail } : {},
2251
+ ...contentText ? { contentText } : {},
2251
2252
  data: {
2252
2253
  ...previous?.data,
2253
2254
  ...next.data
@@ -2794,6 +2795,54 @@ function retainToolCallUpdate(toolCalls, next, seen) {
2794
2795
  return { nextToolCall, decision };
2795
2796
  }
2796
2797
 
2798
+ // ../../packages/ycodium-acp-executor/src/executor/child-sessions.ts
2799
+ var CHILD_LIMIT = 256;
2800
+ var active = (status) => status === "running" || status === "waiting";
2801
+ function createChildSessionRegistry(limit = CHILD_LIMIT) {
2802
+ const records = /* @__PURE__ */ new Map();
2803
+ const evictOne = (keep) => {
2804
+ const protectedIds = /* @__PURE__ */ new Set();
2805
+ for (const [id, record2] of records) {
2806
+ if (!active(record2.observed)) continue;
2807
+ protectedIds.add(id);
2808
+ let parent = record2.parentAgentId;
2809
+ while (parent !== void 0 && !protectedIds.has(parent)) {
2810
+ protectedIds.add(parent);
2811
+ parent = records.get(parent)?.parentAgentId;
2812
+ }
2813
+ }
2814
+ for (const id of records.keys()) {
2815
+ if (id === keep || protectedIds.has(id)) continue;
2816
+ records.delete(id);
2817
+ return;
2818
+ }
2819
+ };
2820
+ const add = (sessionId, record2) => {
2821
+ records.set(sessionId, record2);
2822
+ if (records.size > limit) evictOne(sessionId);
2823
+ };
2824
+ return {
2825
+ has: (sessionId) => records.has(sessionId),
2826
+ get: (sessionId) => records.get(sessionId),
2827
+ mark: (sessionId) => {
2828
+ if (records.has(sessionId)) return;
2829
+ add(sessionId, {
2830
+ turnId: void 0,
2831
+ title: void 0,
2832
+ description: void 0,
2833
+ parentAgentId: void 0,
2834
+ observed: void 0,
2835
+ reported: void 0,
2836
+ reportedError: void 0,
2837
+ announced: false,
2838
+ pendingMetadata: false
2839
+ });
2840
+ },
2841
+ add,
2842
+ entries: () => records.entries()
2843
+ };
2844
+ }
2845
+
2797
2846
  // ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.4.0_zod@4.6.5/node_modules/@agentclientprotocol/sdk/dist/schema/index.js
2798
2847
  var AGENT_METHODS = {
2799
2848
  initialize: "initialize",
@@ -26776,7 +26825,9 @@ function createExecutorLifecycle({
26776
26825
  eventStream,
26777
26826
  onInputDead,
26778
26827
  shared,
26779
- promptResults
26828
+ promptResults,
26829
+ settleToolSubagents,
26830
+ settleSessionEnded
26780
26831
  }) {
26781
26832
  const cancel = async (turnId) => {
26782
26833
  failIfDisposed();
@@ -26807,6 +26858,7 @@ function createExecutorLifecycle({
26807
26858
  shared.promptsInFlight = 0;
26808
26859
  shared.activeTurnId = void 0;
26809
26860
  shared.status = "ready";
26861
+ settleToolSubagents("turn-interrupted", targetTurnId);
26810
26862
  emit({
26811
26863
  type: "turn.completed",
26812
26864
  ...stamp(),
@@ -26918,6 +26970,7 @@ function createExecutorLifecycle({
26918
26970
  shared.abortLocalPrompt?.();
26919
26971
  promptResults.finishUnreceived();
26920
26972
  await promptResults.wait();
26973
+ settleSessionEnded();
26921
26974
  emit({
26922
26975
  type: "session.exited",
26923
26976
  ...stamp(),
@@ -27021,6 +27074,304 @@ var acpPromptFailureCategory = (error62, input2) => {
27021
27074
  return error62 instanceof AcpConnectionClosedError ? acpTransportIfEstablished(input2.sessionEstablished, input2.disposed) : void 0;
27022
27075
  };
27023
27076
 
27077
+ // ../../packages/ycodium-acp-executor/src/tool-subagents.ts
27078
+ var EXCLUDED = /* @__PURE__ */ Symbol("excluded");
27079
+ var sealedHidden = (entry) => ({
27080
+ sealed: true,
27081
+ keepToolRow: false,
27082
+ turnId: entry.turnId,
27083
+ kind: entry.kind,
27084
+ taskId: entry.taskId,
27085
+ facts: entry.facts
27086
+ });
27087
+ function toolSubagentSettlementOfTurn(state, failureCategory) {
27088
+ if (state === "cancelled") return "turn-interrupted";
27089
+ return state === "failed" && failureCategory === "transport" ? "session-ended" : "turn-ended";
27090
+ }
27091
+ var sameFacts = (a, b) => a.title === b.title && a.description === b.description && a.summary === b.summary && a.role === b.role && a.model === b.model && a.effort === b.effort && a.rosterKind === b.rosterKind;
27092
+ function linkage(taskId, toolCallId, facts) {
27093
+ return {
27094
+ taskId,
27095
+ taskType: "subagent",
27096
+ toolUseId: toolCallId,
27097
+ title: facts.title,
27098
+ ...facts.role === void 0 ? {} : { role: facts.role },
27099
+ ...facts.model === void 0 ? {} : { model: facts.model },
27100
+ ...facts.effort === void 0 ? {} : { effort: facts.effort },
27101
+ ...facts.rosterKind === void 0 ? {} : { rosterKind: facts.rosterKind }
27102
+ };
27103
+ }
27104
+ var isEntry = (value) => value !== EXCLUDED && !("sealed" in value);
27105
+ function createToolSubagentTracker(spec) {
27106
+ const calls = /* @__PURE__ */ new Map();
27107
+ const agentTasks = /* @__PURE__ */ new Map();
27108
+ const rememberAgent = (ref, taskId, facts) => {
27109
+ agentTasks.set(ref, { taskId, facts });
27110
+ };
27111
+ const turnOf = (turnId) => turnId === void 0 ? {} : { turnId };
27112
+ const onToolCallUpdated = (call) => {
27113
+ const tracked = calls.get(call.toolCallId);
27114
+ if (tracked === EXCLUDED) return void 0;
27115
+ if (tracked !== void 0 && !isEntry(tracked)) {
27116
+ const late = spec.resolve?.(call, tracked.kind, { known: true, background: false });
27117
+ if (late !== void 0 && late.type !== "hold" && late.agentRef !== void 0) {
27118
+ rememberAgent(late.agentRef, tracked.taskId, tracked.facts);
27119
+ }
27120
+ const repeatedTerminal = call.status === "completed" || call.status === "failed";
27121
+ const events2 = [];
27122
+ const final = tracked.final;
27123
+ if (repeatedTerminal && final !== void 0 && final.summary === void 0 && late?.type === "final" && late.status === final.status && late.summary !== void 0) {
27124
+ final.summary = late.summary;
27125
+ events2.push({
27126
+ type: "task.completed",
27127
+ ...turnOf(tracked.turnId),
27128
+ payload: {
27129
+ ...linkage(tracked.taskId, call.toolCallId, tracked.facts),
27130
+ status: final.status,
27131
+ summary: late.summary
27132
+ }
27133
+ });
27134
+ }
27135
+ return {
27136
+ events: events2,
27137
+ handled: !tracked.keepToolRow || repeatedTerminal,
27138
+ ...turnOf(tracked.turnId)
27139
+ };
27140
+ }
27141
+ let known = tracked;
27142
+ let kind;
27143
+ if (known === void 0) {
27144
+ const recognized = spec.recognize(call);
27145
+ if (recognized === void 0) return void 0;
27146
+ if (recognized === "exclude") {
27147
+ calls.set(call.toolCallId, EXCLUDED);
27148
+ return void 0;
27149
+ }
27150
+ kind = recognized;
27151
+ } else {
27152
+ kind = known.kind;
27153
+ }
27154
+ const resolution = spec.resolve?.(call, kind, {
27155
+ known: known?.announced === true,
27156
+ background: known?.background ?? false
27157
+ });
27158
+ if (known?.phase === "idle" && resolution?.type !== "final") {
27159
+ if (resolution?.type === "background" && resolution.agentRef !== void 0) {
27160
+ rememberAgent(resolution.agentRef, known.taskId, known.facts);
27161
+ }
27162
+ return { events: [], handled: true };
27163
+ }
27164
+ let carriedTurn;
27165
+ if (known === void 0 || !known.announced) {
27166
+ if (resolution === void 0 && !(spec.ready?.(call, kind) ?? true)) {
27167
+ if (known === void 0) {
27168
+ calls.set(call.toolCallId, {
27169
+ kind,
27170
+ taskId: call.toolCallId,
27171
+ turnId: call.turnId,
27172
+ facts: spec.facts(call, kind, void 0),
27173
+ phase: "open",
27174
+ status: void 0,
27175
+ background: false,
27176
+ announced: false
27177
+ });
27178
+ }
27179
+ return { events: [], handled: true };
27180
+ }
27181
+ carriedTurn = known?.turnId;
27182
+ calls.delete(call.toolCallId);
27183
+ known = void 0;
27184
+ }
27185
+ const events = [];
27186
+ const ref = known === void 0 ? spec.resumes?.(call, kind) : void 0;
27187
+ const prior = ref === void 0 ? void 0 : agentTasks.get(ref);
27188
+ const facts = spec.facts(call, kind, prior?.facts ?? known?.facts);
27189
+ const turnId = known?.turnId ?? carriedTurn ?? call.turnId;
27190
+ const turn = turnOf(turnId);
27191
+ let entry;
27192
+ if (known !== void 0) {
27193
+ entry = known;
27194
+ } else if (prior !== void 0) {
27195
+ for (const [id, other] of calls) {
27196
+ if (other === EXCLUDED || other.taskId !== prior.taskId) continue;
27197
+ if (isEntry(other)) calls.set(id, sealedHidden(other));
27198
+ else if (other.final !== void 0) {
27199
+ const { final: _superseded, ...rest } = other;
27200
+ calls.set(id, rest);
27201
+ }
27202
+ }
27203
+ entry = {
27204
+ kind,
27205
+ taskId: prior.taskId,
27206
+ turnId,
27207
+ facts,
27208
+ phase: "open",
27209
+ status: "running",
27210
+ background: false,
27211
+ announced: true
27212
+ };
27213
+ calls.set(call.toolCallId, entry);
27214
+ events.push({
27215
+ type: "task.updated",
27216
+ ...turn,
27217
+ payload: {
27218
+ ...linkage(entry.taskId, call.toolCallId, facts),
27219
+ description: facts.description,
27220
+ status: "running"
27221
+ }
27222
+ });
27223
+ } else {
27224
+ entry = {
27225
+ kind,
27226
+ taskId: call.toolCallId,
27227
+ turnId,
27228
+ facts,
27229
+ phase: "open",
27230
+ status: void 0,
27231
+ background: false,
27232
+ announced: true
27233
+ };
27234
+ calls.set(call.toolCallId, entry);
27235
+ if (spec.announce === "started") {
27236
+ events.push({
27237
+ type: "task.started",
27238
+ ...turn,
27239
+ payload: {
27240
+ ...linkage(entry.taskId, call.toolCallId, facts),
27241
+ description: facts.description
27242
+ }
27243
+ });
27244
+ }
27245
+ }
27246
+ const seen = known !== void 0 || prior !== void 0;
27247
+ const wasStatus = entry.status;
27248
+ entry.turnId = turnId;
27249
+ if (resolution?.type === "hold") {
27250
+ entry.facts = facts;
27251
+ return { events, handled: true };
27252
+ }
27253
+ if (resolution?.type === "background") {
27254
+ entry.facts = resolution.role === void 0 ? facts : { ...facts, role: resolution.role };
27255
+ if (!entry.background) {
27256
+ events.push({
27257
+ type: "task.updated",
27258
+ ...turn,
27259
+ payload: {
27260
+ ...linkage(entry.taskId, call.toolCallId, entry.facts),
27261
+ status: "running",
27262
+ isBackgrounded: true
27263
+ }
27264
+ });
27265
+ }
27266
+ entry.background = true;
27267
+ entry.status = "running";
27268
+ if (resolution.agentRef !== void 0)
27269
+ rememberAgent(resolution.agentRef, entry.taskId, entry.facts);
27270
+ return { events, handled: true };
27271
+ }
27272
+ if (resolution?.type === "final") {
27273
+ const finalFacts = resolution.role === void 0 ? facts : { ...facts, role: resolution.role };
27274
+ const keepToolRow = resolution.keepToolRow === true;
27275
+ const base = linkage(entry.taskId, call.toolCallId, finalFacts);
27276
+ if (resolution.agentRef !== void 0)
27277
+ rememberAgent(resolution.agentRef, entry.taskId, finalFacts);
27278
+ calls.set(call.toolCallId, {
27279
+ sealed: true,
27280
+ keepToolRow,
27281
+ ...keepToolRow && (resolution.status === "completed" || resolution.status === "failed") ? { final: { status: resolution.status, summary: resolution.summary } } : {},
27282
+ turnId,
27283
+ kind,
27284
+ taskId: entry.taskId,
27285
+ facts: finalFacts
27286
+ });
27287
+ if (resolution.status === "completed" || resolution.status === "failed") {
27288
+ events.push({
27289
+ type: "task.completed",
27290
+ ...turn,
27291
+ payload: {
27292
+ ...base,
27293
+ status: resolution.status,
27294
+ ...resolution.summary === void 0 ? {} : { summary: resolution.summary }
27295
+ }
27296
+ });
27297
+ } else {
27298
+ events.push({
27299
+ type: "task.updated",
27300
+ ...turn,
27301
+ payload: {
27302
+ ...base,
27303
+ status: resolution.status,
27304
+ ...resolution.status === "idle" ? { outcomeUnknown: true } : {},
27305
+ ...resolution.description === void 0 ? {} : { description: resolution.description },
27306
+ ...resolution.timelineBypass === true ? { timelineBypass: true } : {}
27307
+ }
27308
+ });
27309
+ }
27310
+ return { events, handled: !keepToolRow, ...turn };
27311
+ }
27312
+ const status = call.status === "pending" && wasStatus !== "running" ? "pending" : "running";
27313
+ const changed = !seen && spec.announce === "progress" ? true : seen && (wasStatus !== status || !sameFacts(entry.facts, facts));
27314
+ entry.facts = facts;
27315
+ entry.status = status;
27316
+ if (changed) {
27317
+ events.push({
27318
+ type: "task.progress",
27319
+ ...turn,
27320
+ payload: {
27321
+ ...linkage(entry.taskId, call.toolCallId, facts),
27322
+ description: facts.description,
27323
+ ...facts.summary === void 0 ? {} : { summary: facts.summary },
27324
+ status
27325
+ }
27326
+ });
27327
+ }
27328
+ return { events, handled: true };
27329
+ };
27330
+ const settle2 = (settlement, turnId) => {
27331
+ const events = [];
27332
+ for (const [toolCallId, entry] of calls) {
27333
+ if (!isEntry(entry)) continue;
27334
+ if (settlement !== "session-ended" && turnId !== void 0 && entry.turnId !== void 0 && entry.turnId !== turnId) {
27335
+ continue;
27336
+ }
27337
+ const interrupted = settlement === "turn-interrupted";
27338
+ const ended = settlement === "session-ended" || interrupted && spec.interruptedMayStillRun !== true;
27339
+ if (!entry.announced) {
27340
+ if (ended) calls.set(toolCallId, sealedHidden(entry));
27341
+ else entry.phase = "idle";
27342
+ continue;
27343
+ }
27344
+ const base = linkage(entry.taskId, toolCallId, entry.facts);
27345
+ const turn = turnOf(entry.turnId);
27346
+ if (ended) {
27347
+ events.push({ type: "task.updated", ...turn, payload: { ...base, status: "cancelled" } });
27348
+ calls.set(toolCallId, sealedHidden(entry));
27349
+ continue;
27350
+ }
27351
+ if (entry.phase === "idle") continue;
27352
+ const note = spec.endNote({ interrupted, background: entry.background });
27353
+ events.push({
27354
+ type: "task.updated",
27355
+ ...turn,
27356
+ payload: {
27357
+ ...base,
27358
+ status: "idle",
27359
+ outcomeUnknown: true,
27360
+ description: note.description,
27361
+ ...note.timelineBypass === true ? { timelineBypass: true } : {}
27362
+ }
27363
+ });
27364
+ entry.phase = "idle";
27365
+ }
27366
+ return events;
27367
+ };
27368
+ const mayStillRun = () => {
27369
+ for (const entry of calls.values()) if (isEntry(entry)) return true;
27370
+ return false;
27371
+ };
27372
+ return { onToolCallUpdated, settle: settle2, mayStillRun };
27373
+ }
27374
+
27024
27375
  // ../../packages/ycodium-acp-executor/src/executor/prompt.ts
27025
27376
  function createExecutorPrompt({
27026
27377
  isLive,
@@ -27040,7 +27391,8 @@ function createExecutorPrompt({
27040
27391
  applyRequestedModel,
27041
27392
  notifyPromptSettled,
27042
27393
  shared,
27043
- promptResults
27394
+ promptResults,
27395
+ settleToolSubagents
27044
27396
  }) {
27045
27397
  const settleTurn = (input2) => {
27046
27398
  if (!isLive(input2.expectedGeneration) || input2.record.finished) {
@@ -27064,6 +27416,10 @@ function createExecutorPrompt({
27064
27416
  shared.status = "ready";
27065
27417
  }
27066
27418
  const interrupted = promptResults.hasInterrupted(input2.turnId);
27419
+ settleToolSubagents(
27420
+ toolSubagentSettlementOfTurn(interrupted ? "cancelled" : input2.state, input2.failureCategory),
27421
+ input2.turnId
27422
+ );
27067
27423
  emit({
27068
27424
  type: "turn.completed",
27069
27425
  ...stamp(),
@@ -27984,11 +28340,19 @@ function acpInitializePayload(clientInfo, overrides) {
27984
28340
  writeTextFile: false,
27985
28341
  ...overrides?.fs
27986
28342
  },
27987
- terminal: overrides?.terminal ?? false
28343
+ terminal: overrides?.terminal ?? false,
28344
+ ...overrides?.subagents === true ? { subagents: {} } : {}
27988
28345
  },
27989
28346
  clientInfo
27990
28347
  };
27991
28348
  }
28349
+ function acpCapabilityOverrides(input2) {
28350
+ const rest = {
28351
+ ...input2.clientCapabilities
28352
+ };
28353
+ delete rest.subagents;
28354
+ return input2.subagentSessions === true ? { ...rest, subagents: true } : rest;
28355
+ }
27992
28356
 
27993
28357
  // ../../packages/ycodium-acp-executor/src/refreshDeadline.ts
27994
28358
  var MODEL_CATALOG_REFRESH_TIMEOUT_MS = 9e4;
@@ -28123,6 +28487,20 @@ function createExecutorSession({
28123
28487
  failIfDisposed,
28124
28488
  shared
28125
28489
  }) {
28490
+ const requestSession = async (method, params) => {
28491
+ const knownSessionId = params["sessionId"];
28492
+ if (typeof knownSessionId === "string") shared.ownSessionIds.add(knownSessionId);
28493
+ shared.sessionOpensInFlight += 1;
28494
+ try {
28495
+ const result = await connection.request(method, params);
28496
+ const sessionId = result?.sessionId;
28497
+ if (typeof sessionId === "string" && sessionId.length > 0)
28498
+ shared.ownSessionIds.add(sessionId);
28499
+ return result;
28500
+ } finally {
28501
+ shared.sessionOpensInFlight -= 1;
28502
+ }
28503
+ };
28126
28504
  const openFreshSession = async (expectedGeneration) => {
28127
28505
  const initialized = shared.initializeResult;
28128
28506
  if (initialized === void 0) {
@@ -28133,7 +28511,7 @@ function createExecutorSession({
28133
28511
  initialized.agentCapabilities
28134
28512
  );
28135
28513
  const additionalDirectories = options2.additionalDirectories !== void 0 && options2.additionalDirectories.length > 0 ? { additionalDirectories: options2.additionalDirectories } : {};
28136
- const created = await connection.request("session/new", {
28514
+ const created = await requestSession("session/new", {
28137
28515
  cwd: options2.cwd,
28138
28516
  mcpServers,
28139
28517
  ...additionalDirectories
@@ -28250,7 +28628,13 @@ function createExecutorSession({
28250
28628
  return applyOnce(input2.state, input2.acpSessionId, input2.setup, false);
28251
28629
  };
28252
28630
  const startOnce = async (expectedGeneration) => {
28253
- const initializePayload = acpInitializePayload(options2.clientInfo, options2.clientCapabilities);
28631
+ const initializePayload = acpInitializePayload(
28632
+ options2.clientInfo,
28633
+ acpCapabilityOverrides({
28634
+ clientCapabilities: options2.clientCapabilities,
28635
+ subagentSessions: options2.subagentSessions
28636
+ })
28637
+ );
28254
28638
  const initialized = await connection.request(
28255
28639
  "initialize",
28256
28640
  initializePayload
@@ -28274,7 +28658,7 @@ function createExecutorSession({
28274
28658
  let setup;
28275
28659
  let nextSessionId;
28276
28660
  if (options2.resumeSessionId && options2.resumeMethod === "session/resume") {
28277
- setup = await connection.request("session/resume", {
28661
+ setup = await requestSession("session/resume", {
28278
28662
  sessionId: options2.resumeSessionId,
28279
28663
  cwd: options2.cwd,
28280
28664
  mcpServers,
@@ -28284,7 +28668,7 @@ function createExecutorSession({
28284
28668
  } else if (options2.resumeSessionId) {
28285
28669
  shared.sessionLoadInFlight = true;
28286
28670
  try {
28287
- setup = await connection.request("session/load", {
28671
+ setup = await requestSession("session/load", {
28288
28672
  sessionId: options2.resumeSessionId,
28289
28673
  cwd: options2.cwd,
28290
28674
  mcpServers,
@@ -28299,7 +28683,7 @@ function createExecutorSession({
28299
28683
  });
28300
28684
  nextSessionId = options2.resumeSessionId;
28301
28685
  } else {
28302
- const created = await connection.request("session/new", {
28686
+ const created = await requestSession("session/new", {
28303
28687
  cwd: options2.cwd,
28304
28688
  mcpServers,
28305
28689
  ...additionalDirectories
@@ -28484,6 +28868,127 @@ function createExecutorSettlement({
28484
28868
  return { rememberSettledPromptKey, abortPendingSettlement, settleFromNotification };
28485
28869
  }
28486
28870
 
28871
+ // ../../packages/ycodium-acp-executor/src/executor/subagent-sessions.ts
28872
+ function parseState(raw) {
28873
+ if (!isRecord(raw)) return { status: void 0, error: void 0 };
28874
+ const state = raw["state"];
28875
+ if (state === "running") return { status: "running", error: void 0 };
28876
+ if (state === "requires_action") return { status: "waiting", error: void 0 };
28877
+ if (state !== "idle") return { status: void 0, error: void 0 };
28878
+ const stopReason = raw["stopReason"];
28879
+ const error62 = isRecord(raw["error"]) ? asTrimmedString(raw["error"]["message"]) : void 0;
28880
+ if (stopReason === "error" || isRecord(raw["error"])) return { status: "failed", error: error62 };
28881
+ if (stopReason === "cancelled") return { status: "cancelled", error: void 0 };
28882
+ return { status: "idle", error: void 0 };
28883
+ }
28884
+ function childLinkage(childId, record2) {
28885
+ return {
28886
+ taskType: "subagent",
28887
+ rosterKind: "subagent",
28888
+ nativeSessionId: childId,
28889
+ timelineBypass: true,
28890
+ ...record2.title === void 0 ? {} : { title: record2.title }
28891
+ };
28892
+ }
28893
+ function createSubagentSessionTracker(registry2) {
28894
+ const observe = (notification, ctx) => {
28895
+ const update = notification.update;
28896
+ if (!isRecord(update) || update["sessionUpdate"] !== "subagent_update") return [];
28897
+ const childId = asTrimmedString(update["sessionId"]);
28898
+ if (childId === void 0 || ctx.ownSessionIds.has(childId)) return [];
28899
+ const outerId = notification.sessionId;
28900
+ const nested = registry2.has(outerId);
28901
+ if (ctx.foreign && !nested) return [];
28902
+ if (outerId === childId) return [];
28903
+ const title = asTrimmedString(update["title"]);
28904
+ const description = asTrimmedString(update["description"]);
28905
+ const state = parseState(update["state"]);
28906
+ let record2 = registry2.get(childId);
28907
+ if (record2 === void 0) {
28908
+ record2 = {
28909
+ turnId: ctx.turnId,
28910
+ title,
28911
+ description,
28912
+ parentAgentId: nested ? outerId : void 0,
28913
+ observed: state.status,
28914
+ reported: void 0,
28915
+ reportedError: void 0,
28916
+ // 重放里恢复的身份:宿主早有这一行,不再发 started。
28917
+ announced: ctx.silent,
28918
+ pendingMetadata: false
28919
+ };
28920
+ registry2.add(childId, record2);
28921
+ }
28922
+ record2.turnId ??= ctx.turnId;
28923
+ if (!ctx.silent) {
28924
+ if (title !== void 0 && title !== record2.title || description !== void 0 && description !== record2.description) {
28925
+ record2.pendingMetadata = true;
28926
+ }
28927
+ }
28928
+ if (title !== void 0) record2.title = title;
28929
+ if (description !== void 0) record2.description = description;
28930
+ if (state.status !== void 0) record2.observed = state.status;
28931
+ if (ctx.silent) return [];
28932
+ const linkage2 = childLinkage(childId, record2);
28933
+ const turn = record2.turnId === void 0 ? {} : { turnId: record2.turnId };
28934
+ const events = [];
28935
+ if (!record2.announced && state.status === void 0) return events;
28936
+ if (!record2.announced) {
28937
+ record2.announced = true;
28938
+ record2.pendingMetadata = false;
28939
+ events.push({
28940
+ type: "task.started",
28941
+ ...turn,
28942
+ payload: {
28943
+ taskId: childId,
28944
+ ...linkage2,
28945
+ ...record2.description === void 0 ? {} : { description: record2.description }
28946
+ }
28947
+ });
28948
+ }
28949
+ const statusChanged = state.status !== void 0 && (state.status !== record2.reported || record2.pendingMetadata || state.error !== void 0 && state.error !== record2.reportedError);
28950
+ if (statusChanged) {
28951
+ record2.pendingMetadata = false;
28952
+ record2.reported = state.status;
28953
+ record2.reportedError = state.status === "failed" ? state.error ?? record2.reportedError : void 0;
28954
+ events.push({
28955
+ type: "task.updated",
28956
+ ...turn,
28957
+ payload: {
28958
+ taskId: childId,
28959
+ status: state.status,
28960
+ ...state.error === void 0 ? {} : { error: state.error },
28961
+ ...record2.description === void 0 ? {} : { description: record2.description },
28962
+ ...linkage2
28963
+ }
28964
+ });
28965
+ }
28966
+ return events;
28967
+ };
28968
+ const settleSessionEnded = () => {
28969
+ const events = [];
28970
+ for (const [childId, record2] of registry2.entries()) {
28971
+ const last = record2.reported ?? record2.observed;
28972
+ if (!record2.announced || last !== "running" && last !== "waiting") continue;
28973
+ record2.reported = "idle";
28974
+ record2.observed = "idle";
28975
+ events.push({
28976
+ type: "task.updated",
28977
+ ...record2.turnId === void 0 ? {} : { turnId: record2.turnId },
28978
+ payload: {
28979
+ taskId: childId,
28980
+ status: "idle",
28981
+ outcomeUnknown: true,
28982
+ ...record2.description === void 0 ? {} : { description: record2.description },
28983
+ ...childLinkage(childId, record2)
28984
+ }
28985
+ });
28986
+ }
28987
+ return events;
28988
+ };
28989
+ return { observe, settleSessionEnded };
28990
+ }
28991
+
28487
28992
  // ../../packages/ycodium-acp-executor/src/executor/updates.ts
28488
28993
  var COMPACTION_SUMMARY_MAX_CHARS = 8e3;
28489
28994
  var SHOWN_TOOL_CALL_LIMIT = 256;
@@ -28502,6 +29007,8 @@ function createExecutorUpdates({
28502
29007
  shared
28503
29008
  }) {
28504
29009
  const shownToolCallIds = /* @__PURE__ */ new Set();
29010
+ const markChildSession = shared.childSessions.mark;
29011
+ const subagentSessions = options2.subagentSessions === true ? createSubagentSessionTracker(shared.childSessions) : void 0;
28505
29012
  const emitCompactionState = (record2, state) => {
28506
29013
  const summary = record2.summary?.trim() ?? "";
28507
29014
  const truncated = summary.length > COMPACTION_SUMMARY_MAX_CHARS;
@@ -28587,6 +29094,30 @@ function createExecutorUpdates({
28587
29094
  return;
28588
29095
  }
28589
29096
  };
29097
+ const emitTaskEvents = (taskEvents) => {
29098
+ for (const taskEvent of taskEvents ?? []) {
29099
+ emit({
29100
+ type: taskEvent.type,
29101
+ ...stamp(),
29102
+ provider: options2.provider,
29103
+ threadId: options2.threadId,
29104
+ ...taskEvent.turnId !== void 0 ? { turnId: taskEvent.turnId } : {},
29105
+ payload: taskEvent.payload
29106
+ });
29107
+ }
29108
+ };
29109
+ const toolSubagents = hooks.toolSubagents === void 0 ? void 0 : createToolSubagentTracker(hooks.toolSubagents);
29110
+ const settleToolSubagents = (settlement, turnId) => emitTaskEvents(toolSubagents?.settle(settlement, turnId));
29111
+ const settleSessionEnded = () => {
29112
+ settleToolSubagents("session-ended");
29113
+ emitTaskEvents(subagentSessions?.settleSessionEnded());
29114
+ emitTaskEvents(hooks.onSessionEnded?.());
29115
+ };
29116
+ const observeContext = () => ({
29117
+ turnId: shared.activeTurnId,
29118
+ sessionId: shared.sessionId,
29119
+ markChildSession
29120
+ });
28590
29121
  const handleSessionUpdate = (params) => {
28591
29122
  const parsed = parseSessionUpdateEvent(params);
28592
29123
  if (parsed.modeId && shared.modeState) {
@@ -28613,43 +29144,39 @@ function createExecutorUpdates({
28613
29144
  rawTitle: params.update.title,
28614
29145
  nowMs
28615
29146
  });
28616
- const hookResult = hooks.onToolCallUpdated?.({
29147
+ const hasToolHooks = toolSubagents !== void 0 || hooks.onToolCallUpdated !== void 0;
29148
+ const call = !hasToolHooks ? void 0 : {
28617
29149
  toolCallId: nextToolCall.toolCallId,
28618
29150
  status: nextToolCall.status,
28619
29151
  title: nextToolCall.title,
28620
29152
  kind: nextToolCall.kind,
28621
29153
  rawInput: nextToolCall.data["rawInput"],
28622
29154
  rawOutput: nextToolCall.data["rawOutput"],
29155
+ contentText: nextToolCall.contentText,
28623
29156
  meta: params.update._meta,
28624
29157
  turnId: shared.activeTurnId
28625
- });
28626
- const taskEvents = hookResult === void 0 ? [] : "events" in hookResult ? hookResult.events : hookResult;
29158
+ };
29159
+ const hookResult = call === void 0 ? void 0 : toolSubagents?.onToolCallUpdated(call) ?? hooks.onToolCallUpdated?.(call);
28627
29160
  const handledByHook = hookResult !== void 0 && "events" in hookResult && hookResult.handled === true;
28628
- for (const taskEvent of taskEvents) {
28629
- emit({
28630
- type: taskEvent.type,
28631
- ...stamp(),
28632
- provider: options2.provider,
28633
- threadId: options2.threadId,
28634
- ...taskEvent.turnId !== void 0 ? { turnId: taskEvent.turnId } : {},
28635
- payload: taskEvent.payload
28636
- });
28637
- }
29161
+ emitTaskEvents(
29162
+ hookResult === void 0 ? [] : "events" in hookResult ? hookResult.events : hookResult
29163
+ );
28638
29164
  if (nextToolCall.status === "completed" && hookResult && "artifacts" in hookResult)
28639
29165
  emitArtifacts(hookResult.artifacts ?? [], nextToolCall.toolCallId);
28640
29166
  if (handledByHook || !decision.emit) {
28641
29167
  continue;
28642
29168
  }
29169
+ const toolTurnId = (hookResult !== void 0 && "events" in hookResult ? hookResult.turnId : void 0) ?? shared.activeTurnId;
28643
29170
  if (!shownToolCallIds.has(nextToolCall.toolCallId)) {
28644
29171
  rememberShownToolCall(nextToolCall.toolCallId);
28645
- closeActiveAssistantSegment(shared.activeTurnId);
29172
+ if (toolTurnId === shared.activeTurnId) closeActiveAssistantSegment(shared.activeTurnId);
28646
29173
  }
28647
29174
  emit(
28648
29175
  makeAcpToolCallEvent({
28649
29176
  stamp: stamp(),
28650
29177
  provider: options2.provider,
28651
29178
  threadId: options2.threadId,
28652
- turnId: shared.activeTurnId,
29179
+ turnId: toolTurnId,
28653
29180
  toolCall: nextToolCall,
28654
29181
  rawPayload: event.rawPayload
28655
29182
  })
@@ -28726,7 +29253,36 @@ function createExecutorUpdates({
28726
29253
  }
28727
29254
  }
28728
29255
  };
28729
- return { emitCompactionState, handleSessionUpdate };
29256
+ const receiveSessionUpdate = (params) => {
29257
+ const foreign = !shared.ownSessionIds.has(params.sessionId) && (shared.childSessions.has(params.sessionId) || shared.sessionOpensInFlight === 0 && shared.ownSessionIds.size > 0);
29258
+ emitTaskEvents(
29259
+ subagentSessions?.observe(params, {
29260
+ turnId: shared.activeTurnId,
29261
+ foreign,
29262
+ ownSessionIds: shared.ownSessionIds,
29263
+ silent: shared.sessionLoadInFlight
29264
+ })
29265
+ );
29266
+ if (!shared.sessionLoadInFlight) {
29267
+ if (hooks.onSessionUpdate) {
29268
+ emitTaskEvents(hooks.onSessionUpdate(params, { ...observeContext(), foreign }));
29269
+ }
29270
+ }
29271
+ if (!foreign) handleSessionUpdate(params);
29272
+ };
29273
+ const receiveExtensionNotification = (method, params) => {
29274
+ if (shared.sessionLoadInFlight || !hooks.onExtensionNotification) return;
29275
+ const result = hooks.onExtensionNotification(method, params, observeContext());
29276
+ if (Array.isArray(result)) emitTaskEvents(result);
29277
+ };
29278
+ return {
29279
+ emitCompactionState,
29280
+ receiveSessionUpdate,
29281
+ receiveExtensionNotification,
29282
+ settleToolSubagents,
29283
+ settleSessionEnded,
29284
+ toolSubagentsMayRun: () => toolSubagents?.mayStillRun() ?? false
29285
+ };
28730
29286
  }
28731
29287
 
28732
29288
  // ../../packages/ycodium-acp-executor/src/openCommands.ts
@@ -28875,7 +29431,10 @@ function createAcpExecutor(options2) {
28875
29431
  abortLocalPrompt: void 0,
28876
29432
  connectionClosed: false,
28877
29433
  sessionLoadInFlight: false,
28878
- droppedReplayUpdates: 0
29434
+ droppedReplayUpdates: 0,
29435
+ ownSessionIds: /* @__PURE__ */ new Set(),
29436
+ childSessions: createChildSessionRegistry(),
29437
+ sessionOpensInFlight: 0
28879
29438
  };
28880
29439
  const interruptedTurnIds = /* @__PURE__ */ new Set();
28881
29440
  const approvals = createApprovalGate({
@@ -28905,7 +29464,14 @@ function createAcpExecutor(options2) {
28905
29464
  promptMutex,
28906
29465
  shared
28907
29466
  });
28908
- const { emitCompactionState, handleSessionUpdate } = createExecutorUpdates({
29467
+ const {
29468
+ emitCompactionState,
29469
+ receiveSessionUpdate,
29470
+ receiveExtensionNotification,
29471
+ settleToolSubagents,
29472
+ settleSessionEnded,
29473
+ toolSubagentsMayRun
29474
+ } = createExecutorUpdates({
28909
29475
  emit,
28910
29476
  stamp,
28911
29477
  options: options2,
@@ -28968,11 +29534,11 @@ function createAcpExecutor(options2) {
28968
29534
  if (notification.method === "session/update") {
28969
29535
  const params = notification.params;
28970
29536
  const transformed = hooks.transformSessionUpdate ? hooks.transformSessionUpdate(params) : params;
28971
- if (transformed !== void 0) handleSessionUpdate(transformed);
29537
+ if (transformed !== void 0) receiveSessionUpdate(transformed);
28972
29538
  return;
28973
29539
  }
28974
29540
  if (settleFromNotification(notification.method, notification.params)) return;
28975
- void hooks.onExtensionNotification?.(notification.method, notification.params);
29541
+ receiveExtensionNotification(notification.method, notification.params);
28976
29542
  },
28977
29543
  onRequest: async (method, params) => {
28978
29544
  if (method === CLIENT_METHODS.session_request_permission) {
@@ -29028,6 +29594,7 @@ function createAcpExecutor(options2) {
29028
29594
  });
29029
29595
  const { sendPromptRpc, prompt } = createExecutorPrompt({
29030
29596
  promptResults,
29597
+ settleToolSubagents,
29031
29598
  isLive,
29032
29599
  closeActiveAssistantSegment,
29033
29600
  emit,
@@ -29052,6 +29619,8 @@ function createAcpExecutor(options2) {
29052
29619
  dispose: disposeLifecycle
29053
29620
  } = createExecutorLifecycle({
29054
29621
  promptResults,
29622
+ settleToolSubagents,
29623
+ settleSessionEnded,
29055
29624
  failIfDisposed,
29056
29625
  requireStarted,
29057
29626
  interruptedTurnIds,
@@ -29100,6 +29669,7 @@ function createAcpExecutor(options2) {
29100
29669
  setNativeMode,
29101
29670
  compact,
29102
29671
  openToolCalls: () => readOpenToolCalls(toolCalls, shared.activeTurnId),
29672
+ toolSubagentsMayRun,
29103
29673
  dispose: (exitCode) => {
29104
29674
  disposeOnce ??= (async () => {
29105
29675
  try {
@@ -29280,7 +29850,13 @@ async function openAcpProbeHandshake(input2) {
29280
29850
  });
29281
29851
  try {
29282
29852
  const initializeResult = await withProbeTimeout(
29283
- connection.request("initialize", acpInitializePayload(input2.clientInfo)),
29853
+ connection.request(
29854
+ "initialize",
29855
+ acpInitializePayload(
29856
+ input2.clientInfo,
29857
+ acpCapabilityOverrides({ subagentSessions: input2.subagentSessions })
29858
+ )
29859
+ ),
29284
29860
  input2.requestTimeoutMs,
29285
29861
  "ACP probe request 'initialize'",
29286
29862
  input2.signal
@@ -30269,109 +30845,39 @@ var SUBAGENT_TITLES = /* @__PURE__ */ new Set([
30269
30845
  "Run start_subagent?"
30270
30846
  ]);
30271
30847
  var isRecord12 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
30272
- function linkage(toolCallId) {
30273
- return {
30274
- taskId: toolCallId,
30275
- taskType: "subagent",
30276
- toolUseId: toolCallId,
30277
- title: SUBAGENT_BATCH_TITLE
30278
- };
30279
- }
30280
- function classify(input2) {
30281
- if (input2.kind !== void 0 && input2.kind !== "other") return void 0;
30282
- if (input2.title === void 0 || !SUBAGENT_TITLES.has(input2.title)) return void 0;
30283
- return isRecord12(input2.meta) && input2.meta["is_mcp_tool_call"] === true ? "mcp" : "subagent";
30284
- }
30285
30848
  function outputText(rawOutput) {
30286
30849
  return typeof rawOutput === "string" && rawOutput.trim() !== "" ? boundText(rawOutput.trim()) : void 0;
30287
30850
  }
30288
- function createSubagentTracker() {
30289
- const tracked = /* @__PURE__ */ new Map();
30290
- const onToolCallUpdated = (input2) => {
30291
- const known = tracked.get(input2.toolCallId);
30292
- if (known === "mcp") return [];
30293
- if (known === "finished") return { events: [], handled: true };
30294
- let open4 = known;
30295
- if (open4 === void 0) {
30296
- const kind = classify(input2);
30297
- if (kind === void 0) return [];
30298
- if (kind === "mcp") {
30299
- tracked.set(input2.toolCallId, "mcp");
30300
- return [];
30301
- }
30302
- if (input2.turnId === void 0 && input2.status === "completed" && (input2.rawOutput === void 0 || input2.rawOutput === null)) {
30303
- tracked.set(input2.toolCallId, { turnId: void 0, status: void 0 });
30304
- return { events: [], handled: true };
30305
- }
30306
- open4 = { turnId: input2.turnId, status: void 0 };
30307
- }
30308
- const turnId = open4.turnId ?? input2.turnId;
30309
- const turn = turnId === void 0 ? {} : { turnId };
30310
- const base = linkage(input2.toolCallId);
30311
- if (input2.status === "failed") {
30312
- tracked.set(input2.toolCallId, "finished");
30313
- const summary = outputText(input2.rawOutput);
30314
- return {
30315
- handled: true,
30316
- events: [
30317
- {
30318
- type: "task.completed",
30319
- ...turn,
30320
- payload: { ...base, status: "failed", ...summary ? { summary } : {} }
30321
- }
30322
- ]
30323
- };
30851
+ var antigravityToolSubagents = {
30852
+ recognize: (call) => {
30853
+ if (call.kind !== void 0 && call.kind !== "other") return void 0;
30854
+ if (call.title === void 0 || !SUBAGENT_TITLES.has(call.title)) return void 0;
30855
+ return isRecord12(call.meta) && call.meta["is_mcp_tool_call"] === true ? "exclude" : "subagent";
30856
+ },
30857
+ // `start_subagent` 返回的是启动说明,不是子代理的结果:即使工具已 completed,批也还在跑。
30858
+ facts: (call, _kind, previous) => {
30859
+ const description = outputText(call.rawOutput) ?? previous?.description ?? SUBAGENT_BATCH_TITLE;
30860
+ return { title: SUBAGENT_BATCH_TITLE, description, summary: description };
30861
+ },
30862
+ announce: "progress",
30863
+ resolve: (call, _kind, seen) => {
30864
+ if (call.status === "failed") {
30865
+ const summary = outputText(call.rawOutput);
30866
+ return { type: "final", status: "failed", ...summary ? { summary } : {} };
30324
30867
  }
30325
- if (input2.turnId === void 0 && input2.status === "completed") {
30326
- tracked.set(input2.toolCallId, "finished");
30327
- return {
30328
- handled: true,
30329
- events: [
30330
- {
30331
- type: "task.updated",
30332
- ...turn,
30333
- payload: {
30334
- ...base,
30335
- status: "idle",
30336
- description: EARLIER_BATCH_DESCRIPTION,
30337
- timelineBypass: true
30338
- }
30339
- }
30340
- ]
30341
- };
30868
+ if (call.turnId !== void 0 || call.status !== "completed") return void 0;
30869
+ if (!seen.known && (call.rawOutput === void 0 || call.rawOutput === null)) {
30870
+ return { type: "hold" };
30342
30871
  }
30343
- const status = input2.status === "pending" ? "pending" : "running";
30344
- const description = outputText(input2.rawOutput) ?? open4.description ?? SUBAGENT_BATCH_TITLE;
30345
- const events = open4.status === status && open4.description === description ? [] : [
30346
- {
30347
- type: "task.progress",
30348
- ...turn,
30349
- payload: { ...base, description, summary: description, status }
30350
- }
30351
- ];
30352
- tracked.set(input2.toolCallId, { turnId, status, description });
30353
- return { events, handled: true };
30354
- };
30355
- const finishOpen = (status, error62) => {
30356
- const events = [];
30357
- for (const [toolCallId, entry] of tracked) {
30358
- if (entry === "finished" || entry === "mcp") continue;
30359
- events.push({
30360
- type: "task.updated",
30361
- ...entry.turnId === void 0 ? {} : { turnId: entry.turnId },
30362
- payload: {
30363
- ...linkage(toolCallId),
30364
- status,
30365
- ...status === "idle" ? { description: TURN_ENDED_DESCRIPTION, timelineBypass: true } : {},
30366
- ...error62 === void 0 ? {} : { error: error62 }
30367
- }
30368
- });
30369
- tracked.set(toolCallId, "finished");
30370
- }
30371
- return events;
30372
- };
30373
- return { onToolCallUpdated, finishOpen };
30374
- }
30872
+ return {
30873
+ type: "final",
30874
+ status: "idle",
30875
+ description: EARLIER_BATCH_DESCRIPTION,
30876
+ timelineBypass: true
30877
+ };
30878
+ },
30879
+ endNote: () => ({ description: TURN_ENDED_DESCRIPTION, timelineBypass: true })
30880
+ };
30375
30881
 
30376
30882
  // src/userInput.ts
30377
30883
  var INTERACTION_ID_PREFIX = "interaction_";
@@ -30678,8 +31184,7 @@ function createAntigravitySession({
30678
31184
  login,
30679
31185
  noteSession,
30680
31186
  recordCatalog,
30681
- applyModePlan,
30682
- pushTaskEvents
31187
+ applyModePlan
30683
31188
  }) {
30684
31189
  return {
30685
31190
  startSession: async (input2, signal) => {
@@ -30772,15 +31277,12 @@ function createAntigravitySession({
30772
31277
  threadId: input2.threadId,
30773
31278
  originBindingGeneration: input2.bindingGeneration
30774
31279
  });
30775
- const subagents = createSubagentTracker();
30776
31280
  const hooks = {
30777
31281
  // 大载荷在进执行器之前就截断:事件的 rawPayload 取自这里的返回值。
30778
31282
  transformSessionUpdate: transformAntigravitySessionUpdate,
30779
- // 子代理调用由子代理批接管,不再当命令跟踪;其余调用交给后台命令跟踪。
30780
- onToolCallUpdated: (update) => {
30781
- const subagent = subagents.onToolCallUpdated(update);
30782
- return "handled" in subagent ? subagent : background.onToolCallUpdated(update);
30783
- },
31283
+ // 子代理调用由执行器的子代理跟踪接管,不再当命令跟踪;其余调用交给后台命令跟踪。
31284
+ toolSubagents: antigravityToolSubagents,
31285
+ onToolCallUpdated: background.onToolCallUpdated,
30784
31286
  permissionUserInput: antigravityPermissionUserInput,
30785
31287
  onExtensionRequest: createClientFileHandler({
30786
31288
  cwd,
@@ -30818,17 +31320,9 @@ function createAntigravitySession({
30818
31320
  for await (const event of executor.events) {
30819
31321
  if (event.type === "turn.completed") {
30820
31322
  for (const started of background.promote()) events.push(started);
30821
- const state = event.payload?.state;
30822
- pushTaskEvents(
30823
- input2.threadId,
30824
- subagents.finishOpen(state === "cancelled" ? "cancelled" : "idle")
30825
- );
30826
- } else if (event.type === "session.exited") {
30827
- pushTaskEvents(input2.threadId, subagents.finishOpen("cancelled"));
30828
31323
  }
30829
31324
  events.push(event);
30830
31325
  }
30831
- pushTaskEvents(input2.threadId, subagents.finishOpen("cancelled"));
30832
31326
  })();
30833
31327
  try {
30834
31328
  throwIfStartAborted(signal);
@@ -30885,8 +31379,7 @@ function createAntigravitySession({
30885
31379
  setup: started.sessionSetupResult,
30886
31380
  appliedModeId,
30887
31381
  live,
30888
- background,
30889
- subagents
31382
+ background
30890
31383
  });
30891
31384
  host.log.info("session started", {
30892
31385
  threadId: input2.threadId,
@@ -30921,8 +31414,7 @@ function createAntigravityTurn({
30921
31414
  mutable,
30922
31415
  requireThread,
30923
31416
  stopSession,
30924
- login,
30925
- pushTaskEvents
31417
+ login
30926
31418
  }) {
30927
31419
  const runLogoutTurn = async (booked, input2) => {
30928
31420
  const turnId = input2.expectedTurnId ?? NodeCrypto4.randomUUID();
@@ -31001,13 +31493,6 @@ function createAntigravityTurn({
31001
31493
  ...booked.session.resumeCursor === void 0 ? {} : { resumeCursor: booked.session.resumeCursor }
31002
31494
  };
31003
31495
  } catch (error62) {
31004
- pushTaskEvents(
31005
- input2.threadId,
31006
- booked.subagents.finishOpen(
31007
- "failed",
31008
- error62 instanceof Error ? error62.message : String(error62)
31009
- )
31010
- );
31011
31496
  throw booked.live.signInRequired ? new AntigravitySignInRequiredError() : error62;
31012
31497
  } finally {
31013
31498
  signal?.removeEventListener("abort", onAbort);
@@ -31374,14 +31859,14 @@ async function resolveAntigravityExecutable(input2) {
31374
31859
  }
31375
31860
  if (input2.managed !== void 0) {
31376
31861
  try {
31377
- const active = await readActiveRelease({ layout: input2.managed, names, platform: platform2 });
31378
- if (active !== void 0) {
31862
+ const active2 = await readActiveRelease({ layout: input2.managed, names, platform: platform2 });
31863
+ if (active2 !== void 0) {
31379
31864
  return {
31380
- executablePath: active.executablePath,
31381
- harnessPath: active.harnessPath,
31865
+ executablePath: active2.executablePath,
31866
+ harnessPath: active2.harnessPath,
31382
31867
  source: "managed",
31383
- version: active.version,
31384
- managedVersionDirectory: active.versionDirectory
31868
+ version: active2.version,
31869
+ managedVersionDirectory: active2.versionDirectory
31385
31870
  };
31386
31871
  }
31387
31872
  } catch (error62) {
@@ -32905,20 +33390,6 @@ async function createAntigravityInstance(config2, host, deps) {
32905
33390
  return void 0;
32906
33391
  }
32907
33392
  };
32908
- const pushTaskEvents = (threadId, tasks) => {
32909
- for (const task of tasks) {
32910
- events.push({
32911
- type: task.type,
32912
- eventId: NodeCrypto6.randomUUID(),
32913
- createdAt: nowIso(),
32914
- provider: ANTIGRAVITY_DRIVER_KIND,
32915
- providerInstanceId: host.instanceId,
32916
- threadId,
32917
- ...task.turnId === void 0 ? {} : { turnId: task.turnId },
32918
- payload: task.payload
32919
- });
32920
- }
32921
- };
32922
33393
  const session = createAntigravitySession({
32923
33394
  deps,
32924
33395
  host,
@@ -32938,8 +33409,7 @@ async function createAntigravityInstance(config2, host, deps) {
32938
33409
  login,
32939
33410
  noteSession,
32940
33411
  recordCatalog,
32941
- applyModePlan,
32942
- pushTaskEvents
33412
+ applyModePlan
32943
33413
  });
32944
33414
  const turn = createAntigravityTurn({
32945
33415
  deps,
@@ -32947,8 +33417,7 @@ async function createAntigravityInstance(config2, host, deps) {
32947
33417
  mutable,
32948
33418
  requireThread,
32949
33419
  stopSession,
32950
- login,
32951
- pushTaskEvents
33420
+ login
32952
33421
  });
32953
33422
  const instance = {
32954
33423
  // 探测绝不起进程:官方程序每次启动解包约 1 GB,健康检查又每隔几分钟来一次。只看磁盘上
@@ -33220,7 +33689,7 @@ function resolveAntigravityReleaseAsset(platform2, arch2) {
33220
33689
 
33221
33690
  // src/runtimeInstaller.ts
33222
33691
  var Yauzl = __toESM(require_yauzl(), 1);
33223
- import * as NodeCrypto7 from "node:crypto";
33692
+ import * as NodeCrypto6 from "node:crypto";
33224
33693
  import * as NodeFS2 from "node:fs";
33225
33694
  import * as NodeFSP11 from "node:fs/promises";
33226
33695
  import * as NodePath12 from "node:path";
@@ -33290,7 +33759,7 @@ async function downloadArchive(input2, archivePath) {
33290
33759
  "The Antigravity download size did not match the pinned release."
33291
33760
  );
33292
33761
  }
33293
- const hash2 = NodeCrypto7.createHash("sha256");
33762
+ const hash2 = NodeCrypto6.createHash("sha256");
33294
33763
  let downloaded = 0;
33295
33764
  let reportedPercent = -1;
33296
33765
  const meter = new NodeStream2.Transform({
@@ -33771,12 +34240,12 @@ function createRuntimeManager(deps) {
33771
34240
  () => false
33772
34241
  );
33773
34242
  try {
33774
- const active = await readActiveRelease({ layout, names, platform: platform2 });
34243
+ const active2 = await readActiveRelease({ layout, names, platform: platform2 });
33775
34244
  return {
33776
34245
  hasFiles,
33777
- installed: active !== void 0,
33778
- installedVersion: active?.version ?? null,
33779
- activeReleaseId: active?.releaseId ?? null,
34246
+ installed: active2 !== void 0,
34247
+ installedVersion: active2?.version ?? null,
34248
+ activeReleaseId: active2?.releaseId ?? null,
33780
34249
  damaged: null
33781
34250
  };
33782
34251
  } catch (error62) {
@@ -34117,7 +34586,7 @@ var executors = [
34117
34586
  ];
34118
34587
  var index_default = definePlugin({
34119
34588
  id: "agent-antigravity",
34120
- apiVersion: 48,
34589
+ apiVersion: 49,
34121
34590
  executors,
34122
34591
  activate(ctx) {
34123
34592
  const runtime = createRuntimeManager({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-antigravity",
3
- "version": "0.2.3598",
3
+ "version": "0.2.3608",
4
4
  "description": "Google Antigravity executor: runs the Antigravity agent over Agent Client Protocol stdio.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -31,8 +31,8 @@
31
31
  "typescript": "~6.0.3",
32
32
  "vite-plus": "0.2.2",
33
33
  "yauzl": "^3.4.0",
34
- "@ycodium-ai/plugin-api": "0.2.3598",
35
- "ycodium-acp-executor": "0.2.3598",
34
+ "@ycodium-ai/plugin-api": "0.2.3608",
35
+ "ycodium-acp-executor": "0.2.3608",
36
36
  "ycodium-executor-testing": "0.0.0"
37
37
  },
38
38
  "ycodium": {