@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.
- package/dist/{chunk-2KU5227F.js → chunk-CPVZCCBS.js} +243 -72
- package/dist/{chunk-2KU5227F.js.map → chunk-CPVZCCBS.js.map} +2 -2
- package/dist/{chunk-O56TVV5C.js → chunk-RQXSP55N.js} +2 -2
- package/dist/{chunk-O56TVV5C.js.map → chunk-RQXSP55N.js.map} +1 -1
- package/dist/{cli-4SSU3XE7.js → cli-4CH5AIPM.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/infra/operation-metrics.d.ts +5 -0
- package/dist/engine/infra/operation-metrics.d.ts.map +1 -1
- package/dist/engine/infra/operation-metrics.js +9 -1
- package/dist/engine/infra/operation-metrics.js.map +1 -1
- package/dist/engine/session/api/session-api.d.ts +8 -0
- package/dist/engine/session/api/session-api.d.ts.map +1 -1
- package/dist/engine/session/api/session-api.js.map +1 -1
- package/dist/engine/session/live/agent-session.d.ts.map +1 -1
- package/dist/engine/session/live/agent-session.js +26 -21
- package/dist/engine/session/live/agent-session.js.map +1 -1
- package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
- package/dist/engine/session/manager/session-manager.js +3 -2
- package/dist/engine/session/manager/session-manager.js.map +1 -1
- package/dist/engine/session/prompt/execute-prompt.d.ts.map +1 -1
- package/dist/engine/session/prompt/execute-prompt.js +32 -7
- package/dist/engine/session/prompt/execute-prompt.js.map +1 -1
- package/dist/engine.js +2 -2
- package/package.json +1 -1
- /package/dist/{cli-4SSU3XE7.js.map → cli-4CH5AIPM.js.map} +0 -0
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
__toESM,
|
|
6
6
|
__using,
|
|
7
7
|
package_default
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RQXSP55N.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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
29360
|
-
const trimmed =
|
|
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
|
-
#
|
|
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) =>
|
|
29707
|
+
(candidate) => primaryMatches(candidate) && categoryMatches(candidate) && matchesCandidateText(candidate.matchText, matchText)
|
|
29651
29708
|
);
|
|
29652
29709
|
if (matchedIndex === -1) {
|
|
29653
29710
|
matchedIndex = candidates.findIndex(
|
|
29654
|
-
(candidate) =>
|
|
29711
|
+
(candidate) => secondaryMatches(candidate) && categoryMatches(candidate) && matchesCandidateText(candidate.matchText, matchText)
|
|
29655
29712
|
);
|
|
29656
29713
|
}
|
|
29657
|
-
if (matchedIndex === -1
|
|
29714
|
+
if (matchedIndex === -1) {
|
|
29658
29715
|
matchedIndex = candidates.findIndex(
|
|
29659
|
-
(candidate) => categoryMatches(candidate) &&
|
|
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)
|
|
29722
|
+
);
|
|
29723
|
+
}
|
|
29724
|
+
if (matchedIndex === -1 && matchText !== void 0) {
|
|
29725
|
+
matchedIndex = candidates.findIndex(
|
|
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?.
|
|
29981
|
-
if (this.#
|
|
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?.
|
|
30102
|
-
this.#
|
|
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);
|
|
@@ -95497,6 +95616,14 @@ var CachedSessionEventStore = class {
|
|
|
95497
95616
|
// src/engine/infra/operation-metrics.ts
|
|
95498
95617
|
var AccumulatingOperationMetrics = class {
|
|
95499
95618
|
#durations = /* @__PURE__ */ new Map();
|
|
95619
|
+
#maximumMilliseconds;
|
|
95620
|
+
/**
|
|
95621
|
+
* Each accumulated duration stops at `maximumMilliseconds`, which bounds what is reported to a peer. A
|
|
95622
|
+
* diagnostic that stays on this machine passes `Infinity`, so a long wait reads as long as it was.
|
|
95623
|
+
*/
|
|
95624
|
+
constructor(maximumMilliseconds = 12e4) {
|
|
95625
|
+
this.#maximumMilliseconds = maximumMilliseconds;
|
|
95626
|
+
}
|
|
95500
95627
|
measure = async (name2, operation) => {
|
|
95501
95628
|
const startedAt = performance.now();
|
|
95502
95629
|
try {
|
|
@@ -95519,7 +95646,7 @@ var AccumulatingOperationMetrics = class {
|
|
|
95519
95646
|
record = (name2, durationMilliseconds) => {
|
|
95520
95647
|
this.#durations.set(
|
|
95521
95648
|
name2,
|
|
95522
|
-
Math.min(
|
|
95649
|
+
Math.min(this.#maximumMilliseconds, (this.#durations.get(name2) ?? 0) + Math.max(0, durationMilliseconds))
|
|
95523
95650
|
);
|
|
95524
95651
|
};
|
|
95525
95652
|
};
|
|
@@ -97312,27 +97439,30 @@ var AgentSession = class _AgentSession {
|
|
|
97312
97439
|
this.writeStoredSession((/* @__PURE__ */ new Date()).toISOString());
|
|
97313
97440
|
const lifecycle = options.lifecycle;
|
|
97314
97441
|
if (lifecycle !== void 0) {
|
|
97315
|
-
await
|
|
97316
|
-
|
|
97317
|
-
|
|
97318
|
-
|
|
97319
|
-
|
|
97320
|
-
|
|
97321
|
-
|
|
97322
|
-
|
|
97323
|
-
|
|
97324
|
-
|
|
97325
|
-
|
|
97326
|
-
|
|
97327
|
-
|
|
97328
|
-
|
|
97329
|
-
|
|
97330
|
-
|
|
97331
|
-
|
|
97332
|
-
|
|
97333
|
-
|
|
97334
|
-
|
|
97442
|
+
await (options.timing?.metrics ?? unmeasuredOperationMetrics).measure("record-started", async () => {
|
|
97443
|
+
await this.#releaseHeld();
|
|
97444
|
+
await this.recordLifecycleEvent({
|
|
97445
|
+
payload: {
|
|
97446
|
+
commandId: options.commandId,
|
|
97447
|
+
content: lifecycle.content,
|
|
97448
|
+
...lifecycle.disposition === void 0 ? {} : { disposition: lifecycle.disposition },
|
|
97449
|
+
kind: "prompt.requested",
|
|
97450
|
+
...lifecycle.context === void 0 ? {} : { context: lifecycle.context },
|
|
97451
|
+
...lifecycle.targetCommandId === void 0 ? {} : { targetCommandId: lifecycle.targetCommandId }
|
|
97452
|
+
},
|
|
97453
|
+
type: "lifecycle-metadata"
|
|
97454
|
+
});
|
|
97455
|
+
await this.recordLifecycleEvent({
|
|
97456
|
+
payload: {
|
|
97457
|
+
attemptId: lifecycle.attemptId,
|
|
97458
|
+
commandId: options.commandId,
|
|
97459
|
+
epoch: lifecycle.epoch,
|
|
97460
|
+
kind: "prompt.started"
|
|
97461
|
+
},
|
|
97462
|
+
type: "lifecycle-metadata"
|
|
97463
|
+
});
|
|
97335
97464
|
});
|
|
97465
|
+
options.timing?.handedToAgent();
|
|
97336
97466
|
}
|
|
97337
97467
|
this.#delegableCommandId = lifecycle === void 0 ? null : options.commandId;
|
|
97338
97468
|
if (lifecycle !== void 0) {
|
|
@@ -98665,12 +98795,13 @@ var SessionManager2 = class {
|
|
|
98665
98795
|
if (cancelled()) {
|
|
98666
98796
|
return { stopReason: "cancelled" };
|
|
98667
98797
|
}
|
|
98668
|
-
const
|
|
98798
|
+
const metrics = options2.timing?.metrics ?? unmeasuredOperationMetrics;
|
|
98799
|
+
const runtime = await metrics.measure("ensure-session", async () => await this.ensureSession(options2));
|
|
98669
98800
|
if (cancelled()) {
|
|
98670
98801
|
return { stopReason: "cancelled" };
|
|
98671
98802
|
}
|
|
98672
98803
|
try {
|
|
98673
|
-
await runtime.preparePrompt(options2.signal);
|
|
98804
|
+
await metrics.measure("prepare-prompt", async () => await runtime.preparePrompt(options2.signal));
|
|
98674
98805
|
if (cancelled()) {
|
|
98675
98806
|
return { stopReason: "cancelled" };
|
|
98676
98807
|
}
|
|
@@ -103425,20 +103556,46 @@ async function executePrompt({
|
|
|
103425
103556
|
signal,
|
|
103426
103557
|
cancellationRequested
|
|
103427
103558
|
}) {
|
|
103559
|
+
const receivedAt = performance.now();
|
|
103560
|
+
const metrics = new AccumulatingOperationMetrics(Number.POSITIVE_INFINITY);
|
|
103561
|
+
const timing = {
|
|
103562
|
+
metrics,
|
|
103563
|
+
handedToAgent: () => {
|
|
103564
|
+
console.info(
|
|
103565
|
+
JSON.stringify({
|
|
103566
|
+
event: "runtime-prompt-preparation-timing",
|
|
103567
|
+
sessionId: command.sessionId,
|
|
103568
|
+
commandId: command.commandId,
|
|
103569
|
+
observedAt: Date.now(),
|
|
103570
|
+
phases: {
|
|
103571
|
+
...Object.fromEntries(
|
|
103572
|
+
metrics.snapshot().map((metric) => [metric.name, metric.durationMilliseconds])
|
|
103573
|
+
),
|
|
103574
|
+
total: performance.now() - receivedAt
|
|
103575
|
+
}
|
|
103576
|
+
})
|
|
103577
|
+
);
|
|
103578
|
+
}
|
|
103579
|
+
};
|
|
103428
103580
|
try {
|
|
103429
|
-
const resolved = await
|
|
103430
|
-
directories,
|
|
103431
|
-
|
|
103432
|
-
|
|
103433
|
-
|
|
103434
|
-
|
|
103581
|
+
const resolved = await metrics.measure(
|
|
103582
|
+
"resolve-directories",
|
|
103583
|
+
async () => await resolveSessionDirectories(
|
|
103584
|
+
directories,
|
|
103585
|
+
command.bindingId,
|
|
103586
|
+
command.directoryId,
|
|
103587
|
+
command.additionalDirectoryIds,
|
|
103588
|
+
signal
|
|
103589
|
+
)
|
|
103435
103590
|
);
|
|
103436
|
-
const { agent: agent2, adapter, externalizeSessionUpdate } = await
|
|
103437
|
-
|
|
103438
|
-
signal,
|
|
103439
|
-
|
|
103591
|
+
const { agent: agent2, adapter, externalizeSessionUpdate } = await metrics.measure(
|
|
103592
|
+
"resolve-agent",
|
|
103593
|
+
async () => await resolveAgent(command.agentId, signal, command.sessionId)
|
|
103594
|
+
);
|
|
103595
|
+
const availability = await metrics.measure(
|
|
103596
|
+
"await-session-availability",
|
|
103597
|
+
async () => await waitForSessionAvailability(signal)
|
|
103440
103598
|
);
|
|
103441
|
-
const availability = await waitForSessionAvailability(signal);
|
|
103442
103599
|
if (availability.kind === "busy") {
|
|
103443
103600
|
throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
|
|
103444
103601
|
}
|
|
@@ -103469,21 +103626,31 @@ async function executePrompt({
|
|
|
103469
103626
|
if (availability.disposition !== SessionPromptDisposition.Steer) {
|
|
103470
103627
|
sessions.promptSuggestions.want(command.sessionId, command.suggestNextPrompt === true);
|
|
103471
103628
|
}
|
|
103472
|
-
let prepared = await
|
|
103629
|
+
let prepared = await metrics.measure(
|
|
103630
|
+
"prepare-session",
|
|
103631
|
+
async () => await sessions.prepareExecutionSession(preparation)
|
|
103632
|
+
);
|
|
103473
103633
|
if (command.sessionConfigurations !== void 0 && availability.disposition !== SessionPromptDisposition.Steer) {
|
|
103474
|
-
|
|
103475
|
-
|
|
103476
|
-
|
|
103477
|
-
|
|
103478
|
-
|
|
103479
|
-
|
|
103480
|
-
|
|
103481
|
-
|
|
103482
|
-
|
|
103483
|
-
|
|
103484
|
-
|
|
103634
|
+
const configurations = prepared.configOptions;
|
|
103635
|
+
await metrics.measure(
|
|
103636
|
+
"apply-configuration",
|
|
103637
|
+
async () => await applyCompleteSessionConfiguration(
|
|
103638
|
+
sessions,
|
|
103639
|
+
configurations,
|
|
103640
|
+
sessionConfigurations ?? [],
|
|
103641
|
+
executionAgent,
|
|
103642
|
+
adapter,
|
|
103643
|
+
resolved.cwd,
|
|
103644
|
+
resolved.additionalDirectories,
|
|
103645
|
+
command.commandId,
|
|
103646
|
+
command.sessionId,
|
|
103647
|
+
signal
|
|
103648
|
+
)
|
|
103649
|
+
);
|
|
103650
|
+
prepared = await metrics.measure(
|
|
103651
|
+
"prepare-session",
|
|
103652
|
+
async () => await sessions.prepareExecutionSession(preparation)
|
|
103485
103653
|
);
|
|
103486
|
-
prepared = await sessions.prepareExecutionSession(preparation);
|
|
103487
103654
|
}
|
|
103488
103655
|
signal.throwIfAborted();
|
|
103489
103656
|
const lifecycle = eventProjection.lifecycle(
|
|
@@ -103493,7 +103660,10 @@ async function executePrompt({
|
|
|
103493
103660
|
epoch,
|
|
103494
103661
|
availability.disposition
|
|
103495
103662
|
);
|
|
103496
|
-
const attachments = await
|
|
103663
|
+
const attachments = await metrics.measure(
|
|
103664
|
+
"resolve-attachments",
|
|
103665
|
+
async () => await resolvePromptArtifacts(readArtifact, command.attachments, signal)
|
|
103666
|
+
);
|
|
103497
103667
|
const skipped = command.attachments.length - attachments.images.length - attachments.resources.length;
|
|
103498
103668
|
if (skipped > 0) {
|
|
103499
103669
|
reportFailure("prompt_attachments_skipped", command.commandId, { count: skipped.toString() });
|
|
@@ -103537,6 +103707,7 @@ async function executePrompt({
|
|
|
103537
103707
|
resources: attachments.resources,
|
|
103538
103708
|
sessionId: command.sessionId,
|
|
103539
103709
|
signal,
|
|
103710
|
+
timing,
|
|
103540
103711
|
...suggestion2 === "requested" ? { suggestNextPrompt: true } : {},
|
|
103541
103712
|
targetCommandId: command.targetCommandId,
|
|
103542
103713
|
recovery
|
|
@@ -105899,4 +106070,4 @@ export {
|
|
|
105899
106070
|
* MIT Licensed
|
|
105900
106071
|
*)
|
|
105901
106072
|
*/
|
|
105902
|
-
//# sourceMappingURL=chunk-
|
|
106073
|
+
//# sourceMappingURL=chunk-CPVZCCBS.js.map
|