@causyne/agent 1.20.65 → 1.20.69
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/package.json +1 -1
- package/src/agentLoop.js +49 -26
- package/src/agentLoop.ts +49 -26
- package/src/browser/causyneBrowser.js +1 -1
- package/src/browser/causyneBrowser.ts +1 -1
- package/src/cliMode.js +68 -11
- package/src/commands.js +46 -19
- package/src/contextManager.js +1 -1
- package/src/continuum/ui/continuumPicker.js +1 -1
- package/src/continuum/ui/continuumPicker.ts +1 -1
- package/src/embodimentSession.js +1 -1
- package/src/planCache.js +1 -1
- package/src/planCache.ts +1 -1
- package/src/promptMentions.js +7 -7
- package/src/promptMentions.ts +7 -7
- package/src/providers/antigravity.js +52 -12
- package/src/providers/antigravity.ts +47 -16
- package/src/providers/dashscope-byok.js +1 -1
- package/src/providers/qwen-byok.js +1 -1
- package/src/skillsManager.d.ts +4 -1
- package/src/tokenTracker.js +1 -1
- package/src/tokenTracker.ts +1 -1
- package/src/tool-scripts/ax_snapshot.ps1 +10 -10
- package/src/tools/fsList.js +1 -1
- package/src/tools/memoryWrite.js +1 -1
- package/src/tools/memoryWrite.ts +1 -1
- package/src/tui/chatRenderer.js +3 -2
- package/src/tui/codeStreamRenderer.js +8 -5
- package/src/tui/codeStreamRenderer.ts +10 -5
- package/src/tui/consoleGuard.js +15 -0
- package/src/tui/consoleGuard.ts +15 -0
- package/src/tui/lineEditor.js +14 -21
- package/src/tui/modelPicker.js +1 -1
- package/src/tui/modelPicker.ts +1 -1
- package/src/tui/prompt.js +41 -13
- package/src/tui/sessionPicker.js +1 -1
- package/src/tui/sessionPicker.ts +1 -1
- package/src/tui/sessionSidebar.js +13 -0
- package/src/tui/sessionSidebar.ts +15 -0
- package/src/tui/skillAuthoring.js +147 -0
- package/src/tui/skillAuthoring.ts +172 -0
- package/src/tui/stage.js +4 -2
- package/src/tui/stageSurface.js +43 -11
- package/src/tui/text.js +25 -2
- package/src/tui/text.ts +24 -2
- package/src/tui/theme.js +3 -0
- package/src/vfeTracker.js +1 -1
- package/src/vfeTracker.ts +1 -1
package/package.json
CHANGED
package/src/agentLoop.js
CHANGED
|
@@ -54,6 +54,7 @@ import path from 'path';
|
|
|
54
54
|
import { analyzeFiles, formatFindings, isScannableFile } from './slopDetector.js';
|
|
55
55
|
import { suggestMovements, formatMovementBrief } from './designPalettes.js';
|
|
56
56
|
import { createProvider } from './providers/factory.js';
|
|
57
|
+
import { isNativeMutation } from './providers/antigravity.js';
|
|
57
58
|
import { resolveMentionedContext } from './promptMentions.js';
|
|
58
59
|
import { isLaunchOnlyPrompt, launchScopeError } from './launchIntent.js';
|
|
59
60
|
import { StreamingCodePreview, NativeCodeObserver, codeProgressFromAction } from './tui/codeProgress.js';
|
|
@@ -867,7 +868,7 @@ export class AgentLoop {
|
|
|
867
868
|
try {
|
|
868
869
|
const matches = await cortexDb.search(this.currentTaskPrompt, 2, { workspace: this.workspaceRoot });
|
|
869
870
|
if (matches.length > 0 && matches[0]) {
|
|
870
|
-
lessonsLearned = `\n\n
|
|
871
|
+
lessonsLearned = `\n\n◆ DIGITAL BRAIN (LESSONS LEARNED FROM PAST MISTAKES):\n` + matches.map((m) => `- ${m.text}`).join('\n');
|
|
871
872
|
this._lessonSimilarity = matches[0].similarity || 0;
|
|
872
873
|
this.debugLog(`cortex search hit: ${(this._lessonSimilarity * 100).toFixed(0)}% similarity`);
|
|
873
874
|
}
|
|
@@ -891,7 +892,7 @@ export class AgentLoop {
|
|
|
891
892
|
try {
|
|
892
893
|
const recentPatterns = await cortexDb.getRecentCreativePatterns(5);
|
|
893
894
|
if (recentPatterns.length > 0) {
|
|
894
|
-
antiRepeatDirective = `\n\n
|
|
895
|
+
antiRepeatDirective = `\n\n◆ CREATIVE DIVERSITY (DO NOT REPEAT RECENT PATTERNS):\n` +
|
|
895
896
|
recentPatterns.map((p) => `- ${p}`).join('\n') +
|
|
896
897
|
`\nChoose a DIFFERENT design approach, color palette, and font combination than the above.`;
|
|
897
898
|
}
|
|
@@ -1168,7 +1169,8 @@ export class AgentLoop {
|
|
|
1168
1169
|
const assessment = await coldObserver.evaluateMutation(tool, args, { workspaceRoot: this.workspaceRoot });
|
|
1169
1170
|
if (assessment.veto)
|
|
1170
1171
|
return false;
|
|
1171
|
-
const
|
|
1172
|
+
const isModeC = (this.config.autonomyMode || 'C') === 'C';
|
|
1173
|
+
const needsApproval = (!isModeC && uncertain) || requiresToolApproval({
|
|
1172
1174
|
mode: this.config.autonomyMode || 'C', tool, args,
|
|
1173
1175
|
risk: assessment.requiresConfirmation ? 'dangerous' : validation.risk,
|
|
1174
1176
|
heavyDownload: false, standingApproval: this.isAlwaysAllowed(tool)
|
|
@@ -1889,6 +1891,7 @@ export class AgentLoop {
|
|
|
1889
1891
|
const recoveryPaths = new Set();
|
|
1890
1892
|
let modelCallIndex = 0;
|
|
1891
1893
|
let mediaExplorationRecoveries = 0;
|
|
1894
|
+
let taskMutationCount = 0;
|
|
1892
1895
|
let reasoningOnlyRecoveries = 0;
|
|
1893
1896
|
let planHandoffRecoveries = 0;
|
|
1894
1897
|
let incompleteTurnContinuations = 0;
|
|
@@ -2082,7 +2085,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2082
2085
|
Array.isArray(ctx.keyFiles) && ctx.keyFiles.length > 0 && `Key files: ${ctx.keyFiles.slice(0, 25).join(', ')}`
|
|
2083
2086
|
].filter(Boolean);
|
|
2084
2087
|
if (facts.length > 0) {
|
|
2085
|
-
workspaceSummary = `\n\n
|
|
2088
|
+
workspaceSummary = `\n\n◆ WORKSPACE CONTEXT (already scanned for you — do NOT waste steps rediscovering this):\n${facts.join('\n')}`;
|
|
2086
2089
|
}
|
|
2087
2090
|
}
|
|
2088
2091
|
// --- PROMPT ASSEMBLY, ORDERED STABLE → VOLATILE ---
|
|
@@ -2188,7 +2191,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2188
2191
|
// here never invalidates the cached prefix in [1]-[3].
|
|
2189
2192
|
{
|
|
2190
2193
|
role: 'system',
|
|
2191
|
-
content: `${uncertaintyDirective ? uncertaintyDirective + '\n\n' : ''}${describeSession(this.taskId)}CURRENT AUTONOMY MODE: ${autonomyMode}\nALLOWED WORKSPACE PATHS: ${allowedPaths}\n(You MUST NOT write files outside these paths!)\n\n
|
|
2194
|
+
content: `${uncertaintyDirective ? uncertaintyDirective + '\n\n' : ''}${describeSession(this.taskId)}CURRENT AUTONOMY MODE: ${autonomyMode}\nALLOWED WORKSPACE PATHS: ${allowedPaths}\n(You MUST NOT write files outside these paths!)\n\n◆ PERSISTENT MEMORY (FACTS LEARNED ABOUT THE USER):\n${memoryContext}`
|
|
2192
2195
|
}
|
|
2193
2196
|
];
|
|
2194
2197
|
// Dev-only visibility into what fills each step's prompt. Set
|
|
@@ -2437,8 +2440,12 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2437
2440
|
auditLog.log({ event: 'native_action', taskId: this.taskId,
|
|
2438
2441
|
provider: this.config.provider || 'unknown', tool: action.name, status: action.status,
|
|
2439
2442
|
...(action.id ? { actionId: action.id } : {}) });
|
|
2440
|
-
if (action.status === 'completed' &&
|
|
2441
|
-
|
|
2443
|
+
if (action.status === 'completed' && !isChecklistTool) {
|
|
2444
|
+
const actionKey = action.id ? String(action.id) : `${action.name}:${completedNativeActionIds.size}`;
|
|
2445
|
+
if (!completedNativeActionIds.has(actionKey)) {
|
|
2446
|
+
completedNativeActionIds.add(actionKey);
|
|
2447
|
+
this.stepsCompleted++;
|
|
2448
|
+
}
|
|
2442
2449
|
}
|
|
2443
2450
|
const isCompleted = action.status === 'completed';
|
|
2444
2451
|
const isFailed = action.status === 'failed';
|
|
@@ -2500,8 +2507,11 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2500
2507
|
const lowerName = action.name.toLowerCase();
|
|
2501
2508
|
const rawDetail = String(action.detail || '');
|
|
2502
2509
|
const lowerDetail = rawDetail.toLowerCase();
|
|
2503
|
-
if (['fs_write', 'fs_edit', 'write_file', 'edit_file', 'write', 'edit', 'replace_file_content'].includes(lowerName)
|
|
2510
|
+
if (['fs_write', 'fs_edit', 'write_file', 'edit_file', 'write', 'edit', 'replace_file_content'].includes(lowerName)
|
|
2511
|
+
|| isNativeMutation(action.name, actionArgs)) {
|
|
2504
2512
|
nativeMutationCount++;
|
|
2513
|
+
taskMutationCount++;
|
|
2514
|
+
mediaExplorationRecoveries = 0;
|
|
2505
2515
|
if (nativeMutationCount === 1 && this._implementationPlanSeeded) {
|
|
2506
2516
|
this.advanceImplementationPlanProgress('mutation');
|
|
2507
2517
|
}
|
|
@@ -2792,7 +2802,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2792
2802
|
const hasExternalActions = completedExternalActions.length > 0;
|
|
2793
2803
|
const isIncompleteTurn = Boolean(response.incompleteTurn);
|
|
2794
2804
|
if (hasExternalActions) {
|
|
2795
|
-
this.stepsCompleted += completedExternalActions.length;
|
|
2805
|
+
this.stepsCompleted += Math.max(0, completedExternalActions.length - completedNativeActionIds.size);
|
|
2796
2806
|
for (const extAction of completedExternalActions) {
|
|
2797
2807
|
const extPlan = normalizePeerPlanEntries(extAction.parameters);
|
|
2798
2808
|
if (extPlan) {
|
|
@@ -3144,7 +3154,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3144
3154
|
const needsDepth = this.config.enforceGameDepth === true && this.stepsCompleted < 50;
|
|
3145
3155
|
if (needsDepth) {
|
|
3146
3156
|
this.gameGuardFired = true;
|
|
3147
|
-
this.emitEvent({ type: 'status', message: '
|
|
3157
|
+
this.emitEvent({ type: 'status', message: '✦ Sovereign Game Guard: Checking production depth...' });
|
|
3148
3158
|
const guardMsg = `[SOVEREIGN DEPTH NOTICE: You are building a Full Production Game with enforceGameDepth enabled. Current step count: ${this.stepsCompleted}. Expand the game with more levels, richer UI, complex enemy AI, or more assets before finishing. If the task is genuinely complete, state so and finish.]`;
|
|
3149
3159
|
this.messages.push({ role: 'system', content: guardMsg });
|
|
3150
3160
|
this.memoryManager.saveHistory(this.messages);
|
|
@@ -3188,7 +3198,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3188
3198
|
event: 'anti_slop_notice', taskId: this.taskId,
|
|
3189
3199
|
score: result.score, signals: result.findings.map((f) => f.id)
|
|
3190
3200
|
});
|
|
3191
|
-
this.emitEvent({ type: 'status', message:
|
|
3201
|
+
this.emitEvent({ type: 'status', message: `✦ Anti-Slop Audit: design scored ${result.score}` });
|
|
3192
3202
|
if (this.slopReviewAttempts >= 2 || auditHash === this.slopLastAuditHash) {
|
|
3193
3203
|
this.emitEvent({ type: 'error', message: `Web design audit still found generic patterns (score ${result.score}); the result was not verified as complete.` });
|
|
3194
3204
|
this.memoryManager.saveHistory(this.messages);
|
|
@@ -3267,7 +3277,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3267
3277
|
// The verification tools live in the web pack; make sure they are
|
|
3268
3278
|
// actually in context before demanding the agent use them.
|
|
3269
3279
|
this.unlockPack('web');
|
|
3270
|
-
this.emitEvent({ type: 'status', message: '
|
|
3280
|
+
this.emitEvent({ type: 'status', message: '✦ Anti-Slop Check: Visual/semantic verification recommended.' });
|
|
3271
3281
|
this.messages.push({ role: 'system', content: webGuardMsg });
|
|
3272
3282
|
this.memoryManager.saveHistory(this.messages);
|
|
3273
3283
|
if (!this.webVerificationState.htmlInspected || browserReady || (hasVision && visionReady)) {
|
|
@@ -4074,7 +4084,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4074
4084
|
this.webVerificationState.browserActUsed = false;
|
|
4075
4085
|
this.emitEvent({
|
|
4076
4086
|
type: 'status',
|
|
4077
|
-
message:
|
|
4087
|
+
message: `△ Browser runtime error(s) detected: ${allRuntimeErrors[0]}`
|
|
4078
4088
|
});
|
|
4079
4089
|
this.messages.push({
|
|
4080
4090
|
role: 'system',
|
|
@@ -4134,8 +4144,15 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4134
4144
|
const eventResult = result?._is_image_marker
|
|
4135
4145
|
? { success: result.success !== false && !result.error, output: result.output || `Image captured: ${result.filename || 'image'} (${result.mimeType || 'image/png'})` }
|
|
4136
4146
|
: result;
|
|
4137
|
-
|
|
4138
|
-
|
|
4147
|
+
const isErrorOutcome = result?.success === false || typeof result?.error === 'string';
|
|
4148
|
+
const errorMsg = eventResult?.error || (typeof result?.error === 'string' ? result.error : undefined);
|
|
4149
|
+
this.emitEvent({
|
|
4150
|
+
type: isErrorOutcome ? 'step_error' : 'step_complete',
|
|
4151
|
+
tool: functionName,
|
|
4152
|
+
...(isErrorOutcome && errorMsg ? { error: errorMsg } : {}),
|
|
4153
|
+
result: eventResult,
|
|
4154
|
+
toolCallId: toolCall.id
|
|
4155
|
+
});
|
|
4139
4156
|
this.stepsCompleted++;
|
|
4140
4157
|
if (this._implementationPlanSeeded && result?.success !== false && !result?.error && functionName !== 'update_plan') {
|
|
4141
4158
|
this.advanceImplementationPlanProgress('mutation');
|
|
@@ -4199,7 +4216,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4199
4216
|
stepsCompleted: this.stepsCompleted,
|
|
4200
4217
|
activeTier: this.activeTier,
|
|
4201
4218
|
maxTierSteps: this.maxSteps,
|
|
4202
|
-
message:
|
|
4219
|
+
message: `△ Circuit Breaker Checkpoint (100 steps reached). Approve to unlock and continue using your remaining ${this.activeTier.toUpperCase()} tier budget (up to ${this.maxSteps} steps total)?`
|
|
4203
4220
|
},
|
|
4204
4221
|
risk: 'info'
|
|
4205
4222
|
});
|
|
@@ -4210,7 +4227,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4210
4227
|
break;
|
|
4211
4228
|
}
|
|
4212
4229
|
this.circuitBreakerUnlocked = true;
|
|
4213
|
-
this.emitEvent({ type: 'status', message:
|
|
4230
|
+
this.emitEvent({ type: 'status', message: `✓ Circuit breaker unlocked! Resuming execution up to ${this.maxSteps} tier budget...` });
|
|
4214
4231
|
}
|
|
4215
4232
|
}
|
|
4216
4233
|
// Sovereign Tier Budget Extension Checkpoint Gate
|
|
@@ -4229,7 +4246,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4229
4246
|
stepsCompleted: this.stepsCompleted,
|
|
4230
4247
|
activeTier: this.activeTier,
|
|
4231
4248
|
currentMaxSteps: this.maxSteps,
|
|
4232
|
-
message:
|
|
4249
|
+
message: `△ Tier Limit Reached (${this.stepsCompleted} / ${this.maxSteps} steps). The agent needs more steps to fulfill your intent. Approve to unlock another +${extensionBatch} steps for your ${this.activeTier.toUpperCase()} tier?`
|
|
4233
4250
|
},
|
|
4234
4251
|
risk: 'info'
|
|
4235
4252
|
});
|
|
@@ -4241,7 +4258,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4241
4258
|
}
|
|
4242
4259
|
this.maxSteps += extensionBatch;
|
|
4243
4260
|
this.maxCircuitBreaker = this.maxSteps;
|
|
4244
|
-
this.emitEvent({ type: 'status', message:
|
|
4261
|
+
this.emitEvent({ type: 'status', message: `✓ Tier budget extended (+${extensionBatch} steps unlocked, new limit: ${this.maxSteps}). Resuming task...` });
|
|
4245
4262
|
}
|
|
4246
4263
|
}
|
|
4247
4264
|
// SmartToolsUse tracks actual local tool calls, without denying
|
|
@@ -4470,17 +4487,23 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4470
4487
|
}
|
|
4471
4488
|
if (e?.code === 'AGY_EXPLORATION_LOOP' || e?.code === 'AGENT_EXPLORATION_LOOP' || e?.code === 'STALL_EXPLORATION_LOOP') {
|
|
4472
4489
|
auditLog.log({ event: 'media_exploration_checkpoint', taskId: this.taskId,
|
|
4473
|
-
inspectionCount: e.inspectionCount, recovery: mediaExplorationRecoveries });
|
|
4490
|
+
inspectionCount: e.inspectionCount, recovery: mediaExplorationRecoveries, mutations: taskMutationCount });
|
|
4474
4491
|
if (mediaExplorationRecoveries++ === 0) {
|
|
4475
|
-
this.messages.push({ role: 'system', content:
|
|
4476
|
-
'
|
|
4477
|
-
'
|
|
4478
|
-
|
|
4492
|
+
this.messages.push({ role: 'system', content: taskMutationCount > 0
|
|
4493
|
+
? '[TASK RECOVERY] Repeated identical tool polling or inspection was paused after workspace edits. Do not repeat identical probes; verify the completed changes once and present the final result.'
|
|
4494
|
+
: '[TASK RECOVERY] Consecutive read-only inspections without workspace changes were paused. ' +
|
|
4495
|
+
'The user requested a concrete change. Reuse the observations already gathered; do not repeat probes. ' +
|
|
4496
|
+
'Make one targeted workspace edit now, then run one focused verification. ' +
|
|
4497
|
+
'If editing is blocked, report the exact blocker. Do not claim completion from inspection alone.' });
|
|
4479
4498
|
this.memoryManager.saveHistory(this.messages);
|
|
4480
|
-
this.emitEvent({ type: 'notice', message:
|
|
4499
|
+
this.emitEvent({ type: 'notice', message: taskMutationCount > 0
|
|
4500
|
+
? 'Repeated status probe paused; continuing from completed workspace edits.'
|
|
4501
|
+
: 'Repeated inspection paused; continuing once with a direct edit instruction.' });
|
|
4481
4502
|
continue;
|
|
4482
4503
|
}
|
|
4483
|
-
this.emitEvent({ type: 'error', message:
|
|
4504
|
+
this.emitEvent({ type: 'error', message: taskMutationCount > 0
|
|
4505
|
+
? 'The provider repeated an identical tool call after a recovery checkpoint. Workspace edits are preserved on disk.'
|
|
4506
|
+
: 'The provider continued read-only inspection after a corrective checkpoint. The task remains unfinished; no edit was verified.' });
|
|
4484
4507
|
break;
|
|
4485
4508
|
}
|
|
4486
4509
|
if (e?.code === 'PROVIDER_EMPTY_RESPONSE'
|
package/src/agentLoop.ts
CHANGED
|
@@ -95,6 +95,7 @@ import path from 'path';
|
|
|
95
95
|
import { analyzeFiles, formatFindings, isScannableFile } from './slopDetector.js';
|
|
96
96
|
import { suggestMovements, formatMovementBrief } from './designPalettes.js';
|
|
97
97
|
import { createProvider } from './providers/factory.js';
|
|
98
|
+
import { isNativeMutation } from './providers/antigravity.js';
|
|
98
99
|
import { resolveMentionedContext } from './promptMentions.js';
|
|
99
100
|
import { isLaunchOnlyPrompt, launchScopeError } from './launchIntent.js';
|
|
100
101
|
import { StreamingCodePreview, NativeCodeObserver, codeProgressFromAction } from './tui/codeProgress.js';
|
|
@@ -979,7 +980,7 @@ export class AgentLoop {
|
|
|
979
980
|
try {
|
|
980
981
|
const matches = await cortexDb.search(this.currentTaskPrompt, 2, { workspace: this.workspaceRoot });
|
|
981
982
|
if (matches.length > 0 && matches[0]) {
|
|
982
|
-
lessonsLearned = `\n\n
|
|
983
|
+
lessonsLearned = `\n\n◆ DIGITAL BRAIN (LESSONS LEARNED FROM PAST MISTAKES):\n` + matches.map((m: any) => `- ${m.text}`).join('\n');
|
|
983
984
|
this._lessonSimilarity = matches[0].similarity || 0;
|
|
984
985
|
this.debugLog(`cortex search hit: ${(this._lessonSimilarity * 100).toFixed(0)}% similarity`);
|
|
985
986
|
}
|
|
@@ -1003,7 +1004,7 @@ export class AgentLoop {
|
|
|
1003
1004
|
try {
|
|
1004
1005
|
const recentPatterns = await cortexDb.getRecentCreativePatterns(5);
|
|
1005
1006
|
if (recentPatterns.length > 0) {
|
|
1006
|
-
antiRepeatDirective = `\n\n
|
|
1007
|
+
antiRepeatDirective = `\n\n◆ CREATIVE DIVERSITY (DO NOT REPEAT RECENT PATTERNS):\n` +
|
|
1007
1008
|
recentPatterns.map((p: any) => `- ${p}`).join('\n') +
|
|
1008
1009
|
`\nChoose a DIFFERENT design approach, color palette, and font combination than the above.`;
|
|
1009
1010
|
}
|
|
@@ -1267,7 +1268,8 @@ export class AgentLoop {
|
|
|
1267
1268
|
if (hook?.denied) return false;
|
|
1268
1269
|
const assessment = await coldObserver.evaluateMutation(tool, args, { workspaceRoot: this.workspaceRoot });
|
|
1269
1270
|
if (assessment.veto) return false;
|
|
1270
|
-
const
|
|
1271
|
+
const isModeC = (this.config.autonomyMode || 'C') === 'C';
|
|
1272
|
+
const needsApproval = (!isModeC && uncertain) || requiresToolApproval({
|
|
1271
1273
|
mode: this.config.autonomyMode || 'C', tool, args,
|
|
1272
1274
|
risk: assessment.requiresConfirmation ? 'dangerous' : validation.risk,
|
|
1273
1275
|
heavyDownload: false, standingApproval: this.isAlwaysAllowed(tool)
|
|
@@ -1975,6 +1977,7 @@ export class AgentLoop {
|
|
|
1975
1977
|
const recoveryPaths = new Set<string>();
|
|
1976
1978
|
let modelCallIndex = 0;
|
|
1977
1979
|
let mediaExplorationRecoveries = 0;
|
|
1980
|
+
let taskMutationCount = 0;
|
|
1978
1981
|
let reasoningOnlyRecoveries = 0;
|
|
1979
1982
|
let planHandoffRecoveries = 0;
|
|
1980
1983
|
let incompleteTurnContinuations = 0;
|
|
@@ -2180,7 +2183,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2180
2183
|
Array.isArray(ctx.keyFiles) && ctx.keyFiles.length > 0 && `Key files: ${ctx.keyFiles.slice(0, 25).join(', ')}`
|
|
2181
2184
|
].filter(Boolean);
|
|
2182
2185
|
if (facts.length > 0) {
|
|
2183
|
-
workspaceSummary = `\n\n
|
|
2186
|
+
workspaceSummary = `\n\n◆ WORKSPACE CONTEXT (already scanned for you — do NOT waste steps rediscovering this):\n${facts.join('\n')}`;
|
|
2184
2187
|
}
|
|
2185
2188
|
}
|
|
2186
2189
|
|
|
@@ -2294,7 +2297,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2294
2297
|
// here never invalidates the cached prefix in [1]-[3].
|
|
2295
2298
|
{
|
|
2296
2299
|
role: 'system',
|
|
2297
|
-
content: `${uncertaintyDirective ? uncertaintyDirective + '\n\n' : ''}${describeSession(this.taskId)}CURRENT AUTONOMY MODE: ${autonomyMode}\nALLOWED WORKSPACE PATHS: ${allowedPaths}\n(You MUST NOT write files outside these paths!)\n\n
|
|
2300
|
+
content: `${uncertaintyDirective ? uncertaintyDirective + '\n\n' : ''}${describeSession(this.taskId)}CURRENT AUTONOMY MODE: ${autonomyMode}\nALLOWED WORKSPACE PATHS: ${allowedPaths}\n(You MUST NOT write files outside these paths!)\n\n◆ PERSISTENT MEMORY (FACTS LEARNED ABOUT THE USER):\n${memoryContext}`
|
|
2298
2301
|
}
|
|
2299
2302
|
];
|
|
2300
2303
|
|
|
@@ -2543,8 +2546,12 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2543
2546
|
auditLog.log({ event: 'native_action', taskId: this.taskId,
|
|
2544
2547
|
provider: this.config.provider || 'unknown', tool: action.name, status: action.status,
|
|
2545
2548
|
...(action.id ? { actionId: action.id } : {}) });
|
|
2546
|
-
if (action.status === 'completed' &&
|
|
2547
|
-
|
|
2549
|
+
if (action.status === 'completed' && !isChecklistTool) {
|
|
2550
|
+
const actionKey = action.id ? String(action.id) : `${action.name}:${completedNativeActionIds.size}`;
|
|
2551
|
+
if (!completedNativeActionIds.has(actionKey)) {
|
|
2552
|
+
completedNativeActionIds.add(actionKey);
|
|
2553
|
+
this.stepsCompleted++;
|
|
2554
|
+
}
|
|
2548
2555
|
}
|
|
2549
2556
|
const isCompleted = action.status === 'completed';
|
|
2550
2557
|
const isFailed = action.status === 'failed';
|
|
@@ -2601,8 +2608,11 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2601
2608
|
const lowerName = action.name.toLowerCase();
|
|
2602
2609
|
const rawDetail = String(action.detail || '');
|
|
2603
2610
|
const lowerDetail = rawDetail.toLowerCase();
|
|
2604
|
-
if (['fs_write', 'fs_edit', 'write_file', 'edit_file', 'write', 'edit', 'replace_file_content'].includes(lowerName)
|
|
2611
|
+
if (['fs_write', 'fs_edit', 'write_file', 'edit_file', 'write', 'edit', 'replace_file_content'].includes(lowerName)
|
|
2612
|
+
|| isNativeMutation(action.name, actionArgs)) {
|
|
2605
2613
|
nativeMutationCount++;
|
|
2614
|
+
taskMutationCount++;
|
|
2615
|
+
mediaExplorationRecoveries = 0;
|
|
2606
2616
|
if (nativeMutationCount === 1 && this._implementationPlanSeeded) {
|
|
2607
2617
|
this.advanceImplementationPlanProgress('mutation');
|
|
2608
2618
|
} else if (nativeMutationCount % 2 === 0) {
|
|
@@ -2918,7 +2928,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2918
2928
|
const isIncompleteTurn = Boolean((response as any).incompleteTurn);
|
|
2919
2929
|
|
|
2920
2930
|
if (hasExternalActions) {
|
|
2921
|
-
this.stepsCompleted += completedExternalActions.length;
|
|
2931
|
+
this.stepsCompleted += Math.max(0, completedExternalActions.length - completedNativeActionIds.size);
|
|
2922
2932
|
for (const extAction of completedExternalActions) {
|
|
2923
2933
|
const extPlan = normalizePeerPlanEntries(extAction.parameters);
|
|
2924
2934
|
if (extPlan) {
|
|
@@ -3304,7 +3314,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3304
3314
|
|
|
3305
3315
|
if (needsDepth) {
|
|
3306
3316
|
this.gameGuardFired = true;
|
|
3307
|
-
this.emitEvent({ type: 'status', message: '
|
|
3317
|
+
this.emitEvent({ type: 'status', message: '✦ Sovereign Game Guard: Checking production depth...' });
|
|
3308
3318
|
|
|
3309
3319
|
const guardMsg = `[SOVEREIGN DEPTH NOTICE: You are building a Full Production Game with enforceGameDepth enabled. Current step count: ${this.stepsCompleted}. Expand the game with more levels, richer UI, complex enemy AI, or more assets before finishing. If the task is genuinely complete, state so and finish.]`;
|
|
3310
3320
|
|
|
@@ -3351,7 +3361,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3351
3361
|
event: 'anti_slop_notice', taskId: this.taskId,
|
|
3352
3362
|
score: result.score, signals: result.findings.map((f: any) => f.id)
|
|
3353
3363
|
});
|
|
3354
|
-
this.emitEvent({ type: 'status', message:
|
|
3364
|
+
this.emitEvent({ type: 'status', message: `✦ Anti-Slop Audit: design scored ${result.score}` });
|
|
3355
3365
|
if (this.slopReviewAttempts >= 2 || auditHash === this.slopLastAuditHash) {
|
|
3356
3366
|
this.emitEvent({ type: 'error', message: `Web design audit still found generic patterns (score ${result.score}); the result was not verified as complete.` });
|
|
3357
3367
|
this.memoryManager.saveHistory(this.messages);
|
|
@@ -3429,7 +3439,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3429
3439
|
// The verification tools live in the web pack; make sure they are
|
|
3430
3440
|
// actually in context before demanding the agent use them.
|
|
3431
3441
|
this.unlockPack('web');
|
|
3432
|
-
this.emitEvent({ type: 'status', message: '
|
|
3442
|
+
this.emitEvent({ type: 'status', message: '✦ Anti-Slop Check: Visual/semantic verification recommended.' });
|
|
3433
3443
|
this.messages.push({ role: 'system', content: webGuardMsg });
|
|
3434
3444
|
this.memoryManager.saveHistory(this.messages);
|
|
3435
3445
|
if (!this.webVerificationState.htmlInspected || browserReady || (hasVision && visionReady)) {
|
|
@@ -4297,7 +4307,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4297
4307
|
this.webVerificationState.browserActUsed = false;
|
|
4298
4308
|
this.emitEvent({
|
|
4299
4309
|
type: 'status',
|
|
4300
|
-
message:
|
|
4310
|
+
message: `△ Browser runtime error(s) detected: ${allRuntimeErrors[0]}`
|
|
4301
4311
|
});
|
|
4302
4312
|
this.messages.push({
|
|
4303
4313
|
role: 'system',
|
|
@@ -4361,8 +4371,15 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4361
4371
|
const eventResult = result?._is_image_marker
|
|
4362
4372
|
? { success: result.success !== false && !result.error, output: result.output || `Image captured: ${result.filename || 'image'} (${result.mimeType || 'image/png'})` }
|
|
4363
4373
|
: result;
|
|
4364
|
-
|
|
4365
|
-
|
|
4374
|
+
const isErrorOutcome = result?.success === false || typeof result?.error === 'string';
|
|
4375
|
+
const errorMsg = eventResult?.error || (typeof result?.error === 'string' ? result.error : undefined);
|
|
4376
|
+
this.emitEvent({
|
|
4377
|
+
type: isErrorOutcome ? 'step_error' : 'step_complete',
|
|
4378
|
+
tool: functionName,
|
|
4379
|
+
...(isErrorOutcome && errorMsg ? { error: errorMsg } : {}),
|
|
4380
|
+
result: eventResult,
|
|
4381
|
+
toolCallId: toolCall.id
|
|
4382
|
+
});
|
|
4366
4383
|
this.stepsCompleted++;
|
|
4367
4384
|
if (this._implementationPlanSeeded && result?.success !== false && !result?.error && functionName !== 'update_plan') {
|
|
4368
4385
|
this.advanceImplementationPlanProgress('mutation');
|
|
@@ -4433,7 +4450,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4433
4450
|
stepsCompleted: this.stepsCompleted,
|
|
4434
4451
|
activeTier: this.activeTier,
|
|
4435
4452
|
maxTierSteps: this.maxSteps,
|
|
4436
|
-
message:
|
|
4453
|
+
message: `△ Circuit Breaker Checkpoint (100 steps reached). Approve to unlock and continue using your remaining ${this.activeTier.toUpperCase()} tier budget (up to ${this.maxSteps} steps total)?`
|
|
4437
4454
|
},
|
|
4438
4455
|
risk: 'info'
|
|
4439
4456
|
});
|
|
@@ -4445,7 +4462,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4445
4462
|
break;
|
|
4446
4463
|
}
|
|
4447
4464
|
this.circuitBreakerUnlocked = true;
|
|
4448
|
-
this.emitEvent({ type: 'status', message:
|
|
4465
|
+
this.emitEvent({ type: 'status', message: `✓ Circuit breaker unlocked! Resuming execution up to ${this.maxSteps} tier budget...` });
|
|
4449
4466
|
}
|
|
4450
4467
|
}
|
|
4451
4468
|
|
|
@@ -4464,7 +4481,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4464
4481
|
stepsCompleted: this.stepsCompleted,
|
|
4465
4482
|
activeTier: this.activeTier,
|
|
4466
4483
|
currentMaxSteps: this.maxSteps,
|
|
4467
|
-
message:
|
|
4484
|
+
message: `△ Tier Limit Reached (${this.stepsCompleted} / ${this.maxSteps} steps). The agent needs more steps to fulfill your intent. Approve to unlock another +${extensionBatch} steps for your ${this.activeTier.toUpperCase()} tier?`
|
|
4468
4485
|
},
|
|
4469
4486
|
risk: 'info'
|
|
4470
4487
|
});
|
|
@@ -4477,7 +4494,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4477
4494
|
}
|
|
4478
4495
|
this.maxSteps += extensionBatch;
|
|
4479
4496
|
this.maxCircuitBreaker = this.maxSteps;
|
|
4480
|
-
this.emitEvent({ type: 'status', message:
|
|
4497
|
+
this.emitEvent({ type: 'status', message: `✓ Tier budget extended (+${extensionBatch} steps unlocked, new limit: ${this.maxSteps}). Resuming task...` });
|
|
4481
4498
|
}
|
|
4482
4499
|
}
|
|
4483
4500
|
|
|
@@ -4720,19 +4737,25 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4720
4737
|
}
|
|
4721
4738
|
if (e?.code === 'AGY_EXPLORATION_LOOP' || e?.code === 'AGENT_EXPLORATION_LOOP' || e?.code === 'STALL_EXPLORATION_LOOP') {
|
|
4722
4739
|
auditLog.log({ event: 'media_exploration_checkpoint', taskId: this.taskId,
|
|
4723
|
-
inspectionCount: e.inspectionCount, recovery: mediaExplorationRecoveries });
|
|
4740
|
+
inspectionCount: e.inspectionCount, recovery: mediaExplorationRecoveries, mutations: taskMutationCount });
|
|
4724
4741
|
if (mediaExplorationRecoveries++ === 0) {
|
|
4725
4742
|
this.messages.push({ role: 'system', content:
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4743
|
+
taskMutationCount > 0
|
|
4744
|
+
? '[TASK RECOVERY] Repeated identical tool polling or inspection was paused after workspace edits. Do not repeat identical probes; verify the completed changes once and present the final result.'
|
|
4745
|
+
: '[TASK RECOVERY] Consecutive read-only inspections without workspace changes were paused. ' +
|
|
4746
|
+
'The user requested a concrete change. Reuse the observations already gathered; do not repeat probes. ' +
|
|
4747
|
+
'Make one targeted workspace edit now, then run one focused verification. ' +
|
|
4748
|
+
'If editing is blocked, report the exact blocker. Do not claim completion from inspection alone.' });
|
|
4730
4749
|
this.memoryManager.saveHistory(this.messages);
|
|
4731
|
-
this.emitEvent({ type: 'notice', message:
|
|
4750
|
+
this.emitEvent({ type: 'notice', message: taskMutationCount > 0
|
|
4751
|
+
? 'Repeated status probe paused; continuing from completed workspace edits.'
|
|
4752
|
+
: 'Repeated inspection paused; continuing once with a direct edit instruction.' });
|
|
4732
4753
|
continue;
|
|
4733
4754
|
}
|
|
4734
4755
|
this.emitEvent({ type: 'error', message:
|
|
4735
|
-
|
|
4756
|
+
taskMutationCount > 0
|
|
4757
|
+
? 'The provider repeated an identical tool call after a recovery checkpoint. Workspace edits are preserved on disk.'
|
|
4758
|
+
: 'The provider continued read-only inspection after a corrective checkpoint. The task remains unfinished; no edit was verified.' });
|
|
4736
4759
|
break;
|
|
4737
4760
|
}
|
|
4738
4761
|
if (e?.code === 'PROVIDER_EMPTY_RESPONSE'
|
|
@@ -10,7 +10,7 @@ import { windowSnapshot } from './snapshotWindow.js';
|
|
|
10
10
|
const NAVIGATION_TIMEOUT_MS = 30_000;
|
|
11
11
|
const ACTION_TIMEOUT_MS = 12_000;
|
|
12
12
|
const IFRAME_SNAPSHOT_TIMEOUT_MS = 3_000;
|
|
13
|
-
const IDLE_CLOSE_MS =
|
|
13
|
+
const IDLE_CLOSE_MS = 120 * 60_000;
|
|
14
14
|
const MAX_SEARCH_RESULTS = 10;
|
|
15
15
|
const MAX_EXTRACT_CHARS = 80_000;
|
|
16
16
|
const MAX_DOWNLOAD_BYTES = 250 * 1024 * 1024;
|
|
@@ -16,7 +16,7 @@ import { windowSnapshot, type SnapshotWindow } from './snapshotWindow.js';
|
|
|
16
16
|
const NAVIGATION_TIMEOUT_MS = 30_000;
|
|
17
17
|
const ACTION_TIMEOUT_MS = 12_000;
|
|
18
18
|
const IFRAME_SNAPSHOT_TIMEOUT_MS = 3_000;
|
|
19
|
-
const IDLE_CLOSE_MS =
|
|
19
|
+
const IDLE_CLOSE_MS = 120 * 60_000;
|
|
20
20
|
const MAX_SEARCH_RESULTS = 10;
|
|
21
21
|
const MAX_EXTRACT_CHARS = 80_000;
|
|
22
22
|
const MAX_DOWNLOAD_BYTES = 250 * 1024 * 1024;
|
package/src/cliMode.js
CHANGED
|
@@ -472,12 +472,66 @@ export async function chatMode({ home = false } = {}) {
|
|
|
472
472
|
|
|
473
473
|
// surfaces, and the text form remains the fallback rather than a
|
|
474
474
|
// second implementation that can disagree.
|
|
475
|
+
if (commandResult.effect === 'clear-skill') {
|
|
476
|
+
loop.activeSkill = null;
|
|
477
|
+
if (surface) surface.setSessionInfo({ activeSkill: null });
|
|
478
|
+
if (prompt) {
|
|
479
|
+
prompt.notice = 'Active skill cleared';
|
|
480
|
+
if (typeof prompt.draw === 'function') prompt.draw();
|
|
481
|
+
}
|
|
482
|
+
conn.renderer.write('\n' + paint('muted', ' Active skill cleared.') + '\n');
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (commandResult.effect === 'create-skill' && prompt) {
|
|
487
|
+
const { runInteractiveSkillWizard } = await import('./tui/skillAuthoring.js');
|
|
488
|
+
const created = await runInteractiveSkillWizard(prompt);
|
|
489
|
+
if (created) {
|
|
490
|
+
loop.activeSkill = created;
|
|
491
|
+
if (surface) surface.setSessionInfo({ activeSkill: loop.activeSkill });
|
|
492
|
+
prompt.notice = `✦ Skill created & activated: ${created.domain}/${created.id}`;
|
|
493
|
+
conn.renderer.write('\n' + paint('success', ` Created and activated skill: ${bold(created.domain + '/' + created.id)}`) + '\n');
|
|
494
|
+
if (created.path) conn.renderer.write(dim(` Stored at: ${created.path}\n`));
|
|
495
|
+
if (typeof prompt.draw === 'function') prompt.draw();
|
|
496
|
+
}
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
|
|
475
500
|
if (commandResult.effect === 'pick-skill' && prompt) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
501
|
+
prompt.browseSkills(commandResult.items, async (skill) => {
|
|
502
|
+
if (!skill) return;
|
|
503
|
+
if (skill.isCreateAction || (skill.domain === 'custom' && skill.id === 'create')) {
|
|
504
|
+
const { runInteractiveSkillWizard } = await import('./tui/skillAuthoring.js');
|
|
505
|
+
const created = await runInteractiveSkillWizard(prompt);
|
|
506
|
+
if (created) {
|
|
507
|
+
loop.activeSkill = created;
|
|
508
|
+
if (surface) surface.setSessionInfo({ activeSkill: loop.activeSkill });
|
|
509
|
+
prompt.notice = `✦ Skill created & activated: ${created.domain}/${created.id}`;
|
|
510
|
+
conn.renderer.write('\n' + paint('success', ` Created and activated skill: ${bold(created.domain + '/' + created.id)}`) + '\n');
|
|
511
|
+
if (created.path) conn.renderer.write(dim(` Stored at: ${created.path}\n`));
|
|
512
|
+
if (typeof prompt.draw === 'function') prompt.draw();
|
|
513
|
+
}
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
const { readCompiledSkill } = await import('./skillsManager.js');
|
|
518
|
+
const content = readCompiledSkill(skill.domain, skill.id);
|
|
519
|
+
loop.activeSkill = {
|
|
520
|
+
id: `${skill.domain}/${skill.id}`,
|
|
521
|
+
name: skill.name || skill.id,
|
|
522
|
+
domain: skill.domain,
|
|
523
|
+
description: skill.description || '',
|
|
524
|
+
content: typeof content === 'string' ? content : ''
|
|
525
|
+
};
|
|
526
|
+
if (surface) surface.setSessionInfo({ activeSkill: loop.activeSkill });
|
|
527
|
+
prompt.notice = `✦ Skill active: ${skill.domain}/${skill.id}`;
|
|
528
|
+
conn.renderer.write('\n' + paint('success', ` ✦ Activated skill: ${bold(skill.domain + '/' + skill.id)}`) + '\n');
|
|
529
|
+
if (skill.description) {
|
|
530
|
+
conn.renderer.write(dim(` ${skill.description}\n`));
|
|
531
|
+
}
|
|
532
|
+
conn.renderer.write(dim(` Type instructions for this skill, or press Enter to apply to workspace.\n`));
|
|
533
|
+
prompt.setText('');
|
|
534
|
+
if (typeof prompt.draw === 'function') prompt.draw();
|
|
481
535
|
});
|
|
482
536
|
continue;
|
|
483
537
|
}
|
|
@@ -526,6 +580,7 @@ export async function chatMode({ home = false } = {}) {
|
|
|
526
580
|
// a working method the agent follows rather than a document it shows you.
|
|
527
581
|
if (commandResult.effect === 'invoke-skill') {
|
|
528
582
|
loop.activeSkill = commandResult.skill;
|
|
583
|
+
if (surface) surface.setSessionInfo({ activeSkill: loop.activeSkill });
|
|
529
584
|
conn.renderer.skillInvoked(commandResult.skill.id, commandResult.instruction);
|
|
530
585
|
task = commandResult.instruction
|
|
531
586
|
|| `Apply the ${commandResult.skill.id} skill to the current workspace.`;
|
|
@@ -582,17 +637,19 @@ export async function chatMode({ home = false } = {}) {
|
|
|
582
637
|
paint('muted', ' Run /setup or select setup from the home menu to configure your provider.\n'));
|
|
583
638
|
continue;
|
|
584
639
|
}
|
|
585
|
-
|
|
640
|
+
try {
|
|
641
|
+
await loop.run();
|
|
642
|
+
} finally {
|
|
643
|
+
conn.stopSpinner();
|
|
644
|
+
// Active skill remains persistent across turns until explicitly cleared via /skill clear or another skill is selected.
|
|
645
|
+
if (surface) surface.setSessionInfo({ activeSkill: loop.activeSkill });
|
|
646
|
+
conn.renderer.turnFooter(Date.now() - startedAt);
|
|
647
|
+
}
|
|
586
648
|
} finally {
|
|
587
649
|
// Must be released on the error path too, or one failed turn leaves the
|
|
588
650
|
// prompt permanently queueing and the chat looks hung.
|
|
589
651
|
if (prompt) prompt.setBusy(false);
|
|
590
652
|
}
|
|
591
|
-
conn.stopSpinner();
|
|
592
|
-
// One turn, one skill: an invocation must not silently steer every later
|
|
593
|
-
// message in the session.
|
|
594
|
-
loop.activeSkill = null;
|
|
595
|
-
conn.renderer.turnFooter(Date.now() - startedAt);
|
|
596
653
|
}
|
|
597
654
|
|
|
598
655
|
process.exit(0);
|