@morphllm/morphsdk 0.2.145 → 0.2.146

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 (205) hide show
  1. package/dist/{chunk-HBIW2XV2.js → chunk-4PBUB77N.js} +2 -2
  2. package/dist/{chunk-SUE4GYA2.js → chunk-BDHKL3MT.js} +2 -2
  3. package/dist/{chunk-S54SPKX3.js → chunk-BIQ7234U.js} +2 -2
  4. package/dist/{chunk-I3J46TSB.js → chunk-DKODF3YG.js} +4 -5
  5. package/dist/chunk-DKODF3YG.js.map +1 -0
  6. package/dist/{chunk-MRPASJBX.js → chunk-E45FW5EK.js} +2 -2
  7. package/dist/{chunk-BXRJYLRS.js → chunk-E4YKEKGW.js} +2 -2
  8. package/dist/{chunk-G23BI5CQ.js → chunk-EU7OLX4Z.js} +2 -2
  9. package/dist/chunk-EUHNJMWL.js +409 -0
  10. package/dist/chunk-EUHNJMWL.js.map +1 -0
  11. package/dist/{chunk-HE7K2QNQ.js → chunk-FBOJJ3UY.js} +17 -17
  12. package/dist/{chunk-HYRHI2UL.js → chunk-FIVYDIHX.js} +1 -1
  13. package/dist/{chunk-GXM3G7Z4.js → chunk-FYO46OT6.js} +2 -2
  14. package/dist/{chunk-GHPQYSSF.js → chunk-GJUB3ECP.js} +2 -2
  15. package/dist/{chunk-4Y2NM6JD.js → chunk-HZOTLGJH.js} +2 -42
  16. package/dist/chunk-HZOTLGJH.js.map +1 -0
  17. package/dist/{chunk-MTJ3PR4M.js → chunk-I7SFRYTX.js} +2 -2
  18. package/dist/{chunk-PX7ODEML.js → chunk-J2HIK4GB.js} +2 -2
  19. package/dist/{chunk-RZXS4ADX.js → chunk-JSWNBCGS.js} +2 -2
  20. package/dist/{chunk-GXCWKYGU.js → chunk-KYKRRF7E.js} +2 -2
  21. package/dist/{chunk-N7TTZIBK.js → chunk-MMBQKN4G.js} +2 -2
  22. package/dist/{chunk-B3AKP3RA.js → chunk-NF2QWJDY.js} +2 -31
  23. package/dist/chunk-NF2QWJDY.js.map +1 -0
  24. package/dist/{chunk-JMUAQQJU.js → chunk-NKUSUSVI.js} +3 -3
  25. package/dist/{chunk-VRV5UYTN.js → chunk-OV57JBMB.js} +2 -2
  26. package/dist/{chunk-EPIOAODF.js → chunk-Q36MNOFA.js} +2 -2
  27. package/dist/{chunk-JRBU4UNP.js → chunk-QRSWXP4K.js} +2 -2
  28. package/dist/{chunk-KELRCMA6.js → chunk-SJYAKVSS.js} +2 -2
  29. package/dist/{chunk-KELRCMA6.js.map → chunk-SJYAKVSS.js.map} +1 -1
  30. package/dist/{chunk-IRWHN55G.js → chunk-T564HFSH.js} +1 -1
  31. package/dist/{chunk-6CFKWZK3.js → chunk-UVNENJ6H.js} +3 -3
  32. package/dist/{chunk-5FCXLQJU.js → chunk-UYPWKQKV.js} +2 -2
  33. package/dist/{chunk-BAF33L6C.js → chunk-V73GO5AJ.js} +2 -2
  34. package/dist/chunk-VCKJ22DX.js +131 -0
  35. package/dist/chunk-VCKJ22DX.js.map +1 -0
  36. package/dist/{chunk-XL7R3XN5.js → chunk-VZ6VYRQB.js} +2 -2
  37. package/dist/{chunk-4LWMPKSB.js → chunk-YIETFYCL.js} +44 -71
  38. package/dist/chunk-YIETFYCL.js.map +1 -0
  39. package/dist/client.cjs +438 -426
  40. package/dist/client.cjs.map +1 -1
  41. package/dist/client.js +27 -26
  42. package/dist/edge.cjs +1 -1
  43. package/dist/edge.cjs.map +1 -1
  44. package/dist/edge.js +4 -4
  45. package/dist/{finish-Ddj1MPGt.d.ts → finish-DBKuo8yj.d.ts} +1 -1
  46. package/dist/index.cjs +438 -445
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.js +29 -29
  49. package/dist/modelrouter/core.cjs +1 -1
  50. package/dist/modelrouter/core.cjs.map +1 -1
  51. package/dist/modelrouter/core.js +3 -3
  52. package/dist/modelrouter/index.cjs +1 -1
  53. package/dist/modelrouter/index.cjs.map +1 -1
  54. package/dist/modelrouter/index.js +3 -3
  55. package/dist/subagents/anthropic.cjs +434 -422
  56. package/dist/subagents/anthropic.cjs.map +1 -1
  57. package/dist/subagents/anthropic.js +9 -8
  58. package/dist/subagents/vercel.cjs +434 -422
  59. package/dist/subagents/vercel.cjs.map +1 -1
  60. package/dist/subagents/vercel.js +9 -8
  61. package/dist/tools/browser/anthropic.cjs +1 -1
  62. package/dist/tools/browser/anthropic.cjs.map +1 -1
  63. package/dist/tools/browser/anthropic.js +5 -5
  64. package/dist/tools/browser/core.cjs +1 -1
  65. package/dist/tools/browser/core.cjs.map +1 -1
  66. package/dist/tools/browser/core.js +4 -4
  67. package/dist/tools/browser/index.cjs +1 -1
  68. package/dist/tools/browser/index.cjs.map +1 -1
  69. package/dist/tools/browser/index.js +7 -7
  70. package/dist/tools/browser/openai.cjs +1 -1
  71. package/dist/tools/browser/openai.cjs.map +1 -1
  72. package/dist/tools/browser/openai.js +5 -5
  73. package/dist/tools/browser/profiles/core.cjs +1 -1
  74. package/dist/tools/browser/profiles/core.cjs.map +1 -1
  75. package/dist/tools/browser/profiles/core.js +3 -3
  76. package/dist/tools/browser/profiles/index.cjs +1 -1
  77. package/dist/tools/browser/profiles/index.cjs.map +1 -1
  78. package/dist/tools/browser/profiles/index.js +3 -3
  79. package/dist/tools/browser/vercel.cjs +1 -1
  80. package/dist/tools/browser/vercel.cjs.map +1 -1
  81. package/dist/tools/browser/vercel.js +5 -5
  82. package/dist/tools/codebase_search/anthropic.cjs +1 -1
  83. package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
  84. package/dist/tools/codebase_search/anthropic.js +4 -4
  85. package/dist/tools/codebase_search/core.cjs +1 -1
  86. package/dist/tools/codebase_search/core.cjs.map +1 -1
  87. package/dist/tools/codebase_search/core.js +3 -3
  88. package/dist/tools/codebase_search/index.cjs +1 -1
  89. package/dist/tools/codebase_search/index.cjs.map +1 -1
  90. package/dist/tools/codebase_search/index.js +6 -6
  91. package/dist/tools/codebase_search/openai.cjs +1 -1
  92. package/dist/tools/codebase_search/openai.cjs.map +1 -1
  93. package/dist/tools/codebase_search/openai.js +4 -4
  94. package/dist/tools/codebase_search/vercel.cjs +1 -1
  95. package/dist/tools/codebase_search/vercel.cjs.map +1 -1
  96. package/dist/tools/codebase_search/vercel.js +4 -4
  97. package/dist/tools/fastapply/anthropic.cjs +1 -1
  98. package/dist/tools/fastapply/anthropic.cjs.map +1 -1
  99. package/dist/tools/fastapply/anthropic.js +4 -4
  100. package/dist/tools/fastapply/apply.cjs +1 -1
  101. package/dist/tools/fastapply/apply.cjs.map +1 -1
  102. package/dist/tools/fastapply/apply.js +2 -2
  103. package/dist/tools/fastapply/core.cjs +1 -1
  104. package/dist/tools/fastapply/core.cjs.map +1 -1
  105. package/dist/tools/fastapply/core.js +3 -3
  106. package/dist/tools/fastapply/index.cjs +1 -1
  107. package/dist/tools/fastapply/index.cjs.map +1 -1
  108. package/dist/tools/fastapply/index.js +6 -6
  109. package/dist/tools/fastapply/openai.cjs +1 -1
  110. package/dist/tools/fastapply/openai.cjs.map +1 -1
  111. package/dist/tools/fastapply/openai.js +4 -4
  112. package/dist/tools/fastapply/vercel.cjs +1 -1
  113. package/dist/tools/fastapply/vercel.cjs.map +1 -1
  114. package/dist/tools/fastapply/vercel.js +4 -4
  115. package/dist/tools/index.cjs +1 -1
  116. package/dist/tools/index.cjs.map +1 -1
  117. package/dist/tools/index.js +6 -6
  118. package/dist/tools/utils/resilience.cjs +1 -1
  119. package/dist/tools/utils/resilience.cjs.map +1 -1
  120. package/dist/tools/utils/resilience.js +2 -2
  121. package/dist/tools/warp_grep/agent/config.cjs +3 -4
  122. package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
  123. package/dist/tools/warp_grep/agent/config.d.ts +1 -2
  124. package/dist/tools/warp_grep/agent/config.js +1 -1
  125. package/dist/tools/warp_grep/agent/parser.cjs +121 -52
  126. package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
  127. package/dist/tools/warp_grep/agent/parser.d.ts +5 -12
  128. package/dist/tools/warp_grep/agent/parser.js +3 -7
  129. package/dist/tools/warp_grep/agent/runner.cjs +416 -335
  130. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  131. package/dist/tools/warp_grep/agent/runner.d.ts +3 -6
  132. package/dist/tools/warp_grep/agent/runner.js +6 -5
  133. package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
  134. package/dist/tools/warp_grep/agent/types.d.ts +3 -22
  135. package/dist/tools/warp_grep/anthropic.cjs +434 -422
  136. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  137. package/dist/tools/warp_grep/anthropic.js +9 -8
  138. package/dist/tools/warp_grep/client.cjs +434 -422
  139. package/dist/tools/warp_grep/client.cjs.map +1 -1
  140. package/dist/tools/warp_grep/client.js +8 -7
  141. package/dist/tools/warp_grep/gemini.cjs +434 -422
  142. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  143. package/dist/tools/warp_grep/gemini.js +8 -7
  144. package/dist/tools/warp_grep/gemini.js.map +1 -1
  145. package/dist/tools/warp_grep/harness.cjs +176 -164
  146. package/dist/tools/warp_grep/harness.cjs.map +1 -1
  147. package/dist/tools/warp_grep/harness.d.ts +38 -17
  148. package/dist/tools/warp_grep/harness.js +14 -15
  149. package/dist/tools/warp_grep/harness.js.map +1 -1
  150. package/dist/tools/warp_grep/index.cjs +434 -441
  151. package/dist/tools/warp_grep/index.cjs.map +1 -1
  152. package/dist/tools/warp_grep/index.d.ts +1 -1
  153. package/dist/tools/warp_grep/index.js +10 -10
  154. package/dist/tools/warp_grep/openai.cjs +434 -422
  155. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  156. package/dist/tools/warp_grep/openai.js +9 -8
  157. package/dist/tools/warp_grep/providers/local.cjs +2 -43
  158. package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
  159. package/dist/tools/warp_grep/providers/local.d.ts +1 -5
  160. package/dist/tools/warp_grep/providers/local.js +2 -2
  161. package/dist/tools/warp_grep/providers/remote.cjs +2 -32
  162. package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
  163. package/dist/tools/warp_grep/providers/remote.d.ts +1 -9
  164. package/dist/tools/warp_grep/providers/remote.js +2 -2
  165. package/dist/tools/warp_grep/providers/types.cjs.map +1 -1
  166. package/dist/tools/warp_grep/providers/types.d.ts +1 -14
  167. package/dist/tools/warp_grep/vercel.cjs +434 -422
  168. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  169. package/dist/tools/warp_grep/vercel.js +9 -8
  170. package/dist/version.cjs +1 -1
  171. package/dist/version.cjs.map +1 -1
  172. package/dist/version.js +1 -1
  173. package/package.json +1 -1
  174. package/dist/chunk-4LWMPKSB.js.map +0 -1
  175. package/dist/chunk-4Y2NM6JD.js.map +0 -1
  176. package/dist/chunk-B3AKP3RA.js.map +0 -1
  177. package/dist/chunk-CMSHXALI.js +0 -60
  178. package/dist/chunk-CMSHXALI.js.map +0 -1
  179. package/dist/chunk-I3J46TSB.js.map +0 -1
  180. package/dist/chunk-OPEQQGST.js +0 -396
  181. package/dist/chunk-OPEQQGST.js.map +0 -1
  182. /package/dist/{chunk-HBIW2XV2.js.map → chunk-4PBUB77N.js.map} +0 -0
  183. /package/dist/{chunk-SUE4GYA2.js.map → chunk-BDHKL3MT.js.map} +0 -0
  184. /package/dist/{chunk-S54SPKX3.js.map → chunk-BIQ7234U.js.map} +0 -0
  185. /package/dist/{chunk-MRPASJBX.js.map → chunk-E45FW5EK.js.map} +0 -0
  186. /package/dist/{chunk-BXRJYLRS.js.map → chunk-E4YKEKGW.js.map} +0 -0
  187. /package/dist/{chunk-G23BI5CQ.js.map → chunk-EU7OLX4Z.js.map} +0 -0
  188. /package/dist/{chunk-HE7K2QNQ.js.map → chunk-FBOJJ3UY.js.map} +0 -0
  189. /package/dist/{chunk-HYRHI2UL.js.map → chunk-FIVYDIHX.js.map} +0 -0
  190. /package/dist/{chunk-GXM3G7Z4.js.map → chunk-FYO46OT6.js.map} +0 -0
  191. /package/dist/{chunk-GHPQYSSF.js.map → chunk-GJUB3ECP.js.map} +0 -0
  192. /package/dist/{chunk-MTJ3PR4M.js.map → chunk-I7SFRYTX.js.map} +0 -0
  193. /package/dist/{chunk-PX7ODEML.js.map → chunk-J2HIK4GB.js.map} +0 -0
  194. /package/dist/{chunk-RZXS4ADX.js.map → chunk-JSWNBCGS.js.map} +0 -0
  195. /package/dist/{chunk-GXCWKYGU.js.map → chunk-KYKRRF7E.js.map} +0 -0
  196. /package/dist/{chunk-N7TTZIBK.js.map → chunk-MMBQKN4G.js.map} +0 -0
  197. /package/dist/{chunk-JMUAQQJU.js.map → chunk-NKUSUSVI.js.map} +0 -0
  198. /package/dist/{chunk-VRV5UYTN.js.map → chunk-OV57JBMB.js.map} +0 -0
  199. /package/dist/{chunk-EPIOAODF.js.map → chunk-Q36MNOFA.js.map} +0 -0
  200. /package/dist/{chunk-JRBU4UNP.js.map → chunk-QRSWXP4K.js.map} +0 -0
  201. /package/dist/{chunk-IRWHN55G.js.map → chunk-T564HFSH.js.map} +0 -0
  202. /package/dist/{chunk-6CFKWZK3.js.map → chunk-UVNENJ6H.js.map} +0 -0
  203. /package/dist/{chunk-5FCXLQJU.js.map → chunk-UYPWKQKV.js.map} +0 -0
  204. /package/dist/{chunk-BAF33L6C.js.map → chunk-V73GO5AJ.js.map} +0 -0
  205. /package/dist/{chunk-XL7R3XN5.js.map → chunk-VZ6VYRQB.js.map} +0 -0
@@ -20,67 +20,136 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // tools/warp_grep/agent/parser.ts
21
21
  var parser_exports = {};
22
22
  __export(parser_exports, {
23
- extractPathFromCommand: () => extractPathFromCommand,
24
- parseFinishFiles: () => parseFinishFiles,
25
- parseReadLines: () => parseReadLines
23
+ LLMResponseParser: () => LLMResponseParser
26
24
  });
27
25
  module.exports = __toCommonJS(parser_exports);
28
- function parseReadLines(linesStr) {
29
- const ranges = [];
30
- for (const rangeStr of linesStr.split(",")) {
31
- const trimmed = rangeStr.trim();
32
- if (!trimmed) continue;
33
- const parts = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
34
- if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {
35
- ranges.push([parts[0], parts[1]]);
36
- } else if (Number.isFinite(parts[0])) {
37
- ranges.push([parts[0], parts[0]]);
38
- }
39
- }
40
- if (ranges.length === 1) return { start: ranges[0][0], end: ranges[0][1] };
41
- if (ranges.length > 1) return { lines: ranges };
42
- return {};
26
+ var VALID_COMMANDS = ["list_directory", "ripgrep", "read", "finish"];
27
+ function isValidCommand(name) {
28
+ return VALID_COMMANDS.includes(name);
43
29
  }
44
- function parseFinishFiles(filesStr) {
45
- const files = [];
46
- for (const line of filesStr.trim().split(/\s+/)) {
47
- const trimmed = line.trim();
48
- if (!trimmed) continue;
49
- const colonIdx = trimmed.indexOf(":");
50
- if (colonIdx === -1) {
51
- files.push({ path: trimmed, lines: "*" });
52
- continue;
53
- }
54
- const filePath = trimmed.slice(0, colonIdx);
55
- const rangesPart = trimmed.slice(colonIdx + 1);
56
- if (!rangesPart.trim() || rangesPart.trim() === "*") {
57
- files.push({ path: filePath, lines: "*" });
58
- continue;
30
+ function parseQwen3ToolCalls(text) {
31
+ const tools = [];
32
+ const toolCallRegex = /<tool_call>\s*<function=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/function>\s*<\/tool_call>/gi;
33
+ let match;
34
+ while ((match = toolCallRegex.exec(text)) !== null) {
35
+ const funcName = match[1].toLowerCase();
36
+ const body = match[2];
37
+ if (!isValidCommand(funcName)) continue;
38
+ const params = {};
39
+ const paramRegex = /<parameter=([a-z_][a-z0-9_]*)>([\s\S]*?)<\/parameter>/gi;
40
+ let paramMatch;
41
+ while ((paramMatch = paramRegex.exec(body)) !== null) {
42
+ params[paramMatch[1].toLowerCase()] = paramMatch[2].trim();
59
43
  }
60
- const ranges = [];
61
- for (const rangeStr of rangesPart.split(",")) {
62
- const rt = rangeStr.trim();
63
- if (!rt) continue;
64
- const parts = rt.split("-").map((v) => parseInt(v.trim(), 10));
65
- if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {
66
- ranges.push([parts[0], parts[1]]);
67
- } else if (Number.isFinite(parts[0])) {
68
- ranges.push([parts[0], parts[0]]);
44
+ if (funcName === "ripgrep") {
45
+ const pattern = params.pattern;
46
+ if (!pattern) continue;
47
+ const args = {
48
+ pattern,
49
+ path: params.path || ".",
50
+ ...params.glob && { glob: params.glob },
51
+ ...params.context_lines && { context_lines: parseInt(params.context_lines, 10) },
52
+ ...params.case_sensitive && { case_sensitive: params.case_sensitive === "true" }
53
+ };
54
+ tools.push({ name: "grep", arguments: args });
55
+ } else if (funcName === "list_directory") {
56
+ const command = params.command;
57
+ const directPath = params.path;
58
+ let dirPath = directPath || ".";
59
+ if (!directPath && command) {
60
+ const tokens = command.trim().split(/\s+/);
61
+ const pathTokens = tokens.slice(1).filter((t) => !t.startsWith("-") && !t.startsWith("|") && !t.startsWith("\\("));
62
+ if (pathTokens.length > 0) {
63
+ dirPath = pathTokens[0];
64
+ }
65
+ }
66
+ tools.push({ name: "list_directory", arguments: { path: dirPath, pattern: params.pattern || null } });
67
+ } else if (funcName === "read") {
68
+ const filePath = params.path;
69
+ if (!filePath) continue;
70
+ const args = { path: filePath };
71
+ const linesStr = params.lines;
72
+ if (linesStr) {
73
+ const ranges = [];
74
+ for (const rangeStr of linesStr.split(",")) {
75
+ const trimmed = rangeStr.trim();
76
+ if (!trimmed) continue;
77
+ const [s, e] = trimmed.split("-").map((v) => parseInt(v.trim(), 10));
78
+ if (Number.isFinite(s) && Number.isFinite(e)) {
79
+ ranges.push([s, e]);
80
+ } else if (Number.isFinite(s)) {
81
+ ranges.push([s, s]);
82
+ }
83
+ }
84
+ if (ranges.length === 1) {
85
+ args.start = ranges[0][0];
86
+ args.end = ranges[0][1];
87
+ } else if (ranges.length > 1) {
88
+ args.lines = ranges;
89
+ }
90
+ }
91
+ tools.push({ name: "read", arguments: args });
92
+ } else if (funcName === "finish") {
93
+ if (params.result && !params.files) {
94
+ tools.push({ name: "finish", arguments: { files: [], textResult: params.result } });
95
+ continue;
96
+ }
97
+ const filesStr = params.files;
98
+ if (!filesStr) {
99
+ tools.push({ name: "finish", arguments: { files: [], textResult: "No relevant code found." } });
100
+ continue;
101
+ }
102
+ const files = [];
103
+ for (const line of filesStr.split("\n")) {
104
+ const trimmed = line.trim();
105
+ if (!trimmed) continue;
106
+ const colonIdx = trimmed.indexOf(":");
107
+ if (colonIdx === -1) {
108
+ files.push({ path: trimmed, lines: "*" });
109
+ } else {
110
+ const filePath = trimmed.slice(0, colonIdx);
111
+ const rangesPart = trimmed.slice(colonIdx + 1);
112
+ const ranges = [];
113
+ for (const rangeStr of rangesPart.split(",")) {
114
+ const rt = rangeStr.trim();
115
+ if (!rt || rt === "*") {
116
+ files.push({ path: filePath, lines: "*" });
117
+ break;
118
+ }
119
+ const [s, e] = rt.split("-").map((v) => parseInt(v.trim(), 10));
120
+ if (Number.isFinite(s) && Number.isFinite(e)) {
121
+ ranges.push([s, e]);
122
+ } else if (Number.isFinite(s)) {
123
+ ranges.push([s, s]);
124
+ }
125
+ }
126
+ if (ranges.length > 0) {
127
+ files.push({ path: filePath, lines: ranges });
128
+ } else if (!files.some((f) => f.path === filePath)) {
129
+ files.push({ path: filePath, lines: "*" });
130
+ }
131
+ }
132
+ }
133
+ if (files.length > 0) {
134
+ tools.push({ name: "finish", arguments: { files } });
135
+ } else {
136
+ tools.push({ name: "finish", arguments: { files: [], textResult: filesStr } });
69
137
  }
70
138
  }
71
- files.push({ path: filePath, lines: ranges.length > 0 ? ranges : "*" });
72
139
  }
73
- return files;
74
- }
75
- function extractPathFromCommand(command) {
76
- const tokens = command.trim().split(/\s+/);
77
- const pathTokens = tokens.slice(1).filter((t) => !t.startsWith("-") && !t.startsWith("|") && !t.startsWith("\\("));
78
- return pathTokens[0] || ".";
140
+ return tools;
79
141
  }
142
+ var LLMResponseParser = class {
143
+ parse(text) {
144
+ if (typeof text !== "string") {
145
+ throw new TypeError("Command text must be a string.");
146
+ }
147
+ const withoutThink = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
148
+ return parseQwen3ToolCalls(withoutThink);
149
+ }
150
+ };
80
151
  // Annotate the CommonJS export names for ESM import in node:
81
152
  0 && (module.exports = {
82
- extractPathFromCommand,
83
- parseFinishFiles,
84
- parseReadLines
153
+ LLMResponseParser
85
154
  });
86
155
  //# sourceMappingURL=parser.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../tools/warp_grep/agent/parser.ts"],"sourcesContent":["// Helpers for parsing string-format tool arguments from OpenAI tool calls\n\nimport type { FinishFileSpec } from './types.js';\n\n/** Parse \"lines\" string from read tool (e.g. \"1-50\" or \"1-20,45-80\") into structured args */\nexport function parseReadLines(linesStr: string): { start?: number; end?: number; lines?: Array<[number, number]> } {\n const ranges: Array<[number, number]> = [];\n for (const rangeStr of linesStr.split(',')) {\n const trimmed = rangeStr.trim();\n if (!trimmed) continue;\n const parts = trimmed.split('-').map(v => parseInt(v.trim(), 10));\n if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {\n ranges.push([parts[0], parts[1]]);\n } else if (Number.isFinite(parts[0])) {\n ranges.push([parts[0], parts[0]]);\n }\n }\n if (ranges.length === 1) return { start: ranges[0][0], end: ranges[0][1] };\n if (ranges.length > 1) return { lines: ranges };\n return {};\n}\n\n/** Parse \"files\" string from finish tool (e.g. \"src/auth.py:1-50\\nsrc/user.py\" or space-separated) into FinishFileSpec[] */\nexport function parseFinishFiles(filesStr: string): FinishFileSpec[] {\n const files: FinishFileSpec[] = [];\n // Split on whitespace (training uses space-separated, SDK also supports newlines)\n for (const line of filesStr.trim().split(/\\s+/)) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n const colonIdx = trimmed.indexOf(':');\n if (colonIdx === -1) {\n files.push({ path: trimmed, lines: '*' });\n continue;\n }\n const filePath = trimmed.slice(0, colonIdx);\n const rangesPart = trimmed.slice(colonIdx + 1);\n if (!rangesPart.trim() || rangesPart.trim() === '*') {\n files.push({ path: filePath, lines: '*' });\n continue;\n }\n const ranges: Array<[number, number]> = [];\n for (const rangeStr of rangesPart.split(',')) {\n const rt = rangeStr.trim();\n if (!rt) continue;\n const parts = rt.split('-').map(v => parseInt(v.trim(), 10));\n if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {\n ranges.push([parts[0], parts[1]]);\n } else if (Number.isFinite(parts[0])) {\n ranges.push([parts[0], parts[0]]);\n }\n }\n files.push({ path: filePath, lines: ranges.length > 0 ? ranges : '*' });\n }\n return files;\n}\n\n/** Extract directory path from a list_directory command string (e.g. \"ls -la src/\" → \"src/\") */\nexport function extractPathFromCommand(command: string): string {\n const tokens = command.trim().split(/\\s+/);\n const pathTokens = tokens.slice(1).filter(t => !t.startsWith('-') && !t.startsWith('|') && !t.startsWith('\\\\('));\n return pathTokens[0] || '.';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,SAAS,eAAe,UAAqF;AAClH,QAAM,SAAkC,CAAC;AACzC,aAAW,YAAY,SAAS,MAAM,GAAG,GAAG;AAC1C,UAAM,UAAU,SAAS,KAAK;AAC9B,QAAI,CAAC,QAAS;AACd,UAAM,QAAQ,QAAQ,MAAM,GAAG,EAAE,IAAI,OAAK,SAAS,EAAE,KAAK,GAAG,EAAE,CAAC;AAChE,QAAI,MAAM,UAAU,KAAK,OAAO,SAAS,MAAM,CAAC,CAAC,KAAK,OAAO,SAAS,MAAM,CAAC,CAAC,GAAG;AAC/E,aAAO,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;AAAA,IAClC,WAAW,OAAO,SAAS,MAAM,CAAC,CAAC,GAAG;AACpC,aAAO,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;AAAA,IAClC;AAAA,EACF;AACA,MAAI,OAA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KAAK,EAAE,MAAM,UAAU,OAAO,OAAO,SAAS,IAAI,SAAS,IAAI,CAAC;AAAA,EACxE;AACA,SAAO;AACT;AAGO,SAAS,uBAAuB,SAAyB;AAC9D,QAAM,SAAS,QAAQ,KAAK,EAAE,MAAM,KAAK;AACzC,QAAM,aAAa,OAAO,MAAM,CAAC,EAAE,OAAO,OAAK,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC,EAAE,WAAW,KAAK,CAAC;AAC/G,SAAO,WAAW,CAAC,KAAK;AAC1B;","names":[]}
1
+ {"version":3,"sources":["../../../../tools/warp_grep/agent/parser.ts"],"sourcesContent":["// Parses assistant lines into structured tool calls (Qwen3-Coder-Next format only)\nimport type { ToolCall } from './types.js';\n\nconst VALID_COMMANDS = ['list_directory', 'ripgrep', 'read', 'finish'] as const;\ntype ValidCommand = typeof VALID_COMMANDS[number];\n\nfunction isValidCommand(name: string): name is ValidCommand {\n return VALID_COMMANDS.includes(name as ValidCommand);\n}\n\n/**\n * Parse Qwen3-Coder-Next native XML tool call format:\n * <tool_call><function=NAME><parameter=KEY>VALUE</parameter></function></tool_call>\n */\nfunction parseQwen3ToolCalls(text: string): ToolCall[] {\n const tools: ToolCall[] = [];\n const toolCallRegex = /<tool_call>\\s*<function=([a-z_][a-z0-9_]*)>([\\s\\S]*?)<\\/function>\\s*<\\/tool_call>/gi;\n let match;\n\n while ((match = toolCallRegex.exec(text)) !== null) {\n const funcName = match[1].toLowerCase();\n const body = match[2];\n\n if (!isValidCommand(funcName)) continue;\n\n // Extract all <parameter=KEY>VALUE</parameter> pairs\n const params: Record<string, string> = {};\n const paramRegex = /<parameter=([a-z_][a-z0-9_]*)>([\\s\\S]*?)<\\/parameter>/gi;\n let paramMatch;\n while ((paramMatch = paramRegex.exec(body)) !== null) {\n params[paramMatch[1].toLowerCase()] = paramMatch[2].trim();\n }\n\n if (funcName === 'ripgrep') {\n const pattern = params.pattern;\n if (!pattern) continue;\n const args: Record<string, unknown> = {\n pattern,\n path: params.path || '.',\n ...(params.glob && { glob: params.glob }),\n ...(params.context_lines && { context_lines: parseInt(params.context_lines, 10) }),\n ...(params.case_sensitive && { case_sensitive: params.case_sensitive === 'true' }),\n };\n tools.push({ name: 'grep', arguments: args });\n } else if (funcName === 'list_directory') {\n // Extract path from command parameter (best effort: look for target directory)\n const command = params.command;\n const directPath = params.path;\n let dirPath = directPath || '.';\n if (!directPath && command) {\n // Try to extract a meaningful path from the command string\n // Common patterns: \"find <path> ...\", \"ls <path>\", \"ls -la <path>\"\n // Skip the command name and any flags (tokens starting with -, \\(, |)\n const tokens = command.trim().split(/\\s+/);\n const pathTokens = tokens.slice(1).filter(t => !t.startsWith('-') && !t.startsWith('|') && !t.startsWith('\\\\('));\n if (pathTokens.length > 0) {\n dirPath = pathTokens[0];\n }\n }\n tools.push({ name: 'list_directory', arguments: { path: dirPath, pattern: params.pattern || null } });\n } else if (funcName === 'read') {\n const filePath = params.path;\n if (!filePath) continue;\n const args: Record<string, unknown> = { path: filePath };\n const linesStr = params.lines;\n if (linesStr) {\n const ranges: Array<[number, number]> = [];\n for (const rangeStr of linesStr.split(',')) {\n const trimmed = rangeStr.trim();\n if (!trimmed) continue;\n const [s, e] = trimmed.split('-').map(v => parseInt(v.trim(), 10));\n if (Number.isFinite(s) && Number.isFinite(e)) {\n ranges.push([s, e]);\n } else if (Number.isFinite(s)) {\n ranges.push([s, s]);\n }\n }\n if (ranges.length === 1) {\n args.start = ranges[0][0];\n args.end = ranges[0][1];\n } else if (ranges.length > 1) {\n args.lines = ranges;\n }\n }\n tools.push({ name: 'read', arguments: args });\n } else if (funcName === 'finish') {\n // If the model used \"result\" parameter instead of \"files\", treat as text-only finish\n if (params.result && !params.files) {\n tools.push({ name: 'finish', arguments: { files: [], textResult: params.result } });\n continue;\n }\n const filesStr = params.files;\n if (!filesStr) {\n tools.push({ name: 'finish', arguments: { files: [], textResult: 'No relevant code found.' } });\n continue;\n }\n // Parse flat string format: \"path:start-end\\npath\" or \"path\\npath:start-end\"\n const files: Array<{ path: string; lines: '*' | Array<[number, number]> }> = [];\n for (const line of filesStr.split('\\n')) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n const colonIdx = trimmed.indexOf(':');\n if (colonIdx === -1) {\n // No colon — whole file\n files.push({ path: trimmed, lines: '*' });\n } else {\n const filePath = trimmed.slice(0, colonIdx);\n const rangesPart = trimmed.slice(colonIdx + 1);\n const ranges: Array<[number, number]> = [];\n for (const rangeStr of rangesPart.split(',')) {\n const rt = rangeStr.trim();\n if (!rt || rt === '*') {\n // Whole file marker\n files.push({ path: filePath, lines: '*' });\n break;\n }\n const [s, e] = rt.split('-').map(v => parseInt(v.trim(), 10));\n if (Number.isFinite(s) && Number.isFinite(e)) {\n ranges.push([s, e]);\n } else if (Number.isFinite(s)) {\n // Single line\n ranges.push([s, s]);\n }\n }\n if (ranges.length > 0) {\n files.push({ path: filePath, lines: ranges });\n } else if (!files.some(f => f.path === filePath)) {\n files.push({ path: filePath, lines: '*' });\n }\n }\n }\n if (files.length > 0) {\n tools.push({ name: 'finish', arguments: { files } });\n } else {\n tools.push({ name: 'finish', arguments: { files: [], textResult: filesStr } });\n }\n }\n }\n\n return tools;\n}\n\nexport class LLMResponseParser {\n parse(text: string): ToolCall[] {\n if (typeof text !== 'string') {\n throw new TypeError('Command text must be a string.');\n }\n\n // Strip <think> blocks\n const withoutThink = text.replace(/<think>[\\s\\S]*?<\\/think>/gi, '');\n\n // Parse Qwen3 <tool_call><function=...> format\n return parseQwen3ToolCalls(withoutThink);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAM,iBAAiB,CAAC,kBAAkB,WAAW,QAAQ,QAAQ;AAGrE,SAAS,eAAe,MAAoC;AAC1D,SAAO,eAAe,SAAS,IAAoB;AACrD;AAMA,SAAS,oBAAoB,MAA0B;AACrD,QAAM,QAAoB,CAAC;AAC3B,QAAM,gBAAg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E,CAAC;AAAA,MACrD,OAAO;AACL,cAAM,KAAK,EAAE,MAAM,UAAU,WAAW,EAAE,OAAO,CAAC,GAAG,YAAY,SAAS,EAAE,CAAC;AAAA,MAC/E;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEO,IAAM,oBAAN,MAAwB;AAAA,EAC7B,MAAM,MAA0B;AAC9B,QAAI,OAAO,SAAS,UAAU;AAC5B,YAAM,IAAI,UAAU,gCAAgC;AAAA,IACtD;AAGA,UAAM,eAAe,KAAK,QAAQ,8BAA8B,EAAE;AAGlE,WAAO,oBAAoB,YAAY;AAAA,EACzC;AACF;","names":[]}
@@ -1,15 +1,8 @@
1
- import { FinishFileSpec } from './types.js';
1
+ import { ToolCall } from './types.js';
2
2
  import '../../utils/resilience.js';
3
3
 
4
- /** Parse "lines" string from read tool (e.g. "1-50" or "1-20,45-80") into structured args */
5
- declare function parseReadLines(linesStr: string): {
6
- start?: number;
7
- end?: number;
8
- lines?: Array<[number, number]>;
9
- };
10
- /** Parse "files" string from finish tool (e.g. "src/auth.py:1-50\nsrc/user.py" or space-separated) into FinishFileSpec[] */
11
- declare function parseFinishFiles(filesStr: string): FinishFileSpec[];
12
- /** Extract directory path from a list_directory command string (e.g. "ls -la src/" → "src/") */
13
- declare function extractPathFromCommand(command: string): string;
4
+ declare class LLMResponseParser {
5
+ parse(text: string): ToolCall[];
6
+ }
14
7
 
15
- export { extractPathFromCommand, parseFinishFiles, parseReadLines };
8
+ export { LLMResponseParser };
@@ -1,12 +1,8 @@
1
1
  import {
2
- extractPathFromCommand,
3
- parseFinishFiles,
4
- parseReadLines
5
- } from "../../../chunk-CMSHXALI.js";
2
+ LLMResponseParser
3
+ } from "../../../chunk-VCKJ22DX.js";
6
4
  import "../../../chunk-PZ5AY32C.js";
7
5
  export {
8
- extractPathFromCommand,
9
- parseFinishFiles,
10
- parseReadLines
6
+ LLMResponseParser
11
7
  };
12
8
  //# sourceMappingURL=parser.js.map