@moxt-ai/mobius 0.0.55 → 0.0.56
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-installation/fixed-installation-executor.d.ts.map +1 -1
- package/dist/agent-installation/fixed-installation-executor.js +19 -20
- package/dist/agent-installation/fixed-installation-executor.js.map +1 -1
- package/dist/cli.js +167 -27
- package/dist/cli.js.map +3 -3
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +12 -2
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +166 -26
- package/dist/index.js.map +3 -3
- package/dist/run-daemon.d.ts +5 -2
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +91 -5
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.d.ts +4 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +166 -26
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -22572,6 +22572,9 @@ var AGENT_INSTALL_CANCELLED_KIND = "agent.integration.install.cancelled";
|
|
|
22572
22572
|
var AGENT_SETTINGS_DISCOVER_KIND = "agent.settings.discover";
|
|
22573
22573
|
var AGENT_SETTINGS_DISCOVERED_KIND = "agent.settings.discovered";
|
|
22574
22574
|
var AGENT_SETTINGS_DISCOVERY_FAILED_KIND = "agent.settings.discovery.failed";
|
|
22575
|
+
var AGENT_CATALOG_REFRESH_KIND = "agent.catalog.refresh";
|
|
22576
|
+
var AGENT_CATALOG_REFRESHED_KIND = "agent.catalog.refreshed";
|
|
22577
|
+
var AGENT_CATALOG_REFRESH_FAILED_KIND = "agent.catalog.refresh.failed";
|
|
22575
22578
|
var FILE_READ_KIND = "file.read";
|
|
22576
22579
|
var FILE_BEGIN_KIND = "file.begin";
|
|
22577
22580
|
var FILE_CHUNK_KIND = "file.chunk";
|
|
@@ -22687,6 +22690,20 @@ var agentSettingsDiscoveryFailedEventSchema = external_exports.strictObject({
|
|
|
22687
22690
|
message: external_exports.string().min(1).max(500),
|
|
22688
22691
|
requestId: IDENTIFIER
|
|
22689
22692
|
}).readonly();
|
|
22693
|
+
var agentCatalogRefreshCommandSchema = external_exports.strictObject({
|
|
22694
|
+
kind: external_exports.literal(AGENT_CATALOG_REFRESH_KIND),
|
|
22695
|
+
requestId: IDENTIFIER
|
|
22696
|
+
}).readonly();
|
|
22697
|
+
var agentCatalogRefreshedEventSchema = external_exports.strictObject({
|
|
22698
|
+
kind: external_exports.literal(AGENT_CATALOG_REFRESHED_KIND),
|
|
22699
|
+
requestId: IDENTIFIER
|
|
22700
|
+
}).readonly();
|
|
22701
|
+
var agentCatalogRefreshFailedEventSchema = external_exports.strictObject({
|
|
22702
|
+
code: IDENTIFIER,
|
|
22703
|
+
kind: external_exports.literal(AGENT_CATALOG_REFRESH_FAILED_KIND),
|
|
22704
|
+
message: external_exports.string().min(1).max(500),
|
|
22705
|
+
requestId: IDENTIFIER
|
|
22706
|
+
}).readonly();
|
|
22690
22707
|
var sessionConfigurationSelectionSchema = external_exports.strictObject({
|
|
22691
22708
|
booleanValue: external_exports.boolean(),
|
|
22692
22709
|
configId: IDENTIFIER,
|
|
@@ -23088,6 +23105,9 @@ var encode3 = (message, schema) => JSON.stringify(decodeValue(message, schema));
|
|
|
23088
23105
|
var decodeAgentSettingsDiscoverCommand = (encoded) => decode3(encoded, agentSettingsDiscoverCommandSchema);
|
|
23089
23106
|
var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
|
|
23090
23107
|
var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
|
|
23108
|
+
var decodeAgentCatalogRefreshCommand = (encoded) => decode3(encoded, agentCatalogRefreshCommandSchema);
|
|
23109
|
+
var encodeAgentCatalogRefreshedEvent = (message) => encode3(message, agentCatalogRefreshedEventSchema);
|
|
23110
|
+
var encodeAgentCatalogRefreshFailedEvent = (message) => encode3(message, agentCatalogRefreshFailedEventSchema);
|
|
23091
23111
|
var decodeFileReadCommand = (encoded) => decode3(encoded, fileReadCommandSchema);
|
|
23092
23112
|
var encodeFileBeginEvent = (message) => encode3(message, fileBeginEventSchema);
|
|
23093
23113
|
var encodeFileChunkEvent = (message) => encode3(message, fileChunkEventSchema);
|
|
@@ -23879,6 +23899,15 @@ var DaemonLocalContext = class {
|
|
|
23879
23899
|
this.environment = Object.freeze({ ...environment, MOBIUS_STATE_DIRECTORY: this.stateDirectory });
|
|
23880
23900
|
}
|
|
23881
23901
|
};
|
|
23902
|
+
function withDaemonEnvironment(agent, environment) {
|
|
23903
|
+
const launchEnvironment = {};
|
|
23904
|
+
for (const [name, value] of Object.entries(environment)) {
|
|
23905
|
+
if (typeof value === "string") {
|
|
23906
|
+
launchEnvironment[name] = value;
|
|
23907
|
+
}
|
|
23908
|
+
}
|
|
23909
|
+
return agent.withEnvironment({ ...launchEnvironment, ...agent.environment });
|
|
23910
|
+
}
|
|
23882
23911
|
var DaemonReconnectTarget = class {
|
|
23883
23912
|
};
|
|
23884
23913
|
var OpaqueDaemonReconnectTarget = class extends DaemonReconnectTarget {
|
|
@@ -23900,12 +23929,13 @@ var ChannelDaemonReconnectTarget = class extends DaemonReconnectTarget {
|
|
|
23900
23929
|
}
|
|
23901
23930
|
};
|
|
23902
23931
|
function createDaemonConfig(connection, agents = [], installableAgents = [], localContext = new DaemonLocalContext(readStateDirectory(), process.env), reconnectTarget = new ChannelDaemonReconnectTarget(connection.channelId)) {
|
|
23932
|
+
const daemonAgents = agents.map((agent) => withDaemonEnvironment(agent, localContext.environment));
|
|
23903
23933
|
return {
|
|
23904
|
-
agents,
|
|
23934
|
+
agents: daemonAgents,
|
|
23905
23935
|
defaultWorkspace: connection.defaultWorkspace,
|
|
23906
23936
|
auditDatabasePath: connection.auditDatabasePath,
|
|
23907
23937
|
bindingId: "workspace",
|
|
23908
|
-
catalog: new LocalAgentCatalog(
|
|
23938
|
+
catalog: new LocalAgentCatalog(daemonAgents, installableAgents),
|
|
23909
23939
|
channelId: connection.channelId,
|
|
23910
23940
|
installableAgents,
|
|
23911
23941
|
localContext,
|
|
@@ -36087,16 +36117,9 @@ var FixedInstallationExecutor = class {
|
|
|
36087
36117
|
};
|
|
36088
36118
|
const initialInventory = await discoverLocalAgentInventory({
|
|
36089
36119
|
...discoveryOptions,
|
|
36090
|
-
specifications:
|
|
36120
|
+
specifications: [specification]
|
|
36091
36121
|
});
|
|
36092
|
-
|
|
36093
|
-
this.#catalog.transition(initialInventory.readyAgents(), initialInventory.installable);
|
|
36094
|
-
try {
|
|
36095
|
-
await this.#publishCatalog(signal);
|
|
36096
|
-
} catch (error62) {
|
|
36097
|
-
this.#catalog.transition(previous2.agents, previous2.installableAgents);
|
|
36098
|
-
throw error62;
|
|
36099
|
-
}
|
|
36122
|
+
await this.#publishDiscoveredAgent(agentId, initialInventory, this.#environment, signal);
|
|
36100
36123
|
const alreadyReady = initialInventory.available.find((candidate) => candidate.specification.id === agentId);
|
|
36101
36124
|
if (alreadyReady instanceof AvailableAgent) {
|
|
36102
36125
|
return;
|
|
@@ -36149,7 +36172,7 @@ var FixedInstallationExecutor = class {
|
|
|
36149
36172
|
defaultWorkspace: this.#defaultWorkspace,
|
|
36150
36173
|
environment,
|
|
36151
36174
|
signal,
|
|
36152
|
-
specifications:
|
|
36175
|
+
specifications: [specification]
|
|
36153
36176
|
});
|
|
36154
36177
|
const verified = inventory.available.find((candidate) => candidate.specification.id === agentId);
|
|
36155
36178
|
if (verified instanceof AvailableAgent) {
|
|
@@ -36157,14 +36180,7 @@ var FixedInstallationExecutor = class {
|
|
|
36157
36180
|
adapterVersion: verified.agent.adapterVersion,
|
|
36158
36181
|
agentVersion: verified.agent.agentVersion
|
|
36159
36182
|
});
|
|
36160
|
-
|
|
36161
|
-
this.#catalog.transition(inventory.readyAgents(), inventory.installable);
|
|
36162
|
-
try {
|
|
36163
|
-
await this.#publishCatalog(signal);
|
|
36164
|
-
} catch (error62) {
|
|
36165
|
-
this.#catalog.transition(previousCatalog.agents, previousCatalog.installableAgents);
|
|
36166
|
-
throw error62;
|
|
36167
|
-
}
|
|
36183
|
+
await this.#publishDiscoveredAgent(agentId, inventory, environment, signal);
|
|
36168
36184
|
return;
|
|
36169
36185
|
}
|
|
36170
36186
|
const unavailable = inventory.unavailable.find((candidate) => candidate.specification.id === agentId);
|
|
@@ -36192,6 +36208,22 @@ var FixedInstallationExecutor = class {
|
|
|
36192
36208
|
throw translateExecutionError(error62);
|
|
36193
36209
|
}
|
|
36194
36210
|
};
|
|
36211
|
+
#publishDiscoveredAgent = async (agentId, inventory, environment, signal) => {
|
|
36212
|
+
const previous2 = this.#catalog.read();
|
|
36213
|
+
this.#catalog.transition(
|
|
36214
|
+
[
|
|
36215
|
+
...previous2.agents.filter((agent) => agent.id !== agentId),
|
|
36216
|
+
...inventory.readyAgents().map((agent) => withDaemonEnvironment(agent, environment))
|
|
36217
|
+
],
|
|
36218
|
+
[...previous2.installableAgents.filter((agent) => agent.id !== agentId), ...inventory.installable]
|
|
36219
|
+
);
|
|
36220
|
+
try {
|
|
36221
|
+
await this.#publishCatalog(signal);
|
|
36222
|
+
} catch (error62) {
|
|
36223
|
+
this.#catalog.transition(previous2.agents, previous2.installableAgents);
|
|
36224
|
+
throw error62;
|
|
36225
|
+
}
|
|
36226
|
+
};
|
|
36195
36227
|
};
|
|
36196
36228
|
|
|
36197
36229
|
// src/artifacts/local-file-streamer.ts
|
|
@@ -40028,7 +40060,28 @@ async function installDetectedAgentIntegrations(config2, installations, signal)
|
|
|
40028
40060
|
);
|
|
40029
40061
|
}
|
|
40030
40062
|
}
|
|
40031
|
-
async function
|
|
40063
|
+
async function refreshAgentCatalog(config2, resolveEnvironment, signal) {
|
|
40064
|
+
signal.throwIfAborted();
|
|
40065
|
+
const environment = await resolveEnvironment(signal);
|
|
40066
|
+
signal.throwIfAborted();
|
|
40067
|
+
const inventory = await discoverLocalAgentInventory({
|
|
40068
|
+
defaultWorkspace: config2.defaultWorkspace,
|
|
40069
|
+
environment,
|
|
40070
|
+
signal
|
|
40071
|
+
});
|
|
40072
|
+
const previousCatalog = config2.catalog.read();
|
|
40073
|
+
config2.catalog.transition(
|
|
40074
|
+
inventory.readyAgents().map((agent) => withDaemonEnvironment(agent, environment)),
|
|
40075
|
+
inventory.installable
|
|
40076
|
+
);
|
|
40077
|
+
try {
|
|
40078
|
+
await publishAgentCatalog(config2, signal);
|
|
40079
|
+
} catch (error62) {
|
|
40080
|
+
config2.catalog.transition(previousCatalog.agents, previousCatalog.installableAgents);
|
|
40081
|
+
throw error62;
|
|
40082
|
+
}
|
|
40083
|
+
}
|
|
40084
|
+
async function runRelayConnection(config2, directories, audit, sessions, installations, installationObserver, nativeSessions, outbox, publisher, activeTurns, activeAttemptIds, connectionEpoch, diagnostics, onConnected, signal, timer, resolveAgentCatalogEnvironment) {
|
|
40032
40085
|
const relayUrl = new URL(config2.relayUrl);
|
|
40033
40086
|
relayUrl.searchParams.set("deliveryReceipts", "1");
|
|
40034
40087
|
relayUrl.searchParams.set("liveness", "1");
|
|
@@ -40038,6 +40091,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40038
40091
|
const connectionController = new AbortController();
|
|
40039
40092
|
const nativeRequests = /* @__PURE__ */ new Map();
|
|
40040
40093
|
const agentSettingsDiscoveries = /* @__PURE__ */ new Map();
|
|
40094
|
+
const agentCatalogRefreshes = /* @__PURE__ */ new Map();
|
|
40041
40095
|
installationObserver.connect(socket);
|
|
40042
40096
|
onConnected();
|
|
40043
40097
|
try {
|
|
@@ -40489,6 +40543,82 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40489
40543
|
});
|
|
40490
40544
|
return;
|
|
40491
40545
|
}
|
|
40546
|
+
if (kind === AGENT_CATALOG_REFRESH_KIND) {
|
|
40547
|
+
const command2 = decodeAgentCatalogRefreshCommand(encoded);
|
|
40548
|
+
if (agentCatalogRefreshes.has(command2.requestId) || agentCatalogRefreshes.size > 0) {
|
|
40549
|
+
if (socket.readyState === WebSocket2.OPEN) {
|
|
40550
|
+
send(
|
|
40551
|
+
socket,
|
|
40552
|
+
encodeAgentCatalogRefreshFailedEvent({
|
|
40553
|
+
code: "agent_catalog_refresh_busy",
|
|
40554
|
+
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
40555
|
+
message: "Another local Agent catalog refresh is already running",
|
|
40556
|
+
requestId: command2.requestId
|
|
40557
|
+
})
|
|
40558
|
+
);
|
|
40559
|
+
}
|
|
40560
|
+
return;
|
|
40561
|
+
}
|
|
40562
|
+
const controller = new AbortController();
|
|
40563
|
+
const operationSignal = AbortSignal.any([connectionController.signal, controller.signal]);
|
|
40564
|
+
const timeout = timer.schedule(
|
|
40565
|
+
() => controller.abort(
|
|
40566
|
+
new AcpExecutionError(
|
|
40567
|
+
"The local Agent catalog refresh timed out",
|
|
40568
|
+
{},
|
|
40569
|
+
"agent_catalog_refresh_timeout"
|
|
40570
|
+
)
|
|
40571
|
+
),
|
|
40572
|
+
9e4
|
|
40573
|
+
);
|
|
40574
|
+
const completion = (async () => {
|
|
40575
|
+
try {
|
|
40576
|
+
await refreshAgentCatalog(config2, resolveAgentCatalogEnvironment, operationSignal);
|
|
40577
|
+
audit.record({
|
|
40578
|
+
commandId: command2.requestId,
|
|
40579
|
+
event: "agent_catalog_refreshed",
|
|
40580
|
+
sessionId: "agent-catalog"
|
|
40581
|
+
});
|
|
40582
|
+
if (socket.readyState === WebSocket2.OPEN) {
|
|
40583
|
+
send(
|
|
40584
|
+
socket,
|
|
40585
|
+
encodeAgentCatalogRefreshedEvent({
|
|
40586
|
+
kind: AGENT_CATALOG_REFRESHED_KIND,
|
|
40587
|
+
requestId: command2.requestId
|
|
40588
|
+
})
|
|
40589
|
+
);
|
|
40590
|
+
}
|
|
40591
|
+
} catch (error62) {
|
|
40592
|
+
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
40593
|
+
"The local Agent catalog refresh was cancelled",
|
|
40594
|
+
{},
|
|
40595
|
+
"agent_catalog_refresh_cancelled"
|
|
40596
|
+
) : error62;
|
|
40597
|
+
audit.record({
|
|
40598
|
+
commandId: command2.requestId,
|
|
40599
|
+
details: { code: operationErrorCode(failure2) },
|
|
40600
|
+
event: "agent_catalog_refresh_failed",
|
|
40601
|
+
sessionId: "agent-catalog"
|
|
40602
|
+
});
|
|
40603
|
+
if (socket.readyState === WebSocket2.OPEN) {
|
|
40604
|
+
send(
|
|
40605
|
+
socket,
|
|
40606
|
+
encodeAgentCatalogRefreshFailedEvent({
|
|
40607
|
+
code: operationErrorCode(failure2),
|
|
40608
|
+
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
40609
|
+
message: operationErrorMessage(failure2),
|
|
40610
|
+
requestId: command2.requestId
|
|
40611
|
+
})
|
|
40612
|
+
);
|
|
40613
|
+
}
|
|
40614
|
+
} finally {
|
|
40615
|
+
timeout.cancel();
|
|
40616
|
+
agentCatalogRefreshes.delete(command2.requestId);
|
|
40617
|
+
}
|
|
40618
|
+
})();
|
|
40619
|
+
agentCatalogRefreshes.set(command2.requestId, { completion, controller });
|
|
40620
|
+
return;
|
|
40621
|
+
}
|
|
40492
40622
|
if (kind === NATIVE_SESSION_REQUEST_KIND) {
|
|
40493
40623
|
const command2 = decodeNativeSessionCommand(encoded);
|
|
40494
40624
|
const previous2 = [...nativeRequests.values()].filter(
|
|
@@ -40860,11 +40990,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
40860
40990
|
connectionController.abort();
|
|
40861
40991
|
await Promise.all([
|
|
40862
40992
|
...[...nativeRequests.values()].map((request) => request.completion),
|
|
40863
|
-
...[...agentSettingsDiscoveries.values()].map((request) => request.completion)
|
|
40993
|
+
...[...agentSettingsDiscoveries.values()].map((request) => request.completion),
|
|
40994
|
+
...[...agentCatalogRefreshes.values()].map((request) => request.completion)
|
|
40864
40995
|
]);
|
|
40865
40996
|
}
|
|
40866
40997
|
}
|
|
40867
|
-
async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
40998
|
+
async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, options = {}) {
|
|
40868
40999
|
const installationAudit = new AuditInstallationEvents(audit);
|
|
40869
41000
|
const stateDirectory = config2.localContext.stateDirectory;
|
|
40870
41001
|
const specifications = supportedLocalAgentSpecifications();
|
|
@@ -40906,6 +41037,10 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
|
40906
41037
|
let connectionAnnounced = false;
|
|
40907
41038
|
let catalogPublished = false;
|
|
40908
41039
|
let readinessAnnounced = false;
|
|
41040
|
+
const resolveAgentCatalogEnvironment = options.resolveAgentCatalogEnvironment ?? (async (catalogSignal) => {
|
|
41041
|
+
catalogSignal.throwIfAborted();
|
|
41042
|
+
return config2.localContext.environment;
|
|
41043
|
+
});
|
|
40909
41044
|
const startAutomaticIntegrationProvisioning = () => {
|
|
40910
41045
|
if (!connectionAnnounced || !catalogPublished || automaticIntegrationProvisioningStarted) {
|
|
40911
41046
|
return;
|
|
@@ -40971,7 +41106,8 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
|
40971
41106
|
diagnostics,
|
|
40972
41107
|
announceConnection,
|
|
40973
41108
|
signal,
|
|
40974
|
-
timer
|
|
41109
|
+
timer,
|
|
41110
|
+
resolveAgentCatalogEnvironment
|
|
40975
41111
|
);
|
|
40976
41112
|
} catch (error62) {
|
|
40977
41113
|
if (signal.aborted) {
|
|
@@ -41897,10 +42033,12 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
|
|
|
41897
42033
|
}
|
|
41898
42034
|
var MobiusRuntimeEngine = class {
|
|
41899
42035
|
#config;
|
|
42036
|
+
#options;
|
|
41900
42037
|
#state = new IdleMobiusRuntimeState();
|
|
41901
|
-
constructor(config2) {
|
|
42038
|
+
constructor(config2, options = {}) {
|
|
41902
42039
|
validateRuntimeConfiguration(config2);
|
|
41903
42040
|
this.#config = config2;
|
|
42041
|
+
this.#options = options;
|
|
41904
42042
|
}
|
|
41905
42043
|
run = async (signal) => {
|
|
41906
42044
|
if (!(this.#state instanceof IdleMobiusRuntimeState)) {
|
|
@@ -41910,7 +42048,9 @@ var MobiusRuntimeEngine = class {
|
|
|
41910
42048
|
this.#state = new RunningMobiusRuntimeState();
|
|
41911
42049
|
const audit = new AuditStore(this.#config.auditDatabasePath);
|
|
41912
42050
|
try {
|
|
41913
|
-
await runDaemon(this.#config, audit, signal
|
|
42051
|
+
await runDaemon(this.#config, audit, signal, void 0, {
|
|
42052
|
+
...this.#options.resolveAgentCatalogEnvironment === void 0 ? {} : { resolveAgentCatalogEnvironment: this.#options.resolveAgentCatalogEnvironment }
|
|
42053
|
+
});
|
|
41914
42054
|
} finally {
|
|
41915
42055
|
audit.close();
|
|
41916
42056
|
this.#state = new FinishedMobiusRuntimeState();
|