@morphllm/morphsdk 0.2.197 → 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 (301) hide show
  1. package/README.md +1 -147
  2. package/dist/{chunk-GE5MNVT7.js → chunk-5KQ2WRBU.js} +2 -2
  3. package/dist/{chunk-LKFZBBTD.js → chunk-5TOJD2C5.js} +1 -1
  4. package/dist/chunk-5TOJD2C5.js.map +1 -0
  5. package/dist/{chunk-PQCOBN7L.js → chunk-7UU4NF4G.js} +4 -10
  6. package/dist/chunk-7UU4NF4G.js.map +1 -0
  7. package/dist/{chunk-6YZCPCAY.js → chunk-BLCCGRKT.js} +2 -2
  8. package/dist/{chunk-2BT4UGKH.js → chunk-BTMMUG3E.js} +2 -2
  9. package/dist/{chunk-VJD6MF3M.js → chunk-CEXBKXWU.js} +4 -4
  10. package/dist/{chunk-UOS3XKJD.js → chunk-DP2PT36G.js} +2 -2
  11. package/dist/{chunk-CZ74CRGH.js → chunk-EMURAU6J.js} +4 -6
  12. package/dist/chunk-EMURAU6J.js.map +1 -0
  13. package/dist/chunk-GKRPR5PZ.js +322 -0
  14. package/dist/chunk-GKRPR5PZ.js.map +1 -0
  15. package/dist/{chunk-DNL4DMMS.js → chunk-GTV27THY.js} +2 -2
  16. package/dist/{chunk-ATAKRJQZ.js → chunk-IDMKQWQG.js} +1 -36
  17. package/dist/chunk-IDMKQWQG.js.map +1 -0
  18. package/dist/{chunk-EGI642TV.js → chunk-JOC3ZI56.js} +3 -39
  19. package/dist/chunk-JOC3ZI56.js.map +1 -0
  20. package/dist/{chunk-VGCPVDFP.js → chunk-K2JR2NFQ.js} +4 -4
  21. package/dist/{chunk-DHGXGVHC.js → chunk-KXEPBLVD.js} +8 -8
  22. package/dist/{chunk-SVD3YRWM.js → chunk-MEZTHMB2.js} +4 -4
  23. package/dist/{chunk-BECYWCEZ.js → chunk-O7LJEVZO.js} +2 -2
  24. package/dist/{chunk-7QOGUY4A.js → chunk-PKJ7ODTG.js} +4 -4
  25. package/dist/{chunk-2HXELZI5.js → chunk-PW6K6OJL.js} +2 -2
  26. package/dist/chunk-PW6K6OJL.js.map +1 -0
  27. package/dist/{chunk-YVKRPVOM.js → chunk-Q3NH3NPD.js} +2 -2
  28. package/dist/{chunk-ZA3UJRSE.js → chunk-RL3ZTXT3.js} +4 -4
  29. package/dist/{chunk-WN6YLBEH.js → chunk-ULHHMZRL.js} +4 -4
  30. package/dist/{chunk-TJUZAO7T.js → chunk-UT3NQLCF.js} +2 -2
  31. package/dist/{chunk-DW6ZIVCM.js → chunk-VS5F2ORN.js} +4 -4
  32. package/dist/{chunk-UZA2ODNU.js → chunk-W37OFBSG.js} +2 -2
  33. package/dist/{chunk-JU6TCHVI.js → chunk-WDBYAXZ5.js} +2 -2
  34. package/dist/{chunk-2XDSHAB5.js → chunk-YSFEKIYQ.js} +2 -2
  35. package/dist/{chunk-WDLDKJHT.js → chunk-ZHB57ORD.js} +6 -6
  36. package/dist/client-CGW0Cevz.d.ts +402 -0
  37. package/dist/client.cjs +195 -2068
  38. package/dist/client.cjs.map +1 -1
  39. package/dist/client.d.ts +3 -11
  40. package/dist/client.js +28 -35
  41. package/dist/core/client.cjs +2 -44
  42. package/dist/core/client.cjs.map +1 -1
  43. package/dist/core/client.d.ts +2 -10
  44. package/dist/core/client.js +4 -4
  45. package/dist/core/error.cjs +2 -38
  46. package/dist/core/error.cjs.map +1 -1
  47. package/dist/core/error.d.ts +1 -1
  48. package/dist/core/error.js +3 -3
  49. package/dist/core/index.cjs +2 -44
  50. package/dist/core/index.cjs.map +1 -1
  51. package/dist/core/index.js +5 -5
  52. package/dist/core/resource.cjs.map +1 -1
  53. package/dist/core/resource.d.ts +1 -1
  54. package/dist/core/resource.js +1 -1
  55. package/dist/edge.cjs +2 -44
  56. package/dist/edge.cjs.map +1 -1
  57. package/dist/edge.js +8 -8
  58. package/dist/index.cjs +195 -2086
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.ts +1 -9
  61. package/dist/index.js +30 -58
  62. package/dist/modelrouter/core.cjs +2 -44
  63. package/dist/modelrouter/core.cjs.map +1 -1
  64. package/dist/modelrouter/core.js +6 -6
  65. package/dist/modelrouter/index.cjs +2 -44
  66. package/dist/modelrouter/index.cjs.map +1 -1
  67. package/dist/modelrouter/index.js +6 -6
  68. package/dist/subagents/anthropic.cjs +2 -44
  69. package/dist/subagents/anthropic.cjs.map +1 -1
  70. package/dist/subagents/anthropic.js +12 -12
  71. package/dist/subagents/vercel.cjs +2 -44
  72. package/dist/subagents/vercel.cjs.map +1 -1
  73. package/dist/subagents/vercel.js +12 -12
  74. package/dist/tools/codebase_search/anthropic.cjs +2 -44
  75. package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
  76. package/dist/tools/codebase_search/anthropic.js +7 -7
  77. package/dist/tools/codebase_search/core.cjs +2 -44
  78. package/dist/tools/codebase_search/core.cjs.map +1 -1
  79. package/dist/tools/codebase_search/core.js +6 -6
  80. package/dist/tools/codebase_search/index.cjs +2 -44
  81. package/dist/tools/codebase_search/index.cjs.map +1 -1
  82. package/dist/tools/codebase_search/index.js +11 -11
  83. package/dist/tools/codebase_search/openai.cjs +2 -44
  84. package/dist/tools/codebase_search/openai.cjs.map +1 -1
  85. package/dist/tools/codebase_search/openai.js +7 -7
  86. package/dist/tools/codebase_search/vercel.cjs +2 -44
  87. package/dist/tools/codebase_search/vercel.cjs.map +1 -1
  88. package/dist/tools/codebase_search/vercel.js +7 -7
  89. package/dist/tools/compact/core.cjs +2 -44
  90. package/dist/tools/compact/core.cjs.map +1 -1
  91. package/dist/tools/compact/core.js +6 -6
  92. package/dist/tools/compact/index.cjs +2 -44
  93. package/dist/tools/compact/index.cjs.map +1 -1
  94. package/dist/tools/compact/index.js +7 -7
  95. package/dist/tools/fastapply/anthropic.cjs +2 -38
  96. package/dist/tools/fastapply/anthropic.cjs.map +1 -1
  97. package/dist/tools/fastapply/anthropic.js +8 -8
  98. package/dist/tools/fastapply/apply.cjs +2 -38
  99. package/dist/tools/fastapply/apply.cjs.map +1 -1
  100. package/dist/tools/fastapply/apply.js +2 -2
  101. package/dist/tools/fastapply/core.cjs +2 -44
  102. package/dist/tools/fastapply/core.cjs.map +1 -1
  103. package/dist/tools/fastapply/core.js +7 -7
  104. package/dist/tools/fastapply/index.cjs +2 -38
  105. package/dist/tools/fastapply/index.cjs.map +1 -1
  106. package/dist/tools/fastapply/index.js +12 -12
  107. package/dist/tools/fastapply/openai.cjs +2 -38
  108. package/dist/tools/fastapply/openai.cjs.map +1 -1
  109. package/dist/tools/fastapply/openai.js +8 -8
  110. package/dist/tools/fastapply/vercel.cjs +2 -38
  111. package/dist/tools/fastapply/vercel.cjs.map +1 -1
  112. package/dist/tools/fastapply/vercel.js +8 -8
  113. package/dist/tools/index.cjs +2 -38
  114. package/dist/tools/index.cjs.map +1 -1
  115. package/dist/tools/index.js +12 -12
  116. package/dist/tools/utils/resilience.cjs +2 -38
  117. package/dist/tools/utils/resilience.cjs.map +1 -1
  118. package/dist/tools/utils/resilience.js +2 -2
  119. package/dist/tools/warp_grep/agent/runner.cjs +2 -38
  120. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  121. package/dist/tools/warp_grep/agent/runner.js +3 -3
  122. package/dist/tools/warp_grep/anthropic.cjs +2 -44
  123. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  124. package/dist/tools/warp_grep/anthropic.js +12 -12
  125. package/dist/tools/warp_grep/client.cjs +2 -44
  126. package/dist/tools/warp_grep/client.cjs.map +1 -1
  127. package/dist/tools/warp_grep/client.js +11 -11
  128. package/dist/tools/warp_grep/gemini.cjs +2 -44
  129. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  130. package/dist/tools/warp_grep/gemini.js +11 -11
  131. package/dist/tools/warp_grep/harness.js +7 -7
  132. package/dist/tools/warp_grep/index.cjs +2 -44
  133. package/dist/tools/warp_grep/index.cjs.map +1 -1
  134. package/dist/tools/warp_grep/index.js +14 -14
  135. package/dist/tools/warp_grep/openai.cjs +2 -44
  136. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  137. package/dist/tools/warp_grep/openai.js +12 -12
  138. package/dist/tools/warp_grep/vercel.cjs +2 -44
  139. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  140. package/dist/tools/warp_grep/vercel.js +12 -12
  141. package/dist/tracing/core.cjs +2 -34
  142. package/dist/tracing/core.cjs.map +1 -1
  143. package/dist/tracing/core.d.ts +1 -2
  144. package/dist/tracing/core.js +2 -2
  145. package/dist/tracing/index.cjs +4 -42
  146. package/dist/tracing/index.cjs.map +1 -1
  147. package/dist/tracing/index.d.ts +0 -34
  148. package/dist/tracing/index.js +3 -10
  149. package/dist/tracing/interaction.cjs +0 -30
  150. package/dist/tracing/interaction.cjs.map +1 -1
  151. package/dist/tracing/interaction.js +1 -1
  152. package/dist/tracing/types.cjs.map +1 -1
  153. package/dist/tracing/types.d.ts +1 -27
  154. package/dist/version.cjs +2 -38
  155. package/dist/version.cjs.map +1 -1
  156. package/dist/version.js +1 -1
  157. package/package.json +2 -38
  158. package/dist/anthropic-B6my2oBx.d.ts +0 -56
  159. package/dist/chunk-2AMEQAO2.js +0 -46
  160. package/dist/chunk-2AMEQAO2.js.map +0 -1
  161. package/dist/chunk-2HMEZZKK.js +0 -44
  162. package/dist/chunk-2HMEZZKK.js.map +0 -1
  163. package/dist/chunk-2HXELZI5.js.map +0 -1
  164. package/dist/chunk-2VERUKO2.js +0 -177
  165. package/dist/chunk-2VERUKO2.js.map +0 -1
  166. package/dist/chunk-4FWK3CEH.js +0 -692
  167. package/dist/chunk-4FWK3CEH.js.map +0 -1
  168. package/dist/chunk-ATAKRJQZ.js.map +0 -1
  169. package/dist/chunk-CZ74CRGH.js.map +0 -1
  170. package/dist/chunk-EGI642TV.js.map +0 -1
  171. package/dist/chunk-FLWBVHDC.js +0 -622
  172. package/dist/chunk-FLWBVHDC.js.map +0 -1
  173. package/dist/chunk-JZJY2XFQ.js +0 -96
  174. package/dist/chunk-JZJY2XFQ.js.map +0 -1
  175. package/dist/chunk-LKFZBBTD.js.map +0 -1
  176. package/dist/chunk-LRHJVSSD.js +0 -57
  177. package/dist/chunk-LRHJVSSD.js.map +0 -1
  178. package/dist/chunk-NKFAMQF2.js +0 -202
  179. package/dist/chunk-NKFAMQF2.js.map +0 -1
  180. package/dist/chunk-PQCOBN7L.js.map +0 -1
  181. package/dist/chunk-TCCZBGG5.js +0 -46
  182. package/dist/chunk-TCCZBGG5.js.map +0 -1
  183. package/dist/chunk-W34BUTVR.js +0 -389
  184. package/dist/chunk-W34BUTVR.js.map +0 -1
  185. package/dist/chunk-WFOGTZF6.js +0 -80
  186. package/dist/chunk-WFOGTZF6.js.map +0 -1
  187. package/dist/chunk-YTYCHRQ2.js +0 -106
  188. package/dist/chunk-YTYCHRQ2.js.map +0 -1
  189. package/dist/client-B3fWTCcL.d.ts +0 -1021
  190. package/dist/openai-BQMeDFef.d.ts +0 -81
  191. package/dist/tools/browser/anthropic.cjs +0 -655
  192. package/dist/tools/browser/anthropic.cjs.map +0 -1
  193. package/dist/tools/browser/anthropic.d.ts +0 -4
  194. package/dist/tools/browser/anthropic.js +0 -22
  195. package/dist/tools/browser/anthropic.js.map +0 -1
  196. package/dist/tools/browser/core.cjs +0 -1831
  197. package/dist/tools/browser/core.cjs.map +0 -1
  198. package/dist/tools/browser/core.d.ts +0 -245
  199. package/dist/tools/browser/core.js +0 -32
  200. package/dist/tools/browser/core.js.map +0 -1
  201. package/dist/tools/browser/errors.cjs +0 -208
  202. package/dist/tools/browser/errors.cjs.map +0 -1
  203. package/dist/tools/browser/errors.d.ts +0 -158
  204. package/dist/tools/browser/errors.js +0 -22
  205. package/dist/tools/browser/errors.js.map +0 -1
  206. package/dist/tools/browser/index.cjs +0 -2169
  207. package/dist/tools/browser/index.cjs.map +0 -1
  208. package/dist/tools/browser/index.d.ts +0 -134
  209. package/dist/tools/browser/index.js +0 -163
  210. package/dist/tools/browser/index.js.map +0 -1
  211. package/dist/tools/browser/live.cjs +0 -134
  212. package/dist/tools/browser/live.cjs.map +0 -1
  213. package/dist/tools/browser/live.d.ts +0 -75
  214. package/dist/tools/browser/live.js +0 -16
  215. package/dist/tools/browser/live.js.map +0 -1
  216. package/dist/tools/browser/openai.cjs +0 -671
  217. package/dist/tools/browser/openai.cjs.map +0 -1
  218. package/dist/tools/browser/openai.d.ts +0 -4
  219. package/dist/tools/browser/openai.js +0 -28
  220. package/dist/tools/browser/openai.js.map +0 -1
  221. package/dist/tools/browser/profiles/core.cjs +0 -942
  222. package/dist/tools/browser/profiles/core.cjs.map +0 -1
  223. package/dist/tools/browser/profiles/core.d.ts +0 -187
  224. package/dist/tools/browser/profiles/core.js +0 -30
  225. package/dist/tools/browser/profiles/core.js.map +0 -1
  226. package/dist/tools/browser/profiles/index.cjs +0 -942
  227. package/dist/tools/browser/profiles/index.cjs.map +0 -1
  228. package/dist/tools/browser/profiles/index.d.ts +0 -4
  229. package/dist/tools/browser/profiles/index.js +0 -30
  230. package/dist/tools/browser/profiles/index.js.map +0 -1
  231. package/dist/tools/browser/profiles/types.cjs +0 -74
  232. package/dist/tools/browser/profiles/types.cjs.map +0 -1
  233. package/dist/tools/browser/profiles/types.d.ts +0 -195
  234. package/dist/tools/browser/profiles/types.js +0 -16
  235. package/dist/tools/browser/profiles/types.js.map +0 -1
  236. package/dist/tools/browser/prompts.cjs +0 -69
  237. package/dist/tools/browser/prompts.cjs.map +0 -1
  238. package/dist/tools/browser/prompts.d.ts +0 -7
  239. package/dist/tools/browser/prompts.js +0 -10
  240. package/dist/tools/browser/prompts.js.map +0 -1
  241. package/dist/tools/browser/types.cjs +0 -19
  242. package/dist/tools/browser/types.cjs.map +0 -1
  243. package/dist/tools/browser/types.d.ts +0 -338
  244. package/dist/tools/browser/types.js +0 -1
  245. package/dist/tools/browser/types.js.map +0 -1
  246. package/dist/tools/browser/vercel.cjs +0 -632
  247. package/dist/tools/browser/vercel.cjs.map +0 -1
  248. package/dist/tools/browser/vercel.d.ts +0 -4
  249. package/dist/tools/browser/vercel.js +0 -22
  250. package/dist/tools/browser/vercel.js.map +0 -1
  251. package/dist/tools/reflex/core.cjs +0 -756
  252. package/dist/tools/reflex/core.cjs.map +0 -1
  253. package/dist/tools/reflex/core.d.ts +0 -59
  254. package/dist/tools/reflex/core.js +0 -16
  255. package/dist/tools/reflex/core.js.map +0 -1
  256. package/dist/tools/reflex/index.cjs +0 -756
  257. package/dist/tools/reflex/index.cjs.map +0 -1
  258. package/dist/tools/reflex/index.d.ts +0 -5
  259. package/dist/tools/reflex/index.js +0 -16
  260. package/dist/tools/reflex/index.js.map +0 -1
  261. package/dist/tools/reflex/types.cjs +0 -19
  262. package/dist/tools/reflex/types.cjs.map +0 -1
  263. package/dist/tools/reflex/types.d.ts +0 -171
  264. package/dist/tools/reflex/types.js +0 -1
  265. package/dist/tools/reflex/types.js.map +0 -1
  266. package/dist/tools/traces/core.cjs +0 -76
  267. package/dist/tools/traces/core.cjs.map +0 -1
  268. package/dist/tools/traces/core.d.ts +0 -24
  269. package/dist/tools/traces/core.js +0 -9
  270. package/dist/tools/traces/core.js.map +0 -1
  271. package/dist/tools/traces/index.cjs +0 -76
  272. package/dist/tools/traces/index.cjs.map +0 -1
  273. package/dist/tools/traces/index.d.ts +0 -5
  274. package/dist/tools/traces/index.js +0 -9
  275. package/dist/tools/traces/index.js.map +0 -1
  276. package/dist/tools/traces/types.cjs +0 -19
  277. package/dist/tools/traces/types.cjs.map +0 -1
  278. package/dist/tools/traces/types.d.ts +0 -56
  279. package/dist/tools/traces/types.js +0 -1
  280. package/dist/tools/traces/types.js.map +0 -1
  281. package/dist/vercel-CVF27qFK.d.ts +0 -74
  282. /package/dist/{chunk-GE5MNVT7.js.map → chunk-5KQ2WRBU.js.map} +0 -0
  283. /package/dist/{chunk-6YZCPCAY.js.map → chunk-BLCCGRKT.js.map} +0 -0
  284. /package/dist/{chunk-2BT4UGKH.js.map → chunk-BTMMUG3E.js.map} +0 -0
  285. /package/dist/{chunk-VJD6MF3M.js.map → chunk-CEXBKXWU.js.map} +0 -0
  286. /package/dist/{chunk-UOS3XKJD.js.map → chunk-DP2PT36G.js.map} +0 -0
  287. /package/dist/{chunk-DNL4DMMS.js.map → chunk-GTV27THY.js.map} +0 -0
  288. /package/dist/{chunk-VGCPVDFP.js.map → chunk-K2JR2NFQ.js.map} +0 -0
  289. /package/dist/{chunk-DHGXGVHC.js.map → chunk-KXEPBLVD.js.map} +0 -0
  290. /package/dist/{chunk-SVD3YRWM.js.map → chunk-MEZTHMB2.js.map} +0 -0
  291. /package/dist/{chunk-BECYWCEZ.js.map → chunk-O7LJEVZO.js.map} +0 -0
  292. /package/dist/{chunk-7QOGUY4A.js.map → chunk-PKJ7ODTG.js.map} +0 -0
  293. /package/dist/{chunk-YVKRPVOM.js.map → chunk-Q3NH3NPD.js.map} +0 -0
  294. /package/dist/{chunk-ZA3UJRSE.js.map → chunk-RL3ZTXT3.js.map} +0 -0
  295. /package/dist/{chunk-WN6YLBEH.js.map → chunk-ULHHMZRL.js.map} +0 -0
  296. /package/dist/{chunk-TJUZAO7T.js.map → chunk-UT3NQLCF.js.map} +0 -0
  297. /package/dist/{chunk-DW6ZIVCM.js.map → chunk-VS5F2ORN.js.map} +0 -0
  298. /package/dist/{chunk-UZA2ODNU.js.map → chunk-W37OFBSG.js.map} +0 -0
  299. /package/dist/{chunk-JU6TCHVI.js.map → chunk-WDBYAXZ5.js.map} +0 -0
  300. /package/dist/{chunk-2XDSHAB5.js.map → chunk-YSFEKIYQ.js.map} +0 -0
  301. /package/dist/{chunk-WDLDKJHT.js.map → chunk-ZHB57ORD.js.map} +0 -0
@@ -1,622 +0,0 @@
1
- import {
2
- ProfilesClient
3
- } from "./chunk-W34BUTVR.js";
4
- import {
5
- buildEmbedCode,
6
- buildLiveIframe,
7
- buildLiveUrl,
8
- resolvePreset
9
- } from "./chunk-YTYCHRQ2.js";
10
- import {
11
- MorphAPIClient
12
- } from "./chunk-PQCOBN7L.js";
13
- import {
14
- logger
15
- } from "./chunk-F3NCFNUX.js";
16
- import {
17
- fetchWithRetry,
18
- withTimeout
19
- } from "./chunk-UOS3XKJD.js";
20
- import {
21
- APIResource
22
- } from "./chunk-LKFZBBTD.js";
23
-
24
- // tools/browser/core.ts
25
- var DEFAULT_CONFIG = {
26
- apiUrl: process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com",
27
- timeout: 1e6,
28
- // 10 minutes for complex tasks
29
- debug: false
30
- };
31
- var BrowserClient = class extends APIResource {
32
- config;
33
- /**
34
- * Profile management - create and manage browser profiles for storing login state.
35
- */
36
- profiles;
37
- constructor(clientOrConfig = {}) {
38
- const isClient = clientOrConfig instanceof MorphAPIClient;
39
- super(
40
- isClient ? clientOrConfig : new MorphAPIClient({
41
- apiKey: clientOrConfig.apiKey,
42
- browserURL: clientOrConfig.apiUrl,
43
- timeout: clientOrConfig.timeout,
44
- retryConfig: clientOrConfig.retryConfig,
45
- debug: clientOrConfig.debug
46
- })
47
- );
48
- this.config = isClient ? {
49
- ...DEFAULT_CONFIG,
50
- apiUrl: clientOrConfig.browserURL,
51
- apiKey: clientOrConfig.resolveApiKey(),
52
- retryConfig: clientOrConfig.retryConfig,
53
- debug: clientOrConfig.debug
54
- } : { ...DEFAULT_CONFIG, ...clientOrConfig };
55
- this.profiles = new ProfilesClient(this.config);
56
- }
57
- /**
58
- * Execute a browser automation task
59
- */
60
- async execute(input) {
61
- return executeBrowserTask(input, this.config);
62
- }
63
- async createTask(input) {
64
- const apiUrl = this.config.apiUrl || DEFAULT_CONFIG.apiUrl;
65
- const debug = this.config.debug || false;
66
- const hasTask = typeof input.task === "string" && input.task.trim().length > 0;
67
- const hasDiff = typeof input.diff === "string" && input.diff.trim().length > 0;
68
- if (!hasTask && !hasDiff) {
69
- throw new Error('Browser task requires either "task" (natural language) or "diff" (PR-review planning)');
70
- }
71
- logger.debug("Browser", "create_task", { task: (input.task ?? "").slice(0, 100), url: input.url, endpoint: `${apiUrl}/browser-task/async` });
72
- const headers = { "Content-Type": "application/json" };
73
- if (this.config.apiKey) headers["Authorization"] = `Bearer ${this.config.apiKey}`;
74
- const response = await fetch(`${apiUrl}/browser-task/async`, {
75
- method: "POST",
76
- headers,
77
- body: JSON.stringify({
78
- task: input.task,
79
- diff: input.diff,
80
- url: input.url,
81
- max_steps: input.maxSteps ?? 10,
82
- model: input.model ?? "morph-computer-use-v0",
83
- viewport_width: input.viewportWidth ?? 1280,
84
- viewport_height: input.viewportHeight ?? 720,
85
- external_id: input.externalId,
86
- repo_id: input.repoId,
87
- repo_full_name: input.repoFullName,
88
- commit_id: input.commitId,
89
- record_video: input.recordVideo ?? false,
90
- video_width: input.videoWidth ?? input.viewportWidth ?? 1280,
91
- video_height: input.videoHeight ?? input.viewportHeight ?? 720,
92
- allow_resizing: input.allowResizing ?? false,
93
- structured_output: "schema" in input ? stringifyStructuredOutput(input.schema) : void 0,
94
- auth: input.auth,
95
- profile_id: input.profileId,
96
- force_query_params: input.forceQueryParams
97
- })
98
- });
99
- if (!response.ok) {
100
- const errorText = await response.text().catch(() => response.statusText);
101
- logger.error("Browser", "create_task_error", { status: response.status, error: errorText });
102
- throw new Error(`HTTP ${response.status}: ${errorText}`);
103
- }
104
- const result = mapTaskResult(await response.json());
105
- logger.debug("Browser", "task_created", { recording_id: result.recordingId, task_id: result.taskId, debug_url: !!result.debugUrl });
106
- if ("schema" in input) {
107
- return wrapTaskResponseWithSchema(result, this.config, input.schema);
108
- } else {
109
- return wrapTaskResponse(result, this.config);
110
- }
111
- }
112
- /**
113
- * Execute task with recording and wait for video to be ready
114
- */
115
- async executeWithRecording(input) {
116
- return executeWithRecording(input, this.config);
117
- }
118
- /**
119
- * Get recording status and URLs
120
- */
121
- async getRecording(recordingId) {
122
- return getRecording(recordingId, this.config);
123
- }
124
- /**
125
- * Wait for recording to complete with automatic polling
126
- */
127
- async waitForRecording(recordingId, options) {
128
- return waitForRecording(recordingId, this.config, options);
129
- }
130
- /**
131
- * Get errors from recording with screenshots
132
- */
133
- async getErrors(recordingId) {
134
- return getErrors(recordingId, this.config);
135
- }
136
- /**
137
- * Get animated WebP preview of recording
138
- */
139
- async getWebp(recordingId, options) {
140
- return getWebp(recordingId, this.config, options);
141
- }
142
- /**
143
- * Check if browser worker service is healthy
144
- */
145
- async checkHealth() {
146
- return checkHealth(this.config);
147
- }
148
- };
149
- async function executeBrowserTask(input, config = {}) {
150
- const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;
151
- const timeout = config.timeout || DEFAULT_CONFIG.timeout;
152
- const debug = config.debug || false;
153
- if (!input.task || input.task.trim().length === 0) {
154
- return {
155
- success: false,
156
- error: 'Task description is required. Example: "Go to example.com and click the login button"'
157
- };
158
- }
159
- if (input.maxSteps !== void 0 && (input.maxSteps < 1 || input.maxSteps > 50)) {
160
- return {
161
- success: false,
162
- error: "maxSteps must be between 1 and 50. Use more steps for complex multi-page flows."
163
- };
164
- }
165
- logger.debug("Browser", "execute_start", { task: input.task.slice(0, 100), url: input.url, max_steps: input.maxSteps ?? 10, record_video: input.recordVideo ?? false });
166
- const startTime = Date.now();
167
- try {
168
- const headers = { "Content-Type": "application/json" };
169
- if (config.apiKey) headers["Authorization"] = `Bearer ${config.apiKey}`;
170
- const fetchPromise = fetchWithRetry(
171
- `${apiUrl}/browser-task`,
172
- {
173
- method: "POST",
174
- headers,
175
- body: JSON.stringify({
176
- task: input.task,
177
- url: input.url,
178
- max_steps: input.maxSteps ?? 10,
179
- model: input.model ?? "morph-computer-use-v0",
180
- viewport_width: input.viewportWidth ?? 1280,
181
- viewport_height: input.viewportHeight ?? 720,
182
- external_id: input.externalId,
183
- repo_id: input.repoId,
184
- commit_id: input.commitId,
185
- record_video: input.recordVideo ?? false,
186
- video_width: input.videoWidth ?? input.viewportWidth ?? 1280,
187
- video_height: input.videoHeight ?? input.viewportHeight ?? 720,
188
- allow_resizing: input.allowResizing ?? false,
189
- structured_output: input.structuredOutput,
190
- auth: input.auth,
191
- profile_id: input.profileId,
192
- force_query_params: input.forceQueryParams
193
- })
194
- },
195
- config.retryConfig
196
- );
197
- const response = await withTimeout(
198
- fetchPromise,
199
- timeout,
200
- `Browser task timed out after ${timeout}ms. Consider increasing timeout or reducing maxSteps.`
201
- );
202
- if (!response.ok) {
203
- const errorText = await response.text().catch(() => response.statusText);
204
- logger.error("Browser", "execute_error", { status: response.status, error: errorText });
205
- throw new Error(`HTTP ${response.status}: ${errorText}`);
206
- }
207
- const result = mapTaskResult(await response.json());
208
- const elapsed = Date.now() - startTime;
209
- logger.debug("Browser", "execute_complete", { success: result.success, latency_ms: elapsed, steps: result.stepsTaken ?? 0, recording_id: result.recordingId });
210
- return result;
211
- } catch (error) {
212
- if (error instanceof Error) {
213
- if (error.message.includes("ECONNREFUSED") || error.message.includes("fetch failed")) {
214
- return {
215
- success: false,
216
- error: `Cannot connect to browser worker at ${apiUrl}. Ensure the service is running and accessible. For local dev, set MORPH_ENVIRONMENT=DEV.`
217
- };
218
- }
219
- return {
220
- success: false,
221
- error: error.message
222
- };
223
- }
224
- return {
225
- success: false,
226
- error: String(error)
227
- };
228
- }
229
- }
230
- async function getRecording(recordingId, config = {}) {
231
- const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;
232
- const debug = config.debug || false;
233
- if (!config.apiKey) {
234
- throw new Error("API key required for getRecording");
235
- }
236
- if (debug) console.log(`[Browser] getRecording: ${recordingId}`);
237
- const response = await fetch(`${apiUrl}/recordings/${recordingId}`, {
238
- method: "GET",
239
- headers: { "Authorization": `Bearer ${config.apiKey}` }
240
- });
241
- if (!response.ok) {
242
- const errorText = await response.text().catch(() => response.statusText);
243
- if (debug) console.error(`[Browser] getRecording error: ${response.status} - ${errorText}`);
244
- throw new Error(`HTTP ${response.status}: ${errorText}`);
245
- }
246
- const data = mapRecordingStatus(await response.json());
247
- if (debug) console.log(`[Browser] Recording status: ${data.status}`);
248
- return {
249
- ...data,
250
- getWebp: (options) => getWebp(recordingId, config, options),
251
- getErrors: () => getErrors(recordingId, config)
252
- };
253
- }
254
- async function waitForRecording(recordingId, config = {}, options = {}) {
255
- const timeout = options.timeout ?? 6e4;
256
- const pollInterval = options.pollInterval ?? 2e3;
257
- const startTime = Date.now();
258
- while (Date.now() - startTime < timeout) {
259
- const status = await getRecording(recordingId, config);
260
- if (status.status === "COMPLETED" || status.status === "ERROR") {
261
- return status;
262
- }
263
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
264
- }
265
- throw new Error(`Recording timeout after ${timeout}ms - status still pending`);
266
- }
267
- async function executeWithRecording(input, config = {}) {
268
- const taskResult = await executeBrowserTask(input, config);
269
- if (taskResult.recordingId) {
270
- try {
271
- const recording = await waitForRecording(
272
- taskResult.recordingId,
273
- config,
274
- { timeout: 6e4, pollInterval: 2e3 }
275
- );
276
- return {
277
- ...taskResult,
278
- recording
279
- };
280
- } catch (error) {
281
- const errorRecording = {
282
- id: taskResult.recordingId,
283
- status: "ERROR",
284
- error: error instanceof Error ? error.message : String(error),
285
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
286
- getWebp: (options) => getWebp(taskResult.recordingId, config, options),
287
- getErrors: () => getErrors(taskResult.recordingId, config)
288
- };
289
- return {
290
- ...taskResult,
291
- recording: errorRecording
292
- };
293
- }
294
- }
295
- return taskResult;
296
- }
297
- async function getErrors(recordingId, config = {}) {
298
- const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;
299
- const debug = config.debug || false;
300
- if (!config.apiKey) {
301
- throw new Error("API key required for getErrors");
302
- }
303
- if (debug) console.log(`[Browser] getErrors: ${recordingId}`);
304
- const response = await fetch(`${apiUrl}/recordings/${recordingId}/errors`, {
305
- method: "GET",
306
- headers: { "Authorization": `Bearer ${config.apiKey}` }
307
- });
308
- if (!response.ok) {
309
- const errorText = await response.text().catch(() => response.statusText);
310
- if (debug) console.error(`[Browser] getErrors error: ${response.status} - ${errorText}`);
311
- throw new Error(`HTTP ${response.status}: ${errorText}`);
312
- }
313
- const errors = mapErrorsResponse(await response.json());
314
- if (debug) console.log(`[Browser] Found ${errors.totalErrors} errors`);
315
- return errors;
316
- }
317
- function stringifyStructuredOutput(schema) {
318
- try {
319
- return JSON.stringify({
320
- type: "object",
321
- description: "Zod schema definition (Zod v3)",
322
- zodDef: schema._def
323
- });
324
- } catch (error) {
325
- console.warn("[Browser] Failed to serialize Zod schema:", error);
326
- return JSON.stringify({
327
- type: "object",
328
- description: "Schema serialization failed"
329
- });
330
- }
331
- }
332
- function parseStructuredTaskOutput(result, schema) {
333
- if (!result.output) {
334
- return { ...result, parsed: null };
335
- }
336
- try {
337
- const parsed = JSON.parse(result.output);
338
- const validated = schema.parse(parsed);
339
- return { ...result, parsed: validated };
340
- } catch (error) {
341
- if (error instanceof SyntaxError) {
342
- return { ...result, parsed: null };
343
- }
344
- throw error;
345
- }
346
- }
347
- function mapTaskResult(api) {
348
- if (!api || typeof api !== "object") {
349
- return api;
350
- }
351
- return {
352
- success: api.success,
353
- result: api.result,
354
- error: api.error,
355
- stepsTaken: api.steps_taken,
356
- executionTimeMs: api.execution_time_ms,
357
- urls: api.urls,
358
- actionNames: api.action_names,
359
- errors: api.errors,
360
- modelActions: api.model_actions,
361
- isDone: api.is_done,
362
- actionHistory: api.action_history,
363
- actionResults: api.action_results,
364
- hasErrors: api.has_errors,
365
- numberOfSteps: api.number_of_steps,
366
- judgement: api.judgement,
367
- isValidated: api.is_validated,
368
- replayId: api.replay_id,
369
- replayUrl: api.replay_url,
370
- recordingId: api.recording_id,
371
- recordingStatus: api.recording_status,
372
- taskId: api.task_id,
373
- status: api.status,
374
- output: api.output,
375
- debugUrl: api.debug_url
376
- };
377
- }
378
- function mapRecordingStatus(api) {
379
- return {
380
- id: api.id,
381
- status: api.status,
382
- replayUrl: api.replay_url,
383
- networkUrl: api.network_url,
384
- consoleUrl: api.console_url,
385
- videoUrl: api.video_url,
386
- result: api.result,
387
- totalEvents: api.total_events,
388
- fileSize: api.file_size,
389
- duration: api.duration,
390
- error: api.error,
391
- createdAt: api.created_at
392
- };
393
- }
394
- function mapBrowserError(api) {
395
- return {
396
- type: api.type,
397
- message: api.message,
398
- url: api.url,
399
- timestamp: api.timestamp,
400
- screenshotUrl: api.screenshot_url,
401
- capturedAt: api.captured_at,
402
- status: api.status
403
- };
404
- }
405
- function mapErrorsResponse(api) {
406
- return {
407
- recordingId: api.recording_id,
408
- totalErrors: api.total_errors,
409
- errors: Array.isArray(api.errors) ? api.errors.map(mapBrowserError) : []
410
- };
411
- }
412
- function mapWebpResponse(api) {
413
- return {
414
- webpUrl: api.webp_url,
415
- cached: api.cached,
416
- width: api.width,
417
- fps: api.fps,
418
- maxDuration: api.max_duration,
419
- fileSize: api.file_size,
420
- maxSizeMb: api.max_size_mb,
421
- budgetMet: api.budget_met,
422
- qualityUsed: api.quality_used,
423
- attempts: api.attempts
424
- };
425
- }
426
- async function getTaskStatus(taskId, config) {
427
- const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;
428
- const debug = config.debug || false;
429
- if (debug) console.log(`[Browser] getTaskStatus: ${taskId}`);
430
- const headers = {};
431
- if (config.apiKey) headers["Authorization"] = `Bearer ${config.apiKey}`;
432
- const response = await fetch(`${apiUrl}/tasks/${taskId}`, {
433
- method: "GET",
434
- headers
435
- });
436
- if (!response.ok) {
437
- const errorText = await response.text().catch(() => response.statusText);
438
- if (debug) console.error(`[Browser] getTaskStatus error: ${response.status} - ${errorText}`);
439
- throw new Error(`HTTP ${response.status}: ${errorText}`);
440
- }
441
- const result = mapTaskResult(await response.json());
442
- if (debug) console.log(`[Browser] Task status: ${result.status}`);
443
- return result;
444
- }
445
- function generateLiveUrl(taskId, config) {
446
- const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;
447
- const baseUrl = apiUrl.replace("/api", "");
448
- return `${baseUrl}/tasks/${taskId}/live`;
449
- }
450
- async function pollTaskUntilComplete(taskId, config, pollConfig = {}) {
451
- const interval = pollConfig.interval ?? 2e3;
452
- const timeout = pollConfig.timeout ?? 3e5;
453
- const startTime = Date.now();
454
- while (Date.now() - startTime < timeout) {
455
- const status = await getTaskStatus(taskId, config);
456
- if (status.status === "completed" || status.status === "failed") {
457
- return status;
458
- }
459
- await new Promise((resolve) => setTimeout(resolve, interval));
460
- }
461
- throw new Error(`Task polling timeout after ${timeout}ms`);
462
- }
463
- function wrapTaskResponse(result, config) {
464
- const debugUrl = result.debugUrl ?? "";
465
- const wrapped = {
466
- ...result,
467
- debugUrl,
468
- taskId: result.taskId || "",
469
- liveUrl: result.taskId ? generateLiveUrl(result.taskId, config) : debugUrl,
470
- complete: async (pollConfig) => {
471
- if (result.taskId) {
472
- return pollTaskUntilComplete(result.taskId, config, pollConfig);
473
- }
474
- if (result.recordingId) {
475
- const recording = await waitForRecording(
476
- result.recordingId,
477
- config,
478
- pollConfig
479
- );
480
- return {
481
- ...result,
482
- recordingStatus: recording.status
483
- };
484
- }
485
- throw new Error("Cannot poll completion: no taskId or recordingId available");
486
- },
487
- // Add Steel live session helpers - either functional or error-throwing
488
- getLiveUrl: debugUrl ? (options) => buildLiveUrl(debugUrl, options) : () => {
489
- throw new Error(
490
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
491
- );
492
- },
493
- getLiveIframe: debugUrl ? (optionsOrPreset) => {
494
- const options = resolvePreset(optionsOrPreset);
495
- return buildLiveIframe(debugUrl, options);
496
- } : () => {
497
- throw new Error(
498
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
499
- );
500
- },
501
- getEmbedCode: debugUrl ? () => buildEmbedCode(debugUrl) : () => {
502
- throw new Error(
503
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help."
504
- );
505
- }
506
- };
507
- return wrapped;
508
- }
509
- function wrapTaskResponseWithSchema(result, config, schema) {
510
- const debugUrl = result.debugUrl ?? "";
511
- const parsed = result.output ? parseStructuredTaskOutput(result, schema) : { ...result, parsed: null };
512
- const wrapped = {
513
- ...parsed,
514
- debugUrl,
515
- taskId: result.taskId || "",
516
- liveUrl: result.taskId ? generateLiveUrl(result.taskId, config) : debugUrl,
517
- complete: async (pollConfig) => {
518
- if (result.taskId) {
519
- const finalResult = await pollTaskUntilComplete(result.taskId, config, pollConfig);
520
- return parseStructuredTaskOutput(finalResult, schema);
521
- }
522
- if (result.recordingId) {
523
- const recording = await waitForRecording(
524
- result.recordingId,
525
- config,
526
- pollConfig
527
- );
528
- return {
529
- ...parsed,
530
- recordingStatus: recording.status
531
- };
532
- }
533
- throw new Error("Cannot poll completion: no taskId or recordingId available");
534
- },
535
- // Add Steel live session helpers - either functional or error-throwing
536
- getLiveUrl: debugUrl ? (options) => buildLiveUrl(debugUrl, options) : () => {
537
- throw new Error(
538
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions. "
539
- );
540
- },
541
- getLiveIframe: debugUrl ? (optionsOrPreset) => {
542
- const options = resolvePreset(optionsOrPreset);
543
- return buildLiveIframe(debugUrl, options);
544
- } : () => {
545
- throw new Error(
546
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions."
547
- );
548
- },
549
- getEmbedCode: debugUrl ? () => buildEmbedCode(debugUrl) : () => {
550
- throw new Error(
551
- "Live sessions not available. Your backend must return a debugUrl in the response. Contact support@morphllm.com if you need help enabling live sessions."
552
- );
553
- }
554
- };
555
- return wrapped;
556
- }
557
- async function getWebp(recordingId, config = {}, options = {}) {
558
- const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;
559
- const debug = config.debug || false;
560
- if (!config.apiKey) {
561
- throw new Error("API key required for getWebp");
562
- }
563
- const params = new URLSearchParams();
564
- if (options.maxDuration !== void 0) params.set("max_duration", String(options.maxDuration));
565
- if (options.fps !== void 0) params.set("fps", String(options.fps));
566
- if (options.width !== void 0) params.set("width", String(options.width));
567
- if (options.quality !== void 0) params.set("quality", String(options.quality));
568
- if (options.maxSizeMb !== void 0) params.set("max_size_mb", String(options.maxSizeMb));
569
- const url = `${apiUrl}/recordings/${recordingId}/webp${params.toString() ? "?" + params.toString() : ""}`;
570
- if (debug) console.log(`[Browser] getWebp: ${url}`);
571
- const response = await fetch(url, {
572
- method: "GET",
573
- headers: { "Authorization": `Bearer ${config.apiKey}` }
574
- });
575
- if (!response.ok) {
576
- const errorText = await response.text().catch(() => response.statusText);
577
- if (debug) console.error(`[Browser] getWebp error: ${response.status} - ${errorText}`);
578
- throw new Error(`HTTP ${response.status}: ${errorText}`);
579
- }
580
- const result = mapWebpResponse(await response.json());
581
- if (debug) console.log(`[Browser] WebP ready: ${result.webpUrl} (cached: ${result.cached})`);
582
- return result;
583
- }
584
- async function checkHealth(config = {}) {
585
- const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;
586
- try {
587
- const response = await fetch(`${apiUrl}/health`, {
588
- method: "GET",
589
- headers: config.apiKey ? { "Authorization": `Bearer ${config.apiKey}` } : {}
590
- });
591
- if (!response.ok) {
592
- throw new Error(`HTTP ${response.status}`);
593
- }
594
- const data = await response.json();
595
- return {
596
- ok: true,
597
- google_configured: data.google_configured ?? false,
598
- database_configured: data.database_configured ?? false,
599
- s3_configured: data.s3_configured ?? false
600
- };
601
- } catch (error) {
602
- return {
603
- ok: false,
604
- google_configured: false,
605
- database_configured: false,
606
- s3_configured: false,
607
- error: error instanceof Error ? error.message : String(error)
608
- };
609
- }
610
- }
611
-
612
- export {
613
- BrowserClient,
614
- executeBrowserTask,
615
- getRecording,
616
- waitForRecording,
617
- executeWithRecording,
618
- getErrors,
619
- getWebp,
620
- checkHealth
621
- };
622
- //# sourceMappingURL=chunk-FLWBVHDC.js.map