@morphllm/morphsdk 0.2.198 → 0.2.200

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 (307) hide show
  1. package/README.md +1 -147
  2. package/dist/{chunk-ZQNTXHBQ.js → chunk-3CCWSLQW.js} +2 -2
  3. package/dist/{chunk-FESO6TDQ.js → chunk-7I2A7GGJ.js} +2 -2
  4. package/dist/{chunk-4JUIEYAH.js → chunk-AKSXZBPT.js} +3 -3
  5. package/dist/chunk-B4X5RWLR.js +271 -0
  6. package/dist/chunk-B4X5RWLR.js.map +1 -0
  7. package/dist/{chunk-QKNGVBE2.js → chunk-L6YOMTFU.js} +3 -3
  8. package/dist/{chunk-YQ2G5YLI.js → chunk-MLROWLS6.js} +4 -4
  9. package/dist/{chunk-4DNEBVGV.js → chunk-MPL6BDR6.js} +2 -2
  10. package/dist/{chunk-3XS5P5XH.js → chunk-PD3EDFQD.js} +2 -2
  11. package/dist/{chunk-CAFREMIT.js → chunk-PJNL35DC.js} +2 -2
  12. package/dist/{chunk-PEFXG5M6.js → chunk-Q65LL6UM.js} +2 -2
  13. package/dist/{chunk-YUH3MTP3.js → chunk-QTBFL4DG.js} +2 -2
  14. package/dist/{chunk-XTFRHVCW.js → chunk-SNYHVDE4.js} +4 -4
  15. package/dist/{chunk-ZGERT23F.js → chunk-TIMDDHYB.js} +4 -4
  16. package/dist/{chunk-PV6EF6NG.js → chunk-UHIANNKC.js} +4 -4
  17. package/dist/{chunk-FUYX2MNM.js → chunk-UKAAT6KT.js} +4 -10
  18. package/dist/chunk-UKAAT6KT.js.map +1 -0
  19. package/dist/{chunk-ZU5YYGBJ.js → chunk-UZ42MHTR.js} +3 -63
  20. package/dist/chunk-UZ42MHTR.js.map +1 -0
  21. package/dist/{chunk-XK3PQZW6.js → chunk-WTENYKJP.js} +2 -2
  22. package/dist/{chunk-6XFL2NER.js → chunk-XTLPA7ZP.js} +2 -2
  23. package/dist/{chunk-D2RFP6R2.js → chunk-Z57GJLCG.js} +3 -3
  24. package/dist/{chunk-SKN2L5CE.js → chunk-ZE64EWUV.js} +2 -2
  25. package/dist/client-BWhi-vSj.d.ts +341 -0
  26. package/dist/client.cjs +88 -2086
  27. package/dist/client.cjs.map +1 -1
  28. package/dist/client.d.ts +4 -10
  29. package/dist/client.js +20 -30
  30. package/dist/core/client.cjs +2 -68
  31. package/dist/core/client.cjs.map +1 -1
  32. package/dist/core/client.d.ts +0 -8
  33. package/dist/core/client.js +4 -4
  34. package/dist/core/error.cjs +2 -62
  35. package/dist/core/error.cjs.map +1 -1
  36. package/dist/core/error.js +3 -3
  37. package/dist/core/index.cjs +2 -68
  38. package/dist/core/index.cjs.map +1 -1
  39. package/dist/core/index.js +4 -4
  40. package/dist/edge.cjs +2 -68
  41. package/dist/edge.cjs.map +1 -1
  42. package/dist/edge.js +7 -7
  43. package/dist/index.cjs +89 -2101
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.d.ts +2 -8
  46. package/dist/index.js +21 -47
  47. package/dist/modelrouter/core.cjs +2 -68
  48. package/dist/modelrouter/core.cjs.map +1 -1
  49. package/dist/modelrouter/core.js +5 -5
  50. package/dist/modelrouter/index.cjs +2 -68
  51. package/dist/modelrouter/index.cjs.map +1 -1
  52. package/dist/modelrouter/index.js +5 -5
  53. package/dist/subagents/anthropic.cjs +2 -68
  54. package/dist/subagents/anthropic.cjs.map +1 -1
  55. package/dist/subagents/anthropic.d.ts +1 -1
  56. package/dist/subagents/anthropic.js +9 -9
  57. package/dist/subagents/index.d.ts +1 -1
  58. package/dist/subagents/prompts.d.ts +1 -1
  59. package/dist/subagents/types.d.ts +1 -1
  60. package/dist/subagents/vercel.cjs +2 -68
  61. package/dist/subagents/vercel.cjs.map +1 -1
  62. package/dist/subagents/vercel.d.ts +1 -1
  63. package/dist/subagents/vercel.js +9 -9
  64. package/dist/tools/compact/core.cjs +2 -68
  65. package/dist/tools/compact/core.cjs.map +1 -1
  66. package/dist/tools/compact/core.js +5 -5
  67. package/dist/tools/compact/index.cjs +2 -68
  68. package/dist/tools/compact/index.cjs.map +1 -1
  69. package/dist/tools/compact/index.js +6 -6
  70. package/dist/tools/fastapply/anthropic.cjs +2 -62
  71. package/dist/tools/fastapply/anthropic.cjs.map +1 -1
  72. package/dist/tools/fastapply/anthropic.js +7 -7
  73. package/dist/tools/fastapply/apply.cjs +2 -62
  74. package/dist/tools/fastapply/apply.cjs.map +1 -1
  75. package/dist/tools/fastapply/apply.js +2 -2
  76. package/dist/tools/fastapply/core.cjs +2 -68
  77. package/dist/tools/fastapply/core.cjs.map +1 -1
  78. package/dist/tools/fastapply/core.js +6 -6
  79. package/dist/tools/fastapply/index.cjs +2 -62
  80. package/dist/tools/fastapply/index.cjs.map +1 -1
  81. package/dist/tools/fastapply/index.js +13 -13
  82. package/dist/tools/fastapply/openai.cjs +2 -62
  83. package/dist/tools/fastapply/openai.cjs.map +1 -1
  84. package/dist/tools/fastapply/openai.js +7 -7
  85. package/dist/tools/fastapply/vercel.cjs +2 -62
  86. package/dist/tools/fastapply/vercel.cjs.map +1 -1
  87. package/dist/tools/fastapply/vercel.js +7 -7
  88. package/dist/tools/index.cjs +2 -62
  89. package/dist/tools/index.cjs.map +1 -1
  90. package/dist/tools/index.js +13 -13
  91. package/dist/tools/utils/resilience.cjs +2 -62
  92. package/dist/tools/utils/resilience.cjs.map +1 -1
  93. package/dist/tools/utils/resilience.js +2 -2
  94. package/dist/tools/warp_grep/agent/runner.cjs +2 -62
  95. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  96. package/dist/tools/warp_grep/agent/runner.js +2 -2
  97. package/dist/tools/warp_grep/anthropic.cjs +2 -68
  98. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  99. package/dist/tools/warp_grep/anthropic.d.ts +1 -1
  100. package/dist/tools/warp_grep/anthropic.js +9 -9
  101. package/dist/tools/warp_grep/client.cjs +2 -68
  102. package/dist/tools/warp_grep/client.cjs.map +1 -1
  103. package/dist/tools/warp_grep/client.d.ts +1 -1
  104. package/dist/tools/warp_grep/client.js +8 -8
  105. package/dist/tools/warp_grep/gemini.cjs +2 -68
  106. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  107. package/dist/tools/warp_grep/gemini.d.ts +1 -1
  108. package/dist/tools/warp_grep/gemini.js +8 -8
  109. package/dist/tools/warp_grep/index.cjs +2 -68
  110. package/dist/tools/warp_grep/index.cjs.map +1 -1
  111. package/dist/tools/warp_grep/index.d.ts +1 -1
  112. package/dist/tools/warp_grep/index.js +8 -8
  113. package/dist/tools/warp_grep/openai.cjs +2 -68
  114. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  115. package/dist/tools/warp_grep/openai.d.ts +1 -1
  116. package/dist/tools/warp_grep/openai.js +9 -9
  117. package/dist/tools/warp_grep/providers/code_storage_http.d.ts +1 -1
  118. package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
  119. package/dist/tools/warp_grep/vercel.cjs +2 -68
  120. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  121. package/dist/tools/warp_grep/vercel.d.ts +1 -1
  122. package/dist/tools/warp_grep/vercel.js +9 -9
  123. package/dist/{types-qwD753FR.d.ts → types-DxZLPogx.d.ts} +1 -1
  124. package/dist/version.cjs +2 -62
  125. package/dist/version.cjs.map +1 -1
  126. package/dist/version.js +1 -1
  127. package/package.json +2 -62
  128. package/dist/anthropic-B6my2oBx.d.ts +0 -56
  129. package/dist/chunk-2AMEQAO2.js +0 -46
  130. package/dist/chunk-2AMEQAO2.js.map +0 -1
  131. package/dist/chunk-2HMEZZKK.js +0 -44
  132. package/dist/chunk-2HMEZZKK.js.map +0 -1
  133. package/dist/chunk-2VERUKO2.js +0 -177
  134. package/dist/chunk-2VERUKO2.js.map +0 -1
  135. package/dist/chunk-EMURAU6J.js +0 -148
  136. package/dist/chunk-EMURAU6J.js.map +0 -1
  137. package/dist/chunk-FUYX2MNM.js.map +0 -1
  138. package/dist/chunk-GJ42MYUU.js +0 -57
  139. package/dist/chunk-GJ42MYUU.js.map +0 -1
  140. package/dist/chunk-IDMKQWQG.js +0 -214
  141. package/dist/chunk-IDMKQWQG.js.map +0 -1
  142. package/dist/chunk-KQKLQHJF.js +0 -96
  143. package/dist/chunk-KQKLQHJF.js.map +0 -1
  144. package/dist/chunk-O5264GI4.js +0 -58
  145. package/dist/chunk-O5264GI4.js.map +0 -1
  146. package/dist/chunk-PIIXU2H3.js +0 -389
  147. package/dist/chunk-PIIXU2H3.js.map +0 -1
  148. package/dist/chunk-T6TXYTKH.js +0 -83
  149. package/dist/chunk-T6TXYTKH.js.map +0 -1
  150. package/dist/chunk-TLXVGE4R.js +0 -42
  151. package/dist/chunk-TLXVGE4R.js.map +0 -1
  152. package/dist/chunk-VBZ7BG47.js +0 -97
  153. package/dist/chunk-VBZ7BG47.js.map +0 -1
  154. package/dist/chunk-WLMPQFER.js +0 -128
  155. package/dist/chunk-WLMPQFER.js.map +0 -1
  156. package/dist/chunk-XH6KJJDI.js +0 -80
  157. package/dist/chunk-XH6KJJDI.js.map +0 -1
  158. package/dist/chunk-YD6TNDR4.js +0 -622
  159. package/dist/chunk-YD6TNDR4.js.map +0 -1
  160. package/dist/chunk-YHZJYCOU.js +0 -680
  161. package/dist/chunk-YHZJYCOU.js.map +0 -1
  162. package/dist/chunk-YQMPVJ2L.js +0 -32
  163. package/dist/chunk-YQMPVJ2L.js.map +0 -1
  164. package/dist/chunk-YTYCHRQ2.js +0 -106
  165. package/dist/chunk-YTYCHRQ2.js.map +0 -1
  166. package/dist/chunk-ZU5YYGBJ.js.map +0 -1
  167. package/dist/client-DCeydotn.d.ts +0 -1015
  168. package/dist/openai-BQMeDFef.d.ts +0 -81
  169. package/dist/otel-CG0uqXjp.d.ts +0 -42
  170. package/dist/tools/browser/anthropic.cjs +0 -645
  171. package/dist/tools/browser/anthropic.cjs.map +0 -1
  172. package/dist/tools/browser/anthropic.d.ts +0 -4
  173. package/dist/tools/browser/anthropic.js +0 -22
  174. package/dist/tools/browser/anthropic.js.map +0 -1
  175. package/dist/tools/browser/core.cjs +0 -1821
  176. package/dist/tools/browser/core.cjs.map +0 -1
  177. package/dist/tools/browser/core.d.ts +0 -245
  178. package/dist/tools/browser/core.js +0 -32
  179. package/dist/tools/browser/core.js.map +0 -1
  180. package/dist/tools/browser/errors.cjs +0 -208
  181. package/dist/tools/browser/errors.cjs.map +0 -1
  182. package/dist/tools/browser/errors.d.ts +0 -158
  183. package/dist/tools/browser/errors.js +0 -22
  184. package/dist/tools/browser/errors.js.map +0 -1
  185. package/dist/tools/browser/index.cjs +0 -2159
  186. package/dist/tools/browser/index.cjs.map +0 -1
  187. package/dist/tools/browser/index.d.ts +0 -134
  188. package/dist/tools/browser/index.js +0 -163
  189. package/dist/tools/browser/index.js.map +0 -1
  190. package/dist/tools/browser/live.cjs +0 -134
  191. package/dist/tools/browser/live.cjs.map +0 -1
  192. package/dist/tools/browser/live.d.ts +0 -75
  193. package/dist/tools/browser/live.js +0 -16
  194. package/dist/tools/browser/live.js.map +0 -1
  195. package/dist/tools/browser/openai.cjs +0 -661
  196. package/dist/tools/browser/openai.cjs.map +0 -1
  197. package/dist/tools/browser/openai.d.ts +0 -4
  198. package/dist/tools/browser/openai.js +0 -28
  199. package/dist/tools/browser/openai.js.map +0 -1
  200. package/dist/tools/browser/profiles/core.cjs +0 -932
  201. package/dist/tools/browser/profiles/core.cjs.map +0 -1
  202. package/dist/tools/browser/profiles/core.d.ts +0 -187
  203. package/dist/tools/browser/profiles/core.js +0 -30
  204. package/dist/tools/browser/profiles/core.js.map +0 -1
  205. package/dist/tools/browser/profiles/index.cjs +0 -932
  206. package/dist/tools/browser/profiles/index.cjs.map +0 -1
  207. package/dist/tools/browser/profiles/index.d.ts +0 -4
  208. package/dist/tools/browser/profiles/index.js +0 -30
  209. package/dist/tools/browser/profiles/index.js.map +0 -1
  210. package/dist/tools/browser/profiles/types.cjs +0 -74
  211. package/dist/tools/browser/profiles/types.cjs.map +0 -1
  212. package/dist/tools/browser/profiles/types.d.ts +0 -195
  213. package/dist/tools/browser/profiles/types.js +0 -16
  214. package/dist/tools/browser/profiles/types.js.map +0 -1
  215. package/dist/tools/browser/prompts.cjs +0 -69
  216. package/dist/tools/browser/prompts.cjs.map +0 -1
  217. package/dist/tools/browser/prompts.d.ts +0 -7
  218. package/dist/tools/browser/prompts.js +0 -10
  219. package/dist/tools/browser/prompts.js.map +0 -1
  220. package/dist/tools/browser/types.cjs +0 -19
  221. package/dist/tools/browser/types.cjs.map +0 -1
  222. package/dist/tools/browser/types.d.ts +0 -338
  223. package/dist/tools/browser/types.js +0 -1
  224. package/dist/tools/browser/types.js.map +0 -1
  225. package/dist/tools/browser/vercel.cjs +0 -622
  226. package/dist/tools/browser/vercel.cjs.map +0 -1
  227. package/dist/tools/browser/vercel.d.ts +0 -4
  228. package/dist/tools/browser/vercel.js +0 -22
  229. package/dist/tools/browser/vercel.js.map +0 -1
  230. package/dist/tools/codebase_search/anthropic.cjs +0 -696
  231. package/dist/tools/codebase_search/anthropic.cjs.map +0 -1
  232. package/dist/tools/codebase_search/anthropic.d.ts +0 -40
  233. package/dist/tools/codebase_search/anthropic.js +0 -16
  234. package/dist/tools/codebase_search/anthropic.js.map +0 -1
  235. package/dist/tools/codebase_search/core.cjs +0 -638
  236. package/dist/tools/codebase_search/core.cjs.map +0 -1
  237. package/dist/tools/codebase_search/core.d.ts +0 -51
  238. package/dist/tools/codebase_search/core.js +0 -16
  239. package/dist/tools/codebase_search/core.js.map +0 -1
  240. package/dist/tools/codebase_search/index.cjs +0 -821
  241. package/dist/tools/codebase_search/index.cjs.map +0 -1
  242. package/dist/tools/codebase_search/index.d.ts +0 -12
  243. package/dist/tools/codebase_search/index.js +0 -32
  244. package/dist/tools/codebase_search/index.js.map +0 -1
  245. package/dist/tools/codebase_search/openai.cjs +0 -745
  246. package/dist/tools/codebase_search/openai.cjs.map +0 -1
  247. package/dist/tools/codebase_search/openai.d.ts +0 -87
  248. package/dist/tools/codebase_search/openai.js +0 -26
  249. package/dist/tools/codebase_search/openai.js.map +0 -1
  250. package/dist/tools/codebase_search/prompts.cjs +0 -57
  251. package/dist/tools/codebase_search/prompts.cjs.map +0 -1
  252. package/dist/tools/codebase_search/prompts.d.ts +0 -7
  253. package/dist/tools/codebase_search/prompts.js +0 -10
  254. package/dist/tools/codebase_search/prompts.js.map +0 -1
  255. package/dist/tools/codebase_search/types.cjs +0 -19
  256. package/dist/tools/codebase_search/types.cjs.map +0 -1
  257. package/dist/tools/codebase_search/types.d.ts +0 -50
  258. package/dist/tools/codebase_search/types.js +0 -1
  259. package/dist/tools/codebase_search/types.js.map +0 -1
  260. package/dist/tools/codebase_search/vercel.cjs +0 -658
  261. package/dist/tools/codebase_search/vercel.cjs.map +0 -1
  262. package/dist/tools/codebase_search/vercel.d.ts +0 -65
  263. package/dist/tools/codebase_search/vercel.js +0 -20
  264. package/dist/tools/codebase_search/vercel.js.map +0 -1
  265. package/dist/tracing/core.cjs +0 -410
  266. package/dist/tracing/core.cjs.map +0 -1
  267. package/dist/tracing/core.d.ts +0 -58
  268. package/dist/tracing/core.js +0 -12
  269. package/dist/tracing/core.js.map +0 -1
  270. package/dist/tracing/index.cjs +0 -422
  271. package/dist/tracing/index.cjs.map +0 -1
  272. package/dist/tracing/index.d.ts +0 -5
  273. package/dist/tracing/index.js +0 -17
  274. package/dist/tracing/index.js.map +0 -1
  275. package/dist/tracing/interaction.cjs +0 -273
  276. package/dist/tracing/interaction.cjs.map +0 -1
  277. package/dist/tracing/interaction.d.ts +0 -41
  278. package/dist/tracing/interaction.js +0 -11
  279. package/dist/tracing/interaction.js.map +0 -1
  280. package/dist/tracing/otel.cjs +0 -56
  281. package/dist/tracing/otel.cjs.map +0 -1
  282. package/dist/tracing/otel.d.ts +0 -2
  283. package/dist/tracing/otel.js +0 -10
  284. package/dist/tracing/otel.js.map +0 -1
  285. package/dist/tracing/types.cjs +0 -19
  286. package/dist/tracing/types.cjs.map +0 -1
  287. package/dist/tracing/types.d.ts +0 -124
  288. package/dist/tracing/types.js +0 -1
  289. package/dist/tracing/types.js.map +0 -1
  290. package/dist/vercel-CVF27qFK.d.ts +0 -74
  291. /package/dist/{chunk-ZQNTXHBQ.js.map → chunk-3CCWSLQW.js.map} +0 -0
  292. /package/dist/{chunk-FESO6TDQ.js.map → chunk-7I2A7GGJ.js.map} +0 -0
  293. /package/dist/{chunk-4JUIEYAH.js.map → chunk-AKSXZBPT.js.map} +0 -0
  294. /package/dist/{chunk-QKNGVBE2.js.map → chunk-L6YOMTFU.js.map} +0 -0
  295. /package/dist/{chunk-YQ2G5YLI.js.map → chunk-MLROWLS6.js.map} +0 -0
  296. /package/dist/{chunk-4DNEBVGV.js.map → chunk-MPL6BDR6.js.map} +0 -0
  297. /package/dist/{chunk-3XS5P5XH.js.map → chunk-PD3EDFQD.js.map} +0 -0
  298. /package/dist/{chunk-CAFREMIT.js.map → chunk-PJNL35DC.js.map} +0 -0
  299. /package/dist/{chunk-PEFXG5M6.js.map → chunk-Q65LL6UM.js.map} +0 -0
  300. /package/dist/{chunk-YUH3MTP3.js.map → chunk-QTBFL4DG.js.map} +0 -0
  301. /package/dist/{chunk-XTFRHVCW.js.map → chunk-SNYHVDE4.js.map} +0 -0
  302. /package/dist/{chunk-ZGERT23F.js.map → chunk-TIMDDHYB.js.map} +0 -0
  303. /package/dist/{chunk-PV6EF6NG.js.map → chunk-UHIANNKC.js.map} +0 -0
  304. /package/dist/{chunk-XK3PQZW6.js.map → chunk-WTENYKJP.js.map} +0 -0
  305. /package/dist/{chunk-6XFL2NER.js.map → chunk-XTLPA7ZP.js.map} +0 -0
  306. /package/dist/{chunk-D2RFP6R2.js.map → chunk-Z57GJLCG.js.map} +0 -0
  307. /package/dist/{chunk-SKN2L5CE.js.map → chunk-ZE64EWUV.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -36,7 +36,7 @@ var init_package = __esm({
36
36
  "package.json"() {
37
37
  package_default = {
38
38
  name: "@morphllm/morphsdk",
39
- version: "0.2.198",
39
+ version: "0.2.200",
40
40
  description: "TypeScript SDK and CLI for Morph Fast Apply integration",
41
41
  type: "module",
42
42
  main: "./dist/index.cjs",
@@ -93,16 +93,6 @@ var init_package = __esm({
93
93
  import: "./dist/tools/warp_grep/harness.js",
94
94
  require: "./dist/tools/warp_grep/harness.cjs"
95
95
  },
96
- "./tracing": {
97
- types: "./dist/tracing/index.d.ts",
98
- import: "./dist/tracing/index.js",
99
- require: "./dist/tracing/index.cjs"
100
- },
101
- "./tracing/otel": {
102
- types: "./dist/tracing/otel.d.ts",
103
- import: "./dist/tracing/otel.js",
104
- require: "./dist/tracing/otel.cjs"
105
- },
106
96
  "./tools/fastapply": {
107
97
  types: "./dist/tools/fastapply/index.d.ts",
108
98
  import: "./dist/tools/fastapply/index.js",
@@ -123,51 +113,6 @@ var init_package = __esm({
123
113
  import: "./dist/tools/fastapply/vercel.js",
124
114
  require: "./dist/tools/fastapply/vercel.cjs"
125
115
  },
126
- "./tools/codebase-search": {
127
- types: "./dist/tools/codebase_search/index.d.ts",
128
- import: "./dist/tools/codebase_search/index.js",
129
- require: "./dist/tools/codebase_search/index.cjs"
130
- },
131
- "./tools/codebase-search/anthropic": {
132
- types: "./dist/tools/codebase_search/anthropic.d.ts",
133
- import: "./dist/tools/codebase_search/anthropic.js",
134
- require: "./dist/tools/codebase_search/anthropic.cjs"
135
- },
136
- "./tools/codebase-search/openai": {
137
- types: "./dist/tools/codebase_search/openai.d.ts",
138
- import: "./dist/tools/codebase_search/openai.js",
139
- require: "./dist/tools/codebase_search/openai.cjs"
140
- },
141
- "./tools/codebase-search/vercel": {
142
- types: "./dist/tools/codebase_search/vercel.d.ts",
143
- import: "./dist/tools/codebase_search/vercel.js",
144
- require: "./dist/tools/codebase_search/vercel.cjs"
145
- },
146
- "./tools/browser": {
147
- types: "./dist/tools/browser/index.d.ts",
148
- import: "./dist/tools/browser/index.js",
149
- require: "./dist/tools/browser/index.cjs"
150
- },
151
- "./tools/browser/anthropic": {
152
- types: "./dist/tools/browser/anthropic.d.ts",
153
- import: "./dist/tools/browser/anthropic.js",
154
- require: "./dist/tools/browser/anthropic.cjs"
155
- },
156
- "./tools/browser/openai": {
157
- types: "./dist/tools/browser/openai.d.ts",
158
- import: "./dist/tools/browser/openai.js",
159
- require: "./dist/tools/browser/openai.cjs"
160
- },
161
- "./tools/browser/vercel": {
162
- types: "./dist/tools/browser/vercel.d.ts",
163
- import: "./dist/tools/browser/vercel.js",
164
- require: "./dist/tools/browser/vercel.cjs"
165
- },
166
- "./tools/browser/profiles": {
167
- types: "./dist/tools/browser/profiles/index.d.ts",
168
- import: "./dist/tools/browser/profiles/index.js",
169
- require: "./dist/tools/browser/profiles/index.cjs"
170
- },
171
116
  "./modelrouter": {
172
117
  types: "./dist/modelrouter/index.d.ts",
173
118
  import: "./dist/modelrouter/index.js",
@@ -208,7 +153,7 @@ var init_package = __esm({
208
153
  "!dist/**/*.test.*"
209
154
  ],
210
155
  scripts: {
211
- build: "tsup version.ts index.ts edge.ts client.ts core/index.ts core/client.ts core/resource.ts core/error.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts subagents/index.ts subagents/types.ts subagents/prompts.ts subagents/vercel.ts subagents/anthropic.ts tracing/index.ts tracing/core.ts tracing/interaction.ts tracing/otel.ts tracing/types.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve && tsup ai-sdk/index.ts --format esm,cjs --sourcemap --dts --no-clean --out-dir dist/ai-sdk",
156
+ build: "tsup version.ts index.ts edge.ts client.ts core/index.ts core/client.ts core/resource.ts core/error.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts subagents/index.ts subagents/types.ts subagents/prompts.ts subagents/vercel.ts subagents/anthropic.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve && tsup ai-sdk/index.ts --format esm,cjs --sourcemap --dts --no-clean --out-dir dist/ai-sdk",
212
157
  prepare: "npm run build",
213
158
  typecheck: "tsc --noEmit && tsc --noEmit -p ai-sdk/tsconfig.json",
214
159
  lint: "eslint .",
@@ -218,7 +163,6 @@ var init_package = __esm({
218
163
  "test:openai": "vitest run openai",
219
164
  "test:vercel": "vitest run vercel",
220
165
  "test:git": "vitest run git",
221
- "test:browser": "vitest run browser",
222
166
  "test:agent": "npx tsx tests/fullAgentTest.ts",
223
167
  "test:integration": "npx tsx tests/fullIntegrationTest.ts",
224
168
  "test:e2e": "vitest run --config vitest.e2e.config.ts",
@@ -238,10 +182,6 @@ var init_package = __esm({
238
182
  },
239
183
  license: "MIT",
240
184
  dependencies: {
241
- "@opentelemetry/api": "^1.9.0",
242
- "@opentelemetry/exporter-trace-otlp-http": "^0.203.0",
243
- "@opentelemetry/sdk-trace-base": "^2.7.1",
244
- "@traceloop/node-server-sdk": "^0.27.0",
245
185
  "@vscode/ripgrep": "^1.17.0",
246
186
  ai: ">=5.0.0",
247
187
  diff: "^7.0.0",
@@ -1355,23 +1295,16 @@ __export(index_exports, {
1355
1295
  APIResource: () => APIResource,
1356
1296
  AnthropicRouter: () => AnthropicRouter,
1357
1297
  AnthropicToolFactory: () => AnthropicToolFactory,
1358
- BrowserClient: () => BrowserClient,
1359
- CodebaseSearchClient: () => CodebaseSearchClient,
1360
1298
  CompactClient: () => CompactClient,
1361
1299
  FastApplyAnchorIntegrityError: () => FastApplyAnchorIntegrityError,
1362
1300
  FastApplyClient: () => FastApplyClient,
1363
1301
  FastApplyContextLengthError: () => FastApplyContextLengthError,
1364
1302
  GeminiRouter: () => GeminiRouter,
1365
- GitHubClient: () => GitHubClient,
1366
- GitHubError: () => GitHubError,
1367
1303
  LocalRipgrepProvider: () => LocalRipgrepProvider,
1368
1304
  MorphAPIClient: () => MorphAPIClient,
1369
1305
  MorphClient: () => MorphClient,
1370
- NoInstallationError: () => NoInstallationError,
1371
- NotFoundError: () => NotFoundError,
1372
1306
  OpenAIRouter: () => OpenAIRouter,
1373
1307
  OpenAIToolFactory: () => OpenAIToolFactory,
1374
- PermissionError: () => PermissionError,
1375
1308
  RawRouter: () => RawRouter,
1376
1309
  SDK_VERSION: () => SDK_VERSION,
1377
1310
  VercelToolFactory: () => VercelToolFactory,
@@ -1489,7 +1422,6 @@ async function toMorphError(response) {
1489
1422
  // core/client.ts
1490
1423
  var DEFAULT_BASE_URL = "https://api.morphllm.com";
1491
1424
  var DEFAULT_REPOS_URL = "https://repos.morphllm.com";
1492
- var DEFAULT_BROWSER_URL = "https://browser.morphllm.com";
1493
1425
  var DEFAULT_TIMEOUT = 6e4;
1494
1426
  var env = (name) => typeof process !== "undefined" ? process.env?.[name] : void 0;
1495
1427
  var stripTrailingSlash = (url) => url.replace(/\/+$/, "");
@@ -1498,7 +1430,6 @@ var MorphAPIClient = class {
1498
1430
  apiKey;
1499
1431
  baseURL;
1500
1432
  reposURL;
1501
- browserURL;
1502
1433
  /** Explicit default timeout (ms), if set. The request default is applied lazily so
1503
1434
  * resources can read an undefined value and supply their own fallback. */
1504
1435
  timeout;
@@ -1508,9 +1439,6 @@ var MorphAPIClient = class {
1508
1439
  this.apiKey = options.apiKey;
1509
1440
  this.baseURL = stripTrailingSlash(options.baseURL ?? DEFAULT_BASE_URL);
1510
1441
  this.reposURL = stripTrailingSlash(options.reposURL ?? env("MORPH_SEARCH_URL") ?? DEFAULT_REPOS_URL);
1511
- this.browserURL = stripTrailingSlash(
1512
- options.browserURL ?? (env("MORPH_ENVIRONMENT") === "DEV" ? "http://localhost:8000" : DEFAULT_BROWSER_URL)
1513
- );
1514
1442
  this.timeout = options.timeout;
1515
1443
  this.retryConfig = options.retryConfig;
1516
1444
  this.debug = options.debug ?? false;
@@ -1569,7 +1497,6 @@ var MorphAPIClient = class {
1569
1497
  timeout,
1570
1498
  `Morph request to ${url} timed out after ${timeout}ms`
1571
1499
  );
1572
- if (opts.raw) return response;
1573
1500
  if (!response.ok) throw await toMorphError(response);
1574
1501
  if (opts.stream) return response;
1575
1502
  if (response.status === 204) return void 0;
@@ -1689,1381 +1616,48 @@ async function executeEditFile(input, config = {}) {
1689
1616
  logger.debug("FastApply", "security_check", { resolved: fullPath, relative: relativePath });
1690
1617
  try {
1691
1618
  const { readFile, writeFile } = await import("fs/promises");
1692
- const { callMorphAPI: callMorphAPI2, generateUdiff: generateUdiff2, countChanges: countChanges2 } = await Promise.resolve().then(() => (init_apply(), apply_exports));
1693
- let originalCode = "";
1694
- let fileExists = true;
1695
- try {
1696
- originalCode = await readFile(fullPath, "utf-8");
1697
- logger.debug("FastApply", "file_read", { path: fullPath, exists: true, size_bytes: originalCode.length });
1698
- } catch (error) {
1699
- if (error.code !== "ENOENT") {
1700
- throw error;
1701
- }
1702
- fileExists = false;
1703
- logger.debug("FastApply", "file_read", { path: fullPath, exists: false });
1704
- }
1705
- const instruction = input.instruction ?? input.instructions ?? "";
1706
- logger.debug("FastApply", "api_call", { instruction_len: instruction.length, code_edit_len: input.code_edit.length, original_len: originalCode.length });
1707
- const { content: mergedCode, completionId } = await callMorphAPI2(originalCode, input.code_edit, instruction, input.target_filepath, config);
1708
- logger.debug("FastApply", "api_response", { completion_id: completionId, merged_len: mergedCode.length });
1709
- const udiff = config.generateUdiff !== false ? generateUdiff2(originalCode, mergedCode, input.target_filepath) : void 0;
1710
- if (config.autoWrite !== false) {
1711
- await writeFile(fullPath, mergedCode, "utf-8");
1712
- logger.debug("FastApply", "file_write", { path: fullPath, size_bytes: mergedCode.length });
1713
- }
1714
- const changes = countChanges2(originalCode, mergedCode);
1715
- logger.debug("FastApply", "changes", { added: changes.linesAdded, removed: changes.linesRemoved, modified: changes.linesModified });
1716
- return {
1717
- success: true,
1718
- filepath: input.target_filepath,
1719
- udiff,
1720
- changes,
1721
- completionId
1722
- };
1723
- } catch (error) {
1724
- const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
1725
- const structuredError = error instanceof FastApplyContextLengthError || error instanceof FastApplyAnchorIntegrityError ? error : void 0;
1726
- logger.error("FastApply", "execute_error", { error: errorMessage, target_filepath: input.target_filepath, stack: error instanceof Error ? error.stack : void 0 });
1727
- return {
1728
- success: false,
1729
- filepath: input.target_filepath,
1730
- changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },
1731
- error: errorMessage,
1732
- errorCode: structuredError?.code,
1733
- completionId: structuredError?.completionId
1734
- };
1735
- }
1736
- }
1737
-
1738
- // tools/codebase_search/core.ts
1739
- init_logger();
1740
- var DEFAULT_TIMEOUT3 = 3e4;
1741
- var emptyStats = { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: 0 };
1742
- async function runSearch(client, input, repoId, timeout, baseURL) {
1743
- const startTime = Date.now();
1744
- logger.debug("CodebaseSearch", "request", { query: input.query.slice(0, 100), repo_id: repoId });
1745
- try {
1746
- const data = await client.post(
1747
- "/v1/codebase_search",
1748
- {
1749
- baseURL: baseURL ?? client.reposURL,
1750
- timeout,
1751
- body: {
1752
- query: input.query,
1753
- repoId,
1754
- targetDirectories: input.target_directories || [],
1755
- limit: input.limit || 10,
1756
- candidateLimit: 50
1757
- }
1758
- }
1759
- );
1760
- const elapsed = Date.now() - startTime;
1761
- logger.debug("CodebaseSearch", "response", { results_count: data.results?.length || 0, latency_ms: elapsed });
1762
- return {
1763
- success: true,
1764
- results: data.results || [],
1765
- stats: data.stats || { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: elapsed }
1766
- };
1767
- } catch (error) {
1768
- const message = error instanceof MorphError && error.statusCode ? `Search failed (${error.statusCode}): ${error.message}` : error instanceof Error ? error.message : "Unknown error";
1769
- logger.error("CodebaseSearch", "error", { error: message, latency_ms: Date.now() - startTime });
1770
- return { success: false, results: [], stats: { ...emptyStats }, error: message };
1771
- }
1772
- }
1773
- var CodebaseSearchClient = class extends APIResource {
1774
- timeout;
1775
- constructor(clientOrConfig = {}) {
1776
- super(
1777
- clientOrConfig instanceof MorphAPIClient ? clientOrConfig : new MorphAPIClient({
1778
- apiKey: clientOrConfig.apiKey,
1779
- timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT3,
1780
- retryConfig: clientOrConfig.retryConfig,
1781
- debug: clientOrConfig.debug
1782
- })
1783
- );
1784
- this.timeout = (clientOrConfig instanceof MorphAPIClient ? void 0 : clientOrConfig.timeout) ?? DEFAULT_TIMEOUT3;
1785
- }
1786
- /**
1787
- * Execute a semantic code search
1788
- *
1789
- * @param input - Search parameters including query, repoId, and target directories
1790
- * @param overrides - Optional config overrides for this operation
1791
- * @returns Search results with ranked code matches
1792
- */
1793
- async search(input, overrides) {
1794
- return runSearch(
1795
- this._client,
1796
- { query: input.query, target_directories: input.target_directories, explanation: input.explanation, limit: input.limit },
1797
- input.repoId,
1798
- overrides?.timeout ?? this.timeout,
1799
- overrides?.searchUrl
1800
- );
1801
- }
1802
- };
1803
- async function executeCodebaseSearch(input, config) {
1804
- const apiKey = config.apiKey || process.env.MORPH_API_KEY;
1805
- if (!apiKey) {
1806
- throw new Error("MORPH_API_KEY not found. Set environment variable or pass in config");
1807
- }
1808
- const client = new MorphAPIClient({
1809
- apiKey,
1810
- reposURL: config.searchUrl,
1811
- timeout: config.timeout ?? DEFAULT_TIMEOUT3,
1812
- retryConfig: config.retryConfig,
1813
- debug: config.debug
1814
- });
1815
- return runSearch(client, input, config.repoId, config.timeout ?? DEFAULT_TIMEOUT3, config.searchUrl);
1816
- }
1817
-
1818
- // tools/browser/core.ts
1819
- init_logger();
1820
-
1821
- // tools/browser/live.ts
1822
- var LIVE_PRESETS = {
1823
- /** Read-only monitoring (no interaction) */
1824
- readonly: { interactive: false },
1825
- /** Interactive control (human-in-the-loop) */
1826
- interactive: { interactive: true },
1827
- /** Watch-only without controls */
1828
- monitoring: { interactive: false, showControls: false }
1829
- };
1830
- function buildLiveUrl(debugUrl, options = {}) {
1831
- if (!debugUrl) {
1832
- throw new Error(
1833
- "debugUrl is required. Ensure your backend returns debugUrl in the task response. Contact support@morphllm.com if you need help."
1834
- );
1835
- }
1836
- const normalized = normalizeLiveUrl(debugUrl);
1837
- const url = new URL(normalized);
1838
- if (options.interactive !== void 0) {
1839
- url.searchParams.set("interactive", String(options.interactive));
1840
- }
1841
- if (options.theme) {
1842
- url.searchParams.set("theme", options.theme);
1843
- }
1844
- if (options.showControls !== void 0) {
1845
- url.searchParams.set("showControls", String(options.showControls));
1846
- }
1847
- if (options.pageId) {
1848
- url.searchParams.set("pageId", options.pageId);
1849
- }
1850
- if (options.pageIndex) {
1851
- url.searchParams.set("pageIndex", options.pageIndex);
1852
- }
1853
- return url.toString();
1854
- }
1855
- function cdpToHttps(wsUrl) {
1856
- return wsUrl.replace(/^wss:\/\//, "https://").replace(/^ws:\/\//, "http://");
1857
- }
1858
- function normalizeLiveUrl(debugUrl) {
1859
- const trimmed = debugUrl.trim();
1860
- if (!trimmed) return trimmed;
1861
- if (trimmed.startsWith("wss://") || trimmed.startsWith("ws://")) {
1862
- return `https://live.browser-use.com?wss=${encodeURIComponent(cdpToHttps(trimmed))}`;
1863
- }
1864
- let url;
1865
- try {
1866
- url = new URL(trimmed);
1867
- } catch {
1868
- return trimmed;
1869
- }
1870
- const wssParam = url.searchParams.get("wss");
1871
- if (wssParam && (wssParam.startsWith("wss://") || wssParam.startsWith("ws://"))) {
1872
- url.searchParams.set("wss", cdpToHttps(wssParam));
1873
- }
1874
- return url.toString();
1875
- }
1876
- function buildLiveIframe(debugUrl, options = {}) {
1877
- const {
1878
- width = "100%",
1879
- height = "600px",
1880
- style = "",
1881
- className = "",
1882
- ...sessionOptions
1883
- } = options;
1884
- const src = buildLiveUrl(debugUrl, sessionOptions);
1885
- const widthStr = typeof width === "number" ? `${width}px` : width;
1886
- const heightStr = typeof height === "number" ? `${height}px` : height;
1887
- const baseStyle = `width: ${widthStr}; height: ${heightStr}; border: none;`;
1888
- const fullStyle = style ? `${baseStyle} ${style}` : baseStyle;
1889
- const attributes = [
1890
- `src="${src}"`,
1891
- `style="${fullStyle}"`
1892
- ];
1893
- if (className) {
1894
- attributes.push(`class="${className}"`);
1895
- }
1896
- return `<iframe ${attributes.join(" ")}></iframe>`;
1897
- }
1898
- function buildEmbedCode(debugUrl, options = {}) {
1899
- const iframe = buildLiveIframe(debugUrl, options);
1900
- return `<!-- Embed Morph Live Session -->
1901
- ${iframe}`;
1902
- }
1903
- function resolvePreset(optionsOrPreset) {
1904
- if (!optionsOrPreset) {
1905
- return {};
1906
- }
1907
- if (typeof optionsOrPreset === "string") {
1908
- const preset = LIVE_PRESETS[optionsOrPreset];
1909
- if (!preset) {
1910
- throw new Error(
1911
- `Unknown preset: ${optionsOrPreset}. Available presets: ${Object.keys(LIVE_PRESETS).join(", ")}`
1912
- );
1913
- }
1914
- return preset;
1915
- }
1916
- return optionsOrPreset;
1917
- }
1918
-
1919
- // tools/browser/errors.ts
1920
- var MorphError2 = class extends Error {
1921
- /** Error code for programmatic handling */
1922
- code;
1923
- /** Original cause of the error, if any */
1924
- cause;
1925
- constructor(message, code, cause) {
1926
- super(message);
1927
- this.name = "MorphError";
1928
- this.code = code;
1929
- this.cause = cause;
1930
- if (Error.captureStackTrace) {
1931
- Error.captureStackTrace(this, this.constructor);
1932
- }
1933
- }
1934
- /**
1935
- * Returns a JSON representation of the error for logging.
1936
- */
1937
- toJSON() {
1938
- return {
1939
- name: this.name,
1940
- message: this.message,
1941
- code: this.code,
1942
- cause: this.cause?.message
1943
- };
1944
- }
1945
- };
1946
- var MorphValidationError = class extends MorphError2 {
1947
- /** The field that failed validation */
1948
- field;
1949
- constructor(message, field) {
1950
- super(message, "validation_error");
1951
- this.name = "MorphValidationError";
1952
- this.field = field;
1953
- }
1954
- toJSON() {
1955
- return {
1956
- ...super.toJSON(),
1957
- field: this.field
1958
- };
1959
- }
1960
- };
1961
- var MorphAPIError = class extends MorphError2 {
1962
- /** HTTP status code */
1963
- statusCode;
1964
- /** Request ID for debugging (if available) */
1965
- requestId;
1966
- /** Raw response body */
1967
- rawResponse;
1968
- constructor(message, code, statusCode, options) {
1969
- super(message, code, options?.cause);
1970
- this.name = "MorphAPIError";
1971
- this.statusCode = statusCode;
1972
- this.requestId = options?.requestId;
1973
- this.rawResponse = options?.rawResponse;
1974
- }
1975
- toJSON() {
1976
- return {
1977
- ...super.toJSON(),
1978
- statusCode: this.statusCode,
1979
- requestId: this.requestId
1980
- };
1981
- }
1982
- };
1983
- var MorphAuthenticationError = class extends MorphAPIError {
1984
- constructor(message = "Authentication required. Please provide a valid API key.") {
1985
- super(message, "authentication_required", 401);
1986
- this.name = "MorphAuthenticationError";
1987
- }
1988
- };
1989
- var MorphRateLimitError = class extends MorphAPIError {
1990
- /** When the rate limit resets (Unix timestamp) */
1991
- resetAt;
1992
- /** Number of seconds until reset */
1993
- retryAfter;
1994
- constructor(message = "Rate limit exceeded. Please retry later.", options) {
1995
- super(message, "rate_limit_exceeded", 429, { requestId: options?.requestId });
1996
- this.name = "MorphRateLimitError";
1997
- this.resetAt = options?.resetAt;
1998
- this.retryAfter = options?.retryAfter;
1999
- }
2000
- toJSON() {
2001
- return {
2002
- ...super.toJSON(),
2003
- resetAt: this.resetAt,
2004
- retryAfter: this.retryAfter
2005
- };
2006
- }
2007
- };
2008
- var MorphNotFoundError = class extends MorphAPIError {
2009
- /** The type of resource that was not found */
2010
- resourceType;
2011
- /** The ID of the resource that was not found */
2012
- resourceId;
2013
- constructor(resourceType, resourceId) {
2014
- const message = resourceId ? `${resourceType} '${resourceId}' not found` : `${resourceType} not found`;
2015
- super(message, "resource_not_found", 404);
2016
- this.name = "MorphNotFoundError";
2017
- this.resourceType = resourceType;
2018
- this.resourceId = resourceId;
2019
- }
2020
- toJSON() {
2021
- return {
2022
- ...super.toJSON(),
2023
- resourceType: this.resourceType,
2024
- resourceId: this.resourceId
2025
- };
2026
- }
2027
- };
2028
- var MorphProfileLimitError = class extends MorphAPIError {
2029
- /** Current number of profiles */
2030
- currentCount;
2031
- /** Maximum allowed profiles for the plan */
2032
- maxAllowed;
2033
- constructor(message = "Profile limit exceeded for your plan.", options) {
2034
- super(message, "profile_limit_exceeded", 403, { requestId: options?.requestId });
2035
- this.name = "MorphProfileLimitError";
2036
- this.currentCount = options?.currentCount;
2037
- this.maxAllowed = options?.maxAllowed;
2038
- }
2039
- toJSON() {
2040
- return {
2041
- ...super.toJSON(),
2042
- currentCount: this.currentCount,
2043
- maxAllowed: this.maxAllowed
2044
- };
2045
- }
2046
- };
2047
- function parseAPIError(statusCode, responseText, requestId) {
2048
- let errorData = {};
2049
- try {
2050
- errorData = JSON.parse(responseText);
2051
- } catch {
2052
- }
2053
- const message = errorData.detail || errorData.message || responseText || "Unknown error";
2054
- const code = errorData.code;
2055
- switch (statusCode) {
2056
- case 401:
2057
- return new MorphAuthenticationError(message);
2058
- case 403:
2059
- if (code === "profile_limit_exceeded" || message.toLowerCase().includes("limit")) {
2060
- return new MorphProfileLimitError(message, { requestId });
2061
- }
2062
- return new MorphAPIError(message, "insufficient_permissions", statusCode, { requestId, rawResponse: responseText });
2063
- case 404:
2064
- if (message.toLowerCase().includes("profile")) {
2065
- return new MorphNotFoundError("Profile", void 0);
2066
- }
2067
- if (message.toLowerCase().includes("session")) {
2068
- return new MorphNotFoundError("Session", void 0);
2069
- }
2070
- return new MorphAPIError(message, "resource_not_found", statusCode, { requestId, rawResponse: responseText });
2071
- case 429:
2072
- return new MorphRateLimitError(message, { requestId });
2073
- case 422:
2074
- return new MorphAPIError(message, "validation_error", statusCode, { requestId, rawResponse: responseText });
2075
- case 500:
2076
- case 502:
2077
- case 503:
2078
- case 504:
2079
- return new MorphAPIError(message, "service_unavailable", statusCode, { requestId, rawResponse: responseText });
2080
- default:
2081
- return new MorphAPIError(message, "network_error", statusCode, { requestId, rawResponse: responseText });
2082
- }
2083
- }
2084
-
2085
- // tools/browser/profiles/types.ts
2086
- function transformProfile(api) {
2087
- return {
2088
- id: api.id,
2089
- name: api.name,
2090
- repoId: api.repo_id,
2091
- cookieDomains: api.cookie_domains,
2092
- lastUsedAt: api.last_used_at,
2093
- createdAt: api.created_at,
2094
- updatedAt: api.updated_at
2095
- };
2096
- }
2097
- function transformCreateInput(input) {
2098
- return {
2099
- name: input.name,
2100
- repo_id: input.repoId
2101
- };
2102
- }
2103
- function transformSession(api) {
2104
- return {
2105
- sessionId: api.session_id,
2106
- debugUrl: api.debug_url || ""
2107
- };
2108
- }
2109
- function transformSaveInput(input) {
2110
- return {
2111
- session_id: input.sessionId,
2112
- profile_id: input.profileId
2113
- };
2114
- }
2115
- function transformStateResponse(api) {
2116
- return {
2117
- profileId: api.profile_id,
2118
- stateUrl: api.state_url,
2119
- expiresIn: api.expires_in
2120
- };
2121
- }
2122
-
2123
- // tools/browser/profiles/core.ts
2124
- var DEFAULT_API_URL2 = process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com";
2125
- var ProfilesClient = class {
2126
- config;
2127
- constructor(config) {
2128
- this.config = config;
2129
- }
2130
- /**
2131
- * Create a new browser profile and immediately start a live session.
2132
- *
2133
- * @param input - Profile creation parameters
2134
- * @returns Profile setup handle with live URL + save()
2135
- * @throws {MorphValidationError} If input validation fails
2136
- * @throws {MorphProfileLimitError} If profile limit is exceeded
2137
- * @throws {MorphAuthenticationError} If API key is missing or invalid
2138
- *
2139
- * @example
2140
- * ```typescript
2141
- * const setup = await morph.browser.profiles.createProfile({
2142
- * name: 'LinkedIn Production',
2143
- * repoId: 'owner/repo'
2144
- * });
2145
- * console.log(setup.session.debugUrl);
2146
- * await setup.save();
2147
- * ```
2148
- */
2149
- async createProfile(input) {
2150
- return createProfile(input, this.config);
2151
- }
2152
- /**
2153
- * List all profiles for the authenticated user.
2154
- *
2155
- * @param repoId - Optional repository ID to filter by
2156
- * @returns Array of profiles
2157
- *
2158
- * @example
2159
- * ```typescript
2160
- * // List all profiles
2161
- * const allProfiles = await morph.browser.profiles.listProfiles();
2162
- *
2163
- * // List profiles for a specific repo
2164
- * const repoProfiles = await morph.browser.profiles.listProfiles('owner/repo');
2165
- * ```
2166
- */
2167
- async listProfiles(repoId) {
2168
- return listProfiles(this.config, repoId);
2169
- }
2170
- /**
2171
- * Get a profile by ID with convenience methods.
2172
- *
2173
- * @param id - Profile ID
2174
- * @returns Profile with attached methods
2175
- * @throws {MorphNotFoundError} If profile is not found
2176
- *
2177
- * @example
2178
- * ```typescript
2179
- * const profile = await morph.browser.profiles.getProfile('profile-id');
2180
- * const state = await profile.getState();
2181
- * await profile.delete();
2182
- * ```
2183
- */
2184
- async getProfile(id) {
2185
- return getProfile(id, this.config);
2186
- }
2187
- /**
2188
- * Update a profile by opening a live session (no rename).
2189
- *
2190
- * @param id - Profile ID
2191
- * @returns Profile setup handle with live URL + save()
2192
- */
2193
- async updateProfile(id) {
2194
- return updateProfile(id, this.config);
2195
- }
2196
- /**
2197
- * Delete a profile.
2198
- *
2199
- * @param id - Profile ID
2200
- * @throws {MorphNotFoundError} If profile is not found
2201
- */
2202
- async deleteProfile(id) {
2203
- return deleteProfile(id, this.config);
2204
- }
2205
- /**
2206
- * Start a browser session for profile setup.
2207
- *
2208
- * Returns a live URL where the user can sign into accounts.
2209
- * After signing in, call `saveSession` to persist the state.
2210
- *
2211
- * @param input - Optional session parameters
2212
- * @returns Session with debug URL
2213
- *
2214
- * @example
2215
- * ```typescript
2216
- * const session = await morph.browser.profiles.startSession();
2217
- * console.log('Sign in at:', session.debugUrl);
2218
- * // Open debugUrl in browser, user signs in...
2219
- * await morph.browser.profiles.saveSession(session.sessionId, profile.id);
2220
- * ```
2221
- */
2222
- async startSession(input) {
2223
- return startProfileSession(this.config, input);
2224
- }
2225
- /**
2226
- * Save browser state from a session to a profile.
2227
- *
2228
- * Call this after the user is done signing into accounts.
2229
- * Extracts cookies, localStorage, and sessionStorage.
2230
- *
2231
- * @param sessionId - Browser session ID from startSession
2232
- * @param profileId - Profile ID to save state to
2233
- * @returns Updated profile with cookie domains
2234
- */
2235
- async saveSession(sessionId, profileId) {
2236
- return saveProfileSession({ sessionId, profileId }, this.config);
2237
- }
2238
- /**
2239
- * List available repo IDs (discovery).
2240
- *
2241
- * @returns Repo summaries with profile counts
2242
- */
2243
- async listRepos() {
2244
- return listRepos(this.config);
2245
- }
2246
- /**
2247
- * Get the presigned URL for a profile's state.
2248
- *
2249
- * Use this to download the raw state JSON for debugging
2250
- * or to restore state manually.
2251
- *
2252
- * @param profileId - Profile ID
2253
- * @returns State URL with expiry information
2254
- */
2255
- async getProfileState(profileId) {
2256
- return getProfileState(profileId, this.config);
2257
- }
2258
- };
2259
- function validateCreateInput(input) {
2260
- if (!input.name || typeof input.name !== "string") {
2261
- throw new MorphValidationError("name is required", "name");
2262
- }
2263
- const trimmedName = input.name.trim();
2264
- if (trimmedName.length === 0) {
2265
- throw new MorphValidationError("name cannot be empty", "name");
2266
- }
2267
- if (trimmedName.length > 100) {
2268
- throw new MorphValidationError("name must be 100 characters or less", "name");
2269
- }
2270
- if (!input.repoId || typeof input.repoId !== "string") {
2271
- throw new MorphValidationError("repoId is required", "repoId");
2272
- }
2273
- if (input.repoId.trim().length === 0) {
2274
- throw new MorphValidationError("repoId cannot be empty", "repoId");
2275
- }
2276
- }
2277
- function validateId(id, fieldName) {
2278
- if (!id || typeof id !== "string") {
2279
- throw new MorphValidationError(`${fieldName} is required`, fieldName);
2280
- }
2281
- if (id.trim().length === 0) {
2282
- throw new MorphValidationError(`${fieldName} cannot be empty`, fieldName);
2283
- }
2284
- }
2285
- async function createProfile(input, config = {}) {
2286
- validateCreateInput(input);
2287
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2288
- const headers = buildHeaders(config);
2289
- const response = await fetchWithRetry(
2290
- `${apiUrl}/profiles`,
2291
- {
2292
- method: "POST",
2293
- headers,
2294
- body: JSON.stringify(transformCreateInput(input))
2295
- },
2296
- config.retryConfig
2297
- );
2298
- if (!response.ok) {
2299
- const errorText = await response.text().catch(() => response.statusText);
2300
- const requestId = response.headers.get("x-request-id") || void 0;
2301
- throw parseAPIError(response.status, errorText, requestId);
2302
- }
2303
- const apiProfile = await response.json();
2304
- const profile = transformProfile(apiProfile);
2305
- const session = await startProfileSession(config, { profileId: profile.id });
2306
- return buildProfileSetup(profile, session, config);
2307
- }
2308
- async function listProfiles(config = {}, repoId) {
2309
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2310
- const headers = buildHeaders(config);
2311
- const url = repoId ? `${apiUrl}/profiles?repo_id=${encodeURIComponent(repoId)}` : `${apiUrl}/profiles`;
2312
- const response = await fetchWithRetry(
2313
- url,
2314
- { method: "GET", headers },
2315
- config.retryConfig
2316
- );
2317
- if (!response.ok) {
2318
- const errorText = await response.text().catch(() => response.statusText);
2319
- const requestId = response.headers.get("x-request-id") || void 0;
2320
- throw parseAPIError(response.status, errorText, requestId);
2321
- }
2322
- const data = await response.json();
2323
- return data.profiles.map(transformProfile);
2324
- }
2325
- async function getProfile(id, config = {}) {
2326
- validateId(id, "id");
2327
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2328
- const headers = buildHeaders(config);
2329
- const response = await fetchWithRetry(
2330
- `${apiUrl}/profiles/${encodeURIComponent(id)}`,
2331
- { method: "GET", headers },
2332
- config.retryConfig
2333
- );
2334
- if (!response.ok) {
2335
- const errorText = await response.text().catch(() => response.statusText);
2336
- const requestId = response.headers.get("x-request-id") || void 0;
2337
- throw parseAPIError(response.status, errorText, requestId);
2338
- }
2339
- const apiProfile = await response.json();
2340
- const profile = transformProfile(apiProfile);
2341
- return {
2342
- ...profile,
2343
- getState: () => getProfileState(id, config),
2344
- delete: () => deleteProfile(id, config)
2345
- };
2346
- }
2347
- async function updateProfile(id, config = {}) {
2348
- validateId(id, "id");
2349
- const profile = await fetchProfile(id, config);
2350
- const session = await startProfileSession(config, { profileId: profile.id });
2351
- return buildProfileSetup(profile, session, config);
2352
- }
2353
- async function deleteProfile(id, config = {}) {
2354
- validateId(id, "id");
2355
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2356
- const headers = buildHeaders(config);
2357
- const response = await fetchWithRetry(
2358
- `${apiUrl}/profiles/${encodeURIComponent(id)}`,
2359
- { method: "DELETE", headers },
2360
- config.retryConfig
2361
- );
2362
- if (!response.ok) {
2363
- const errorText = await response.text().catch(() => response.statusText);
2364
- const requestId = response.headers.get("x-request-id") || void 0;
2365
- throw parseAPIError(response.status, errorText, requestId);
2366
- }
2367
- }
2368
- async function startProfileSession(config = {}, input) {
2369
- if (!config.apiKey) {
2370
- throw new MorphAuthenticationError();
2371
- }
2372
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2373
- const headers = buildHeaders(config);
2374
- const body = input?.profileId ? { profile_id: input.profileId } : {};
2375
- const response = await fetchWithRetry(
2376
- `${apiUrl}/profiles/session/start`,
2377
- {
2378
- method: "POST",
2379
- headers,
2380
- body: JSON.stringify(body)
2381
- },
2382
- config.retryConfig
2383
- );
2384
- if (!response.ok) {
2385
- const errorText = await response.text().catch(() => response.statusText);
2386
- const requestId = response.headers.get("x-request-id") || void 0;
2387
- throw parseAPIError(response.status, errorText, requestId);
2388
- }
2389
- const apiSession = await response.json();
2390
- return transformSession(apiSession);
2391
- }
2392
- async function saveProfileSession(input, config = {}) {
2393
- validateId(input.sessionId, "sessionId");
2394
- validateId(input.profileId, "profileId");
2395
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2396
- const headers = buildHeaders(config);
2397
- const response = await fetchWithRetry(
2398
- `${apiUrl}/profiles/session/save`,
2399
- {
2400
- method: "POST",
2401
- headers,
2402
- body: JSON.stringify(transformSaveInput(input))
2403
- },
2404
- config.retryConfig
2405
- );
2406
- if (!response.ok) {
2407
- const errorText = await response.text().catch(() => response.statusText);
2408
- const requestId = response.headers.get("x-request-id") || void 0;
2409
- throw parseAPIError(response.status, errorText, requestId);
2410
- }
2411
- const apiProfile = await response.json();
2412
- return transformProfile(apiProfile);
2413
- }
2414
- async function listRepos(config = {}) {
2415
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2416
- const headers = buildHeaders(config);
2417
- const response = await fetchWithRetry(
2418
- `${apiUrl}/repos`,
2419
- { method: "GET", headers },
2420
- config.retryConfig
2421
- );
2422
- if (!response.ok) {
2423
- const errorText = await response.text().catch(() => response.statusText);
2424
- const requestId = response.headers.get("x-request-id") || void 0;
2425
- throw parseAPIError(response.status, errorText, requestId);
2426
- }
2427
- const data = await response.json();
2428
- const repos = Array.isArray(data?.repos) ? data.repos : [];
2429
- return repos.map((repo) => ({
2430
- repoId: repo.repo_id,
2431
- repoFullName: repo.repo_full_name,
2432
- profileCount: repo.profile_count ?? 0
2433
- }));
2434
- }
2435
- async function getProfileState(profileId, config = {}) {
2436
- validateId(profileId, "profileId");
2437
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2438
- const headers = buildHeaders(config);
2439
- const response = await fetchWithRetry(
2440
- `${apiUrl}/profiles/${encodeURIComponent(profileId)}/state`,
2441
- { method: "GET", headers },
2442
- config.retryConfig
2443
- );
2444
- if (!response.ok) {
2445
- const errorText = await response.text().catch(() => response.statusText);
2446
- const requestId = response.headers.get("x-request-id") || void 0;
2447
- throw parseAPIError(response.status, errorText, requestId);
2448
- }
2449
- const apiState = await response.json();
2450
- return transformStateResponse(apiState);
2451
- }
2452
- function buildHeaders(config) {
2453
- const headers = { "Content-Type": "application/json" };
2454
- if (config.apiKey) {
2455
- headers["Authorization"] = `Bearer ${config.apiKey}`;
2456
- }
2457
- return headers;
2458
- }
2459
- async function fetchProfile(id, config) {
2460
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2461
- const headers = buildHeaders(config);
2462
- const response = await fetchWithRetry(
2463
- `${apiUrl}/profiles/${encodeURIComponent(id)}`,
2464
- { method: "GET", headers },
2465
- config.retryConfig
2466
- );
2467
- if (!response.ok) {
2468
- const errorText = await response.text().catch(() => response.statusText);
2469
- const requestId = response.headers.get("x-request-id") || void 0;
2470
- throw parseAPIError(response.status, errorText, requestId);
2471
- }
2472
- const apiProfile = await response.json();
2473
- return transformProfile(apiProfile);
2474
- }
2475
- function buildProfileSetup(profile, session, config) {
2476
- return {
2477
- profile,
2478
- session,
2479
- save: () => saveProfileSession({ sessionId: session.sessionId, profileId: profile.id }, config)
2480
- };
2481
- }
2482
-
2483
- // tools/browser/core.ts
2484
- var DEFAULT_CONFIG2 = {
2485
- apiUrl: process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com",
2486
- timeout: 1e6,
2487
- // 10 minutes for complex tasks
2488
- debug: false
2489
- };
2490
- var BrowserClient = class extends APIResource {
2491
- config;
2492
- /**
2493
- * Profile management - create and manage browser profiles for storing login state.
2494
- */
2495
- profiles;
2496
- constructor(clientOrConfig = {}) {
2497
- const isClient = clientOrConfig instanceof MorphAPIClient;
2498
- super(
2499
- isClient ? clientOrConfig : new MorphAPIClient({
2500
- apiKey: clientOrConfig.apiKey,
2501
- browserURL: clientOrConfig.apiUrl,
2502
- timeout: clientOrConfig.timeout,
2503
- retryConfig: clientOrConfig.retryConfig,
2504
- debug: clientOrConfig.debug
2505
- })
2506
- );
2507
- this.config = isClient ? {
2508
- ...DEFAULT_CONFIG2,
2509
- apiUrl: clientOrConfig.browserURL,
2510
- apiKey: clientOrConfig.resolveApiKey(),
2511
- retryConfig: clientOrConfig.retryConfig,
2512
- debug: clientOrConfig.debug
2513
- } : { ...DEFAULT_CONFIG2, ...clientOrConfig };
2514
- this.profiles = new ProfilesClient(this.config);
2515
- }
2516
- /**
2517
- * Execute a browser automation task
2518
- */
2519
- async execute(input) {
2520
- return executeBrowserTask(input, this.config);
2521
- }
2522
- async createTask(input) {
2523
- const apiUrl = this.config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2524
- const debug = this.config.debug || false;
2525
- const hasTask = typeof input.task === "string" && input.task.trim().length > 0;
2526
- const hasDiff = typeof input.diff === "string" && input.diff.trim().length > 0;
2527
- if (!hasTask && !hasDiff) {
2528
- throw new Error('Browser task requires either "task" (natural language) or "diff" (PR-review planning)');
2529
- }
2530
- logger.debug("Browser", "create_task", { task: (input.task ?? "").slice(0, 100), url: input.url, endpoint: `${apiUrl}/browser-task/async` });
2531
- const headers = { "Content-Type": "application/json" };
2532
- if (this.config.apiKey) headers["Authorization"] = `Bearer ${this.config.apiKey}`;
2533
- const response = await fetch(`${apiUrl}/browser-task/async`, {
2534
- method: "POST",
2535
- headers,
2536
- body: JSON.stringify({
2537
- task: input.task,
2538
- diff: input.diff,
2539
- url: input.url,
2540
- max_steps: input.maxSteps ?? 10,
2541
- model: input.model ?? "morph-computer-use-v0",
2542
- viewport_width: input.viewportWidth ?? 1280,
2543
- viewport_height: input.viewportHeight ?? 720,
2544
- external_id: input.externalId,
2545
- repo_id: input.repoId,
2546
- repo_full_name: input.repoFullName,
2547
- commit_id: input.commitId,
2548
- record_video: input.recordVideo ?? false,
2549
- video_width: input.videoWidth ?? input.viewportWidth ?? 1280,
2550
- video_height: input.videoHeight ?? input.viewportHeight ?? 720,
2551
- allow_resizing: input.allowResizing ?? false,
2552
- structured_output: "schema" in input ? stringifyStructuredOutput(input.schema) : void 0,
2553
- auth: input.auth,
2554
- profile_id: input.profileId,
2555
- force_query_params: input.forceQueryParams
2556
- })
2557
- });
2558
- if (!response.ok) {
2559
- const errorText = await response.text().catch(() => response.statusText);
2560
- logger.error("Browser", "create_task_error", { status: response.status, error: errorText });
2561
- throw new Error(`HTTP ${response.status}: ${errorText}`);
2562
- }
2563
- const result = mapTaskResult(await response.json());
2564
- logger.debug("Browser", "task_created", { recording_id: result.recordingId, task_id: result.taskId, debug_url: !!result.debugUrl });
2565
- if ("schema" in input) {
2566
- return wrapTaskResponseWithSchema(result, this.config, input.schema);
2567
- } else {
2568
- return wrapTaskResponse(result, this.config);
2569
- }
2570
- }
2571
- /**
2572
- * Execute task with recording and wait for video to be ready
2573
- */
2574
- async executeWithRecording(input) {
2575
- return executeWithRecording(input, this.config);
2576
- }
2577
- /**
2578
- * Get recording status and URLs
2579
- */
2580
- async getRecording(recordingId) {
2581
- return getRecording(recordingId, this.config);
2582
- }
2583
- /**
2584
- * Wait for recording to complete with automatic polling
2585
- */
2586
- async waitForRecording(recordingId, options) {
2587
- return waitForRecording(recordingId, this.config, options);
2588
- }
2589
- /**
2590
- * Get errors from recording with screenshots
2591
- */
2592
- async getErrors(recordingId) {
2593
- return getErrors(recordingId, this.config);
2594
- }
2595
- /**
2596
- * Get animated WebP preview of recording
2597
- */
2598
- async getWebp(recordingId, options) {
2599
- return getWebp(recordingId, this.config, options);
2600
- }
2601
- /**
2602
- * Check if browser worker service is healthy
2603
- */
2604
- async checkHealth() {
2605
- return checkHealth(this.config);
2606
- }
2607
- };
2608
- async function executeBrowserTask(input, config = {}) {
2609
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2610
- const timeout = config.timeout || DEFAULT_CONFIG2.timeout;
2611
- const debug = config.debug || false;
2612
- if (!input.task || input.task.trim().length === 0) {
2613
- return {
2614
- success: false,
2615
- error: 'Task description is required. Example: "Go to example.com and click the login button"'
2616
- };
2617
- }
2618
- if (input.maxSteps !== void 0 && (input.maxSteps < 1 || input.maxSteps > 50)) {
2619
- return {
2620
- success: false,
2621
- error: "maxSteps must be between 1 and 50. Use more steps for complex multi-page flows."
2622
- };
2623
- }
2624
- logger.debug("Browser", "execute_start", { task: input.task.slice(0, 100), url: input.url, max_steps: input.maxSteps ?? 10, record_video: input.recordVideo ?? false });
2625
- const startTime = Date.now();
2626
- try {
2627
- const headers = { "Content-Type": "application/json" };
2628
- if (config.apiKey) headers["Authorization"] = `Bearer ${config.apiKey}`;
2629
- const fetchPromise = fetchWithRetry(
2630
- `${apiUrl}/browser-task`,
2631
- {
2632
- method: "POST",
2633
- headers,
2634
- body: JSON.stringify({
2635
- task: input.task,
2636
- url: input.url,
2637
- max_steps: input.maxSteps ?? 10,
2638
- model: input.model ?? "morph-computer-use-v0",
2639
- viewport_width: input.viewportWidth ?? 1280,
2640
- viewport_height: input.viewportHeight ?? 720,
2641
- external_id: input.externalId,
2642
- repo_id: input.repoId,
2643
- commit_id: input.commitId,
2644
- record_video: input.recordVideo ?? false,
2645
- video_width: input.videoWidth ?? input.viewportWidth ?? 1280,
2646
- video_height: input.videoHeight ?? input.viewportHeight ?? 720,
2647
- allow_resizing: input.allowResizing ?? false,
2648
- structured_output: input.structuredOutput,
2649
- auth: input.auth,
2650
- profile_id: input.profileId,
2651
- force_query_params: input.forceQueryParams
2652
- })
2653
- },
2654
- config.retryConfig
2655
- );
2656
- const response = await withTimeout(
2657
- fetchPromise,
2658
- timeout,
2659
- `Browser task timed out after ${timeout}ms. Consider increasing timeout or reducing maxSteps.`
2660
- );
2661
- if (!response.ok) {
2662
- const errorText = await response.text().catch(() => response.statusText);
2663
- logger.error("Browser", "execute_error", { status: response.status, error: errorText });
2664
- throw new Error(`HTTP ${response.status}: ${errorText}`);
2665
- }
2666
- const result = mapTaskResult(await response.json());
2667
- const elapsed = Date.now() - startTime;
2668
- logger.debug("Browser", "execute_complete", { success: result.success, latency_ms: elapsed, steps: result.stepsTaken ?? 0, recording_id: result.recordingId });
2669
- return result;
2670
- } catch (error) {
2671
- if (error instanceof Error) {
2672
- if (error.message.includes("ECONNREFUSED") || error.message.includes("fetch failed")) {
2673
- return {
2674
- success: false,
2675
- error: `Cannot connect to browser worker at ${apiUrl}. Ensure the service is running and accessible. For local dev, set MORPH_ENVIRONMENT=DEV.`
2676
- };
2677
- }
2678
- return {
2679
- success: false,
2680
- error: error.message
2681
- };
2682
- }
2683
- return {
2684
- success: false,
2685
- error: String(error)
2686
- };
2687
- }
2688
- }
2689
- async function getRecording(recordingId, config = {}) {
2690
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2691
- const debug = config.debug || false;
2692
- if (!config.apiKey) {
2693
- throw new Error("API key required for getRecording");
2694
- }
2695
- if (debug) console.log(`[Browser] getRecording: ${recordingId}`);
2696
- const response = await fetch(`${apiUrl}/recordings/${recordingId}`, {
2697
- method: "GET",
2698
- headers: { "Authorization": `Bearer ${config.apiKey}` }
2699
- });
2700
- if (!response.ok) {
2701
- const errorText = await response.text().catch(() => response.statusText);
2702
- if (debug) console.error(`[Browser] getRecording error: ${response.status} - ${errorText}`);
2703
- throw new Error(`HTTP ${response.status}: ${errorText}`);
2704
- }
2705
- const data = mapRecordingStatus(await response.json());
2706
- if (debug) console.log(`[Browser] Recording status: ${data.status}`);
2707
- return {
2708
- ...data,
2709
- getWebp: (options) => getWebp(recordingId, config, options),
2710
- getErrors: () => getErrors(recordingId, config)
2711
- };
2712
- }
2713
- async function waitForRecording(recordingId, config = {}, options = {}) {
2714
- const timeout = options.timeout ?? 6e4;
2715
- const pollInterval = options.pollInterval ?? 2e3;
2716
- const startTime = Date.now();
2717
- while (Date.now() - startTime < timeout) {
2718
- const status = await getRecording(recordingId, config);
2719
- if (status.status === "COMPLETED" || status.status === "ERROR") {
2720
- return status;
2721
- }
2722
- await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
2723
- }
2724
- throw new Error(`Recording timeout after ${timeout}ms - status still pending`);
2725
- }
2726
- async function executeWithRecording(input, config = {}) {
2727
- const taskResult = await executeBrowserTask(input, config);
2728
- if (taskResult.recordingId) {
2729
- try {
2730
- const recording = await waitForRecording(
2731
- taskResult.recordingId,
2732
- config,
2733
- { timeout: 6e4, pollInterval: 2e3 }
2734
- );
2735
- return {
2736
- ...taskResult,
2737
- recording
2738
- };
2739
- } catch (error) {
2740
- const errorRecording = {
2741
- id: taskResult.recordingId,
2742
- status: "ERROR",
2743
- error: error instanceof Error ? error.message : String(error),
2744
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2745
- getWebp: (options) => getWebp(taskResult.recordingId, config, options),
2746
- getErrors: () => getErrors(taskResult.recordingId, config)
2747
- };
2748
- return {
2749
- ...taskResult,
2750
- recording: errorRecording
2751
- };
2752
- }
2753
- }
2754
- return taskResult;
2755
- }
2756
- async function getErrors(recordingId, config = {}) {
2757
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2758
- const debug = config.debug || false;
2759
- if (!config.apiKey) {
2760
- throw new Error("API key required for getErrors");
2761
- }
2762
- if (debug) console.log(`[Browser] getErrors: ${recordingId}`);
2763
- const response = await fetch(`${apiUrl}/recordings/${recordingId}/errors`, {
2764
- method: "GET",
2765
- headers: { "Authorization": `Bearer ${config.apiKey}` }
2766
- });
2767
- if (!response.ok) {
2768
- const errorText = await response.text().catch(() => response.statusText);
2769
- if (debug) console.error(`[Browser] getErrors error: ${response.status} - ${errorText}`);
2770
- throw new Error(`HTTP ${response.status}: ${errorText}`);
2771
- }
2772
- const errors = mapErrorsResponse(await response.json());
2773
- if (debug) console.log(`[Browser] Found ${errors.totalErrors} errors`);
2774
- return errors;
2775
- }
2776
- function stringifyStructuredOutput(schema) {
2777
- try {
2778
- return JSON.stringify({
2779
- type: "object",
2780
- description: "Zod schema definition (Zod v3)",
2781
- zodDef: schema._def
2782
- });
2783
- } catch (error) {
2784
- console.warn("[Browser] Failed to serialize Zod schema:", error);
2785
- return JSON.stringify({
2786
- type: "object",
2787
- description: "Schema serialization failed"
2788
- });
2789
- }
2790
- }
2791
- function parseStructuredTaskOutput(result, schema) {
2792
- if (!result.output) {
2793
- return { ...result, parsed: null };
2794
- }
2795
- try {
2796
- const parsed = JSON.parse(result.output);
2797
- const validated = schema.parse(parsed);
2798
- return { ...result, parsed: validated };
2799
- } catch (error) {
2800
- if (error instanceof SyntaxError) {
2801
- return { ...result, parsed: null };
2802
- }
2803
- throw error;
2804
- }
2805
- }
2806
- function mapTaskResult(api) {
2807
- if (!api || typeof api !== "object") {
2808
- return api;
2809
- }
2810
- return {
2811
- success: api.success,
2812
- result: api.result,
2813
- error: api.error,
2814
- stepsTaken: api.steps_taken,
2815
- executionTimeMs: api.execution_time_ms,
2816
- urls: api.urls,
2817
- actionNames: api.action_names,
2818
- errors: api.errors,
2819
- modelActions: api.model_actions,
2820
- isDone: api.is_done,
2821
- actionHistory: api.action_history,
2822
- actionResults: api.action_results,
2823
- hasErrors: api.has_errors,
2824
- numberOfSteps: api.number_of_steps,
2825
- judgement: api.judgement,
2826
- isValidated: api.is_validated,
2827
- replayId: api.replay_id,
2828
- replayUrl: api.replay_url,
2829
- recordingId: api.recording_id,
2830
- recordingStatus: api.recording_status,
2831
- taskId: api.task_id,
2832
- status: api.status,
2833
- output: api.output,
2834
- debugUrl: api.debug_url
2835
- };
2836
- }
2837
- function mapRecordingStatus(api) {
2838
- return {
2839
- id: api.id,
2840
- status: api.status,
2841
- replayUrl: api.replay_url,
2842
- networkUrl: api.network_url,
2843
- consoleUrl: api.console_url,
2844
- videoUrl: api.video_url,
2845
- result: api.result,
2846
- totalEvents: api.total_events,
2847
- fileSize: api.file_size,
2848
- duration: api.duration,
2849
- error: api.error,
2850
- createdAt: api.created_at
2851
- };
2852
- }
2853
- function mapBrowserError(api) {
2854
- return {
2855
- type: api.type,
2856
- message: api.message,
2857
- url: api.url,
2858
- timestamp: api.timestamp,
2859
- screenshotUrl: api.screenshot_url,
2860
- capturedAt: api.captured_at,
2861
- status: api.status
2862
- };
2863
- }
2864
- function mapErrorsResponse(api) {
2865
- return {
2866
- recordingId: api.recording_id,
2867
- totalErrors: api.total_errors,
2868
- errors: Array.isArray(api.errors) ? api.errors.map(mapBrowserError) : []
2869
- };
2870
- }
2871
- function mapWebpResponse(api) {
2872
- return {
2873
- webpUrl: api.webp_url,
2874
- cached: api.cached,
2875
- width: api.width,
2876
- fps: api.fps,
2877
- maxDuration: api.max_duration,
2878
- fileSize: api.file_size,
2879
- maxSizeMb: api.max_size_mb,
2880
- budgetMet: api.budget_met,
2881
- qualityUsed: api.quality_used,
2882
- attempts: api.attempts
2883
- };
2884
- }
2885
- async function getTaskStatus(taskId, config) {
2886
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2887
- const debug = config.debug || false;
2888
- if (debug) console.log(`[Browser] getTaskStatus: ${taskId}`);
2889
- const headers = {};
2890
- if (config.apiKey) headers["Authorization"] = `Bearer ${config.apiKey}`;
2891
- const response = await fetch(`${apiUrl}/tasks/${taskId}`, {
2892
- method: "GET",
2893
- headers
2894
- });
2895
- if (!response.ok) {
2896
- const errorText = await response.text().catch(() => response.statusText);
2897
- if (debug) console.error(`[Browser] getTaskStatus error: ${response.status} - ${errorText}`);
2898
- throw new Error(`HTTP ${response.status}: ${errorText}`);
2899
- }
2900
- const result = mapTaskResult(await response.json());
2901
- if (debug) console.log(`[Browser] Task status: ${result.status}`);
2902
- return result;
2903
- }
2904
- function generateLiveUrl(taskId, config) {
2905
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2906
- const baseUrl = apiUrl.replace("/api", "");
2907
- return `${baseUrl}/tasks/${taskId}/live`;
2908
- }
2909
- async function pollTaskUntilComplete(taskId, config, pollConfig = {}) {
2910
- const interval = pollConfig.interval ?? 2e3;
2911
- const timeout = pollConfig.timeout ?? 3e5;
2912
- const startTime = Date.now();
2913
- while (Date.now() - startTime < timeout) {
2914
- const status = await getTaskStatus(taskId, config);
2915
- if (status.status === "completed" || status.status === "failed") {
2916
- return status;
2917
- }
2918
- await new Promise((resolve2) => setTimeout(resolve2, interval));
2919
- }
2920
- throw new Error(`Task polling timeout after ${timeout}ms`);
2921
- }
2922
- function wrapTaskResponse(result, config) {
2923
- const debugUrl = result.debugUrl ?? "";
2924
- const wrapped = {
2925
- ...result,
2926
- debugUrl,
2927
- taskId: result.taskId || "",
2928
- liveUrl: result.taskId ? generateLiveUrl(result.taskId, config) : debugUrl,
2929
- complete: async (pollConfig) => {
2930
- if (result.taskId) {
2931
- return pollTaskUntilComplete(result.taskId, config, pollConfig);
2932
- }
2933
- if (result.recordingId) {
2934
- const recording = await waitForRecording(
2935
- result.recordingId,
2936
- config,
2937
- pollConfig
2938
- );
2939
- return {
2940
- ...result,
2941
- recordingStatus: recording.status
2942
- };
2943
- }
2944
- throw new Error("Cannot poll completion: no taskId or recordingId available");
2945
- },
2946
- // Add Steel live session helpers - either functional or error-throwing
2947
- getLiveUrl: debugUrl ? (options) => buildLiveUrl(debugUrl, options) : () => {
2948
- throw new Error(
2949
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
2950
- );
2951
- },
2952
- getLiveIframe: debugUrl ? (optionsOrPreset) => {
2953
- const options = resolvePreset(optionsOrPreset);
2954
- return buildLiveIframe(debugUrl, options);
2955
- } : () => {
2956
- throw new Error(
2957
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
2958
- );
2959
- },
2960
- getEmbedCode: debugUrl ? () => buildEmbedCode(debugUrl) : () => {
2961
- throw new Error(
2962
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
2963
- );
2964
- }
2965
- };
2966
- return wrapped;
2967
- }
2968
- function wrapTaskResponseWithSchema(result, config, schema) {
2969
- const debugUrl = result.debugUrl ?? "";
2970
- const parsed = result.output ? parseStructuredTaskOutput(result, schema) : { ...result, parsed: null };
2971
- const wrapped = {
2972
- ...parsed,
2973
- debugUrl,
2974
- taskId: result.taskId || "",
2975
- liveUrl: result.taskId ? generateLiveUrl(result.taskId, config) : debugUrl,
2976
- complete: async (pollConfig) => {
2977
- if (result.taskId) {
2978
- const finalResult = await pollTaskUntilComplete(result.taskId, config, pollConfig);
2979
- return parseStructuredTaskOutput(finalResult, schema);
2980
- }
2981
- if (result.recordingId) {
2982
- const recording = await waitForRecording(
2983
- result.recordingId,
2984
- config,
2985
- pollConfig
2986
- );
2987
- return {
2988
- ...parsed,
2989
- recordingStatus: recording.status
2990
- };
1619
+ const { callMorphAPI: callMorphAPI2, generateUdiff: generateUdiff2, countChanges: countChanges2 } = await Promise.resolve().then(() => (init_apply(), apply_exports));
1620
+ let originalCode = "";
1621
+ let fileExists = true;
1622
+ try {
1623
+ originalCode = await readFile(fullPath, "utf-8");
1624
+ logger.debug("FastApply", "file_read", { path: fullPath, exists: true, size_bytes: originalCode.length });
1625
+ } catch (error) {
1626
+ if (error.code !== "ENOENT") {
1627
+ throw error;
2991
1628
  }
2992
- throw new Error("Cannot poll completion: no taskId or recordingId available");
2993
- },
2994
- // Add Steel live session helpers - either functional or error-throwing
2995
- getLiveUrl: debugUrl ? (options) => buildLiveUrl(debugUrl, options) : () => {
2996
- throw new Error(
2997
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions. "
2998
- );
2999
- },
3000
- getLiveIframe: debugUrl ? (optionsOrPreset) => {
3001
- const options = resolvePreset(optionsOrPreset);
3002
- return buildLiveIframe(debugUrl, options);
3003
- } : () => {
3004
- throw new Error(
3005
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions."
3006
- );
3007
- },
3008
- getEmbedCode: debugUrl ? () => buildEmbedCode(debugUrl) : () => {
3009
- throw new Error(
3010
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions."
3011
- );
1629
+ fileExists = false;
1630
+ logger.debug("FastApply", "file_read", { path: fullPath, exists: false });
3012
1631
  }
3013
- };
3014
- return wrapped;
3015
- }
3016
- async function getWebp(recordingId, config = {}, options = {}) {
3017
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
3018
- const debug = config.debug || false;
3019
- if (!config.apiKey) {
3020
- throw new Error("API key required for getWebp");
3021
- }
3022
- const params = new URLSearchParams();
3023
- if (options.maxDuration !== void 0) params.set("max_duration", String(options.maxDuration));
3024
- if (options.fps !== void 0) params.set("fps", String(options.fps));
3025
- if (options.width !== void 0) params.set("width", String(options.width));
3026
- if (options.quality !== void 0) params.set("quality", String(options.quality));
3027
- if (options.maxSizeMb !== void 0) params.set("max_size_mb", String(options.maxSizeMb));
3028
- const url = `${apiUrl}/recordings/${recordingId}/webp${params.toString() ? "?" + params.toString() : ""}`;
3029
- if (debug) console.log(`[Browser] getWebp: ${url}`);
3030
- const response = await fetch(url, {
3031
- method: "GET",
3032
- headers: { "Authorization": `Bearer ${config.apiKey}` }
3033
- });
3034
- if (!response.ok) {
3035
- const errorText = await response.text().catch(() => response.statusText);
3036
- if (debug) console.error(`[Browser] getWebp error: ${response.status} - ${errorText}`);
3037
- throw new Error(`HTTP ${response.status}: ${errorText}`);
3038
- }
3039
- const result = mapWebpResponse(await response.json());
3040
- if (debug) console.log(`[Browser] WebP ready: ${result.webpUrl} (cached: ${result.cached})`);
3041
- return result;
3042
- }
3043
- async function checkHealth(config = {}) {
3044
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
3045
- try {
3046
- const response = await fetch(`${apiUrl}/health`, {
3047
- method: "GET",
3048
- headers: config.apiKey ? { "Authorization": `Bearer ${config.apiKey}` } : {}
3049
- });
3050
- if (!response.ok) {
3051
- throw new Error(`HTTP ${response.status}`);
1632
+ const instruction = input.instruction ?? input.instructions ?? "";
1633
+ logger.debug("FastApply", "api_call", { instruction_len: instruction.length, code_edit_len: input.code_edit.length, original_len: originalCode.length });
1634
+ const { content: mergedCode, completionId } = await callMorphAPI2(originalCode, input.code_edit, instruction, input.target_filepath, config);
1635
+ logger.debug("FastApply", "api_response", { completion_id: completionId, merged_len: mergedCode.length });
1636
+ const udiff = config.generateUdiff !== false ? generateUdiff2(originalCode, mergedCode, input.target_filepath) : void 0;
1637
+ if (config.autoWrite !== false) {
1638
+ await writeFile(fullPath, mergedCode, "utf-8");
1639
+ logger.debug("FastApply", "file_write", { path: fullPath, size_bytes: mergedCode.length });
3052
1640
  }
3053
- const data = await response.json();
1641
+ const changes = countChanges2(originalCode, mergedCode);
1642
+ logger.debug("FastApply", "changes", { added: changes.linesAdded, removed: changes.linesRemoved, modified: changes.linesModified });
3054
1643
  return {
3055
- ok: true,
3056
- google_configured: data.google_configured ?? false,
3057
- database_configured: data.database_configured ?? false,
3058
- s3_configured: data.s3_configured ?? false
1644
+ success: true,
1645
+ filepath: input.target_filepath,
1646
+ udiff,
1647
+ changes,
1648
+ completionId
3059
1649
  };
3060
1650
  } catch (error) {
1651
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
1652
+ const structuredError = error instanceof FastApplyContextLengthError || error instanceof FastApplyAnchorIntegrityError ? error : void 0;
1653
+ logger.error("FastApply", "execute_error", { error: errorMessage, target_filepath: input.target_filepath, stack: error instanceof Error ? error.stack : void 0 });
3061
1654
  return {
3062
- ok: false,
3063
- google_configured: false,
3064
- database_configured: false,
3065
- s3_configured: false,
3066
- error: error instanceof Error ? error.message : String(error)
1655
+ success: false,
1656
+ filepath: input.target_filepath,
1657
+ changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },
1658
+ error: errorMessage,
1659
+ errorCode: structuredError?.code,
1660
+ completionId: structuredError?.completionId
3067
1661
  };
3068
1662
  }
3069
1663
  }
@@ -3377,7 +1971,7 @@ var import_openai2 = __toESM(require("openai"), 1);
3377
1971
  init_version();
3378
1972
  var import_path4 = __toESM(require("path"), 1);
3379
1973
  init_logger();
3380
- var DEFAULT_API_URL3 = "https://api.morphllm.com";
1974
+ var DEFAULT_API_URL2 = "https://api.morphllm.com";
3381
1975
  var TOOL_SPECS = [
3382
1976
  {
3383
1977
  type: "function",
@@ -3486,7 +2080,7 @@ var TOOL_SPECS = [
3486
2080
  }
3487
2081
  ];
3488
2082
  async function callModel(messages, model, options = {}) {
3489
- const baseUrl = options.morphApiUrl || DEFAULT_API_URL3;
2083
+ const baseUrl = options.morphApiUrl || DEFAULT_API_URL2;
3490
2084
  const apiKey = options.morphApiKey || process.env.MORPH_API_KEY || "";
3491
2085
  const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
3492
2086
  const parsedUrl = new URL(baseUrl);
@@ -4040,14 +2634,14 @@ function parseGitHubUrl(input) {
4040
2634
  }
4041
2635
 
4042
2636
  // tools/compact/core.ts
4043
- var DEFAULT_API_URL4 = "https://api.morphllm.com";
4044
- var DEFAULT_TIMEOUT4 = 12e4;
2637
+ var DEFAULT_API_URL3 = "https://api.morphllm.com";
2638
+ var DEFAULT_TIMEOUT3 = 12e4;
4045
2639
  function resolveClient(clientOrConfig) {
4046
2640
  if (clientOrConfig instanceof MorphAPIClient) return clientOrConfig;
4047
2641
  return new MorphAPIClient({
4048
2642
  apiKey: clientOrConfig.morphApiKey,
4049
- baseURL: clientOrConfig.morphApiUrl ?? DEFAULT_API_URL4,
4050
- timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT4,
2643
+ baseURL: clientOrConfig.morphApiUrl ?? DEFAULT_API_URL3,
2644
+ timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT3,
4051
2645
  retryConfig: clientOrConfig.retryConfig,
4052
2646
  debug: clientOrConfig.debug
4053
2647
  });
@@ -4060,7 +2654,7 @@ var CompactClient = class extends APIResource {
4060
2654
  const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;
4061
2655
  this.config = {
4062
2656
  morphApiUrl: this._client.baseURL,
4063
- timeout: cfg.timeout ?? DEFAULT_TIMEOUT4,
2657
+ timeout: cfg.timeout ?? DEFAULT_TIMEOUT3,
4064
2658
  debug: cfg.debug ?? false
4065
2659
  };
4066
2660
  }
@@ -4427,357 +3021,16 @@ function formatResult(result) {
4427
3021
  return parts.join("\n");
4428
3022
  }
4429
3023
 
4430
- // tools/github/types.ts
4431
- var GitHubError = class extends Error {
4432
- /** HTTP status code */
4433
- status;
4434
- /** Error code from API */
4435
- code;
4436
- constructor(message, status, code) {
4437
- super(message);
4438
- this.name = "GitHubError";
4439
- this.status = status;
4440
- this.code = code;
4441
- }
4442
- };
4443
- var NoInstallationError = class extends GitHubError {
4444
- constructor(message = "No GitHub installation found. Connect GitHub at morphllm.com/dashboard/integrations/github") {
4445
- super(message, 404, "NO_INSTALLATION");
4446
- }
4447
- };
4448
- var NotFoundError = class extends GitHubError {
4449
- constructor(resource) {
4450
- super(`${resource} not found`, 404, "NOT_FOUND");
4451
- }
4452
- };
4453
- var PermissionError = class extends GitHubError {
4454
- constructor(message = "Insufficient permissions for this operation") {
4455
- super(message, 403, "PERMISSION_DENIED");
4456
- }
4457
- };
4458
-
4459
- // tools/github/core.ts
4460
- var DEFAULT_BASE_URL2 = "https://api.morphllm.com";
4461
- var DEFAULT_TIMEOUT5 = 3e4;
4462
- var GitHubClient = class extends APIResource {
4463
- timeout;
4464
- debug;
4465
- defaultInstallationId;
4466
- /** Installation operations */
4467
- installations;
4468
- /** Repository operations */
4469
- repos;
4470
- /** Project operations (monorepo sub-projects) */
4471
- projects;
4472
- /** Pull request operations */
4473
- pullRequests;
4474
- /** Deployment operations */
4475
- deployments;
4476
- /** Comment operations */
4477
- comments;
4478
- /** Check run operations */
4479
- checkRuns;
4480
- /**
4481
- * Get the GitHub App installation URL.
4482
- * Users visit this URL once to install the Morph GitHub App on their account/org.
4483
- */
4484
- getInstallUrl() {
4485
- return "https://github.com/apps/morph-subagents/installations/new";
4486
- }
4487
- constructor(clientOrConfig = {}, options = {}) {
4488
- const isClient = clientOrConfig instanceof MorphAPIClient;
4489
- const config = isClient ? {} : clientOrConfig;
4490
- super(
4491
- isClient ? clientOrConfig : new MorphAPIClient({
4492
- apiKey: config.apiKey,
4493
- baseURL: config.baseUrl ?? DEFAULT_BASE_URL2,
4494
- timeout: config.timeout ?? DEFAULT_TIMEOUT5,
4495
- debug: config.debug
4496
- })
4497
- );
4498
- this.timeout = config.timeout || DEFAULT_TIMEOUT5;
4499
- this.debug = config.debug || false;
4500
- this.defaultInstallationId = isClient ? options.installationId : config.installationId;
4501
- if (!this._client.resolveApiKey()) {
4502
- throw new Error("API key required. Set MORPH_API_KEY or pass apiKey in config.");
4503
- }
4504
- this.installations = {
4505
- list: this.listInstallations.bind(this),
4506
- get: this.getInstallation.bind(this),
4507
- update: this.updateInstallation.bind(this),
4508
- disconnect: this.disconnectInstallation.bind(this)
4509
- };
4510
- this.repos = {
4511
- list: this.listRepos.bind(this),
4512
- get: this.getRepo.bind(this),
4513
- update: this.updateRepo.bind(this),
4514
- remove: this.removeRepo.bind(this),
4515
- sync: this.syncRepos.bind(this)
4516
- };
4517
- this.projects = {
4518
- list: this.listProjects.bind(this),
4519
- create: this.createProject.bind(this),
4520
- update: this.updateProject.bind(this),
4521
- delete: this.deleteProject.bind(this)
4522
- };
4523
- this.pullRequests = {
4524
- list: this.listPullRequests.bind(this),
4525
- get: this.getPullRequest.bind(this)
4526
- };
4527
- this.deployments = {
4528
- list: this.listDeployments.bind(this)
4529
- };
4530
- this.comments = {
4531
- list: this.listComments.bind(this),
4532
- create: this.createComment.bind(this),
4533
- update: this.updateComment.bind(this),
4534
- delete: this.deleteComment.bind(this)
4535
- };
4536
- this.checkRuns = {
4537
- create: this.createCheckRun.bind(this),
4538
- update: this.updateCheckRun.bind(this)
4539
- };
4540
- }
4541
- /**
4542
- * Make an authenticated API request
4543
- */
4544
- async request(method, path6, body) {
4545
- if (this.debug) {
4546
- console.log(`[GitHub SDK] ${method} ${path6}`, body || "");
4547
- }
4548
- let response;
4549
- try {
4550
- response = await this._client.request(method, path6, {
4551
- body,
4552
- timeout: this.timeout,
4553
- raw: true
4554
- });
4555
- } catch (error) {
4556
- if (error instanceof Error && /timed out/i.test(error.message)) {
4557
- throw new GitHubError("Request timeout", 408, "TIMEOUT");
4558
- }
4559
- throw new GitHubError(error instanceof Error ? error.message : "Unknown error", 500, "UNKNOWN");
4560
- }
4561
- if (!response.ok) {
4562
- const errorData = await response.json().catch(() => ({}));
4563
- const message = errorData.error || errorData.detail || errorData.message || response.statusText;
4564
- if (this.debug) {
4565
- console.error(`[GitHub SDK] Error ${response.status}:`, message);
4566
- }
4567
- if (response.status === 404) {
4568
- if (message.includes("installation")) {
4569
- throw new NoInstallationError(message);
4570
- }
4571
- throw new NotFoundError(message);
4572
- }
4573
- if (response.status === 403) {
4574
- throw new PermissionError(message);
4575
- }
4576
- throw new GitHubError(message, response.status, errorData.code);
4577
- }
4578
- const data = await response.json();
4579
- if (this.debug) {
4580
- console.log(`[GitHub SDK] Response:`, JSON.stringify(data).slice(0, 200));
4581
- }
4582
- return data;
4583
- }
4584
- /**
4585
- * Get the installation ID to use for a request
4586
- */
4587
- getInstallationId(input) {
4588
- return input?.installationId || this.defaultInstallationId;
4589
- }
4590
- // ==========================================================================
4591
- // Installations
4592
- // ==========================================================================
4593
- async listInstallations() {
4594
- return this.request("GET", "/api/v1/github/installations");
4595
- }
4596
- async getInstallation(installationId) {
4597
- return this.request("GET", `/api/v1/github/installations/${installationId}`);
4598
- }
4599
- async updateInstallation(input) {
4600
- if (this.debug) console.log("[GitHub SDK] updateInstallation", input.installationId);
4601
- const { installationId, ...body } = input;
4602
- return this.request("PATCH", `/api/v1/github/installations/${installationId}`, body);
4603
- }
4604
- async disconnectInstallation(installationId) {
4605
- if (this.debug) console.log("[GitHub SDK] disconnectInstallation", installationId);
4606
- return this.request("DELETE", `/api/v1/github/installations/${installationId}`);
4607
- }
4608
- // ==========================================================================
4609
- // Repositories
4610
- // ==========================================================================
4611
- async listRepos(input) {
4612
- const installationId = input.installationId || this.defaultInstallationId;
4613
- if (!installationId) {
4614
- throw new NoInstallationError("installationId required. Call installations.list() first.");
4615
- }
4616
- return this.request("GET", `/api/v1/github/installations/${installationId}/repos`);
4617
- }
4618
- async getRepo(repoId) {
4619
- if (this.debug) console.log("[GitHub SDK] getRepo", repoId);
4620
- return this.request("GET", `/api/v1/github/repos/${repoId}`);
4621
- }
4622
- async updateRepo(input) {
4623
- if (this.debug) console.log("[GitHub SDK] updateRepo", input.repoId);
4624
- const { repoId, ...body } = input;
4625
- return this.request("PATCH", `/api/v1/github/repos/${repoId}`, body);
4626
- }
4627
- async removeRepo(repoId) {
4628
- if (this.debug) console.log("[GitHub SDK] removeRepo", repoId);
4629
- return this.request("DELETE", `/api/v1/github/repos/${repoId}`);
4630
- }
4631
- async syncRepos(input) {
4632
- const installationId = input.installationId || this.defaultInstallationId;
4633
- if (!installationId) {
4634
- throw new NoInstallationError("installationId required. Call installations.list() first.");
4635
- }
4636
- if (this.debug) console.log("[GitHub SDK] syncRepos", installationId);
4637
- return this.request("POST", `/api/v1/github/installations/${installationId}/repos/sync`);
4638
- }
4639
- // ==========================================================================
4640
- // Projects (monorepo sub-projects)
4641
- // ==========================================================================
4642
- async listProjects(input) {
4643
- if (this.debug) console.log("[GitHub SDK] listProjects", input.repoId);
4644
- return this.request("GET", `/api/v1/github/repos/${input.repoId}/projects`);
4645
- }
4646
- async createProject(input) {
4647
- if (this.debug) console.log("[GitHub SDK] createProject", input.repoId, input.name);
4648
- const { repoId, ...body } = input;
4649
- return this.request("POST", `/api/v1/github/repos/${repoId}/projects`, body);
4650
- }
4651
- async updateProject(input) {
4652
- if (this.debug) console.log("[GitHub SDK] updateProject", input.projectId);
4653
- const { projectId, ...body } = input;
4654
- return this.request("PATCH", `/api/v1/github/projects/${projectId}`, body);
4655
- }
4656
- async deleteProject(projectId) {
4657
- if (this.debug) console.log("[GitHub SDK] deleteProject", projectId);
4658
- return this.request("DELETE", `/api/v1/github/projects/${projectId}`);
4659
- }
4660
- // ==========================================================================
4661
- // Pull Requests
4662
- // ==========================================================================
4663
- async listPullRequests(input) {
4664
- const installationId = this.getInstallationId(input);
4665
- const params = new URLSearchParams({
4666
- owner: input.owner,
4667
- repo: input.repo,
4668
- ...input.state && { state: input.state },
4669
- ...installationId && { installationId }
4670
- });
4671
- return this.request("GET", `/api/v1/github/pulls?${params}`);
4672
- }
4673
- async getPullRequest(input) {
4674
- const installationId = this.getInstallationId(input);
4675
- const params = new URLSearchParams({
4676
- owner: input.owner,
4677
- repo: input.repo,
4678
- ...installationId && { installationId }
4679
- });
4680
- return this.request(
4681
- "GET",
4682
- `/api/v1/github/pulls/${input.number}?${params}`
4683
- );
4684
- }
4685
- // ==========================================================================
4686
- // Deployments
4687
- // ==========================================================================
4688
- async listDeployments(input) {
4689
- const installationId = this.getInstallationId(input);
4690
- const params = new URLSearchParams({
4691
- owner: input.owner,
4692
- repo: input.repo,
4693
- ...input.sha && { sha: input.sha },
4694
- ...input.environment && { environment: input.environment },
4695
- ...installationId && { installationId }
4696
- });
4697
- return this.request("GET", `/api/v1/github/deployments?${params}`);
4698
- }
4699
- // ==========================================================================
4700
- // Comments
4701
- // ==========================================================================
4702
- async listComments(input) {
4703
- const installationId = this.getInstallationId(input);
4704
- const params = new URLSearchParams({
4705
- owner: input.owner,
4706
- repo: input.repo,
4707
- pr: String(input.pr),
4708
- ...installationId && { installationId }
4709
- });
4710
- return this.request("GET", `/api/v1/github/comments?${params}`);
4711
- }
4712
- async createComment(input) {
4713
- const installationId = this.getInstallationId(input);
4714
- return this.request("POST", "/api/v1/github/comments", {
4715
- owner: input.owner,
4716
- repo: input.repo,
4717
- pr: input.pr,
4718
- body: input.body,
4719
- ...installationId && { installationId }
4720
- });
4721
- }
4722
- async updateComment(input) {
4723
- const installationId = this.getInstallationId(input);
4724
- return this.request("PATCH", `/api/v1/github/comments/${input.commentId}`, {
4725
- owner: input.owner,
4726
- repo: input.repo,
4727
- body: input.body,
4728
- ...installationId && { installationId }
4729
- });
4730
- }
4731
- async deleteComment(input) {
4732
- const installationId = this.getInstallationId(input);
4733
- const params = new URLSearchParams({
4734
- owner: input.owner,
4735
- repo: input.repo,
4736
- ...installationId && { installationId }
4737
- });
4738
- await this.request("DELETE", `/api/v1/github/comments/${input.commentId}?${params}`);
4739
- }
4740
- // ==========================================================================
4741
- // Check Runs
4742
- // ==========================================================================
4743
- async createCheckRun(input) {
4744
- const installationId = this.getInstallationId(input);
4745
- return this.request("POST", "/api/v1/github/check-runs", {
4746
- owner: input.owner,
4747
- repo: input.repo,
4748
- sha: input.sha,
4749
- name: input.name,
4750
- status: input.status,
4751
- ...input.title && { title: input.title },
4752
- ...input.summary && { summary: input.summary },
4753
- ...installationId && { installationId }
4754
- });
4755
- }
4756
- async updateCheckRun(input) {
4757
- const installationId = this.getInstallationId(input);
4758
- return this.request("PATCH", `/api/v1/github/check-runs/${input.checkRunId}`, {
4759
- owner: input.owner,
4760
- repo: input.repo,
4761
- ...input.status && { status: input.status },
4762
- ...input.conclusion && { conclusion: input.conclusion },
4763
- ...input.title && { title: input.title },
4764
- ...input.summary && { summary: input.summary },
4765
- ...input.text && { text: input.text },
4766
- ...installationId && { installationId }
4767
- });
4768
- }
4769
- };
4770
-
4771
3024
  // modelrouter/core.ts
4772
3025
  init_logger();
4773
- var DEFAULT_API_URL5 = "https://api.morphllm.com";
4774
- var DEFAULT_TIMEOUT6 = 5e3;
3026
+ var DEFAULT_API_URL4 = "https://api.morphllm.com";
3027
+ var DEFAULT_TIMEOUT4 = 5e3;
4775
3028
  function resolveClient2(clientOrConfig) {
4776
3029
  if (clientOrConfig instanceof MorphAPIClient) return clientOrConfig;
4777
3030
  return new MorphAPIClient({
4778
3031
  apiKey: clientOrConfig.apiKey,
4779
- baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL5,
4780
- timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT6,
3032
+ baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL4,
3033
+ timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT4,
4781
3034
  retryConfig: clientOrConfig.retryConfig,
4782
3035
  debug: clientOrConfig.debug
4783
3036
  });
@@ -4789,7 +3042,7 @@ var BaseRouter = class extends APIResource {
4789
3042
  super(resolveClient2(clientOrConfig));
4790
3043
  this.provider = provider;
4791
3044
  const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;
4792
- this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT6;
3045
+ this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT4;
4793
3046
  }
4794
3047
  /** Throw the historical "API key is required" message when no key is resolvable. */
4795
3048
  requireApiKey() {
@@ -4895,7 +3148,7 @@ var RouterClassifier = class extends APIResource {
4895
3148
  constructor(clientOrConfig = {}) {
4896
3149
  super(resolveClient2(clientOrConfig));
4897
3150
  const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;
4898
- this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT6;
3151
+ this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT4;
4899
3152
  }
4900
3153
  /** Classify an input across the requested axes (all three by default). */
4901
3154
  async classify(input) {
@@ -4953,7 +3206,7 @@ var TOOL_PARAMETERS = {
4953
3206
  required: ["search_term"]
4954
3207
  };
4955
3208
  function createWarpGrepTool(config) {
4956
- const tool5 = {
3209
+ const tool4 = {
4957
3210
  type: "function",
4958
3211
  function: {
4959
3212
  name: config.name ?? WARP_GREP_TOOL_NAME,
@@ -4961,7 +3214,7 @@ function createWarpGrepTool(config) {
4961
3214
  parameters: TOOL_PARAMETERS
4962
3215
  }
4963
3216
  };
4964
- return Object.assign(tool5, {
3217
+ return Object.assign(tool4, {
4965
3218
  execute: async (input) => {
4966
3219
  return executeToolCall(input, config);
4967
3220
  },
@@ -4972,7 +3225,7 @@ function createWarpGrepTool(config) {
4972
3225
  }
4973
3226
  function createGitHubSearchTool(config) {
4974
3227
  const client = new WarpGrepClient(config);
4975
- const tool5 = {
3228
+ const tool4 = {
4976
3229
  type: "function",
4977
3230
  function: {
4978
3231
  name: GITHUB_SEARCH_TOOL_NAME,
@@ -4980,7 +3233,7 @@ function createGitHubSearchTool(config) {
4980
3233
  parameters: GITHUB_SEARCH_INPUT_SCHEMA
4981
3234
  }
4982
3235
  };
4983
- return Object.assign(tool5, {
3236
+ return Object.assign(tool4, {
4984
3237
  execute: async (input) => {
4985
3238
  const github = input.github_url || input.owner_repo;
4986
3239
  if (!github) {
@@ -4994,107 +3247,6 @@ function createGitHubSearchTool(config) {
4994
3247
  });
4995
3248
  }
4996
3249
 
4997
- // tools/codebase_search/prompts.ts
4998
- var CODEBASE_SEARCH_DESCRIPTION = `Semantic search that finds code by meaning, not exact text.
4999
-
5000
- Use this to explore unfamiliar codebases or ask "how/where/what" questions:
5001
- - "How does X work?" - Find implementation details
5002
- - "Where is Y handled?" - Locate specific functionality
5003
- - "What happens when Z?" - Understand flow
5004
-
5005
- The tool uses two-stage retrieval (embedding similarity + reranking) to find the most semantically relevant code chunks.
5006
-
5007
- Returns code chunks with file paths, line ranges, and full content ranked by relevance.`;
5008
- var CODEBASE_SEARCH_SYSTEM_PROMPT = `You have access to the codebase_search tool that performs semantic code search.
5009
-
5010
- When searching:
5011
- - Use natural language queries describing what you're looking for
5012
- - Be specific about functionality, not variable names
5013
- - Use target_directories to narrow search if you know the area
5014
- - Results are ranked by relevance (rerank score is most important)
5015
-
5016
- The tool returns:
5017
- - File paths with symbol names (e.g. "src/auth.ts::AuthService@L1-L17")
5018
- - Line ranges for precise navigation
5019
- - Full code content for each match
5020
- - Dual relevance scores: embedding similarity + rerank score
5021
-
5022
- Use results to understand code or answer questions. The content is provided in full - avoid re-reading unless you need more context.`;
5023
-
5024
- // tools/codebase_search/openai.ts
5025
- function createCodebaseSearchTool(config) {
5026
- const toolDefinition = {
5027
- type: "function",
5028
- function: {
5029
- name: "codebase_search",
5030
- description: CODEBASE_SEARCH_DESCRIPTION,
5031
- parameters: {
5032
- type: "object",
5033
- properties: {
5034
- query: {
5035
- type: "string",
5036
- description: 'A complete question about what you want to understand. Ask as if talking to a colleague: "How does X work?", "What happens when Y?", "Where is Z handled?"'
5037
- },
5038
- target_directories: {
5039
- type: "array",
5040
- items: { type: "string" },
5041
- description: "Prefix directory paths to limit search scope (single directory only, no glob patterns). Use [] to search entire repo."
5042
- },
5043
- explanation: {
5044
- type: "string",
5045
- description: "One sentence explanation as to why this tool is being used, and how it contributes to the goal."
5046
- },
5047
- limit: {
5048
- type: "number",
5049
- description: "Maximum results to return (default: 10)"
5050
- }
5051
- },
5052
- required: ["query", "target_directories", "explanation"]
5053
- }
5054
- }
5055
- };
5056
- return Object.assign(toolDefinition, {
5057
- execute: async (input) => {
5058
- const parsedInput = typeof input === "string" ? JSON.parse(input) : input;
5059
- return executeCodebaseSearch(parsedInput, config);
5060
- },
5061
- formatResult: (result) => {
5062
- return formatResult2(result);
5063
- },
5064
- getSystemPrompt: () => {
5065
- return CODEBASE_SEARCH_SYSTEM_PROMPT;
5066
- }
5067
- });
5068
- }
5069
- function formatResult2(result) {
5070
- if (!result.success) {
5071
- return `Search failed: ${result.error}`;
5072
- }
5073
- if (result.results.length === 0) {
5074
- return "No matching code found. Try rephrasing your query or removing directory filters.";
5075
- }
5076
- const lines = [];
5077
- lines.push(`Found ${result.results.length} relevant code sections (${result.stats.searchTimeMs}ms):
5078
- `);
5079
- result.results.forEach((r, i) => {
5080
- const relevance = (r.rerankScore * 100).toFixed(1);
5081
- lines.push(`${i + 1}. ${r.filepath} (${relevance}% relevant)`);
5082
- lines.push(` Symbol: ${r.symbolPath}`);
5083
- lines.push(` Language: ${r.language}`);
5084
- lines.push(` Lines: ${r.startLine}-${r.endLine}`);
5085
- lines.push(` Code:`);
5086
- const codeLines = r.content.split("\n");
5087
- codeLines.slice(0, Math.min(codeLines.length, 20)).forEach((line) => {
5088
- lines.push(` ${line}`);
5089
- });
5090
- if (codeLines.length > 20) {
5091
- lines.push(` ... (${codeLines.length - 20} more lines)`);
5092
- }
5093
- lines.push("");
5094
- });
5095
- return lines.join("\n");
5096
- }
5097
-
5098
3250
  // tools/fastapply/prompts.ts
5099
3251
  var EDIT_FILE_TOOL_DESCRIPTION = `Use this tool to make an edit to an existing file.
5100
3252
 
@@ -5165,7 +3317,7 @@ async function execute(input, config) {
5165
3317
  function getSystemPrompt() {
5166
3318
  return EDIT_FILE_SYSTEM_PROMPT;
5167
3319
  }
5168
- function formatResult3(result) {
3320
+ function formatResult2(result) {
5169
3321
  if (!result.success) {
5170
3322
  return `Error editing file: ${result.error}`;
5171
3323
  }
@@ -5188,7 +3340,7 @@ function createEditFileTool(config = {}) {
5188
3340
  return execute(parsedInput, config);
5189
3341
  },
5190
3342
  formatResult: (result) => {
5191
- return formatResult3(result);
3343
+ return formatResult2(result);
5192
3344
  },
5193
3345
  getSystemPrompt: () => {
5194
3346
  return getSystemPrompt();
@@ -5213,18 +3365,6 @@ var OpenAIToolFactory = class {
5213
3365
  morphApiKey: this.config.apiKey
5214
3366
  });
5215
3367
  }
5216
- /**
5217
- * Create an OpenAI-compatible codebase search tool
5218
- *
5219
- * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
5220
- * @returns OpenAI ChatCompletionTool with execute and formatResult methods
5221
- */
5222
- createCodebaseSearchTool(toolConfig) {
5223
- return createCodebaseSearchTool({
5224
- ...toolConfig,
5225
- apiKey: this.config.apiKey
5226
- });
5227
- }
5228
3368
  /**
5229
3369
  * Create an OpenAI-compatible edit file tool
5230
3370
  *
@@ -5260,12 +3400,12 @@ var INPUT_SCHEMA = {
5260
3400
  required: ["search_term"]
5261
3401
  };
5262
3402
  function createWarpGrepTool2(config) {
5263
- const tool5 = {
3403
+ const tool4 = {
5264
3404
  name: config.name ?? WARP_GREP_TOOL_NAME,
5265
3405
  description: config.description ?? WARP_GREP_DESCRIPTION,
5266
3406
  input_schema: INPUT_SCHEMA
5267
3407
  };
5268
- return Object.assign(tool5, {
3408
+ return Object.assign(tool4, {
5269
3409
  execute: async (input) => {
5270
3410
  return executeToolCall(input, config);
5271
3411
  },
@@ -5276,12 +3416,12 @@ function createWarpGrepTool2(config) {
5276
3416
  }
5277
3417
  function createGitHubSearchTool2(config) {
5278
3418
  const client = new WarpGrepClient(config);
5279
- const tool5 = {
3419
+ const tool4 = {
5280
3420
  name: GITHUB_SEARCH_TOOL_NAME,
5281
3421
  description: GITHUB_SEARCH_DESCRIPTION,
5282
3422
  input_schema: GITHUB_SEARCH_INPUT_SCHEMA
5283
3423
  };
5284
- return Object.assign(tool5, {
3424
+ return Object.assign(tool4, {
5285
3425
  execute: async (input) => {
5286
3426
  const github = input.github_url || input.owner_repo;
5287
3427
  if (!github) {
@@ -5295,77 +3435,6 @@ function createGitHubSearchTool2(config) {
5295
3435
  });
5296
3436
  }
5297
3437
 
5298
- // tools/codebase_search/anthropic.ts
5299
- function createCodebaseSearchTool2(config) {
5300
- const toolDefinition = {
5301
- name: "codebase_search",
5302
- description: CODEBASE_SEARCH_DESCRIPTION,
5303
- input_schema: {
5304
- type: "object",
5305
- properties: {
5306
- explanation: {
5307
- type: "string",
5308
- description: "One sentence explanation as to why this tool is being used, and how it contributes to the goal."
5309
- },
5310
- query: {
5311
- type: "string",
5312
- description: 'A complete question about what you want to understand. Ask as if talking to a colleague: "How does X work?", "What happens when Y?", "Where is Z handled?"'
5313
- },
5314
- target_directories: {
5315
- type: "array",
5316
- items: { type: "string" },
5317
- description: "Prefix directory paths to limit search scope (single directory only, no glob patterns). Use [] to search entire repo."
5318
- },
5319
- limit: {
5320
- type: "number",
5321
- description: "Maximum results to return (default: 10)"
5322
- }
5323
- },
5324
- required: ["query", "target_directories", "explanation"]
5325
- },
5326
- cache_control: { type: "ephemeral" }
5327
- };
5328
- return Object.assign(toolDefinition, {
5329
- execute: async (input) => {
5330
- return executeCodebaseSearch(input, config);
5331
- },
5332
- formatResult: (result) => {
5333
- return formatResult4(result);
5334
- },
5335
- getSystemPrompt: () => {
5336
- return CODEBASE_SEARCH_SYSTEM_PROMPT;
5337
- }
5338
- });
5339
- }
5340
- function formatResult4(result) {
5341
- if (!result.success) {
5342
- return `Search failed: ${result.error}`;
5343
- }
5344
- if (result.results.length === 0) {
5345
- return "No matching code found. Try rephrasing your query or broadening the search scope.";
5346
- }
5347
- const lines = [];
5348
- lines.push(`Found ${result.results.length} relevant code sections (searched ${result.stats.candidatesRetrieved} candidates in ${result.stats.searchTimeMs}ms):
5349
- `);
5350
- result.results.forEach((r, i) => {
5351
- const relevance = (r.rerankScore * 100).toFixed(1);
5352
- lines.push(`${i + 1}. ${r.filepath} (${relevance}% relevant)`);
5353
- lines.push(` Symbol: ${r.symbolPath}`);
5354
- lines.push(` Language: ${r.language}`);
5355
- lines.push(` Lines: ${r.startLine}-${r.endLine}`);
5356
- lines.push(` Code:`);
5357
- const codeLines = r.content.split("\n");
5358
- codeLines.slice(0, Math.min(codeLines.length, 20)).forEach((line) => {
5359
- lines.push(` ${line}`);
5360
- });
5361
- if (codeLines.length > 20) {
5362
- lines.push(` ... (${codeLines.length - 20} more lines)`);
5363
- }
5364
- lines.push("");
5365
- });
5366
- return lines.join("\n");
5367
- }
5368
-
5369
3438
  // tools/fastapply/anthropic.ts
5370
3439
  var editFileTool2 = {
5371
3440
  name: "edit_file",
@@ -5389,7 +3458,7 @@ var editFileTool2 = {
5389
3458
  required: ["target_filepath", "instruction", "code_edit"]
5390
3459
  }
5391
3460
  };
5392
- function formatResult5(result) {
3461
+ function formatResult3(result) {
5393
3462
  if (!result.success) {
5394
3463
  return `Error editing file: ${result.error}`;
5395
3464
  }
@@ -5406,7 +3475,7 @@ function createEditFileTool2(config = {}) {
5406
3475
  return executeEditFile(input, config);
5407
3476
  },
5408
3477
  formatResult: (result) => {
5409
- return formatResult5(result);
3478
+ return formatResult3(result);
5410
3479
  },
5411
3480
  getSystemPrompt: () => {
5412
3481
  return EDIT_FILE_SYSTEM_PROMPT;
@@ -5772,18 +3841,6 @@ var AnthropicToolFactory = class {
5772
3841
  morphApiKey: this.config.apiKey
5773
3842
  });
5774
3843
  }
5775
- /**
5776
- * Create an Anthropic-compatible codebase search tool
5777
- *
5778
- * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
5779
- * @returns Anthropic Tool with execute and formatResult methods
5780
- */
5781
- createCodebaseSearchTool(toolConfig) {
5782
- return createCodebaseSearchTool2({
5783
- ...toolConfig,
5784
- apiKey: this.config.apiKey
5785
- });
5786
- }
5787
3844
  /**
5788
3845
  * Create an Anthropic-compatible edit file tool
5789
3846
  *
@@ -5885,56 +3942,15 @@ function createGitHubSearchTool3(config) {
5885
3942
  });
5886
3943
  }
5887
3944
 
5888
- // tools/codebase_search/vercel.ts
3945
+ // tools/fastapply/vercel.ts
5889
3946
  var import_ai2 = require("ai");
5890
3947
  var import_zod2 = require("zod");
5891
- function createCodebaseSearchTool3(config) {
5892
- const schema = import_zod2.z.object({
5893
- query: import_zod2.z.string().describe('A complete question about what you want to understand. Ask as if talking to a colleague: "How does X work?", "What happens when Y?", "Where is Z handled?"'),
5894
- target_directories: import_zod2.z.array(import_zod2.z.string()).describe("Prefix directory paths to limit search scope (single directory only, no glob patterns). Use [] to search entire repo."),
5895
- explanation: import_zod2.z.string().describe("One sentence explanation as to why this tool is being used, and how it contributes to the goal."),
5896
- limit: import_zod2.z.number().optional().describe("Max results to return (default: 10)")
5897
- });
5898
- return (0, import_ai2.tool)({
5899
- description: CODEBASE_SEARCH_DESCRIPTION,
5900
- inputSchema: schema,
5901
- execute: async (params) => {
5902
- const { query, target_directories, explanation, limit } = params;
5903
- const result = await executeCodebaseSearch(
5904
- { query, target_directories, explanation, limit },
5905
- config
5906
- );
5907
- if (!result.success) {
5908
- return {
5909
- error: result.error,
5910
- results: []
5911
- };
5912
- }
5913
- return {
5914
- found: result.results.length,
5915
- searchTime: `${result.stats.searchTimeMs}ms`,
5916
- results: result.results.map((r) => ({
5917
- file: r.filepath,
5918
- symbol: r.symbolPath,
5919
- lines: `${r.startLine}-${r.endLine}`,
5920
- language: r.language,
5921
- relevance: `${(r.rerankScore * 100).toFixed(1)}%`,
5922
- code: r.content
5923
- }))
5924
- };
5925
- }
5926
- });
5927
- }
5928
-
5929
- // tools/fastapply/vercel.ts
5930
- var import_ai3 = require("ai");
5931
- var import_zod3 = require("zod");
5932
- var editFileSchema = import_zod3.z.object({
5933
- target_filepath: import_zod3.z.string().describe("The path of the target file to modify"),
5934
- instruction: import_zod3.z.string().describe("A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit."),
5935
- code_edit: import_zod3.z.string().describe("Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections.")
3948
+ var editFileSchema = import_zod2.z.object({
3949
+ target_filepath: import_zod2.z.string().describe("The path of the target file to modify"),
3950
+ instruction: import_zod2.z.string().describe("A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit."),
3951
+ code_edit: import_zod2.z.string().describe("Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections.")
5936
3952
  });
5937
- var editFileTool3 = (0, import_ai3.tool)({
3953
+ var editFileTool3 = (0, import_ai2.tool)({
5938
3954
  description: EDIT_FILE_TOOL_DESCRIPTION,
5939
3955
  inputSchema: editFileSchema,
5940
3956
  execute: async (params) => {
@@ -5955,12 +3971,12 @@ var editFileTool3 = (0, import_ai3.tool)({
5955
3971
  }
5956
3972
  });
5957
3973
  function createEditFileTool3(config = {}) {
5958
- const schema = import_zod3.z.object({
5959
- target_filepath: import_zod3.z.string().describe("The path of the target file to modify"),
5960
- instruction: import_zod3.z.string().describe("A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit."),
5961
- code_edit: import_zod3.z.string().describe("Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections.")
3974
+ const schema = import_zod2.z.object({
3975
+ target_filepath: import_zod2.z.string().describe("The path of the target file to modify"),
3976
+ instruction: import_zod2.z.string().describe("A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit."),
3977
+ code_edit: import_zod2.z.string().describe("Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections.")
5962
3978
  });
5963
- return (0, import_ai3.tool)({
3979
+ return (0, import_ai2.tool)({
5964
3980
  description: config.description || EDIT_FILE_TOOL_DESCRIPTION,
5965
3981
  inputSchema: schema,
5966
3982
  execute: async (params) => {
@@ -5986,8 +4002,8 @@ function createEditFileTool3(config = {}) {
5986
4002
  }
5987
4003
 
5988
4004
  // subagents/vercel.ts
5989
- var import_ai4 = require("ai");
5990
- var import_zod4 = require("zod");
4005
+ var import_ai3 = require("ai");
4006
+ var import_zod3 = require("zod");
5991
4007
  var DEFAULT_MAX_TURNS2 = {
5992
4008
  quick: 3,
5993
4009
  medium: 6,
@@ -6015,18 +4031,18 @@ function createExploreSubagent2(config) {
6015
4031
  ) : null;
6016
4032
  const runPromise = (async () => {
6017
4033
  try {
6018
- const codebaseSearchSchema = import_zod4.z.object({
6019
- searchRequest: import_zod4.z.string().describe("Natural language description of what to search for")
4034
+ const codebaseSearchSchema = import_zod3.z.object({
4035
+ searchRequest: import_zod3.z.string().describe("Natural language description of what to search for")
6020
4036
  });
6021
- const sendMessageSchema = import_zod4.z.object({
6022
- message: import_zod4.z.string().describe("The message to send to the orchestrator")
4037
+ const sendMessageSchema = import_zod3.z.object({
4038
+ message: import_zod3.z.string().describe("The message to send to the orchestrator")
6023
4039
  });
6024
- const result = await (0, import_ai4.generateText)({
4040
+ const result = await (0, import_ai3.generateText)({
6025
4041
  model: config.model,
6026
4042
  system: getSystemPrompt2(thoroughness),
6027
4043
  prompt,
6028
4044
  tools: {
6029
- codebase_search: (0, import_ai4.tool)({
4045
+ codebase_search: (0, import_ai3.tool)({
6030
4046
  description: CODEBASE_SEARCH_TOOL.description,
6031
4047
  inputSchema: codebaseSearchSchema,
6032
4048
  execute: async (params) => {
@@ -6049,7 +4065,7 @@ function createExploreSubagent2(config) {
6049
4065
  return formatResult(warpResult);
6050
4066
  }
6051
4067
  }),
6052
- send_message: (0, import_ai4.tool)({
4068
+ send_message: (0, import_ai3.tool)({
6053
4069
  description: SEND_MESSAGE_TOOL.description,
6054
4070
  inputSchema: sendMessageSchema,
6055
4071
  execute: async (params) => {
@@ -6080,7 +4096,7 @@ function createExploreSubagent2(config) {
6080
4096
  }
6081
4097
  })
6082
4098
  },
6083
- stopWhen: (0, import_ai4.stepCountIs)(getMaxTurns2(config))
4099
+ stopWhen: (0, import_ai3.stepCountIs)(getMaxTurns2(config))
6084
4100
  });
6085
4101
  callbacks.onStep?.({
6086
4102
  step: searchCount,
@@ -6123,10 +4139,10 @@ function createExploreSubagent2(config) {
6123
4139
  }
6124
4140
  return runPromise;
6125
4141
  }
6126
- const exploreToolSchema = import_zod4.z.object({
6127
- searchRequest: import_zod4.z.string().describe("What to explore in the codebase. Be specific about what you want to understand.")
4142
+ const exploreToolSchema = import_zod3.z.object({
4143
+ searchRequest: import_zod3.z.string().describe("What to explore in the codebase. Be specific about what you want to understand.")
6128
4144
  });
6129
- const exploreTool = (0, import_ai4.tool)({
4145
+ const exploreTool = (0, import_ai3.tool)({
6130
4146
  description: "Explore a codebase to answer questions about code structure, find implementations, trace call chains, and understand architecture. Returns a summary of findings. Use this for broad exploration rather than pinpoint keyword searches.",
6131
4147
  inputSchema: exploreToolSchema,
6132
4148
  execute: async (params) => {
@@ -6253,18 +4269,6 @@ var VercelToolFactory = class {
6253
4269
  morphApiKey: this.config.apiKey
6254
4270
  });
6255
4271
  }
6256
- /**
6257
- * Create a Vercel AI SDK-compatible codebase search tool
6258
- *
6259
- * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
6260
- * @returns Vercel AI SDK tool
6261
- */
6262
- createCodebaseSearchTool(toolConfig) {
6263
- return createCodebaseSearchTool3({
6264
- ...toolConfig,
6265
- apiKey: this.config.apiKey
6266
- });
6267
- }
6268
4272
  /**
6269
4273
  * Create a Vercel AI SDK-compatible edit file tool
6270
4274
  *
@@ -6309,14 +4313,8 @@ var MorphClient = class extends MorphAPIClient {
6309
4313
  config;
6310
4314
  /** FastApply tool for editing files with AI-powered merge */
6311
4315
  fastApply;
6312
- /** CodebaseSearch tool for semantic code search */
6313
- codebaseSearch;
6314
4316
  /** WarpGrep tool for fast code search using ripgrep */
6315
4317
  warpGrep;
6316
- /** Browser tool for AI-powered browser automation */
6317
- browser;
6318
- /** GitHub tool for PR context, comments, and check runs */
6319
- github;
6320
4318
  /** Model routers for intelligent model selection */
6321
4319
  routers;
6322
4320
  /** OpenAI-compatible tool factories */
@@ -6354,10 +4352,7 @@ var MorphClient = class extends MorphAPIClient {
6354
4352
  this.config = config;
6355
4353
  logger.debug("MorphClient", "initialized", { debug: !!config.debug, timeout: config.timeout });
6356
4354
  this.fastApply = new FastApplyClient(this);
6357
- this.codebaseSearch = new CodebaseSearchClient(this);
6358
4355
  this.warpGrep = new WarpGrepClient(this);
6359
- this.browser = new BrowserClient(this);
6360
- this.github = new GitHubClient(this, { installationId: config.github?.installationId });
6361
4356
  this.routers = {
6362
4357
  openai: new OpenAIRouter(this),
6363
4358
  anthropic: new AnthropicRouter(this),
@@ -6374,7 +4369,7 @@ var MorphClient = class extends MorphAPIClient {
6374
4369
  };
6375
4370
 
6376
4371
  // tools/warp_grep/index.ts
6377
- var import_zod5 = require("zod");
4372
+ var import_zod4 = require("zod");
6378
4373
 
6379
4374
  // tools/warp_grep/providers/index.ts
6380
4375
  init_local();
@@ -6405,31 +4400,24 @@ ${payload}
6405
4400
  var sharedFormatter = new ToolOutputFormatter();
6406
4401
 
6407
4402
  // tools/warp_grep/index.ts
6408
- var warpGrepInputSchema = import_zod5.z.object({
6409
- search_term: import_zod5.z.string().describe("Search problem statement that this subagent is supposed to research for")
4403
+ var warpGrepInputSchema = import_zod4.z.object({
4404
+ search_term: import_zod4.z.string().describe("Search problem statement that this subagent is supposed to research for")
6410
4405
  });
6411
4406
  // Annotate the CommonJS export names for ESM import in node:
6412
4407
  0 && (module.exports = {
6413
4408
  APIResource,
6414
4409
  AnthropicRouter,
6415
4410
  AnthropicToolFactory,
6416
- BrowserClient,
6417
- CodebaseSearchClient,
6418
4411
  CompactClient,
6419
4412
  FastApplyAnchorIntegrityError,
6420
4413
  FastApplyClient,
6421
4414
  FastApplyContextLengthError,
6422
4415
  GeminiRouter,
6423
- GitHubClient,
6424
- GitHubError,
6425
4416
  LocalRipgrepProvider,
6426
4417
  MorphAPIClient,
6427
4418
  MorphClient,
6428
- NoInstallationError,
6429
- NotFoundError,
6430
4419
  OpenAIRouter,
6431
4420
  OpenAIToolFactory,
6432
- PermissionError,
6433
4421
  RawRouter,
6434
4422
  SDK_VERSION,
6435
4423
  VercelToolFactory,