@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.
- package/dist/{chunk-O56TVV5C.js → chunk-W5MXRFJ5.js} +2 -2
- package/dist/{chunk-O56TVV5C.js.map → chunk-W5MXRFJ5.js.map} +1 -1
- package/dist/{chunk-2KU5227F.js → chunk-YN6SPJT7.js} +143 -24
- package/dist/{chunk-2KU5227F.js.map → chunk-YN6SPJT7.js.map} +2 -2
- package/dist/{cli-4SSU3XE7.js → cli-JLNGQRI5.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/engine/acp/adapter/antigravity/background-wakeup.d.ts.map +1 -1
- package/dist/engine/acp/adapter/antigravity/background-wakeup.js +148 -25
- package/dist/engine/acp/adapter/antigravity/background-wakeup.js.map +1 -1
- package/dist/engine.js +2 -2
- package/package.json +1 -1
- /package/dist/{cli-4SSU3XE7.js.map → cli-JLNGQRI5.js.map} +0 -0
|
@@ -33,10 +33,10 @@ import {
|
|
|
33
33
|
unhandledRejectionLogFilename,
|
|
34
34
|
validateLocalPath,
|
|
35
35
|
validatePairingId
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-YN6SPJT7.js";
|
|
37
37
|
import {
|
|
38
38
|
package_default
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-W5MXRFJ5.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-
|
|
5822
|
+
//# sourceMappingURL=cli-JLNGQRI5.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-
|
|
6
|
+
} from "./chunk-W5MXRFJ5.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-
|
|
2011
|
+
const { runCLI } = await import("./cli-JLNGQRI5.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;
|
|
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;AAarF,eAAO,MAAM,4BAA4B,SAAU,CAAC;AA6JpD,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;AAuFD,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC1C,MAAM,GAAG,SAAS,CAQpB;AA4TD;;;;GAIG;AACH,qBAAa,2BAA2B;;IAWpC,YAAY,OAAO,EAAE,kCAAkC,EAItD;IAqoCD,QAAQ,CAAC,iBAAiB,YAAmB,UAAU,KAAG,OAAO,CAAC,IAAI,CAAC,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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
271
|
-
|
|
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
|
-
#
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
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
|
-
|
|
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,
|
|
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) =>
|
|
668
|
+
matchedIndex = candidates.findIndex((candidate) => secondaryMatches(candidate) && categoryMatches(candidate) && textCompatible(candidate));
|
|
598
669
|
}
|
|
599
|
-
if (matchedIndex === -1 &&
|
|
600
|
-
matchedIndex = candidates.findIndex((candidate) => categoryMatches(candidate) && matchesCandidateText(candidate.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?.
|
|
910
|
-
if (this.#
|
|
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?.
|
|
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.#
|
|
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);
|