@moxt-ai/mobius 0.0.454 → 0.0.455
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-7VYQEJW7.js → chunk-TPFOWHSZ.js} +280 -36
- package/dist/{chunk-7VYQEJW7.js.map → chunk-TPFOWHSZ.js.map} +4 -4
- package/dist/{chunk-TOQQNYQU.js → chunk-ZNK44CJT.js} +2 -2
- package/dist/{chunk-TOQQNYQU.js.map → chunk-ZNK44CJT.js.map} +1 -1
- package/dist/{cli-CCIMF4WB.js → cli-LYAYRPGJ.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/engine/acp/acp-error.d.ts +5 -0
- package/dist/engine/acp/acp-error.d.ts.map +1 -1
- package/dist/engine/acp/acp-error.js +5 -0
- package/dist/engine/acp/acp-error.js.map +1 -1
- 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 +28 -2
- package/dist/engine/acp/adapter/antigravity/adapter.js.map +1 -1
- package/dist/engine/acp/adapter/antigravity/agent-connection.d.ts +6 -0
- package/dist/engine/acp/adapter/antigravity/agent-connection.d.ts.map +1 -1
- package/dist/engine/acp/adapter/antigravity/agent-connection.js +20 -1
- package/dist/engine/acp/adapter/antigravity/agent-connection.js.map +1 -1
- package/dist/engine/acp/adapter/antigravity/background-wakeup.d.ts +2 -0
- package/dist/engine/acp/adapter/antigravity/background-wakeup.d.ts.map +1 -1
- package/dist/engine/acp/adapter/antigravity/background-wakeup.js +2 -2
- package/dist/engine/acp/adapter/antigravity/background-wakeup.js.map +1 -1
- package/dist/engine/acp/adapter/antigravity/conversation-handoff.d.ts +7 -0
- package/dist/engine/acp/adapter/antigravity/conversation-handoff.d.ts.map +1 -0
- package/dist/engine/acp/adapter/antigravity/conversation-handoff.js +110 -0
- package/dist/engine/acp/adapter/antigravity/conversation-handoff.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/session/live/agent-session-restore.d.ts +1 -0
- package/dist/engine/session/live/agent-session-restore.d.ts.map +1 -1
- package/dist/engine/session/live/agent-session.d.ts +7 -1
- package/dist/engine/session/live/agent-session.d.ts.map +1 -1
- package/dist/engine/session/live/agent-session.js +14 -1
- package/dist/engine/session/live/agent-session.js.map +1 -1
- package/dist/engine/session/live/session-restore.d.ts +6 -0
- package/dist/engine/session/live/session-restore.d.ts.map +1 -1
- package/dist/engine/session/live/session-restore.js +26 -0
- package/dist/engine/session/live/session-restore.js.map +1 -1
- package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
- package/dist/engine/session/manager/session-manager.js +26 -1
- package/dist/engine/session/manager/session-manager.js.map +1 -1
- package/dist/engine.js +2 -2
- package/package.json +1 -1
- /package/dist/{cli-CCIMF4WB.js.map → cli-LYAYRPGJ.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
__export,
|
|
4
4
|
__using,
|
|
5
5
|
package_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZNK44CJT.js";
|
|
7
7
|
|
|
8
8
|
// src/engine/runtime/relay/runtime-revocation.ts
|
|
9
9
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -26978,6 +26978,7 @@ function operationErrorMessage(error62) {
|
|
|
26978
26978
|
}
|
|
26979
26979
|
|
|
26980
26980
|
// src/engine/acp/acp-error.ts
|
|
26981
|
+
var NATIVE_SESSION_UNUSABLE_ERROR_CODE = "native_session_unusable";
|
|
26981
26982
|
var AcpExecutionError = class extends OperationError {
|
|
26982
26983
|
constructor(message, options = {}, code = "acp_execution_failed") {
|
|
26983
26984
|
super(code, message, options);
|
|
@@ -29253,6 +29254,7 @@ var FULL_ACCESS_MODE_DESCRIPTION = "Never asks the user: approves file edits and
|
|
|
29253
29254
|
var MAXIMUM_STDERR_TAIL_CHARACTERS = 2048;
|
|
29254
29255
|
var MAXIMUM_PENDING_CONFIG_ECHOES = 16;
|
|
29255
29256
|
var CANCEL_REQUEST_METHOD2 = "$/cancel_request";
|
|
29257
|
+
var INVALID_THINKING_SIGNATURE_PATTERN = /\bmessages\.\d+\.content\.\d+(?:\.thinking\.signature: Field required|: Invalid `signature` in `thinking` block)/u;
|
|
29256
29258
|
function readStringProperty(record2, key) {
|
|
29257
29259
|
const value = record2[key];
|
|
29258
29260
|
return typeof value === "string" ? value : void 0;
|
|
@@ -29376,6 +29378,9 @@ async function prepareAntigravitySessionCancel(clientConnection2, sessionId) {
|
|
|
29376
29378
|
}
|
|
29377
29379
|
return await owner.prepareSessionCancel(sessionId);
|
|
29378
29380
|
}
|
|
29381
|
+
function takeAntigravityUnusableNativeSession(clientConnection2, sessionId) {
|
|
29382
|
+
return activeConnectionsByClient.get(clientConnection2)?.takeUnusableNativeSession(sessionId) ?? false;
|
|
29383
|
+
}
|
|
29379
29384
|
var AntigravityAgentConnection = class {
|
|
29380
29385
|
connection;
|
|
29381
29386
|
termination;
|
|
@@ -29389,6 +29394,8 @@ var AntigravityAgentConnection = class {
|
|
|
29389
29394
|
#messageStreams = /* @__PURE__ */ new Map();
|
|
29390
29395
|
#pendingRequests = /* @__PURE__ */ new Map();
|
|
29391
29396
|
#pendingConfigEchoes = [];
|
|
29397
|
+
/** Native sessions whose current prompt reported an unusable conversation. */
|
|
29398
|
+
#unusableSessions = /* @__PURE__ */ new Set();
|
|
29392
29399
|
#latestPermissionMode = { kind: "native" };
|
|
29393
29400
|
#sessionEstablished = false;
|
|
29394
29401
|
#closePromise = null;
|
|
@@ -29562,6 +29569,7 @@ var AntigravityAgentConnection = class {
|
|
|
29562
29569
|
await this.#flushDeliveries();
|
|
29563
29570
|
return disposition;
|
|
29564
29571
|
};
|
|
29572
|
+
takeUnusableNativeSession = (sessionId) => this.#unusableSessions.delete(sessionId);
|
|
29565
29573
|
initialize = async (signal) => {
|
|
29566
29574
|
signal.throwIfAborted();
|
|
29567
29575
|
};
|
|
@@ -29672,6 +29680,7 @@ var AntigravityAgentConnection = class {
|
|
|
29672
29680
|
case methods.agent.session.prompt: {
|
|
29673
29681
|
if (sessionId !== void 0) {
|
|
29674
29682
|
this.#messageStreams.set(sessionId, { kind: "none" });
|
|
29683
|
+
this.#unusableSessions.delete(sessionId);
|
|
29675
29684
|
}
|
|
29676
29685
|
return message;
|
|
29677
29686
|
}
|
|
@@ -29795,6 +29804,10 @@ var AntigravityAgentConnection = class {
|
|
|
29795
29804
|
}
|
|
29796
29805
|
const modeState = this.#permissionModes.get(sessionId) ?? { kind: "native" };
|
|
29797
29806
|
const updateKind = readStringProperty(update, "sessionUpdate");
|
|
29807
|
+
const executorError = updateKind === void 0 ? void 0 : extractExecutorError(updateKind, update);
|
|
29808
|
+
if (executorError !== void 0 && INVALID_THINKING_SIGNATURE_PATTERN.test(executorError)) {
|
|
29809
|
+
this.#unusableSessions.add(sessionId);
|
|
29810
|
+
}
|
|
29798
29811
|
if (updateKind === "config_option_update") {
|
|
29799
29812
|
if (this.#consumeConfigEcho(sessionId, update["configOptions"])) {
|
|
29800
29813
|
return void 0;
|
|
@@ -84424,7 +84437,115 @@ var AgentQueryProcesses = class {
|
|
|
84424
84437
|
};
|
|
84425
84438
|
};
|
|
84426
84439
|
|
|
84440
|
+
// src/engine/acp/adapter/antigravity/conversation-handoff.ts
|
|
84441
|
+
import { join as join24 } from "node:path";
|
|
84442
|
+
var TRANSCRIPT_TAIL_BYTES2 = 1048576;
|
|
84443
|
+
var MAXIMUM_HANDOFF_CHARACTERS = 32e3;
|
|
84444
|
+
var MAXIMUM_MESSAGE_CHARACTERS = 4e3;
|
|
84445
|
+
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;
|
|
84446
|
+
var USER_REQUEST_PATTERN = /<USER_REQUEST>\n?([\s\S]*?)\n?<\/USER_REQUEST>/u;
|
|
84447
|
+
var HANDOFF_TAG = "previous_conversation";
|
|
84448
|
+
var transcriptStepSchema2 = external_exports.object({
|
|
84449
|
+
content: external_exports.string().optional(),
|
|
84450
|
+
step_index: external_exports.number().int().nonnegative(),
|
|
84451
|
+
type: external_exports.string()
|
|
84452
|
+
});
|
|
84453
|
+
function messageFromStep(step) {
|
|
84454
|
+
const content = step.content?.trim();
|
|
84455
|
+
if (content === void 0 || content.length === 0) {
|
|
84456
|
+
return void 0;
|
|
84457
|
+
}
|
|
84458
|
+
switch (step.type) {
|
|
84459
|
+
case "USER_INPUT": {
|
|
84460
|
+
const request = USER_REQUEST_PATTERN.exec(content)?.[1]?.trim();
|
|
84461
|
+
return request === void 0 || request.length === 0 ? void 0 : { role: "user", text: request };
|
|
84462
|
+
}
|
|
84463
|
+
case "PLANNER_RESPONSE":
|
|
84464
|
+
return { role: "assistant", text: content };
|
|
84465
|
+
default:
|
|
84466
|
+
return void 0;
|
|
84467
|
+
}
|
|
84468
|
+
}
|
|
84469
|
+
async function readConversationMessages(launchEnvironment, nativeSessionId) {
|
|
84470
|
+
const geminiHome = resolveGeminiHome(launchEnvironment);
|
|
84471
|
+
if (geminiHome === void 0 || !SESSION_UUID_PATTERN2.test(nativeSessionId)) {
|
|
84472
|
+
return null;
|
|
84473
|
+
}
|
|
84474
|
+
const tail = await readScopedFileTail(
|
|
84475
|
+
geminiHome,
|
|
84476
|
+
join24("antigravity-cli", "brain", nativeSessionId, ".system_generated", "logs", "transcript.jsonl"),
|
|
84477
|
+
TRANSCRIPT_TAIL_BYTES2
|
|
84478
|
+
);
|
|
84479
|
+
if (tail === null) {
|
|
84480
|
+
return null;
|
|
84481
|
+
}
|
|
84482
|
+
const lines = new TextDecoder().decode(tail.bytes).split("\n");
|
|
84483
|
+
const steps = [];
|
|
84484
|
+
for (const line of lines.slice(tail.offset > 0 ? 1 : 0)) {
|
|
84485
|
+
if (line.trim().length === 0) {
|
|
84486
|
+
continue;
|
|
84487
|
+
}
|
|
84488
|
+
let decoded;
|
|
84489
|
+
try {
|
|
84490
|
+
decoded = JSON.parse(line);
|
|
84491
|
+
} catch {
|
|
84492
|
+
continue;
|
|
84493
|
+
}
|
|
84494
|
+
const parsed = transcriptStepSchema2.safeParse(decoded);
|
|
84495
|
+
if (parsed.success) {
|
|
84496
|
+
steps.push(parsed.data);
|
|
84497
|
+
}
|
|
84498
|
+
}
|
|
84499
|
+
steps.sort((left, right) => left.step_index - right.step_index);
|
|
84500
|
+
const messages = steps.flatMap((step) => {
|
|
84501
|
+
const message = messageFromStep(step);
|
|
84502
|
+
return message === void 0 ? [] : [message];
|
|
84503
|
+
});
|
|
84504
|
+
return { messages, complete: tail.offset === 0 };
|
|
84505
|
+
}
|
|
84506
|
+
async function antigravityConversationHandoff(launchEnvironment, unusableNativeSessionId) {
|
|
84507
|
+
const conversation = await readConversationMessages(launchEnvironment, unusableNativeSessionId);
|
|
84508
|
+
const introduction = "This conversation continues an earlier one that could no longer be sent to the model. Treat the earlier messages below as what the user and you have already said; continue from them without repeating finished work unless the user asks.";
|
|
84509
|
+
if (conversation === null || conversation.messages.length === 0) {
|
|
84510
|
+
return `<${HANDOFF_TAG}>
|
|
84511
|
+
${introduction}
|
|
84512
|
+
The earlier messages could not be read.
|
|
84513
|
+
</${HANDOFF_TAG}>`;
|
|
84514
|
+
}
|
|
84515
|
+
const entries = [];
|
|
84516
|
+
let length = 0;
|
|
84517
|
+
let omitted = 0;
|
|
84518
|
+
for (let index2 = conversation.messages.length - 1; index2 >= 0; index2 -= 1) {
|
|
84519
|
+
const message = conversation.messages[index2];
|
|
84520
|
+
if (message === void 0) {
|
|
84521
|
+
continue;
|
|
84522
|
+
}
|
|
84523
|
+
const text2 = truncate(message.text, MAXIMUM_MESSAGE_CHARACTERS).replaceAll(
|
|
84524
|
+
`</${HANDOFF_TAG}>`,
|
|
84525
|
+
`</ ${HANDOFF_TAG}>`
|
|
84526
|
+
);
|
|
84527
|
+
const entry = `[${message.role}]
|
|
84528
|
+
${text2}`;
|
|
84529
|
+
if (length + entry.length > MAXIMUM_HANDOFF_CHARACTERS) {
|
|
84530
|
+
omitted = index2 + 1;
|
|
84531
|
+
break;
|
|
84532
|
+
}
|
|
84533
|
+
entries.unshift(entry);
|
|
84534
|
+
length += entry.length;
|
|
84535
|
+
}
|
|
84536
|
+
const earlierOmitted = omitted > 0 || !conversation.complete;
|
|
84537
|
+
return [
|
|
84538
|
+
`<${HANDOFF_TAG}>`,
|
|
84539
|
+
introduction,
|
|
84540
|
+
...earlierOmitted ? ["Earlier messages are omitted; the ones below are the most recent."] : [],
|
|
84541
|
+
"",
|
|
84542
|
+
entries.join("\n\n"),
|
|
84543
|
+
`</${HANDOFF_TAG}>`
|
|
84544
|
+
].join("\n");
|
|
84545
|
+
}
|
|
84546
|
+
|
|
84427
84547
|
// src/engine/acp/adapter/antigravity/adapter.ts
|
|
84548
|
+
var UNUSABLE_NATIVE_SESSION_MESSAGE = "Antigravity can no longer send this conversation's saved history to the model. Your next message continues in a new Antigravity conversation that carries this conversation's context.";
|
|
84428
84549
|
var AntigravityAdapter = class {
|
|
84429
84550
|
#queryProcesses;
|
|
84430
84551
|
#connector;
|
|
@@ -84449,6 +84570,30 @@ var AntigravityAdapter = class {
|
|
|
84449
84570
|
this.#executionConnections.bind(execution, nativeSessionId);
|
|
84450
84571
|
return normalizeOpenedSession(execution, nativeSessionId, response, signal);
|
|
84451
84572
|
});
|
|
84573
|
+
// `agy acp` adds `systemPrompt.append` to the new conversation's system prompt and keeps it with the conversation.
|
|
84574
|
+
continueInNewSession = (params) => this.#executionConnections.withConnection(params, async (execution, signal) => {
|
|
84575
|
+
const { connection } = execution;
|
|
84576
|
+
const handoff2 = await antigravityConversationHandoff(
|
|
84577
|
+
{ ...process.env, ...params.scope.agent.environment },
|
|
84578
|
+
params.unusableNativeSessionId
|
|
84579
|
+
);
|
|
84580
|
+
signal.throwIfAborted();
|
|
84581
|
+
const response = await connection.race(
|
|
84582
|
+
connection.connection.agent.request(
|
|
84583
|
+
methods.agent.session.new,
|
|
84584
|
+
{
|
|
84585
|
+
...sessionWorkspace(params.scope),
|
|
84586
|
+
_meta: { antigravity: { systemPrompt: { append: handoff2 } } }
|
|
84587
|
+
},
|
|
84588
|
+
{ cancellationSignal: signal }
|
|
84589
|
+
),
|
|
84590
|
+
"ACP agent exited while starting a session",
|
|
84591
|
+
signal
|
|
84592
|
+
);
|
|
84593
|
+
const nativeSessionId = createdNativeSessionId(response);
|
|
84594
|
+
this.#executionConnections.bind(execution, nativeSessionId);
|
|
84595
|
+
return normalizeOpenedSession(execution, nativeSessionId, response, signal);
|
|
84596
|
+
});
|
|
84452
84597
|
openSession = (params) => this.#executionConnections.withConnection(params, async (execution, signal) => {
|
|
84453
84598
|
const { connection } = execution;
|
|
84454
84599
|
const nativeSessionId = nativeSessionIdSchema.parse(params.nativeSessionId);
|
|
@@ -84494,7 +84639,14 @@ var AntigravityAdapter = class {
|
|
|
84494
84639
|
closeSession = (...args) => this.#executionConnections.closeSession(...args);
|
|
84495
84640
|
releaseSession = (params) => this.#executionConnections.releaseSession(params);
|
|
84496
84641
|
readNativeHistoryRevision = (params) => this.#executionConnections.readNativeHistoryRevision(params);
|
|
84497
|
-
prompt = (
|
|
84642
|
+
prompt = async (params) => {
|
|
84643
|
+
const result = await this.#executionConnections.prompt(params);
|
|
84644
|
+
const connection = this.#executionConnections.connection(params);
|
|
84645
|
+
if (connection !== void 0 && takeAntigravityUnusableNativeSession(connection.connection, params.nativeSessionId) && result.stopReason !== "cancelled") {
|
|
84646
|
+
throw new AcpExecutionError(UNUSABLE_NATIVE_SESSION_MESSAGE, {}, NATIVE_SESSION_UNUSABLE_ERROR_CODE);
|
|
84647
|
+
}
|
|
84648
|
+
return result;
|
|
84649
|
+
};
|
|
84498
84650
|
steer = (...args) => this.#executionConnections.steer(...args);
|
|
84499
84651
|
renameSession = (...args) => this.#executionConnections.renameSession(...args);
|
|
84500
84652
|
configureSession = (...args) => this.#executionConnections.configureSession(...args);
|
|
@@ -85211,11 +85363,11 @@ function describeEnvironmentProxyRoute(target) {
|
|
|
85211
85363
|
}
|
|
85212
85364
|
|
|
85213
85365
|
// src/engine/runtime/observability/diagnostic-log.ts
|
|
85214
|
-
import { join as
|
|
85366
|
+
import { join as join27 } from "node:path";
|
|
85215
85367
|
|
|
85216
85368
|
// src/engine/storage/logs/bounded-log.ts
|
|
85217
85369
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync10, renameSync as renameSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
85218
|
-
import { join as
|
|
85370
|
+
import { join as join25 } from "node:path";
|
|
85219
85371
|
var BoundedLineLog = class {
|
|
85220
85372
|
#path;
|
|
85221
85373
|
#maximumBytes;
|
|
@@ -85224,7 +85376,7 @@ var BoundedLineLog = class {
|
|
|
85224
85376
|
#onWriteFailure;
|
|
85225
85377
|
constructor(directory, filename, maximumBytes, onWriteFailure = () => void 0) {
|
|
85226
85378
|
this.#directory = directory;
|
|
85227
|
-
this.#path =
|
|
85379
|
+
this.#path = join25(directory, filename);
|
|
85228
85380
|
this.#maximumBytes = maximumBytes;
|
|
85229
85381
|
this.#onWriteFailure = onWriteFailure;
|
|
85230
85382
|
}
|
|
@@ -85275,21 +85427,21 @@ var BoundedLineLog = class {
|
|
|
85275
85427
|
|
|
85276
85428
|
// src/engine/storage/logs/log-files.ts
|
|
85277
85429
|
import { readFileSync as readFileSync11 } from "node:fs";
|
|
85278
|
-
import { join as
|
|
85430
|
+
import { join as join26 } from "node:path";
|
|
85279
85431
|
var DAEMON_LOG_FILENAME = "daemon.log";
|
|
85280
85432
|
var WORKER_LIFECYCLE_LOG_FILENAME = "worker-lifecycle.log";
|
|
85281
85433
|
function unhandledRejectionLogFilename(role) {
|
|
85282
85434
|
return `unhandled-rejections-${role}.log`;
|
|
85283
85435
|
}
|
|
85284
85436
|
function logDirectory(dataDirectory) {
|
|
85285
|
-
return
|
|
85437
|
+
return join26(dataDirectory, "logs");
|
|
85286
85438
|
}
|
|
85287
85439
|
function processLogPaths(dataDirectory) {
|
|
85288
85440
|
return [
|
|
85289
85441
|
WORKER_LIFECYCLE_LOG_FILENAME,
|
|
85290
85442
|
unhandledRejectionLogFilename("manager"),
|
|
85291
85443
|
unhandledRejectionLogFilename("worker")
|
|
85292
|
-
].map((filename) =>
|
|
85444
|
+
].map((filename) => join26(logDirectory(dataDirectory), filename));
|
|
85293
85445
|
}
|
|
85294
85446
|
function readLogText(path6) {
|
|
85295
85447
|
try {
|
|
@@ -85364,7 +85516,7 @@ var RuntimeDiagnosticLog = class {
|
|
|
85364
85516
|
this.#maximumBytes = maximumBytes;
|
|
85365
85517
|
const processLogsDirectory = options.processLogsDirectory;
|
|
85366
85518
|
this.#sources = [
|
|
85367
|
-
{ maximumBytes, path:
|
|
85519
|
+
{ maximumBytes, path: join27(directory, DAEMON_LOG_FILENAME) },
|
|
85368
85520
|
// The process logs a Runtime does not own, but must read to explain its own deaths.
|
|
85369
85521
|
...processLogsDirectory === void 0 ? [] : processLogPaths(processLogsDirectory).map((path6) => ({ maximumBytes: null, path: path6 }))
|
|
85370
85522
|
];
|
|
@@ -86499,7 +86651,7 @@ function sql(strings, ...params) {
|
|
|
86499
86651
|
return new SQL([new StringChunk(str)]);
|
|
86500
86652
|
}
|
|
86501
86653
|
_sql.raw = raw;
|
|
86502
|
-
function
|
|
86654
|
+
function join34(chunks, separator) {
|
|
86503
86655
|
const result = [];
|
|
86504
86656
|
for (const [i, chunk] of chunks.entries()) {
|
|
86505
86657
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -86507,7 +86659,7 @@ function sql(strings, ...params) {
|
|
|
86507
86659
|
}
|
|
86508
86660
|
return new SQL(result);
|
|
86509
86661
|
}
|
|
86510
|
-
_sql.join =
|
|
86662
|
+
_sql.join = join34;
|
|
86511
86663
|
function identifier2(value) {
|
|
86512
86664
|
return new Name(value);
|
|
86513
86665
|
}
|
|
@@ -88652,7 +88804,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
88652
88804
|
const baseTableName = this.tableName;
|
|
88653
88805
|
const tableName = getTableLikeName(table);
|
|
88654
88806
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
88655
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
88807
|
+
if (typeof tableName === "string" && this.config.joins?.some((join34) => join34.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
88656
88808
|
if (!this.isPartialSelect) {
|
|
88657
88809
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
88658
88810
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -89491,7 +89643,7 @@ var SQLiteDialect = class {
|
|
|
89491
89643
|
if (!joins2) return;
|
|
89492
89644
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
89493
89645
|
if (!withEntries.length) return;
|
|
89494
|
-
return sql.join(withEntries.map(([k2,
|
|
89646
|
+
return sql.join(withEntries.map(([k2, join34]) => {
|
|
89495
89647
|
const relation = tableConfig.relations[k2];
|
|
89496
89648
|
const isSingle2 = is(relation, One2);
|
|
89497
89649
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -89502,7 +89654,7 @@ var SQLiteDialect = class {
|
|
|
89502
89654
|
table: targetTable,
|
|
89503
89655
|
mode: isSingle2 ? "first" : "many",
|
|
89504
89656
|
schema,
|
|
89505
|
-
queryConfig:
|
|
89657
|
+
queryConfig: join34,
|
|
89506
89658
|
tableConfig: schema[relation.targetTableName],
|
|
89507
89659
|
relationWhere: filter,
|
|
89508
89660
|
isNested: true,
|
|
@@ -89516,7 +89668,7 @@ var SQLiteDialect = class {
|
|
|
89516
89668
|
key: k2,
|
|
89517
89669
|
selection: innerQuery.selection,
|
|
89518
89670
|
isArray: !isSingle2,
|
|
89519
|
-
isOptional: (relation.optional ?? false) ||
|
|
89671
|
+
isOptional: (relation.optional ?? false) || join34 !== true && !!join34.where
|
|
89520
89672
|
});
|
|
89521
89673
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
89522
89674
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -90132,7 +90284,7 @@ var SQLiteUpdateBase = class {
|
|
|
90132
90284
|
createJoin(joinType) {
|
|
90133
90285
|
return ((table, on2) => {
|
|
90134
90286
|
const tableName = getTableLikeName(table);
|
|
90135
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
90287
|
+
if (typeof tableName === "string" && this.config.joins.some((join34) => join34.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
90136
90288
|
if (typeof on2 === "function") {
|
|
90137
90289
|
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;
|
|
90138
90290
|
on2 = on2(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -91086,7 +91238,7 @@ var SessionEventCacheTable = class {
|
|
|
91086
91238
|
// src/engine/storage/sqlite/local-databases.ts
|
|
91087
91239
|
import { createHash as createHash4 } from "node:crypto";
|
|
91088
91240
|
import { existsSync as existsSync9 } from "node:fs";
|
|
91089
|
-
import { join as
|
|
91241
|
+
import { join as join28 } from "node:path";
|
|
91090
91242
|
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
91091
91243
|
|
|
91092
91244
|
// src/engine/generated/acp-session-store-migrations.ts
|
|
@@ -91339,9 +91491,9 @@ var LocalSqliteDatabase = class {
|
|
|
91339
91491
|
function channelSessionDatabasePaths(stateDirectory, channelId) {
|
|
91340
91492
|
const channelHash = createHash4("sha256").update(channelId).digest("hex");
|
|
91341
91493
|
return {
|
|
91342
|
-
cancellations:
|
|
91343
|
-
events:
|
|
91344
|
-
sessions:
|
|
91494
|
+
cancellations: join28(stateDirectory, "sessions", `${channelHash}.cancellations.sqlite`),
|
|
91495
|
+
events: join28(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
|
|
91496
|
+
sessions: join28(stateDirectory, "sessions", `${channelHash}.sqlite`)
|
|
91345
91497
|
};
|
|
91346
91498
|
}
|
|
91347
91499
|
function recordAppliedAdmissionOrder(path6) {
|
|
@@ -93096,6 +93248,30 @@ async function restoreSession(session, signal, recovery) {
|
|
|
93096
93248
|
conversation !== void 0 && session.restored ? conversation.updatedAt : (/* @__PURE__ */ new Date()).toISOString()
|
|
93097
93249
|
);
|
|
93098
93250
|
}
|
|
93251
|
+
async function continueInNewNativeSession(session, signal, unusableNativeSessionId) {
|
|
93252
|
+
const stored = session.metrics.measureSync("session-state-read", () => session.store.read(session.sessionId));
|
|
93253
|
+
const conversation = stored instanceof FoundStoredSession ? stored.session : void 0;
|
|
93254
|
+
if (conversation === void 0 || conversation.nativeSessionId !== unusableNativeSessionId || conversation.agentId !== session.agentId || conversation.cwd !== session.cwd || !arraysEqual(conversation.additionalDirectories, session.additionalDirectories)) {
|
|
93255
|
+
throw new AcpExecutionError(
|
|
93256
|
+
"The Session no longer continues the native conversation that failed",
|
|
93257
|
+
{},
|
|
93258
|
+
"session_identity_mismatch"
|
|
93259
|
+
);
|
|
93260
|
+
}
|
|
93261
|
+
const opened = await session.metrics.measure(
|
|
93262
|
+
"session-new",
|
|
93263
|
+
async () => await session.continueSession(unusableNativeSessionId, signal)
|
|
93264
|
+
);
|
|
93265
|
+
session.selectNativeSession(opened.nativeSessionId);
|
|
93266
|
+
session.setPrompted(true);
|
|
93267
|
+
session.setSessionTitle(conversation.title);
|
|
93268
|
+
session.setRestored(true);
|
|
93269
|
+
session.startExecutionOnlyCapture();
|
|
93270
|
+
session.applySessionOpened(opened);
|
|
93271
|
+
await session.restoreStoredConfigurations(conversation, signal);
|
|
93272
|
+
signal.throwIfAborted();
|
|
93273
|
+
session.writeStoredSession((/* @__PURE__ */ new Date()).toISOString());
|
|
93274
|
+
}
|
|
93099
93275
|
|
|
93100
93276
|
// src/engine/session/live/agent-session.ts
|
|
93101
93277
|
var SESSION_CONTROL_COMMAND_ID = "session-control";
|
|
@@ -93316,6 +93492,23 @@ var AgentSession = class _AgentSession {
|
|
|
93316
93492
|
promptSuggestions,
|
|
93317
93493
|
timer
|
|
93318
93494
|
);
|
|
93495
|
+
/**
|
|
93496
|
+
* Starts a process that continues the Session in a new native conversation, in place of the stored one whose
|
|
93497
|
+
* prompts failed with `native_session_unusable`.
|
|
93498
|
+
*/
|
|
93499
|
+
static continueUnusable = async (options, unusableNativeSessionId, getObserver, agentCommand, store, adapter, promptSuggestions, timer) => await _AgentSession.#start(
|
|
93500
|
+
options,
|
|
93501
|
+
getObserver,
|
|
93502
|
+
agentCommand,
|
|
93503
|
+
store,
|
|
93504
|
+
async (runtime) => await runtime.#writeNativeHistory(
|
|
93505
|
+
async () => await continueInNewNativeSession(runtime, options.signal, unusableNativeSessionId)
|
|
93506
|
+
),
|
|
93507
|
+
unmeasuredOperationMetrics,
|
|
93508
|
+
adapter,
|
|
93509
|
+
promptSuggestions,
|
|
93510
|
+
timer
|
|
93511
|
+
);
|
|
93319
93512
|
belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
|
|
93320
93513
|
usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
|
|
93321
93514
|
writeStoredSession = (updatedAt) => {
|
|
@@ -94164,6 +94357,17 @@ var AgentSession = class _AgentSession {
|
|
|
94164
94357
|
generateTitle: this.#generateTitle
|
|
94165
94358
|
});
|
|
94166
94359
|
createSession = (signal) => this.#adapter.createSession(this.#sessionParams(signal));
|
|
94360
|
+
continueSession = async (unusableNativeSessionId, signal) => {
|
|
94361
|
+
const continueInNewSession = this.#adapter.continueInNewSession;
|
|
94362
|
+
if (continueInNewSession === void 0) {
|
|
94363
|
+
throw new AcpExecutionError(
|
|
94364
|
+
"This Agent cannot continue a conversation in a new native conversation",
|
|
94365
|
+
{},
|
|
94366
|
+
"session_restore_unsupported"
|
|
94367
|
+
);
|
|
94368
|
+
}
|
|
94369
|
+
return await continueInNewSession({ ...this.#sessionParams(signal), unusableNativeSessionId });
|
|
94370
|
+
};
|
|
94167
94371
|
openSession = (signal) => this.#adapter.openSession({ ...this.#sessionParams(signal), nativeSessionId: this.nativeSessionId() });
|
|
94168
94372
|
openSessionWithReplay = async (signal) => (await this.#loadSession(signal)).opened;
|
|
94169
94373
|
setConfigOptions(options) {
|
|
@@ -94946,6 +95150,7 @@ var SessionManager2 = class {
|
|
|
94946
95150
|
}
|
|
94947
95151
|
} catch (error62) {
|
|
94948
95152
|
const failedRuntime = this.#executionProcesses.get(options2.sessionId);
|
|
95153
|
+
const unusableNativeSessionId = error62 instanceof AcpExecutionError && error62.code === NATIVE_SESSION_UNUSABLE_ERROR_CODE ? failedRuntime?.nativeSessionId() : void 0;
|
|
94949
95154
|
if (failedRuntime !== void 0) {
|
|
94950
95155
|
await this.#retireSessionProcess(
|
|
94951
95156
|
options2.sessionId,
|
|
@@ -94956,6 +95161,9 @@ var SessionManager2 = class {
|
|
|
94956
95161
|
if (cancelled()) {
|
|
94957
95162
|
return { stopReason: "cancelled" };
|
|
94958
95163
|
}
|
|
95164
|
+
if (unusableNativeSessionId !== void 0 && unusableNativeSessionId.length > 0) {
|
|
95165
|
+
await this.#continueInNewNativeSession(options2, unusableNativeSessionId);
|
|
95166
|
+
}
|
|
94959
95167
|
if (error62 instanceof AcpExecutionError) {
|
|
94960
95168
|
throw error62;
|
|
94961
95169
|
}
|
|
@@ -94972,6 +95180,42 @@ var SessionManager2 = class {
|
|
|
94972
95180
|
}
|
|
94973
95181
|
}
|
|
94974
95182
|
});
|
|
95183
|
+
/**
|
|
95184
|
+
* Moves a Session off a native conversation the Agent can no longer continue before its failed prompt settles,
|
|
95185
|
+
* so the member's next prompt reaches a conversation that works. When this fails, the next prompt fails the same
|
|
95186
|
+
* way and tries again.
|
|
95187
|
+
*/
|
|
95188
|
+
async #continueInNewNativeSession(options, unusableNativeSessionId) {
|
|
95189
|
+
if (options.adapter.continueInNewSession === void 0) {
|
|
95190
|
+
return;
|
|
95191
|
+
}
|
|
95192
|
+
try {
|
|
95193
|
+
await this.#executionProcesses.prepare(
|
|
95194
|
+
options.sessionId,
|
|
95195
|
+
async () => this.#startRetainedSessionProcess(
|
|
95196
|
+
options,
|
|
95197
|
+
async () => await AgentSession.continueUnusable(
|
|
95198
|
+
options,
|
|
95199
|
+
unusableNativeSessionId,
|
|
95200
|
+
() => this.#runtimeObserver,
|
|
95201
|
+
this.#executions.agentCommand,
|
|
95202
|
+
this.#store,
|
|
95203
|
+
options.adapter,
|
|
95204
|
+
this.promptSuggestions,
|
|
95205
|
+
this.#timer
|
|
95206
|
+
)
|
|
95207
|
+
)
|
|
95208
|
+
);
|
|
95209
|
+
} catch (error62) {
|
|
95210
|
+
if (options.signal.aborted) {
|
|
95211
|
+
return;
|
|
95212
|
+
}
|
|
95213
|
+
console.warn(
|
|
95214
|
+
`[${options.agent.id}-acp] The Session could not continue in a new native conversation`,
|
|
95215
|
+
error62
|
|
95216
|
+
);
|
|
95217
|
+
}
|
|
95218
|
+
}
|
|
94975
95219
|
respondPermission = async (options) => {
|
|
94976
95220
|
this.#assertOpen(options.sessionId);
|
|
94977
95221
|
const runtime = this.#executionProcesses.get(options.sessionId);
|
|
@@ -96354,7 +96598,7 @@ var SessionTurns = class {
|
|
|
96354
96598
|
|
|
96355
96599
|
// src/engine/session/workspace/workspace-directory.ts
|
|
96356
96600
|
import { homedir as homedir4 } from "node:os";
|
|
96357
|
-
import { basename as basename8, dirname as dirname10, isAbsolute as isAbsolute16, join as
|
|
96601
|
+
import { basename as basename8, dirname as dirname10, isAbsolute as isAbsolute16, join as join29, normalize as normalize2, relative as relative3 } from "node:path";
|
|
96358
96602
|
|
|
96359
96603
|
// src/engine/session/workspace/local-authorization-error.ts
|
|
96360
96604
|
var LocalAuthorizationError = class extends OperationError {
|
|
@@ -96500,7 +96744,7 @@ var WorkspaceDirectoryService = class {
|
|
|
96500
96744
|
continue;
|
|
96501
96745
|
}
|
|
96502
96746
|
try {
|
|
96503
|
-
const path6 = await this.resolvePath(
|
|
96747
|
+
const path6 = await this.resolvePath(join29(target, child.name), signal);
|
|
96504
96748
|
entries.push({ directoryId: encodePath(path6), name: child.name });
|
|
96505
96749
|
} catch (cause) {
|
|
96506
96750
|
signal.throwIfAborted();
|
|
@@ -96685,13 +96929,13 @@ function buildSessionLayer(options) {
|
|
|
96685
96929
|
|
|
96686
96930
|
// src/engine/session/content/external-content-store.ts
|
|
96687
96931
|
import { createHash as createHash8 } from "node:crypto";
|
|
96688
|
-
import { extname as extname2, join as
|
|
96932
|
+
import { extname as extname2, join as join31 } from "node:path";
|
|
96689
96933
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
96690
96934
|
|
|
96691
96935
|
// src/engine/storage/files/scratch-directory.ts
|
|
96692
96936
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
96693
96937
|
import { lstat as lstat4, mkdir as mkdir5, readdir as readdir6, readFile as readFile7, realpath as realpath7, rename as rename4, rm as rm5, stat as stat6, utimes, writeFile as writeFile2 } from "node:fs/promises";
|
|
96694
|
-
import { dirname as dirname11, join as
|
|
96938
|
+
import { dirname as dirname11, join as join30 } from "node:path";
|
|
96695
96939
|
async function atomicWrite(path6, bytes, signal) {
|
|
96696
96940
|
const temporary = `${path6}.${randomUUID18()}.tmp`;
|
|
96697
96941
|
try {
|
|
@@ -96705,7 +96949,7 @@ async function atomicWrite(path6, bytes, signal) {
|
|
|
96705
96949
|
var ScratchDirectory = class {
|
|
96706
96950
|
#root;
|
|
96707
96951
|
constructor(parent) {
|
|
96708
|
-
this.#root =
|
|
96952
|
+
this.#root = join30(parent, randomUUID18());
|
|
96709
96953
|
}
|
|
96710
96954
|
/** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
|
|
96711
96955
|
refreshLease = async (leaseMilliseconds) => {
|
|
@@ -96716,7 +96960,7 @@ var ScratchDirectory = class {
|
|
|
96716
96960
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
96717
96961
|
continue;
|
|
96718
96962
|
}
|
|
96719
|
-
const path6 =
|
|
96963
|
+
const path6 = join30(dirname11(this.#root), directory.name);
|
|
96720
96964
|
if (path6 === this.#root) {
|
|
96721
96965
|
continue;
|
|
96722
96966
|
}
|
|
@@ -96731,10 +96975,10 @@ var ScratchDirectory = class {
|
|
|
96731
96975
|
};
|
|
96732
96976
|
/** Writes `bytes` atomically to `<group>/<name>` with owner-only permissions and returns the path. */
|
|
96733
96977
|
write = async (group, name2, bytes, signal) => {
|
|
96734
|
-
const directory =
|
|
96978
|
+
const directory = join30(this.#root, group);
|
|
96735
96979
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
96736
96980
|
signal.throwIfAborted();
|
|
96737
|
-
const path6 =
|
|
96981
|
+
const path6 = join30(directory, name2);
|
|
96738
96982
|
await atomicWrite(path6, bytes, signal);
|
|
96739
96983
|
return path6;
|
|
96740
96984
|
};
|
|
@@ -96785,7 +97029,7 @@ var LocalExternalContentStore = class {
|
|
|
96785
97029
|
#expirationTimer;
|
|
96786
97030
|
#cleanup = Promise.resolve();
|
|
96787
97031
|
constructor(stateDirectory) {
|
|
96788
|
-
this.#scratch = new ScratchDirectory(
|
|
97032
|
+
this.#scratch = new ScratchDirectory(join31(stateDirectory, "tmp", "session-content"));
|
|
96789
97033
|
this.#expirationTimer = setInterval(() => {
|
|
96790
97034
|
void this.#expire().catch(() => void 0);
|
|
96791
97035
|
}, 6e4);
|
|
@@ -97193,7 +97437,7 @@ var AgentProcessPool = class {
|
|
|
97193
97437
|
|
|
97194
97438
|
// src/engine/session/settings/agent-settings-cache.ts
|
|
97195
97439
|
import { createHash as createHash9, randomUUID as randomUUID19 } from "node:crypto";
|
|
97196
|
-
import { join as
|
|
97440
|
+
import { join as join32 } from "node:path";
|
|
97197
97441
|
var CACHE_FILE_LIMIT = 32 * 1024 * 1024;
|
|
97198
97442
|
var CACHE_FORMAT = 1;
|
|
97199
97443
|
var generationSchema = external_exports.union([external_exports.literal("initial"), external_exports.uuid()]);
|
|
@@ -97258,8 +97502,8 @@ var AgentSettingsCache = class {
|
|
|
97258
97502
|
#generationPath;
|
|
97259
97503
|
#generation = 0;
|
|
97260
97504
|
constructor(stateDirectory) {
|
|
97261
|
-
this.#directory =
|
|
97262
|
-
this.#generationPath =
|
|
97505
|
+
this.#directory = join32(stateDirectory, "agent-settings");
|
|
97506
|
+
this.#generationPath = join32(this.#directory, "generation");
|
|
97263
97507
|
}
|
|
97264
97508
|
get generation() {
|
|
97265
97509
|
return this.#generation;
|
|
@@ -97270,7 +97514,7 @@ var AgentSettingsCache = class {
|
|
|
97270
97514
|
};
|
|
97271
97515
|
open = async (agent2, signal) => {
|
|
97272
97516
|
const inspections = /* @__PURE__ */ new Map();
|
|
97273
|
-
const path6 =
|
|
97517
|
+
const path6 = join32(this.#directory, `${hash2(agent2.id)}.json`);
|
|
97274
97518
|
const fingerprint = hash2([
|
|
97275
97519
|
agent2.agentVersion,
|
|
97276
97520
|
agent2.adapterVersion,
|
|
@@ -98295,7 +98539,7 @@ function createContentWriteCommands(context) {
|
|
|
98295
98539
|
import { WebSocket as WebSocket5 } from "undici";
|
|
98296
98540
|
|
|
98297
98541
|
// src/engine/session/content/session-files.ts
|
|
98298
|
-
import { basename as basename9, extname as extname3, isAbsolute as isAbsolute17, join as
|
|
98542
|
+
import { basename as basename9, extname as extname3, isAbsolute as isAbsolute17, join as join33, normalize as normalize3, resolve as resolve17 } from "node:path";
|
|
98299
98543
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
98300
98544
|
function requestedPath(value) {
|
|
98301
98545
|
if (value.includes("\0")) {
|
|
@@ -98319,7 +98563,7 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
98319
98563
|
if (isAbsolute17(requested.path) && normalize3(requested.path) !== requested.path) {
|
|
98320
98564
|
return null;
|
|
98321
98565
|
}
|
|
98322
|
-
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute17(requested.path) ? [
|
|
98566
|
+
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute17(requested.path) ? [join33(workingDirectory, requested.path), requested.path] : [resolve17(workingDirectory, requested.path)];
|
|
98323
98567
|
for (const candidate of candidates) {
|
|
98324
98568
|
if (!isAbsolute17(candidate) || normalize3(candidate) !== candidate) {
|
|
98325
98569
|
continue;
|
|
@@ -100896,4 +101140,4 @@ export {
|
|
|
100896
101140
|
* MIT Licensed
|
|
100897
101141
|
*)
|
|
100898
101142
|
*/
|
|
100899
|
-
//# sourceMappingURL=chunk-
|
|
101143
|
+
//# sourceMappingURL=chunk-TPFOWHSZ.js.map
|