@moxt-ai/mobius 0.0.59 → 0.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp/session-manager.d.ts +0 -3
- package/dist/acp/session-manager.d.ts.map +1 -1
- package/dist/acp/session-manager.js +16 -36
- package/dist/acp/session-manager.js.map +1 -1
- package/dist/agent-catalog/agents/deepseek-harness-agent.d.ts.map +1 -1
- package/dist/agent-catalog/agents/deepseek-harness-agent.js +39 -8
- package/dist/agent-catalog/agents/deepseek-harness-agent.js.map +1 -1
- 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/agent-installation/deepseek-managed-package.js +2 -2
- 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/authorization/local-video.d.ts +1 -2
- package/dist/authorization/local-video.d.ts.map +1 -1
- package/dist/authorization/local-video.js.map +1 -1
- package/dist/cli.js +650 -789
- package/dist/cli.js.map +4 -4
- package/dist/index.js +652 -790
- package/dist/index.js.map +4 -4
- 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 +116 -118
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +661 -799
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -2
- package/dist/artifacts/runtime-artifact-uploader.d.ts +0 -12
- package/dist/artifacts/runtime-artifact-uploader.d.ts.map +0 -1
- package/dist/artifacts/runtime-artifact-uploader.js +0 -150
- package/dist/artifacts/runtime-artifact-uploader.js.map +0 -1
- package/dist/authorization/local-artifact.d.ts +0 -6
- package/dist/authorization/local-artifact.d.ts.map +0 -1
- package/dist/authorization/local-artifact.js +0 -2
- package/dist/authorization/local-artifact.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -16628,8 +16628,8 @@ function rewriteKeyNames(ctx) {
|
|
|
16628
16628
|
bySchema.set(entry.schema, entry);
|
|
16629
16629
|
}
|
|
16630
16630
|
const rewrites = /* @__PURE__ */ new Map();
|
|
16631
|
-
for (const
|
|
16632
|
-
const seen = ctx.seen.get(
|
|
16631
|
+
for (const record2 of pendingRecords.get(ctx) ?? []) {
|
|
16632
|
+
const seen = ctx.seen.get(record2);
|
|
16633
16633
|
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
16634
16634
|
if (!names || names === true || rewrites.has(names))
|
|
16635
16635
|
continue;
|
|
@@ -20338,39 +20338,65 @@ var decodePromptResourcesValue = (value) => decodeValue(value, external_exports.
|
|
|
20338
20338
|
var decodeSessionConfigurationSelections = (value) => decodeValue(value, sessionConfigurationSelectionsSchema);
|
|
20339
20339
|
var encode3 = (message, schema) => JSON.stringify(decodeValue(message, schema));
|
|
20340
20340
|
var decodeAgentSettingsDiscoverCommand = (encoded) => decode3(encoded, agentSettingsDiscoverCommandSchema);
|
|
20341
|
+
var encodeAgentSettingsDiscoverCommand = (message) => encode3(message, agentSettingsDiscoverCommandSchema);
|
|
20342
|
+
var decodeAgentSettingsDiscoveredEvent = (encoded) => decode3(encoded, agentSettingsDiscoveredEventSchema);
|
|
20341
20343
|
var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
|
|
20344
|
+
var decodeAgentSettingsDiscoveryFailedEvent = (encoded) => decode3(encoded, agentSettingsDiscoveryFailedEventSchema);
|
|
20342
20345
|
var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
|
|
20343
20346
|
var decodeAgentCatalogRefreshCommand = (encoded) => decode3(encoded, agentCatalogRefreshCommandSchema);
|
|
20347
|
+
var encodeAgentCatalogRefreshCommand = (message) => encode3(message, agentCatalogRefreshCommandSchema);
|
|
20348
|
+
var decodeAgentCatalogRefreshedEvent = (encoded) => decode3(encoded, agentCatalogRefreshedEventSchema);
|
|
20344
20349
|
var encodeAgentCatalogRefreshedEvent = (message) => encode3(message, agentCatalogRefreshedEventSchema);
|
|
20350
|
+
var decodeAgentCatalogRefreshFailedEvent = (encoded) => decode3(encoded, agentCatalogRefreshFailedEventSchema);
|
|
20345
20351
|
var encodeAgentCatalogRefreshFailedEvent = (message) => encode3(message, agentCatalogRefreshFailedEventSchema);
|
|
20346
20352
|
var decodeFileReadCommand = (encoded) => decode3(encoded, fileReadCommandSchema);
|
|
20353
|
+
var encodeFileReadCommand = (message) => encode3(message, fileReadCommandSchema);
|
|
20354
|
+
var decodeFileBeginEvent = (encoded) => decode3(encoded, fileBeginEventSchema);
|
|
20347
20355
|
var encodeFileBeginEvent = (message) => encode3(message, fileBeginEventSchema);
|
|
20356
|
+
var decodeFileChunkEvent = (encoded) => decode3(encoded, fileChunkEventSchema);
|
|
20348
20357
|
var encodeFileChunkEvent = (message) => encode3(message, fileChunkEventSchema);
|
|
20358
|
+
var decodeFileEndEvent = (encoded) => decode3(encoded, fileEndEventSchema);
|
|
20349
20359
|
var encodeFileEndEvent = (message) => encode3(message, fileEndEventSchema);
|
|
20360
|
+
var decodeFileFailedEvent = (encoded) => decode3(encoded, fileFailedEventSchema);
|
|
20350
20361
|
var encodeFileFailedEvent = (message) => encode3(message, fileFailedEventSchema);
|
|
20351
20362
|
var decodeWorkspaceListCommand = (encoded) => decode3(encoded, workspaceListCommandSchema);
|
|
20363
|
+
var encodeWorkspaceListCommand = (message) => encode3(message, workspaceListCommandSchema);
|
|
20364
|
+
var decodeWorkspaceEntriesEvent = (encoded) => decode3(encoded, workspaceEntriesEventSchema);
|
|
20352
20365
|
var encodeWorkspaceEntriesEvent = (message) => encode3(message, workspaceEntriesEventSchema);
|
|
20353
20366
|
var decodeSessionPrepareCommand = (encoded) => decode3(encoded, sessionPrepareCommandSchema);
|
|
20367
|
+
var encodeSessionPrepareCommand = (message) => encode3(message, sessionPrepareCommandSchema);
|
|
20368
|
+
var decodeSessionReadyEvent = (encoded) => decode3(encoded, sessionReadyEventSchema);
|
|
20354
20369
|
var encodeSessionReadyEvent = (message) => encode3(message, sessionReadyEventSchema);
|
|
20355
20370
|
var decodeSessionConfigureCommand = (encoded) => decode3(encoded, sessionConfigureCommandSchema);
|
|
20356
|
-
var
|
|
20357
|
-
var
|
|
20358
|
-
var
|
|
20359
|
-
var
|
|
20360
|
-
var
|
|
20371
|
+
var encodeSessionConfigureCommand = (message) => encode3(message, sessionConfigureCommandSchema);
|
|
20372
|
+
var decodeSessionConfigUpdatedEvent = (encoded) => decode3(encoded, sessionConfigUpdatedEventSchema);
|
|
20373
|
+
var decodeSessionUsageUpdatedEvent = (encoded) => decode3(encoded, sessionUsageUpdatedEventSchema);
|
|
20374
|
+
var decodeSessionCommandsUpdatedEvent = (encoded) => decode3(encoded, sessionCommandsUpdatedEventSchema);
|
|
20375
|
+
var decodeSessionInfoUpdatedEvent = (encoded) => decode3(encoded, sessionInfoUpdatedEventSchema);
|
|
20376
|
+
var decodeSessionPermissionRequestedEvent = (encoded) => decode3(encoded, sessionPermissionRequestedEventSchema);
|
|
20361
20377
|
var decodeSessionPermissionRespondCommand = (encoded) => decode3(encoded, sessionPermissionRespondCommandSchema);
|
|
20362
|
-
var
|
|
20363
|
-
var
|
|
20378
|
+
var encodeSessionPermissionRespondCommand = (message) => encode3(message, sessionPermissionRespondCommandSchema);
|
|
20379
|
+
var decodeSessionPermissionResolvedEvent = (encoded) => decode3(encoded, sessionPermissionResolvedEventSchema);
|
|
20380
|
+
var decodeSessionElicitationRequestedEvent = (encoded) => decode3(encoded, sessionElicitationRequestedEventSchema);
|
|
20364
20381
|
var decodeSessionElicitationRespondCommand = (encoded) => decode3(encoded, sessionElicitationRespondCommandSchema);
|
|
20365
|
-
var
|
|
20382
|
+
var encodeSessionElicitationRespondCommand = (message) => encode3(message, sessionElicitationRespondCommandSchema);
|
|
20383
|
+
var decodeSessionElicitationResolvedEvent = (encoded) => decode3(encoded, sessionElicitationResolvedEventSchema);
|
|
20384
|
+
var decodeSessionOperationFailedEvent = (encoded) => decode3(encoded, sessionOperationFailedEventSchema);
|
|
20366
20385
|
var encodeSessionOperationFailedEvent = (message) => encode3(message, sessionOperationFailedEventSchema);
|
|
20367
|
-
var
|
|
20386
|
+
var decodeAgentContentEvent = (encoded) => decode3(encoded, agentContentEventSchema);
|
|
20368
20387
|
var decodeAgentInstallRequestCommand = (encoded) => decode3(encoded, agentInstallRequestCommandSchema);
|
|
20388
|
+
var encodeAgentInstallRequestCommand = (message) => encode3(message, agentInstallRequestCommandSchema);
|
|
20369
20389
|
var decodeAgentInstallCancelCommand = (encoded) => decode3(encoded, agentInstallCancelCommandSchema);
|
|
20390
|
+
var encodeAgentInstallCancelCommand = (message) => encode3(message, agentInstallCancelCommandSchema);
|
|
20391
|
+
var decodeAgentInstallStartedEvent = (encoded) => decode3(encoded, agentInstallStartedEventSchema);
|
|
20370
20392
|
var encodeAgentInstallStartedEvent = (message) => encode3(message, agentInstallStartedEventSchema);
|
|
20393
|
+
var decodeAgentInstallProgressEvent = (encoded) => decode3(encoded, agentInstallProgressEventSchema);
|
|
20371
20394
|
var encodeAgentInstallProgressEvent = (message) => encode3(message, agentInstallProgressEventSchema);
|
|
20395
|
+
var decodeAgentInstallCompletedEvent = (encoded) => decode3(encoded, agentInstallCompletedEventSchema);
|
|
20372
20396
|
var encodeAgentInstallCompletedEvent = (message) => encode3(message, agentInstallCompletedEventSchema);
|
|
20397
|
+
var decodeAgentInstallFailedEvent = (encoded) => decode3(encoded, agentInstallFailedEventSchema);
|
|
20373
20398
|
var encodeAgentInstallFailedEvent = (message) => encode3(message, agentInstallFailedEventSchema);
|
|
20399
|
+
var decodeAgentInstallCancelledEvent = (encoded) => decode3(encoded, agentInstallCancelledEventSchema);
|
|
20374
20400
|
var encodeAgentInstallCancelledEvent = (message) => encode3(message, agentInstallCancelledEventSchema);
|
|
20375
20401
|
|
|
20376
20402
|
// ../protocol/src/messages.ts
|
|
@@ -20805,49 +20831,29 @@ function decodeSessionFailedEvent(encoded) {
|
|
|
20805
20831
|
sessionId: readIdentifier(value, "sessionId")
|
|
20806
20832
|
};
|
|
20807
20833
|
}
|
|
20808
|
-
function
|
|
20809
|
-
return JSON.stringify(
|
|
20810
|
-
}
|
|
20811
|
-
function encodeRuntimeDeliveryReceived(message) {
|
|
20812
|
-
return JSON.stringify(decodeRuntimeDeliveryReceived(JSON.stringify(message)));
|
|
20813
|
-
}
|
|
20814
|
-
function encodeSessionStartedEvent(message) {
|
|
20815
|
-
return JSON.stringify(decodeSessionStartedEvent(JSON.stringify(message)));
|
|
20834
|
+
function encodeSessionPromptCommand(message) {
|
|
20835
|
+
return JSON.stringify(decodeSessionPromptCommand(JSON.stringify(message)));
|
|
20816
20836
|
}
|
|
20817
|
-
function
|
|
20818
|
-
return JSON.stringify(
|
|
20837
|
+
function encodeSessionCancelCommand(message) {
|
|
20838
|
+
return JSON.stringify(decodeSessionCancelCommand(JSON.stringify(message)));
|
|
20819
20839
|
}
|
|
20820
|
-
function
|
|
20821
|
-
return JSON.stringify(
|
|
20840
|
+
function encodeRuntimeLivenessReadyEvent(message) {
|
|
20841
|
+
return JSON.stringify(decodeRuntimeLivenessReadyEvent(JSON.stringify(message)));
|
|
20822
20842
|
}
|
|
20823
|
-
function
|
|
20824
|
-
return JSON.stringify(
|
|
20843
|
+
function encodeRuntimeHeartbeatEvent(message) {
|
|
20844
|
+
return JSON.stringify(decodeRuntimeHeartbeatEvent(JSON.stringify(message)));
|
|
20825
20845
|
}
|
|
20826
|
-
function
|
|
20827
|
-
return JSON.stringify(
|
|
20846
|
+
function encodeRuntimeHeartbeatAckEvent(message) {
|
|
20847
|
+
return JSON.stringify(decodeRuntimeHeartbeatAckEvent(JSON.stringify(message)));
|
|
20828
20848
|
}
|
|
20829
|
-
|
|
20830
|
-
|
|
20831
|
-
var MOBIUS_API_PREFIX = "/mobius/api";
|
|
20832
|
-
var API_PREFIX_PATTERN = /^\/[a-zA-Z0-9._~-]+(?:\/[a-zA-Z0-9._~-]+)*$/;
|
|
20833
|
-
var MobiusApiConfigurationError = class extends Error {
|
|
20834
|
-
code = "invalid_api_prefix";
|
|
20835
|
-
constructor() {
|
|
20836
|
-
super("The Mobius API prefix must be an absolute path without parameters");
|
|
20837
|
-
this.name = "MobiusApiConfigurationError";
|
|
20838
|
-
}
|
|
20839
|
-
};
|
|
20840
|
-
function parseMobiusApiPrefix(value) {
|
|
20841
|
-
if (typeof value !== "string" || !API_PREFIX_PATTERN.test(value)) {
|
|
20842
|
-
throw new MobiusApiConfigurationError();
|
|
20843
|
-
}
|
|
20844
|
-
return value;
|
|
20849
|
+
function encodeRuntimeDelivery(message) {
|
|
20850
|
+
return JSON.stringify(decodeRuntimeDelivery(JSON.stringify(message)));
|
|
20845
20851
|
}
|
|
20846
|
-
function
|
|
20847
|
-
return
|
|
20852
|
+
function encodeRuntimeDeliveryReceived(message) {
|
|
20853
|
+
return JSON.stringify(decodeRuntimeDeliveryReceived(JSON.stringify(message)));
|
|
20848
20854
|
}
|
|
20849
|
-
function
|
|
20850
|
-
return
|
|
20855
|
+
function encodeRuntimeDeliveryCommitted(message) {
|
|
20856
|
+
return JSON.stringify(decodeRuntimeDeliveryCommitted(JSON.stringify(message)));
|
|
20851
20857
|
}
|
|
20852
20858
|
|
|
20853
20859
|
// ../protocol/src/session-history.ts
|
|
@@ -21024,9 +21030,13 @@ function decode4(schema, encoded) {
|
|
|
21024
21030
|
}
|
|
21025
21031
|
}
|
|
21026
21032
|
var decodeNativeSessionCommand = (encoded) => decode4(nativeSessionCommandSchema, encoded);
|
|
21033
|
+
var encodeNativeSessionCommand = (value) => JSON.stringify(nativeSessionCommandSchema.parse(value));
|
|
21034
|
+
var decodeNativeSessionResult = (encoded) => decode4(nativeSessionResultSchema, encoded);
|
|
21027
21035
|
var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
|
|
21028
21036
|
var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
|
|
21037
|
+
var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
|
|
21029
21038
|
var decodeNativeSessionTurnForkCommand = (encoded) => decode4(nativeSessionTurnForkCommandSchema, encoded);
|
|
21039
|
+
var encodeNativeSessionTurnForkCommand = (value) => JSON.stringify(nativeSessionTurnForkCommandSchema.parse(value));
|
|
21030
21040
|
|
|
21031
21041
|
// ../protocol/src/session-events.ts
|
|
21032
21042
|
var SESSION_EVENT_KIND = "session.event";
|
|
@@ -21118,8 +21128,285 @@ var encode4 = (message, schema) => {
|
|
|
21118
21128
|
var decodeSessionEventEnvelope = (encoded) => decode5(encoded, eventEnvelopeSchema);
|
|
21119
21129
|
var encodeSessionEventEnvelope = (message) => encode4(message, eventEnvelopeSchema);
|
|
21120
21130
|
var decodeSessionEventAcknowledgement = (encoded) => decode5(encoded, eventAcknowledgementSchema);
|
|
21131
|
+
var encodeSessionEventAcknowledgement = (message) => encode4(message, eventAcknowledgementSchema);
|
|
21121
21132
|
var decodeSessionEventDeferred = (encoded) => decode5(encoded, eventDeferredSchema);
|
|
21133
|
+
var encodeSessionEventDeferred = (message) => encode4(message, eventDeferredSchema);
|
|
21122
21134
|
var decodeSessionEventRejection = (encoded) => decode5(encoded, eventRejectionSchema);
|
|
21135
|
+
var encodeSessionEventRejection = (message) => encode4(message, eventRejectionSchema);
|
|
21136
|
+
function decodeRecordedSessionEvent(encoded) {
|
|
21137
|
+
const kind = decodeMessageKind(encoded);
|
|
21138
|
+
switch (kind) {
|
|
21139
|
+
case AGENT_ACTIVITY_KIND:
|
|
21140
|
+
return decodeAgentActivityEvent(encoded);
|
|
21141
|
+
case AGENT_CONTENT_KIND:
|
|
21142
|
+
return decodeAgentContentEvent(encoded);
|
|
21143
|
+
case AGENT_MESSAGE_DELTA_KIND:
|
|
21144
|
+
return decodeAgentMessageDeltaEvent(encoded);
|
|
21145
|
+
case SESSION_COMMANDS_UPDATED_KIND:
|
|
21146
|
+
return decodeSessionCommandsUpdatedEvent(encoded);
|
|
21147
|
+
case SESSION_COMPLETED_KIND:
|
|
21148
|
+
return decodeSessionCompletedEvent(encoded);
|
|
21149
|
+
case SESSION_CONFIG_UPDATED_KIND:
|
|
21150
|
+
return decodeSessionConfigUpdatedEvent(encoded);
|
|
21151
|
+
case SESSION_ELICITATION_REQUESTED_KIND:
|
|
21152
|
+
return decodeSessionElicitationRequestedEvent(encoded);
|
|
21153
|
+
case SESSION_ELICITATION_RESOLVED_KIND:
|
|
21154
|
+
return decodeSessionElicitationResolvedEvent(encoded);
|
|
21155
|
+
case SESSION_FAILED_KIND:
|
|
21156
|
+
return decodeSessionFailedEvent(encoded);
|
|
21157
|
+
case SESSION_INFO_UPDATED_KIND:
|
|
21158
|
+
return decodeSessionInfoUpdatedEvent(encoded);
|
|
21159
|
+
case SESSION_PERMISSION_REQUESTED_KIND:
|
|
21160
|
+
return decodeSessionPermissionRequestedEvent(encoded);
|
|
21161
|
+
case SESSION_PERMISSION_RESOLVED_KIND:
|
|
21162
|
+
return decodeSessionPermissionResolvedEvent(encoded);
|
|
21163
|
+
case SESSION_READY_KIND:
|
|
21164
|
+
return decodeSessionReadyEvent(encoded);
|
|
21165
|
+
case SESSION_STARTED_KIND:
|
|
21166
|
+
return decodeSessionStartedEvent(encoded);
|
|
21167
|
+
case SESSION_USAGE_UPDATED_KIND:
|
|
21168
|
+
return decodeSessionUsageUpdatedEvent(encoded);
|
|
21169
|
+
default:
|
|
21170
|
+
throw new ProtocolMessageError("Unsupported recorded session event");
|
|
21171
|
+
}
|
|
21172
|
+
}
|
|
21173
|
+
var encodeRecordedSessionEvent = (event) => JSON.stringify(decodeRecordedSessionEvent(JSON.stringify(event)));
|
|
21174
|
+
|
|
21175
|
+
// ../protocol/src/daemon-transport.ts
|
|
21176
|
+
function defineMessageSignature(kind, encoder, decoder) {
|
|
21177
|
+
const schema = (message) => decoder(JSON.stringify(message));
|
|
21178
|
+
return {
|
|
21179
|
+
decoder,
|
|
21180
|
+
encoder: (message) => encoder(schema(message)),
|
|
21181
|
+
kind,
|
|
21182
|
+
schema
|
|
21183
|
+
};
|
|
21184
|
+
}
|
|
21185
|
+
var serviceToDaemonSignatures = {
|
|
21186
|
+
[AGENT_CATALOG_REFRESH_KIND]: defineMessageSignature(
|
|
21187
|
+
AGENT_CATALOG_REFRESH_KIND,
|
|
21188
|
+
encodeAgentCatalogRefreshCommand,
|
|
21189
|
+
decodeAgentCatalogRefreshCommand
|
|
21190
|
+
),
|
|
21191
|
+
[AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
|
|
21192
|
+
AGENT_INSTALL_CANCEL_KIND,
|
|
21193
|
+
encodeAgentInstallCancelCommand,
|
|
21194
|
+
decodeAgentInstallCancelCommand
|
|
21195
|
+
),
|
|
21196
|
+
[AGENT_INSTALL_REQUEST_KIND]: defineMessageSignature(
|
|
21197
|
+
AGENT_INSTALL_REQUEST_KIND,
|
|
21198
|
+
encodeAgentInstallRequestCommand,
|
|
21199
|
+
decodeAgentInstallRequestCommand
|
|
21200
|
+
),
|
|
21201
|
+
[AGENT_SETTINGS_DISCOVER_KIND]: defineMessageSignature(
|
|
21202
|
+
AGENT_SETTINGS_DISCOVER_KIND,
|
|
21203
|
+
encodeAgentSettingsDiscoverCommand,
|
|
21204
|
+
decodeAgentSettingsDiscoverCommand
|
|
21205
|
+
),
|
|
21206
|
+
[FILE_READ_KIND]: defineMessageSignature(FILE_READ_KIND, encodeFileReadCommand, decodeFileReadCommand),
|
|
21207
|
+
[NATIVE_SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
21208
|
+
NATIVE_SESSION_CANCEL_KIND,
|
|
21209
|
+
encodeNativeSessionCancel,
|
|
21210
|
+
decodeNativeSessionCancel
|
|
21211
|
+
),
|
|
21212
|
+
[NATIVE_SESSION_REQUEST_KIND]: defineMessageSignature(
|
|
21213
|
+
NATIVE_SESSION_REQUEST_KIND,
|
|
21214
|
+
encodeNativeSessionCommand,
|
|
21215
|
+
decodeNativeSessionCommand
|
|
21216
|
+
),
|
|
21217
|
+
[NATIVE_SESSION_TURN_FORK_KIND]: defineMessageSignature(
|
|
21218
|
+
NATIVE_SESSION_TURN_FORK_KIND,
|
|
21219
|
+
encodeNativeSessionTurnForkCommand,
|
|
21220
|
+
decodeNativeSessionTurnForkCommand
|
|
21221
|
+
),
|
|
21222
|
+
[RUNTIME_DELIVERY_KIND]: defineMessageSignature(
|
|
21223
|
+
RUNTIME_DELIVERY_KIND,
|
|
21224
|
+
encodeRuntimeDelivery,
|
|
21225
|
+
decodeRuntimeDelivery
|
|
21226
|
+
),
|
|
21227
|
+
[RUNTIME_DELIVERY_COMMITTED_KIND]: defineMessageSignature(
|
|
21228
|
+
RUNTIME_DELIVERY_COMMITTED_KIND,
|
|
21229
|
+
encodeRuntimeDeliveryCommitted,
|
|
21230
|
+
decodeRuntimeDeliveryCommitted
|
|
21231
|
+
),
|
|
21232
|
+
[RUNTIME_HEARTBEAT_ACK_KIND]: defineMessageSignature(
|
|
21233
|
+
RUNTIME_HEARTBEAT_ACK_KIND,
|
|
21234
|
+
encodeRuntimeHeartbeatAckEvent,
|
|
21235
|
+
decodeRuntimeHeartbeatAckEvent
|
|
21236
|
+
),
|
|
21237
|
+
[RUNTIME_LIVENESS_READY_KIND]: defineMessageSignature(
|
|
21238
|
+
RUNTIME_LIVENESS_READY_KIND,
|
|
21239
|
+
encodeRuntimeLivenessReadyEvent,
|
|
21240
|
+
decodeRuntimeLivenessReadyEvent
|
|
21241
|
+
),
|
|
21242
|
+
[SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
21243
|
+
SESSION_CANCEL_KIND,
|
|
21244
|
+
encodeSessionCancelCommand,
|
|
21245
|
+
decodeSessionCancelCommand
|
|
21246
|
+
),
|
|
21247
|
+
[SESSION_CONFIGURE_KIND]: defineMessageSignature(
|
|
21248
|
+
SESSION_CONFIGURE_KIND,
|
|
21249
|
+
encodeSessionConfigureCommand,
|
|
21250
|
+
decodeSessionConfigureCommand
|
|
21251
|
+
),
|
|
21252
|
+
[SESSION_ELICITATION_RESPOND_KIND]: defineMessageSignature(
|
|
21253
|
+
SESSION_ELICITATION_RESPOND_KIND,
|
|
21254
|
+
encodeSessionElicitationRespondCommand,
|
|
21255
|
+
decodeSessionElicitationRespondCommand
|
|
21256
|
+
),
|
|
21257
|
+
[SESSION_EVENT_ACK_KIND]: defineMessageSignature(
|
|
21258
|
+
SESSION_EVENT_ACK_KIND,
|
|
21259
|
+
encodeSessionEventAcknowledgement,
|
|
21260
|
+
decodeSessionEventAcknowledgement
|
|
21261
|
+
),
|
|
21262
|
+
[SESSION_EVENT_DEFERRED_KIND]: defineMessageSignature(
|
|
21263
|
+
SESSION_EVENT_DEFERRED_KIND,
|
|
21264
|
+
encodeSessionEventDeferred,
|
|
21265
|
+
decodeSessionEventDeferred
|
|
21266
|
+
),
|
|
21267
|
+
[SESSION_EVENT_REJECTED_KIND]: defineMessageSignature(
|
|
21268
|
+
SESSION_EVENT_REJECTED_KIND,
|
|
21269
|
+
encodeSessionEventRejection,
|
|
21270
|
+
decodeSessionEventRejection
|
|
21271
|
+
),
|
|
21272
|
+
[SESSION_PERMISSION_RESPOND_KIND]: defineMessageSignature(
|
|
21273
|
+
SESSION_PERMISSION_RESPOND_KIND,
|
|
21274
|
+
encodeSessionPermissionRespondCommand,
|
|
21275
|
+
decodeSessionPermissionRespondCommand
|
|
21276
|
+
),
|
|
21277
|
+
[SESSION_PREPARE_KIND]: defineMessageSignature(
|
|
21278
|
+
SESSION_PREPARE_KIND,
|
|
21279
|
+
encodeSessionPrepareCommand,
|
|
21280
|
+
decodeSessionPrepareCommand
|
|
21281
|
+
),
|
|
21282
|
+
[SESSION_PROMPT_KIND]: defineMessageSignature(
|
|
21283
|
+
SESSION_PROMPT_KIND,
|
|
21284
|
+
encodeSessionPromptCommand,
|
|
21285
|
+
decodeSessionPromptCommand
|
|
21286
|
+
),
|
|
21287
|
+
[WORKSPACE_LIST_KIND]: defineMessageSignature(
|
|
21288
|
+
WORKSPACE_LIST_KIND,
|
|
21289
|
+
encodeWorkspaceListCommand,
|
|
21290
|
+
decodeWorkspaceListCommand
|
|
21291
|
+
)
|
|
21292
|
+
};
|
|
21293
|
+
var serviceToDaemonRegistry = serviceToDaemonSignatures;
|
|
21294
|
+
function decodeServiceToDaemonMessage(encoded) {
|
|
21295
|
+
const kind = decodeMessageKind(encoded);
|
|
21296
|
+
const signature = serviceToDaemonRegistry[kind];
|
|
21297
|
+
if (signature === void 0) {
|
|
21298
|
+
throw new ProtocolMessageError(`Unsupported service-to-daemon message kind: ${kind}`);
|
|
21299
|
+
}
|
|
21300
|
+
return signature.decoder(encoded);
|
|
21301
|
+
}
|
|
21302
|
+
var daemonToServiceSignatures = {
|
|
21303
|
+
[AGENT_CATALOG_REFRESHED_KIND]: defineMessageSignature(
|
|
21304
|
+
AGENT_CATALOG_REFRESHED_KIND,
|
|
21305
|
+
encodeAgentCatalogRefreshedEvent,
|
|
21306
|
+
decodeAgentCatalogRefreshedEvent
|
|
21307
|
+
),
|
|
21308
|
+
[AGENT_CATALOG_REFRESH_FAILED_KIND]: defineMessageSignature(
|
|
21309
|
+
AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
21310
|
+
encodeAgentCatalogRefreshFailedEvent,
|
|
21311
|
+
decodeAgentCatalogRefreshFailedEvent
|
|
21312
|
+
),
|
|
21313
|
+
[AGENT_INSTALL_CANCELLED_KIND]: defineMessageSignature(
|
|
21314
|
+
AGENT_INSTALL_CANCELLED_KIND,
|
|
21315
|
+
encodeAgentInstallCancelledEvent,
|
|
21316
|
+
decodeAgentInstallCancelledEvent
|
|
21317
|
+
),
|
|
21318
|
+
[AGENT_INSTALL_COMPLETED_KIND]: defineMessageSignature(
|
|
21319
|
+
AGENT_INSTALL_COMPLETED_KIND,
|
|
21320
|
+
encodeAgentInstallCompletedEvent,
|
|
21321
|
+
decodeAgentInstallCompletedEvent
|
|
21322
|
+
),
|
|
21323
|
+
[AGENT_INSTALL_FAILED_KIND]: defineMessageSignature(
|
|
21324
|
+
AGENT_INSTALL_FAILED_KIND,
|
|
21325
|
+
encodeAgentInstallFailedEvent,
|
|
21326
|
+
decodeAgentInstallFailedEvent
|
|
21327
|
+
),
|
|
21328
|
+
[AGENT_INSTALL_PROGRESS_KIND]: defineMessageSignature(
|
|
21329
|
+
AGENT_INSTALL_PROGRESS_KIND,
|
|
21330
|
+
encodeAgentInstallProgressEvent,
|
|
21331
|
+
decodeAgentInstallProgressEvent
|
|
21332
|
+
),
|
|
21333
|
+
[AGENT_INSTALL_STARTED_KIND]: defineMessageSignature(
|
|
21334
|
+
AGENT_INSTALL_STARTED_KIND,
|
|
21335
|
+
encodeAgentInstallStartedEvent,
|
|
21336
|
+
decodeAgentInstallStartedEvent
|
|
21337
|
+
),
|
|
21338
|
+
[AGENT_SETTINGS_DISCOVERED_KIND]: defineMessageSignature(
|
|
21339
|
+
AGENT_SETTINGS_DISCOVERED_KIND,
|
|
21340
|
+
encodeAgentSettingsDiscoveredEvent,
|
|
21341
|
+
decodeAgentSettingsDiscoveredEvent
|
|
21342
|
+
),
|
|
21343
|
+
[AGENT_SETTINGS_DISCOVERY_FAILED_KIND]: defineMessageSignature(
|
|
21344
|
+
AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
21345
|
+
encodeAgentSettingsDiscoveryFailedEvent,
|
|
21346
|
+
decodeAgentSettingsDiscoveryFailedEvent
|
|
21347
|
+
),
|
|
21348
|
+
[FILE_BEGIN_KIND]: defineMessageSignature(FILE_BEGIN_KIND, encodeFileBeginEvent, decodeFileBeginEvent),
|
|
21349
|
+
[FILE_CHUNK_KIND]: defineMessageSignature(FILE_CHUNK_KIND, encodeFileChunkEvent, decodeFileChunkEvent),
|
|
21350
|
+
[FILE_END_KIND]: defineMessageSignature(FILE_END_KIND, encodeFileEndEvent, decodeFileEndEvent),
|
|
21351
|
+
[FILE_FAILED_KIND]: defineMessageSignature(FILE_FAILED_KIND, encodeFileFailedEvent, decodeFileFailedEvent),
|
|
21352
|
+
[NATIVE_SESSION_RESULT_KIND]: defineMessageSignature(
|
|
21353
|
+
NATIVE_SESSION_RESULT_KIND,
|
|
21354
|
+
encodeNativeSessionResult,
|
|
21355
|
+
decodeNativeSessionResult
|
|
21356
|
+
),
|
|
21357
|
+
[RUNTIME_DELIVERY_RECEIVED_KIND]: defineMessageSignature(
|
|
21358
|
+
RUNTIME_DELIVERY_RECEIVED_KIND,
|
|
21359
|
+
encodeRuntimeDeliveryReceived,
|
|
21360
|
+
decodeRuntimeDeliveryReceived
|
|
21361
|
+
),
|
|
21362
|
+
[RUNTIME_HEARTBEAT_KIND]: defineMessageSignature(
|
|
21363
|
+
RUNTIME_HEARTBEAT_KIND,
|
|
21364
|
+
encodeRuntimeHeartbeatEvent,
|
|
21365
|
+
decodeRuntimeHeartbeatEvent
|
|
21366
|
+
),
|
|
21367
|
+
[SESSION_EVENT_KIND]: defineMessageSignature(
|
|
21368
|
+
SESSION_EVENT_KIND,
|
|
21369
|
+
encodeSessionEventEnvelope,
|
|
21370
|
+
decodeSessionEventEnvelope
|
|
21371
|
+
),
|
|
21372
|
+
[SESSION_OPERATION_FAILED_KIND]: defineMessageSignature(
|
|
21373
|
+
SESSION_OPERATION_FAILED_KIND,
|
|
21374
|
+
encodeSessionOperationFailedEvent,
|
|
21375
|
+
decodeSessionOperationFailedEvent
|
|
21376
|
+
),
|
|
21377
|
+
[SESSION_READY_KIND]: defineMessageSignature(SESSION_READY_KIND, encodeSessionReadyEvent, decodeSessionReadyEvent),
|
|
21378
|
+
[WORKSPACE_ENTRIES_KIND]: defineMessageSignature(
|
|
21379
|
+
WORKSPACE_ENTRIES_KIND,
|
|
21380
|
+
encodeWorkspaceEntriesEvent,
|
|
21381
|
+
decodeWorkspaceEntriesEvent
|
|
21382
|
+
)
|
|
21383
|
+
};
|
|
21384
|
+
function encodeDaemonToServiceMessage(message) {
|
|
21385
|
+
return daemonToServiceSignatures[message.kind].encoder(message);
|
|
21386
|
+
}
|
|
21387
|
+
|
|
21388
|
+
// ../protocol/src/mobius-api.ts
|
|
21389
|
+
var MOBIUS_API_PREFIX = "/mobius/api";
|
|
21390
|
+
var API_PREFIX_PATTERN = /^\/[a-zA-Z0-9._~-]+(?:\/[a-zA-Z0-9._~-]+)*$/;
|
|
21391
|
+
var MobiusApiConfigurationError = class extends Error {
|
|
21392
|
+
code = "invalid_api_prefix";
|
|
21393
|
+
constructor() {
|
|
21394
|
+
super("The Mobius API prefix must be an absolute path without parameters");
|
|
21395
|
+
this.name = "MobiusApiConfigurationError";
|
|
21396
|
+
}
|
|
21397
|
+
};
|
|
21398
|
+
function parseMobiusApiPrefix(value) {
|
|
21399
|
+
if (typeof value !== "string" || !API_PREFIX_PATTERN.test(value)) {
|
|
21400
|
+
throw new MobiusApiConfigurationError();
|
|
21401
|
+
}
|
|
21402
|
+
return value;
|
|
21403
|
+
}
|
|
21404
|
+
function mobiusApiPath(resourcePath, apiPrefix = MOBIUS_API_PREFIX) {
|
|
21405
|
+
return `${parseMobiusApiPrefix(apiPrefix)}${resourcePath}`;
|
|
21406
|
+
}
|
|
21407
|
+
function mobiusApiUrl(origin, resourcePath, apiPrefix = MOBIUS_API_PREFIX) {
|
|
21408
|
+
return new URL(mobiusApiPath(resourcePath, apiPrefix), origin);
|
|
21409
|
+
}
|
|
21123
21410
|
|
|
21124
21411
|
// src/agent-catalog/local-agent.ts
|
|
21125
21412
|
import { realpathSync, statSync } from "node:fs";
|
|
@@ -30622,10 +30909,6 @@ var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
|
|
|
30622
30909
|
var SESSION_CONTROL_COMMAND_ID = "session-control";
|
|
30623
30910
|
var SESSION_CONTROL_TIMEOUT_MILLISECONDS = 3e4;
|
|
30624
30911
|
var NullAcpSessionObserver = class {
|
|
30625
|
-
importLocalArtifact = (_sessionId, _artifact, signal) => {
|
|
30626
|
-
signal.throwIfAborted();
|
|
30627
|
-
return Promise.resolve("");
|
|
30628
|
-
};
|
|
30629
30912
|
onCommands = () => Promise.resolve();
|
|
30630
30913
|
onConfig = () => Promise.resolve();
|
|
30631
30914
|
onContent = () => Promise.resolve();
|
|
@@ -31185,20 +31468,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
31185
31468
|
#agentName = "";
|
|
31186
31469
|
#agentVersion = "";
|
|
31187
31470
|
#bufferedAgentText = [];
|
|
31188
|
-
#capabilities =
|
|
31189
|
-
additionalDirectories: false,
|
|
31190
|
-
audioPrompt: false,
|
|
31191
|
-
closeSession: false,
|
|
31192
|
-
deleteSession: false,
|
|
31193
|
-
embeddedContextPrompt: false,
|
|
31194
|
-
imagePrompt: false,
|
|
31195
|
-
listSessions: false,
|
|
31196
|
-
loadSession: false,
|
|
31197
|
-
promptQueueing: false,
|
|
31198
|
-
resumeSession: false,
|
|
31199
|
-
steering: false,
|
|
31200
|
-
unstableForkSession: false
|
|
31201
|
-
};
|
|
31471
|
+
#capabilities = unsupportedSessionCapabilities();
|
|
31202
31472
|
#commands = [];
|
|
31203
31473
|
#configRevision = 0;
|
|
31204
31474
|
#configOptions = [];
|
|
@@ -31418,7 +31688,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
31418
31688
|
if (video === null) {
|
|
31419
31689
|
return { ...content3, data: "" };
|
|
31420
31690
|
}
|
|
31421
|
-
return
|
|
31691
|
+
return this.importVideo(video);
|
|
31422
31692
|
}
|
|
31423
31693
|
return content3;
|
|
31424
31694
|
};
|
|
@@ -31469,22 +31739,19 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
31469
31739
|
}
|
|
31470
31740
|
return imageDisplayContent(raster.mimeType, raster.name, await raster.base64(), "");
|
|
31471
31741
|
};
|
|
31472
|
-
importVideo =
|
|
31473
|
-
|
|
31474
|
-
|
|
31475
|
-
|
|
31476
|
-
|
|
31477
|
-
|
|
31478
|
-
|
|
31479
|
-
|
|
31480
|
-
|
|
31481
|
-
|
|
31482
|
-
|
|
31483
|
-
|
|
31484
|
-
|
|
31485
|
-
uri: ""
|
|
31486
|
-
};
|
|
31487
|
-
};
|
|
31742
|
+
importVideo = (video) => ({
|
|
31743
|
+
artifactId: "",
|
|
31744
|
+
data: video.base64(),
|
|
31745
|
+
mimeType: video.mimeType,
|
|
31746
|
+
name: video.name,
|
|
31747
|
+
newText: "",
|
|
31748
|
+
oldText: "",
|
|
31749
|
+
path: "",
|
|
31750
|
+
terminalId: "",
|
|
31751
|
+
text: "",
|
|
31752
|
+
type: "video",
|
|
31753
|
+
uri: ""
|
|
31754
|
+
});
|
|
31488
31755
|
async #initializeAgent(signal) {
|
|
31489
31756
|
await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
|
|
31490
31757
|
}
|
|
@@ -33496,7 +33763,7 @@ var AuditStore = class {
|
|
|
33496
33763
|
this.database.exec("ALTER TABLE audit_events ADD COLUMN details_json TEXT NOT NULL DEFAULT '{}'");
|
|
33497
33764
|
}
|
|
33498
33765
|
}
|
|
33499
|
-
record(
|
|
33766
|
+
record(record2) {
|
|
33500
33767
|
this.database.prepare(
|
|
33501
33768
|
`
|
|
33502
33769
|
INSERT INTO audit_events (
|
|
@@ -33509,10 +33776,10 @@ var AuditStore = class {
|
|
|
33509
33776
|
`
|
|
33510
33777
|
).run(
|
|
33511
33778
|
(/* @__PURE__ */ new Date()).toISOString(),
|
|
33512
|
-
|
|
33513
|
-
|
|
33514
|
-
|
|
33515
|
-
JSON.stringify(
|
|
33779
|
+
record2.event,
|
|
33780
|
+
record2.commandId,
|
|
33781
|
+
record2.sessionId,
|
|
33782
|
+
JSON.stringify(record2.details ?? {})
|
|
33516
33783
|
);
|
|
33517
33784
|
}
|
|
33518
33785
|
close() {
|
|
@@ -33530,7 +33797,7 @@ var LocalAuthorizationError = class extends Error {
|
|
|
33530
33797
|
};
|
|
33531
33798
|
|
|
33532
33799
|
// src/pairing/pair-local-machine.ts
|
|
33533
|
-
import { mkdir as
|
|
33800
|
+
import { mkdir as mkdir5, realpath as realpath7, stat as stat6 } from "node:fs/promises";
|
|
33534
33801
|
import { hostname as hostname3 } from "node:os";
|
|
33535
33802
|
import { basename as basename3, resolve as resolve5 } from "node:path";
|
|
33536
33803
|
import { fetch as fetch2 } from "undici";
|
|
@@ -34184,34 +34451,48 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
34184
34451
|
};
|
|
34185
34452
|
|
|
34186
34453
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
34187
|
-
import { realpath as realpath4, stat as stat4 } from "node:fs/promises";
|
|
34454
|
+
import { mkdir as mkdir2, realpath as realpath4, stat as stat4, writeFile } from "node:fs/promises";
|
|
34188
34455
|
import { isAbsolute as isAbsolute4, join as join7, normalize as normalize2 } from "node:path";
|
|
34189
34456
|
|
|
34190
34457
|
// src/agent-installation/deepseek-managed-package.ts
|
|
34191
34458
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
34192
|
-
dependencyResolutionArguments = Object.freeze(["--before=2026-09-
|
|
34459
|
+
dependencyResolutionArguments = Object.freeze(["--before=2026-09-18T00:00:00.000Z"]);
|
|
34193
34460
|
includeOptionalDependencies = true;
|
|
34194
34461
|
verifyDependencyClosure = true;
|
|
34195
34462
|
};
|
|
34196
34463
|
var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
|
|
34197
34464
|
"@deepseek-ai/dsh",
|
|
34198
|
-
"0.1.
|
|
34465
|
+
"0.1.5-rc.2",
|
|
34199
34466
|
"dsh",
|
|
34200
|
-
"sha512-
|
|
34201
|
-
"https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.
|
|
34467
|
+
"sha512-8Xc8hCQHcIWRmTCVU/xZdp6/qMsWMeAd2ObChKDEsfhUPJFXx6H0lgeb1DxUMD86HZrrVN+1bCvn1ppjZ/fOxw==",
|
|
34468
|
+
"https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.5-rc.2.tgz"
|
|
34202
34469
|
);
|
|
34203
34470
|
|
|
34204
34471
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
34205
|
-
|
|
34472
|
+
var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP bridge to an image-capable route.
|
|
34473
|
+
- id: acp
|
|
34474
|
+
config:
|
|
34475
|
+
provider: deepseek-official
|
|
34476
|
+
model: deepseek-v4-flash-vision-exp
|
|
34477
|
+
`;
|
|
34478
|
+
async function prepareAgentHome(path2, imagePrompts) {
|
|
34206
34479
|
if (!isAbsolute4(path2) || normalize2(path2) !== path2) {
|
|
34207
34480
|
throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
|
|
34208
34481
|
}
|
|
34209
34482
|
try {
|
|
34483
|
+
if (imagePrompts) {
|
|
34484
|
+
await mkdir2(path2, { mode: 448, recursive: true });
|
|
34485
|
+
}
|
|
34210
34486
|
const resolved = await realpath4(path2);
|
|
34211
34487
|
const metadata = await stat4(resolved);
|
|
34212
34488
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
34213
34489
|
throw new Error("Agent home is not a user-owned directory");
|
|
34214
34490
|
}
|
|
34491
|
+
if (imagePrompts) {
|
|
34492
|
+
await writeFile(join7(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
|
|
34493
|
+
mode: 384
|
|
34494
|
+
});
|
|
34495
|
+
}
|
|
34215
34496
|
return resolved;
|
|
34216
34497
|
} catch (error62) {
|
|
34217
34498
|
if (error62 instanceof AgentProbeError) {
|
|
@@ -34246,6 +34527,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
34246
34527
|
}
|
|
34247
34528
|
createLaunchEnvironment = async (agent, context) => {
|
|
34248
34529
|
let selectedHome = context.environment["DSH_HOME"];
|
|
34530
|
+
let managedHome = false;
|
|
34249
34531
|
try {
|
|
34250
34532
|
const managed = await this.resolveManagedAgent(
|
|
34251
34533
|
readStateDirectory(context.environment),
|
|
@@ -34254,6 +34536,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
34254
34536
|
);
|
|
34255
34537
|
if (managed.path === agent.path) {
|
|
34256
34538
|
selectedHome = join7(readStateDirectory(context.environment), "agents", this.id, "home");
|
|
34539
|
+
managedHome = true;
|
|
34257
34540
|
}
|
|
34258
34541
|
} catch {
|
|
34259
34542
|
context.signal.throwIfAborted();
|
|
@@ -34262,7 +34545,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
34262
34545
|
return Object.freeze({});
|
|
34263
34546
|
}
|
|
34264
34547
|
return Object.freeze({
|
|
34265
|
-
DSH_HOME: await
|
|
34548
|
+
DSH_HOME: await prepareAgentHome(selectedHome, managedHome)
|
|
34266
34549
|
});
|
|
34267
34550
|
};
|
|
34268
34551
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
@@ -34277,8 +34560,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
34277
34560
|
verifyAcp = (_connection, initialized, _defaultWorkspace, _signal) => {
|
|
34278
34561
|
const capabilities = initialized.agentCapabilities ?? {};
|
|
34279
34562
|
const session = capabilities.sessionCapabilities;
|
|
34280
|
-
|
|
34281
|
-
if ((initialized.authMethods ?? []).length !== 0 || capabilities.loadSession === true || capabilities.mcpCapabilities?.http !== true || session?.close == null || session.list == null || session.resume == null || session.additionalDirectories != null || session.delete != null || session.fork != null || prompt?.audio === true || prompt?.embeddedContext === true || prompt?.image === true) {
|
|
34563
|
+
if ((initialized.authMethods ?? []).length !== 0 || capabilities.loadSession === true || capabilities.mcpCapabilities?.http !== true || session?.close == null || session.list == null || session.resume == null || session.additionalDirectories != null || session.delete != null || session.fork != null) {
|
|
34282
34564
|
throw new AgentProbeError(
|
|
34283
34565
|
"acp_incompatible",
|
|
34284
34566
|
"DeepSeek Harness reported an unsupported ACP capability set"
|
|
@@ -34489,7 +34771,7 @@ import { join as join10 } from "node:path";
|
|
|
34489
34771
|
// src/agent-installation/managed-agent-archive.ts
|
|
34490
34772
|
import { createHash } from "node:crypto";
|
|
34491
34773
|
import { createReadStream } from "node:fs";
|
|
34492
|
-
import { chmod, copyFile, mkdir as
|
|
34774
|
+
import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open4, realpath as realpath6, rename as rename2, rm as rm2, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
|
|
34493
34775
|
import { delimiter as delimiter2, dirname as dirname4, isAbsolute as isAbsolute6, join as join9, relative as relative3, sep as sep3 } from "node:path";
|
|
34494
34776
|
|
|
34495
34777
|
// src/agent-installation/verified-download.ts
|
|
@@ -35527,7 +35809,7 @@ async function discoverLocalAgentInventory(options) {
|
|
|
35527
35809
|
|
|
35528
35810
|
// src/storage/runtime-installation-store.ts
|
|
35529
35811
|
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
35530
|
-
import { mkdir as
|
|
35812
|
+
import { mkdir as mkdir4, open as open5, rename as rename3, unlink, writeFile as writeFile3 } from "node:fs/promises";
|
|
35531
35813
|
import { dirname as dirname5, join as join15, resolve as resolve4 } from "node:path";
|
|
35532
35814
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
35533
35815
|
var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
|
|
@@ -35830,9 +36112,9 @@ async function writeJsonAtomically(path2, value, signal) {
|
|
|
35830
36112
|
const directory = dirname5(path2);
|
|
35831
36113
|
const temporaryPath = join15(directory, `.${randomUUID()}.tmp`);
|
|
35832
36114
|
try {
|
|
35833
|
-
await
|
|
36115
|
+
await mkdir4(directory, { mode: 448, recursive: true });
|
|
35834
36116
|
signal.throwIfAborted();
|
|
35835
|
-
await
|
|
36117
|
+
await writeFile3(temporaryPath, `${JSON.stringify(value, null, 2)}
|
|
35836
36118
|
`, { flag: "wx", mode: 384 });
|
|
35837
36119
|
signal.throwIfAborted();
|
|
35838
36120
|
await rename3(temporaryPath, path2);
|
|
@@ -35863,7 +36145,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
35863
36145
|
const rootDirectory = resolve4(options.stateDirectory);
|
|
35864
36146
|
const applicationDirectory = join15(rootDirectory, "installations", applicationId);
|
|
35865
36147
|
try {
|
|
35866
|
-
await
|
|
36148
|
+
await mkdir4(applicationDirectory, { mode: 448, recursive: true });
|
|
35867
36149
|
} catch (cause) {
|
|
35868
36150
|
throw new RuntimeInstallationStoreError(
|
|
35869
36151
|
"installation_unavailable",
|
|
@@ -35876,7 +36158,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
35876
36158
|
const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
|
|
35877
36159
|
const stateDirectory = join15(applicationDirectory, storedInstallationId);
|
|
35878
36160
|
try {
|
|
35879
|
-
await
|
|
36161
|
+
await mkdir4(stateDirectory, { mode: 448, recursive: true });
|
|
35880
36162
|
} catch (cause) {
|
|
35881
36163
|
throw new RuntimeInstallationStoreError(
|
|
35882
36164
|
"installation_unavailable",
|
|
@@ -36032,7 +36314,7 @@ async function readOrCreateInstallationId(applicationDirectory, signal) {
|
|
|
36032
36314
|
}
|
|
36033
36315
|
const candidate = installationId();
|
|
36034
36316
|
try {
|
|
36035
|
-
await
|
|
36317
|
+
await writeFile3(pointerPath, `${JSON.stringify({ installationId: candidate, version: 1 })}
|
|
36036
36318
|
`, {
|
|
36037
36319
|
flag: "wx",
|
|
36038
36320
|
mode: 384
|
|
@@ -36196,7 +36478,7 @@ function parseResumeArgument(arguments_) {
|
|
|
36196
36478
|
async function resolveDefaultWorkspace(path2) {
|
|
36197
36479
|
const requestedWorkspace = resolve5(path2);
|
|
36198
36480
|
try {
|
|
36199
|
-
await
|
|
36481
|
+
await mkdir5(requestedWorkspace, { recursive: true, mode: 448 });
|
|
36200
36482
|
const defaultWorkspace = await realpath7(requestedWorkspace);
|
|
36201
36483
|
const metadata = await stat6(defaultWorkspace);
|
|
36202
36484
|
if (!metadata.isDirectory()) {
|
|
@@ -36418,10 +36700,10 @@ function isRuntimeRelayRevocation(closeCode, closeReason) {
|
|
|
36418
36700
|
}
|
|
36419
36701
|
|
|
36420
36702
|
// src/run-daemon.ts
|
|
36421
|
-
import { createHash as
|
|
36703
|
+
import { createHash as createHash4, randomUUID as randomUUID4 } from "node:crypto";
|
|
36422
36704
|
import { basename as basename7 } from "node:path";
|
|
36423
36705
|
import { styleText } from "node:util";
|
|
36424
|
-
import { fetch as
|
|
36706
|
+
import { fetch as fetch5, WebSocket as WebSocket2 } from "undici";
|
|
36425
36707
|
|
|
36426
36708
|
// src/agent-catalog/agent-settings-adapter.ts
|
|
36427
36709
|
var AGENT_DEFAULT_VALUE = "agent_default";
|
|
@@ -36650,11 +36932,42 @@ function relayHttpEndpoint(relayUrl) {
|
|
|
36650
36932
|
var CATALOG_UPDATE_TIMEOUT_MILLISECONDS = 2e4;
|
|
36651
36933
|
var AgentCatalogPublishError = class extends Error {
|
|
36652
36934
|
code = "agent_catalog_update_failed";
|
|
36653
|
-
|
|
36935
|
+
diagnosticDetails;
|
|
36936
|
+
constructor(message, options = {}, diagnosticDetails = {}) {
|
|
36654
36937
|
super(message, options);
|
|
36938
|
+
this.diagnosticDetails = diagnosticDetails;
|
|
36655
36939
|
this.name = "AgentCatalogPublishError";
|
|
36656
36940
|
}
|
|
36657
36941
|
};
|
|
36942
|
+
function isRecord10(value) {
|
|
36943
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36944
|
+
}
|
|
36945
|
+
function isSafeRelayErrorMessage(value) {
|
|
36946
|
+
return value.length > 0 && value.length <= 512 && Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
|
|
36947
|
+
}
|
|
36948
|
+
async function rejectedCatalogError(response) {
|
|
36949
|
+
let value;
|
|
36950
|
+
try {
|
|
36951
|
+
value = await response.json();
|
|
36952
|
+
} catch {
|
|
36953
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
36954
|
+
}
|
|
36955
|
+
if (!isRecord10(value) || !isRecord10(value["error"])) {
|
|
36956
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
36957
|
+
}
|
|
36958
|
+
const code = value["error"]["code"];
|
|
36959
|
+
const message = value["error"]["message"];
|
|
36960
|
+
if (typeof code !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(code) || typeof message !== "string" || !isSafeRelayErrorMessage(message)) {
|
|
36961
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
36962
|
+
}
|
|
36963
|
+
return new AgentCatalogPublishError(
|
|
36964
|
+
`The Relay rejected the Agent catalog update (${code}): ${message}`,
|
|
36965
|
+
{},
|
|
36966
|
+
{
|
|
36967
|
+
relayErrorCode: code
|
|
36968
|
+
}
|
|
36969
|
+
);
|
|
36970
|
+
}
|
|
36658
36971
|
function catalogEndpoint(config2) {
|
|
36659
36972
|
const endpoint = relayHttpEndpoint(config2.relayUrl);
|
|
36660
36973
|
if (endpoint.pathname.endsWith("/daemon")) {
|
|
@@ -36702,10 +37015,10 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
36702
37015
|
{ cause: error62 }
|
|
36703
37016
|
);
|
|
36704
37017
|
}
|
|
36705
|
-
await response.body?.cancel();
|
|
36706
37018
|
if (!response.ok) {
|
|
36707
|
-
throw
|
|
37019
|
+
throw await rejectedCatalogError(response);
|
|
36708
37020
|
}
|
|
37021
|
+
await response.body?.cancel();
|
|
36709
37022
|
}
|
|
36710
37023
|
|
|
36711
37024
|
// src/agent-installation/agent-installation-manager.ts
|
|
@@ -37214,30 +37527,26 @@ async function streamLocalFile(command, send2, signal) {
|
|
|
37214
37527
|
throw new Error("The local file is too large to read");
|
|
37215
37528
|
}
|
|
37216
37529
|
const raster = await readLocalRaster(target, signal);
|
|
37217
|
-
send2(
|
|
37218
|
-
|
|
37219
|
-
|
|
37220
|
-
|
|
37221
|
-
|
|
37222
|
-
|
|
37223
|
-
|
|
37224
|
-
|
|
37225
|
-
|
|
37226
|
-
})
|
|
37227
|
-
);
|
|
37530
|
+
send2({
|
|
37531
|
+
byteLength: before.size,
|
|
37532
|
+
kind: FILE_BEGIN_KIND,
|
|
37533
|
+
mediaType: raster?.mimeType ?? "application/octet-stream",
|
|
37534
|
+
modifiedAt: before.mtime.toISOString(),
|
|
37535
|
+
name: basename4(target) || "file",
|
|
37536
|
+
requestId: command.requestId,
|
|
37537
|
+
sessionId: command.sessionId
|
|
37538
|
+
});
|
|
37228
37539
|
let sequence = 0;
|
|
37229
37540
|
const stream = createReadStream2(target, { highWaterMark: CHUNK_BYTES, signal });
|
|
37230
37541
|
for await (const value of stream) {
|
|
37231
37542
|
const bytes = value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
37232
|
-
send2(
|
|
37233
|
-
|
|
37234
|
-
|
|
37235
|
-
|
|
37236
|
-
|
|
37237
|
-
|
|
37238
|
-
|
|
37239
|
-
})
|
|
37240
|
-
);
|
|
37543
|
+
send2({
|
|
37544
|
+
data: Buffer.from(bytes).toString("base64"),
|
|
37545
|
+
kind: FILE_CHUNK_KIND,
|
|
37546
|
+
requestId: command.requestId,
|
|
37547
|
+
sequence,
|
|
37548
|
+
sessionId: command.sessionId
|
|
37549
|
+
});
|
|
37241
37550
|
sequence += 1;
|
|
37242
37551
|
}
|
|
37243
37552
|
const after = await stat7(target);
|
|
@@ -37245,399 +37554,12 @@ async function streamLocalFile(command, send2, signal) {
|
|
|
37245
37554
|
if (after.size !== before.size || after.mtimeMs !== before.mtimeMs) {
|
|
37246
37555
|
throw new Error("The local file changed during transfer");
|
|
37247
37556
|
}
|
|
37248
|
-
send2(
|
|
37249
|
-
|
|
37250
|
-
|
|
37251
|
-
|
|
37252
|
-
sessionId: command.sessionId
|
|
37253
|
-
})
|
|
37254
|
-
);
|
|
37255
|
-
}
|
|
37256
|
-
|
|
37257
|
-
// src/artifacts/runtime-artifact-uploader.ts
|
|
37258
|
-
import { createHash as createHash3 } from "node:crypto";
|
|
37259
|
-
|
|
37260
|
-
// ../mobius-sdk/src/errors.ts
|
|
37261
|
-
var MobiusError = class extends Error {
|
|
37262
|
-
code;
|
|
37263
|
-
constructor(code, message, options = {}) {
|
|
37264
|
-
super(message, options);
|
|
37265
|
-
this.code = code;
|
|
37266
|
-
this.name = "MobiusError";
|
|
37267
|
-
}
|
|
37268
|
-
};
|
|
37269
|
-
var MobiusProtocolError = class extends MobiusError {
|
|
37270
|
-
constructor(message, options = {}) {
|
|
37271
|
-
super("invalid_service_response", message, options);
|
|
37272
|
-
this.name = "MobiusProtocolError";
|
|
37273
|
-
}
|
|
37274
|
-
};
|
|
37275
|
-
var MobiusValidationError = class extends MobiusError {
|
|
37276
|
-
constructor(message, options = {}) {
|
|
37277
|
-
super("invalid_request", message, options);
|
|
37278
|
-
this.name = "MobiusValidationError";
|
|
37279
|
-
}
|
|
37280
|
-
};
|
|
37281
|
-
|
|
37282
|
-
// ../mobius-sdk/src/resources.ts
|
|
37283
|
-
var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
37284
|
-
function invalidResponse(message) {
|
|
37285
|
-
return new MobiusProtocolError(message);
|
|
37286
|
-
}
|
|
37287
|
-
function isRecord10(value) {
|
|
37288
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37289
|
-
}
|
|
37290
|
-
function record2(value, name) {
|
|
37291
|
-
if (!isRecord10(value)) {
|
|
37292
|
-
throw invalidResponse(`The service returned an invalid ${name}`);
|
|
37293
|
-
}
|
|
37294
|
-
return value;
|
|
37295
|
-
}
|
|
37296
|
-
function stringField(value, field, maximumLength = 85e5) {
|
|
37297
|
-
const candidate = value[field];
|
|
37298
|
-
if (typeof candidate !== "string" || candidate.length > maximumLength) {
|
|
37299
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
37300
|
-
}
|
|
37301
|
-
return candidate;
|
|
37302
|
-
}
|
|
37303
|
-
function identifierField(value, field) {
|
|
37304
|
-
const candidate = stringField(value, field, 128);
|
|
37305
|
-
if (!IDENTIFIER_PATTERN6.test(candidate)) {
|
|
37306
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
37307
|
-
}
|
|
37308
|
-
return candidate;
|
|
37309
|
-
}
|
|
37310
|
-
function integerField(value, field) {
|
|
37311
|
-
const candidate = value[field];
|
|
37312
|
-
if (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0) {
|
|
37313
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
37314
|
-
}
|
|
37315
|
-
return candidate;
|
|
37316
|
-
}
|
|
37317
|
-
function validateTimestamp(value, field) {
|
|
37318
|
-
if (Number.isNaN(Date.parse(value))) {
|
|
37319
|
-
throw invalidResponse(`The service returned an invalid ${field}`);
|
|
37320
|
-
}
|
|
37321
|
-
return value;
|
|
37322
|
-
}
|
|
37323
|
-
var MobiusArtifactUploadRequest = class {
|
|
37324
|
-
byteLength;
|
|
37325
|
-
mediaType;
|
|
37326
|
-
name;
|
|
37327
|
-
sha256;
|
|
37328
|
-
constructor(name, mediaType, byteLength, sha256) {
|
|
37329
|
-
if (name.length < 1 || name.length > 500 || name.includes("\0") || mediaType.length < 1 || mediaType.length > 255 || mediaType.includes("\r") || mediaType.includes("\n") || !Number.isSafeInteger(byteLength) || byteLength < 1 || !/^[a-f0-9]{64}$/.test(sha256)) {
|
|
37330
|
-
throw new MobiusValidationError("The artifact upload request is invalid");
|
|
37331
|
-
}
|
|
37332
|
-
this.byteLength = byteLength;
|
|
37333
|
-
this.mediaType = mediaType;
|
|
37334
|
-
this.name = name;
|
|
37335
|
-
this.sha256 = sha256;
|
|
37336
|
-
}
|
|
37337
|
-
};
|
|
37338
|
-
var MobiusArtifact = class {
|
|
37339
|
-
artifactId;
|
|
37340
|
-
byteLength;
|
|
37341
|
-
createdAt;
|
|
37342
|
-
mediaType;
|
|
37343
|
-
name;
|
|
37344
|
-
sessionId;
|
|
37345
|
-
sha256;
|
|
37346
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt) {
|
|
37347
|
-
this.artifactId = artifactId;
|
|
37348
|
-
this.byteLength = byteLength;
|
|
37349
|
-
this.createdAt = createdAt;
|
|
37350
|
-
this.mediaType = mediaType;
|
|
37351
|
-
this.name = name;
|
|
37352
|
-
this.sessionId = sessionId;
|
|
37353
|
-
this.sha256 = sha256;
|
|
37354
|
-
}
|
|
37355
|
-
};
|
|
37356
|
-
var MobiusUploadingArtifact = class extends MobiusArtifact {
|
|
37357
|
-
expiresAt;
|
|
37358
|
-
state = "uploading";
|
|
37359
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiresAt) {
|
|
37360
|
-
super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
|
|
37361
|
-
this.expiresAt = expiresAt;
|
|
37362
|
-
}
|
|
37363
|
-
};
|
|
37364
|
-
var MobiusArtifactUpload = class extends MobiusUploadingArtifact {
|
|
37365
|
-
uploadToken;
|
|
37366
|
-
constructor(artifact, uploadToken) {
|
|
37367
|
-
super(
|
|
37368
|
-
artifact.sessionId,
|
|
37369
|
-
artifact.artifactId,
|
|
37370
|
-
artifact.name,
|
|
37371
|
-
artifact.mediaType,
|
|
37372
|
-
artifact.byteLength,
|
|
37373
|
-
artifact.sha256,
|
|
37374
|
-
artifact.createdAt,
|
|
37375
|
-
artifact.expiresAt
|
|
37376
|
-
);
|
|
37377
|
-
this.uploadToken = uploadToken;
|
|
37378
|
-
}
|
|
37379
|
-
};
|
|
37380
|
-
var MobiusAvailableArtifact = class extends MobiusArtifact {
|
|
37381
|
-
availableAt;
|
|
37382
|
-
state = "available";
|
|
37383
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, availableAt) {
|
|
37384
|
-
super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
|
|
37385
|
-
this.availableAt = availableAt;
|
|
37386
|
-
}
|
|
37387
|
-
};
|
|
37388
|
-
var MobiusExpiredArtifact = class extends MobiusArtifact {
|
|
37389
|
-
expiredAt;
|
|
37390
|
-
state = "expired";
|
|
37391
|
-
constructor(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt, expiredAt) {
|
|
37392
|
-
super(sessionId, artifactId, name, mediaType, byteLength, sha256, createdAt);
|
|
37393
|
-
this.expiredAt = expiredAt;
|
|
37394
|
-
}
|
|
37395
|
-
};
|
|
37396
|
-
function artifactFields(value) {
|
|
37397
|
-
const sha256 = stringField(value, "sha256", 64);
|
|
37398
|
-
if (!/^[a-f0-9]{64}$/.test(sha256)) {
|
|
37399
|
-
throw invalidResponse("The service returned an invalid artifact digest");
|
|
37400
|
-
}
|
|
37401
|
-
return {
|
|
37402
|
-
artifactId: identifierField(value, "artifactId"),
|
|
37403
|
-
byteLength: integerField(value, "byteLength"),
|
|
37404
|
-
createdAt: validateTimestamp(stringField(value, "createdAt", 128), "createdAt"),
|
|
37405
|
-
mediaType: stringField(value, "mediaType", 255),
|
|
37406
|
-
name: stringField(value, "name", 500),
|
|
37407
|
-
sessionId: identifierField(value, "sessionId"),
|
|
37408
|
-
sha256
|
|
37409
|
-
};
|
|
37410
|
-
}
|
|
37411
|
-
function uploadingArtifact(value) {
|
|
37412
|
-
const fields = artifactFields(value);
|
|
37413
|
-
return new MobiusUploadingArtifact(
|
|
37414
|
-
fields.sessionId,
|
|
37415
|
-
fields.artifactId,
|
|
37416
|
-
fields.name,
|
|
37417
|
-
fields.mediaType,
|
|
37418
|
-
fields.byteLength,
|
|
37419
|
-
fields.sha256,
|
|
37420
|
-
fields.createdAt,
|
|
37421
|
-
validateTimestamp(stringField(value, "expiresAt", 128), "expiresAt")
|
|
37422
|
-
);
|
|
37423
|
-
}
|
|
37424
|
-
function decodeMobiusArtifactUpload(value) {
|
|
37425
|
-
const artifact = record2(value, "artifact upload authorization");
|
|
37426
|
-
return new MobiusArtifactUpload(uploadingArtifact(artifact), stringField(artifact, "uploadToken", 256));
|
|
37427
|
-
}
|
|
37428
|
-
function decodeMobiusArtifact(value) {
|
|
37429
|
-
const artifact = record2(value, "artifact");
|
|
37430
|
-
const state = stringField(artifact, "state", 32);
|
|
37431
|
-
if (state === "uploading") {
|
|
37432
|
-
return uploadingArtifact(artifact);
|
|
37433
|
-
}
|
|
37434
|
-
const fields = artifactFields(artifact);
|
|
37435
|
-
if (state === "available") {
|
|
37436
|
-
return new MobiusAvailableArtifact(
|
|
37437
|
-
fields.sessionId,
|
|
37438
|
-
fields.artifactId,
|
|
37439
|
-
fields.name,
|
|
37440
|
-
fields.mediaType,
|
|
37441
|
-
fields.byteLength,
|
|
37442
|
-
fields.sha256,
|
|
37443
|
-
fields.createdAt,
|
|
37444
|
-
validateTimestamp(stringField(artifact, "availableAt", 128), "availableAt")
|
|
37445
|
-
);
|
|
37446
|
-
}
|
|
37447
|
-
if (state === "expired") {
|
|
37448
|
-
return new MobiusExpiredArtifact(
|
|
37449
|
-
fields.sessionId,
|
|
37450
|
-
fields.artifactId,
|
|
37451
|
-
fields.name,
|
|
37452
|
-
fields.mediaType,
|
|
37453
|
-
fields.byteLength,
|
|
37454
|
-
fields.sha256,
|
|
37455
|
-
fields.createdAt,
|
|
37456
|
-
validateTimestamp(stringField(artifact, "expiredAt", 128), "expiredAt")
|
|
37457
|
-
);
|
|
37458
|
-
}
|
|
37459
|
-
throw invalidResponse("The service returned an invalid artifact state");
|
|
37460
|
-
}
|
|
37461
|
-
function decodeMobiusAvailableArtifact(value) {
|
|
37462
|
-
const artifact = decodeMobiusArtifact(value);
|
|
37463
|
-
if (!(artifact instanceof MobiusAvailableArtifact)) {
|
|
37464
|
-
throw invalidResponse("The service did not make the artifact available");
|
|
37465
|
-
}
|
|
37466
|
-
return artifact;
|
|
37467
|
-
}
|
|
37468
|
-
var MobiusRuntimePairingLifecycle = Object.freeze({
|
|
37469
|
-
Expired: "expired",
|
|
37470
|
-
Paired: "paired",
|
|
37471
|
-
Pending: "pending",
|
|
37472
|
-
Revoked: "revoked"
|
|
37473
|
-
});
|
|
37474
|
-
|
|
37475
|
-
// src/artifacts/runtime-artifact-uploader.ts
|
|
37476
|
-
import { fetch as fetch4 } from "undici";
|
|
37477
|
-
var UPLOAD_TIMEOUT_MILLISECONDS = 2e4;
|
|
37478
|
-
var RuntimeArtifactUploadError = class extends Error {
|
|
37479
|
-
code;
|
|
37480
|
-
constructor(code, message, options = {}) {
|
|
37481
|
-
super(message, options);
|
|
37482
|
-
this.code = code;
|
|
37483
|
-
this.name = "RuntimeArtifactUploadError";
|
|
37484
|
-
}
|
|
37485
|
-
};
|
|
37486
|
-
var UploadedRuntimeArtifact = class {
|
|
37487
|
-
artifactId;
|
|
37488
|
-
byteLength;
|
|
37489
|
-
mimeType;
|
|
37490
|
-
name;
|
|
37491
|
-
sha256;
|
|
37492
|
-
constructor(artifactId, name, mimeType, byteLength, sha256) {
|
|
37493
|
-
this.artifactId = artifactId;
|
|
37494
|
-
this.byteLength = byteLength;
|
|
37495
|
-
this.mimeType = mimeType;
|
|
37496
|
-
this.name = name;
|
|
37497
|
-
this.sha256 = sha256;
|
|
37498
|
-
}
|
|
37499
|
-
};
|
|
37500
|
-
function channelOrigin(config2) {
|
|
37501
|
-
const url2 = new URL(config2.relayUrl);
|
|
37502
|
-
url2.protocol = url2.protocol === "wss:" ? "https:" : "http:";
|
|
37503
|
-
let channelPath = "";
|
|
37504
|
-
if (url2.pathname.endsWith("/daemon")) {
|
|
37505
|
-
channelPath = url2.pathname.slice(0, -"/daemon".length);
|
|
37506
|
-
} else {
|
|
37507
|
-
const runtimePath = `${MOBIUS_API_PREFIX}/v1/runtimes/connect`;
|
|
37508
|
-
if (!url2.pathname.endsWith("/v1/runtimes/connect") && !url2.pathname.endsWith(runtimePath)) {
|
|
37509
|
-
throw new RuntimeArtifactUploadError("artifact_endpoint_invalid", "The Relay artifact endpoint is invalid");
|
|
37510
|
-
}
|
|
37511
|
-
channelPath = `${url2.pathname.replace(/\/v1\/runtimes\/connect$/, "")}/channels/${encodeURIComponent(config2.channelId)}`;
|
|
37512
|
-
}
|
|
37513
|
-
url2.pathname = channelPath;
|
|
37514
|
-
url2.search = "";
|
|
37515
|
-
url2.hash = "";
|
|
37516
|
-
return url2;
|
|
37517
|
-
}
|
|
37518
|
-
function uploadError(code, message, cause) {
|
|
37519
|
-
return new RuntimeArtifactUploadError(code, message, cause === void 0 ? {} : { cause });
|
|
37520
|
-
}
|
|
37521
|
-
function translateSdkError(cause) {
|
|
37522
|
-
if (cause instanceof MobiusValidationError) {
|
|
37523
|
-
throw uploadError("artifact_upload_failed", cause.message, cause);
|
|
37524
|
-
}
|
|
37525
|
-
if (cause instanceof MobiusProtocolError) {
|
|
37526
|
-
throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
|
|
37527
|
-
}
|
|
37528
|
-
throw cause;
|
|
37529
|
-
}
|
|
37530
|
-
async function readJson(response) {
|
|
37531
|
-
try {
|
|
37532
|
-
return await response.json();
|
|
37533
|
-
} catch (cause) {
|
|
37534
|
-
throw uploadError("artifact_upload_failed", "The Relay returned an invalid upload response", cause);
|
|
37535
|
-
}
|
|
37536
|
-
}
|
|
37537
|
-
async function readAuthorization(response) {
|
|
37538
|
-
try {
|
|
37539
|
-
return decodeMobiusArtifactUpload(await readJson(response));
|
|
37540
|
-
} catch (cause) {
|
|
37541
|
-
translateSdkError(cause);
|
|
37542
|
-
}
|
|
37543
|
-
}
|
|
37544
|
-
function sessionArtifactUrl(origin, sessionId, resourcePath) {
|
|
37545
|
-
return new URL(`${origin.pathname}/sessions/${encodeURIComponent(sessionId)}/${resourcePath}`, origin);
|
|
37546
|
-
}
|
|
37547
|
-
async function postLease(url2, headers, request, signal) {
|
|
37548
|
-
return await fetch4(url2, {
|
|
37549
|
-
dispatcher: environmentProxyDispatcher,
|
|
37550
|
-
headers: { ...headers, "content-type": "application/json" },
|
|
37551
|
-
method: "POST",
|
|
37552
|
-
body: JSON.stringify(request),
|
|
37553
|
-
signal
|
|
37554
|
-
});
|
|
37555
|
-
}
|
|
37556
|
-
async function putContent(url2, headers, authorization, bytes, signal) {
|
|
37557
|
-
return await fetch4(url2, {
|
|
37558
|
-
dispatcher: environmentProxyDispatcher,
|
|
37559
|
-
headers: {
|
|
37560
|
-
...headers,
|
|
37561
|
-
"content-type": authorization.mediaType,
|
|
37562
|
-
"x-mobius-upload-token": authorization.uploadToken
|
|
37563
|
-
},
|
|
37564
|
-
method: "PUT",
|
|
37565
|
-
body: bytes,
|
|
37566
|
-
signal
|
|
37557
|
+
send2({
|
|
37558
|
+
kind: FILE_END_KIND,
|
|
37559
|
+
requestId: command.requestId,
|
|
37560
|
+
sessionId: command.sessionId
|
|
37567
37561
|
});
|
|
37568
37562
|
}
|
|
37569
|
-
async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
37570
|
-
signal.throwIfAborted();
|
|
37571
|
-
let request;
|
|
37572
|
-
try {
|
|
37573
|
-
request = new MobiusArtifactUploadRequest(
|
|
37574
|
-
artifact.name,
|
|
37575
|
-
artifact.mimeType,
|
|
37576
|
-
artifact.bytes.byteLength,
|
|
37577
|
-
createHash3("sha256").update(artifact.bytes).digest("hex")
|
|
37578
|
-
);
|
|
37579
|
-
} catch (cause) {
|
|
37580
|
-
translateSdkError(cause);
|
|
37581
|
-
}
|
|
37582
|
-
const timeoutSignal = AbortSignal.timeout(UPLOAD_TIMEOUT_MILLISECONDS);
|
|
37583
|
-
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
37584
|
-
const origin = channelOrigin(config2);
|
|
37585
|
-
const headers = runtimeAuthorization(config2.relayUrl);
|
|
37586
|
-
let created;
|
|
37587
|
-
try {
|
|
37588
|
-
created = await postLease(
|
|
37589
|
-
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"),
|
|
37590
|
-
headers,
|
|
37591
|
-
request,
|
|
37592
|
-
requestSignal
|
|
37593
|
-
);
|
|
37594
|
-
} catch (cause) {
|
|
37595
|
-
signal.throwIfAborted();
|
|
37596
|
-
throw uploadError(
|
|
37597
|
-
timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
|
|
37598
|
-
timeoutSignal.aborted ? "The artifact upload authorization timed out" : "The artifact upload could not start",
|
|
37599
|
-
cause
|
|
37600
|
-
);
|
|
37601
|
-
}
|
|
37602
|
-
if (!created.ok) {
|
|
37603
|
-
await created.body?.cancel();
|
|
37604
|
-
throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact upload");
|
|
37605
|
-
}
|
|
37606
|
-
const authorization = await readAuthorization(created);
|
|
37607
|
-
let uploaded;
|
|
37608
|
-
try {
|
|
37609
|
-
uploaded = await putContent(
|
|
37610
|
-
sessionArtifactUrl(origin, sessionId, `artifacts/${encodeURIComponent(authorization.artifactId)}/content`),
|
|
37611
|
-
headers,
|
|
37612
|
-
authorization,
|
|
37613
|
-
artifact.bytes,
|
|
37614
|
-
requestSignal
|
|
37615
|
-
);
|
|
37616
|
-
} catch (cause) {
|
|
37617
|
-
signal.throwIfAborted();
|
|
37618
|
-
throw uploadError(
|
|
37619
|
-
timeoutSignal.aborted ? "artifact_upload_timeout" : "artifact_upload_failed",
|
|
37620
|
-
timeoutSignal.aborted ? "The artifact upload timed out" : "The artifact content could not be uploaded",
|
|
37621
|
-
cause
|
|
37622
|
-
);
|
|
37623
|
-
}
|
|
37624
|
-
if (!uploaded.ok) {
|
|
37625
|
-
await uploaded.body?.cancel();
|
|
37626
|
-
throw uploadError("artifact_upload_rejected", "The Relay rejected the artifact content");
|
|
37627
|
-
}
|
|
37628
|
-
try {
|
|
37629
|
-
const available = decodeMobiusAvailableArtifact(await readJson(uploaded));
|
|
37630
|
-
return new UploadedRuntimeArtifact(
|
|
37631
|
-
available.artifactId,
|
|
37632
|
-
available.name,
|
|
37633
|
-
available.mediaType,
|
|
37634
|
-
available.byteLength,
|
|
37635
|
-
available.sha256
|
|
37636
|
-
);
|
|
37637
|
-
} catch (cause) {
|
|
37638
|
-
translateSdkError(cause);
|
|
37639
|
-
}
|
|
37640
|
-
}
|
|
37641
37563
|
|
|
37642
37564
|
// src/authorization/workspace-directory.ts
|
|
37643
37565
|
import { readdir as readdir2, realpath as realpath9, stat as stat8 } from "node:fs/promises";
|
|
@@ -38458,13 +38380,13 @@ var NativeSessionService = class {
|
|
|
38458
38380
|
};
|
|
38459
38381
|
|
|
38460
38382
|
// src/prompt-artifact-resolver.ts
|
|
38461
|
-
import { createHash as
|
|
38462
|
-
import { fetch as
|
|
38383
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
38384
|
+
import { fetch as fetch4 } from "undici";
|
|
38463
38385
|
var ARTIFACT_SCHEME = "mobius-artifact:";
|
|
38464
38386
|
var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
|
|
38465
38387
|
var MAX_AGENT_IMAGE_BASE64_LENGTH = 4e6;
|
|
38466
38388
|
var MAX_AGENT_RESOURCE_BYTE_LENGTH = 1e6;
|
|
38467
|
-
var
|
|
38389
|
+
var IDENTIFIER_PATTERN6 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
38468
38390
|
var PromptArtifactError = class extends Error {
|
|
38469
38391
|
code;
|
|
38470
38392
|
constructor(code, message, options = {}) {
|
|
@@ -38507,7 +38429,7 @@ function parseReference(resource) {
|
|
|
38507
38429
|
const encodedByteLength2 = url2.searchParams.get("byteLength") ?? "";
|
|
38508
38430
|
const sha256 = url2.searchParams.get("sha256") ?? "";
|
|
38509
38431
|
const byteLength = Number(encodedByteLength2);
|
|
38510
|
-
if (url2.protocol !== ARTIFACT_SCHEME || url2.hash.length > 0 || resource.type !== "link" || resource.text.length > 0 || !
|
|
38432
|
+
if (url2.protocol !== ARTIFACT_SCHEME || url2.hash.length > 0 || resource.type !== "link" || resource.text.length > 0 || !IDENTIFIER_PATTERN6.test(artifactId) || keys.length !== 2 || keys[0] !== "byteLength" || keys[1] !== "sha256" || !/^[1-9][0-9]*$/.test(encodedByteLength2) || !Number.isSafeInteger(byteLength) || !/^[a-f0-9]{64}$/.test(sha256)) {
|
|
38511
38433
|
throw new PromptArtifactError("artifact_reference_invalid", "The prompt artifact reference is invalid");
|
|
38512
38434
|
}
|
|
38513
38435
|
return new PromptArtifactReference(artifactId, byteLength, sha256, resource);
|
|
@@ -38573,7 +38495,7 @@ async function download(config2, command, reference, signal) {
|
|
|
38573
38495
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
38574
38496
|
let response;
|
|
38575
38497
|
try {
|
|
38576
|
-
response = await
|
|
38498
|
+
response = await fetch4(downloadUrl(config2, command, reference), {
|
|
38577
38499
|
dispatcher: environmentProxyDispatcher,
|
|
38578
38500
|
headers: {
|
|
38579
38501
|
accept: reference.resource.mimeType,
|
|
@@ -38597,7 +38519,7 @@ async function download(config2, command, reference, signal) {
|
|
|
38597
38519
|
);
|
|
38598
38520
|
}
|
|
38599
38521
|
const bytes = await responseBytes(response, reference.byteLength, requestSignal);
|
|
38600
|
-
if (
|
|
38522
|
+
if (createHash3("sha256").update(bytes).digest("hex") !== reference.sha256) {
|
|
38601
38523
|
throw new PromptArtifactError(
|
|
38602
38524
|
"artifact_integrity_failed",
|
|
38603
38525
|
"The prompt artifact failed integrity validation"
|
|
@@ -39067,12 +38989,10 @@ var RelayConnectionLiveness = class {
|
|
|
39067
38989
|
heartbeatId,
|
|
39068
38990
|
this.#timer.schedule(this.#handleTimeout, HEARTBEAT_ACK_TIMEOUT_MILLISECONDS)
|
|
39069
38991
|
);
|
|
39070
|
-
const sent = this.#transport.send(
|
|
39071
|
-
|
|
39072
|
-
|
|
39073
|
-
|
|
39074
|
-
})
|
|
39075
|
-
);
|
|
38992
|
+
const sent = this.#transport.send({
|
|
38993
|
+
heartbeatId,
|
|
38994
|
+
kind: RUNTIME_HEARTBEAT_KIND
|
|
38995
|
+
});
|
|
39076
38996
|
if (!sent && this.#state instanceof AwaitingHeartbeatAckState && this.#state.heartbeatId === heartbeatId) {
|
|
39077
38997
|
this.#state.timeout.cancel();
|
|
39078
38998
|
this.#state = new FinishedRelayLivenessState();
|
|
@@ -39684,47 +39604,44 @@ var AGENT_TEXT_MAXIMUM_LENGTH = 1e5;
|
|
|
39684
39604
|
var ACTIVE_TURN_RECONCILIATION_TIMEOUT_MILLISECONDS = 2e4;
|
|
39685
39605
|
var ACTIVE_TURN_RECONCILIATION_CLOSE_CODE = 4009;
|
|
39686
39606
|
var DaemonAcpObserver = class {
|
|
39687
|
-
#config;
|
|
39688
39607
|
#record;
|
|
39689
|
-
constructor(
|
|
39690
|
-
this.#
|
|
39691
|
-
this.#record = record3;
|
|
39608
|
+
constructor(record2) {
|
|
39609
|
+
this.#record = record2;
|
|
39692
39610
|
}
|
|
39693
|
-
importLocalArtifact = async (sessionId, artifact, signal) => (await uploadRuntimeArtifact(this.#config, sessionId, artifact, signal)).artifactId;
|
|
39694
39611
|
onCommands = (event) => {
|
|
39695
|
-
this.#record(event.sessionId,
|
|
39612
|
+
this.#record(event.sessionId, event);
|
|
39696
39613
|
return Promise.resolve();
|
|
39697
39614
|
};
|
|
39698
39615
|
onConfig = (event) => {
|
|
39699
|
-
this.#record(event.sessionId,
|
|
39616
|
+
this.#record(event.sessionId, event);
|
|
39700
39617
|
return Promise.resolve();
|
|
39701
39618
|
};
|
|
39702
39619
|
onContent = (event) => {
|
|
39703
|
-
this.#record(event.sessionId,
|
|
39620
|
+
this.#record(event.sessionId, event);
|
|
39704
39621
|
return Promise.resolve();
|
|
39705
39622
|
};
|
|
39706
39623
|
onElicitation = (event) => {
|
|
39707
|
-
this.#record(event.sessionId,
|
|
39624
|
+
this.#record(event.sessionId, event);
|
|
39708
39625
|
return Promise.resolve();
|
|
39709
39626
|
};
|
|
39710
39627
|
onElicitationResolved = (event) => {
|
|
39711
|
-
this.#record(event.sessionId,
|
|
39628
|
+
this.#record(event.sessionId, event);
|
|
39712
39629
|
return Promise.resolve();
|
|
39713
39630
|
};
|
|
39714
39631
|
onInfo = (event) => {
|
|
39715
|
-
this.#record(event.sessionId,
|
|
39632
|
+
this.#record(event.sessionId, event);
|
|
39716
39633
|
return Promise.resolve();
|
|
39717
39634
|
};
|
|
39718
39635
|
onPermission = (event) => {
|
|
39719
|
-
this.#record(event.sessionId,
|
|
39636
|
+
this.#record(event.sessionId, event);
|
|
39720
39637
|
return Promise.resolve();
|
|
39721
39638
|
};
|
|
39722
39639
|
onPermissionResolved = (event) => {
|
|
39723
|
-
this.#record(event.sessionId,
|
|
39640
|
+
this.#record(event.sessionId, event);
|
|
39724
39641
|
return Promise.resolve();
|
|
39725
39642
|
};
|
|
39726
39643
|
onUsage = (event) => {
|
|
39727
|
-
this.#record(event.sessionId,
|
|
39644
|
+
this.#record(event.sessionId, event);
|
|
39728
39645
|
return Promise.resolve();
|
|
39729
39646
|
};
|
|
39730
39647
|
};
|
|
@@ -39773,60 +39690,45 @@ var DaemonInstallationObserver = class {
|
|
|
39773
39690
|
if (state instanceof RunningInstallation) {
|
|
39774
39691
|
if (!this.#started.has(state.requestId)) {
|
|
39775
39692
|
this.#started.add(state.requestId);
|
|
39776
|
-
this.#send(
|
|
39777
|
-
socket,
|
|
39778
|
-
encodeAgentInstallStartedEvent({
|
|
39779
|
-
agentId: state.agentId,
|
|
39780
|
-
kind: AGENT_INSTALL_STARTED_KIND,
|
|
39781
|
-
requestId: state.requestId
|
|
39782
|
-
})
|
|
39783
|
-
);
|
|
39784
|
-
}
|
|
39785
|
-
this.#send(
|
|
39786
|
-
socket,
|
|
39787
|
-
encodeAgentInstallProgressEvent({
|
|
39693
|
+
this.#send(socket, {
|
|
39788
39694
|
agentId: state.agentId,
|
|
39789
|
-
kind:
|
|
39790
|
-
requestId: state.requestId
|
|
39791
|
-
|
|
39792
|
-
|
|
39793
|
-
|
|
39695
|
+
kind: AGENT_INSTALL_STARTED_KIND,
|
|
39696
|
+
requestId: state.requestId
|
|
39697
|
+
});
|
|
39698
|
+
}
|
|
39699
|
+
this.#send(socket, {
|
|
39700
|
+
agentId: state.agentId,
|
|
39701
|
+
kind: AGENT_INSTALL_PROGRESS_KIND,
|
|
39702
|
+
requestId: state.requestId,
|
|
39703
|
+
stage: state.stage
|
|
39704
|
+
});
|
|
39794
39705
|
return Promise.resolve();
|
|
39795
39706
|
}
|
|
39796
39707
|
if (state instanceof SucceededInstallation) {
|
|
39797
|
-
this.#send(
|
|
39798
|
-
|
|
39799
|
-
|
|
39800
|
-
|
|
39801
|
-
|
|
39802
|
-
|
|
39803
|
-
requestId: state.requestId
|
|
39804
|
-
})
|
|
39805
|
-
);
|
|
39708
|
+
this.#send(socket, {
|
|
39709
|
+
agentId: state.agentId,
|
|
39710
|
+
authenticationMayBeRequired: state.authenticationMayBeRequired,
|
|
39711
|
+
kind: AGENT_INSTALL_COMPLETED_KIND,
|
|
39712
|
+
requestId: state.requestId
|
|
39713
|
+
});
|
|
39806
39714
|
return Promise.resolve();
|
|
39807
39715
|
}
|
|
39808
39716
|
if (state instanceof FailedInstallation) {
|
|
39809
|
-
this.#send(
|
|
39810
|
-
|
|
39811
|
-
|
|
39812
|
-
|
|
39813
|
-
|
|
39814
|
-
|
|
39815
|
-
|
|
39816
|
-
requestId: state.requestId
|
|
39817
|
-
})
|
|
39818
|
-
);
|
|
39717
|
+
this.#send(socket, {
|
|
39718
|
+
agentId: state.agentId,
|
|
39719
|
+
code: state.code,
|
|
39720
|
+
kind: AGENT_INSTALL_FAILED_KIND,
|
|
39721
|
+
message: state.message,
|
|
39722
|
+
requestId: state.requestId
|
|
39723
|
+
});
|
|
39819
39724
|
return Promise.resolve();
|
|
39820
39725
|
}
|
|
39821
39726
|
if (state instanceof CancelledInstallation) {
|
|
39822
|
-
this.#send(
|
|
39823
|
-
|
|
39824
|
-
|
|
39825
|
-
|
|
39826
|
-
|
|
39827
|
-
requestId: state.requestId
|
|
39828
|
-
})
|
|
39829
|
-
);
|
|
39727
|
+
this.#send(socket, {
|
|
39728
|
+
agentId: state.agentId,
|
|
39729
|
+
kind: AGENT_INSTALL_CANCELLED_KIND,
|
|
39730
|
+
requestId: state.requestId
|
|
39731
|
+
});
|
|
39830
39732
|
return Promise.resolve();
|
|
39831
39733
|
}
|
|
39832
39734
|
throw new Error("Unsupported Agent integration installation state");
|
|
@@ -39923,7 +39825,7 @@ async function reconcileActiveTurn(config2, turn, signal) {
|
|
|
39923
39825
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
39924
39826
|
let response;
|
|
39925
39827
|
try {
|
|
39926
|
-
response = await
|
|
39828
|
+
response = await fetch5(activeTurnReconciliationEndpoint(config2, turn), {
|
|
39927
39829
|
body: JSON.stringify({ outcome: { kind: "running" } }),
|
|
39928
39830
|
dispatcher: environmentProxyDispatcher,
|
|
39929
39831
|
headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
|
|
@@ -39956,7 +39858,7 @@ function send(socket, message) {
|
|
|
39956
39858
|
if (socket.readyState !== WebSocket2.OPEN) {
|
|
39957
39859
|
throw new Error("Relay connection is not open");
|
|
39958
39860
|
}
|
|
39959
|
-
socket.send(message);
|
|
39861
|
+
socket.send(encodeDaemonToServiceMessage(message));
|
|
39960
39862
|
}
|
|
39961
39863
|
function closeRelaySocket(socket, code, reason) {
|
|
39962
39864
|
try {
|
|
@@ -39990,7 +39892,7 @@ var ConnectedDaemonSessionEventState = class extends DaemonSessionEventConnectio
|
|
|
39990
39892
|
return false;
|
|
39991
39893
|
}
|
|
39992
39894
|
try {
|
|
39993
|
-
this.#socket.send(message);
|
|
39895
|
+
this.#socket.send(encodeDaemonToServiceMessage(message));
|
|
39994
39896
|
return true;
|
|
39995
39897
|
} catch {
|
|
39996
39898
|
return false;
|
|
@@ -40034,17 +39936,17 @@ var DaemonSessionEventPublisher = class {
|
|
|
40034
39936
|
this.#connection = this.#connection.disconnect(socket);
|
|
40035
39937
|
this.#clearInFlight();
|
|
40036
39938
|
};
|
|
40037
|
-
recordAttempt = (sessionId,
|
|
40038
|
-
const
|
|
40039
|
-
if (kind === SESSION_COMPLETED_KIND || kind === SESSION_FAILED_KIND) {
|
|
40040
|
-
this.#outbox.enqueueCritical(sessionId,
|
|
39939
|
+
recordAttempt = (sessionId, event, attemptId) => {
|
|
39940
|
+
const encoded = encodeRecordedSessionEvent(event);
|
|
39941
|
+
if (event.kind === SESSION_COMPLETED_KIND || event.kind === SESSION_FAILED_KIND) {
|
|
39942
|
+
this.#outbox.enqueueCritical(sessionId, encoded, attemptId);
|
|
40041
39943
|
} else {
|
|
40042
|
-
this.#outbox.enqueue(sessionId,
|
|
39944
|
+
this.#outbox.enqueue(sessionId, encoded, attemptId);
|
|
40043
39945
|
}
|
|
40044
39946
|
this.#publishNextBatch();
|
|
40045
39947
|
};
|
|
40046
|
-
recordRuntime = (sessionId,
|
|
40047
|
-
this.#outbox.enqueue(sessionId,
|
|
39948
|
+
recordRuntime = (sessionId, event) => {
|
|
39949
|
+
this.#outbox.enqueue(sessionId, encodeRecordedSessionEvent(event));
|
|
40048
39950
|
this.#publishNextBatch();
|
|
40049
39951
|
};
|
|
40050
39952
|
acknowledge = (acknowledgement) => {
|
|
@@ -40111,7 +40013,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
40111
40013
|
if (this.#inFlightBytes + byteLength > SESSION_EVENT_REPLAY_BYTE_LIMIT) {
|
|
40112
40014
|
continue;
|
|
40113
40015
|
}
|
|
40114
|
-
if (!this.#connection.send(
|
|
40016
|
+
if (!this.#connection.send(envelope2)) {
|
|
40115
40017
|
this.#clearInFlight();
|
|
40116
40018
|
return;
|
|
40117
40019
|
}
|
|
@@ -40205,8 +40107,8 @@ var CoalescingDaemonActivityPublisher = class {
|
|
|
40205
40107
|
}
|
|
40206
40108
|
};
|
|
40207
40109
|
};
|
|
40208
|
-
function
|
|
40209
|
-
return
|
|
40110
|
+
function daemonActivity(command, activity) {
|
|
40111
|
+
return {
|
|
40210
40112
|
activityId: activity.activityId,
|
|
40211
40113
|
activityType: activity.activityType,
|
|
40212
40114
|
commandId: command.commandId,
|
|
@@ -40222,18 +40124,18 @@ function encodeDaemonActivity(command, activity) {
|
|
|
40222
40124
|
status: activity.status,
|
|
40223
40125
|
title: activity.title,
|
|
40224
40126
|
toolKind: activity.toolKind
|
|
40225
|
-
}
|
|
40127
|
+
};
|
|
40226
40128
|
}
|
|
40227
40129
|
function reportFailure(publisher, command, code, message, attemptId) {
|
|
40228
40130
|
publisher.recordAttempt(
|
|
40229
40131
|
command.sessionId,
|
|
40230
|
-
|
|
40132
|
+
{
|
|
40231
40133
|
code,
|
|
40232
40134
|
commandId: command.commandId,
|
|
40233
40135
|
kind: SESSION_FAILED_KIND,
|
|
40234
40136
|
message,
|
|
40235
40137
|
sessionId: command.sessionId
|
|
40236
|
-
}
|
|
40138
|
+
},
|
|
40237
40139
|
attemptId
|
|
40238
40140
|
);
|
|
40239
40141
|
}
|
|
@@ -40253,17 +40155,14 @@ function reportOperationFailure(socket, requestId, sessionId, error62, runtimeTi
|
|
|
40253
40155
|
if (socket.readyState !== WebSocket2.OPEN) {
|
|
40254
40156
|
return;
|
|
40255
40157
|
}
|
|
40256
|
-
send(
|
|
40257
|
-
|
|
40258
|
-
|
|
40259
|
-
|
|
40260
|
-
|
|
40261
|
-
|
|
40262
|
-
|
|
40263
|
-
|
|
40264
|
-
sessionId
|
|
40265
|
-
})
|
|
40266
|
-
);
|
|
40158
|
+
send(socket, {
|
|
40159
|
+
code: operationErrorCode(error62),
|
|
40160
|
+
kind: "session.operation.failed",
|
|
40161
|
+
message: operationErrorMessage(error62),
|
|
40162
|
+
requestId,
|
|
40163
|
+
...runtimeTimings.length === 0 ? {} : { runtimeTimings },
|
|
40164
|
+
sessionId
|
|
40165
|
+
});
|
|
40267
40166
|
}
|
|
40268
40167
|
async function resolveSessionDirectories(directories, bindingId, directoryId2, additionalDirectoryIds, signal) {
|
|
40269
40168
|
const cwd = await directories.resolve(bindingId, directoryId2, signal);
|
|
@@ -40436,7 +40335,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
|
|
|
40436
40335
|
resolution: modelEffort.resolution,
|
|
40437
40336
|
valuesByModel: {}
|
|
40438
40337
|
};
|
|
40439
|
-
return
|
|
40338
|
+
return createHash4("sha256").update(
|
|
40440
40339
|
JSON.stringify({
|
|
40441
40340
|
adapterVersion: agent.adapterVersion,
|
|
40442
40341
|
agentId: agent.id,
|
|
@@ -40455,18 +40354,15 @@ async function executeWorkspaceList(socket, command, directories, audit, signal)
|
|
|
40455
40354
|
event: "workspace_list_authorized",
|
|
40456
40355
|
sessionId: "workspace-browser"
|
|
40457
40356
|
});
|
|
40458
|
-
send(
|
|
40459
|
-
|
|
40460
|
-
|
|
40461
|
-
|
|
40462
|
-
|
|
40463
|
-
|
|
40464
|
-
|
|
40465
|
-
|
|
40466
|
-
|
|
40467
|
-
requestId: command.requestId
|
|
40468
|
-
})
|
|
40469
|
-
);
|
|
40357
|
+
send(socket, {
|
|
40358
|
+
bindingId: command.bindingId,
|
|
40359
|
+
directoryId: listing.directoryId,
|
|
40360
|
+
directoryLabel: listing.directoryLabel,
|
|
40361
|
+
entries: listing.entries,
|
|
40362
|
+
kind: "workspace.entries",
|
|
40363
|
+
parentDirectoryId: listing.parentDirectoryId,
|
|
40364
|
+
requestId: command.requestId
|
|
40365
|
+
});
|
|
40470
40366
|
} catch (error62) {
|
|
40471
40367
|
reportOperationFailure(socket, command.requestId, "", error62);
|
|
40472
40368
|
}
|
|
@@ -40521,15 +40417,12 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
|
|
|
40521
40417
|
event: "session_configured",
|
|
40522
40418
|
sessionId: command.sessionId
|
|
40523
40419
|
});
|
|
40524
|
-
publisher.recordRuntime(
|
|
40525
|
-
|
|
40526
|
-
|
|
40527
|
-
|
|
40528
|
-
|
|
40529
|
-
|
|
40530
|
-
sessionId: command.sessionId
|
|
40531
|
-
})
|
|
40532
|
-
);
|
|
40420
|
+
publisher.recordRuntime(command.sessionId, {
|
|
40421
|
+
configOptions,
|
|
40422
|
+
kind: "session.config.updated",
|
|
40423
|
+
requestId: command.requestId,
|
|
40424
|
+
sessionId: command.sessionId
|
|
40425
|
+
});
|
|
40533
40426
|
}
|
|
40534
40427
|
const event = {
|
|
40535
40428
|
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
@@ -40548,17 +40441,14 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
|
|
|
40548
40441
|
runtimeTimings: metrics.snapshot()
|
|
40549
40442
|
};
|
|
40550
40443
|
metrics.measureSync("readiness-commit", () => {
|
|
40551
|
-
publisher.recordRuntime(command.sessionId,
|
|
40444
|
+
publisher.recordRuntime(command.sessionId, event);
|
|
40552
40445
|
});
|
|
40553
40446
|
return event;
|
|
40554
40447
|
});
|
|
40555
|
-
send(
|
|
40556
|
-
|
|
40557
|
-
|
|
40558
|
-
|
|
40559
|
-
runtimeTimings: metrics.snapshot()
|
|
40560
|
-
})
|
|
40561
|
-
);
|
|
40448
|
+
send(socket, {
|
|
40449
|
+
...readyEvent,
|
|
40450
|
+
runtimeTimings: metrics.snapshot()
|
|
40451
|
+
});
|
|
40562
40452
|
} catch (error62) {
|
|
40563
40453
|
audit.record({
|
|
40564
40454
|
commandId: command.requestId,
|
|
@@ -40598,15 +40488,12 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
40598
40488
|
event: "session_configured",
|
|
40599
40489
|
sessionId: command.sessionId
|
|
40600
40490
|
});
|
|
40601
|
-
publisher.recordRuntime(
|
|
40602
|
-
|
|
40603
|
-
|
|
40604
|
-
|
|
40605
|
-
|
|
40606
|
-
|
|
40607
|
-
sessionId: command.sessionId
|
|
40608
|
-
})
|
|
40609
|
-
);
|
|
40491
|
+
publisher.recordRuntime(command.sessionId, {
|
|
40492
|
+
configOptions,
|
|
40493
|
+
kind: "session.config.updated",
|
|
40494
|
+
requestId: command.requestId,
|
|
40495
|
+
sessionId: command.sessionId
|
|
40496
|
+
});
|
|
40610
40497
|
} catch (error62) {
|
|
40611
40498
|
if (signal.aborted) {
|
|
40612
40499
|
signal.throwIfAborted();
|
|
@@ -40616,20 +40503,20 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
40616
40503
|
}
|
|
40617
40504
|
async function executePrompt(outbox, publisher, command, config2, directories, audit, sessions, attemptId, activateAttempt, timer, signal) {
|
|
40618
40505
|
const activities = new CoalescingDaemonActivityPublisher(timer, (activity) => {
|
|
40619
|
-
publisher.recordAttempt(command.sessionId,
|
|
40506
|
+
publisher.recordAttempt(command.sessionId, daemonActivity(command, activity), attemptId);
|
|
40620
40507
|
});
|
|
40621
40508
|
const text3 = new CoalescingTextPublisher(
|
|
40622
40509
|
timer,
|
|
40623
40510
|
(messageId, delta) => {
|
|
40624
40511
|
publisher.recordAttempt(
|
|
40625
40512
|
command.sessionId,
|
|
40626
|
-
|
|
40513
|
+
{
|
|
40627
40514
|
commandId: command.commandId,
|
|
40628
40515
|
kind: AGENT_MESSAGE_DELTA_KIND,
|
|
40629
40516
|
messageId,
|
|
40630
40517
|
sessionId: command.sessionId,
|
|
40631
40518
|
text: delta
|
|
40632
|
-
}
|
|
40519
|
+
},
|
|
40633
40520
|
attemptId
|
|
40634
40521
|
);
|
|
40635
40522
|
},
|
|
@@ -40688,12 +40575,12 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40688
40575
|
outbox.transitionExecution(command.commandId, "running");
|
|
40689
40576
|
publisher.recordAttempt(
|
|
40690
40577
|
command.sessionId,
|
|
40691
|
-
|
|
40578
|
+
{
|
|
40692
40579
|
commandId: command.commandId,
|
|
40693
40580
|
kind: SESSION_STARTED_KIND,
|
|
40694
40581
|
attemptId,
|
|
40695
40582
|
sessionId: command.sessionId
|
|
40696
|
-
}
|
|
40583
|
+
},
|
|
40697
40584
|
attemptId
|
|
40698
40585
|
);
|
|
40699
40586
|
activateAttempt();
|
|
@@ -40738,12 +40625,12 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40738
40625
|
activities.flush();
|
|
40739
40626
|
publisher.recordAttempt(
|
|
40740
40627
|
command.sessionId,
|
|
40741
|
-
|
|
40628
|
+
{
|
|
40742
40629
|
commandId: command.commandId,
|
|
40743
40630
|
kind: SESSION_COMPLETED_KIND,
|
|
40744
40631
|
sessionId: command.sessionId,
|
|
40745
40632
|
stopReason
|
|
40746
|
-
}
|
|
40633
|
+
},
|
|
40747
40634
|
attemptId
|
|
40748
40635
|
);
|
|
40749
40636
|
outbox.transitionExecution(command.commandId, stopReason === "cancelled" ? "cancelled" : "succeeded");
|
|
@@ -41167,9 +41054,10 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41167
41054
|
}
|
|
41168
41055
|
};
|
|
41169
41056
|
const processDeliveredPayload = async (delivery) => {
|
|
41170
|
-
const
|
|
41057
|
+
const message = decodeServiceToDaemonMessage(delivery.payload);
|
|
41058
|
+
const kind = message.kind;
|
|
41171
41059
|
if (kind === SESSION_CANCEL_KIND) {
|
|
41172
|
-
const cancellation =
|
|
41060
|
+
const cancellation = message;
|
|
41173
41061
|
if (cancellation.sessionId !== delivery.sessionId) {
|
|
41174
41062
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
41175
41063
|
}
|
|
@@ -41186,7 +41074,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41186
41074
|
return;
|
|
41187
41075
|
}
|
|
41188
41076
|
if (kind === SESSION_CONFIGURE_KIND) {
|
|
41189
|
-
const command =
|
|
41077
|
+
const command = message;
|
|
41190
41078
|
if (command.sessionId !== delivery.sessionId) {
|
|
41191
41079
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
41192
41080
|
}
|
|
@@ -41203,7 +41091,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41203
41091
|
return;
|
|
41204
41092
|
}
|
|
41205
41093
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
41206
|
-
const command =
|
|
41094
|
+
const command = message;
|
|
41207
41095
|
if (command.sessionId !== delivery.sessionId) {
|
|
41208
41096
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
41209
41097
|
}
|
|
@@ -41220,7 +41108,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41220
41108
|
return;
|
|
41221
41109
|
}
|
|
41222
41110
|
if (kind === SESSION_ELICITATION_RESPOND_KIND) {
|
|
41223
|
-
const command =
|
|
41111
|
+
const command = message;
|
|
41224
41112
|
if (command.sessionId !== delivery.sessionId) {
|
|
41225
41113
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
41226
41114
|
}
|
|
@@ -41237,7 +41125,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41237
41125
|
return;
|
|
41238
41126
|
}
|
|
41239
41127
|
if (kind === SESSION_PROMPT_KIND) {
|
|
41240
|
-
const command =
|
|
41128
|
+
const command = message;
|
|
41241
41129
|
await processDeliveredPrompt(
|
|
41242
41130
|
delivery,
|
|
41243
41131
|
command,
|
|
@@ -41281,18 +41169,19 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41281
41169
|
}).finally(() => processingDeliveryIds.delete(delivery.deliveryId));
|
|
41282
41170
|
};
|
|
41283
41171
|
const receiveRuntimeDelivery = (delivery) => {
|
|
41284
|
-
const
|
|
41172
|
+
const payload = decodeServiceToDaemonMessage(delivery.payload);
|
|
41173
|
+
const payloadKind = payload.kind;
|
|
41285
41174
|
let payloadSessionId = "";
|
|
41286
41175
|
if (payloadKind === SESSION_CANCEL_KIND) {
|
|
41287
|
-
payloadSessionId =
|
|
41176
|
+
payloadSessionId = payload.sessionId;
|
|
41288
41177
|
} else if (payloadKind === SESSION_CONFIGURE_KIND) {
|
|
41289
|
-
payloadSessionId =
|
|
41178
|
+
payloadSessionId = payload.sessionId;
|
|
41290
41179
|
} else if (payloadKind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
41291
|
-
payloadSessionId =
|
|
41180
|
+
payloadSessionId = payload.sessionId;
|
|
41292
41181
|
} else if (payloadKind === SESSION_ELICITATION_RESPOND_KIND) {
|
|
41293
|
-
payloadSessionId =
|
|
41182
|
+
payloadSessionId = payload.sessionId;
|
|
41294
41183
|
} else if (payloadKind === SESSION_PROMPT_KIND) {
|
|
41295
|
-
payloadSessionId =
|
|
41184
|
+
payloadSessionId = payload.sessionId;
|
|
41296
41185
|
} else {
|
|
41297
41186
|
throw new Error("Runtime delivery contains an unsupported protocol message");
|
|
41298
41187
|
}
|
|
@@ -41300,14 +41189,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41300
41189
|
throw new Error("Runtime delivery Session identity does not match its payload");
|
|
41301
41190
|
}
|
|
41302
41191
|
const stored = outbox.claimRuntimeDelivery(delivery);
|
|
41303
|
-
send(
|
|
41304
|
-
|
|
41305
|
-
|
|
41306
|
-
|
|
41307
|
-
|
|
41308
|
-
sessionId: delivery.sessionId
|
|
41309
|
-
})
|
|
41310
|
-
);
|
|
41192
|
+
send(socket, {
|
|
41193
|
+
deliveryId: delivery.deliveryId,
|
|
41194
|
+
kind: RUNTIME_DELIVERY_RECEIVED_KIND,
|
|
41195
|
+
sessionId: delivery.sessionId
|
|
41196
|
+
});
|
|
41311
41197
|
processRuntimeDelivery(delivery, stored.state);
|
|
41312
41198
|
};
|
|
41313
41199
|
const resumeRuntimeDeliveries = () => {
|
|
@@ -41319,14 +41205,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41319
41205
|
sessionId: stored.sessionId
|
|
41320
41206
|
};
|
|
41321
41207
|
if (stored.state !== "relay_committed") {
|
|
41322
|
-
send(
|
|
41323
|
-
|
|
41324
|
-
|
|
41325
|
-
|
|
41326
|
-
|
|
41327
|
-
sessionId: stored.sessionId
|
|
41328
|
-
})
|
|
41329
|
-
);
|
|
41208
|
+
send(socket, {
|
|
41209
|
+
deliveryId: stored.deliveryId,
|
|
41210
|
+
kind: RUNTIME_DELIVERY_RECEIVED_KIND,
|
|
41211
|
+
sessionId: stored.sessionId
|
|
41212
|
+
});
|
|
41330
41213
|
}
|
|
41331
41214
|
processRuntimeDelivery(delivery, stored.state);
|
|
41332
41215
|
}
|
|
@@ -41385,28 +41268,29 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41385
41268
|
return;
|
|
41386
41269
|
}
|
|
41387
41270
|
try {
|
|
41388
|
-
const
|
|
41271
|
+
const message = decodeServiceToDaemonMessage(encoded);
|
|
41272
|
+
const kind = message.kind;
|
|
41389
41273
|
if (kind === RUNTIME_DELIVERY_COMMITTED_KIND) {
|
|
41390
|
-
const committed =
|
|
41274
|
+
const committed = message;
|
|
41391
41275
|
if (!outbox.markRuntimeDeliveryCommitted(committed.deliveryId, committed.sessionId)) {
|
|
41392
41276
|
console.warn("Mobius daemon ignored confirmation for an unknown Runtime delivery");
|
|
41393
41277
|
}
|
|
41394
41278
|
return;
|
|
41395
41279
|
}
|
|
41396
41280
|
if (kind === RUNTIME_DELIVERY_KIND) {
|
|
41397
|
-
receiveRuntimeDelivery(
|
|
41281
|
+
receiveRuntimeDelivery(message);
|
|
41398
41282
|
return;
|
|
41399
41283
|
}
|
|
41400
41284
|
if (kind === SESSION_EVENT_ACK_KIND) {
|
|
41401
|
-
publisher.acknowledge(
|
|
41285
|
+
publisher.acknowledge(message);
|
|
41402
41286
|
return;
|
|
41403
41287
|
}
|
|
41404
41288
|
if (kind === SESSION_EVENT_DEFERRED_KIND) {
|
|
41405
|
-
publisher.defer(
|
|
41289
|
+
publisher.defer(message);
|
|
41406
41290
|
return;
|
|
41407
41291
|
}
|
|
41408
41292
|
if (kind === SESSION_EVENT_REJECTED_KIND) {
|
|
41409
|
-
const rejection =
|
|
41293
|
+
const rejection = message;
|
|
41410
41294
|
if (publisher.quarantine(rejection)) {
|
|
41411
41295
|
audit.record({
|
|
41412
41296
|
commandId: rejection.eventId,
|
|
@@ -41420,7 +41304,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41420
41304
|
return;
|
|
41421
41305
|
}
|
|
41422
41306
|
if (kind === NATIVE_SESSION_CANCEL_KIND) {
|
|
41423
|
-
const command2 =
|
|
41307
|
+
const command2 = message;
|
|
41424
41308
|
const pending = nativeRequests.get(command2.requestId);
|
|
41425
41309
|
if (pending?.sessionId === command2.sessionId) {
|
|
41426
41310
|
pending.controller.abort(
|
|
@@ -41434,35 +41318,29 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41434
41318
|
return;
|
|
41435
41319
|
}
|
|
41436
41320
|
if (kind === AGENT_SETTINGS_DISCOVER_KIND) {
|
|
41437
|
-
const command2 =
|
|
41321
|
+
const command2 = message;
|
|
41438
41322
|
const existing = [...agentSettingsDiscoveries.values()].find(
|
|
41439
41323
|
(request) => request.agentId === command2.agentId && !request.controller.signal.aborted
|
|
41440
41324
|
);
|
|
41441
41325
|
if (agentSettingsDiscoveries.has(command2.requestId) || existing !== void 0) {
|
|
41442
41326
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41443
|
-
send(
|
|
41444
|
-
|
|
41445
|
-
|
|
41446
|
-
|
|
41447
|
-
|
|
41448
|
-
|
|
41449
|
-
requestId: command2.requestId
|
|
41450
|
-
})
|
|
41451
|
-
);
|
|
41327
|
+
send(socket, {
|
|
41328
|
+
code: "agent_settings_discovery_busy",
|
|
41329
|
+
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
41330
|
+
message: "Another settings discovery is already running for this Agent",
|
|
41331
|
+
requestId: command2.requestId
|
|
41332
|
+
});
|
|
41452
41333
|
}
|
|
41453
41334
|
return;
|
|
41454
41335
|
}
|
|
41455
41336
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
41456
41337
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41457
|
-
send(
|
|
41458
|
-
|
|
41459
|
-
|
|
41460
|
-
|
|
41461
|
-
|
|
41462
|
-
|
|
41463
|
-
requestId: command2.requestId
|
|
41464
|
-
})
|
|
41465
|
-
);
|
|
41338
|
+
send(socket, {
|
|
41339
|
+
code: "agent_settings_discovery_busy",
|
|
41340
|
+
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
41341
|
+
message: "Too many Agent settings discoveries are running",
|
|
41342
|
+
requestId: command2.requestId
|
|
41343
|
+
});
|
|
41466
41344
|
}
|
|
41467
41345
|
return;
|
|
41468
41346
|
}
|
|
@@ -41494,7 +41372,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41494
41372
|
sessionId: `agent-settings:${command2.agentId}`
|
|
41495
41373
|
});
|
|
41496
41374
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41497
|
-
send(socket,
|
|
41375
|
+
send(socket, result);
|
|
41498
41376
|
}
|
|
41499
41377
|
} catch (error62) {
|
|
41500
41378
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -41509,15 +41387,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41509
41387
|
sessionId: `agent-settings:${command2.agentId}`
|
|
41510
41388
|
});
|
|
41511
41389
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41512
|
-
send(
|
|
41513
|
-
|
|
41514
|
-
|
|
41515
|
-
|
|
41516
|
-
|
|
41517
|
-
|
|
41518
|
-
requestId: command2.requestId
|
|
41519
|
-
})
|
|
41520
|
-
);
|
|
41390
|
+
send(socket, {
|
|
41391
|
+
code: operationErrorCode(failure2),
|
|
41392
|
+
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
41393
|
+
message: operationErrorMessage(failure2),
|
|
41394
|
+
requestId: command2.requestId
|
|
41395
|
+
});
|
|
41521
41396
|
}
|
|
41522
41397
|
} finally {
|
|
41523
41398
|
timeout.cancel();
|
|
@@ -41532,18 +41407,15 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41532
41407
|
return;
|
|
41533
41408
|
}
|
|
41534
41409
|
if (kind === AGENT_CATALOG_REFRESH_KIND) {
|
|
41535
|
-
const command2 =
|
|
41410
|
+
const command2 = message;
|
|
41536
41411
|
if (agentCatalogRefreshes.has(command2.requestId) || agentCatalogRefreshes.size > 0) {
|
|
41537
41412
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41538
|
-
send(
|
|
41539
|
-
|
|
41540
|
-
|
|
41541
|
-
|
|
41542
|
-
|
|
41543
|
-
|
|
41544
|
-
requestId: command2.requestId
|
|
41545
|
-
})
|
|
41546
|
-
);
|
|
41413
|
+
send(socket, {
|
|
41414
|
+
code: "agent_catalog_refresh_busy",
|
|
41415
|
+
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
41416
|
+
message: "Another local Agent catalog refresh is already running",
|
|
41417
|
+
requestId: command2.requestId
|
|
41418
|
+
});
|
|
41547
41419
|
}
|
|
41548
41420
|
return;
|
|
41549
41421
|
}
|
|
@@ -41568,13 +41440,10 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41568
41440
|
sessionId: "agent-catalog"
|
|
41569
41441
|
});
|
|
41570
41442
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41571
|
-
send(
|
|
41572
|
-
|
|
41573
|
-
|
|
41574
|
-
|
|
41575
|
-
requestId: command2.requestId
|
|
41576
|
-
})
|
|
41577
|
-
);
|
|
41443
|
+
send(socket, {
|
|
41444
|
+
kind: AGENT_CATALOG_REFRESHED_KIND,
|
|
41445
|
+
requestId: command2.requestId
|
|
41446
|
+
});
|
|
41578
41447
|
}
|
|
41579
41448
|
} catch (error62) {
|
|
41580
41449
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -41589,15 +41458,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41589
41458
|
sessionId: "agent-catalog"
|
|
41590
41459
|
});
|
|
41591
41460
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41592
|
-
send(
|
|
41593
|
-
|
|
41594
|
-
|
|
41595
|
-
|
|
41596
|
-
|
|
41597
|
-
|
|
41598
|
-
requestId: command2.requestId
|
|
41599
|
-
})
|
|
41600
|
-
);
|
|
41461
|
+
send(socket, {
|
|
41462
|
+
code: operationErrorCode(failure2),
|
|
41463
|
+
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
41464
|
+
message: operationErrorMessage(failure2),
|
|
41465
|
+
requestId: command2.requestId
|
|
41466
|
+
});
|
|
41601
41467
|
}
|
|
41602
41468
|
} finally {
|
|
41603
41469
|
timeout.cancel();
|
|
@@ -41608,7 +41474,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41608
41474
|
return;
|
|
41609
41475
|
}
|
|
41610
41476
|
if (kind === NATIVE_SESSION_REQUEST_KIND) {
|
|
41611
|
-
const command2 =
|
|
41477
|
+
const command2 = message;
|
|
41612
41478
|
const previous2 = [...nativeRequests.values()].filter(
|
|
41613
41479
|
(request) => request.agentId === command2.agentId
|
|
41614
41480
|
);
|
|
@@ -41661,7 +41527,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41661
41527
|
operationSignal.throwIfAborted();
|
|
41662
41528
|
const result = await nativeSessions.execute(command2, operationSignal);
|
|
41663
41529
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41664
|
-
send(socket,
|
|
41530
|
+
send(socket, result);
|
|
41665
41531
|
}
|
|
41666
41532
|
} catch (error62) {
|
|
41667
41533
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -41690,7 +41556,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41690
41556
|
return;
|
|
41691
41557
|
}
|
|
41692
41558
|
if (kind === NATIVE_SESSION_TURN_FORK_KIND) {
|
|
41693
|
-
const command2 =
|
|
41559
|
+
const command2 = message;
|
|
41694
41560
|
const previous2 = [...nativeRequests.values()].filter(
|
|
41695
41561
|
(request) => request.agentId === command2.agentId
|
|
41696
41562
|
);
|
|
@@ -41741,7 +41607,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41741
41607
|
operationSignal.throwIfAborted();
|
|
41742
41608
|
const result = await nativeSessions.executeTurnFork(command2, operationSignal);
|
|
41743
41609
|
if (socket.readyState === WebSocket2.OPEN) {
|
|
41744
|
-
send(socket,
|
|
41610
|
+
send(socket, result);
|
|
41745
41611
|
}
|
|
41746
41612
|
} catch (error62) {
|
|
41747
41613
|
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
@@ -41770,39 +41636,35 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41770
41636
|
return;
|
|
41771
41637
|
}
|
|
41772
41638
|
if (kind === RUNTIME_LIVENESS_READY_KIND) {
|
|
41773
|
-
decodeRuntimeLivenessReadyEvent(encoded);
|
|
41774
41639
|
connectionLiveness.start();
|
|
41775
41640
|
return;
|
|
41776
41641
|
}
|
|
41777
41642
|
if (kind === RUNTIME_HEARTBEAT_ACK_KIND) {
|
|
41778
|
-
connectionLiveness.acknowledge(
|
|
41643
|
+
connectionLiveness.acknowledge(message);
|
|
41779
41644
|
return;
|
|
41780
41645
|
}
|
|
41781
41646
|
if (kind === FILE_READ_KIND) {
|
|
41782
|
-
const command2 =
|
|
41647
|
+
const command2 = message;
|
|
41783
41648
|
void streamLocalFile(
|
|
41784
41649
|
command2,
|
|
41785
|
-
(
|
|
41650
|
+
(message2) => send(socket, message2),
|
|
41786
41651
|
connectionController.signal
|
|
41787
41652
|
).catch((error62) => {
|
|
41788
41653
|
if (socket.readyState !== WebSocket2.OPEN || connectionController.signal.aborted) {
|
|
41789
41654
|
return;
|
|
41790
41655
|
}
|
|
41791
|
-
send(
|
|
41792
|
-
|
|
41793
|
-
|
|
41794
|
-
|
|
41795
|
-
|
|
41796
|
-
|
|
41797
|
-
|
|
41798
|
-
sessionId: command2.sessionId
|
|
41799
|
-
})
|
|
41800
|
-
);
|
|
41656
|
+
send(socket, {
|
|
41657
|
+
code: "file_unavailable",
|
|
41658
|
+
kind: FILE_FAILED_KIND,
|
|
41659
|
+
message: error62 instanceof Error ? error62.message : "The local file is unavailable",
|
|
41660
|
+
requestId: command2.requestId,
|
|
41661
|
+
sessionId: command2.sessionId
|
|
41662
|
+
});
|
|
41801
41663
|
});
|
|
41802
41664
|
return;
|
|
41803
41665
|
}
|
|
41804
41666
|
if (kind === SESSION_CANCEL_KIND) {
|
|
41805
|
-
const cancellation =
|
|
41667
|
+
const cancellation = message;
|
|
41806
41668
|
const turn2 = activeTurns.get(cancellation.commandId);
|
|
41807
41669
|
if (turn2 === void 0 || !turn2.matches(cancellation)) {
|
|
41808
41670
|
console.warn("Mobius daemon ignored cancellation for an inactive turn");
|
|
@@ -41822,12 +41684,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41822
41684
|
return;
|
|
41823
41685
|
}
|
|
41824
41686
|
if (kind === WORKSPACE_LIST_KIND) {
|
|
41825
|
-
const command2 =
|
|
41687
|
+
const command2 = message;
|
|
41826
41688
|
void executeWorkspaceList(socket, command2, directories, audit, connectionController.signal);
|
|
41827
41689
|
return;
|
|
41828
41690
|
}
|
|
41829
41691
|
if (kind === SESSION_PREPARE_KIND) {
|
|
41830
|
-
const command2 =
|
|
41692
|
+
const command2 = message;
|
|
41831
41693
|
void executeSessionPrepare(
|
|
41832
41694
|
publisher,
|
|
41833
41695
|
socket,
|
|
@@ -41841,7 +41703,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41841
41703
|
return;
|
|
41842
41704
|
}
|
|
41843
41705
|
if (kind === SESSION_CONFIGURE_KIND) {
|
|
41844
|
-
const command2 =
|
|
41706
|
+
const command2 = message;
|
|
41845
41707
|
void executeSessionConfigure(
|
|
41846
41708
|
publisher,
|
|
41847
41709
|
socket,
|
|
@@ -41855,7 +41717,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41855
41717
|
return;
|
|
41856
41718
|
}
|
|
41857
41719
|
if (kind === SESSION_PERMISSION_RESPOND_KIND) {
|
|
41858
|
-
const command2 =
|
|
41720
|
+
const command2 = message;
|
|
41859
41721
|
void sessions.respondPermission(command2).then(() => {
|
|
41860
41722
|
audit.record({
|
|
41861
41723
|
commandId: command2.interactionId,
|
|
@@ -41868,7 +41730,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41868
41730
|
return;
|
|
41869
41731
|
}
|
|
41870
41732
|
if (kind === SESSION_ELICITATION_RESPOND_KIND) {
|
|
41871
|
-
const command2 =
|
|
41733
|
+
const command2 = message;
|
|
41872
41734
|
void sessions.respondElicitation(command2).then(() => {
|
|
41873
41735
|
audit.record({
|
|
41874
41736
|
commandId: command2.interactionId,
|
|
@@ -41881,14 +41743,14 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41881
41743
|
return;
|
|
41882
41744
|
}
|
|
41883
41745
|
if (kind === AGENT_INSTALL_REQUEST_KIND) {
|
|
41884
|
-
const command2 =
|
|
41746
|
+
const command2 = message;
|
|
41885
41747
|
void installations.request(command2, signal).catch((error62) => {
|
|
41886
41748
|
console.error("Mobius Agent integration installation failed", error62);
|
|
41887
41749
|
});
|
|
41888
41750
|
return;
|
|
41889
41751
|
}
|
|
41890
41752
|
if (kind === AGENT_INSTALL_CANCEL_KIND) {
|
|
41891
|
-
const command2 =
|
|
41753
|
+
const command2 = message;
|
|
41892
41754
|
void installations.cancel(command2.requestId).catch((error62) => {
|
|
41893
41755
|
reportOperationFailure(socket, command2.requestId, "", error62);
|
|
41894
41756
|
});
|
|
@@ -41897,7 +41759,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41897
41759
|
if (kind !== SESSION_PROMPT_KIND) {
|
|
41898
41760
|
throw new Error("Unsupported protocol message");
|
|
41899
41761
|
}
|
|
41900
|
-
const command =
|
|
41762
|
+
const command = message;
|
|
41901
41763
|
if (activeTurns.has(command.commandId)) {
|
|
41902
41764
|
return;
|
|
41903
41765
|
}
|
|
@@ -42018,15 +41880,15 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
42018
41880
|
const publisher = new DaemonSessionEventPublisher(outbox, timer);
|
|
42019
41881
|
const activeTurns = /* @__PURE__ */ new Map();
|
|
42020
41882
|
const activeAttemptIds = /* @__PURE__ */ new Map();
|
|
42021
|
-
const recordSessionEvent = (sessionId,
|
|
41883
|
+
const recordSessionEvent = (sessionId, event) => {
|
|
42022
41884
|
const attemptId = activeAttemptIds.get(sessionId);
|
|
42023
41885
|
if (attemptId === void 0) {
|
|
42024
|
-
publisher.recordRuntime(sessionId,
|
|
41886
|
+
publisher.recordRuntime(sessionId, event);
|
|
42025
41887
|
return;
|
|
42026
41888
|
}
|
|
42027
|
-
publisher.recordAttempt(sessionId,
|
|
41889
|
+
publisher.recordAttempt(sessionId, event, attemptId);
|
|
42028
41890
|
};
|
|
42029
|
-
const sessions = new AcpSessionManager(new DaemonAcpObserver(
|
|
41891
|
+
const sessions = new AcpSessionManager(new DaemonAcpObserver(recordSessionEvent), sessionStore);
|
|
42030
41892
|
const directories = new WorkspaceDirectoryService(config2.bindingId, config2.defaultWorkspace);
|
|
42031
41893
|
const installationObserver = new DaemonInstallationObserver();
|
|
42032
41894
|
const diagnostics = new RelayConnectionDiagnostics(audit, config2.channelId, config2.relayUrl);
|
|
@@ -42161,9 +42023,9 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
42161
42023
|
}
|
|
42162
42024
|
|
|
42163
42025
|
// src/runtime.ts
|
|
42164
|
-
import { mkdir as
|
|
42026
|
+
import { mkdir as mkdir6, realpath as realpath10, stat as stat9 } from "node:fs/promises";
|
|
42165
42027
|
import { dirname as dirname8, join as join17, resolve as resolve7 } from "node:path";
|
|
42166
|
-
var
|
|
42028
|
+
var IDENTIFIER_PATTERN7 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
42167
42029
|
var RUNTIME_CREDENTIAL_PATTERN2 = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
42168
42030
|
var MobiusRuntimeConfigurationError = class extends Error {
|
|
42169
42031
|
code = "runtime_configuration_invalid";
|
|
@@ -42215,7 +42077,7 @@ function relayUrlFromConnection(connection) {
|
|
|
42215
42077
|
}
|
|
42216
42078
|
function loadMobiusRuntimeConnection(environment = process.env) {
|
|
42217
42079
|
const channelId = requiredEnvironmentValue(environment, "MOBIUS_CHANNEL_ID");
|
|
42218
|
-
if (!
|
|
42080
|
+
if (!IDENTIFIER_PATTERN7.test(channelId)) {
|
|
42219
42081
|
throw new MobiusRuntimeConfigurationError("MOBIUS_CHANNEL_ID is invalid");
|
|
42220
42082
|
}
|
|
42221
42083
|
return Object.freeze({
|
|
@@ -42229,7 +42091,7 @@ function loadMobiusRuntimeConnection(environment = process.env) {
|
|
|
42229
42091
|
async function resolveWorkspace(path2) {
|
|
42230
42092
|
const requested = resolve7(path2);
|
|
42231
42093
|
try {
|
|
42232
|
-
await
|
|
42094
|
+
await mkdir6(requested, { recursive: true, mode: 448 });
|
|
42233
42095
|
const resolved = await realpath10(requested);
|
|
42234
42096
|
const metadata = await stat9(resolved);
|
|
42235
42097
|
if (!metadata.isDirectory()) {
|
|
@@ -42249,7 +42111,7 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
|
|
|
42249
42111
|
const relayUrl = relayUrlFromConnection(connection);
|
|
42250
42112
|
const defaultWorkspace = await resolveWorkspace(connection.defaultWorkspace);
|
|
42251
42113
|
const auditDatabasePath = resolve7(connection.auditDatabasePath);
|
|
42252
|
-
await
|
|
42114
|
+
await mkdir6(dirname8(auditDatabasePath), { recursive: true, mode: 448 });
|
|
42253
42115
|
const inventory = await discoverLocalAgentInventory({
|
|
42254
42116
|
defaultWorkspace,
|
|
42255
42117
|
environment: localContext.environment,
|