@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
package/dist/client.d.ts CHANGED
@@ -5,11 +5,11 @@ import './tools/browser/core.js';
5
5
  import './tools/warp_grep/client.js';
6
6
  import './git/client.js';
7
7
  import './modelrouter/core.js';
8
- export { M as MorphClient, a as MorphClientConfig } from './client-CSINf0lQ.js';
8
+ export { M as MorphClient, a as MorphClientConfig } from './client-CsO9LifG.js';
9
9
  import './tools/fastapply/types.js';
10
10
  import './tools/codebase_search/types.js';
11
11
  import './tools/browser/types.js';
12
- import './types-CnvVDM63.js';
12
+ import './types-Cv4LpqVl.js';
13
13
  import './tools/warp_grep/providers/types.js';
14
14
  import './git/types.js';
15
15
  import 'isomorphic-git';
package/dist/client.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  MorphClient
3
- } from "./chunk-LM62QCGS.js";
4
- import "./chunk-4R3ALD5C.js";
5
- import "./chunk-QL5SMQ73.js";
6
- import "./chunk-ND7IFSMR.js";
3
+ } from "./chunk-EK5ZEOI3.js";
4
+ import "./chunk-ZLJAODDJ.js";
5
+ import "./chunk-24EYSWME.js";
6
+ import "./chunk-3ONNAQZU.js";
7
7
  import "./chunk-KW7OEGZK.js";
8
- import "./chunk-5PGRBWJX.js";
9
- import "./chunk-6OII5QOW.js";
10
- import "./chunk-26QXQFLZ.js";
11
- import "./chunk-DCIUCDWJ.js";
8
+ import "./chunk-FJKPMMNQ.js";
9
+ import "./chunk-WIAYUEJK.js";
10
+ import "./chunk-PUGSTXLO.js";
11
+ import "./chunk-P2O5JKE5.js";
12
12
  import "./chunk-APP75CBN.js";
13
13
  import "./chunk-5QRN3JNB.js";
14
14
  import "./chunk-FMLHRJDF.js";
15
- import "./chunk-HBIDSKIQ.js";
15
+ import "./chunk-4KMBU6T3.js";
16
16
  import "./chunk-G2RSY56Q.js";
17
17
  import "./chunk-YPKNMYD4.js";
18
18
  import "./chunk-TPP2UGQP.js";
19
- import "./chunk-XT5ZO6ES.js";
19
+ import "./chunk-5PNMAWLC.js";
20
20
  import "./chunk-UBX7QYBD.js";
21
21
  import "./chunk-GJU7UOFL.js";
22
22
  import "./chunk-76DJEQEP.js";
package/dist/index.cjs CHANGED
@@ -1001,9 +1001,15 @@ async function checkHealth(config = {}) {
1001
1001
  }
1002
1002
 
1003
1003
  // tools/warp_grep/agent/config.ts
1004
+ var parseEnvTimeout = (envValue, defaultMs) => {
1005
+ if (!envValue) return defaultMs;
1006
+ const parsed = parseInt(envValue, 10);
1007
+ return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
1008
+ };
1004
1009
  var AGENT_CONFIG = {
1005
1010
  MAX_TURNS: 4,
1006
- TIMEOUT_MS: 3e4,
1011
+ /** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
1012
+ TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 3e4),
1007
1013
  MAX_CONTEXT_CHARS: 54e4,
1008
1014
  MAX_OUTPUT_LINES: 200,
1009
1015
  MAX_READ_LINES: 800,
@@ -1569,10 +1575,25 @@ async function toolGrep(provider, args) {
1569
1575
  }
1570
1576
 
1571
1577
  // tools/warp_grep/agent/tools/read.ts
1578
+ function isValidRange(start, end) {
1579
+ return typeof start === "number" && typeof end === "number" && Number.isFinite(start) && Number.isFinite(end) && start > 0 && end >= start;
1580
+ }
1572
1581
  async function toolRead(provider, args) {
1573
- if (args.lines && args.lines.length > 0) {
1582
+ if (args.lines && Array.isArray(args.lines) && args.lines.length > 0) {
1583
+ const validRanges = [];
1584
+ for (const range of args.lines) {
1585
+ if (Array.isArray(range) && range.length >= 2 && isValidRange(range[0], range[1])) {
1586
+ validRanges.push([range[0], range[1]]);
1587
+ }
1588
+ }
1589
+ if (validRanges.length === 0) {
1590
+ const res2 = await provider.read({ path: args.path });
1591
+ if (res2.error) return res2.error;
1592
+ if (!res2.lines.length) return "(empty file)";
1593
+ return res2.lines.join("\n");
1594
+ }
1574
1595
  const chunks = [];
1575
- for (const [start, end] of args.lines) {
1596
+ for (const [start, end] of validRanges) {
1576
1597
  const res2 = await provider.read({ path: args.path, start, end });
1577
1598
  if (res2.error) return res2.error;
1578
1599
  chunks.push(res2.lines.join("\n"));
@@ -1608,14 +1629,28 @@ async function toolListDirectory(provider, args) {
1608
1629
  }
1609
1630
 
1610
1631
  // tools/warp_grep/agent/tools/finish.ts
1632
+ function isValidRange2(range) {
1633
+ 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];
1634
+ }
1635
+ function extractValidRanges(lines) {
1636
+ if (!Array.isArray(lines)) return null;
1637
+ const valid = [];
1638
+ for (const range of lines) {
1639
+ if (isValidRange2(range)) {
1640
+ valid.push([range[0], range[1]]);
1641
+ }
1642
+ }
1643
+ return valid.length > 0 ? valid : null;
1644
+ }
1611
1645
  async function readFinishFiles(repoRoot, files, reader) {
1612
1646
  const out = [];
1613
1647
  for (const f of files) {
1614
- if (f.lines === "*") {
1648
+ const validRanges = f.lines === "*" ? null : extractValidRanges(f.lines);
1649
+ if (f.lines === "*" || !validRanges) {
1615
1650
  const lines = await reader(f.path);
1616
1651
  out.push({ path: f.path, ranges: "*", content: lines.join("\n") });
1617
1652
  } else {
1618
- const ranges = mergeRanges(f.lines);
1653
+ const ranges = mergeRanges(validRanges);
1619
1654
  const chunks = [];
1620
1655
  for (const [s, e] of ranges) {
1621
1656
  const lines = await reader(f.path, s, e);
@@ -1842,7 +1877,8 @@ async function callModel(messages, model, options = {}) {
1842
1877
  },
1843
1878
  options.retryConfig
1844
1879
  );
1845
- const resp = await withTimeout(fetchPromise, AGENT_CONFIG.TIMEOUT_MS, "morph-warp-grep request timed out");
1880
+ const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
1881
+ const resp = await withTimeout(fetchPromise, timeoutMs, "morph-warp-grep request timed out");
1846
1882
  if (!resp.ok) {
1847
1883
  if (resp.status === 404) {
1848
1884
  throw new Error(
@@ -1876,7 +1912,8 @@ async function runWarpGrep(config) {
1876
1912
  const assistantContent = await callModel(messages, model, {
1877
1913
  morphApiKey: config.morphApiKey,
1878
1914
  morphApiUrl: config.morphApiUrl,
1879
- retryConfig: config.retryConfig
1915
+ retryConfig: config.retryConfig,
1916
+ timeout: config.timeout
1880
1917
  }).catch((e) => {
1881
1918
  errors.push({ message: e instanceof Error ? e.message : String(e) });
1882
1919
  return "";
@@ -1949,7 +1986,7 @@ async function runWarpGrep(config) {
1949
1986
  }
1950
1987
  const parts = ["Relevant context found:"];
1951
1988
  for (const f of finishMeta.files) {
1952
- const ranges = f.lines === "*" ? "*" : f.lines.map(([s, e]) => `${s}-${e}`).join(", ");
1989
+ const ranges = f.lines === "*" ? "*" : Array.isArray(f.lines) ? f.lines.map(([s, e]) => `${s}-${e}`).join(", ") : "*";
1953
1990
  parts.push(`- ${f.path}: ${ranges}`);
1954
1991
  }
1955
1992
  const payload = parts.join("\n");
@@ -2309,11 +2346,19 @@ Details: ${res.stderr}` : ""}`
2309
2346
  };
2310
2347
  }
2311
2348
  const total = lines.length;
2312
- let s = params.start ?? 1;
2313
- let e = Math.min(params.end ?? total, total);
2314
- if (s > total && total > 0) {
2315
- s = 1;
2316
- e = total;
2349
+ const rawStart = params.start;
2350
+ const rawEnd = params.end;
2351
+ let s = 1;
2352
+ let e = total;
2353
+ const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
2354
+ const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
2355
+ if (startValid && endValid) {
2356
+ s = rawStart ?? 1;
2357
+ e = Math.min(rawEnd ?? total, total);
2358
+ if (s > total && total > 0 || s > e) {
2359
+ s = 1;
2360
+ e = total;
2361
+ }
2317
2362
  }
2318
2363
  const out = [];
2319
2364
  for (let i = s; i <= e; i += 1) {
@@ -2489,8 +2534,13 @@ var RemoteCommandsProvider = class {
2489
2534
  * Read file and add line numbers
2490
2535
  */
2491
2536
  async read(params) {
2492
- const start = params.start ?? 1;
2493
- const end = params.end ?? 1e6;
2537
+ const rawStart = params.start;
2538
+ const rawEnd = params.end;
2539
+ const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
2540
+ const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
2541
+ const rangeValid = startValid && endValid && (rawStart === void 0 || rawEnd === void 0 || rawStart <= rawEnd);
2542
+ const start = rangeValid && rawStart !== void 0 ? rawStart : 1;
2543
+ const end = rangeValid && rawEnd !== void 0 ? rawEnd : 1e6;
2494
2544
  try {
2495
2545
  const stdout = await this.commands.read(params.path, start, end);
2496
2546
  const contentLines = (stdout || "").split("\n");
@@ -2594,7 +2644,8 @@ var WarpGrepClient = class {
2594
2644
  debug: input.debug ?? this.config.debug,
2595
2645
  morphApiKey: this.config.morphApiKey,
2596
2646
  morphApiUrl: this.config.morphApiUrl,
2597
- retryConfig: this.config.retryConfig
2647
+ retryConfig: this.config.retryConfig,
2648
+ timeout: this.config.timeout
2598
2649
  }
2599
2650
  );
2600
2651
  }
@@ -2611,7 +2662,8 @@ async function executeToolCall(input, config) {
2611
2662
  debug: config.debug ?? false,
2612
2663
  morphApiKey: config.morphApiKey,
2613
2664
  morphApiUrl: config.morphApiUrl,
2614
- retryConfig: config.retryConfig
2665
+ retryConfig: config.retryConfig,
2666
+ timeout: config.timeout
2615
2667
  });
2616
2668
  const finish = result.finish;
2617
2669
  if (result.terminationReason !== "completed" || !finish?.metadata) {