@morphllm/morphsdk 0.2.83 → 0.2.85

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 (64) hide show
  1. package/dist/{chunk-HRK53IKL.js → chunk-37SJ3IOY.js} +63 -42
  2. package/dist/chunk-37SJ3IOY.js.map +1 -0
  3. package/dist/{chunk-S27A4NQM.js → chunk-5X7IJXKA.js} +2 -2
  4. package/dist/{chunk-RL4JBZ3T.js → chunk-AJEE5RRB.js} +2 -2
  5. package/dist/{chunk-QOYI77CN.js → chunk-HJOMBO2A.js} +154 -3
  6. package/dist/chunk-HJOMBO2A.js.map +1 -0
  7. package/dist/{chunk-LXG37353.js → chunk-IXNX4HMC.js} +2 -2
  8. package/dist/{chunk-P2O5JKE5.js → chunk-KRDIR7GG.js} +17 -8
  9. package/dist/chunk-KRDIR7GG.js.map +1 -0
  10. package/dist/{chunk-FY32COVL.js → chunk-L5C6E32T.js} +1 -1
  11. package/dist/{chunk-FY32COVL.js.map → chunk-L5C6E32T.js.map} +1 -1
  12. package/dist/{chunk-HPR6BJA7.js → chunk-SQF3OG24.js} +5 -5
  13. package/dist/{client-CsO9LifG.d.ts → client-Drz3OGq-.d.ts} +1 -1
  14. package/dist/client.cjs +220 -44
  15. package/dist/client.cjs.map +1 -1
  16. package/dist/client.d.ts +3 -2
  17. package/dist/client.js +7 -7
  18. package/dist/index.cjs +220 -44
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +8 -8
  22. package/dist/tools/warp_grep/agent/runner.cjs +170 -9
  23. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  24. package/dist/tools/warp_grep/agent/runner.d.ts +9 -2
  25. package/dist/tools/warp_grep/agent/runner.js +6 -4
  26. package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
  27. package/dist/tools/warp_grep/agent/types.d.ts +12 -1
  28. package/dist/tools/warp_grep/anthropic.cjs +16 -7
  29. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  30. package/dist/tools/warp_grep/anthropic.d.ts +3 -2
  31. package/dist/tools/warp_grep/anthropic.js +4 -4
  32. package/dist/tools/warp_grep/client.cjs +225 -46
  33. package/dist/tools/warp_grep/client.cjs.map +1 -1
  34. package/dist/tools/warp_grep/client.d.ts +39 -6
  35. package/dist/tools/warp_grep/client.js +3 -3
  36. package/dist/tools/warp_grep/gemini.cjs +16 -7
  37. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  38. package/dist/tools/warp_grep/gemini.d.ts +3 -2
  39. package/dist/tools/warp_grep/gemini.js +3 -3
  40. package/dist/tools/warp_grep/harness.cjs +16 -7
  41. package/dist/tools/warp_grep/harness.cjs.map +1 -1
  42. package/dist/tools/warp_grep/harness.js +1 -1
  43. package/dist/tools/warp_grep/index.cjs +227 -46
  44. package/dist/tools/warp_grep/index.cjs.map +1 -1
  45. package/dist/tools/warp_grep/index.d.ts +3 -3
  46. package/dist/tools/warp_grep/index.js +7 -5
  47. package/dist/tools/warp_grep/openai.cjs +16 -7
  48. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  49. package/dist/tools/warp_grep/openai.d.ts +3 -2
  50. package/dist/tools/warp_grep/openai.js +4 -4
  51. package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
  52. package/dist/tools/warp_grep/vercel.cjs +16 -7
  53. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  54. package/dist/tools/warp_grep/vercel.d.ts +2 -1
  55. package/dist/tools/warp_grep/vercel.js +4 -4
  56. package/dist/{types-Cv4LpqVl.d.ts → types-BMowL9iZ.d.ts} +5 -0
  57. package/package.json +1 -1
  58. package/dist/chunk-HRK53IKL.js.map +0 -1
  59. package/dist/chunk-P2O5JKE5.js.map +0 -1
  60. package/dist/chunk-QOYI77CN.js.map +0 -1
  61. /package/dist/{chunk-S27A4NQM.js.map → chunk-5X7IJXKA.js.map} +0 -0
  62. /package/dist/{chunk-RL4JBZ3T.js.map → chunk-AJEE5RRB.js.map} +0 -0
  63. /package/dist/{chunk-LXG37353.js.map → chunk-IXNX4HMC.js.map} +0 -0
  64. /package/dist/{chunk-HPR6BJA7.js.map → chunk-SQF3OG24.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- export { A as AnthropicToolFactory, M as MorphClient, a as MorphClientConfig, O as OpenAIToolFactory, V as VercelToolFactory } from './client-CsO9LifG.js';
1
+ export { A as AnthropicToolFactory, M as MorphClient, a as MorphClientConfig, O as OpenAIToolFactory, V as VercelToolFactory } from './client-Drz3OGq-.js';
2
2
  export { FastApplyClient, applyEdit } from './tools/fastapply/core.js';
3
3
  export { CodebaseSearchClient } from './tools/codebase_search/core.js';
4
4
  export { WarpGrepClient } from './tools/warp_grep/client.js';
5
5
  export { BrowserClient } from './tools/browser/core.js';
6
6
  export { MorphGit } from './git/client.js';
7
7
  export { MorphGitConfig } from './git/types.js';
8
- export { W as WarpGrepClientConfig, c as WarpGrepContext, a as WarpGrepInput, b as WarpGrepResult, d as WarpGrepToolConfig } from './types-Cv4LpqVl.js';
8
+ export { W as WarpGrepClientConfig, c as WarpGrepContext, a as WarpGrepInput, b as WarpGrepResult, d as WarpGrepToolConfig } from './types-BMowL9iZ.js';
9
9
  export { GrepResult, ListDirectoryEntry, ReadResult, WarpGrepProvider } from './tools/warp_grep/providers/types.js';
10
10
  export { LocalRipgrepProvider } from './tools/warp_grep/providers/local.js';
11
- export { AgentRunResult, ChatMessage, SessionConfig } from './tools/warp_grep/agent/types.js';
11
+ export { AgentRunResult, ChatMessage, SessionConfig, WarpGrepStep } from './tools/warp_grep/agent/types.js';
12
12
  export { AnthropicRouter, GeminiRouter, OpenAIRouter, RawRouter } from './modelrouter/core.js';
13
13
  export { ApplyEditConfig, ApplyEditInput, ApplyEditResult, EditChanges, EditFileConfig, EditFileInput, EditFileResult } from './tools/fastapply/types.js';
14
14
  export { CodeSearchResult, CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult, SearchStats } from './tools/codebase_search/types.js';
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
- import "./chunk-FY32COVL.js";
1
+ import "./chunk-L5C6E32T.js";
2
2
  import {
3
3
  AnthropicToolFactory,
4
4
  MorphClient,
5
5
  OpenAIToolFactory,
6
6
  VercelToolFactory
7
- } from "./chunk-HPR6BJA7.js";
8
- import "./chunk-RL4JBZ3T.js";
9
- import "./chunk-LXG37353.js";
10
- import "./chunk-S27A4NQM.js";
7
+ } from "./chunk-SQF3OG24.js";
8
+ import "./chunk-AJEE5RRB.js";
9
+ import "./chunk-IXNX4HMC.js";
10
+ import "./chunk-5X7IJXKA.js";
11
11
  import "./chunk-KW7OEGZK.js";
12
12
  import {
13
13
  WarpGrepClient
14
- } from "./chunk-HRK53IKL.js";
15
- import "./chunk-QOYI77CN.js";
14
+ } from "./chunk-37SJ3IOY.js";
15
+ import "./chunk-HJOMBO2A.js";
16
16
  import "./chunk-PUGSTXLO.js";
17
- import "./chunk-P2O5JKE5.js";
17
+ import "./chunk-KRDIR7GG.js";
18
18
  import "./chunk-APP75CBN.js";
19
19
  import "./chunk-5QRN3JNB.js";
20
20
  import "./chunk-FMLHRJDF.js";
@@ -30,7 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // tools/warp_grep/agent/runner.ts
31
31
  var runner_exports = {};
32
32
  __export(runner_exports, {
33
- runWarpGrep: () => runWarpGrep
33
+ runWarpGrep: () => runWarpGrep,
34
+ runWarpGrepStreaming: () => runWarpGrepStreaming
34
35
  });
35
36
  module.exports = __toCommonJS(runner_exports);
36
37
 
@@ -645,14 +646,23 @@ async function toolRead(provider, args) {
645
646
 
646
647
  // tools/warp_grep/agent/tools/list_directory.ts
647
648
  async function toolListDirectory(provider, args) {
648
- const list = await provider.listDirectory({
649
- path: args.path,
650
- pattern: args.pattern ?? null,
651
- maxResults: args.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES,
652
- maxDepth: args.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH
653
- });
649
+ const maxResults = args.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES;
650
+ const initialDepth = args.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
651
+ async function getListRecursive(currentDepth) {
652
+ const entries = await provider.listDirectory({
653
+ path: args.path,
654
+ pattern: args.pattern ?? null,
655
+ maxResults,
656
+ maxDepth: currentDepth
657
+ });
658
+ if (entries.length >= maxResults && currentDepth > 0) {
659
+ return getListRecursive(currentDepth - 1);
660
+ }
661
+ return { entries };
662
+ }
663
+ const { entries: list } = await getListRecursive(initialDepth);
654
664
  if (!list.length) return "empty";
655
- if (list.length >= AGENT_CONFIG.MAX_OUTPUT_LINES) {
665
+ if (list.length >= maxResults) {
656
666
  return "query not specific enough, tool called tried to return too much context and failed";
657
667
  }
658
668
  return list.map((e) => {
@@ -1146,8 +1156,159 @@ async function runWarpGrep(config) {
1146
1156
  timings
1147
1157
  };
1148
1158
  }
1159
+ async function* runWarpGrepStreaming(config) {
1160
+ const totalStart = Date.now();
1161
+ const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
1162
+ const timings = { turns: [], timeout_ms: timeoutMs };
1163
+ const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
1164
+ const messages = [];
1165
+ messages.push({ role: "system", content: getSystemPrompt() });
1166
+ const initialStateStart = Date.now();
1167
+ const initialState = await buildInitialState(repoRoot, config.query, config.provider);
1168
+ timings.initial_state_ms = Date.now() - initialStateStart;
1169
+ messages.push({ role: "user", content: initialState });
1170
+ const maxTurns = AGENT_CONFIG.MAX_TURNS;
1171
+ const model = config.model || DEFAULT_MODEL;
1172
+ const provider = config.provider;
1173
+ const errors = [];
1174
+ let finishMeta;
1175
+ let terminationReason = "terminated";
1176
+ for (let turn = 1; turn <= maxTurns; turn += 1) {
1177
+ const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
1178
+ enforceContextLimit(messages);
1179
+ const modelCallStart = Date.now();
1180
+ const assistantContent = await callModel(messages, model, {
1181
+ morphApiKey: config.morphApiKey,
1182
+ morphApiUrl: config.morphApiUrl,
1183
+ retryConfig: config.retryConfig,
1184
+ timeout: timeoutMs
1185
+ }).catch((e) => {
1186
+ errors.push({ message: e instanceof Error ? e.message : String(e) });
1187
+ return "";
1188
+ });
1189
+ turnMetrics.morph_api_ms = Date.now() - modelCallStart;
1190
+ if (!assistantContent) {
1191
+ timings.turns.push(turnMetrics);
1192
+ break;
1193
+ }
1194
+ messages.push({ role: "assistant", content: assistantContent });
1195
+ const toolCalls = parser.parse(assistantContent);
1196
+ if (toolCalls.length === 0) {
1197
+ 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" });
1198
+ terminationReason = "terminated";
1199
+ timings.turns.push(turnMetrics);
1200
+ break;
1201
+ }
1202
+ yield {
1203
+ turn,
1204
+ toolCalls: toolCalls.map((c) => ({
1205
+ name: c.name,
1206
+ arguments: c.arguments ?? {}
1207
+ }))
1208
+ };
1209
+ const finishCalls = toolCalls.filter((c) => c.name === "finish");
1210
+ const grepCalls = toolCalls.filter((c) => c.name === "grep");
1211
+ const listDirCalls = toolCalls.filter((c) => c.name === "list_directory");
1212
+ const readCalls = toolCalls.filter((c) => c.name === "read");
1213
+ const skipCalls = toolCalls.filter((c) => c.name === "_skip");
1214
+ const formatted = [];
1215
+ for (const c of skipCalls) {
1216
+ const msg = c.arguments?.message || "Command skipped due to parsing error";
1217
+ formatted.push(msg);
1218
+ }
1219
+ const allPromises = [];
1220
+ for (const c of grepCalls) {
1221
+ const args = c.arguments ?? {};
1222
+ allPromises.push(
1223
+ toolGrep(provider, args).then(
1224
+ ({ output }) => formatAgentToolOutput("grep", args, output, { isError: false }),
1225
+ (err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
1226
+ )
1227
+ );
1228
+ }
1229
+ for (const c of listDirCalls) {
1230
+ const args = c.arguments ?? {};
1231
+ allPromises.push(
1232
+ toolListDirectory(provider, args).then(
1233
+ (p) => formatAgentToolOutput("list_directory", args, p, { isError: false }),
1234
+ (err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
1235
+ )
1236
+ );
1237
+ }
1238
+ for (const c of readCalls) {
1239
+ const args = c.arguments ?? {};
1240
+ allPromises.push(
1241
+ toolRead(provider, args).then(
1242
+ (p) => formatAgentToolOutput("read", args, p, { isError: false }),
1243
+ (err) => formatAgentToolOutput("read", args, String(err), { isError: true })
1244
+ )
1245
+ );
1246
+ }
1247
+ const toolExecStart = Date.now();
1248
+ const allResults = await Promise.all(allPromises);
1249
+ turnMetrics.local_tools_ms = Date.now() - toolExecStart;
1250
+ for (const result of allResults) {
1251
+ formatted.push(result);
1252
+ }
1253
+ if (formatted.length > 0) {
1254
+ const turnMessage = formatTurnMessage(turn, maxTurns);
1255
+ const contextBudget = calculateContextBudget(messages);
1256
+ messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
1257
+ }
1258
+ timings.turns.push(turnMetrics);
1259
+ if (finishCalls.length) {
1260
+ const fc = finishCalls[0];
1261
+ const files = fc.arguments?.files ?? [];
1262
+ finishMeta = { files };
1263
+ terminationReason = "completed";
1264
+ break;
1265
+ }
1266
+ }
1267
+ if (terminationReason !== "completed" || !finishMeta) {
1268
+ timings.total_ms = Date.now() - totalStart;
1269
+ return { terminationReason, messages, errors, timings };
1270
+ }
1271
+ const parts = ["Relevant context found:"];
1272
+ for (const f of finishMeta.files) {
1273
+ const ranges = f.lines === "*" ? "*" : Array.isArray(f.lines) ? f.lines.map(([s, e]) => `${s}-${e}`).join(", ") : "*";
1274
+ parts.push(`- ${f.path}: ${ranges}`);
1275
+ }
1276
+ const payload = parts.join("\n");
1277
+ const finishResolutionStart = Date.now();
1278
+ const fileReadErrors = [];
1279
+ const resolved = await readFinishFiles(
1280
+ repoRoot,
1281
+ finishMeta.files,
1282
+ async (p, s, e) => {
1283
+ try {
1284
+ const rr = await provider.read({ path: p, start: s, end: e });
1285
+ return rr.lines.map((l) => {
1286
+ const idx = l.indexOf("|");
1287
+ return idx >= 0 ? l.slice(idx + 1) : l;
1288
+ });
1289
+ } catch (err) {
1290
+ const errorMsg = err instanceof Error ? err.message : String(err);
1291
+ fileReadErrors.push({ path: p, error: errorMsg });
1292
+ console.error(`[warp_grep] Failed to read file: ${p} - ${errorMsg}`);
1293
+ return [`[couldn't find: ${p}]`];
1294
+ }
1295
+ }
1296
+ );
1297
+ timings.finish_resolution_ms = Date.now() - finishResolutionStart;
1298
+ if (fileReadErrors.length > 0) {
1299
+ errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
1300
+ }
1301
+ timings.total_ms = Date.now() - totalStart;
1302
+ return {
1303
+ terminationReason: "completed",
1304
+ messages,
1305
+ finish: { payload, metadata: finishMeta, resolved },
1306
+ timings
1307
+ };
1308
+ }
1149
1309
  // Annotate the CommonJS export names for ESM import in node:
1150
1310
  0 && (module.exports = {
1151
- runWarpGrep
1311
+ runWarpGrep,
1312
+ runWarpGrepStreaming
1152
1313
  });
1153
1314
  //# sourceMappingURL=runner.cjs.map