@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/cli.js
CHANGED
|
@@ -3381,7 +3381,7 @@ var program = new Command();
|
|
|
3381
3381
|
// package.json
|
|
3382
3382
|
var package_default = {
|
|
3383
3383
|
name: "@moxt-ai/mobius",
|
|
3384
|
-
version: "0.0.
|
|
3384
|
+
version: "0.0.175",
|
|
3385
3385
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
3386
3386
|
type: "module",
|
|
3387
3387
|
bin: {
|
|
@@ -29666,17 +29666,6 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
|
29666
29666
|
action: external_exports.enum(["import", "fork"]),
|
|
29667
29667
|
entryId: identifierStringSchema,
|
|
29668
29668
|
targetSessionId: identifierStringSchema
|
|
29669
|
-
}).readonly(),
|
|
29670
|
-
external_exports.object({
|
|
29671
|
-
...identity,
|
|
29672
|
-
action: external_exports.literal("fork-recorded"),
|
|
29673
|
-
targetSessionId: identifierStringSchema,
|
|
29674
|
-
throughCommandId: identifierStringSchema
|
|
29675
|
-
}).readonly(),
|
|
29676
|
-
external_exports.object({
|
|
29677
|
-
...identity,
|
|
29678
|
-
action: external_exports.literal("delete"),
|
|
29679
|
-
entryId: identifierStringSchema
|
|
29680
29669
|
}).readonly()
|
|
29681
29670
|
]);
|
|
29682
29671
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
@@ -29692,17 +29681,6 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
|
29692
29681
|
action: external_exports.enum(["import", "fork"]),
|
|
29693
29682
|
entryId: identifierStringSchema,
|
|
29694
29683
|
targetSessionId: identifierStringSchema
|
|
29695
|
-
}).readonly(),
|
|
29696
|
-
external_exports.object({
|
|
29697
|
-
...identity,
|
|
29698
|
-
action: external_exports.literal("fork-recorded"),
|
|
29699
|
-
targetSessionId: identifierStringSchema,
|
|
29700
|
-
throughCommandId: identifierStringSchema
|
|
29701
|
-
}).readonly(),
|
|
29702
|
-
external_exports.object({
|
|
29703
|
-
...identity,
|
|
29704
|
-
action: external_exports.literal("delete"),
|
|
29705
|
-
entryId: identifierStringSchema
|
|
29706
29684
|
}).readonly()
|
|
29707
29685
|
]);
|
|
29708
29686
|
var nativeSessionEntrySchema = external_exports.object({
|
|
@@ -29747,16 +29725,10 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
29747
29725
|
}).readonly(),
|
|
29748
29726
|
external_exports.object({
|
|
29749
29727
|
...resultEnvelope,
|
|
29750
|
-
action: external_exports.enum(["import", "fork"
|
|
29728
|
+
action: external_exports.enum(["import", "fork"]),
|
|
29751
29729
|
targetSessionId: identifierStringSchema,
|
|
29752
29730
|
ready: sessionReadyEventSchema,
|
|
29753
29731
|
title: external_exports.string().max(500)
|
|
29754
|
-
}).readonly(),
|
|
29755
|
-
external_exports.object({
|
|
29756
|
-
...resultEnvelope,
|
|
29757
|
-
action: external_exports.literal("delete"),
|
|
29758
|
-
entryId: identifierStringSchema,
|
|
29759
|
-
deletedSessionIds: external_exports.array(identifierStringSchema).max(500).readonly()
|
|
29760
29732
|
}).readonly()
|
|
29761
29733
|
]);
|
|
29762
29734
|
var nativeSessionCancelSchema = external_exports.object({ ...envelope, kind: external_exports.literal(NATIVE_SESSION_CANCEL_KIND) }).readonly();
|
|
@@ -38659,6 +38631,10 @@ var acpSessionStoreMigrations = [
|
|
|
38659
38631
|
{
|
|
38660
38632
|
"name": "0003_silky_ravenous.sql",
|
|
38661
38633
|
"sql": "DROP TABLE `session_event_v2`;"
|
|
38634
|
+
},
|
|
38635
|
+
{
|
|
38636
|
+
"name": "0004_special_mathemanic.sql",
|
|
38637
|
+
"sql": "DROP TABLE `deleted_acp_session`;--> statement-breakpoint\nALTER TABLE `acp_session` DROP COLUMN `last_terminal_command_id`;"
|
|
38662
38638
|
}
|
|
38663
38639
|
];
|
|
38664
38640
|
|
|
@@ -38669,33 +38645,25 @@ var acpSession = sqliteTable("acp_session", {
|
|
|
38669
38645
|
nativeSessionId: text("native_session_id").notNull(),
|
|
38670
38646
|
cwd: text("cwd").notNull(),
|
|
38671
38647
|
additionalDirectories: text("additional_directories").notNull(),
|
|
38672
|
-
lastTerminalCommandId: text("last_terminal_command_id"),
|
|
38673
38648
|
prompted: integer2("prompted", { mode: "boolean" }).notNull(),
|
|
38674
38649
|
title: text("title").notNull(),
|
|
38675
38650
|
updatedAt: text("updated_at").notNull()
|
|
38676
38651
|
});
|
|
38677
38652
|
|
|
38678
|
-
// src/schema/acp-session-store/deleted-acp-session.ts
|
|
38679
|
-
var deletedAcpSession = sqliteTable("deleted_acp_session", {
|
|
38680
|
-
sessionId: text("session_id").primaryKey()
|
|
38681
|
-
});
|
|
38682
|
-
|
|
38683
38653
|
// src/acp/session-store.ts
|
|
38684
38654
|
var AcpStoredSession = class {
|
|
38685
38655
|
additionalDirectories;
|
|
38686
38656
|
agentId;
|
|
38687
38657
|
cwd;
|
|
38688
|
-
lastTerminalCommandId;
|
|
38689
38658
|
nativeSessionId;
|
|
38690
38659
|
prompted;
|
|
38691
38660
|
sessionId;
|
|
38692
38661
|
title;
|
|
38693
38662
|
updatedAt;
|
|
38694
|
-
constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString()
|
|
38663
|
+
constructor(sessionId, agentId, nativeSessionId, cwd, additionalDirectories, prompted, title2, updatedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
38695
38664
|
this.additionalDirectories = [...additionalDirectories];
|
|
38696
38665
|
this.agentId = agentId;
|
|
38697
38666
|
this.cwd = cwd;
|
|
38698
|
-
this.lastTerminalCommandId = lastTerminalCommandId;
|
|
38699
38667
|
this.nativeSessionId = nativeSessionId;
|
|
38700
38668
|
this.prompted = prompted;
|
|
38701
38669
|
this.sessionId = sessionId;
|
|
@@ -38716,32 +38684,16 @@ var FoundAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
|
38716
38684
|
this.session = session;
|
|
38717
38685
|
}
|
|
38718
38686
|
};
|
|
38719
|
-
var DeletedAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
38720
|
-
found = false;
|
|
38721
|
-
};
|
|
38722
38687
|
var MemoryAcpSessionStore = class {
|
|
38723
38688
|
#sessions = /* @__PURE__ */ new Map();
|
|
38724
|
-
#deleted = /* @__PURE__ */ new Set();
|
|
38725
38689
|
close = () => {
|
|
38726
38690
|
this.#sessions.clear();
|
|
38727
|
-
this.#deleted.clear();
|
|
38728
38691
|
};
|
|
38729
38692
|
findNative = (agentId, nativeSessionId) => [...this.#sessions.values()].filter(
|
|
38730
38693
|
(session) => session.agentId === agentId && session.nativeSessionId === nativeSessionId
|
|
38731
38694
|
);
|
|
38732
38695
|
list = () => [...this.#sessions.values()].toSorted((left, right) => right.updatedAt.localeCompare(left.updatedAt));
|
|
38733
|
-
markDeleted = (agentId, nativeSessionId) => {
|
|
38734
|
-
const ids = this.findNative(agentId, nativeSessionId).map((session) => session.sessionId);
|
|
38735
|
-
for (const id of ids) {
|
|
38736
|
-
this.#sessions.delete(id);
|
|
38737
|
-
this.#deleted.add(id);
|
|
38738
|
-
}
|
|
38739
|
-
return ids;
|
|
38740
|
-
};
|
|
38741
38696
|
read = (sessionId) => {
|
|
38742
|
-
if (this.#deleted.has(sessionId)) {
|
|
38743
|
-
return new DeletedAcpStoredSession();
|
|
38744
|
-
}
|
|
38745
38697
|
const session = this.#sessions.get(sessionId);
|
|
38746
38698
|
return session === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(session);
|
|
38747
38699
|
};
|
|
@@ -38756,14 +38708,12 @@ var storedSessionRowSchema = external_exports.object({
|
|
|
38756
38708
|
additionalDirectories: external_exports.string(),
|
|
38757
38709
|
agentId: external_exports.string(),
|
|
38758
38710
|
cwd: external_exports.string(),
|
|
38759
|
-
lastTerminalCommandId: external_exports.string().nullable(),
|
|
38760
38711
|
nativeSessionId: external_exports.string(),
|
|
38761
38712
|
prompted: external_exports.boolean(),
|
|
38762
38713
|
sessionId: external_exports.string(),
|
|
38763
38714
|
title: external_exports.string(),
|
|
38764
38715
|
updatedAt: external_exports.string()
|
|
38765
38716
|
});
|
|
38766
|
-
var sessionIdRowSchema = external_exports.object({ sessionId: external_exports.string() });
|
|
38767
38717
|
function decodeStoredSession(value) {
|
|
38768
38718
|
const row = storedSessionRowSchema.parse(value);
|
|
38769
38719
|
const decodedAdditionalDirectories = JSON.parse(row.additionalDirectories);
|
|
@@ -38776,8 +38726,7 @@ function decodeStoredSession(value) {
|
|
|
38776
38726
|
additionalDirectories,
|
|
38777
38727
|
row.prompted,
|
|
38778
38728
|
row.title,
|
|
38779
|
-
row.updatedAt
|
|
38780
|
-
row.lastTerminalCommandId
|
|
38729
|
+
row.updatedAt
|
|
38781
38730
|
);
|
|
38782
38731
|
}
|
|
38783
38732
|
var SqliteAcpSessionStore = class {
|
|
@@ -38812,37 +38761,12 @@ var SqliteAcpSessionStore = class {
|
|
|
38812
38761
|
}
|
|
38813
38762
|
}
|
|
38814
38763
|
};
|
|
38815
|
-
#transaction = (operation) => {
|
|
38816
|
-
this.#sqliteDatabase.exec("BEGIN IMMEDIATE");
|
|
38817
|
-
try {
|
|
38818
|
-
operation();
|
|
38819
|
-
this.#sqliteDatabase.exec("COMMIT");
|
|
38820
|
-
} catch (error62) {
|
|
38821
|
-
this.#sqliteDatabase.exec("ROLLBACK");
|
|
38822
|
-
throw error62;
|
|
38823
|
-
}
|
|
38824
|
-
};
|
|
38825
38764
|
close = () => {
|
|
38826
38765
|
this.#sqliteDatabase.close();
|
|
38827
38766
|
};
|
|
38828
38767
|
findNative = (agentId, nativeSessionId) => this.#database.select().from(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).all().map(decodeStoredSession);
|
|
38829
38768
|
list = () => this.#database.select().from(acpSession).orderBy(desc(acpSession.updatedAt)).all().map(decodeStoredSession);
|
|
38830
|
-
markDeleted = (agentId, nativeSessionId) => {
|
|
38831
|
-
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);
|
|
38832
|
-
this.#transaction(() => {
|
|
38833
|
-
this.#database.delete(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).run();
|
|
38834
|
-
for (const id of ids) {
|
|
38835
|
-
this.#database.insert(deletedAcpSession).values({ sessionId: id }).onConflictDoNothing().run();
|
|
38836
|
-
}
|
|
38837
|
-
});
|
|
38838
|
-
return ids;
|
|
38839
|
-
};
|
|
38840
38769
|
read = (sessionId) => {
|
|
38841
|
-
const deleted = this.#database.select({ sessionId: deletedAcpSession.sessionId }).from(deletedAcpSession).where(eq(deletedAcpSession.sessionId, sessionId)).get();
|
|
38842
|
-
if (deleted !== void 0) {
|
|
38843
|
-
sessionIdRowSchema.parse(deleted);
|
|
38844
|
-
return new DeletedAcpStoredSession();
|
|
38845
|
-
}
|
|
38846
38770
|
const row = this.#database.select().from(acpSession).where(eq(acpSession.sessionId, sessionId)).get();
|
|
38847
38771
|
return row === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(decodeStoredSession(row));
|
|
38848
38772
|
};
|
|
@@ -38854,20 +38778,13 @@ var SqliteAcpSessionStore = class {
|
|
|
38854
38778
|
additionalDirectories: JSON.stringify(session.additionalDirectories),
|
|
38855
38779
|
agentId: session.agentId,
|
|
38856
38780
|
cwd: session.cwd,
|
|
38857
|
-
lastTerminalCommandId: session.lastTerminalCommandId,
|
|
38858
38781
|
nativeSessionId: session.nativeSessionId,
|
|
38859
38782
|
prompted: session.prompted,
|
|
38860
38783
|
sessionId: session.sessionId,
|
|
38861
38784
|
title: session.title,
|
|
38862
38785
|
updatedAt: session.updatedAt
|
|
38863
38786
|
};
|
|
38864
|
-
this.#
|
|
38865
|
-
this.#database.delete(deletedAcpSession).where(eq(deletedAcpSession.sessionId, session.sessionId)).run();
|
|
38866
|
-
this.#database.insert(acpSession).values(value).onConflictDoUpdate({
|
|
38867
|
-
target: acpSession.sessionId,
|
|
38868
|
-
set: value
|
|
38869
|
-
}).run();
|
|
38870
|
-
});
|
|
38787
|
+
this.#database.insert(acpSession).values(value).onConflictDoUpdate({ target: acpSession.sessionId, set: value }).run();
|
|
38871
38788
|
};
|
|
38872
38789
|
};
|
|
38873
38790
|
|
|
@@ -38908,7 +38825,6 @@ var AgentSession = class _AgentSession {
|
|
|
38908
38825
|
#commands = [];
|
|
38909
38826
|
#configRevision = 0;
|
|
38910
38827
|
#configOptions = [];
|
|
38911
|
-
#lastTerminalCommandId = null;
|
|
38912
38828
|
#nativeHistoryOwnership = { kind: "unbound" };
|
|
38913
38829
|
#prompted = false;
|
|
38914
38830
|
#nativePrompt = null;
|
|
@@ -39221,13 +39137,6 @@ var AgentSession = class _AgentSession {
|
|
|
39221
39137
|
this.#store.remove(this.#mobiusSessionId);
|
|
39222
39138
|
stored = this.#metrics.measureSync("session-state-read", () => this.#store.read(this.#mobiusSessionId));
|
|
39223
39139
|
}
|
|
39224
|
-
if (stored instanceof DeletedAcpStoredSession) {
|
|
39225
|
-
throw new AcpExecutionError(
|
|
39226
|
-
"The native Agent session was deleted. Start a new chat.",
|
|
39227
|
-
{},
|
|
39228
|
-
"native_session_deleted"
|
|
39229
|
-
);
|
|
39230
|
-
}
|
|
39231
39140
|
let lifecycleResponse;
|
|
39232
39141
|
if (origin?.kind === "fork") {
|
|
39233
39142
|
if (!this.#capabilities.unstableForkSession) {
|
|
@@ -39275,7 +39184,6 @@ var AgentSession = class _AgentSession {
|
|
|
39275
39184
|
} else if (stored instanceof FoundAcpStoredSession && stored.session.agentId === this.#agentId && stored.session.cwd === this.#cwd && arraysEqual(stored.session.additionalDirectories, this.#additionalDirectories)) {
|
|
39276
39185
|
this.selectNativeSession(stored.session.nativeSessionId);
|
|
39277
39186
|
this.#prompted = stored.session.prompted;
|
|
39278
|
-
this.#lastTerminalCommandId = stored.session.lastTerminalCommandId;
|
|
39279
39187
|
this.#sessionTitle = stored.session.title;
|
|
39280
39188
|
this.#restored = true;
|
|
39281
39189
|
if (this.#capabilities.resumeSession) {
|
|
@@ -39351,8 +39259,7 @@ var AgentSession = class _AgentSession {
|
|
|
39351
39259
|
this.#additionalDirectories,
|
|
39352
39260
|
this.#prompted,
|
|
39353
39261
|
this.#sessionTitle ?? "",
|
|
39354
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
39355
|
-
this.#lastTerminalCommandId
|
|
39262
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
39356
39263
|
)
|
|
39357
39264
|
);
|
|
39358
39265
|
};
|
|
@@ -39381,24 +39288,6 @@ var AgentSession = class _AgentSession {
|
|
|
39381
39288
|
}
|
|
39382
39289
|
return decoded.data;
|
|
39383
39290
|
};
|
|
39384
|
-
deleteNativeSession = async (nativeSessionId, signal) => {
|
|
39385
|
-
if (!this.#capabilities.deleteSession || !this.#capabilities.listSessions) {
|
|
39386
|
-
throw new AcpExecutionError(
|
|
39387
|
-
"This Agent does not support native session deletion",
|
|
39388
|
-
{},
|
|
39389
|
-
"native_session_unsupported"
|
|
39390
|
-
);
|
|
39391
|
-
}
|
|
39392
|
-
await this.race(
|
|
39393
|
-
this.#connection.connection.agent.request(
|
|
39394
|
-
methods8.agent.session.delete,
|
|
39395
|
-
{ sessionId: nativeSessionIdSchema.parse(nativeSessionId) },
|
|
39396
|
-
{ cancellationSignal: signal }
|
|
39397
|
-
),
|
|
39398
|
-
"ACP agent exited while deleting a session",
|
|
39399
|
-
signal
|
|
39400
|
-
);
|
|
39401
|
-
};
|
|
39402
39291
|
nativeSessionId = () => this.#updates.sessionId();
|
|
39403
39292
|
adoptNativeSessionId = (sessionId) => {
|
|
39404
39293
|
if (this.#prompted || this.#updates.sessionId() !== sessionId) {
|
|
@@ -39554,8 +39443,7 @@ var AgentSession = class _AgentSession {
|
|
|
39554
39443
|
this.#additionalDirectories,
|
|
39555
39444
|
true,
|
|
39556
39445
|
this.#sessionTitle,
|
|
39557
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
39558
|
-
this.#lastTerminalCommandId
|
|
39446
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
39559
39447
|
)
|
|
39560
39448
|
);
|
|
39561
39449
|
this.#prompted = true;
|
|
@@ -39624,7 +39512,6 @@ var AgentSession = class _AgentSession {
|
|
|
39624
39512
|
usage: result.usage ?? null
|
|
39625
39513
|
});
|
|
39626
39514
|
}
|
|
39627
|
-
this.#lastTerminalCommandId = options.commandId;
|
|
39628
39515
|
this.#store.write(
|
|
39629
39516
|
new AcpStoredSession(
|
|
39630
39517
|
this.#mobiusSessionId,
|
|
@@ -39634,8 +39521,7 @@ var AgentSession = class _AgentSession {
|
|
|
39634
39521
|
this.#additionalDirectories,
|
|
39635
39522
|
true,
|
|
39636
39523
|
this.#sessionTitle ?? "",
|
|
39637
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
39638
|
-
this.#lastTerminalCommandId
|
|
39524
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
39639
39525
|
)
|
|
39640
39526
|
);
|
|
39641
39527
|
if (lifecycleV2 !== void 0) {
|
|
@@ -39923,8 +39809,7 @@ var AgentSession = class _AgentSession {
|
|
|
39923
39809
|
this.#additionalDirectories,
|
|
39924
39810
|
this.#prompted,
|
|
39925
39811
|
this.#sessionTitle ?? "",
|
|
39926
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
39927
|
-
this.#lastTerminalCommandId
|
|
39812
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
39928
39813
|
)
|
|
39929
39814
|
);
|
|
39930
39815
|
}
|
|
@@ -40965,13 +40850,6 @@ var AgentRuntimeManager = class {
|
|
|
40965
40850
|
}
|
|
40966
40851
|
prepareSession = async (options, metrics = unmeasuredOperationMetrics) => this.#operations.run(options, async (options2) => {
|
|
40967
40852
|
const stored = metrics.measureSync("session-state-read", () => this.#store.read(options2.sessionId));
|
|
40968
|
-
if (stored instanceof DeletedAcpStoredSession) {
|
|
40969
|
-
throw new AcpExecutionError(
|
|
40970
|
-
"The native Agent session was deleted. Start a new chat.",
|
|
40971
|
-
{},
|
|
40972
|
-
"native_session_deleted"
|
|
40973
|
-
);
|
|
40974
|
-
}
|
|
40975
40853
|
if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
|
|
40976
40854
|
throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
|
|
40977
40855
|
}
|
|
@@ -41420,7 +41298,7 @@ var AgentRuntimeManager = class {
|
|
|
41420
41298
|
}
|
|
41421
41299
|
});
|
|
41422
41300
|
}
|
|
41423
|
-
if (this.#executionProcesses.get(options2.sessionId) !== void 0 || this.#executionProcesses.pending(options2.sessionId) !== void 0 || this.#store.read(options2.sessionId) instanceof FoundAcpStoredSession
|
|
41301
|
+
if (this.#executionProcesses.get(options2.sessionId) !== void 0 || this.#executionProcesses.pending(options2.sessionId) !== void 0 || this.#store.read(options2.sessionId) instanceof FoundAcpStoredSession) {
|
|
41424
41302
|
throw new AcpExecutionError(
|
|
41425
41303
|
"The destination conversation already exists",
|
|
41426
41304
|
{},
|
|
@@ -41466,40 +41344,6 @@ var AgentRuntimeManager = class {
|
|
|
41466
41344
|
}
|
|
41467
41345
|
});
|
|
41468
41346
|
});
|
|
41469
|
-
deleteNativeSession = async (options, nativeSessionId) => this.#operations.run(options, async (options2) => {
|
|
41470
|
-
return await this.#queryProcesses.use(options2, async (runtime) => {
|
|
41471
|
-
const key = `${options2.agent.id}:${nativeSessionId}`;
|
|
41472
|
-
const linked = this.#store.findNative(options2.agent.id, nativeSessionId);
|
|
41473
|
-
if (this.#nativeOperations.has(key) || linked.some(
|
|
41474
|
-
(entry) => this.#executions.command(entry.sessionId) !== void 0 || this.#executionProcesses.pending(entry.sessionId) !== void 0
|
|
41475
|
-
)) {
|
|
41476
|
-
throw new AcpExecutionError(
|
|
41477
|
-
"Wait for the native session's running operation to finish",
|
|
41478
|
-
{},
|
|
41479
|
-
"session_busy"
|
|
41480
|
-
);
|
|
41481
|
-
}
|
|
41482
|
-
this.#nativeOperations.add(key);
|
|
41483
|
-
try {
|
|
41484
|
-
for (const entry of linked) {
|
|
41485
|
-
const active = this.#executionProcesses.get(entry.sessionId);
|
|
41486
|
-
if (active !== void 0 && active !== runtime) {
|
|
41487
|
-
await this.#retireSessionProcess(entry.sessionId, active, async () => await active.close());
|
|
41488
|
-
}
|
|
41489
|
-
}
|
|
41490
|
-
options2.signal.throwIfAborted();
|
|
41491
|
-
await runtime.deleteNativeSession(nativeSessionId, options2.signal);
|
|
41492
|
-
const deleted = this.#store.markDeleted(options2.agent.id, nativeSessionId);
|
|
41493
|
-
if (runtime.nativeSessionId() === nativeSessionId) {
|
|
41494
|
-
await this.#queryProcesses.retire(options2.sessionId, runtime);
|
|
41495
|
-
}
|
|
41496
|
-
return deleted;
|
|
41497
|
-
} finally {
|
|
41498
|
-
this.#nativeOperations.delete(key);
|
|
41499
|
-
this.#processes.notifyChanged();
|
|
41500
|
-
}
|
|
41501
|
-
});
|
|
41502
|
-
});
|
|
41503
41347
|
};
|
|
41504
41348
|
|
|
41505
41349
|
// src/agent-catalog/publish-agent-catalog.ts
|
|
@@ -43880,7 +43724,6 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
|
|
|
43880
43724
|
|
|
43881
43725
|
// src/native-sessions/service.ts
|
|
43882
43726
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
43883
|
-
import { basename as basename5 } from "node:path";
|
|
43884
43727
|
var NativeSessionService = class {
|
|
43885
43728
|
#entries = /* @__PURE__ */ new Map();
|
|
43886
43729
|
#cursors = /* @__PURE__ */ new Map();
|
|
@@ -43924,64 +43767,6 @@ var NativeSessionService = class {
|
|
|
43924
43767
|
...await this.#activeTurn(command, options)
|
|
43925
43768
|
};
|
|
43926
43769
|
}
|
|
43927
|
-
if (command.action === "fork-recorded") {
|
|
43928
|
-
const source = this.#sessions.findSessions([command.sessionId])[0];
|
|
43929
|
-
if (source === void 0 || !source.prompted) {
|
|
43930
|
-
throw new AcpExecutionError(
|
|
43931
|
-
"The source conversation has no resumable native Agent session",
|
|
43932
|
-
{},
|
|
43933
|
-
"native_session_not_found"
|
|
43934
|
-
);
|
|
43935
|
-
}
|
|
43936
|
-
if (source.agentId !== command.agentId || source.cwd !== cwd || source.additionalDirectories.length !== additionalDirectories.length || source.additionalDirectories.some((path3, index) => path3 !== additionalDirectories[index])) {
|
|
43937
|
-
throw new AcpExecutionError(
|
|
43938
|
-
"The source conversation execution target does not match the fork request",
|
|
43939
|
-
{},
|
|
43940
|
-
"native_session_target_changed"
|
|
43941
|
-
);
|
|
43942
|
-
}
|
|
43943
|
-
if (source.lastTerminalCommandId !== command.throughCommandId) {
|
|
43944
|
-
throw new AcpExecutionError(
|
|
43945
|
-
"The selected Turn is no longer the source conversation head",
|
|
43946
|
-
{},
|
|
43947
|
-
"fork_point_stale"
|
|
43948
|
-
);
|
|
43949
|
-
}
|
|
43950
|
-
const opened2 = await this.#sessions.openNativeSession(
|
|
43951
|
-
{ ...options, sessionId: command.targetSessionId },
|
|
43952
|
-
{ kind: "fork", nativeSessionId: source.nativeSessionId }
|
|
43953
|
-
);
|
|
43954
|
-
signal.throwIfAborted();
|
|
43955
|
-
const directory = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
|
|
43956
|
-
const ready2 = {
|
|
43957
|
-
additionalDirectories: additionalDirectories.map((path3, index) => ({
|
|
43958
|
-
directoryId: command.additionalDirectoryIds[index] ?? command.directoryId,
|
|
43959
|
-
name: basename5(path3) || path3
|
|
43960
|
-
})),
|
|
43961
|
-
agentId: command.agentId,
|
|
43962
|
-
agentName: opened2.prepared.agentName,
|
|
43963
|
-
agentVersion: opened2.prepared.agentVersion,
|
|
43964
|
-
capabilities: opened2.prepared.capabilities,
|
|
43965
|
-
commands: opened2.prepared.commands,
|
|
43966
|
-
configOptions: opened2.prepared.configOptions,
|
|
43967
|
-
directoryId: command.directoryId,
|
|
43968
|
-
directoryLabel: directory.directoryLabel,
|
|
43969
|
-
kind: "session.ready",
|
|
43970
|
-
requestId: command.requestId,
|
|
43971
|
-
restored: true,
|
|
43972
|
-
sessionId: opened2.sessionId
|
|
43973
|
-
};
|
|
43974
|
-
this.record(command, "native_recorded_session_forked");
|
|
43975
|
-
return {
|
|
43976
|
-
action: "fork-recorded",
|
|
43977
|
-
kind: "native.session.result",
|
|
43978
|
-
ready: ready2,
|
|
43979
|
-
requestId: command.requestId,
|
|
43980
|
-
sessionId: command.sessionId,
|
|
43981
|
-
targetSessionId: command.targetSessionId,
|
|
43982
|
-
title: source.title || "Untitled session"
|
|
43983
|
-
};
|
|
43984
|
-
}
|
|
43985
43770
|
const prepared = await this.#sessions.prepareNativeSessionBrowser(options);
|
|
43986
43771
|
if (!prepared.capabilities.listSessions) {
|
|
43987
43772
|
throw new AcpExecutionError(
|
|
@@ -44116,25 +43901,6 @@ var NativeSessionService = class {
|
|
|
44116
43901
|
);
|
|
44117
43902
|
}
|
|
44118
43903
|
const target = await this.resolveTarget(command, options, selected);
|
|
44119
|
-
if (command.action === "delete") {
|
|
44120
|
-
if (!prepared.capabilities.deleteSession) {
|
|
44121
|
-
throw new AcpExecutionError(
|
|
44122
|
-
"This Agent does not support native session deletion",
|
|
44123
|
-
{},
|
|
44124
|
-
"native_session_unsupported"
|
|
44125
|
-
);
|
|
44126
|
-
}
|
|
44127
|
-
signal.throwIfAborted();
|
|
44128
|
-
this.record(command, "native_session_delete_authorized");
|
|
44129
|
-
const deletedSessionIds = await this.#sessions.deleteNativeSession(options, target.info.sessionId);
|
|
44130
|
-
this.record(command, "native_session_deleted");
|
|
44131
|
-
return {
|
|
44132
|
-
...envelope2,
|
|
44133
|
-
action: "delete",
|
|
44134
|
-
entryId: command.entryId,
|
|
44135
|
-
deletedSessionIds: deletedSessionIds.map(decodeIdentifier)
|
|
44136
|
-
};
|
|
44137
|
-
}
|
|
44138
43904
|
const action = command.action;
|
|
44139
43905
|
if (action === "import" && !prepared.capabilities.loadSession && !prepared.capabilities.resumeSession) {
|
|
44140
43906
|
throw new AcpExecutionError("This Agent cannot import native sessions", {}, "native_session_unsupported");
|
|
@@ -45144,7 +44910,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45144
44910
|
// src/artifacts/local-file-streamer.ts
|
|
45145
44911
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
45146
44912
|
import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
|
|
45147
|
-
import { basename as
|
|
44913
|
+
import { basename as basename5, isAbsolute as isAbsolute10, normalize as normalize4, resolve as resolve7 } from "node:path";
|
|
45148
44914
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
45149
44915
|
var CHUNK_BYTES = 192 * 1024;
|
|
45150
44916
|
function requestedPath(value) {
|
|
@@ -45196,7 +44962,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
45196
44962
|
kind: FILE_BEGIN_KIND,
|
|
45197
44963
|
mediaType: external?.mediaType ?? raster?.mimeType ?? "application/octet-stream",
|
|
45198
44964
|
modifiedAt: before.mtime.toISOString(),
|
|
45199
|
-
name: external?.name ?? (
|
|
44965
|
+
name: external?.name ?? (basename5(target) || "file"),
|
|
45200
44966
|
requestId: command.requestId,
|
|
45201
44967
|
sessionId: command.sessionId
|
|
45202
44968
|
});
|
|
@@ -45226,7 +44992,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
45226
44992
|
}
|
|
45227
44993
|
|
|
45228
44994
|
// src/authorization/resolve-session-directories.ts
|
|
45229
|
-
import { basename as
|
|
44995
|
+
import { basename as basename6 } from "node:path";
|
|
45230
44996
|
var ResolvedSessionDirectories = class {
|
|
45231
44997
|
additionalDirectories;
|
|
45232
44998
|
additionalDirectoryEntries;
|
|
@@ -45251,7 +45017,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
45251
45017
|
additionalDirectories.push(directory);
|
|
45252
45018
|
additionalDirectoryEntries.push({
|
|
45253
45019
|
directoryId: additionalDirectoryId,
|
|
45254
|
-
name:
|
|
45020
|
+
name: basename6(directory)
|
|
45255
45021
|
});
|
|
45256
45022
|
}
|
|
45257
45023
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
@@ -46030,7 +45796,7 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
46030
45796
|
// src/native-sessions/handle-native-requests.ts
|
|
46031
45797
|
import { WebSocket as WebSocket4 } from "undici";
|
|
46032
45798
|
function createNativeSessionRequestHandler(dependencies) {
|
|
46033
|
-
const { audit, diagnostics, nativeSessions,
|
|
45799
|
+
const { audit, diagnostics, nativeSessions, signal, socket, timer } = dependencies;
|
|
46034
45800
|
const pending = /* @__PURE__ */ new Map();
|
|
46035
45801
|
const cancel = (command) => {
|
|
46036
45802
|
const request = pending.get(command.requestId);
|
|
@@ -46082,17 +45848,6 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
46082
45848
|
}
|
|
46083
45849
|
operationSignal.throwIfAborted();
|
|
46084
45850
|
const result = await nativeSessions.execute(command, operationSignal);
|
|
46085
|
-
if (command.action === "fork-recorded" && result.action === "fork-recorded") {
|
|
46086
|
-
publisher.publishBatch(result.ready.sessionId, [
|
|
46087
|
-
result.ready,
|
|
46088
|
-
{
|
|
46089
|
-
kind: "session.forked",
|
|
46090
|
-
sessionId: result.ready.sessionId,
|
|
46091
|
-
sourceSessionId: command.sessionId,
|
|
46092
|
-
throughCommandId: command.throughCommandId
|
|
46093
|
-
}
|
|
46094
|
-
]);
|
|
46095
|
-
}
|
|
46096
45851
|
if (socket.readyState === WebSocket4.OPEN) {
|
|
46097
45852
|
send(socket, result);
|
|
46098
45853
|
}
|
|
@@ -46172,7 +45927,6 @@ function createDaemonCommandHandler({
|
|
|
46172
45927
|
audit,
|
|
46173
45928
|
diagnostics,
|
|
46174
45929
|
nativeSessions,
|
|
46175
|
-
publisher,
|
|
46176
45930
|
signal,
|
|
46177
45931
|
socket,
|
|
46178
45932
|
timer
|