@morphllm/morphsdk 0.2.80 → 0.2.81

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 (58) hide show
  1. package/dist/{chunk-DCIUCDWJ.js → chunk-467MCW5R.js} +38 -10
  2. package/dist/chunk-467MCW5R.js.map +1 -0
  3. package/dist/{chunk-HBIDSKIQ.js → chunk-4NI25AKV.js} +14 -6
  4. package/dist/chunk-4NI25AKV.js.map +1 -0
  5. package/dist/{chunk-5PGRBWJX.js → chunk-4VMIPD4G.js} +4 -4
  6. package/dist/{chunk-6OII5QOW.js → chunk-B3UC7UVA.js} +3 -3
  7. package/dist/{chunk-6OII5QOW.js.map → chunk-B3UC7UVA.js.map} +1 -1
  8. package/dist/{chunk-QL5SMQ73.js → chunk-NTTQJM6O.js} +2 -2
  9. package/dist/{chunk-ND7IFSMR.js → chunk-OFMDENAQ.js} +2 -2
  10. package/dist/{chunk-26QXQFLZ.js → chunk-PHJQ4N3T.js} +8 -3
  11. package/dist/chunk-PHJQ4N3T.js.map +1 -0
  12. package/dist/{chunk-LM62QCGS.js → chunk-X6A64F2F.js} +5 -5
  13. package/dist/{chunk-4R3ALD5C.js → chunk-Z2HDXUH7.js} +2 -2
  14. package/dist/client.cjs +54 -12
  15. package/dist/client.cjs.map +1 -1
  16. package/dist/client.js +9 -9
  17. package/dist/index.cjs +54 -12
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.js +9 -9
  20. package/dist/tools/warp_grep/agent/runner.cjs +34 -5
  21. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  22. package/dist/tools/warp_grep/agent/runner.js +2 -2
  23. package/dist/tools/warp_grep/anthropic.cjs +54 -12
  24. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  25. package/dist/tools/warp_grep/anthropic.js +6 -6
  26. package/dist/tools/warp_grep/client.cjs +54 -12
  27. package/dist/tools/warp_grep/client.cjs.map +1 -1
  28. package/dist/tools/warp_grep/client.js +5 -5
  29. package/dist/tools/warp_grep/gemini.cjs +54 -12
  30. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  31. package/dist/tools/warp_grep/gemini.js +5 -5
  32. package/dist/tools/warp_grep/harness.cjs +50 -14
  33. package/dist/tools/warp_grep/harness.cjs.map +1 -1
  34. package/dist/tools/warp_grep/harness.js +2 -2
  35. package/dist/tools/warp_grep/index.cjs +58 -17
  36. package/dist/tools/warp_grep/index.cjs.map +1 -1
  37. package/dist/tools/warp_grep/index.js +5 -5
  38. package/dist/tools/warp_grep/openai.cjs +54 -12
  39. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  40. package/dist/tools/warp_grep/openai.js +6 -6
  41. package/dist/tools/warp_grep/providers/local.cjs +13 -5
  42. package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
  43. package/dist/tools/warp_grep/providers/local.js +1 -1
  44. package/dist/tools/warp_grep/providers/remote.cjs +7 -2
  45. package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
  46. package/dist/tools/warp_grep/providers/remote.js +1 -1
  47. package/dist/tools/warp_grep/vercel.cjs +54 -12
  48. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  49. package/dist/tools/warp_grep/vercel.js +6 -6
  50. package/package.json +1 -1
  51. package/dist/chunk-26QXQFLZ.js.map +0 -1
  52. package/dist/chunk-DCIUCDWJ.js.map +0 -1
  53. package/dist/chunk-HBIDSKIQ.js.map +0 -1
  54. /package/dist/{chunk-5PGRBWJX.js.map → chunk-4VMIPD4G.js.map} +0 -0
  55. /package/dist/{chunk-QL5SMQ73.js.map → chunk-NTTQJM6O.js.map} +0 -0
  56. /package/dist/{chunk-ND7IFSMR.js.map → chunk-OFMDENAQ.js.map} +0 -0
  57. /package/dist/{chunk-LM62QCGS.js.map → chunk-X6A64F2F.js.map} +0 -0
  58. /package/dist/{chunk-4R3ALD5C.js.map → chunk-Z2HDXUH7.js.map} +0 -0
@@ -621,10 +621,25 @@ async function toolGrep(provider, args) {
621
621
  }
622
622
 
623
623
  // tools/warp_grep/agent/tools/read.ts
624
+ function isValidRange(start, end) {
625
+ return typeof start === "number" && typeof end === "number" && Number.isFinite(start) && Number.isFinite(end) && start > 0 && end >= start;
626
+ }
624
627
  async function toolRead(provider, args) {
625
- if (args.lines && args.lines.length > 0) {
628
+ if (args.lines && Array.isArray(args.lines) && args.lines.length > 0) {
629
+ const validRanges = [];
630
+ for (const range of args.lines) {
631
+ if (Array.isArray(range) && range.length >= 2 && isValidRange(range[0], range[1])) {
632
+ validRanges.push([range[0], range[1]]);
633
+ }
634
+ }
635
+ if (validRanges.length === 0) {
636
+ const res2 = await provider.read({ path: args.path });
637
+ if (res2.error) return res2.error;
638
+ if (!res2.lines.length) return "(empty file)";
639
+ return res2.lines.join("\n");
640
+ }
626
641
  const chunks = [];
627
- for (const [start, end] of args.lines) {
642
+ for (const [start, end] of validRanges) {
628
643
  const res2 = await provider.read({ path: args.path, start, end });
629
644
  if (res2.error) return res2.error;
630
645
  chunks.push(res2.lines.join("\n"));
@@ -660,23 +675,36 @@ async function toolListDirectory(provider, args) {
660
675
  }
661
676
 
662
677
  // tools/warp_grep/agent/tools/finish.ts
678
+ function isValidRange2(range) {
679
+ return Array.isArray(range) && range.length >= 2 && typeof range[0] === "number" && typeof range[1] === "number" && Number.isFinite(range[0]) && Number.isFinite(range[1]) && range[0] > 0 && range[1] >= range[0];
680
+ }
681
+ function extractValidRanges(lines) {
682
+ if (!Array.isArray(lines)) return null;
683
+ const valid = [];
684
+ for (const range of lines) {
685
+ if (isValidRange2(range)) {
686
+ valid.push([range[0], range[1]]);
687
+ }
688
+ }
689
+ return valid.length > 0 ? valid : null;
690
+ }
663
691
  function normalizeFinishFiles(files) {
664
692
  return files.map((f) => {
665
- if (f.lines === "*") {
666
- return { path: f.path, lines: "*" };
667
- }
668
- const merged = mergeRanges(f.lines);
669
- return { path: f.path, lines: merged };
693
+ if (f.lines === "*") return { path: f.path, lines: "*" };
694
+ const validRanges = extractValidRanges(f.lines);
695
+ if (!validRanges) return { path: f.path, lines: "*" };
696
+ return { path: f.path, lines: mergeRanges(validRanges) };
670
697
  });
671
698
  }
672
699
  async function readFinishFiles(repoRoot, files, reader) {
673
700
  const out = [];
674
701
  for (const f of files) {
675
- if (f.lines === "*") {
702
+ const validRanges = f.lines === "*" ? null : extractValidRanges(f.lines);
703
+ if (f.lines === "*" || !validRanges) {
676
704
  const lines = await reader(f.path);
677
705
  out.push({ path: f.path, ranges: "*", content: lines.join("\n") });
678
706
  } else {
679
- const ranges = mergeRanges(f.lines);
707
+ const ranges = mergeRanges(validRanges);
680
708
  const chunks = [];
681
709
  for (const [s, e] of ranges) {
682
710
  const lines = await reader(f.path, s, e);
@@ -1084,7 +1112,7 @@ async function runWarpGrep(config) {
1084
1112
  }
1085
1113
  const parts = ["Relevant context found:"];
1086
1114
  for (const f of finishMeta.files) {
1087
- const ranges = f.lines === "*" ? "*" : f.lines.map(([s, e]) => `${s}-${e}`).join(", ");
1115
+ const ranges = f.lines === "*" ? "*" : Array.isArray(f.lines) ? f.lines.map(([s, e]) => `${s}-${e}`).join(", ") : "*";
1088
1116
  parts.push(`- ${f.path}: ${ranges}`);
1089
1117
  }
1090
1118
  const payload = parts.join("\n");
@@ -1444,11 +1472,19 @@ Details: ${res.stderr}` : ""}`
1444
1472
  };
1445
1473
  }
1446
1474
  const total = lines.length;
1447
- let s = params.start ?? 1;
1448
- let e = Math.min(params.end ?? total, total);
1449
- if (s > total && total > 0) {
1450
- s = 1;
1451
- e = total;
1475
+ const rawStart = params.start;
1476
+ const rawEnd = params.end;
1477
+ let s = 1;
1478
+ let e = total;
1479
+ const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
1480
+ const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
1481
+ if (startValid && endValid) {
1482
+ s = rawStart ?? 1;
1483
+ e = Math.min(rawEnd ?? total, total);
1484
+ if (s > total && total > 0 || s > e) {
1485
+ s = 1;
1486
+ e = total;
1487
+ }
1452
1488
  }
1453
1489
  const out = [];
1454
1490
  for (let i = s; i <= e; i += 1) {
@@ -1624,8 +1660,13 @@ var RemoteCommandsProvider = class {
1624
1660
  * Read file and add line numbers
1625
1661
  */
1626
1662
  async read(params) {
1627
- const start = params.start ?? 1;
1628
- const end = params.end ?? 1e6;
1663
+ const rawStart = params.start;
1664
+ const rawEnd = params.end;
1665
+ const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
1666
+ const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
1667
+ const rangeValid = startValid && endValid && (rawStart === void 0 || rawEnd === void 0 || rawStart <= rawEnd);
1668
+ const start = rangeValid && rawStart !== void 0 ? rawStart : 1;
1669
+ const end = rangeValid && rawEnd !== void 0 ? rawEnd : 1e6;
1629
1670
  try {
1630
1671
  const stdout = await this.commands.read(params.path, start, end);
1631
1672
  const contentLines = (stdout || "").split("\n");