@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/runtime.js
CHANGED
|
@@ -19789,9 +19789,6 @@ var AGENT_INSTALL_CANCELLED_KIND = "agent.integration.install.cancelled";
|
|
|
19789
19789
|
var AGENT_SETTINGS_DISCOVER_KIND = "agent.settings.discover";
|
|
19790
19790
|
var AGENT_SETTINGS_DISCOVERED_KIND = "agent.settings.discovered";
|
|
19791
19791
|
var AGENT_SETTINGS_DISCOVERY_FAILED_KIND = "agent.settings.discovery.failed";
|
|
19792
|
-
var AGENT_CATALOG_REFRESH_KIND = "agent.catalog.refresh";
|
|
19793
|
-
var AGENT_CATALOG_REFRESHED_KIND = "agent.catalog.refreshed";
|
|
19794
|
-
var AGENT_CATALOG_REFRESH_FAILED_KIND = "agent.catalog.refresh.failed";
|
|
19795
19792
|
var FILE_READ_KIND = "file.read";
|
|
19796
19793
|
var FILE_BEGIN_KIND = "file.begin";
|
|
19797
19794
|
var FILE_CHUNK_KIND = "file.chunk";
|
|
@@ -19953,20 +19950,6 @@ var agentSettingsDiscoveryFailedEventSchema = external_exports.object({
|
|
|
19953
19950
|
message: external_exports.string().min(1).max(500),
|
|
19954
19951
|
requestId: identifierStringSchema
|
|
19955
19952
|
}).readonly();
|
|
19956
|
-
var agentCatalogRefreshCommandSchema = external_exports.object({
|
|
19957
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESH_KIND),
|
|
19958
|
-
requestId: identifierStringSchema
|
|
19959
|
-
}).readonly();
|
|
19960
|
-
var agentCatalogRefreshedEventSchema = external_exports.object({
|
|
19961
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESHED_KIND),
|
|
19962
|
-
requestId: identifierStringSchema
|
|
19963
|
-
}).readonly();
|
|
19964
|
-
var agentCatalogRefreshFailedEventSchema = external_exports.object({
|
|
19965
|
-
code: identifierStringSchema,
|
|
19966
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESH_FAILED_KIND),
|
|
19967
|
-
message: external_exports.string().min(1).max(500),
|
|
19968
|
-
requestId: identifierStringSchema
|
|
19969
|
-
}).readonly();
|
|
19970
19953
|
var sessionConfigurationSelectionSchema = external_exports.object({
|
|
19971
19954
|
booleanValue: external_exports.boolean(),
|
|
19972
19955
|
configId: identifierStringSchema,
|
|
@@ -20371,12 +20354,6 @@ var decodeAgentSettingsDiscoveredEvent = (encoded) => decode3(encoded, agentSett
|
|
|
20371
20354
|
var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
|
|
20372
20355
|
var decodeAgentSettingsDiscoveryFailedEvent = (encoded) => decode3(encoded, agentSettingsDiscoveryFailedEventSchema);
|
|
20373
20356
|
var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
|
|
20374
|
-
var decodeAgentCatalogRefreshCommand = (encoded) => decode3(encoded, agentCatalogRefreshCommandSchema);
|
|
20375
|
-
var encodeAgentCatalogRefreshCommand = (message) => encode3(message, agentCatalogRefreshCommandSchema);
|
|
20376
|
-
var decodeAgentCatalogRefreshedEvent = (encoded) => decode3(encoded, agentCatalogRefreshedEventSchema);
|
|
20377
|
-
var encodeAgentCatalogRefreshedEvent = (message) => encode3(message, agentCatalogRefreshedEventSchema);
|
|
20378
|
-
var decodeAgentCatalogRefreshFailedEvent = (encoded) => decode3(encoded, agentCatalogRefreshFailedEventSchema);
|
|
20379
|
-
var encodeAgentCatalogRefreshFailedEvent = (message) => encode3(message, agentCatalogRefreshFailedEventSchema);
|
|
20380
20357
|
var decodeFileReadCommand = (encoded) => decode3(encoded, fileReadCommandSchema);
|
|
20381
20358
|
var encodeFileReadCommand = (message) => encode3(message, fileReadCommandSchema);
|
|
20382
20359
|
var decodeFileBeginEvent = (encoded) => decode3(encoded, fileBeginEventSchema);
|
|
@@ -20445,6 +20422,8 @@ var SESSION_CANCEL_KIND = "session.cancel";
|
|
|
20445
20422
|
var RUNTIME_LIVENESS_READY_KIND = "runtime.liveness.ready";
|
|
20446
20423
|
var RUNTIME_HEARTBEAT_KIND = "runtime.heartbeat";
|
|
20447
20424
|
var RUNTIME_HEARTBEAT_ACK_KIND = "runtime.heartbeat.ack";
|
|
20425
|
+
var RUNTIME_PING_KIND = "runtime.ping";
|
|
20426
|
+
var RUNTIME_PONG_KIND = "runtime.pong";
|
|
20448
20427
|
var SESSION_STARTED_KIND = "session.started";
|
|
20449
20428
|
var SESSION_QUEUED_KIND = "session.queued";
|
|
20450
20429
|
var AGENT_MESSAGE_DELTA_KIND = "agent.message.delta";
|
|
@@ -20757,6 +20736,16 @@ function decodeRuntimeHeartbeatAckEvent(encoded) {
|
|
|
20757
20736
|
kind: RUNTIME_HEARTBEAT_ACK_KIND
|
|
20758
20737
|
};
|
|
20759
20738
|
}
|
|
20739
|
+
function decodeRuntimePingCommand(encoded) {
|
|
20740
|
+
const value = parseJson2(encoded);
|
|
20741
|
+
assertKind(value, RUNTIME_PING_KIND);
|
|
20742
|
+
return { kind: RUNTIME_PING_KIND, requestId: readIdentifier(value, "requestId") };
|
|
20743
|
+
}
|
|
20744
|
+
function decodeRuntimePongEvent(encoded) {
|
|
20745
|
+
const value = parseJson2(encoded);
|
|
20746
|
+
assertKind(value, RUNTIME_PONG_KIND);
|
|
20747
|
+
return { kind: RUNTIME_PONG_KIND, requestId: readIdentifier(value, "requestId") };
|
|
20748
|
+
}
|
|
20760
20749
|
function decodeSessionStartedEvent(encoded) {
|
|
20761
20750
|
const value = parseJson2(encoded);
|
|
20762
20751
|
assertKind(value, SESSION_STARTED_KIND);
|
|
@@ -20854,6 +20843,12 @@ function encodeRuntimeHeartbeatEvent(message) {
|
|
|
20854
20843
|
function encodeRuntimeHeartbeatAckEvent(message) {
|
|
20855
20844
|
return JSON.stringify(decodeRuntimeHeartbeatAckEvent(JSON.stringify(message)));
|
|
20856
20845
|
}
|
|
20846
|
+
function encodeRuntimePingCommand(message) {
|
|
20847
|
+
return JSON.stringify(decodeRuntimePingCommand(JSON.stringify(message)));
|
|
20848
|
+
}
|
|
20849
|
+
function encodeRuntimePongEvent(message) {
|
|
20850
|
+
return JSON.stringify(decodeRuntimePongEvent(JSON.stringify(message)));
|
|
20851
|
+
}
|
|
20857
20852
|
function decodeAgentActivityNarrationEvent(encoded) {
|
|
20858
20853
|
const value = parseJson2(encoded);
|
|
20859
20854
|
assertKind(value, AGENT_ACTIVITY_NARRATION_KIND);
|
|
@@ -20967,10 +20962,6 @@ function withinHistoryContentLimits(history) {
|
|
|
20967
20962
|
) <= SESSION_HISTORY_IMAGE_CHARACTER_LIMIT;
|
|
20968
20963
|
}
|
|
20969
20964
|
var sessionHistorySchema = external_exports.discriminatedUnion("status", [availableSessionHistorySchema, unavailableSessionHistorySchema]).refine(withinHistoryContentLimits);
|
|
20970
|
-
var nativeMessagePageSchema = external_exports.discriminatedUnion("status", [
|
|
20971
|
-
availableSessionHistoryObjectSchema.extend({ nextCursor: external_exports.string().max(512).nullable() }).readonly(),
|
|
20972
|
-
unavailableSessionHistoryObjectSchema.extend({ nextCursor: external_exports.null() }).readonly()
|
|
20973
|
-
]).refine(withinHistoryContentLimits);
|
|
20974
20965
|
|
|
20975
20966
|
// ../protocol/src/native-sessions.ts
|
|
20976
20967
|
var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
|
|
@@ -21036,10 +21027,7 @@ var identity = {
|
|
|
21036
21027
|
directoryId
|
|
21037
21028
|
};
|
|
21038
21029
|
var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
21039
|
-
external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
21040
21030
|
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
21041
|
-
external_exports.object({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
|
|
21042
|
-
external_exports.object({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
|
|
21043
21031
|
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
21044
21032
|
external_exports.object({
|
|
21045
21033
|
...identity,
|
|
@@ -21065,10 +21053,7 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
|
21065
21053
|
}).readonly()
|
|
21066
21054
|
]);
|
|
21067
21055
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
21068
|
-
external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
21069
21056
|
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
21070
|
-
external_exports.object({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
|
|
21071
|
-
external_exports.object({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
|
|
21072
21057
|
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
21073
21058
|
external_exports.object({
|
|
21074
21059
|
...identity,
|
|
@@ -21108,7 +21093,6 @@ var resultEnvelope = {
|
|
|
21108
21093
|
kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
|
|
21109
21094
|
};
|
|
21110
21095
|
var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
21111
|
-
external_exports.object({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
21112
21096
|
external_exports.object({
|
|
21113
21097
|
...resultEnvelope,
|
|
21114
21098
|
action: external_exports.literal("active-turn"),
|
|
@@ -21141,22 +21125,6 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
21141
21125
|
ready: sessionReadyEventSchema,
|
|
21142
21126
|
title: external_exports.string().max(500)
|
|
21143
21127
|
}).readonly(),
|
|
21144
|
-
external_exports.object({
|
|
21145
|
-
...resultEnvelope,
|
|
21146
|
-
action: external_exports.literal("preview"),
|
|
21147
|
-
entryId: identifierStringSchema,
|
|
21148
|
-
targetSessionId: identifierStringSchema,
|
|
21149
|
-
reason: external_exports.enum(["continuation_unavailable", "requested"]),
|
|
21150
|
-
history: sessionHistorySchema,
|
|
21151
|
-
title: external_exports.string().max(500)
|
|
21152
|
-
}).readonly(),
|
|
21153
|
-
external_exports.object({
|
|
21154
|
-
...resultEnvelope,
|
|
21155
|
-
action: external_exports.literal("history"),
|
|
21156
|
-
entryId: identifierStringSchema,
|
|
21157
|
-
history: sessionHistorySchema,
|
|
21158
|
-
title: external_exports.string().max(500)
|
|
21159
|
-
}).readonly(),
|
|
21160
21128
|
external_exports.object({
|
|
21161
21129
|
...resultEnvelope,
|
|
21162
21130
|
action: external_exports.literal("delete"),
|
|
@@ -21727,28 +21695,9 @@ function decodeRecordedSessionEvent(encoded) {
|
|
|
21727
21695
|
var encodeRecordedSessionEvent = (event) => JSON.stringify(decodeRecordedSessionEvent(JSON.stringify(event)));
|
|
21728
21696
|
|
|
21729
21697
|
// ../protocol/src/session-live-history.ts
|
|
21730
|
-
var SESSION_LIVE_HISTORY_PAGE_LOAD_KIND = "session.live-history.page.load";
|
|
21731
|
-
var SESSION_LIVE_HISTORY_PAGE_LOADED_KIND = "session.live-history.page.loaded";
|
|
21732
21698
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
|
|
21733
21699
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
|
|
21734
21700
|
var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
|
|
21735
|
-
var sessionLiveHistoryPageLoadSchema = external_exports.object({
|
|
21736
|
-
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
21737
|
-
agentId: identifierStringSchema,
|
|
21738
|
-
bindingId: identifierStringSchema,
|
|
21739
|
-
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21740
|
-
directoryId: directoryIdentifier,
|
|
21741
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOAD_KIND),
|
|
21742
|
-
limit: external_exports.number().int().min(1).max(100),
|
|
21743
|
-
requestId: identifierStringSchema,
|
|
21744
|
-
sessionId: identifierStringSchema
|
|
21745
|
-
}).readonly();
|
|
21746
|
-
var sessionLiveHistoryPageLoadedSchema = external_exports.object({
|
|
21747
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOADED_KIND),
|
|
21748
|
-
page: nativeMessagePageSchema,
|
|
21749
|
-
requestId: identifierStringSchema,
|
|
21750
|
-
sessionId: identifierStringSchema
|
|
21751
|
-
}).readonly();
|
|
21752
21701
|
var sessionLiveHistoryV2PageLoadSchema = external_exports.object({
|
|
21753
21702
|
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
21754
21703
|
agentId: identifierStringSchema,
|
|
@@ -21774,10 +21723,6 @@ function decode7(schema, encoded) {
|
|
|
21774
21723
|
throw new ProtocolMessageError("Invalid live Session history message", { cause });
|
|
21775
21724
|
}
|
|
21776
21725
|
}
|
|
21777
|
-
var decodeSessionLiveHistoryPageLoad = (encoded) => decode7(sessionLiveHistoryPageLoadSchema, encoded);
|
|
21778
|
-
var decodeSessionLiveHistoryPageLoaded = (encoded) => decode7(sessionLiveHistoryPageLoadedSchema, encoded);
|
|
21779
|
-
var encodeSessionLiveHistoryPageLoad = (value) => JSON.stringify(sessionLiveHistoryPageLoadSchema.parse(value));
|
|
21780
|
-
var encodeSessionLiveHistoryPageLoaded = (value) => JSON.stringify(sessionLiveHistoryPageLoadedSchema.parse(value));
|
|
21781
21726
|
var decodeSessionLiveHistoryV2PageLoad = (encoded) => decode7(sessionLiveHistoryV2PageLoadSchema, encoded);
|
|
21782
21727
|
var decodeSessionLiveHistoryV2PageLoaded = (encoded) => decode7(sessionLiveHistoryV2PageLoadedSchema, encoded);
|
|
21783
21728
|
var encodeSessionLiveHistoryV2PageLoad = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadSchema.parse(value));
|
|
@@ -21794,11 +21739,6 @@ function defineMessageSignature(kind, encoder, decoder) {
|
|
|
21794
21739
|
};
|
|
21795
21740
|
}
|
|
21796
21741
|
var serviceToDaemonSignatures = {
|
|
21797
|
-
[AGENT_CATALOG_REFRESH_KIND]: defineMessageSignature(
|
|
21798
|
-
AGENT_CATALOG_REFRESH_KIND,
|
|
21799
|
-
encodeAgentCatalogRefreshCommand,
|
|
21800
|
-
decodeAgentCatalogRefreshCommand
|
|
21801
|
-
),
|
|
21802
21742
|
[AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
|
|
21803
21743
|
AGENT_INSTALL_CANCEL_KIND,
|
|
21804
21744
|
encodeAgentInstallCancelCommand,
|
|
@@ -21841,6 +21781,7 @@ var serviceToDaemonSignatures = {
|
|
|
21841
21781
|
encodeRuntimeLivenessReadyEvent,
|
|
21842
21782
|
decodeRuntimeLivenessReadyEvent
|
|
21843
21783
|
),
|
|
21784
|
+
[RUNTIME_PING_KIND]: defineMessageSignature(RUNTIME_PING_KIND, encodeRuntimePingCommand, decodeRuntimePingCommand),
|
|
21844
21785
|
[SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
21845
21786
|
SESSION_CANCEL_KIND,
|
|
21846
21787
|
encodeSessionCancelCommand,
|
|
@@ -21856,11 +21797,6 @@ var serviceToDaemonSignatures = {
|
|
|
21856
21797
|
encodeSessionElicitationRespondCommand,
|
|
21857
21798
|
decodeSessionElicitationRespondCommand
|
|
21858
21799
|
),
|
|
21859
|
-
[SESSION_LIVE_HISTORY_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
21860
|
-
SESSION_LIVE_HISTORY_PAGE_LOAD_KIND,
|
|
21861
|
-
encodeSessionLiveHistoryPageLoad,
|
|
21862
|
-
decodeSessionLiveHistoryPageLoad
|
|
21863
|
-
),
|
|
21864
21800
|
[SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
21865
21801
|
SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND,
|
|
21866
21802
|
encodeSessionLiveHistoryV2PageLoad,
|
|
@@ -21902,16 +21838,6 @@ function decodeServiceToDaemonMessage(encoded) {
|
|
|
21902
21838
|
return signature.decoder(encoded);
|
|
21903
21839
|
}
|
|
21904
21840
|
var daemonToServiceSignatures = {
|
|
21905
|
-
[AGENT_CATALOG_REFRESHED_KIND]: defineMessageSignature(
|
|
21906
|
-
AGENT_CATALOG_REFRESHED_KIND,
|
|
21907
|
-
encodeAgentCatalogRefreshedEvent,
|
|
21908
|
-
decodeAgentCatalogRefreshedEvent
|
|
21909
|
-
),
|
|
21910
|
-
[AGENT_CATALOG_REFRESH_FAILED_KIND]: defineMessageSignature(
|
|
21911
|
-
AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
21912
|
-
encodeAgentCatalogRefreshFailedEvent,
|
|
21913
|
-
decodeAgentCatalogRefreshFailedEvent
|
|
21914
|
-
),
|
|
21915
21841
|
[AGENT_INSTALL_CANCELLED_KIND]: defineMessageSignature(
|
|
21916
21842
|
AGENT_INSTALL_CANCELLED_KIND,
|
|
21917
21843
|
encodeAgentInstallCancelledEvent,
|
|
@@ -21981,6 +21907,7 @@ var daemonToServiceSignatures = {
|
|
|
21981
21907
|
encodeRuntimeHeartbeatEvent,
|
|
21982
21908
|
decodeRuntimeHeartbeatEvent
|
|
21983
21909
|
),
|
|
21910
|
+
[RUNTIME_PONG_KIND]: defineMessageSignature(RUNTIME_PONG_KIND, encodeRuntimePongEvent, decodeRuntimePongEvent),
|
|
21984
21911
|
[SESSION_EVENT_KIND]: defineMessageSignature(
|
|
21985
21912
|
SESSION_EVENT_KIND,
|
|
21986
21913
|
encodeSessionEventEnvelope,
|
|
@@ -21996,11 +21923,6 @@ var daemonToServiceSignatures = {
|
|
|
21996
21923
|
encodeSessionOperationFailedEvent,
|
|
21997
21924
|
decodeSessionOperationFailedEvent
|
|
21998
21925
|
),
|
|
21999
|
-
[SESSION_LIVE_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
22000
|
-
SESSION_LIVE_HISTORY_PAGE_LOADED_KIND,
|
|
22001
|
-
encodeSessionLiveHistoryPageLoaded,
|
|
22002
|
-
decodeSessionLiveHistoryPageLoaded
|
|
22003
|
-
),
|
|
22004
21926
|
[SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
22005
21927
|
SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
|
|
22006
21928
|
encodeSessionLiveHistoryV2PageLoaded,
|
|
@@ -36329,9 +36251,6 @@ var LocalExternalContentStore = class {
|
|
|
36329
36251
|
};
|
|
36330
36252
|
|
|
36331
36253
|
// src/native-sessions/chat-agent.ts
|
|
36332
|
-
function supportsNativeChat(agentId) {
|
|
36333
|
-
return agentId === "codex" || agentId === "claude" || agentId === "opencode" || agentId === "pi";
|
|
36334
|
-
}
|
|
36335
36254
|
function isNativeChatSessionId(agentId, sessionId) {
|
|
36336
36255
|
if (!nativeSessionIdSchema.safeParse(sessionId).success) {
|
|
36337
36256
|
return false;
|
|
@@ -39589,7 +39508,6 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
39589
39508
|
child2.removeListener("exit", onExit);
|
|
39590
39509
|
}
|
|
39591
39510
|
}
|
|
39592
|
-
var readCodexHistory = async (agent, cwd, nativeSessionId, signal) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, { detail: "messages" });
|
|
39593
39511
|
var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTurn) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, {
|
|
39594
39512
|
detail: "rich",
|
|
39595
39513
|
...nativeTurn === void 0 ? {} : { nativeTurn }
|
|
@@ -39598,84 +39516,6 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
|
|
|
39598
39516
|
// src/native-sessions/service.ts
|
|
39599
39517
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
39600
39518
|
import { basename as basename4 } from "node:path";
|
|
39601
|
-
|
|
39602
|
-
// src/native-sessions/acp-history.ts
|
|
39603
|
-
async function readAcpHistory(sessions, directories, bindingId, options, nativeSessionId) {
|
|
39604
|
-
let cursor = null;
|
|
39605
|
-
let inspected = 0;
|
|
39606
|
-
for (let pageNumber = 0; pageNumber < 500 && inspected < 500; pageNumber += 1) {
|
|
39607
|
-
const page = await sessions.listNativeSessions(options, cursor);
|
|
39608
|
-
inspected += page.sessions.length;
|
|
39609
|
-
const found = page.sessions.find((entry) => entry.sessionId === nativeSessionId);
|
|
39610
|
-
if (found !== void 0) {
|
|
39611
|
-
const primary = await directories.identify(bindingId, found.cwd, options.signal);
|
|
39612
|
-
const additional = await Promise.all(
|
|
39613
|
-
found.additionalDirectories.map(
|
|
39614
|
-
async (directory) => await directories.identify(bindingId, directory, options.signal)
|
|
39615
|
-
)
|
|
39616
|
-
);
|
|
39617
|
-
if (primary.path !== options.cwd || additional.length !== options.additionalDirectories.length || additional.some((directory, index) => directory.path !== options.additionalDirectories[index])) {
|
|
39618
|
-
throw new AcpExecutionError(
|
|
39619
|
-
"The native Session belongs to another workspace.",
|
|
39620
|
-
{},
|
|
39621
|
-
"session_identity_mismatch"
|
|
39622
|
-
);
|
|
39623
|
-
}
|
|
39624
|
-
return await sessions.previewNativeSession(options, nativeSessionId);
|
|
39625
|
-
}
|
|
39626
|
-
if (page.nextCursor === null || page.nextCursor === cursor) {
|
|
39627
|
-
break;
|
|
39628
|
-
}
|
|
39629
|
-
cursor = page.nextCursor ?? null;
|
|
39630
|
-
}
|
|
39631
|
-
throw new AcpExecutionError("The native Session was not found.", {}, "native_session_not_found");
|
|
39632
|
-
}
|
|
39633
|
-
|
|
39634
|
-
// src/native-sessions/acp-adapter.ts
|
|
39635
|
-
var acpSessionAdapter = {
|
|
39636
|
-
history: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
|
|
39637
|
-
preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
|
|
39638
|
-
};
|
|
39639
|
-
|
|
39640
|
-
// src/native-sessions/codex-adapter.ts
|
|
39641
|
-
async function verifiedHistory(context, full) {
|
|
39642
|
-
const { options, nativeSessionId, directories, bindingId } = context;
|
|
39643
|
-
const snapshot = full ? await readCodexFullHistory(options.agent, options.cwd, nativeSessionId, options.signal) : await readCodexHistory(options.agent, options.cwd, nativeSessionId, options.signal);
|
|
39644
|
-
const resolved = await directories.identify(bindingId, snapshot.cwd, options.signal);
|
|
39645
|
-
if (snapshot.nativeSessionId !== nativeSessionId || resolved.path !== options.cwd) {
|
|
39646
|
-
throw new AcpExecutionError(
|
|
39647
|
-
"Codex returned history for a different session or workspace.",
|
|
39648
|
-
{},
|
|
39649
|
-
"invalid_native_session_response"
|
|
39650
|
-
);
|
|
39651
|
-
}
|
|
39652
|
-
return snapshot.history;
|
|
39653
|
-
}
|
|
39654
|
-
var codexSessionAdapter = {
|
|
39655
|
-
history: async (context) => await verifiedHistory(context, true),
|
|
39656
|
-
// Codex enforces an exclusive writer per thread. Its read-only app-server
|
|
39657
|
-
// history path keeps externally owned conversations previewable.
|
|
39658
|
-
preview: async (context) => await verifiedHistory(context, false)
|
|
39659
|
-
};
|
|
39660
|
-
|
|
39661
|
-
// src/native-sessions/agent-adapter.ts
|
|
39662
|
-
var genericSessionAdapter = {
|
|
39663
|
-
history: async () => {
|
|
39664
|
-
throw new AcpExecutionError("Native history is unavailable for this Agent", {}, "native_session_unsupported");
|
|
39665
|
-
},
|
|
39666
|
-
preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
|
|
39667
|
-
};
|
|
39668
|
-
function nativeSessionAdapter(agentId) {
|
|
39669
|
-
if (agentId === "codex") {
|
|
39670
|
-
return codexSessionAdapter;
|
|
39671
|
-
}
|
|
39672
|
-
if (agentId === "claude" || agentId === "opencode" || agentId === "pi") {
|
|
39673
|
-
return acpSessionAdapter;
|
|
39674
|
-
}
|
|
39675
|
-
return genericSessionAdapter;
|
|
39676
|
-
}
|
|
39677
|
-
|
|
39678
|
-
// src/native-sessions/service.ts
|
|
39679
39519
|
var NativeSessionService = class {
|
|
39680
39520
|
#entries = /* @__PURE__ */ new Map();
|
|
39681
39521
|
#cursors = /* @__PURE__ */ new Map();
|
|
@@ -39719,25 +39559,6 @@ var NativeSessionService = class {
|
|
|
39719
39559
|
...await this.#activeTurn(command, options)
|
|
39720
39560
|
};
|
|
39721
39561
|
}
|
|
39722
|
-
if (command.action === "create") {
|
|
39723
|
-
if (!supportsNativeChat(options.agent.id)) {
|
|
39724
|
-
throw new AcpExecutionError(
|
|
39725
|
-
"Native session creation is unavailable for this Agent",
|
|
39726
|
-
{},
|
|
39727
|
-
"native_session_unsupported"
|
|
39728
|
-
);
|
|
39729
|
-
}
|
|
39730
|
-
const nativeSessionId = await this.#sessions.createNativeSession(options);
|
|
39731
|
-
signal.throwIfAborted();
|
|
39732
|
-
this.record(command, "native_session_created");
|
|
39733
|
-
return {
|
|
39734
|
-
action: "create",
|
|
39735
|
-
kind: "native.session.result",
|
|
39736
|
-
nativeSessionId: decodeIdentifier(nativeSessionId),
|
|
39737
|
-
requestId: command.requestId,
|
|
39738
|
-
sessionId: command.sessionId
|
|
39739
|
-
};
|
|
39740
|
-
}
|
|
39741
39562
|
if (command.action === "fork-recorded") {
|
|
39742
39563
|
const source = this.#sessions.findSessions([command.sessionId])[0];
|
|
39743
39564
|
if (source === void 0 || !source.prompted) {
|
|
@@ -39930,44 +39751,6 @@ var NativeSessionService = class {
|
|
|
39930
39751
|
);
|
|
39931
39752
|
}
|
|
39932
39753
|
const target = await this.resolveTarget(command, options, selected);
|
|
39933
|
-
if (command.action === "history") {
|
|
39934
|
-
const history = await nativeSessionAdapter(options.agent.id).history({
|
|
39935
|
-
sessions: this.#sessions,
|
|
39936
|
-
directories: this.#directories,
|
|
39937
|
-
bindingId: command.bindingId,
|
|
39938
|
-
options: { ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
39939
|
-
nativeSessionId: target.info.sessionId
|
|
39940
|
-
});
|
|
39941
|
-
signal.throwIfAborted();
|
|
39942
|
-
this.record(command, "native_session_history_read");
|
|
39943
|
-
return {
|
|
39944
|
-
...envelope2,
|
|
39945
|
-
action: "history",
|
|
39946
|
-
entryId: command.entryId,
|
|
39947
|
-
history,
|
|
39948
|
-
title: target.info.title ?? "Untitled session"
|
|
39949
|
-
};
|
|
39950
|
-
}
|
|
39951
|
-
if (command.action === "preview") {
|
|
39952
|
-
const history = await nativeSessionAdapter(options.agent.id).preview({
|
|
39953
|
-
sessions: this.#sessions,
|
|
39954
|
-
directories: this.#directories,
|
|
39955
|
-
bindingId: command.bindingId,
|
|
39956
|
-
options: { ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
39957
|
-
nativeSessionId: target.info.sessionId
|
|
39958
|
-
});
|
|
39959
|
-
signal.throwIfAborted();
|
|
39960
|
-
this.record(command, "native_session_previewed");
|
|
39961
|
-
return {
|
|
39962
|
-
...envelope2,
|
|
39963
|
-
action: "preview",
|
|
39964
|
-
entryId: command.entryId,
|
|
39965
|
-
targetSessionId: command.sessionId,
|
|
39966
|
-
reason: "requested",
|
|
39967
|
-
title: target.info.title ?? "Untitled session",
|
|
39968
|
-
history
|
|
39969
|
-
};
|
|
39970
|
-
}
|
|
39971
39754
|
if (command.action === "delete") {
|
|
39972
39755
|
if (!prepared.capabilities.deleteSession) {
|
|
39973
39756
|
throw new AcpExecutionError(
|
|
@@ -40371,135 +40154,13 @@ var RelayConnectionDiagnostics = class {
|
|
|
40371
40154
|
};
|
|
40372
40155
|
|
|
40373
40156
|
// src/relay-connection/run-relay-connection.ts
|
|
40374
|
-
import { WebSocket as
|
|
40157
|
+
import { WebSocket as WebSocket7 } from "undici";
|
|
40375
40158
|
|
|
40376
40159
|
// src/daemon-command-handler.ts
|
|
40377
|
-
import { WebSocket as
|
|
40378
|
-
|
|
40379
|
-
// src/agent-catalog/handle-agent-catalog-refresh.ts
|
|
40380
|
-
import { WebSocket as WebSocket3 } from "undici";
|
|
40381
|
-
async function retainStillInstalledAgents(previous, refreshed, signal) {
|
|
40382
|
-
const refreshedIdentifiers = new Set(refreshed.map((agent) => agent.id));
|
|
40383
|
-
const retained = [];
|
|
40384
|
-
for (const agent of previous) {
|
|
40385
|
-
if (refreshedIdentifiers.has(agent.id)) {
|
|
40386
|
-
continue;
|
|
40387
|
-
}
|
|
40388
|
-
signal.throwIfAborted();
|
|
40389
|
-
if (await revalidateExecutable(agent.agentIdentity)) {
|
|
40390
|
-
retained.push(agent);
|
|
40391
|
-
}
|
|
40392
|
-
}
|
|
40393
|
-
return Object.freeze([...refreshed, ...retained]);
|
|
40394
|
-
}
|
|
40395
|
-
async function refreshAgentCatalog(config2, resolveEnvironment, signal) {
|
|
40396
|
-
signal.throwIfAborted();
|
|
40397
|
-
const shellEnvironment = await resolveEnvironment(signal);
|
|
40398
|
-
const environment = new DaemonLocalContext(config2.localContext.stateDirectory, shellEnvironment).environment;
|
|
40399
|
-
signal.throwIfAborted();
|
|
40400
|
-
const inventory = await discoverLocalAgentInventory({
|
|
40401
|
-
defaultWorkspace: config2.defaultWorkspace,
|
|
40402
|
-
environment,
|
|
40403
|
-
signal
|
|
40404
|
-
});
|
|
40405
|
-
const previousCatalog = config2.catalog.read();
|
|
40406
|
-
const refreshedAgents = inventory.readyAgents().map((agent) => withDaemonEnvironment(agent, environment));
|
|
40407
|
-
const agents = await retainStillInstalledAgents(previousCatalog.agents, refreshedAgents, signal);
|
|
40408
|
-
const verifiedIdentifiers = new Set(agents.map((agent) => agent.id));
|
|
40409
|
-
config2.catalog.transition(
|
|
40410
|
-
agents,
|
|
40411
|
-
inventory.installable.filter((agent) => !verifiedIdentifiers.has(agent.id))
|
|
40412
|
-
);
|
|
40413
|
-
try {
|
|
40414
|
-
await publishAgentCatalog(config2, signal);
|
|
40415
|
-
} catch (error62) {
|
|
40416
|
-
config2.catalog.transition(previousCatalog.agents, previousCatalog.installableAgents);
|
|
40417
|
-
throw error62;
|
|
40418
|
-
}
|
|
40419
|
-
}
|
|
40420
|
-
function createAgentCatalogRefreshHandler(dependencies) {
|
|
40421
|
-
const { config: config2, audit, diagnostics, socket, signal, timer, resolveEnvironment } = dependencies;
|
|
40422
|
-
const agentCatalogRefreshes = /* @__PURE__ */ new Map();
|
|
40423
|
-
const handle = (command) => {
|
|
40424
|
-
if (agentCatalogRefreshes.has(command.requestId) || agentCatalogRefreshes.size > 0) {
|
|
40425
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
40426
|
-
send(socket, {
|
|
40427
|
-
code: "agent_catalog_refresh_busy",
|
|
40428
|
-
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
40429
|
-
message: "Another local Agent catalog refresh is already running",
|
|
40430
|
-
requestId: command.requestId
|
|
40431
|
-
});
|
|
40432
|
-
}
|
|
40433
|
-
return;
|
|
40434
|
-
}
|
|
40435
|
-
const controller = new AbortController();
|
|
40436
|
-
const operationSignal = AbortSignal.any([signal, controller.signal]);
|
|
40437
|
-
const timeout = timer.schedule(
|
|
40438
|
-
() => controller.abort(
|
|
40439
|
-
new AcpExecutionError(
|
|
40440
|
-
"The local Agent catalog refresh timed out",
|
|
40441
|
-
{},
|
|
40442
|
-
"agent_catalog_refresh_timeout"
|
|
40443
|
-
)
|
|
40444
|
-
),
|
|
40445
|
-
9e4
|
|
40446
|
-
);
|
|
40447
|
-
const completion = (async () => {
|
|
40448
|
-
try {
|
|
40449
|
-
await refreshAgentCatalog(config2, resolveEnvironment, operationSignal);
|
|
40450
|
-
audit.record({
|
|
40451
|
-
commandId: command.requestId,
|
|
40452
|
-
event: "agent_catalog_refreshed",
|
|
40453
|
-
sessionId: "agent-catalog"
|
|
40454
|
-
});
|
|
40455
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
40456
|
-
send(socket, {
|
|
40457
|
-
kind: AGENT_CATALOG_REFRESHED_KIND,
|
|
40458
|
-
requestId: command.requestId
|
|
40459
|
-
});
|
|
40460
|
-
}
|
|
40461
|
-
} catch (error62) {
|
|
40462
|
-
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
40463
|
-
"The local Agent catalog refresh was cancelled",
|
|
40464
|
-
{},
|
|
40465
|
-
"agent_catalog_refresh_cancelled"
|
|
40466
|
-
) : error62;
|
|
40467
|
-
audit.record({
|
|
40468
|
-
commandId: command.requestId,
|
|
40469
|
-
details: { code: operationErrorCode(failure2) },
|
|
40470
|
-
event: "agent_catalog_refresh_failed",
|
|
40471
|
-
sessionId: "agent-catalog"
|
|
40472
|
-
});
|
|
40473
|
-
diagnostics.daemonDiagnostic(
|
|
40474
|
-
"agent_catalog_refresh_failed",
|
|
40475
|
-
command.requestId,
|
|
40476
|
-
{ code: operationErrorCode(failure2) },
|
|
40477
|
-
failure2
|
|
40478
|
-
);
|
|
40479
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
40480
|
-
send(socket, {
|
|
40481
|
-
code: operationErrorCode(failure2),
|
|
40482
|
-
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
40483
|
-
message: operationErrorMessage(failure2),
|
|
40484
|
-
requestId: command.requestId
|
|
40485
|
-
});
|
|
40486
|
-
}
|
|
40487
|
-
} finally {
|
|
40488
|
-
timeout.cancel();
|
|
40489
|
-
agentCatalogRefreshes.delete(command.requestId);
|
|
40490
|
-
}
|
|
40491
|
-
})();
|
|
40492
|
-
agentCatalogRefreshes.set(command.requestId, { completion, controller });
|
|
40493
|
-
return;
|
|
40494
|
-
};
|
|
40495
|
-
const settle2 = async () => {
|
|
40496
|
-
await Promise.all([...agentCatalogRefreshes.values()].map((request) => request.completion));
|
|
40497
|
-
};
|
|
40498
|
-
return { handle, settle: settle2 };
|
|
40499
|
-
}
|
|
40160
|
+
import { WebSocket as WebSocket5 } from "undici";
|
|
40500
40161
|
|
|
40501
40162
|
// src/agent-catalog/handle-agent-settings-discovery.ts
|
|
40502
|
-
import { WebSocket as
|
|
40163
|
+
import { WebSocket as WebSocket3 } from "undici";
|
|
40503
40164
|
|
|
40504
40165
|
// src/agent-catalog/discover-agent-settings.ts
|
|
40505
40166
|
import { createHash as createHash5 } from "node:crypto";
|
|
@@ -40987,7 +40648,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
40987
40648
|
(request) => request.agentId === command.agentId && !request.controller.signal.aborted
|
|
40988
40649
|
);
|
|
40989
40650
|
if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
|
|
40990
|
-
if (socket.readyState ===
|
|
40651
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
40991
40652
|
send(socket, {
|
|
40992
40653
|
code: "agent_settings_discovery_busy",
|
|
40993
40654
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -41002,7 +40663,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41002
40663
|
return;
|
|
41003
40664
|
}
|
|
41004
40665
|
if (existing !== void 0) {
|
|
41005
|
-
if (socket.readyState ===
|
|
40666
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
41006
40667
|
send(socket, {
|
|
41007
40668
|
code: "agent_settings_discovery_busy",
|
|
41008
40669
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -41013,7 +40674,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41013
40674
|
return;
|
|
41014
40675
|
}
|
|
41015
40676
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
41016
|
-
if (socket.readyState ===
|
|
40677
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
41017
40678
|
send(socket, {
|
|
41018
40679
|
code: "agent_settings_discovery_busy",
|
|
41019
40680
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -41059,7 +40720,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41059
40720
|
event: "agent_settings_discovered",
|
|
41060
40721
|
sessionId: `agent-settings:${command.agentId}`
|
|
41061
40722
|
});
|
|
41062
|
-
if (socket.readyState ===
|
|
40723
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
41063
40724
|
send(socket, { ...result.event, requestId });
|
|
41064
40725
|
}
|
|
41065
40726
|
}
|
|
@@ -41085,7 +40746,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41085
40746
|
`
|
|
41086
40747
|
);
|
|
41087
40748
|
}
|
|
41088
|
-
if (socket.readyState ===
|
|
40749
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
41089
40750
|
for (const requestId of requestIds) {
|
|
41090
40751
|
send(socket, {
|
|
41091
40752
|
code: operationErrorCode(failure2),
|
|
@@ -41231,300 +40892,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
41231
40892
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
41232
40893
|
}
|
|
41233
40894
|
|
|
41234
|
-
// src/native-sessions/live-history-page.ts
|
|
41235
|
-
function encodeLiveHistoryCursor(cursor) {
|
|
41236
|
-
return Buffer.from(JSON.stringify(cursor), "utf8").toString("base64url");
|
|
41237
|
-
}
|
|
41238
|
-
function decodeLiveHistoryCursor(cursor, sessionId) {
|
|
41239
|
-
try {
|
|
41240
|
-
if (!/^[A-Za-z0-9_-]{1,512}$/u.test(cursor)) {
|
|
41241
|
-
throw new Error("Invalid cursor alphabet");
|
|
41242
|
-
}
|
|
41243
|
-
const value = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
41244
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
41245
|
-
throw new Error("Invalid cursor shape");
|
|
41246
|
-
}
|
|
41247
|
-
const record2 = Object.fromEntries(Object.entries(value));
|
|
41248
|
-
const keys = Object.keys(record2).sort().join(",");
|
|
41249
|
-
const legacyNative = keys === "endIndex,sessionId";
|
|
41250
|
-
const kind = legacyNative ? "native" : record2["kind"];
|
|
41251
|
-
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) {
|
|
41252
|
-
throw new Error("Invalid cursor target");
|
|
41253
|
-
}
|
|
41254
|
-
if (kind === "active") {
|
|
41255
|
-
if (keys !== "endIndex,epoch,kind,sessionId" || typeof record2["epoch"] !== "string") {
|
|
41256
|
-
throw new Error("Invalid active cursor target");
|
|
41257
|
-
}
|
|
41258
|
-
return { endIndex: record2["endIndex"], epoch: record2["epoch"], kind, sessionId };
|
|
41259
|
-
}
|
|
41260
|
-
if (keys !== "endIndex,kind,sessionId" && !legacyNative) {
|
|
41261
|
-
throw new Error("Invalid native cursor target");
|
|
41262
|
-
}
|
|
41263
|
-
return { endIndex: record2["endIndex"], kind, sessionId };
|
|
41264
|
-
} catch (cause) {
|
|
41265
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", { cause }, "invalid_cursor");
|
|
41266
|
-
}
|
|
41267
|
-
}
|
|
41268
|
-
function activeHistoryCursor(sessionId, epoch, endIndex) {
|
|
41269
|
-
return encodeLiveHistoryCursor({ endIndex, epoch, kind: "active", sessionId });
|
|
41270
|
-
}
|
|
41271
|
-
function nativeHistoryCursor(sessionId, endIndex) {
|
|
41272
|
-
return encodeLiveHistoryCursor({ endIndex, kind: "native", sessionId });
|
|
41273
|
-
}
|
|
41274
|
-
function liveHistoryCoveredTurnRanges(history) {
|
|
41275
|
-
const ranges = [];
|
|
41276
|
-
let historyIndex = history.messages.length;
|
|
41277
|
-
for (const commandId of history.coveredCommandIds) {
|
|
41278
|
-
let assistantStartIndex = historyIndex;
|
|
41279
|
-
while (assistantStartIndex > 0 && history.messages[assistantStartIndex - 1]?.role === "assistant") {
|
|
41280
|
-
assistantStartIndex -= 1;
|
|
41281
|
-
}
|
|
41282
|
-
const userIndex = assistantStartIndex - 1;
|
|
41283
|
-
if (assistantStartIndex === historyIndex || history.messages[userIndex]?.role !== "user") {
|
|
41284
|
-
break;
|
|
41285
|
-
}
|
|
41286
|
-
ranges.push({ assistantEndIndex: historyIndex, assistantStartIndex, commandId, userIndex });
|
|
41287
|
-
historyIndex = userIndex;
|
|
41288
|
-
}
|
|
41289
|
-
return ranges;
|
|
41290
|
-
}
|
|
41291
|
-
function historyMessageCharacters(message) {
|
|
41292
|
-
return message.text.length + (message.role === "assistant" ? JSON.stringify(message.activities).length + JSON.stringify(message.content).length : 0);
|
|
41293
|
-
}
|
|
41294
|
-
function isNativeHistoryImageMimeType(mimeType) {
|
|
41295
|
-
return mimeType === "image/png" || mimeType === "image/jpeg" || mimeType === "image/gif" || mimeType === "image/webp";
|
|
41296
|
-
}
|
|
41297
|
-
function selectMessagesBefore(messages, endIndex, messageLimit, characterLimit) {
|
|
41298
|
-
const selected = [];
|
|
41299
|
-
let remainingCharacters = characterLimit;
|
|
41300
|
-
let startIndex = endIndex;
|
|
41301
|
-
for (let index = endIndex - 1; index >= 0 && selected.length < messageLimit; index -= 1) {
|
|
41302
|
-
const message = messages[index];
|
|
41303
|
-
if (message === void 0) {
|
|
41304
|
-
break;
|
|
41305
|
-
}
|
|
41306
|
-
const characters = historyMessageCharacters(message);
|
|
41307
|
-
if (characters > remainingCharacters) {
|
|
41308
|
-
break;
|
|
41309
|
-
}
|
|
41310
|
-
selected.unshift(message);
|
|
41311
|
-
remainingCharacters -= characters;
|
|
41312
|
-
startIndex = index;
|
|
41313
|
-
}
|
|
41314
|
-
if (selected.length === 0 && endIndex > 0) {
|
|
41315
|
-
throw new AcpExecutionError(
|
|
41316
|
-
"A native Session history item exceeds the page budget",
|
|
41317
|
-
{},
|
|
41318
|
-
"history_item_too_large"
|
|
41319
|
-
);
|
|
41320
|
-
}
|
|
41321
|
-
return { characters: characterLimit - remainingCharacters, messages: selected, startIndex };
|
|
41322
|
-
}
|
|
41323
|
-
function nativeActiveMessage(message) {
|
|
41324
|
-
if (message.role === "assistant") {
|
|
41325
|
-
return {
|
|
41326
|
-
activities: message.activities,
|
|
41327
|
-
content: message.content,
|
|
41328
|
-
role: "assistant",
|
|
41329
|
-
text: message.text
|
|
41330
|
-
};
|
|
41331
|
-
}
|
|
41332
|
-
const images = (message.images ?? []).flatMap((image) => {
|
|
41333
|
-
if (image.data.length < 4 || image.data.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/u.test(image.data) || !isNativeHistoryImageMimeType(image.mimeType)) {
|
|
41334
|
-
return [];
|
|
41335
|
-
}
|
|
41336
|
-
return [{ data: image.data, mimeType: image.mimeType, name: image.name }];
|
|
41337
|
-
});
|
|
41338
|
-
return { ...images.length === 0 ? {} : { images }, role: "user", text: message.text };
|
|
41339
|
-
}
|
|
41340
|
-
function nativeHistoryCoversCompletedRecovery(history, recovery) {
|
|
41341
|
-
const root = recovery.messages.find((message) => message.role === "user" && message.id === recovery.commandId);
|
|
41342
|
-
if (root === void 0) {
|
|
41343
|
-
return false;
|
|
41344
|
-
}
|
|
41345
|
-
const rootIndex = history.messages.findLastIndex(
|
|
41346
|
-
(message) => message.role === "user" && message.text === root.text
|
|
41347
|
-
);
|
|
41348
|
-
if (rootIndex < 0) {
|
|
41349
|
-
return false;
|
|
41350
|
-
}
|
|
41351
|
-
const nativeAssistant = history.messages.slice(rootIndex + 1).filter((message) => message.role === "assistant");
|
|
41352
|
-
if (nativeAssistant.length === 0) {
|
|
41353
|
-
return false;
|
|
41354
|
-
}
|
|
41355
|
-
const recoveryAssistant = recovery.messages.filter((message) => message.role === "assistant");
|
|
41356
|
-
const recoveryText = recoveryAssistant.map((message) => message.text).join("");
|
|
41357
|
-
const nativeText = nativeAssistant.map((message) => message.text).join("");
|
|
41358
|
-
if (recoveryText.length > 0 && !nativeText.includes(recoveryText)) {
|
|
41359
|
-
return false;
|
|
41360
|
-
}
|
|
41361
|
-
const nativeContent = new Set(
|
|
41362
|
-
nativeAssistant.flatMap((message) => message.content).map((content) => JSON.stringify(content))
|
|
41363
|
-
);
|
|
41364
|
-
return recoveryAssistant.flatMap((message) => message.content).every((content) => nativeContent.has(JSON.stringify(content)));
|
|
41365
|
-
}
|
|
41366
|
-
function historyBeforeActiveTurn(history, activeTurn) {
|
|
41367
|
-
if (history.status === "unavailable") {
|
|
41368
|
-
return history;
|
|
41369
|
-
}
|
|
41370
|
-
const activeRoot = activeTurn.messages.find(
|
|
41371
|
-
(message) => message.role === "user" && message.id === activeTurn.commandId
|
|
41372
|
-
);
|
|
41373
|
-
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;
|
|
41374
|
-
const activeUserIndex = matchingActiveUserIndex >= 0 ? matchingActiveUserIndex : liveHistoryCoveredTurnRanges(history).find((range) => range.commandId === activeTurn.commandId)?.userIndex ?? -1;
|
|
41375
|
-
if (activeUserIndex < 0) {
|
|
41376
|
-
return history;
|
|
41377
|
-
}
|
|
41378
|
-
return {
|
|
41379
|
-
...history,
|
|
41380
|
-
coveredCommandIds: history.coveredCommandIds.filter((id) => id !== activeTurn.commandId),
|
|
41381
|
-
coveredMessageIds: history.coveredMessageIds.filter(
|
|
41382
|
-
(id) => id !== `${activeTurn.commandId}:user` && id !== `${activeTurn.commandId}:agent`
|
|
41383
|
-
),
|
|
41384
|
-
messages: history.messages.slice(0, activeUserIndex)
|
|
41385
|
-
};
|
|
41386
|
-
}
|
|
41387
|
-
function paginateAvailableNativeHistory(history, sessionId, endIndex, limit, characterLimit) {
|
|
41388
|
-
if (endIndex > history.messages.length) {
|
|
41389
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
41390
|
-
}
|
|
41391
|
-
const selected = selectMessagesBefore(history.messages, endIndex, limit, characterLimit);
|
|
41392
|
-
const coveredMessageIds = new Set(history.coveredMessageIds);
|
|
41393
|
-
const ranges = liveHistoryCoveredTurnRanges(history);
|
|
41394
|
-
return {
|
|
41395
|
-
coveredCommandIds: ranges.filter((range) => range.userIndex >= selected.startIndex && range.assistantEndIndex <= endIndex).map((range) => range.commandId),
|
|
41396
|
-
coveredMessageIds: ranges.flatMap((range) => [
|
|
41397
|
-
...range.userIndex >= selected.startIndex && range.userIndex < endIndex && coveredMessageIds.has(`${range.commandId}:user`) ? [`${range.commandId}:user`] : [],
|
|
41398
|
-
...range.assistantStartIndex >= selected.startIndex && range.assistantEndIndex <= endIndex && coveredMessageIds.has(`${range.commandId}:agent`) ? [`${range.commandId}:agent`] : []
|
|
41399
|
-
]),
|
|
41400
|
-
messages: selected.messages,
|
|
41401
|
-
nextCursor: selected.startIndex > 0 ? nativeHistoryCursor(sessionId, selected.startIndex) : null,
|
|
41402
|
-
status: "available",
|
|
41403
|
-
truncated: history.truncated
|
|
41404
|
-
};
|
|
41405
|
-
}
|
|
41406
|
-
function paginateNativeHistory(history, sessionId, cursor, limit) {
|
|
41407
|
-
if (cursor?.kind === "active") {
|
|
41408
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
41409
|
-
}
|
|
41410
|
-
if (history.status === "unavailable") {
|
|
41411
|
-
if (cursor !== null) {
|
|
41412
|
-
throw new AcpExecutionError("Unavailable native Session history has no cursor", {}, "invalid_cursor");
|
|
41413
|
-
}
|
|
41414
|
-
return { cause: history.cause, nextCursor: null, status: "unavailable" };
|
|
41415
|
-
}
|
|
41416
|
-
return paginateAvailableNativeHistory(
|
|
41417
|
-
history,
|
|
41418
|
-
sessionId,
|
|
41419
|
-
cursor?.endIndex ?? history.messages.length,
|
|
41420
|
-
limit,
|
|
41421
|
-
SESSION_HISTORY_CHARACTER_LIMIT
|
|
41422
|
-
);
|
|
41423
|
-
}
|
|
41424
|
-
function paginateActiveTurn(history, activeTurn, sessionId, endIndex, limit) {
|
|
41425
|
-
if (endIndex > activeTurn.messages.length) {
|
|
41426
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
41427
|
-
}
|
|
41428
|
-
const activeMessages = activeTurn.messages.map(nativeActiveMessage);
|
|
41429
|
-
const active = selectMessagesBefore(activeMessages, endIndex, limit, SESSION_HISTORY_CHARACTER_LIMIT);
|
|
41430
|
-
const historicalLimit = limit - active.messages.length;
|
|
41431
|
-
const historicalCharacterLimit = SESSION_HISTORY_CHARACTER_LIMIT - active.characters;
|
|
41432
|
-
const pendingHistoricalCursor = history.status === "available" && history.messages.length > 0 ? nativeHistoryCursor(sessionId, history.messages.length) : null;
|
|
41433
|
-
const latestHistoricalMessage = history.status === "available" ? history.messages.at(-1) : void 0;
|
|
41434
|
-
const historicalPageFits = latestHistoricalMessage === void 0 || historyMessageCharacters(latestHistoricalMessage) <= historicalCharacterLimit;
|
|
41435
|
-
const historical = active.startIndex === 0 && history.status === "available" && historicalLimit > 0 && historicalPageFits ? paginateAvailableNativeHistory(
|
|
41436
|
-
history,
|
|
41437
|
-
sessionId,
|
|
41438
|
-
history.messages.length,
|
|
41439
|
-
historicalLimit,
|
|
41440
|
-
historicalCharacterLimit
|
|
41441
|
-
) : null;
|
|
41442
|
-
return {
|
|
41443
|
-
streamPosition: { commandId: activeTurn.commandId, epoch: activeTurn.epoch, sequence: activeTurn.sequence },
|
|
41444
|
-
coveredCommandIds: historical?.coveredCommandIds ?? [],
|
|
41445
|
-
coveredMessageIds: [
|
|
41446
|
-
...historical?.coveredMessageIds ?? [],
|
|
41447
|
-
...active.startIndex === 0 ? [`${activeTurn.commandId}:user`, `${activeTurn.commandId}:agent`] : []
|
|
41448
|
-
],
|
|
41449
|
-
messages: [...historical?.messages ?? [], ...active.messages],
|
|
41450
|
-
nextCursor: active.startIndex > 0 ? activeHistoryCursor(sessionId, activeTurn.epoch, active.startIndex) : historical === null ? pendingHistoricalCursor : historical.nextCursor,
|
|
41451
|
-
status: "available",
|
|
41452
|
-
truncated: activeTurn.truncated || (historical?.truncated ?? false)
|
|
41453
|
-
};
|
|
41454
|
-
}
|
|
41455
|
-
function paginateLiveSessionHistory(history, activeTurn, sessionId, encodedCursor, limit) {
|
|
41456
|
-
const cursor = encodedCursor === null ? null : decodeLiveHistoryCursor(encodedCursor, sessionId);
|
|
41457
|
-
if (activeTurn === null || activeTurn.state === "completed" && history.status === "available" && nativeHistoryCoversCompletedRecovery(history, activeTurn)) {
|
|
41458
|
-
return paginateNativeHistory(history, sessionId, cursor, limit);
|
|
41459
|
-
}
|
|
41460
|
-
const historical = historyBeforeActiveTurn(history, activeTurn);
|
|
41461
|
-
if (cursor?.kind === "native") {
|
|
41462
|
-
return paginateNativeHistory(historical, sessionId, cursor, limit);
|
|
41463
|
-
}
|
|
41464
|
-
if (cursor !== null && cursor.epoch !== activeTurn.epoch) {
|
|
41465
|
-
throw new AcpExecutionError("The active Turn history cursor is stale", {}, "stale_cursor");
|
|
41466
|
-
}
|
|
41467
|
-
return paginateActiveTurn(historical, activeTurn, sessionId, cursor?.endIndex ?? activeTurn.messages.length, limit);
|
|
41468
|
-
}
|
|
41469
|
-
|
|
41470
40895
|
// src/daemon-history-commands.ts
|
|
41471
|
-
async function executeSessionLiveHistoryPageLoad(socket, command, config2, directories, audit, sessions, activeTurn, signal) {
|
|
41472
|
-
try {
|
|
41473
|
-
const resolved = await resolveSessionDirectories(
|
|
41474
|
-
directories,
|
|
41475
|
-
config2.bindingId,
|
|
41476
|
-
command.directoryId,
|
|
41477
|
-
command.additionalDirectoryIds,
|
|
41478
|
-
signal
|
|
41479
|
-
);
|
|
41480
|
-
const history = await sessions.loadSessionHistory({
|
|
41481
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
41482
|
-
agent: config2.catalog.find(command.agentId),
|
|
41483
|
-
cwd: resolved.cwd,
|
|
41484
|
-
sessionId: command.sessionId,
|
|
41485
|
-
signal
|
|
41486
|
-
});
|
|
41487
|
-
signal.throwIfAborted();
|
|
41488
|
-
const page = paginateLiveSessionHistory(
|
|
41489
|
-
history,
|
|
41490
|
-
activeTurn(command.sessionId),
|
|
41491
|
-
command.sessionId,
|
|
41492
|
-
command.cursor,
|
|
41493
|
-
command.limit
|
|
41494
|
-
);
|
|
41495
|
-
audit.record({
|
|
41496
|
-
commandId: command.requestId,
|
|
41497
|
-
event: "session_history_loaded",
|
|
41498
|
-
sessionId: command.sessionId
|
|
41499
|
-
});
|
|
41500
|
-
send(socket, {
|
|
41501
|
-
kind: "session.live-history.page.loaded",
|
|
41502
|
-
page,
|
|
41503
|
-
requestId: command.requestId,
|
|
41504
|
-
sessionId: command.sessionId
|
|
41505
|
-
});
|
|
41506
|
-
} catch (error62) {
|
|
41507
|
-
if (signal.aborted) {
|
|
41508
|
-
return;
|
|
41509
|
-
}
|
|
41510
|
-
audit.record({
|
|
41511
|
-
commandId: command.requestId,
|
|
41512
|
-
details: { code: operationErrorCode(error62) },
|
|
41513
|
-
event: "session_history_unavailable",
|
|
41514
|
-
sessionId: command.sessionId
|
|
41515
|
-
});
|
|
41516
|
-
send(socket, {
|
|
41517
|
-
kind: "session.live-history.page.loaded",
|
|
41518
|
-
page: {
|
|
41519
|
-
status: "unavailable",
|
|
41520
|
-
cause: { code: operationErrorCode(error62), message: operationErrorMessage(error62) },
|
|
41521
|
-
nextCursor: null
|
|
41522
|
-
},
|
|
41523
|
-
requestId: command.requestId,
|
|
41524
|
-
sessionId: command.sessionId
|
|
41525
|
-
});
|
|
41526
|
-
}
|
|
41527
|
-
}
|
|
41528
40896
|
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
|
|
41529
40897
|
try {
|
|
41530
40898
|
const resolved = await resolveSessionDirectories(
|
|
@@ -42295,7 +41663,7 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
42295
41663
|
}
|
|
42296
41664
|
|
|
42297
41665
|
// src/native-sessions/handle-native-requests.ts
|
|
42298
|
-
import { WebSocket as
|
|
41666
|
+
import { WebSocket as WebSocket4 } from "undici";
|
|
42299
41667
|
function createNativeSessionRequestHandler(dependencies) {
|
|
42300
41668
|
const { audit, diagnostics, nativeSessions, publisher, signal, socket, timer } = dependencies;
|
|
42301
41669
|
const pending = /* @__PURE__ */ new Map();
|
|
@@ -42360,7 +41728,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
42360
41728
|
}
|
|
42361
41729
|
]);
|
|
42362
41730
|
}
|
|
42363
|
-
if (socket.readyState ===
|
|
41731
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
42364
41732
|
send(socket, result);
|
|
42365
41733
|
}
|
|
42366
41734
|
} catch (error62) {
|
|
@@ -42419,8 +41787,7 @@ function createDaemonCommandHandler({
|
|
|
42419
41787
|
socket,
|
|
42420
41788
|
signal,
|
|
42421
41789
|
runtimeSignal,
|
|
42422
|
-
timer
|
|
42423
|
-
resolveAgentCatalogEnvironment
|
|
41790
|
+
timer
|
|
42424
41791
|
}) {
|
|
42425
41792
|
const handleSettingsDiscovery = createAgentSettingsDiscoveryHandler({
|
|
42426
41793
|
config: config2,
|
|
@@ -42432,20 +41799,10 @@ function createDaemonCommandHandler({
|
|
|
42432
41799
|
signal,
|
|
42433
41800
|
timer
|
|
42434
41801
|
});
|
|
42435
|
-
const handleCatalogRefresh = createAgentCatalogRefreshHandler({
|
|
42436
|
-
config: config2,
|
|
42437
|
-
audit,
|
|
42438
|
-
diagnostics,
|
|
42439
|
-
socket,
|
|
42440
|
-
signal,
|
|
42441
|
-
timer,
|
|
42442
|
-
resolveEnvironment: resolveAgentCatalogEnvironment
|
|
42443
|
-
});
|
|
42444
41802
|
const queueChanged = (sessionId) => {
|
|
42445
41803
|
publisher.publish(sessionId, { kind: "session.queue.changed", sessionId });
|
|
42446
41804
|
eventLogV2.queueChanged(sessionId);
|
|
42447
41805
|
};
|
|
42448
|
-
const activeTurnRecovery = (sessionId) => activeTurns.recovery((command) => command.sessionId === sessionId);
|
|
42449
41806
|
const nativeRequestHandler = createNativeSessionRequestHandler({
|
|
42450
41807
|
audit,
|
|
42451
41808
|
diagnostics,
|
|
@@ -42458,18 +41815,8 @@ function createDaemonCommandHandler({
|
|
|
42458
41815
|
return {
|
|
42459
41816
|
handle: (message) => {
|
|
42460
41817
|
const kind = message.kind;
|
|
42461
|
-
if (kind ===
|
|
42462
|
-
|
|
42463
|
-
void executeSessionLiveHistoryPageLoad(
|
|
42464
|
-
socket,
|
|
42465
|
-
command2,
|
|
42466
|
-
config2,
|
|
42467
|
-
directories,
|
|
42468
|
-
audit,
|
|
42469
|
-
sessions,
|
|
42470
|
-
activeTurnRecovery,
|
|
42471
|
-
signal
|
|
42472
|
-
);
|
|
41818
|
+
if (kind === RUNTIME_PING_KIND) {
|
|
41819
|
+
send(socket, { kind: RUNTIME_PONG_KIND, requestId: message.requestId });
|
|
42473
41820
|
return;
|
|
42474
41821
|
}
|
|
42475
41822
|
if (kind === SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) {
|
|
@@ -42494,10 +41841,6 @@ function createDaemonCommandHandler({
|
|
|
42494
41841
|
handleSettingsDiscovery.handle(message);
|
|
42495
41842
|
return;
|
|
42496
41843
|
}
|
|
42497
|
-
if (kind === AGENT_CATALOG_REFRESH_KIND) {
|
|
42498
|
-
handleCatalogRefresh.handle(message);
|
|
42499
|
-
return;
|
|
42500
|
-
}
|
|
42501
41844
|
if (kind === NATIVE_SESSION_REQUEST_KIND) {
|
|
42502
41845
|
nativeRequestHandler.handle(message);
|
|
42503
41846
|
return;
|
|
@@ -42511,7 +41854,7 @@ function createDaemonCommandHandler({
|
|
|
42511
41854
|
sessions.findSessions([command2.sessionId])[0]?.cwd ?? null,
|
|
42512
41855
|
externalContent
|
|
42513
41856
|
).catch((error62) => {
|
|
42514
|
-
if (socket.readyState !==
|
|
41857
|
+
if (socket.readyState !== WebSocket5.OPEN || signal.aborted) {
|
|
42515
41858
|
return;
|
|
42516
41859
|
}
|
|
42517
41860
|
send(socket, {
|
|
@@ -42717,17 +42060,13 @@ function createDaemonCommandHandler({
|
|
|
42717
42060
|
});
|
|
42718
42061
|
},
|
|
42719
42062
|
settle: async () => {
|
|
42720
|
-
await Promise.all([
|
|
42721
|
-
nativeRequestHandler.settle(),
|
|
42722
|
-
handleSettingsDiscovery.settle(),
|
|
42723
|
-
handleCatalogRefresh.settle()
|
|
42724
|
-
]);
|
|
42063
|
+
await Promise.all([nativeRequestHandler.settle(), handleSettingsDiscovery.settle()]);
|
|
42725
42064
|
}
|
|
42726
42065
|
};
|
|
42727
42066
|
}
|
|
42728
42067
|
|
|
42729
42068
|
// src/relay-connection/connect.ts
|
|
42730
|
-
import { WebSocket as
|
|
42069
|
+
import { WebSocket as WebSocket6 } from "undici";
|
|
42731
42070
|
|
|
42732
42071
|
// src/relay-connection/runtime-revocation.ts
|
|
42733
42072
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -42765,7 +42104,7 @@ function connectRelay(url2, signal) {
|
|
|
42765
42104
|
const endpoint = new URL(url2);
|
|
42766
42105
|
const headers = runtimeAuthorization(endpoint);
|
|
42767
42106
|
endpoint.searchParams.delete("token");
|
|
42768
|
-
const socket = new
|
|
42107
|
+
const socket = new WebSocket6(endpoint, {
|
|
42769
42108
|
dispatcher: environmentProxyDispatcher,
|
|
42770
42109
|
headers
|
|
42771
42110
|
});
|
|
@@ -42983,8 +42322,7 @@ async function runRelayConnection({
|
|
|
42983
42322
|
diagnostics,
|
|
42984
42323
|
onConnected,
|
|
42985
42324
|
signal,
|
|
42986
|
-
timer
|
|
42987
|
-
resolveAgentCatalogEnvironment
|
|
42325
|
+
timer
|
|
42988
42326
|
}) {
|
|
42989
42327
|
const relayUrl = new URL(config2.relayUrl);
|
|
42990
42328
|
relayUrl.searchParams.set("liveness", "1");
|
|
@@ -43007,8 +42345,7 @@ async function runRelayConnection({
|
|
|
43007
42345
|
socket,
|
|
43008
42346
|
signal: connectionController.signal,
|
|
43009
42347
|
runtimeSignal: signal,
|
|
43010
|
-
timer
|
|
43011
|
-
resolveAgentCatalogEnvironment
|
|
42348
|
+
timer
|
|
43012
42349
|
});
|
|
43013
42350
|
installationObserver.connect(socket);
|
|
43014
42351
|
onConnected();
|
|
@@ -43054,14 +42391,14 @@ async function runRelayConnection({
|
|
|
43054
42391
|
};
|
|
43055
42392
|
const connectionLiveness = new RelayConnectionLiveness(timer, {
|
|
43056
42393
|
send: (message) => {
|
|
43057
|
-
if (socket.readyState !==
|
|
42394
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
43058
42395
|
return false;
|
|
43059
42396
|
}
|
|
43060
42397
|
try {
|
|
43061
42398
|
send(socket, message);
|
|
43062
42399
|
return true;
|
|
43063
42400
|
} catch (error62) {
|
|
43064
|
-
if (socket.readyState !==
|
|
42401
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
43065
42402
|
return false;
|
|
43066
42403
|
}
|
|
43067
42404
|
throw error62;
|
|
@@ -43150,7 +42487,7 @@ async function runRelayConnection({
|
|
|
43150
42487
|
}
|
|
43151
42488
|
|
|
43152
42489
|
// src/relay-connection/session-event-publisher.ts
|
|
43153
|
-
import { WebSocket as
|
|
42490
|
+
import { WebSocket as WebSocket8 } from "undici";
|
|
43154
42491
|
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
43155
42492
|
var DaemonSessionEventPublisher = class {
|
|
43156
42493
|
#socket = null;
|
|
@@ -43167,7 +42504,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
43167
42504
|
};
|
|
43168
42505
|
publish = (sessionId, event) => {
|
|
43169
42506
|
const socket = this.#socket;
|
|
43170
|
-
if (socket === null || socket.readyState !==
|
|
42507
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
43171
42508
|
return;
|
|
43172
42509
|
}
|
|
43173
42510
|
const encoded = encodeDaemonToServiceMessage({
|
|
@@ -43191,7 +42528,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
43191
42528
|
};
|
|
43192
42529
|
publishStatus = (event) => {
|
|
43193
42530
|
const socket = this.#socket;
|
|
43194
|
-
if (socket === null || socket.readyState !==
|
|
42531
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
43195
42532
|
return;
|
|
43196
42533
|
}
|
|
43197
42534
|
const encoded = encodeDaemonToServiceMessage(event);
|
|
@@ -43206,7 +42543,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
43206
42543
|
};
|
|
43207
42544
|
publishV2 = (event) => {
|
|
43208
42545
|
const socket = this.#socket;
|
|
43209
|
-
if (socket === null || socket.readyState !==
|
|
42546
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
43210
42547
|
return;
|
|
43211
42548
|
}
|
|
43212
42549
|
const encoded = encodeDaemonToServiceMessage({ event, kind: SESSION_EVENT_V2_KIND });
|
|
@@ -43445,10 +42782,6 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43445
42782
|
let connectionAnnounced = false;
|
|
43446
42783
|
let catalogPublished = false;
|
|
43447
42784
|
let readinessAnnounced = false;
|
|
43448
|
-
const resolveAgentCatalogEnvironment = options.resolveAgentCatalogEnvironment ?? (async (catalogSignal) => {
|
|
43449
|
-
catalogSignal.throwIfAborted();
|
|
43450
|
-
return config2.localContext.environment;
|
|
43451
|
-
});
|
|
43452
42785
|
const startAutomaticIntegrationProvisioning = () => {
|
|
43453
42786
|
if (!connectionAnnounced || !catalogPublished || automaticIntegrationProvisioningStarted) {
|
|
43454
42787
|
return;
|
|
@@ -43526,8 +42859,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43526
42859
|
announceConnection();
|
|
43527
42860
|
},
|
|
43528
42861
|
signal,
|
|
43529
|
-
timer
|
|
43530
|
-
resolveAgentCatalogEnvironment
|
|
42862
|
+
timer
|
|
43531
42863
|
});
|
|
43532
42864
|
} catch (error62) {
|
|
43533
42865
|
if (signal.aborted) {
|
|
@@ -44435,8 +43767,7 @@ var MobiusRuntimeEngine = class {
|
|
|
44435
43767
|
const audit = new AuditStore();
|
|
44436
43768
|
try {
|
|
44437
43769
|
await runDaemon(this.#config, audit, signal, void 0, {
|
|
44438
|
-
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus }
|
|
44439
|
-
...this.#options.resolveAgentCatalogEnvironment === void 0 ? {} : { resolveAgentCatalogEnvironment: this.#options.resolveAgentCatalogEnvironment }
|
|
43770
|
+
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus }
|
|
44440
43771
|
});
|
|
44441
43772
|
} finally {
|
|
44442
43773
|
audit.close();
|