@morphllm/morphsdk 0.2.82 → 0.2.84

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 (49) hide show
  1. package/dist/{chunk-ZLJAODDJ.js → chunk-262WRPS5.js} +2 -2
  2. package/dist/{chunk-FJKPMMNQ.js → chunk-D4EQYM6O.js} +2 -2
  3. package/dist/{chunk-P2O5JKE5.js → chunk-KRDIR7GG.js} +17 -8
  4. package/dist/chunk-KRDIR7GG.js.map +1 -0
  5. package/dist/{chunk-WIAYUEJK.js → chunk-LF2X6YNP.js} +26 -6
  6. package/dist/chunk-LF2X6YNP.js.map +1 -0
  7. package/dist/{chunk-24EYSWME.js → chunk-LX2WNS3L.js} +2 -2
  8. package/dist/{chunk-3ONNAQZU.js → chunk-MJ7JODAY.js} +2 -2
  9. package/dist/{chunk-EK5ZEOI3.js → chunk-N3RNM4A4.js} +5 -5
  10. package/dist/client.cjs +40 -11
  11. package/dist/client.cjs.map +1 -1
  12. package/dist/client.js +7 -7
  13. package/dist/index.cjs +40 -11
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.js +7 -7
  16. package/dist/tools/warp_grep/agent/runner.cjs +40 -11
  17. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  18. package/dist/tools/warp_grep/agent/runner.js +2 -2
  19. package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
  20. package/dist/tools/warp_grep/agent/types.d.ts +14 -1
  21. package/dist/tools/warp_grep/anthropic.cjs +40 -11
  22. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  23. package/dist/tools/warp_grep/anthropic.js +4 -4
  24. package/dist/tools/warp_grep/client.cjs +40 -11
  25. package/dist/tools/warp_grep/client.cjs.map +1 -1
  26. package/dist/tools/warp_grep/client.js +3 -3
  27. package/dist/tools/warp_grep/gemini.cjs +40 -11
  28. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  29. package/dist/tools/warp_grep/gemini.js +3 -3
  30. package/dist/tools/warp_grep/harness.cjs +16 -7
  31. package/dist/tools/warp_grep/harness.cjs.map +1 -1
  32. package/dist/tools/warp_grep/harness.js +1 -1
  33. package/dist/tools/warp_grep/index.cjs +40 -11
  34. package/dist/tools/warp_grep/index.cjs.map +1 -1
  35. package/dist/tools/warp_grep/index.js +3 -3
  36. package/dist/tools/warp_grep/openai.cjs +40 -11
  37. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  38. package/dist/tools/warp_grep/openai.js +4 -4
  39. package/dist/tools/warp_grep/vercel.cjs +40 -11
  40. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  41. package/dist/tools/warp_grep/vercel.js +4 -4
  42. package/package.json +1 -1
  43. package/dist/chunk-P2O5JKE5.js.map +0 -1
  44. package/dist/chunk-WIAYUEJK.js.map +0 -1
  45. /package/dist/{chunk-ZLJAODDJ.js.map → chunk-262WRPS5.js.map} +0 -0
  46. /package/dist/{chunk-FJKPMMNQ.js.map → chunk-D4EQYM6O.js.map} +0 -0
  47. /package/dist/{chunk-24EYSWME.js.map → chunk-LX2WNS3L.js.map} +0 -0
  48. /package/dist/{chunk-3ONNAQZU.js.map → chunk-MJ7JODAY.js.map} +0 -0
  49. /package/dist/{chunk-EK5ZEOI3.js.map → chunk-N3RNM4A4.js.map} +0 -0
@@ -10,10 +10,10 @@ import {
10
10
  executeToolCall,
11
11
  executeWarpGrep,
12
12
  formatResult
13
- } from "../../chunk-FJKPMMNQ.js";
13
+ } from "../../chunk-D4EQYM6O.js";
14
14
  import {
15
15
  runWarpGrep
16
- } from "../../chunk-WIAYUEJK.js";
16
+ } from "../../chunk-LF2X6YNP.js";
17
17
  import {
18
18
  RemoteCommandsProvider
19
19
  } from "../../chunk-PUGSTXLO.js";
@@ -23,7 +23,7 @@ import {
23
23
  toolGrep,
24
24
  toolListDirectory,
25
25
  toolRead
26
- } from "../../chunk-P2O5JKE5.js";
26
+ } from "../../chunk-KRDIR7GG.js";
27
27
  import "../../chunk-APP75CBN.js";
28
28
  import "../../chunk-5QRN3JNB.js";
29
29
  import {
@@ -650,14 +650,23 @@ async function toolRead(provider, args) {
650
650
 
651
651
  // tools/warp_grep/agent/tools/list_directory.ts
652
652
  async function toolListDirectory(provider, args) {
653
- const list = await provider.listDirectory({
654
- path: args.path,
655
- pattern: args.pattern ?? null,
656
- maxResults: args.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES,
657
- maxDepth: args.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH
658
- });
653
+ const maxResults = args.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES;
654
+ const initialDepth = args.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
655
+ async function getListRecursive(currentDepth) {
656
+ const entries = await provider.listDirectory({
657
+ path: args.path,
658
+ pattern: args.pattern ?? null,
659
+ maxResults,
660
+ maxDepth: currentDepth
661
+ });
662
+ if (entries.length >= maxResults && currentDepth > 0) {
663
+ return getListRecursive(currentDepth - 1);
664
+ }
665
+ return { entries };
666
+ }
667
+ const { entries: list } = await getListRecursive(initialDepth);
659
668
  if (!list.length) return "empty";
660
- if (list.length >= AGENT_CONFIG.MAX_OUTPUT_LINES) {
669
+ if (list.length >= maxResults) {
661
670
  return "query not specific enough, tool called tried to return too much context and failed";
662
671
  }
663
672
  return list.map((e) => {
@@ -1009,10 +1018,15 @@ async function callModel(messages, model, options = {}) {
1009
1018
  return content;
1010
1019
  }
1011
1020
  async function runWarpGrep(config) {
1021
+ const totalStart = Date.now();
1022
+ const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
1023
+ const timings = { turns: [], timeout_ms: timeoutMs };
1012
1024
  const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
1013
1025
  const messages = [];
1014
1026
  messages.push({ role: "system", content: getSystemPrompt() });
1027
+ const initialStateStart = Date.now();
1015
1028
  const initialState = await buildInitialState(repoRoot, config.query, config.provider);
1029
+ timings.initial_state_ms = Date.now() - initialStateStart;
1016
1030
  messages.push({ role: "user", content: initialState });
1017
1031
  const maxTurns = AGENT_CONFIG.MAX_TURNS;
1018
1032
  const model = config.model || DEFAULT_MODEL;
@@ -1021,22 +1035,29 @@ async function runWarpGrep(config) {
1021
1035
  let finishMeta;
1022
1036
  let terminationReason = "terminated";
1023
1037
  for (let turn = 1; turn <= maxTurns; turn += 1) {
1038
+ const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
1024
1039
  enforceContextLimit(messages);
1040
+ const modelCallStart = Date.now();
1025
1041
  const assistantContent = await callModel(messages, model, {
1026
1042
  morphApiKey: config.morphApiKey,
1027
1043
  morphApiUrl: config.morphApiUrl,
1028
1044
  retryConfig: config.retryConfig,
1029
- timeout: config.timeout
1045
+ timeout: timeoutMs
1030
1046
  }).catch((e) => {
1031
1047
  errors.push({ message: e instanceof Error ? e.message : String(e) });
1032
1048
  return "";
1033
1049
  });
1034
- if (!assistantContent) break;
1050
+ turnMetrics.morph_api_ms = Date.now() - modelCallStart;
1051
+ if (!assistantContent) {
1052
+ timings.turns.push(turnMetrics);
1053
+ break;
1054
+ }
1035
1055
  messages.push({ role: "assistant", content: assistantContent });
1036
1056
  const toolCalls = parser.parse(assistantContent);
1037
1057
  if (toolCalls.length === 0) {
1038
1058
  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" });
1039
1059
  terminationReason = "terminated";
1060
+ timings.turns.push(turnMetrics);
1040
1061
  break;
1041
1062
  }
1042
1063
  const finishCalls = toolCalls.filter((c) => c.name === "finish");
@@ -1077,7 +1098,9 @@ async function runWarpGrep(config) {
1077
1098
  )
1078
1099
  );
1079
1100
  }
1101
+ const toolExecStart = Date.now();
1080
1102
  const allResults = await Promise.all(allPromises);
1103
+ turnMetrics.local_tools_ms = Date.now() - toolExecStart;
1081
1104
  for (const result of allResults) {
1082
1105
  formatted.push(result);
1083
1106
  }
@@ -1086,6 +1109,7 @@ async function runWarpGrep(config) {
1086
1109
  const contextBudget = calculateContextBudget(messages);
1087
1110
  messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
1088
1111
  }
1112
+ timings.turns.push(turnMetrics);
1089
1113
  if (finishCalls.length) {
1090
1114
  const fc = finishCalls[0];
1091
1115
  const files = fc.arguments?.files ?? [];
@@ -1095,7 +1119,8 @@ async function runWarpGrep(config) {
1095
1119
  }
1096
1120
  }
1097
1121
  if (terminationReason !== "completed" || !finishMeta) {
1098
- return { terminationReason, messages, errors };
1122
+ timings.total_ms = Date.now() - totalStart;
1123
+ return { terminationReason, messages, errors, timings };
1099
1124
  }
1100
1125
  const parts = ["Relevant context found:"];
1101
1126
  for (const f of finishMeta.files) {
@@ -1103,6 +1128,7 @@ async function runWarpGrep(config) {
1103
1128
  parts.push(`- ${f.path}: ${ranges}`);
1104
1129
  }
1105
1130
  const payload = parts.join("\n");
1131
+ const finishResolutionStart = Date.now();
1106
1132
  const fileReadErrors = [];
1107
1133
  const resolved = await readFinishFiles(
1108
1134
  repoRoot,
@@ -1122,13 +1148,16 @@ async function runWarpGrep(config) {
1122
1148
  }
1123
1149
  }
1124
1150
  );
1151
+ timings.finish_resolution_ms = Date.now() - finishResolutionStart;
1125
1152
  if (fileReadErrors.length > 0) {
1126
1153
  errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
1127
1154
  }
1155
+ timings.total_ms = Date.now() - totalStart;
1128
1156
  return {
1129
1157
  terminationReason: "completed",
1130
1158
  messages,
1131
- finish: { payload, metadata: finishMeta, resolved }
1159
+ finish: { payload, metadata: finishMeta, resolved },
1160
+ timings
1132
1161
  };
1133
1162
  }
1134
1163