@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
package/dist/client.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  MorphClient
3
- } from "./chunk-EK5ZEOI3.js";
4
- import "./chunk-ZLJAODDJ.js";
5
- import "./chunk-24EYSWME.js";
6
- import "./chunk-3ONNAQZU.js";
3
+ } from "./chunk-N3RNM4A4.js";
4
+ import "./chunk-262WRPS5.js";
5
+ import "./chunk-LX2WNS3L.js";
6
+ import "./chunk-MJ7JODAY.js";
7
7
  import "./chunk-KW7OEGZK.js";
8
- import "./chunk-FJKPMMNQ.js";
9
- import "./chunk-WIAYUEJK.js";
8
+ import "./chunk-D4EQYM6O.js";
9
+ import "./chunk-LF2X6YNP.js";
10
10
  import "./chunk-PUGSTXLO.js";
11
- import "./chunk-P2O5JKE5.js";
11
+ import "./chunk-KRDIR7GG.js";
12
12
  import "./chunk-APP75CBN.js";
13
13
  import "./chunk-5QRN3JNB.js";
14
14
  import "./chunk-FMLHRJDF.js";
package/dist/index.cjs CHANGED
@@ -1611,14 +1611,23 @@ async function toolRead(provider, args) {
1611
1611
 
1612
1612
  // tools/warp_grep/agent/tools/list_directory.ts
1613
1613
  async function toolListDirectory(provider, args) {
1614
- const list = await provider.listDirectory({
1615
- path: args.path,
1616
- pattern: args.pattern ?? null,
1617
- maxResults: args.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES,
1618
- maxDepth: args.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH
1619
- });
1614
+ const maxResults = args.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES;
1615
+ const initialDepth = args.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
1616
+ async function getListRecursive(currentDepth) {
1617
+ const entries = await provider.listDirectory({
1618
+ path: args.path,
1619
+ pattern: args.pattern ?? null,
1620
+ maxResults,
1621
+ maxDepth: currentDepth
1622
+ });
1623
+ if (entries.length >= maxResults && currentDepth > 0) {
1624
+ return getListRecursive(currentDepth - 1);
1625
+ }
1626
+ return { entries };
1627
+ }
1628
+ const { entries: list } = await getListRecursive(initialDepth);
1620
1629
  if (!list.length) return "empty";
1621
- if (list.length >= AGENT_CONFIG.MAX_OUTPUT_LINES) {
1630
+ if (list.length >= maxResults) {
1622
1631
  return "query not specific enough, tool called tried to return too much context and failed";
1623
1632
  }
1624
1633
  return list.map((e) => {
@@ -1896,10 +1905,15 @@ async function callModel(messages, model, options = {}) {
1896
1905
  return content;
1897
1906
  }
1898
1907
  async function runWarpGrep(config) {
1908
+ const totalStart = Date.now();
1909
+ const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
1910
+ const timings = { turns: [], timeout_ms: timeoutMs };
1899
1911
  const repoRoot = import_path3.default.resolve(config.repoRoot || process.cwd());
1900
1912
  const messages = [];
1901
1913
  messages.push({ role: "system", content: getSystemPrompt() });
1914
+ const initialStateStart = Date.now();
1902
1915
  const initialState = await buildInitialState(repoRoot, config.query, config.provider);
1916
+ timings.initial_state_ms = Date.now() - initialStateStart;
1903
1917
  messages.push({ role: "user", content: initialState });
1904
1918
  const maxTurns = AGENT_CONFIG.MAX_TURNS;
1905
1919
  const model = config.model || DEFAULT_MODEL;
@@ -1908,22 +1922,29 @@ async function runWarpGrep(config) {
1908
1922
  let finishMeta;
1909
1923
  let terminationReason = "terminated";
1910
1924
  for (let turn = 1; turn <= maxTurns; turn += 1) {
1925
+ const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
1911
1926
  enforceContextLimit(messages);
1927
+ const modelCallStart = Date.now();
1912
1928
  const assistantContent = await callModel(messages, model, {
1913
1929
  morphApiKey: config.morphApiKey,
1914
1930
  morphApiUrl: config.morphApiUrl,
1915
1931
  retryConfig: config.retryConfig,
1916
- timeout: config.timeout
1932
+ timeout: timeoutMs
1917
1933
  }).catch((e) => {
1918
1934
  errors.push({ message: e instanceof Error ? e.message : String(e) });
1919
1935
  return "";
1920
1936
  });
1921
- if (!assistantContent) break;
1937
+ turnMetrics.morph_api_ms = Date.now() - modelCallStart;
1938
+ if (!assistantContent) {
1939
+ timings.turns.push(turnMetrics);
1940
+ break;
1941
+ }
1922
1942
  messages.push({ role: "assistant", content: assistantContent });
1923
1943
  const toolCalls = parser.parse(assistantContent);
1924
1944
  if (toolCalls.length === 0) {
1925
1945
  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" });
1926
1946
  terminationReason = "terminated";
1947
+ timings.turns.push(turnMetrics);
1927
1948
  break;
1928
1949
  }
1929
1950
  const finishCalls = toolCalls.filter((c) => c.name === "finish");
@@ -1964,7 +1985,9 @@ async function runWarpGrep(config) {
1964
1985
  )
1965
1986
  );
1966
1987
  }
1988
+ const toolExecStart = Date.now();
1967
1989
  const allResults = await Promise.all(allPromises);
1990
+ turnMetrics.local_tools_ms = Date.now() - toolExecStart;
1968
1991
  for (const result of allResults) {
1969
1992
  formatted.push(result);
1970
1993
  }
@@ -1973,6 +1996,7 @@ async function runWarpGrep(config) {
1973
1996
  const contextBudget = calculateContextBudget(messages);
1974
1997
  messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
1975
1998
  }
1999
+ timings.turns.push(turnMetrics);
1976
2000
  if (finishCalls.length) {
1977
2001
  const fc = finishCalls[0];
1978
2002
  const files = fc.arguments?.files ?? [];
@@ -1982,7 +2006,8 @@ async function runWarpGrep(config) {
1982
2006
  }
1983
2007
  }
1984
2008
  if (terminationReason !== "completed" || !finishMeta) {
1985
- return { terminationReason, messages, errors };
2009
+ timings.total_ms = Date.now() - totalStart;
2010
+ return { terminationReason, messages, errors, timings };
1986
2011
  }
1987
2012
  const parts = ["Relevant context found:"];
1988
2013
  for (const f of finishMeta.files) {
@@ -1990,6 +2015,7 @@ async function runWarpGrep(config) {
1990
2015
  parts.push(`- ${f.path}: ${ranges}`);
1991
2016
  }
1992
2017
  const payload = parts.join("\n");
2018
+ const finishResolutionStart = Date.now();
1993
2019
  const fileReadErrors = [];
1994
2020
  const resolved = await readFinishFiles(
1995
2021
  repoRoot,
@@ -2009,13 +2035,16 @@ async function runWarpGrep(config) {
2009
2035
  }
2010
2036
  }
2011
2037
  );
2038
+ timings.finish_resolution_ms = Date.now() - finishResolutionStart;
2012
2039
  if (fileReadErrors.length > 0) {
2013
2040
  errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
2014
2041
  }
2042
+ timings.total_ms = Date.now() - totalStart;
2015
2043
  return {
2016
2044
  terminationReason: "completed",
2017
2045
  messages,
2018
- finish: { payload, metadata: finishMeta, resolved }
2046
+ finish: { payload, metadata: finishMeta, resolved },
2047
+ timings
2019
2048
  };
2020
2049
  }
2021
2050