ft-scout 9.5.6 → 9.5.7

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.
@@ -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.7' },
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.7' },
24
24
  signal: AbortSignal.timeout(10000),
25
25
  });
26
26
  if (res.ok) {
@@ -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>;
@@ -149,7 +149,7 @@ export declare class SystemComputerController implements IComputerController {
149
149
  y: number;
150
150
  }>;
151
151
  runDiagnostic(): Promise<ComputerActionResult>;
152
- type(text: string): Promise<ComputerActionResult>;
152
+ type(text: string, targetApp?: string): Promise<ComputerActionResult>;
153
153
  keyPress(key: string): Promise<ComputerActionResult>;
154
154
  key_press(key: string): Promise<ComputerActionResult>;
155
155
  hotkey(keys: string[]): Promise<ComputerActionResult>;
@@ -548,18 +548,14 @@ if ($act -eq "move") {
548
548
  activeWindow: 'Desktop',
549
549
  };
550
550
  }
551
- async type(text) {
551
+ async type(text, targetApp) {
552
552
  if (!text)
553
553
  return { success: true, output: 'Typed empty string', action: 'type' };
554
554
  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]);
555
+ const app = targetApp || this.expectedApplication || '';
556
+ const res = await this.runDriverAction('type', app ? [text, app] : [text]);
561
557
  const success = Boolean(res?.success);
562
- const activeWin = res?.activeWindow || targetApp || 'foreground';
558
+ const activeWin = res?.activeWindow || app || 'foreground';
563
559
  this.activeWindow = activeWin;
564
560
  return {
565
561
  success,
@@ -657,16 +653,20 @@ if ($act -eq "move") {
657
653
  titleTerms.push('visual studio code', 'code');
658
654
  processNames.push('Code');
659
655
  }
660
- else if (appLower === 'chrome' || appLower === 'google chrome' || appLower === 'google-chrome' || appLower === 'browser') {
661
- const chromeCandidates = [
656
+ else if (appLower === 'chrome' || appLower === 'google chrome' || appLower === 'google-chrome' || appLower === 'browser' || appLower === 'web browser' || appLower === 'default browser' || appLower === 'web' || appLower === 'internet') {
657
+ const browserCandidates = [
662
658
  'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
663
659
  'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
664
660
  process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, 'Google', 'Chrome', 'Application', 'chrome.exe') : '',
661
+ 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe',
662
+ 'C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe',
663
+ 'C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe',
664
+ process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, 'BraveSoftware', 'Brave-Browser', 'Application', 'brave.exe') : '',
665
665
  ].filter(Boolean);
666
- const found = chromeCandidates.find((p) => fs.existsSync(p));
666
+ const found = browserCandidates.find((p) => fs.existsSync(p));
667
667
  canonicalCmd = found || 'chrome.exe';
668
- titleTerms.push('chrome', 'google chrome');
669
- processNames.push('chrome');
668
+ titleTerms.push('chrome', 'google chrome', 'edge', 'microsoft edge', 'brave', 'browser', 'new tab', 'google');
669
+ processNames.push('chrome', 'msedge', 'brave');
670
670
  }
671
671
  else if (appLower === 'edge' || appLower === 'msedge' || appLower === 'microsoft edge') {
672
672
  const edgeCandidates = [
@@ -757,48 +757,70 @@ if ($act -eq "move") {
757
757
  async openApplication(appName, args = []) {
758
758
  const resolved = this.resolveCanonicalApp(appName, args);
759
759
  const canonicalCmd = resolved.canonicalCmd;
760
- const finalArgs = resolved.args;
760
+ const appLower = appName.toLowerCase().trim();
761
+ const isGenericBrowser = ['browser', 'web browser', 'default browser', 'web', 'internet'].includes(appLower);
762
+ const isBrowser = isGenericBrowser ||
763
+ ['chrome', 'google chrome', 'edge', 'msedge', 'brave'].includes(appLower) ||
764
+ canonicalCmd.toLowerCase().includes('chrome') ||
765
+ canonicalCmd.toLowerCase().includes('msedge') ||
766
+ canonicalCmd.toLowerCase().includes('brave');
767
+ let finalArgs = resolved.args;
768
+ if (isBrowser && finalArgs.length === 0 && !isGenericBrowser) {
769
+ finalArgs = ['--new-window', 'https://www.google.com'];
770
+ }
761
771
  const argsStr = finalArgs.join(' ');
762
772
  try {
763
773
  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);
774
+ // Primary: Spawn detached via Windows Shell (cmd.exe /c start) directly from Node.js.
775
+ // In Windows, processes launched via "start" are delegated to explorer.exe,
776
+ // completely independent of this console, job object, or process tree,
777
+ // and remain open indefinitely on the user's desktop.
778
+ let launched = false;
779
+ try {
780
+ const startTarget = isGenericBrowser ? 'https://www.google.com' : canonicalCmd;
781
+ const startArgs = isGenericBrowser ? [] : finalArgs;
782
+ const child = spawn('cmd.exe', ['/c', 'start', '', startTarget, ...startArgs], {
783
+ detached: true,
784
+ stdio: 'ignore',
785
+ });
786
+ child.unref();
787
+ launched = true;
788
+ }
789
+ catch { }
790
+ // Fallback to native scout_driver launch if spawn fails
791
+ if (!launched) {
792
+ await this.runDriverAction('launch', finalArgs.length > 0 ? [canonicalCmd, argsStr] : [canonicalCmd]);
778
793
  }
779
794
  this.expectedApplication = appName;
780
795
  // Observation-based wait: poll inspectUI to confirm window appeared
781
- const delays = [300, 600, 1000];
796
+ const delays = [300, 600, 1000, 1500];
797
+ let matchedWindow = null;
782
798
  for (const delay of delays) {
783
799
  await this.wait(delay);
784
800
  const ui = await this.inspectUI();
785
- const match = ui.windows.some(w => {
801
+ const match = ui.windows.find(w => {
786
802
  const wLower = w.toLowerCase();
787
803
  return resolved.titleTerms.some(term => wLower.includes(term.toLowerCase()));
788
804
  });
789
- if (match || (ui.activeWindow && resolved.titleTerms.some(term => ui.activeWindow.toLowerCase().includes(term.toLowerCase())))) {
805
+ if (match) {
806
+ matchedWindow = match;
807
+ break;
808
+ }
809
+ if (ui.activeWindow && resolved.titleTerms.some(term => ui.activeWindow.toLowerCase().includes(term.toLowerCase()))) {
810
+ matchedWindow = ui.activeWindow;
790
811
  break;
791
812
  }
792
813
  }
793
- if (this.expectedApplication) {
794
- await this.switchWindow(this.expectedApplication);
814
+ if (matchedWindow) {
815
+ this.expectedApplication = matchedWindow;
816
+ this.activeWindow = matchedWindow;
795
817
  }
796
818
  return {
797
819
  success: true,
798
- output: `Launched and focused application: "${this.expectedApplication || appName}"`,
820
+ output: `Launched and focused application: "${matchedWindow || this.expectedApplication || appName}"`,
799
821
  action: 'open_app',
800
- activeWindow: this.expectedApplication || appName,
801
- expectedWindow: this.expectedApplication || appName,
822
+ activeWindow: matchedWindow || this.expectedApplication || appName,
823
+ expectedWindow: matchedWindow || this.expectedApplication || appName,
802
824
  };
803
825
  }
804
826
  else if (process.platform === 'darwin') {
@@ -877,9 +899,16 @@ if ($act -eq "move") {
877
899
  try {
878
900
  const script = `
879
901
  $wshell = New-Object -ComObject Wscript.Shell
880
- $result = $wshell.AppActivate("${windowTitleOrApp.replace(/"/g, '`"')}")
902
+ $target = "${windowTitleOrApp.replace(/"/g, '`"')}"
903
+ $result = $wshell.AppActivate($target)
881
904
  if (-not $result) {
882
- $p = Get-Process | Where-Object { $_.MainWindowTitle -like "*${windowTitleOrApp.replace(/"/g, '`"')}*" -or $_.ProcessName -like "*${windowTitleOrApp.replace(/"/g, '`"')}*" } | Select-Object -First 1
905
+ $p = Get-Process | Where-Object { $_.MainWindowTitle -like "*$target*" -or $_.ProcessName -like "*$target*" } | Select-Object -First 1
906
+ if (-not $p) {
907
+ $kw = if ($target -match 'chrome|browser') { 'chrome' } elseif ($target -match 'edge') { 'msedge' } elseif ($target -match 'notepad') { 'notepad' } elseif ($target -match 'code') { 'code' } else { '' }
908
+ if ($kw) {
909
+ $p = Get-Process | Where-Object { $_.ProcessName -like "*$kw*" -or $_.MainWindowTitle -like "*$kw*" } | Select-Object -First 1
910
+ }
911
+ }
883
912
  if ($p) {
884
913
  $null = $wshell.AppActivate($p.Id)
885
914
  $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;