vigthoria-cli 1.10.37 → 1.10.47

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.
Files changed (58) hide show
  1. package/dist/commands/agent-session-menu.d.ts +19 -0
  2. package/dist/commands/agent-session-menu.js +155 -0
  3. package/dist/commands/auth.js +68 -51
  4. package/dist/commands/bridge.js +19 -12
  5. package/dist/commands/cancel.js +22 -15
  6. package/dist/commands/chat.d.ts +0 -28
  7. package/dist/commands/chat.js +407 -1254
  8. package/dist/commands/config.js +73 -33
  9. package/dist/commands/deploy.js +123 -83
  10. package/dist/commands/device.js +61 -21
  11. package/dist/commands/edit.js +39 -32
  12. package/dist/commands/explain.js +25 -18
  13. package/dist/commands/generate.js +44 -37
  14. package/dist/commands/hub.js +102 -95
  15. package/dist/commands/index.js +46 -41
  16. package/dist/commands/legion.js +186 -146
  17. package/dist/commands/review.js +36 -29
  18. package/dist/commands/security.js +12 -5
  19. package/dist/commands/wallet.js +35 -28
  20. package/dist/commands/workflow.js +20 -13
  21. package/dist/utils/brain-hub-client.js +5 -1
  22. package/dist/utils/bridge-client.js +52 -11
  23. package/dist/utils/codebase-indexer.js +41 -4
  24. package/dist/utils/context-ranker.js +21 -15
  25. package/dist/utils/files.js +42 -5
  26. package/dist/utils/logger.js +50 -42
  27. package/dist/utils/persona.js +8 -3
  28. package/dist/utils/post-write-validator.js +29 -22
  29. package/dist/utils/project-memory.js +23 -16
  30. package/dist/utils/task-display.js +20 -13
  31. package/dist/utils/workspace-brain-service.js +45 -8
  32. package/dist/utils/workspace-cache.js +26 -18
  33. package/dist/utils/workspace-stream.js +63 -21
  34. package/package.json +3 -6
  35. package/dist/commands/fork.d.ts +0 -17
  36. package/dist/commands/fork.js +0 -164
  37. package/dist/commands/history.d.ts +0 -17
  38. package/dist/commands/history.js +0 -113
  39. package/dist/commands/preview.d.ts +0 -55
  40. package/dist/commands/preview.js +0 -467
  41. package/dist/commands/replay.d.ts +0 -18
  42. package/dist/commands/replay.js +0 -156
  43. package/dist/commands/repo.d.ts +0 -97
  44. package/dist/commands/repo.js +0 -773
  45. package/dist/commands/update.d.ts +0 -9
  46. package/dist/commands/update.js +0 -201
  47. package/dist/index.d.ts +0 -21
  48. package/dist/index.js +0 -1823
  49. package/dist/utils/api.d.ts +0 -572
  50. package/dist/utils/api.js +0 -6548
  51. package/dist/utils/cli-state.d.ts +0 -54
  52. package/dist/utils/cli-state.js +0 -185
  53. package/dist/utils/config.d.ts +0 -85
  54. package/dist/utils/config.js +0 -267
  55. package/dist/utils/session.d.ts +0 -118
  56. package/dist/utils/session.js +0 -423
  57. package/dist/utils/tools.d.ts +0 -276
  58. package/dist/utils/tools.js +0 -3516
@@ -0,0 +1,19 @@
1
+ export interface AgentSessionConfig {
2
+ workspacePath: string;
3
+ debugMode: boolean;
4
+ autoApprove: boolean;
5
+ autoSave: boolean;
6
+ }
7
+ export interface AgentSessionMenuDefaults {
8
+ workspacePath?: string;
9
+ debugMode?: boolean;
10
+ autoApprove?: boolean;
11
+ autoSave?: boolean;
12
+ }
13
+ export interface AgentSessionMenuOptions {
14
+ prompt?: string;
15
+ json?: boolean;
16
+ projectProvided?: boolean;
17
+ }
18
+ export declare function shouldShowAgentSessionMenu(options?: AgentSessionMenuOptions): boolean;
19
+ export declare function runAgentSessionMenu(defaults?: AgentSessionMenuDefaults): Promise<AgentSessionConfig>;
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Interactive agent/operator session setup menu (Node inquirer — CLI equivalent of InquirerPy).
3
+ */
4
+ import chalk from 'chalk';
5
+ import inquirer from 'inquirer';
6
+ import * as fs from 'fs';
7
+ import * as os from 'os';
8
+ import * as path from 'path';
9
+
10
+ function validateExistingDirectory(input) {
11
+ const trimmed = String(input || '').trim().replace(/^['"]|['"]$/g, '');
12
+ if (!trimmed) {
13
+ return 'Path is required.';
14
+ }
15
+ const resolved = path.resolve(trimmed);
16
+ try {
17
+ if (!fs.existsSync(resolved)) {
18
+ return `Directory does not exist: ${resolved}`;
19
+ }
20
+ if (!fs.statSync(resolved).isDirectory()) {
21
+ return `Not a directory: ${resolved}`;
22
+ }
23
+ }
24
+ catch (error) {
25
+ return `Cannot access path: ${error?.message || error}`;
26
+ }
27
+ return true;
28
+ }
29
+
30
+ export function shouldShowAgentSessionMenu(options = {}) {
31
+ if (options.prompt) {
32
+ return false;
33
+ }
34
+ if (options.json) {
35
+ return false;
36
+ }
37
+ if (options.projectProvided) {
38
+ return false;
39
+ }
40
+ if (/^(1|true|yes)$/i.test(String(process.env.VIGTHORIA_NO_SESSION_MENU || ''))) {
41
+ return false;
42
+ }
43
+ return Boolean(process.stdout.isTTY && process.stdin.isTTY);
44
+ }
45
+
46
+ export async function runAgentSessionMenu(defaults = {}) {
47
+ const session = {
48
+ workspacePath: path.resolve(String(defaults.workspacePath || process.cwd())),
49
+ debugMode: defaults.debugMode === true,
50
+ autoApprove: defaults.autoApprove === true,
51
+ autoSave: defaults.autoSave !== false,
52
+ };
53
+ const recentHint = String(defaults.configuredRoot || '').trim();
54
+ let done = false;
55
+ let menuPass = 0;
56
+ while (!done) {
57
+ if (menuPass === 0) {
58
+ console.log();
59
+ console.log(chalk.cyan('═══ Agent Session Setup ═══'));
60
+ }
61
+ else {
62
+ console.log();
63
+ console.log(chalk.cyan('── Session settings ──'));
64
+ }
65
+ menuPass += 1;
66
+ console.log(chalk.gray(`Workspace: ${session.workspacePath}`));
67
+ if (recentHint && recentHint !== session.workspacePath) {
68
+ console.log(chalk.gray(`Configured default: ${recentHint}`));
69
+ }
70
+ console.log(chalk.gray(`Debug: ${session.debugMode ? 'on' : 'off'} | Auto-approve: ${session.autoApprove ? 'on' : 'off'} | Auto-save: ${session.autoSave ? 'on' : 'off'}`));
71
+ console.log();
72
+ const { action } = await inquirer.prompt([
73
+ {
74
+ type: 'list',
75
+ name: 'action',
76
+ message: 'Configure your session',
77
+ choices: [
78
+ { name: 'Set workspace path (existing directory)', value: 'set-workspace' },
79
+ { name: 'Create new directory and set as workspace', value: 'create-workspace' },
80
+ { name: 'Session settings (debug, auto-save, auto-approve)', value: 'settings' },
81
+ { name: 'Start session with current settings', value: 'start' },
82
+ ],
83
+ },
84
+ ]);
85
+ if (action === 'set-workspace') {
86
+ const { workspacePath } = await inquirer.prompt([
87
+ {
88
+ type: 'input',
89
+ name: 'workspacePath',
90
+ message: 'Workspace directory path:',
91
+ default: session.workspacePath,
92
+ validate: validateExistingDirectory,
93
+ },
94
+ ]);
95
+ session.workspacePath = path.resolve(workspacePath);
96
+ }
97
+ else if (action === 'create-workspace') {
98
+ const { basePath, folderName } = await inquirer.prompt([
99
+ {
100
+ type: 'input',
101
+ name: 'basePath',
102
+ message: 'Base directory:',
103
+ default: os.homedir(),
104
+ validate: validateExistingDirectory,
105
+ },
106
+ {
107
+ type: 'input',
108
+ name: 'folderName',
109
+ message: 'New folder name:',
110
+ validate: (value) => {
111
+ const trimmed = String(value || '').trim();
112
+ if (!trimmed) {
113
+ return 'Folder name is required.';
114
+ }
115
+ if (/[<>:"|?*\x00]/.test(trimmed)) {
116
+ return 'Folder name contains invalid characters.';
117
+ }
118
+ return true;
119
+ },
120
+ },
121
+ ]);
122
+ const target = path.join(path.resolve(basePath), String(folderName).trim());
123
+ fs.mkdirSync(target, { recursive: true });
124
+ session.workspacePath = target;
125
+ console.log(chalk.green(`Created workspace: ${target}`));
126
+ }
127
+ else if (action === 'settings') {
128
+ const settings = await inquirer.prompt([
129
+ {
130
+ type: 'confirm',
131
+ name: 'debugMode',
132
+ message: 'Enable debug mode (verbose logging)?',
133
+ default: session.debugMode,
134
+ },
135
+ {
136
+ type: 'confirm',
137
+ name: 'autoSave',
138
+ message: 'Auto-save session on exit?',
139
+ default: session.autoSave,
140
+ },
141
+ {
142
+ type: 'confirm',
143
+ name: 'autoApprove',
144
+ message: 'Auto-approve tool actions (dangerous)?',
145
+ default: session.autoApprove,
146
+ },
147
+ ]);
148
+ Object.assign(session, settings);
149
+ }
150
+ else {
151
+ done = true;
152
+ }
153
+ }
154
+ return session;
155
+ }
@@ -1,12 +1,29 @@
1
- import chalk from 'chalk';
2
- import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs';
3
- import { homedir } from 'os';
4
- import path from 'path';
5
- import readline from 'readline';
6
- import { Config } from '../utils/config.js';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loadAuthConfig = loadAuthConfig;
7
+ exports.saveAuthConfig = saveAuthConfig;
8
+ exports.clearAuthConfig = clearAuthConfig;
9
+ exports.getAuthToken = getAuthToken;
10
+ exports.login = login;
11
+ exports.logout = logout;
12
+ exports.whoami = whoami;
13
+ exports.doctor = doctor;
14
+ exports.handleLogin = handleLogin;
15
+ exports.handleLogout = handleLogout;
16
+ exports.statusAction = statusAction;
17
+ exports.registerAuthCommands = registerAuthCommands;
18
+ const chalk_1 = __importDefault(require("chalk"));
19
+ const fs_1 = require("fs");
20
+ const os_1 = require("os");
21
+ const path_1 = __importDefault(require("path"));
22
+ const readline_1 = __importDefault(require("readline"));
23
+ const config_js_1 = require("../utils/config.js");
7
24
  const DEFAULT_API_URL = 'https://coder.vigthoria.io';
8
- const CONFIG_DIR = path.join(homedir(), '.vigthoria');
9
- const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
25
+ const CONFIG_DIR = path_1.default.join((0, os_1.homedir)(), '.vigthoria');
26
+ const CONFIG_FILE = path_1.default.join(CONFIG_DIR, 'config.json');
10
27
  const KNOWN_AUTH_BASE_URLS = ['https://coder.vigthoria.io'];
11
28
  class HttpError extends Error {
12
29
  status;
@@ -39,11 +56,11 @@ function getAuthBaseCandidates(seedBaseUrl) {
39
56
  return uniqueStrings([seed, ...(peer ? [peer] : []), ...KNOWN_AUTH_BASE_URLS]).map(trimTrailingSlash);
40
57
  }
41
58
  function ensureConfigDir() {
42
- if (!existsSync(CONFIG_DIR)) {
43
- mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
59
+ if (!(0, fs_1.existsSync)(CONFIG_DIR)) {
60
+ (0, fs_1.mkdirSync)(CONFIG_DIR, { recursive: true, mode: 0o700 });
44
61
  }
45
62
  try {
46
- chmodSync(CONFIG_DIR, 0o700);
63
+ (0, fs_1.chmodSync)(CONFIG_DIR, 0o700);
47
64
  }
48
65
  catch {
49
66
  // Best-effort on non-POSIX filesystems.
@@ -51,7 +68,7 @@ function ensureConfigDir() {
51
68
  }
52
69
  function syncSharedConfig(config) {
53
70
  try {
54
- const shared = new Config();
71
+ const shared = new config_js_1.Config();
55
72
  shared.set('apiUrl', trimTrailingSlash(config.apiUrl || getApiUrl()));
56
73
  if (config.token) {
57
74
  shared.set('authToken', config.token);
@@ -72,7 +89,7 @@ function syncSharedConfig(config) {
72
89
  }
73
90
  function clearSharedConfigAuth() {
74
91
  try {
75
- const shared = new Config();
92
+ const shared = new config_js_1.Config();
76
93
  shared.set('authToken', null);
77
94
  shared.set('refreshToken', null);
78
95
  shared.set('userId', null);
@@ -120,12 +137,12 @@ function extractAuthUser(payload, fallbackEmail) {
120
137
  }
121
138
  return fallbackEmail ? { email: fallbackEmail } : undefined;
122
139
  }
123
- export function loadAuthConfig() {
124
- if (!existsSync(CONFIG_FILE)) {
140
+ function loadAuthConfig() {
141
+ if (!(0, fs_1.existsSync)(CONFIG_FILE)) {
125
142
  return { apiUrl: getApiUrl() };
126
143
  }
127
144
  try {
128
- const parsed = JSON.parse(readFileSync(CONFIG_FILE, 'utf8'));
145
+ const parsed = JSON.parse((0, fs_1.readFileSync)(CONFIG_FILE, 'utf8'));
129
146
  return {
130
147
  apiUrl: trimTrailingSlash(parsed.apiUrl || getApiUrl()),
131
148
  token: parsed.token || parsed.authToken,
@@ -134,28 +151,28 @@ export function loadAuthConfig() {
134
151
  };
135
152
  }
136
153
  catch (error) {
137
- console.warn(chalk.yellow(`Warning: could not read auth config: ${humanMessage(error)}`));
154
+ console.warn(chalk_1.default.yellow(`Warning: could not read auth config: ${humanMessage(error)}`));
138
155
  return { apiUrl: getApiUrl() };
139
156
  }
140
157
  }
141
- export function saveAuthConfig(config) {
158
+ function saveAuthConfig(config) {
142
159
  ensureConfigDir();
143
- writeFileSync(CONFIG_FILE, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
160
+ (0, fs_1.writeFileSync)(CONFIG_FILE, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
144
161
  try {
145
- chmodSync(CONFIG_FILE, 0o600);
162
+ (0, fs_1.chmodSync)(CONFIG_FILE, 0o600);
146
163
  }
147
164
  catch {
148
165
  // Best-effort on non-POSIX filesystems.
149
166
  }
150
167
  syncSharedConfig(config);
151
168
  }
152
- export function clearAuthConfig() {
153
- if (existsSync(CONFIG_FILE)) {
154
- rmSync(CONFIG_FILE, { force: true });
169
+ function clearAuthConfig() {
170
+ if ((0, fs_1.existsSync)(CONFIG_FILE)) {
171
+ (0, fs_1.rmSync)(CONFIG_FILE, { force: true });
155
172
  }
156
173
  clearSharedConfigAuth();
157
174
  }
158
- export function getAuthToken() {
175
+ function getAuthToken() {
159
176
  return process.env.VIGTHORIA_TOKEN || loadAuthConfig().token;
160
177
  }
161
178
  async function requestJson(url, init) {
@@ -226,7 +243,7 @@ async function fetchV3ServiceKey(apiBase, token) {
226
243
  return undefined;
227
244
  }
228
245
  async function ask(question, hidden = false) {
229
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
246
+ const rl = readline_1.default.createInterface({ input: process.stdin, output: process.stdout });
230
247
  if (!hidden) {
231
248
  try {
232
249
  return await new Promise((resolve) => rl.question(question, resolve));
@@ -265,7 +282,7 @@ function markSuccessExit() {
265
282
  function markErrorExit() {
266
283
  process.exitCode = 1;
267
284
  }
268
- export async function login(email, password) {
285
+ async function login(email, password) {
269
286
  try {
270
287
  const resolvedEmail = (email || '').trim();
271
288
  const resolvedPassword = password || '';
@@ -322,7 +339,7 @@ export async function login(email, password) {
322
339
  throw new Error(message);
323
340
  }
324
341
  }
325
- export async function logout() {
342
+ async function logout() {
326
343
  const config = loadAuthConfig();
327
344
  if (config.token) {
328
345
  const bases = getAuthBaseCandidates(config.apiUrl || getApiUrl());
@@ -347,13 +364,13 @@ export async function logout() {
347
364
  }
348
365
  }
349
366
  if (!remoteLogoutDone) {
350
- console.warn(chalk.yellow('Remote logout endpoint not reachable; local credentials were still cleared.'));
367
+ console.warn(chalk_1.default.yellow('Remote logout endpoint not reachable; local credentials were still cleared.'));
351
368
  }
352
369
  }
353
370
  clearAuthConfig();
354
371
  process.exitCode = 0;
355
372
  }
356
- export async function whoami() {
373
+ async function whoami() {
357
374
  const config = loadAuthConfig();
358
375
  if (!config.token) {
359
376
  return undefined;
@@ -401,7 +418,7 @@ export async function whoami() {
401
418
  }
402
419
  throw new Error(`Unable to verify account on known auth endpoints. Tried ${attempted.join(', ')}`);
403
420
  }
404
- export async function doctor() {
421
+ async function doctor() {
405
422
  const config = loadAuthConfig();
406
423
  const report = {
407
424
  nodeVersion: process.version,
@@ -414,7 +431,7 @@ export async function doctor() {
414
431
  process.exitCode = 0;
415
432
  return report;
416
433
  }
417
- export async function handleLogin(options = {}) {
434
+ async function handleLogin(options = {}) {
418
435
  try {
419
436
  if (options.token) {
420
437
  const config = {
@@ -427,14 +444,14 @@ export async function handleLogin(options = {}) {
427
444
  config.v3ServiceKey = v3ServiceKey;
428
445
  }
429
446
  saveAuthConfig(config);
430
- console.log(chalk.green('Logged in successfully with API token.'));
447
+ console.log(chalk_1.default.green('Logged in successfully with API token.'));
431
448
  process.exitCode = 0;
432
449
  return config;
433
450
  }
434
451
  let email = options.email?.trim();
435
452
  let password = options.password;
436
453
  if (options.device) {
437
- console.log(chalk.yellow('Device-code login is not enabled by this Vigthoria service. Falling back to email and password authentication.'));
454
+ console.log(chalk_1.default.yellow('Device-code login is not enabled by this Vigthoria service. Falling back to email and password authentication.'));
438
455
  }
439
456
  if (!email) {
440
457
  email = (await ask('Email: ')).trim();
@@ -446,7 +463,7 @@ export async function handleLogin(options = {}) {
446
463
  throw new Error('Email and password are required. Use --email and --password, or run vigthoria login interactively.');
447
464
  }
448
465
  const config = await login(email, password);
449
- console.log(chalk.green('Logged in successfully.'));
466
+ console.log(chalk_1.default.green('Logged in successfully.'));
450
467
  if (config.user?.email) {
451
468
  console.log(`Account: ${config.user.email}`);
452
469
  }
@@ -472,7 +489,7 @@ export async function handleLogin(options = {}) {
472
489
  }
473
490
  catch { /* non-fatal — login already succeeded */ }
474
491
  try {
475
- const sharedConfig = new Config();
492
+ const sharedConfig = new config_js_1.Config();
476
493
  await sharedConfig.refreshHubModelPreferences();
477
494
  const hubPrefs = sharedConfig.get('hubModelPrefs');
478
495
  if (hubPrefs?.balance !== undefined) {
@@ -485,32 +502,32 @@ export async function handleLogin(options = {}) {
485
502
  return config;
486
503
  }
487
504
  catch (error) {
488
- console.error(chalk.red(`Login failed: ${humanMessage(error)}`));
505
+ console.error(chalk_1.default.red(`Login failed: ${humanMessage(error)}`));
489
506
  process.exitCode = 1;
490
507
  return undefined;
491
508
  }
492
509
  }
493
- export async function handleLogout(_options) {
510
+ async function handleLogout(_options) {
494
511
  try {
495
512
  await logout();
496
- console.log(chalk.green('Logged out successfully.'));
513
+ console.log(chalk_1.default.green('Logged out successfully.'));
497
514
  process.exitCode = 0;
498
515
  }
499
516
  catch (error) {
500
- console.error(chalk.red(`Logout failed: ${humanMessage(error)}`));
517
+ console.error(chalk_1.default.red(`Logout failed: ${humanMessage(error)}`));
501
518
  process.exitCode = 1;
502
519
  }
503
520
  }
504
- export async function statusAction() {
521
+ async function statusAction() {
505
522
  try {
506
523
  const legacyConfig = loadAuthConfig();
507
- const sharedConfig = new Config();
524
+ const sharedConfig = new config_js_1.Config();
508
525
  const sharedApiUrl = String(sharedConfig.get('apiUrl') || '').trim();
509
526
  const sharedToken = String(sharedConfig.get('authToken') || '').trim();
510
527
  const effectiveApiUrl = trimTrailingSlash(sharedApiUrl || legacyConfig.apiUrl || getApiUrl());
511
528
  const effectiveToken = sharedToken || legacyConfig.token || '';
512
529
  if (!effectiveToken) {
513
- console.log(chalk.yellow('Not logged in.'));
530
+ console.log(chalk_1.default.yellow('Not logged in.'));
514
531
  process.exitCode = 0;
515
532
  return;
516
533
  }
@@ -529,8 +546,8 @@ export async function statusAction() {
529
546
  // Network failures should not force logout status.
530
547
  }
531
548
  if (!authLooksValid) {
532
- console.log(chalk.yellow('Not logged in. Session expired or invalid.'));
533
- console.log(chalk.gray('Run: vigthoria login'));
549
+ console.log(chalk_1.default.yellow('Not logged in. Session expired or invalid.'));
550
+ console.log(chalk_1.default.gray('Run: vigthoria login'));
534
551
  process.exitCode = 1;
535
552
  return;
536
553
  }
@@ -562,8 +579,8 @@ export async function statusAction() {
562
579
  // Status should still render even if health probes fail.
563
580
  }
564
581
  const plan = String(sharedConfig.get('subscription')?.plan || '').trim();
565
- console.log(chalk.white('Account Status'));
566
- console.log(chalk.green('Logged in.'));
582
+ console.log(chalk_1.default.white('Account Status'));
583
+ console.log(chalk_1.default.green('Logged in.'));
567
584
  if (user?.email) {
568
585
  console.log(`Account: ${user.email}`);
569
586
  }
@@ -577,11 +594,11 @@ export async function statusAction() {
577
594
  process.exitCode = 0;
578
595
  }
579
596
  catch (error) {
580
- console.error(chalk.red(`Unable to read status: ${humanMessage(error)}`));
597
+ console.error(chalk_1.default.red(`Unable to read status: ${humanMessage(error)}`));
581
598
  process.exitCode = 1;
582
599
  }
583
600
  }
584
- export function registerAuthCommands(program) {
601
+ function registerAuthCommands(program) {
585
602
  const auth = program.command('auth').description('Manage Vigthoria CLI authentication');
586
603
  auth
587
604
  .command('login')
@@ -606,16 +623,16 @@ export function registerAuthCommands(program) {
606
623
  try {
607
624
  const user = await whoami();
608
625
  if (!user) {
609
- console.log(chalk.yellow('Not logged in.'));
626
+ console.log(chalk_1.default.yellow('Not logged in.'));
610
627
  process.exitCode = 0;
611
628
  return;
612
629
  }
613
- console.log(chalk.green('Logged in.'));
630
+ console.log(chalk_1.default.green('Logged in.'));
614
631
  console.log(user.email || user.name || user.id || 'Authenticated user');
615
632
  process.exitCode = 0;
616
633
  }
617
634
  catch (error) {
618
- console.error(chalk.red(`Unable to fetch account: ${humanMessage(error)}`));
635
+ console.error(chalk_1.default.red(`Unable to fetch account: ${humanMessage(error)}`));
619
636
  process.exitCode = 1;
620
637
  }
621
638
  });
@@ -1,27 +1,34 @@
1
- import chalk from 'chalk';
2
- import { createSpinner } from '../utils/logger.js';
3
- import { APIClient } from '../utils/api.js';
4
- export class BridgeCommand {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BridgeCommand = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const logger_js_1 = require("../utils/logger.js");
9
+ const api_js_1 = require("../utils/api.js");
10
+ class BridgeCommand {
5
11
  api;
6
12
  constructor(config, logger) {
7
- this.api = new APIClient(config, logger);
13
+ this.api = new api_js_1.APIClient(config, logger);
8
14
  }
9
15
  async status() {
10
- const spinner = createSpinner('Checking DevTools Bridge...').start();
16
+ const spinner = (0, logger_js_1.createSpinner)('Checking DevTools Bridge...').start();
11
17
  const bridge = await this.api.getDevtoolsBridgeStatus();
12
18
  spinner.stop();
13
19
  console.log();
14
- console.log(chalk.white('DevTools Bridge:'));
15
- console.log(chalk.gray(' Status: ') + (bridge.ok ? chalk.green('Reachable') : chalk.yellow('Not running')));
20
+ console.log(chalk_1.default.white('DevTools Bridge:'));
21
+ console.log(chalk_1.default.gray(' Status: ') + (bridge.ok ? chalk_1.default.green('Reachable') : chalk_1.default.yellow('Not running')));
16
22
  if (!bridge.ok) {
17
23
  const detail = String(bridge.error || 'Connection refused').trim() || 'Connection refused';
18
- console.log(chalk.gray(' Error: ') + chalk.yellow(detail));
24
+ console.log(chalk_1.default.gray(' Error: ') + chalk_1.default.yellow(detail));
19
25
  }
20
- console.log(chalk.gray(' Browser tasks: ') + (bridge.ok
21
- ? chalk.green('Local browser observability is available for debugging flows.')
22
- : chalk.gray('Start the DevTools Bridge to enable local browser observability.')));
26
+ console.log(chalk_1.default.gray(' Browser tasks: ') + (bridge.ok
27
+ ? chalk_1.default.green('Local browser observability is available for debugging flows.')
28
+ : chalk_1.default.gray('Start the DevTools Bridge to enable local browser observability.')));
23
29
  console.log();
24
30
  this.api.destroy();
25
31
  process.exitCode = 0;
26
32
  }
27
33
  }
34
+ exports.BridgeCommand = BridgeCommand;
@@ -1,4 +1,10 @@
1
- import { isServerRuntime } from '../utils/api.js';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CancelCommand = void 0;
7
+ const api_js_1 = require("../utils/api.js");
2
8
  /**
3
9
  * cancel.ts — Cancel an in-flight V3 agent run, or cancel all active runs.
4
10
  *
@@ -7,9 +13,9 @@ import { isServerRuntime } from '../utils/api.js';
7
13
  * vig cancel --all Cancel every currently-active run
8
14
  * vig cancel --list Just list active runs (no cancellation)
9
15
  */
10
- import chalk from 'chalk';
11
- import { createSpinner, CH } from '../utils/logger.js';
12
- export class CancelCommand {
16
+ const chalk_1 = __importDefault(require("chalk"));
17
+ const logger_js_1 = require("../utils/logger.js");
18
+ class CancelCommand {
13
19
  config;
14
20
  logger;
15
21
  constructor(config, logger) {
@@ -32,7 +38,7 @@ export class CancelCommand {
32
38
  }
33
39
  getBaseUrl() {
34
40
  const configuredApiUrl = String(this.config.get('apiUrl') || 'https://coder.vigthoria.io').replace(/\/$/, '');
35
- const allowLocal = !isServerRuntime() || process.env.VIGTHORIA_ALLOW_LOCAL_V3_AGENT === '1';
41
+ const allowLocal = !(0, api_js_1.isServerRuntime)() || process.env.VIGTHORIA_ALLOW_LOCAL_V3_AGENT === '1';
36
42
  return (process.env.VIGTHORIA_V3_AGENT_URL ||
37
43
  process.env.V3_AGENT_URL ||
38
44
  (allowLocal ? 'http://127.0.0.1:8030' : null) ||
@@ -74,7 +80,7 @@ export class CancelCommand {
74
80
  async run(contextId, options) {
75
81
  const baseUrl = this.getBaseUrl();
76
82
  if (options.list) {
77
- const spinner = createSpinner('Loading active runs...').start();
83
+ const spinner = (0, logger_js_1.createSpinner)('Loading active runs...').start();
78
84
  const active = await this.listActive(baseUrl);
79
85
  spinner.stop();
80
86
  if (!active)
@@ -84,34 +90,34 @@ export class CancelCommand {
84
90
  return;
85
91
  }
86
92
  if (active.active_count === 0) {
87
- this.logger.info(chalk.dim('No active runs.'));
93
+ this.logger.info(chalk_1.default.dim('No active runs.'));
88
94
  return;
89
95
  }
90
- console.log(chalk.bold(`\n${CH.success} Active Runs (${active.active_count}/${active.max_concurrent_runs})\n`));
96
+ console.log(chalk_1.default.bold(`\n${logger_js_1.CH.success} Active Runs (${active.active_count}/${active.max_concurrent_runs})\n`));
91
97
  for (const cid of active.active_context_ids) {
92
- console.log(` ${chalk.cyan(cid)}`);
98
+ console.log(` ${chalk_1.default.cyan(cid)}`);
93
99
  }
94
100
  console.log();
95
101
  return;
96
102
  }
97
103
  if (options.all) {
98
- const spinner = createSpinner('Loading active runs...').start();
104
+ const spinner = (0, logger_js_1.createSpinner)('Loading active runs...').start();
99
105
  const active = await this.listActive(baseUrl);
100
106
  spinner.stop();
101
107
  if (!active)
102
108
  return;
103
109
  if (active.active_count === 0) {
104
- this.logger.info(chalk.dim('No active runs to cancel.'));
110
+ this.logger.info(chalk_1.default.dim('No active runs to cancel.'));
105
111
  return;
106
112
  }
107
113
  const results = [];
108
114
  for (const cid of active.active_context_ids) {
109
- const sp = createSpinner(`Cancelling ${cid}...`).start();
115
+ const sp = (0, logger_js_1.createSpinner)(`Cancelling ${cid}...`).start();
110
116
  const r = await this.cancelOne(baseUrl, cid);
111
117
  sp.stop();
112
118
  if (r) {
113
119
  results.push(r);
114
- this.logger.success(`Cancelled ${chalk.cyan(cid)} (asyncio_cancelled=${r.asyncio_cancelled})`);
120
+ this.logger.success(`Cancelled ${chalk_1.default.cyan(cid)} (asyncio_cancelled=${r.asyncio_cancelled})`);
115
121
  }
116
122
  }
117
123
  if (options.json)
@@ -122,7 +128,7 @@ export class CancelCommand {
122
128
  this.logger.error('Usage: vig cancel <context_id> | --all | --list');
123
129
  return;
124
130
  }
125
- const spinner = createSpinner(`Cancelling ${contextId}...`).start();
131
+ const spinner = (0, logger_js_1.createSpinner)(`Cancelling ${contextId}...`).start();
126
132
  const r = await this.cancelOne(baseUrl, contextId);
127
133
  spinner.stop();
128
134
  if (!r)
@@ -131,7 +137,8 @@ export class CancelCommand {
131
137
  console.log(JSON.stringify(r, null, 2));
132
138
  return;
133
139
  }
134
- this.logger.success(`Cancelled ${chalk.cyan(contextId)} ` +
140
+ this.logger.success(`Cancelled ${chalk_1.default.cyan(contextId)} ` +
135
141
  `(asyncio_cancelled=${r.asyncio_cancelled}, active_runs_after=${r.active_runs_after})`);
136
142
  }
137
143
  }
144
+ exports.CancelCommand = CancelCommand;