@moxt-ai/mobius 0.0.38 → 0.0.40
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/agent-discovery.d.ts +2 -2
- package/dist/agent-catalog/agent-discovery.d.ts.map +1 -1
- package/dist/agent-catalog/agent-discovery.js +3 -2
- package/dist/agent-catalog/agent-discovery.js.map +1 -1
- package/dist/agent-catalog/agents/grok-build-agent.d.ts +1 -1
- package/dist/agent-catalog/agents/grok-build-agent.d.ts.map +1 -1
- package/dist/agent-catalog/agents/grok-build-agent.js +18 -8
- package/dist/agent-catalog/agents/grok-build-agent.js.map +1 -1
- package/dist/agent-catalog/discover-agent.js +1 -1
- package/dist/agent-catalog/discover-agent.js.map +1 -1
- package/dist/agent-catalog/discover-local-agents.d.ts +0 -1
- package/dist/agent-catalog/discover-local-agents.d.ts.map +1 -1
- package/dist/agent-catalog/discover-local-agents.js +0 -1
- package/dist/agent-catalog/discover-local-agents.js.map +1 -1
- package/dist/agent-installation/fixed-installation-executor.js +2 -2
- package/dist/agent-installation/fixed-installation-executor.js.map +1 -1
- package/dist/cli.js +200 -94
- package/dist/cli.js.map +3 -3
- package/dist/index.js +197 -91
- package/dist/index.js.map +3 -3
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +131 -66
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +199 -93
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
package/dist/run-daemon.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-daemon.d.ts","sourceRoot":"","sources":["../src/run-daemon.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run-daemon.d.ts","sourceRoot":"","sources":["../src/run-daemon.ts"],"names":[],"mappings":"AAgJA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAQzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAUhD,OAAO,EAA4B,KAAK,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AA+6E5G,wBAAsB,SAAS,CAC3B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,WAAW,EACnB,KAAK,GAAE,WAA+B,GACvC,OAAO,CAAC,IAAI,CAAC,CAqKf"}
|
package/dist/run-daemon.js
CHANGED
|
@@ -6,7 +6,7 @@ import { fetch, WebSocket } from "undici";
|
|
|
6
6
|
import { AcpExecutionError, AcpSessionManager } from "./acp/session-manager.js";
|
|
7
7
|
import { SqliteAcpSessionStore } from "./acp/session-store.js";
|
|
8
8
|
import { supportedLocalAgentSpecifications } from "./agent-catalog/discover-local-agents.js";
|
|
9
|
-
import { LocalAgentCatalogError, LocalAgentDefinition } from "./agent-catalog/local-agent.js";
|
|
9
|
+
import { AgentIntegrationDefinition, LocalAgentCatalogError, LocalAgentDefinition, } from "./agent-catalog/local-agent.js";
|
|
10
10
|
import { publishAgentCatalog } from "./agent-catalog/publish-agent-catalog.js";
|
|
11
11
|
import { AgentInstallationManager, CancelledInstallation, FailedInstallation, RequestedInstallation, RunningInstallation, SucceededInstallation, } from "./agent-installation/agent-installation-manager.js";
|
|
12
12
|
import { FixedInstallationExecutor } from "./agent-installation/fixed-installation-executor.js";
|
|
@@ -895,32 +895,9 @@ async function executeBotPrompt(outbox, publisher, command, config, directories,
|
|
|
895
895
|
}
|
|
896
896
|
const attachments = await resolvePromptArtifacts(config, command, signal);
|
|
897
897
|
const applied = await applicator.apply(command, grant, attachments.resources, signal);
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
const executionSignal = AbortSignal.any([signal, deadlineSignal]);
|
|
902
|
-
const agent = botExecutionAgent(grant.agent, lease.context.contextHandle, ipc.socketPath);
|
|
903
|
-
await sessions.prepareExecutionSession({
|
|
904
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
905
|
-
agent,
|
|
906
|
-
cwd: resolved.cwd,
|
|
907
|
-
sessionId: command.sessionId,
|
|
908
|
-
signal: executionSignal,
|
|
909
|
-
});
|
|
910
|
-
for (const selection of command.sessionConfigurations) {
|
|
911
|
-
await sessions.configureSession({
|
|
912
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
913
|
-
agent,
|
|
914
|
-
booleanValue: selection.booleanValue,
|
|
915
|
-
configId: selection.configId,
|
|
916
|
-
cwd: resolved.cwd,
|
|
917
|
-
requestId: `cfg_${randomUUID()}`,
|
|
918
|
-
sessionId: command.sessionId,
|
|
919
|
-
signal: executionSignal,
|
|
920
|
-
value: selection.value,
|
|
921
|
-
valueType: selection.valueType,
|
|
922
|
-
});
|
|
923
|
-
}
|
|
898
|
+
const deadlineSignal = AbortSignal.timeout(remaining);
|
|
899
|
+
const executionSignal = AbortSignal.any([signal, deadlineSignal]);
|
|
900
|
+
const startExecution = () => {
|
|
924
901
|
audit.record({
|
|
925
902
|
commandId: command.commandId,
|
|
926
903
|
details: {
|
|
@@ -941,46 +918,97 @@ async function executeBotPrompt(outbox, publisher, command, config, directories,
|
|
|
941
918
|
sessionId: command.sessionId,
|
|
942
919
|
}), attemptId);
|
|
943
920
|
activateAttempt();
|
|
944
|
-
|
|
921
|
+
};
|
|
922
|
+
let stopReason = "steered";
|
|
923
|
+
if (command.disposition === SessionPromptDisposition.Steer) {
|
|
924
|
+
startExecution();
|
|
925
|
+
await sessions.steerPrompt({
|
|
945
926
|
additionalDirectories: resolved.additionalDirectories,
|
|
946
|
-
agent,
|
|
927
|
+
agent: grant.agent,
|
|
947
928
|
commandId: command.commandId,
|
|
948
929
|
cwd: resolved.cwd,
|
|
949
930
|
images: attachments.images,
|
|
950
|
-
onActivity: activities.record,
|
|
951
|
-
onText: (text, messageId) => {
|
|
952
|
-
publisher.recordAttempt(command.sessionId, encodeAgentMessageDeltaEvent({
|
|
953
|
-
commandId: command.commandId,
|
|
954
|
-
kind: AGENT_MESSAGE_DELTA_KIND,
|
|
955
|
-
messageId,
|
|
956
|
-
sessionId: command.sessionId,
|
|
957
|
-
text,
|
|
958
|
-
}), attemptId);
|
|
959
|
-
return Promise.resolve();
|
|
960
|
-
},
|
|
961
931
|
prompt: command.prompt,
|
|
962
932
|
resources: applied.resources,
|
|
963
933
|
sessionId: command.sessionId,
|
|
964
934
|
signal: executionSignal,
|
|
965
|
-
|
|
966
|
-
activities.flush();
|
|
967
|
-
publisher.recordAttempt(command.sessionId, encodeSessionCompletedEvent({
|
|
968
|
-
commandId: command.commandId,
|
|
969
|
-
kind: SESSION_COMPLETED_KIND,
|
|
970
|
-
sessionId: command.sessionId,
|
|
971
|
-
stopReason: result.stopReason,
|
|
972
|
-
}), attemptId);
|
|
973
|
-
outbox.transitionExecution(command.commandId, result.stopReason === "cancelled" ? "cancelled" : "succeeded");
|
|
974
|
-
audit.record({
|
|
975
|
-
commandId: command.commandId,
|
|
976
|
-
details: { botId: command.botId, executionId: command.executionId },
|
|
977
|
-
event: result.stopReason === "cancelled" ? "bot_session_cancelled" : "bot_session_completed",
|
|
978
|
-
sessionId: command.sessionId,
|
|
935
|
+
targetCommandId: command.targetCommandId,
|
|
979
936
|
});
|
|
980
937
|
}
|
|
981
|
-
|
|
982
|
-
|
|
938
|
+
else {
|
|
939
|
+
if (command.disposition === SessionPromptDisposition.Queue &&
|
|
940
|
+
!outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
|
|
941
|
+
throw new AcpExecutionError("The queued Bot prompt target is unavailable", {}, "prompt_queue_target_unavailable");
|
|
942
|
+
}
|
|
943
|
+
const lease = contexts.activate(command);
|
|
944
|
+
try {
|
|
945
|
+
const agent = botExecutionAgent(grant.agent, lease.context.contextHandle, ipc.socketPath);
|
|
946
|
+
await sessions.prepareExecutionSession({
|
|
947
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
948
|
+
agent,
|
|
949
|
+
cwd: resolved.cwd,
|
|
950
|
+
sessionId: command.sessionId,
|
|
951
|
+
signal: executionSignal,
|
|
952
|
+
});
|
|
953
|
+
for (const selection of command.sessionConfigurations) {
|
|
954
|
+
await sessions.configureSession({
|
|
955
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
956
|
+
agent,
|
|
957
|
+
booleanValue: selection.booleanValue,
|
|
958
|
+
configId: selection.configId,
|
|
959
|
+
cwd: resolved.cwd,
|
|
960
|
+
requestId: `cfg_${randomUUID()}`,
|
|
961
|
+
sessionId: command.sessionId,
|
|
962
|
+
signal: executionSignal,
|
|
963
|
+
value: selection.value,
|
|
964
|
+
valueType: selection.valueType,
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
startExecution();
|
|
968
|
+
const result = await sessions.runPrompt({
|
|
969
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
970
|
+
agent,
|
|
971
|
+
commandId: command.commandId,
|
|
972
|
+
cwd: resolved.cwd,
|
|
973
|
+
disposition: command.disposition,
|
|
974
|
+
images: attachments.images,
|
|
975
|
+
onActivity: activities.record,
|
|
976
|
+
onText: (text, messageId) => {
|
|
977
|
+
publisher.recordAttempt(command.sessionId, encodeAgentMessageDeltaEvent({
|
|
978
|
+
commandId: command.commandId,
|
|
979
|
+
kind: AGENT_MESSAGE_DELTA_KIND,
|
|
980
|
+
messageId,
|
|
981
|
+
sessionId: command.sessionId,
|
|
982
|
+
text,
|
|
983
|
+
}), attemptId);
|
|
984
|
+
return Promise.resolve();
|
|
985
|
+
},
|
|
986
|
+
prompt: command.prompt,
|
|
987
|
+
resources: applied.resources,
|
|
988
|
+
sessionId: command.sessionId,
|
|
989
|
+
signal: executionSignal,
|
|
990
|
+
targetCommandId: command.targetCommandId,
|
|
991
|
+
});
|
|
992
|
+
stopReason = result.stopReason;
|
|
993
|
+
}
|
|
994
|
+
finally {
|
|
995
|
+
lease.release();
|
|
996
|
+
}
|
|
983
997
|
}
|
|
998
|
+
activities.flush();
|
|
999
|
+
publisher.recordAttempt(command.sessionId, encodeSessionCompletedEvent({
|
|
1000
|
+
commandId: command.commandId,
|
|
1001
|
+
kind: SESSION_COMPLETED_KIND,
|
|
1002
|
+
sessionId: command.sessionId,
|
|
1003
|
+
stopReason,
|
|
1004
|
+
}), attemptId);
|
|
1005
|
+
outbox.transitionExecution(command.commandId, stopReason === "cancelled" ? "cancelled" : "succeeded");
|
|
1006
|
+
audit.record({
|
|
1007
|
+
commandId: command.commandId,
|
|
1008
|
+
details: { botId: command.botId, executionId: command.executionId },
|
|
1009
|
+
event: stopReason === "cancelled" ? "bot_session_cancelled" : "bot_session_completed",
|
|
1010
|
+
sessionId: command.sessionId,
|
|
1011
|
+
});
|
|
984
1012
|
}
|
|
985
1013
|
catch (error) {
|
|
986
1014
|
activities.flush();
|
|
@@ -1045,6 +1073,19 @@ async function publishAgentCatalogUntilAvailable(config, diagnostics, signal, ti
|
|
|
1045
1073
|
}
|
|
1046
1074
|
}
|
|
1047
1075
|
}
|
|
1076
|
+
async function installDetectedAgentIntegrations(config, installations, signal) {
|
|
1077
|
+
for (const agent of config.catalog.read().installableAgents) {
|
|
1078
|
+
if (!(agent instanceof AgentIntegrationDefinition)) {
|
|
1079
|
+
continue;
|
|
1080
|
+
}
|
|
1081
|
+
signal.throwIfAborted();
|
|
1082
|
+
await installations.request({
|
|
1083
|
+
agentId: agent.id,
|
|
1084
|
+
kind: AGENT_INSTALL_REQUEST_KIND,
|
|
1085
|
+
requestId: `automatic-integration-${randomUUID()}`,
|
|
1086
|
+
}, signal);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1048
1089
|
async function runRelayConnection(config, directories, audit, sessions, installations, installationObserver, nativeSessions, outbox, publisher, grants, contexts, applicator, ipc, activeTurns, activeAttemptIds, connectionEpoch, diagnostics, onConnected, signal, timer) {
|
|
1049
1090
|
const relayUrl = new URL(config.relayUrl);
|
|
1050
1091
|
relayUrl.searchParams.set("deliveryReceipts", "1");
|
|
@@ -1052,11 +1093,11 @@ async function runRelayConnection(config, directories, audit, sessions, installa
|
|
|
1052
1093
|
const socket = await connectRelay(relayUrl, signal);
|
|
1053
1094
|
const reconnectingTurns = [...activeTurns.values()];
|
|
1054
1095
|
diagnostics.connectionOpened(connectionEpoch);
|
|
1055
|
-
onConnected();
|
|
1056
1096
|
const connectionController = new AbortController();
|
|
1057
1097
|
const nativeRequests = new Map();
|
|
1058
1098
|
const agentSettingsDiscoveries = new Map();
|
|
1059
1099
|
installationObserver.connect(socket);
|
|
1100
|
+
onConnected();
|
|
1060
1101
|
try {
|
|
1061
1102
|
await new Promise((resolve, reject) => {
|
|
1062
1103
|
let finished = false;
|
|
@@ -1201,7 +1242,7 @@ async function runRelayConnection(config, directories, audit, sessions, installa
|
|
|
1201
1242
|
}
|
|
1202
1243
|
if (kind === BOT_SESSION_PROMPT_KIND) {
|
|
1203
1244
|
const command = decodeBotSessionPromptCommand(delivery.payload);
|
|
1204
|
-
await processDeliveredPrompt(delivery, command,
|
|
1245
|
+
await processDeliveredPrompt(delivery, command, command.disposition !== SessionPromptDisposition.Steer, (attemptId, activateAttempt, executionSignal) => executeBotPrompt(outbox, publisher, command, config, directories, audit, sessions, grants, contexts, applicator, ipc, attemptId, activateAttempt, timer, executionSignal));
|
|
1205
1246
|
return;
|
|
1206
1247
|
}
|
|
1207
1248
|
if (kind === SESSION_PROMPT_KIND) {
|
|
@@ -1704,7 +1745,11 @@ async function runRelayConnection(config, directories, audit, sessions, installa
|
|
|
1704
1745
|
}
|
|
1705
1746
|
const turn = new ActiveDaemonTurn(command, receipt.attemptId);
|
|
1706
1747
|
activeTurns.set(command.commandId, turn);
|
|
1707
|
-
void executeBotPrompt(outbox, publisher, command, config, directories, audit, sessions, grants, contexts, applicator, ipc, receipt.attemptId, () =>
|
|
1748
|
+
void executeBotPrompt(outbox, publisher, command, config, directories, audit, sessions, grants, contexts, applicator, ipc, receipt.attemptId, () => {
|
|
1749
|
+
if (command.disposition !== SessionPromptDisposition.Steer) {
|
|
1750
|
+
activeAttemptIds.set(command.sessionId, receipt.attemptId);
|
|
1751
|
+
}
|
|
1752
|
+
}, timer, turn.signal)
|
|
1708
1753
|
.catch((error) => {
|
|
1709
1754
|
console.error("Mobius daemon Bot turn failed", error);
|
|
1710
1755
|
})
|
|
@@ -1820,9 +1865,22 @@ export async function runDaemon(config, audit, signal, timer = systemDaemonTimer
|
|
|
1820
1865
|
const nativeSessions = new NativeSessionService(config, directories, sessions, audit);
|
|
1821
1866
|
const installations = new AgentInstallationManager(specifications, installationExecutor, installationObserver, installationAudit);
|
|
1822
1867
|
let connectionEpoch = 0;
|
|
1868
|
+
let automaticIntegrationProvisioningStarted = false;
|
|
1869
|
+
let automaticIntegrationProvisioning = Promise.resolve();
|
|
1823
1870
|
let connectionAnnounced = false;
|
|
1824
1871
|
let catalogPublished = false;
|
|
1825
1872
|
let readinessAnnounced = false;
|
|
1873
|
+
const startAutomaticIntegrationProvisioning = () => {
|
|
1874
|
+
if (!connectionAnnounced || !catalogPublished || automaticIntegrationProvisioningStarted) {
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1877
|
+
automaticIntegrationProvisioningStarted = true;
|
|
1878
|
+
automaticIntegrationProvisioning = installDetectedAgentIntegrations(config, installations, signal).catch((error) => {
|
|
1879
|
+
if (!signal.aborted) {
|
|
1880
|
+
console.error("Mobius daemon could not automatically install detected Agent integrations", error);
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1883
|
+
};
|
|
1826
1884
|
const announceReadiness = () => {
|
|
1827
1885
|
if (!connectionAnnounced || !catalogPublished || readinessAnnounced) {
|
|
1828
1886
|
return;
|
|
@@ -1839,6 +1897,7 @@ export async function runDaemon(config, audit, signal, timer = systemDaemonTimer
|
|
|
1839
1897
|
process.stdout.write("Mobius daemon connected to the relay.\n\n");
|
|
1840
1898
|
process.stdout.write(`${styleText(["bold", "yellow"], `Reconnect this channel later:\n ${reconnectCommand}`)}\n\n`);
|
|
1841
1899
|
announceReadiness();
|
|
1900
|
+
startAutomaticIntegrationProvisioning();
|
|
1842
1901
|
};
|
|
1843
1902
|
const catalogPublication = publishAgentCatalogUntilAvailable(config, diagnostics, signal, timer);
|
|
1844
1903
|
void catalogPublication.then(() => {
|
|
@@ -1847,6 +1906,7 @@ export async function runDaemon(config, audit, signal, timer = systemDaemonTimer
|
|
|
1847
1906
|
}
|
|
1848
1907
|
catalogPublished = true;
|
|
1849
1908
|
announceReadiness();
|
|
1909
|
+
startAutomaticIntegrationProvisioning();
|
|
1850
1910
|
});
|
|
1851
1911
|
try {
|
|
1852
1912
|
await ipc.listen(signal);
|
|
@@ -1875,30 +1935,35 @@ export async function runDaemon(config, audit, signal, timer = systemDaemonTimer
|
|
|
1875
1935
|
}
|
|
1876
1936
|
finally {
|
|
1877
1937
|
try {
|
|
1878
|
-
await
|
|
1938
|
+
await automaticIntegrationProvisioning;
|
|
1879
1939
|
}
|
|
1880
1940
|
finally {
|
|
1881
1941
|
try {
|
|
1882
|
-
await
|
|
1942
|
+
await installations.close();
|
|
1883
1943
|
}
|
|
1884
1944
|
finally {
|
|
1885
1945
|
try {
|
|
1886
|
-
await
|
|
1946
|
+
await ipc.close();
|
|
1887
1947
|
}
|
|
1888
1948
|
finally {
|
|
1889
1949
|
try {
|
|
1890
|
-
|
|
1950
|
+
await sessions.close();
|
|
1891
1951
|
}
|
|
1892
1952
|
finally {
|
|
1893
1953
|
try {
|
|
1894
|
-
|
|
1954
|
+
sessionStore.close();
|
|
1895
1955
|
}
|
|
1896
1956
|
finally {
|
|
1897
1957
|
try {
|
|
1898
|
-
|
|
1958
|
+
grants.close();
|
|
1899
1959
|
}
|
|
1900
1960
|
finally {
|
|
1901
|
-
|
|
1961
|
+
try {
|
|
1962
|
+
publisher.close();
|
|
1963
|
+
}
|
|
1964
|
+
finally {
|
|
1965
|
+
outbox.close();
|
|
1966
|
+
}
|
|
1902
1967
|
}
|
|
1903
1968
|
}
|
|
1904
1969
|
}
|