@moxt-ai/mobius 0.0.174 → 0.0.175
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/agent-runtime-manager.d.ts +0 -1
- package/dist/acp/agent-runtime-manager.d.ts.map +1 -1
- package/dist/acp/agent-runtime-manager.js +2 -37
- package/dist/acp/agent-runtime-manager.js.map +1 -1
- package/dist/acp/agent-session.d.ts +0 -1
- package/dist/acp/agent-session.d.ts.map +1 -1
- package/dist/acp/agent-session.js +5 -17
- package/dist/acp/agent-session.js.map +1 -1
- package/dist/acp/session-store.d.ts +1 -8
- package/dist/acp/session-store.d.ts.map +1 -1
- package/dist/acp/session-store.js +8 -73
- package/dist/acp/session-store.js.map +1 -1
- package/dist/cli.js +19 -265
- package/dist/cli.js.map +4 -4
- package/dist/daemon-command-handler.d.ts.map +1 -1
- package/dist/daemon-command-handler.js +0 -1
- package/dist/daemon-command-handler.js.map +1 -1
- package/dist/daemon-turn-registry.d.ts +13 -13
- package/dist/generated/acp-session-store-migrations.d.ts +3 -0
- package/dist/generated/acp-session-store-migrations.d.ts.map +1 -1
- package/dist/generated/acp-session-store-migrations.js +5 -1
- package/dist/generated/acp-session-store-migrations.js.map +1 -1
- package/dist/index.js +18 -264
- package/dist/index.js.map +4 -4
- package/dist/native-sessions/handle-native-requests.d.ts +0 -2
- package/dist/native-sessions/handle-native-requests.d.ts.map +1 -1
- package/dist/native-sessions/handle-native-requests.js +1 -12
- package/dist/native-sessions/handle-native-requests.js.map +1 -1
- package/dist/native-sessions/service.d.ts.map +1 -1
- package/dist/native-sessions/service.js +0 -62
- package/dist/native-sessions/service.js.map +1 -1
- package/dist/runtime.js +20 -266
- package/dist/runtime.js.map +4 -4
- package/dist/schema/acp-session-store/acp-session.d.ts +0 -16
- package/dist/schema/acp-session-store/acp-session.d.ts.map +1 -1
- package/dist/schema/acp-session-store/acp-session.js +0 -1
- package/dist/schema/acp-session-store/acp-session.js.map +1 -1
- package/dist/schema/acp-session-store/index.d.ts +0 -1
- package/dist/schema/acp-session-store/index.d.ts.map +1 -1
- package/dist/schema/acp-session-store/index.js +0 -1
- package/dist/schema/acp-session-store/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/schema/acp-session-store/deleted-acp-session.d.ts +0 -24
- package/dist/schema/acp-session-store/deleted-acp-session.d.ts.map +0 -1
- package/dist/schema/acp-session-store/deleted-acp-session.js +0 -5
- package/dist/schema/acp-session-store/deleted-acp-session.js.map +0 -1
package/dist/runtime.js
CHANGED
|
@@ -21039,17 +21039,6 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
|
21039
21039
|
action: external_exports.enum(["import", "fork"]),
|
|
21040
21040
|
entryId: identifierStringSchema,
|
|
21041
21041
|
targetSessionId: identifierStringSchema
|
|
21042
|
-
}).readonly(),
|
|
21043
|
-
external_exports.object({
|
|
21044
|
-
...identity,
|
|
21045
|
-
action: external_exports.literal("fork-recorded"),
|
|
21046
|
-
targetSessionId: identifierStringSchema,
|
|
21047
|
-
throughCommandId: identifierStringSchema
|
|
21048
|
-
}).readonly(),
|
|
21049
|
-
external_exports.object({
|
|
21050
|
-
...identity,
|
|
21051
|
-
action: external_exports.literal("delete"),
|
|
21052
|
-
entryId: identifierStringSchema
|
|
21053
21042
|
}).readonly()
|
|
21054
21043
|
]);
|
|
21055
21044
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
@@ -21065,17 +21054,6 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
|
21065
21054
|
action: external_exports.enum(["import", "fork"]),
|
|
21066
21055
|
entryId: identifierStringSchema,
|
|
21067
21056
|
targetSessionId: identifierStringSchema
|
|
21068
|
-
}).readonly(),
|
|
21069
|
-
external_exports.object({
|
|
21070
|
-
...identity,
|
|
21071
|
-
action: external_exports.literal("fork-recorded"),
|
|
21072
|
-
targetSessionId: identifierStringSchema,
|
|
21073
|
-
throughCommandId: identifierStringSchema
|
|
21074
|
-
}).readonly(),
|
|
21075
|
-
external_exports.object({
|
|
21076
|
-
...identity,
|
|
21077
|
-
action: external_exports.literal("delete"),
|
|
21078
|
-
entryId: identifierStringSchema
|
|
21079
21057
|
}).readonly()
|
|
21080
21058
|
]);
|
|
21081
21059
|
var nativeSessionEntrySchema = external_exports.object({
|
|
@@ -21120,16 +21098,10 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
21120
21098
|
}).readonly(),
|
|
21121
21099
|
external_exports.object({
|
|
21122
21100
|
...resultEnvelope,
|
|
21123
|
-
action: external_exports.enum(["import", "fork"
|
|
21101
|
+
action: external_exports.enum(["import", "fork"]),
|
|
21124
21102
|
targetSessionId: identifierStringSchema,
|
|
21125
21103
|
ready: sessionReadyEventSchema,
|
|
21126
21104
|
title: external_exports.string().max(500)
|
|
21127
|
-
}).readonly(),
|
|
21128
|
-
external_exports.object({
|
|
21129
|
-
...resultEnvelope,
|
|
21130
|
-
action: external_exports.literal("delete"),
|
|
21131
|
-
entryId: identifierStringSchema,
|
|
21132
|
-
deletedSessionIds: external_exports.array(identifierStringSchema).max(500).readonly()
|
|
21133
21105
|
}).readonly()
|
|
21134
21106
|
]);
|
|
21135
21107
|
var nativeSessionCancelSchema = external_exports.object({ ...envelope, kind: external_exports.literal(NATIVE_SESSION_CANCEL_KIND) }).readonly();
|
|
@@ -34294,6 +34266,10 @@ var acpSessionStoreMigrations = [
|
|
|
34294
34266
|
{
|
|
34295
34267
|
"name": "0003_silky_ravenous.sql",
|
|
34296
34268
|
"sql": "DROP TABLE `session_event_v2`;"
|
|
34269
|
+
},
|
|
34270
|
+
{
|
|
34271
|
+
"name": "0004_special_mathemanic.sql",
|
|
34272
|
+
"sql": "DROP TABLE `deleted_acp_session`;--> statement-breakpoint\nALTER TABLE `acp_session` DROP COLUMN `last_terminal_command_id`;"
|
|
34297
34273
|
}
|
|
34298
34274
|
];
|
|
34299
34275
|
|
|
@@ -34304,33 +34280,25 @@ var acpSession = sqliteTable("acp_session", {
|
|
|
34304
34280
|
nativeSessionId: text("native_session_id").notNull(),
|
|
34305
34281
|
cwd: text("cwd").notNull(),
|
|
34306
34282
|
additionalDirectories: text("additional_directories").notNull(),
|
|
34307
|
-
lastTerminalCommandId: text("last_terminal_command_id"),
|
|
34308
34283
|
prompted: integer2("prompted", { mode: "boolean" }).notNull(),
|
|
34309
34284
|
title: text("title").notNull(),
|
|
34310
34285
|
updatedAt: text("updated_at").notNull()
|
|
34311
34286
|
});
|
|
34312
34287
|
|
|
34313
|
-
// src/schema/acp-session-store/deleted-acp-session.ts
|
|
34314
|
-
var deletedAcpSession = sqliteTable("deleted_acp_session", {
|
|
34315
|
-
sessionId: text("session_id").primaryKey()
|
|
34316
|
-
});
|
|
34317
|
-
|
|
34318
34288
|
// src/acp/session-store.ts
|
|
34319
34289
|
var AcpStoredSession = class {
|
|
34320
34290
|
additionalDirectories;
|
|
34321
34291
|
agentId;
|
|
34322
34292
|
cwd;
|
|
34323
|
-
lastTerminalCommandId;
|
|
34324
34293
|
nativeSessionId;
|
|
34325
34294
|
prompted;
|
|
34326
34295
|
sessionId;
|
|
34327
34296
|
title;
|
|
34328
34297
|
updatedAt;
|
|
34329
|
-
constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString()
|
|
34298
|
+
constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
34330
34299
|
this.additionalDirectories = [...additionalDirectories];
|
|
34331
34300
|
this.agentId = agentId;
|
|
34332
34301
|
this.cwd = cwd;
|
|
34333
|
-
this.lastTerminalCommandId = lastTerminalCommandId;
|
|
34334
34302
|
this.nativeSessionId = nativeSessionId;
|
|
34335
34303
|
this.prompted = prompted;
|
|
34336
34304
|
this.sessionId = sessionId;
|
|
@@ -34351,32 +34319,16 @@ var FoundAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
|
34351
34319
|
this.session = session;
|
|
34352
34320
|
}
|
|
34353
34321
|
};
|
|
34354
|
-
var DeletedAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
34355
|
-
found = false;
|
|
34356
|
-
};
|
|
34357
34322
|
var MemoryAcpSessionStore = class {
|
|
34358
34323
|
#sessions = /* @__PURE__ */ new Map();
|
|
34359
|
-
#deleted = /* @__PURE__ */ new Set();
|
|
34360
34324
|
close = () => {
|
|
34361
34325
|
this.#sessions.clear();
|
|
34362
|
-
this.#deleted.clear();
|
|
34363
34326
|
};
|
|
34364
34327
|
findNative = (agentId, nativeSessionId) => [...this.#sessions.values()].filter(
|
|
34365
34328
|
(session) => session.agentId === agentId && session.nativeSessionId === nativeSessionId
|
|
34366
34329
|
);
|
|
34367
34330
|
list = () => [...this.#sessions.values()].toSorted((left, right) => right.updatedAt.localeCompare(left.updatedAt));
|
|
34368
|
-
markDeleted = (agentId, nativeSessionId) => {
|
|
34369
|
-
const ids = this.findNative(agentId, nativeSessionId).map((session) => session.sessionId);
|
|
34370
|
-
for (const id of ids) {
|
|
34371
|
-
this.#sessions.delete(id);
|
|
34372
|
-
this.#deleted.add(id);
|
|
34373
|
-
}
|
|
34374
|
-
return ids;
|
|
34375
|
-
};
|
|
34376
34331
|
read = (sessionId) => {
|
|
34377
|
-
if (this.#deleted.has(sessionId)) {
|
|
34378
|
-
return new DeletedAcpStoredSession();
|
|
34379
|
-
}
|
|
34380
34332
|
const session = this.#sessions.get(sessionId);
|
|
34381
34333
|
return session === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(session);
|
|
34382
34334
|
};
|
|
@@ -34391,14 +34343,12 @@ var storedSessionRowSchema = external_exports.object({
|
|
|
34391
34343
|
additionalDirectories: external_exports.string(),
|
|
34392
34344
|
agentId: external_exports.string(),
|
|
34393
34345
|
cwd: external_exports.string(),
|
|
34394
|
-
lastTerminalCommandId: external_exports.string().nullable(),
|
|
34395
34346
|
nativeSessionId: external_exports.string(),
|
|
34396
34347
|
prompted: external_exports.boolean(),
|
|
34397
34348
|
sessionId: external_exports.string(),
|
|
34398
34349
|
title: external_exports.string(),
|
|
34399
34350
|
updatedAt: external_exports.string()
|
|
34400
34351
|
});
|
|
34401
|
-
var sessionIdRowSchema = external_exports.object({ sessionId: external_exports.string() });
|
|
34402
34352
|
function decodeStoredSession(value) {
|
|
34403
34353
|
const row = storedSessionRowSchema.parse(value);
|
|
34404
34354
|
const decodedAdditionalDirectories = JSON.parse(row.additionalDirectories);
|
|
@@ -34411,8 +34361,7 @@ function decodeStoredSession(value) {
|
|
|
34411
34361
|
additionalDirectories,
|
|
34412
34362
|
row.prompted,
|
|
34413
34363
|
row.title,
|
|
34414
|
-
row.updatedAt
|
|
34415
|
-
row.lastTerminalCommandId
|
|
34364
|
+
row.updatedAt
|
|
34416
34365
|
);
|
|
34417
34366
|
}
|
|
34418
34367
|
var SqliteAcpSessionStore = class {
|
|
@@ -34447,37 +34396,12 @@ var SqliteAcpSessionStore = class {
|
|
|
34447
34396
|
}
|
|
34448
34397
|
}
|
|
34449
34398
|
};
|
|
34450
|
-
#transaction = (operation) => {
|
|
34451
|
-
this.#sqliteDatabase.exec("BEGIN IMMEDIATE");
|
|
34452
|
-
try {
|
|
34453
|
-
operation();
|
|
34454
|
-
this.#sqliteDatabase.exec("COMMIT");
|
|
34455
|
-
} catch (error62) {
|
|
34456
|
-
this.#sqliteDatabase.exec("ROLLBACK");
|
|
34457
|
-
throw error62;
|
|
34458
|
-
}
|
|
34459
|
-
};
|
|
34460
34399
|
close = () => {
|
|
34461
34400
|
this.#sqliteDatabase.close();
|
|
34462
34401
|
};
|
|
34463
34402
|
findNative = (agentId, nativeSessionId) => this.#database.select().from(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).all().map(decodeStoredSession);
|
|
34464
34403
|
list = () => this.#database.select().from(acpSession).orderBy(desc(acpSession.updatedAt)).all().map(decodeStoredSession);
|
|
34465
|
-
markDeleted = (agentId, nativeSessionId) => {
|
|
34466
|
-
const ids = this.#database.select({ sessionId: acpSession.sessionId }).from(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).all().map((row) => sessionIdRowSchema.parse(row).sessionId);
|
|
34467
|
-
this.#transaction(() => {
|
|
34468
|
-
this.#database.delete(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).run();
|
|
34469
|
-
for (const id of ids) {
|
|
34470
|
-
this.#database.insert(deletedAcpSession).values({ sessionId: id }).onConflictDoNothing().run();
|
|
34471
|
-
}
|
|
34472
|
-
});
|
|
34473
|
-
return ids;
|
|
34474
|
-
};
|
|
34475
34404
|
read = (sessionId) => {
|
|
34476
|
-
const deleted = this.#database.select({ sessionId: deletedAcpSession.sessionId }).from(deletedAcpSession).where(eq(deletedAcpSession.sessionId, sessionId)).get();
|
|
34477
|
-
if (deleted !== void 0) {
|
|
34478
|
-
sessionIdRowSchema.parse(deleted);
|
|
34479
|
-
return new DeletedAcpStoredSession();
|
|
34480
|
-
}
|
|
34481
34405
|
const row = this.#database.select().from(acpSession).where(eq(acpSession.sessionId, sessionId)).get();
|
|
34482
34406
|
return row === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(decodeStoredSession(row));
|
|
34483
34407
|
};
|
|
@@ -34489,20 +34413,13 @@ var SqliteAcpSessionStore = class {
|
|
|
34489
34413
|
additionalDirectories: JSON.stringify(session.additionalDirectories),
|
|
34490
34414
|
agentId: session.agentId,
|
|
34491
34415
|
cwd: session.cwd,
|
|
34492
|
-
lastTerminalCommandId: session.lastTerminalCommandId,
|
|
34493
34416
|
nativeSessionId: session.nativeSessionId,
|
|
34494
34417
|
prompted: session.prompted,
|
|
34495
34418
|
sessionId: session.sessionId,
|
|
34496
34419
|
title: session.title,
|
|
34497
34420
|
updatedAt: session.updatedAt
|
|
34498
34421
|
};
|
|
34499
|
-
this.#
|
|
34500
|
-
this.#database.delete(deletedAcpSession).where(eq(deletedAcpSession.sessionId, session.sessionId)).run();
|
|
34501
|
-
this.#database.insert(acpSession).values(value).onConflictDoUpdate({
|
|
34502
|
-
target: acpSession.sessionId,
|
|
34503
|
-
set: value
|
|
34504
|
-
}).run();
|
|
34505
|
-
});
|
|
34422
|
+
this.#database.insert(acpSession).values(value).onConflictDoUpdate({ target: acpSession.sessionId, set: value }).run();
|
|
34506
34423
|
};
|
|
34507
34424
|
};
|
|
34508
34425
|
|
|
@@ -34543,7 +34460,6 @@ var AgentSession = class _AgentSession {
|
|
|
34543
34460
|
#commands = [];
|
|
34544
34461
|
#configRevision = 0;
|
|
34545
34462
|
#configOptions = [];
|
|
34546
|
-
#lastTerminalCommandId = null;
|
|
34547
34463
|
#nativeHistoryOwnership = { kind: "unbound" };
|
|
34548
34464
|
#prompted = false;
|
|
34549
34465
|
#nativePrompt = null;
|
|
@@ -34856,13 +34772,6 @@ var AgentSession = class _AgentSession {
|
|
|
34856
34772
|
this.#store.remove(this.#mobiusSessionId);
|
|
34857
34773
|
stored = this.#metrics.measureSync("session-state-read", () => this.#store.read(this.#mobiusSessionId));
|
|
34858
34774
|
}
|
|
34859
|
-
if (stored instanceof DeletedAcpStoredSession) {
|
|
34860
|
-
throw new AcpExecutionError(
|
|
34861
|
-
"The native Agent session was deleted. Start a new chat.",
|
|
34862
|
-
{},
|
|
34863
|
-
"native_session_deleted"
|
|
34864
|
-
);
|
|
34865
|
-
}
|
|
34866
34775
|
let lifecycleResponse;
|
|
34867
34776
|
if (origin?.kind === "fork") {
|
|
34868
34777
|
if (!this.#capabilities.unstableForkSession) {
|
|
@@ -34910,7 +34819,6 @@ var AgentSession = class _AgentSession {
|
|
|
34910
34819
|
} else if (stored instanceof FoundAcpStoredSession && stored.session.agentId === this.#agentId && stored.session.cwd === this.#cwd && arraysEqual(stored.session.additionalDirectories, this.#additionalDirectories)) {
|
|
34911
34820
|
this.selectNativeSession(stored.session.nativeSessionId);
|
|
34912
34821
|
this.#prompted = stored.session.prompted;
|
|
34913
|
-
this.#lastTerminalCommandId = stored.session.lastTerminalCommandId;
|
|
34914
34822
|
this.#sessionTitle = stored.session.title;
|
|
34915
34823
|
this.#restored = true;
|
|
34916
34824
|
if (this.#capabilities.resumeSession) {
|
|
@@ -34986,8 +34894,7 @@ var AgentSession = class _AgentSession {
|
|
|
34986
34894
|
this.#additionalDirectories,
|
|
34987
34895
|
this.#prompted,
|
|
34988
34896
|
this.#sessionTitle ?? "",
|
|
34989
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
34990
|
-
this.#lastTerminalCommandId
|
|
34897
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
34991
34898
|
)
|
|
34992
34899
|
);
|
|
34993
34900
|
};
|
|
@@ -35016,24 +34923,6 @@ var AgentSession = class _AgentSession {
|
|
|
35016
34923
|
}
|
|
35017
34924
|
return decoded.data;
|
|
35018
34925
|
};
|
|
35019
|
-
deleteNativeSession = async (nativeSessionId, signal) => {
|
|
35020
|
-
if (!this.#capabilities.deleteSession || !this.#capabilities.listSessions) {
|
|
35021
|
-
throw new AcpExecutionError(
|
|
35022
|
-
"This Agent does not support native session deletion",
|
|
35023
|
-
{},
|
|
35024
|
-
"native_session_unsupported"
|
|
35025
|
-
);
|
|
35026
|
-
}
|
|
35027
|
-
await this.race(
|
|
35028
|
-
this.#connection.connection.agent.request(
|
|
35029
|
-
methods8.agent.session.delete,
|
|
35030
|
-
{ sessionId: nativeSessionIdSchema.parse(nativeSessionId) },
|
|
35031
|
-
{ cancellationSignal: signal }
|
|
35032
|
-
),
|
|
35033
|
-
"ACP agent exited while deleting a session",
|
|
35034
|
-
signal
|
|
35035
|
-
);
|
|
35036
|
-
};
|
|
35037
34926
|
nativeSessionId = () => this.#updates.sessionId();
|
|
35038
34927
|
adoptNativeSessionId = (sessionId) => {
|
|
35039
34928
|
if (this.#prompted || this.#updates.sessionId() !== sessionId) {
|
|
@@ -35189,8 +35078,7 @@ var AgentSession = class _AgentSession {
|
|
|
35189
35078
|
this.#additionalDirectories,
|
|
35190
35079
|
true,
|
|
35191
35080
|
this.#sessionTitle,
|
|
35192
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
35193
|
-
this.#lastTerminalCommandId
|
|
35081
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
35194
35082
|
)
|
|
35195
35083
|
);
|
|
35196
35084
|
this.#prompted = true;
|
|
@@ -35259,7 +35147,6 @@ var AgentSession = class _AgentSession {
|
|
|
35259
35147
|
usage: result.usage ?? null
|
|
35260
35148
|
});
|
|
35261
35149
|
}
|
|
35262
|
-
this.#lastTerminalCommandId = options.commandId;
|
|
35263
35150
|
this.#store.write(
|
|
35264
35151
|
new AcpStoredSession(
|
|
35265
35152
|
this.#mobiusSessionId,
|
|
@@ -35269,8 +35156,7 @@ var AgentSession = class _AgentSession {
|
|
|
35269
35156
|
this.#additionalDirectories,
|
|
35270
35157
|
true,
|
|
35271
35158
|
this.#sessionTitle ?? "",
|
|
35272
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
35273
|
-
this.#lastTerminalCommandId
|
|
35159
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
35274
35160
|
)
|
|
35275
35161
|
);
|
|
35276
35162
|
if (lifecycleV2 !== void 0) {
|
|
@@ -35558,8 +35444,7 @@ var AgentSession = class _AgentSession {
|
|
|
35558
35444
|
this.#additionalDirectories,
|
|
35559
35445
|
this.#prompted,
|
|
35560
35446
|
this.#sessionTitle ?? "",
|
|
35561
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
35562
|
-
this.#lastTerminalCommandId
|
|
35447
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
35563
35448
|
)
|
|
35564
35449
|
);
|
|
35565
35450
|
}
|
|
@@ -36600,13 +36485,6 @@ var AgentRuntimeManager = class {
|
|
|
36600
36485
|
}
|
|
36601
36486
|
prepareSession = async (options, metrics = unmeasuredOperationMetrics) => this.#operations.run(options, async (options2) => {
|
|
36602
36487
|
const stored = metrics.measureSync("session-state-read", () => this.#store.read(options2.sessionId));
|
|
36603
|
-
if (stored instanceof DeletedAcpStoredSession) {
|
|
36604
|
-
throw new AcpExecutionError(
|
|
36605
|
-
"The native Agent session was deleted. Start a new chat.",
|
|
36606
|
-
{},
|
|
36607
|
-
"native_session_deleted"
|
|
36608
|
-
);
|
|
36609
|
-
}
|
|
36610
36488
|
if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
|
|
36611
36489
|
throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
|
|
36612
36490
|
}
|
|
@@ -37055,7 +36933,7 @@ var AgentRuntimeManager = class {
|
|
|
37055
36933
|
}
|
|
37056
36934
|
});
|
|
37057
36935
|
}
|
|
37058
|
-
if (this.#executionProcesses.get(options2.sessionId) !== void 0 || this.#executionProcesses.pending(options2.sessionId) !== void 0 || this.#store.read(options2.sessionId) instanceof FoundAcpStoredSession
|
|
36936
|
+
if (this.#executionProcesses.get(options2.sessionId) !== void 0 || this.#executionProcesses.pending(options2.sessionId) !== void 0 || this.#store.read(options2.sessionId) instanceof FoundAcpStoredSession) {
|
|
37059
36937
|
throw new AcpExecutionError(
|
|
37060
36938
|
"The destination conversation already exists",
|
|
37061
36939
|
{},
|
|
@@ -37101,40 +36979,6 @@ var AgentRuntimeManager = class {
|
|
|
37101
36979
|
}
|
|
37102
36980
|
});
|
|
37103
36981
|
});
|
|
37104
|
-
deleteNativeSession = async (options, nativeSessionId) => this.#operations.run(options, async (options2) => {
|
|
37105
|
-
return await this.#queryProcesses.use(options2, async (runtime) => {
|
|
37106
|
-
const key = `${options2.agent.id}:${nativeSessionId}`;
|
|
37107
|
-
const linked = this.#store.findNative(options2.agent.id, nativeSessionId);
|
|
37108
|
-
if (this.#nativeOperations.has(key) || linked.some(
|
|
37109
|
-
(entry) => this.#executions.command(entry.sessionId) !== void 0 || this.#executionProcesses.pending(entry.sessionId) !== void 0
|
|
37110
|
-
)) {
|
|
37111
|
-
throw new AcpExecutionError(
|
|
37112
|
-
"Wait for the native session's running operation to finish",
|
|
37113
|
-
{},
|
|
37114
|
-
"session_busy"
|
|
37115
|
-
);
|
|
37116
|
-
}
|
|
37117
|
-
this.#nativeOperations.add(key);
|
|
37118
|
-
try {
|
|
37119
|
-
for (const entry of linked) {
|
|
37120
|
-
const active = this.#executionProcesses.get(entry.sessionId);
|
|
37121
|
-
if (active !== void 0 && active !== runtime) {
|
|
37122
|
-
await this.#retireSessionProcess(entry.sessionId, active, async () => await active.close());
|
|
37123
|
-
}
|
|
37124
|
-
}
|
|
37125
|
-
options2.signal.throwIfAborted();
|
|
37126
|
-
await runtime.deleteNativeSession(nativeSessionId, options2.signal);
|
|
37127
|
-
const deleted = this.#store.markDeleted(options2.agent.id, nativeSessionId);
|
|
37128
|
-
if (runtime.nativeSessionId() === nativeSessionId) {
|
|
37129
|
-
await this.#queryProcesses.retire(options2.sessionId, runtime);
|
|
37130
|
-
}
|
|
37131
|
-
return deleted;
|
|
37132
|
-
} finally {
|
|
37133
|
-
this.#nativeOperations.delete(key);
|
|
37134
|
-
this.#processes.notifyChanged();
|
|
37135
|
-
}
|
|
37136
|
-
});
|
|
37137
|
-
});
|
|
37138
36982
|
};
|
|
37139
36983
|
|
|
37140
36984
|
// src/agent-catalog/publish-agent-catalog.ts
|
|
@@ -39515,7 +39359,6 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
|
|
|
39515
39359
|
|
|
39516
39360
|
// src/native-sessions/service.ts
|
|
39517
39361
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
39518
|
-
import { basename as basename4 } from "node:path";
|
|
39519
39362
|
var NativeSessionService = class {
|
|
39520
39363
|
#entries = /* @__PURE__ */ new Map();
|
|
39521
39364
|
#cursors = /* @__PURE__ */ new Map();
|
|
@@ -39559,64 +39402,6 @@ var NativeSessionService = class {
|
|
|
39559
39402
|
...await this.#activeTurn(command, options)
|
|
39560
39403
|
};
|
|
39561
39404
|
}
|
|
39562
|
-
if (command.action === "fork-recorded") {
|
|
39563
|
-
const source = this.#sessions.findSessions([command.sessionId])[0];
|
|
39564
|
-
if (source === void 0 || !source.prompted) {
|
|
39565
|
-
throw new AcpExecutionError(
|
|
39566
|
-
"The source conversation has no resumable native Agent session",
|
|
39567
|
-
{},
|
|
39568
|
-
"native_session_not_found"
|
|
39569
|
-
);
|
|
39570
|
-
}
|
|
39571
|
-
if (source.agentId !== command.agentId || source.cwd !== cwd || source.additionalDirectories.length !== additionalDirectories.length || source.additionalDirectories.some((path2, index) => path2 !== additionalDirectories[index])) {
|
|
39572
|
-
throw new AcpExecutionError(
|
|
39573
|
-
"The source conversation execution target does not match the fork request",
|
|
39574
|
-
{},
|
|
39575
|
-
"native_session_target_changed"
|
|
39576
|
-
);
|
|
39577
|
-
}
|
|
39578
|
-
if (source.lastTerminalCommandId !== command.throughCommandId) {
|
|
39579
|
-
throw new AcpExecutionError(
|
|
39580
|
-
"The selected Turn is no longer the source conversation head",
|
|
39581
|
-
{},
|
|
39582
|
-
"fork_point_stale"
|
|
39583
|
-
);
|
|
39584
|
-
}
|
|
39585
|
-
const opened2 = await this.#sessions.openNativeSession(
|
|
39586
|
-
{ ...options, sessionId: command.targetSessionId },
|
|
39587
|
-
{ kind: "fork", nativeSessionId: source.nativeSessionId }
|
|
39588
|
-
);
|
|
39589
|
-
signal.throwIfAborted();
|
|
39590
|
-
const directory = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
|
|
39591
|
-
const ready2 = {
|
|
39592
|
-
additionalDirectories: additionalDirectories.map((path2, index) => ({
|
|
39593
|
-
directoryId: command.additionalDirectoryIds[index] ?? command.directoryId,
|
|
39594
|
-
name: basename4(path2) || path2
|
|
39595
|
-
})),
|
|
39596
|
-
agentId: command.agentId,
|
|
39597
|
-
agentName: opened2.prepared.agentName,
|
|
39598
|
-
agentVersion: opened2.prepared.agentVersion,
|
|
39599
|
-
capabilities: opened2.prepared.capabilities,
|
|
39600
|
-
commands: opened2.prepared.commands,
|
|
39601
|
-
configOptions: opened2.prepared.configOptions,
|
|
39602
|
-
directoryId: command.directoryId,
|
|
39603
|
-
directoryLabel: directory.directoryLabel,
|
|
39604
|
-
kind: "session.ready",
|
|
39605
|
-
requestId: command.requestId,
|
|
39606
|
-
restored: true,
|
|
39607
|
-
sessionId: opened2.sessionId
|
|
39608
|
-
};
|
|
39609
|
-
this.record(command, "native_recorded_session_forked");
|
|
39610
|
-
return {
|
|
39611
|
-
action: "fork-recorded",
|
|
39612
|
-
kind: "native.session.result",
|
|
39613
|
-
ready: ready2,
|
|
39614
|
-
requestId: command.requestId,
|
|
39615
|
-
sessionId: command.sessionId,
|
|
39616
|
-
targetSessionId: command.targetSessionId,
|
|
39617
|
-
title: source.title || "Untitled session"
|
|
39618
|
-
};
|
|
39619
|
-
}
|
|
39620
39405
|
const prepared = await this.#sessions.prepareNativeSessionBrowser(options);
|
|
39621
39406
|
if (!prepared.capabilities.listSessions) {
|
|
39622
39407
|
throw new AcpExecutionError(
|
|
@@ -39751,25 +39536,6 @@ var NativeSessionService = class {
|
|
|
39751
39536
|
);
|
|
39752
39537
|
}
|
|
39753
39538
|
const target = await this.resolveTarget(command, options, selected);
|
|
39754
|
-
if (command.action === "delete") {
|
|
39755
|
-
if (!prepared.capabilities.deleteSession) {
|
|
39756
|
-
throw new AcpExecutionError(
|
|
39757
|
-
"This Agent does not support native session deletion",
|
|
39758
|
-
{},
|
|
39759
|
-
"native_session_unsupported"
|
|
39760
|
-
);
|
|
39761
|
-
}
|
|
39762
|
-
signal.throwIfAborted();
|
|
39763
|
-
this.record(command, "native_session_delete_authorized");
|
|
39764
|
-
const deletedSessionIds = await this.#sessions.deleteNativeSession(options, target.info.sessionId);
|
|
39765
|
-
this.record(command, "native_session_deleted");
|
|
39766
|
-
return {
|
|
39767
|
-
...envelope2,
|
|
39768
|
-
action: "delete",
|
|
39769
|
-
entryId: command.entryId,
|
|
39770
|
-
deletedSessionIds: deletedSessionIds.map(decodeIdentifier)
|
|
39771
|
-
};
|
|
39772
|
-
}
|
|
39773
39539
|
const action = command.action;
|
|
39774
39540
|
if (action === "import" && !prepared.capabilities.loadSession && !prepared.capabilities.resumeSession) {
|
|
39775
39541
|
throw new AcpExecutionError("This Agent cannot import native sessions", {}, "native_session_unsupported");
|
|
@@ -40779,7 +40545,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
40779
40545
|
// src/artifacts/local-file-streamer.ts
|
|
40780
40546
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
40781
40547
|
import { realpath as realpath9, stat as stat8 } from "node:fs/promises";
|
|
40782
|
-
import { basename as
|
|
40548
|
+
import { basename as basename4, isAbsolute as isAbsolute10, normalize as normalize4, resolve as resolve5 } from "node:path";
|
|
40783
40549
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
40784
40550
|
var CHUNK_BYTES = 192 * 1024;
|
|
40785
40551
|
function requestedPath(value) {
|
|
@@ -40831,7 +40597,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
40831
40597
|
kind: FILE_BEGIN_KIND,
|
|
40832
40598
|
mediaType: external?.mediaType ?? raster?.mimeType ?? "application/octet-stream",
|
|
40833
40599
|
modifiedAt: before.mtime.toISOString(),
|
|
40834
|
-
name: external?.name ?? (
|
|
40600
|
+
name: external?.name ?? (basename4(target) || "file"),
|
|
40835
40601
|
requestId: command.requestId,
|
|
40836
40602
|
sessionId: command.sessionId
|
|
40837
40603
|
});
|
|
@@ -40861,7 +40627,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
40861
40627
|
}
|
|
40862
40628
|
|
|
40863
40629
|
// src/authorization/resolve-session-directories.ts
|
|
40864
|
-
import { basename as
|
|
40630
|
+
import { basename as basename5 } from "node:path";
|
|
40865
40631
|
var ResolvedSessionDirectories = class {
|
|
40866
40632
|
additionalDirectories;
|
|
40867
40633
|
additionalDirectoryEntries;
|
|
@@ -40886,7 +40652,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
40886
40652
|
additionalDirectories.push(directory);
|
|
40887
40653
|
additionalDirectoryEntries.push({
|
|
40888
40654
|
directoryId: additionalDirectoryId,
|
|
40889
|
-
name:
|
|
40655
|
+
name: basename5(directory)
|
|
40890
40656
|
});
|
|
40891
40657
|
}
|
|
40892
40658
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
@@ -41665,7 +41431,7 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
41665
41431
|
// src/native-sessions/handle-native-requests.ts
|
|
41666
41432
|
import { WebSocket as WebSocket4 } from "undici";
|
|
41667
41433
|
function createNativeSessionRequestHandler(dependencies) {
|
|
41668
|
-
const { audit, diagnostics, nativeSessions,
|
|
41434
|
+
const { audit, diagnostics, nativeSessions, signal, socket, timer } = dependencies;
|
|
41669
41435
|
const pending = /* @__PURE__ */ new Map();
|
|
41670
41436
|
const cancel = (command) => {
|
|
41671
41437
|
const request = pending.get(command.requestId);
|
|
@@ -41717,17 +41483,6 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
41717
41483
|
}
|
|
41718
41484
|
operationSignal.throwIfAborted();
|
|
41719
41485
|
const result = await nativeSessions.execute(command, operationSignal);
|
|
41720
|
-
if (command.action === "fork-recorded" && result.action === "fork-recorded") {
|
|
41721
|
-
publisher.publishBatch(result.ready.sessionId, [
|
|
41722
|
-
result.ready,
|
|
41723
|
-
{
|
|
41724
|
-
kind: "session.forked",
|
|
41725
|
-
sessionId: result.ready.sessionId,
|
|
41726
|
-
sourceSessionId: command.sessionId,
|
|
41727
|
-
throughCommandId: command.throughCommandId
|
|
41728
|
-
}
|
|
41729
|
-
]);
|
|
41730
|
-
}
|
|
41731
41486
|
if (socket.readyState === WebSocket4.OPEN) {
|
|
41732
41487
|
send(socket, result);
|
|
41733
41488
|
}
|
|
@@ -41807,7 +41562,6 @@ function createDaemonCommandHandler({
|
|
|
41807
41562
|
audit,
|
|
41808
41563
|
diagnostics,
|
|
41809
41564
|
nativeSessions,
|
|
41810
|
-
publisher,
|
|
41811
41565
|
signal,
|
|
41812
41566
|
socket,
|
|
41813
41567
|
timer
|
|
@@ -42906,7 +42660,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
42906
42660
|
// src/pairing/pair-local-machine.ts
|
|
42907
42661
|
import { mkdir as mkdir6, realpath as realpath10, stat as stat9 } from "node:fs/promises";
|
|
42908
42662
|
import { hostname as hostname3 } from "node:os";
|
|
42909
|
-
import { basename as
|
|
42663
|
+
import { basename as basename6, resolve as resolve7 } from "node:path";
|
|
42910
42664
|
import { fetch as fetch4 } from "undici";
|
|
42911
42665
|
|
|
42912
42666
|
// src/storage/runtime-installation-store.ts
|
|
@@ -43548,7 +43302,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
43548
43302
|
installableAgents,
|
|
43549
43303
|
machineName: hostname3(),
|
|
43550
43304
|
pairingCode: options.code,
|
|
43551
|
-
workspaceName:
|
|
43305
|
+
workspaceName: basename6(defaultWorkspace) || "Local workspace"
|
|
43552
43306
|
}),
|
|
43553
43307
|
dispatcher: environmentProxyDispatcher,
|
|
43554
43308
|
headers: { "content-type": "application/json" },
|