vigthoria-cli 1.11.27 → 1.11.28
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/chat.d.ts +5 -0
- package/dist/commands/chat.js +131 -25
- package/dist/utils/agentRoute.js +14 -4
- package/dist/utils/api.js +12 -42
- package/dist/utils/requestIntent.d.ts +6 -0
- package/dist/utils/requestIntent.js +53 -2
- package/package.json +1 -1
package/dist/commands/chat.d.ts
CHANGED
|
@@ -171,6 +171,11 @@ export declare class ChatCommand {
|
|
|
171
171
|
private runOperatorDirectAnswer;
|
|
172
172
|
private runSimplePrompt;
|
|
173
173
|
private runAgentTurn;
|
|
174
|
+
private resolveAgentTurnPrompt;
|
|
175
|
+
private shouldPreserveBuildOutcomeForContinue;
|
|
176
|
+
private resolveOriginalPrompt;
|
|
177
|
+
private commitAgentRunOutcome;
|
|
178
|
+
private printResumeContinuationHint;
|
|
174
179
|
private buildLocalLoopLiveOutcome;
|
|
175
180
|
private persistLocalLoopOutcome;
|
|
176
181
|
private runLocalAgentLoop;
|
package/dist/commands/chat.js
CHANGED
|
@@ -17,7 +17,7 @@ import { runAgentSessionMenu, shouldShowAgentSessionMenu } from './agent-session
|
|
|
17
17
|
import { createLiveOutcome, evaluateExecutorSuccess, handleTaskEvent, isSubstantiveAgentAnswer, isToolEvidenceStubAnswer, normalizeAgentAnswerContent, noteAnalysisToolUse, } from '../utils/agentRunOutcome.js';
|
|
18
18
|
import { looksLikeMarkdownReport, renderMarkdownToTerminal, summarizeMarkdownReport, } from '../utils/terminalMarkdown.js';
|
|
19
19
|
import { emitDeckEvent, isDeckModeEnabled } from '../utils/deckEvents.js';
|
|
20
|
-
import { inferAgentTaskType as sharedInferAgentTaskType, isTrivialHtmlPageRequest, resolvePlannerAgentTimeoutMs, resolveWorkflowType, shouldSkipAnalysisRescue, taskRequiresWorkspaceChanges as promptRequiresWorkspaceChanges, buildExecutionHints, } from '../utils/requestIntent.js';
|
|
20
|
+
import { inferAgentTaskType as sharedInferAgentTaskType, isTrivialHtmlPageRequest, resolvePlannerAgentTimeoutMs, resolveWorkflowType, shouldSkipAnalysisRescue, taskRequiresWorkspaceChanges as promptRequiresWorkspaceChanges, buildExecutionHints, isAgentContinuePrompt, isAgentRetryPrompt, isBuiltContinuePrompt, isBuiltRetryPrompt, } from '../utils/requestIntent.js';
|
|
21
21
|
import { resolveAgentRoute } from '../utils/agentRoute.js';
|
|
22
22
|
import { runTemplateInstantPath } from '../utils/templateInstantPath.js';
|
|
23
23
|
const DEFAULT_V3_AGENT_TIMEOUT_MS = (() => {
|
|
@@ -1405,6 +1405,9 @@ export class ChatCommand {
|
|
|
1405
1405
|
this.directToolContinuationCount = 0;
|
|
1406
1406
|
this.tools = new AgenticTools(this.logger, this.currentProjectPath, async (action) => this.requestPermission(action), this.autoApprove);
|
|
1407
1407
|
this.initializeSession(options.resume === true || options.retry === true || options.continue === true);
|
|
1408
|
+
if (options.resume && this.lastAgentRunOutcome && !this.jsonOutput && !options.prompt) {
|
|
1409
|
+
this.printResumeContinuationHint();
|
|
1410
|
+
}
|
|
1408
1411
|
// ── Commando Bridge: connect if --bridge was specified ──────────
|
|
1409
1412
|
if (options.bridge) {
|
|
1410
1413
|
const bridgeClient = new BridgeClient({
|
|
@@ -1677,7 +1680,11 @@ export class ChatCommand {
|
|
|
1677
1680
|
this.operatorMode = this.currentSession.operatorMode || this.operatorMode;
|
|
1678
1681
|
this.currentModel = this.currentSession.model || this.currentModel;
|
|
1679
1682
|
if (this.currentSession.lastAgentRunOutcome) {
|
|
1680
|
-
|
|
1683
|
+
const saved = this.currentSession.lastAgentRunOutcome;
|
|
1684
|
+
this.lastAgentRunOutcome = {
|
|
1685
|
+
...saved,
|
|
1686
|
+
originalPrompt: saved.originalPrompt ?? null,
|
|
1687
|
+
};
|
|
1681
1688
|
}
|
|
1682
1689
|
return;
|
|
1683
1690
|
}
|
|
@@ -2165,7 +2172,8 @@ export class ChatCommand {
|
|
|
2165
2172
|
if (!this.tools) {
|
|
2166
2173
|
throw new Error('Agent tools are not initialized.');
|
|
2167
2174
|
}
|
|
2168
|
-
|
|
2175
|
+
const resolvedPrompt = this.resolveAgentTurnPrompt(prompt);
|
|
2176
|
+
this.lastAgentRoute = await resolveAgentRoute(this.api, resolvedPrompt);
|
|
2169
2177
|
if (!this.jsonOutput) {
|
|
2170
2178
|
const r = this.lastAgentRoute;
|
|
2171
2179
|
const routerNote = r.routerLatencyMs
|
|
@@ -2173,13 +2181,13 @@ export class ChatCommand {
|
|
|
2173
2181
|
: '';
|
|
2174
2182
|
this.logger.debug(`Agent route: ${r.path} / ${r.taskKind} [${r.source}]${routerNote} — ${r.reason}`);
|
|
2175
2183
|
}
|
|
2176
|
-
const requiresV3Workflow = this.shouldRequireV3AgentWorkflow(
|
|
2177
|
-
const handledByTemplateInstant = await this.tryTemplateInstantPath(
|
|
2184
|
+
const requiresV3Workflow = this.shouldRequireV3AgentWorkflow(resolvedPrompt);
|
|
2185
|
+
const handledByTemplateInstant = await this.tryTemplateInstantPath(resolvedPrompt);
|
|
2178
2186
|
if (handledByTemplateInstant) {
|
|
2179
2187
|
this.saveSession();
|
|
2180
2188
|
return;
|
|
2181
2189
|
}
|
|
2182
|
-
const handledByDirectFileFlow = await this.tryDirectSingleFileFlow(
|
|
2190
|
+
const handledByDirectFileFlow = await this.tryDirectSingleFileFlow(resolvedPrompt);
|
|
2183
2191
|
if (handledByDirectFileFlow) {
|
|
2184
2192
|
this.saveSession();
|
|
2185
2193
|
return;
|
|
@@ -2187,12 +2195,12 @@ export class ChatCommand {
|
|
|
2187
2195
|
// Prime the message context with the target file when the direct-file flow was
|
|
2188
2196
|
// bypassed (e.g. HTML files routed to V3) so the local agent loop has file
|
|
2189
2197
|
// awareness and the ⚙ Executing: read_file banner is always emitted.
|
|
2190
|
-
await this.primeBypassedTargetFileContext(
|
|
2191
|
-
if (this.shouldPreferLocalAgentLoop(
|
|
2192
|
-
await this.runLocalAgentLoop(
|
|
2198
|
+
await this.primeBypassedTargetFileContext(resolvedPrompt);
|
|
2199
|
+
if (this.shouldPreferLocalAgentLoop(resolvedPrompt)) {
|
|
2200
|
+
await this.runLocalAgentLoop(resolvedPrompt);
|
|
2193
2201
|
return;
|
|
2194
2202
|
}
|
|
2195
|
-
const handledByV3Workflow = await this.tryV3AgentWorkflow(
|
|
2203
|
+
const handledByV3Workflow = await this.tryV3AgentWorkflow(resolvedPrompt);
|
|
2196
2204
|
if (handledByV3Workflow) {
|
|
2197
2205
|
this.saveSession();
|
|
2198
2206
|
return;
|
|
@@ -2204,7 +2212,95 @@ export class ChatCommand {
|
|
|
2204
2212
|
this.saveSession();
|
|
2205
2213
|
return;
|
|
2206
2214
|
}
|
|
2207
|
-
await this.runLocalAgentLoop(
|
|
2215
|
+
await this.runLocalAgentLoop(resolvedPrompt);
|
|
2216
|
+
}
|
|
2217
|
+
resolveAgentTurnPrompt(prompt) {
|
|
2218
|
+
if (isBuiltContinuePrompt(prompt) || isBuiltRetryPrompt(prompt)) {
|
|
2219
|
+
return prompt;
|
|
2220
|
+
}
|
|
2221
|
+
if (isAgentContinuePrompt(prompt)) {
|
|
2222
|
+
const followUp = this.buildContinuePrompt();
|
|
2223
|
+
if (followUp) {
|
|
2224
|
+
if (!this.jsonOutput) {
|
|
2225
|
+
console.log(chalk.cyan('↪ Treating your message as /continue — resuming the previous agent run.'));
|
|
2226
|
+
}
|
|
2227
|
+
return followUp;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
if (isAgentRetryPrompt(prompt)) {
|
|
2231
|
+
const followUp = this.buildRetryPrompt();
|
|
2232
|
+
if (followUp) {
|
|
2233
|
+
if (!this.jsonOutput) {
|
|
2234
|
+
console.log(chalk.cyan('↪ Treating your message as /retry — re-running failed tasks from the previous run.'));
|
|
2235
|
+
}
|
|
2236
|
+
return followUp;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
return prompt;
|
|
2240
|
+
}
|
|
2241
|
+
shouldPreserveBuildOutcomeForContinue(runPrompt, prior) {
|
|
2242
|
+
if (this.taskRequiresWorkspaceChanges(runPrompt)) {
|
|
2243
|
+
return false;
|
|
2244
|
+
}
|
|
2245
|
+
if (isBuiltContinuePrompt(runPrompt) || isBuiltRetryPrompt(runPrompt)) {
|
|
2246
|
+
return false;
|
|
2247
|
+
}
|
|
2248
|
+
const chainPrompt = prior.originalPrompt || prior.prompt;
|
|
2249
|
+
if (!this.taskRequiresWorkspaceChanges(chainPrompt)) {
|
|
2250
|
+
return false;
|
|
2251
|
+
}
|
|
2252
|
+
return isAgentContinuePrompt(runPrompt);
|
|
2253
|
+
}
|
|
2254
|
+
resolveOriginalPrompt(runPrompt) {
|
|
2255
|
+
const prior = this.lastAgentRunOutcome;
|
|
2256
|
+
if (prior?.originalPrompt) {
|
|
2257
|
+
return prior.originalPrompt;
|
|
2258
|
+
}
|
|
2259
|
+
if (this.taskRequiresWorkspaceChanges(runPrompt) && !isBuiltContinuePrompt(runPrompt) && !isBuiltRetryPrompt(runPrompt)) {
|
|
2260
|
+
return runPrompt;
|
|
2261
|
+
}
|
|
2262
|
+
if (prior && this.taskRequiresWorkspaceChanges(prior.originalPrompt || prior.prompt)) {
|
|
2263
|
+
return prior.originalPrompt || prior.prompt;
|
|
2264
|
+
}
|
|
2265
|
+
return null;
|
|
2266
|
+
}
|
|
2267
|
+
commitAgentRunOutcome(outcome, runPrompt) {
|
|
2268
|
+
const prior = this.lastAgentRunOutcome;
|
|
2269
|
+
if (prior && this.shouldPreserveBuildOutcomeForContinue(runPrompt, prior)) {
|
|
2270
|
+
if (!this.jsonOutput) {
|
|
2271
|
+
console.log(chalk.yellow('↪ Keeping the previous build run state — use /continue to resume implementation.'));
|
|
2272
|
+
}
|
|
2273
|
+
return;
|
|
2274
|
+
}
|
|
2275
|
+
outcome.originalPrompt = this.resolveOriginalPrompt(runPrompt);
|
|
2276
|
+
this.lastAgentRunOutcome = outcome;
|
|
2277
|
+
}
|
|
2278
|
+
printResumeContinuationHint() {
|
|
2279
|
+
const outcome = this.lastAgentRunOutcome;
|
|
2280
|
+
if (!outcome) {
|
|
2281
|
+
return;
|
|
2282
|
+
}
|
|
2283
|
+
const sourcePrompt = outcome.originalPrompt || outcome.prompt;
|
|
2284
|
+
const isBuild = this.taskRequiresWorkspaceChanges(sourcePrompt);
|
|
2285
|
+
const openWork = outcome.failedTaskIds.length > 0
|
|
2286
|
+
|| outcome.unfinishedTaskIds.length > 0
|
|
2287
|
+
|| (outcome.tasksTotal > 0 && outcome.tasksSucceeded < outcome.tasksTotal);
|
|
2288
|
+
if (!isBuild && !openWork) {
|
|
2289
|
+
return;
|
|
2290
|
+
}
|
|
2291
|
+
console.log('');
|
|
2292
|
+
console.log(chalk.cyan('Prior agent run restored for this project.'));
|
|
2293
|
+
if (openWork) {
|
|
2294
|
+
const taskIds = [...new Set([...outcome.failedTaskIds, ...outcome.unfinishedTaskIds])].slice(0, 8);
|
|
2295
|
+
if (taskIds.length > 0) {
|
|
2296
|
+
console.log(chalk.gray(` Unfinished tasks: ${taskIds.join(', ')}`));
|
|
2297
|
+
}
|
|
2298
|
+
else {
|
|
2299
|
+
console.log(chalk.gray(` Progress: ${outcome.tasksSucceeded}/${outcome.tasksTotal} tasks completed`));
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
console.log(chalk.gray(' Type ') + chalk.cyan('/continue') + chalk.gray(' to resume implementation, or ') + chalk.cyan('/retry') + chalk.gray(' for failed tasks only.'));
|
|
2303
|
+
console.log('');
|
|
2208
2304
|
}
|
|
2209
2305
|
buildLocalLoopLiveOutcome(prompt) {
|
|
2210
2306
|
const liveOutcome = createLiveOutcome();
|
|
@@ -2220,8 +2316,9 @@ export class ChatCommand {
|
|
|
2220
2316
|
return liveOutcome;
|
|
2221
2317
|
}
|
|
2222
2318
|
persistLocalLoopOutcome(prompt, evaluation, liveOutcome) {
|
|
2223
|
-
this.
|
|
2319
|
+
this.commitAgentRunOutcome({
|
|
2224
2320
|
prompt,
|
|
2321
|
+
originalPrompt: null,
|
|
2225
2322
|
taskId: null,
|
|
2226
2323
|
contextId: null,
|
|
2227
2324
|
tasksSucceeded: liveOutcome.tasksSucceeded,
|
|
@@ -2242,7 +2339,7 @@ export class ChatCommand {
|
|
|
2242
2339
|
workspacePath: this.currentProjectPath || null,
|
|
2243
2340
|
workspaceSyncIssue: null,
|
|
2244
2341
|
finishedAt: Date.now(),
|
|
2245
|
-
};
|
|
2342
|
+
}, prompt);
|
|
2246
2343
|
}
|
|
2247
2344
|
async runLocalAgentLoop(prompt) {
|
|
2248
2345
|
if (!this.tools) {
|
|
@@ -2580,8 +2677,9 @@ export class ChatCommand {
|
|
|
2580
2677
|
liveOutcome.tasksSucceeded = 1;
|
|
2581
2678
|
liveOutcome.answerContent = summary;
|
|
2582
2679
|
const evaluation = evaluateExecutorSuccess(liveOutcome);
|
|
2583
|
-
this.
|
|
2680
|
+
this.commitAgentRunOutcome({
|
|
2584
2681
|
prompt,
|
|
2682
|
+
originalPrompt: null,
|
|
2585
2683
|
taskId: null,
|
|
2586
2684
|
contextId: null,
|
|
2587
2685
|
tasksSucceeded: 1,
|
|
@@ -2602,7 +2700,7 @@ export class ChatCommand {
|
|
|
2602
2700
|
workspacePath: workspacePath || null,
|
|
2603
2701
|
workspaceSyncIssue: null,
|
|
2604
2702
|
finishedAt: Date.now(),
|
|
2605
|
-
};
|
|
2703
|
+
}, prompt);
|
|
2606
2704
|
if (!this.jsonOutput) {
|
|
2607
2705
|
console.log(chalk.green(`✓ ${summary}`));
|
|
2608
2706
|
console.log(chalk.gray(' Run: vigthoria preview'));
|
|
@@ -3198,8 +3296,9 @@ export class ChatCommand {
|
|
|
3198
3296
|
if (!executorSucceeded) {
|
|
3199
3297
|
process.exitCode = 1;
|
|
3200
3298
|
}
|
|
3201
|
-
this.
|
|
3299
|
+
this.commitAgentRunOutcome({
|
|
3202
3300
|
prompt,
|
|
3301
|
+
originalPrompt: null,
|
|
3203
3302
|
taskId: response.taskId || null,
|
|
3204
3303
|
contextId: response.contextId || null,
|
|
3205
3304
|
tasksSucceeded: liveOutcome.tasksSucceeded,
|
|
@@ -3222,9 +3321,11 @@ export class ChatCommand {
|
|
|
3222
3321
|
? 'Local workspace has files but the agent did not confirm tracked changes.'
|
|
3223
3322
|
: null,
|
|
3224
3323
|
finishedAt: Date.now(),
|
|
3225
|
-
};
|
|
3324
|
+
}, prompt);
|
|
3226
3325
|
if (!this.jsonOutput && !this.directPromptMode) {
|
|
3227
|
-
|
|
3326
|
+
if (this.lastAgentRunOutcome) {
|
|
3327
|
+
this.printAgentRunSummary(this.lastAgentRunOutcome, runEvaluation, changedFileCount);
|
|
3328
|
+
}
|
|
3228
3329
|
}
|
|
3229
3330
|
if (this.jsonOutput) {
|
|
3230
3331
|
if (!executorSucceeded) {
|
|
@@ -3296,8 +3397,9 @@ export class ChatCommand {
|
|
|
3296
3397
|
taskDisplay.finalize();
|
|
3297
3398
|
}
|
|
3298
3399
|
catch (_) { /* render is best-effort */ }
|
|
3299
|
-
this.
|
|
3400
|
+
this.commitAgentRunOutcome({
|
|
3300
3401
|
prompt,
|
|
3402
|
+
originalPrompt: null,
|
|
3301
3403
|
taskId: null,
|
|
3302
3404
|
contextId: null,
|
|
3303
3405
|
tasksSucceeded: liveOutcome.tasksSucceeded,
|
|
@@ -3318,7 +3420,7 @@ export class ChatCommand {
|
|
|
3318
3420
|
workspacePath: workspacePath || null,
|
|
3319
3421
|
workspaceSyncIssue: null,
|
|
3320
3422
|
finishedAt: Date.now(),
|
|
3321
|
-
};
|
|
3423
|
+
}, prompt);
|
|
3322
3424
|
if (!this.jsonOutput) {
|
|
3323
3425
|
process.exitCode = 1;
|
|
3324
3426
|
}
|
|
@@ -3346,7 +3448,9 @@ export class ChatCommand {
|
|
|
3346
3448
|
requiresWorkspaceChanges: this.taskRequiresWorkspaceChanges(prompt),
|
|
3347
3449
|
workspaceHasOutput: this.api.hasAgentWorkspaceOutput(workspaceContext),
|
|
3348
3450
|
});
|
|
3349
|
-
|
|
3451
|
+
if (this.lastAgentRunOutcome) {
|
|
3452
|
+
this.printAgentRunSummary(this.lastAgentRunOutcome, failedEval, 0);
|
|
3453
|
+
}
|
|
3350
3454
|
}
|
|
3351
3455
|
return true;
|
|
3352
3456
|
}
|
|
@@ -3797,6 +3901,7 @@ export class ChatCommand {
|
|
|
3797
3901
|
const o = this.lastAgentRunOutcome;
|
|
3798
3902
|
if (!o || !o.prompt)
|
|
3799
3903
|
return null;
|
|
3904
|
+
const sourcePrompt = o.originalPrompt || o.prompt;
|
|
3800
3905
|
const runtime = this.getRuntimeEnvironmentContext();
|
|
3801
3906
|
const remaining = [...new Set([...o.failedTaskIds, ...o.unfinishedTaskIds])];
|
|
3802
3907
|
const taskList = remaining.length > 0 ? remaining.join(', ') : '';
|
|
@@ -3811,9 +3916,9 @@ export class ChatCommand {
|
|
|
3811
3916
|
? '\nUse local workspace tools and local filesystem paths first; do not assume server-side workspace access.'
|
|
3812
3917
|
: '';
|
|
3813
3918
|
if (taskList) {
|
|
3814
|
-
return `Resume the previous agent run. Re-execute only these tasks and make them pass: ${taskList}.${blockerLine}${missingLine}${envLine}${localPreferenceLine}\nOriginal request was: ${
|
|
3919
|
+
return `Resume the previous agent run. Re-execute only these tasks and make them pass: ${taskList}.${blockerLine}${missingLine}${envLine}${localPreferenceLine}\nOriginal request was: ${sourcePrompt}`;
|
|
3815
3920
|
}
|
|
3816
|
-
return `Retry the previous request and make sure it finishes successfully.${blockerLine}${missingLine}${envLine}${localPreferenceLine}\nOriginal request was: ${
|
|
3921
|
+
return `Retry the previous request and make sure it finishes successfully.${blockerLine}${missingLine}${envLine}${localPreferenceLine}\nOriginal request was: ${sourcePrompt}`;
|
|
3817
3922
|
}
|
|
3818
3923
|
computeRetryPromptSignature() {
|
|
3819
3924
|
const o = this.lastAgentRunOutcome;
|
|
@@ -3831,9 +3936,10 @@ export class ChatCommand {
|
|
|
3831
3936
|
const o = this.lastAgentRunOutcome;
|
|
3832
3937
|
if (!o || !o.prompt)
|
|
3833
3938
|
return null;
|
|
3939
|
+
const sourcePrompt = o.originalPrompt || o.prompt;
|
|
3834
3940
|
const remaining = [...new Set([...o.failedTaskIds, ...o.unfinishedTaskIds])];
|
|
3835
3941
|
const taskList = remaining.length > 0 ? `\nRemaining tasks to finish: ${remaining.join(', ')}.` : '';
|
|
3836
|
-
const mustChangeFiles = this.taskRequiresWorkspaceChanges(
|
|
3942
|
+
const mustChangeFiles = this.taskRequiresWorkspaceChanges(sourcePrompt)
|
|
3837
3943
|
? '\nThis was a build/edit request. Do not stop after analysis or tool JSON; make real workspace file changes and verify them before finishing.'
|
|
3838
3944
|
: '';
|
|
3839
3945
|
const blockerLine = o.qualityBlockers.length > 0
|
|
@@ -3842,7 +3948,7 @@ export class ChatCommand {
|
|
|
3842
3948
|
const missingLine = o.qualityMissing.length > 0
|
|
3843
3949
|
? `\nMissing pieces: ${o.qualityMissing.slice(0, 6).join(', ')}.`
|
|
3844
3950
|
: '';
|
|
3845
|
-
return `Continue the previous agent run from the current workspace state without re-doing already-completed work.${taskList}${mustChangeFiles}${blockerLine}${missingLine}\nOriginal request was: ${
|
|
3951
|
+
return `Continue the previous agent run from the current workspace state without re-doing already-completed work.${taskList}${mustChangeFiles}${blockerLine}${missingLine}\nOriginal request was: ${sourcePrompt}`;
|
|
3846
3952
|
}
|
|
3847
3953
|
/**
|
|
3848
3954
|
* Re-print the last agent run summary, or guide the user when there isn't one.
|
package/dist/utils/agentRoute.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Unified agent routing: regex (instant) → optional Balanced 4B → V3 execution hints.
|
|
3
3
|
*/
|
|
4
|
-
import { inferAgentTaskType, isTrivialHtmlPageRequest,
|
|
4
|
+
import { inferAgentTaskType, isTrivialHtmlPageRequest, isAgentContinuePrompt, isAgentRetryPrompt, hasGameIntent, hasWebPageIntent, taskRequiresWorkspaceChanges, stripExecutionShaping, } from './requestIntent.js';
|
|
5
5
|
import { isFastInferenceRouterAvailable, routeWithBalanced4b, shouldUseBalancedRouter, } from './fastAgentRouter.js';
|
|
6
6
|
function normalizeTaskKind(value, fallback) {
|
|
7
7
|
const kind = String(value || fallback).trim().toLowerCase();
|
|
@@ -74,13 +74,23 @@ function mergeLlmRoute(regexTask, prompt, parsed) {
|
|
|
74
74
|
}
|
|
75
75
|
export async function resolveAgentRoute(api, prompt) {
|
|
76
76
|
const stripped = stripExecutionShaping(prompt);
|
|
77
|
-
if (
|
|
77
|
+
if (isAgentContinuePrompt(stripped)) {
|
|
78
78
|
const regexTask = inferAgentTaskType(stripped);
|
|
79
79
|
return {
|
|
80
80
|
path: 'v3-agent',
|
|
81
81
|
taskKind: regexTask === 'analysis' ? 'implementation' : regexTask,
|
|
82
|
-
confidence: 0.
|
|
83
|
-
reason: 'continue
|
|
82
|
+
confidence: 0.92,
|
|
83
|
+
reason: 'continue follow-up (regex)',
|
|
84
|
+
source: 'regex',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (isAgentRetryPrompt(stripped)) {
|
|
88
|
+
const regexTask = inferAgentTaskType(stripped);
|
|
89
|
+
return {
|
|
90
|
+
path: 'v3-agent',
|
|
91
|
+
taskKind: regexTask === 'analysis' ? 'implementation' : regexTask,
|
|
92
|
+
confidence: 0.92,
|
|
93
|
+
reason: 'retry follow-up (regex)',
|
|
84
94
|
source: 'regex',
|
|
85
95
|
};
|
|
86
96
|
}
|
package/dist/utils/api.js
CHANGED
|
@@ -2646,48 +2646,18 @@ menu {
|
|
|
2646
2646
|
}
|
|
2647
2647
|
return;
|
|
2648
2648
|
}
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
if (event.type !== 'tool_call') {
|
|
2662
|
-
if (event.type === 'tool_result' && event.success) {
|
|
2663
|
-
const name = String(event.name || event.tool || '').trim();
|
|
2664
|
-
const args = event.arguments || {};
|
|
2665
|
-
const targetPath = typeof event.target === 'string'
|
|
2666
|
-
? event.target
|
|
2667
|
-
: (typeof args.path === 'string' ? args.path : '');
|
|
2668
|
-
if ((name === 'write_file' || name === 'edit_file') && targetPath) {
|
|
2669
|
-
const filePath = this.normalizeAgentWorkspaceRelativePath(targetPath, serverRoot || undefined);
|
|
2670
|
-
if (filePath && typeof args.content === 'string') {
|
|
2671
|
-
streamedFiles[filePath] = args.content;
|
|
2672
|
-
}
|
|
2673
|
-
}
|
|
2674
|
-
}
|
|
2675
|
-
return;
|
|
2676
|
-
}
|
|
2677
|
-
const args = event.arguments || {};
|
|
2678
|
-
if ((event.name === 'write_file' || event.name === 'edit_file') && typeof args.path === 'string') {
|
|
2679
|
-
const filePath = this.normalizeAgentWorkspaceRelativePath(args.path, serverRoot || undefined);
|
|
2680
|
-
if (!filePath) {
|
|
2681
|
-
return;
|
|
2682
|
-
}
|
|
2683
|
-
if (event.name === 'write_file' && typeof args.content === 'string') {
|
|
2684
|
-
streamedFiles[filePath] = args.content;
|
|
2685
|
-
return;
|
|
2686
|
-
}
|
|
2687
|
-
if (event.name === 'edit_file' && typeof args.old_string === 'string' && typeof args.new_string === 'string') {
|
|
2688
|
-
const existing = streamedFiles[filePath];
|
|
2689
|
-
if (typeof existing === 'string' && existing.includes(args.old_string)) {
|
|
2690
|
-
streamedFiles[filePath] = existing.replace(args.old_string, args.new_string);
|
|
2649
|
+
// Only count confirmed mutations — not workspace snapshots (hydrated baseline)
|
|
2650
|
+
// or tool_call previews that may still fail client-side / read-only guards.
|
|
2651
|
+
if (event.type === 'tool_result' && event.success) {
|
|
2652
|
+
const name = String(event.name || event.tool || '').trim();
|
|
2653
|
+
const args = event.arguments || {};
|
|
2654
|
+
const targetPath = typeof event.target === 'string'
|
|
2655
|
+
? event.target
|
|
2656
|
+
: (typeof args.path === 'string' ? args.path : '');
|
|
2657
|
+
if ((name === 'write_file' || name === 'edit_file') && targetPath) {
|
|
2658
|
+
const filePath = this.normalizeAgentWorkspaceRelativePath(targetPath, serverRoot || undefined);
|
|
2659
|
+
if (filePath && typeof args.content === 'string') {
|
|
2660
|
+
streamedFiles[filePath] = args.content;
|
|
2691
2661
|
}
|
|
2692
2662
|
}
|
|
2693
2663
|
}
|
|
@@ -7,6 +7,12 @@ export declare function stripExecutionShaping(prompt: string): string;
|
|
|
7
7
|
export declare function hasBuildVerb(prompt: string): boolean;
|
|
8
8
|
export declare function hasArtifactNoun(prompt: string): boolean;
|
|
9
9
|
export declare function hasGameIntent(prompt: string): boolean;
|
|
10
|
+
/** True when the CLI already expanded a /continue-style follow-up prompt. */
|
|
11
|
+
export declare function isBuiltContinuePrompt(prompt: string): boolean;
|
|
12
|
+
/** True when the CLI already expanded a /retry-style follow-up prompt. */
|
|
13
|
+
export declare function isBuiltRetryPrompt(prompt: string): boolean;
|
|
14
|
+
export declare function isAgentContinuePrompt(prompt: string): boolean;
|
|
15
|
+
export declare function isAgentRetryPrompt(prompt: string): boolean;
|
|
10
16
|
export declare function isContinueOrRetryPrompt(prompt: string): boolean;
|
|
11
17
|
export declare function hasWebPageIntent(prompt: string): boolean;
|
|
12
18
|
export declare function isTrivialHtmlPageRequest(prompt: string): boolean;
|
|
@@ -41,9 +41,57 @@ export function hasGameIntent(prompt) {
|
|
|
41
41
|
}
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
|
+
const CONTINUE_VERB = /\b(?:continue|contiune|continu|proceed|resume|keep\s+going|go\s+on|carry\s+on|pick\s+up\s+where)\b/i;
|
|
45
|
+
const CONTINUE_OBJECT = /\b(?:task|tasks|work|build|building|implementation|project|run|plan|planning|remaining|unfinished|missing|components?|next\s+steps?|previous|last|where\s+we\s+left|hyperloop|report)\b/i;
|
|
46
|
+
/** True when the CLI already expanded a /continue-style follow-up prompt. */
|
|
47
|
+
export function isBuiltContinuePrompt(prompt) {
|
|
48
|
+
return /^Continue the previous agent run/i.test(stripExecutionShaping(prompt));
|
|
49
|
+
}
|
|
50
|
+
/** True when the CLI already expanded a /retry-style follow-up prompt. */
|
|
51
|
+
export function isBuiltRetryPrompt(prompt) {
|
|
52
|
+
const text = stripExecutionShaping(prompt);
|
|
53
|
+
return /^(?:Resume the previous agent run|Retry the previous request)/i.test(text);
|
|
54
|
+
}
|
|
55
|
+
export function isAgentContinuePrompt(prompt) {
|
|
56
|
+
const text = stripExecutionShaping(prompt).trim();
|
|
57
|
+
if (!text) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (isBuiltContinuePrompt(text) || isBuiltRetryPrompt(text)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (/^\/(?:continue|contiune|contiunue)$/i.test(text)) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
if (/\bcontinue\s+(?:the\s+)?(?:previous|last|current)\s+(?:agent\s+)?run\b/i.test(text)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
if (/\bresume\s+(?:the\s+)?(?:failed|unfinished)\b/i.test(text)) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
if (/\bplanner\s+produced\s+\d+\s+execution\s+tasks\b/i.test(text)) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
if (CONTINUE_VERB.test(text) && CONTINUE_OBJECT.test(text)) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
if (/^(?:please\s+)?(?:continue|contiune|proceed)(?:[!?.]|$)/i.test(text)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
export function isAgentRetryPrompt(prompt) {
|
|
84
|
+
const text = stripExecutionShaping(prompt).trim();
|
|
85
|
+
if (!text || isBuiltContinuePrompt(text) || isBuiltRetryPrompt(text)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if (/^\/retry$/i.test(text)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return /\b(?:retry|re-?try)\s+(?:the\s+)?(?:failed|last|previous|unfinished)\b/i.test(text);
|
|
92
|
+
}
|
|
44
93
|
export function isContinueOrRetryPrompt(prompt) {
|
|
45
|
-
|
|
46
|
-
return /\b(continue\s+(?:the\s+)?(?:previous|last|current)\s+(?:agent\s+)?run|\/retry|\/continue|resume\s+(?:the\s+)?(?:failed|unfinished)|planner\s+produced\s+\d+\s+execution\s+tasks)\b/i.test(text);
|
|
94
|
+
return isAgentContinuePrompt(prompt) || isAgentRetryPrompt(prompt);
|
|
47
95
|
}
|
|
48
96
|
export function hasWebPageIntent(prompt) {
|
|
49
97
|
const text = stripExecutionShaping(prompt);
|
|
@@ -165,6 +213,9 @@ export function resolveWorkflowType(agentTaskType, prompt) {
|
|
|
165
213
|
if (hasAnalyzeAndBuildIntent(prompt)) {
|
|
166
214
|
return 'full';
|
|
167
215
|
}
|
|
216
|
+
if (isBuiltContinuePrompt(prompt) || isBuiltRetryPrompt(prompt)) {
|
|
217
|
+
return taskRequiresWorkspaceChanges(prompt) ? 'full' : 'analysis_only';
|
|
218
|
+
}
|
|
168
219
|
if (!taskRequiresWorkspaceChanges(prompt)) {
|
|
169
220
|
return 'analysis_only';
|
|
170
221
|
}
|