@moxt-ai/mobius 0.0.173 → 0.0.174
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/agent-catalog/agent-specification.js +1 -1
- package/dist/cli.js +48 -717
- 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 -26
- 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/index.js +47 -716
- package/dist/index.js.map +4 -4
- package/dist/native-sessions/service.d.ts.map +1 -1
- package/dist/native-sessions/service.js +0 -55
- 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 +47 -716
- package/dist/runtime.js.map +4 -4
- 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/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.174",
|
|
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,
|
|
@@ -29692,10 +29680,7 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
|
29692
29680
|
}).readonly()
|
|
29693
29681
|
]);
|
|
29694
29682
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
29695
|
-
external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
29696
29683
|
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
29684
|
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
29700
29685
|
external_exports.object({
|
|
29701
29686
|
...identity,
|
|
@@ -29735,7 +29720,6 @@ var resultEnvelope = {
|
|
|
29735
29720
|
kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
|
|
29736
29721
|
};
|
|
29737
29722
|
var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
29738
|
-
external_exports.object({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
29739
29723
|
external_exports.object({
|
|
29740
29724
|
...resultEnvelope,
|
|
29741
29725
|
action: external_exports.literal("active-turn"),
|
|
@@ -29768,22 +29752,6 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
29768
29752
|
ready: sessionReadyEventSchema,
|
|
29769
29753
|
title: external_exports.string().max(500)
|
|
29770
29754
|
}).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
29755
|
external_exports.object({
|
|
29788
29756
|
...resultEnvelope,
|
|
29789
29757
|
action: external_exports.literal("delete"),
|
|
@@ -30354,28 +30322,9 @@ function decodeRecordedSessionEvent(encoded) {
|
|
|
30354
30322
|
var encodeRecordedSessionEvent = (event) => JSON.stringify(decodeRecordedSessionEvent(JSON.stringify(event)));
|
|
30355
30323
|
|
|
30356
30324
|
// ../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
30325
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
|
|
30360
30326
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
|
|
30361
30327
|
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
30328
|
var sessionLiveHistoryV2PageLoadSchema = external_exports.object({
|
|
30380
30329
|
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
30381
30330
|
agentId: identifierStringSchema,
|
|
@@ -30401,10 +30350,6 @@ function decode7(schema, encoded) {
|
|
|
30401
30350
|
throw new ProtocolMessageError("Invalid live Session history message", { cause });
|
|
30402
30351
|
}
|
|
30403
30352
|
}
|
|
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
30353
|
var decodeSessionLiveHistoryV2PageLoad = (encoded) => decode7(sessionLiveHistoryV2PageLoadSchema, encoded);
|
|
30409
30354
|
var decodeSessionLiveHistoryV2PageLoaded = (encoded) => decode7(sessionLiveHistoryV2PageLoadedSchema, encoded);
|
|
30410
30355
|
var encodeSessionLiveHistoryV2PageLoad = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadSchema.parse(value));
|
|
@@ -30421,11 +30366,6 @@ function defineMessageSignature(kind, encoder, decoder) {
|
|
|
30421
30366
|
};
|
|
30422
30367
|
}
|
|
30423
30368
|
var serviceToDaemonSignatures = {
|
|
30424
|
-
[AGENT_CATALOG_REFRESH_KIND]: defineMessageSignature(
|
|
30425
|
-
AGENT_CATALOG_REFRESH_KIND,
|
|
30426
|
-
encodeAgentCatalogRefreshCommand,
|
|
30427
|
-
decodeAgentCatalogRefreshCommand
|
|
30428
|
-
),
|
|
30429
30369
|
[AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
|
|
30430
30370
|
AGENT_INSTALL_CANCEL_KIND,
|
|
30431
30371
|
encodeAgentInstallCancelCommand,
|
|
@@ -30468,6 +30408,7 @@ var serviceToDaemonSignatures = {
|
|
|
30468
30408
|
encodeRuntimeLivenessReadyEvent,
|
|
30469
30409
|
decodeRuntimeLivenessReadyEvent
|
|
30470
30410
|
),
|
|
30411
|
+
[RUNTIME_PING_KIND]: defineMessageSignature(RUNTIME_PING_KIND, encodeRuntimePingCommand, decodeRuntimePingCommand),
|
|
30471
30412
|
[SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
30472
30413
|
SESSION_CANCEL_KIND,
|
|
30473
30414
|
encodeSessionCancelCommand,
|
|
@@ -30483,11 +30424,6 @@ var serviceToDaemonSignatures = {
|
|
|
30483
30424
|
encodeSessionElicitationRespondCommand,
|
|
30484
30425
|
decodeSessionElicitationRespondCommand
|
|
30485
30426
|
),
|
|
30486
|
-
[SESSION_LIVE_HISTORY_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
30487
|
-
SESSION_LIVE_HISTORY_PAGE_LOAD_KIND,
|
|
30488
|
-
encodeSessionLiveHistoryPageLoad,
|
|
30489
|
-
decodeSessionLiveHistoryPageLoad
|
|
30490
|
-
),
|
|
30491
30427
|
[SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
30492
30428
|
SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND,
|
|
30493
30429
|
encodeSessionLiveHistoryV2PageLoad,
|
|
@@ -30529,16 +30465,6 @@ function decodeServiceToDaemonMessage(encoded) {
|
|
|
30529
30465
|
return signature.decoder(encoded);
|
|
30530
30466
|
}
|
|
30531
30467
|
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
30468
|
[AGENT_INSTALL_CANCELLED_KIND]: defineMessageSignature(
|
|
30543
30469
|
AGENT_INSTALL_CANCELLED_KIND,
|
|
30544
30470
|
encodeAgentInstallCancelledEvent,
|
|
@@ -30608,6 +30534,7 @@ var daemonToServiceSignatures = {
|
|
|
30608
30534
|
encodeRuntimeHeartbeatEvent,
|
|
30609
30535
|
decodeRuntimeHeartbeatEvent
|
|
30610
30536
|
),
|
|
30537
|
+
[RUNTIME_PONG_KIND]: defineMessageSignature(RUNTIME_PONG_KIND, encodeRuntimePongEvent, decodeRuntimePongEvent),
|
|
30611
30538
|
[SESSION_EVENT_KIND]: defineMessageSignature(
|
|
30612
30539
|
SESSION_EVENT_KIND,
|
|
30613
30540
|
encodeSessionEventEnvelope,
|
|
@@ -30623,11 +30550,6 @@ var daemonToServiceSignatures = {
|
|
|
30623
30550
|
encodeSessionOperationFailedEvent,
|
|
30624
30551
|
decodeSessionOperationFailedEvent
|
|
30625
30552
|
),
|
|
30626
|
-
[SESSION_LIVE_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
30627
|
-
SESSION_LIVE_HISTORY_PAGE_LOADED_KIND,
|
|
30628
|
-
encodeSessionLiveHistoryPageLoaded,
|
|
30629
|
-
decodeSessionLiveHistoryPageLoaded
|
|
30630
|
-
),
|
|
30631
30553
|
[SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
30632
30554
|
SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
|
|
30633
30555
|
encodeSessionLiveHistoryV2PageLoaded,
|
|
@@ -40694,9 +40616,6 @@ var LocalExternalContentStore = class {
|
|
|
40694
40616
|
};
|
|
40695
40617
|
|
|
40696
40618
|
// src/native-sessions/chat-agent.ts
|
|
40697
|
-
function supportsNativeChat(agentId) {
|
|
40698
|
-
return agentId === "codex" || agentId === "claude" || agentId === "opencode" || agentId === "pi";
|
|
40699
|
-
}
|
|
40700
40619
|
function isNativeChatSessionId(agentId, sessionId) {
|
|
40701
40620
|
if (!nativeSessionIdSchema.safeParse(sessionId).success) {
|
|
40702
40621
|
return false;
|
|
@@ -43954,7 +43873,6 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
43954
43873
|
child2.removeListener("exit", onExit);
|
|
43955
43874
|
}
|
|
43956
43875
|
}
|
|
43957
|
-
var readCodexHistory = async (agent, cwd, nativeSessionId, signal) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, { detail: "messages" });
|
|
43958
43876
|
var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTurn) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, {
|
|
43959
43877
|
detail: "rich",
|
|
43960
43878
|
...nativeTurn === void 0 ? {} : { nativeTurn }
|
|
@@ -43963,84 +43881,6 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
|
|
|
43963
43881
|
// src/native-sessions/service.ts
|
|
43964
43882
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
43965
43883
|
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
43884
|
var NativeSessionService = class {
|
|
44045
43885
|
#entries = /* @__PURE__ */ new Map();
|
|
44046
43886
|
#cursors = /* @__PURE__ */ new Map();
|
|
@@ -44084,25 +43924,6 @@ var NativeSessionService = class {
|
|
|
44084
43924
|
...await this.#activeTurn(command, options)
|
|
44085
43925
|
};
|
|
44086
43926
|
}
|
|
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
43927
|
if (command.action === "fork-recorded") {
|
|
44107
43928
|
const source = this.#sessions.findSessions([command.sessionId])[0];
|
|
44108
43929
|
if (source === void 0 || !source.prompted) {
|
|
@@ -44295,44 +44116,6 @@ var NativeSessionService = class {
|
|
|
44295
44116
|
);
|
|
44296
44117
|
}
|
|
44297
44118
|
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
44119
|
if (command.action === "delete") {
|
|
44337
44120
|
if (!prepared.capabilities.deleteSession) {
|
|
44338
44121
|
throw new AcpExecutionError(
|
|
@@ -44736,135 +44519,13 @@ var RelayConnectionDiagnostics = class {
|
|
|
44736
44519
|
};
|
|
44737
44520
|
|
|
44738
44521
|
// src/relay-connection/run-relay-connection.ts
|
|
44739
|
-
import { WebSocket as
|
|
44522
|
+
import { WebSocket as WebSocket7 } from "undici";
|
|
44740
44523
|
|
|
44741
44524
|
// 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
|
-
}
|
|
44525
|
+
import { WebSocket as WebSocket5 } from "undici";
|
|
44865
44526
|
|
|
44866
44527
|
// src/agent-catalog/handle-agent-settings-discovery.ts
|
|
44867
|
-
import { WebSocket as
|
|
44528
|
+
import { WebSocket as WebSocket3 } from "undici";
|
|
44868
44529
|
|
|
44869
44530
|
// src/agent-catalog/discover-agent-settings.ts
|
|
44870
44531
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -45352,7 +45013,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45352
45013
|
(request) => request.agentId === command.agentId && !request.controller.signal.aborted
|
|
45353
45014
|
);
|
|
45354
45015
|
if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
|
|
45355
|
-
if (socket.readyState ===
|
|
45016
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45356
45017
|
send(socket, {
|
|
45357
45018
|
code: "agent_settings_discovery_busy",
|
|
45358
45019
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -45367,7 +45028,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45367
45028
|
return;
|
|
45368
45029
|
}
|
|
45369
45030
|
if (existing !== void 0) {
|
|
45370
|
-
if (socket.readyState ===
|
|
45031
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45371
45032
|
send(socket, {
|
|
45372
45033
|
code: "agent_settings_discovery_busy",
|
|
45373
45034
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -45378,7 +45039,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45378
45039
|
return;
|
|
45379
45040
|
}
|
|
45380
45041
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
45381
|
-
if (socket.readyState ===
|
|
45042
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45382
45043
|
send(socket, {
|
|
45383
45044
|
code: "agent_settings_discovery_busy",
|
|
45384
45045
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -45424,7 +45085,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45424
45085
|
event: "agent_settings_discovered",
|
|
45425
45086
|
sessionId: `agent-settings:${command.agentId}`
|
|
45426
45087
|
});
|
|
45427
|
-
if (socket.readyState ===
|
|
45088
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45428
45089
|
send(socket, { ...result.event, requestId });
|
|
45429
45090
|
}
|
|
45430
45091
|
}
|
|
@@ -45450,7 +45111,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45450
45111
|
`
|
|
45451
45112
|
);
|
|
45452
45113
|
}
|
|
45453
|
-
if (socket.readyState ===
|
|
45114
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45454
45115
|
for (const requestId of requestIds) {
|
|
45455
45116
|
send(socket, {
|
|
45456
45117
|
code: operationErrorCode(failure2),
|
|
@@ -45596,300 +45257,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
45596
45257
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
45597
45258
|
}
|
|
45598
45259
|
|
|
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
45260
|
// 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
45261
|
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
|
|
45894
45262
|
try {
|
|
45895
45263
|
const resolved = await resolveSessionDirectories(
|
|
@@ -46660,7 +46028,7 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
46660
46028
|
}
|
|
46661
46029
|
|
|
46662
46030
|
// src/native-sessions/handle-native-requests.ts
|
|
46663
|
-
import { WebSocket as
|
|
46031
|
+
import { WebSocket as WebSocket4 } from "undici";
|
|
46664
46032
|
function createNativeSessionRequestHandler(dependencies) {
|
|
46665
46033
|
const { audit, diagnostics, nativeSessions, publisher, signal, socket, timer } = dependencies;
|
|
46666
46034
|
const pending = /* @__PURE__ */ new Map();
|
|
@@ -46725,7 +46093,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
46725
46093
|
}
|
|
46726
46094
|
]);
|
|
46727
46095
|
}
|
|
46728
|
-
if (socket.readyState ===
|
|
46096
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
46729
46097
|
send(socket, result);
|
|
46730
46098
|
}
|
|
46731
46099
|
} catch (error62) {
|
|
@@ -46784,8 +46152,7 @@ function createDaemonCommandHandler({
|
|
|
46784
46152
|
socket,
|
|
46785
46153
|
signal,
|
|
46786
46154
|
runtimeSignal,
|
|
46787
|
-
timer
|
|
46788
|
-
resolveAgentCatalogEnvironment
|
|
46155
|
+
timer
|
|
46789
46156
|
}) {
|
|
46790
46157
|
const handleSettingsDiscovery = createAgentSettingsDiscoveryHandler({
|
|
46791
46158
|
config: config2,
|
|
@@ -46797,20 +46164,10 @@ function createDaemonCommandHandler({
|
|
|
46797
46164
|
signal,
|
|
46798
46165
|
timer
|
|
46799
46166
|
});
|
|
46800
|
-
const handleCatalogRefresh = createAgentCatalogRefreshHandler({
|
|
46801
|
-
config: config2,
|
|
46802
|
-
audit,
|
|
46803
|
-
diagnostics,
|
|
46804
|
-
socket,
|
|
46805
|
-
signal,
|
|
46806
|
-
timer,
|
|
46807
|
-
resolveEnvironment: resolveAgentCatalogEnvironment
|
|
46808
|
-
});
|
|
46809
46167
|
const queueChanged = (sessionId) => {
|
|
46810
46168
|
publisher.publish(sessionId, { kind: "session.queue.changed", sessionId });
|
|
46811
46169
|
eventLogV2.queueChanged(sessionId);
|
|
46812
46170
|
};
|
|
46813
|
-
const activeTurnRecovery = (sessionId) => activeTurns.recovery((command) => command.sessionId === sessionId);
|
|
46814
46171
|
const nativeRequestHandler = createNativeSessionRequestHandler({
|
|
46815
46172
|
audit,
|
|
46816
46173
|
diagnostics,
|
|
@@ -46823,18 +46180,8 @@ function createDaemonCommandHandler({
|
|
|
46823
46180
|
return {
|
|
46824
46181
|
handle: (message) => {
|
|
46825
46182
|
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
|
-
);
|
|
46183
|
+
if (kind === RUNTIME_PING_KIND) {
|
|
46184
|
+
send(socket, { kind: RUNTIME_PONG_KIND, requestId: message.requestId });
|
|
46838
46185
|
return;
|
|
46839
46186
|
}
|
|
46840
46187
|
if (kind === SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) {
|
|
@@ -46859,10 +46206,6 @@ function createDaemonCommandHandler({
|
|
|
46859
46206
|
handleSettingsDiscovery.handle(message);
|
|
46860
46207
|
return;
|
|
46861
46208
|
}
|
|
46862
|
-
if (kind === AGENT_CATALOG_REFRESH_KIND) {
|
|
46863
|
-
handleCatalogRefresh.handle(message);
|
|
46864
|
-
return;
|
|
46865
|
-
}
|
|
46866
46209
|
if (kind === NATIVE_SESSION_REQUEST_KIND) {
|
|
46867
46210
|
nativeRequestHandler.handle(message);
|
|
46868
46211
|
return;
|
|
@@ -46876,7 +46219,7 @@ function createDaemonCommandHandler({
|
|
|
46876
46219
|
sessions.findSessions([command2.sessionId])[0]?.cwd ?? null,
|
|
46877
46220
|
externalContent
|
|
46878
46221
|
).catch((error62) => {
|
|
46879
|
-
if (socket.readyState !==
|
|
46222
|
+
if (socket.readyState !== WebSocket5.OPEN || signal.aborted) {
|
|
46880
46223
|
return;
|
|
46881
46224
|
}
|
|
46882
46225
|
send(socket, {
|
|
@@ -47082,17 +46425,13 @@ function createDaemonCommandHandler({
|
|
|
47082
46425
|
});
|
|
47083
46426
|
},
|
|
47084
46427
|
settle: async () => {
|
|
47085
|
-
await Promise.all([
|
|
47086
|
-
nativeRequestHandler.settle(),
|
|
47087
|
-
handleSettingsDiscovery.settle(),
|
|
47088
|
-
handleCatalogRefresh.settle()
|
|
47089
|
-
]);
|
|
46428
|
+
await Promise.all([nativeRequestHandler.settle(), handleSettingsDiscovery.settle()]);
|
|
47090
46429
|
}
|
|
47091
46430
|
};
|
|
47092
46431
|
}
|
|
47093
46432
|
|
|
47094
46433
|
// src/relay-connection/connect.ts
|
|
47095
|
-
import { WebSocket as
|
|
46434
|
+
import { WebSocket as WebSocket6 } from "undici";
|
|
47096
46435
|
|
|
47097
46436
|
// src/relay-connection/runtime-revocation.ts
|
|
47098
46437
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -47130,7 +46469,7 @@ function connectRelay(url2, signal) {
|
|
|
47130
46469
|
const endpoint = new URL(url2);
|
|
47131
46470
|
const headers = runtimeAuthorization(endpoint);
|
|
47132
46471
|
endpoint.searchParams.delete("token");
|
|
47133
|
-
const socket = new
|
|
46472
|
+
const socket = new WebSocket6(endpoint, {
|
|
47134
46473
|
dispatcher: environmentProxyDispatcher,
|
|
47135
46474
|
headers
|
|
47136
46475
|
});
|
|
@@ -47348,8 +46687,7 @@ async function runRelayConnection({
|
|
|
47348
46687
|
diagnostics,
|
|
47349
46688
|
onConnected,
|
|
47350
46689
|
signal,
|
|
47351
|
-
timer
|
|
47352
|
-
resolveAgentCatalogEnvironment
|
|
46690
|
+
timer
|
|
47353
46691
|
}) {
|
|
47354
46692
|
const relayUrl = new URL(config2.relayUrl);
|
|
47355
46693
|
relayUrl.searchParams.set("liveness", "1");
|
|
@@ -47372,8 +46710,7 @@ async function runRelayConnection({
|
|
|
47372
46710
|
socket,
|
|
47373
46711
|
signal: connectionController.signal,
|
|
47374
46712
|
runtimeSignal: signal,
|
|
47375
|
-
timer
|
|
47376
|
-
resolveAgentCatalogEnvironment
|
|
46713
|
+
timer
|
|
47377
46714
|
});
|
|
47378
46715
|
installationObserver.connect(socket);
|
|
47379
46716
|
onConnected();
|
|
@@ -47419,14 +46756,14 @@ async function runRelayConnection({
|
|
|
47419
46756
|
};
|
|
47420
46757
|
const connectionLiveness = new RelayConnectionLiveness(timer, {
|
|
47421
46758
|
send: (message) => {
|
|
47422
|
-
if (socket.readyState !==
|
|
46759
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
47423
46760
|
return false;
|
|
47424
46761
|
}
|
|
47425
46762
|
try {
|
|
47426
46763
|
send(socket, message);
|
|
47427
46764
|
return true;
|
|
47428
46765
|
} catch (error62) {
|
|
47429
|
-
if (socket.readyState !==
|
|
46766
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
47430
46767
|
return false;
|
|
47431
46768
|
}
|
|
47432
46769
|
throw error62;
|
|
@@ -47515,7 +46852,7 @@ async function runRelayConnection({
|
|
|
47515
46852
|
}
|
|
47516
46853
|
|
|
47517
46854
|
// src/relay-connection/session-event-publisher.ts
|
|
47518
|
-
import { WebSocket as
|
|
46855
|
+
import { WebSocket as WebSocket8 } from "undici";
|
|
47519
46856
|
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
47520
46857
|
var DaemonSessionEventPublisher = class {
|
|
47521
46858
|
#socket = null;
|
|
@@ -47532,7 +46869,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
47532
46869
|
};
|
|
47533
46870
|
publish = (sessionId, event) => {
|
|
47534
46871
|
const socket = this.#socket;
|
|
47535
|
-
if (socket === null || socket.readyState !==
|
|
46872
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
47536
46873
|
return;
|
|
47537
46874
|
}
|
|
47538
46875
|
const encoded = encodeDaemonToServiceMessage({
|
|
@@ -47556,7 +46893,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
47556
46893
|
};
|
|
47557
46894
|
publishStatus = (event) => {
|
|
47558
46895
|
const socket = this.#socket;
|
|
47559
|
-
if (socket === null || socket.readyState !==
|
|
46896
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
47560
46897
|
return;
|
|
47561
46898
|
}
|
|
47562
46899
|
const encoded = encodeDaemonToServiceMessage(event);
|
|
@@ -47571,7 +46908,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
47571
46908
|
};
|
|
47572
46909
|
publishV2 = (event) => {
|
|
47573
46910
|
const socket = this.#socket;
|
|
47574
|
-
if (socket === null || socket.readyState !==
|
|
46911
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
47575
46912
|
return;
|
|
47576
46913
|
}
|
|
47577
46914
|
const encoded = encodeDaemonToServiceMessage({ event, kind: SESSION_EVENT_V2_KIND });
|
|
@@ -47810,10 +47147,6 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
47810
47147
|
let connectionAnnounced = false;
|
|
47811
47148
|
let catalogPublished = false;
|
|
47812
47149
|
let readinessAnnounced = false;
|
|
47813
|
-
const resolveAgentCatalogEnvironment = options.resolveAgentCatalogEnvironment ?? (async (catalogSignal) => {
|
|
47814
|
-
catalogSignal.throwIfAborted();
|
|
47815
|
-
return config2.localContext.environment;
|
|
47816
|
-
});
|
|
47817
47150
|
const startAutomaticIntegrationProvisioning = () => {
|
|
47818
47151
|
if (!connectionAnnounced || !catalogPublished || automaticIntegrationProvisioningStarted) {
|
|
47819
47152
|
return;
|
|
@@ -47891,8 +47224,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
47891
47224
|
announceConnection();
|
|
47892
47225
|
},
|
|
47893
47226
|
signal,
|
|
47894
|
-
timer
|
|
47895
|
-
resolveAgentCatalogEnvironment
|
|
47227
|
+
timer
|
|
47896
47228
|
});
|
|
47897
47229
|
} catch (error62) {
|
|
47898
47230
|
if (signal.aborted) {
|
|
@@ -47986,8 +47318,7 @@ var MobiusRuntimeEngine = class {
|
|
|
47986
47318
|
const audit = new AuditStore();
|
|
47987
47319
|
try {
|
|
47988
47320
|
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 }
|
|
47321
|
+
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus }
|
|
47991
47322
|
});
|
|
47992
47323
|
} finally {
|
|
47993
47324
|
audit.close();
|