@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/index.js
CHANGED
|
@@ -33,7 +33,6 @@ var createAcpClient = (handler) => client({ name: "mobius" }).onRequest(
|
|
|
33
33
|
|
|
34
34
|
// src/config.ts
|
|
35
35
|
import { join as join3, resolve as resolve3 } from "node:path";
|
|
36
|
-
import { fileURLToPath } from "node:url";
|
|
37
36
|
|
|
38
37
|
// ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/external.js
|
|
39
38
|
var external_exports = {};
|
|
@@ -21005,7 +21004,10 @@ var nativeSessionTurnForkCommandSchema = external_exports.strictObject({
|
|
|
21005
21004
|
title: external_exports.string().max(500)
|
|
21006
21005
|
}).readonly();
|
|
21007
21006
|
var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
21007
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
21008
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
|
|
21008
21009
|
external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
|
|
21010
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
|
|
21009
21011
|
external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifier }).readonly(),
|
|
21010
21012
|
external_exports.strictObject({
|
|
21011
21013
|
...identity,
|
|
@@ -21025,7 +21027,10 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
|
21025
21027
|
}).readonly()
|
|
21026
21028
|
]);
|
|
21027
21029
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
21030
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
21031
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
|
|
21028
21032
|
external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
|
|
21033
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
|
|
21029
21034
|
external_exports.strictObject({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifier }).readonly(),
|
|
21030
21035
|
external_exports.strictObject({
|
|
21031
21036
|
...identity,
|
|
@@ -21052,6 +21057,7 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
|
21052
21057
|
]);
|
|
21053
21058
|
var nativeSessionEntrySchema = external_exports.strictObject({
|
|
21054
21059
|
entryId: identifier,
|
|
21060
|
+
nativeSessionId: identifier,
|
|
21055
21061
|
title: external_exports.string().max(500),
|
|
21056
21062
|
directoryId,
|
|
21057
21063
|
directoryLabel: external_exports.string().min(1).max(2048),
|
|
@@ -21063,6 +21069,18 @@ var resultEnvelope = {
|
|
|
21063
21069
|
kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
|
|
21064
21070
|
};
|
|
21065
21071
|
var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
21072
|
+
external_exports.strictObject({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifier }).readonly(),
|
|
21073
|
+
external_exports.strictObject({
|
|
21074
|
+
...resultEnvelope,
|
|
21075
|
+
action: external_exports.literal("linked-history"),
|
|
21076
|
+
targetSessionId: identifier,
|
|
21077
|
+
history: sessionHistorySchema
|
|
21078
|
+
}).readonly(),
|
|
21079
|
+
external_exports.strictObject({
|
|
21080
|
+
...resultEnvelope,
|
|
21081
|
+
action: external_exports.literal("unlinked-history"),
|
|
21082
|
+
targetSessionId: identifier
|
|
21083
|
+
}).readonly(),
|
|
21066
21084
|
external_exports.strictObject({
|
|
21067
21085
|
...resultEnvelope,
|
|
21068
21086
|
action: external_exports.literal("find"),
|
|
@@ -21092,6 +21110,13 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
21092
21110
|
history: sessionHistorySchema,
|
|
21093
21111
|
title: external_exports.string().max(500)
|
|
21094
21112
|
}).readonly(),
|
|
21113
|
+
external_exports.strictObject({
|
|
21114
|
+
...resultEnvelope,
|
|
21115
|
+
action: external_exports.literal("history"),
|
|
21116
|
+
entryId: identifier,
|
|
21117
|
+
history: sessionHistorySchema,
|
|
21118
|
+
title: external_exports.string().max(500)
|
|
21119
|
+
}).readonly(),
|
|
21095
21120
|
external_exports.strictObject({
|
|
21096
21121
|
...resultEnvelope,
|
|
21097
21122
|
action: external_exports.literal("delete"),
|
|
@@ -22349,7 +22374,6 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
|
|
|
22349
22374
|
return {
|
|
22350
22375
|
agents: daemonAgents,
|
|
22351
22376
|
defaultWorkspace: connection.defaultWorkspace,
|
|
22352
|
-
auditDatabasePath: connection.auditDatabasePath,
|
|
22353
22377
|
bindingId: "workspace",
|
|
22354
22378
|
catalog: new LocalAgentCatalog(daemonAgents, installableAgents),
|
|
22355
22379
|
channelId: connection.channelId,
|
|
@@ -22370,7 +22394,6 @@ function loadDaemonConfig() {
|
|
|
22370
22394
|
return createDaemonConfig(
|
|
22371
22395
|
{
|
|
22372
22396
|
defaultWorkspace: loadDefaultWorkspace(),
|
|
22373
|
-
auditDatabasePath: process.env["MOBIUS_AUDIT_DATABASE"] ?? fileURLToPath(new URL("../../../.mobius/daemon.sqlite", import.meta.url)),
|
|
22374
22397
|
channelId: process.env["MOBIUS_CHANNEL_ID"] ?? "local",
|
|
22375
22398
|
relayUrl
|
|
22376
22399
|
},
|
|
@@ -22391,7 +22414,7 @@ import {
|
|
|
22391
22414
|
// src/authorization/local-raster.ts
|
|
22392
22415
|
import { open as open2, readFile as readFile2, realpath as realpath2, stat as stat2 } from "node:fs/promises";
|
|
22393
22416
|
import { basename, isAbsolute, normalize } from "node:path";
|
|
22394
|
-
import { fileURLToPath
|
|
22417
|
+
import { fileURLToPath } from "node:url";
|
|
22395
22418
|
var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
|
|
22396
22419
|
var MAX_INLINE_RASTER_BYTES = 3e6;
|
|
22397
22420
|
var PNG_SIGNATURE = Uint8Array.of(137, 80, 78, 71);
|
|
@@ -22488,7 +22511,7 @@ function parseLocalImageUri(uri) {
|
|
|
22488
22511
|
if (url2.protocol !== "file:" || url2.host.length > 0) {
|
|
22489
22512
|
return null;
|
|
22490
22513
|
}
|
|
22491
|
-
return
|
|
22514
|
+
return fileURLToPath(url2);
|
|
22492
22515
|
} catch {
|
|
22493
22516
|
return null;
|
|
22494
22517
|
}
|
|
@@ -30920,9 +30943,6 @@ var AcpHistoryReplay = class {
|
|
|
30920
30943
|
};
|
|
30921
30944
|
|
|
30922
30945
|
// src/acp/session-store.ts
|
|
30923
|
-
import { mkdirSync } from "node:fs";
|
|
30924
|
-
import { dirname } from "node:path";
|
|
30925
|
-
import { DatabaseSync } from "node:sqlite";
|
|
30926
30946
|
var AcpStoredSession = class {
|
|
30927
30947
|
additionalDirectories;
|
|
30928
30948
|
agentId;
|
|
@@ -30955,44 +30975,6 @@ var FoundAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
|
30955
30975
|
var DeletedAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
30956
30976
|
found = false;
|
|
30957
30977
|
};
|
|
30958
|
-
function readString3(value, field) {
|
|
30959
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
30960
|
-
throw new Error(`Stored ACP session has an invalid ${field}`);
|
|
30961
|
-
}
|
|
30962
|
-
return value;
|
|
30963
|
-
}
|
|
30964
|
-
function readAdditionalDirectories(value) {
|
|
30965
|
-
if (typeof value !== "string") {
|
|
30966
|
-
throw new Error("Stored ACP session has invalid additional directories");
|
|
30967
|
-
}
|
|
30968
|
-
const decoded = JSON.parse(value);
|
|
30969
|
-
if (!Array.isArray(decoded) || decoded.some((directory) => typeof directory !== "string")) {
|
|
30970
|
-
throw new Error("Stored ACP session has invalid additional directories");
|
|
30971
|
-
}
|
|
30972
|
-
return decoded;
|
|
30973
|
-
}
|
|
30974
|
-
function readPrompted(value) {
|
|
30975
|
-
if (value === 0) {
|
|
30976
|
-
return false;
|
|
30977
|
-
}
|
|
30978
|
-
if (value === 1) {
|
|
30979
|
-
return true;
|
|
30980
|
-
}
|
|
30981
|
-
throw new Error("Stored ACP session has an invalid prompted state");
|
|
30982
|
-
}
|
|
30983
|
-
function decodeSessionRow(row) {
|
|
30984
|
-
if (typeof row !== "object" || row === null || Array.isArray(row)) {
|
|
30985
|
-
throw new Error("Stored ACP session is not an object");
|
|
30986
|
-
}
|
|
30987
|
-
return new AcpStoredSession(
|
|
30988
|
-
readString3(Reflect.get(row, "session_id"), "session ID"),
|
|
30989
|
-
readString3(Reflect.get(row, "agent_id"), "agent ID"),
|
|
30990
|
-
readString3(Reflect.get(row, "native_session_id"), "native session ID"),
|
|
30991
|
-
readString3(Reflect.get(row, "cwd"), "working directory"),
|
|
30992
|
-
readAdditionalDirectories(Reflect.get(row, "additional_directories_json")),
|
|
30993
|
-
readPrompted(Reflect.get(row, "prompted"))
|
|
30994
|
-
);
|
|
30995
|
-
}
|
|
30996
30978
|
var MemoryAcpSessionStore = class {
|
|
30997
30979
|
#sessions = /* @__PURE__ */ new Map();
|
|
30998
30980
|
#deleted = /* @__PURE__ */ new Set();
|
|
@@ -31021,106 +31003,6 @@ var MemoryAcpSessionStore = class {
|
|
|
31021
31003
|
this.#sessions.set(session.sessionId, session);
|
|
31022
31004
|
};
|
|
31023
31005
|
};
|
|
31024
|
-
var SqliteAcpSessionStore = class {
|
|
31025
|
-
#database;
|
|
31026
|
-
constructor(path2) {
|
|
31027
|
-
mkdirSync(dirname(path2), { recursive: true });
|
|
31028
|
-
this.#database = new DatabaseSync(path2);
|
|
31029
|
-
this.#database.exec(`
|
|
31030
|
-
CREATE TABLE IF NOT EXISTS acp_deleted_sessions (session_id TEXT PRIMARY KEY) STRICT;
|
|
31031
|
-
CREATE TABLE IF NOT EXISTS acp_sessions (
|
|
31032
|
-
session_id TEXT PRIMARY KEY,
|
|
31033
|
-
agent_id TEXT NOT NULL,
|
|
31034
|
-
native_session_id TEXT NOT NULL,
|
|
31035
|
-
cwd TEXT NOT NULL,
|
|
31036
|
-
additional_directories_json TEXT NOT NULL,
|
|
31037
|
-
prompted INTEGER NOT NULL DEFAULT 0 CHECK (prompted IN (0, 1)),
|
|
31038
|
-
updated_at TEXT NOT NULL
|
|
31039
|
-
) STRICT
|
|
31040
|
-
`);
|
|
31041
|
-
const columns = this.#database.prepare("PRAGMA table_info(acp_sessions)").all();
|
|
31042
|
-
const hasPromptedColumn = columns.some(
|
|
31043
|
-
(column) => typeof column === "object" && column !== null && Reflect.get(column, "name") === "prompted"
|
|
31044
|
-
);
|
|
31045
|
-
if (!hasPromptedColumn) {
|
|
31046
|
-
this.#database.exec(`
|
|
31047
|
-
ALTER TABLE acp_sessions
|
|
31048
|
-
ADD COLUMN prompted INTEGER NOT NULL DEFAULT 1 CHECK (prompted IN (0, 1))
|
|
31049
|
-
`);
|
|
31050
|
-
}
|
|
31051
|
-
}
|
|
31052
|
-
read = (sessionId) => {
|
|
31053
|
-
if (this.#database.prepare("SELECT session_id FROM acp_deleted_sessions WHERE session_id = ?").get(sessionId) !== void 0) {
|
|
31054
|
-
return new DeletedAcpStoredSession();
|
|
31055
|
-
}
|
|
31056
|
-
const row = this.#database.prepare(
|
|
31057
|
-
`
|
|
31058
|
-
SELECT
|
|
31059
|
-
session_id,
|
|
31060
|
-
agent_id,
|
|
31061
|
-
native_session_id,
|
|
31062
|
-
cwd,
|
|
31063
|
-
additional_directories_json,
|
|
31064
|
-
prompted
|
|
31065
|
-
FROM acp_sessions
|
|
31066
|
-
WHERE session_id = ?
|
|
31067
|
-
`
|
|
31068
|
-
).get(sessionId);
|
|
31069
|
-
return row === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(decodeSessionRow(row));
|
|
31070
|
-
};
|
|
31071
|
-
remove = (sessionId) => {
|
|
31072
|
-
this.#database.prepare("DELETE FROM acp_sessions WHERE session_id = ?").run(sessionId);
|
|
31073
|
-
};
|
|
31074
|
-
findNative = (agentId, nativeSessionId) => this.#database.prepare("SELECT * FROM acp_sessions WHERE agent_id = ? AND native_session_id = ?").all(agentId, nativeSessionId).map(decodeSessionRow);
|
|
31075
|
-
markDeleted = (agentId, nativeSessionId) => {
|
|
31076
|
-
const ids = this.findNative(agentId, nativeSessionId).map((session) => session.sessionId);
|
|
31077
|
-
this.#database.exec("BEGIN");
|
|
31078
|
-
try {
|
|
31079
|
-
for (const id of ids) {
|
|
31080
|
-
this.#database.prepare("INSERT OR IGNORE INTO acp_deleted_sessions (session_id) VALUES (?)").run(id);
|
|
31081
|
-
this.remove(id);
|
|
31082
|
-
}
|
|
31083
|
-
this.#database.exec("COMMIT");
|
|
31084
|
-
return ids;
|
|
31085
|
-
} catch (error62) {
|
|
31086
|
-
this.#database.exec("ROLLBACK");
|
|
31087
|
-
throw error62;
|
|
31088
|
-
}
|
|
31089
|
-
};
|
|
31090
|
-
write = (session) => {
|
|
31091
|
-
this.#database.prepare(
|
|
31092
|
-
`
|
|
31093
|
-
INSERT INTO acp_sessions (
|
|
31094
|
-
session_id,
|
|
31095
|
-
agent_id,
|
|
31096
|
-
native_session_id,
|
|
31097
|
-
cwd,
|
|
31098
|
-
additional_directories_json,
|
|
31099
|
-
prompted,
|
|
31100
|
-
updated_at
|
|
31101
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
31102
|
-
ON CONFLICT(session_id) DO UPDATE SET
|
|
31103
|
-
agent_id = excluded.agent_id,
|
|
31104
|
-
native_session_id = excluded.native_session_id,
|
|
31105
|
-
cwd = excluded.cwd,
|
|
31106
|
-
additional_directories_json = excluded.additional_directories_json,
|
|
31107
|
-
prompted = excluded.prompted,
|
|
31108
|
-
updated_at = excluded.updated_at
|
|
31109
|
-
`
|
|
31110
|
-
).run(
|
|
31111
|
-
session.sessionId,
|
|
31112
|
-
session.agentId,
|
|
31113
|
-
session.nativeSessionId,
|
|
31114
|
-
session.cwd,
|
|
31115
|
-
JSON.stringify(session.additionalDirectories),
|
|
31116
|
-
session.prompted ? 1 : 0,
|
|
31117
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
31118
|
-
);
|
|
31119
|
-
};
|
|
31120
|
-
close = () => {
|
|
31121
|
-
this.#database.close();
|
|
31122
|
-
};
|
|
31123
|
-
};
|
|
31124
31006
|
|
|
31125
31007
|
// src/acp/session-manager.ts
|
|
31126
31008
|
var PROCESS_STOP_TIMEOUT_MILLISECONDS = 1e3;
|
|
@@ -31347,7 +31229,7 @@ function truncate3(value, maximumLength) {
|
|
|
31347
31229
|
function isRecord5(value) {
|
|
31348
31230
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31349
31231
|
}
|
|
31350
|
-
function
|
|
31232
|
+
function readString3(value, fallback = "") {
|
|
31351
31233
|
return typeof value === "string" ? value : fallback;
|
|
31352
31234
|
}
|
|
31353
31235
|
function arraysEqual(left, right) {
|
|
@@ -31380,8 +31262,8 @@ function normalizeElicitationOptions(schema) {
|
|
|
31380
31262
|
for (const option of oneOf) {
|
|
31381
31263
|
if (isRecord5(option) && typeof option["const"] === "string") {
|
|
31382
31264
|
normalized.push({
|
|
31383
|
-
description: truncate3(
|
|
31384
|
-
label: truncate3(
|
|
31265
|
+
description: truncate3(readString3(option["description"]), 500),
|
|
31266
|
+
label: truncate3(readString3(option["title"], option["const"]), 255),
|
|
31385
31267
|
value: truncate3(option["const"], 500)
|
|
31386
31268
|
});
|
|
31387
31269
|
}
|
|
@@ -31432,8 +31314,8 @@ function normalizeElicitationFields(requestedSchema) {
|
|
|
31432
31314
|
defaultBooleanValue: typeof defaultValue === "boolean" ? defaultValue : false,
|
|
31433
31315
|
defaultNumberValue: typeof defaultValue === "number" && Number.isFinite(defaultValue) ? defaultValue : 0,
|
|
31434
31316
|
defaultStringValue: typeof defaultValue === "string" ? truncate3(defaultValue, 1e4) : Array.isArray(defaultValue) ? truncate3(JSON.stringify(defaultValue), 1e4) : "",
|
|
31435
|
-
description: truncate3(
|
|
31436
|
-
format: truncate3(
|
|
31317
|
+
description: truncate3(readString3(property["description"]), 500),
|
|
31318
|
+
format: truncate3(readString3(property["format"]), 64),
|
|
31437
31319
|
hasDefaultValue: defaultValue !== void 0 && defaultValue !== null,
|
|
31438
31320
|
maximum: numericString(property["maximum"]),
|
|
31439
31321
|
maximumLength: numericString(property["maxLength"] ?? property["maxItems"]),
|
|
@@ -31441,9 +31323,9 @@ function normalizeElicitationFields(requestedSchema) {
|
|
|
31441
31323
|
minimumLength: numericString(property["minLength"] ?? property["minItems"]),
|
|
31442
31324
|
name: truncate3(name, 128),
|
|
31443
31325
|
options,
|
|
31444
|
-
pattern: truncate3(
|
|
31326
|
+
pattern: truncate3(readString3(property["pattern"]), 500),
|
|
31445
31327
|
required: required2.has(name),
|
|
31446
|
-
title: truncate3(
|
|
31328
|
+
title: truncate3(readString3(property["title"], name), 255),
|
|
31447
31329
|
type: normalizedType
|
|
31448
31330
|
});
|
|
31449
31331
|
}
|
|
@@ -32282,6 +32164,17 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
32282
32164
|
);
|
|
32283
32165
|
};
|
|
32284
32166
|
nativeSessionId = () => this.#nativeSessionId;
|
|
32167
|
+
adoptNativeSessionId = (sessionId) => {
|
|
32168
|
+
if (this.#prompted || this.#nativeSessionId !== sessionId) {
|
|
32169
|
+
throw new AcpExecutionError("The new Codex Session cannot be adopted", {}, "session_identity_mismatch");
|
|
32170
|
+
}
|
|
32171
|
+
const previousSessionId = this.#mobiusSessionId;
|
|
32172
|
+
this.#store.write(
|
|
32173
|
+
new AcpStoredSession(sessionId, this.#agentId, sessionId, this.#cwd, this.#additionalDirectories, false)
|
|
32174
|
+
);
|
|
32175
|
+
this.#store.remove(previousSessionId);
|
|
32176
|
+
this.#mobiusSessionId = sessionId;
|
|
32177
|
+
};
|
|
32285
32178
|
configure = async (options) => {
|
|
32286
32179
|
const existing = this.#configOptions.find((option) => option.id === options.configId);
|
|
32287
32180
|
if (existing === void 0 || existing.type !== options.valueType) {
|
|
@@ -32675,7 +32568,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
32675
32568
|
message: truncate3(request.message, 2e3),
|
|
32676
32569
|
mode: request.mode,
|
|
32677
32570
|
sessionId: this.#mobiusSessionId,
|
|
32678
|
-
url: request.mode === "url" && typeof Reflect.get(request, "url") === "string" ? truncate3(
|
|
32571
|
+
url: request.mode === "url" && typeof Reflect.get(request, "url") === "string" ? truncate3(readString3(Reflect.get(request, "url")), 4096) : ""
|
|
32679
32572
|
});
|
|
32680
32573
|
return await pending.completion.promise;
|
|
32681
32574
|
} finally {
|
|
@@ -33035,11 +32928,13 @@ var AcpSessionManager = class {
|
|
|
33035
32928
|
#transientProcessCount = 0;
|
|
33036
32929
|
#store;
|
|
33037
32930
|
#nativeHistoryReader;
|
|
32931
|
+
#sessionIdentity;
|
|
33038
32932
|
#observer;
|
|
33039
|
-
constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader = null) {
|
|
32933
|
+
constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader = null, sessionIdentity = "assigned") {
|
|
33040
32934
|
this.#observer = observer;
|
|
33041
32935
|
this.#store = store;
|
|
33042
32936
|
this.#nativeHistoryReader = nativeHistoryReader;
|
|
32937
|
+
this.#sessionIdentity = sessionIdentity;
|
|
33043
32938
|
}
|
|
33044
32939
|
setObserver = (observer) => {
|
|
33045
32940
|
this.#observer = observer;
|
|
@@ -33151,7 +33046,13 @@ var AcpSessionManager = class {
|
|
|
33151
33046
|
if (retained) {
|
|
33152
33047
|
this.#sessions.delete(sessionId);
|
|
33153
33048
|
}
|
|
33154
|
-
|
|
33049
|
+
try {
|
|
33050
|
+
await this.#retireProcess(runtime, retained, close);
|
|
33051
|
+
} finally {
|
|
33052
|
+
if (retained && this.#sessionIdentity === "native") {
|
|
33053
|
+
this.#store.remove(sessionId);
|
|
33054
|
+
}
|
|
33055
|
+
}
|
|
33155
33056
|
}
|
|
33156
33057
|
async #retireNativeBrowserProcess(sessionId, runtime, close) {
|
|
33157
33058
|
const retained = this.#nativeBrowserSessions.get(sessionId) === runtime;
|
|
@@ -33298,7 +33199,14 @@ var AcpSessionManager = class {
|
|
|
33298
33199
|
try {
|
|
33299
33200
|
return await this.#startRetainedSessionProcess(
|
|
33300
33201
|
options,
|
|
33301
|
-
async () => await AcpProcessSession.start(
|
|
33202
|
+
async () => await AcpProcessSession.start(
|
|
33203
|
+
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(
|
|
33204
|
+
options.sessionId
|
|
33205
|
+
) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
|
|
33206
|
+
() => this.#observer,
|
|
33207
|
+
this.#store,
|
|
33208
|
+
metrics
|
|
33209
|
+
)
|
|
33302
33210
|
);
|
|
33303
33211
|
} finally {
|
|
33304
33212
|
this.#preparing.delete(options.sessionId);
|
|
@@ -33721,6 +33629,45 @@ var AcpSessionManager = class {
|
|
|
33721
33629
|
]);
|
|
33722
33630
|
};
|
|
33723
33631
|
hasPreparedSession = (sessionId, agentId, cwd, additionalDirectories) => this.#sessions.get(sessionId)?.belongsTo(agentId, cwd, additionalDirectories) === true;
|
|
33632
|
+
createNativeSession = async (options) => {
|
|
33633
|
+
const temporarySessionId = `new-${crypto.randomUUID()}`;
|
|
33634
|
+
const temporaryOptions = { ...options, sessionId: temporarySessionId };
|
|
33635
|
+
this.#beginSessionUse(temporarySessionId);
|
|
33636
|
+
try {
|
|
33637
|
+
const runtime = await this.#startPreparation(temporaryOptions);
|
|
33638
|
+
let adopted = false;
|
|
33639
|
+
try {
|
|
33640
|
+
const nativeSessionId = runtime.nativeSessionId();
|
|
33641
|
+
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)) {
|
|
33642
|
+
throw new AcpExecutionError(
|
|
33643
|
+
"Codex returned an invalid new Session ID",
|
|
33644
|
+
{},
|
|
33645
|
+
"invalid_native_session_response"
|
|
33646
|
+
);
|
|
33647
|
+
}
|
|
33648
|
+
runtime.adoptNativeSessionId(nativeSessionId);
|
|
33649
|
+
this.#sessions.delete(temporarySessionId);
|
|
33650
|
+
this.#sessions.set(nativeSessionId, runtime);
|
|
33651
|
+
this.#retainedProcesses.set(
|
|
33652
|
+
runtime,
|
|
33653
|
+
new FoundAcpSessionProcessEvictionCandidate(nativeSessionId, runtime)
|
|
33654
|
+
);
|
|
33655
|
+
adopted = true;
|
|
33656
|
+
return nativeSessionId;
|
|
33657
|
+
} finally {
|
|
33658
|
+
if (!adopted) {
|
|
33659
|
+
await this.#retireSessionProcess(
|
|
33660
|
+
temporarySessionId,
|
|
33661
|
+
runtime,
|
|
33662
|
+
async () => await runtime.closeProcess()
|
|
33663
|
+
);
|
|
33664
|
+
}
|
|
33665
|
+
}
|
|
33666
|
+
} finally {
|
|
33667
|
+
this.#store.remove(temporarySessionId);
|
|
33668
|
+
this.#endSessionUse(temporarySessionId);
|
|
33669
|
+
}
|
|
33670
|
+
};
|
|
33724
33671
|
ensureSession = async (options) => {
|
|
33725
33672
|
const existing = this.#sessions.get(options.sessionId);
|
|
33726
33673
|
if (existing !== void 0) {
|
|
@@ -33814,6 +33761,25 @@ var AcpSessionManager = class {
|
|
|
33814
33761
|
this.#endSessionUse(options.sessionId);
|
|
33815
33762
|
}
|
|
33816
33763
|
};
|
|
33764
|
+
loadLinkedSessionHistory = async (options) => {
|
|
33765
|
+
options.signal.throwIfAborted();
|
|
33766
|
+
const stored = this.#store.read(options.sessionId);
|
|
33767
|
+
if (!(stored instanceof FoundAcpStoredSession) || !stored.session.prompted) {
|
|
33768
|
+
return null;
|
|
33769
|
+
}
|
|
33770
|
+
const linked = stored.session;
|
|
33771
|
+
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])) {
|
|
33772
|
+
throw new AcpExecutionError(
|
|
33773
|
+
"The session belongs to another Agent or workspace",
|
|
33774
|
+
{},
|
|
33775
|
+
"session_identity_mismatch"
|
|
33776
|
+
);
|
|
33777
|
+
}
|
|
33778
|
+
if (this.#nativeHistoryReader === null) {
|
|
33779
|
+
return await this.loadSessionHistory(options);
|
|
33780
|
+
}
|
|
33781
|
+
return await this.#nativeHistoryReader.read(options, linked.nativeSessionId);
|
|
33782
|
+
};
|
|
33817
33783
|
openNativeSession = async (options, origin, loadHistory) => {
|
|
33818
33784
|
const key = `${options.agent.id}:${origin.nativeSessionId}`;
|
|
33819
33785
|
if (this.#nativeOperations.has(key)) {
|
|
@@ -34033,51 +33999,20 @@ async function runAcpPrompt(options) {
|
|
|
34033
33999
|
}
|
|
34034
34000
|
|
|
34035
34001
|
// src/audit/audit-store.ts
|
|
34036
|
-
|
|
34037
|
-
import { dirname as dirname2 } from "node:path";
|
|
34038
|
-
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
34002
|
+
var MAX_AUDIT_RECORDS = 1024;
|
|
34039
34003
|
var AuditStore = class {
|
|
34040
|
-
|
|
34041
|
-
|
|
34042
|
-
|
|
34043
|
-
|
|
34044
|
-
|
|
34045
|
-
|
|
34046
|
-
|
|
34047
|
-
recorded_at TEXT NOT NULL,
|
|
34048
|
-
event TEXT NOT NULL,
|
|
34049
|
-
command_id TEXT NOT NULL,
|
|
34050
|
-
session_id TEXT NOT NULL,
|
|
34051
|
-
details_json TEXT NOT NULL DEFAULT '{}'
|
|
34052
|
-
) STRICT
|
|
34053
|
-
`);
|
|
34054
|
-
const columns = this.database.prepare("PRAGMA table_info(audit_events)").all();
|
|
34055
|
-
if (!columns.some((column) => Reflect.get(column, "name") === "details_json")) {
|
|
34056
|
-
this.database.exec("ALTER TABLE audit_events ADD COLUMN details_json TEXT NOT NULL DEFAULT '{}'");
|
|
34057
|
-
}
|
|
34058
|
-
}
|
|
34059
|
-
record(record2) {
|
|
34060
|
-
this.database.prepare(
|
|
34061
|
-
`
|
|
34062
|
-
INSERT INTO audit_events (
|
|
34063
|
-
recorded_at,
|
|
34064
|
-
event,
|
|
34065
|
-
command_id,
|
|
34066
|
-
session_id,
|
|
34067
|
-
details_json
|
|
34068
|
-
) VALUES (?, ?, ?, ?, ?)
|
|
34069
|
-
`
|
|
34070
|
-
).run(
|
|
34071
|
-
(/* @__PURE__ */ new Date()).toISOString(),
|
|
34072
|
-
record2.event,
|
|
34073
|
-
record2.commandId,
|
|
34074
|
-
record2.sessionId,
|
|
34075
|
-
JSON.stringify(record2.details ?? {})
|
|
34004
|
+
#records = [];
|
|
34005
|
+
record = (record2) => {
|
|
34006
|
+
if (this.#records.length === MAX_AUDIT_RECORDS) {
|
|
34007
|
+
this.#records.shift();
|
|
34008
|
+
}
|
|
34009
|
+
this.#records.push(
|
|
34010
|
+
record2.details === void 0 ? { ...record2 } : { ...record2, details: { ...record2.details } }
|
|
34076
34011
|
);
|
|
34077
|
-
}
|
|
34078
|
-
close() {
|
|
34079
|
-
this.
|
|
34080
|
-
}
|
|
34012
|
+
};
|
|
34013
|
+
close = () => {
|
|
34014
|
+
this.#records.length = 0;
|
|
34015
|
+
};
|
|
34081
34016
|
};
|
|
34082
34017
|
|
|
34083
34018
|
// src/authorization/local-authorization-error.ts
|
|
@@ -34203,7 +34138,7 @@ var LocalAgentInventory = class {
|
|
|
34203
34138
|
|
|
34204
34139
|
// src/agent-installation/managed-npm-package.ts
|
|
34205
34140
|
import { mkdir, mkdtemp, open as open3, realpath as realpath3, rename, rm, stat as stat3 } from "node:fs/promises";
|
|
34206
|
-
import { delimiter, dirname
|
|
34141
|
+
import { delimiter, dirname, isAbsolute as isAbsolute2, join as join4, relative, sep } from "node:path";
|
|
34207
34142
|
var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
|
|
34208
34143
|
var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
|
|
34209
34144
|
var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
|
|
@@ -34433,7 +34368,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
34433
34368
|
throw error62;
|
|
34434
34369
|
}
|
|
34435
34370
|
}
|
|
34436
|
-
const parent =
|
|
34371
|
+
const parent = dirname(root);
|
|
34437
34372
|
await mkdir(parent, { mode: 448, recursive: true });
|
|
34438
34373
|
const staging = await mkdtemp(join4(parent, `.${definition2.version}.staging-`));
|
|
34439
34374
|
try {
|
|
@@ -34468,7 +34403,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
34468
34403
|
NPM_CONFIG_IGNORE_SCRIPTS: "true",
|
|
34469
34404
|
NPM_CONFIG_PACKAGE_LOCK: "true",
|
|
34470
34405
|
NPM_CONFIG_REGISTRY: "https://registry.npmjs.org/",
|
|
34471
|
-
PATH: `${
|
|
34406
|
+
PATH: `${dirname(process.execPath)}${delimiter}/usr/bin${delimiter}/bin`
|
|
34472
34407
|
};
|
|
34473
34408
|
if (definition2.includeOptionalDependencies) {
|
|
34474
34409
|
installEnvironment["NPM_CONFIG_INCLUDE"] = "optional";
|
|
@@ -35333,18 +35268,17 @@ function effortValues(model) {
|
|
|
35333
35268
|
}
|
|
35334
35269
|
function modelSetting(models, currentValue) {
|
|
35335
35270
|
const values = modelValues(models);
|
|
35336
|
-
const current =
|
|
35271
|
+
const current = values.some((value) => value.value === currentValue) ? currentValue : models.find((model) => model.isDefault === true)?.id ?? values[0]?.value ?? "";
|
|
35337
35272
|
if (current.length === 0) {
|
|
35338
35273
|
return null;
|
|
35339
35274
|
}
|
|
35340
|
-
const options = values.some((value) => value.value === current) ? values : [{ description: "", name: current, value: current }, ...values];
|
|
35341
35275
|
return {
|
|
35342
35276
|
category: "model",
|
|
35343
35277
|
currentValue: current,
|
|
35344
35278
|
description: "Model Codex uses for the session",
|
|
35345
35279
|
id: MODEL_SETTING_ID,
|
|
35346
35280
|
name: "Model",
|
|
35347
|
-
options,
|
|
35281
|
+
options: values,
|
|
35348
35282
|
type: "select"
|
|
35349
35283
|
};
|
|
35350
35284
|
}
|
|
@@ -36632,7 +36566,7 @@ import { join as join10 } from "node:path";
|
|
|
36632
36566
|
import { createHash } from "node:crypto";
|
|
36633
36567
|
import { createReadStream } from "node:fs";
|
|
36634
36568
|
import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open4, realpath as realpath6, rename as rename2, rm as rm2, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
|
|
36635
|
-
import { delimiter as delimiter2, dirname as
|
|
36569
|
+
import { delimiter as delimiter2, dirname as dirname2, isAbsolute as isAbsolute6, join as join9, relative as relative3, sep as sep3 } from "node:path";
|
|
36636
36570
|
|
|
36637
36571
|
// src/agent-installation/verified-download.ts
|
|
36638
36572
|
import { fetch } from "undici";
|
|
@@ -37932,7 +37866,7 @@ async function discoverLocalAgentInventory(options) {
|
|
|
37932
37866
|
// src/storage/runtime-installation-store.ts
|
|
37933
37867
|
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
37934
37868
|
import { mkdir as mkdir4, open as open5, readdir as readdir2, rename as rename3, unlink, writeFile as writeFile3 } from "node:fs/promises";
|
|
37935
|
-
import { dirname as
|
|
37869
|
+
import { dirname as dirname3, join as join15, resolve as resolve4 } from "node:path";
|
|
37936
37870
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
37937
37871
|
var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
|
|
37938
37872
|
var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
|
|
@@ -38273,7 +38207,7 @@ async function readJsonFile(path2, signal, missingCode) {
|
|
|
38273
38207
|
}
|
|
38274
38208
|
async function writeJsonAtomically(path2, value, signal) {
|
|
38275
38209
|
signal.throwIfAborted();
|
|
38276
|
-
const directory =
|
|
38210
|
+
const directory = dirname3(path2);
|
|
38277
38211
|
const temporaryPath = join15(directory, `.${randomUUID()}.tmp`);
|
|
38278
38212
|
try {
|
|
38279
38213
|
await mkdir4(directory, { mode: 448, recursive: true });
|
|
@@ -38336,7 +38270,6 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
38336
38270
|
return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
|
|
38337
38271
|
};
|
|
38338
38272
|
connectionPath = (connectionId2) => join15(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
|
|
38339
|
-
auditDatabasePath = (connectionId2) => join15(this.stateDirectory, "audit", `${validateConnectionId(connectionId2)}.sqlite`);
|
|
38340
38273
|
channelIndexPath = (channelId) => join15(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
|
|
38341
38274
|
readConnection = async (connectionId2, signal) => {
|
|
38342
38275
|
const stored = decodeConnection(
|
|
@@ -38775,7 +38708,6 @@ function buildPairedDaemon(installation, connection, defaultWorkspace, inventory
|
|
|
38775
38708
|
config: createDaemonConfig(
|
|
38776
38709
|
{
|
|
38777
38710
|
defaultWorkspace,
|
|
38778
|
-
auditDatabasePath: installation.auditDatabasePath(connection.connectionId),
|
|
38779
38711
|
channelId: connection.channelId,
|
|
38780
38712
|
relayUrl
|
|
38781
38713
|
},
|
|
@@ -38895,7 +38827,7 @@ function isRuntimeRelayRevocation(closeCode, closeReason) {
|
|
|
38895
38827
|
}
|
|
38896
38828
|
|
|
38897
38829
|
// src/run-daemon.ts
|
|
38898
|
-
import { createHash as
|
|
38830
|
+
import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
|
|
38899
38831
|
import { basename as basename7 } from "node:path";
|
|
38900
38832
|
import { styleText } from "node:util";
|
|
38901
38833
|
import { fetch as fetch5, WebSocket as WebSocket2 } from "undici";
|
|
@@ -39681,7 +39613,7 @@ var FixedInstallationExecutor = class {
|
|
|
39681
39613
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
39682
39614
|
import { realpath as realpath8, stat as stat7 } from "node:fs/promises";
|
|
39683
39615
|
import { basename as basename4, isAbsolute as isAbsolute9, normalize as normalize3 } from "node:path";
|
|
39684
|
-
import { fileURLToPath as
|
|
39616
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
39685
39617
|
var CHUNK_BYTES = 192 * 1024;
|
|
39686
39618
|
function requestedPath(value) {
|
|
39687
39619
|
if (value.includes("\0")) {
|
|
@@ -39690,7 +39622,7 @@ function requestedPath(value) {
|
|
|
39690
39622
|
if (value.startsWith("file:")) {
|
|
39691
39623
|
try {
|
|
39692
39624
|
const url2 = new URL(value);
|
|
39693
|
-
return url2.protocol === "file:" && url2.host.length === 0 ?
|
|
39625
|
+
return url2.protocol === "file:" && url2.host.length === 0 ? fileURLToPath2(url2) : null;
|
|
39694
39626
|
} catch {
|
|
39695
39627
|
return null;
|
|
39696
39628
|
}
|
|
@@ -39759,7 +39691,7 @@ async function streamLocalFile(command, send2, signal) {
|
|
|
39759
39691
|
// src/authorization/workspace-directory.ts
|
|
39760
39692
|
import { readdir as readdir3, realpath as realpath9, stat as stat8 } from "node:fs/promises";
|
|
39761
39693
|
import { homedir as homedir2 } from "node:os";
|
|
39762
|
-
import { basename as basename5, dirname as
|
|
39694
|
+
import { basename as basename5, dirname as dirname4, isAbsolute as isAbsolute10, join as join16, normalize as normalize4, relative as relative4 } from "node:path";
|
|
39763
39695
|
var WorkspaceDirectoryListing = class {
|
|
39764
39696
|
directoryId;
|
|
39765
39697
|
directoryLabel;
|
|
@@ -39883,7 +39815,7 @@ var WorkspaceDirectoryService = class {
|
|
|
39883
39815
|
}
|
|
39884
39816
|
}
|
|
39885
39817
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
39886
|
-
const parent =
|
|
39818
|
+
const parent = dirname4(target);
|
|
39887
39819
|
return new WorkspaceDirectoryListing(
|
|
39888
39820
|
id,
|
|
39889
39821
|
this.label(target),
|
|
@@ -39908,7 +39840,7 @@ var WorkspaceDirectoryService = class {
|
|
|
39908
39840
|
};
|
|
39909
39841
|
|
|
39910
39842
|
// src/daemon-diagnostic-log.ts
|
|
39911
|
-
import { appendFileSync, mkdirSync
|
|
39843
|
+
import { appendFileSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
|
|
39912
39844
|
import { join as join17 } from "node:path";
|
|
39913
39845
|
var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
|
|
39914
39846
|
var DaemonDiagnosticLog = class {
|
|
@@ -39924,7 +39856,7 @@ var DaemonDiagnosticLog = class {
|
|
|
39924
39856
|
const encoded = `${diagnostic.replace(/[\r\n]+/gu, " ").trim()}
|
|
39925
39857
|
`;
|
|
39926
39858
|
const encodedBytes = Buffer.byteLength(encoded);
|
|
39927
|
-
|
|
39859
|
+
mkdirSync(this.#directory, { mode: 448, recursive: true });
|
|
39928
39860
|
let existingBytes = 0;
|
|
39929
39861
|
try {
|
|
39930
39862
|
existingBytes = statSync3(this.#path).size;
|
|
@@ -39977,7 +39909,7 @@ var turnsSchema = external_exports.object({
|
|
|
39977
39909
|
error: external_exports.unknown().nullish(),
|
|
39978
39910
|
items: external_exports.array(external_exports.unknown()).max(1e5)
|
|
39979
39911
|
})
|
|
39980
|
-
).max(
|
|
39912
|
+
).max(SESSION_HISTORY_MESSAGE_LIMIT),
|
|
39981
39913
|
nextCursor: external_exports.string().nullish()
|
|
39982
39914
|
});
|
|
39983
39915
|
var itemTypeSchema = external_exports.object({ type: external_exports.string().min(1).max(80) });
|
|
@@ -40164,7 +40096,7 @@ function decodeHistory(thread, value, options) {
|
|
|
40164
40096
|
messages.push(message);
|
|
40165
40097
|
characters += messageSize(message);
|
|
40166
40098
|
}
|
|
40167
|
-
while (messages.length > SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT || characters > SESSION_HISTORY_CHARACTER_LIMIT) {
|
|
40099
|
+
while (messages.length > (options.detail === "rich" ? SESSION_HISTORY_MESSAGE_LIMIT : SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT) || characters > SESSION_HISTORY_CHARACTER_LIMIT) {
|
|
40168
40100
|
const removed = messages.shift();
|
|
40169
40101
|
if (removed !== void 0) {
|
|
40170
40102
|
characters -= messageSize(removed);
|
|
@@ -40204,6 +40136,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
40204
40136
|
});
|
|
40205
40137
|
const response = Promise.withResolvers();
|
|
40206
40138
|
let state = { kind: "initializing", requestId: 1 };
|
|
40139
|
+
const seenCursors = /* @__PURE__ */ new Set();
|
|
40207
40140
|
let pending = "";
|
|
40208
40141
|
let receivedBytes = 0;
|
|
40209
40142
|
const fail = (cause) => response.reject(
|
|
@@ -40270,7 +40203,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
40270
40203
|
break;
|
|
40271
40204
|
case "metadata": {
|
|
40272
40205
|
const { thread } = threadSchema.parse(message.result);
|
|
40273
|
-
state = { kind: "turns", requestId: 3, thread };
|
|
40206
|
+
state = { kind: "turns", requestId: 3, thread, pages: [] };
|
|
40274
40207
|
send2({
|
|
40275
40208
|
id: state.requestId,
|
|
40276
40209
|
method: "thread/turns/list",
|
|
@@ -40283,9 +40216,45 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
40283
40216
|
});
|
|
40284
40217
|
break;
|
|
40285
40218
|
}
|
|
40286
|
-
case "turns":
|
|
40287
|
-
|
|
40288
|
-
|
|
40219
|
+
case "turns": {
|
|
40220
|
+
const page = turnsSchema.parse(message.result);
|
|
40221
|
+
const pages = [...state.pages, ...page.data];
|
|
40222
|
+
const maxTurns = options.detail === "rich" ? SESSION_HISTORY_MESSAGE_LIMIT : SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT;
|
|
40223
|
+
if (page.nextCursor == null || pages.length >= maxTurns) {
|
|
40224
|
+
response.resolve(
|
|
40225
|
+
decodeHistory(
|
|
40226
|
+
state.thread,
|
|
40227
|
+
{
|
|
40228
|
+
data: pages.slice(0, maxTurns),
|
|
40229
|
+
nextCursor: page.nextCursor
|
|
40230
|
+
},
|
|
40231
|
+
options
|
|
40232
|
+
)
|
|
40233
|
+
);
|
|
40234
|
+
return;
|
|
40235
|
+
}
|
|
40236
|
+
if (page.data.length === 0 || seenCursors.has(page.nextCursor)) {
|
|
40237
|
+
throw new AcpExecutionError(
|
|
40238
|
+
"Codex repeated a history page cursor.",
|
|
40239
|
+
{},
|
|
40240
|
+
"invalid_native_session_response"
|
|
40241
|
+
);
|
|
40242
|
+
}
|
|
40243
|
+
seenCursors.add(page.nextCursor);
|
|
40244
|
+
state = { kind: "turns", requestId: state.requestId + 1, thread: state.thread, pages };
|
|
40245
|
+
send2({
|
|
40246
|
+
id: state.requestId,
|
|
40247
|
+
method: "thread/turns/list",
|
|
40248
|
+
params: {
|
|
40249
|
+
threadId: nativeSessionId,
|
|
40250
|
+
cursor: page.nextCursor,
|
|
40251
|
+
limit: Math.min(SESSION_HISTORY_PREVIEW_MESSAGE_LIMIT, maxTurns - pages.length),
|
|
40252
|
+
sortDirection: "desc",
|
|
40253
|
+
itemsView: options.detail === "rich" ? "full" : "summary"
|
|
40254
|
+
}
|
|
40255
|
+
});
|
|
40256
|
+
break;
|
|
40257
|
+
}
|
|
40289
40258
|
default: {
|
|
40290
40259
|
const unhandled = state;
|
|
40291
40260
|
throw new Error(`Unknown history read state: ${String(unhandled)}`);
|
|
@@ -40306,7 +40275,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
40306
40275
|
);
|
|
40307
40276
|
const timeout = setTimeout(
|
|
40308
40277
|
() => fail(new AcpExecutionError("Reading saved Codex history timed out.", {}, "native_history_timeout")),
|
|
40309
|
-
15e3
|
|
40278
|
+
options.detail === "rich" ? 6e4 : 15e3
|
|
40310
40279
|
);
|
|
40311
40280
|
child.stdout.setEncoding("utf8");
|
|
40312
40281
|
child.stdout.on("data", onData);
|
|
@@ -40376,6 +40345,84 @@ var NativeSessionService = class {
|
|
|
40376
40345
|
sessionId: command.sessionId,
|
|
40377
40346
|
signal
|
|
40378
40347
|
};
|
|
40348
|
+
if (command.action === "linked-history") {
|
|
40349
|
+
if (options.agent.id !== "codex") {
|
|
40350
|
+
const history = await this.#sessions.loadLinkedSessionHistory({
|
|
40351
|
+
...options,
|
|
40352
|
+
sessionId: command.targetSessionId
|
|
40353
|
+
});
|
|
40354
|
+
this.record(command, "native_session_history_read");
|
|
40355
|
+
return history === null ? {
|
|
40356
|
+
action: "unlinked-history",
|
|
40357
|
+
kind: "native.session.result",
|
|
40358
|
+
requestId: command.requestId,
|
|
40359
|
+
sessionId: command.sessionId,
|
|
40360
|
+
targetSessionId: command.targetSessionId
|
|
40361
|
+
} : {
|
|
40362
|
+
action: "linked-history",
|
|
40363
|
+
history,
|
|
40364
|
+
kind: "native.session.result",
|
|
40365
|
+
requestId: command.requestId,
|
|
40366
|
+
sessionId: command.sessionId,
|
|
40367
|
+
targetSessionId: command.targetSessionId
|
|
40368
|
+
};
|
|
40369
|
+
}
|
|
40370
|
+
const nativeSessionId = nativeSessionIdSchema.parse(command.targetSessionId);
|
|
40371
|
+
if (this.#sessions.hasPreparedSession(nativeSessionId, options.agent.id, cwd, additionalDirectories) && await this.#sessions.loadLinkedSessionHistory({ ...options, sessionId: nativeSessionId }) === null) {
|
|
40372
|
+
this.record(command, "native_session_history_read");
|
|
40373
|
+
return {
|
|
40374
|
+
action: "linked-history",
|
|
40375
|
+
history: {
|
|
40376
|
+
status: "available",
|
|
40377
|
+
messages: [],
|
|
40378
|
+
truncated: false,
|
|
40379
|
+
coveredCommandIds: [],
|
|
40380
|
+
coveredMessageIds: []
|
|
40381
|
+
},
|
|
40382
|
+
kind: "native.session.result",
|
|
40383
|
+
requestId: command.requestId,
|
|
40384
|
+
sessionId: command.sessionId,
|
|
40385
|
+
targetSessionId: command.targetSessionId
|
|
40386
|
+
};
|
|
40387
|
+
}
|
|
40388
|
+
const snapshot = await readCodexFullHistory(options.agent, cwd, nativeSessionId, signal);
|
|
40389
|
+
const resolved = await this.#directories.identify(command.bindingId, snapshot.cwd, signal);
|
|
40390
|
+
if (snapshot.nativeSessionId !== nativeSessionId || resolved.path !== cwd) {
|
|
40391
|
+
throw new AcpExecutionError(
|
|
40392
|
+
"Codex returned history for a different session or workspace.",
|
|
40393
|
+
{},
|
|
40394
|
+
"invalid_native_session_response"
|
|
40395
|
+
);
|
|
40396
|
+
}
|
|
40397
|
+
this.record(command, "native_session_history_read");
|
|
40398
|
+
return {
|
|
40399
|
+
action: "linked-history",
|
|
40400
|
+
history: snapshot.history,
|
|
40401
|
+
kind: "native.session.result",
|
|
40402
|
+
requestId: command.requestId,
|
|
40403
|
+
sessionId: command.sessionId,
|
|
40404
|
+
targetSessionId: command.targetSessionId
|
|
40405
|
+
};
|
|
40406
|
+
}
|
|
40407
|
+
if (command.action === "create") {
|
|
40408
|
+
if (options.agent.id !== "codex") {
|
|
40409
|
+
throw new AcpExecutionError(
|
|
40410
|
+
"Native session creation is unavailable for this Agent",
|
|
40411
|
+
{},
|
|
40412
|
+
"native_session_unsupported"
|
|
40413
|
+
);
|
|
40414
|
+
}
|
|
40415
|
+
const nativeSessionId = await this.#sessions.createNativeSession(options);
|
|
40416
|
+
signal.throwIfAborted();
|
|
40417
|
+
this.record(command, "native_session_created");
|
|
40418
|
+
return {
|
|
40419
|
+
action: "create",
|
|
40420
|
+
kind: "native.session.result",
|
|
40421
|
+
nativeSessionId,
|
|
40422
|
+
requestId: command.requestId,
|
|
40423
|
+
sessionId: command.sessionId
|
|
40424
|
+
};
|
|
40425
|
+
}
|
|
40379
40426
|
const prepared = await this.#sessions.prepareNativeSessionBrowser(options);
|
|
40380
40427
|
if (!prepared.capabilities.listSessions) {
|
|
40381
40428
|
throw new AcpExecutionError(
|
|
@@ -40403,6 +40450,7 @@ var NativeSessionService = class {
|
|
|
40403
40450
|
});
|
|
40404
40451
|
return {
|
|
40405
40452
|
entryId,
|
|
40453
|
+
nativeSessionId: info.sessionId,
|
|
40406
40454
|
title: info.title ?? "Untitled session",
|
|
40407
40455
|
directoryId: authorized.directoryId,
|
|
40408
40456
|
directoryLabel: authorized.directoryLabel,
|
|
@@ -40508,6 +40556,18 @@ var NativeSessionService = class {
|
|
|
40508
40556
|
);
|
|
40509
40557
|
}
|
|
40510
40558
|
const target = await this.resolveTarget(command, options, selected);
|
|
40559
|
+
if (command.action === "history") {
|
|
40560
|
+
const history = await this.readHistory(command, options, target, signal);
|
|
40561
|
+
signal.throwIfAborted();
|
|
40562
|
+
this.record(command, "native_session_history_read");
|
|
40563
|
+
return {
|
|
40564
|
+
...envelope2,
|
|
40565
|
+
action: "history",
|
|
40566
|
+
entryId: command.entryId,
|
|
40567
|
+
history,
|
|
40568
|
+
title: target.info.title ?? "Untitled session"
|
|
40569
|
+
};
|
|
40570
|
+
}
|
|
40511
40571
|
if (command.action === "preview") {
|
|
40512
40572
|
const history = await this.previewHistory(command, options, target, signal);
|
|
40513
40573
|
signal.throwIfAborted();
|
|
@@ -40681,6 +40741,25 @@ var NativeSessionService = class {
|
|
|
40681
40741
|
}
|
|
40682
40742
|
return snapshot.history;
|
|
40683
40743
|
};
|
|
40744
|
+
readHistory = async (command, options, target, signal) => {
|
|
40745
|
+
if (options.agent.id !== "codex") {
|
|
40746
|
+
throw new AcpExecutionError(
|
|
40747
|
+
"Native history is unavailable for this Agent",
|
|
40748
|
+
{},
|
|
40749
|
+
"native_session_unsupported"
|
|
40750
|
+
);
|
|
40751
|
+
}
|
|
40752
|
+
const snapshot = await readCodexFullHistory(options.agent, target.cwd, target.info.sessionId, signal);
|
|
40753
|
+
const resolved = await this.#directories.identify(command.bindingId, snapshot.cwd, signal);
|
|
40754
|
+
if (snapshot.nativeSessionId !== target.info.sessionId || resolved.path !== target.cwd) {
|
|
40755
|
+
throw new AcpExecutionError(
|
|
40756
|
+
"Codex returned history for a different session or workspace.",
|
|
40757
|
+
{},
|
|
40758
|
+
"invalid_native_session_response"
|
|
40759
|
+
);
|
|
40760
|
+
}
|
|
40761
|
+
return snapshot.history;
|
|
40762
|
+
};
|
|
40684
40763
|
authorizeEntry = async (command, options, info) => {
|
|
40685
40764
|
try {
|
|
40686
40765
|
const primary = await this.#directories.identify(command.bindingId, info.cwd, options.signal);
|
|
@@ -41456,26 +41535,26 @@ var RelayConnectionLiveness = class {
|
|
|
41456
41535
|
};
|
|
41457
41536
|
|
|
41458
41537
|
// src/relay-connection/session-event-outbox.ts
|
|
41459
|
-
import {
|
|
41460
|
-
import {
|
|
41461
|
-
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
41538
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
41539
|
+
import { DatabaseSync } from "node:sqlite";
|
|
41462
41540
|
var DEFAULT_OUTBOX_LIMITS = {
|
|
41463
41541
|
criticalEventBytes: 136 * 1024 * 1024,
|
|
41464
41542
|
runtimeDeliveryBytes: 64 * 1024 * 1024,
|
|
41465
41543
|
runtimeDeliveryCount: 64,
|
|
41466
41544
|
standardEventBytes: 128 * 1024 * 1024
|
|
41467
41545
|
};
|
|
41546
|
+
var MAX_TERMINAL_RECEIPTS = 1024;
|
|
41468
41547
|
var SessionEventOutboxCapacityError = class extends Error {
|
|
41469
41548
|
code = "session_event_outbox_full";
|
|
41470
41549
|
constructor() {
|
|
41471
|
-
super("The
|
|
41550
|
+
super("The in-memory Session event outbox is full");
|
|
41472
41551
|
this.name = "SessionEventOutboxCapacityError";
|
|
41473
41552
|
}
|
|
41474
41553
|
};
|
|
41475
41554
|
var RuntimeDeliveryInboxCapacityError = class extends Error {
|
|
41476
41555
|
code = "runtime_delivery_inbox_full";
|
|
41477
41556
|
constructor() {
|
|
41478
|
-
super("The
|
|
41557
|
+
super("The in-memory Runtime delivery inbox is full");
|
|
41479
41558
|
this.name = "RuntimeDeliveryInboxCapacityError";
|
|
41480
41559
|
}
|
|
41481
41560
|
};
|
|
@@ -41520,11 +41599,10 @@ function rowString(row, field) {
|
|
|
41520
41599
|
var SessionEventOutbox = class {
|
|
41521
41600
|
#database;
|
|
41522
41601
|
#limits;
|
|
41523
|
-
constructor(
|
|
41602
|
+
constructor(limits = DEFAULT_OUTBOX_LIMITS) {
|
|
41524
41603
|
validateLimits(limits);
|
|
41525
41604
|
this.#limits = limits;
|
|
41526
|
-
|
|
41527
|
-
this.#database = new DatabaseSync3(path2);
|
|
41605
|
+
this.#database = new DatabaseSync(":memory:");
|
|
41528
41606
|
this.#database.exec(`
|
|
41529
41607
|
CREATE TABLE IF NOT EXISTS relay_session_event_outbox (
|
|
41530
41608
|
ordinal INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -41552,7 +41630,7 @@ var SessionEventOutbox = class {
|
|
|
41552
41630
|
CREATE TABLE IF NOT EXISTS relay_turn_receipts (
|
|
41553
41631
|
command_id TEXT PRIMARY KEY,
|
|
41554
41632
|
session_id TEXT NOT NULL,
|
|
41555
|
-
|
|
41633
|
+
command_hash TEXT NOT NULL,
|
|
41556
41634
|
attempt_id TEXT NOT NULL,
|
|
41557
41635
|
state TEXT NOT NULL CHECK (
|
|
41558
41636
|
state IN ('dispatching', 'running', 'succeeded', 'failed', 'cancelled')
|
|
@@ -41583,19 +41661,20 @@ var SessionEventOutbox = class {
|
|
|
41583
41661
|
`);
|
|
41584
41662
|
}
|
|
41585
41663
|
claimExecution = (commandId, sessionId, commandJson) => {
|
|
41664
|
+
const commandHash = createHash4("sha256").update(commandJson).digest("hex");
|
|
41586
41665
|
this.#database.exec("BEGIN IMMEDIATE");
|
|
41587
41666
|
try {
|
|
41588
41667
|
const existing = this.#database.prepare(
|
|
41589
|
-
`SELECT session_id,
|
|
41668
|
+
`SELECT session_id, command_hash, attempt_id, state
|
|
41590
41669
|
FROM relay_turn_receipts WHERE command_id = ?`
|
|
41591
41670
|
).get(commandId);
|
|
41592
41671
|
if (typeof existing === "object" && existing !== null) {
|
|
41593
41672
|
const storedSessionId = Reflect.get(existing, "session_id");
|
|
41594
|
-
const
|
|
41673
|
+
const storedCommandHash = Reflect.get(existing, "command_hash");
|
|
41595
41674
|
const attemptId2 = Reflect.get(existing, "attempt_id");
|
|
41596
41675
|
const state = Reflect.get(existing, "state");
|
|
41597
|
-
if (storedSessionId !== sessionId ||
|
|
41598
|
-
throw new Error("The daemon command identity conflicts with its
|
|
41676
|
+
if (storedSessionId !== sessionId || storedCommandHash !== commandHash || typeof attemptId2 !== "string" || !isDaemonExecutionState(state)) {
|
|
41677
|
+
throw new Error("The daemon command identity conflicts with its in-memory receipt");
|
|
41599
41678
|
}
|
|
41600
41679
|
this.#database.exec("COMMIT");
|
|
41601
41680
|
return { attemptId: attemptId2, commandId, kind: "duplicate", state };
|
|
@@ -41603,9 +41682,9 @@ var SessionEventOutbox = class {
|
|
|
41603
41682
|
const attemptId = crypto.randomUUID();
|
|
41604
41683
|
this.#database.prepare(
|
|
41605
41684
|
`INSERT INTO relay_turn_receipts (
|
|
41606
|
-
command_id, session_id,
|
|
41685
|
+
command_id, session_id, command_hash, attempt_id, state
|
|
41607
41686
|
) VALUES (?, ?, ?, ?, 'dispatching')`
|
|
41608
|
-
).run(commandId, sessionId,
|
|
41687
|
+
).run(commandId, sessionId, commandHash, attemptId);
|
|
41609
41688
|
this.#database.exec("COMMIT");
|
|
41610
41689
|
return {
|
|
41611
41690
|
attemptId,
|
|
@@ -41632,11 +41711,21 @@ var SessionEventOutbox = class {
|
|
|
41632
41711
|
throw new Error("The daemon execution transition is invalid");
|
|
41633
41712
|
}
|
|
41634
41713
|
this.#database.prepare(`UPDATE relay_turn_receipts SET state = ? WHERE command_id = ?`).run(state, commandId);
|
|
41714
|
+
if (state === "succeeded" || state === "failed" || state === "cancelled") {
|
|
41715
|
+
this.#database.prepare(
|
|
41716
|
+
`DELETE FROM relay_turn_receipts
|
|
41717
|
+
WHERE state IN ('succeeded', 'failed', 'cancelled')
|
|
41718
|
+
AND rowid NOT IN (
|
|
41719
|
+
SELECT rowid FROM relay_turn_receipts
|
|
41720
|
+
WHERE state IN ('succeeded', 'failed', 'cancelled')
|
|
41721
|
+
ORDER BY rowid DESC LIMIT ?
|
|
41722
|
+
)`
|
|
41723
|
+
).run(MAX_TERMINAL_RECEIPTS);
|
|
41724
|
+
}
|
|
41635
41725
|
};
|
|
41636
41726
|
/**
|
|
41637
|
-
* The Attempt this Runtime
|
|
41638
|
-
*
|
|
41639
|
-
* the restart, so this is the only record of the Attempt identity the Relay is still waiting on.
|
|
41727
|
+
* The Attempt this live Runtime claimed for a command that has not reached a terminal state.
|
|
41728
|
+
* Receipts disappear when the daemon process exits.
|
|
41640
41729
|
*/
|
|
41641
41730
|
findUnsettledAttemptId = (commandId, sessionId) => {
|
|
41642
41731
|
const row = this.#database.prepare(`SELECT attempt_id, state FROM relay_turn_receipts WHERE command_id = ? AND session_id = ?`).get(commandId, sessionId);
|
|
@@ -41685,7 +41774,7 @@ var SessionEventOutbox = class {
|
|
|
41685
41774
|
WHERE event_id = ? AND session_id = ?`
|
|
41686
41775
|
).run(rejection.eventId, rejection.sessionId);
|
|
41687
41776
|
if (deletion.changes !== 1) {
|
|
41688
|
-
throw new Error("The rejected session event could not be removed from the
|
|
41777
|
+
throw new Error("The rejected session event could not be removed from the in-memory outbox");
|
|
41689
41778
|
}
|
|
41690
41779
|
this.#decrementEventState(byteLength);
|
|
41691
41780
|
this.#database.exec("COMMIT");
|
|
@@ -41704,7 +41793,7 @@ var SessionEventOutbox = class {
|
|
|
41704
41793
|
enqueueCritical = (sessionId, payload, attemptId = "") => this.#enqueueBounded(sessionId, payload, attemptId, this.#limits.criticalEventBytes);
|
|
41705
41794
|
/**
|
|
41706
41795
|
* Bytes still available to standard Session events. The daemon uses this to shed
|
|
41707
|
-
* superseded streaming events instead of filling the
|
|
41796
|
+
* superseded streaming events instead of filling the in-memory outbox, so a long Turn
|
|
41708
41797
|
* behind a slow Relay cannot make the next enqueue throw.
|
|
41709
41798
|
*/
|
|
41710
41799
|
standardCapacityRemaining = () => {
|
|
@@ -41729,7 +41818,7 @@ var SessionEventOutbox = class {
|
|
|
41729
41818
|
const payload = rowString(existing, "payload_json");
|
|
41730
41819
|
const state = runtimeDeliveryState(existing);
|
|
41731
41820
|
if (sessionId !== delivery.sessionId || payload !== delivery.payload) {
|
|
41732
|
-
throw new Error("The Runtime delivery identity conflicts with its
|
|
41821
|
+
throw new Error("The Runtime delivery identity conflicts with its in-memory receipt");
|
|
41733
41822
|
}
|
|
41734
41823
|
this.#database.exec("COMMIT");
|
|
41735
41824
|
return new StoredRuntimeDelivery(delivery.deliveryId, sessionId, payload, state, true);
|
|
@@ -41897,7 +41986,7 @@ var SessionEventOutbox = class {
|
|
|
41897
41986
|
WHERE event_id = ? AND session_id = ?`
|
|
41898
41987
|
).run(eventId, sessionId);
|
|
41899
41988
|
if (deletion.changes !== 1) {
|
|
41900
|
-
throw new Error("The acknowledged session event could not be removed from the
|
|
41989
|
+
throw new Error("The acknowledged session event could not be removed from the in-memory outbox");
|
|
41901
41990
|
}
|
|
41902
41991
|
this.#decrementEventState(byteLength);
|
|
41903
41992
|
this.#database.exec("COMMIT");
|
|
@@ -42379,7 +42468,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
42379
42468
|
};
|
|
42380
42469
|
/**
|
|
42381
42470
|
* Enqueue a standard event, shedding it instead of ending the daemon when the
|
|
42382
|
-
*
|
|
42471
|
+
* in-memory outbox is full.
|
|
42383
42472
|
*
|
|
42384
42473
|
* A capacity error used to escape the coalescing timer that publishes activities,
|
|
42385
42474
|
* so the process exited and every restart died on the same retained backlog. A full
|
|
@@ -42422,7 +42511,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
42422
42511
|
return;
|
|
42423
42512
|
}
|
|
42424
42513
|
this.#shedEventKinds.add(kind);
|
|
42425
|
-
console.warn(`Mobius daemon is dropping
|
|
42514
|
+
console.warn(`Mobius daemon is dropping queued "${kind}" events because the Session event outbox is full`);
|
|
42426
42515
|
};
|
|
42427
42516
|
acknowledge = (acknowledgement) => {
|
|
42428
42517
|
if (!this.#outbox.acknowledge(acknowledgement)) {
|
|
@@ -42936,7 +43025,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
|
|
|
42936
43025
|
unsupportedModelIds: modelEffort.unsupportedModelIds,
|
|
42937
43026
|
valuesByModel: {}
|
|
42938
43027
|
};
|
|
42939
|
-
return
|
|
43028
|
+
return createHash5("sha256").update(
|
|
42940
43029
|
JSON.stringify({
|
|
42941
43030
|
adapterVersion: agent.kind === "acp-adapter-process" ? agent.adapterVersion : agent.agentVersion,
|
|
42942
43031
|
agentId: agent.id,
|
|
@@ -43931,7 +44020,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
43931
44020
|
if (connectionController.signal.aborted) {
|
|
43932
44021
|
return;
|
|
43933
44022
|
}
|
|
43934
|
-
console.error("Mobius daemon could not process a
|
|
44023
|
+
console.error("Mobius daemon could not process a in-memory Runtime delivery", error62);
|
|
43935
44024
|
failAndClose(
|
|
43936
44025
|
new Error("Runtime delivery processing failed", { cause: error62 }),
|
|
43937
44026
|
4008,
|
|
@@ -44734,8 +44823,8 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44734
44823
|
publishCatalog: async (installationSignal) => await publishAgentCatalog(config2, installationSignal),
|
|
44735
44824
|
stateDirectory
|
|
44736
44825
|
});
|
|
44737
|
-
const sessionStore = new
|
|
44738
|
-
const outbox = new SessionEventOutbox(
|
|
44826
|
+
const sessionStore = new MemoryAcpSessionStore();
|
|
44827
|
+
const outbox = new SessionEventOutbox();
|
|
44739
44828
|
const publisher = new DaemonSessionEventPublisher(outbox, timer);
|
|
44740
44829
|
const activeTurns = /* @__PURE__ */ new Map();
|
|
44741
44830
|
const activeAttemptIds = /* @__PURE__ */ new Map();
|
|
@@ -44747,9 +44836,14 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44747
44836
|
}
|
|
44748
44837
|
publisher.recordAttempt(sessionId, event, attemptId);
|
|
44749
44838
|
};
|
|
44750
|
-
const sessions = new AcpSessionManager(
|
|
44751
|
-
|
|
44752
|
-
|
|
44839
|
+
const sessions = new AcpSessionManager(
|
|
44840
|
+
new DaemonAcpObserver(recordSessionEvent),
|
|
44841
|
+
sessionStore,
|
|
44842
|
+
{
|
|
44843
|
+
read: async (options2, nativeSessionId) => options2.agent.id === "codex" ? (await readCodexFullHistory(options2.agent, options2.cwd, nativeSessionId, options2.signal)).history : null
|
|
44844
|
+
},
|
|
44845
|
+
"native"
|
|
44846
|
+
);
|
|
44753
44847
|
const directories = new WorkspaceDirectoryService(config2.bindingId, config2.defaultWorkspace);
|
|
44754
44848
|
const installationObserver = new DaemonInstallationObserver();
|
|
44755
44849
|
const diagnostics = new RelayConnectionDiagnostics(
|
|
@@ -44885,13 +44979,9 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44885
44979
|
await sessions.close();
|
|
44886
44980
|
} finally {
|
|
44887
44981
|
try {
|
|
44888
|
-
|
|
44982
|
+
publisher.close();
|
|
44889
44983
|
} finally {
|
|
44890
|
-
|
|
44891
|
-
publisher.close();
|
|
44892
|
-
} finally {
|
|
44893
|
-
outbox.close();
|
|
44894
|
-
}
|
|
44984
|
+
outbox.close();
|
|
44895
44985
|
}
|
|
44896
44986
|
}
|
|
44897
44987
|
}
|
|
@@ -44902,7 +44992,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44902
44992
|
|
|
44903
44993
|
// src/runtime.ts
|
|
44904
44994
|
import { mkdir as mkdir6, realpath as realpath10, stat as stat9 } from "node:fs/promises";
|
|
44905
|
-
import {
|
|
44995
|
+
import { resolve as resolve7 } from "node:path";
|
|
44906
44996
|
var IDENTIFIER_PATTERN7 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
44907
44997
|
var RUNTIME_CREDENTIAL_PATTERN2 = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
44908
44998
|
var MobiusRuntimeConfigurationError = class extends Error {
|
|
@@ -44959,7 +45049,6 @@ function loadMobiusRuntimeConnection(environment = process.env) {
|
|
|
44959
45049
|
throw new MobiusRuntimeConfigurationError("MOBIUS_CHANNEL_ID is invalid");
|
|
44960
45050
|
}
|
|
44961
45051
|
return Object.freeze({
|
|
44962
|
-
auditDatabasePath: environment["MOBIUS_AUDIT_DATABASE"]?.trim() || join18(readStateDirectory(environment), "audit", `${channelId}.sqlite`),
|
|
44963
45052
|
channelId,
|
|
44964
45053
|
defaultWorkspace: loadDefaultWorkspace(environment),
|
|
44965
45054
|
relayUrl: requiredEnvironmentValue(environment, "MOBIUS_RELAY_URL"),
|
|
@@ -44988,8 +45077,6 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
|
|
|
44988
45077
|
const localContext = new DaemonLocalContext(readStateDirectory(environment), environment);
|
|
44989
45078
|
const relayUrl = relayUrlFromConnection(connection);
|
|
44990
45079
|
const defaultWorkspace = await resolveWorkspace(connection.defaultWorkspace);
|
|
44991
|
-
const auditDatabasePath = resolve7(connection.auditDatabasePath);
|
|
44992
|
-
await mkdir6(dirname8(auditDatabasePath), { recursive: true, mode: 448 });
|
|
44993
45080
|
const inventory = await discoverLocalAgentInventory({
|
|
44994
45081
|
defaultWorkspace,
|
|
44995
45082
|
environment: localContext.environment,
|
|
@@ -45001,7 +45088,6 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
|
|
|
45001
45088
|
return new MobiusRuntimeEngine(
|
|
45002
45089
|
createDaemonConfig(
|
|
45003
45090
|
{
|
|
45004
|
-
auditDatabasePath,
|
|
45005
45091
|
channelId: connection.channelId,
|
|
45006
45092
|
defaultWorkspace,
|
|
45007
45093
|
relayUrl
|
|
@@ -45027,7 +45113,7 @@ var MobiusRuntimeEngine = class {
|
|
|
45027
45113
|
}
|
|
45028
45114
|
signal.throwIfAborted();
|
|
45029
45115
|
this.#state = new RunningMobiusRuntimeState();
|
|
45030
|
-
const audit = new AuditStore(
|
|
45116
|
+
const audit = new AuditStore();
|
|
45031
45117
|
try {
|
|
45032
45118
|
await runDaemon(this.#config, audit, signal, void 0, {
|
|
45033
45119
|
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus },
|