@agentrix/cli 0.0.3 → 0.0.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/README.md +69 -0
- package/dist/index.cjs +315 -155
- package/dist/index.mjs +162 -2
- package/dist/lib.cjs +4 -4
- package/dist/lib.mjs +1 -1
- package/dist/{logger-B7C5x_8c.cjs → logger-BZmE9yGJ.cjs} +29 -2
- package/dist/{logger-DAsm4mPf.mjs → logger-uuzG-sjn.mjs} +28 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import chalk from 'chalk';
|
|
|
4
4
|
import { encodeBase64, createKeyPairWithUit8Array, encryptMachineEncryptionKey, generateAESKey, decodeBase64, decryptWithEphemeralKey, createEventId, encryptFileContent, machineAuth, encryptSdkMessage, decryptSdkMessage, loadAgentConfig, getAgentContext, workerAuth } from '@agentrix/shared';
|
|
5
5
|
import { randomBytes, randomUUID as randomUUID$1 } from 'node:crypto';
|
|
6
6
|
import axios from 'axios';
|
|
7
|
-
import { m as machine, l as logger, p as projectPath, a as packageJson, c as createLogger, g as getLogPath, b as logger$1 } from './logger-
|
|
7
|
+
import { m as machine, l as logger, p as projectPath, a as packageJson, c as createLogger, g as getLogPath, b as logger$1 } from './logger-uuzG-sjn.mjs';
|
|
8
8
|
import * as fs from 'node:fs';
|
|
9
9
|
import { existsSync, rmSync, mkdirSync, readdirSync, createWriteStream } from 'node:fs';
|
|
10
10
|
import { createInterface } from 'node:readline';
|
|
@@ -16,7 +16,7 @@ import { io } from 'socket.io-client';
|
|
|
16
16
|
import { EventEmitter } from 'node:events';
|
|
17
17
|
import * as path from 'node:path';
|
|
18
18
|
import { join as join$1, dirname, extname } from 'node:path';
|
|
19
|
-
import { spawn } from 'child_process';
|
|
19
|
+
import { spawn, execSync } from 'child_process';
|
|
20
20
|
import psList from 'ps-list';
|
|
21
21
|
import spawn$1 from 'cross-spawn';
|
|
22
22
|
import fastify from 'fastify';
|
|
@@ -16566,6 +16566,91 @@ const workerRegistry = {
|
|
|
16566
16566
|
}
|
|
16567
16567
|
};
|
|
16568
16568
|
|
|
16569
|
+
async function checkForUpgrades() {
|
|
16570
|
+
const currentVersion = packageJson.version;
|
|
16571
|
+
try {
|
|
16572
|
+
const output = execSync("npm view @agentrix/cli version", {
|
|
16573
|
+
encoding: "utf-8",
|
|
16574
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
16575
|
+
// Suppress stderr
|
|
16576
|
+
timeout: 5e3
|
|
16577
|
+
// 5 second timeout
|
|
16578
|
+
}).trim();
|
|
16579
|
+
const latestVersion = output;
|
|
16580
|
+
const hasUpgrade = compareVersions(latestVersion, currentVersion) > 0;
|
|
16581
|
+
return {
|
|
16582
|
+
hasUpgrade,
|
|
16583
|
+
currentVersion,
|
|
16584
|
+
latestVersion
|
|
16585
|
+
};
|
|
16586
|
+
} catch (error) {
|
|
16587
|
+
return {
|
|
16588
|
+
hasUpgrade: false,
|
|
16589
|
+
currentVersion,
|
|
16590
|
+
latestVersion: null
|
|
16591
|
+
};
|
|
16592
|
+
}
|
|
16593
|
+
}
|
|
16594
|
+
function compareVersions(v1, v2) {
|
|
16595
|
+
const parts1 = v1.split(".").map(Number);
|
|
16596
|
+
const parts2 = v2.split(".").map(Number);
|
|
16597
|
+
for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
|
|
16598
|
+
const part1 = parts1[i] || 0;
|
|
16599
|
+
const part2 = parts2[i] || 0;
|
|
16600
|
+
if (part1 > part2) return 1;
|
|
16601
|
+
if (part1 < part2) return -1;
|
|
16602
|
+
}
|
|
16603
|
+
return 0;
|
|
16604
|
+
}
|
|
16605
|
+
function displayUpgradeNotification(result) {
|
|
16606
|
+
if (!result.hasUpgrade || !result.latestVersion) {
|
|
16607
|
+
return;
|
|
16608
|
+
}
|
|
16609
|
+
console.log("");
|
|
16610
|
+
console.log(chalk.yellow("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"));
|
|
16611
|
+
console.log(chalk.yellow("\u2502") + " " + chalk.bold("Upgrade Available") + " " + chalk.yellow("\u2502"));
|
|
16612
|
+
console.log(chalk.yellow("\u2502") + " " + chalk.yellow("\u2502"));
|
|
16613
|
+
console.log(chalk.yellow("\u2502") + ` Current: ${chalk.dim(result.currentVersion)} \u2192 Latest: ${chalk.green.bold(result.latestVersion)} ` + chalk.yellow("\u2502"));
|
|
16614
|
+
console.log(chalk.yellow("\u2502") + " " + chalk.yellow("\u2502"));
|
|
16615
|
+
console.log(chalk.yellow("\u2502") + " Run " + chalk.cyan.bold("agentrix upgrade") + " to upgrade " + chalk.yellow("\u2502"));
|
|
16616
|
+
console.log(chalk.yellow("\u2502") + " " + chalk.yellow("\u2502"));
|
|
16617
|
+
console.log(chalk.yellow("\u2502") + " To enable auto-upgrade, set: " + chalk.yellow("\u2502"));
|
|
16618
|
+
console.log(chalk.yellow("\u2502") + " " + chalk.dim("AGENTRIX_DISABLE_AUTO_UPGRADE=false") + " " + chalk.yellow("\u2502"));
|
|
16619
|
+
console.log(chalk.yellow("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"));
|
|
16620
|
+
console.log("");
|
|
16621
|
+
}
|
|
16622
|
+
function isAutoUpgradeDisabled() {
|
|
16623
|
+
return process.env.AGENTRIX_DISABLE_AUTO_UPGRADE === "true";
|
|
16624
|
+
}
|
|
16625
|
+
async function performAutoUpgrade() {
|
|
16626
|
+
try {
|
|
16627
|
+
const { execSync: execSync2 } = await import('child_process');
|
|
16628
|
+
console.log("");
|
|
16629
|
+
console.log(chalk.blue("\u{1F504} Auto-upgrading Agentrix CLI..."));
|
|
16630
|
+
let packageManager = "npm";
|
|
16631
|
+
try {
|
|
16632
|
+
execSync2("yarn --version", { stdio: "ignore" });
|
|
16633
|
+
packageManager = "yarn";
|
|
16634
|
+
} catch {
|
|
16635
|
+
}
|
|
16636
|
+
console.log(chalk.dim(` Using ${packageManager}...`));
|
|
16637
|
+
if (packageManager === "yarn") {
|
|
16638
|
+
execSync2("yarn global upgrade @agentrix/cli", { stdio: "inherit" });
|
|
16639
|
+
} else {
|
|
16640
|
+
execSync2("npm update -g @agentrix/cli", { stdio: "inherit" });
|
|
16641
|
+
}
|
|
16642
|
+
console.log(chalk.green("\u2713 Upgrade complete"));
|
|
16643
|
+
console.log("");
|
|
16644
|
+
return true;
|
|
16645
|
+
} catch (error) {
|
|
16646
|
+
console.log("");
|
|
16647
|
+
console.log(chalk.yellow("\u26A0\uFE0F Auto-upgrade failed"));
|
|
16648
|
+
console.log(chalk.dim(" You can upgrade manually with: agentrix upgrade"));
|
|
16649
|
+
console.log("");
|
|
16650
|
+
return false;
|
|
16651
|
+
}
|
|
16652
|
+
}
|
|
16653
|
+
|
|
16569
16654
|
const cli = yargs(hideBin(process.argv)).scriptName("agentrix").version(packageJson.version).usage("$0 <command> [options]").option("debug", {
|
|
16570
16655
|
alias: "d",
|
|
16571
16656
|
type: "boolean",
|
|
@@ -16573,6 +16658,46 @@ const cli = yargs(hideBin(process.argv)).scriptName("agentrix").version(packageJ
|
|
|
16573
16658
|
global: true
|
|
16574
16659
|
}).help("help").alias("h", "help").alias("v", "version").strict().epilog("For more information, visit https://github.com/xmz-ai/agentrix-cli");
|
|
16575
16660
|
void machine.getStatePaths;
|
|
16661
|
+
cli.command("upgrade", "Upgrade CLI to the latest version", {}, async (argv) => {
|
|
16662
|
+
console.log(chalk.dim(`Current version: ${packageJson.version}`));
|
|
16663
|
+
const daemonRunning = await checkIfDaemonRunningAndCleanupStaleState();
|
|
16664
|
+
const upgraded = await performAutoUpgrade();
|
|
16665
|
+
if (!upgraded) {
|
|
16666
|
+
process.exit(1);
|
|
16667
|
+
}
|
|
16668
|
+
if (daemonRunning) {
|
|
16669
|
+
console.log(chalk.blue("Restarting daemon..."));
|
|
16670
|
+
await stopDaemon();
|
|
16671
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
16672
|
+
const daemonProcess = spawnAgentrixCLI(["daemon"], {
|
|
16673
|
+
detached: true,
|
|
16674
|
+
stdio: "ignore",
|
|
16675
|
+
env: process.env
|
|
16676
|
+
});
|
|
16677
|
+
daemonProcess.unref();
|
|
16678
|
+
let started = false;
|
|
16679
|
+
for (let i = 0; i < 50; i++) {
|
|
16680
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
16681
|
+
if (await checkIfDaemonRunningAndCleanupStaleState()) {
|
|
16682
|
+
started = true;
|
|
16683
|
+
break;
|
|
16684
|
+
}
|
|
16685
|
+
}
|
|
16686
|
+
if (started) {
|
|
16687
|
+
console.log(chalk.green("\u2713 Daemon restarted successfully"));
|
|
16688
|
+
} else {
|
|
16689
|
+
console.log(chalk.yellow("\u26A0\uFE0F Daemon may still be starting. Run 'agentrix status' to check."));
|
|
16690
|
+
}
|
|
16691
|
+
}
|
|
16692
|
+
try {
|
|
16693
|
+
const { version } = await import('./logger-uuzG-sjn.mjs').then(function (n) { return n._; });
|
|
16694
|
+
console.log(chalk.green(`
|
|
16695
|
+
\u2713 Now running version: ${version}`));
|
|
16696
|
+
} catch {
|
|
16697
|
+
console.log(chalk.dim("\nRun 'agentrix --version' to see the new version"));
|
|
16698
|
+
}
|
|
16699
|
+
process.exit(0);
|
|
16700
|
+
});
|
|
16576
16701
|
cli.command("doctor", "System diagnostics & troubleshooting", {}, async (argv) => {
|
|
16577
16702
|
await runDoctorCommand();
|
|
16578
16703
|
process.exit(0);
|
|
@@ -16724,6 +16849,41 @@ cli.command(
|
|
|
16724
16849
|
}
|
|
16725
16850
|
process.exit(1);
|
|
16726
16851
|
}
|
|
16852
|
+
const skipUpgradeCheck = process.env.AGENTRIX_SKIP_UPGRADE_CHECK === "true";
|
|
16853
|
+
const autoUpgradeDisabled = isAutoUpgradeDisabled();
|
|
16854
|
+
let upgradeResult = {
|
|
16855
|
+
hasUpgrade: false,
|
|
16856
|
+
currentVersion: "",
|
|
16857
|
+
latestVersion: null
|
|
16858
|
+
};
|
|
16859
|
+
if (!skipUpgradeCheck) {
|
|
16860
|
+
upgradeResult = await checkForUpgrades();
|
|
16861
|
+
}
|
|
16862
|
+
if (upgradeResult.hasUpgrade) {
|
|
16863
|
+
if (autoUpgradeDisabled) {
|
|
16864
|
+
displayUpgradeNotification(upgradeResult);
|
|
16865
|
+
} else {
|
|
16866
|
+
const upgraded = await performAutoUpgrade();
|
|
16867
|
+
if (upgraded) {
|
|
16868
|
+
console.log(chalk.green("\u2713 Restarting with new version..."));
|
|
16869
|
+
console.log("");
|
|
16870
|
+
const { execSync } = await import('child_process');
|
|
16871
|
+
try {
|
|
16872
|
+
execSync("agentrix start", {
|
|
16873
|
+
stdio: "inherit",
|
|
16874
|
+
env: {
|
|
16875
|
+
...process.env,
|
|
16876
|
+
// Set flag to prevent infinite upgrade loop
|
|
16877
|
+
AGENTRIX_SKIP_UPGRADE_CHECK: "true"
|
|
16878
|
+
}
|
|
16879
|
+
});
|
|
16880
|
+
process.exit(0);
|
|
16881
|
+
} catch (error) {
|
|
16882
|
+
console.log(chalk.yellow("\u26A0\uFE0F Failed to restart, continuing with upgrade..."));
|
|
16883
|
+
}
|
|
16884
|
+
}
|
|
16885
|
+
}
|
|
16886
|
+
}
|
|
16727
16887
|
const wasRunning = await isLatestDaemonRunning();
|
|
16728
16888
|
if (!wasRunning) {
|
|
16729
16889
|
console.log("Starting Agentrix background service...");
|
package/dist/lib.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _package = require('./logger-BZmE9yGJ.cjs');
|
|
4
4
|
require('winston');
|
|
5
5
|
require('chalk');
|
|
6
6
|
require('node:os');
|
|
@@ -14,6 +14,6 @@ require('url');
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
exports.Machine =
|
|
18
|
-
exports.logger =
|
|
19
|
-
exports.machine =
|
|
17
|
+
exports.Machine = _package.Machine;
|
|
18
|
+
exports.logger = _package.logger;
|
|
19
|
+
exports.machine = _package.machine;
|
package/dist/lib.mjs
CHANGED
|
@@ -13,7 +13,7 @@ var url = require('url');
|
|
|
13
13
|
|
|
14
14
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
15
15
|
var name = "@agentrix/cli";
|
|
16
|
-
var version = "0.0.
|
|
16
|
+
var version = "0.0.5";
|
|
17
17
|
var description = "Mobile and Web client for Claude Code and Codex";
|
|
18
18
|
var author = "agentrix.xmz.ai";
|
|
19
19
|
var type = "module";
|
|
@@ -159,7 +159,33 @@ var packageJson = {
|
|
|
159
159
|
packageManager: packageManager
|
|
160
160
|
};
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
var _package = /*#__PURE__*/Object.freeze({
|
|
163
|
+
__proto__: null,
|
|
164
|
+
author: author,
|
|
165
|
+
bin: bin,
|
|
166
|
+
bugs: bugs,
|
|
167
|
+
default: packageJson,
|
|
168
|
+
dependencies: dependencies,
|
|
169
|
+
description: description,
|
|
170
|
+
devDependencies: devDependencies,
|
|
171
|
+
exports: exports$1,
|
|
172
|
+
files: files,
|
|
173
|
+
homepage: homepage,
|
|
174
|
+
main: main,
|
|
175
|
+
module: module$1,
|
|
176
|
+
name: name,
|
|
177
|
+
packageManager: packageManager,
|
|
178
|
+
pkgroll: pkgroll,
|
|
179
|
+
publishConfig: publishConfig,
|
|
180
|
+
repository: repository,
|
|
181
|
+
resolutions: resolutions,
|
|
182
|
+
scripts: scripts,
|
|
183
|
+
type: type,
|
|
184
|
+
types: types,
|
|
185
|
+
version: version
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const __dirname$1 = require$$1.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('logger-BZmE9yGJ.cjs', document.baseURI).href))));
|
|
163
189
|
function projectPath() {
|
|
164
190
|
const path = require$$1.resolve(__dirname$1, "..");
|
|
165
191
|
return path;
|
|
@@ -488,6 +514,7 @@ var logger$1 = /*#__PURE__*/Object.freeze({
|
|
|
488
514
|
});
|
|
489
515
|
|
|
490
516
|
exports.Machine = Machine;
|
|
517
|
+
exports._package = _package;
|
|
491
518
|
exports.createLogger = createLogger;
|
|
492
519
|
exports.getLogPath = getLogPath;
|
|
493
520
|
exports.logger = logger;
|
|
@@ -10,7 +10,7 @@ import { dirname, resolve } from 'path';
|
|
|
10
10
|
import { fileURLToPath } from 'url';
|
|
11
11
|
|
|
12
12
|
var name = "@agentrix/cli";
|
|
13
|
-
var version = "0.0.
|
|
13
|
+
var version = "0.0.5";
|
|
14
14
|
var description = "Mobile and Web client for Claude Code and Codex";
|
|
15
15
|
var author = "agentrix.xmz.ai";
|
|
16
16
|
var type = "module";
|
|
@@ -156,6 +156,32 @@ var packageJson = {
|
|
|
156
156
|
packageManager: packageManager
|
|
157
157
|
};
|
|
158
158
|
|
|
159
|
+
var _package = /*#__PURE__*/Object.freeze({
|
|
160
|
+
__proto__: null,
|
|
161
|
+
author: author,
|
|
162
|
+
bin: bin,
|
|
163
|
+
bugs: bugs,
|
|
164
|
+
default: packageJson,
|
|
165
|
+
dependencies: dependencies,
|
|
166
|
+
description: description,
|
|
167
|
+
devDependencies: devDependencies,
|
|
168
|
+
exports: exports$1,
|
|
169
|
+
files: files,
|
|
170
|
+
homepage: homepage,
|
|
171
|
+
main: main,
|
|
172
|
+
module: module$1,
|
|
173
|
+
name: name,
|
|
174
|
+
packageManager: packageManager,
|
|
175
|
+
pkgroll: pkgroll,
|
|
176
|
+
publishConfig: publishConfig,
|
|
177
|
+
repository: repository,
|
|
178
|
+
resolutions: resolutions,
|
|
179
|
+
scripts: scripts,
|
|
180
|
+
type: type,
|
|
181
|
+
types: types,
|
|
182
|
+
version: version
|
|
183
|
+
});
|
|
184
|
+
|
|
159
185
|
const __dirname$1 = dirname(fileURLToPath(import.meta.url));
|
|
160
186
|
function projectPath() {
|
|
161
187
|
const path = resolve(__dirname$1, "..");
|
|
@@ -484,4 +510,4 @@ var logger$1 = /*#__PURE__*/Object.freeze({
|
|
|
484
510
|
logger: logger
|
|
485
511
|
});
|
|
486
512
|
|
|
487
|
-
export { Machine as M, packageJson as a, logger$1 as b, createLogger as c, getLogPath as g, logger as l, machine as m, projectPath as p };
|
|
513
|
+
export { Machine as M, _package as _, packageJson as a, logger$1 as b, createLogger as c, getLogPath as g, logger as l, machine as m, projectPath as p };
|