@morphllm/morphsdk 0.2.103 → 0.2.105
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/README.md +146 -1
- package/dist/chunk-DX5HVNUP.js +574 -0
- package/dist/chunk-DX5HVNUP.js.map +1 -0
- package/dist/client-DYnecl6H.d.ts +733 -0
- package/dist/client.cjs +286 -0
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +5 -5
- package/dist/client.js +1 -1
- package/dist/index.cjs +296 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -1
- package/package.json +1 -1
- package/dist/chunk-Y2OTK5WC.js +0 -283
- package/dist/chunk-Y2OTK5WC.js.map +0 -1
- package/dist/client-BVeUudyD.d.ts +0 -312
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AnthropicToolFactory, M as MorphClient, a as MorphClientConfig, O as OpenAIToolFactory, V as VercelToolFactory } from './client-
|
|
1
|
+
export { A as AnthropicToolFactory, d as CheckRun, C as Comment, k as CreateCheckRunInput, i as CreateCommentInput, j as DeleteCommentInput, D as Deployment, F as FileChange, f as GetPullRequestInput, G as GitHubClient, b as GitHubClientConfig, m as GitHubError, I as Installation, h as ListCommentsInput, g as ListDeploymentsInput, e as ListPullRequestsInput, L as ListReposInput, M as MorphClient, a as MorphClientConfig, N as NoInstallationError, n as NotFoundError, O as OpenAIToolFactory, o as PermissionError, P as PullRequest, c as PullRequestWithContext, R as Repo, l as UpdateCheckRunInput, U as UpdateCommentInput, V as VercelToolFactory } from './client-DYnecl6H.js';
|
|
2
2
|
export { FastApplyClient } from './tools/fastapply/core.js';
|
|
3
3
|
export { CodebaseSearchClient } from './tools/codebase_search/core.js';
|
|
4
4
|
export { WarpGrepClient } from './tools/warp_grep/client.js';
|
package/dist/index.js
CHANGED
|
@@ -7,10 +7,15 @@ import "./chunk-TPP2UGQP.js";
|
|
|
7
7
|
import "./chunk-G2RSY56Q.js";
|
|
8
8
|
import {
|
|
9
9
|
AnthropicToolFactory,
|
|
10
|
+
GitHubClient,
|
|
11
|
+
GitHubError,
|
|
10
12
|
MorphClient,
|
|
13
|
+
NoInstallationError,
|
|
14
|
+
NotFoundError,
|
|
11
15
|
OpenAIToolFactory,
|
|
16
|
+
PermissionError,
|
|
12
17
|
VercelToolFactory
|
|
13
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-DX5HVNUP.js";
|
|
14
19
|
import "./chunk-QUIGATZE.js";
|
|
15
20
|
import "./chunk-MY4OU4ON.js";
|
|
16
21
|
import "./chunk-AFLEE2PO.js";
|
|
@@ -68,11 +73,16 @@ export {
|
|
|
68
73
|
CodebaseSearchClient,
|
|
69
74
|
FastApplyClient,
|
|
70
75
|
GeminiRouter,
|
|
76
|
+
GitHubClient,
|
|
77
|
+
GitHubError,
|
|
71
78
|
LocalRipgrepProvider,
|
|
72
79
|
MorphClient,
|
|
73
80
|
MorphGit,
|
|
81
|
+
NoInstallationError,
|
|
82
|
+
NotFoundError,
|
|
74
83
|
OpenAIRouter,
|
|
75
84
|
OpenAIToolFactory,
|
|
85
|
+
PermissionError,
|
|
76
86
|
RawRouter,
|
|
77
87
|
VercelToolFactory,
|
|
78
88
|
WarpGrepClient,
|
package/package.json
CHANGED
package/dist/chunk-Y2OTK5WC.js
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createWarpGrepTool
|
|
3
|
-
} from "./chunk-QUIGATZE.js";
|
|
4
|
-
import {
|
|
5
|
-
createWarpGrepTool as createWarpGrepTool3
|
|
6
|
-
} from "./chunk-MY4OU4ON.js";
|
|
7
|
-
import {
|
|
8
|
-
createWarpGrepTool as createWarpGrepTool2
|
|
9
|
-
} from "./chunk-AFLEE2PO.js";
|
|
10
|
-
import {
|
|
11
|
-
WarpGrepClient
|
|
12
|
-
} from "./chunk-4CZPXV6R.js";
|
|
13
|
-
import {
|
|
14
|
-
createCodebaseSearchTool as createCodebaseSearchTool3
|
|
15
|
-
} from "./chunk-O5DA5V5S.js";
|
|
16
|
-
import {
|
|
17
|
-
createCodebaseSearchTool as createCodebaseSearchTool2
|
|
18
|
-
} from "./chunk-OUEJ6XEO.js";
|
|
19
|
-
import {
|
|
20
|
-
createCodebaseSearchTool
|
|
21
|
-
} from "./chunk-ZRLEAPZV.js";
|
|
22
|
-
import {
|
|
23
|
-
CodebaseSearchClient
|
|
24
|
-
} from "./chunk-WM77HRKO.js";
|
|
25
|
-
import {
|
|
26
|
-
createEditFileTool as createEditFileTool3
|
|
27
|
-
} from "./chunk-HDRLLCAD.js";
|
|
28
|
-
import {
|
|
29
|
-
createEditFileTool as createEditFileTool2
|
|
30
|
-
} from "./chunk-KQP6ZPYB.js";
|
|
31
|
-
import {
|
|
32
|
-
createEditFileTool
|
|
33
|
-
} from "./chunk-I3IN742Q.js";
|
|
34
|
-
import {
|
|
35
|
-
FastApplyClient
|
|
36
|
-
} from "./chunk-TLC3QKE6.js";
|
|
37
|
-
import {
|
|
38
|
-
BrowserClient
|
|
39
|
-
} from "./chunk-4IOC2D5Y.js";
|
|
40
|
-
import {
|
|
41
|
-
MorphGit
|
|
42
|
-
} from "./chunk-LE66XCOI.js";
|
|
43
|
-
import {
|
|
44
|
-
AnthropicRouter,
|
|
45
|
-
GeminiRouter,
|
|
46
|
-
OpenAIRouter,
|
|
47
|
-
RawRouter
|
|
48
|
-
} from "./chunk-EMMSRY32.js";
|
|
49
|
-
|
|
50
|
-
// factories/openai.ts
|
|
51
|
-
var OpenAIToolFactory = class {
|
|
52
|
-
constructor(config) {
|
|
53
|
-
this.config = config;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Create an OpenAI-compatible warp grep tool
|
|
57
|
-
*
|
|
58
|
-
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
59
|
-
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
60
|
-
*/
|
|
61
|
-
createWarpGrepTool(toolConfig) {
|
|
62
|
-
return createWarpGrepTool({
|
|
63
|
-
...toolConfig,
|
|
64
|
-
morphApiKey: this.config.apiKey
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Create an OpenAI-compatible codebase search tool
|
|
69
|
-
*
|
|
70
|
-
* @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
|
|
71
|
-
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
72
|
-
*/
|
|
73
|
-
createCodebaseSearchTool(toolConfig) {
|
|
74
|
-
return createCodebaseSearchTool({
|
|
75
|
-
...toolConfig,
|
|
76
|
-
apiKey: this.config.apiKey
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Create an OpenAI-compatible edit file tool
|
|
81
|
-
*
|
|
82
|
-
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
83
|
-
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
84
|
-
*/
|
|
85
|
-
createEditFileTool(toolConfig = {}) {
|
|
86
|
-
return createEditFileTool({
|
|
87
|
-
...toolConfig,
|
|
88
|
-
morphApiKey: this.config.apiKey
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// factories/anthropic.ts
|
|
94
|
-
var AnthropicToolFactory = class {
|
|
95
|
-
constructor(config) {
|
|
96
|
-
this.config = config;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Create an Anthropic-compatible warp grep tool
|
|
100
|
-
*
|
|
101
|
-
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
102
|
-
* @returns Anthropic Tool with execute and formatResult methods
|
|
103
|
-
*/
|
|
104
|
-
createWarpGrepTool(toolConfig) {
|
|
105
|
-
return createWarpGrepTool2({
|
|
106
|
-
...toolConfig,
|
|
107
|
-
morphApiKey: this.config.apiKey
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Create an Anthropic-compatible codebase search tool
|
|
112
|
-
*
|
|
113
|
-
* @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
|
|
114
|
-
* @returns Anthropic Tool with execute and formatResult methods
|
|
115
|
-
*/
|
|
116
|
-
createCodebaseSearchTool(toolConfig) {
|
|
117
|
-
return createCodebaseSearchTool2({
|
|
118
|
-
...toolConfig,
|
|
119
|
-
apiKey: this.config.apiKey
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Create an Anthropic-compatible edit file tool
|
|
124
|
-
*
|
|
125
|
-
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
126
|
-
* @returns Anthropic Tool with execute and formatResult methods
|
|
127
|
-
*/
|
|
128
|
-
createEditFileTool(toolConfig = {}) {
|
|
129
|
-
return createEditFileTool2({
|
|
130
|
-
...toolConfig,
|
|
131
|
-
morphApiKey: this.config.apiKey
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// factories/vercel.ts
|
|
137
|
-
var VercelToolFactory = class {
|
|
138
|
-
constructor(config) {
|
|
139
|
-
this.config = config;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Create a Vercel AI SDK-compatible warp grep tool
|
|
143
|
-
*
|
|
144
|
-
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
145
|
-
* @returns Vercel AI SDK tool
|
|
146
|
-
*/
|
|
147
|
-
createWarpGrepTool(toolConfig) {
|
|
148
|
-
return createWarpGrepTool3({
|
|
149
|
-
...toolConfig,
|
|
150
|
-
morphApiKey: this.config.apiKey
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Create a Vercel AI SDK-compatible codebase search tool
|
|
155
|
-
*
|
|
156
|
-
* @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
|
|
157
|
-
* @returns Vercel AI SDK tool
|
|
158
|
-
*/
|
|
159
|
-
createCodebaseSearchTool(toolConfig) {
|
|
160
|
-
return createCodebaseSearchTool3({
|
|
161
|
-
...toolConfig,
|
|
162
|
-
apiKey: this.config.apiKey
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Create a Vercel AI SDK-compatible edit file tool
|
|
167
|
-
*
|
|
168
|
-
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
169
|
-
* @returns Vercel AI SDK tool
|
|
170
|
-
*/
|
|
171
|
-
createEditFileTool(toolConfig = {}) {
|
|
172
|
-
return createEditFileTool3({
|
|
173
|
-
...toolConfig,
|
|
174
|
-
morphApiKey: this.config.apiKey
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// client.ts
|
|
180
|
-
var MorphClient = class {
|
|
181
|
-
/** Client configuration */
|
|
182
|
-
config;
|
|
183
|
-
/** FastApply tool for editing files with AI-powered merge */
|
|
184
|
-
fastApply;
|
|
185
|
-
/** CodebaseSearch tool for semantic code search */
|
|
186
|
-
codebaseSearch;
|
|
187
|
-
/** WarpGrep tool for fast code search using ripgrep */
|
|
188
|
-
warpGrep;
|
|
189
|
-
/** Browser tool for AI-powered browser automation */
|
|
190
|
-
browser;
|
|
191
|
-
/** Git tool for version control operations */
|
|
192
|
-
git;
|
|
193
|
-
/** Model routers for intelligent model selection */
|
|
194
|
-
routers;
|
|
195
|
-
/** OpenAI-compatible tool factories */
|
|
196
|
-
openai;
|
|
197
|
-
/** Anthropic-compatible tool factories */
|
|
198
|
-
anthropic;
|
|
199
|
-
/** Vercel AI SDK tool factories */
|
|
200
|
-
vercel;
|
|
201
|
-
/**
|
|
202
|
-
* Create a new Morph SDK client
|
|
203
|
-
*
|
|
204
|
-
* @param config - Client configuration (apiKey, debug, timeout, retryConfig)
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* ```typescript
|
|
208
|
-
* const morph = new MorphClient({
|
|
209
|
-
* apiKey: process.env.MORPH_API_KEY,
|
|
210
|
-
* debug: true,
|
|
211
|
-
* timeout: 60000
|
|
212
|
-
* });
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
215
|
-
constructor(config = {}) {
|
|
216
|
-
this.config = config;
|
|
217
|
-
this.fastApply = new FastApplyClient({
|
|
218
|
-
apiKey: config.apiKey,
|
|
219
|
-
debug: config.debug,
|
|
220
|
-
timeout: config.timeout,
|
|
221
|
-
retryConfig: config.retryConfig
|
|
222
|
-
});
|
|
223
|
-
this.codebaseSearch = new CodebaseSearchClient({
|
|
224
|
-
apiKey: config.apiKey,
|
|
225
|
-
debug: config.debug,
|
|
226
|
-
timeout: config.timeout,
|
|
227
|
-
retryConfig: config.retryConfig
|
|
228
|
-
});
|
|
229
|
-
this.warpGrep = new WarpGrepClient({
|
|
230
|
-
morphApiKey: config.apiKey,
|
|
231
|
-
debug: config.debug,
|
|
232
|
-
timeout: config.timeout,
|
|
233
|
-
retryConfig: config.retryConfig
|
|
234
|
-
});
|
|
235
|
-
this.browser = new BrowserClient({
|
|
236
|
-
apiKey: config.apiKey,
|
|
237
|
-
debug: config.debug,
|
|
238
|
-
timeout: config.timeout,
|
|
239
|
-
retryConfig: config.retryConfig
|
|
240
|
-
});
|
|
241
|
-
this.git = new MorphGit({
|
|
242
|
-
apiKey: config.apiKey,
|
|
243
|
-
retryConfig: config.retryConfig
|
|
244
|
-
});
|
|
245
|
-
this.routers = {
|
|
246
|
-
openai: new OpenAIRouter({
|
|
247
|
-
apiKey: config.apiKey,
|
|
248
|
-
debug: config.debug,
|
|
249
|
-
timeout: config.timeout,
|
|
250
|
-
retryConfig: config.retryConfig
|
|
251
|
-
}),
|
|
252
|
-
anthropic: new AnthropicRouter({
|
|
253
|
-
apiKey: config.apiKey,
|
|
254
|
-
debug: config.debug,
|
|
255
|
-
timeout: config.timeout,
|
|
256
|
-
retryConfig: config.retryConfig
|
|
257
|
-
}),
|
|
258
|
-
gemini: new GeminiRouter({
|
|
259
|
-
apiKey: config.apiKey,
|
|
260
|
-
debug: config.debug,
|
|
261
|
-
timeout: config.timeout,
|
|
262
|
-
retryConfig: config.retryConfig
|
|
263
|
-
}),
|
|
264
|
-
raw: new RawRouter({
|
|
265
|
-
apiKey: config.apiKey,
|
|
266
|
-
debug: config.debug,
|
|
267
|
-
timeout: config.timeout,
|
|
268
|
-
retryConfig: config.retryConfig
|
|
269
|
-
})
|
|
270
|
-
};
|
|
271
|
-
this.openai = new OpenAIToolFactory(config);
|
|
272
|
-
this.anthropic = new AnthropicToolFactory(config);
|
|
273
|
-
this.vercel = new VercelToolFactory(config);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
export {
|
|
278
|
-
OpenAIToolFactory,
|
|
279
|
-
AnthropicToolFactory,
|
|
280
|
-
VercelToolFactory,
|
|
281
|
-
MorphClient
|
|
282
|
-
};
|
|
283
|
-
//# sourceMappingURL=chunk-Y2OTK5WC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../factories/openai.ts","../factories/anthropic.ts","../factories/vercel.ts","../client.ts"],"sourcesContent":["/**\n * OpenAI Tool Factory for MorphClient\n * \n * Creates OpenAI-compatible tools that inherit the API key from MorphClient.\n */\n\nimport type { MorphClientConfig } from '../client.js';\nimport { createWarpGrepTool } from '../tools/warp_grep/openai.js';\nimport { createCodebaseSearchTool } from '../tools/codebase_search/openai.js';\nimport { createEditFileTool } from '../tools/fastapply/openai.js';\nimport type { WarpGrepToolConfig } from '../tools/warp_grep/types.js';\nimport type { CodebaseSearchConfig } from '../tools/codebase_search/types.js';\nimport type { EditFileConfig } from '../tools/fastapply/types.js';\n\n/**\n * Factory for creating OpenAI-compatible tools with inherited API key\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n * \n * const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.openai.createCodebaseSearchTool({ repoId: 'my-project' });\n * const editTool = morph.openai.createEditFileTool({ baseDir: './src' });\n * \n * // Use with OpenAI client\n * const response = await openai.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [grepTool, searchTool, editTool],\n * messages: [{ role: 'user', content: 'Find and fix the bug' }]\n * });\n * ```\n */\nexport class OpenAIToolFactory {\n constructor(private config: MorphClientConfig) {}\n\n /**\n * Create an OpenAI-compatible warp grep tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>) {\n return createWarpGrepTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an OpenAI-compatible codebase search tool\n * \n * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>) {\n return createCodebaseSearchTool({ \n ...toolConfig, \n apiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an OpenAI-compatible edit file tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createEditFileTool(toolConfig: Omit<EditFileConfig, 'morphApiKey'> = {}) {\n return createEditFileTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n}\n\n","/**\n * Anthropic Tool Factory for MorphClient\n * \n * Creates Anthropic-compatible tools that inherit the API key from MorphClient.\n */\n\nimport type { MorphClientConfig } from '../client.js';\nimport { createWarpGrepTool } from '../tools/warp_grep/anthropic.js';\nimport { createCodebaseSearchTool } from '../tools/codebase_search/anthropic.js';\nimport { createEditFileTool } from '../tools/fastapply/anthropic.js';\nimport type { WarpGrepToolConfig } from '../tools/warp_grep/types.js';\nimport type { CodebaseSearchConfig } from '../tools/codebase_search/types.js';\nimport type { EditFileConfig } from '../tools/fastapply/types.js';\n\n/**\n * Factory for creating Anthropic-compatible tools with inherited API key\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n * \n * const grepTool = morph.anthropic.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'my-project' });\n * const editTool = morph.anthropic.createEditFileTool({ baseDir: './src' });\n * \n * // Use with Anthropic client\n * const response = await anthropic.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [grepTool, searchTool, editTool],\n * messages: [{ role: 'user', content: 'Find and fix the bug' }]\n * });\n * ```\n */\nexport class AnthropicToolFactory {\n constructor(private config: MorphClientConfig) {}\n\n /**\n * Create an Anthropic-compatible warp grep tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>) {\n return createWarpGrepTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n\n }\n\n /**\n * Create an Anthropic-compatible codebase search tool\n * \n * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>) {\n return createCodebaseSearchTool({ \n ...toolConfig, \n apiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an Anthropic-compatible edit file tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createEditFileTool(toolConfig: Omit<EditFileConfig, 'morphApiKey'> = {}) {\n return createEditFileTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n}\n\n","/**\n * Vercel AI SDK Tool Factory for MorphClient\n * \n * Creates Vercel AI SDK-compatible tools that inherit the API key from MorphClient.\n */\n\nimport type { MorphClientConfig } from '../client.js';\nimport { createWarpGrepTool } from '../tools/warp_grep/vercel.js';\nimport { createCodebaseSearchTool } from '../tools/codebase_search/vercel.js';\nimport { createEditFileTool } from '../tools/fastapply/vercel.js';\nimport type { WarpGrepToolConfig } from '../tools/warp_grep/types.js';\nimport type { CodebaseSearchConfig } from '../tools/codebase_search/types.js';\nimport type { EditFileConfig } from '../tools/fastapply/types.js';\n\n/**\n * Factory for creating Vercel AI SDK-compatible tools with inherited API key\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n * \n * const grepTool = morph.vercel.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.vercel.createCodebaseSearchTool({ repoId: 'my-project' });\n * const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });\n * \n * // Use with Vercel AI SDK\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { grep: grepTool, search: searchTool, edit: editTool },\n * prompt: 'Find and fix the bug'\n * });\n * ```\n */\nexport class VercelToolFactory {\n constructor(private config: MorphClientConfig) {}\n\n /**\n * Create a Vercel AI SDK-compatible warp grep tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>) {\n return createWarpGrepTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create a Vercel AI SDK-compatible codebase search tool\n * \n * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>) {\n return createCodebaseSearchTool({ \n ...toolConfig, \n apiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create a Vercel AI SDK-compatible edit file tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createEditFileTool(toolConfig: Omit<EditFileConfig, 'morphApiKey'> = {}) {\n return createEditFileTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n}\n\n","/**\n * Unified Morph SDK Client\n * \n * Provides access to all Morph tools through a single interface\n * \n * @example\n * ```typescript\n * import { MorphClient } from '@morphllm/morphsdk';\n * \n * const morph = new MorphClient({ \n * apiKey: process.env.MORPH_API_KEY,\n * debug: true,\n * timeout: 60000\n * });\n * \n * // Direct execution\n * await morph.fastApply.execute({ target_filepath: 'src/index.ts', ... });\n * await morph.warpGrep.execute({ query: 'Find auth', repoRoot: '.' });\n * await morph.codebaseSearch.search({ query: 'auth logic', repoId: 'x' });\n * \n * // Tool creation for AI agents (API key inherited)\n * const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'x' });\n * const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });\n * \n * // Use tools with OpenAI\n * const response = await openai.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [grepTool],\n * messages: [{ role: 'user', content: 'Find the bug' }]\n * });\n * ```\n */\n\nimport type { RetryConfig } from './tools/utils/resilience.js';\nimport { FastApplyClient } from './tools/fastapply/core.js';\nimport { CodebaseSearchClient } from './tools/codebase_search/core.js';\nimport { BrowserClient } from './tools/browser/core.js';\nimport { WarpGrepClient } from './tools/warp_grep/client.js';\nimport { MorphGit } from './git/index.js';\nimport { OpenAIRouter, AnthropicRouter, GeminiRouter, RawRouter } from './modelrouter/core.js';\nimport { OpenAIToolFactory, AnthropicToolFactory, VercelToolFactory } from './factories/index.js';\n\n/**\n * Configuration for the MorphClient\n */\nexport interface MorphClientConfig {\n /** Morph API key for authentication (defaults to MORPH_API_KEY env var) */\n apiKey?: string;\n /** Enable debug logging across all tools */\n debug?: boolean;\n /** Default timeout in milliseconds for API requests */\n timeout?: number;\n /** Retry configuration for failed requests */\n retryConfig?: RetryConfig;\n}\n\n/**\n * Unified Morph SDK Client\n * \n * Provides access to all Morph tools through a single interface:\n * - fastApply: AI-powered file editing with intelligent merging\n * - codebaseSearch: Semantic code search\n * - warpGrep: Fast code search with ripgrep\n * - browser: AI-powered browser automation\n * - git: Version control operations\n * - routers: Intelligent model selection (OpenAI, Anthropic, Gemini)\n * - openai/anthropic/vercel: Tool factories for agent frameworks\n */\nexport class MorphClient {\n /** Client configuration */\n public config: MorphClientConfig;\n\n /** FastApply tool for editing files with AI-powered merge */\n public fastApply: FastApplyClient;\n\n /** CodebaseSearch tool for semantic code search */\n public codebaseSearch: CodebaseSearchClient;\n\n /** WarpGrep tool for fast code search using ripgrep */\n public warpGrep: WarpGrepClient;\n\n /** Browser tool for AI-powered browser automation */\n public browser: BrowserClient;\n\n /** Git tool for version control operations */\n public git: MorphGit;\n\n /** Model routers for intelligent model selection */\n public routers: {\n openai: OpenAIRouter;\n anthropic: AnthropicRouter;\n gemini: GeminiRouter;\n raw: RawRouter;\n };\n\n /** OpenAI-compatible tool factories */\n public openai: OpenAIToolFactory;\n\n /** Anthropic-compatible tool factories */\n public anthropic: AnthropicToolFactory;\n\n /** Vercel AI SDK tool factories */\n public vercel: VercelToolFactory;\n\n /**\n * Create a new Morph SDK client\n * \n * @param config - Client configuration (apiKey, debug, timeout, retryConfig)\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ \n * apiKey: process.env.MORPH_API_KEY,\n * debug: true,\n * timeout: 60000\n * });\n * ```\n */\n constructor(config: MorphClientConfig = {}) {\n this.config = config;\n\n // Initialize all sub-clients with shared config\n this.fastApply = new FastApplyClient({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n });\n\n this.codebaseSearch = new CodebaseSearchClient({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n });\n\n this.warpGrep = new WarpGrepClient({\n morphApiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n });\n\n this.browser = new BrowserClient({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n });\n\n this.git = new MorphGit({\n apiKey: config.apiKey,\n retryConfig: config.retryConfig,\n });\n\n this.routers = {\n openai: new OpenAIRouter({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n }),\n anthropic: new AnthropicRouter({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n }),\n gemini: new GeminiRouter({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n }),\n raw: new RawRouter({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n }),\n };\n\n // Initialize tool factories\n this.openai = new OpenAIToolFactory(config);\n this.anthropic = new AnthropicToolFactory(config);\n this.vercel = new VercelToolFactory(config);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCO,IAAM,oBAAN,MAAwB;AAAA,EAC7B,YAAoB,QAA2B;AAA3B;AAAA,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhD,mBAAmB,YAAqD;AACtE,WAAO,mBAAmB;AAAA,MACxB,GAAG;AAAA,MACH,aAAa,KAAK,OAAO;AAAA,IAC3B,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,yBAAyB,YAAkD;AACzE,WAAO,yBAAyB;AAAA,MAC9B,GAAG;AAAA,MACH,QAAQ,KAAK,OAAO;AAAA,IACtB,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,mBAAmB,aAAkD,CAAC,GAAG;AACvE,WAAO,mBAAmB;AAAA,MACxB,GAAG;AAAA,MACH,aAAa,KAAK,OAAO;AAAA,IAC3B,CAAC;AAAA,EACH;AACF;;;ACzCO,IAAM,uBAAN,MAA2B;AAAA,EAChC,YAAoB,QAA2B;AAA3B;AAAA,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhD,mBAAmB,YAAqD;AACtE,WAAOA,oBAAmB;AAAA,MACxB,GAAG;AAAA,MACH,aAAa,KAAK,OAAO;AAAA,IAC3B,CAAC;AAAA,EAEH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,yBAAyB,YAAkD;AACzE,WAAOC,0BAAyB;AAAA,MAC9B,GAAG;AAAA,MACH,QAAQ,KAAK,OAAO;AAAA,IACtB,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,mBAAmB,aAAkD,CAAC,GAAG;AACvE,WAAOC,oBAAmB;AAAA,MACxB,GAAG;AAAA,MACH,aAAa,KAAK,OAAO;AAAA,IAC3B,CAAC;AAAA,EACH;AACF;;;AC1CO,IAAM,oBAAN,MAAwB;AAAA,EAC7B,YAAoB,QAA2B;AAA3B;AAAA,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhD,mBAAmB,YAAqD;AACtE,WAAOC,oBAAmB;AAAA,MACxB,GAAG;AAAA,MACH,aAAa,KAAK,OAAO;AAAA,IAC3B,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,yBAAyB,YAAkD;AACzE,WAAOC,0BAAyB;AAAA,MAC9B,GAAG;AAAA,MACH,QAAQ,KAAK,OAAO;AAAA,IACtB,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,mBAAmB,aAAkD,CAAC,GAAG;AACvE,WAAOC,oBAAmB;AAAA,MACxB,GAAG;AAAA,MACH,aAAa,KAAK,OAAO;AAAA,IAC3B,CAAC;AAAA,EACH;AACF;;;ACLO,IAAM,cAAN,MAAkB;AAAA;AAAA,EAEhB;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAQA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBP,YAAY,SAA4B,CAAC,GAAG;AAC1C,SAAK,SAAS;AAGd,SAAK,YAAY,IAAI,gBAAgB;AAAA,MACnC,QAAQ,OAAO;AAAA,MACf,OAAO,OAAO;AAAA,MACd,SAAS,OAAO;AAAA,MAChB,aAAa,OAAO;AAAA,IACtB,CAAC;AAED,SAAK,iBAAiB,IAAI,qBAAqB;AAAA,MAC7C,QAAQ,OAAO;AAAA,MACf,OAAO,OAAO;AAAA,MACd,SAAS,OAAO;AAAA,MAChB,aAAa,OAAO;AAAA,IACtB,CAAC;AAED,SAAK,WAAW,IAAI,eAAe;AAAA,MACjC,aAAa,OAAO;AAAA,MACpB,OAAO,OAAO;AAAA,MACd,SAAS,OAAO;AAAA,MAChB,aAAa,OAAO;AAAA,IACtB,CAAC;AAED,SAAK,UAAU,IAAI,cAAc;AAAA,MAC/B,QAAQ,OAAO;AAAA,MACf,OAAO,OAAO;AAAA,MACd,SAAS,OAAO;AAAA,MAChB,aAAa,OAAO;AAAA,IACtB,CAAC;AAED,SAAK,MAAM,IAAI,SAAS;AAAA,MACtB,QAAQ,OAAO;AAAA,MACf,aAAa,OAAO;AAAA,IACtB,CAAC;AAED,SAAK,UAAU;AAAA,MACb,QAAQ,IAAI,aAAa;AAAA,QACvB,QAAQ,OAAO;AAAA,QACf,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,QAChB,aAAa,OAAO;AAAA,MACtB,CAAC;AAAA,MACD,WAAW,IAAI,gBAAgB;AAAA,QAC7B,QAAQ,OAAO;AAAA,QACf,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,QAChB,aAAa,OAAO;AAAA,MACtB,CAAC;AAAA,MACD,QAAQ,IAAI,aAAa;AAAA,QACvB,QAAQ,OAAO;AAAA,QACf,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,QAChB,aAAa,OAAO;AAAA,MACtB,CAAC;AAAA,MACD,KAAK,IAAI,UAAU;AAAA,QACjB,QAAQ,OAAO;AAAA,QACf,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,QAChB,aAAa,OAAO;AAAA,MACtB,CAAC;AAAA,IACH;AAGA,SAAK,SAAS,IAAI,kBAAkB,MAAM;AAC1C,SAAK,YAAY,IAAI,qBAAqB,MAAM;AAChD,SAAK,SAAS,IAAI,kBAAkB,MAAM;AAAA,EAC5C;AACF;","names":["createWarpGrepTool","createCodebaseSearchTool","createEditFileTool","createWarpGrepTool","createCodebaseSearchTool","createEditFileTool"]}
|
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
import { RetryConfig } from './tools/utils/resilience.js';
|
|
2
|
-
import { FastApplyClient } from './tools/fastapply/core.js';
|
|
3
|
-
import { CodebaseSearchClient } from './tools/codebase_search/core.js';
|
|
4
|
-
import { BrowserClient } from './tools/browser/core.js';
|
|
5
|
-
import { WarpGrepClient } from './tools/warp_grep/client.js';
|
|
6
|
-
import { MorphGit } from './git/client.js';
|
|
7
|
-
import { OpenAIRouter, AnthropicRouter, GeminiRouter, RawRouter } from './modelrouter/core.js';
|
|
8
|
-
import { EditFileConfig, EditFileInput, EditFileResult, EditChanges } from './tools/fastapply/types.js';
|
|
9
|
-
import { CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult } from './tools/codebase_search/types.js';
|
|
10
|
-
import { d as WarpGrepToolConfig, b as WarpGrepResult, c as WarpGrepContext } from './types-BMowL9iZ.js';
|
|
11
|
-
import * as openai_resources_index_mjs from 'openai/resources/index.mjs';
|
|
12
|
-
import * as _anthropic_ai_sdk_resources_messages_mjs from '@anthropic-ai/sdk/resources/messages.mjs';
|
|
13
|
-
import * as ai from 'ai';
|
|
14
|
-
import { WarpGrepInput } from './tools/warp_grep/vercel.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Factory for creating OpenAI-compatible tools with inherited API key
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
|
|
22
|
-
*
|
|
23
|
-
* const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });
|
|
24
|
-
* const searchTool = morph.openai.createCodebaseSearchTool({ repoId: 'my-project' });
|
|
25
|
-
* const editTool = morph.openai.createEditFileTool({ baseDir: './src' });
|
|
26
|
-
*
|
|
27
|
-
* // Use with OpenAI client
|
|
28
|
-
* const response = await openai.chat.completions.create({
|
|
29
|
-
* model: 'gpt-4o',
|
|
30
|
-
* tools: [grepTool, searchTool, editTool],
|
|
31
|
-
* messages: [{ role: 'user', content: 'Find and fix the bug' }]
|
|
32
|
-
* });
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
declare class OpenAIToolFactory {
|
|
36
|
-
private config;
|
|
37
|
-
constructor(config: MorphClientConfig);
|
|
38
|
-
/**
|
|
39
|
-
* Create an OpenAI-compatible warp grep tool
|
|
40
|
-
*
|
|
41
|
-
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
42
|
-
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
43
|
-
*/
|
|
44
|
-
createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>): openai_resources_index_mjs.ChatCompletionTool & {
|
|
45
|
-
execute: (input: unknown) => Promise<WarpGrepResult>;
|
|
46
|
-
formatResult: (result: WarpGrepResult) => string;
|
|
47
|
-
getSystemPrompt: () => string;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Create an OpenAI-compatible codebase search tool
|
|
51
|
-
*
|
|
52
|
-
* @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
|
|
53
|
-
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
54
|
-
*/
|
|
55
|
-
createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>): openai_resources_index_mjs.ChatCompletionTool & {
|
|
56
|
-
execute: (input: CodebaseSearchInput | string) => Promise<CodebaseSearchResult>;
|
|
57
|
-
formatResult: (result: CodebaseSearchResult) => string;
|
|
58
|
-
getSystemPrompt: () => string;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Create an OpenAI-compatible edit file tool
|
|
62
|
-
*
|
|
63
|
-
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
64
|
-
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
65
|
-
*/
|
|
66
|
-
createEditFileTool(toolConfig?: Omit<EditFileConfig, 'morphApiKey'>): openai_resources_index_mjs.ChatCompletionTool & {
|
|
67
|
-
execute: (input: EditFileInput | string) => Promise<EditFileResult>;
|
|
68
|
-
formatResult: (result: EditFileResult) => string;
|
|
69
|
-
getSystemPrompt: () => string;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Factory for creating Anthropic-compatible tools with inherited API key
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```typescript
|
|
78
|
-
* const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
|
|
79
|
-
*
|
|
80
|
-
* const grepTool = morph.anthropic.createWarpGrepTool({ repoRoot: '.' });
|
|
81
|
-
* const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'my-project' });
|
|
82
|
-
* const editTool = morph.anthropic.createEditFileTool({ baseDir: './src' });
|
|
83
|
-
*
|
|
84
|
-
* // Use with Anthropic client
|
|
85
|
-
* const response = await anthropic.messages.create({
|
|
86
|
-
* model: 'claude-sonnet-4-5-20250929',
|
|
87
|
-
* tools: [grepTool, searchTool, editTool],
|
|
88
|
-
* messages: [{ role: 'user', content: 'Find and fix the bug' }]
|
|
89
|
-
* });
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
declare class AnthropicToolFactory {
|
|
93
|
-
private config;
|
|
94
|
-
constructor(config: MorphClientConfig);
|
|
95
|
-
/**
|
|
96
|
-
* Create an Anthropic-compatible warp grep tool
|
|
97
|
-
*
|
|
98
|
-
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
99
|
-
* @returns Anthropic Tool with execute and formatResult methods
|
|
100
|
-
*/
|
|
101
|
-
createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>): _anthropic_ai_sdk_resources_messages_mjs.Tool & {
|
|
102
|
-
execute: (input: unknown) => Promise<WarpGrepResult>;
|
|
103
|
-
formatResult: (result: WarpGrepResult) => string;
|
|
104
|
-
getSystemPrompt: () => string;
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Create an Anthropic-compatible codebase search tool
|
|
108
|
-
*
|
|
109
|
-
* @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
|
|
110
|
-
* @returns Anthropic Tool with execute and formatResult methods
|
|
111
|
-
*/
|
|
112
|
-
createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>): _anthropic_ai_sdk_resources_messages_mjs.Tool & {
|
|
113
|
-
execute: (input: CodebaseSearchInput) => Promise<CodebaseSearchResult>;
|
|
114
|
-
formatResult: (result: CodebaseSearchResult) => string;
|
|
115
|
-
getSystemPrompt: () => string;
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Create an Anthropic-compatible edit file tool
|
|
119
|
-
*
|
|
120
|
-
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
121
|
-
* @returns Anthropic Tool with execute and formatResult methods
|
|
122
|
-
*/
|
|
123
|
-
createEditFileTool(toolConfig?: Omit<EditFileConfig, 'morphApiKey'>): _anthropic_ai_sdk_resources_messages_mjs.Tool & {
|
|
124
|
-
execute: (input: EditFileInput) => Promise<EditFileResult>;
|
|
125
|
-
formatResult: (result: EditFileResult) => string;
|
|
126
|
-
getSystemPrompt: () => string;
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Factory for creating Vercel AI SDK-compatible tools with inherited API key
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* ```typescript
|
|
135
|
-
* const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
|
|
136
|
-
*
|
|
137
|
-
* const grepTool = morph.vercel.createWarpGrepTool({ repoRoot: '.' });
|
|
138
|
-
* const searchTool = morph.vercel.createCodebaseSearchTool({ repoId: 'my-project' });
|
|
139
|
-
* const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });
|
|
140
|
-
*
|
|
141
|
-
* // Use with Vercel AI SDK
|
|
142
|
-
* const result = await generateText({
|
|
143
|
-
* model: anthropic('claude-sonnet-4-5-20250929'),
|
|
144
|
-
* tools: { grep: grepTool, search: searchTool, edit: editTool },
|
|
145
|
-
* prompt: 'Find and fix the bug'
|
|
146
|
-
* });
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
declare class VercelToolFactory {
|
|
150
|
-
private config;
|
|
151
|
-
constructor(config: MorphClientConfig);
|
|
152
|
-
/**
|
|
153
|
-
* Create a Vercel AI SDK-compatible warp grep tool
|
|
154
|
-
*
|
|
155
|
-
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
156
|
-
* @returns Vercel AI SDK tool
|
|
157
|
-
*/
|
|
158
|
-
createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>): ai.Tool<WarpGrepInput, {
|
|
159
|
-
success: boolean;
|
|
160
|
-
contexts: WarpGrepContext[] | undefined;
|
|
161
|
-
summary: string | undefined;
|
|
162
|
-
}>;
|
|
163
|
-
/**
|
|
164
|
-
* Create a Vercel AI SDK-compatible codebase search tool
|
|
165
|
-
*
|
|
166
|
-
* @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
|
|
167
|
-
* @returns Vercel AI SDK tool
|
|
168
|
-
*/
|
|
169
|
-
createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>): ai.Tool<{
|
|
170
|
-
query: string;
|
|
171
|
-
target_directories: string[];
|
|
172
|
-
explanation: string;
|
|
173
|
-
limit?: number | undefined;
|
|
174
|
-
}, {
|
|
175
|
-
error: string | undefined;
|
|
176
|
-
results: never[];
|
|
177
|
-
found?: undefined;
|
|
178
|
-
searchTime?: undefined;
|
|
179
|
-
} | {
|
|
180
|
-
found: number;
|
|
181
|
-
searchTime: string;
|
|
182
|
-
results: {
|
|
183
|
-
file: string;
|
|
184
|
-
symbol: string;
|
|
185
|
-
lines: string;
|
|
186
|
-
language: string;
|
|
187
|
-
relevance: string;
|
|
188
|
-
code: string;
|
|
189
|
-
}[];
|
|
190
|
-
error?: undefined;
|
|
191
|
-
}>;
|
|
192
|
-
/**
|
|
193
|
-
* Create a Vercel AI SDK-compatible edit file tool
|
|
194
|
-
*
|
|
195
|
-
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
196
|
-
* @returns Vercel AI SDK tool
|
|
197
|
-
*/
|
|
198
|
-
createEditFileTool(toolConfig?: Omit<EditFileConfig, 'morphApiKey'>): ai.Tool<{
|
|
199
|
-
target_filepath: string;
|
|
200
|
-
instructions: string;
|
|
201
|
-
code_edit: string;
|
|
202
|
-
}, {
|
|
203
|
-
success: boolean;
|
|
204
|
-
filepath: string;
|
|
205
|
-
changes: EditChanges;
|
|
206
|
-
udiff: string | undefined;
|
|
207
|
-
}>;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Unified Morph SDK Client
|
|
212
|
-
*
|
|
213
|
-
* Provides access to all Morph tools through a single interface
|
|
214
|
-
*
|
|
215
|
-
* @example
|
|
216
|
-
* ```typescript
|
|
217
|
-
* import { MorphClient } from '@morphllm/morphsdk';
|
|
218
|
-
*
|
|
219
|
-
* const morph = new MorphClient({
|
|
220
|
-
* apiKey: process.env.MORPH_API_KEY,
|
|
221
|
-
* debug: true,
|
|
222
|
-
* timeout: 60000
|
|
223
|
-
* });
|
|
224
|
-
*
|
|
225
|
-
* // Direct execution
|
|
226
|
-
* await morph.fastApply.execute({ target_filepath: 'src/index.ts', ... });
|
|
227
|
-
* await morph.warpGrep.execute({ query: 'Find auth', repoRoot: '.' });
|
|
228
|
-
* await morph.codebaseSearch.search({ query: 'auth logic', repoId: 'x' });
|
|
229
|
-
*
|
|
230
|
-
* // Tool creation for AI agents (API key inherited)
|
|
231
|
-
* const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });
|
|
232
|
-
* const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'x' });
|
|
233
|
-
* const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });
|
|
234
|
-
*
|
|
235
|
-
* // Use tools with OpenAI
|
|
236
|
-
* const response = await openai.chat.completions.create({
|
|
237
|
-
* model: 'gpt-4o',
|
|
238
|
-
* tools: [grepTool],
|
|
239
|
-
* messages: [{ role: 'user', content: 'Find the bug' }]
|
|
240
|
-
* });
|
|
241
|
-
* ```
|
|
242
|
-
*/
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Configuration for the MorphClient
|
|
246
|
-
*/
|
|
247
|
-
interface MorphClientConfig {
|
|
248
|
-
/** Morph API key for authentication (defaults to MORPH_API_KEY env var) */
|
|
249
|
-
apiKey?: string;
|
|
250
|
-
/** Enable debug logging across all tools */
|
|
251
|
-
debug?: boolean;
|
|
252
|
-
/** Default timeout in milliseconds for API requests */
|
|
253
|
-
timeout?: number;
|
|
254
|
-
/** Retry configuration for failed requests */
|
|
255
|
-
retryConfig?: RetryConfig;
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Unified Morph SDK Client
|
|
259
|
-
*
|
|
260
|
-
* Provides access to all Morph tools through a single interface:
|
|
261
|
-
* - fastApply: AI-powered file editing with intelligent merging
|
|
262
|
-
* - codebaseSearch: Semantic code search
|
|
263
|
-
* - warpGrep: Fast code search with ripgrep
|
|
264
|
-
* - browser: AI-powered browser automation
|
|
265
|
-
* - git: Version control operations
|
|
266
|
-
* - routers: Intelligent model selection (OpenAI, Anthropic, Gemini)
|
|
267
|
-
* - openai/anthropic/vercel: Tool factories for agent frameworks
|
|
268
|
-
*/
|
|
269
|
-
declare class MorphClient {
|
|
270
|
-
/** Client configuration */
|
|
271
|
-
config: MorphClientConfig;
|
|
272
|
-
/** FastApply tool for editing files with AI-powered merge */
|
|
273
|
-
fastApply: FastApplyClient;
|
|
274
|
-
/** CodebaseSearch tool for semantic code search */
|
|
275
|
-
codebaseSearch: CodebaseSearchClient;
|
|
276
|
-
/** WarpGrep tool for fast code search using ripgrep */
|
|
277
|
-
warpGrep: WarpGrepClient;
|
|
278
|
-
/** Browser tool for AI-powered browser automation */
|
|
279
|
-
browser: BrowserClient;
|
|
280
|
-
/** Git tool for version control operations */
|
|
281
|
-
git: MorphGit;
|
|
282
|
-
/** Model routers for intelligent model selection */
|
|
283
|
-
routers: {
|
|
284
|
-
openai: OpenAIRouter;
|
|
285
|
-
anthropic: AnthropicRouter;
|
|
286
|
-
gemini: GeminiRouter;
|
|
287
|
-
raw: RawRouter;
|
|
288
|
-
};
|
|
289
|
-
/** OpenAI-compatible tool factories */
|
|
290
|
-
openai: OpenAIToolFactory;
|
|
291
|
-
/** Anthropic-compatible tool factories */
|
|
292
|
-
anthropic: AnthropicToolFactory;
|
|
293
|
-
/** Vercel AI SDK tool factories */
|
|
294
|
-
vercel: VercelToolFactory;
|
|
295
|
-
/**
|
|
296
|
-
* Create a new Morph SDK client
|
|
297
|
-
*
|
|
298
|
-
* @param config - Client configuration (apiKey, debug, timeout, retryConfig)
|
|
299
|
-
*
|
|
300
|
-
* @example
|
|
301
|
-
* ```typescript
|
|
302
|
-
* const morph = new MorphClient({
|
|
303
|
-
* apiKey: process.env.MORPH_API_KEY,
|
|
304
|
-
* debug: true,
|
|
305
|
-
* timeout: 60000
|
|
306
|
-
* });
|
|
307
|
-
* ```
|
|
308
|
-
*/
|
|
309
|
-
constructor(config?: MorphClientConfig);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
export { AnthropicToolFactory as A, MorphClient as M, OpenAIToolFactory as O, VercelToolFactory as V, type MorphClientConfig as a };
|