@morphllm/morphsdk 0.2.125 → 0.2.127

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 (219) hide show
  1. package/dist/{chunk-DGYWACHC.js → chunk-3ZA7Y66U.js} +2 -2
  2. package/dist/{chunk-5L3TPS6A.js → chunk-6DRIR7AI.js} +5 -4
  3. package/dist/chunk-6DRIR7AI.js.map +1 -0
  4. package/dist/{chunk-G5YJDK5S.js → chunk-ADHGSV2D.js} +2 -2
  5. package/dist/{chunk-5PNMAWLC.js → chunk-DKODF3YG.js} +2 -2
  6. package/dist/{chunk-5PNMAWLC.js.map → chunk-DKODF3YG.js.map} +1 -1
  7. package/dist/{chunk-BQO3WODX.js → chunk-DS7YL4V3.js} +8 -13
  8. package/dist/chunk-DS7YL4V3.js.map +1 -0
  9. package/dist/{chunk-FEQJCZJQ.js → chunk-EGOCFCAH.js} +2 -2
  10. package/dist/{chunk-TFK4UOUE.js → chunk-EL6CCK7C.js} +6 -6
  11. package/dist/{chunk-IB4MEIQG.js → chunk-GDCVK6SP.js} +2 -2
  12. package/dist/{chunk-UGSV5LPO.js → chunk-GVF4Q75N.js} +2 -2
  13. package/dist/{chunk-TS3E6IRI.js → chunk-GWKCMFD6.js} +2 -2
  14. package/dist/{chunk-WZAZFW77.js → chunk-HZK5TEUK.js} +1 -1
  15. package/dist/{chunk-EF7ZYLA2.js → chunk-HZOTLGJH.js} +19 -12
  16. package/dist/chunk-HZOTLGJH.js.map +1 -0
  17. package/dist/{chunk-3MLWXJTJ.js → chunk-K2FXHDX2.js} +15 -10
  18. package/dist/chunk-K2FXHDX2.js.map +1 -0
  19. package/dist/{chunk-FAZO2LNY.js → chunk-K6YSD3DR.js} +2 -2
  20. package/dist/{chunk-ACHEU2V3.js → chunk-LX34ZO3N.js} +2 -2
  21. package/dist/{chunk-OFQRY3RM.js → chunk-LXBIP5FI.js} +18 -23
  22. package/dist/chunk-LXBIP5FI.js.map +1 -0
  23. package/dist/{chunk-F6HNFC2H.js → chunk-MJHAVXFK.js} +2 -2
  24. package/dist/{chunk-PUGSTXLO.js → chunk-NF2QWJDY.js} +6 -7
  25. package/dist/chunk-NF2QWJDY.js.map +1 -0
  26. package/dist/{chunk-6TH3VNCF.js → chunk-NQQS5BZZ.js} +3 -3
  27. package/dist/{chunk-V3HLOZK2.js → chunk-QLBRTLEI.js} +1 -1
  28. package/dist/{chunk-V3HLOZK2.js.map → chunk-QLBRTLEI.js.map} +1 -1
  29. package/dist/{chunk-57PXQ6IS.js → chunk-QOE522DB.js} +15 -15
  30. package/dist/chunk-QRXG5CAZ.js +27 -0
  31. package/dist/chunk-QRXG5CAZ.js.map +1 -0
  32. package/dist/{chunk-7RTJCQWB.js → chunk-QUULFOWB.js} +10 -5
  33. package/dist/chunk-QUULFOWB.js.map +1 -0
  34. package/dist/{chunk-33CP5QCC.js → chunk-R5IFI552.js} +3 -3
  35. package/dist/{chunk-33CP5QCC.js.map → chunk-R5IFI552.js.map} +1 -1
  36. package/dist/{chunk-IRNUW2DB.js → chunk-REJNS3OW.js} +8 -13
  37. package/dist/chunk-REJNS3OW.js.map +1 -0
  38. package/dist/{chunk-2S7ZQFIB.js → chunk-U73OIAJC.js} +2 -2
  39. package/dist/{chunk-OQGX4RZP.js → chunk-UAQ7UWZB.js} +2 -2
  40. package/dist/chunk-VCKJ22DX.js +131 -0
  41. package/dist/chunk-VCKJ22DX.js.map +1 -0
  42. package/dist/{chunk-2MK64KK4.js → chunk-YTUQEDWH.js} +2 -2
  43. package/dist/{chunk-H6KT7IXW.js → chunk-ZVAXTR2V.js} +2 -2
  44. package/dist/{chunk-BGL35LL6.js → chunk-ZYD2SEQK.js} +2 -2
  45. package/dist/{client-JHPwle1Z.d.ts → client-CNYzlN_6.d.ts} +6 -7
  46. package/dist/client.cjs +166 -579
  47. package/dist/client.cjs.map +1 -1
  48. package/dist/client.d.ts +1 -2
  49. package/dist/client.js +27 -28
  50. package/dist/edge.cjs +2 -2
  51. package/dist/edge.cjs.map +1 -1
  52. package/dist/edge.js +4 -4
  53. package/dist/{finish-pPJfB0uO.d.ts → finish-DBKuo8yj.d.ts} +2 -0
  54. package/dist/index.cjs +166 -579
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.d.ts +1 -2
  57. package/dist/index.js +29 -30
  58. package/dist/modelrouter/core.cjs +2 -2
  59. package/dist/modelrouter/core.cjs.map +1 -1
  60. package/dist/modelrouter/core.js +3 -3
  61. package/dist/modelrouter/index.cjs +2 -2
  62. package/dist/modelrouter/index.cjs.map +1 -1
  63. package/dist/modelrouter/index.js +3 -3
  64. package/dist/tools/browser/anthropic.cjs +2 -2
  65. package/dist/tools/browser/anthropic.cjs.map +1 -1
  66. package/dist/tools/browser/anthropic.js +5 -5
  67. package/dist/tools/browser/core.cjs +2 -2
  68. package/dist/tools/browser/core.cjs.map +1 -1
  69. package/dist/tools/browser/core.js +4 -4
  70. package/dist/tools/browser/index.cjs +2 -2
  71. package/dist/tools/browser/index.cjs.map +1 -1
  72. package/dist/tools/browser/index.js +7 -7
  73. package/dist/tools/browser/openai.cjs +2 -2
  74. package/dist/tools/browser/openai.cjs.map +1 -1
  75. package/dist/tools/browser/openai.js +5 -5
  76. package/dist/tools/browser/profiles/core.cjs +2 -2
  77. package/dist/tools/browser/profiles/core.cjs.map +1 -1
  78. package/dist/tools/browser/profiles/core.js +3 -3
  79. package/dist/tools/browser/profiles/index.cjs +2 -2
  80. package/dist/tools/browser/profiles/index.cjs.map +1 -1
  81. package/dist/tools/browser/profiles/index.js +3 -3
  82. package/dist/tools/browser/vercel.cjs +2 -2
  83. package/dist/tools/browser/vercel.cjs.map +1 -1
  84. package/dist/tools/browser/vercel.js +5 -5
  85. package/dist/tools/codebase_search/anthropic.cjs +2 -2
  86. package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
  87. package/dist/tools/codebase_search/anthropic.js +4 -4
  88. package/dist/tools/codebase_search/core.cjs +2 -2
  89. package/dist/tools/codebase_search/core.cjs.map +1 -1
  90. package/dist/tools/codebase_search/core.js +3 -3
  91. package/dist/tools/codebase_search/index.cjs +2 -2
  92. package/dist/tools/codebase_search/index.cjs.map +1 -1
  93. package/dist/tools/codebase_search/index.js +6 -6
  94. package/dist/tools/codebase_search/openai.cjs +2 -2
  95. package/dist/tools/codebase_search/openai.cjs.map +1 -1
  96. package/dist/tools/codebase_search/openai.js +4 -4
  97. package/dist/tools/codebase_search/vercel.cjs +2 -2
  98. package/dist/tools/codebase_search/vercel.cjs.map +1 -1
  99. package/dist/tools/codebase_search/vercel.js +4 -4
  100. package/dist/tools/fastapply/anthropic.cjs +2 -2
  101. package/dist/tools/fastapply/anthropic.cjs.map +1 -1
  102. package/dist/tools/fastapply/anthropic.js +4 -4
  103. package/dist/tools/fastapply/apply.cjs +2 -2
  104. package/dist/tools/fastapply/apply.cjs.map +1 -1
  105. package/dist/tools/fastapply/apply.js +2 -2
  106. package/dist/tools/fastapply/core.cjs +2 -2
  107. package/dist/tools/fastapply/core.cjs.map +1 -1
  108. package/dist/tools/fastapply/core.js +3 -3
  109. package/dist/tools/fastapply/index.cjs +2 -2
  110. package/dist/tools/fastapply/index.cjs.map +1 -1
  111. package/dist/tools/fastapply/index.js +6 -6
  112. package/dist/tools/fastapply/openai.cjs +2 -2
  113. package/dist/tools/fastapply/openai.cjs.map +1 -1
  114. package/dist/tools/fastapply/openai.js +4 -4
  115. package/dist/tools/fastapply/vercel.cjs +2 -2
  116. package/dist/tools/fastapply/vercel.cjs.map +1 -1
  117. package/dist/tools/fastapply/vercel.js +4 -4
  118. package/dist/tools/index.cjs +2 -2
  119. package/dist/tools/index.cjs.map +1 -1
  120. package/dist/tools/index.js +6 -6
  121. package/dist/tools/utils/resilience.cjs +2 -2
  122. package/dist/tools/utils/resilience.cjs.map +1 -1
  123. package/dist/tools/utils/resilience.js +2 -2
  124. package/dist/tools/warp_grep/agent/config.cjs +1 -1
  125. package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
  126. package/dist/tools/warp_grep/agent/config.d.ts +1 -1
  127. package/dist/tools/warp_grep/agent/config.js +1 -1
  128. package/dist/tools/warp_grep/agent/formatter.cjs +3 -74
  129. package/dist/tools/warp_grep/agent/formatter.cjs.map +1 -1
  130. package/dist/tools/warp_grep/agent/formatter.d.ts +1 -5
  131. package/dist/tools/warp_grep/agent/formatter.js +1 -1
  132. package/dist/tools/warp_grep/agent/parser.cjs +91 -242
  133. package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
  134. package/dist/tools/warp_grep/agent/parser.d.ts +0 -8
  135. package/dist/tools/warp_grep/agent/parser.js +1 -1
  136. package/dist/tools/warp_grep/agent/runner.cjs +122 -543
  137. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  138. package/dist/tools/warp_grep/agent/runner.js +6 -7
  139. package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
  140. package/dist/tools/warp_grep/agent/types.d.ts +2 -0
  141. package/dist/tools/warp_grep/anthropic.cjs +152 -570
  142. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  143. package/dist/tools/warp_grep/anthropic.d.ts +2 -4
  144. package/dist/tools/warp_grep/anthropic.js +11 -15
  145. package/dist/tools/warp_grep/client.cjs +143 -558
  146. package/dist/tools/warp_grep/client.cjs.map +1 -1
  147. package/dist/tools/warp_grep/client.js +9 -10
  148. package/dist/tools/warp_grep/gemini.cjs +152 -570
  149. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  150. package/dist/tools/warp_grep/gemini.d.ts +2 -4
  151. package/dist/tools/warp_grep/gemini.js +18 -23
  152. package/dist/tools/warp_grep/gemini.js.map +1 -1
  153. package/dist/tools/warp_grep/harness.cjs +124 -540
  154. package/dist/tools/warp_grep/harness.cjs.map +1 -1
  155. package/dist/tools/warp_grep/harness.d.ts +4 -5
  156. package/dist/tools/warp_grep/harness.js +5 -11
  157. package/dist/tools/warp_grep/harness.js.map +1 -1
  158. package/dist/tools/warp_grep/index.cjs +147 -565
  159. package/dist/tools/warp_grep/index.cjs.map +1 -1
  160. package/dist/tools/warp_grep/index.d.ts +7 -4
  161. package/dist/tools/warp_grep/index.js +14 -20
  162. package/dist/tools/warp_grep/openai.cjs +152 -570
  163. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  164. package/dist/tools/warp_grep/openai.d.ts +2 -4
  165. package/dist/tools/warp_grep/openai.js +11 -15
  166. package/dist/tools/warp_grep/providers/local.cjs +17 -10
  167. package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
  168. package/dist/tools/warp_grep/providers/local.d.ts +6 -1
  169. package/dist/tools/warp_grep/providers/local.js +2 -2
  170. package/dist/tools/warp_grep/providers/remote.cjs +4 -5
  171. package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
  172. package/dist/tools/warp_grep/providers/remote.js +2 -2
  173. package/dist/tools/warp_grep/providers/types.cjs.map +1 -1
  174. package/dist/tools/warp_grep/providers/types.d.ts +2 -0
  175. package/dist/tools/warp_grep/vercel.cjs +151 -563
  176. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  177. package/dist/tools/warp_grep/vercel.d.ts +2 -2
  178. package/dist/tools/warp_grep/vercel.js +11 -15
  179. package/dist/version.cjs +2 -2
  180. package/dist/version.cjs.map +1 -1
  181. package/dist/version.js +1 -1
  182. package/package.json +2 -2
  183. package/dist/chunk-3MLWXJTJ.js.map +0 -1
  184. package/dist/chunk-5L3TPS6A.js.map +0 -1
  185. package/dist/chunk-7RTJCQWB.js.map +0 -1
  186. package/dist/chunk-APP75CBN.js +0 -98
  187. package/dist/chunk-APP75CBN.js.map +0 -1
  188. package/dist/chunk-BQO3WODX.js.map +0 -1
  189. package/dist/chunk-EF7ZYLA2.js.map +0 -1
  190. package/dist/chunk-FMLHRJDF.js +0 -207
  191. package/dist/chunk-FMLHRJDF.js.map +0 -1
  192. package/dist/chunk-GHGJAQSJ.js +0 -282
  193. package/dist/chunk-GHGJAQSJ.js.map +0 -1
  194. package/dist/chunk-IRNUW2DB.js.map +0 -1
  195. package/dist/chunk-OFQRY3RM.js.map +0 -1
  196. package/dist/chunk-PUGSTXLO.js.map +0 -1
  197. package/dist/tools/warp_grep/agent/prompt.cjs +0 -232
  198. package/dist/tools/warp_grep/agent/prompt.cjs.map +0 -1
  199. package/dist/tools/warp_grep/agent/prompt.d.ts +0 -4
  200. package/dist/tools/warp_grep/agent/prompt.js +0 -10
  201. package/dist/tools/warp_grep/agent/prompt.js.map +0 -1
  202. /package/dist/{chunk-DGYWACHC.js.map → chunk-3ZA7Y66U.js.map} +0 -0
  203. /package/dist/{chunk-G5YJDK5S.js.map → chunk-ADHGSV2D.js.map} +0 -0
  204. /package/dist/{chunk-FEQJCZJQ.js.map → chunk-EGOCFCAH.js.map} +0 -0
  205. /package/dist/{chunk-TFK4UOUE.js.map → chunk-EL6CCK7C.js.map} +0 -0
  206. /package/dist/{chunk-IB4MEIQG.js.map → chunk-GDCVK6SP.js.map} +0 -0
  207. /package/dist/{chunk-UGSV5LPO.js.map → chunk-GVF4Q75N.js.map} +0 -0
  208. /package/dist/{chunk-TS3E6IRI.js.map → chunk-GWKCMFD6.js.map} +0 -0
  209. /package/dist/{chunk-WZAZFW77.js.map → chunk-HZK5TEUK.js.map} +0 -0
  210. /package/dist/{chunk-FAZO2LNY.js.map → chunk-K6YSD3DR.js.map} +0 -0
  211. /package/dist/{chunk-ACHEU2V3.js.map → chunk-LX34ZO3N.js.map} +0 -0
  212. /package/dist/{chunk-F6HNFC2H.js.map → chunk-MJHAVXFK.js.map} +0 -0
  213. /package/dist/{chunk-6TH3VNCF.js.map → chunk-NQQS5BZZ.js.map} +0 -0
  214. /package/dist/{chunk-57PXQ6IS.js.map → chunk-QOE522DB.js.map} +0 -0
  215. /package/dist/{chunk-2S7ZQFIB.js.map → chunk-U73OIAJC.js.map} +0 -0
  216. /package/dist/{chunk-OQGX4RZP.js.map → chunk-UAQ7UWZB.js.map} +0 -0
  217. /package/dist/{chunk-2MK64KK4.js.map → chunk-YTUQEDWH.js.map} +0 -0
  218. /package/dist/{chunk-H6KT7IXW.js.map → chunk-ZVAXTR2V.js.map} +0 -0
  219. /package/dist/{chunk-BGL35LL6.js.map → chunk-ZYD2SEQK.js.map} +0 -0
@@ -130,7 +130,7 @@ var init_config = __esm({
130
130
  ".*"
131
131
  ];
132
132
  DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
133
- DEFAULT_MODEL = "morph-warp-grep-v1";
133
+ DEFAULT_MODEL = "morph-warp-grep-v2";
134
134
  }
135
135
  });
136
136
 
@@ -285,7 +285,8 @@ var local_exports = {};
285
285
  __export(local_exports, {
286
286
  LocalRipgrepProvider: () => LocalRipgrepProvider
287
287
  });
288
- function shouldSkip2(name) {
288
+ function shouldSkip2(name, allowNames) {
289
+ if (allowNames?.has(name)) return false;
289
290
  if (SKIP_NAMES2.has(name)) return true;
290
291
  if (name.startsWith(".")) return true;
291
292
  for (const ext of SKIP_EXTENSIONS2) {
@@ -380,10 +381,14 @@ var init_local = __esm({
380
381
  ".js.map"
381
382
  ]);
382
383
  LocalRipgrepProvider = class {
383
- constructor(repoRoot, excludes = DEFAULT_EXCLUDES) {
384
+ constructor(repoRoot, excludes = DEFAULT_EXCLUDES, options) {
384
385
  this.repoRoot = repoRoot;
385
386
  this.excludes = excludes;
387
+ if (options?.allowNames?.length) {
388
+ this.allowNames = new Set(options.allowNames);
389
+ }
386
390
  }
391
+ allowNames;
387
392
  async grep(params) {
388
393
  let abs;
389
394
  try {
@@ -397,6 +402,7 @@ var init_local = __esm({
397
402
  const stat = await import_promises2.default.stat(abs).catch(() => null);
398
403
  if (!stat) return { lines: [] };
399
404
  const targetArg = abs === import_path4.default.resolve(this.repoRoot) ? "." : toRepoRelative(this.repoRoot, abs);
405
+ const contextLines = params.context_lines !== void 0 ? String(params.context_lines) : "1";
400
406
  const args = [
401
407
  "--no-config",
402
408
  "--no-heading",
@@ -406,9 +412,10 @@ var init_local = __esm({
406
412
  "--trim",
407
413
  "--max-columns=400",
408
414
  "-C",
409
- "1",
415
+ contextLines,
416
+ ...params.case_sensitive === false ? ["--ignore-case"] : [],
410
417
  ...params.glob ? ["--glob", params.glob] : [],
411
- ...this.excludes.flatMap((e) => ["-g", `!${e}`]),
418
+ ...this.excludes.filter((e) => !this.allowNames?.has(e)).flatMap((e) => ["-g", `!${e}`]),
412
419
  params.pattern,
413
420
  targetArg || "."
414
421
  ];
@@ -433,10 +440,9 @@ Details: ${res.stderr}` : ""}`
433
440
  }
434
441
  const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
435
442
  if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
436
- return {
437
- lines: [],
438
- error: "query not specific enough, tool tried to return too much context and failed"
439
- };
443
+ const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
444
+ truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
445
+ return { lines: truncated };
440
446
  }
441
447
  return { lines };
442
448
  }
@@ -510,7 +516,7 @@ Details: ${res.stderr}` : ""}`
510
516
  }
511
517
  if (out.length > AGENT_CONFIG.MAX_READ_LINES) {
512
518
  const truncated = out.slice(0, AGENT_CONFIG.MAX_READ_LINES);
513
- truncated.push(`... [truncated: showing ${AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines]`);
519
+ truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines)`);
514
520
  return { lines: truncated };
515
521
  }
516
522
  return { lines: out };
@@ -530,6 +536,7 @@ Details: ${res.stderr}` : ""}`
530
536
  const maxDepth = params.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
531
537
  const regex = params.pattern ? new RegExp(params.pattern) : null;
532
538
  const repoRoot = this.repoRoot;
539
+ const allowNames = this.allowNames;
533
540
  const results = [];
534
541
  let timedOut = false;
535
542
  const startTime = Date.now();
@@ -547,7 +554,7 @@ Details: ${res.stderr}` : ""}`
547
554
  }
548
555
  for (const entry of entries) {
549
556
  if (timedOut || results.length >= maxResults) break;
550
- if (shouldSkip2(entry.name)) continue;
557
+ if (shouldSkip2(entry.name, allowNames)) continue;
551
558
  if (regex && !regex.test(entry.name)) continue;
552
559
  const full = import_path4.default.join(dir, entry.name);
553
560
  const isDir = entry.isDirectory();
@@ -578,7 +585,6 @@ __export(vercel_exports, {
578
585
  default: () => vercel_default,
579
586
  execute: () => execute,
580
587
  formatResult: () => formatResult,
581
- getSystemPrompt: () => getSystemPrompt,
582
588
  warpGrepJsonSchema: () => warpGrepJsonSchema
583
589
  });
584
590
  module.exports = __toCommonJS(vercel_exports);
@@ -588,483 +594,130 @@ var import_zod = require("zod");
588
594
  // tools/warp_grep/agent/runner.ts
589
595
  init_config();
590
596
 
591
- // tools/warp_grep/agent/prompt.ts
592
- var SYSTEM_PROMPT = `You are a code search agent. Your task is to find all relevant code for a given search_string.
593
-
594
- ### workflow
595
- You have exactly 4 turns. The 4th turn MUST be a \`finish\` call. Each turn allows up to 8 parallel tool calls.
596
-
597
- - Turn 1: Map the territory OR dive deep (based on search_string specificity)
598
- - Turn 2-3: Refine based on findings
599
- - Turn 4: MUST call \`finish\` with all relevant code locations
600
- - You MAY call \`finish\` early if confident\u2014but never before at least 1 search turn.
601
- - The user strongly prefers if you can call the finish tool early, but you must be correct
602
-
603
- Remember, if the task feels easy to you, it is strongly desirable to call 'finish' early using fewer turns, but quality over speed
604
-
605
- ### tools
606
- Tool calls use nested XML elements:
607
- \`\`\`xml
608
- <tool_name>
609
- <parameter>value</parameter>
610
- </tool_name>
611
- \`\`\`
612
-
613
- ### \`list_directory\`
614
- Directory tree view. Shows structure of a path, optionally filtered by regex pattern.
615
-
616
- Elements:
617
- - \`<path>\` (required): Directory path to list (use \`.\` for repo root)
618
- - \`<pattern>\` (optional): Regex to filter results
619
-
620
- Examples:
621
- \`\`\`
622
- <list_directory>
623
- <path>src/services</path>
624
- </list_directory>
625
-
626
- <list_directory>
627
- <path>lib/utils</path>
628
- <pattern>.*\\.(ts|js)$</pattern>
629
- </list_directory>
630
- \`\`\`
631
-
632
- ### \`read\`
633
- Read file contents. Supports multiple line ranges.
634
- - Returns numbered lines for easy reference
635
- - ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
636
-
637
- Elements:
638
- - \`<path>\` (required): File path to read
639
- - \`<lines>\` (optional): Line ranges like "1-50,75-80,100-120" (omit to read entire file)
640
-
641
- Examples:
642
- \`\`\`
643
- <read>
644
- <path>src/main.py</path>
645
- </read>
646
-
647
- <read>
648
- <path>src/auth.py</path>
649
- <lines>1-20,45-80,150-200</lines>
650
- </read>
651
- \`\`\`
652
-
653
- ### \`grep\`
654
- Search for pattern matches across files. Returns matches with 1 line of context above and below.
655
- - Match lines use \`:\` separator \u2192 \`filepath:linenum:content\`
656
- - Context lines use \`-\` separator \u2192 \`filepath-linenum-content\`
657
-
658
- Elements:
659
- - \`<pattern>\` (required): Search pattern (regex). Use \`(a|b)\` for OR patterns.
660
- - \`<sub_dir>\` (optional): Subdirectory to search in (defaults to \`.\`)
661
- - \`<glob>\` (optional): File pattern filter like \`*.py\` or \`*.{ts,tsx}\`
662
-
663
- Examples:
664
- \`\`\`
665
- <grep>
666
- <pattern>(authenticate|authorize|login)</pattern>
667
- <sub_dir>src/auth/</sub_dir>
668
- </grep>
669
-
670
- <grep>
671
- <pattern>class.*(Service|Controller)</pattern>
672
- <glob>*.{ts,js}</glob>
673
- </grep>
674
-
675
- <grep>
676
- <pattern>(DB_HOST|DATABASE_URL|connection)</pattern>
677
- <glob>*.{py,yaml,env}</glob>
678
- <sub_dir>lib/</sub_dir>
679
- </grep>
680
- \`\`\`
681
-
682
- ### \`finish\`
683
- Submit final answer with all relevant code locations. Uses nested \`<file>\` elements.
684
-
685
- File elements:
686
- - \`<path>\` (required): File path
687
- - \`<lines>\` (optional): Line ranges like "1-50,75-80" (\`*\` for entire file)
688
-
689
- ALWAYS include import statements (usually lines 1-20). Better to over-include than miss context.
690
-
691
- Examples:
692
- \`\`\`
693
- <finish>
694
- <file>
695
- <path>src/auth.py</path>
696
- <lines>1-15,25-50,75-80</lines>
697
- </file>
698
- <file>
699
- <path>src/models/user.py</path>
700
- <lines>*</lines>
701
- </file>
702
- </finish>
703
- \`\`\`
704
- </tools>
705
-
706
- <strategy>
707
- **Before your first tool call, classify the search_string:**
708
-
709
- | Search_string Type | Round 1 Strategy | Early Finish? |
710
- |------------|------------------|---------------|
711
- | **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by round 2 |
712
- | **Conceptual** (how does X work, where is Y handled) | list_directory + 2-3 broad greps | Rarely early |
713
- | **Exploratory** (find all tests, list API endpoints) | list_directory at multiple depths | Usually needs 3 rounds |
714
-
715
- **Parallel call patterns:**
716
- - **Shotgun grep**: Same pattern, 8 different directories\u2014fast coverage
717
- - **Variant grep**: 8 pattern variations (synonyms, naming conventions)\u2014catches inconsistent codebases
718
- - **Funnel**: 1 list_directory + 7 greps\u2014orient and search simultaneously
719
- - **Deep read**: 8 reads on files you already identified\u2014gather full context fast
720
-
721
- **Tool call expectations:**
722
- - Low quality tool calls are ones that give back sparse information. This either means they are not well thought out and are not educated guesses OR, they are too broad and give back too many results.
723
- - High quality tool calls strike a balance between complexity in the tool call to exclude results we know we don't want, and how wide the search space is so that we don't miss anything. It is ok to start off with wider search spaces, but is imperative that you use your intuition from there on out and seek high quality tool calls only.
724
- - You are not starting blind, you have some information about root level repo structure going in, so use that to prevent making trivial repo wide queries.
725
- - The grep tool shows you which file path and line numbers the pattern was found in, use this information smartly when trying to read the file.
726
- </strategy>
727
-
728
- <output_format>
729
- EVERY response MUST follow this exact format:
730
-
731
- 1. First, wrap your reasoning in \`<think>...</think>\` tags containing:
732
- - Search_string classification (specific/conceptual/exploratory)
733
- - Confidence estimate (can I finish in 1-2 rounds?)
734
- - This round's parallel strategy
735
- - What signals would let me finish early?
736
-
737
- 2. Then, output up to 8 tool calls using nested XML elements.
738
-
739
- Example:
740
- \`\`\`
741
- <think>
742
- This is a specific search_string about authentication. I'll grep for auth-related patterns.
743
- High confidence I can finish in 2 rounds if I find the auth module. I have already been shown the repo's structure at root
744
- Strategy: Shotgun grep across likely directories.
745
- </think>
746
- <grep>
747
- <pattern>(authenticate|login|session)</pattern>
748
- <sub_dir>src/auth/</sub_dir>
749
- </grep>
750
- <grep>
751
- <pattern>(middleware|interceptor)</pattern>
752
- <glob>*.{ts,js}</glob>
753
- </grep>
754
- <list_directory>
755
- <path>src/auth</path>
756
- </list_directory>
757
- \`\`\`
758
-
759
- Finishing example:
760
- \`\`\`
761
- <think>
762
- I think I have a rough idea, but this is my last turn so I must call the finish tool regardless.
763
- </think>
764
- <finish>
765
- <file>
766
- <path>src/auth/login.py</path>
767
- <lines>1-50</lines>
768
- </file>
769
- <file>
770
- <path>src/middleware/session.py</path>
771
- <lines>10-80</lines>
772
- </file>
773
- </finish>
774
- \`\`\`
775
-
776
- No commentary outside \`<think>\`. No explanations after tool calls.
777
- </output_format>
778
-
779
- use as all 8 tool calls to be optimal
780
-
781
- <finishing_requirements>
782
- When calling \`finish\`:
783
- - Include the import section (typically lines 1-20) of each file
784
- - Include all function/class definitions that are relevant
785
- - Include any type definitions, interfaces, or constants used
786
- - Better to over-include than leave the user missing context
787
- - If unsure about boundaries, include more rather than less
788
- </finishing_requirements>`;
789
- function getSystemPrompt() {
790
- return SYSTEM_PROMPT;
791
- }
792
-
793
597
  // tools/warp_grep/agent/parser.ts
794
- var VALID_COMMANDS = ["list_directory", "grep", "read", "finish"];
598
+ var VALID_COMMANDS = ["list_directory", "ripgrep", "read", "finish"];
795
599
  function isValidCommand(name) {
796
600
  return VALID_COMMANDS.includes(name);
797
601
  }
798
- function getXmlElementText(xml, tagName) {
799
- const regex = new RegExp(`<${tagName}>([\\s\\S]*?)</${tagName}>`, "i");
800
- const match = xml.match(regex);
801
- return match ? match[1].trim() : null;
802
- }
803
- function parseNestedXmlTools(text) {
602
+ function parseQwen3ToolCalls(text) {
804
603
  const tools = [];
805
- const toolRegex = /<([a-z_][a-z0-9_]*)>([\s\S]*?)<\/\1>/gi;
604
+ const toolCallRegex = /<tool_call>\s*<function=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/function>\s*<\/tool_call>/gi;
806
605
  let match;
807
- while ((match = toolRegex.exec(text)) !== null) {
808
- const rawToolName = match[1].toLowerCase();
809
- const content = match[2];
810
- if (!isValidCommand(rawToolName)) continue;
811
- const toolName = rawToolName;
812
- if (toolName === "list_directory") {
813
- const path5 = getXmlElementText(content, "path");
814
- const pattern = getXmlElementText(content, "pattern");
815
- if (path5) {
816
- tools.push({ name: "list_directory", arguments: { path: path5, pattern } });
606
+ while ((match = toolCallRegex.exec(text)) !== null) {
607
+ const funcName = match[1].toLowerCase();
608
+ const body = match[2];
609
+ if (!isValidCommand(funcName)) continue;
610
+ const params = {};
611
+ const paramRegex = /<parameter=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/parameter>/gi;
612
+ let paramMatch;
613
+ while ((paramMatch = paramRegex.exec(body)) !== null) {
614
+ params[paramMatch[1].toLowerCase()] = paramMatch[2].trim();
615
+ }
616
+ if (funcName === "ripgrep") {
617
+ const pattern = params.pattern;
618
+ if (!pattern) continue;
619
+ const args = {
620
+ pattern,
621
+ path: params.path || ".",
622
+ ...params.glob && { glob: params.glob },
623
+ ...params.context_lines && { context_lines: parseInt(params.context_lines, 10) },
624
+ ...params.case_sensitive && { case_sensitive: params.case_sensitive === "true" }
625
+ };
626
+ tools.push({ name: "grep", arguments: args });
627
+ } else if (funcName === "list_directory") {
628
+ const command = params.command;
629
+ const directPath = params.path;
630
+ let dirPath = directPath || ".";
631
+ if (!directPath && command) {
632
+ const tokens = command.trim().split(/\s+/);
633
+ const pathTokens = tokens.slice(1).filter((t) => !t.startsWith("-") && !t.startsWith("|") && !t.startsWith("\\("));
634
+ if (pathTokens.length > 0) {
635
+ dirPath = pathTokens[0];
636
+ }
817
637
  }
818
- } else if (toolName === "grep") {
819
- const pattern = getXmlElementText(content, "pattern");
820
- const subDir = getXmlElementText(content, "sub_dir");
821
- const glob = getXmlElementText(content, "glob");
822
- if (pattern) {
823
- tools.push({
824
- name: "grep",
825
- arguments: {
826
- pattern,
827
- path: subDir || ".",
828
- ...glob && { glob }
638
+ tools.push({ name: "list_directory", arguments: { path: dirPath, pattern: params.pattern || null } });
639
+ } else if (funcName === "read") {
640
+ const filePath = params.path;
641
+ if (!filePath) continue;
642
+ const args = { path: filePath };
643
+ const linesStr = params.lines;
644
+ if (linesStr) {
645
+ const ranges = [];
646
+ for (const rangeStr of linesStr.split(",")) {
647
+ const trimmed = rangeStr.trim();
648
+ if (!trimmed) continue;
649
+ const [s, e] = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
650
+ if (Number.isFinite(s) && Number.isFinite(e)) {
651
+ ranges.push([s, e]);
652
+ } else if (Number.isFinite(s)) {
653
+ ranges.push([s, s]);
829
654
  }
830
- });
655
+ }
656
+ if (ranges.length === 1) {
657
+ args.start = ranges[0][0];
658
+ args.end = ranges[0][1];
659
+ } else if (ranges.length > 1) {
660
+ args.lines = ranges;
661
+ }
662
+ }
663
+ tools.push({ name: "read", arguments: args });
664
+ } else if (funcName === "finish") {
665
+ if (params.result && !params.files) {
666
+ tools.push({ name: "finish", arguments: { files: [], textResult: params.result } });
667
+ continue;
831
668
  }
832
- } else if (toolName === "read") {
833
- const path5 = getXmlElementText(content, "path");
834
- const linesStr = getXmlElementText(content, "lines");
835
- if (path5) {
836
- const args = { path: path5 };
837
- if (linesStr) {
669
+ const filesStr = params.files;
670
+ if (!filesStr) {
671
+ tools.push({ name: "finish", arguments: { files: [], textResult: "No relevant code found." } });
672
+ continue;
673
+ }
674
+ const files = [];
675
+ for (const line of filesStr.split("\n")) {
676
+ const trimmed = line.trim();
677
+ if (!trimmed) continue;
678
+ const colonIdx = trimmed.indexOf(":");
679
+ if (colonIdx === -1) {
680
+ files.push({ path: trimmed, lines: "*" });
681
+ } else {
682
+ const filePath = trimmed.slice(0, colonIdx);
683
+ const rangesPart = trimmed.slice(colonIdx + 1);
838
684
  const ranges = [];
839
- for (const rangeStr of linesStr.split(",")) {
840
- const trimmed = rangeStr.trim();
841
- if (!trimmed) continue;
842
- const [s, e] = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
685
+ for (const rangeStr of rangesPart.split(",")) {
686
+ const rt = rangeStr.trim();
687
+ if (!rt || rt === "*") {
688
+ files.push({ path: filePath, lines: "*" });
689
+ break;
690
+ }
691
+ const [s, e] = rt.split("-").map((v) => parseInt(v.trim(), 10));
843
692
  if (Number.isFinite(s) && Number.isFinite(e)) {
844
693
  ranges.push([s, e]);
845
694
  } else if (Number.isFinite(s)) {
846
695
  ranges.push([s, s]);
847
696
  }
848
697
  }
849
- if (ranges.length === 1) {
850
- args.start = ranges[0][0];
851
- args.end = ranges[0][1];
852
- } else if (ranges.length > 1) {
853
- args.lines = ranges;
854
- }
855
- }
856
- tools.push({ name: "read", arguments: args });
857
- }
858
- } else if (toolName === "finish") {
859
- const fileRegex = /<file>([\s\S]*?)<\/file>/gi;
860
- const files = [];
861
- let fileMatch;
862
- while ((fileMatch = fileRegex.exec(content)) !== null) {
863
- const fileContent = fileMatch[1];
864
- const filePath = getXmlElementText(fileContent, "path");
865
- const linesStr = getXmlElementText(fileContent, "lines");
866
- if (filePath) {
867
- if (!linesStr || linesStr.trim() === "*") {
698
+ if (ranges.length > 0) {
699
+ files.push({ path: filePath, lines: ranges });
700
+ } else if (!files.some((f) => f.path === filePath)) {
868
701
  files.push({ path: filePath, lines: "*" });
869
- } else {
870
- const ranges = [];
871
- for (const rangeStr of linesStr.split(",")) {
872
- const [s, e] = rangeStr.split("-").map((v) => parseInt(v.trim(), 10));
873
- if (Number.isFinite(s) && Number.isFinite(e)) {
874
- ranges.push([s, e]);
875
- }
876
- }
877
- if (ranges.length > 0) {
878
- files.push({ path: filePath, lines: ranges });
879
- } else {
880
- files.push({ path: filePath, lines: "*" });
881
- }
882
702
  }
883
703
  }
884
704
  }
885
705
  if (files.length > 0) {
886
706
  tools.push({ name: "finish", arguments: { files } });
887
707
  } else {
888
- const raw = content.replace(/<[^>]*>/g, "").trim();
889
- const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
890
- tools.push({ name: "finish", arguments: { files: [], textResult } });
708
+ tools.push({ name: "finish", arguments: { files: [], textResult: filesStr } });
891
709
  }
892
710
  }
893
711
  }
894
- if (tools.length === 0) {
895
- const fnFinishMatch = text.match(/<function=finish>([\s\S]*?)<\/function>/i);
896
- if (fnFinishMatch) {
897
- const inner = fnFinishMatch[1];
898
- const paramMatch = inner.match(/<parameter=result>([\s\S]*?)<\/parameter>/i);
899
- const raw = (paramMatch ? paramMatch[1] : inner).trim();
900
- const textResult = !raw || raw === "*" ? "No relevant code found." : raw;
901
- tools.push({ name: "finish", arguments: { files: [], textResult } });
902
- }
903
- }
904
712
  return tools;
905
713
  }
906
- function preprocessText(text) {
907
- const processed = text.replace(/<think>[\s\S]*?<\/think>/gi, "").replace(/<\/?tool_call>/gi, "");
908
- const nestedTools = parseNestedXmlTools(processed);
909
- const toolCallLines = [];
910
- const allLines = processed.split(/\r?\n/).map((l) => l.trim());
911
- for (const line of allLines) {
912
- if (!line) continue;
913
- if (line.startsWith("<")) continue;
914
- const firstWord = line.split(/\s/)[0];
915
- if (VALID_COMMANDS.includes(firstWord)) {
916
- if (!toolCallLines.includes(line)) {
917
- toolCallLines.push(line);
918
- }
919
- }
920
- }
921
- return { lines: toolCallLines, nestedTools };
922
- }
923
714
  var LLMResponseParser = class {
924
- finishSpecSplitRe = /,(?=[^,\s]+:)/;
925
715
  parse(text) {
926
716
  if (typeof text !== "string") {
927
717
  throw new TypeError("Command text must be a string.");
928
718
  }
929
- const { lines, nestedTools } = preprocessText(text);
930
- const commands = [...nestedTools];
931
- let finishAccumulator = null;
932
- lines.forEach((line) => {
933
- if (!line || line.startsWith("#")) return;
934
- const parts = this.splitLine(line);
935
- if (parts.length === 0) return;
936
- const cmd = parts[0];
937
- switch (cmd) {
938
- case "list_directory":
939
- this.handleListDirectory(parts, line, commands);
940
- break;
941
- case "grep":
942
- this.handleGrep(parts, line, commands);
943
- break;
944
- case "read":
945
- this.handleRead(parts, line, commands);
946
- break;
947
- case "finish":
948
- finishAccumulator = this.handleFinish(parts, line, commands, finishAccumulator);
949
- break;
950
- default:
951
- break;
952
- }
953
- });
954
- if (finishAccumulator) {
955
- const map = finishAccumulator;
956
- const entries = [...map.entries()];
957
- const filesPayload = entries.map(([path5, ranges]) => ({
958
- path: path5,
959
- lines: [...ranges].sort((a, b) => a[0] - b[0])
960
- }));
961
- commands.push({ name: "finish", arguments: { files: filesPayload } });
962
- }
963
- return commands;
964
- }
965
- splitLine(line) {
966
- const parts = [];
967
- let current = "";
968
- let inSingle = false;
969
- for (let i = 0; i < line.length; i++) {
970
- const ch = line[i];
971
- if (ch === "'" && line[i - 1] !== "\\") {
972
- inSingle = !inSingle;
973
- current += ch;
974
- } else if (!inSingle && /\s/.test(ch)) {
975
- if (current) {
976
- parts.push(current);
977
- current = "";
978
- }
979
- } else {
980
- current += ch;
981
- }
982
- }
983
- if (current) parts.push(current);
984
- return parts;
985
- }
986
- /** Helper to create a _skip tool call with an error message */
987
- skip(message) {
988
- return { name: "_skip", arguments: { message } };
989
- }
990
- handleListDirectory(parts, rawLine, commands) {
991
- if (parts.length < 2) {
992
- commands.push(this.skip(
993
- `[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: list_directory <path> [pattern]. Example: list_directory src/`
994
- ));
995
- return;
996
- }
997
- const path5 = parts[1];
998
- const pattern = parts[2]?.replace(/^"|"$/g, "") ?? null;
999
- commands.push({ name: "list_directory", arguments: { path: path5, pattern } });
1000
- }
1001
- handleGrep(parts, rawLine, commands) {
1002
- if (parts.length < 3) {
1003
- commands.push(this.skip(
1004
- `[SKIPPED] Your command "${rawLine}" is missing arguments. Correct format: grep '<pattern>' <path>. Example: grep 'TODO' src/`
1005
- ));
1006
- return;
1007
- }
1008
- let pat = parts[1];
1009
- if (pat.startsWith("'") && pat.endsWith("'")) {
1010
- pat = pat.slice(1, -1);
1011
- }
1012
- if (!pat) {
1013
- commands.push(this.skip(
1014
- `[SKIPPED] Your command "${rawLine}" has an empty pattern. Provide a non-empty search pattern. Example: grep 'function' src/`
1015
- ));
1016
- return;
1017
- }
1018
- commands.push({ name: "grep", arguments: { pattern: pat, path: parts[2] } });
1019
- }
1020
- handleRead(parts, rawLine, commands) {
1021
- if (parts.length < 2) {
1022
- commands.push(this.skip(
1023
- `[SKIPPED] Your command "${rawLine}" is missing a path. Correct format: read <path> or read <path>:<start>-<end>. Example: read src/index.ts:1-50`
1024
- ));
1025
- return;
1026
- }
1027
- const spec = parts[1];
1028
- const rangeIdx = spec.indexOf(":");
1029
- if (rangeIdx === -1) {
1030
- commands.push({ name: "read", arguments: { path: spec } });
1031
- return;
1032
- }
1033
- const filePath = spec.slice(0, rangeIdx);
1034
- const range = spec.slice(rangeIdx + 1);
1035
- const [s, e] = range.split("-").map((v) => parseInt(v, 10));
1036
- if (!Number.isFinite(s) || !Number.isFinite(e)) {
1037
- commands.push({ name: "read", arguments: { path: filePath } });
1038
- return;
1039
- }
1040
- commands.push({ name: "read", arguments: { path: filePath, start: s, end: e } });
1041
- }
1042
- handleFinish(parts, rawLine, commands, acc) {
1043
- const map = acc ?? /* @__PURE__ */ new Map();
1044
- const args = parts.slice(1);
1045
- for (const token of args) {
1046
- const [filePath, rangesText] = token.split(":", 2);
1047
- if (!filePath || !rangesText) {
1048
- commands.push(this.skip(
1049
- `[SKIPPED] Invalid finish token "${token}". Correct format: finish <path>:<start>-<end>. Example: finish src/index.ts:1-50`
1050
- ));
1051
- continue;
1052
- }
1053
- const rangeSpecs = rangesText.split(",").filter(Boolean);
1054
- for (const spec of rangeSpecs) {
1055
- const [s, e] = spec.split("-").map((v) => parseInt(v, 10));
1056
- if (!Number.isFinite(s) || !Number.isFinite(e) || e < s) {
1057
- commands.push(this.skip(
1058
- `[SKIPPED] Invalid range "${spec}" in "${token}". Ranges must be <start>-<end> where start <= end. Example: 1-50`
1059
- ));
1060
- continue;
1061
- }
1062
- const arr = map.get(filePath) ?? [];
1063
- arr.push([s, e]);
1064
- map.set(filePath, arr);
1065
- }
1066
- }
1067
- return map;
719
+ const withoutThink = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
720
+ return parseQwen3ToolCalls(withoutThink);
1068
721
  }
1069
722
  };
1070
723
 
@@ -1134,14 +787,12 @@ async function toolListDirectory(provider, args) {
1134
787
  }
1135
788
  const { entries: list } = await getListRecursive(initialDepth);
1136
789
  if (!list.length) return "empty";
1137
- if (list.length >= maxResults) {
1138
- return "query not specific enough, tool called tried to return too much context and failed";
1139
- }
1140
- return list.map((e) => {
790
+ const tree = list.map((e) => {
1141
791
  const indent = " ".repeat(e.depth);
1142
792
  const name = e.type === "dir" ? `${e.name}/` : e.name;
1143
793
  return `${indent}${name}`;
1144
794
  }).join("\n");
795
+ return tree;
1145
796
  }
1146
797
 
1147
798
  // tools/warp_grep/agent/tools/finish.ts
@@ -1204,90 +855,19 @@ function mergeRanges(ranges) {
1204
855
 
1205
856
  // tools/warp_grep/agent/formatter.ts
1206
857
  var ToolOutputFormatter = class {
1207
- format(toolName, args, output, options = {}) {
858
+ format(toolName, _args, output, options = {}) {
1208
859
  const name = (toolName ?? "").trim();
1209
860
  if (!name) {
1210
861
  return "";
1211
862
  }
1212
863
  const payload = output?.toString?.()?.trim?.() ?? "";
1213
864
  const isError = Boolean(options.isError);
1214
- const safeArgs = args ?? {};
1215
865
  if (!payload && !isError) {
1216
866
  return "";
1217
867
  }
1218
- switch (name) {
1219
- case "read":
1220
- return this.formatRead(safeArgs, payload, isError);
1221
- case "list_directory":
1222
- return this.formatListDirectory(safeArgs, payload, isError);
1223
- case "grep":
1224
- return this.formatGrep(safeArgs, payload, isError);
1225
- default:
1226
- return payload ? `<tool_output>
1227
- ${payload}
1228
- </tool_output>` : "";
1229
- }
1230
- }
1231
- formatRead(args, payload, isError) {
1232
- if (isError) {
1233
- return payload;
1234
- }
1235
- const path5 = this.asString(args.path) || "...";
1236
- const start = args.start;
1237
- const end = args.end;
1238
- const linesArray = args.lines;
1239
- const attributes = [`path="${path5}"`];
1240
- if (linesArray && linesArray.length > 0) {
1241
- const rangeStr = linesArray.map(([s, e]) => `${s}-${e}`).join(",");
1242
- attributes.push(`lines="${rangeStr}"`);
1243
- } else if (start !== void 0 && end !== void 0) {
1244
- attributes.push(`lines="${start}-${end}"`);
1245
- }
1246
- return `<read ${attributes.join(" ")}>
1247
- ${payload}
1248
- </read>`;
1249
- }
1250
- formatListDirectory(args, payload, isError) {
1251
- const path5 = this.asString(args.path) || ".";
1252
- const pattern = this.asString(args.pattern);
1253
- const attributes = [`path="${path5}"`];
1254
- if (pattern) {
1255
- attributes.push(`pattern="${pattern}"`);
1256
- }
1257
- if (isError) {
1258
- attributes.push('status="error"');
1259
- }
1260
- return `<list_directory ${attributes.join(" ")}>
1261
- ${payload}
1262
- </list_directory>`;
1263
- }
1264
- formatGrep(args, payload, isError) {
1265
- const pattern = this.asString(args.pattern);
1266
- const subDir = this.asString(args.path);
1267
- const glob = this.asString(args.glob);
1268
- const attributes = [];
1269
- if (pattern !== void 0) {
1270
- attributes.push(`pattern="${pattern}"`);
1271
- }
1272
- if (subDir !== void 0) {
1273
- attributes.push(`sub_dir="${subDir}"`);
1274
- }
1275
- if (glob !== void 0) {
1276
- attributes.push(`glob="${glob}"`);
1277
- }
1278
- if (isError) {
1279
- attributes.push('status="error"');
1280
- }
1281
- const attrText = attributes.length ? ` ${attributes.join(" ")}` : "";
1282
- return `<grep${attrText}>
868
+ return `<tool_response>
1283
869
  ${payload}
1284
- </grep>`;
1285
- }
1286
- asString(value) {
1287
- if (value === null || value === void 0) {
1288
- return void 0;
1289
- }
1290
- return String(value);
870
+ </tool_response>`;
1291
871
  }
1292
872
  };
1293
873
  var sharedFormatter = new ToolOutputFormatter();
@@ -1316,12 +896,15 @@ function calculateContextBudget(messages) {
1316
896
  const maxK = Math.round(maxChars / 1e3);
1317
897
  return `<context_budget>${percent}% (${usedK}K/${maxK}K chars)</context_budget>`;
1318
898
  }
1319
- async function buildInitialState(repoRoot, query, provider) {
899
+ async function buildInitialState(repoRoot, query, provider, options) {
900
+ const budget = calculateContextBudget([]);
901
+ const turnTag = `Turn 0/${AGENT_CONFIG.MAX_TURNS}`;
902
+ const treeDepth = options?.query_type === "node_modules" ? 1 : 2;
1320
903
  try {
1321
904
  const entries = await provider.listDirectory({
1322
905
  path: ".",
1323
906
  maxResults: AGENT_CONFIG.MAX_OUTPUT_LINES,
1324
- maxDepth: 2
907
+ maxDepth: treeDepth
1325
908
  });
1326
909
  const treeLines = entries.map((e) => {
1327
910
  const indent = " ".repeat(e.depth);
@@ -1337,7 +920,9 @@ ${treeOutput}
1337
920
 
1338
921
  <search_string>
1339
922
  ${query}
1340
- </search_string>`;
923
+ </search_string>
924
+ ${budget}
925
+ ${turnTag}`;
1341
926
  } catch {
1342
927
  const repoName = import_path.default.basename(repoRoot);
1343
928
  return `<repo_structure>
@@ -1346,7 +931,9 @@ ${repoName}/
1346
931
 
1347
932
  <search_string>
1348
933
  ${query}
1349
- </search_string>`;
934
+ </search_string>
935
+ ${budget}
936
+ ${turnTag}`;
1350
937
  }
1351
938
  }
1352
939
  function enforceContextLimit(messages, maxChars = AGENT_CONFIG.MAX_CONTEXT_CHARS) {
@@ -1382,7 +969,7 @@ var import_openai = __toESM(require("openai"), 1);
1382
969
  // package.json
1383
970
  var package_default = {
1384
971
  name: "@morphllm/morphsdk",
1385
- version: "0.2.125",
972
+ version: "0.2.127",
1386
973
  description: "TypeScript SDK and CLI for Morph Fast Apply integration",
1387
974
  type: "module",
1388
975
  main: "./dist/index.cjs",
@@ -1524,7 +1111,7 @@ var package_default = {
1524
1111
  "!dist/**/*.test.*"
1525
1112
  ],
1526
1113
  scripts: {
1527
- build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/prompt.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
1114
+ build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
1528
1115
  prepare: "npm run build",
1529
1116
  typecheck: "tsc --noEmit",
1530
1117
  lint: "eslint .",
@@ -1661,14 +1248,13 @@ async function runWarpGrep(config) {
1661
1248
  const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
1662
1249
  const timings = { turns: [], timeout_ms: timeoutMs };
1663
1250
  const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
1251
+ const model = config.model || DEFAULT_MODEL;
1664
1252
  const messages = [];
1665
- messages.push({ role: "system", content: getSystemPrompt() });
1253
+ const maxTurns = AGENT_CONFIG.MAX_TURNS;
1666
1254
  const initialStateStart = Date.now();
1667
- const initialState = await buildInitialState(repoRoot, config.query, config.provider);
1255
+ const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
1668
1256
  timings.initial_state_ms = Date.now() - initialStateStart;
1669
1257
  messages.push({ role: "user", content: initialState });
1670
- const maxTurns = AGENT_CONFIG.MAX_TURNS;
1671
- const model = config.model || DEFAULT_MODEL;
1672
1258
  const provider = config.provider;
1673
1259
  const errors = [];
1674
1260
  let finishMeta;
@@ -1718,7 +1304,7 @@ async function runWarpGrep(config) {
1718
1304
  const args = c.arguments ?? {};
1719
1305
  allPromises.push(
1720
1306
  toolGrep(provider, args).then(
1721
- ({ output }) => formatAgentToolOutput("grep", args, output, { isError: false }),
1307
+ ({ output }) => formatAgentToolOutput("grep", args, output),
1722
1308
  (err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
1723
1309
  )
1724
1310
  );
@@ -1727,7 +1313,7 @@ async function runWarpGrep(config) {
1727
1313
  const args = c.arguments ?? {};
1728
1314
  allPromises.push(
1729
1315
  toolListDirectory(provider, args).then(
1730
- (p) => formatAgentToolOutput("list_directory", args, p, { isError: false }),
1316
+ (p) => formatAgentToolOutput("list_directory", args, p),
1731
1317
  (err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
1732
1318
  )
1733
1319
  );
@@ -1736,7 +1322,7 @@ async function runWarpGrep(config) {
1736
1322
  const args = c.arguments ?? {};
1737
1323
  allPromises.push(
1738
1324
  toolRead(provider, args).then(
1739
- (p) => formatAgentToolOutput("read", args, p, { isError: false }),
1325
+ (p) => formatAgentToolOutput("read", args, p),
1740
1326
  (err) => formatAgentToolOutput("read", args, String(err), { isError: true })
1741
1327
  )
1742
1328
  );
@@ -1820,14 +1406,13 @@ async function* runWarpGrepStreaming(config) {
1820
1406
  const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
1821
1407
  const timings = { turns: [], timeout_ms: timeoutMs };
1822
1408
  const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
1409
+ const model = config.model || DEFAULT_MODEL;
1823
1410
  const messages = [];
1824
- messages.push({ role: "system", content: getSystemPrompt() });
1411
+ const maxTurns = AGENT_CONFIG.MAX_TURNS;
1825
1412
  const initialStateStart = Date.now();
1826
- const initialState = await buildInitialState(repoRoot, config.query, config.provider);
1413
+ const initialState = await buildInitialState(repoRoot, config.query, config.provider, { query_type: config.query_type });
1827
1414
  timings.initial_state_ms = Date.now() - initialStateStart;
1828
1415
  messages.push({ role: "user", content: initialState });
1829
- const maxTurns = AGENT_CONFIG.MAX_TURNS;
1830
- const model = config.model || DEFAULT_MODEL;
1831
1416
  const provider = config.provider;
1832
1417
  const errors = [];
1833
1418
  let finishMeta;
@@ -1884,7 +1469,7 @@ async function* runWarpGrepStreaming(config) {
1884
1469
  const args = c.arguments ?? {};
1885
1470
  allPromises.push(
1886
1471
  toolGrep(provider, args).then(
1887
- ({ output }) => formatAgentToolOutput("grep", args, output, { isError: false }),
1472
+ ({ output }) => formatAgentToolOutput("grep", args, output),
1888
1473
  (err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
1889
1474
  )
1890
1475
  );
@@ -1893,7 +1478,7 @@ async function* runWarpGrepStreaming(config) {
1893
1478
  const args = c.arguments ?? {};
1894
1479
  allPromises.push(
1895
1480
  toolListDirectory(provider, args).then(
1896
- (p) => formatAgentToolOutput("list_directory", args, p, { isError: false }),
1481
+ (p) => formatAgentToolOutput("list_directory", args, p),
1897
1482
  (err) => formatAgentToolOutput("list_directory", args, String(err), { isError: true })
1898
1483
  )
1899
1484
  );
@@ -1902,7 +1487,7 @@ async function* runWarpGrepStreaming(config) {
1902
1487
  const args = c.arguments ?? {};
1903
1488
  allPromises.push(
1904
1489
  toolRead(provider, args).then(
1905
- (p) => formatAgentToolOutput("read", args, p, { isError: false }),
1490
+ (p) => formatAgentToolOutput("read", args, p),
1906
1491
  (err) => formatAgentToolOutput("read", args, String(err), { isError: true })
1907
1492
  )
1908
1493
  );
@@ -2080,10 +1665,9 @@ var RemoteCommandsProvider = class {
2080
1665
  const stdout = await this.commands.grep(params.pattern, params.path, params.glob);
2081
1666
  const lines = (stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
2082
1667
  if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
2083
- return {
2084
- lines: [],
2085
- error: "Query not specific enough - too many results returned. Try a more specific pattern."
2086
- };
1668
+ const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
1669
+ truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
1670
+ return { lines: truncated };
2087
1671
  }
2088
1672
  return { lines };
2089
1673
  } catch (error) {
@@ -2113,7 +1697,7 @@ var RemoteCommandsProvider = class {
2113
1697
  const lines = contentLines.map((content, idx) => `${start + idx}|${content}`);
2114
1698
  if (lines.length > AGENT_CONFIG.MAX_READ_LINES) {
2115
1699
  const truncated = lines.slice(0, AGENT_CONFIG.MAX_READ_LINES);
2116
- truncated.push(`... [truncated: showing ${AGENT_CONFIG.MAX_READ_LINES} of ${lines.length} lines]`);
1700
+ truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${lines.length} lines)`);
2117
1701
  return { lines: truncated };
2118
1702
  }
2119
1703
  return { lines };
@@ -2459,7 +2043,7 @@ function formatResult(result) {
2459
2043
 
2460
2044
  // tools/warp_grep/prompts.ts
2461
2045
  var WARP_GREP_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase to gather context, and the task does not involve a single file or function which is provided by name, you should ALWAYS use the warpgrep codebase search tool first instead of running search commands. When the task requires exploration beyond a single known file, invoke warpgrep first with a natural-language query describing the target functionality, bug, or architectural concern. Warp Grep is a fast and accurate tool that can search for all relevant context in a codebase. Keep queries action-oriented (e.g., "Find where billing invoices are generated and emailed"), and after reviewing the summarized results, you may verify important findings with other search tools or direct file reads to ensure completeness. Warp Grep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task requires exploration beyond a single known file, ALWAYS default to warpgrep codebase search before other search mechanisms.';
2462
- var GITHUB_WARP_GREP_SEARCH_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase of a public GitHub repository (not your local workspace), use warpgrep_github_search instead of warpgrep_codebase_search. ONLY use this tool when the task requires understanding code in an external repo, and invoke warpgrep_github_search with a GitHub URL or owner/repo shorthand (e.g., vercel/next.js) and a natural-language query describing the target functionality, bug, or architectural concern. DO NOT use this tool when the task requires understanding code in your local workspace. Use warpgrep_codebase_search instead.Useful when you suspect a library or framework is being used in a way that is not documented, or if you suspect an update or a bug in the library or framework.WarpGrep searches GitHub repos the same way it searches local codebases: fast and accurate. Keep queries action-oriented (e.g., "Find where how the new use workflow directive works"), and after reviewing the results, you may verify important findings with other tools or direct file reads. WarpGrep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task involves exploring code in an external public repo, ALWAYS use warpgrep_github_search.';
2046
+ var GITHUB_WARP_GREP_SEARCH_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase of a public GitHub repository (not your local workspace), use warpgrep_github_search instead of warpgrep_codebase_search. ONLY use this tool when the task requires understanding code in an external repo, and invoke warpgrep_github_search with a natural-language query describing the target functionality, bug, or architectural concern. DO NOT use this tool when the task requires understanding code in your local workspace. Use warpgrep_codebase_search instead.Useful when you suspect a library or framework is being used in a way that is not documented, or if you suspect an update or a bug in the library or framework.WarpGrep searches GitHub repos the same way it searches local codebases: fast and accurate. Keep queries action-oriented (e.g., "Find where how the new use workflow directive works"), and after reviewing the results, you may verify important findings with other tools or direct file reads. WarpGrep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task involves exploring code in an external public repo, ALWAYS use warpgrep_github_search. You must provide either a github_url or owner_repo parameter (at least one is required).';
2463
2047
  var GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;
2464
2048
  var GITHUB_READ_FILE_DESCRIPTION = "Read a single file (or a line range) from a public GitHub repository. ONLY USE THIS WHEN YOU ALREADY KNOW THE EXACT FILE PATH YOU WANT TO READ, for example after finding it via warpgrep_github_search results. Takes owner/repo shorthand and the file path within the repo. Optionally specify startLine and endLine (1-based) to read a specific range. Returns the file content with line numbers.";
2465
2049
 
@@ -2516,11 +2100,16 @@ function createGitHubSearchTool(config) {
2516
2100
  description: GITHUB_SEARCH_DESCRIPTION,
2517
2101
  inputSchema: import_zod.z.object({
2518
2102
  query: import_zod.z.string().describe("Natural language search query"),
2519
- github: import_zod.z.string().describe('GitHub URL or "owner/repo" shorthand'),
2103
+ github_url: import_zod.z.string().optional().describe('GitHub repository URL to search (e.g. "https://github.com/vercel/next.js"). You must provide either github_url or owner_repo.'),
2104
+ owner_repo: import_zod.z.string().optional().describe('Repository owner/repo shorthand (e.g. "vercel/next.js"). You must provide either github_url or owner_repo.'),
2520
2105
  branch: import_zod.z.string().optional().describe("Branch to search (defaults to repo default branch)")
2521
2106
  }),
2522
2107
  execute: async (params) => {
2523
- const result = await client.searchGitHub(params);
2108
+ const github = params.github_url || params.owner_repo;
2109
+ if (!github) {
2110
+ throw new Error("Please provide github search url or owner/repo id");
2111
+ }
2112
+ const result = await client.searchGitHub({ query: params.query, github, branch: params.branch });
2524
2113
  if (!result.success) {
2525
2114
  throw new Error(`GitHub search failed: ${result.error}`);
2526
2115
  }
@@ -2559,7 +2148,6 @@ var vercel_default = createWarpGrepTool;
2559
2148
  createWarpGrepTool,
2560
2149
  execute,
2561
2150
  formatResult,
2562
- getSystemPrompt,
2563
2151
  warpGrepJsonSchema
2564
2152
  });
2565
2153
  //# sourceMappingURL=vercel.cjs.map