@morphllm/morphsdk 0.2.21 → 0.2.22
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-DF2ZOO7R.js → chunk-5VQEQSJQ.js} +3 -52
- package/dist/chunk-5VQEQSJQ.js.map +1 -0
- package/dist/chunk-73RQWOQC.js +16 -0
- package/dist/chunk-73RQWOQC.js.map +1 -0
- package/dist/{chunk-2DXRTGRH.js → chunk-74ZHKB54.js} +1 -1
- package/dist/{chunk-2DXRTGRH.js.map → chunk-74ZHKB54.js.map} +1 -1
- package/dist/chunk-AFEPUNAO.js +15 -0
- package/dist/chunk-AFEPUNAO.js.map +1 -0
- package/dist/chunk-EAA7D24N.js +201 -0
- package/dist/chunk-EAA7D24N.js.map +1 -0
- package/dist/chunk-EK7OQPWD.js +44 -0
- package/dist/chunk-EK7OQPWD.js.map +1 -0
- package/dist/chunk-FSVBNZMU.js +44 -0
- package/dist/chunk-FSVBNZMU.js.map +1 -0
- package/dist/chunk-G2RSY56Q.js +11 -0
- package/dist/chunk-G2RSY56Q.js.map +1 -0
- package/dist/chunk-GTOXMAF2.js +140 -0
- package/dist/chunk-GTOXMAF2.js.map +1 -0
- package/dist/chunk-HKZB23U7.js +85 -0
- package/dist/chunk-HKZB23U7.js.map +1 -0
- package/dist/chunk-JZGU5UC6.js +53 -0
- package/dist/chunk-JZGU5UC6.js.map +1 -0
- package/dist/chunk-NDZO5IPV.js +121 -0
- package/dist/chunk-NDZO5IPV.js.map +1 -0
- package/dist/{chunk-34F3D6JD.js → chunk-NSQGPBMU.js} +9 -9
- package/dist/chunk-RSLIOCOE.js +26 -0
- package/dist/chunk-RSLIOCOE.js.map +1 -0
- package/dist/chunk-SMGZ6A64.js +53 -0
- package/dist/chunk-SMGZ6A64.js.map +1 -0
- package/dist/chunk-TICMYDII.js +81 -0
- package/dist/chunk-TICMYDII.js.map +1 -0
- package/dist/chunk-UYBIKZPM.js +135 -0
- package/dist/chunk-UYBIKZPM.js.map +1 -0
- package/dist/chunk-VBBJGWHY.js +73 -0
- package/dist/chunk-VBBJGWHY.js.map +1 -0
- package/dist/chunk-XQLKK2ZH.js +56 -0
- package/dist/chunk-XQLKK2ZH.js.map +1 -0
- package/dist/chunk-XYPMN4A3.js +1 -0
- package/dist/chunk-XYPMN4A3.js.map +1 -0
- package/dist/chunk-Z2FBMSNE.js +10 -0
- package/dist/chunk-Z2FBMSNE.js.map +1 -0
- package/dist/client.cjs +2 -51
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +4 -4
- package/dist/git/client.cjs +2 -51
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.js +1 -1
- package/dist/git/index.cjs +2 -51
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.js +2 -2
- package/dist/git/types.cjs.map +1 -1
- package/dist/index.cjs +2 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -10
- package/dist/tools/warp_grep/agent/config.cjs +41 -0
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/config.js +12 -0
- package/dist/tools/warp_grep/agent/config.js.map +1 -0
- package/dist/tools/warp_grep/agent/formatter.cjs +106 -0
- package/dist/tools/warp_grep/agent/formatter.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/formatter.js +10 -0
- package/dist/tools/warp_grep/agent/formatter.js.map +1 -0
- package/dist/tools/warp_grep/agent/grep_helpers.cjs +148 -0
- package/dist/tools/warp_grep/agent/grep_helpers.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/grep_helpers.js +14 -0
- package/dist/tools/warp_grep/agent/grep_helpers.js.map +1 -0
- package/dist/tools/warp_grep/agent/parser.cjs +165 -0
- package/dist/tools/warp_grep/agent/parser.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/parser.js +10 -0
- package/dist/tools/warp_grep/agent/parser.js.map +1 -0
- package/dist/tools/warp_grep/agent/prompt.cjs +110 -0
- package/dist/tools/warp_grep/agent/prompt.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/prompt.js +10 -0
- package/dist/tools/warp_grep/agent/prompt.js.map +1 -0
- package/dist/tools/warp_grep/agent/runner.cjs +744 -0
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/runner.js +17 -0
- package/dist/tools/warp_grep/agent/runner.js.map +1 -0
- package/dist/tools/warp_grep/agent/types.cjs +19 -0
- package/dist/tools/warp_grep/agent/types.cjs.map +1 -0
- package/dist/tools/warp_grep/agent/types.js +2 -0
- package/dist/tools/warp_grep/agent/types.js.map +1 -0
- package/dist/tools/warp_grep/anthropic.cjs +977 -0
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -0
- package/dist/tools/warp_grep/anthropic.js +22 -0
- package/dist/tools/warp_grep/anthropic.js.map +1 -0
- package/dist/tools/warp_grep/index.cjs +1136 -0
- package/dist/tools/warp_grep/index.cjs.map +1 -0
- package/dist/tools/warp_grep/index.js +48 -0
- package/dist/tools/warp_grep/index.js.map +1 -0
- package/dist/tools/warp_grep/openai.cjs +980 -0
- package/dist/tools/warp_grep/openai.cjs.map +1 -0
- package/dist/tools/warp_grep/openai.js +22 -0
- package/dist/tools/warp_grep/openai.js.map +1 -0
- package/dist/tools/warp_grep/providers/command.cjs +98 -0
- package/dist/tools/warp_grep/providers/command.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/command.js +9 -0
- package/dist/tools/warp_grep/providers/command.js.map +1 -0
- package/dist/tools/warp_grep/providers/local.cjs +232 -0
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/local.js +12 -0
- package/dist/tools/warp_grep/providers/local.js.map +1 -0
- package/dist/tools/warp_grep/providers/types.cjs +19 -0
- package/dist/tools/warp_grep/providers/types.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/types.js +1 -0
- package/dist/tools/warp_grep/providers/types.js.map +1 -0
- package/dist/tools/warp_grep/tools/analyse.cjs +40 -0
- package/dist/tools/warp_grep/tools/analyse.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/analyse.js +8 -0
- package/dist/tools/warp_grep/tools/analyse.js.map +1 -0
- package/dist/tools/warp_grep/tools/finish.cjs +69 -0
- package/dist/tools/warp_grep/tools/finish.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/finish.js +10 -0
- package/dist/tools/warp_grep/tools/finish.js.map +1 -0
- package/dist/tools/warp_grep/tools/grep.cjs +35 -0
- package/dist/tools/warp_grep/tools/grep.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/grep.js +12 -0
- package/dist/tools/warp_grep/tools/grep.js.map +1 -0
- package/dist/tools/warp_grep/tools/read.cjs +34 -0
- package/dist/tools/warp_grep/tools/read.cjs.map +1 -0
- package/dist/tools/warp_grep/tools/read.js +8 -0
- package/dist/tools/warp_grep/tools/read.js.map +1 -0
- package/dist/tools/warp_grep/utils/files.cjs +45 -0
- package/dist/tools/warp_grep/utils/files.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/files.js +8 -0
- package/dist/tools/warp_grep/utils/files.js.map +1 -0
- package/dist/tools/warp_grep/utils/format.cjs +42 -0
- package/dist/tools/warp_grep/utils/format.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/format.js +18 -0
- package/dist/tools/warp_grep/utils/format.js.map +1 -0
- package/dist/tools/warp_grep/utils/paths.cjs +91 -0
- package/dist/tools/warp_grep/utils/paths.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/paths.js +16 -0
- package/dist/tools/warp_grep/utils/paths.js.map +1 -0
- package/dist/tools/warp_grep/utils/ripgrep.cjs +50 -0
- package/dist/tools/warp_grep/utils/ripgrep.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/ripgrep.js +8 -0
- package/dist/tools/warp_grep/utils/ripgrep.js.map +1 -0
- package/dist/tools/warp_grep/vercel.cjs +968 -0
- package/dist/tools/warp_grep/vercel.cjs.map +1 -0
- package/dist/tools/warp_grep/vercel.js +22 -0
- package/dist/tools/warp_grep/vercel.js.map +1 -0
- package/package.json +23 -3
- package/dist/anthropic-CknfcMoO.d.ts +0 -64
- package/dist/chunk-DF2ZOO7R.js.map +0 -1
- package/dist/client.d.ts +0 -114
- package/dist/git/client.d.ts +0 -255
- 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 -196
- package/dist/tools/browser/index.d.ts +0 -72
- package/dist/tools/browser/openai.d.ts +0 -69
- package/dist/tools/browser/prompts.d.ts +0 -7
- package/dist/tools/browser/types.d.ts +0 -227
- 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 -46
- 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/vercel-B1GZ_g9N.d.ts +0 -69
- /package/dist/{chunk-34F3D6JD.js.map → chunk-NSQGPBMU.js.map} +0 -0
|
@@ -1,196 +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
|
-
* @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 };
|
|
@@ -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,69 +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
|
-
* @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 };
|
|
@@ -1,7 +0,0 @@
|
|
|
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 };
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { RetryConfig } from '../utils/resilience.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Type definitions for browser automation tool
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Available browser automation models
|
|
9
|
-
*/
|
|
10
|
-
type BrowserModel = 'gemini-flash-latest' | 'morph-computer-use-v0';
|
|
11
|
-
/**
|
|
12
|
-
* Configuration for the browser worker service
|
|
13
|
-
*/
|
|
14
|
-
interface BrowserConfig {
|
|
15
|
-
/** Browser worker API URL (default: https://browser.morphllm.com) */
|
|
16
|
-
apiUrl?: string;
|
|
17
|
-
/** Morph API key for authentication (required in production) */
|
|
18
|
-
apiKey?: string;
|
|
19
|
-
/** Request timeout in milliseconds (default: 120000) */
|
|
20
|
-
timeout?: number;
|
|
21
|
-
/** Retry configuration for API calls */
|
|
22
|
-
retryConfig?: RetryConfig;
|
|
23
|
-
/** Enable debug logging (default: false) */
|
|
24
|
-
debug?: boolean;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Input parameters for browser automation task
|
|
28
|
-
*/
|
|
29
|
-
interface BrowserTaskInput {
|
|
30
|
-
/** Natural language description of what to do */
|
|
31
|
-
task: string;
|
|
32
|
-
/** Starting URL (e.g., https://3000-xyz.e2b.dev) */
|
|
33
|
-
url?: string;
|
|
34
|
-
/** Maximum number of browser actions to take (1-50, default: 10) */
|
|
35
|
-
max_steps?: number;
|
|
36
|
-
/** Model to use for task execution (default: morph-computer-use-v0) */
|
|
37
|
-
model?: BrowserModel;
|
|
38
|
-
/** Browserless region: 'sfo' (US West) or 'lon' (Europe) */
|
|
39
|
-
region?: 'sfo' | 'lon';
|
|
40
|
-
/** Enable stealth mode to avoid bot detection (default: true) */
|
|
41
|
-
stealth?: boolean;
|
|
42
|
-
/** Browser viewport width (default: 1280) */
|
|
43
|
-
viewport_width?: number;
|
|
44
|
-
/** Browser viewport height (default: 720) */
|
|
45
|
-
viewport_height?: number;
|
|
46
|
-
/** User-defined reference/tracking ID (e.g., "PR-1234", "jira-PROJ-567") */
|
|
47
|
-
external_id?: string;
|
|
48
|
-
/** Optional repository ID to associate with this session */
|
|
49
|
-
repo_id?: string;
|
|
50
|
-
/** Optional commit UUID to associate with this session */
|
|
51
|
-
commit_id?: string;
|
|
52
|
-
/** Record session video to S3 (default: false) */
|
|
53
|
-
record_video?: boolean;
|
|
54
|
-
/** Video width (default: 1280) */
|
|
55
|
-
video_width?: number;
|
|
56
|
-
/** Video height (default: 720) */
|
|
57
|
-
video_height?: number;
|
|
58
|
-
/** Serialized structured output schema (internal use) */
|
|
59
|
-
structured_output?: string;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Input with Zod schema for structured output
|
|
63
|
-
*/
|
|
64
|
-
interface BrowserTaskInputWithSchema<T> extends Omit<BrowserTaskInput, 'structured_output'> {
|
|
65
|
-
/** Zod schema for structured output */
|
|
66
|
-
schema: any;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Result from executing a browser task
|
|
70
|
-
*/
|
|
71
|
-
interface BrowserTaskResult {
|
|
72
|
-
/** Whether the task completed successfully */
|
|
73
|
-
success: boolean;
|
|
74
|
-
/** Task result or findings */
|
|
75
|
-
result?: string;
|
|
76
|
-
/** Error message if task failed */
|
|
77
|
-
error?: string;
|
|
78
|
-
/** Number of browser actions taken */
|
|
79
|
-
steps_taken?: number;
|
|
80
|
-
/** Total execution time in milliseconds */
|
|
81
|
-
execution_time_ms?: number;
|
|
82
|
-
/** UUID of saved replay record (if session replay enabled) */
|
|
83
|
-
replay_id?: string;
|
|
84
|
-
/** Browserless replay URL (if session replay enabled) */
|
|
85
|
-
replay_url?: string;
|
|
86
|
-
/** Recording ID (if record_video=true) */
|
|
87
|
-
recording_id?: string;
|
|
88
|
-
/** Recording status: PENDING, PROCESSING, COMPLETED, ERROR */
|
|
89
|
-
recording_status?: string;
|
|
90
|
-
/** Task ID for async task tracking */
|
|
91
|
-
task_id?: string;
|
|
92
|
-
/** Task status: pending, running, completed, failed */
|
|
93
|
-
status?: string;
|
|
94
|
-
/** Structured output (JSON string) */
|
|
95
|
-
output?: string;
|
|
96
|
-
/** Live session debug URL for real-time viewing (WebRTC streaming) */
|
|
97
|
-
debugUrl?: string;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Configuration for live session viewing
|
|
101
|
-
*/
|
|
102
|
-
interface LiveSessionOptions {
|
|
103
|
-
/** Enable or disable remote control (default: true for headful, varies for headless) */
|
|
104
|
-
interactive?: boolean;
|
|
105
|
-
/** UI theme: 'dark' or 'light' (headless only, default: 'dark') */
|
|
106
|
-
theme?: 'dark' | 'light';
|
|
107
|
-
/** Show or hide navigation controls (headless only, default: true) */
|
|
108
|
-
showControls?: boolean;
|
|
109
|
-
/** Focus view on specific page/tab ID (headless only) */
|
|
110
|
-
pageId?: string;
|
|
111
|
-
/** Display specific tab by index (headless only) */
|
|
112
|
-
pageIndex?: string;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Configuration for iframe generation
|
|
116
|
-
*/
|
|
117
|
-
interface IframeOptions extends LiveSessionOptions {
|
|
118
|
-
/** Iframe width (default: '100%') */
|
|
119
|
-
width?: string | number;
|
|
120
|
-
/** Iframe height (default: '600px') */
|
|
121
|
-
height?: string | number;
|
|
122
|
-
/** Additional inline styles */
|
|
123
|
-
style?: string;
|
|
124
|
-
/** CSS class name */
|
|
125
|
-
className?: string;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Task result with convenience methods for async execution
|
|
129
|
-
*/
|
|
130
|
-
interface BrowserTaskWithPromise extends BrowserTaskResult {
|
|
131
|
-
task_id: string;
|
|
132
|
-
/** Live URL to watch task execution in real-time */
|
|
133
|
-
liveUrl: string;
|
|
134
|
-
/** Wait for task completion */
|
|
135
|
-
complete: (pollConfig?: {
|
|
136
|
-
interval?: number;
|
|
137
|
-
timeout?: number;
|
|
138
|
-
}) => Promise<BrowserTaskResult>;
|
|
139
|
-
/** Get live session URL with optional parameters (Steel.dev) - throws if debugUrl not available */
|
|
140
|
-
getLiveUrl: (options?: LiveSessionOptions) => string;
|
|
141
|
-
/** Get iframe HTML for embedding live session - throws if debugUrl not available */
|
|
142
|
-
getLiveIframe: (optionsOrPreset?: string | IframeOptions) => string;
|
|
143
|
-
/** Get complete embed code snippet - throws if debugUrl not available */
|
|
144
|
-
getEmbedCode: () => string;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Task result with schema validation
|
|
148
|
-
*/
|
|
149
|
-
interface BrowserTaskWithPromiseAndSchema<T> extends BrowserTaskResult {
|
|
150
|
-
task_id: string;
|
|
151
|
-
/** Live URL to watch task execution in real-time */
|
|
152
|
-
liveUrl: string;
|
|
153
|
-
/** Parsed and validated output */
|
|
154
|
-
parsed: T | null;
|
|
155
|
-
/** Wait for task completion with schema validation */
|
|
156
|
-
complete: (pollConfig?: {
|
|
157
|
-
interval?: number;
|
|
158
|
-
timeout?: number;
|
|
159
|
-
}) => Promise<BrowserTaskResult & {
|
|
160
|
-
parsed: T | null;
|
|
161
|
-
}>;
|
|
162
|
-
/** Get live session URL with optional parameters - throws if debugUrl not available */
|
|
163
|
-
getLiveUrl: (options?: LiveSessionOptions) => string;
|
|
164
|
-
/** Get iframe HTML for embedding live session - throws if debugUrl not available */
|
|
165
|
-
getLiveIframe: (optionsOrPreset?: string | IframeOptions) => string;
|
|
166
|
-
/** Get complete embed code snippet - throws if debugUrl not available */
|
|
167
|
-
getEmbedCode: () => string;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Recording status and metadata
|
|
171
|
-
*/
|
|
172
|
-
interface RecordingStatus {
|
|
173
|
-
/** Recording ID */
|
|
174
|
-
id: string;
|
|
175
|
-
/** Current status */
|
|
176
|
-
status: 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'ERROR';
|
|
177
|
-
/** Presigned S3 URL for rrweb replay JSON (interactive DOM replay) */
|
|
178
|
-
replay_url?: string;
|
|
179
|
-
/** Presigned S3 URL for network logs (NDJSON format) */
|
|
180
|
-
network_url?: string;
|
|
181
|
-
/** Presigned S3 URL for console logs (NDJSON format) */
|
|
182
|
-
console_url?: string;
|
|
183
|
-
/** Presigned S3 URL for native browser video (WebM or MP4 format, real-time recording) */
|
|
184
|
-
video_url?: string;
|
|
185
|
-
/** Total rrweb events captured */
|
|
186
|
-
total_events?: number;
|
|
187
|
-
/** Total bytes of all files */
|
|
188
|
-
file_size?: number;
|
|
189
|
-
/** Duration in milliseconds */
|
|
190
|
-
duration?: number;
|
|
191
|
-
/** Error message if status=ERROR */
|
|
192
|
-
error?: string;
|
|
193
|
-
/** When recording was created */
|
|
194
|
-
created_at: string;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Browser error with screenshot captured at error time
|
|
198
|
-
*/
|
|
199
|
-
interface BrowserError {
|
|
200
|
-
/** Error type: console error or network error */
|
|
201
|
-
type: 'console' | 'network';
|
|
202
|
-
/** Error message */
|
|
203
|
-
message: string;
|
|
204
|
-
/** URL where error occurred */
|
|
205
|
-
url?: string;
|
|
206
|
-
/** CDP timestamp in seconds since browser start */
|
|
207
|
-
timestamp: number;
|
|
208
|
-
/** Presigned S3 URL to screenshot JPEG (captured 500ms after error) */
|
|
209
|
-
screenshot_url?: string;
|
|
210
|
-
/** When screenshot was captured (Unix timestamp) */
|
|
211
|
-
captured_at?: number;
|
|
212
|
-
/** HTTP status code (for network errors) */
|
|
213
|
-
status?: number;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Response from getErrors()
|
|
217
|
-
*/
|
|
218
|
-
interface ErrorsResponse {
|
|
219
|
-
/** Recording ID */
|
|
220
|
-
recording_id: string;
|
|
221
|
-
/** Total number of errors */
|
|
222
|
-
total_errors: number;
|
|
223
|
-
/** Errors with real-time screenshots */
|
|
224
|
-
errors: BrowserError[];
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export type { BrowserConfig, BrowserError, BrowserModel, BrowserTaskInput, BrowserTaskInputWithSchema, BrowserTaskResult, BrowserTaskWithPromise, BrowserTaskWithPromiseAndSchema, ErrorsResponse, IframeOptions, LiveSessionOptions, RecordingStatus };
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as ai from 'ai';
|
|
2
|
-
import { BrowserConfig } from './types.js';
|
|
3
|
-
import '../utils/resilience.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Create Vercel AI SDK tool for browser automation
|
|
7
|
-
*
|
|
8
|
-
* @param config - Optional browser worker configuration
|
|
9
|
-
* @returns Vercel AI SDK tool
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { generateText } from 'ai';
|
|
14
|
-
* import { anthropic } from '@ai-sdk/anthropic';
|
|
15
|
-
* import { createBrowserTool } from 'morphsdk/tools/browser/vercel';
|
|
16
|
-
*
|
|
17
|
-
* const browserTool = createBrowserTool({
|
|
18
|
-
* apiUrl: 'https://browser-worker.example.com'
|
|
19
|
-
* });
|
|
20
|
-
*
|
|
21
|
-
* const result = await generateText({
|
|
22
|
-
* model: anthropic('claude-sonnet-4-5-20250929'),
|
|
23
|
-
* tools: { browserTask: browserTool },
|
|
24
|
-
* prompt: 'Test the checkout flow at https://3000-abc.e2b.dev',
|
|
25
|
-
* maxSteps: 5
|
|
26
|
-
* });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
declare function createBrowserTool(config?: BrowserConfig): ai.Tool<{
|
|
30
|
-
task: string;
|
|
31
|
-
max_steps: number;
|
|
32
|
-
region: "sfo" | "lon";
|
|
33
|
-
url?: string | undefined;
|
|
34
|
-
}, {
|
|
35
|
-
success: boolean;
|
|
36
|
-
result: string | undefined;
|
|
37
|
-
steps_taken: number | undefined;
|
|
38
|
-
execution_time_ms: number | undefined;
|
|
39
|
-
error?: undefined;
|
|
40
|
-
} | {
|
|
41
|
-
success: boolean;
|
|
42
|
-
error: string | undefined;
|
|
43
|
-
result?: undefined;
|
|
44
|
-
steps_taken?: undefined;
|
|
45
|
-
execution_time_ms?: undefined;
|
|
46
|
-
}>;
|
|
47
|
-
/**
|
|
48
|
-
* Default browser tool for Vercel AI SDK
|
|
49
|
-
*/
|
|
50
|
-
declare const browserTool: ai.Tool<{
|
|
51
|
-
task: string;
|
|
52
|
-
max_steps: number;
|
|
53
|
-
region: "sfo" | "lon";
|
|
54
|
-
url?: string | undefined;
|
|
55
|
-
}, {
|
|
56
|
-
success: boolean;
|
|
57
|
-
result: string | undefined;
|
|
58
|
-
steps_taken: number | undefined;
|
|
59
|
-
execution_time_ms: number | undefined;
|
|
60
|
-
error?: undefined;
|
|
61
|
-
} | {
|
|
62
|
-
success: boolean;
|
|
63
|
-
error: string | undefined;
|
|
64
|
-
result?: undefined;
|
|
65
|
-
steps_taken?: undefined;
|
|
66
|
-
execution_time_ms?: undefined;
|
|
67
|
-
}>;
|
|
68
|
-
|
|
69
|
-
export { browserTool, createBrowserTool };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Tool } from '@anthropic-ai/sdk/resources/messages';
|
|
2
|
-
import { CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult } from './types.js';
|
|
3
|
-
import '../utils/resilience.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Anthropic SDK adapter for codebase_search tool
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Create Anthropic-native codebase_search tool with execute and formatResult methods
|
|
11
|
-
*
|
|
12
|
-
* @param config - Configuration with repoId
|
|
13
|
-
* @returns Anthropic Tool definition with execute and formatResult methods
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* import Anthropic from '@anthropic-ai/sdk';
|
|
18
|
-
* import { createCodebaseSearchTool } from 'morphsdk/tools/anthropic';
|
|
19
|
-
*
|
|
20
|
-
* const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
|
|
21
|
-
* const tool = createCodebaseSearchTool({ repoId: 'my-project' });
|
|
22
|
-
*
|
|
23
|
-
* const response = await client.messages.create({
|
|
24
|
-
* model: "claude-sonnet-4-5-20250929",
|
|
25
|
-
* tools: [tool], // tool itself is the Tool definition
|
|
26
|
-
* messages: [{ role: "user", content: "Find authentication code" }]
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* // Execute tool and format result
|
|
30
|
-
* const result = await tool.execute(toolUseBlock.input);
|
|
31
|
-
* const formatted = tool.formatResult(result);
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
declare function createCodebaseSearchTool(config: CodebaseSearchConfig): Tool & {
|
|
35
|
-
execute: (input: CodebaseSearchInput) => Promise<CodebaseSearchResult>;
|
|
36
|
-
formatResult: (result: CodebaseSearchResult) => string;
|
|
37
|
-
getSystemPrompt: () => string;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export { createCodebaseSearchTool };
|