vigthoria-cli 1.9.2 → 1.9.8
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 +15 -5
- package/dist/commands/auth.d.ts +28 -38
- package/dist/commands/auth.js +461 -313
- package/dist/commands/bridge.js +3 -8
- package/dist/commands/chat.d.ts +3 -0
- package/dist/commands/chat.js +97 -34
- package/dist/commands/index.js +1 -1
- package/dist/commands/legion.d.ts +22 -19
- package/dist/commands/legion.js +561 -134
- package/dist/commands/preview.js +32 -7
- package/dist/commands/repo.js +19 -13
- package/dist/commands/security.d.ts +20 -0
- package/dist/commands/security.js +98 -0
- package/dist/commands/update.d.ts +9 -0
- package/dist/commands/update.js +235 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +147 -40
- package/dist/utils/api.d.ts +25 -70
- package/dist/utils/api.js +875 -693
- package/dist/utils/config.js +1 -1
- package/dist/utils/tools.d.ts +11 -0
- package/dist/utils/tools.js +251 -5
- package/install.ps1 +322 -0
- package/install.sh +314 -0
- package/package.json +18 -3
- package/scripts/release/LOCAL_MACHINE_USER_VERIFICATION.md +159 -0
- package/scripts/release/publish-cli-release.sh +73 -0
- package/scripts/release/validate-no-go-gates.sh +129 -0
- package/scripts/release/verify-runtime-consistency.mjs +64 -0
package/dist/index.js
CHANGED
|
@@ -54,6 +54,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
54
54
|
};
|
|
55
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
56
|
exports.__cliErrorHandlingReady = void 0;
|
|
57
|
+
exports.validateReleaseMetadata = validateReleaseMetadata;
|
|
57
58
|
exports.setupErrorHandlers = setupErrorHandlers;
|
|
58
59
|
exports.main = main;
|
|
59
60
|
const commander_1 = require("commander");
|
|
@@ -75,6 +76,7 @@ const history_js_1 = require("./commands/history.js");
|
|
|
75
76
|
const replay_js_1 = require("./commands/replay.js");
|
|
76
77
|
const fork_js_1 = require("./commands/fork.js");
|
|
77
78
|
const cancel_js_1 = require("./commands/cancel.js");
|
|
79
|
+
const security_js_1 = require("./commands/security.js");
|
|
78
80
|
const config_js_2 = require("./utils/config.js");
|
|
79
81
|
const logger_js_1 = require("./utils/logger.js");
|
|
80
82
|
const chalk_1 = __importDefault(require("chalk"));
|
|
@@ -96,17 +98,19 @@ function getInvokedBinaryName() {
|
|
|
96
98
|
return path.basename(executable, path.extname(executable)).toLowerCase();
|
|
97
99
|
}
|
|
98
100
|
// Get version from package.json dynamically
|
|
101
|
+
function getPackageMetadataPaths() {
|
|
102
|
+
return [
|
|
103
|
+
path.join(__dirname, '..', 'package.json'),
|
|
104
|
+
path.join(__dirname, '..', '..', 'package.json'),
|
|
105
|
+
path.join(process.cwd(), 'package.json'),
|
|
106
|
+
path.join(process.cwd(), 'node_modules', 'vigthoria-cli', 'package.json'),
|
|
107
|
+
// Also check global npm paths on Windows
|
|
108
|
+
path.join(process.env.APPDATA || '', 'npm', 'node_modules', 'vigthoria-cli', 'package.json'),
|
|
109
|
+
];
|
|
110
|
+
}
|
|
99
111
|
function getVersion() {
|
|
100
112
|
try {
|
|
101
|
-
|
|
102
|
-
const possiblePaths = [
|
|
103
|
-
path.join(__dirname, '..', 'package.json'),
|
|
104
|
-
path.join(__dirname, '..', '..', 'package.json'),
|
|
105
|
-
path.join(process.cwd(), 'node_modules', 'vigthoria-cli', 'package.json'),
|
|
106
|
-
// Also check global npm paths on Windows
|
|
107
|
-
path.join(process.env.APPDATA || '', 'npm', 'node_modules', 'vigthoria-cli', 'package.json'),
|
|
108
|
-
];
|
|
109
|
-
for (const p of possiblePaths) {
|
|
113
|
+
for (const p of getPackageMetadataPaths()) {
|
|
110
114
|
if (fs.existsSync(p)) {
|
|
111
115
|
const pkg = JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
112
116
|
if (pkg.name === 'vigthoria-cli') {
|
|
@@ -116,16 +120,55 @@ function getVersion() {
|
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
122
|
catch (e) {
|
|
119
|
-
|
|
123
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
124
|
+
if (process.env.VIGTHORIA_DEBUG_VERSION === '1') {
|
|
125
|
+
console.error(chalk_1.default.gray(`Unable to read package version: ${message}`));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return '0.0.0';
|
|
129
|
+
}
|
|
130
|
+
function validateReleaseMetadata() {
|
|
131
|
+
try {
|
|
132
|
+
const packagePath = getPackageMetadataPaths().find((candidate) => fs.existsSync(candidate));
|
|
133
|
+
if (!packagePath) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
|
137
|
+
const packageDir = path.dirname(packagePath);
|
|
138
|
+
const readmePath = path.join(packageDir, 'README.md');
|
|
139
|
+
if (!fs.existsSync(readmePath)) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
const readme = fs.readFileSync(readmePath, 'utf8');
|
|
143
|
+
const bins = pkg.bin && typeof pkg.bin === 'object' ? pkg.bin : {};
|
|
144
|
+
const requiredReadmePhrases = [
|
|
145
|
+
'npm install -g vigthoria-cli',
|
|
146
|
+
'curl -fsSL https://cli.vigthoria.io/install.sh | bash',
|
|
147
|
+
'irm https://cli.vigthoria.io/install.ps1 | iex',
|
|
148
|
+
'vigthoria login',
|
|
149
|
+
'vigthoria chat',
|
|
150
|
+
'vig c',
|
|
151
|
+
'vigthoria edit',
|
|
152
|
+
'vigthoria update',
|
|
153
|
+
'vigthoria doctor',
|
|
154
|
+
];
|
|
155
|
+
return (pkg.name === 'vigthoria-cli' &&
|
|
156
|
+
typeof pkg.version === 'string' &&
|
|
157
|
+
pkg.description === 'Vigthoria Coder CLI - AI-powered terminal coding assistant' &&
|
|
158
|
+
pkg.main === 'dist/index.js' &&
|
|
159
|
+
bins.vigthoria === 'dist/index.js' &&
|
|
160
|
+
bins.vig === 'dist/index.js' &&
|
|
161
|
+
bins['vigthoria-chat'] === 'dist/index.js' &&
|
|
162
|
+
requiredReadmePhrases.every((phrase) => readme.includes(phrase)));
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
166
|
+
if (process.env.VIGTHORIA_DEBUG_VERSION === '1') {
|
|
167
|
+
console.error(chalk_1.default.gray(`Release metadata validation failed: ${message}`));
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
120
170
|
}
|
|
121
|
-
return '1.9.2';
|
|
122
171
|
}
|
|
123
|
-
const VERSION = getVersion();
|
|
124
|
-
const VIGTHORIA_DEFAULT_MANIFEST_URL = process.env.VIGTHORIA_UPDATE_MANIFEST_URL || "https://coder.vigthoria.io/releases/manifest.json";
|
|
125
|
-
/**
|
|
126
|
-
* Compare semantic versions properly
|
|
127
|
-
* Returns: -1 if v1 < v2, 0 if equal, 1 if v1 > v2
|
|
128
|
-
*/
|
|
129
172
|
function compareVersions(v1, v2) {
|
|
130
173
|
const parts1 = v1.split('.').map(Number);
|
|
131
174
|
const parts2 = v2.split('.').map(Number);
|
|
@@ -139,6 +182,8 @@ function compareVersions(v1, v2) {
|
|
|
139
182
|
}
|
|
140
183
|
return 0;
|
|
141
184
|
}
|
|
185
|
+
const VERSION = getVersion();
|
|
186
|
+
const VIGTHORIA_DEFAULT_MANIFEST_URL = process.env.VIGTHORIA_UPDATE_MANIFEST_URL || "https://coder.vigthoria.io/releases/manifest.json";
|
|
142
187
|
function resolveManifestEntry(manifest, channel) {
|
|
143
188
|
const normalized = String(channel || 'stable').trim() || 'stable';
|
|
144
189
|
if (manifest.channels && manifest.channels[normalized]) {
|
|
@@ -177,6 +222,13 @@ async function installGlobalPackageWithNpm(packageSpec) {
|
|
|
177
222
|
const { execFileSync, execSync } = await import('child_process');
|
|
178
223
|
const attempts = [];
|
|
179
224
|
if (process.platform === 'win32') {
|
|
225
|
+
// First-choice: cmd.exe /c npm — resolves npm.cmd shims on any Windows Node setup
|
|
226
|
+
const comspec = process.env.COMSPEC || 'cmd.exe';
|
|
227
|
+
attempts.push({
|
|
228
|
+
label: 'cmd.exe /c npm',
|
|
229
|
+
command: comspec,
|
|
230
|
+
args: ['/c', 'npm', 'install', '-g', packageSpec],
|
|
231
|
+
});
|
|
180
232
|
const npmExecPath = process.env.npm_execpath;
|
|
181
233
|
if (npmExecPath && fs.existsSync(npmExecPath)) {
|
|
182
234
|
attempts.push({
|
|
@@ -403,32 +455,35 @@ function setupErrorHandlers() {
|
|
|
403
455
|
}
|
|
404
456
|
});
|
|
405
457
|
}
|
|
406
|
-
async function main() {
|
|
458
|
+
async function main(args) {
|
|
407
459
|
const program = new commander_1.Command();
|
|
408
460
|
const config = new config_js_2.Config();
|
|
409
461
|
const logger = new logger_js_1.Logger();
|
|
410
462
|
const invokedBinaryName = getInvokedBinaryName();
|
|
411
|
-
const
|
|
412
|
-
const
|
|
413
|
-
const
|
|
463
|
+
const argv = [...args];
|
|
464
|
+
const firstArg = argv[2];
|
|
465
|
+
const jsonOutputRequested = argv.includes('--json');
|
|
466
|
+
const directPromptRequested = argv.includes('--prompt') || argv.includes('-P');
|
|
467
|
+
const isLegionCortexRequest = invokedBinaryName === 'vigthoria' && argv[2] === 'legion' && argv.includes('--cortex');
|
|
414
468
|
if (invokedBinaryName === 'vigthoria-chat') {
|
|
415
469
|
const knownCommands = new Set([
|
|
416
470
|
'chat', 'chat-resume', 'agent', 'edit', 'generate', 'explain', 'fix', 'review', 'cancel',
|
|
417
|
-
'hub', 'repo', 'deploy', 'operator', 'workflow', 'flow', 'login', 'logout', 'status', 'config', 'update',
|
|
471
|
+
'hub', 'repo', 'deploy', 'operator', 'workflow', 'flow', 'security', 'vsec', 'login', 'logout', 'status', 'config', 'update',
|
|
418
472
|
'--help', '-h', '--version', '-V', 'help', 'version',
|
|
419
473
|
]);
|
|
420
474
|
if (!firstArg || firstArg.startsWith('-') || !knownCommands.has(firstArg)) {
|
|
421
|
-
|
|
475
|
+
argv.splice(2, 0, 'chat');
|
|
422
476
|
}
|
|
423
477
|
}
|
|
424
|
-
const requestedCommand = resolveRequestedCommand(
|
|
425
|
-
// Skip gateway JWT auth when running on-server with a service key (e.g.,
|
|
478
|
+
const requestedCommand = resolveRequestedCommand(argv);
|
|
479
|
+
// Skip gateway JWT auth when running on-server with a service key (e.g., Cortex on-box).
|
|
426
480
|
// The service key is checked by Hyper Loop directly — no user session needed.
|
|
427
481
|
const hasServiceKey = !!(process.env.HYPERLOOP_SERVICE_KEY ||
|
|
428
482
|
process.env.V3_SERVICE_KEY);
|
|
429
|
-
if (!hasServiceKey && requestedCommand && isAuthProtectedCommand(requestedCommand)) {
|
|
483
|
+
if (!hasServiceKey && !isLegionCortexRequest && requestedCommand && isAuthProtectedCommand(requestedCommand)) {
|
|
430
484
|
const authOk = await enforceGatewayAuthSession(config, logger, jsonOutputRequested);
|
|
431
485
|
if (!authOk) {
|
|
486
|
+
process.exitCode = 1;
|
|
432
487
|
return;
|
|
433
488
|
}
|
|
434
489
|
}
|
|
@@ -584,6 +639,40 @@ async function main() {
|
|
|
584
639
|
const bridge = new bridge_js_1.BridgeCommand(config, logger);
|
|
585
640
|
await bridge.status();
|
|
586
641
|
});
|
|
642
|
+
// Security command group - Security DevOps scans and fix plans
|
|
643
|
+
const securityCommand = program
|
|
644
|
+
.command('security')
|
|
645
|
+
.alias('vsec')
|
|
646
|
+
.description('Run security scans, scores, and fix plans via Vigthoria MCP security tools');
|
|
647
|
+
securityCommand
|
|
648
|
+
.command('scan')
|
|
649
|
+
.description('Scan project for security issues')
|
|
650
|
+
.option('-d, --dir <path>', 'Directory to scan (default: current directory)')
|
|
651
|
+
.option('--json', 'Emit JSON output', false)
|
|
652
|
+
.action(async (options) => {
|
|
653
|
+
const security = new security_js_1.SecurityCommand(config, logger);
|
|
654
|
+
await security.scan({ dir: options.dir, json: options.json });
|
|
655
|
+
});
|
|
656
|
+
securityCommand
|
|
657
|
+
.command('score')
|
|
658
|
+
.description('Calculate project security score')
|
|
659
|
+
.option('-d, --dir <path>', 'Directory to score (default: current directory)')
|
|
660
|
+
.option('--json', 'Emit JSON output', false)
|
|
661
|
+
.action(async (options) => {
|
|
662
|
+
const security = new security_js_1.SecurityCommand(config, logger);
|
|
663
|
+
await security.score({ dir: options.dir, json: options.json });
|
|
664
|
+
});
|
|
665
|
+
securityCommand
|
|
666
|
+
.command('fix')
|
|
667
|
+
.description('Generate security fix plan')
|
|
668
|
+
.option('-d, --dir <path>', 'Directory to inspect (default: current directory)')
|
|
669
|
+
.option('-i, --issue-id <id>', 'Single issue id to target')
|
|
670
|
+
.option('--apply', 'Request auto-apply mode (safe mode still requires explicit patching)', false)
|
|
671
|
+
.option('--json', 'Emit JSON output', false)
|
|
672
|
+
.action(async (options) => {
|
|
673
|
+
const security = new security_js_1.SecurityCommand(config, logger);
|
|
674
|
+
await security.fix({ dir: options.dir, issueId: options.issueId, apply: options.apply, json: options.json });
|
|
675
|
+
});
|
|
587
676
|
// Edit command - Edit files with AI
|
|
588
677
|
program
|
|
589
678
|
.command('edit <file>')
|
|
@@ -988,13 +1077,18 @@ Examples:
|
|
|
988
1077
|
.description('Run parallel tasks via Hyper Loop Legion orchestrator')
|
|
989
1078
|
.option('--workers', 'List available Legion workers')
|
|
990
1079
|
.option('--status', 'Show Legion infrastructure status')
|
|
991
|
-
.option('--
|
|
992
|
-
.option('--approve', 'Auto-approve
|
|
1080
|
+
.option('--cortex', 'Vigthoria Cortex: maximum intelligence execution')
|
|
1081
|
+
.option('--approve', 'Auto-approve Cortex execution prompt')
|
|
993
1082
|
.option('--no-approve', 'Require interactive approval before execution')
|
|
994
|
-
.option('--auto-charge', 'Attempt direct VigCoin top-up when
|
|
995
|
-
.option('--plan-only', 'Run
|
|
996
|
-
.option('--
|
|
997
|
-
.option('--
|
|
1083
|
+
.option('--auto-charge', 'Attempt direct VigCoin top-up when Cortex balance is low')
|
|
1084
|
+
.option('--plan-only', 'Run Cortex estimator only; do not execute Legion job')
|
|
1085
|
+
.option('--force-budget', 'Allow execution when estimated budget exceeds the hard safe-stop ceiling')
|
|
1086
|
+
.option('--ignore-preflight', 'Bypass mandatory local preflight checks (no warranty)')
|
|
1087
|
+
.option('--speed', 'Enable speed mode (allows optional role skips when convergence is detected)')
|
|
1088
|
+
.option('--repro-cmd <command>', 'Local reproduction/preflight command to validate before cloud spend')
|
|
1089
|
+
.option('--expect-repro-fail', 'Require repro command to fail (non-zero) before proceeding')
|
|
1090
|
+
.option('--models <csv>', 'Comma-separated model IDs to constrain Cortex selection')
|
|
1091
|
+
.option('-t, --timeout <seconds>', 'Override Legion execution timeout in seconds (defaults to server policy)')
|
|
998
1092
|
.option('-w, --worker <name>', 'Execute a specific worker')
|
|
999
1093
|
.option('-p, --project <path>', 'Project directory', process.cwd())
|
|
1000
1094
|
.action(async (request, options) => {
|
|
@@ -1003,11 +1097,16 @@ Examples:
|
|
|
1003
1097
|
await legion.run(request, {
|
|
1004
1098
|
workers: options.workers,
|
|
1005
1099
|
status: options.status,
|
|
1006
|
-
|
|
1100
|
+
cortex: Boolean(options.cortex),
|
|
1007
1101
|
approve: options.approve,
|
|
1008
1102
|
noApprove: options.approve === false,
|
|
1009
1103
|
autoCharge: options.autoCharge,
|
|
1010
1104
|
planOnly: options.planOnly,
|
|
1105
|
+
forceBudget: options.forceBudget,
|
|
1106
|
+
ignorePreflight: options.ignorePreflight,
|
|
1107
|
+
speed: options.speed,
|
|
1108
|
+
reproCmd: options.reproCmd,
|
|
1109
|
+
expectReproFail: options.expectReproFail,
|
|
1011
1110
|
models: options.models,
|
|
1012
1111
|
timeoutSec: Number.isFinite(parsedTimeout) && parsedTimeout > 0 ? parsedTimeout : undefined,
|
|
1013
1112
|
worker: options.worker,
|
|
@@ -1060,8 +1159,11 @@ Examples:
|
|
|
1060
1159
|
// Auth commands
|
|
1061
1160
|
program
|
|
1062
1161
|
.command('login')
|
|
1063
|
-
.description('Login to Vigthoria Coder')
|
|
1064
|
-
.option('-t, --token <token>', 'API token')
|
|
1162
|
+
.description('Login to Vigthoria Coder (prompts for credentials when run without flags)')
|
|
1163
|
+
.option('-t, --token <token>', 'API token for token-based authentication')
|
|
1164
|
+
.option('-e, --email <email>', 'Account email for credential-based login')
|
|
1165
|
+
.option('-p, --password <password>', 'Account password for credential-based login')
|
|
1166
|
+
.option('--device', 'Use OAuth device flow (requires server support)')
|
|
1065
1167
|
.action(async (options) => {
|
|
1066
1168
|
await (0, auth_js_1.handleLogin)(options);
|
|
1067
1169
|
});
|
|
@@ -1083,13 +1185,14 @@ Examples:
|
|
|
1083
1185
|
.action(() => {
|
|
1084
1186
|
const checks = [
|
|
1085
1187
|
['Node.js', process.version],
|
|
1086
|
-
['Platform',
|
|
1188
|
+
['Platform', `${process.platform} ${process.arch}`],
|
|
1087
1189
|
['Working directory', process.cwd()],
|
|
1088
1190
|
];
|
|
1089
1191
|
console.log('Vigthoria CLI diagnostics');
|
|
1090
1192
|
for (const [label, value] of checks) {
|
|
1091
1193
|
console.log(`- ${label}: ${value}`);
|
|
1092
1194
|
}
|
|
1195
|
+
process.exitCode = 0;
|
|
1093
1196
|
});
|
|
1094
1197
|
// Config command
|
|
1095
1198
|
program
|
|
@@ -1264,7 +1367,7 @@ Examples:
|
|
|
1264
1367
|
await legion.run(undefined, {
|
|
1265
1368
|
status: true,
|
|
1266
1369
|
workers: false,
|
|
1267
|
-
|
|
1370
|
+
cortex: false,
|
|
1268
1371
|
approve: false,
|
|
1269
1372
|
noApprove: true,
|
|
1270
1373
|
planOnly: false,
|
|
@@ -1317,12 +1420,16 @@ Examples:
|
|
|
1317
1420
|
}
|
|
1318
1421
|
try {
|
|
1319
1422
|
// Default to chat if no command
|
|
1320
|
-
if (
|
|
1423
|
+
if (args.length === 2) {
|
|
1321
1424
|
const chat = new chat_js_1.ChatCommand(config, logger);
|
|
1322
1425
|
await chat.run({ model: 'code', project: process.cwd() });
|
|
1426
|
+
process.exitCode = 0;
|
|
1323
1427
|
return;
|
|
1324
1428
|
}
|
|
1325
|
-
await program.parseAsync(
|
|
1429
|
+
await program.parseAsync(args);
|
|
1430
|
+
if (process.exitCode === undefined || process.exitCode === 0) {
|
|
1431
|
+
process.exitCode = 0;
|
|
1432
|
+
}
|
|
1326
1433
|
}
|
|
1327
1434
|
catch (error) {
|
|
1328
1435
|
reportCliError(error, jsonOutputRequested);
|
|
@@ -1336,7 +1443,7 @@ process.on('unhandledRejection', (reason) => {
|
|
|
1336
1443
|
});
|
|
1337
1444
|
async function bootstrapCli() {
|
|
1338
1445
|
try {
|
|
1339
|
-
await main();
|
|
1446
|
+
await main(process.argv);
|
|
1340
1447
|
}
|
|
1341
1448
|
catch (err) {
|
|
1342
1449
|
handleFatalCliError(err, process.argv.includes('--json'));
|
package/dist/utils/api.d.ts
CHANGED
|
@@ -9,30 +9,12 @@ export declare class CLIError extends Error {
|
|
|
9
9
|
category: CLIErrorCategory;
|
|
10
10
|
statusCode?: number;
|
|
11
11
|
endpoint?: string;
|
|
12
|
-
code: string;
|
|
13
|
-
details?: any;
|
|
14
|
-
isCritical: boolean;
|
|
15
12
|
constructor(message: string, category: CLIErrorCategory, opts?: {
|
|
16
13
|
statusCode?: number;
|
|
17
14
|
endpoint?: string;
|
|
18
15
|
cause?: Error;
|
|
19
16
|
});
|
|
20
17
|
}
|
|
21
|
-
export type CliError = {
|
|
22
|
-
code: string;
|
|
23
|
-
message: string;
|
|
24
|
-
details?: any;
|
|
25
|
-
isCritical: boolean;
|
|
26
|
-
};
|
|
27
|
-
export type ApiError = {
|
|
28
|
-
code: number;
|
|
29
|
-
message: string;
|
|
30
|
-
details?: any;
|
|
31
|
-
isAuthError: boolean;
|
|
32
|
-
};
|
|
33
|
-
export declare function handleApiError(error: any): CliError;
|
|
34
|
-
export declare function handleAuthError(error: any): CliError;
|
|
35
|
-
export declare function propagateError(err: any): never;
|
|
36
18
|
/** Classify an axios or fetch error into a structured CLIError. */
|
|
37
19
|
export declare function classifyError(error: unknown, fallbackCategory?: CLIErrorCategory): CLIError;
|
|
38
20
|
/** Format a CLIError for user-facing display. */
|
|
@@ -40,6 +22,7 @@ export declare function formatCLIError(err: CLIError): string;
|
|
|
40
22
|
export declare function sanitizeUserFacingErrorText(input: string): string;
|
|
41
23
|
export declare function isServerRuntime(): boolean;
|
|
42
24
|
export declare function describeUpstreamStatus(status: number): string;
|
|
25
|
+
export declare function propagateError(err: any): never;
|
|
43
26
|
export interface ChatMessage {
|
|
44
27
|
role: 'user' | 'assistant' | 'system';
|
|
45
28
|
content: string;
|
|
@@ -110,6 +93,7 @@ export interface OperatorWorkflowResponse {
|
|
|
110
93
|
sourceWorkflowId?: string | null;
|
|
111
94
|
} | null;
|
|
112
95
|
metadata?: Record<string, unknown>;
|
|
96
|
+
changedFiles?: Record<string, string>;
|
|
113
97
|
}
|
|
114
98
|
export interface StreamChunk {
|
|
115
99
|
type: 'content' | 'done' | 'error';
|
|
@@ -207,43 +191,26 @@ export interface VigthoriUser {
|
|
|
207
191
|
adminAccess: boolean;
|
|
208
192
|
};
|
|
209
193
|
}
|
|
210
|
-
export interface JwtPayload {
|
|
211
|
-
exp?: number;
|
|
212
|
-
iat?: number;
|
|
213
|
-
sub?: string;
|
|
214
|
-
[claim: string]: unknown;
|
|
215
|
-
}
|
|
216
|
-
export type JwtState = {
|
|
217
|
-
token: string | null;
|
|
218
|
-
expiresAt: number | null;
|
|
219
|
-
isExpired?: () => boolean;
|
|
220
|
-
};
|
|
221
|
-
export declare function validateJwtExpiry(token: string): boolean;
|
|
222
|
-
export declare function validateJwt(token: string): JwtPayload | null;
|
|
223
|
-
export type ApiConfig = Config;
|
|
224
|
-
export type ApiClient = APIClient;
|
|
225
|
-
export declare function refreshJwtIfNeeded(state: JwtState): Promise<string | null>;
|
|
226
|
-
export declare function createApiClient(config: any): {
|
|
227
|
-
get: (path: string) => Promise<any>;
|
|
228
|
-
post: (path: string, body: any) => Promise<any>;
|
|
229
|
-
handleAuthError: (err: any) => void;
|
|
230
|
-
};
|
|
231
194
|
export declare class APIClient {
|
|
232
195
|
private client;
|
|
233
196
|
private modelRouterClient;
|
|
234
197
|
private selfHostedModelRouterClient;
|
|
235
|
-
config
|
|
236
|
-
token: string | null;
|
|
237
|
-
expiresAt: number | null;
|
|
198
|
+
private config;
|
|
238
199
|
private logger;
|
|
239
200
|
private ws;
|
|
240
201
|
private vigFlowTokens;
|
|
202
|
+
private _httpsAgent;
|
|
241
203
|
constructor(config: Config, logger: Logger);
|
|
204
|
+
/**
|
|
205
|
+
* Destroy keep-alive sockets so the Node.js event loop can drain
|
|
206
|
+
* naturally. Call this before exiting commands that run HTTP probes
|
|
207
|
+
* (e.g. `status`) to avoid the libuv UV_HANDLE_CLOSING assertion
|
|
208
|
+
* on Windows / Node 25+.
|
|
209
|
+
*/
|
|
242
210
|
destroy(): void;
|
|
243
211
|
private getSelfHostedModelsApiUrl;
|
|
244
212
|
login(email: string, password: string): Promise<boolean>;
|
|
245
213
|
loginWithToken(token: string): Promise<boolean>;
|
|
246
|
-
private decodeJwtPayload;
|
|
247
214
|
private extractUserProfile;
|
|
248
215
|
private refreshToken;
|
|
249
216
|
getSubscriptionStatus(): Promise<void>;
|
|
@@ -267,7 +234,6 @@ export declare class APIClient {
|
|
|
267
234
|
getMcpBaseUrls(): string[];
|
|
268
235
|
getVigFlowBaseUrls(): string[];
|
|
269
236
|
getTemplateServiceBaseUrls(): string[];
|
|
270
|
-
private allowLocalServiceFallbacks;
|
|
271
237
|
private isFrontendTask;
|
|
272
238
|
/**
|
|
273
239
|
* Returns true when the prompt describes a read-only / analysis task.
|
|
@@ -328,6 +294,7 @@ export declare class APIClient {
|
|
|
328
294
|
private compactV3Context;
|
|
329
295
|
buildMinimalV3AgentContext(context?: Record<string, any>): string;
|
|
330
296
|
private extractEmergencyAppName;
|
|
297
|
+
private materializeEmergencySaaSWorkspace;
|
|
331
298
|
private ensureExecutionContext;
|
|
332
299
|
bindExecutionContext(context?: Record<string, any>): Promise<Record<string, any>>;
|
|
333
300
|
private resolveAgentTargetPath;
|
|
@@ -398,6 +365,11 @@ export declare class APIClient {
|
|
|
398
365
|
* Ensure code has balanced curly braces by appending missing closing braces.
|
|
399
366
|
*/
|
|
400
367
|
private ensureBalancedBraces;
|
|
368
|
+
/**
|
|
369
|
+
* Quick JS/TS syntax validation using Node's built-in parser.
|
|
370
|
+
* Returns true if the code parses without errors.
|
|
371
|
+
*/
|
|
372
|
+
private validateJsSyntax;
|
|
401
373
|
/**
|
|
402
374
|
* Extract the first complete function/class from code.
|
|
403
375
|
* Used as last-resort when the model keeps over-producing.
|
|
@@ -481,39 +453,22 @@ export declare class APIClient {
|
|
|
481
453
|
* the fix has fewer closers than the original, appends the missing ones.
|
|
482
454
|
*/
|
|
483
455
|
private repairBracketBalance;
|
|
484
|
-
/**
|
|
485
|
-
* Build workspace summary re-ordered by semantic relevance to the prompt.
|
|
486
|
-
* Changed files are listed first, then keyword-matched files, then the rest.
|
|
487
|
-
* Falls back to plain buildLocalWorkspaceSummary when no prompt is provided.
|
|
488
|
-
*/
|
|
489
|
-
private buildSemanticWorkspaceSummary;
|
|
490
|
-
/**
|
|
491
|
-
* Self-healing cycle: run post-write validators and, if errors are found,
|
|
492
|
-
* send a targeted correction prompt to the V3 agent (max one healing round).
|
|
493
|
-
*
|
|
494
|
-
* This is a best-effort operation — failures never propagate to the user as
|
|
495
|
-
* hard errors; they are surfaced as a status line in the terminal output.
|
|
496
|
-
*/
|
|
497
|
-
runSelfHealingCycle(originalPrompt: string, workspacePath: string, context?: Record<string, any>): Promise<{
|
|
498
|
-
healingAttempted: boolean;
|
|
499
|
-
passed: boolean;
|
|
500
|
-
tool: string;
|
|
501
|
-
}>;
|
|
502
456
|
private resolveModelId;
|
|
503
457
|
private getCoderHealth;
|
|
504
458
|
private getModelsHealth;
|
|
505
459
|
private getSelfHostedHealth;
|
|
506
|
-
attemptV3ServiceRecovery(reason?: string, options?: {
|
|
507
|
-
attempts?: number;
|
|
508
|
-
delayMs?: number;
|
|
509
|
-
}): Promise<{
|
|
510
|
-
recovered: boolean;
|
|
511
|
-
message: string;
|
|
512
|
-
endpoint?: string;
|
|
513
|
-
}>;
|
|
514
460
|
private getV3AgentHealth;
|
|
515
461
|
private getHyperLoopHealth;
|
|
516
462
|
private getRepoMemoryHealth;
|
|
463
|
+
runSelfHealingCycle(_originalPrompt: string, _workspacePath: string, _context?: Record<string, any>): Promise<{
|
|
464
|
+
healingAttempted: boolean;
|
|
465
|
+
passed: boolean;
|
|
466
|
+
tool: string;
|
|
467
|
+
}>;
|
|
468
|
+
attemptV3ServiceRecovery(reason?: string, _options?: Record<string, any>): Promise<{
|
|
469
|
+
recovered: boolean;
|
|
470
|
+
message: string;
|
|
471
|
+
}>;
|
|
517
472
|
getDevtoolsBridgeStatus(): Promise<EndpointHealthStatus>;
|
|
518
473
|
getCapabilityTruthStatus(context?: Record<string, any>): Promise<CapabilityTruthStatus>;
|
|
519
474
|
getHealthStatus(): Promise<APIHealthStatus>;
|