@mndrk/agx 1.4.21 → 1.4.23

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,102 @@ 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
+ try {
7195
+ execSync(`crontab ${tmp}`, { timeout: 5000 });
7196
+ } finally {
7197
+ try { fs.unlinkSync(tmp); } catch {}
7198
+ }
7199
+ };
7200
+
7201
+ // Check if auto-update is enabled
7202
+ const isAutoEnabled = () => getCrontab().includes(CRON_MARKER);
7203
+
7204
+ if (subCmd === 'status' || subCmd === '--status') {
7205
+ const pkg = require('./package.json');
7206
+ console.log(`${c.bold}agx update status${c.reset}\n`);
7207
+ console.log(` Current version: ${c.cyan}${pkg.version}${c.reset}`);
7208
+ console.log(` Auto-update: ${isAutoEnabled() ? `${c.green}enabled${c.reset} (daily at 3am)` : `${c.dim}disabled${c.reset}`}`);
7209
+ process.exit(0);
7210
+ }
7211
+
7212
+ if (subCmd === '--auto' || subCmd === 'auto' || subCmd === 'enable') {
7213
+ if (isAutoEnabled()) {
7214
+ console.log(`${c.yellow}⚠${c.reset} Auto-update already enabled`);
7215
+ process.exit(0);
7216
+ }
7217
+ const crontab = getCrontab();
7218
+ const newLine = `${CRON_SCHEDULE} ${CRON_CMD} ${CRON_MARKER}\n`;
7219
+ try {
7220
+ setCrontab(crontab + newLine);
7221
+ console.log(`${c.green}✓${c.reset} Auto-update enabled (daily at 3am)`);
7222
+ console.log(` ${c.dim}To disable: agx update --off${c.reset}`);
7223
+ } catch (err) {
7224
+ console.log(`${c.yellow}⚠${c.reset} Could not modify crontab automatically.`);
7225
+ console.log(`\n Add this line to your crontab (${c.cyan}crontab -e${c.reset}):\n`);
7226
+ console.log(` ${c.dim}${CRON_SCHEDULE} ${CRON_CMD}${c.reset}\n`);
7227
+ }
7228
+ process.exit(0);
7229
+ }
7230
+
7231
+ if (subCmd === '--off' || subCmd === 'off' || subCmd === 'disable') {
7232
+ const crontab = getCrontab();
7233
+ if (!isAutoEnabled()) {
7234
+ console.log(`${c.dim}Auto-update not enabled${c.reset}`);
7235
+ process.exit(0);
7236
+ }
7237
+ const lines = crontab.split('\n').filter(l => !l.includes(CRON_MARKER));
7238
+ try {
7239
+ setCrontab(lines.join('\n'));
7240
+ console.log(`${c.green}✓${c.reset} Auto-update disabled`);
7241
+ } catch (err) {
7242
+ console.log(`${c.yellow}⚠${c.reset} Could not modify crontab automatically.`);
7243
+ console.log(`\n Remove the agx-auto-update line from your crontab (${c.cyan}crontab -e${c.reset})\n`);
7244
+ }
7245
+ process.exit(0);
7246
+ }
7247
+
7248
+ // Default: update now
7249
+ console.log(`${c.cyan}→${c.reset} Checking for updates...`);
7250
+ try {
7251
+ const result = spawnSync('npm', ['update', '-g', '@mndrk/agx'], {
7252
+ stdio: 'inherit',
7253
+ shell: true
7254
+ });
7255
+ if (result.status === 0) {
7256
+ console.log(`${c.green}✓${c.reset} Update complete`);
7257
+ } else {
7258
+ console.log(`${c.red}✗${c.reset} Update failed`);
7259
+ process.exit(1);
7260
+ }
7261
+ } catch (err) {
7262
+ console.error(`${c.red}✗${c.reset} Update failed: ${err.message}`);
7263
+ process.exit(1);
7264
+ }
7265
+ process.exit(0);
7266
+ }
7267
+
7172
7268
  // agx security - Manage daemon security settings
7173
7269
  if (cmd === 'security') {
7174
7270
  const securityCmd = args[1];
package/lib/cli/runCli.js CHANGED
@@ -2277,6 +2277,102 @@ 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
+ try {
2303
+ execSync(`crontab ${tmp}`, { timeout: 5000 });
2304
+ } finally {
2305
+ try { fs.unlinkSync(tmp); } catch {}
2306
+ }
2307
+ };
2308
+
2309
+ // Check if auto-update is enabled
2310
+ const isAutoEnabled = () => getCrontab().includes(CRON_MARKER);
2311
+
2312
+ if (subCmd === 'status' || subCmd === '--status') {
2313
+ const pkg = require('../../package.json');
2314
+ console.log(`${c.bold}agx update status${c.reset}\n`);
2315
+ console.log(` Current version: ${c.cyan}${pkg.version}${c.reset}`);
2316
+ console.log(` Auto-update: ${isAutoEnabled() ? `${c.green}enabled${c.reset} (daily at 3am)` : `${c.dim}disabled${c.reset}`}`);
2317
+ process.exit(0);
2318
+ }
2319
+
2320
+ if (subCmd === '--auto' || subCmd === 'auto' || subCmd === 'enable') {
2321
+ if (isAutoEnabled()) {
2322
+ console.log(`${c.yellow}⚠${c.reset} Auto-update already enabled`);
2323
+ process.exit(0);
2324
+ }
2325
+ const crontab = getCrontab();
2326
+ const newLine = `${CRON_SCHEDULE} ${CRON_CMD} ${CRON_MARKER}\n`;
2327
+ try {
2328
+ setCrontab(crontab + newLine);
2329
+ console.log(`${c.green}✓${c.reset} Auto-update enabled (daily at 3am)`);
2330
+ console.log(` ${c.dim}To disable: agx update --off${c.reset}`);
2331
+ } catch (err) {
2332
+ console.log(`${c.yellow}⚠${c.reset} Could not modify crontab automatically.`);
2333
+ console.log(`\n Add this line to your crontab (${c.cyan}crontab -e${c.reset}):\n`);
2334
+ console.log(` ${c.dim}${CRON_SCHEDULE} ${CRON_CMD}${c.reset}\n`);
2335
+ }
2336
+ process.exit(0);
2337
+ }
2338
+
2339
+ if (subCmd === '--off' || subCmd === 'off' || subCmd === 'disable') {
2340
+ const crontab = getCrontab();
2341
+ if (!isAutoEnabled()) {
2342
+ console.log(`${c.dim}Auto-update not enabled${c.reset}`);
2343
+ process.exit(0);
2344
+ }
2345
+ const lines = crontab.split('\n').filter(l => !l.includes(CRON_MARKER));
2346
+ try {
2347
+ setCrontab(lines.join('\n'));
2348
+ console.log(`${c.green}✓${c.reset} Auto-update disabled`);
2349
+ } catch (err) {
2350
+ console.log(`${c.yellow}⚠${c.reset} Could not modify crontab automatically.`);
2351
+ console.log(`\n Remove the agx-auto-update line from your crontab (${c.cyan}crontab -e${c.reset})\n`);
2352
+ }
2353
+ process.exit(0);
2354
+ }
2355
+
2356
+ // Default: update now
2357
+ console.log(`${c.cyan}→${c.reset} Checking for updates...`);
2358
+ try {
2359
+ const result = spawnSync('npm', ['update', '-g', '@mndrk/agx'], {
2360
+ stdio: 'inherit',
2361
+ shell: true
2362
+ });
2363
+ if (result.status === 0) {
2364
+ console.log(`${c.green}✓${c.reset} Update complete`);
2365
+ } else {
2366
+ console.log(`${c.red}✗${c.reset} Update failed`);
2367
+ process.exit(1);
2368
+ }
2369
+ } catch (err) {
2370
+ console.error(`${c.red}✗${c.reset} Update failed: ${err.message}`);
2371
+ process.exit(1);
2372
+ }
2373
+ process.exit(0);
2374
+ }
2375
+
2280
2376
  if (cmd === 'security') {
2281
2377
  const securityCmd = args[1];
2282
2378
  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.23",
4
4
  "description": "Autonomous AI Agent Orchestrator for Claude, Gemini, and Ollama",
5
5
  "main": "lib/index.js",
6
6
  "exports": {