@morphllm/morphsdk 0.2.38 → 0.2.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-AKVAAKRB.js → chunk-3NTGAUTJ.js} +73 -2
- package/dist/chunk-3NTGAUTJ.js.map +1 -0
- package/dist/{chunk-TBVDBQZ2.js → chunk-4WIBODS7.js} +61 -3
- package/dist/chunk-4WIBODS7.js.map +1 -0
- package/dist/{chunk-LN4CTQZG.js → chunk-7MCSSJJA.js} +2 -2
- package/dist/{chunk-DJSQUQGY.js → chunk-DIWNR3UP.js} +3 -3
- package/dist/{chunk-W5CHJ6OX.js → chunk-JSZQVUSE.js} +2 -2
- package/dist/{chunk-YSBSDU75.js → chunk-LUI7APXX.js} +2 -2
- package/dist/{chunk-EAA7D24N.js → chunk-N5654KQR.js} +13 -13
- package/dist/client.cjs +60 -2
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +3 -3
- package/dist/git/client.cjs +60 -2
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.js +1 -1
- package/dist/git/index.cjs +60 -2
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.js +1 -1
- package/dist/git/types.cjs.map +1 -1
- package/dist/index.cjs +60 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/modelrouter/core.cjs +74 -2
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +5 -3
- package/dist/modelrouter/index.cjs +74 -2
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +5 -3
- package/dist/modelrouter/types.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +5 -5
- package/dist/tools/warp_grep/anthropic.js +6 -6
- package/dist/tools/warp_grep/index.js +8 -8
- package/dist/tools/warp_grep/openai.js +6 -6
- package/dist/tools/warp_grep/vercel.js +6 -6
- package/package.json +1 -1
- package/dist/anthropic-DpEAqqZF.d.ts +0 -88
- package/dist/chunk-AKVAAKRB.js.map +0 -1
- package/dist/chunk-TBVDBQZ2.js.map +0 -1
- package/dist/client.d.ts +0 -114
- package/dist/git/client.d.ts +0 -261
- package/dist/git/config.d.ts +0 -11
- package/dist/git/index.d.ts +0 -5
- package/dist/git/types.d.ts +0 -102
- package/dist/index.d.ts +0 -14
- package/dist/modelrouter/core.d.ts +0 -56
- package/dist/modelrouter/index.d.ts +0 -2
- package/dist/modelrouter/types.d.ts +0 -35
- package/dist/openai-BkKsS30n.d.ts +0 -111
- package/dist/tools/browser/anthropic.d.ts +0 -51
- package/dist/tools/browser/core.d.ts +0 -203
- package/dist/tools/browser/index.d.ts +0 -72
- package/dist/tools/browser/openai.d.ts +0 -73
- package/dist/tools/browser/prompts.d.ts +0 -7
- package/dist/tools/browser/types.d.ts +0 -255
- package/dist/tools/browser/vercel.d.ts +0 -69
- package/dist/tools/codebase_search/anthropic.d.ts +0 -40
- package/dist/tools/codebase_search/core.d.ts +0 -40
- package/dist/tools/codebase_search/index.d.ts +0 -10
- package/dist/tools/codebase_search/openai.d.ts +0 -87
- package/dist/tools/codebase_search/prompts.d.ts +0 -7
- package/dist/tools/codebase_search/types.d.ts +0 -50
- package/dist/tools/codebase_search/vercel.d.ts +0 -65
- package/dist/tools/fastapply/anthropic.d.ts +0 -4
- package/dist/tools/fastapply/core.d.ts +0 -41
- package/dist/tools/fastapply/index.d.ts +0 -10
- package/dist/tools/fastapply/openai.d.ts +0 -4
- package/dist/tools/fastapply/prompts.d.ts +0 -7
- package/dist/tools/fastapply/types.d.ts +0 -77
- package/dist/tools/fastapply/vercel.d.ts +0 -4
- package/dist/tools/index.d.ts +0 -10
- package/dist/tools/utils/resilience.d.ts +0 -58
- package/dist/tools/warp_grep/agent/config.d.ts +0 -8
- package/dist/tools/warp_grep/agent/formatter.d.ts +0 -14
- package/dist/tools/warp_grep/agent/grep_helpers.d.ts +0 -16
- package/dist/tools/warp_grep/agent/parser.d.ts +0 -16
- package/dist/tools/warp_grep/agent/prompt.d.ts +0 -4
- package/dist/tools/warp_grep/agent/runner.d.ts +0 -10
- package/dist/tools/warp_grep/agent/types.d.ts +0 -44
- package/dist/tools/warp_grep/anthropic.d.ts +0 -14
- package/dist/tools/warp_grep/index.d.ts +0 -11
- package/dist/tools/warp_grep/openai.d.ts +0 -33
- package/dist/tools/warp_grep/providers/command.d.ts +0 -48
- package/dist/tools/warp_grep/providers/local.d.ts +0 -30
- package/dist/tools/warp_grep/providers/types.d.ts +0 -49
- package/dist/tools/warp_grep/tools/analyse.d.ts +0 -10
- package/dist/tools/warp_grep/tools/finish.d.ts +0 -10
- package/dist/tools/warp_grep/tools/grep.d.ts +0 -8
- package/dist/tools/warp_grep/tools/read.d.ts +0 -9
- package/dist/tools/warp_grep/utils/files.d.ts +0 -3
- package/dist/tools/warp_grep/utils/format.d.ts +0 -4
- package/dist/tools/warp_grep/utils/paths.d.ts +0 -7
- package/dist/tools/warp_grep/utils/ripgrep.d.ts +0 -11
- package/dist/tools/warp_grep/vercel.d.ts +0 -33
- package/dist/vercel-B1GZ_g9N.d.ts +0 -69
- /package/dist/{chunk-LN4CTQZG.js.map → chunk-7MCSSJJA.js.map} +0 -0
- /package/dist/{chunk-DJSQUQGY.js.map → chunk-DIWNR3UP.js.map} +0 -0
- /package/dist/{chunk-W5CHJ6OX.js.map → chunk-JSZQVUSE.js.map} +0 -0
- /package/dist/{chunk-YSBSDU75.js.map → chunk-LUI7APXX.js.map} +0 -0
- /package/dist/{chunk-EAA7D24N.js.map → chunk-N5654KQR.js.map} +0 -0
|
@@ -1,111 +0,0 @@
|
|
|
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 };
|
|
@@ -1,51 +0,0 @@
|
|
|
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 };
|
|
@@ -1,203 +0,0 @@
|
|
|
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
|
-
* Returns the full task result including rich agent history data (urls, errors,
|
|
58
|
-
* action_history, judgement, etc.). When using this as an agent tool, use the
|
|
59
|
-
* formatResult() functions from the SDK adapters to return a concise summary.
|
|
60
|
-
*
|
|
61
|
-
* @param input - Task parameters
|
|
62
|
-
* @param config - Optional configuration (apiKey, apiUrl to override default)
|
|
63
|
-
* @returns Task result with success status, findings, and comprehensive execution history
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* const result = await executeBrowserTask(
|
|
68
|
-
* {
|
|
69
|
-
* task: "Test checkout flow for buying a pineapple",
|
|
70
|
-
* url: "https://3000-abc.e2b.dev",
|
|
71
|
-
* max_steps: 20,
|
|
72
|
-
* repo_id: "my-project",
|
|
73
|
-
* commit_id: "uuid-here"
|
|
74
|
-
* },
|
|
75
|
-
* {
|
|
76
|
-
* apiKey: process.env.MORPH_API_KEY,
|
|
77
|
-
* // apiUrl: 'http://localhost:8001' // Override for local testing
|
|
78
|
-
* }
|
|
79
|
-
* );
|
|
80
|
-
*
|
|
81
|
-
* if (result.success) {
|
|
82
|
-
* console.log('Task completed:', result.result);
|
|
83
|
-
* console.log('URLs visited:', result.urls);
|
|
84
|
-
* console.log('Actions taken:', result.action_names);
|
|
85
|
-
* console.log('Has errors:', result.has_errors);
|
|
86
|
-
* console.log('Replay:', result.replay_url);
|
|
87
|
-
* }
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
declare function executeBrowserTask(input: BrowserTaskInput, config?: BrowserConfig): Promise<BrowserTaskResult>;
|
|
91
|
-
/**
|
|
92
|
-
* Get recording status and video URL
|
|
93
|
-
*
|
|
94
|
-
* @param recordingId - Recording UUID from BrowserTaskResult
|
|
95
|
-
* @param config - Configuration with apiKey
|
|
96
|
-
* @returns Recording status with video URL when ready
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```typescript
|
|
100
|
-
* const status = await getRecording('uuid-here', { apiKey: 'key' });
|
|
101
|
-
* if (status.status === 'COMPLETED' && status.video_url) {
|
|
102
|
-
* console.log('Video ready:', status.video_url);
|
|
103
|
-
* }
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
declare function getRecording(recordingId: string, config?: BrowserConfig): Promise<RecordingStatus>;
|
|
107
|
-
/**
|
|
108
|
-
* Wait for recording to complete with automatic polling
|
|
109
|
-
*
|
|
110
|
-
* @param recordingId - Recording UUID
|
|
111
|
-
* @param config - Configuration with apiKey
|
|
112
|
-
* @param options - Polling options
|
|
113
|
-
* @returns Recording status when completed or errored
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```typescript
|
|
117
|
-
* const result = await executeBrowserTask({ task: '...', record_video: true }, config);
|
|
118
|
-
* if (result.recording_id) {
|
|
119
|
-
* const recording = await waitForRecording(result.recording_id, config, {
|
|
120
|
-
* timeout: 60000, // 1 minute
|
|
121
|
-
* pollInterval: 2000 // Check every 2 seconds
|
|
122
|
-
* });
|
|
123
|
-
* console.log('Video URL:', recording.video_url);
|
|
124
|
-
* }
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
declare function waitForRecording(recordingId: string, config?: BrowserConfig, options?: {
|
|
128
|
-
timeout?: number;
|
|
129
|
-
pollInterval?: number;
|
|
130
|
-
}): Promise<RecordingStatus>;
|
|
131
|
-
/**
|
|
132
|
-
* Execute task with recording and wait for video to be ready
|
|
133
|
-
*
|
|
134
|
-
* @param input - Task parameters with record_video=true
|
|
135
|
-
* @param config - Configuration with apiKey
|
|
136
|
-
* @returns Task result with ready video URL
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```typescript
|
|
140
|
-
* const result = await executeWithRecording(
|
|
141
|
-
* {
|
|
142
|
-
* task: "Test checkout flow",
|
|
143
|
-
* url: "https://example.com",
|
|
144
|
-
* record_video: true,
|
|
145
|
-
* repo_id: "my-project"
|
|
146
|
-
* },
|
|
147
|
-
* { apiKey: process.env.MORPH_API_KEY }
|
|
148
|
-
* );
|
|
149
|
-
*
|
|
150
|
-
* console.log('Task result:', result.result);
|
|
151
|
-
* console.log('Video URL:', result.recording?.video_url);
|
|
152
|
-
* ```
|
|
153
|
-
*/
|
|
154
|
-
declare function executeWithRecording(input: BrowserTaskInput & {
|
|
155
|
-
record_video: true;
|
|
156
|
-
}, config?: BrowserConfig): Promise<BrowserTaskResult & {
|
|
157
|
-
recording?: RecordingStatus;
|
|
158
|
-
}>;
|
|
159
|
-
/**
|
|
160
|
-
* Get errors from recording with screenshots
|
|
161
|
-
*
|
|
162
|
-
* Screenshots are captured in real-time (500ms after error occurs) during the browser session.
|
|
163
|
-
*
|
|
164
|
-
* @param recordingId - Recording UUID from BrowserTaskResult
|
|
165
|
-
* @param config - Configuration with apiKey
|
|
166
|
-
* @returns Errors with real-time screenshots
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* ```typescript
|
|
170
|
-
* const { errors, total_errors } = await getErrors('uuid-here', { apiKey: 'key' });
|
|
171
|
-
*
|
|
172
|
-
* console.log(`Found ${total_errors} errors`);
|
|
173
|
-
*
|
|
174
|
-
* errors.forEach(err => {
|
|
175
|
-
* console.log(`[${err.type}] ${err.message}`);
|
|
176
|
-
* if (err.url) console.log(` URL: ${err.url}`);
|
|
177
|
-
* if (err.screenshot_url) console.log(` Screenshot: ${err.screenshot_url}`);
|
|
178
|
-
*
|
|
179
|
-
* // Download screenshot
|
|
180
|
-
* if (err.screenshot_url) {
|
|
181
|
-
* const response = await fetch(err.screenshot_url);
|
|
182
|
-
* const screenshot = await response.arrayBuffer();
|
|
183
|
-
* // Save or process screenshot
|
|
184
|
-
* }
|
|
185
|
-
* });
|
|
186
|
-
* ```
|
|
187
|
-
*/
|
|
188
|
-
declare function getErrors(recordingId: string, config?: BrowserConfig): Promise<ErrorsResponse>;
|
|
189
|
-
/**
|
|
190
|
-
* Check if browser worker service is healthy
|
|
191
|
-
*
|
|
192
|
-
* @param config - Optional configuration
|
|
193
|
-
* @returns Health status
|
|
194
|
-
*/
|
|
195
|
-
declare function checkHealth(config?: BrowserConfig): Promise<{
|
|
196
|
-
ok: boolean;
|
|
197
|
-
google_configured: boolean;
|
|
198
|
-
database_configured: boolean;
|
|
199
|
-
s3_configured: boolean;
|
|
200
|
-
error?: string;
|
|
201
|
-
}>;
|
|
202
|
-
|
|
203
|
-
export { BrowserClient, checkHealth, executeBrowserTask, executeWithRecording, getErrors, getRecording, waitForRecording };
|
|
@@ -1,72 +0,0 @@
|
|
|
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 };
|
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
* Returns a concise summary suitable for agent context. The full result object
|
|
25
|
-
* (with urls, errors, action_history, judgement, etc.) is available when calling
|
|
26
|
-
* execute() directly, but this formatted string omits those details to save tokens.
|
|
27
|
-
*
|
|
28
|
-
* @param result - Browser task result with full history data
|
|
29
|
-
* @returns Formatted string summary for tool result
|
|
30
|
-
*/
|
|
31
|
-
declare function formatResult(result: BrowserTaskResult): string;
|
|
32
|
-
/**
|
|
33
|
-
* Get system prompt for browser automation
|
|
34
|
-
*/
|
|
35
|
-
declare function getSystemPrompt(): string;
|
|
36
|
-
/**
|
|
37
|
-
* Create a configured browser tool with execute and formatResult methods
|
|
38
|
-
*
|
|
39
|
-
* @param config - Browser worker configuration
|
|
40
|
-
* @returns Tool definition with execute and formatResult methods
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```typescript
|
|
44
|
-
* import OpenAI from 'openai';
|
|
45
|
-
* import { createBrowserTool } from 'morphsdk/tools/browser/openai';
|
|
46
|
-
*
|
|
47
|
-
* const tool = createBrowserTool({
|
|
48
|
-
* apiUrl: 'https://browser-worker.example.com'
|
|
49
|
-
* });
|
|
50
|
-
*
|
|
51
|
-
* const client = new OpenAI();
|
|
52
|
-
*
|
|
53
|
-
* const response = await client.chat.completions.create({
|
|
54
|
-
* model: 'gpt-4o',
|
|
55
|
-
* tools: [tool], // tool itself is the ChatCompletionTool
|
|
56
|
-
* messages: [{
|
|
57
|
-
* role: 'user',
|
|
58
|
-
* content: 'Test the checkout at https://3000-abc.e2b.dev'
|
|
59
|
-
* }]
|
|
60
|
-
* });
|
|
61
|
-
*
|
|
62
|
-
* // Execute and format
|
|
63
|
-
* const result = await tool.execute(toolCallArgs);
|
|
64
|
-
* const formatted = tool.formatResult(result);
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
declare function createBrowserTool(config?: BrowserConfig): ChatCompletionTool & {
|
|
68
|
-
execute: (input: BrowserTaskInput | string) => Promise<BrowserTaskResult>;
|
|
69
|
-
formatResult: (result: BrowserTaskResult) => string;
|
|
70
|
-
getSystemPrompt: () => string;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export { browserTool, createBrowserTool, execute, formatResult, getSystemPrompt };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool descriptions and prompts for AI models
|
|
3
|
-
*/
|
|
4
|
-
declare const BROWSER_TOOL_DESCRIPTION = "Test and verify your implemented code in a live browser. This tool executes natural language test instructions and returns a video recording plus detailed logs to help you debug issues.\n\n## When to Use\nUse this AFTER coding is complete to verify your implementation:\n- You've finished writing/modifying code and need to verify it works\n- You need to test user interactions end-to-end (clicks, forms, navigation)\n- You want to catch runtime errors, console warnings, or network failures\n- You need visual confirmation that UI elements render and behave correctly\n\n## What You Get Back\nThe tool returns debugging artifacts to help you identify and fix issues:\n- **Video recording**: Watch exactly what happened in the browser session\n- **Console logs**: All console.log, warnings, and errors with timestamps\n- **Network logs**: Failed requests, 404s, API errors with screenshots\n- **Error screenshots**: Visual snapshots captured when errors occur\n\n## How to Write Good Tests\nBe specific about the user journey you're testing:\n\u274C Bad: \"Test the login feature\"\n\u2705 Good: \"Navigate to /login, enter 'test@example.com' and 'password123', click the Login button, verify we reach the /dashboard page\"\n\nInclude verification steps:\n\u2705 \"Click the Add Item button, verify the item appears in the list\"\n\u2705 \"Submit the form, verify a success message is displayed\"\n\n## Iterating on Failures\n1. Run the test and review the video + logs\n2. Identify the specific issue (console error, failed request, wrong behavior)\n3. Fix the code based on the evidence\n4. Re-run the test to verify the fix\n5. Repeat until test passes\n\n## Requirements\n- **URL**: Must be publicly accessible (use tunnels like ngrok, Cloudflare, or deploy to staging)\n- **Timing**: Use this after implementation, not during coding\n- **Complexity**: Set max_steps higher (20-30) for multi-step user workflows";
|
|
5
|
-
declare const BROWSER_SYSTEM_PROMPT = "You are an AI agent designed to automate browser tasks to accomplish the <user_request>. Respond with a valid JSON object in the format: {\"thinking\": \"Reason step-by-step about your current state, history, and the user request to decide your next goal and action. Analyze the browser state and screenshot to confirm the outcome of your last action.\", \"evaluation_previous_goal\": \"A concise, one-sentence evaluation of your last action's outcome (e.g., Success, Failure, or Uncertain).\", \"memory\": \"1-3 sentences summarizing key information and progress so far. This helps you track progress across multiple steps (e.g., items collected, pages visited).\", \"next_goal\": \"A clear, one-sentence description of your immediate next objective.\", \"action\": [{\"action_name\": {\"parameter\": \"value\"}}]}";
|
|
6
|
-
|
|
7
|
-
export { BROWSER_SYSTEM_PROMPT, BROWSER_TOOL_DESCRIPTION };
|