@moxt-ai/mobius 0.0.173 → 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/agent-catalog/agent-specification.js +1 -1
- package/dist/cli.js +66 -981
- package/dist/cli.js.map +4 -4
- package/dist/daemon-command-handler.d.ts +1 -2
- package/dist/daemon-command-handler.d.ts.map +1 -1
- package/dist/daemon-command-handler.js +6 -27
- package/dist/daemon-command-handler.js.map +1 -1
- package/dist/daemon-history-commands.d.ts +1 -3
- package/dist/daemon-history-commands.d.ts.map +1 -1
- package/dist/daemon-history-commands.js +1 -48
- package/dist/daemon-history-commands.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 +65 -980
- 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 -117
- package/dist/native-sessions/service.js.map +1 -1
- package/dist/relay-connection/run-relay-connection.d.ts +1 -2
- package/dist/relay-connection/run-relay-connection.d.ts.map +1 -1
- package/dist/relay-connection/run-relay-connection.js +1 -2
- package/dist/relay-connection/run-relay-connection.js.map +1 -1
- package/dist/run-daemon.d.ts +0 -1
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +0 -6
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.d.ts +0 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +67 -982
- 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/agent-catalog/handle-agent-catalog-refresh.d.ts +0 -21
- package/dist/agent-catalog/handle-agent-catalog-refresh.d.ts.map +0 -1
- package/dist/agent-catalog/handle-agent-catalog-refresh.js +0 -119
- package/dist/agent-catalog/handle-agent-catalog-refresh.js.map +0 -1
- package/dist/native-sessions/acp-adapter.d.ts +0 -3
- package/dist/native-sessions/acp-adapter.d.ts.map +0 -1
- package/dist/native-sessions/acp-adapter.js +0 -6
- package/dist/native-sessions/acp-adapter.js.map +0 -1
- package/dist/native-sessions/acp-history.d.ts +0 -6
- package/dist/native-sessions/acp-history.d.ts.map +0 -1
- package/dist/native-sessions/acp-history.js +0 -27
- package/dist/native-sessions/acp-history.js.map +0 -1
- package/dist/native-sessions/agent-adapter.d.ts +0 -16
- package/dist/native-sessions/agent-adapter.d.ts.map +0 -1
- package/dist/native-sessions/agent-adapter.js +0 -19
- package/dist/native-sessions/agent-adapter.js.map +0 -1
- package/dist/native-sessions/codex-adapter.d.ts +0 -3
- package/dist/native-sessions/codex-adapter.d.ts.map +0 -1
- package/dist/native-sessions/codex-adapter.js +0 -20
- package/dist/native-sessions/codex-adapter.js.map +0 -1
- package/dist/native-sessions/live-history-page.d.ts +0 -4
- package/dist/native-sessions/live-history-page.d.ts.map +0 -1
- package/dist/native-sessions/live-history-page.js +0 -258
- package/dist/native-sessions/live-history-page.js.map +0 -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: {
|
|
@@ -28416,9 +28416,6 @@ var AGENT_INSTALL_CANCELLED_KIND = "agent.integration.install.cancelled";
|
|
|
28416
28416
|
var AGENT_SETTINGS_DISCOVER_KIND = "agent.settings.discover";
|
|
28417
28417
|
var AGENT_SETTINGS_DISCOVERED_KIND = "agent.settings.discovered";
|
|
28418
28418
|
var AGENT_SETTINGS_DISCOVERY_FAILED_KIND = "agent.settings.discovery.failed";
|
|
28419
|
-
var AGENT_CATALOG_REFRESH_KIND = "agent.catalog.refresh";
|
|
28420
|
-
var AGENT_CATALOG_REFRESHED_KIND = "agent.catalog.refreshed";
|
|
28421
|
-
var AGENT_CATALOG_REFRESH_FAILED_KIND = "agent.catalog.refresh.failed";
|
|
28422
28419
|
var FILE_READ_KIND = "file.read";
|
|
28423
28420
|
var FILE_BEGIN_KIND = "file.begin";
|
|
28424
28421
|
var FILE_CHUNK_KIND = "file.chunk";
|
|
@@ -28580,20 +28577,6 @@ var agentSettingsDiscoveryFailedEventSchema = external_exports.object({
|
|
|
28580
28577
|
message: external_exports.string().min(1).max(500),
|
|
28581
28578
|
requestId: identifierStringSchema
|
|
28582
28579
|
}).readonly();
|
|
28583
|
-
var agentCatalogRefreshCommandSchema = external_exports.object({
|
|
28584
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESH_KIND),
|
|
28585
|
-
requestId: identifierStringSchema
|
|
28586
|
-
}).readonly();
|
|
28587
|
-
var agentCatalogRefreshedEventSchema = external_exports.object({
|
|
28588
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESHED_KIND),
|
|
28589
|
-
requestId: identifierStringSchema
|
|
28590
|
-
}).readonly();
|
|
28591
|
-
var agentCatalogRefreshFailedEventSchema = external_exports.object({
|
|
28592
|
-
code: identifierStringSchema,
|
|
28593
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESH_FAILED_KIND),
|
|
28594
|
-
message: external_exports.string().min(1).max(500),
|
|
28595
|
-
requestId: identifierStringSchema
|
|
28596
|
-
}).readonly();
|
|
28597
28580
|
var sessionConfigurationSelectionSchema = external_exports.object({
|
|
28598
28581
|
booleanValue: external_exports.boolean(),
|
|
28599
28582
|
configId: identifierStringSchema,
|
|
@@ -28998,12 +28981,6 @@ var decodeAgentSettingsDiscoveredEvent = (encoded) => decode3(encoded, agentSett
|
|
|
28998
28981
|
var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
|
|
28999
28982
|
var decodeAgentSettingsDiscoveryFailedEvent = (encoded) => decode3(encoded, agentSettingsDiscoveryFailedEventSchema);
|
|
29000
28983
|
var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
|
|
29001
|
-
var decodeAgentCatalogRefreshCommand = (encoded) => decode3(encoded, agentCatalogRefreshCommandSchema);
|
|
29002
|
-
var encodeAgentCatalogRefreshCommand = (message) => encode3(message, agentCatalogRefreshCommandSchema);
|
|
29003
|
-
var decodeAgentCatalogRefreshedEvent = (encoded) => decode3(encoded, agentCatalogRefreshedEventSchema);
|
|
29004
|
-
var encodeAgentCatalogRefreshedEvent = (message) => encode3(message, agentCatalogRefreshedEventSchema);
|
|
29005
|
-
var decodeAgentCatalogRefreshFailedEvent = (encoded) => decode3(encoded, agentCatalogRefreshFailedEventSchema);
|
|
29006
|
-
var encodeAgentCatalogRefreshFailedEvent = (message) => encode3(message, agentCatalogRefreshFailedEventSchema);
|
|
29007
28984
|
var decodeFileReadCommand = (encoded) => decode3(encoded, fileReadCommandSchema);
|
|
29008
28985
|
var encodeFileReadCommand = (message) => encode3(message, fileReadCommandSchema);
|
|
29009
28986
|
var decodeFileBeginEvent = (encoded) => decode3(encoded, fileBeginEventSchema);
|
|
@@ -29072,6 +29049,8 @@ var SESSION_CANCEL_KIND = "session.cancel";
|
|
|
29072
29049
|
var RUNTIME_LIVENESS_READY_KIND = "runtime.liveness.ready";
|
|
29073
29050
|
var RUNTIME_HEARTBEAT_KIND = "runtime.heartbeat";
|
|
29074
29051
|
var RUNTIME_HEARTBEAT_ACK_KIND = "runtime.heartbeat.ack";
|
|
29052
|
+
var RUNTIME_PING_KIND = "runtime.ping";
|
|
29053
|
+
var RUNTIME_PONG_KIND = "runtime.pong";
|
|
29075
29054
|
var SESSION_STARTED_KIND = "session.started";
|
|
29076
29055
|
var SESSION_QUEUED_KIND = "session.queued";
|
|
29077
29056
|
var AGENT_MESSAGE_DELTA_KIND = "agent.message.delta";
|
|
@@ -29384,6 +29363,16 @@ function decodeRuntimeHeartbeatAckEvent(encoded) {
|
|
|
29384
29363
|
kind: RUNTIME_HEARTBEAT_ACK_KIND
|
|
29385
29364
|
};
|
|
29386
29365
|
}
|
|
29366
|
+
function decodeRuntimePingCommand(encoded) {
|
|
29367
|
+
const value = parseJson2(encoded);
|
|
29368
|
+
assertKind(value, RUNTIME_PING_KIND);
|
|
29369
|
+
return { kind: RUNTIME_PING_KIND, requestId: readIdentifier(value, "requestId") };
|
|
29370
|
+
}
|
|
29371
|
+
function decodeRuntimePongEvent(encoded) {
|
|
29372
|
+
const value = parseJson2(encoded);
|
|
29373
|
+
assertKind(value, RUNTIME_PONG_KIND);
|
|
29374
|
+
return { kind: RUNTIME_PONG_KIND, requestId: readIdentifier(value, "requestId") };
|
|
29375
|
+
}
|
|
29387
29376
|
function decodeSessionStartedEvent(encoded) {
|
|
29388
29377
|
const value = parseJson2(encoded);
|
|
29389
29378
|
assertKind(value, SESSION_STARTED_KIND);
|
|
@@ -29481,6 +29470,12 @@ function encodeRuntimeHeartbeatEvent(message) {
|
|
|
29481
29470
|
function encodeRuntimeHeartbeatAckEvent(message) {
|
|
29482
29471
|
return JSON.stringify(decodeRuntimeHeartbeatAckEvent(JSON.stringify(message)));
|
|
29483
29472
|
}
|
|
29473
|
+
function encodeRuntimePingCommand(message) {
|
|
29474
|
+
return JSON.stringify(decodeRuntimePingCommand(JSON.stringify(message)));
|
|
29475
|
+
}
|
|
29476
|
+
function encodeRuntimePongEvent(message) {
|
|
29477
|
+
return JSON.stringify(decodeRuntimePongEvent(JSON.stringify(message)));
|
|
29478
|
+
}
|
|
29484
29479
|
function decodeAgentActivityNarrationEvent(encoded) {
|
|
29485
29480
|
const value = parseJson2(encoded);
|
|
29486
29481
|
assertKind(value, AGENT_ACTIVITY_NARRATION_KIND);
|
|
@@ -29594,10 +29589,6 @@ function withinHistoryContentLimits(history) {
|
|
|
29594
29589
|
) <= SESSION_HISTORY_IMAGE_CHARACTER_LIMIT;
|
|
29595
29590
|
}
|
|
29596
29591
|
var sessionHistorySchema = external_exports.discriminatedUnion("status", [availableSessionHistorySchema, unavailableSessionHistorySchema]).refine(withinHistoryContentLimits);
|
|
29597
|
-
var nativeMessagePageSchema = external_exports.discriminatedUnion("status", [
|
|
29598
|
-
availableSessionHistoryObjectSchema.extend({ nextCursor: external_exports.string().max(512).nullable() }).readonly(),
|
|
29599
|
-
unavailableSessionHistoryObjectSchema.extend({ nextCursor: external_exports.null() }).readonly()
|
|
29600
|
-
]).refine(withinHistoryContentLimits);
|
|
29601
29592
|
|
|
29602
29593
|
// ../protocol/src/native-sessions.ts
|
|
29603
29594
|
var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
|
|
@@ -29663,10 +29654,7 @@ var identity = {
|
|
|
29663
29654
|
directoryId
|
|
29664
29655
|
};
|
|
29665
29656
|
var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
29666
|
-
external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
29667
29657
|
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
29668
|
-
external_exports.object({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
|
|
29669
|
-
external_exports.object({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
|
|
29670
29658
|
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
29671
29659
|
external_exports.object({
|
|
29672
29660
|
...identity,
|
|
@@ -29678,24 +29666,10 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
|
29678
29666
|
action: external_exports.enum(["import", "fork"]),
|
|
29679
29667
|
entryId: identifierStringSchema,
|
|
29680
29668
|
targetSessionId: identifierStringSchema
|
|
29681
|
-
}).readonly(),
|
|
29682
|
-
external_exports.object({
|
|
29683
|
-
...identity,
|
|
29684
|
-
action: external_exports.literal("fork-recorded"),
|
|
29685
|
-
targetSessionId: identifierStringSchema,
|
|
29686
|
-
throughCommandId: identifierStringSchema
|
|
29687
|
-
}).readonly(),
|
|
29688
|
-
external_exports.object({
|
|
29689
|
-
...identity,
|
|
29690
|
-
action: external_exports.literal("delete"),
|
|
29691
|
-
entryId: identifierStringSchema
|
|
29692
29669
|
}).readonly()
|
|
29693
29670
|
]);
|
|
29694
29671
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
29695
|
-
external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
29696
29672
|
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
29697
|
-
external_exports.object({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
|
|
29698
|
-
external_exports.object({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
|
|
29699
29673
|
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
29700
29674
|
external_exports.object({
|
|
29701
29675
|
...identity,
|
|
@@ -29707,17 +29681,6 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
|
29707
29681
|
action: external_exports.enum(["import", "fork"]),
|
|
29708
29682
|
entryId: identifierStringSchema,
|
|
29709
29683
|
targetSessionId: identifierStringSchema
|
|
29710
|
-
}).readonly(),
|
|
29711
|
-
external_exports.object({
|
|
29712
|
-
...identity,
|
|
29713
|
-
action: external_exports.literal("fork-recorded"),
|
|
29714
|
-
targetSessionId: identifierStringSchema,
|
|
29715
|
-
throughCommandId: identifierStringSchema
|
|
29716
|
-
}).readonly(),
|
|
29717
|
-
external_exports.object({
|
|
29718
|
-
...identity,
|
|
29719
|
-
action: external_exports.literal("delete"),
|
|
29720
|
-
entryId: identifierStringSchema
|
|
29721
29684
|
}).readonly()
|
|
29722
29685
|
]);
|
|
29723
29686
|
var nativeSessionEntrySchema = external_exports.object({
|
|
@@ -29735,7 +29698,6 @@ var resultEnvelope = {
|
|
|
29735
29698
|
kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
|
|
29736
29699
|
};
|
|
29737
29700
|
var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
29738
|
-
external_exports.object({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
29739
29701
|
external_exports.object({
|
|
29740
29702
|
...resultEnvelope,
|
|
29741
29703
|
action: external_exports.literal("active-turn"),
|
|
@@ -29763,32 +29725,10 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
29763
29725
|
}).readonly(),
|
|
29764
29726
|
external_exports.object({
|
|
29765
29727
|
...resultEnvelope,
|
|
29766
|
-
action: external_exports.enum(["import", "fork"
|
|
29728
|
+
action: external_exports.enum(["import", "fork"]),
|
|
29767
29729
|
targetSessionId: identifierStringSchema,
|
|
29768
29730
|
ready: sessionReadyEventSchema,
|
|
29769
29731
|
title: external_exports.string().max(500)
|
|
29770
|
-
}).readonly(),
|
|
29771
|
-
external_exports.object({
|
|
29772
|
-
...resultEnvelope,
|
|
29773
|
-
action: external_exports.literal("preview"),
|
|
29774
|
-
entryId: identifierStringSchema,
|
|
29775
|
-
targetSessionId: identifierStringSchema,
|
|
29776
|
-
reason: external_exports.enum(["continuation_unavailable", "requested"]),
|
|
29777
|
-
history: sessionHistorySchema,
|
|
29778
|
-
title: external_exports.string().max(500)
|
|
29779
|
-
}).readonly(),
|
|
29780
|
-
external_exports.object({
|
|
29781
|
-
...resultEnvelope,
|
|
29782
|
-
action: external_exports.literal("history"),
|
|
29783
|
-
entryId: identifierStringSchema,
|
|
29784
|
-
history: sessionHistorySchema,
|
|
29785
|
-
title: external_exports.string().max(500)
|
|
29786
|
-
}).readonly(),
|
|
29787
|
-
external_exports.object({
|
|
29788
|
-
...resultEnvelope,
|
|
29789
|
-
action: external_exports.literal("delete"),
|
|
29790
|
-
entryId: identifierStringSchema,
|
|
29791
|
-
deletedSessionIds: external_exports.array(identifierStringSchema).max(500).readonly()
|
|
29792
29732
|
}).readonly()
|
|
29793
29733
|
]);
|
|
29794
29734
|
var nativeSessionCancelSchema = external_exports.object({ ...envelope, kind: external_exports.literal(NATIVE_SESSION_CANCEL_KIND) }).readonly();
|
|
@@ -30354,28 +30294,9 @@ function decodeRecordedSessionEvent(encoded) {
|
|
|
30354
30294
|
var encodeRecordedSessionEvent = (event) => JSON.stringify(decodeRecordedSessionEvent(JSON.stringify(event)));
|
|
30355
30295
|
|
|
30356
30296
|
// ../protocol/src/session-live-history.ts
|
|
30357
|
-
var SESSION_LIVE_HISTORY_PAGE_LOAD_KIND = "session.live-history.page.load";
|
|
30358
|
-
var SESSION_LIVE_HISTORY_PAGE_LOADED_KIND = "session.live-history.page.loaded";
|
|
30359
30297
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
|
|
30360
30298
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
|
|
30361
30299
|
var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
|
|
30362
|
-
var sessionLiveHistoryPageLoadSchema = external_exports.object({
|
|
30363
|
-
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
30364
|
-
agentId: identifierStringSchema,
|
|
30365
|
-
bindingId: identifierStringSchema,
|
|
30366
|
-
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
30367
|
-
directoryId: directoryIdentifier,
|
|
30368
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOAD_KIND),
|
|
30369
|
-
limit: external_exports.number().int().min(1).max(100),
|
|
30370
|
-
requestId: identifierStringSchema,
|
|
30371
|
-
sessionId: identifierStringSchema
|
|
30372
|
-
}).readonly();
|
|
30373
|
-
var sessionLiveHistoryPageLoadedSchema = external_exports.object({
|
|
30374
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOADED_KIND),
|
|
30375
|
-
page: nativeMessagePageSchema,
|
|
30376
|
-
requestId: identifierStringSchema,
|
|
30377
|
-
sessionId: identifierStringSchema
|
|
30378
|
-
}).readonly();
|
|
30379
30300
|
var sessionLiveHistoryV2PageLoadSchema = external_exports.object({
|
|
30380
30301
|
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
30381
30302
|
agentId: identifierStringSchema,
|
|
@@ -30401,10 +30322,6 @@ function decode7(schema, encoded) {
|
|
|
30401
30322
|
throw new ProtocolMessageError("Invalid live Session history message", { cause });
|
|
30402
30323
|
}
|
|
30403
30324
|
}
|
|
30404
|
-
var decodeSessionLiveHistoryPageLoad = (encoded) => decode7(sessionLiveHistoryPageLoadSchema, encoded);
|
|
30405
|
-
var decodeSessionLiveHistoryPageLoaded = (encoded) => decode7(sessionLiveHistoryPageLoadedSchema, encoded);
|
|
30406
|
-
var encodeSessionLiveHistoryPageLoad = (value) => JSON.stringify(sessionLiveHistoryPageLoadSchema.parse(value));
|
|
30407
|
-
var encodeSessionLiveHistoryPageLoaded = (value) => JSON.stringify(sessionLiveHistoryPageLoadedSchema.parse(value));
|
|
30408
30325
|
var decodeSessionLiveHistoryV2PageLoad = (encoded) => decode7(sessionLiveHistoryV2PageLoadSchema, encoded);
|
|
30409
30326
|
var decodeSessionLiveHistoryV2PageLoaded = (encoded) => decode7(sessionLiveHistoryV2PageLoadedSchema, encoded);
|
|
30410
30327
|
var encodeSessionLiveHistoryV2PageLoad = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadSchema.parse(value));
|
|
@@ -30421,11 +30338,6 @@ function defineMessageSignature(kind, encoder, decoder) {
|
|
|
30421
30338
|
};
|
|
30422
30339
|
}
|
|
30423
30340
|
var serviceToDaemonSignatures = {
|
|
30424
|
-
[AGENT_CATALOG_REFRESH_KIND]: defineMessageSignature(
|
|
30425
|
-
AGENT_CATALOG_REFRESH_KIND,
|
|
30426
|
-
encodeAgentCatalogRefreshCommand,
|
|
30427
|
-
decodeAgentCatalogRefreshCommand
|
|
30428
|
-
),
|
|
30429
30341
|
[AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
|
|
30430
30342
|
AGENT_INSTALL_CANCEL_KIND,
|
|
30431
30343
|
encodeAgentInstallCancelCommand,
|
|
@@ -30468,6 +30380,7 @@ var serviceToDaemonSignatures = {
|
|
|
30468
30380
|
encodeRuntimeLivenessReadyEvent,
|
|
30469
30381
|
decodeRuntimeLivenessReadyEvent
|
|
30470
30382
|
),
|
|
30383
|
+
[RUNTIME_PING_KIND]: defineMessageSignature(RUNTIME_PING_KIND, encodeRuntimePingCommand, decodeRuntimePingCommand),
|
|
30471
30384
|
[SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
30472
30385
|
SESSION_CANCEL_KIND,
|
|
30473
30386
|
encodeSessionCancelCommand,
|
|
@@ -30483,11 +30396,6 @@ var serviceToDaemonSignatures = {
|
|
|
30483
30396
|
encodeSessionElicitationRespondCommand,
|
|
30484
30397
|
decodeSessionElicitationRespondCommand
|
|
30485
30398
|
),
|
|
30486
|
-
[SESSION_LIVE_HISTORY_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
30487
|
-
SESSION_LIVE_HISTORY_PAGE_LOAD_KIND,
|
|
30488
|
-
encodeSessionLiveHistoryPageLoad,
|
|
30489
|
-
decodeSessionLiveHistoryPageLoad
|
|
30490
|
-
),
|
|
30491
30399
|
[SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
30492
30400
|
SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND,
|
|
30493
30401
|
encodeSessionLiveHistoryV2PageLoad,
|
|
@@ -30529,16 +30437,6 @@ function decodeServiceToDaemonMessage(encoded) {
|
|
|
30529
30437
|
return signature.decoder(encoded);
|
|
30530
30438
|
}
|
|
30531
30439
|
var daemonToServiceSignatures = {
|
|
30532
|
-
[AGENT_CATALOG_REFRESHED_KIND]: defineMessageSignature(
|
|
30533
|
-
AGENT_CATALOG_REFRESHED_KIND,
|
|
30534
|
-
encodeAgentCatalogRefreshedEvent,
|
|
30535
|
-
decodeAgentCatalogRefreshedEvent
|
|
30536
|
-
),
|
|
30537
|
-
[AGENT_CATALOG_REFRESH_FAILED_KIND]: defineMessageSignature(
|
|
30538
|
-
AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
30539
|
-
encodeAgentCatalogRefreshFailedEvent,
|
|
30540
|
-
decodeAgentCatalogRefreshFailedEvent
|
|
30541
|
-
),
|
|
30542
30440
|
[AGENT_INSTALL_CANCELLED_KIND]: defineMessageSignature(
|
|
30543
30441
|
AGENT_INSTALL_CANCELLED_KIND,
|
|
30544
30442
|
encodeAgentInstallCancelledEvent,
|
|
@@ -30608,6 +30506,7 @@ var daemonToServiceSignatures = {
|
|
|
30608
30506
|
encodeRuntimeHeartbeatEvent,
|
|
30609
30507
|
decodeRuntimeHeartbeatEvent
|
|
30610
30508
|
),
|
|
30509
|
+
[RUNTIME_PONG_KIND]: defineMessageSignature(RUNTIME_PONG_KIND, encodeRuntimePongEvent, decodeRuntimePongEvent),
|
|
30611
30510
|
[SESSION_EVENT_KIND]: defineMessageSignature(
|
|
30612
30511
|
SESSION_EVENT_KIND,
|
|
30613
30512
|
encodeSessionEventEnvelope,
|
|
@@ -30623,11 +30522,6 @@ var daemonToServiceSignatures = {
|
|
|
30623
30522
|
encodeSessionOperationFailedEvent,
|
|
30624
30523
|
decodeSessionOperationFailedEvent
|
|
30625
30524
|
),
|
|
30626
|
-
[SESSION_LIVE_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
30627
|
-
SESSION_LIVE_HISTORY_PAGE_LOADED_KIND,
|
|
30628
|
-
encodeSessionLiveHistoryPageLoaded,
|
|
30629
|
-
decodeSessionLiveHistoryPageLoaded
|
|
30630
|
-
),
|
|
30631
30525
|
[SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
30632
30526
|
SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
|
|
30633
30527
|
encodeSessionLiveHistoryV2PageLoaded,
|
|
@@ -38737,6 +38631,10 @@ var acpSessionStoreMigrations = [
|
|
|
38737
38631
|
{
|
|
38738
38632
|
"name": "0003_silky_ravenous.sql",
|
|
38739
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`;"
|
|
38740
38638
|
}
|
|
38741
38639
|
];
|
|
38742
38640
|
|
|
@@ -38747,33 +38645,25 @@ var acpSession = sqliteTable("acp_session", {
|
|
|
38747
38645
|
nativeSessionId: text("native_session_id").notNull(),
|
|
38748
38646
|
cwd: text("cwd").notNull(),
|
|
38749
38647
|
additionalDirectories: text("additional_directories").notNull(),
|
|
38750
|
-
lastTerminalCommandId: text("last_terminal_command_id"),
|
|
38751
38648
|
prompted: integer2("prompted", { mode: "boolean" }).notNull(),
|
|
38752
38649
|
title: text("title").notNull(),
|
|
38753
38650
|
updatedAt: text("updated_at").notNull()
|
|
38754
38651
|
});
|
|
38755
38652
|
|
|
38756
|
-
// src/schema/acp-session-store/deleted-acp-session.ts
|
|
38757
|
-
var deletedAcpSession = sqliteTable("deleted_acp_session", {
|
|
38758
|
-
sessionId: text("session_id").primaryKey()
|
|
38759
|
-
});
|
|
38760
|
-
|
|
38761
38653
|
// src/acp/session-store.ts
|
|
38762
38654
|
var AcpStoredSession = class {
|
|
38763
38655
|
additionalDirectories;
|
|
38764
38656
|
agentId;
|
|
38765
38657
|
cwd;
|
|
38766
|
-
lastTerminalCommandId;
|
|
38767
38658
|
nativeSessionId;
|
|
38768
38659
|
prompted;
|
|
38769
38660
|
sessionId;
|
|
38770
38661
|
title;
|
|
38771
38662
|
updatedAt;
|
|
38772
|
-
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()) {
|
|
38773
38664
|
this.additionalDirectories = [...additionalDirectories];
|
|
38774
38665
|
this.agentId = agentId;
|
|
38775
38666
|
this.cwd = cwd;
|
|
38776
|
-
this.lastTerminalCommandId = lastTerminalCommandId;
|
|
38777
38667
|
this.nativeSessionId = nativeSessionId;
|
|
38778
38668
|
this.prompted = prompted;
|
|
38779
38669
|
this.sessionId = sessionId;
|
|
@@ -38794,32 +38684,16 @@ var FoundAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
|
38794
38684
|
this.session = session;
|
|
38795
38685
|
}
|
|
38796
38686
|
};
|
|
38797
|
-
var DeletedAcpStoredSession = class extends AcpStoredSessionLookup {
|
|
38798
|
-
found = false;
|
|
38799
|
-
};
|
|
38800
38687
|
var MemoryAcpSessionStore = class {
|
|
38801
38688
|
#sessions = /* @__PURE__ */ new Map();
|
|
38802
|
-
#deleted = /* @__PURE__ */ new Set();
|
|
38803
38689
|
close = () => {
|
|
38804
38690
|
this.#sessions.clear();
|
|
38805
|
-
this.#deleted.clear();
|
|
38806
38691
|
};
|
|
38807
38692
|
findNative = (agentId, nativeSessionId) => [...this.#sessions.values()].filter(
|
|
38808
38693
|
(session) => session.agentId === agentId && session.nativeSessionId === nativeSessionId
|
|
38809
38694
|
);
|
|
38810
38695
|
list = () => [...this.#sessions.values()].toSorted((left, right) => right.updatedAt.localeCompare(left.updatedAt));
|
|
38811
|
-
markDeleted = (agentId, nativeSessionId) => {
|
|
38812
|
-
const ids = this.findNative(agentId, nativeSessionId).map((session) => session.sessionId);
|
|
38813
|
-
for (const id of ids) {
|
|
38814
|
-
this.#sessions.delete(id);
|
|
38815
|
-
this.#deleted.add(id);
|
|
38816
|
-
}
|
|
38817
|
-
return ids;
|
|
38818
|
-
};
|
|
38819
38696
|
read = (sessionId) => {
|
|
38820
|
-
if (this.#deleted.has(sessionId)) {
|
|
38821
|
-
return new DeletedAcpStoredSession();
|
|
38822
|
-
}
|
|
38823
38697
|
const session = this.#sessions.get(sessionId);
|
|
38824
38698
|
return session === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(session);
|
|
38825
38699
|
};
|
|
@@ -38834,14 +38708,12 @@ var storedSessionRowSchema = external_exports.object({
|
|
|
38834
38708
|
additionalDirectories: external_exports.string(),
|
|
38835
38709
|
agentId: external_exports.string(),
|
|
38836
38710
|
cwd: external_exports.string(),
|
|
38837
|
-
lastTerminalCommandId: external_exports.string().nullable(),
|
|
38838
38711
|
nativeSessionId: external_exports.string(),
|
|
38839
38712
|
prompted: external_exports.boolean(),
|
|
38840
38713
|
sessionId: external_exports.string(),
|
|
38841
38714
|
title: external_exports.string(),
|
|
38842
38715
|
updatedAt: external_exports.string()
|
|
38843
38716
|
});
|
|
38844
|
-
var sessionIdRowSchema = external_exports.object({ sessionId: external_exports.string() });
|
|
38845
38717
|
function decodeStoredSession(value) {
|
|
38846
38718
|
const row = storedSessionRowSchema.parse(value);
|
|
38847
38719
|
const decodedAdditionalDirectories = JSON.parse(row.additionalDirectories);
|
|
@@ -38854,8 +38726,7 @@ function decodeStoredSession(value) {
|
|
|
38854
38726
|
additionalDirectories,
|
|
38855
38727
|
row.prompted,
|
|
38856
38728
|
row.title,
|
|
38857
|
-
row.updatedAt
|
|
38858
|
-
row.lastTerminalCommandId
|
|
38729
|
+
row.updatedAt
|
|
38859
38730
|
);
|
|
38860
38731
|
}
|
|
38861
38732
|
var SqliteAcpSessionStore = class {
|
|
@@ -38890,37 +38761,12 @@ var SqliteAcpSessionStore = class {
|
|
|
38890
38761
|
}
|
|
38891
38762
|
}
|
|
38892
38763
|
};
|
|
38893
|
-
#transaction = (operation) => {
|
|
38894
|
-
this.#sqliteDatabase.exec("BEGIN IMMEDIATE");
|
|
38895
|
-
try {
|
|
38896
|
-
operation();
|
|
38897
|
-
this.#sqliteDatabase.exec("COMMIT");
|
|
38898
|
-
} catch (error62) {
|
|
38899
|
-
this.#sqliteDatabase.exec("ROLLBACK");
|
|
38900
|
-
throw error62;
|
|
38901
|
-
}
|
|
38902
|
-
};
|
|
38903
38764
|
close = () => {
|
|
38904
38765
|
this.#sqliteDatabase.close();
|
|
38905
38766
|
};
|
|
38906
38767
|
findNative = (agentId, nativeSessionId) => this.#database.select().from(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).all().map(decodeStoredSession);
|
|
38907
38768
|
list = () => this.#database.select().from(acpSession).orderBy(desc(acpSession.updatedAt)).all().map(decodeStoredSession);
|
|
38908
|
-
markDeleted = (agentId, nativeSessionId) => {
|
|
38909
|
-
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);
|
|
38910
|
-
this.#transaction(() => {
|
|
38911
|
-
this.#database.delete(acpSession).where(and(eq(acpSession.agentId, agentId), eq(acpSession.nativeSessionId, nativeSessionId))).run();
|
|
38912
|
-
for (const id of ids) {
|
|
38913
|
-
this.#database.insert(deletedAcpSession).values({ sessionId: id }).onConflictDoNothing().run();
|
|
38914
|
-
}
|
|
38915
|
-
});
|
|
38916
|
-
return ids;
|
|
38917
|
-
};
|
|
38918
38769
|
read = (sessionId) => {
|
|
38919
|
-
const deleted = this.#database.select({ sessionId: deletedAcpSession.sessionId }).from(deletedAcpSession).where(eq(deletedAcpSession.sessionId, sessionId)).get();
|
|
38920
|
-
if (deleted !== void 0) {
|
|
38921
|
-
sessionIdRowSchema.parse(deleted);
|
|
38922
|
-
return new DeletedAcpStoredSession();
|
|
38923
|
-
}
|
|
38924
38770
|
const row = this.#database.select().from(acpSession).where(eq(acpSession.sessionId, sessionId)).get();
|
|
38925
38771
|
return row === void 0 ? new MissingAcpStoredSession() : new FoundAcpStoredSession(decodeStoredSession(row));
|
|
38926
38772
|
};
|
|
@@ -38932,20 +38778,13 @@ var SqliteAcpSessionStore = class {
|
|
|
38932
38778
|
additionalDirectories: JSON.stringify(session.additionalDirectories),
|
|
38933
38779
|
agentId: session.agentId,
|
|
38934
38780
|
cwd: session.cwd,
|
|
38935
|
-
lastTerminalCommandId: session.lastTerminalCommandId,
|
|
38936
38781
|
nativeSessionId: session.nativeSessionId,
|
|
38937
38782
|
prompted: session.prompted,
|
|
38938
38783
|
sessionId: session.sessionId,
|
|
38939
38784
|
title: session.title,
|
|
38940
38785
|
updatedAt: session.updatedAt
|
|
38941
38786
|
};
|
|
38942
|
-
this.#
|
|
38943
|
-
this.#database.delete(deletedAcpSession).where(eq(deletedAcpSession.sessionId, session.sessionId)).run();
|
|
38944
|
-
this.#database.insert(acpSession).values(value).onConflictDoUpdate({
|
|
38945
|
-
target: acpSession.sessionId,
|
|
38946
|
-
set: value
|
|
38947
|
-
}).run();
|
|
38948
|
-
});
|
|
38787
|
+
this.#database.insert(acpSession).values(value).onConflictDoUpdate({ target: acpSession.sessionId, set: value }).run();
|
|
38949
38788
|
};
|
|
38950
38789
|
};
|
|
38951
38790
|
|
|
@@ -38986,7 +38825,6 @@ var AgentSession = class _AgentSession {
|
|
|
38986
38825
|
#commands = [];
|
|
38987
38826
|
#configRevision = 0;
|
|
38988
38827
|
#configOptions = [];
|
|
38989
|
-
#lastTerminalCommandId = null;
|
|
38990
38828
|
#nativeHistoryOwnership = { kind: "unbound" };
|
|
38991
38829
|
#prompted = false;
|
|
38992
38830
|
#nativePrompt = null;
|
|
@@ -39299,13 +39137,6 @@ var AgentSession = class _AgentSession {
|
|
|
39299
39137
|
this.#store.remove(this.#mobiusSessionId);
|
|
39300
39138
|
stored = this.#metrics.measureSync("session-state-read", () => this.#store.read(this.#mobiusSessionId));
|
|
39301
39139
|
}
|
|
39302
|
-
if (stored instanceof DeletedAcpStoredSession) {
|
|
39303
|
-
throw new AcpExecutionError(
|
|
39304
|
-
"The native Agent session was deleted. Start a new chat.",
|
|
39305
|
-
{},
|
|
39306
|
-
"native_session_deleted"
|
|
39307
|
-
);
|
|
39308
|
-
}
|
|
39309
39140
|
let lifecycleResponse;
|
|
39310
39141
|
if (origin?.kind === "fork") {
|
|
39311
39142
|
if (!this.#capabilities.unstableForkSession) {
|
|
@@ -39353,7 +39184,6 @@ var AgentSession = class _AgentSession {
|
|
|
39353
39184
|
} else if (stored instanceof FoundAcpStoredSession && stored.session.agentId === this.#agentId && stored.session.cwd === this.#cwd && arraysEqual(stored.session.additionalDirectories, this.#additionalDirectories)) {
|
|
39354
39185
|
this.selectNativeSession(stored.session.nativeSessionId);
|
|
39355
39186
|
this.#prompted = stored.session.prompted;
|
|
39356
|
-
this.#lastTerminalCommandId = stored.session.lastTerminalCommandId;
|
|
39357
39187
|
this.#sessionTitle = stored.session.title;
|
|
39358
39188
|
this.#restored = true;
|
|
39359
39189
|
if (this.#capabilities.resumeSession) {
|
|
@@ -39429,8 +39259,7 @@ var AgentSession = class _AgentSession {
|
|
|
39429
39259
|
this.#additionalDirectories,
|
|
39430
39260
|
this.#prompted,
|
|
39431
39261
|
this.#sessionTitle ?? "",
|
|
39432
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
39433
|
-
this.#lastTerminalCommandId
|
|
39262
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
39434
39263
|
)
|
|
39435
39264
|
);
|
|
39436
39265
|
};
|
|
@@ -39459,24 +39288,6 @@ var AgentSession = class _AgentSession {
|
|
|
39459
39288
|
}
|
|
39460
39289
|
return decoded.data;
|
|
39461
39290
|
};
|
|
39462
|
-
deleteNativeSession = async (nativeSessionId, signal) => {
|
|
39463
|
-
if (!this.#capabilities.deleteSession || !this.#capabilities.listSessions) {
|
|
39464
|
-
throw new AcpExecutionError(
|
|
39465
|
-
"This Agent does not support native session deletion",
|
|
39466
|
-
{},
|
|
39467
|
-
"native_session_unsupported"
|
|
39468
|
-
);
|
|
39469
|
-
}
|
|
39470
|
-
await this.race(
|
|
39471
|
-
this.#connection.connection.agent.request(
|
|
39472
|
-
methods8.agent.session.delete,
|
|
39473
|
-
{ sessionId: nativeSessionIdSchema.parse(nativeSessionId) },
|
|
39474
|
-
{ cancellationSignal: signal }
|
|
39475
|
-
),
|
|
39476
|
-
"ACP agent exited while deleting a session",
|
|
39477
|
-
signal
|
|
39478
|
-
);
|
|
39479
|
-
};
|
|
39480
39291
|
nativeSessionId = () => this.#updates.sessionId();
|
|
39481
39292
|
adoptNativeSessionId = (sessionId) => {
|
|
39482
39293
|
if (this.#prompted || this.#updates.sessionId() !== sessionId) {
|
|
@@ -39632,8 +39443,7 @@ var AgentSession = class _AgentSession {
|
|
|
39632
39443
|
this.#additionalDirectories,
|
|
39633
39444
|
true,
|
|
39634
39445
|
this.#sessionTitle,
|
|
39635
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
39636
|
-
this.#lastTerminalCommandId
|
|
39446
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
39637
39447
|
)
|
|
39638
39448
|
);
|
|
39639
39449
|
this.#prompted = true;
|
|
@@ -39702,7 +39512,6 @@ var AgentSession = class _AgentSession {
|
|
|
39702
39512
|
usage: result.usage ?? null
|
|
39703
39513
|
});
|
|
39704
39514
|
}
|
|
39705
|
-
this.#lastTerminalCommandId = options.commandId;
|
|
39706
39515
|
this.#store.write(
|
|
39707
39516
|
new AcpStoredSession(
|
|
39708
39517
|
this.#mobiusSessionId,
|
|
@@ -39712,8 +39521,7 @@ var AgentSession = class _AgentSession {
|
|
|
39712
39521
|
this.#additionalDirectories,
|
|
39713
39522
|
true,
|
|
39714
39523
|
this.#sessionTitle ?? "",
|
|
39715
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
39716
|
-
this.#lastTerminalCommandId
|
|
39524
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
39717
39525
|
)
|
|
39718
39526
|
);
|
|
39719
39527
|
if (lifecycleV2 !== void 0) {
|
|
@@ -40001,8 +39809,7 @@ var AgentSession = class _AgentSession {
|
|
|
40001
39809
|
this.#additionalDirectories,
|
|
40002
39810
|
this.#prompted,
|
|
40003
39811
|
this.#sessionTitle ?? "",
|
|
40004
|
-
(/* @__PURE__ */ new Date()).toISOString()
|
|
40005
|
-
this.#lastTerminalCommandId
|
|
39812
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
40006
39813
|
)
|
|
40007
39814
|
);
|
|
40008
39815
|
}
|
|
@@ -40694,9 +40501,6 @@ var LocalExternalContentStore = class {
|
|
|
40694
40501
|
};
|
|
40695
40502
|
|
|
40696
40503
|
// src/native-sessions/chat-agent.ts
|
|
40697
|
-
function supportsNativeChat(agentId) {
|
|
40698
|
-
return agentId === "codex" || agentId === "claude" || agentId === "opencode" || agentId === "pi";
|
|
40699
|
-
}
|
|
40700
40504
|
function isNativeChatSessionId(agentId, sessionId) {
|
|
40701
40505
|
if (!nativeSessionIdSchema.safeParse(sessionId).success) {
|
|
40702
40506
|
return false;
|
|
@@ -41046,13 +40850,6 @@ var AgentRuntimeManager = class {
|
|
|
41046
40850
|
}
|
|
41047
40851
|
prepareSession = async (options, metrics = unmeasuredOperationMetrics) => this.#operations.run(options, async (options2) => {
|
|
41048
40852
|
const stored = metrics.measureSync("session-state-read", () => this.#store.read(options2.sessionId));
|
|
41049
|
-
if (stored instanceof DeletedAcpStoredSession) {
|
|
41050
|
-
throw new AcpExecutionError(
|
|
41051
|
-
"The native Agent session was deleted. Start a new chat.",
|
|
41052
|
-
{},
|
|
41053
|
-
"native_session_deleted"
|
|
41054
|
-
);
|
|
41055
|
-
}
|
|
41056
40853
|
if (stored instanceof FoundAcpStoredSession && this.#nativeOperations.has(`${stored.session.agentId}:${stored.session.nativeSessionId}`)) {
|
|
41057
40854
|
throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
|
|
41058
40855
|
}
|
|
@@ -41501,7 +41298,7 @@ var AgentRuntimeManager = class {
|
|
|
41501
41298
|
}
|
|
41502
41299
|
});
|
|
41503
41300
|
}
|
|
41504
|
-
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) {
|
|
41505
41302
|
throw new AcpExecutionError(
|
|
41506
41303
|
"The destination conversation already exists",
|
|
41507
41304
|
{},
|
|
@@ -41547,40 +41344,6 @@ var AgentRuntimeManager = class {
|
|
|
41547
41344
|
}
|
|
41548
41345
|
});
|
|
41549
41346
|
});
|
|
41550
|
-
deleteNativeSession = async (options, nativeSessionId) => this.#operations.run(options, async (options2) => {
|
|
41551
|
-
return await this.#queryProcesses.use(options2, async (runtime) => {
|
|
41552
|
-
const key = `${options2.agent.id}:${nativeSessionId}`;
|
|
41553
|
-
const linked = this.#store.findNative(options2.agent.id, nativeSessionId);
|
|
41554
|
-
if (this.#nativeOperations.has(key) || linked.some(
|
|
41555
|
-
(entry) => this.#executions.command(entry.sessionId) !== void 0 || this.#executionProcesses.pending(entry.sessionId) !== void 0
|
|
41556
|
-
)) {
|
|
41557
|
-
throw new AcpExecutionError(
|
|
41558
|
-
"Wait for the native session's running operation to finish",
|
|
41559
|
-
{},
|
|
41560
|
-
"session_busy"
|
|
41561
|
-
);
|
|
41562
|
-
}
|
|
41563
|
-
this.#nativeOperations.add(key);
|
|
41564
|
-
try {
|
|
41565
|
-
for (const entry of linked) {
|
|
41566
|
-
const active = this.#executionProcesses.get(entry.sessionId);
|
|
41567
|
-
if (active !== void 0 && active !== runtime) {
|
|
41568
|
-
await this.#retireSessionProcess(entry.sessionId, active, async () => await active.close());
|
|
41569
|
-
}
|
|
41570
|
-
}
|
|
41571
|
-
options2.signal.throwIfAborted();
|
|
41572
|
-
await runtime.deleteNativeSession(nativeSessionId, options2.signal);
|
|
41573
|
-
const deleted = this.#store.markDeleted(options2.agent.id, nativeSessionId);
|
|
41574
|
-
if (runtime.nativeSessionId() === nativeSessionId) {
|
|
41575
|
-
await this.#queryProcesses.retire(options2.sessionId, runtime);
|
|
41576
|
-
}
|
|
41577
|
-
return deleted;
|
|
41578
|
-
} finally {
|
|
41579
|
-
this.#nativeOperations.delete(key);
|
|
41580
|
-
this.#processes.notifyChanged();
|
|
41581
|
-
}
|
|
41582
|
-
});
|
|
41583
|
-
});
|
|
41584
41347
|
};
|
|
41585
41348
|
|
|
41586
41349
|
// src/agent-catalog/publish-agent-catalog.ts
|
|
@@ -43954,7 +43717,6 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
43954
43717
|
child2.removeListener("exit", onExit);
|
|
43955
43718
|
}
|
|
43956
43719
|
}
|
|
43957
|
-
var readCodexHistory = async (agent, cwd, nativeSessionId, signal) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, { detail: "messages" });
|
|
43958
43720
|
var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTurn) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, {
|
|
43959
43721
|
detail: "rich",
|
|
43960
43722
|
...nativeTurn === void 0 ? {} : { nativeTurn }
|
|
@@ -43962,85 +43724,6 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
|
|
|
43962
43724
|
|
|
43963
43725
|
// src/native-sessions/service.ts
|
|
43964
43726
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
43965
|
-
import { basename as basename5 } from "node:path";
|
|
43966
|
-
|
|
43967
|
-
// src/native-sessions/acp-history.ts
|
|
43968
|
-
async function readAcpHistory(sessions, directories, bindingId, options, nativeSessionId) {
|
|
43969
|
-
let cursor = null;
|
|
43970
|
-
let inspected = 0;
|
|
43971
|
-
for (let pageNumber = 0; pageNumber < 500 && inspected < 500; pageNumber += 1) {
|
|
43972
|
-
const page = await sessions.listNativeSessions(options, cursor);
|
|
43973
|
-
inspected += page.sessions.length;
|
|
43974
|
-
const found = page.sessions.find((entry) => entry.sessionId === nativeSessionId);
|
|
43975
|
-
if (found !== void 0) {
|
|
43976
|
-
const primary = await directories.identify(bindingId, found.cwd, options.signal);
|
|
43977
|
-
const additional = await Promise.all(
|
|
43978
|
-
found.additionalDirectories.map(
|
|
43979
|
-
async (directory) => await directories.identify(bindingId, directory, options.signal)
|
|
43980
|
-
)
|
|
43981
|
-
);
|
|
43982
|
-
if (primary.path !== options.cwd || additional.length !== options.additionalDirectories.length || additional.some((directory, index) => directory.path !== options.additionalDirectories[index])) {
|
|
43983
|
-
throw new AcpExecutionError(
|
|
43984
|
-
"The native Session belongs to another workspace.",
|
|
43985
|
-
{},
|
|
43986
|
-
"session_identity_mismatch"
|
|
43987
|
-
);
|
|
43988
|
-
}
|
|
43989
|
-
return await sessions.previewNativeSession(options, nativeSessionId);
|
|
43990
|
-
}
|
|
43991
|
-
if (page.nextCursor === null || page.nextCursor === cursor) {
|
|
43992
|
-
break;
|
|
43993
|
-
}
|
|
43994
|
-
cursor = page.nextCursor ?? null;
|
|
43995
|
-
}
|
|
43996
|
-
throw new AcpExecutionError("The native Session was not found.", {}, "native_session_not_found");
|
|
43997
|
-
}
|
|
43998
|
-
|
|
43999
|
-
// src/native-sessions/acp-adapter.ts
|
|
44000
|
-
var acpSessionAdapter = {
|
|
44001
|
-
history: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
|
|
44002
|
-
preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
|
|
44003
|
-
};
|
|
44004
|
-
|
|
44005
|
-
// src/native-sessions/codex-adapter.ts
|
|
44006
|
-
async function verifiedHistory(context, full) {
|
|
44007
|
-
const { options, nativeSessionId, directories, bindingId } = context;
|
|
44008
|
-
const snapshot = full ? await readCodexFullHistory(options.agent, options.cwd, nativeSessionId, options.signal) : await readCodexHistory(options.agent, options.cwd, nativeSessionId, options.signal);
|
|
44009
|
-
const resolved = await directories.identify(bindingId, snapshot.cwd, options.signal);
|
|
44010
|
-
if (snapshot.nativeSessionId !== nativeSessionId || resolved.path !== options.cwd) {
|
|
44011
|
-
throw new AcpExecutionError(
|
|
44012
|
-
"Codex returned history for a different session or workspace.",
|
|
44013
|
-
{},
|
|
44014
|
-
"invalid_native_session_response"
|
|
44015
|
-
);
|
|
44016
|
-
}
|
|
44017
|
-
return snapshot.history;
|
|
44018
|
-
}
|
|
44019
|
-
var codexSessionAdapter = {
|
|
44020
|
-
history: async (context) => await verifiedHistory(context, true),
|
|
44021
|
-
// Codex enforces an exclusive writer per thread. Its read-only app-server
|
|
44022
|
-
// history path keeps externally owned conversations previewable.
|
|
44023
|
-
preview: async (context) => await verifiedHistory(context, false)
|
|
44024
|
-
};
|
|
44025
|
-
|
|
44026
|
-
// src/native-sessions/agent-adapter.ts
|
|
44027
|
-
var genericSessionAdapter = {
|
|
44028
|
-
history: async () => {
|
|
44029
|
-
throw new AcpExecutionError("Native history is unavailable for this Agent", {}, "native_session_unsupported");
|
|
44030
|
-
},
|
|
44031
|
-
preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
|
|
44032
|
-
};
|
|
44033
|
-
function nativeSessionAdapter(agentId) {
|
|
44034
|
-
if (agentId === "codex") {
|
|
44035
|
-
return codexSessionAdapter;
|
|
44036
|
-
}
|
|
44037
|
-
if (agentId === "claude" || agentId === "opencode" || agentId === "pi") {
|
|
44038
|
-
return acpSessionAdapter;
|
|
44039
|
-
}
|
|
44040
|
-
return genericSessionAdapter;
|
|
44041
|
-
}
|
|
44042
|
-
|
|
44043
|
-
// src/native-sessions/service.ts
|
|
44044
43727
|
var NativeSessionService = class {
|
|
44045
43728
|
#entries = /* @__PURE__ */ new Map();
|
|
44046
43729
|
#cursors = /* @__PURE__ */ new Map();
|
|
@@ -44084,83 +43767,6 @@ var NativeSessionService = class {
|
|
|
44084
43767
|
...await this.#activeTurn(command, options)
|
|
44085
43768
|
};
|
|
44086
43769
|
}
|
|
44087
|
-
if (command.action === "create") {
|
|
44088
|
-
if (!supportsNativeChat(options.agent.id)) {
|
|
44089
|
-
throw new AcpExecutionError(
|
|
44090
|
-
"Native session creation is unavailable for this Agent",
|
|
44091
|
-
{},
|
|
44092
|
-
"native_session_unsupported"
|
|
44093
|
-
);
|
|
44094
|
-
}
|
|
44095
|
-
const nativeSessionId = await this.#sessions.createNativeSession(options);
|
|
44096
|
-
signal.throwIfAborted();
|
|
44097
|
-
this.record(command, "native_session_created");
|
|
44098
|
-
return {
|
|
44099
|
-
action: "create",
|
|
44100
|
-
kind: "native.session.result",
|
|
44101
|
-
nativeSessionId: decodeIdentifier(nativeSessionId),
|
|
44102
|
-
requestId: command.requestId,
|
|
44103
|
-
sessionId: command.sessionId
|
|
44104
|
-
};
|
|
44105
|
-
}
|
|
44106
|
-
if (command.action === "fork-recorded") {
|
|
44107
|
-
const source = this.#sessions.findSessions([command.sessionId])[0];
|
|
44108
|
-
if (source === void 0 || !source.prompted) {
|
|
44109
|
-
throw new AcpExecutionError(
|
|
44110
|
-
"The source conversation has no resumable native Agent session",
|
|
44111
|
-
{},
|
|
44112
|
-
"native_session_not_found"
|
|
44113
|
-
);
|
|
44114
|
-
}
|
|
44115
|
-
if (source.agentId !== command.agentId || source.cwd !== cwd || source.additionalDirectories.length !== additionalDirectories.length || source.additionalDirectories.some((path3, index) => path3 !== additionalDirectories[index])) {
|
|
44116
|
-
throw new AcpExecutionError(
|
|
44117
|
-
"The source conversation execution target does not match the fork request",
|
|
44118
|
-
{},
|
|
44119
|
-
"native_session_target_changed"
|
|
44120
|
-
);
|
|
44121
|
-
}
|
|
44122
|
-
if (source.lastTerminalCommandId !== command.throughCommandId) {
|
|
44123
|
-
throw new AcpExecutionError(
|
|
44124
|
-
"The selected Turn is no longer the source conversation head",
|
|
44125
|
-
{},
|
|
44126
|
-
"fork_point_stale"
|
|
44127
|
-
);
|
|
44128
|
-
}
|
|
44129
|
-
const opened2 = await this.#sessions.openNativeSession(
|
|
44130
|
-
{ ...options, sessionId: command.targetSessionId },
|
|
44131
|
-
{ kind: "fork", nativeSessionId: source.nativeSessionId }
|
|
44132
|
-
);
|
|
44133
|
-
signal.throwIfAborted();
|
|
44134
|
-
const directory = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
|
|
44135
|
-
const ready2 = {
|
|
44136
|
-
additionalDirectories: additionalDirectories.map((path3, index) => ({
|
|
44137
|
-
directoryId: command.additionalDirectoryIds[index] ?? command.directoryId,
|
|
44138
|
-
name: basename5(path3) || path3
|
|
44139
|
-
})),
|
|
44140
|
-
agentId: command.agentId,
|
|
44141
|
-
agentName: opened2.prepared.agentName,
|
|
44142
|
-
agentVersion: opened2.prepared.agentVersion,
|
|
44143
|
-
capabilities: opened2.prepared.capabilities,
|
|
44144
|
-
commands: opened2.prepared.commands,
|
|
44145
|
-
configOptions: opened2.prepared.configOptions,
|
|
44146
|
-
directoryId: command.directoryId,
|
|
44147
|
-
directoryLabel: directory.directoryLabel,
|
|
44148
|
-
kind: "session.ready",
|
|
44149
|
-
requestId: command.requestId,
|
|
44150
|
-
restored: true,
|
|
44151
|
-
sessionId: opened2.sessionId
|
|
44152
|
-
};
|
|
44153
|
-
this.record(command, "native_recorded_session_forked");
|
|
44154
|
-
return {
|
|
44155
|
-
action: "fork-recorded",
|
|
44156
|
-
kind: "native.session.result",
|
|
44157
|
-
ready: ready2,
|
|
44158
|
-
requestId: command.requestId,
|
|
44159
|
-
sessionId: command.sessionId,
|
|
44160
|
-
targetSessionId: command.targetSessionId,
|
|
44161
|
-
title: source.title || "Untitled session"
|
|
44162
|
-
};
|
|
44163
|
-
}
|
|
44164
43770
|
const prepared = await this.#sessions.prepareNativeSessionBrowser(options);
|
|
44165
43771
|
if (!prepared.capabilities.listSessions) {
|
|
44166
43772
|
throw new AcpExecutionError(
|
|
@@ -44295,63 +43901,6 @@ var NativeSessionService = class {
|
|
|
44295
43901
|
);
|
|
44296
43902
|
}
|
|
44297
43903
|
const target = await this.resolveTarget(command, options, selected);
|
|
44298
|
-
if (command.action === "history") {
|
|
44299
|
-
const history = await nativeSessionAdapter(options.agent.id).history({
|
|
44300
|
-
sessions: this.#sessions,
|
|
44301
|
-
directories: this.#directories,
|
|
44302
|
-
bindingId: command.bindingId,
|
|
44303
|
-
options: { ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
44304
|
-
nativeSessionId: target.info.sessionId
|
|
44305
|
-
});
|
|
44306
|
-
signal.throwIfAborted();
|
|
44307
|
-
this.record(command, "native_session_history_read");
|
|
44308
|
-
return {
|
|
44309
|
-
...envelope2,
|
|
44310
|
-
action: "history",
|
|
44311
|
-
entryId: command.entryId,
|
|
44312
|
-
history,
|
|
44313
|
-
title: target.info.title ?? "Untitled session"
|
|
44314
|
-
};
|
|
44315
|
-
}
|
|
44316
|
-
if (command.action === "preview") {
|
|
44317
|
-
const history = await nativeSessionAdapter(options.agent.id).preview({
|
|
44318
|
-
sessions: this.#sessions,
|
|
44319
|
-
directories: this.#directories,
|
|
44320
|
-
bindingId: command.bindingId,
|
|
44321
|
-
options: { ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
44322
|
-
nativeSessionId: target.info.sessionId
|
|
44323
|
-
});
|
|
44324
|
-
signal.throwIfAborted();
|
|
44325
|
-
this.record(command, "native_session_previewed");
|
|
44326
|
-
return {
|
|
44327
|
-
...envelope2,
|
|
44328
|
-
action: "preview",
|
|
44329
|
-
entryId: command.entryId,
|
|
44330
|
-
targetSessionId: command.sessionId,
|
|
44331
|
-
reason: "requested",
|
|
44332
|
-
title: target.info.title ?? "Untitled session",
|
|
44333
|
-
history
|
|
44334
|
-
};
|
|
44335
|
-
}
|
|
44336
|
-
if (command.action === "delete") {
|
|
44337
|
-
if (!prepared.capabilities.deleteSession) {
|
|
44338
|
-
throw new AcpExecutionError(
|
|
44339
|
-
"This Agent does not support native session deletion",
|
|
44340
|
-
{},
|
|
44341
|
-
"native_session_unsupported"
|
|
44342
|
-
);
|
|
44343
|
-
}
|
|
44344
|
-
signal.throwIfAborted();
|
|
44345
|
-
this.record(command, "native_session_delete_authorized");
|
|
44346
|
-
const deletedSessionIds = await this.#sessions.deleteNativeSession(options, target.info.sessionId);
|
|
44347
|
-
this.record(command, "native_session_deleted");
|
|
44348
|
-
return {
|
|
44349
|
-
...envelope2,
|
|
44350
|
-
action: "delete",
|
|
44351
|
-
entryId: command.entryId,
|
|
44352
|
-
deletedSessionIds: deletedSessionIds.map(decodeIdentifier)
|
|
44353
|
-
};
|
|
44354
|
-
}
|
|
44355
43904
|
const action = command.action;
|
|
44356
43905
|
if (action === "import" && !prepared.capabilities.loadSession && !prepared.capabilities.resumeSession) {
|
|
44357
43906
|
throw new AcpExecutionError("This Agent cannot import native sessions", {}, "native_session_unsupported");
|
|
@@ -44736,135 +44285,13 @@ var RelayConnectionDiagnostics = class {
|
|
|
44736
44285
|
};
|
|
44737
44286
|
|
|
44738
44287
|
// src/relay-connection/run-relay-connection.ts
|
|
44739
|
-
import { WebSocket as
|
|
44288
|
+
import { WebSocket as WebSocket7 } from "undici";
|
|
44740
44289
|
|
|
44741
44290
|
// src/daemon-command-handler.ts
|
|
44742
|
-
import { WebSocket as
|
|
44743
|
-
|
|
44744
|
-
// src/agent-catalog/handle-agent-catalog-refresh.ts
|
|
44745
|
-
import { WebSocket as WebSocket3 } from "undici";
|
|
44746
|
-
async function retainStillInstalledAgents(previous, refreshed, signal) {
|
|
44747
|
-
const refreshedIdentifiers = new Set(refreshed.map((agent) => agent.id));
|
|
44748
|
-
const retained = [];
|
|
44749
|
-
for (const agent of previous) {
|
|
44750
|
-
if (refreshedIdentifiers.has(agent.id)) {
|
|
44751
|
-
continue;
|
|
44752
|
-
}
|
|
44753
|
-
signal.throwIfAborted();
|
|
44754
|
-
if (await revalidateExecutable(agent.agentIdentity)) {
|
|
44755
|
-
retained.push(agent);
|
|
44756
|
-
}
|
|
44757
|
-
}
|
|
44758
|
-
return Object.freeze([...refreshed, ...retained]);
|
|
44759
|
-
}
|
|
44760
|
-
async function refreshAgentCatalog(config2, resolveEnvironment, signal) {
|
|
44761
|
-
signal.throwIfAborted();
|
|
44762
|
-
const shellEnvironment = await resolveEnvironment(signal);
|
|
44763
|
-
const environment = new DaemonLocalContext(config2.localContext.stateDirectory, shellEnvironment).environment;
|
|
44764
|
-
signal.throwIfAborted();
|
|
44765
|
-
const inventory = await discoverLocalAgentInventory({
|
|
44766
|
-
defaultWorkspace: config2.defaultWorkspace,
|
|
44767
|
-
environment,
|
|
44768
|
-
signal
|
|
44769
|
-
});
|
|
44770
|
-
const previousCatalog = config2.catalog.read();
|
|
44771
|
-
const refreshedAgents = inventory.readyAgents().map((agent) => withDaemonEnvironment(agent, environment));
|
|
44772
|
-
const agents = await retainStillInstalledAgents(previousCatalog.agents, refreshedAgents, signal);
|
|
44773
|
-
const verifiedIdentifiers = new Set(agents.map((agent) => agent.id));
|
|
44774
|
-
config2.catalog.transition(
|
|
44775
|
-
agents,
|
|
44776
|
-
inventory.installable.filter((agent) => !verifiedIdentifiers.has(agent.id))
|
|
44777
|
-
);
|
|
44778
|
-
try {
|
|
44779
|
-
await publishAgentCatalog(config2, signal);
|
|
44780
|
-
} catch (error62) {
|
|
44781
|
-
config2.catalog.transition(previousCatalog.agents, previousCatalog.installableAgents);
|
|
44782
|
-
throw error62;
|
|
44783
|
-
}
|
|
44784
|
-
}
|
|
44785
|
-
function createAgentCatalogRefreshHandler(dependencies) {
|
|
44786
|
-
const { config: config2, audit, diagnostics, socket, signal, timer, resolveEnvironment } = dependencies;
|
|
44787
|
-
const agentCatalogRefreshes = /* @__PURE__ */ new Map();
|
|
44788
|
-
const handle = (command) => {
|
|
44789
|
-
if (agentCatalogRefreshes.has(command.requestId) || agentCatalogRefreshes.size > 0) {
|
|
44790
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
44791
|
-
send(socket, {
|
|
44792
|
-
code: "agent_catalog_refresh_busy",
|
|
44793
|
-
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
44794
|
-
message: "Another local Agent catalog refresh is already running",
|
|
44795
|
-
requestId: command.requestId
|
|
44796
|
-
});
|
|
44797
|
-
}
|
|
44798
|
-
return;
|
|
44799
|
-
}
|
|
44800
|
-
const controller = new AbortController();
|
|
44801
|
-
const operationSignal = AbortSignal.any([signal, controller.signal]);
|
|
44802
|
-
const timeout = timer.schedule(
|
|
44803
|
-
() => controller.abort(
|
|
44804
|
-
new AcpExecutionError(
|
|
44805
|
-
"The local Agent catalog refresh timed out",
|
|
44806
|
-
{},
|
|
44807
|
-
"agent_catalog_refresh_timeout"
|
|
44808
|
-
)
|
|
44809
|
-
),
|
|
44810
|
-
9e4
|
|
44811
|
-
);
|
|
44812
|
-
const completion = (async () => {
|
|
44813
|
-
try {
|
|
44814
|
-
await refreshAgentCatalog(config2, resolveEnvironment, operationSignal);
|
|
44815
|
-
audit.record({
|
|
44816
|
-
commandId: command.requestId,
|
|
44817
|
-
event: "agent_catalog_refreshed",
|
|
44818
|
-
sessionId: "agent-catalog"
|
|
44819
|
-
});
|
|
44820
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
44821
|
-
send(socket, {
|
|
44822
|
-
kind: AGENT_CATALOG_REFRESHED_KIND,
|
|
44823
|
-
requestId: command.requestId
|
|
44824
|
-
});
|
|
44825
|
-
}
|
|
44826
|
-
} catch (error62) {
|
|
44827
|
-
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
44828
|
-
"The local Agent catalog refresh was cancelled",
|
|
44829
|
-
{},
|
|
44830
|
-
"agent_catalog_refresh_cancelled"
|
|
44831
|
-
) : error62;
|
|
44832
|
-
audit.record({
|
|
44833
|
-
commandId: command.requestId,
|
|
44834
|
-
details: { code: operationErrorCode(failure2) },
|
|
44835
|
-
event: "agent_catalog_refresh_failed",
|
|
44836
|
-
sessionId: "agent-catalog"
|
|
44837
|
-
});
|
|
44838
|
-
diagnostics.daemonDiagnostic(
|
|
44839
|
-
"agent_catalog_refresh_failed",
|
|
44840
|
-
command.requestId,
|
|
44841
|
-
{ code: operationErrorCode(failure2) },
|
|
44842
|
-
failure2
|
|
44843
|
-
);
|
|
44844
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
44845
|
-
send(socket, {
|
|
44846
|
-
code: operationErrorCode(failure2),
|
|
44847
|
-
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
44848
|
-
message: operationErrorMessage(failure2),
|
|
44849
|
-
requestId: command.requestId
|
|
44850
|
-
});
|
|
44851
|
-
}
|
|
44852
|
-
} finally {
|
|
44853
|
-
timeout.cancel();
|
|
44854
|
-
agentCatalogRefreshes.delete(command.requestId);
|
|
44855
|
-
}
|
|
44856
|
-
})();
|
|
44857
|
-
agentCatalogRefreshes.set(command.requestId, { completion, controller });
|
|
44858
|
-
return;
|
|
44859
|
-
};
|
|
44860
|
-
const settle2 = async () => {
|
|
44861
|
-
await Promise.all([...agentCatalogRefreshes.values()].map((request) => request.completion));
|
|
44862
|
-
};
|
|
44863
|
-
return { handle, settle: settle2 };
|
|
44864
|
-
}
|
|
44291
|
+
import { WebSocket as WebSocket5 } from "undici";
|
|
44865
44292
|
|
|
44866
44293
|
// src/agent-catalog/handle-agent-settings-discovery.ts
|
|
44867
|
-
import { WebSocket as
|
|
44294
|
+
import { WebSocket as WebSocket3 } from "undici";
|
|
44868
44295
|
|
|
44869
44296
|
// src/agent-catalog/discover-agent-settings.ts
|
|
44870
44297
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -45352,7 +44779,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45352
44779
|
(request) => request.agentId === command.agentId && !request.controller.signal.aborted
|
|
45353
44780
|
);
|
|
45354
44781
|
if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
|
|
45355
|
-
if (socket.readyState ===
|
|
44782
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45356
44783
|
send(socket, {
|
|
45357
44784
|
code: "agent_settings_discovery_busy",
|
|
45358
44785
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -45367,7 +44794,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45367
44794
|
return;
|
|
45368
44795
|
}
|
|
45369
44796
|
if (existing !== void 0) {
|
|
45370
|
-
if (socket.readyState ===
|
|
44797
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45371
44798
|
send(socket, {
|
|
45372
44799
|
code: "agent_settings_discovery_busy",
|
|
45373
44800
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -45378,7 +44805,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45378
44805
|
return;
|
|
45379
44806
|
}
|
|
45380
44807
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
45381
|
-
if (socket.readyState ===
|
|
44808
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45382
44809
|
send(socket, {
|
|
45383
44810
|
code: "agent_settings_discovery_busy",
|
|
45384
44811
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -45424,7 +44851,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45424
44851
|
event: "agent_settings_discovered",
|
|
45425
44852
|
sessionId: `agent-settings:${command.agentId}`
|
|
45426
44853
|
});
|
|
45427
|
-
if (socket.readyState ===
|
|
44854
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45428
44855
|
send(socket, { ...result.event, requestId });
|
|
45429
44856
|
}
|
|
45430
44857
|
}
|
|
@@ -45450,7 +44877,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45450
44877
|
`
|
|
45451
44878
|
);
|
|
45452
44879
|
}
|
|
45453
|
-
if (socket.readyState ===
|
|
44880
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45454
44881
|
for (const requestId of requestIds) {
|
|
45455
44882
|
send(socket, {
|
|
45456
44883
|
code: operationErrorCode(failure2),
|
|
@@ -45483,7 +44910,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45483
44910
|
// src/artifacts/local-file-streamer.ts
|
|
45484
44911
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
45485
44912
|
import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
|
|
45486
|
-
import { basename as
|
|
44913
|
+
import { basename as basename5, isAbsolute as isAbsolute10, normalize as normalize4, resolve as resolve7 } from "node:path";
|
|
45487
44914
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
45488
44915
|
var CHUNK_BYTES = 192 * 1024;
|
|
45489
44916
|
function requestedPath(value) {
|
|
@@ -45535,7 +44962,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
45535
44962
|
kind: FILE_BEGIN_KIND,
|
|
45536
44963
|
mediaType: external?.mediaType ?? raster?.mimeType ?? "application/octet-stream",
|
|
45537
44964
|
modifiedAt: before.mtime.toISOString(),
|
|
45538
|
-
name: external?.name ?? (
|
|
44965
|
+
name: external?.name ?? (basename5(target) || "file"),
|
|
45539
44966
|
requestId: command.requestId,
|
|
45540
44967
|
sessionId: command.sessionId
|
|
45541
44968
|
});
|
|
@@ -45565,7 +44992,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
45565
44992
|
}
|
|
45566
44993
|
|
|
45567
44994
|
// src/authorization/resolve-session-directories.ts
|
|
45568
|
-
import { basename as
|
|
44995
|
+
import { basename as basename6 } from "node:path";
|
|
45569
44996
|
var ResolvedSessionDirectories = class {
|
|
45570
44997
|
additionalDirectories;
|
|
45571
44998
|
additionalDirectoryEntries;
|
|
@@ -45590,306 +45017,13 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
45590
45017
|
additionalDirectories.push(directory);
|
|
45591
45018
|
additionalDirectoryEntries.push({
|
|
45592
45019
|
directoryId: additionalDirectoryId,
|
|
45593
|
-
name:
|
|
45020
|
+
name: basename6(directory)
|
|
45594
45021
|
});
|
|
45595
45022
|
}
|
|
45596
45023
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
45597
45024
|
}
|
|
45598
45025
|
|
|
45599
|
-
// src/native-sessions/live-history-page.ts
|
|
45600
|
-
function encodeLiveHistoryCursor(cursor) {
|
|
45601
|
-
return Buffer.from(JSON.stringify(cursor), "utf8").toString("base64url");
|
|
45602
|
-
}
|
|
45603
|
-
function decodeLiveHistoryCursor(cursor, sessionId) {
|
|
45604
|
-
try {
|
|
45605
|
-
if (!/^[A-Za-z0-9_-]{1,512}$/u.test(cursor)) {
|
|
45606
|
-
throw new Error("Invalid cursor alphabet");
|
|
45607
|
-
}
|
|
45608
|
-
const value = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
45609
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
45610
|
-
throw new Error("Invalid cursor shape");
|
|
45611
|
-
}
|
|
45612
|
-
const record2 = Object.fromEntries(Object.entries(value));
|
|
45613
|
-
const keys = Object.keys(record2).sort().join(",");
|
|
45614
|
-
const legacyNative = keys === "endIndex,sessionId";
|
|
45615
|
-
const kind = legacyNative ? "native" : record2["kind"];
|
|
45616
|
-
if (keys !== "endIndex,kind,sessionId" && keys !== "endIndex,epoch,kind,sessionId" && !legacyNative || record2["sessionId"] !== sessionId || kind !== "active" && kind !== "native" || typeof record2["endIndex"] !== "number" || !Number.isSafeInteger(record2["endIndex"]) || record2["endIndex"] < 0) {
|
|
45617
|
-
throw new Error("Invalid cursor target");
|
|
45618
|
-
}
|
|
45619
|
-
if (kind === "active") {
|
|
45620
|
-
if (keys !== "endIndex,epoch,kind,sessionId" || typeof record2["epoch"] !== "string") {
|
|
45621
|
-
throw new Error("Invalid active cursor target");
|
|
45622
|
-
}
|
|
45623
|
-
return { endIndex: record2["endIndex"], epoch: record2["epoch"], kind, sessionId };
|
|
45624
|
-
}
|
|
45625
|
-
if (keys !== "endIndex,kind,sessionId" && !legacyNative) {
|
|
45626
|
-
throw new Error("Invalid native cursor target");
|
|
45627
|
-
}
|
|
45628
|
-
return { endIndex: record2["endIndex"], kind, sessionId };
|
|
45629
|
-
} catch (cause) {
|
|
45630
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", { cause }, "invalid_cursor");
|
|
45631
|
-
}
|
|
45632
|
-
}
|
|
45633
|
-
function activeHistoryCursor(sessionId, epoch, endIndex) {
|
|
45634
|
-
return encodeLiveHistoryCursor({ endIndex, epoch, kind: "active", sessionId });
|
|
45635
|
-
}
|
|
45636
|
-
function nativeHistoryCursor(sessionId, endIndex) {
|
|
45637
|
-
return encodeLiveHistoryCursor({ endIndex, kind: "native", sessionId });
|
|
45638
|
-
}
|
|
45639
|
-
function liveHistoryCoveredTurnRanges(history) {
|
|
45640
|
-
const ranges = [];
|
|
45641
|
-
let historyIndex = history.messages.length;
|
|
45642
|
-
for (const commandId of history.coveredCommandIds) {
|
|
45643
|
-
let assistantStartIndex = historyIndex;
|
|
45644
|
-
while (assistantStartIndex > 0 && history.messages[assistantStartIndex - 1]?.role === "assistant") {
|
|
45645
|
-
assistantStartIndex -= 1;
|
|
45646
|
-
}
|
|
45647
|
-
const userIndex = assistantStartIndex - 1;
|
|
45648
|
-
if (assistantStartIndex === historyIndex || history.messages[userIndex]?.role !== "user") {
|
|
45649
|
-
break;
|
|
45650
|
-
}
|
|
45651
|
-
ranges.push({ assistantEndIndex: historyIndex, assistantStartIndex, commandId, userIndex });
|
|
45652
|
-
historyIndex = userIndex;
|
|
45653
|
-
}
|
|
45654
|
-
return ranges;
|
|
45655
|
-
}
|
|
45656
|
-
function historyMessageCharacters(message) {
|
|
45657
|
-
return message.text.length + (message.role === "assistant" ? JSON.stringify(message.activities).length + JSON.stringify(message.content).length : 0);
|
|
45658
|
-
}
|
|
45659
|
-
function isNativeHistoryImageMimeType(mimeType) {
|
|
45660
|
-
return mimeType === "image/png" || mimeType === "image/jpeg" || mimeType === "image/gif" || mimeType === "image/webp";
|
|
45661
|
-
}
|
|
45662
|
-
function selectMessagesBefore(messages, endIndex, messageLimit, characterLimit) {
|
|
45663
|
-
const selected = [];
|
|
45664
|
-
let remainingCharacters = characterLimit;
|
|
45665
|
-
let startIndex = endIndex;
|
|
45666
|
-
for (let index = endIndex - 1; index >= 0 && selected.length < messageLimit; index -= 1) {
|
|
45667
|
-
const message = messages[index];
|
|
45668
|
-
if (message === void 0) {
|
|
45669
|
-
break;
|
|
45670
|
-
}
|
|
45671
|
-
const characters = historyMessageCharacters(message);
|
|
45672
|
-
if (characters > remainingCharacters) {
|
|
45673
|
-
break;
|
|
45674
|
-
}
|
|
45675
|
-
selected.unshift(message);
|
|
45676
|
-
remainingCharacters -= characters;
|
|
45677
|
-
startIndex = index;
|
|
45678
|
-
}
|
|
45679
|
-
if (selected.length === 0 && endIndex > 0) {
|
|
45680
|
-
throw new AcpExecutionError(
|
|
45681
|
-
"A native Session history item exceeds the page budget",
|
|
45682
|
-
{},
|
|
45683
|
-
"history_item_too_large"
|
|
45684
|
-
);
|
|
45685
|
-
}
|
|
45686
|
-
return { characters: characterLimit - remainingCharacters, messages: selected, startIndex };
|
|
45687
|
-
}
|
|
45688
|
-
function nativeActiveMessage(message) {
|
|
45689
|
-
if (message.role === "assistant") {
|
|
45690
|
-
return {
|
|
45691
|
-
activities: message.activities,
|
|
45692
|
-
content: message.content,
|
|
45693
|
-
role: "assistant",
|
|
45694
|
-
text: message.text
|
|
45695
|
-
};
|
|
45696
|
-
}
|
|
45697
|
-
const images = (message.images ?? []).flatMap((image) => {
|
|
45698
|
-
if (image.data.length < 4 || image.data.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/u.test(image.data) || !isNativeHistoryImageMimeType(image.mimeType)) {
|
|
45699
|
-
return [];
|
|
45700
|
-
}
|
|
45701
|
-
return [{ data: image.data, mimeType: image.mimeType, name: image.name }];
|
|
45702
|
-
});
|
|
45703
|
-
return { ...images.length === 0 ? {} : { images }, role: "user", text: message.text };
|
|
45704
|
-
}
|
|
45705
|
-
function nativeHistoryCoversCompletedRecovery(history, recovery) {
|
|
45706
|
-
const root = recovery.messages.find((message) => message.role === "user" && message.id === recovery.commandId);
|
|
45707
|
-
if (root === void 0) {
|
|
45708
|
-
return false;
|
|
45709
|
-
}
|
|
45710
|
-
const rootIndex = history.messages.findLastIndex(
|
|
45711
|
-
(message) => message.role === "user" && message.text === root.text
|
|
45712
|
-
);
|
|
45713
|
-
if (rootIndex < 0) {
|
|
45714
|
-
return false;
|
|
45715
|
-
}
|
|
45716
|
-
const nativeAssistant = history.messages.slice(rootIndex + 1).filter((message) => message.role === "assistant");
|
|
45717
|
-
if (nativeAssistant.length === 0) {
|
|
45718
|
-
return false;
|
|
45719
|
-
}
|
|
45720
|
-
const recoveryAssistant = recovery.messages.filter((message) => message.role === "assistant");
|
|
45721
|
-
const recoveryText = recoveryAssistant.map((message) => message.text).join("");
|
|
45722
|
-
const nativeText = nativeAssistant.map((message) => message.text).join("");
|
|
45723
|
-
if (recoveryText.length > 0 && !nativeText.includes(recoveryText)) {
|
|
45724
|
-
return false;
|
|
45725
|
-
}
|
|
45726
|
-
const nativeContent = new Set(
|
|
45727
|
-
nativeAssistant.flatMap((message) => message.content).map((content) => JSON.stringify(content))
|
|
45728
|
-
);
|
|
45729
|
-
return recoveryAssistant.flatMap((message) => message.content).every((content) => nativeContent.has(JSON.stringify(content)));
|
|
45730
|
-
}
|
|
45731
|
-
function historyBeforeActiveTurn(history, activeTurn) {
|
|
45732
|
-
if (history.status === "unavailable") {
|
|
45733
|
-
return history;
|
|
45734
|
-
}
|
|
45735
|
-
const activeRoot = activeTurn.messages.find(
|
|
45736
|
-
(message) => message.role === "user" && message.id === activeTurn.commandId
|
|
45737
|
-
);
|
|
45738
|
-
const matchingActiveUserIndex = activeRoot === void 0 ? -1 : activeTurn.state === "completed" || history.messages.at(-1)?.role === "user" && history.messages.at(-1)?.text === activeRoot.text || history.coveredCommandIds.includes(activeTurn.commandId) ? history.messages.findLastIndex((message) => message.role === "user" && message.text === activeRoot.text) : -1;
|
|
45739
|
-
const activeUserIndex = matchingActiveUserIndex >= 0 ? matchingActiveUserIndex : liveHistoryCoveredTurnRanges(history).find((range) => range.commandId === activeTurn.commandId)?.userIndex ?? -1;
|
|
45740
|
-
if (activeUserIndex < 0) {
|
|
45741
|
-
return history;
|
|
45742
|
-
}
|
|
45743
|
-
return {
|
|
45744
|
-
...history,
|
|
45745
|
-
coveredCommandIds: history.coveredCommandIds.filter((id) => id !== activeTurn.commandId),
|
|
45746
|
-
coveredMessageIds: history.coveredMessageIds.filter(
|
|
45747
|
-
(id) => id !== `${activeTurn.commandId}:user` && id !== `${activeTurn.commandId}:agent`
|
|
45748
|
-
),
|
|
45749
|
-
messages: history.messages.slice(0, activeUserIndex)
|
|
45750
|
-
};
|
|
45751
|
-
}
|
|
45752
|
-
function paginateAvailableNativeHistory(history, sessionId, endIndex, limit, characterLimit) {
|
|
45753
|
-
if (endIndex > history.messages.length) {
|
|
45754
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
45755
|
-
}
|
|
45756
|
-
const selected = selectMessagesBefore(history.messages, endIndex, limit, characterLimit);
|
|
45757
|
-
const coveredMessageIds = new Set(history.coveredMessageIds);
|
|
45758
|
-
const ranges = liveHistoryCoveredTurnRanges(history);
|
|
45759
|
-
return {
|
|
45760
|
-
coveredCommandIds: ranges.filter((range) => range.userIndex >= selected.startIndex && range.assistantEndIndex <= endIndex).map((range) => range.commandId),
|
|
45761
|
-
coveredMessageIds: ranges.flatMap((range) => [
|
|
45762
|
-
...range.userIndex >= selected.startIndex && range.userIndex < endIndex && coveredMessageIds.has(`${range.commandId}:user`) ? [`${range.commandId}:user`] : [],
|
|
45763
|
-
...range.assistantStartIndex >= selected.startIndex && range.assistantEndIndex <= endIndex && coveredMessageIds.has(`${range.commandId}:agent`) ? [`${range.commandId}:agent`] : []
|
|
45764
|
-
]),
|
|
45765
|
-
messages: selected.messages,
|
|
45766
|
-
nextCursor: selected.startIndex > 0 ? nativeHistoryCursor(sessionId, selected.startIndex) : null,
|
|
45767
|
-
status: "available",
|
|
45768
|
-
truncated: history.truncated
|
|
45769
|
-
};
|
|
45770
|
-
}
|
|
45771
|
-
function paginateNativeHistory(history, sessionId, cursor, limit) {
|
|
45772
|
-
if (cursor?.kind === "active") {
|
|
45773
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
45774
|
-
}
|
|
45775
|
-
if (history.status === "unavailable") {
|
|
45776
|
-
if (cursor !== null) {
|
|
45777
|
-
throw new AcpExecutionError("Unavailable native Session history has no cursor", {}, "invalid_cursor");
|
|
45778
|
-
}
|
|
45779
|
-
return { cause: history.cause, nextCursor: null, status: "unavailable" };
|
|
45780
|
-
}
|
|
45781
|
-
return paginateAvailableNativeHistory(
|
|
45782
|
-
history,
|
|
45783
|
-
sessionId,
|
|
45784
|
-
cursor?.endIndex ?? history.messages.length,
|
|
45785
|
-
limit,
|
|
45786
|
-
SESSION_HISTORY_CHARACTER_LIMIT
|
|
45787
|
-
);
|
|
45788
|
-
}
|
|
45789
|
-
function paginateActiveTurn(history, activeTurn, sessionId, endIndex, limit) {
|
|
45790
|
-
if (endIndex > activeTurn.messages.length) {
|
|
45791
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
45792
|
-
}
|
|
45793
|
-
const activeMessages = activeTurn.messages.map(nativeActiveMessage);
|
|
45794
|
-
const active = selectMessagesBefore(activeMessages, endIndex, limit, SESSION_HISTORY_CHARACTER_LIMIT);
|
|
45795
|
-
const historicalLimit = limit - active.messages.length;
|
|
45796
|
-
const historicalCharacterLimit = SESSION_HISTORY_CHARACTER_LIMIT - active.characters;
|
|
45797
|
-
const pendingHistoricalCursor = history.status === "available" && history.messages.length > 0 ? nativeHistoryCursor(sessionId, history.messages.length) : null;
|
|
45798
|
-
const latestHistoricalMessage = history.status === "available" ? history.messages.at(-1) : void 0;
|
|
45799
|
-
const historicalPageFits = latestHistoricalMessage === void 0 || historyMessageCharacters(latestHistoricalMessage) <= historicalCharacterLimit;
|
|
45800
|
-
const historical = active.startIndex === 0 && history.status === "available" && historicalLimit > 0 && historicalPageFits ? paginateAvailableNativeHistory(
|
|
45801
|
-
history,
|
|
45802
|
-
sessionId,
|
|
45803
|
-
history.messages.length,
|
|
45804
|
-
historicalLimit,
|
|
45805
|
-
historicalCharacterLimit
|
|
45806
|
-
) : null;
|
|
45807
|
-
return {
|
|
45808
|
-
streamPosition: { commandId: activeTurn.commandId, epoch: activeTurn.epoch, sequence: activeTurn.sequence },
|
|
45809
|
-
coveredCommandIds: historical?.coveredCommandIds ?? [],
|
|
45810
|
-
coveredMessageIds: [
|
|
45811
|
-
...historical?.coveredMessageIds ?? [],
|
|
45812
|
-
...active.startIndex === 0 ? [`${activeTurn.commandId}:user`, `${activeTurn.commandId}:agent`] : []
|
|
45813
|
-
],
|
|
45814
|
-
messages: [...historical?.messages ?? [], ...active.messages],
|
|
45815
|
-
nextCursor: active.startIndex > 0 ? activeHistoryCursor(sessionId, activeTurn.epoch, active.startIndex) : historical === null ? pendingHistoricalCursor : historical.nextCursor,
|
|
45816
|
-
status: "available",
|
|
45817
|
-
truncated: activeTurn.truncated || (historical?.truncated ?? false)
|
|
45818
|
-
};
|
|
45819
|
-
}
|
|
45820
|
-
function paginateLiveSessionHistory(history, activeTurn, sessionId, encodedCursor, limit) {
|
|
45821
|
-
const cursor = encodedCursor === null ? null : decodeLiveHistoryCursor(encodedCursor, sessionId);
|
|
45822
|
-
if (activeTurn === null || activeTurn.state === "completed" && history.status === "available" && nativeHistoryCoversCompletedRecovery(history, activeTurn)) {
|
|
45823
|
-
return paginateNativeHistory(history, sessionId, cursor, limit);
|
|
45824
|
-
}
|
|
45825
|
-
const historical = historyBeforeActiveTurn(history, activeTurn);
|
|
45826
|
-
if (cursor?.kind === "native") {
|
|
45827
|
-
return paginateNativeHistory(historical, sessionId, cursor, limit);
|
|
45828
|
-
}
|
|
45829
|
-
if (cursor !== null && cursor.epoch !== activeTurn.epoch) {
|
|
45830
|
-
throw new AcpExecutionError("The active Turn history cursor is stale", {}, "stale_cursor");
|
|
45831
|
-
}
|
|
45832
|
-
return paginateActiveTurn(historical, activeTurn, sessionId, cursor?.endIndex ?? activeTurn.messages.length, limit);
|
|
45833
|
-
}
|
|
45834
|
-
|
|
45835
45026
|
// src/daemon-history-commands.ts
|
|
45836
|
-
async function executeSessionLiveHistoryPageLoad(socket, command, config2, directories, audit, sessions, activeTurn, signal) {
|
|
45837
|
-
try {
|
|
45838
|
-
const resolved = await resolveSessionDirectories(
|
|
45839
|
-
directories,
|
|
45840
|
-
config2.bindingId,
|
|
45841
|
-
command.directoryId,
|
|
45842
|
-
command.additionalDirectoryIds,
|
|
45843
|
-
signal
|
|
45844
|
-
);
|
|
45845
|
-
const history = await sessions.loadSessionHistory({
|
|
45846
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
45847
|
-
agent: config2.catalog.find(command.agentId),
|
|
45848
|
-
cwd: resolved.cwd,
|
|
45849
|
-
sessionId: command.sessionId,
|
|
45850
|
-
signal
|
|
45851
|
-
});
|
|
45852
|
-
signal.throwIfAborted();
|
|
45853
|
-
const page = paginateLiveSessionHistory(
|
|
45854
|
-
history,
|
|
45855
|
-
activeTurn(command.sessionId),
|
|
45856
|
-
command.sessionId,
|
|
45857
|
-
command.cursor,
|
|
45858
|
-
command.limit
|
|
45859
|
-
);
|
|
45860
|
-
audit.record({
|
|
45861
|
-
commandId: command.requestId,
|
|
45862
|
-
event: "session_history_loaded",
|
|
45863
|
-
sessionId: command.sessionId
|
|
45864
|
-
});
|
|
45865
|
-
send(socket, {
|
|
45866
|
-
kind: "session.live-history.page.loaded",
|
|
45867
|
-
page,
|
|
45868
|
-
requestId: command.requestId,
|
|
45869
|
-
sessionId: command.sessionId
|
|
45870
|
-
});
|
|
45871
|
-
} catch (error62) {
|
|
45872
|
-
if (signal.aborted) {
|
|
45873
|
-
return;
|
|
45874
|
-
}
|
|
45875
|
-
audit.record({
|
|
45876
|
-
commandId: command.requestId,
|
|
45877
|
-
details: { code: operationErrorCode(error62) },
|
|
45878
|
-
event: "session_history_unavailable",
|
|
45879
|
-
sessionId: command.sessionId
|
|
45880
|
-
});
|
|
45881
|
-
send(socket, {
|
|
45882
|
-
kind: "session.live-history.page.loaded",
|
|
45883
|
-
page: {
|
|
45884
|
-
status: "unavailable",
|
|
45885
|
-
cause: { code: operationErrorCode(error62), message: operationErrorMessage(error62) },
|
|
45886
|
-
nextCursor: null
|
|
45887
|
-
},
|
|
45888
|
-
requestId: command.requestId,
|
|
45889
|
-
sessionId: command.sessionId
|
|
45890
|
-
});
|
|
45891
|
-
}
|
|
45892
|
-
}
|
|
45893
45027
|
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
|
|
45894
45028
|
try {
|
|
45895
45029
|
const resolved = await resolveSessionDirectories(
|
|
@@ -46660,9 +45794,9 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
46660
45794
|
}
|
|
46661
45795
|
|
|
46662
45796
|
// src/native-sessions/handle-native-requests.ts
|
|
46663
|
-
import { WebSocket as
|
|
45797
|
+
import { WebSocket as WebSocket4 } from "undici";
|
|
46664
45798
|
function createNativeSessionRequestHandler(dependencies) {
|
|
46665
|
-
const { audit, diagnostics, nativeSessions,
|
|
45799
|
+
const { audit, diagnostics, nativeSessions, signal, socket, timer } = dependencies;
|
|
46666
45800
|
const pending = /* @__PURE__ */ new Map();
|
|
46667
45801
|
const cancel = (command) => {
|
|
46668
45802
|
const request = pending.get(command.requestId);
|
|
@@ -46714,18 +45848,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
46714
45848
|
}
|
|
46715
45849
|
operationSignal.throwIfAborted();
|
|
46716
45850
|
const result = await nativeSessions.execute(command, operationSignal);
|
|
46717
|
-
if (
|
|
46718
|
-
publisher.publishBatch(result.ready.sessionId, [
|
|
46719
|
-
result.ready,
|
|
46720
|
-
{
|
|
46721
|
-
kind: "session.forked",
|
|
46722
|
-
sessionId: result.ready.sessionId,
|
|
46723
|
-
sourceSessionId: command.sessionId,
|
|
46724
|
-
throughCommandId: command.throughCommandId
|
|
46725
|
-
}
|
|
46726
|
-
]);
|
|
46727
|
-
}
|
|
46728
|
-
if (socket.readyState === WebSocket5.OPEN) {
|
|
45851
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
46729
45852
|
send(socket, result);
|
|
46730
45853
|
}
|
|
46731
45854
|
} catch (error62) {
|
|
@@ -46784,8 +45907,7 @@ function createDaemonCommandHandler({
|
|
|
46784
45907
|
socket,
|
|
46785
45908
|
signal,
|
|
46786
45909
|
runtimeSignal,
|
|
46787
|
-
timer
|
|
46788
|
-
resolveAgentCatalogEnvironment
|
|
45910
|
+
timer
|
|
46789
45911
|
}) {
|
|
46790
45912
|
const handleSettingsDiscovery = createAgentSettingsDiscoveryHandler({
|
|
46791
45913
|
config: config2,
|
|
@@ -46797,25 +45919,14 @@ function createDaemonCommandHandler({
|
|
|
46797
45919
|
signal,
|
|
46798
45920
|
timer
|
|
46799
45921
|
});
|
|
46800
|
-
const handleCatalogRefresh = createAgentCatalogRefreshHandler({
|
|
46801
|
-
config: config2,
|
|
46802
|
-
audit,
|
|
46803
|
-
diagnostics,
|
|
46804
|
-
socket,
|
|
46805
|
-
signal,
|
|
46806
|
-
timer,
|
|
46807
|
-
resolveEnvironment: resolveAgentCatalogEnvironment
|
|
46808
|
-
});
|
|
46809
45922
|
const queueChanged = (sessionId) => {
|
|
46810
45923
|
publisher.publish(sessionId, { kind: "session.queue.changed", sessionId });
|
|
46811
45924
|
eventLogV2.queueChanged(sessionId);
|
|
46812
45925
|
};
|
|
46813
|
-
const activeTurnRecovery = (sessionId) => activeTurns.recovery((command) => command.sessionId === sessionId);
|
|
46814
45926
|
const nativeRequestHandler = createNativeSessionRequestHandler({
|
|
46815
45927
|
audit,
|
|
46816
45928
|
diagnostics,
|
|
46817
45929
|
nativeSessions,
|
|
46818
|
-
publisher,
|
|
46819
45930
|
signal,
|
|
46820
45931
|
socket,
|
|
46821
45932
|
timer
|
|
@@ -46823,18 +45934,8 @@ function createDaemonCommandHandler({
|
|
|
46823
45934
|
return {
|
|
46824
45935
|
handle: (message) => {
|
|
46825
45936
|
const kind = message.kind;
|
|
46826
|
-
if (kind ===
|
|
46827
|
-
|
|
46828
|
-
void executeSessionLiveHistoryPageLoad(
|
|
46829
|
-
socket,
|
|
46830
|
-
command2,
|
|
46831
|
-
config2,
|
|
46832
|
-
directories,
|
|
46833
|
-
audit,
|
|
46834
|
-
sessions,
|
|
46835
|
-
activeTurnRecovery,
|
|
46836
|
-
signal
|
|
46837
|
-
);
|
|
45937
|
+
if (kind === RUNTIME_PING_KIND) {
|
|
45938
|
+
send(socket, { kind: RUNTIME_PONG_KIND, requestId: message.requestId });
|
|
46838
45939
|
return;
|
|
46839
45940
|
}
|
|
46840
45941
|
if (kind === SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) {
|
|
@@ -46859,10 +45960,6 @@ function createDaemonCommandHandler({
|
|
|
46859
45960
|
handleSettingsDiscovery.handle(message);
|
|
46860
45961
|
return;
|
|
46861
45962
|
}
|
|
46862
|
-
if (kind === AGENT_CATALOG_REFRESH_KIND) {
|
|
46863
|
-
handleCatalogRefresh.handle(message);
|
|
46864
|
-
return;
|
|
46865
|
-
}
|
|
46866
45963
|
if (kind === NATIVE_SESSION_REQUEST_KIND) {
|
|
46867
45964
|
nativeRequestHandler.handle(message);
|
|
46868
45965
|
return;
|
|
@@ -46876,7 +45973,7 @@ function createDaemonCommandHandler({
|
|
|
46876
45973
|
sessions.findSessions([command2.sessionId])[0]?.cwd ?? null,
|
|
46877
45974
|
externalContent
|
|
46878
45975
|
).catch((error62) => {
|
|
46879
|
-
if (socket.readyState !==
|
|
45976
|
+
if (socket.readyState !== WebSocket5.OPEN || signal.aborted) {
|
|
46880
45977
|
return;
|
|
46881
45978
|
}
|
|
46882
45979
|
send(socket, {
|
|
@@ -47082,17 +46179,13 @@ function createDaemonCommandHandler({
|
|
|
47082
46179
|
});
|
|
47083
46180
|
},
|
|
47084
46181
|
settle: async () => {
|
|
47085
|
-
await Promise.all([
|
|
47086
|
-
nativeRequestHandler.settle(),
|
|
47087
|
-
handleSettingsDiscovery.settle(),
|
|
47088
|
-
handleCatalogRefresh.settle()
|
|
47089
|
-
]);
|
|
46182
|
+
await Promise.all([nativeRequestHandler.settle(), handleSettingsDiscovery.settle()]);
|
|
47090
46183
|
}
|
|
47091
46184
|
};
|
|
47092
46185
|
}
|
|
47093
46186
|
|
|
47094
46187
|
// src/relay-connection/connect.ts
|
|
47095
|
-
import { WebSocket as
|
|
46188
|
+
import { WebSocket as WebSocket6 } from "undici";
|
|
47096
46189
|
|
|
47097
46190
|
// src/relay-connection/runtime-revocation.ts
|
|
47098
46191
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -47130,7 +46223,7 @@ function connectRelay(url2, signal) {
|
|
|
47130
46223
|
const endpoint = new URL(url2);
|
|
47131
46224
|
const headers = runtimeAuthorization(endpoint);
|
|
47132
46225
|
endpoint.searchParams.delete("token");
|
|
47133
|
-
const socket = new
|
|
46226
|
+
const socket = new WebSocket6(endpoint, {
|
|
47134
46227
|
dispatcher: environmentProxyDispatcher,
|
|
47135
46228
|
headers
|
|
47136
46229
|
});
|
|
@@ -47348,8 +46441,7 @@ async function runRelayConnection({
|
|
|
47348
46441
|
diagnostics,
|
|
47349
46442
|
onConnected,
|
|
47350
46443
|
signal,
|
|
47351
|
-
timer
|
|
47352
|
-
resolveAgentCatalogEnvironment
|
|
46444
|
+
timer
|
|
47353
46445
|
}) {
|
|
47354
46446
|
const relayUrl = new URL(config2.relayUrl);
|
|
47355
46447
|
relayUrl.searchParams.set("liveness", "1");
|
|
@@ -47372,8 +46464,7 @@ async function runRelayConnection({
|
|
|
47372
46464
|
socket,
|
|
47373
46465
|
signal: connectionController.signal,
|
|
47374
46466
|
runtimeSignal: signal,
|
|
47375
|
-
timer
|
|
47376
|
-
resolveAgentCatalogEnvironment
|
|
46467
|
+
timer
|
|
47377
46468
|
});
|
|
47378
46469
|
installationObserver.connect(socket);
|
|
47379
46470
|
onConnected();
|
|
@@ -47419,14 +46510,14 @@ async function runRelayConnection({
|
|
|
47419
46510
|
};
|
|
47420
46511
|
const connectionLiveness = new RelayConnectionLiveness(timer, {
|
|
47421
46512
|
send: (message) => {
|
|
47422
|
-
if (socket.readyState !==
|
|
46513
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
47423
46514
|
return false;
|
|
47424
46515
|
}
|
|
47425
46516
|
try {
|
|
47426
46517
|
send(socket, message);
|
|
47427
46518
|
return true;
|
|
47428
46519
|
} catch (error62) {
|
|
47429
|
-
if (socket.readyState !==
|
|
46520
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
47430
46521
|
return false;
|
|
47431
46522
|
}
|
|
47432
46523
|
throw error62;
|
|
@@ -47515,7 +46606,7 @@ async function runRelayConnection({
|
|
|
47515
46606
|
}
|
|
47516
46607
|
|
|
47517
46608
|
// src/relay-connection/session-event-publisher.ts
|
|
47518
|
-
import { WebSocket as
|
|
46609
|
+
import { WebSocket as WebSocket8 } from "undici";
|
|
47519
46610
|
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
47520
46611
|
var DaemonSessionEventPublisher = class {
|
|
47521
46612
|
#socket = null;
|
|
@@ -47532,7 +46623,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
47532
46623
|
};
|
|
47533
46624
|
publish = (sessionId, event) => {
|
|
47534
46625
|
const socket = this.#socket;
|
|
47535
|
-
if (socket === null || socket.readyState !==
|
|
46626
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
47536
46627
|
return;
|
|
47537
46628
|
}
|
|
47538
46629
|
const encoded = encodeDaemonToServiceMessage({
|
|
@@ -47556,7 +46647,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
47556
46647
|
};
|
|
47557
46648
|
publishStatus = (event) => {
|
|
47558
46649
|
const socket = this.#socket;
|
|
47559
|
-
if (socket === null || socket.readyState !==
|
|
46650
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
47560
46651
|
return;
|
|
47561
46652
|
}
|
|
47562
46653
|
const encoded = encodeDaemonToServiceMessage(event);
|
|
@@ -47571,7 +46662,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
47571
46662
|
};
|
|
47572
46663
|
publishV2 = (event) => {
|
|
47573
46664
|
const socket = this.#socket;
|
|
47574
|
-
if (socket === null || socket.readyState !==
|
|
46665
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
47575
46666
|
return;
|
|
47576
46667
|
}
|
|
47577
46668
|
const encoded = encodeDaemonToServiceMessage({ event, kind: SESSION_EVENT_V2_KIND });
|
|
@@ -47810,10 +46901,6 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
47810
46901
|
let connectionAnnounced = false;
|
|
47811
46902
|
let catalogPublished = false;
|
|
47812
46903
|
let readinessAnnounced = false;
|
|
47813
|
-
const resolveAgentCatalogEnvironment = options.resolveAgentCatalogEnvironment ?? (async (catalogSignal) => {
|
|
47814
|
-
catalogSignal.throwIfAborted();
|
|
47815
|
-
return config2.localContext.environment;
|
|
47816
|
-
});
|
|
47817
46904
|
const startAutomaticIntegrationProvisioning = () => {
|
|
47818
46905
|
if (!connectionAnnounced || !catalogPublished || automaticIntegrationProvisioningStarted) {
|
|
47819
46906
|
return;
|
|
@@ -47891,8 +46978,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
47891
46978
|
announceConnection();
|
|
47892
46979
|
},
|
|
47893
46980
|
signal,
|
|
47894
|
-
timer
|
|
47895
|
-
resolveAgentCatalogEnvironment
|
|
46981
|
+
timer
|
|
47896
46982
|
});
|
|
47897
46983
|
} catch (error62) {
|
|
47898
46984
|
if (signal.aborted) {
|
|
@@ -47986,8 +47072,7 @@ var MobiusRuntimeEngine = class {
|
|
|
47986
47072
|
const audit = new AuditStore();
|
|
47987
47073
|
try {
|
|
47988
47074
|
await runDaemon(this.#config, audit, signal, void 0, {
|
|
47989
|
-
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus }
|
|
47990
|
-
...this.#options.resolveAgentCatalogEnvironment === void 0 ? {} : { resolveAgentCatalogEnvironment: this.#options.resolveAgentCatalogEnvironment }
|
|
47075
|
+
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus }
|
|
47991
47076
|
});
|
|
47992
47077
|
} finally {
|
|
47993
47078
|
audit.close();
|