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
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
import {} from './types.js';
|
|
2
|
+
import { BrowserHandler, ComputerHandler, TerminalHandler, FilesystemHandler, GitHandler, SearchHandler, ApiHandler, } from './domainHandlers.js';
|
|
3
|
+
export class UnifiedToolRouter {
|
|
4
|
+
handlers = new Map();
|
|
5
|
+
constructor(customHandlers) {
|
|
6
|
+
// Register default handlers
|
|
7
|
+
this.handlers.set('browser', customHandlers?.browser ?? new BrowserHandler());
|
|
8
|
+
this.handlers.set('computer', customHandlers?.computer ?? new ComputerHandler());
|
|
9
|
+
this.handlers.set('terminal', customHandlers?.terminal ?? new TerminalHandler());
|
|
10
|
+
this.handlers.set('filesystem', customHandlers?.filesystem ?? new FilesystemHandler());
|
|
11
|
+
this.handlers.set('git', customHandlers?.git ?? new GitHandler());
|
|
12
|
+
this.handlers.set('search', customHandlers?.search ?? new SearchHandler());
|
|
13
|
+
this.handlers.set('api', customHandlers?.api ?? new ApiHandler());
|
|
14
|
+
}
|
|
15
|
+
registerHandler(domain, handler) {
|
|
16
|
+
this.handlers.set(domain, handler);
|
|
17
|
+
}
|
|
18
|
+
getHandler(domain) {
|
|
19
|
+
return this.handlers.get(domain);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Automatic Tool Selection:
|
|
23
|
+
* Analyzes natural language action intent + execution context to select the optimal domain and tool.
|
|
24
|
+
*/
|
|
25
|
+
route(goalOrTask, context) {
|
|
26
|
+
const text = String(goalOrTask || '').trim();
|
|
27
|
+
const lower = text.toLowerCase();
|
|
28
|
+
// 1. Browser domain routing
|
|
29
|
+
const urlMatch = text.match(/https?:\/\/[^\s"'<>]+/i);
|
|
30
|
+
if (urlMatch ||
|
|
31
|
+
lower.includes('browse') ||
|
|
32
|
+
lower.includes('webpage') ||
|
|
33
|
+
lower.includes('website') ||
|
|
34
|
+
lower.includes('url') ||
|
|
35
|
+
lower.includes('navigate to') ||
|
|
36
|
+
(context?.hasBrowser && (lower.includes('page') || lower.includes('click') || lower.includes('form')))) {
|
|
37
|
+
if (urlMatch || lower.includes('navigate') || lower.includes('open site') || lower.includes('open url')) {
|
|
38
|
+
return {
|
|
39
|
+
domain: 'browser',
|
|
40
|
+
tool: 'browser_navigate',
|
|
41
|
+
confidence: 0.95,
|
|
42
|
+
rationale: 'URL or webpage navigation requested.',
|
|
43
|
+
extractedArgs: urlMatch ? { url: urlMatch[0] } : undefined,
|
|
44
|
+
riskLevel: 0, // Read-only
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (lower.includes('click') || lower.includes('button') || lower.includes('link')) {
|
|
48
|
+
const buttonMatch = text.match(/["']([^"']+)["']/);
|
|
49
|
+
return {
|
|
50
|
+
domain: 'browser',
|
|
51
|
+
tool: 'browser_click',
|
|
52
|
+
confidence: 0.9,
|
|
53
|
+
rationale: 'Web element click requested.',
|
|
54
|
+
extractedArgs: buttonMatch ? { selectorOrText: buttonMatch[1] } : undefined,
|
|
55
|
+
riskLevel: lower.includes('submit') || lower.includes('delete') || lower.includes('buy') ? 2 : 1,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (lower.includes('type') || lower.includes('fill') || lower.includes('enter text')) {
|
|
59
|
+
return {
|
|
60
|
+
domain: 'browser',
|
|
61
|
+
tool: 'browser_type',
|
|
62
|
+
confidence: 0.9,
|
|
63
|
+
rationale: 'Web input typing requested.',
|
|
64
|
+
riskLevel: 1,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (lower.includes('inspect') || lower.includes('dom') || lower.includes('elements') || lower.includes('read page')) {
|
|
68
|
+
return {
|
|
69
|
+
domain: 'browser',
|
|
70
|
+
tool: 'browser_inspect',
|
|
71
|
+
confidence: 0.9,
|
|
72
|
+
rationale: 'Web page DOM inspection requested.',
|
|
73
|
+
riskLevel: 0,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
domain: 'browser',
|
|
78
|
+
tool: 'browser_content',
|
|
79
|
+
confidence: 0.85,
|
|
80
|
+
rationale: 'Web page content extraction requested.',
|
|
81
|
+
riskLevel: 0,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// 2. Git domain routing
|
|
85
|
+
const isGitOperation = lower.startsWith('git ') ||
|
|
86
|
+
/\bgit\b/i.test(lower) ||
|
|
87
|
+
/\b(?:pull request|git status|git diff|git log|git commit|git branch)\b/i.test(lower);
|
|
88
|
+
if (isGitOperation) {
|
|
89
|
+
let tool = 'git_diff';
|
|
90
|
+
let risk = 0;
|
|
91
|
+
if (lower.includes('diff')) {
|
|
92
|
+
tool = 'git_diff';
|
|
93
|
+
}
|
|
94
|
+
else if (lower.includes('status')) {
|
|
95
|
+
tool = 'git_status';
|
|
96
|
+
}
|
|
97
|
+
else if (lower.includes('log')) {
|
|
98
|
+
tool = 'git_log';
|
|
99
|
+
}
|
|
100
|
+
else if (lower.includes('commit')) {
|
|
101
|
+
tool = 'git_commit';
|
|
102
|
+
risk = 1;
|
|
103
|
+
}
|
|
104
|
+
else if (lower.includes('branch')) {
|
|
105
|
+
tool = 'git_branch';
|
|
106
|
+
risk = 1;
|
|
107
|
+
}
|
|
108
|
+
else if (/\b(?:pull request|pr)\b/i.test(lower)) {
|
|
109
|
+
tool = 'git_pr';
|
|
110
|
+
risk = 2;
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
domain: 'git',
|
|
114
|
+
tool,
|
|
115
|
+
confidence: 0.95,
|
|
116
|
+
rationale: `Git version control operation: ${tool}`,
|
|
117
|
+
riskLevel: risk,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// 3. Filesystem domain routing
|
|
121
|
+
const hasFileWord = lower.includes('file') || lower.includes('directory') || lower.includes('folder');
|
|
122
|
+
const codeExtRegex = /\.(ts|js|json|md|py|java|cs|html|css|txt|yaml|yml)\b/i;
|
|
123
|
+
const fileInText = text.match(/([a-zA-Z0-9_\-./\\]+\.[a-zA-Z0-9]+)/);
|
|
124
|
+
if (hasFileWord || codeExtRegex.test(text)) {
|
|
125
|
+
if (lower.includes('read') || lower.includes('view') || lower.includes('cat ') || lower.includes('inspect file')) {
|
|
126
|
+
return {
|
|
127
|
+
domain: 'filesystem',
|
|
128
|
+
tool: 'read_file',
|
|
129
|
+
confidence: 0.92,
|
|
130
|
+
rationale: 'Reading file contents from workspace filesystem.',
|
|
131
|
+
extractedArgs: fileInText ? { path: fileInText[1] } : undefined,
|
|
132
|
+
riskLevel: 0,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (lower.includes('edit') || lower.includes('modify') || lower.includes('replace') || lower.includes('fix code') || lower.includes('patch')) {
|
|
136
|
+
return {
|
|
137
|
+
domain: 'filesystem',
|
|
138
|
+
tool: 'edit_file',
|
|
139
|
+
confidence: 0.92,
|
|
140
|
+
rationale: 'Modifying existing workspace file.',
|
|
141
|
+
extractedArgs: fileInText ? { path: fileInText[1] } : undefined,
|
|
142
|
+
riskLevel: 1,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
if (lower.includes('write') || lower.includes('create file') || lower.includes('save to')) {
|
|
146
|
+
return {
|
|
147
|
+
domain: 'filesystem',
|
|
148
|
+
tool: 'write_file',
|
|
149
|
+
confidence: 0.92,
|
|
150
|
+
rationale: 'Writing/creating file on workspace filesystem.',
|
|
151
|
+
extractedArgs: fileInText ? { path: fileInText[1] } : undefined,
|
|
152
|
+
riskLevel: 1,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (lower.includes('list') || lower.includes('ls') || lower.includes('dir')) {
|
|
156
|
+
return {
|
|
157
|
+
domain: 'filesystem',
|
|
158
|
+
tool: 'list_dir',
|
|
159
|
+
confidence: 0.88,
|
|
160
|
+
rationale: 'Listing directory contents.',
|
|
161
|
+
riskLevel: 0,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// 4. Computer / Desktop domain routing
|
|
166
|
+
if (context?.hasDesktopApp ||
|
|
167
|
+
lower.includes('desktop') ||
|
|
168
|
+
lower.includes('window') ||
|
|
169
|
+
lower.includes('screen') ||
|
|
170
|
+
lower.includes('mouse') ||
|
|
171
|
+
lower.includes('notepad') ||
|
|
172
|
+
lower.includes('calculator') ||
|
|
173
|
+
lower.includes('calc') ||
|
|
174
|
+
lower.includes('explorer') ||
|
|
175
|
+
lower.includes('paint') ||
|
|
176
|
+
lower.includes('switch window') ||
|
|
177
|
+
lower.includes('open app') ||
|
|
178
|
+
lower.includes('hotkey')) {
|
|
179
|
+
if (lower.includes('screenshot') || lower.includes('see screen') || lower.includes('capture screen')) {
|
|
180
|
+
return {
|
|
181
|
+
domain: 'computer',
|
|
182
|
+
tool: 'computer_screenshot',
|
|
183
|
+
confidence: 0.95,
|
|
184
|
+
rationale: 'Desktop screen capture requested.',
|
|
185
|
+
riskLevel: 0,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
if (lower.includes('open') || lower.includes('launch')) {
|
|
189
|
+
const appMatch = text.match(/(?:open|launch)\s+([a-zA-Z0-9_\-]+)/i);
|
|
190
|
+
return {
|
|
191
|
+
domain: 'computer',
|
|
192
|
+
tool: 'computer_open_app',
|
|
193
|
+
confidence: 0.9,
|
|
194
|
+
rationale: 'Launching desktop application.',
|
|
195
|
+
extractedArgs: appMatch ? { appName: appMatch[1] } : undefined,
|
|
196
|
+
riskLevel: 2,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (lower.includes('switch') || lower.includes('focus')) {
|
|
200
|
+
return {
|
|
201
|
+
domain: 'computer',
|
|
202
|
+
tool: 'computer_switch_window',
|
|
203
|
+
confidence: 0.9,
|
|
204
|
+
rationale: 'Switching active desktop window.',
|
|
205
|
+
riskLevel: 1,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
if (lower.includes('click')) {
|
|
209
|
+
return {
|
|
210
|
+
domain: 'computer',
|
|
211
|
+
tool: 'computer_click',
|
|
212
|
+
confidence: 0.88,
|
|
213
|
+
rationale: 'Desktop mouse click requested.',
|
|
214
|
+
riskLevel: 1,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
if (lower.includes('type')) {
|
|
218
|
+
return {
|
|
219
|
+
domain: 'computer',
|
|
220
|
+
tool: 'computer_type',
|
|
221
|
+
confidence: 0.88,
|
|
222
|
+
rationale: 'Desktop keyboard typing requested.',
|
|
223
|
+
riskLevel: 1,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
domain: 'computer',
|
|
228
|
+
tool: 'computer_inspect_ui',
|
|
229
|
+
confidence: 0.82,
|
|
230
|
+
rationale: 'Inspecting desktop application UI.',
|
|
231
|
+
riskLevel: 0,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
// 5. Search domain routing
|
|
235
|
+
if (lower.includes('grep') || lower.includes('search for') || lower.includes('find text')) {
|
|
236
|
+
const queryMatch = text.match(/["']([^"']+)["']/);
|
|
237
|
+
return {
|
|
238
|
+
domain: 'search',
|
|
239
|
+
tool: 'grep_search',
|
|
240
|
+
confidence: 0.9,
|
|
241
|
+
rationale: 'Text search / pattern matching across workspace.',
|
|
242
|
+
extractedArgs: queryMatch ? { query: queryMatch[1] } : undefined,
|
|
243
|
+
riskLevel: 0,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
// 6. Terminal domain routing (Default fallback for CLI commands, build, test, execution)
|
|
247
|
+
let risk = 1;
|
|
248
|
+
if (lower.includes('rm -rf') || lower.includes('delete') || lower.includes('drop') || lower.includes('format')) {
|
|
249
|
+
risk = 3;
|
|
250
|
+
}
|
|
251
|
+
else if (lower.includes('publish') || lower.includes('deploy') || lower.includes('push')) {
|
|
252
|
+
risk = 2;
|
|
253
|
+
}
|
|
254
|
+
else if (lower.includes('test') || lower.includes('echo') || lower.includes('pwd') || lower.includes('whoami')) {
|
|
255
|
+
risk = 0;
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
domain: 'terminal',
|
|
259
|
+
tool: 'run_command',
|
|
260
|
+
confidence: 0.8,
|
|
261
|
+
rationale: 'Command execution in workspace terminal.',
|
|
262
|
+
extractedArgs: { command: text },
|
|
263
|
+
riskLevel: risk,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Cross-Domain Plan Generation:
|
|
268
|
+
* Decomposes complex composite goals across multiple tool domains.
|
|
269
|
+
* Supports canonical workflow:
|
|
270
|
+
* Browser (find failing CI) -> Terminal/Git (checkout/diff) -> Filesystem (edit/fix) -> Terminal (run tests) -> Browser (verify)
|
|
271
|
+
*/
|
|
272
|
+
planWorkflow(compositeGoal, context) {
|
|
273
|
+
const lower = compositeGoal.toLowerCase();
|
|
274
|
+
// Check for the classic multi-domain scenario:
|
|
275
|
+
// "Find the failing deployment, inspect the code, fix it, run tests, and verify the deployment"
|
|
276
|
+
if ((lower.includes('failing') || lower.includes('deployment') || lower.includes('ci')) &&
|
|
277
|
+
(lower.includes('code') || lower.includes('fix')) &&
|
|
278
|
+
(lower.includes('test') || lower.includes('run tests')) &&
|
|
279
|
+
(lower.includes('verify') || lower.includes('check'))) {
|
|
280
|
+
return [
|
|
281
|
+
{
|
|
282
|
+
stepId: 'step_1_browser_inspect_ci',
|
|
283
|
+
domain: 'browser',
|
|
284
|
+
goal: 'Inspect deployment / CI run logs in browser',
|
|
285
|
+
tool: 'browser_content',
|
|
286
|
+
args: { url: context?.activeUrl || 'https://github.com/org/repo/actions' },
|
|
287
|
+
expectedOutputKey: 'ci_error_logs',
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
stepId: 'step_2_git_inspect_repo',
|
|
291
|
+
domain: 'git',
|
|
292
|
+
goal: 'Check repository status and recent changes',
|
|
293
|
+
tool: 'git_status',
|
|
294
|
+
args: {},
|
|
295
|
+
dependsOn: ['step_1_browser_inspect_ci'],
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
stepId: 'step_3_filesystem_fix_code',
|
|
299
|
+
domain: 'filesystem',
|
|
300
|
+
goal: 'Inspect and fix the faulty code in workspace',
|
|
301
|
+
tool: 'edit_file',
|
|
302
|
+
args: { path: 'src/index.ts', target: 'FIXME', replacement: 'RESOLVED' },
|
|
303
|
+
dependsOn: ['step_2_git_inspect_repo'],
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
stepId: 'step_4_terminal_run_tests',
|
|
307
|
+
domain: 'terminal',
|
|
308
|
+
goal: 'Execute test suite to verify the code fix',
|
|
309
|
+
tool: 'run_command',
|
|
310
|
+
args: { command: 'npm test' },
|
|
311
|
+
dependsOn: ['step_3_filesystem_fix_code'],
|
|
312
|
+
expectedOutputKey: 'test_results',
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
stepId: 'step_5_browser_verify_deployment',
|
|
316
|
+
domain: 'browser',
|
|
317
|
+
goal: 'Verify deployment status in browser dashboard',
|
|
318
|
+
tool: 'browser_navigate',
|
|
319
|
+
args: { url: context?.activeUrl || 'https://github.com/org/repo/actions' },
|
|
320
|
+
dependsOn: ['step_4_terminal_run_tests'],
|
|
321
|
+
},
|
|
322
|
+
];
|
|
323
|
+
}
|
|
324
|
+
// Generic single or double-domain fallback planning
|
|
325
|
+
const routed = this.route(compositeGoal, context);
|
|
326
|
+
return [
|
|
327
|
+
{
|
|
328
|
+
stepId: 'step_1_primary_action',
|
|
329
|
+
domain: routed.domain,
|
|
330
|
+
goal: compositeGoal,
|
|
331
|
+
tool: routed.tool,
|
|
332
|
+
args: routed.extractedArgs || {},
|
|
333
|
+
},
|
|
334
|
+
];
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Direct execution through the appropriate domain handler.
|
|
338
|
+
*/
|
|
339
|
+
async execute(domain, tool, args, context) {
|
|
340
|
+
const handler = this.handlers.get(domain);
|
|
341
|
+
if (!handler) {
|
|
342
|
+
throw new Error(`No handler registered for domain: ${domain}`);
|
|
343
|
+
}
|
|
344
|
+
if (!handler.canHandle(tool)) {
|
|
345
|
+
throw new Error(`Handler for domain "${domain}" cannot handle tool: "${tool}"`);
|
|
346
|
+
}
|
|
347
|
+
return await handler.execute(tool, args, context);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Multi-Domain Workflow Execution:
|
|
351
|
+
* Chains steps across different domains, maintains variable context, and records transitions.
|
|
352
|
+
*/
|
|
353
|
+
async executeWorkflow(steps, initialContext) {
|
|
354
|
+
const stepResults = [];
|
|
355
|
+
const domainTransitions = [];
|
|
356
|
+
const variables = { ...(initialContext?.variables || {}) };
|
|
357
|
+
let previousDomain = null;
|
|
358
|
+
let success = true;
|
|
359
|
+
for (const step of steps) {
|
|
360
|
+
// Check domain transition
|
|
361
|
+
if (previousDomain && previousDomain !== step.domain) {
|
|
362
|
+
domainTransitions.push({
|
|
363
|
+
from: previousDomain,
|
|
364
|
+
to: step.domain,
|
|
365
|
+
atStepId: step.stepId,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
previousDomain = step.domain;
|
|
369
|
+
// Merge variables into step args if formatted as {{varName}}
|
|
370
|
+
const resolvedArgs = {};
|
|
371
|
+
for (const [k, v] of Object.entries(step.args)) {
|
|
372
|
+
if (typeof v === 'string' && v.startsWith('{{') && v.endsWith('}}')) {
|
|
373
|
+
const varKey = v.slice(2, -2).trim();
|
|
374
|
+
resolvedArgs[k] = variables[varKey] !== undefined ? variables[varKey] : v;
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
resolvedArgs[k] = v;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
const startTime = Date.now();
|
|
381
|
+
try {
|
|
382
|
+
const output = await this.execute(step.domain, step.tool, resolvedArgs, {
|
|
383
|
+
...initialContext,
|
|
384
|
+
variables,
|
|
385
|
+
});
|
|
386
|
+
const durationMs = Date.now() - startTime;
|
|
387
|
+
if (step.expectedOutputKey) {
|
|
388
|
+
variables[step.expectedOutputKey] = output;
|
|
389
|
+
}
|
|
390
|
+
stepResults.push({
|
|
391
|
+
stepId: step.stepId,
|
|
392
|
+
domain: step.domain,
|
|
393
|
+
tool: step.tool,
|
|
394
|
+
success: true,
|
|
395
|
+
output,
|
|
396
|
+
durationMs,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
catch (err) {
|
|
400
|
+
const durationMs = Date.now() - startTime;
|
|
401
|
+
success = false;
|
|
402
|
+
stepResults.push({
|
|
403
|
+
stepId: step.stepId,
|
|
404
|
+
domain: step.domain,
|
|
405
|
+
tool: step.tool,
|
|
406
|
+
success: false,
|
|
407
|
+
output: null,
|
|
408
|
+
error: err.message || String(err),
|
|
409
|
+
durationMs,
|
|
410
|
+
});
|
|
411
|
+
break; // Stop sequential execution on failure
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
const completedSteps = stepResults.filter(r => r.success).length;
|
|
415
|
+
const summary = `Executed ${completedSteps}/${steps.length} multi-domain steps with ${domainTransitions.length} domain transitions. Status: ${success ? 'PASSED' : 'FAILED'}.`;
|
|
416
|
+
return {
|
|
417
|
+
success,
|
|
418
|
+
completedSteps,
|
|
419
|
+
totalSteps: steps.length,
|
|
420
|
+
stepResults,
|
|
421
|
+
domainTransitions,
|
|
422
|
+
summary,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
//# sourceMappingURL=unifiedRouter.js.map
|
package/bin/src/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import { handleLogout } from './commands/logout.js';
|
|
|
22
22
|
import { handleSwitch, handleAccounts } from './commands/switchCommand.js';
|
|
23
23
|
import { handleAuthStatus } from './commands/authCommand.js';
|
|
24
24
|
import { handleDashboard } from './commands/dashboard.js';
|
|
25
|
+
import { handleSupport } from './commands/support.js';
|
|
25
26
|
import { handleQuota } from './commands/quota.js';
|
|
26
27
|
import { handlePlanCommand } from './commands/plan.js';
|
|
27
28
|
import { handleMcpList, handleMcpAdd, handleMcpRemove, handleMcpConnect, handleMcpDisconnect, handleMcpInspect, handleMcpTools, handleMcpHealth } from './commands/mcp.js';
|
|
@@ -38,16 +39,16 @@ program
|
|
|
38
39
|
.name('scout')
|
|
39
40
|
.alias('ft')
|
|
40
41
|
.description('FrontTerrain The Onboarding Co-Pilot for New Codebases')
|
|
41
|
-
.version('9.5.
|
|
42
|
+
.version('9.5.6');
|
|
42
43
|
// Header UI on execution with FrontTerrain proprietary logo & version auto-checker
|
|
43
44
|
program.hook('preAction', async (_thisCommand, actionCommand) => {
|
|
44
|
-
intro(renderBranding('9.5.
|
|
45
|
+
intro(renderBranding('9.5.6'));
|
|
45
46
|
const cmdName = actionCommand ? actionCommand.name() : '';
|
|
46
47
|
if (cmdName !== 'upgrade') {
|
|
47
|
-
await checkForUpdates('9.5.
|
|
48
|
+
await checkForUpdates('9.5.6');
|
|
48
49
|
}
|
|
49
|
-
// Auth Guard: enforce authentication for all commands except login, signup, upgrade, help, dashboard, auth, status, plan, mcp, switch, accounts
|
|
50
|
-
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'];
|
|
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
52
|
if (!EXEMPT_COMMANDS.includes(cmdName)) {
|
|
52
53
|
const authCfg = loadAuthConfig();
|
|
53
54
|
const hasEnvApiKey = Boolean(process.env.OPENAI_API_KEY ||
|
|
@@ -265,7 +266,7 @@ program
|
|
|
265
266
|
.command('upgrade')
|
|
266
267
|
.description('Check for updates and auto-upgrade Scout to the latest version')
|
|
267
268
|
.action(async () => {
|
|
268
|
-
await checkForUpdates('9.5.
|
|
269
|
+
await checkForUpdates('9.5.6', true);
|
|
269
270
|
outro(chalk.cyan('Upgrade check complete.'));
|
|
270
271
|
});
|
|
271
272
|
program
|
|
@@ -355,6 +356,25 @@ program
|
|
|
355
356
|
await handlePlanCommand();
|
|
356
357
|
outro(chalk.cyan('Subscription workflow complete.'));
|
|
357
358
|
});
|
|
359
|
+
program
|
|
360
|
+
.command('support')
|
|
361
|
+
.alias('ticket')
|
|
362
|
+
.alias('helpdesk')
|
|
363
|
+
.description('Help & Support center: submit tickets, view status, browse FAQs & diagnostics')
|
|
364
|
+
.option('-n, --new', 'Raise a new support ticket interactively')
|
|
365
|
+
.option('-l, --list', 'List all open support tickets')
|
|
366
|
+
.option('-o, --open', 'Open the Web Help & Support Dashboard in your browser')
|
|
367
|
+
.option('--faq', 'View instant knowledge base FAQs')
|
|
368
|
+
.option('--diagnostics', 'View sanitized system and agent diagnostics')
|
|
369
|
+
.action(async (options) => {
|
|
370
|
+
await handleSupport({
|
|
371
|
+
new: !!options.new,
|
|
372
|
+
list: !!options.list,
|
|
373
|
+
open: !!options.open,
|
|
374
|
+
faq: !!options.faq,
|
|
375
|
+
diagnostics: !!options.diagnostics,
|
|
376
|
+
});
|
|
377
|
+
});
|
|
358
378
|
const mcp = program
|
|
359
379
|
.command('mcp')
|
|
360
380
|
.description('Manage Model Context Protocol (MCP) server connections, tools, and health');
|
package/bin/src/mcp/client.js
CHANGED
package/bin/src/server/server.js
CHANGED
|
@@ -14,6 +14,7 @@ import { TaskStateManager } from '../engine/agentState.js';
|
|
|
14
14
|
import { ApprovalManager } from '../engine/safety.js';
|
|
15
15
|
import { AgentExecutionLoop } from '../engine/agentEngine.js';
|
|
16
16
|
import { getMCPManager, MCPTelemetry } from '../mcp/index.js';
|
|
17
|
+
import { loadSupportTickets, createSupportTicket, getSupportTicket, addTicketMessage, updateTicketStatus, collectSanitizedDiagnostics, getPresetFaqs, } from '../utils/support.js';
|
|
17
18
|
let activeAgentLoop = null;
|
|
18
19
|
const serverStateManager = new TaskStateManager(process.cwd());
|
|
19
20
|
const DEFAULT_PORT = 9120;
|
|
@@ -1054,6 +1055,138 @@ export function startDashboardServer(port = DEFAULT_PORT) {
|
|
|
1054
1055
|
return;
|
|
1055
1056
|
}
|
|
1056
1057
|
}
|
|
1058
|
+
// ---------------------------------------------------------
|
|
1059
|
+
// Help & Support API Endpoints
|
|
1060
|
+
// ---------------------------------------------------------
|
|
1061
|
+
// GET /api/support/tickets - List all support tickets
|
|
1062
|
+
if (pathname === '/api/support/tickets' && req.method === 'GET') {
|
|
1063
|
+
const tickets = loadSupportTickets();
|
|
1064
|
+
res.writeHead(200);
|
|
1065
|
+
res.end(JSON.stringify({ success: true, tickets }));
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
// POST /api/support/tickets - Submit a new support ticket
|
|
1069
|
+
if (pathname === '/api/support/tickets' && req.method === 'POST') {
|
|
1070
|
+
let body = '';
|
|
1071
|
+
req.on('data', chunk => body += chunk);
|
|
1072
|
+
req.on('end', () => {
|
|
1073
|
+
try {
|
|
1074
|
+
const data = JSON.parse(body || '{}');
|
|
1075
|
+
if (!data.subject || !data.description || !data.userEmail) {
|
|
1076
|
+
res.writeHead(400);
|
|
1077
|
+
res.end(JSON.stringify({
|
|
1078
|
+
success: false,
|
|
1079
|
+
error: 'Subject, description, and contact email are required to create a ticket.'
|
|
1080
|
+
}));
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
const ticket = createSupportTicket({
|
|
1084
|
+
subject: data.subject,
|
|
1085
|
+
description: data.description,
|
|
1086
|
+
userEmail: data.userEmail,
|
|
1087
|
+
userName: data.userName,
|
|
1088
|
+
category: data.category,
|
|
1089
|
+
priority: data.priority,
|
|
1090
|
+
attachDiagnostics: data.attachDiagnostics !== false,
|
|
1091
|
+
});
|
|
1092
|
+
res.writeHead(201);
|
|
1093
|
+
res.end(JSON.stringify({ success: true, ticket }));
|
|
1094
|
+
}
|
|
1095
|
+
catch (err) {
|
|
1096
|
+
res.writeHead(400);
|
|
1097
|
+
res.end(JSON.stringify({ success: false, error: err.message || 'Failed to create support ticket' }));
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
// GET /api/support/faqs - Knowledge base & FAQ items
|
|
1103
|
+
if (pathname === '/api/support/faqs' && req.method === 'GET') {
|
|
1104
|
+
const faqs = getPresetFaqs();
|
|
1105
|
+
res.writeHead(200);
|
|
1106
|
+
res.end(JSON.stringify({ success: true, faqs }));
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
// GET /api/support/diagnostics - Sanitized diagnostic bundle
|
|
1110
|
+
if (pathname === '/api/support/diagnostics' && req.method === 'GET') {
|
|
1111
|
+
const diagnostics = collectSanitizedDiagnostics();
|
|
1112
|
+
res.writeHead(200);
|
|
1113
|
+
res.end(JSON.stringify({ success: true, diagnostics }));
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
// GET /api/support/tickets/:id
|
|
1117
|
+
const ticketIdMatch = pathname.match(/^\/api\/support\/tickets\/([a-zA-Z0-9_\-]+)$/);
|
|
1118
|
+
if (ticketIdMatch && req.method === 'GET') {
|
|
1119
|
+
const ticketId = ticketIdMatch[1];
|
|
1120
|
+
const ticket = getSupportTicket(ticketId);
|
|
1121
|
+
if (!ticket) {
|
|
1122
|
+
res.writeHead(404);
|
|
1123
|
+
res.end(JSON.stringify({ success: false, error: 'Ticket not found' }));
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
res.writeHead(200);
|
|
1127
|
+
res.end(JSON.stringify({ success: true, ticket }));
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
// POST /api/support/tickets/:id/message - Add reply to ticket
|
|
1131
|
+
const ticketMessageMatch = pathname.match(/^\/api\/support\/tickets\/([a-zA-Z0-9_\-]+)\/message$/);
|
|
1132
|
+
if (ticketMessageMatch && req.method === 'POST') {
|
|
1133
|
+
const ticketId = ticketMessageMatch[1];
|
|
1134
|
+
let body = '';
|
|
1135
|
+
req.on('data', chunk => body += chunk);
|
|
1136
|
+
req.on('end', () => {
|
|
1137
|
+
try {
|
|
1138
|
+
const data = JSON.parse(body || '{}');
|
|
1139
|
+
if (!data.message || !data.message.trim()) {
|
|
1140
|
+
res.writeHead(400);
|
|
1141
|
+
res.end(JSON.stringify({ success: false, error: 'Message cannot be empty.' }));
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
const updated = addTicketMessage(ticketId, data.message, data.sender || 'user', data.senderName);
|
|
1145
|
+
if (!updated) {
|
|
1146
|
+
res.writeHead(404);
|
|
1147
|
+
res.end(JSON.stringify({ success: false, error: 'Ticket not found.' }));
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
res.writeHead(200);
|
|
1151
|
+
res.end(JSON.stringify({ success: true, ticket: updated }));
|
|
1152
|
+
}
|
|
1153
|
+
catch (err) {
|
|
1154
|
+
res.writeHead(400);
|
|
1155
|
+
res.end(JSON.stringify({ success: false, error: err.message || 'Failed to add message.' }));
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
return;
|
|
1159
|
+
}
|
|
1160
|
+
// POST /api/support/tickets/:id/status - Update ticket status
|
|
1161
|
+
const ticketStatusMatch = pathname.match(/^\/api\/support\/tickets\/([a-zA-Z0-9_\-]+)\/status$/);
|
|
1162
|
+
if (ticketStatusMatch && req.method === 'POST') {
|
|
1163
|
+
const ticketId = ticketStatusMatch[1];
|
|
1164
|
+
let body = '';
|
|
1165
|
+
req.on('data', chunk => body += chunk);
|
|
1166
|
+
req.on('end', () => {
|
|
1167
|
+
try {
|
|
1168
|
+
const data = JSON.parse(body || '{}');
|
|
1169
|
+
if (!data.status) {
|
|
1170
|
+
res.writeHead(400);
|
|
1171
|
+
res.end(JSON.stringify({ success: false, error: 'Status is required.' }));
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
const updated = updateTicketStatus(ticketId, data.status);
|
|
1175
|
+
if (!updated) {
|
|
1176
|
+
res.writeHead(404);
|
|
1177
|
+
res.end(JSON.stringify({ success: false, error: 'Ticket not found.' }));
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
res.writeHead(200);
|
|
1181
|
+
res.end(JSON.stringify({ success: true, ticket: updated }));
|
|
1182
|
+
}
|
|
1183
|
+
catch (err) {
|
|
1184
|
+
res.writeHead(400);
|
|
1185
|
+
res.end(JSON.stringify({ success: false, error: err.message || 'Failed to update status.' }));
|
|
1186
|
+
}
|
|
1187
|
+
});
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1057
1190
|
res.writeHead(404);
|
|
1058
1191
|
res.end(JSON.stringify({ error: 'API route not found' }));
|
|
1059
1192
|
return;
|
|
@@ -1072,6 +1205,9 @@ export function startDashboardServer(port = DEFAULT_PORT) {
|
|
|
1072
1205
|
else if (pathname === '/admin' || pathname === '/admin/') {
|
|
1073
1206
|
filePath = path.join(webDir, 'admin.html');
|
|
1074
1207
|
}
|
|
1208
|
+
else if (pathname === '/support' || pathname === '/support/' || pathname === '/help' || pathname === '/help/') {
|
|
1209
|
+
filePath = path.join(webDir, 'support.html');
|
|
1210
|
+
}
|
|
1075
1211
|
else {
|
|
1076
1212
|
let targetFile = pathname === '/' ? 'index.html' : pathname.replace(/^\//, '');
|
|
1077
1213
|
filePath = path.join(webDir, targetFile);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
export function renderBranding(version = '9.5.
|
|
2
|
+
export function renderBranding(version = '9.5.6') {
|
|
3
3
|
const logo = chalk.cyan.bold(' ███████╗████████╗') + ' ' + chalk.cyan.bold('███████╗ ██████╗ ██████╗ ██╗ ██╗████████╗') + '\n' +
|
|
4
4
|
chalk.cyan.bold(' ██╔════╝╚══██╔══╝') + ' ' + chalk.cyan.bold('██╔════╝ ██╔════╝██╔═══██╗ ██║ ██║╚══██╔══╝') + '\n' +
|
|
5
5
|
chalk.cyan.bold(' █████╗ ██║ ') + ' ' + chalk.cyan.bold(' ███████╗ ██║ ██║ ██║ ██║ ██║ ██║ ') + '\n' +
|