@moxt-ai/mobius 0.0.462 → 0.0.465

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 (28) hide show
  1. package/dist/{chunk-2KU5227F.js → chunk-CPVZCCBS.js} +243 -72
  2. package/dist/{chunk-2KU5227F.js.map → chunk-CPVZCCBS.js.map} +2 -2
  3. package/dist/{chunk-O56TVV5C.js → chunk-RQXSP55N.js} +2 -2
  4. package/dist/{chunk-O56TVV5C.js.map → chunk-RQXSP55N.js.map} +1 -1
  5. package/dist/{cli-4SSU3XE7.js → cli-4CH5AIPM.js} +3 -3
  6. package/dist/cli.js +2 -2
  7. package/dist/engine/acp/adapter/antigravity/background-wakeup.d.ts.map +1 -1
  8. package/dist/engine/acp/adapter/antigravity/background-wakeup.js +148 -25
  9. package/dist/engine/acp/adapter/antigravity/background-wakeup.js.map +1 -1
  10. package/dist/engine/infra/operation-metrics.d.ts +5 -0
  11. package/dist/engine/infra/operation-metrics.d.ts.map +1 -1
  12. package/dist/engine/infra/operation-metrics.js +9 -1
  13. package/dist/engine/infra/operation-metrics.js.map +1 -1
  14. package/dist/engine/session/api/session-api.d.ts +8 -0
  15. package/dist/engine/session/api/session-api.d.ts.map +1 -1
  16. package/dist/engine/session/api/session-api.js.map +1 -1
  17. package/dist/engine/session/live/agent-session.d.ts.map +1 -1
  18. package/dist/engine/session/live/agent-session.js +26 -21
  19. package/dist/engine/session/live/agent-session.js.map +1 -1
  20. package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
  21. package/dist/engine/session/manager/session-manager.js +3 -2
  22. package/dist/engine/session/manager/session-manager.js.map +1 -1
  23. package/dist/engine/session/prompt/execute-prompt.d.ts.map +1 -1
  24. package/dist/engine/session/prompt/execute-prompt.js +32 -7
  25. package/dist/engine/session/prompt/execute-prompt.js.map +1 -1
  26. package/dist/engine.js +2 -2
  27. package/package.json +1 -1
  28. /package/dist/{cli-4SSU3XE7.js.map → cli-4CH5AIPM.js.map} +0 -0
@@ -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.462",
83
+ version: "0.0.465",
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-O56TVV5C.js.map
174
+ //# sourceMappingURL=chunk-RQXSP55N.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.462\",\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.465\",\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
  }
@@ -33,10 +33,10 @@ import {
33
33
  unhandledRejectionLogFilename,
34
34
  validateLocalPath,
35
35
  validatePairingId
36
- } from "./chunk-2KU5227F.js";
36
+ } from "./chunk-CPVZCCBS.js";
37
37
  import {
38
38
  package_default
39
- } from "./chunk-O56TVV5C.js";
39
+ } from "./chunk-RQXSP55N.js";
40
40
 
41
41
  // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
42
42
  var CommanderError = class extends Error {
@@ -5819,4 +5819,4 @@ async function runCLI() {
5819
5819
  export {
5820
5820
  runCLI
5821
5821
  };
5822
- //# sourceMappingURL=cli-4SSU3XE7.js.map
5822
+ //# sourceMappingURL=cli-4CH5AIPM.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-O56TVV5C.js";
6
+ } from "./chunk-RQXSP55N.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-4SSU3XE7.js");
2011
+ const { runCLI } = await import("./cli-4CH5AIPM.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;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,E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,CAyDrE;IAEF,QAAQ,CAAC,iBAAiB,YAAmB,UAAU,KAAG,OAAO,CAAC,0BAA0B,CAAC,CAuN3F;IAwCF,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"}
@@ -9,6 +9,7 @@ import { AGENT_TURN_META, BACKGROUND_TASKS_META, } from "../../agent/in-process-
9
9
  const TRANSCRIPT_TAIL_BYTES = 65_536;
10
10
  const TRANSCRIPT_INITIAL_DELAY_MS = 40;
11
11
  const TRANSCRIPT_POLL_INTERVAL_MS = 150;
12
+ const MAX_PARTIAL_SETTLED_TEXT_DEFERRALS = 2;
12
13
  export const WAKEUP_INACTIVITY_TIMEOUT_MS = 300_000;
13
14
  const SESSION_UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
14
15
  const SUBAGENT_CONVERSATION_ID_PATTERN = /"conversationId"\s*:\s*"([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})"/giu;
@@ -18,6 +19,8 @@ const AGENT_EXECUTOR_ERROR_PATTERN = /^\s*⚠ agent executor error:\s*(.+?)\s*$/
18
19
  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
20
  // The tool-step entry Antigravity writes when a command, timer, or workflow moves to the background.
20
21
  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;
22
+ const BACKGROUND_TASK_DESCRIPTION_PATTERN = /\nTask Description:\s*([\s\S]+?)(?:\nTask logs are available at:|\nLog output:|$)/u;
23
+ const TRANSCRIPT_TRUNCATED_SUFFIX_PATTERN = /\r?\n<truncated \d+ bytes>$/u;
21
24
  const SUBAGENT_CREATED_MARKER = "Created the following subagent";
22
25
  const MAXIMUM_TOOL_DESCRIPTION_CHARS = 500;
23
26
  const MINIMUM_TRUNCATED_MATCH_CHARS = 16;
@@ -69,7 +72,7 @@ async function readTranscriptTailState(launchEnvironment, sessionId, baselineSte
69
72
  return null;
70
73
  }
71
74
  if (tail.bytes.byteLength === 0) {
72
- return { firstStepIndex: -1, maxStepIndex: -1, settledStepIndex: null, steps: [] };
75
+ return { firstStepIndex: -1, maxStepIndex: -1, settledStep: null, steps: [] };
73
76
  }
74
77
  const text = new TextDecoder().decode(tail.bytes);
75
78
  const lines = text.split("\n");
@@ -102,10 +105,20 @@ async function readTranscriptTailState(launchEnvironment, sessionId, baselineSte
102
105
  return {
103
106
  firstStepIndex,
104
107
  maxStepIndex,
105
- settledStepIndex: settledStep?.step_index ?? null,
108
+ settledStep: settledStep === undefined ? null : { content: settledStep.content, stepIndex: settledStep.step_index },
106
109
  steps,
107
110
  };
108
111
  }
112
+ function extractMessageChunkText(updateKind, update) {
113
+ if (updateKind !== "agent_message_chunk" && updateKind !== "agent_message") {
114
+ return undefined;
115
+ }
116
+ const content = update["content"];
117
+ if (!isRecord(content) || content["type"] !== "text") {
118
+ return undefined;
119
+ }
120
+ return readString(content, "text");
121
+ }
109
122
  function extractUuidMatches(text, pattern) {
110
123
  pattern.lastIndex = 0;
111
124
  const matches = [];
@@ -118,14 +131,7 @@ function extractUuidMatches(text, pattern) {
118
131
  return matches;
119
132
  }
120
133
  export function extractExecutorError(updateKind, update) {
121
- if (updateKind !== "agent_message_chunk" && updateKind !== "agent_message") {
122
- return undefined;
123
- }
124
- const content = update["content"];
125
- if (!isRecord(content) || content["type"] !== "text") {
126
- return undefined;
127
- }
128
- const text = readString(content, "text");
134
+ const text = extractMessageChunkText(updateKind, update);
129
135
  if (text === undefined) {
130
136
  return undefined;
131
137
  }
@@ -258,6 +264,36 @@ function decodeTranscriptArg(value) {
258
264
  return value;
259
265
  }
260
266
  }
267
+ function decodeTruncatedJsonString(raw) {
268
+ if (!raw.startsWith('"')) {
269
+ return undefined;
270
+ }
271
+ let body = raw.slice(1).replace(TRANSCRIPT_TRUNCATED_SUFFIX_PATTERN, "");
272
+ // Drop an incomplete escape sequence at the truncation boundary so appending a closing quote parses as JSON.
273
+ const partialUnicode = /\\u[0-9a-fA-F]{0,3}$/u.exec(body);
274
+ if (partialUnicode !== null) {
275
+ const precedingBackslashes = /\\*$/u.exec(body.slice(0, partialUnicode.index))?.[0].length ?? 0;
276
+ if (precedingBackslashes % 2 === 0) {
277
+ body = body.slice(0, partialUnicode.index);
278
+ }
279
+ }
280
+ const trailingBackslashes = /\\+$/u.exec(body)?.[0].length ?? 0;
281
+ if (trailingBackslashes % 2 === 1) {
282
+ body = body.slice(0, -1);
283
+ }
284
+ try {
285
+ const parsed = JSON.parse(`"${body}"`);
286
+ return typeof parsed === "string" ? parsed : undefined;
287
+ }
288
+ catch {
289
+ return body;
290
+ }
291
+ }
292
+ function extractBackgroundTaskDescription(content) {
293
+ const match = BACKGROUND_TASK_DESCRIPTION_PATTERN.exec(content);
294
+ const description = match?.[1]?.trim();
295
+ return description !== undefined && description.length > 0 ? description : undefined;
296
+ }
261
297
  function readTranscriptArgString(args, key) {
262
298
  const raw = args[key];
263
299
  if (raw === undefined) {
@@ -267,8 +303,10 @@ function readTranscriptArgString(args, key) {
267
303
  if (typeof decoded !== "string") {
268
304
  return undefined;
269
305
  }
270
- const stripped = typeof raw === "string" && decoded === raw && decoded.startsWith('"') ? decoded.slice(1) : decoded;
271
- const trimmed = stripped.trim();
306
+ const normalized = typeof raw === "string" && decoded === raw && raw.startsWith('"')
307
+ ? (decodeTruncatedJsonString(raw) ?? decoded.slice(1))
308
+ : decoded;
309
+ const trimmed = normalized.trim();
272
310
  return trimmed.length > 0 ? trimmed : undefined;
273
311
  }
274
312
  function readTranscriptToolCallInfo(raw) {
@@ -409,10 +447,12 @@ export class AntigravityBackgroundWakeup {
409
447
  },
410
448
  toolMetadata: new Map(),
411
449
  wakeupCompletedOpenBgCandidates: new Set(),
450
+ wakeupDeferredSettledStep: null,
412
451
  wakeupGeneration: 0,
413
452
  wakeupOwedToolCallIds: new Set(),
414
453
  wakeupSettledStepIndex: null,
415
454
  wakeupStageSeq: 0,
455
+ wakeupStreamedMessageText: "",
416
456
  };
417
457
  this.#sessions.set(sessionId, created);
418
458
  return created;
@@ -494,6 +534,8 @@ export class AntigravityBackgroundWakeup {
494
534
  session.backgroundTasks.clear();
495
535
  session.wakeupOwedToolCallIds.clear();
496
536
  session.wakeupCompletedOpenBgCandidates.clear();
537
+ session.wakeupDeferredSettledStep = null;
538
+ session.wakeupStreamedMessageText = "";
497
539
  session.backgroundCorrelation.pendingCandidates.length = 0;
498
540
  session.backgroundCorrelation.nativeTaskIdByToolCallId.clear();
499
541
  session.subagents.conversationIdByToolCallId.clear();
@@ -540,10 +582,19 @@ export class AntigravityBackgroundWakeup {
540
582
  candidates.splice(index, 1);
541
583
  }
542
584
  };
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);
585
+ #isRunningBackgroundCandidate = (session, toolCallId) => {
586
+ const tracked = session.backgroundTasks.get(toolCallId);
587
+ return ((tracked !== undefined && tracked.state === "running") ||
588
+ (session.phase.kind === "wakeup" && session.phase.openToolIds.has(toolCallId)));
589
+ };
590
+ #isCompletedBackgroundCandidate = (session, toolCallId) => {
591
+ const tracked = session.backgroundTasks.get(toolCallId);
592
+ return ((tracked !== undefined && tracked.state === "awaiting-results") ||
593
+ session.wakeupCompletedOpenBgCandidates.has(toolCallId) ||
594
+ session.wakeupOwedToolCallIds.has(toolCallId));
595
+ };
596
+ #isActiveBackgroundCandidate = (session, toolCallId) => this.#isRunningBackgroundCandidate(session, toolCallId) ||
597
+ this.#isCompletedBackgroundCandidate(session, toolCallId);
547
598
  #pruneInactiveCandidates = (session) => {
548
599
  const candidates = session.backgroundCorrelation.pendingCandidates;
549
600
  let writeIndex = 0;
@@ -558,6 +609,7 @@ export class AntigravityBackgroundWakeup {
558
609
  #syncBackgroundTaskCreations = (sessionId, session, steps) => {
559
610
  const correlation = session.backgroundCorrelation;
560
611
  const targetSessionId = sessionId.toLowerCase();
612
+ const deliveredInSteps = extractTaskResultSenderIds(sessionId, steps, session.sessionOpenStepIndex, Number.MAX_SAFE_INTEGER);
561
613
  let lastPlanner;
562
614
  for (const step of steps) {
563
615
  if (step.type === "PLANNER_RESPONSE" && step.tool_calls !== undefined && step.tool_calls.length > 0) {
@@ -588,16 +640,35 @@ export class AntigravityBackgroundWakeup {
588
640
  if ((info !== null && info.category === null) || step.step_index <= session.sessionOpenStepIndex) {
589
641
  continue;
590
642
  }
643
+ const matchText = info?.matchText ?? extractBackgroundTaskDescription(step.content);
591
644
  const candidates = correlation.pendingCandidates;
592
645
  const categoryMatches = (candidate) => info === null || info.category === null || candidate.category === info.category;
593
- let matchedIndex = candidates.findIndex((candidate) => this.#isActiveBackgroundCandidate(session, candidate.toolCallId) &&
646
+ const textCompatible = (candidate) => candidate.matchText === undefined ||
647
+ matchText === undefined ||
648
+ matchesCandidateText(candidate.matchText, matchText);
649
+ const alreadyDelivered = correlation.deliveredNativeTaskIds.has(nativeTaskId) || deliveredInSteps.has(nativeTaskId);
650
+ const primaryMatches = (candidate) => alreadyDelivered
651
+ ? this.#isCompletedBackgroundCandidate(session, candidate.toolCallId)
652
+ : this.#isRunningBackgroundCandidate(session, candidate.toolCallId);
653
+ const secondaryMatches = (candidate) => alreadyDelivered
654
+ ? this.#isRunningBackgroundCandidate(session, candidate.toolCallId)
655
+ : this.#isCompletedBackgroundCandidate(session, candidate.toolCallId);
656
+ let matchedIndex = candidates.findIndex((candidate) => primaryMatches(candidate) &&
594
657
  categoryMatches(candidate) &&
595
- matchesCandidateText(candidate.matchText, info?.matchText));
658
+ matchesCandidateText(candidate.matchText, matchText));
659
+ if (matchedIndex === -1) {
660
+ matchedIndex = candidates.findIndex((candidate) => secondaryMatches(candidate) &&
661
+ categoryMatches(candidate) &&
662
+ matchesCandidateText(candidate.matchText, matchText));
663
+ }
664
+ if (matchedIndex === -1) {
665
+ matchedIndex = candidates.findIndex((candidate) => primaryMatches(candidate) && categoryMatches(candidate) && textCompatible(candidate));
666
+ }
596
667
  if (matchedIndex === -1) {
597
- matchedIndex = candidates.findIndex((candidate) => this.#isActiveBackgroundCandidate(session, candidate.toolCallId) && categoryMatches(candidate));
668
+ matchedIndex = candidates.findIndex((candidate) => secondaryMatches(candidate) && categoryMatches(candidate) && textCompatible(candidate));
598
669
  }
599
- if (matchedIndex === -1 && info?.matchText !== undefined) {
600
- matchedIndex = candidates.findIndex((candidate) => categoryMatches(candidate) && matchesCandidateText(candidate.matchText, info.matchText));
670
+ if (matchedIndex === -1 && matchText !== undefined) {
671
+ matchedIndex = candidates.findIndex((candidate) => categoryMatches(candidate) && matchesCandidateText(candidate.matchText, matchText));
601
672
  }
602
673
  if (matchedIndex !== -1) {
603
674
  const matched = candidates[matchedIndex];
@@ -799,6 +870,8 @@ export class AntigravityBackgroundWakeup {
799
870
  const generation = session.wakeupGeneration;
800
871
  session.wakeupOwedToolCallIds.clear();
801
872
  session.wakeupCompletedOpenBgCandidates.clear();
873
+ session.wakeupDeferredSettledStep = null;
874
+ session.wakeupStreamedMessageText = "";
802
875
  for (const [toolCallId, task] of session.backgroundTasks) {
803
876
  if (task.kind !== "subagent" && task.state === "awaiting-results") {
804
877
  session.wakeupOwedToolCallIds.add(toolCallId);
@@ -821,6 +894,8 @@ export class AntigravityBackgroundWakeup {
821
894
  session.phase = { cancelRequested, kind: "idle" };
822
895
  session.wakeupOwedToolCallIds.clear();
823
896
  session.wakeupCompletedOpenBgCandidates.clear();
897
+ session.wakeupDeferredSettledStep = null;
898
+ session.wakeupStreamedMessageText = "";
824
899
  this.#dropAwaitingResultTasks(session);
825
900
  const notifications = [];
826
901
  const bgNotification = this.#takeBackgroundTasksUpdate(sessionId, session);
@@ -841,6 +916,8 @@ export class AntigravityBackgroundWakeup {
841
916
  session.phase = { cancelRequested: false, kind: "idle" };
842
917
  session.wakeupOwedToolCallIds.clear();
843
918
  session.wakeupCompletedOpenBgCandidates.clear();
919
+ session.wakeupDeferredSettledStep = null;
920
+ session.wakeupStreamedMessageText = "";
844
921
  this.#dropAwaitingResultTasks(session);
845
922
  const notifications = [];
846
923
  const bgNotification = this.#takeBackgroundTasksUpdate(sessionId, session);
@@ -877,6 +954,41 @@ export class AntigravityBackgroundWakeup {
877
954
  return;
878
955
  }
879
956
  };
957
+ /**
958
+ * `agy` can flush a settled `PLANNER_RESPONSE` to `transcript.jsonl` slightly before the
959
+ * matching `agent_message_chunk` notifications finish traversing ACP stdout. Settling early
960
+ * would close the wakeup turn empty and cause the late chunk to open a second turn.
961
+ */
962
+ #shouldDeferSettledReply = (session, settledStep) => {
963
+ const expectedText = settledStep.content?.trim() ?? "";
964
+ if (expectedText.length === 0) {
965
+ return false;
966
+ }
967
+ if (session.wakeupStreamedMessageText.trim().length === 0) {
968
+ return true;
969
+ }
970
+ if (session.wakeupStreamedMessageText.includes(expectedText)) {
971
+ return false;
972
+ }
973
+ const nextCount = session.wakeupDeferredSettledStep?.stepIndex === settledStep.stepIndex
974
+ ? session.wakeupDeferredSettledStep.count + 1
975
+ : 1;
976
+ session.wakeupDeferredSettledStep = { count: nextCount, stepIndex: settledStep.stepIndex };
977
+ return nextCount <= MAX_PARTIAL_SETTLED_TEXT_DEFERRALS;
978
+ };
979
+ #consumeSettledReplyText = (session, settledStep) => {
980
+ session.wakeupDeferredSettledStep = null;
981
+ const expectedText = settledStep.content?.trim() ?? "";
982
+ if (expectedText.length === 0) {
983
+ return;
984
+ }
985
+ const matchIndex = session.wakeupStreamedMessageText.indexOf(expectedText);
986
+ if (matchIndex !== -1) {
987
+ session.wakeupStreamedMessageText = session.wakeupStreamedMessageText.slice(matchIndex + expectedText.length);
988
+ return;
989
+ }
990
+ session.wakeupStreamedMessageText = "";
991
+ };
880
992
  #checkWakeupTranscript = async (sessionId, generation, stageEpoch) => {
881
993
  if (this.#disposed) {
882
994
  return;
@@ -906,8 +1018,13 @@ export class AntigravityBackgroundWakeup {
906
1018
  this.#syncSubagentCreations(current, tail.steps);
907
1019
  this.#syncBackgroundTaskCreations(sessionId, current, tail.steps);
908
1020
  }
909
- if (tail?.settledStepIndex !== null && tail?.settledStepIndex !== undefined) {
910
- if (this.#settleWakeupReply(sessionId, current, tail, tail.settledStepIndex)) {
1021
+ if (tail?.settledStep !== null && tail?.settledStep !== undefined) {
1022
+ if (this.#shouldDeferSettledReply(current, tail.settledStep)) {
1023
+ this.#rescheduleTranscriptCheck(sessionId, current, generation, stageEpoch, currentStage);
1024
+ return;
1025
+ }
1026
+ this.#consumeSettledReplyText(current, tail.settledStep);
1027
+ if (this.#settleWakeupReply(sessionId, current, tail, tail.settledStep.stepIndex)) {
911
1028
  this.#emitNotifications(this.#finishWakeup(sessionId, current, "end_turn", false));
912
1029
  }
913
1030
  else {
@@ -1037,9 +1154,10 @@ export class AntigravityBackgroundWakeup {
1037
1154
  this.#syncSubagentCreations(current, tail.steps);
1038
1155
  this.#syncBackgroundTaskCreations(sessionId, current, tail.steps);
1039
1156
  }
1040
- if (tail?.settledStepIndex !== null && tail?.settledStepIndex !== undefined) {
1157
+ if (tail?.settledStep !== null && tail?.settledStep !== undefined) {
1041
1158
  // The deadline passed, so a result still awaited is not coming: the settled reply ends the continuation.
1042
- this.#settleWakeupReply(sessionId, current, tail, tail.settledStepIndex);
1159
+ this.#consumeSettledReplyText(current, tail.settledStep);
1160
+ this.#settleWakeupReply(sessionId, current, tail, tail.settledStep.stepIndex);
1043
1161
  this.#emitNotifications(this.#finishWakeup(sessionId, current, "end_turn", false));
1044
1162
  return;
1045
1163
  }
@@ -1496,6 +1614,11 @@ export class AntigravityBackgroundWakeup {
1496
1614
  return;
1497
1615
  }
1498
1616
  if (isWakeupChunkUpdateKind(updateKind)) {
1617
+ const messageText = extractMessageChunkText(updateKind, update);
1618
+ if (messageText !== undefined && messageText.length > 0) {
1619
+ session.wakeupStreamedMessageText += messageText;
1620
+ session.wakeupDeferredSettledStep = null;
1621
+ }
1499
1622
  const executorError = extractExecutorError(updateKind, update);
1500
1623
  this.#promoteOpenWakeupToolsToBackground(session);
1501
1624
  const bg = this.#takeBackgroundTasksUpdate(sessionId, session);