@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/index.js
CHANGED
|
@@ -21065,17 +21065,6 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
|
21065
21065
|
action: external_exports.enum(["import", "fork"]),
|
|
21066
21066
|
entryId: identifierStringSchema,
|
|
21067
21067
|
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
21068
|
}).readonly()
|
|
21080
21069
|
]);
|
|
21081
21070
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
@@ -21091,17 +21080,6 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
|
21091
21080
|
action: external_exports.enum(["import", "fork"]),
|
|
21092
21081
|
entryId: identifierStringSchema,
|
|
21093
21082
|
targetSessionId: identifierStringSchema
|
|
21094
|
-
}).readonly(),
|
|
21095
|
-
external_exports.object({
|
|
21096
|
-
...identity,
|
|
21097
|
-
action: external_exports.literal("fork-recorded"),
|
|
21098
|
-
targetSessionId: identifierStringSchema,
|
|
21099
|
-
throughCommandId: identifierStringSchema
|
|
21100
|
-
}).readonly(),
|
|
21101
|
-
external_exports.object({
|
|
21102
|
-
...identity,
|
|
21103
|
-
action: external_exports.literal("delete"),
|
|
21104
|
-
entryId: identifierStringSchema
|
|
21105
21083
|
}).readonly()
|
|
21106
21084
|
]);
|
|
21107
21085
|
var nativeSessionEntrySchema = external_exports.object({
|
|
@@ -21146,16 +21124,10 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
21146
21124
|
}).readonly(),
|
|
21147
21125
|
external_exports.object({
|
|
21148
21126
|
...resultEnvelope,
|
|
21149
|
-
action: external_exports.enum(["import", "fork"
|
|
21127
|
+
action: external_exports.enum(["import", "fork"]),
|
|
21150
21128
|
targetSessionId: identifierStringSchema,
|
|
21151
21129
|
ready: sessionReadyEventSchema,
|
|
21152
21130
|
title: external_exports.string().max(500)
|
|
21153
|
-
}).readonly(),
|
|
21154
|
-
external_exports.object({
|
|
21155
|
-
...resultEnvelope,
|
|
21156
|
-
action: external_exports.literal("delete"),
|
|
21157
|
-
entryId: identifierStringSchema,
|
|
21158
|
-
deletedSessionIds: external_exports.array(identifierStringSchema).max(500).readonly()
|
|
21159
21131
|
}).readonly()
|
|
21160
21132
|
]);
|
|
21161
21133
|
var nativeSessionCancelSchema = external_exports.object({ ...envelope, kind: external_exports.literal(NATIVE_SESSION_CANCEL_KIND) }).readonly();
|
|
@@ -30090,6 +30062,10 @@ var acpSessionStoreMigrations = [
|
|
|
30090
30062
|
{
|
|
30091
30063
|
"name": "0003_silky_ravenous.sql",
|
|
30092
30064
|
"sql": "DROP TABLE `session_event_v2`;"
|
|
30065
|
+
},
|
|
30066
|
+
{
|
|
30067
|
+
"name": "0004_special_mathemanic.sql",
|
|
30068
|
+
"sql": "DROP TABLE `deleted_acp_session`;--> statement-breakpoint\nALTER TABLE `acp_session` DROP COLUMN `last_terminal_command_id`;"
|
|
30093
30069
|
}
|
|
30094
30070
|
];
|
|
30095
30071
|
|
|
@@ -30100,33 +30076,25 @@ var acpSession = sqliteTable("acp_session", {
|
|
|
30100
30076
|
nativeSessionId: text("native_session_id").notNull(),
|
|
30101
30077
|
cwd: text("cwd").notNull(),
|
|
30102
30078
|
additionalDirectories: text("additional_directories").notNull(),
|
|
30103
|
-
lastTerminalCommandId: text("last_terminal_command_id"),
|
|
30104
30079
|
prompted: integer2("prompted", { mode: "boolean" }).notNull(),
|
|
30105
30080
|
title: text("title").notNull(),
|
|
30106
30081
|
updatedAt: text("updated_at").notNull()
|
|
30107
30082
|
});
|
|
30108
30083
|
|
|
30109
|
-
// src/schema/acp-session-store/deleted-acp-session.ts
|
|
30110
|
-
var deletedAcpSession = sqliteTable("deleted_acp_session", {
|
|
30111
|
-
sessionId: text("session_id").primaryKey()
|
|
30112
|
-
});
|
|
30113
|
-
|
|
30114
30084
|
// src/acp/session-store.ts
|
|
30115
30085
|
var AcpStoredSession = class {
|
|
30116
30086
|
additionalDirectories;
|
|
30117
30087
|
agentId;
|
|
30118
30088
|
cwd;
|
|
30119
|
-
lastTerminalCommandId;
|
|
30120
30089
|
nativeSessionId;
|
|
30121
30090
|
prompted;
|
|
30122
30091
|
sessionId;
|
|
30123
30092
|
title;
|
|
30124
30093
|
updatedAt;
|
|
30125
|
-
constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString()
|
|
30094
|
+
constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
30126
30095
|
this.additionalDirectories = [...additionalDirectories];
|
|
30127
30096
|
this.agentId = agentId;
|
|
30128
30097
|
this.cwd = cwd;
|
|
30129
|
-
this.lastTerminalCommandId = lastTerminalCommandId;
|
|
30130
30098
|
this.nativeSessionId = nativeSessionId;
|
|
30131
30099
|
this.prompted = prompted;
|
|
30132
30100
|
this.sessionId = sessionId;
|
|
@@ -30147,32 +30115,16 @@ var FoundAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
|
30147
30115
|
this.session = session;
|
|
30148
30116
|
}
|
|
30149
30117
|
};
|
|
30150
|
-
var DeletedAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
30151
|
-
found = false;
|
|
30152
|
-
};
|
|
30153
30118
|
var MemoryAcpSessionStore = class {
|
|
30154
30119
|
#sessions = /* @__PURE__ */ new Map();
|
|
30155
|
-
#deleted = /* @__PURE__ */ new Set();
|
|
30156
30120
|
close = () => {
|
|
30157
30121
|
this.#sessions.clear();
|
|
30158
|
-
this.#deleted.clear();
|
|
30159
30122
|
};
|
|
30160
30123
|
findNative = (agentId, nativeSessionId) => [...this.#sessions.values()].filter(
|
|
30161
30124
|
(session) => session.agentId === agentId && session.nativeSessionId === nativeSessionId
|
|
30162
30125
|
);
|
|
30163
30126
|
list = () => [...this.#sessions.values()].toSorted((left, right) => right.updatedAt.localeCompare(left.updatedAt));
|
|
30164
|
-
markDeleted = (agentId, nativeSessionId) => {
|
|
30165
|
-
const ids = this.findNative(agentId, nativeSessionId).map((session) => session.sessionId);
|
|
30166
|
-
for (const id of ids) {
|
|
30167
|
-
this.#sessions.delete(id);
|
|
30168
|
-
this.#deleted.add(id);
|
|
30169
|
-
}
|
|
30170
|
-
return ids;
|
|
30171
|
-
};
|
|
30172
30127
|
read = (sessionId) => {
|
|
30173
|
-
if (this.#deleted.has(sessionId)) {
|
|
30174
|
-
return new DeletedAcpStoredSession();
|
|
30175
|
-
}
|
|
30176
30128
|
const session = this.#sessions.get(sessionId);
|
|
30177
30129
|
return session === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(session);
|
|
30178
30130
|
};
|
|
@@ -30187,14 +30139,12 @@ var storedSessionRowSchema = external_exports.object({
|
|
|
30187
30139
|
additionalDirectories: external_exports.string(),
|
|
30188
30140
|
agentId: external_exports.string(),
|
|
30189
30141
|
cwd: external_exports.string(),
|
|
30190
|
-
lastTerminalCommandId: external_exports.string().nullable(),
|
|
30191
30142
|
nativeSessionId: external_exports.string(),
|
|
30192
30143
|
prompted: external_exports.boolean(),
|
|
30193
30144
|
sessionId: external_exports.string(),
|
|
30194
30145
|
title: external_exports.string(),
|
|
30195
30146
|
updatedAt: external_exports.string()
|
|
30196
30147
|
});
|
|
30197
|
-
var sessionIdRowSchema = external_exports.object({ sessionId: external_exports.string() });
|
|
30198
30148
|
function decodeStoredSession(value) {
|
|
30199
30149
|
const row = storedSessionRowSchema.parse(value);
|
|
30200
30150
|
const decodedAdditionalDirectories = JSON.parse(row.additionalDirectories);
|
|
@@ -30207,8 +30157,7 @@ function decodeStoredSession(value) {
|
|
|
30207
30157
|
additionalDirectories,
|
|
30208
30158
|
row.prompted,
|
|
30209
30159
|
row.title,
|
|
30210
|
-
row.updatedAt
|
|
30211
|
-
row.lastTerminalCommandId
|
|
30160
|
+
row.updatedAt
|
|
30212
30161
|
);
|
|
30213
30162
|
}
|
|
30214
30163
|
var SqliteAcpSessionStore = class {
|
|
@@ -30243,37 +30192,12 @@ var SqliteAcpSessionStore = class {
|
|
|
30243
30192
|
}
|
|
30244
30193
|
}
|
|
30245
30194
|
};
|
|
30246
|
-
#transaction = (operation) => {
|
|
30247
|
-
this.#sqliteDatabase.exec("BEGIN IMMEDIATE");
|
|
30248
|
-
try {
|
|
30249
|
-
operation();
|
|
30250
|
-
this.#sqliteDatabase.exec("COMMIT");
|
|
30251
|
-
} catch (error62) {
|
|
30252
|
-
this.#sqliteDatabase.exec("ROLLBACK");
|
|
30253
|
-
throw error62;
|
|
30254
|
-
}
|
|
30255
|
-
};
|
|
30256
30195
|
close = () => {
|
|
30257
30196
|
this.#sqliteDatabase.close();
|
|
30258
30197
|
};
|
|
30259
30198
|
findNative = (agentId, nativeSessionId) => this.#database.select().from(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).all().map(decodeStoredSession);
|
|
30260
30199
|
list = () => this.#database.select().from(acpSession).orderBy(desc(acpSession.updatedAt)).all().map(decodeStoredSession);
|
|
30261
|
-
markDeleted = (agentId, nativeSessionId) => {
|
|
30262
|
-
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);
|
|
30263
|
-
this.#transaction(() => {
|
|
30264
|
-
this.#database.delete(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).run();
|
|
30265
|
-
for (const id of ids) {
|
|
30266
|
-
this.#database.insert(deletedAcpSession).values({ sessionId: id }).onConflictDoNothing().run();
|
|
30267
|
-
}
|
|
30268
|
-
});
|
|
30269
|
-
return ids;
|
|
30270
|
-
};
|
|
30271
30200
|
read = (sessionId) => {
|
|
30272
|
-
const deleted = this.#database.select({ sessionId: deletedAcpSession.sessionId }).from(deletedAcpSession).where(eq(deletedAcpSession.sessionId, sessionId)).get();
|
|
30273
|
-
if (deleted !== void 0) {
|
|
30274
|
-
sessionIdRowSchema.parse(deleted);
|
|
30275
|
-
return new DeletedAcpStoredSession();
|
|
30276
|
-
}
|
|
30277
30201
|
const row = this.#database.select().from(acpSession).where(eq(acpSession.sessionId, sessionId)).get();
|
|
30278
30202
|
return row === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(decodeStoredSession(row));
|
|
30279
30203
|
};
|
|
@@ -30285,20 +30209,13 @@ var SqliteAcpSessionStore = class {
|
|
|
30285
30209
|
additionalDirectories: JSON.stringify(session.additionalDirectories),
|
|
30286
30210
|
agentId: session.agentId,
|
|
30287
30211
|
cwd: session.cwd,
|
|
30288
|
-
lastTerminalCommandId: session.lastTerminalCommandId,
|
|
30289
30212
|
nativeSessionId: session.nativeSessionId,
|
|
30290
30213
|
prompted: session.prompted,
|
|
30291
30214
|
sessionId: session.sessionId,
|
|
30292
30215
|
title: session.title,
|
|
30293
30216
|
updatedAt: session.updatedAt
|
|
30294
30217
|
};
|
|
30295
|
-
this.#
|
|
30296
|
-
this.#database.delete(deletedAcpSession).where(eq(deletedAcpSession.sessionId, session.sessionId)).run();
|
|
30297
|
-
this.#database.insert(acpSession).values(value).onConflictDoUpdate({
|
|
30298
|
-
target: acpSession.sessionId,
|
|
30299
|
-
set: value
|
|
30300
|
-
}).run();
|
|
30301
|
-
});
|
|
30218
|
+
this.#database.insert(acpSession).values(value).onConflictDoUpdate({ target: acpSession.sessionId, set: value }).run();
|
|
30302
30219
|
};
|
|
30303
30220
|
};
|
|
30304
30221
|
|
|
@@ -30339,7 +30256,6 @@ var AgentSession = class _AgentSession {
|
|
|
30339
30256
|
#commands = [];
|
|
30340
30257
|
#configRevision = 0;
|
|
30341
30258
|
#configOptions = [];
|
|
30342
|
-
#lastTerminalCommandId = null;
|
|
30343
30259
|
#nativeHistoryOwnership = { kind: "unbound" };
|
|
30344
30260
|
#prompted = false;
|
|
30345
30261
|
#nativePrompt = null;
|
|
@@ -30652,13 +30568,6 @@ var AgentSession = class _AgentSession {
|
|
|
30652
30568
|
this.#store.remove(this.#mobiusSessionId);
|
|
30653
30569
|
stored = this.#metrics.measureSync("session-state-read", () => this.#store.read(this.#mobiusSessionId));
|
|
30654
30570
|
}
|
|
30655
|
-
if (stored instanceof DeletedAcpStoredSession) {
|
|
30656
|
-
throw new AcpExecutionError(
|
|
30657
|
-
"The native Agent session was deleted. Start a new chat.",
|
|
30658
|
-
{},
|
|
30659
|
-
"native_session_deleted"
|
|
30660
|
-
);
|
|
30661
|
-
}
|
|
30662
30571
|
let lifecycleResponse;
|
|
30663
30572
|
if (origin?.kind === "fork") {
|
|
30664
30573
|
if (!this.#capabilities.unstableForkSession) {
|
|
@@ -30706,7 +30615,6 @@ var AgentSession = class _AgentSession {
|
|
|
30706
30615
|
} else if (stored instanceof FoundAcpStoredSession && stored.session.agentId === this.#agentId && stored.session.cwd === this.#cwd && arraysEqual(stored.session.additionalDirectories, this.#additionalDirectories)) {
|
|
30707
30616
|
this.selectNativeSession(stored.session.nativeSessionId);
|
|
30708
30617
|
this.#prompted = stored.session.prompted;
|
|
30709
|
-
this.#lastTerminalCommandId = stored.session.lastTerminalCommandId;
|
|
30710
30618
|
this.#sessionTitle = stored.session.title;
|
|
30711
30619
|
this.#restored = true;
|
|
30712
30620
|
if (this.#capabilities.resumeSession) {
|
|
@@ -30782,8 +30690,7 @@ var AgentSession = class _AgentSession {
|
|
|
30782
30690
|
this.#additionalDirectories,
|
|
30783
30691
|
this.#prompted,
|
|
30784
30692
|
this.#sessionTitle ?? "",
|
|
30785
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
30786
|
-
this.#lastTerminalCommandId
|
|
30693
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
30787
30694
|
)
|
|
30788
30695
|
);
|
|
30789
30696
|
};
|
|
@@ -30812,24 +30719,6 @@ var AgentSession = class _AgentSession {
|
|
|
30812
30719
|
}
|
|
30813
30720
|
return decoded.data;
|
|
30814
30721
|
};
|
|
30815
|
-
deleteNativeSession = async (nativeSessionId, signal) => {
|
|
30816
|
-
if (!this.#capabilities.deleteSession || !this.#capabilities.listSessions) {
|
|
30817
|
-
throw new AcpExecutionError(
|
|
30818
|
-
"This Agent does not support native session deletion",
|
|
30819
|
-
{},
|
|
30820
|
-
"native_session_unsupported"
|
|
30821
|
-
);
|
|
30822
|
-
}
|
|
30823
|
-
await this.race(
|
|
30824
|
-
this.#connection.connection.agent.request(
|
|
30825
|
-
methods3.agent.session.delete,
|
|
30826
|
-
{ sessionId: nativeSessionIdSchema.parse(nativeSessionId) },
|
|
30827
|
-
{ cancellationSignal: signal }
|
|
30828
|
-
),
|
|
30829
|
-
"ACP agent exited while deleting a session",
|
|
30830
|
-
signal
|
|
30831
|
-
);
|
|
30832
|
-
};
|
|
30833
30722
|
nativeSessionId = () => this.#updates.sessionId();
|
|
30834
30723
|
adoptNativeSessionId = (sessionId) => {
|
|
30835
30724
|
if (this.#prompted || this.#updates.sessionId() !== sessionId) {
|
|
@@ -30985,8 +30874,7 @@ var AgentSession = class _AgentSession {
|
|
|
30985
30874
|
this.#additionalDirectories,
|
|
30986
30875
|
true,
|
|
30987
30876
|
this.#sessionTitle,
|
|
30988
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
30989
|
-
this.#lastTerminalCommandId
|
|
30877
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
30990
30878
|
)
|
|
30991
30879
|
);
|
|
30992
30880
|
this.#prompted = true;
|
|
@@ -31055,7 +30943,6 @@ var AgentSession = class _AgentSession {
|
|
|
31055
30943
|
usage: result.usage ?? null
|
|
31056
30944
|
});
|
|
31057
30945
|
}
|
|
31058
|
-
this.#lastTerminalCommandId = options.commandId;
|
|
31059
30946
|
this.#store.write(
|
|
31060
30947
|
new AcpStoredSession(
|
|
31061
30948
|
this.#mobiusSessionId,
|
|
@@ -31065,8 +30952,7 @@ var AgentSession = class _AgentSession {
|
|
|
31065
30952
|
this.#additionalDirectories,
|
|
31066
30953
|
true,
|
|
31067
30954
|
this.#sessionTitle ?? "",
|
|
31068
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
31069
|
-
this.#lastTerminalCommandId
|
|
30955
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
31070
30956
|
)
|
|
31071
30957
|
);
|
|
31072
30958
|
if (lifecycleV2 !== void 0) {
|
|
@@ -31354,8 +31240,7 @@ var AgentSession = class _AgentSession {
|
|
|
31354
31240
|
this.#additionalDirectories,
|
|
31355
31241
|
this.#prompted,
|
|
31356
31242
|
this.#sessionTitle ?? "",
|
|
31357
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
31358
|
-
this.#lastTerminalCommandId
|
|
31243
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
31359
31244
|
)
|
|
31360
31245
|
);
|
|
31361
31246
|
}
|
|
@@ -32396,13 +32281,6 @@ var AgentRuntimeManager = class {
|
|
|
32396
32281
|
}
|
|
32397
32282
|
prepareSession = async (options, metrics = unmeasuredOperationMetrics) => this.#operations.run(options, async (options2) => {
|
|
32398
32283
|
const stored = metrics.measureSync("session-state-read", () => this.#store.read(options2.sessionId));
|
|
32399
|
-
if (stored instanceof DeletedAcpStoredSession) {
|
|
32400
|
-
throw new AcpExecutionError(
|
|
32401
|
-
"The native Agent session was deleted. Start a new chat.",
|
|
32402
|
-
{},
|
|
32403
|
-
"native_session_deleted"
|
|
32404
|
-
);
|
|
32405
|
-
}
|
|
32406
32284
|
if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
|
|
32407
32285
|
throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
|
|
32408
32286
|
}
|
|
@@ -32851,7 +32729,7 @@ var AgentRuntimeManager = class {
|
|
|
32851
32729
|
}
|
|
32852
32730
|
});
|
|
32853
32731
|
}
|
|
32854
|
-
if (this.#executionProcesses.get(options2.sessionId) !== void 0 || this.#executionProcesses.pending(options2.sessionId) !== void 0 || this.#store.read(options2.sessionId) instanceof FoundAcpStoredSession
|
|
32732
|
+
if (this.#executionProcesses.get(options2.sessionId) !== void 0 || this.#executionProcesses.pending(options2.sessionId) !== void 0 || this.#store.read(options2.sessionId) instanceof FoundAcpStoredSession) {
|
|
32855
32733
|
throw new AcpExecutionError(
|
|
32856
32734
|
"The destination conversation already exists",
|
|
32857
32735
|
{},
|
|
@@ -32897,40 +32775,6 @@ var AgentRuntimeManager = class {
|
|
|
32897
32775
|
}
|
|
32898
32776
|
});
|
|
32899
32777
|
});
|
|
32900
|
-
deleteNativeSession = async (options, nativeSessionId) => this.#operations.run(options, async (options2) => {
|
|
32901
|
-
return await this.#queryProcesses.use(options2, async (runtime) => {
|
|
32902
|
-
const key = `${options2.agent.id}:${nativeSessionId}`;
|
|
32903
|
-
const linked = this.#store.findNative(options2.agent.id, nativeSessionId);
|
|
32904
|
-
if (this.#nativeOperations.has(key) || linked.some(
|
|
32905
|
-
(entry) => this.#executions.command(entry.sessionId) !== void 0 || this.#executionProcesses.pending(entry.sessionId) !== void 0
|
|
32906
|
-
)) {
|
|
32907
|
-
throw new AcpExecutionError(
|
|
32908
|
-
"Wait for the native session's running operation to finish",
|
|
32909
|
-
{},
|
|
32910
|
-
"session_busy"
|
|
32911
|
-
);
|
|
32912
|
-
}
|
|
32913
|
-
this.#nativeOperations.add(key);
|
|
32914
|
-
try {
|
|
32915
|
-
for (const entry of linked) {
|
|
32916
|
-
const active = this.#executionProcesses.get(entry.sessionId);
|
|
32917
|
-
if (active !== void 0 && active !== runtime) {
|
|
32918
|
-
await this.#retireSessionProcess(entry.sessionId, active, async () => await active.close());
|
|
32919
|
-
}
|
|
32920
|
-
}
|
|
32921
|
-
options2.signal.throwIfAborted();
|
|
32922
|
-
await runtime.deleteNativeSession(nativeSessionId, options2.signal);
|
|
32923
|
-
const deleted = this.#store.markDeleted(options2.agent.id, nativeSessionId);
|
|
32924
|
-
if (runtime.nativeSessionId() === nativeSessionId) {
|
|
32925
|
-
await this.#queryProcesses.retire(options2.sessionId, runtime);
|
|
32926
|
-
}
|
|
32927
|
-
return deleted;
|
|
32928
|
-
} finally {
|
|
32929
|
-
this.#nativeOperations.delete(key);
|
|
32930
|
-
this.#processes.notifyChanged();
|
|
32931
|
-
}
|
|
32932
|
-
});
|
|
32933
|
-
});
|
|
32934
32778
|
};
|
|
32935
32779
|
|
|
32936
32780
|
// src/acp/run-prompt.ts
|
|
@@ -40399,7 +40243,6 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
|
|
|
40399
40243
|
|
|
40400
40244
|
// src/native-sessions/service.ts
|
|
40401
40245
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
40402
|
-
import { basename as basename5 } from "node:path";
|
|
40403
40246
|
var NativeSessionService = class {
|
|
40404
40247
|
#entries = /* @__PURE__ */ new Map();
|
|
40405
40248
|
#cursors = /* @__PURE__ */ new Map();
|
|
@@ -40443,64 +40286,6 @@ var NativeSessionService = class {
|
|
|
40443
40286
|
...await this.#activeTurn(command, options)
|
|
40444
40287
|
};
|
|
40445
40288
|
}
|
|
40446
|
-
if (command.action === "fork-recorded") {
|
|
40447
|
-
const source = this.#sessions.findSessions([command.sessionId])[0];
|
|
40448
|
-
if (source === void 0 || !source.prompted) {
|
|
40449
|
-
throw new AcpExecutionError(
|
|
40450
|
-
"The source conversation has no resumable native Agent session",
|
|
40451
|
-
{},
|
|
40452
|
-
"native_session_not_found"
|
|
40453
|
-
);
|
|
40454
|
-
}
|
|
40455
|
-
if (source.agentId !== command.agentId || source.cwd !== cwd || source.additionalDirectories.length !== additionalDirectories.length || source.additionalDirectories.some((path2, index) => path2 !== additionalDirectories[index])) {
|
|
40456
|
-
throw new AcpExecutionError(
|
|
40457
|
-
"The source conversation execution target does not match the fork request",
|
|
40458
|
-
{},
|
|
40459
|
-
"native_session_target_changed"
|
|
40460
|
-
);
|
|
40461
|
-
}
|
|
40462
|
-
if (source.lastTerminalCommandId !== command.throughCommandId) {
|
|
40463
|
-
throw new AcpExecutionError(
|
|
40464
|
-
"The selected Turn is no longer the source conversation head",
|
|
40465
|
-
{},
|
|
40466
|
-
"fork_point_stale"
|
|
40467
|
-
);
|
|
40468
|
-
}
|
|
40469
|
-
const opened2 = await this.#sessions.openNativeSession(
|
|
40470
|
-
{ ...options, sessionId: command.targetSessionId },
|
|
40471
|
-
{ kind: "fork", nativeSessionId: source.nativeSessionId }
|
|
40472
|
-
);
|
|
40473
|
-
signal.throwIfAborted();
|
|
40474
|
-
const directory = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
|
|
40475
|
-
const ready2 = {
|
|
40476
|
-
additionalDirectories: additionalDirectories.map((path2, index) => ({
|
|
40477
|
-
directoryId: command.additionalDirectoryIds[index] ?? command.directoryId,
|
|
40478
|
-
name: basename5(path2) || path2
|
|
40479
|
-
})),
|
|
40480
|
-
agentId: command.agentId,
|
|
40481
|
-
agentName: opened2.prepared.agentName,
|
|
40482
|
-
agentVersion: opened2.prepared.agentVersion,
|
|
40483
|
-
capabilities: opened2.prepared.capabilities,
|
|
40484
|
-
commands: opened2.prepared.commands,
|
|
40485
|
-
configOptions: opened2.prepared.configOptions,
|
|
40486
|
-
directoryId: command.directoryId,
|
|
40487
|
-
directoryLabel: directory.directoryLabel,
|
|
40488
|
-
kind: "session.ready",
|
|
40489
|
-
requestId: command.requestId,
|
|
40490
|
-
restored: true,
|
|
40491
|
-
sessionId: opened2.sessionId
|
|
40492
|
-
};
|
|
40493
|
-
this.record(command, "native_recorded_session_forked");
|
|
40494
|
-
return {
|
|
40495
|
-
action: "fork-recorded",
|
|
40496
|
-
kind: "native.session.result",
|
|
40497
|
-
ready: ready2,
|
|
40498
|
-
requestId: command.requestId,
|
|
40499
|
-
sessionId: command.sessionId,
|
|
40500
|
-
targetSessionId: command.targetSessionId,
|
|
40501
|
-
title: source.title || "Untitled session"
|
|
40502
|
-
};
|
|
40503
|
-
}
|
|
40504
40289
|
const prepared = await this.#sessions.prepareNativeSessionBrowser(options);
|
|
40505
40290
|
if (!prepared.capabilities.listSessions) {
|
|
40506
40291
|
throw new AcpExecutionError(
|
|
@@ -40635,25 +40420,6 @@ var NativeSessionService = class {
|
|
|
40635
40420
|
);
|
|
40636
40421
|
}
|
|
40637
40422
|
const target = await this.resolveTarget(command, options, selected);
|
|
40638
|
-
if (command.action === "delete") {
|
|
40639
|
-
if (!prepared.capabilities.deleteSession) {
|
|
40640
|
-
throw new AcpExecutionError(
|
|
40641
|
-
"This Agent does not support native session deletion",
|
|
40642
|
-
{},
|
|
40643
|
-
"native_session_unsupported"
|
|
40644
|
-
);
|
|
40645
|
-
}
|
|
40646
|
-
signal.throwIfAborted();
|
|
40647
|
-
this.record(command, "native_session_delete_authorized");
|
|
40648
|
-
const deletedSessionIds = await this.#sessions.deleteNativeSession(options, target.info.sessionId);
|
|
40649
|
-
this.record(command, "native_session_deleted");
|
|
40650
|
-
return {
|
|
40651
|
-
...envelope2,
|
|
40652
|
-
action: "delete",
|
|
40653
|
-
entryId: command.entryId,
|
|
40654
|
-
deletedSessionIds: deletedSessionIds.map(decodeIdentifier)
|
|
40655
|
-
};
|
|
40656
|
-
}
|
|
40657
40423
|
const action = command.action;
|
|
40658
40424
|
if (action === "import" && !prepared.capabilities.loadSession && !prepared.capabilities.resumeSession) {
|
|
40659
40425
|
throw new AcpExecutionError("This Agent cannot import native sessions", {}, "native_session_unsupported");
|
|
@@ -41663,7 +41429,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41663
41429
|
// src/artifacts/local-file-streamer.ts
|
|
41664
41430
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
41665
41431
|
import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
|
|
41666
|
-
import { basename as
|
|
41432
|
+
import { basename as basename5, isAbsolute as isAbsolute10, normalize as normalize4, resolve as resolve7 } from "node:path";
|
|
41667
41433
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
41668
41434
|
var CHUNK_BYTES = 192 * 1024;
|
|
41669
41435
|
function requestedPath(value) {
|
|
@@ -41715,7 +41481,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
41715
41481
|
kind: FILE_BEGIN_KIND,
|
|
41716
41482
|
mediaType: external?.mediaType ?? raster?.mimeType ?? "application/octet-stream",
|
|
41717
41483
|
modifiedAt: before.mtime.toISOString(),
|
|
41718
|
-
name: external?.name ?? (
|
|
41484
|
+
name: external?.name ?? (basename5(target) || "file"),
|
|
41719
41485
|
requestId: command.requestId,
|
|
41720
41486
|
sessionId: command.sessionId
|
|
41721
41487
|
});
|
|
@@ -41745,7 +41511,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
41745
41511
|
}
|
|
41746
41512
|
|
|
41747
41513
|
// src/authorization/resolve-session-directories.ts
|
|
41748
|
-
import { basename as
|
|
41514
|
+
import { basename as basename6 } from "node:path";
|
|
41749
41515
|
var ResolvedSessionDirectories = class {
|
|
41750
41516
|
additionalDirectories;
|
|
41751
41517
|
additionalDirectoryEntries;
|
|
@@ -41770,7 +41536,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
41770
41536
|
additionalDirectories.push(directory);
|
|
41771
41537
|
additionalDirectoryEntries.push({
|
|
41772
41538
|
directoryId: additionalDirectoryId,
|
|
41773
|
-
name:
|
|
41539
|
+
name: basename6(directory)
|
|
41774
41540
|
});
|
|
41775
41541
|
}
|
|
41776
41542
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
@@ -42549,7 +42315,7 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
42549
42315
|
// src/native-sessions/handle-native-requests.ts
|
|
42550
42316
|
import { WebSocket as WebSocket4 } from "undici";
|
|
42551
42317
|
function createNativeSessionRequestHandler(dependencies) {
|
|
42552
|
-
const { audit, diagnostics, nativeSessions,
|
|
42318
|
+
const { audit, diagnostics, nativeSessions, signal, socket, timer } = dependencies;
|
|
42553
42319
|
const pending = /* @__PURE__ */ new Map();
|
|
42554
42320
|
const cancel = (command) => {
|
|
42555
42321
|
const request = pending.get(command.requestId);
|
|
@@ -42601,17 +42367,6 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
42601
42367
|
}
|
|
42602
42368
|
operationSignal.throwIfAborted();
|
|
42603
42369
|
const result = await nativeSessions.execute(command, operationSignal);
|
|
42604
|
-
if (command.action === "fork-recorded" && result.action === "fork-recorded") {
|
|
42605
|
-
publisher.publishBatch(result.ready.sessionId, [
|
|
42606
|
-
result.ready,
|
|
42607
|
-
{
|
|
42608
|
-
kind: "session.forked",
|
|
42609
|
-
sessionId: result.ready.sessionId,
|
|
42610
|
-
sourceSessionId: command.sessionId,
|
|
42611
|
-
throughCommandId: command.throughCommandId
|
|
42612
|
-
}
|
|
42613
|
-
]);
|
|
42614
|
-
}
|
|
42615
42370
|
if (socket.readyState === WebSocket4.OPEN) {
|
|
42616
42371
|
send(socket, result);
|
|
42617
42372
|
}
|
|
@@ -42691,7 +42446,6 @@ function createDaemonCommandHandler({
|
|
|
42691
42446
|
audit,
|
|
42692
42447
|
diagnostics,
|
|
42693
42448
|
nativeSessions,
|
|
42694
|
-
publisher,
|
|
42695
42449
|
signal,
|
|
42696
42450
|
socket,
|
|
42697
42451
|
timer
|