@morphllm/morphsdk 0.2.81 → 0.2.83

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 (77) hide show
  1. package/dist/{chunk-4NI25AKV.js → chunk-4KMBU6T3.js} +2 -2
  2. package/dist/{chunk-XT5ZO6ES.js → chunk-5PNMAWLC.js} +8 -2
  3. package/dist/chunk-5PNMAWLC.js.map +1 -0
  4. package/dist/{chunk-X6A64F2F.js → chunk-HPR6BJA7.js} +5 -5
  5. package/dist/{chunk-4VMIPD4G.js → chunk-HRK53IKL.js} +8 -6
  6. package/dist/chunk-HRK53IKL.js.map +1 -0
  7. package/dist/{chunk-NTTQJM6O.js → chunk-LXG37353.js} +2 -2
  8. package/dist/{chunk-467MCW5R.js → chunk-P2O5JKE5.js} +2 -2
  9. package/dist/{chunk-PHJQ4N3T.js → chunk-PUGSTXLO.js} +2 -2
  10. package/dist/{chunk-B3UC7UVA.js → chunk-QOYI77CN.js} +30 -8
  11. package/dist/chunk-QOYI77CN.js.map +1 -0
  12. package/dist/{chunk-Z2HDXUH7.js → chunk-RL4JBZ3T.js} +2 -2
  13. package/dist/{chunk-OFMDENAQ.js → chunk-S27A4NQM.js} +2 -2
  14. package/dist/{client-CSINf0lQ.d.ts → client-CsO9LifG.d.ts} +1 -1
  15. package/dist/client.cjs +38 -8
  16. package/dist/client.cjs.map +1 -1
  17. package/dist/client.d.ts +2 -2
  18. package/dist/client.js +10 -10
  19. package/dist/index.cjs +38 -8
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +10 -10
  23. package/dist/tools/warp_grep/agent/config.cjs +7 -1
  24. package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
  25. package/dist/tools/warp_grep/agent/config.d.ts +1 -0
  26. package/dist/tools/warp_grep/agent/config.js +1 -1
  27. package/dist/tools/warp_grep/agent/runner.cjs +34 -6
  28. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  29. package/dist/tools/warp_grep/agent/runner.js +3 -3
  30. package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
  31. package/dist/tools/warp_grep/agent/types.d.ts +16 -1
  32. package/dist/tools/warp_grep/anthropic.cjs +36 -7
  33. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  34. package/dist/tools/warp_grep/anthropic.d.ts +1 -1
  35. package/dist/tools/warp_grep/anthropic.js +7 -7
  36. package/dist/tools/warp_grep/client.cjs +38 -8
  37. package/dist/tools/warp_grep/client.cjs.map +1 -1
  38. package/dist/tools/warp_grep/client.d.ts +1 -1
  39. package/dist/tools/warp_grep/client.js +6 -6
  40. package/dist/tools/warp_grep/gemini.cjs +36 -7
  41. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  42. package/dist/tools/warp_grep/gemini.d.ts +1 -1
  43. package/dist/tools/warp_grep/gemini.js +6 -6
  44. package/dist/tools/warp_grep/harness.cjs +7 -1
  45. package/dist/tools/warp_grep/harness.cjs.map +1 -1
  46. package/dist/tools/warp_grep/harness.js +3 -3
  47. package/dist/tools/warp_grep/index.cjs +38 -8
  48. package/dist/tools/warp_grep/index.cjs.map +1 -1
  49. package/dist/tools/warp_grep/index.d.ts +1 -1
  50. package/dist/tools/warp_grep/index.js +6 -6
  51. package/dist/tools/warp_grep/openai.cjs +36 -7
  52. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  53. package/dist/tools/warp_grep/openai.d.ts +1 -1
  54. package/dist/tools/warp_grep/openai.js +7 -7
  55. package/dist/tools/warp_grep/providers/local.cjs +7 -1
  56. package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
  57. package/dist/tools/warp_grep/providers/local.js +2 -2
  58. package/dist/tools/warp_grep/providers/remote.cjs +7 -1
  59. package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
  60. package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
  61. package/dist/tools/warp_grep/providers/remote.js +2 -2
  62. package/dist/tools/warp_grep/vercel.cjs +36 -7
  63. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  64. package/dist/tools/warp_grep/vercel.d.ts +1 -1
  65. package/dist/tools/warp_grep/vercel.js +7 -7
  66. package/dist/{types-CnvVDM63.d.ts → types-Cv4LpqVl.d.ts} +2 -0
  67. package/package.json +1 -1
  68. package/dist/chunk-4VMIPD4G.js.map +0 -1
  69. package/dist/chunk-B3UC7UVA.js.map +0 -1
  70. package/dist/chunk-XT5ZO6ES.js.map +0 -1
  71. /package/dist/{chunk-4NI25AKV.js.map → chunk-4KMBU6T3.js.map} +0 -0
  72. /package/dist/{chunk-X6A64F2F.js.map → chunk-HPR6BJA7.js.map} +0 -0
  73. /package/dist/{chunk-NTTQJM6O.js.map → chunk-LXG37353.js.map} +0 -0
  74. /package/dist/{chunk-467MCW5R.js.map → chunk-P2O5JKE5.js.map} +0 -0
  75. /package/dist/{chunk-PHJQ4N3T.js.map → chunk-PUGSTXLO.js.map} +0 -0
  76. /package/dist/{chunk-Z2HDXUH7.js.map → chunk-RL4JBZ3T.js.map} +0 -0
  77. /package/dist/{chunk-OFMDENAQ.js.map → chunk-S27A4NQM.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  export { WarpGrepClient, executeToolCall, executeWarpGrep, formatResult } from './client.js';
3
- export { R as RemoteCommands, W as WarpGrepClientConfig, c as WarpGrepContext, a as WarpGrepInput, b as WarpGrepResult, d as WarpGrepToolConfig } from '../../types-CnvVDM63.js';
3
+ export { R as RemoteCommands, W as WarpGrepClientConfig, c as WarpGrepContext, a as WarpGrepInput, b as WarpGrepResult, d as WarpGrepToolConfig } from '../../types-Cv4LpqVl.js';
4
4
  export { GrepResult, ListDirectoryEntry, ReadResult, WarpGrepProvider } from './providers/types.js';
5
5
  export { LocalRipgrepProvider } from './providers/local.js';
6
6
  export { RemoteCommandsProvider } from './providers/remote.js';
@@ -10,20 +10,20 @@ import {
10
10
  executeToolCall,
11
11
  executeWarpGrep,
12
12
  formatResult
13
- } from "../../chunk-4VMIPD4G.js";
13
+ } from "../../chunk-HRK53IKL.js";
14
14
  import {
15
15
  runWarpGrep
16
- } from "../../chunk-B3UC7UVA.js";
16
+ } from "../../chunk-QOYI77CN.js";
17
17
  import {
18
18
  RemoteCommandsProvider
19
- } from "../../chunk-PHJQ4N3T.js";
19
+ } from "../../chunk-PUGSTXLO.js";
20
20
  import {
21
21
  normalizeFinishFiles,
22
22
  readFinishFiles,
23
23
  toolGrep,
24
24
  toolListDirectory,
25
25
  toolRead
26
- } from "../../chunk-467MCW5R.js";
26
+ } from "../../chunk-P2O5JKE5.js";
27
27
  import "../../chunk-APP75CBN.js";
28
28
  import "../../chunk-5QRN3JNB.js";
29
29
  import {
@@ -32,13 +32,13 @@ import {
32
32
  } from "../../chunk-FMLHRJDF.js";
33
33
  import {
34
34
  LocalRipgrepProvider
35
- } from "../../chunk-4NI25AKV.js";
35
+ } from "../../chunk-4KMBU6T3.js";
36
36
  import "../../chunk-G2RSY56Q.js";
37
37
  import {
38
38
  fixPathRepetition
39
39
  } from "../../chunk-YPKNMYD4.js";
40
40
  import "../../chunk-TPP2UGQP.js";
41
- import "../../chunk-XT5ZO6ES.js";
41
+ import "../../chunk-5PNMAWLC.js";
42
42
  import "../../chunk-4VWJFZVS.js";
43
43
  import "../../chunk-PZ5AY32C.js";
44
44
  export {
@@ -40,9 +40,15 @@ __export(openai_exports, {
40
40
  module.exports = __toCommonJS(openai_exports);
41
41
 
42
42
  // tools/warp_grep/agent/config.ts
43
+ var parseEnvTimeout = (envValue, defaultMs) => {
44
+ if (!envValue) return defaultMs;
45
+ const parsed = parseInt(envValue, 10);
46
+ return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
47
+ };
43
48
  var AGENT_CONFIG = {
44
49
  MAX_TURNS: 4,
45
- TIMEOUT_MS: 3e4,
50
+ /** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
51
+ TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 3e4),
46
52
  MAX_CONTEXT_CHARS: 54e4,
47
53
  MAX_OUTPUT_LINES: 200,
48
54
  MAX_READ_LINES: 800,
@@ -984,7 +990,8 @@ async function callModel(messages, model, options = {}) {
984
990
  },
985
991
  options.retryConfig
986
992
  );
987
- const resp = await withTimeout(fetchPromise, AGENT_CONFIG.TIMEOUT_MS, "morph-warp-grep request timed out");
993
+ const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
994
+ const resp = await withTimeout(fetchPromise, timeoutMs, "morph-warp-grep request timed out");
988
995
  if (!resp.ok) {
989
996
  if (resp.status === 404) {
990
997
  throw new Error(
@@ -1002,10 +1009,15 @@ async function callModel(messages, model, options = {}) {
1002
1009
  return content;
1003
1010
  }
1004
1011
  async function runWarpGrep(config) {
1012
+ const totalStart = Date.now();
1013
+ const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
1014
+ const timings = { turns: [], timeout_ms: timeoutMs };
1005
1015
  const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
1006
1016
  const messages = [];
1007
1017
  messages.push({ role: "system", content: getSystemPrompt() });
1018
+ const initialStateStart = Date.now();
1008
1019
  const initialState = await buildInitialState(repoRoot, config.query, config.provider);
1020
+ timings.initial_state_ms = Date.now() - initialStateStart;
1009
1021
  messages.push({ role: "user", content: initialState });
1010
1022
  const maxTurns = AGENT_CONFIG.MAX_TURNS;
1011
1023
  const model = config.model || DEFAULT_MODEL;
@@ -1014,21 +1026,29 @@ async function runWarpGrep(config) {
1014
1026
  let finishMeta;
1015
1027
  let terminationReason = "terminated";
1016
1028
  for (let turn = 1; turn <= maxTurns; turn += 1) {
1029
+ const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
1017
1030
  enforceContextLimit(messages);
1031
+ const modelCallStart = Date.now();
1018
1032
  const assistantContent = await callModel(messages, model, {
1019
1033
  morphApiKey: config.morphApiKey,
1020
1034
  morphApiUrl: config.morphApiUrl,
1021
- retryConfig: config.retryConfig
1035
+ retryConfig: config.retryConfig,
1036
+ timeout: timeoutMs
1022
1037
  }).catch((e) => {
1023
1038
  errors.push({ message: e instanceof Error ? e.message : String(e) });
1024
1039
  return "";
1025
1040
  });
1026
- if (!assistantContent) break;
1041
+ turnMetrics.morph_api_ms = Date.now() - modelCallStart;
1042
+ if (!assistantContent) {
1043
+ timings.turns.push(turnMetrics);
1044
+ break;
1045
+ }
1027
1046
  messages.push({ role: "assistant", content: assistantContent });
1028
1047
  const toolCalls = parser.parse(assistantContent);
1029
1048
  if (toolCalls.length === 0) {
1030
1049
  errors.push({ message: "No tool calls produced by the model. Your MCP is likely out of date! Update it by running: rm -rf ~/.npm/_npx && npm cache clean --force && npx -y @morphllm/morphmcp@latest" });
1031
1050
  terminationReason = "terminated";
1051
+ timings.turns.push(turnMetrics);
1032
1052
  break;
1033
1053
  }
1034
1054
  const finishCalls = toolCalls.filter((c) => c.name === "finish");
@@ -1069,7 +1089,9 @@ async function runWarpGrep(config) {
1069
1089
  )
1070
1090
  );
1071
1091
  }
1092
+ const toolExecStart = Date.now();
1072
1093
  const allResults = await Promise.all(allPromises);
1094
+ turnMetrics.local_tools_ms = Date.now() - toolExecStart;
1073
1095
  for (const result of allResults) {
1074
1096
  formatted.push(result);
1075
1097
  }
@@ -1078,6 +1100,7 @@ async function runWarpGrep(config) {
1078
1100
  const contextBudget = calculateContextBudget(messages);
1079
1101
  messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
1080
1102
  }
1103
+ timings.turns.push(turnMetrics);
1081
1104
  if (finishCalls.length) {
1082
1105
  const fc = finishCalls[0];
1083
1106
  const files = fc.arguments?.files ?? [];
@@ -1087,7 +1110,8 @@ async function runWarpGrep(config) {
1087
1110
  }
1088
1111
  }
1089
1112
  if (terminationReason !== "completed" || !finishMeta) {
1090
- return { terminationReason, messages, errors };
1113
+ timings.total_ms = Date.now() - totalStart;
1114
+ return { terminationReason, messages, errors, timings };
1091
1115
  }
1092
1116
  const parts = ["Relevant context found:"];
1093
1117
  for (const f of finishMeta.files) {
@@ -1095,6 +1119,7 @@ async function runWarpGrep(config) {
1095
1119
  parts.push(`- ${f.path}: ${ranges}`);
1096
1120
  }
1097
1121
  const payload = parts.join("\n");
1122
+ const finishResolutionStart = Date.now();
1098
1123
  const fileReadErrors = [];
1099
1124
  const resolved = await readFinishFiles(
1100
1125
  repoRoot,
@@ -1114,13 +1139,16 @@ async function runWarpGrep(config) {
1114
1139
  }
1115
1140
  }
1116
1141
  );
1142
+ timings.finish_resolution_ms = Date.now() - finishResolutionStart;
1117
1143
  if (fileReadErrors.length > 0) {
1118
1144
  errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
1119
1145
  }
1146
+ timings.total_ms = Date.now() - totalStart;
1120
1147
  return {
1121
1148
  terminationReason: "completed",
1122
1149
  messages,
1123
- finish: { payload, metadata: finishMeta, resolved }
1150
+ finish: { payload, metadata: finishMeta, resolved },
1151
+ timings
1124
1152
  };
1125
1153
  }
1126
1154
 
@@ -1717,7 +1745,8 @@ async function executeToolCall(input, config) {
1717
1745
  debug: config.debug ?? false,
1718
1746
  morphApiKey: config.morphApiKey,
1719
1747
  morphApiUrl: config.morphApiUrl,
1720
- retryConfig: config.retryConfig
1748
+ retryConfig: config.retryConfig,
1749
+ timeout: config.timeout
1721
1750
  });
1722
1751
  const finish = result.finish;
1723
1752
  if (result.terminationReason !== "completed" || !finish?.metadata) {