ft-scout 9.5.5 → 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.
Files changed (92) hide show
  1. package/README.md +1 -1
  2. package/bin/src/engine/agent/computerUseLoop.d.ts +107 -0
  3. package/bin/src/engine/agent/computerUseLoop.js +413 -0
  4. package/bin/src/engine/agent/index.d.ts +2 -0
  5. package/bin/src/engine/agent/index.js +2 -0
  6. package/bin/src/engine/agent/recovery/index.d.ts +4 -0
  7. package/bin/src/engine/agent/recovery/index.js +4 -0
  8. package/bin/src/engine/agent/recovery/loopDetector.d.ts +26 -0
  9. package/bin/src/engine/agent/recovery/loopDetector.js +126 -0
  10. package/bin/src/engine/agent/recovery/recoveryManager.d.ts +43 -0
  11. package/bin/src/engine/agent/recovery/recoveryManager.js +271 -0
  12. package/bin/src/engine/agent/recovery/types.d.ts +48 -0
  13. package/bin/src/engine/agent/recovery/types.js +4 -0
  14. package/bin/src/engine/agent/verification/index.d.ts +3 -0
  15. package/bin/src/engine/agent/verification/index.js +3 -0
  16. package/bin/src/engine/agent/verification/stateChangeVerifier.d.ts +22 -0
  17. package/bin/src/engine/agent/verification/stateChangeVerifier.js +282 -0
  18. package/bin/src/engine/agent/verification/types.d.ts +28 -0
  19. package/bin/src/engine/agent/verification/types.js +4 -0
  20. package/bin/src/engine/agentEngine.d.ts +2 -1
  21. package/bin/src/engine/agentEngine.js +2 -1
  22. package/bin/src/engine/agentState.d.ts +41 -1
  23. package/bin/src/engine/agentState.js +45 -0
  24. package/bin/src/engine/browser/actions/actionEngine.d.ts +41 -0
  25. package/bin/src/engine/browser/actions/actionEngine.js +707 -0
  26. package/bin/src/engine/browser/actions/index.d.ts +4 -0
  27. package/bin/src/engine/browser/actions/index.js +4 -0
  28. package/bin/src/engine/browser/actions/reliability.d.ts +41 -0
  29. package/bin/src/engine/browser/actions/reliability.js +170 -0
  30. package/bin/src/engine/browser/actions/types.d.ts +50 -0
  31. package/bin/src/engine/browser/actions/types.js +2 -0
  32. package/bin/src/engine/browser/browserController.d.ts +18 -0
  33. package/bin/src/engine/browser/browserController.js +44 -12
  34. package/bin/src/engine/browser/index.d.ts +2 -0
  35. package/bin/src/engine/browser/index.js +2 -0
  36. package/bin/src/engine/browser/observer/accessibilityTree.d.ts +14 -0
  37. package/bin/src/engine/browser/observer/accessibilityTree.js +214 -0
  38. package/bin/src/engine/browser/observer/browserObserver.d.ts +29 -0
  39. package/bin/src/engine/browser/observer/browserObserver.js +204 -0
  40. package/bin/src/engine/browser/observer/domExtractor.d.ts +30 -0
  41. package/bin/src/engine/browser/observer/domExtractor.js +407 -0
  42. package/bin/src/engine/browser/observer/index.d.ts +5 -0
  43. package/bin/src/engine/browser/observer/index.js +5 -0
  44. package/bin/src/engine/browser/observer/types.d.ts +163 -0
  45. package/bin/src/engine/browser/observer/types.js +8 -0
  46. package/bin/src/engine/computer/computerController.d.ts +43 -0
  47. package/bin/src/engine/computer/computerController.js +111 -0
  48. package/bin/src/engine/computer/mockComputer.d.ts +6 -1
  49. package/bin/src/engine/computer/mockComputer.js +58 -0
  50. package/bin/src/engine/models/harpProvider.d.ts +32 -0
  51. package/bin/src/engine/models/harpProvider.js +124 -0
  52. package/bin/src/engine/models/index.d.ts +6 -0
  53. package/bin/src/engine/models/index.js +6 -0
  54. package/bin/src/engine/models/localModelProvider.d.ts +11 -0
  55. package/bin/src/engine/models/localModelProvider.js +48 -0
  56. package/bin/src/engine/models/openaiProvider.d.ts +11 -0
  57. package/bin/src/engine/models/openaiProvider.js +50 -0
  58. package/bin/src/engine/models/reasoningOrchestrator.d.ts +17 -0
  59. package/bin/src/engine/models/reasoningOrchestrator.js +75 -0
  60. package/bin/src/engine/models/types.d.ts +63 -0
  61. package/bin/src/engine/models/types.js +2 -0
  62. package/bin/src/engine/production/index.d.ts +3 -0
  63. package/bin/src/engine/production/index.js +3 -0
  64. package/bin/src/engine/production/taskReplay.d.ts +37 -0
  65. package/bin/src/engine/production/taskReplay.js +81 -0
  66. package/bin/src/engine/production/telemetry.d.ts +43 -0
  67. package/bin/src/engine/production/telemetry.js +68 -0
  68. package/bin/src/engine/runtime/agentRuntime.d.ts +1 -1
  69. package/bin/src/engine/safety/index.d.ts +3 -0
  70. package/bin/src/engine/safety/index.js +3 -0
  71. package/bin/src/engine/safety/policyEngine.d.ts +40 -0
  72. package/bin/src/engine/safety/policyEngine.js +282 -0
  73. package/bin/src/engine/safety/types.d.ts +24 -0
  74. package/bin/src/engine/safety/types.js +2 -0
  75. package/bin/src/engine/safety.d.ts +1 -0
  76. package/bin/src/engine/safety.js +1 -0
  77. package/bin/src/engine/toolRegistry.d.ts +4 -0
  78. package/bin/src/engine/toolRegistry.js +9 -0
  79. package/bin/src/engine/tools/domainHandlers.d.ts +61 -0
  80. package/bin/src/engine/tools/domainHandlers.js +458 -0
  81. package/bin/src/engine/tools/index.d.ts +4 -0
  82. package/bin/src/engine/tools/index.js +4 -0
  83. package/bin/src/engine/tools/types.d.ts +56 -0
  84. package/bin/src/engine/tools/types.js +2 -0
  85. package/bin/src/engine/tools/unifiedRouter.d.ts +29 -0
  86. package/bin/src/engine/tools/unifiedRouter.js +426 -0
  87. package/bin/src/index.js +4 -4
  88. package/bin/src/mcp/client.js +1 -1
  89. package/bin/src/utils/branding.js +1 -1
  90. package/bin/src/utils/qrBridge.js +1 -1
  91. package/bin/src/utils/support.js +1 -1
  92. package/package.json +2 -2
@@ -0,0 +1,282 @@
1
+ import {} from '../../browser/observer/types.js';
2
+ import {} from '../../browser/actions/types.js';
3
+ import {} from '../computerUseLoop.js';
4
+ import {} from './types.js';
5
+ export class StateChangeVerifier {
6
+ /**
7
+ * Verifies whether an expected state change occurred following an action.
8
+ * Core question: "Did the expected state change occur?"
9
+ */
10
+ verifyStateChange(params) {
11
+ const { actionResult, plannedAction, beforeState, afterState, expected } = params;
12
+ // 1. Primitive Execution Verification
13
+ if (!actionResult.success) {
14
+ return {
15
+ verified: false,
16
+ stateChanged: false,
17
+ navigationOccurred: false,
18
+ buttonActionOccurred: false,
19
+ formSubmitted: false,
20
+ formUnchanged: false,
21
+ errorAppeared: false,
22
+ modalDismissed: false,
23
+ modalAppeared: false,
24
+ contentChanged: false,
25
+ confidence: 1.0,
26
+ details: `Action execution primitive failed: ${actionResult.error || 'Unknown error'}`,
27
+ recoveryRecommended: true,
28
+ recommendedStrategy: 'RE_LOCATE',
29
+ };
30
+ }
31
+ const beforeUrl = beforeState?.url || actionResult.beforeState?.url || '';
32
+ const afterUrl = afterState?.url || actionResult.afterState?.url || '';
33
+ // 2. Navigation Verification
34
+ const urlChanged = Boolean(beforeUrl && afterUrl && beforeUrl !== afterUrl);
35
+ let navigationOccurred = urlChanged;
36
+ let navigationMatchesPattern = true;
37
+ if (expected?.expectedUrlPattern) {
38
+ navigationMatchesPattern = afterUrl.toLowerCase().includes(expected.expectedUrlPattern.toLowerCase());
39
+ if (!navigationMatchesPattern) {
40
+ navigationOccurred = false;
41
+ }
42
+ }
43
+ // 3. Error Detection (Did an error appear?)
44
+ const beforeErrors = this.extractErrorStrings(beforeState);
45
+ const afterErrors = this.extractErrorStrings(afterState);
46
+ const newErrors = afterErrors.filter(err => !beforeErrors.includes(err));
47
+ const errorAppeared = newErrors.length > 0;
48
+ const errorMessage = errorAppeared ? newErrors[0] : undefined;
49
+ // 4. Modal / Dialog Transition Detection
50
+ const beforeModalOpen = Boolean(beforeState?.modals?.some(m => m.isOpen));
51
+ const afterModalOpen = Boolean(afterState?.modals?.some(m => m.isOpen));
52
+ const modalDismissed = beforeModalOpen && !afterModalOpen;
53
+ const modalAppeared = !beforeModalOpen && afterModalOpen;
54
+ // 5. Button Action & Element Mutation Detection
55
+ const buttonActionOccurred = this.checkButtonActionOccurred({
56
+ plannedAction,
57
+ beforeState,
58
+ afterState,
59
+ urlChanged,
60
+ modalDismissed,
61
+ modalAppeared,
62
+ });
63
+ // 6. Form Submission vs Form Unchanged Detection
64
+ const formAnalysis = this.analyzeFormState({
65
+ plannedAction,
66
+ beforeState,
67
+ afterState,
68
+ urlChanged,
69
+ errorAppeared,
70
+ });
71
+ // 7. General Content Change Detection
72
+ const beforeTextLen = beforeState?.visibleText?.trim().length || 0;
73
+ const afterTextLen = afterState?.visibleText?.trim().length || 0;
74
+ const beforeElCount = beforeState?.elements?.length || 0;
75
+ const afterElCount = afterState?.elements?.length || 0;
76
+ const contentChanged = Math.abs(beforeTextLen - afterTextLen) > 10 || beforeElCount !== afterElCount;
77
+ const stateChanged = urlChanged || modalDismissed || modalAppeared || buttonActionOccurred || formAnalysis.formSubmitted || contentChanged;
78
+ // 8. Expected vs Actual Outcome Assessment
79
+ let verified = false;
80
+ let details = '';
81
+ let confidence = 0.9;
82
+ let recoveryRecommended = false;
83
+ let recommendedStrategy;
84
+ if (errorAppeared) {
85
+ // New error appeared on the page (e.g. form validation failure, invalid input, server error)
86
+ verified = false;
87
+ recoveryRecommended = true;
88
+ recommendedStrategy = 'SEMANTIC_ALTERNATIVE';
89
+ details = `Action triggered an error on page: "${errorMessage}"`;
90
+ }
91
+ else if (formAnalysis.formUnchanged && this.isSubmissionAction(plannedAction)) {
92
+ // Submit button clicked, but form remained identical with no feedback
93
+ verified = false;
94
+ recoveryRecommended = true;
95
+ recommendedStrategy = 'SEMANTIC_ALTERNATIVE';
96
+ details = 'Form unchanged: Submit action was clicked but form inputs were neither submitted nor cleared, and no navigation occurred.';
97
+ }
98
+ else if (plannedAction.tool === 'navigate') {
99
+ if (afterUrl === 'about:blank' || (expected?.expectedUrlPattern && !navigationMatchesPattern)) {
100
+ verified = false;
101
+ recoveryRecommended = true;
102
+ recommendedStrategy = 'RETRY';
103
+ details = `Navigation to expected target failed. Current URL: "${afterUrl}"`;
104
+ }
105
+ else {
106
+ verified = true;
107
+ details = `Navigation confirmed to: "${afterUrl}"`;
108
+ }
109
+ }
110
+ else if (plannedAction.args.key === 'Escape' || plannedAction.description.toLowerCase().includes('dismiss')) {
111
+ if (modalDismissed) {
112
+ verified = true;
113
+ details = 'Modal dialog dismissed successfully';
114
+ }
115
+ else if (!afterModalOpen) {
116
+ verified = true;
117
+ details = 'No blocking modal present';
118
+ }
119
+ else {
120
+ verified = false;
121
+ recoveryRecommended = true;
122
+ recommendedStrategy = 'RETRY';
123
+ details = 'Modal dialog remained open after dismiss attempt';
124
+ }
125
+ }
126
+ else if (plannedAction.tool === 'type') {
127
+ // Type action verification
128
+ const targetVal = plannedAction.args.text;
129
+ const hasTextNow = afterState?.visibleText?.includes(targetVal) ||
130
+ afterState?.forms?.some(f => f.fields.some(field => field.value?.includes(targetVal)));
131
+ verified = hasTextNow || stateChanged;
132
+ details = verified ? `Typed text successfully entered` : `Text input did not reflect in target element`;
133
+ if (!verified) {
134
+ recoveryRecommended = true;
135
+ recommendedStrategy = 'RE_LOCATE';
136
+ }
137
+ }
138
+ else if (plannedAction.tool === 'click') {
139
+ if (stateChanged) {
140
+ verified = true;
141
+ details = urlChanged
142
+ ? `Click resulted in navigation to ${afterUrl}`
143
+ : `Click triggered expected state change (mutation or modal)`;
144
+ }
145
+ else {
146
+ // Click occurred without any observable state change
147
+ verified = false;
148
+ recoveryRecommended = true;
149
+ recommendedStrategy = 'SEMANTIC_ALTERNATIVE';
150
+ details = 'Click had no observable effect on DOM or URL (potential inert element or missing handler)';
151
+ }
152
+ }
153
+ else {
154
+ // Default tool verification (wait, scroll, select)
155
+ verified = true;
156
+ details = `Action "${plannedAction.tool}" verified successfully`;
157
+ }
158
+ return {
159
+ verified,
160
+ stateChanged,
161
+ navigationOccurred,
162
+ buttonActionOccurred,
163
+ formSubmitted: formAnalysis.formSubmitted,
164
+ formUnchanged: formAnalysis.formUnchanged,
165
+ errorAppeared,
166
+ errorMessage: errorMessage || undefined,
167
+ modalDismissed,
168
+ modalAppeared,
169
+ contentChanged,
170
+ confidence,
171
+ details,
172
+ beforeUrl: beforeUrl || undefined,
173
+ afterUrl: afterUrl || undefined,
174
+ recoveryRecommended: recoveryRecommended || undefined,
175
+ recommendedStrategy: recommendedStrategy || undefined,
176
+ };
177
+ }
178
+ extractErrorStrings(state) {
179
+ if (!state)
180
+ return [];
181
+ const errors = [];
182
+ // 1. Accessibility & Role alerts
183
+ for (const el of (state.elements || [])) {
184
+ const role = (el.role || '').toLowerCase();
185
+ const text = (el.text || '').trim();
186
+ const cls = (el.attributes['class'] || '').toLowerCase();
187
+ if (role === 'alert' || role === 'alertdialog' || cls.includes('error') || cls.includes('alert-danger') || cls.includes('toast-error')) {
188
+ if (text && text.length < 300) {
189
+ errors.push(text);
190
+ }
191
+ }
192
+ }
193
+ // 2. Visible text matching
194
+ const lines = (state.visibleText || '').split('\n');
195
+ for (const line of lines) {
196
+ const trimmed = line.trim();
197
+ if (/^(?:error|failed|invalid|exception|warning)\b/i.test(trimmed) && trimmed.length < 200) {
198
+ if (!errors.includes(trimmed)) {
199
+ errors.push(trimmed);
200
+ }
201
+ }
202
+ }
203
+ return errors;
204
+ }
205
+ checkButtonActionOccurred(params) {
206
+ if (params.plannedAction.tool !== 'click') {
207
+ return false;
208
+ }
209
+ if (params.urlChanged || params.modalDismissed || params.modalAppeared) {
210
+ return true;
211
+ }
212
+ const target = (params.plannedAction.args.target || '').toLowerCase();
213
+ const beforeEl = params.beforeState?.elements?.find(e => (e.selector && target.includes(e.selector.toLowerCase())) ||
214
+ (e.text && target.includes(e.text.toLowerCase())) ||
215
+ (e.id && target.includes(e.id.toLowerCase())));
216
+ const afterEl = params.afterState?.elements?.find(e => (e.selector && target.includes(e.selector.toLowerCase())) ||
217
+ (e.text && target.includes(e.text.toLowerCase())) ||
218
+ (e.id && target.includes(e.id.toLowerCase())));
219
+ if (beforeEl && afterEl) {
220
+ // Check aria-expanded
221
+ if (beforeEl.attributes['aria-expanded'] !== afterEl.attributes['aria-expanded']) {
222
+ return true;
223
+ }
224
+ // Check disabled
225
+ if (beforeEl.state.disabled !== afterEl.state.disabled) {
226
+ return true;
227
+ }
228
+ // Check class change
229
+ if (beforeEl.attributes['class'] !== afterEl.attributes['class']) {
230
+ return true;
231
+ }
232
+ }
233
+ return false;
234
+ }
235
+ analyzeFormState(params) {
236
+ const isSubmit = this.isSubmissionAction(params.plannedAction);
237
+ if (!isSubmit) {
238
+ return { formSubmitted: false, formUnchanged: false };
239
+ }
240
+ // If URL changed on submit, navigation / submission succeeded
241
+ if (params.urlChanged) {
242
+ return { formSubmitted: true, formUnchanged: false };
243
+ }
244
+ const beforeForms = params.beforeState?.forms || [];
245
+ const afterForms = params.afterState?.forms || [];
246
+ // If form unmounted or disappeared, submission succeeded
247
+ if (beforeForms.length > 0 && afterForms.length === 0) {
248
+ return { formSubmitted: true, formUnchanged: false };
249
+ }
250
+ // Compare form values
251
+ if (beforeForms.length > 0 && afterForms.length > 0) {
252
+ const beforeF = beforeForms[0];
253
+ const afterF = afterForms[0];
254
+ let valuesIdentical = true;
255
+ for (let i = 0; i < beforeF.fields.length; i++) {
256
+ const bVal = beforeF.fields[i]?.value || '';
257
+ const aVal = afterF.fields[i]?.value || '';
258
+ if (bVal !== aVal) {
259
+ valuesIdentical = false;
260
+ break;
261
+ }
262
+ }
263
+ if (valuesIdentical && !params.errorAppeared) {
264
+ // Form remained completely unchanged with no feedback
265
+ return { formSubmitted: false, formUnchanged: true };
266
+ }
267
+ if (!valuesIdentical) {
268
+ return { formSubmitted: true, formUnchanged: false };
269
+ }
270
+ }
271
+ return { formSubmitted: false, formUnchanged: false };
272
+ }
273
+ isSubmissionAction(action) {
274
+ if (action.tool !== 'click')
275
+ return false;
276
+ const desc = (action.description || '').toLowerCase();
277
+ const target = (action.args.target || '').toLowerCase();
278
+ return /submit|register|sign\s*up|log\s*in|save|confirm|checkout/i.test(desc) ||
279
+ /submit|register|sign\s*up|log\s*in|save|confirm|checkout/i.test(target);
280
+ }
281
+ }
282
+ //# sourceMappingURL=stateChangeVerifier.js.map
@@ -0,0 +1,28 @@
1
+ export interface ExpectedStateChange {
2
+ type?: 'navigation' | 'button_action' | 'form_submission' | 'modal_dismiss' | 'text_present' | 'element_mutation' | 'any_state_change' | undefined;
3
+ target?: string | undefined;
4
+ expectedUrlPattern?: string | undefined;
5
+ expectedText?: string | undefined;
6
+ disallowedErrors?: string[] | undefined;
7
+ timeoutMs?: number | undefined;
8
+ }
9
+ export interface StateChangeVerificationResult {
10
+ verified: boolean;
11
+ stateChanged: boolean;
12
+ navigationOccurred: boolean;
13
+ buttonActionOccurred: boolean;
14
+ formSubmitted: boolean;
15
+ formUnchanged: boolean;
16
+ errorAppeared: boolean;
17
+ errorMessage?: string | undefined;
18
+ modalDismissed: boolean;
19
+ modalAppeared: boolean;
20
+ contentChanged: boolean;
21
+ confidence: number;
22
+ details: string;
23
+ beforeUrl?: string | undefined;
24
+ afterUrl?: string | undefined;
25
+ recoveryRecommended?: boolean | undefined;
26
+ recommendedStrategy?: 'RETRY' | 'RE_OBSERVE' | 'RE_LOCATE' | 'SEMANTIC_ALTERNATIVE' | 'VISUAL_FALLBACK' | 'REPORT_FAILURE' | undefined;
27
+ }
28
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,4 @@
1
+ import {} from '../../browser/observer/types.js';
2
+ import {} from '../../browser/actions/types.js';
3
+ import {} from '../computerUseLoop.js';
4
+ //# sourceMappingURL=types.js.map
@@ -8,7 +8,8 @@ import { UnifiedToolRegistry } from './toolRegistry.js';
8
8
  import { type IComputerController, SystemComputerController, MockComputerController } from './computer/index.js';
9
9
  import { AgentWorkspace, inferExecutionIntent, resolveDesktopPath, type ExecutionIntent } from './workspace/index.js';
10
10
  import { AgentRuntime } from './runtime/index.js';
11
- export { AgentRuntime, AgentWorkspace, inferExecutionIntent, resolveDesktopPath, type ExecutionIntent, type IComputerController, SystemComputerController, MockComputerController };
11
+ import { ComputerUseAgentLoop, type ComputerUseTaskResult } from './agent/index.js';
12
+ export { AgentRuntime, AgentWorkspace, inferExecutionIntent, resolveDesktopPath, type ExecutionIntent, type IComputerController, SystemComputerController, MockComputerController, ComputerUseAgentLoop, type ComputerUseTaskResult };
12
13
  export declare function robustSnippetReplace(origContent: string, target: string, replacement: string): {
13
14
  success: boolean;
14
15
  updatedContent: string;
@@ -27,7 +27,8 @@ import { CheckpointManager } from './checkpoints/checkpointManager.js';
27
27
  import { renderStepHeader, renderThoughtBox, renderToolCall, renderToolResult, renderTaskCompletedCard, } from '../utils/claudeUI.js';
28
28
  import { loadWorkspaceRules } from '../utils/rules.js';
29
29
  import { InterruptManager } from '../utils/interruptHandler.js';
30
- export { AgentRuntime, AgentWorkspace, inferExecutionIntent, resolveDesktopPath, SystemComputerController, MockComputerController };
30
+ import { ComputerUseAgentLoop } from './agent/index.js';
31
+ export { AgentRuntime, AgentWorkspace, inferExecutionIntent, resolveDesktopPath, SystemComputerController, MockComputerController, ComputerUseAgentLoop };
31
32
  const execAsync = promisify(exec);
32
33
  export function robustSnippetReplace(origContent, target, replacement) {
33
34
  if (!origContent || !target) {
@@ -1,3 +1,4 @@
1
+ import { type BrowserState } from './browser/index.js';
1
2
  export interface TaskPlanStep {
2
3
  id: number;
3
4
  description: string;
@@ -52,6 +53,24 @@ export interface PendingAction {
52
53
  riskReason: string;
53
54
  requestedAt: string;
54
55
  }
56
+ export interface TaskState {
57
+ objective: string;
58
+ plan: TaskPlanStep[];
59
+ current_step: number;
60
+ completed_steps: number[];
61
+ browser_state?: BrowserState | undefined;
62
+ tool_history: Array<{
63
+ step: number;
64
+ tool: string;
65
+ args: Record<string, any>;
66
+ resultSummary?: string | undefined;
67
+ timestamp: string;
68
+ }>;
69
+ errors: TaskError[];
70
+ retries: number;
71
+ status: 'planning' | 'running' | 'executing' | 'waiting_approval' | 'recovering' | 'completed' | 'failed' | 'paused' | 'timeout';
72
+ structured_result?: Record<string, any> | undefined;
73
+ }
55
74
  export interface AutonomousTaskState {
56
75
  task_id: string;
57
76
  taskId: string;
@@ -70,11 +89,21 @@ export interface AutonomousTaskState {
70
89
  errors: TaskError[];
71
90
  pending_action: PendingAction | null;
72
91
  verification_status: 'pending' | 'verified' | 'failed' | null;
73
- status: 'planning' | 'running' | 'executing' | 'waiting_approval' | 'recovering' | 'completed' | 'failed' | 'paused';
92
+ status: 'planning' | 'running' | 'executing' | 'waiting_approval' | 'recovering' | 'completed' | 'failed' | 'paused' | 'timeout';
74
93
  created_at: string;
75
94
  updated_at: string;
76
95
  completed_at?: string | undefined;
77
96
  metadata?: Record<string, any> | undefined;
97
+ browser_state?: BrowserState | undefined;
98
+ tool_history?: Array<{
99
+ step: number;
100
+ tool: string;
101
+ args: Record<string, any>;
102
+ resultSummary?: string | undefined;
103
+ timestamp: string;
104
+ }> | undefined;
105
+ retries?: number | undefined;
106
+ structured_result?: Record<string, any> | undefined;
78
107
  }
79
108
  export declare class TaskStateManager {
80
109
  private state;
@@ -121,6 +150,17 @@ export declare class TaskStateManager {
121
150
  mimeType?: string | undefined;
122
151
  }): TaskArtifact;
123
152
  getArtifacts(): TaskArtifact[];
153
+ setBrowserState(browserState: BrowserState): void;
154
+ addToolHistory(entry: {
155
+ step: number;
156
+ tool: string;
157
+ args: Record<string, any>;
158
+ resultSummary?: string | undefined;
159
+ }): void;
160
+ incrementRetries(): number;
161
+ resetRetries(): void;
162
+ setStructuredResult(result: Record<string, any>): void;
163
+ getTaskState(): TaskState;
124
164
  setActiveApplication(appName: string | null): void;
125
165
  setActiveUrl(url: string | null): void;
126
166
  setActiveWindow(windowTitle: string | null): void;
@@ -1,5 +1,6 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import {} from './browser/index.js';
3
4
  export class TaskStateManager {
4
5
  state;
5
6
  workspaceDir;
@@ -245,6 +246,50 @@ export class TaskStateManager {
245
246
  getArtifacts() {
246
247
  return [...this.state.artifacts];
247
248
  }
249
+ setBrowserState(browserState) {
250
+ this.state.browser_state = browserState;
251
+ this.touch();
252
+ }
253
+ addToolHistory(entry) {
254
+ if (!this.state.tool_history) {
255
+ this.state.tool_history = [];
256
+ }
257
+ this.state.tool_history.push({
258
+ ...entry,
259
+ timestamp: new Date().toISOString(),
260
+ });
261
+ if (this.state.tool_history.length > 50) {
262
+ this.state.tool_history.shift();
263
+ }
264
+ this.touch();
265
+ }
266
+ incrementRetries() {
267
+ this.state.retries = (this.state.retries || 0) + 1;
268
+ this.touch();
269
+ return this.state.retries;
270
+ }
271
+ resetRetries() {
272
+ this.state.retries = 0;
273
+ this.touch();
274
+ }
275
+ setStructuredResult(result) {
276
+ this.state.structured_result = result;
277
+ this.touch();
278
+ }
279
+ getTaskState() {
280
+ return {
281
+ objective: this.state.objective || this.state.goal,
282
+ plan: this.state.plan,
283
+ current_step: this.state.current_step,
284
+ completed_steps: this.state.completed_steps,
285
+ browser_state: this.state.browser_state,
286
+ tool_history: this.state.tool_history || [],
287
+ errors: this.state.errors,
288
+ retries: this.state.retries || 0,
289
+ status: this.state.status,
290
+ structured_result: this.state.structured_result,
291
+ };
292
+ }
248
293
  setActiveApplication(appName) {
249
294
  this.state.active_application = appName;
250
295
  this.touch();
@@ -0,0 +1,41 @@
1
+ import { type ActionTarget, type ActionResult, type WaitCondition, type IBrowserActionEngine, type RetryPolicy } from './types.js';
2
+ import { BrowserObserver } from '../observer/browserObserver.js';
3
+ export interface InternalBrowserTab {
4
+ id: string;
5
+ url: string;
6
+ title: string;
7
+ html: string;
8
+ history: {
9
+ past: string[];
10
+ future: string[];
11
+ };
12
+ }
13
+ export declare class BrowserActionEngine implements IBrowserActionEngine {
14
+ private tabs;
15
+ private activeTabId;
16
+ private observer;
17
+ private workspaceDir;
18
+ private retryPolicy;
19
+ constructor(workspaceDir?: string, retryPolicy?: Partial<RetryPolicy>);
20
+ getObserver(): BrowserObserver;
21
+ getActiveTab(): InternalBrowserTab | null;
22
+ getTabs(): InternalBrowserTab[];
23
+ private captureCurrentState;
24
+ navigate(url: string, htmlContent?: string): Promise<ActionResult>;
25
+ click(target: ActionTarget | string): Promise<ActionResult>;
26
+ type(target: ActionTarget | string, text: string, options?: {
27
+ clear?: boolean;
28
+ delayMs?: number;
29
+ }): Promise<ActionResult>;
30
+ select(target: ActionTarget | string, value: string): Promise<ActionResult>;
31
+ scroll(direction: 'up' | 'down' | 'left' | 'right', amount?: number): Promise<ActionResult>;
32
+ hover(target: ActionTarget | string): Promise<ActionResult>;
33
+ press_key(key: string): Promise<ActionResult>;
34
+ open_tab(url?: string, htmlContent?: string): Promise<ActionResult>;
35
+ close_tab(tabId?: string): Promise<ActionResult>;
36
+ switch_tab(tabId: string): Promise<ActionResult>;
37
+ wait(condition: WaitCondition, param?: any): Promise<ActionResult>;
38
+ upload(target: ActionTarget | string, localFilePath: string): Promise<ActionResult>;
39
+ download(target: ActionTarget | string, destPath?: string): Promise<ActionResult>;
40
+ }
41
+ //# sourceMappingURL=actionEngine.d.ts.map