@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
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../tools/browser/profiles/core.ts"],"sourcesContent":["/**\n * ProfilesClient - Manage browser profiles for storing login state.\n *\n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: '...' });\n *\n * // Create a profile + live setup session\n * const setup = await morph.browser.profiles.createProfile({\n * name: 'LinkedIn',\n * repoId: 'owner/repo'\n * });\n *\n * console.log('Sign in at:', setup.session.debugUrl);\n * // User logs in, then explicitly save\n * await setup.save();\n *\n * // Use profile in browser tasks\n * await morph.browser.execute({\n * task: 'Check notifications',\n * url: 'https://linkedin.com',\n * profileId: profile.id\n * });\n * ```\n */\n\nimport { fetchWithRetry } from '../../utils/resilience.js';\nimport type { BrowserConfig } from '../types.js';\nimport {\n MorphValidationError,\n MorphAuthenticationError,\n parseAPIError,\n} from '../errors.js';\nimport type {\n Profile,\n ProfileSetup,\n ProfileWithMethods,\n CreateProfileInput,\n ProfileListResponse,\n ProfileSession,\n ProfileSessionInput,\n SaveProfileSessionInput,\n ProfileStateResponse,\n RepoSummary,\n RepoListResponse,\n APIProfile,\n APIProfileSession,\n APIProfileStateResponse,\n} from './types.js';\nimport {\n transformProfile,\n transformCreateInput,\n transformSession,\n transformSaveInput,\n transformStateResponse,\n} from './types.js';\n\nconst DEFAULT_API_URL = process.env.MORPH_ENVIRONMENT === 'DEV'\n ? 'http://localhost:8000'\n : 'https://browser.morphllm.com';\n\n/**\n * ProfilesClient class for managing browser profiles.\n *\n * Access via `morph.browser.profiles` on a MorphClient instance.\n */\nexport class ProfilesClient {\n private config: BrowserConfig;\n\n constructor(config: BrowserConfig) {\n this.config = config;\n }\n\n /**\n * Create a new browser profile and immediately start a live session.\n *\n * @param input - Profile creation parameters\n * @returns Profile setup handle with live URL + save()\n * @throws {MorphValidationError} If input validation fails\n * @throws {MorphProfileLimitError} If profile limit is exceeded\n * @throws {MorphAuthenticationError} If API key is missing or invalid\n *\n * @example\n * ```typescript\n * const setup = await morph.browser.profiles.createProfile({\n * name: 'LinkedIn Production',\n * repoId: 'owner/repo'\n * });\n * console.log(setup.session.debugUrl);\n * await setup.save();\n * ```\n */\n async createProfile(input: CreateProfileInput): Promise<ProfileSetup> {\n return createProfile(input, this.config);\n }\n\n /**\n * List all profiles for the authenticated user.\n *\n * @param repoId - Optional repository ID to filter by\n * @returns Array of profiles\n *\n * @example\n * ```typescript\n * // List all profiles\n * const allProfiles = await morph.browser.profiles.listProfiles();\n *\n * // List profiles for a specific repo\n * const repoProfiles = await morph.browser.profiles.listProfiles('owner/repo');\n * ```\n */\n async listProfiles(repoId?: string): Promise<Profile[]> {\n return listProfiles(this.config, repoId);\n }\n\n /**\n * Get a profile by ID with convenience methods.\n *\n * @param id - Profile ID\n * @returns Profile with attached methods\n * @throws {MorphNotFoundError} If profile is not found\n *\n * @example\n * ```typescript\n * const profile = await morph.browser.profiles.getProfile('profile-id');\n * const state = await profile.getState();\n * await profile.delete();\n * ```\n */\n async getProfile(id: string): Promise<ProfileWithMethods> {\n return getProfile(id, this.config);\n }\n\n /**\n * Update a profile by opening a live session (no rename).\n *\n * @param id - Profile ID\n * @returns Profile setup handle with live URL + save()\n */\n async updateProfile(id: string): Promise<ProfileSetup> {\n return updateProfile(id, this.config);\n }\n\n /**\n * Delete a profile.\n *\n * @param id - Profile ID\n * @throws {MorphNotFoundError} If profile is not found\n */\n async deleteProfile(id: string): Promise<void> {\n return deleteProfile(id, this.config);\n }\n\n /**\n * Start a browser session for profile setup.\n *\n * Returns a live URL where the user can sign into accounts.\n * After signing in, call `saveSession` to persist the state.\n *\n * @param input - Optional session parameters\n * @returns Session with debug URL\n *\n * @example\n * ```typescript\n * const session = await morph.browser.profiles.startSession();\n * console.log('Sign in at:', session.debugUrl);\n * // Open debugUrl in browser, user signs in...\n * await morph.browser.profiles.saveSession(session.sessionId, profile.id);\n * ```\n */\n async startSession(input?: ProfileSessionInput): Promise<ProfileSession> {\n return startProfileSession(this.config, input);\n }\n\n /**\n * Save browser state from a session to a profile.\n *\n * Call this after the user is done signing into accounts.\n * Extracts cookies, localStorage, and sessionStorage.\n *\n * @param sessionId - Browser session ID from startSession\n * @param profileId - Profile ID to save state to\n * @returns Updated profile with cookie domains\n */\n async saveSession(sessionId: string, profileId: string): Promise<Profile> {\n return saveProfileSession({ sessionId, profileId }, this.config);\n }\n\n /**\n * List available repo IDs (discovery).\n *\n * @returns Repo summaries with profile counts\n */\n async listRepos(): Promise<RepoSummary[]> {\n return listRepos(this.config);\n }\n\n /**\n * Get the presigned URL for a profile's state.\n *\n * Use this to download the raw state JSON for debugging\n * or to restore state manually.\n *\n * @param profileId - Profile ID\n * @returns State URL with expiry information\n */\n async getProfileState(profileId: string): Promise<ProfileStateResponse> {\n return getProfileState(profileId, this.config);\n }\n}\n\n// ============================================================================\n// Validation Helpers\n// ============================================================================\n\nfunction validateCreateInput(input: CreateProfileInput): void {\n if (!input.name || typeof input.name !== 'string') {\n throw new MorphValidationError('name is required', 'name');\n }\n\n const trimmedName = input.name.trim();\n if (trimmedName.length === 0) {\n throw new MorphValidationError('name cannot be empty', 'name');\n }\n\n if (trimmedName.length > 100) {\n throw new MorphValidationError('name must be 100 characters or less', 'name');\n }\n\n if (!input.repoId || typeof input.repoId !== 'string') {\n throw new MorphValidationError('repoId is required', 'repoId');\n }\n\n if (input.repoId.trim().length === 0) {\n throw new MorphValidationError('repoId cannot be empty', 'repoId');\n }\n}\n\nfunction validateId(id: string, fieldName: string): void {\n if (!id || typeof id !== 'string') {\n throw new MorphValidationError(`${fieldName} is required`, fieldName);\n }\n\n if (id.trim().length === 0) {\n throw new MorphValidationError(`${fieldName} cannot be empty`, fieldName);\n }\n}\n\n// ============================================================================\n// Standalone Functions\n// ============================================================================\n\n/**\n * Create a new browser profile.\n */\nexport async function createProfile(\n input: CreateProfileInput,\n config: BrowserConfig = {}\n): Promise<ProfileSetup> {\n validateCreateInput(input);\n\n const apiUrl = config.apiUrl || DEFAULT_API_URL;\n const headers = buildHeaders(config);\n\n const response = await fetchWithRetry(\n `${apiUrl}/profiles`,\n {\n method: 'POST',\n headers,\n body: JSON.stringify(transformCreateInput(input)),\n },\n config.retryConfig\n );\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n const requestId = response.headers.get('x-request-id') || undefined;\n throw parseAPIError(response.status, errorText, requestId);\n }\n\n const apiProfile: APIProfile = await response.json();\n const profile = transformProfile(apiProfile);\n const session = await startProfileSession(config, { profileId: profile.id });\n return buildProfileSetup(profile, session, config);\n}\n\n/**\n * List all profiles for the authenticated user.\n */\nexport async function listProfiles(\n config: BrowserConfig = {},\n repoId?: string\n): Promise<Profile[]> {\n const apiUrl = config.apiUrl || DEFAULT_API_URL;\n const headers = buildHeaders(config);\n\n const url = repoId\n ? `${apiUrl}/profiles?repo_id=${encodeURIComponent(repoId)}`\n : `${apiUrl}/profiles`;\n\n const response = await fetchWithRetry(\n url,\n { method: 'GET', headers },\n config.retryConfig\n );\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n const requestId = response.headers.get('x-request-id') || undefined;\n throw parseAPIError(response.status, errorText, requestId);\n }\n\n const data: { profiles: APIProfile[] } = await response.json();\n return data.profiles.map(transformProfile);\n}\n\n/**\n * Get a profile by ID with convenience methods.\n */\nexport async function getProfile(\n id: string,\n config: BrowserConfig = {}\n): Promise<ProfileWithMethods> {\n validateId(id, 'id');\n\n const apiUrl = config.apiUrl || DEFAULT_API_URL;\n const headers = buildHeaders(config);\n\n const response = await fetchWithRetry(\n `${apiUrl}/profiles/${encodeURIComponent(id)}`,\n { method: 'GET', headers },\n config.retryConfig\n );\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n const requestId = response.headers.get('x-request-id') || undefined;\n throw parseAPIError(response.status, errorText, requestId);\n }\n\n const apiProfile: APIProfile = await response.json();\n const profile = transformProfile(apiProfile);\n\n // Attach convenience methods\n return {\n ...profile,\n getState: () => getProfileState(id, config),\n delete: () => deleteProfile(id, config),\n };\n}\n\n/**\n * Update a profile.\n */\nexport async function updateProfile(\n id: string,\n config: BrowserConfig = {}\n): Promise<ProfileSetup> {\n validateId(id, 'id');\n const profile = await fetchProfile(id, config);\n const session = await startProfileSession(config, { profileId: profile.id });\n return buildProfileSetup(profile, session, config);\n}\n\n/**\n * Delete a profile.\n */\nexport async function deleteProfile(\n id: string,\n config: BrowserConfig = {}\n): Promise<void> {\n validateId(id, 'id');\n\n const apiUrl = config.apiUrl || DEFAULT_API_URL;\n const headers = buildHeaders(config);\n\n const response = await fetchWithRetry(\n `${apiUrl}/profiles/${encodeURIComponent(id)}`,\n { method: 'DELETE', headers },\n config.retryConfig\n );\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n const requestId = response.headers.get('x-request-id') || undefined;\n throw parseAPIError(response.status, errorText, requestId);\n }\n}\n\n/**\n * Start a browser session for profile setup.\n */\nexport async function startProfileSession(\n config: BrowserConfig = {},\n input?: ProfileSessionInput\n): Promise<ProfileSession> {\n if (!config.apiKey) {\n throw new MorphAuthenticationError();\n }\n\n const apiUrl = config.apiUrl || DEFAULT_API_URL;\n const headers = buildHeaders(config);\n\n // Transform input if provided\n const body = input?.profileId\n ? { profile_id: input.profileId }\n : {};\n\n const response = await fetchWithRetry(\n `${apiUrl}/profiles/session/start`,\n {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n },\n config.retryConfig\n );\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n const requestId = response.headers.get('x-request-id') || undefined;\n throw parseAPIError(response.status, errorText, requestId);\n }\n\n const apiSession: APIProfileSession = await response.json();\n return transformSession(apiSession);\n}\n\n/**\n * Save browser state from a session to a profile.\n */\nexport async function saveProfileSession(\n input: SaveProfileSessionInput,\n config: BrowserConfig = {}\n): Promise<Profile> {\n validateId(input.sessionId, 'sessionId');\n validateId(input.profileId, 'profileId');\n\n const apiUrl = config.apiUrl || DEFAULT_API_URL;\n const headers = buildHeaders(config);\n\n const response = await fetchWithRetry(\n `${apiUrl}/profiles/session/save`,\n {\n method: 'POST',\n headers,\n body: JSON.stringify(transformSaveInput(input)),\n },\n config.retryConfig\n );\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n const requestId = response.headers.get('x-request-id') || undefined;\n throw parseAPIError(response.status, errorText, requestId);\n }\n\n const apiProfile: APIProfile = await response.json();\n return transformProfile(apiProfile);\n}\n\n/**\n * List repo IDs available to the authenticated user/org.\n */\nexport async function listRepos(config: BrowserConfig = {}): Promise<RepoSummary[]> {\n const apiUrl = config.apiUrl || DEFAULT_API_URL;\n const headers = buildHeaders(config);\n\n const response = await fetchWithRetry(\n `${apiUrl}/repos`,\n { method: 'GET', headers },\n config.retryConfig\n );\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n const requestId = response.headers.get('x-request-id') || undefined;\n throw parseAPIError(response.status, errorText, requestId);\n }\n\n const data = await response.json();\n const repos = Array.isArray(data?.repos) ? data.repos : [];\n\n return repos.map((repo: any) => ({\n repoId: repo.repo_id,\n repoFullName: repo.repo_full_name,\n profileCount: repo.profile_count ?? 0,\n })) satisfies RepoSummary[];\n}\n\n/**\n * Get the presigned URL for a profile's state.\n */\nexport async function getProfileState(\n profileId: string,\n config: BrowserConfig = {}\n): Promise<ProfileStateResponse> {\n validateId(profileId, 'profileId');\n\n const apiUrl = config.apiUrl || DEFAULT_API_URL;\n const headers = buildHeaders(config);\n\n const response = await fetchWithRetry(\n `${apiUrl}/profiles/${encodeURIComponent(profileId)}/state`,\n { method: 'GET', headers },\n config.retryConfig\n );\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n const requestId = response.headers.get('x-request-id') || undefined;\n throw parseAPIError(response.status, errorText, requestId);\n }\n\n const apiState: APIProfileStateResponse = await response.json();\n return transformStateResponse(apiState);\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nfunction buildHeaders(config: BrowserConfig): Record<string, string> {\n const headers: Record<string, string> = { 'Content-Type': 'application/json' };\n if (config.apiKey) {\n headers['Authorization'] = `Bearer ${config.apiKey}`;\n }\n return headers;\n}\n\nasync function fetchProfile(id: string, config: BrowserConfig): Promise<Profile> {\n const apiUrl = config.apiUrl || DEFAULT_API_URL;\n const headers = buildHeaders(config);\n\n const response = await fetchWithRetry(\n `${apiUrl}/profiles/${encodeURIComponent(id)}`,\n { method: 'GET', headers },\n config.retryConfig\n );\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n const requestId = response.headers.get('x-request-id') || undefined;\n throw parseAPIError(response.status, errorText, requestId);\n }\n\n const apiProfile: APIProfile = await response.json();\n return transformProfile(apiProfile);\n}\n\nfunction buildProfileSetup(profile: Profile, session: ProfileSession, config: BrowserConfig): ProfileSetup {\n return {\n profile,\n session,\n save: () => saveProfileSession({ sessionId: session.sessionId, profileId: profile.id }, config),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyDA,IAAM,kBAAkB,QAAQ,IAAI,sBAAsB,QACtD,0BACA;AAOG,IAAM,iBAAN,MAAqB;AAAA,EAClB;AAAA,EAER,YAAY,QAAuB;AACjC,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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D;AACA,SAAO;AACT;AAEA,eAAe,aAAa,IAAY,QAAyC;AAC/E,QAAM,SAAS,OAAO,UAAU;AAChC,QAAM,UAAU,aAAa,MAAM;AAEnC,QAAM,WAAW,MAAM;AAAA,IACrB,GAAG,MAAM,aAAa,mBAAmB,EAAE,CAAC;AAAA,IAC5C,EAAE,QAAQ,OAAO,QAAQ;AAAA,IACzB,OAAO;AAAA,EACT;AAEA,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,YAAY,MAAM,SAAS,KAAK,EAAE,MAAM,MAAM,SAAS,UAAU;AACvE,UAAM,YAAY,SAAS,QAAQ,IAAI,cAAc,KAAK;AAC1D,UAAM,cAAc,SAAS,QAAQ,WAAW,SAAS;AAAA,EAC3D;AAEA,QAAM,aAAyB,MAAM,SAAS,KAAK;AACnD,SAAO,iBAAiB,UAAU;AACpC;AAEA,SAAS,kBAAkB,SAAkB,SAAyB,QAAqC;AACzG,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,MAAM,MAAM,mBAAmB,EAAE,WAAW,QAAQ,WAAW,WAAW,QAAQ,GAAG,GAAG,MAAM;AAAA,EAChG;AACF;","names":[]}
@@ -1,80 +0,0 @@
1
- import {
2
- BROWSER_SYSTEM_PROMPT,
3
- BROWSER_TOOL_DESCRIPTION
4
- } from "./chunk-2HMEZZKK.js";
5
- import {
6
- executeBrowserTask
7
- } from "./chunk-YD6TNDR4.js";
8
- import {
9
- __export
10
- } from "./chunk-PZ5AY32C.js";
11
-
12
- // tools/browser/anthropic.ts
13
- var anthropic_exports = {};
14
- __export(anthropic_exports, {
15
- browserTool: () => browserTool,
16
- createBrowserTool: () => createBrowserTool
17
- });
18
- var browserTool = {
19
- name: "browser_task",
20
- description: BROWSER_TOOL_DESCRIPTION,
21
- input_schema: {
22
- type: "object",
23
- properties: {
24
- task: {
25
- type: "string",
26
- description: 'Natural language description of what to do (e.g., "Test checkout flow for buying a pineapple")'
27
- },
28
- url: {
29
- type: "string",
30
- description: "Starting URL (e.g., https://3000-xyz.e2b.dev). Required if navigating to a specific page."
31
- },
32
- maxSteps: {
33
- type: "number",
34
- description: "Maximum number of browser actions to take (1-50). Default: 10. Use 15-30 for complex flows.",
35
- default: 10
36
- },
37
- region: {
38
- type: "string",
39
- enum: ["sfo", "lon"],
40
- description: "Browserless region: sfo (US West Coast) or lon (Europe). Default: sfo.",
41
- default: "sfo"
42
- }
43
- },
44
- required: ["task"]
45
- }
46
- };
47
- function formatResult(result) {
48
- if (result.success) {
49
- const parts = [
50
- "\u2705 Browser task completed successfully",
51
- `Steps taken: ${result.stepsTaken ?? 0}`,
52
- result.executionTimeMs ? `Execution time: ${result.executionTimeMs}ms` : null,
53
- "",
54
- "Result:",
55
- result.result || "Task completed"
56
- ];
57
- return parts.filter(Boolean).join("\n");
58
- }
59
- return `\u274C Browser task failed: ${result.error || "Unknown error"}`;
60
- }
61
- function createBrowserTool(config) {
62
- return Object.assign({}, browserTool, {
63
- execute: async (input) => {
64
- return executeBrowserTask(input, config);
65
- },
66
- formatResult: (result) => {
67
- return formatResult(result);
68
- },
69
- getSystemPrompt: () => {
70
- return BROWSER_SYSTEM_PROMPT;
71
- }
72
- });
73
- }
74
-
75
- export {
76
- browserTool,
77
- createBrowserTool,
78
- anthropic_exports
79
- };
80
- //# sourceMappingURL=chunk-XH6KJJDI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../tools/browser/anthropic.ts"],"sourcesContent":["/**\n * Anthropic SDK adapter for browser automation tool\n */\n\nimport type { Tool } from '@anthropic-ai/sdk/resources/messages.mjs';\nimport { executeBrowserTask } from './core.js';\nimport type {\n BrowserConfig,\n BrowserTaskInput,\n BrowserTaskResult,\n} from './types.js';\nimport { BROWSER_TOOL_DESCRIPTION, BROWSER_SYSTEM_PROMPT } from './prompts.js';\n\n/**\n * Anthropic tool definition for browser automation\n */\nexport const browserTool: Tool = {\n name: 'browser_task',\n description: BROWSER_TOOL_DESCRIPTION,\n input_schema: {\n type: 'object',\n properties: {\n task: {\n type: 'string',\n description: 'Natural language description of what to do (e.g., \"Test checkout flow for buying a pineapple\")',\n },\n url: {\n type: 'string',\n description: 'Starting URL (e.g., https://3000-xyz.e2b.dev). Required if navigating to a specific page.',\n },\n maxSteps: {\n type: 'number',\n description: 'Maximum number of browser actions to take (1-50). Default: 10. Use 15-30 for complex flows.',\n default: 10,\n },\n region: {\n type: 'string',\n enum: ['sfo', 'lon'],\n description: 'Browserless region: sfo (US West Coast) or lon (Europe). Default: sfo.',\n default: 'sfo',\n },\n },\n required: ['task'],\n },\n};\n\n/**\n * Format browser task result for Anthropic tool result\n * \n * Returns a concise summary suitable for agent context. The full result object\n * (with urls, errors, action_history, judgement, etc.) is available when calling\n * execute() directly, but this formatted string omits those details to save tokens.\n * \n * @param result - Browser task result with full history data\n * @returns Formatted string summary for tool result\n */\nfunction formatResult(result: BrowserTaskResult): string {\n if (result.success) {\n const parts = [\n '✅ Browser task completed successfully',\n `Steps taken: ${result.stepsTaken ?? 0}`,\n result.executionTimeMs ? `Execution time: ${result.executionTimeMs}ms` : null,\n '',\n 'Result:',\n result.result || 'Task completed',\n ];\n return parts.filter(Boolean).join('\\n');\n }\n\n return `❌ Browser task failed: ${result.error || 'Unknown error'}`;\n}\n\n/**\n * Create a configured browser tool with execute and formatResult methods\n * \n * @param config - Browser worker configuration\n * @returns Tool definition with execute and formatResult methods\n * \n * @example\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { createBrowserTool } from 'morphsdk/tools/browser/anthropic';\n * \n * const tool = createBrowserTool({\n * apiKey: process.env.MORPH_API_KEY,\n * timeout: 180000\n * });\n * \n * const client = new Anthropic();\n * \n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [tool], // tool itself is the Tool definition\n * messages: [{\n * role: 'user',\n * content: 'Test the checkout flow at https://3000-abc.e2b.dev'\n * }]\n * });\n * \n * // Execute and format\n * const result = await tool.execute(toolUseBlock.input);\n * const formatted = tool.formatResult(result);\n * ```\n */\nexport function createBrowserTool(config?: BrowserConfig) {\n return Object.assign({}, browserTool, {\n execute: async (input: BrowserTaskInput): Promise<BrowserTaskResult> => {\n return executeBrowserTask(input, config);\n },\n formatResult: (result: BrowserTaskResult): string => {\n return formatResult(result);\n },\n getSystemPrompt: (): string => {\n return BROWSER_SYSTEM_PROMPT;\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,IAAM,cAAoB;AAAA,EAC/B,MAAM;AAAA,EACN,aAAa;AAAA,EACb,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA,KAAK;AAAA,QACH,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA,UAAU;AAAA,QACR,MAAM;AAAA,QACN,aAAa;AAAA,QACb,SAAS;AAAA,MACX;AAAA,MACA,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,MAAM,CAAC,OAAO,KAAK;AAAA,QACnB,aAAa;AAAA,QACb,SAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,UAAU,CAAC,MAAM;AAAA,EACnB;AACF;AAYA,SAAS,aAAa,QAAmC;AACvD,MAAI,OAAO,SAAS;AAClB,UAAM,QAAQ;AAAA,MACZ;AAAA,MACA,gBAAgB,OAAO,cAAc,CAAC;AAAA,MACtC,OAAO,kBAAkB,mBAAmB,OAAO,eAAe,OAAO;AAAA,MACzE;AAAA,MACA;AAAA,MACA,OAAO,UAAU;AAAA,IACnB;AACA,WAAO,MAAM,OAAO,OAAO,EAAE,KAAK,IAAI;AAAA,EACxC;AAEA,SAAO,+BAA0B,OAAO,SAAS,eAAe;AAClE;AAkCO,SAAS,kBAAkB,QAAwB;AACxD,SAAO,OAAO,OAAO,CAAC,GAAG,aAAa;AAAA,IACpC,SAAS,OAAO,UAAwD;AACtE,aAAO,mBAAmB,OAAO,MAAM;AAAA,IACzC;AAAA,IACA,cAAc,CAAC,WAAsC;AACnD,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,IACA,iBAAiB,MAAc;AAC7B,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;","names":[]}