ft-scout 9.5.6 → 9.5.8

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 (33) hide show
  1. package/README.md +1 -1
  2. package/bin/src/commands/benchmark.d.ts +1 -1
  3. package/bin/src/commands/benchmark.js +4 -1
  4. package/bin/src/commands/replay.d.ts +6 -0
  5. package/bin/src/commands/replay.js +64 -0
  6. package/bin/src/engine/agentEngine.d.ts +2 -0
  7. package/bin/src/engine/agentEngine.js +409 -55
  8. package/bin/src/engine/browser/actions/actionEngine.js +1 -1
  9. package/bin/src/engine/browser/observer/browserObserver.js +1 -1
  10. package/bin/src/engine/checkpoints/checkpointManager.js +9 -0
  11. package/bin/src/engine/computer/computerController.d.ts +8 -2
  12. package/bin/src/engine/computer/computerController.js +172 -38
  13. package/bin/src/engine/computer/mockComputer.d.ts +1 -1
  14. package/bin/src/engine/computer/mockComputer.js +1 -1
  15. package/bin/src/engine/computer/scoutDriver.cs +310 -63
  16. package/bin/src/engine/llm.js +37 -17
  17. package/bin/src/engine/models/harpProvider.js +48 -0
  18. package/bin/src/engine/production/taskReplay.d.ts +24 -5
  19. package/bin/src/engine/production/taskReplay.js +158 -11
  20. package/bin/src/engine/runtime/agentRuntime.js +35 -7
  21. package/bin/src/engine/tools/domainHandlers.js +44 -7
  22. package/bin/src/engine/workspace/agentWorkspace.js +11 -2
  23. package/bin/src/index.js +17 -6
  24. package/bin/src/mcp/client.js +1 -1
  25. package/bin/src/server/server.js +57 -18
  26. package/bin/src/utils/branding.js +1 -1
  27. package/bin/src/utils/claudeUI.d.ts +10 -1
  28. package/bin/src/utils/claudeUI.js +136 -6
  29. package/bin/src/utils/config.d.ts +9 -0
  30. package/bin/src/utils/config.js +39 -1
  31. package/bin/src/utils/qrBridge.js +1 -1
  32. package/bin/src/utils/support.js +1 -1
  33. package/package.json +1 -1
@@ -1,4 +1,12 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import dotenv from 'dotenv';
1
5
  import {} from './types.js';
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+ dotenv.config({ path: path.resolve(__dirname, '../../../../.env'), quiet: true });
9
+ dotenv.config({ quiet: true });
2
10
  export class HarpReasoningProvider {
3
11
  providerName = 'harp';
4
12
  defaultModel = 'harp-1b-instruct';
@@ -27,6 +35,46 @@ export class HarpReasoningProvider {
27
35
  finishReason: (rawRes.toolCalls && rawRes.toolCalls.length > 0) ? 'tool_calls' : 'stop',
28
36
  };
29
37
  }
38
+ // Live FrontTerrain HARP Neural Inference API (when available and not in synthetic tool-matching mode)
39
+ const endpointUrl = process.env.HARP_API_URL;
40
+ if (endpointUrl && (!request.tools || request.tools.length === 0)) {
41
+ try {
42
+ const response = await fetch(endpointUrl, {
43
+ method: 'POST',
44
+ headers: { 'Content-Type': 'application/json' },
45
+ body: JSON.stringify({
46
+ model: activeModel,
47
+ messages: request.messages,
48
+ max_tokens: 1024,
49
+ }),
50
+ });
51
+ if (response.ok) {
52
+ const data = await response.json();
53
+ const choice = data.choices?.[0]?.message;
54
+ if (choice) {
55
+ const content = choice.content || '';
56
+ const latencyMs = Date.now() - startTime;
57
+ return {
58
+ thought: `HARP-1B analyzed task objective and completed live neural inference.`,
59
+ content,
60
+ toolCalls: [],
61
+ model: activeModel,
62
+ provider: this.providerName,
63
+ usage: data.usage || {
64
+ promptTokens: this.estimateTokens(request.messages),
65
+ completionTokens: this.estimateTokens([{ role: 'assistant', content }]),
66
+ totalTokens: this.estimateTokens(request.messages) + this.estimateTokens([{ role: 'assistant', content }]),
67
+ },
68
+ latencyMs,
69
+ finishReason: 'stop',
70
+ };
71
+ }
72
+ }
73
+ }
74
+ catch {
75
+ // Fall back gracefully to structured generator
76
+ }
77
+ }
30
78
  // Native HARP inference engine simulation / structured generator
31
79
  const latencyMs = Date.now() - startTime;
32
80
  const lastMsg = request.messages[request.messages.length - 1]?.content || '';
@@ -7,6 +7,7 @@ export interface ReplayStep {
7
7
  observationAfter?: any | undefined;
8
8
  result: any;
9
9
  success: boolean;
10
+ error?: string | undefined;
10
11
  durationMs: number;
11
12
  timestamp: string;
12
13
  }
@@ -20,18 +21,36 @@ export interface TaskReplayTrace {
20
21
  totalDurationMs: number;
21
22
  metadata?: Record<string, any> | undefined;
22
23
  }
24
+ export interface ReplayStepResult {
25
+ stepIndex: number;
26
+ action: string;
27
+ tool?: string | undefined;
28
+ success: boolean;
29
+ error?: string | undefined;
30
+ durationMs: number;
31
+ }
32
+ export interface ReplayExecutionResult {
33
+ totalReplayed: number;
34
+ matches: number;
35
+ failures: number;
36
+ stepResults: ReplayStepResult[];
37
+ durationMs: number;
38
+ }
23
39
  export declare class TaskReplayManager {
24
40
  private traces;
41
+ private storageDir;
42
+ constructor(storageDir?: string);
43
+ private ensureStorageDir;
25
44
  startTrace(taskId: string, objective: string, metadata?: Record<string, any> | undefined): TaskReplayTrace;
26
45
  recordStep(taskId: string, step: Omit<ReplayStep, 'timestamp'>): void;
27
46
  finalizeTrace(taskId: string, status: TaskReplayTrace['finalStatus']): TaskReplayTrace | undefined;
28
47
  getTrace(taskId: string): TaskReplayTrace | undefined;
29
48
  exportTraceJson(taskId: string): string;
30
49
  importTraceJson(jsonContent: string): TaskReplayTrace;
31
- replay(taskId: string, stepExecutor?: (step: ReplayStep) => Promise<boolean>): Promise<{
32
- totalReplayed: number;
33
- matches: number;
34
- failures: number;
35
- }>;
50
+ saveTraceToDisk(taskId: string, customDir?: string): string;
51
+ loadTraceFromDisk(taskId: string, customDir?: string): TaskReplayTrace | undefined;
52
+ listDiskTraces(customDir?: string): string[];
53
+ replay(taskId: string, stepExecutor?: (step: ReplayStep) => Promise<boolean>): Promise<ReplayExecutionResult>;
36
54
  }
55
+ export declare const defaultTaskReplayManager: TaskReplayManager;
37
56
  //# sourceMappingURL=taskReplay.d.ts.map
@@ -1,5 +1,30 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import os from 'os';
1
4
  export class TaskReplayManager {
2
5
  traces = new Map();
6
+ storageDir;
7
+ constructor(storageDir) {
8
+ this.storageDir = storageDir || path.resolve(process.cwd(), '.ft', 'traces');
9
+ }
10
+ ensureStorageDir() {
11
+ try {
12
+ if (!fs.existsSync(this.storageDir)) {
13
+ fs.mkdirSync(this.storageDir, { recursive: true });
14
+ }
15
+ if (process.platform === 'win32') {
16
+ try {
17
+ const { execSync } = require('child_process');
18
+ const rootFt = path.resolve(this.storageDir, '..');
19
+ if (path.basename(rootFt) === '.ft' && fs.existsSync(rootFt)) {
20
+ execSync(`attrib +h "${rootFt}"`, { windowsHide: true, stdio: 'ignore' });
21
+ }
22
+ }
23
+ catch { }
24
+ }
25
+ }
26
+ catch { }
27
+ }
3
28
  startTrace(taskId, objective, metadata) {
4
29
  const trace = {
5
30
  taskId,
@@ -14,60 +39,179 @@ export class TaskReplayManager {
14
39
  return trace;
15
40
  }
16
41
  recordStep(taskId, step) {
17
- const trace = this.traces.get(taskId);
18
- if (!trace)
19
- return;
42
+ let trace = this.traces.get(taskId);
43
+ if (!trace) {
44
+ // Attempt to restore from disk if trace was started earlier
45
+ trace = this.loadTraceFromDisk(taskId);
46
+ if (!trace) {
47
+ // Auto-create trace container if recording directly
48
+ trace = this.startTrace(taskId, `Task ${taskId}`);
49
+ }
50
+ }
20
51
  trace.steps.push({
21
52
  ...step,
22
53
  timestamp: new Date().toISOString(),
23
54
  });
24
55
  }
25
56
  finalizeTrace(taskId, status) {
26
- const trace = this.traces.get(taskId);
57
+ const trace = this.traces.get(taskId) || this.loadTraceFromDisk(taskId);
27
58
  if (!trace)
28
59
  return undefined;
29
60
  trace.endTime = new Date().toISOString();
30
61
  trace.finalStatus = status;
31
62
  trace.totalDurationMs = Date.now() - new Date(trace.startTime).getTime();
63
+ // Automatically persist finalized trace to disk
64
+ try {
65
+ this.saveTraceToDisk(taskId);
66
+ }
67
+ catch { }
32
68
  return trace;
33
69
  }
34
70
  getTrace(taskId) {
35
- return this.traces.get(taskId);
71
+ let trace = this.traces.get(taskId);
72
+ if (!trace) {
73
+ trace = this.loadTraceFromDisk(taskId);
74
+ }
75
+ return trace;
36
76
  }
37
77
  exportTraceJson(taskId) {
38
- const trace = this.traces.get(taskId);
78
+ const trace = this.getTrace(taskId);
39
79
  if (!trace)
40
80
  throw new Error(`Trace not found for task ${taskId}`);
41
81
  return JSON.stringify(trace, null, 2);
42
82
  }
43
83
  importTraceJson(jsonContent) {
44
84
  const trace = JSON.parse(jsonContent);
85
+ if (!trace || !trace.taskId) {
86
+ throw new Error('Invalid trace JSON payload: missing taskId');
87
+ }
45
88
  this.traces.set(trace.taskId, trace);
46
89
  return trace;
47
90
  }
91
+ saveTraceToDisk(taskId, customDir) {
92
+ const trace = this.getTrace(taskId);
93
+ if (!trace)
94
+ throw new Error(`Trace not found for task ${taskId}`);
95
+ const dir = customDir || this.storageDir;
96
+ if (!fs.existsSync(dir)) {
97
+ fs.mkdirSync(dir, { recursive: true });
98
+ }
99
+ const filePath = path.join(dir, `${taskId}.json`);
100
+ fs.writeFileSync(filePath, JSON.stringify(trace, null, 2), 'utf-8');
101
+ return filePath;
102
+ }
103
+ loadTraceFromDisk(taskId, customDir) {
104
+ const dir = customDir || this.storageDir;
105
+ const filePath = path.join(dir, `${taskId}.json`);
106
+ if (!fs.existsSync(filePath)) {
107
+ // Also check global fallback ~/.ft/traces
108
+ const globalFilePath = path.join(os.homedir(), '.ft', 'traces', `${taskId}.json`);
109
+ if (fs.existsSync(globalFilePath)) {
110
+ try {
111
+ const content = fs.readFileSync(globalFilePath, 'utf-8');
112
+ const trace = JSON.parse(content);
113
+ this.traces.set(trace.taskId, trace);
114
+ return trace;
115
+ }
116
+ catch { }
117
+ }
118
+ return undefined;
119
+ }
120
+ try {
121
+ const content = fs.readFileSync(filePath, 'utf-8');
122
+ const trace = JSON.parse(content);
123
+ this.traces.set(trace.taskId, trace);
124
+ return trace;
125
+ }
126
+ catch {
127
+ return undefined;
128
+ }
129
+ }
130
+ listDiskTraces(customDir) {
131
+ const dir = customDir || this.storageDir;
132
+ if (!fs.existsSync(dir))
133
+ return [];
134
+ try {
135
+ return fs.readdirSync(dir)
136
+ .filter(f => f.endsWith('.json'))
137
+ .map(f => f.replace(/\.json$/, ''));
138
+ }
139
+ catch {
140
+ return [];
141
+ }
142
+ }
48
143
  async replay(taskId, stepExecutor) {
49
- const trace = this.traces.get(taskId);
144
+ const trace = this.getTrace(taskId);
50
145
  if (!trace)
51
146
  throw new Error(`Trace not found for task ${taskId}`);
147
+ const startTime = Date.now();
52
148
  let matches = 0;
53
149
  let failures = 0;
150
+ const stepResults = [];
54
151
  for (const step of trace.steps) {
152
+ const stepStartTime = Date.now();
55
153
  if (stepExecutor) {
56
- const ok = await stepExecutor(step);
57
- if (ok) {
58
- matches++;
154
+ try {
155
+ const ok = await stepExecutor(step);
156
+ const durationMs = Date.now() - stepStartTime;
157
+ if (ok) {
158
+ matches++;
159
+ stepResults.push({
160
+ stepIndex: step.stepIndex,
161
+ action: step.action,
162
+ tool: step.tool,
163
+ success: true,
164
+ durationMs,
165
+ });
166
+ }
167
+ else {
168
+ failures++;
169
+ stepResults.push({
170
+ stepIndex: step.stepIndex,
171
+ action: step.action,
172
+ tool: step.tool,
173
+ success: false,
174
+ error: 'Step executor returned false (verification failed)',
175
+ durationMs,
176
+ });
177
+ }
59
178
  }
60
- else {
179
+ catch (err) {
180
+ const durationMs = Date.now() - stepStartTime;
61
181
  failures++;
182
+ stepResults.push({
183
+ stepIndex: step.stepIndex,
184
+ action: step.action,
185
+ tool: step.tool,
186
+ success: false,
187
+ error: err?.message || String(err),
188
+ durationMs,
189
+ });
62
190
  }
63
191
  }
64
192
  else {
65
193
  // Deterministic verification against recorded success
194
+ const durationMs = step.durationMs || 0;
66
195
  if (step.success) {
67
196
  matches++;
197
+ stepResults.push({
198
+ stepIndex: step.stepIndex,
199
+ action: step.action,
200
+ tool: step.tool,
201
+ success: true,
202
+ durationMs,
203
+ });
68
204
  }
69
205
  else {
70
206
  failures++;
207
+ stepResults.push({
208
+ stepIndex: step.stepIndex,
209
+ action: step.action,
210
+ tool: step.tool,
211
+ success: false,
212
+ error: step.error || 'Recorded step was unsuccessful',
213
+ durationMs,
214
+ });
71
215
  }
72
216
  }
73
217
  }
@@ -75,7 +219,10 @@ export class TaskReplayManager {
75
219
  totalReplayed: trace.steps.length,
76
220
  matches,
77
221
  failures,
222
+ stepResults,
223
+ durationMs: Date.now() - startTime,
78
224
  };
79
225
  }
80
226
  }
227
+ export const defaultTaskReplayManager = new TaskReplayManager();
81
228
  //# sourceMappingURL=taskReplay.js.map
@@ -20,7 +20,7 @@ import { robustSnippetReplace, buildDirectoryTree } from '../agentEngine.js';
20
20
  import { loadAuthConfig, isProOrHigher } from '../../utils/auth.js';
21
21
  import { getMCPManager } from '../../mcp/index.js';
22
22
  import { compress, LEVEL_FAST } from 'codrop';
23
- import { renderStepHeader, renderThoughtBox, renderToolCall, renderToolResult, renderTaskCompletedCard, } from '../../utils/claudeUI.js';
23
+ import { renderStepHeader, renderThoughtBox, renderToolCall, renderToolResult, renderTaskCompletedCard, getActionFriendlyDescription, } from '../../utils/claudeUI.js';
24
24
  import { loadWorkspaceRules } from '../../utils/rules.js';
25
25
  import { InterruptManager } from '../../utils/interruptHandler.js';
26
26
  export class AgentRuntime {
@@ -492,9 +492,21 @@ Action Rules:
492
492
  }
493
493
  const msg = sanitizeMessage(choice.message);
494
494
  this.historyMessages.push(msg);
495
- if (msg.content && msg.content.trim()) {
496
- renderThoughtBox(msg.content, step);
495
+ let fallbackDesc;
496
+ if (msg.tool_calls && msg.tool_calls.length > 0) {
497
+ const firstTc = msg.tool_calls[0];
498
+ if (firstTc?.function?.name) {
499
+ let callArgs = {};
500
+ try {
501
+ callArgs = JSON.parse(firstTc.function.arguments || '{}');
502
+ }
503
+ catch { }
504
+ fallbackDesc = getActionFriendlyDescription(firstTc.function.name, callArgs);
505
+ }
497
506
  }
507
+ const rawReasoning = choice.message?.reasoning_content || choice.message?.thinking || choice.message?.thought || '';
508
+ const combinedReasoning = rawReasoning ? `${rawReasoning}\n${msg.content || ''}` : (msg.content || '');
509
+ renderThoughtBox(combinedReasoning, step, fallbackDesc);
498
510
  let toolCallsToExecute = [];
499
511
  if (msg.tool_calls && msg.tool_calls.length > 0) {
500
512
  for (const tc of msg.tool_calls) {
@@ -1320,6 +1332,7 @@ Action Rules:
1320
1332
  fs.mkdirSync(path.dirname(fullPath), { recursive: true });
1321
1333
  fs.writeFileSync(fullPath, content, 'utf-8');
1322
1334
  this.modifiedFiles.add(targetPath);
1335
+ this.readFilesHistory.delete(targetPath);
1323
1336
  this.workspace.recordArtifact({
1324
1337
  filename: path.basename(targetPath),
1325
1338
  path: targetPath,
@@ -1331,17 +1344,26 @@ Action Rules:
1331
1344
  return { result: `Successfully wrote file "${targetPath}".` };
1332
1345
  }
1333
1346
  case 'edit_file': {
1334
- const targetPath = String(args.path || '').trim();
1347
+ const targetPath = String(args.path || args.filePath || args.file || '').trim();
1348
+ let target = String(args.target ?? args.old_string ?? args.old_str ?? args.oldText ?? args.find ?? args.search ?? '');
1349
+ let replacement = String(args.replacement ?? args.new_string ?? args.new_str ?? args.newText ?? args.replace ?? '');
1350
+ if (replacement.includes('\\n') && !replacement.includes('\n')) {
1351
+ replacement = replacement.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
1352
+ }
1353
+ if (target.includes('\\n') && !target.includes('\n')) {
1354
+ target = target.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
1355
+ }
1335
1356
  const fullPath = path.isAbsolute(targetPath) ? targetPath : path.resolve(this.cwd, targetPath);
1336
1357
  if (!fs.existsSync(fullPath))
1337
1358
  return { result: `Error: File "${targetPath}" does not exist.` };
1338
1359
  const currentContent = fs.readFileSync(fullPath, 'utf-8');
1339
- const replaceRes = robustSnippetReplace(currentContent, args.target, args.replacement);
1360
+ const replaceRes = robustSnippetReplace(currentContent, target, replacement);
1340
1361
  if (!replaceRes.success) {
1341
1362
  return { result: `Error: ${replaceRes.error}` };
1342
1363
  }
1343
1364
  fs.writeFileSync(fullPath, replaceRes.updatedContent, 'utf-8');
1344
1365
  this.modifiedFiles.add(targetPath);
1366
+ this.readFilesHistory.delete(targetPath);
1345
1367
  this.workspace.addObservation({ tool: name, resultSummary: `Edited file ${targetPath}`, verified: true, target: targetPath });
1346
1368
  return { result: `Successfully updated "${targetPath}".` };
1347
1369
  }
@@ -1405,7 +1427,7 @@ Action Rules:
1405
1427
  };
1406
1428
  }
1407
1429
  case 'multi_edit_file': {
1408
- const targetPath = String(args.path || '').trim();
1430
+ const targetPath = String(args.path || args.filePath || args.file || '').trim();
1409
1431
  const edits = Array.isArray(args.edits) ? args.edits : [];
1410
1432
  const fullPath = path.isAbsolute(targetPath) ? targetPath : path.resolve(this.cwd, targetPath);
1411
1433
  if (!fs.existsSync(fullPath))
@@ -1413,7 +1435,13 @@ Action Rules:
1413
1435
  let content = fs.readFileSync(fullPath, 'utf-8');
1414
1436
  let count = 0;
1415
1437
  for (const ed of edits) {
1416
- const res = robustSnippetReplace(content, ed.target, ed.replacement);
1438
+ let target = String(ed.target ?? ed.old_string ?? ed.old_str ?? ed.oldText ?? ed.find ?? ed.search ?? '');
1439
+ let replacement = String(ed.replacement ?? ed.new_string ?? ed.new_str ?? ed.newText ?? ed.replace ?? '');
1440
+ if (target.includes('\\n') && !target.includes('\n'))
1441
+ target = target.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
1442
+ if (replacement.includes('\\n') && !replacement.includes('\n'))
1443
+ replacement = replacement.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
1444
+ const res = robustSnippetReplace(content, target, replacement);
1417
1445
  if (res.success) {
1418
1446
  content = res.updatedContent;
1419
1447
  count++;
@@ -6,6 +6,7 @@ import {} from './types.js';
6
6
  import {} from '../browser/actions/types.js';
7
7
  import {} from '../browser/observer/browserObserver.js';
8
8
  import {} from '../computer/computerController.js';
9
+ import { robustSnippetReplace } from '../agentEngine.js';
9
10
  const execAsync = promisify(exec);
10
11
  // ============================================================================
11
12
  // 1. Browser Domain Handler
@@ -308,16 +309,52 @@ export class FilesystemHandler {
308
309
  throw new Error(`File not found for editing: ${resolvedPath}`);
309
310
  }
310
311
  let content = await fs.promises.readFile(resolvedPath, 'utf-8');
311
- const target = args.target;
312
- const replacement = args.replacement ?? '';
313
- if (typeof target === 'string') {
314
- if (!content.includes(target)) {
315
- throw new Error(`Target text to replace not found in ${resolvedPath}`);
312
+ let target = String(args.target ?? args.old_string ?? args.old_str ?? args.oldText ?? args.find ?? args.search ?? '');
313
+ let replacement = String(args.replacement ?? args.new_string ?? args.new_str ?? args.newText ?? args.replace ?? '');
314
+ if (target.includes('\\n') && !target.includes('\n'))
315
+ target = target.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
316
+ if (replacement.includes('\\n') && !replacement.includes('\n'))
317
+ replacement = replacement.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
318
+ const replaceRes = robustSnippetReplace(content, target, replacement);
319
+ if (!replaceRes.success) {
320
+ throw new Error(replaceRes.error || `Target text to replace not found in ${resolvedPath}`);
321
+ }
322
+ await fs.promises.writeFile(resolvedPath, replaceRes.updatedContent, 'utf-8');
323
+ return { success: true, path: resolvedPath };
324
+ }
325
+ case 'multi_edit_file': {
326
+ if (!fs.existsSync(resolvedPath)) {
327
+ throw new Error(`File not found for multi-editing: ${resolvedPath}`);
328
+ }
329
+ const edits = Array.isArray(args.edits) ? args.edits : [];
330
+ if (edits.length === 0) {
331
+ throw new Error(`No edits provided for multi_edit_file on ${resolvedPath}`);
332
+ }
333
+ let content = await fs.promises.readFile(resolvedPath, 'utf-8');
334
+ let count = 0;
335
+ const errors = [];
336
+ for (let i = 0; i < edits.length; i++) {
337
+ const ed = edits[i];
338
+ let target = String(ed.target ?? ed.old_string ?? ed.old_str ?? ed.oldText ?? ed.find ?? ed.search ?? '');
339
+ let replacement = String(ed.replacement ?? ed.new_string ?? ed.new_str ?? ed.newText ?? ed.replace ?? '');
340
+ if (target.includes('\\n') && !target.includes('\n'))
341
+ target = target.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
342
+ if (replacement.includes('\\n') && !replacement.includes('\n'))
343
+ replacement = replacement.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
344
+ const res = robustSnippetReplace(content, target, replacement);
345
+ if (res.success) {
346
+ content = res.updatedContent;
347
+ count++;
348
+ }
349
+ else {
350
+ errors.push(`Edit #${i + 1}: ${res.error}`);
316
351
  }
317
- content = content.replaceAll(target, replacement);
352
+ }
353
+ if (count === 0) {
354
+ throw new Error(`All ${edits.length} edits failed on ${resolvedPath}:\n${errors.join('\n')}`);
318
355
  }
319
356
  await fs.promises.writeFile(resolvedPath, content, 'utf-8');
320
- return { success: true, path: resolvedPath };
357
+ return { success: true, path: resolvedPath, appliedCount: count, totalEdits: edits.length, errors };
321
358
  }
322
359
  case 'list_dir': {
323
360
  const dirPath = fs.existsSync(resolvedPath) ? resolvedPath : (context?.cwd || process.cwd());
@@ -69,9 +69,11 @@ export function inferExecutionIntent(goal) {
69
69
  }
70
70
  const hasBrowserApp = requiredApplications.some(a => ['Google Chrome', 'Mozilla Firefox', 'Microsoft Edge', 'Web Browser'].includes(a));
71
71
  const isExplicitBrowserAction = /\b(?:browse\s+(?:to\s+)?https?:\/\/|navigate\s+to\s+https?:\/\/|open\s+(?:the\s+)?(?:webpage|website|url\s+in\s+browser)|in\s+(?:the\s+)?browser)\b/i.test(lower);
72
- const isBrowserGoal = hasBrowserApp || isExplicitBrowserAction;
72
+ const isAppLaunchCommand = /\b(?:open|launch|start|run|switch\s+to|focus|bring\s+up|close|kill|exit|khol|kholo|chala|chalao|band)\b/i.test(lower);
73
73
  const isDesktopAppGoal = requiredApplications.some(a => !['Google Chrome', 'Mozilla Firefox', 'Microsoft Edge', 'Web Browser'].includes(a)) ||
74
- /\b(?:open|launch|switch to|in)\s+(?:the\s+)?(?:notepad|excel|word|calculator|paint|terminal|powershell|cmd|app|window)\b/i.test(lower);
74
+ (hasBrowserApp && isAppLaunchCommand) ||
75
+ /\b(?:open|launch|switch to|in)\s+(?:the\s+)?(?:notepad|excel|word|calculator|paint|terminal|powershell|cmd|app|window|browser|chrome|edge)\b/i.test(lower);
76
+ const isBrowserGoal = isExplicitBrowserAction || (hasBrowserApp && !isAppLaunchCommand);
75
77
  if (isDesktopAppGoal && isBrowserGoal) {
76
78
  return {
77
79
  requiredApplications,
@@ -503,6 +505,13 @@ export class AgentWorkspace {
503
505
  try {
504
506
  const ftDir = path.join(this.workspaceDir, '.ft');
505
507
  fs.mkdirSync(ftDir, { recursive: true });
508
+ if (process.platform === 'win32') {
509
+ try {
510
+ const { execSync } = require('child_process');
511
+ execSync(`attrib +h "${ftDir}"`, { windowsHide: true, stdio: 'ignore' });
512
+ }
513
+ catch { }
514
+ }
506
515
  fs.writeFileSync(path.join(ftDir, 'scratchpad.md'), this.data.scratchpadNotes, 'utf-8');
507
516
  try {
508
517
  fs.writeFileSync(path.join(ftDir, 'scratchpad.cdp'), compress(Buffer.from(this.data.scratchpadNotes, 'utf-8'), LEVEL_FAST));
package/bin/src/index.js CHANGED
@@ -29,6 +29,7 @@ import { handleMcpList, handleMcpAdd, handleMcpRemove, handleMcpConnect, handleM
29
29
  import { handleCheckpoint, handleRollback, handleListCheckpoints } from './commands/checkpoint.js';
30
30
  import { handleWatch } from './commands/watch.js';
31
31
  import { handlePrCommand } from './commands/pr.js';
32
+ import { handleReplay } from './commands/replay.js';
32
33
  import { renderBranding } from './utils/branding.js';
33
34
  import { checkForUpdates } from './utils/updateCheck.js';
34
35
  import { maybeShowDiscoveryMessage } from './discovery/display.js';
@@ -39,16 +40,16 @@ program
39
40
  .name('scout')
40
41
  .alias('ft')
41
42
  .description('FrontTerrain The Onboarding Co-Pilot for New Codebases')
42
- .version('9.5.6');
43
+ .version('9.5.8');
43
44
  // Header UI on execution with FrontTerrain proprietary logo & version auto-checker
44
45
  program.hook('preAction', async (_thisCommand, actionCommand) => {
45
- intro(renderBranding('9.5.6'));
46
+ intro(renderBranding('9.5.8'));
46
47
  const cmdName = actionCommand ? actionCommand.name() : '';
47
48
  if (cmdName !== 'upgrade') {
48
- await checkForUpdates('9.5.6');
49
+ await checkForUpdates('9.5.8');
49
50
  }
50
- // Auth Guard: enforce authentication for all commands except login, signup, upgrade, help, dashboard, auth, status, plan, mcp, switch, accounts, support
51
- const EXEMPT_COMMANDS = ['login', 'signin', 'signup', 'register', 'upgrade', 'help', 'dashboard', 'web-ui', 'gui', 'auth', 'status', 'quota', 'usage', 'credits', 'plan', 'pricing', 'subscribe', 'mcp', 'switch', 'accounts', 'account', 'support', 'ticket', 'helpdesk'];
51
+ // Auth Guard: enforce authentication for all commands except login, signup, upgrade, help, dashboard, auth, status, plan, mcp, switch, accounts, support, replay
52
+ const EXEMPT_COMMANDS = ['login', 'signin', 'signup', 'register', 'upgrade', 'help', 'dashboard', 'web-ui', 'gui', 'auth', 'status', 'quota', 'usage', 'credits', 'plan', 'pricing', 'subscribe', 'mcp', 'switch', 'accounts', 'account', 'support', 'ticket', 'helpdesk', 'replay', 'trace'];
52
53
  if (!EXEMPT_COMMANDS.includes(cmdName)) {
53
54
  const authCfg = loadAuthConfig();
54
55
  const hasEnvApiKey = Boolean(process.env.OPENAI_API_KEY ||
@@ -266,7 +267,7 @@ program
266
267
  .command('upgrade')
267
268
  .description('Check for updates and auto-upgrade Scout to the latest version')
268
269
  .action(async () => {
269
- await checkForUpdates('9.5.6', true);
270
+ await checkForUpdates('9.5.8', true);
270
271
  outro(chalk.cyan('Upgrade check complete.'));
271
272
  });
272
273
  program
@@ -541,6 +542,16 @@ program
541
542
  await handlePrCommand(title, options);
542
543
  outro(chalk.cyan('PR workflow complete.'));
543
544
  });
545
+ // Production Hardening: Task Replay & Telemetry Engine
546
+ program
547
+ .command('replay [taskId]')
548
+ .alias('trace')
549
+ .description('Deterministic multi-step task replay, regression verification & execution trace export')
550
+ .option('-l, --list', 'List all available recorded task traces')
551
+ .option('-e, --export', 'Export task trace as JSON to stdout')
552
+ .action(async (taskId, options) => {
553
+ await handleReplay(taskId, options);
554
+ });
544
555
  try {
545
556
  await program.parseAsync(process.argv);
546
557
  }
@@ -37,7 +37,7 @@ export class MCPClient {
37
37
  },
38
38
  clientInfo: {
39
39
  name: 'scout',
40
- version: '9.5.6',
40
+ version: '9.5.8',
41
41
  },
42
42
  };
43
43
  const result = await this.transport.sendRequest('initialize', initParams, timeoutMs);