@morphllm/morphsdk 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/README.md +39 -0
  2. package/dist/chunk-4UVEBIDK.js +358 -0
  3. package/dist/chunk-4UVEBIDK.js.map +1 -0
  4. package/dist/chunk-4V46N27D.js +169 -0
  5. package/dist/chunk-4V46N27D.js.map +1 -0
  6. package/dist/chunk-4VWJFZVS.js +89 -0
  7. package/dist/chunk-4VWJFZVS.js.map +1 -0
  8. package/dist/chunk-5COKN3XD.js +91 -0
  9. package/dist/chunk-5COKN3XD.js.map +1 -0
  10. package/dist/chunk-5VQEQSJQ.js +394 -0
  11. package/dist/chunk-5VQEQSJQ.js.map +1 -0
  12. package/dist/chunk-63WE2C5R.js +43 -0
  13. package/dist/chunk-63WE2C5R.js.map +1 -0
  14. package/dist/chunk-74ZHKB54.js +9 -0
  15. package/dist/chunk-74ZHKB54.js.map +1 -0
  16. package/dist/chunk-7PZJQFCY.js +39 -0
  17. package/dist/chunk-7PZJQFCY.js.map +1 -0
  18. package/dist/chunk-BILUTNBC.js +83 -0
  19. package/dist/chunk-BILUTNBC.js.map +1 -0
  20. package/dist/chunk-G4DJ6VSM.js +78 -0
  21. package/dist/chunk-G4DJ6VSM.js.map +1 -0
  22. package/dist/chunk-HGIFACNP.js +59 -0
  23. package/dist/chunk-HGIFACNP.js.map +1 -0
  24. package/dist/chunk-OI5YYE36.js +189 -0
  25. package/dist/chunk-OI5YYE36.js.map +1 -0
  26. package/dist/chunk-PZ5AY32C.js +10 -0
  27. package/dist/chunk-PZ5AY32C.js.map +1 -0
  28. package/dist/chunk-VJK4PH5V.js +105 -0
  29. package/dist/chunk-VJK4PH5V.js.map +1 -0
  30. package/dist/chunk-WXBUVKYL.js +128 -0
  31. package/dist/chunk-WXBUVKYL.js.map +1 -0
  32. package/dist/chunk-X2K57BH6.js +1 -0
  33. package/dist/chunk-X2K57BH6.js.map +1 -0
  34. package/dist/chunk-YQMPVJ2L.js +32 -0
  35. package/dist/chunk-YQMPVJ2L.js.map +1 -0
  36. package/dist/chunk-YWS2GRQC.js +97 -0
  37. package/dist/chunk-YWS2GRQC.js.map +1 -0
  38. package/dist/chunk-ZQEWQ7LJ.js +97 -0
  39. package/dist/chunk-ZQEWQ7LJ.js.map +1 -0
  40. package/dist/client.cjs +1358 -0
  41. package/dist/client.cjs.map +1 -0
  42. package/dist/client.js +15 -0
  43. package/dist/client.js.map +1 -0
  44. package/dist/git/client.cjs +428 -0
  45. package/dist/git/client.cjs.map +1 -0
  46. package/dist/git/client.js +8 -0
  47. package/dist/git/client.js.map +1 -0
  48. package/dist/git/config.cjs +41 -0
  49. package/dist/git/config.cjs.map +1 -0
  50. package/dist/git/config.js +17 -0
  51. package/dist/git/config.js.map +1 -0
  52. package/dist/git/index.cjs +438 -0
  53. package/dist/git/index.cjs.map +1 -0
  54. package/dist/git/index.js +14 -0
  55. package/dist/git/index.js.map +1 -0
  56. package/dist/git/types.cjs +19 -0
  57. package/dist/git/types.cjs.map +1 -0
  58. package/dist/git/types.js +1 -0
  59. package/dist/git/types.js.map +1 -0
  60. package/dist/index.cjs +1372 -0
  61. package/dist/index.cjs.map +1 -0
  62. package/dist/index.js +34 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/tools/browser/anthropic.cjs +281 -0
  65. package/dist/tools/browser/anthropic.cjs.map +1 -0
  66. package/dist/tools/browser/anthropic.js +72 -0
  67. package/dist/tools/browser/anthropic.js.map +1 -0
  68. package/dist/tools/browser/core.cjs +459 -0
  69. package/dist/tools/browser/core.cjs.map +1 -0
  70. package/dist/tools/browser/core.js +21 -0
  71. package/dist/tools/browser/core.js.map +1 -0
  72. package/dist/tools/browser/index.cjs +497 -0
  73. package/dist/tools/browser/index.cjs.map +1 -0
  74. package/dist/tools/browser/index.js +27 -0
  75. package/dist/tools/browser/index.js.map +1 -0
  76. package/dist/tools/browser/openai.cjs +297 -0
  77. package/dist/tools/browser/openai.cjs.map +1 -0
  78. package/dist/tools/browser/openai.js +85 -0
  79. package/dist/tools/browser/openai.js.map +1 -0
  80. package/dist/tools/browser/prompts.cjs +64 -0
  81. package/dist/tools/browser/prompts.cjs.map +1 -0
  82. package/dist/tools/browser/prompts.js +10 -0
  83. package/dist/tools/browser/prompts.js.map +1 -0
  84. package/dist/tools/browser/types.cjs +19 -0
  85. package/dist/tools/browser/types.cjs.map +1 -0
  86. package/dist/tools/browser/types.js +1 -0
  87. package/dist/tools/browser/types.js.map +1 -0
  88. package/dist/tools/browser/vercel.cjs +242 -0
  89. package/dist/tools/browser/vercel.cjs.map +1 -0
  90. package/dist/tools/browser/vercel.js +49 -0
  91. package/dist/tools/browser/vercel.js.map +1 -0
  92. package/dist/tools/codebase_search/anthropic.cjs +267 -0
  93. package/dist/tools/codebase_search/anthropic.cjs.map +1 -0
  94. package/dist/tools/codebase_search/anthropic.js +11 -0
  95. package/dist/tools/codebase_search/anthropic.js.map +1 -0
  96. package/dist/tools/codebase_search/core.cjs +201 -0
  97. package/dist/tools/codebase_search/core.cjs.map +1 -0
  98. package/dist/tools/codebase_search/core.js +11 -0
  99. package/dist/tools/codebase_search/core.js.map +1 -0
  100. package/dist/tools/codebase_search/index.cjs +393 -0
  101. package/dist/tools/codebase_search/index.cjs.map +1 -0
  102. package/dist/tools/codebase_search/index.js +27 -0
  103. package/dist/tools/codebase_search/index.js.map +1 -0
  104. package/dist/tools/codebase_search/openai.cjs +316 -0
  105. package/dist/tools/codebase_search/openai.cjs.map +1 -0
  106. package/dist/tools/codebase_search/openai.js +21 -0
  107. package/dist/tools/codebase_search/openai.js.map +1 -0
  108. package/dist/tools/codebase_search/prompts.cjs +57 -0
  109. package/dist/tools/codebase_search/prompts.cjs.map +1 -0
  110. package/dist/tools/codebase_search/prompts.js +10 -0
  111. package/dist/tools/codebase_search/prompts.js.map +1 -0
  112. package/dist/tools/codebase_search/types.cjs +19 -0
  113. package/dist/tools/codebase_search/types.cjs.map +1 -0
  114. package/dist/tools/codebase_search/types.js +1 -0
  115. package/dist/tools/codebase_search/types.js.map +1 -0
  116. package/dist/tools/codebase_search/vercel.cjs +230 -0
  117. package/dist/tools/codebase_search/vercel.cjs.map +1 -0
  118. package/dist/tools/codebase_search/vercel.js +15 -0
  119. package/dist/tools/codebase_search/vercel.js.map +1 -0
  120. package/dist/tools/fastapply/anthropic.cjs +335 -0
  121. package/dist/tools/fastapply/anthropic.cjs.map +1 -0
  122. package/dist/tools/fastapply/anthropic.js +13 -0
  123. package/dist/tools/fastapply/anthropic.js.map +1 -0
  124. package/dist/tools/fastapply/core.cjs +267 -0
  125. package/dist/tools/fastapply/core.cjs.map +1 -0
  126. package/dist/tools/fastapply/core.js +15 -0
  127. package/dist/tools/fastapply/core.js.map +1 -0
  128. package/dist/tools/fastapply/index.cjs +500 -0
  129. package/dist/tools/fastapply/index.cjs.map +1 -0
  130. package/dist/tools/fastapply/index.js +32 -0
  131. package/dist/tools/fastapply/index.js.map +1 -0
  132. package/dist/tools/fastapply/openai.cjs +353 -0
  133. package/dist/tools/fastapply/openai.cjs.map +1 -0
  134. package/dist/tools/fastapply/openai.js +21 -0
  135. package/dist/tools/fastapply/openai.js.map +1 -0
  136. package/dist/tools/fastapply/prompts.cjs +68 -0
  137. package/dist/tools/fastapply/prompts.cjs.map +1 -0
  138. package/dist/tools/fastapply/prompts.js +10 -0
  139. package/dist/tools/fastapply/prompts.js.map +1 -0
  140. package/dist/tools/fastapply/types.cjs +19 -0
  141. package/dist/tools/fastapply/types.cjs.map +1 -0
  142. package/dist/tools/fastapply/types.js +1 -0
  143. package/dist/tools/fastapply/types.js.map +1 -0
  144. package/dist/tools/fastapply/vercel.cjs +347 -0
  145. package/dist/tools/fastapply/vercel.cjs.map +1 -0
  146. package/dist/tools/fastapply/vercel.js +17 -0
  147. package/dist/tools/fastapply/vercel.js.map +1 -0
  148. package/dist/tools/index.cjs +500 -0
  149. package/dist/tools/index.cjs.map +1 -0
  150. package/dist/tools/index.js +32 -0
  151. package/dist/tools/index.js.map +1 -0
  152. package/dist/tools/modelrouter/core.cjs +286 -0
  153. package/dist/tools/modelrouter/core.cjs.map +1 -0
  154. package/dist/tools/modelrouter/core.js +13 -0
  155. package/dist/tools/modelrouter/core.js.map +1 -0
  156. package/dist/tools/modelrouter/index.cjs +286 -0
  157. package/dist/tools/modelrouter/index.cjs.map +1 -0
  158. package/dist/tools/modelrouter/index.js +13 -0
  159. package/dist/tools/modelrouter/index.js.map +1 -0
  160. package/dist/tools/modelrouter/types.cjs +19 -0
  161. package/dist/tools/modelrouter/types.cjs.map +1 -0
  162. package/dist/tools/modelrouter/types.js +1 -0
  163. package/dist/tools/modelrouter/types.js.map +1 -0
  164. package/dist/tools/utils/resilience.cjs +115 -0
  165. package/dist/tools/utils/resilience.cjs.map +1 -0
  166. package/dist/tools/utils/resilience.js +12 -0
  167. package/dist/tools/utils/resilience.js.map +1 -0
  168. package/package.json +159 -0
@@ -0,0 +1,347 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // tools/fastapply/vercel.ts
21
+ var vercel_exports = {};
22
+ __export(vercel_exports, {
23
+ createEditFileTool: () => createEditFileTool,
24
+ default: () => vercel_default,
25
+ editFileTool: () => editFileTool,
26
+ getSystemPrompt: () => getSystemPrompt
27
+ });
28
+ module.exports = __toCommonJS(vercel_exports);
29
+ var import_ai = require("ai");
30
+ var import_zod = require("zod");
31
+
32
+ // tools/fastapply/core.ts
33
+ var import_promises = require("fs/promises");
34
+ var import_path = require("path");
35
+ var import_diff = require("diff");
36
+
37
+ // tools/utils/resilience.ts
38
+ var DEFAULT_RETRY_CONFIG = {
39
+ maxRetries: 3,
40
+ initialDelay: 1e3,
41
+ maxDelay: 3e4,
42
+ backoffMultiplier: 2,
43
+ retryableErrors: ["ECONNREFUSED", "ETIMEDOUT", "ENOTFOUND"]
44
+ };
45
+ async function fetchWithRetry(url, options, retryConfig = {}) {
46
+ const {
47
+ maxRetries = DEFAULT_RETRY_CONFIG.maxRetries,
48
+ initialDelay = DEFAULT_RETRY_CONFIG.initialDelay,
49
+ maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,
50
+ backoffMultiplier = DEFAULT_RETRY_CONFIG.backoffMultiplier,
51
+ retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors,
52
+ onRetry
53
+ } = retryConfig;
54
+ let lastError = null;
55
+ let delay = initialDelay;
56
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
57
+ try {
58
+ const response = await fetch(url, options);
59
+ if (response.status === 429 || response.status === 503) {
60
+ if (attempt < maxRetries) {
61
+ const retryAfter = response.headers.get("Retry-After");
62
+ const waitTime = retryAfter ? parseInt(retryAfter) * 1e3 : Math.min(delay, maxDelay);
63
+ const error = new Error(`HTTP ${response.status}: Retrying after ${waitTime}ms`);
64
+ if (onRetry) {
65
+ onRetry(attempt + 1, error);
66
+ }
67
+ await sleep(waitTime);
68
+ delay *= backoffMultiplier;
69
+ continue;
70
+ }
71
+ }
72
+ return response;
73
+ } catch (error) {
74
+ lastError = error;
75
+ const isRetryable = retryableErrors.some(
76
+ (errType) => lastError?.message?.includes(errType)
77
+ );
78
+ if (!isRetryable || attempt === maxRetries) {
79
+ throw lastError;
80
+ }
81
+ const waitTime = Math.min(delay, maxDelay);
82
+ if (onRetry) {
83
+ onRetry(attempt + 1, lastError);
84
+ }
85
+ await sleep(waitTime);
86
+ delay *= backoffMultiplier;
87
+ }
88
+ }
89
+ throw lastError || new Error("Max retries exceeded");
90
+ }
91
+ async function withTimeout(promise, timeoutMs, errorMessage) {
92
+ let timeoutId;
93
+ const timeoutPromise = new Promise((_, reject) => {
94
+ timeoutId = setTimeout(() => {
95
+ reject(new Error(errorMessage || `Operation timed out after ${timeoutMs}ms`));
96
+ }, timeoutMs);
97
+ });
98
+ try {
99
+ const result = await Promise.race([promise, timeoutPromise]);
100
+ clearTimeout(timeoutId);
101
+ return result;
102
+ } catch (error) {
103
+ clearTimeout(timeoutId);
104
+ throw error;
105
+ }
106
+ }
107
+ function sleep(ms) {
108
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
109
+ }
110
+
111
+ // tools/fastapply/core.ts
112
+ var DEFAULT_CONFIG = {
113
+ morphApiUrl: "https://api.morphllm.com",
114
+ baseDir: process.cwd(),
115
+ generateUdiff: true,
116
+ autoWrite: true,
117
+ timeout: 3e4,
118
+ debug: false
119
+ };
120
+ function generateUdiff(original, modified, filepath) {
121
+ return (0, import_diff.createTwoFilesPatch)(
122
+ filepath,
123
+ filepath,
124
+ original,
125
+ modified,
126
+ "Original",
127
+ "Modified"
128
+ );
129
+ }
130
+ function countChanges(original, modified) {
131
+ const diff = generateUdiff(original, modified, "file");
132
+ const lines = diff.split("\n");
133
+ let linesAdded = 0;
134
+ let linesRemoved = 0;
135
+ for (const line of lines) {
136
+ if (line.startsWith("+") && !line.startsWith("+++")) {
137
+ linesAdded++;
138
+ } else if (line.startsWith("-") && !line.startsWith("---")) {
139
+ linesRemoved++;
140
+ }
141
+ }
142
+ const linesModified = Math.min(linesAdded, linesRemoved);
143
+ return {
144
+ linesAdded: linesAdded - linesModified,
145
+ linesRemoved: linesRemoved - linesModified,
146
+ linesModified
147
+ };
148
+ }
149
+ async function callMorphAPI(originalCode, codeEdit, instructions, filepath, config) {
150
+ const apiKey = config.morphApiKey || process.env.MORPH_API_KEY;
151
+ const apiUrl = config.morphApiUrl || DEFAULT_CONFIG.morphApiUrl;
152
+ const timeout = config.timeout || DEFAULT_CONFIG.timeout;
153
+ const debug = config.debug || false;
154
+ if (!apiKey) {
155
+ throw new Error(
156
+ "Morph API key not found. Set MORPH_API_KEY environment variable or pass morphApiKey in config."
157
+ );
158
+ }
159
+ const message = `<instruction>${instructions}</instruction>
160
+ <code>${originalCode}</code>
161
+ <update>${codeEdit}</update>`;
162
+ if (debug) {
163
+ console.log(`[FastApply] Calling ${apiUrl}/v1/chat/completions`);
164
+ console.log(`[FastApply] File: ${filepath}, Instructions: ${instructions.slice(0, 60)}...`);
165
+ console.log(`[FastApply] Original: ${originalCode.length} chars, Edit: ${codeEdit.length} chars`);
166
+ }
167
+ const startTime = Date.now();
168
+ const fetchPromise = fetchWithRetry(
169
+ `${apiUrl}/v1/chat/completions`,
170
+ {
171
+ method: "POST",
172
+ headers: {
173
+ "Content-Type": "application/json",
174
+ "Authorization": `Bearer ${apiKey}`
175
+ },
176
+ body: JSON.stringify({
177
+ model: "morph-v3-fast",
178
+ messages: [{ role: "user", content: message }]
179
+ })
180
+ },
181
+ config.retryConfig
182
+ );
183
+ const response = await withTimeout(
184
+ fetchPromise,
185
+ timeout,
186
+ `Morph API request timed out after ${timeout}ms`
187
+ );
188
+ if (!response.ok) {
189
+ const error = await response.text();
190
+ if (debug) console.error(`[FastApply] API error: ${response.status} - ${error}`);
191
+ throw new Error(`Morph API error (${response.status}): ${error}`);
192
+ }
193
+ const data = await response.json();
194
+ const elapsed = Date.now() - startTime;
195
+ if (debug) {
196
+ console.log(`[FastApply] \u2705 Success in ${elapsed}ms, merged: ${data.choices[0].message.content.length} chars`);
197
+ }
198
+ return data.choices[0].message.content;
199
+ }
200
+ async function executeEditFile(input, config = {}) {
201
+ const baseDir = config.baseDir || DEFAULT_CONFIG.baseDir;
202
+ const fullPath = (0, import_path.resolve)((0, import_path.join)(baseDir, input.target_filepath));
203
+ const debug = config.debug || false;
204
+ const relativePath = (0, import_path.relative)(baseDir, fullPath);
205
+ if (relativePath.startsWith("..") || fullPath === baseDir) {
206
+ return {
207
+ success: false,
208
+ filepath: input.target_filepath,
209
+ changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },
210
+ error: `Invalid filepath: '${input.target_filepath}' is outside baseDir`
211
+ };
212
+ }
213
+ try {
214
+ if (debug) console.log(`[FastApply] Reading file: ${input.target_filepath}`);
215
+ const originalCode = await (0, import_promises.readFile)(fullPath, "utf-8");
216
+ const mergedCode = await callMorphAPI(originalCode, input.code_edit, input.instructions, input.target_filepath, config);
217
+ const udiff = config.generateUdiff !== false ? generateUdiff(originalCode, mergedCode, input.target_filepath) : void 0;
218
+ if (config.autoWrite !== false) {
219
+ await (0, import_promises.writeFile)(fullPath, mergedCode, "utf-8");
220
+ if (debug) console.log(`[FastApply] Wrote ${mergedCode.length} chars to ${input.target_filepath}`);
221
+ }
222
+ const changes = countChanges(originalCode, mergedCode);
223
+ return {
224
+ success: true,
225
+ filepath: input.target_filepath,
226
+ udiff,
227
+ changes
228
+ };
229
+ } catch (error) {
230
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
231
+ if (debug) console.error(`[FastApply] Error: ${errorMessage}`);
232
+ return {
233
+ success: false,
234
+ filepath: input.target_filepath,
235
+ changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },
236
+ error: errorMessage
237
+ };
238
+ }
239
+ }
240
+
241
+ // tools/fastapply/prompts.ts
242
+ var EDIT_FILE_TOOL_DESCRIPTION = `Use this tool to make an edit to an existing file.
243
+
244
+ This will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.
245
+
246
+ When writing the edit, you should specify each edit in sequence, with the special comment // ... existing code ... to represent unchanged code in between edited lines.
247
+
248
+ For example:
249
+
250
+ // ... existing code ...
251
+ FIRST_EDIT
252
+ // ... existing code ...
253
+ SECOND_EDIT
254
+ // ... existing code ...
255
+ THIRD_EDIT
256
+ // ... existing code ...
257
+
258
+ You should still bias towards repeating as few lines of the original file as possible to convey the change.
259
+ But, each edit should contain minimally sufficient context of unchanged lines around the code you're editing to resolve ambiguity.
260
+
261
+ DO NOT omit spans of pre-existing code (or comments) without using the // ... existing code ... comment to indicate its absence. If you omit the existing code comment, the model may inadvertently delete these lines.
262
+
263
+ If you plan on deleting a section, you must provide context before and after to delete it.
264
+
265
+ Make sure it is clear what the edit should be, and where it should be applied.
266
+ Make edits to a file in a single edit_file call instead of multiple edit_file calls to the same file. The apply model can handle many distinct edits at once.`;
267
+ var EDIT_FILE_SYSTEM_PROMPT = `When the user is asking for edits to their code, use the edit_file tool to highlight the changes necessary and add comments to indicate where unchanged code has been skipped. For example:
268
+
269
+ // ... existing code ...
270
+ {{ edit_1 }}
271
+ // ... existing code ...
272
+ {{ edit_2 }}
273
+ // ... existing code ...
274
+
275
+ Often this will mean that the start/end of the file will be skipped, but that's okay! Rewrite the entire file ONLY if specifically requested. Always provide a brief explanation of the updates, unless the user specifically requests only the code.
276
+
277
+ These edit codeblocks are also read by a less intelligent language model, colloquially called the apply model, to update the file. To help specify the edit to the apply model, you will be very careful when generating the codeblock to not introduce ambiguity. You will specify all unchanged regions (code and comments) of the file with "// ... existing code ..." comment markers. This will ensure the apply model will not delete existing unchanged code or comments when editing the file.`;
278
+
279
+ // tools/fastapply/vercel.ts
280
+ var editFileSchema = import_zod.z.object({
281
+ target_filepath: import_zod.z.string().describe("The path of the target file to modify"),
282
+ instructions: import_zod.z.string().describe("A single sentence describing what you are changing (first person)"),
283
+ code_edit: import_zod.z.string().describe("The lazy edit with // ... existing code ... markers")
284
+ });
285
+ var editFileTool = (0, import_ai.tool)({
286
+ description: EDIT_FILE_TOOL_DESCRIPTION,
287
+ parameters: editFileSchema,
288
+ // @ts-ignore
289
+ execute: async (params) => {
290
+ const result = await executeEditFile({
291
+ target_filepath: params.target_filepath,
292
+ instructions: params.instructions,
293
+ code_edit: params.code_edit
294
+ });
295
+ if (!result.success) {
296
+ throw new Error(`Failed to edit file: ${result.error}`);
297
+ }
298
+ return {
299
+ success: true,
300
+ filepath: result.filepath,
301
+ changes: result.changes,
302
+ udiff: result.udiff
303
+ };
304
+ }
305
+ });
306
+ function getSystemPrompt() {
307
+ return EDIT_FILE_SYSTEM_PROMPT;
308
+ }
309
+ function createEditFileTool(config = {}) {
310
+ const schema = import_zod.z.object({
311
+ target_filepath: import_zod.z.string().describe("The path of the target file to modify"),
312
+ instructions: import_zod.z.string().describe("A single sentence describing what you are changing (first person)"),
313
+ code_edit: import_zod.z.string().describe("The lazy edit with // ... existing code ... markers")
314
+ });
315
+ return (0, import_ai.tool)({
316
+ description: EDIT_FILE_TOOL_DESCRIPTION,
317
+ parameters: schema,
318
+ // @ts-ignore
319
+ execute: async (params) => {
320
+ const result = await executeEditFile(
321
+ {
322
+ target_filepath: params.target_filepath,
323
+ instructions: params.instructions,
324
+ code_edit: params.code_edit
325
+ },
326
+ config
327
+ );
328
+ if (!result.success) {
329
+ throw new Error(`Failed to edit file: ${result.error}`);
330
+ }
331
+ return {
332
+ success: true,
333
+ filepath: result.filepath,
334
+ changes: result.changes,
335
+ udiff: result.udiff
336
+ };
337
+ }
338
+ });
339
+ }
340
+ var vercel_default = editFileTool;
341
+ // Annotate the CommonJS export names for ESM import in node:
342
+ 0 && (module.exports = {
343
+ createEditFileTool,
344
+ editFileTool,
345
+ getSystemPrompt
346
+ });
347
+ //# sourceMappingURL=vercel.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../tools/fastapply/vercel.ts","../../../tools/fastapply/core.ts","../../../tools/utils/resilience.ts","../../../tools/fastapply/prompts.ts"],"sourcesContent":["/**\n * Vercel AI SDK adapter for edit_file tool\n */\n\nimport { tool } from 'ai';\nimport { z } from 'zod';\nimport { executeEditFile } from './core.js';\nimport { EDIT_FILE_TOOL_DESCRIPTION, EDIT_FILE_SYSTEM_PROMPT } from './prompts.js';\nimport type { EditFileConfig } from './types.js';\n\n/**\n * Vercel AI SDK tool for edit_file\n * \n * @example\n * ```ts\n * import { generateText } from 'ai';\n * import { anthropic } from '@ai-sdk/anthropic';\n * import { editFileTool } from 'morphsdk/tools/vercel';\n * \n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { editFile: editFileTool },\n * prompt: \"Fix the bug in app.ts\"\n * });\n * ```\n */\nconst editFileSchema = z.object({\n target_filepath: z.string().describe('The path of the target file to modify'),\n instructions: z\n .string()\n .describe('A single sentence describing what you are changing (first person)'),\n code_edit: z\n .string()\n .describe('The lazy edit with // ... existing code ... markers'),\n});\n\n// @ts-ignore - Vercel AI SDK tool() has execute runtime support but types are incomplete\nexport const editFileTool = tool({\n description: EDIT_FILE_TOOL_DESCRIPTION,\n parameters: editFileSchema,\n // @ts-ignore\n execute: async (params) => {\n const result = await executeEditFile({\n target_filepath: params.target_filepath,\n instructions: params.instructions,\n code_edit: params.code_edit,\n });\n \n if (!result.success) {\n throw new Error(`Failed to edit file: ${result.error}`);\n }\n \n return {\n success: true,\n filepath: result.filepath,\n changes: result.changes,\n udiff: result.udiff,\n };\n },\n});\n\n/**\n * Get the system prompt for edit_file usage\n * \n * Add this to your system message to guide the model on using edit_file properly.\n * \n * @example\n * ```ts\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * system: getSystemPrompt(),\n * tools: { editFile: editFileTool },\n * prompt: \"Fix bugs\"\n * });\n * ```\n */\nexport function getSystemPrompt(): string {\n return EDIT_FILE_SYSTEM_PROMPT;\n}\n\n/**\n * Create a custom edit_file tool with configuration\n * \n * @param config - Configuration options\n * @returns Vercel AI SDK tool with custom config\n * \n * @example\n * ```ts\n * const customEditTool = createEditFileTool({\n * baseDir: './src',\n * generateUdiff: true\n * });\n * \n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { editFile: customEditTool },\n * prompt: \"Fix bugs\"\n * });\n * ```\n */\nexport function createEditFileTool(config: EditFileConfig = {}) {\n const schema = z.object({\n target_filepath: z.string().describe('The path of the target file to modify'),\n instructions: z\n .string()\n .describe('A single sentence describing what you are changing (first person)'),\n code_edit: z\n .string()\n .describe('The lazy edit with // ... existing code ... markers'),\n });\n\n // @ts-ignore - Vercel AI SDK tool() has execute runtime support but types are incomplete\n return tool({\n description: EDIT_FILE_TOOL_DESCRIPTION,\n parameters: schema,\n // @ts-ignore\n execute: async (params) => {\n const result = await executeEditFile(\n {\n target_filepath: params.target_filepath,\n instructions: params.instructions,\n code_edit: params.code_edit,\n },\n config\n );\n \n if (!result.success) {\n throw new Error(`Failed to edit file: ${result.error}`);\n }\n \n return {\n success: true,\n filepath: result.filepath,\n changes: result.changes,\n udiff: result.udiff,\n };\n },\n });\n}\n\n// Default export for convenience\nexport default editFileTool;\n\n","/**\n * Core implementation of Morph Fast Apply\n */\n\nimport { readFile, writeFile } from 'fs/promises';\nimport { join, resolve, relative } from 'path';\nimport { createTwoFilesPatch } from 'diff';\nimport { fetchWithRetry, withTimeout } from '../utils/resilience.js';\nimport type {\n EditFileInput,\n EditFileResult,\n EditFileConfig,\n EditChanges,\n MorphApplyResponse,\n} from './types.js';\n\nconst DEFAULT_CONFIG: Required<Omit<EditFileConfig, 'morphApiKey' | 'systemPrompt' | 'retryConfig'>> = {\n morphApiUrl: 'https://api.morphllm.com',\n baseDir: process.cwd(),\n generateUdiff: true,\n autoWrite: true,\n timeout: 30000,\n debug: false,\n};\n\n/**\n * FastApply client for programmatic file editing\n */\nexport class FastApplyClient {\n private config: EditFileConfig;\n\n constructor(config: { apiKey?: string; debug?: boolean; timeout?: number; retryConfig?: any } = {}) {\n this.config = {\n morphApiKey: config.apiKey,\n morphApiUrl: DEFAULT_CONFIG.morphApiUrl,\n debug: config.debug,\n timeout: config.timeout || DEFAULT_CONFIG.timeout,\n retryConfig: config.retryConfig,\n generateUdiff: DEFAULT_CONFIG.generateUdiff,\n autoWrite: DEFAULT_CONFIG.autoWrite,\n };\n }\n\n /**\n * Execute a file edit operation\n * \n * @param input - Edit parameters including filepath, instructions, and code_edit\n * @param overrides - Optional config overrides for this operation\n * @returns Edit result with success status and changes\n */\n async execute(input: EditFileInput, overrides?: Partial<EditFileConfig>): Promise<EditFileResult> {\n return executeEditFile(input, { ...this.config, ...overrides });\n }\n}\n\n/**\n * Generate a unified diff between two strings\n */\nexport function generateUdiff(\n original: string,\n modified: string,\n filepath: string\n): string {\n return createTwoFilesPatch(\n filepath,\n filepath,\n original,\n modified,\n 'Original',\n 'Modified'\n );\n}\n\n/**\n * Count changes from a unified diff\n */\nexport function countChanges(original: string, modified: string): EditChanges {\n const diff = generateUdiff(original, modified, 'file');\n const lines = diff.split('\\n');\n \n let linesAdded = 0;\n let linesRemoved = 0;\n \n for (const line of lines) {\n if (line.startsWith('+') && !line.startsWith('+++')) {\n linesAdded++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n linesRemoved++;\n }\n }\n \n const linesModified = Math.min(linesAdded, linesRemoved);\n \n return {\n linesAdded: linesAdded - linesModified,\n linesRemoved: linesRemoved - linesModified,\n linesModified,\n };\n}\n\n/**\n * Call Morph Apply API to merge code edits\n * Uses OpenAI-compatible chat completions endpoint with XML-formatted message\n */\nasync function callMorphAPI(\n originalCode: string,\n codeEdit: string,\n instructions: string,\n filepath: string,\n config: EditFileConfig\n): Promise<string> {\n const apiKey = config.morphApiKey || process.env.MORPH_API_KEY;\n const apiUrl = config.morphApiUrl || DEFAULT_CONFIG.morphApiUrl;\n const timeout = config.timeout || DEFAULT_CONFIG.timeout;\n const debug = config.debug || false;\n \n if (!apiKey) {\n throw new Error(\n 'Morph API key not found. Set MORPH_API_KEY environment variable or pass morphApiKey in config.'\n );\n }\n \n // Format message with XML tags as per Morph Fast Apply spec\n const message = `<instruction>${instructions}</instruction>\\n<code>${originalCode}</code>\\n<update>${codeEdit}</update>`;\n \n if (debug) {\n console.log(`[FastApply] Calling ${apiUrl}/v1/chat/completions`);\n console.log(`[FastApply] File: ${filepath}, Instructions: ${instructions.slice(0, 60)}...`);\n console.log(`[FastApply] Original: ${originalCode.length} chars, Edit: ${codeEdit.length} chars`);\n }\n \n const startTime = Date.now();\n \n // Fetch with retry and timeout\n const fetchPromise = fetchWithRetry(\n `${apiUrl}/v1/chat/completions`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${apiKey}`,\n },\n body: JSON.stringify({\n model: 'morph-v3-fast',\n messages: [{ role: 'user', content: message }],\n }),\n },\n config.retryConfig\n );\n\n const response = await withTimeout(\n fetchPromise,\n timeout,\n `Morph API request timed out after ${timeout}ms`\n );\n \n if (!response.ok) {\n const error = await response.text();\n if (debug) console.error(`[FastApply] API error: ${response.status} - ${error}`);\n throw new Error(`Morph API error (${response.status}): ${error}`);\n }\n \n const data: MorphApplyResponse = await response.json();\n const elapsed = Date.now() - startTime;\n \n if (debug) {\n console.log(`[FastApply] ✅ Success in ${elapsed}ms, merged: ${data.choices[0].message.content.length} chars`);\n }\n \n return data.choices[0].message.content;\n}\n\n/**\n * Execute a file edit using Morph Fast Apply\n */\nexport async function executeEditFile(\n input: EditFileInput,\n config: EditFileConfig = {}\n): Promise<EditFileResult> {\n const baseDir = config.baseDir || DEFAULT_CONFIG.baseDir;\n const fullPath = resolve(join(baseDir, input.target_filepath));\n const debug = config.debug || false;\n \n // Security: ensure file is within baseDir\n const relativePath = relative(baseDir, fullPath);\n if (relativePath.startsWith('..') || fullPath === baseDir) {\n return {\n success: false,\n filepath: input.target_filepath,\n changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },\n error: `Invalid filepath: '${input.target_filepath}' is outside baseDir`,\n };\n }\n \n try {\n if (debug) console.log(`[FastApply] Reading file: ${input.target_filepath}`);\n const originalCode = await readFile(fullPath, 'utf-8');\n \n const mergedCode = await callMorphAPI(originalCode, input.code_edit, input.instructions, input.target_filepath, config);\n \n const udiff = config.generateUdiff !== false ? generateUdiff(originalCode, mergedCode, input.target_filepath) : undefined;\n \n if (config.autoWrite !== false) {\n await writeFile(fullPath, mergedCode, 'utf-8');\n if (debug) console.log(`[FastApply] Wrote ${mergedCode.length} chars to ${input.target_filepath}`);\n }\n \n const changes = countChanges(originalCode, mergedCode);\n \n return {\n success: true,\n filepath: input.target_filepath,\n udiff,\n changes,\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';\n if (debug) console.error(`[FastApply] Error: ${errorMessage}`);\n \n return {\n success: false,\n filepath: input.target_filepath,\n changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },\n error: errorMessage,\n };\n }\n}\n\n","/**\n * Resilience utilities for retry logic and timeout handling\n */\n\nexport interface RetryConfig {\n maxRetries?: number; // Default: 3\n initialDelay?: number; // Default: 1000ms\n maxDelay?: number; // Default: 30000ms\n backoffMultiplier?: number; // Default: 2\n retryableErrors?: string[]; // Default: ['ECONNREFUSED', 'ETIMEDOUT', 'ENOTFOUND']\n onRetry?: (attempt: number, error: Error) => void;\n}\n\nconst DEFAULT_RETRY_CONFIG: Required<Omit<RetryConfig, 'onRetry'>> = {\n maxRetries: 3,\n initialDelay: 1000,\n maxDelay: 30000,\n backoffMultiplier: 2,\n retryableErrors: ['ECONNREFUSED', 'ETIMEDOUT', 'ENOTFOUND'],\n};\n\n/**\n * Retry a fetch request with exponential backoff\n * \n * @param url - Request URL\n * @param options - Fetch options\n * @param retryConfig - Retry configuration\n * @returns Response from fetch\n * \n * @example\n * ```typescript\n * const response = await fetchWithRetry(\n * 'https://api.example.com/data',\n * { method: 'POST', body: JSON.stringify(data) },\n * { maxRetries: 5, initialDelay: 500 }\n * );\n * ```\n */\nexport async function fetchWithRetry(\n url: string,\n options: RequestInit,\n retryConfig: RetryConfig = {}\n): Promise<Response> {\n const {\n maxRetries = DEFAULT_RETRY_CONFIG.maxRetries,\n initialDelay = DEFAULT_RETRY_CONFIG.initialDelay,\n maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,\n backoffMultiplier = DEFAULT_RETRY_CONFIG.backoffMultiplier,\n retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors,\n onRetry,\n } = retryConfig;\n\n let lastError: Error | null = null;\n let delay = initialDelay;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n const response = await fetch(url, options);\n \n // Retry on 429 (rate limit) or 503 (service unavailable)\n if (response.status === 429 || response.status === 503) {\n if (attempt < maxRetries) {\n // Check for Retry-After header\n const retryAfter = response.headers.get('Retry-After');\n const waitTime = retryAfter \n ? parseInt(retryAfter) * 1000 \n : Math.min(delay, maxDelay);\n \n const error = new Error(`HTTP ${response.status}: Retrying after ${waitTime}ms`);\n if (onRetry) {\n onRetry(attempt + 1, error);\n }\n \n await sleep(waitTime);\n delay *= backoffMultiplier;\n continue;\n }\n }\n\n return response;\n } catch (error) {\n lastError = error as Error;\n \n // Check if error is retryable\n const isRetryable = retryableErrors.some(errType => \n lastError?.message?.includes(errType)\n );\n\n if (!isRetryable || attempt === maxRetries) {\n throw lastError;\n }\n\n // Exponential backoff\n const waitTime = Math.min(delay, maxDelay);\n if (onRetry) {\n onRetry(attempt + 1, lastError);\n }\n \n await sleep(waitTime);\n delay *= backoffMultiplier;\n }\n }\n\n throw lastError || new Error('Max retries exceeded');\n}\n\n/**\n * Add timeout to any promise\n * \n * @param promise - Promise to wrap with timeout\n * @param timeoutMs - Timeout in milliseconds\n * @param errorMessage - Optional custom error message\n * @returns Promise that rejects if timeout is reached\n * \n * @example\n * ```typescript\n * const result = await withTimeout(\n * fetchData(),\n * 5000,\n * 'Data fetch timed out'\n * );\n * ```\n */\nexport async function withTimeout<T>(\n promise: Promise<T>,\n timeoutMs: number,\n errorMessage?: string\n): Promise<T> {\n let timeoutId: NodeJS.Timeout | number;\n \n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => {\n reject(new Error(errorMessage || `Operation timed out after ${timeoutMs}ms`));\n }, timeoutMs);\n });\n\n try {\n const result = await Promise.race([promise, timeoutPromise]);\n clearTimeout(timeoutId!);\n return result;\n } catch (error) {\n clearTimeout(timeoutId!);\n throw error;\n }\n}\n\n/**\n * Sleep for specified milliseconds\n */\nfunction sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n/**\n * Unified error type for all tools\n */\nexport class MorphError extends Error {\n constructor(\n message: string,\n public code: string,\n public statusCode?: number,\n public retryable: boolean = false\n ) {\n super(message);\n this.name = 'MorphError';\n }\n}\n\n\n","/**\n * System prompts for edit_file tool\n */\n\nexport const EDIT_FILE_TOOL_DESCRIPTION = `Use this tool to make an edit to an existing file.\n\nThis will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.\n\nWhen writing the edit, you should specify each edit in sequence, with the special comment // ... existing code ... to represent unchanged code in between edited lines.\n\nFor example:\n\n// ... existing code ...\nFIRST_EDIT\n// ... existing code ...\nSECOND_EDIT\n// ... existing code ...\nTHIRD_EDIT\n// ... existing code ...\n\nYou should still bias towards repeating as few lines of the original file as possible to convey the change.\nBut, each edit should contain minimally sufficient context of unchanged lines around the code you're editing to resolve ambiguity.\n\nDO NOT omit spans of pre-existing code (or comments) without using the // ... existing code ... comment to indicate its absence. If you omit the existing code comment, the model may inadvertently delete these lines.\n\nIf you plan on deleting a section, you must provide context before and after to delete it.\n\nMake sure it is clear what the edit should be, and where it should be applied.\nMake edits to a file in a single edit_file call instead of multiple edit_file calls to the same file. The apply model can handle many distinct edits at once.`;\n\nexport const EDIT_FILE_SYSTEM_PROMPT = `When the user is asking for edits to their code, use the edit_file tool to highlight the changes necessary and add comments to indicate where unchanged code has been skipped. For example:\n\n// ... existing code ...\n{{ edit_1 }}\n// ... existing code ...\n{{ edit_2 }}\n// ... existing code ...\n\nOften this will mean that the start/end of the file will be skipped, but that's okay! Rewrite the entire file ONLY if specifically requested. Always provide a brief explanation of the updates, unless the user specifically requests only the code.\n\nThese edit codeblocks are also read by a less intelligent language model, colloquially called the apply model, to update the file. To help specify the edit to the apply model, you will be very careful when generating the codeblock to not introduce ambiguity. You will specify all unchanged regions (code and comments) of the file with \"// ... existing code ...\" comment markers. This will ensure the apply model will not delete existing unchanged code or comments when editing the file.`;\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,gBAAqB;AACrB,iBAAkB;;;ACDlB,sBAAoC;AACpC,kBAAwC;AACxC,kBAAoC;;;ACOpC,IAAM,uBAA+D;AAAA,EACnE,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,iBAAiB,CAAC,gBAAgB,aAAa,WAAW;AAC5D;AAmBA,eAAsB,eACpB,KACA,SACA,cAA2B,CAAC,GACT;AACnB,QAAM;AAAA,IACJ,aAAa,qBAAqB;AAAA,IAClC,eAAe,qBAAqB;AAAA,IACpC,WAAW,qBAAqB;AAAA,IAChC,oBAAoB,qBAAqB;AAAA,IACzC,kBAAkB,qBAAqB;AAAA,IACvC;AAAA,EACF,IAAI;AAEJ,MAAI,YAA0B;AAC9B,MAAI,QAAQ;AAEZ,WAAS,UAAU,GAAG,WAAW,YAAY,WAAW;AACtD,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,KAAK,OAAO;AAGzC,UAAI,SAAS,WAAW,OAAO,SAAS,WAAW,KAAK;AACtD,YAAI,UAAU,YAAY;AAExB,gBAAM,aAAa,SAAS,QAAQ,IAAI,aAAa;AACrD,gBAAM,WAAW,aACb,SAAS,UAAU,IAAI,MACvB,KAAK,IAAI,OAAO,QAAQ;AAE5B,gBAAM,QAAQ,IAAI,MAAM,QAAQ,SAAS,MAAM,oBAAoB,QAAQ,IAAI;AAC/E,cAAI,SAAS;AACX,oBAAQ,UAAU,GAAG,KAAK;AAAA,UAC5B;AAEA,gBAAM,MAAM,QAAQ;AACpB,mBAAS;AACT;AAAA,QACF;AAAA,MACF;AAEA,aAAO;AAAA,IACT,SAAS,OAAO;AACd,kBA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AO;AAAA,MACxB,cAAc,OAAO;AAAA,MACrB,WAAW,OAAO;AAAA,IACpB,CAAC;AAED,QAAI,CAAC,OAAO,SAAS;AACnB,YAAM,IAAI,MAAM,wBAAwB,OAAO,KAAK,EAAE;AAAA,IACxD;AAEA,WAAO;AAAA,MACL,SAAS;AAAA,MACT,UAAU,OAAO;AAAA,MACjB,SAAS,OAAO;AAAA,MAChB,OAAO,OAAO;AAAA,IAChB;AAAA,EACF;AACF,CAAC;AAiBM,SAAS,kBAA0B;AACxC,SAAO;AACT;AAsBO,SAAS,mBAAmB,SAAyB,CAAC,GAAG;AAC9D,QAAM,SAAS,aAAE,OAAO;AAAA,IACtB,iBAAiB,aAAE,OAAO,EAAE,SAAS,uCAAuC;AAAA,IAC5E,cAAc,aACX,OAAO,EACP,SAAS,mEAAmE;AAAA,IAC/E,WAAW,aACR,OAAO,EACP,SAAS,qDAAqD;AAAA,EACnE,CAAC;AAGD,aAAO,gBAAK;AAAA,IACV,aAAa;AAAA,IACb,YAAY;AAAA;AAAA,IAEZ,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM;AAAA,QACnB;AAAA,UACE,iBAAiB,OAAO;AAAA,UACxB,cAAc,OAAO;AAAA,UACrB,WAAW,OAAO;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,IAAI,MAAM,wBAAwB,OAAO,KAAK,EAAE;AAAA,MACxD;AAEA,aAAO;AAAA,QACL,SAAS;AAAA,QACT,UAAU,OAAO;AAAA,QACjB,SAAS,OAAO;AAAA,QAChB,OAAO,OAAO;AAAA,MAChB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAGA,IAAO,iBAAQ;","names":["resolve"]}
@@ -0,0 +1,17 @@
1
+ import {
2
+ createEditFileTool,
3
+ editFileTool,
4
+ getSystemPrompt,
5
+ vercel_default
6
+ } from "../../chunk-5COKN3XD.js";
7
+ import "../../chunk-63WE2C5R.js";
8
+ import "../../chunk-4V46N27D.js";
9
+ import "../../chunk-4VWJFZVS.js";
10
+ import "../../chunk-PZ5AY32C.js";
11
+ export {
12
+ createEditFileTool,
13
+ vercel_default as default,
14
+ editFileTool,
15
+ getSystemPrompt
16
+ };
17
+ //# sourceMappingURL=vercel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}