@moxt-ai/mobius 0.0.472 → 0.0.474
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-W5AYDFKU.js → chunk-CSWWCB7Z.js} +1407 -132
- package/dist/{chunk-W5AYDFKU.js.map → chunk-CSWWCB7Z.js.map} +4 -4
- package/dist/{chunk-6WVQ6SPI.js → chunk-RRU2BXWE.js} +2 -2
- package/dist/{chunk-6WVQ6SPI.js.map → chunk-RRU2BXWE.js.map} +1 -1
- package/dist/{cli-VHW4NONP.js → cli-5KNYU3LO.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/engine/acp/adapter/antigravity/adapter.d.ts +1 -0
- package/dist/engine/acp/adapter/antigravity/adapter.d.ts.map +1 -1
- package/dist/engine/acp/adapter/antigravity/adapter.js +17 -5
- package/dist/engine/acp/adapter/antigravity/adapter.js.map +1 -1
- package/dist/engine/acp/adapter/antigravity/agent-connection.d.ts +12 -0
- package/dist/engine/acp/adapter/antigravity/agent-connection.d.ts.map +1 -1
- package/dist/engine/acp/adapter/antigravity/agent-connection.js +100 -0
- package/dist/engine/acp/adapter/antigravity/agent-connection.js.map +1 -1
- package/dist/engine/acp/adapter/antigravity/background-wakeup.d.ts +26 -0
- package/dist/engine/acp/adapter/antigravity/background-wakeup.d.ts.map +1 -1
- package/dist/engine/acp/adapter/antigravity/background-wakeup.js +592 -0
- package/dist/engine/acp/adapter/antigravity/background-wakeup.js.map +1 -1
- package/dist/engine/acp/adapter/antigravity/session-artifacts.d.ts +39 -0
- package/dist/engine/acp/adapter/antigravity/session-artifacts.d.ts.map +1 -0
- package/dist/engine/acp/adapter/antigravity/session-artifacts.js +409 -0
- package/dist/engine/acp/adapter/antigravity/session-artifacts.js.map +1 -0
- package/dist/engine/acp/native-history/preview-contract.d.ts +7 -0
- package/dist/engine/acp/native-history/preview-contract.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/prompt.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/prompt.js +1 -0
- package/dist/engine/runtime/command/registry/prompt.js.map +1 -1
- package/dist/engine/session/live/agent-session.d.ts +2 -0
- package/dist/engine/session/live/agent-session.d.ts.map +1 -1
- package/dist/engine/session/live/agent-session.js +26 -2
- package/dist/engine/session/live/agent-session.js.map +1 -1
- package/dist/engine/session/manager/session-manager.d.ts +5 -0
- package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
- package/dist/engine/session/manager/session-manager.js +16 -2
- package/dist/engine/session/manager/session-manager.js.map +1 -1
- package/dist/engine/session/prompt/execute-prompt.d.ts +3 -1
- package/dist/engine/session/prompt/execute-prompt.d.ts.map +1 -1
- package/dist/engine/session/prompt/execute-prompt.js +57 -26
- package/dist/engine/session/prompt/execute-prompt.js.map +1 -1
- package/dist/engine/session/turn/active-turn.d.ts +5 -0
- package/dist/engine/session/turn/active-turn.d.ts.map +1 -1
- package/dist/engine/session/turn/active-turn.js +7 -0
- package/dist/engine/session/turn/active-turn.js.map +1 -1
- package/dist/engine/session/turn/session-execution.d.ts +5 -0
- package/dist/engine/session/turn/session-execution.d.ts.map +1 -1
- package/dist/engine/session/turn/session-execution.js +17 -0
- package/dist/engine/session/turn/session-execution.js.map +1 -1
- package/dist/engine/session/turn/session-turns.d.ts +1 -0
- package/dist/engine/session/turn/session-turns.d.ts.map +1 -1
- package/dist/engine/session/turn/session-turns.js +1 -0
- package/dist/engine/session/turn/session-turns.js.map +1 -1
- package/dist/engine/storage/files/local-files.d.ts +11 -0
- package/dist/engine/storage/files/local-files.d.ts.map +1 -1
- package/dist/engine/storage/files/local-files.js +141 -0
- package/dist/engine/storage/files/local-files.js.map +1 -1
- package/dist/engine.js +2 -2
- package/package.json +2 -2
- /package/dist/{cli-VHW4NONP.js.map → cli-5KNYU3LO.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-RRU2BXWE.js";
|
|
9
9
|
|
|
10
10
|
// ../../node_modules/.pnpm/ignore@7.0.9/node_modules/ignore/index.js
|
|
11
11
|
var require_ignore = __commonJS({
|
|
@@ -23278,6 +23278,7 @@ import { constants, createReadStream } from "node:fs";
|
|
|
23278
23278
|
import { mkdir, mkdtemp, open as open2, readdir, readFile, readlink, realpath, rm, stat } from "node:fs/promises";
|
|
23279
23279
|
import { tmpdir } from "node:os";
|
|
23280
23280
|
import { basename, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
23281
|
+
import { DatabaseSync } from "node:sqlite";
|
|
23281
23282
|
import { promisify } from "node:util";
|
|
23282
23283
|
function entryKind(entry) {
|
|
23283
23284
|
if (entry.isDirectory()) {
|
|
@@ -23370,6 +23371,131 @@ async function readScopedFileTail(baseDirectory, requestedRelativePath, maximumB
|
|
|
23370
23371
|
return null;
|
|
23371
23372
|
}
|
|
23372
23373
|
}
|
|
23374
|
+
async function readScopedFileBytes(baseDirectory, requestedRelativePath, maximumBytes) {
|
|
23375
|
+
if (requestedRelativePath.length === 0 || isAbsolute(requestedRelativePath) || maximumBytes <= 0) {
|
|
23376
|
+
return null;
|
|
23377
|
+
}
|
|
23378
|
+
try {
|
|
23379
|
+
const directory = await canonicalPath(resolve(baseDirectory));
|
|
23380
|
+
const candidate = resolve(directory, requestedRelativePath);
|
|
23381
|
+
if (!withinDirectory(directory, candidate)) {
|
|
23382
|
+
return null;
|
|
23383
|
+
}
|
|
23384
|
+
const target = await canonicalPath(candidate);
|
|
23385
|
+
if (!withinDirectory(directory, target)) {
|
|
23386
|
+
return null;
|
|
23387
|
+
}
|
|
23388
|
+
const handle = await open2(target, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
23389
|
+
try {
|
|
23390
|
+
const metadata = await handle.stat();
|
|
23391
|
+
if (!metadata.isFile() || metadata.size > maximumBytes) {
|
|
23392
|
+
return null;
|
|
23393
|
+
}
|
|
23394
|
+
if (metadata.size === 0) {
|
|
23395
|
+
return new Uint8Array(0);
|
|
23396
|
+
}
|
|
23397
|
+
const buffer = new Uint8Array(metadata.size);
|
|
23398
|
+
const { bytesRead } = await handle.read(buffer, 0, metadata.size, 0);
|
|
23399
|
+
return buffer.subarray(0, bytesRead);
|
|
23400
|
+
} finally {
|
|
23401
|
+
await handle.close();
|
|
23402
|
+
}
|
|
23403
|
+
} catch {
|
|
23404
|
+
return null;
|
|
23405
|
+
}
|
|
23406
|
+
}
|
|
23407
|
+
async function statScopedFile(baseDirectory, requestedRelativePath) {
|
|
23408
|
+
if (requestedRelativePath.length === 0 || isAbsolute(requestedRelativePath)) {
|
|
23409
|
+
return null;
|
|
23410
|
+
}
|
|
23411
|
+
try {
|
|
23412
|
+
const directory = await canonicalPath(resolve(baseDirectory));
|
|
23413
|
+
const candidate = resolve(directory, requestedRelativePath);
|
|
23414
|
+
if (!withinDirectory(directory, candidate)) {
|
|
23415
|
+
return null;
|
|
23416
|
+
}
|
|
23417
|
+
const target = await canonicalPath(candidate);
|
|
23418
|
+
if (!withinDirectory(directory, target)) {
|
|
23419
|
+
return null;
|
|
23420
|
+
}
|
|
23421
|
+
const handle = await open2(target, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
23422
|
+
try {
|
|
23423
|
+
const metadata = await handle.stat();
|
|
23424
|
+
if (!metadata.isFile()) {
|
|
23425
|
+
return null;
|
|
23426
|
+
}
|
|
23427
|
+
return { modifiedMilliseconds: metadata.mtimeMs, size: metadata.size };
|
|
23428
|
+
} finally {
|
|
23429
|
+
await handle.close();
|
|
23430
|
+
}
|
|
23431
|
+
} catch {
|
|
23432
|
+
return null;
|
|
23433
|
+
}
|
|
23434
|
+
}
|
|
23435
|
+
async function listScopedDirectory(baseDirectory, requestedRelativePath) {
|
|
23436
|
+
if (requestedRelativePath.length === 0 || isAbsolute(requestedRelativePath)) {
|
|
23437
|
+
return null;
|
|
23438
|
+
}
|
|
23439
|
+
try {
|
|
23440
|
+
const directory = await canonicalPath(resolve(baseDirectory));
|
|
23441
|
+
const candidate = resolve(directory, requestedRelativePath);
|
|
23442
|
+
if (!withinDirectory(directory, candidate)) {
|
|
23443
|
+
return null;
|
|
23444
|
+
}
|
|
23445
|
+
const target = await canonicalPath(candidate);
|
|
23446
|
+
if (!withinDirectory(directory, target)) {
|
|
23447
|
+
return null;
|
|
23448
|
+
}
|
|
23449
|
+
const metadata = await stat(target);
|
|
23450
|
+
if (!metadata.isDirectory()) {
|
|
23451
|
+
return null;
|
|
23452
|
+
}
|
|
23453
|
+
return await listDirectory(target);
|
|
23454
|
+
} catch {
|
|
23455
|
+
return null;
|
|
23456
|
+
}
|
|
23457
|
+
}
|
|
23458
|
+
async function queryScopedSqliteRow(baseDirectory, requestedRelativePath, sql2) {
|
|
23459
|
+
if (requestedRelativePath.length === 0 || isAbsolute(requestedRelativePath)) {
|
|
23460
|
+
return null;
|
|
23461
|
+
}
|
|
23462
|
+
let dbPath = null;
|
|
23463
|
+
try {
|
|
23464
|
+
const directory = await canonicalPath(resolve(baseDirectory));
|
|
23465
|
+
const candidate = resolve(directory, requestedRelativePath);
|
|
23466
|
+
if (!withinDirectory(directory, candidate)) {
|
|
23467
|
+
return null;
|
|
23468
|
+
}
|
|
23469
|
+
const target = await canonicalPath(candidate);
|
|
23470
|
+
if (!withinDirectory(directory, target)) {
|
|
23471
|
+
return null;
|
|
23472
|
+
}
|
|
23473
|
+
const handle = await open2(target, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
23474
|
+
try {
|
|
23475
|
+
const metadata = await handle.stat();
|
|
23476
|
+
dbPath = metadata.isFile() ? target : null;
|
|
23477
|
+
} finally {
|
|
23478
|
+
await handle.close();
|
|
23479
|
+
}
|
|
23480
|
+
} catch {
|
|
23481
|
+
return null;
|
|
23482
|
+
}
|
|
23483
|
+
if (dbPath === null) {
|
|
23484
|
+
return null;
|
|
23485
|
+
}
|
|
23486
|
+
let db2;
|
|
23487
|
+
try {
|
|
23488
|
+
db2 = new DatabaseSync(dbPath, { readOnly: true });
|
|
23489
|
+
return db2.prepare(sql2).get() ?? null;
|
|
23490
|
+
} catch {
|
|
23491
|
+
return null;
|
|
23492
|
+
} finally {
|
|
23493
|
+
try {
|
|
23494
|
+
db2?.close();
|
|
23495
|
+
} catch {
|
|
23496
|
+
}
|
|
23497
|
+
}
|
|
23498
|
+
}
|
|
23373
23499
|
async function readFileBytes(path6) {
|
|
23374
23500
|
return await readFile(path6);
|
|
23375
23501
|
}
|
|
@@ -29112,7 +29238,7 @@ function createWritableAcpStream(output2) {
|
|
|
29112
29238
|
|
|
29113
29239
|
// src/engine/acp/adapter/antigravity/background-wakeup.ts
|
|
29114
29240
|
import { homedir } from "node:os";
|
|
29115
|
-
import { join as
|
|
29241
|
+
import { join as join12 } from "node:path";
|
|
29116
29242
|
|
|
29117
29243
|
// src/engine/util/timer.ts
|
|
29118
29244
|
var SystemTimer = class {
|
|
@@ -29127,6 +29253,415 @@ var SystemTimer = class {
|
|
|
29127
29253
|
};
|
|
29128
29254
|
var systemTimer = new SystemTimer();
|
|
29129
29255
|
|
|
29256
|
+
// src/engine/acp/adapter/antigravity/session-artifacts.ts
|
|
29257
|
+
import { join as join11 } from "node:path";
|
|
29258
|
+
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;
|
|
29259
|
+
var TASK_ID_PATTERN = /^task-\d+$/u;
|
|
29260
|
+
var TASK_SENDER_PATTERN = /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/(task-\d+)$/iu;
|
|
29261
|
+
var MAXIMUM_JSON_BYTES = 65536;
|
|
29262
|
+
var MAXIMUM_SWARM_OR_READ_INDEX_BYTES = 262144;
|
|
29263
|
+
var MAXIMUM_SUBAGENT_FILES = 64;
|
|
29264
|
+
var MAXIMUM_MESSAGE_FILES = 256;
|
|
29265
|
+
var MAXIMUM_UNDELIVERED_FILES = 32;
|
|
29266
|
+
var MAXIMUM_TASK_LOG_FILES = 16;
|
|
29267
|
+
var MAXIMUM_ERROR_TEXT_CHARS = 500;
|
|
29268
|
+
var RESTART_SYSTEM_MESSAGE_MARKER = "All your subagents and background tasks have been stopped due to server restart";
|
|
29269
|
+
var subagentRecordSchema = external_exports.object({
|
|
29270
|
+
conversationId: external_exports.string().optional(),
|
|
29271
|
+
id: external_exports.string().optional(),
|
|
29272
|
+
state: external_exports.string().optional()
|
|
29273
|
+
});
|
|
29274
|
+
var swarmMemberSchema = external_exports.object({
|
|
29275
|
+
conversation_id: external_exports.string().optional(),
|
|
29276
|
+
conversationId: external_exports.string().optional(),
|
|
29277
|
+
desired_state: external_exports.string().optional(),
|
|
29278
|
+
desiredState: external_exports.string().optional(),
|
|
29279
|
+
phase: external_exports.string().optional(),
|
|
29280
|
+
wake_mode: external_exports.string().optional(),
|
|
29281
|
+
wakeMode: external_exports.string().optional()
|
|
29282
|
+
});
|
|
29283
|
+
var swarmMembersFileSchema = external_exports.object({
|
|
29284
|
+
members: external_exports.array(swarmMemberSchema).optional()
|
|
29285
|
+
});
|
|
29286
|
+
var messageRecordSchema = external_exports.object({
|
|
29287
|
+
id: external_exports.string().optional(),
|
|
29288
|
+
priority: external_exports.string().optional(),
|
|
29289
|
+
sender: external_exports.string().optional(),
|
|
29290
|
+
sourceMetadata: external_exports.object({
|
|
29291
|
+
tool: external_exports.object({
|
|
29292
|
+
toolCall: external_exports.object({
|
|
29293
|
+
id: external_exports.string().optional()
|
|
29294
|
+
}).optional()
|
|
29295
|
+
}).optional()
|
|
29296
|
+
}).optional(),
|
|
29297
|
+
timestamp: external_exports.string().optional()
|
|
29298
|
+
});
|
|
29299
|
+
var readIndexSchema = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
29300
|
+
var conversationDbStepRowSchema = external_exports.object({
|
|
29301
|
+
error_details: external_exports.instanceof(Uint8Array).nullable().optional(),
|
|
29302
|
+
status: external_exports.number().int().optional()
|
|
29303
|
+
});
|
|
29304
|
+
var EMPTY_SUBAGENT_SNAPSHOT = {
|
|
29305
|
+
activeChildIds: /* @__PURE__ */ new Set(),
|
|
29306
|
+
available: false,
|
|
29307
|
+
conversationIdByToolCallId: /* @__PURE__ */ new Map(),
|
|
29308
|
+
deliveredNativeTaskIds: /* @__PURE__ */ new Set(),
|
|
29309
|
+
deliveredToolCallIds: /* @__PURE__ */ new Set(),
|
|
29310
|
+
resolvedChildIds: /* @__PURE__ */ new Set()
|
|
29311
|
+
};
|
|
29312
|
+
function parseTimestampMs(raw) {
|
|
29313
|
+
if (raw === void 0 || raw.length === 0) {
|
|
29314
|
+
return void 0;
|
|
29315
|
+
}
|
|
29316
|
+
const parsed = Date.parse(raw);
|
|
29317
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
29318
|
+
}
|
|
29319
|
+
function normalizeUuid(raw) {
|
|
29320
|
+
if (raw === void 0) {
|
|
29321
|
+
return void 0;
|
|
29322
|
+
}
|
|
29323
|
+
const trimmed = raw.trim().toLowerCase();
|
|
29324
|
+
return SESSION_UUID_PATTERN.test(trimmed) ? trimmed : void 0;
|
|
29325
|
+
}
|
|
29326
|
+
async function readScopedJson(baseDirectory, relativePath, maximumBytes, schema) {
|
|
29327
|
+
const bytes = await readScopedFileBytes(baseDirectory, relativePath, maximumBytes);
|
|
29328
|
+
if (bytes === null || bytes.byteLength === 0) {
|
|
29329
|
+
return null;
|
|
29330
|
+
}
|
|
29331
|
+
let decoded;
|
|
29332
|
+
try {
|
|
29333
|
+
decoded = JSON.parse(new TextDecoder().decode(bytes));
|
|
29334
|
+
} catch {
|
|
29335
|
+
return null;
|
|
29336
|
+
}
|
|
29337
|
+
const parsed = schema.safeParse(decoded);
|
|
29338
|
+
return parsed.success ? parsed.data : null;
|
|
29339
|
+
}
|
|
29340
|
+
function brainGeneratedPath(sessionId, ...segments) {
|
|
29341
|
+
return join11("antigravity-cli", "brain", sessionId, ".system_generated", ...segments);
|
|
29342
|
+
}
|
|
29343
|
+
async function readChildInboundInfo(geminiHome, parentSessionId, childId) {
|
|
29344
|
+
const toolCallIds = [];
|
|
29345
|
+
let latestInboundMs;
|
|
29346
|
+
let hasUndeliveredFromParent = false;
|
|
29347
|
+
const normalizedParent = parentSessionId.toLowerCase();
|
|
29348
|
+
const inspectDirectory = async (relativeDir, markUndelivered) => {
|
|
29349
|
+
const entries = await listScopedDirectory(geminiHome, relativeDir);
|
|
29350
|
+
if (entries === null) {
|
|
29351
|
+
return;
|
|
29352
|
+
}
|
|
29353
|
+
let inspected = 0;
|
|
29354
|
+
for (const entry of entries) {
|
|
29355
|
+
if (inspected >= MAXIMUM_UNDELIVERED_FILES) {
|
|
29356
|
+
break;
|
|
29357
|
+
}
|
|
29358
|
+
if (entry.kind !== "file" || !entry.name.endsWith(".json") || entry.name === "read.json") {
|
|
29359
|
+
continue;
|
|
29360
|
+
}
|
|
29361
|
+
inspected += 1;
|
|
29362
|
+
const record2 = await readScopedJson(
|
|
29363
|
+
geminiHome,
|
|
29364
|
+
join11(relativeDir, entry.name),
|
|
29365
|
+
MAXIMUM_JSON_BYTES,
|
|
29366
|
+
messageRecordSchema
|
|
29367
|
+
);
|
|
29368
|
+
if (record2 === null) {
|
|
29369
|
+
continue;
|
|
29370
|
+
}
|
|
29371
|
+
const sender = normalizeUuid(record2.sender);
|
|
29372
|
+
if (sender !== normalizedParent) {
|
|
29373
|
+
continue;
|
|
29374
|
+
}
|
|
29375
|
+
if (markUndelivered) {
|
|
29376
|
+
hasUndeliveredFromParent = true;
|
|
29377
|
+
}
|
|
29378
|
+
const ts2 = parseTimestampMs(record2.timestamp);
|
|
29379
|
+
if (ts2 !== void 0 && (latestInboundMs === void 0 || ts2 > latestInboundMs)) {
|
|
29380
|
+
latestInboundMs = ts2;
|
|
29381
|
+
}
|
|
29382
|
+
const toolCallId = record2.sourceMetadata?.tool?.toolCall?.id?.trim();
|
|
29383
|
+
if (toolCallId !== void 0 && toolCallId.length > 0) {
|
|
29384
|
+
toolCallIds.push(toolCallId);
|
|
29385
|
+
}
|
|
29386
|
+
}
|
|
29387
|
+
};
|
|
29388
|
+
await inspectDirectory(brainGeneratedPath(childId, "messages"), false);
|
|
29389
|
+
await inspectDirectory(brainGeneratedPath(childId, "messages", "undelivered"), true);
|
|
29390
|
+
return { hasUndeliveredFromParent, latestInboundMs, toolCallIds };
|
|
29391
|
+
}
|
|
29392
|
+
async function readAntigravitySubagentSnapshot(geminiHome, sessionId) {
|
|
29393
|
+
if (geminiHome === void 0 || !SESSION_UUID_PATTERN.test(sessionId)) {
|
|
29394
|
+
return EMPTY_SUBAGENT_SNAPSHOT;
|
|
29395
|
+
}
|
|
29396
|
+
const targetSessionId = sessionId.toLowerCase();
|
|
29397
|
+
const conversationIdByToolCallId = /* @__PURE__ */ new Map();
|
|
29398
|
+
const activeChildIds = /* @__PURE__ */ new Set();
|
|
29399
|
+
const resolvedChildIds = /* @__PURE__ */ new Set();
|
|
29400
|
+
const deliveredToolCallIds = /* @__PURE__ */ new Set();
|
|
29401
|
+
const deliveredNativeTaskIds = /* @__PURE__ */ new Set();
|
|
29402
|
+
const parentRepliedChildren = /* @__PURE__ */ new Set();
|
|
29403
|
+
const parentReplyMsByChild = /* @__PURE__ */ new Map();
|
|
29404
|
+
const parentMsgDir = brainGeneratedPath(sessionId, "messages");
|
|
29405
|
+
const parentMsgEntries = await listScopedDirectory(geminiHome, parentMsgDir);
|
|
29406
|
+
if (parentMsgEntries !== null) {
|
|
29407
|
+
let inspected = 0;
|
|
29408
|
+
for (const entry of parentMsgEntries) {
|
|
29409
|
+
if (inspected >= MAXIMUM_MESSAGE_FILES) {
|
|
29410
|
+
break;
|
|
29411
|
+
}
|
|
29412
|
+
if (entry.kind !== "file" || !entry.name.endsWith(".json") || entry.name === "read.json") {
|
|
29413
|
+
continue;
|
|
29414
|
+
}
|
|
29415
|
+
inspected += 1;
|
|
29416
|
+
const record2 = await readScopedJson(
|
|
29417
|
+
geminiHome,
|
|
29418
|
+
join11(parentMsgDir, entry.name),
|
|
29419
|
+
MAXIMUM_JSON_BYTES,
|
|
29420
|
+
messageRecordSchema
|
|
29421
|
+
);
|
|
29422
|
+
if (record2 === null || record2.sender === void 0) {
|
|
29423
|
+
continue;
|
|
29424
|
+
}
|
|
29425
|
+
const taskMatch = TASK_SENDER_PATTERN.exec(record2.sender.trim());
|
|
29426
|
+
if (taskMatch !== null) {
|
|
29427
|
+
if (taskMatch[1]?.toLowerCase() === targetSessionId && taskMatch[2] !== void 0) {
|
|
29428
|
+
deliveredNativeTaskIds.add(taskMatch[2]);
|
|
29429
|
+
const toolCallId = record2.sourceMetadata?.tool?.toolCall?.id?.trim();
|
|
29430
|
+
if (toolCallId !== void 0 && toolCallId.length > 0) {
|
|
29431
|
+
deliveredToolCallIds.add(toolCallId);
|
|
29432
|
+
}
|
|
29433
|
+
}
|
|
29434
|
+
continue;
|
|
29435
|
+
}
|
|
29436
|
+
const childSender = normalizeUuid(record2.sender);
|
|
29437
|
+
if (childSender !== void 0 && childSender !== targetSessionId) {
|
|
29438
|
+
parentRepliedChildren.add(childSender);
|
|
29439
|
+
const ts2 = parseTimestampMs(record2.timestamp);
|
|
29440
|
+
const existing = parentReplyMsByChild.get(childSender);
|
|
29441
|
+
if (ts2 !== void 0 && (existing === void 0 || ts2 > existing)) {
|
|
29442
|
+
parentReplyMsByChild.set(childSender, ts2);
|
|
29443
|
+
}
|
|
29444
|
+
}
|
|
29445
|
+
}
|
|
29446
|
+
}
|
|
29447
|
+
let available = false;
|
|
29448
|
+
const classifyAliveChild = async (childId) => {
|
|
29449
|
+
const inbound = await readChildInboundInfo(geminiHome, sessionId, childId);
|
|
29450
|
+
for (const toolCallId of inbound.toolCallIds) {
|
|
29451
|
+
conversationIdByToolCallId.set(toolCallId, childId);
|
|
29452
|
+
}
|
|
29453
|
+
const replied = parentRepliedChildren.has(childId);
|
|
29454
|
+
const replyMs = parentReplyMsByChild.get(childId);
|
|
29455
|
+
const replyCoversLatestInbound = replied && !inbound.hasUndeliveredFromParent && (inbound.latestInboundMs === void 0 || replyMs !== void 0 && replyMs >= inbound.latestInboundMs);
|
|
29456
|
+
if (replyCoversLatestInbound) {
|
|
29457
|
+
resolvedChildIds.add(childId);
|
|
29458
|
+
} else {
|
|
29459
|
+
activeChildIds.add(childId);
|
|
29460
|
+
}
|
|
29461
|
+
};
|
|
29462
|
+
const subagentsDir = brainGeneratedPath(sessionId, "subagents");
|
|
29463
|
+
const subagentEntries = await listScopedDirectory(geminiHome, subagentsDir);
|
|
29464
|
+
if (subagentEntries !== null) {
|
|
29465
|
+
available = true;
|
|
29466
|
+
let inspected = 0;
|
|
29467
|
+
for (const entry of subagentEntries) {
|
|
29468
|
+
if (inspected >= MAXIMUM_SUBAGENT_FILES) {
|
|
29469
|
+
break;
|
|
29470
|
+
}
|
|
29471
|
+
if (entry.kind !== "file" || !entry.name.endsWith(".json")) {
|
|
29472
|
+
continue;
|
|
29473
|
+
}
|
|
29474
|
+
inspected += 1;
|
|
29475
|
+
const record2 = await readScopedJson(
|
|
29476
|
+
geminiHome,
|
|
29477
|
+
join11(subagentsDir, entry.name),
|
|
29478
|
+
MAXIMUM_JSON_BYTES,
|
|
29479
|
+
subagentRecordSchema
|
|
29480
|
+
);
|
|
29481
|
+
if (record2 === null) {
|
|
29482
|
+
continue;
|
|
29483
|
+
}
|
|
29484
|
+
const childId = normalizeUuid(record2.conversationId) ?? normalizeUuid(record2.id) ?? normalizeUuid(entry.name.slice(0, -".json".length));
|
|
29485
|
+
if (childId === void 0) {
|
|
29486
|
+
continue;
|
|
29487
|
+
}
|
|
29488
|
+
if (record2.state === "SUBAGENT_STATE_KILLED") {
|
|
29489
|
+
resolvedChildIds.add(childId);
|
|
29490
|
+
const inbound = await readChildInboundInfo(geminiHome, sessionId, childId);
|
|
29491
|
+
for (const toolCallId of inbound.toolCallIds) {
|
|
29492
|
+
conversationIdByToolCallId.set(toolCallId, childId);
|
|
29493
|
+
}
|
|
29494
|
+
continue;
|
|
29495
|
+
}
|
|
29496
|
+
await classifyAliveChild(childId);
|
|
29497
|
+
}
|
|
29498
|
+
}
|
|
29499
|
+
const swarmFile = await readScopedJson(
|
|
29500
|
+
geminiHome,
|
|
29501
|
+
brainGeneratedPath(sessionId, "swarm", "members.json"),
|
|
29502
|
+
MAXIMUM_SWARM_OR_READ_INDEX_BYTES,
|
|
29503
|
+
swarmMembersFileSchema
|
|
29504
|
+
);
|
|
29505
|
+
if (swarmFile?.members !== void 0) {
|
|
29506
|
+
available = true;
|
|
29507
|
+
for (const member of swarmFile.members.slice(0, MAXIMUM_SUBAGENT_FILES)) {
|
|
29508
|
+
const childId = normalizeUuid(member.conversation_id ?? member.conversationId);
|
|
29509
|
+
if (childId === void 0) {
|
|
29510
|
+
continue;
|
|
29511
|
+
}
|
|
29512
|
+
const desiredState = (member.desired_state ?? member.desiredState ?? "").toUpperCase();
|
|
29513
|
+
const phase = (member.phase ?? "").toUpperCase();
|
|
29514
|
+
const wakeMode = (member.wake_mode ?? member.wakeMode ?? "").toLowerCase();
|
|
29515
|
+
if (desiredState.includes("KILLED") || phase.includes("KILLED") || (phase.includes("WAIT") || phase.includes("IDLE") || phase.includes("PARK")) && wakeMode === "mentions") {
|
|
29516
|
+
resolvedChildIds.add(childId);
|
|
29517
|
+
continue;
|
|
29518
|
+
}
|
|
29519
|
+
await classifyAliveChild(childId);
|
|
29520
|
+
}
|
|
29521
|
+
}
|
|
29522
|
+
return {
|
|
29523
|
+
activeChildIds,
|
|
29524
|
+
available,
|
|
29525
|
+
conversationIdByToolCallId,
|
|
29526
|
+
deliveredNativeTaskIds,
|
|
29527
|
+
deliveredToolCallIds,
|
|
29528
|
+
resolvedChildIds
|
|
29529
|
+
};
|
|
29530
|
+
}
|
|
29531
|
+
async function readAntigravityPendingReply(geminiHome, sessionId, lastTranscriptStep) {
|
|
29532
|
+
if (lastTranscriptStep !== void 0 && lastTranscriptStep.type === "SYSTEM_MESSAGE" && !(lastTranscriptStep.content?.includes(RESTART_SYSTEM_MESSAGE_MARKER) ?? false)) {
|
|
29533
|
+
return true;
|
|
29534
|
+
}
|
|
29535
|
+
if (geminiHome === void 0 || !SESSION_UUID_PATTERN.test(sessionId)) {
|
|
29536
|
+
return false;
|
|
29537
|
+
}
|
|
29538
|
+
const undeliveredDir = brainGeneratedPath(sessionId, "messages", "undelivered");
|
|
29539
|
+
const undeliveredEntries = await listScopedDirectory(geminiHome, undeliveredDir);
|
|
29540
|
+
if (undeliveredEntries !== null) {
|
|
29541
|
+
let inspected2 = 0;
|
|
29542
|
+
for (const entry of undeliveredEntries) {
|
|
29543
|
+
if (inspected2 >= MAXIMUM_UNDELIVERED_FILES) {
|
|
29544
|
+
break;
|
|
29545
|
+
}
|
|
29546
|
+
if (entry.kind !== "file" || !entry.name.endsWith(".json")) {
|
|
29547
|
+
continue;
|
|
29548
|
+
}
|
|
29549
|
+
inspected2 += 1;
|
|
29550
|
+
const record2 = await readScopedJson(
|
|
29551
|
+
geminiHome,
|
|
29552
|
+
join11(undeliveredDir, entry.name),
|
|
29553
|
+
MAXIMUM_JSON_BYTES,
|
|
29554
|
+
messageRecordSchema
|
|
29555
|
+
);
|
|
29556
|
+
if (record2 === null || record2.priority === void 0 || record2.priority === "MESSAGE_PRIORITY_HIGH") {
|
|
29557
|
+
return true;
|
|
29558
|
+
}
|
|
29559
|
+
}
|
|
29560
|
+
}
|
|
29561
|
+
const parentMsgDir = brainGeneratedPath(sessionId, "messages");
|
|
29562
|
+
const readIndex = await readScopedJson(
|
|
29563
|
+
geminiHome,
|
|
29564
|
+
join11(parentMsgDir, "read.json"),
|
|
29565
|
+
MAXIMUM_SWARM_OR_READ_INDEX_BYTES,
|
|
29566
|
+
readIndexSchema
|
|
29567
|
+
);
|
|
29568
|
+
if (readIndex === null) {
|
|
29569
|
+
return false;
|
|
29570
|
+
}
|
|
29571
|
+
const entries = await listScopedDirectory(geminiHome, parentMsgDir);
|
|
29572
|
+
if (entries === null) {
|
|
29573
|
+
return false;
|
|
29574
|
+
}
|
|
29575
|
+
let inspected = 0;
|
|
29576
|
+
for (const entry of entries) {
|
|
29577
|
+
if (inspected >= MAXIMUM_MESSAGE_FILES) {
|
|
29578
|
+
break;
|
|
29579
|
+
}
|
|
29580
|
+
if (entry.kind !== "file" || !entry.name.endsWith(".json") || entry.name === "read.json") {
|
|
29581
|
+
continue;
|
|
29582
|
+
}
|
|
29583
|
+
inspected += 1;
|
|
29584
|
+
const messageIdFromName = entry.name.slice(0, -".json".length);
|
|
29585
|
+
if (readIndex[messageIdFromName] === true) {
|
|
29586
|
+
continue;
|
|
29587
|
+
}
|
|
29588
|
+
const message = await readScopedJson(
|
|
29589
|
+
geminiHome,
|
|
29590
|
+
join11(parentMsgDir, entry.name),
|
|
29591
|
+
MAXIMUM_JSON_BYTES,
|
|
29592
|
+
messageRecordSchema
|
|
29593
|
+
);
|
|
29594
|
+
if (message === null) {
|
|
29595
|
+
continue;
|
|
29596
|
+
}
|
|
29597
|
+
const id = message.id ?? messageIdFromName;
|
|
29598
|
+
if (readIndex[id] !== true && message.priority === "MESSAGE_PRIORITY_HIGH") {
|
|
29599
|
+
return true;
|
|
29600
|
+
}
|
|
29601
|
+
}
|
|
29602
|
+
return false;
|
|
29603
|
+
}
|
|
29604
|
+
async function readAntigravityTaskLogSignature(geminiHome, sessionId, nativeTaskIds) {
|
|
29605
|
+
if (geminiHome === void 0 || !SESSION_UUID_PATTERN.test(sessionId)) {
|
|
29606
|
+
return "";
|
|
29607
|
+
}
|
|
29608
|
+
const tasksDir = brainGeneratedPath(sessionId, "tasks");
|
|
29609
|
+
const targets = [];
|
|
29610
|
+
for (const nativeTaskId of nativeTaskIds) {
|
|
29611
|
+
if (TASK_ID_PATTERN.test(nativeTaskId)) {
|
|
29612
|
+
targets.push(`${nativeTaskId}.log`);
|
|
29613
|
+
}
|
|
29614
|
+
}
|
|
29615
|
+
if (targets.length === 0) {
|
|
29616
|
+
const entries = await listScopedDirectory(geminiHome, tasksDir);
|
|
29617
|
+
if (entries === null) {
|
|
29618
|
+
return "";
|
|
29619
|
+
}
|
|
29620
|
+
for (const entry of entries) {
|
|
29621
|
+
if (entry.kind === "file" && /^task-\d+\.log$/u.test(entry.name)) {
|
|
29622
|
+
targets.push(entry.name);
|
|
29623
|
+
}
|
|
29624
|
+
}
|
|
29625
|
+
}
|
|
29626
|
+
targets.sort();
|
|
29627
|
+
const parts = [];
|
|
29628
|
+
for (const fileName of targets.slice(0, MAXIMUM_TASK_LOG_FILES)) {
|
|
29629
|
+
const stats = await statScopedFile(geminiHome, join11(tasksDir, fileName));
|
|
29630
|
+
if (stats !== null) {
|
|
29631
|
+
parts.push(`${fileName}:${String(stats.size)}:${String(Math.trunc(stats.modifiedMilliseconds))}`);
|
|
29632
|
+
}
|
|
29633
|
+
}
|
|
29634
|
+
return parts.join("|");
|
|
29635
|
+
}
|
|
29636
|
+
function extractReadableErrorFromBlob(blob2) {
|
|
29637
|
+
const decoded = new TextDecoder("utf-8", { fatal: false }).decode(blob2);
|
|
29638
|
+
const printableRuns = decoded.match(/[\x20-\x7e]{8,}/gu) ?? [];
|
|
29639
|
+
const informative = printableRuns.map((run) => run.trim()).filter((run) => /[a-zA-Z]{3,}/u.test(run)).sort((left, right) => right.length - left.length)[0];
|
|
29640
|
+
if (informative === void 0 || informative.length === 0) {
|
|
29641
|
+
return "Antigravity recorded an internal execution error";
|
|
29642
|
+
}
|
|
29643
|
+
return truncate(informative, MAXIMUM_ERROR_TEXT_CHARS);
|
|
29644
|
+
}
|
|
29645
|
+
async function readAntigravityConversationTerminalError(geminiHome, sessionId) {
|
|
29646
|
+
if (geminiHome === void 0 || !SESSION_UUID_PATTERN.test(sessionId)) {
|
|
29647
|
+
return null;
|
|
29648
|
+
}
|
|
29649
|
+
const row = await queryScopedSqliteRow(
|
|
29650
|
+
geminiHome,
|
|
29651
|
+
join11("antigravity-cli", "conversations", `${sessionId}.db`),
|
|
29652
|
+
"SELECT status, error_details FROM steps ORDER BY idx DESC LIMIT 1"
|
|
29653
|
+
);
|
|
29654
|
+
const parsed = conversationDbStepRowSchema.safeParse(row);
|
|
29655
|
+
if (!parsed.success) {
|
|
29656
|
+
return null;
|
|
29657
|
+
}
|
|
29658
|
+
const details = parsed.data.error_details;
|
|
29659
|
+
if (details === null || details === void 0 || details.byteLength === 0) {
|
|
29660
|
+
return null;
|
|
29661
|
+
}
|
|
29662
|
+
return extractReadableErrorFromBlob(details);
|
|
29663
|
+
}
|
|
29664
|
+
|
|
29130
29665
|
// src/engine/acp/adapter/antigravity/background-wakeup.ts
|
|
29131
29666
|
var TRANSCRIPT_TAIL_BYTES = 65536;
|
|
29132
29667
|
var SUBAGENT_RECONCILE_TAIL_BYTES = 1048576;
|
|
@@ -29134,7 +29669,11 @@ var TRANSCRIPT_INITIAL_DELAY_MS = 40;
|
|
|
29134
29669
|
var TRANSCRIPT_POLL_INTERVAL_MS = 150;
|
|
29135
29670
|
var MAX_PARTIAL_SETTLED_TEXT_DEFERRALS = 2;
|
|
29136
29671
|
var WAKEUP_INACTIVITY_TIMEOUT_MS = 3e5;
|
|
29137
|
-
var
|
|
29672
|
+
var WATCHDOG_SLICE_MS = 6e4;
|
|
29673
|
+
var ORPHAN_SHELL_SILENCE_SLICES = 5;
|
|
29674
|
+
var ORPHAN_SHELL_MAX_HOLD_SLICES = 30;
|
|
29675
|
+
var OPEN_PROMPT_INACTIVITY_SLICES = 15;
|
|
29676
|
+
var SESSION_UUID_PATTERN2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
|
|
29138
29677
|
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;
|
|
29139
29678
|
var SUBAGENT_IDLE_ID_PATTERN = /\bSubagent ([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}) (?:has gone|went) idle\b/giu;
|
|
29140
29679
|
var SUBAGENT_MESSAGE_SENDER_PATTERN = /^\[Message\]\s+timestamp=\S+\s+sender=([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?!\/)\b/gimu;
|
|
@@ -29179,10 +29718,10 @@ function resolveGeminiHome(launchEnvironment) {
|
|
|
29179
29718
|
return configured;
|
|
29180
29719
|
}
|
|
29181
29720
|
const home = launchEnvironment["HOME"]?.trim() || launchEnvironment["USERPROFILE"]?.trim() || homedir();
|
|
29182
|
-
return home.length > 0 ?
|
|
29721
|
+
return home.length > 0 ? join12(home, ".gemini") : void 0;
|
|
29183
29722
|
}
|
|
29184
29723
|
async function readTranscriptTailState(launchEnvironment, sessionId, baselineStepIndex, maximumBytes = TRANSCRIPT_TAIL_BYTES) {
|
|
29185
|
-
if (!
|
|
29724
|
+
if (!SESSION_UUID_PATTERN2.test(sessionId)) {
|
|
29186
29725
|
return null;
|
|
29187
29726
|
}
|
|
29188
29727
|
const geminiHome = resolveGeminiHome(launchEnvironment);
|
|
@@ -29191,7 +29730,7 @@ async function readTranscriptTailState(launchEnvironment, sessionId, baselineSte
|
|
|
29191
29730
|
}
|
|
29192
29731
|
const tail = await readScopedFileTail(
|
|
29193
29732
|
geminiHome,
|
|
29194
|
-
|
|
29733
|
+
join12("antigravity-cli", "brain", sessionId, ".system_generated", "logs", "transcript.jsonl"),
|
|
29195
29734
|
maximumBytes
|
|
29196
29735
|
);
|
|
29197
29736
|
if (tail === null) {
|
|
@@ -29301,6 +29840,12 @@ function readToolCategory(update, inputs, previous) {
|
|
|
29301
29840
|
if (name2 === "manage_subagents") {
|
|
29302
29841
|
return "manage-subagents";
|
|
29303
29842
|
}
|
|
29843
|
+
if (name2 === "manage_task") {
|
|
29844
|
+
return "manage-task";
|
|
29845
|
+
}
|
|
29846
|
+
if (name2 === "swarm") {
|
|
29847
|
+
return "swarm";
|
|
29848
|
+
}
|
|
29304
29849
|
const title = readString3(update, "title");
|
|
29305
29850
|
if (title === "Run invoke_subagent" || title === "Running invoke_subagent" || title === "Run invoke_subagent?" || title === "Running start_subagent" || title === "Run start_subagent?") {
|
|
29306
29851
|
return "subagent";
|
|
@@ -29311,6 +29856,12 @@ function readToolCategory(update, inputs, previous) {
|
|
|
29311
29856
|
if (title === "Run manage_subagents") {
|
|
29312
29857
|
return "manage-subagents";
|
|
29313
29858
|
}
|
|
29859
|
+
if (title === "Run manage_task" || title === "Running manage_task") {
|
|
29860
|
+
return "manage-task";
|
|
29861
|
+
}
|
|
29862
|
+
if (title === "Run swarm" || title === "Running swarm") {
|
|
29863
|
+
return "swarm";
|
|
29864
|
+
}
|
|
29314
29865
|
if (previous?.category !== void 0 && previous.category !== null) {
|
|
29315
29866
|
return previous.category;
|
|
29316
29867
|
}
|
|
@@ -29319,12 +29870,25 @@ function readToolCategory(update, inputs, previous) {
|
|
|
29319
29870
|
}
|
|
29320
29871
|
return null;
|
|
29321
29872
|
}
|
|
29873
|
+
function normalizeManageTaskKillId(rawTaskId) {
|
|
29874
|
+
if (rawTaskId === void 0) {
|
|
29875
|
+
return void 0;
|
|
29876
|
+
}
|
|
29877
|
+
const trimmed = rawTaskId.trim();
|
|
29878
|
+
if (trimmed.length === 0) {
|
|
29879
|
+
return void 0;
|
|
29880
|
+
}
|
|
29881
|
+
const slashIndex = trimmed.lastIndexOf("/");
|
|
29882
|
+
return slashIndex === -1 ? trimmed : trimmed.slice(slashIndex + 1);
|
|
29883
|
+
}
|
|
29322
29884
|
function inspectToolMetadata(update, previous) {
|
|
29323
29885
|
const inputs = extractToolInputRecords(update);
|
|
29324
29886
|
const category = readToolCategory(update, inputs, previous);
|
|
29325
29887
|
let isDaemon = previous?.isDaemon ?? false;
|
|
29326
29888
|
const subagentKillIds = new Set(previous?.subagentKillIds ?? []);
|
|
29327
29889
|
let subagentKillAll = previous?.subagentKillAll ?? false;
|
|
29890
|
+
let killTaskId = previous?.killTaskId;
|
|
29891
|
+
let swarmAction = previous?.swarmAction;
|
|
29328
29892
|
for (const record2 of inputs) {
|
|
29329
29893
|
if (record2["IsDaemon"] === true) {
|
|
29330
29894
|
isDaemon = true;
|
|
@@ -29348,16 +29912,30 @@ function inspectToolMetadata(update, previous) {
|
|
|
29348
29912
|
}
|
|
29349
29913
|
}
|
|
29350
29914
|
}
|
|
29915
|
+
if (category === "manage-task") {
|
|
29916
|
+
const action = readString3(record2, "Action");
|
|
29917
|
+
if (action === "kill") {
|
|
29918
|
+
killTaskId = normalizeManageTaskKillId(readString3(record2, "TaskId")) ?? killTaskId;
|
|
29919
|
+
}
|
|
29920
|
+
}
|
|
29921
|
+
if (category === "swarm") {
|
|
29922
|
+
const action = readString3(record2, "action");
|
|
29923
|
+
if (action === "add" || action === "kill") {
|
|
29924
|
+
swarmAction = action;
|
|
29925
|
+
}
|
|
29926
|
+
}
|
|
29351
29927
|
}
|
|
29352
29928
|
const matchText = readInputString(inputs, "CommandLine") ?? readInputString(inputs, "Prompt") ?? readInputString(inputs, "Description") ?? previous?.matchText;
|
|
29353
|
-
const description = readInputString(inputs, "toolSummary") ?? readInputString(inputs, "Description") ?? readInputString(inputs, "Role") ?? readInputString(inputs, "CommandLine") ?? readInputString(inputs, "Prompt") ?? readString3(update, "title") ?? previous?.description;
|
|
29929
|
+
const description = readInputString(inputs, "toolSummary") ?? readInputString(inputs, "Description") ?? readInputString(inputs, "Role") ?? readInputString(inputs, "name") ?? readInputString(inputs, "CommandLine") ?? readInputString(inputs, "Prompt") ?? readString3(update, "title") ?? previous?.description;
|
|
29354
29930
|
return {
|
|
29355
29931
|
category,
|
|
29356
29932
|
description: description === void 0 ? void 0 : truncate(description, MAXIMUM_TOOL_DESCRIPTION_CHARS),
|
|
29357
29933
|
isDaemon,
|
|
29934
|
+
killTaskId,
|
|
29358
29935
|
matchText,
|
|
29359
29936
|
subagentKillAll,
|
|
29360
|
-
subagentKillIds: [...subagentKillIds]
|
|
29937
|
+
subagentKillIds: [...subagentKillIds],
|
|
29938
|
+
swarmAction
|
|
29361
29939
|
};
|
|
29362
29940
|
}
|
|
29363
29941
|
function isBackgroundableCategory(category) {
|
|
@@ -29451,6 +30029,28 @@ function extractTaskResultSenderIds(sessionId, steps, minStepExclusive, maxStepI
|
|
|
29451
30029
|
}
|
|
29452
30030
|
return received;
|
|
29453
30031
|
}
|
|
30032
|
+
var RESTART_SYSTEM_MESSAGE_MARKER2 = "All your subagents and background tasks have been stopped due to server restart";
|
|
30033
|
+
function findTrailingSettledReply(steps, minStepExclusive) {
|
|
30034
|
+
for (let index2 = steps.length - 1; index2 >= 0; index2 -= 1) {
|
|
30035
|
+
const step = steps[index2];
|
|
30036
|
+
if (step === void 0 || step.step_index <= minStepExclusive) {
|
|
30037
|
+
break;
|
|
30038
|
+
}
|
|
30039
|
+
if (step.type === "USER_INPUT") {
|
|
30040
|
+
return null;
|
|
30041
|
+
}
|
|
30042
|
+
if (step.type === "SYSTEM_MESSAGE" && !(step.content?.includes(RESTART_SYSTEM_MESSAGE_MARKER2) ?? false)) {
|
|
30043
|
+
return null;
|
|
30044
|
+
}
|
|
30045
|
+
if (step.type === "PLANNER_RESPONSE") {
|
|
30046
|
+
if (step.status === "DONE" && (step.tool_calls === void 0 || step.tool_calls.length === 0)) {
|
|
30047
|
+
return { content: step.content, stepIndex: step.step_index };
|
|
30048
|
+
}
|
|
30049
|
+
return null;
|
|
30050
|
+
}
|
|
30051
|
+
}
|
|
30052
|
+
return null;
|
|
30053
|
+
}
|
|
29454
30054
|
function backgroundKindFor(category) {
|
|
29455
30055
|
switch (category) {
|
|
29456
30056
|
case "command":
|
|
@@ -29461,6 +30061,8 @@ function backgroundKindFor(category) {
|
|
|
29461
30061
|
case "workflow":
|
|
29462
30062
|
return "other";
|
|
29463
30063
|
case "manage-subagents":
|
|
30064
|
+
case "manage-task":
|
|
30065
|
+
case "swarm":
|
|
29464
30066
|
case null:
|
|
29465
30067
|
return null;
|
|
29466
30068
|
}
|
|
@@ -29492,6 +30094,8 @@ function isWakeupChunkUpdateKind(updateKind) {
|
|
|
29492
30094
|
var AntigravityBackgroundWakeup = class {
|
|
29493
30095
|
#emitMetaUpdate;
|
|
29494
30096
|
#launchEnvironment;
|
|
30097
|
+
#onOpenPromptTimeout;
|
|
30098
|
+
#onOrphanShellPromptSettle;
|
|
29495
30099
|
#timer;
|
|
29496
30100
|
#sessions = /* @__PURE__ */ new Map();
|
|
29497
30101
|
#pendingRequests = /* @__PURE__ */ new Map();
|
|
@@ -29499,6 +30103,8 @@ var AntigravityBackgroundWakeup = class {
|
|
|
29499
30103
|
constructor(options) {
|
|
29500
30104
|
this.#emitMetaUpdate = options.emitMetaUpdate;
|
|
29501
30105
|
this.#launchEnvironment = options.launchEnvironment;
|
|
30106
|
+
this.#onOpenPromptTimeout = options.onOpenPromptTimeout;
|
|
30107
|
+
this.#onOrphanShellPromptSettle = options.onOrphanShellPromptSettle;
|
|
29502
30108
|
this.#timer = options.timer ?? systemTimer;
|
|
29503
30109
|
}
|
|
29504
30110
|
#ensureSession = (sessionId) => {
|
|
@@ -29519,6 +30125,7 @@ var AntigravityBackgroundWakeup = class {
|
|
|
29519
30125
|
backgroundTasks: /* @__PURE__ */ new Map(),
|
|
29520
30126
|
baselineStepIndex: -1,
|
|
29521
30127
|
lastEmittedBackgroundKey: "[]",
|
|
30128
|
+
openNonShellToolIds: /* @__PURE__ */ new Set(),
|
|
29522
30129
|
phase: { cancelRequested: false, kind: "idle" },
|
|
29523
30130
|
sessionOpenStepIndex: -1,
|
|
29524
30131
|
subagents: {
|
|
@@ -29534,11 +30141,362 @@ var AntigravityBackgroundWakeup = class {
|
|
|
29534
30141
|
wakeupOwedToolCallIds: /* @__PURE__ */ new Set(),
|
|
29535
30142
|
wakeupSettledStepIndex: null,
|
|
29536
30143
|
wakeupStageSeq: 0,
|
|
29537
|
-
wakeupStreamedMessageText: ""
|
|
30144
|
+
wakeupStreamedMessageText: "",
|
|
30145
|
+
watchdog: null,
|
|
30146
|
+
watchdogSeq: 0
|
|
29538
30147
|
};
|
|
29539
30148
|
this.#sessions.set(sessionId, created);
|
|
29540
30149
|
return created;
|
|
29541
30150
|
};
|
|
30151
|
+
#cancelWatchdog = (session) => {
|
|
30152
|
+
if (session.watchdog !== null) {
|
|
30153
|
+
session.watchdog.task.cancel();
|
|
30154
|
+
session.watchdog = null;
|
|
30155
|
+
}
|
|
30156
|
+
session.watchdogSeq += 1;
|
|
30157
|
+
};
|
|
30158
|
+
#isShellOnlyBackground = (session) => {
|
|
30159
|
+
if (session.backgroundTasks.size === 0) {
|
|
30160
|
+
return false;
|
|
30161
|
+
}
|
|
30162
|
+
for (const task of session.backgroundTasks.values()) {
|
|
30163
|
+
if (task.kind !== "shell" || task.state !== "running") {
|
|
30164
|
+
return false;
|
|
30165
|
+
}
|
|
30166
|
+
}
|
|
30167
|
+
return true;
|
|
30168
|
+
};
|
|
30169
|
+
#activeShellNativeTaskIds = (session) => {
|
|
30170
|
+
const ids = [];
|
|
30171
|
+
for (const [toolCallId, task] of session.backgroundTasks) {
|
|
30172
|
+
if (task.kind !== "shell") {
|
|
30173
|
+
continue;
|
|
30174
|
+
}
|
|
30175
|
+
const nativeTaskId = session.backgroundCorrelation.nativeTaskIdByToolCallId.get(toolCallId);
|
|
30176
|
+
if (nativeTaskId !== void 0) {
|
|
30177
|
+
ids.push(nativeTaskId);
|
|
30178
|
+
}
|
|
30179
|
+
}
|
|
30180
|
+
return ids;
|
|
30181
|
+
};
|
|
30182
|
+
#killBackgroundTaskByNativeId = (session, killTaskId) => {
|
|
30183
|
+
const mappedToolCallId = session.backgroundCorrelation.toolCallIdByNativeTaskId.get(killTaskId);
|
|
30184
|
+
if (mappedToolCallId !== void 0 && session.backgroundTasks.has(mappedToolCallId)) {
|
|
30185
|
+
this.#deleteBackgroundTask(session, mappedToolCallId);
|
|
30186
|
+
return true;
|
|
30187
|
+
}
|
|
30188
|
+
if (session.backgroundTasks.has(killTaskId)) {
|
|
30189
|
+
this.#deleteBackgroundTask(session, killTaskId);
|
|
30190
|
+
return true;
|
|
30191
|
+
}
|
|
30192
|
+
return false;
|
|
30193
|
+
};
|
|
30194
|
+
#reconcileStructuredArtifacts = async (sessionId, session, lastTranscriptStep, clearCompletedBackground) => {
|
|
30195
|
+
const geminiHome = resolveGeminiHome(this.#launchEnvironment);
|
|
30196
|
+
const snapshot = await readAntigravitySubagentSnapshot(geminiHome, sessionId);
|
|
30197
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session) {
|
|
30198
|
+
return false;
|
|
30199
|
+
}
|
|
30200
|
+
for (const [toolCallId, childId] of snapshot.conversationIdByToolCallId) {
|
|
30201
|
+
if (session.backgroundTasks.has(toolCallId)) {
|
|
30202
|
+
session.subagents.conversationIdByToolCallId.set(toolCallId, childId);
|
|
30203
|
+
const pendingIndex = session.subagents.pendingToolCallIds.indexOf(toolCallId);
|
|
30204
|
+
if (pendingIndex !== -1) {
|
|
30205
|
+
session.subagents.pendingToolCallIds.splice(pendingIndex, 1);
|
|
30206
|
+
}
|
|
30207
|
+
}
|
|
30208
|
+
}
|
|
30209
|
+
for (const nativeTaskId of snapshot.deliveredNativeTaskIds) {
|
|
30210
|
+
session.backgroundCorrelation.deliveredNativeTaskIds.add(nativeTaskId);
|
|
30211
|
+
}
|
|
30212
|
+
if (!clearCompletedBackground) {
|
|
30213
|
+
return true;
|
|
30214
|
+
}
|
|
30215
|
+
for (const [toolCallId, task] of [...session.backgroundTasks.entries()]) {
|
|
30216
|
+
if (task.kind === "subagent") {
|
|
30217
|
+
const childId = session.subagents.conversationIdByToolCallId.get(toolCallId);
|
|
30218
|
+
if (childId !== void 0 && snapshot.resolvedChildIds.has(childId)) {
|
|
30219
|
+
this.#deleteSubagentTask(session, toolCallId);
|
|
30220
|
+
}
|
|
30221
|
+
continue;
|
|
30222
|
+
}
|
|
30223
|
+
const nativeTaskId = session.backgroundCorrelation.nativeTaskIdByToolCallId.get(toolCallId);
|
|
30224
|
+
if (snapshot.deliveredToolCallIds.has(toolCallId) || nativeTaskId !== void 0 && snapshot.deliveredNativeTaskIds.has(nativeTaskId)) {
|
|
30225
|
+
this.#deleteBackgroundTask(session, toolCallId);
|
|
30226
|
+
}
|
|
30227
|
+
}
|
|
30228
|
+
if (snapshot.available && snapshot.activeChildIds.size === 0 && this.#hasSubagentTasks(session)) {
|
|
30229
|
+
const pendingReply = await readAntigravityPendingReply(geminiHome, sessionId, lastTranscriptStep);
|
|
30230
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session) {
|
|
30231
|
+
return false;
|
|
30232
|
+
}
|
|
30233
|
+
if (!pendingReply) {
|
|
30234
|
+
this.#deleteAllSubagentTasks(session);
|
|
30235
|
+
}
|
|
30236
|
+
}
|
|
30237
|
+
return true;
|
|
30238
|
+
};
|
|
30239
|
+
#inspectPostReplyShellState = async (sessionId, session) => {
|
|
30240
|
+
if (session.activeInteractions > 0 || session.openNonShellToolIds.size > 0 || !this.#isShellOnlyBackground(session)) {
|
|
30241
|
+
return { kind: "not-applicable" };
|
|
30242
|
+
}
|
|
30243
|
+
if (session.phase.kind === "client-prompt" && session.phase.cancelled) {
|
|
30244
|
+
return { kind: "not-applicable" };
|
|
30245
|
+
}
|
|
30246
|
+
if (session.phase.kind === "idle" && session.phase.cancelRequested) {
|
|
30247
|
+
return { kind: "not-applicable" };
|
|
30248
|
+
}
|
|
30249
|
+
if (session.phase.kind !== "client-prompt" && session.phase.kind !== "idle") {
|
|
30250
|
+
return { kind: "not-applicable" };
|
|
30251
|
+
}
|
|
30252
|
+
const prePromptStepIndex = session.phase.kind === "client-prompt" ? session.phase.prePromptStepIndex : session.baselineStepIndex;
|
|
30253
|
+
const tail = await readTranscriptTailState(this.#launchEnvironment, sessionId, prePromptStepIndex);
|
|
30254
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session) {
|
|
30255
|
+
return { kind: "not-applicable" };
|
|
30256
|
+
}
|
|
30257
|
+
if (tail !== null) {
|
|
30258
|
+
this.#syncBackgroundTaskCreations(sessionId, session, tail.steps);
|
|
30259
|
+
}
|
|
30260
|
+
if (session.phase.kind === "client-prompt") {
|
|
30261
|
+
if (tail === null || findTrailingSettledReply(tail.steps, session.phase.prePromptStepIndex) === null) {
|
|
30262
|
+
return { kind: "not-applicable" };
|
|
30263
|
+
}
|
|
30264
|
+
}
|
|
30265
|
+
const geminiHome = resolveGeminiHome(this.#launchEnvironment);
|
|
30266
|
+
const snapshot = await readAntigravitySubagentSnapshot(geminiHome, sessionId);
|
|
30267
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session || snapshot.activeChildIds.size > 0) {
|
|
30268
|
+
return { kind: "not-applicable" };
|
|
30269
|
+
}
|
|
30270
|
+
const pendingReply = await readAntigravityPendingReply(geminiHome, sessionId, tail?.steps.at(-1));
|
|
30271
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session || pendingReply) {
|
|
30272
|
+
return { kind: "not-applicable" };
|
|
30273
|
+
}
|
|
30274
|
+
const logSignature = await readAntigravityTaskLogSignature(
|
|
30275
|
+
geminiHome,
|
|
30276
|
+
sessionId,
|
|
30277
|
+
this.#activeShellNativeTaskIds(session)
|
|
30278
|
+
);
|
|
30279
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session) {
|
|
30280
|
+
return { kind: "not-applicable" };
|
|
30281
|
+
}
|
|
30282
|
+
return { kind: "shell-only-after-reply", logSignature };
|
|
30283
|
+
};
|
|
30284
|
+
#armClientPromptWatchdog = (sessionId, session) => {
|
|
30285
|
+
this.#cancelWatchdog(session);
|
|
30286
|
+
const epoch = session.watchdogSeq;
|
|
30287
|
+
const scheduleNext = () => this.#timer.schedule(() => {
|
|
30288
|
+
void this.#handleClientPromptWatchdogTick(sessionId, session, epoch);
|
|
30289
|
+
}, WATCHDOG_SLICE_MS);
|
|
30290
|
+
session.watchdog = {
|
|
30291
|
+
epoch,
|
|
30292
|
+
inactivitySlices: 0,
|
|
30293
|
+
kind: "client-prompt",
|
|
30294
|
+
lastLogSignature: null,
|
|
30295
|
+
sawAcpActivity: false,
|
|
30296
|
+
shellHoldSlices: 0,
|
|
30297
|
+
silentShellSlices: 0,
|
|
30298
|
+
task: scheduleNext()
|
|
30299
|
+
};
|
|
30300
|
+
};
|
|
30301
|
+
#syncIdleShellWatchdog = (sessionId, session) => {
|
|
30302
|
+
const shouldArm = session.phase.kind === "idle" && !session.phase.cancelRequested && session.activeInteractions === 0 && this.#isShellOnlyBackground(session);
|
|
30303
|
+
if (!shouldArm) {
|
|
30304
|
+
if (session.watchdog?.kind === "idle-shell") {
|
|
30305
|
+
this.#cancelWatchdog(session);
|
|
30306
|
+
}
|
|
30307
|
+
return;
|
|
30308
|
+
}
|
|
30309
|
+
if (session.watchdog?.kind === "idle-shell") {
|
|
30310
|
+
return;
|
|
30311
|
+
}
|
|
30312
|
+
this.#cancelWatchdog(session);
|
|
30313
|
+
const epoch = session.watchdogSeq;
|
|
30314
|
+
session.watchdog = {
|
|
30315
|
+
epoch,
|
|
30316
|
+
kind: "idle-shell",
|
|
30317
|
+
lastLogSignature: null,
|
|
30318
|
+
shellHoldSlices: 0,
|
|
30319
|
+
silentShellSlices: 0,
|
|
30320
|
+
task: this.#timer.schedule(() => {
|
|
30321
|
+
void this.#handleIdleShellWatchdogTick(sessionId, session, epoch);
|
|
30322
|
+
}, WATCHDOG_SLICE_MS)
|
|
30323
|
+
};
|
|
30324
|
+
};
|
|
30325
|
+
#handleClientPromptWatchdogTick = async (sessionId, session, epoch) => {
|
|
30326
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session) {
|
|
30327
|
+
return;
|
|
30328
|
+
}
|
|
30329
|
+
const handle = session.watchdog;
|
|
30330
|
+
if (handle === null || handle.kind !== "client-prompt" || handle.epoch !== epoch || session.phase.kind !== "client-prompt" || session.phase.cancelled) {
|
|
30331
|
+
return;
|
|
30332
|
+
}
|
|
30333
|
+
const reschedule = () => {
|
|
30334
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session || session.watchdog !== handle || handle.epoch !== epoch || session.phase.kind !== "client-prompt" || session.phase.cancelled) {
|
|
30335
|
+
return;
|
|
30336
|
+
}
|
|
30337
|
+
handle.task = this.#timer.schedule(() => {
|
|
30338
|
+
void this.#handleClientPromptWatchdogTick(sessionId, session, epoch);
|
|
30339
|
+
}, WATCHDOG_SLICE_MS);
|
|
30340
|
+
};
|
|
30341
|
+
const hadAcpActivity = handle.sawAcpActivity;
|
|
30342
|
+
handle.sawAcpActivity = false;
|
|
30343
|
+
if (session.activeInteractions > 0) {
|
|
30344
|
+
handle.inactivitySlices = 0;
|
|
30345
|
+
handle.silentShellSlices = 0;
|
|
30346
|
+
reschedule();
|
|
30347
|
+
return;
|
|
30348
|
+
}
|
|
30349
|
+
const shellState = await this.#inspectPostReplyShellState(sessionId, session);
|
|
30350
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session || session.watchdog !== handle || handle.epoch !== epoch || session.phase.kind !== "client-prompt" || session.phase.cancelled) {
|
|
30351
|
+
return;
|
|
30352
|
+
}
|
|
30353
|
+
if (shellState.kind === "shell-only-after-reply") {
|
|
30354
|
+
handle.inactivitySlices = 0;
|
|
30355
|
+
handle.shellHoldSlices += 1;
|
|
30356
|
+
const logChanged = handle.lastLogSignature !== null && shellState.logSignature !== handle.lastLogSignature;
|
|
30357
|
+
handle.lastLogSignature = shellState.logSignature;
|
|
30358
|
+
if (hadAcpActivity || logChanged) {
|
|
30359
|
+
handle.silentShellSlices = 0;
|
|
30360
|
+
} else {
|
|
30361
|
+
handle.silentShellSlices += 1;
|
|
30362
|
+
}
|
|
30363
|
+
if (handle.silentShellSlices >= ORPHAN_SHELL_SILENCE_SLICES || handle.shellHoldSlices >= ORPHAN_SHELL_MAX_HOLD_SLICES) {
|
|
30364
|
+
this.#cancelWatchdog(session);
|
|
30365
|
+
this.#onOrphanShellPromptSettle?.(sessionId);
|
|
30366
|
+
return;
|
|
30367
|
+
}
|
|
30368
|
+
reschedule();
|
|
30369
|
+
return;
|
|
30370
|
+
}
|
|
30371
|
+
handle.shellHoldSlices = 0;
|
|
30372
|
+
handle.silentShellSlices = 0;
|
|
30373
|
+
handle.lastLogSignature = null;
|
|
30374
|
+
if (!hadAcpActivity && session.openNonShellToolIds.size === 0 && session.backgroundTasks.size === 0 && session.activeInteractions === 0) {
|
|
30375
|
+
handle.inactivitySlices += 1;
|
|
30376
|
+
if (handle.inactivitySlices >= OPEN_PROMPT_INACTIVITY_SLICES) {
|
|
30377
|
+
const geminiHome = resolveGeminiHome(this.#launchEnvironment);
|
|
30378
|
+
const snapshot = await readAntigravitySubagentSnapshot(geminiHome, sessionId);
|
|
30379
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session || session.watchdog !== handle || handle.epoch !== epoch || session.phase.kind !== "client-prompt" || session.phase.cancelled) {
|
|
30380
|
+
return;
|
|
30381
|
+
}
|
|
30382
|
+
if (snapshot.activeChildIds.size > 0) {
|
|
30383
|
+
handle.inactivitySlices = 0;
|
|
30384
|
+
reschedule();
|
|
30385
|
+
return;
|
|
30386
|
+
}
|
|
30387
|
+
const prePromptStepIndex = session.phase.prePromptStepIndex;
|
|
30388
|
+
const tail = await readTranscriptTailState(this.#launchEnvironment, sessionId, prePromptStepIndex);
|
|
30389
|
+
const pendingReply = await readAntigravityPendingReply(geminiHome, sessionId, tail?.steps.at(-1));
|
|
30390
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session || session.watchdog !== handle || handle.epoch !== epoch || session.phase.kind !== "client-prompt" || session.phase.cancelled) {
|
|
30391
|
+
return;
|
|
30392
|
+
}
|
|
30393
|
+
if (tail !== null && findTrailingSettledReply(tail.steps, prePromptStepIndex) !== null && !pendingReply) {
|
|
30394
|
+
this.#cancelWatchdog(session);
|
|
30395
|
+
this.#onOpenPromptTimeout?.(sessionId, { kind: "settled" });
|
|
30396
|
+
return;
|
|
30397
|
+
}
|
|
30398
|
+
const recordedError = await readAntigravityConversationTerminalError(geminiHome, sessionId);
|
|
30399
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session || session.watchdog !== handle || handle.epoch !== epoch || session.phase.kind !== "client-prompt" || session.phase.cancelled) {
|
|
30400
|
+
return;
|
|
30401
|
+
}
|
|
30402
|
+
this.#cancelWatchdog(session);
|
|
30403
|
+
this.#onOpenPromptTimeout?.(sessionId, {
|
|
30404
|
+
kind: "failed",
|
|
30405
|
+
message: recordedError ?? "Antigravity stopped responding during the turn"
|
|
30406
|
+
});
|
|
30407
|
+
return;
|
|
30408
|
+
}
|
|
30409
|
+
} else {
|
|
30410
|
+
handle.inactivitySlices = 0;
|
|
30411
|
+
}
|
|
30412
|
+
reschedule();
|
|
30413
|
+
};
|
|
30414
|
+
#handleIdleShellWatchdogTick = async (sessionId, session, epoch) => {
|
|
30415
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session) {
|
|
30416
|
+
return;
|
|
30417
|
+
}
|
|
30418
|
+
const handle = session.watchdog;
|
|
30419
|
+
if (handle === null || handle.kind !== "idle-shell" || handle.epoch !== epoch || session.phase.kind !== "idle" || session.phase.cancelRequested) {
|
|
30420
|
+
return;
|
|
30421
|
+
}
|
|
30422
|
+
const reschedule = () => {
|
|
30423
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session || session.watchdog !== handle || handle.epoch !== epoch || session.phase.kind !== "idle" || session.phase.cancelRequested) {
|
|
30424
|
+
return;
|
|
30425
|
+
}
|
|
30426
|
+
handle.task = this.#timer.schedule(() => {
|
|
30427
|
+
void this.#handleIdleShellWatchdogTick(sessionId, session, epoch);
|
|
30428
|
+
}, WATCHDOG_SLICE_MS);
|
|
30429
|
+
};
|
|
30430
|
+
const shellState = await this.#inspectPostReplyShellState(sessionId, session);
|
|
30431
|
+
if (this.#disposed || this.#sessions.get(sessionId) !== session || session.watchdog !== handle || handle.epoch !== epoch || session.phase.kind !== "idle" || session.phase.cancelRequested) {
|
|
30432
|
+
return;
|
|
30433
|
+
}
|
|
30434
|
+
if (shellState.kind !== "shell-only-after-reply") {
|
|
30435
|
+
handle.silentShellSlices = 0;
|
|
30436
|
+
reschedule();
|
|
30437
|
+
return;
|
|
30438
|
+
}
|
|
30439
|
+
handle.shellHoldSlices += 1;
|
|
30440
|
+
const logChanged = handle.lastLogSignature !== null && shellState.logSignature !== handle.lastLogSignature;
|
|
30441
|
+
handle.lastLogSignature = shellState.logSignature;
|
|
30442
|
+
if (logChanged) {
|
|
30443
|
+
handle.silentShellSlices = 0;
|
|
30444
|
+
} else {
|
|
30445
|
+
handle.silentShellSlices += 1;
|
|
30446
|
+
}
|
|
30447
|
+
if (handle.silentShellSlices >= ORPHAN_SHELL_SILENCE_SLICES || handle.shellHoldSlices >= ORPHAN_SHELL_MAX_HOLD_SLICES) {
|
|
30448
|
+
this.#cancelWatchdog(session);
|
|
30449
|
+
for (const [toolCallId, task] of [...session.backgroundTasks.entries()]) {
|
|
30450
|
+
if (task.kind === "shell") {
|
|
30451
|
+
this.#deleteBackgroundTask(session, toolCallId);
|
|
30452
|
+
}
|
|
30453
|
+
}
|
|
30454
|
+
const bg2 = this.#takeBackgroundTasksUpdate(sessionId, session);
|
|
30455
|
+
if (bg2 !== null) {
|
|
30456
|
+
this.#emitMetaUpdate(bg2);
|
|
30457
|
+
}
|
|
30458
|
+
return;
|
|
30459
|
+
}
|
|
30460
|
+
reschedule();
|
|
30461
|
+
};
|
|
30462
|
+
/**
|
|
30463
|
+
* Whether `sessionId` currently has an open client prompt whose final reply is already settled
|
|
30464
|
+
* in the native transcript and is only kept open by non-daemon background shell command(s).
|
|
30465
|
+
*/
|
|
30466
|
+
isReplyDoneWithOnlyShellTasks = async (sessionId) => {
|
|
30467
|
+
if (this.#disposed) {
|
|
30468
|
+
return false;
|
|
30469
|
+
}
|
|
30470
|
+
const session = this.#sessions.get(sessionId);
|
|
30471
|
+
if (session === void 0 || session.phase.kind !== "client-prompt" || session.phase.cancelled) {
|
|
30472
|
+
return false;
|
|
30473
|
+
}
|
|
30474
|
+
return (await this.#inspectPostReplyShellState(sessionId, session)).kind === "shell-only-after-reply";
|
|
30475
|
+
};
|
|
30476
|
+
/**
|
|
30477
|
+
* Transitions a client prompt that the proxy settled directly back to idle and clears its
|
|
30478
|
+
* background tasks before the proxy answers the client's `session/prompt` request.
|
|
30479
|
+
*/
|
|
30480
|
+
completeClientPromptByProxy = (sessionId) => {
|
|
30481
|
+
if (this.#disposed) {
|
|
30482
|
+
return null;
|
|
30483
|
+
}
|
|
30484
|
+
const session = this.#sessions.get(sessionId);
|
|
30485
|
+
if (session === void 0) {
|
|
30486
|
+
return null;
|
|
30487
|
+
}
|
|
30488
|
+
for (const [key, pending] of [...this.#pendingRequests.entries()]) {
|
|
30489
|
+
if (pending.sessionId === sessionId && pending.kind === "prompt") {
|
|
30490
|
+
this.#pendingRequests.delete(key);
|
|
30491
|
+
}
|
|
30492
|
+
}
|
|
30493
|
+
this.#cancelWatchdog(session);
|
|
30494
|
+
this.#cancelWakeupTimers(session.phase);
|
|
30495
|
+
session.openNonShellToolIds.clear();
|
|
30496
|
+
this.#clearAllBackgroundTasks(session);
|
|
30497
|
+
session.phase = { cancelRequested: false, kind: "idle" };
|
|
30498
|
+
return this.#takeBackgroundTasksUpdate(sessionId, session);
|
|
30499
|
+
};
|
|
29542
30500
|
#cancelWakeupTimers = (phase) => {
|
|
29543
30501
|
if (phase.kind !== "wakeup") {
|
|
29544
30502
|
return;
|
|
@@ -29951,6 +30909,7 @@ var AntigravityBackgroundWakeup = class {
|
|
|
29951
30909
|
};
|
|
29952
30910
|
};
|
|
29953
30911
|
#enterWakeup = (sessionId, session, taskIds) => {
|
|
30912
|
+
this.#cancelWatchdog(session);
|
|
29954
30913
|
const notifications = [];
|
|
29955
30914
|
const bgNotification = this.#takeBackgroundTasksUpdate(sessionId, session);
|
|
29956
30915
|
if (bgNotification !== null) {
|
|
@@ -29989,6 +30948,7 @@ var AntigravityBackgroundWakeup = class {
|
|
|
29989
30948
|
session.wakeupDeferredSettledStep = null;
|
|
29990
30949
|
session.wakeupStreamedMessageText = "";
|
|
29991
30950
|
this.#dropAwaitingResultTasks(session);
|
|
30951
|
+
this.#syncIdleShellWatchdog(sessionId, session);
|
|
29992
30952
|
const notifications = [];
|
|
29993
30953
|
const bgNotification = this.#takeBackgroundTasksUpdate(sessionId, session);
|
|
29994
30954
|
if (bgNotification !== null) {
|
|
@@ -30013,6 +30973,7 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30013
30973
|
session.wakeupDeferredSettledStep = null;
|
|
30014
30974
|
session.wakeupStreamedMessageText = "";
|
|
30015
30975
|
this.#dropAwaitingResultTasks(session);
|
|
30976
|
+
this.#syncIdleShellWatchdog(sessionId, session);
|
|
30016
30977
|
const notifications = [];
|
|
30017
30978
|
const bgNotification = this.#takeBackgroundTasksUpdate(sessionId, session);
|
|
30018
30979
|
if (bgNotification !== null) {
|
|
@@ -30136,6 +31097,17 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30136
31097
|
this.#consumeSubagentIdlesThrough(current, widerTail.steps, tail.settledStep.stepIndex);
|
|
30137
31098
|
}
|
|
30138
31099
|
}
|
|
31100
|
+
if (this.#hasSubagentTasks(current)) {
|
|
31101
|
+
const stillActive = await this.#reconcileStructuredArtifacts(
|
|
31102
|
+
sessionId,
|
|
31103
|
+
current,
|
|
31104
|
+
tail.steps.at(-1),
|
|
31105
|
+
true
|
|
31106
|
+
);
|
|
31107
|
+
if (!stillActive || current.phase.kind !== "wakeup" || current.phase.generation !== generation || current.phase.stage.stageEpoch !== stageEpoch || current.phase.stage.kind !== "streaming" && current.phase.stage.kind !== "awaiting-output") {
|
|
31108
|
+
return;
|
|
31109
|
+
}
|
|
31110
|
+
}
|
|
30139
31111
|
this.#consumeSettledReplyText(current, tail.settledStep);
|
|
30140
31112
|
if (this.#settleWakeupReply(sessionId, current, tail, tail.settledStep.stepIndex)) {
|
|
30141
31113
|
this.#emitNotifications(this.#finishWakeup(sessionId, current, "end_turn", false));
|
|
@@ -30321,13 +31293,35 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30321
31293
|
const meta3 = inspectToolMetadata(update, session.toolMetadata.get(toolCallId));
|
|
30322
31294
|
session.toolMetadata.set(toolCallId, meta3);
|
|
30323
31295
|
if (meta3.isDaemon) {
|
|
31296
|
+
session.openNonShellToolIds.delete(toolCallId);
|
|
30324
31297
|
this.#deleteBackgroundTask(session, toolCallId);
|
|
30325
31298
|
return;
|
|
30326
31299
|
}
|
|
31300
|
+
const isShellTool = meta3.category === "command";
|
|
31301
|
+
if (!isShellTool) {
|
|
31302
|
+
if (status === "in_progress" || status === "pending") {
|
|
31303
|
+
session.openNonShellToolIds.add(toolCallId);
|
|
31304
|
+
} else if (status === "completed" || status === "failed" || status === "cancelled") {
|
|
31305
|
+
session.openNonShellToolIds.delete(toolCallId);
|
|
31306
|
+
}
|
|
31307
|
+
}
|
|
30327
31308
|
if (meta3.category === "manage-subagents" && status === "completed") {
|
|
30328
31309
|
await this.#killSubagentsByMetadata(sessionId, session, meta3);
|
|
30329
31310
|
return;
|
|
30330
31311
|
}
|
|
31312
|
+
if (meta3.category === "manage-task" && status === "completed" && meta3.killTaskId !== void 0) {
|
|
31313
|
+
this.#killBackgroundTaskByNativeId(session, meta3.killTaskId);
|
|
31314
|
+
return;
|
|
31315
|
+
}
|
|
31316
|
+
if (meta3.category === "swarm") {
|
|
31317
|
+
if (!cancelled && meta3.swarmAction === "add" && status === "completed") {
|
|
31318
|
+
this.#registerSubagentTask(session, toolCallId, meta3.description);
|
|
31319
|
+
await this.#reconcileStructuredArtifacts(sessionId, session, void 0, false);
|
|
31320
|
+
} else if (meta3.swarmAction === "kill" && status === "completed") {
|
|
31321
|
+
await this.#reconcileStructuredArtifacts(sessionId, session, void 0, true);
|
|
31322
|
+
}
|
|
31323
|
+
return;
|
|
31324
|
+
}
|
|
30331
31325
|
if (meta3.category === "subagent") {
|
|
30332
31326
|
if (!cancelled && status === "completed") {
|
|
30333
31327
|
this.#registerSubagentTask(session, toolCallId, meta3.description);
|
|
@@ -30457,6 +31451,34 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30457
31451
|
if (bg2 !== null) {
|
|
30458
31452
|
notifications.push(bg2);
|
|
30459
31453
|
}
|
|
31454
|
+
} else if (meta3.category === "manage-task" && status === "completed" && meta3.killTaskId !== void 0) {
|
|
31455
|
+
if (this.#killBackgroundTaskByNativeId(session, meta3.killTaskId)) {
|
|
31456
|
+
const bg2 = this.#takeBackgroundTasksUpdate(sessionId, session);
|
|
31457
|
+
if (bg2 !== null) {
|
|
31458
|
+
notifications.push(bg2);
|
|
31459
|
+
}
|
|
31460
|
+
}
|
|
31461
|
+
} else if (meta3.category === "swarm" && status === "completed") {
|
|
31462
|
+
if (meta3.swarmAction === "add") {
|
|
31463
|
+
this.#registerSubagentTask(session, toolCallId, meta3.description);
|
|
31464
|
+
const active = await this.#reconcileStructuredArtifacts(sessionId, session, void 0, false);
|
|
31465
|
+
if (!active) {
|
|
31466
|
+
return;
|
|
31467
|
+
}
|
|
31468
|
+
const bg2 = this.#takeBackgroundTasksUpdate(sessionId, session);
|
|
31469
|
+
if (bg2 !== null) {
|
|
31470
|
+
notifications.push(bg2);
|
|
31471
|
+
}
|
|
31472
|
+
} else if (meta3.swarmAction === "kill") {
|
|
31473
|
+
const active = await this.#reconcileStructuredArtifacts(sessionId, session, void 0, true);
|
|
31474
|
+
if (!active) {
|
|
31475
|
+
return;
|
|
31476
|
+
}
|
|
31477
|
+
const bg2 = this.#takeBackgroundTasksUpdate(sessionId, session);
|
|
31478
|
+
if (bg2 !== null) {
|
|
31479
|
+
notifications.push(bg2);
|
|
31480
|
+
}
|
|
31481
|
+
}
|
|
30460
31482
|
}
|
|
30461
31483
|
this.#pauseOrResumeWakeupTimers(sessionId, session);
|
|
30462
31484
|
}
|
|
@@ -30474,7 +31496,9 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30474
31496
|
return;
|
|
30475
31497
|
}
|
|
30476
31498
|
const session = this.#ensureSession(sessionId);
|
|
31499
|
+
this.#cancelWatchdog(session);
|
|
30477
31500
|
this.#cancelWakeupTimers(session.phase);
|
|
31501
|
+
session.openNonShellToolIds.clear();
|
|
30478
31502
|
session.phase = { kind: "loading", requestKey: key };
|
|
30479
31503
|
if (key !== void 0) {
|
|
30480
31504
|
this.#pendingRequests.set(key, { kind: "load", sessionId });
|
|
@@ -30493,6 +31517,8 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30493
31517
|
return;
|
|
30494
31518
|
}
|
|
30495
31519
|
const session = this.#ensureSession(sessionId);
|
|
31520
|
+
this.#cancelWatchdog(session);
|
|
31521
|
+
session.openNonShellToolIds.clear();
|
|
30496
31522
|
if (session.phase.kind === "wakeup") {
|
|
30497
31523
|
this.#emitNotifications(this.#finishWakeup(sessionId, session, "end_turn", false));
|
|
30498
31524
|
}
|
|
@@ -30509,6 +31535,7 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30509
31535
|
prePromptStepIndex,
|
|
30510
31536
|
requestKey: key
|
|
30511
31537
|
};
|
|
31538
|
+
this.#armClientPromptWatchdog(sessionId, session);
|
|
30512
31539
|
if (key !== void 0) {
|
|
30513
31540
|
this.#pendingRequests.set(key, { kind: "prompt", sessionId });
|
|
30514
31541
|
}
|
|
@@ -30599,10 +31626,17 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30599
31626
|
}
|
|
30600
31627
|
}
|
|
30601
31628
|
}
|
|
31629
|
+
this.#cancelWatchdog(session2);
|
|
31630
|
+
session2.openNonShellToolIds.clear();
|
|
31631
|
+
if (!promptCancelled && session2.backgroundTasks.size > 0) {
|
|
31632
|
+
await this.#reconcileStructuredArtifacts(tracked.sessionId, session2, tail?.steps.at(-1), true);
|
|
31633
|
+
promptCancelled = this.#disposed || session2.phase.kind === "client-prompt" && session2.phase.cancelled || session2.phase.kind === "idle" && session2.phase.cancelRequested || responseStopReason === "cancelled";
|
|
31634
|
+
}
|
|
30602
31635
|
if (promptCancelled) {
|
|
30603
31636
|
this.#clearAllBackgroundTasks(session2);
|
|
30604
31637
|
}
|
|
30605
31638
|
session2.phase = { cancelRequested: promptCancelled, kind: "idle" };
|
|
31639
|
+
this.#syncIdleShellWatchdog(tracked.sessionId, session2);
|
|
30606
31640
|
const bg2 = this.#takeBackgroundTasksUpdate(tracked.sessionId, session2);
|
|
30607
31641
|
const rewritePromptCancelled = promptCancelled && "result" in message && isRecord5(message.result) && responseStopReason !== "cancelled";
|
|
30608
31642
|
const beforeUpdates = bg2 === null ? [] : [bg2];
|
|
@@ -30633,6 +31667,9 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30633
31667
|
case "loading":
|
|
30634
31668
|
return EMPTY_INCOMING_OUTCOME;
|
|
30635
31669
|
case "client-prompt": {
|
|
31670
|
+
if (session.watchdog?.kind === "client-prompt") {
|
|
31671
|
+
session.watchdog.sawAcpActivity = true;
|
|
31672
|
+
}
|
|
30636
31673
|
if (updateKind === "tool_call" || updateKind === "tool_call_update") {
|
|
30637
31674
|
await this.#applyClientPromptToolUpdate(sessionId, session, update, session.phase.cancelled);
|
|
30638
31675
|
}
|
|
@@ -30651,6 +31688,7 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30651
31688
|
} else {
|
|
30652
31689
|
this.#deleteBackgroundTask(session, toolCallId);
|
|
30653
31690
|
}
|
|
31691
|
+
this.#syncIdleShellWatchdog(sessionId, session);
|
|
30654
31692
|
const bg2 = this.#takeBackgroundTasksUpdate(sessionId, session);
|
|
30655
31693
|
return bg2 === null ? EMPTY_INCOMING_OUTCOME : { afterUpdates: [bg2], beforeUpdates: [] };
|
|
30656
31694
|
}
|
|
@@ -30661,6 +31699,7 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30661
31699
|
} else {
|
|
30662
31700
|
this.#deleteBackgroundTask(session, toolCallId);
|
|
30663
31701
|
}
|
|
31702
|
+
this.#syncIdleShellWatchdog(sessionId, session);
|
|
30664
31703
|
const bg2 = this.#takeBackgroundTasksUpdate(sessionId, session);
|
|
30665
31704
|
return bg2 === null ? EMPTY_INCOMING_OUTCOME : { afterUpdates: [bg2], beforeUpdates: [] };
|
|
30666
31705
|
}
|
|
@@ -30752,6 +31791,20 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30752
31791
|
executorError
|
|
30753
31792
|
);
|
|
30754
31793
|
}
|
|
31794
|
+
return;
|
|
31795
|
+
}
|
|
31796
|
+
if (updateKind === "usage_update" && session.phase.openToolIds.size === 0 && session.activeInteractions === 0 && (session.phase.stage.kind === "streaming" || session.phase.stage.kind === "awaiting-output")) {
|
|
31797
|
+
session.phase.stage.transcriptCheck.cancel();
|
|
31798
|
+
const nextCheck = this.#scheduleTranscriptPoll(
|
|
31799
|
+
sessionId,
|
|
31800
|
+
session.phase.generation,
|
|
31801
|
+
session.phase.stage.stageEpoch,
|
|
31802
|
+
TRANSCRIPT_INITIAL_DELAY_MS
|
|
31803
|
+
);
|
|
31804
|
+
session.phase = {
|
|
31805
|
+
...session.phase,
|
|
31806
|
+
stage: { ...session.phase.stage, transcriptCheck: nextCheck }
|
|
31807
|
+
};
|
|
30755
31808
|
}
|
|
30756
31809
|
};
|
|
30757
31810
|
beginInteraction = (sessionId) => {
|
|
@@ -30760,6 +31813,9 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30760
31813
|
}
|
|
30761
31814
|
const session = this.#ensureSession(sessionId);
|
|
30762
31815
|
session.activeInteractions += 1;
|
|
31816
|
+
if (session.watchdog?.kind === "idle-shell") {
|
|
31817
|
+
this.#cancelWatchdog(session);
|
|
31818
|
+
}
|
|
30763
31819
|
this.#pauseOrResumeWakeupTimers(sessionId, session);
|
|
30764
31820
|
};
|
|
30765
31821
|
endInteraction = (sessionId) => {
|
|
@@ -30771,6 +31827,7 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30771
31827
|
return;
|
|
30772
31828
|
}
|
|
30773
31829
|
session.activeInteractions = Math.max(0, session.activeInteractions - 1);
|
|
31830
|
+
this.#syncIdleShellWatchdog(sessionId, session);
|
|
30774
31831
|
this.#pauseOrResumeWakeupTimers(sessionId, session);
|
|
30775
31832
|
};
|
|
30776
31833
|
cancelSession = (sessionId) => {
|
|
@@ -30778,6 +31835,7 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30778
31835
|
return "retain";
|
|
30779
31836
|
}
|
|
30780
31837
|
const session = this.#ensureSession(sessionId);
|
|
31838
|
+
this.#cancelWatchdog(session);
|
|
30781
31839
|
const mustClose = session.phase.kind === "wakeup" || this.#hasSubagentTasks(session);
|
|
30782
31840
|
if (mustClose) {
|
|
30783
31841
|
this.#cancelWakeupTimers(session.phase);
|
|
@@ -30798,6 +31856,7 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30798
31856
|
}
|
|
30799
31857
|
for (const [sessionId, session] of this.#sessions) {
|
|
30800
31858
|
const wasWakeup = session.phase.kind === "wakeup";
|
|
31859
|
+
this.#cancelWatchdog(session);
|
|
30801
31860
|
this.#cancelWakeupTimers(session.phase);
|
|
30802
31861
|
this.#clearAllBackgroundTasks(session);
|
|
30803
31862
|
if (wasWakeup) {
|
|
@@ -30823,6 +31882,7 @@ var AntigravityBackgroundWakeup = class {
|
|
|
30823
31882
|
}
|
|
30824
31883
|
this.#disposed = true;
|
|
30825
31884
|
for (const session of this.#sessions.values()) {
|
|
31885
|
+
this.#cancelWatchdog(session);
|
|
30826
31886
|
this.#cancelWakeupTimers(session.phase);
|
|
30827
31887
|
}
|
|
30828
31888
|
this.#sessions.clear();
|
|
@@ -30990,6 +32050,12 @@ async function prepareAntigravitySessionCancel(clientConnection2, sessionId) {
|
|
|
30990
32050
|
function takeAntigravityUnusableNativeSession(clientConnection2, sessionId) {
|
|
30991
32051
|
return activeConnectionsByClient.get(clientConnection2)?.takeUnusableNativeSession(sessionId) ?? false;
|
|
30992
32052
|
}
|
|
32053
|
+
function takeAntigravityProcessRecycleRequired(clientConnection2, sessionId) {
|
|
32054
|
+
return activeConnectionsByClient.get(clientConnection2)?.takeProcessRecycleRequired(sessionId) ?? false;
|
|
32055
|
+
}
|
|
32056
|
+
async function trySettleAntigravityIdlePrompt(clientConnection2, sessionId) {
|
|
32057
|
+
return await activeConnectionsByClient.get(clientConnection2)?.trySettleIdlePrompt(sessionId) ?? false;
|
|
32058
|
+
}
|
|
30993
32059
|
var AntigravityAgentConnection = class {
|
|
30994
32060
|
connection;
|
|
30995
32061
|
termination;
|
|
@@ -31005,6 +32071,10 @@ var AntigravityAgentConnection = class {
|
|
|
31005
32071
|
#pendingConfigEchoes = [];
|
|
31006
32072
|
/** Native sessions whose current prompt reported an unusable conversation. */
|
|
31007
32073
|
#unusableSessions = /* @__PURE__ */ new Set();
|
|
32074
|
+
/** Native sessions whose open prompt was settled by the proxy and whose child process must be recycled. */
|
|
32075
|
+
#recycleRequiredSessions = /* @__PURE__ */ new Set();
|
|
32076
|
+
/** Native sessions whose wedged prompt was settled by the proxy; drop late updates before teardown. */
|
|
32077
|
+
#proxySettledSessions = /* @__PURE__ */ new Set();
|
|
31008
32078
|
/** The client prompt each native session runs, while it runs. */
|
|
31009
32079
|
#runningPrompts = /* @__PURE__ */ new Map();
|
|
31010
32080
|
/** Every prompt sent to Antigravity whose answer has not arrived, by request id. */
|
|
@@ -31026,6 +32096,12 @@ var AntigravityAgentConnection = class {
|
|
|
31026
32096
|
this.#queueMetaUpdate(notification);
|
|
31027
32097
|
},
|
|
31028
32098
|
launchEnvironment,
|
|
32099
|
+
onOpenPromptTimeout: (sessionId, outcome) => {
|
|
32100
|
+
void this.#settlePromptByProxy(sessionId, outcome);
|
|
32101
|
+
},
|
|
32102
|
+
onOrphanShellPromptSettle: (sessionId) => {
|
|
32103
|
+
void this.#settlePromptByProxy(sessionId, { kind: "settled" });
|
|
32104
|
+
},
|
|
31029
32105
|
...options.timer === void 0 ? {} : { timer: options.timer }
|
|
31030
32106
|
});
|
|
31031
32107
|
const launch = executableLaunch2(options.command, ["acp"]);
|
|
@@ -31185,6 +32261,62 @@ var AntigravityAgentConnection = class {
|
|
|
31185
32261
|
return disposition;
|
|
31186
32262
|
};
|
|
31187
32263
|
takeUnusableNativeSession = (sessionId) => this.#unusableSessions.delete(sessionId);
|
|
32264
|
+
takeProcessRecycleRequired = (sessionId) => this.#recycleRequiredSessions.delete(sessionId);
|
|
32265
|
+
#settlePromptByProxy = async (sessionId, outcome) => {
|
|
32266
|
+
if (this.#closePromise !== null || this.#deliveryAbort.signal.aborted) {
|
|
32267
|
+
return false;
|
|
32268
|
+
}
|
|
32269
|
+
const running = this.#runningPrompts.get(sessionId);
|
|
32270
|
+
if (running === void 0 || running.cancelled) {
|
|
32271
|
+
return false;
|
|
32272
|
+
}
|
|
32273
|
+
this.#runningPrompts.delete(sessionId);
|
|
32274
|
+
this.#promptsByKey.delete(running.clientKey);
|
|
32275
|
+
this.#promptsByKey.delete(running.currentKey);
|
|
32276
|
+
if (running.pendingSteer !== void 0) {
|
|
32277
|
+
this.#promptsByKey.delete(running.pendingSteer.key);
|
|
32278
|
+
running.pendingSteer.settle(false);
|
|
32279
|
+
running.pendingSteer = void 0;
|
|
32280
|
+
}
|
|
32281
|
+
this.#proxySettledSessions.add(sessionId);
|
|
32282
|
+
this.#recycleRequiredSessions.add(sessionId);
|
|
32283
|
+
const bg2 = this.#backgroundWakeup.completeClientPromptByProxy(sessionId);
|
|
32284
|
+
if (bg2 !== null) {
|
|
32285
|
+
this.#queueMetaUpdate(bg2);
|
|
32286
|
+
}
|
|
32287
|
+
await this.#flushDeliveries();
|
|
32288
|
+
if (this.#closePromise !== null || this.#deliveryAbort.signal.aborted) {
|
|
32289
|
+
return false;
|
|
32290
|
+
}
|
|
32291
|
+
if (outcome.kind === "settled") {
|
|
32292
|
+
const usage = addUsage(running.supersededUsage, void 0);
|
|
32293
|
+
this.#answerClient?.({
|
|
32294
|
+
id: running.clientKey,
|
|
32295
|
+
jsonrpc: "2.0",
|
|
32296
|
+
result: { stopReason: "end_turn", ...usage === void 0 ? {} : { usage } }
|
|
32297
|
+
});
|
|
32298
|
+
return true;
|
|
32299
|
+
}
|
|
32300
|
+
this.#answerClient?.({
|
|
32301
|
+
error: { code: -32603, message: outcome.message },
|
|
32302
|
+
id: running.clientKey,
|
|
32303
|
+
jsonrpc: "2.0"
|
|
32304
|
+
});
|
|
32305
|
+
return true;
|
|
32306
|
+
};
|
|
32307
|
+
trySettleIdlePrompt = async (sessionId) => {
|
|
32308
|
+
if (this.#closePromise !== null || this.#deliveryAbort.signal.aborted) {
|
|
32309
|
+
return false;
|
|
32310
|
+
}
|
|
32311
|
+
const running = this.#runningPrompts.get(sessionId);
|
|
32312
|
+
if (running === void 0 || running.cancelled) {
|
|
32313
|
+
return false;
|
|
32314
|
+
}
|
|
32315
|
+
if (!await this.#backgroundWakeup.isReplyDoneWithOnlyShellTasks(sessionId)) {
|
|
32316
|
+
return false;
|
|
32317
|
+
}
|
|
32318
|
+
return await this.#settlePromptByProxy(sessionId, { kind: "settled" });
|
|
32319
|
+
};
|
|
31188
32320
|
initialize = async (signal) => {
|
|
31189
32321
|
signal.throwIfAborted();
|
|
31190
32322
|
};
|
|
@@ -31318,6 +32450,7 @@ var AntigravityAgentConnection = class {
|
|
|
31318
32450
|
if (sessionId !== void 0) {
|
|
31319
32451
|
this.#messageStreams.set(sessionId, { kind: "none" });
|
|
31320
32452
|
this.#unusableSessions.delete(sessionId);
|
|
32453
|
+
this.#proxySettledSessions.delete(sessionId);
|
|
31321
32454
|
if (key !== void 0) {
|
|
31322
32455
|
const prompt = {
|
|
31323
32456
|
cancelled: false,
|
|
@@ -31563,6 +32696,13 @@ var AntigravityAgentConnection = class {
|
|
|
31563
32696
|
try {
|
|
31564
32697
|
await previous;
|
|
31565
32698
|
await this.#flushDeliveries();
|
|
32699
|
+
if (joinable() === running && await this.#backgroundWakeup.isReplyDoneWithOnlyShellTasks(sessionId)) {
|
|
32700
|
+
if (joinable() === running) {
|
|
32701
|
+
await this.#settlePromptByProxy(sessionId, { kind: "settled" });
|
|
32702
|
+
}
|
|
32703
|
+
answer({ outcome: "promptRequired", reason: "noRunningTurn" });
|
|
32704
|
+
return;
|
|
32705
|
+
}
|
|
31566
32706
|
if (joinable() !== running) {
|
|
31567
32707
|
answer({ outcome: "promptRequired", reason: "noRunningTurn" });
|
|
31568
32708
|
return;
|
|
@@ -31611,6 +32751,12 @@ var AntigravityAgentConnection = class {
|
|
|
31611
32751
|
if (this.#closePromise !== null || this.#deliveryAbort.signal.aborted) {
|
|
31612
32752
|
return;
|
|
31613
32753
|
}
|
|
32754
|
+
if (this.#proxySettledSessions.size > 0 && isNotificationMessage3(chunk) && chunk.method === methods.client.session.update && isRecord5(chunk.params)) {
|
|
32755
|
+
const chunkSessionId = readStringProperty(chunk.params, "sessionId");
|
|
32756
|
+
if (chunkSessionId !== void 0 && this.#proxySettledSessions.has(chunkSessionId)) {
|
|
32757
|
+
return;
|
|
32758
|
+
}
|
|
32759
|
+
}
|
|
31614
32760
|
const routed = isResponseMessage3(chunk) ? this.#routePromptAnswer(chunk) : chunk;
|
|
31615
32761
|
if (routed === void 0) {
|
|
31616
32762
|
return;
|
|
@@ -81296,13 +82442,13 @@ var CodexAgentSpecification = class extends InProcessAcpAgentSpecification {
|
|
|
81296
82442
|
|
|
81297
82443
|
// src/engine/agent/specification/vendors/pi-agent.ts
|
|
81298
82444
|
import { createHash as createHash3 } from "node:crypto";
|
|
81299
|
-
import { join as
|
|
82445
|
+
import { join as join24 } from "node:path";
|
|
81300
82446
|
|
|
81301
82447
|
// src/engine/acp/harness/pi/upstream/dist/acp/agent.js
|
|
81302
82448
|
import { spawnSync } from "node:child_process";
|
|
81303
82449
|
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
81304
82450
|
import { existsSync as existsSync8, readdirSync as readdirSync6, readFileSync as readFileSync9, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
|
|
81305
|
-
import { basename as basename6, dirname as dirname8, isAbsolute as isAbsolute13, join as
|
|
82451
|
+
import { basename as basename6, dirname as dirname8, isAbsolute as isAbsolute13, join as join23 } from "node:path";
|
|
81306
82452
|
|
|
81307
82453
|
// src/engine/acp/harness/pi/upstream/dist/pi-rpc/process.js
|
|
81308
82454
|
import { spawn as spawn7 } from "node:child_process";
|
|
@@ -81758,7 +82904,7 @@ function maybeAuthRequiredError(err) {
|
|
|
81758
82904
|
}
|
|
81759
82905
|
|
|
81760
82906
|
// src/engine/acp/harness/pi/upstream/dist/acp/paths.js
|
|
81761
|
-
import { join as
|
|
82907
|
+
import { join as join19 } from "node:path";
|
|
81762
82908
|
|
|
81763
82909
|
// src/engine/acp/harness/pi/upstream/dist/acp/environment.js
|
|
81764
82910
|
import { homedir as homedir3 } from "node:os";
|
|
@@ -81768,10 +82914,10 @@ function environmentHome(environment) {
|
|
|
81768
82914
|
|
|
81769
82915
|
// src/engine/acp/harness/pi/upstream/dist/acp/paths.js
|
|
81770
82916
|
function getPiAcpDir(environment = process.env) {
|
|
81771
|
-
return
|
|
82917
|
+
return join19(environmentHome(environment), ".pi", "pi-acp");
|
|
81772
82918
|
}
|
|
81773
82919
|
function getPiAcpSessionMapPath(environment = process.env) {
|
|
81774
|
-
return
|
|
82920
|
+
return join19(getPiAcpDir(environment), "session-map.json");
|
|
81775
82921
|
}
|
|
81776
82922
|
|
|
81777
82923
|
// src/engine/acp/harness/pi/upstream/dist/acp/pi-commands.js
|
|
@@ -81893,15 +83039,15 @@ async function readPiLatestEntryId(sessionFile) {
|
|
|
81893
83039
|
|
|
81894
83040
|
// src/engine/acp/harness/pi/upstream/dist/acp/pi-sessions.js
|
|
81895
83041
|
import { closeSync as closeSync2, existsSync as existsSync5, openSync as openSync2, readdirSync as readdirSync4, readFileSync as readFileSync4, readSync as readSync2, statSync as statSync2 } from "node:fs";
|
|
81896
|
-
import { isAbsolute as isAbsolute11, join as
|
|
83042
|
+
import { isAbsolute as isAbsolute11, join as join20, resolve as resolve11 } from "node:path";
|
|
81897
83043
|
var DEFAULT_TAIL_BYTES = 256 * 1024;
|
|
81898
83044
|
var DEFAULT_HEAD_BYTES = 64 * 1024;
|
|
81899
83045
|
function getPiAgentDir(environment) {
|
|
81900
83046
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
81901
|
-
return configured ? resolve11(configured) :
|
|
83047
|
+
return configured ? resolve11(configured) : join20(environmentHome(environment), ".pi", "agent");
|
|
81902
83048
|
}
|
|
81903
83049
|
function readSessionDirFromSettings(agentDir) {
|
|
81904
|
-
const settingsPath =
|
|
83050
|
+
const settingsPath = join20(agentDir, "settings.json");
|
|
81905
83051
|
try {
|
|
81906
83052
|
if (!existsSync5(settingsPath)) {
|
|
81907
83053
|
return null;
|
|
@@ -81922,7 +83068,7 @@ function readSessionDirFromSettings(agentDir) {
|
|
|
81922
83068
|
}
|
|
81923
83069
|
function getPiSessionsDir(environment = process.env) {
|
|
81924
83070
|
const agentDir = getPiAgentDir(environment);
|
|
81925
|
-
return readSessionDirFromSettings(agentDir) ??
|
|
83071
|
+
return readSessionDirFromSettings(agentDir) ?? join20(agentDir, "sessions");
|
|
81926
83072
|
}
|
|
81927
83073
|
function getPiSessionDiscoveryDirs(environment) {
|
|
81928
83074
|
const discoveryDirectories = [getPiSessionsDir(environment)];
|
|
@@ -81933,7 +83079,7 @@ function getPiSessionDiscoveryDirs(environment) {
|
|
|
81933
83079
|
if (!entry.isDirectory()) {
|
|
81934
83080
|
continue;
|
|
81935
83081
|
}
|
|
81936
|
-
const directory =
|
|
83082
|
+
const directory = join20(mobiusSessionsRoot, entry.name);
|
|
81937
83083
|
if (!discoveryDirectories.includes(directory)) {
|
|
81938
83084
|
discoveryDirectories.push(directory);
|
|
81939
83085
|
}
|
|
@@ -81950,7 +83096,7 @@ function walkJsonlFiles(dir, out2) {
|
|
|
81950
83096
|
}
|
|
81951
83097
|
for (const e of entries) {
|
|
81952
83098
|
const name2 = typeof e.name === "string" ? e.name : String(e.name);
|
|
81953
|
-
const p =
|
|
83099
|
+
const p = join20(dir, name2);
|
|
81954
83100
|
if (e.isDirectory()) {
|
|
81955
83101
|
walkJsonlFiles(p, out2);
|
|
81956
83102
|
} else if (e.isFile() && name2.endsWith(".jsonl")) {
|
|
@@ -82219,7 +83365,7 @@ function findPiSession(sessionId, environment = process.env) {
|
|
|
82219
83365
|
|
|
82220
83366
|
// src/engine/acp/harness/pi/upstream/dist/acp/pi-settings.js
|
|
82221
83367
|
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
|
|
82222
|
-
import { join as
|
|
83368
|
+
import { join as join21, resolve as resolve12 } from "node:path";
|
|
82223
83369
|
function isObject2(x) {
|
|
82224
83370
|
return Boolean(x) && typeof x === "object" && !Array.isArray(x);
|
|
82225
83371
|
}
|
|
@@ -82248,7 +83394,7 @@ function readJsonFile2(path6) {
|
|
|
82248
83394
|
}
|
|
82249
83395
|
}
|
|
82250
83396
|
function getMergedSettings(cwd, environment) {
|
|
82251
|
-
const globalSettingsPath =
|
|
83397
|
+
const globalSettingsPath = join21(getAgentDir(environment), "settings.json");
|
|
82252
83398
|
const projectSettingsPath = resolve12(cwd, ".pi", "settings.json");
|
|
82253
83399
|
const global2 = readJsonFile2(globalSettingsPath);
|
|
82254
83400
|
const project = readJsonFile2(projectSettingsPath);
|
|
@@ -82256,7 +83402,7 @@ function getMergedSettings(cwd, environment) {
|
|
|
82256
83402
|
}
|
|
82257
83403
|
function getAgentDir(environment = process.env) {
|
|
82258
83404
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
82259
|
-
return configured ? resolve12(configured) :
|
|
83405
|
+
return configured ? resolve12(configured) : join21(environmentHome(environment), ".pi", "agent");
|
|
82260
83406
|
}
|
|
82261
83407
|
function getEnableSkillCommands(cwd, environment = process.env) {
|
|
82262
83408
|
const merged = getMergedSettings(cwd, environment);
|
|
@@ -82510,7 +83656,7 @@ var SessionStore = class {
|
|
|
82510
83656
|
|
|
82511
83657
|
// src/engine/acp/harness/pi/upstream/dist/acp/slash-commands.js
|
|
82512
83658
|
import { existsSync as existsSync7, readdirSync as readdirSync5, readFileSync as readFileSync7 } from "node:fs";
|
|
82513
|
-
import { join as
|
|
83659
|
+
import { join as join22, resolve as resolve13 } from "node:path";
|
|
82514
83660
|
function parseFrontmatter(content) {
|
|
82515
83661
|
const frontmatter = {};
|
|
82516
83662
|
if (!content.startsWith("---")) {
|
|
@@ -82538,7 +83684,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
82538
83684
|
try {
|
|
82539
83685
|
const entries = readdirSync5(dir, { withFileTypes: true });
|
|
82540
83686
|
for (const entry of entries) {
|
|
82541
|
-
const fullPath =
|
|
83687
|
+
const fullPath = join22(dir, entry.name);
|
|
82542
83688
|
if (entry.isDirectory()) {
|
|
82543
83689
|
const newSubdir = subdir ? `${subdir}:${entry.name}` : entry.name;
|
|
82544
83690
|
commands.push(...loadCommandsFromDir(fullPath, source, newSubdir));
|
|
@@ -82578,7 +83724,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
82578
83724
|
}
|
|
82579
83725
|
function loadSlashCommands(cwd, environment = process.env) {
|
|
82580
83726
|
const commands = [];
|
|
82581
|
-
const userDir =
|
|
83727
|
+
const userDir = join22(environmentHome(environment), ".pi", "agent", "prompts");
|
|
82582
83728
|
const projectDir = resolve13(cwd, ".pi", "prompts");
|
|
82583
83729
|
commands.push(...loadCommandsFromDir(userDir, "user"));
|
|
82584
83730
|
commands.push(...loadCommandsFromDir(projectDir, "project"));
|
|
@@ -84247,7 +85393,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
84247
85393
|
if (piPath) {
|
|
84248
85394
|
const resolved = realpathSync3(piPath);
|
|
84249
85395
|
const pkgRoot = dirname8(dirname8(resolved));
|
|
84250
|
-
const p =
|
|
85396
|
+
const p = join23(pkgRoot, "CHANGELOG.md");
|
|
84251
85397
|
if (existsSync8(p)) {
|
|
84252
85398
|
return p;
|
|
84253
85399
|
}
|
|
@@ -84258,7 +85404,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
84258
85404
|
const npmRoot = spawnSync("npm", ["root", "-g"], { encoding: "utf-8" });
|
|
84259
85405
|
const root = String(npmRoot.stdout ?? "").trim();
|
|
84260
85406
|
if (root) {
|
|
84261
|
-
const p =
|
|
85407
|
+
const p = join23(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
|
|
84262
85408
|
if (existsSync8(p)) {
|
|
84263
85409
|
return p;
|
|
84264
85410
|
}
|
|
@@ -84352,7 +85498,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
84352
85498
|
return { stopReason: "end_turn" };
|
|
84353
85499
|
}
|
|
84354
85500
|
const safeSessionId = session.sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
84355
|
-
const outputPath =
|
|
85501
|
+
const outputPath = join23(session.cwd, `pi-session-${safeSessionId}.html`);
|
|
84356
85502
|
let resultPath = "";
|
|
84357
85503
|
try {
|
|
84358
85504
|
const result2 = await session.proc.exportHtml(outputPath);
|
|
@@ -85089,7 +86235,7 @@ function buildStartupInfo(opts) {
|
|
|
85089
86235
|
md.push("");
|
|
85090
86236
|
};
|
|
85091
86237
|
const contextItems = [];
|
|
85092
|
-
const contextPath =
|
|
86238
|
+
const contextPath = join23(opts.cwd, "AGENTS.md");
|
|
85093
86239
|
if (existsSync8(contextPath)) {
|
|
85094
86240
|
contextItems.push(contextPath);
|
|
85095
86241
|
}
|
|
@@ -85098,7 +86244,7 @@ function buildStartupInfo(opts) {
|
|
|
85098
86244
|
const pushSkillFromRoot = (root) => {
|
|
85099
86245
|
try {
|
|
85100
86246
|
for (const e of readdirSync6(root)) {
|
|
85101
|
-
const p =
|
|
86247
|
+
const p = join23(root, e);
|
|
85102
86248
|
try {
|
|
85103
86249
|
const st2 = statSync3(p);
|
|
85104
86250
|
if (st2.isFile() && e.toLowerCase().endsWith(".md")) {
|
|
@@ -85123,7 +86269,7 @@ function buildStartupInfo(opts) {
|
|
|
85123
86269
|
if (name2 === "node_modules" || name2 === ".git") {
|
|
85124
86270
|
continue;
|
|
85125
86271
|
}
|
|
85126
|
-
const p =
|
|
86272
|
+
const p = join23(dir, name2);
|
|
85127
86273
|
let st2;
|
|
85128
86274
|
try {
|
|
85129
86275
|
st2 = statSync3(p);
|
|
@@ -85140,16 +86286,16 @@ function buildStartupInfo(opts) {
|
|
|
85140
86286
|
} catch {
|
|
85141
86287
|
}
|
|
85142
86288
|
};
|
|
85143
|
-
const globalSkillsDir =
|
|
86289
|
+
const globalSkillsDir = join23(getAgentDir(opts.environment), "skills");
|
|
85144
86290
|
pushSkillFromRoot(globalSkillsDir);
|
|
85145
86291
|
const home = opts.environment["HOME"] ?? opts.environment["USERPROFILE"] ?? "";
|
|
85146
|
-
const legacyAgentsSkillsDir =
|
|
86292
|
+
const legacyAgentsSkillsDir = join23(home, ".agents", "skills");
|
|
85147
86293
|
pushSkillFromRoot(legacyAgentsSkillsDir);
|
|
85148
|
-
const projectSkillsDir =
|
|
86294
|
+
const projectSkillsDir = join23(opts.cwd, ".pi", "skills");
|
|
85149
86295
|
pushSkillFromRoot(projectSkillsDir);
|
|
85150
86296
|
addSection("Skills", skillsItems);
|
|
85151
86297
|
const promptsItems = [];
|
|
85152
|
-
const promptsDir =
|
|
86298
|
+
const promptsDir = join23(home, ".pi", "agent", "prompts");
|
|
85153
86299
|
try {
|
|
85154
86300
|
const prompts = readdirSync6(promptsDir).filter((f) => f.endsWith(".md"));
|
|
85155
86301
|
for (const f of prompts) {
|
|
@@ -85159,17 +86305,17 @@ function buildStartupInfo(opts) {
|
|
|
85159
86305
|
}
|
|
85160
86306
|
addSection("Prompts", promptsItems);
|
|
85161
86307
|
const extItems = [];
|
|
85162
|
-
const extDir =
|
|
86308
|
+
const extDir = join23(home, ".pi", "agent", "extensions");
|
|
85163
86309
|
try {
|
|
85164
86310
|
const exts = readdirSync6(extDir).filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
|
|
85165
86311
|
for (const f of exts) {
|
|
85166
|
-
extItems.push(
|
|
86312
|
+
extItems.push(join23(extDir, f));
|
|
85167
86313
|
}
|
|
85168
86314
|
} catch {
|
|
85169
86315
|
}
|
|
85170
86316
|
const settingsPaths = [
|
|
85171
|
-
|
|
85172
|
-
|
|
86317
|
+
join23(getAgentDir(opts.environment), "settings.json"),
|
|
86318
|
+
join23(opts.cwd, ".pi", "settings.json")
|
|
85173
86319
|
];
|
|
85174
86320
|
for (const settingsPath of settingsPaths) {
|
|
85175
86321
|
try {
|
|
@@ -85360,7 +86506,7 @@ var PiAgentSpecification = class extends InProcessAcpAgentSpecification {
|
|
|
85360
86506
|
// keeps the adapter's opt-in capability flag enabled for every launch it owns.
|
|
85361
86507
|
createLaunchEnvironment = async (_agent, context) => {
|
|
85362
86508
|
const workspaceHash = createHash3("sha256").update(context.defaultWorkspace).digest("hex").slice(0, 24);
|
|
85363
|
-
const sessionDirectory =
|
|
86509
|
+
const sessionDirectory = join24(context.dataDirectory, "agents", "pi", "sessions", workspaceHash);
|
|
85364
86510
|
return Object.freeze({
|
|
85365
86511
|
PI_ACP_ENABLE_EMBEDDED_CONTEXT: "true",
|
|
85366
86512
|
MOBIUS_PI_SESSION_DIR: sessionDirectory
|
|
@@ -86077,7 +87223,7 @@ import { fetch as fetch2 } from "undici";
|
|
|
86077
87223
|
// src/engine/storage/antigravity-usage-credentials.ts
|
|
86078
87224
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
86079
87225
|
import { homedir as homedir4 } from "node:os";
|
|
86080
|
-
import { join as
|
|
87226
|
+
import { join as join25, resolve as resolve14 } from "node:path";
|
|
86081
87227
|
var agyOAuthTokenFileSchema = external_exports.object({
|
|
86082
87228
|
auth_method: external_exports.string().optional(),
|
|
86083
87229
|
id_token_email: external_exports.string().optional(),
|
|
@@ -86111,7 +87257,7 @@ function resolveGeminiHome2(environment) {
|
|
|
86111
87257
|
return resolve14(configured);
|
|
86112
87258
|
}
|
|
86113
87259
|
const home = environment["HOME"]?.trim() || environment["USERPROFILE"]?.trim() || homedir4();
|
|
86114
|
-
return
|
|
87260
|
+
return join25(resolve14(home), ".gemini");
|
|
86115
87261
|
}
|
|
86116
87262
|
function classifyAuthMethod(raw) {
|
|
86117
87263
|
const normalized = raw?.trim().toLowerCase() ?? "";
|
|
@@ -86146,10 +87292,10 @@ async function readAntigravityStoredCredentials(environment) {
|
|
|
86146
87292
|
};
|
|
86147
87293
|
}
|
|
86148
87294
|
const geminiHome = resolveGeminiHome2(environment);
|
|
86149
|
-
const cliDir =
|
|
87295
|
+
const cliDir = join25(geminiHome, "antigravity-cli");
|
|
86150
87296
|
const [cliSettingsRaw, sharedConfigRaw] = await Promise.all([
|
|
86151
|
-
readTextIfPresent(
|
|
86152
|
-
readTextIfPresent(
|
|
87297
|
+
readTextIfPresent(join25(cliDir, "settings.json")),
|
|
87298
|
+
readTextIfPresent(join25(geminiHome, "config", "config.json"))
|
|
86153
87299
|
]);
|
|
86154
87300
|
if (hasGatewayEnabled(cliSettingsRaw) || hasGatewayEnabled(sharedConfigRaw)) {
|
|
86155
87301
|
return {
|
|
@@ -86158,9 +87304,9 @@ async function readAntigravityStoredCredentials(environment) {
|
|
|
86158
87304
|
};
|
|
86159
87305
|
}
|
|
86160
87306
|
const projectFromEnv = environment["ANTIGRAVITY_PROJECT_ID"]?.trim() || environment["AGY_ACP_CCPA_PROJECT"]?.trim() || environment["GOOGLE_CLOUD_PROJECT"]?.trim();
|
|
86161
|
-
const projectFromCache = (await readTextIfPresent(
|
|
87307
|
+
const projectFromCache = (await readTextIfPresent(join25(cliDir, "cache", "default_project_id.txt")))?.trim();
|
|
86162
87308
|
const fallbackProjectId = projectFromEnv !== void 0 && projectFromEnv.length > 0 ? projectFromEnv : projectFromCache !== void 0 && projectFromCache.length > 0 ? projectFromCache : void 0;
|
|
86163
|
-
const agyTokenRaw = await readTextIfPresent(
|
|
87309
|
+
const agyTokenRaw = await readTextIfPresent(join25(cliDir, "antigravity-oauth-token"));
|
|
86164
87310
|
if (agyTokenRaw !== null) {
|
|
86165
87311
|
try {
|
|
86166
87312
|
const parsed = agyOAuthTokenFileSchema.safeParse(JSON.parse(agyTokenRaw));
|
|
@@ -86179,7 +87325,7 @@ async function readAntigravityStoredCredentials(environment) {
|
|
|
86179
87325
|
} catch {
|
|
86180
87326
|
}
|
|
86181
87327
|
}
|
|
86182
|
-
const acpTokenRaw = await readTextIfPresent(
|
|
87328
|
+
const acpTokenRaw = await readTextIfPresent(join25(geminiHome, "antigravity-acp", "acp_token.json"));
|
|
86183
87329
|
if (acpTokenRaw !== null) {
|
|
86184
87330
|
try {
|
|
86185
87331
|
const parsed = acpTokenFileSchema.safeParse(JSON.parse(acpTokenRaw));
|
|
@@ -88269,11 +89415,11 @@ var AgentQueryProcesses = class {
|
|
|
88269
89415
|
};
|
|
88270
89416
|
|
|
88271
89417
|
// src/engine/acp/adapter/antigravity/conversation-handoff.ts
|
|
88272
|
-
import { join as
|
|
89418
|
+
import { join as join26 } from "node:path";
|
|
88273
89419
|
var TRANSCRIPT_TAIL_BYTES2 = 1048576;
|
|
88274
89420
|
var MAXIMUM_HANDOFF_CHARACTERS = 32e3;
|
|
88275
89421
|
var MAXIMUM_MESSAGE_CHARACTERS = 4e3;
|
|
88276
|
-
var
|
|
89422
|
+
var SESSION_UUID_PATTERN3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
|
|
88277
89423
|
var USER_REQUEST_PATTERN = /<USER_REQUEST>\n?([\s\S]*?)\n?<\/USER_REQUEST>/u;
|
|
88278
89424
|
var HANDOFF_TAG = "previous_conversation";
|
|
88279
89425
|
var transcriptStepSchema2 = external_exports.object({
|
|
@@ -88299,12 +89445,12 @@ function messageFromStep(step) {
|
|
|
88299
89445
|
}
|
|
88300
89446
|
async function readConversationMessages(launchEnvironment, nativeSessionId) {
|
|
88301
89447
|
const geminiHome = resolveGeminiHome(launchEnvironment);
|
|
88302
|
-
if (geminiHome === void 0 || !
|
|
89448
|
+
if (geminiHome === void 0 || !SESSION_UUID_PATTERN3.test(nativeSessionId)) {
|
|
88303
89449
|
return null;
|
|
88304
89450
|
}
|
|
88305
89451
|
const tail = await readScopedFileTail(
|
|
88306
89452
|
geminiHome,
|
|
88307
|
-
|
|
89453
|
+
join26("antigravity-cli", "brain", nativeSessionId, ".system_generated", "logs", "transcript.jsonl"),
|
|
88308
89454
|
TRANSCRIPT_TAIL_BYTES2
|
|
88309
89455
|
);
|
|
88310
89456
|
if (tail === null) {
|
|
@@ -88473,12 +89619,25 @@ var AntigravityAdapter = class {
|
|
|
88473
89619
|
prompt = async (params) => {
|
|
88474
89620
|
const result = await this.#executionConnections.prompt(params);
|
|
88475
89621
|
const connection = this.#executionConnections.connection(params);
|
|
88476
|
-
if (connection !== void 0
|
|
88477
|
-
|
|
89622
|
+
if (connection !== void 0) {
|
|
89623
|
+
const recycleProcess = takeAntigravityProcessRecycleRequired(connection.connection, params.nativeSessionId);
|
|
89624
|
+
if (takeAntigravityUnusableNativeSession(connection.connection, params.nativeSessionId) && result.stopReason !== "cancelled") {
|
|
89625
|
+
throw new AcpExecutionError(UNUSABLE_NATIVE_SESSION_MESSAGE, {}, NATIVE_SESSION_UNUSABLE_ERROR_CODE);
|
|
89626
|
+
}
|
|
89627
|
+
if (recycleProcess) {
|
|
89628
|
+
return { ...result, recycleProcess: true };
|
|
89629
|
+
}
|
|
88478
89630
|
}
|
|
88479
89631
|
return result;
|
|
88480
89632
|
};
|
|
88481
89633
|
steer = (...args) => this.#executionConnections.steer(...args);
|
|
89634
|
+
trySettleIdlePrompt = async (params) => {
|
|
89635
|
+
const connection = this.#executionConnections.connection(params);
|
|
89636
|
+
if (connection === void 0) {
|
|
89637
|
+
return false;
|
|
89638
|
+
}
|
|
89639
|
+
return await trySettleAntigravityIdlePrompt(connection.connection, params.nativeSessionId);
|
|
89640
|
+
};
|
|
88482
89641
|
renameSession = (...args) => this.#executionConnections.renameSession(...args);
|
|
88483
89642
|
configureSession = (...args) => this.#executionConnections.configureSession(...args);
|
|
88484
89643
|
// Antigravity reports `thought_level` options only for the currently selected model.
|
|
@@ -89267,11 +90426,11 @@ var RuntimeAgentDependencies = class {
|
|
|
89267
90426
|
};
|
|
89268
90427
|
|
|
89269
90428
|
// src/engine/runtime/observability/diagnostic-log.ts
|
|
89270
|
-
import { join as
|
|
90429
|
+
import { join as join29 } from "node:path";
|
|
89271
90430
|
|
|
89272
90431
|
// src/engine/storage/logs/bounded-log.ts
|
|
89273
90432
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync10, renameSync as renameSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
89274
|
-
import { join as
|
|
90433
|
+
import { join as join27 } from "node:path";
|
|
89275
90434
|
var BoundedLineLog = class {
|
|
89276
90435
|
#path;
|
|
89277
90436
|
#maximumBytes;
|
|
@@ -89280,7 +90439,7 @@ var BoundedLineLog = class {
|
|
|
89280
90439
|
#onWriteFailure;
|
|
89281
90440
|
constructor(directory, filename, maximumBytes, onWriteFailure = () => void 0) {
|
|
89282
90441
|
this.#directory = directory;
|
|
89283
|
-
this.#path =
|
|
90442
|
+
this.#path = join27(directory, filename);
|
|
89284
90443
|
this.#maximumBytes = maximumBytes;
|
|
89285
90444
|
this.#onWriteFailure = onWriteFailure;
|
|
89286
90445
|
}
|
|
@@ -89331,21 +90490,21 @@ var BoundedLineLog = class {
|
|
|
89331
90490
|
|
|
89332
90491
|
// src/engine/storage/logs/log-files.ts
|
|
89333
90492
|
import { readFileSync as readFileSync11 } from "node:fs";
|
|
89334
|
-
import { join as
|
|
90493
|
+
import { join as join28 } from "node:path";
|
|
89335
90494
|
var DAEMON_LOG_FILENAME = "daemon.log";
|
|
89336
90495
|
var WORKER_LIFECYCLE_LOG_FILENAME = "worker-lifecycle.log";
|
|
89337
90496
|
function unhandledRejectionLogFilename(role) {
|
|
89338
90497
|
return `unhandled-rejections-${role}.log`;
|
|
89339
90498
|
}
|
|
89340
90499
|
function logDirectory(dataDirectory) {
|
|
89341
|
-
return
|
|
90500
|
+
return join28(dataDirectory, "logs");
|
|
89342
90501
|
}
|
|
89343
90502
|
function processLogPaths(dataDirectory) {
|
|
89344
90503
|
return [
|
|
89345
90504
|
WORKER_LIFECYCLE_LOG_FILENAME,
|
|
89346
90505
|
unhandledRejectionLogFilename("manager"),
|
|
89347
90506
|
unhandledRejectionLogFilename("worker")
|
|
89348
|
-
].map((filename) =>
|
|
90507
|
+
].map((filename) => join28(logDirectory(dataDirectory), filename));
|
|
89349
90508
|
}
|
|
89350
90509
|
function readLogText(path6) {
|
|
89351
90510
|
try {
|
|
@@ -89423,7 +90582,7 @@ var RuntimeDiagnosticLog = class {
|
|
|
89423
90582
|
this.#maximumBytes = maximumBytes;
|
|
89424
90583
|
const processLogsDirectory = options.processLogsDirectory;
|
|
89425
90584
|
this.#sources = [
|
|
89426
|
-
{ maximumBytes, path:
|
|
90585
|
+
{ maximumBytes, path: join29(directory, DAEMON_LOG_FILENAME) },
|
|
89427
90586
|
// The process logs a Runtime does not own, but must read to explain its own deaths.
|
|
89428
90587
|
...processLogsDirectory === void 0 ? [] : processLogPaths(processLogsDirectory).map((path6) => ({ maximumBytes: null, path: path6 }))
|
|
89429
90588
|
];
|
|
@@ -90558,7 +91717,7 @@ function sql(strings, ...params) {
|
|
|
90558
91717
|
return new SQL([new StringChunk(str)]);
|
|
90559
91718
|
}
|
|
90560
91719
|
_sql.raw = raw;
|
|
90561
|
-
function
|
|
91720
|
+
function join37(chunks, separator) {
|
|
90562
91721
|
const result = [];
|
|
90563
91722
|
for (const [i, chunk] of chunks.entries()) {
|
|
90564
91723
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -90566,7 +91725,7 @@ function sql(strings, ...params) {
|
|
|
90566
91725
|
}
|
|
90567
91726
|
return new SQL(result);
|
|
90568
91727
|
}
|
|
90569
|
-
_sql.join =
|
|
91728
|
+
_sql.join = join37;
|
|
90570
91729
|
function identifier2(value) {
|
|
90571
91730
|
return new Name(value);
|
|
90572
91731
|
}
|
|
@@ -92711,7 +93870,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
92711
93870
|
const baseTableName = this.tableName;
|
|
92712
93871
|
const tableName = getTableLikeName(table);
|
|
92713
93872
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
92714
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
93873
|
+
if (typeof tableName === "string" && this.config.joins?.some((join37) => join37.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
92715
93874
|
if (!this.isPartialSelect) {
|
|
92716
93875
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
92717
93876
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -93550,7 +94709,7 @@ var SQLiteDialect = class {
|
|
|
93550
94709
|
if (!joins2) return;
|
|
93551
94710
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
93552
94711
|
if (!withEntries.length) return;
|
|
93553
|
-
return sql.join(withEntries.map(([k2,
|
|
94712
|
+
return sql.join(withEntries.map(([k2, join37]) => {
|
|
93554
94713
|
const relation = tableConfig.relations[k2];
|
|
93555
94714
|
const isSingle2 = is(relation, One2);
|
|
93556
94715
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -93561,7 +94720,7 @@ var SQLiteDialect = class {
|
|
|
93561
94720
|
table: targetTable,
|
|
93562
94721
|
mode: isSingle2 ? "first" : "many",
|
|
93563
94722
|
schema,
|
|
93564
|
-
queryConfig:
|
|
94723
|
+
queryConfig: join37,
|
|
93565
94724
|
tableConfig: schema[relation.targetTableName],
|
|
93566
94725
|
relationWhere: filter,
|
|
93567
94726
|
isNested: true,
|
|
@@ -93575,7 +94734,7 @@ var SQLiteDialect = class {
|
|
|
93575
94734
|
key: k2,
|
|
93576
94735
|
selection: innerQuery.selection,
|
|
93577
94736
|
isArray: !isSingle2,
|
|
93578
|
-
isOptional: (relation.optional ?? false) ||
|
|
94737
|
+
isOptional: (relation.optional ?? false) || join37 !== true && !!join37.where
|
|
93579
94738
|
});
|
|
93580
94739
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
93581
94740
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -94191,7 +95350,7 @@ var SQLiteUpdateBase = class {
|
|
|
94191
95350
|
createJoin(joinType) {
|
|
94192
95351
|
return ((table, on2) => {
|
|
94193
95352
|
const tableName = getTableLikeName(table);
|
|
94194
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
95353
|
+
if (typeof tableName === "string" && this.config.joins.some((join37) => join37.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
94195
95354
|
if (typeof on2 === "function") {
|
|
94196
95355
|
const from = this.config.from ? is(table, SQLiteTable) ? table[Table.Symbol.Columns] : is(table, Subquery) ? table._.selectedFields : is(table, SQLiteViewBase) ? table[ViewBaseConfig].selectedFields : void 0 : void 0;
|
|
94197
95356
|
on2 = on2(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -95145,8 +96304,8 @@ var SessionEventCacheTable = class {
|
|
|
95145
96304
|
// src/engine/storage/sqlite/local-databases.ts
|
|
95146
96305
|
import { createHash as createHash4 } from "node:crypto";
|
|
95147
96306
|
import { existsSync as existsSync9 } from "node:fs";
|
|
95148
|
-
import { join as
|
|
95149
|
-
import { DatabaseSync as
|
|
96307
|
+
import { join as join30 } from "node:path";
|
|
96308
|
+
import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
|
|
95150
96309
|
|
|
95151
96310
|
// src/engine/generated/acp-session-store-migrations.ts
|
|
95152
96311
|
var acpSessionStoreMigrations = [
|
|
@@ -95231,7 +96390,7 @@ var sessionTitlePreferencesMigrations = [
|
|
|
95231
96390
|
// src/engine/storage/sqlite/local-sqlite-database.ts
|
|
95232
96391
|
import { chmodSync, mkdirSync as mkdirSync4 } from "node:fs";
|
|
95233
96392
|
import { dirname as dirname9 } from "node:path";
|
|
95234
|
-
import { DatabaseSync as
|
|
96393
|
+
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
95235
96394
|
|
|
95236
96395
|
// ../../node_modules/.pnpm/drizzle-orm@1.0.0-rc.4_@cloudflare+workers-types@5.20261028.1_@types+better-sqlite3@7.6_12a6406e88a0f7753ae87b6d067c841c/node_modules/drizzle-orm/node-sqlite/session.js
|
|
95237
96396
|
var NodeSQLiteSession = class extends SQLiteAsyncSession {
|
|
@@ -95305,7 +96464,7 @@ var NodeSQLiteTransaction = class NodeSQLiteTransaction2 extends SQLiteAsyncTran
|
|
|
95305
96464
|
};
|
|
95306
96465
|
|
|
95307
96466
|
// ../../node_modules/.pnpm/drizzle-orm@1.0.0-rc.4_@cloudflare+workers-types@5.20261028.1_@types+better-sqlite3@7.6_12a6406e88a0f7753ae87b6d067c841c/node_modules/drizzle-orm/node-sqlite/driver.js
|
|
95308
|
-
import { DatabaseSync } from "node:sqlite";
|
|
96467
|
+
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
95309
96468
|
var NodeSQLiteDatabase = class extends SQLiteAsyncDatabase {
|
|
95310
96469
|
static [entityKind] = "NodeSQLiteDatabase";
|
|
95311
96470
|
};
|
|
@@ -95320,14 +96479,14 @@ function construct(client2, config2 = {}) {
|
|
|
95320
96479
|
return db2;
|
|
95321
96480
|
}
|
|
95322
96481
|
function drizzle(...params) {
|
|
95323
|
-
if (params[0] === void 0 || typeof params[0] === "string") return construct(params[0] === void 0 ? new
|
|
96482
|
+
if (params[0] === void 0 || typeof params[0] === "string") return construct(params[0] === void 0 ? new DatabaseSync2(":memory:") : new DatabaseSync2(params[0]), params[1]);
|
|
95324
96483
|
const { connection, client: client2, ...config2 } = params[0];
|
|
95325
96484
|
if (client2) return construct(client2, config2);
|
|
95326
96485
|
if (typeof connection === "object") {
|
|
95327
96486
|
const { path: path6, ...options } = connection;
|
|
95328
|
-
return construct(new
|
|
96487
|
+
return construct(new DatabaseSync2(path6 ?? ":memory:", options), config2);
|
|
95329
96488
|
}
|
|
95330
|
-
return construct(new
|
|
96489
|
+
return construct(new DatabaseSync2(connection ?? ":memory:"), config2);
|
|
95331
96490
|
}
|
|
95332
96491
|
(function(_drizzle) {
|
|
95333
96492
|
function mock(config2) {
|
|
@@ -95344,7 +96503,7 @@ var LocalSqliteDatabase = class {
|
|
|
95344
96503
|
constructor(path6, label, migrations, pragmas = []) {
|
|
95345
96504
|
this.path = path6;
|
|
95346
96505
|
mkdirSync4(dirname9(path6), { mode: 448, recursive: true });
|
|
95347
|
-
this.#sqlite = new
|
|
96506
|
+
this.#sqlite = new DatabaseSync3(path6);
|
|
95348
96507
|
chmodSync(path6, 384);
|
|
95349
96508
|
try {
|
|
95350
96509
|
for (const pragma of pragmas) {
|
|
@@ -95398,16 +96557,16 @@ var LocalSqliteDatabase = class {
|
|
|
95398
96557
|
function channelSessionDatabasePaths(stateDirectory, channelId) {
|
|
95399
96558
|
const channelHash = createHash4("sha256").update(channelId).digest("hex");
|
|
95400
96559
|
return {
|
|
95401
|
-
cancellations:
|
|
95402
|
-
events:
|
|
95403
|
-
sessions:
|
|
96560
|
+
cancellations: join30(stateDirectory, "sessions", `${channelHash}.cancellations.sqlite`),
|
|
96561
|
+
events: join30(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
|
|
96562
|
+
sessions: join30(stateDirectory, "sessions", `${channelHash}.sqlite`)
|
|
95404
96563
|
};
|
|
95405
96564
|
}
|
|
95406
96565
|
function recordAppliedAdmissionOrder(path6) {
|
|
95407
96566
|
if (!existsSync9(path6)) {
|
|
95408
96567
|
return;
|
|
95409
96568
|
}
|
|
95410
|
-
const database = new
|
|
96569
|
+
const database = new DatabaseSync4(path6);
|
|
95411
96570
|
try {
|
|
95412
96571
|
const version3 = database.prepare("PRAGMA user_version").get()?.["user_version"];
|
|
95413
96572
|
const column = database.prepare("SELECT name FROM pragma_table_info('execution_receipt') WHERE name = 'admission_order'").get();
|
|
@@ -97238,6 +98397,7 @@ var AgentSession = class _AgentSession {
|
|
|
97238
98397
|
agentTurnCommand = () => this.#agentTurn?.commandId;
|
|
97239
98398
|
/** The command whose prompt the Agent is running, which only the Agent can report as delegated. */
|
|
97240
98399
|
#delegableCommandId = null;
|
|
98400
|
+
#processRecycleRequired = false;
|
|
97241
98401
|
#modelEffort = null;
|
|
97242
98402
|
#scope;
|
|
97243
98403
|
#subscriber;
|
|
@@ -97793,6 +98953,9 @@ var AgentSession = class _AgentSession {
|
|
|
97793
98953
|
this.#delegableCommandId = null;
|
|
97794
98954
|
}
|
|
97795
98955
|
});
|
|
98956
|
+
if (result.recycleProcess === true) {
|
|
98957
|
+
this.#processRecycleRequired = true;
|
|
98958
|
+
}
|
|
97796
98959
|
this.writeStoredSession((/* @__PURE__ */ new Date()).toISOString());
|
|
97797
98960
|
if (lifecycle !== void 0) {
|
|
97798
98961
|
const messageId = result._meta?.messageId;
|
|
@@ -97859,7 +99022,10 @@ var AgentSession = class _AgentSession {
|
|
|
97859
99022
|
validatePromptContent(options, this.#capabilities);
|
|
97860
99023
|
options.signal.throwIfAborted();
|
|
97861
99024
|
const lifecycle = options.lifecycle;
|
|
97862
|
-
|
|
99025
|
+
const recordSteerStart = async () => {
|
|
99026
|
+
if (lifecycle === void 0) {
|
|
99027
|
+
return;
|
|
99028
|
+
}
|
|
97863
99029
|
await this.recordLifecycleEvent({
|
|
97864
99030
|
payload: {
|
|
97865
99031
|
commandId: options.commandId,
|
|
@@ -97880,9 +99046,10 @@ var AgentSession = class _AgentSession {
|
|
|
97880
99046
|
},
|
|
97881
99047
|
type: "lifecycle-metadata"
|
|
97882
99048
|
});
|
|
97883
|
-
}
|
|
99049
|
+
};
|
|
97884
99050
|
try {
|
|
97885
99051
|
const outcome = await this.#adapter.steer({ ...this.#target(), content: options, signal: options.signal });
|
|
99052
|
+
await recordSteerStart();
|
|
97886
99053
|
if (lifecycle !== void 0) {
|
|
97887
99054
|
await this.recordLifecycleEvent({
|
|
97888
99055
|
payload: {
|
|
@@ -97898,6 +99065,10 @@ var AgentSession = class _AgentSession {
|
|
|
97898
99065
|
return outcome.outcome;
|
|
97899
99066
|
} catch (error62) {
|
|
97900
99067
|
const failure2 = error62 instanceof AcpExecutionError ? error62 : new AcpExecutionError("ACP agent execution failed", { cause: error62 });
|
|
99068
|
+
if (failure2.code === "steering_target_unavailable") {
|
|
99069
|
+
throw failure2;
|
|
99070
|
+
}
|
|
99071
|
+
await recordSteerStart();
|
|
97901
99072
|
if (lifecycle !== void 0) {
|
|
97902
99073
|
await this.recordLifecycleEvent({
|
|
97903
99074
|
payload: {
|
|
@@ -97913,6 +99084,17 @@ var AgentSession = class _AgentSession {
|
|
|
97913
99084
|
throw failure2;
|
|
97914
99085
|
}
|
|
97915
99086
|
};
|
|
99087
|
+
trySettleIdlePrompt = async () => {
|
|
99088
|
+
if (this.#nativeIdentity.kind !== "bound" || this.#adapter.trySettleIdlePrompt === void 0) {
|
|
99089
|
+
return false;
|
|
99090
|
+
}
|
|
99091
|
+
return await this.#adapter.trySettleIdlePrompt(this.#target());
|
|
99092
|
+
};
|
|
99093
|
+
takeProcessRecycleRequired = () => {
|
|
99094
|
+
const required2 = this.#processRecycleRequired;
|
|
99095
|
+
this.#processRecycleRequired = false;
|
|
99096
|
+
return required2;
|
|
99097
|
+
};
|
|
97916
99098
|
cancel = async (signal) => {
|
|
97917
99099
|
signal.throwIfAborted();
|
|
97918
99100
|
await this.#interactions.cancelPendingInteractions();
|
|
@@ -98611,9 +99793,9 @@ var SessionManager2 = class {
|
|
|
98611
99793
|
* Releases a closed or idle Session's process while keeping its title, settings and native
|
|
98612
99794
|
* identity available for the next preparation. This does not mark the Session closed.
|
|
98613
99795
|
*/
|
|
98614
|
-
async #stopSessionProcess(sessionId, runtime) {
|
|
99796
|
+
async #stopSessionProcess(sessionId, runtime, close = () => runtime.close()) {
|
|
98615
99797
|
this.#executionProcesses.detach(sessionId, runtime);
|
|
98616
|
-
const retirement = this.#processes.retire(runtime,
|
|
99798
|
+
const retirement = this.#processes.retire(runtime, close);
|
|
98617
99799
|
this.#sessionRetirements.set(sessionId, retirement);
|
|
98618
99800
|
try {
|
|
98619
99801
|
await retirement;
|
|
@@ -99079,6 +100261,17 @@ var SessionManager2 = class {
|
|
|
99079
100261
|
});
|
|
99080
100262
|
/** Whether a steering prompt can join the named execution: the one rule every steering check asks. */
|
|
99081
100263
|
acceptsSteering = (sessionId, targetCommandId) => this.#executions.acceptsSteering(sessionId, targetCommandId);
|
|
100264
|
+
/**
|
|
100265
|
+
* Asks an active session whose reply already finished while only an orphan background shell command
|
|
100266
|
+
* keeps its native prompt open to settle cleanly so a follow-up prompt can start at once.
|
|
100267
|
+
*/
|
|
100268
|
+
trySettleIdlePrompt = async (sessionId) => {
|
|
100269
|
+
const runtime = this.#executionProcesses.get(sessionId);
|
|
100270
|
+
if (runtime === void 0) {
|
|
100271
|
+
return false;
|
|
100272
|
+
}
|
|
100273
|
+
return await runtime.trySettleIdlePrompt();
|
|
100274
|
+
};
|
|
99082
100275
|
steerPrompt = async (options) => this.#operations.run(options, async (options2) => {
|
|
99083
100276
|
if (!this.acceptsSteering(options2.sessionId, options2.targetCommandId)) {
|
|
99084
100277
|
throw new AcpExecutionError("The target turn is no longer active", {}, "steering_target_unavailable");
|
|
@@ -99143,6 +100336,9 @@ var SessionManager2 = class {
|
|
|
99143
100336
|
...options2,
|
|
99144
100337
|
cancellationRequested: cancelled
|
|
99145
100338
|
});
|
|
100339
|
+
if (runtime.takeProcessRecycleRequired()) {
|
|
100340
|
+
await this.#stopSessionProcess(options2.sessionId, runtime, () => runtime.closeProcess());
|
|
100341
|
+
}
|
|
99146
100342
|
return cancelled() ? { stopReason: "cancelled" } : result;
|
|
99147
100343
|
} catch (error62) {
|
|
99148
100344
|
if (cancelled()) {
|
|
@@ -100307,6 +101503,13 @@ var ActiveRuntimeTurn = class {
|
|
|
100307
101503
|
this.#admission = { kind: "admitted", disposition };
|
|
100308
101504
|
return disposition;
|
|
100309
101505
|
};
|
|
101506
|
+
/**
|
|
101507
|
+
* Moves a steering prompt that could not join its finished target into normal FIFO execution
|
|
101508
|
+
* so it runs as a prompt of its own once the finished target releases the Session.
|
|
101509
|
+
*/
|
|
101510
|
+
fallbackSteerToQueue = () => {
|
|
101511
|
+
this.#admission = { kind: "admitted", disposition: SessionPromptDisposition.Queue };
|
|
101512
|
+
};
|
|
100310
101513
|
queuePromotion = () => {
|
|
100311
101514
|
if (this.#admission.kind === "queued") {
|
|
100312
101515
|
return this.#admission.promotion.promise;
|
|
@@ -100507,6 +101710,25 @@ var SessionExecutionState = class {
|
|
|
100507
101710
|
}
|
|
100508
101711
|
}
|
|
100509
101712
|
};
|
|
101713
|
+
/**
|
|
101714
|
+
* Claims the Session FIFO for a steering prompt whose target just finished before steering
|
|
101715
|
+
* could inject, waiting until any earlier non-steering execution releases the Session.
|
|
101716
|
+
*/
|
|
101717
|
+
fallbackSteerToPrompt = async (turn, waitSignal) => {
|
|
101718
|
+
waitSignal.throwIfAborted();
|
|
101719
|
+
turn.fallbackSteerToQueue();
|
|
101720
|
+
const head = () => [...this.#turnsByCommandId.values()].find(
|
|
101721
|
+
(candidate) => candidate.effectiveDisposition() !== SessionPromptDisposition.Steer
|
|
101722
|
+
);
|
|
101723
|
+
for (; ; ) {
|
|
101724
|
+
waitSignal.throwIfAborted();
|
|
101725
|
+
const first = head();
|
|
101726
|
+
if (first === void 0 || first === turn) {
|
|
101727
|
+
return;
|
|
101728
|
+
}
|
|
101729
|
+
await waitForTurnCompletion(first, waitSignal);
|
|
101730
|
+
}
|
|
101731
|
+
};
|
|
100510
101732
|
};
|
|
100511
101733
|
|
|
100512
101734
|
// src/engine/session/turn/session-turns.ts
|
|
@@ -100588,6 +101810,7 @@ var SessionTurns = class {
|
|
|
100588
101810
|
return { turn: null, queued: [] };
|
|
100589
101811
|
};
|
|
100590
101812
|
admitAndWait = async (turn, waitSignal, onQueued) => this.session(turn.command.sessionId).admitAndWait(turn, waitSignal, onQueued);
|
|
101813
|
+
fallbackSteerToPrompt = async (turn, waitSignal) => await this.session(turn.command.sessionId).fallbackSteerToPrompt(turn, waitSignal);
|
|
100591
101814
|
/** Discards empty session states so the index does not grow unboundedly. */
|
|
100592
101815
|
sweep = () => {
|
|
100593
101816
|
for (const [sessionId, session] of this.#bySessionId) {
|
|
@@ -100603,7 +101826,7 @@ var SessionTurns = class {
|
|
|
100603
101826
|
|
|
100604
101827
|
// src/engine/session/workspace/workspace-directory.ts
|
|
100605
101828
|
import { homedir as homedir5 } from "node:os";
|
|
100606
|
-
import { basename as basename8, dirname as dirname10, isAbsolute as isAbsolute16, join as
|
|
101829
|
+
import { basename as basename8, dirname as dirname10, isAbsolute as isAbsolute16, join as join31, normalize as normalize2, relative as relative3 } from "node:path";
|
|
100607
101830
|
|
|
100608
101831
|
// src/engine/session/workspace/local-authorization-error.ts
|
|
100609
101832
|
var LocalAuthorizationError = class extends OperationError {
|
|
@@ -100749,7 +101972,7 @@ var WorkspaceDirectoryService = class {
|
|
|
100749
101972
|
continue;
|
|
100750
101973
|
}
|
|
100751
101974
|
try {
|
|
100752
|
-
const path6 = await this.resolvePath(
|
|
101975
|
+
const path6 = await this.resolvePath(join31(target, child.name), signal);
|
|
100753
101976
|
entries.push({ directoryId: encodePath(path6), name: child.name });
|
|
100754
101977
|
} catch (cause) {
|
|
100755
101978
|
signal.throwIfAborted();
|
|
@@ -100934,13 +102157,13 @@ function buildSessionLayer(options) {
|
|
|
100934
102157
|
|
|
100935
102158
|
// src/engine/session/content/external-content-store.ts
|
|
100936
102159
|
import { createHash as createHash8 } from "node:crypto";
|
|
100937
|
-
import { extname as extname2, join as
|
|
102160
|
+
import { extname as extname2, join as join33 } from "node:path";
|
|
100938
102161
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
100939
102162
|
|
|
100940
102163
|
// src/engine/storage/files/scratch-directory.ts
|
|
100941
102164
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
100942
102165
|
import { lstat as lstat4, mkdir as mkdir5, readdir as readdir6, readFile as readFile8, realpath as realpath7, rename as rename4, rm as rm5, stat as stat6, utimes, writeFile as writeFile2 } from "node:fs/promises";
|
|
100943
|
-
import { dirname as dirname11, join as
|
|
102166
|
+
import { dirname as dirname11, join as join32 } from "node:path";
|
|
100944
102167
|
async function atomicWrite(path6, bytes, signal) {
|
|
100945
102168
|
const temporary = `${path6}.${randomUUID18()}.tmp`;
|
|
100946
102169
|
try {
|
|
@@ -100954,7 +102177,7 @@ async function atomicWrite(path6, bytes, signal) {
|
|
|
100954
102177
|
var ScratchDirectory = class {
|
|
100955
102178
|
#root;
|
|
100956
102179
|
constructor(parent) {
|
|
100957
|
-
this.#root =
|
|
102180
|
+
this.#root = join32(parent, randomUUID18());
|
|
100958
102181
|
}
|
|
100959
102182
|
/** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
|
|
100960
102183
|
refreshLease = async (leaseMilliseconds) => {
|
|
@@ -100965,7 +102188,7 @@ var ScratchDirectory = class {
|
|
|
100965
102188
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
100966
102189
|
continue;
|
|
100967
102190
|
}
|
|
100968
|
-
const path6 =
|
|
102191
|
+
const path6 = join32(dirname11(this.#root), directory.name);
|
|
100969
102192
|
if (path6 === this.#root) {
|
|
100970
102193
|
continue;
|
|
100971
102194
|
}
|
|
@@ -100980,10 +102203,10 @@ var ScratchDirectory = class {
|
|
|
100980
102203
|
};
|
|
100981
102204
|
/** Writes `bytes` atomically to `<group>/<name>` with owner-only permissions and returns the path. */
|
|
100982
102205
|
write = async (group, name2, bytes, signal) => {
|
|
100983
|
-
const directory =
|
|
102206
|
+
const directory = join32(this.#root, group);
|
|
100984
102207
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
100985
102208
|
signal.throwIfAborted();
|
|
100986
|
-
const path6 =
|
|
102209
|
+
const path6 = join32(directory, name2);
|
|
100987
102210
|
await atomicWrite(path6, bytes, signal);
|
|
100988
102211
|
return path6;
|
|
100989
102212
|
};
|
|
@@ -101034,7 +102257,7 @@ var LocalExternalContentStore = class {
|
|
|
101034
102257
|
#expirationTimer;
|
|
101035
102258
|
#cleanup = Promise.resolve();
|
|
101036
102259
|
constructor(stateDirectory) {
|
|
101037
|
-
this.#scratch = new ScratchDirectory(
|
|
102260
|
+
this.#scratch = new ScratchDirectory(join33(stateDirectory, "tmp", "session-content"));
|
|
101038
102261
|
this.#expirationTimer = setInterval(() => {
|
|
101039
102262
|
void this.#expire().catch(() => void 0);
|
|
101040
102263
|
}, 6e4);
|
|
@@ -101442,7 +102665,7 @@ var AgentProcessPool = class {
|
|
|
101442
102665
|
|
|
101443
102666
|
// src/engine/session/settings/agent-settings-cache.ts
|
|
101444
102667
|
import { createHash as createHash9, randomUUID as randomUUID19 } from "node:crypto";
|
|
101445
|
-
import { join as
|
|
102668
|
+
import { join as join34 } from "node:path";
|
|
101446
102669
|
var CACHE_FILE_LIMIT = 32 * 1024 * 1024;
|
|
101447
102670
|
var CACHE_FORMAT = 1;
|
|
101448
102671
|
var generationSchema = external_exports.union([external_exports.literal("initial"), external_exports.uuid()]);
|
|
@@ -101507,8 +102730,8 @@ var AgentSettingsCache = class {
|
|
|
101507
102730
|
#generationPath;
|
|
101508
102731
|
#generation = 0;
|
|
101509
102732
|
constructor(stateDirectory) {
|
|
101510
|
-
this.#directory =
|
|
101511
|
-
this.#generationPath =
|
|
102733
|
+
this.#directory = join34(stateDirectory, "agent-settings");
|
|
102734
|
+
this.#generationPath = join34(this.#directory, "generation");
|
|
101512
102735
|
}
|
|
101513
102736
|
get generation() {
|
|
101514
102737
|
return this.#generation;
|
|
@@ -101519,7 +102742,7 @@ var AgentSettingsCache = class {
|
|
|
101519
102742
|
};
|
|
101520
102743
|
open = async (agent2, signal) => {
|
|
101521
102744
|
const inspections = /* @__PURE__ */ new Map();
|
|
101522
|
-
const path6 =
|
|
102745
|
+
const path6 = join34(this.#directory, `${hash2(agent2.id)}.json`);
|
|
101523
102746
|
const fingerprint = hash2([
|
|
101524
102747
|
agent2.agentVersion,
|
|
101525
102748
|
agent2.adapterVersion,
|
|
@@ -102784,14 +104007,14 @@ function createContentWriteCommands(context) {
|
|
|
102784
104007
|
import { WebSocket as WebSocket5 } from "undici";
|
|
102785
104008
|
|
|
102786
104009
|
// src/engine/session/content/session-files.ts
|
|
102787
|
-
import { basename as basename9, extname as extname3, isAbsolute as isAbsolute18, join as
|
|
104010
|
+
import { basename as basename9, extname as extname3, isAbsolute as isAbsolute18, join as join36, normalize as normalize3, resolve as resolve18 } from "node:path";
|
|
102788
104011
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
102789
104012
|
|
|
102790
104013
|
// src/engine/storage/files/workspace-files.ts
|
|
102791
104014
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
102792
104015
|
import { constants as constants6 } from "node:fs";
|
|
102793
104016
|
import { lstat as lstat5, open as open6, readdir as readdir7, realpath as realpath8 } from "node:fs/promises";
|
|
102794
|
-
import { dirname as dirname12, isAbsolute as isAbsolute17, join as
|
|
104017
|
+
import { dirname as dirname12, isAbsolute as isAbsolute17, join as join35, parse as parse5, relative as relative4, sep as sep6 } from "node:path";
|
|
102795
104018
|
var MAXIMUM_NAME_LENGTH = 255;
|
|
102796
104019
|
var MAXIMUM_PATH_LENGTH = 1024;
|
|
102797
104020
|
var MAXIMUM_IGNORE_FILE_BYTES = 1024 * 1024;
|
|
@@ -102870,7 +104093,7 @@ async function readOpenedDirectory(root, target, handle, offset, limit, signal)
|
|
|
102870
104093
|
if (entry.name.includes("\\") || entry.name.length > MAXIMUM_NAME_LENGTH) {
|
|
102871
104094
|
continue;
|
|
102872
104095
|
}
|
|
102873
|
-
const path6 = portable(relative4(root,
|
|
104096
|
+
const path6 = portable(relative4(root, join35(target, entry.name)));
|
|
102874
104097
|
const matchedPath = entry.isDirectory() ? `${path6}/` : path6;
|
|
102875
104098
|
if (path6.length > MAXIMUM_PATH_LENGTH || isGitPath(path6) || matcher.ignores(matchedPath)) {
|
|
102876
104099
|
continue;
|
|
@@ -102892,7 +104115,7 @@ async function readOpenedDirectory(root, target, handle, offset, limit, signal)
|
|
|
102892
104115
|
continue;
|
|
102893
104116
|
}
|
|
102894
104117
|
try {
|
|
102895
|
-
const metadata = await lstat5(
|
|
104118
|
+
const metadata = await lstat5(join35(access4, entry.name));
|
|
102896
104119
|
signal.throwIfAborted();
|
|
102897
104120
|
if (metadata.isFile()) {
|
|
102898
104121
|
entries.push({ kind, name: entry.name, path: path6, size: metadata.size });
|
|
@@ -102984,7 +104207,7 @@ async function recordAncestry(resolved) {
|
|
|
102984
104207
|
const below = relative4(top, resolved.path);
|
|
102985
104208
|
const paths = [top];
|
|
102986
104209
|
for (const segment of below === "" ? [] : below.split(sep6)) {
|
|
102987
|
-
paths.push(
|
|
104210
|
+
paths.push(join35(paths[paths.length - 1] ?? top, segment));
|
|
102988
104211
|
}
|
|
102989
104212
|
const ancestry = [];
|
|
102990
104213
|
for (const path6 of paths) {
|
|
@@ -103056,7 +104279,7 @@ function requestedTarget(root, path6) {
|
|
|
103056
104279
|
if (path6.length === 0 || path6.length > MAXIMUM_PATH_LENGTH || /[\0\\]/u.test(path6) || segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
|
|
103057
104280
|
throw new WorkspaceFileError("file_outside_scope", "The workspace path leaves its directory");
|
|
103058
104281
|
}
|
|
103059
|
-
return
|
|
104282
|
+
return join35(root, ...segments);
|
|
103060
104283
|
}
|
|
103061
104284
|
function containedPath(root, canonical) {
|
|
103062
104285
|
const child = relative4(root, canonical);
|
|
@@ -103073,12 +104296,12 @@ async function ignoreMatcher(root, throughDirectory, explicitDirectory, signal)
|
|
|
103073
104296
|
for (let index2 = 0; index2 <= segments.length; index2 += 1) {
|
|
103074
104297
|
const matcher = (0, import_ignore.default)();
|
|
103075
104298
|
for (const name2 of [".gitignore", ".ignore"]) {
|
|
103076
|
-
matcher.add(await readIgnoreFile(
|
|
104299
|
+
matcher.add(await readIgnoreFile(join35(directory, name2), signal));
|
|
103077
104300
|
}
|
|
103078
104301
|
rules.push({ base: portable(relative4(root, directory)), matcher });
|
|
103079
104302
|
const segment = segments[index2];
|
|
103080
104303
|
if (segment !== void 0) {
|
|
103081
|
-
directory =
|
|
104304
|
+
directory = join35(directory, segment);
|
|
103082
104305
|
}
|
|
103083
104306
|
}
|
|
103084
104307
|
const explicit = portable(relative4(root, explicitDirectory));
|
|
@@ -103242,7 +104465,7 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
103242
104465
|
if (isAbsolute18(requested.path) && normalize3(requested.path) !== requested.path) {
|
|
103243
104466
|
return null;
|
|
103244
104467
|
}
|
|
103245
|
-
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute18(requested.path) ? [
|
|
104468
|
+
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute18(requested.path) ? [join36(workingDirectory, requested.path), requested.path] : [resolve18(workingDirectory, requested.path)];
|
|
103246
104469
|
for (const candidate of candidates) {
|
|
103247
104470
|
if (!isAbsolute18(candidate) || normalize3(candidate) !== candidate) {
|
|
103248
104471
|
continue;
|
|
@@ -103886,6 +105109,7 @@ async function executePrompt({
|
|
|
103886
105109
|
attemptId,
|
|
103887
105110
|
epoch,
|
|
103888
105111
|
waitForSessionAvailability,
|
|
105112
|
+
fallbackSteerToPrompt,
|
|
103889
105113
|
signal,
|
|
103890
105114
|
cancellationRequested
|
|
103891
105115
|
}) {
|
|
@@ -103925,6 +105149,9 @@ async function executePrompt({
|
|
|
103925
105149
|
"resolve-agent",
|
|
103926
105150
|
async () => await resolveAgent(command.agentId, signal, command.sessionId)
|
|
103927
105151
|
);
|
|
105152
|
+
if (command.disposition === SessionPromptDisposition.Queue) {
|
|
105153
|
+
await sessions.trySettleIdlePrompt(command.sessionId);
|
|
105154
|
+
}
|
|
103928
105155
|
const availability = await metrics.measure(
|
|
103929
105156
|
"await-session-availability",
|
|
103930
105157
|
async () => await waitForSessionAvailability(signal)
|
|
@@ -104004,26 +105231,15 @@ async function executePrompt({
|
|
|
104004
105231
|
if (command.prompt.trim().length === 0 && attachments.images.length === 0 && attachments.resources.length === 0) {
|
|
104005
105232
|
throw new PromptArtifactError("prompt_attachments_unsupported", "No supported prompt content remains");
|
|
104006
105233
|
}
|
|
104007
|
-
|
|
104008
|
-
|
|
104009
|
-
|
|
104010
|
-
|
|
104011
|
-
|
|
104012
|
-
|
|
104013
|
-
|
|
104014
|
-
|
|
104015
|
-
|
|
104016
|
-
images: attachments.images,
|
|
104017
|
-
lifecycle,
|
|
104018
|
-
prompt: command.prompt,
|
|
104019
|
-
resources: attachments.resources,
|
|
104020
|
-
sessionId: command.sessionId,
|
|
104021
|
-
signal,
|
|
104022
|
-
targetCommandId: command.targetCommandId
|
|
104023
|
-
});
|
|
104024
|
-
stopReason = "steered";
|
|
104025
|
-
} else {
|
|
104026
|
-
const suggestion2 = command.suggestNextPrompt !== true ? "not-requested" : prepared.capabilities.promptSuggestions ? "requested" : "unsupported";
|
|
105234
|
+
const runAsPrompt = async (disposition, activePrepared) => {
|
|
105235
|
+
const promptLifecycle = eventProjection.lifecycle(
|
|
105236
|
+
command.sessionId,
|
|
105237
|
+
command.commandId,
|
|
105238
|
+
attemptId,
|
|
105239
|
+
epoch,
|
|
105240
|
+
disposition
|
|
105241
|
+
);
|
|
105242
|
+
const suggestion2 = command.suggestNextPrompt !== true ? "not-requested" : activePrepared.capabilities.promptSuggestions ? "requested" : "unsupported";
|
|
104027
105243
|
sessions.promptSuggestions.begin(command.sessionId, command.commandId, suggestion2);
|
|
104028
105244
|
const result = await sessions.runPrompt({
|
|
104029
105245
|
adapter,
|
|
@@ -104033,9 +105249,9 @@ async function executePrompt({
|
|
|
104033
105249
|
agent: executionAgent,
|
|
104034
105250
|
commandId: command.commandId,
|
|
104035
105251
|
cwd: resolved.cwd,
|
|
104036
|
-
disposition
|
|
105252
|
+
disposition,
|
|
104037
105253
|
images: attachments.images,
|
|
104038
|
-
lifecycle,
|
|
105254
|
+
lifecycle: promptLifecycle,
|
|
104039
105255
|
prompt: command.prompt,
|
|
104040
105256
|
resources: attachments.resources,
|
|
104041
105257
|
sessionId: command.sessionId,
|
|
@@ -104045,8 +105261,66 @@ async function executePrompt({
|
|
|
104045
105261
|
targetCommandId: command.targetCommandId,
|
|
104046
105262
|
recovery
|
|
104047
105263
|
});
|
|
104048
|
-
|
|
104049
|
-
|
|
105264
|
+
sessions.promptSuggestions.finish(command.sessionId, command.commandId, result.stopReason);
|
|
105265
|
+
return result.stopReason;
|
|
105266
|
+
};
|
|
105267
|
+
let stopReason;
|
|
105268
|
+
if (availability.disposition === SessionPromptDisposition.Steer) {
|
|
105269
|
+
try {
|
|
105270
|
+
await sessions.steerPrompt({
|
|
105271
|
+
adapter,
|
|
105272
|
+
...externalizeSessionUpdate === void 0 ? {} : { externalizeSessionUpdate },
|
|
105273
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
105274
|
+
agent: executionAgent,
|
|
105275
|
+
commandId: command.commandId,
|
|
105276
|
+
cwd: resolved.cwd,
|
|
105277
|
+
images: attachments.images,
|
|
105278
|
+
lifecycle,
|
|
105279
|
+
prompt: command.prompt,
|
|
105280
|
+
resources: attachments.resources,
|
|
105281
|
+
sessionId: command.sessionId,
|
|
105282
|
+
signal,
|
|
105283
|
+
targetCommandId: command.targetCommandId
|
|
105284
|
+
});
|
|
105285
|
+
stopReason = "steered";
|
|
105286
|
+
} catch (error62) {
|
|
105287
|
+
if (!(error62 instanceof AcpExecutionError) || error62.code !== "steering_target_unavailable" || fallbackSteerToPrompt === void 0) {
|
|
105288
|
+
throw error62;
|
|
105289
|
+
}
|
|
105290
|
+
await fallbackSteerToPrompt(signal);
|
|
105291
|
+
signal.throwIfAborted();
|
|
105292
|
+
sessions.promptSuggestions.want(command.sessionId, command.suggestNextPrompt === true);
|
|
105293
|
+
let fallbackPrepared = await metrics.measure(
|
|
105294
|
+
"prepare-session",
|
|
105295
|
+
async () => await sessions.prepareExecutionSession(preparation)
|
|
105296
|
+
);
|
|
105297
|
+
if (command.sessionConfigurations !== void 0) {
|
|
105298
|
+
const configurations = fallbackPrepared.configOptions;
|
|
105299
|
+
await metrics.measure(
|
|
105300
|
+
"apply-configuration",
|
|
105301
|
+
async () => await applyCompleteSessionConfiguration(
|
|
105302
|
+
sessions,
|
|
105303
|
+
configurations,
|
|
105304
|
+
sessionConfigurations ?? [],
|
|
105305
|
+
executionAgent,
|
|
105306
|
+
adapter,
|
|
105307
|
+
resolved.cwd,
|
|
105308
|
+
resolved.additionalDirectories,
|
|
105309
|
+
command.commandId,
|
|
105310
|
+
command.sessionId,
|
|
105311
|
+
signal
|
|
105312
|
+
)
|
|
105313
|
+
);
|
|
105314
|
+
fallbackPrepared = await metrics.measure(
|
|
105315
|
+
"prepare-session",
|
|
105316
|
+
async () => await sessions.prepareExecutionSession(preparation)
|
|
105317
|
+
);
|
|
105318
|
+
}
|
|
105319
|
+
signal.throwIfAborted();
|
|
105320
|
+
stopReason = await runAsPrompt(SessionPromptDisposition.Queue, fallbackPrepared);
|
|
105321
|
+
}
|
|
105322
|
+
} else {
|
|
105323
|
+
stopReason = await runAsPrompt(availability.disposition, prepared);
|
|
104050
105324
|
}
|
|
104051
105325
|
await eventProjection.completed(command.sessionId, command.commandId, stopReason);
|
|
104052
105326
|
} catch (error62) {
|
|
@@ -104154,6 +105428,7 @@ var sessionPromptCommand = {
|
|
|
104154
105428
|
waitForSessionAvailability: (signal) => context.sessionTurns.admitAndWait(turn, signal, () => {
|
|
104155
105429
|
queueChanged();
|
|
104156
105430
|
}),
|
|
105431
|
+
fallbackSteerToPrompt: (signal) => context.sessionTurns.fallbackSteerToPrompt(turn, signal),
|
|
104157
105432
|
signal: turn.signal,
|
|
104158
105433
|
cancellationRequested: turn.cancellationRequested
|
|
104159
105434
|
}).catch((error62) => {
|
|
@@ -106429,4 +107704,4 @@ export {
|
|
|
106429
107704
|
* MIT Licensed
|
|
106430
107705
|
*)
|
|
106431
107706
|
*/
|
|
106432
|
-
//# sourceMappingURL=chunk-
|
|
107707
|
+
//# sourceMappingURL=chunk-CSWWCB7Z.js.map
|