@morphllm/morphsdk 0.2.198 → 0.2.199

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 (243) hide show
  1. package/README.md +1 -147
  2. package/dist/{chunk-CAFREMIT.js → chunk-5KQ2WRBU.js} +2 -2
  3. package/dist/{chunk-FUYX2MNM.js → chunk-7UU4NF4G.js} +4 -10
  4. package/dist/chunk-7UU4NF4G.js.map +1 -0
  5. package/dist/{chunk-XTFRHVCW.js → chunk-BLCCGRKT.js} +2 -2
  6. package/dist/{chunk-6XFL2NER.js → chunk-BTMMUG3E.js} +2 -2
  7. package/dist/{chunk-4JUIEYAH.js → chunk-CEXBKXWU.js} +3 -3
  8. package/dist/{chunk-FESO6TDQ.js → chunk-DP2PT36G.js} +2 -2
  9. package/dist/chunk-GKRPR5PZ.js +322 -0
  10. package/dist/chunk-GKRPR5PZ.js.map +1 -0
  11. package/dist/{chunk-ZQNTXHBQ.js → chunk-GTV27THY.js} +2 -2
  12. package/dist/{chunk-ZU5YYGBJ.js → chunk-JOC3ZI56.js} +3 -29
  13. package/dist/chunk-JOC3ZI56.js.map +1 -0
  14. package/dist/{chunk-WLMPQFER.js → chunk-K2JR2NFQ.js} +4 -4
  15. package/dist/{chunk-YQ2G5YLI.js → chunk-KXEPBLVD.js} +10 -10
  16. package/dist/{chunk-T6TXYTKH.js → chunk-MEZTHMB2.js} +4 -4
  17. package/dist/{chunk-ZGERT23F.js → chunk-O7LJEVZO.js} +2 -2
  18. package/dist/{chunk-LN7GNFET.js → chunk-OPNTDMHH.js} +4 -4
  19. package/dist/{chunk-QKNGVBE2.js → chunk-PKJ7ODTG.js} +3 -3
  20. package/dist/{chunk-4DNEBVGV.js → chunk-PW6K6OJL.js} +2 -2
  21. package/dist/{chunk-PV6EF6NG.js → chunk-Q3NH3NPD.js} +2 -2
  22. package/dist/{chunk-O5264GI4.js → chunk-RL3ZTXT3.js} +4 -4
  23. package/dist/{chunk-D2RFP6R2.js → chunk-ULHHMZRL.js} +3 -3
  24. package/dist/{chunk-PEFXG5M6.js → chunk-UT3NQLCF.js} +2 -2
  25. package/dist/{chunk-VBZ7BG47.js → chunk-VS5F2ORN.js} +3 -3
  26. package/dist/{chunk-YUH3MTP3.js → chunk-W37OFBSG.js} +2 -2
  27. package/dist/{chunk-SKN2L5CE.js → chunk-WDBYAXZ5.js} +2 -2
  28. package/dist/{chunk-XK3PQZW6.js → chunk-YSFEKIYQ.js} +2 -2
  29. package/dist/{chunk-3XS5P5XH.js → chunk-ZHB57ORD.js} +6 -6
  30. package/dist/client-CGW0Cevz.d.ts +402 -0
  31. package/dist/client.cjs +12 -1644
  32. package/dist/client.cjs.map +1 -1
  33. package/dist/client.d.ts +3 -7
  34. package/dist/client.js +27 -32
  35. package/dist/core/client.cjs +2 -34
  36. package/dist/core/client.cjs.map +1 -1
  37. package/dist/core/client.d.ts +0 -8
  38. package/dist/core/client.js +4 -4
  39. package/dist/core/error.cjs +2 -28
  40. package/dist/core/error.cjs.map +1 -1
  41. package/dist/core/error.js +3 -3
  42. package/dist/core/index.cjs +2 -34
  43. package/dist/core/index.cjs.map +1 -1
  44. package/dist/core/index.js +4 -4
  45. package/dist/edge.cjs +2 -34
  46. package/dist/edge.cjs.map +1 -1
  47. package/dist/edge.js +7 -7
  48. package/dist/index.cjs +12 -1656
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.ts +1 -5
  51. package/dist/index.js +31 -49
  52. package/dist/modelrouter/core.cjs +2 -34
  53. package/dist/modelrouter/core.cjs.map +1 -1
  54. package/dist/modelrouter/core.js +5 -5
  55. package/dist/modelrouter/index.cjs +2 -34
  56. package/dist/modelrouter/index.cjs.map +1 -1
  57. package/dist/modelrouter/index.js +5 -5
  58. package/dist/subagents/anthropic.cjs +2 -34
  59. package/dist/subagents/anthropic.cjs.map +1 -1
  60. package/dist/subagents/anthropic.js +11 -11
  61. package/dist/subagents/vercel.cjs +2 -34
  62. package/dist/subagents/vercel.cjs.map +1 -1
  63. package/dist/subagents/vercel.js +11 -11
  64. package/dist/tools/codebase_search/anthropic.cjs +2 -34
  65. package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
  66. package/dist/tools/codebase_search/anthropic.js +6 -6
  67. package/dist/tools/codebase_search/core.cjs +2 -34
  68. package/dist/tools/codebase_search/core.cjs.map +1 -1
  69. package/dist/tools/codebase_search/core.js +5 -5
  70. package/dist/tools/codebase_search/index.cjs +2 -34
  71. package/dist/tools/codebase_search/index.cjs.map +1 -1
  72. package/dist/tools/codebase_search/index.js +10 -10
  73. package/dist/tools/codebase_search/openai.cjs +2 -34
  74. package/dist/tools/codebase_search/openai.cjs.map +1 -1
  75. package/dist/tools/codebase_search/openai.js +6 -6
  76. package/dist/tools/codebase_search/vercel.cjs +2 -34
  77. package/dist/tools/codebase_search/vercel.cjs.map +1 -1
  78. package/dist/tools/codebase_search/vercel.js +6 -6
  79. package/dist/tools/compact/core.cjs +2 -34
  80. package/dist/tools/compact/core.cjs.map +1 -1
  81. package/dist/tools/compact/core.js +5 -5
  82. package/dist/tools/compact/index.cjs +2 -34
  83. package/dist/tools/compact/index.cjs.map +1 -1
  84. package/dist/tools/compact/index.js +6 -6
  85. package/dist/tools/fastapply/anthropic.cjs +2 -28
  86. package/dist/tools/fastapply/anthropic.cjs.map +1 -1
  87. package/dist/tools/fastapply/anthropic.js +7 -7
  88. package/dist/tools/fastapply/apply.cjs +2 -28
  89. package/dist/tools/fastapply/apply.cjs.map +1 -1
  90. package/dist/tools/fastapply/apply.js +2 -2
  91. package/dist/tools/fastapply/core.cjs +2 -34
  92. package/dist/tools/fastapply/core.cjs.map +1 -1
  93. package/dist/tools/fastapply/core.js +6 -6
  94. package/dist/tools/fastapply/index.cjs +2 -28
  95. package/dist/tools/fastapply/index.cjs.map +1 -1
  96. package/dist/tools/fastapply/index.js +11 -11
  97. package/dist/tools/fastapply/openai.cjs +2 -28
  98. package/dist/tools/fastapply/openai.cjs.map +1 -1
  99. package/dist/tools/fastapply/openai.js +7 -7
  100. package/dist/tools/fastapply/vercel.cjs +2 -28
  101. package/dist/tools/fastapply/vercel.cjs.map +1 -1
  102. package/dist/tools/fastapply/vercel.js +7 -7
  103. package/dist/tools/index.cjs +2 -28
  104. package/dist/tools/index.cjs.map +1 -1
  105. package/dist/tools/index.js +11 -11
  106. package/dist/tools/utils/resilience.cjs +2 -28
  107. package/dist/tools/utils/resilience.cjs.map +1 -1
  108. package/dist/tools/utils/resilience.js +2 -2
  109. package/dist/tools/warp_grep/agent/runner.cjs +2 -28
  110. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  111. package/dist/tools/warp_grep/agent/runner.js +3 -3
  112. package/dist/tools/warp_grep/anthropic.cjs +2 -34
  113. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  114. package/dist/tools/warp_grep/anthropic.js +11 -11
  115. package/dist/tools/warp_grep/client.cjs +2 -34
  116. package/dist/tools/warp_grep/client.cjs.map +1 -1
  117. package/dist/tools/warp_grep/client.js +10 -10
  118. package/dist/tools/warp_grep/gemini.cjs +2 -34
  119. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  120. package/dist/tools/warp_grep/gemini.js +10 -10
  121. package/dist/tools/warp_grep/harness.js +9 -9
  122. package/dist/tools/warp_grep/index.cjs +2 -34
  123. package/dist/tools/warp_grep/index.cjs.map +1 -1
  124. package/dist/tools/warp_grep/index.js +16 -16
  125. package/dist/tools/warp_grep/openai.cjs +2 -34
  126. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  127. package/dist/tools/warp_grep/openai.js +11 -11
  128. package/dist/tools/warp_grep/providers/local.js +2 -2
  129. package/dist/tools/warp_grep/vercel.cjs +2 -34
  130. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  131. package/dist/tools/warp_grep/vercel.js +11 -11
  132. package/dist/version.cjs +2 -28
  133. package/dist/version.cjs.map +1 -1
  134. package/dist/version.js +1 -1
  135. package/package.json +2 -28
  136. package/dist/anthropic-B6my2oBx.d.ts +0 -56
  137. package/dist/chunk-2AMEQAO2.js +0 -46
  138. package/dist/chunk-2AMEQAO2.js.map +0 -1
  139. package/dist/chunk-2HMEZZKK.js +0 -44
  140. package/dist/chunk-2HMEZZKK.js.map +0 -1
  141. package/dist/chunk-2VERUKO2.js +0 -177
  142. package/dist/chunk-2VERUKO2.js.map +0 -1
  143. package/dist/chunk-FUYX2MNM.js.map +0 -1
  144. package/dist/chunk-GJ42MYUU.js +0 -57
  145. package/dist/chunk-GJ42MYUU.js.map +0 -1
  146. package/dist/chunk-KQKLQHJF.js +0 -96
  147. package/dist/chunk-KQKLQHJF.js.map +0 -1
  148. package/dist/chunk-PIIXU2H3.js +0 -389
  149. package/dist/chunk-PIIXU2H3.js.map +0 -1
  150. package/dist/chunk-XH6KJJDI.js +0 -80
  151. package/dist/chunk-XH6KJJDI.js.map +0 -1
  152. package/dist/chunk-YD6TNDR4.js +0 -622
  153. package/dist/chunk-YD6TNDR4.js.map +0 -1
  154. package/dist/chunk-YHZJYCOU.js +0 -680
  155. package/dist/chunk-YHZJYCOU.js.map +0 -1
  156. package/dist/chunk-YTYCHRQ2.js +0 -106
  157. package/dist/chunk-YTYCHRQ2.js.map +0 -1
  158. package/dist/chunk-ZU5YYGBJ.js.map +0 -1
  159. package/dist/client-DCeydotn.d.ts +0 -1015
  160. package/dist/openai-BQMeDFef.d.ts +0 -81
  161. package/dist/tools/browser/anthropic.cjs +0 -645
  162. package/dist/tools/browser/anthropic.cjs.map +0 -1
  163. package/dist/tools/browser/anthropic.d.ts +0 -4
  164. package/dist/tools/browser/anthropic.js +0 -22
  165. package/dist/tools/browser/anthropic.js.map +0 -1
  166. package/dist/tools/browser/core.cjs +0 -1821
  167. package/dist/tools/browser/core.cjs.map +0 -1
  168. package/dist/tools/browser/core.d.ts +0 -245
  169. package/dist/tools/browser/core.js +0 -32
  170. package/dist/tools/browser/core.js.map +0 -1
  171. package/dist/tools/browser/errors.cjs +0 -208
  172. package/dist/tools/browser/errors.cjs.map +0 -1
  173. package/dist/tools/browser/errors.d.ts +0 -158
  174. package/dist/tools/browser/errors.js +0 -22
  175. package/dist/tools/browser/errors.js.map +0 -1
  176. package/dist/tools/browser/index.cjs +0 -2159
  177. package/dist/tools/browser/index.cjs.map +0 -1
  178. package/dist/tools/browser/index.d.ts +0 -134
  179. package/dist/tools/browser/index.js +0 -163
  180. package/dist/tools/browser/index.js.map +0 -1
  181. package/dist/tools/browser/live.cjs +0 -134
  182. package/dist/tools/browser/live.cjs.map +0 -1
  183. package/dist/tools/browser/live.d.ts +0 -75
  184. package/dist/tools/browser/live.js +0 -16
  185. package/dist/tools/browser/live.js.map +0 -1
  186. package/dist/tools/browser/openai.cjs +0 -661
  187. package/dist/tools/browser/openai.cjs.map +0 -1
  188. package/dist/tools/browser/openai.d.ts +0 -4
  189. package/dist/tools/browser/openai.js +0 -28
  190. package/dist/tools/browser/openai.js.map +0 -1
  191. package/dist/tools/browser/profiles/core.cjs +0 -932
  192. package/dist/tools/browser/profiles/core.cjs.map +0 -1
  193. package/dist/tools/browser/profiles/core.d.ts +0 -187
  194. package/dist/tools/browser/profiles/core.js +0 -30
  195. package/dist/tools/browser/profiles/core.js.map +0 -1
  196. package/dist/tools/browser/profiles/index.cjs +0 -932
  197. package/dist/tools/browser/profiles/index.cjs.map +0 -1
  198. package/dist/tools/browser/profiles/index.d.ts +0 -4
  199. package/dist/tools/browser/profiles/index.js +0 -30
  200. package/dist/tools/browser/profiles/index.js.map +0 -1
  201. package/dist/tools/browser/profiles/types.cjs +0 -74
  202. package/dist/tools/browser/profiles/types.cjs.map +0 -1
  203. package/dist/tools/browser/profiles/types.d.ts +0 -195
  204. package/dist/tools/browser/profiles/types.js +0 -16
  205. package/dist/tools/browser/profiles/types.js.map +0 -1
  206. package/dist/tools/browser/prompts.cjs +0 -69
  207. package/dist/tools/browser/prompts.cjs.map +0 -1
  208. package/dist/tools/browser/prompts.d.ts +0 -7
  209. package/dist/tools/browser/prompts.js +0 -10
  210. package/dist/tools/browser/prompts.js.map +0 -1
  211. package/dist/tools/browser/types.cjs +0 -19
  212. package/dist/tools/browser/types.cjs.map +0 -1
  213. package/dist/tools/browser/types.d.ts +0 -338
  214. package/dist/tools/browser/types.js +0 -1
  215. package/dist/tools/browser/types.js.map +0 -1
  216. package/dist/tools/browser/vercel.cjs +0 -622
  217. package/dist/tools/browser/vercel.cjs.map +0 -1
  218. package/dist/tools/browser/vercel.d.ts +0 -4
  219. package/dist/tools/browser/vercel.js +0 -22
  220. package/dist/tools/browser/vercel.js.map +0 -1
  221. package/dist/vercel-CVF27qFK.d.ts +0 -74
  222. /package/dist/{chunk-CAFREMIT.js.map → chunk-5KQ2WRBU.js.map} +0 -0
  223. /package/dist/{chunk-XTFRHVCW.js.map → chunk-BLCCGRKT.js.map} +0 -0
  224. /package/dist/{chunk-6XFL2NER.js.map → chunk-BTMMUG3E.js.map} +0 -0
  225. /package/dist/{chunk-4JUIEYAH.js.map → chunk-CEXBKXWU.js.map} +0 -0
  226. /package/dist/{chunk-FESO6TDQ.js.map → chunk-DP2PT36G.js.map} +0 -0
  227. /package/dist/{chunk-ZQNTXHBQ.js.map → chunk-GTV27THY.js.map} +0 -0
  228. /package/dist/{chunk-WLMPQFER.js.map → chunk-K2JR2NFQ.js.map} +0 -0
  229. /package/dist/{chunk-YQ2G5YLI.js.map → chunk-KXEPBLVD.js.map} +0 -0
  230. /package/dist/{chunk-T6TXYTKH.js.map → chunk-MEZTHMB2.js.map} +0 -0
  231. /package/dist/{chunk-ZGERT23F.js.map → chunk-O7LJEVZO.js.map} +0 -0
  232. /package/dist/{chunk-LN7GNFET.js.map → chunk-OPNTDMHH.js.map} +0 -0
  233. /package/dist/{chunk-QKNGVBE2.js.map → chunk-PKJ7ODTG.js.map} +0 -0
  234. /package/dist/{chunk-4DNEBVGV.js.map → chunk-PW6K6OJL.js.map} +0 -0
  235. /package/dist/{chunk-PV6EF6NG.js.map → chunk-Q3NH3NPD.js.map} +0 -0
  236. /package/dist/{chunk-O5264GI4.js.map → chunk-RL3ZTXT3.js.map} +0 -0
  237. /package/dist/{chunk-D2RFP6R2.js.map → chunk-ULHHMZRL.js.map} +0 -0
  238. /package/dist/{chunk-PEFXG5M6.js.map → chunk-UT3NQLCF.js.map} +0 -0
  239. /package/dist/{chunk-VBZ7BG47.js.map → chunk-VS5F2ORN.js.map} +0 -0
  240. /package/dist/{chunk-YUH3MTP3.js.map → chunk-W37OFBSG.js.map} +0 -0
  241. /package/dist/{chunk-SKN2L5CE.js.map → chunk-WDBYAXZ5.js.map} +0 -0
  242. /package/dist/{chunk-XK3PQZW6.js.map → chunk-YSFEKIYQ.js.map} +0 -0
  243. /package/dist/{chunk-3XS5P5XH.js.map → chunk-ZHB57ORD.js.map} +0 -0
package/dist/client.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.199",
40
40
  description: "TypeScript SDK and CLI for Morph Fast Apply integration",
41
41
  type: "module",
42
42
  main: "./dist/index.cjs",
@@ -143,31 +143,6 @@ var init_package = __esm({
143
143
  import: "./dist/tools/codebase_search/vercel.js",
144
144
  require: "./dist/tools/codebase_search/vercel.cjs"
145
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
146
  "./modelrouter": {
172
147
  types: "./dist/modelrouter/index.d.ts",
173
148
  import: "./dist/modelrouter/index.js",
@@ -208,7 +183,7 @@ var init_package = __esm({
208
183
  "!dist/**/*.test.*"
209
184
  ],
210
185
  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",
186
+ 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 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",
212
187
  prepare: "npm run build",
213
188
  typecheck: "tsc --noEmit && tsc --noEmit -p ai-sdk/tsconfig.json",
214
189
  lint: "eslint .",
@@ -218,7 +193,6 @@ var init_package = __esm({
218
193
  "test:openai": "vitest run openai",
219
194
  "test:vercel": "vitest run vercel",
220
195
  "test:git": "vitest run git",
221
- "test:browser": "vitest run browser",
222
196
  "test:agent": "npx tsx tests/fullAgentTest.ts",
223
197
  "test:integration": "npx tsx tests/fullIntegrationTest.ts",
224
198
  "test:e2e": "vitest run --config vitest.e2e.config.ts",
@@ -1464,7 +1438,6 @@ async function toMorphError(response) {
1464
1438
  // core/client.ts
1465
1439
  var DEFAULT_BASE_URL = "https://api.morphllm.com";
1466
1440
  var DEFAULT_REPOS_URL = "https://repos.morphllm.com";
1467
- var DEFAULT_BROWSER_URL = "https://browser.morphllm.com";
1468
1441
  var DEFAULT_TIMEOUT = 6e4;
1469
1442
  var env = (name) => typeof process !== "undefined" ? process.env?.[name] : void 0;
1470
1443
  var stripTrailingSlash = (url) => url.replace(/\/+$/, "");
@@ -1473,7 +1446,6 @@ var MorphAPIClient = class {
1473
1446
  apiKey;
1474
1447
  baseURL;
1475
1448
  reposURL;
1476
- browserURL;
1477
1449
  /** Explicit default timeout (ms), if set. The request default is applied lazily so
1478
1450
  * resources can read an undefined value and supply their own fallback. */
1479
1451
  timeout;
@@ -1483,9 +1455,6 @@ var MorphAPIClient = class {
1483
1455
  this.apiKey = options.apiKey;
1484
1456
  this.baseURL = stripTrailingSlash(options.baseURL ?? DEFAULT_BASE_URL);
1485
1457
  this.reposURL = stripTrailingSlash(options.reposURL ?? env("MORPH_SEARCH_URL") ?? DEFAULT_REPOS_URL);
1486
- this.browserURL = stripTrailingSlash(
1487
- options.browserURL ?? (env("MORPH_ENVIRONMENT") === "DEV" ? "http://localhost:8000" : DEFAULT_BROWSER_URL)
1488
- );
1489
1458
  this.timeout = options.timeout;
1490
1459
  this.retryConfig = options.retryConfig;
1491
1460
  this.debug = options.debug ?? false;
@@ -1544,7 +1513,6 @@ var MorphAPIClient = class {
1544
1513
  timeout,
1545
1514
  `Morph request to ${url} timed out after ${timeout}ms`
1546
1515
  );
1547
- if (opts.raw) return response;
1548
1516
  if (!response.ok) throw await toMorphError(response);
1549
1517
  if (opts.stream) return response;
1550
1518
  if (response.status === 204) return void 0;
@@ -1790,1259 +1758,6 @@ async function executeCodebaseSearch(input, config) {
1790
1758
  return runSearch(client, input, config.repoId, config.timeout ?? DEFAULT_TIMEOUT3, config.searchUrl);
1791
1759
  }
1792
1760
 
1793
- // tools/browser/core.ts
1794
- init_logger();
1795
-
1796
- // tools/browser/live.ts
1797
- var LIVE_PRESETS = {
1798
- /** Read-only monitoring (no interaction) */
1799
- readonly: { interactive: false },
1800
- /** Interactive control (human-in-the-loop) */
1801
- interactive: { interactive: true },
1802
- /** Watch-only without controls */
1803
- monitoring: { interactive: false, showControls: false }
1804
- };
1805
- function buildLiveUrl(debugUrl, options = {}) {
1806
- if (!debugUrl) {
1807
- throw new Error(
1808
- "debugUrl is required. Ensure your backend returns debugUrl in the task response. Contact support@morphllm.com if you need help."
1809
- );
1810
- }
1811
- const normalized = normalizeLiveUrl(debugUrl);
1812
- const url = new URL(normalized);
1813
- if (options.interactive !== void 0) {
1814
- url.searchParams.set("interactive", String(options.interactive));
1815
- }
1816
- if (options.theme) {
1817
- url.searchParams.set("theme", options.theme);
1818
- }
1819
- if (options.showControls !== void 0) {
1820
- url.searchParams.set("showControls", String(options.showControls));
1821
- }
1822
- if (options.pageId) {
1823
- url.searchParams.set("pageId", options.pageId);
1824
- }
1825
- if (options.pageIndex) {
1826
- url.searchParams.set("pageIndex", options.pageIndex);
1827
- }
1828
- return url.toString();
1829
- }
1830
- function cdpToHttps(wsUrl) {
1831
- return wsUrl.replace(/^wss:\/\//, "https://").replace(/^ws:\/\//, "http://");
1832
- }
1833
- function normalizeLiveUrl(debugUrl) {
1834
- const trimmed = debugUrl.trim();
1835
- if (!trimmed) return trimmed;
1836
- if (trimmed.startsWith("wss://") || trimmed.startsWith("ws://")) {
1837
- return `https://live.browser-use.com?wss=${encodeURIComponent(cdpToHttps(trimmed))}`;
1838
- }
1839
- let url;
1840
- try {
1841
- url = new URL(trimmed);
1842
- } catch {
1843
- return trimmed;
1844
- }
1845
- const wssParam = url.searchParams.get("wss");
1846
- if (wssParam && (wssParam.startsWith("wss://") || wssParam.startsWith("ws://"))) {
1847
- url.searchParams.set("wss", cdpToHttps(wssParam));
1848
- }
1849
- return url.toString();
1850
- }
1851
- function buildLiveIframe(debugUrl, options = {}) {
1852
- const {
1853
- width = "100%",
1854
- height = "600px",
1855
- style = "",
1856
- className = "",
1857
- ...sessionOptions
1858
- } = options;
1859
- const src = buildLiveUrl(debugUrl, sessionOptions);
1860
- const widthStr = typeof width === "number" ? `${width}px` : width;
1861
- const heightStr = typeof height === "number" ? `${height}px` : height;
1862
- const baseStyle = `width: ${widthStr}; height: ${heightStr}; border: none;`;
1863
- const fullStyle = style ? `${baseStyle} ${style}` : baseStyle;
1864
- const attributes = [
1865
- `src="${src}"`,
1866
- `style="${fullStyle}"`
1867
- ];
1868
- if (className) {
1869
- attributes.push(`class="${className}"`);
1870
- }
1871
- return `<iframe ${attributes.join(" ")}></iframe>`;
1872
- }
1873
- function buildEmbedCode(debugUrl, options = {}) {
1874
- const iframe = buildLiveIframe(debugUrl, options);
1875
- return `<!-- Embed Morph Live Session -->
1876
- ${iframe}`;
1877
- }
1878
- function resolvePreset(optionsOrPreset) {
1879
- if (!optionsOrPreset) {
1880
- return {};
1881
- }
1882
- if (typeof optionsOrPreset === "string") {
1883
- const preset = LIVE_PRESETS[optionsOrPreset];
1884
- if (!preset) {
1885
- throw new Error(
1886
- `Unknown preset: ${optionsOrPreset}. Available presets: ${Object.keys(LIVE_PRESETS).join(", ")}`
1887
- );
1888
- }
1889
- return preset;
1890
- }
1891
- return optionsOrPreset;
1892
- }
1893
-
1894
- // tools/browser/errors.ts
1895
- var MorphError2 = class extends Error {
1896
- /** Error code for programmatic handling */
1897
- code;
1898
- /** Original cause of the error, if any */
1899
- cause;
1900
- constructor(message, code, cause) {
1901
- super(message);
1902
- this.name = "MorphError";
1903
- this.code = code;
1904
- this.cause = cause;
1905
- if (Error.captureStackTrace) {
1906
- Error.captureStackTrace(this, this.constructor);
1907
- }
1908
- }
1909
- /**
1910
- * Returns a JSON representation of the error for logging.
1911
- */
1912
- toJSON() {
1913
- return {
1914
- name: this.name,
1915
- message: this.message,
1916
- code: this.code,
1917
- cause: this.cause?.message
1918
- };
1919
- }
1920
- };
1921
- var MorphValidationError = class extends MorphError2 {
1922
- /** The field that failed validation */
1923
- field;
1924
- constructor(message, field) {
1925
- super(message, "validation_error");
1926
- this.name = "MorphValidationError";
1927
- this.field = field;
1928
- }
1929
- toJSON() {
1930
- return {
1931
- ...super.toJSON(),
1932
- field: this.field
1933
- };
1934
- }
1935
- };
1936
- var MorphAPIError = class extends MorphError2 {
1937
- /** HTTP status code */
1938
- statusCode;
1939
- /** Request ID for debugging (if available) */
1940
- requestId;
1941
- /** Raw response body */
1942
- rawResponse;
1943
- constructor(message, code, statusCode, options) {
1944
- super(message, code, options?.cause);
1945
- this.name = "MorphAPIError";
1946
- this.statusCode = statusCode;
1947
- this.requestId = options?.requestId;
1948
- this.rawResponse = options?.rawResponse;
1949
- }
1950
- toJSON() {
1951
- return {
1952
- ...super.toJSON(),
1953
- statusCode: this.statusCode,
1954
- requestId: this.requestId
1955
- };
1956
- }
1957
- };
1958
- var MorphAuthenticationError = class extends MorphAPIError {
1959
- constructor(message = "Authentication required. Please provide a valid API key.") {
1960
- super(message, "authentication_required", 401);
1961
- this.name = "MorphAuthenticationError";
1962
- }
1963
- };
1964
- var MorphRateLimitError = class extends MorphAPIError {
1965
- /** When the rate limit resets (Unix timestamp) */
1966
- resetAt;
1967
- /** Number of seconds until reset */
1968
- retryAfter;
1969
- constructor(message = "Rate limit exceeded. Please retry later.", options) {
1970
- super(message, "rate_limit_exceeded", 429, { requestId: options?.requestId });
1971
- this.name = "MorphRateLimitError";
1972
- this.resetAt = options?.resetAt;
1973
- this.retryAfter = options?.retryAfter;
1974
- }
1975
- toJSON() {
1976
- return {
1977
- ...super.toJSON(),
1978
- resetAt: this.resetAt,
1979
- retryAfter: this.retryAfter
1980
- };
1981
- }
1982
- };
1983
- var MorphNotFoundError = class extends MorphAPIError {
1984
- /** The type of resource that was not found */
1985
- resourceType;
1986
- /** The ID of the resource that was not found */
1987
- resourceId;
1988
- constructor(resourceType, resourceId) {
1989
- const message = resourceId ? `${resourceType} '${resourceId}' not found` : `${resourceType} not found`;
1990
- super(message, "resource_not_found", 404);
1991
- this.name = "MorphNotFoundError";
1992
- this.resourceType = resourceType;
1993
- this.resourceId = resourceId;
1994
- }
1995
- toJSON() {
1996
- return {
1997
- ...super.toJSON(),
1998
- resourceType: this.resourceType,
1999
- resourceId: this.resourceId
2000
- };
2001
- }
2002
- };
2003
- var MorphProfileLimitError = class extends MorphAPIError {
2004
- /** Current number of profiles */
2005
- currentCount;
2006
- /** Maximum allowed profiles for the plan */
2007
- maxAllowed;
2008
- constructor(message = "Profile limit exceeded for your plan.", options) {
2009
- super(message, "profile_limit_exceeded", 403, { requestId: options?.requestId });
2010
- this.name = "MorphProfileLimitError";
2011
- this.currentCount = options?.currentCount;
2012
- this.maxAllowed = options?.maxAllowed;
2013
- }
2014
- toJSON() {
2015
- return {
2016
- ...super.toJSON(),
2017
- currentCount: this.currentCount,
2018
- maxAllowed: this.maxAllowed
2019
- };
2020
- }
2021
- };
2022
- function parseAPIError(statusCode, responseText, requestId) {
2023
- let errorData = {};
2024
- try {
2025
- errorData = JSON.parse(responseText);
2026
- } catch {
2027
- }
2028
- const message = errorData.detail || errorData.message || responseText || "Unknown error";
2029
- const code = errorData.code;
2030
- switch (statusCode) {
2031
- case 401:
2032
- return new MorphAuthenticationError(message);
2033
- case 403:
2034
- if (code === "profile_limit_exceeded" || message.toLowerCase().includes("limit")) {
2035
- return new MorphProfileLimitError(message, { requestId });
2036
- }
2037
- return new MorphAPIError(message, "insufficient_permissions", statusCode, { requestId, rawResponse: responseText });
2038
- case 404:
2039
- if (message.toLowerCase().includes("profile")) {
2040
- return new MorphNotFoundError("Profile", void 0);
2041
- }
2042
- if (message.toLowerCase().includes("session")) {
2043
- return new MorphNotFoundError("Session", void 0);
2044
- }
2045
- return new MorphAPIError(message, "resource_not_found", statusCode, { requestId, rawResponse: responseText });
2046
- case 429:
2047
- return new MorphRateLimitError(message, { requestId });
2048
- case 422:
2049
- return new MorphAPIError(message, "validation_error", statusCode, { requestId, rawResponse: responseText });
2050
- case 500:
2051
- case 502:
2052
- case 503:
2053
- case 504:
2054
- return new MorphAPIError(message, "service_unavailable", statusCode, { requestId, rawResponse: responseText });
2055
- default:
2056
- return new MorphAPIError(message, "network_error", statusCode, { requestId, rawResponse: responseText });
2057
- }
2058
- }
2059
-
2060
- // tools/browser/profiles/types.ts
2061
- function transformProfile(api) {
2062
- return {
2063
- id: api.id,
2064
- name: api.name,
2065
- repoId: api.repo_id,
2066
- cookieDomains: api.cookie_domains,
2067
- lastUsedAt: api.last_used_at,
2068
- createdAt: api.created_at,
2069
- updatedAt: api.updated_at
2070
- };
2071
- }
2072
- function transformCreateInput(input) {
2073
- return {
2074
- name: input.name,
2075
- repo_id: input.repoId
2076
- };
2077
- }
2078
- function transformSession(api) {
2079
- return {
2080
- sessionId: api.session_id,
2081
- debugUrl: api.debug_url || ""
2082
- };
2083
- }
2084
- function transformSaveInput(input) {
2085
- return {
2086
- session_id: input.sessionId,
2087
- profile_id: input.profileId
2088
- };
2089
- }
2090
- function transformStateResponse(api) {
2091
- return {
2092
- profileId: api.profile_id,
2093
- stateUrl: api.state_url,
2094
- expiresIn: api.expires_in
2095
- };
2096
- }
2097
-
2098
- // tools/browser/profiles/core.ts
2099
- var DEFAULT_API_URL2 = process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com";
2100
- var ProfilesClient = class {
2101
- config;
2102
- constructor(config) {
2103
- this.config = config;
2104
- }
2105
- /**
2106
- * Create a new browser profile and immediately start a live session.
2107
- *
2108
- * @param input - Profile creation parameters
2109
- * @returns Profile setup handle with live URL + save()
2110
- * @throws {MorphValidationError} If input validation fails
2111
- * @throws {MorphProfileLimitError} If profile limit is exceeded
2112
- * @throws {MorphAuthenticationError} If API key is missing or invalid
2113
- *
2114
- * @example
2115
- * ```typescript
2116
- * const setup = await morph.browser.profiles.createProfile({
2117
- * name: 'LinkedIn Production',
2118
- * repoId: 'owner/repo'
2119
- * });
2120
- * console.log(setup.session.debugUrl);
2121
- * await setup.save();
2122
- * ```
2123
- */
2124
- async createProfile(input) {
2125
- return createProfile(input, this.config);
2126
- }
2127
- /**
2128
- * List all profiles for the authenticated user.
2129
- *
2130
- * @param repoId - Optional repository ID to filter by
2131
- * @returns Array of profiles
2132
- *
2133
- * @example
2134
- * ```typescript
2135
- * // List all profiles
2136
- * const allProfiles = await morph.browser.profiles.listProfiles();
2137
- *
2138
- * // List profiles for a specific repo
2139
- * const repoProfiles = await morph.browser.profiles.listProfiles('owner/repo');
2140
- * ```
2141
- */
2142
- async listProfiles(repoId) {
2143
- return listProfiles(this.config, repoId);
2144
- }
2145
- /**
2146
- * Get a profile by ID with convenience methods.
2147
- *
2148
- * @param id - Profile ID
2149
- * @returns Profile with attached methods
2150
- * @throws {MorphNotFoundError} If profile is not found
2151
- *
2152
- * @example
2153
- * ```typescript
2154
- * const profile = await morph.browser.profiles.getProfile('profile-id');
2155
- * const state = await profile.getState();
2156
- * await profile.delete();
2157
- * ```
2158
- */
2159
- async getProfile(id) {
2160
- return getProfile(id, this.config);
2161
- }
2162
- /**
2163
- * Update a profile by opening a live session (no rename).
2164
- *
2165
- * @param id - Profile ID
2166
- * @returns Profile setup handle with live URL + save()
2167
- */
2168
- async updateProfile(id) {
2169
- return updateProfile(id, this.config);
2170
- }
2171
- /**
2172
- * Delete a profile.
2173
- *
2174
- * @param id - Profile ID
2175
- * @throws {MorphNotFoundError} If profile is not found
2176
- */
2177
- async deleteProfile(id) {
2178
- return deleteProfile(id, this.config);
2179
- }
2180
- /**
2181
- * Start a browser session for profile setup.
2182
- *
2183
- * Returns a live URL where the user can sign into accounts.
2184
- * After signing in, call `saveSession` to persist the state.
2185
- *
2186
- * @param input - Optional session parameters
2187
- * @returns Session with debug URL
2188
- *
2189
- * @example
2190
- * ```typescript
2191
- * const session = await morph.browser.profiles.startSession();
2192
- * console.log('Sign in at:', session.debugUrl);
2193
- * // Open debugUrl in browser, user signs in...
2194
- * await morph.browser.profiles.saveSession(session.sessionId, profile.id);
2195
- * ```
2196
- */
2197
- async startSession(input) {
2198
- return startProfileSession(this.config, input);
2199
- }
2200
- /**
2201
- * Save browser state from a session to a profile.
2202
- *
2203
- * Call this after the user is done signing into accounts.
2204
- * Extracts cookies, localStorage, and sessionStorage.
2205
- *
2206
- * @param sessionId - Browser session ID from startSession
2207
- * @param profileId - Profile ID to save state to
2208
- * @returns Updated profile with cookie domains
2209
- */
2210
- async saveSession(sessionId, profileId) {
2211
- return saveProfileSession({ sessionId, profileId }, this.config);
2212
- }
2213
- /**
2214
- * List available repo IDs (discovery).
2215
- *
2216
- * @returns Repo summaries with profile counts
2217
- */
2218
- async listRepos() {
2219
- return listRepos(this.config);
2220
- }
2221
- /**
2222
- * Get the presigned URL for a profile's state.
2223
- *
2224
- * Use this to download the raw state JSON for debugging
2225
- * or to restore state manually.
2226
- *
2227
- * @param profileId - Profile ID
2228
- * @returns State URL with expiry information
2229
- */
2230
- async getProfileState(profileId) {
2231
- return getProfileState(profileId, this.config);
2232
- }
2233
- };
2234
- function validateCreateInput(input) {
2235
- if (!input.name || typeof input.name !== "string") {
2236
- throw new MorphValidationError("name is required", "name");
2237
- }
2238
- const trimmedName = input.name.trim();
2239
- if (trimmedName.length === 0) {
2240
- throw new MorphValidationError("name cannot be empty", "name");
2241
- }
2242
- if (trimmedName.length > 100) {
2243
- throw new MorphValidationError("name must be 100 characters or less", "name");
2244
- }
2245
- if (!input.repoId || typeof input.repoId !== "string") {
2246
- throw new MorphValidationError("repoId is required", "repoId");
2247
- }
2248
- if (input.repoId.trim().length === 0) {
2249
- throw new MorphValidationError("repoId cannot be empty", "repoId");
2250
- }
2251
- }
2252
- function validateId(id, fieldName) {
2253
- if (!id || typeof id !== "string") {
2254
- throw new MorphValidationError(`${fieldName} is required`, fieldName);
2255
- }
2256
- if (id.trim().length === 0) {
2257
- throw new MorphValidationError(`${fieldName} cannot be empty`, fieldName);
2258
- }
2259
- }
2260
- async function createProfile(input, config = {}) {
2261
- validateCreateInput(input);
2262
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2263
- const headers = buildHeaders(config);
2264
- const response = await fetchWithRetry(
2265
- `${apiUrl}/profiles`,
2266
- {
2267
- method: "POST",
2268
- headers,
2269
- body: JSON.stringify(transformCreateInput(input))
2270
- },
2271
- config.retryConfig
2272
- );
2273
- if (!response.ok) {
2274
- const errorText = await response.text().catch(() => response.statusText);
2275
- const requestId = response.headers.get("x-request-id") || void 0;
2276
- throw parseAPIError(response.status, errorText, requestId);
2277
- }
2278
- const apiProfile = await response.json();
2279
- const profile = transformProfile(apiProfile);
2280
- const session = await startProfileSession(config, { profileId: profile.id });
2281
- return buildProfileSetup(profile, session, config);
2282
- }
2283
- async function listProfiles(config = {}, repoId) {
2284
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2285
- const headers = buildHeaders(config);
2286
- const url = repoId ? `${apiUrl}/profiles?repo_id=${encodeURIComponent(repoId)}` : `${apiUrl}/profiles`;
2287
- const response = await fetchWithRetry(
2288
- url,
2289
- { method: "GET", headers },
2290
- config.retryConfig
2291
- );
2292
- if (!response.ok) {
2293
- const errorText = await response.text().catch(() => response.statusText);
2294
- const requestId = response.headers.get("x-request-id") || void 0;
2295
- throw parseAPIError(response.status, errorText, requestId);
2296
- }
2297
- const data = await response.json();
2298
- return data.profiles.map(transformProfile);
2299
- }
2300
- async function getProfile(id, config = {}) {
2301
- validateId(id, "id");
2302
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2303
- const headers = buildHeaders(config);
2304
- const response = await fetchWithRetry(
2305
- `${apiUrl}/profiles/${encodeURIComponent(id)}`,
2306
- { method: "GET", headers },
2307
- config.retryConfig
2308
- );
2309
- if (!response.ok) {
2310
- const errorText = await response.text().catch(() => response.statusText);
2311
- const requestId = response.headers.get("x-request-id") || void 0;
2312
- throw parseAPIError(response.status, errorText, requestId);
2313
- }
2314
- const apiProfile = await response.json();
2315
- const profile = transformProfile(apiProfile);
2316
- return {
2317
- ...profile,
2318
- getState: () => getProfileState(id, config),
2319
- delete: () => deleteProfile(id, config)
2320
- };
2321
- }
2322
- async function updateProfile(id, config = {}) {
2323
- validateId(id, "id");
2324
- const profile = await fetchProfile(id, config);
2325
- const session = await startProfileSession(config, { profileId: profile.id });
2326
- return buildProfileSetup(profile, session, config);
2327
- }
2328
- async function deleteProfile(id, config = {}) {
2329
- validateId(id, "id");
2330
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2331
- const headers = buildHeaders(config);
2332
- const response = await fetchWithRetry(
2333
- `${apiUrl}/profiles/${encodeURIComponent(id)}`,
2334
- { method: "DELETE", headers },
2335
- config.retryConfig
2336
- );
2337
- if (!response.ok) {
2338
- const errorText = await response.text().catch(() => response.statusText);
2339
- const requestId = response.headers.get("x-request-id") || void 0;
2340
- throw parseAPIError(response.status, errorText, requestId);
2341
- }
2342
- }
2343
- async function startProfileSession(config = {}, input) {
2344
- if (!config.apiKey) {
2345
- throw new MorphAuthenticationError();
2346
- }
2347
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2348
- const headers = buildHeaders(config);
2349
- const body = input?.profileId ? { profile_id: input.profileId } : {};
2350
- const response = await fetchWithRetry(
2351
- `${apiUrl}/profiles/session/start`,
2352
- {
2353
- method: "POST",
2354
- headers,
2355
- body: JSON.stringify(body)
2356
- },
2357
- config.retryConfig
2358
- );
2359
- if (!response.ok) {
2360
- const errorText = await response.text().catch(() => response.statusText);
2361
- const requestId = response.headers.get("x-request-id") || void 0;
2362
- throw parseAPIError(response.status, errorText, requestId);
2363
- }
2364
- const apiSession = await response.json();
2365
- return transformSession(apiSession);
2366
- }
2367
- async function saveProfileSession(input, config = {}) {
2368
- validateId(input.sessionId, "sessionId");
2369
- validateId(input.profileId, "profileId");
2370
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2371
- const headers = buildHeaders(config);
2372
- const response = await fetchWithRetry(
2373
- `${apiUrl}/profiles/session/save`,
2374
- {
2375
- method: "POST",
2376
- headers,
2377
- body: JSON.stringify(transformSaveInput(input))
2378
- },
2379
- config.retryConfig
2380
- );
2381
- if (!response.ok) {
2382
- const errorText = await response.text().catch(() => response.statusText);
2383
- const requestId = response.headers.get("x-request-id") || void 0;
2384
- throw parseAPIError(response.status, errorText, requestId);
2385
- }
2386
- const apiProfile = await response.json();
2387
- return transformProfile(apiProfile);
2388
- }
2389
- async function listRepos(config = {}) {
2390
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2391
- const headers = buildHeaders(config);
2392
- const response = await fetchWithRetry(
2393
- `${apiUrl}/repos`,
2394
- { method: "GET", headers },
2395
- config.retryConfig
2396
- );
2397
- if (!response.ok) {
2398
- const errorText = await response.text().catch(() => response.statusText);
2399
- const requestId = response.headers.get("x-request-id") || void 0;
2400
- throw parseAPIError(response.status, errorText, requestId);
2401
- }
2402
- const data = await response.json();
2403
- const repos = Array.isArray(data?.repos) ? data.repos : [];
2404
- return repos.map((repo) => ({
2405
- repoId: repo.repo_id,
2406
- repoFullName: repo.repo_full_name,
2407
- profileCount: repo.profile_count ?? 0
2408
- }));
2409
- }
2410
- async function getProfileState(profileId, config = {}) {
2411
- validateId(profileId, "profileId");
2412
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2413
- const headers = buildHeaders(config);
2414
- const response = await fetchWithRetry(
2415
- `${apiUrl}/profiles/${encodeURIComponent(profileId)}/state`,
2416
- { method: "GET", headers },
2417
- config.retryConfig
2418
- );
2419
- if (!response.ok) {
2420
- const errorText = await response.text().catch(() => response.statusText);
2421
- const requestId = response.headers.get("x-request-id") || void 0;
2422
- throw parseAPIError(response.status, errorText, requestId);
2423
- }
2424
- const apiState = await response.json();
2425
- return transformStateResponse(apiState);
2426
- }
2427
- function buildHeaders(config) {
2428
- const headers = { "Content-Type": "application/json" };
2429
- if (config.apiKey) {
2430
- headers["Authorization"] = `Bearer ${config.apiKey}`;
2431
- }
2432
- return headers;
2433
- }
2434
- async function fetchProfile(id, config) {
2435
- const apiUrl = config.apiUrl || DEFAULT_API_URL2;
2436
- const headers = buildHeaders(config);
2437
- const response = await fetchWithRetry(
2438
- `${apiUrl}/profiles/${encodeURIComponent(id)}`,
2439
- { method: "GET", headers },
2440
- config.retryConfig
2441
- );
2442
- if (!response.ok) {
2443
- const errorText = await response.text().catch(() => response.statusText);
2444
- const requestId = response.headers.get("x-request-id") || void 0;
2445
- throw parseAPIError(response.status, errorText, requestId);
2446
- }
2447
- const apiProfile = await response.json();
2448
- return transformProfile(apiProfile);
2449
- }
2450
- function buildProfileSetup(profile, session, config) {
2451
- return {
2452
- profile,
2453
- session,
2454
- save: () => saveProfileSession({ sessionId: session.sessionId, profileId: profile.id }, config)
2455
- };
2456
- }
2457
-
2458
- // tools/browser/core.ts
2459
- var DEFAULT_CONFIG2 = {
2460
- apiUrl: process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com",
2461
- timeout: 1e6,
2462
- // 10 minutes for complex tasks
2463
- debug: false
2464
- };
2465
- var BrowserClient = class extends APIResource {
2466
- config;
2467
- /**
2468
- * Profile management - create and manage browser profiles for storing login state.
2469
- */
2470
- profiles;
2471
- constructor(clientOrConfig = {}) {
2472
- const isClient = clientOrConfig instanceof MorphAPIClient;
2473
- super(
2474
- isClient ? clientOrConfig : new MorphAPIClient({
2475
- apiKey: clientOrConfig.apiKey,
2476
- browserURL: clientOrConfig.apiUrl,
2477
- timeout: clientOrConfig.timeout,
2478
- retryConfig: clientOrConfig.retryConfig,
2479
- debug: clientOrConfig.debug
2480
- })
2481
- );
2482
- this.config = isClient ? {
2483
- ...DEFAULT_CONFIG2,
2484
- apiUrl: clientOrConfig.browserURL,
2485
- apiKey: clientOrConfig.resolveApiKey(),
2486
- retryConfig: clientOrConfig.retryConfig,
2487
- debug: clientOrConfig.debug
2488
- } : { ...DEFAULT_CONFIG2, ...clientOrConfig };
2489
- this.profiles = new ProfilesClient(this.config);
2490
- }
2491
- /**
2492
- * Execute a browser automation task
2493
- */
2494
- async execute(input) {
2495
- return executeBrowserTask(input, this.config);
2496
- }
2497
- async createTask(input) {
2498
- const apiUrl = this.config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2499
- const debug = this.config.debug || false;
2500
- const hasTask = typeof input.task === "string" && input.task.trim().length > 0;
2501
- const hasDiff = typeof input.diff === "string" && input.diff.trim().length > 0;
2502
- if (!hasTask && !hasDiff) {
2503
- throw new Error('Browser task requires either "task" (natural language) or "diff" (PR-review planning)');
2504
- }
2505
- logger.debug("Browser", "create_task", { task: (input.task ?? "").slice(0, 100), url: input.url, endpoint: `${apiUrl}/browser-task/async` });
2506
- const headers = { "Content-Type": "application/json" };
2507
- if (this.config.apiKey) headers["Authorization"] = `Bearer ${this.config.apiKey}`;
2508
- const response = await fetch(`${apiUrl}/browser-task/async`, {
2509
- method: "POST",
2510
- headers,
2511
- body: JSON.stringify({
2512
- task: input.task,
2513
- diff: input.diff,
2514
- url: input.url,
2515
- max_steps: input.maxSteps ?? 10,
2516
- model: input.model ?? "morph-computer-use-v0",
2517
- viewport_width: input.viewportWidth ?? 1280,
2518
- viewport_height: input.viewportHeight ?? 720,
2519
- external_id: input.externalId,
2520
- repo_id: input.repoId,
2521
- repo_full_name: input.repoFullName,
2522
- commit_id: input.commitId,
2523
- record_video: input.recordVideo ?? false,
2524
- video_width: input.videoWidth ?? input.viewportWidth ?? 1280,
2525
- video_height: input.videoHeight ?? input.viewportHeight ?? 720,
2526
- allow_resizing: input.allowResizing ?? false,
2527
- structured_output: "schema" in input ? stringifyStructuredOutput(input.schema) : void 0,
2528
- auth: input.auth,
2529
- profile_id: input.profileId,
2530
- force_query_params: input.forceQueryParams
2531
- })
2532
- });
2533
- if (!response.ok) {
2534
- const errorText = await response.text().catch(() => response.statusText);
2535
- logger.error("Browser", "create_task_error", { status: response.status, error: errorText });
2536
- throw new Error(`HTTP ${response.status}: ${errorText}`);
2537
- }
2538
- const result = mapTaskResult(await response.json());
2539
- logger.debug("Browser", "task_created", { recording_id: result.recordingId, task_id: result.taskId, debug_url: !!result.debugUrl });
2540
- if ("schema" in input) {
2541
- return wrapTaskResponseWithSchema(result, this.config, input.schema);
2542
- } else {
2543
- return wrapTaskResponse(result, this.config);
2544
- }
2545
- }
2546
- /**
2547
- * Execute task with recording and wait for video to be ready
2548
- */
2549
- async executeWithRecording(input) {
2550
- return executeWithRecording(input, this.config);
2551
- }
2552
- /**
2553
- * Get recording status and URLs
2554
- */
2555
- async getRecording(recordingId) {
2556
- return getRecording(recordingId, this.config);
2557
- }
2558
- /**
2559
- * Wait for recording to complete with automatic polling
2560
- */
2561
- async waitForRecording(recordingId, options) {
2562
- return waitForRecording(recordingId, this.config, options);
2563
- }
2564
- /**
2565
- * Get errors from recording with screenshots
2566
- */
2567
- async getErrors(recordingId) {
2568
- return getErrors(recordingId, this.config);
2569
- }
2570
- /**
2571
- * Get animated WebP preview of recording
2572
- */
2573
- async getWebp(recordingId, options) {
2574
- return getWebp(recordingId, this.config, options);
2575
- }
2576
- /**
2577
- * Check if browser worker service is healthy
2578
- */
2579
- async checkHealth() {
2580
- return checkHealth(this.config);
2581
- }
2582
- };
2583
- async function executeBrowserTask(input, config = {}) {
2584
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2585
- const timeout = config.timeout || DEFAULT_CONFIG2.timeout;
2586
- const debug = config.debug || false;
2587
- if (!input.task || input.task.trim().length === 0) {
2588
- return {
2589
- success: false,
2590
- error: 'Task description is required. Example: "Go to example.com and click the login button"'
2591
- };
2592
- }
2593
- if (input.maxSteps !== void 0 && (input.maxSteps < 1 || input.maxSteps > 50)) {
2594
- return {
2595
- success: false,
2596
- error: "maxSteps must be between 1 and 50. Use more steps for complex multi-page flows."
2597
- };
2598
- }
2599
- logger.debug("Browser", "execute_start", { task: input.task.slice(0, 100), url: input.url, max_steps: input.maxSteps ?? 10, record_video: input.recordVideo ?? false });
2600
- const startTime = Date.now();
2601
- try {
2602
- const headers = { "Content-Type": "application/json" };
2603
- if (config.apiKey) headers["Authorization"] = `Bearer ${config.apiKey}`;
2604
- const fetchPromise = fetchWithRetry(
2605
- `${apiUrl}/browser-task`,
2606
- {
2607
- method: "POST",
2608
- headers,
2609
- body: JSON.stringify({
2610
- task: input.task,
2611
- url: input.url,
2612
- max_steps: input.maxSteps ?? 10,
2613
- model: input.model ?? "morph-computer-use-v0",
2614
- viewport_width: input.viewportWidth ?? 1280,
2615
- viewport_height: input.viewportHeight ?? 720,
2616
- external_id: input.externalId,
2617
- repo_id: input.repoId,
2618
- commit_id: input.commitId,
2619
- record_video: input.recordVideo ?? false,
2620
- video_width: input.videoWidth ?? input.viewportWidth ?? 1280,
2621
- video_height: input.videoHeight ?? input.viewportHeight ?? 720,
2622
- allow_resizing: input.allowResizing ?? false,
2623
- structured_output: input.structuredOutput,
2624
- auth: input.auth,
2625
- profile_id: input.profileId,
2626
- force_query_params: input.forceQueryParams
2627
- })
2628
- },
2629
- config.retryConfig
2630
- );
2631
- const response = await withTimeout(
2632
- fetchPromise,
2633
- timeout,
2634
- `Browser task timed out after ${timeout}ms. Consider increasing timeout or reducing maxSteps.`
2635
- );
2636
- if (!response.ok) {
2637
- const errorText = await response.text().catch(() => response.statusText);
2638
- logger.error("Browser", "execute_error", { status: response.status, error: errorText });
2639
- throw new Error(`HTTP ${response.status}: ${errorText}`);
2640
- }
2641
- const result = mapTaskResult(await response.json());
2642
- const elapsed = Date.now() - startTime;
2643
- logger.debug("Browser", "execute_complete", { success: result.success, latency_ms: elapsed, steps: result.stepsTaken ?? 0, recording_id: result.recordingId });
2644
- return result;
2645
- } catch (error) {
2646
- if (error instanceof Error) {
2647
- if (error.message.includes("ECONNREFUSED") || error.message.includes("fetch failed")) {
2648
- return {
2649
- success: false,
2650
- error: `Cannot connect to browser worker at ${apiUrl}. Ensure the service is running and accessible. For local dev, set MORPH_ENVIRONMENT=DEV.`
2651
- };
2652
- }
2653
- return {
2654
- success: false,
2655
- error: error.message
2656
- };
2657
- }
2658
- return {
2659
- success: false,
2660
- error: String(error)
2661
- };
2662
- }
2663
- }
2664
- async function getRecording(recordingId, config = {}) {
2665
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2666
- const debug = config.debug || false;
2667
- if (!config.apiKey) {
2668
- throw new Error("API key required for getRecording");
2669
- }
2670
- if (debug) console.log(`[Browser] getRecording: ${recordingId}`);
2671
- const response = await fetch(`${apiUrl}/recordings/${recordingId}`, {
2672
- method: "GET",
2673
- headers: { "Authorization": `Bearer ${config.apiKey}` }
2674
- });
2675
- if (!response.ok) {
2676
- const errorText = await response.text().catch(() => response.statusText);
2677
- if (debug) console.error(`[Browser] getRecording error: ${response.status} - ${errorText}`);
2678
- throw new Error(`HTTP ${response.status}: ${errorText}`);
2679
- }
2680
- const data = mapRecordingStatus(await response.json());
2681
- if (debug) console.log(`[Browser] Recording status: ${data.status}`);
2682
- return {
2683
- ...data,
2684
- getWebp: (options) => getWebp(recordingId, config, options),
2685
- getErrors: () => getErrors(recordingId, config)
2686
- };
2687
- }
2688
- async function waitForRecording(recordingId, config = {}, options = {}) {
2689
- const timeout = options.timeout ?? 6e4;
2690
- const pollInterval = options.pollInterval ?? 2e3;
2691
- const startTime = Date.now();
2692
- while (Date.now() - startTime < timeout) {
2693
- const status = await getRecording(recordingId, config);
2694
- if (status.status === "COMPLETED" || status.status === "ERROR") {
2695
- return status;
2696
- }
2697
- await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
2698
- }
2699
- throw new Error(`Recording timeout after ${timeout}ms - status still pending`);
2700
- }
2701
- async function executeWithRecording(input, config = {}) {
2702
- const taskResult = await executeBrowserTask(input, config);
2703
- if (taskResult.recordingId) {
2704
- try {
2705
- const recording = await waitForRecording(
2706
- taskResult.recordingId,
2707
- config,
2708
- { timeout: 6e4, pollInterval: 2e3 }
2709
- );
2710
- return {
2711
- ...taskResult,
2712
- recording
2713
- };
2714
- } catch (error) {
2715
- const errorRecording = {
2716
- id: taskResult.recordingId,
2717
- status: "ERROR",
2718
- error: error instanceof Error ? error.message : String(error),
2719
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2720
- getWebp: (options) => getWebp(taskResult.recordingId, config, options),
2721
- getErrors: () => getErrors(taskResult.recordingId, config)
2722
- };
2723
- return {
2724
- ...taskResult,
2725
- recording: errorRecording
2726
- };
2727
- }
2728
- }
2729
- return taskResult;
2730
- }
2731
- async function getErrors(recordingId, config = {}) {
2732
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2733
- const debug = config.debug || false;
2734
- if (!config.apiKey) {
2735
- throw new Error("API key required for getErrors");
2736
- }
2737
- if (debug) console.log(`[Browser] getErrors: ${recordingId}`);
2738
- const response = await fetch(`${apiUrl}/recordings/${recordingId}/errors`, {
2739
- method: "GET",
2740
- headers: { "Authorization": `Bearer ${config.apiKey}` }
2741
- });
2742
- if (!response.ok) {
2743
- const errorText = await response.text().catch(() => response.statusText);
2744
- if (debug) console.error(`[Browser] getErrors error: ${response.status} - ${errorText}`);
2745
- throw new Error(`HTTP ${response.status}: ${errorText}`);
2746
- }
2747
- const errors = mapErrorsResponse(await response.json());
2748
- if (debug) console.log(`[Browser] Found ${errors.totalErrors} errors`);
2749
- return errors;
2750
- }
2751
- function stringifyStructuredOutput(schema) {
2752
- try {
2753
- return JSON.stringify({
2754
- type: "object",
2755
- description: "Zod schema definition (Zod v3)",
2756
- zodDef: schema._def
2757
- });
2758
- } catch (error) {
2759
- console.warn("[Browser] Failed to serialize Zod schema:", error);
2760
- return JSON.stringify({
2761
- type: "object",
2762
- description: "Schema serialization failed"
2763
- });
2764
- }
2765
- }
2766
- function parseStructuredTaskOutput(result, schema) {
2767
- if (!result.output) {
2768
- return { ...result, parsed: null };
2769
- }
2770
- try {
2771
- const parsed = JSON.parse(result.output);
2772
- const validated = schema.parse(parsed);
2773
- return { ...result, parsed: validated };
2774
- } catch (error) {
2775
- if (error instanceof SyntaxError) {
2776
- return { ...result, parsed: null };
2777
- }
2778
- throw error;
2779
- }
2780
- }
2781
- function mapTaskResult(api) {
2782
- if (!api || typeof api !== "object") {
2783
- return api;
2784
- }
2785
- return {
2786
- success: api.success,
2787
- result: api.result,
2788
- error: api.error,
2789
- stepsTaken: api.steps_taken,
2790
- executionTimeMs: api.execution_time_ms,
2791
- urls: api.urls,
2792
- actionNames: api.action_names,
2793
- errors: api.errors,
2794
- modelActions: api.model_actions,
2795
- isDone: api.is_done,
2796
- actionHistory: api.action_history,
2797
- actionResults: api.action_results,
2798
- hasErrors: api.has_errors,
2799
- numberOfSteps: api.number_of_steps,
2800
- judgement: api.judgement,
2801
- isValidated: api.is_validated,
2802
- replayId: api.replay_id,
2803
- replayUrl: api.replay_url,
2804
- recordingId: api.recording_id,
2805
- recordingStatus: api.recording_status,
2806
- taskId: api.task_id,
2807
- status: api.status,
2808
- output: api.output,
2809
- debugUrl: api.debug_url
2810
- };
2811
- }
2812
- function mapRecordingStatus(api) {
2813
- return {
2814
- id: api.id,
2815
- status: api.status,
2816
- replayUrl: api.replay_url,
2817
- networkUrl: api.network_url,
2818
- consoleUrl: api.console_url,
2819
- videoUrl: api.video_url,
2820
- result: api.result,
2821
- totalEvents: api.total_events,
2822
- fileSize: api.file_size,
2823
- duration: api.duration,
2824
- error: api.error,
2825
- createdAt: api.created_at
2826
- };
2827
- }
2828
- function mapBrowserError(api) {
2829
- return {
2830
- type: api.type,
2831
- message: api.message,
2832
- url: api.url,
2833
- timestamp: api.timestamp,
2834
- screenshotUrl: api.screenshot_url,
2835
- capturedAt: api.captured_at,
2836
- status: api.status
2837
- };
2838
- }
2839
- function mapErrorsResponse(api) {
2840
- return {
2841
- recordingId: api.recording_id,
2842
- totalErrors: api.total_errors,
2843
- errors: Array.isArray(api.errors) ? api.errors.map(mapBrowserError) : []
2844
- };
2845
- }
2846
- function mapWebpResponse(api) {
2847
- return {
2848
- webpUrl: api.webp_url,
2849
- cached: api.cached,
2850
- width: api.width,
2851
- fps: api.fps,
2852
- maxDuration: api.max_duration,
2853
- fileSize: api.file_size,
2854
- maxSizeMb: api.max_size_mb,
2855
- budgetMet: api.budget_met,
2856
- qualityUsed: api.quality_used,
2857
- attempts: api.attempts
2858
- };
2859
- }
2860
- async function getTaskStatus(taskId, config) {
2861
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2862
- const debug = config.debug || false;
2863
- if (debug) console.log(`[Browser] getTaskStatus: ${taskId}`);
2864
- const headers = {};
2865
- if (config.apiKey) headers["Authorization"] = `Bearer ${config.apiKey}`;
2866
- const response = await fetch(`${apiUrl}/tasks/${taskId}`, {
2867
- method: "GET",
2868
- headers
2869
- });
2870
- if (!response.ok) {
2871
- const errorText = await response.text().catch(() => response.statusText);
2872
- if (debug) console.error(`[Browser] getTaskStatus error: ${response.status} - ${errorText}`);
2873
- throw new Error(`HTTP ${response.status}: ${errorText}`);
2874
- }
2875
- const result = mapTaskResult(await response.json());
2876
- if (debug) console.log(`[Browser] Task status: ${result.status}`);
2877
- return result;
2878
- }
2879
- function generateLiveUrl(taskId, config) {
2880
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2881
- const baseUrl = apiUrl.replace("/api", "");
2882
- return `${baseUrl}/tasks/${taskId}/live`;
2883
- }
2884
- async function pollTaskUntilComplete(taskId, config, pollConfig = {}) {
2885
- const interval = pollConfig.interval ?? 2e3;
2886
- const timeout = pollConfig.timeout ?? 3e5;
2887
- const startTime = Date.now();
2888
- while (Date.now() - startTime < timeout) {
2889
- const status = await getTaskStatus(taskId, config);
2890
- if (status.status === "completed" || status.status === "failed") {
2891
- return status;
2892
- }
2893
- await new Promise((resolve2) => setTimeout(resolve2, interval));
2894
- }
2895
- throw new Error(`Task polling timeout after ${timeout}ms`);
2896
- }
2897
- function wrapTaskResponse(result, config) {
2898
- const debugUrl = result.debugUrl ?? "";
2899
- const wrapped = {
2900
- ...result,
2901
- debugUrl,
2902
- taskId: result.taskId || "",
2903
- liveUrl: result.taskId ? generateLiveUrl(result.taskId, config) : debugUrl,
2904
- complete: async (pollConfig) => {
2905
- if (result.taskId) {
2906
- return pollTaskUntilComplete(result.taskId, config, pollConfig);
2907
- }
2908
- if (result.recordingId) {
2909
- const recording = await waitForRecording(
2910
- result.recordingId,
2911
- config,
2912
- pollConfig
2913
- );
2914
- return {
2915
- ...result,
2916
- recordingStatus: recording.status
2917
- };
2918
- }
2919
- throw new Error("Cannot poll completion: no taskId or recordingId available");
2920
- },
2921
- // Add Steel live session helpers - either functional or error-throwing
2922
- getLiveUrl: debugUrl ? (options) => buildLiveUrl(debugUrl, options) : () => {
2923
- throw new Error(
2924
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
2925
- );
2926
- },
2927
- getLiveIframe: debugUrl ? (optionsOrPreset) => {
2928
- const options = resolvePreset(optionsOrPreset);
2929
- return buildLiveIframe(debugUrl, options);
2930
- } : () => {
2931
- throw new Error(
2932
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
2933
- );
2934
- },
2935
- getEmbedCode: debugUrl ? () => buildEmbedCode(debugUrl) : () => {
2936
- throw new Error(
2937
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
2938
- );
2939
- }
2940
- };
2941
- return wrapped;
2942
- }
2943
- function wrapTaskResponseWithSchema(result, config, schema) {
2944
- const debugUrl = result.debugUrl ?? "";
2945
- const parsed = result.output ? parseStructuredTaskOutput(result, schema) : { ...result, parsed: null };
2946
- const wrapped = {
2947
- ...parsed,
2948
- debugUrl,
2949
- taskId: result.taskId || "",
2950
- liveUrl: result.taskId ? generateLiveUrl(result.taskId, config) : debugUrl,
2951
- complete: async (pollConfig) => {
2952
- if (result.taskId) {
2953
- const finalResult = await pollTaskUntilComplete(result.taskId, config, pollConfig);
2954
- return parseStructuredTaskOutput(finalResult, schema);
2955
- }
2956
- if (result.recordingId) {
2957
- const recording = await waitForRecording(
2958
- result.recordingId,
2959
- config,
2960
- pollConfig
2961
- );
2962
- return {
2963
- ...parsed,
2964
- recordingStatus: recording.status
2965
- };
2966
- }
2967
- throw new Error("Cannot poll completion: no taskId or recordingId available");
2968
- },
2969
- // Add Steel live session helpers - either functional or error-throwing
2970
- getLiveUrl: debugUrl ? (options) => buildLiveUrl(debugUrl, options) : () => {
2971
- throw new Error(
2972
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions. "
2973
- );
2974
- },
2975
- getLiveIframe: debugUrl ? (optionsOrPreset) => {
2976
- const options = resolvePreset(optionsOrPreset);
2977
- return buildLiveIframe(debugUrl, options);
2978
- } : () => {
2979
- throw new Error(
2980
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions."
2981
- );
2982
- },
2983
- getEmbedCode: debugUrl ? () => buildEmbedCode(debugUrl) : () => {
2984
- throw new Error(
2985
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions."
2986
- );
2987
- }
2988
- };
2989
- return wrapped;
2990
- }
2991
- async function getWebp(recordingId, config = {}, options = {}) {
2992
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
2993
- const debug = config.debug || false;
2994
- if (!config.apiKey) {
2995
- throw new Error("API key required for getWebp");
2996
- }
2997
- const params = new URLSearchParams();
2998
- if (options.maxDuration !== void 0) params.set("max_duration", String(options.maxDuration));
2999
- if (options.fps !== void 0) params.set("fps", String(options.fps));
3000
- if (options.width !== void 0) params.set("width", String(options.width));
3001
- if (options.quality !== void 0) params.set("quality", String(options.quality));
3002
- if (options.maxSizeMb !== void 0) params.set("max_size_mb", String(options.maxSizeMb));
3003
- const url = `${apiUrl}/recordings/${recordingId}/webp${params.toString() ? "?" + params.toString() : ""}`;
3004
- if (debug) console.log(`[Browser] getWebp: ${url}`);
3005
- const response = await fetch(url, {
3006
- method: "GET",
3007
- headers: { "Authorization": `Bearer ${config.apiKey}` }
3008
- });
3009
- if (!response.ok) {
3010
- const errorText = await response.text().catch(() => response.statusText);
3011
- if (debug) console.error(`[Browser] getWebp error: ${response.status} - ${errorText}`);
3012
- throw new Error(`HTTP ${response.status}: ${errorText}`);
3013
- }
3014
- const result = mapWebpResponse(await response.json());
3015
- if (debug) console.log(`[Browser] WebP ready: ${result.webpUrl} (cached: ${result.cached})`);
3016
- return result;
3017
- }
3018
- async function checkHealth(config = {}) {
3019
- const apiUrl = config.apiUrl || DEFAULT_CONFIG2.apiUrl;
3020
- try {
3021
- const response = await fetch(`${apiUrl}/health`, {
3022
- method: "GET",
3023
- headers: config.apiKey ? { "Authorization": `Bearer ${config.apiKey}` } : {}
3024
- });
3025
- if (!response.ok) {
3026
- throw new Error(`HTTP ${response.status}`);
3027
- }
3028
- const data = await response.json();
3029
- return {
3030
- ok: true,
3031
- google_configured: data.google_configured ?? false,
3032
- database_configured: data.database_configured ?? false,
3033
- s3_configured: data.s3_configured ?? false
3034
- };
3035
- } catch (error) {
3036
- return {
3037
- ok: false,
3038
- google_configured: false,
3039
- database_configured: false,
3040
- s3_configured: false,
3041
- error: error instanceof Error ? error.message : String(error)
3042
- };
3043
- }
3044
- }
3045
-
3046
1761
  // tools/warp_grep/agent/runner.ts
3047
1762
  init_config();
3048
1763
 
@@ -3352,7 +2067,7 @@ var import_openai2 = __toESM(require("openai"), 1);
3352
2067
  init_version();
3353
2068
  var import_path4 = __toESM(require("path"), 1);
3354
2069
  init_logger();
3355
- var DEFAULT_API_URL3 = "https://api.morphllm.com";
2070
+ var DEFAULT_API_URL2 = "https://api.morphllm.com";
3356
2071
  var TOOL_SPECS = [
3357
2072
  {
3358
2073
  type: "function",
@@ -3461,7 +2176,7 @@ var TOOL_SPECS = [
3461
2176
  }
3462
2177
  ];
3463
2178
  async function callModel(messages, model, options = {}) {
3464
- const baseUrl = options.morphApiUrl || DEFAULT_API_URL3;
2179
+ const baseUrl = options.morphApiUrl || DEFAULT_API_URL2;
3465
2180
  const apiKey = options.morphApiKey || process.env.MORPH_API_KEY || "";
3466
2181
  const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
3467
2182
  const parsedUrl = new URL(baseUrl);
@@ -4015,13 +2730,13 @@ function parseGitHubUrl(input) {
4015
2730
  }
4016
2731
 
4017
2732
  // tools/compact/core.ts
4018
- var DEFAULT_API_URL4 = "https://api.morphllm.com";
2733
+ var DEFAULT_API_URL3 = "https://api.morphllm.com";
4019
2734
  var DEFAULT_TIMEOUT4 = 12e4;
4020
2735
  function resolveClient(clientOrConfig) {
4021
2736
  if (clientOrConfig instanceof MorphAPIClient) return clientOrConfig;
4022
2737
  return new MorphAPIClient({
4023
2738
  apiKey: clientOrConfig.morphApiKey,
4024
- baseURL: clientOrConfig.morphApiUrl ?? DEFAULT_API_URL4,
2739
+ baseURL: clientOrConfig.morphApiUrl ?? DEFAULT_API_URL3,
4025
2740
  timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT4,
4026
2741
  retryConfig: clientOrConfig.retryConfig,
4027
2742
  debug: clientOrConfig.debug
@@ -4402,357 +3117,16 @@ function formatResult(result) {
4402
3117
  return parts.join("\n");
4403
3118
  }
4404
3119
 
4405
- // tools/github/types.ts
4406
- var GitHubError = class extends Error {
4407
- /** HTTP status code */
4408
- status;
4409
- /** Error code from API */
4410
- code;
4411
- constructor(message, status, code) {
4412
- super(message);
4413
- this.name = "GitHubError";
4414
- this.status = status;
4415
- this.code = code;
4416
- }
4417
- };
4418
- var NoInstallationError = class extends GitHubError {
4419
- constructor(message = "No GitHub installation found. Connect GitHub at morphllm.com/dashboard/integrations/github") {
4420
- super(message, 404, "NO_INSTALLATION");
4421
- }
4422
- };
4423
- var NotFoundError = class extends GitHubError {
4424
- constructor(resource) {
4425
- super(`${resource} not found`, 404, "NOT_FOUND");
4426
- }
4427
- };
4428
- var PermissionError = class extends GitHubError {
4429
- constructor(message = "Insufficient permissions for this operation") {
4430
- super(message, 403, "PERMISSION_DENIED");
4431
- }
4432
- };
4433
-
4434
- // tools/github/core.ts
4435
- var DEFAULT_BASE_URL2 = "https://api.morphllm.com";
4436
- var DEFAULT_TIMEOUT5 = 3e4;
4437
- var GitHubClient = class extends APIResource {
4438
- timeout;
4439
- debug;
4440
- defaultInstallationId;
4441
- /** Installation operations */
4442
- installations;
4443
- /** Repository operations */
4444
- repos;
4445
- /** Project operations (monorepo sub-projects) */
4446
- projects;
4447
- /** Pull request operations */
4448
- pullRequests;
4449
- /** Deployment operations */
4450
- deployments;
4451
- /** Comment operations */
4452
- comments;
4453
- /** Check run operations */
4454
- checkRuns;
4455
- /**
4456
- * Get the GitHub App installation URL.
4457
- * Users visit this URL once to install the Morph GitHub App on their account/org.
4458
- */
4459
- getInstallUrl() {
4460
- return "https://github.com/apps/morph-subagents/installations/new";
4461
- }
4462
- constructor(clientOrConfig = {}, options = {}) {
4463
- const isClient = clientOrConfig instanceof MorphAPIClient;
4464
- const config = isClient ? {} : clientOrConfig;
4465
- super(
4466
- isClient ? clientOrConfig : new MorphAPIClient({
4467
- apiKey: config.apiKey,
4468
- baseURL: config.baseUrl ?? DEFAULT_BASE_URL2,
4469
- timeout: config.timeout ?? DEFAULT_TIMEOUT5,
4470
- debug: config.debug
4471
- })
4472
- );
4473
- this.timeout = config.timeout || DEFAULT_TIMEOUT5;
4474
- this.debug = config.debug || false;
4475
- this.defaultInstallationId = isClient ? options.installationId : config.installationId;
4476
- if (!this._client.resolveApiKey()) {
4477
- throw new Error("API key required. Set MORPH_API_KEY or pass apiKey in config.");
4478
- }
4479
- this.installations = {
4480
- list: this.listInstallations.bind(this),
4481
- get: this.getInstallation.bind(this),
4482
- update: this.updateInstallation.bind(this),
4483
- disconnect: this.disconnectInstallation.bind(this)
4484
- };
4485
- this.repos = {
4486
- list: this.listRepos.bind(this),
4487
- get: this.getRepo.bind(this),
4488
- update: this.updateRepo.bind(this),
4489
- remove: this.removeRepo.bind(this),
4490
- sync: this.syncRepos.bind(this)
4491
- };
4492
- this.projects = {
4493
- list: this.listProjects.bind(this),
4494
- create: this.createProject.bind(this),
4495
- update: this.updateProject.bind(this),
4496
- delete: this.deleteProject.bind(this)
4497
- };
4498
- this.pullRequests = {
4499
- list: this.listPullRequests.bind(this),
4500
- get: this.getPullRequest.bind(this)
4501
- };
4502
- this.deployments = {
4503
- list: this.listDeployments.bind(this)
4504
- };
4505
- this.comments = {
4506
- list: this.listComments.bind(this),
4507
- create: this.createComment.bind(this),
4508
- update: this.updateComment.bind(this),
4509
- delete: this.deleteComment.bind(this)
4510
- };
4511
- this.checkRuns = {
4512
- create: this.createCheckRun.bind(this),
4513
- update: this.updateCheckRun.bind(this)
4514
- };
4515
- }
4516
- /**
4517
- * Make an authenticated API request
4518
- */
4519
- async request(method, path6, body) {
4520
- if (this.debug) {
4521
- console.log(`[GitHub SDK] ${method} ${path6}`, body || "");
4522
- }
4523
- let response;
4524
- try {
4525
- response = await this._client.request(method, path6, {
4526
- body,
4527
- timeout: this.timeout,
4528
- raw: true
4529
- });
4530
- } catch (error) {
4531
- if (error instanceof Error && /timed out/i.test(error.message)) {
4532
- throw new GitHubError("Request timeout", 408, "TIMEOUT");
4533
- }
4534
- throw new GitHubError(error instanceof Error ? error.message : "Unknown error", 500, "UNKNOWN");
4535
- }
4536
- if (!response.ok) {
4537
- const errorData = await response.json().catch(() => ({}));
4538
- const message = errorData.error || errorData.detail || errorData.message || response.statusText;
4539
- if (this.debug) {
4540
- console.error(`[GitHub SDK] Error ${response.status}:`, message);
4541
- }
4542
- if (response.status === 404) {
4543
- if (message.includes("installation")) {
4544
- throw new NoInstallationError(message);
4545
- }
4546
- throw new NotFoundError(message);
4547
- }
4548
- if (response.status === 403) {
4549
- throw new PermissionError(message);
4550
- }
4551
- throw new GitHubError(message, response.status, errorData.code);
4552
- }
4553
- const data = await response.json();
4554
- if (this.debug) {
4555
- console.log(`[GitHub SDK] Response:`, JSON.stringify(data).slice(0, 200));
4556
- }
4557
- return data;
4558
- }
4559
- /**
4560
- * Get the installation ID to use for a request
4561
- */
4562
- getInstallationId(input) {
4563
- return input?.installationId || this.defaultInstallationId;
4564
- }
4565
- // ==========================================================================
4566
- // Installations
4567
- // ==========================================================================
4568
- async listInstallations() {
4569
- return this.request("GET", "/api/v1/github/installations");
4570
- }
4571
- async getInstallation(installationId) {
4572
- return this.request("GET", `/api/v1/github/installations/${installationId}`);
4573
- }
4574
- async updateInstallation(input) {
4575
- if (this.debug) console.log("[GitHub SDK] updateInstallation", input.installationId);
4576
- const { installationId, ...body } = input;
4577
- return this.request("PATCH", `/api/v1/github/installations/${installationId}`, body);
4578
- }
4579
- async disconnectInstallation(installationId) {
4580
- if (this.debug) console.log("[GitHub SDK] disconnectInstallation", installationId);
4581
- return this.request("DELETE", `/api/v1/github/installations/${installationId}`);
4582
- }
4583
- // ==========================================================================
4584
- // Repositories
4585
- // ==========================================================================
4586
- async listRepos(input) {
4587
- const installationId = input.installationId || this.defaultInstallationId;
4588
- if (!installationId) {
4589
- throw new NoInstallationError("installationId required. Call installations.list() first.");
4590
- }
4591
- return this.request("GET", `/api/v1/github/installations/${installationId}/repos`);
4592
- }
4593
- async getRepo(repoId) {
4594
- if (this.debug) console.log("[GitHub SDK] getRepo", repoId);
4595
- return this.request("GET", `/api/v1/github/repos/${repoId}`);
4596
- }
4597
- async updateRepo(input) {
4598
- if (this.debug) console.log("[GitHub SDK] updateRepo", input.repoId);
4599
- const { repoId, ...body } = input;
4600
- return this.request("PATCH", `/api/v1/github/repos/${repoId}`, body);
4601
- }
4602
- async removeRepo(repoId) {
4603
- if (this.debug) console.log("[GitHub SDK] removeRepo", repoId);
4604
- return this.request("DELETE", `/api/v1/github/repos/${repoId}`);
4605
- }
4606
- async syncRepos(input) {
4607
- const installationId = input.installationId || this.defaultInstallationId;
4608
- if (!installationId) {
4609
- throw new NoInstallationError("installationId required. Call installations.list() first.");
4610
- }
4611
- if (this.debug) console.log("[GitHub SDK] syncRepos", installationId);
4612
- return this.request("POST", `/api/v1/github/installations/${installationId}/repos/sync`);
4613
- }
4614
- // ==========================================================================
4615
- // Projects (monorepo sub-projects)
4616
- // ==========================================================================
4617
- async listProjects(input) {
4618
- if (this.debug) console.log("[GitHub SDK] listProjects", input.repoId);
4619
- return this.request("GET", `/api/v1/github/repos/${input.repoId}/projects`);
4620
- }
4621
- async createProject(input) {
4622
- if (this.debug) console.log("[GitHub SDK] createProject", input.repoId, input.name);
4623
- const { repoId, ...body } = input;
4624
- return this.request("POST", `/api/v1/github/repos/${repoId}/projects`, body);
4625
- }
4626
- async updateProject(input) {
4627
- if (this.debug) console.log("[GitHub SDK] updateProject", input.projectId);
4628
- const { projectId, ...body } = input;
4629
- return this.request("PATCH", `/api/v1/github/projects/${projectId}`, body);
4630
- }
4631
- async deleteProject(projectId) {
4632
- if (this.debug) console.log("[GitHub SDK] deleteProject", projectId);
4633
- return this.request("DELETE", `/api/v1/github/projects/${projectId}`);
4634
- }
4635
- // ==========================================================================
4636
- // Pull Requests
4637
- // ==========================================================================
4638
- async listPullRequests(input) {
4639
- const installationId = this.getInstallationId(input);
4640
- const params = new URLSearchParams({
4641
- owner: input.owner,
4642
- repo: input.repo,
4643
- ...input.state && { state: input.state },
4644
- ...installationId && { installationId }
4645
- });
4646
- return this.request("GET", `/api/v1/github/pulls?${params}`);
4647
- }
4648
- async getPullRequest(input) {
4649
- const installationId = this.getInstallationId(input);
4650
- const params = new URLSearchParams({
4651
- owner: input.owner,
4652
- repo: input.repo,
4653
- ...installationId && { installationId }
4654
- });
4655
- return this.request(
4656
- "GET",
4657
- `/api/v1/github/pulls/${input.number}?${params}`
4658
- );
4659
- }
4660
- // ==========================================================================
4661
- // Deployments
4662
- // ==========================================================================
4663
- async listDeployments(input) {
4664
- const installationId = this.getInstallationId(input);
4665
- const params = new URLSearchParams({
4666
- owner: input.owner,
4667
- repo: input.repo,
4668
- ...input.sha && { sha: input.sha },
4669
- ...input.environment && { environment: input.environment },
4670
- ...installationId && { installationId }
4671
- });
4672
- return this.request("GET", `/api/v1/github/deployments?${params}`);
4673
- }
4674
- // ==========================================================================
4675
- // Comments
4676
- // ==========================================================================
4677
- async listComments(input) {
4678
- const installationId = this.getInstallationId(input);
4679
- const params = new URLSearchParams({
4680
- owner: input.owner,
4681
- repo: input.repo,
4682
- pr: String(input.pr),
4683
- ...installationId && { installationId }
4684
- });
4685
- return this.request("GET", `/api/v1/github/comments?${params}`);
4686
- }
4687
- async createComment(input) {
4688
- const installationId = this.getInstallationId(input);
4689
- return this.request("POST", "/api/v1/github/comments", {
4690
- owner: input.owner,
4691
- repo: input.repo,
4692
- pr: input.pr,
4693
- body: input.body,
4694
- ...installationId && { installationId }
4695
- });
4696
- }
4697
- async updateComment(input) {
4698
- const installationId = this.getInstallationId(input);
4699
- return this.request("PATCH", `/api/v1/github/comments/${input.commentId}`, {
4700
- owner: input.owner,
4701
- repo: input.repo,
4702
- body: input.body,
4703
- ...installationId && { installationId }
4704
- });
4705
- }
4706
- async deleteComment(input) {
4707
- const installationId = this.getInstallationId(input);
4708
- const params = new URLSearchParams({
4709
- owner: input.owner,
4710
- repo: input.repo,
4711
- ...installationId && { installationId }
4712
- });
4713
- await this.request("DELETE", `/api/v1/github/comments/${input.commentId}?${params}`);
4714
- }
4715
- // ==========================================================================
4716
- // Check Runs
4717
- // ==========================================================================
4718
- async createCheckRun(input) {
4719
- const installationId = this.getInstallationId(input);
4720
- return this.request("POST", "/api/v1/github/check-runs", {
4721
- owner: input.owner,
4722
- repo: input.repo,
4723
- sha: input.sha,
4724
- name: input.name,
4725
- status: input.status,
4726
- ...input.title && { title: input.title },
4727
- ...input.summary && { summary: input.summary },
4728
- ...installationId && { installationId }
4729
- });
4730
- }
4731
- async updateCheckRun(input) {
4732
- const installationId = this.getInstallationId(input);
4733
- return this.request("PATCH", `/api/v1/github/check-runs/${input.checkRunId}`, {
4734
- owner: input.owner,
4735
- repo: input.repo,
4736
- ...input.status && { status: input.status },
4737
- ...input.conclusion && { conclusion: input.conclusion },
4738
- ...input.title && { title: input.title },
4739
- ...input.summary && { summary: input.summary },
4740
- ...input.text && { text: input.text },
4741
- ...installationId && { installationId }
4742
- });
4743
- }
4744
- };
4745
-
4746
3120
  // modelrouter/core.ts
4747
3121
  init_logger();
4748
- var DEFAULT_API_URL5 = "https://api.morphllm.com";
4749
- var DEFAULT_TIMEOUT6 = 5e3;
3122
+ var DEFAULT_API_URL4 = "https://api.morphllm.com";
3123
+ var DEFAULT_TIMEOUT5 = 5e3;
4750
3124
  function resolveClient2(clientOrConfig) {
4751
3125
  if (clientOrConfig instanceof MorphAPIClient) return clientOrConfig;
4752
3126
  return new MorphAPIClient({
4753
3127
  apiKey: clientOrConfig.apiKey,
4754
- baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL5,
4755
- timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT6,
3128
+ baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL4,
3129
+ timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT5,
4756
3130
  retryConfig: clientOrConfig.retryConfig,
4757
3131
  debug: clientOrConfig.debug
4758
3132
  });
@@ -4764,7 +3138,7 @@ var BaseRouter = class extends APIResource {
4764
3138
  super(resolveClient2(clientOrConfig));
4765
3139
  this.provider = provider;
4766
3140
  const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;
4767
- this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT6;
3141
+ this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT5;
4768
3142
  }
4769
3143
  /** Throw the historical "API key is required" message when no key is resolvable. */
4770
3144
  requireApiKey() {
@@ -4870,7 +3244,7 @@ var RouterClassifier = class extends APIResource {
4870
3244
  constructor(clientOrConfig = {}) {
4871
3245
  super(resolveClient2(clientOrConfig));
4872
3246
  const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;
4873
- this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT6;
3247
+ this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT5;
4874
3248
  }
4875
3249
  /** Classify an input across the requested axes (all three by default). */
4876
3250
  async classify(input) {
@@ -6288,10 +4662,6 @@ var MorphClient = class extends MorphAPIClient {
6288
4662
  codebaseSearch;
6289
4663
  /** WarpGrep tool for fast code search using ripgrep */
6290
4664
  warpGrep;
6291
- /** Browser tool for AI-powered browser automation */
6292
- browser;
6293
- /** GitHub tool for PR context, comments, and check runs */
6294
- github;
6295
4665
  /** Model routers for intelligent model selection */
6296
4666
  routers;
6297
4667
  /** OpenAI-compatible tool factories */
@@ -6331,8 +4701,6 @@ var MorphClient = class extends MorphAPIClient {
6331
4701
  this.fastApply = new FastApplyClient(this);
6332
4702
  this.codebaseSearch = new CodebaseSearchClient(this);
6333
4703
  this.warpGrep = new WarpGrepClient(this);
6334
- this.browser = new BrowserClient(this);
6335
- this.github = new GitHubClient(this, { installationId: config.github?.installationId });
6336
4704
  this.routers = {
6337
4705
  openai: new OpenAIRouter(this),
6338
4706
  anthropic: new AnthropicRouter(this),