@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,942 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // tools/browser/profiles/core.ts
21
- var core_exports = {};
22
- __export(core_exports, {
23
- ProfilesClient: () => ProfilesClient,
24
- createProfile: () => createProfile,
25
- deleteProfile: () => deleteProfile,
26
- getProfile: () => getProfile,
27
- getProfileState: () => getProfileState,
28
- listProfiles: () => listProfiles,
29
- listRepos: () => listRepos,
30
- saveProfileSession: () => saveProfileSession,
31
- startProfileSession: () => startProfileSession,
32
- updateProfile: () => updateProfile
33
- });
34
- module.exports = __toCommonJS(core_exports);
35
-
36
- // package.json
37
- var package_default = {
38
- name: "@morphllm/morphsdk",
39
- version: "0.2.197",
40
- description: "TypeScript SDK and CLI for Morph Fast Apply integration",
41
- type: "module",
42
- main: "./dist/index.cjs",
43
- module: "./dist/index.js",
44
- types: "./dist/index.d.ts",
45
- exports: {
46
- ".": {
47
- types: "./dist/index.d.ts",
48
- import: "./dist/index.js",
49
- require: "./dist/index.cjs"
50
- },
51
- "./logger": {
52
- types: "./dist/logger.d.ts",
53
- import: "./dist/logger.js",
54
- require: "./dist/logger.cjs"
55
- },
56
- "./edge": {
57
- types: "./dist/edge.d.ts",
58
- import: "./dist/edge.js",
59
- require: "./dist/edge.cjs"
60
- },
61
- "./tools/warp-grep": {
62
- types: "./dist/tools/warp_grep/index.d.ts",
63
- import: "./dist/tools/warp_grep/index.js",
64
- require: "./dist/tools/warp_grep/index.cjs"
65
- },
66
- "./tools/warp-grep/openai": {
67
- types: "./dist/tools/warp_grep/openai.d.ts",
68
- import: "./dist/tools/warp_grep/openai.js",
69
- require: "./dist/tools/warp_grep/openai.cjs"
70
- },
71
- "./tools/warp-grep/anthropic": {
72
- types: "./dist/tools/warp_grep/anthropic.d.ts",
73
- import: "./dist/tools/warp_grep/anthropic.js",
74
- require: "./dist/tools/warp_grep/anthropic.cjs"
75
- },
76
- "./tools/warp-grep/vercel": {
77
- types: "./dist/tools/warp_grep/vercel.d.ts",
78
- import: "./dist/tools/warp_grep/vercel.js",
79
- require: "./dist/tools/warp_grep/vercel.cjs"
80
- },
81
- "./tools/warp-grep/client": {
82
- types: "./dist/tools/warp_grep/client.d.ts",
83
- import: "./dist/tools/warp_grep/client.js",
84
- require: "./dist/tools/warp_grep/client.cjs"
85
- },
86
- "./tools/warp-grep/gemini": {
87
- types: "./dist/tools/warp_grep/gemini.d.ts",
88
- import: "./dist/tools/warp_grep/gemini.js",
89
- require: "./dist/tools/warp_grep/gemini.cjs"
90
- },
91
- "./tools/warp-grep/harness": {
92
- types: "./dist/tools/warp_grep/harness.d.ts",
93
- import: "./dist/tools/warp_grep/harness.js",
94
- require: "./dist/tools/warp_grep/harness.cjs"
95
- },
96
- "./tracing": {
97
- types: "./dist/tracing/index.d.ts",
98
- import: "./dist/tracing/index.js",
99
- require: "./dist/tracing/index.cjs"
100
- },
101
- "./tracing/otel": {
102
- types: "./dist/tracing/otel.d.ts",
103
- import: "./dist/tracing/otel.js",
104
- require: "./dist/tracing/otel.cjs"
105
- },
106
- "./tools/fastapply": {
107
- types: "./dist/tools/fastapply/index.d.ts",
108
- import: "./dist/tools/fastapply/index.js",
109
- require: "./dist/tools/fastapply/index.cjs"
110
- },
111
- "./tools/fastapply/anthropic": {
112
- types: "./dist/tools/fastapply/anthropic.d.ts",
113
- import: "./dist/tools/fastapply/anthropic.js",
114
- require: "./dist/tools/fastapply/anthropic.cjs"
115
- },
116
- "./tools/fastapply/openai": {
117
- types: "./dist/tools/fastapply/openai.d.ts",
118
- import: "./dist/tools/fastapply/openai.js",
119
- require: "./dist/tools/fastapply/openai.cjs"
120
- },
121
- "./tools/fastapply/vercel": {
122
- types: "./dist/tools/fastapply/vercel.d.ts",
123
- import: "./dist/tools/fastapply/vercel.js",
124
- require: "./dist/tools/fastapply/vercel.cjs"
125
- },
126
- "./tools/codebase-search": {
127
- types: "./dist/tools/codebase_search/index.d.ts",
128
- import: "./dist/tools/codebase_search/index.js",
129
- require: "./dist/tools/codebase_search/index.cjs"
130
- },
131
- "./tools/codebase-search/anthropic": {
132
- types: "./dist/tools/codebase_search/anthropic.d.ts",
133
- import: "./dist/tools/codebase_search/anthropic.js",
134
- require: "./dist/tools/codebase_search/anthropic.cjs"
135
- },
136
- "./tools/codebase-search/openai": {
137
- types: "./dist/tools/codebase_search/openai.d.ts",
138
- import: "./dist/tools/codebase_search/openai.js",
139
- require: "./dist/tools/codebase_search/openai.cjs"
140
- },
141
- "./tools/codebase-search/vercel": {
142
- types: "./dist/tools/codebase_search/vercel.d.ts",
143
- import: "./dist/tools/codebase_search/vercel.js",
144
- require: "./dist/tools/codebase_search/vercel.cjs"
145
- },
146
- "./tools/browser": {
147
- types: "./dist/tools/browser/index.d.ts",
148
- import: "./dist/tools/browser/index.js",
149
- require: "./dist/tools/browser/index.cjs"
150
- },
151
- "./tools/browser/anthropic": {
152
- types: "./dist/tools/browser/anthropic.d.ts",
153
- import: "./dist/tools/browser/anthropic.js",
154
- require: "./dist/tools/browser/anthropic.cjs"
155
- },
156
- "./tools/browser/openai": {
157
- types: "./dist/tools/browser/openai.d.ts",
158
- import: "./dist/tools/browser/openai.js",
159
- require: "./dist/tools/browser/openai.cjs"
160
- },
161
- "./tools/browser/vercel": {
162
- types: "./dist/tools/browser/vercel.d.ts",
163
- import: "./dist/tools/browser/vercel.js",
164
- require: "./dist/tools/browser/vercel.cjs"
165
- },
166
- "./tools/browser/profiles": {
167
- types: "./dist/tools/browser/profiles/index.d.ts",
168
- import: "./dist/tools/browser/profiles/index.js",
169
- require: "./dist/tools/browser/profiles/index.cjs"
170
- },
171
- "./modelrouter": {
172
- types: "./dist/modelrouter/index.d.ts",
173
- import: "./dist/modelrouter/index.js",
174
- require: "./dist/modelrouter/index.cjs"
175
- },
176
- "./tools/compact": {
177
- types: "./dist/tools/compact/index.d.ts",
178
- import: "./dist/tools/compact/index.js",
179
- require: "./dist/tools/compact/index.cjs"
180
- },
181
- "./tools/reflex": {
182
- types: "./dist/tools/reflex/index.d.ts",
183
- import: "./dist/tools/reflex/index.js",
184
- require: "./dist/tools/reflex/index.cjs"
185
- },
186
- "./tools/traces": {
187
- types: "./dist/tools/traces/index.d.ts",
188
- import: "./dist/tools/traces/index.js",
189
- require: "./dist/tools/traces/index.cjs"
190
- },
191
- "./subagents": {
192
- types: "./dist/subagents/index.d.ts",
193
- import: "./dist/subagents/index.js",
194
- require: "./dist/subagents/index.cjs"
195
- },
196
- "./subagents/vercel": {
197
- types: "./dist/subagents/vercel.d.ts",
198
- import: "./dist/subagents/vercel.js",
199
- require: "./dist/subagents/vercel.cjs"
200
- },
201
- "./subagents/anthropic": {
202
- types: "./dist/subagents/anthropic.d.ts",
203
- import: "./dist/subagents/anthropic.js",
204
- require: "./dist/subagents/anthropic.cjs"
205
- },
206
- "./ai-sdk": {
207
- types: "./dist/ai-sdk/index.d.ts",
208
- import: "./dist/ai-sdk/index.js",
209
- require: "./dist/ai-sdk/index.cjs"
210
- }
211
- },
212
- files: [
213
- "dist/**/*.js",
214
- "dist/**/*.cjs",
215
- "dist/**/*.d.ts",
216
- "dist/**/*.map",
217
- "!dist/**/__tests__/**",
218
- "!dist/**/*.test.*"
219
- ],
220
- scripts: {
221
- 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/reflex/index.ts tools/reflex/core.ts tools/reflex/types.ts tools/traces/index.ts tools/traces/core.ts tools/traces/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",
222
- prepare: "npm run build",
223
- typecheck: "tsc --noEmit && tsc --noEmit -p ai-sdk/tsconfig.json",
224
- lint: "eslint .",
225
- test: "vitest run",
226
- "test:watch": "vitest watch",
227
- "test:anthropic": "vitest run anthropic",
228
- "test:openai": "vitest run openai",
229
- "test:vercel": "vitest run vercel",
230
- "test:git": "vitest run git",
231
- "test:browser": "vitest run browser",
232
- "test:agent": "npx tsx tests/fullAgentTest.ts",
233
- "test:integration": "npx tsx tests/fullIntegrationTest.ts",
234
- "test:e2e": "vitest run --config vitest.e2e.config.ts",
235
- "release:patch": "npm version patch && npm publish",
236
- "release:minor": "npm version minor && npm publish",
237
- "release:major": "npm version major && npm publish"
238
- },
239
- keywords: [
240
- "morph",
241
- "fast-apply",
242
- "cli",
243
- "sdk",
244
- "edit-file"
245
- ],
246
- engines: {
247
- node: ">=18"
248
- },
249
- license: "MIT",
250
- dependencies: {
251
- "@opentelemetry/api": "^1.9.0",
252
- "@opentelemetry/exporter-trace-otlp-http": "^0.203.0",
253
- "@opentelemetry/sdk-trace-base": "^2.7.1",
254
- "@traceloop/node-server-sdk": "^0.27.0",
255
- "@vscode/ripgrep": "^1.17.0",
256
- ai: ">=5.0.0",
257
- diff: "^7.0.0",
258
- openai: "^4.52.7",
259
- zod: ">=3.23.0"
260
- },
261
- devDependencies: {
262
- "@ai-sdk/anthropic": "^2.0.70",
263
- "@ai-sdk/openai": "^2.0.35",
264
- "@anthropic-ai/sdk": "^0.30.1",
265
- "@google/generative-ai": "^0.24.1",
266
- "@types/diff": "^7.0.2",
267
- "@types/node": "^20.14.10",
268
- "@typescript-eslint/eslint-plugin": "^7.18.0",
269
- "@typescript-eslint/parser": "^7.18.0",
270
- dotenv: "^16.4.5",
271
- eslint: "^8.57.0",
272
- shx: "^0.3.4",
273
- tsup: "^8.5.0",
274
- tsx: "^4.16.2",
275
- typescript: "^5.5.4",
276
- vitest: "^2.1.6"
277
- },
278
- peerDependencies: {
279
- "@ai-sdk/openai-compatible": ">=2.0.74 <4",
280
- "@anthropic-ai/sdk": ">=0.25.0",
281
- "@google/generative-ai": ">=0.21.0",
282
- ai: ">=5.0.0",
283
- zod: ">=3.23.0"
284
- },
285
- peerDependenciesMeta: {
286
- "@anthropic-ai/sdk": {
287
- optional: true
288
- },
289
- "@google/generative-ai": {
290
- optional: true
291
- },
292
- ai: {
293
- optional: true
294
- },
295
- zod: {
296
- optional: true
297
- }
298
- },
299
- publishConfig: {
300
- access: "public"
301
- }
302
- };
303
-
304
- // version.ts
305
- var SDK_VERSION = package_default.version;
306
-
307
- // tools/utils/resilience.ts
308
- var DEFAULT_RETRY_CONFIG = {
309
- maxRetries: 3,
310
- initialDelay: 1e3,
311
- maxDelay: 3e4,
312
- backoffMultiplier: 2,
313
- retryableErrors: ["ECONNREFUSED", "ETIMEDOUT", "ENOTFOUND"]
314
- };
315
- async function fetchWithRetry(url, options, retryConfig = {}) {
316
- const {
317
- maxRetries = DEFAULT_RETRY_CONFIG.maxRetries,
318
- initialDelay = DEFAULT_RETRY_CONFIG.initialDelay,
319
- maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,
320
- backoffMultiplier = DEFAULT_RETRY_CONFIG.backoffMultiplier,
321
- retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors,
322
- onRetry
323
- } = retryConfig;
324
- let lastError = null;
325
- let delay = initialDelay;
326
- options = { ...options, headers: { "X-Morph-SDK-Version": SDK_VERSION, ...options.headers } };
327
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
328
- try {
329
- const response = await fetch(url, options);
330
- if (response.status === 429 || response.status === 503) {
331
- if (attempt < maxRetries) {
332
- const retryAfter = response.headers.get("Retry-After");
333
- const waitTime = retryAfter ? parseInt(retryAfter) * 1e3 : Math.min(delay, maxDelay);
334
- const error = new Error(`HTTP ${response.status}: Retrying after ${waitTime}ms`);
335
- if (onRetry) {
336
- onRetry(attempt + 1, error);
337
- }
338
- await sleep(waitTime);
339
- delay *= backoffMultiplier;
340
- continue;
341
- }
342
- }
343
- return response;
344
- } catch (error) {
345
- lastError = error;
346
- const isRetryable = retryableErrors.some(
347
- (errType) => lastError?.message?.includes(errType)
348
- );
349
- if (!isRetryable || attempt === maxRetries) {
350
- throw lastError;
351
- }
352
- const waitTime = Math.min(delay, maxDelay);
353
- if (onRetry) {
354
- onRetry(attempt + 1, lastError);
355
- }
356
- await sleep(waitTime);
357
- delay *= backoffMultiplier;
358
- }
359
- }
360
- throw lastError || new Error("Max retries exceeded");
361
- }
362
- function sleep(ms) {
363
- return new Promise((resolve) => setTimeout(resolve, ms));
364
- }
365
-
366
- // tools/browser/errors.ts
367
- var MorphError = class extends Error {
368
- /** Error code for programmatic handling */
369
- code;
370
- /** Original cause of the error, if any */
371
- cause;
372
- constructor(message, code, cause) {
373
- super(message);
374
- this.name = "MorphError";
375
- this.code = code;
376
- this.cause = cause;
377
- if (Error.captureStackTrace) {
378
- Error.captureStackTrace(this, this.constructor);
379
- }
380
- }
381
- /**
382
- * Returns a JSON representation of the error for logging.
383
- */
384
- toJSON() {
385
- return {
386
- name: this.name,
387
- message: this.message,
388
- code: this.code,
389
- cause: this.cause?.message
390
- };
391
- }
392
- };
393
- var MorphValidationError = class extends MorphError {
394
- /** The field that failed validation */
395
- field;
396
- constructor(message, field) {
397
- super(message, "validation_error");
398
- this.name = "MorphValidationError";
399
- this.field = field;
400
- }
401
- toJSON() {
402
- return {
403
- ...super.toJSON(),
404
- field: this.field
405
- };
406
- }
407
- };
408
- var MorphAPIError = class extends MorphError {
409
- /** HTTP status code */
410
- statusCode;
411
- /** Request ID for debugging (if available) */
412
- requestId;
413
- /** Raw response body */
414
- rawResponse;
415
- constructor(message, code, statusCode, options) {
416
- super(message, code, options?.cause);
417
- this.name = "MorphAPIError";
418
- this.statusCode = statusCode;
419
- this.requestId = options?.requestId;
420
- this.rawResponse = options?.rawResponse;
421
- }
422
- toJSON() {
423
- return {
424
- ...super.toJSON(),
425
- statusCode: this.statusCode,
426
- requestId: this.requestId
427
- };
428
- }
429
- };
430
- var MorphAuthenticationError = class extends MorphAPIError {
431
- constructor(message = "Authentication required. Please provide a valid API key.") {
432
- super(message, "authentication_required", 401);
433
- this.name = "MorphAuthenticationError";
434
- }
435
- };
436
- var MorphRateLimitError = class extends MorphAPIError {
437
- /** When the rate limit resets (Unix timestamp) */
438
- resetAt;
439
- /** Number of seconds until reset */
440
- retryAfter;
441
- constructor(message = "Rate limit exceeded. Please retry later.", options) {
442
- super(message, "rate_limit_exceeded", 429, { requestId: options?.requestId });
443
- this.name = "MorphRateLimitError";
444
- this.resetAt = options?.resetAt;
445
- this.retryAfter = options?.retryAfter;
446
- }
447
- toJSON() {
448
- return {
449
- ...super.toJSON(),
450
- resetAt: this.resetAt,
451
- retryAfter: this.retryAfter
452
- };
453
- }
454
- };
455
- var MorphNotFoundError = class extends MorphAPIError {
456
- /** The type of resource that was not found */
457
- resourceType;
458
- /** The ID of the resource that was not found */
459
- resourceId;
460
- constructor(resourceType, resourceId) {
461
- const message = resourceId ? `${resourceType} '${resourceId}' not found` : `${resourceType} not found`;
462
- super(message, "resource_not_found", 404);
463
- this.name = "MorphNotFoundError";
464
- this.resourceType = resourceType;
465
- this.resourceId = resourceId;
466
- }
467
- toJSON() {
468
- return {
469
- ...super.toJSON(),
470
- resourceType: this.resourceType,
471
- resourceId: this.resourceId
472
- };
473
- }
474
- };
475
- var MorphProfileLimitError = class extends MorphAPIError {
476
- /** Current number of profiles */
477
- currentCount;
478
- /** Maximum allowed profiles for the plan */
479
- maxAllowed;
480
- constructor(message = "Profile limit exceeded for your plan.", options) {
481
- super(message, "profile_limit_exceeded", 403, { requestId: options?.requestId });
482
- this.name = "MorphProfileLimitError";
483
- this.currentCount = options?.currentCount;
484
- this.maxAllowed = options?.maxAllowed;
485
- }
486
- toJSON() {
487
- return {
488
- ...super.toJSON(),
489
- currentCount: this.currentCount,
490
- maxAllowed: this.maxAllowed
491
- };
492
- }
493
- };
494
- function parseAPIError(statusCode, responseText, requestId) {
495
- let errorData = {};
496
- try {
497
- errorData = JSON.parse(responseText);
498
- } catch {
499
- }
500
- const message = errorData.detail || errorData.message || responseText || "Unknown error";
501
- const code = errorData.code;
502
- switch (statusCode) {
503
- case 401:
504
- return new MorphAuthenticationError(message);
505
- case 403:
506
- if (code === "profile_limit_exceeded" || message.toLowerCase().includes("limit")) {
507
- return new MorphProfileLimitError(message, { requestId });
508
- }
509
- return new MorphAPIError(message, "insufficient_permissions", statusCode, { requestId, rawResponse: responseText });
510
- case 404:
511
- if (message.toLowerCase().includes("profile")) {
512
- return new MorphNotFoundError("Profile", void 0);
513
- }
514
- if (message.toLowerCase().includes("session")) {
515
- return new MorphNotFoundError("Session", void 0);
516
- }
517
- return new MorphAPIError(message, "resource_not_found", statusCode, { requestId, rawResponse: responseText });
518
- case 429:
519
- return new MorphRateLimitError(message, { requestId });
520
- case 422:
521
- return new MorphAPIError(message, "validation_error", statusCode, { requestId, rawResponse: responseText });
522
- case 500:
523
- case 502:
524
- case 503:
525
- case 504:
526
- return new MorphAPIError(message, "service_unavailable", statusCode, { requestId, rawResponse: responseText });
527
- default:
528
- return new MorphAPIError(message, "network_error", statusCode, { requestId, rawResponse: responseText });
529
- }
530
- }
531
-
532
- // tools/browser/profiles/types.ts
533
- function transformProfile(api) {
534
- return {
535
- id: api.id,
536
- name: api.name,
537
- repoId: api.repo_id,
538
- cookieDomains: api.cookie_domains,
539
- lastUsedAt: api.last_used_at,
540
- createdAt: api.created_at,
541
- updatedAt: api.updated_at
542
- };
543
- }
544
- function transformCreateInput(input) {
545
- return {
546
- name: input.name,
547
- repo_id: input.repoId
548
- };
549
- }
550
- function transformSession(api) {
551
- return {
552
- sessionId: api.session_id,
553
- debugUrl: api.debug_url || ""
554
- };
555
- }
556
- function transformSaveInput(input) {
557
- return {
558
- session_id: input.sessionId,
559
- profile_id: input.profileId
560
- };
561
- }
562
- function transformStateResponse(api) {
563
- return {
564
- profileId: api.profile_id,
565
- stateUrl: api.state_url,
566
- expiresIn: api.expires_in
567
- };
568
- }
569
-
570
- // tools/browser/profiles/core.ts
571
- var DEFAULT_API_URL = process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com";
572
- var ProfilesClient = class {
573
- config;
574
- constructor(config) {
575
- this.config = config;
576
- }
577
- /**
578
- * Create a new browser profile and immediately start a live session.
579
- *
580
- * @param input - Profile creation parameters
581
- * @returns Profile setup handle with live URL + save()
582
- * @throws {MorphValidationError} If input validation fails
583
- * @throws {MorphProfileLimitError} If profile limit is exceeded
584
- * @throws {MorphAuthenticationError} If API key is missing or invalid
585
- *
586
- * @example
587
- * ```typescript
588
- * const setup = await morph.browser.profiles.createProfile({
589
- * name: 'LinkedIn Production',
590
- * repoId: 'owner/repo'
591
- * });
592
- * console.log(setup.session.debugUrl);
593
- * await setup.save();
594
- * ```
595
- */
596
- async createProfile(input) {
597
- return createProfile(input, this.config);
598
- }
599
- /**
600
- * List all profiles for the authenticated user.
601
- *
602
- * @param repoId - Optional repository ID to filter by
603
- * @returns Array of profiles
604
- *
605
- * @example
606
- * ```typescript
607
- * // List all profiles
608
- * const allProfiles = await morph.browser.profiles.listProfiles();
609
- *
610
- * // List profiles for a specific repo
611
- * const repoProfiles = await morph.browser.profiles.listProfiles('owner/repo');
612
- * ```
613
- */
614
- async listProfiles(repoId) {
615
- return listProfiles(this.config, repoId);
616
- }
617
- /**
618
- * Get a profile by ID with convenience methods.
619
- *
620
- * @param id - Profile ID
621
- * @returns Profile with attached methods
622
- * @throws {MorphNotFoundError} If profile is not found
623
- *
624
- * @example
625
- * ```typescript
626
- * const profile = await morph.browser.profiles.getProfile('profile-id');
627
- * const state = await profile.getState();
628
- * await profile.delete();
629
- * ```
630
- */
631
- async getProfile(id) {
632
- return getProfile(id, this.config);
633
- }
634
- /**
635
- * Update a profile by opening a live session (no rename).
636
- *
637
- * @param id - Profile ID
638
- * @returns Profile setup handle with live URL + save()
639
- */
640
- async updateProfile(id) {
641
- return updateProfile(id, this.config);
642
- }
643
- /**
644
- * Delete a profile.
645
- *
646
- * @param id - Profile ID
647
- * @throws {MorphNotFoundError} If profile is not found
648
- */
649
- async deleteProfile(id) {
650
- return deleteProfile(id, this.config);
651
- }
652
- /**
653
- * Start a browser session for profile setup.
654
- *
655
- * Returns a live URL where the user can sign into accounts.
656
- * After signing in, call `saveSession` to persist the state.
657
- *
658
- * @param input - Optional session parameters
659
- * @returns Session with debug URL
660
- *
661
- * @example
662
- * ```typescript
663
- * const session = await morph.browser.profiles.startSession();
664
- * console.log('Sign in at:', session.debugUrl);
665
- * // Open debugUrl in browser, user signs in...
666
- * await morph.browser.profiles.saveSession(session.sessionId, profile.id);
667
- * ```
668
- */
669
- async startSession(input) {
670
- return startProfileSession(this.config, input);
671
- }
672
- /**
673
- * Save browser state from a session to a profile.
674
- *
675
- * Call this after the user is done signing into accounts.
676
- * Extracts cookies, localStorage, and sessionStorage.
677
- *
678
- * @param sessionId - Browser session ID from startSession
679
- * @param profileId - Profile ID to save state to
680
- * @returns Updated profile with cookie domains
681
- */
682
- async saveSession(sessionId, profileId) {
683
- return saveProfileSession({ sessionId, profileId }, this.config);
684
- }
685
- /**
686
- * List available repo IDs (discovery).
687
- *
688
- * @returns Repo summaries with profile counts
689
- */
690
- async listRepos() {
691
- return listRepos(this.config);
692
- }
693
- /**
694
- * Get the presigned URL for a profile's state.
695
- *
696
- * Use this to download the raw state JSON for debugging
697
- * or to restore state manually.
698
- *
699
- * @param profileId - Profile ID
700
- * @returns State URL with expiry information
701
- */
702
- async getProfileState(profileId) {
703
- return getProfileState(profileId, this.config);
704
- }
705
- };
706
- function validateCreateInput(input) {
707
- if (!input.name || typeof input.name !== "string") {
708
- throw new MorphValidationError("name is required", "name");
709
- }
710
- const trimmedName = input.name.trim();
711
- if (trimmedName.length === 0) {
712
- throw new MorphValidationError("name cannot be empty", "name");
713
- }
714
- if (trimmedName.length > 100) {
715
- throw new MorphValidationError("name must be 100 characters or less", "name");
716
- }
717
- if (!input.repoId || typeof input.repoId !== "string") {
718
- throw new MorphValidationError("repoId is required", "repoId");
719
- }
720
- if (input.repoId.trim().length === 0) {
721
- throw new MorphValidationError("repoId cannot be empty", "repoId");
722
- }
723
- }
724
- function validateId(id, fieldName) {
725
- if (!id || typeof id !== "string") {
726
- throw new MorphValidationError(`${fieldName} is required`, fieldName);
727
- }
728
- if (id.trim().length === 0) {
729
- throw new MorphValidationError(`${fieldName} cannot be empty`, fieldName);
730
- }
731
- }
732
- async function createProfile(input, config = {}) {
733
- validateCreateInput(input);
734
- const apiUrl = config.apiUrl || DEFAULT_API_URL;
735
- const headers = buildHeaders(config);
736
- const response = await fetchWithRetry(
737
- `${apiUrl}/profiles`,
738
- {
739
- method: "POST",
740
- headers,
741
- body: JSON.stringify(transformCreateInput(input))
742
- },
743
- config.retryConfig
744
- );
745
- if (!response.ok) {
746
- const errorText = await response.text().catch(() => response.statusText);
747
- const requestId = response.headers.get("x-request-id") || void 0;
748
- throw parseAPIError(response.status, errorText, requestId);
749
- }
750
- const apiProfile = await response.json();
751
- const profile = transformProfile(apiProfile);
752
- const session = await startProfileSession(config, { profileId: profile.id });
753
- return buildProfileSetup(profile, session, config);
754
- }
755
- async function listProfiles(config = {}, repoId) {
756
- const apiUrl = config.apiUrl || DEFAULT_API_URL;
757
- const headers = buildHeaders(config);
758
- const url = repoId ? `${apiUrl}/profiles?repo_id=${encodeURIComponent(repoId)}` : `${apiUrl}/profiles`;
759
- const response = await fetchWithRetry(
760
- url,
761
- { method: "GET", headers },
762
- config.retryConfig
763
- );
764
- if (!response.ok) {
765
- const errorText = await response.text().catch(() => response.statusText);
766
- const requestId = response.headers.get("x-request-id") || void 0;
767
- throw parseAPIError(response.status, errorText, requestId);
768
- }
769
- const data = await response.json();
770
- return data.profiles.map(transformProfile);
771
- }
772
- async function getProfile(id, config = {}) {
773
- validateId(id, "id");
774
- const apiUrl = config.apiUrl || DEFAULT_API_URL;
775
- const headers = buildHeaders(config);
776
- const response = await fetchWithRetry(
777
- `${apiUrl}/profiles/${encodeURIComponent(id)}`,
778
- { method: "GET", headers },
779
- config.retryConfig
780
- );
781
- if (!response.ok) {
782
- const errorText = await response.text().catch(() => response.statusText);
783
- const requestId = response.headers.get("x-request-id") || void 0;
784
- throw parseAPIError(response.status, errorText, requestId);
785
- }
786
- const apiProfile = await response.json();
787
- const profile = transformProfile(apiProfile);
788
- return {
789
- ...profile,
790
- getState: () => getProfileState(id, config),
791
- delete: () => deleteProfile(id, config)
792
- };
793
- }
794
- async function updateProfile(id, config = {}) {
795
- validateId(id, "id");
796
- const profile = await fetchProfile(id, config);
797
- const session = await startProfileSession(config, { profileId: profile.id });
798
- return buildProfileSetup(profile, session, config);
799
- }
800
- async function deleteProfile(id, config = {}) {
801
- validateId(id, "id");
802
- const apiUrl = config.apiUrl || DEFAULT_API_URL;
803
- const headers = buildHeaders(config);
804
- const response = await fetchWithRetry(
805
- `${apiUrl}/profiles/${encodeURIComponent(id)}`,
806
- { method: "DELETE", headers },
807
- config.retryConfig
808
- );
809
- if (!response.ok) {
810
- const errorText = await response.text().catch(() => response.statusText);
811
- const requestId = response.headers.get("x-request-id") || void 0;
812
- throw parseAPIError(response.status, errorText, requestId);
813
- }
814
- }
815
- async function startProfileSession(config = {}, input) {
816
- if (!config.apiKey) {
817
- throw new MorphAuthenticationError();
818
- }
819
- const apiUrl = config.apiUrl || DEFAULT_API_URL;
820
- const headers = buildHeaders(config);
821
- const body = input?.profileId ? { profile_id: input.profileId } : {};
822
- const response = await fetchWithRetry(
823
- `${apiUrl}/profiles/session/start`,
824
- {
825
- method: "POST",
826
- headers,
827
- body: JSON.stringify(body)
828
- },
829
- config.retryConfig
830
- );
831
- if (!response.ok) {
832
- const errorText = await response.text().catch(() => response.statusText);
833
- const requestId = response.headers.get("x-request-id") || void 0;
834
- throw parseAPIError(response.status, errorText, requestId);
835
- }
836
- const apiSession = await response.json();
837
- return transformSession(apiSession);
838
- }
839
- async function saveProfileSession(input, config = {}) {
840
- validateId(input.sessionId, "sessionId");
841
- validateId(input.profileId, "profileId");
842
- const apiUrl = config.apiUrl || DEFAULT_API_URL;
843
- const headers = buildHeaders(config);
844
- const response = await fetchWithRetry(
845
- `${apiUrl}/profiles/session/save`,
846
- {
847
- method: "POST",
848
- headers,
849
- body: JSON.stringify(transformSaveInput(input))
850
- },
851
- config.retryConfig
852
- );
853
- if (!response.ok) {
854
- const errorText = await response.text().catch(() => response.statusText);
855
- const requestId = response.headers.get("x-request-id") || void 0;
856
- throw parseAPIError(response.status, errorText, requestId);
857
- }
858
- const apiProfile = await response.json();
859
- return transformProfile(apiProfile);
860
- }
861
- async function listRepos(config = {}) {
862
- const apiUrl = config.apiUrl || DEFAULT_API_URL;
863
- const headers = buildHeaders(config);
864
- const response = await fetchWithRetry(
865
- `${apiUrl}/repos`,
866
- { method: "GET", headers },
867
- config.retryConfig
868
- );
869
- if (!response.ok) {
870
- const errorText = await response.text().catch(() => response.statusText);
871
- const requestId = response.headers.get("x-request-id") || void 0;
872
- throw parseAPIError(response.status, errorText, requestId);
873
- }
874
- const data = await response.json();
875
- const repos = Array.isArray(data?.repos) ? data.repos : [];
876
- return repos.map((repo) => ({
877
- repoId: repo.repo_id,
878
- repoFullName: repo.repo_full_name,
879
- profileCount: repo.profile_count ?? 0
880
- }));
881
- }
882
- async function getProfileState(profileId, config = {}) {
883
- validateId(profileId, "profileId");
884
- const apiUrl = config.apiUrl || DEFAULT_API_URL;
885
- const headers = buildHeaders(config);
886
- const response = await fetchWithRetry(
887
- `${apiUrl}/profiles/${encodeURIComponent(profileId)}/state`,
888
- { method: "GET", headers },
889
- config.retryConfig
890
- );
891
- if (!response.ok) {
892
- const errorText = await response.text().catch(() => response.statusText);
893
- const requestId = response.headers.get("x-request-id") || void 0;
894
- throw parseAPIError(response.status, errorText, requestId);
895
- }
896
- const apiState = await response.json();
897
- return transformStateResponse(apiState);
898
- }
899
- function buildHeaders(config) {
900
- const headers = { "Content-Type": "application/json" };
901
- if (config.apiKey) {
902
- headers["Authorization"] = `Bearer ${config.apiKey}`;
903
- }
904
- return headers;
905
- }
906
- async function fetchProfile(id, config) {
907
- const apiUrl = config.apiUrl || DEFAULT_API_URL;
908
- const headers = buildHeaders(config);
909
- const response = await fetchWithRetry(
910
- `${apiUrl}/profiles/${encodeURIComponent(id)}`,
911
- { method: "GET", headers },
912
- config.retryConfig
913
- );
914
- if (!response.ok) {
915
- const errorText = await response.text().catch(() => response.statusText);
916
- const requestId = response.headers.get("x-request-id") || void 0;
917
- throw parseAPIError(response.status, errorText, requestId);
918
- }
919
- const apiProfile = await response.json();
920
- return transformProfile(apiProfile);
921
- }
922
- function buildProfileSetup(profile, session, config) {
923
- return {
924
- profile,
925
- session,
926
- save: () => saveProfileSession({ sessionId: session.sessionId, profileId: profile.id }, config)
927
- };
928
- }
929
- // Annotate the CommonJS export names for ESM import in node:
930
- 0 && (module.exports = {
931
- ProfilesClient,
932
- createProfile,
933
- deleteProfile,
934
- getProfile,
935
- getProfileState,
936
- listProfiles,
937
- listRepos,
938
- saveProfileSession,
939
- startProfileSession,
940
- updateProfile
941
- });
942
- //# sourceMappingURL=core.cjs.map