vigthoria-cli 1.10.51 → 1.11.0
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/dist/commands/background.d.ts +19 -0
- package/dist/commands/background.js +160 -0
- package/dist/commands/chat.js +110 -36
- package/dist/index.js +55 -2
- package/dist/utils/agentRunOutcome.d.ts +36 -0
- package/dist/utils/agentRunOutcome.js +123 -0
- package/dist/utils/api.d.ts +32 -0
- package/dist/utils/api.js +657 -160
- package/package.json +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task-and-quality-validated success evaluation for V3 agent runs.
|
|
3
|
+
* Decouples CLI verdict from raw file-change counts (1.11.0+).
|
|
4
|
+
*/
|
|
5
|
+
export function createLiveOutcome() {
|
|
6
|
+
return {
|
|
7
|
+
executorFailed: false,
|
|
8
|
+
plannerError: null,
|
|
9
|
+
executorError: null,
|
|
10
|
+
tasksTotal: 0,
|
|
11
|
+
tasksSucceeded: 0,
|
|
12
|
+
changedFileCount: 0,
|
|
13
|
+
requiresWorkspaceChanges: false,
|
|
14
|
+
workspaceHasOutput: false,
|
|
15
|
+
failedTaskIds: new Set(),
|
|
16
|
+
analysisToolsUsed: 0,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Process executor_complete / task summary events from the V3 SSE stream. */
|
|
20
|
+
export function handleTaskEvent(summary, liveOutcome) {
|
|
21
|
+
const tid = summary.task_id || summary.id;
|
|
22
|
+
const status = String(summary.status || '').toLowerCase();
|
|
23
|
+
if (status === 'completed' || status === 'success') {
|
|
24
|
+
if (tid) {
|
|
25
|
+
liveOutcome.failedTaskIds.delete(String(tid));
|
|
26
|
+
}
|
|
27
|
+
liveOutcome.tasksSucceeded += 1;
|
|
28
|
+
}
|
|
29
|
+
else if (status === 'failed' || status === 'blocked') {
|
|
30
|
+
if (tid) {
|
|
31
|
+
liveOutcome.failedTaskIds.add(String(tid));
|
|
32
|
+
}
|
|
33
|
+
liveOutcome.executorFailed = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const READ_DISCOVERY_TOOLS = new Set([
|
|
37
|
+
'read_file',
|
|
38
|
+
'grep',
|
|
39
|
+
'list_directory',
|
|
40
|
+
'glob',
|
|
41
|
+
'search_project',
|
|
42
|
+
'list_dir',
|
|
43
|
+
'dir',
|
|
44
|
+
'read',
|
|
45
|
+
]);
|
|
46
|
+
/** Track read/discovery tool usage for analysis-turn accountability. */
|
|
47
|
+
export function noteAnalysisToolUse(toolName, liveOutcome) {
|
|
48
|
+
const normalized = String(toolName || '').trim().toLowerCase();
|
|
49
|
+
if (READ_DISCOVERY_TOOLS.has(normalized)) {
|
|
50
|
+
liveOutcome.analysisToolsUsed += 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Compute the real CLI success verdict.
|
|
55
|
+
* When tasks were planned, ALL must succeed — file changes alone never imply victory.
|
|
56
|
+
*/
|
|
57
|
+
export function evaluateExecutorSuccess(liveOutcome) {
|
|
58
|
+
const hasFatalError = liveOutcome.executorFailed
|
|
59
|
+
|| Boolean(liveOutcome.plannerError)
|
|
60
|
+
|| Boolean(liveOutcome.executorError);
|
|
61
|
+
if (hasFatalError && liveOutcome.tasksTotal === 0) {
|
|
62
|
+
return {
|
|
63
|
+
executorSucceeded: false,
|
|
64
|
+
statusHeadline: '✕ Execution Error',
|
|
65
|
+
uiTheme: 'error',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (liveOutcome.tasksTotal > 0) {
|
|
69
|
+
const allTasksPassed = liveOutcome.tasksSucceeded === liveOutcome.tasksTotal;
|
|
70
|
+
const partialTasksPassed = liveOutcome.tasksSucceeded > 0;
|
|
71
|
+
const failedCount = liveOutcome.failedTaskIds.size;
|
|
72
|
+
if (allTasksPassed && !hasFatalError) {
|
|
73
|
+
return {
|
|
74
|
+
executorSucceeded: true,
|
|
75
|
+
statusHeadline: `✓ Agent run finished (${liveOutcome.tasksSucceeded}/${liveOutcome.tasksTotal} tasks completed)`,
|
|
76
|
+
uiTheme: 'success',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (partialTasksPassed) {
|
|
80
|
+
return {
|
|
81
|
+
executorSucceeded: false,
|
|
82
|
+
statusHeadline: `⚠ Warning: Partial Run (${liveOutcome.tasksSucceeded}/${liveOutcome.tasksTotal} tasks completed${failedCount ? `, ${failedCount} failed` : ''})`,
|
|
83
|
+
uiTheme: 'warning',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
executorSucceeded: false,
|
|
88
|
+
statusHeadline: `✕ Failed: 0/${liveOutcome.tasksTotal} tasks completed${liveOutcome.changedFileCount > 0 ? ' (stub writes or stalls detected)' : ''}`,
|
|
89
|
+
uiTheme: 'error',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// Analysis / verification turns with no planned task graph
|
|
93
|
+
if (!liveOutcome.requiresWorkspaceChanges) {
|
|
94
|
+
const analysisOk = liveOutcome.analysisToolsUsed > 0 || liveOutcome.workspaceHasOutput;
|
|
95
|
+
if (!analysisOk && hasFatalError) {
|
|
96
|
+
return {
|
|
97
|
+
executorSucceeded: false,
|
|
98
|
+
statusHeadline: '✕ Analysis failed — no workspace evidence gathered',
|
|
99
|
+
uiTheme: 'error',
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (!analysisOk) {
|
|
103
|
+
return {
|
|
104
|
+
executorSucceeded: false,
|
|
105
|
+
statusHeadline: '⚠ Warning: No read tools confirmed — answer may be incomplete',
|
|
106
|
+
uiTheme: 'warning',
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
executorSucceeded: true,
|
|
111
|
+
statusHeadline: '✓ Analysis completed',
|
|
112
|
+
uiTheme: 'success',
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const legacySuccess = liveOutcome.workspaceHasOutput && liveOutcome.changedFileCount > 0;
|
|
116
|
+
return {
|
|
117
|
+
executorSucceeded: legacySuccess && !hasFatalError,
|
|
118
|
+
statusHeadline: legacySuccess && !hasFatalError
|
|
119
|
+
? '✓ Agent run finished'
|
|
120
|
+
: '✕ No validated workspace output',
|
|
121
|
+
uiTheme: legacySuccess && !hasFatalError ? 'success' : 'error',
|
|
122
|
+
};
|
|
123
|
+
}
|
package/dist/utils/api.d.ts
CHANGED
|
@@ -224,6 +224,11 @@ export declare class APIClient {
|
|
|
224
224
|
private vigFlowTokens;
|
|
225
225
|
private _httpsAgent;
|
|
226
226
|
private lastChatTransportErrors;
|
|
227
|
+
private clientToolErrors;
|
|
228
|
+
private pendingV3ClientToolTasks;
|
|
229
|
+
/** Tracks files mutated via client_tool_request during an active V3 SSE stream. */
|
|
230
|
+
private activeV3StreamedFiles;
|
|
231
|
+
private activeV3StreamContext;
|
|
227
232
|
constructor(config: Config, logger: Logger);
|
|
228
233
|
/**
|
|
229
234
|
* Destroy keep-alive sockets so the Node.js event loop can drain
|
|
@@ -253,6 +258,7 @@ export declare class APIClient {
|
|
|
253
258
|
getV3AgentBaseUrls(preferLocal?: boolean): string[];
|
|
254
259
|
getV3AgentRunUrl(baseUrl: string): string;
|
|
255
260
|
getV3AgentContinueUrl(baseUrl: string): string;
|
|
261
|
+
getV3AgentBackgroundUrl(baseUrl: string, suffix?: string): string;
|
|
256
262
|
getOperatorBaseUrls(): string[];
|
|
257
263
|
getOperatorStreamUrl(baseUrl: string): string;
|
|
258
264
|
getMcpBaseUrls(): string[];
|
|
@@ -328,6 +334,8 @@ export declare class APIClient {
|
|
|
328
334
|
* 5. Drop readmeExcerpt
|
|
329
335
|
*/
|
|
330
336
|
private compactV3Context;
|
|
337
|
+
/** Remove duplicate functionIndex entries that poison model context after compaction. */
|
|
338
|
+
private dedupeBrainPayload;
|
|
331
339
|
buildMinimalV3AgentContext(context?: Record<string, any>): string;
|
|
332
340
|
private extractEmergencyAppName;
|
|
333
341
|
private materializeEmergencySaaSWorkspace;
|
|
@@ -355,6 +363,10 @@ export declare class APIClient {
|
|
|
355
363
|
extractExpectedWorkspaceFiles(message?: string, context?: Record<string, any>): string[];
|
|
356
364
|
captureV3AgentStreamMutation(event: any, streamedFiles: Record<string, string>, serverRoot?: string | null): void;
|
|
357
365
|
private applyV3AgentStreamEventToWorkspace;
|
|
366
|
+
private resolveV3ClientToolPath;
|
|
367
|
+
private recordV3ClientToolMutation;
|
|
368
|
+
private executeV3ClientToolRequest;
|
|
369
|
+
private handleV3ClientToolRequest;
|
|
358
370
|
private writeV3AgentWorkspaceFile;
|
|
359
371
|
private deleteV3AgentWorkspaceFile;
|
|
360
372
|
recoverAgentWorkspaceFiles(context?: Record<string, any>, streamedFiles?: Record<string, string>, expectedFiles?: string[]): void;
|
|
@@ -374,8 +386,25 @@ export declare class APIClient {
|
|
|
374
386
|
*/
|
|
375
387
|
private synthesizeAnswerFromV3Events;
|
|
376
388
|
private sanitizeV3AgentEventForUser;
|
|
389
|
+
private resolveAgentChangedFiles;
|
|
390
|
+
private finalizeV3AgentWorkflowResponse;
|
|
377
391
|
collectV3AgentStream(response: Response, context?: Record<string, any>): Promise<any>;
|
|
378
392
|
runV3AgentWorkflow(message: string, context?: Record<string, any>): Promise<V3AgentWorkflowResponse>;
|
|
393
|
+
startV3BackgroundJob(message: string, context?: Record<string, any>): Promise<any>;
|
|
394
|
+
listV3BackgroundJobs(limit?: number): Promise<any[]>;
|
|
395
|
+
getV3BackgroundJob(jobId: string): Promise<any>;
|
|
396
|
+
cancelV3BackgroundJob(jobId: string): Promise<any>;
|
|
397
|
+
getV3BackgroundJobFiles(jobId: string): Promise<{
|
|
398
|
+
status: string;
|
|
399
|
+
files: Record<string, string>;
|
|
400
|
+
file_count: number;
|
|
401
|
+
local_workspace_path?: string;
|
|
402
|
+
}>;
|
|
403
|
+
applyV3BackgroundJobFiles(jobId: string, context?: Record<string, any>): Promise<{
|
|
404
|
+
applied: string[];
|
|
405
|
+
skipped: string[];
|
|
406
|
+
status: string;
|
|
407
|
+
}>;
|
|
379
408
|
private formatOperatorResponse;
|
|
380
409
|
runOperatorWorkflow(message: string, context?: Record<string, any>): Promise<OperatorWorkflowResponse>;
|
|
381
410
|
/**
|
|
@@ -515,6 +544,9 @@ export declare class APIClient {
|
|
|
515
544
|
}>;
|
|
516
545
|
mapPreflightEndpointToRoute(endpoint: string): ChatRoutePreference | null;
|
|
517
546
|
getLastChatTransportErrors(): string[];
|
|
547
|
+
getClientToolErrors(): string[];
|
|
548
|
+
clearAgentRunDiagnostics(): void;
|
|
549
|
+
private recordClientToolError;
|
|
518
550
|
submitClientToolResult(contextId: string, callId: string, result: {
|
|
519
551
|
success: boolean;
|
|
520
552
|
output: string;
|