@morphllm/morphsdk 0.2.202 → 0.2.204

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 (246) hide show
  1. package/README.md +101 -0
  2. package/dist/chunk-2GMG5XKU.js +100 -0
  3. package/dist/chunk-2PPYWRMZ.js +3 -4
  4. package/dist/chunk-3HAHJYZQ.cjs +74 -0
  5. package/dist/{chunk-2XU3XXUE.js → chunk-3JROKKS4.js} +3 -25
  6. package/dist/{chunk-26K5EJD3.js → chunk-43JBUEIX.js} +4 -18
  7. package/dist/chunk-44OIEPIO.js +4 -23
  8. package/dist/chunk-4EQQGUZ7.cjs +104 -0
  9. package/dist/chunk-4OUGA3KS.js +1 -5
  10. package/dist/{chunk-VQDDL3UH.js → chunk-4TZBUFVP.js} +2 -8
  11. package/dist/{chunk-YAM6P5OQ.js → chunk-564XJOQP.js} +2 -6
  12. package/dist/chunk-5H3FKFOI.cjs +77 -0
  13. package/dist/chunk-5TTZQF4X.cjs +110 -0
  14. package/dist/chunk-6HAYJA6M.cjs +317 -0
  15. package/dist/chunk-6TZCVTW5.js +3 -4
  16. package/dist/chunk-6WP7EA4F.js +2 -4
  17. package/dist/chunk-74A4HLIO.cjs +42 -0
  18. package/dist/chunk-75ZPJI57.cjs +9 -0
  19. package/dist/chunk-7PJYY46L.cjs +2 -0
  20. package/dist/chunk-AWFZKS27.cjs +11 -0
  21. package/dist/chunk-BJBWWIZV.cjs +2 -0
  22. package/dist/chunk-DLYDIYDK.cjs +305 -0
  23. package/dist/{chunk-65TUD7JV.js → chunk-DYCMPDPV.js} +13 -29
  24. package/dist/{chunk-3CPI6ZIC.js → chunk-DZP7BR66.js} +22 -43
  25. package/dist/chunk-E63OPKP7.js +96 -0
  26. package/dist/chunk-E6V75LI6.cjs +334 -0
  27. package/dist/{chunk-XPHNS7NW.js → chunk-EJ6ID24K.js} +3 -12
  28. package/dist/chunk-EJTL2BOZ.cjs +42 -0
  29. package/dist/chunk-ETBRAKVV.js +1 -5
  30. package/dist/chunk-F633IVQA.cjs +91 -0
  31. package/dist/chunk-FBOZIVVQ.js +1 -0
  32. package/dist/{chunk-UKXCGQPS.js → chunk-FGA6EYC2.js} +35 -37
  33. package/dist/{chunk-CAWQEHKP.js → chunk-G4RODMXA.js} +4 -19
  34. package/dist/chunk-GUNGJC6X.cjs +256 -0
  35. package/dist/chunk-GYE3FY6Z.js +8 -0
  36. package/dist/chunk-HDP4QAZL.js +1 -4
  37. package/dist/chunk-HNMEBYIS.cjs +86 -0
  38. package/dist/chunk-HP3PCOTW.cjs +81 -0
  39. package/dist/{chunk-ICCGLO6V.js → chunk-IGXNLXPN.js} +12 -17
  40. package/dist/chunk-IPJA3ZS6.cjs +10 -0
  41. package/dist/chunk-JHC2R3HU.cjs +317 -0
  42. package/dist/{chunk-IBRBSDLT.js → chunk-JVMIFGZY.js} +5 -8
  43. package/dist/chunk-KF6S3EPJ.cjs +100 -0
  44. package/dist/chunk-KVGZ2TSG.cjs +274 -0
  45. package/dist/{chunk-6OYJC4TZ.js → chunk-L5SCKZVK.js} +13 -22
  46. package/dist/chunk-LDM7RNNN.js +1 -0
  47. package/dist/{chunk-UAZKHSEU.js → chunk-LQST3NW2.js} +5 -15
  48. package/dist/chunk-M34E2AMK.js +1 -5
  49. package/dist/chunk-MF56KEI4.js +1 -4
  50. package/dist/chunk-MLKGABMK.js +1 -3
  51. package/dist/chunk-MLPZKUCO.js +4 -5
  52. package/dist/chunk-MMX5PUGC.cjs +242 -0
  53. package/dist/chunk-MWXJ6DZ2.cjs +21 -0
  54. package/dist/chunk-NJWOWXUR.cjs +137 -0
  55. package/dist/chunk-NNKBKENK.cjs +15 -0
  56. package/dist/chunk-NRG6QX3L.js +1 -3
  57. package/dist/chunk-OCKEEEYE.cjs +433 -0
  58. package/dist/chunk-OENJO7YW.js +306 -0
  59. package/dist/chunk-OKLAYEBC.cjs +2 -0
  60. package/dist/chunk-OPDWMD4Q.js +1 -3
  61. package/dist/{chunk-D6YJ5X3C.js → chunk-OX5GN2KB.js} +26 -14
  62. package/dist/{chunk-JEVLCA5C.js → chunk-OYBOP47A.js} +18 -19
  63. package/dist/chunk-OZHCHPIE.js +1 -0
  64. package/dist/chunk-PA3UTI4A.js +1 -4
  65. package/dist/chunk-QEEAIXL5.cjs +74 -0
  66. package/dist/chunk-QT5LGZG3.cjs +10 -0
  67. package/dist/chunk-R3TUE7O2.cjs +107 -0
  68. package/dist/chunk-RYVW7RUM.js +2 -6
  69. package/dist/{chunk-LVKKICOB.js → chunk-SOQYE5A4.js} +36 -69
  70. package/dist/chunk-ST2OXLT5.cjs +91 -0
  71. package/dist/{chunk-SIFDK4AA.js → chunk-TH4MG73B.js} +3 -24
  72. package/dist/{chunk-OSL4CNSO.js → chunk-TLMAMVAW.js} +7 -23
  73. package/dist/chunk-TPZHMD7J.cjs +72 -0
  74. package/dist/{chunk-PDSIWL7I.js → chunk-U4PYAGNR.js} +6 -19
  75. package/dist/chunk-UAPK3AIJ.js +1 -10
  76. package/dist/chunk-UF5IKELS.cjs +26 -0
  77. package/dist/chunk-UHFVWYSP.cjs +408 -0
  78. package/dist/chunk-UKBSXYKE.cjs +280 -0
  79. package/dist/chunk-UNX7V6P6.cjs +60 -0
  80. package/dist/chunk-UZMMJ47A.cjs +107 -0
  81. package/dist/chunk-VHD7CW5O.cjs +43 -0
  82. package/dist/chunk-VL4QNALG.cjs +50 -0
  83. package/dist/chunk-VYE7O4FM.cjs +51 -0
  84. package/dist/chunk-WIYVT4UO.cjs +173 -0
  85. package/dist/chunk-WJHHO24M.cjs +91 -0
  86. package/dist/chunk-WR7LSUIR.cjs +213 -0
  87. package/dist/chunk-XE6D4J63.cjs +72 -0
  88. package/dist/chunk-YAUXTFIN.cjs +21 -0
  89. package/dist/{chunk-NFPRKZQ5.js → chunk-YJUCGZNN.js} +5 -22
  90. package/dist/chunk-ZSHVXDA2.js +4 -10
  91. package/dist/chunk-ZX6T3LNG.js +302 -0
  92. package/dist/{client-BWhi-vSj.d.ts → client-DSXbcxII.d.ts} +10 -1
  93. package/dist/client.cjs +44 -4360
  94. package/dist/client.d.ts +4 -2
  95. package/dist/client.js +36 -37
  96. package/dist/core/client.cjs +14 -476
  97. package/dist/core/client.d.ts +8 -0
  98. package/dist/core/client.js +10 -11
  99. package/dist/core/error.cjs +8 -251
  100. package/dist/core/error.js +4 -9
  101. package/dist/core/index.cjs +27 -491
  102. package/dist/core/index.d.ts +2 -0
  103. package/dist/core/index.js +12 -19
  104. package/dist/core/resource.cjs +9 -33
  105. package/dist/core/resource.d.ts +2 -0
  106. package/dist/core/resource.js +2 -7
  107. package/dist/edge.cjs +74 -1111
  108. package/dist/edge.d.ts +3 -0
  109. package/dist/edge.js +14 -42
  110. package/dist/guard-CvW03v4u.d.ts +59 -0
  111. package/dist/index.cjs +140 -4431
  112. package/dist/index.d.ts +6 -2
  113. package/dist/index.js +44 -87
  114. package/dist/modelrouter/core.cjs +35 -651
  115. package/dist/modelrouter/core.d.ts +2 -0
  116. package/dist/modelrouter/core.js +12 -21
  117. package/dist/modelrouter/index.cjs +35 -651
  118. package/dist/modelrouter/index.d.ts +2 -0
  119. package/dist/modelrouter/index.js +12 -21
  120. package/dist/modelrouter/types.cjs +1 -17
  121. package/dist/modelrouter/types.d.ts +5 -0
  122. package/dist/modelrouter/types.js +1 -0
  123. package/dist/subagents/anthropic.cjs +31 -2784
  124. package/dist/subagents/anthropic.d.ts +3 -1
  125. package/dist/subagents/anthropic.js +23 -24
  126. package/dist/subagents/index.cjs +14 -95
  127. package/dist/subagents/index.d.ts +3 -1
  128. package/dist/subagents/index.js +2 -11
  129. package/dist/subagents/prompts.cjs +14 -93
  130. package/dist/subagents/prompts.d.ts +3 -1
  131. package/dist/subagents/prompts.js +2 -11
  132. package/dist/subagents/types.cjs +1 -17
  133. package/dist/subagents/types.d.ts +3 -1
  134. package/dist/subagents/types.js +1 -0
  135. package/dist/subagents/vercel.cjs +31 -2761
  136. package/dist/subagents/vercel.d.ts +3 -1
  137. package/dist/subagents/vercel.js +23 -24
  138. package/dist/tools/compact/core.cjs +20 -552
  139. package/dist/tools/compact/core.d.ts +2 -0
  140. package/dist/tools/compact/core.js +12 -13
  141. package/dist/tools/compact/index.cjs +24 -598
  142. package/dist/tools/compact/index.d.ts +3 -1
  143. package/dist/tools/compact/index.js +13 -17
  144. package/dist/tools/compact/types.cjs +1 -17
  145. package/dist/tools/compact/types.d.ts +4 -4
  146. package/dist/tools/compact/types.js +1 -0
  147. package/dist/tools/fastapply/anthropic.cjs +39 -899
  148. package/dist/tools/fastapply/anthropic.d.ts +2 -0
  149. package/dist/tools/fastapply/anthropic.js +15 -24
  150. package/dist/tools/fastapply/apply.cjs +32 -672
  151. package/dist/tools/fastapply/apply.d.ts +2 -0
  152. package/dist/tools/fastapply/apply.js +8 -19
  153. package/dist/tools/fastapply/core.cjs +49 -1069
  154. package/dist/tools/fastapply/core.d.ts +3 -0
  155. package/dist/tools/fastapply/core.js +13 -29
  156. package/dist/tools/fastapply/index.cjs +56 -1052
  157. package/dist/tools/fastapply/index.d.ts +2 -0
  158. package/dist/tools/fastapply/index.js +18 -44
  159. package/dist/tools/fastapply/openai.cjs +45 -910
  160. package/dist/tools/fastapply/openai.d.ts +2 -0
  161. package/dist/tools/fastapply/openai.js +15 -26
  162. package/dist/tools/fastapply/prompts.cjs +10 -62
  163. package/dist/tools/fastapply/prompts.js +2 -9
  164. package/dist/tools/fastapply/types.cjs +1 -17
  165. package/dist/tools/fastapply/types.d.ts +9 -4
  166. package/dist/tools/fastapply/types.js +1 -0
  167. package/dist/tools/fastapply/vercel.cjs +37 -905
  168. package/dist/tools/fastapply/vercel.d.ts +2 -0
  169. package/dist/tools/fastapply/vercel.js +15 -22
  170. package/dist/tools/index.cjs +56 -1052
  171. package/dist/tools/index.d.ts +2 -0
  172. package/dist/tools/index.js +18 -44
  173. package/dist/tools/pii/index.cjs +47 -0
  174. package/dist/tools/pii/index.d.ts +4 -0
  175. package/dist/tools/pii/index.js +6 -0
  176. package/dist/tools/pii/model.cjs +45 -0
  177. package/dist/tools/pii/model.d.ts +83 -0
  178. package/dist/tools/pii/model.js +4 -0
  179. package/dist/tools/pii/patterns.cjs +15 -0
  180. package/dist/tools/pii/patterns.d.ts +31 -0
  181. package/dist/tools/pii/patterns.js +2 -0
  182. package/dist/tools/pii/regex.cjs +32 -0
  183. package/dist/tools/pii/regex.d.ts +48 -0
  184. package/dist/tools/pii/regex.js +3 -0
  185. package/dist/tools/pii/types.cjs +2 -0
  186. package/dist/tools/pii/types.d.ts +108 -0
  187. package/dist/tools/pii/types.js +1 -0
  188. package/dist/tools/utils/resilience.cjs +15 -312
  189. package/dist/tools/utils/resilience.js +3 -12
  190. package/dist/tools/warp_grep/agent/config.cjs +16 -127
  191. package/dist/tools/warp_grep/agent/config.js +2 -11
  192. package/dist/tools/warp_grep/agent/formatter.cjs +12 -48
  193. package/dist/tools/warp_grep/agent/formatter.js +2 -9
  194. package/dist/tools/warp_grep/agent/parser.cjs +16 -83
  195. package/dist/tools/warp_grep/agent/parser.d.ts +2 -0
  196. package/dist/tools/warp_grep/agent/parser.js +2 -11
  197. package/dist/tools/warp_grep/agent/runner.cjs +19 -1081
  198. package/dist/tools/warp_grep/agent/runner.d.ts +2 -0
  199. package/dist/tools/warp_grep/agent/runner.js +11 -14
  200. package/dist/tools/warp_grep/agent/types.cjs +1 -17
  201. package/dist/tools/warp_grep/agent/types.d.ts +4 -0
  202. package/dist/tools/warp_grep/agent/types.js +1 -0
  203. package/dist/tools/warp_grep/anthropic.cjs +51 -2561
  204. package/dist/tools/warp_grep/anthropic.d.ts +3 -1
  205. package/dist/tools/warp_grep/anthropic.js +23 -35
  206. package/dist/tools/warp_grep/client.cjs +53 -2471
  207. package/dist/tools/warp_grep/client.d.ts +3 -1
  208. package/dist/tools/warp_grep/client.js +21 -34
  209. package/dist/tools/warp_grep/gemini.cjs +52 -2490
  210. package/dist/tools/warp_grep/gemini.d.ts +3 -1
  211. package/dist/tools/warp_grep/gemini.js +25 -41
  212. package/dist/tools/warp_grep/harness.cjs +81 -936
  213. package/dist/tools/warp_grep/harness.d.ts +2 -0
  214. package/dist/tools/warp_grep/harness.js +12 -51
  215. package/dist/tools/warp_grep/index.cjs +128 -2575
  216. package/dist/tools/warp_grep/index.d.ts +3 -1
  217. package/dist/tools/warp_grep/index.js +28 -87
  218. package/dist/tools/warp_grep/openai.cjs +57 -2575
  219. package/dist/tools/warp_grep/openai.d.ts +3 -1
  220. package/dist/tools/warp_grep/openai.js +23 -37
  221. package/dist/tools/warp_grep/providers/code_storage_http.cjs +12 -65
  222. package/dist/tools/warp_grep/providers/code_storage_http.d.ts +3 -1
  223. package/dist/tools/warp_grep/providers/code_storage_http.js +2 -9
  224. package/dist/tools/warp_grep/providers/local.cjs +10 -589
  225. package/dist/tools/warp_grep/providers/local.js +6 -11
  226. package/dist/tools/warp_grep/providers/remote.cjs +8 -331
  227. package/dist/tools/warp_grep/providers/remote.d.ts +3 -1
  228. package/dist/tools/warp_grep/providers/remote.js +3 -8
  229. package/dist/tools/warp_grep/providers/types.cjs +1 -17
  230. package/dist/tools/warp_grep/providers/types.js +1 -0
  231. package/dist/tools/warp_grep/utils/files.cjs +9 -42
  232. package/dist/tools/warp_grep/utils/files.js +2 -7
  233. package/dist/tools/warp_grep/utils/github.cjs +9 -43
  234. package/dist/tools/warp_grep/utils/github.js +2 -7
  235. package/dist/tools/warp_grep/utils/paths.cjs +28 -104
  236. package/dist/tools/warp_grep/utils/paths.js +2 -17
  237. package/dist/tools/warp_grep/utils/ripgrep.cjs +9 -103
  238. package/dist/tools/warp_grep/utils/ripgrep.js +2 -7
  239. package/dist/tools/warp_grep/vercel.cjs +57 -2557
  240. package/dist/tools/warp_grep/vercel.d.ts +3 -1
  241. package/dist/tools/warp_grep/vercel.js +23 -37
  242. package/dist/{types-DxZLPogx.d.ts → types-BKhXjDCB.d.ts} +6 -1
  243. package/dist/version.cjs +7 -225
  244. package/dist/version.js +2 -7
  245. package/package.json +11 -2
  246. package/dist/chunk-E6TL6MIH.js +0 -203
@@ -0,0 +1,274 @@
1
+ 'use strict';
2
+
3
+ var chunk4EQQGUZ7_cjs = require('./chunk-4EQQGUZ7.cjs');
4
+ var path = require('path');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var path__default = /*#__PURE__*/_interopDefault(path);
9
+
10
+ // tools/warp_grep/agent/tools/grep.ts
11
+ async function toolGrep(provider, args) {
12
+ const res = await provider.grep(args);
13
+ if (res.error) {
14
+ return { output: res.error };
15
+ }
16
+ if (!res.lines.length) {
17
+ return { output: "no matches" };
18
+ }
19
+ return { output: res.lines.join("\n") };
20
+ }
21
+
22
+ // tools/warp_grep/agent/tools/read.ts
23
+ function isValidRange(start, end) {
24
+ return typeof start === "number" && typeof end === "number" && Number.isFinite(start) && Number.isFinite(end) && start > 0 && end >= start;
25
+ }
26
+ async function toolRead(provider, args) {
27
+ if (args.lines && Array.isArray(args.lines) && args.lines.length > 0) {
28
+ const validRanges = [];
29
+ for (const range of args.lines) {
30
+ if (Array.isArray(range) && range.length >= 2 && isValidRange(range[0], range[1])) {
31
+ validRanges.push([range[0], range[1]]);
32
+ }
33
+ }
34
+ if (validRanges.length === 0) {
35
+ const res2 = await provider.read({ path: args.path });
36
+ if (res2.error) return res2.error;
37
+ if (!res2.lines.length) return "(empty file)";
38
+ return res2.lines.join("\n");
39
+ }
40
+ const chunks = [];
41
+ for (const [start, end] of validRanges) {
42
+ const res2 = await provider.read({ path: args.path, start, end });
43
+ if (res2.error) return res2.error;
44
+ chunks.push(res2.lines.join("\n"));
45
+ }
46
+ if (chunks.every((c) => c === "")) return "(empty file)";
47
+ return chunks.join("\n...\n");
48
+ }
49
+ const res = await provider.read({ path: args.path, start: args.start, end: args.end });
50
+ if (res.error) {
51
+ return res.error;
52
+ }
53
+ if (!res.lines.length) return "(empty file)";
54
+ return res.lines.join("\n");
55
+ }
56
+ async function toolListDirectory(provider, args, repoRoot) {
57
+ const maxResults = args.maxResults ?? chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_LIST_RESULTS;
58
+ const maxDepth = args.maxDepth ?? chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_LIST_DEPTH;
59
+ const entries = await provider.listDirectory({
60
+ path: args.path,
61
+ pattern: args.pattern ?? null,
62
+ maxResults,
63
+ maxDepth
64
+ });
65
+ if (!entries.length) return "empty";
66
+ if (repoRoot) {
67
+ const absRoot = repoRoot;
68
+ const lines = entries.map((e) => path__default.default.join(absRoot, e.path));
69
+ return lines.join("\n");
70
+ }
71
+ return entries.map((e) => e.path).join("\n");
72
+ }
73
+
74
+ // tools/warp_grep/agent/tools/glob.ts
75
+ async function toolGlob(provider, args) {
76
+ const res = await provider.glob(args);
77
+ if (res.error) {
78
+ return res.error;
79
+ }
80
+ if (!res.files.length) {
81
+ return "no matches";
82
+ }
83
+ const header = `Found ${res.totalFound} file(s) matching "${args.pattern}" within ${res.searchDir}, sorted by modification time (newest first):`;
84
+ const body = res.files.join("\n");
85
+ const truncated = res.totalFound > res.files.length ? `
86
+ [${res.totalFound - res.files.length} files truncated]` : "";
87
+ return `${header}
88
+ ---
89
+ ${body}
90
+ ---${truncated}`;
91
+ }
92
+
93
+ // tools/warp_grep/agent/tools/finish.ts
94
+ function isValidRange2(range) {
95
+ return Array.isArray(range) && range.length >= 2 && typeof range[0] === "number" && typeof range[1] === "number" && Number.isFinite(range[0]) && Number.isFinite(range[1]) && range[0] > 0 && range[1] >= range[0];
96
+ }
97
+ function extractValidRanges(lines) {
98
+ if (!Array.isArray(lines)) return null;
99
+ const valid = [];
100
+ for (const range of lines) {
101
+ if (isValidRange2(range)) {
102
+ valid.push([range[0], range[1]]);
103
+ }
104
+ }
105
+ return valid.length > 0 ? valid : null;
106
+ }
107
+ function normalizeFinishFiles(files) {
108
+ return files.map((f) => {
109
+ if (f.lines === "*") return { path: f.path, lines: "*" };
110
+ const validRanges = extractValidRanges(f.lines);
111
+ if (!validRanges) return { path: f.path, lines: "*" };
112
+ return { path: f.path, lines: mergeRanges(validRanges) };
113
+ });
114
+ }
115
+ async function readFinishFiles(repoRoot, files, reader) {
116
+ const out = [];
117
+ for (const f of files) {
118
+ const validRanges = f.lines === "*" ? null : extractValidRanges(f.lines);
119
+ if (f.lines === "*" || !validRanges) {
120
+ const lines = await reader(f.path);
121
+ out.push({ path: f.path, ranges: "*", content: lines.join("\n") });
122
+ } else {
123
+ const ranges = mergeRanges(validRanges);
124
+ const chunks = [];
125
+ for (let i = 0; i < ranges.length; i++) {
126
+ const [s, e] = ranges[i];
127
+ if (i === 0 && s > 1) {
128
+ chunks.push(`// ... existing code, block starting at line ${s} ...`);
129
+ } else if (i > 0) {
130
+ chunks.push(`// ... existing code, block starting at line ${s} ...`);
131
+ }
132
+ const lines = await reader(f.path, s, e);
133
+ chunks.push(lines.join("\n"));
134
+ }
135
+ out.push({ path: f.path, ranges, content: chunks.join("\n") });
136
+ }
137
+ }
138
+ return out;
139
+ }
140
+ function mergeRanges(ranges) {
141
+ if (!ranges.length) return [];
142
+ const sorted = [...ranges].sort((a, b) => a[0] - b[0]);
143
+ const merged = [];
144
+ let [cs, ce] = sorted[0];
145
+ for (let i = 1; i < sorted.length; i++) {
146
+ const [s, e] = sorted[i];
147
+ if (s <= ce + 1) {
148
+ ce = Math.max(ce, e);
149
+ } else {
150
+ merged.push([cs, ce]);
151
+ cs = s;
152
+ ce = e;
153
+ }
154
+ }
155
+ merged.push([cs, ce]);
156
+ return merged;
157
+ }
158
+ var TRUNCATED_MARKER = "[truncated for context limit]";
159
+ function getMessageSize(m) {
160
+ if (m.role === "tool") return m.content.length;
161
+ if (m.role === "assistant") {
162
+ let size = typeof m.content === "string" ? m.content.length : 0;
163
+ if (m.tool_calls) {
164
+ size += m.tool_calls.reduce((s, tc) => s + tc.function.name.length + tc.function.arguments.length, 0);
165
+ }
166
+ return size;
167
+ }
168
+ return m.content.length;
169
+ }
170
+ function formatTurnMessage(turnsUsed, maxTurns) {
171
+ const turnsRemaining = maxTurns - turnsUsed;
172
+ if (turnsRemaining === 1) {
173
+ return `
174
+ You have used ${turnsUsed} turns, you only have 1 turn remaining. You have run out of turns to explore the code base and MUST call the finish tool now`;
175
+ }
176
+ return `
177
+ You have used ${turnsUsed} turn${turnsUsed === 1 ? "" : "s"} and have ${turnsRemaining} remaining`;
178
+ }
179
+ function calculateContextBudget(messages) {
180
+ const totalChars = messages.reduce((sum, m) => sum + getMessageSize(m), 0);
181
+ const maxChars = chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_CONTEXT_CHARS;
182
+ const percent = Math.floor(totalChars / maxChars * 100);
183
+ const usedK = Math.floor(totalChars / 1e3);
184
+ const maxK = Math.floor(maxChars / 1e3);
185
+ return `<context_budget>${percent}% (${usedK}K/${maxK}K chars)</context_budget>`;
186
+ }
187
+ async function buildInitialState(repoRoot, searchTerm, provider, options) {
188
+ const budget = calculateContextBudget([]);
189
+ const turnTag = `You have used 0 turns and have ${chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_TURNS} remaining`;
190
+ const treeDepth = options?.search_type === "node_modules" ? 1 : 2;
191
+ const absRoot = repoRoot;
192
+ try {
193
+ const entries = await provider.listDirectory({
194
+ path: ".",
195
+ maxResults: chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_OUTPUT_LINES,
196
+ maxDepth: treeDepth
197
+ });
198
+ const lines = [absRoot];
199
+ for (const e of entries) {
200
+ lines.push(path__default.default.join(absRoot, e.path));
201
+ }
202
+ return `<repo_structure>
203
+ ${lines.join("\n")}
204
+ </repo_structure>
205
+
206
+ <search_string>
207
+ ${searchTerm}
208
+ </search_string>
209
+ ${budget}
210
+ ${turnTag}`;
211
+ } catch {
212
+ return `<repo_structure>
213
+ ${absRoot}
214
+ </repo_structure>
215
+
216
+ <search_string>
217
+ ${searchTerm}
218
+ </search_string>
219
+ ${budget}
220
+ ${turnTag}`;
221
+ }
222
+ }
223
+ function formatListDirectoryTree(entries) {
224
+ if (!entries.length) return "empty";
225
+ return entries.map((e) => {
226
+ const indent = " ".repeat(e.depth);
227
+ const name = e.type === "dir" ? `${e.name}/` : e.name;
228
+ return `${indent}${name}`;
229
+ }).join("\n");
230
+ }
231
+ function enforceContextLimit(messages, maxChars = chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_CONTEXT_CHARS) {
232
+ const getTotalChars = () => messages.reduce((sum, m) => sum + getMessageSize(m), 0);
233
+ if (getTotalChars() <= maxChars) {
234
+ return messages;
235
+ }
236
+ const truncatableIndices = [];
237
+ let firstUserSkipped = false;
238
+ for (let i = 0; i < messages.length; i++) {
239
+ const m = messages[i];
240
+ if (m.role === "tool") {
241
+ truncatableIndices.push(i);
242
+ } else if (m.role === "user") {
243
+ if (!firstUserSkipped) {
244
+ firstUserSkipped = true;
245
+ continue;
246
+ }
247
+ truncatableIndices.push(i);
248
+ }
249
+ }
250
+ for (const idx of truncatableIndices) {
251
+ if (getTotalChars() <= maxChars) {
252
+ break;
253
+ }
254
+ const m = messages[idx];
255
+ if (m.role === "tool" && m.content !== TRUNCATED_MARKER) {
256
+ messages[idx] = { role: "tool", tool_call_id: m.tool_call_id, content: TRUNCATED_MARKER };
257
+ } else if (m.role === "user" && m.content !== TRUNCATED_MARKER) {
258
+ messages[idx] = { role: "user", content: TRUNCATED_MARKER };
259
+ }
260
+ }
261
+ return messages;
262
+ }
263
+
264
+ exports.buildInitialState = buildInitialState;
265
+ exports.calculateContextBudget = calculateContextBudget;
266
+ exports.enforceContextLimit = enforceContextLimit;
267
+ exports.formatListDirectoryTree = formatListDirectoryTree;
268
+ exports.formatTurnMessage = formatTurnMessage;
269
+ exports.normalizeFinishFiles = normalizeFinishFiles;
270
+ exports.readFinishFiles = readFinishFiles;
271
+ exports.toolGlob = toolGlob;
272
+ exports.toolGrep = toolGrep;
273
+ exports.toolListDirectory = toolListDirectory;
274
+ exports.toolRead = toolRead;
@@ -1,15 +1,7 @@
1
- import {
2
- MorphAPIClient
3
- } from "./chunk-ICCGLO6V.js";
4
- import {
5
- logger
6
- } from "./chunk-6WP7EA4F.js";
7
- import {
8
- MorphError
9
- } from "./chunk-VQDDL3UH.js";
10
- import {
11
- APIResource
12
- } from "./chunk-NRG6QX3L.js";
1
+ import { MorphAPIClient } from './chunk-IGXNLXPN.js';
2
+ import { logger } from './chunk-6WP7EA4F.js';
3
+ import { MorphError } from './chunk-4TZBUFVP.js';
4
+ import { APIResource } from './chunk-NRG6QX3L.js';
13
5
 
14
6
  // modelrouter/core.ts
15
7
  var DEFAULT_API_URL = "https://api.morphllm.com";
@@ -21,9 +13,14 @@ function resolveClient(clientOrConfig) {
21
13
  baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL,
22
14
  timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,
23
15
  retryConfig: clientOrConfig.retryConfig,
24
- debug: clientOrConfig.debug
16
+ debug: clientOrConfig.debug,
17
+ redactPII: clientOrConfig.redactPII
25
18
  });
26
19
  }
20
+ async function redactInput(client, input) {
21
+ const pii = client.pii?.session();
22
+ return pii && typeof input === "string" ? await pii.redact(input) : input;
23
+ }
27
24
  var BaseRouter = class extends APIResource {
28
25
  provider;
29
26
  timeout;
@@ -45,7 +42,7 @@ var BaseRouter = class extends APIResource {
45
42
  async route(provider, input) {
46
43
  try {
47
44
  return await this._client.post(`/v1/router/${provider}`, {
48
- body: { input: input.input, mode: input.mode || "balanced" },
45
+ body: { input: await redactInput(this._client, input.input), mode: input.mode || "balanced" },
49
46
  timeout: this.timeout
50
47
  });
51
48
  } catch (error) {
@@ -149,7 +146,7 @@ var RouterClassifier = class extends APIResource {
149
146
  logger.debug("RouterClassifier", "request", { classes: input.classes ?? "all" });
150
147
  try {
151
148
  const res = await this._client.post("/v1/router/classify", {
152
- body: { input: input.input, ...input.classes ? { classes: input.classes } : {} },
149
+ body: { input: await redactInput(this._client, input.input), ...input.classes ? { classes: input.classes } : {} },
153
150
  timeout: this.timeout
154
151
  });
155
152
  logger.debug("RouterClassifier", "classified", {
@@ -167,10 +164,4 @@ var RouterClassifier = class extends APIResource {
167
164
  }
168
165
  };
169
166
 
170
- export {
171
- OpenAIRouter,
172
- AnthropicRouter,
173
- GeminiRouter,
174
- RawRouter,
175
- RouterClassifier
176
- };
167
+ export { AnthropicRouter, GeminiRouter, OpenAIRouter, RawRouter, RouterClassifier };
@@ -0,0 +1 @@
1
+
@@ -1,16 +1,8 @@
1
- import {
2
- WarpGrepClient,
3
- formatResult
4
- } from "./chunk-3CPI6ZIC.js";
5
- import {
6
- CODEBASE_SEARCH_TOOL,
7
- SEND_MESSAGE_TOOL,
8
- getSystemPrompt
9
- } from "./chunk-ETBRAKVV.js";
1
+ import { WarpGrepClient, formatResult } from './chunk-DZP7BR66.js';
2
+ import { SEND_MESSAGE_TOOL, CODEBASE_SEARCH_TOOL, getSystemPrompt } from './chunk-ETBRAKVV.js';
3
+ import { tool, generateText, stepCountIs } from 'ai';
4
+ import { z } from 'zod';
10
5
 
11
- // subagents/vercel.ts
12
- import { tool, generateText, stepCountIs } from "ai";
13
- import { z } from "zod";
14
6
  var DEFAULT_MAX_TURNS = {
15
7
  quick: 3,
16
8
  medium: 6,
@@ -259,6 +251,4 @@ function deduplicateContexts(contexts) {
259
251
  return Array.from(map.values());
260
252
  }
261
253
 
262
- export {
263
- createExploreSubagent
264
- };
254
+ export { createExploreSubagent };
@@ -97,8 +97,4 @@ var BUILTIN_EXCLUDES = [
97
97
  var DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
98
98
  var DEFAULT_MODEL = "morph-warp-grep-v2.1";
99
99
 
100
- export {
101
- AGENT_CONFIG,
102
- DEFAULT_EXCLUDES,
103
- DEFAULT_MODEL
104
- };
100
+ export { AGENT_CONFIG, DEFAULT_EXCLUDES, DEFAULT_MODEL };
@@ -20,7 +20,4 @@ function formatAgentToolOutput(toolName, args, output, options = {}) {
20
20
  return sharedFormatter.format(toolName, args, output, options);
21
21
  }
22
22
 
23
- export {
24
- ToolOutputFormatter,
25
- formatAgentToolOutput
26
- };
23
+ export { ToolOutputFormatter, formatAgentToolOutput };
@@ -4,6 +4,4 @@ var __export = (target, all) => {
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
5
5
  };
6
6
 
7
- export {
8
- __export
9
- };
7
+ export { __export };
@@ -1,5 +1,6 @@
1
+ import { spawn } from 'child_process';
2
+
1
3
  // tools/warp_grep/utils/ripgrep.ts
2
- import { spawn } from "child_process";
3
4
  var resolvedRgPath = null;
4
5
  var rgPathChecked = false;
5
6
  function spawnRg(rgBinary, args, opts) {
@@ -23,7 +24,7 @@ function spawnRg(rgBinary, args, opts) {
23
24
  }
24
25
  async function preferredRgPath() {
25
26
  try {
26
- return (await import("@vscode/ripgrep")).rgPath ?? "rg";
27
+ return (await import('@vscode/ripgrep')).rgPath ?? "rg";
27
28
  } catch {
28
29
  return "rg";
29
30
  }
@@ -66,6 +67,4 @@ async function runRipgrep(args, opts) {
66
67
  };
67
68
  }
68
69
 
69
- export {
70
- runRipgrep
71
- };
70
+ export { runRipgrep };
@@ -0,0 +1,242 @@
1
+ 'use strict';
2
+
3
+ var chunkUZMMJ47A_cjs = require('./chunk-UZMMJ47A.cjs');
4
+ var chunk5H3FKFOI_cjs = require('./chunk-5H3FKFOI.cjs');
5
+ var chunkST2OXLT5_cjs = require('./chunk-ST2OXLT5.cjs');
6
+ var chunkGUNGJC6X_cjs = require('./chunk-GUNGJC6X.cjs');
7
+ var chunkHNMEBYIS_cjs = require('./chunk-HNMEBYIS.cjs');
8
+ var chunkHP3PCOTW_cjs = require('./chunk-HP3PCOTW.cjs');
9
+ var chunk3HAHJYZQ_cjs = require('./chunk-3HAHJYZQ.cjs');
10
+ var chunkNJWOWXUR_cjs = require('./chunk-NJWOWXUR.cjs');
11
+ var chunkUKBSXYKE_cjs = require('./chunk-UKBSXYKE.cjs');
12
+ var chunkJHC2R3HU_cjs = require('./chunk-JHC2R3HU.cjs');
13
+ var chunkWIYVT4UO_cjs = require('./chunk-WIYVT4UO.cjs');
14
+ var chunkF633IVQA_cjs = require('./chunk-F633IVQA.cjs');
15
+ var chunk5TTZQF4X_cjs = require('./chunk-5TTZQF4X.cjs');
16
+ var chunkVL4QNALG_cjs = require('./chunk-VL4QNALG.cjs');
17
+
18
+ // factories/openai.ts
19
+ var OpenAIToolFactory = class {
20
+ constructor(config) {
21
+ this.config = config;
22
+ }
23
+ /**
24
+ * Create an OpenAI-compatible warp grep tool
25
+ *
26
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
27
+ * @returns OpenAI ChatCompletionTool with execute and formatResult methods
28
+ */
29
+ createWarpGrepTool(toolConfig) {
30
+ return chunkST2OXLT5_cjs.createWarpGrepTool({
31
+ ...toolConfig,
32
+ morphApiKey: this.config.apiKey,
33
+ redactPII: toolConfig.redactPII ?? this.config.redactPII
34
+ });
35
+ }
36
+ /**
37
+ * Create an OpenAI-compatible edit file tool
38
+ *
39
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
40
+ * @returns OpenAI ChatCompletionTool with execute and formatResult methods
41
+ */
42
+ createEditFileTool(toolConfig = {}) {
43
+ return chunkHNMEBYIS_cjs.createEditFileTool({
44
+ ...toolConfig,
45
+ morphApiKey: this.config.apiKey,
46
+ redactPII: toolConfig.redactPII ?? this.config.redactPII
47
+ });
48
+ }
49
+ /**
50
+ * Create an OpenAI-compatible GitHub search tool
51
+ *
52
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
53
+ * @returns OpenAI ChatCompletionTool with execute and formatResult methods
54
+ */
55
+ createGitHubSearchTool(toolConfig) {
56
+ return chunkST2OXLT5_cjs.createGitHubSearchTool({
57
+ ...toolConfig,
58
+ morphApiKey: this.config.apiKey
59
+ });
60
+ }
61
+ };
62
+
63
+ // factories/anthropic.ts
64
+ var AnthropicToolFactory = class {
65
+ constructor(config) {
66
+ this.config = config;
67
+ }
68
+ /**
69
+ * Create an Anthropic-compatible warp grep tool
70
+ *
71
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
72
+ * @returns Anthropic Tool with execute and formatResult methods
73
+ */
74
+ createWarpGrepTool(toolConfig) {
75
+ return chunk5H3FKFOI_cjs.createWarpGrepTool({
76
+ ...toolConfig,
77
+ morphApiKey: this.config.apiKey,
78
+ redactPII: toolConfig.redactPII ?? this.config.redactPII
79
+ });
80
+ }
81
+ /**
82
+ * Create an Anthropic-compatible edit file tool
83
+ *
84
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
85
+ * @returns Anthropic Tool with execute and formatResult methods
86
+ */
87
+ createEditFileTool(toolConfig = {}) {
88
+ return chunk3HAHJYZQ_cjs.createEditFileTool({
89
+ ...toolConfig,
90
+ morphApiKey: this.config.apiKey,
91
+ redactPII: toolConfig.redactPII ?? this.config.redactPII
92
+ });
93
+ }
94
+ /**
95
+ * Create an Anthropic-compatible GitHub search tool
96
+ *
97
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
98
+ * @returns Anthropic Tool with execute and formatResult methods
99
+ */
100
+ createGitHubSearchTool(toolConfig) {
101
+ return chunk5H3FKFOI_cjs.createGitHubSearchTool({
102
+ ...toolConfig,
103
+ morphApiKey: this.config.apiKey
104
+ });
105
+ }
106
+ /**
107
+ * Create an Explore subagent that searches the codebase and returns summaries
108
+ *
109
+ * @param config - Subagent configuration including client and model (morphApiKey inherited from MorphClient)
110
+ * @returns Explore subagent with .tool, .run(), and .stream() methods
111
+ */
112
+ createExploreSubagent(config) {
113
+ return chunkUKBSXYKE_cjs.createExploreSubagent({
114
+ ...config,
115
+ morphApiKey: this.config.apiKey
116
+ });
117
+ }
118
+ };
119
+
120
+ // factories/vercel.ts
121
+ var VercelToolFactory = class {
122
+ constructor(config) {
123
+ this.config = config;
124
+ }
125
+ /**
126
+ * Create a Vercel AI SDK-compatible warp grep tool
127
+ *
128
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
129
+ * @returns Vercel AI SDK tool
130
+ */
131
+ createWarpGrepTool(toolConfig) {
132
+ return chunkUZMMJ47A_cjs.createWarpGrepTool({
133
+ ...toolConfig,
134
+ morphApiKey: this.config.apiKey,
135
+ redactPII: toolConfig.redactPII ?? this.config.redactPII
136
+ });
137
+ }
138
+ /**
139
+ * Create a Vercel AI SDK-compatible edit file tool
140
+ *
141
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
142
+ * @returns Vercel AI SDK tool
143
+ */
144
+ createEditFileTool(toolConfig = {}) {
145
+ return chunkHP3PCOTW_cjs.createEditFileTool({
146
+ ...toolConfig,
147
+ morphApiKey: this.config.apiKey,
148
+ redactPII: toolConfig.redactPII ?? this.config.redactPII
149
+ });
150
+ }
151
+ /**
152
+ * Create a Vercel AI SDK-compatible GitHub search tool
153
+ *
154
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
155
+ * @returns Vercel AI SDK tool
156
+ */
157
+ createGitHubSearchTool(toolConfig) {
158
+ return chunkUZMMJ47A_cjs.createGitHubSearchTool({
159
+ ...toolConfig,
160
+ morphApiKey: this.config.apiKey
161
+ });
162
+ }
163
+ /**
164
+ * Create an Explore subagent that searches the codebase and returns summaries
165
+ *
166
+ * @param config - Subagent configuration including model (morphApiKey inherited from MorphClient)
167
+ * @returns Explore subagent with .tool, .run(), and .stream() methods
168
+ */
169
+ createExploreSubagent(config) {
170
+ return chunkGUNGJC6X_cjs.createExploreSubagent({
171
+ ...config,
172
+ morphApiKey: this.config.apiKey
173
+ });
174
+ }
175
+ };
176
+
177
+ // client.ts
178
+ var MorphClient = class extends chunk5TTZQF4X_cjs.MorphAPIClient {
179
+ /** Client configuration */
180
+ config;
181
+ /** FastApply tool for editing files with AI-powered merge */
182
+ fastApply;
183
+ /** WarpGrep tool for fast code search using ripgrep */
184
+ warpGrep;
185
+ /** Model routers for intelligent model selection */
186
+ routers;
187
+ /** OpenAI-compatible tool factories */
188
+ openai;
189
+ /** Anthropic-compatible tool factories */
190
+ anthropic;
191
+ /** Vercel AI SDK tool factories */
192
+ vercel;
193
+ /** Compact context with line ranges */
194
+ compact;
195
+ /**
196
+ * Create a new Morph SDK client
197
+ *
198
+ * @param config - Client configuration (apiKey, debug, timeout, retryConfig)
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const morph = new MorphClient({
203
+ * apiKey: process.env.MORPH_API_KEY,
204
+ * debug: true,
205
+ * timeout: 60000
206
+ * });
207
+ * ```
208
+ */
209
+ constructor(config = {}) {
210
+ super({
211
+ apiKey: config.apiKey,
212
+ timeout: config.timeout,
213
+ retryConfig: config.retryConfig,
214
+ debug: config.debug,
215
+ redactPII: config.redactPII
216
+ });
217
+ if (!config.apiKey) {
218
+ throw new Error("Morph API key is required. Pass it as { apiKey } when constructing MorphClient.");
219
+ }
220
+ this.config = config;
221
+ chunkVL4QNALG_cjs.logger.debug("MorphClient", "initialized", { debug: !!config.debug, timeout: config.timeout });
222
+ this.fastApply = new chunkNJWOWXUR_cjs.FastApplyClient(this);
223
+ this.warpGrep = new chunkJHC2R3HU_cjs.WarpGrepClient(this);
224
+ this.routers = {
225
+ openai: new chunkWIYVT4UO_cjs.OpenAIRouter(this),
226
+ anthropic: new chunkWIYVT4UO_cjs.AnthropicRouter(this),
227
+ gemini: new chunkWIYVT4UO_cjs.GeminiRouter(this),
228
+ raw: new chunkWIYVT4UO_cjs.RawRouter(this),
229
+ classify: new chunkWIYVT4UO_cjs.RouterClassifier(this)
230
+ };
231
+ const compactClient = new chunkF633IVQA_cjs.CompactClient(this);
232
+ this.compact = compactClient.compact.bind(compactClient);
233
+ this.openai = new OpenAIToolFactory(config);
234
+ this.anthropic = new AnthropicToolFactory(config);
235
+ this.vercel = new VercelToolFactory(config);
236
+ }
237
+ };
238
+
239
+ exports.AnthropicToolFactory = AnthropicToolFactory;
240
+ exports.MorphClient = MorphClient;
241
+ exports.OpenAIToolFactory = OpenAIToolFactory;
242
+ exports.VercelToolFactory = VercelToolFactory;
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ // tools/warp_grep/utils/github.ts
4
+ function parseGitHubUrl(input) {
5
+ input = input.trim();
6
+ const urlPattern = /^(?:https?:\/\/)?github\.com\/([^\/]+)\/([^\/\?\#]+)/;
7
+ const match = input.match(urlPattern);
8
+ if (match) {
9
+ return { owner: match[1], repo: match[2].replace(/\.git$/, "") };
10
+ }
11
+ const shortPattern = /^([^\/]+)\/([^\/]+)$/;
12
+ const shortMatch = input.match(shortPattern);
13
+ if (shortMatch && !shortMatch[1].includes(".")) {
14
+ return { owner: shortMatch[1], repo: shortMatch[2].replace(/\.git$/, "") };
15
+ }
16
+ throw new Error(
17
+ `Invalid GitHub URL or shorthand: "${input}". Expected "owner/repo" or "https://github.com/owner/repo"`
18
+ );
19
+ }
20
+
21
+ exports.parseGitHubUrl = parseGitHubUrl;