@mndrk/agx 1.4.21 → 1.4.22

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/index.js CHANGED
@@ -7169,6 +7169,99 @@ async function checkOnboarding() {
7169
7169
  process.exit(0);
7170
7170
  }
7171
7171
 
7172
+ // ============================================================
7173
+ // agx update - Self-update and auto-update management
7174
+ // ============================================================
7175
+ if (cmd === 'update') {
7176
+ const subCmd = args[1];
7177
+ const CRON_MARKER = '# agx-auto-update';
7178
+ const CRON_SCHEDULE = '0 3 * * *'; // Daily at 3am
7179
+ const CRON_CMD = 'npm update -g @mndrk/agx';
7180
+
7181
+ // Helper to get current crontab
7182
+ const getCrontab = () => {
7183
+ try {
7184
+ return execSync('crontab -l 2>/dev/null', { encoding: 'utf8' });
7185
+ } catch {
7186
+ return '';
7187
+ }
7188
+ };
7189
+
7190
+ // Helper to set crontab
7191
+ const setCrontab = (content) => {
7192
+ const tmp = path.join(os.tmpdir(), `agx-crontab-${Date.now()}`);
7193
+ fs.writeFileSync(tmp, content);
7194
+ execSync(`crontab ${tmp}`);
7195
+ fs.unlinkSync(tmp);
7196
+ };
7197
+
7198
+ // Check if auto-update is enabled
7199
+ const isAutoEnabled = () => getCrontab().includes(CRON_MARKER);
7200
+
7201
+ if (subCmd === 'status' || subCmd === '--status') {
7202
+ const pkg = require('./package.json');
7203
+ console.log(`${c.bold}agx update status${c.reset}\n`);
7204
+ console.log(` Current version: ${c.cyan}${pkg.version}${c.reset}`);
7205
+ console.log(` Auto-update: ${isAutoEnabled() ? `${c.green}enabled${c.reset} (daily at 3am)` : `${c.dim}disabled${c.reset}`}`);
7206
+ process.exit(0);
7207
+ }
7208
+
7209
+ if (subCmd === '--auto' || subCmd === 'auto' || subCmd === 'enable') {
7210
+ if (isAutoEnabled()) {
7211
+ console.log(`${c.yellow}⚠${c.reset} Auto-update already enabled`);
7212
+ process.exit(0);
7213
+ }
7214
+ const crontab = getCrontab();
7215
+ const newLine = `${CRON_SCHEDULE} ${CRON_CMD} ${CRON_MARKER}\n`;
7216
+ try {
7217
+ setCrontab(crontab + newLine);
7218
+ console.log(`${c.green}✓${c.reset} Auto-update enabled (daily at 3am)`);
7219
+ console.log(` ${c.dim}To disable: agx update --off${c.reset}`);
7220
+ } catch (err) {
7221
+ console.log(`${c.yellow}⚠${c.reset} Could not modify crontab automatically.`);
7222
+ console.log(`\n Add this line to your crontab (${c.cyan}crontab -e${c.reset}):\n`);
7223
+ console.log(` ${c.dim}${CRON_SCHEDULE} ${CRON_CMD}${c.reset}\n`);
7224
+ }
7225
+ process.exit(0);
7226
+ }
7227
+
7228
+ if (subCmd === '--off' || subCmd === 'off' || subCmd === 'disable') {
7229
+ const crontab = getCrontab();
7230
+ if (!isAutoEnabled()) {
7231
+ console.log(`${c.dim}Auto-update not enabled${c.reset}`);
7232
+ process.exit(0);
7233
+ }
7234
+ const lines = crontab.split('\n').filter(l => !l.includes(CRON_MARKER));
7235
+ try {
7236
+ setCrontab(lines.join('\n'));
7237
+ console.log(`${c.green}✓${c.reset} Auto-update disabled`);
7238
+ } catch (err) {
7239
+ console.log(`${c.yellow}⚠${c.reset} Could not modify crontab automatically.`);
7240
+ console.log(`\n Remove the agx-auto-update line from your crontab (${c.cyan}crontab -e${c.reset})\n`);
7241
+ }
7242
+ process.exit(0);
7243
+ }
7244
+
7245
+ // Default: update now
7246
+ console.log(`${c.cyan}→${c.reset} Checking for updates...`);
7247
+ try {
7248
+ const result = spawnSync('npm', ['update', '-g', '@mndrk/agx'], {
7249
+ stdio: 'inherit',
7250
+ shell: true
7251
+ });
7252
+ if (result.status === 0) {
7253
+ console.log(`${c.green}✓${c.reset} Update complete`);
7254
+ } else {
7255
+ console.log(`${c.red}✗${c.reset} Update failed`);
7256
+ process.exit(1);
7257
+ }
7258
+ } catch (err) {
7259
+ console.error(`${c.red}✗${c.reset} Update failed: ${err.message}`);
7260
+ process.exit(1);
7261
+ }
7262
+ process.exit(0);
7263
+ }
7264
+
7172
7265
  // agx security - Manage daemon security settings
7173
7266
  if (cmd === 'security') {
7174
7267
  const securityCmd = args[1];
package/lib/cli/runCli.js CHANGED
@@ -2277,6 +2277,88 @@ async function checkOnboarding() {
2277
2277
  }
2278
2278
 
2279
2279
  // agx security - Manage daemon security settings
2280
+ // ============================================================
2281
+ // agx update - Self-update and auto-update management
2282
+ // ============================================================
2283
+ if (cmd === 'update') {
2284
+ const subCmd = args[1];
2285
+ const CRON_MARKER = '# agx-auto-update';
2286
+ const CRON_SCHEDULE = '0 3 * * *'; // Daily at 3am
2287
+ const CRON_CMD = 'npm update -g @mndrk/agx';
2288
+
2289
+ // Helper to get current crontab
2290
+ const getCrontab = () => {
2291
+ try {
2292
+ return execSync('crontab -l 2>/dev/null', { encoding: 'utf8' });
2293
+ } catch {
2294
+ return '';
2295
+ }
2296
+ };
2297
+
2298
+ // Helper to set crontab
2299
+ const setCrontab = (content) => {
2300
+ const tmp = path.join(os.tmpdir(), `agx-crontab-${Date.now()}`);
2301
+ fs.writeFileSync(tmp, content);
2302
+ execSync(`crontab ${tmp}`);
2303
+ fs.unlinkSync(tmp);
2304
+ };
2305
+
2306
+ // Check if auto-update is enabled
2307
+ const isAutoEnabled = () => getCrontab().includes(CRON_MARKER);
2308
+
2309
+ if (subCmd === 'status' || subCmd === '--status') {
2310
+ const pkg = require('../../package.json');
2311
+ console.log(`${c.bold}agx update status${c.reset}\n`);
2312
+ console.log(` Current version: ${c.cyan}${pkg.version}${c.reset}`);
2313
+ console.log(` Auto-update: ${isAutoEnabled() ? `${c.green}enabled${c.reset} (daily at 3am)` : `${c.dim}disabled${c.reset}`}`);
2314
+ process.exit(0);
2315
+ }
2316
+
2317
+ if (subCmd === '--auto' || subCmd === 'auto' || subCmd === 'enable') {
2318
+ if (isAutoEnabled()) {
2319
+ console.log(`${c.yellow}⚠${c.reset} Auto-update already enabled`);
2320
+ process.exit(0);
2321
+ }
2322
+ const crontab = getCrontab();
2323
+ const newLine = `${CRON_SCHEDULE} ${CRON_CMD} ${CRON_MARKER}\n`;
2324
+ setCrontab(crontab + newLine);
2325
+ console.log(`${c.green}✓${c.reset} Auto-update enabled (daily at 3am)`);
2326
+ console.log(` ${c.dim}To disable: agx update --off${c.reset}`);
2327
+ process.exit(0);
2328
+ }
2329
+
2330
+ if (subCmd === '--off' || subCmd === 'off' || subCmd === 'disable') {
2331
+ const crontab = getCrontab();
2332
+ if (!isAutoEnabled()) {
2333
+ console.log(`${c.dim}Auto-update not enabled${c.reset}`);
2334
+ process.exit(0);
2335
+ }
2336
+ const lines = crontab.split('\n').filter(l => !l.includes(CRON_MARKER));
2337
+ setCrontab(lines.join('\n'));
2338
+ console.log(`${c.green}✓${c.reset} Auto-update disabled`);
2339
+ process.exit(0);
2340
+ }
2341
+
2342
+ // Default: update now
2343
+ console.log(`${c.cyan}→${c.reset} Checking for updates...`);
2344
+ try {
2345
+ const result = spawnSync('npm', ['update', '-g', '@mndrk/agx'], {
2346
+ stdio: 'inherit',
2347
+ shell: true
2348
+ });
2349
+ if (result.status === 0) {
2350
+ console.log(`${c.green}✓${c.reset} Update complete`);
2351
+ } else {
2352
+ console.log(`${c.red}✗${c.reset} Update failed`);
2353
+ process.exit(1);
2354
+ }
2355
+ } catch (err) {
2356
+ console.error(`${c.red}✗${c.reset} Update failed: ${err.message}`);
2357
+ process.exit(1);
2358
+ }
2359
+ process.exit(0);
2360
+ }
2361
+
2280
2362
  if (cmd === 'security') {
2281
2363
  const securityCmd = args[1];
2282
2364
  const { loadSecurityConfig, setupDaemonSecret, SECURITY_CONFIG_FILE } = require('../security');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mndrk/agx",
3
- "version": "1.4.21",
3
+ "version": "1.4.22",
4
4
  "description": "Autonomous AI Agent Orchestrator for Claude, Gemini, and Ollama",
5
5
  "main": "lib/index.js",
6
6
  "exports": {