ft-scout 9.5.2 → 9.5.5

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.
@@ -0,0 +1,227 @@
1
+ import chalk from 'chalk';
2
+ import { intro, outro, text, select, confirm, isCancel, spinner } from '@clack/prompts';
3
+ import { exec } from 'child_process';
4
+ import { promisify } from 'util';
5
+ import { loadAuthConfig } from '../utils/auth.js';
6
+ import { safeNote, renderMarkdown } from '../utils/markdown.js';
7
+ import { loadSupportTickets, createSupportTicket, getPresetFaqs, collectSanitizedDiagnostics, } from '../utils/support.js';
8
+ import { startDashboardServer } from '../server/server.js';
9
+ const execAsync = promisify(exec);
10
+ export async function handleSupport(options) {
11
+ const authCfg = loadAuthConfig();
12
+ const defaultEmail = authCfg.user?.email || '';
13
+ // Direct flag: --open (Open Web Dashboard)
14
+ if (options?.open) {
15
+ await openSupportInBrowser();
16
+ return;
17
+ }
18
+ // Direct flag: --list (List Tickets)
19
+ if (options?.list) {
20
+ displayTicketsList();
21
+ return;
22
+ }
23
+ // Direct flag: --new (Raise New Ticket)
24
+ if (options?.new) {
25
+ await promptCreateTicket(defaultEmail);
26
+ return;
27
+ }
28
+ // Direct flag: --faq (Show FAQs)
29
+ if (options?.faq) {
30
+ displayFaqs();
31
+ return;
32
+ }
33
+ // Direct flag: --diagnostics (Show Diagnostics)
34
+ if (options?.diagnostics) {
35
+ displayDiagnostics();
36
+ return;
37
+ }
38
+ // Interactive menu when no flags provided
39
+ intro(chalk.bold.cyan(' FrontTerrain Scout - Help & Support Center'));
40
+ const action = await select({
41
+ message: 'How can we assist you today?',
42
+ options: [
43
+ { value: 'new', label: '🎫 Raise a New Support Ticket', hint: 'Submit bug, request feature, or ask for help' },
44
+ { value: 'list', label: '📋 View My Open Tickets', hint: 'Check status and replies on raised tickets' },
45
+ { value: 'web', label: '🌐 Open Web Support Dashboard', hint: 'Interactive tickets UI, FAQs & diagnostics in browser' },
46
+ { value: 'faq', label: '💡 Browse Quick FAQs', hint: 'Common questions on quotas, desktop tools & MCP' },
47
+ { value: 'diagnostics', label: '🔍 View System Diagnostics', hint: 'Check environment, model, tier & scout version' },
48
+ ],
49
+ });
50
+ if (isCancel(action)) {
51
+ outro(chalk.yellow('Support session closed. Run `scout support` anytime!'));
52
+ return;
53
+ }
54
+ switch (action) {
55
+ case 'new':
56
+ await promptCreateTicket(defaultEmail);
57
+ break;
58
+ case 'list':
59
+ displayTicketsList();
60
+ break;
61
+ case 'web':
62
+ await openSupportInBrowser();
63
+ break;
64
+ case 'faq':
65
+ displayFaqs();
66
+ break;
67
+ case 'diagnostics':
68
+ displayDiagnostics();
69
+ break;
70
+ }
71
+ }
72
+ async function promptCreateTicket(defaultEmail) {
73
+ const subject = await text({
74
+ message: 'Ticket Subject / Summary:',
75
+ placeholder: 'e.g. Issue launching VS Code with computer tools',
76
+ validate: (val) => (!val || !val.trim() ? 'Subject is required.' : undefined),
77
+ });
78
+ if (isCancel(subject))
79
+ return;
80
+ const category = await select({
81
+ message: 'Select Category:',
82
+ options: [
83
+ { value: 'agent_automation', label: '🤖 Agent & Computer Automation', hint: 'CLI steps, app launching, file edits' },
84
+ { value: 'billing_quota', label: '💳 Billing, Credits & BYOK', hint: 'Subscription upgrades, PayPal/Razorpay, quotas' },
85
+ { value: 'cli_crash', label: '⚡ CLI Error or Crash', hint: 'Terminal exceptions, command failures' },
86
+ { value: 'mcp_integration', label: '🔌 MCP Tools & Servers', hint: 'Connecting servers, stdio/http tools' },
87
+ { value: 'feature_request', label: '✨ Feature Suggestion', hint: 'Ideas to make Scout co-pilot better' },
88
+ { value: 'other', label: '❓ General Question / Other' },
89
+ ],
90
+ });
91
+ if (isCancel(category))
92
+ return;
93
+ const priority = await select({
94
+ message: 'Select Priority Level:',
95
+ options: [
96
+ { value: 'low', label: '🟢 Low', hint: 'Minor inquiry or cosmetic suggestion' },
97
+ { value: 'medium', label: '🟡 Medium', hint: 'Normal feature or non-blocking bug' },
98
+ { value: 'high', label: '🟠 High', hint: 'Degraded capability or failing workflow' },
99
+ { value: 'urgent', label: '🔴 Urgent / Blocker', hint: 'Critical blocker preventing work' },
100
+ ],
101
+ });
102
+ if (isCancel(priority))
103
+ return;
104
+ const description = await text({
105
+ message: 'Detailed Description (what happened, steps to reproduce, or requirements):',
106
+ placeholder: 'Describe your issue or request in detail...',
107
+ validate: (val) => (!val || !val.trim() ? 'Description is required.' : undefined),
108
+ });
109
+ if (isCancel(description))
110
+ return;
111
+ const email = await text({
112
+ message: 'Your Contact Email (for status updates & response notifications):',
113
+ defaultValue: defaultEmail,
114
+ placeholder: 'developer@example.com',
115
+ validate: (val) => {
116
+ if (!val || !val.trim())
117
+ return 'Contact email is required.';
118
+ if (!val.includes('@') || !val.includes('.'))
119
+ return 'Please enter a valid email address.';
120
+ return undefined;
121
+ },
122
+ });
123
+ if (isCancel(email))
124
+ return;
125
+ const attachDiagnostics = await confirm({
126
+ message: 'Auto-attach sanitized system diagnostics (OS, Scout version, active tier, active model)?',
127
+ initialValue: true,
128
+ });
129
+ if (isCancel(attachDiagnostics))
130
+ return;
131
+ const spin = spinner();
132
+ spin.start('Submitting support ticket to FrontTerrain...');
133
+ const ticket = createSupportTicket({
134
+ subject: String(subject),
135
+ description: String(description),
136
+ userEmail: String(email),
137
+ category: category,
138
+ priority: priority,
139
+ attachDiagnostics: Boolean(attachDiagnostics),
140
+ });
141
+ spin.stop(chalk.green(`Ticket created successfully: ${chalk.bold(ticket.id)}`));
142
+ safeNote(`${chalk.bold.green('✔ Support Ticket Submitted Successfully')}\n\n` +
143
+ `• ${chalk.bold('Ticket ID:')} ${chalk.bold.cyan(ticket.id)}\n` +
144
+ `• ${chalk.bold('Subject:')} ${ticket.subject}\n` +
145
+ `• ${chalk.bold('Category:')} ${ticket.category.replace(/_/g, ' ').toUpperCase()}\n` +
146
+ `• ${chalk.bold('Priority:')} ${ticket.priority.toUpperCase()}\n` +
147
+ `• ${chalk.bold('Status:')} ${chalk.bold.yellow(ticket.status.toUpperCase())}\n` +
148
+ `• ${chalk.bold('Contact:')} ${ticket.userEmail}\n\n` +
149
+ `${chalk.dim('You can track this ticket anytime using:')}\n` +
150
+ ` ${chalk.cyan('scout support --list')}\n` +
151
+ ` ${chalk.cyan('scout support --open')} ${chalk.dim('(opens web dashboard)')}`, 'FrontTerrain Support Ticket');
152
+ }
153
+ function displayTicketsList() {
154
+ const tickets = loadSupportTickets();
155
+ if (tickets.length === 0) {
156
+ safeNote('No support tickets found on this device.\n\n' +
157
+ `To raise a ticket, run: ${chalk.cyan('scout support --new')}`, 'Support Tickets');
158
+ return;
159
+ }
160
+ const lines = tickets.map((t) => {
161
+ let statusBadge = chalk.yellow(`[${t.status.toUpperCase()}]`);
162
+ if (t.status === 'resolved')
163
+ statusBadge = chalk.green(`[${t.status.toUpperCase()}]`);
164
+ if (t.status === 'in_progress')
165
+ statusBadge = chalk.cyan(`[${t.status.toUpperCase()}]`);
166
+ if (t.status === 'closed')
167
+ statusBadge = chalk.gray(`[${t.status.toUpperCase()}]`);
168
+ let priorityBadge = chalk.white(`[${t.priority.toUpperCase()}]`);
169
+ if (t.priority === 'urgent')
170
+ priorityBadge = chalk.bold.red(`[URGENT]`);
171
+ else if (t.priority === 'high')
172
+ priorityBadge = chalk.yellow(`[HIGH]`);
173
+ return (`${chalk.bold.cyan(t.id)} ${statusBadge} ${priorityBadge} ${chalk.bold(t.subject)}\n` +
174
+ ` • Category: ${chalk.dim(t.category.replace(/_/g, ' '))} | Created: ${chalk.dim(new Date(t.createdAt).toLocaleString())}\n` +
175
+ ` • Messages: ${t.messages.length} | Contact: ${chalk.dim(t.userEmail)}`);
176
+ });
177
+ safeNote(`Found ${tickets.length} support ticket(s):\n\n` +
178
+ lines.join('\n\n') +
179
+ `\n\n${chalk.dim('To manage tickets in browser, run:')} ${chalk.cyan('scout support --open')}`, `Support Tickets (${tickets.length})`);
180
+ }
181
+ function displayFaqs() {
182
+ const faqs = getPresetFaqs();
183
+ const formatted = faqs.map((f, i) => `### ${i + 1}. ${f.question}\n` +
184
+ `*Category: ${f.category}*\n\n` +
185
+ `${f.answer}\n`).join('\n---\n\n');
186
+ safeNote(renderMarkdown(formatted), 'FrontTerrain Scout Knowledge Base');
187
+ }
188
+ function displayDiagnostics() {
189
+ const diag = collectSanitizedDiagnostics();
190
+ const content = `• **Scout Version:** \`${diag.scoutVersion}\`\n` +
191
+ `• **Node.js:** \`${diag.nodeVersion}\`\n` +
192
+ `• **OS Platform:** \`${diag.platform} (${diag.osRelease}) [${diag.arch}]\`\n` +
193
+ `• **Subscription Tier:** \`${diag.currentTier}\`\n` +
194
+ `• **Active LLM Model:** \`${diag.activeModel}\`\n` +
195
+ `• **BYOK Mode:** \`${diag.byokEnabled ? 'Enabled' : 'Disabled'}\`\n` +
196
+ `• **Credit Quota:** \`${diag.usedCredits}/${diag.totalCredits} credits used\`\n` +
197
+ `• **Active Saved Tasks:** \`${diag.activeTaskCount}\`\n`;
198
+ safeNote(renderMarkdown(content), 'Scout System Diagnostics');
199
+ }
200
+ async function openSupportInBrowser() {
201
+ const s = spinner();
202
+ s.start('Connecting to Scout Web Support Dashboard...');
203
+ try {
204
+ const { url } = await startDashboardServer(9120);
205
+ const supportUrl = `${url}/support`;
206
+ s.stop(`Support server active at ${chalk.bold.cyan(supportUrl)}`);
207
+ const openCmd = process.platform === 'win32'
208
+ ? `start "" "${supportUrl}"`
209
+ : process.platform === 'darwin'
210
+ ? `open "${supportUrl}"`
211
+ : `xdg-open "${supportUrl}"`;
212
+ try {
213
+ await execAsync(openCmd);
214
+ }
215
+ catch { }
216
+ safeNote(`Web Support Dashboard: ${chalk.bold.underline.cyan(supportUrl)}\n\n` +
217
+ `• Submit & track tickets with live messaging\n` +
218
+ `• Searchable Knowledge Base & FAQs\n` +
219
+ `• Instant Diagnostic Report export\n\n` +
220
+ `${chalk.dim('Press Ctrl+C to stop local dashboard server.')}`, 'FrontTerrain Help & Support Dashboard');
221
+ }
222
+ catch (err) {
223
+ s.stop(chalk.red('Failed to start dashboard server.'));
224
+ console.error(chalk.red(`Error: ${err?.message || err}`));
225
+ }
226
+ }
227
+ //# sourceMappingURL=support.js.map
@@ -277,7 +277,7 @@ export const AGENT_TOOLS = [
277
277
  },
278
278
  {
279
279
  name: 'ask_user',
280
- description: 'ONLY use for missing API keys or secret credentials. DO NOT use to ask the user what code to write or to re-confirm their prompttake immediate autonomous tool action instead.',
280
+ description: 'Prompt the user directly for input, decisions, preferences, confirmations, or clarifications. Use this whenever you need user guidance, choices between options, or additional details to proceed.',
281
281
  parameters: {
282
282
  type: 'object',
283
283
  properties: {
@@ -299,14 +299,14 @@ export const AGENT_TOOLS = [
299
299
  },
300
300
  {
301
301
  name: 'delegate_subtask',
302
- description: 'Delegate a specialized subtask to an autonomous specialist subagent (architect, coder, tester, reviewer, general). Useful for delegating code reviews, test generation, architectural breakdowns, or isolated module implementations to an autonomous worker agent.',
302
+ description: 'Delegate a specialized subtask to an autonomous specialist subagent (architect, coder, tester, reviewer, operator, researcher, general). Useful for delegating web research, desktop app automation, code reviews, test generation, architectural breakdowns, or isolated module implementations to an autonomous worker agent.',
303
303
  parameters: {
304
304
  type: 'object',
305
305
  properties: {
306
306
  role: {
307
307
  type: 'string',
308
- enum: ['architect', 'coder', 'tester', 'reviewer', 'general'],
309
- description: 'Specialist role for the subagent (architect, coder, tester, reviewer, general)',
308
+ enum: ['architect', 'coder', 'tester', 'reviewer', 'operator', 'researcher', 'general'],
309
+ description: 'Specialist role for the subagent (architect, coder, tester, reviewer, operator, researcher, general)',
310
310
  },
311
311
  task: {
312
312
  type: 'string',
@@ -625,12 +625,10 @@ Task Execution Intent & Constraints:
625
625
  const isPaid = this.isPaidTier();
626
626
  const tierDirective = isPaid ? `
627
627
  PLAN TIER & CAPABILITIES: ${this.userTier.toUpperCase()} (FULL ACCESS UNLOCKED)
628
- • Unlimited autonomous multi-step loops with no step limits.
629
628
  • Autonomous Computer-Use, Browser Automation, and AI Scratchpad Reasoning are fully ENABLED.
630
629
  • Use the 'scratchpad' tool to organize multi-step reasoning, break down complex goals, draft hypotheses, and track working memory across turns.
631
630
  ` : `
632
- PLAN TIER & CAPABILITIES: DEVELOPER FREE (UNLIMITED MULTI-STEP CORE CODING)
633
- • Unlimited execution steps: Take as many iterative steps as needed to solve, test, and verify the task thoroughly.
631
+ PLAN TIER & CAPABILITIES: DEVELOPER FREE (CORE CODING & WORKSPACE OPS)
634
632
  • Developer operations enabled: Code editing, file/directory creation, running terminal commands/tests, syntax verification, reading, and exploration.
635
633
  • Work systematically: Inspect the code, run relevant builds/tests, verify syntax, and ensure high code quality before completing.
636
634
  `;
@@ -747,6 +745,70 @@ When returning tool calls, use standard OpenAI function calling format or JSON t
747
745
  }
748
746
  // Robust Target File Discovery: Only run file discovery if the goal has explicit code editing/modification intent
749
747
  const simpleAppCheck = checkSimpleAppAction(userGoal);
748
+ if (simpleAppCheck.isSimple && simpleAppCheck.appName) {
749
+ const app = simpleAppCheck.appName;
750
+ const action = simpleAppCheck.action || 'open';
751
+ this.taskStateManager.startStep(1);
752
+ let res;
753
+ const toolName = action === 'close' ? 'computer_close_app' : (action === 'switch' ? 'computer_switch_window' : 'computer_open_app');
754
+ const toolArgs = action === 'switch' ? { windowTitleOrApp: app } : { appName: app };
755
+ renderStepHeader({
756
+ step: 1,
757
+ maxSteps: this.maxSteps,
758
+ startTimeMs: this.startTime,
759
+ tokensConsumed: 0,
760
+ userTier: this.userTier,
761
+ });
762
+ renderToolCall({
763
+ name: toolName,
764
+ args: toolArgs,
765
+ step: 1,
766
+ });
767
+ const actionStartTime = Date.now();
768
+ if (action === 'close') {
769
+ res = await this.computerController.closeApplication(app);
770
+ }
771
+ else if (action === 'switch') {
772
+ res = await this.computerController.switchWindow(app);
773
+ }
774
+ else {
775
+ res = await this.computerController.openApplication(app);
776
+ }
777
+ renderToolResult({
778
+ name: toolName,
779
+ args: toolArgs,
780
+ result: JSON.stringify(res, null, 2),
781
+ durationMs: Date.now() - actionStartTime,
782
+ success: res && res.success !== false,
783
+ });
784
+ const actionVerb = action === 'close' ? 'closed' : (action === 'switch' ? 'focused' : 'launched');
785
+ const summary = res && res.success !== false
786
+ ? `I've ${actionVerb} ${app} for you. It's ready on your screen!`
787
+ : `Attempted to ${action} ${app}: ${res?.output || res?.error || 'Failed to execute application action'}`;
788
+ this.taskStateManager.completeStep(1, summary);
789
+ this.taskStateManager.setStatus(res && res.success !== false ? 'completed' : 'failed');
790
+ renderTaskCompletedCard({
791
+ objective: userGoal,
792
+ summary,
793
+ modifiedFiles: [],
794
+ steps: 1,
795
+ maxSteps: this.maxSteps,
796
+ totalTokens: 0,
797
+ totalToolCalls: 1,
798
+ elapsedSecs: Math.max(0.1, (Date.now() - this.startTime) / 1000),
799
+ userTier: this.userTier,
800
+ });
801
+ saveAgentSession({
802
+ goal: userGoal,
803
+ summary,
804
+ modifiedFiles: [],
805
+ });
806
+ this.syncTelemetry('idle', `scout: completed app action ${action} for ${app}`);
807
+ return {
808
+ success: res && res.success !== false,
809
+ summary,
810
+ };
811
+ }
750
812
  const lowerGoal = userGoal.toLowerCase().trim();
751
813
  const hasCodeEditIntent = /\b(edit|modify|fix|update|change|refactor|write|create|implement|patch|delete|remove|add\s+code|add\s+function|debug)\b/i.test(lowerGoal) &&
752
814
  !/\b(lookup|look\s*up|who|what|why|where|how|explain|describe|tell|status|check|github|mcp)\b/i.test(lowerGoal);
@@ -926,12 +988,7 @@ When returning tool calls, use standard OpenAI function calling format or JSON t
926
988
  userTier: this.userTier,
927
989
  });
928
990
  const stepSpinner = spinner();
929
- if (!Number.isFinite(this.maxSteps)) {
930
- stepSpinner.start(chalk.cyan(`Scout is Working (Step ${step})`));
931
- }
932
- else {
933
- stepSpinner.start(chalk.cyan(`Scout is Working (Step ${step}/${this.maxSteps})`));
934
- }
991
+ stepSpinner.start(chalk.cyan(`Scout is Working (Step ${step})`));
935
992
  try {
936
993
  let response;
937
994
  const mcpRouting = getMCPManager().routeTools(userGoal);
@@ -947,9 +1004,40 @@ When returning tool calls, use standard OpenAI function calling format or JSON t
947
1004
  goalLower.includes('calc') ||
948
1005
  goalLower.includes('paint') ||
949
1006
  goalLower.includes('type') ||
1007
+ goalLower.includes('chrome') ||
1008
+ goalLower.includes('browser') ||
1009
+ goalLower.includes('vscode') ||
1010
+ goalLower.includes('vs code') ||
1011
+ goalLower.includes('code') ||
1012
+ goalLower.includes('terminal') ||
1013
+ goalLower.includes('powershell') ||
1014
+ goalLower.includes('cmd') ||
1015
+ goalLower.includes('explorer') ||
1016
+ goalLower.includes('spotify') ||
1017
+ goalLower.includes('slack') ||
1018
+ goalLower.includes('discord') ||
1019
+ goalLower.includes('edge') ||
1020
+ goalLower.includes('firefox') ||
1021
+ goalLower.includes('excel') ||
1022
+ goalLower.includes('word') ||
1023
+ goalLower.includes('blender') ||
1024
+ goalLower.includes('open') ||
1025
+ goalLower.includes('launch') ||
1026
+ goalLower.includes('window') ||
1027
+ simpleAppCheck.isSimple ||
950
1028
  this.executionIntent?.requiredInteraction === 'computer' ||
951
1029
  (this.executionIntent?.requiredApplications && this.executionIntent.requiredApplications.length > 0);
952
1030
  let baseTools = this.toolRegistry.getToolsForTier(this.userTier);
1031
+ if (needsComputer) {
1032
+ const computerTools = this.toolRegistry.getAllTools().filter((t) => t.name.startsWith('computer_'));
1033
+ const existingNames = new Set(baseTools.map((t) => t.name));
1034
+ for (const ct of computerTools) {
1035
+ if (!existingNames.has(ct.name)) {
1036
+ baseTools.push(ct);
1037
+ existingNames.add(ct.name);
1038
+ }
1039
+ }
1040
+ }
953
1041
  if (mcpRouting.tools.length > 0 && !needsBrowser && !needsComputer) {
954
1042
  const ESSENTIAL_BASE_TOOLS = new Set(['read_file', 'write_file', 'edit_file', 'run_command', 'list_dir', 'grep_search', 'task_completed', 'ask_user', 'speak_text', 'scratchpad', 'computer_open_app']);
955
1043
  baseTools = baseTools.filter((t) => ESSENTIAL_BASE_TOOLS.has(t.name));
@@ -1303,8 +1391,8 @@ You MUST output exactly ONE JSON code block per tool call. Do NOT describe what
1303
1391
  return {
1304
1392
  success: false,
1305
1393
  summary: Number.isFinite(this.maxSteps)
1306
- ? `Reached max iteration steps limit (${this.maxSteps}). Modified files: ${Array.from(this.modifiedFiles).join(', ')}`
1307
- : `Task ended after ${step} iteration steps. Modified files: ${Array.from(this.modifiedFiles).join(', ')}`,
1394
+ ? `Reached step limit (${this.maxSteps}). Modified files: ${Array.from(this.modifiedFiles).join(', ')}`
1395
+ : `Task ended after ${step} steps. Modified files: ${Array.from(this.modifiedFiles).join(', ')}`,
1308
1396
  };
1309
1397
  }
1310
1398
  finally {
@@ -116,6 +116,12 @@ export declare class SystemComputerController implements IComputerController {
116
116
  keyPress(key: string): Promise<ComputerActionResult>;
117
117
  hotkey(keys: string[]): Promise<ComputerActionResult>;
118
118
  wait(ms: number): Promise<void>;
119
+ resolveCanonicalApp(appName: string, args?: string[]): {
120
+ canonicalCmd: string;
121
+ args: string[];
122
+ titleTerms: string[];
123
+ processNames: string[];
124
+ };
119
125
  openApplication(appName: string, args?: string[]): Promise<ComputerActionResult>;
120
126
  closeApplication(appName: string): Promise<ComputerActionResult>;
121
127
  switchWindow(windowTitleOrApp: string): Promise<ComputerActionResult>;