@moxt-ai/mobius 0.0.462 → 0.0.464

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.462",
83
+ version: "0.0.464",
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-W5MXRFJ5.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.464\",\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
  }
@@ -5,7 +5,7 @@ import {
5
5
  __toESM,
6
6
  __using,
7
7
  package_default
8
- } from "./chunk-O56TVV5C.js";
8
+ } from "./chunk-W5MXRFJ5.js";
9
9
 
10
10
  // ../../node_modules/.pnpm/ignore@7.0.9/node_modules/ignore/index.js
11
11
  var require_ignore = __commonJS({
@@ -29113,6 +29113,7 @@ var systemTimer = new SystemTimer();
29113
29113
  var TRANSCRIPT_TAIL_BYTES = 65536;
29114
29114
  var TRANSCRIPT_INITIAL_DELAY_MS = 40;
29115
29115
  var TRANSCRIPT_POLL_INTERVAL_MS = 150;
29116
+ var MAX_PARTIAL_SETTLED_TEXT_DEFERRALS = 2;
29116
29117
  var WAKEUP_INACTIVITY_TIMEOUT_MS = 3e5;
29117
29118
  var SESSION_UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
29118
29119
  var 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;
@@ -29120,6 +29121,8 @@ var SUBAGENT_IDLE_ID_PATTERN = /\bSubagent ([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-
29120
29121
  var AGENT_EXECUTOR_ERROR_PATTERN = /^\s*⚠ agent executor error:\s*(.+?)\s*$/su;
29121
29122
  var 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;
29122
29123
  var 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;
29124
+ var BACKGROUND_TASK_DESCRIPTION_PATTERN = /\nTask Description:\s*([\s\S]+?)(?:\nTask logs are available at:|\nLog output:|$)/u;
29125
+ var TRANSCRIPT_TRUNCATED_SUFFIX_PATTERN = /\r?\n<truncated \d+ bytes>$/u;
29123
29126
  var SUBAGENT_CREATED_MARKER = "Created the following subagent";
29124
29127
  var MAXIMUM_TOOL_DESCRIPTION_CHARS = 500;
29125
29128
  var MINIMUM_TRUNCATED_MATCH_CHARS = 16;
@@ -29175,7 +29178,7 @@ async function readTranscriptTailState(launchEnvironment, sessionId, baselineSte
29175
29178
  return null;
29176
29179
  }
29177
29180
  if (tail.bytes.byteLength === 0) {
29178
- return { firstStepIndex: -1, maxStepIndex: -1, settledStepIndex: null, steps: [] };
29181
+ return { firstStepIndex: -1, maxStepIndex: -1, settledStep: null, steps: [] };
29179
29182
  }
29180
29183
  const text2 = new TextDecoder().decode(tail.bytes);
29181
29184
  const lines = text2.split("\n");
@@ -29206,10 +29209,20 @@ async function readTranscriptTailState(launchEnvironment, sessionId, baselineSte
29206
29209
  return {
29207
29210
  firstStepIndex,
29208
29211
  maxStepIndex,
29209
- settledStepIndex: settledStep?.step_index ?? null,
29212
+ settledStep: settledStep === void 0 ? null : { content: settledStep.content, stepIndex: settledStep.step_index },
29210
29213
  steps
29211
29214
  };
29212
29215
  }
29216
+ function extractMessageChunkText(updateKind, update) {
29217
+ if (updateKind !== "agent_message_chunk" && updateKind !== "agent_message") {
29218
+ return void 0;
29219
+ }
29220
+ const content = update["content"];
29221
+ if (!isRecord5(content) || content["type"] !== "text") {
29222
+ return void 0;
29223
+ }
29224
+ return readString3(content, "text");
29225
+ }
29213
29226
  function extractUuidMatches(text2, pattern) {
29214
29227
  pattern.lastIndex = 0;
29215
29228
  const matches = [];
@@ -29222,14 +29235,7 @@ function extractUuidMatches(text2, pattern) {
29222
29235
  return matches;
29223
29236
  }
29224
29237
  function extractExecutorError(updateKind, update) {
29225
- if (updateKind !== "agent_message_chunk" && updateKind !== "agent_message") {
29226
- return void 0;
29227
- }
29228
- const content = update["content"];
29229
- if (!isRecord5(content) || content["type"] !== "text") {
29230
- return void 0;
29231
- }
29232
- const text2 = readString3(content, "text");
29238
+ const text2 = extractMessageChunkText(updateKind, update);
29233
29239
  if (text2 === void 0) {
29234
29240
  return void 0;
29235
29241
  }
@@ -29347,6 +29353,34 @@ function decodeTranscriptArg(value) {
29347
29353
  return value;
29348
29354
  }
29349
29355
  }
29356
+ function decodeTruncatedJsonString(raw) {
29357
+ if (!raw.startsWith('"')) {
29358
+ return void 0;
29359
+ }
29360
+ let body = raw.slice(1).replace(TRANSCRIPT_TRUNCATED_SUFFIX_PATTERN, "");
29361
+ const partialUnicode = /\\u[0-9a-fA-F]{0,3}$/u.exec(body);
29362
+ if (partialUnicode !== null) {
29363
+ const precedingBackslashes = /\\*$/u.exec(body.slice(0, partialUnicode.index))?.[0].length ?? 0;
29364
+ if (precedingBackslashes % 2 === 0) {
29365
+ body = body.slice(0, partialUnicode.index);
29366
+ }
29367
+ }
29368
+ const trailingBackslashes = /\\+$/u.exec(body)?.[0].length ?? 0;
29369
+ if (trailingBackslashes % 2 === 1) {
29370
+ body = body.slice(0, -1);
29371
+ }
29372
+ try {
29373
+ const parsed = JSON.parse(`"${body}"`);
29374
+ return typeof parsed === "string" ? parsed : void 0;
29375
+ } catch {
29376
+ return body;
29377
+ }
29378
+ }
29379
+ function extractBackgroundTaskDescription(content) {
29380
+ const match = BACKGROUND_TASK_DESCRIPTION_PATTERN.exec(content);
29381
+ const description = match?.[1]?.trim();
29382
+ return description !== void 0 && description.length > 0 ? description : void 0;
29383
+ }
29350
29384
  function readTranscriptArgString(args, key) {
29351
29385
  const raw = args[key];
29352
29386
  if (raw === void 0) {
@@ -29356,8 +29390,8 @@ function readTranscriptArgString(args, key) {
29356
29390
  if (typeof decoded !== "string") {
29357
29391
  return void 0;
29358
29392
  }
29359
- const stripped = typeof raw === "string" && decoded === raw && decoded.startsWith('"') ? decoded.slice(1) : decoded;
29360
- const trimmed = stripped.trim();
29393
+ const normalized = typeof raw === "string" && decoded === raw && raw.startsWith('"') ? decodeTruncatedJsonString(raw) ?? decoded.slice(1) : decoded;
29394
+ const trimmed = normalized.trim();
29361
29395
  return trimmed.length > 0 ? trimmed : void 0;
29362
29396
  }
29363
29397
  function readTranscriptToolCallInfo(raw) {
@@ -29475,10 +29509,12 @@ var AntigravityBackgroundWakeup = class {
29475
29509
  },
29476
29510
  toolMetadata: /* @__PURE__ */ new Map(),
29477
29511
  wakeupCompletedOpenBgCandidates: /* @__PURE__ */ new Set(),
29512
+ wakeupDeferredSettledStep: null,
29478
29513
  wakeupGeneration: 0,
29479
29514
  wakeupOwedToolCallIds: /* @__PURE__ */ new Set(),
29480
29515
  wakeupSettledStepIndex: null,
29481
- wakeupStageSeq: 0
29516
+ wakeupStageSeq: 0,
29517
+ wakeupStreamedMessageText: ""
29482
29518
  };
29483
29519
  this.#sessions.set(sessionId, created);
29484
29520
  return created;
@@ -29559,6 +29595,8 @@ var AntigravityBackgroundWakeup = class {
29559
29595
  session.backgroundTasks.clear();
29560
29596
  session.wakeupOwedToolCallIds.clear();
29561
29597
  session.wakeupCompletedOpenBgCandidates.clear();
29598
+ session.wakeupDeferredSettledStep = null;
29599
+ session.wakeupStreamedMessageText = "";
29562
29600
  session.backgroundCorrelation.pendingCandidates.length = 0;
29563
29601
  session.backgroundCorrelation.nativeTaskIdByToolCallId.clear();
29564
29602
  session.subagents.conversationIdByToolCallId.clear();
@@ -29604,7 +29642,15 @@ var AntigravityBackgroundWakeup = class {
29604
29642
  candidates.splice(index2, 1);
29605
29643
  }
29606
29644
  };
29607
- #isActiveBackgroundCandidate = (session, toolCallId) => session.backgroundTasks.has(toolCallId) || session.phase.kind === "wakeup" && session.phase.openToolIds.has(toolCallId) || session.wakeupCompletedOpenBgCandidates.has(toolCallId) || session.wakeupOwedToolCallIds.has(toolCallId);
29645
+ #isRunningBackgroundCandidate = (session, toolCallId) => {
29646
+ const tracked = session.backgroundTasks.get(toolCallId);
29647
+ return tracked !== void 0 && tracked.state === "running" || session.phase.kind === "wakeup" && session.phase.openToolIds.has(toolCallId);
29648
+ };
29649
+ #isCompletedBackgroundCandidate = (session, toolCallId) => {
29650
+ const tracked = session.backgroundTasks.get(toolCallId);
29651
+ return tracked !== void 0 && tracked.state === "awaiting-results" || session.wakeupCompletedOpenBgCandidates.has(toolCallId) || session.wakeupOwedToolCallIds.has(toolCallId);
29652
+ };
29653
+ #isActiveBackgroundCandidate = (session, toolCallId) => this.#isRunningBackgroundCandidate(session, toolCallId) || this.#isCompletedBackgroundCandidate(session, toolCallId);
29608
29654
  #pruneInactiveCandidates = (session) => {
29609
29655
  const candidates = session.backgroundCorrelation.pendingCandidates;
29610
29656
  let writeIndex = 0;
@@ -29619,6 +29665,12 @@ var AntigravityBackgroundWakeup = class {
29619
29665
  #syncBackgroundTaskCreations = (sessionId, session, steps) => {
29620
29666
  const correlation = session.backgroundCorrelation;
29621
29667
  const targetSessionId = sessionId.toLowerCase();
29668
+ const deliveredInSteps = extractTaskResultSenderIds(
29669
+ sessionId,
29670
+ steps,
29671
+ session.sessionOpenStepIndex,
29672
+ Number.MAX_SAFE_INTEGER
29673
+ );
29622
29674
  let lastPlanner;
29623
29675
  for (const step of steps) {
29624
29676
  if (step.type === "PLANNER_RESPONSE" && step.tool_calls !== void 0 && step.tool_calls.length > 0) {
@@ -29644,19 +29696,34 @@ var AntigravityBackgroundWakeup = class {
29644
29696
  if (info !== null && info.category === null || step.step_index <= session.sessionOpenStepIndex) {
29645
29697
  continue;
29646
29698
  }
29699
+ const matchText = info?.matchText ?? extractBackgroundTaskDescription(step.content);
29647
29700
  const candidates = correlation.pendingCandidates;
29648
29701
  const categoryMatches = (candidate) => info === null || info.category === null || candidate.category === info.category;
29702
+ const textCompatible = (candidate) => candidate.matchText === void 0 || matchText === void 0 || matchesCandidateText(candidate.matchText, matchText);
29703
+ const alreadyDelivered = correlation.deliveredNativeTaskIds.has(nativeTaskId) || deliveredInSteps.has(nativeTaskId);
29704
+ const primaryMatches = (candidate) => alreadyDelivered ? this.#isCompletedBackgroundCandidate(session, candidate.toolCallId) : this.#isRunningBackgroundCandidate(session, candidate.toolCallId);
29705
+ const secondaryMatches = (candidate) => alreadyDelivered ? this.#isRunningBackgroundCandidate(session, candidate.toolCallId) : this.#isCompletedBackgroundCandidate(session, candidate.toolCallId);
29649
29706
  let matchedIndex = candidates.findIndex(
29650
- (candidate) => this.#isActiveBackgroundCandidate(session, candidate.toolCallId) && categoryMatches(candidate) && matchesCandidateText(candidate.matchText, info?.matchText)
29707
+ (candidate) => primaryMatches(candidate) && categoryMatches(candidate) && matchesCandidateText(candidate.matchText, matchText)
29651
29708
  );
29652
29709
  if (matchedIndex === -1) {
29653
29710
  matchedIndex = candidates.findIndex(
29654
- (candidate) => this.#isActiveBackgroundCandidate(session, candidate.toolCallId) && categoryMatches(candidate)
29711
+ (candidate) => secondaryMatches(candidate) && categoryMatches(candidate) && matchesCandidateText(candidate.matchText, matchText)
29712
+ );
29713
+ }
29714
+ if (matchedIndex === -1) {
29715
+ matchedIndex = candidates.findIndex(
29716
+ (candidate) => primaryMatches(candidate) && categoryMatches(candidate) && textCompatible(candidate)
29717
+ );
29718
+ }
29719
+ if (matchedIndex === -1) {
29720
+ matchedIndex = candidates.findIndex(
29721
+ (candidate) => secondaryMatches(candidate) && categoryMatches(candidate) && textCompatible(candidate)
29655
29722
  );
29656
29723
  }
29657
- if (matchedIndex === -1 && info?.matchText !== void 0) {
29724
+ if (matchedIndex === -1 && matchText !== void 0) {
29658
29725
  matchedIndex = candidates.findIndex(
29659
- (candidate) => categoryMatches(candidate) && matchesCandidateText(candidate.matchText, info.matchText)
29726
+ (candidate) => categoryMatches(candidate) && matchesCandidateText(candidate.matchText, matchText)
29660
29727
  );
29661
29728
  }
29662
29729
  if (matchedIndex !== -1) {
@@ -29866,6 +29933,8 @@ var AntigravityBackgroundWakeup = class {
29866
29933
  const generation = session.wakeupGeneration;
29867
29934
  session.wakeupOwedToolCallIds.clear();
29868
29935
  session.wakeupCompletedOpenBgCandidates.clear();
29936
+ session.wakeupDeferredSettledStep = null;
29937
+ session.wakeupStreamedMessageText = "";
29869
29938
  for (const [toolCallId, task] of session.backgroundTasks) {
29870
29939
  if (task.kind !== "subagent" && task.state === "awaiting-results") {
29871
29940
  session.wakeupOwedToolCallIds.add(toolCallId);
@@ -29890,6 +29959,8 @@ var AntigravityBackgroundWakeup = class {
29890
29959
  session.phase = { cancelRequested, kind: "idle" };
29891
29960
  session.wakeupOwedToolCallIds.clear();
29892
29961
  session.wakeupCompletedOpenBgCandidates.clear();
29962
+ session.wakeupDeferredSettledStep = null;
29963
+ session.wakeupStreamedMessageText = "";
29893
29964
  this.#dropAwaitingResultTasks(session);
29894
29965
  const notifications = [];
29895
29966
  const bgNotification = this.#takeBackgroundTasksUpdate(sessionId, session);
@@ -29912,6 +29983,8 @@ var AntigravityBackgroundWakeup = class {
29912
29983
  session.phase = { cancelRequested: false, kind: "idle" };
29913
29984
  session.wakeupOwedToolCallIds.clear();
29914
29985
  session.wakeupCompletedOpenBgCandidates.clear();
29986
+ session.wakeupDeferredSettledStep = null;
29987
+ session.wakeupStreamedMessageText = "";
29915
29988
  this.#dropAwaitingResultTasks(session);
29916
29989
  const notifications = [];
29917
29990
  const bgNotification = this.#takeBackgroundTasksUpdate(sessionId, session);
@@ -29950,6 +30023,41 @@ var AntigravityBackgroundWakeup = class {
29950
30023
  return;
29951
30024
  }
29952
30025
  };
30026
+ /**
30027
+ * `agy` can flush a settled `PLANNER_RESPONSE` to `transcript.jsonl` slightly before the
30028
+ * matching `agent_message_chunk` notifications finish traversing ACP stdout. Settling early
30029
+ * would close the wakeup turn empty and cause the late chunk to open a second turn.
30030
+ */
30031
+ #shouldDeferSettledReply = (session, settledStep) => {
30032
+ const expectedText = settledStep.content?.trim() ?? "";
30033
+ if (expectedText.length === 0) {
30034
+ return false;
30035
+ }
30036
+ if (session.wakeupStreamedMessageText.trim().length === 0) {
30037
+ return true;
30038
+ }
30039
+ if (session.wakeupStreamedMessageText.includes(expectedText)) {
30040
+ return false;
30041
+ }
30042
+ const nextCount = session.wakeupDeferredSettledStep?.stepIndex === settledStep.stepIndex ? session.wakeupDeferredSettledStep.count + 1 : 1;
30043
+ session.wakeupDeferredSettledStep = { count: nextCount, stepIndex: settledStep.stepIndex };
30044
+ return nextCount <= MAX_PARTIAL_SETTLED_TEXT_DEFERRALS;
30045
+ };
30046
+ #consumeSettledReplyText = (session, settledStep) => {
30047
+ session.wakeupDeferredSettledStep = null;
30048
+ const expectedText = settledStep.content?.trim() ?? "";
30049
+ if (expectedText.length === 0) {
30050
+ return;
30051
+ }
30052
+ const matchIndex = session.wakeupStreamedMessageText.indexOf(expectedText);
30053
+ if (matchIndex !== -1) {
30054
+ session.wakeupStreamedMessageText = session.wakeupStreamedMessageText.slice(
30055
+ matchIndex + expectedText.length
30056
+ );
30057
+ return;
30058
+ }
30059
+ session.wakeupStreamedMessageText = "";
30060
+ };
29953
30061
  #checkWakeupTranscript = async (sessionId, generation, stageEpoch) => {
29954
30062
  if (this.#disposed) {
29955
30063
  return;
@@ -29977,8 +30085,13 @@ var AntigravityBackgroundWakeup = class {
29977
30085
  this.#syncSubagentCreations(current, tail.steps);
29978
30086
  this.#syncBackgroundTaskCreations(sessionId, current, tail.steps);
29979
30087
  }
29980
- if (tail?.settledStepIndex !== null && tail?.settledStepIndex !== void 0) {
29981
- if (this.#settleWakeupReply(sessionId, current, tail, tail.settledStepIndex)) {
30088
+ if (tail?.settledStep !== null && tail?.settledStep !== void 0) {
30089
+ if (this.#shouldDeferSettledReply(current, tail.settledStep)) {
30090
+ this.#rescheduleTranscriptCheck(sessionId, current, generation, stageEpoch, currentStage);
30091
+ return;
30092
+ }
30093
+ this.#consumeSettledReplyText(current, tail.settledStep);
30094
+ if (this.#settleWakeupReply(sessionId, current, tail, tail.settledStep.stepIndex)) {
29982
30095
  this.#emitNotifications(this.#finishWakeup(sessionId, current, "end_turn", false));
29983
30096
  } else {
29984
30097
  const bg2 = this.#takeBackgroundTasksUpdate(sessionId, current);
@@ -30098,8 +30211,9 @@ var AntigravityBackgroundWakeup = class {
30098
30211
  this.#syncSubagentCreations(current, tail.steps);
30099
30212
  this.#syncBackgroundTaskCreations(sessionId, current, tail.steps);
30100
30213
  }
30101
- if (tail?.settledStepIndex !== null && tail?.settledStepIndex !== void 0) {
30102
- this.#settleWakeupReply(sessionId, current, tail, tail.settledStepIndex);
30214
+ if (tail?.settledStep !== null && tail?.settledStep !== void 0) {
30215
+ this.#consumeSettledReplyText(current, tail.settledStep);
30216
+ this.#settleWakeupReply(sessionId, current, tail, tail.settledStep.stepIndex);
30103
30217
  this.#emitNotifications(this.#finishWakeup(sessionId, current, "end_turn", false));
30104
30218
  return;
30105
30219
  }
@@ -30559,6 +30673,11 @@ var AntigravityBackgroundWakeup = class {
30559
30673
  return;
30560
30674
  }
30561
30675
  if (isWakeupChunkUpdateKind(updateKind)) {
30676
+ const messageText = extractMessageChunkText(updateKind, update);
30677
+ if (messageText !== void 0 && messageText.length > 0) {
30678
+ session.wakeupStreamedMessageText += messageText;
30679
+ session.wakeupDeferredSettledStep = null;
30680
+ }
30562
30681
  const executorError = extractExecutorError(updateKind, update);
30563
30682
  this.#promoteOpenWakeupToolsToBackground(session);
30564
30683
  const bg2 = this.#takeBackgroundTasksUpdate(sessionId, session);
@@ -105899,4 +106018,4 @@ export {
105899
106018
  * MIT Licensed
105900
106019
  *)
105901
106020
  */
105902
- //# sourceMappingURL=chunk-2KU5227F.js.map
106021
+ //# sourceMappingURL=chunk-YN6SPJT7.js.map