@moxt-ai/mobius 0.0.58 → 0.0.60
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/publish-agent-catalog.d.ts.map +1 -1
- package/dist/agent-catalog/publish-agent-catalog.js +36 -3
- package/dist/agent-catalog/publish-agent-catalog.js.map +1 -1
- package/dist/artifacts/local-file-streamer.d.ts +2 -2
- package/dist/artifacts/local-file-streamer.d.ts.map +1 -1
- package/dist/artifacts/local-file-streamer.js +7 -7
- package/dist/artifacts/local-file-streamer.js.map +1 -1
- package/dist/cli.js +648 -330
- package/dist/cli.js.map +4 -4
- package/dist/index.js +647 -329
- package/dist/index.js.map +4 -4
- package/dist/relay-connection/diagnostics.d.ts +5 -0
- package/dist/relay-connection/diagnostics.d.ts.map +1 -1
- package/dist/relay-connection/diagnostics.js +14 -0
- package/dist/relay-connection/diagnostics.js.map +1 -1
- package/dist/relay-connection/liveness.d.ts +2 -2
- package/dist/relay-connection/liveness.d.ts.map +1 -1
- package/dist/relay-connection/liveness.js +3 -3
- package/dist/relay-connection/liveness.js.map +1 -1
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +162 -114
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +656 -338
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -23103,39 +23103,65 @@ var decodePromptResourcesValue = (value) => decodeValue(value, external_exports.
|
|
|
23103
23103
|
var decodeSessionConfigurationSelections = (value) => decodeValue(value, sessionConfigurationSelectionsSchema);
|
|
23104
23104
|
var encode3 = (message, schema) => JSON.stringify(decodeValue(message, schema));
|
|
23105
23105
|
var decodeAgentSettingsDiscoverCommand = (encoded) => decode3(encoded, agentSettingsDiscoverCommandSchema);
|
|
23106
|
+
var encodeAgentSettingsDiscoverCommand = (message) => encode3(message, agentSettingsDiscoverCommandSchema);
|
|
23107
|
+
var decodeAgentSettingsDiscoveredEvent = (encoded) => decode3(encoded, agentSettingsDiscoveredEventSchema);
|
|
23106
23108
|
var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
|
|
23109
|
+
var decodeAgentSettingsDiscoveryFailedEvent = (encoded) => decode3(encoded, agentSettingsDiscoveryFailedEventSchema);
|
|
23107
23110
|
var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
|
|
23108
23111
|
var decodeAgentCatalogRefreshCommand = (encoded) => decode3(encoded, agentCatalogRefreshCommandSchema);
|
|
23112
|
+
var encodeAgentCatalogRefreshCommand = (message) => encode3(message, agentCatalogRefreshCommandSchema);
|
|
23113
|
+
var decodeAgentCatalogRefreshedEvent = (encoded) => decode3(encoded, agentCatalogRefreshedEventSchema);
|
|
23109
23114
|
var encodeAgentCatalogRefreshedEvent = (message) => encode3(message, agentCatalogRefreshedEventSchema);
|
|
23115
|
+
var decodeAgentCatalogRefreshFailedEvent = (encoded) => decode3(encoded, agentCatalogRefreshFailedEventSchema);
|
|
23110
23116
|
var encodeAgentCatalogRefreshFailedEvent = (message) => encode3(message, agentCatalogRefreshFailedEventSchema);
|
|
23111
23117
|
var decodeFileReadCommand = (encoded) => decode3(encoded, fileReadCommandSchema);
|
|
23118
|
+
var encodeFileReadCommand = (message) => encode3(message, fileReadCommandSchema);
|
|
23119
|
+
var decodeFileBeginEvent = (encoded) => decode3(encoded, fileBeginEventSchema);
|
|
23112
23120
|
var encodeFileBeginEvent = (message) => encode3(message, fileBeginEventSchema);
|
|
23121
|
+
var decodeFileChunkEvent = (encoded) => decode3(encoded, fileChunkEventSchema);
|
|
23113
23122
|
var encodeFileChunkEvent = (message) => encode3(message, fileChunkEventSchema);
|
|
23123
|
+
var decodeFileEndEvent = (encoded) => decode3(encoded, fileEndEventSchema);
|
|
23114
23124
|
var encodeFileEndEvent = (message) => encode3(message, fileEndEventSchema);
|
|
23125
|
+
var decodeFileFailedEvent = (encoded) => decode3(encoded, fileFailedEventSchema);
|
|
23115
23126
|
var encodeFileFailedEvent = (message) => encode3(message, fileFailedEventSchema);
|
|
23116
23127
|
var decodeWorkspaceListCommand = (encoded) => decode3(encoded, workspaceListCommandSchema);
|
|
23128
|
+
var encodeWorkspaceListCommand = (message) => encode3(message, workspaceListCommandSchema);
|
|
23129
|
+
var decodeWorkspaceEntriesEvent = (encoded) => decode3(encoded, workspaceEntriesEventSchema);
|
|
23117
23130
|
var encodeWorkspaceEntriesEvent = (message) => encode3(message, workspaceEntriesEventSchema);
|
|
23118
23131
|
var decodeSessionPrepareCommand = (encoded) => decode3(encoded, sessionPrepareCommandSchema);
|
|
23132
|
+
var encodeSessionPrepareCommand = (message) => encode3(message, sessionPrepareCommandSchema);
|
|
23133
|
+
var decodeSessionReadyEvent = (encoded) => decode3(encoded, sessionReadyEventSchema);
|
|
23119
23134
|
var encodeSessionReadyEvent = (message) => encode3(message, sessionReadyEventSchema);
|
|
23120
23135
|
var decodeSessionConfigureCommand = (encoded) => decode3(encoded, sessionConfigureCommandSchema);
|
|
23121
|
-
var
|
|
23122
|
-
var
|
|
23123
|
-
var
|
|
23124
|
-
var
|
|
23125
|
-
var
|
|
23136
|
+
var encodeSessionConfigureCommand = (message) => encode3(message, sessionConfigureCommandSchema);
|
|
23137
|
+
var decodeSessionConfigUpdatedEvent = (encoded) => decode3(encoded, sessionConfigUpdatedEventSchema);
|
|
23138
|
+
var decodeSessionUsageUpdatedEvent = (encoded) => decode3(encoded, sessionUsageUpdatedEventSchema);
|
|
23139
|
+
var decodeSessionCommandsUpdatedEvent = (encoded) => decode3(encoded, sessionCommandsUpdatedEventSchema);
|
|
23140
|
+
var decodeSessionInfoUpdatedEvent = (encoded) => decode3(encoded, sessionInfoUpdatedEventSchema);
|
|
23141
|
+
var decodeSessionPermissionRequestedEvent = (encoded) => decode3(encoded, sessionPermissionRequestedEventSchema);
|
|
23126
23142
|
var decodeSessionPermissionRespondCommand = (encoded) => decode3(encoded, sessionPermissionRespondCommandSchema);
|
|
23127
|
-
var
|
|
23128
|
-
var
|
|
23143
|
+
var encodeSessionPermissionRespondCommand = (message) => encode3(message, sessionPermissionRespondCommandSchema);
|
|
23144
|
+
var decodeSessionPermissionResolvedEvent = (encoded) => decode3(encoded, sessionPermissionResolvedEventSchema);
|
|
23145
|
+
var decodeSessionElicitationRequestedEvent = (encoded) => decode3(encoded, sessionElicitationRequestedEventSchema);
|
|
23129
23146
|
var decodeSessionElicitationRespondCommand = (encoded) => decode3(encoded, sessionElicitationRespondCommandSchema);
|
|
23130
|
-
var
|
|
23147
|
+
var encodeSessionElicitationRespondCommand = (message) => encode3(message, sessionElicitationRespondCommandSchema);
|
|
23148
|
+
var decodeSessionElicitationResolvedEvent = (encoded) => decode3(encoded, sessionElicitationResolvedEventSchema);
|
|
23149
|
+
var decodeSessionOperationFailedEvent = (encoded) => decode3(encoded, sessionOperationFailedEventSchema);
|
|
23131
23150
|
var encodeSessionOperationFailedEvent = (message) => encode3(message, sessionOperationFailedEventSchema);
|
|
23132
|
-
var
|
|
23151
|
+
var decodeAgentContentEvent = (encoded) => decode3(encoded, agentContentEventSchema);
|
|
23133
23152
|
var decodeAgentInstallRequestCommand = (encoded) => decode3(encoded, agentInstallRequestCommandSchema);
|
|
23153
|
+
var encodeAgentInstallRequestCommand = (message) => encode3(message, agentInstallRequestCommandSchema);
|
|
23134
23154
|
var decodeAgentInstallCancelCommand = (encoded) => decode3(encoded, agentInstallCancelCommandSchema);
|
|
23155
|
+
var encodeAgentInstallCancelCommand = (message) => encode3(message, agentInstallCancelCommandSchema);
|
|
23156
|
+
var decodeAgentInstallStartedEvent = (encoded) => decode3(encoded, agentInstallStartedEventSchema);
|
|
23135
23157
|
var encodeAgentInstallStartedEvent = (message) => encode3(message, agentInstallStartedEventSchema);
|
|
23158
|
+
var decodeAgentInstallProgressEvent = (encoded) => decode3(encoded, agentInstallProgressEventSchema);
|
|
23136
23159
|
var encodeAgentInstallProgressEvent = (message) => encode3(message, agentInstallProgressEventSchema);
|
|
23160
|
+
var decodeAgentInstallCompletedEvent = (encoded) => decode3(encoded, agentInstallCompletedEventSchema);
|
|
23137
23161
|
var encodeAgentInstallCompletedEvent = (message) => encode3(message, agentInstallCompletedEventSchema);
|
|
23162
|
+
var decodeAgentInstallFailedEvent = (encoded) => decode3(encoded, agentInstallFailedEventSchema);
|
|
23138
23163
|
var encodeAgentInstallFailedEvent = (message) => encode3(message, agentInstallFailedEventSchema);
|
|
23164
|
+
var decodeAgentInstallCancelledEvent = (encoded) => decode3(encoded, agentInstallCancelledEventSchema);
|
|
23139
23165
|
var encodeAgentInstallCancelledEvent = (message) => encode3(message, agentInstallCancelledEventSchema);
|
|
23140
23166
|
|
|
23141
23167
|
// ../protocol/src/messages.ts
|
|
@@ -23570,49 +23596,29 @@ function decodeSessionFailedEvent(encoded) {
|
|
|
23570
23596
|
sessionId: readIdentifier(value, "sessionId")
|
|
23571
23597
|
};
|
|
23572
23598
|
}
|
|
23573
|
-
function
|
|
23574
|
-
return JSON.stringify(
|
|
23575
|
-
}
|
|
23576
|
-
function encodeRuntimeDeliveryReceived(message) {
|
|
23577
|
-
return JSON.stringify(decodeRuntimeDeliveryReceived(JSON.stringify(message)));
|
|
23578
|
-
}
|
|
23579
|
-
function encodeSessionStartedEvent(message) {
|
|
23580
|
-
return JSON.stringify(decodeSessionStartedEvent(JSON.stringify(message)));
|
|
23599
|
+
function encodeSessionPromptCommand(message) {
|
|
23600
|
+
return JSON.stringify(decodeSessionPromptCommand(JSON.stringify(message)));
|
|
23581
23601
|
}
|
|
23582
|
-
function
|
|
23583
|
-
return JSON.stringify(
|
|
23602
|
+
function encodeSessionCancelCommand(message) {
|
|
23603
|
+
return JSON.stringify(decodeSessionCancelCommand(JSON.stringify(message)));
|
|
23584
23604
|
}
|
|
23585
|
-
function
|
|
23586
|
-
return JSON.stringify(
|
|
23605
|
+
function encodeRuntimeLivenessReadyEvent(message) {
|
|
23606
|
+
return JSON.stringify(decodeRuntimeLivenessReadyEvent(JSON.stringify(message)));
|
|
23587
23607
|
}
|
|
23588
|
-
function
|
|
23589
|
-
return JSON.stringify(
|
|
23608
|
+
function encodeRuntimeHeartbeatEvent(message) {
|
|
23609
|
+
return JSON.stringify(decodeRuntimeHeartbeatEvent(JSON.stringify(message)));
|
|
23590
23610
|
}
|
|
23591
|
-
function
|
|
23592
|
-
return JSON.stringify(
|
|
23611
|
+
function encodeRuntimeHeartbeatAckEvent(message) {
|
|
23612
|
+
return JSON.stringify(decodeRuntimeHeartbeatAckEvent(JSON.stringify(message)));
|
|
23593
23613
|
}
|
|
23594
|
-
|
|
23595
|
-
|
|
23596
|
-
var MOBIUS_API_PREFIX = "/mobius/api";
|
|
23597
|
-
var API_PREFIX_PATTERN = /^\/[a-zA-Z0-9._~-]+(?:\/[a-zA-Z0-9._~-]+)*$/;
|
|
23598
|
-
var MobiusApiConfigurationError = class extends Error {
|
|
23599
|
-
code = "invalid_api_prefix";
|
|
23600
|
-
constructor() {
|
|
23601
|
-
super("The Mobius API prefix must be an absolute path without parameters");
|
|
23602
|
-
this.name = "MobiusApiConfigurationError";
|
|
23603
|
-
}
|
|
23604
|
-
};
|
|
23605
|
-
function parseMobiusApiPrefix(value) {
|
|
23606
|
-
if (typeof value !== "string" || !API_PREFIX_PATTERN.test(value)) {
|
|
23607
|
-
throw new MobiusApiConfigurationError();
|
|
23608
|
-
}
|
|
23609
|
-
return value;
|
|
23614
|
+
function encodeRuntimeDelivery(message) {
|
|
23615
|
+
return JSON.stringify(decodeRuntimeDelivery(JSON.stringify(message)));
|
|
23610
23616
|
}
|
|
23611
|
-
function
|
|
23612
|
-
return
|
|
23617
|
+
function encodeRuntimeDeliveryReceived(message) {
|
|
23618
|
+
return JSON.stringify(decodeRuntimeDeliveryReceived(JSON.stringify(message)));
|
|
23613
23619
|
}
|
|
23614
|
-
function
|
|
23615
|
-
return
|
|
23620
|
+
function encodeRuntimeDeliveryCommitted(message) {
|
|
23621
|
+
return JSON.stringify(decodeRuntimeDeliveryCommitted(JSON.stringify(message)));
|
|
23616
23622
|
}
|
|
23617
23623
|
|
|
23618
23624
|
// ../protocol/src/session-history.ts
|
|
@@ -23789,9 +23795,13 @@ function decode4(schema, encoded) {
|
|
|
23789
23795
|
}
|
|
23790
23796
|
}
|
|
23791
23797
|
var decodeNativeSessionCommand = (encoded) => decode4(nativeSessionCommandSchema, encoded);
|
|
23798
|
+
var encodeNativeSessionCommand = (value) => JSON.stringify(nativeSessionCommandSchema.parse(value));
|
|
23799
|
+
var decodeNativeSessionResult = (encoded) => decode4(nativeSessionResultSchema, encoded);
|
|
23792
23800
|
var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
|
|
23793
23801
|
var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
|
|
23802
|
+
var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
|
|
23794
23803
|
var decodeNativeSessionTurnForkCommand = (encoded) => decode4(nativeSessionTurnForkCommandSchema, encoded);
|
|
23804
|
+
var encodeNativeSessionTurnForkCommand = (value) => JSON.stringify(nativeSessionTurnForkCommandSchema.parse(value));
|
|
23795
23805
|
|
|
23796
23806
|
// ../protocol/src/session-events.ts
|
|
23797
23807
|
var SESSION_EVENT_KIND = "session.event";
|
|
@@ -23883,8 +23893,285 @@ var encode4 = (message, schema) => {
|
|
|
23883
23893
|
var decodeSessionEventEnvelope = (encoded) => decode5(encoded, eventEnvelopeSchema);
|
|
23884
23894
|
var encodeSessionEventEnvelope = (message) => encode4(message, eventEnvelopeSchema);
|
|
23885
23895
|
var decodeSessionEventAcknowledgement = (encoded) => decode5(encoded, eventAcknowledgementSchema);
|
|
23896
|
+
var encodeSessionEventAcknowledgement = (message) => encode4(message, eventAcknowledgementSchema);
|
|
23886
23897
|
var decodeSessionEventDeferred = (encoded) => decode5(encoded, eventDeferredSchema);
|
|
23898
|
+
var encodeSessionEventDeferred = (message) => encode4(message, eventDeferredSchema);
|
|
23887
23899
|
var decodeSessionEventRejection = (encoded) => decode5(encoded, eventRejectionSchema);
|
|
23900
|
+
var encodeSessionEventRejection = (message) => encode4(message, eventRejectionSchema);
|
|
23901
|
+
function decodeRecordedSessionEvent(encoded) {
|
|
23902
|
+
const kind = decodeMessageKind(encoded);
|
|
23903
|
+
switch (kind) {
|
|
23904
|
+
case AGENT_ACTIVITY_KIND:
|
|
23905
|
+
return decodeAgentActivityEvent(encoded);
|
|
23906
|
+
case AGENT_CONTENT_KIND:
|
|
23907
|
+
return decodeAgentContentEvent(encoded);
|
|
23908
|
+
case AGENT_MESSAGE_DELTA_KIND:
|
|
23909
|
+
return decodeAgentMessageDeltaEvent(encoded);
|
|
23910
|
+
case SESSION_COMMANDS_UPDATED_KIND:
|
|
23911
|
+
return decodeSessionCommandsUpdatedEvent(encoded);
|
|
23912
|
+
case SESSION_COMPLETED_KIND:
|
|
23913
|
+
return decodeSessionCompletedEvent(encoded);
|
|
23914
|
+
case SESSION_CONFIG_UPDATED_KIND:
|
|
23915
|
+
return decodeSessionConfigUpdatedEvent(encoded);
|
|
23916
|
+
case SESSION_ELICITATION_REQUESTED_KIND:
|
|
23917
|
+
return decodeSessionElicitationRequestedEvent(encoded);
|
|
23918
|
+
case SESSION_ELICITATION_RESOLVED_KIND:
|
|
23919
|
+
return decodeSessionElicitationResolvedEvent(encoded);
|
|
23920
|
+
case SESSION_FAILED_KIND:
|
|
23921
|
+
return decodeSessionFailedEvent(encoded);
|
|
23922
|
+
case SESSION_INFO_UPDATED_KIND:
|
|
23923
|
+
return decodeSessionInfoUpdatedEvent(encoded);
|
|
23924
|
+
case SESSION_PERMISSION_REQUESTED_KIND:
|
|
23925
|
+
return decodeSessionPermissionRequestedEvent(encoded);
|
|
23926
|
+
case SESSION_PERMISSION_RESOLVED_KIND:
|
|
23927
|
+
return decodeSessionPermissionResolvedEvent(encoded);
|
|
23928
|
+
case SESSION_READY_KIND:
|
|
23929
|
+
return decodeSessionReadyEvent(encoded);
|
|
23930
|
+
case SESSION_STARTED_KIND:
|
|
23931
|
+
return decodeSessionStartedEvent(encoded);
|
|
23932
|
+
case SESSION_USAGE_UPDATED_KIND:
|
|
23933
|
+
return decodeSessionUsageUpdatedEvent(encoded);
|
|
23934
|
+
default:
|
|
23935
|
+
throw new ProtocolMessageError("Unsupported recorded session event");
|
|
23936
|
+
}
|
|
23937
|
+
}
|
|
23938
|
+
var encodeRecordedSessionEvent = (event) => JSON.stringify(decodeRecordedSessionEvent(JSON.stringify(event)));
|
|
23939
|
+
|
|
23940
|
+
// ../protocol/src/daemon-transport.ts
|
|
23941
|
+
function defineMessageSignature(kind, encoder, decoder) {
|
|
23942
|
+
const schema = (message) => decoder(JSON.stringify(message));
|
|
23943
|
+
return {
|
|
23944
|
+
decoder,
|
|
23945
|
+
encoder: (message) => encoder(schema(message)),
|
|
23946
|
+
kind,
|
|
23947
|
+
schema
|
|
23948
|
+
};
|
|
23949
|
+
}
|
|
23950
|
+
var serviceToDaemonSignatures = {
|
|
23951
|
+
[AGENT_CATALOG_REFRESH_KIND]: defineMessageSignature(
|
|
23952
|
+
AGENT_CATALOG_REFRESH_KIND,
|
|
23953
|
+
encodeAgentCatalogRefreshCommand,
|
|
23954
|
+
decodeAgentCatalogRefreshCommand
|
|
23955
|
+
),
|
|
23956
|
+
[AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
|
|
23957
|
+
AGENT_INSTALL_CANCEL_KIND,
|
|
23958
|
+
encodeAgentInstallCancelCommand,
|
|
23959
|
+
decodeAgentInstallCancelCommand
|
|
23960
|
+
),
|
|
23961
|
+
[AGENT_INSTALL_REQUEST_KIND]: defineMessageSignature(
|
|
23962
|
+
AGENT_INSTALL_REQUEST_KIND,
|
|
23963
|
+
encodeAgentInstallRequestCommand,
|
|
23964
|
+
decodeAgentInstallRequestCommand
|
|
23965
|
+
),
|
|
23966
|
+
[AGENT_SETTINGS_DISCOVER_KIND]: defineMessageSignature(
|
|
23967
|
+
AGENT_SETTINGS_DISCOVER_KIND,
|
|
23968
|
+
encodeAgentSettingsDiscoverCommand,
|
|
23969
|
+
decodeAgentSettingsDiscoverCommand
|
|
23970
|
+
),
|
|
23971
|
+
[FILE_READ_KIND]: defineMessageSignature(FILE_READ_KIND, encodeFileReadCommand, decodeFileReadCommand),
|
|
23972
|
+
[NATIVE_SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
23973
|
+
NATIVE_SESSION_CANCEL_KIND,
|
|
23974
|
+
encodeNativeSessionCancel,
|
|
23975
|
+
decodeNativeSessionCancel
|
|
23976
|
+
),
|
|
23977
|
+
[NATIVE_SESSION_REQUEST_KIND]: defineMessageSignature(
|
|
23978
|
+
NATIVE_SESSION_REQUEST_KIND,
|
|
23979
|
+
encodeNativeSessionCommand,
|
|
23980
|
+
decodeNativeSessionCommand
|
|
23981
|
+
),
|
|
23982
|
+
[NATIVE_SESSION_TURN_FORK_KIND]: defineMessageSignature(
|
|
23983
|
+
NATIVE_SESSION_TURN_FORK_KIND,
|
|
23984
|
+
encodeNativeSessionTurnForkCommand,
|
|
23985
|
+
decodeNativeSessionTurnForkCommand
|
|
23986
|
+
),
|
|
23987
|
+
[RUNTIME_DELIVERY_KIND]: defineMessageSignature(
|
|
23988
|
+
RUNTIME_DELIVERY_KIND,
|
|
23989
|
+
encodeRuntimeDelivery,
|
|
23990
|
+
decodeRuntimeDelivery
|
|
23991
|
+
),
|
|
23992
|
+
[RUNTIME_DELIVERY_COMMITTED_KIND]: defineMessageSignature(
|
|
23993
|
+
RUNTIME_DELIVERY_COMMITTED_KIND,
|
|
23994
|
+
encodeRuntimeDeliveryCommitted,
|
|
23995
|
+
decodeRuntimeDeliveryCommitted
|
|
23996
|
+
),
|
|
23997
|
+
[RUNTIME_HEARTBEAT_ACK_KIND]: defineMessageSignature(
|
|
23998
|
+
RUNTIME_HEARTBEAT_ACK_KIND,
|
|
23999
|
+
encodeRuntimeHeartbeatAckEvent,
|
|
24000
|
+
decodeRuntimeHeartbeatAckEvent
|
|
24001
|
+
),
|
|
24002
|
+
[RUNTIME_LIVENESS_READY_KIND]: defineMessageSignature(
|
|
24003
|
+
RUNTIME_LIVENESS_READY_KIND,
|
|
24004
|
+
encodeRuntimeLivenessReadyEvent,
|
|
24005
|
+
decodeRuntimeLivenessReadyEvent
|
|
24006
|
+
),
|
|
24007
|
+
[SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
24008
|
+
SESSION_CANCEL_KIND,
|
|
24009
|
+
encodeSessionCancelCommand,
|
|
24010
|
+
decodeSessionCancelCommand
|
|
24011
|
+
),
|
|
24012
|
+
[SESSION_CONFIGURE_KIND]: defineMessageSignature(
|
|
24013
|
+
SESSION_CONFIGURE_KIND,
|
|
24014
|
+
encodeSessionConfigureCommand,
|
|
24015
|
+
decodeSessionConfigureCommand
|
|
24016
|
+
),
|
|
24017
|
+
[SESSION_ELICITATION_RESPOND_KIND]: defineMessageSignature(
|
|
24018
|
+
SESSION_ELICITATION_RESPOND_KIND,
|
|
24019
|
+
encodeSessionElicitationRespondCommand,
|
|
24020
|
+
decodeSessionElicitationRespondCommand
|
|
24021
|
+
),
|
|
24022
|
+
[SESSION_EVENT_ACK_KIND]: defineMessageSignature(
|
|
24023
|
+
SESSION_EVENT_ACK_KIND,
|
|
24024
|
+
encodeSessionEventAcknowledgement,
|
|
24025
|
+
decodeSessionEventAcknowledgement
|
|
24026
|
+
),
|
|
24027
|
+
[SESSION_EVENT_DEFERRED_KIND]: defineMessageSignature(
|
|
24028
|
+
SESSION_EVENT_DEFERRED_KIND,
|
|
24029
|
+
encodeSessionEventDeferred,
|
|
24030
|
+
decodeSessionEventDeferred
|
|
24031
|
+
),
|
|
24032
|
+
[SESSION_EVENT_REJECTED_KIND]: defineMessageSignature(
|
|
24033
|
+
SESSION_EVENT_REJECTED_KIND,
|
|
24034
|
+
encodeSessionEventRejection,
|
|
24035
|
+
decodeSessionEventRejection
|
|
24036
|
+
),
|
|
24037
|
+
[SESSION_PERMISSION_RESPOND_KIND]: defineMessageSignature(
|
|
24038
|
+
SESSION_PERMISSION_RESPOND_KIND,
|
|
24039
|
+
encodeSessionPermissionRespondCommand,
|
|
24040
|
+
decodeSessionPermissionRespondCommand
|
|
24041
|
+
),
|
|
24042
|
+
[SESSION_PREPARE_KIND]: defineMessageSignature(
|
|
24043
|
+
SESSION_PREPARE_KIND,
|
|
24044
|
+
encodeSessionPrepareCommand,
|
|
24045
|
+
decodeSessionPrepareCommand
|
|
24046
|
+
),
|
|
24047
|
+
[SESSION_PROMPT_KIND]: defineMessageSignature(
|
|
24048
|
+
SESSION_PROMPT_KIND,
|
|
24049
|
+
encodeSessionPromptCommand,
|
|
24050
|
+
decodeSessionPromptCommand
|
|
24051
|
+
),
|
|
24052
|
+
[WORKSPACE_LIST_KIND]: defineMessageSignature(
|
|
24053
|
+
WORKSPACE_LIST_KIND,
|
|
24054
|
+
encodeWorkspaceListCommand,
|
|
24055
|
+
decodeWorkspaceListCommand
|
|
24056
|
+
)
|
|
24057
|
+
};
|
|
24058
|
+
var serviceToDaemonRegistry = serviceToDaemonSignatures;
|
|
24059
|
+
function decodeServiceToDaemonMessage(encoded) {
|
|
24060
|
+
const kind = decodeMessageKind(encoded);
|
|
24061
|
+
const signature = serviceToDaemonRegistry[kind];
|
|
24062
|
+
if (signature === void 0) {
|
|
24063
|
+
throw new ProtocolMessageError(`Unsupported service-to-daemon message kind: ${kind}`);
|
|
24064
|
+
}
|
|
24065
|
+
return signature.decoder(encoded);
|
|
24066
|
+
}
|
|
24067
|
+
var daemonToServiceSignatures = {
|
|
24068
|
+
[AGENT_CATALOG_REFRESHED_KIND]: defineMessageSignature(
|
|
24069
|
+
AGENT_CATALOG_REFRESHED_KIND,
|
|
24070
|
+
encodeAgentCatalogRefreshedEvent,
|
|
24071
|
+
decodeAgentCatalogRefreshedEvent
|
|
24072
|
+
),
|
|
24073
|
+
[AGENT_CATALOG_REFRESH_FAILED_KIND]: defineMessageSignature(
|
|
24074
|
+
AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
24075
|
+
encodeAgentCatalogRefreshFailedEvent,
|
|
24076
|
+
decodeAgentCatalogRefreshFailedEvent
|
|
24077
|
+
),
|
|
24078
|
+
[AGENT_INSTALL_CANCELLED_KIND]: defineMessageSignature(
|
|
24079
|
+
AGENT_INSTALL_CANCELLED_KIND,
|
|
24080
|
+
encodeAgentInstallCancelledEvent,
|
|
24081
|
+
decodeAgentInstallCancelledEvent
|
|
24082
|
+
),
|
|
24083
|
+
[AGENT_INSTALL_COMPLETED_KIND]: defineMessageSignature(
|
|
24084
|
+
AGENT_INSTALL_COMPLETED_KIND,
|
|
24085
|
+
encodeAgentInstallCompletedEvent,
|
|
24086
|
+
decodeAgentInstallCompletedEvent
|
|
24087
|
+
),
|
|
24088
|
+
[AGENT_INSTALL_FAILED_KIND]: defineMessageSignature(
|
|
24089
|
+
AGENT_INSTALL_FAILED_KIND,
|
|
24090
|
+
encodeAgentInstallFailedEvent,
|
|
24091
|
+
decodeAgentInstallFailedEvent
|
|
24092
|
+
),
|
|
24093
|
+
[AGENT_INSTALL_PROGRESS_KIND]: defineMessageSignature(
|
|
24094
|
+
AGENT_INSTALL_PROGRESS_KIND,
|
|
24095
|
+
encodeAgentInstallProgressEvent,
|
|
24096
|
+
decodeAgentInstallProgressEvent
|
|
24097
|
+
),
|
|
24098
|
+
[AGENT_INSTALL_STARTED_KIND]: defineMessageSignature(
|
|
24099
|
+
AGENT_INSTALL_STARTED_KIND,
|
|
24100
|
+
encodeAgentInstallStartedEvent,
|
|
24101
|
+
decodeAgentInstallStartedEvent
|
|
24102
|
+
),
|
|
24103
|
+
[AGENT_SETTINGS_DISCOVERED_KIND]: defineMessageSignature(
|
|
24104
|
+
AGENT_SETTINGS_DISCOVERED_KIND,
|
|
24105
|
+
encodeAgentSettingsDiscoveredEvent,
|
|
24106
|
+
decodeAgentSettingsDiscoveredEvent
|
|
24107
|
+
),
|
|
24108
|
+
[AGENT_SETTINGS_DISCOVERY_FAILED_KIND]: defineMessageSignature(
|
|
24109
|
+
AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
24110
|
+
encodeAgentSettingsDiscoveryFailedEvent,
|
|
24111
|
+
decodeAgentSettingsDiscoveryFailedEvent
|
|
24112
|
+
),
|
|
24113
|
+
[FILE_BEGIN_KIND]: defineMessageSignature(FILE_BEGIN_KIND, encodeFileBeginEvent, decodeFileBeginEvent),
|
|
24114
|
+
[FILE_CHUNK_KIND]: defineMessageSignature(FILE_CHUNK_KIND, encodeFileChunkEvent, decodeFileChunkEvent),
|
|
24115
|
+
[FILE_END_KIND]: defineMessageSignature(FILE_END_KIND, encodeFileEndEvent, decodeFileEndEvent),
|
|
24116
|
+
[FILE_FAILED_KIND]: defineMessageSignature(FILE_FAILED_KIND, encodeFileFailedEvent, decodeFileFailedEvent),
|
|
24117
|
+
[NATIVE_SESSION_RESULT_KIND]: defineMessageSignature(
|
|
24118
|
+
NATIVE_SESSION_RESULT_KIND,
|
|
24119
|
+
encodeNativeSessionResult,
|
|
24120
|
+
decodeNativeSessionResult
|
|
24121
|
+
),
|
|
24122
|
+
[RUNTIME_DELIVERY_RECEIVED_KIND]: defineMessageSignature(
|
|
24123
|
+
RUNTIME_DELIVERY_RECEIVED_KIND,
|
|
24124
|
+
encodeRuntimeDeliveryReceived,
|
|
24125
|
+
decodeRuntimeDeliveryReceived
|
|
24126
|
+
),
|
|
24127
|
+
[RUNTIME_HEARTBEAT_KIND]: defineMessageSignature(
|
|
24128
|
+
RUNTIME_HEARTBEAT_KIND,
|
|
24129
|
+
encodeRuntimeHeartbeatEvent,
|
|
24130
|
+
decodeRuntimeHeartbeatEvent
|
|
24131
|
+
),
|
|
24132
|
+
[SESSION_EVENT_KIND]: defineMessageSignature(
|
|
24133
|
+
SESSION_EVENT_KIND,
|
|
24134
|
+
encodeSessionEventEnvelope,
|
|
24135
|
+
decodeSessionEventEnvelope
|
|
24136
|
+
),
|
|
24137
|
+
[SESSION_OPERATION_FAILED_KIND]: defineMessageSignature(
|
|
24138
|
+
SESSION_OPERATION_FAILED_KIND,
|
|
24139
|
+
encodeSessionOperationFailedEvent,
|
|
24140
|
+
decodeSessionOperationFailedEvent
|
|
24141
|
+
),
|
|
24142
|
+
[SESSION_READY_KIND]: defineMessageSignature(SESSION_READY_KIND, encodeSessionReadyEvent, decodeSessionReadyEvent),
|
|
24143
|
+
[WORKSPACE_ENTRIES_KIND]: defineMessageSignature(
|
|
24144
|
+
WORKSPACE_ENTRIES_KIND,
|
|
24145
|
+
encodeWorkspaceEntriesEvent,
|
|
24146
|
+
decodeWorkspaceEntriesEvent
|
|
24147
|
+
)
|
|
24148
|
+
};
|
|
24149
|
+
function encodeDaemonToServiceMessage(message) {
|
|
24150
|
+
return daemonToServiceSignatures[message.kind].encoder(message);
|
|
24151
|
+
}
|
|
24152
|
+
|
|
24153
|
+
// ../protocol/src/mobius-api.ts
|
|
24154
|
+
var MOBIUS_API_PREFIX = "/mobius/api";
|
|
24155
|
+
var API_PREFIX_PATTERN = /^\/[a-zA-Z0-9._~-]+(?:\/[a-zA-Z0-9._~-]+)*$/;
|
|
24156
|
+
var MobiusApiConfigurationError = class extends Error {
|
|
24157
|
+
code = "invalid_api_prefix";
|
|
24158
|
+
constructor() {
|
|
24159
|
+
super("The Mobius API prefix must be an absolute path without parameters");
|
|
24160
|
+
this.name = "MobiusApiConfigurationError";
|
|
24161
|
+
}
|
|
24162
|
+
};
|
|
24163
|
+
function parseMobiusApiPrefix(value) {
|
|
24164
|
+
if (typeof value !== "string" || !API_PREFIX_PATTERN.test(value)) {
|
|
24165
|
+
throw new MobiusApiConfigurationError();
|
|
24166
|
+
}
|
|
24167
|
+
return value;
|
|
24168
|
+
}
|
|
24169
|
+
function mobiusApiPath(resourcePath, apiPrefix = MOBIUS_API_PREFIX) {
|
|
24170
|
+
return `${parseMobiusApiPrefix(apiPrefix)}${resourcePath}`;
|
|
24171
|
+
}
|
|
24172
|
+
function mobiusApiUrl(origin, resourcePath, apiPrefix = MOBIUS_API_PREFIX) {
|
|
24173
|
+
return new URL(mobiusApiPath(resourcePath, apiPrefix), origin);
|
|
24174
|
+
}
|
|
23888
24175
|
|
|
23889
24176
|
// src/config.ts
|
|
23890
24177
|
function loadDefaultWorkspace(environment = process.env) {
|
|
@@ -35707,11 +35994,42 @@ function relayHttpEndpoint(relayUrl) {
|
|
|
35707
35994
|
var CATALOG_UPDATE_TIMEOUT_MILLISECONDS = 2e4;
|
|
35708
35995
|
var AgentCatalogPublishError = class extends Error {
|
|
35709
35996
|
code = "agent_catalog_update_failed";
|
|
35710
|
-
|
|
35997
|
+
diagnosticDetails;
|
|
35998
|
+
constructor(message, options = {}, diagnosticDetails = {}) {
|
|
35711
35999
|
super(message, options);
|
|
36000
|
+
this.diagnosticDetails = diagnosticDetails;
|
|
35712
36001
|
this.name = "AgentCatalogPublishError";
|
|
35713
36002
|
}
|
|
35714
36003
|
};
|
|
36004
|
+
function isRecord8(value) {
|
|
36005
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36006
|
+
}
|
|
36007
|
+
function isSafeRelayErrorMessage(value) {
|
|
36008
|
+
return value.length > 0 && value.length <= 512 && Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
|
|
36009
|
+
}
|
|
36010
|
+
async function rejectedCatalogError(response) {
|
|
36011
|
+
let value;
|
|
36012
|
+
try {
|
|
36013
|
+
value = await response.json();
|
|
36014
|
+
} catch {
|
|
36015
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
36016
|
+
}
|
|
36017
|
+
if (!isRecord8(value) || !isRecord8(value["error"])) {
|
|
36018
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
36019
|
+
}
|
|
36020
|
+
const code = value["error"]["code"];
|
|
36021
|
+
const message = value["error"]["message"];
|
|
36022
|
+
if (typeof code !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(code) || typeof message !== "string" || !isSafeRelayErrorMessage(message)) {
|
|
36023
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
36024
|
+
}
|
|
36025
|
+
return new AgentCatalogPublishError(
|
|
36026
|
+
`The Relay rejected the Agent catalog update (${code}): ${message}`,
|
|
36027
|
+
{},
|
|
36028
|
+
{
|
|
36029
|
+
relayErrorCode: code
|
|
36030
|
+
}
|
|
36031
|
+
);
|
|
36032
|
+
}
|
|
35715
36033
|
function catalogEndpoint(config2) {
|
|
35716
36034
|
const endpoint = relayHttpEndpoint(config2.relayUrl);
|
|
35717
36035
|
if (endpoint.pathname.endsWith("/daemon")) {
|
|
@@ -35759,10 +36077,10 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
35759
36077
|
{ cause: error62 }
|
|
35760
36078
|
);
|
|
35761
36079
|
}
|
|
35762
|
-
await response.body?.cancel();
|
|
35763
36080
|
if (!response.ok) {
|
|
35764
|
-
throw
|
|
36081
|
+
throw await rejectedCatalogError(response);
|
|
35765
36082
|
}
|
|
36083
|
+
await response.body?.cancel();
|
|
35766
36084
|
}
|
|
35767
36085
|
|
|
35768
36086
|
// src/agent-installation/agent-installation-manager.ts
|
|
@@ -36271,30 +36589,26 @@ async function streamLocalFile(command, send2, signal) {
|
|
|
36271
36589
|
throw new Error("The local file is too large to read");
|
|
36272
36590
|
}
|
|
36273
36591
|
const raster = await readLocalRaster(target, signal);
|
|
36274
|
-
send2(
|
|
36275
|
-
|
|
36276
|
-
|
|
36277
|
-
|
|
36278
|
-
|
|
36279
|
-
|
|
36280
|
-
|
|
36281
|
-
|
|
36282
|
-
|
|
36283
|
-
})
|
|
36284
|
-
);
|
|
36592
|
+
send2({
|
|
36593
|
+
byteLength: before.size,
|
|
36594
|
+
kind: FILE_BEGIN_KIND,
|
|
36595
|
+
mediaType: raster?.mimeType ?? "application/octet-stream",
|
|
36596
|
+
modifiedAt: before.mtime.toISOString(),
|
|
36597
|
+
name: basename3(target) || "file",
|
|
36598
|
+
requestId: command.requestId,
|
|
36599
|
+
sessionId: command.sessionId
|
|
36600
|
+
});
|
|
36285
36601
|
let sequence = 0;
|
|
36286
36602
|
const stream = createReadStream2(target, { highWaterMark: CHUNK_BYTES, signal });
|
|
36287
36603
|
for await (const value of stream) {
|
|
36288
36604
|
const bytes = value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
36289
|
-
send2(
|
|
36290
|
-
|
|
36291
|
-
|
|
36292
|
-
|
|
36293
|
-
|
|
36294
|
-
|
|
36295
|
-
|
|
36296
|
-
})
|
|
36297
|
-
);
|
|
36605
|
+
send2({
|
|
36606
|
+
data: Buffer.from(bytes).toString("base64"),
|
|
36607
|
+
kind: FILE_CHUNK_KIND,
|
|
36608
|
+
requestId: command.requestId,
|
|
36609
|
+
sequence,
|
|
36610
|
+
sessionId: command.sessionId
|
|
36611
|
+
});
|
|
36298
36612
|
sequence += 1;
|
|
36299
36613
|
}
|
|
36300
36614
|
const after = await stat6(target);
|
|
@@ -36302,13 +36616,11 @@ async function streamLocalFile(command, send2, signal) {
|
|
|
36302
36616
|
if (after.size !== before.size || after.mtimeMs !== before.mtimeMs) {
|
|
36303
36617
|
throw new Error("The local file changed during transfer");
|
|
36304
36618
|
}
|
|
36305
|
-
send2(
|
|
36306
|
-
|
|
36307
|
-
|
|
36308
|
-
|
|
36309
|
-
|
|
36310
|
-
})
|
|
36311
|
-
);
|
|
36619
|
+
send2({
|
|
36620
|
+
kind: FILE_END_KIND,
|
|
36621
|
+
requestId: command.requestId,
|
|
36622
|
+
sessionId: command.sessionId
|
|
36623
|
+
});
|
|
36312
36624
|
}
|
|
36313
36625
|
|
|
36314
36626
|
// src/artifacts/runtime-artifact-uploader.ts
|
|
@@ -36341,11 +36653,11 @@ var IDENTIFIER_PATTERN4 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
|
36341
36653
|
function invalidResponse(message) {
|
|
36342
36654
|
return new MobiusProtocolError(message);
|
|
36343
36655
|
}
|
|
36344
|
-
function
|
|
36656
|
+
function isRecord9(value) {
|
|
36345
36657
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36346
36658
|
}
|
|
36347
36659
|
function record2(value, name) {
|
|
36348
|
-
if (!
|
|
36660
|
+
if (!isRecord9(value)) {
|
|
36349
36661
|
throw invalidResponse(`The service returned an invalid ${name}`);
|
|
36350
36662
|
}
|
|
36351
36663
|
return value;
|
|
@@ -37995,6 +38307,25 @@ var RelayConnectionDiagnostics = class {
|
|
|
37995
38307
|
addFailureDetails(details, failure2);
|
|
37996
38308
|
this.#record("relay_connection_failed", connectionEpoch.toString(), details, true);
|
|
37997
38309
|
};
|
|
38310
|
+
/**
|
|
38311
|
+
* Records that the Runtime gave up on Agent turns the Relay already settled. This is not a connection
|
|
38312
|
+
* failure, so it is recorded independently of the per-epoch failure deduplication.
|
|
38313
|
+
*/
|
|
38314
|
+
reconciliationAbandoned = (connectionEpoch, relayErrorCode2, turnCount) => {
|
|
38315
|
+
this.#record(
|
|
38316
|
+
"relay_reconciliation_abandoned",
|
|
38317
|
+
connectionEpoch.toString(),
|
|
38318
|
+
{
|
|
38319
|
+
connectionEpoch: connectionEpoch.toString(),
|
|
38320
|
+
relayErrorCode: relayErrorCode2 ?? "unknown",
|
|
38321
|
+
relayOrigin: this.#relayOrigin,
|
|
38322
|
+
source: "reconciliation_abandoned",
|
|
38323
|
+
turnCount: turnCount.toString(),
|
|
38324
|
+
...this.#route
|
|
38325
|
+
},
|
|
38326
|
+
true
|
|
38327
|
+
);
|
|
38328
|
+
};
|
|
37998
38329
|
connectionOpened = (connectionEpoch) => {
|
|
37999
38330
|
this.#record(
|
|
38000
38331
|
"relay_connection_opened",
|
|
@@ -38134,12 +38465,10 @@ var RelayConnectionLiveness = class {
|
|
|
38134
38465
|
heartbeatId,
|
|
38135
38466
|
this.#timer.schedule(this.#handleTimeout, HEARTBEAT_ACK_TIMEOUT_MILLISECONDS)
|
|
38136
38467
|
);
|
|
38137
|
-
const sent = this.#transport.send(
|
|
38138
|
-
|
|
38139
|
-
|
|
38140
|
-
|
|
38141
|
-
})
|
|
38142
|
-
);
|
|
38468
|
+
const sent = this.#transport.send({
|
|
38469
|
+
heartbeatId,
|
|
38470
|
+
kind: RUNTIME_HEARTBEAT_KIND
|
|
38471
|
+
});
|
|
38143
38472
|
if (!sent && this.#state instanceof AwaitingHeartbeatAckState && this.#state.heartbeatId === heartbeatId) {
|
|
38144
38473
|
this.#state.timeout.cancel();
|
|
38145
38474
|
this.#state = new FinishedRelayLivenessState();
|
|
@@ -38759,39 +39088,39 @@ var DaemonAcpObserver = class {
|
|
|
38759
39088
|
}
|
|
38760
39089
|
importLocalArtifact = async (sessionId, artifact, signal) => (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
|
|
38761
39090
|
onCommands = (event) => {
|
|
38762
|
-
this.#record(event.sessionId,
|
|
39091
|
+
this.#record(event.sessionId, event);
|
|
38763
39092
|
return Promise.resolve();
|
|
38764
39093
|
};
|
|
38765
39094
|
onConfig = (event) => {
|
|
38766
|
-
this.#record(event.sessionId,
|
|
39095
|
+
this.#record(event.sessionId, event);
|
|
38767
39096
|
return Promise.resolve();
|
|
38768
39097
|
};
|
|
38769
39098
|
onContent = (event) => {
|
|
38770
|
-
this.#record(event.sessionId,
|
|
39099
|
+
this.#record(event.sessionId, event);
|
|
38771
39100
|
return Promise.resolve();
|
|
38772
39101
|
};
|
|
38773
39102
|
onElicitation = (event) => {
|
|
38774
|
-
this.#record(event.sessionId,
|
|
39103
|
+
this.#record(event.sessionId, event);
|
|
38775
39104
|
return Promise.resolve();
|
|
38776
39105
|
};
|
|
38777
39106
|
onElicitationResolved = (event) => {
|
|
38778
|
-
this.#record(event.sessionId,
|
|
39107
|
+
this.#record(event.sessionId, event);
|
|
38779
39108
|
return Promise.resolve();
|
|
38780
39109
|
};
|
|
38781
39110
|
onInfo = (event) => {
|
|
38782
|
-
this.#record(event.sessionId,
|
|
39111
|
+
this.#record(event.sessionId, event);
|
|
38783
39112
|
return Promise.resolve();
|
|
38784
39113
|
};
|
|
38785
39114
|
onPermission = (event) => {
|
|
38786
|
-
this.#record(event.sessionId,
|
|
39115
|
+
this.#record(event.sessionId, event);
|
|
38787
39116
|
return Promise.resolve();
|
|
38788
39117
|
};
|
|
38789
39118
|
onPermissionResolved = (event) => {
|
|
38790
|
-
this.#record(event.sessionId,
|
|
39119
|
+
this.#record(event.sessionId, event);
|
|
38791
39120
|
return Promise.resolve();
|
|
38792
39121
|
};
|
|
38793
39122
|
onUsage = (event) => {
|
|
38794
|
-
this.#record(event.sessionId,
|
|
39123
|
+
this.#record(event.sessionId, event);
|
|
38795
39124
|
return Promise.resolve();
|
|
38796
39125
|
};
|
|
38797
39126
|
};
|
|
@@ -38840,60 +39169,45 @@ var DaemonInstallationObserver = class {
|
|
|
38840
39169
|
if (state instanceof RunningInstallation) {
|
|
38841
39170
|
if (!this.#started.has(state.requestId)) {
|
|
38842
39171
|
this.#started.add(state.requestId);
|
|
38843
|
-
this.#send(
|
|
38844
|
-
socket,
|
|
38845
|
-
encodeAgentInstallStartedEvent({
|
|
38846
|
-
agentId: state.agentId,
|
|
38847
|
-
kind: AGENT_INSTALL_STARTED_KIND,
|
|
38848
|
-
requestId: state.requestId
|
|
38849
|
-
})
|
|
38850
|
-
);
|
|
38851
|
-
}
|
|
38852
|
-
this.#send(
|
|
38853
|
-
socket,
|
|
38854
|
-
encodeAgentInstallProgressEvent({
|
|
39172
|
+
this.#send(socket, {
|
|
38855
39173
|
agentId: state.agentId,
|
|
38856
|
-
kind:
|
|
38857
|
-
requestId: state.requestId
|
|
38858
|
-
|
|
38859
|
-
|
|
38860
|
-
|
|
39174
|
+
kind: AGENT_INSTALL_STARTED_KIND,
|
|
39175
|
+
requestId: state.requestId
|
|
39176
|
+
});
|
|
39177
|
+
}
|
|
39178
|
+
this.#send(socket, {
|
|
39179
|
+
agentId: state.agentId,
|
|
39180
|
+
kind: AGENT_INSTALL_PROGRESS_KIND,
|
|
39181
|
+
requestId: state.requestId,
|
|
39182
|
+
stage: state.stage
|
|
39183
|
+
});
|
|
38861
39184
|
return Promise.resolve();
|
|
38862
39185
|
}
|
|
38863
39186
|
if (state instanceof SucceededInstallation) {
|
|
38864
|
-
this.#send(
|
|
38865
|
-
|
|
38866
|
-
|
|
38867
|
-
|
|
38868
|
-
|
|
38869
|
-
|
|
38870
|
-
requestId: state.requestId
|
|
38871
|
-
})
|
|
38872
|
-
);
|
|
39187
|
+
this.#send(socket, {
|
|
39188
|
+
agentId: state.agentId,
|
|
39189
|
+
authenticationMayBeRequired: state.authenticationMayBeRequired,
|
|
39190
|
+
kind: AGENT_INSTALL_COMPLETED_KIND,
|
|
39191
|
+
requestId: state.requestId
|
|
39192
|
+
});
|
|
38873
39193
|
return Promise.resolve();
|
|
38874
39194
|
}
|
|
38875
39195
|
if (state instanceof FailedInstallation) {
|
|
38876
|
-
this.#send(
|
|
38877
|
-
|
|
38878
|
-
|
|
38879
|
-
|
|
38880
|
-
|
|
38881
|
-
|
|
38882
|
-
|
|
38883
|
-
requestId: state.requestId
|
|
38884
|
-
})
|
|
38885
|
-
);
|
|
39196
|
+
this.#send(socket, {
|
|
39197
|
+
agentId: state.agentId,
|
|
39198
|
+
code: state.code,
|
|
39199
|
+
kind: AGENT_INSTALL_FAILED_KIND,
|
|
39200
|
+
message: state.message,
|
|
39201
|
+
requestId: state.requestId
|
|
39202
|
+
});
|
|
38886
39203
|
return Promise.resolve();
|
|
38887
39204
|
}
|
|
38888
39205
|
if (state instanceof CancelledInstallation) {
|
|
38889
|
-
this.#send(
|
|
38890
|
-
|
|
38891
|
-
|
|
38892
|
-
|
|
38893
|
-
|
|
38894
|
-
requestId: state.requestId
|
|
38895
|
-
})
|
|
38896
|
-
);
|
|
39206
|
+
this.#send(socket, {
|
|
39207
|
+
agentId: state.agentId,
|
|
39208
|
+
kind: AGENT_INSTALL_CANCELLED_KIND,
|
|
39209
|
+
requestId: state.requestId
|
|
39210
|
+
});
|
|
38897
39211
|
return Promise.resolve();
|
|
38898
39212
|
}
|
|
38899
39213
|
throw new Error("Unsupported Agent integration installation state");
|
|
@@ -38941,11 +39255,34 @@ var ActiveDaemonTurn = class {
|
|
|
38941
39255
|
};
|
|
38942
39256
|
var ActiveTurnReconciliationError = class extends Error {
|
|
38943
39257
|
code = "active_turn_reconciliation_failed";
|
|
39258
|
+
diagnosticDetails;
|
|
39259
|
+
relayErrorCode;
|
|
39260
|
+
terminal;
|
|
38944
39261
|
constructor(message, options = {}) {
|
|
38945
39262
|
super(message, options);
|
|
38946
39263
|
this.name = "ActiveTurnReconciliationError";
|
|
39264
|
+
this.relayErrorCode = options.relayErrorCode ?? null;
|
|
39265
|
+
this.terminal = options.terminal ?? false;
|
|
39266
|
+
this.diagnosticDetails = this.relayErrorCode === null ? {} : { relayErrorCode: this.relayErrorCode };
|
|
38947
39267
|
}
|
|
38948
39268
|
};
|
|
39269
|
+
var TERMINAL_RECONCILIATION_RELAY_CODES = /* @__PURE__ */ new Set(["session_conflict"]);
|
|
39270
|
+
async function relayErrorCode(response) {
|
|
39271
|
+
try {
|
|
39272
|
+
const body = JSON.parse(await response.text());
|
|
39273
|
+
if (typeof body !== "object" || body === null) {
|
|
39274
|
+
return null;
|
|
39275
|
+
}
|
|
39276
|
+
const error62 = Reflect.get(body, "error");
|
|
39277
|
+
if (typeof error62 !== "object" || error62 === null) {
|
|
39278
|
+
return null;
|
|
39279
|
+
}
|
|
39280
|
+
const code = Reflect.get(error62, "code");
|
|
39281
|
+
return typeof code === "string" && code.length > 0 ? code : null;
|
|
39282
|
+
} catch {
|
|
39283
|
+
return null;
|
|
39284
|
+
}
|
|
39285
|
+
}
|
|
38949
39286
|
function activeTurnReconciliationEndpoint(config2, turn) {
|
|
38950
39287
|
const endpoint = relayHttpEndpoint(config2.relayUrl);
|
|
38951
39288
|
let channelPath = "";
|
|
@@ -38983,12 +39320,15 @@ async function reconcileActiveTurn(config2, turn, signal) {
|
|
|
38983
39320
|
{ cause: error62 }
|
|
38984
39321
|
);
|
|
38985
39322
|
}
|
|
38986
|
-
await response.body?.cancel();
|
|
38987
39323
|
if (!response.ok) {
|
|
39324
|
+
const errorCode = await relayErrorCode(response);
|
|
39325
|
+
const terminal = errorCode !== null && TERMINAL_RECONCILIATION_RELAY_CODES.has(errorCode);
|
|
38988
39326
|
throw new ActiveTurnReconciliationError(
|
|
38989
|
-
`The Relay rejected the active Agent turn reconciliation with status ${response.status.toString()}
|
|
39327
|
+
terminal ? `The Relay reported that the active Agent turn can no longer be reconciled (${errorCode})` : `The Relay rejected the active Agent turn reconciliation with status ${response.status.toString()}`,
|
|
39328
|
+
{ relayErrorCode: errorCode, terminal }
|
|
38990
39329
|
);
|
|
38991
39330
|
}
|
|
39331
|
+
await response.body?.cancel();
|
|
38992
39332
|
}
|
|
38993
39333
|
async function reconcileActiveTurns(config2, turns, signal) {
|
|
38994
39334
|
await Promise.all(turns.map(async (turn) => await reconcileActiveTurn(config2, turn, signal)));
|
|
@@ -38997,7 +39337,7 @@ function send(socket, message) {
|
|
|
38997
39337
|
if (socket.readyState !== WebSocket2.OPEN) {
|
|
38998
39338
|
throw new Error("Relay connection is not open");
|
|
38999
39339
|
}
|
|
39000
|
-
socket.send(message);
|
|
39340
|
+
socket.send(encodeDaemonToServiceMessage(message));
|
|
39001
39341
|
}
|
|
39002
39342
|
function closeRelaySocket(socket, code, reason) {
|
|
39003
39343
|
try {
|
|
@@ -39031,7 +39371,7 @@ var ConnectedDaemonSessionEventState = class extends DaemonSessionEventConnectio
|
|
|
39031
39371
|
return false;
|
|
39032
39372
|
}
|
|
39033
39373
|
try {
|
|
39034
|
-
this.#socket.send(message);
|
|
39374
|
+
this.#socket.send(encodeDaemonToServiceMessage(message));
|
|
39035
39375
|
return true;
|
|
39036
39376
|
} catch {
|
|
39037
39377
|
return false;
|
|
@@ -39075,17 +39415,17 @@ var DaemonSessionEventPublisher = class {
|
|
|
39075
39415
|
this.#connection = this.#connection.disconnect(socket);
|
|
39076
39416
|
this.#clearInFlight();
|
|
39077
39417
|
};
|
|
39078
|
-
recordAttempt = (sessionId,
|
|
39079
|
-
const
|
|
39080
|
-
if (kind === SESSION_COMPLETED_KIND || kind === SESSION_FAILED_KIND) {
|
|
39081
|
-
this.#outbox.enqueueCritical(sessionId,
|
|
39418
|
+
recordAttempt = (sessionId, event, attemptId) => {
|
|
39419
|
+
const encoded = encodeRecordedSessionEvent(event);
|
|
39420
|
+
if (event.kind === SESSION_COMPLETED_KIND || event.kind === SESSION_FAILED_KIND) {
|
|
39421
|
+
this.#outbox.enqueueCritical(sessionId, encoded, attemptId);
|
|
39082
39422
|
} else {
|
|
39083
|
-
this.#outbox.enqueue(sessionId,
|
|
39423
|
+
this.#outbox.enqueue(sessionId, encoded, attemptId);
|
|
39084
39424
|
}
|
|
39085
39425
|
this.#publishNextBatch();
|
|
39086
39426
|
};
|
|
39087
|
-
recordRuntime = (sessionId,
|
|
39088
|
-
this.#outbox.enqueue(sessionId,
|
|
39427
|
+
recordRuntime = (sessionId, event) => {
|
|
39428
|
+
this.#outbox.enqueue(sessionId, encodeRecordedSessionEvent(event));
|
|
39089
39429
|
this.#publishNextBatch();
|
|
39090
39430
|
};
|
|
39091
39431
|
acknowledge = (acknowledgement) => {
|
|
@@ -39152,7 +39492,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
39152
39492
|
if (this.#inFlightBytes + byteLength > SESSION_EVENT_REPLAY_BYTE_LIMIT) {
|
|
39153
39493
|
continue;
|
|
39154
39494
|
}
|
|
39155
|
-
if (!this.#connection.send(
|
|
39495
|
+
if (!this.#connection.send(envelope2)) {
|
|
39156
39496
|
this.#clearInFlight();
|
|
39157
39497
|
return;
|
|
39158
39498
|
}
|
|
@@ -39246,8 +39586,8 @@ var CoalescingDaemonActivityPublisher = class {
|
|
|
39246
39586
|
}
|
|
39247
39587
|
};
|
|
39248
39588
|
};
|
|
39249
|
-
function
|
|
39250
|
-
return
|
|
39589
|
+
function daemonActivity(command, activity) {
|
|
39590
|
+
return {
|
|
39251
39591
|
activityId: activity.activityId,
|
|
39252
39592
|
activityType: activity.activityType,
|
|
39253
39593
|
commandId: command.commandId,
|
|
@@ -39263,18 +39603,18 @@ function encodeDaemonActivity(command, activity) {
|
|
|
39263
39603
|
status: activity.status,
|
|
39264
39604
|
title: activity.title,
|
|
39265
39605
|
toolKind: activity.toolKind
|
|
39266
|
-
}
|
|
39606
|
+
};
|
|
39267
39607
|
}
|
|
39268
39608
|
function reportFailure(publisher, command, code, message, attemptId) {
|
|
39269
39609
|
publisher.recordAttempt(
|
|
39270
39610
|
command.sessionId,
|
|
39271
|
-
|
|
39611
|
+
{
|
|
39272
39612
|
code,
|
|
39273
39613
|
commandId: command.commandId,
|
|
39274
39614
|
kind: SESSION_FAILED_KIND,
|
|
39275
39615
|
message,
|
|
39276
39616
|
sessionId: command.sessionId
|
|
39277
|
-
}
|
|
39617
|
+
},
|
|
39278
39618
|
attemptId
|
|
39279
39619
|
);
|
|
39280
39620
|
}
|
|
@@ -39294,17 +39634,14 @@ function reportOperationFailure(socket, requestId, sessionId, error62, runtimeTi
|
|
|
39294
39634
|
if (socket.readyState !== WebSocket2.OPEN) {
|
|
39295
39635
|
return;
|
|
39296
39636
|
}
|
|
39297
|
-
send(
|
|
39298
|
-
|
|
39299
|
-
|
|
39300
|
-
|
|
39301
|
-
|
|
39302
|
-
|
|
39303
|
-
|
|
39304
|
-
|
|
39305
|
-
sessionId
|
|
39306
|
-
})
|
|
39307
|
-
);
|
|
39637
|
+
send(socket, {
|
|
39638
|
+
code: operationErrorCode(error62),
|
|
39639
|
+
kind: "session.operation.failed",
|
|
39640
|
+
message: operationErrorMessage(error62),
|
|
39641
|
+
requestId,
|
|
39642
|
+
...runtimeTimings.length === 0 ? {} : { runtimeTimings },
|
|
39643
|
+
sessionId
|
|
39644
|
+
});
|
|
39308
39645
|
}
|
|
39309
39646
|
async function resolveSessionDirectories(directories, bindingId, directoryId2, additionalDirectoryIds, signal) {
|
|
39310
39647
|
const cwd = await directories.resolve(bindingId, directoryId2, signal);
|
|
@@ -39496,18 +39833,15 @@ async function executeWorkspaceList(socket, command, directories, audit, signal)
|
|
|
39496
39833
|
event: "workspace_list_authorized",
|
|
39497
39834
|
sessionId: "workspace-browser"
|
|
39498
39835
|
});
|
|
39499
|
-
send(
|
|
39500
|
-
|
|
39501
|
-
|
|
39502
|
-
|
|
39503
|
-
|
|
39504
|
-
|
|
39505
|
-
|
|
39506
|
-
|
|
39507
|
-
|
|
39508
|
-
requestId: command.requestId
|
|
39509
|
-
})
|
|
39510
|
-
);
|
|
39836
|
+
send(socket, {
|
|
39837
|
+
bindingId: command.bindingId,
|
|
39838
|
+
directoryId: listing.directoryId,
|
|
39839
|
+
directoryLabel: listing.directoryLabel,
|
|
39840
|
+
entries: listing.entries,
|
|
39841
|
+
kind: "workspace.entries",
|
|
39842
|
+
parentDirectoryId: listing.parentDirectoryId,
|
|
39843
|
+
requestId: command.requestId
|
|
39844
|
+
});
|
|
39511
39845
|
} catch (error62) {
|
|
39512
39846
|
reportOperationFailure(socket, command.requestId, "", error62);
|
|
39513
39847
|
}
|
|
@@ -39562,15 +39896,12 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
|
|
|
39562
39896
|
event: "session_configured",
|
|
39563
39897
|
sessionId: command.sessionId
|
|
39564
39898
|
});
|
|
39565
|
-
publisher.recordRuntime(
|
|
39566
|
-
|
|
39567
|
-
|
|
39568
|
-
|
|
39569
|
-
|
|
39570
|
-
|
|
39571
|
-
sessionId: command.sessionId
|
|
39572
|
-
})
|
|
39573
|
-
);
|
|
39899
|
+
publisher.recordRuntime(command.sessionId, {
|
|
39900
|
+
configOptions,
|
|
39901
|
+
kind: "session.config.updated",
|
|
39902
|
+
requestId: command.requestId,
|
|
39903
|
+
sessionId: command.sessionId
|
|
39904
|
+
});
|
|
39574
39905
|
}
|
|
39575
39906
|
const event = {
|
|
39576
39907
|
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
@@ -39589,17 +39920,14 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
|
|
|
39589
39920
|
runtimeTimings: metrics.snapshot()
|
|
39590
39921
|
};
|
|
39591
39922
|
metrics.measureSync("readiness-commit", () => {
|
|
39592
|
-
publisher.recordRuntime(command.sessionId,
|
|
39923
|
+
publisher.recordRuntime(command.sessionId, event);
|
|
39593
39924
|
});
|
|
39594
39925
|
return event;
|
|
39595
39926
|
});
|
|
39596
|
-
send(
|
|
39597
|
-
|
|
39598
|
-
|
|
39599
|
-
|
|
39600
|
-
runtimeTimings: metrics.snapshot()
|
|
39601
|
-
})
|
|
39602
|
-
);
|
|
39927
|
+
send(socket, {
|
|
39928
|
+
...readyEvent,
|
|
39929
|
+
runtimeTimings: metrics.snapshot()
|
|
39930
|
+
});
|
|
39603
39931
|
} catch (error62) {
|
|
39604
39932
|
audit.record({
|
|
39605
39933
|
commandId: command.requestId,
|
|
@@ -39639,15 +39967,12 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
39639
39967
|
event: "session_configured",
|
|
39640
39968
|
sessionId: command.sessionId
|
|
39641
39969
|
});
|
|
39642
|
-
publisher.recordRuntime(
|
|
39643
|
-
|
|
39644
|
-
|
|
39645
|
-
|
|
39646
|
-
|
|
39647
|
-
|
|
39648
|
-
sessionId: command.sessionId
|
|
39649
|
-
})
|
|
39650
|
-
);
|
|
39970
|
+
publisher.recordRuntime(command.sessionId, {
|
|
39971
|
+
configOptions,
|
|
39972
|
+
kind: "session.config.updated",
|
|
39973
|
+
requestId: command.requestId,
|
|
39974
|
+
sessionId: command.sessionId
|
|
39975
|
+
});
|
|
39651
39976
|
} catch (error62) {
|
|
39652
39977
|
if (signal.aborted) {
|
|
39653
39978
|
signal.throwIfAborted();
|
|
@@ -39657,20 +39982,20 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
39657
39982
|
}
|
|
39658
39983
|
async function executePrompt(outbox, publisher, command, config2, directories, audit, sessions, attemptId, activateAttempt, timer, signal) {
|
|
39659
39984
|
const activities = new CoalescingDaemonActivityPublisher(timer, (activity) => {
|
|
39660
|
-
publisher.recordAttempt(command.sessionId,
|
|
39985
|
+
publisher.recordAttempt(command.sessionId, daemonActivity(command, activity), attemptId);
|
|
39661
39986
|
});
|
|
39662
39987
|
const text3 = new CoalescingTextPublisher(
|
|
39663
39988
|
timer,
|
|
39664
39989
|
(messageId, delta) => {
|
|
39665
39990
|
publisher.recordAttempt(
|
|
39666
39991
|
command.sessionId,
|
|
39667
|
-
|
|
39992
|
+
{
|
|
39668
39993
|
commandId: command.commandId,
|
|
39669
39994
|
kind: AGENT_MESSAGE_DELTA_KIND,
|
|
39670
39995
|
messageId,
|
|
39671
39996
|
sessionId: command.sessionId,
|
|
39672
39997
|
text: delta
|
|
39673
|
-
}
|
|
39998
|
+
},
|
|
39674
39999
|
attemptId
|
|
39675
40000
|
);
|
|
39676
40001
|
},
|
|
@@ -39729,12 +40054,12 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
39729
40054
|
outbox.transitionExecution(command.commandId, "running");
|
|
39730
40055
|
publisher.recordAttempt(
|
|
39731
40056
|
command.sessionId,
|
|
39732
|
-
|
|
40057
|
+
{
|
|
39733
40058
|
commandId: command.commandId,
|
|
39734
40059
|
kind: SESSION_STARTED_KIND,
|
|
39735
40060
|
attemptId,
|
|
39736
40061
|
sessionId: command.sessionId
|
|
39737
|
-
}
|
|
40062
|
+
},
|
|
39738
40063
|
attemptId
|
|
39739
40064
|
);
|
|
39740
40065
|
activateAttempt();
|
|
@@ -39779,12 +40104,12 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
39779
40104
|
activities.flush();
|
|
39780
40105
|
publisher.recordAttempt(
|
|
39781
40106
|
command.sessionId,
|
|
39782
|
-
|
|
40107
|
+
{
|
|
39783
40108
|
commandId: command.commandId,
|
|
39784
40109
|
kind: SESSION_COMPLETED_KIND,
|
|
39785
40110
|
sessionId: command.sessionId,
|
|
39786
40111
|
stopReason
|
|
39787
|
-
}
|
|
40112
|
+
},
|
|
39788
40113
|
attemptId
|
|
39789
40114
|
);
|
|
39790
40115
|
outbox.transitionExecution(command.commandId, stopReason === "cancelled" ? "cancelled" : "succeeded");
|
|
@@ -40208,9 +40533,10 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40208
40533
|
}
|
|
40209
40534
|
};
|
|
40210
40535
|
const processDeliveredPayload = async (delivery) => {
|
|
40211
|
-
const
|
|
40536
|
+
const message = decodeServiceToDaemonMessage(delivery.payload);
|
|
40537
|
+
const kind = message.kind;
|
|
40212
40538
|
if (kind === SESSION_CANCEL_KIND) {
|
|
40213
|
-
const cancellation =
|
|
40539
|
+
const cancellation = message;
|
|
40214
40540
|
if (cancellation.sessionId !== delivery.sessionId) {
|
|
40215
40541
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
40216
40542
|
}
|
|
@@ -40227,7 +40553,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40227
40553
|
return;
|
|
40228
40554
|
}
|
|
40229
40555
|
if (kind === SESSION_CONFIGURE_KIND) {
|
|
40230
|
-
const command =
|
|
40556
|
+
const command = message;
|
|
40231
40557
|
if (command.sessionId !== delivery.sessionId) {
|
|
40232
40558
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
40233
40559
|
}
|
|
@@ -40244,7 +40570,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40244
40570
|
return;
|
|
40245
40571
|
}
|
|
40246
40572
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
40247
|
-
const command =
|
|
40573
|
+
const command = message;
|
|
40248
40574
|
if (command.sessionId !== delivery.sessionId) {
|
|
40249
40575
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
40250
40576
|
}
|
|
@@ -40261,7 +40587,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40261
40587
|
return;
|
|
40262
40588
|
}
|
|
40263
40589
|
if (kind === SESSION_ELICITATION_RESPOND_KIND) {
|
|
40264
|
-
const command =
|
|
40590
|
+
const command = message;
|
|
40265
40591
|
if (command.sessionId !== delivery.sessionId) {
|
|
40266
40592
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
40267
40593
|
}
|
|
@@ -40278,7 +40604,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40278
40604
|
return;
|
|
40279
40605
|
}
|
|
40280
40606
|
if (kind === SESSION_PROMPT_KIND) {
|
|
40281
|
-
const command =
|
|
40607
|
+
const command = message;
|
|
40282
40608
|
await processDeliveredPrompt(
|
|
40283
40609
|
delivery,
|
|
40284
40610
|
command,
|
|
@@ -40322,18 +40648,19 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40322
40648
|
}).finally(() => processingDeliveryIds.delete(delivery.deliveryId));
|
|
40323
40649
|
};
|
|
40324
40650
|
const receiveRuntimeDelivery = (delivery) => {
|
|
40325
|
-
const
|
|
40651
|
+
const payload = decodeServiceToDaemonMessage(delivery.payload);
|
|
40652
|
+
const payloadKind = payload.kind;
|
|
40326
40653
|
let payloadSessionId = "";
|
|
40327
40654
|
if (payloadKind === SESSION_CANCEL_KIND) {
|
|
40328
|
-
payloadSessionId =
|
|
40655
|
+
payloadSessionId = payload.sessionId;
|
|
40329
40656
|
} else if (payloadKind === SESSION_CONFIGURE_KIND) {
|
|
40330
|
-
payloadSessionId =
|
|
40657
|
+
payloadSessionId = payload.sessionId;
|
|
40331
40658
|
} else if (payloadKind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
40332
|
-
payloadSessionId =
|
|
40659
|
+
payloadSessionId = payload.sessionId;
|
|
40333
40660
|
} else if (payloadKind === SESSION_ELICITATION_RESPOND_KIND) {
|
|
40334
|
-
payloadSessionId =
|
|
40661
|
+
payloadSessionId = payload.sessionId;
|
|
40335
40662
|
} else if (payloadKind === SESSION_PROMPT_KIND) {
|
|
40336
|
-
payloadSessionId =
|
|
40663
|
+
payloadSessionId = payload.sessionId;
|
|
40337
40664
|
} else {
|
|
40338
40665
|
throw new Error("Runtime delivery contains an unsupported protocol message");
|
|
40339
40666
|
}
|
|
@@ -40341,14 +40668,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40341
40668
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
40342
40669
|
}
|
|
40343
40670
|
const stored = outbox.claimRuntimeDelivery(delivery);
|
|
40344
|
-
send(
|
|
40345
|
-
|
|
40346
|
-
|
|
40347
|
-
|
|
40348
|
-
|
|
40349
|
-
sessionId: delivery.sessionId
|
|
40350
|
-
})
|
|
40351
|
-
);
|
|
40671
|
+
send(socket, {
|
|
40672
|
+
deliveryId: delivery.deliveryId,
|
|
40673
|
+
kind: RUNTIME_DELIVERY_RECEIVED_KIND,
|
|
40674
|
+
sessionId: delivery.sessionId
|
|
40675
|
+
});
|
|
40352
40676
|
processRuntimeDelivery(delivery, stored.state);
|
|
40353
40677
|
};
|
|
40354
40678
|
const resumeRuntimeDeliveries = () => {
|
|
@@ -40360,14 +40684,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40360
40684
|
sessionId: stored.sessionId
|
|
40361
40685
|
};
|
|
40362
40686
|
if (stored.state !== "relay_committed") {
|
|
40363
|
-
send(
|
|
40364
|
-
|
|
40365
|
-
|
|
40366
|
-
|
|
40367
|
-
|
|
40368
|
-
sessionId: stored.sessionId
|
|
40369
|
-
})
|
|
40370
|
-
);
|
|
40687
|
+
send(socket, {
|
|
40688
|
+
deliveryId: stored.deliveryId,
|
|
40689
|
+
kind: RUNTIME_DELIVERY_RECEIVED_KIND,
|
|
40690
|
+
sessionId: stored.sessionId
|
|
40691
|
+
});
|
|
40371
40692
|
}
|
|
40372
40693
|
processRuntimeDelivery(delivery, stored.state);
|
|
40373
40694
|
}
|
|
@@ -40426,28 +40747,29 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40426
40747
|
return;
|
|
40427
40748
|
}
|
|
40428
40749
|
try {
|
|
40429
|
-
const
|
|
40750
|
+
const message = decodeServiceToDaemonMessage(encoded);
|
|
40751
|
+
const kind = message.kind;
|
|
40430
40752
|
if (kind === RUNTIME_DELIVERY_COMMITTED_KIND) {
|
|
40431
|
-
const committed =
|
|
40753
|
+
const committed = message;
|
|
40432
40754
|
if (!outbox.markRuntimeDeliveryCommitted(committed.deliveryId, committed.sessionId)) {
|
|
40433
40755
|
console.warn("Mobius daemon ignored confirmation for an unknown Runtime delivery");
|
|
40434
40756
|
}
|
|
40435
40757
|
return;
|
|
40436
40758
|
}
|
|
40437
40759
|
if (kind === RUNTIME_DELIVERY_KIND) {
|
|
40438
|
-
receiveRuntimeDelivery(
|
|
40760
|
+
receiveRuntimeDelivery(message);
|
|
40439
40761
|
return;
|
|
40440
40762
|
}
|
|
40441
40763
|
if (kind === SESSION_EVENT_ACK_KIND) {
|
|
40442
|
-
publisher.acknowledge(
|
|
40764
|
+
publisher.acknowledge(message);
|
|
40443
40765
|
return;
|
|
40444
40766
|
}
|
|
40445
40767
|
if (kind === SESSION_EVENT_DEFERRED_KIND) {
|
|
40446
|
-
publisher.defer(
|
|
40768
|
+
publisher.defer(message);
|
|
40447
40769
|
return;
|
|
40448
40770
|
}
|
|
40449
40771
|
if (kind === SESSION_EVENT_REJECTED_KIND) {
|
|
40450
|
-
const rejection =
|
|
40772
|
+
const rejection = message;
|
|
40451
40773
|
if (publisher.quarantine(rejection)) {
|
|
40452
40774
|
audit.record({
|
|
40453
40775
|
commandId: rejection.eventId,
|
|
@@ -40461,7 +40783,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40461
40783
|
return;
|
|
40462
40784
|
}
|
|
40463
40785
|
if (kind === NATIVE_SESSION_CANCEL_KIND) {
|
|
40464
|
-
const command2 =
|
|
40786
|
+
const command2 = message;
|
|
40465
40787
|
const pending = nativeRequests.get(command2.requestId);
|
|
40466
40788
|
if (pending?.sessionId === command2.sessionId) {
|
|
40467
40789
|
pending.controller.abort(
|
|
@@ -40475,35 +40797,29 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40475
40797
|
return;
|
|
40476
40798
|
}
|
|
40477
40799
|
if (kind === AGENT_SETTINGS_DISCOVER_KIND) {
|
|
40478
|
-
const command2 =
|
|
40800
|
+
const command2 = message;
|
|
40479
40801
|
const existing = [...agentSettingsDiscoveries.values()].find(
|
|
40480
40802
|
(request) => request.agentId === command2.agentId && !request.controller.signal.aborted
|
|
40481
40803
|
);
|
|
40482
40804
|
if (agentSettingsDiscoveries.has(command2.requestId) || existing !== void 0) {
|
|
40483
40805
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40484
|
-
send(
|
|
40485
|
-
|
|
40486
|
-
|
|
40487
|
-
|
|
40488
|
-
|
|
40489
|
-
|
|
40490
|
-
requestId: command2.requestId
|
|
40491
|
-
})
|
|
40492
|
-
);
|
|
40806
|
+
send(socket, {
|
|
40807
|
+
code: "agent_settings_discovery_busy",
|
|
40808
|
+
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
40809
|
+
message: "Another settings discovery is already running for this Agent",
|
|
40810
|
+
requestId: command2.requestId
|
|
40811
|
+
});
|
|
40493
40812
|
}
|
|
40494
40813
|
return;
|
|
40495
40814
|
}
|
|
40496
40815
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
40497
40816
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40498
|
-
send(
|
|
40499
|
-
|
|
40500
|
-
|
|
40501
|
-
|
|
40502
|
-
|
|
40503
|
-
|
|
40504
|
-
requestId: command2.requestId
|
|
40505
|
-
})
|
|
40506
|
-
);
|
|
40817
|
+
send(socket, {
|
|
40818
|
+
code: "agent_settings_discovery_busy",
|
|
40819
|
+
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
40820
|
+
message: "Too many Agent settings discoveries are running",
|
|
40821
|
+
requestId: command2.requestId
|
|
40822
|
+
});
|
|
40507
40823
|
}
|
|
40508
40824
|
return;
|
|
40509
40825
|
}
|
|
@@ -40535,7 +40851,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40535
40851
|
sessionId: `agent-settings:${command2.agentId}`
|
|
40536
40852
|
});
|
|
40537
40853
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40538
|
-
send(socket,
|
|
40854
|
+
send(socket, result);
|
|
40539
40855
|
}
|
|
40540
40856
|
} catch (error62) {
|
|
40541
40857
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -40550,15 +40866,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40550
40866
|
sessionId: `agent-settings:${command2.agentId}`
|
|
40551
40867
|
});
|
|
40552
40868
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40553
|
-
send(
|
|
40554
|
-
|
|
40555
|
-
|
|
40556
|
-
|
|
40557
|
-
|
|
40558
|
-
|
|
40559
|
-
requestId: command2.requestId
|
|
40560
|
-
})
|
|
40561
|
-
);
|
|
40869
|
+
send(socket, {
|
|
40870
|
+
code: operationErrorCode(failure2),
|
|
40871
|
+
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
40872
|
+
message: operationErrorMessage(failure2),
|
|
40873
|
+
requestId: command2.requestId
|
|
40874
|
+
});
|
|
40562
40875
|
}
|
|
40563
40876
|
} finally {
|
|
40564
40877
|
timeout.cancel();
|
|
@@ -40573,18 +40886,15 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40573
40886
|
return;
|
|
40574
40887
|
}
|
|
40575
40888
|
if (kind === AGENT_CATALOG_REFRESH_KIND) {
|
|
40576
|
-
const command2 =
|
|
40889
|
+
const command2 = message;
|
|
40577
40890
|
if (agentCatalogRefreshes.has(command2.requestId) || agentCatalogRefreshes.size > 0) {
|
|
40578
40891
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40579
|
-
send(
|
|
40580
|
-
|
|
40581
|
-
|
|
40582
|
-
|
|
40583
|
-
|
|
40584
|
-
|
|
40585
|
-
requestId: command2.requestId
|
|
40586
|
-
})
|
|
40587
|
-
);
|
|
40892
|
+
send(socket, {
|
|
40893
|
+
code: "agent_catalog_refresh_busy",
|
|
40894
|
+
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
40895
|
+
message: "Another local Agent catalog refresh is already running",
|
|
40896
|
+
requestId: command2.requestId
|
|
40897
|
+
});
|
|
40588
40898
|
}
|
|
40589
40899
|
return;
|
|
40590
40900
|
}
|
|
@@ -40609,13 +40919,10 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40609
40919
|
sessionId: "agent-catalog"
|
|
40610
40920
|
});
|
|
40611
40921
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40612
|
-
send(
|
|
40613
|
-
|
|
40614
|
-
|
|
40615
|
-
|
|
40616
|
-
requestId: command2.requestId
|
|
40617
|
-
})
|
|
40618
|
-
);
|
|
40922
|
+
send(socket, {
|
|
40923
|
+
kind: AGENT_CATALOG_REFRESHED_KIND,
|
|
40924
|
+
requestId: command2.requestId
|
|
40925
|
+
});
|
|
40619
40926
|
}
|
|
40620
40927
|
} catch (error62) {
|
|
40621
40928
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -40630,15 +40937,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40630
40937
|
sessionId: "agent-catalog"
|
|
40631
40938
|
});
|
|
40632
40939
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40633
|
-
send(
|
|
40634
|
-
|
|
40635
|
-
|
|
40636
|
-
|
|
40637
|
-
|
|
40638
|
-
|
|
40639
|
-
requestId: command2.requestId
|
|
40640
|
-
})
|
|
40641
|
-
);
|
|
40940
|
+
send(socket, {
|
|
40941
|
+
code: operationErrorCode(failure2),
|
|
40942
|
+
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
40943
|
+
message: operationErrorMessage(failure2),
|
|
40944
|
+
requestId: command2.requestId
|
|
40945
|
+
});
|
|
40642
40946
|
}
|
|
40643
40947
|
} finally {
|
|
40644
40948
|
timeout.cancel();
|
|
@@ -40649,7 +40953,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40649
40953
|
return;
|
|
40650
40954
|
}
|
|
40651
40955
|
if (kind === NATIVE_SESSION_REQUEST_KIND) {
|
|
40652
|
-
const command2 =
|
|
40956
|
+
const command2 = message;
|
|
40653
40957
|
const previous2 = [...nativeRequests.values()].filter(
|
|
40654
40958
|
(request) => request.agentId === command2.agentId
|
|
40655
40959
|
);
|
|
@@ -40702,7 +41006,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40702
41006
|
operationSignal.throwIfAborted();
|
|
40703
41007
|
const result = await nativeSessions.execute(command2, operationSignal);
|
|
40704
41008
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40705
|
-
send(socket,
|
|
41009
|
+
send(socket, result);
|
|
40706
41010
|
}
|
|
40707
41011
|
} catch (error62) {
|
|
40708
41012
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -40731,7 +41035,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40731
41035
|
return;
|
|
40732
41036
|
}
|
|
40733
41037
|
if (kind === NATIVE_SESSION_TURN_FORK_KIND) {
|
|
40734
|
-
const command2 =
|
|
41038
|
+
const command2 = message;
|
|
40735
41039
|
const previous2 = [...nativeRequests.values()].filter(
|
|
40736
41040
|
(request) => request.agentId === command2.agentId
|
|
40737
41041
|
);
|
|
@@ -40782,7 +41086,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40782
41086
|
operationSignal.throwIfAborted();
|
|
40783
41087
|
const result = await nativeSessions.executeTurnFork(command2, operationSignal);
|
|
40784
41088
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
40785
|
-
send(socket,
|
|
41089
|
+
send(socket, result);
|
|
40786
41090
|
}
|
|
40787
41091
|
} catch (error62) {
|
|
40788
41092
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -40811,39 +41115,35 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40811
41115
|
return;
|
|
40812
41116
|
}
|
|
40813
41117
|
if (kind === RUNTIME_LIVENESS_READY_KIND) {
|
|
40814
|
-
decodeRuntimeLivenessReadyEvent(encoded);
|
|
40815
41118
|
connectionLiveness.start();
|
|
40816
41119
|
return;
|
|
40817
41120
|
}
|
|
40818
41121
|
if (kind === RUNTIME_HEARTBEAT_ACK_KIND) {
|
|
40819
|
-
connectionLiveness.acknowledge(
|
|
41122
|
+
connectionLiveness.acknowledge(message);
|
|
40820
41123
|
return;
|
|
40821
41124
|
}
|
|
40822
41125
|
if (kind === FILE_READ_KIND) {
|
|
40823
|
-
const command2 =
|
|
41126
|
+
const command2 = message;
|
|
40824
41127
|
void streamLocalFile(
|
|
40825
41128
|
command2,
|
|
40826
|
-
(
|
|
41129
|
+
(message2) => send(socket, message2),
|
|
40827
41130
|
connectionController.signal
|
|
40828
41131
|
).catch((error62) => {
|
|
40829
41132
|
if (socket.readyState !== WebSocket2.OPEN || connectionController.signal.aborted) {
|
|
40830
41133
|
return;
|
|
40831
41134
|
}
|
|
40832
|
-
send(
|
|
40833
|
-
|
|
40834
|
-
|
|
40835
|
-
|
|
40836
|
-
|
|
40837
|
-
|
|
40838
|
-
|
|
40839
|
-
sessionId: command2.sessionId
|
|
40840
|
-
})
|
|
40841
|
-
);
|
|
41135
|
+
send(socket, {
|
|
41136
|
+
code: "file_unavailable",
|
|
41137
|
+
kind: FILE_FAILED_KIND,
|
|
41138
|
+
message: error62 instanceof Error ? error62.message : "The local file is unavailable",
|
|
41139
|
+
requestId: command2.requestId,
|
|
41140
|
+
sessionId: command2.sessionId
|
|
41141
|
+
});
|
|
40842
41142
|
});
|
|
40843
41143
|
return;
|
|
40844
41144
|
}
|
|
40845
41145
|
if (kind === SESSION_CANCEL_KIND) {
|
|
40846
|
-
const cancellation =
|
|
41146
|
+
const cancellation = message;
|
|
40847
41147
|
const turn2 = activeTurns.get(cancellation.commandId);
|
|
40848
41148
|
if (turn2 === void 0 || !turn2.matches(cancellation)) {
|
|
40849
41149
|
console.warn("Mobius daemon ignored cancellation for an inactive turn");
|
|
@@ -40863,12 +41163,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40863
41163
|
return;
|
|
40864
41164
|
}
|
|
40865
41165
|
if (kind === WORKSPACE_LIST_KIND) {
|
|
40866
|
-
const command2 =
|
|
41166
|
+
const command2 = message;
|
|
40867
41167
|
void executeWorkspaceList(socket, command2, directories, audit, connectionController.signal);
|
|
40868
41168
|
return;
|
|
40869
41169
|
}
|
|
40870
41170
|
if (kind === SESSION_PREPARE_KIND) {
|
|
40871
|
-
const command2 =
|
|
41171
|
+
const command2 = message;
|
|
40872
41172
|
void executeSessionPrepare(
|
|
40873
41173
|
publisher,
|
|
40874
41174
|
socket,
|
|
@@ -40882,7 +41182,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40882
41182
|
return;
|
|
40883
41183
|
}
|
|
40884
41184
|
if (kind === SESSION_CONFIGURE_KIND) {
|
|
40885
|
-
const command2 =
|
|
41185
|
+
const command2 = message;
|
|
40886
41186
|
void executeSessionConfigure(
|
|
40887
41187
|
publisher,
|
|
40888
41188
|
socket,
|
|
@@ -40896,7 +41196,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40896
41196
|
return;
|
|
40897
41197
|
}
|
|
40898
41198
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
40899
|
-
const command2 =
|
|
41199
|
+
const command2 = message;
|
|
40900
41200
|
void sessions.respondPermission(command2).then(() => {
|
|
40901
41201
|
audit.record({
|
|
40902
41202
|
commandId: command2.interactionId,
|
|
@@ -40909,7 +41209,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40909
41209
|
return;
|
|
40910
41210
|
}
|
|
40911
41211
|
if (kind === SESSION_ELICITATION_RESPOND_KIND) {
|
|
40912
|
-
const command2 =
|
|
41212
|
+
const command2 = message;
|
|
40913
41213
|
void sessions.respondElicitation(command2).then(() => {
|
|
40914
41214
|
audit.record({
|
|
40915
41215
|
commandId: command2.interactionId,
|
|
@@ -40922,14 +41222,14 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40922
41222
|
return;
|
|
40923
41223
|
}
|
|
40924
41224
|
if (kind === AGENT_INSTALL_REQUEST_KIND) {
|
|
40925
|
-
const command2 =
|
|
41225
|
+
const command2 = message;
|
|
40926
41226
|
void installations.request(command2, signal).catch((error62) => {
|
|
40927
41227
|
console.error("Mobius Agent integration installation failed", error62);
|
|
40928
41228
|
});
|
|
40929
41229
|
return;
|
|
40930
41230
|
}
|
|
40931
41231
|
if (kind === AGENT_INSTALL_CANCEL_KIND) {
|
|
40932
|
-
const command2 =
|
|
41232
|
+
const command2 = message;
|
|
40933
41233
|
void installations.cancel(command2.requestId).catch((error62) => {
|
|
40934
41234
|
reportOperationFailure(socket, command2.requestId, "", error62);
|
|
40935
41235
|
});
|
|
@@ -40938,7 +41238,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40938
41238
|
if (kind !== SESSION_PROMPT_KIND) {
|
|
40939
41239
|
throw new Error("Unsupported protocol message");
|
|
40940
41240
|
}
|
|
40941
|
-
const command =
|
|
41241
|
+
const command = message;
|
|
40942
41242
|
if (activeTurns.has(command.commandId)) {
|
|
40943
41243
|
return;
|
|
40944
41244
|
}
|
|
@@ -41003,6 +41303,24 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41003
41303
|
return;
|
|
41004
41304
|
}
|
|
41005
41305
|
console.error("Mobius daemon could not reconcile active Agent turns", error62);
|
|
41306
|
+
if (error62 instanceof ActiveTurnReconciliationError && error62.terminal) {
|
|
41307
|
+
diagnostics.reconciliationAbandoned(
|
|
41308
|
+
connectionEpoch,
|
|
41309
|
+
error62.relayErrorCode,
|
|
41310
|
+
reconnectingTurns.length
|
|
41311
|
+
);
|
|
41312
|
+
console.error(
|
|
41313
|
+
"Mobius daemon abandoned Agent turns the Relay already settled",
|
|
41314
|
+
error62.relayErrorCode
|
|
41315
|
+
);
|
|
41316
|
+
for (const turn of reconnectingTurns) {
|
|
41317
|
+
activeTurns.delete(turn.command.commandId);
|
|
41318
|
+
turn.abortDaemon();
|
|
41319
|
+
}
|
|
41320
|
+
publisher.connect(socket);
|
|
41321
|
+
resumeRuntimeDeliveries();
|
|
41322
|
+
return;
|
|
41323
|
+
}
|
|
41006
41324
|
failAndClose(
|
|
41007
41325
|
new Error("Active Agent turn reconciliation failed", { cause: error62 }),
|
|
41008
41326
|
ACTIVE_TURN_RECONCILIATION_CLOSE_CODE,
|
|
@@ -41041,13 +41359,13 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
41041
41359
|
const publisher = new DaemonSessionEventPublisher(outbox, timer);
|
|
41042
41360
|
const activeTurns = /* @__PURE__ */ new Map();
|
|
41043
41361
|
const activeAttemptIds = /* @__PURE__ */ new Map();
|
|
41044
|
-
const recordSessionEvent = (sessionId,
|
|
41362
|
+
const recordSessionEvent = (sessionId, event) => {
|
|
41045
41363
|
const attemptId = activeAttemptIds.get(sessionId);
|
|
41046
41364
|
if (attemptId === void 0) {
|
|
41047
|
-
publisher.recordRuntime(sessionId,
|
|
41365
|
+
publisher.recordRuntime(sessionId, event);
|
|
41048
41366
|
return;
|
|
41049
41367
|
}
|
|
41050
|
-
publisher.recordAttempt(sessionId,
|
|
41368
|
+
publisher.recordAttempt(sessionId, event, attemptId);
|
|
41051
41369
|
};
|
|
41052
41370
|
const sessions = new AcpSessionManager(new DaemonAcpObserver(config2, recordSessionEvent), sessionStore);
|
|
41053
41371
|
const directories = new WorkspaceDirectoryService(config2.bindingId, config2.defaultWorkspace);
|
|
@@ -41277,7 +41595,7 @@ var ImportedLegacyRuntimeConnection = class extends StoredRuntimeConnection {
|
|
|
41277
41595
|
super(applicationId, installationId2, connectionId2, channelId, defaultWorkspace, relayOrigin, runtimeCredential2);
|
|
41278
41596
|
}
|
|
41279
41597
|
};
|
|
41280
|
-
function
|
|
41598
|
+
function isRecord10(value) {
|
|
41281
41599
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41282
41600
|
}
|
|
41283
41601
|
function hasExactKeys(value, expectedKeys) {
|
|
@@ -41344,7 +41662,7 @@ function channelIndexFileName(channelId) {
|
|
|
41344
41662
|
return `mci_${createHash5("sha256").update(channelId).digest("hex")}.json`;
|
|
41345
41663
|
}
|
|
41346
41664
|
function decodeInstallationPointer(value) {
|
|
41347
|
-
if (!
|
|
41665
|
+
if (!isRecord10(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
|
|
41348
41666
|
throw new RuntimeInstallationStoreError("invalid_installation", "The local installation record is invalid");
|
|
41349
41667
|
}
|
|
41350
41668
|
const storedInstallationId = value["installationId"];
|
|
@@ -41354,7 +41672,7 @@ function decodeInstallationPointer(value) {
|
|
|
41354
41672
|
return { installationId: validateInstallationId(storedInstallationId) };
|
|
41355
41673
|
}
|
|
41356
41674
|
function decodeChannelIndex(value) {
|
|
41357
|
-
if (!
|
|
41675
|
+
if (!isRecord10(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
|
|
41358
41676
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
41359
41677
|
}
|
|
41360
41678
|
const applicationId = value["applicationId"];
|
|
@@ -41422,7 +41740,7 @@ function decodeImportedLegacyConnection(value) {
|
|
|
41422
41740
|
);
|
|
41423
41741
|
}
|
|
41424
41742
|
function decodeConnection(value) {
|
|
41425
|
-
if (!
|
|
41743
|
+
if (!isRecord10(value)) {
|
|
41426
41744
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
41427
41745
|
}
|
|
41428
41746
|
if (value["kind"] === "verified") {
|
|
@@ -41434,7 +41752,7 @@ function decodeConnection(value) {
|
|
|
41434
41752
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
41435
41753
|
}
|
|
41436
41754
|
function decodeLegacyConnection(value, expectedChannelId) {
|
|
41437
|
-
if (!
|
|
41755
|
+
if (!isRecord10(value) || !hasExactKeys(value, CURRENT_CONNECTION_KEYS) && !hasExactKeys(value, LEGACY_CONNECTION_KEYS)) {
|
|
41438
41756
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
41439
41757
|
}
|
|
41440
41758
|
const channelId = value["channelId"];
|
|
@@ -41734,7 +42052,7 @@ var PairingClientError = class extends Error {
|
|
|
41734
42052
|
this.name = "PairingClientError";
|
|
41735
42053
|
}
|
|
41736
42054
|
};
|
|
41737
|
-
function
|
|
42055
|
+
function isRecord11(value) {
|
|
41738
42056
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41739
42057
|
}
|
|
41740
42058
|
function hasExactKeys2(value, expectedKeys) {
|
|
@@ -41812,9 +42130,9 @@ async function readJsonResponse(response) {
|
|
|
41812
42130
|
}
|
|
41813
42131
|
}
|
|
41814
42132
|
function readRelayError(value) {
|
|
41815
|
-
if (
|
|
42133
|
+
if (isRecord11(value)) {
|
|
41816
42134
|
const error62 = value["error"];
|
|
41817
|
-
if (
|
|
42135
|
+
if (isRecord11(error62)) {
|
|
41818
42136
|
const code = error62["code"];
|
|
41819
42137
|
const message = error62["message"];
|
|
41820
42138
|
if (typeof code === "string" && typeof message === "string") {
|
|
@@ -41825,7 +42143,7 @@ function readRelayError(value) {
|
|
|
41825
42143
|
return new PairingClientError("pairing_failed", "The relay could not pair this machine");
|
|
41826
42144
|
}
|
|
41827
42145
|
function decodePairingResponse(value, credentialField, expectedKeys) {
|
|
41828
|
-
if (!
|
|
42146
|
+
if (!isRecord11(value) || !hasExactKeys2(value, expectedKeys)) {
|
|
41829
42147
|
throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
|
|
41830
42148
|
}
|
|
41831
42149
|
const channelId = value["channelId"];
|