vigthoria-cli 1.8.15 → 1.9.2

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.
@@ -9,16 +9,37 @@ 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;
12
15
  constructor(message: string, category: CLIErrorCategory, opts?: {
13
16
  statusCode?: number;
14
17
  endpoint?: string;
15
18
  cause?: Error;
16
19
  });
17
20
  }
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;
18
36
  /** Classify an axios or fetch error into a structured CLIError. */
19
37
  export declare function classifyError(error: unknown, fallbackCategory?: CLIErrorCategory): CLIError;
20
38
  /** Format a CLIError for user-facing display. */
21
39
  export declare function formatCLIError(err: CLIError): string;
40
+ export declare function sanitizeUserFacingErrorText(input: string): string;
41
+ export declare function isServerRuntime(): boolean;
42
+ export declare function describeUpstreamStatus(status: number): string;
22
43
  export interface ChatMessage {
23
44
  role: 'user' | 'assistant' | 'system';
24
45
  content: string;
@@ -39,8 +60,8 @@ export interface V3AgentWorkflowResponse {
39
60
  contextId?: string | null;
40
61
  backendUrl: string;
41
62
  partial?: boolean;
42
- changedFiles?: Record<string, string>;
43
63
  metadata?: Record<string, unknown>;
64
+ changedFiles?: Record<string, string>;
44
65
  }
45
66
  export interface FrontendPreviewGateResult {
46
67
  required: boolean;
@@ -186,29 +207,43 @@ export interface VigthoriUser {
186
207
  adminAccess: boolean;
187
208
  };
188
209
  }
189
- export declare function sanitizeUserFacingErrorText(input: string): string;
190
- export declare function isServerRuntime(): boolean;
191
- export declare function describeUpstreamStatus(status: number): string;
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
+ };
192
231
  export declare class APIClient {
193
232
  private client;
194
233
  private modelRouterClient;
195
234
  private selfHostedModelRouterClient;
196
- private config;
235
+ config: Config;
236
+ token: string | null;
237
+ expiresAt: number | null;
197
238
  private logger;
198
239
  private ws;
199
240
  private vigFlowTokens;
200
- private _httpsAgent;
201
241
  constructor(config: Config, logger: Logger);
202
- /**
203
- * Destroy keep-alive sockets so the Node.js event loop can drain
204
- * naturally. Call this before exiting commands that run HTTP probes
205
- * (e.g. `status`) to avoid the libuv UV_HANDLE_CLOSING assertion
206
- * on Windows / Node 25+.
207
- */
208
242
  destroy(): void;
209
243
  private getSelfHostedModelsApiUrl;
210
244
  login(email: string, password: string): Promise<boolean>;
211
245
  loginWithToken(token: string): Promise<boolean>;
246
+ private decodeJwtPayload;
212
247
  private extractUserProfile;
213
248
  private refreshToken;
214
249
  getSubscriptionStatus(): Promise<void>;
@@ -232,6 +267,7 @@ export declare class APIClient {
232
267
  getMcpBaseUrls(): string[];
233
268
  getVigFlowBaseUrls(): string[];
234
269
  getTemplateServiceBaseUrls(): string[];
270
+ private allowLocalServiceFallbacks;
235
271
  private isFrontendTask;
236
272
  /**
237
273
  * Returns true when the prompt describes a read-only / analysis task.
@@ -292,7 +328,6 @@ export declare class APIClient {
292
328
  private compactV3Context;
293
329
  buildMinimalV3AgentContext(context?: Record<string, any>): string;
294
330
  private extractEmergencyAppName;
295
- private materializeEmergencySaaSWorkspace;
296
331
  private ensureExecutionContext;
297
332
  bindExecutionContext(context?: Record<string, any>): Promise<Record<string, any>>;
298
333
  private resolveAgentTargetPath;
@@ -363,11 +398,6 @@ export declare class APIClient {
363
398
  * Ensure code has balanced curly braces by appending missing closing braces.
364
399
  */
365
400
  private ensureBalancedBraces;
366
- /**
367
- * Quick JS/TS syntax validation using Node's built-in parser.
368
- * Returns true if the code parses without errors.
369
- */
370
- private validateJsSyntax;
371
401
  /**
372
402
  * Extract the first complete function/class from code.
373
403
  * Used as last-resort when the model keeps over-producing.
@@ -451,10 +481,36 @@ export declare class APIClient {
451
481
  * the fix has fewer closers than the original, appends the missing ones.
452
482
  */
453
483
  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
+ }>;
454
502
  private resolveModelId;
455
503
  private getCoderHealth;
456
504
  private getModelsHealth;
457
505
  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
+ }>;
458
514
  private getV3AgentHealth;
459
515
  private getHyperLoopHealth;
460
516
  private getRepoMemoryHealth;