@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
@@ -649,14 +649,23 @@ async function toolRead(provider, args) {
649
649
 
650
650
  // tools/warp_grep/agent/tools/list_directory.ts
651
651
  async function toolListDirectory(provider, args) {
652
- const list = await provider.listDirectory({
653
- path: args.path,
654
- pattern: args.pattern ?? null,
655
- maxResults: args.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES,
656
- maxDepth: args.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH
657
- });
652
+ const maxResults = args.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES;
653
+ const initialDepth = args.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
654
+ async function getListRecursive(currentDepth) {
655
+ const entries = await provider.listDirectory({
656
+ path: args.path,
657
+ pattern: args.pattern ?? null,
658
+ maxResults,
659
+ maxDepth: currentDepth
660
+ });
661
+ if (entries.length >= maxResults && currentDepth > 0) {
662
+ return getListRecursive(currentDepth - 1);
663
+ }
664
+ return { entries };
665
+ }
666
+ const { entries: list } = await getListRecursive(initialDepth);
658
667
  if (!list.length) return "empty";
659
- if (list.length >= AGENT_CONFIG.MAX_OUTPUT_LINES) {
668
+ if (list.length >= maxResults) {
660
669
  return "query not specific enough, tool called tried to return too much context and failed";
661
670
  }
662
671
  return list.map((e) => {
@@ -1008,10 +1017,15 @@ async function callModel(messages, model, options = {}) {
1008
1017
  return content;
1009
1018
  }
1010
1019
  async function runWarpGrep(config) {
1020
+ const totalStart = Date.now();
1021
+ const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
1022
+ const timings = { turns: [], timeout_ms: timeoutMs };
1011
1023
  const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
1012
1024
  const messages = [];
1013
1025
  messages.push({ role: "system", content: getSystemPrompt() });
1026
+ const initialStateStart = Date.now();
1014
1027
  const initialState = await buildInitialState(repoRoot, config.query, config.provider);
1028
+ timings.initial_state_ms = Date.now() - initialStateStart;
1015
1029
  messages.push({ role: "user", content: initialState });
1016
1030
  const maxTurns = AGENT_CONFIG.MAX_TURNS;
1017
1031
  const model = config.model || DEFAULT_MODEL;
@@ -1020,22 +1034,29 @@ async function runWarpGrep(config) {
1020
1034
  let finishMeta;
1021
1035
  let terminationReason = "terminated";
1022
1036
  for (let turn = 1; turn <= maxTurns; turn += 1) {
1037
+ const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
1023
1038
  enforceContextLimit(messages);
1039
+ const modelCallStart = Date.now();
1024
1040
  const assistantContent = await callModel(messages, model, {
1025
1041
  morphApiKey: config.morphApiKey,
1026
1042
  morphApiUrl: config.morphApiUrl,
1027
1043
  retryConfig: config.retryConfig,
1028
- timeout: config.timeout
1044
+ timeout: timeoutMs
1029
1045
  }).catch((e) => {
1030
1046
  errors.push({ message: e instanceof Error ? e.message : String(e) });
1031
1047
  return "";
1032
1048
  });
1033
- if (!assistantContent) break;
1049
+ turnMetrics.morph_api_ms = Date.now() - modelCallStart;
1050
+ if (!assistantContent) {
1051
+ timings.turns.push(turnMetrics);
1052
+ break;
1053
+ }
1034
1054
  messages.push({ role: "assistant", content: assistantContent });
1035
1055
  const toolCalls = parser.parse(assistantContent);
1036
1056
  if (toolCalls.length === 0) {
1037
1057
  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" });
1038
1058
  terminationReason = "terminated";
1059
+ timings.turns.push(turnMetrics);
1039
1060
  break;
1040
1061
  }
1041
1062
  const finishCalls = toolCalls.filter((c) => c.name === "finish");
@@ -1076,7 +1097,9 @@ async function runWarpGrep(config) {
1076
1097
  )
1077
1098
  );
1078
1099
  }
1100
+ const toolExecStart = Date.now();
1079
1101
  const allResults = await Promise.all(allPromises);
1102
+ turnMetrics.local_tools_ms = Date.now() - toolExecStart;
1080
1103
  for (const result of allResults) {
1081
1104
  formatted.push(result);
1082
1105
  }
@@ -1085,6 +1108,7 @@ async function runWarpGrep(config) {
1085
1108
  const contextBudget = calculateContextBudget(messages);
1086
1109
  messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
1087
1110
  }
1111
+ timings.turns.push(turnMetrics);
1088
1112
  if (finishCalls.length) {
1089
1113
  const fc = finishCalls[0];
1090
1114
  const files = fc.arguments?.files ?? [];
@@ -1094,7 +1118,8 @@ async function runWarpGrep(config) {
1094
1118
  }
1095
1119
  }
1096
1120
  if (terminationReason !== "completed" || !finishMeta) {
1097
- return { terminationReason, messages, errors };
1121
+ timings.total_ms = Date.now() - totalStart;
1122
+ return { terminationReason, messages, errors, timings };
1098
1123
  }
1099
1124
  const parts = ["Relevant context found:"];
1100
1125
  for (const f of finishMeta.files) {
@@ -1102,6 +1127,7 @@ async function runWarpGrep(config) {
1102
1127
  parts.push(`- ${f.path}: ${ranges}`);
1103
1128
  }
1104
1129
  const payload = parts.join("\n");
1130
+ const finishResolutionStart = Date.now();
1105
1131
  const fileReadErrors = [];
1106
1132
  const resolved = await readFinishFiles(
1107
1133
  repoRoot,
@@ -1121,13 +1147,16 @@ async function runWarpGrep(config) {
1121
1147
  }
1122
1148
  }
1123
1149
  );
1150
+ timings.finish_resolution_ms = Date.now() - finishResolutionStart;
1124
1151
  if (fileReadErrors.length > 0) {
1125
1152
  errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
1126
1153
  }
1154
+ timings.total_ms = Date.now() - totalStart;
1127
1155
  return {
1128
1156
  terminationReason: "completed",
1129
1157
  messages,
1130
- finish: { payload, metadata: finishMeta, resolved }
1158
+ finish: { payload, metadata: finishMeta, resolved },
1159
+ timings
1131
1160
  };
1132
1161
  }
1133
1162