@moxt-ai/mobius 0.0.92 → 0.0.94
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/acp/activity.js +1 -1
- package/dist/acp/activity.js.map +1 -1
- package/dist/acp/codex/agent.d.ts.map +1 -1
- package/dist/acp/codex/agent.js +4 -8
- package/dist/acp/codex/agent.js.map +1 -1
- package/dist/acp/session-manager.d.ts +4 -1
- package/dist/acp/session-manager.d.ts.map +1 -1
- package/dist/acp/session-manager.js +77 -4
- package/dist/acp/session-manager.js.map +1 -1
- package/dist/acp/session-store.d.ts +3 -10
- package/dist/acp/session-store.d.ts.map +1 -1
- package/dist/acp/session-store.js +1 -131
- package/dist/acp/session-store.js.map +1 -1
- package/dist/audit/audit-store.d.ts +3 -4
- package/dist/audit/audit-store.d.ts.map +1 -1
- package/dist/audit/audit-store.js +10 -37
- package/dist/audit/audit-store.js.map +1 -1
- package/dist/cli.js +417 -330
- package/dist/cli.js.map +3 -3
- package/dist/config.d.ts +0 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -4
- package/dist/config.js.map +1 -1
- package/dist/daemon-manager.d.ts.map +1 -1
- package/dist/daemon-manager.js +13 -19
- package/dist/daemon-manager.js.map +1 -1
- package/dist/index.js +354 -268
- package/dist/index.js.map +3 -3
- package/dist/native-sessions/codex-history.d.ts.map +1 -1
- package/dist/native-sessions/codex-history.js +38 -8
- package/dist/native-sessions/codex-history.js.map +1 -1
- package/dist/native-sessions/service.d.ts +1 -0
- package/dist/native-sessions/service.d.ts.map +1 -1
- package/dist/native-sessions/service.js +99 -1
- package/dist/native-sessions/service.js.map +1 -1
- package/dist/pairing/pair-local-machine.d.ts.map +1 -1
- package/dist/pairing/pair-local-machine.js +0 -1
- package/dist/pairing/pair-local-machine.js.map +1 -1
- package/dist/relay-connection/coalescing-narration-publisher.d.ts +1 -1
- package/dist/relay-connection/coalescing-narration-publisher.js +1 -1
- package/dist/relay-connection/coalescing-text-publisher.d.ts +1 -1
- package/dist/relay-connection/coalescing-text-publisher.js +1 -1
- package/dist/relay-connection/session-event-outbox.d.ts +4 -5
- package/dist/relay-connection/session-event-outbox.d.ts.map +1 -1
- package/dist/relay-connection/session-event-outbox.js +31 -21
- package/dist/relay-connection/session-event-outbox.js.map +1 -1
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +13 -19
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.d.ts +0 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +348 -260
- package/dist/runtime.js.map +3 -3
- package/dist/storage/runtime-installation-store.d.ts +0 -1
- package/dist/storage/runtime-installation-store.d.ts.map +1 -1
- package/dist/storage/runtime-installation-store.js +0 -1
- package/dist/storage/runtime-installation-store.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all2) => {
|
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
9
|
import { constants as constants2 } from "node:fs";
|
|
10
|
-
import { mkdir as mkdir6, open as
|
|
10
|
+
import { mkdir as mkdir6, open as open6 } from "node:fs/promises";
|
|
11
11
|
import { resolve as resolve7 } from "node:path";
|
|
12
12
|
|
|
13
13
|
// ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
@@ -3381,7 +3381,7 @@ var program = new Command();
|
|
|
3381
3381
|
// package.json
|
|
3382
3382
|
var package_default = {
|
|
3383
3383
|
name: "@moxt-ai/mobius",
|
|
3384
|
-
version: "0.0.
|
|
3384
|
+
version: "0.0.94",
|
|
3385
3385
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
3386
3386
|
type: "module",
|
|
3387
3387
|
bin: {
|
|
@@ -25186,18 +25186,17 @@ function effortValues(model) {
|
|
|
25186
25186
|
}
|
|
25187
25187
|
function modelSetting(models, currentValue) {
|
|
25188
25188
|
const values = modelValues(models);
|
|
25189
|
-
const current =
|
|
25189
|
+
const current = values.some((value) => value.value === currentValue) ? currentValue : models.find((model) => model.isDefault === true)?.id ?? values[0]?.value ?? "";
|
|
25190
25190
|
if (current.length === 0) {
|
|
25191
25191
|
return null;
|
|
25192
25192
|
}
|
|
25193
|
-
const options = values.some((value) => value.value === current) ? values : [{ description: "", name: current, value: current }, ...values];
|
|
25194
25193
|
return {
|
|
25195
25194
|
category: "model",
|
|
25196
25195
|
currentValue: current,
|
|
25197
25196
|
description: "Model Codex uses for the session",
|
|
25198
25197
|
id: MODEL_SETTING_ID,
|
|
25199
25198
|
name: "Model",
|
|
25200
|
-
options,
|
|
25199
|
+
options: values,
|
|
25201
25200
|
type: "select"
|
|
25202
25201
|
};
|
|
25203
25202
|
}
|
|
@@ -27154,41 +27153,41 @@ var DiscoveryAcpHandler = class {
|
|
|
27154
27153
|
};
|
|
27155
27154
|
function readableAcpStream(input2) {
|
|
27156
27155
|
let byteLength = 0;
|
|
27157
|
-
let
|
|
27156
|
+
let open7 = true;
|
|
27158
27157
|
return new ReadableStream({
|
|
27159
27158
|
start(controller) {
|
|
27160
27159
|
input2.on("data", (chunk) => {
|
|
27161
|
-
if (!
|
|
27160
|
+
if (!open7) {
|
|
27162
27161
|
return;
|
|
27163
27162
|
}
|
|
27164
27163
|
if (!(chunk instanceof Uint8Array)) {
|
|
27165
|
-
|
|
27164
|
+
open7 = false;
|
|
27166
27165
|
controller.error(new Error("ACP adapter produced invalid output"));
|
|
27167
27166
|
return;
|
|
27168
27167
|
}
|
|
27169
27168
|
byteLength += chunk.byteLength;
|
|
27170
27169
|
if (byteLength > ACP_OUTPUT_LIMIT_BYTES) {
|
|
27171
|
-
|
|
27170
|
+
open7 = false;
|
|
27172
27171
|
controller.error(new Error("ACP adapter output limit exceeded"));
|
|
27173
27172
|
return;
|
|
27174
27173
|
}
|
|
27175
27174
|
controller.enqueue(new Uint8Array(chunk));
|
|
27176
27175
|
});
|
|
27177
27176
|
input2.once("end", () => {
|
|
27178
|
-
if (
|
|
27179
|
-
|
|
27177
|
+
if (open7) {
|
|
27178
|
+
open7 = false;
|
|
27180
27179
|
controller.close();
|
|
27181
27180
|
}
|
|
27182
27181
|
});
|
|
27183
27182
|
input2.once("error", (error62) => {
|
|
27184
|
-
if (
|
|
27185
|
-
|
|
27183
|
+
if (open7) {
|
|
27184
|
+
open7 = false;
|
|
27186
27185
|
controller.error(error62);
|
|
27187
27186
|
}
|
|
27188
27187
|
});
|
|
27189
27188
|
},
|
|
27190
27189
|
cancel() {
|
|
27191
|
-
|
|
27190
|
+
open7 = false;
|
|
27192
27191
|
}
|
|
27193
27192
|
});
|
|
27194
27193
|
}
|
|
@@ -29127,7 +29126,10 @@ var nativeSessionTurnForkCommandSchema = external_exports.strictObject({
|
|
|
29127
29126
|
title: external_exports.string().max(500)
|
|
29128
29127
|
}).readonly();
|
|
29129
29128
|
var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
29129
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
29130
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
|
|
29130
29131
|
external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
|
|
29132
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
|
|
29131
29133
|
external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifier }).readonly(),
|
|
29132
29134
|
external_exports.strictObject({
|
|
29133
29135
|
...identity,
|
|
@@ -29147,7 +29149,10 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
|
29147
29149
|
}).readonly()
|
|
29148
29150
|
]);
|
|
29149
29151
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
29152
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
29153
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
|
|
29150
29154
|
external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
|
|
29155
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
|
|
29151
29156
|
external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifier }).readonly(),
|
|
29152
29157
|
external_exports.strictObject({
|
|
29153
29158
|
...identity,
|
|
@@ -29174,6 +29179,7 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
|
29174
29179
|
]);
|
|
29175
29180
|
var nativeSessionEntrySchema = external_exports.strictObject({
|
|
29176
29181
|
entryId: identifier,
|
|
29182
|
+
nativeSessionId: identifier,
|
|
29177
29183
|
title: external_exports.string().max(500),
|
|
29178
29184
|
directoryId,
|
|
29179
29185
|
directoryLabel: external_exports.string().min(1).max(2048),
|
|
@@ -29185,6 +29191,18 @@ var resultEnvelope = {
|
|
|
29185
29191
|
kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
|
|
29186
29192
|
};
|
|
29187
29193
|
var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
29194
|
+
external_exports.strictObject({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifier }).readonly(),
|
|
29195
|
+
external_exports.strictObject({
|
|
29196
|
+
...resultEnvelope,
|
|
29197
|
+
action: external_exports.literal("linked-history"),
|
|
29198
|
+
targetSessionId: identifier,
|
|
29199
|
+
history: sessionHistorySchema
|
|
29200
|
+
}).readonly(),
|
|
29201
|
+
external_exports.strictObject({
|
|
29202
|
+
...resultEnvelope,
|
|
29203
|
+
action: external_exports.literal("unlinked-history"),
|
|
29204
|
+
targetSessionId: identifier
|
|
29205
|
+
}).readonly(),
|
|
29188
29206
|
external_exports.strictObject({
|
|
29189
29207
|
...resultEnvelope,
|
|
29190
29208
|
action: external_exports.literal("find"),
|
|
@@ -29214,6 +29232,13 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
29214
29232
|
history: sessionHistorySchema,
|
|
29215
29233
|
title: external_exports.string().max(500)
|
|
29216
29234
|
}).readonly(),
|
|
29235
|
+
external_exports.strictObject({
|
|
29236
|
+
...resultEnvelope,
|
|
29237
|
+
action: external_exports.literal("history"),
|
|
29238
|
+
entryId: identifier,
|
|
29239
|
+
history: sessionHistorySchema,
|
|
29240
|
+
title: external_exports.string().max(500)
|
|
29241
|
+
}).readonly(),
|
|
29217
29242
|
external_exports.strictObject({
|
|
29218
29243
|
...resultEnvelope,
|
|
29219
29244
|
action: external_exports.literal("delete"),
|
|
@@ -29725,7 +29750,6 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
|
|
|
29725
29750
|
return {
|
|
29726
29751
|
agents: daemonAgents,
|
|
29727
29752
|
defaultWorkspace: connection.defaultWorkspace,
|
|
29728
|
-
auditDatabasePath: connection.auditDatabasePath,
|
|
29729
29753
|
bindingId: "workspace",
|
|
29730
29754
|
catalog: new LocalAgentCatalog(daemonAgents, installableAgents),
|
|
29731
29755
|
channelId: connection.channelId,
|
|
@@ -29738,8 +29762,8 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
|
|
|
29738
29762
|
|
|
29739
29763
|
// src/daemon-manager.ts
|
|
29740
29764
|
import { spawn as spawn6 } from "node:child_process";
|
|
29741
|
-
import { createHash as
|
|
29742
|
-
import {
|
|
29765
|
+
import { createHash as createHash6, randomBytes } from "node:crypto";
|
|
29766
|
+
import { readFile as readFile3, unlink as unlink2, writeFile as writeFile4 } from "node:fs/promises";
|
|
29743
29767
|
import { createConnection, createServer } from "node:net";
|
|
29744
29768
|
import { tmpdir } from "node:os";
|
|
29745
29769
|
import { join as join18 } from "node:path";
|
|
@@ -30157,7 +30181,6 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
30157
30181
|
return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
|
|
30158
30182
|
};
|
|
30159
30183
|
connectionPath = (connectionId2) => join15(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
|
|
30160
|
-
auditDatabasePath = (connectionId2) => join15(this.stateDirectory, "audit", `${validateConnectionId(connectionId2)}.sqlite`);
|
|
30161
30184
|
channelIndexPath = (channelId) => join15(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
|
|
30162
30185
|
readConnection = async (connectionId2, signal) => {
|
|
30163
30186
|
const stored = decodeConnection(
|
|
@@ -30596,7 +30619,6 @@ function buildPairedDaemon(installation, connection, defaultWorkspace, inventory
|
|
|
30596
30619
|
config: createDaemonConfig(
|
|
30597
30620
|
{
|
|
30598
30621
|
defaultWorkspace,
|
|
30599
|
-
auditDatabasePath: installation.auditDatabasePath(connection.connectionId),
|
|
30600
30622
|
channelId: connection.channelId,
|
|
30601
30623
|
relayUrl
|
|
30602
30624
|
},
|
|
@@ -30685,55 +30707,24 @@ async function resumeLocalMachine(arguments_, signal = new AbortController().sig
|
|
|
30685
30707
|
}
|
|
30686
30708
|
|
|
30687
30709
|
// src/audit/audit-store.ts
|
|
30688
|
-
|
|
30689
|
-
import { dirname as dirname4 } from "node:path";
|
|
30690
|
-
import { DatabaseSync } from "node:sqlite";
|
|
30710
|
+
var MAX_AUDIT_RECORDS = 1024;
|
|
30691
30711
|
var AuditStore = class {
|
|
30692
|
-
|
|
30693
|
-
|
|
30694
|
-
|
|
30695
|
-
|
|
30696
|
-
|
|
30697
|
-
|
|
30698
|
-
|
|
30699
|
-
recorded_at TEXT NOT NULL,
|
|
30700
|
-
event TEXT NOT NULL,
|
|
30701
|
-
command_id TEXT NOT NULL,
|
|
30702
|
-
session_id TEXT NOT NULL,
|
|
30703
|
-
details_json TEXT NOT NULL DEFAULT '{}'
|
|
30704
|
-
) STRICT
|
|
30705
|
-
`);
|
|
30706
|
-
const columns = this.database.prepare("PRAGMA table_info(audit_events)").all();
|
|
30707
|
-
if (!columns.some((column) => Reflect.get(column, "name") === "details_json")) {
|
|
30708
|
-
this.database.exec("ALTER TABLE audit_events ADD COLUMN details_json TEXT NOT NULL DEFAULT '{}'");
|
|
30709
|
-
}
|
|
30710
|
-
}
|
|
30711
|
-
record(record2) {
|
|
30712
|
-
this.database.prepare(
|
|
30713
|
-
`
|
|
30714
|
-
INSERT INTO audit_events (
|
|
30715
|
-
recorded_at,
|
|
30716
|
-
event,
|
|
30717
|
-
command_id,
|
|
30718
|
-
session_id,
|
|
30719
|
-
details_json
|
|
30720
|
-
) VALUES (?, ?, ?, ?, ?)
|
|
30721
|
-
`
|
|
30722
|
-
).run(
|
|
30723
|
-
(/* @__PURE__ */ new Date()).toISOString(),
|
|
30724
|
-
record2.event,
|
|
30725
|
-
record2.commandId,
|
|
30726
|
-
record2.sessionId,
|
|
30727
|
-
JSON.stringify(record2.details ?? {})
|
|
30712
|
+
#records = [];
|
|
30713
|
+
record = (record2) => {
|
|
30714
|
+
if (this.#records.length === MAX_AUDIT_RECORDS) {
|
|
30715
|
+
this.#records.shift();
|
|
30716
|
+
}
|
|
30717
|
+
this.#records.push(
|
|
30718
|
+
record2.details === void 0 ? { ...record2 } : { ...record2, details: { ...record2.details } }
|
|
30728
30719
|
);
|
|
30729
|
-
}
|
|
30730
|
-
close() {
|
|
30731
|
-
this.
|
|
30732
|
-
}
|
|
30720
|
+
};
|
|
30721
|
+
close = () => {
|
|
30722
|
+
this.#records.length = 0;
|
|
30723
|
+
};
|
|
30733
30724
|
};
|
|
30734
30725
|
|
|
30735
30726
|
// src/run-daemon.ts
|
|
30736
|
-
import { createHash as
|
|
30727
|
+
import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
|
|
30737
30728
|
import { basename as basename7 } from "node:path";
|
|
30738
30729
|
import { styleText } from "node:util";
|
|
30739
30730
|
import { fetch as fetch5, WebSocket as WebSocket2 } from "undici";
|
|
@@ -34217,7 +34208,7 @@ var attention = {
|
|
|
34217
34208
|
};
|
|
34218
34209
|
function resolveAllAttention(events, context) {
|
|
34219
34210
|
let index2 = -1;
|
|
34220
|
-
let
|
|
34211
|
+
let open7;
|
|
34221
34212
|
let group;
|
|
34222
34213
|
let text3;
|
|
34223
34214
|
let openingSequence;
|
|
@@ -34227,16 +34218,16 @@ function resolveAllAttention(events, context) {
|
|
|
34227
34218
|
let offset;
|
|
34228
34219
|
while (++index2 < events.length) {
|
|
34229
34220
|
if (events[index2][0] === "enter" && events[index2][1].type === "attentionSequence" && events[index2][1]._close) {
|
|
34230
|
-
|
|
34231
|
-
while (
|
|
34232
|
-
if (events[
|
|
34233
|
-
context.sliceSerialize(events[
|
|
34234
|
-
if ((events[
|
|
34221
|
+
open7 = index2;
|
|
34222
|
+
while (open7--) {
|
|
34223
|
+
if (events[open7][0] === "exit" && events[open7][1].type === "attentionSequence" && events[open7][1]._open && // If the markers are the same:
|
|
34224
|
+
context.sliceSerialize(events[open7][1]).charCodeAt(0) === context.sliceSerialize(events[index2][1]).charCodeAt(0)) {
|
|
34225
|
+
if ((events[open7][1]._close || events[index2][1]._open) && (events[index2][1].end.offset - events[index2][1].start.offset) % 3 && !((events[open7][1].end.offset - events[open7][1].start.offset + events[index2][1].end.offset - events[index2][1].start.offset) % 3)) {
|
|
34235
34226
|
continue;
|
|
34236
34227
|
}
|
|
34237
|
-
use = events[
|
|
34228
|
+
use = events[open7][1].end.offset - events[open7][1].start.offset > 1 && events[index2][1].end.offset - events[index2][1].start.offset > 1 ? 2 : 1;
|
|
34238
34229
|
const start = {
|
|
34239
|
-
...events[
|
|
34230
|
+
...events[open7][1].end
|
|
34240
34231
|
};
|
|
34241
34232
|
const end = {
|
|
34242
34233
|
...events[index2][1].start
|
|
@@ -34247,7 +34238,7 @@ function resolveAllAttention(events, context) {
|
|
|
34247
34238
|
type: use > 1 ? "strongSequence" : "emphasisSequence",
|
|
34248
34239
|
start,
|
|
34249
34240
|
end: {
|
|
34250
|
-
...events[
|
|
34241
|
+
...events[open7][1].end
|
|
34251
34242
|
}
|
|
34252
34243
|
};
|
|
34253
34244
|
closingSequence = {
|
|
@@ -34260,7 +34251,7 @@ function resolveAllAttention(events, context) {
|
|
|
34260
34251
|
text3 = {
|
|
34261
34252
|
type: use > 1 ? "strongText" : "emphasisText",
|
|
34262
34253
|
start: {
|
|
34263
|
-
...events[
|
|
34254
|
+
...events[open7][1].end
|
|
34264
34255
|
},
|
|
34265
34256
|
end: {
|
|
34266
34257
|
...events[index2][1].start
|
|
@@ -34275,18 +34266,18 @@ function resolveAllAttention(events, context) {
|
|
|
34275
34266
|
...closingSequence.end
|
|
34276
34267
|
}
|
|
34277
34268
|
};
|
|
34278
|
-
events[
|
|
34269
|
+
events[open7][1].end = {
|
|
34279
34270
|
...openingSequence.start
|
|
34280
34271
|
};
|
|
34281
34272
|
events[index2][1].start = {
|
|
34282
34273
|
...closingSequence.end
|
|
34283
34274
|
};
|
|
34284
34275
|
nextEvents = [];
|
|
34285
|
-
if (events[
|
|
34286
|
-
nextEvents = push(nextEvents, [["enter", events[
|
|
34276
|
+
if (events[open7][1].end.offset - events[open7][1].start.offset) {
|
|
34277
|
+
nextEvents = push(nextEvents, [["enter", events[open7][1], context], ["exit", events[open7][1], context]]);
|
|
34287
34278
|
}
|
|
34288
34279
|
nextEvents = push(nextEvents, [["enter", group, context], ["enter", openingSequence, context], ["exit", openingSequence, context], ["enter", text3, context]]);
|
|
34289
|
-
nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(
|
|
34280
|
+
nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open7 + 1, index2), context));
|
|
34290
34281
|
nextEvents = push(nextEvents, [["exit", text3, context], ["enter", closingSequence, context], ["exit", closingSequence, context], ["exit", group, context]]);
|
|
34291
34282
|
if (events[index2][1].end.offset - events[index2][1].start.offset) {
|
|
34292
34283
|
offset = 2;
|
|
@@ -34294,8 +34285,8 @@ function resolveAllAttention(events, context) {
|
|
|
34294
34285
|
} else {
|
|
34295
34286
|
offset = 0;
|
|
34296
34287
|
}
|
|
34297
|
-
splice(events,
|
|
34298
|
-
index2 =
|
|
34288
|
+
splice(events, open7 - 1, index2 - open7 + 3, nextEvents);
|
|
34289
|
+
index2 = open7 + nextEvents.length - offset - 2;
|
|
34299
34290
|
break;
|
|
34300
34291
|
}
|
|
34301
34292
|
}
|
|
@@ -34327,10 +34318,10 @@ function tokenizeAttention(effects, ok2) {
|
|
|
34327
34318
|
}
|
|
34328
34319
|
const token = effects.exit("attentionSequence");
|
|
34329
34320
|
const after = classifyCharacter(code);
|
|
34330
|
-
const
|
|
34321
|
+
const open7 = !after || after === 2 && before || attentionMarkers2.includes(code);
|
|
34331
34322
|
const close = !before || before === 2 && after || attentionMarkers2.includes(previous2);
|
|
34332
|
-
token._open = Boolean(marker === 42 ?
|
|
34333
|
-
token._close = Boolean(marker === 42 ? close : close && (after || !
|
|
34323
|
+
token._open = Boolean(marker === 42 ? open7 : open7 && (before || !close));
|
|
34324
|
+
token._close = Boolean(marker === 42 ? close : close && (after || !open7));
|
|
34334
34325
|
return ok2(code);
|
|
34335
34326
|
}
|
|
34336
34327
|
}
|
|
@@ -34354,9 +34345,9 @@ function tokenizeAutolink(effects, ok2, nok) {
|
|
|
34354
34345
|
effects.consume(code);
|
|
34355
34346
|
effects.exit("autolinkMarker");
|
|
34356
34347
|
effects.enter("autolinkProtocol");
|
|
34357
|
-
return
|
|
34348
|
+
return open7;
|
|
34358
34349
|
}
|
|
34359
|
-
function
|
|
34350
|
+
function open7(code) {
|
|
34360
34351
|
if (asciiAlpha(code)) {
|
|
34361
34352
|
effects.consume(code);
|
|
34362
34353
|
return schemeOrEmailAtext;
|
|
@@ -34556,9 +34547,9 @@ function tokenizeCharacterReference(effects, ok2, nok) {
|
|
|
34556
34547
|
effects.enter("characterReferenceMarker");
|
|
34557
34548
|
effects.consume(code);
|
|
34558
34549
|
effects.exit("characterReferenceMarker");
|
|
34559
|
-
return
|
|
34550
|
+
return open7;
|
|
34560
34551
|
}
|
|
34561
|
-
function
|
|
34552
|
+
function open7(code) {
|
|
34562
34553
|
if (code === 35) {
|
|
34563
34554
|
effects.enter("characterReferenceMarkerNumeric");
|
|
34564
34555
|
effects.consume(code);
|
|
@@ -35927,9 +35918,9 @@ function tokenizeHtmlFlow(effects, ok2, nok) {
|
|
|
35927
35918
|
effects.enter("htmlFlow");
|
|
35928
35919
|
effects.enter("htmlFlowData");
|
|
35929
35920
|
effects.consume(code);
|
|
35930
|
-
return
|
|
35921
|
+
return open7;
|
|
35931
35922
|
}
|
|
35932
|
-
function
|
|
35923
|
+
function open7(code) {
|
|
35933
35924
|
if (code === 33) {
|
|
35934
35925
|
effects.consume(code);
|
|
35935
35926
|
return declarationOpen;
|
|
@@ -36277,9 +36268,9 @@ function tokenizeHtmlText(effects, ok2, nok) {
|
|
|
36277
36268
|
effects.enter("htmlText");
|
|
36278
36269
|
effects.enter("htmlTextData");
|
|
36279
36270
|
effects.consume(code);
|
|
36280
|
-
return
|
|
36271
|
+
return open7;
|
|
36281
36272
|
}
|
|
36282
|
-
function
|
|
36273
|
+
function open7(code) {
|
|
36283
36274
|
if (code === 33) {
|
|
36284
36275
|
effects.consume(code);
|
|
36285
36276
|
return declarationOpen;
|
|
@@ -36605,12 +36596,12 @@ function resolveToLabelEnd(events, context) {
|
|
|
36605
36596
|
let index2 = events.length;
|
|
36606
36597
|
let offset = 0;
|
|
36607
36598
|
let token;
|
|
36608
|
-
let
|
|
36599
|
+
let open7;
|
|
36609
36600
|
let close;
|
|
36610
36601
|
let media;
|
|
36611
36602
|
while (index2--) {
|
|
36612
36603
|
token = events[index2][1];
|
|
36613
|
-
if (
|
|
36604
|
+
if (open7) {
|
|
36614
36605
|
if (token.type === "link" || token.type === "labelLink" && token._inactive) {
|
|
36615
36606
|
break;
|
|
36616
36607
|
}
|
|
@@ -36619,7 +36610,7 @@ function resolveToLabelEnd(events, context) {
|
|
|
36619
36610
|
}
|
|
36620
36611
|
} else if (close) {
|
|
36621
36612
|
if (events[index2][0] === "enter" && (token.type === "labelImage" || token.type === "labelLink") && !token._balanced) {
|
|
36622
|
-
|
|
36613
|
+
open7 = index2;
|
|
36623
36614
|
if (token.type !== "labelLink") {
|
|
36624
36615
|
offset = 2;
|
|
36625
36616
|
break;
|
|
@@ -36630,9 +36621,9 @@ function resolveToLabelEnd(events, context) {
|
|
|
36630
36621
|
}
|
|
36631
36622
|
}
|
|
36632
36623
|
const group = {
|
|
36633
|
-
type: events[
|
|
36624
|
+
type: events[open7][1].type === "labelLink" ? "link" : "image",
|
|
36634
36625
|
start: {
|
|
36635
|
-
...events[
|
|
36626
|
+
...events[open7][1].start
|
|
36636
36627
|
},
|
|
36637
36628
|
end: {
|
|
36638
36629
|
...events[events.length - 1][1].end
|
|
@@ -36641,7 +36632,7 @@ function resolveToLabelEnd(events, context) {
|
|
|
36641
36632
|
const label = {
|
|
36642
36633
|
type: "label",
|
|
36643
36634
|
start: {
|
|
36644
|
-
...events[
|
|
36635
|
+
...events[open7][1].start
|
|
36645
36636
|
},
|
|
36646
36637
|
end: {
|
|
36647
36638
|
...events[close][1].end
|
|
@@ -36650,20 +36641,20 @@ function resolveToLabelEnd(events, context) {
|
|
|
36650
36641
|
const text3 = {
|
|
36651
36642
|
type: "labelText",
|
|
36652
36643
|
start: {
|
|
36653
|
-
...events[
|
|
36644
|
+
...events[open7 + offset + 2][1].end
|
|
36654
36645
|
},
|
|
36655
36646
|
end: {
|
|
36656
36647
|
...events[close - 2][1].start
|
|
36657
36648
|
}
|
|
36658
36649
|
};
|
|
36659
36650
|
media = [["enter", group, context], ["enter", label, context]];
|
|
36660
|
-
media = push(media, events.slice(
|
|
36651
|
+
media = push(media, events.slice(open7 + 1, open7 + offset + 3));
|
|
36661
36652
|
media = push(media, [["enter", text3, context]]);
|
|
36662
|
-
media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(
|
|
36653
|
+
media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open7 + offset + 4, close - 3), context));
|
|
36663
36654
|
media = push(media, [["exit", text3, context], events[close - 2], events[close - 1], ["exit", label, context]]);
|
|
36664
36655
|
media = push(media, events.slice(close + 1));
|
|
36665
36656
|
media = push(media, [["exit", group, context]]);
|
|
36666
|
-
splice(events,
|
|
36657
|
+
splice(events, open7, events.length, media);
|
|
36667
36658
|
return events;
|
|
36668
36659
|
}
|
|
36669
36660
|
function tokenizeLabelEnd(effects, ok2, nok) {
|
|
@@ -36808,9 +36799,9 @@ function tokenizeLabelStartImage(effects, ok2, nok) {
|
|
|
36808
36799
|
effects.enter("labelImageMarker");
|
|
36809
36800
|
effects.consume(code);
|
|
36810
36801
|
effects.exit("labelImageMarker");
|
|
36811
|
-
return
|
|
36802
|
+
return open7;
|
|
36812
36803
|
}
|
|
36813
|
-
function
|
|
36804
|
+
function open7(code) {
|
|
36814
36805
|
if (code === 91) {
|
|
36815
36806
|
effects.enter("labelMarker");
|
|
36816
36807
|
effects.consume(code);
|
|
@@ -38114,8 +38105,8 @@ function compiler(options) {
|
|
|
38114
38105
|
return length;
|
|
38115
38106
|
}
|
|
38116
38107
|
function opener(create, and) {
|
|
38117
|
-
return
|
|
38118
|
-
function
|
|
38108
|
+
return open7;
|
|
38109
|
+
function open7(token) {
|
|
38119
38110
|
enter.call(this, create(token), token);
|
|
38120
38111
|
if (and) and.call(this, token);
|
|
38121
38112
|
}
|
|
@@ -38147,18 +38138,18 @@ function compiler(options) {
|
|
|
38147
38138
|
}
|
|
38148
38139
|
function exit2(token, onExitError) {
|
|
38149
38140
|
const node3 = this.stack.pop();
|
|
38150
|
-
const
|
|
38151
|
-
if (!
|
|
38141
|
+
const open7 = this.tokenStack.pop();
|
|
38142
|
+
if (!open7) {
|
|
38152
38143
|
throw new Error("Cannot close `" + token.type + "` (" + stringifyPosition({
|
|
38153
38144
|
start: token.start,
|
|
38154
38145
|
end: token.end
|
|
38155
38146
|
}) + "): it\u2019s not open");
|
|
38156
|
-
} else if (
|
|
38147
|
+
} else if (open7[0].type !== token.type) {
|
|
38157
38148
|
if (onExitError) {
|
|
38158
|
-
onExitError.call(this, token,
|
|
38149
|
+
onExitError.call(this, token, open7[0]);
|
|
38159
38150
|
} else {
|
|
38160
|
-
const handler =
|
|
38161
|
-
handler.call(this, token,
|
|
38151
|
+
const handler = open7[1] || defaultOnError;
|
|
38152
|
+
handler.call(this, token, open7[0]);
|
|
38162
38153
|
}
|
|
38163
38154
|
}
|
|
38164
38155
|
node3.position.end = point2(token.end);
|
|
@@ -39241,9 +39232,6 @@ var AcpHistoryReplay = class {
|
|
|
39241
39232
|
};
|
|
39242
39233
|
|
|
39243
39234
|
// src/acp/session-store.ts
|
|
39244
|
-
import { mkdirSync as mkdirSync2 } from "node:fs";
|
|
39245
|
-
import { dirname as dirname5 } from "node:path";
|
|
39246
|
-
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
39247
39235
|
var AcpStoredSession = class {
|
|
39248
39236
|
additionalDirectories;
|
|
39249
39237
|
agentId;
|
|
@@ -39276,44 +39264,6 @@ var FoundAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
|
39276
39264
|
var DeletedAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
39277
39265
|
found = false;
|
|
39278
39266
|
};
|
|
39279
|
-
function readString3(value, field) {
|
|
39280
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
39281
|
-
throw new Error(`Stored ACP session has an invalid ${field}`);
|
|
39282
|
-
}
|
|
39283
|
-
return value;
|
|
39284
|
-
}
|
|
39285
|
-
function readAdditionalDirectories(value) {
|
|
39286
|
-
if (typeof value !== "string") {
|
|
39287
|
-
throw new Error("Stored ACP session has invalid additional directories");
|
|
39288
|
-
}
|
|
39289
|
-
const decoded = JSON.parse(value);
|
|
39290
|
-
if (!Array.isArray(decoded) || decoded.some((directory) => typeof directory !== "string")) {
|
|
39291
|
-
throw new Error("Stored ACP session has invalid additional directories");
|
|
39292
|
-
}
|
|
39293
|
-
return decoded;
|
|
39294
|
-
}
|
|
39295
|
-
function readPrompted(value) {
|
|
39296
|
-
if (value === 0) {
|
|
39297
|
-
return false;
|
|
39298
|
-
}
|
|
39299
|
-
if (value === 1) {
|
|
39300
|
-
return true;
|
|
39301
|
-
}
|
|
39302
|
-
throw new Error("Stored ACP session has an invalid prompted state");
|
|
39303
|
-
}
|
|
39304
|
-
function decodeSessionRow(row) {
|
|
39305
|
-
if (typeof row !== "object" || row === null || Array.isArray(row)) {
|
|
39306
|
-
throw new Error("Stored ACP session is not an object");
|
|
39307
|
-
}
|
|
39308
|
-
return new AcpStoredSession(
|
|
39309
|
-
readString3(Reflect.get(row, "session_id"), "session ID"),
|
|
39310
|
-
readString3(Reflect.get(row, "agent_id"), "agent ID"),
|
|
39311
|
-
readString3(Reflect.get(row, "native_session_id"), "native session ID"),
|
|
39312
|
-
readString3(Reflect.get(row, "cwd"), "working directory"),
|
|
39313
|
-
readAdditionalDirectories(Reflect.get(row, "additional_directories_json")),
|
|
39314
|
-
readPrompted(Reflect.get(row, "prompted"))
|
|
39315
|
-
);
|
|
39316
|
-
}
|
|
39317
39267
|
var MemoryAcpSessionStore = class {
|
|
39318
39268
|
#sessions = /* @__PURE__ */ new Map();
|
|
39319
39269
|
#deleted = /* @__PURE__ */ new Set();
|
|
@@ -39342,106 +39292,6 @@ var MemoryAcpSessionStore = class {
|
|
|
39342
39292
|
this.#sessions.set(session.sessionId, session);
|
|
39343
39293
|
};
|
|
39344
39294
|
};
|
|
39345
|
-
var SqliteAcpSessionStore = class {
|
|
39346
|
-
#database;
|
|
39347
|
-
constructor(path3) {
|
|
39348
|
-
mkdirSync2(dirname5(path3), { recursive: true });
|
|
39349
|
-
this.#database = new DatabaseSync2(path3);
|
|
39350
|
-
this.#database.exec(`
|
|
39351
|
-
CREATE TABLE IF NOT EXISTS acp_deleted_sessions (session_id TEXT PRIMARY KEY) STRICT;
|
|
39352
|
-
CREATE TABLE IF NOT EXISTS acp_sessions (
|
|
39353
|
-
session_id TEXT PRIMARY KEY,
|
|
39354
|
-
agent_id TEXT NOT NULL,
|
|
39355
|
-
native_session_id TEXT NOT NULL,
|
|
39356
|
-
cwd TEXT NOT NULL,
|
|
39357
|
-
additional_directories_json TEXT NOT NULL,
|
|
39358
|
-
prompted INTEGER NOT NULL DEFAULT 0 CHECK (prompted IN (0, 1)),
|
|
39359
|
-
updated_at TEXT NOT NULL
|
|
39360
|
-
) STRICT
|
|
39361
|
-
`);
|
|
39362
|
-
const columns = this.#database.prepare("PRAGMA table_info(acp_sessions)").all();
|
|
39363
|
-
const hasPromptedColumn = columns.some(
|
|
39364
|
-
(column) => typeof column === "object" && column !== null && Reflect.get(column, "name") === "prompted"
|
|
39365
|
-
);
|
|
39366
|
-
if (!hasPromptedColumn) {
|
|
39367
|
-
this.#database.exec(`
|
|
39368
|
-
ALTER TABLE acp_sessions
|
|
39369
|
-
ADD COLUMN prompted INTEGER NOT NULL DEFAULT 1 CHECK (prompted IN (0, 1))
|
|
39370
|
-
`);
|
|
39371
|
-
}
|
|
39372
|
-
}
|
|
39373
|
-
read = (sessionId) => {
|
|
39374
|
-
if (this.#database.prepare("SELECT session_id FROM acp_deleted_sessions WHERE session_id = ?").get(sessionId) !== void 0) {
|
|
39375
|
-
return new DeletedAcpStoredSession();
|
|
39376
|
-
}
|
|
39377
|
-
const row = this.#database.prepare(
|
|
39378
|
-
`
|
|
39379
|
-
SELECT
|
|
39380
|
-
session_id,
|
|
39381
|
-
agent_id,
|
|
39382
|
-
native_session_id,
|
|
39383
|
-
cwd,
|
|
39384
|
-
additional_directories_json,
|
|
39385
|
-
prompted
|
|
39386
|
-
FROM acp_sessions
|
|
39387
|
-
WHERE session_id = ?
|
|
39388
|
-
`
|
|
39389
|
-
).get(sessionId);
|
|
39390
|
-
return row === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(decodeSessionRow(row));
|
|
39391
|
-
};
|
|
39392
|
-
remove = (sessionId) => {
|
|
39393
|
-
this.#database.prepare("DELETE FROM acp_sessions WHERE session_id = ?").run(sessionId);
|
|
39394
|
-
};
|
|
39395
|
-
findNative = (agentId, nativeSessionId) => this.#database.prepare("SELECT * FROM acp_sessions WHERE agent_id = ? AND native_session_id = ?").all(agentId, nativeSessionId).map(decodeSessionRow);
|
|
39396
|
-
markDeleted = (agentId, nativeSessionId) => {
|
|
39397
|
-
const ids = this.findNative(agentId, nativeSessionId).map((session) => session.sessionId);
|
|
39398
|
-
this.#database.exec("BEGIN");
|
|
39399
|
-
try {
|
|
39400
|
-
for (const id of ids) {
|
|
39401
|
-
this.#database.prepare("INSERT OR IGNORE INTO acp_deleted_sessions (session_id) VALUES (?)").run(id);
|
|
39402
|
-
this.remove(id);
|
|
39403
|
-
}
|
|
39404
|
-
this.#database.exec("COMMIT");
|
|
39405
|
-
return ids;
|
|
39406
|
-
} catch (error62) {
|
|
39407
|
-
this.#database.exec("ROLLBACK");
|
|
39408
|
-
throw error62;
|
|
39409
|
-
}
|
|
39410
|
-
};
|
|
39411
|
-
write = (session) => {
|
|
39412
|
-
this.#database.prepare(
|
|
39413
|
-
`
|
|
39414
|
-
INSERT INTO acp_sessions (
|
|
39415
|
-
session_id,
|
|
39416
|
-
agent_id,
|
|
39417
|
-
native_session_id,
|
|
39418
|
-
cwd,
|
|
39419
|
-
additional_directories_json,
|
|
39420
|
-
prompted,
|
|
39421
|
-
updated_at
|
|
39422
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
39423
|
-
ON CONFLICT(session_id) DO UPDATE SET
|
|
39424
|
-
agent_id = excluded.agent_id,
|
|
39425
|
-
native_session_id = excluded.native_session_id,
|
|
39426
|
-
cwd = excluded.cwd,
|
|
39427
|
-
additional_directories_json = excluded.additional_directories_json,
|
|
39428
|
-
prompted = excluded.prompted,
|
|
39429
|
-
updated_at = excluded.updated_at
|
|
39430
|
-
`
|
|
39431
|
-
).run(
|
|
39432
|
-
session.sessionId,
|
|
39433
|
-
session.agentId,
|
|
39434
|
-
session.nativeSessionId,
|
|
39435
|
-
session.cwd,
|
|
39436
|
-
JSON.stringify(session.additionalDirectories),
|
|
39437
|
-
session.prompted ? 1 : 0,
|
|
39438
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
39439
|
-
);
|
|
39440
|
-
};
|
|
39441
|
-
close = () => {
|
|
39442
|
-
this.#database.close();
|
|
39443
|
-
};
|
|
39444
|
-
};
|
|
39445
39295
|
|
|
39446
39296
|
// src/acp/session-manager.ts
|
|
39447
39297
|
var PROCESS_STOP_TIMEOUT_MILLISECONDS = 1e3;
|
|
@@ -39668,7 +39518,7 @@ function truncate4(value, maximumLength) {
|
|
|
39668
39518
|
function isRecord9(value) {
|
|
39669
39519
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
39670
39520
|
}
|
|
39671
|
-
function
|
|
39521
|
+
function readString3(value, fallback = "") {
|
|
39672
39522
|
return typeof value === "string" ? value : fallback;
|
|
39673
39523
|
}
|
|
39674
39524
|
function arraysEqual(left, right) {
|
|
@@ -39701,8 +39551,8 @@ function normalizeElicitationOptions(schema) {
|
|
|
39701
39551
|
for (const option of oneOf) {
|
|
39702
39552
|
if (isRecord9(option) && typeof option["const"] === "string") {
|
|
39703
39553
|
normalized.push({
|
|
39704
|
-
description: truncate4(
|
|
39705
|
-
label: truncate4(
|
|
39554
|
+
description: truncate4(readString3(option["description"]), 500),
|
|
39555
|
+
label: truncate4(readString3(option["title"], option["const"]), 255),
|
|
39706
39556
|
value: truncate4(option["const"], 500)
|
|
39707
39557
|
});
|
|
39708
39558
|
}
|
|
@@ -39753,8 +39603,8 @@ function normalizeElicitationFields(requestedSchema) {
|
|
|
39753
39603
|
defaultBooleanValue: typeof defaultValue === "boolean" ? defaultValue : false,
|
|
39754
39604
|
defaultNumberValue: typeof defaultValue === "number" && Number.isFinite(defaultValue) ? defaultValue : 0,
|
|
39755
39605
|
defaultStringValue: typeof defaultValue === "string" ? truncate4(defaultValue, 1e4) : Array.isArray(defaultValue) ? truncate4(JSON.stringify(defaultValue), 1e4) : "",
|
|
39756
|
-
description: truncate4(
|
|
39757
|
-
format: truncate4(
|
|
39606
|
+
description: truncate4(readString3(property["description"]), 500),
|
|
39607
|
+
format: truncate4(readString3(property["format"]), 64),
|
|
39758
39608
|
hasDefaultValue: defaultValue !== void 0 && defaultValue !== null,
|
|
39759
39609
|
maximum: numericString(property["maximum"]),
|
|
39760
39610
|
maximumLength: numericString(property["maxLength"] ?? property["maxItems"]),
|
|
@@ -39762,9 +39612,9 @@ function normalizeElicitationFields(requestedSchema) {
|
|
|
39762
39612
|
minimumLength: numericString(property["minLength"] ?? property["minItems"]),
|
|
39763
39613
|
name: truncate4(name, 128),
|
|
39764
39614
|
options,
|
|
39765
|
-
pattern: truncate4(
|
|
39615
|
+
pattern: truncate4(readString3(property["pattern"]), 500),
|
|
39766
39616
|
required: required2.has(name),
|
|
39767
|
-
title: truncate4(
|
|
39617
|
+
title: truncate4(readString3(property["title"], name), 255),
|
|
39768
39618
|
type: normalizedType
|
|
39769
39619
|
});
|
|
39770
39620
|
}
|
|
@@ -40603,6 +40453,17 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
40603
40453
|
);
|
|
40604
40454
|
};
|
|
40605
40455
|
nativeSessionId = () => this.#nativeSessionId;
|
|
40456
|
+
adoptNativeSessionId = (sessionId) => {
|
|
40457
|
+
if (this.#prompted || this.#nativeSessionId !== sessionId) {
|
|
40458
|
+
throw new AcpExecutionError("The new Codex Session cannot be adopted", {}, "session_identity_mismatch");
|
|
40459
|
+
}
|
|
40460
|
+
const previousSessionId = this.#mobiusSessionId;
|
|
40461
|
+
this.#store.write(
|
|
40462
|
+
new AcpStoredSession(sessionId, this.#agentId, sessionId, this.#cwd, this.#additionalDirectories, false)
|
|
40463
|
+
);
|
|
40464
|
+
this.#store.remove(previousSessionId);
|
|
40465
|
+
this.#mobiusSessionId = sessionId;
|
|
40466
|
+
};
|
|
40606
40467
|
configure = async (options) => {
|
|
40607
40468
|
const existing = this.#configOptions.find((option) => option.id === options.configId);
|
|
40608
40469
|
if (existing === void 0 || existing.type !== options.valueType) {
|
|
@@ -40996,7 +40857,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
40996
40857
|
message: truncate4(request.message, 2e3),
|
|
40997
40858
|
mode: request.mode,
|
|
40998
40859
|
sessionId: this.#mobiusSessionId,
|
|
40999
|
-
url: request.mode === "url" && typeof Reflect.get(request, "url") === "string" ? truncate4(
|
|
40860
|
+
url: request.mode === "url" && typeof Reflect.get(request, "url") === "string" ? truncate4(readString3(Reflect.get(request, "url")), 4096) : ""
|
|
41000
40861
|
});
|
|
41001
40862
|
return await pending.completion.promise;
|
|
41002
40863
|
} finally {
|
|
@@ -41356,11 +41217,13 @@ var AcpSessionManager = class {
|
|
|
41356
41217
|
#transientProcessCount = 0;
|
|
41357
41218
|
#store;
|
|
41358
41219
|
#nativeHistoryReader;
|
|
41220
|
+
#sessionIdentity;
|
|
41359
41221
|
#observer;
|
|
41360
|
-
constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader = null) {
|
|
41222
|
+
constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader = null, sessionIdentity = "assigned") {
|
|
41361
41223
|
this.#observer = observer;
|
|
41362
41224
|
this.#store = store;
|
|
41363
41225
|
this.#nativeHistoryReader = nativeHistoryReader;
|
|
41226
|
+
this.#sessionIdentity = sessionIdentity;
|
|
41364
41227
|
}
|
|
41365
41228
|
setObserver = (observer) => {
|
|
41366
41229
|
this.#observer = observer;
|
|
@@ -41472,7 +41335,13 @@ var AcpSessionManager = class {
|
|
|
41472
41335
|
if (retained) {
|
|
41473
41336
|
this.#sessions.delete(sessionId);
|
|
41474
41337
|
}
|
|
41475
|
-
|
|
41338
|
+
try {
|
|
41339
|
+
await this.#retireProcess(runtime, retained, close);
|
|
41340
|
+
} finally {
|
|
41341
|
+
if (retained && this.#sessionIdentity === "native") {
|
|
41342
|
+
this.#store.remove(sessionId);
|
|
41343
|
+
}
|
|
41344
|
+
}
|
|
41476
41345
|
}
|
|
41477
41346
|
async #retireNativeBrowserProcess(sessionId, runtime, close) {
|
|
41478
41347
|
const retained = this.#nativeBrowserSessions.get(sessionId) === runtime;
|
|
@@ -41619,7 +41488,14 @@ var AcpSessionManager = class {
|
|
|
41619
41488
|
try {
|
|
41620
41489
|
return await this.#startRetainedSessionProcess(
|
|
41621
41490
|
options,
|
|
41622
|
-
async () => await AcpProcessSession.start(
|
|
41491
|
+
async () => await AcpProcessSession.start(
|
|
41492
|
+
this.#sessionIdentity === "native" && options.agent.id === "codex" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(
|
|
41493
|
+
options.sessionId
|
|
41494
|
+
) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
|
|
41495
|
+
() => this.#observer,
|
|
41496
|
+
this.#store,
|
|
41497
|
+
metrics
|
|
41498
|
+
)
|
|
41623
41499
|
);
|
|
41624
41500
|
} finally {
|
|
41625
41501
|
this.#preparing.delete(options.sessionId);
|
|
@@ -42042,6 +41918,45 @@ var AcpSessionManager = class {
|
|
|
42042
41918
|
]);
|
|
42043
41919
|
};
|
|
42044
41920
|
hasPreparedSession = (sessionId, agentId, cwd, additionalDirectories) => this.#sessions.get(sessionId)?.belongsTo(agentId, cwd, additionalDirectories) === true;
|
|
41921
|
+
createNativeSession = async (options) => {
|
|
41922
|
+
const temporarySessionId = `new-${crypto.randomUUID()}`;
|
|
41923
|
+
const temporaryOptions = { ...options, sessionId: temporarySessionId };
|
|
41924
|
+
this.#beginSessionUse(temporarySessionId);
|
|
41925
|
+
try {
|
|
41926
|
+
const runtime = await this.#startPreparation(temporaryOptions);
|
|
41927
|
+
let adopted = false;
|
|
41928
|
+
try {
|
|
41929
|
+
const nativeSessionId = runtime.nativeSessionId();
|
|
41930
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(nativeSessionId) || this.#sessions.has(nativeSessionId) || !(this.#store.read(nativeSessionId) instanceof MissingAcpStoredSession)) {
|
|
41931
|
+
throw new AcpExecutionError(
|
|
41932
|
+
"Codex returned an invalid new Session ID",
|
|
41933
|
+
{},
|
|
41934
|
+
"invalid_native_session_response"
|
|
41935
|
+
);
|
|
41936
|
+
}
|
|
41937
|
+
runtime.adoptNativeSessionId(nativeSessionId);
|
|
41938
|
+
this.#sessions.delete(temporarySessionId);
|
|
41939
|
+
this.#sessions.set(nativeSessionId, runtime);
|
|
41940
|
+
this.#retainedProcesses.set(
|
|
41941
|
+
runtime,
|
|
41942
|
+
new FoundAcpSessionProcessEvictionCandidate(nativeSessionId, runtime)
|
|
41943
|
+
);
|
|
41944
|
+
adopted = true;
|
|
41945
|
+
return nativeSessionId;
|
|
41946
|
+
} finally {
|
|
41947
|
+
if (!adopted) {
|
|
41948
|
+
await this.#retireSessionProcess(
|
|
41949
|
+
temporarySessionId,
|
|
41950
|
+
runtime,
|
|
41951
|
+
async () => await runtime.closeProcess()
|
|
41952
|
+
);
|
|
41953
|
+
}
|
|
41954
|
+
}
|
|
41955
|
+
} finally {
|
|
41956
|
+
this.#store.remove(temporarySessionId);
|
|
41957
|
+
this.#endSessionUse(temporarySessionId);
|
|
41958
|
+
}
|
|
41959
|
+
};
|
|
42045
41960
|
ensureSession = async (options) => {
|
|
42046
41961
|
const existing = this.#sessions.get(options.sessionId);
|
|
42047
41962
|
if (existing !== void 0) {
|
|
@@ -42135,6 +42050,25 @@ var AcpSessionManager = class {
|
|
|
42135
42050
|
this.#endSessionUse(options.sessionId);
|
|
42136
42051
|
}
|
|
42137
42052
|
};
|
|
42053
|
+
loadLinkedSessionHistory = async (options) => {
|
|
42054
|
+
options.signal.throwIfAborted();
|
|
42055
|
+
const stored = this.#store.read(options.sessionId);
|
|
42056
|
+
if (!(stored instanceof FoundAcpStoredSession) || !stored.session.prompted) {
|
|
42057
|
+
return null;
|
|
42058
|
+
}
|
|
42059
|
+
const linked = stored.session;
|
|
42060
|
+
if (linked.agentId !== options.agent.id || linked.cwd !== options.cwd || linked.additionalDirectories.length !== options.additionalDirectories.length || linked.additionalDirectories.some((directory, index2) => directory !== options.additionalDirectories[index2])) {
|
|
42061
|
+
throw new AcpExecutionError(
|
|
42062
|
+
"The session belongs to another Agent or workspace",
|
|
42063
|
+
{},
|
|
42064
|
+
"session_identity_mismatch"
|
|
42065
|
+
);
|
|
42066
|
+
}
|
|
42067
|
+
if (this.#nativeHistoryReader === null) {
|
|
42068
|
+
return await this.loadSessionHistory(options);
|
|
42069
|
+
}
|
|
42070
|
+
return await this.#nativeHistoryReader.read(options, linked.nativeSessionId);
|
|
42071
|
+
};
|
|
42138
42072
|
openNativeSession = async (options, origin, loadHistory) => {
|
|
42139
42073
|
const key = `${options.agent.id}:${origin.nativeSessionId}`;
|
|
42140
42074
|
if (this.#nativeOperations.has(key)) {
|
|
@@ -43198,7 +43132,7 @@ var LocalAuthorizationError = class extends Error {
|
|
|
43198
43132
|
// src/authorization/workspace-directory.ts
|
|
43199
43133
|
import { readdir as readdir3, realpath as realpath9, stat as stat8 } from "node:fs/promises";
|
|
43200
43134
|
import { homedir as homedir2 } from "node:os";
|
|
43201
|
-
import { basename as basename5, dirname as
|
|
43135
|
+
import { basename as basename5, dirname as dirname4, isAbsolute as isAbsolute10, join as join16, normalize as normalize4, relative as relative4 } from "node:path";
|
|
43202
43136
|
var WorkspaceDirectoryListing = class {
|
|
43203
43137
|
directoryId;
|
|
43204
43138
|
directoryLabel;
|
|
@@ -43322,7 +43256,7 @@ var WorkspaceDirectoryService = class {
|
|
|
43322
43256
|
}
|
|
43323
43257
|
}
|
|
43324
43258
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
43325
|
-
const parent =
|
|
43259
|
+
const parent = dirname4(target);
|
|
43326
43260
|
return new WorkspaceDirectoryListing(
|
|
43327
43261
|
id,
|
|
43328
43262
|
this.label(target),
|
|
@@ -43347,7 +43281,7 @@ var WorkspaceDirectoryService = class {
|
|
|
43347
43281
|
};
|
|
43348
43282
|
|
|
43349
43283
|
// src/daemon-diagnostic-log.ts
|
|
43350
|
-
import { appendFileSync, mkdirSync
|
|
43284
|
+
import { appendFileSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
|
|
43351
43285
|
import { join as join17 } from "node:path";
|
|
43352
43286
|
var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
|
|
43353
43287
|
var DaemonDiagnosticLog = class {
|
|
@@ -43363,7 +43297,7 @@ var DaemonDiagnosticLog = class {
|
|
|
43363
43297
|
const encoded = `${diagnostic.replace(/[\r\n]+/gu, " ").trim()}
|
|
43364
43298
|
`;
|
|
43365
43299
|
const encodedBytes = Buffer.byteLength(encoded);
|
|
43366
|
-
|
|
43300
|
+
mkdirSync(this.#directory, { mode: 448, recursive: true });
|
|
43367
43301
|
let existingBytes = 0;
|
|
43368
43302
|
try {
|
|
43369
43303
|
existingBytes = statSync3(this.#path).size;
|
|
@@ -43416,7 +43350,7 @@ var turnsSchema = external_exports.object({
|
|
|
43416
43350
|
error: external_exports.unknown().nullish(),
|
|
43417
43351
|
items: external_exports.array(external_exports.unknown()).max(1e5)
|
|
43418
43352
|
})
|
|
43419
|
-
).max(
|
|
43353
|
+
).max(SESSION_HISTORY_MESSAGE_LIMIT),
|
|
43420
43354
|
nextCursor: external_exports.string().nullish()
|
|
43421
43355
|
});
|
|
43422
43356
|
var itemTypeSchema = external_exports.object({ type: external_exports.string().min(1).max(80) });
|
|
@@ -43603,7 +43537,7 @@ function decodeHistory(thread, value, options) {
|
|
|
43603
43537
|
messages.push(message);
|
|
43604
43538
|
characters += messageSize(message);
|
|
43605
43539
|
}
|
|
43606
|
-
while (messages.length > SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT || characters > SESSION_HISTORY_CHARACTER_LIMIT) {
|
|
43540
|
+
while (messages.length > (options.detail === "rich" ? SESSION_HISTORY_MESSAGE_LIMIT : SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT) || characters > SESSION_HISTORY_CHARACTER_LIMIT) {
|
|
43607
43541
|
const removed = messages.shift();
|
|
43608
43542
|
if (removed !== void 0) {
|
|
43609
43543
|
characters -= messageSize(removed);
|
|
@@ -43643,6 +43577,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
43643
43577
|
});
|
|
43644
43578
|
const response = Promise.withResolvers();
|
|
43645
43579
|
let state = { kind: "initializing", requestId: 1 };
|
|
43580
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
43646
43581
|
let pending = "";
|
|
43647
43582
|
let receivedBytes = 0;
|
|
43648
43583
|
const fail = (cause) => response.reject(
|
|
@@ -43709,7 +43644,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
43709
43644
|
break;
|
|
43710
43645
|
case "metadata": {
|
|
43711
43646
|
const { thread } = threadSchema.parse(message.result);
|
|
43712
|
-
state = { kind: "turns", requestId: 3, thread };
|
|
43647
|
+
state = { kind: "turns", requestId: 3, thread, pages: [] };
|
|
43713
43648
|
send2({
|
|
43714
43649
|
id: state.requestId,
|
|
43715
43650
|
method: "thread/turns/list",
|
|
@@ -43722,9 +43657,45 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
43722
43657
|
});
|
|
43723
43658
|
break;
|
|
43724
43659
|
}
|
|
43725
|
-
case "turns":
|
|
43726
|
-
|
|
43727
|
-
|
|
43660
|
+
case "turns": {
|
|
43661
|
+
const page = turnsSchema.parse(message.result);
|
|
43662
|
+
const pages = [...state.pages, ...page.data];
|
|
43663
|
+
const maxTurns = options.detail === "rich" ? SESSION_HISTORY_MESSAGE_LIMIT : SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT;
|
|
43664
|
+
if (page.nextCursor == null || pages.length >= maxTurns) {
|
|
43665
|
+
response.resolve(
|
|
43666
|
+
decodeHistory(
|
|
43667
|
+
state.thread,
|
|
43668
|
+
{
|
|
43669
|
+
data: pages.slice(0, maxTurns),
|
|
43670
|
+
nextCursor: page.nextCursor
|
|
43671
|
+
},
|
|
43672
|
+
options
|
|
43673
|
+
)
|
|
43674
|
+
);
|
|
43675
|
+
return;
|
|
43676
|
+
}
|
|
43677
|
+
if (page.data.length === 0 || seenCursors.has(page.nextCursor)) {
|
|
43678
|
+
throw new AcpExecutionError(
|
|
43679
|
+
"Codex repeated a history page cursor.",
|
|
43680
|
+
{},
|
|
43681
|
+
"invalid_native_session_response"
|
|
43682
|
+
);
|
|
43683
|
+
}
|
|
43684
|
+
seenCursors.add(page.nextCursor);
|
|
43685
|
+
state = { kind: "turns", requestId: state.requestId + 1, thread: state.thread, pages };
|
|
43686
|
+
send2({
|
|
43687
|
+
id: state.requestId,
|
|
43688
|
+
method: "thread/turns/list",
|
|
43689
|
+
params: {
|
|
43690
|
+
threadId: nativeSessionId,
|
|
43691
|
+
cursor: page.nextCursor,
|
|
43692
|
+
limit: Math.min(SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT, maxTurns - pages.length),
|
|
43693
|
+
sortDirection: "desc",
|
|
43694
|
+
itemsView: options.detail === "rich" ? "full" : "summary"
|
|
43695
|
+
}
|
|
43696
|
+
});
|
|
43697
|
+
break;
|
|
43698
|
+
}
|
|
43728
43699
|
default: {
|
|
43729
43700
|
const unhandled = state;
|
|
43730
43701
|
throw new Error(`Unknown history read state: ${String(unhandled)}`);
|
|
@@ -43745,7 +43716,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
43745
43716
|
);
|
|
43746
43717
|
const timeout = setTimeout(
|
|
43747
43718
|
() => fail(new AcpExecutionError("Reading saved Codex history timed out.", {}, "native_history_timeout")),
|
|
43748
|
-
15e3
|
|
43719
|
+
options.detail === "rich" ? 6e4 : 15e3
|
|
43749
43720
|
);
|
|
43750
43721
|
child.stdout.setEncoding("utf8");
|
|
43751
43722
|
child.stdout.on("data", onData);
|
|
@@ -43815,6 +43786,84 @@ var NativeSessionService = class {
|
|
|
43815
43786
|
sessionId: command.sessionId,
|
|
43816
43787
|
signal
|
|
43817
43788
|
};
|
|
43789
|
+
if (command.action === "linked-history") {
|
|
43790
|
+
if (options.agent.id !== "codex") {
|
|
43791
|
+
const history = await this.#sessions.loadLinkedSessionHistory({
|
|
43792
|
+
...options,
|
|
43793
|
+
sessionId: command.targetSessionId
|
|
43794
|
+
});
|
|
43795
|
+
this.record(command, "native_session_history_read");
|
|
43796
|
+
return history === null ? {
|
|
43797
|
+
action: "unlinked-history",
|
|
43798
|
+
kind: "native.session.result",
|
|
43799
|
+
requestId: command.requestId,
|
|
43800
|
+
sessionId: command.sessionId,
|
|
43801
|
+
targetSessionId: command.targetSessionId
|
|
43802
|
+
} : {
|
|
43803
|
+
action: "linked-history",
|
|
43804
|
+
history,
|
|
43805
|
+
kind: "native.session.result",
|
|
43806
|
+
requestId: command.requestId,
|
|
43807
|
+
sessionId: command.sessionId,
|
|
43808
|
+
targetSessionId: command.targetSessionId
|
|
43809
|
+
};
|
|
43810
|
+
}
|
|
43811
|
+
const nativeSessionId = nativeSessionIdSchema.parse(command.targetSessionId);
|
|
43812
|
+
if (this.#sessions.hasPreparedSession(nativeSessionId, options.agent.id, cwd, additionalDirectories) && await this.#sessions.loadLinkedSessionHistory({ ...options, sessionId: nativeSessionId }) === null) {
|
|
43813
|
+
this.record(command, "native_session_history_read");
|
|
43814
|
+
return {
|
|
43815
|
+
action: "linked-history",
|
|
43816
|
+
history: {
|
|
43817
|
+
status: "available",
|
|
43818
|
+
messages: [],
|
|
43819
|
+
truncated: false,
|
|
43820
|
+
coveredCommandIds: [],
|
|
43821
|
+
coveredMessageIds: []
|
|
43822
|
+
},
|
|
43823
|
+
kind: "native.session.result",
|
|
43824
|
+
requestId: command.requestId,
|
|
43825
|
+
sessionId: command.sessionId,
|
|
43826
|
+
targetSessionId: command.targetSessionId
|
|
43827
|
+
};
|
|
43828
|
+
}
|
|
43829
|
+
const snapshot = await readCodexFullHistory(options.agent, cwd, nativeSessionId, signal);
|
|
43830
|
+
const resolved = await this.#directories.identify(command.bindingId, snapshot.cwd, signal);
|
|
43831
|
+
if (snapshot.nativeSessionId !== nativeSessionId || resolved.path !== cwd) {
|
|
43832
|
+
throw new AcpExecutionError(
|
|
43833
|
+
"Codex returned history for a different session or workspace.",
|
|
43834
|
+
{},
|
|
43835
|
+
"invalid_native_session_response"
|
|
43836
|
+
);
|
|
43837
|
+
}
|
|
43838
|
+
this.record(command, "native_session_history_read");
|
|
43839
|
+
return {
|
|
43840
|
+
action: "linked-history",
|
|
43841
|
+
history: snapshot.history,
|
|
43842
|
+
kind: "native.session.result",
|
|
43843
|
+
requestId: command.requestId,
|
|
43844
|
+
sessionId: command.sessionId,
|
|
43845
|
+
targetSessionId: command.targetSessionId
|
|
43846
|
+
};
|
|
43847
|
+
}
|
|
43848
|
+
if (command.action === "create") {
|
|
43849
|
+
if (options.agent.id !== "codex") {
|
|
43850
|
+
throw new AcpExecutionError(
|
|
43851
|
+
"Native session creation is unavailable for this Agent",
|
|
43852
|
+
{},
|
|
43853
|
+
"native_session_unsupported"
|
|
43854
|
+
);
|
|
43855
|
+
}
|
|
43856
|
+
const nativeSessionId = await this.#sessions.createNativeSession(options);
|
|
43857
|
+
signal.throwIfAborted();
|
|
43858
|
+
this.record(command, "native_session_created");
|
|
43859
|
+
return {
|
|
43860
|
+
action: "create",
|
|
43861
|
+
kind: "native.session.result",
|
|
43862
|
+
nativeSessionId,
|
|
43863
|
+
requestId: command.requestId,
|
|
43864
|
+
sessionId: command.sessionId
|
|
43865
|
+
};
|
|
43866
|
+
}
|
|
43818
43867
|
const prepared = await this.#sessions.prepareNativeSessionBrowser(options);
|
|
43819
43868
|
if (!prepared.capabilities.listSessions) {
|
|
43820
43869
|
throw new AcpExecutionError(
|
|
@@ -43842,6 +43891,7 @@ var NativeSessionService = class {
|
|
|
43842
43891
|
});
|
|
43843
43892
|
return {
|
|
43844
43893
|
entryId,
|
|
43894
|
+
nativeSessionId: info.sessionId,
|
|
43845
43895
|
title: info.title ?? "Untitled session",
|
|
43846
43896
|
directoryId: authorized.directoryId,
|
|
43847
43897
|
directoryLabel: authorized.directoryLabel,
|
|
@@ -43947,6 +43997,18 @@ var NativeSessionService = class {
|
|
|
43947
43997
|
);
|
|
43948
43998
|
}
|
|
43949
43999
|
const target = await this.resolveTarget(command, options, selected);
|
|
44000
|
+
if (command.action === "history") {
|
|
44001
|
+
const history = await this.readHistory(command, options, target, signal);
|
|
44002
|
+
signal.throwIfAborted();
|
|
44003
|
+
this.record(command, "native_session_history_read");
|
|
44004
|
+
return {
|
|
44005
|
+
...envelope2,
|
|
44006
|
+
action: "history",
|
|
44007
|
+
entryId: command.entryId,
|
|
44008
|
+
history,
|
|
44009
|
+
title: target.info.title ?? "Untitled session"
|
|
44010
|
+
};
|
|
44011
|
+
}
|
|
43950
44012
|
if (command.action === "preview") {
|
|
43951
44013
|
const history = await this.previewHistory(command, options, target, signal);
|
|
43952
44014
|
signal.throwIfAborted();
|
|
@@ -44120,6 +44182,25 @@ var NativeSessionService = class {
|
|
|
44120
44182
|
}
|
|
44121
44183
|
return snapshot.history;
|
|
44122
44184
|
};
|
|
44185
|
+
readHistory = async (command, options, target, signal) => {
|
|
44186
|
+
if (options.agent.id !== "codex") {
|
|
44187
|
+
throw new AcpExecutionError(
|
|
44188
|
+
"Native history is unavailable for this Agent",
|
|
44189
|
+
{},
|
|
44190
|
+
"native_session_unsupported"
|
|
44191
|
+
);
|
|
44192
|
+
}
|
|
44193
|
+
const snapshot = await readCodexFullHistory(options.agent, target.cwd, target.info.sessionId, signal);
|
|
44194
|
+
const resolved = await this.#directories.identify(command.bindingId, snapshot.cwd, signal);
|
|
44195
|
+
if (snapshot.nativeSessionId !== target.info.sessionId || resolved.path !== target.cwd) {
|
|
44196
|
+
throw new AcpExecutionError(
|
|
44197
|
+
"Codex returned history for a different session or workspace.",
|
|
44198
|
+
{},
|
|
44199
|
+
"invalid_native_session_response"
|
|
44200
|
+
);
|
|
44201
|
+
}
|
|
44202
|
+
return snapshot.history;
|
|
44203
|
+
};
|
|
44123
44204
|
authorizeEntry = async (command, options, info) => {
|
|
44124
44205
|
try {
|
|
44125
44206
|
const primary = await this.#directories.identify(command.bindingId, info.cwd, options.signal);
|
|
@@ -44915,26 +44996,26 @@ var RelayConnectionLiveness = class {
|
|
|
44915
44996
|
};
|
|
44916
44997
|
|
|
44917
44998
|
// src/relay-connection/session-event-outbox.ts
|
|
44918
|
-
import {
|
|
44919
|
-
import {
|
|
44920
|
-
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
44999
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
45000
|
+
import { DatabaseSync } from "node:sqlite";
|
|
44921
45001
|
var DEFAULT_OUTBOX_LIMITS = {
|
|
44922
45002
|
criticalEventBytes: 136 * 1024 * 1024,
|
|
44923
45003
|
runtimeDeliveryBytes: 64 * 1024 * 1024,
|
|
44924
45004
|
runtimeDeliveryCount: 64,
|
|
44925
45005
|
standardEventBytes: 128 * 1024 * 1024
|
|
44926
45006
|
};
|
|
45007
|
+
var MAX_TERMINAL_RECEIPTS = 1024;
|
|
44927
45008
|
var SessionEventOutboxCapacityError = class extends Error {
|
|
44928
45009
|
code = "session_event_outbox_full";
|
|
44929
45010
|
constructor() {
|
|
44930
|
-
super("The
|
|
45011
|
+
super("The in-memory Session event outbox is full");
|
|
44931
45012
|
this.name = "SessionEventOutboxCapacityError";
|
|
44932
45013
|
}
|
|
44933
45014
|
};
|
|
44934
45015
|
var RuntimeDeliveryInboxCapacityError = class extends Error {
|
|
44935
45016
|
code = "runtime_delivery_inbox_full";
|
|
44936
45017
|
constructor() {
|
|
44937
|
-
super("The
|
|
45018
|
+
super("The in-memory Runtime delivery inbox is full");
|
|
44938
45019
|
this.name = "RuntimeDeliveryInboxCapacityError";
|
|
44939
45020
|
}
|
|
44940
45021
|
};
|
|
@@ -44979,11 +45060,10 @@ function rowString(row, field) {
|
|
|
44979
45060
|
var SessionEventOutbox = class {
|
|
44980
45061
|
#database;
|
|
44981
45062
|
#limits;
|
|
44982
|
-
constructor(
|
|
45063
|
+
constructor(limits = DEFAULT_OUTBOX_LIMITS) {
|
|
44983
45064
|
validateLimits(limits);
|
|
44984
45065
|
this.#limits = limits;
|
|
44985
|
-
|
|
44986
|
-
this.#database = new DatabaseSync3(path3);
|
|
45066
|
+
this.#database = new DatabaseSync(":memory:");
|
|
44987
45067
|
this.#database.exec(`
|
|
44988
45068
|
CREATE TABLE IF NOT EXISTS relay_session_event_outbox (
|
|
44989
45069
|
ordinal INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -45011,7 +45091,7 @@ var SessionEventOutbox = class {
|
|
|
45011
45091
|
CREATE TABLE IF NOT EXISTS relay_turn_receipts (
|
|
45012
45092
|
command_id TEXT PRIMARY KEY,
|
|
45013
45093
|
session_id TEXT NOT NULL,
|
|
45014
|
-
|
|
45094
|
+
command_hash TEXT NOT NULL,
|
|
45015
45095
|
attempt_id TEXT NOT NULL,
|
|
45016
45096
|
state TEXT NOT NULL CHECK (
|
|
45017
45097
|
state IN ('dispatching', 'running', 'succeeded', 'failed', 'cancelled')
|
|
@@ -45042,19 +45122,20 @@ var SessionEventOutbox = class {
|
|
|
45042
45122
|
`);
|
|
45043
45123
|
}
|
|
45044
45124
|
claimExecution = (commandId, sessionId, commandJson) => {
|
|
45125
|
+
const commandHash = createHash4("sha256").update(commandJson).digest("hex");
|
|
45045
45126
|
this.#database.exec("BEGIN IMMEDIATE");
|
|
45046
45127
|
try {
|
|
45047
45128
|
const existing = this.#database.prepare(
|
|
45048
|
-
`SELECT session_id,
|
|
45129
|
+
`SELECT session_id, command_hash, attempt_id, state
|
|
45049
45130
|
FROM relay_turn_receipts WHERE command_id = ?`
|
|
45050
45131
|
).get(commandId);
|
|
45051
45132
|
if (typeof existing === "object" && existing !== null) {
|
|
45052
45133
|
const storedSessionId = Reflect.get(existing, "session_id");
|
|
45053
|
-
const
|
|
45134
|
+
const storedCommandHash = Reflect.get(existing, "command_hash");
|
|
45054
45135
|
const attemptId2 = Reflect.get(existing, "attempt_id");
|
|
45055
45136
|
const state = Reflect.get(existing, "state");
|
|
45056
|
-
if (storedSessionId !== sessionId ||
|
|
45057
|
-
throw new Error("The daemon command identity conflicts with its
|
|
45137
|
+
if (storedSessionId !== sessionId || storedCommandHash !== commandHash || typeof attemptId2 !== "string" || !isDaemonExecutionState(state)) {
|
|
45138
|
+
throw new Error("The daemon command identity conflicts with its in-memory receipt");
|
|
45058
45139
|
}
|
|
45059
45140
|
this.#database.exec("COMMIT");
|
|
45060
45141
|
return { attemptId: attemptId2, commandId, kind: "duplicate", state };
|
|
@@ -45062,9 +45143,9 @@ var SessionEventOutbox = class {
|
|
|
45062
45143
|
const attemptId = crypto.randomUUID();
|
|
45063
45144
|
this.#database.prepare(
|
|
45064
45145
|
`INSERT INTO relay_turn_receipts (
|
|
45065
|
-
command_id, session_id,
|
|
45146
|
+
command_id, session_id, command_hash, attempt_id, state
|
|
45066
45147
|
) VALUES (?, ?, ?, ?, 'dispatching')`
|
|
45067
|
-
).run(commandId, sessionId,
|
|
45148
|
+
).run(commandId, sessionId, commandHash, attemptId);
|
|
45068
45149
|
this.#database.exec("COMMIT");
|
|
45069
45150
|
return {
|
|
45070
45151
|
attemptId,
|
|
@@ -45091,11 +45172,21 @@ var SessionEventOutbox = class {
|
|
|
45091
45172
|
throw new Error("The daemon execution transition is invalid");
|
|
45092
45173
|
}
|
|
45093
45174
|
this.#database.prepare(`UPDATE relay_turn_receipts SET state = ? WHERE command_id = ?`).run(state, commandId);
|
|
45175
|
+
if (state === "succeeded" || state === "failed" || state === "cancelled") {
|
|
45176
|
+
this.#database.prepare(
|
|
45177
|
+
`DELETE FROM relay_turn_receipts
|
|
45178
|
+
WHERE state IN ('succeeded', 'failed', 'cancelled')
|
|
45179
|
+
AND rowid NOT IN (
|
|
45180
|
+
SELECT rowid FROM relay_turn_receipts
|
|
45181
|
+
WHERE state IN ('succeeded', 'failed', 'cancelled')
|
|
45182
|
+
ORDER BY rowid DESC LIMIT ?
|
|
45183
|
+
)`
|
|
45184
|
+
).run(MAX_TERMINAL_RECEIPTS);
|
|
45185
|
+
}
|
|
45094
45186
|
};
|
|
45095
45187
|
/**
|
|
45096
|
-
* The Attempt this Runtime
|
|
45097
|
-
*
|
|
45098
|
-
* the restart, so this is the only record of the Attempt identity the Relay is still waiting on.
|
|
45188
|
+
* The Attempt this live Runtime claimed for a command that has not reached a terminal state.
|
|
45189
|
+
* Receipts disappear when the daemon process exits.
|
|
45099
45190
|
*/
|
|
45100
45191
|
findUnsettledAttemptId = (commandId, sessionId) => {
|
|
45101
45192
|
const row = this.#database.prepare(`SELECT attempt_id, state FROM relay_turn_receipts WHERE command_id = ? AND session_id = ?`).get(commandId, sessionId);
|
|
@@ -45144,7 +45235,7 @@ var SessionEventOutbox = class {
|
|
|
45144
45235
|
WHERE event_id = ? AND session_id = ?`
|
|
45145
45236
|
).run(rejection.eventId, rejection.sessionId);
|
|
45146
45237
|
if (deletion.changes !== 1) {
|
|
45147
|
-
throw new Error("The rejected session event could not be removed from the
|
|
45238
|
+
throw new Error("The rejected session event could not be removed from the in-memory outbox");
|
|
45148
45239
|
}
|
|
45149
45240
|
this.#decrementEventState(byteLength);
|
|
45150
45241
|
this.#database.exec("COMMIT");
|
|
@@ -45163,7 +45254,7 @@ var SessionEventOutbox = class {
|
|
|
45163
45254
|
enqueueCritical = (sessionId, payload, attemptId = "") => this.#enqueueBounded(sessionId, payload, attemptId, this.#limits.criticalEventBytes);
|
|
45164
45255
|
/**
|
|
45165
45256
|
* Bytes still available to standard Session events. The daemon uses this to shed
|
|
45166
|
-
* superseded streaming events instead of filling the
|
|
45257
|
+
* superseded streaming events instead of filling the in-memory outbox, so a long Turn
|
|
45167
45258
|
* behind a slow Relay cannot make the next enqueue throw.
|
|
45168
45259
|
*/
|
|
45169
45260
|
standardCapacityRemaining = () => {
|
|
@@ -45188,7 +45279,7 @@ var SessionEventOutbox = class {
|
|
|
45188
45279
|
const payload = rowString(existing, "payload_json");
|
|
45189
45280
|
const state = runtimeDeliveryState(existing);
|
|
45190
45281
|
if (sessionId !== delivery.sessionId || payload !== delivery.payload) {
|
|
45191
|
-
throw new Error("The Runtime delivery identity conflicts with its
|
|
45282
|
+
throw new Error("The Runtime delivery identity conflicts with its in-memory receipt");
|
|
45192
45283
|
}
|
|
45193
45284
|
this.#database.exec("COMMIT");
|
|
45194
45285
|
return new StoredRuntimeDelivery(delivery.deliveryId, sessionId, payload, state, true);
|
|
@@ -45356,7 +45447,7 @@ var SessionEventOutbox = class {
|
|
|
45356
45447
|
WHERE event_id = ? AND session_id = ?`
|
|
45357
45448
|
).run(eventId, sessionId);
|
|
45358
45449
|
if (deletion.changes !== 1) {
|
|
45359
|
-
throw new Error("The acknowledged session event could not be removed from the
|
|
45450
|
+
throw new Error("The acknowledged session event could not be removed from the in-memory outbox");
|
|
45360
45451
|
}
|
|
45361
45452
|
this.#decrementEventState(byteLength);
|
|
45362
45453
|
this.#database.exec("COMMIT");
|
|
@@ -45838,7 +45929,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
45838
45929
|
};
|
|
45839
45930
|
/**
|
|
45840
45931
|
* Enqueue a standard event, shedding it instead of ending the daemon when the
|
|
45841
|
-
*
|
|
45932
|
+
* in-memory outbox is full.
|
|
45842
45933
|
*
|
|
45843
45934
|
* A capacity error used to escape the coalescing timer that publishes activities,
|
|
45844
45935
|
* so the process exited and every restart died on the same retained backlog. A full
|
|
@@ -45881,7 +45972,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
45881
45972
|
return;
|
|
45882
45973
|
}
|
|
45883
45974
|
this.#shedEventKinds.add(kind);
|
|
45884
|
-
console.warn(`Mobius daemon is dropping
|
|
45975
|
+
console.warn(`Mobius daemon is dropping queued "${kind}" events because the Session event outbox is full`);
|
|
45885
45976
|
};
|
|
45886
45977
|
acknowledge = (acknowledgement) => {
|
|
45887
45978
|
if (!this.#outbox.acknowledge(acknowledgement)) {
|
|
@@ -46395,7 +46486,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
|
|
|
46395
46486
|
unsupportedModelIds: modelEffort.unsupportedModelIds,
|
|
46396
46487
|
valuesByModel: {}
|
|
46397
46488
|
};
|
|
46398
|
-
return
|
|
46489
|
+
return createHash5("sha256").update(
|
|
46399
46490
|
JSON.stringify({
|
|
46400
46491
|
adapterVersion: agent.kind === "acp-adapter-process" ? agent.adapterVersion : agent.agentVersion,
|
|
46401
46492
|
agentId: agent.id,
|
|
@@ -47390,7 +47481,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
47390
47481
|
if (connectionController.signal.aborted) {
|
|
47391
47482
|
return;
|
|
47392
47483
|
}
|
|
47393
|
-
console.error("Mobius daemon could not process a
|
|
47484
|
+
console.error("Mobius daemon could not process a in-memory Runtime delivery", error62);
|
|
47394
47485
|
failAndClose(
|
|
47395
47486
|
new Error("Runtime delivery processing failed", { cause: error62 }),
|
|
47396
47487
|
4008,
|
|
@@ -48193,8 +48284,8 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
48193
48284
|
publishCatalog: async (installationSignal) => await publishAgentCatalog(config2, installationSignal),
|
|
48194
48285
|
stateDirectory
|
|
48195
48286
|
});
|
|
48196
|
-
const sessionStore = new
|
|
48197
|
-
const outbox = new SessionEventOutbox(
|
|
48287
|
+
const sessionStore = new MemoryAcpSessionStore();
|
|
48288
|
+
const outbox = new SessionEventOutbox();
|
|
48198
48289
|
const publisher = new DaemonSessionEventPublisher(outbox, timer);
|
|
48199
48290
|
const activeTurns = /* @__PURE__ */ new Map();
|
|
48200
48291
|
const activeAttemptIds = /* @__PURE__ */ new Map();
|
|
@@ -48206,9 +48297,14 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
48206
48297
|
}
|
|
48207
48298
|
publisher.recordAttempt(sessionId, event, attemptId);
|
|
48208
48299
|
};
|
|
48209
|
-
const sessions = new AcpSessionManager(
|
|
48210
|
-
|
|
48211
|
-
|
|
48300
|
+
const sessions = new AcpSessionManager(
|
|
48301
|
+
new DaemonAcpObserver(recordSessionEvent),
|
|
48302
|
+
sessionStore,
|
|
48303
|
+
{
|
|
48304
|
+
read: async (options2, nativeSessionId) => options2.agent.id === "codex" ? (await readCodexFullHistory(options2.agent, options2.cwd, nativeSessionId, options2.signal)).history : null
|
|
48305
|
+
},
|
|
48306
|
+
"native"
|
|
48307
|
+
);
|
|
48212
48308
|
const directories = new WorkspaceDirectoryService(config2.bindingId, config2.defaultWorkspace);
|
|
48213
48309
|
const installationObserver = new DaemonInstallationObserver();
|
|
48214
48310
|
const diagnostics = new RelayConnectionDiagnostics(
|
|
@@ -48344,13 +48440,9 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
48344
48440
|
await sessions.close();
|
|
48345
48441
|
} finally {
|
|
48346
48442
|
try {
|
|
48347
|
-
|
|
48443
|
+
publisher.close();
|
|
48348
48444
|
} finally {
|
|
48349
|
-
|
|
48350
|
-
publisher.close();
|
|
48351
|
-
} finally {
|
|
48352
|
-
outbox.close();
|
|
48353
|
-
}
|
|
48445
|
+
outbox.close();
|
|
48354
48446
|
}
|
|
48355
48447
|
}
|
|
48356
48448
|
}
|
|
@@ -48406,7 +48498,7 @@ var MobiusRuntimeEngine = class {
|
|
|
48406
48498
|
}
|
|
48407
48499
|
signal.throwIfAborted();
|
|
48408
48500
|
this.#state = new RunningMobiusRuntimeState();
|
|
48409
|
-
const audit = new AuditStore(
|
|
48501
|
+
const audit = new AuditStore();
|
|
48410
48502
|
try {
|
|
48411
48503
|
await runDaemon(this.#config, audit, signal, void 0, {
|
|
48412
48504
|
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus },
|
|
@@ -48456,7 +48548,7 @@ function isRecord11(value) {
|
|
|
48456
48548
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
48457
48549
|
}
|
|
48458
48550
|
function controlSocketPath(stateDirectory) {
|
|
48459
|
-
const installationHash =
|
|
48551
|
+
const installationHash = createHash6("sha256").update(stateDirectory).digest("hex").slice(0, 32);
|
|
48460
48552
|
return process.platform === "win32" ? `\\\\.\\pipe\\mobius-${installationHash}` : join18(tmpdir(), `mobius-${installationHash}.sock`);
|
|
48461
48553
|
}
|
|
48462
48554
|
function controlTokenPath(stateDirectory) {
|
|
@@ -48777,24 +48869,19 @@ async function sendControlRequest(stateDirectory, command, signal) {
|
|
|
48777
48869
|
socket.destroy();
|
|
48778
48870
|
}
|
|
48779
48871
|
}
|
|
48780
|
-
async function spawnManager(
|
|
48781
|
-
const
|
|
48782
|
-
|
|
48783
|
-
|
|
48784
|
-
|
|
48785
|
-
|
|
48786
|
-
|
|
48787
|
-
|
|
48788
|
-
child.unref();
|
|
48789
|
-
return child;
|
|
48790
|
-
} finally {
|
|
48791
|
-
await log.close();
|
|
48792
|
-
}
|
|
48872
|
+
async function spawnManager() {
|
|
48873
|
+
const child = spawn6(process.execPath, [process.argv[1] ?? "", "__manager"], {
|
|
48874
|
+
detached: true,
|
|
48875
|
+
env: process.env,
|
|
48876
|
+
stdio: "ignore"
|
|
48877
|
+
});
|
|
48878
|
+
child.unref();
|
|
48879
|
+
return child;
|
|
48793
48880
|
}
|
|
48794
|
-
async function launchManager(
|
|
48881
|
+
async function launchManager(managerVersion) {
|
|
48795
48882
|
process.stdout.write(`Starting mobius daemon ${managerVersion}
|
|
48796
48883
|
`);
|
|
48797
|
-
await spawnManager(
|
|
48884
|
+
await spawnManager();
|
|
48798
48885
|
}
|
|
48799
48886
|
async function waitForManagerExit(stateDirectory, signal) {
|
|
48800
48887
|
const deadline = AbortSignal.any([signal, AbortSignal.timeout(1e4)]);
|
|
@@ -48857,14 +48944,14 @@ async function ensureMatchingManager(stateDirectory, managerVersion, signal) {
|
|
|
48857
48944
|
throw new Error("The Mobius manager returned an unexpected response");
|
|
48858
48945
|
}
|
|
48859
48946
|
await stopManager(stateDirectory, signal);
|
|
48860
|
-
await launchManager(
|
|
48947
|
+
await launchManager(managerVersion);
|
|
48861
48948
|
managerStarted = true;
|
|
48862
48949
|
} catch (cause) {
|
|
48863
48950
|
if (!isNodeError2(cause, "ENOENT") && !isNodeError2(cause, "ECONNREFUSED")) {
|
|
48864
48951
|
throw cause;
|
|
48865
48952
|
}
|
|
48866
48953
|
if (!managerStarted) {
|
|
48867
|
-
await launchManager(
|
|
48954
|
+
await launchManager(managerVersion);
|
|
48868
48955
|
managerStarted = true;
|
|
48869
48956
|
}
|
|
48870
48957
|
await new Promise((resolve8, reject) => {
|
|
@@ -49041,7 +49128,7 @@ async function writePairList(path3, pairs) {
|
|
|
49041
49128
|
shutdown.signal.throwIfAborted();
|
|
49042
49129
|
let file2;
|
|
49043
49130
|
try {
|
|
49044
|
-
file2 = await
|
|
49131
|
+
file2 = await open6(path3, constants2.O_WRONLY | constants2.O_NOFOLLOW);
|
|
49045
49132
|
} catch (cause) {
|
|
49046
49133
|
if (typeof cause === "object" && cause !== null && "code" in cause && cause.code === "ENOENT") {
|
|
49047
49134
|
throw new Error("The JSON output file does not exist", { cause });
|