@morphllm/morphsdk 0.2.146 → 0.2.147

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-J2HIK4GB.js → chunk-334JOOAC.js} +2 -2
  2. package/dist/{chunk-QRSWXP4K.js → chunk-3GXWZ7TI.js} +2 -2
  3. package/dist/{chunk-BDHKL3MT.js → chunk-4LZK67MS.js} +2 -2
  4. package/dist/{chunk-UVNENJ6H.js → chunk-4XNHMFVU.js} +3 -3
  5. package/dist/{chunk-HZOTLGJH.js → chunk-4Y2NM6JD.js} +42 -2
  6. package/dist/chunk-4Y2NM6JD.js.map +1 -0
  7. package/dist/{chunk-V73GO5AJ.js → chunk-7HKJUVAK.js} +2 -2
  8. package/dist/{chunk-NF2QWJDY.js → chunk-B3AKP3RA.js} +31 -2
  9. package/dist/chunk-B3AKP3RA.js.map +1 -0
  10. package/dist/{chunk-VZ6VYRQB.js → chunk-BXQYZR7O.js} +2 -2
  11. package/dist/{chunk-GJUB3ECP.js → chunk-CJD4ZFOX.js} +2 -2
  12. package/dist/chunk-CMSHXALI.js +60 -0
  13. package/dist/chunk-CMSHXALI.js.map +1 -0
  14. package/dist/{chunk-KYKRRF7E.js → chunk-DYCRGTRN.js} +2 -2
  15. package/dist/{chunk-EU7OLX4Z.js → chunk-ETKDGHOB.js} +2 -2
  16. package/dist/{chunk-SJYAKVSS.js → chunk-G4TRYATX.js} +2 -2
  17. package/dist/{chunk-SJYAKVSS.js.map → chunk-G4TRYATX.js.map} +1 -1
  18. package/dist/chunk-GK56GCLU.js +401 -0
  19. package/dist/chunk-GK56GCLU.js.map +1 -0
  20. package/dist/{chunk-I7SFRYTX.js → chunk-HWED34T3.js} +2 -2
  21. package/dist/{chunk-FIVYDIHX.js → chunk-HYRHI2UL.js} +1 -1
  22. package/dist/{chunk-DKODF3YG.js → chunk-I3J46TSB.js} +5 -4
  23. package/dist/chunk-I3J46TSB.js.map +1 -0
  24. package/dist/{chunk-E4YKEKGW.js → chunk-KV2CC4N7.js} +2 -2
  25. package/dist/{chunk-BIQ7234U.js → chunk-LSPEWVCD.js} +2 -2
  26. package/dist/{chunk-OV57JBMB.js → chunk-N7XLC7BK.js} +2 -2
  27. package/dist/{chunk-FBOJJ3UY.js → chunk-O356YR2N.js} +17 -17
  28. package/dist/{chunk-JSWNBCGS.js → chunk-PIHW2GSK.js} +2 -2
  29. package/dist/{chunk-UYPWKQKV.js → chunk-RGNP6FNH.js} +2 -2
  30. package/dist/{chunk-YIETFYCL.js → chunk-T7HF2TDQ.js} +75 -48
  31. package/dist/chunk-T7HF2TDQ.js.map +1 -0
  32. package/dist/{chunk-NKUSUSVI.js → chunk-T7VCGKXB.js} +3 -3
  33. package/dist/{chunk-Q36MNOFA.js → chunk-UZ2QUWJD.js} +2 -2
  34. package/dist/{chunk-FYO46OT6.js → chunk-VTTU7MJB.js} +2 -2
  35. package/dist/{chunk-4PBUB77N.js → chunk-XADFYB6B.js} +2 -2
  36. package/dist/{chunk-T564HFSH.js → chunk-XS4PO4FC.js} +1 -1
  37. package/dist/{chunk-E45FW5EK.js → chunk-YH3XIVF2.js} +2 -2
  38. package/dist/{chunk-MMBQKN4G.js → chunk-ZZW4B4GG.js} +2 -2
  39. package/dist/client.cjs +439 -446
  40. package/dist/client.cjs.map +1 -1
  41. package/dist/client.js +26 -27
  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-DBKuo8yj.d.ts → finish-Ddj1MPGt.d.ts} +1 -1
  46. package/dist/index.cjs +458 -446
  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 +435 -442
  56. package/dist/subagents/anthropic.cjs.map +1 -1
  57. package/dist/subagents/anthropic.js +8 -9
  58. package/dist/subagents/vercel.cjs +435 -442
  59. package/dist/subagents/vercel.cjs.map +1 -1
  60. package/dist/subagents/vercel.js +8 -9
  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 +4 -3
  122. package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
  123. package/dist/tools/warp_grep/agent/config.d.ts +2 -1
  124. package/dist/tools/warp_grep/agent/config.js +1 -1
  125. package/dist/tools/warp_grep/agent/parser.cjs +52 -121
  126. package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
  127. package/dist/tools/warp_grep/agent/parser.d.ts +12 -5
  128. package/dist/tools/warp_grep/agent/parser.js +7 -3
  129. package/dist/tools/warp_grep/agent/runner.cjs +348 -424
  130. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  131. package/dist/tools/warp_grep/agent/runner.d.ts +6 -3
  132. package/dist/tools/warp_grep/agent/runner.js +5 -6
  133. package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
  134. package/dist/tools/warp_grep/agent/types.d.ts +22 -3
  135. package/dist/tools/warp_grep/anthropic.cjs +435 -442
  136. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  137. package/dist/tools/warp_grep/anthropic.js +8 -9
  138. package/dist/tools/warp_grep/client.cjs +435 -442
  139. package/dist/tools/warp_grep/client.cjs.map +1 -1
  140. package/dist/tools/warp_grep/client.js +7 -8
  141. package/dist/tools/warp_grep/gemini.cjs +435 -442
  142. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  143. package/dist/tools/warp_grep/gemini.js +7 -8
  144. package/dist/tools/warp_grep/gemini.js.map +1 -1
  145. package/dist/tools/warp_grep/harness.cjs +168 -180
  146. package/dist/tools/warp_grep/harness.cjs.map +1 -1
  147. package/dist/tools/warp_grep/harness.d.ts +17 -38
  148. package/dist/tools/warp_grep/harness.js +15 -14
  149. package/dist/tools/warp_grep/harness.js.map +1 -1
  150. package/dist/tools/warp_grep/index.cjs +454 -442
  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 +435 -442
  155. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  156. package/dist/tools/warp_grep/openai.js +8 -9
  157. package/dist/tools/warp_grep/providers/local.cjs +43 -2
  158. package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
  159. package/dist/tools/warp_grep/providers/local.d.ts +5 -1
  160. package/dist/tools/warp_grep/providers/local.js +2 -2
  161. package/dist/tools/warp_grep/providers/remote.cjs +32 -2
  162. package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
  163. package/dist/tools/warp_grep/providers/remote.d.ts +9 -1
  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 +14 -1
  167. package/dist/tools/warp_grep/vercel.cjs +435 -442
  168. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  169. package/dist/tools/warp_grep/vercel.js +8 -9
  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-DKODF3YG.js.map +0 -1
  175. package/dist/chunk-EUHNJMWL.js +0 -409
  176. package/dist/chunk-EUHNJMWL.js.map +0 -1
  177. package/dist/chunk-HZOTLGJH.js.map +0 -1
  178. package/dist/chunk-NF2QWJDY.js.map +0 -1
  179. package/dist/chunk-VCKJ22DX.js +0 -131
  180. package/dist/chunk-VCKJ22DX.js.map +0 -1
  181. package/dist/chunk-YIETFYCL.js.map +0 -1
  182. /package/dist/{chunk-J2HIK4GB.js.map → chunk-334JOOAC.js.map} +0 -0
  183. /package/dist/{chunk-QRSWXP4K.js.map → chunk-3GXWZ7TI.js.map} +0 -0
  184. /package/dist/{chunk-BDHKL3MT.js.map → chunk-4LZK67MS.js.map} +0 -0
  185. /package/dist/{chunk-UVNENJ6H.js.map → chunk-4XNHMFVU.js.map} +0 -0
  186. /package/dist/{chunk-V73GO5AJ.js.map → chunk-7HKJUVAK.js.map} +0 -0
  187. /package/dist/{chunk-VZ6VYRQB.js.map → chunk-BXQYZR7O.js.map} +0 -0
  188. /package/dist/{chunk-GJUB3ECP.js.map → chunk-CJD4ZFOX.js.map} +0 -0
  189. /package/dist/{chunk-KYKRRF7E.js.map → chunk-DYCRGTRN.js.map} +0 -0
  190. /package/dist/{chunk-EU7OLX4Z.js.map → chunk-ETKDGHOB.js.map} +0 -0
  191. /package/dist/{chunk-I7SFRYTX.js.map → chunk-HWED34T3.js.map} +0 -0
  192. /package/dist/{chunk-FIVYDIHX.js.map → chunk-HYRHI2UL.js.map} +0 -0
  193. /package/dist/{chunk-E4YKEKGW.js.map → chunk-KV2CC4N7.js.map} +0 -0
  194. /package/dist/{chunk-BIQ7234U.js.map → chunk-LSPEWVCD.js.map} +0 -0
  195. /package/dist/{chunk-OV57JBMB.js.map → chunk-N7XLC7BK.js.map} +0 -0
  196. /package/dist/{chunk-FBOJJ3UY.js.map → chunk-O356YR2N.js.map} +0 -0
  197. /package/dist/{chunk-JSWNBCGS.js.map → chunk-PIHW2GSK.js.map} +0 -0
  198. /package/dist/{chunk-UYPWKQKV.js.map → chunk-RGNP6FNH.js.map} +0 -0
  199. /package/dist/{chunk-NKUSUSVI.js.map → chunk-T7VCGKXB.js.map} +0 -0
  200. /package/dist/{chunk-Q36MNOFA.js.map → chunk-UZ2QUWJD.js.map} +0 -0
  201. /package/dist/{chunk-FYO46OT6.js.map → chunk-VTTU7MJB.js.map} +0 -0
  202. /package/dist/{chunk-4PBUB77N.js.map → chunk-XADFYB6B.js.map} +0 -0
  203. /package/dist/{chunk-T564HFSH.js.map → chunk-XS4PO4FC.js.map} +0 -0
  204. /package/dist/{chunk-E45FW5EK.js.map → chunk-YH3XIVF2.js.map} +0 -0
  205. /package/dist/{chunk-MMBQKN4G.js.map → chunk-ZZW4B4GG.js.map} +0 -0
@@ -20,136 +20,67 @@ 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
- LLMResponseParser: () => LLMResponseParser
23
+ extractPathFromCommand: () => extractPathFromCommand,
24
+ parseFinishFiles: () => parseFinishFiles,
25
+ parseReadLines: () => parseReadLines
24
26
  });
25
27
  module.exports = __toCommonJS(parser_exports);
26
- var VALID_COMMANDS = ["list_directory", "ripgrep", "read", "finish"];
27
- function isValidCommand(name) {
28
- return VALID_COMMANDS.includes(name);
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 {};
29
43
  }
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();
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;
43
53
  }
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 } });
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;
59
+ }
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]]);
137
69
  }
138
70
  }
71
+ files.push({ path: filePath, lines: ranges.length > 0 ? ranges : "*" });
139
72
  }
140
- return tools;
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] || ".";
141
79
  }
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
- };
151
80
  // Annotate the CommonJS export names for ESM import in node:
152
81
  0 && (module.exports = {
153
- LLMResponseParser
82
+ extractPathFromCommand,
83
+ parseFinishFiles,
84
+ parseReadLines
154
85
  });
155
86
  //# sourceMappingURL=parser.cjs.map
@@ -1 +1 @@
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,gBAAgB;AACtB,MAAI;AAEJ,UAAQ,QAAQ,cAAc,KAAK,IAAI,OAAO,MAAM;AAClD,UAAM,WAAW,MAAM,CAAC,EAAE,YAAY;AACtC,UAAM,OAAO,MAAM,CAAC;AA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AAA,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
+ {"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,OAAO,WAAW,EAAG,QAAO,EAAE,OAAO,OAAO,CAAC,EAAE,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AS,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,8 +1,15 @@
1
- import { ToolCall } from './types.js';
1
+ import { FinishFileSpec } from './types.js';
2
2
  import '../../utils/resilience.js';
3
3
 
4
- declare class LLMResponseParser {
5
- parse(text: string): ToolCall[];
6
- }
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;
7
14
 
8
- export { LLMResponseParser };
15
+ export { extractPathFromCommand, parseFinishFiles, parseReadLines };
@@ -1,8 +1,12 @@
1
1
  import {
2
- LLMResponseParser
3
- } from "../../../chunk-VCKJ22DX.js";
2
+ extractPathFromCommand,
3
+ parseFinishFiles,
4
+ parseReadLines
5
+ } from "../../../chunk-CMSHXALI.js";
4
6
  import "../../../chunk-PZ5AY32C.js";
5
7
  export {
6
- LLMResponseParser
8
+ extractPathFromCommand,
9
+ parseFinishFiles,
10
+ parseReadLines
7
11
  };
8
12
  //# sourceMappingURL=parser.js.map