@morphllm/morphsdk 0.2.80 → 0.2.82

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 (80) hide show
  1. package/dist/{chunk-QL5SMQ73.js → chunk-24EYSWME.js} +2 -2
  2. package/dist/{chunk-ND7IFSMR.js → chunk-3ONNAQZU.js} +2 -2
  3. package/dist/{chunk-HBIDSKIQ.js → chunk-4KMBU6T3.js} +15 -7
  4. package/dist/chunk-4KMBU6T3.js.map +1 -0
  5. package/dist/{chunk-XT5ZO6ES.js → chunk-5PNMAWLC.js} +8 -2
  6. package/dist/chunk-5PNMAWLC.js.map +1 -0
  7. package/dist/{chunk-LM62QCGS.js → chunk-EK5ZEOI3.js} +5 -5
  8. package/dist/{chunk-5PGRBWJX.js → chunk-FJKPMMNQ.js} +8 -6
  9. package/dist/chunk-FJKPMMNQ.js.map +1 -0
  10. package/dist/{chunk-DCIUCDWJ.js → chunk-P2O5JKE5.js} +39 -11
  11. package/dist/chunk-P2O5JKE5.js.map +1 -0
  12. package/dist/{chunk-26QXQFLZ.js → chunk-PUGSTXLO.js} +9 -4
  13. package/dist/chunk-PUGSTXLO.js.map +1 -0
  14. package/dist/{chunk-6OII5QOW.js → chunk-WIAYUEJK.js} +8 -6
  15. package/dist/chunk-WIAYUEJK.js.map +1 -0
  16. package/dist/{chunk-4R3ALD5C.js → chunk-ZLJAODDJ.js} +2 -2
  17. package/dist/{client-CSINf0lQ.d.ts → client-CsO9LifG.d.ts} +1 -1
  18. package/dist/client.cjs +69 -17
  19. package/dist/client.cjs.map +1 -1
  20. package/dist/client.d.ts +2 -2
  21. package/dist/client.js +10 -10
  22. package/dist/index.cjs +69 -17
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.js +10 -10
  26. package/dist/tools/warp_grep/agent/config.cjs +7 -1
  27. package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
  28. package/dist/tools/warp_grep/agent/config.d.ts +1 -0
  29. package/dist/tools/warp_grep/agent/config.js +1 -1
  30. package/dist/tools/warp_grep/agent/runner.cjs +45 -8
  31. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  32. package/dist/tools/warp_grep/agent/runner.js +3 -3
  33. package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
  34. package/dist/tools/warp_grep/agent/types.d.ts +2 -0
  35. package/dist/tools/warp_grep/anthropic.cjs +67 -16
  36. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  37. package/dist/tools/warp_grep/anthropic.d.ts +1 -1
  38. package/dist/tools/warp_grep/anthropic.js +7 -7
  39. package/dist/tools/warp_grep/client.cjs +69 -17
  40. package/dist/tools/warp_grep/client.cjs.map +1 -1
  41. package/dist/tools/warp_grep/client.d.ts +1 -1
  42. package/dist/tools/warp_grep/client.js +6 -6
  43. package/dist/tools/warp_grep/gemini.cjs +67 -16
  44. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  45. package/dist/tools/warp_grep/gemini.d.ts +1 -1
  46. package/dist/tools/warp_grep/gemini.js +6 -6
  47. package/dist/tools/warp_grep/harness.cjs +57 -15
  48. package/dist/tools/warp_grep/harness.cjs.map +1 -1
  49. package/dist/tools/warp_grep/harness.js +3 -3
  50. package/dist/tools/warp_grep/index.cjs +73 -22
  51. package/dist/tools/warp_grep/index.cjs.map +1 -1
  52. package/dist/tools/warp_grep/index.d.ts +1 -1
  53. package/dist/tools/warp_grep/index.js +6 -6
  54. package/dist/tools/warp_grep/openai.cjs +67 -16
  55. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  56. package/dist/tools/warp_grep/openai.d.ts +1 -1
  57. package/dist/tools/warp_grep/openai.js +7 -7
  58. package/dist/tools/warp_grep/providers/local.cjs +20 -6
  59. package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
  60. package/dist/tools/warp_grep/providers/local.js +2 -2
  61. package/dist/tools/warp_grep/providers/remote.cjs +14 -3
  62. package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
  63. package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
  64. package/dist/tools/warp_grep/providers/remote.js +2 -2
  65. package/dist/tools/warp_grep/vercel.cjs +67 -16
  66. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  67. package/dist/tools/warp_grep/vercel.d.ts +1 -1
  68. package/dist/tools/warp_grep/vercel.js +7 -7
  69. package/dist/{types-CnvVDM63.d.ts → types-Cv4LpqVl.d.ts} +2 -0
  70. package/package.json +1 -1
  71. package/dist/chunk-26QXQFLZ.js.map +0 -1
  72. package/dist/chunk-5PGRBWJX.js.map +0 -1
  73. package/dist/chunk-6OII5QOW.js.map +0 -1
  74. package/dist/chunk-DCIUCDWJ.js.map +0 -1
  75. package/dist/chunk-HBIDSKIQ.js.map +0 -1
  76. package/dist/chunk-XT5ZO6ES.js.map +0 -1
  77. /package/dist/{chunk-QL5SMQ73.js.map → chunk-24EYSWME.js.map} +0 -0
  78. /package/dist/{chunk-ND7IFSMR.js.map → chunk-3ONNAQZU.js.map} +0 -0
  79. /package/dist/{chunk-LM62QCGS.js.map → chunk-EK5ZEOI3.js.map} +0 -0
  80. /package/dist/{chunk-4R3ALD5C.js.map → chunk-ZLJAODDJ.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { Tool } from '@anthropic-ai/sdk/resources/messages';
2
2
  export { formatResult } from './client.js';
3
3
  export { getSystemPrompt } from './agent/prompt.js';
4
- import { d as WarpGrepToolConfig, b as WarpGrepResult } from '../../types-CnvVDM63.js';
4
+ import { d as WarpGrepToolConfig, b as WarpGrepResult } from '../../types-Cv4LpqVl.js';
5
5
  import './providers/types.js';
6
6
  import '../utils/resilience.js';
7
7
 
@@ -2,24 +2,24 @@ import {
2
2
  createWarpGrepTool,
3
3
  execute,
4
4
  warpGrepTool
5
- } from "../../chunk-4R3ALD5C.js";
5
+ } from "../../chunk-ZLJAODDJ.js";
6
6
  import "../../chunk-KW7OEGZK.js";
7
7
  import {
8
8
  formatResult
9
- } from "../../chunk-5PGRBWJX.js";
10
- import "../../chunk-6OII5QOW.js";
11
- import "../../chunk-26QXQFLZ.js";
12
- import "../../chunk-DCIUCDWJ.js";
9
+ } from "../../chunk-FJKPMMNQ.js";
10
+ import "../../chunk-WIAYUEJK.js";
11
+ import "../../chunk-PUGSTXLO.js";
12
+ import "../../chunk-P2O5JKE5.js";
13
13
  import "../../chunk-APP75CBN.js";
14
14
  import "../../chunk-5QRN3JNB.js";
15
15
  import {
16
16
  getSystemPrompt
17
17
  } from "../../chunk-FMLHRJDF.js";
18
- import "../../chunk-HBIDSKIQ.js";
18
+ import "../../chunk-4KMBU6T3.js";
19
19
  import "../../chunk-G2RSY56Q.js";
20
20
  import "../../chunk-YPKNMYD4.js";
21
21
  import "../../chunk-TPP2UGQP.js";
22
- import "../../chunk-XT5ZO6ES.js";
22
+ import "../../chunk-5PNMAWLC.js";
23
23
  import "../../chunk-4VWJFZVS.js";
24
24
  import "../../chunk-PZ5AY32C.js";
25
25
  export {
@@ -38,9 +38,15 @@ __export(client_exports, {
38
38
  module.exports = __toCommonJS(client_exports);
39
39
 
40
40
  // tools/warp_grep/agent/config.ts
41
+ var parseEnvTimeout = (envValue, defaultMs) => {
42
+ if (!envValue) return defaultMs;
43
+ const parsed = parseInt(envValue, 10);
44
+ return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
45
+ };
41
46
  var AGENT_CONFIG = {
42
47
  MAX_TURNS: 4,
43
- TIMEOUT_MS: 3e4,
48
+ /** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
49
+ TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 3e4),
44
50
  MAX_CONTEXT_CHARS: 54e4,
45
51
  MAX_OUTPUT_LINES: 200,
46
52
  MAX_READ_LINES: 800,
@@ -606,10 +612,25 @@ async function toolGrep(provider, args) {
606
612
  }
607
613
 
608
614
  // tools/warp_grep/agent/tools/read.ts
615
+ function isValidRange(start, end) {
616
+ return typeof start === "number" && typeof end === "number" && Number.isFinite(start) && Number.isFinite(end) && start > 0 && end >= start;
617
+ }
609
618
  async function toolRead(provider, args) {
610
- if (args.lines && args.lines.length > 0) {
619
+ if (args.lines && Array.isArray(args.lines) && args.lines.length > 0) {
620
+ const validRanges = [];
621
+ for (const range of args.lines) {
622
+ if (Array.isArray(range) && range.length >= 2 && isValidRange(range[0], range[1])) {
623
+ validRanges.push([range[0], range[1]]);
624
+ }
625
+ }
626
+ if (validRanges.length === 0) {
627
+ const res2 = await provider.read({ path: args.path });
628
+ if (res2.error) return res2.error;
629
+ if (!res2.lines.length) return "(empty file)";
630
+ return res2.lines.join("\n");
631
+ }
611
632
  const chunks = [];
612
- for (const [start, end] of args.lines) {
633
+ for (const [start, end] of validRanges) {
613
634
  const res2 = await provider.read({ path: args.path, start, end });
614
635
  if (res2.error) return res2.error;
615
636
  chunks.push(res2.lines.join("\n"));
@@ -645,14 +666,28 @@ async function toolListDirectory(provider, args) {
645
666
  }
646
667
 
647
668
  // tools/warp_grep/agent/tools/finish.ts
669
+ function isValidRange2(range) {
670
+ 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];
671
+ }
672
+ function extractValidRanges(lines) {
673
+ if (!Array.isArray(lines)) return null;
674
+ const valid = [];
675
+ for (const range of lines) {
676
+ if (isValidRange2(range)) {
677
+ valid.push([range[0], range[1]]);
678
+ }
679
+ }
680
+ return valid.length > 0 ? valid : null;
681
+ }
648
682
  async function readFinishFiles(repoRoot, files, reader) {
649
683
  const out = [];
650
684
  for (const f of files) {
651
- if (f.lines === "*") {
685
+ const validRanges = f.lines === "*" ? null : extractValidRanges(f.lines);
686
+ if (f.lines === "*" || !validRanges) {
652
687
  const lines = await reader(f.path);
653
688
  out.push({ path: f.path, ranges: "*", content: lines.join("\n") });
654
689
  } else {
655
- const ranges = mergeRanges(f.lines);
690
+ const ranges = mergeRanges(validRanges);
656
691
  const chunks = [];
657
692
  for (const [s, e] of ranges) {
658
693
  const lines = await reader(f.path, s, e);
@@ -953,7 +988,8 @@ async function callModel(messages, model, options = {}) {
953
988
  },
954
989
  options.retryConfig
955
990
  );
956
- const resp = await withTimeout(fetchPromise, AGENT_CONFIG.TIMEOUT_MS, "morph-warp-grep request timed out");
991
+ const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
992
+ const resp = await withTimeout(fetchPromise, timeoutMs, "morph-warp-grep request timed out");
957
993
  if (!resp.ok) {
958
994
  if (resp.status === 404) {
959
995
  throw new Error(
@@ -987,7 +1023,8 @@ async function runWarpGrep(config) {
987
1023
  const assistantContent = await callModel(messages, model, {
988
1024
  morphApiKey: config.morphApiKey,
989
1025
  morphApiUrl: config.morphApiUrl,
990
- retryConfig: config.retryConfig
1026
+ retryConfig: config.retryConfig,
1027
+ timeout: config.timeout
991
1028
  }).catch((e) => {
992
1029
  errors.push({ message: e instanceof Error ? e.message : String(e) });
993
1030
  return "";
@@ -1060,7 +1097,7 @@ async function runWarpGrep(config) {
1060
1097
  }
1061
1098
  const parts = ["Relevant context found:"];
1062
1099
  for (const f of finishMeta.files) {
1063
- const ranges = f.lines === "*" ? "*" : f.lines.map(([s, e]) => `${s}-${e}`).join(", ");
1100
+ const ranges = f.lines === "*" ? "*" : Array.isArray(f.lines) ? f.lines.map(([s, e]) => `${s}-${e}`).join(", ") : "*";
1064
1101
  parts.push(`- ${f.path}: ${ranges}`);
1065
1102
  }
1066
1103
  const payload = parts.join("\n");
@@ -1420,11 +1457,19 @@ Details: ${res.stderr}` : ""}`
1420
1457
  };
1421
1458
  }
1422
1459
  const total = lines.length;
1423
- let s = params.start ?? 1;
1424
- let e = Math.min(params.end ?? total, total);
1425
- if (s > total && total > 0) {
1426
- s = 1;
1427
- e = total;
1460
+ const rawStart = params.start;
1461
+ const rawEnd = params.end;
1462
+ let s = 1;
1463
+ let e = total;
1464
+ const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
1465
+ const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
1466
+ if (startValid && endValid) {
1467
+ s = rawStart ?? 1;
1468
+ e = Math.min(rawEnd ?? total, total);
1469
+ if (s > total && total > 0 || s > e) {
1470
+ s = 1;
1471
+ e = total;
1472
+ }
1428
1473
  }
1429
1474
  const out = [];
1430
1475
  for (let i = s; i <= e; i += 1) {
@@ -1600,8 +1645,13 @@ var RemoteCommandsProvider = class {
1600
1645
  * Read file and add line numbers
1601
1646
  */
1602
1647
  async read(params) {
1603
- const start = params.start ?? 1;
1604
- const end = params.end ?? 1e6;
1648
+ const rawStart = params.start;
1649
+ const rawEnd = params.end;
1650
+ const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
1651
+ const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
1652
+ const rangeValid = startValid && endValid && (rawStart === void 0 || rawEnd === void 0 || rawStart <= rawEnd);
1653
+ const start = rangeValid && rawStart !== void 0 ? rawStart : 1;
1654
+ const end = rangeValid && rawEnd !== void 0 ? rawEnd : 1e6;
1605
1655
  try {
1606
1656
  const stdout = await this.commands.read(params.path, start, end);
1607
1657
  const contentLines = (stdout || "").split("\n");
@@ -1705,7 +1755,8 @@ var WarpGrepClient = class {
1705
1755
  debug: input.debug ?? this.config.debug,
1706
1756
  morphApiKey: this.config.morphApiKey,
1707
1757
  morphApiUrl: this.config.morphApiUrl,
1708
- retryConfig: this.config.retryConfig
1758
+ retryConfig: this.config.retryConfig,
1759
+ timeout: this.config.timeout
1709
1760
  }
1710
1761
  );
1711
1762
  }
@@ -1726,7 +1777,8 @@ async function executeToolCall(input, config) {
1726
1777
  debug: config.debug ?? false,
1727
1778
  morphApiKey: config.morphApiKey,
1728
1779
  morphApiUrl: config.morphApiUrl,
1729
- retryConfig: config.retryConfig
1780
+ retryConfig: config.retryConfig,
1781
+ timeout: config.timeout
1730
1782
  });
1731
1783
  const finish = result.finish;
1732
1784
  if (result.terminationReason !== "completed" || !finish?.metadata) {