@morphllm/morphsdk 0.2.18 → 0.2.20

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 (53) hide show
  1. package/dist/anthropic-CknfcMoO.d.ts +64 -0
  2. package/dist/{chunk-UFIIEUGW.js → chunk-XUL4CHWU.js} +9 -9
  3. package/dist/{chunk-VONZKK4S.js → chunk-YVGRWE7D.js} +1 -1
  4. package/dist/chunk-YVGRWE7D.js.map +1 -0
  5. package/dist/client.d.ts +114 -0
  6. package/dist/client.js +4 -4
  7. package/dist/git/client.d.ts +230 -0
  8. package/dist/git/config.d.ts +11 -0
  9. package/dist/git/index.d.ts +5 -0
  10. package/dist/git/types.d.ts +91 -0
  11. package/dist/index.d.ts +14 -0
  12. package/dist/index.js +10 -10
  13. package/dist/modelrouter/core.d.ts +56 -0
  14. package/dist/modelrouter/index.d.ts +2 -0
  15. package/dist/modelrouter/types.d.ts +35 -0
  16. package/dist/openai-BkKsS30n.d.ts +111 -0
  17. package/dist/tools/browser/anthropic.d.ts +51 -0
  18. package/dist/tools/browser/core.d.ts +196 -0
  19. package/dist/tools/browser/index.d.ts +72 -0
  20. package/dist/tools/browser/openai.d.ts +69 -0
  21. package/dist/tools/browser/prompts.d.ts +7 -0
  22. package/dist/tools/browser/types.d.ts +227 -0
  23. package/dist/tools/browser/vercel.cjs +1 -1
  24. package/dist/tools/browser/vercel.cjs.map +1 -1
  25. package/dist/tools/browser/vercel.d.ts +69 -0
  26. package/dist/tools/browser/vercel.js +1 -1
  27. package/dist/tools/browser/vercel.js.map +1 -1
  28. package/dist/tools/codebase_search/anthropic.d.ts +40 -0
  29. package/dist/tools/codebase_search/core.d.ts +40 -0
  30. package/dist/tools/codebase_search/index.cjs.map +1 -1
  31. package/dist/tools/codebase_search/index.d.ts +10 -0
  32. package/dist/tools/codebase_search/index.js +4 -4
  33. package/dist/tools/codebase_search/openai.d.ts +87 -0
  34. package/dist/tools/codebase_search/prompts.d.ts +7 -0
  35. package/dist/tools/codebase_search/types.d.ts +46 -0
  36. package/dist/tools/codebase_search/vercel.cjs.map +1 -1
  37. package/dist/tools/codebase_search/vercel.d.ts +65 -0
  38. package/dist/tools/codebase_search/vercel.js +1 -1
  39. package/dist/tools/fastapply/anthropic.d.ts +4 -0
  40. package/dist/tools/fastapply/core.d.ts +41 -0
  41. package/dist/tools/fastapply/index.d.ts +10 -0
  42. package/dist/tools/fastapply/index.js +3 -3
  43. package/dist/tools/fastapply/openai.d.ts +4 -0
  44. package/dist/tools/fastapply/prompts.d.ts +7 -0
  45. package/dist/tools/fastapply/types.d.ts +77 -0
  46. package/dist/tools/fastapply/vercel.d.ts +4 -0
  47. package/dist/tools/index.d.ts +10 -0
  48. package/dist/tools/index.js +3 -3
  49. package/dist/tools/utils/resilience.d.ts +58 -0
  50. package/dist/vercel-B1GZ_g9N.d.ts +69 -0
  51. package/package.json +1 -1
  52. package/dist/chunk-VONZKK4S.js.map +0 -1
  53. /package/dist/{chunk-UFIIEUGW.js.map → chunk-XUL4CHWU.js.map} +0 -0
@@ -0,0 +1,2 @@
1
+ export { AnthropicRouter, GeminiRouter, OpenAIRouter } from './core.js';
2
+ export { ComplexityLevel, Provider, RouterConfig, RouterInput, RouterMode, RouterResult } from './types.js';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Model router types for intelligent model selection
3
+ */
4
+ type ComplexityLevel = 'easy' | 'medium' | 'hard' | 'needs-info';
5
+ type RouterMode = 'balanced' | 'aggressive';
6
+ type Provider = 'openai' | 'anthropic' | 'gemini';
7
+ interface RouterConfig {
8
+ /** Morph API key (defaults to MORPH_API_KEY env var) */
9
+ apiKey?: string;
10
+ /** Router API URL (defaults to https://api.morphllm.com) */
11
+ apiUrl?: string;
12
+ /** Request timeout in milliseconds (default: 10000) */
13
+ timeout?: number;
14
+ /** Enable debug logging */
15
+ debug?: boolean;
16
+ /** Retry configuration */
17
+ retryConfig?: {
18
+ maxRetries?: number;
19
+ initialDelay?: number;
20
+ maxDelay?: number;
21
+ backoffMultiplier?: number;
22
+ };
23
+ }
24
+ interface RouterInput {
25
+ /** User input or task description */
26
+ input: string;
27
+ /** Routing mode: balanced (cheaper models) or aggressive (more capable models) */
28
+ mode?: RouterMode;
29
+ }
30
+ interface RouterResult {
31
+ /** Selected model name */
32
+ model: string;
33
+ }
34
+
35
+ export type { ComplexityLevel, Provider, RouterConfig, RouterInput, RouterMode, RouterResult };
@@ -0,0 +1,111 @@
1
+ import { ChatCompletionTool } from 'openai/resources/chat/completions';
2
+ import { EditFileInput, EditFileConfig, EditFileResult } from './tools/fastapply/types.js';
3
+
4
+ /**
5
+ * OpenAI SDK adapter for edit_file tool
6
+ */
7
+
8
+ /**
9
+ * OpenAI-native tool definition for edit_file
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import OpenAI from 'openai';
14
+ * import { editFileTool } from 'morphsdk/tools/openai';
15
+ *
16
+ * const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
17
+ *
18
+ * const response = await client.chat.completions.create({
19
+ * model: "gpt-4o",
20
+ * tools: [editFileTool],
21
+ * messages: [{ role: "user", content: "Fix the bug in app.ts" }]
22
+ * });
23
+ * ```
24
+ */
25
+ declare const editFileTool: ChatCompletionTool;
26
+ /**
27
+ * Execute an edit_file tool call
28
+ *
29
+ * @param input - The tool input from GPT (parsed from tool_calls)
30
+ * @param config - Optional configuration
31
+ * @returns The result of the edit operation
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const args = JSON.parse(toolCall.function.arguments);
36
+ * const result = await execute(args);
37
+ * console.log('Changes applied:', result.udiff);
38
+ * ```
39
+ */
40
+ declare function execute(input: EditFileInput, config?: EditFileConfig): Promise<EditFileResult>;
41
+ /**
42
+ * Get the system prompt for edit_file usage
43
+ *
44
+ * Add this to your system message to guide GPT on using edit_file properly.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const response = await client.chat.completions.create({
49
+ * model: "gpt-4o",
50
+ * messages: [
51
+ * { role: "system", content: getSystemPrompt() },
52
+ * { role: "user", content: "Fix bugs" }
53
+ * ],
54
+ * tools: [editFileTool]
55
+ * });
56
+ * ```
57
+ */
58
+ declare function getSystemPrompt(): string;
59
+ /**
60
+ * Format the result for passing back to GPT
61
+ *
62
+ * @param result - The edit result
63
+ * @returns Formatted string for tool message
64
+ */
65
+ declare function formatResult(result: EditFileResult): string;
66
+ /**
67
+ * Create a custom edit_file tool with configuration and methods
68
+ *
69
+ * @param config - Configuration options
70
+ * @returns Tool definition with execute and formatResult methods
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * import OpenAI from 'openai';
75
+ * import { createEditFileTool } from 'morphsdk/tools/fastapply/openai';
76
+ *
77
+ * const tool = createEditFileTool({
78
+ * baseDir: './src',
79
+ * generateUdiff: true,
80
+ * description: 'Custom tool description for your use case'
81
+ * });
82
+ *
83
+ * const client = new OpenAI();
84
+ *
85
+ * const response = await client.chat.completions.create({
86
+ * model: 'gpt-4o',
87
+ * tools: [tool], // tool itself is the ChatCompletionTool
88
+ * messages: [{ role: 'user', content: 'Fix bug in app.ts' }]
89
+ * });
90
+ *
91
+ * // Execute and format
92
+ * const result = await tool.execute(toolCallArgs);
93
+ * const formatted = tool.formatResult(result);
94
+ * ```
95
+ */
96
+ declare function createEditFileTool(config?: EditFileConfig): ChatCompletionTool & {
97
+ execute: (input: EditFileInput | string) => Promise<EditFileResult>;
98
+ formatResult: (result: EditFileResult) => string;
99
+ getSystemPrompt: () => string;
100
+ };
101
+
102
+ declare const openai_createEditFileTool: typeof createEditFileTool;
103
+ declare const openai_editFileTool: typeof editFileTool;
104
+ declare const openai_execute: typeof execute;
105
+ declare const openai_formatResult: typeof formatResult;
106
+ declare const openai_getSystemPrompt: typeof getSystemPrompt;
107
+ declare namespace openai {
108
+ export { openai_createEditFileTool as createEditFileTool, editFileTool as default, openai_editFileTool as editFileTool, openai_execute as execute, openai_formatResult as formatResult, openai_getSystemPrompt as getSystemPrompt };
109
+ }
110
+
111
+ export { execute as a, createEditFileTool as c, editFileTool as e, formatResult as f, getSystemPrompt as g, openai as o };
@@ -0,0 +1,51 @@
1
+ import { Tool } from '@anthropic-ai/sdk/resources/messages.mjs';
2
+ import { BrowserConfig, BrowserTaskInput, BrowserTaskResult } from './types.js';
3
+ import '../utils/resilience.js';
4
+
5
+ /**
6
+ * Anthropic SDK adapter for browser automation tool
7
+ */
8
+
9
+ /**
10
+ * Anthropic tool definition for browser automation
11
+ */
12
+ declare const browserTool: Tool;
13
+ /**
14
+ * Create a configured browser tool with execute and formatResult methods
15
+ *
16
+ * @param config - Browser worker configuration
17
+ * @returns Tool definition with execute and formatResult methods
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import Anthropic from '@anthropic-ai/sdk';
22
+ * import { createBrowserTool } from 'morphsdk/tools/browser/anthropic';
23
+ *
24
+ * const tool = createBrowserTool({
25
+ * apiKey: process.env.MORPH_API_KEY,
26
+ * timeout: 180000
27
+ * });
28
+ *
29
+ * const client = new Anthropic();
30
+ *
31
+ * const response = await client.messages.create({
32
+ * model: 'claude-sonnet-4-5-20250929',
33
+ * tools: [tool], // tool itself is the Tool definition
34
+ * messages: [{
35
+ * role: 'user',
36
+ * content: 'Test the checkout flow at https://3000-abc.e2b.dev'
37
+ * }]
38
+ * });
39
+ *
40
+ * // Execute and format
41
+ * const result = await tool.execute(toolUseBlock.input);
42
+ * const formatted = tool.formatResult(result);
43
+ * ```
44
+ */
45
+ declare function createBrowserTool(config?: BrowserConfig): Tool & {
46
+ execute: (input: BrowserTaskInput) => Promise<BrowserTaskResult>;
47
+ formatResult: (result: BrowserTaskResult) => string;
48
+ getSystemPrompt: () => string;
49
+ };
50
+
51
+ export { browserTool, createBrowserTool };
@@ -0,0 +1,196 @@
1
+ import { BrowserConfig, BrowserTaskInput, BrowserTaskResult, BrowserTaskWithPromise, BrowserTaskInputWithSchema, BrowserTaskWithPromiseAndSchema, RecordingStatus, ErrorsResponse } from './types.js';
2
+ import '../utils/resilience.js';
3
+
4
+ /**
5
+ * Core implementation for browser automation tasks
6
+ */
7
+
8
+ /**
9
+ * BrowserClient class for easier usage with instance configuration
10
+ */
11
+ declare class BrowserClient {
12
+ private config;
13
+ constructor(config?: BrowserConfig);
14
+ /**
15
+ * Execute a browser automation task
16
+ */
17
+ execute(input: BrowserTaskInput): Promise<BrowserTaskResult>;
18
+ createTask(input: BrowserTaskInput): Promise<BrowserTaskWithPromise>;
19
+ createTask<T>(input: BrowserTaskInputWithSchema<T>): Promise<BrowserTaskWithPromiseAndSchema<T>>;
20
+ /**
21
+ * Execute task with recording and wait for video to be ready
22
+ */
23
+ executeWithRecording(input: BrowserTaskInput & {
24
+ record_video: true;
25
+ }): Promise<BrowserTaskResult & {
26
+ recording?: RecordingStatus;
27
+ }>;
28
+ /**
29
+ * Get recording status and URLs
30
+ */
31
+ getRecording(recordingId: string): Promise<RecordingStatus>;
32
+ /**
33
+ * Wait for recording to complete with automatic polling
34
+ */
35
+ waitForRecording(recordingId: string, options?: {
36
+ timeout?: number;
37
+ pollInterval?: number;
38
+ }): Promise<RecordingStatus>;
39
+ /**
40
+ * Get errors from recording with screenshots
41
+ */
42
+ getErrors(recordingId: string): Promise<ErrorsResponse>;
43
+ /**
44
+ * Check if browser worker service is healthy
45
+ */
46
+ checkHealth(): Promise<{
47
+ ok: boolean;
48
+ google_configured: boolean;
49
+ database_configured: boolean;
50
+ s3_configured: boolean;
51
+ error?: string;
52
+ }>;
53
+ }
54
+ /**
55
+ * Execute a natural language browser automation task
56
+ *
57
+ * @param input - Task parameters
58
+ * @param config - Optional configuration (apiKey, apiUrl to override default)
59
+ * @returns Task result with success status and findings
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const result = await executeBrowserTask(
64
+ * {
65
+ * task: "Test checkout flow for buying a pineapple",
66
+ * url: "https://3000-abc.e2b.dev",
67
+ * max_steps: 20,
68
+ * repo_id: "my-project",
69
+ * commit_id: "uuid-here"
70
+ * },
71
+ * {
72
+ * apiKey: process.env.MORPH_API_KEY,
73
+ * // apiUrl: 'http://localhost:8001' // Override for local testing
74
+ * }
75
+ * );
76
+ *
77
+ * if (result.success) {
78
+ * console.log('Task completed:', result.result);
79
+ * console.log('Replay:', result.replay_url);
80
+ * }
81
+ * ```
82
+ */
83
+ declare function executeBrowserTask(input: BrowserTaskInput, config?: BrowserConfig): Promise<BrowserTaskResult>;
84
+ /**
85
+ * Get recording status and video URL
86
+ *
87
+ * @param recordingId - Recording UUID from BrowserTaskResult
88
+ * @param config - Configuration with apiKey
89
+ * @returns Recording status with video URL when ready
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * const status = await getRecording('uuid-here', { apiKey: 'key' });
94
+ * if (status.status === 'COMPLETED' && status.video_url) {
95
+ * console.log('Video ready:', status.video_url);
96
+ * }
97
+ * ```
98
+ */
99
+ declare function getRecording(recordingId: string, config?: BrowserConfig): Promise<RecordingStatus>;
100
+ /**
101
+ * Wait for recording to complete with automatic polling
102
+ *
103
+ * @param recordingId - Recording UUID
104
+ * @param config - Configuration with apiKey
105
+ * @param options - Polling options
106
+ * @returns Recording status when completed or errored
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const result = await executeBrowserTask({ task: '...', record_video: true }, config);
111
+ * if (result.recording_id) {
112
+ * const recording = await waitForRecording(result.recording_id, config, {
113
+ * timeout: 60000, // 1 minute
114
+ * pollInterval: 2000 // Check every 2 seconds
115
+ * });
116
+ * console.log('Video URL:', recording.video_url);
117
+ * }
118
+ * ```
119
+ */
120
+ declare function waitForRecording(recordingId: string, config?: BrowserConfig, options?: {
121
+ timeout?: number;
122
+ pollInterval?: number;
123
+ }): Promise<RecordingStatus>;
124
+ /**
125
+ * Execute task with recording and wait for video to be ready
126
+ *
127
+ * @param input - Task parameters with record_video=true
128
+ * @param config - Configuration with apiKey
129
+ * @returns Task result with ready video URL
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * const result = await executeWithRecording(
134
+ * {
135
+ * task: "Test checkout flow",
136
+ * url: "https://example.com",
137
+ * record_video: true,
138
+ * repo_id: "my-project"
139
+ * },
140
+ * { apiKey: process.env.MORPH_API_KEY }
141
+ * );
142
+ *
143
+ * console.log('Task result:', result.result);
144
+ * console.log('Video URL:', result.recording?.video_url);
145
+ * ```
146
+ */
147
+ declare function executeWithRecording(input: BrowserTaskInput & {
148
+ record_video: true;
149
+ }, config?: BrowserConfig): Promise<BrowserTaskResult & {
150
+ recording?: RecordingStatus;
151
+ }>;
152
+ /**
153
+ * Get errors from recording with screenshots
154
+ *
155
+ * Screenshots are captured in real-time (500ms after error occurs) during the browser session.
156
+ *
157
+ * @param recordingId - Recording UUID from BrowserTaskResult
158
+ * @param config - Configuration with apiKey
159
+ * @returns Errors with real-time screenshots
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * const { errors, total_errors } = await getErrors('uuid-here', { apiKey: 'key' });
164
+ *
165
+ * console.log(`Found ${total_errors} errors`);
166
+ *
167
+ * errors.forEach(err => {
168
+ * console.log(`[${err.type}] ${err.message}`);
169
+ * if (err.url) console.log(` URL: ${err.url}`);
170
+ * if (err.screenshot_url) console.log(` Screenshot: ${err.screenshot_url}`);
171
+ *
172
+ * // Download screenshot
173
+ * if (err.screenshot_url) {
174
+ * const response = await fetch(err.screenshot_url);
175
+ * const screenshot = await response.arrayBuffer();
176
+ * // Save or process screenshot
177
+ * }
178
+ * });
179
+ * ```
180
+ */
181
+ declare function getErrors(recordingId: string, config?: BrowserConfig): Promise<ErrorsResponse>;
182
+ /**
183
+ * Check if browser worker service is healthy
184
+ *
185
+ * @param config - Optional configuration
186
+ * @returns Health status
187
+ */
188
+ declare function checkHealth(config?: BrowserConfig): Promise<{
189
+ ok: boolean;
190
+ google_configured: boolean;
191
+ database_configured: boolean;
192
+ s3_configured: boolean;
193
+ error?: string;
194
+ }>;
195
+
196
+ export { BrowserClient, checkHealth, executeBrowserTask, executeWithRecording, getErrors, getRecording, waitForRecording };
@@ -0,0 +1,72 @@
1
+ export { BrowserClient, checkHealth, executeBrowserTask, executeWithRecording, getErrors, getRecording, waitForRecording } from './core.js';
2
+ import { LiveSessionOptions, IframeOptions } from './types.js';
3
+ export { BrowserConfig, BrowserError, BrowserModel, BrowserTaskInput, BrowserTaskInputWithSchema, BrowserTaskResult, BrowserTaskWithPromise, BrowserTaskWithPromiseAndSchema, ErrorsResponse, RecordingStatus } from './types.js';
4
+ export { BROWSER_SYSTEM_PROMPT, BROWSER_TOOL_DESCRIPTION } from './prompts.js';
5
+ import '../utils/resilience.js';
6
+
7
+ /**
8
+ * Live session utilities for Morph browser sessions
9
+ *
10
+ * Provides helpers for embedding and sharing live browser sessions with WebRTC streaming.
11
+ */
12
+
13
+ /**
14
+ * Preset configurations for common use cases
15
+ */
16
+ declare const LIVE_PRESETS: {
17
+ /** Read-only monitoring (no interaction) */
18
+ readonly readonly: LiveSessionOptions;
19
+ /** Interactive control (human-in-the-loop) */
20
+ readonly interactive: LiveSessionOptions;
21
+ /** Watch-only without controls */
22
+ readonly monitoring: LiveSessionOptions;
23
+ };
24
+ /**
25
+ * Build a live session URL with query parameters
26
+ *
27
+ * @param debugUrl - Live session debug URL (e.g., from task.debugUrl)
28
+ * @param options - Live session configuration options
29
+ * @returns URL with query parameters for iframe embedding
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const url = buildLiveUrl(task.debugUrl, { interactive: true });
34
+ * // Returns: https://example.com/sessions/abc?interactive=true
35
+ * ```
36
+ */
37
+ declare function buildLiveUrl(debugUrl: string, options?: LiveSessionOptions): string;
38
+ /**
39
+ * Build iframe HTML for embedding a live session
40
+ *
41
+ * @param debugUrl - Live session debug URL
42
+ * @param options - Iframe configuration including dimensions and session options
43
+ * @returns HTML iframe element as string
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const iframe = buildLiveIframe(task.debugUrl, {
48
+ * interactive: true,
49
+ * width: '100%',
50
+ * height: '600px'
51
+ * });
52
+ * ```
53
+ */
54
+ declare function buildLiveIframe(debugUrl: string, options?: IframeOptions): string;
55
+ /**
56
+ * Build complete embed code with HTML snippet
57
+ *
58
+ * @param debugUrl - Live session debug URL
59
+ * @param options - Iframe configuration
60
+ * @returns Multi-line HTML snippet ready to copy-paste
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const code = buildEmbedCode(task.debugUrl, { interactive: false });
65
+ * console.log(code);
66
+ * // <!-- Embed Morph Live Session -->
67
+ * // <iframe src="..." style="..."></iframe>
68
+ * ```
69
+ */
70
+ declare function buildEmbedCode(debugUrl: string, options?: IframeOptions): string;
71
+
72
+ export { IframeOptions, LIVE_PRESETS, LiveSessionOptions, buildEmbedCode, buildLiveIframe, buildLiveUrl };
@@ -0,0 +1,69 @@
1
+ import { ChatCompletionTool } from 'openai/resources/chat/completions.mjs';
2
+ import { BrowserTaskInput, BrowserConfig, BrowserTaskResult } from './types.js';
3
+ import '../utils/resilience.js';
4
+
5
+ /**
6
+ * OpenAI SDK adapter for browser automation tool
7
+ */
8
+
9
+ /**
10
+ * OpenAI tool definition for browser automation
11
+ */
12
+ declare const browserTool: ChatCompletionTool;
13
+ /**
14
+ * Execute a browser task (for use in tool call handling)
15
+ *
16
+ * @param input - Tool input parameters (may be JSON string)
17
+ * @param config - Optional browser worker configuration
18
+ * @returns Task execution result
19
+ */
20
+ declare function execute(input: BrowserTaskInput | string, config?: BrowserConfig): Promise<BrowserTaskResult>;
21
+ /**
22
+ * Format browser task result for OpenAI tool result
23
+ *
24
+ * @param result - Browser task result
25
+ * @returns Formatted string for tool result
26
+ */
27
+ declare function formatResult(result: BrowserTaskResult): string;
28
+ /**
29
+ * Get system prompt for browser automation
30
+ */
31
+ declare function getSystemPrompt(): string;
32
+ /**
33
+ * Create a configured browser tool with execute and formatResult methods
34
+ *
35
+ * @param config - Browser worker configuration
36
+ * @returns Tool definition with execute and formatResult methods
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * import OpenAI from 'openai';
41
+ * import { createBrowserTool } from 'morphsdk/tools/browser/openai';
42
+ *
43
+ * const tool = createBrowserTool({
44
+ * apiUrl: 'https://browser-worker.example.com'
45
+ * });
46
+ *
47
+ * const client = new OpenAI();
48
+ *
49
+ * const response = await client.chat.completions.create({
50
+ * model: 'gpt-4o',
51
+ * tools: [tool], // tool itself is the ChatCompletionTool
52
+ * messages: [{
53
+ * role: 'user',
54
+ * content: 'Test the checkout at https://3000-abc.e2b.dev'
55
+ * }]
56
+ * });
57
+ *
58
+ * // Execute and format
59
+ * const result = await tool.execute(toolCallArgs);
60
+ * const formatted = tool.formatResult(result);
61
+ * ```
62
+ */
63
+ declare function createBrowserTool(config?: BrowserConfig): ChatCompletionTool & {
64
+ execute: (input: BrowserTaskInput | string) => Promise<BrowserTaskResult>;
65
+ formatResult: (result: BrowserTaskResult) => string;
66
+ getSystemPrompt: () => string;
67
+ };
68
+
69
+ export { browserTool, createBrowserTool, execute, formatResult, getSystemPrompt };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tool descriptions and prompts for AI models
3
+ */
4
+ declare const BROWSER_TOOL_DESCRIPTION = "Execute natural language browser automation tasks using an AI-powered agent. The agent can navigate websites, interact with elements, fill forms, click buttons, and verify functionality.\n\nUse this tool to:\n- Test web applications end-to-end\n- Verify UI functionality\n- Automate user workflows\n- Extract information from web pages\n\nThe agent uses GPT-4o-mini to interpret your task and execute the necessary browser actions. It runs in a remote browser via Browserless.io, so it can access any publicly accessible URL.\n\nImportant:\n- Provide clear, specific task descriptions\n- Include the starting URL if navigating to a specific page\n- Use remote URLs (e.g., https://3000-xyz.e2b.dev) not localhost\n- Complex tasks may require more max_steps";
5
+ declare const BROWSER_SYSTEM_PROMPT = "You have access to browser automation capabilities. When testing or interacting with web applications:\n\n1. Be specific about what you're testing or verifying\n2. Break complex tasks into clear steps\n3. Always provide the full URL including protocol (https://)\n4. For localhost apps, use the remote tunnel URL (e.g., e2b.dev URLs)\n5. Specify the number of steps needed - simple tasks use 5-10, complex flows use 15-30\n\nExample good tasks:\n- \"Go to https://3000-abc.e2b.dev and verify the landing page loads with a hero section\"\n- \"Test guest checkout: add a pineapple to cart, proceed to checkout, fill shipping info, and verify order summary\"\n- \"Navigate to the dashboard and click on the settings tab, then verify the API keys section is visible\"\n\nExample bad tasks:\n- \"test the app\" (too vague)\n- \"go to localhost:3000\" (use remote URL instead)\n- \"do everything\" (not specific enough)";
6
+
7
+ export { BROWSER_SYSTEM_PROMPT, BROWSER_TOOL_DESCRIPTION };