ft-scout 9.5.4 → 9.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/src/commands/agent.d.ts +5 -0
- package/bin/src/commands/agent.js +45 -3
- package/bin/src/commands/support.d.ts +9 -0
- package/bin/src/commands/support.js +227 -0
- package/bin/src/engine/agent/computerUseLoop.d.ts +107 -0
- package/bin/src/engine/agent/computerUseLoop.js +413 -0
- package/bin/src/engine/agent/index.d.ts +2 -0
- package/bin/src/engine/agent/index.js +2 -0
- package/bin/src/engine/agent/recovery/index.d.ts +4 -0
- package/bin/src/engine/agent/recovery/index.js +4 -0
- package/bin/src/engine/agent/recovery/loopDetector.d.ts +26 -0
- package/bin/src/engine/agent/recovery/loopDetector.js +126 -0
- package/bin/src/engine/agent/recovery/recoveryManager.d.ts +43 -0
- package/bin/src/engine/agent/recovery/recoveryManager.js +271 -0
- package/bin/src/engine/agent/recovery/types.d.ts +48 -0
- package/bin/src/engine/agent/recovery/types.js +4 -0
- package/bin/src/engine/agent/verification/index.d.ts +3 -0
- package/bin/src/engine/agent/verification/index.js +3 -0
- package/bin/src/engine/agent/verification/stateChangeVerifier.d.ts +22 -0
- package/bin/src/engine/agent/verification/stateChangeVerifier.js +282 -0
- package/bin/src/engine/agent/verification/types.d.ts +28 -0
- package/bin/src/engine/agent/verification/types.js +4 -0
- package/bin/src/engine/agentEngine.d.ts +2 -1
- package/bin/src/engine/agentEngine.js +98 -7
- package/bin/src/engine/agentState.d.ts +41 -1
- package/bin/src/engine/agentState.js +45 -0
- package/bin/src/engine/browser/actions/actionEngine.d.ts +41 -0
- package/bin/src/engine/browser/actions/actionEngine.js +707 -0
- package/bin/src/engine/browser/actions/index.d.ts +4 -0
- package/bin/src/engine/browser/actions/index.js +4 -0
- package/bin/src/engine/browser/actions/reliability.d.ts +41 -0
- package/bin/src/engine/browser/actions/reliability.js +170 -0
- package/bin/src/engine/browser/actions/types.d.ts +50 -0
- package/bin/src/engine/browser/actions/types.js +2 -0
- package/bin/src/engine/browser/browserController.d.ts +18 -0
- package/bin/src/engine/browser/browserController.js +44 -12
- package/bin/src/engine/browser/index.d.ts +2 -0
- package/bin/src/engine/browser/index.js +2 -0
- package/bin/src/engine/browser/observer/accessibilityTree.d.ts +14 -0
- package/bin/src/engine/browser/observer/accessibilityTree.js +214 -0
- package/bin/src/engine/browser/observer/browserObserver.d.ts +29 -0
- package/bin/src/engine/browser/observer/browserObserver.js +204 -0
- package/bin/src/engine/browser/observer/domExtractor.d.ts +30 -0
- package/bin/src/engine/browser/observer/domExtractor.js +407 -0
- package/bin/src/engine/browser/observer/index.d.ts +5 -0
- package/bin/src/engine/browser/observer/index.js +5 -0
- package/bin/src/engine/browser/observer/types.d.ts +163 -0
- package/bin/src/engine/browser/observer/types.js +8 -0
- package/bin/src/engine/computer/computerController.d.ts +49 -0
- package/bin/src/engine/computer/computerController.js +249 -104
- package/bin/src/engine/computer/mockComputer.d.ts +6 -1
- package/bin/src/engine/computer/mockComputer.js +58 -0
- package/bin/src/engine/computer/scoutDriver.cs +84 -2
- package/bin/src/engine/llm.js +16 -0
- package/bin/src/engine/models/harpProvider.d.ts +32 -0
- package/bin/src/engine/models/harpProvider.js +124 -0
- package/bin/src/engine/models/index.d.ts +6 -0
- package/bin/src/engine/models/index.js +6 -0
- package/bin/src/engine/models/localModelProvider.d.ts +11 -0
- package/bin/src/engine/models/localModelProvider.js +48 -0
- package/bin/src/engine/models/openaiProvider.d.ts +11 -0
- package/bin/src/engine/models/openaiProvider.js +50 -0
- package/bin/src/engine/models/reasoningOrchestrator.d.ts +17 -0
- package/bin/src/engine/models/reasoningOrchestrator.js +75 -0
- package/bin/src/engine/models/types.d.ts +63 -0
- package/bin/src/engine/models/types.js +2 -0
- package/bin/src/engine/planner.js +64 -34
- package/bin/src/engine/production/index.d.ts +3 -0
- package/bin/src/engine/production/index.js +3 -0
- package/bin/src/engine/production/taskReplay.d.ts +37 -0
- package/bin/src/engine/production/taskReplay.js +81 -0
- package/bin/src/engine/production/telemetry.d.ts +43 -0
- package/bin/src/engine/production/telemetry.js +68 -0
- package/bin/src/engine/runtime/agentRuntime.d.ts +1 -1
- package/bin/src/engine/runtime/agentRuntime.js +99 -0
- package/bin/src/engine/safety/index.d.ts +3 -0
- package/bin/src/engine/safety/index.js +3 -0
- package/bin/src/engine/safety/policyEngine.d.ts +40 -0
- package/bin/src/engine/safety/policyEngine.js +282 -0
- package/bin/src/engine/safety/types.d.ts +24 -0
- package/bin/src/engine/safety/types.js +2 -0
- package/bin/src/engine/safety.d.ts +1 -0
- package/bin/src/engine/safety.js +1 -0
- package/bin/src/engine/subagents/subagentManager.js +2 -2
- package/bin/src/engine/toolRegistry.d.ts +4 -0
- package/bin/src/engine/toolRegistry.js +9 -0
- package/bin/src/engine/tools/domainHandlers.d.ts +61 -0
- package/bin/src/engine/tools/domainHandlers.js +458 -0
- package/bin/src/engine/tools/index.d.ts +4 -0
- package/bin/src/engine/tools/index.js +4 -0
- package/bin/src/engine/tools/types.d.ts +56 -0
- package/bin/src/engine/tools/types.js +2 -0
- package/bin/src/engine/tools/unifiedRouter.d.ts +29 -0
- package/bin/src/engine/tools/unifiedRouter.js +426 -0
- package/bin/src/index.js +26 -6
- package/bin/src/mcp/client.js +1 -1
- package/bin/src/server/server.js +136 -0
- package/bin/src/utils/branding.js +1 -1
- package/bin/src/utils/qrBridge.js +1 -1
- package/bin/src/utils/session.d.ts +5 -1
- package/bin/src/utils/session.js +36 -3
- package/bin/src/utils/support.d.ts +63 -0
- package/bin/src/utils/support.js +182 -0
- package/package.json +2 -2
|
@@ -34,6 +34,37 @@ export interface UIInspectionResult {
|
|
|
34
34
|
windows: string[];
|
|
35
35
|
focusedElement?: string;
|
|
36
36
|
}
|
|
37
|
+
export type SupportedAppType = 'browser' | 'terminal' | 'editor' | 'file_manager' | 'other';
|
|
38
|
+
export interface ActiveWindowInfo {
|
|
39
|
+
title: string;
|
|
40
|
+
appName: string;
|
|
41
|
+
appType: SupportedAppType;
|
|
42
|
+
bounds?: {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
} | undefined;
|
|
48
|
+
processId?: number | undefined;
|
|
49
|
+
isResponding: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface DesktopApplicationState {
|
|
52
|
+
appName: string;
|
|
53
|
+
appType: SupportedAppType;
|
|
54
|
+
isRunning: boolean;
|
|
55
|
+
isFocused: boolean;
|
|
56
|
+
windowTitle: string;
|
|
57
|
+
bounds?: {
|
|
58
|
+
x: number;
|
|
59
|
+
y: number;
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
} | undefined;
|
|
63
|
+
canAcceptInput: boolean;
|
|
64
|
+
}
|
|
65
|
+
export type DesktopActionRiskLevel = 0 | 1 | 2 | 3;
|
|
66
|
+
export declare function classifyAppType(windowTitleOrApp: string): SupportedAppType;
|
|
67
|
+
export declare function getDesktopActionRiskLevel(action: string): DesktopActionRiskLevel;
|
|
37
68
|
export interface IComputerController {
|
|
38
69
|
screenshot(): Promise<ScreenCaptureResult>;
|
|
39
70
|
click(x: number, y: number, options?: {
|
|
@@ -47,15 +78,18 @@ export interface IComputerController {
|
|
|
47
78
|
mouseUp(x?: number, y?: number, button?: 'left' | 'right' | 'middle'): Promise<ComputerActionResult>;
|
|
48
79
|
type(text: string): Promise<ComputerActionResult>;
|
|
49
80
|
keyPress(key: string): Promise<ComputerActionResult>;
|
|
81
|
+
key_press(key: string): Promise<ComputerActionResult>;
|
|
50
82
|
hotkey(keys: string[]): Promise<ComputerActionResult>;
|
|
51
83
|
scroll(deltaX: number, deltaY: number): Promise<ComputerActionResult>;
|
|
52
84
|
mouseMove(x: number, y: number): Promise<ComputerActionResult>;
|
|
53
85
|
move(x: number, y: number): Promise<ComputerActionResult>;
|
|
86
|
+
move_mouse(x: number, y: number): Promise<ComputerActionResult>;
|
|
54
87
|
drag(fromX: number, fromY: number, toX: number, toY: number): Promise<ComputerActionResult>;
|
|
55
88
|
wait(ms: number): Promise<void>;
|
|
56
89
|
openApplication(appName: string, args?: string[]): Promise<ComputerActionResult>;
|
|
57
90
|
closeApplication(appName: string): Promise<ComputerActionResult>;
|
|
58
91
|
switchWindow(windowTitleOrApp: string): Promise<ComputerActionResult>;
|
|
92
|
+
switch_to_app(appType: SupportedAppType | string): Promise<ComputerActionResult>;
|
|
59
93
|
getWindowBounds?(windowTitleOrApp: string): Promise<{
|
|
60
94
|
x: number;
|
|
61
95
|
y: number;
|
|
@@ -63,6 +97,8 @@ export interface IComputerController {
|
|
|
63
97
|
height: number;
|
|
64
98
|
} | null>;
|
|
65
99
|
inspectUI(): Promise<UIInspectionResult>;
|
|
100
|
+
active_window(): Promise<ActiveWindowInfo>;
|
|
101
|
+
application_state(appName?: string): Promise<DesktopApplicationState[]>;
|
|
66
102
|
getMousePosition(): Promise<{
|
|
67
103
|
x: number;
|
|
68
104
|
y: number;
|
|
@@ -105,6 +141,7 @@ export declare class SystemComputerController implements IComputerController {
|
|
|
105
141
|
mouseUp(x?: number, y?: number, button?: 'left' | 'right' | 'middle'): Promise<ComputerActionResult>;
|
|
106
142
|
mouseMove(x: number, y: number): Promise<ComputerActionResult>;
|
|
107
143
|
move(x: number, y: number): Promise<ComputerActionResult>;
|
|
144
|
+
move_mouse(x: number, y: number): Promise<ComputerActionResult>;
|
|
108
145
|
drag(startX: number, startY: number, endX: number, endY: number): Promise<ComputerActionResult>;
|
|
109
146
|
scroll(deltaX: number, deltaY: number): Promise<ComputerActionResult>;
|
|
110
147
|
getMousePosition(): Promise<{
|
|
@@ -114,8 +151,15 @@ export declare class SystemComputerController implements IComputerController {
|
|
|
114
151
|
runDiagnostic(): Promise<ComputerActionResult>;
|
|
115
152
|
type(text: string): Promise<ComputerActionResult>;
|
|
116
153
|
keyPress(key: string): Promise<ComputerActionResult>;
|
|
154
|
+
key_press(key: string): Promise<ComputerActionResult>;
|
|
117
155
|
hotkey(keys: string[]): Promise<ComputerActionResult>;
|
|
118
156
|
wait(ms: number): Promise<void>;
|
|
157
|
+
resolveCanonicalApp(appName: string, args?: string[]): {
|
|
158
|
+
canonicalCmd: string;
|
|
159
|
+
args: string[];
|
|
160
|
+
titleTerms: string[];
|
|
161
|
+
processNames: string[];
|
|
162
|
+
};
|
|
119
163
|
openApplication(appName: string, args?: string[]): Promise<ComputerActionResult>;
|
|
120
164
|
closeApplication(appName: string): Promise<ComputerActionResult>;
|
|
121
165
|
switchWindow(windowTitleOrApp: string): Promise<ComputerActionResult>;
|
|
@@ -126,5 +170,10 @@ export declare class SystemComputerController implements IComputerController {
|
|
|
126
170
|
height: number;
|
|
127
171
|
} | null>;
|
|
128
172
|
inspectUI(): Promise<UIInspectionResult>;
|
|
173
|
+
active_window(): Promise<ActiveWindowInfo>;
|
|
174
|
+
application_state(appName?: string): Promise<DesktopApplicationState[]>;
|
|
175
|
+
switch_to_app(appType: SupportedAppType | string): Promise<ComputerActionResult>;
|
|
129
176
|
}
|
|
177
|
+
export type ComputerController = IComputerController;
|
|
178
|
+
export declare const ComputerController: typeof SystemComputerController;
|
|
130
179
|
//# sourceMappingURL=computerController.d.ts.map
|
|
@@ -8,6 +8,39 @@ const __dirname = path.dirname(__filename);
|
|
|
8
8
|
const execAsync = promisify(exec);
|
|
9
9
|
const execFileAsync = promisify(execFile);
|
|
10
10
|
import { OperatorHud } from './operatorHud.js';
|
|
11
|
+
export function classifyAppType(windowTitleOrApp) {
|
|
12
|
+
const lower = (windowTitleOrApp || '').toLowerCase().trim();
|
|
13
|
+
if (/chrome|edge|msedge|brave|firefox|opera|browser|safari|github/i.test(lower)) {
|
|
14
|
+
return 'browser';
|
|
15
|
+
}
|
|
16
|
+
if (/terminal|wt|windows\s*terminal|powershell|pwsh|cmd|bash|wsl|command\s*prompt|zsh|git\s*bash/i.test(lower)) {
|
|
17
|
+
return 'terminal';
|
|
18
|
+
}
|
|
19
|
+
if (/code|cursor|notepad|sublime|atom|vim|neovim|ide|editor/i.test(lower)) {
|
|
20
|
+
return 'editor';
|
|
21
|
+
}
|
|
22
|
+
if (/explorer|file\s*explorer|finder|nautilus|dolphin|files/i.test(lower)) {
|
|
23
|
+
return 'file_manager';
|
|
24
|
+
}
|
|
25
|
+
return 'other';
|
|
26
|
+
}
|
|
27
|
+
export function getDesktopActionRiskLevel(action) {
|
|
28
|
+
const act = action.toLowerCase().trim();
|
|
29
|
+
// Level 0: Read-only inspection
|
|
30
|
+
if (['screenshot', 'active_window', 'activewindow', 'application_state', 'applicationstate', 'inspectui', 'getmouseposition', 'diagnostic', 'position'].includes(act)) {
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
// Level 1: Reversible input modification
|
|
34
|
+
if (['move', 'move_mouse', 'movemouse', 'mousemove', 'type', 'key_press', 'keypress', 'click', 'leftclick', 'rightclick', 'doubleclick', 'drag', 'scroll', 'switchwindow', 'switch_to_app', 'switchtoapp'].includes(act)) {
|
|
35
|
+
return 1;
|
|
36
|
+
}
|
|
37
|
+
// Level 2: External side effects / process launching
|
|
38
|
+
if (['openapplication', 'closeapplication', 'hotkey'].includes(act)) {
|
|
39
|
+
return 2;
|
|
40
|
+
}
|
|
41
|
+
// Level 3: High impact / destructive
|
|
42
|
+
return 3;
|
|
43
|
+
}
|
|
11
44
|
export class SystemComputerController {
|
|
12
45
|
workspaceDir;
|
|
13
46
|
screenshotsDir;
|
|
@@ -440,6 +473,9 @@ if ($act -eq "move") {
|
|
|
440
473
|
coordinates: { x, y },
|
|
441
474
|
};
|
|
442
475
|
}
|
|
476
|
+
async move_mouse(x, y) {
|
|
477
|
+
return this.move(x, y);
|
|
478
|
+
}
|
|
443
479
|
async drag(startX, startY, endX, endY) {
|
|
444
480
|
if (process.platform === 'win32') {
|
|
445
481
|
const res = await this.runDriverAction('drag', [startX, startY, endX, endY]);
|
|
@@ -564,6 +600,9 @@ if ($act -eq "move") {
|
|
|
564
600
|
}
|
|
565
601
|
return { success: true, output: `Simulated key press: ${key}`, action: 'key_press' };
|
|
566
602
|
}
|
|
603
|
+
async key_press(key) {
|
|
604
|
+
return this.keyPress(key);
|
|
605
|
+
}
|
|
567
606
|
async hotkey(keys) {
|
|
568
607
|
if (!keys || keys.length === 0) {
|
|
569
608
|
return { success: false, output: 'No keys provided for hotkey', action: 'hotkey', error: 'No keys provided' };
|
|
@@ -597,16 +636,136 @@ if ($act -eq "move") {
|
|
|
597
636
|
async wait(ms) {
|
|
598
637
|
return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
599
638
|
}
|
|
600
|
-
|
|
639
|
+
resolveCanonicalApp(appName, args = []) {
|
|
601
640
|
const appLower = appName.toLowerCase().trim();
|
|
602
|
-
|
|
641
|
+
let canonicalCmd = appName.trim();
|
|
642
|
+
let appArgs = [...args];
|
|
643
|
+
let titleTerms = [appName.trim()];
|
|
644
|
+
let processNames = [appName.trim().replace(/\.exe$/i, '')];
|
|
645
|
+
if (appLower === 'calc' || appLower === 'calculator' || appLower === 'wincalc') {
|
|
646
|
+
canonicalCmd = 'calc.exe';
|
|
647
|
+
titleTerms.push('calculator', 'calc');
|
|
648
|
+
processNames.push('calc', 'CalculatorApp', 'Calculator');
|
|
649
|
+
}
|
|
650
|
+
else if (appLower === 'notepad' || appLower === 'text editor' || appLower === 'editor') {
|
|
651
|
+
canonicalCmd = 'notepad.exe';
|
|
652
|
+
titleTerms.push('notepad');
|
|
653
|
+
processNames.push('notepad');
|
|
654
|
+
}
|
|
655
|
+
else if (appLower === 'code' || appLower === 'vscode' || appLower === 'vs code' || appLower === 'visual studio code') {
|
|
656
|
+
canonicalCmd = 'code';
|
|
657
|
+
titleTerms.push('visual studio code', 'code');
|
|
658
|
+
processNames.push('Code');
|
|
659
|
+
}
|
|
660
|
+
else if (appLower === 'chrome' || appLower === 'google chrome' || appLower === 'google-chrome' || appLower === 'browser') {
|
|
661
|
+
const chromeCandidates = [
|
|
662
|
+
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
|
|
663
|
+
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
|
|
664
|
+
process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, 'Google', 'Chrome', 'Application', 'chrome.exe') : '',
|
|
665
|
+
].filter(Boolean);
|
|
666
|
+
const found = chromeCandidates.find((p) => fs.existsSync(p));
|
|
667
|
+
canonicalCmd = found || 'chrome.exe';
|
|
668
|
+
titleTerms.push('chrome', 'google chrome');
|
|
669
|
+
processNames.push('chrome');
|
|
670
|
+
}
|
|
671
|
+
else if (appLower === 'edge' || appLower === 'msedge' || appLower === 'microsoft edge') {
|
|
672
|
+
const edgeCandidates = [
|
|
673
|
+
'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe',
|
|
674
|
+
'C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe',
|
|
675
|
+
];
|
|
676
|
+
const found = edgeCandidates.find((p) => fs.existsSync(p));
|
|
677
|
+
canonicalCmd = found || 'msedge.exe';
|
|
678
|
+
titleTerms.push('edge', 'microsoft edge');
|
|
679
|
+
processNames.push('msedge');
|
|
680
|
+
}
|
|
681
|
+
else if (appLower === 'brave' || appLower === 'brave browser') {
|
|
682
|
+
const braveCandidates = [
|
|
683
|
+
'C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe',
|
|
684
|
+
process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, 'BraveSoftware', 'Brave-Browser', 'Application', 'brave.exe') : '',
|
|
685
|
+
].filter(Boolean);
|
|
686
|
+
const found = braveCandidates.find((p) => fs.existsSync(p));
|
|
687
|
+
canonicalCmd = found || 'brave.exe';
|
|
688
|
+
titleTerms.push('brave');
|
|
689
|
+
processNames.push('brave');
|
|
690
|
+
}
|
|
691
|
+
else if (appLower === 'explorer' || appLower === 'file explorer' || appLower === 'files') {
|
|
692
|
+
canonicalCmd = 'explorer.exe';
|
|
693
|
+
if (appArgs.length === 0)
|
|
694
|
+
appArgs.push('.');
|
|
695
|
+
titleTerms.push('file explorer', 'explorer');
|
|
696
|
+
processNames.push('explorer');
|
|
697
|
+
}
|
|
698
|
+
else if (appLower === 'terminal' || appLower === 'wt' || appLower === 'windows terminal') {
|
|
699
|
+
canonicalCmd = 'wt.exe';
|
|
700
|
+
titleTerms.push('terminal', 'windows terminal');
|
|
701
|
+
processNames.push('WindowsTerminal', 'wt');
|
|
702
|
+
}
|
|
703
|
+
else if (appLower === 'cmd' || appLower === 'command prompt') {
|
|
704
|
+
canonicalCmd = 'cmd.exe';
|
|
705
|
+
titleTerms.push('cmd', 'command prompt');
|
|
706
|
+
processNames.push('cmd');
|
|
707
|
+
}
|
|
708
|
+
else if (appLower === 'powershell' || appLower === 'pwsh') {
|
|
709
|
+
canonicalCmd = 'powershell.exe';
|
|
710
|
+
titleTerms.push('powershell');
|
|
711
|
+
processNames.push('powershell', 'pwsh');
|
|
712
|
+
}
|
|
713
|
+
else if (appLower === 'paint' || appLower === 'mspaint') {
|
|
714
|
+
canonicalCmd = 'mspaint.exe';
|
|
715
|
+
titleTerms.push('paint');
|
|
716
|
+
processNames.push('mspaint');
|
|
717
|
+
}
|
|
718
|
+
else if (appLower === 'spotify') {
|
|
719
|
+
const appData = process.env.APPDATA ? path.join(process.env.APPDATA, 'Spotify', 'Spotify.exe') : '';
|
|
720
|
+
canonicalCmd = (appData && fs.existsSync(appData)) ? appData : 'spotify.exe';
|
|
721
|
+
titleTerms.push('spotify');
|
|
722
|
+
processNames.push('Spotify');
|
|
723
|
+
}
|
|
724
|
+
else if (appLower.includes('blender')) {
|
|
725
|
+
const candidatePaths = [
|
|
726
|
+
'C:\\Program Files\\Blender Foundation\\Blender 5.2\\blender.exe',
|
|
727
|
+
'C:\\Program Files\\Blender Foundation\\Blender 5.1\\blender.exe',
|
|
728
|
+
'C:\\Program Files\\Blender Foundation\\Blender 5.0\\blender.exe',
|
|
729
|
+
'C:\\Program Files\\Blender Foundation\\Blender 4.3\\blender.exe',
|
|
730
|
+
'C:\\Program Files\\Blender Foundation\\Blender 4.2\\blender.exe',
|
|
731
|
+
];
|
|
732
|
+
let resolvedBlender = candidatePaths.find((p) => fs.existsSync(p));
|
|
733
|
+
if (!resolvedBlender) {
|
|
734
|
+
const bfDir = 'C:\\Program Files\\Blender Foundation';
|
|
735
|
+
if (fs.existsSync(bfDir)) {
|
|
736
|
+
try {
|
|
737
|
+
const subdirs = fs.readdirSync(bfDir);
|
|
738
|
+
for (const sub of subdirs) {
|
|
739
|
+
const cand = path.join(bfDir, sub, 'blender.exe');
|
|
740
|
+
if (fs.existsSync(cand)) {
|
|
741
|
+
resolvedBlender = cand;
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
catch { }
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
if (resolvedBlender) {
|
|
750
|
+
canonicalCmd = resolvedBlender;
|
|
751
|
+
}
|
|
752
|
+
titleTerms.push('blender');
|
|
753
|
+
processNames.push('blender');
|
|
754
|
+
}
|
|
755
|
+
return { canonicalCmd, args: appArgs, titleTerms, processNames };
|
|
756
|
+
}
|
|
757
|
+
async openApplication(appName, args = []) {
|
|
758
|
+
const resolved = this.resolveCanonicalApp(appName, args);
|
|
759
|
+
const canonicalCmd = resolved.canonicalCmd;
|
|
760
|
+
const finalArgs = resolved.args;
|
|
761
|
+
const argsStr = finalArgs.join(' ');
|
|
603
762
|
try {
|
|
604
763
|
if (process.platform === 'win32') {
|
|
605
|
-
const driverRes = await this.runDriverAction('launch',
|
|
764
|
+
const driverRes = await this.runDriverAction('launch', finalArgs.length > 0 ? [canonicalCmd, argsStr] : [canonicalCmd]);
|
|
606
765
|
if (!driverRes || !driverRes.success) {
|
|
607
766
|
const spawnDetached = (cmd, a = []) => {
|
|
608
767
|
try {
|
|
609
|
-
const child = spawn('cmd.exe', ['/c', 'start', '
|
|
768
|
+
const child = spawn('cmd.exe', ['/c', 'start', '', cmd, ...a], {
|
|
610
769
|
detached: true,
|
|
611
770
|
stdio: 'ignore',
|
|
612
771
|
windowsHide: true,
|
|
@@ -615,110 +774,19 @@ if ($act -eq "move") {
|
|
|
615
774
|
}
|
|
616
775
|
catch { }
|
|
617
776
|
};
|
|
618
|
-
|
|
619
|
-
spawnDetached('code', argsStr ? [argsStr] : []);
|
|
620
|
-
}
|
|
621
|
-
else if (appLower === 'explorer' || appLower === 'file explorer') {
|
|
622
|
-
spawnDetached('explorer', [argsStr || '.']);
|
|
623
|
-
}
|
|
624
|
-
else if (appLower === 'notepad') {
|
|
625
|
-
spawnDetached('notepad', argsStr ? [argsStr] : []);
|
|
626
|
-
}
|
|
627
|
-
else if (appLower === 'terminal' || appLower === 'cmd' || appLower === 'powershell') {
|
|
628
|
-
spawnDetached('powershell', argsStr ? [argsStr] : []);
|
|
629
|
-
}
|
|
630
|
-
else if (appLower.includes('blender')) {
|
|
631
|
-
const candidatePaths = [
|
|
632
|
-
'C:\\Program Files\\Blender Foundation\\Blender 5.2\\blender.exe',
|
|
633
|
-
'C:\\Program Files\\Blender Foundation\\Blender 5.1\\blender.exe',
|
|
634
|
-
'C:\\Program Files\\Blender Foundation\\Blender 5.0\\blender.exe',
|
|
635
|
-
'C:\\Program Files\\Blender Foundation\\Blender 4.3\\blender.exe',
|
|
636
|
-
'C:\\Program Files\\Blender Foundation\\Blender 4.2\\blender.exe',
|
|
637
|
-
];
|
|
638
|
-
let resolvedBlender = candidatePaths.find((p) => fs.existsSync(p));
|
|
639
|
-
if (!resolvedBlender) {
|
|
640
|
-
const bfDir = 'C:\\Program Files\\Blender Foundation';
|
|
641
|
-
if (fs.existsSync(bfDir)) {
|
|
642
|
-
try {
|
|
643
|
-
const subdirs = fs.readdirSync(bfDir);
|
|
644
|
-
for (const sub of subdirs) {
|
|
645
|
-
const cand = path.join(bfDir, sub, 'blender.exe');
|
|
646
|
-
if (fs.existsSync(cand)) {
|
|
647
|
-
resolvedBlender = cand;
|
|
648
|
-
break;
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
catch { }
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
const serverScript = path.resolve(process.cwd(), '.ft', 'scripts', 'start_blender_mcp.py');
|
|
656
|
-
if (resolvedBlender) {
|
|
657
|
-
const pyArg = fs.existsSync(serverScript) ? `-ArgumentList @('--python', '${serverScript.replace(/\\/g, '\\\\')}')` : '';
|
|
658
|
-
await execAsync(`powershell -NoProfile -Command "Start-Process '${resolvedBlender}' ${pyArg} -WindowStyle Minimized"`);
|
|
659
|
-
}
|
|
660
|
-
else {
|
|
661
|
-
spawnDetached(appName, argsStr ? [argsStr] : []);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
else if (appLower === 'chrome' || appLower === 'google chrome' || appLower === 'google-chrome') {
|
|
665
|
-
const chromeCandidates = [
|
|
666
|
-
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
|
|
667
|
-
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
|
|
668
|
-
process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, 'Google', 'Chrome', 'Application', 'chrome.exe') : '',
|
|
669
|
-
].filter(Boolean);
|
|
670
|
-
const resolvedChrome = chromeCandidates.find((p) => fs.existsSync(p));
|
|
671
|
-
if (resolvedChrome) {
|
|
672
|
-
spawnDetached(resolvedChrome, argsStr ? [argsStr] : []);
|
|
673
|
-
}
|
|
674
|
-
else {
|
|
675
|
-
spawnDetached('chrome', argsStr ? [argsStr] : []);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
else if (appLower === 'edge' || appLower === 'msedge' || appLower === 'microsoft edge') {
|
|
679
|
-
const edgeCandidates = [
|
|
680
|
-
'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe',
|
|
681
|
-
'C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe',
|
|
682
|
-
];
|
|
683
|
-
const resolvedEdge = edgeCandidates.find((p) => fs.existsSync(p));
|
|
684
|
-
if (resolvedEdge) {
|
|
685
|
-
spawnDetached(resolvedEdge, argsStr ? [argsStr] : []);
|
|
686
|
-
}
|
|
687
|
-
else {
|
|
688
|
-
spawnDetached('msedge', argsStr ? [argsStr] : []);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
else if (appLower === 'brave' || appLower === 'brave browser') {
|
|
692
|
-
const braveCandidates = [
|
|
693
|
-
'C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe',
|
|
694
|
-
process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, 'BraveSoftware', 'Brave-Browser', 'Application', 'brave.exe') : '',
|
|
695
|
-
].filter(Boolean);
|
|
696
|
-
const resolvedBrave = braveCandidates.find((p) => fs.existsSync(p));
|
|
697
|
-
if (resolvedBrave) {
|
|
698
|
-
spawnDetached(resolvedBrave, argsStr ? [argsStr] : []);
|
|
699
|
-
}
|
|
700
|
-
else {
|
|
701
|
-
spawnDetached('brave', argsStr ? [argsStr] : []);
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
else if (appLower === 'calc' || appLower === 'calculator') {
|
|
705
|
-
spawnDetached('calc');
|
|
706
|
-
}
|
|
707
|
-
else if (appLower === 'mspaint' || appLower === 'paint') {
|
|
708
|
-
spawnDetached('mspaint');
|
|
709
|
-
}
|
|
710
|
-
else {
|
|
711
|
-
spawnDetached(appName, argsStr ? [argsStr] : []);
|
|
712
|
-
}
|
|
777
|
+
spawnDetached(canonicalCmd, finalArgs);
|
|
713
778
|
}
|
|
714
779
|
this.expectedApplication = appName;
|
|
715
780
|
// Observation-based wait: poll inspectUI to confirm window appeared
|
|
716
|
-
const delays = [
|
|
781
|
+
const delays = [300, 600, 1000];
|
|
717
782
|
for (const delay of delays) {
|
|
718
783
|
await this.wait(delay);
|
|
719
784
|
const ui = await this.inspectUI();
|
|
720
|
-
const match = ui.windows.some(w =>
|
|
721
|
-
|
|
785
|
+
const match = ui.windows.some(w => {
|
|
786
|
+
const wLower = w.toLowerCase();
|
|
787
|
+
return resolved.titleTerms.some(term => wLower.includes(term.toLowerCase()));
|
|
788
|
+
});
|
|
789
|
+
if (match || (ui.activeWindow && resolved.titleTerms.some(term => ui.activeWindow.toLowerCase().includes(term.toLowerCase())))) {
|
|
722
790
|
break;
|
|
723
791
|
}
|
|
724
792
|
}
|
|
@@ -762,10 +830,15 @@ if ($act -eq "move") {
|
|
|
762
830
|
async closeApplication(appName) {
|
|
763
831
|
try {
|
|
764
832
|
if (process.platform === 'win32') {
|
|
765
|
-
const
|
|
833
|
+
const resolved = this.resolveCanonicalApp(appName);
|
|
766
834
|
const driverRes = await this.runDriverAction('close_window', [appName]);
|
|
767
835
|
if (!driverRes || !driverRes.success) {
|
|
768
|
-
|
|
836
|
+
for (const pName of resolved.processNames) {
|
|
837
|
+
try {
|
|
838
|
+
await execAsync(`powershell -NoProfile -Command "Stop-Process -Name '${pName}' -Force -ErrorAction SilentlyContinue"`);
|
|
839
|
+
}
|
|
840
|
+
catch { }
|
|
841
|
+
}
|
|
769
842
|
}
|
|
770
843
|
}
|
|
771
844
|
else {
|
|
@@ -876,5 +949,77 @@ if ($result) { Write-Output "OK" } else { Write-Output "NOT_FOUND" }
|
|
|
876
949
|
}
|
|
877
950
|
return { activeWindow: 'Desktop', windows: ['Desktop', 'Terminal'] };
|
|
878
951
|
}
|
|
952
|
+
async active_window() {
|
|
953
|
+
const ui = await this.inspectUI();
|
|
954
|
+
const title = ui.activeWindow || this.activeWindow || 'Desktop';
|
|
955
|
+
const appType = classifyAppType(title);
|
|
956
|
+
let bounds;
|
|
957
|
+
try {
|
|
958
|
+
const b = await this.getWindowBounds(title);
|
|
959
|
+
if (b)
|
|
960
|
+
bounds = b;
|
|
961
|
+
}
|
|
962
|
+
catch { }
|
|
963
|
+
return {
|
|
964
|
+
title,
|
|
965
|
+
appName: title.split(/[-—·]/)[0]?.trim() || title,
|
|
966
|
+
appType,
|
|
967
|
+
bounds: bounds || undefined,
|
|
968
|
+
isResponding: true,
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
async application_state(appName) {
|
|
972
|
+
const ui = await this.inspectUI();
|
|
973
|
+
const activeWin = ui.activeWindow || 'Desktop';
|
|
974
|
+
const states = [];
|
|
975
|
+
for (const win of ui.windows) {
|
|
976
|
+
if (!win || win === 'Desktop')
|
|
977
|
+
continue;
|
|
978
|
+
const appType = classifyAppType(win);
|
|
979
|
+
const isFocused = win.toLowerCase() === activeWin.toLowerCase() ||
|
|
980
|
+
(activeWin !== 'Desktop' && win.toLowerCase().includes(activeWin.toLowerCase()));
|
|
981
|
+
if (appName && !win.toLowerCase().includes(appName.toLowerCase())) {
|
|
982
|
+
continue;
|
|
983
|
+
}
|
|
984
|
+
let bounds;
|
|
985
|
+
try {
|
|
986
|
+
const b = await this.getWindowBounds(win);
|
|
987
|
+
if (b)
|
|
988
|
+
bounds = b;
|
|
989
|
+
}
|
|
990
|
+
catch { }
|
|
991
|
+
states.push({
|
|
992
|
+
appName: win.split(/[-—·]/)[0]?.trim() || win,
|
|
993
|
+
appType,
|
|
994
|
+
isRunning: true,
|
|
995
|
+
isFocused,
|
|
996
|
+
windowTitle: win,
|
|
997
|
+
bounds: bounds || undefined,
|
|
998
|
+
canAcceptInput: true,
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
return states;
|
|
1002
|
+
}
|
|
1003
|
+
async switch_to_app(appType) {
|
|
1004
|
+
const target = appType.toLowerCase().trim();
|
|
1005
|
+
const ui = await this.inspectUI();
|
|
1006
|
+
// 1. Check if an application of this type is already open
|
|
1007
|
+
const openMatch = ui.windows.find(w => classifyAppType(w) === target || w.toLowerCase().includes(target));
|
|
1008
|
+
if (openMatch) {
|
|
1009
|
+
return await this.switchWindow(openMatch);
|
|
1010
|
+
}
|
|
1011
|
+
// 2. Not running: Launch canonical default application for this category
|
|
1012
|
+
let defaultApp = target;
|
|
1013
|
+
if (target === 'browser')
|
|
1014
|
+
defaultApp = 'chrome';
|
|
1015
|
+
else if (target === 'terminal')
|
|
1016
|
+
defaultApp = 'wt';
|
|
1017
|
+
else if (target === 'editor')
|
|
1018
|
+
defaultApp = 'notepad';
|
|
1019
|
+
else if (target === 'file_manager')
|
|
1020
|
+
defaultApp = 'explorer';
|
|
1021
|
+
return await this.openApplication(defaultApp);
|
|
1022
|
+
}
|
|
879
1023
|
}
|
|
1024
|
+
export const ComputerController = SystemComputerController;
|
|
880
1025
|
//# sourceMappingURL=computerController.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IComputerController, ScreenCaptureResult, ComputerActionResult, UIInspectionResult } from './computerController.js';
|
|
1
|
+
import type { IComputerController, ScreenCaptureResult, ComputerActionResult, UIInspectionResult, ActiveWindowInfo, DesktopApplicationState, SupportedAppType } from './computerController.js';
|
|
2
2
|
export declare class MockComputerController implements IComputerController {
|
|
3
3
|
activeWindow: string;
|
|
4
4
|
expectedApplication: string | null;
|
|
@@ -31,10 +31,12 @@ export declare class MockComputerController implements IComputerController {
|
|
|
31
31
|
mouseUp(x?: number, y?: number, button?: 'left' | 'right' | 'middle'): Promise<ComputerActionResult>;
|
|
32
32
|
type(text: string): Promise<ComputerActionResult>;
|
|
33
33
|
keyPress(key: string): Promise<ComputerActionResult>;
|
|
34
|
+
key_press(key: string): Promise<ComputerActionResult>;
|
|
34
35
|
hotkey(keys: string[]): Promise<ComputerActionResult>;
|
|
35
36
|
scroll(deltaX: number, deltaY: number): Promise<ComputerActionResult>;
|
|
36
37
|
mouseMove(x: number, y: number): Promise<ComputerActionResult>;
|
|
37
38
|
move(x: number, y: number): Promise<ComputerActionResult>;
|
|
39
|
+
move_mouse(x: number, y: number): Promise<ComputerActionResult>;
|
|
38
40
|
drag(fromX: number, fromY: number, toX: number, toY: number): Promise<ComputerActionResult>;
|
|
39
41
|
wait(ms: number): Promise<void>;
|
|
40
42
|
getMousePosition(): Promise<{
|
|
@@ -52,6 +54,9 @@ export declare class MockComputerController implements IComputerController {
|
|
|
52
54
|
height: number;
|
|
53
55
|
} | null>;
|
|
54
56
|
inspectUI(): Promise<UIInspectionResult>;
|
|
57
|
+
active_window(): Promise<ActiveWindowInfo>;
|
|
58
|
+
application_state(appName?: string): Promise<DesktopApplicationState[]>;
|
|
59
|
+
switch_to_app(appType: SupportedAppType | string): Promise<ComputerActionResult>;
|
|
55
60
|
getActionLog(): Array<{
|
|
56
61
|
action: string;
|
|
57
62
|
args: any;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { classifyAppType } from './computerController.js';
|
|
1
2
|
export class MockComputerController {
|
|
2
3
|
activeWindow = 'Desktop';
|
|
3
4
|
expectedApplication = null;
|
|
@@ -139,6 +140,9 @@ export class MockComputerController {
|
|
|
139
140
|
this.log('keyPress', { key });
|
|
140
141
|
return { success: true, output: `Pressed key: ${key}`, action: 'key_press' };
|
|
141
142
|
}
|
|
143
|
+
async key_press(key) {
|
|
144
|
+
return this.keyPress(key);
|
|
145
|
+
}
|
|
142
146
|
async hotkey(keys) {
|
|
143
147
|
this.log('hotkey', { keys });
|
|
144
148
|
return { success: true, output: `Executed hotkey: ${keys.join('+')}`, action: 'hotkey' };
|
|
@@ -162,6 +166,9 @@ export class MockComputerController {
|
|
|
162
166
|
activeWindow: this.activeWindow,
|
|
163
167
|
};
|
|
164
168
|
}
|
|
169
|
+
async move_mouse(x, y) {
|
|
170
|
+
return this.move(x, y);
|
|
171
|
+
}
|
|
165
172
|
async drag(fromX, fromY, toX, toY) {
|
|
166
173
|
this.currentX = toX;
|
|
167
174
|
this.currentY = toY;
|
|
@@ -250,6 +257,57 @@ export class MockComputerController {
|
|
|
250
257
|
focusedElement: 'MainView',
|
|
251
258
|
};
|
|
252
259
|
}
|
|
260
|
+
async active_window() {
|
|
261
|
+
this.log('active_window', {});
|
|
262
|
+
const appType = classifyAppType(this.activeWindow);
|
|
263
|
+
return {
|
|
264
|
+
title: this.activeWindow,
|
|
265
|
+
appName: this.activeWindow.split(/[-—·]/)[0]?.trim() || this.activeWindow,
|
|
266
|
+
appType,
|
|
267
|
+
bounds: { x: 0, y: 0, width: this.screenWidth, height: this.screenHeight },
|
|
268
|
+
isResponding: true,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
async application_state(appName) {
|
|
272
|
+
this.log('application_state', { appName });
|
|
273
|
+
const states = [];
|
|
274
|
+
for (const win of this.openWindows) {
|
|
275
|
+
if (appName && !win.toLowerCase().includes(appName.toLowerCase())) {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
const appType = classifyAppType(win);
|
|
279
|
+
states.push({
|
|
280
|
+
appName: win.split(/[-—·]/)[0]?.trim() || win,
|
|
281
|
+
appType,
|
|
282
|
+
isRunning: true,
|
|
283
|
+
isFocused: win === this.activeWindow,
|
|
284
|
+
windowTitle: win,
|
|
285
|
+
bounds: { x: 0, y: 0, width: this.screenWidth, height: this.screenHeight },
|
|
286
|
+
canAcceptInput: true,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
return states;
|
|
290
|
+
}
|
|
291
|
+
async switch_to_app(appType) {
|
|
292
|
+
this.log('switch_to_app', { appType });
|
|
293
|
+
const target = appType.toLowerCase().trim();
|
|
294
|
+
// 1. Check if an application of this category is open
|
|
295
|
+
const openMatch = this.openWindows.find(w => classifyAppType(w) === target || w.toLowerCase().includes(target));
|
|
296
|
+
if (openMatch) {
|
|
297
|
+
return await this.switchWindow(openMatch);
|
|
298
|
+
}
|
|
299
|
+
// 2. Open default application for this category
|
|
300
|
+
let defaultName = target;
|
|
301
|
+
if (target === 'browser')
|
|
302
|
+
defaultName = 'Google Chrome';
|
|
303
|
+
else if (target === 'terminal')
|
|
304
|
+
defaultName = 'Terminal';
|
|
305
|
+
else if (target === 'editor')
|
|
306
|
+
defaultName = 'VS Code';
|
|
307
|
+
else if (target === 'file_manager')
|
|
308
|
+
defaultName = 'File Explorer';
|
|
309
|
+
return await this.openApplication(defaultName);
|
|
310
|
+
}
|
|
253
311
|
getActionLog() {
|
|
254
312
|
return [...this.actionLog];
|
|
255
313
|
}
|