@causyne/agent 1.20.63 → 1.20.68

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.
Files changed (47) hide show
  1. package/package.json +1 -1
  2. package/src/agentLoop.js +23 -15
  3. package/src/agentLoop.ts +23 -15
  4. package/src/approvalPolicy.js +19 -0
  5. package/src/approvalPolicy.ts +18 -0
  6. package/src/browser/causyneBrowser.js +34 -4
  7. package/src/browser/causyneBrowser.ts +32 -4
  8. package/src/cliMode.js +65 -36
  9. package/src/commands.js +48 -19
  10. package/src/contextManager.js +1 -1
  11. package/src/continuum/ui/continuumPicker.js +1 -1
  12. package/src/continuum/ui/continuumPicker.ts +1 -1
  13. package/src/embodimentSession.js +1 -1
  14. package/src/planCache.js +1 -1
  15. package/src/planCache.ts +1 -1
  16. package/src/promptMentions.js +7 -7
  17. package/src/promptMentions.ts +7 -7
  18. package/src/providers/dashscope-byok.js +1 -1
  19. package/src/providers/qwen-byok.js +1 -1
  20. package/src/skillsManager.d.ts +4 -1
  21. package/src/tokenTracker.js +1 -1
  22. package/src/tokenTracker.ts +1 -1
  23. package/src/tool-scripts/ax_snapshot.ps1 +10 -10
  24. package/src/tools/fsList.js +1 -1
  25. package/src/tools/memoryWrite.js +1 -1
  26. package/src/tools/memoryWrite.ts +1 -1
  27. package/src/tui/chatRenderer.js +3 -2
  28. package/src/tui/codeStreamRenderer.js +8 -5
  29. package/src/tui/codeStreamRenderer.ts +10 -5
  30. package/src/tui/composerControls.js +2 -0
  31. package/src/tui/composerControls.ts +2 -0
  32. package/src/tui/dialogs.js +36 -4
  33. package/src/tui/lineEditor.js +14 -21
  34. package/src/tui/modelPicker.js +1 -1
  35. package/src/tui/modelPicker.ts +1 -1
  36. package/src/tui/prompt.js +48 -16
  37. package/src/tui/sessionPicker.js +1 -1
  38. package/src/tui/sessionPicker.ts +1 -1
  39. package/src/tui/sessionSidebar.js +13 -0
  40. package/src/tui/sessionSidebar.ts +15 -0
  41. package/src/tui/skillAuthoring.js +147 -0
  42. package/src/tui/skillAuthoring.ts +172 -0
  43. package/src/tui/stage.js +1 -1
  44. package/src/tui/stageSurface.js +8 -10
  45. package/src/tui/theme.js +3 -0
  46. package/src/vfeTracker.js +1 -1
  47. package/src/vfeTracker.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@causyne/agent",
3
- "version": "1.20.63",
3
+ "version": "1.20.68",
4
4
  "description": "Agentic AI for software, tools, and computer workflows",
5
5
  "main": "bin/causyne.js",
6
6
  "type": "module",
package/src/agentLoop.js CHANGED
@@ -867,7 +867,7 @@ export class AgentLoop {
867
867
  try {
868
868
  const matches = await cortexDb.search(this.currentTaskPrompt, 2, { workspace: this.workspaceRoot });
869
869
  if (matches.length > 0 && matches[0]) {
870
- lessonsLearned = `\n\n🧠 DIGITAL BRAIN (LESSONS LEARNED FROM PAST MISTAKES):\n` + matches.map((m) => `- ${m.text}`).join('\n');
870
+ lessonsLearned = `\n\n◆ DIGITAL BRAIN (LESSONS LEARNED FROM PAST MISTAKES):\n` + matches.map((m) => `- ${m.text}`).join('\n');
871
871
  this._lessonSimilarity = matches[0].similarity || 0;
872
872
  this.debugLog(`cortex search hit: ${(this._lessonSimilarity * 100).toFixed(0)}% similarity`);
873
873
  }
@@ -891,7 +891,7 @@ export class AgentLoop {
891
891
  try {
892
892
  const recentPatterns = await cortexDb.getRecentCreativePatterns(5);
893
893
  if (recentPatterns.length > 0) {
894
- antiRepeatDirective = `\n\n🎨 CREATIVE DIVERSITY (DO NOT REPEAT RECENT PATTERNS):\n` +
894
+ antiRepeatDirective = `\n\n◆ CREATIVE DIVERSITY (DO NOT REPEAT RECENT PATTERNS):\n` +
895
895
  recentPatterns.map((p) => `- ${p}`).join('\n') +
896
896
  `\nChoose a DIFFERENT design approach, color palette, and font combination than the above.`;
897
897
  }
@@ -1168,7 +1168,8 @@ export class AgentLoop {
1168
1168
  const assessment = await coldObserver.evaluateMutation(tool, args, { workspaceRoot: this.workspaceRoot });
1169
1169
  if (assessment.veto)
1170
1170
  return false;
1171
- const needsApproval = uncertain || requiresToolApproval({
1171
+ const isModeC = (this.config.autonomyMode || 'C') === 'C';
1172
+ const needsApproval = (!isModeC && uncertain) || requiresToolApproval({
1172
1173
  mode: this.config.autonomyMode || 'C', tool, args,
1173
1174
  risk: assessment.requiresConfirmation ? 'dangerous' : validation.risk,
1174
1175
  heavyDownload: false, standingApproval: this.isAlwaysAllowed(tool)
@@ -2082,7 +2083,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
2082
2083
  Array.isArray(ctx.keyFiles) && ctx.keyFiles.length > 0 && `Key files: ${ctx.keyFiles.slice(0, 25).join(', ')}`
2083
2084
  ].filter(Boolean);
2084
2085
  if (facts.length > 0) {
2085
- workspaceSummary = `\n\n📂 WORKSPACE CONTEXT (already scanned for you — do NOT waste steps rediscovering this):\n${facts.join('\n')}`;
2086
+ workspaceSummary = `\n\n◆ WORKSPACE CONTEXT (already scanned for you — do NOT waste steps rediscovering this):\n${facts.join('\n')}`;
2086
2087
  }
2087
2088
  }
2088
2089
  // --- PROMPT ASSEMBLY, ORDERED STABLE → VOLATILE ---
@@ -2188,7 +2189,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
2188
2189
  // here never invalidates the cached prefix in [1]-[3].
2189
2190
  {
2190
2191
  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🧠 PERSISTENT MEMORY (FACTS LEARNED ABOUT THE USER):\n${memoryContext}`
2192
+ 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
2193
  }
2193
2194
  ];
2194
2195
  // Dev-only visibility into what fills each step's prompt. Set
@@ -3144,7 +3145,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
3144
3145
  const needsDepth = this.config.enforceGameDepth === true && this.stepsCompleted < 50;
3145
3146
  if (needsDepth) {
3146
3147
  this.gameGuardFired = true;
3147
- this.emitEvent({ type: 'status', message: '⚡ Sovereign Game Guard: Checking production depth...' });
3148
+ this.emitEvent({ type: 'status', message: '✦ Sovereign Game Guard: Checking production depth...' });
3148
3149
  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
3150
  this.messages.push({ role: 'system', content: guardMsg });
3150
3151
  this.memoryManager.saveHistory(this.messages);
@@ -3188,7 +3189,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
3188
3189
  event: 'anti_slop_notice', taskId: this.taskId,
3189
3190
  score: result.score, signals: result.findings.map((f) => f.id)
3190
3191
  });
3191
- this.emitEvent({ type: 'status', message: `⚡ Anti-Slop Audit: design scored ${result.score}` });
3192
+ this.emitEvent({ type: 'status', message: `✦ Anti-Slop Audit: design scored ${result.score}` });
3192
3193
  if (this.slopReviewAttempts >= 2 || auditHash === this.slopLastAuditHash) {
3193
3194
  this.emitEvent({ type: 'error', message: `Web design audit still found generic patterns (score ${result.score}); the result was not verified as complete.` });
3194
3195
  this.memoryManager.saveHistory(this.messages);
@@ -3267,7 +3268,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
3267
3268
  // The verification tools live in the web pack; make sure they are
3268
3269
  // actually in context before demanding the agent use them.
3269
3270
  this.unlockPack('web');
3270
- this.emitEvent({ type: 'status', message: '⚡ Anti-Slop Check: Visual/semantic verification recommended.' });
3271
+ this.emitEvent({ type: 'status', message: '✦ Anti-Slop Check: Visual/semantic verification recommended.' });
3271
3272
  this.messages.push({ role: 'system', content: webGuardMsg });
3272
3273
  this.memoryManager.saveHistory(this.messages);
3273
3274
  if (!this.webVerificationState.htmlInspected || browserReady || (hasVision && visionReady)) {
@@ -4074,7 +4075,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
4074
4075
  this.webVerificationState.browserActUsed = false;
4075
4076
  this.emitEvent({
4076
4077
  type: 'status',
4077
- message: `⚠️ Browser runtime error(s) detected: ${allRuntimeErrors[0]}`
4078
+ message: `△ Browser runtime error(s) detected: ${allRuntimeErrors[0]}`
4078
4079
  });
4079
4080
  this.messages.push({
4080
4081
  role: 'system',
@@ -4134,8 +4135,15 @@ You are operating in a text-and-code modality without direct image pixel renderi
4134
4135
  const eventResult = result?._is_image_marker
4135
4136
  ? { success: result.success !== false && !result.error, output: result.output || `Image captured: ${result.filename || 'image'} (${result.mimeType || 'image/png'})` }
4136
4137
  : result;
4137
- this.emitEvent({ type: result?.success === false || typeof result?.error === 'string' ? 'step_error' : 'step_complete',
4138
- tool: functionName, result: eventResult, toolCallId: toolCall.id });
4138
+ const isErrorOutcome = result?.success === false || typeof result?.error === 'string';
4139
+ const errorMsg = eventResult?.error || (typeof result?.error === 'string' ? result.error : undefined);
4140
+ this.emitEvent({
4141
+ type: isErrorOutcome ? 'step_error' : 'step_complete',
4142
+ tool: functionName,
4143
+ ...(isErrorOutcome && errorMsg ? { error: errorMsg } : {}),
4144
+ result: eventResult,
4145
+ toolCallId: toolCall.id
4146
+ });
4139
4147
  this.stepsCompleted++;
4140
4148
  if (this._implementationPlanSeeded && result?.success !== false && !result?.error && functionName !== 'update_plan') {
4141
4149
  this.advanceImplementationPlanProgress('mutation');
@@ -4199,7 +4207,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
4199
4207
  stepsCompleted: this.stepsCompleted,
4200
4208
  activeTier: this.activeTier,
4201
4209
  maxTierSteps: this.maxSteps,
4202
- 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)?`
4210
+ 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
4211
  },
4204
4212
  risk: 'info'
4205
4213
  });
@@ -4210,7 +4218,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
4210
4218
  break;
4211
4219
  }
4212
4220
  this.circuitBreakerUnlocked = true;
4213
- this.emitEvent({ type: 'status', message: `⚡ Circuit breaker unlocked! Resuming execution up to ${this.maxSteps} tier budget...` });
4221
+ this.emitEvent({ type: 'status', message: `✓ Circuit breaker unlocked! Resuming execution up to ${this.maxSteps} tier budget...` });
4214
4222
  }
4215
4223
  }
4216
4224
  // Sovereign Tier Budget Extension Checkpoint Gate
@@ -4229,7 +4237,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
4229
4237
  stepsCompleted: this.stepsCompleted,
4230
4238
  activeTier: this.activeTier,
4231
4239
  currentMaxSteps: this.maxSteps,
4232
- 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?`
4240
+ 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
4241
  },
4234
4242
  risk: 'info'
4235
4243
  });
@@ -4241,7 +4249,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
4241
4249
  }
4242
4250
  this.maxSteps += extensionBatch;
4243
4251
  this.maxCircuitBreaker = this.maxSteps;
4244
- this.emitEvent({ type: 'status', message: `⚡ Tier budget extended (+${extensionBatch} steps unlocked, new limit: ${this.maxSteps}). Resuming task...` });
4252
+ this.emitEvent({ type: 'status', message: `✓ Tier budget extended (+${extensionBatch} steps unlocked, new limit: ${this.maxSteps}). Resuming task...` });
4245
4253
  }
4246
4254
  }
4247
4255
  // SmartToolsUse tracks actual local tool calls, without denying
package/src/agentLoop.ts CHANGED
@@ -979,7 +979,7 @@ export class AgentLoop {
979
979
  try {
980
980
  const matches = await cortexDb.search(this.currentTaskPrompt, 2, { workspace: this.workspaceRoot });
981
981
  if (matches.length > 0 && matches[0]) {
982
- lessonsLearned = `\n\n🧠 DIGITAL BRAIN (LESSONS LEARNED FROM PAST MISTAKES):\n` + matches.map((m: any) => `- ${m.text}`).join('\n');
982
+ lessonsLearned = `\n\n◆ DIGITAL BRAIN (LESSONS LEARNED FROM PAST MISTAKES):\n` + matches.map((m: any) => `- ${m.text}`).join('\n');
983
983
  this._lessonSimilarity = matches[0].similarity || 0;
984
984
  this.debugLog(`cortex search hit: ${(this._lessonSimilarity * 100).toFixed(0)}% similarity`);
985
985
  }
@@ -1003,7 +1003,7 @@ export class AgentLoop {
1003
1003
  try {
1004
1004
  const recentPatterns = await cortexDb.getRecentCreativePatterns(5);
1005
1005
  if (recentPatterns.length > 0) {
1006
- antiRepeatDirective = `\n\n🎨 CREATIVE DIVERSITY (DO NOT REPEAT RECENT PATTERNS):\n` +
1006
+ antiRepeatDirective = `\n\n◆ CREATIVE DIVERSITY (DO NOT REPEAT RECENT PATTERNS):\n` +
1007
1007
  recentPatterns.map((p: any) => `- ${p}`).join('\n') +
1008
1008
  `\nChoose a DIFFERENT design approach, color palette, and font combination than the above.`;
1009
1009
  }
@@ -1267,7 +1267,8 @@ export class AgentLoop {
1267
1267
  if (hook?.denied) return false;
1268
1268
  const assessment = await coldObserver.evaluateMutation(tool, args, { workspaceRoot: this.workspaceRoot });
1269
1269
  if (assessment.veto) return false;
1270
- const needsApproval = uncertain || requiresToolApproval({
1270
+ const isModeC = (this.config.autonomyMode || 'C') === 'C';
1271
+ const needsApproval = (!isModeC && uncertain) || requiresToolApproval({
1271
1272
  mode: this.config.autonomyMode || 'C', tool, args,
1272
1273
  risk: assessment.requiresConfirmation ? 'dangerous' : validation.risk,
1273
1274
  heavyDownload: false, standingApproval: this.isAlwaysAllowed(tool)
@@ -2180,7 +2181,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
2180
2181
  Array.isArray(ctx.keyFiles) && ctx.keyFiles.length > 0 && `Key files: ${ctx.keyFiles.slice(0, 25).join(', ')}`
2181
2182
  ].filter(Boolean);
2182
2183
  if (facts.length > 0) {
2183
- workspaceSummary = `\n\n📂 WORKSPACE CONTEXT (already scanned for you — do NOT waste steps rediscovering this):\n${facts.join('\n')}`;
2184
+ workspaceSummary = `\n\n◆ WORKSPACE CONTEXT (already scanned for you — do NOT waste steps rediscovering this):\n${facts.join('\n')}`;
2184
2185
  }
2185
2186
  }
2186
2187
 
@@ -2294,7 +2295,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
2294
2295
  // here never invalidates the cached prefix in [1]-[3].
2295
2296
  {
2296
2297
  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🧠 PERSISTENT MEMORY (FACTS LEARNED ABOUT THE USER):\n${memoryContext}`
2298
+ 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
2299
  }
2299
2300
  ];
2300
2301
 
@@ -3304,7 +3305,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
3304
3305
 
3305
3306
  if (needsDepth) {
3306
3307
  this.gameGuardFired = true;
3307
- this.emitEvent({ type: 'status', message: '⚡ Sovereign Game Guard: Checking production depth...' });
3308
+ this.emitEvent({ type: 'status', message: '✦ Sovereign Game Guard: Checking production depth...' });
3308
3309
 
3309
3310
  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
3311
 
@@ -3351,7 +3352,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
3351
3352
  event: 'anti_slop_notice', taskId: this.taskId,
3352
3353
  score: result.score, signals: result.findings.map((f: any) => f.id)
3353
3354
  });
3354
- this.emitEvent({ type: 'status', message: `⚡ Anti-Slop Audit: design scored ${result.score}` });
3355
+ this.emitEvent({ type: 'status', message: `✦ Anti-Slop Audit: design scored ${result.score}` });
3355
3356
  if (this.slopReviewAttempts >= 2 || auditHash === this.slopLastAuditHash) {
3356
3357
  this.emitEvent({ type: 'error', message: `Web design audit still found generic patterns (score ${result.score}); the result was not verified as complete.` });
3357
3358
  this.memoryManager.saveHistory(this.messages);
@@ -3429,7 +3430,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
3429
3430
  // The verification tools live in the web pack; make sure they are
3430
3431
  // actually in context before demanding the agent use them.
3431
3432
  this.unlockPack('web');
3432
- this.emitEvent({ type: 'status', message: '⚡ Anti-Slop Check: Visual/semantic verification recommended.' });
3433
+ this.emitEvent({ type: 'status', message: '✦ Anti-Slop Check: Visual/semantic verification recommended.' });
3433
3434
  this.messages.push({ role: 'system', content: webGuardMsg });
3434
3435
  this.memoryManager.saveHistory(this.messages);
3435
3436
  if (!this.webVerificationState.htmlInspected || browserReady || (hasVision && visionReady)) {
@@ -4297,7 +4298,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
4297
4298
  this.webVerificationState.browserActUsed = false;
4298
4299
  this.emitEvent({
4299
4300
  type: 'status',
4300
- message: `⚠️ Browser runtime error(s) detected: ${allRuntimeErrors[0]}`
4301
+ message: `△ Browser runtime error(s) detected: ${allRuntimeErrors[0]}`
4301
4302
  });
4302
4303
  this.messages.push({
4303
4304
  role: 'system',
@@ -4361,8 +4362,15 @@ You are operating in a text-and-code modality without direct image pixel renderi
4361
4362
  const eventResult = result?._is_image_marker
4362
4363
  ? { success: result.success !== false && !result.error, output: result.output || `Image captured: ${result.filename || 'image'} (${result.mimeType || 'image/png'})` }
4363
4364
  : result;
4364
- this.emitEvent({ type: result?.success === false || typeof result?.error === 'string' ? 'step_error' : 'step_complete',
4365
- tool: functionName, result: eventResult, toolCallId: toolCall.id });
4365
+ const isErrorOutcome = result?.success === false || typeof result?.error === 'string';
4366
+ const errorMsg = eventResult?.error || (typeof result?.error === 'string' ? result.error : undefined);
4367
+ this.emitEvent({
4368
+ type: isErrorOutcome ? 'step_error' : 'step_complete',
4369
+ tool: functionName,
4370
+ ...(isErrorOutcome && errorMsg ? { error: errorMsg } : {}),
4371
+ result: eventResult,
4372
+ toolCallId: toolCall.id
4373
+ });
4366
4374
  this.stepsCompleted++;
4367
4375
  if (this._implementationPlanSeeded && result?.success !== false && !result?.error && functionName !== 'update_plan') {
4368
4376
  this.advanceImplementationPlanProgress('mutation');
@@ -4433,7 +4441,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
4433
4441
  stepsCompleted: this.stepsCompleted,
4434
4442
  activeTier: this.activeTier,
4435
4443
  maxTierSteps: this.maxSteps,
4436
- 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)?`
4444
+ 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
4445
  },
4438
4446
  risk: 'info'
4439
4447
  });
@@ -4445,7 +4453,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
4445
4453
  break;
4446
4454
  }
4447
4455
  this.circuitBreakerUnlocked = true;
4448
- this.emitEvent({ type: 'status', message: `⚡ Circuit breaker unlocked! Resuming execution up to ${this.maxSteps} tier budget...` });
4456
+ this.emitEvent({ type: 'status', message: `✓ Circuit breaker unlocked! Resuming execution up to ${this.maxSteps} tier budget...` });
4449
4457
  }
4450
4458
  }
4451
4459
 
@@ -4464,7 +4472,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
4464
4472
  stepsCompleted: this.stepsCompleted,
4465
4473
  activeTier: this.activeTier,
4466
4474
  currentMaxSteps: this.maxSteps,
4467
- 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?`
4475
+ 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
4476
  },
4469
4477
  risk: 'info'
4470
4478
  });
@@ -4477,7 +4485,7 @@ You are operating in a text-and-code modality without direct image pixel renderi
4477
4485
  }
4478
4486
  this.maxSteps += extensionBatch;
4479
4487
  this.maxCircuitBreaker = this.maxSteps;
4480
- this.emitEvent({ type: 'status', message: `⚡ Tier budget extended (+${extensionBatch} steps unlocked, new limit: ${this.maxSteps}). Resuming task...` });
4488
+ this.emitEvent({ type: 'status', message: `✓ Tier budget extended (+${extensionBatch} steps unlocked, new limit: ${this.maxSteps}). Resuming task...` });
4481
4489
  }
4482
4490
  }
4483
4491
 
@@ -38,6 +38,22 @@ export function isWholeFileDeletion(tool, args) {
38
38
  return command.length > 0
39
39
  && (WHOLE_FILE_DELETE.test(command) || DELETE_API_CALL.test(command) || NESTED_SHELL_DELETE.test(command));
40
40
  }
41
+ /** Routine browser verification inside the isolated agent browser (preview, snapshot, click, fill, screenshot, etc.) does not require HITL in Mode B or C unless uploading or downloading files. */
42
+ export function isRoutineBrowserVerification(tool, args) {
43
+ if (tool !== 'browser_act')
44
+ return false;
45
+ const actions = Array.isArray(args?.actions) ? args.actions : [];
46
+ if (actions.length === 0) {
47
+ const singleType = typeof args?.action === 'string' ? args.action : typeof args?.type === 'string' ? args.type : '';
48
+ return singleType !== 'download' && singleType !== 'upload';
49
+ }
50
+ return !actions.some(item => {
51
+ if (!item || typeof item !== 'object')
52
+ return false;
53
+ const type = String(item.type ?? item.action ?? '');
54
+ return type === 'download' || type === 'upload';
55
+ });
56
+ }
41
57
  /** Prompt policy only. Sandbox denial, workspace checks, and observer veto run separately. */
42
58
  export function requiresToolApproval(input) {
43
59
  if (input.mode === 'C') {
@@ -48,6 +64,9 @@ export function requiresToolApproval(input) {
48
64
  }
49
65
  if (input.standingApproval)
50
66
  return false;
67
+ if (input.mode !== 'A' && isRoutineBrowserVerification(input.tool, input.args)) {
68
+ return false;
69
+ }
51
70
  return input.risk === 'extreme'
52
71
  || input.heavyDownload
53
72
  || input.risk === 'dangerous'
@@ -51,6 +51,21 @@ export function isWholeFileDeletion(tool: string, args: Record<string, unknown>)
51
51
  && (WHOLE_FILE_DELETE.test(command) || DELETE_API_CALL.test(command) || NESTED_SHELL_DELETE.test(command));
52
52
  }
53
53
 
54
+ /** Routine browser verification inside the isolated agent browser (preview, snapshot, click, fill, screenshot, etc.) does not require HITL in Mode B or C unless uploading or downloading files. */
55
+ export function isRoutineBrowserVerification(tool: string, args: Record<string, unknown>): boolean {
56
+ if (tool !== 'browser_act') return false;
57
+ const actions = Array.isArray(args?.actions) ? args.actions : [];
58
+ if (actions.length === 0) {
59
+ const singleType = typeof args?.action === 'string' ? args.action : typeof args?.type === 'string' ? args.type : '';
60
+ return singleType !== 'download' && singleType !== 'upload';
61
+ }
62
+ return !actions.some(item => {
63
+ if (!item || typeof item !== 'object') return false;
64
+ const type = String((item as { type?: unknown; action?: unknown }).type ?? (item as { action?: unknown }).action ?? '');
65
+ return type === 'download' || type === 'upload';
66
+ });
67
+ }
68
+
54
69
  /** Prompt policy only. Sandbox denial, workspace checks, and observer veto run separately. */
55
70
  export function requiresToolApproval(input: ToolApprovalInput): boolean {
56
71
  if (input.mode === 'C') {
@@ -59,6 +74,9 @@ export function requiresToolApproval(input: ToolApprovalInput): boolean {
59
74
  return input.tool !== 'fs_delete' || !input.standingApproval;
60
75
  }
61
76
  if (input.standingApproval) return false;
77
+ if (input.mode !== 'A' && isRoutineBrowserVerification(input.tool, input.args)) {
78
+ return false;
79
+ }
62
80
  return input.risk === 'extreme'
63
81
  || input.heavyDownload
64
82
  || input.risk === 'dangerous'
@@ -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 = 10 * 60_000;
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;
@@ -670,6 +670,7 @@ export class CausyneBrowser {
670
670
  securedPages = new WeakSet();
671
671
  pageStates = new WeakMap();
672
672
  contextRouteInstalled = false;
673
+ lastTarget = null;
673
674
  constructor(options = {}) {
674
675
  this.workspace = path.resolve(options.workspace ?? process.cwd());
675
676
  this.ensureBrowserCapability = options.ensureBrowserCapability ?? (() => ensureCapability('browser'));
@@ -681,8 +682,10 @@ export class CausyneBrowser {
681
682
  }
682
683
  setWorkspace(workspace) {
683
684
  if (workspace && typeof workspace === 'string') {
684
- if (this.workspace !== path.resolve(workspace))
685
+ if (this.workspace !== path.resolve(workspace)) {
685
686
  this.workspacePreview.clear();
687
+ this.lastTarget = null;
688
+ }
686
689
  this.workspace = path.resolve(workspace);
687
690
  }
688
691
  }
@@ -745,6 +748,7 @@ export class CausyneBrowser {
745
748
  async snapshot(offset = 0) {
746
749
  await this.start();
747
750
  const state = await this.activeTab();
751
+ await this.restoreLastTargetIfBlank(state);
748
752
  await this.captureSnapshotState(state);
749
753
  return {
750
754
  ...windowSnapshot(state.lastSnapshot, offset),
@@ -1102,6 +1106,7 @@ export class CausyneBrowser {
1102
1106
  state.refs.clear();
1103
1107
  state.lastSnapshot = '';
1104
1108
  state.lastStructure = null;
1109
+ this.lastTarget = { kind: 'url', url: state.page.url() };
1105
1110
  }
1106
1111
  async preview(state, filePath, workspace) {
1107
1112
  state.runtimeErrors = [];
@@ -1113,6 +1118,28 @@ export class CausyneBrowser {
1113
1118
  state.refs.clear();
1114
1119
  state.lastSnapshot = '';
1115
1120
  state.lastStructure = null;
1121
+ this.lastTarget = { kind: 'preview', workspace, filePath };
1122
+ }
1123
+ async restoreLastTargetIfBlank(state) {
1124
+ if (!this.lastTarget)
1125
+ return false;
1126
+ const currentUrl = state.page.url();
1127
+ if (currentUrl && currentUrl !== 'about:blank')
1128
+ return false;
1129
+ const target = this.lastTarget;
1130
+ try {
1131
+ if (target.kind === 'preview') {
1132
+ await this.preview(state, target.filePath, target.workspace);
1133
+ }
1134
+ else {
1135
+ await this.navigate(state, target.url);
1136
+ }
1137
+ await this.captureSnapshotState(state);
1138
+ return true;
1139
+ }
1140
+ catch {
1141
+ return false;
1142
+ }
1116
1143
  }
1117
1144
  async navigateWithMacroFallback(state, action) {
1118
1145
  const { targetUrl, macroName, macroQuery } = this.resolveTargetUrl(action);
@@ -1178,8 +1205,11 @@ export class CausyneBrowser {
1178
1205
  const refId = action.ref ?? (action.index !== undefined ? `e${action.index}` : undefined);
1179
1206
  if (refId) {
1180
1207
  let ref = state.refs.get(refId);
1181
- if (!ref && state.refs.size === 0) {
1182
- await this.captureSnapshotState(state).catch(() => { });
1208
+ if (!ref) {
1209
+ await this.restoreLastTargetIfBlank(state);
1210
+ if (!state.refs.has(refId)) {
1211
+ await this.captureSnapshotState(state).catch(() => { });
1212
+ }
1183
1213
  ref = state.refs.get(refId);
1184
1214
  }
1185
1215
  if (!ref)
@@ -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 = 10 * 60_000;
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;
@@ -936,6 +936,7 @@ export class CausyneBrowser {
936
936
  private securedPages = new WeakSet<object>();
937
937
  private pageStates = new WeakMap<object, TabState>();
938
938
  private contextRouteInstalled = false;
939
+ private lastTarget: { kind: 'preview'; workspace: string; filePath: string } | { kind: 'url'; url: string } | null = null;
939
940
 
940
941
  constructor(options: RuntimeOptions = {}) {
941
942
  this.workspace = path.resolve(options.workspace ?? process.cwd());
@@ -949,7 +950,10 @@ export class CausyneBrowser {
949
950
 
950
951
  setWorkspace(workspace: string): void {
951
952
  if (workspace && typeof workspace === 'string') {
952
- if (this.workspace !== path.resolve(workspace)) this.workspacePreview.clear();
953
+ if (this.workspace !== path.resolve(workspace)) {
954
+ this.workspacePreview.clear();
955
+ this.lastTarget = null;
956
+ }
953
957
  this.workspace = path.resolve(workspace);
954
958
  }
955
959
  }
@@ -1012,6 +1016,7 @@ export class CausyneBrowser {
1012
1016
  async snapshot(offset = 0): Promise<SnapshotWindow & { tabId: string; url: string; title: string; refsCount: number; structure?: PageStructure | null }> {
1013
1017
  await this.start();
1014
1018
  const state = await this.activeTab();
1019
+ await this.restoreLastTargetIfBlank(state);
1015
1020
  await this.captureSnapshotState(state);
1016
1021
  return {
1017
1022
  ...windowSnapshot(state.lastSnapshot, offset),
@@ -1342,6 +1347,7 @@ export class CausyneBrowser {
1342
1347
  state.refs.clear();
1343
1348
  state.lastSnapshot = '';
1344
1349
  state.lastStructure = null;
1350
+ this.lastTarget = { kind: 'url', url: state.page.url() };
1345
1351
  }
1346
1352
 
1347
1353
  private async preview(state: TabState, filePath: string, workspace: string): Promise<void> {
@@ -1353,6 +1359,25 @@ export class CausyneBrowser {
1353
1359
  state.refs.clear();
1354
1360
  state.lastSnapshot = '';
1355
1361
  state.lastStructure = null;
1362
+ this.lastTarget = { kind: 'preview', workspace, filePath };
1363
+ }
1364
+
1365
+ private async restoreLastTargetIfBlank(state: TabState): Promise<boolean> {
1366
+ if (!this.lastTarget) return false;
1367
+ const currentUrl = state.page.url();
1368
+ if (currentUrl && currentUrl !== 'about:blank') return false;
1369
+ const target = this.lastTarget;
1370
+ try {
1371
+ if (target.kind === 'preview') {
1372
+ await this.preview(state, target.filePath, target.workspace);
1373
+ } else {
1374
+ await this.navigate(state, target.url);
1375
+ }
1376
+ await this.captureSnapshotState(state);
1377
+ return true;
1378
+ } catch {
1379
+ return false;
1380
+ }
1356
1381
  }
1357
1382
 
1358
1383
  private async navigateWithMacroFallback(state: TabState, action: BrowserAction): Promise<void> {
@@ -1414,8 +1439,11 @@ export class CausyneBrowser {
1414
1439
  const refId = action.ref ?? (action.index !== undefined ? `e${action.index}` : undefined);
1415
1440
  if (refId) {
1416
1441
  let ref = state.refs.get(refId);
1417
- if (!ref && state.refs.size === 0) {
1418
- await this.captureSnapshotState(state).catch(() => {});
1442
+ if (!ref) {
1443
+ await this.restoreLastTargetIfBlank(state);
1444
+ if (!state.refs.has(refId)) {
1445
+ await this.captureSnapshotState(state).catch(() => {});
1446
+ }
1419
1447
  ref = state.refs.get(refId);
1420
1448
  }
1421
1449
  if (!ref) throw new Error(`Unknown element ref ${refId}. Take a new snapshot before interacting.`);
package/src/cliMode.js CHANGED
@@ -90,34 +90,9 @@ function makeApprovalHandler(conn, dialogs = null) {
90
90
  // and a scrollable diff in one frame. The plain fallback asks the same
91
91
  // question in the scrollback, which is all a non-TTY session can do.
92
92
  if (dialogs && detail) {
93
- // Loops only for "Allow always" → Cancel: backing out of the standing
94
- // grant returns you to the question, it does not silently deny the call.
95
- // Every other path returns on the first pass.
96
- let approved = false;
97
- let scope = 'reject';
98
-
99
- for (;;) {
100
- const answer = await dialogs.approve(detail);
101
- approved = Boolean(answer && answer.approved);
102
- scope = (answer && answer.scope) || 'reject';
103
-
104
- if (scope !== 'always') break;
105
-
106
- // A SECOND, EXPLICIT CONFIRMATION — the same shape opencode uses, and
107
- // for the same reason: a standing grant is a much larger thing than
108
- // approving one call, so it must not be reachable by one keystroke.
109
- // The text says exactly what is being given up and for how long.
110
- const confirmed = await dialogs.confirm(
111
- `Allow ${bold(detail.tool)} to run WITHOUT asking, for the rest of this session?\n`
112
- + ` This lasts until Causyne restarts. Undo it any time with /approvals clear.`,
113
- // Reaching this question already required moving onto Allow always
114
- // and pressing Enter. A second Enter is therefore an explicit second
115
- // confirmation, rather than a reflex approval on the first dialog.
116
- { defaultAnswer: true }
117
- );
118
- if (confirmed) break;
119
- // Cancelled: ask again rather than denying something they never rejected.
120
- }
93
+ const answer = await dialogs.approve(detail);
94
+ const approved = Boolean(answer && answer.approved);
95
+ const scope = (answer && answer.scope) || 'reject';
121
96
 
122
97
  if (approved && scope === 'always') {
123
98
  grantAlways(detail.tool);
@@ -497,12 +472,66 @@ export async function chatMode({ home = false } = {}) {
497
472
 
498
473
  // surfaces, and the text form remains the fallback rather than a
499
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
+
500
500
  if (commandResult.effect === 'pick-skill' && prompt) {
501
- // Picking a skill puts it on the input line rather than running it
502
- // straight away, so the user can add what they want done with it. That
503
- // is the difference between a launcher and a document viewer.
504
- prompt.browseSkills(commandResult.items, (skill) => {
505
- prompt.setText(`/skills ${skill.domain}/${skill.id} `);
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();
506
535
  });
507
536
  continue;
508
537
  }
@@ -551,6 +580,7 @@ export async function chatMode({ home = false } = {}) {
551
580
  // a working method the agent follows rather than a document it shows you.
552
581
  if (commandResult.effect === 'invoke-skill') {
553
582
  loop.activeSkill = commandResult.skill;
583
+ if (surface) surface.setSessionInfo({ activeSkill: loop.activeSkill });
554
584
  conn.renderer.skillInvoked(commandResult.skill.id, commandResult.instruction);
555
585
  task = commandResult.instruction
556
586
  || `Apply the ${commandResult.skill.id} skill to the current workspace.`;
@@ -614,9 +644,8 @@ export async function chatMode({ home = false } = {}) {
614
644
  if (prompt) prompt.setBusy(false);
615
645
  }
616
646
  conn.stopSpinner();
617
- // One turn, one skill: an invocation must not silently steer every later
618
- // message in the session.
619
- loop.activeSkill = null;
647
+ // Active skill remains persistent across turns until explicitly cleared via /skill clear or another skill is selected.
648
+ if (surface) surface.setSessionInfo({ activeSkill: loop.activeSkill });
620
649
  conn.renderer.turnFooter(Date.now() - startedAt);
621
650
  }
622
651