@moxt-ai/mobius 0.0.458 → 0.0.459

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.
@@ -80,7 +80,7 @@ var __callDispose = (stack, error, hasError) => {
80
80
  // package.json
81
81
  var package_default = {
82
82
  name: "@moxt-ai/mobius",
83
- version: "0.0.458",
83
+ version: "0.0.459",
84
84
  description: "Mobius CLI for pairing and running local AI agent services.",
85
85
  type: "module",
86
86
  bin: {
@@ -171,4 +171,4 @@ export {
171
171
  __callDispose,
172
172
  package_default
173
173
  };
174
- //# sourceMappingURL=chunk-BHWFDFZG.js.map
174
+ //# sourceMappingURL=chunk-OYY3E77D.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../package.json"],
4
- "sourcesContent": ["{\n \"name\": \"@moxt-ai/mobius\",\n \"version\": \"0.0.458\",\n \"description\": \"Mobius CLI for pairing and running local AI agent services.\",\n \"type\": \"module\",\n \"bin\": {\n \"mobius\": \"dist/cli.js\"\n },\n \"exports\": {\n \"./engine\": {\n \"mobius-source\": \"./src/exports/engine.ts\",\n \"types\": \"./dist/exports/engine.d.ts\",\n \"default\": \"./dist/engine.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"NOTICE\",\n \"THIRD-PARTY-NOTICES.txt\"\n ],\n \"engines\": {\n \"node\": \">=22.19.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"exports\": {\n \"./engine\": {\n \"types\": \"./dist/exports/engine.d.ts\",\n \"import\": \"./dist/engine.js\",\n \"default\": \"./dist/engine.js\"\n }\n }\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/moxt-ai/mobius.git\",\n \"directory\": \"packages/cli\"\n },\n \"scripts\": {\n \"prebuild\": \"tsc --project src/engine/acp/harness/claude/upstream/tsconfig.json && tsc --project src/engine/acp/harness/pi/upstream/tsconfig.json\",\n \"build\": \"node scripts/build.ts && tsc --project tsconfig.build.json\",\n \"dev\": \"node --watch src/cli/entrypoint.ts\",\n \"pretypecheck\": \"tsc --project src/engine/acp/harness/claude/upstream/tsconfig.json && tsc --project src/engine/acp/harness/pi/upstream/tsconfig.json\",\n \"prepack\": \"pnpm build\",\n \"start\": \"node dist/cli.js\",\n \"typecheck\": \"tsc --project tsconfig.json && tsc --project tests/tsconfig.json\",\n \"pretest:controlled\": \"pnpm build\",\n \"test:controlled\": \"vitest run tests/sessions tests/runtime\",\n \"pretest:manual\": \"pnpm pretest:controlled\",\n \"test:manual\": \"vitest run tests/manual\",\n \"pretest:agents\": \"pnpm build\",\n \"test:agents\": \"vitest run tests/agents --maxWorkers=2\"\n },\n \"dependencies\": {\n \"undici\": \"8.12.2\"\n },\n \"devDependencies\": {\n \"@moxt-ai/mobius-sdk-before-prompt-suggestions\": \"npm:@moxt-ai/mobius-sdk@0.0.181\",\n \"@agentclientprotocol/sdk\": \"^1.4.0\",\n \"@anthropic-ai/claude-agent-sdk\": \"0.3.257\",\n \"@anthropic-ai/sdk\": \"0.122.0\",\n \"@moxt-ai/mobius-sdk\": \"workspace:*\",\n \"@moxt-ai/mobius-test\": \"workspace:*\",\n \"@types/node\": \"^24.13.5\",\n \"@types/semver\": \"^7.8.0\",\n \"@types/ws\": \"^8.18.1\",\n \"commander\": \"15.0.0\",\n \"drizzle-kit\": \"1.0.0-rc.4\",\n \"drizzle-orm\": \"1.0.0-rc.4\",\n \"esbuild\": \"0.28.2\",\n \"ignore\": \"7.0.9\",\n \"semver\": \"^7.8.5\",\n \"valibot\": \"1.5.0\",\n \"ws\": \"^8.21.3\",\n \"zod\": \"^4.6.7\"\n },\n \"keywords\": [],\n \"author\": \"Moxt\",\n \"license\": \"Apache-2.0\",\n \"bugs\": {\n \"url\": \"https://github.com/moxt-ai/mobius/issues\"\n },\n \"homepage\": \"https://github.com/moxt-ai/mobius#readme\"\n}\n"],
4
+ "sourcesContent": ["{\n \"name\": \"@moxt-ai/mobius\",\n \"version\": \"0.0.459\",\n \"description\": \"Mobius CLI for pairing and running local AI agent services.\",\n \"type\": \"module\",\n \"bin\": {\n \"mobius\": \"dist/cli.js\"\n },\n \"exports\": {\n \"./engine\": {\n \"mobius-source\": \"./src/exports/engine.ts\",\n \"types\": \"./dist/exports/engine.d.ts\",\n \"default\": \"./dist/engine.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"NOTICE\",\n \"THIRD-PARTY-NOTICES.txt\"\n ],\n \"engines\": {\n \"node\": \">=22.19.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"exports\": {\n \"./engine\": {\n \"types\": \"./dist/exports/engine.d.ts\",\n \"import\": \"./dist/engine.js\",\n \"default\": \"./dist/engine.js\"\n }\n }\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/moxt-ai/mobius.git\",\n \"directory\": \"packages/cli\"\n },\n \"scripts\": {\n \"prebuild\": \"tsc --project src/engine/acp/harness/claude/upstream/tsconfig.json && tsc --project src/engine/acp/harness/pi/upstream/tsconfig.json\",\n \"build\": \"node scripts/build.ts && tsc --project tsconfig.build.json\",\n \"dev\": \"node --watch src/cli/entrypoint.ts\",\n \"pretypecheck\": \"tsc --project src/engine/acp/harness/claude/upstream/tsconfig.json && tsc --project src/engine/acp/harness/pi/upstream/tsconfig.json\",\n \"prepack\": \"pnpm build\",\n \"start\": \"node dist/cli.js\",\n \"typecheck\": \"tsc --project tsconfig.json && tsc --project tests/tsconfig.json\",\n \"pretest:controlled\": \"pnpm build\",\n \"test:controlled\": \"vitest run tests/sessions tests/runtime\",\n \"pretest:manual\": \"pnpm pretest:controlled\",\n \"test:manual\": \"vitest run tests/manual\",\n \"pretest:agents\": \"pnpm build\",\n \"test:agents\": \"vitest run tests/agents --maxWorkers=2\"\n },\n \"dependencies\": {\n \"undici\": \"8.12.2\"\n },\n \"devDependencies\": {\n \"@moxt-ai/mobius-sdk-before-prompt-suggestions\": \"npm:@moxt-ai/mobius-sdk@0.0.181\",\n \"@agentclientprotocol/sdk\": \"^1.4.0\",\n \"@anthropic-ai/claude-agent-sdk\": \"0.3.257\",\n \"@anthropic-ai/sdk\": \"0.122.0\",\n \"@moxt-ai/mobius-sdk\": \"workspace:*\",\n \"@moxt-ai/mobius-test\": \"workspace:*\",\n \"@types/node\": \"^24.13.5\",\n \"@types/semver\": \"^7.8.0\",\n \"@types/ws\": \"^8.18.1\",\n \"commander\": \"15.0.0\",\n \"drizzle-kit\": \"1.0.0-rc.4\",\n \"drizzle-orm\": \"1.0.0-rc.4\",\n \"esbuild\": \"0.28.2\",\n \"ignore\": \"7.0.9\",\n \"semver\": \"^7.8.5\",\n \"valibot\": \"1.5.0\",\n \"ws\": \"^8.21.3\",\n \"zod\": \"^4.6.7\"\n },\n \"keywords\": [],\n \"author\": \"Moxt\",\n \"license\": \"Apache-2.0\",\n \"bugs\": {\n \"url\": \"https://github.com/moxt-ai/mobius/issues\"\n },\n \"homepage\": \"https://github.com/moxt-ai/mobius#readme\"\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACI,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,KAAO;AAAA,IACH,QAAU;AAAA,EACd;AAAA,EACA,SAAW;AAAA,IACP,YAAY;AAAA,MACR,iBAAiB;AAAA,MACjB,OAAS;AAAA,MACT,SAAW;AAAA,IACf;AAAA,EACJ;AAAA,EACA,OAAS;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AAAA,EACA,SAAW;AAAA,IACP,MAAQ;AAAA,EACZ;AAAA,EACA,eAAiB;AAAA,IACb,QAAU;AAAA,IACV,SAAW;AAAA,MACP,YAAY;AAAA,QACR,OAAS;AAAA,QACT,QAAU;AAAA,QACV,SAAW;AAAA,MACf;AAAA,IACJ;AAAA,EACJ;AAAA,EACA,YAAc;AAAA,IACV,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACjB;AAAA,EACA,SAAW;AAAA,IACP,UAAY;AAAA,IACZ,OAAS;AAAA,IACT,KAAO;AAAA,IACP,cAAgB;AAAA,IAChB,SAAW;AAAA,IACX,OAAS;AAAA,IACT,WAAa;AAAA,IACb,sBAAsB;AAAA,IACtB,mBAAmB;AAAA,IACnB,kBAAkB;AAAA,IAClB,eAAe;AAAA,IACf,kBAAkB;AAAA,IAClB,eAAe;AAAA,EACnB;AAAA,EACA,cAAgB;AAAA,IACZ,QAAU;AAAA,EACd;AAAA,EACA,iBAAmB;AAAA,IACf,iDAAiD;AAAA,IACjD,4BAA4B;AAAA,IAC5B,kCAAkC;AAAA,IAClC,qBAAqB;AAAA,IACrB,uBAAuB;AAAA,IACvB,wBAAwB;AAAA,IACxB,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,WAAa;AAAA,IACb,eAAe;AAAA,IACf,eAAe;AAAA,IACf,SAAW;AAAA,IACX,QAAU;AAAA,IACV,QAAU;AAAA,IACV,SAAW;AAAA,IACX,IAAM;AAAA,IACN,KAAO;AAAA,EACX;AAAA,EACA,UAAY,CAAC;AAAA,EACb,QAAU;AAAA,EACV,SAAW;AAAA,EACX,MAAQ;AAAA,IACJ,KAAO;AAAA,EACX;AAAA,EACA,UAAY;AAChB;",
6
6
  "names": []
7
7
  }
@@ -32,10 +32,10 @@ import {
32
32
  unhandledRejectionLogFilename,
33
33
  validateLocalPath,
34
34
  validatePairingId
35
- } from "./chunk-TDFSYA4U.js";
35
+ } from "./chunk-KVFXX7GF.js";
36
36
  import {
37
37
  package_default
38
- } from "./chunk-BHWFDFZG.js";
38
+ } from "./chunk-OYY3E77D.js";
39
39
 
40
40
  // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
41
41
  var CommanderError = class extends Error {
@@ -5802,4 +5802,4 @@ async function runCLI() {
5802
5802
  export {
5803
5803
  runCLI
5804
5804
  };
5805
- //# sourceMappingURL=cli-DHEOX6YM.js.map
5805
+ //# sourceMappingURL=cli-2AOWXBAQ.js.map
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  __commonJS,
4
4
  __toESM,
5
5
  package_default
6
- } from "./chunk-BHWFDFZG.js";
6
+ } from "./chunk-OYY3E77D.js";
7
7
 
8
8
  // ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js
9
9
  var require_constants = __commonJS({
@@ -2008,7 +2008,7 @@ if (!(0, import_semver.satisfies)(process.versions.node, package_default.engines
2008
2008
  );
2009
2009
  process.exitCode = 1;
2010
2010
  } else {
2011
- const { runCLI } = await import("./cli-DHEOX6YM.js");
2011
+ const { runCLI } = await import("./cli-2AOWXBAQ.js");
2012
2012
  await runCLI();
2013
2013
  }
2014
2014
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"background-wakeup.d.ts","sourceRoot":"","sources":["../../../../../src/engine/acp/adapter/antigravity/background-wakeup.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,UAAU,EAKlB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAmC,KAAK,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAYrF,eAAO,MAAM,4BAA4B,SAAU,CAAC;AAmHpD,MAAM,WAAW,2BAA2B;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE;QACb,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAClD,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;KACjD,CAAC;CACL;AAED,MAAM,WAAW,0BAA0B;IACvC,QAAQ,CAAC,YAAY,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC9D,QAAQ,CAAC,aAAa,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC/D,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAC7C;AAOD,MAAM,WAAW,kCAAkC;IAC/C,QAAQ,CAAC,cAAc,EAAE,CAAC,YAAY,EAAE,2BAA2B,KAAK,IAAI,CAAC;IAC7E,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IACzE,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;CAC1B;AAuBD,wBAAgB,iBAAiB,CAAC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,MAAM,GAAG,SAAS,CAOrH;AA2ED,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC1C,MAAM,GAAG,SAAS,CAepB;AAiLD;;;;GAIG;AACH,qBAAa,2BAA2B;;IAWpC,YAAY,OAAO,EAAE,kCAAkC,EAItD;IAm0BD,QAAQ,CAAC,iBAAiB,YAAmB,UAAU,KAAG,OAAO,CAAC,IAAI,CAAC,CAyDrE;IAEF,QAAQ,CAAC,iBAAiB,YAAmB,UAAU,KAAG,OAAO,CAAC,0BAA0B,CAAC,CA4M3F;IAmCF,QAAQ,CAAC,gBAAgB,cAAe,MAAM,KAAG,IAAI,CAOnD;IAEF,QAAQ,CAAC,cAAc,cAAe,MAAM,KAAG,IAAI,CAUjD;IAEF,QAAQ,CAAC,aAAa,cAAe,MAAM,KAAG,QAAQ,GAAG,OAAO,CAuB9D;IAEF,QAAQ,CAAC,uBAAuB,YAAa,MAAM,KAAG,IAAI,CAwBxD;IAEF,QAAQ,CAAC,OAAO,QAAO,IAAI,CAUzB;CACL"}
1
+ {"version":3,"file":"background-wakeup.d.ts","sourceRoot":"","sources":["../../../../../src/engine/acp/adapter/antigravity/background-wakeup.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,UAAU,EAKlB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAmC,KAAK,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAYrF,eAAO,MAAM,4BAA4B,SAAU,CAAC;AAiJpD,MAAM,WAAW,2BAA2B;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE;QACb,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAClD,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;KACjD,CAAC;CACL;AAED,MAAM,WAAW,0BAA0B;IACvC,QAAQ,CAAC,YAAY,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC9D,QAAQ,CAAC,aAAa,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC/D,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAC7C;AAOD,MAAM,WAAW,kCAAkC;IAC/C,QAAQ,CAAC,cAAc,EAAE,CAAC,YAAY,EAAE,2BAA2B,KAAK,IAAI,CAAC;IAC7E,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IACzE,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;CAC1B;AAuBD,wBAAgB,iBAAiB,CAAC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,MAAM,GAAG,SAAS,CAOrH;AA2ED,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC1C,MAAM,GAAG,SAAS,CAepB;AA0RD;;;;GAIG;AACH,qBAAa,2BAA2B;;IAWpC,YAAY,OAAO,EAAE,kCAAkC,EAItD;IA6hCD,QAAQ,CAAC,iBAAiB,YAAmB,UAAU,KAAG,OAAO,CAAC,IAAI,CAAC,CAyDrE;IAEF,QAAQ,CAAC,iBAAiB,YAAmB,UAAU,KAAG,OAAO,CAAC,0BAA0B,CAAC,CAuN3F;IAmCF,QAAQ,CAAC,gBAAgB,cAAe,MAAM,KAAG,IAAI,CAOnD;IAEF,QAAQ,CAAC,cAAc,cAAe,MAAM,KAAG,IAAI,CAUjD;IAEF,QAAQ,CAAC,aAAa,cAAe,MAAM,KAAG,QAAQ,GAAG,OAAO,CAuB9D;IAEF,QAAQ,CAAC,uBAAuB,YAAa,MAAM,KAAG,IAAI,CAwBxD;IAEF,QAAQ,CAAC,OAAO,QAAO,IAAI,CAUzB;CACL"}
@@ -16,8 +16,11 @@ const SUBAGENT_IDLE_ID_PATTERN = /\bSubagent ([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4
16
16
  const AGENT_EXECUTOR_ERROR_PATTERN = /^\s*⚠ agent executor error:\s*(.+?)\s*$/su;
17
17
  // The message Antigravity adds to the conversation when a background task it ran finishes.
18
18
  const TASK_RESULT_SENDER_PATTERN = /\bsender=([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/(task-\d+)\b/giu;
19
+ // The tool-step entry Antigravity writes when a command, timer, or workflow moves to the background.
20
+ const BACKGROUND_TASK_CREATED_PATTERN = /\bTool is running as a background task with task id:\s*([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/(task-\d+)\b/iu;
19
21
  const SUBAGENT_CREATED_MARKER = "Created the following subagent";
20
22
  const MAXIMUM_TOOL_DESCRIPTION_CHARS = 500;
23
+ const MINIMUM_TRUNCATED_MATCH_CHARS = 16;
21
24
  const transcriptStepSchema = z.object({
22
25
  content: z.string().optional(),
23
26
  status: z.string().optional(),
@@ -221,6 +224,10 @@ function inspectToolMetadata(update, previous) {
221
224
  }
222
225
  }
223
226
  }
227
+ const matchText = readInputString(inputs, "CommandLine") ??
228
+ readInputString(inputs, "Prompt") ??
229
+ readInputString(inputs, "Description") ??
230
+ previous?.matchText;
224
231
  const description = readInputString(inputs, "toolSummary") ??
225
232
  readInputString(inputs, "Description") ??
226
233
  readInputString(inputs, "Role") ??
@@ -232,10 +239,90 @@ function inspectToolMetadata(update, previous) {
232
239
  category,
233
240
  description: description === undefined ? undefined : truncate(description, MAXIMUM_TOOL_DESCRIPTION_CHARS),
234
241
  isDaemon,
242
+ matchText,
235
243
  subagentKillAll,
236
244
  subagentKillIds: [...subagentKillIds],
237
245
  };
238
246
  }
247
+ function isBackgroundableCategory(category) {
248
+ return category === "command" || category === "schedule" || category === "workflow";
249
+ }
250
+ function decodeTranscriptArg(value) {
251
+ if (typeof value !== "string") {
252
+ return value;
253
+ }
254
+ try {
255
+ return JSON.parse(value);
256
+ }
257
+ catch {
258
+ return value;
259
+ }
260
+ }
261
+ function readTranscriptArgString(args, key) {
262
+ const raw = args[key];
263
+ if (raw === undefined) {
264
+ return undefined;
265
+ }
266
+ const decoded = decodeTranscriptArg(raw);
267
+ if (typeof decoded !== "string") {
268
+ return undefined;
269
+ }
270
+ const stripped = typeof raw === "string" && decoded === raw && decoded.startsWith('"') ? decoded.slice(1) : decoded;
271
+ const trimmed = stripped.trim();
272
+ return trimmed.length > 0 ? trimmed : undefined;
273
+ }
274
+ function readTranscriptToolCallInfo(raw) {
275
+ if (!isRecord(raw)) {
276
+ return null;
277
+ }
278
+ const name = readString(raw, "name");
279
+ const category = name === "run_command"
280
+ ? "command"
281
+ : name === "schedule"
282
+ ? "schedule"
283
+ : name === "run_workflow"
284
+ ? "workflow"
285
+ : null;
286
+ const args = isRecord(raw["args"]) ? raw["args"] : undefined;
287
+ const isDaemon = args !== undefined &&
288
+ (decodeTranscriptArg(args["IsDaemon"]) === true ||
289
+ readTranscriptArgString(args, "CronExpression") !== undefined);
290
+ const matchText = args === undefined
291
+ ? undefined
292
+ : (readTranscriptArgString(args, "CommandLine") ??
293
+ readTranscriptArgString(args, "Prompt") ??
294
+ readTranscriptArgString(args, "Description"));
295
+ return { category, isDaemon, matchText };
296
+ }
297
+ function matchesCandidateText(candidateText, transcriptText) {
298
+ if (candidateText === undefined || transcriptText === undefined) {
299
+ return false;
300
+ }
301
+ if (candidateText === transcriptText) {
302
+ return true;
303
+ }
304
+ const shorter = candidateText.length <= transcriptText.length ? candidateText : transcriptText;
305
+ const longer = candidateText.length <= transcriptText.length ? transcriptText : candidateText;
306
+ return shorter.length >= MINIMUM_TRUNCATED_MATCH_CHARS && longer.startsWith(shorter);
307
+ }
308
+ function extractTaskResultSenderIds(sessionId, steps, minStepExclusive, maxStepInclusive) {
309
+ const targetSessionId = sessionId.toLowerCase();
310
+ const received = new Set();
311
+ for (const step of steps) {
312
+ if (step.step_index <= minStepExclusive ||
313
+ step.step_index > maxStepInclusive ||
314
+ step.type !== "SYSTEM_MESSAGE" ||
315
+ step.content === undefined) {
316
+ continue;
317
+ }
318
+ for (const match of step.content.matchAll(TASK_RESULT_SENDER_PATTERN)) {
319
+ if (match[1]?.toLowerCase() === targetSessionId && match[2] !== undefined) {
320
+ received.add(match[2]);
321
+ }
322
+ }
323
+ }
324
+ return received;
325
+ }
239
326
  function backgroundKindFor(category) {
240
327
  switch (category) {
241
328
  case "command":
@@ -301,6 +388,14 @@ export class AntigravityBackgroundWakeup {
301
388
  }
302
389
  const created = {
303
390
  activeInteractions: 0,
391
+ backgroundCorrelation: {
392
+ boundCreationSteps: new Set(),
393
+ daemonNativeTaskIds: new Set(),
394
+ deliveredNativeTaskIds: new Set(),
395
+ nativeTaskIdByToolCallId: new Map(),
396
+ pendingCandidates: [],
397
+ toolCallIdByNativeTaskId: new Map(),
398
+ },
304
399
  backgroundTasks: new Map(),
305
400
  baselineStepIndex: -1,
306
401
  lastEmittedBackgroundKey: "[]",
@@ -313,8 +408,9 @@ export class AntigravityBackgroundWakeup {
313
408
  pendingToolCallIds: [],
314
409
  },
315
410
  toolMetadata: new Map(),
411
+ wakeupCompletedOpenBgCandidates: new Set(),
316
412
  wakeupGeneration: 0,
317
- wakeupPendingTaskResults: 0,
413
+ wakeupOwedToolCallIds: new Set(),
318
414
  wakeupSettledStepIndex: null,
319
415
  wakeupStageSeq: 0,
320
416
  };
@@ -387,8 +483,19 @@ export class AntigravityBackgroundWakeup {
387
483
  }
388
484
  }
389
485
  };
486
+ #deleteBackgroundTask = (session, toolCallId) => {
487
+ session.backgroundTasks.delete(toolCallId);
488
+ session.wakeupOwedToolCallIds.delete(toolCallId);
489
+ session.wakeupCompletedOpenBgCandidates.delete(toolCallId);
490
+ this.#removeBackgroundCandidate(session, toolCallId);
491
+ session.backgroundCorrelation.nativeTaskIdByToolCallId.delete(toolCallId);
492
+ };
390
493
  #clearAllBackgroundTasks = (session) => {
391
494
  session.backgroundTasks.clear();
495
+ session.wakeupOwedToolCallIds.clear();
496
+ session.wakeupCompletedOpenBgCandidates.clear();
497
+ session.backgroundCorrelation.pendingCandidates.length = 0;
498
+ session.backgroundCorrelation.nativeTaskIdByToolCallId.clear();
392
499
  session.subagents.conversationIdByToolCallId.clear();
393
500
  session.subagents.pendingToolCallIds.length = 0;
394
501
  };
@@ -399,7 +506,105 @@ export class AntigravityBackgroundWakeup {
399
506
  this.#deleteSubagentTask(session, taskId);
400
507
  }
401
508
  else {
402
- session.backgroundTasks.delete(taskId);
509
+ this.#deleteBackgroundTask(session, taskId);
510
+ }
511
+ }
512
+ }
513
+ };
514
+ #recordBackgroundCandidate = (session, toolCallId, meta) => {
515
+ if (meta.isDaemon || !isBackgroundableCategory(meta.category)) {
516
+ return;
517
+ }
518
+ if (session.backgroundCorrelation.nativeTaskIdByToolCallId.has(toolCallId)) {
519
+ return;
520
+ }
521
+ const candidates = session.backgroundCorrelation.pendingCandidates;
522
+ const existingIndex = candidates.findIndex((candidate) => candidate.toolCallId === toolCallId);
523
+ if (existingIndex !== -1) {
524
+ const existing = candidates[existingIndex];
525
+ if (existing !== undefined && existing.matchText === undefined && meta.matchText !== undefined) {
526
+ candidates[existingIndex] = { ...existing, matchText: meta.matchText };
527
+ }
528
+ return;
529
+ }
530
+ candidates.push({
531
+ category: meta.category,
532
+ matchText: meta.matchText,
533
+ toolCallId,
534
+ });
535
+ };
536
+ #removeBackgroundCandidate = (session, toolCallId) => {
537
+ const candidates = session.backgroundCorrelation.pendingCandidates;
538
+ const index = candidates.findIndex((candidate) => candidate.toolCallId === toolCallId);
539
+ if (index !== -1) {
540
+ candidates.splice(index, 1);
541
+ }
542
+ };
543
+ #isActiveBackgroundCandidate = (session, toolCallId) => session.backgroundTasks.has(toolCallId) ||
544
+ (session.phase.kind === "wakeup" && session.phase.openToolIds.has(toolCallId)) ||
545
+ session.wakeupCompletedOpenBgCandidates.has(toolCallId) ||
546
+ session.wakeupOwedToolCallIds.has(toolCallId);
547
+ #pruneInactiveCandidates = (session) => {
548
+ const candidates = session.backgroundCorrelation.pendingCandidates;
549
+ let writeIndex = 0;
550
+ for (const candidate of candidates) {
551
+ if (this.#isActiveBackgroundCandidate(session, candidate.toolCallId)) {
552
+ candidates[writeIndex] = candidate;
553
+ writeIndex += 1;
554
+ }
555
+ }
556
+ candidates.length = writeIndex;
557
+ };
558
+ #syncBackgroundTaskCreations = (sessionId, session, steps) => {
559
+ const correlation = session.backgroundCorrelation;
560
+ const targetSessionId = sessionId.toLowerCase();
561
+ let lastPlanner;
562
+ for (const step of steps) {
563
+ if (step.type === "PLANNER_RESPONSE" && step.tool_calls !== undefined && step.tool_calls.length > 0) {
564
+ lastPlanner = step;
565
+ continue;
566
+ }
567
+ if (step.type !== "GENERIC" ||
568
+ step.status !== "RUNNING" ||
569
+ step.content === undefined ||
570
+ correlation.boundCreationSteps.has(step.step_index)) {
571
+ continue;
572
+ }
573
+ const match = BACKGROUND_TASK_CREATED_PATTERN.exec(step.content);
574
+ if (match === null || match[1]?.toLowerCase() !== targetSessionId || match[2] === undefined) {
575
+ continue;
576
+ }
577
+ const nativeTaskId = match[2];
578
+ correlation.boundCreationSteps.add(step.step_index);
579
+ const offset = lastPlanner === undefined ? -1 : step.step_index - lastPlanner.step_index - 1;
580
+ const rawToolCall = lastPlanner?.tool_calls !== undefined && offset >= 0 && offset < lastPlanner.tool_calls.length
581
+ ? lastPlanner.tool_calls[offset]
582
+ : undefined;
583
+ const info = readTranscriptToolCallInfo(rawToolCall);
584
+ if (info?.isDaemon === true) {
585
+ correlation.daemonNativeTaskIds.add(nativeTaskId);
586
+ continue;
587
+ }
588
+ if ((info !== null && info.category === null) || step.step_index <= session.sessionOpenStepIndex) {
589
+ continue;
590
+ }
591
+ const candidates = correlation.pendingCandidates;
592
+ const categoryMatches = (candidate) => info === null || info.category === null || candidate.category === info.category;
593
+ let matchedIndex = candidates.findIndex((candidate) => this.#isActiveBackgroundCandidate(session, candidate.toolCallId) &&
594
+ categoryMatches(candidate) &&
595
+ matchesCandidateText(candidate.matchText, info?.matchText));
596
+ if (matchedIndex === -1) {
597
+ matchedIndex = candidates.findIndex((candidate) => this.#isActiveBackgroundCandidate(session, candidate.toolCallId) && categoryMatches(candidate));
598
+ }
599
+ if (matchedIndex === -1 && info?.matchText !== undefined) {
600
+ matchedIndex = candidates.findIndex((candidate) => categoryMatches(candidate) && matchesCandidateText(candidate.matchText, info.matchText));
601
+ }
602
+ if (matchedIndex !== -1) {
603
+ const matched = candidates[matchedIndex];
604
+ if (matched !== undefined) {
605
+ candidates.splice(matchedIndex, 1);
606
+ correlation.nativeTaskIdByToolCallId.set(matched.toolCallId, nativeTaskId);
607
+ correlation.toolCallIdByNativeTaskId.set(nativeTaskId, matched.toolCallId);
403
608
  }
404
609
  }
405
610
  }
@@ -592,7 +797,13 @@ export class AntigravityBackgroundWakeup {
592
797
  }
593
798
  session.wakeupGeneration += 1;
594
799
  const generation = session.wakeupGeneration;
595
- session.wakeupPendingTaskResults = [...session.backgroundTasks.values()].filter((task) => task.kind !== "subagent" && task.state === "awaiting-results").length;
800
+ session.wakeupOwedToolCallIds.clear();
801
+ session.wakeupCompletedOpenBgCandidates.clear();
802
+ for (const [toolCallId, task] of session.backgroundTasks) {
803
+ if (task.kind !== "subagent" && task.state === "awaiting-results") {
804
+ session.wakeupOwedToolCallIds.add(toolCallId);
805
+ }
806
+ }
596
807
  session.wakeupSettledStepIndex = null;
597
808
  this.#setWakeupAwaitingOutput(sessionId, session, generation, new Set());
598
809
  notifications.push(makeMetaNotification(sessionId, AGENT_TURN_META, {
@@ -608,6 +819,8 @@ export class AntigravityBackgroundWakeup {
608
819
  }
609
820
  this.#cancelWakeupTimers(session.phase);
610
821
  session.phase = { cancelRequested, kind: "idle" };
822
+ session.wakeupOwedToolCallIds.clear();
823
+ session.wakeupCompletedOpenBgCandidates.clear();
611
824
  this.#dropAwaitingResultTasks(session);
612
825
  const notifications = [];
613
826
  const bgNotification = this.#takeBackgroundTasksUpdate(sessionId, session);
@@ -626,6 +839,8 @@ export class AntigravityBackgroundWakeup {
626
839
  }
627
840
  this.#cancelWakeupTimers(session.phase);
628
841
  session.phase = { cancelRequested: false, kind: "idle" };
842
+ session.wakeupOwedToolCallIds.clear();
843
+ session.wakeupCompletedOpenBgCandidates.clear();
629
844
  this.#dropAwaitingResultTasks(session);
630
845
  const notifications = [];
631
846
  const bgNotification = this.#takeBackgroundTasksUpdate(sessionId, session);
@@ -689,12 +904,17 @@ export class AntigravityBackgroundWakeup {
689
904
  }
690
905
  if (tail !== null) {
691
906
  this.#syncSubagentCreations(current, tail.steps);
907
+ this.#syncBackgroundTaskCreations(sessionId, current, tail.steps);
692
908
  }
693
909
  if (tail?.settledStepIndex !== null && tail?.settledStepIndex !== undefined) {
694
910
  if (this.#settleWakeupReply(sessionId, current, tail, tail.settledStepIndex)) {
695
911
  this.#emitNotifications(this.#finishWakeup(sessionId, current, "end_turn", false));
696
912
  }
697
913
  else {
914
+ const bg = this.#takeBackgroundTasksUpdate(sessionId, current);
915
+ if (bg !== null) {
916
+ this.#emitMetaUpdate(bg);
917
+ }
698
918
  this.#setWakeupAwaitingOutput(sessionId, current, generation, current.phase.openToolIds);
699
919
  }
700
920
  return;
@@ -711,9 +931,10 @@ export class AntigravityBackgroundWakeup {
711
931
  this.#rescheduleTranscriptCheck(sessionId, current, generation, stageEpoch, currentStage);
712
932
  };
713
933
  /**
714
- * Records that the continuation's reply settled at `settledStepIndex` and counts the task results Antigravity
715
- * handed to it up to there. Answers whether the continuation ends: it goes on while results are still owed, since
716
- * Antigravity hands each to the run right after the reply it has, and the run continues from it.
934
+ * Records that the continuation's reply settled at `settledStepIndex` and reconciles the task results Antigravity
935
+ * handed to it up to there against the specific background tool calls still owed. Answers whether the continuation
936
+ * ends: it goes on while any owed non-daemon result has not reached the transcript yet, since Antigravity hands
937
+ * each to the run right after the reply it has, and the run continues from it.
717
938
  */
718
939
  #settleWakeupReply = (sessionId, session, tail, settledStepIndex) => {
719
940
  const sinceStepIndex = session.baselineStepIndex;
@@ -722,25 +943,65 @@ export class AntigravityBackgroundWakeup {
722
943
  this.#consumeSubagentIdlesThrough(session, tail.steps, settledStepIndex);
723
944
  if (tail.firstStepIndex > sinceStepIndex + 1) {
724
945
  // The tail does not reach back to where the reply's run began, so the results it received are unknown.
725
- session.wakeupPendingTaskResults = 0;
946
+ session.wakeupOwedToolCallIds.clear();
947
+ session.wakeupCompletedOpenBgCandidates.clear();
948
+ this.#pruneInactiveCandidates(session);
726
949
  return true;
727
950
  }
728
- const received = new Set();
729
- for (const step of tail.steps) {
730
- if (step.step_index <= sinceStepIndex ||
731
- step.step_index > settledStepIndex ||
732
- step.type !== "SYSTEM_MESSAGE" ||
733
- step.content === undefined) {
734
- continue;
951
+ const correlation = session.backgroundCorrelation;
952
+ const received = extractTaskResultSenderIds(sessionId, tail.steps, sinceStepIndex, settledStepIndex);
953
+ for (const nativeTaskId of received) {
954
+ correlation.deliveredNativeTaskIds.add(nativeTaskId);
955
+ }
956
+ for (const toolCallId of [...session.wakeupCompletedOpenBgCandidates]) {
957
+ session.wakeupCompletedOpenBgCandidates.delete(toolCallId);
958
+ const nativeTaskId = correlation.nativeTaskIdByToolCallId.get(toolCallId);
959
+ if (nativeTaskId !== undefined && !correlation.deliveredNativeTaskIds.has(nativeTaskId)) {
960
+ session.wakeupOwedToolCallIds.add(toolCallId);
961
+ if (!session.backgroundTasks.has(toolCallId)) {
962
+ const meta = session.toolMetadata.get(toolCallId);
963
+ const kind = backgroundKindFor(meta?.category ?? null) ?? "shell";
964
+ session.backgroundTasks.set(toolCallId, {
965
+ ...(meta?.description === undefined ? {} : { description: meta.description }),
966
+ kind,
967
+ state: "awaiting-results",
968
+ taskId: toolCallId,
969
+ toolUseId: toolCallId,
970
+ });
971
+ }
735
972
  }
736
- for (const match of step.content.matchAll(TASK_RESULT_SENDER_PATTERN)) {
737
- if (match[1]?.toLowerCase() === sessionId.toLowerCase() && match[2] !== undefined) {
738
- received.add(match[2]);
973
+ }
974
+ const consumedReceived = new Set();
975
+ const unboundOwed = [];
976
+ for (const toolCallId of [...session.wakeupOwedToolCallIds]) {
977
+ const nativeTaskId = correlation.nativeTaskIdByToolCallId.get(toolCallId);
978
+ if (nativeTaskId !== undefined) {
979
+ if (correlation.deliveredNativeTaskIds.has(nativeTaskId)) {
980
+ session.wakeupOwedToolCallIds.delete(toolCallId);
981
+ consumedReceived.add(nativeTaskId);
739
982
  }
740
983
  }
984
+ else {
985
+ unboundOwed.push(toolCallId);
986
+ }
987
+ }
988
+ if (unboundOwed.length > 0) {
989
+ // Fallback when a task's creation step scrolled out of the 64 KiB tail before we bound its native id:
990
+ // still exclude daemon tasks and native ids bound to other tool calls so they cannot satisfy it.
991
+ let unmatchedReceived = 0;
992
+ for (const nativeTaskId of received) {
993
+ if (!consumedReceived.has(nativeTaskId) &&
994
+ !correlation.daemonNativeTaskIds.has(nativeTaskId) &&
995
+ !correlation.toolCallIdByNativeTaskId.has(nativeTaskId)) {
996
+ unmatchedReceived += 1;
997
+ }
998
+ }
999
+ for (const toolCallId of unboundOwed.slice(0, unmatchedReceived)) {
1000
+ session.wakeupOwedToolCallIds.delete(toolCallId);
1001
+ }
741
1002
  }
742
- session.wakeupPendingTaskResults = Math.max(0, session.wakeupPendingTaskResults - received.size);
743
- return session.wakeupPendingTaskResults === 0;
1003
+ this.#pruneInactiveCandidates(session);
1004
+ return session.wakeupOwedToolCallIds.size === 0;
744
1005
  };
745
1006
  #handleWakeupTimeout = async (sessionId, generation, stageEpoch, message) => {
746
1007
  if (this.#disposed) {
@@ -774,6 +1035,7 @@ export class AntigravityBackgroundWakeup {
774
1035
  }
775
1036
  if (tail !== null) {
776
1037
  this.#syncSubagentCreations(current, tail.steps);
1038
+ this.#syncBackgroundTaskCreations(sessionId, current, tail.steps);
777
1039
  }
778
1040
  if (tail?.settledStepIndex !== null && tail?.settledStepIndex !== undefined) {
779
1041
  // The deadline passed, so a result still awaited is not coming: the settled reply ends the continuation.
@@ -842,7 +1104,7 @@ export class AntigravityBackgroundWakeup {
842
1104
  const meta = inspectToolMetadata(update, session.toolMetadata.get(toolCallId));
843
1105
  session.toolMetadata.set(toolCallId, meta);
844
1106
  if (meta.isDaemon) {
845
- session.backgroundTasks.delete(toolCallId);
1107
+ this.#deleteBackgroundTask(session, toolCallId);
846
1108
  return;
847
1109
  }
848
1110
  if (meta.category === "manage-subagents" && status === "completed") {
@@ -861,6 +1123,7 @@ export class AntigravityBackgroundWakeup {
861
1123
  return;
862
1124
  }
863
1125
  if (!cancelled && status === "in_progress") {
1126
+ this.#recordBackgroundCandidate(session, toolCallId, meta);
864
1127
  session.backgroundTasks.set(toolCallId, {
865
1128
  ...(meta.description === undefined ? {} : { description: meta.description }),
866
1129
  kind,
@@ -872,6 +1135,9 @@ export class AntigravityBackgroundWakeup {
872
1135
  }
873
1136
  if (status === "pending" || status === "completed" || status === "failed" || status === "cancelled") {
874
1137
  session.backgroundTasks.delete(toolCallId);
1138
+ if (status !== "pending") {
1139
+ this.#removeBackgroundCandidate(session, toolCallId);
1140
+ }
875
1141
  }
876
1142
  };
877
1143
  #applyWakeupToolUpdate = async (sessionId, session, update, notifications) => {
@@ -890,7 +1156,7 @@ export class AntigravityBackgroundWakeup {
890
1156
  if (trackedExisting !== undefined) {
891
1157
  if (status === "completed") {
892
1158
  if (trackedExisting.kind !== "subagent" && trackedExisting.state !== "awaiting-results") {
893
- session.wakeupPendingTaskResults += 1;
1159
+ session.wakeupOwedToolCallIds.add(toolCallId);
894
1160
  }
895
1161
  session.backgroundTasks.set(toolCallId, { ...trackedExisting, state: "awaiting-results" });
896
1162
  const bg = this.#takeBackgroundTasksUpdate(sessionId, session);
@@ -906,7 +1172,7 @@ export class AntigravityBackgroundWakeup {
906
1172
  this.#deleteSubagentTask(session, toolCallId);
907
1173
  }
908
1174
  else {
909
- session.backgroundTasks.delete(toolCallId);
1175
+ this.#deleteBackgroundTask(session, toolCallId);
910
1176
  }
911
1177
  const bg = this.#takeBackgroundTasksUpdate(sessionId, session);
912
1178
  if (bg !== null) {
@@ -916,6 +1182,7 @@ export class AntigravityBackgroundWakeup {
916
1182
  return;
917
1183
  }
918
1184
  if (meta.isDaemon) {
1185
+ this.#removeBackgroundCandidate(session, toolCallId);
919
1186
  if (session.phase.openToolIds.has(toolCallId)) {
920
1187
  const nextOpenToolIds = new Set(session.phase.openToolIds);
921
1188
  nextOpenToolIds.delete(toolCallId);
@@ -924,6 +1191,7 @@ export class AntigravityBackgroundWakeup {
924
1191
  return;
925
1192
  }
926
1193
  if (updateKind === "tool_call" && (status === "in_progress" || status === "pending")) {
1194
+ this.#recordBackgroundCandidate(session, toolCallId, meta);
927
1195
  if (!session.phase.openToolIds.has(toolCallId)) {
928
1196
  const nextOpenToolIds = new Set(session.phase.openToolIds);
929
1197
  nextOpenToolIds.add(toolCallId);
@@ -932,12 +1200,25 @@ export class AntigravityBackgroundWakeup {
932
1200
  this.#pauseOrResumeWakeupTimers(sessionId, session);
933
1201
  return;
934
1202
  }
1203
+ if (status === "in_progress" || status === "pending") {
1204
+ this.#recordBackgroundCandidate(session, toolCallId, meta);
1205
+ return;
1206
+ }
935
1207
  if (status === "completed" || status === "failed" || status === "cancelled") {
936
- if (session.phase.openToolIds.has(toolCallId)) {
1208
+ const wasOpenTool = session.phase.openToolIds.has(toolCallId);
1209
+ if (wasOpenTool) {
937
1210
  const nextOpenToolIds = new Set(session.phase.openToolIds);
938
1211
  nextOpenToolIds.delete(toolCallId);
939
1212
  session.phase = { ...session.phase, openToolIds: nextOpenToolIds };
940
1213
  }
1214
+ const kind = backgroundKindFor(meta.category);
1215
+ if (wasOpenTool && status === "completed" && (kind === "shell" || kind === "other")) {
1216
+ this.#recordBackgroundCandidate(session, toolCallId, meta);
1217
+ session.wakeupCompletedOpenBgCandidates.add(toolCallId);
1218
+ }
1219
+ else if (status === "failed" || status === "cancelled") {
1220
+ this.#removeBackgroundCandidate(session, toolCallId);
1221
+ }
941
1222
  if (meta.category === "subagent" && status === "completed") {
942
1223
  this.#registerSubagentTask(session, toolCallId, meta.description);
943
1224
  await this.#syncPendingSubagentCreations(sessionId, session);
@@ -1040,6 +1321,7 @@ export class AntigravityBackgroundWakeup {
1040
1321
  if (tail !== null) {
1041
1322
  session.baselineStepIndex = Math.max(session.baselineStepIndex, tail.maxStepIndex);
1042
1323
  session.sessionOpenStepIndex = Math.max(session.sessionOpenStepIndex, tail.maxStepIndex);
1324
+ this.#syncBackgroundTaskCreations(tracked.sessionId, session, tail.steps);
1043
1325
  }
1044
1326
  if (tracked.kind === "load") {
1045
1327
  session.phase = { cancelRequested: false, kind: "idle" };
@@ -1056,6 +1338,11 @@ export class AntigravityBackgroundWakeup {
1056
1338
  if (tail !== null) {
1057
1339
  session.baselineStepIndex = Math.max(session.baselineStepIndex, tail.maxStepIndex);
1058
1340
  this.#syncSubagentCreations(session, tail.steps);
1341
+ this.#syncBackgroundTaskCreations(tracked.sessionId, session, tail.steps);
1342
+ for (const nativeTaskId of extractTaskResultSenderIds(tracked.sessionId, tail.steps, prePromptStepIndex, session.baselineStepIndex)) {
1343
+ session.backgroundCorrelation.deliveredNativeTaskIds.add(nativeTaskId);
1344
+ }
1345
+ this.#pruneInactiveCandidates(session);
1059
1346
  if (!promptCancelled) {
1060
1347
  let lastPlannerStepIndex;
1061
1348
  for (let index = tail.steps.length - 1; index >= 0; index -= 1) {
@@ -1127,7 +1414,7 @@ export class AntigravityBackgroundWakeup {
1127
1414
  this.#deleteSubagentTask(session, toolCallId);
1128
1415
  }
1129
1416
  else {
1130
- session.backgroundTasks.delete(toolCallId);
1417
+ this.#deleteBackgroundTask(session, toolCallId);
1131
1418
  }
1132
1419
  const bg = this.#takeBackgroundTasksUpdate(sessionId, session);
1133
1420
  return bg === null ? EMPTY_INCOMING_OUTCOME : { afterUpdates: [bg], beforeUpdates: [] };
@@ -1138,7 +1425,7 @@ export class AntigravityBackgroundWakeup {
1138
1425
  this.#deleteSubagentTask(session, toolCallId);
1139
1426
  }
1140
1427
  else {
1141
- session.backgroundTasks.delete(toolCallId);
1428
+ this.#deleteBackgroundTask(session, toolCallId);
1142
1429
  }
1143
1430
  const bg = this.#takeBackgroundTasksUpdate(sessionId, session);
1144
1431
  return bg === null