@moxt-ai/mobius 0.0.302 → 0.0.303
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/catalog.d.ts +2 -1
- package/dist/agent/catalog.d.ts.map +1 -1
- package/dist/agent/catalog.js +18 -4
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/discovery/agent-discovery.d.ts +9 -0
- package/dist/agent/discovery/agent-discovery.d.ts.map +1 -1
- package/dist/agent/discovery/agent-discovery.js +10 -0
- package/dist/agent/discovery/agent-discovery.js.map +1 -1
- package/dist/agent/discovery/discover-local-agents.d.ts +1 -0
- package/dist/agent/discovery/discover-local-agents.d.ts.map +1 -1
- package/dist/agent/discovery/discover-local-agents.js +1 -0
- package/dist/agent/discovery/discover-local-agents.js.map +1 -1
- package/dist/cli.js +303 -75
- package/dist/cli.js.map +4 -4
- package/dist/daemon/pairing/pair-local-machine.d.ts.map +1 -1
- package/dist/daemon/pairing/pair-local-machine.js +5 -1
- package/dist/daemon/pairing/pair-local-machine.js.map +1 -1
- package/dist/runtime/catalog/handle-agent-catalog-discovery.d.ts +29 -0
- package/dist/runtime/catalog/handle-agent-catalog-discovery.d.ts.map +1 -0
- package/dist/runtime/catalog/handle-agent-catalog-discovery.js +88 -0
- package/dist/runtime/catalog/handle-agent-catalog-discovery.js.map +1 -0
- package/dist/runtime/catalog/resolve-catalog-agent.d.ts +2 -1
- package/dist/runtime/catalog/resolve-catalog-agent.d.ts.map +1 -1
- package/dist/runtime/catalog/resolve-catalog-agent.js +12 -20
- package/dist/runtime/catalog/resolve-catalog-agent.js.map +1 -1
- package/dist/runtime/command/registry/agent-catalog.d.ts +4 -0
- package/dist/runtime/command/registry/agent-catalog.d.ts.map +1 -0
- package/dist/runtime/command/registry/agent-catalog.js +29 -0
- package/dist/runtime/command/registry/agent-catalog.js.map +1 -0
- package/dist/runtime/command/registry/index.d.ts.map +1 -1
- package/dist/runtime/command/registry/index.js +2 -0
- package/dist/runtime/command/registry/index.js.map +1 -1
- package/dist/runtime/config.d.ts +6 -1
- package/dist/runtime/config.d.ts.map +1 -1
- package/dist/runtime/config.js +2 -1
- package/dist/runtime/config.js.map +1 -1
- package/dist/runtime/engine.d.ts.map +1 -1
- package/dist/runtime/engine.js +1 -1
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime.js +260 -67
- package/dist/runtime.js.map +4 -4
- package/dist/util/serial-task-queue.d.ts +6 -0
- package/dist/util/serial-task-queue.d.ts.map +1 -0
- package/dist/util/serial-task-queue.js +14 -0
- package/dist/util/serial-task-queue.js.map +1 -0
- package/package.json +2 -2
package/dist/runtime.js
CHANGED
|
@@ -21002,6 +21002,37 @@ var runtimeUpgradeResultSchema = external_exports.strictObject({
|
|
|
21002
21002
|
var decodeRuntimeUpgradeResult = (raw) => runtimeUpgradeResultSchema.parse(JSON.parse(raw));
|
|
21003
21003
|
var encodeRuntimeUpgradeResult = (value) => JSON.stringify(runtimeUpgradeResultSchema.parse(value));
|
|
21004
21004
|
|
|
21005
|
+
// ../mobius-sdk/src/protocol/session/agent/catalog.ts
|
|
21006
|
+
var AGENT_CATALOG_DISCOVER_KIND = "agent.catalog.discover";
|
|
21007
|
+
var AGENT_CATALOG_DISCOVERED_KIND = "agent.catalog.discovered";
|
|
21008
|
+
var AGENT_CATALOG_DISCOVERY_FAILED_KIND = "agent.catalog.discovery.failed";
|
|
21009
|
+
var catalogedAgentSchema = external_exports.object({
|
|
21010
|
+
agentVersion: external_exports.string().min(1).max(128),
|
|
21011
|
+
id: identifierStringSchema,
|
|
21012
|
+
label: external_exports.string().min(1).max(255)
|
|
21013
|
+
}).readonly();
|
|
21014
|
+
var agentCatalogDiscoverCommandSchema = external_exports.object({
|
|
21015
|
+
kind: external_exports.literal(AGENT_CATALOG_DISCOVER_KIND),
|
|
21016
|
+
requestId: identifierStringSchema
|
|
21017
|
+
}).readonly();
|
|
21018
|
+
var agentCatalogDiscoveredEventSchema = external_exports.object({
|
|
21019
|
+
agents: external_exports.array(catalogedAgentSchema).max(64).readonly(),
|
|
21020
|
+
kind: external_exports.literal(AGENT_CATALOG_DISCOVERED_KIND),
|
|
21021
|
+
requestId: identifierStringSchema
|
|
21022
|
+
}).readonly();
|
|
21023
|
+
var agentCatalogDiscoveryFailedEventSchema = external_exports.object({
|
|
21024
|
+
code: identifierStringSchema,
|
|
21025
|
+
kind: external_exports.literal(AGENT_CATALOG_DISCOVERY_FAILED_KIND),
|
|
21026
|
+
message: external_exports.string().min(1).max(500),
|
|
21027
|
+
requestId: identifierStringSchema
|
|
21028
|
+
}).readonly();
|
|
21029
|
+
var decodeAgentCatalogDiscoverCommand = (encoded) => decodeZodMessage(encoded, agentCatalogDiscoverCommandSchema);
|
|
21030
|
+
var encodeAgentCatalogDiscoverCommand = (message) => encodeZodMessage(message, agentCatalogDiscoverCommandSchema);
|
|
21031
|
+
var decodeAgentCatalogDiscoveredEvent = (encoded) => decodeZodMessage(encoded, agentCatalogDiscoveredEventSchema);
|
|
21032
|
+
var encodeAgentCatalogDiscoveredEvent = (message) => encodeZodMessage(message, agentCatalogDiscoveredEventSchema);
|
|
21033
|
+
var decodeAgentCatalogDiscoveryFailedEvent = (encoded) => decodeZodMessage(encoded, agentCatalogDiscoveryFailedEventSchema);
|
|
21034
|
+
var encodeAgentCatalogDiscoveryFailedEvent = (message) => encodeZodMessage(message, agentCatalogDiscoveryFailedEventSchema);
|
|
21035
|
+
|
|
21005
21036
|
// ../mobius-sdk/src/protocol/session/shared/index.ts
|
|
21006
21037
|
var SHORT_TEXT = external_exports.string().max(500);
|
|
21007
21038
|
var workspaceEntrySchema = external_exports.object({
|
|
@@ -22410,6 +22441,11 @@ var serviceToDaemonSignatures = {
|
|
|
22410
22441
|
encodeAgentSettingsDiscoverCommand,
|
|
22411
22442
|
decodeAgentSettingsDiscoverCommand
|
|
22412
22443
|
),
|
|
22444
|
+
[AGENT_CATALOG_DISCOVER_KIND]: defineMessageSignature(
|
|
22445
|
+
AGENT_CATALOG_DISCOVER_KIND,
|
|
22446
|
+
encodeAgentCatalogDiscoverCommand,
|
|
22447
|
+
decodeAgentCatalogDiscoverCommand
|
|
22448
|
+
),
|
|
22413
22449
|
[FILE_READ_KIND]: defineMessageSignature(FILE_READ_KIND, encodeFileReadCommand, decodeFileReadCommand),
|
|
22414
22450
|
[SESSION_LIST_KIND]: defineMessageSignature(SESSION_LIST_KIND, encodeSessionListCommand, decodeSessionListCommand),
|
|
22415
22451
|
[SESSION_QUERY_KIND]: defineMessageSignature(
|
|
@@ -22559,6 +22595,16 @@ var daemonToServiceSignatures = {
|
|
|
22559
22595
|
encodeAgentSettingsDiscoveryFailedEvent,
|
|
22560
22596
|
decodeAgentSettingsDiscoveryFailedEvent
|
|
22561
22597
|
),
|
|
22598
|
+
[AGENT_CATALOG_DISCOVERED_KIND]: defineMessageSignature(
|
|
22599
|
+
AGENT_CATALOG_DISCOVERED_KIND,
|
|
22600
|
+
encodeAgentCatalogDiscoveredEvent,
|
|
22601
|
+
decodeAgentCatalogDiscoveredEvent
|
|
22602
|
+
),
|
|
22603
|
+
[AGENT_CATALOG_DISCOVERY_FAILED_KIND]: defineMessageSignature(
|
|
22604
|
+
AGENT_CATALOG_DISCOVERY_FAILED_KIND,
|
|
22605
|
+
encodeAgentCatalogDiscoveryFailedEvent,
|
|
22606
|
+
decodeAgentCatalogDiscoveryFailedEvent
|
|
22607
|
+
),
|
|
22562
22608
|
[FILE_BEGIN_KIND]: defineMessageSignature(FILE_BEGIN_KIND, encodeFileBeginEvent, decodeFileBeginEvent),
|
|
22563
22609
|
[FILE_CHUNK_KIND]: defineMessageSignature(FILE_CHUNK_KIND, encodeFileChunkEvent, decodeFileChunkEvent),
|
|
22564
22610
|
[FILE_END_KIND]: defineMessageSignature(FILE_END_KIND, encodeFileEndEvent, decodeFileEndEvent),
|
|
@@ -22641,7 +22687,7 @@ import { fetch as fetch3 } from "undici";
|
|
|
22641
22687
|
// package.json
|
|
22642
22688
|
var package_default = {
|
|
22643
22689
|
name: "@moxt-ai/mobius",
|
|
22644
|
-
version: "0.0.
|
|
22690
|
+
version: "0.0.303",
|
|
22645
22691
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
22646
22692
|
type: "module",
|
|
22647
22693
|
bin: {
|
|
@@ -74125,6 +74171,20 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
74125
74171
|
// src/runtime/config.ts
|
|
74126
74172
|
import { join as join20, resolve as resolve13 } from "node:path";
|
|
74127
74173
|
|
|
74174
|
+
// src/util/serial-task-queue.ts
|
|
74175
|
+
var SerialTaskQueue = class {
|
|
74176
|
+
#tail = Promise.resolve();
|
|
74177
|
+
run = async (task, signal) => {
|
|
74178
|
+
signal.throwIfAborted();
|
|
74179
|
+
const result = this.#tail.then(() => {
|
|
74180
|
+
signal.throwIfAborted();
|
|
74181
|
+
return task(signal);
|
|
74182
|
+
});
|
|
74183
|
+
this.#tail = result.catch(() => void 0);
|
|
74184
|
+
return await result;
|
|
74185
|
+
};
|
|
74186
|
+
};
|
|
74187
|
+
|
|
74128
74188
|
// src/agent/catalog.ts
|
|
74129
74189
|
var LocalAgentCatalogSnapshot = class {
|
|
74130
74190
|
agents;
|
|
@@ -74140,6 +74200,7 @@ var LocalAgentCatalogError = class extends OperationError {
|
|
|
74140
74200
|
};
|
|
74141
74201
|
var LocalAgentCatalog = class {
|
|
74142
74202
|
#snapshot;
|
|
74203
|
+
#updates = new SerialTaskQueue();
|
|
74143
74204
|
constructor(agents) {
|
|
74144
74205
|
this.#snapshot = this.validate(agents);
|
|
74145
74206
|
}
|
|
@@ -74152,10 +74213,20 @@ var LocalAgentCatalog = class {
|
|
|
74152
74213
|
throw new LocalAgentCatalogError();
|
|
74153
74214
|
};
|
|
74154
74215
|
read = () => this.#snapshot;
|
|
74155
|
-
|
|
74156
|
-
|
|
74157
|
-
this.#
|
|
74158
|
-
|
|
74216
|
+
/** Serializes replacements and publication; a failed publication restores only its own prior snapshot. */
|
|
74217
|
+
replaceAndPublish = async (build, publish, signal) => {
|
|
74218
|
+
return await this.#updates.run(async (updateSignal) => {
|
|
74219
|
+
const previous = this.#snapshot;
|
|
74220
|
+
const next = this.validate(build(previous.agents));
|
|
74221
|
+
this.#snapshot = next;
|
|
74222
|
+
try {
|
|
74223
|
+
await publish(updateSignal);
|
|
74224
|
+
} catch (error62) {
|
|
74225
|
+
this.#snapshot = previous;
|
|
74226
|
+
throw error62;
|
|
74227
|
+
}
|
|
74228
|
+
return next;
|
|
74229
|
+
}, signal);
|
|
74159
74230
|
};
|
|
74160
74231
|
validate = (agents) => {
|
|
74161
74232
|
const identifiers = /* @__PURE__ */ new Set();
|
|
@@ -74202,7 +74273,7 @@ var OpaqueRuntimeReconnectTarget = class extends RuntimeReconnectTarget {
|
|
|
74202
74273
|
this.commandArgument = `--connection ${connectionId2}`;
|
|
74203
74274
|
}
|
|
74204
74275
|
};
|
|
74205
|
-
function createRuntimeConfig(connection, agents = [], localContext = new RuntimeLocalContext(readStateDirectory(), process.env), reconnectTarget = null, resolveAgent) {
|
|
74276
|
+
function createRuntimeConfig(connection, agents = [], localContext = new RuntimeLocalContext(readStateDirectory(), process.env), reconnectTarget = null, resolveAgent, rediscoverAgents) {
|
|
74206
74277
|
const runtimeAgents = agents.map((agent) => withRuntimeEnvironment(agent, localContext.environment));
|
|
74207
74278
|
return {
|
|
74208
74279
|
agents: runtimeAgents,
|
|
@@ -74213,7 +74284,8 @@ function createRuntimeConfig(connection, agents = [], localContext = new Runtime
|
|
|
74213
74284
|
localContext,
|
|
74214
74285
|
reconnectTarget,
|
|
74215
74286
|
relayUrl: connection.relayUrl,
|
|
74216
|
-
...resolveAgent === void 0 ? {} : { resolveAgent }
|
|
74287
|
+
...resolveAgent === void 0 ? {} : { resolveAgent },
|
|
74288
|
+
...rediscoverAgents === void 0 ? {} : { rediscoverAgents }
|
|
74217
74289
|
};
|
|
74218
74290
|
}
|
|
74219
74291
|
|
|
@@ -74243,21 +74315,17 @@ function createCatalogAgentResolver(discover, readConfig, publish) {
|
|
|
74243
74315
|
signal.throwIfAborted();
|
|
74244
74316
|
const inventory = await discover(signal);
|
|
74245
74317
|
signal.throwIfAborted();
|
|
74246
|
-
const
|
|
74247
|
-
|
|
74248
|
-
|
|
74249
|
-
|
|
74250
|
-
|
|
74251
|
-
|
|
74252
|
-
|
|
74253
|
-
|
|
74254
|
-
|
|
74255
|
-
|
|
74256
|
-
|
|
74257
|
-
} catch (error62) {
|
|
74258
|
-
config2.catalog.transition(previous.agents);
|
|
74259
|
-
throw error62;
|
|
74260
|
-
}
|
|
74318
|
+
const rediscovered = inventory.readyAgents().filter((ready) => ready.id === agent.id).map((ready) => withRuntimeEnvironment(ready, config2.localContext.environment));
|
|
74319
|
+
await config2.catalog.replaceAndPublish(
|
|
74320
|
+
(current) => {
|
|
74321
|
+
if (!current.some((entry) => entry.id === agent.id)) {
|
|
74322
|
+
throw new Error(`The local Agent ${agent.id} left the catalog before its refresh completed`);
|
|
74323
|
+
}
|
|
74324
|
+
return [...current.filter((entry) => entry.id !== agent.id), ...rediscovered];
|
|
74325
|
+
},
|
|
74326
|
+
(publishSignal) => publish(config2, publishSignal),
|
|
74327
|
+
signal
|
|
74328
|
+
);
|
|
74261
74329
|
return config2.catalog.find(agent.id);
|
|
74262
74330
|
} finally {
|
|
74263
74331
|
swaps.delete(agent.id);
|
|
@@ -75116,7 +75184,12 @@ function buildPairedRuntime(installation, connection, defaultWorkspace, inventor
|
|
|
75116
75184
|
}),
|
|
75117
75185
|
() => config2,
|
|
75118
75186
|
publishAgentCatalog
|
|
75119
|
-
)
|
|
75187
|
+
),
|
|
75188
|
+
(refreshSignal) => discoverLocalAgentInventory({
|
|
75189
|
+
defaultWorkspace,
|
|
75190
|
+
environment: localContext.environment,
|
|
75191
|
+
signal: refreshSignal
|
|
75192
|
+
}).then((inventory2) => inventory2.readyAgents())
|
|
75120
75193
|
);
|
|
75121
75194
|
return {
|
|
75122
75195
|
channelUrl: new URL(`/channels/${encodeURIComponent(connection.channelId)}`, connection.relayOrigin).toString(),
|
|
@@ -88173,11 +88246,151 @@ var RelayConnectionDiagnostics = class {
|
|
|
88173
88246
|
};
|
|
88174
88247
|
|
|
88175
88248
|
// src/runtime/relay/run-relay-connection.ts
|
|
88176
|
-
import { WebSocket as
|
|
88249
|
+
import { WebSocket as WebSocket8 } from "undici";
|
|
88177
88250
|
|
|
88178
|
-
// src/runtime/
|
|
88251
|
+
// src/runtime/catalog/handle-agent-catalog-discovery.ts
|
|
88179
88252
|
import { WebSocket as WebSocket3 } from "undici";
|
|
88180
88253
|
|
|
88254
|
+
// src/runtime/command/transport.ts
|
|
88255
|
+
import { WebSocket as WebSocket2 } from "undici";
|
|
88256
|
+
function send(socket, message) {
|
|
88257
|
+
if (socket.readyState !== WebSocket2.OPEN) {
|
|
88258
|
+
throw new Error("Relay connection is not open");
|
|
88259
|
+
}
|
|
88260
|
+
socket.send(encodeDaemonToServiceMessage(message));
|
|
88261
|
+
}
|
|
88262
|
+
function reportOperationFailure(socket, requestId, sessionId, error62, runtimeTimings = []) {
|
|
88263
|
+
if (socket.readyState !== WebSocket2.OPEN) {
|
|
88264
|
+
return;
|
|
88265
|
+
}
|
|
88266
|
+
send(socket, {
|
|
88267
|
+
code: operationErrorCode(error62),
|
|
88268
|
+
kind: "session.operation.failed",
|
|
88269
|
+
message: operationErrorMessage(error62),
|
|
88270
|
+
requestId,
|
|
88271
|
+
...runtimeTimings.length === 0 ? {} : { runtimeTimings },
|
|
88272
|
+
sessionId
|
|
88273
|
+
});
|
|
88274
|
+
}
|
|
88275
|
+
|
|
88276
|
+
// src/runtime/catalog/handle-agent-catalog-discovery.ts
|
|
88277
|
+
var CATALOG_DISCOVERY_TIMEOUT_MILLISECONDS = 9e4;
|
|
88278
|
+
function discoveredEvent(command, agents) {
|
|
88279
|
+
return {
|
|
88280
|
+
agents: agents.map((agent) => ({
|
|
88281
|
+
agentVersion: agent.agentVersion,
|
|
88282
|
+
id: agent.id,
|
|
88283
|
+
label: agent.label
|
|
88284
|
+
})),
|
|
88285
|
+
kind: "agent.catalog.discovered",
|
|
88286
|
+
requestId: command.requestId
|
|
88287
|
+
};
|
|
88288
|
+
}
|
|
88289
|
+
function createAgentCatalogDiscoveryHandler(dependencies) {
|
|
88290
|
+
const { config: config2, discover, diagnostics, socket, signal, timer } = dependencies;
|
|
88291
|
+
const requestIds = /* @__PURE__ */ new Set();
|
|
88292
|
+
let controller = null;
|
|
88293
|
+
let completion = null;
|
|
88294
|
+
const handle = (command) => {
|
|
88295
|
+
if (requestIds.has(command.requestId) || controller !== null) {
|
|
88296
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
88297
|
+
send(socket, {
|
|
88298
|
+
code: "agent_catalog_discovery_busy",
|
|
88299
|
+
kind: AGENT_CATALOG_DISCOVERY_FAILED_KIND,
|
|
88300
|
+
message: "An Agent catalog discovery is already running",
|
|
88301
|
+
requestId: command.requestId
|
|
88302
|
+
});
|
|
88303
|
+
}
|
|
88304
|
+
return;
|
|
88305
|
+
}
|
|
88306
|
+
controller = new AbortController();
|
|
88307
|
+
requestIds.add(command.requestId);
|
|
88308
|
+
const operationSignal = AbortSignal.any([signal, controller.signal]);
|
|
88309
|
+
const timeout = timer.schedule(
|
|
88310
|
+
() => controller?.abort(new Error("Agent catalog discovery timed out")),
|
|
88311
|
+
CATALOG_DISCOVERY_TIMEOUT_MILLISECONDS
|
|
88312
|
+
);
|
|
88313
|
+
completion = (async () => {
|
|
88314
|
+
try {
|
|
88315
|
+
const readyAgents = await discover(operationSignal);
|
|
88316
|
+
operationSignal.throwIfAborted();
|
|
88317
|
+
const published = await config2.catalog.replaceAndPublish(
|
|
88318
|
+
() => readyAgents.map((agent) => withRuntimeEnvironment(agent, config2.localContext.environment)),
|
|
88319
|
+
(publishSignal) => publishAgentCatalog(config2, publishSignal),
|
|
88320
|
+
operationSignal
|
|
88321
|
+
);
|
|
88322
|
+
operationSignal.throwIfAborted();
|
|
88323
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
88324
|
+
send(
|
|
88325
|
+
socket,
|
|
88326
|
+
discoveredEvent(
|
|
88327
|
+
command,
|
|
88328
|
+
published.agents.map((agent) => ({
|
|
88329
|
+
agentVersion: agent.agentVersion,
|
|
88330
|
+
id: agent.id,
|
|
88331
|
+
label: agent.label
|
|
88332
|
+
}))
|
|
88333
|
+
)
|
|
88334
|
+
);
|
|
88335
|
+
}
|
|
88336
|
+
} catch (error62) {
|
|
88337
|
+
diagnostics.daemonDiagnostic(
|
|
88338
|
+
"agent_catalog_discovery_failed",
|
|
88339
|
+
command.requestId,
|
|
88340
|
+
{ code: operationErrorCode(error62) },
|
|
88341
|
+
error62
|
|
88342
|
+
);
|
|
88343
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
88344
|
+
send(socket, {
|
|
88345
|
+
code: operationErrorCode(error62),
|
|
88346
|
+
kind: AGENT_CATALOG_DISCOVERY_FAILED_KIND,
|
|
88347
|
+
message: operationErrorMessage(error62),
|
|
88348
|
+
requestId: command.requestId
|
|
88349
|
+
});
|
|
88350
|
+
}
|
|
88351
|
+
} finally {
|
|
88352
|
+
timeout.cancel();
|
|
88353
|
+
requestIds.delete(command.requestId);
|
|
88354
|
+
controller = null;
|
|
88355
|
+
completion = null;
|
|
88356
|
+
}
|
|
88357
|
+
})();
|
|
88358
|
+
};
|
|
88359
|
+
const settle2 = async () => {
|
|
88360
|
+
await (completion ?? Promise.resolve());
|
|
88361
|
+
};
|
|
88362
|
+
return { handle, settle: settle2 };
|
|
88363
|
+
}
|
|
88364
|
+
|
|
88365
|
+
// src/runtime/command/registry/agent-catalog.ts
|
|
88366
|
+
function createAgentCatalogCommands(context) {
|
|
88367
|
+
const handler = createAgentCatalogDiscoveryHandler({
|
|
88368
|
+
config: context.config,
|
|
88369
|
+
discover: context.config.rediscoverAgents === void 0 ? () => {
|
|
88370
|
+
throw new Error("Agent catalog discovery is not available for this Runtime");
|
|
88371
|
+
} : context.config.rediscoverAgents,
|
|
88372
|
+
diagnostics: context.diagnostics,
|
|
88373
|
+
socket: context.socket,
|
|
88374
|
+
signal: context.signal,
|
|
88375
|
+
timer: context.timer
|
|
88376
|
+
});
|
|
88377
|
+
return [
|
|
88378
|
+
{
|
|
88379
|
+
kind: AGENT_CATALOG_DISCOVER_KIND,
|
|
88380
|
+
handle: (_context, message) => {
|
|
88381
|
+
if (message.kind !== AGENT_CATALOG_DISCOVER_KIND) {
|
|
88382
|
+
throw new Error("Command kind mismatch");
|
|
88383
|
+
}
|
|
88384
|
+
handler.handle(message);
|
|
88385
|
+
},
|
|
88386
|
+
settle: handler.settle
|
|
88387
|
+
}
|
|
88388
|
+
];
|
|
88389
|
+
}
|
|
88390
|
+
|
|
88391
|
+
// src/runtime/command/agent-settings-discovery.ts
|
|
88392
|
+
import { WebSocket as WebSocket4 } from "undici";
|
|
88393
|
+
|
|
88181
88394
|
// src/session/api/session-error.ts
|
|
88182
88395
|
var SessionError = class extends OperationError {
|
|
88183
88396
|
constructor(code, message, options = {}) {
|
|
@@ -88513,28 +88726,6 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
|
|
|
88513
88726
|
).digest("hex");
|
|
88514
88727
|
}
|
|
88515
88728
|
|
|
88516
|
-
// src/runtime/command/transport.ts
|
|
88517
|
-
import { WebSocket as WebSocket2 } from "undici";
|
|
88518
|
-
function send(socket, message) {
|
|
88519
|
-
if (socket.readyState !== WebSocket2.OPEN) {
|
|
88520
|
-
throw new Error("Relay connection is not open");
|
|
88521
|
-
}
|
|
88522
|
-
socket.send(encodeDaemonToServiceMessage(message));
|
|
88523
|
-
}
|
|
88524
|
-
function reportOperationFailure(socket, requestId, sessionId, error62, runtimeTimings = []) {
|
|
88525
|
-
if (socket.readyState !== WebSocket2.OPEN) {
|
|
88526
|
-
return;
|
|
88527
|
-
}
|
|
88528
|
-
send(socket, {
|
|
88529
|
-
code: operationErrorCode(error62),
|
|
88530
|
-
kind: "session.operation.failed",
|
|
88531
|
-
message: operationErrorMessage(error62),
|
|
88532
|
-
requestId,
|
|
88533
|
-
...runtimeTimings.length === 0 ? {} : { runtimeTimings },
|
|
88534
|
-
sessionId
|
|
88535
|
-
});
|
|
88536
|
-
}
|
|
88537
|
-
|
|
88538
88729
|
// src/runtime/command/agent-settings-discovery.ts
|
|
88539
88730
|
function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
88540
88731
|
const { config: config2, directories, sessions, diagnostics, socket, signal, timer } = dependencies;
|
|
@@ -88544,7 +88735,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
88544
88735
|
(request) => request.agentId === command.agentId && !request.controller.signal.aborted
|
|
88545
88736
|
);
|
|
88546
88737
|
if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
|
|
88547
|
-
if (socket.readyState ===
|
|
88738
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
88548
88739
|
send(socket, {
|
|
88549
88740
|
code: "agent_settings_discovery_busy",
|
|
88550
88741
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -88559,7 +88750,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
88559
88750
|
return;
|
|
88560
88751
|
}
|
|
88561
88752
|
if (existing !== void 0) {
|
|
88562
|
-
if (socket.readyState ===
|
|
88753
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
88563
88754
|
send(socket, {
|
|
88564
88755
|
code: "agent_settings_discovery_busy",
|
|
88565
88756
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -88570,7 +88761,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
88570
88761
|
return;
|
|
88571
88762
|
}
|
|
88572
88763
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
88573
|
-
if (socket.readyState ===
|
|
88764
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
88574
88765
|
send(socket, {
|
|
88575
88766
|
code: "agent_settings_discovery_busy",
|
|
88576
88767
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -88608,7 +88799,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
88608
88799
|
);
|
|
88609
88800
|
}
|
|
88610
88801
|
for (const requestId of requestIds) {
|
|
88611
|
-
if (socket.readyState ===
|
|
88802
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
88612
88803
|
send(socket, { ...result.event, requestId });
|
|
88613
88804
|
}
|
|
88614
88805
|
}
|
|
@@ -88622,7 +88813,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
88622
88813
|
`
|
|
88623
88814
|
);
|
|
88624
88815
|
}
|
|
88625
|
-
if (socket.readyState ===
|
|
88816
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
88626
88817
|
for (const requestId of requestIds) {
|
|
88627
88818
|
send(socket, {
|
|
88628
88819
|
code: operationErrorCode(failure2),
|
|
@@ -88678,7 +88869,7 @@ function createAgentSettingsCommands(context) {
|
|
|
88678
88869
|
}
|
|
88679
88870
|
|
|
88680
88871
|
// src/runtime/command/registry/file-read/index.ts
|
|
88681
|
-
import { WebSocket as
|
|
88872
|
+
import { WebSocket as WebSocket5 } from "undici";
|
|
88682
88873
|
|
|
88683
88874
|
// src/session/content/session-files.ts
|
|
88684
88875
|
import { basename as basename8, extname as extname2, isAbsolute as isAbsolute15, join as join30, normalize as normalize3, resolve as resolve16 } from "node:path";
|
|
@@ -88781,7 +88972,7 @@ var fileReadCommand = {
|
|
|
88781
88972
|
sessions.findSessions([message.sessionId])[0]?.cwd ?? null,
|
|
88782
88973
|
externalContent
|
|
88783
88974
|
).catch((error62) => {
|
|
88784
|
-
if (socket.readyState !==
|
|
88975
|
+
if (socket.readyState !== WebSocket5.OPEN || signal.aborted) {
|
|
88785
88976
|
return;
|
|
88786
88977
|
}
|
|
88787
88978
|
send(socket, {
|
|
@@ -89124,7 +89315,7 @@ var elicitationRespondCommand = {
|
|
|
89124
89315
|
};
|
|
89125
89316
|
|
|
89126
89317
|
// src/runtime/command/native-session-requests.ts
|
|
89127
|
-
import { WebSocket as
|
|
89318
|
+
import { WebSocket as WebSocket6 } from "undici";
|
|
89128
89319
|
function createNativeSessionRequestHandler(dependencies) {
|
|
89129
89320
|
const { diagnostics, nativeSessions, signal, socket, timer } = dependencies;
|
|
89130
89321
|
const pending = /* @__PURE__ */ new Map();
|
|
@@ -89176,7 +89367,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
89176
89367
|
}
|
|
89177
89368
|
operationSignal.throwIfAborted();
|
|
89178
89369
|
const result = await nativeSessions.execute(command, operationSignal);
|
|
89179
|
-
if (socket.readyState ===
|
|
89370
|
+
if (socket.readyState === WebSocket6.OPEN) {
|
|
89180
89371
|
send(socket, result);
|
|
89181
89372
|
}
|
|
89182
89373
|
} catch (error62) {
|
|
@@ -90277,6 +90468,7 @@ function createCommandRegistry(context) {
|
|
|
90277
90468
|
sessionHistoryPageLoadCommand,
|
|
90278
90469
|
previewHistoryPageLoadCommand,
|
|
90279
90470
|
...createNativeSessionCommands(context),
|
|
90471
|
+
...createAgentCatalogCommands(context),
|
|
90280
90472
|
...createAgentSettingsCommands(context),
|
|
90281
90473
|
fileReadCommand,
|
|
90282
90474
|
sessionCancelCommand,
|
|
@@ -90312,7 +90504,7 @@ function createRuntimeCommandDispatcher(options) {
|
|
|
90312
90504
|
}
|
|
90313
90505
|
|
|
90314
90506
|
// src/runtime/relay/connect.ts
|
|
90315
|
-
import { WebSocket as
|
|
90507
|
+
import { WebSocket as WebSocket7 } from "undici";
|
|
90316
90508
|
|
|
90317
90509
|
// src/runtime/relay/runtime-revocation.ts
|
|
90318
90510
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -90350,7 +90542,7 @@ function connectRelay(url2, signal) {
|
|
|
90350
90542
|
const endpoint = new URL(url2);
|
|
90351
90543
|
const headers = relayAuthorization(endpoint);
|
|
90352
90544
|
endpoint.searchParams.delete("token");
|
|
90353
|
-
const socket = new
|
|
90545
|
+
const socket = new WebSocket7(endpoint, {
|
|
90354
90546
|
dispatcher: environmentProxyDispatcher,
|
|
90355
90547
|
headers
|
|
90356
90548
|
});
|
|
@@ -90558,7 +90750,7 @@ function readCommandCorrelation(encoded) {
|
|
|
90558
90750
|
};
|
|
90559
90751
|
}
|
|
90560
90752
|
function rejectUnsupportedCommand(socket, correlation, rejection) {
|
|
90561
|
-
if (socket.readyState !==
|
|
90753
|
+
if (socket.readyState !== WebSocket8.OPEN) {
|
|
90562
90754
|
return;
|
|
90563
90755
|
}
|
|
90564
90756
|
send(socket, {
|
|
@@ -90606,7 +90798,7 @@ async function runRelayConnection({
|
|
|
90606
90798
|
timer
|
|
90607
90799
|
});
|
|
90608
90800
|
void reportUpgradeAvailability((result) => {
|
|
90609
|
-
if (socket.readyState ===
|
|
90801
|
+
if (socket.readyState === WebSocket8.OPEN) {
|
|
90610
90802
|
send(socket, result);
|
|
90611
90803
|
}
|
|
90612
90804
|
}, signal).catch((cause) => {
|
|
@@ -90657,14 +90849,14 @@ async function runRelayConnection({
|
|
|
90657
90849
|
};
|
|
90658
90850
|
const connectionLiveness = new RelayConnectionLiveness(timer, {
|
|
90659
90851
|
send: (message) => {
|
|
90660
|
-
if (socket.readyState !==
|
|
90852
|
+
if (socket.readyState !== WebSocket8.OPEN) {
|
|
90661
90853
|
return false;
|
|
90662
90854
|
}
|
|
90663
90855
|
try {
|
|
90664
90856
|
send(socket, message);
|
|
90665
90857
|
return true;
|
|
90666
90858
|
} catch (error62) {
|
|
90667
|
-
if (socket.readyState !==
|
|
90859
|
+
if (socket.readyState !== WebSocket8.OPEN) {
|
|
90668
90860
|
return false;
|
|
90669
90861
|
}
|
|
90670
90862
|
throw error62;
|
|
@@ -90770,7 +90962,7 @@ async function runRelayConnection({
|
|
|
90770
90962
|
}
|
|
90771
90963
|
|
|
90772
90964
|
// src/runtime/relay/session-event-publisher.ts
|
|
90773
|
-
import { WebSocket as
|
|
90965
|
+
import { WebSocket as WebSocket9 } from "undici";
|
|
90774
90966
|
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
90775
90967
|
var MAX_PENDING_BYTES2 = 32 * 1024 * 1024;
|
|
90776
90968
|
var MAX_EVENT_BATCH_BYTES = 1024 * 1024;
|
|
@@ -90820,7 +91012,7 @@ var RuntimeSessionEventPublisher = class {
|
|
|
90820
91012
|
publishClosed = (event) => this.#send(event);
|
|
90821
91013
|
#send = (message) => {
|
|
90822
91014
|
const connection = this.#connection;
|
|
90823
|
-
if (connection.kind !== "connected" || connection.socket.readyState !==
|
|
91015
|
+
if (connection.kind !== "connected" || connection.socket.readyState !== WebSocket9.OPEN) {
|
|
90824
91016
|
return;
|
|
90825
91017
|
}
|
|
90826
91018
|
const socket = connection.socket;
|
|
@@ -90871,7 +91063,7 @@ var RuntimeSessionEventPublisher = class {
|
|
|
90871
91063
|
batch.bytes += bytes;
|
|
90872
91064
|
this.#pendingBytes += additionalBytes;
|
|
90873
91065
|
const connection = this.#connection;
|
|
90874
|
-
if (connection.kind !== "connected" || connection.socket.readyState !==
|
|
91066
|
+
if (connection.kind !== "connected" || connection.socket.readyState !== WebSocket9.OPEN) {
|
|
90875
91067
|
return;
|
|
90876
91068
|
}
|
|
90877
91069
|
const socket = connection.socket;
|
|
@@ -90891,7 +91083,7 @@ var RuntimeSessionEventPublisher = class {
|
|
|
90891
91083
|
flushEvents = (socket) => {
|
|
90892
91084
|
this.cancelFlush();
|
|
90893
91085
|
const connection = this.#connection;
|
|
90894
|
-
if (connection.kind !== "connected" || connection.socket !== socket || socket.readyState !==
|
|
91086
|
+
if (connection.kind !== "connected" || connection.socket !== socket || socket.readyState !== WebSocket9.OPEN) {
|
|
90895
91087
|
return;
|
|
90896
91088
|
}
|
|
90897
91089
|
let attempted = 0;
|
|
@@ -91204,7 +91396,8 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
|
|
|
91204
91396
|
(refreshSignal) => discover(refreshSignal),
|
|
91205
91397
|
() => config2,
|
|
91206
91398
|
publishAgentCatalog
|
|
91207
|
-
)
|
|
91399
|
+
),
|
|
91400
|
+
(refreshSignal) => discover(refreshSignal).then((inventory2) => inventory2.readyAgents())
|
|
91208
91401
|
);
|
|
91209
91402
|
return new MobiusRuntimeEngine(config2);
|
|
91210
91403
|
}
|