@moxt-ai/mobius 0.0.90 → 0.0.92
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/cli.js +43 -32
- package/dist/cli.js.map +2 -2
- package/dist/daemon-manager.d.ts.map +1 -1
- package/dist/daemon-manager.js +23 -9
- package/dist/daemon-manager.js.map +1 -1
- package/dist/index.js +16 -16
- package/dist/index.js.map +2 -2
- package/dist/pairing/pair-local-machine.d.ts.map +1 -1
- package/dist/pairing/pair-local-machine.js +9 -15
- package/dist/pairing/pair-local-machine.js.map +1 -1
- package/dist/runtime.js +15 -13
- package/dist/runtime.js.map +2 -2
- package/dist/storage/runtime-installation-store.d.ts.map +1 -1
- package/dist/storage/runtime-installation-store.js +10 -8
- package/dist/storage/runtime-installation-store.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3381,7 +3381,7 @@ var program = new Command();
|
|
|
3381
3381
|
// package.json
|
|
3382
3382
|
var package_default = {
|
|
3383
3383
|
name: "@moxt-ai/mobius",
|
|
3384
|
-
version: "0.0.
|
|
3384
|
+
version: "0.0.92",
|
|
3385
3385
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
3386
3386
|
type: "module",
|
|
3387
3387
|
bin: {
|
|
@@ -29786,6 +29786,7 @@ var VERIFIED_CONNECTION_KEYS = [
|
|
|
29786
29786
|
var VERSION_THREE_VERIFIED_CONNECTION_KEYS = VERIFIED_CONNECTION_KEYS.filter(
|
|
29787
29787
|
(key) => key !== "activation"
|
|
29788
29788
|
);
|
|
29789
|
+
var VERSION_FOUR_VERIFIED_CONNECTION_KEYS = VERIFIED_CONNECTION_KEYS;
|
|
29789
29790
|
var VERSION_TWO_VERIFIED_CONNECTION_KEYS = VERSION_THREE_VERIFIED_CONNECTION_KEYS.filter(
|
|
29790
29791
|
(key) => key !== "pairingId"
|
|
29791
29792
|
);
|
|
@@ -29976,16 +29977,17 @@ function decodeChannelIndex(value) {
|
|
|
29976
29977
|
};
|
|
29977
29978
|
}
|
|
29978
29979
|
function decodeVerifiedConnection(value) {
|
|
29979
|
-
const current = hasExactKeys(value, VERIFIED_CONNECTION_KEYS) && value["version"] ===
|
|
29980
|
+
const current = hasExactKeys(value, VERIFIED_CONNECTION_KEYS) && value["version"] === 5;
|
|
29981
|
+
const versionFour = hasExactKeys(value, VERSION_FOUR_VERIFIED_CONNECTION_KEYS) && value["version"] === 4;
|
|
29980
29982
|
const versionThree = hasExactKeys(value, VERSION_THREE_VERIFIED_CONNECTION_KEYS) && value["version"] === 3;
|
|
29981
29983
|
const versionTwo = hasExactKeys(value, VERSION_TWO_VERIFIED_CONNECTION_KEYS) && value["version"] === 2;
|
|
29982
29984
|
const legacy = hasExactKeys(value, LEGACY_VERIFIED_CONNECTION_KEYS) && value["version"] === 1;
|
|
29983
|
-
if (!current && !versionThree && !versionTwo && !legacy || value["kind"] !== "verified") {
|
|
29985
|
+
if (!current && !versionFour && !versionThree && !versionTwo && !legacy || value["kind"] !== "verified") {
|
|
29984
29986
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
29985
29987
|
}
|
|
29986
29988
|
const applicationId = value["applicationId"];
|
|
29987
|
-
const activation = current ? value["activation"] : "active";
|
|
29988
|
-
const appId = typeof value["appId"] === "string" ? value["appId"] : "unknown";
|
|
29989
|
+
const activation = current || versionFour ? value["activation"] : "active";
|
|
29990
|
+
const appId = current && typeof value["appId"] === "string" ? value["appId"] : "unknown";
|
|
29989
29991
|
const channelId = value["channelId"];
|
|
29990
29992
|
const connectionId2 = value["connectionId"];
|
|
29991
29993
|
const defaultWorkspace = value["defaultWorkspace"];
|
|
@@ -29995,7 +29997,7 @@ function decodeVerifiedConnection(value) {
|
|
|
29995
29997
|
const relayOrigin = value["relayOrigin"];
|
|
29996
29998
|
const runtimeCredential2 = value["runtimeCredential"];
|
|
29997
29999
|
const runtimeId = value["runtimeId"];
|
|
29998
|
-
if (typeof applicationId !== "string" || activation !== "active" && activation !== "stopped" || (current || versionThree || versionTwo) && typeof value["appId"] !== "string" || typeof channelId !== "string" || typeof connectionId2 !== "string" || typeof defaultWorkspace !== "string" || typeof storedInstallationId !== "string" || (current || versionThree) && typeof pairingId !== "string" || typeof relayOrigin !== "string" || typeof runtimeCredential2 !== "string" || typeof runtimeId !== "string") {
|
|
30000
|
+
if (typeof applicationId !== "string" || activation !== "active" && activation !== "stopped" || (current || versionFour || versionThree || versionTwo) && typeof value["appId"] !== "string" || typeof channelId !== "string" || typeof connectionId2 !== "string" || typeof defaultWorkspace !== "string" || typeof storedInstallationId !== "string" || (current || versionFour || versionThree) && typeof pairingId !== "string" || typeof relayOrigin !== "string" || typeof runtimeCredential2 !== "string" || typeof runtimeId !== "string") {
|
|
29999
30001
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
30000
30002
|
}
|
|
30001
30003
|
return new VerifiedRuntimeConnection(
|
|
@@ -30006,7 +30008,7 @@ function decodeVerifiedConnection(value) {
|
|
|
30006
30008
|
validateConnectionId(connectionId2),
|
|
30007
30009
|
validateIdentifier(channelId, "invalid_connection"),
|
|
30008
30010
|
defaultWorkspace,
|
|
30009
|
-
(current || versionThree) && savedPairingId.length > 0 ? validateIdentifier(savedPairingId, "invalid_connection") : "",
|
|
30011
|
+
(current || versionFour || versionThree) && savedPairingId.length > 0 ? validateIdentifier(savedPairingId, "invalid_connection") : "",
|
|
30010
30012
|
parseRelayOrigin(relayOrigin),
|
|
30011
30013
|
validateRuntimeCredential(runtimeCredential2),
|
|
30012
30014
|
validateIdentifier(runtimeId, "invalid_connection")
|
|
@@ -30321,7 +30323,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
30321
30323
|
relayOrigin: connection.relayOrigin.toString(),
|
|
30322
30324
|
runtimeCredential: connection.runtimeCredential,
|
|
30323
30325
|
runtimeId: connection.runtimeId,
|
|
30324
|
-
version:
|
|
30326
|
+
version: 5
|
|
30325
30327
|
},
|
|
30326
30328
|
signal
|
|
30327
30329
|
);
|
|
@@ -30384,8 +30386,8 @@ var PAIRING_TIMEOUT_MILLISECONDS = 2e4;
|
|
|
30384
30386
|
var PAIRING_CODE_PATTERN = /^[A-HJ-NP-Z2-9]{4}(?:-[A-HJ-NP-Z2-9]{4}){4}$/;
|
|
30385
30387
|
var IDENTIFIER_PATTERN5 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
30386
30388
|
var TOKEN_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
30387
|
-
var CLAIM_RESPONSE_KEYS = ["channelId", "daemonToken", "runtimeId"];
|
|
30388
|
-
var REDEEM_RESPONSE_KEYS = ["channelId", "runtimeCredential", "runtimeId"];
|
|
30389
|
+
var CLAIM_RESPONSE_KEYS = ["appId", "channelId", "daemonToken", "runtimeId"];
|
|
30390
|
+
var REDEEM_RESPONSE_KEYS = ["appId", "channelId", "runtimeCredential", "runtimeId"];
|
|
30389
30391
|
var MOBIUS_CLI_APPLICATION_ID = "dev.mobius.cli";
|
|
30390
30392
|
var PairingClientError = class extends Error {
|
|
30391
30393
|
code;
|
|
@@ -30423,7 +30425,7 @@ function readSingleOption(arguments_, option) {
|
|
|
30423
30425
|
function assertKnownArguments(arguments_) {
|
|
30424
30426
|
for (let index2 = 0; index2 < arguments_.length; index2 += 2) {
|
|
30425
30427
|
const option = arguments_[index2];
|
|
30426
|
-
if (option !== "--url" && option !== "--code" && option !== "--pairing" && option !== "--workspace"
|
|
30428
|
+
if (option !== "--url" && option !== "--code" && option !== "--pairing" && option !== "--workspace") {
|
|
30427
30429
|
throw new PairingClientError("invalid_arguments", `Unknown pairing option: ${option ?? "missing option"}`);
|
|
30428
30430
|
}
|
|
30429
30431
|
}
|
|
@@ -30462,7 +30464,6 @@ function parsePairingCode(value) {
|
|
|
30462
30464
|
function parsePairCommand(arguments_, defaultWorkspace) {
|
|
30463
30465
|
assertKnownArguments(arguments_);
|
|
30464
30466
|
return {
|
|
30465
|
-
appId: arguments_.includes("--app-id") ? validatePairingId(readSingleOption(arguments_, "--app-id")) : "standalone",
|
|
30466
30467
|
code: parsePairingCode(readSingleOption(arguments_, "--code")),
|
|
30467
30468
|
pairingId: arguments_.includes("--pairing") ? validatePairingId(readSingleOption(arguments_, "--pairing")) : "",
|
|
30468
30469
|
relayOrigin: parseRelayOrigin2(readSingleOption(arguments_, "--url")),
|
|
@@ -30535,13 +30536,14 @@ function decodePairingResponse(value, credentialField, expectedKeys) {
|
|
|
30535
30536
|
if (!isRecord6(value) || !hasExactKeys2(value, expectedKeys)) {
|
|
30536
30537
|
throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
|
|
30537
30538
|
}
|
|
30539
|
+
const appId = value["appId"];
|
|
30538
30540
|
const channelId = value["channelId"];
|
|
30539
30541
|
const runtimeCredential2 = value[credentialField];
|
|
30540
30542
|
const runtimeId = value["runtimeId"];
|
|
30541
|
-
if (typeof channelId !== "string" || !IDENTIFIER_PATTERN5.test(channelId) || typeof runtimeCredential2 !== "string" || !TOKEN_PATTERN.test(runtimeCredential2) || typeof runtimeId !== "string" || !IDENTIFIER_PATTERN5.test(runtimeId)) {
|
|
30543
|
+
if (typeof appId !== "string" || !IDENTIFIER_PATTERN5.test(appId) || typeof channelId !== "string" || !IDENTIFIER_PATTERN5.test(channelId) || typeof runtimeCredential2 !== "string" || !TOKEN_PATTERN.test(runtimeCredential2) || typeof runtimeId !== "string" || !IDENTIFIER_PATTERN5.test(runtimeId)) {
|
|
30542
30544
|
throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
|
|
30543
30545
|
}
|
|
30544
|
-
return { channelId, runtimeCredential: runtimeCredential2, runtimeId };
|
|
30546
|
+
return { appId, channelId, runtimeCredential: runtimeCredential2, runtimeId };
|
|
30545
30547
|
}
|
|
30546
30548
|
async function claimPairing(options, defaultWorkspace, localAgents, installableAgents, signal) {
|
|
30547
30549
|
const agents = localAgents.map((agent) => ({
|
|
@@ -30619,7 +30621,7 @@ async function pairRuntime(installation, options, signal, environment) {
|
|
|
30619
30621
|
const claim2 = await claimPairing(options, defaultWorkspace, agents, inventory.installable, signal);
|
|
30620
30622
|
const connection = await installation.saveConnection(
|
|
30621
30623
|
{
|
|
30622
|
-
appId:
|
|
30624
|
+
appId: claim2.appId,
|
|
30623
30625
|
channelId: claim2.channelId,
|
|
30624
30626
|
defaultWorkspace,
|
|
30625
30627
|
pairingId: options.pairingId,
|
|
@@ -30667,7 +30669,6 @@ async function pairLocalMachine(arguments_, signal = new AbortController().signa
|
|
|
30667
30669
|
return await pairRuntime(
|
|
30668
30670
|
installation,
|
|
30669
30671
|
{
|
|
30670
|
-
appId: requested.appId,
|
|
30671
30672
|
code: requested.code,
|
|
30672
30673
|
pairingId: requested.pairingId,
|
|
30673
30674
|
relayOrigin: requested.relayOrigin,
|
|
@@ -48799,22 +48800,22 @@ async function waitForManagerExit(stateDirectory, signal) {
|
|
|
48799
48800
|
const deadline = AbortSignal.any([signal, AbortSignal.timeout(1e4)]);
|
|
48800
48801
|
while (!deadline.aborted) {
|
|
48801
48802
|
try {
|
|
48802
|
-
await
|
|
48803
|
+
await readFile3(join18(stateDirectory, "manager.lock"), "utf8");
|
|
48803
48804
|
} catch (cause) {
|
|
48804
|
-
if (isNodeError2(cause, "ENOENT")
|
|
48805
|
+
if (isNodeError2(cause, "ENOENT")) {
|
|
48805
48806
|
return;
|
|
48806
48807
|
}
|
|
48808
|
+
throw cause;
|
|
48807
48809
|
}
|
|
48808
48810
|
await new Promise((resolve8, reject) => {
|
|
48809
|
-
const timeout = setTimeout(
|
|
48810
|
-
deadline.
|
|
48811
|
-
|
|
48812
|
-
()
|
|
48813
|
-
|
|
48814
|
-
|
|
48815
|
-
|
|
48816
|
-
|
|
48817
|
-
);
|
|
48811
|
+
const timeout = setTimeout(finish, 20);
|
|
48812
|
+
const abort = () => finish(deadline.reason);
|
|
48813
|
+
function finish(cause) {
|
|
48814
|
+
clearTimeout(timeout);
|
|
48815
|
+
deadline.removeEventListener("abort", abort);
|
|
48816
|
+
cause === void 0 ? resolve8() : reject(cause);
|
|
48817
|
+
}
|
|
48818
|
+
deadline.addEventListener("abort", abort, { once: true });
|
|
48818
48819
|
});
|
|
48819
48820
|
}
|
|
48820
48821
|
throw deadline.reason;
|
|
@@ -48908,6 +48909,7 @@ async function runManager(installation, managerVersion, signal) {
|
|
|
48908
48909
|
const shutdown2 = new AbortController();
|
|
48909
48910
|
const combined = AbortSignal.any([signal, shutdown2.signal]);
|
|
48910
48911
|
const supervisor = new RuntimeSupervisor(installation);
|
|
48912
|
+
const sockets = /* @__PURE__ */ new Set();
|
|
48911
48913
|
try {
|
|
48912
48914
|
await supervisor.restore(combined);
|
|
48913
48915
|
} catch (cause) {
|
|
@@ -48916,6 +48918,8 @@ async function runManager(installation, managerVersion, signal) {
|
|
|
48916
48918
|
`);
|
|
48917
48919
|
}
|
|
48918
48920
|
const server = createServer((socket) => {
|
|
48921
|
+
sockets.add(socket);
|
|
48922
|
+
socket.once("close", () => sockets.delete(socket));
|
|
48919
48923
|
void (async () => {
|
|
48920
48924
|
try {
|
|
48921
48925
|
const request = decodeCommand(await readSocketMessage(socket, combined), token);
|
|
@@ -48939,8 +48943,12 @@ async function runManager(installation, managerVersion, signal) {
|
|
|
48939
48943
|
kind: "pair-removed"
|
|
48940
48944
|
};
|
|
48941
48945
|
} else {
|
|
48942
|
-
|
|
48943
|
-
|
|
48946
|
+
const beginShutdown = () => shutdown2.abort();
|
|
48947
|
+
socket.once("close", beginShutdown);
|
|
48948
|
+
socket.once("error", beginShutdown);
|
|
48949
|
+
socket.end(`${JSON.stringify({ kind: "stopped" })}
|
|
48950
|
+
`, beginShutdown);
|
|
48951
|
+
return;
|
|
48944
48952
|
}
|
|
48945
48953
|
socket.end(`${JSON.stringify(response)}
|
|
48946
48954
|
`);
|
|
@@ -48969,7 +48977,11 @@ async function runManager(installation, managerVersion, signal) {
|
|
|
48969
48977
|
}
|
|
48970
48978
|
try {
|
|
48971
48979
|
await new Promise((resolve8) => combined.addEventListener("abort", () => resolve8(), { once: true }));
|
|
48972
|
-
|
|
48980
|
+
const serverClosed = new Promise((resolve8) => server.close(() => resolve8()));
|
|
48981
|
+
for (const socket of sockets) {
|
|
48982
|
+
socket.destroy();
|
|
48983
|
+
}
|
|
48984
|
+
await serverClosed;
|
|
48973
48985
|
await supervisor.close();
|
|
48974
48986
|
} finally {
|
|
48975
48987
|
if (process.platform !== "win32") {
|
|
@@ -49022,7 +49034,6 @@ function pairArguments(options) {
|
|
|
49022
49034
|
"--code",
|
|
49023
49035
|
options.code,
|
|
49024
49036
|
...options.pairing === void 0 ? [] : ["--pairing", options.pairing],
|
|
49025
|
-
...options.appId === void 0 ? [] : ["--app-id", options.appId],
|
|
49026
49037
|
...options.workspace === void 0 ? [] : ["--workspace", options.workspace]
|
|
49027
49038
|
];
|
|
49028
49039
|
}
|
|
@@ -49084,7 +49095,7 @@ function createProgram() {
|
|
|
49084
49095
|
await runManager(installation, package_default.version, shutdown.signal);
|
|
49085
49096
|
});
|
|
49086
49097
|
const pair = program2.command("pair").description("pair this machine or manage saved pairings");
|
|
49087
|
-
pair.addOption(valueOption("--url <relay-url>", "relay HTTP or HTTPS URL")).addOption(valueOption("--code <pairing-code>", "pairing code shown in the browser")).addOption(valueOption("--pairing <runtime-pairing-id>", "Runtime pairing identifier")).addOption(valueOption("--
|
|
49098
|
+
pair.addOption(valueOption("--url <relay-url>", "relay HTTP or HTTPS URL")).addOption(valueOption("--code <pairing-code>", "pairing code shown in the browser")).addOption(valueOption("--pairing <runtime-pairing-id>", "Runtime pairing identifier")).addOption(valueOption("--workspace <directory>", "default workspace directory")).action(async (options) => {
|
|
49088
49099
|
const requested = {
|
|
49089
49100
|
...options,
|
|
49090
49101
|
code: requireOption(options.code, "--code <pairing-code>", pair),
|