@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.
- package/README.md +1 -147
- package/dist/{chunk-GE5MNVT7.js → chunk-5KQ2WRBU.js} +2 -2
- package/dist/{chunk-LKFZBBTD.js → chunk-5TOJD2C5.js} +1 -1
- package/dist/chunk-5TOJD2C5.js.map +1 -0
- package/dist/{chunk-PQCOBN7L.js → chunk-7UU4NF4G.js} +4 -10
- package/dist/chunk-7UU4NF4G.js.map +1 -0
- package/dist/{chunk-6YZCPCAY.js → chunk-BLCCGRKT.js} +2 -2
- package/dist/{chunk-2BT4UGKH.js → chunk-BTMMUG3E.js} +2 -2
- package/dist/{chunk-VJD6MF3M.js → chunk-CEXBKXWU.js} +4 -4
- package/dist/{chunk-UOS3XKJD.js → chunk-DP2PT36G.js} +2 -2
- package/dist/{chunk-CZ74CRGH.js → chunk-EMURAU6J.js} +4 -6
- package/dist/chunk-EMURAU6J.js.map +1 -0
- package/dist/chunk-GKRPR5PZ.js +322 -0
- package/dist/chunk-GKRPR5PZ.js.map +1 -0
- package/dist/{chunk-DNL4DMMS.js → chunk-GTV27THY.js} +2 -2
- package/dist/{chunk-ATAKRJQZ.js → chunk-IDMKQWQG.js} +1 -36
- package/dist/chunk-IDMKQWQG.js.map +1 -0
- package/dist/{chunk-EGI642TV.js → chunk-JOC3ZI56.js} +3 -39
- package/dist/chunk-JOC3ZI56.js.map +1 -0
- package/dist/{chunk-VGCPVDFP.js → chunk-K2JR2NFQ.js} +4 -4
- package/dist/{chunk-DHGXGVHC.js → chunk-KXEPBLVD.js} +8 -8
- package/dist/{chunk-SVD3YRWM.js → chunk-MEZTHMB2.js} +4 -4
- package/dist/{chunk-BECYWCEZ.js → chunk-O7LJEVZO.js} +2 -2
- package/dist/{chunk-7QOGUY4A.js → chunk-PKJ7ODTG.js} +4 -4
- package/dist/{chunk-2HXELZI5.js → chunk-PW6K6OJL.js} +2 -2
- package/dist/chunk-PW6K6OJL.js.map +1 -0
- package/dist/{chunk-YVKRPVOM.js → chunk-Q3NH3NPD.js} +2 -2
- package/dist/{chunk-ZA3UJRSE.js → chunk-RL3ZTXT3.js} +4 -4
- package/dist/{chunk-WN6YLBEH.js → chunk-ULHHMZRL.js} +4 -4
- package/dist/{chunk-TJUZAO7T.js → chunk-UT3NQLCF.js} +2 -2
- package/dist/{chunk-DW6ZIVCM.js → chunk-VS5F2ORN.js} +4 -4
- package/dist/{chunk-UZA2ODNU.js → chunk-W37OFBSG.js} +2 -2
- package/dist/{chunk-JU6TCHVI.js → chunk-WDBYAXZ5.js} +2 -2
- package/dist/{chunk-2XDSHAB5.js → chunk-YSFEKIYQ.js} +2 -2
- package/dist/{chunk-WDLDKJHT.js → chunk-ZHB57ORD.js} +6 -6
- package/dist/client-CGW0Cevz.d.ts +402 -0
- package/dist/client.cjs +195 -2068
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +3 -11
- package/dist/client.js +28 -35
- package/dist/core/client.cjs +2 -44
- package/dist/core/client.cjs.map +1 -1
- package/dist/core/client.d.ts +2 -10
- package/dist/core/client.js +4 -4
- package/dist/core/error.cjs +2 -38
- package/dist/core/error.cjs.map +1 -1
- package/dist/core/error.d.ts +1 -1
- package/dist/core/error.js +3 -3
- package/dist/core/index.cjs +2 -44
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +5 -5
- package/dist/core/resource.cjs.map +1 -1
- package/dist/core/resource.d.ts +1 -1
- package/dist/core/resource.js +1 -1
- package/dist/edge.cjs +2 -44
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +8 -8
- package/dist/index.cjs +195 -2086
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -9
- package/dist/index.js +30 -58
- package/dist/modelrouter/core.cjs +2 -44
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +6 -6
- package/dist/modelrouter/index.cjs +2 -44
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +6 -6
- package/dist/subagents/anthropic.cjs +2 -44
- package/dist/subagents/anthropic.cjs.map +1 -1
- package/dist/subagents/anthropic.js +12 -12
- package/dist/subagents/vercel.cjs +2 -44
- package/dist/subagents/vercel.cjs.map +1 -1
- package/dist/subagents/vercel.js +12 -12
- package/dist/tools/codebase_search/anthropic.cjs +2 -44
- package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +7 -7
- package/dist/tools/codebase_search/core.cjs +2 -44
- package/dist/tools/codebase_search/core.cjs.map +1 -1
- package/dist/tools/codebase_search/core.js +6 -6
- package/dist/tools/codebase_search/index.cjs +2 -44
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.js +11 -11
- package/dist/tools/codebase_search/openai.cjs +2 -44
- package/dist/tools/codebase_search/openai.cjs.map +1 -1
- package/dist/tools/codebase_search/openai.js +7 -7
- package/dist/tools/codebase_search/vercel.cjs +2 -44
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +7 -7
- package/dist/tools/compact/core.cjs +2 -44
- package/dist/tools/compact/core.cjs.map +1 -1
- package/dist/tools/compact/core.js +6 -6
- package/dist/tools/compact/index.cjs +2 -44
- package/dist/tools/compact/index.cjs.map +1 -1
- package/dist/tools/compact/index.js +7 -7
- package/dist/tools/fastapply/anthropic.cjs +2 -38
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +8 -8
- package/dist/tools/fastapply/apply.cjs +2 -38
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +2 -44
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +7 -7
- package/dist/tools/fastapply/index.cjs +2 -38
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +12 -12
- package/dist/tools/fastapply/openai.cjs +2 -38
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +8 -8
- package/dist/tools/fastapply/vercel.cjs +2 -38
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +8 -8
- package/dist/tools/index.cjs +2 -38
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +12 -12
- package/dist/tools/utils/resilience.cjs +2 -38
- package/dist/tools/utils/resilience.cjs.map +1 -1
- package/dist/tools/utils/resilience.js +2 -2
- package/dist/tools/warp_grep/agent/runner.cjs +2 -38
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +3 -3
- package/dist/tools/warp_grep/anthropic.cjs +2 -44
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +12 -12
- package/dist/tools/warp_grep/client.cjs +2 -44
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +11 -11
- package/dist/tools/warp_grep/gemini.cjs +2 -44
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.js +11 -11
- package/dist/tools/warp_grep/harness.js +7 -7
- package/dist/tools/warp_grep/index.cjs +2 -44
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.js +14 -14
- package/dist/tools/warp_grep/openai.cjs +2 -44
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +12 -12
- package/dist/tools/warp_grep/vercel.cjs +2 -44
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +12 -12
- package/dist/tracing/core.cjs +2 -34
- package/dist/tracing/core.cjs.map +1 -1
- package/dist/tracing/core.d.ts +1 -2
- package/dist/tracing/core.js +2 -2
- package/dist/tracing/index.cjs +4 -42
- package/dist/tracing/index.cjs.map +1 -1
- package/dist/tracing/index.d.ts +0 -34
- package/dist/tracing/index.js +3 -10
- package/dist/tracing/interaction.cjs +0 -30
- package/dist/tracing/interaction.cjs.map +1 -1
- package/dist/tracing/interaction.js +1 -1
- package/dist/tracing/types.cjs.map +1 -1
- package/dist/tracing/types.d.ts +1 -27
- package/dist/version.cjs +2 -38
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -38
- package/dist/anthropic-B6my2oBx.d.ts +0 -56
- package/dist/chunk-2AMEQAO2.js +0 -46
- package/dist/chunk-2AMEQAO2.js.map +0 -1
- package/dist/chunk-2HMEZZKK.js +0 -44
- package/dist/chunk-2HMEZZKK.js.map +0 -1
- package/dist/chunk-2HXELZI5.js.map +0 -1
- package/dist/chunk-2VERUKO2.js +0 -177
- package/dist/chunk-2VERUKO2.js.map +0 -1
- package/dist/chunk-4FWK3CEH.js +0 -692
- package/dist/chunk-4FWK3CEH.js.map +0 -1
- package/dist/chunk-ATAKRJQZ.js.map +0 -1
- package/dist/chunk-CZ74CRGH.js.map +0 -1
- package/dist/chunk-EGI642TV.js.map +0 -1
- package/dist/chunk-FLWBVHDC.js +0 -622
- package/dist/chunk-FLWBVHDC.js.map +0 -1
- package/dist/chunk-JZJY2XFQ.js +0 -96
- package/dist/chunk-JZJY2XFQ.js.map +0 -1
- package/dist/chunk-LKFZBBTD.js.map +0 -1
- package/dist/chunk-LRHJVSSD.js +0 -57
- package/dist/chunk-LRHJVSSD.js.map +0 -1
- package/dist/chunk-NKFAMQF2.js +0 -202
- package/dist/chunk-NKFAMQF2.js.map +0 -1
- package/dist/chunk-PQCOBN7L.js.map +0 -1
- package/dist/chunk-TCCZBGG5.js +0 -46
- package/dist/chunk-TCCZBGG5.js.map +0 -1
- package/dist/chunk-W34BUTVR.js +0 -389
- package/dist/chunk-W34BUTVR.js.map +0 -1
- package/dist/chunk-WFOGTZF6.js +0 -80
- package/dist/chunk-WFOGTZF6.js.map +0 -1
- package/dist/chunk-YTYCHRQ2.js +0 -106
- package/dist/chunk-YTYCHRQ2.js.map +0 -1
- package/dist/client-B3fWTCcL.d.ts +0 -1021
- package/dist/openai-BQMeDFef.d.ts +0 -81
- package/dist/tools/browser/anthropic.cjs +0 -655
- package/dist/tools/browser/anthropic.cjs.map +0 -1
- package/dist/tools/browser/anthropic.d.ts +0 -4
- package/dist/tools/browser/anthropic.js +0 -22
- package/dist/tools/browser/anthropic.js.map +0 -1
- package/dist/tools/browser/core.cjs +0 -1831
- package/dist/tools/browser/core.cjs.map +0 -1
- package/dist/tools/browser/core.d.ts +0 -245
- package/dist/tools/browser/core.js +0 -32
- package/dist/tools/browser/core.js.map +0 -1
- package/dist/tools/browser/errors.cjs +0 -208
- package/dist/tools/browser/errors.cjs.map +0 -1
- package/dist/tools/browser/errors.d.ts +0 -158
- package/dist/tools/browser/errors.js +0 -22
- package/dist/tools/browser/errors.js.map +0 -1
- package/dist/tools/browser/index.cjs +0 -2169
- package/dist/tools/browser/index.cjs.map +0 -1
- package/dist/tools/browser/index.d.ts +0 -134
- package/dist/tools/browser/index.js +0 -163
- package/dist/tools/browser/index.js.map +0 -1
- package/dist/tools/browser/live.cjs +0 -134
- package/dist/tools/browser/live.cjs.map +0 -1
- package/dist/tools/browser/live.d.ts +0 -75
- package/dist/tools/browser/live.js +0 -16
- package/dist/tools/browser/live.js.map +0 -1
- package/dist/tools/browser/openai.cjs +0 -671
- package/dist/tools/browser/openai.cjs.map +0 -1
- package/dist/tools/browser/openai.d.ts +0 -4
- package/dist/tools/browser/openai.js +0 -28
- package/dist/tools/browser/openai.js.map +0 -1
- package/dist/tools/browser/profiles/core.cjs +0 -942
- package/dist/tools/browser/profiles/core.cjs.map +0 -1
- package/dist/tools/browser/profiles/core.d.ts +0 -187
- package/dist/tools/browser/profiles/core.js +0 -30
- package/dist/tools/browser/profiles/core.js.map +0 -1
- package/dist/tools/browser/profiles/index.cjs +0 -942
- package/dist/tools/browser/profiles/index.cjs.map +0 -1
- package/dist/tools/browser/profiles/index.d.ts +0 -4
- package/dist/tools/browser/profiles/index.js +0 -30
- package/dist/tools/browser/profiles/index.js.map +0 -1
- package/dist/tools/browser/profiles/types.cjs +0 -74
- package/dist/tools/browser/profiles/types.cjs.map +0 -1
- package/dist/tools/browser/profiles/types.d.ts +0 -195
- package/dist/tools/browser/profiles/types.js +0 -16
- package/dist/tools/browser/profiles/types.js.map +0 -1
- package/dist/tools/browser/prompts.cjs +0 -69
- package/dist/tools/browser/prompts.cjs.map +0 -1
- package/dist/tools/browser/prompts.d.ts +0 -7
- package/dist/tools/browser/prompts.js +0 -10
- package/dist/tools/browser/prompts.js.map +0 -1
- package/dist/tools/browser/types.cjs +0 -19
- package/dist/tools/browser/types.cjs.map +0 -1
- package/dist/tools/browser/types.d.ts +0 -338
- package/dist/tools/browser/types.js +0 -1
- package/dist/tools/browser/types.js.map +0 -1
- package/dist/tools/browser/vercel.cjs +0 -632
- package/dist/tools/browser/vercel.cjs.map +0 -1
- package/dist/tools/browser/vercel.d.ts +0 -4
- package/dist/tools/browser/vercel.js +0 -22
- package/dist/tools/browser/vercel.js.map +0 -1
- package/dist/tools/reflex/core.cjs +0 -756
- package/dist/tools/reflex/core.cjs.map +0 -1
- package/dist/tools/reflex/core.d.ts +0 -59
- package/dist/tools/reflex/core.js +0 -16
- package/dist/tools/reflex/core.js.map +0 -1
- package/dist/tools/reflex/index.cjs +0 -756
- package/dist/tools/reflex/index.cjs.map +0 -1
- package/dist/tools/reflex/index.d.ts +0 -5
- package/dist/tools/reflex/index.js +0 -16
- package/dist/tools/reflex/index.js.map +0 -1
- package/dist/tools/reflex/types.cjs +0 -19
- package/dist/tools/reflex/types.cjs.map +0 -1
- package/dist/tools/reflex/types.d.ts +0 -171
- package/dist/tools/reflex/types.js +0 -1
- package/dist/tools/reflex/types.js.map +0 -1
- package/dist/tools/traces/core.cjs +0 -76
- package/dist/tools/traces/core.cjs.map +0 -1
- package/dist/tools/traces/core.d.ts +0 -24
- package/dist/tools/traces/core.js +0 -9
- package/dist/tools/traces/core.js.map +0 -1
- package/dist/tools/traces/index.cjs +0 -76
- package/dist/tools/traces/index.cjs.map +0 -1
- package/dist/tools/traces/index.d.ts +0 -5
- package/dist/tools/traces/index.js +0 -9
- package/dist/tools/traces/index.js.map +0 -1
- package/dist/tools/traces/types.cjs +0 -19
- package/dist/tools/traces/types.cjs.map +0 -1
- package/dist/tools/traces/types.d.ts +0 -56
- package/dist/tools/traces/types.js +0 -1
- package/dist/tools/traces/types.js.map +0 -1
- package/dist/vercel-CVF27qFK.d.ts +0 -74
- /package/dist/{chunk-GE5MNVT7.js.map → chunk-5KQ2WRBU.js.map} +0 -0
- /package/dist/{chunk-6YZCPCAY.js.map → chunk-BLCCGRKT.js.map} +0 -0
- /package/dist/{chunk-2BT4UGKH.js.map → chunk-BTMMUG3E.js.map} +0 -0
- /package/dist/{chunk-VJD6MF3M.js.map → chunk-CEXBKXWU.js.map} +0 -0
- /package/dist/{chunk-UOS3XKJD.js.map → chunk-DP2PT36G.js.map} +0 -0
- /package/dist/{chunk-DNL4DMMS.js.map → chunk-GTV27THY.js.map} +0 -0
- /package/dist/{chunk-VGCPVDFP.js.map → chunk-K2JR2NFQ.js.map} +0 -0
- /package/dist/{chunk-DHGXGVHC.js.map → chunk-KXEPBLVD.js.map} +0 -0
- /package/dist/{chunk-SVD3YRWM.js.map → chunk-MEZTHMB2.js.map} +0 -0
- /package/dist/{chunk-BECYWCEZ.js.map → chunk-O7LJEVZO.js.map} +0 -0
- /package/dist/{chunk-7QOGUY4A.js.map → chunk-PKJ7ODTG.js.map} +0 -0
- /package/dist/{chunk-YVKRPVOM.js.map → chunk-Q3NH3NPD.js.map} +0 -0
- /package/dist/{chunk-ZA3UJRSE.js.map → chunk-RL3ZTXT3.js.map} +0 -0
- /package/dist/{chunk-WN6YLBEH.js.map → chunk-ULHHMZRL.js.map} +0 -0
- /package/dist/{chunk-TJUZAO7T.js.map → chunk-UT3NQLCF.js.map} +0 -0
- /package/dist/{chunk-DW6ZIVCM.js.map → chunk-VS5F2ORN.js.map} +0 -0
- /package/dist/{chunk-UZA2ODNU.js.map → chunk-W37OFBSG.js.map} +0 -0
- /package/dist/{chunk-JU6TCHVI.js.map → chunk-WDBYAXZ5.js.map} +0 -0
- /package/dist/{chunk-2XDSHAB5.js.map → chunk-YSFEKIYQ.js.map} +0 -0
- /package/dist/{chunk-WDLDKJHT.js.map → chunk-ZHB57ORD.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/browser/profiles/types.ts"],"sourcesContent":["/**\n * Type definitions for browser profiles.\n *\n * All types use camelCase for SDK ergonomics.\n * API responses are normalized from snake_case to camelCase.\n */\n\n/**\n * A browser profile that stores login state (cookies, localStorage).\n *\n * @example\n * ```typescript\n * const profile = await morph.browser.profiles.getProfile('profile-id');\n * console.log(profile.cookieDomains); // ['linkedin.com', 'google.com']\n * ```\n */\nexport interface Profile {\n /** Unique profile identifier (UUID) */\n id: string;\n /** Human-readable profile name */\n name: string;\n /** Repository ID this profile is associated with */\n repoId: string;\n /** List of domains with stored cookies */\n cookieDomains?: string[];\n /** ISO 8601 timestamp of last use */\n lastUsedAt?: string;\n /** ISO 8601 timestamp of creation */\n createdAt: string;\n /** ISO 8601 timestamp of last update */\n updatedAt: string;\n}\n\n/**\n * Input for creating a new profile.\n *\n * @example\n * ```typescript\n * await morph.browser.profiles.createProfile({\n * name: 'LinkedIn Production',\n * repoId: 'owner/repo'\n * });\n * ```\n */\nexport interface CreateProfileInput {\n /** Profile name (1-100 characters) */\n name: string;\n /** Repository ID - profiles are repo-specific */\n repoId: string;\n}\n\n/**\n * Input for updating a profile.\n */\n// Intentionally no UpdateProfileInput: update means \"open a live session\"\n\n/**\n * Response for listing profiles.\n */\nexport interface ProfileListResponse {\n profiles: Profile[];\n}\n\n/**\n * A browser session for profile setup.\n *\n * @example\n * ```typescript\n * const session = await morph.browser.profiles.startSession();\n * console.log('Sign in at:', session.debugUrl);\n * // After user signs in...\n * await morph.browser.profiles.saveSession(session.sessionId, profile.id);\n * ```\n */\nexport interface ProfileSession {\n /** Unique session identifier */\n sessionId: string;\n /** Live session URL for viewing/interacting with the browser */\n debugUrl: string;\n}\n\n/**\n * Profile setup handle returned by create/update.\n *\n * Provides a live URL for login and an explicit save() helper.\n */\nexport interface ProfileSetup {\n profile: Profile;\n session: ProfileSession;\n save: () => Promise<Profile>;\n}\n/**\n * Input for starting a profile session.\n */\nexport interface ProfileSessionInput {\n /** Optional profile ID to update an existing profile */\n profileId?: string;\n}\n\n/**\n * Input for saving a profile session.\n */\nexport interface SaveProfileSessionInput {\n /** The browser session ID to extract state from */\n sessionId: string;\n /** The profile ID to save state to */\n profileId: string;\n}\n\n/**\n * Response for profile state URL.\n */\nexport interface ProfileStateResponse {\n /** Profile ID */\n profileId: string;\n /** Presigned URL to download the profile state (expires in `expiresIn` seconds) */\n stateUrl: string;\n /** URL expiry time in seconds */\n expiresIn: number;\n}\n\n/**\n * Repo summary for profile discovery.\n */\nexport interface RepoSummary {\n repoId: string;\n repoFullName?: string;\n profileCount: number;\n}\n\n/**\n * Response for repo discovery.\n */\nexport interface RepoListResponse {\n repos: RepoSummary[];\n}\n\n/**\n * Profile with convenience methods attached.\n *\n * @example\n * ```typescript\n * const profile = await morph.browser.profiles.getProfile('id');\n * const state = await profile.getState();\n * await profile.delete();\n * ```\n */\nexport interface ProfileWithMethods extends Profile {\n /** Get presigned URL for profile state */\n getState: () => Promise<ProfileStateResponse>;\n /** Delete this profile */\n delete: () => Promise<void>;\n}\n\n// ============================================================================\n// Internal API types (snake_case - matches backend response)\n// ============================================================================\n\n/** @internal API response format */\nexport interface APIProfile {\n id: string;\n name: string;\n repo_id: string;\n cookie_domains?: string[];\n last_used_at?: string;\n created_at: string;\n updated_at: string;\n}\n\n/** @internal API response format */\nexport interface APIProfileSession {\n session_id: string;\n debug_url?: string;\n}\n\n/** @internal API response format */\nexport interface APIProfileStateResponse {\n profile_id: string;\n state_url: string;\n expires_in: number;\n}\n\n// ============================================================================\n// Transformers\n// ============================================================================\n\n/**\n * Transform API profile response to SDK format.\n * @internal\n */\nexport function transformProfile(api: APIProfile): Profile {\n return {\n id: api.id,\n name: api.name,\n repoId: api.repo_id,\n cookieDomains: api.cookie_domains,\n lastUsedAt: api.last_used_at,\n createdAt: api.created_at,\n updatedAt: api.updated_at,\n };\n}\n\n/**\n * Transform SDK input to API format.\n * @internal\n */\nexport function transformCreateInput(input: CreateProfileInput): { name: string; repo_id: string } {\n return {\n name: input.name,\n repo_id: input.repoId,\n };\n}\n\n/**\n * Transform API session response to SDK format.\n * @internal\n */\nexport function transformSession(api: APIProfileSession): ProfileSession {\n return {\n sessionId: api.session_id,\n debugUrl: api.debug_url || '',\n };\n}\n\n/**\n * Transform SDK save input to API format.\n * @internal\n */\nexport function transformSaveInput(input: SaveProfileSessionInput): { session_id: string; profile_id: string } {\n return {\n session_id: input.sessionId,\n profile_id: input.profileId,\n };\n}\n\n/**\n * Transform API state response to SDK format.\n * @internal\n */\nexport function transformStateResponse(api: APIProfileStateResponse): ProfileStateResponse {\n return {\n profileId: api.profile_id,\n stateUrl: api.state_url,\n expiresIn: api.expires_in,\n };\n}\n"],"mappings":";AA8LO,SAAS,iBAAiB,KAA0B;AACzD,SAAO;AAAA,IACL,IAAI,IAAI;AAAA,IACR,MAAM,IAAI;AAAA,IACV,QAAQ,IAAI;AAAA,IACZ,eAAe,IAAI;AAAA,IACnB,YAAY,IAAI;AAAA,IAChB,WAAW,IAAI;AAAA,IACf,WAAW,IAAI;AAAA,EACjB;AACF;AAMO,SAAS,qBAAqB,OAA8D;AACjG,SAAO;AAAA,IACL,MAAM,MAAM;AAAA,IACZ,SAAS,MAAM;AAAA,EACjB;AACF;AAMO,SAAS,iBAAiB,KAAwC;AACvE,SAAO;AAAA,IACL,WAAW,IAAI;AAAA,IACf,UAAU,IAAI,aAAa;AAAA,EAC7B;AACF;AAMO,SAAS,mBAAmB,OAA4E;AAC7G,SAAO;AAAA,IACL,YAAY,MAAM;AAAA,IAClB,YAAY,MAAM;AAAA,EACpB;AACF;AAMO,SAAS,uBAAuB,KAAoD;AACzF,SAAO;AAAA,IACL,WAAW,IAAI;AAAA,IACf,UAAU,IAAI;AAAA,IACd,WAAW,IAAI;AAAA,EACjB;AACF;","names":[]}
|
package/dist/chunk-2HMEZZKK.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// tools/browser/prompts.ts
|
|
2
|
-
var BROWSER_TOOL_DESCRIPTION = `Test and verify your implemented code in a live browser. This tool executes natural language test instructions and returns a video recording plus detailed logs to help you debug issues.
|
|
3
|
-
|
|
4
|
-
## When to Use
|
|
5
|
-
Use this AFTER coding is complete to verify your implementation:
|
|
6
|
-
- You've finished writing/modifying code and need to verify it works
|
|
7
|
-
- You need to test user interactions end-to-end (clicks, forms, navigation)
|
|
8
|
-
- You want to catch runtime errors, console warnings, or network failures
|
|
9
|
-
- You need visual confirmation that UI elements render and behave correctly
|
|
10
|
-
|
|
11
|
-
## What You Get Back
|
|
12
|
-
The tool returns debugging artifacts to help you identify and fix issues:
|
|
13
|
-
- **Video recording**: Watch exactly what happened in the browser session
|
|
14
|
-
- **Console logs**: All console.log, warnings, and errors with timestamps
|
|
15
|
-
- **Network logs**: Failed requests, 404s, API errors with screenshots
|
|
16
|
-
- **Error screenshots**: Visual snapshots captured when errors occur
|
|
17
|
-
|
|
18
|
-
## How to Write Good Tests
|
|
19
|
-
Be specific about the user journey you're testing:
|
|
20
|
-
\u274C Bad: "Test the login feature"
|
|
21
|
-
\u2705 Good: "Navigate to /login, enter 'test@example.com' and 'password123', click the Login button, verify we reach the /dashboard page"
|
|
22
|
-
|
|
23
|
-
Include verification steps:
|
|
24
|
-
\u2705 "Click the Add Item button, verify the item appears in the list"
|
|
25
|
-
\u2705 "Submit the form, verify a success message is displayed"
|
|
26
|
-
|
|
27
|
-
## Iterating on Failures
|
|
28
|
-
1. Run the test and review the video + logs
|
|
29
|
-
2. Identify the specific issue (console error, failed request, wrong behavior)
|
|
30
|
-
3. Fix the code based on the evidence
|
|
31
|
-
4. Re-run the test to verify the fix
|
|
32
|
-
5. Repeat until test passes
|
|
33
|
-
|
|
34
|
-
## Requirements
|
|
35
|
-
- **URL**: Must be publicly accessible (use tunnels like ngrok, Cloudflare, or deploy to staging)
|
|
36
|
-
- **Timing**: Use this after implementation, not during coding
|
|
37
|
-
- **Complexity**: Set maxSteps higher (20-30) for multi-step user workflows`;
|
|
38
|
-
var BROWSER_SYSTEM_PROMPT = `You are an AI agent designed to automate browser tasks to accomplish the <user_request>. Respond with a valid JSON object in the format: {"thinking": "Reason step-by-step about your current state, history, and the user request to decide your next goal and action. Analyze the browser state and screenshot to confirm the outcome of your last action.", "evaluation_previous_goal": "A concise, one-sentence evaluation of your last action's outcome (e.g., Success, Failure, or Uncertain).", "memory": "1-3 sentences summarizing key information and progress so far. This helps you track progress across multiple steps (e.g., items collected, pages visited).", "next_goal": "A clear, one-sentence description of your immediate next objective.", "action": [{"action_name": {"parameter": "value"}}]}`;
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
BROWSER_TOOL_DESCRIPTION,
|
|
42
|
-
BROWSER_SYSTEM_PROMPT
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=chunk-2HMEZZKK.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/browser/prompts.ts"],"sourcesContent":["/**\n * Tool descriptions and prompts for AI models\n */\n\nexport const BROWSER_TOOL_DESCRIPTION = `Test and verify your implemented code in a live browser. This tool executes natural language test instructions and returns a video recording plus detailed logs to help you debug issues.\n\n## When to Use\nUse this AFTER coding is complete to verify your implementation:\n- You've finished writing/modifying code and need to verify it works\n- You need to test user interactions end-to-end (clicks, forms, navigation)\n- You want to catch runtime errors, console warnings, or network failures\n- You need visual confirmation that UI elements render and behave correctly\n\n## What You Get Back\nThe tool returns debugging artifacts to help you identify and fix issues:\n- **Video recording**: Watch exactly what happened in the browser session\n- **Console logs**: All console.log, warnings, and errors with timestamps\n- **Network logs**: Failed requests, 404s, API errors with screenshots\n- **Error screenshots**: Visual snapshots captured when errors occur\n\n## How to Write Good Tests\nBe specific about the user journey you're testing:\n❌ Bad: \"Test the login feature\"\n✅ Good: \"Navigate to /login, enter 'test@example.com' and 'password123', click the Login button, verify we reach the /dashboard page\"\n\nInclude verification steps:\n✅ \"Click the Add Item button, verify the item appears in the list\"\n✅ \"Submit the form, verify a success message is displayed\"\n\n## Iterating on Failures\n1. Run the test and review the video + logs\n2. Identify the specific issue (console error, failed request, wrong behavior)\n3. Fix the code based on the evidence\n4. Re-run the test to verify the fix\n5. Repeat until test passes\n\n## Requirements\n- **URL**: Must be publicly accessible (use tunnels like ngrok, Cloudflare, or deploy to staging)\n- **Timing**: Use this after implementation, not during coding\n- **Complexity**: Set maxSteps higher (20-30) for multi-step user workflows`;\n\n\nexport const BROWSER_SYSTEM_PROMPT = `You are an AI agent designed to automate browser tasks to accomplish the <user_request>. Respond with a valid JSON object in the format: {\"thinking\": \"Reason step-by-step about your current state, history, and the user request to decide your next goal and action. Analyze the browser state and screenshot to confirm the outcome of your last action.\", \"evaluation_previous_goal\": \"A concise, one-sentence evaluation of your last action's outcome (e.g., Success, Failure, or Uncertain).\", \"memory\": \"1-3 sentences summarizing key information and progress so far. This helps you track progress across multiple steps (e.g., items collected, pages visited).\", \"next_goal\": \"A clear, one-sentence description of your immediate next objective.\", \"action\": [{\"action_name\": {\"parameter\": \"value\"}}]}`;\n"],"mappings":";AAIO,IAAM,2BAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsCjC,IAAM,wBAAwB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../core/error.ts"],"sourcesContent":["/**\n * Single error mapper for the SDK transport.\n *\n * Consolidates the per-tool error handling that used to live in every client\n * (compact, reflex, github, …) into one place, preserving the actionable\n * 401/429 messaging. Reuses the existing `MorphError` type so callers that\n * `instanceof MorphError` keep working.\n */\nimport { MorphError } from '../tools/utils/resilience.js';\n\ninterface ApiErrorBody {\n error?: { message?: string; code?: string; type?: string };\n message?: string;\n}\n\n/**\n * Turn a non-OK `Response` into a `MorphError`, extracting the API's error\n * message when present and marking 429/503 as retryable.\n */\nexport async function toMorphError(response: Response): Promise<MorphError> {\n let message = `Morph API request failed (${response.status})`;\n let code = 'api_error';\n\n try {\n const body = (await response.json()) as ApiErrorBody;\n message = body.error?.message ?? body.message ?? message;\n code = body.error?.code ?? body.error?.type ?? code;\n } catch {\n // Non-JSON body — keep the status-based default message.\n }\n\n if (response.status === 401) code = 'authentication_error';\n if (response.status === 429) code = 'rate_limit_exceeded';\n\n const retryable = response.status === 429 || response.status === 503;\n return new MorphError(message, code, response.status, retryable);\n}\n"],"mappings":";;;;;AAmBA,eAAsB,aAAa,UAAyC;AAC1E,MAAI,UAAU,6BAA6B,SAAS,MAAM;AAC1D,MAAI,OAAO;AAEX,MAAI;AACF,UAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,cAAU,KAAK,OAAO,WAAW,KAAK,WAAW;AACjD,WAAO,KAAK,OAAO,QAAQ,KAAK,OAAO,QAAQ;AAAA,EACjD,QAAQ;AAAA,EAER;AAEA,MAAI,SAAS,WAAW,IAAK,QAAO;AACpC,MAAI,SAAS,WAAW,IAAK,QAAO;AAEpC,QAAM,YAAY,SAAS,WAAW,OAAO,SAAS,WAAW;AACjE,SAAO,IAAI,WAAW,SAAS,MAAM,SAAS,QAAQ,SAAS;AACjE;","names":[]}
|
package/dist/chunk-2VERUKO2.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
// tools/browser/errors.ts
|
|
2
|
-
var MorphError = class extends Error {
|
|
3
|
-
/** Error code for programmatic handling */
|
|
4
|
-
code;
|
|
5
|
-
/** Original cause of the error, if any */
|
|
6
|
-
cause;
|
|
7
|
-
constructor(message, code, cause) {
|
|
8
|
-
super(message);
|
|
9
|
-
this.name = "MorphError";
|
|
10
|
-
this.code = code;
|
|
11
|
-
this.cause = cause;
|
|
12
|
-
if (Error.captureStackTrace) {
|
|
13
|
-
Error.captureStackTrace(this, this.constructor);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Returns a JSON representation of the error for logging.
|
|
18
|
-
*/
|
|
19
|
-
toJSON() {
|
|
20
|
-
return {
|
|
21
|
-
name: this.name,
|
|
22
|
-
message: this.message,
|
|
23
|
-
code: this.code,
|
|
24
|
-
cause: this.cause?.message
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var MorphValidationError = class extends MorphError {
|
|
29
|
-
/** The field that failed validation */
|
|
30
|
-
field;
|
|
31
|
-
constructor(message, field) {
|
|
32
|
-
super(message, "validation_error");
|
|
33
|
-
this.name = "MorphValidationError";
|
|
34
|
-
this.field = field;
|
|
35
|
-
}
|
|
36
|
-
toJSON() {
|
|
37
|
-
return {
|
|
38
|
-
...super.toJSON(),
|
|
39
|
-
field: this.field
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
var MorphAPIError = class extends MorphError {
|
|
44
|
-
/** HTTP status code */
|
|
45
|
-
statusCode;
|
|
46
|
-
/** Request ID for debugging (if available) */
|
|
47
|
-
requestId;
|
|
48
|
-
/** Raw response body */
|
|
49
|
-
rawResponse;
|
|
50
|
-
constructor(message, code, statusCode, options) {
|
|
51
|
-
super(message, code, options?.cause);
|
|
52
|
-
this.name = "MorphAPIError";
|
|
53
|
-
this.statusCode = statusCode;
|
|
54
|
-
this.requestId = options?.requestId;
|
|
55
|
-
this.rawResponse = options?.rawResponse;
|
|
56
|
-
}
|
|
57
|
-
toJSON() {
|
|
58
|
-
return {
|
|
59
|
-
...super.toJSON(),
|
|
60
|
-
statusCode: this.statusCode,
|
|
61
|
-
requestId: this.requestId
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
var MorphAuthenticationError = class extends MorphAPIError {
|
|
66
|
-
constructor(message = "Authentication required. Please provide a valid API key.") {
|
|
67
|
-
super(message, "authentication_required", 401);
|
|
68
|
-
this.name = "MorphAuthenticationError";
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var MorphRateLimitError = class extends MorphAPIError {
|
|
72
|
-
/** When the rate limit resets (Unix timestamp) */
|
|
73
|
-
resetAt;
|
|
74
|
-
/** Number of seconds until reset */
|
|
75
|
-
retryAfter;
|
|
76
|
-
constructor(message = "Rate limit exceeded. Please retry later.", options) {
|
|
77
|
-
super(message, "rate_limit_exceeded", 429, { requestId: options?.requestId });
|
|
78
|
-
this.name = "MorphRateLimitError";
|
|
79
|
-
this.resetAt = options?.resetAt;
|
|
80
|
-
this.retryAfter = options?.retryAfter;
|
|
81
|
-
}
|
|
82
|
-
toJSON() {
|
|
83
|
-
return {
|
|
84
|
-
...super.toJSON(),
|
|
85
|
-
resetAt: this.resetAt,
|
|
86
|
-
retryAfter: this.retryAfter
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
var MorphNotFoundError = class extends MorphAPIError {
|
|
91
|
-
/** The type of resource that was not found */
|
|
92
|
-
resourceType;
|
|
93
|
-
/** The ID of the resource that was not found */
|
|
94
|
-
resourceId;
|
|
95
|
-
constructor(resourceType, resourceId) {
|
|
96
|
-
const message = resourceId ? `${resourceType} '${resourceId}' not found` : `${resourceType} not found`;
|
|
97
|
-
super(message, "resource_not_found", 404);
|
|
98
|
-
this.name = "MorphNotFoundError";
|
|
99
|
-
this.resourceType = resourceType;
|
|
100
|
-
this.resourceId = resourceId;
|
|
101
|
-
}
|
|
102
|
-
toJSON() {
|
|
103
|
-
return {
|
|
104
|
-
...super.toJSON(),
|
|
105
|
-
resourceType: this.resourceType,
|
|
106
|
-
resourceId: this.resourceId
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
var MorphProfileLimitError = class extends MorphAPIError {
|
|
111
|
-
/** Current number of profiles */
|
|
112
|
-
currentCount;
|
|
113
|
-
/** Maximum allowed profiles for the plan */
|
|
114
|
-
maxAllowed;
|
|
115
|
-
constructor(message = "Profile limit exceeded for your plan.", options) {
|
|
116
|
-
super(message, "profile_limit_exceeded", 403, { requestId: options?.requestId });
|
|
117
|
-
this.name = "MorphProfileLimitError";
|
|
118
|
-
this.currentCount = options?.currentCount;
|
|
119
|
-
this.maxAllowed = options?.maxAllowed;
|
|
120
|
-
}
|
|
121
|
-
toJSON() {
|
|
122
|
-
return {
|
|
123
|
-
...super.toJSON(),
|
|
124
|
-
currentCount: this.currentCount,
|
|
125
|
-
maxAllowed: this.maxAllowed
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
function parseAPIError(statusCode, responseText, requestId) {
|
|
130
|
-
let errorData = {};
|
|
131
|
-
try {
|
|
132
|
-
errorData = JSON.parse(responseText);
|
|
133
|
-
} catch {
|
|
134
|
-
}
|
|
135
|
-
const message = errorData.detail || errorData.message || responseText || "Unknown error";
|
|
136
|
-
const code = errorData.code;
|
|
137
|
-
switch (statusCode) {
|
|
138
|
-
case 401:
|
|
139
|
-
return new MorphAuthenticationError(message);
|
|
140
|
-
case 403:
|
|
141
|
-
if (code === "profile_limit_exceeded" || message.toLowerCase().includes("limit")) {
|
|
142
|
-
return new MorphProfileLimitError(message, { requestId });
|
|
143
|
-
}
|
|
144
|
-
return new MorphAPIError(message, "insufficient_permissions", statusCode, { requestId, rawResponse: responseText });
|
|
145
|
-
case 404:
|
|
146
|
-
if (message.toLowerCase().includes("profile")) {
|
|
147
|
-
return new MorphNotFoundError("Profile", void 0);
|
|
148
|
-
}
|
|
149
|
-
if (message.toLowerCase().includes("session")) {
|
|
150
|
-
return new MorphNotFoundError("Session", void 0);
|
|
151
|
-
}
|
|
152
|
-
return new MorphAPIError(message, "resource_not_found", statusCode, { requestId, rawResponse: responseText });
|
|
153
|
-
case 429:
|
|
154
|
-
return new MorphRateLimitError(message, { requestId });
|
|
155
|
-
case 422:
|
|
156
|
-
return new MorphAPIError(message, "validation_error", statusCode, { requestId, rawResponse: responseText });
|
|
157
|
-
case 500:
|
|
158
|
-
case 502:
|
|
159
|
-
case 503:
|
|
160
|
-
case 504:
|
|
161
|
-
return new MorphAPIError(message, "service_unavailable", statusCode, { requestId, rawResponse: responseText });
|
|
162
|
-
default:
|
|
163
|
-
return new MorphAPIError(message, "network_error", statusCode, { requestId, rawResponse: responseText });
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export {
|
|
168
|
-
MorphError,
|
|
169
|
-
MorphValidationError,
|
|
170
|
-
MorphAPIError,
|
|
171
|
-
MorphAuthenticationError,
|
|
172
|
-
MorphRateLimitError,
|
|
173
|
-
MorphNotFoundError,
|
|
174
|
-
MorphProfileLimitError,
|
|
175
|
-
parseAPIError
|
|
176
|
-
};
|
|
177
|
-
//# sourceMappingURL=chunk-2VERUKO2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/browser/errors.ts"],"sourcesContent":["/**\n * Custom error classes for browser automation and profiles.\n *\n * @example\n * ```typescript\n * try {\n * await morph.browser.profiles.createProfile({ name: '', repoId: 'owner/repo' });\n * } catch (e) {\n * if (e instanceof MorphValidationError) {\n * console.log('Validation failed:', e.field, e.message);\n * } else if (e instanceof MorphAPIError) {\n * console.log('API error:', e.code, e.statusCode);\n * }\n * }\n * ```\n */\n\n/**\n * Error codes for Morph Browser SDK\n */\nexport type MorphErrorCode =\n // Validation errors\n | 'validation_error'\n | 'invalid_parameter'\n | 'missing_required_field'\n // Authentication errors\n | 'authentication_required'\n | 'invalid_api_key'\n | 'insufficient_permissions'\n // Resource errors\n | 'profile_not_found'\n | 'session_not_found'\n | 'resource_not_found'\n // Limit errors\n | 'profile_limit_exceeded'\n | 'rate_limit_exceeded'\n // Session errors\n | 'session_expired'\n | 'session_save_failed'\n // Network errors\n | 'network_error'\n | 'timeout'\n | 'service_unavailable';\n\n/**\n * Base error class for all Morph SDK errors.\n */\nexport class MorphError extends Error {\n /** Error code for programmatic handling */\n readonly code: MorphErrorCode;\n /** Original cause of the error, if any */\n readonly cause?: Error;\n\n constructor(message: string, code: MorphErrorCode, cause?: Error) {\n super(message);\n this.name = 'MorphError';\n this.code = code;\n this.cause = cause;\n\n // Maintains proper stack trace in V8 environments\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n\n /**\n * Returns a JSON representation of the error for logging.\n */\n toJSON() {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n cause: this.cause?.message,\n };\n }\n}\n\n/**\n * Error thrown when API request validation fails.\n */\nexport class MorphValidationError extends MorphError {\n /** The field that failed validation */\n readonly field?: string;\n\n constructor(message: string, field?: string) {\n super(message, 'validation_error');\n this.name = 'MorphValidationError';\n this.field = field;\n }\n\n toJSON() {\n return {\n ...super.toJSON(),\n field: this.field,\n };\n }\n}\n\n/**\n * Error thrown when an API request fails.\n */\nexport class MorphAPIError extends MorphError {\n /** HTTP status code */\n readonly statusCode: number;\n /** Request ID for debugging (if available) */\n readonly requestId?: string;\n /** Raw response body */\n readonly rawResponse?: string;\n\n constructor(\n message: string,\n code: MorphErrorCode,\n statusCode: number,\n options?: {\n requestId?: string;\n rawResponse?: string;\n cause?: Error;\n }\n ) {\n super(message, code, options?.cause);\n this.name = 'MorphAPIError';\n this.statusCode = statusCode;\n this.requestId = options?.requestId;\n this.rawResponse = options?.rawResponse;\n }\n\n toJSON() {\n return {\n ...super.toJSON(),\n statusCode: this.statusCode,\n requestId: this.requestId,\n };\n }\n}\n\n/**\n * Error thrown when authentication fails.\n */\nexport class MorphAuthenticationError extends MorphAPIError {\n constructor(message: string = 'Authentication required. Please provide a valid API key.') {\n super(message, 'authentication_required', 401);\n this.name = 'MorphAuthenticationError';\n }\n}\n\n/**\n * Error thrown when rate limit is exceeded.\n */\nexport class MorphRateLimitError extends MorphAPIError {\n /** When the rate limit resets (Unix timestamp) */\n readonly resetAt?: number;\n /** Number of seconds until reset */\n readonly retryAfter?: number;\n\n constructor(\n message: string = 'Rate limit exceeded. Please retry later.',\n options?: {\n resetAt?: number;\n retryAfter?: number;\n requestId?: string;\n }\n ) {\n super(message, 'rate_limit_exceeded', 429, { requestId: options?.requestId });\n this.name = 'MorphRateLimitError';\n this.resetAt = options?.resetAt;\n this.retryAfter = options?.retryAfter;\n }\n\n toJSON() {\n return {\n ...super.toJSON(),\n resetAt: this.resetAt,\n retryAfter: this.retryAfter,\n };\n }\n}\n\n/**\n * Error thrown when a resource is not found.\n */\nexport class MorphNotFoundError extends MorphAPIError {\n /** The type of resource that was not found */\n readonly resourceType: string;\n /** The ID of the resource that was not found */\n readonly resourceId?: string;\n\n constructor(resourceType: string, resourceId?: string) {\n const message = resourceId\n ? `${resourceType} '${resourceId}' not found`\n : `${resourceType} not found`;\n super(message, 'resource_not_found', 404);\n this.name = 'MorphNotFoundError';\n this.resourceType = resourceType;\n this.resourceId = resourceId;\n }\n\n toJSON() {\n return {\n ...super.toJSON(),\n resourceType: this.resourceType,\n resourceId: this.resourceId,\n };\n }\n}\n\n/**\n * Error thrown when profile limit is exceeded.\n */\nexport class MorphProfileLimitError extends MorphAPIError {\n /** Current number of profiles */\n readonly currentCount?: number;\n /** Maximum allowed profiles for the plan */\n readonly maxAllowed?: number;\n\n constructor(\n message: string = 'Profile limit exceeded for your plan.',\n options?: {\n currentCount?: number;\n maxAllowed?: number;\n requestId?: string;\n }\n ) {\n super(message, 'profile_limit_exceeded', 403, { requestId: options?.requestId });\n this.name = 'MorphProfileLimitError';\n this.currentCount = options?.currentCount;\n this.maxAllowed = options?.maxAllowed;\n }\n\n toJSON() {\n return {\n ...super.toJSON(),\n currentCount: this.currentCount,\n maxAllowed: this.maxAllowed,\n };\n }\n}\n\n/**\n * Parse an API error response and return the appropriate error class.\n */\nexport function parseAPIError(\n statusCode: number,\n responseText: string,\n requestId?: string\n): MorphAPIError {\n // Try to parse JSON error response\n let errorData: { detail?: string; code?: string; message?: string } = {};\n try {\n errorData = JSON.parse(responseText);\n } catch {\n // Not JSON, use raw text\n }\n\n const message = errorData.detail || errorData.message || responseText || 'Unknown error';\n const code = errorData.code;\n\n // Map status codes to specific error classes\n switch (statusCode) {\n case 401:\n return new MorphAuthenticationError(message);\n\n case 403:\n if (code === 'profile_limit_exceeded' || message.toLowerCase().includes('limit')) {\n return new MorphProfileLimitError(message, { requestId });\n }\n return new MorphAPIError(message, 'insufficient_permissions', statusCode, { requestId, rawResponse: responseText });\n\n case 404:\n if (message.toLowerCase().includes('profile')) {\n return new MorphNotFoundError('Profile', undefined);\n }\n if (message.toLowerCase().includes('session')) {\n return new MorphNotFoundError('Session', undefined);\n }\n return new MorphAPIError(message, 'resource_not_found', statusCode, { requestId, rawResponse: responseText });\n\n case 429:\n return new MorphRateLimitError(message, { requestId });\n\n case 422:\n return new MorphAPIError(message, 'validation_error', statusCode, { requestId, rawResponse: responseText });\n\n case 500:\n case 502:\n case 503:\n case 504:\n return new MorphAPIError(message, 'service_unavailable', statusCode, { requestId, rawResponse: responseText });\n\n default:\n return new MorphAPIError(message, 'network_error', statusCode, { requestId, rawResponse: responseText });\n }\n}\n"],"mappings":";AA+CO,IAAM,aAAN,cAAyB,MAAM;AAAA;AAAA,EAE3B;AAAA;AAAA,EAEA;AAAA,EAET,YAAY,SAAiB,MAAsB,OAAe;AAChE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,QAAQ;AAGb,QAAI,MAAM,mBAAmB;AAC3B,YAAM,kBAAkB,MAAM,KAAK,WAAW;AAAA,IAChD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,SAAS;AACP,WAAO;AAAA,MACL,MAAM,KAAK;A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