@morphllm/morphsdk 0.2.52 → 0.2.53

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 (64) hide show
  1. package/dist/{chunk-UU6XCZG3.js → chunk-2XNF3W7C.js} +3 -3
  2. package/dist/{chunk-FYQUSDOE.js → chunk-563REN2T.js} +3 -3
  3. package/dist/{chunk-G4AWE5A2.js → chunk-5QIWYEHJ.js} +2 -2
  4. package/dist/{chunk-YR53PPVM.js → chunk-C4IXE2RM.js} +3 -3
  5. package/dist/{chunk-64PMM72R.js → chunk-CKTA4AXM.js} +58 -2
  6. package/dist/chunk-CKTA4AXM.js.map +1 -0
  7. package/dist/{chunk-L5BMGLLQ.js → chunk-IFVROB4L.js} +21 -14
  8. package/dist/{chunk-L5BMGLLQ.js.map → chunk-IFVROB4L.js.map} +1 -1
  9. package/dist/{chunk-3FTAIJBH.js → chunk-IUG2FHNN.js} +2 -2
  10. package/dist/{chunk-MZT6HVGD.js → chunk-KYVR4QCG.js} +3 -3
  11. package/dist/{chunk-MZT6HVGD.js.map → chunk-KYVR4QCG.js.map} +1 -1
  12. package/dist/{chunk-PZDR5ZZ2.js → chunk-NOQCKVY3.js} +9 -9
  13. package/dist/{chunk-UIZT3KVJ.js → chunk-QZNGKOCZ.js} +2 -2
  14. package/dist/client.cjs +64 -2
  15. package/dist/client.cjs.map +1 -1
  16. package/dist/client.js +15 -15
  17. package/dist/index.cjs +68 -4
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +6 -5
  20. package/dist/index.js +19 -17
  21. package/dist/tools/fastapply/anthropic.cjs.map +1 -1
  22. package/dist/tools/fastapply/anthropic.js +2 -2
  23. package/dist/tools/fastapply/core.cjs +57 -0
  24. package/dist/tools/fastapply/core.cjs.map +1 -1
  25. package/dist/tools/fastapply/core.d.ts +50 -2
  26. package/dist/tools/fastapply/core.js +3 -1
  27. package/dist/tools/fastapply/index.cjs +34 -0
  28. package/dist/tools/fastapply/index.cjs.map +1 -1
  29. package/dist/tools/fastapply/index.d.ts +2 -2
  30. package/dist/tools/fastapply/index.js +6 -4
  31. package/dist/tools/fastapply/openai.cjs.map +1 -1
  32. package/dist/tools/fastapply/openai.js +2 -2
  33. package/dist/tools/fastapply/types.cjs.map +1 -1
  34. package/dist/tools/fastapply/types.d.ts +47 -1
  35. package/dist/tools/fastapply/vercel.cjs.map +1 -1
  36. package/dist/tools/fastapply/vercel.js +2 -2
  37. package/dist/tools/index.cjs +34 -0
  38. package/dist/tools/index.cjs.map +1 -1
  39. package/dist/tools/index.d.ts +2 -2
  40. package/dist/tools/index.js +6 -4
  41. package/dist/tools/warp_grep/agent/runner.cjs +8 -1
  42. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  43. package/dist/tools/warp_grep/agent/runner.js +6 -6
  44. package/dist/tools/warp_grep/anthropic.cjs +9 -2
  45. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  46. package/dist/tools/warp_grep/anthropic.js +8 -8
  47. package/dist/tools/warp_grep/index.cjs +9 -2
  48. package/dist/tools/warp_grep/index.cjs.map +1 -1
  49. package/dist/tools/warp_grep/index.js +10 -10
  50. package/dist/tools/warp_grep/openai.cjs +9 -2
  51. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  52. package/dist/tools/warp_grep/openai.js +8 -8
  53. package/dist/tools/warp_grep/vercel.cjs +9 -2
  54. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  55. package/dist/tools/warp_grep/vercel.js +8 -8
  56. package/package.json +1 -1
  57. package/dist/chunk-64PMM72R.js.map +0 -1
  58. /package/dist/{chunk-UU6XCZG3.js.map → chunk-2XNF3W7C.js.map} +0 -0
  59. /package/dist/{chunk-FYQUSDOE.js.map → chunk-563REN2T.js.map} +0 -0
  60. /package/dist/{chunk-G4AWE5A2.js.map → chunk-5QIWYEHJ.js.map} +0 -0
  61. /package/dist/{chunk-YR53PPVM.js.map → chunk-C4IXE2RM.js.map} +0 -0
  62. /package/dist/{chunk-3FTAIJBH.js.map → chunk-IUG2FHNN.js.map} +0 -0
  63. /package/dist/{chunk-PZDR5ZZ2.js.map → chunk-NOQCKVY3.js.map} +0 -0
  64. /package/dist/{chunk-UIZT3KVJ.js.map → chunk-QZNGKOCZ.js.map} +0 -0
package/dist/client.js CHANGED
@@ -1,32 +1,32 @@
1
1
  import {
2
2
  MorphClient
3
- } from "./chunk-PZDR5ZZ2.js";
4
- import "./chunk-YR53PPVM.js";
5
- import "./chunk-UU6XCZG3.js";
6
- import "./chunk-FYQUSDOE.js";
7
- import "./chunk-MZT6HVGD.js";
8
- import "./chunk-L5BMGLLQ.js";
9
- import "./chunk-TICMYDII.js";
10
- import "./chunk-NDZO5IPV.js";
3
+ } from "./chunk-NOQCKVY3.js";
4
+ import "./chunk-C4IXE2RM.js";
5
+ import "./chunk-2XNF3W7C.js";
6
+ import "./chunk-563REN2T.js";
7
+ import "./chunk-KYVR4QCG.js";
8
+ import "./chunk-IFVROB4L.js";
9
+ import "./chunk-EK7OQPWD.js";
10
+ import "./chunk-HQO45BAJ.js";
11
11
  import "./chunk-LVPVVLTI.js";
12
12
  import "./chunk-WETRQJGU.js";
13
- import "./chunk-HQO45BAJ.js";
14
13
  import "./chunk-ZJIIICRA.js";
15
14
  import "./chunk-G2RSY56Q.js";
16
15
  import "./chunk-SMGZ6A64.js";
17
16
  import "./chunk-TPP2UGQP.js";
18
- import "./chunk-TJIUA27P.js";
19
17
  import "./chunk-73RQWOQC.js";
20
- import "./chunk-EK7OQPWD.js";
18
+ import "./chunk-TJIUA27P.js";
19
+ import "./chunk-TICMYDII.js";
20
+ import "./chunk-NDZO5IPV.js";
21
21
  import "./chunk-UBX7QYBD.js";
22
22
  import "./chunk-GJU7UOFL.js";
23
23
  import "./chunk-76DJEQEP.js";
24
24
  import "./chunk-WM77HRKO.js";
25
25
  import "./chunk-YQMPVJ2L.js";
26
- import "./chunk-3FTAIJBH.js";
27
- import "./chunk-G4AWE5A2.js";
28
- import "./chunk-UIZT3KVJ.js";
29
- import "./chunk-64PMM72R.js";
26
+ import "./chunk-IUG2FHNN.js";
27
+ import "./chunk-5QIWYEHJ.js";
28
+ import "./chunk-QZNGKOCZ.js";
29
+ import "./chunk-CKTA4AXM.js";
30
30
  import "./chunk-63WE2C5R.js";
31
31
  import "./chunk-LVY5LPEX.js";
32
32
  import "./chunk-SQN4DUQS.js";
package/dist/index.cjs CHANGED
@@ -44,7 +44,8 @@ __export(index_exports, {
44
44
  OpenAIToolFactory: () => OpenAIToolFactory,
45
45
  RawRouter: () => RawRouter,
46
46
  VercelToolFactory: () => VercelToolFactory,
47
- WarpGrepClient: () => WarpGrepClient
47
+ WarpGrepClient: () => WarpGrepClient,
48
+ applyEdit: () => applyEdit
48
49
  });
49
50
  module.exports = __toCommonJS(index_exports);
50
51
 
@@ -159,6 +160,29 @@ var FastApplyClient = class {
159
160
  async execute(input, overrides) {
160
161
  return executeEditFile(input, { ...this.config, ...overrides });
161
162
  }
163
+ /**
164
+ * Apply an edit to code directly without file I/O
165
+ *
166
+ * Useful for sandbox environments or when you manage your own file system.
167
+ * Compatible with the earlier OpenAI client API contract.
168
+ *
169
+ * @param input - Code and edit parameters
170
+ * @param overrides - Optional config overrides for this operation
171
+ * @returns Result with merged code
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * const result = await client.applyEdit({
176
+ * originalCode: 'function hello() { return "world"; }',
177
+ * codeEdit: 'function hello() { return "universe"; }',
178
+ * instructions: 'Change return value'
179
+ * });
180
+ * console.log(result.mergedCode);
181
+ * ```
182
+ */
183
+ async applyEdit(input, overrides) {
184
+ return applyEdit(input, { ...this.config, ...overrides });
185
+ }
162
186
  };
163
187
  function generateUdiff(original, modified, filepath) {
164
188
  return (0, import_diff.createTwoFilesPatch)(
@@ -288,6 +312,38 @@ async function executeEditFile(input, config = {}) {
288
312
  };
289
313
  }
290
314
  }
315
+ async function applyEdit(input, config = {}) {
316
+ const debug = config.debug || false;
317
+ const filepath = input.filepath || "file";
318
+ try {
319
+ if (debug) {
320
+ console.log(`[FastApply] Applying edit to code (${input.originalCode.length} chars)`);
321
+ }
322
+ const mergedCode = await callMorphAPI(
323
+ input.originalCode,
324
+ input.codeEdit,
325
+ input.instructions,
326
+ filepath,
327
+ config
328
+ );
329
+ const udiff = config.generateUdiff !== false ? generateUdiff(input.originalCode, mergedCode, filepath) : void 0;
330
+ const changes = countChanges(input.originalCode, mergedCode);
331
+ return {
332
+ success: true,
333
+ mergedCode,
334
+ udiff,
335
+ changes
336
+ };
337
+ } catch (error) {
338
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
339
+ if (debug) console.error(`[FastApply] Error: ${errorMessage}`);
340
+ return {
341
+ success: false,
342
+ changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },
343
+ error: errorMessage
344
+ };
345
+ }
346
+ }
291
347
 
292
348
  // tools/codebase_search/core.ts
293
349
  var CodebaseSearchClient = class {
@@ -1722,6 +1778,7 @@ async function runWarpGrep(config) {
1722
1778
  parts.push(`- ${f.path}: ${ranges}`);
1723
1779
  }
1724
1780
  const payload = parts.join("\n");
1781
+ const fileReadErrors = [];
1725
1782
  const resolved = await readFinishFiles(
1726
1783
  repoRoot,
1727
1784
  finishMeta.files,
@@ -1732,11 +1789,17 @@ async function runWarpGrep(config) {
1732
1789
  const idx = l.indexOf("|");
1733
1790
  return idx >= 0 ? l.slice(idx + 1) : l;
1734
1791
  });
1735
- } catch {
1792
+ } catch (err) {
1793
+ const errorMsg = err instanceof Error ? err.message : String(err);
1794
+ fileReadErrors.push({ path: p, error: errorMsg });
1795
+ console.error(`[warp_grep] Failed to read file: ${p} - ${errorMsg}`);
1736
1796
  return [`[couldn't find: ${p}]`];
1737
1797
  }
1738
1798
  }
1739
1799
  );
1800
+ if (fileReadErrors.length > 0) {
1801
+ errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
1802
+ }
1740
1803
  return {
1741
1804
  terminationReason: "completed",
1742
1805
  messages,
@@ -2826,7 +2889,7 @@ var RawRouter = class extends BaseRouter {
2826
2889
  };
2827
2890
 
2828
2891
  // tools/warp_grep/prompts.ts
2829
- var WARP_GREP_DESCRIPTION = "A fast and accurate tool that can search for all relevant context in a codebase. You must use this tool to save time and avoid context pollution.";
2892
+ var WARP_GREP_DESCRIPTION = "ALWAYS use Warp Grep when you need to search a large chunk of code. Warp Grep is a fast and accurate tool that can search for all relevant context in a codebase. Warp Grep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type ";
2830
2893
 
2831
2894
  // tools/warp_grep/openai.ts
2832
2895
  var TOOL_PARAMETERS = {
@@ -3715,6 +3778,7 @@ var CommandExecProvider = class {
3715
3778
  OpenAIToolFactory,
3716
3779
  RawRouter,
3717
3780
  VercelToolFactory,
3718
- WarpGrepClient
3781
+ WarpGrepClient,
3782
+ applyEdit
3719
3783
  });
3720
3784
  //# sourceMappingURL=index.cjs.map