@agentrix/cli 0.0.7 → 0.0.9
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 +2 -2
- package/dist/index.cjs +196 -57
- package/dist/index.mjs +185 -46
- package/dist/lib.cjs +1 -1
- package/dist/lib.mjs +1 -1
- package/dist/{logger-CE8nWMZI.mjs → logger-6H3e_sL6.mjs} +1 -1
- package/dist/{logger-CqXZ3EDu.cjs → logger-ChBQkYk7.cjs} +24 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,8 +64,8 @@ This command will:
|
|
|
64
64
|
You can also upgrade using npm directly:
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
|
-
# Upgrade to latest version
|
|
68
|
-
npm
|
|
67
|
+
# Upgrade to latest version (fastest)
|
|
68
|
+
npm install -g @agentrix/cli@latest
|
|
69
69
|
|
|
70
70
|
# Check installed version
|
|
71
71
|
agentrix --version
|
package/dist/index.cjs
CHANGED
|
@@ -6,16 +6,16 @@ var chalk = require('chalk');
|
|
|
6
6
|
var shared = require('@agentrix/shared');
|
|
7
7
|
var node_crypto = require('node:crypto');
|
|
8
8
|
var axios = require('axios');
|
|
9
|
-
var _package = require('./logger-
|
|
9
|
+
var _package = require('./logger-ChBQkYk7.cjs');
|
|
10
10
|
var fs$1 = require('node:fs');
|
|
11
11
|
var node_readline = require('node:readline');
|
|
12
12
|
var fs = require('fs');
|
|
13
|
-
var
|
|
13
|
+
var path = require('path');
|
|
14
14
|
var os = require('node:os');
|
|
15
15
|
var open = require('open');
|
|
16
16
|
var socket_ioClient = require('socket.io-client');
|
|
17
17
|
var node_events = require('node:events');
|
|
18
|
-
var path = require('node:path');
|
|
18
|
+
var path$1 = require('node:path');
|
|
19
19
|
var child_process = require('child_process');
|
|
20
20
|
var psList = require('ps-list');
|
|
21
21
|
var spawn = require('cross-spawn');
|
|
@@ -51,7 +51,7 @@ function _interopNamespaceDefault(e) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs$1);
|
|
54
|
-
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
54
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path$1);
|
|
55
55
|
|
|
56
56
|
async function delay(ms) {
|
|
57
57
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -144,7 +144,7 @@ async function isLatestDaemonRunning() {
|
|
|
144
144
|
return false;
|
|
145
145
|
}
|
|
146
146
|
try {
|
|
147
|
-
const packageJsonPath =
|
|
147
|
+
const packageJsonPath = path.join(_package.projectPath(), "package.json");
|
|
148
148
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
149
149
|
const currentCliVersion = packageJson.version;
|
|
150
150
|
_package.logger.debug(`[DAEMON CONTROL] Current CLI version: ${currentCliVersion}, Daemon started with version: ${state.cliVersion}`);
|
|
@@ -11432,7 +11432,7 @@ function requireMimeTypes () {
|
|
|
11432
11432
|
* MIT Licensed
|
|
11433
11433
|
*/
|
|
11434
11434
|
var db = requireMimeDb();
|
|
11435
|
-
var extname =
|
|
11435
|
+
var extname = path.extname;
|
|
11436
11436
|
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
11437
11437
|
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
11438
11438
|
exports$1.charset = charset;
|
|
@@ -11866,6 +11866,8 @@ async function findAllAgentrixProcesses() {
|
|
|
11866
11866
|
let type = "unknown";
|
|
11867
11867
|
if (cmd.includes(" worker")) {
|
|
11868
11868
|
type = "worker";
|
|
11869
|
+
} else if (cmd.includes(" upgrade-daemon")) {
|
|
11870
|
+
type = "upgrade-daemon";
|
|
11869
11871
|
} else if (cmd.includes(" daemon")) {
|
|
11870
11872
|
type = "daemon";
|
|
11871
11873
|
} else if (cmd.includes("doctor")) {
|
|
@@ -11953,8 +11955,8 @@ async function runDoctorCommand(filter) {
|
|
|
11953
11955
|
console.log("");
|
|
11954
11956
|
console.log(chalk.bold("\u{1F527} Daemon Spawn Diagnostics"));
|
|
11955
11957
|
const projectRoot = _package.projectPath();
|
|
11956
|
-
const wrapperPath = path.join(projectRoot, "bin", "agentrix.mjs");
|
|
11957
|
-
const cliEntrypoint = path.join(projectRoot, "dist", "index.mjs");
|
|
11958
|
+
const wrapperPath = path$1.join(projectRoot, "bin", "agentrix.mjs");
|
|
11959
|
+
const cliEntrypoint = path$1.join(projectRoot, "dist", "index.mjs");
|
|
11958
11960
|
console.log(`Project Root: ${chalk.blue(projectRoot)}`);
|
|
11959
11961
|
console.log(`Wrapper Script: ${chalk.blue(wrapperPath)}`);
|
|
11960
11962
|
console.log(`CLI Entrypoint: ${chalk.blue(cliEntrypoint)}`);
|
|
@@ -12018,6 +12020,7 @@ async function runDoctorCommand(filter) {
|
|
|
12018
12020
|
Object.entries(grouped).forEach(([type, processes]) => {
|
|
12019
12021
|
const typeLabels = {
|
|
12020
12022
|
"daemon": "\u{1F916} Daemon",
|
|
12023
|
+
"upgrade-daemon": "\u{1F504} Upgrade Daemon",
|
|
12021
12024
|
"worker": "\u{1F517} Workers",
|
|
12022
12025
|
"doctor": "\u{1FA7A} Doctor",
|
|
12023
12026
|
"unknown": "\u2753 Unknown"
|
|
@@ -12150,7 +12153,7 @@ function startDaemonControlServer({
|
|
|
12150
12153
|
|
|
12151
12154
|
function spawnAgentrixCLI(args, options = {}) {
|
|
12152
12155
|
const projectRoot = _package.projectPath();
|
|
12153
|
-
const entrypoint = path.join(projectRoot, "dist", "index.mjs");
|
|
12156
|
+
const entrypoint = path$1.join(projectRoot, "dist", "index.mjs");
|
|
12154
12157
|
const nodeArgs = ["--no-warnings", "--no-deprecation", entrypoint, ...args];
|
|
12155
12158
|
if (!fs$1.existsSync(entrypoint)) {
|
|
12156
12159
|
const errorMessage = `Entrypoint ${entrypoint} does not exist`;
|
|
@@ -12481,16 +12484,30 @@ const VALID_HOOK_NAMES = [
|
|
|
12481
12484
|
"RepositoryInit"
|
|
12482
12485
|
];
|
|
12483
12486
|
async function loadHooks(claudeDir) {
|
|
12484
|
-
const hooksDir =
|
|
12485
|
-
const hooksEntry = require$$1.join(hooksDir, "dist", "index.js");
|
|
12487
|
+
const hooksDir = path.join(claudeDir, "hooks");
|
|
12486
12488
|
if (!fs.existsSync(hooksDir)) {
|
|
12487
12489
|
return {};
|
|
12488
12490
|
}
|
|
12489
|
-
|
|
12491
|
+
const entryPoints = [
|
|
12492
|
+
path.join(hooksDir, "dist", "index.mjs"),
|
|
12493
|
+
path.join(hooksDir, "dist", "index.js"),
|
|
12494
|
+
path.join(hooksDir, "index.mjs"),
|
|
12495
|
+
path.join(hooksDir, "index.js")
|
|
12496
|
+
];
|
|
12497
|
+
let hooksEntry = null;
|
|
12498
|
+
for (const entry of entryPoints) {
|
|
12499
|
+
if (fs.existsSync(entry)) {
|
|
12500
|
+
hooksEntry = entry;
|
|
12501
|
+
break;
|
|
12502
|
+
}
|
|
12503
|
+
}
|
|
12504
|
+
if (!hooksEntry) {
|
|
12490
12505
|
console.warn(`[Hook Loader] Hooks not built: ${hooksDir}`);
|
|
12491
12506
|
console.warn("[Hook Loader] To build hooks, run:");
|
|
12492
12507
|
console.warn(`[Hook Loader] cd ${hooksDir}`);
|
|
12493
12508
|
console.warn("[Hook Loader] npm install && npm run build");
|
|
12509
|
+
console.warn("[Hook Loader] Or place hooks directly in:");
|
|
12510
|
+
console.warn(`[Hook Loader] ${path.join(hooksDir, "index.js")} or ${path.join(hooksDir, "index.mjs")}`);
|
|
12494
12511
|
return {};
|
|
12495
12512
|
}
|
|
12496
12513
|
try {
|
|
@@ -12806,7 +12823,7 @@ async function initialCommit(dir) {
|
|
|
12806
12823
|
await git.commit("Initial commit", { "--allow-empty": null });
|
|
12807
12824
|
}
|
|
12808
12825
|
async function gitClone(gitUrl, targetDir) {
|
|
12809
|
-
const parentDir = path.dirname(targetDir);
|
|
12826
|
+
const parentDir = path$1.dirname(targetDir);
|
|
12810
12827
|
if (!fs$1.existsSync(parentDir)) {
|
|
12811
12828
|
fs$1.mkdirSync(parentDir, { recursive: true });
|
|
12812
12829
|
}
|
|
@@ -12997,7 +13014,7 @@ async function generateAndSavePatch(workingDirectory, fromCommit, toCommit, data
|
|
|
12997
13014
|
if (!patch.trim()) {
|
|
12998
13015
|
return void 0;
|
|
12999
13016
|
}
|
|
13000
|
-
const patchPath = path.join(dataDir, "patch.diff");
|
|
13017
|
+
const patchPath = path$1.join(dataDir, "patch.diff");
|
|
13001
13018
|
await promises.writeFile(patchPath, patch);
|
|
13002
13019
|
return patchPath;
|
|
13003
13020
|
}
|
|
@@ -14032,7 +14049,7 @@ URL: ${result.pullRequestUrl}`
|
|
|
14032
14049
|
try {
|
|
14033
14050
|
const agentContext = shared.getAgentContext();
|
|
14034
14051
|
const agentDir = agentContext.resolveAgentDir(this.options.input.agentId);
|
|
14035
|
-
const claudeDir =
|
|
14052
|
+
const claudeDir = path.join(agentDir, ".claude");
|
|
14036
14053
|
const hooks = await loadHooks(claudeDir);
|
|
14037
14054
|
this.loadedHooks = hooks;
|
|
14038
14055
|
return hooks;
|
|
@@ -15748,9 +15765,9 @@ CRITICAL: Respond with ONLY the JSON object, no additional text before or after.
|
|
|
15748
15765
|
async function downloadImage(url, targetDir) {
|
|
15749
15766
|
try {
|
|
15750
15767
|
const urlPath = new URL(url).pathname;
|
|
15751
|
-
const extension = path.extname(urlPath) || ".jpg";
|
|
15768
|
+
const extension = path$1.extname(urlPath) || ".jpg";
|
|
15752
15769
|
const filename = `${node_crypto.randomUUID()}${extension}`;
|
|
15753
|
-
const filePath = path.join(targetDir, filename);
|
|
15770
|
+
const filePath = path$1.join(targetDir, filename);
|
|
15754
15771
|
const response = await fetch(url);
|
|
15755
15772
|
if (!response.ok) {
|
|
15756
15773
|
throw new Error(`Failed to download image: ${response.status} ${response.statusText}`);
|
|
@@ -16642,24 +16659,153 @@ function displayUpgradeNotification(result) {
|
|
|
16642
16659
|
function isAutoUpgradeDisabled() {
|
|
16643
16660
|
return process.env.AGENTRIX_DISABLE_AUTO_UPGRADE === "true";
|
|
16644
16661
|
}
|
|
16645
|
-
async function performAutoUpgrade() {
|
|
16662
|
+
async function performAutoUpgrade(upgradeCheck) {
|
|
16646
16663
|
try {
|
|
16647
16664
|
const { execSync: execSync2 } = await import('child_process');
|
|
16648
16665
|
console.log("");
|
|
16649
|
-
|
|
16650
|
-
|
|
16666
|
+
if (!upgradeCheck) {
|
|
16667
|
+
console.log(chalk.blue("\u{1F504} Checking for upgrades..."));
|
|
16668
|
+
upgradeCheck = await checkForUpgrades();
|
|
16669
|
+
}
|
|
16670
|
+
if (!upgradeCheck.hasUpgrade) {
|
|
16671
|
+
console.log(chalk.green("\u2713 Already on latest version"));
|
|
16672
|
+
console.log("");
|
|
16673
|
+
return true;
|
|
16674
|
+
}
|
|
16675
|
+
console.log(chalk.blue(`\u{1F504} Upgrading from ${upgradeCheck.currentVersion} to ${upgradeCheck.latestVersion}...`));
|
|
16676
|
+
execSync2("npm install -g @agentrix/cli@latest", { stdio: "inherit" });
|
|
16651
16677
|
console.log(chalk.green("\u2713 Upgrade complete"));
|
|
16652
16678
|
console.log("");
|
|
16653
16679
|
return true;
|
|
16654
16680
|
} catch (error) {
|
|
16655
16681
|
console.log("");
|
|
16656
16682
|
console.log(chalk.yellow("\u26A0\uFE0F Auto-upgrade failed"));
|
|
16657
|
-
console.log(chalk.dim(" You can upgrade manually with: npm
|
|
16683
|
+
console.log(chalk.dim(" You can upgrade manually with: npm install -g @agentrix/cli@latest"));
|
|
16658
16684
|
console.log("");
|
|
16659
16685
|
return false;
|
|
16660
16686
|
}
|
|
16661
16687
|
}
|
|
16662
16688
|
|
|
16689
|
+
const UPGRADE_CHECK_INTERVAL = 6 * 60 * 60 * 1e3;
|
|
16690
|
+
function getUpgradeDaemonStatePath() {
|
|
16691
|
+
const statePaths = _package.machine.getStatePaths();
|
|
16692
|
+
return path.join(path.dirname(statePaths.daemonStateFile), "upgrade-daemon.state.json");
|
|
16693
|
+
}
|
|
16694
|
+
function readUpgradeDaemonState() {
|
|
16695
|
+
try {
|
|
16696
|
+
const statePath = getUpgradeDaemonStatePath();
|
|
16697
|
+
if (!fs.existsSync(statePath)) {
|
|
16698
|
+
return null;
|
|
16699
|
+
}
|
|
16700
|
+
const content = fs.readFileSync(statePath, "utf-8");
|
|
16701
|
+
return JSON.parse(content);
|
|
16702
|
+
} catch {
|
|
16703
|
+
return null;
|
|
16704
|
+
}
|
|
16705
|
+
}
|
|
16706
|
+
function writeUpgradeDaemonState(state) {
|
|
16707
|
+
const statePath = getUpgradeDaemonStatePath();
|
|
16708
|
+
fs.writeFileSync(statePath, JSON.stringify(state, null, 2));
|
|
16709
|
+
}
|
|
16710
|
+
function deleteUpgradeDaemonState() {
|
|
16711
|
+
try {
|
|
16712
|
+
const statePath = getUpgradeDaemonStatePath();
|
|
16713
|
+
if (fs.existsSync(statePath)) {
|
|
16714
|
+
fs.unlinkSync(statePath);
|
|
16715
|
+
}
|
|
16716
|
+
} catch {
|
|
16717
|
+
}
|
|
16718
|
+
}
|
|
16719
|
+
function isProcessRunning(pid) {
|
|
16720
|
+
try {
|
|
16721
|
+
process.kill(pid, 0);
|
|
16722
|
+
return true;
|
|
16723
|
+
} catch {
|
|
16724
|
+
return false;
|
|
16725
|
+
}
|
|
16726
|
+
}
|
|
16727
|
+
function isUpgradeDaemonRunning() {
|
|
16728
|
+
const state = readUpgradeDaemonState();
|
|
16729
|
+
if (!state) {
|
|
16730
|
+
return false;
|
|
16731
|
+
}
|
|
16732
|
+
if (!isProcessRunning(state.pid)) {
|
|
16733
|
+
deleteUpgradeDaemonState();
|
|
16734
|
+
return false;
|
|
16735
|
+
}
|
|
16736
|
+
return true;
|
|
16737
|
+
}
|
|
16738
|
+
function stopUpgradeDaemon() {
|
|
16739
|
+
const state = readUpgradeDaemonState();
|
|
16740
|
+
if (!state) {
|
|
16741
|
+
return;
|
|
16742
|
+
}
|
|
16743
|
+
try {
|
|
16744
|
+
if (isProcessRunning(state.pid)) {
|
|
16745
|
+
process.kill(state.pid, "SIGTERM");
|
|
16746
|
+
}
|
|
16747
|
+
} catch {
|
|
16748
|
+
} finally {
|
|
16749
|
+
deleteUpgradeDaemonState();
|
|
16750
|
+
}
|
|
16751
|
+
}
|
|
16752
|
+
async function checkAndUpgrade() {
|
|
16753
|
+
if (isAutoUpgradeDisabled()) {
|
|
16754
|
+
return false;
|
|
16755
|
+
}
|
|
16756
|
+
const upgradeResult = await checkForUpgrades();
|
|
16757
|
+
if (upgradeResult.hasUpgrade) {
|
|
16758
|
+
const upgraded = await performAutoUpgrade(upgradeResult);
|
|
16759
|
+
if (upgraded) {
|
|
16760
|
+
await stopDaemon();
|
|
16761
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
16762
|
+
const daemonProcess = spawnAgentrixCLI(["daemon"], {
|
|
16763
|
+
detached: true,
|
|
16764
|
+
stdio: "ignore",
|
|
16765
|
+
env: process.env
|
|
16766
|
+
});
|
|
16767
|
+
daemonProcess.unref();
|
|
16768
|
+
return true;
|
|
16769
|
+
}
|
|
16770
|
+
}
|
|
16771
|
+
return false;
|
|
16772
|
+
}
|
|
16773
|
+
async function runUpgradeDaemonLoop() {
|
|
16774
|
+
writeUpgradeDaemonState({
|
|
16775
|
+
pid: process.pid,
|
|
16776
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
16777
|
+
});
|
|
16778
|
+
process.on("SIGTERM", () => {
|
|
16779
|
+
deleteUpgradeDaemonState();
|
|
16780
|
+
process.exit(0);
|
|
16781
|
+
});
|
|
16782
|
+
process.on("SIGINT", () => {
|
|
16783
|
+
deleteUpgradeDaemonState();
|
|
16784
|
+
process.exit(0);
|
|
16785
|
+
});
|
|
16786
|
+
try {
|
|
16787
|
+
await checkAndUpgrade();
|
|
16788
|
+
} catch (error) {
|
|
16789
|
+
}
|
|
16790
|
+
while (true) {
|
|
16791
|
+
await new Promise((resolve) => setTimeout(resolve, UPGRADE_CHECK_INTERVAL));
|
|
16792
|
+
try {
|
|
16793
|
+
await checkAndUpgrade();
|
|
16794
|
+
} catch (error) {
|
|
16795
|
+
}
|
|
16796
|
+
}
|
|
16797
|
+
}
|
|
16798
|
+
async function startUpgradeDaemon() {
|
|
16799
|
+
await runUpgradeDaemonLoop();
|
|
16800
|
+
}
|
|
16801
|
+
|
|
16802
|
+
var upgradeDaemon = /*#__PURE__*/Object.freeze({
|
|
16803
|
+
__proto__: null,
|
|
16804
|
+
isUpgradeDaemonRunning: isUpgradeDaemonRunning,
|
|
16805
|
+
startUpgradeDaemon: startUpgradeDaemon,
|
|
16806
|
+
stopUpgradeDaemon: stopUpgradeDaemon
|
|
16807
|
+
});
|
|
16808
|
+
|
|
16663
16809
|
const cli = yargs(helpers.hideBin(process.argv)).scriptName("agentrix").version(_package.packageJson.version).usage("$0 <command> [options]").option("debug", {
|
|
16664
16810
|
alias: "d",
|
|
16665
16811
|
type: "boolean",
|
|
@@ -16699,7 +16845,7 @@ cli.command("upgrade", "Upgrade CLI to the latest version", {}, async (argv) =>
|
|
|
16699
16845
|
}
|
|
16700
16846
|
}
|
|
16701
16847
|
try {
|
|
16702
|
-
const { version } = await Promise.resolve().then(function () { return require('./logger-
|
|
16848
|
+
const { version } = await Promise.resolve().then(function () { return require('./logger-ChBQkYk7.cjs'); }).then(function (n) { return n._package; });
|
|
16703
16849
|
console.log(chalk.green(`
|
|
16704
16850
|
\u2713 Now running version: ${version}`));
|
|
16705
16851
|
} catch {
|
|
@@ -16724,6 +16870,7 @@ cli.command("logout", "Logout from Agentrix", {}, async (argv) => {
|
|
|
16724
16870
|
process.exit(0);
|
|
16725
16871
|
});
|
|
16726
16872
|
cli.command("stop", "Stop the daemon", {}, async (argv) => {
|
|
16873
|
+
stopUpgradeDaemon();
|
|
16727
16874
|
await stopDaemon();
|
|
16728
16875
|
process.exit(0);
|
|
16729
16876
|
});
|
|
@@ -16844,6 +16991,17 @@ cli.command(
|
|
|
16844
16991
|
}
|
|
16845
16992
|
}
|
|
16846
16993
|
);
|
|
16994
|
+
cli.command(
|
|
16995
|
+
"upgrade-daemon",
|
|
16996
|
+
false,
|
|
16997
|
+
// Hidden command
|
|
16998
|
+
{},
|
|
16999
|
+
async (argv) => {
|
|
17000
|
+
const { startUpgradeDaemon } = await Promise.resolve().then(function () { return upgradeDaemon; });
|
|
17001
|
+
await startUpgradeDaemon();
|
|
17002
|
+
process.exit(0);
|
|
17003
|
+
}
|
|
17004
|
+
);
|
|
16847
17005
|
cli.command(
|
|
16848
17006
|
"start",
|
|
16849
17007
|
"Start daemon (if not running) and show status",
|
|
@@ -16858,41 +17016,6 @@ cli.command(
|
|
|
16858
17016
|
}
|
|
16859
17017
|
process.exit(1);
|
|
16860
17018
|
}
|
|
16861
|
-
const skipUpgradeCheck = process.env.AGENTRIX_SKIP_UPGRADE_CHECK === "true";
|
|
16862
|
-
const autoUpgradeDisabled = isAutoUpgradeDisabled();
|
|
16863
|
-
let upgradeResult = {
|
|
16864
|
-
hasUpgrade: false,
|
|
16865
|
-
currentVersion: "",
|
|
16866
|
-
latestVersion: null
|
|
16867
|
-
};
|
|
16868
|
-
if (!skipUpgradeCheck) {
|
|
16869
|
-
upgradeResult = await checkForUpgrades();
|
|
16870
|
-
}
|
|
16871
|
-
if (upgradeResult.hasUpgrade) {
|
|
16872
|
-
if (autoUpgradeDisabled) {
|
|
16873
|
-
displayUpgradeNotification(upgradeResult);
|
|
16874
|
-
} else {
|
|
16875
|
-
const upgraded = await performAutoUpgrade();
|
|
16876
|
-
if (upgraded) {
|
|
16877
|
-
console.log(chalk.green("\u2713 Restarting with new version..."));
|
|
16878
|
-
console.log("");
|
|
16879
|
-
const { execSync } = await import('child_process');
|
|
16880
|
-
try {
|
|
16881
|
-
execSync("agentrix start", {
|
|
16882
|
-
stdio: "inherit",
|
|
16883
|
-
env: {
|
|
16884
|
-
...process.env,
|
|
16885
|
-
// Set flag to prevent infinite upgrade loop
|
|
16886
|
-
AGENTRIX_SKIP_UPGRADE_CHECK: "true"
|
|
16887
|
-
}
|
|
16888
|
-
});
|
|
16889
|
-
process.exit(0);
|
|
16890
|
-
} catch (error) {
|
|
16891
|
-
console.log(chalk.yellow("\u26A0\uFE0F Failed to restart, continuing with upgrade..."));
|
|
16892
|
-
}
|
|
16893
|
-
}
|
|
16894
|
-
}
|
|
16895
|
-
}
|
|
16896
17019
|
const wasRunning = await isLatestDaemonRunning();
|
|
16897
17020
|
if (!wasRunning) {
|
|
16898
17021
|
console.log("Starting Agentrix background service...");
|
|
@@ -16916,6 +17039,22 @@ cli.command(
|
|
|
16916
17039
|
console.log(chalk.yellow("\u26A0\uFE0F Daemon may still be starting..."));
|
|
16917
17040
|
}
|
|
16918
17041
|
}
|
|
17042
|
+
const autoUpgradeDisabled = isAutoUpgradeDisabled();
|
|
17043
|
+
if (!autoUpgradeDisabled) {
|
|
17044
|
+
if (!isUpgradeDaemonRunning()) {
|
|
17045
|
+
const upgradeDaemonProcess = spawnAgentrixCLI(["upgrade-daemon"], {
|
|
17046
|
+
detached: true,
|
|
17047
|
+
stdio: "ignore",
|
|
17048
|
+
env: process.env
|
|
17049
|
+
});
|
|
17050
|
+
upgradeDaemonProcess.unref();
|
|
17051
|
+
}
|
|
17052
|
+
} else {
|
|
17053
|
+
const upgradeResult = await checkForUpgrades();
|
|
17054
|
+
if (upgradeResult.hasUpgrade) {
|
|
17055
|
+
displayUpgradeNotification(upgradeResult);
|
|
17056
|
+
}
|
|
17057
|
+
}
|
|
16919
17058
|
await runDoctorCommand("daemon");
|
|
16920
17059
|
process.exit(0);
|
|
16921
17060
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -4,12 +4,12 @@ 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-6H3e_sL6.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';
|
|
11
|
-
import { readFileSync, existsSync as existsSync$1 } from 'fs';
|
|
12
|
-
import
|
|
11
|
+
import fs$1, { readFileSync, existsSync as existsSync$1 } from 'fs';
|
|
12
|
+
import path$1, { join } from 'path';
|
|
13
13
|
import os from 'node:os';
|
|
14
14
|
import open from 'open';
|
|
15
15
|
import { io } from 'socket.io-client';
|
|
@@ -11412,7 +11412,7 @@ function requireMimeTypes () {
|
|
|
11412
11412
|
* MIT Licensed
|
|
11413
11413
|
*/
|
|
11414
11414
|
var db = requireMimeDb();
|
|
11415
|
-
var extname =
|
|
11415
|
+
var extname = path$1.extname;
|
|
11416
11416
|
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
11417
11417
|
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
11418
11418
|
exports$1.charset = charset;
|
|
@@ -11846,6 +11846,8 @@ async function findAllAgentrixProcesses() {
|
|
|
11846
11846
|
let type = "unknown";
|
|
11847
11847
|
if (cmd.includes(" worker")) {
|
|
11848
11848
|
type = "worker";
|
|
11849
|
+
} else if (cmd.includes(" upgrade-daemon")) {
|
|
11850
|
+
type = "upgrade-daemon";
|
|
11849
11851
|
} else if (cmd.includes(" daemon")) {
|
|
11850
11852
|
type = "daemon";
|
|
11851
11853
|
} else if (cmd.includes("doctor")) {
|
|
@@ -11998,6 +12000,7 @@ async function runDoctorCommand(filter) {
|
|
|
11998
12000
|
Object.entries(grouped).forEach(([type, processes]) => {
|
|
11999
12001
|
const typeLabels = {
|
|
12000
12002
|
"daemon": "\u{1F916} Daemon",
|
|
12003
|
+
"upgrade-daemon": "\u{1F504} Upgrade Daemon",
|
|
12001
12004
|
"worker": "\u{1F517} Workers",
|
|
12002
12005
|
"doctor": "\u{1FA7A} Doctor",
|
|
12003
12006
|
"unknown": "\u2753 Unknown"
|
|
@@ -12462,15 +12465,29 @@ const VALID_HOOK_NAMES = [
|
|
|
12462
12465
|
];
|
|
12463
12466
|
async function loadHooks(claudeDir) {
|
|
12464
12467
|
const hooksDir = join(claudeDir, "hooks");
|
|
12465
|
-
const hooksEntry = join(hooksDir, "dist", "index.js");
|
|
12466
12468
|
if (!existsSync$1(hooksDir)) {
|
|
12467
12469
|
return {};
|
|
12468
12470
|
}
|
|
12469
|
-
|
|
12471
|
+
const entryPoints = [
|
|
12472
|
+
join(hooksDir, "dist", "index.mjs"),
|
|
12473
|
+
join(hooksDir, "dist", "index.js"),
|
|
12474
|
+
join(hooksDir, "index.mjs"),
|
|
12475
|
+
join(hooksDir, "index.js")
|
|
12476
|
+
];
|
|
12477
|
+
let hooksEntry = null;
|
|
12478
|
+
for (const entry of entryPoints) {
|
|
12479
|
+
if (existsSync$1(entry)) {
|
|
12480
|
+
hooksEntry = entry;
|
|
12481
|
+
break;
|
|
12482
|
+
}
|
|
12483
|
+
}
|
|
12484
|
+
if (!hooksEntry) {
|
|
12470
12485
|
console.warn(`[Hook Loader] Hooks not built: ${hooksDir}`);
|
|
12471
12486
|
console.warn("[Hook Loader] To build hooks, run:");
|
|
12472
12487
|
console.warn(`[Hook Loader] cd ${hooksDir}`);
|
|
12473
12488
|
console.warn("[Hook Loader] npm install && npm run build");
|
|
12489
|
+
console.warn("[Hook Loader] Or place hooks directly in:");
|
|
12490
|
+
console.warn(`[Hook Loader] ${join(hooksDir, "index.js")} or ${join(hooksDir, "index.mjs")}`);
|
|
12474
12491
|
return {};
|
|
12475
12492
|
}
|
|
12476
12493
|
try {
|
|
@@ -16622,24 +16639,153 @@ function displayUpgradeNotification(result) {
|
|
|
16622
16639
|
function isAutoUpgradeDisabled() {
|
|
16623
16640
|
return process.env.AGENTRIX_DISABLE_AUTO_UPGRADE === "true";
|
|
16624
16641
|
}
|
|
16625
|
-
async function performAutoUpgrade() {
|
|
16642
|
+
async function performAutoUpgrade(upgradeCheck) {
|
|
16626
16643
|
try {
|
|
16627
16644
|
const { execSync: execSync2 } = await import('child_process');
|
|
16628
16645
|
console.log("");
|
|
16629
|
-
|
|
16630
|
-
|
|
16646
|
+
if (!upgradeCheck) {
|
|
16647
|
+
console.log(chalk.blue("\u{1F504} Checking for upgrades..."));
|
|
16648
|
+
upgradeCheck = await checkForUpgrades();
|
|
16649
|
+
}
|
|
16650
|
+
if (!upgradeCheck.hasUpgrade) {
|
|
16651
|
+
console.log(chalk.green("\u2713 Already on latest version"));
|
|
16652
|
+
console.log("");
|
|
16653
|
+
return true;
|
|
16654
|
+
}
|
|
16655
|
+
console.log(chalk.blue(`\u{1F504} Upgrading from ${upgradeCheck.currentVersion} to ${upgradeCheck.latestVersion}...`));
|
|
16656
|
+
execSync2("npm install -g @agentrix/cli@latest", { stdio: "inherit" });
|
|
16631
16657
|
console.log(chalk.green("\u2713 Upgrade complete"));
|
|
16632
16658
|
console.log("");
|
|
16633
16659
|
return true;
|
|
16634
16660
|
} catch (error) {
|
|
16635
16661
|
console.log("");
|
|
16636
16662
|
console.log(chalk.yellow("\u26A0\uFE0F Auto-upgrade failed"));
|
|
16637
|
-
console.log(chalk.dim(" You can upgrade manually with: npm
|
|
16663
|
+
console.log(chalk.dim(" You can upgrade manually with: npm install -g @agentrix/cli@latest"));
|
|
16638
16664
|
console.log("");
|
|
16639
16665
|
return false;
|
|
16640
16666
|
}
|
|
16641
16667
|
}
|
|
16642
16668
|
|
|
16669
|
+
const UPGRADE_CHECK_INTERVAL = 6 * 60 * 60 * 1e3;
|
|
16670
|
+
function getUpgradeDaemonStatePath() {
|
|
16671
|
+
const statePaths = machine.getStatePaths();
|
|
16672
|
+
return path$1.join(path$1.dirname(statePaths.daemonStateFile), "upgrade-daemon.state.json");
|
|
16673
|
+
}
|
|
16674
|
+
function readUpgradeDaemonState() {
|
|
16675
|
+
try {
|
|
16676
|
+
const statePath = getUpgradeDaemonStatePath();
|
|
16677
|
+
if (!fs$1.existsSync(statePath)) {
|
|
16678
|
+
return null;
|
|
16679
|
+
}
|
|
16680
|
+
const content = fs$1.readFileSync(statePath, "utf-8");
|
|
16681
|
+
return JSON.parse(content);
|
|
16682
|
+
} catch {
|
|
16683
|
+
return null;
|
|
16684
|
+
}
|
|
16685
|
+
}
|
|
16686
|
+
function writeUpgradeDaemonState(state) {
|
|
16687
|
+
const statePath = getUpgradeDaemonStatePath();
|
|
16688
|
+
fs$1.writeFileSync(statePath, JSON.stringify(state, null, 2));
|
|
16689
|
+
}
|
|
16690
|
+
function deleteUpgradeDaemonState() {
|
|
16691
|
+
try {
|
|
16692
|
+
const statePath = getUpgradeDaemonStatePath();
|
|
16693
|
+
if (fs$1.existsSync(statePath)) {
|
|
16694
|
+
fs$1.unlinkSync(statePath);
|
|
16695
|
+
}
|
|
16696
|
+
} catch {
|
|
16697
|
+
}
|
|
16698
|
+
}
|
|
16699
|
+
function isProcessRunning(pid) {
|
|
16700
|
+
try {
|
|
16701
|
+
process.kill(pid, 0);
|
|
16702
|
+
return true;
|
|
16703
|
+
} catch {
|
|
16704
|
+
return false;
|
|
16705
|
+
}
|
|
16706
|
+
}
|
|
16707
|
+
function isUpgradeDaemonRunning() {
|
|
16708
|
+
const state = readUpgradeDaemonState();
|
|
16709
|
+
if (!state) {
|
|
16710
|
+
return false;
|
|
16711
|
+
}
|
|
16712
|
+
if (!isProcessRunning(state.pid)) {
|
|
16713
|
+
deleteUpgradeDaemonState();
|
|
16714
|
+
return false;
|
|
16715
|
+
}
|
|
16716
|
+
return true;
|
|
16717
|
+
}
|
|
16718
|
+
function stopUpgradeDaemon() {
|
|
16719
|
+
const state = readUpgradeDaemonState();
|
|
16720
|
+
if (!state) {
|
|
16721
|
+
return;
|
|
16722
|
+
}
|
|
16723
|
+
try {
|
|
16724
|
+
if (isProcessRunning(state.pid)) {
|
|
16725
|
+
process.kill(state.pid, "SIGTERM");
|
|
16726
|
+
}
|
|
16727
|
+
} catch {
|
|
16728
|
+
} finally {
|
|
16729
|
+
deleteUpgradeDaemonState();
|
|
16730
|
+
}
|
|
16731
|
+
}
|
|
16732
|
+
async function checkAndUpgrade() {
|
|
16733
|
+
if (isAutoUpgradeDisabled()) {
|
|
16734
|
+
return false;
|
|
16735
|
+
}
|
|
16736
|
+
const upgradeResult = await checkForUpgrades();
|
|
16737
|
+
if (upgradeResult.hasUpgrade) {
|
|
16738
|
+
const upgraded = await performAutoUpgrade(upgradeResult);
|
|
16739
|
+
if (upgraded) {
|
|
16740
|
+
await stopDaemon();
|
|
16741
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
16742
|
+
const daemonProcess = spawnAgentrixCLI(["daemon"], {
|
|
16743
|
+
detached: true,
|
|
16744
|
+
stdio: "ignore",
|
|
16745
|
+
env: process.env
|
|
16746
|
+
});
|
|
16747
|
+
daemonProcess.unref();
|
|
16748
|
+
return true;
|
|
16749
|
+
}
|
|
16750
|
+
}
|
|
16751
|
+
return false;
|
|
16752
|
+
}
|
|
16753
|
+
async function runUpgradeDaemonLoop() {
|
|
16754
|
+
writeUpgradeDaemonState({
|
|
16755
|
+
pid: process.pid,
|
|
16756
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
16757
|
+
});
|
|
16758
|
+
process.on("SIGTERM", () => {
|
|
16759
|
+
deleteUpgradeDaemonState();
|
|
16760
|
+
process.exit(0);
|
|
16761
|
+
});
|
|
16762
|
+
process.on("SIGINT", () => {
|
|
16763
|
+
deleteUpgradeDaemonState();
|
|
16764
|
+
process.exit(0);
|
|
16765
|
+
});
|
|
16766
|
+
try {
|
|
16767
|
+
await checkAndUpgrade();
|
|
16768
|
+
} catch (error) {
|
|
16769
|
+
}
|
|
16770
|
+
while (true) {
|
|
16771
|
+
await new Promise((resolve) => setTimeout(resolve, UPGRADE_CHECK_INTERVAL));
|
|
16772
|
+
try {
|
|
16773
|
+
await checkAndUpgrade();
|
|
16774
|
+
} catch (error) {
|
|
16775
|
+
}
|
|
16776
|
+
}
|
|
16777
|
+
}
|
|
16778
|
+
async function startUpgradeDaemon() {
|
|
16779
|
+
await runUpgradeDaemonLoop();
|
|
16780
|
+
}
|
|
16781
|
+
|
|
16782
|
+
var upgradeDaemon = /*#__PURE__*/Object.freeze({
|
|
16783
|
+
__proto__: null,
|
|
16784
|
+
isUpgradeDaemonRunning: isUpgradeDaemonRunning,
|
|
16785
|
+
startUpgradeDaemon: startUpgradeDaemon,
|
|
16786
|
+
stopUpgradeDaemon: stopUpgradeDaemon
|
|
16787
|
+
});
|
|
16788
|
+
|
|
16643
16789
|
const cli = yargs(hideBin(process.argv)).scriptName("agentrix").version(packageJson.version).usage("$0 <command> [options]").option("debug", {
|
|
16644
16790
|
alias: "d",
|
|
16645
16791
|
type: "boolean",
|
|
@@ -16679,7 +16825,7 @@ cli.command("upgrade", "Upgrade CLI to the latest version", {}, async (argv) =>
|
|
|
16679
16825
|
}
|
|
16680
16826
|
}
|
|
16681
16827
|
try {
|
|
16682
|
-
const { version } = await import('./logger-
|
|
16828
|
+
const { version } = await import('./logger-6H3e_sL6.mjs').then(function (n) { return n._; });
|
|
16683
16829
|
console.log(chalk.green(`
|
|
16684
16830
|
\u2713 Now running version: ${version}`));
|
|
16685
16831
|
} catch {
|
|
@@ -16704,6 +16850,7 @@ cli.command("logout", "Logout from Agentrix", {}, async (argv) => {
|
|
|
16704
16850
|
process.exit(0);
|
|
16705
16851
|
});
|
|
16706
16852
|
cli.command("stop", "Stop the daemon", {}, async (argv) => {
|
|
16853
|
+
stopUpgradeDaemon();
|
|
16707
16854
|
await stopDaemon();
|
|
16708
16855
|
process.exit(0);
|
|
16709
16856
|
});
|
|
@@ -16824,6 +16971,17 @@ cli.command(
|
|
|
16824
16971
|
}
|
|
16825
16972
|
}
|
|
16826
16973
|
);
|
|
16974
|
+
cli.command(
|
|
16975
|
+
"upgrade-daemon",
|
|
16976
|
+
false,
|
|
16977
|
+
// Hidden command
|
|
16978
|
+
{},
|
|
16979
|
+
async (argv) => {
|
|
16980
|
+
const { startUpgradeDaemon } = await Promise.resolve().then(function () { return upgradeDaemon; });
|
|
16981
|
+
await startUpgradeDaemon();
|
|
16982
|
+
process.exit(0);
|
|
16983
|
+
}
|
|
16984
|
+
);
|
|
16827
16985
|
cli.command(
|
|
16828
16986
|
"start",
|
|
16829
16987
|
"Start daemon (if not running) and show status",
|
|
@@ -16838,41 +16996,6 @@ cli.command(
|
|
|
16838
16996
|
}
|
|
16839
16997
|
process.exit(1);
|
|
16840
16998
|
}
|
|
16841
|
-
const skipUpgradeCheck = process.env.AGENTRIX_SKIP_UPGRADE_CHECK === "true";
|
|
16842
|
-
const autoUpgradeDisabled = isAutoUpgradeDisabled();
|
|
16843
|
-
let upgradeResult = {
|
|
16844
|
-
hasUpgrade: false,
|
|
16845
|
-
currentVersion: "",
|
|
16846
|
-
latestVersion: null
|
|
16847
|
-
};
|
|
16848
|
-
if (!skipUpgradeCheck) {
|
|
16849
|
-
upgradeResult = await checkForUpgrades();
|
|
16850
|
-
}
|
|
16851
|
-
if (upgradeResult.hasUpgrade) {
|
|
16852
|
-
if (autoUpgradeDisabled) {
|
|
16853
|
-
displayUpgradeNotification(upgradeResult);
|
|
16854
|
-
} else {
|
|
16855
|
-
const upgraded = await performAutoUpgrade();
|
|
16856
|
-
if (upgraded) {
|
|
16857
|
-
console.log(chalk.green("\u2713 Restarting with new version..."));
|
|
16858
|
-
console.log("");
|
|
16859
|
-
const { execSync } = await import('child_process');
|
|
16860
|
-
try {
|
|
16861
|
-
execSync("agentrix start", {
|
|
16862
|
-
stdio: "inherit",
|
|
16863
|
-
env: {
|
|
16864
|
-
...process.env,
|
|
16865
|
-
// Set flag to prevent infinite upgrade loop
|
|
16866
|
-
AGENTRIX_SKIP_UPGRADE_CHECK: "true"
|
|
16867
|
-
}
|
|
16868
|
-
});
|
|
16869
|
-
process.exit(0);
|
|
16870
|
-
} catch (error) {
|
|
16871
|
-
console.log(chalk.yellow("\u26A0\uFE0F Failed to restart, continuing with upgrade..."));
|
|
16872
|
-
}
|
|
16873
|
-
}
|
|
16874
|
-
}
|
|
16875
|
-
}
|
|
16876
16999
|
const wasRunning = await isLatestDaemonRunning();
|
|
16877
17000
|
if (!wasRunning) {
|
|
16878
17001
|
console.log("Starting Agentrix background service...");
|
|
@@ -16896,6 +17019,22 @@ cli.command(
|
|
|
16896
17019
|
console.log(chalk.yellow("\u26A0\uFE0F Daemon may still be starting..."));
|
|
16897
17020
|
}
|
|
16898
17021
|
}
|
|
17022
|
+
const autoUpgradeDisabled = isAutoUpgradeDisabled();
|
|
17023
|
+
if (!autoUpgradeDisabled) {
|
|
17024
|
+
if (!isUpgradeDaemonRunning()) {
|
|
17025
|
+
const upgradeDaemonProcess = spawnAgentrixCLI(["upgrade-daemon"], {
|
|
17026
|
+
detached: true,
|
|
17027
|
+
stdio: "ignore",
|
|
17028
|
+
env: process.env
|
|
17029
|
+
});
|
|
17030
|
+
upgradeDaemonProcess.unref();
|
|
17031
|
+
}
|
|
17032
|
+
} else {
|
|
17033
|
+
const upgradeResult = await checkForUpgrades();
|
|
17034
|
+
if (upgradeResult.hasUpgrade) {
|
|
17035
|
+
displayUpgradeNotification(upgradeResult);
|
|
17036
|
+
}
|
|
17037
|
+
}
|
|
16899
17038
|
await runDoctorCommand("daemon");
|
|
16900
17039
|
process.exit(0);
|
|
16901
17040
|
}
|
package/dist/lib.cjs
CHANGED
package/dist/lib.mjs
CHANGED
|
@@ -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.9";
|
|
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";
|
|
@@ -6,14 +6,14 @@ var os = require('node:os');
|
|
|
6
6
|
var node_crypto = require('node:crypto');
|
|
7
7
|
var fs = require('node:fs');
|
|
8
8
|
var promises = require('node:fs/promises');
|
|
9
|
-
var path = require('node:path');
|
|
9
|
+
var path$1 = require('node:path');
|
|
10
10
|
var shared = require('@agentrix/shared');
|
|
11
|
-
var
|
|
11
|
+
var path = require('path');
|
|
12
12
|
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.9";
|
|
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";
|
|
@@ -185,10 +185,10 @@ var _package = /*#__PURE__*/Object.freeze({
|
|
|
185
185
|
version: version
|
|
186
186
|
});
|
|
187
187
|
|
|
188
|
-
const __dirname$1 =
|
|
188
|
+
const __dirname$1 = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('logger-ChBQkYk7.cjs', document.baseURI).href))));
|
|
189
189
|
function projectPath() {
|
|
190
|
-
const path =
|
|
191
|
-
return path;
|
|
190
|
+
const path$1 = path.resolve(__dirname$1, "..");
|
|
191
|
+
return path$1;
|
|
192
192
|
}
|
|
193
193
|
class Machine {
|
|
194
194
|
serverUrl;
|
|
@@ -206,9 +206,9 @@ class Machine {
|
|
|
206
206
|
this.isDaemonProcess = args[0] === "daemon";
|
|
207
207
|
this.serverUrl = process.env.AGENTRIX_SERVER_URL || "https://agentrix.xmz.ai";
|
|
208
208
|
this.webappUrl = process.env.AGENTRIX_WEBAPP_URL || "https://agentrix.xmz.ai";
|
|
209
|
-
this.agentrixHomeDir = process.env.AGENTRIX_HOME_DIR ? process.env.AGENTRIX_HOME_DIR.replace(/^~/, os.homedir()) : path.join(os.homedir(), ".agentrix");
|
|
210
|
-
this.agentrixWorkspaceHomeDir = process.env.AGENTRIX_WORKSPACE_HOME_DIR ? process.env.AGENTRIX_WORKSPACE_HOME_DIR.replace(/^~/, os.homedir()) : path.join(this.agentrixHomeDir, "workspaces");
|
|
211
|
-
this.agentrixAgentsHomeDir = process.env.AGENTRIX_AGENTS_HOME_DIR ? process.env.AGENTRIX_AGENTS_HOME_DIR.replace(/^~/, os.homedir()) : path.join(this.agentrixHomeDir, "agents");
|
|
209
|
+
this.agentrixHomeDir = process.env.AGENTRIX_HOME_DIR ? process.env.AGENTRIX_HOME_DIR.replace(/^~/, os.homedir()) : path$1.join(os.homedir(), ".agentrix");
|
|
210
|
+
this.agentrixWorkspaceHomeDir = process.env.AGENTRIX_WORKSPACE_HOME_DIR ? process.env.AGENTRIX_WORKSPACE_HOME_DIR.replace(/^~/, os.homedir()) : path$1.join(this.agentrixHomeDir, "workspaces");
|
|
211
|
+
this.agentrixAgentsHomeDir = process.env.AGENTRIX_AGENTS_HOME_DIR ? process.env.AGENTRIX_AGENTS_HOME_DIR.replace(/^~/, os.homedir()) : path$1.join(this.agentrixHomeDir, "agents");
|
|
212
212
|
this.disableCaffeinate = ["true", "1", "yes"].includes(
|
|
213
213
|
(process.env.AGENTRIX_DISABLE_CAFFEINATE ?? "").toLowerCase()
|
|
214
214
|
);
|
|
@@ -218,11 +218,11 @@ class Machine {
|
|
|
218
218
|
this.ensureDir(this.agentrixAgentsHomeDir);
|
|
219
219
|
this.statePaths = {
|
|
220
220
|
rootDir: this.agentrixHomeDir,
|
|
221
|
-
logsDir: this.ensureDir(path.join(this.agentrixHomeDir, "logs")),
|
|
222
|
-
settingsFile: path.join(this.agentrixHomeDir, "settings.json"),
|
|
223
|
-
credentialsFile: path.join(this.agentrixHomeDir, "credentials.json"),
|
|
224
|
-
daemonStateFile: path.join(this.agentrixHomeDir, "daemon.state.json"),
|
|
225
|
-
daemonLockFile: path.join(this.agentrixHomeDir, "daemon.state.json.lock")
|
|
221
|
+
logsDir: this.ensureDir(path$1.join(this.agentrixHomeDir, "logs")),
|
|
222
|
+
settingsFile: path$1.join(this.agentrixHomeDir, "settings.json"),
|
|
223
|
+
credentialsFile: path$1.join(this.agentrixHomeDir, "credentials.json"),
|
|
224
|
+
daemonStateFile: path$1.join(this.agentrixHomeDir, "daemon.state.json"),
|
|
225
|
+
daemonLockFile: path$1.join(this.agentrixHomeDir, "daemon.state.json.lock")
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
228
|
generateMachineId() {
|
|
@@ -357,22 +357,22 @@ class Machine {
|
|
|
357
357
|
if (cwd) {
|
|
358
358
|
return this.ensureDir(cwd.replace(/^~/, os.homedir()));
|
|
359
359
|
}
|
|
360
|
-
const workspaceDir = path.join(this.agentrixWorkspaceHomeDir, "users", userId, taskId, "project");
|
|
360
|
+
const workspaceDir = path$1.join(this.agentrixWorkspaceHomeDir, "users", userId, taskId, "project");
|
|
361
361
|
return this.ensureDir(workspaceDir);
|
|
362
362
|
}
|
|
363
363
|
resolveDataDir(userId, taskId) {
|
|
364
|
-
const dataDir = path.join(this.agentrixWorkspaceHomeDir, "users", userId, taskId, "data");
|
|
364
|
+
const dataDir = path$1.join(this.agentrixWorkspaceHomeDir, "users", userId, taskId, "data");
|
|
365
365
|
return this.ensureDir(dataDir);
|
|
366
366
|
}
|
|
367
367
|
resolveAttachmentsDir(userId, taskId) {
|
|
368
|
-
const attachmentsDir = path.join(this.resolveDataDir(userId, taskId), "attachments");
|
|
368
|
+
const attachmentsDir = path$1.join(this.resolveDataDir(userId, taskId), "attachments");
|
|
369
369
|
return this.ensureDir(attachmentsDir);
|
|
370
370
|
}
|
|
371
371
|
resolveAgentDir(agentId) {
|
|
372
|
-
return path.join(this.agentrixAgentsHomeDir, agentId);
|
|
372
|
+
return path$1.join(this.agentrixAgentsHomeDir, agentId);
|
|
373
373
|
}
|
|
374
374
|
getInitialCommitHashPath(userId, taskId) {
|
|
375
|
-
return path.join(this.resolveDataDir(userId, taskId), "initial-commit-hash.txt");
|
|
375
|
+
return path$1.join(this.resolveDataDir(userId, taskId), "initial-commit-hash.txt");
|
|
376
376
|
}
|
|
377
377
|
async readInitialCommitHash(userId, taskId) {
|
|
378
378
|
const path = this.getInitialCommitHashPath(userId, taskId);
|
|
@@ -391,13 +391,13 @@ class Machine {
|
|
|
391
391
|
await promises.writeFile(path, hash);
|
|
392
392
|
}
|
|
393
393
|
writeTaskInput(data) {
|
|
394
|
-
const path
|
|
395
|
-
const inputFile = path.join(path
|
|
394
|
+
const path = this.resolveDataDir(data.userId, data.taskId);
|
|
395
|
+
const inputFile = path$1.join(path, "input.json");
|
|
396
396
|
fs.writeFileSync(inputFile, JSON.stringify(data, null, 2));
|
|
397
397
|
}
|
|
398
398
|
readTaskInput(userId, taskId) {
|
|
399
|
-
const path
|
|
400
|
-
const inputFile = path.join(path
|
|
399
|
+
const path = this.resolveDataDir(userId, taskId);
|
|
400
|
+
const inputFile = path$1.join(path, "input.json");
|
|
401
401
|
if (!fs.existsSync(inputFile)) {
|
|
402
402
|
throw new Error(`Task input file does not exist: ${inputFile}`);
|
|
403
403
|
}
|
|
@@ -503,7 +503,7 @@ function getLogPath(context) {
|
|
|
503
503
|
return "";
|
|
504
504
|
}
|
|
505
505
|
const filename = context.type === "daemon" ? "daemon.log" : `task-${context.taskId}.log`;
|
|
506
|
-
return path.join(logsDir, filename);
|
|
506
|
+
return path$1.join(logsDir, filename);
|
|
507
507
|
}
|
|
508
508
|
|
|
509
509
|
var logger$1 = /*#__PURE__*/Object.freeze({
|