@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/cli.js
CHANGED
|
@@ -2086,7 +2086,7 @@ var init_package = __esm({
|
|
|
2086
2086
|
"package.json"() {
|
|
2087
2087
|
package_default = {
|
|
2088
2088
|
name: "@moxt-ai/mobius",
|
|
2089
|
-
version: "0.0.
|
|
2089
|
+
version: "0.0.303",
|
|
2090
2090
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
2091
2091
|
type: "module",
|
|
2092
2092
|
bin: {
|
|
@@ -72906,6 +72906,46 @@ var init_access = __esm({
|
|
|
72906
72906
|
}
|
|
72907
72907
|
});
|
|
72908
72908
|
|
|
72909
|
+
// ../mobius-sdk/src/protocol/session/agent/catalog.ts
|
|
72910
|
+
var AGENT_CATALOG_DISCOVER_KIND, AGENT_CATALOG_DISCOVERED_KIND, AGENT_CATALOG_DISCOVERY_FAILED_KIND, catalogedAgentSchema, agentCatalogDiscoverCommandSchema, agentCatalogDiscoveredEventSchema, agentCatalogDiscoveryFailedEventSchema, decodeAgentCatalogDiscoverCommand, encodeAgentCatalogDiscoverCommand, decodeAgentCatalogDiscoveredEvent, encodeAgentCatalogDiscoveredEvent, decodeAgentCatalogDiscoveryFailedEvent, encodeAgentCatalogDiscoveryFailedEvent;
|
|
72911
|
+
var init_catalog = __esm({
|
|
72912
|
+
"../mobius-sdk/src/protocol/session/agent/catalog.ts"() {
|
|
72913
|
+
"use strict";
|
|
72914
|
+
init_zod();
|
|
72915
|
+
init_identifier();
|
|
72916
|
+
init_message_codec();
|
|
72917
|
+
AGENT_CATALOG_DISCOVER_KIND = "agent.catalog.discover";
|
|
72918
|
+
AGENT_CATALOG_DISCOVERED_KIND = "agent.catalog.discovered";
|
|
72919
|
+
AGENT_CATALOG_DISCOVERY_FAILED_KIND = "agent.catalog.discovery.failed";
|
|
72920
|
+
catalogedAgentSchema = external_exports.object({
|
|
72921
|
+
agentVersion: external_exports.string().min(1).max(128),
|
|
72922
|
+
id: identifierStringSchema,
|
|
72923
|
+
label: external_exports.string().min(1).max(255)
|
|
72924
|
+
}).readonly();
|
|
72925
|
+
agentCatalogDiscoverCommandSchema = external_exports.object({
|
|
72926
|
+
kind: external_exports.literal(AGENT_CATALOG_DISCOVER_KIND),
|
|
72927
|
+
requestId: identifierStringSchema
|
|
72928
|
+
}).readonly();
|
|
72929
|
+
agentCatalogDiscoveredEventSchema = external_exports.object({
|
|
72930
|
+
agents: external_exports.array(catalogedAgentSchema).max(64).readonly(),
|
|
72931
|
+
kind: external_exports.literal(AGENT_CATALOG_DISCOVERED_KIND),
|
|
72932
|
+
requestId: identifierStringSchema
|
|
72933
|
+
}).readonly();
|
|
72934
|
+
agentCatalogDiscoveryFailedEventSchema = external_exports.object({
|
|
72935
|
+
code: identifierStringSchema,
|
|
72936
|
+
kind: external_exports.literal(AGENT_CATALOG_DISCOVERY_FAILED_KIND),
|
|
72937
|
+
message: external_exports.string().min(1).max(500),
|
|
72938
|
+
requestId: identifierStringSchema
|
|
72939
|
+
}).readonly();
|
|
72940
|
+
decodeAgentCatalogDiscoverCommand = (encoded) => decodeZodMessage(encoded, agentCatalogDiscoverCommandSchema);
|
|
72941
|
+
encodeAgentCatalogDiscoverCommand = (message) => encodeZodMessage(message, agentCatalogDiscoverCommandSchema);
|
|
72942
|
+
decodeAgentCatalogDiscoveredEvent = (encoded) => decodeZodMessage(encoded, agentCatalogDiscoveredEventSchema);
|
|
72943
|
+
encodeAgentCatalogDiscoveredEvent = (message) => encodeZodMessage(message, agentCatalogDiscoveredEventSchema);
|
|
72944
|
+
decodeAgentCatalogDiscoveryFailedEvent = (encoded) => decodeZodMessage(encoded, agentCatalogDiscoveryFailedEventSchema);
|
|
72945
|
+
encodeAgentCatalogDiscoveryFailedEvent = (message) => encodeZodMessage(message, agentCatalogDiscoveryFailedEventSchema);
|
|
72946
|
+
}
|
|
72947
|
+
});
|
|
72948
|
+
|
|
72909
72949
|
// ../mobius-sdk/src/protocol/session/shared/index.ts
|
|
72910
72950
|
var SHORT_TEXT, workspaceEntrySchema, sessionStatusSchema, sessionCapabilitiesSchema, sessionCommandSchema, configValueSchema, sessionIdentityFields;
|
|
72911
72951
|
var init_shared2 = __esm({
|
|
@@ -74859,6 +74899,7 @@ var init_daemon_transport = __esm({
|
|
|
74859
74899
|
init_diagnostics();
|
|
74860
74900
|
init_liveness();
|
|
74861
74901
|
init_upgrade();
|
|
74902
|
+
init_catalog();
|
|
74862
74903
|
init_settings2();
|
|
74863
74904
|
init_configuration();
|
|
74864
74905
|
init_title();
|
|
@@ -74882,6 +74923,11 @@ var init_daemon_transport = __esm({
|
|
|
74882
74923
|
encodeAgentSettingsDiscoverCommand,
|
|
74883
74924
|
decodeAgentSettingsDiscoverCommand
|
|
74884
74925
|
),
|
|
74926
|
+
[AGENT_CATALOG_DISCOVER_KIND]: defineMessageSignature(
|
|
74927
|
+
AGENT_CATALOG_DISCOVER_KIND,
|
|
74928
|
+
encodeAgentCatalogDiscoverCommand,
|
|
74929
|
+
decodeAgentCatalogDiscoverCommand
|
|
74930
|
+
),
|
|
74885
74931
|
[FILE_READ_KIND]: defineMessageSignature(FILE_READ_KIND, encodeFileReadCommand, decodeFileReadCommand),
|
|
74886
74932
|
[SESSION_LIST_KIND]: defineMessageSignature(SESSION_LIST_KIND, encodeSessionListCommand, decodeSessionListCommand),
|
|
74887
74933
|
[SESSION_QUERY_KIND]: defineMessageSignature(
|
|
@@ -75023,6 +75069,16 @@ var init_daemon_transport = __esm({
|
|
|
75023
75069
|
encodeAgentSettingsDiscoveryFailedEvent,
|
|
75024
75070
|
decodeAgentSettingsDiscoveryFailedEvent
|
|
75025
75071
|
),
|
|
75072
|
+
[AGENT_CATALOG_DISCOVERED_KIND]: defineMessageSignature(
|
|
75073
|
+
AGENT_CATALOG_DISCOVERED_KIND,
|
|
75074
|
+
encodeAgentCatalogDiscoveredEvent,
|
|
75075
|
+
decodeAgentCatalogDiscoveredEvent
|
|
75076
|
+
),
|
|
75077
|
+
[AGENT_CATALOG_DISCOVERY_FAILED_KIND]: defineMessageSignature(
|
|
75078
|
+
AGENT_CATALOG_DISCOVERY_FAILED_KIND,
|
|
75079
|
+
encodeAgentCatalogDiscoveryFailedEvent,
|
|
75080
|
+
decodeAgentCatalogDiscoveryFailedEvent
|
|
75081
|
+
),
|
|
75026
75082
|
[FILE_BEGIN_KIND]: defineMessageSignature(FILE_BEGIN_KIND, encodeFileBeginEvent, decodeFileBeginEvent),
|
|
75027
75083
|
[FILE_CHUNK_KIND]: defineMessageSignature(FILE_CHUNK_KIND, encodeFileChunkEvent, decodeFileChunkEvent),
|
|
75028
75084
|
[FILE_END_KIND]: defineMessageSignature(FILE_END_KIND, encodeFileEndEvent, decodeFileEndEvent),
|
|
@@ -75108,6 +75164,7 @@ var init_protocol = __esm({
|
|
|
75108
75164
|
init_liveness();
|
|
75109
75165
|
init_upgrade();
|
|
75110
75166
|
init_access();
|
|
75167
|
+
init_catalog();
|
|
75111
75168
|
init_settings2();
|
|
75112
75169
|
init_configuration();
|
|
75113
75170
|
init_title();
|
|
@@ -75721,7 +75778,11 @@ var init_agent = __esm({
|
|
|
75721
75778
|
const decoded = threadListResponseSchema.parse(
|
|
75722
75779
|
await this.#appServer.request(
|
|
75723
75780
|
"thread/list",
|
|
75724
|
-
{
|
|
75781
|
+
{
|
|
75782
|
+
cursor: context.params.cursor ?? null,
|
|
75783
|
+
// Codex defaults to interactive sources and otherwise hides exec handoffs.
|
|
75784
|
+
sourceKinds: ["cli", "vscode", "exec", "appServer"]
|
|
75785
|
+
},
|
|
75725
75786
|
AbortSignal.any([context.signal, AbortSignal.timeout(SESSION_LIST_TIMEOUT_MILLISECONDS2)])
|
|
75726
75787
|
)
|
|
75727
75788
|
);
|
|
@@ -81006,6 +81067,7 @@ var init_discover_local_agents = __esm({
|
|
|
81006
81067
|
init_supported_agent_specifications();
|
|
81007
81068
|
init_agent_discovery();
|
|
81008
81069
|
init_executable_discovery();
|
|
81070
|
+
init_agent_discovery();
|
|
81009
81071
|
}
|
|
81010
81072
|
});
|
|
81011
81073
|
|
|
@@ -81186,12 +81248,33 @@ var init_publish_agent_catalog = __esm({
|
|
|
81186
81248
|
}
|
|
81187
81249
|
});
|
|
81188
81250
|
|
|
81251
|
+
// src/util/serial-task-queue.ts
|
|
81252
|
+
var SerialTaskQueue;
|
|
81253
|
+
var init_serial_task_queue = __esm({
|
|
81254
|
+
"src/util/serial-task-queue.ts"() {
|
|
81255
|
+
"use strict";
|
|
81256
|
+
SerialTaskQueue = class {
|
|
81257
|
+
#tail = Promise.resolve();
|
|
81258
|
+
run = async (task, signal) => {
|
|
81259
|
+
signal.throwIfAborted();
|
|
81260
|
+
const result = this.#tail.then(() => {
|
|
81261
|
+
signal.throwIfAborted();
|
|
81262
|
+
return task(signal);
|
|
81263
|
+
});
|
|
81264
|
+
this.#tail = result.catch(() => void 0);
|
|
81265
|
+
return await result;
|
|
81266
|
+
};
|
|
81267
|
+
};
|
|
81268
|
+
}
|
|
81269
|
+
});
|
|
81270
|
+
|
|
81189
81271
|
// src/agent/catalog.ts
|
|
81190
81272
|
var LocalAgentCatalogSnapshot, LocalAgentCatalogError, LocalAgentCatalog;
|
|
81191
|
-
var
|
|
81273
|
+
var init_catalog2 = __esm({
|
|
81192
81274
|
"src/agent/catalog.ts"() {
|
|
81193
81275
|
"use strict";
|
|
81194
81276
|
init_operation_error();
|
|
81277
|
+
init_serial_task_queue();
|
|
81195
81278
|
LocalAgentCatalogSnapshot = class {
|
|
81196
81279
|
agents;
|
|
81197
81280
|
constructor(agents) {
|
|
@@ -81206,6 +81289,7 @@ var init_catalog = __esm({
|
|
|
81206
81289
|
};
|
|
81207
81290
|
LocalAgentCatalog = class {
|
|
81208
81291
|
#snapshot;
|
|
81292
|
+
#updates = new SerialTaskQueue();
|
|
81209
81293
|
constructor(agents) {
|
|
81210
81294
|
this.#snapshot = this.validate(agents);
|
|
81211
81295
|
}
|
|
@@ -81218,10 +81302,20 @@ var init_catalog = __esm({
|
|
|
81218
81302
|
throw new LocalAgentCatalogError();
|
|
81219
81303
|
};
|
|
81220
81304
|
read = () => this.#snapshot;
|
|
81221
|
-
|
|
81222
|
-
|
|
81223
|
-
this.#
|
|
81224
|
-
|
|
81305
|
+
/** Serializes replacements and publication; a failed publication restores only its own prior snapshot. */
|
|
81306
|
+
replaceAndPublish = async (build, publish, signal) => {
|
|
81307
|
+
return await this.#updates.run(async (updateSignal) => {
|
|
81308
|
+
const previous = this.#snapshot;
|
|
81309
|
+
const next = this.validate(build(previous.agents));
|
|
81310
|
+
this.#snapshot = next;
|
|
81311
|
+
try {
|
|
81312
|
+
await publish(updateSignal);
|
|
81313
|
+
} catch (error62) {
|
|
81314
|
+
this.#snapshot = previous;
|
|
81315
|
+
throw error62;
|
|
81316
|
+
}
|
|
81317
|
+
return next;
|
|
81318
|
+
}, signal);
|
|
81225
81319
|
};
|
|
81226
81320
|
validate = (agents) => {
|
|
81227
81321
|
const identifiers = /* @__PURE__ */ new Set();
|
|
@@ -81252,7 +81346,7 @@ function withRuntimeEnvironment(agent, environment) {
|
|
|
81252
81346
|
}
|
|
81253
81347
|
return agent.withEnvironment({ ...launchEnvironment, ...agent.environment });
|
|
81254
81348
|
}
|
|
81255
|
-
function createRuntimeConfig(connection, agents = [], localContext = new RuntimeLocalContext(readStateDirectory(), process.env), reconnectTarget = null, resolveAgent) {
|
|
81349
|
+
function createRuntimeConfig(connection, agents = [], localContext = new RuntimeLocalContext(readStateDirectory(), process.env), reconnectTarget = null, resolveAgent, rediscoverAgents) {
|
|
81256
81350
|
const runtimeAgents = agents.map((agent) => withRuntimeEnvironment(agent, localContext.environment));
|
|
81257
81351
|
return {
|
|
81258
81352
|
agents: runtimeAgents,
|
|
@@ -81263,7 +81357,8 @@ function createRuntimeConfig(connection, agents = [], localContext = new Runtime
|
|
|
81263
81357
|
localContext,
|
|
81264
81358
|
reconnectTarget,
|
|
81265
81359
|
relayUrl: connection.relayUrl,
|
|
81266
|
-
...resolveAgent === void 0 ? {} : { resolveAgent }
|
|
81360
|
+
...resolveAgent === void 0 ? {} : { resolveAgent },
|
|
81361
|
+
...rediscoverAgents === void 0 ? {} : { rediscoverAgents }
|
|
81267
81362
|
};
|
|
81268
81363
|
}
|
|
81269
81364
|
var RuntimeLocalContext, RuntimeReconnectTarget, OpaqueRuntimeReconnectTarget;
|
|
@@ -81271,7 +81366,7 @@ var init_config = __esm({
|
|
|
81271
81366
|
"src/runtime/config.ts"() {
|
|
81272
81367
|
"use strict";
|
|
81273
81368
|
init_protocol();
|
|
81274
|
-
|
|
81369
|
+
init_catalog2();
|
|
81275
81370
|
init_state_directory();
|
|
81276
81371
|
RuntimeLocalContext = class {
|
|
81277
81372
|
environment;
|
|
@@ -81321,21 +81416,17 @@ function createCatalogAgentResolver(discover, readConfig, publish) {
|
|
|
81321
81416
|
signal.throwIfAborted();
|
|
81322
81417
|
const inventory = await discover(signal);
|
|
81323
81418
|
signal.throwIfAborted();
|
|
81324
|
-
const
|
|
81325
|
-
|
|
81326
|
-
|
|
81327
|
-
|
|
81328
|
-
|
|
81329
|
-
|
|
81330
|
-
|
|
81331
|
-
|
|
81332
|
-
|
|
81333
|
-
|
|
81334
|
-
|
|
81335
|
-
} catch (error62) {
|
|
81336
|
-
config2.catalog.transition(previous.agents);
|
|
81337
|
-
throw error62;
|
|
81338
|
-
}
|
|
81419
|
+
const rediscovered = inventory.readyAgents().filter((ready) => ready.id === agent.id).map((ready) => withRuntimeEnvironment(ready, config2.localContext.environment));
|
|
81420
|
+
await config2.catalog.replaceAndPublish(
|
|
81421
|
+
(current) => {
|
|
81422
|
+
if (!current.some((entry) => entry.id === agent.id)) {
|
|
81423
|
+
throw new Error(`The local Agent ${agent.id} left the catalog before its refresh completed`);
|
|
81424
|
+
}
|
|
81425
|
+
return [...current.filter((entry) => entry.id !== agent.id), ...rediscovered];
|
|
81426
|
+
},
|
|
81427
|
+
(publishSignal) => publish(config2, publishSignal),
|
|
81428
|
+
signal
|
|
81429
|
+
);
|
|
81339
81430
|
return config2.catalog.find(agent.id);
|
|
81340
81431
|
} finally {
|
|
81341
81432
|
swaps.delete(agent.id);
|
|
@@ -82526,7 +82617,12 @@ function buildPairedRuntime(installation, connection, defaultWorkspace, inventor
|
|
|
82526
82617
|
}),
|
|
82527
82618
|
() => config2,
|
|
82528
82619
|
publishAgentCatalog
|
|
82529
|
-
)
|
|
82620
|
+
),
|
|
82621
|
+
(refreshSignal) => discoverLocalAgentInventory({
|
|
82622
|
+
defaultWorkspace,
|
|
82623
|
+
environment: localContext.environment,
|
|
82624
|
+
signal: refreshSignal
|
|
82625
|
+
}).then((inventory2) => inventory2.readyAgents())
|
|
82530
82626
|
);
|
|
82531
82627
|
return {
|
|
82532
82628
|
channelUrl: new URL(`/channels/${encodeURIComponent(connection.channelId)}`, connection.relayOrigin).toString(),
|
|
@@ -97750,6 +97846,169 @@ var init_diagnostics2 = __esm({
|
|
|
97750
97846
|
}
|
|
97751
97847
|
});
|
|
97752
97848
|
|
|
97849
|
+
// src/runtime/command/transport.ts
|
|
97850
|
+
import { WebSocket as WebSocket2 } from "undici";
|
|
97851
|
+
function send(socket, message) {
|
|
97852
|
+
if (socket.readyState !== WebSocket2.OPEN) {
|
|
97853
|
+
throw new Error("Relay connection is not open");
|
|
97854
|
+
}
|
|
97855
|
+
socket.send(encodeDaemonToServiceMessage(message));
|
|
97856
|
+
}
|
|
97857
|
+
function reportOperationFailure(socket, requestId, sessionId, error62, runtimeTimings = []) {
|
|
97858
|
+
if (socket.readyState !== WebSocket2.OPEN) {
|
|
97859
|
+
return;
|
|
97860
|
+
}
|
|
97861
|
+
send(socket, {
|
|
97862
|
+
code: operationErrorCode(error62),
|
|
97863
|
+
kind: "session.operation.failed",
|
|
97864
|
+
message: operationErrorMessage(error62),
|
|
97865
|
+
requestId,
|
|
97866
|
+
...runtimeTimings.length === 0 ? {} : { runtimeTimings },
|
|
97867
|
+
sessionId
|
|
97868
|
+
});
|
|
97869
|
+
}
|
|
97870
|
+
var init_transport = __esm({
|
|
97871
|
+
"src/runtime/command/transport.ts"() {
|
|
97872
|
+
"use strict";
|
|
97873
|
+
init_protocol();
|
|
97874
|
+
init_operation_error();
|
|
97875
|
+
}
|
|
97876
|
+
});
|
|
97877
|
+
|
|
97878
|
+
// src/runtime/catalog/handle-agent-catalog-discovery.ts
|
|
97879
|
+
import { WebSocket as WebSocket3 } from "undici";
|
|
97880
|
+
function discoveredEvent(command, agents) {
|
|
97881
|
+
return {
|
|
97882
|
+
agents: agents.map((agent) => ({
|
|
97883
|
+
agentVersion: agent.agentVersion,
|
|
97884
|
+
id: agent.id,
|
|
97885
|
+
label: agent.label
|
|
97886
|
+
})),
|
|
97887
|
+
kind: "agent.catalog.discovered",
|
|
97888
|
+
requestId: command.requestId
|
|
97889
|
+
};
|
|
97890
|
+
}
|
|
97891
|
+
function createAgentCatalogDiscoveryHandler(dependencies) {
|
|
97892
|
+
const { config: config2, discover, diagnostics, socket, signal, timer } = dependencies;
|
|
97893
|
+
const requestIds = /* @__PURE__ */ new Set();
|
|
97894
|
+
let controller = null;
|
|
97895
|
+
let completion = null;
|
|
97896
|
+
const handle = (command) => {
|
|
97897
|
+
if (requestIds.has(command.requestId) || controller !== null) {
|
|
97898
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
97899
|
+
send(socket, {
|
|
97900
|
+
code: "agent_catalog_discovery_busy",
|
|
97901
|
+
kind: AGENT_CATALOG_DISCOVERY_FAILED_KIND,
|
|
97902
|
+
message: "An Agent catalog discovery is already running",
|
|
97903
|
+
requestId: command.requestId
|
|
97904
|
+
});
|
|
97905
|
+
}
|
|
97906
|
+
return;
|
|
97907
|
+
}
|
|
97908
|
+
controller = new AbortController();
|
|
97909
|
+
requestIds.add(command.requestId);
|
|
97910
|
+
const operationSignal = AbortSignal.any([signal, controller.signal]);
|
|
97911
|
+
const timeout = timer.schedule(
|
|
97912
|
+
() => controller?.abort(new Error("Agent catalog discovery timed out")),
|
|
97913
|
+
CATALOG_DISCOVERY_TIMEOUT_MILLISECONDS
|
|
97914
|
+
);
|
|
97915
|
+
completion = (async () => {
|
|
97916
|
+
try {
|
|
97917
|
+
const readyAgents = await discover(operationSignal);
|
|
97918
|
+
operationSignal.throwIfAborted();
|
|
97919
|
+
const published = await config2.catalog.replaceAndPublish(
|
|
97920
|
+
() => readyAgents.map((agent) => withRuntimeEnvironment(agent, config2.localContext.environment)),
|
|
97921
|
+
(publishSignal) => publishAgentCatalog(config2, publishSignal),
|
|
97922
|
+
operationSignal
|
|
97923
|
+
);
|
|
97924
|
+
operationSignal.throwIfAborted();
|
|
97925
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
97926
|
+
send(
|
|
97927
|
+
socket,
|
|
97928
|
+
discoveredEvent(
|
|
97929
|
+
command,
|
|
97930
|
+
published.agents.map((agent) => ({
|
|
97931
|
+
agentVersion: agent.agentVersion,
|
|
97932
|
+
id: agent.id,
|
|
97933
|
+
label: agent.label
|
|
97934
|
+
}))
|
|
97935
|
+
)
|
|
97936
|
+
);
|
|
97937
|
+
}
|
|
97938
|
+
} catch (error62) {
|
|
97939
|
+
diagnostics.daemonDiagnostic(
|
|
97940
|
+
"agent_catalog_discovery_failed",
|
|
97941
|
+
command.requestId,
|
|
97942
|
+
{ code: operationErrorCode(error62) },
|
|
97943
|
+
error62
|
|
97944
|
+
);
|
|
97945
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
97946
|
+
send(socket, {
|
|
97947
|
+
code: operationErrorCode(error62),
|
|
97948
|
+
kind: AGENT_CATALOG_DISCOVERY_FAILED_KIND,
|
|
97949
|
+
message: operationErrorMessage(error62),
|
|
97950
|
+
requestId: command.requestId
|
|
97951
|
+
});
|
|
97952
|
+
}
|
|
97953
|
+
} finally {
|
|
97954
|
+
timeout.cancel();
|
|
97955
|
+
requestIds.delete(command.requestId);
|
|
97956
|
+
controller = null;
|
|
97957
|
+
completion = null;
|
|
97958
|
+
}
|
|
97959
|
+
})();
|
|
97960
|
+
};
|
|
97961
|
+
const settle2 = async () => {
|
|
97962
|
+
await (completion ?? Promise.resolve());
|
|
97963
|
+
};
|
|
97964
|
+
return { handle, settle: settle2 };
|
|
97965
|
+
}
|
|
97966
|
+
var CATALOG_DISCOVERY_TIMEOUT_MILLISECONDS;
|
|
97967
|
+
var init_handle_agent_catalog_discovery = __esm({
|
|
97968
|
+
"src/runtime/catalog/handle-agent-catalog-discovery.ts"() {
|
|
97969
|
+
"use strict";
|
|
97970
|
+
init_protocol();
|
|
97971
|
+
init_operation_error();
|
|
97972
|
+
init_transport();
|
|
97973
|
+
init_config();
|
|
97974
|
+
init_publish_agent_catalog();
|
|
97975
|
+
CATALOG_DISCOVERY_TIMEOUT_MILLISECONDS = 9e4;
|
|
97976
|
+
}
|
|
97977
|
+
});
|
|
97978
|
+
|
|
97979
|
+
// src/runtime/command/registry/agent-catalog.ts
|
|
97980
|
+
function createAgentCatalogCommands(context) {
|
|
97981
|
+
const handler = createAgentCatalogDiscoveryHandler({
|
|
97982
|
+
config: context.config,
|
|
97983
|
+
discover: context.config.rediscoverAgents === void 0 ? () => {
|
|
97984
|
+
throw new Error("Agent catalog discovery is not available for this Runtime");
|
|
97985
|
+
} : context.config.rediscoverAgents,
|
|
97986
|
+
diagnostics: context.diagnostics,
|
|
97987
|
+
socket: context.socket,
|
|
97988
|
+
signal: context.signal,
|
|
97989
|
+
timer: context.timer
|
|
97990
|
+
});
|
|
97991
|
+
return [
|
|
97992
|
+
{
|
|
97993
|
+
kind: AGENT_CATALOG_DISCOVER_KIND,
|
|
97994
|
+
handle: (_context, message) => {
|
|
97995
|
+
if (message.kind !== AGENT_CATALOG_DISCOVER_KIND) {
|
|
97996
|
+
throw new Error("Command kind mismatch");
|
|
97997
|
+
}
|
|
97998
|
+
handler.handle(message);
|
|
97999
|
+
},
|
|
98000
|
+
settle: handler.settle
|
|
98001
|
+
}
|
|
98002
|
+
];
|
|
98003
|
+
}
|
|
98004
|
+
var init_agent_catalog = __esm({
|
|
98005
|
+
"src/runtime/command/registry/agent-catalog.ts"() {
|
|
98006
|
+
"use strict";
|
|
98007
|
+
init_protocol();
|
|
98008
|
+
init_handle_agent_catalog_discovery();
|
|
98009
|
+
}
|
|
98010
|
+
});
|
|
98011
|
+
|
|
97753
98012
|
// src/session/api/session-error.ts
|
|
97754
98013
|
var SessionError;
|
|
97755
98014
|
var init_session_error = __esm({
|
|
@@ -98123,37 +98382,8 @@ var init_discover_agent_settings = __esm({
|
|
|
98123
98382
|
}
|
|
98124
98383
|
});
|
|
98125
98384
|
|
|
98126
|
-
// src/runtime/command/transport.ts
|
|
98127
|
-
import { WebSocket as WebSocket2 } from "undici";
|
|
98128
|
-
function send(socket, message) {
|
|
98129
|
-
if (socket.readyState !== WebSocket2.OPEN) {
|
|
98130
|
-
throw new Error("Relay connection is not open");
|
|
98131
|
-
}
|
|
98132
|
-
socket.send(encodeDaemonToServiceMessage(message));
|
|
98133
|
-
}
|
|
98134
|
-
function reportOperationFailure(socket, requestId, sessionId, error62, runtimeTimings = []) {
|
|
98135
|
-
if (socket.readyState !== WebSocket2.OPEN) {
|
|
98136
|
-
return;
|
|
98137
|
-
}
|
|
98138
|
-
send(socket, {
|
|
98139
|
-
code: operationErrorCode(error62),
|
|
98140
|
-
kind: "session.operation.failed",
|
|
98141
|
-
message: operationErrorMessage(error62),
|
|
98142
|
-
requestId,
|
|
98143
|
-
...runtimeTimings.length === 0 ? {} : { runtimeTimings },
|
|
98144
|
-
sessionId
|
|
98145
|
-
});
|
|
98146
|
-
}
|
|
98147
|
-
var init_transport = __esm({
|
|
98148
|
-
"src/runtime/command/transport.ts"() {
|
|
98149
|
-
"use strict";
|
|
98150
|
-
init_protocol();
|
|
98151
|
-
init_operation_error();
|
|
98152
|
-
}
|
|
98153
|
-
});
|
|
98154
|
-
|
|
98155
98385
|
// src/runtime/command/agent-settings-discovery.ts
|
|
98156
|
-
import { WebSocket as
|
|
98386
|
+
import { WebSocket as WebSocket4 } from "undici";
|
|
98157
98387
|
function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
98158
98388
|
const { config: config2, directories, sessions, diagnostics, socket, signal, timer } = dependencies;
|
|
98159
98389
|
const agentSettingsDiscoveries = /* @__PURE__ */ new Map();
|
|
@@ -98162,7 +98392,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
98162
98392
|
(request) => request.agentId === command.agentId && !request.controller.signal.aborted
|
|
98163
98393
|
);
|
|
98164
98394
|
if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
|
|
98165
|
-
if (socket.readyState ===
|
|
98395
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
98166
98396
|
send(socket, {
|
|
98167
98397
|
code: "agent_settings_discovery_busy",
|
|
98168
98398
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -98177,7 +98407,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
98177
98407
|
return;
|
|
98178
98408
|
}
|
|
98179
98409
|
if (existing !== void 0) {
|
|
98180
|
-
if (socket.readyState ===
|
|
98410
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
98181
98411
|
send(socket, {
|
|
98182
98412
|
code: "agent_settings_discovery_busy",
|
|
98183
98413
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -98188,7 +98418,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
98188
98418
|
return;
|
|
98189
98419
|
}
|
|
98190
98420
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
98191
|
-
if (socket.readyState ===
|
|
98421
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
98192
98422
|
send(socket, {
|
|
98193
98423
|
code: "agent_settings_discovery_busy",
|
|
98194
98424
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -98226,7 +98456,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
98226
98456
|
);
|
|
98227
98457
|
}
|
|
98228
98458
|
for (const requestId of requestIds) {
|
|
98229
|
-
if (socket.readyState ===
|
|
98459
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
98230
98460
|
send(socket, { ...result.event, requestId });
|
|
98231
98461
|
}
|
|
98232
98462
|
}
|
|
@@ -98240,7 +98470,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
98240
98470
|
`
|
|
98241
98471
|
);
|
|
98242
98472
|
}
|
|
98243
|
-
if (socket.readyState ===
|
|
98473
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
98244
98474
|
for (const requestId of requestIds) {
|
|
98245
98475
|
send(socket, {
|
|
98246
98476
|
code: operationErrorCode(failure2),
|
|
@@ -98410,7 +98640,7 @@ var init_session_files = __esm({
|
|
|
98410
98640
|
});
|
|
98411
98641
|
|
|
98412
98642
|
// src/runtime/command/registry/file-read/index.ts
|
|
98413
|
-
import { WebSocket as
|
|
98643
|
+
import { WebSocket as WebSocket5 } from "undici";
|
|
98414
98644
|
var fileReadCommand;
|
|
98415
98645
|
var init_file_read = __esm({
|
|
98416
98646
|
"src/runtime/command/registry/file-read/index.ts"() {
|
|
@@ -98431,7 +98661,7 @@ var init_file_read = __esm({
|
|
|
98431
98661
|
sessions.findSessions([message.sessionId])[0]?.cwd ?? null,
|
|
98432
98662
|
externalContent
|
|
98433
98663
|
).catch((error62) => {
|
|
98434
|
-
if (socket.readyState !==
|
|
98664
|
+
if (socket.readyState !== WebSocket5.OPEN || signal.aborted) {
|
|
98435
98665
|
return;
|
|
98436
98666
|
}
|
|
98437
98667
|
send(socket, {
|
|
@@ -98804,7 +99034,7 @@ var init_interactions2 = __esm({
|
|
|
98804
99034
|
});
|
|
98805
99035
|
|
|
98806
99036
|
// src/runtime/command/native-session-requests.ts
|
|
98807
|
-
import { WebSocket as
|
|
99037
|
+
import { WebSocket as WebSocket6 } from "undici";
|
|
98808
99038
|
function createNativeSessionRequestHandler(dependencies) {
|
|
98809
99039
|
const { diagnostics, nativeSessions, signal, socket, timer } = dependencies;
|
|
98810
99040
|
const pending = /* @__PURE__ */ new Map();
|
|
@@ -98856,7 +99086,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
98856
99086
|
}
|
|
98857
99087
|
operationSignal.throwIfAborted();
|
|
98858
99088
|
const result = await nativeSessions.execute(command, operationSignal);
|
|
98859
|
-
if (socket.readyState ===
|
|
99089
|
+
if (socket.readyState === WebSocket6.OPEN) {
|
|
98860
99090
|
send(socket, result);
|
|
98861
99091
|
}
|
|
98862
99092
|
} catch (error62) {
|
|
@@ -100041,6 +100271,7 @@ function createCommandRegistry(context) {
|
|
|
100041
100271
|
sessionHistoryPageLoadCommand,
|
|
100042
100272
|
previewHistoryPageLoadCommand,
|
|
100043
100273
|
...createNativeSessionCommands(context),
|
|
100274
|
+
...createAgentCatalogCommands(context),
|
|
100044
100275
|
...createAgentSettingsCommands(context),
|
|
100045
100276
|
fileReadCommand,
|
|
100046
100277
|
sessionCancelCommand,
|
|
@@ -100072,6 +100303,7 @@ function createCommandRegistry(context) {
|
|
|
100072
100303
|
var init_registry2 = __esm({
|
|
100073
100304
|
"src/runtime/command/registry/index.ts"() {
|
|
100074
100305
|
"use strict";
|
|
100306
|
+
init_agent_catalog();
|
|
100075
100307
|
init_agent_settings();
|
|
100076
100308
|
init_file_read();
|
|
100077
100309
|
init_history2();
|
|
@@ -100119,14 +100351,14 @@ var init_runtime_revocation = __esm({
|
|
|
100119
100351
|
});
|
|
100120
100352
|
|
|
100121
100353
|
// src/runtime/relay/connect.ts
|
|
100122
|
-
import { WebSocket as
|
|
100354
|
+
import { WebSocket as WebSocket7 } from "undici";
|
|
100123
100355
|
function connectRelay(url2, signal) {
|
|
100124
100356
|
signal.throwIfAborted();
|
|
100125
100357
|
return new Promise((resolve20, reject2) => {
|
|
100126
100358
|
const endpoint = new URL(url2);
|
|
100127
100359
|
const headers = relayAuthorization(endpoint);
|
|
100128
100360
|
endpoint.searchParams.delete("token");
|
|
100129
|
-
const socket = new
|
|
100361
|
+
const socket = new WebSocket7(endpoint, {
|
|
100130
100362
|
dispatcher: environmentProxyDispatcher,
|
|
100131
100363
|
headers
|
|
100132
100364
|
});
|
|
@@ -100331,7 +100563,7 @@ var init_liveness2 = __esm({
|
|
|
100331
100563
|
});
|
|
100332
100564
|
|
|
100333
100565
|
// src/runtime/relay/run-relay-connection.ts
|
|
100334
|
-
import { WebSocket as
|
|
100566
|
+
import { WebSocket as WebSocket8 } from "undici";
|
|
100335
100567
|
function closeRelaySocket(socket, code, reason) {
|
|
100336
100568
|
try {
|
|
100337
100569
|
socket.close(code, reason);
|
|
@@ -100362,7 +100594,7 @@ function readCommandCorrelation(encoded) {
|
|
|
100362
100594
|
};
|
|
100363
100595
|
}
|
|
100364
100596
|
function rejectUnsupportedCommand(socket, correlation, rejection) {
|
|
100365
|
-
if (socket.readyState !==
|
|
100597
|
+
if (socket.readyState !== WebSocket8.OPEN) {
|
|
100366
100598
|
return;
|
|
100367
100599
|
}
|
|
100368
100600
|
send(socket, {
|
|
@@ -100410,7 +100642,7 @@ async function runRelayConnection({
|
|
|
100410
100642
|
timer
|
|
100411
100643
|
});
|
|
100412
100644
|
void reportUpgradeAvailability((result) => {
|
|
100413
|
-
if (socket.readyState ===
|
|
100645
|
+
if (socket.readyState === WebSocket8.OPEN) {
|
|
100414
100646
|
send(socket, result);
|
|
100415
100647
|
}
|
|
100416
100648
|
}, signal).catch((cause) => {
|
|
@@ -100461,14 +100693,14 @@ async function runRelayConnection({
|
|
|
100461
100693
|
};
|
|
100462
100694
|
const connectionLiveness = new RelayConnectionLiveness(timer, {
|
|
100463
100695
|
send: (message) => {
|
|
100464
|
-
if (socket.readyState !==
|
|
100696
|
+
if (socket.readyState !== WebSocket8.OPEN) {
|
|
100465
100697
|
return false;
|
|
100466
100698
|
}
|
|
100467
100699
|
try {
|
|
100468
100700
|
send(socket, message);
|
|
100469
100701
|
return true;
|
|
100470
100702
|
} catch (error62) {
|
|
100471
|
-
if (socket.readyState !==
|
|
100703
|
+
if (socket.readyState !== WebSocket8.OPEN) {
|
|
100472
100704
|
return false;
|
|
100473
100705
|
}
|
|
100474
100706
|
throw error62;
|
|
@@ -100585,7 +100817,7 @@ var init_run_relay_connection = __esm({
|
|
|
100585
100817
|
});
|
|
100586
100818
|
|
|
100587
100819
|
// src/runtime/relay/session-event-publisher.ts
|
|
100588
|
-
import { WebSocket as
|
|
100820
|
+
import { WebSocket as WebSocket9 } from "undici";
|
|
100589
100821
|
var MAX_BUFFERED_BYTES, MAX_PENDING_BYTES2, MAX_EVENT_BATCH_BYTES, MAX_FRAME_BYTES, LOCAL_BACKPRESSURE_CLOSE_CODE, EMPTY_ENVELOPE_BYTES, SESSION_EVENT_BATCH_WINDOW_MILLISECONDS, RuntimeSessionEventPublisher;
|
|
100590
100822
|
var init_session_event_publisher = __esm({
|
|
100591
100823
|
"src/runtime/relay/session-event-publisher.ts"() {
|
|
@@ -100640,7 +100872,7 @@ var init_session_event_publisher = __esm({
|
|
|
100640
100872
|
publishClosed = (event) => this.#send(event);
|
|
100641
100873
|
#send = (message) => {
|
|
100642
100874
|
const connection = this.#connection;
|
|
100643
|
-
if (connection.kind !== "connected" || connection.socket.readyState !==
|
|
100875
|
+
if (connection.kind !== "connected" || connection.socket.readyState !== WebSocket9.OPEN) {
|
|
100644
100876
|
return;
|
|
100645
100877
|
}
|
|
100646
100878
|
const socket = connection.socket;
|
|
@@ -100691,7 +100923,7 @@ var init_session_event_publisher = __esm({
|
|
|
100691
100923
|
batch.bytes += bytes;
|
|
100692
100924
|
this.#pendingBytes += additionalBytes;
|
|
100693
100925
|
const connection = this.#connection;
|
|
100694
|
-
if (connection.kind !== "connected" || connection.socket.readyState !==
|
|
100926
|
+
if (connection.kind !== "connected" || connection.socket.readyState !== WebSocket9.OPEN) {
|
|
100695
100927
|
return;
|
|
100696
100928
|
}
|
|
100697
100929
|
const socket = connection.socket;
|
|
@@ -100711,7 +100943,7 @@ var init_session_event_publisher = __esm({
|
|
|
100711
100943
|
flushEvents = (socket) => {
|
|
100712
100944
|
this.cancelFlush();
|
|
100713
100945
|
const connection = this.#connection;
|
|
100714
|
-
if (connection.kind !== "connected" || connection.socket !== socket || socket.readyState !==
|
|
100946
|
+
if (connection.kind !== "connected" || connection.socket !== socket || socket.readyState !== WebSocket9.OPEN) {
|
|
100715
100947
|
return;
|
|
100716
100948
|
}
|
|
100717
100949
|
let attempted = 0;
|