@moxt-ai/cli 0.10.0-beta.4 → 0.10.0-beta.5
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/index.cjs +159 -65
- package/dist/index.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10846,7 +10846,9 @@ async function installUserService(store, request2, runtime = defaultServiceManag
|
|
|
10846
10846
|
const capabilities = await detectServiceManagerCapabilities(runtime);
|
|
10847
10847
|
const selection = selectUserServiceManager(request2.preference, capabilities);
|
|
10848
10848
|
if (selection.manager === UserServiceManager.None) {
|
|
10849
|
-
await
|
|
10849
|
+
if (await readStoredServiceManager(store) === UserServiceManager.None) {
|
|
10850
|
+
await persistServiceManager(store, UserServiceManager.None);
|
|
10851
|
+
}
|
|
10850
10852
|
return {
|
|
10851
10853
|
detail: selection.detail,
|
|
10852
10854
|
installed: false,
|
|
@@ -10863,6 +10865,7 @@ async function installUserService(store, request2, runtime = defaultServiceManag
|
|
|
10863
10865
|
}
|
|
10864
10866
|
const candidates = await automaticManagerCandidates(store, capabilities);
|
|
10865
10867
|
const failures = [];
|
|
10868
|
+
let cleanupFailed = false;
|
|
10866
10869
|
for (const manager of candidates) {
|
|
10867
10870
|
try {
|
|
10868
10871
|
await replaceConfiguredManager(store, manager, options, runtime);
|
|
@@ -10873,10 +10876,18 @@ async function installUserService(store, request2, runtime = defaultServiceManag
|
|
|
10873
10876
|
};
|
|
10874
10877
|
} catch (error) {
|
|
10875
10878
|
failures.push(`${manager}: ${error instanceof Error ? error.message : String(error)}`);
|
|
10876
|
-
|
|
10879
|
+
try {
|
|
10880
|
+
await uninstallManager(manager, store, runtime);
|
|
10881
|
+
} catch (cleanupError) {
|
|
10882
|
+
failures.push(`${manager} cleanup: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
|
|
10883
|
+
cleanupFailed = true;
|
|
10884
|
+
break;
|
|
10885
|
+
}
|
|
10877
10886
|
}
|
|
10878
10887
|
}
|
|
10879
|
-
|
|
10888
|
+
if (!cleanupFailed) {
|
|
10889
|
+
await persistServiceManager(store, UserServiceManager.None);
|
|
10890
|
+
}
|
|
10880
10891
|
return {
|
|
10881
10892
|
detail: failures.length === 0 ? selection.detail : `Automatic background service setup failed (${failures.join("; ")}). Pairing is complete, but the Connector must be started manually.`,
|
|
10882
10893
|
installed: false,
|
|
@@ -10922,9 +10933,6 @@ async function refreshManagedUserService(store, options, runtime = defaultServic
|
|
|
10922
10933
|
};
|
|
10923
10934
|
try {
|
|
10924
10935
|
await installManager(manager, store, refreshedOptions, runtime);
|
|
10925
|
-
if (manager === UserServiceManager.Systemd) {
|
|
10926
|
-
await restartManager(manager, store, runtime);
|
|
10927
|
-
}
|
|
10928
10936
|
await persistServiceManager(store, manager, options.entrypointPath);
|
|
10929
10937
|
} catch (error) {
|
|
10930
10938
|
try {
|
|
@@ -11016,7 +11024,7 @@ async function automaticManagerCandidates(store, capabilities) {
|
|
|
11016
11024
|
async function replaceConfiguredManager(store, manager, options, runtime) {
|
|
11017
11025
|
const configuredManager = await readStoredServiceManager(store);
|
|
11018
11026
|
if (configuredManager !== UserServiceManager.None && configuredManager !== manager) {
|
|
11019
|
-
await
|
|
11027
|
+
await uninstallManager(configuredManager, store, runtime);
|
|
11020
11028
|
}
|
|
11021
11029
|
await installManager(manager, store, options, runtime);
|
|
11022
11030
|
await persistServiceManager(store, manager, options.entrypointPath);
|
|
@@ -11076,12 +11084,7 @@ async function stopManager(manager, store, runtime) {
|
|
|
11076
11084
|
]);
|
|
11077
11085
|
return;
|
|
11078
11086
|
}
|
|
11079
|
-
await
|
|
11080
|
-
"-c",
|
|
11081
|
-
supervisorConfigPath(store),
|
|
11082
|
-
"stop",
|
|
11083
|
-
supervisorProgramName
|
|
11084
|
-
]);
|
|
11087
|
+
await stopSupervisorProgram(store, runtime);
|
|
11085
11088
|
}
|
|
11086
11089
|
async function uninstallManager(manager, store, runtime) {
|
|
11087
11090
|
if (manager === UserServiceManager.None) {
|
|
@@ -11109,13 +11112,16 @@ async function uninstallManager(manager, store, runtime) {
|
|
|
11109
11112
|
]);
|
|
11110
11113
|
return;
|
|
11111
11114
|
}
|
|
11112
|
-
await
|
|
11113
|
-
|
|
11114
|
-
|
|
11115
|
-
"
|
|
11116
|
-
|
|
11117
|
-
|
|
11118
|
-
|
|
11115
|
+
const supervisorProcessId = await currentSupervisorProcessId(store, runtime);
|
|
11116
|
+
await stopSupervisorProgram(store, runtime);
|
|
11117
|
+
if (supervisorProcessId !== void 0) {
|
|
11118
|
+
await runtime.run("supervisorctl", [
|
|
11119
|
+
"-c",
|
|
11120
|
+
supervisorConfigPath(store),
|
|
11121
|
+
"shutdown"
|
|
11122
|
+
]);
|
|
11123
|
+
await waitForSupervisorExit(store, runtime, supervisorProcessId);
|
|
11124
|
+
}
|
|
11119
11125
|
await (0, import_promises13.rm)(supervisorDirectory(store), {
|
|
11120
11126
|
force: true,
|
|
11121
11127
|
recursive: true
|
|
@@ -11344,6 +11350,11 @@ WantedBy=default.target
|
|
|
11344
11350
|
"--now",
|
|
11345
11351
|
"moxt-machine-connector.service"
|
|
11346
11352
|
]);
|
|
11353
|
+
await runtime.run("systemctl", [
|
|
11354
|
+
"--user",
|
|
11355
|
+
"restart",
|
|
11356
|
+
"moxt-machine-connector.service"
|
|
11357
|
+
]);
|
|
11347
11358
|
await runCommandIgnoringFailure(runtime, "loginctl", [
|
|
11348
11359
|
"enable-linger",
|
|
11349
11360
|
(0, import_node_os7.userInfo)().username
|
|
@@ -11412,7 +11423,7 @@ stderr_logfile_backups=3
|
|
|
11412
11423
|
async function restartSupervisorUserService(store, runtime) {
|
|
11413
11424
|
const configPath = supervisorConfigPath(store);
|
|
11414
11425
|
const supervisorProcessId = await currentSupervisorProcessId(store, runtime);
|
|
11415
|
-
const
|
|
11426
|
+
const stoppedConnector = await stopSupervisorProgram(store, runtime);
|
|
11416
11427
|
if (supervisorProcessId !== void 0) {
|
|
11417
11428
|
await runtime.run("supervisorctl", [
|
|
11418
11429
|
"-c",
|
|
@@ -11421,7 +11432,7 @@ async function restartSupervisorUserService(store, runtime) {
|
|
|
11421
11432
|
]);
|
|
11422
11433
|
await waitForSupervisorExit(store, runtime, supervisorProcessId);
|
|
11423
11434
|
}
|
|
11424
|
-
await startSupervisorUserService(store, runtime, supervisorProcessId,
|
|
11435
|
+
await startSupervisorUserService(store, runtime, supervisorProcessId, stoppedConnector.processId);
|
|
11425
11436
|
}
|
|
11426
11437
|
async function startSupervisorUserService(store, runtime, previousSupervisorProcessId, previousConnectorProcessId) {
|
|
11427
11438
|
await (0, import_promises13.rm)(supervisorSocketPath(store), { force: true });
|
|
@@ -11435,19 +11446,7 @@ async function startSupervisorUserService(store, runtime, previousSupervisorProc
|
|
|
11435
11446
|
}
|
|
11436
11447
|
async function reloadSupervisorConfiguration(store, runtime) {
|
|
11437
11448
|
const configPath = supervisorConfigPath(store);
|
|
11438
|
-
|
|
11439
|
-
if (processIdBeforeStop !== void 0) {
|
|
11440
|
-
await runtime.run("supervisorctl", [
|
|
11441
|
-
"-c",
|
|
11442
|
-
configPath,
|
|
11443
|
-
"stop",
|
|
11444
|
-
supervisorProgramName
|
|
11445
|
-
]);
|
|
11446
|
-
const processIdAfterStop = await currentSupervisorProgramProcessId(store, runtime);
|
|
11447
|
-
if (processIdAfterStop !== void 0) {
|
|
11448
|
-
throw new Error("Supervisor did not stop the existing Moxt Machine Connector process");
|
|
11449
|
-
}
|
|
11450
|
-
}
|
|
11449
|
+
await stopSupervisorProgram(store, runtime);
|
|
11451
11450
|
await runtime.run("supervisorctl", ["-c", configPath, "reread"]);
|
|
11452
11451
|
await runtime.run("supervisorctl", ["-c", configPath, "update"]);
|
|
11453
11452
|
const processId = await currentSupervisorProgramProcessId(store, runtime);
|
|
@@ -11484,6 +11483,30 @@ async function waitForSupervisorExit(store, runtime, processId) {
|
|
|
11484
11483
|
}
|
|
11485
11484
|
throw new Error(`Supervisor did not exit within ${supervisorExitTimeoutMilliseconds / 1e3} seconds`);
|
|
11486
11485
|
}
|
|
11486
|
+
async function stopSupervisorProgram(store, runtime) {
|
|
11487
|
+
const processId = await currentSupervisorProgramProcessId(store, runtime);
|
|
11488
|
+
if (processId === void 0)
|
|
11489
|
+
return {};
|
|
11490
|
+
await runtime.run("supervisorctl", [
|
|
11491
|
+
"-c",
|
|
11492
|
+
supervisorConfigPath(store),
|
|
11493
|
+
"stop",
|
|
11494
|
+
supervisorProgramName
|
|
11495
|
+
]);
|
|
11496
|
+
await waitForSupervisorProgramExit(store, runtime, processId);
|
|
11497
|
+
return { processId };
|
|
11498
|
+
}
|
|
11499
|
+
async function waitForSupervisorProgramExit(store, runtime, processId) {
|
|
11500
|
+
const deadline = serviceManagerCurrentTime(runtime) + supervisorExitTimeoutMilliseconds;
|
|
11501
|
+
while (serviceManagerCurrentTime(runtime) < deadline) {
|
|
11502
|
+
const reportedProcessId = await currentSupervisorProgramProcessId(store, runtime);
|
|
11503
|
+
if (reportedProcessId !== processId && !serviceProcessIsRunning(runtime, processId)) {
|
|
11504
|
+
return;
|
|
11505
|
+
}
|
|
11506
|
+
await serviceManagerDelay(runtime, 100);
|
|
11507
|
+
}
|
|
11508
|
+
throw new Error(`Supervisor did not stop Moxt Machine Connector process ${processId} within ${supervisorExitTimeoutMilliseconds / 1e3} seconds`);
|
|
11509
|
+
}
|
|
11487
11510
|
function serviceProcessIsRunning(runtime, processId) {
|
|
11488
11511
|
if (runtime.processIsRunning)
|
|
11489
11512
|
return runtime.processIsRunning(processId);
|
|
@@ -11585,13 +11608,6 @@ async function runCommandIgnoringFailure(runtime, command, argumentsList) {
|
|
|
11585
11608
|
return;
|
|
11586
11609
|
}
|
|
11587
11610
|
}
|
|
11588
|
-
async function uninstallManagerIgnoringFailure(manager, store, runtime) {
|
|
11589
|
-
try {
|
|
11590
|
-
await uninstallManager(manager, store, runtime);
|
|
11591
|
-
} catch {
|
|
11592
|
-
return;
|
|
11593
|
-
}
|
|
11594
|
-
}
|
|
11595
11611
|
function escapeXml(value) {
|
|
11596
11612
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
11597
11613
|
}
|
|
@@ -11703,8 +11719,9 @@ async function reconcileManagedDaemon(options, store = new MachineRuntimeStore()
|
|
|
11703
11719
|
if (await recordedServiceDesiredState(store) === ManagedServiceDesiredState.Stopped) {
|
|
11704
11720
|
return { manager, outcome: DaemonReconcileOutcome.Skipped };
|
|
11705
11721
|
}
|
|
11722
|
+
const configuredConnectionIds = (await store.listConnections()).map((connection) => connection.connectionId);
|
|
11706
11723
|
const initial = await reachableRuntimeStatus(store);
|
|
11707
|
-
if (initial?.cliVersion === options.cliVersion) {
|
|
11724
|
+
if (initial?.cliVersion === options.cliVersion && runtimeHasConnections(initial, configuredConnectionIds)) {
|
|
11708
11725
|
return { manager, outcome: DaemonReconcileOutcome.Skipped };
|
|
11709
11726
|
}
|
|
11710
11727
|
if (initial) {
|
|
@@ -11712,16 +11729,16 @@ async function reconcileManagedDaemon(options, store = new MachineRuntimeStore()
|
|
|
11712
11729
|
try {
|
|
11713
11730
|
managerOwnsProcess = await managedServiceOwnsProcess(manager, initial.pid, store);
|
|
11714
11731
|
} catch (error) {
|
|
11715
|
-
throw new DaemonRefreshError(
|
|
11732
|
+
throw new DaemonRefreshError(DaemonRefreshStage.Ownership, `could not verify that the reachable Connector belongs to ${manager}: ${errorMessage4(error)}`, { cause: error });
|
|
11716
11733
|
}
|
|
11717
11734
|
if (!managerOwnsProcess) {
|
|
11718
|
-
|
|
11735
|
+
throw new DaemonRefreshError(DaemonRefreshStage.Ownership, `${manager} does not own reachable daemon PID ${initial.pid}; stop that foreground or orphaned daemon before restarting the managed Connector`);
|
|
11719
11736
|
}
|
|
11720
11737
|
}
|
|
11721
11738
|
try {
|
|
11722
11739
|
await validateCliEntrypoint(options, store);
|
|
11723
11740
|
} catch (error) {
|
|
11724
|
-
throw new DaemonRefreshError(
|
|
11741
|
+
throw new DaemonRefreshError(DaemonRefreshStage.Validation, errorMessage4(error), {
|
|
11725
11742
|
cause: error
|
|
11726
11743
|
});
|
|
11727
11744
|
}
|
|
@@ -11740,27 +11757,31 @@ async function reconcileManagedDaemon(options, store = new MachineRuntimeStore()
|
|
|
11740
11757
|
throw new Error("The Connector service is no longer managed by Moxt");
|
|
11741
11758
|
}
|
|
11742
11759
|
} catch (error) {
|
|
11743
|
-
throw new DaemonRefreshError(
|
|
11760
|
+
throw new DaemonRefreshError(DaemonRefreshStage.Restart, error instanceof Error ? error.message : String(error), { cause: error });
|
|
11744
11761
|
}
|
|
11745
11762
|
const deadline = Date.now() + reconcileTimeoutMilliseconds;
|
|
11746
11763
|
while (Date.now() < deadline) {
|
|
11747
11764
|
const current2 = await reachableRuntimeStatus(store);
|
|
11748
|
-
if (current2?.cliVersion === options.cliVersion && current2.connectorInstanceId !== initial?.connectorInstanceId) {
|
|
11765
|
+
if (current2?.cliVersion === options.cliVersion && current2.connectorInstanceId !== initial?.connectorInstanceId && runtimeHasConnections(current2, configuredConnectionIds)) {
|
|
11749
11766
|
return { manager, outcome: DaemonReconcileOutcome.Restarted };
|
|
11750
11767
|
}
|
|
11751
11768
|
await delay6(100);
|
|
11752
11769
|
}
|
|
11753
|
-
const verificationMessage = initial ? `managed daemon did not report CLI ${options.cliVersion} with a new instance ID` : `managed daemon did not become reachable with CLI ${options.cliVersion}`;
|
|
11770
|
+
const verificationMessage = initial ? `managed daemon did not report CLI ${options.cliVersion} with a new instance ID and all configured connections` : `managed daemon did not become reachable with CLI ${options.cliVersion} and all configured connections`;
|
|
11754
11771
|
try {
|
|
11755
11772
|
await refresh.rollback();
|
|
11756
11773
|
} catch (error) {
|
|
11757
|
-
throw new DaemonRefreshError(
|
|
11774
|
+
throw new DaemonRefreshError(DaemonRefreshStage.Verification, `${verificationMessage}; restoring the previous service definition also failed: ${errorMessage4(error)}`, { cause: error });
|
|
11758
11775
|
}
|
|
11759
|
-
throw new DaemonRefreshError(
|
|
11776
|
+
throw new DaemonRefreshError(DaemonRefreshStage.Verification, verificationMessage);
|
|
11760
11777
|
} finally {
|
|
11761
11778
|
await lock.release();
|
|
11762
11779
|
}
|
|
11763
11780
|
}
|
|
11781
|
+
function runtimeHasConnections(status, connectionIds) {
|
|
11782
|
+
const runtimeConnectionIds = new Set(status.connections.map((connection) => connection.connectionId));
|
|
11783
|
+
return connectionIds.every((connectionId) => runtimeConnectionIds.has(connectionId));
|
|
11784
|
+
}
|
|
11764
11785
|
async function validateCliEntrypoint(options, store) {
|
|
11765
11786
|
await assertManagedServiceProvenance(store, options.entrypointPath);
|
|
11766
11787
|
if (options.commandArguments.length !== 2 || options.commandArguments[0] !== "machine" || options.commandArguments[1] !== "daemon") {
|
|
@@ -11802,7 +11823,7 @@ function delay6(milliseconds) {
|
|
|
11802
11823
|
function errorMessage4(error) {
|
|
11803
11824
|
return error instanceof Error ? error.message : String(error);
|
|
11804
11825
|
}
|
|
11805
|
-
var import_node_child_process6, import_promises14, import_node_path12, import_node_util3, reconcileTimeoutMilliseconds, execFileAsync2, DaemonReconcileOutcome, DaemonRefreshError;
|
|
11826
|
+
var import_node_child_process6, import_promises14, import_node_path12, import_node_util3, reconcileTimeoutMilliseconds, execFileAsync2, DaemonReconcileOutcome, DaemonRefreshStage, DaemonRefreshError;
|
|
11806
11827
|
var init_daemon_reconcile = __esm({
|
|
11807
11828
|
"../machine-connector/dist/runtime/daemon-reconcile.js"() {
|
|
11808
11829
|
"use strict";
|
|
@@ -11822,6 +11843,12 @@ var init_daemon_reconcile = __esm({
|
|
|
11822
11843
|
DaemonReconcileOutcome2["Restarted"] = "restarted";
|
|
11823
11844
|
DaemonReconcileOutcome2["Skipped"] = "skipped";
|
|
11824
11845
|
})(DaemonReconcileOutcome || (DaemonReconcileOutcome = {}));
|
|
11846
|
+
(function(DaemonRefreshStage2) {
|
|
11847
|
+
DaemonRefreshStage2["Ownership"] = "ownership";
|
|
11848
|
+
DaemonRefreshStage2["Restart"] = "restart";
|
|
11849
|
+
DaemonRefreshStage2["Validation"] = "validation";
|
|
11850
|
+
DaemonRefreshStage2["Verification"] = "verification";
|
|
11851
|
+
})(DaemonRefreshStage || (DaemonRefreshStage = {}));
|
|
11825
11852
|
DaemonRefreshError = class extends Error {
|
|
11826
11853
|
stage;
|
|
11827
11854
|
constructor(stage, message, options) {
|
|
@@ -12902,6 +12929,7 @@ async function connectCommand(store, argumentsList, entrypoint) {
|
|
|
12902
12929
|
const rootPath = (0, import_node_path14.resolve)(options.root ?? process.cwd());
|
|
12903
12930
|
const serviceManagerPreference = requestedServiceManagerPreference(options);
|
|
12904
12931
|
await validateExplicitServiceManagerPreference(serviceManagerPreference);
|
|
12932
|
+
await assertConnectionRuntimeCanConverge(store, serviceManagerPreference);
|
|
12905
12933
|
writeLine("Internal Full Host Access: enabled");
|
|
12906
12934
|
writeLine(`Working root: ${rootPath}`);
|
|
12907
12935
|
const result = await pairMachine(store, {
|
|
@@ -12927,13 +12955,22 @@ async function connectCommand(store, argumentsList, entrypoint) {
|
|
|
12927
12955
|
if (service.installed) {
|
|
12928
12956
|
writeLine(`Service manager: ${service.manager}`);
|
|
12929
12957
|
try {
|
|
12930
|
-
await
|
|
12958
|
+
await waitForConnectedManagedDaemon(store, {
|
|
12959
|
+
cliVersion: entrypoint.cliVersion,
|
|
12960
|
+
connectionId: result.connection.connectionId,
|
|
12961
|
+
manager: service.manager,
|
|
12962
|
+
timeoutMilliseconds: entrypoint.serviceReadyTimeoutMilliseconds ?? 3e4
|
|
12963
|
+
});
|
|
12931
12964
|
writeLine("Moxt Machine Connector is online.");
|
|
12932
12965
|
} catch (error) {
|
|
12933
12966
|
if (serviceManagerPreference !== ServiceManagerPreference.Auto) {
|
|
12934
12967
|
throw error;
|
|
12935
12968
|
}
|
|
12936
12969
|
await uninstallUserService(store);
|
|
12970
|
+
const remainingRuntime = await reachableRuntimeStatus2(store);
|
|
12971
|
+
if (remainingRuntime) {
|
|
12972
|
+
throw new Error(`Automatic ${service.manager} setup did not converge the paired connection and daemon PID ${remainingRuntime.pid} is still running. Stop that foreground or orphaned daemon, then run \`moxt machine service install\`.`, { cause: error });
|
|
12973
|
+
}
|
|
12937
12974
|
await installUserService(store, {
|
|
12938
12975
|
options: {
|
|
12939
12976
|
commandArguments: entrypoint.commandArguments,
|
|
@@ -12949,6 +12986,10 @@ async function connectCommand(store, argumentsList, entrypoint) {
|
|
|
12949
12986
|
writeLine(" moxt machine daemon");
|
|
12950
12987
|
}
|
|
12951
12988
|
} else {
|
|
12989
|
+
const remainingRuntime = await reachableRuntimeStatus2(store);
|
|
12990
|
+
if (remainingRuntime && !remainingRuntime.connections.some((connection) => connection.connectionId === result.connection.connectionId)) {
|
|
12991
|
+
throw new Error(`Background service setup did not converge the paired connection and daemon PID ${remainingRuntime.pid} is still running without it. Stop that daemon, then run \`moxt machine service install\` or \`moxt machine daemon\`.`);
|
|
12992
|
+
}
|
|
12952
12993
|
writeLine(service.detail);
|
|
12953
12994
|
writeLine("Run manually:");
|
|
12954
12995
|
writeLine(" moxt machine daemon");
|
|
@@ -13169,19 +13210,71 @@ function requireInstalledServiceManager(manager) {
|
|
|
13169
13210
|
throw new Error("No background Connector service is installed. Run `moxt machine service install` or `moxt machine daemon`.");
|
|
13170
13211
|
}
|
|
13171
13212
|
}
|
|
13172
|
-
async function
|
|
13173
|
-
|
|
13213
|
+
async function assertConnectionRuntimeCanConverge(store, preference) {
|
|
13214
|
+
let status;
|
|
13215
|
+
try {
|
|
13216
|
+
status = (await requestRuntimeStatus(store)).status;
|
|
13217
|
+
} catch {
|
|
13218
|
+
return;
|
|
13219
|
+
}
|
|
13220
|
+
if (!status)
|
|
13221
|
+
return;
|
|
13222
|
+
if (preference === ServiceManagerPreference.None) {
|
|
13223
|
+
throw new Error(`Running Connector daemon PID ${status.pid} cannot safely load a newly paired connection without a restart. Stop it and retry pairing, then run \`moxt machine daemon\`.`);
|
|
13224
|
+
}
|
|
13225
|
+
const manager = await recordedServiceManager(store);
|
|
13226
|
+
if (manager === UserServiceManager.None) {
|
|
13227
|
+
throw new Error(`Running Connector daemon PID ${status.pid} cannot safely load a newly paired connection because it is not managed by a background service. Stop it and retry pairing.`);
|
|
13228
|
+
}
|
|
13229
|
+
let managerOwnsProcess;
|
|
13230
|
+
try {
|
|
13231
|
+
managerOwnsProcess = await managedServiceOwnsProcess(manager, status.pid, store);
|
|
13232
|
+
} catch (error) {
|
|
13233
|
+
throw new Error(`Running Connector daemon PID ${status.pid} cannot safely load a newly paired connection because ${manager} ownership could not be verified: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
13234
|
+
}
|
|
13235
|
+
if (!managerOwnsProcess) {
|
|
13236
|
+
throw new Error(`Running Connector daemon PID ${status.pid} cannot safely load a newly paired connection because ${manager} does not own it. Stop the foreground or orphaned daemon and retry pairing.`);
|
|
13237
|
+
}
|
|
13238
|
+
}
|
|
13239
|
+
async function waitForConnectedManagedDaemon(store, expectation) {
|
|
13240
|
+
const deadline = Date.now() + expectation.timeoutMilliseconds;
|
|
13241
|
+
let lastObservation = "the Connector did not answer its local status socket";
|
|
13174
13242
|
while (Date.now() < deadline) {
|
|
13175
13243
|
try {
|
|
13176
13244
|
const response = await requestRuntimeStatus(store);
|
|
13177
|
-
|
|
13245
|
+
const status = response.status;
|
|
13246
|
+
if (!status) {
|
|
13247
|
+
lastObservation = "the Connector returned no runtime status";
|
|
13248
|
+
await delay8(500);
|
|
13249
|
+
continue;
|
|
13250
|
+
}
|
|
13251
|
+
if (expectation.cliVersion && status.cliVersion !== expectation.cliVersion) {
|
|
13252
|
+
lastObservation = `the reachable daemon reports CLI ${status.cliVersion ?? "unknown"} instead of ${expectation.cliVersion}`;
|
|
13253
|
+
await delay8(500);
|
|
13254
|
+
continue;
|
|
13255
|
+
}
|
|
13256
|
+
if (!status.connections.some((connection) => connection.connectionId === expectation.connectionId)) {
|
|
13257
|
+
lastObservation = `the reachable daemon has not loaded connection ${expectation.connectionId}`;
|
|
13258
|
+
await delay8(500);
|
|
13259
|
+
continue;
|
|
13260
|
+
}
|
|
13261
|
+
if (await managedServiceOwnsProcess(expectation.manager, status.pid, store)) {
|
|
13178
13262
|
return;
|
|
13179
13263
|
}
|
|
13180
|
-
|
|
13181
|
-
|
|
13264
|
+
lastObservation = `${expectation.manager} does not own reachable daemon PID ${status.pid}`;
|
|
13265
|
+
} catch (error) {
|
|
13266
|
+
lastObservation = error instanceof Error ? error.message : String(error);
|
|
13182
13267
|
}
|
|
13268
|
+
await delay8(500);
|
|
13269
|
+
}
|
|
13270
|
+
throw new Error(`The service was installed but the paired connection did not converge on the managed Connector within ${expectation.timeoutMilliseconds / 1e3} seconds: ${lastObservation}`);
|
|
13271
|
+
}
|
|
13272
|
+
async function reachableRuntimeStatus2(store) {
|
|
13273
|
+
try {
|
|
13274
|
+
return (await requestRuntimeStatus(store)).status;
|
|
13275
|
+
} catch {
|
|
13276
|
+
return void 0;
|
|
13183
13277
|
}
|
|
13184
|
-
throw new Error("The service was installed but the Connector did not become online within 30 seconds");
|
|
13185
13278
|
}
|
|
13186
13279
|
async function readOptionalFile2(path4) {
|
|
13187
13280
|
try {
|
|
@@ -13240,6 +13333,7 @@ var dist_exports = {};
|
|
|
13240
13333
|
__export(dist_exports, {
|
|
13241
13334
|
DaemonReconcileOutcome: () => DaemonReconcileOutcome,
|
|
13242
13335
|
DaemonRefreshError: () => DaemonRefreshError,
|
|
13336
|
+
DaemonRefreshStage: () => DaemonRefreshStage,
|
|
13243
13337
|
DoctorCheckStatus: () => DoctorCheckStatus,
|
|
13244
13338
|
LocalIpcServer: () => LocalIpcServer,
|
|
13245
13339
|
MachineClaudePermissionMode: () => MachineClaudePermissionMode,
|
|
@@ -13514,7 +13608,7 @@ function getApiKeyOrUndefined() {
|
|
|
13514
13608
|
|
|
13515
13609
|
// src/utils/http.ts
|
|
13516
13610
|
function getUserAgent() {
|
|
13517
|
-
return `moxt-cli/${"0.10.0-beta.
|
|
13611
|
+
return `moxt-cli/${"0.10.0-beta.5"} (${(0, import_os.platform)()}/${(0, import_os.arch)()}) node/${process.versions.node}`;
|
|
13518
13612
|
}
|
|
13519
13613
|
async function sendRequest(method, path4, init) {
|
|
13520
13614
|
return await fetch(`${getApiBaseUrl()}${path4}`, {
|
|
@@ -27097,7 +27191,7 @@ var FLUSH_TIMEOUT_MS = 3e3;
|
|
|
27097
27191
|
var MAX_BATCH_SIZE = 100;
|
|
27098
27192
|
function commonLabels() {
|
|
27099
27193
|
return {
|
|
27100
|
-
cli_version: "0.10.0-beta.
|
|
27194
|
+
cli_version: "0.10.0-beta.5",
|
|
27101
27195
|
node_version: process.versions.node,
|
|
27102
27196
|
os: (0, import_node_os9.platform)(),
|
|
27103
27197
|
arch: (0, import_node_os9.arch)(),
|
|
@@ -27143,7 +27237,7 @@ async function flush() {
|
|
|
27143
27237
|
}
|
|
27144
27238
|
const batch = buffer.splice(0, MAX_BATCH_SIZE);
|
|
27145
27239
|
const payload = {
|
|
27146
|
-
release_id: "0.10.0-beta.
|
|
27240
|
+
release_id: "0.10.0-beta.5",
|
|
27147
27241
|
client_type: "cli",
|
|
27148
27242
|
metric_data_list: batch.map((m) => ({
|
|
27149
27243
|
profile: "cli",
|
|
@@ -27526,9 +27620,9 @@ function commandPath3(command) {
|
|
|
27526
27620
|
}
|
|
27527
27621
|
|
|
27528
27622
|
// src/index.ts
|
|
27529
|
-
var program2 = createProgram("0.10.0-beta.
|
|
27530
|
-
installDaemonReconcileHook(program2, "0.10.0-beta.
|
|
27531
|
-
installUpdateHook(program2, "0.10.0-beta.
|
|
27623
|
+
var program2 = createProgram("0.10.0-beta.5");
|
|
27624
|
+
installDaemonReconcileHook(program2, "0.10.0-beta.5");
|
|
27625
|
+
installUpdateHook(program2, "0.10.0-beta.5");
|
|
27532
27626
|
instrumentProgram(program2);
|
|
27533
27627
|
installExitHandler();
|
|
27534
27628
|
program2.parseAsync(process.argv).then(async () => {
|