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
@@ -73,7 +73,7 @@ export class BrowserActionEngine {
73
73
  else if (cleanUrl.startsWith('http')) {
74
74
  try {
75
75
  const res = await fetch(cleanUrl, {
76
- headers: { 'User-Agent': 'Scout-ActionEngine/9.5.6' },
76
+ headers: { 'User-Agent': 'Scout-ActionEngine/9.5.8' },
77
77
  signal: AbortSignal.timeout(15000),
78
78
  });
79
79
  if (res.ok) {
@@ -20,7 +20,7 @@ export class BrowserObserver {
20
20
  if (!html && url.startsWith('http')) {
21
21
  try {
22
22
  const res = await fetch(url, {
23
- headers: { 'User-Agent': 'Scout-BrowserObserver/9.5.6' },
23
+ headers: { 'User-Agent': 'Scout-BrowserObserver/9.5.8' },
24
24
  signal: AbortSignal.timeout(10000),
25
25
  });
26
26
  if (res.ok) {
@@ -27,6 +27,15 @@ export class CheckpointManager {
27
27
  if (!fs.existsSync(this.checkpointDir)) {
28
28
  fs.mkdirSync(this.checkpointDir, { recursive: true });
29
29
  }
30
+ if (process.platform === 'win32') {
31
+ try {
32
+ const rootFt = path.join(this.workspaceDir, '.ft');
33
+ if (fs.existsSync(rootFt)) {
34
+ execSync(`attrib +h "${rootFt}"`, { windowsHide: true, stdio: 'ignore' });
35
+ }
36
+ }
37
+ catch { }
38
+ }
30
39
  }
31
40
  catch { }
32
41
  }
@@ -76,7 +76,7 @@ export interface IComputerController {
76
76
  doubleClick(x: number, y: number): Promise<ComputerActionResult>;
77
77
  mouseDown(x?: number, y?: number, button?: 'left' | 'right' | 'middle'): Promise<ComputerActionResult>;
78
78
  mouseUp(x?: number, y?: number, button?: 'left' | 'right' | 'middle'): Promise<ComputerActionResult>;
79
- type(text: string): Promise<ComputerActionResult>;
79
+ type(text: string, targetApp?: string): Promise<ComputerActionResult>;
80
80
  keyPress(key: string): Promise<ComputerActionResult>;
81
81
  key_press(key: string): Promise<ComputerActionResult>;
82
82
  hotkey(keys: string[]): Promise<ComputerActionResult>;
@@ -114,9 +114,15 @@ export declare class SystemComputerController implements IComputerController {
114
114
  private activeWindow;
115
115
  private driverExePath;
116
116
  private driverInitAttempted;
117
+ private serverProcess;
118
+ private serverStdoutBuffer;
119
+ private serverQueue;
117
120
  constructor(workspaceDir?: string);
118
121
  setExpectedApplication(app: string | null): void;
119
122
  getExpectedApplication(): string | null;
123
+ dispose(): void;
124
+ private killServerProcess;
125
+ private ensureServerProcess;
120
126
  /**
121
127
  * Resolves or builds the native scout_driver.exe for Windows.
122
128
  */
@@ -149,7 +155,7 @@ export declare class SystemComputerController implements IComputerController {
149
155
  y: number;
150
156
  }>;
151
157
  runDiagnostic(): Promise<ComputerActionResult>;
152
- type(text: string): Promise<ComputerActionResult>;
158
+ type(text: string, targetApp?: string): Promise<ComputerActionResult>;
153
159
  keyPress(key: string): Promise<ComputerActionResult>;
154
160
  key_press(key: string): Promise<ComputerActionResult>;
155
161
  hotkey(keys: string[]): Promise<ComputerActionResult>;
@@ -48,6 +48,9 @@ export class SystemComputerController {
48
48
  activeWindow = null;
49
49
  driverExePath = null;
50
50
  driverInitAttempted = false;
51
+ serverProcess = null;
52
+ serverStdoutBuffer = '';
53
+ serverQueue = [];
51
54
  constructor(workspaceDir = process.cwd()) {
52
55
  this.workspaceDir = workspaceDir;
53
56
  this.screenshotsDir = path.join(this.workspaceDir, '.ft', 'screenshots');
@@ -57,6 +60,8 @@ export class SystemComputerController {
57
60
  }
58
61
  }
59
62
  catch { }
63
+ // Clean up persistent driver server on process exit
64
+ process.on('exit', () => this.killServerProcess());
60
65
  }
61
66
  setExpectedApplication(app) {
62
67
  this.expectedApplication = app;
@@ -64,6 +69,75 @@ export class SystemComputerController {
64
69
  getExpectedApplication() {
65
70
  return this.expectedApplication;
66
71
  }
72
+ dispose() {
73
+ this.killServerProcess();
74
+ }
75
+ killServerProcess() {
76
+ if (this.serverProcess) {
77
+ try {
78
+ this.serverProcess.stdin?.write('exit\n');
79
+ this.serverProcess.kill();
80
+ }
81
+ catch { }
82
+ this.serverProcess = null;
83
+ }
84
+ this.serverStdoutBuffer = '';
85
+ while (this.serverQueue.length > 0) {
86
+ const item = this.serverQueue.shift();
87
+ if (item) {
88
+ clearTimeout(item.timeout);
89
+ item.reject(new Error('Driver server process terminated'));
90
+ }
91
+ }
92
+ }
93
+ async ensureServerProcess(driverPath) {
94
+ if (this.serverProcess && !this.serverProcess.killed) {
95
+ return true;
96
+ }
97
+ try {
98
+ const cp = spawn(driverPath, ['--server'], {
99
+ windowsHide: true,
100
+ stdio: ['pipe', 'pipe', 'ignore'],
101
+ });
102
+ cp.stdout?.setEncoding('utf-8');
103
+ cp.stdout?.on('data', (chunk) => {
104
+ this.serverStdoutBuffer += chunk;
105
+ let newlineIdx;
106
+ while ((newlineIdx = this.serverStdoutBuffer.indexOf('\n')) !== -1) {
107
+ const line = this.serverStdoutBuffer.slice(0, newlineIdx).trim();
108
+ this.serverStdoutBuffer = this.serverStdoutBuffer.slice(newlineIdx + 1);
109
+ if (!line)
110
+ continue;
111
+ const item = this.serverQueue.shift();
112
+ if (item) {
113
+ clearTimeout(item.timeout);
114
+ try {
115
+ if (line.startsWith('{') && line.endsWith('}')) {
116
+ item.resolve(JSON.parse(line));
117
+ }
118
+ else {
119
+ item.resolve({ success: true, output: line });
120
+ }
121
+ }
122
+ catch {
123
+ item.resolve({ success: true, output: line });
124
+ }
125
+ }
126
+ }
127
+ });
128
+ cp.on('error', () => {
129
+ this.killServerProcess();
130
+ });
131
+ cp.on('exit', () => {
132
+ this.killServerProcess();
133
+ });
134
+ this.serverProcess = cp;
135
+ return true;
136
+ }
137
+ catch {
138
+ return false;
139
+ }
140
+ }
67
141
  /**
68
142
  * Resolves or builds the native scout_driver.exe for Windows.
69
143
  */
@@ -142,6 +216,36 @@ export class SystemComputerController {
142
216
  const driver = await this.ensureDriver();
143
217
  const strArgs = args.map((a) => String(a));
144
218
  if (driver) {
219
+ // Fast path: Persistent driver server IPC (sub-2ms response time)
220
+ try {
221
+ const serverReady = await this.ensureServerProcess(driver);
222
+ if (serverReady && this.serverProcess?.stdin?.writable) {
223
+ const formattedArgs = strArgs.map(arg => {
224
+ if (arg.includes(' ') || arg.includes('\t') || arg.includes('"')) {
225
+ return `"${arg.replace(/"/g, '\\"')}"`;
226
+ }
227
+ return arg;
228
+ });
229
+ const cmdLine = [action, ...formattedArgs].join(' ');
230
+ const res = await new Promise((resolve, reject) => {
231
+ const timeout = setTimeout(() => {
232
+ const idx = this.serverQueue.findIndex(q => q.timeout === timeout);
233
+ if (idx !== -1) {
234
+ this.serverQueue.splice(idx, 1);
235
+ }
236
+ reject(new Error(`Server IPC timeout for action "${action}"`));
237
+ }, 5000);
238
+ this.serverQueue.push({ resolve, reject, timeout });
239
+ this.serverProcess.stdin.write(cmdLine + '\n');
240
+ });
241
+ return res;
242
+ }
243
+ }
244
+ catch {
245
+ // If server IPC fails or times out, gracefully fall back to one-shot execution
246
+ this.killServerProcess();
247
+ }
248
+ // Fallback: One-shot process execution
145
249
  try {
146
250
  const { stdout } = await execFileAsync(driver, [action, ...strArgs], {
147
251
  windowsHide: true,
@@ -548,18 +652,14 @@ if ($act -eq "move") {
548
652
  activeWindow: 'Desktop',
549
653
  };
550
654
  }
551
- async type(text) {
655
+ async type(text, targetApp) {
552
656
  if (!text)
553
657
  return { success: true, output: 'Typed empty string', action: 'type' };
554
658
  if (process.platform === 'win32') {
555
- const targetApp = this.expectedApplication || '';
556
- if (targetApp) {
557
- await this.switchWindow(targetApp);
558
- await this.wait(150);
559
- }
560
- const res = await this.runDriverAction('type', [text]);
659
+ const app = targetApp || this.expectedApplication || '';
660
+ const res = await this.runDriverAction('type', app ? [text, app] : [text]);
561
661
  const success = Boolean(res?.success);
562
- const activeWin = res?.activeWindow || targetApp || 'foreground';
662
+ const activeWin = res?.activeWindow || app || 'foreground';
563
663
  this.activeWindow = activeWin;
564
664
  return {
565
665
  success,
@@ -657,16 +757,20 @@ if ($act -eq "move") {
657
757
  titleTerms.push('visual studio code', 'code');
658
758
  processNames.push('Code');
659
759
  }
660
- else if (appLower === 'chrome' || appLower === 'google chrome' || appLower === 'google-chrome' || appLower === 'browser') {
661
- const chromeCandidates = [
760
+ else if (appLower === 'chrome' || appLower === 'google chrome' || appLower === 'google-chrome' || appLower === 'browser' || appLower === 'web browser' || appLower === 'default browser' || appLower === 'web' || appLower === 'internet') {
761
+ const browserCandidates = [
662
762
  'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
663
763
  'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
664
764
  process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, 'Google', 'Chrome', 'Application', 'chrome.exe') : '',
765
+ 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe',
766
+ 'C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe',
767
+ 'C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe',
768
+ process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, 'BraveSoftware', 'Brave-Browser', 'Application', 'brave.exe') : '',
665
769
  ].filter(Boolean);
666
- const found = chromeCandidates.find((p) => fs.existsSync(p));
770
+ const found = browserCandidates.find((p) => fs.existsSync(p));
667
771
  canonicalCmd = found || 'chrome.exe';
668
- titleTerms.push('chrome', 'google chrome');
669
- processNames.push('chrome');
772
+ titleTerms.push('chrome', 'google chrome', 'edge', 'microsoft edge', 'brave', 'browser', 'new tab', 'google');
773
+ processNames.push('chrome', 'msedge', 'brave');
670
774
  }
671
775
  else if (appLower === 'edge' || appLower === 'msedge' || appLower === 'microsoft edge') {
672
776
  const edgeCandidates = [
@@ -757,48 +861,71 @@ if ($act -eq "move") {
757
861
  async openApplication(appName, args = []) {
758
862
  const resolved = this.resolveCanonicalApp(appName, args);
759
863
  const canonicalCmd = resolved.canonicalCmd;
760
- const finalArgs = resolved.args;
864
+ const appLower = appName.toLowerCase().trim();
865
+ const isGenericBrowser = ['browser', 'web browser', 'default browser', 'web', 'internet'].includes(appLower);
866
+ const isBrowser = isGenericBrowser ||
867
+ ['chrome', 'google chrome', 'edge', 'msedge', 'brave'].includes(appLower) ||
868
+ canonicalCmd.toLowerCase().includes('chrome') ||
869
+ canonicalCmd.toLowerCase().includes('msedge') ||
870
+ canonicalCmd.toLowerCase().includes('brave');
871
+ let finalArgs = resolved.args;
872
+ if (isBrowser && finalArgs.length === 0 && !isGenericBrowser) {
873
+ finalArgs = ['--new-window', 'https://www.google.com'];
874
+ }
761
875
  const argsStr = finalArgs.join(' ');
762
876
  try {
763
877
  if (process.platform === 'win32') {
764
- const driverRes = await this.runDriverAction('launch', finalArgs.length > 0 ? [canonicalCmd, argsStr] : [canonicalCmd]);
765
- if (!driverRes || !driverRes.success) {
766
- const spawnDetached = (cmd, a = []) => {
767
- try {
768
- const child = spawn('cmd.exe', ['/c', 'start', '', cmd, ...a], {
769
- detached: true,
770
- stdio: 'ignore',
771
- windowsHide: true,
772
- });
773
- child.unref();
774
- }
775
- catch { }
776
- };
777
- spawnDetached(canonicalCmd, finalArgs);
878
+ // Primary: Spawn detached via Windows Shell (cmd.exe /c start) directly from Node.js.
879
+ // In Windows, processes launched via "start" are delegated to explorer.exe,
880
+ // completely independent of this console, job object, or process tree,
881
+ // and remain open indefinitely on the user's desktop.
882
+ let launched = false;
883
+ try {
884
+ const startTarget = isGenericBrowser ? 'https://www.google.com' : canonicalCmd;
885
+ const startArgs = isGenericBrowser ? [] : finalArgs;
886
+ const child = spawn('cmd.exe', ['/c', 'start', '""', startTarget, ...startArgs], {
887
+ detached: true,
888
+ stdio: 'ignore',
889
+ windowsHide: true,
890
+ });
891
+ child.unref();
892
+ launched = true;
893
+ }
894
+ catch { }
895
+ // Fallback to native scout_driver launch if spawn fails
896
+ if (!launched) {
897
+ await this.runDriverAction('launch', finalArgs.length > 0 ? [canonicalCmd, argsStr] : [canonicalCmd]);
778
898
  }
779
899
  this.expectedApplication = appName;
780
900
  // Observation-based wait: poll inspectUI to confirm window appeared
781
- const delays = [300, 600, 1000];
901
+ const delays = [300, 600, 1000, 1500];
902
+ let matchedWindow = null;
782
903
  for (const delay of delays) {
783
904
  await this.wait(delay);
784
905
  const ui = await this.inspectUI();
785
- const match = ui.windows.some(w => {
906
+ const match = ui.windows.find(w => {
786
907
  const wLower = w.toLowerCase();
787
908
  return resolved.titleTerms.some(term => wLower.includes(term.toLowerCase()));
788
909
  });
789
- if (match || (ui.activeWindow && resolved.titleTerms.some(term => ui.activeWindow.toLowerCase().includes(term.toLowerCase())))) {
910
+ if (match) {
911
+ matchedWindow = match;
912
+ break;
913
+ }
914
+ if (ui.activeWindow && resolved.titleTerms.some(term => ui.activeWindow.toLowerCase().includes(term.toLowerCase()))) {
915
+ matchedWindow = ui.activeWindow;
790
916
  break;
791
917
  }
792
918
  }
793
- if (this.expectedApplication) {
794
- await this.switchWindow(this.expectedApplication);
919
+ if (matchedWindow) {
920
+ this.expectedApplication = matchedWindow;
921
+ this.activeWindow = matchedWindow;
795
922
  }
796
923
  return {
797
924
  success: true,
798
- output: `Launched and focused application: "${this.expectedApplication || appName}"`,
925
+ output: `Launched and focused application: "${matchedWindow || this.expectedApplication || appName}"`,
799
926
  action: 'open_app',
800
- activeWindow: this.expectedApplication || appName,
801
- expectedWindow: this.expectedApplication || appName,
927
+ activeWindow: matchedWindow || this.expectedApplication || appName,
928
+ expectedWindow: matchedWindow || this.expectedApplication || appName,
802
929
  };
803
930
  }
804
931
  else if (process.platform === 'darwin') {
@@ -877,9 +1004,16 @@ if ($act -eq "move") {
877
1004
  try {
878
1005
  const script = `
879
1006
  $wshell = New-Object -ComObject Wscript.Shell
880
- $result = $wshell.AppActivate("${windowTitleOrApp.replace(/"/g, '`"')}")
1007
+ $target = "${windowTitleOrApp.replace(/"/g, '`"')}"
1008
+ $result = $wshell.AppActivate($target)
881
1009
  if (-not $result) {
882
- $p = Get-Process | Where-Object { $_.MainWindowTitle -like "*${windowTitleOrApp.replace(/"/g, '`"')}*" -or $_.ProcessName -like "*${windowTitleOrApp.replace(/"/g, '`"')}*" } | Select-Object -First 1
1010
+ $p = Get-Process | Where-Object { $_.MainWindowTitle -like "*$target*" -or $_.ProcessName -like "*$target*" } | Select-Object -First 1
1011
+ if (-not $p) {
1012
+ $kw = if ($target -match 'chrome|browser') { 'chrome' } elseif ($target -match 'edge') { 'msedge' } elseif ($target -match 'notepad') { 'notepad' } elseif ($target -match 'code') { 'code' } else { '' }
1013
+ if ($kw) {
1014
+ $p = Get-Process | Where-Object { $_.ProcessName -like "*$kw*" -or $_.MainWindowTitle -like "*$kw*" } | Select-Object -First 1
1015
+ }
1016
+ }
883
1017
  if ($p) {
884
1018
  $null = $wshell.AppActivate($p.Id)
885
1019
  $result = $true
@@ -29,7 +29,7 @@ export declare class MockComputerController implements IComputerController {
29
29
  doubleClick(x: number, y: number): Promise<ComputerActionResult>;
30
30
  mouseDown(x?: number, y?: number, button?: 'left' | 'right' | 'middle'): Promise<ComputerActionResult>;
31
31
  mouseUp(x?: number, y?: number, button?: 'left' | 'right' | 'middle'): Promise<ComputerActionResult>;
32
- type(text: string): Promise<ComputerActionResult>;
32
+ type(text: string, targetApp?: string): Promise<ComputerActionResult>;
33
33
  keyPress(key: string): Promise<ComputerActionResult>;
34
34
  key_press(key: string): Promise<ComputerActionResult>;
35
35
  hotkey(keys: string[]): Promise<ComputerActionResult>;
@@ -115,7 +115,7 @@ export class MockComputerController {
115
115
  button: btn,
116
116
  };
117
117
  }
118
- async type(text) {
118
+ async type(text, targetApp) {
119
119
  this.log('type', { text });
120
120
  if (this.shouldFailNext) {
121
121
  this.shouldFailNext = false;