testchimp-runner-core 0.0.35 → 0.0.36

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 (71) hide show
  1. package/package.json +6 -1
  2. package/plandocs/BEFORE_AFTER_VERIFICATION.md +0 -148
  3. package/plandocs/COORDINATE_MODE_DIAGNOSIS.md +0 -144
  4. package/plandocs/CREDIT_CALLBACK_ARCHITECTURE.md +0 -253
  5. package/plandocs/HUMAN_LIKE_IMPROVEMENTS.md +0 -642
  6. package/plandocs/IMPLEMENTATION_STATUS.md +0 -108
  7. package/plandocs/INTEGRATION_COMPLETE.md +0 -322
  8. package/plandocs/MULTI_AGENT_ARCHITECTURE_REVIEW.md +0 -844
  9. package/plandocs/ORCHESTRATOR_MVP_SUMMARY.md +0 -539
  10. package/plandocs/PHASE1_ABSTRACTION_COMPLETE.md +0 -241
  11. package/plandocs/PHASE1_FINAL_STATUS.md +0 -210
  12. package/plandocs/PHASE_1_COMPLETE.md +0 -165
  13. package/plandocs/PHASE_1_SUMMARY.md +0 -184
  14. package/plandocs/PLANNING_SESSION_SUMMARY.md +0 -372
  15. package/plandocs/PROMPT_OPTIMIZATION_ANALYSIS.md +0 -120
  16. package/plandocs/PROMPT_SANITY_CHECK.md +0 -120
  17. package/plandocs/SCRIPT_CLEANUP_FEATURE.md +0 -201
  18. package/plandocs/SCRIPT_GENERATION_ARCHITECTURE.md +0 -364
  19. package/plandocs/SELECTOR_IMPROVEMENTS.md +0 -139
  20. package/plandocs/SESSION_SUMMARY_v0.0.33.md +0 -151
  21. package/plandocs/TROUBLESHOOTING_SESSION.md +0 -72
  22. package/plandocs/VISION_DIAGNOSTICS_IMPROVEMENTS.md +0 -336
  23. package/plandocs/VISUAL_AGENT_EVOLUTION_PLAN.md +0 -396
  24. package/plandocs/WHATS_NEW_v0.0.33.md +0 -183
  25. package/plandocs/exploratory-mode-support-v2.plan.md +0 -953
  26. package/plandocs/exploratory-mode-support.plan.md +0 -928
  27. package/plandocs/journey-id-tracking-addendum.md +0 -227
  28. package/releasenotes/RELEASE_0.0.26.md +0 -165
  29. package/releasenotes/RELEASE_0.0.27.md +0 -236
  30. package/releasenotes/RELEASE_0.0.28.md +0 -286
  31. package/src/auth-config.ts +0 -84
  32. package/src/credit-usage-service.ts +0 -188
  33. package/src/env-loader.ts +0 -103
  34. package/src/execution-service.ts +0 -996
  35. package/src/file-handler.ts +0 -104
  36. package/src/index.ts +0 -432
  37. package/src/llm-facade.ts +0 -821
  38. package/src/llm-provider.ts +0 -53
  39. package/src/model-constants.ts +0 -35
  40. package/src/orchestrator/decision-parser.ts +0 -139
  41. package/src/orchestrator/index.ts +0 -58
  42. package/src/orchestrator/orchestrator-agent.ts +0 -1282
  43. package/src/orchestrator/orchestrator-prompts.ts +0 -786
  44. package/src/orchestrator/page-som-handler.ts +0 -1565
  45. package/src/orchestrator/som-types.ts +0 -188
  46. package/src/orchestrator/tool-registry.ts +0 -184
  47. package/src/orchestrator/tools/check-page-ready.ts +0 -75
  48. package/src/orchestrator/tools/extract-data.ts +0 -92
  49. package/src/orchestrator/tools/index.ts +0 -15
  50. package/src/orchestrator/tools/inspect-page.ts +0 -42
  51. package/src/orchestrator/tools/recall-history.ts +0 -72
  52. package/src/orchestrator/tools/refresh-som-markers.ts +0 -69
  53. package/src/orchestrator/tools/take-screenshot.ts +0 -128
  54. package/src/orchestrator/tools/verify-action-result.ts +0 -159
  55. package/src/orchestrator/tools/view-previous-screenshot.ts +0 -103
  56. package/src/orchestrator/types.ts +0 -291
  57. package/src/playwright-mcp-service.ts +0 -224
  58. package/src/progress-reporter.ts +0 -144
  59. package/src/prompts.ts +0 -842
  60. package/src/providers/backend-proxy-llm-provider.ts +0 -91
  61. package/src/providers/local-llm-provider.ts +0 -38
  62. package/src/scenario-service.ts +0 -252
  63. package/src/scenario-worker-class.ts +0 -1110
  64. package/src/script-utils.ts +0 -203
  65. package/src/types.ts +0 -239
  66. package/src/utils/browser-utils.ts +0 -348
  67. package/src/utils/coordinate-converter.ts +0 -162
  68. package/src/utils/page-info-retry.ts +0 -65
  69. package/src/utils/page-info-utils.ts +0 -285
  70. package/testchimp-runner-core-0.0.35.tgz +0 -0
  71. package/tsconfig.json +0 -19
@@ -1,188 +0,0 @@
1
- /**
2
- * Set-of-Marks (SoM) Type Definitions
3
- * Types for visual element identification and interaction
4
- */
5
-
6
- export interface Coordinate {
7
- x: number; // Percentage of viewport width: 0-100 (use 3 decimal precision, e.g., 15.625)
8
- y: number; // Percentage of viewport height: 0-100 (use 3 decimal precision, e.g., 82.375)
9
- }
10
-
11
- export enum InteractionAction {
12
- // Click actions
13
- CLICK = 'click',
14
- DOUBLE_CLICK = 'doubleClick',
15
- RIGHT_CLICK = 'rightClick',
16
-
17
- // Mouse actions
18
- HOVER = 'hover',
19
- MOUSE_DOWN = 'mouseDown',
20
- MOUSE_UP = 'mouseUp',
21
- DRAG = 'drag',
22
-
23
- // Input actions
24
- FILL = 'fill',
25
- TYPE = 'type',
26
- CLEAR = 'clear',
27
-
28
- // Keyboard actions
29
- PRESS = 'press',
30
- PRESS_SEQUENTIALLY = 'pressSequentially',
31
-
32
- // Select/Checkbox actions
33
- SELECT = 'select',
34
- CHECK = 'check',
35
- UNCHECK = 'uncheck',
36
-
37
- // Focus/Scroll actions
38
- FOCUS = 'focus',
39
- BLUR = 'blur',
40
- SCROLL = 'scroll',
41
- SCROLL_INTO_VIEW = 'scrollIntoView',
42
-
43
- // Navigation actions
44
- NAVIGATE = 'navigate', // Go to URL (requires value field)
45
- GO_BACK = 'goBack',
46
- GO_FORWARD = 'goForward',
47
- RELOAD = 'reload'
48
- }
49
-
50
- export interface SomCommand {
51
- elementRef?: string; // Integer as string: "1", "2", "42" (optional for coord-based commands)
52
- action: InteractionAction;
53
-
54
- // Coordinate-based action (use when elementRef is empty/null)
55
- coord?: Coordinate; // Percentage-based (x: 0-100, y: 0-100 of viewport)
56
-
57
- // Action-specific parameters
58
- value?: string; // For fill/type/select/press actions
59
- fromCoord?: Coordinate; // For drag (start) - percentage-based
60
- toCoord?: Coordinate; // For drag (end) - percentage-based
61
- force?: boolean; // Force action even if not actionable
62
- scrollAmount?: number; // Pixels to scroll
63
- scrollDirection?: 'up' | 'down' | 'left' | 'right';
64
- button?: 'left' | 'right' | 'middle';
65
- clickCount?: number;
66
- modifiers?: Array<'Alt' | 'Control' | 'Meta' | 'Shift'>;
67
- delay?: number; // Delay between keystrokes for TYPE (ms)
68
- timeout?: number; // Override default timeout
69
- }
70
-
71
- export enum CommandRunStatus {
72
- SUCCESS = 'success',
73
- FAILURE = 'failure'
74
- }
75
-
76
- export interface CommandAttempt {
77
- command?: string;
78
- status: CommandRunStatus;
79
- error?: string;
80
- }
81
-
82
- export interface DomMutation {
83
- type: 'added' | 'removed' | 'modified' | 'attribute_changed';
84
- elementDescription: string;
85
- timestamp: number;
86
- }
87
-
88
- export interface SemanticCommandResult {
89
- failedAttempts: CommandAttempt[];
90
- successAttempt?: CommandAttempt;
91
- error?: string;
92
- status: CommandRunStatus;
93
- mutations?: DomMutation[]; // Only for hover/focus, filtered for relevance
94
- }
95
-
96
- export interface SomElement {
97
- somId: string; // Simple integer as string: "1", "2", "3"
98
- tag: string;
99
- role: string;
100
- text: string;
101
- ariaLabel: string;
102
- placeholder: string;
103
- name: string;
104
- type: string;
105
- id: string;
106
- className: string;
107
- bbox: { x: number; y: number; width: number; height: number };
108
- parent?: {
109
- tag: string;
110
- role: string;
111
- className: string;
112
- text: string;
113
- };
114
- }
115
-
116
- /**
117
- * Typed selector (no string parsing needed)
118
- * Supports chaining: parent.child for scoped selectors
119
- */
120
- export interface TypedSelector {
121
- type: 'id' | 'testId' | 'label' | 'role' | 'placeholder' | 'text' | 'title' | 'altText' | 'name' | 'locator';
122
- value: string;
123
- roleOptions?: { name?: string }; // For getByRole
124
- parent?: TypedSelector; // For chaining: page.locator(parent).locator(this)
125
- }
126
-
127
- /**
128
- * Verification types for expect assertions
129
- */
130
- export enum VerificationType {
131
- // Text verifications
132
- TEXT_CONTAINS = 'textContains',
133
- TEXT_EQUALS = 'textEquals',
134
-
135
- // Input verifications
136
- VALUE_EQUALS = 'valueEquals',
137
- VALUE_EMPTY = 'valueEmpty',
138
-
139
- // Visibility verifications
140
- IS_VISIBLE = 'isVisible',
141
- IS_HIDDEN = 'isHidden',
142
-
143
- // State verifications
144
- IS_ENABLED = 'isEnabled',
145
- IS_DISABLED = 'isDisabled',
146
- IS_CHECKED = 'isChecked',
147
- IS_UNCHECKED = 'isUnchecked',
148
-
149
- // Count verifications (for lists, tables, etc.)
150
- COUNT_EQUALS = 'countEquals',
151
- COUNT_GREATER_THAN = 'countGreaterThan',
152
- COUNT_LESS_THAN = 'countLessThan',
153
-
154
- // Attribute verifications
155
- HAS_CLASS = 'hasClass',
156
- HAS_ATTRIBUTE = 'hasAttribute'
157
- }
158
-
159
- /**
160
- * SoM verification command for expect assertions
161
- */
162
- export interface SomVerification {
163
- verificationType: VerificationType;
164
- elementRef?: string; // SoM ID (e.g., "3") - optional for count verifications
165
- expected?: string | number; // Expected value/text/count
166
- description?: string; // Human-readable description
167
- selector?: string; // For count verifications on non-SoM elements (CSS selector)
168
- }
169
-
170
- /**
171
- * Union type: commands array can contain both actions and verifications
172
- */
173
- export type SomCommandOrVerification = SomCommand | SomVerification;
174
-
175
- /**
176
- * Type guard to check if command is a verification
177
- */
178
- export function isSomVerification(cmd: SomCommandOrVerification): cmd is SomVerification {
179
- return 'verificationType' in cmd;
180
- }
181
-
182
- /**
183
- * Type guard to check if command is an action
184
- */
185
- export function isSomCommand(cmd: SomCommandOrVerification): cmd is SomCommand {
186
- return 'action' in cmd;
187
- }
188
-
@@ -1,184 +0,0 @@
1
- /**
2
- * Tool Registry - Dynamic tool registration and prompt generation
3
- * Tools can be added at runtime and their descriptions are automatically included in agent prompts
4
- */
5
-
6
- import { ToolCall, ToolResult } from './types';
7
-
8
- /**
9
- * Tool parameter definition
10
- */
11
- export interface ToolParameter {
12
- name: string;
13
- type: 'string' | 'number' | 'boolean' | 'object';
14
- description: string;
15
- required: boolean;
16
- default?: any;
17
- }
18
-
19
- /**
20
- * Tool definition
21
- */
22
- export interface Tool {
23
- name: string;
24
- description: string;
25
- parameters: ToolParameter[];
26
-
27
- /**
28
- * Execute the tool
29
- * @param params Tool parameters
30
- * @param context Execution context (page, memory, etc.)
31
- */
32
- execute(params: Record<string, any>, context: ToolExecutionContext): Promise<ToolResult>;
33
- }
34
-
35
- /**
36
- * Context provided to tool execution
37
- */
38
- export interface ToolExecutionContext {
39
- page: any; // Playwright Page
40
- memory: any; // JourneyMemory
41
- stepNumber: number;
42
- logger?: (message: string, level?: 'log' | 'error' | 'warn') => void;
43
- previousSomScreenshot?: string; // For view_previous_screenshot tool
44
- somHandler?: any; // PageSoMHandler for refresh_som_markers tool
45
- }
46
-
47
- /**
48
- * Tool Registry - manages available tools and generates prompts
49
- */
50
- export class ToolRegistry {
51
- private tools: Map<string, Tool> = new Map();
52
-
53
- /**
54
- * Register a tool
55
- */
56
- register(tool: Tool): void {
57
- this.tools.set(tool.name, tool);
58
- }
59
-
60
- /**
61
- * Unregister a tool
62
- */
63
- unregister(toolName: string): void {
64
- this.tools.delete(toolName);
65
- }
66
-
67
- /**
68
- * Get a tool by name
69
- */
70
- get(toolName: string): Tool | undefined {
71
- return this.tools.get(toolName);
72
- }
73
-
74
- /**
75
- * Get all registered tools
76
- */
77
- getAll(): Tool[] {
78
- return Array.from(this.tools.values());
79
- }
80
-
81
- /**
82
- * Execute a tool
83
- */
84
- async execute(toolCall: ToolCall, context: ToolExecutionContext): Promise<ToolResult> {
85
- const tool = this.tools.get(toolCall.name);
86
-
87
- if (!tool) {
88
- return {
89
- success: false,
90
- error: `Tool '${toolCall.name}' not found`
91
- };
92
- }
93
-
94
- // Validate required parameters
95
- const missingParams = tool.parameters
96
- .filter(p => p.required && !(p.name in toolCall.params))
97
- .map(p => p.name);
98
-
99
- if (missingParams.length > 0) {
100
- return {
101
- success: false,
102
- error: `Missing required parameters: ${missingParams.join(', ')}`
103
- };
104
- }
105
-
106
- // Apply defaults for missing optional parameters
107
- const params = { ...toolCall.params };
108
- for (const param of tool.parameters) {
109
- if (!param.required && !(param.name in params) && param.default !== undefined) {
110
- params[param.name] = param.default;
111
- }
112
- }
113
-
114
- try {
115
- return await tool.execute(params, context);
116
- } catch (error: any) {
117
- return {
118
- success: false,
119
- error: `Tool execution failed: ${error.message}`
120
- };
121
- }
122
- }
123
-
124
- /**
125
- * Generate tool descriptions for agent prompt
126
- * Returns formatted text describing all available tools
127
- */
128
- generateToolDescriptions(): string {
129
- if (this.tools.size === 0) {
130
- return 'No tools available.';
131
- }
132
-
133
- const descriptions: string[] = [];
134
-
135
- descriptions.push('AVAILABLE TOOLS:');
136
- descriptions.push('');
137
-
138
- for (const tool of this.tools.values()) {
139
- descriptions.push(`${tool.name}:`);
140
- descriptions.push(` Description: ${tool.description}`);
141
-
142
- if (tool.parameters.length > 0) {
143
- descriptions.push(` Parameters:`);
144
- for (const param of tool.parameters) {
145
- const required = param.required ? '(required)' : '(optional)';
146
- const defaultVal = param.default !== undefined ? ` [default: ${JSON.stringify(param.default)}]` : '';
147
- descriptions.push(` - ${param.name} (${param.type}) ${required}: ${param.description}${defaultVal}`);
148
- }
149
- } else {
150
- descriptions.push(` Parameters: none`);
151
- }
152
-
153
- descriptions.push('');
154
- }
155
-
156
- descriptions.push('To use a tool, include it in your "toolCalls" array with the tool name and parameters.');
157
- descriptions.push('');
158
-
159
- return descriptions.join('\n');
160
- }
161
-
162
- /**
163
- * Generate JSON schema for tool calls (for structured output)
164
- */
165
- generateToolCallSchema(): any {
166
- return {
167
- type: 'array',
168
- items: {
169
- type: 'object',
170
- properties: {
171
- name: {
172
- type: 'string',
173
- enum: Array.from(this.tools.keys())
174
- },
175
- params: {
176
- type: 'object'
177
- }
178
- },
179
- required: ['name', 'params']
180
- }
181
- };
182
- }
183
- }
184
-
@@ -1,75 +0,0 @@
1
- /**
2
- * Check Page Ready Tool
3
- * Verify that page has finished loading and is interactive
4
- */
5
-
6
- import { Tool, ToolParameter, ToolExecutionContext } from '../tool-registry';
7
- import { ToolResult } from '../types';
8
-
9
- export class CheckPageReadyTool implements Tool {
10
- name = 'check_page_ready';
11
- description = 'Verify that the page has finished loading and is ready for interaction. Checks load state, no pending network requests, and DOM stability.';
12
-
13
- parameters: ToolParameter[] = [
14
- {
15
- name: 'timeout',
16
- type: 'number',
17
- description: 'Maximum time to wait for page to be ready (milliseconds)',
18
- required: false,
19
- default: 5000
20
- }
21
- ];
22
-
23
- async execute(params: Record<string, any>, context: ToolExecutionContext): Promise<ToolResult> {
24
- const { page, logger } = context;
25
- const timeout = params.timeout || 5000;
26
-
27
- try {
28
- logger?.(`[CheckPageReady] Verifying page is ready (timeout: ${timeout}ms)`, 'log');
29
-
30
- // Wait for load state
31
- await page.waitForLoadState('domcontentloaded', { timeout });
32
-
33
- // Check if page is interactive (use string to avoid TypeScript DOM type issues)
34
- const isInteractive = await page.evaluate(() => {
35
- const doc = (globalThis as any).document;
36
- return doc.readyState === 'complete' || doc.readyState === 'interactive';
37
- });
38
-
39
- // Get page state info
40
- const url = page.url();
41
- const title = await page.title();
42
-
43
- if (isInteractive) {
44
- logger?.(`[CheckPageReady] ✓ Page is ready: ${title} (${url})`, 'log');
45
- return {
46
- success: true,
47
- data: {
48
- ready: true,
49
- url,
50
- title,
51
- readyState: 'complete'
52
- }
53
- };
54
- } else {
55
- logger?.(`[CheckPageReady] ⚠ Page not fully ready yet`, 'warn');
56
- return {
57
- success: true,
58
- data: {
59
- ready: false,
60
- url,
61
- title,
62
- readyState: 'loading'
63
- }
64
- };
65
- }
66
- } catch (error: any) {
67
- logger?.(`[CheckPageReady] ✗ Failed: ${error.message}`, 'error');
68
- return {
69
- success: false,
70
- error: `Page ready check failed: ${error.message}`
71
- };
72
- }
73
- }
74
- }
75
-
@@ -1,92 +0,0 @@
1
- /**
2
- * Extract Data Tool
3
- * Save data from page for use in later steps
4
- */
5
-
6
- import { Tool, ToolParameter, ToolExecutionContext } from '../tool-registry';
7
- import { ToolResult } from '../types';
8
- import { JourneyMemory } from '../types';
9
-
10
- export class ExtractDataTool implements Tool {
11
- name = 'extract_data';
12
- description = 'Extract and save data from the page for use in later steps. Useful for capturing IDs, usernames, confirmation codes, etc.';
13
-
14
- parameters: ToolParameter[] = [
15
- {
16
- name: 'selector',
17
- type: 'string',
18
- description: 'CSS selector or text content to extract',
19
- required: true
20
- },
21
- {
22
- name: 'dataName',
23
- type: 'string',
24
- description: 'Name to save the data under (e.g., "userId", "confirmationCode")',
25
- required: true
26
- },
27
- {
28
- name: 'attribute',
29
- type: 'string',
30
- description: 'Optional: Extract specific attribute instead of text content (e.g., "href", "value")',
31
- required: false
32
- }
33
- ];
34
-
35
- async execute(params: Record<string, any>, context: ToolExecutionContext): Promise<ToolResult> {
36
- const { page, memory, logger } = context;
37
- const journeyMemory = memory as JourneyMemory;
38
- const { selector, dataName, attribute } = params;
39
-
40
- try {
41
- logger?.(`[ExtractData] Extracting "${dataName}" from selector: ${selector}`, 'log');
42
-
43
- // Try to find element
44
- const element = await page.locator(selector).first();
45
- const count = await page.locator(selector).count();
46
-
47
- if (count === 0) {
48
- logger?.(`[ExtractData] ✗ Element not found: ${selector}`, 'error');
49
- return {
50
- success: false,
51
- error: `Element not found: ${selector}`
52
- };
53
- }
54
-
55
- // Extract data
56
- let extractedValue: string;
57
- if (attribute) {
58
- extractedValue = await element.getAttribute(attribute) || '';
59
- } else {
60
- extractedValue = await element.textContent() || '';
61
- }
62
-
63
- extractedValue = extractedValue.trim();
64
-
65
- if (!extractedValue) {
66
- logger?.(`[ExtractData] ⚠ Extracted empty value from ${selector}`, 'warn');
67
- }
68
-
69
- // Save to memory
70
- journeyMemory.extractedData[dataName] = extractedValue;
71
-
72
- logger?.(`[ExtractData] ✓ Saved "${dataName}" = "${extractedValue.substring(0, 50)}${extractedValue.length > 50 ? '...' : ''}"`, 'log');
73
-
74
- return {
75
- success: true,
76
- data: {
77
- dataName,
78
- value: extractedValue,
79
- selector,
80
- attribute
81
- }
82
- };
83
- } catch (error: any) {
84
- logger?.(`[ExtractData] ✗ Failed: ${error.message}`, 'error');
85
- return {
86
- success: false,
87
- error: `Data extraction failed: ${error.message}`
88
- };
89
- }
90
- }
91
- }
92
-
@@ -1,15 +0,0 @@
1
- /**
2
- * Tool exports - 8 information-gathering tools
3
- * Note: State changes (navigation, clicks, fills) are done via Playwright commands, not tools
4
- * Ref-based commands (getByRef) are translated to Playwright at execution time
5
- */
6
-
7
- export { TakeScreenshotTool } from './take-screenshot';
8
- export { ViewPreviousScreenshotTool } from './view-previous-screenshot';
9
- export { RefreshSomMarkersTool } from './refresh-som-markers';
10
- export { RecallHistoryTool } from './recall-history';
11
- export { InspectPageTool } from './inspect-page';
12
- export { CheckPageReadyTool } from './check-page-ready';
13
- export { ExtractDataTool } from './extract-data';
14
- export { VerifyActionResultTool } from './verify-action-result';
15
-
@@ -1,42 +0,0 @@
1
- /**
2
- * Inspect Page Tool
3
- * Get current DOM snapshot (might be redundant since DOM is always-provided, but keeps extensibility)
4
- */
5
-
6
- import { Tool, ToolParameter, ToolExecutionContext } from '../tool-registry';
7
- import { ToolResult } from '../types';
8
- import { getEnhancedPageInfo } from '../../utils/page-info-utils';
9
-
10
- export class InspectPageTool implements Tool {
11
- name = 'inspect_page';
12
- description = 'Get current page DOM snapshot. Note: Current page info is already provided in context, so this tool is mainly for forcing a fresh snapshot if needed.';
13
-
14
- parameters: ToolParameter[] = [];
15
-
16
- async execute(params: Record<string, any>, context: ToolExecutionContext): Promise<ToolResult> {
17
- const { page, logger } = context;
18
-
19
- try {
20
- logger?.(`[InspectPage] Getting fresh DOM snapshot`, 'log');
21
-
22
- const pageInfo = await getEnhancedPageInfo(page);
23
-
24
- logger?.(`[InspectPage] ✓ DOM snapshot retrieved`, 'log');
25
-
26
- return {
27
- success: true,
28
- data: {
29
- pageInfo,
30
- url: page.url()
31
- }
32
- };
33
- } catch (error: any) {
34
- logger?.(`[InspectPage] ✗ Failed: ${error.message}`, 'error');
35
- return {
36
- success: false,
37
- error: `Page inspection failed: ${error.message}`
38
- };
39
- }
40
- }
41
- }
42
-
@@ -1,72 +0,0 @@
1
- /**
2
- * Recall History Tool
3
- * Access deeper history beyond the recent 6-7 steps always provided
4
- */
5
-
6
- import { Tool, ToolParameter, ToolExecutionContext } from '../tool-registry';
7
- import { ToolResult } from '../types';
8
- import { JourneyMemory } from '../types';
9
-
10
- export class RecallHistoryTool implements Tool {
11
- name = 'recall_history';
12
- description = 'Access journey history beyond the recent 6-7 steps always provided in context. Use when you need to remember what happened earlier in the journey.';
13
-
14
- parameters: ToolParameter[] = [
15
- {
16
- name: 'maxSteps',
17
- type: 'number',
18
- description: 'Maximum number of historical steps to retrieve (from most recent backwards)',
19
- required: false,
20
- default: 10
21
- },
22
- {
23
- name: 'query',
24
- type: 'string',
25
- description: 'Optional: Filter for specific actions (e.g., "login", "form fill")',
26
- required: false
27
- }
28
- ];
29
-
30
- async execute(params: Record<string, any>, context: ToolExecutionContext): Promise<ToolResult> {
31
- const { memory, logger } = context;
32
- const journeyMemory = memory as JourneyMemory;
33
- const maxSteps = params.maxSteps || 10;
34
- const query = params.query?.toLowerCase();
35
-
36
- try {
37
- logger?.(`[RecallHistory] Retrieving up to ${maxSteps} historical steps${query ? ` matching "${query}"` : ''}`, 'log');
38
-
39
- let steps = [...journeyMemory.history];
40
-
41
- // Filter by query if provided
42
- if (query) {
43
- steps = steps.filter(step =>
44
- step.action.toLowerCase().includes(query) ||
45
- step.code.toLowerCase().includes(query) ||
46
- step.observation.toLowerCase().includes(query)
47
- );
48
- }
49
-
50
- // Take most recent N steps
51
- const recentSteps = steps.slice(-maxSteps);
52
-
53
- logger?.(`[RecallHistory] ✓ Found ${recentSteps.length} historical steps`, 'log');
54
-
55
- return {
56
- success: true,
57
- data: {
58
- steps: recentSteps,
59
- totalHistorySize: journeyMemory.history.length,
60
- filtered: !!query
61
- }
62
- };
63
- } catch (error: any) {
64
- logger?.(`[RecallHistory] ✗ Failed: ${error.message}`, 'error');
65
- return {
66
- success: false,
67
- error: `History recall failed: ${error.message}`
68
- };
69
- }
70
- }
71
- }
72
-