@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/index.js
CHANGED
|
@@ -19815,9 +19815,6 @@ var AGENT_INSTALL_CANCELLED_KIND = "agent.integration.install.cancelled";
|
|
|
19815
19815
|
var AGENT_SETTINGS_DISCOVER_KIND = "agent.settings.discover";
|
|
19816
19816
|
var AGENT_SETTINGS_DISCOVERED_KIND = "agent.settings.discovered";
|
|
19817
19817
|
var AGENT_SETTINGS_DISCOVERY_FAILED_KIND = "agent.settings.discovery.failed";
|
|
19818
|
-
var AGENT_CATALOG_REFRESH_KIND = "agent.catalog.refresh";
|
|
19819
|
-
var AGENT_CATALOG_REFRESHED_KIND = "agent.catalog.refreshed";
|
|
19820
|
-
var AGENT_CATALOG_REFRESH_FAILED_KIND = "agent.catalog.refresh.failed";
|
|
19821
19818
|
var FILE_READ_KIND = "file.read";
|
|
19822
19819
|
var FILE_BEGIN_KIND = "file.begin";
|
|
19823
19820
|
var FILE_CHUNK_KIND = "file.chunk";
|
|
@@ -19979,20 +19976,6 @@ var agentSettingsDiscoveryFailedEventSchema = external_exports.object({
|
|
|
19979
19976
|
message: external_exports.string().min(1).max(500),
|
|
19980
19977
|
requestId: identifierStringSchema
|
|
19981
19978
|
}).readonly();
|
|
19982
|
-
var agentCatalogRefreshCommandSchema = external_exports.object({
|
|
19983
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESH_KIND),
|
|
19984
|
-
requestId: identifierStringSchema
|
|
19985
|
-
}).readonly();
|
|
19986
|
-
var agentCatalogRefreshedEventSchema = external_exports.object({
|
|
19987
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESHED_KIND),
|
|
19988
|
-
requestId: identifierStringSchema
|
|
19989
|
-
}).readonly();
|
|
19990
|
-
var agentCatalogRefreshFailedEventSchema = external_exports.object({
|
|
19991
|
-
code: identifierStringSchema,
|
|
19992
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESH_FAILED_KIND),
|
|
19993
|
-
message: external_exports.string().min(1).max(500),
|
|
19994
|
-
requestId: identifierStringSchema
|
|
19995
|
-
}).readonly();
|
|
19996
19979
|
var sessionConfigurationSelectionSchema = external_exports.object({
|
|
19997
19980
|
booleanValue: external_exports.boolean(),
|
|
19998
19981
|
configId: identifierStringSchema,
|
|
@@ -20397,12 +20380,6 @@ var decodeAgentSettingsDiscoveredEvent = (encoded) => decode3(encoded, agentSett
|
|
|
20397
20380
|
var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
|
|
20398
20381
|
var decodeAgentSettingsDiscoveryFailedEvent = (encoded) => decode3(encoded, agentSettingsDiscoveryFailedEventSchema);
|
|
20399
20382
|
var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
|
|
20400
|
-
var decodeAgentCatalogRefreshCommand = (encoded) => decode3(encoded, agentCatalogRefreshCommandSchema);
|
|
20401
|
-
var encodeAgentCatalogRefreshCommand = (message) => encode3(message, agentCatalogRefreshCommandSchema);
|
|
20402
|
-
var decodeAgentCatalogRefreshedEvent = (encoded) => decode3(encoded, agentCatalogRefreshedEventSchema);
|
|
20403
|
-
var encodeAgentCatalogRefreshedEvent = (message) => encode3(message, agentCatalogRefreshedEventSchema);
|
|
20404
|
-
var decodeAgentCatalogRefreshFailedEvent = (encoded) => decode3(encoded, agentCatalogRefreshFailedEventSchema);
|
|
20405
|
-
var encodeAgentCatalogRefreshFailedEvent = (message) => encode3(message, agentCatalogRefreshFailedEventSchema);
|
|
20406
20383
|
var decodeFileReadCommand = (encoded) => decode3(encoded, fileReadCommandSchema);
|
|
20407
20384
|
var encodeFileReadCommand = (message) => encode3(message, fileReadCommandSchema);
|
|
20408
20385
|
var decodeFileBeginEvent = (encoded) => decode3(encoded, fileBeginEventSchema);
|
|
@@ -20471,6 +20448,8 @@ var SESSION_CANCEL_KIND = "session.cancel";
|
|
|
20471
20448
|
var RUNTIME_LIVENESS_READY_KIND = "runtime.liveness.ready";
|
|
20472
20449
|
var RUNTIME_HEARTBEAT_KIND = "runtime.heartbeat";
|
|
20473
20450
|
var RUNTIME_HEARTBEAT_ACK_KIND = "runtime.heartbeat.ack";
|
|
20451
|
+
var RUNTIME_PING_KIND = "runtime.ping";
|
|
20452
|
+
var RUNTIME_PONG_KIND = "runtime.pong";
|
|
20474
20453
|
var SESSION_STARTED_KIND = "session.started";
|
|
20475
20454
|
var SESSION_QUEUED_KIND = "session.queued";
|
|
20476
20455
|
var AGENT_MESSAGE_DELTA_KIND = "agent.message.delta";
|
|
@@ -20783,6 +20762,16 @@ function decodeRuntimeHeartbeatAckEvent(encoded) {
|
|
|
20783
20762
|
kind: RUNTIME_HEARTBEAT_ACK_KIND
|
|
20784
20763
|
};
|
|
20785
20764
|
}
|
|
20765
|
+
function decodeRuntimePingCommand(encoded) {
|
|
20766
|
+
const value = parseJson2(encoded);
|
|
20767
|
+
assertKind(value, RUNTIME_PING_KIND);
|
|
20768
|
+
return { kind: RUNTIME_PING_KIND, requestId: readIdentifier(value, "requestId") };
|
|
20769
|
+
}
|
|
20770
|
+
function decodeRuntimePongEvent(encoded) {
|
|
20771
|
+
const value = parseJson2(encoded);
|
|
20772
|
+
assertKind(value, RUNTIME_PONG_KIND);
|
|
20773
|
+
return { kind: RUNTIME_PONG_KIND, requestId: readIdentifier(value, "requestId") };
|
|
20774
|
+
}
|
|
20786
20775
|
function decodeSessionStartedEvent(encoded) {
|
|
20787
20776
|
const value = parseJson2(encoded);
|
|
20788
20777
|
assertKind(value, SESSION_STARTED_KIND);
|
|
@@ -20880,6 +20869,12 @@ function encodeRuntimeHeartbeatEvent(message) {
|
|
|
20880
20869
|
function encodeRuntimeHeartbeatAckEvent(message) {
|
|
20881
20870
|
return JSON.stringify(decodeRuntimeHeartbeatAckEvent(JSON.stringify(message)));
|
|
20882
20871
|
}
|
|
20872
|
+
function encodeRuntimePingCommand(message) {
|
|
20873
|
+
return JSON.stringify(decodeRuntimePingCommand(JSON.stringify(message)));
|
|
20874
|
+
}
|
|
20875
|
+
function encodeRuntimePongEvent(message) {
|
|
20876
|
+
return JSON.stringify(decodeRuntimePongEvent(JSON.stringify(message)));
|
|
20877
|
+
}
|
|
20883
20878
|
function decodeAgentActivityNarrationEvent(encoded) {
|
|
20884
20879
|
const value = parseJson2(encoded);
|
|
20885
20880
|
assertKind(value, AGENT_ACTIVITY_NARRATION_KIND);
|
|
@@ -20993,10 +20988,6 @@ function withinHistoryContentLimits(history) {
|
|
|
20993
20988
|
) <= SESSION_HISTORY_IMAGE_CHARACTER_LIMIT;
|
|
20994
20989
|
}
|
|
20995
20990
|
var sessionHistorySchema = external_exports.discriminatedUnion("status", [availableSessionHistorySchema, unavailableSessionHistorySchema]).refine(withinHistoryContentLimits);
|
|
20996
|
-
var nativeMessagePageSchema = external_exports.discriminatedUnion("status", [
|
|
20997
|
-
availableSessionHistoryObjectSchema.extend({ nextCursor: external_exports.string().max(512).nullable() }).readonly(),
|
|
20998
|
-
unavailableSessionHistoryObjectSchema.extend({ nextCursor: external_exports.null() }).readonly()
|
|
20999
|
-
]).refine(withinHistoryContentLimits);
|
|
21000
20991
|
|
|
21001
20992
|
// ../protocol/src/native-sessions.ts
|
|
21002
20993
|
var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
|
|
@@ -21062,10 +21053,7 @@ var identity = {
|
|
|
21062
21053
|
directoryId
|
|
21063
21054
|
};
|
|
21064
21055
|
var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
21065
|
-
external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
21066
21056
|
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
21067
|
-
external_exports.object({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
|
|
21068
|
-
external_exports.object({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
|
|
21069
21057
|
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
21070
21058
|
external_exports.object({
|
|
21071
21059
|
...identity,
|
|
@@ -21091,10 +21079,7 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
|
21091
21079
|
}).readonly()
|
|
21092
21080
|
]);
|
|
21093
21081
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
21094
|
-
external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
21095
21082
|
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
21096
|
-
external_exports.object({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
|
|
21097
|
-
external_exports.object({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
|
|
21098
21083
|
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
21099
21084
|
external_exports.object({
|
|
21100
21085
|
...identity,
|
|
@@ -21134,7 +21119,6 @@ var resultEnvelope = {
|
|
|
21134
21119
|
kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
|
|
21135
21120
|
};
|
|
21136
21121
|
var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
21137
|
-
external_exports.object({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
21138
21122
|
external_exports.object({
|
|
21139
21123
|
...resultEnvelope,
|
|
21140
21124
|
action: external_exports.literal("active-turn"),
|
|
@@ -21167,22 +21151,6 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
21167
21151
|
ready: sessionReadyEventSchema,
|
|
21168
21152
|
title: external_exports.string().max(500)
|
|
21169
21153
|
}).readonly(),
|
|
21170
|
-
external_exports.object({
|
|
21171
|
-
...resultEnvelope,
|
|
21172
|
-
action: external_exports.literal("preview"),
|
|
21173
|
-
entryId: identifierStringSchema,
|
|
21174
|
-
targetSessionId: identifierStringSchema,
|
|
21175
|
-
reason: external_exports.enum(["continuation_unavailable", "requested"]),
|
|
21176
|
-
history: sessionHistorySchema,
|
|
21177
|
-
title: external_exports.string().max(500)
|
|
21178
|
-
}).readonly(),
|
|
21179
|
-
external_exports.object({
|
|
21180
|
-
...resultEnvelope,
|
|
21181
|
-
action: external_exports.literal("history"),
|
|
21182
|
-
entryId: identifierStringSchema,
|
|
21183
|
-
history: sessionHistorySchema,
|
|
21184
|
-
title: external_exports.string().max(500)
|
|
21185
|
-
}).readonly(),
|
|
21186
21154
|
external_exports.object({
|
|
21187
21155
|
...resultEnvelope,
|
|
21188
21156
|
action: external_exports.literal("delete"),
|
|
@@ -21753,28 +21721,9 @@ function decodeRecordedSessionEvent(encoded) {
|
|
|
21753
21721
|
var encodeRecordedSessionEvent = (event) => JSON.stringify(decodeRecordedSessionEvent(JSON.stringify(event)));
|
|
21754
21722
|
|
|
21755
21723
|
// ../protocol/src/session-live-history.ts
|
|
21756
|
-
var SESSION_LIVE_HISTORY_PAGE_LOAD_KIND = "session.live-history.page.load";
|
|
21757
|
-
var SESSION_LIVE_HISTORY_PAGE_LOADED_KIND = "session.live-history.page.loaded";
|
|
21758
21724
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
|
|
21759
21725
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
|
|
21760
21726
|
var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
|
|
21761
|
-
var sessionLiveHistoryPageLoadSchema = external_exports.object({
|
|
21762
|
-
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
21763
|
-
agentId: identifierStringSchema,
|
|
21764
|
-
bindingId: identifierStringSchema,
|
|
21765
|
-
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21766
|
-
directoryId: directoryIdentifier,
|
|
21767
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOAD_KIND),
|
|
21768
|
-
limit: external_exports.number().int().min(1).max(100),
|
|
21769
|
-
requestId: identifierStringSchema,
|
|
21770
|
-
sessionId: identifierStringSchema
|
|
21771
|
-
}).readonly();
|
|
21772
|
-
var sessionLiveHistoryPageLoadedSchema = external_exports.object({
|
|
21773
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOADED_KIND),
|
|
21774
|
-
page: nativeMessagePageSchema,
|
|
21775
|
-
requestId: identifierStringSchema,
|
|
21776
|
-
sessionId: identifierStringSchema
|
|
21777
|
-
}).readonly();
|
|
21778
21727
|
var sessionLiveHistoryV2PageLoadSchema = external_exports.object({
|
|
21779
21728
|
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
21780
21729
|
agentId: identifierStringSchema,
|
|
@@ -21800,10 +21749,6 @@ function decode7(schema, encoded) {
|
|
|
21800
21749
|
throw new ProtocolMessageError("Invalid live Session history message", { cause });
|
|
21801
21750
|
}
|
|
21802
21751
|
}
|
|
21803
|
-
var decodeSessionLiveHistoryPageLoad = (encoded) => decode7(sessionLiveHistoryPageLoadSchema, encoded);
|
|
21804
|
-
var decodeSessionLiveHistoryPageLoaded = (encoded) => decode7(sessionLiveHistoryPageLoadedSchema, encoded);
|
|
21805
|
-
var encodeSessionLiveHistoryPageLoad = (value) => JSON.stringify(sessionLiveHistoryPageLoadSchema.parse(value));
|
|
21806
|
-
var encodeSessionLiveHistoryPageLoaded = (value) => JSON.stringify(sessionLiveHistoryPageLoadedSchema.parse(value));
|
|
21807
21752
|
var decodeSessionLiveHistoryV2PageLoad = (encoded) => decode7(sessionLiveHistoryV2PageLoadSchema, encoded);
|
|
21808
21753
|
var decodeSessionLiveHistoryV2PageLoaded = (encoded) => decode7(sessionLiveHistoryV2PageLoadedSchema, encoded);
|
|
21809
21754
|
var encodeSessionLiveHistoryV2PageLoad = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadSchema.parse(value));
|
|
@@ -21820,11 +21765,6 @@ function defineMessageSignature(kind, encoder, decoder) {
|
|
|
21820
21765
|
};
|
|
21821
21766
|
}
|
|
21822
21767
|
var serviceToDaemonSignatures = {
|
|
21823
|
-
[AGENT_CATALOG_REFRESH_KIND]: defineMessageSignature(
|
|
21824
|
-
AGENT_CATALOG_REFRESH_KIND,
|
|
21825
|
-
encodeAgentCatalogRefreshCommand,
|
|
21826
|
-
decodeAgentCatalogRefreshCommand
|
|
21827
|
-
),
|
|
21828
21768
|
[AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
|
|
21829
21769
|
AGENT_INSTALL_CANCEL_KIND,
|
|
21830
21770
|
encodeAgentInstallCancelCommand,
|
|
@@ -21867,6 +21807,7 @@ var serviceToDaemonSignatures = {
|
|
|
21867
21807
|
encodeRuntimeLivenessReadyEvent,
|
|
21868
21808
|
decodeRuntimeLivenessReadyEvent
|
|
21869
21809
|
),
|
|
21810
|
+
[RUNTIME_PING_KIND]: defineMessageSignature(RUNTIME_PING_KIND, encodeRuntimePingCommand, decodeRuntimePingCommand),
|
|
21870
21811
|
[SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
21871
21812
|
SESSION_CANCEL_KIND,
|
|
21872
21813
|
encodeSessionCancelCommand,
|
|
@@ -21882,11 +21823,6 @@ var serviceToDaemonSignatures = {
|
|
|
21882
21823
|
encodeSessionElicitationRespondCommand,
|
|
21883
21824
|
decodeSessionElicitationRespondCommand
|
|
21884
21825
|
),
|
|
21885
|
-
[SESSION_LIVE_HISTORY_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
21886
|
-
SESSION_LIVE_HISTORY_PAGE_LOAD_KIND,
|
|
21887
|
-
encodeSessionLiveHistoryPageLoad,
|
|
21888
|
-
decodeSessionLiveHistoryPageLoad
|
|
21889
|
-
),
|
|
21890
21826
|
[SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
21891
21827
|
SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND,
|
|
21892
21828
|
encodeSessionLiveHistoryV2PageLoad,
|
|
@@ -21928,16 +21864,6 @@ function decodeServiceToDaemonMessage(encoded) {
|
|
|
21928
21864
|
return signature.decoder(encoded);
|
|
21929
21865
|
}
|
|
21930
21866
|
var daemonToServiceSignatures = {
|
|
21931
|
-
[AGENT_CATALOG_REFRESHED_KIND]: defineMessageSignature(
|
|
21932
|
-
AGENT_CATALOG_REFRESHED_KIND,
|
|
21933
|
-
encodeAgentCatalogRefreshedEvent,
|
|
21934
|
-
decodeAgentCatalogRefreshedEvent
|
|
21935
|
-
),
|
|
21936
|
-
[AGENT_CATALOG_REFRESH_FAILED_KIND]: defineMessageSignature(
|
|
21937
|
-
AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
21938
|
-
encodeAgentCatalogRefreshFailedEvent,
|
|
21939
|
-
decodeAgentCatalogRefreshFailedEvent
|
|
21940
|
-
),
|
|
21941
21867
|
[AGENT_INSTALL_CANCELLED_KIND]: defineMessageSignature(
|
|
21942
21868
|
AGENT_INSTALL_CANCELLED_KIND,
|
|
21943
21869
|
encodeAgentInstallCancelledEvent,
|
|
@@ -22007,6 +21933,7 @@ var daemonToServiceSignatures = {
|
|
|
22007
21933
|
encodeRuntimeHeartbeatEvent,
|
|
22008
21934
|
decodeRuntimeHeartbeatEvent
|
|
22009
21935
|
),
|
|
21936
|
+
[RUNTIME_PONG_KIND]: defineMessageSignature(RUNTIME_PONG_KIND, encodeRuntimePongEvent, decodeRuntimePongEvent),
|
|
22010
21937
|
[SESSION_EVENT_KIND]: defineMessageSignature(
|
|
22011
21938
|
SESSION_EVENT_KIND,
|
|
22012
21939
|
encodeSessionEventEnvelope,
|
|
@@ -22022,11 +21949,6 @@ var daemonToServiceSignatures = {
|
|
|
22022
21949
|
encodeSessionOperationFailedEvent,
|
|
22023
21950
|
decodeSessionOperationFailedEvent
|
|
22024
21951
|
),
|
|
22025
|
-
[SESSION_LIVE_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
22026
|
-
SESSION_LIVE_HISTORY_PAGE_LOADED_KIND,
|
|
22027
|
-
encodeSessionLiveHistoryPageLoaded,
|
|
22028
|
-
decodeSessionLiveHistoryPageLoaded
|
|
22029
|
-
),
|
|
22030
21952
|
[SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
22031
21953
|
SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
|
|
22032
21954
|
encodeSessionLiveHistoryV2PageLoaded,
|
|
@@ -32125,9 +32047,6 @@ var LocalExternalContentStore = class {
|
|
|
32125
32047
|
};
|
|
32126
32048
|
|
|
32127
32049
|
// src/native-sessions/chat-agent.ts
|
|
32128
|
-
function supportsNativeChat(agentId) {
|
|
32129
|
-
return agentId === "codex" || agentId === "claude" || agentId === "opencode" || agentId === "pi";
|
|
32130
|
-
}
|
|
32131
32050
|
function isNativeChatSessionId(agentId, sessionId) {
|
|
32132
32051
|
if (!nativeSessionIdSchema.safeParse(sessionId).success) {
|
|
32133
32052
|
return false;
|
|
@@ -40473,7 +40392,6 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
40473
40392
|
child2.removeListener("exit", onExit);
|
|
40474
40393
|
}
|
|
40475
40394
|
}
|
|
40476
|
-
var readCodexHistory = async (agent, cwd, nativeSessionId, signal) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, { detail: "messages" });
|
|
40477
40395
|
var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTurn) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, {
|
|
40478
40396
|
detail: "rich",
|
|
40479
40397
|
...nativeTurn === void 0 ? {} : { nativeTurn }
|
|
@@ -40482,84 +40400,6 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
|
|
|
40482
40400
|
// src/native-sessions/service.ts
|
|
40483
40401
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
40484
40402
|
import { basename as basename5 } from "node:path";
|
|
40485
|
-
|
|
40486
|
-
// src/native-sessions/acp-history.ts
|
|
40487
|
-
async function readAcpHistory(sessions, directories, bindingId, options, nativeSessionId) {
|
|
40488
|
-
let cursor = null;
|
|
40489
|
-
let inspected = 0;
|
|
40490
|
-
for (let pageNumber = 0; pageNumber < 500 && inspected < 500; pageNumber += 1) {
|
|
40491
|
-
const page = await sessions.listNativeSessions(options, cursor);
|
|
40492
|
-
inspected += page.sessions.length;
|
|
40493
|
-
const found = page.sessions.find((entry) => entry.sessionId === nativeSessionId);
|
|
40494
|
-
if (found !== void 0) {
|
|
40495
|
-
const primary = await directories.identify(bindingId, found.cwd, options.signal);
|
|
40496
|
-
const additional = await Promise.all(
|
|
40497
|
-
found.additionalDirectories.map(
|
|
40498
|
-
async (directory) => await directories.identify(bindingId, directory, options.signal)
|
|
40499
|
-
)
|
|
40500
|
-
);
|
|
40501
|
-
if (primary.path !== options.cwd || additional.length !== options.additionalDirectories.length || additional.some((directory, index) => directory.path !== options.additionalDirectories[index])) {
|
|
40502
|
-
throw new AcpExecutionError(
|
|
40503
|
-
"The native Session belongs to another workspace.",
|
|
40504
|
-
{},
|
|
40505
|
-
"session_identity_mismatch"
|
|
40506
|
-
);
|
|
40507
|
-
}
|
|
40508
|
-
return await sessions.previewNativeSession(options, nativeSessionId);
|
|
40509
|
-
}
|
|
40510
|
-
if (page.nextCursor === null || page.nextCursor === cursor) {
|
|
40511
|
-
break;
|
|
40512
|
-
}
|
|
40513
|
-
cursor = page.nextCursor ?? null;
|
|
40514
|
-
}
|
|
40515
|
-
throw new AcpExecutionError("The native Session was not found.", {}, "native_session_not_found");
|
|
40516
|
-
}
|
|
40517
|
-
|
|
40518
|
-
// src/native-sessions/acp-adapter.ts
|
|
40519
|
-
var acpSessionAdapter = {
|
|
40520
|
-
history: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
|
|
40521
|
-
preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
|
|
40522
|
-
};
|
|
40523
|
-
|
|
40524
|
-
// src/native-sessions/codex-adapter.ts
|
|
40525
|
-
async function verifiedHistory(context, full) {
|
|
40526
|
-
const { options, nativeSessionId, directories, bindingId } = context;
|
|
40527
|
-
const snapshot = full ? await readCodexFullHistory(options.agent, options.cwd, nativeSessionId, options.signal) : await readCodexHistory(options.agent, options.cwd, nativeSessionId, options.signal);
|
|
40528
|
-
const resolved = await directories.identify(bindingId, snapshot.cwd, options.signal);
|
|
40529
|
-
if (snapshot.nativeSessionId !== nativeSessionId || resolved.path !== options.cwd) {
|
|
40530
|
-
throw new AcpExecutionError(
|
|
40531
|
-
"Codex returned history for a different session or workspace.",
|
|
40532
|
-
{},
|
|
40533
|
-
"invalid_native_session_response"
|
|
40534
|
-
);
|
|
40535
|
-
}
|
|
40536
|
-
return snapshot.history;
|
|
40537
|
-
}
|
|
40538
|
-
var codexSessionAdapter = {
|
|
40539
|
-
history: async (context) => await verifiedHistory(context, true),
|
|
40540
|
-
// Codex enforces an exclusive writer per thread. Its read-only app-server
|
|
40541
|
-
// history path keeps externally owned conversations previewable.
|
|
40542
|
-
preview: async (context) => await verifiedHistory(context, false)
|
|
40543
|
-
};
|
|
40544
|
-
|
|
40545
|
-
// src/native-sessions/agent-adapter.ts
|
|
40546
|
-
var genericSessionAdapter = {
|
|
40547
|
-
history: async () => {
|
|
40548
|
-
throw new AcpExecutionError("Native history is unavailable for this Agent", {}, "native_session_unsupported");
|
|
40549
|
-
},
|
|
40550
|
-
preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
|
|
40551
|
-
};
|
|
40552
|
-
function nativeSessionAdapter(agentId) {
|
|
40553
|
-
if (agentId === "codex") {
|
|
40554
|
-
return codexSessionAdapter;
|
|
40555
|
-
}
|
|
40556
|
-
if (agentId === "claude" || agentId === "opencode" || agentId === "pi") {
|
|
40557
|
-
return acpSessionAdapter;
|
|
40558
|
-
}
|
|
40559
|
-
return genericSessionAdapter;
|
|
40560
|
-
}
|
|
40561
|
-
|
|
40562
|
-
// src/native-sessions/service.ts
|
|
40563
40403
|
var NativeSessionService = class {
|
|
40564
40404
|
#entries = /* @__PURE__ */ new Map();
|
|
40565
40405
|
#cursors = /* @__PURE__ */ new Map();
|
|
@@ -40603,25 +40443,6 @@ var NativeSessionService = class {
|
|
|
40603
40443
|
...await this.#activeTurn(command, options)
|
|
40604
40444
|
};
|
|
40605
40445
|
}
|
|
40606
|
-
if (command.action === "create") {
|
|
40607
|
-
if (!supportsNativeChat(options.agent.id)) {
|
|
40608
|
-
throw new AcpExecutionError(
|
|
40609
|
-
"Native session creation is unavailable for this Agent",
|
|
40610
|
-
{},
|
|
40611
|
-
"native_session_unsupported"
|
|
40612
|
-
);
|
|
40613
|
-
}
|
|
40614
|
-
const nativeSessionId = await this.#sessions.createNativeSession(options);
|
|
40615
|
-
signal.throwIfAborted();
|
|
40616
|
-
this.record(command, "native_session_created");
|
|
40617
|
-
return {
|
|
40618
|
-
action: "create",
|
|
40619
|
-
kind: "native.session.result",
|
|
40620
|
-
nativeSessionId: decodeIdentifier(nativeSessionId),
|
|
40621
|
-
requestId: command.requestId,
|
|
40622
|
-
sessionId: command.sessionId
|
|
40623
|
-
};
|
|
40624
|
-
}
|
|
40625
40446
|
if (command.action === "fork-recorded") {
|
|
40626
40447
|
const source = this.#sessions.findSessions([command.sessionId])[0];
|
|
40627
40448
|
if (source === void 0 || !source.prompted) {
|
|
@@ -40814,44 +40635,6 @@ var NativeSessionService = class {
|
|
|
40814
40635
|
);
|
|
40815
40636
|
}
|
|
40816
40637
|
const target = await this.resolveTarget(command, options, selected);
|
|
40817
|
-
if (command.action === "history") {
|
|
40818
|
-
const history = await nativeSessionAdapter(options.agent.id).history({
|
|
40819
|
-
sessions: this.#sessions,
|
|
40820
|
-
directories: this.#directories,
|
|
40821
|
-
bindingId: command.bindingId,
|
|
40822
|
-
options: { ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
40823
|
-
nativeSessionId: target.info.sessionId
|
|
40824
|
-
});
|
|
40825
|
-
signal.throwIfAborted();
|
|
40826
|
-
this.record(command, "native_session_history_read");
|
|
40827
|
-
return {
|
|
40828
|
-
...envelope2,
|
|
40829
|
-
action: "history",
|
|
40830
|
-
entryId: command.entryId,
|
|
40831
|
-
history,
|
|
40832
|
-
title: target.info.title ?? "Untitled session"
|
|
40833
|
-
};
|
|
40834
|
-
}
|
|
40835
|
-
if (command.action === "preview") {
|
|
40836
|
-
const history = await nativeSessionAdapter(options.agent.id).preview({
|
|
40837
|
-
sessions: this.#sessions,
|
|
40838
|
-
directories: this.#directories,
|
|
40839
|
-
bindingId: command.bindingId,
|
|
40840
|
-
options: { ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
40841
|
-
nativeSessionId: target.info.sessionId
|
|
40842
|
-
});
|
|
40843
|
-
signal.throwIfAborted();
|
|
40844
|
-
this.record(command, "native_session_previewed");
|
|
40845
|
-
return {
|
|
40846
|
-
...envelope2,
|
|
40847
|
-
action: "preview",
|
|
40848
|
-
entryId: command.entryId,
|
|
40849
|
-
targetSessionId: command.sessionId,
|
|
40850
|
-
reason: "requested",
|
|
40851
|
-
title: target.info.title ?? "Untitled session",
|
|
40852
|
-
history
|
|
40853
|
-
};
|
|
40854
|
-
}
|
|
40855
40638
|
if (command.action === "delete") {
|
|
40856
40639
|
if (!prepared.capabilities.deleteSession) {
|
|
40857
40640
|
throw new AcpExecutionError(
|
|
@@ -41255,135 +41038,13 @@ var RelayConnectionDiagnostics = class {
|
|
|
41255
41038
|
};
|
|
41256
41039
|
|
|
41257
41040
|
// src/relay-connection/run-relay-connection.ts
|
|
41258
|
-
import { WebSocket as
|
|
41041
|
+
import { WebSocket as WebSocket7 } from "undici";
|
|
41259
41042
|
|
|
41260
41043
|
// src/daemon-command-handler.ts
|
|
41261
|
-
import { WebSocket as
|
|
41262
|
-
|
|
41263
|
-
// src/agent-catalog/handle-agent-catalog-refresh.ts
|
|
41264
|
-
import { WebSocket as WebSocket3 } from "undici";
|
|
41265
|
-
async function retainStillInstalledAgents(previous, refreshed, signal) {
|
|
41266
|
-
const refreshedIdentifiers = new Set(refreshed.map((agent) => agent.id));
|
|
41267
|
-
const retained = [];
|
|
41268
|
-
for (const agent of previous) {
|
|
41269
|
-
if (refreshedIdentifiers.has(agent.id)) {
|
|
41270
|
-
continue;
|
|
41271
|
-
}
|
|
41272
|
-
signal.throwIfAborted();
|
|
41273
|
-
if (await revalidateExecutable(agent.agentIdentity)) {
|
|
41274
|
-
retained.push(agent);
|
|
41275
|
-
}
|
|
41276
|
-
}
|
|
41277
|
-
return Object.freeze([...refreshed, ...retained]);
|
|
41278
|
-
}
|
|
41279
|
-
async function refreshAgentCatalog(config2, resolveEnvironment, signal) {
|
|
41280
|
-
signal.throwIfAborted();
|
|
41281
|
-
const shellEnvironment = await resolveEnvironment(signal);
|
|
41282
|
-
const environment = new DaemonLocalContext(config2.localContext.stateDirectory, shellEnvironment).environment;
|
|
41283
|
-
signal.throwIfAborted();
|
|
41284
|
-
const inventory = await discoverLocalAgentInventory({
|
|
41285
|
-
defaultWorkspace: config2.defaultWorkspace,
|
|
41286
|
-
environment,
|
|
41287
|
-
signal
|
|
41288
|
-
});
|
|
41289
|
-
const previousCatalog = config2.catalog.read();
|
|
41290
|
-
const refreshedAgents = inventory.readyAgents().map((agent) => withDaemonEnvironment(agent, environment));
|
|
41291
|
-
const agents = await retainStillInstalledAgents(previousCatalog.agents, refreshedAgents, signal);
|
|
41292
|
-
const verifiedIdentifiers = new Set(agents.map((agent) => agent.id));
|
|
41293
|
-
config2.catalog.transition(
|
|
41294
|
-
agents,
|
|
41295
|
-
inventory.installable.filter((agent) => !verifiedIdentifiers.has(agent.id))
|
|
41296
|
-
);
|
|
41297
|
-
try {
|
|
41298
|
-
await publishAgentCatalog(config2, signal);
|
|
41299
|
-
} catch (error62) {
|
|
41300
|
-
config2.catalog.transition(previousCatalog.agents, previousCatalog.installableAgents);
|
|
41301
|
-
throw error62;
|
|
41302
|
-
}
|
|
41303
|
-
}
|
|
41304
|
-
function createAgentCatalogRefreshHandler(dependencies) {
|
|
41305
|
-
const { config: config2, audit, diagnostics, socket, signal, timer, resolveEnvironment } = dependencies;
|
|
41306
|
-
const agentCatalogRefreshes = /* @__PURE__ */ new Map();
|
|
41307
|
-
const handle = (command) => {
|
|
41308
|
-
if (agentCatalogRefreshes.has(command.requestId) || agentCatalogRefreshes.size > 0) {
|
|
41309
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
41310
|
-
send(socket, {
|
|
41311
|
-
code: "agent_catalog_refresh_busy",
|
|
41312
|
-
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
41313
|
-
message: "Another local Agent catalog refresh is already running",
|
|
41314
|
-
requestId: command.requestId
|
|
41315
|
-
});
|
|
41316
|
-
}
|
|
41317
|
-
return;
|
|
41318
|
-
}
|
|
41319
|
-
const controller = new AbortController();
|
|
41320
|
-
const operationSignal = AbortSignal.any([signal, controller.signal]);
|
|
41321
|
-
const timeout = timer.schedule(
|
|
41322
|
-
() => controller.abort(
|
|
41323
|
-
new AcpExecutionError(
|
|
41324
|
-
"The local Agent catalog refresh timed out",
|
|
41325
|
-
{},
|
|
41326
|
-
"agent_catalog_refresh_timeout"
|
|
41327
|
-
)
|
|
41328
|
-
),
|
|
41329
|
-
9e4
|
|
41330
|
-
);
|
|
41331
|
-
const completion = (async () => {
|
|
41332
|
-
try {
|
|
41333
|
-
await refreshAgentCatalog(config2, resolveEnvironment, operationSignal);
|
|
41334
|
-
audit.record({
|
|
41335
|
-
commandId: command.requestId,
|
|
41336
|
-
event: "agent_catalog_refreshed",
|
|
41337
|
-
sessionId: "agent-catalog"
|
|
41338
|
-
});
|
|
41339
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
41340
|
-
send(socket, {
|
|
41341
|
-
kind: AGENT_CATALOG_REFRESHED_KIND,
|
|
41342
|
-
requestId: command.requestId
|
|
41343
|
-
});
|
|
41344
|
-
}
|
|
41345
|
-
} catch (error62) {
|
|
41346
|
-
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
41347
|
-
"The local Agent catalog refresh was cancelled",
|
|
41348
|
-
{},
|
|
41349
|
-
"agent_catalog_refresh_cancelled"
|
|
41350
|
-
) : error62;
|
|
41351
|
-
audit.record({
|
|
41352
|
-
commandId: command.requestId,
|
|
41353
|
-
details: { code: operationErrorCode(failure2) },
|
|
41354
|
-
event: "agent_catalog_refresh_failed",
|
|
41355
|
-
sessionId: "agent-catalog"
|
|
41356
|
-
});
|
|
41357
|
-
diagnostics.daemonDiagnostic(
|
|
41358
|
-
"agent_catalog_refresh_failed",
|
|
41359
|
-
command.requestId,
|
|
41360
|
-
{ code: operationErrorCode(failure2) },
|
|
41361
|
-
failure2
|
|
41362
|
-
);
|
|
41363
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
41364
|
-
send(socket, {
|
|
41365
|
-
code: operationErrorCode(failure2),
|
|
41366
|
-
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
41367
|
-
message: operationErrorMessage(failure2),
|
|
41368
|
-
requestId: command.requestId
|
|
41369
|
-
});
|
|
41370
|
-
}
|
|
41371
|
-
} finally {
|
|
41372
|
-
timeout.cancel();
|
|
41373
|
-
agentCatalogRefreshes.delete(command.requestId);
|
|
41374
|
-
}
|
|
41375
|
-
})();
|
|
41376
|
-
agentCatalogRefreshes.set(command.requestId, { completion, controller });
|
|
41377
|
-
return;
|
|
41378
|
-
};
|
|
41379
|
-
const settle2 = async () => {
|
|
41380
|
-
await Promise.all([...agentCatalogRefreshes.values()].map((request) => request.completion));
|
|
41381
|
-
};
|
|
41382
|
-
return { handle, settle: settle2 };
|
|
41383
|
-
}
|
|
41044
|
+
import { WebSocket as WebSocket5 } from "undici";
|
|
41384
41045
|
|
|
41385
41046
|
// src/agent-catalog/handle-agent-settings-discovery.ts
|
|
41386
|
-
import { WebSocket as
|
|
41047
|
+
import { WebSocket as WebSocket3 } from "undici";
|
|
41387
41048
|
|
|
41388
41049
|
// src/agent-catalog/discover-agent-settings.ts
|
|
41389
41050
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -41871,7 +41532,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41871
41532
|
(request) => request.agentId === command.agentId && !request.controller.signal.aborted
|
|
41872
41533
|
);
|
|
41873
41534
|
if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
|
|
41874
|
-
if (socket.readyState ===
|
|
41535
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
41875
41536
|
send(socket, {
|
|
41876
41537
|
code: "agent_settings_discovery_busy",
|
|
41877
41538
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -41886,7 +41547,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41886
41547
|
return;
|
|
41887
41548
|
}
|
|
41888
41549
|
if (existing !== void 0) {
|
|
41889
|
-
if (socket.readyState ===
|
|
41550
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
41890
41551
|
send(socket, {
|
|
41891
41552
|
code: "agent_settings_discovery_busy",
|
|
41892
41553
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -41897,7 +41558,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41897
41558
|
return;
|
|
41898
41559
|
}
|
|
41899
41560
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
41900
|
-
if (socket.readyState ===
|
|
41561
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
41901
41562
|
send(socket, {
|
|
41902
41563
|
code: "agent_settings_discovery_busy",
|
|
41903
41564
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -41943,7 +41604,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41943
41604
|
event: "agent_settings_discovered",
|
|
41944
41605
|
sessionId: `agent-settings:${command.agentId}`
|
|
41945
41606
|
});
|
|
41946
|
-
if (socket.readyState ===
|
|
41607
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
41947
41608
|
send(socket, { ...result.event, requestId });
|
|
41948
41609
|
}
|
|
41949
41610
|
}
|
|
@@ -41969,7 +41630,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41969
41630
|
`
|
|
41970
41631
|
);
|
|
41971
41632
|
}
|
|
41972
|
-
if (socket.readyState ===
|
|
41633
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
41973
41634
|
for (const requestId of requestIds) {
|
|
41974
41635
|
send(socket, {
|
|
41975
41636
|
code: operationErrorCode(failure2),
|
|
@@ -42115,300 +41776,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
42115
41776
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
42116
41777
|
}
|
|
42117
41778
|
|
|
42118
|
-
// src/native-sessions/live-history-page.ts
|
|
42119
|
-
function encodeLiveHistoryCursor(cursor) {
|
|
42120
|
-
return Buffer.from(JSON.stringify(cursor), "utf8").toString("base64url");
|
|
42121
|
-
}
|
|
42122
|
-
function decodeLiveHistoryCursor(cursor, sessionId) {
|
|
42123
|
-
try {
|
|
42124
|
-
if (!/^[A-Za-z0-9_-]{1,512}$/u.test(cursor)) {
|
|
42125
|
-
throw new Error("Invalid cursor alphabet");
|
|
42126
|
-
}
|
|
42127
|
-
const value = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
42128
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
42129
|
-
throw new Error("Invalid cursor shape");
|
|
42130
|
-
}
|
|
42131
|
-
const record2 = Object.fromEntries(Object.entries(value));
|
|
42132
|
-
const keys = Object.keys(record2).sort().join(",");
|
|
42133
|
-
const legacyNative = keys === "endIndex,sessionId";
|
|
42134
|
-
const kind = legacyNative ? "native" : record2["kind"];
|
|
42135
|
-
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) {
|
|
42136
|
-
throw new Error("Invalid cursor target");
|
|
42137
|
-
}
|
|
42138
|
-
if (kind === "active") {
|
|
42139
|
-
if (keys !== "endIndex,epoch,kind,sessionId" || typeof record2["epoch"] !== "string") {
|
|
42140
|
-
throw new Error("Invalid active cursor target");
|
|
42141
|
-
}
|
|
42142
|
-
return { endIndex: record2["endIndex"], epoch: record2["epoch"], kind, sessionId };
|
|
42143
|
-
}
|
|
42144
|
-
if (keys !== "endIndex,kind,sessionId" && !legacyNative) {
|
|
42145
|
-
throw new Error("Invalid native cursor target");
|
|
42146
|
-
}
|
|
42147
|
-
return { endIndex: record2["endIndex"], kind, sessionId };
|
|
42148
|
-
} catch (cause) {
|
|
42149
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", { cause }, "invalid_cursor");
|
|
42150
|
-
}
|
|
42151
|
-
}
|
|
42152
|
-
function activeHistoryCursor(sessionId, epoch, endIndex) {
|
|
42153
|
-
return encodeLiveHistoryCursor({ endIndex, epoch, kind: "active", sessionId });
|
|
42154
|
-
}
|
|
42155
|
-
function nativeHistoryCursor(sessionId, endIndex) {
|
|
42156
|
-
return encodeLiveHistoryCursor({ endIndex, kind: "native", sessionId });
|
|
42157
|
-
}
|
|
42158
|
-
function liveHistoryCoveredTurnRanges(history) {
|
|
42159
|
-
const ranges = [];
|
|
42160
|
-
let historyIndex = history.messages.length;
|
|
42161
|
-
for (const commandId of history.coveredCommandIds) {
|
|
42162
|
-
let assistantStartIndex = historyIndex;
|
|
42163
|
-
while (assistantStartIndex > 0 && history.messages[assistantStartIndex - 1]?.role === "assistant") {
|
|
42164
|
-
assistantStartIndex -= 1;
|
|
42165
|
-
}
|
|
42166
|
-
const userIndex = assistantStartIndex - 1;
|
|
42167
|
-
if (assistantStartIndex === historyIndex || history.messages[userIndex]?.role !== "user") {
|
|
42168
|
-
break;
|
|
42169
|
-
}
|
|
42170
|
-
ranges.push({ assistantEndIndex: historyIndex, assistantStartIndex, commandId, userIndex });
|
|
42171
|
-
historyIndex = userIndex;
|
|
42172
|
-
}
|
|
42173
|
-
return ranges;
|
|
42174
|
-
}
|
|
42175
|
-
function historyMessageCharacters(message) {
|
|
42176
|
-
return message.text.length + (message.role === "assistant" ? JSON.stringify(message.activities).length + JSON.stringify(message.content).length : 0);
|
|
42177
|
-
}
|
|
42178
|
-
function isNativeHistoryImageMimeType(mimeType) {
|
|
42179
|
-
return mimeType === "image/png" || mimeType === "image/jpeg" || mimeType === "image/gif" || mimeType === "image/webp";
|
|
42180
|
-
}
|
|
42181
|
-
function selectMessagesBefore(messages, endIndex, messageLimit, characterLimit) {
|
|
42182
|
-
const selected = [];
|
|
42183
|
-
let remainingCharacters = characterLimit;
|
|
42184
|
-
let startIndex = endIndex;
|
|
42185
|
-
for (let index = endIndex - 1; index >= 0 && selected.length < messageLimit; index -= 1) {
|
|
42186
|
-
const message = messages[index];
|
|
42187
|
-
if (message === void 0) {
|
|
42188
|
-
break;
|
|
42189
|
-
}
|
|
42190
|
-
const characters = historyMessageCharacters(message);
|
|
42191
|
-
if (characters > remainingCharacters) {
|
|
42192
|
-
break;
|
|
42193
|
-
}
|
|
42194
|
-
selected.unshift(message);
|
|
42195
|
-
remainingCharacters -= characters;
|
|
42196
|
-
startIndex = index;
|
|
42197
|
-
}
|
|
42198
|
-
if (selected.length === 0 && endIndex > 0) {
|
|
42199
|
-
throw new AcpExecutionError(
|
|
42200
|
-
"A native Session history item exceeds the page budget",
|
|
42201
|
-
{},
|
|
42202
|
-
"history_item_too_large"
|
|
42203
|
-
);
|
|
42204
|
-
}
|
|
42205
|
-
return { characters: characterLimit - remainingCharacters, messages: selected, startIndex };
|
|
42206
|
-
}
|
|
42207
|
-
function nativeActiveMessage(message) {
|
|
42208
|
-
if (message.role === "assistant") {
|
|
42209
|
-
return {
|
|
42210
|
-
activities: message.activities,
|
|
42211
|
-
content: message.content,
|
|
42212
|
-
role: "assistant",
|
|
42213
|
-
text: message.text
|
|
42214
|
-
};
|
|
42215
|
-
}
|
|
42216
|
-
const images = (message.images ?? []).flatMap((image) => {
|
|
42217
|
-
if (image.data.length < 4 || image.data.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/u.test(image.data) || !isNativeHistoryImageMimeType(image.mimeType)) {
|
|
42218
|
-
return [];
|
|
42219
|
-
}
|
|
42220
|
-
return [{ data: image.data, mimeType: image.mimeType, name: image.name }];
|
|
42221
|
-
});
|
|
42222
|
-
return { ...images.length === 0 ? {} : { images }, role: "user", text: message.text };
|
|
42223
|
-
}
|
|
42224
|
-
function nativeHistoryCoversCompletedRecovery(history, recovery) {
|
|
42225
|
-
const root = recovery.messages.find((message) => message.role === "user" && message.id === recovery.commandId);
|
|
42226
|
-
if (root === void 0) {
|
|
42227
|
-
return false;
|
|
42228
|
-
}
|
|
42229
|
-
const rootIndex = history.messages.findLastIndex(
|
|
42230
|
-
(message) => message.role === "user" && message.text === root.text
|
|
42231
|
-
);
|
|
42232
|
-
if (rootIndex < 0) {
|
|
42233
|
-
return false;
|
|
42234
|
-
}
|
|
42235
|
-
const nativeAssistant = history.messages.slice(rootIndex + 1).filter((message) => message.role === "assistant");
|
|
42236
|
-
if (nativeAssistant.length === 0) {
|
|
42237
|
-
return false;
|
|
42238
|
-
}
|
|
42239
|
-
const recoveryAssistant = recovery.messages.filter((message) => message.role === "assistant");
|
|
42240
|
-
const recoveryText = recoveryAssistant.map((message) => message.text).join("");
|
|
42241
|
-
const nativeText = nativeAssistant.map((message) => message.text).join("");
|
|
42242
|
-
if (recoveryText.length > 0 && !nativeText.includes(recoveryText)) {
|
|
42243
|
-
return false;
|
|
42244
|
-
}
|
|
42245
|
-
const nativeContent = new Set(
|
|
42246
|
-
nativeAssistant.flatMap((message) => message.content).map((content) => JSON.stringify(content))
|
|
42247
|
-
);
|
|
42248
|
-
return recoveryAssistant.flatMap((message) => message.content).every((content) => nativeContent.has(JSON.stringify(content)));
|
|
42249
|
-
}
|
|
42250
|
-
function historyBeforeActiveTurn(history, activeTurn) {
|
|
42251
|
-
if (history.status === "unavailable") {
|
|
42252
|
-
return history;
|
|
42253
|
-
}
|
|
42254
|
-
const activeRoot = activeTurn.messages.find(
|
|
42255
|
-
(message) => message.role === "user" && message.id === activeTurn.commandId
|
|
42256
|
-
);
|
|
42257
|
-
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;
|
|
42258
|
-
const activeUserIndex = matchingActiveUserIndex >= 0 ? matchingActiveUserIndex : liveHistoryCoveredTurnRanges(history).find((range) => range.commandId === activeTurn.commandId)?.userIndex ?? -1;
|
|
42259
|
-
if (activeUserIndex < 0) {
|
|
42260
|
-
return history;
|
|
42261
|
-
}
|
|
42262
|
-
return {
|
|
42263
|
-
...history,
|
|
42264
|
-
coveredCommandIds: history.coveredCommandIds.filter((id) => id !== activeTurn.commandId),
|
|
42265
|
-
coveredMessageIds: history.coveredMessageIds.filter(
|
|
42266
|
-
(id) => id !== `${activeTurn.commandId}:user` && id !== `${activeTurn.commandId}:agent`
|
|
42267
|
-
),
|
|
42268
|
-
messages: history.messages.slice(0, activeUserIndex)
|
|
42269
|
-
};
|
|
42270
|
-
}
|
|
42271
|
-
function paginateAvailableNativeHistory(history, sessionId, endIndex, limit, characterLimit) {
|
|
42272
|
-
if (endIndex > history.messages.length) {
|
|
42273
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
42274
|
-
}
|
|
42275
|
-
const selected = selectMessagesBefore(history.messages, endIndex, limit, characterLimit);
|
|
42276
|
-
const coveredMessageIds = new Set(history.coveredMessageIds);
|
|
42277
|
-
const ranges = liveHistoryCoveredTurnRanges(history);
|
|
42278
|
-
return {
|
|
42279
|
-
coveredCommandIds: ranges.filter((range) => range.userIndex >= selected.startIndex && range.assistantEndIndex <= endIndex).map((range) => range.commandId),
|
|
42280
|
-
coveredMessageIds: ranges.flatMap((range) => [
|
|
42281
|
-
...range.userIndex >= selected.startIndex && range.userIndex < endIndex && coveredMessageIds.has(`${range.commandId}:user`) ? [`${range.commandId}:user`] : [],
|
|
42282
|
-
...range.assistantStartIndex >= selected.startIndex && range.assistantEndIndex <= endIndex && coveredMessageIds.has(`${range.commandId}:agent`) ? [`${range.commandId}:agent`] : []
|
|
42283
|
-
]),
|
|
42284
|
-
messages: selected.messages,
|
|
42285
|
-
nextCursor: selected.startIndex > 0 ? nativeHistoryCursor(sessionId, selected.startIndex) : null,
|
|
42286
|
-
status: "available",
|
|
42287
|
-
truncated: history.truncated
|
|
42288
|
-
};
|
|
42289
|
-
}
|
|
42290
|
-
function paginateNativeHistory(history, sessionId, cursor, limit) {
|
|
42291
|
-
if (cursor?.kind === "active") {
|
|
42292
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
42293
|
-
}
|
|
42294
|
-
if (history.status === "unavailable") {
|
|
42295
|
-
if (cursor !== null) {
|
|
42296
|
-
throw new AcpExecutionError("Unavailable native Session history has no cursor", {}, "invalid_cursor");
|
|
42297
|
-
}
|
|
42298
|
-
return { cause: history.cause, nextCursor: null, status: "unavailable" };
|
|
42299
|
-
}
|
|
42300
|
-
return paginateAvailableNativeHistory(
|
|
42301
|
-
history,
|
|
42302
|
-
sessionId,
|
|
42303
|
-
cursor?.endIndex ?? history.messages.length,
|
|
42304
|
-
limit,
|
|
42305
|
-
SESSION_HISTORY_CHARACTER_LIMIT
|
|
42306
|
-
);
|
|
42307
|
-
}
|
|
42308
|
-
function paginateActiveTurn(history, activeTurn, sessionId, endIndex, limit) {
|
|
42309
|
-
if (endIndex > activeTurn.messages.length) {
|
|
42310
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
42311
|
-
}
|
|
42312
|
-
const activeMessages = activeTurn.messages.map(nativeActiveMessage);
|
|
42313
|
-
const active = selectMessagesBefore(activeMessages, endIndex, limit, SESSION_HISTORY_CHARACTER_LIMIT);
|
|
42314
|
-
const historicalLimit = limit - active.messages.length;
|
|
42315
|
-
const historicalCharacterLimit = SESSION_HISTORY_CHARACTER_LIMIT - active.characters;
|
|
42316
|
-
const pendingHistoricalCursor = history.status === "available" && history.messages.length > 0 ? nativeHistoryCursor(sessionId, history.messages.length) : null;
|
|
42317
|
-
const latestHistoricalMessage = history.status === "available" ? history.messages.at(-1) : void 0;
|
|
42318
|
-
const historicalPageFits = latestHistoricalMessage === void 0 || historyMessageCharacters(latestHistoricalMessage) <= historicalCharacterLimit;
|
|
42319
|
-
const historical = active.startIndex === 0 && history.status === "available" && historicalLimit > 0 && historicalPageFits ? paginateAvailableNativeHistory(
|
|
42320
|
-
history,
|
|
42321
|
-
sessionId,
|
|
42322
|
-
history.messages.length,
|
|
42323
|
-
historicalLimit,
|
|
42324
|
-
historicalCharacterLimit
|
|
42325
|
-
) : null;
|
|
42326
|
-
return {
|
|
42327
|
-
streamPosition: { commandId: activeTurn.commandId, epoch: activeTurn.epoch, sequence: activeTurn.sequence },
|
|
42328
|
-
coveredCommandIds: historical?.coveredCommandIds ?? [],
|
|
42329
|
-
coveredMessageIds: [
|
|
42330
|
-
...historical?.coveredMessageIds ?? [],
|
|
42331
|
-
...active.startIndex === 0 ? [`${activeTurn.commandId}:user`, `${activeTurn.commandId}:agent`] : []
|
|
42332
|
-
],
|
|
42333
|
-
messages: [...historical?.messages ?? [], ...active.messages],
|
|
42334
|
-
nextCursor: active.startIndex > 0 ? activeHistoryCursor(sessionId, activeTurn.epoch, active.startIndex) : historical === null ? pendingHistoricalCursor : historical.nextCursor,
|
|
42335
|
-
status: "available",
|
|
42336
|
-
truncated: activeTurn.truncated || (historical?.truncated ?? false)
|
|
42337
|
-
};
|
|
42338
|
-
}
|
|
42339
|
-
function paginateLiveSessionHistory(history, activeTurn, sessionId, encodedCursor, limit) {
|
|
42340
|
-
const cursor = encodedCursor === null ? null : decodeLiveHistoryCursor(encodedCursor, sessionId);
|
|
42341
|
-
if (activeTurn === null || activeTurn.state === "completed" && history.status === "available" && nativeHistoryCoversCompletedRecovery(history, activeTurn)) {
|
|
42342
|
-
return paginateNativeHistory(history, sessionId, cursor, limit);
|
|
42343
|
-
}
|
|
42344
|
-
const historical = historyBeforeActiveTurn(history, activeTurn);
|
|
42345
|
-
if (cursor?.kind === "native") {
|
|
42346
|
-
return paginateNativeHistory(historical, sessionId, cursor, limit);
|
|
42347
|
-
}
|
|
42348
|
-
if (cursor !== null && cursor.epoch !== activeTurn.epoch) {
|
|
42349
|
-
throw new AcpExecutionError("The active Turn history cursor is stale", {}, "stale_cursor");
|
|
42350
|
-
}
|
|
42351
|
-
return paginateActiveTurn(historical, activeTurn, sessionId, cursor?.endIndex ?? activeTurn.messages.length, limit);
|
|
42352
|
-
}
|
|
42353
|
-
|
|
42354
41779
|
// src/daemon-history-commands.ts
|
|
42355
|
-
async function executeSessionLiveHistoryPageLoad(socket, command, config2, directories, audit, sessions, activeTurn, signal) {
|
|
42356
|
-
try {
|
|
42357
|
-
const resolved = await resolveSessionDirectories(
|
|
42358
|
-
directories,
|
|
42359
|
-
config2.bindingId,
|
|
42360
|
-
command.directoryId,
|
|
42361
|
-
command.additionalDirectoryIds,
|
|
42362
|
-
signal
|
|
42363
|
-
);
|
|
42364
|
-
const history = await sessions.loadSessionHistory({
|
|
42365
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
42366
|
-
agent: config2.catalog.find(command.agentId),
|
|
42367
|
-
cwd: resolved.cwd,
|
|
42368
|
-
sessionId: command.sessionId,
|
|
42369
|
-
signal
|
|
42370
|
-
});
|
|
42371
|
-
signal.throwIfAborted();
|
|
42372
|
-
const page = paginateLiveSessionHistory(
|
|
42373
|
-
history,
|
|
42374
|
-
activeTurn(command.sessionId),
|
|
42375
|
-
command.sessionId,
|
|
42376
|
-
command.cursor,
|
|
42377
|
-
command.limit
|
|
42378
|
-
);
|
|
42379
|
-
audit.record({
|
|
42380
|
-
commandId: command.requestId,
|
|
42381
|
-
event: "session_history_loaded",
|
|
42382
|
-
sessionId: command.sessionId
|
|
42383
|
-
});
|
|
42384
|
-
send(socket, {
|
|
42385
|
-
kind: "session.live-history.page.loaded",
|
|
42386
|
-
page,
|
|
42387
|
-
requestId: command.requestId,
|
|
42388
|
-
sessionId: command.sessionId
|
|
42389
|
-
});
|
|
42390
|
-
} catch (error62) {
|
|
42391
|
-
if (signal.aborted) {
|
|
42392
|
-
return;
|
|
42393
|
-
}
|
|
42394
|
-
audit.record({
|
|
42395
|
-
commandId: command.requestId,
|
|
42396
|
-
details: { code: operationErrorCode(error62) },
|
|
42397
|
-
event: "session_history_unavailable",
|
|
42398
|
-
sessionId: command.sessionId
|
|
42399
|
-
});
|
|
42400
|
-
send(socket, {
|
|
42401
|
-
kind: "session.live-history.page.loaded",
|
|
42402
|
-
page: {
|
|
42403
|
-
status: "unavailable",
|
|
42404
|
-
cause: { code: operationErrorCode(error62), message: operationErrorMessage(error62) },
|
|
42405
|
-
nextCursor: null
|
|
42406
|
-
},
|
|
42407
|
-
requestId: command.requestId,
|
|
42408
|
-
sessionId: command.sessionId
|
|
42409
|
-
});
|
|
42410
|
-
}
|
|
42411
|
-
}
|
|
42412
41780
|
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
|
|
42413
41781
|
try {
|
|
42414
41782
|
const resolved = await resolveSessionDirectories(
|
|
@@ -43179,7 +42547,7 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
43179
42547
|
}
|
|
43180
42548
|
|
|
43181
42549
|
// src/native-sessions/handle-native-requests.ts
|
|
43182
|
-
import { WebSocket as
|
|
42550
|
+
import { WebSocket as WebSocket4 } from "undici";
|
|
43183
42551
|
function createNativeSessionRequestHandler(dependencies) {
|
|
43184
42552
|
const { audit, diagnostics, nativeSessions, publisher, signal, socket, timer } = dependencies;
|
|
43185
42553
|
const pending = /* @__PURE__ */ new Map();
|
|
@@ -43244,7 +42612,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
43244
42612
|
}
|
|
43245
42613
|
]);
|
|
43246
42614
|
}
|
|
43247
|
-
if (socket.readyState ===
|
|
42615
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
43248
42616
|
send(socket, result);
|
|
43249
42617
|
}
|
|
43250
42618
|
} catch (error62) {
|
|
@@ -43303,8 +42671,7 @@ function createDaemonCommandHandler({
|
|
|
43303
42671
|
socket,
|
|
43304
42672
|
signal,
|
|
43305
42673
|
runtimeSignal,
|
|
43306
|
-
timer
|
|
43307
|
-
resolveAgentCatalogEnvironment
|
|
42674
|
+
timer
|
|
43308
42675
|
}) {
|
|
43309
42676
|
const handleSettingsDiscovery = createAgentSettingsDiscoveryHandler({
|
|
43310
42677
|
config: config2,
|
|
@@ -43316,20 +42683,10 @@ function createDaemonCommandHandler({
|
|
|
43316
42683
|
signal,
|
|
43317
42684
|
timer
|
|
43318
42685
|
});
|
|
43319
|
-
const handleCatalogRefresh = createAgentCatalogRefreshHandler({
|
|
43320
|
-
config: config2,
|
|
43321
|
-
audit,
|
|
43322
|
-
diagnostics,
|
|
43323
|
-
socket,
|
|
43324
|
-
signal,
|
|
43325
|
-
timer,
|
|
43326
|
-
resolveEnvironment: resolveAgentCatalogEnvironment
|
|
43327
|
-
});
|
|
43328
42686
|
const queueChanged = (sessionId) => {
|
|
43329
42687
|
publisher.publish(sessionId, { kind: "session.queue.changed", sessionId });
|
|
43330
42688
|
eventLogV2.queueChanged(sessionId);
|
|
43331
42689
|
};
|
|
43332
|
-
const activeTurnRecovery = (sessionId) => activeTurns.recovery((command) => command.sessionId === sessionId);
|
|
43333
42690
|
const nativeRequestHandler = createNativeSessionRequestHandler({
|
|
43334
42691
|
audit,
|
|
43335
42692
|
diagnostics,
|
|
@@ -43342,18 +42699,8 @@ function createDaemonCommandHandler({
|
|
|
43342
42699
|
return {
|
|
43343
42700
|
handle: (message) => {
|
|
43344
42701
|
const kind = message.kind;
|
|
43345
|
-
if (kind ===
|
|
43346
|
-
|
|
43347
|
-
void executeSessionLiveHistoryPageLoad(
|
|
43348
|
-
socket,
|
|
43349
|
-
command2,
|
|
43350
|
-
config2,
|
|
43351
|
-
directories,
|
|
43352
|
-
audit,
|
|
43353
|
-
sessions,
|
|
43354
|
-
activeTurnRecovery,
|
|
43355
|
-
signal
|
|
43356
|
-
);
|
|
42702
|
+
if (kind === RUNTIME_PING_KIND) {
|
|
42703
|
+
send(socket, { kind: RUNTIME_PONG_KIND, requestId: message.requestId });
|
|
43357
42704
|
return;
|
|
43358
42705
|
}
|
|
43359
42706
|
if (kind === SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) {
|
|
@@ -43378,10 +42725,6 @@ function createDaemonCommandHandler({
|
|
|
43378
42725
|
handleSettingsDiscovery.handle(message);
|
|
43379
42726
|
return;
|
|
43380
42727
|
}
|
|
43381
|
-
if (kind === AGENT_CATALOG_REFRESH_KIND) {
|
|
43382
|
-
handleCatalogRefresh.handle(message);
|
|
43383
|
-
return;
|
|
43384
|
-
}
|
|
43385
42728
|
if (kind === NATIVE_SESSION_REQUEST_KIND) {
|
|
43386
42729
|
nativeRequestHandler.handle(message);
|
|
43387
42730
|
return;
|
|
@@ -43395,7 +42738,7 @@ function createDaemonCommandHandler({
|
|
|
43395
42738
|
sessions.findSessions([command2.sessionId])[0]?.cwd ?? null,
|
|
43396
42739
|
externalContent
|
|
43397
42740
|
).catch((error62) => {
|
|
43398
|
-
if (socket.readyState !==
|
|
42741
|
+
if (socket.readyState !== WebSocket5.OPEN || signal.aborted) {
|
|
43399
42742
|
return;
|
|
43400
42743
|
}
|
|
43401
42744
|
send(socket, {
|
|
@@ -43601,17 +42944,13 @@ function createDaemonCommandHandler({
|
|
|
43601
42944
|
});
|
|
43602
42945
|
},
|
|
43603
42946
|
settle: async () => {
|
|
43604
|
-
await Promise.all([
|
|
43605
|
-
nativeRequestHandler.settle(),
|
|
43606
|
-
handleSettingsDiscovery.settle(),
|
|
43607
|
-
handleCatalogRefresh.settle()
|
|
43608
|
-
]);
|
|
42947
|
+
await Promise.all([nativeRequestHandler.settle(), handleSettingsDiscovery.settle()]);
|
|
43609
42948
|
}
|
|
43610
42949
|
};
|
|
43611
42950
|
}
|
|
43612
42951
|
|
|
43613
42952
|
// src/relay-connection/connect.ts
|
|
43614
|
-
import { WebSocket as
|
|
42953
|
+
import { WebSocket as WebSocket6 } from "undici";
|
|
43615
42954
|
var CONNECTION_TIMEOUT_MILLISECONDS = 6e4;
|
|
43616
42955
|
var RelayConnectionError = class extends Error {
|
|
43617
42956
|
code;
|
|
@@ -43629,7 +42968,7 @@ function connectRelay(url2, signal) {
|
|
|
43629
42968
|
const endpoint = new URL(url2);
|
|
43630
42969
|
const headers = runtimeAuthorization(endpoint);
|
|
43631
42970
|
endpoint.searchParams.delete("token");
|
|
43632
|
-
const socket = new
|
|
42971
|
+
const socket = new WebSocket6(endpoint, {
|
|
43633
42972
|
dispatcher: environmentProxyDispatcher,
|
|
43634
42973
|
headers
|
|
43635
42974
|
});
|
|
@@ -43847,8 +43186,7 @@ async function runRelayConnection({
|
|
|
43847
43186
|
diagnostics,
|
|
43848
43187
|
onConnected,
|
|
43849
43188
|
signal,
|
|
43850
|
-
timer
|
|
43851
|
-
resolveAgentCatalogEnvironment
|
|
43189
|
+
timer
|
|
43852
43190
|
}) {
|
|
43853
43191
|
const relayUrl = new URL(config2.relayUrl);
|
|
43854
43192
|
relayUrl.searchParams.set("liveness", "1");
|
|
@@ -43871,8 +43209,7 @@ async function runRelayConnection({
|
|
|
43871
43209
|
socket,
|
|
43872
43210
|
signal: connectionController.signal,
|
|
43873
43211
|
runtimeSignal: signal,
|
|
43874
|
-
timer
|
|
43875
|
-
resolveAgentCatalogEnvironment
|
|
43212
|
+
timer
|
|
43876
43213
|
});
|
|
43877
43214
|
installationObserver.connect(socket);
|
|
43878
43215
|
onConnected();
|
|
@@ -43918,14 +43255,14 @@ async function runRelayConnection({
|
|
|
43918
43255
|
};
|
|
43919
43256
|
const connectionLiveness = new RelayConnectionLiveness(timer, {
|
|
43920
43257
|
send: (message) => {
|
|
43921
|
-
if (socket.readyState !==
|
|
43258
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
43922
43259
|
return false;
|
|
43923
43260
|
}
|
|
43924
43261
|
try {
|
|
43925
43262
|
send(socket, message);
|
|
43926
43263
|
return true;
|
|
43927
43264
|
} catch (error62) {
|
|
43928
|
-
if (socket.readyState !==
|
|
43265
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
43929
43266
|
return false;
|
|
43930
43267
|
}
|
|
43931
43268
|
throw error62;
|
|
@@ -44014,7 +43351,7 @@ async function runRelayConnection({
|
|
|
44014
43351
|
}
|
|
44015
43352
|
|
|
44016
43353
|
// src/relay-connection/session-event-publisher.ts
|
|
44017
|
-
import { WebSocket as
|
|
43354
|
+
import { WebSocket as WebSocket8 } from "undici";
|
|
44018
43355
|
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
44019
43356
|
var DaemonSessionEventPublisher = class {
|
|
44020
43357
|
#socket = null;
|
|
@@ -44031,7 +43368,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
44031
43368
|
};
|
|
44032
43369
|
publish = (sessionId, event) => {
|
|
44033
43370
|
const socket = this.#socket;
|
|
44034
|
-
if (socket === null || socket.readyState !==
|
|
43371
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
44035
43372
|
return;
|
|
44036
43373
|
}
|
|
44037
43374
|
const encoded = encodeDaemonToServiceMessage({
|
|
@@ -44055,7 +43392,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
44055
43392
|
};
|
|
44056
43393
|
publishStatus = (event) => {
|
|
44057
43394
|
const socket = this.#socket;
|
|
44058
|
-
if (socket === null || socket.readyState !==
|
|
43395
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
44059
43396
|
return;
|
|
44060
43397
|
}
|
|
44061
43398
|
const encoded = encodeDaemonToServiceMessage(event);
|
|
@@ -44070,7 +43407,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
44070
43407
|
};
|
|
44071
43408
|
publishV2 = (event) => {
|
|
44072
43409
|
const socket = this.#socket;
|
|
44073
|
-
if (socket === null || socket.readyState !==
|
|
43410
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
44074
43411
|
return;
|
|
44075
43412
|
}
|
|
44076
43413
|
const encoded = encodeDaemonToServiceMessage({ event, kind: SESSION_EVENT_V2_KIND });
|
|
@@ -44309,10 +43646,6 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44309
43646
|
let connectionAnnounced = false;
|
|
44310
43647
|
let catalogPublished = false;
|
|
44311
43648
|
let readinessAnnounced = false;
|
|
44312
|
-
const resolveAgentCatalogEnvironment = options.resolveAgentCatalogEnvironment ?? (async (catalogSignal) => {
|
|
44313
|
-
catalogSignal.throwIfAborted();
|
|
44314
|
-
return config2.localContext.environment;
|
|
44315
|
-
});
|
|
44316
43649
|
const startAutomaticIntegrationProvisioning = () => {
|
|
44317
43650
|
if (!connectionAnnounced || !catalogPublished || automaticIntegrationProvisioningStarted) {
|
|
44318
43651
|
return;
|
|
@@ -44390,8 +43723,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44390
43723
|
announceConnection();
|
|
44391
43724
|
},
|
|
44392
43725
|
signal,
|
|
44393
|
-
timer
|
|
44394
|
-
resolveAgentCatalogEnvironment
|
|
43726
|
+
timer
|
|
44395
43727
|
});
|
|
44396
43728
|
} catch (error62) {
|
|
44397
43729
|
if (signal.aborted) {
|
|
@@ -44560,8 +43892,7 @@ var MobiusRuntimeEngine = class {
|
|
|
44560
43892
|
const audit = new AuditStore();
|
|
44561
43893
|
try {
|
|
44562
43894
|
await runDaemon(this.#config, audit, signal, void 0, {
|
|
44563
|
-
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus }
|
|
44564
|
-
...this.#options.resolveAgentCatalogEnvironment === void 0 ? {} : { resolveAgentCatalogEnvironment: this.#options.resolveAgentCatalogEnvironment }
|
|
43895
|
+
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus }
|
|
44565
43896
|
});
|
|
44566
43897
|
} finally {
|
|
44567
43898
|
audit.close();
|