@moxt-ai/mobius 0.0.301 → 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/acp/harness/codex/agent.d.ts.map +1 -1
- package/dist/acp/harness/codex/agent.js +5 -1
- package/dist/acp/harness/codex/agent.js.map +1 -1
- 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 +308 -76
- 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 +265 -68
- 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: {
|
|
@@ -69087,7 +69133,11 @@ var CodexAcpAgent = class {
|
|
|
69087
69133
|
const decoded = threadListResponseSchema.parse(
|
|
69088
69134
|
await this.#appServer.request(
|
|
69089
69135
|
"thread/list",
|
|
69090
|
-
{
|
|
69136
|
+
{
|
|
69137
|
+
cursor: context.params.cursor ?? null,
|
|
69138
|
+
// Codex defaults to interactive sources and otherwise hides exec handoffs.
|
|
69139
|
+
sourceKinds: ["cli", "vscode", "exec", "appServer"]
|
|
69140
|
+
},
|
|
69091
69141
|
AbortSignal.any([context.signal, AbortSignal.timeout(SESSION_LIST_TIMEOUT_MILLISECONDS2)])
|
|
69092
69142
|
)
|
|
69093
69143
|
);
|
|
@@ -74121,6 +74171,20 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
74121
74171
|
// src/runtime/config.ts
|
|
74122
74172
|
import { join as join20, resolve as resolve13 } from "node:path";
|
|
74123
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
|
+
|
|
74124
74188
|
// src/agent/catalog.ts
|
|
74125
74189
|
var LocalAgentCatalogSnapshot = class {
|
|
74126
74190
|
agents;
|
|
@@ -74136,6 +74200,7 @@ var LocalAgentCatalogError = class extends OperationError {
|
|
|
74136
74200
|
};
|
|
74137
74201
|
var LocalAgentCatalog = class {
|
|
74138
74202
|
#snapshot;
|
|
74203
|
+
#updates = new SerialTaskQueue();
|
|
74139
74204
|
constructor(agents) {
|
|
74140
74205
|
this.#snapshot = this.validate(agents);
|
|
74141
74206
|
}
|
|
@@ -74148,10 +74213,20 @@ var LocalAgentCatalog = class {
|
|
|
74148
74213
|
throw new LocalAgentCatalogError();
|
|
74149
74214
|
};
|
|
74150
74215
|
read = () => this.#snapshot;
|
|
74151
|
-
|
|
74152
|
-
|
|
74153
|
-
this.#
|
|
74154
|
-
|
|
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);
|
|
74155
74230
|
};
|
|
74156
74231
|
validate = (agents) => {
|
|
74157
74232
|
const identifiers = /* @__PURE__ */ new Set();
|
|
@@ -74198,7 +74273,7 @@ var OpaqueRuntimeReconnectTarget = class extends RuntimeReconnectTarget {
|
|
|
74198
74273
|
this.commandArgument = `--connection ${connectionId2}`;
|
|
74199
74274
|
}
|
|
74200
74275
|
};
|
|
74201
|
-
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) {
|
|
74202
74277
|
const runtimeAgents = agents.map((agent) => withRuntimeEnvironment(agent, localContext.environment));
|
|
74203
74278
|
return {
|
|
74204
74279
|
agents: runtimeAgents,
|
|
@@ -74209,7 +74284,8 @@ function createRuntimeConfig(connection, agents = [], localContext = new Runtime
|
|
|
74209
74284
|
localContext,
|
|
74210
74285
|
reconnectTarget,
|
|
74211
74286
|
relayUrl: connection.relayUrl,
|
|
74212
|
-
...resolveAgent === void 0 ? {} : { resolveAgent }
|
|
74287
|
+
...resolveAgent === void 0 ? {} : { resolveAgent },
|
|
74288
|
+
...rediscoverAgents === void 0 ? {} : { rediscoverAgents }
|
|
74213
74289
|
};
|
|
74214
74290
|
}
|
|
74215
74291
|
|
|
@@ -74239,21 +74315,17 @@ function createCatalogAgentResolver(discover, readConfig, publish) {
|
|
|
74239
74315
|
signal.throwIfAborted();
|
|
74240
74316
|
const inventory = await discover(signal);
|
|
74241
74317
|
signal.throwIfAborted();
|
|
74242
|
-
const
|
|
74243
|
-
|
|
74244
|
-
|
|
74245
|
-
|
|
74246
|
-
|
|
74247
|
-
|
|
74248
|
-
|
|
74249
|
-
|
|
74250
|
-
|
|
74251
|
-
|
|
74252
|
-
|
|
74253
|
-
} catch (error62) {
|
|
74254
|
-
config2.catalog.transition(previous.agents);
|
|
74255
|
-
throw error62;
|
|
74256
|
-
}
|
|
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
|
+
);
|
|
74257
74329
|
return config2.catalog.find(agent.id);
|
|
74258
74330
|
} finally {
|
|
74259
74331
|
swaps.delete(agent.id);
|
|
@@ -75112,7 +75184,12 @@ function buildPairedRuntime(installation, connection, defaultWorkspace, inventor
|
|
|
75112
75184
|
}),
|
|
75113
75185
|
() => config2,
|
|
75114
75186
|
publishAgentCatalog
|
|
75115
|
-
)
|
|
75187
|
+
),
|
|
75188
|
+
(refreshSignal) => discoverLocalAgentInventory({
|
|
75189
|
+
defaultWorkspace,
|
|
75190
|
+
environment: localContext.environment,
|
|
75191
|
+
signal: refreshSignal
|
|
75192
|
+
}).then((inventory2) => inventory2.readyAgents())
|
|
75116
75193
|
);
|
|
75117
75194
|
return {
|
|
75118
75195
|
channelUrl: new URL(`/channels/${encodeURIComponent(connection.channelId)}`, connection.relayOrigin).toString(),
|
|
@@ -88169,11 +88246,151 @@ var RelayConnectionDiagnostics = class {
|
|
|
88169
88246
|
};
|
|
88170
88247
|
|
|
88171
88248
|
// src/runtime/relay/run-relay-connection.ts
|
|
88172
|
-
import { WebSocket as
|
|
88249
|
+
import { WebSocket as WebSocket8 } from "undici";
|
|
88173
88250
|
|
|
88174
|
-
// src/runtime/
|
|
88251
|
+
// src/runtime/catalog/handle-agent-catalog-discovery.ts
|
|
88175
88252
|
import { WebSocket as WebSocket3 } from "undici";
|
|
88176
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
|
+
|
|
88177
88394
|
// src/session/api/session-error.ts
|
|
88178
88395
|
var SessionError = class extends OperationError {
|
|
88179
88396
|
constructor(code, message, options = {}) {
|
|
@@ -88509,28 +88726,6 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
|
|
|
88509
88726
|
).digest("hex");
|
|
88510
88727
|
}
|
|
88511
88728
|
|
|
88512
|
-
// src/runtime/command/transport.ts
|
|
88513
|
-
import { WebSocket as WebSocket2 } from "undici";
|
|
88514
|
-
function send(socket, message) {
|
|
88515
|
-
if (socket.readyState !== WebSocket2.OPEN) {
|
|
88516
|
-
throw new Error("Relay connection is not open");
|
|
88517
|
-
}
|
|
88518
|
-
socket.send(encodeDaemonToServiceMessage(message));
|
|
88519
|
-
}
|
|
88520
|
-
function reportOperationFailure(socket, requestId, sessionId, error62, runtimeTimings = []) {
|
|
88521
|
-
if (socket.readyState !== WebSocket2.OPEN) {
|
|
88522
|
-
return;
|
|
88523
|
-
}
|
|
88524
|
-
send(socket, {
|
|
88525
|
-
code: operationErrorCode(error62),
|
|
88526
|
-
kind: "session.operation.failed",
|
|
88527
|
-
message: operationErrorMessage(error62),
|
|
88528
|
-
requestId,
|
|
88529
|
-
...runtimeTimings.length === 0 ? {} : { runtimeTimings },
|
|
88530
|
-
sessionId
|
|
88531
|
-
});
|
|
88532
|
-
}
|
|
88533
|
-
|
|
88534
88729
|
// src/runtime/command/agent-settings-discovery.ts
|
|
88535
88730
|
function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
88536
88731
|
const { config: config2, directories, sessions, diagnostics, socket, signal, timer } = dependencies;
|
|
@@ -88540,7 +88735,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
88540
88735
|
(request) => request.agentId === command.agentId && !request.controller.signal.aborted
|
|
88541
88736
|
);
|
|
88542
88737
|
if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
|
|
88543
|
-
if (socket.readyState ===
|
|
88738
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
88544
88739
|
send(socket, {
|
|
88545
88740
|
code: "agent_settings_discovery_busy",
|
|
88546
88741
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -88555,7 +88750,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
88555
88750
|
return;
|
|
88556
88751
|
}
|
|
88557
88752
|
if (existing !== void 0) {
|
|
88558
|
-
if (socket.readyState ===
|
|
88753
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
88559
88754
|
send(socket, {
|
|
88560
88755
|
code: "agent_settings_discovery_busy",
|
|
88561
88756
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -88566,7 +88761,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
88566
88761
|
return;
|
|
88567
88762
|
}
|
|
88568
88763
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
88569
|
-
if (socket.readyState ===
|
|
88764
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
88570
88765
|
send(socket, {
|
|
88571
88766
|
code: "agent_settings_discovery_busy",
|
|
88572
88767
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -88604,7 +88799,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
88604
88799
|
);
|
|
88605
88800
|
}
|
|
88606
88801
|
for (const requestId of requestIds) {
|
|
88607
|
-
if (socket.readyState ===
|
|
88802
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
88608
88803
|
send(socket, { ...result.event, requestId });
|
|
88609
88804
|
}
|
|
88610
88805
|
}
|
|
@@ -88618,7 +88813,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
88618
88813
|
`
|
|
88619
88814
|
);
|
|
88620
88815
|
}
|
|
88621
|
-
if (socket.readyState ===
|
|
88816
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
88622
88817
|
for (const requestId of requestIds) {
|
|
88623
88818
|
send(socket, {
|
|
88624
88819
|
code: operationErrorCode(failure2),
|
|
@@ -88674,7 +88869,7 @@ function createAgentSettingsCommands(context) {
|
|
|
88674
88869
|
}
|
|
88675
88870
|
|
|
88676
88871
|
// src/runtime/command/registry/file-read/index.ts
|
|
88677
|
-
import { WebSocket as
|
|
88872
|
+
import { WebSocket as WebSocket5 } from "undici";
|
|
88678
88873
|
|
|
88679
88874
|
// src/session/content/session-files.ts
|
|
88680
88875
|
import { basename as basename8, extname as extname2, isAbsolute as isAbsolute15, join as join30, normalize as normalize3, resolve as resolve16 } from "node:path";
|
|
@@ -88777,7 +88972,7 @@ var fileReadCommand = {
|
|
|
88777
88972
|
sessions.findSessions([message.sessionId])[0]?.cwd ?? null,
|
|
88778
88973
|
externalContent
|
|
88779
88974
|
).catch((error62) => {
|
|
88780
|
-
if (socket.readyState !==
|
|
88975
|
+
if (socket.readyState !== WebSocket5.OPEN || signal.aborted) {
|
|
88781
88976
|
return;
|
|
88782
88977
|
}
|
|
88783
88978
|
send(socket, {
|
|
@@ -89120,7 +89315,7 @@ var elicitationRespondCommand = {
|
|
|
89120
89315
|
};
|
|
89121
89316
|
|
|
89122
89317
|
// src/runtime/command/native-session-requests.ts
|
|
89123
|
-
import { WebSocket as
|
|
89318
|
+
import { WebSocket as WebSocket6 } from "undici";
|
|
89124
89319
|
function createNativeSessionRequestHandler(dependencies) {
|
|
89125
89320
|
const { diagnostics, nativeSessions, signal, socket, timer } = dependencies;
|
|
89126
89321
|
const pending = /* @__PURE__ */ new Map();
|
|
@@ -89172,7 +89367,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
89172
89367
|
}
|
|
89173
89368
|
operationSignal.throwIfAborted();
|
|
89174
89369
|
const result = await nativeSessions.execute(command, operationSignal);
|
|
89175
|
-
if (socket.readyState ===
|
|
89370
|
+
if (socket.readyState === WebSocket6.OPEN) {
|
|
89176
89371
|
send(socket, result);
|
|
89177
89372
|
}
|
|
89178
89373
|
} catch (error62) {
|
|
@@ -90273,6 +90468,7 @@ function createCommandRegistry(context) {
|
|
|
90273
90468
|
sessionHistoryPageLoadCommand,
|
|
90274
90469
|
previewHistoryPageLoadCommand,
|
|
90275
90470
|
...createNativeSessionCommands(context),
|
|
90471
|
+
...createAgentCatalogCommands(context),
|
|
90276
90472
|
...createAgentSettingsCommands(context),
|
|
90277
90473
|
fileReadCommand,
|
|
90278
90474
|
sessionCancelCommand,
|
|
@@ -90308,7 +90504,7 @@ function createRuntimeCommandDispatcher(options) {
|
|
|
90308
90504
|
}
|
|
90309
90505
|
|
|
90310
90506
|
// src/runtime/relay/connect.ts
|
|
90311
|
-
import { WebSocket as
|
|
90507
|
+
import { WebSocket as WebSocket7 } from "undici";
|
|
90312
90508
|
|
|
90313
90509
|
// src/runtime/relay/runtime-revocation.ts
|
|
90314
90510
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -90346,7 +90542,7 @@ function connectRelay(url2, signal) {
|
|
|
90346
90542
|
const endpoint = new URL(url2);
|
|
90347
90543
|
const headers = relayAuthorization(endpoint);
|
|
90348
90544
|
endpoint.searchParams.delete("token");
|
|
90349
|
-
const socket = new
|
|
90545
|
+
const socket = new WebSocket7(endpoint, {
|
|
90350
90546
|
dispatcher: environmentProxyDispatcher,
|
|
90351
90547
|
headers
|
|
90352
90548
|
});
|
|
@@ -90554,7 +90750,7 @@ function readCommandCorrelation(encoded) {
|
|
|
90554
90750
|
};
|
|
90555
90751
|
}
|
|
90556
90752
|
function rejectUnsupportedCommand(socket, correlation, rejection) {
|
|
90557
|
-
if (socket.readyState !==
|
|
90753
|
+
if (socket.readyState !== WebSocket8.OPEN) {
|
|
90558
90754
|
return;
|
|
90559
90755
|
}
|
|
90560
90756
|
send(socket, {
|
|
@@ -90602,7 +90798,7 @@ async function runRelayConnection({
|
|
|
90602
90798
|
timer
|
|
90603
90799
|
});
|
|
90604
90800
|
void reportUpgradeAvailability((result) => {
|
|
90605
|
-
if (socket.readyState ===
|
|
90801
|
+
if (socket.readyState === WebSocket8.OPEN) {
|
|
90606
90802
|
send(socket, result);
|
|
90607
90803
|
}
|
|
90608
90804
|
}, signal).catch((cause) => {
|
|
@@ -90653,14 +90849,14 @@ async function runRelayConnection({
|
|
|
90653
90849
|
};
|
|
90654
90850
|
const connectionLiveness = new RelayConnectionLiveness(timer, {
|
|
90655
90851
|
send: (message) => {
|
|
90656
|
-
if (socket.readyState !==
|
|
90852
|
+
if (socket.readyState !== WebSocket8.OPEN) {
|
|
90657
90853
|
return false;
|
|
90658
90854
|
}
|
|
90659
90855
|
try {
|
|
90660
90856
|
send(socket, message);
|
|
90661
90857
|
return true;
|
|
90662
90858
|
} catch (error62) {
|
|
90663
|
-
if (socket.readyState !==
|
|
90859
|
+
if (socket.readyState !== WebSocket8.OPEN) {
|
|
90664
90860
|
return false;
|
|
90665
90861
|
}
|
|
90666
90862
|
throw error62;
|
|
@@ -90766,7 +90962,7 @@ async function runRelayConnection({
|
|
|
90766
90962
|
}
|
|
90767
90963
|
|
|
90768
90964
|
// src/runtime/relay/session-event-publisher.ts
|
|
90769
|
-
import { WebSocket as
|
|
90965
|
+
import { WebSocket as WebSocket9 } from "undici";
|
|
90770
90966
|
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
90771
90967
|
var MAX_PENDING_BYTES2 = 32 * 1024 * 1024;
|
|
90772
90968
|
var MAX_EVENT_BATCH_BYTES = 1024 * 1024;
|
|
@@ -90816,7 +91012,7 @@ var RuntimeSessionEventPublisher = class {
|
|
|
90816
91012
|
publishClosed = (event) => this.#send(event);
|
|
90817
91013
|
#send = (message) => {
|
|
90818
91014
|
const connection = this.#connection;
|
|
90819
|
-
if (connection.kind !== "connected" || connection.socket.readyState !==
|
|
91015
|
+
if (connection.kind !== "connected" || connection.socket.readyState !== WebSocket9.OPEN) {
|
|
90820
91016
|
return;
|
|
90821
91017
|
}
|
|
90822
91018
|
const socket = connection.socket;
|
|
@@ -90867,7 +91063,7 @@ var RuntimeSessionEventPublisher = class {
|
|
|
90867
91063
|
batch.bytes += bytes;
|
|
90868
91064
|
this.#pendingBytes += additionalBytes;
|
|
90869
91065
|
const connection = this.#connection;
|
|
90870
|
-
if (connection.kind !== "connected" || connection.socket.readyState !==
|
|
91066
|
+
if (connection.kind !== "connected" || connection.socket.readyState !== WebSocket9.OPEN) {
|
|
90871
91067
|
return;
|
|
90872
91068
|
}
|
|
90873
91069
|
const socket = connection.socket;
|
|
@@ -90887,7 +91083,7 @@ var RuntimeSessionEventPublisher = class {
|
|
|
90887
91083
|
flushEvents = (socket) => {
|
|
90888
91084
|
this.cancelFlush();
|
|
90889
91085
|
const connection = this.#connection;
|
|
90890
|
-
if (connection.kind !== "connected" || connection.socket !== socket || socket.readyState !==
|
|
91086
|
+
if (connection.kind !== "connected" || connection.socket !== socket || socket.readyState !== WebSocket9.OPEN) {
|
|
90891
91087
|
return;
|
|
90892
91088
|
}
|
|
90893
91089
|
let attempted = 0;
|
|
@@ -91200,7 +91396,8 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
|
|
|
91200
91396
|
(refreshSignal) => discover(refreshSignal),
|
|
91201
91397
|
() => config2,
|
|
91202
91398
|
publishAgentCatalog
|
|
91203
|
-
)
|
|
91399
|
+
),
|
|
91400
|
+
(refreshSignal) => discover(refreshSignal).then((inventory2) => inventory2.readyAgents())
|
|
91204
91401
|
);
|
|
91205
91402
|
return new MobiusRuntimeEngine(config2);
|
|
91206
91403
|
}
|