@morphllm/morphsdk 0.2.171 → 0.2.173
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/dist/{chunk-SW527EQT.js → chunk-33ZRF6X3.js} +4 -4
- package/dist/{chunk-3BCKZKNK.js → chunk-3GNXTHHB.js} +2 -2
- package/dist/{chunk-IGQYZ2KH.js → chunk-3I4LCNWJ.js} +2 -2
- package/dist/{chunk-4324ZSCW.js → chunk-577P2AXE.js} +2 -2
- package/dist/{chunk-MZZMSL26.js → chunk-5RTWSAZ6.js} +2 -2
- package/dist/{chunk-JEDEBCZM.js → chunk-73DQQMGR.js} +8 -3
- package/dist/{chunk-JEDEBCZM.js.map → chunk-73DQQMGR.js.map} +1 -1
- package/dist/{chunk-3XRNC56L.js → chunk-7EUJ2AKS.js} +4 -4
- package/dist/{chunk-JLLIVBKY.js → chunk-ACWLQFYS.js} +30 -6
- package/dist/chunk-ACWLQFYS.js.map +1 -0
- package/dist/{chunk-IW4TYYG6.js → chunk-AZOSA7VT.js} +2 -2
- package/dist/{chunk-ZJQTTOHO.js → chunk-C3V5FHZI.js} +2 -2
- package/dist/{chunk-LL3EWDKD.js → chunk-CEZQSARX.js} +4 -4
- package/dist/{chunk-EFCDIESP.js → chunk-CV7SLK6R.js} +2 -2
- package/dist/{chunk-GLQWEINZ.js → chunk-EJ2CQO4V.js} +2 -2
- package/dist/{chunk-LE66XCOI.js → chunk-FN4ADWFQ.js} +27 -10
- package/dist/chunk-FN4ADWFQ.js.map +1 -0
- package/dist/{chunk-CMFY26F3.js → chunk-GESRH23M.js} +4 -4
- package/dist/{chunk-FQJCE2FX.js → chunk-I4FCFIBU.js} +29 -10
- package/dist/chunk-I4FCFIBU.js.map +1 -0
- package/dist/{chunk-JTUB5ZCT.js → chunk-JXJBF6CV.js} +2 -2
- package/dist/chunk-LKFZBBTD.js +12 -0
- package/dist/chunk-LKFZBBTD.js.map +1 -0
- package/dist/{chunk-2ALTBYMY.js → chunk-MQTMT4OR.js} +4 -4
- package/dist/{chunk-UK7TI7QY.js → chunk-NBKL7VWX.js} +101 -145
- package/dist/chunk-NBKL7VWX.js.map +1 -0
- package/dist/{chunk-C37YAYBK.js → chunk-QCFHQPHC.js} +2 -2
- package/dist/chunk-QE3SPHIM.js +120 -0
- package/dist/chunk-QE3SPHIM.js.map +1 -0
- package/dist/{chunk-TAS6S42A.js → chunk-QE6JHRVD.js} +2 -2
- package/dist/{chunk-Y6T4NA75.js → chunk-RXCHMNCY.js} +2 -2
- package/dist/{chunk-4MTZUTNH.js → chunk-S5R4H5HM.js} +23 -8
- package/dist/chunk-S5R4H5HM.js.map +1 -0
- package/dist/chunk-SM3OQZRS.js +142 -0
- package/dist/chunk-SM3OQZRS.js.map +1 -0
- package/dist/chunk-TS56XYWB.js +78 -0
- package/dist/chunk-TS56XYWB.js.map +1 -0
- package/dist/{chunk-5EUMJI3I.js → chunk-TW3XQET2.js} +2 -2
- package/dist/{chunk-OPNTDMHH.js → chunk-VLZ6PNAD.js} +4 -4
- package/dist/chunk-VZ7BOH2K.js +1 -0
- package/dist/chunk-VZ7BOH2K.js.map +1 -0
- package/dist/chunk-W6AGNJ5O.js +97 -0
- package/dist/chunk-W6AGNJ5O.js.map +1 -0
- package/dist/chunk-YGNPVOUO.js +158 -0
- package/dist/chunk-YGNPVOUO.js.map +1 -0
- package/dist/{chunk-2OAKX4SZ.js → chunk-Z3KRXUNG.js} +4 -4
- package/dist/chunk-ZFOR3LI4.js +24 -0
- package/dist/chunk-ZFOR3LI4.js.map +1 -0
- package/dist/{client-DsAAqupx.d.ts → client-Dh6yzCm4.d.ts} +14 -5
- package/dist/client.cjs +724 -523
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +5 -1
- package/dist/client.js +31 -27
- package/dist/core/client.cjs +540 -0
- package/dist/core/client.cjs.map +1 -0
- package/dist/core/client.d.ts +79 -0
- package/dist/core/client.js +12 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/error.cjs +309 -0
- package/dist/core/error.cjs.map +1 -0
- package/dist/core/error.d.ts +18 -0
- package/dist/core/error.js +10 -0
- package/dist/core/error.js.map +1 -0
- package/dist/core/index.cjs +552 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +20 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/resource.cjs +36 -0
- package/dist/core/resource.cjs.map +1 -0
- package/dist/core/resource.d.ts +18 -0
- package/dist/core/resource.js +8 -0
- package/dist/core/resource.js.map +1 -0
- package/dist/edge.cjs +236 -173
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.d.ts +2 -0
- package/dist/edge.js +8 -5
- package/dist/git/client.cjs +529 -9
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.d.ts +8 -2
- package/dist/git/client.js +7 -1
- package/dist/git/index.cjs +529 -9
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.d.ts +2 -0
- package/dist/git/index.js +7 -1
- package/dist/index.cjs +672 -465
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +49 -33
- package/dist/modelrouter/core.cjs +204 -125
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.d.ts +36 -9
- package/dist/modelrouter/core.js +6 -3
- package/dist/modelrouter/index.cjs +204 -125
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.d.ts +3 -0
- package/dist/modelrouter/index.js +6 -3
- package/dist/subagents/anthropic.cjs +268 -52
- package/dist/subagents/anthropic.cjs.map +1 -1
- package/dist/subagents/anthropic.js +10 -6
- package/dist/subagents/vercel.cjs +268 -52
- package/dist/subagents/vercel.cjs.map +1 -1
- package/dist/subagents/vercel.js +10 -6
- package/dist/tools/browser/anthropic.cjs +7 -2
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +9 -6
- package/dist/tools/browser/core.cjs +162 -10
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.d.ts +8 -2
- package/dist/tools/browser/core.js +8 -5
- package/dist/tools/browser/index.cjs +163 -11
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.d.ts +2 -0
- package/dist/tools/browser/index.js +18 -15
- package/dist/tools/browser/index.js.map +1 -1
- package/dist/tools/browser/openai.cjs +7 -2
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +9 -6
- package/dist/tools/browser/profiles/core.cjs +7 -2
- package/dist/tools/browser/profiles/core.cjs.map +1 -1
- package/dist/tools/browser/profiles/core.js +3 -3
- package/dist/tools/browser/profiles/index.cjs +7 -2
- package/dist/tools/browser/profiles/index.cjs.map +1 -1
- package/dist/tools/browser/profiles/index.js +3 -3
- package/dist/tools/browser/vercel.cjs +7 -2
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +9 -6
- package/dist/tools/codebase_search/anthropic.cjs +162 -41
- package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +7 -4
- package/dist/tools/codebase_search/core.cjs +195 -66
- package/dist/tools/codebase_search/core.cjs.map +1 -1
- package/dist/tools/codebase_search/core.d.ts +18 -7
- package/dist/tools/codebase_search/core.js +6 -3
- package/dist/tools/codebase_search/index.cjs +162 -41
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.d.ts +2 -0
- package/dist/tools/codebase_search/index.js +13 -10
- package/dist/tools/codebase_search/openai.cjs +162 -41
- package/dist/tools/codebase_search/openai.cjs.map +1 -1
- package/dist/tools/codebase_search/openai.js +7 -4
- package/dist/tools/codebase_search/vercel.cjs +162 -41
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +7 -4
- package/dist/tools/compact/core.cjs +551 -47
- package/dist/tools/compact/core.cjs.map +1 -1
- package/dist/tools/compact/core.d.ts +16 -3
- package/dist/tools/compact/core.js +7 -1
- package/dist/tools/compact/index.cjs +549 -47
- package/dist/tools/compact/index.cjs.map +1 -1
- package/dist/tools/compact/index.d.ts +2 -0
- package/dist/tools/compact/index.js +8 -2
- package/dist/tools/fastapply/anthropic.cjs +16 -2
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +8 -4
- package/dist/tools/fastapply/apply.cjs +7 -2
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +242 -12
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.d.ts +8 -2
- package/dist/tools/fastapply/core.js +7 -3
- package/dist/tools/fastapply/index.cjs +16 -2
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.d.ts +2 -0
- package/dist/tools/fastapply/index.js +13 -9
- package/dist/tools/fastapply/openai.cjs +16 -2
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +8 -4
- package/dist/tools/fastapply/vercel.cjs +16 -2
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +8 -4
- package/dist/tools/index.cjs +16 -2
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +13 -9
- package/dist/tools/reflex/core.cjs +693 -0
- package/dist/tools/reflex/core.cjs.map +1 -0
- package/dist/tools/reflex/core.d.ts +53 -0
- package/dist/tools/reflex/core.js +16 -0
- package/dist/tools/reflex/core.js.map +1 -0
- package/dist/tools/reflex/index.cjs +693 -0
- package/dist/tools/reflex/index.cjs.map +1 -0
- package/dist/tools/reflex/index.d.ts +5 -0
- package/dist/tools/reflex/index.js +16 -0
- package/dist/tools/reflex/index.js.map +1 -0
- package/dist/tools/reflex/types.cjs +19 -0
- package/dist/tools/reflex/types.cjs.map +1 -0
- package/dist/tools/reflex/types.d.ts +114 -0
- package/dist/tools/reflex/types.js +1 -0
- package/dist/tools/reflex/types.js.map +1 -0
- package/dist/tools/utils/resilience.cjs +7 -2
- 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 +7 -2
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +2 -2
- package/dist/tools/warp_grep/anthropic.cjs +268 -52
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +2 -0
- package/dist/tools/warp_grep/anthropic.js +10 -6
- package/dist/tools/warp_grep/client.cjs +268 -52
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.d.ts +8 -2
- package/dist/tools/warp_grep/client.js +9 -5
- package/dist/tools/warp_grep/gemini.cjs +268 -52
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +2 -0
- package/dist/tools/warp_grep/gemini.js +9 -5
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/harness.js +5 -5
- package/dist/tools/warp_grep/index.cjs +268 -52
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +2 -0
- package/dist/tools/warp_grep/index.js +12 -8
- package/dist/tools/warp_grep/openai.cjs +268 -52
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +2 -0
- package/dist/tools/warp_grep/openai.js +10 -6
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/vercel.cjs +268 -52
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +2 -0
- package/dist/tools/warp_grep/vercel.js +10 -6
- package/dist/version.cjs +7 -2
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -2
- package/dist/chunk-4MTZUTNH.js.map +0 -1
- package/dist/chunk-FQJCE2FX.js.map +0 -1
- package/dist/chunk-H5WNI6R5.js +0 -102
- package/dist/chunk-H5WNI6R5.js.map +0 -1
- package/dist/chunk-JLLIVBKY.js.map +0 -1
- package/dist/chunk-KCFMXLZ7.js +0 -197
- package/dist/chunk-KCFMXLZ7.js.map +0 -1
- package/dist/chunk-LE66XCOI.js.map +0 -1
- package/dist/chunk-SCVWDNQP.js +0 -84
- package/dist/chunk-SCVWDNQP.js.map +0 -1
- package/dist/chunk-UK7TI7QY.js.map +0 -1
- /package/dist/{chunk-SW527EQT.js.map → chunk-33ZRF6X3.js.map} +0 -0
- /package/dist/{chunk-3BCKZKNK.js.map → chunk-3GNXTHHB.js.map} +0 -0
- /package/dist/{chunk-IGQYZ2KH.js.map → chunk-3I4LCNWJ.js.map} +0 -0
- /package/dist/{chunk-4324ZSCW.js.map → chunk-577P2AXE.js.map} +0 -0
- /package/dist/{chunk-MZZMSL26.js.map → chunk-5RTWSAZ6.js.map} +0 -0
- /package/dist/{chunk-3XRNC56L.js.map → chunk-7EUJ2AKS.js.map} +0 -0
- /package/dist/{chunk-IW4TYYG6.js.map → chunk-AZOSA7VT.js.map} +0 -0
- /package/dist/{chunk-ZJQTTOHO.js.map → chunk-C3V5FHZI.js.map} +0 -0
- /package/dist/{chunk-LL3EWDKD.js.map → chunk-CEZQSARX.js.map} +0 -0
- /package/dist/{chunk-EFCDIESP.js.map → chunk-CV7SLK6R.js.map} +0 -0
- /package/dist/{chunk-GLQWEINZ.js.map → chunk-EJ2CQO4V.js.map} +0 -0
- /package/dist/{chunk-CMFY26F3.js.map → chunk-GESRH23M.js.map} +0 -0
- /package/dist/{chunk-JTUB5ZCT.js.map → chunk-JXJBF6CV.js.map} +0 -0
- /package/dist/{chunk-2ALTBYMY.js.map → chunk-MQTMT4OR.js.map} +0 -0
- /package/dist/{chunk-C37YAYBK.js.map → chunk-QCFHQPHC.js.map} +0 -0
- /package/dist/{chunk-TAS6S42A.js.map → chunk-QE6JHRVD.js.map} +0 -0
- /package/dist/{chunk-Y6T4NA75.js.map → chunk-RXCHMNCY.js.map} +0 -0
- /package/dist/{chunk-5EUMJI3I.js.map → chunk-TW3XQET2.js.map} +0 -0
- /package/dist/{chunk-OPNTDMHH.js.map → chunk-VLZ6PNAD.js.map} +0 -0
- /package/dist/{chunk-2OAKX4SZ.js.map → chunk-Z3KRXUNG.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/github/types.ts","../tools/github/core.ts","../factories/openai.ts","../factories/anthropic.ts","../factories/vercel.ts","../client.ts"],"sourcesContent":["/**\n * GitHub SDK Types\n *\n * Type definitions for the Morph GitHub integration.\n * Users connect GitHub in the Morph dashboard, then use these\n * types to interact with their GitHub repos through the SDK.\n */\n\n// =============================================================================\n// Configuration\n// =============================================================================\n\n/**\n * Configuration for the GitHub client\n */\nexport interface GitHubClientConfig {\n /** Morph API key (defaults to MORPH_API_KEY env var) */\n apiKey?: string;\n /** Default installation ID to use (optional, can be specified per-request) */\n installationId?: string;\n /** Base URL for the Morph API (defaults to https://api.morphllm.com) */\n baseUrl?: string;\n /** Request timeout in milliseconds */\n timeout?: number;\n /** Enable debug logging */\n debug?: boolean;\n}\n\n// =============================================================================\n// Core Types\n// =============================================================================\n\n/**\n * A GitHub App installation (connected GitHub account)\n */\nexport interface Installation {\n /** Installation ID (use this for subsequent requests) */\n id: string;\n /** GitHub account login (username or org name) */\n accountLogin: string;\n /** Account type */\n accountType: \"User\" | \"Organization\";\n /** Custom display name (set in Morph dashboard) */\n displayName?: string;\n /** Whether check runs are disabled (only PR comments posted) */\n disableCheckRun: boolean;\n /** Whether to keep all previous PR comments (vs. replacing with latest) */\n keepCommentHistory: boolean;\n /** Browser automation model used for preview tests */\n model: string;\n}\n\n/**\n * Input for updating installation settings\n */\nexport interface UpdateInstallationInput {\n /** Installation ID to update */\n installationId: string;\n /** Custom display name */\n displayName?: string;\n /** Whether to disable check runs */\n disableCheckRun?: boolean;\n /** Whether to keep comment history */\n keepCommentHistory?: boolean;\n /** Browser automation model */\n model?: string;\n}\n\n/**\n * Site authentication credentials for a repo or project\n */\nexport interface SiteAuth {\n /** Login username or email */\n username: string | null;\n /** Login password */\n password: string | null;\n}\n\n/**\n * A repository with its Morph configuration\n */\nexport interface RepoConfig {\n /** Database UUID — use this for update/remove operations */\n id: string;\n /** GitHub's numeric repo ID */\n githubId: number;\n /** Full name including owner (e.g., \"acme/app\") */\n fullName: string;\n /** Repository name (e.g., \"app\") */\n name: string;\n /** Whether Morph tests are enabled */\n enabled: boolean;\n /** Whether to also test on mobile viewport */\n testMobile: boolean;\n /** Path filter — only trigger tests when files match this prefix */\n pathFilter: string | null;\n /** Custom instructions for the AI agent */\n customInstructions: string | null;\n /** Site authentication credentials */\n auth: SiteAuth | null;\n}\n\n/**\n * Input for updating a repo's configuration\n */\nexport interface UpdateRepoInput {\n /** Repo DB ID (from RepoConfig.id) */\n repoId: string;\n /** Whether Morph tests are enabled */\n enabled?: boolean;\n /** Whether to also test on mobile viewport */\n testMobile?: boolean;\n /** Path filter for conditional triggers */\n pathFilter?: string | null;\n /** Custom instructions for the AI agent */\n customInstructions?: string | null;\n /** Site auth credentials (null to clear) */\n auth?: { username?: string; password?: string; cookies?: unknown } | null;\n}\n\n/**\n * Input for syncing repos from GitHub\n */\nexport interface SyncReposInput {\n /** Installation ID to sync repos for */\n installationId: string;\n}\n\n/**\n * A monorepo sub-project scoped under a repo\n */\nexport interface Project {\n /** Project DB UUID */\n id: string;\n /** Parent repo DB UUID */\n repoId: string;\n /** Project name */\n name: string;\n /** Path filter within the repo */\n pathFilter: string | null;\n /** Whether tests are enabled */\n enabled: boolean;\n /** Whether to test on mobile viewport */\n testMobile: boolean;\n /** Custom instructions for the AI agent */\n customInstructions: string | null;\n /** Site authentication credentials */\n auth: SiteAuth | null;\n /** Creation timestamp (ISO 8601) */\n createdAt: string;\n}\n\n/**\n * Input for creating a project\n */\nexport interface CreateProjectInput {\n /** Parent repo DB ID */\n repoId: string;\n /** Project name (must be unique within the repo) */\n name: string;\n /** Path filter within the repo (e.g., \"packages/web/\") */\n pathFilter: string;\n /** Custom instructions for the AI agent */\n customInstructions?: string;\n}\n\n/**\n * Input for updating a project\n */\nexport interface UpdateProjectInput {\n /** Project DB ID */\n projectId: string;\n /** Whether tests are enabled */\n enabled?: boolean;\n /** Whether to test on mobile viewport */\n testMobile?: boolean;\n /** Path filter within the repo */\n pathFilter?: string | null;\n /** Custom instructions for the AI agent */\n customInstructions?: string | null;\n /** Site auth credentials (null to clear) */\n auth?: { username?: string; password?: string; cookies?: unknown } | null;\n}\n\n/**\n * Input for listing projects\n */\nexport interface ListProjectsInput {\n /** Parent repo DB ID */\n repoId: string;\n}\n\n/**\n * A GitHub repository\n */\nexport interface Repo {\n /** GitHub's numeric repo ID */\n id: number;\n /** Repository name (e.g., \"app\") */\n name: string;\n /** Full name including owner (e.g., \"acme/app\") */\n fullName: string;\n /** Whether the repo is private */\n private: boolean;\n /** Default branch name */\n defaultBranch?: string;\n}\n\n/**\n * A pull request (basic info)\n */\nexport interface PullRequest {\n /** PR number */\n number: number;\n /** PR title */\n title: string;\n /** PR description/body */\n body: string | null;\n /** PR state */\n state: \"open\" | \"closed\";\n /** Author's GitHub username */\n author: string;\n /** HEAD commit SHA */\n headSha: string;\n /** Base branch name */\n baseBranch: string;\n /** HEAD branch name */\n headBranch: string;\n /** Creation timestamp (ISO 8601) */\n createdAt: string;\n /** Last update timestamp (ISO 8601) */\n updatedAt: string;\n}\n\n/**\n * A pull request with full context (diff and files)\n */\nexport interface PullRequestWithContext extends PullRequest {\n /** Full unified diff */\n diff: string;\n /** List of changed files with patches */\n files: FileChange[];\n}\n\n/**\n * A file changed in a pull request\n */\nexport interface FileChange {\n /** File path */\n filename: string;\n /** Change status */\n status: \"added\" | \"removed\" | \"modified\" | \"renamed\";\n /** Number of lines added */\n additions: number;\n /** Number of lines deleted */\n deletions: number;\n /** Unified diff patch for this file */\n patch?: string;\n}\n\n/**\n * A deployment (e.g., Vercel preview)\n */\nexport interface Deployment {\n /** Deployment ID */\n id: number;\n /** Commit SHA this deployment is for */\n sha: string;\n /** Environment name (e.g., \"preview\", \"production\") */\n environment: string;\n /** Deployment state */\n state: \"pending\" | \"success\" | \"failure\" | \"error\" | \"inactive\" | \"in_progress\" | \"queued\";\n /** Preview/deployment URL (if available) */\n url: string | null;\n /** Creation timestamp (ISO 8601) */\n createdAt: string;\n}\n\n/**\n * A comment on a PR/issue\n */\nexport interface Comment {\n /** Comment ID */\n id: number;\n /** Comment body/content */\n body: string;\n /** Author's GitHub username */\n author: string;\n /** Creation timestamp (ISO 8601) */\n createdAt: string;\n /** Last update timestamp (ISO 8601) */\n updatedAt: string;\n}\n\n/**\n * A GitHub check run (CI status)\n */\nexport interface CheckRun {\n /** Check run ID */\n id: number;\n /** Check run name */\n name: string;\n /** Current status */\n status: \"queued\" | \"in_progress\" | \"completed\";\n /** Conclusion (only set when status is \"completed\") */\n conclusion?:\n | \"success\"\n | \"failure\"\n | \"neutral\"\n | \"cancelled\"\n | \"skipped\"\n | \"timed_out\"\n | \"action_required\";\n /** Start timestamp (ISO 8601) */\n startedAt?: string;\n /** Completion timestamp (ISO 8601) */\n completedAt?: string;\n}\n\n// =============================================================================\n// Input Types\n// =============================================================================\n\n/**\n * Input for listing repositories\n */\nexport interface ListReposInput {\n /** Installation ID to list repos for */\n installationId: string;\n}\n\n/**\n * Input for listing pull requests\n */\nexport interface ListPullRequestsInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Filter by PR state (default: \"open\") */\n state?: \"open\" | \"closed\" | \"all\";\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for getting a single pull request\n */\nexport interface GetPullRequestInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** PR number */\n number: number;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for listing deployments\n */\nexport interface ListDeploymentsInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Filter by commit SHA */\n sha?: string;\n /** Filter by environment name */\n environment?: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for listing comments on a PR\n */\nexport interface ListCommentsInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** PR number */\n pr: number;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for creating a comment\n */\nexport interface CreateCommentInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** PR number */\n pr: number;\n /** Comment body (Markdown supported) */\n body: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for updating a comment\n */\nexport interface UpdateCommentInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Comment ID to update */\n commentId: number;\n /** New comment body */\n body: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for deleting a comment\n */\nexport interface DeleteCommentInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Comment ID to delete */\n commentId: number;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for creating a check run\n */\nexport interface CreateCheckRunInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Commit SHA to create check run for */\n sha: string;\n /** Check run name (e.g., \"Preview Test\") */\n name: string;\n /** Initial status */\n status: \"queued\" | \"in_progress\";\n /** Output title */\n title?: string;\n /** Output summary (Markdown supported) */\n summary?: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for updating a check run\n */\nexport interface UpdateCheckRunInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Check run ID to update */\n checkRunId: number;\n /** New status */\n status?: \"queued\" | \"in_progress\" | \"completed\";\n /** Conclusion (required if status is \"completed\") */\n conclusion?: CheckRun[\"conclusion\"];\n /** Output title */\n title?: string;\n /** Output summary (Markdown supported) */\n summary?: string;\n /** Output text (detailed info, Markdown supported) */\n text?: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n// =============================================================================\n// Error Types\n// =============================================================================\n\n/**\n * Error thrown by GitHub operations\n */\nexport class GitHubError extends Error {\n /** HTTP status code */\n status: number;\n /** Error code from API */\n code?: string;\n\n constructor(message: string, status: number, code?: string) {\n super(message);\n this.name = \"GitHubError\";\n this.status = status;\n this.code = code;\n }\n}\n\n/**\n * Error thrown when no installation is found or specified\n */\nexport class NoInstallationError extends GitHubError {\n constructor(message = \"No GitHub installation found. Connect GitHub at morphllm.com/dashboard/integrations/github\") {\n super(message, 404, \"NO_INSTALLATION\");\n }\n}\n\n/**\n * Error thrown when resource is not found\n */\nexport class NotFoundError extends GitHubError {\n constructor(resource: string) {\n super(`${resource} not found`, 404, \"NOT_FOUND\");\n }\n}\n\n/**\n * Error thrown when user lacks permission\n */\nexport class PermissionError extends GitHubError {\n constructor(message = \"Insufficient permissions for this operation\") {\n super(message, 403, \"PERMISSION_DENIED\");\n }\n}\n","/**\n * GitHub SDK Client\n *\n * Provides access to GitHub repositories, pull requests, deployments,\n * comments, and check runs through the user's connected GitHub account.\n *\n * All operations are proxied through the Morph API - installation tokens\n * are never exposed to the client.\n */\n\nimport type {\n GitHubClientConfig,\n Installation,\n Repo,\n RepoConfig,\n PullRequest,\n PullRequestWithContext,\n Deployment,\n Comment,\n CheckRun,\n Project,\n ListReposInput,\n ListPullRequestsInput,\n GetPullRequestInput,\n ListDeploymentsInput,\n ListCommentsInput,\n CreateCommentInput,\n UpdateCommentInput,\n DeleteCommentInput,\n CreateCheckRunInput,\n UpdateCheckRunInput,\n UpdateInstallationInput,\n UpdateRepoInput,\n SyncReposInput,\n CreateProjectInput,\n UpdateProjectInput,\n ListProjectsInput,\n} from \"./types.js\";\n\nimport { GitHubError, NoInstallationError, NotFoundError, PermissionError } from \"./types.js\";\nimport { MorphAPIClient } from \"../../core/client.js\";\nimport { APIResource } from \"../../core/resource.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.morphllm.com\";\nconst DEFAULT_TIMEOUT = 30000;\n\n/**\n * GitHub SDK Client\n *\n * @example\n * ```typescript\n * import { MorphClient } from '@morphllm/morphsdk';\n *\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n *\n * // List installations\n * const installations = await morph.github.installations.list();\n *\n * // Get PR with context\n * const pr = await morph.github.pullRequests.get({\n * owner: \"acme\",\n * repo: \"app\",\n * number: 42\n * });\n * ```\n *\n * @deprecated Prefer the unified `MorphClient` (`new MorphClient({ apiKey }).github`).\n * Standalone clients remain only for backwards compatibility and may be removed in a future\n * major version — do not use them in new code.\n */\nexport class GitHubClient extends APIResource {\n private timeout: number;\n private debug: boolean;\n private defaultInstallationId?: string;\n\n /** Installation operations */\n public installations: {\n list: () => Promise<Installation[]>;\n get: (installationId: string) => Promise<Installation>;\n update: (input: UpdateInstallationInput) => Promise<Installation>;\n disconnect: (installationId: string) => Promise<{ success: boolean; alreadyDeleted: boolean }>;\n };\n\n /** Repository operations */\n public repos: {\n list: (input: ListReposInput) => Promise<RepoConfig[]>;\n get: (repoId: string) => Promise<RepoConfig>;\n update: (input: UpdateRepoInput) => Promise<RepoConfig>;\n remove: (repoId: string) => Promise<{ success: boolean; alreadyRemoved: boolean }>;\n sync: (input: SyncReposInput) => Promise<{ count: number }>;\n };\n\n /** Project operations (monorepo sub-projects) */\n public projects: {\n list: (input: ListProjectsInput) => Promise<Project[]>;\n create: (input: CreateProjectInput) => Promise<Project>;\n update: (input: UpdateProjectInput) => Promise<Project>;\n delete: (projectId: string) => Promise<{ success: boolean }>;\n };\n\n /** Pull request operations */\n public pullRequests: {\n list: (input: ListPullRequestsInput) => Promise<PullRequest[]>;\n get: (input: GetPullRequestInput) => Promise<PullRequestWithContext>;\n };\n\n /** Deployment operations */\n public deployments: {\n list: (input: ListDeploymentsInput) => Promise<Deployment[]>;\n };\n\n /** Comment operations */\n public comments: {\n list: (input: ListCommentsInput) => Promise<Comment[]>;\n create: (input: CreateCommentInput) => Promise<Comment>;\n update: (input: UpdateCommentInput) => Promise<Comment>;\n delete: (input: DeleteCommentInput) => Promise<void>;\n };\n\n /** Check run operations */\n public checkRuns: {\n create: (input: CreateCheckRunInput) => Promise<CheckRun>;\n update: (input: UpdateCheckRunInput) => Promise<CheckRun>;\n };\n\n /**\n * Get the GitHub App installation URL.\n * Users visit this URL once to install the Morph GitHub App on their account/org.\n */\n public getInstallUrl(): string {\n return \"https://github.com/apps/morph-subagents/installations/new\";\n }\n\n constructor(\n clientOrConfig: MorphAPIClient | GitHubClientConfig = {},\n options: { installationId?: string } = {},\n ) {\n const isClient = clientOrConfig instanceof MorphAPIClient;\n const config: GitHubClientConfig = isClient ? {} : clientOrConfig;\n super(\n isClient\n ? clientOrConfig\n : new MorphAPIClient({\n apiKey: config.apiKey,\n baseURL: config.baseUrl ?? DEFAULT_BASE_URL,\n timeout: config.timeout ?? DEFAULT_TIMEOUT,\n debug: config.debug,\n }),\n );\n this.timeout = config.timeout || DEFAULT_TIMEOUT;\n this.debug = config.debug || false;\n // When sharing a transport, installationId is passed via `options`.\n this.defaultInstallationId = isClient ? options.installationId : config.installationId;\n\n if (!this._client.resolveApiKey()) {\n throw new Error(\"API key required. Set MORPH_API_KEY or pass apiKey in config.\");\n }\n\n // Bind all methods\n this.installations = {\n list: this.listInstallations.bind(this),\n get: this.getInstallation.bind(this),\n update: this.updateInstallation.bind(this),\n disconnect: this.disconnectInstallation.bind(this),\n };\n\n this.repos = {\n list: this.listRepos.bind(this),\n get: this.getRepo.bind(this),\n update: this.updateRepo.bind(this),\n remove: this.removeRepo.bind(this),\n sync: this.syncRepos.bind(this),\n };\n\n this.projects = {\n list: this.listProjects.bind(this),\n create: this.createProject.bind(this),\n update: this.updateProject.bind(this),\n delete: this.deleteProject.bind(this),\n };\n\n this.pullRequests = {\n list: this.listPullRequests.bind(this),\n get: this.getPullRequest.bind(this),\n };\n\n this.deployments = {\n list: this.listDeployments.bind(this),\n };\n\n this.comments = {\n list: this.listComments.bind(this),\n create: this.createComment.bind(this),\n update: this.updateComment.bind(this),\n delete: this.deleteComment.bind(this),\n };\n\n this.checkRuns = {\n create: this.createCheckRun.bind(this),\n update: this.updateCheckRun.bind(this),\n };\n }\n\n /**\n * Make an authenticated API request\n */\n private async request<T>(\n method: string,\n path: string,\n body?: Record<string, unknown>\n ): Promise<T> {\n if (this.debug) {\n console.log(`[GitHub SDK] ${method} ${path}`, body || \"\");\n }\n\n // Centralize transport (auth, retries, timeout, URL) but keep GitHub's own\n // error taxonomy by inspecting the raw response ourselves.\n let response: Response;\n try {\n response = await this._client.request<Response>(method, path, {\n body,\n timeout: this.timeout,\n raw: true,\n });\n } catch (error) {\n if (error instanceof Error && /timed out/i.test(error.message)) {\n throw new GitHubError(\"Request timeout\", 408, \"TIMEOUT\");\n }\n throw new GitHubError(error instanceof Error ? error.message : \"Unknown error\", 500, \"UNKNOWN\");\n }\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({} as Record<string, any>));\n const message = errorData.error || errorData.detail || errorData.message || response.statusText;\n\n if (this.debug) {\n console.error(`[GitHub SDK] Error ${response.status}:`, message);\n }\n\n // Map to specific error types\n if (response.status === 404) {\n if (message.includes(\"installation\")) {\n throw new NoInstallationError(message);\n }\n throw new NotFoundError(message);\n }\n if (response.status === 403) {\n throw new PermissionError(message);\n }\n throw new GitHubError(message, response.status, errorData.code);\n }\n\n const data = await response.json();\n\n if (this.debug) {\n console.log(`[GitHub SDK] Response:`, JSON.stringify(data).slice(0, 200));\n }\n\n return data as T;\n }\n\n /**\n * Get the installation ID to use for a request\n */\n private getInstallationId(input?: { installationId?: string }): string | undefined {\n return input?.installationId || this.defaultInstallationId;\n }\n\n // ==========================================================================\n // Installations\n // ==========================================================================\n\n private async listInstallations(): Promise<Installation[]> {\n return this.request<Installation[]>(\"GET\", \"/api/v1/github/installations\");\n }\n\n private async getInstallation(installationId: string): Promise<Installation> {\n return this.request<Installation>(\"GET\", `/api/v1/github/installations/${installationId}`);\n }\n\n private async updateInstallation(input: UpdateInstallationInput): Promise<Installation> {\n if (this.debug) console.log(\"[GitHub SDK] updateInstallation\", input.installationId);\n const { installationId, ...body } = input;\n return this.request<Installation>(\"PATCH\", `/api/v1/github/installations/${installationId}`, body);\n }\n\n private async disconnectInstallation(installationId: string): Promise<{ success: boolean; alreadyDeleted: boolean }> {\n if (this.debug) console.log(\"[GitHub SDK] disconnectInstallation\", installationId);\n return this.request<{ success: boolean; alreadyDeleted: boolean }>(\"DELETE\", `/api/v1/github/installations/${installationId}`);\n }\n\n // ==========================================================================\n // Repositories\n // ==========================================================================\n\n private async listRepos(input: ListReposInput): Promise<RepoConfig[]> {\n const installationId = input.installationId || this.defaultInstallationId;\n if (!installationId) {\n throw new NoInstallationError(\"installationId required. Call installations.list() first.\");\n }\n return this.request<RepoConfig[]>(\"GET\", `/api/v1/github/installations/${installationId}/repos`);\n }\n\n private async getRepo(repoId: string): Promise<RepoConfig> {\n if (this.debug) console.log(\"[GitHub SDK] getRepo\", repoId);\n return this.request<RepoConfig>(\"GET\", `/api/v1/github/repos/${repoId}`);\n }\n\n private async updateRepo(input: UpdateRepoInput): Promise<RepoConfig> {\n if (this.debug) console.log(\"[GitHub SDK] updateRepo\", input.repoId);\n const { repoId, ...body } = input;\n return this.request<RepoConfig>(\"PATCH\", `/api/v1/github/repos/${repoId}`, body);\n }\n\n private async removeRepo(repoId: string): Promise<{ success: boolean; alreadyRemoved: boolean }> {\n if (this.debug) console.log(\"[GitHub SDK] removeRepo\", repoId);\n return this.request<{ success: boolean; alreadyRemoved: boolean }>(\"DELETE\", `/api/v1/github/repos/${repoId}`);\n }\n\n private async syncRepos(input: SyncReposInput): Promise<{ count: number }> {\n const installationId = input.installationId || this.defaultInstallationId;\n if (!installationId) {\n throw new NoInstallationError(\"installationId required. Call installations.list() first.\");\n }\n if (this.debug) console.log(\"[GitHub SDK] syncRepos\", installationId);\n return this.request<{ count: number }>(\"POST\", `/api/v1/github/installations/${installationId}/repos/sync`);\n }\n\n // ==========================================================================\n // Projects (monorepo sub-projects)\n // ==========================================================================\n\n private async listProjects(input: ListProjectsInput): Promise<Project[]> {\n if (this.debug) console.log(\"[GitHub SDK] listProjects\", input.repoId);\n return this.request<Project[]>(\"GET\", `/api/v1/github/repos/${input.repoId}/projects`);\n }\n\n private async createProject(input: CreateProjectInput): Promise<Project> {\n if (this.debug) console.log(\"[GitHub SDK] createProject\", input.repoId, input.name);\n const { repoId, ...body } = input;\n return this.request<Project>(\"POST\", `/api/v1/github/repos/${repoId}/projects`, body);\n }\n\n private async updateProject(input: UpdateProjectInput): Promise<Project> {\n if (this.debug) console.log(\"[GitHub SDK] updateProject\", input.projectId);\n const { projectId, ...body } = input;\n return this.request<Project>(\"PATCH\", `/api/v1/github/projects/${projectId}`, body);\n }\n\n private async deleteProject(projectId: string): Promise<{ success: boolean }> {\n if (this.debug) console.log(\"[GitHub SDK] deleteProject\", projectId);\n return this.request<{ success: boolean }>(\"DELETE\", `/api/v1/github/projects/${projectId}`);\n }\n\n // ==========================================================================\n // Pull Requests\n // ==========================================================================\n\n private async listPullRequests(input: ListPullRequestsInput): Promise<PullRequest[]> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n ...(input.state && { state: input.state }),\n ...(installationId && { installationId }),\n });\n return this.request<PullRequest[]>(\"GET\", `/api/v1/github/pulls?${params}`);\n }\n\n private async getPullRequest(input: GetPullRequestInput): Promise<PullRequestWithContext> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n ...(installationId && { installationId }),\n });\n return this.request<PullRequestWithContext>(\n \"GET\",\n `/api/v1/github/pulls/${input.number}?${params}`\n );\n }\n\n // ==========================================================================\n // Deployments\n // ==========================================================================\n\n private async listDeployments(input: ListDeploymentsInput): Promise<Deployment[]> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n ...(input.sha && { sha: input.sha }),\n ...(input.environment && { environment: input.environment }),\n ...(installationId && { installationId }),\n });\n return this.request<Deployment[]>(\"GET\", `/api/v1/github/deployments?${params}`);\n }\n\n // ==========================================================================\n // Comments\n // ==========================================================================\n\n private async listComments(input: ListCommentsInput): Promise<Comment[]> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n pr: String(input.pr),\n ...(installationId && { installationId }),\n });\n return this.request<Comment[]>(\"GET\", `/api/v1/github/comments?${params}`);\n }\n\n private async createComment(input: CreateCommentInput): Promise<Comment> {\n const installationId = this.getInstallationId(input);\n return this.request<Comment>(\"POST\", \"/api/v1/github/comments\", {\n owner: input.owner,\n repo: input.repo,\n pr: input.pr,\n body: input.body,\n ...(installationId && { installationId }),\n });\n }\n\n private async updateComment(input: UpdateCommentInput): Promise<Comment> {\n const installationId = this.getInstallationId(input);\n return this.request<Comment>(\"PATCH\", `/api/v1/github/comments/${input.commentId}`, {\n owner: input.owner,\n repo: input.repo,\n body: input.body,\n ...(installationId && { installationId }),\n });\n }\n\n private async deleteComment(input: DeleteCommentInput): Promise<void> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n ...(installationId && { installationId }),\n });\n await this.request<void>(\"DELETE\", `/api/v1/github/comments/${input.commentId}?${params}`);\n }\n\n // ==========================================================================\n // Check Runs\n // ==========================================================================\n\n private async createCheckRun(input: CreateCheckRunInput): Promise<CheckRun> {\n const installationId = this.getInstallationId(input);\n return this.request<CheckRun>(\"POST\", \"/api/v1/github/check-runs\", {\n owner: input.owner,\n repo: input.repo,\n sha: input.sha,\n name: input.name,\n status: input.status,\n ...(input.title && { title: input.title }),\n ...(input.summary && { summary: input.summary }),\n ...(installationId && { installationId }),\n });\n }\n\n private async updateCheckRun(input: UpdateCheckRunInput): Promise<CheckRun> {\n const installationId = this.getInstallationId(input);\n return this.request<CheckRun>(\"PATCH\", `/api/v1/github/check-runs/${input.checkRunId}`, {\n owner: input.owner,\n repo: input.repo,\n ...(input.status && { status: input.status }),\n ...(input.conclusion && { conclusion: input.conclusion }),\n ...(input.title && { title: input.title }),\n ...(input.summary && { summary: input.summary }),\n ...(input.text && { text: input.text }),\n ...(installationId && { installationId }),\n });\n }\n}\n","/**\n * OpenAI Tool Factory for MorphClient\n * \n * Creates OpenAI-compatible tools that inherit the API key from MorphClient.\n */\n\nimport type { MorphClientConfig } from '../client.js';\nimport { createWarpGrepTool, createGitHubSearchTool } from '../tools/warp_grep/openai.js';\nimport { createCodebaseSearchTool } from '../tools/codebase_search/openai.js';\nimport { createEditFileTool } from '../tools/fastapply/openai.js';\nimport type { WarpGrepToolConfig, GitHubSearchToolConfig } from '../tools/warp_grep/types.js';\nimport type { CodebaseSearchConfig } from '../tools/codebase_search/types.js';\nimport type { EditFileConfig } from '../tools/fastapply/types.js';\n\n/**\n * Factory for creating OpenAI-compatible tools with inherited API key\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n * \n * const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.openai.createCodebaseSearchTool({ repoId: 'my-project' });\n * const editTool = morph.openai.createEditFileTool({ baseDir: './src' });\n * \n * // Use with OpenAI client\n * const response = await openai.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [grepTool, searchTool, editTool],\n * messages: [{ role: 'user', content: 'Find and fix the bug' }]\n * });\n * ```\n */\nexport class OpenAIToolFactory {\n constructor(private config: MorphClientConfig) {}\n\n /**\n * Create an OpenAI-compatible warp grep tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>) {\n return createWarpGrepTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an OpenAI-compatible codebase search tool\n * \n * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>) {\n return createCodebaseSearchTool({ \n ...toolConfig, \n apiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an OpenAI-compatible edit file tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createEditFileTool(toolConfig: Omit<EditFileConfig, 'morphApiKey'> = {}) {\n return createEditFileTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an OpenAI-compatible GitHub search tool\n *\n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createGitHubSearchTool(toolConfig?: Omit<GitHubSearchToolConfig, 'morphApiKey'>) {\n return createGitHubSearchTool({\n ...toolConfig,\n morphApiKey: this.config.apiKey,\n });\n }\n}\n\n","/**\n * Anthropic Tool Factory for MorphClient\n * \n * Creates Anthropic-compatible tools that inherit the API key from MorphClient.\n */\n\nimport type { MorphClientConfig } from '../client.js';\nimport { createWarpGrepTool, createGitHubSearchTool } from '../tools/warp_grep/anthropic.js';\nimport { createCodebaseSearchTool } from '../tools/codebase_search/anthropic.js';\nimport { createEditFileTool } from '../tools/fastapply/anthropic.js';\nimport { createExploreSubagent } from '../subagents/anthropic.js';\nimport type { WarpGrepToolConfig, GitHubSearchToolConfig } from '../tools/warp_grep/types.js';\nimport type { CodebaseSearchConfig } from '../tools/codebase_search/types.js';\nimport type { EditFileConfig } from '../tools/fastapply/types.js';\nimport type { ExploreSubagentConfig } from '../subagents/types.js';\n\n/**\n * Factory for creating Anthropic-compatible tools with inherited API key\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n * \n * const grepTool = morph.anthropic.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'my-project' });\n * const editTool = morph.anthropic.createEditFileTool({ baseDir: './src' });\n * \n * // Use with Anthropic client\n * const response = await anthropic.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [grepTool, searchTool, editTool],\n * messages: [{ role: 'user', content: 'Find and fix the bug' }]\n * });\n * ```\n */\nexport class AnthropicToolFactory {\n constructor(private config: MorphClientConfig) {}\n\n /**\n * Create an Anthropic-compatible warp grep tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>) {\n return createWarpGrepTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n\n }\n\n /**\n * Create an Anthropic-compatible codebase search tool\n * \n * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>) {\n return createCodebaseSearchTool({ \n ...toolConfig, \n apiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an Anthropic-compatible edit file tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createEditFileTool(toolConfig: Omit<EditFileConfig, 'morphApiKey'> = {}) {\n return createEditFileTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an Anthropic-compatible GitHub search tool\n *\n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createGitHubSearchTool(toolConfig?: Omit<GitHubSearchToolConfig, 'morphApiKey'>) {\n return createGitHubSearchTool({\n ...toolConfig,\n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an Explore subagent that searches the codebase and returns summaries\n *\n * @param config - Subagent configuration including client and model (morphApiKey inherited from MorphClient)\n * @returns Explore subagent with .tool, .run(), and .stream() methods\n */\n createExploreSubagent(config: Omit<ExploreSubagentConfig, 'morphApiKey'> & { client: any; model: string }) {\n return createExploreSubagent({\n ...config,\n morphApiKey: this.config.apiKey,\n });\n }\n}\n\n","/**\n * Vercel AI SDK Tool Factory for MorphClient\n * \n * Creates Vercel AI SDK-compatible tools that inherit the API key from MorphClient.\n */\n\nimport type { LanguageModel } from 'ai';\nimport type { MorphClientConfig } from '../client.js';\nimport { createWarpGrepTool, createGitHubSearchTool } from '../tools/warp_grep/vercel.js';\nimport { createCodebaseSearchTool } from '../tools/codebase_search/vercel.js';\nimport { createEditFileTool } from '../tools/fastapply/vercel.js';\nimport { createExploreSubagent } from '../subagents/vercel.js';\nimport type { WarpGrepToolConfig, GitHubSearchToolConfig } from '../tools/warp_grep/types.js';\nimport type { CodebaseSearchConfig } from '../tools/codebase_search/types.js';\nimport type { EditFileConfig } from '../tools/fastapply/types.js';\nimport type { ExploreSubagentConfig } from '../subagents/types.js';\n\n/**\n * Factory for creating Vercel AI SDK-compatible tools with inherited API key\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n * \n * const grepTool = morph.vercel.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.vercel.createCodebaseSearchTool({ repoId: 'my-project' });\n * const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });\n * \n * // Use with Vercel AI SDK\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { grep: grepTool, search: searchTool, edit: editTool },\n * prompt: 'Find and fix the bug'\n * });\n * ```\n */\nexport class VercelToolFactory {\n constructor(private config: MorphClientConfig) {}\n\n /**\n * Create a Vercel AI SDK-compatible warp grep tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>) {\n return createWarpGrepTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create a Vercel AI SDK-compatible codebase search tool\n * \n * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>) {\n return createCodebaseSearchTool({ \n ...toolConfig, \n apiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create a Vercel AI SDK-compatible edit file tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createEditFileTool(toolConfig: Omit<EditFileConfig, 'morphApiKey'> = {}) {\n return createEditFileTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create a Vercel AI SDK-compatible GitHub search tool\n *\n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createGitHubSearchTool(toolConfig?: Omit<GitHubSearchToolConfig, 'morphApiKey'>) {\n return createGitHubSearchTool({\n ...toolConfig,\n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an Explore subagent that searches the codebase and returns summaries\n *\n * @param config - Subagent configuration including model (morphApiKey inherited from MorphClient)\n * @returns Explore subagent with .tool, .run(), and .stream() methods\n */\n createExploreSubagent(config: Omit<ExploreSubagentConfig, 'morphApiKey'> & { model: LanguageModel }) {\n return createExploreSubagent({\n ...config,\n morphApiKey: this.config.apiKey,\n });\n }\n}\n\n","/**\n * Unified Morph SDK Client\n * \n * Provides access to all Morph tools through a single interface\n * \n * @example\n * ```typescript\n * import { MorphClient } from '@morphllm/morphsdk';\n * \n * const morph = new MorphClient({ \n * apiKey: process.env.MORPH_API_KEY,\n * debug: true,\n * timeout: 60000\n * });\n * \n * // Direct execution\n * await morph.fastApply.execute({ target_filepath: 'src/index.ts', ... });\n * await morph.warpGrep.execute({ query: 'Find auth', repoRoot: '.' });\n * await morph.codebaseSearch.search({ query: 'auth logic', repoId: 'x' });\n * \n * // Tool creation for AI agents (API key inherited)\n * const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'x' });\n * const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });\n * \n * // Use tools with OpenAI\n * const response = await openai.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [grepTool],\n * messages: [{ role: 'user', content: 'Find the bug' }]\n * });\n * ```\n */\n\nimport type { RetryConfig } from './tools/utils/resilience.js';\nimport { MorphAPIClient } from './core/client.js';\nimport { logger } from './logger.js';\nimport { FastApplyClient } from './tools/fastapply/core.js';\nimport { CodebaseSearchClient } from './tools/codebase_search/core.js';\nimport { BrowserClient } from './tools/browser/core.js';\nimport { WarpGrepClient } from './tools/warp_grep/client.js';\nimport { GitHubClient } from './tools/github/core.js';\nimport { MorphGit } from './git/index.js';\nimport { CompactClient } from './tools/compact/core.js';\nimport { ReflexClient } from './tools/reflex/core.js';\nimport { OpenAIRouter, AnthropicRouter, GeminiRouter, RawRouter } from './modelrouter/core.js';\nimport { OpenAIToolFactory, AnthropicToolFactory, VercelToolFactory } from './factories/index.js';\n\n/**\n * Configuration for the MorphClient\n */\nexport interface MorphClientConfig {\n /** Morph API key for authentication (defaults to MORPH_API_KEY env var) */\n apiKey?: string;\n /** Enable debug logging across all tools */\n debug?: boolean;\n /** Default timeout in milliseconds for API requests */\n timeout?: number;\n /** Retry configuration for failed requests */\n retryConfig?: RetryConfig;\n /** GitHub-specific configuration */\n github?: {\n /** Default installation ID for GitHub operations */\n installationId?: string;\n };\n}\n\n/**\n * Unified Morph SDK Client\n * \n * Provides access to all Morph tools through a single interface:\n * - fastApply: AI-powered file editing with intelligent merging\n * - codebaseSearch: Semantic code search\n * - warpGrep: Fast code search with ripgrep\n * - browser: AI-powered browser automation\n * - git: Version control operations\n * - routers: Intelligent model selection (OpenAI, Anthropic, Gemini)\n * - openai/anthropic/vercel: Tool factories for agent frameworks\n */\nexport class MorphClient extends MorphAPIClient {\n /** Client configuration */\n public config: MorphClientConfig;\n\n /** FastApply tool for editing files with AI-powered merge */\n public fastApply: FastApplyClient;\n\n /** CodebaseSearch tool for semantic code search */\n public codebaseSearch: CodebaseSearchClient;\n\n /** WarpGrep tool for fast code search using ripgrep */\n public warpGrep: WarpGrepClient;\n\n /** Browser tool for AI-powered browser automation */\n public browser: BrowserClient;\n\n /** GitHub tool for PR context, comments, and check runs */\n public github: GitHubClient;\n\n /** Git tool for version control operations */\n public git: MorphGit;\n\n /** Model routers for intelligent model selection */\n public routers: {\n openai: OpenAIRouter;\n anthropic: AnthropicRouter;\n gemini: GeminiRouter;\n raw: RawRouter;\n };\n\n /** OpenAI-compatible tool factories */\n public openai: OpenAIToolFactory;\n\n /** Anthropic-compatible tool factories */\n public anthropic: AnthropicToolFactory;\n\n /** Vercel AI SDK tool factories */\n public vercel: VercelToolFactory;\n\n /** Compact context with line ranges */\n public compact: CompactClient['compact'];\n\n /** Reflex: train and serve small text classifiers */\n public reflex: ReflexClient;\n\n /**\n * Create a new Morph SDK client\n * \n * @param config - Client configuration (apiKey, debug, timeout, retryConfig)\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ \n * apiKey: process.env.MORPH_API_KEY,\n * debug: true,\n * timeout: 60000\n * });\n * ```\n */\n constructor(config: MorphClientConfig = {}) {\n // MorphClient *is* the transport: it owns auth/host/retries/timeout and every\n // resource below shares it by reference (the OpenAI SDK pattern).\n super({\n apiKey: config.apiKey,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n debug: config.debug,\n });\n\n // An explicit key is required (sub-resources like Git depend on it); this\n // preserves the long-standing eager-throw on construction.\n if (!config.apiKey) {\n throw new Error('Morph API key is required. Pass it as { apiKey } when constructing MorphClient.');\n }\n\n this.config = config;\n logger.debug('MorphClient', 'initialized', { debug: !!config.debug, timeout: config.timeout });\n\n // Attach every resource, sharing this single transport.\n this.fastApply = new FastApplyClient(this);\n this.codebaseSearch = new CodebaseSearchClient(this);\n this.warpGrep = new WarpGrepClient(this);\n this.browser = new BrowserClient(this);\n this.github = new GitHubClient(this, { installationId: config.github?.installationId });\n this.git = new MorphGit(this);\n\n this.routers = {\n openai: new OpenAIRouter(this),\n anthropic: new AnthropicRouter(this),\n gemini: new GeminiRouter(this),\n raw: new RawRouter(this),\n };\n\n const compactClient = new CompactClient(this);\n this.compact = compactClient.compact.bind(compactClient);\n\n this.reflex = new ReflexClient(this);\n\n // Tool factories build framework-specific tool definitions from the same config.\n this.openai = new OpenAIToolFactory(config);\n this.anthropic = new AnthropicToolFactory(config);\n this.vercel = new VercelToolFactory(config);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAweO,IAAM,cAAN,cAA0B,MAAM;AAAA;AAAA,EAErC;AAAA;AAAA,EAEA;AAAA,EAEA,YAAY,SAAiB,QAAgB,MAAe;AAC1D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,YAAY,UAAU,8FAA8F;AAClH,UAAM,SAAS,KAAK,iBAAiB;AAAA,EACvC;AACF;AAKO,IAAM,gBAAN,cAA4B,YAAY;AAAA,EAC7C,YAAY,UAAkB;AAC5B,UAAM,GAAG,QAAQ,cAAc,KAAK,WAAW;AAAA,EACjD;AACF;AAKO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC/C,YAAY,UAAU,+CAA+C;AACnE,UAAM,SAAS,KAAK,mBAAmB;AAAA,EACzC;AACF;;;ACpeA,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AA0BjB,IAAM,eAAN,cAA2B,YAAY;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAG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7B,KAAK,IAAI,UAAU,IAAI;AAAA,IACzB;AAEA,UAAM,gBAAgB,IAAI,cAAc,IAAI;AAC5C,SAAK,UAAU,cAAc,QAAQ,KAAK,aAAa;AAEvD,SAAK,SAAS,IAAI,aAAa,IAAI;AAGnC,SAAK,SAAS,IAAI,kBAAkB,MAAM;AAC1C,SAAK,YAAY,IAAI,qBAAqB,MAAM;AAChD,SAAK,SAAS,IAAI,kBAAkB,MAAM;AAAA,EAC5C;AACF;","names":["createWarpGrepTool","createCodebaseSearchTool","createEditFileTool","createGitHubSearchTool","createWarpGrepTool","createCodebaseSearchTool","createEditFileTool","createGitHubSearchTool","createExploreSubagent"]}
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "./chunk-F3NCFNUX.js";
|
|
24
24
|
import {
|
|
25
25
|
SDK_VERSION
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-73DQQMGR.js";
|
|
27
27
|
|
|
28
28
|
// tools/warp_grep/agent/runner.ts
|
|
29
29
|
import OpenAI from "openai";
|
|
@@ -425,4 +425,4 @@ export {
|
|
|
425
425
|
runWarpGrepStreaming,
|
|
426
426
|
runWarpGrep
|
|
427
427
|
};
|
|
428
|
-
//# sourceMappingURL=chunk-
|
|
428
|
+
//# sourceMappingURL=chunk-QCFHQPHC.js.map
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-F3NCFNUX.js";
|
|
4
|
+
import {
|
|
5
|
+
toMorphError
|
|
6
|
+
} from "./chunk-ZFOR3LI4.js";
|
|
7
|
+
import {
|
|
8
|
+
MorphError,
|
|
9
|
+
fetchWithRetry,
|
|
10
|
+
withTimeout
|
|
11
|
+
} from "./chunk-JXJBF6CV.js";
|
|
12
|
+
import {
|
|
13
|
+
SDK_VERSION
|
|
14
|
+
} from "./chunk-73DQQMGR.js";
|
|
15
|
+
|
|
16
|
+
// core/client.ts
|
|
17
|
+
var DEFAULT_BASE_URL = "https://api.morphllm.com";
|
|
18
|
+
var DEFAULT_REPOS_URL = "https://repos.morphllm.com";
|
|
19
|
+
var DEFAULT_BROWSER_URL = "https://browser.morphllm.com";
|
|
20
|
+
var DEFAULT_TIMEOUT = 6e4;
|
|
21
|
+
var env = (name) => typeof process !== "undefined" ? process.env?.[name] : void 0;
|
|
22
|
+
var stripTrailingSlash = (url) => url.replace(/\/+$/, "");
|
|
23
|
+
var MorphAPIClient = class {
|
|
24
|
+
/** Explicit key as provided; resolved against env at request time. */
|
|
25
|
+
apiKey;
|
|
26
|
+
baseURL;
|
|
27
|
+
reposURL;
|
|
28
|
+
browserURL;
|
|
29
|
+
/** Explicit default timeout (ms), if set. The request default is applied lazily so
|
|
30
|
+
* resources can read an undefined value and supply their own fallback. */
|
|
31
|
+
timeout;
|
|
32
|
+
retryConfig;
|
|
33
|
+
debug;
|
|
34
|
+
constructor(options = {}) {
|
|
35
|
+
this.apiKey = options.apiKey;
|
|
36
|
+
this.baseURL = stripTrailingSlash(options.baseURL ?? DEFAULT_BASE_URL);
|
|
37
|
+
this.reposURL = stripTrailingSlash(options.reposURL ?? env("MORPH_SEARCH_URL") ?? DEFAULT_REPOS_URL);
|
|
38
|
+
this.browserURL = stripTrailingSlash(
|
|
39
|
+
options.browserURL ?? (env("MORPH_ENVIRONMENT") === "DEV" ? "http://localhost:8000" : DEFAULT_BROWSER_URL)
|
|
40
|
+
);
|
|
41
|
+
this.timeout = options.timeout;
|
|
42
|
+
this.retryConfig = options.retryConfig;
|
|
43
|
+
this.debug = options.debug ?? false;
|
|
44
|
+
if (this.debug) logger.enable();
|
|
45
|
+
}
|
|
46
|
+
/** The key actually used for requests: explicit, else `MORPH_API_KEY`. */
|
|
47
|
+
resolveApiKey() {
|
|
48
|
+
return this.apiKey ?? env("MORPH_API_KEY");
|
|
49
|
+
}
|
|
50
|
+
/** Headers shared with tools that bring their own HTTP client (FastApply/WarpGrep via the `openai` package). */
|
|
51
|
+
defaultHeaders() {
|
|
52
|
+
return { "X-Morph-SDK-Version": SDK_VERSION };
|
|
53
|
+
}
|
|
54
|
+
buildURL(path, baseURL) {
|
|
55
|
+
if (/^https?:\/\//i.test(path)) return path;
|
|
56
|
+
const base = stripTrailingSlash(baseURL ?? this.baseURL);
|
|
57
|
+
return `${base}${path.startsWith("/") ? "" : "/"}${path}`;
|
|
58
|
+
}
|
|
59
|
+
buildHeaders(apiKey, extra) {
|
|
60
|
+
return {
|
|
61
|
+
"Content-Type": "application/json",
|
|
62
|
+
"X-Morph-SDK-Version": SDK_VERSION,
|
|
63
|
+
Authorization: `Bearer ${apiKey}`,
|
|
64
|
+
...extra
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
applyQuery(url, query) {
|
|
68
|
+
if (!query) return url;
|
|
69
|
+
const params = new URLSearchParams();
|
|
70
|
+
for (const [key, value] of Object.entries(query)) {
|
|
71
|
+
if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
72
|
+
}
|
|
73
|
+
const qs = params.toString();
|
|
74
|
+
return qs ? `${url}${url.includes("?") ? "&" : "?"}${qs}` : url;
|
|
75
|
+
}
|
|
76
|
+
async request(method, path, opts = {}) {
|
|
77
|
+
const apiKey = this.resolveApiKey();
|
|
78
|
+
if (!apiKey) {
|
|
79
|
+
throw new MorphError(
|
|
80
|
+
"Morph API key not found. Set the MORPH_API_KEY environment variable or pass apiKey in config.",
|
|
81
|
+
"missing_api_key",
|
|
82
|
+
401
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
const url = this.applyQuery(this.buildURL(path, opts.baseURL), opts.query);
|
|
86
|
+
const timeout = opts.timeout ?? this.timeout ?? DEFAULT_TIMEOUT;
|
|
87
|
+
const init = {
|
|
88
|
+
method,
|
|
89
|
+
headers: this.buildHeaders(apiKey, opts.headers),
|
|
90
|
+
...opts.body !== void 0 ? { body: JSON.stringify(opts.body) } : {},
|
|
91
|
+
...opts.signal ? { signal: opts.signal } : {}
|
|
92
|
+
};
|
|
93
|
+
logger.debug("MorphAPIClient", "request", { method, url });
|
|
94
|
+
const response = await withTimeout(
|
|
95
|
+
fetchWithRetry(url, init, this.retryConfig ?? {}),
|
|
96
|
+
timeout,
|
|
97
|
+
`Morph request to ${url} timed out after ${timeout}ms`
|
|
98
|
+
);
|
|
99
|
+
if (opts.raw) return response;
|
|
100
|
+
if (!response.ok) throw await toMorphError(response);
|
|
101
|
+
if (opts.stream) return response;
|
|
102
|
+
if (response.status === 204) return void 0;
|
|
103
|
+
const text = await response.text();
|
|
104
|
+
return text ? JSON.parse(text) : void 0;
|
|
105
|
+
}
|
|
106
|
+
get(path, opts) {
|
|
107
|
+
return this.request("GET", path, opts);
|
|
108
|
+
}
|
|
109
|
+
post(path, opts) {
|
|
110
|
+
return this.request("POST", path, opts);
|
|
111
|
+
}
|
|
112
|
+
delete(path, opts) {
|
|
113
|
+
return this.request("DELETE", path, opts);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export {
|
|
118
|
+
MorphAPIClient
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=chunk-QE3SPHIM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../core/client.ts"],"sourcesContent":["/**\n * MorphAPIClient — the SDK transport.\n *\n * One place owns authentication, the Morph service hosts, default headers,\n * retries, timeouts, and error mapping. Every resource (FastApply, Compact,\n * Reflex, …) holds a reference to this client and delegates HTTP to it via\n * `get`/`post`/`delete`/`request`, exactly like the OpenAI SDK.\n *\n * This module is intentionally free of tool imports and Node built-ins so it\n * stays edge-safe (it is reachable from `@morphllm/morphsdk/edge` through the\n * Compact and model-router resources).\n */\nimport { fetchWithRetry, withTimeout, MorphError, type RetryConfig } from '../tools/utils/resilience.js';\nimport { logger } from '../logger.js';\nimport { SDK_VERSION } from '../version.js';\nimport { toMorphError } from './error.js';\n\n/** The Morph services the SDK talks to. */\nconst DEFAULT_BASE_URL = 'https://api.morphllm.com';\nconst DEFAULT_REPOS_URL = 'https://repos.morphllm.com';\nconst DEFAULT_BROWSER_URL = 'https://browser.morphllm.com';\nconst DEFAULT_TIMEOUT = 60_000;\n\nconst env = (name: string): string | undefined =>\n typeof process !== 'undefined' ? process.env?.[name] : undefined;\n\nconst stripTrailingSlash = (url: string): string => url.replace(/\\/+$/, '');\n\nexport interface MorphAPIClientOptions {\n /** Morph API key. Resolved against `MORPH_API_KEY` at request time if omitted. */\n apiKey?: string;\n /** Primary API host (default `https://api.morphllm.com`). */\n baseURL?: string;\n /** Code-storage host for codebase search and git (default `https://repos.morphllm.com`). */\n reposURL?: string;\n /** Browser-automation host (default `https://browser.morphllm.com`). */\n browserURL?: string;\n /** Default per-request timeout in ms (default 60s). Resources may override per call. */\n timeout?: number;\n /** Retry policy for transient failures. */\n retryConfig?: RetryConfig;\n /** Enable debug logging. */\n debug?: boolean;\n}\n\n/** Per-request options accepted by `request`/`get`/`post`/`delete`. */\nexport interface RequestOptions {\n /** JSON body; serialized with `JSON.stringify`. */\n body?: unknown;\n /** Query parameters; `undefined`/`null` values are dropped. */\n query?: Record<string, string | number | boolean | undefined | null>;\n /** Extra headers, merged over (and able to override) the defaults. */\n headers?: Record<string, string>;\n /** Override the timeout for this call. */\n timeout?: number;\n /** Hit a different host than the default (e.g. `this._client.reposURL`). */\n baseURL?: string;\n /** Return the raw `Response` of a successful (2xx) request instead of parsed JSON (for streaming). */\n stream?: boolean;\n /**\n * Return the raw `Response` without throwing on non-2xx and without parsing.\n * For resources that map errors into their own taxonomy (e.g. GitHub).\n */\n raw?: boolean;\n /** Caller-supplied abort signal. */\n signal?: AbortSignal;\n}\n\nexport class MorphAPIClient {\n /** Explicit key as provided; resolved against env at request time. */\n apiKey?: string;\n baseURL: string;\n reposURL: string;\n browserURL: string;\n /** Explicit default timeout (ms), if set. The request default is applied lazily so\n * resources can read an undefined value and supply their own fallback. */\n timeout?: number;\n retryConfig?: RetryConfig;\n debug: boolean;\n\n constructor(options: MorphAPIClientOptions = {}) {\n this.apiKey = options.apiKey;\n this.baseURL = stripTrailingSlash(options.baseURL ?? DEFAULT_BASE_URL);\n this.reposURL = stripTrailingSlash(options.reposURL ?? env('MORPH_SEARCH_URL') ?? DEFAULT_REPOS_URL);\n this.browserURL = stripTrailingSlash(\n options.browserURL ?? (env('MORPH_ENVIRONMENT') === 'DEV' ? 'http://localhost:8000' : DEFAULT_BROWSER_URL),\n );\n this.timeout = options.timeout;\n this.retryConfig = options.retryConfig;\n this.debug = options.debug ?? false;\n if (this.debug) logger.enable();\n }\n\n /** The key actually used for requests: explicit, else `MORPH_API_KEY`. */\n resolveApiKey(): string | undefined {\n return this.apiKey ?? env('MORPH_API_KEY');\n }\n\n /** Headers shared with tools that bring their own HTTP client (FastApply/WarpGrep via the `openai` package). */\n defaultHeaders(): Record<string, string> {\n return { 'X-Morph-SDK-Version': SDK_VERSION };\n }\n\n buildURL(path: string, baseURL?: string): string {\n if (/^https?:\\/\\//i.test(path)) return path;\n const base = stripTrailingSlash(baseURL ?? this.baseURL);\n return `${base}${path.startsWith('/') ? '' : '/'}${path}`;\n }\n\n private buildHeaders(apiKey: string, extra?: Record<string, string>): Record<string, string> {\n return {\n 'Content-Type': 'application/json',\n 'X-Morph-SDK-Version': SDK_VERSION,\n Authorization: `Bearer ${apiKey}`,\n ...extra,\n };\n }\n\n private applyQuery(url: string, query?: RequestOptions['query']): string {\n if (!query) return url;\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined && value !== null) params.set(key, String(value));\n }\n const qs = params.toString();\n return qs ? `${url}${url.includes('?') ? '&' : '?'}${qs}` : url;\n }\n\n async request<T>(method: string, path: string, opts: RequestOptions = {}): Promise<T> {\n const apiKey = this.resolveApiKey();\n if (!apiKey) {\n throw new MorphError(\n 'Morph API key not found. Set the MORPH_API_KEY environment variable or pass apiKey in config.',\n 'missing_api_key',\n 401,\n );\n }\n\n const url = this.applyQuery(this.buildURL(path, opts.baseURL), opts.query);\n const timeout = opts.timeout ?? this.timeout ?? DEFAULT_TIMEOUT;\n\n const init: RequestInit = {\n method,\n headers: this.buildHeaders(apiKey, opts.headers),\n ...(opts.body !== undefined ? { body: JSON.stringify(opts.body) } : {}),\n ...(opts.signal ? { signal: opts.signal } : {}),\n };\n\n logger.debug('MorphAPIClient', 'request', { method, url });\n\n const response = await withTimeout(\n fetchWithRetry(url, init, this.retryConfig ?? {}),\n timeout,\n `Morph request to ${url} timed out after ${timeout}ms`,\n );\n\n if (opts.raw) return response as unknown as T;\n if (!response.ok) throw await toMorphError(response);\n if (opts.stream) return response as unknown as T;\n if (response.status === 204) return undefined as T;\n\n const text = await response.text();\n return (text ? JSON.parse(text) : undefined) as T;\n }\n\n get<T>(path: string, opts?: RequestOptions): Promise<T> {\n return this.request<T>('GET', path, opts);\n }\n\n post<T>(path: string, opts?: RequestOptions): Promise<T> {\n return this.request<T>('POST', path, opts);\n }\n\n delete<T>(path: string, opts?: RequestOptions): Promise<T> {\n return this.request<T>('DELETE', path, opts);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,IAAM,mBAAmB;AACzB,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAC5B,IAAM,kBAAkB;AAExB,IAAM,MAAM,CAAC,SACX,OAAO,YAAY,cAAc,QAAQ,MAAM,IAAI,IAAI;AAEzD,IAAM,qBAAqB,CAAC,QAAwB,IAAI,QAAQ,QAAQ,EAAE;AA0CnE,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAE1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,UAAiC,CAAC,GAAG;AAC/C,SAAK,SAAS,QAAQ;AACtB,SAAK,UAAU,mBAAmB,QAAQ,WAAW,gBAAgB;AACrE,SAAK,WAAW,mBAAmB,QAAQ,YAAY,IAAI,kBAAkB,KAAK,iBAAiB;AACnG,SAAK,aAAa;AAAA,MAChB,QAAQ,eAAe,IAAI,mBAAmB,MAAM,QA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+
} from "./chunk-ACWLQFYS.js";
|
|
12
12
|
|
|
13
13
|
// tools/warp_grep/vercel.ts
|
|
14
14
|
import { tool } from "ai";
|
|
@@ -115,4 +115,4 @@ export {
|
|
|
115
115
|
createGitHubReadFileTool,
|
|
116
116
|
vercel_default
|
|
117
117
|
};
|
|
118
|
-
//# sourceMappingURL=chunk-
|
|
118
|
+
//# sourceMappingURL=chunk-QE6JHRVD.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-2HMEZZKK.js";
|
|
4
4
|
import {
|
|
5
5
|
executeBrowserTask
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-I4FCFIBU.js";
|
|
7
7
|
import {
|
|
8
8
|
__export
|
|
9
9
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -54,4 +54,4 @@ export {
|
|
|
54
54
|
browserTool,
|
|
55
55
|
vercel_exports
|
|
56
56
|
};
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-RXCHMNCY.js.map
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MorphAPIClient
|
|
3
|
+
} from "./chunk-QE3SPHIM.js";
|
|
1
4
|
import {
|
|
2
5
|
logger
|
|
3
6
|
} from "./chunk-F3NCFNUX.js";
|
|
7
|
+
import {
|
|
8
|
+
APIResource
|
|
9
|
+
} from "./chunk-LKFZBBTD.js";
|
|
4
10
|
|
|
5
11
|
// tools/fastapply/core.ts
|
|
6
12
|
import { join, resolve, relative } from "path";
|
|
@@ -12,15 +18,24 @@ var DEFAULT_CONFIG = {
|
|
|
12
18
|
timeout: 9e4,
|
|
13
19
|
debug: false
|
|
14
20
|
};
|
|
15
|
-
var FastApplyClient = class {
|
|
21
|
+
var FastApplyClient = class extends APIResource {
|
|
16
22
|
config;
|
|
17
|
-
constructor(
|
|
23
|
+
constructor(clientOrConfig = {}) {
|
|
24
|
+
const isClient = clientOrConfig instanceof MorphAPIClient;
|
|
25
|
+
super(
|
|
26
|
+
isClient ? clientOrConfig : new MorphAPIClient({
|
|
27
|
+
apiKey: clientOrConfig.apiKey,
|
|
28
|
+
timeout: clientOrConfig.timeout ?? DEFAULT_CONFIG.timeout,
|
|
29
|
+
retryConfig: clientOrConfig.retryConfig,
|
|
30
|
+
debug: clientOrConfig.debug
|
|
31
|
+
})
|
|
32
|
+
);
|
|
18
33
|
this.config = {
|
|
19
|
-
morphApiKey:
|
|
20
|
-
morphApiUrl:
|
|
21
|
-
debug:
|
|
22
|
-
timeout:
|
|
23
|
-
retryConfig:
|
|
34
|
+
morphApiKey: this._client.resolveApiKey(),
|
|
35
|
+
morphApiUrl: this._client.baseURL,
|
|
36
|
+
debug: this._client.debug,
|
|
37
|
+
timeout: (isClient ? void 0 : clientOrConfig.timeout) ?? DEFAULT_CONFIG.timeout,
|
|
38
|
+
retryConfig: this._client.retryConfig,
|
|
24
39
|
generateUdiff: DEFAULT_CONFIG.generateUdiff,
|
|
25
40
|
autoWrite: DEFAULT_CONFIG.autoWrite
|
|
26
41
|
};
|
|
@@ -124,4 +139,4 @@ export {
|
|
|
124
139
|
FastApplyClient,
|
|
125
140
|
executeEditFile
|
|
126
141
|
};
|
|
127
|
-
//# sourceMappingURL=chunk-
|
|
142
|
+
//# sourceMappingURL=chunk-S5R4H5HM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/fastapply/core.ts"],"sourcesContent":["/**\n * Core implementation of Morph Fast Apply\n *\n * This module provides file-based operations that require Node.js.\n * For edge-compatible code-in/code-out operations, use applyEdit from ./apply.ts\n */\n\nimport { join, resolve, relative } from 'path';\nimport type {\n EditFileInput,\n EditFileResult,\n EditFileConfig,\n} from './types.js';\nimport { logger } from '../../logger.js';\nimport { MorphAPIClient } from '../../core/client.js';\nimport { APIResource } from '../../core/resource.js';\n\n// Re-export edge-compatible functions\nexport { applyEdit, generateUdiff, countChanges, callMorphAPI } from './apply.js';\n\nconst DEFAULT_CONFIG: Required<Omit<EditFileConfig, 'morphApiKey' | 'systemPrompt' | 'retryConfig' | 'description' | 'large'>> = {\n morphApiUrl: 'https://api.morphllm.com',\n baseDir: process.cwd(),\n generateUdiff: true,\n autoWrite: true,\n timeout: 90000,\n debug: false,\n};\n\n/**\n * FastApply client for programmatic file editing\n * Note: This client requires Node.js for file operations\n *\n * @deprecated Prefer the unified `MorphClient` (`new MorphClient({ apiKey }).fastApply`).\n * Standalone clients remain only for backwards compatibility and may be removed in a future\n * major version — do not use them in new code.\n */\nexport class FastApplyClient extends APIResource {\n private config: EditFileConfig;\n\n constructor(clientOrConfig: MorphAPIClient | { apiKey?: string; debug?: boolean; timeout?: number; retryConfig?: any } = {}) {\n const isClient = clientOrConfig instanceof MorphAPIClient;\n super(\n isClient\n ? clientOrConfig\n : new MorphAPIClient({\n apiKey: clientOrConfig.apiKey,\n timeout: clientOrConfig.timeout ?? DEFAULT_CONFIG.timeout,\n retryConfig: clientOrConfig.retryConfig,\n debug: clientOrConfig.debug,\n }),\n );\n // FastApply talks to /v1/chat/completions through the `openai` package, but\n // sources its credentials and host from the shared transport.\n this.config = {\n morphApiKey: this._client.resolveApiKey(),\n morphApiUrl: this._client.baseURL,\n debug: this._client.debug,\n timeout: (isClient ? undefined : clientOrConfig.timeout) ?? DEFAULT_CONFIG.timeout,\n retryConfig: this._client.retryConfig,\n generateUdiff: DEFAULT_CONFIG.generateUdiff,\n autoWrite: DEFAULT_CONFIG.autoWrite,\n };\n }\n\n /**\n * Execute a file edit operation\n *\n * @param input - Edit parameters including filepath, instructions, and code_edit\n * @param overrides - Optional config overrides for this operation\n * @returns Edit result with success status and changes\n */\n async execute(input: EditFileInput, overrides?: Partial<EditFileConfig>): Promise<EditFileResult> {\n return executeEditFile(input, { ...this.config, ...overrides });\n }\n\n /**\n * Apply an edit to code directly without file I/O\n *\n * Useful for sandbox environments or when you manage your own file system.\n * Compatible with the earlier OpenAI client API contract.\n *\n * @param input - Code and edit parameters\n * @param overrides - Optional config overrides for this operation\n * @returns Result with merged code\n *\n * @example\n * ```typescript\n * const result = await client.applyEdit({\n * originalCode: 'function hello() { return \"world\"; }',\n * codeEdit: 'function hello() { return \"universe\"; }',\n * instructions: 'Change return value'\n * });\n * console.log(result.mergedCode);\n * ```\n */\n async applyEdit(input: import('./types.js').ApplyEditInput, overrides?: Partial<import('./types.js').ApplyEditConfig>): Promise<import('./types.js').ApplyEditResult> {\n const { applyEdit } = await import('./apply.js');\n return applyEdit(input, { ...this.config, ...overrides });\n }\n}\n\n/**\n * Execute a file edit using Morph Fast Apply\n * Note: This function requires Node.js for file I/O\n */\nexport async function executeEditFile(\n input: EditFileInput,\n config: EditFileConfig = {}\n): Promise<EditFileResult> {\n const baseDir = config.baseDir || DEFAULT_CONFIG.baseDir;\n const fullPath = resolve(join(baseDir, input.target_filepath));\n\n logger.debug('FastApply', 'execute_start', { target_filepath: input.target_filepath, baseDir, autoWrite: config.autoWrite !== false });\n\n // Security: ensure file is within baseDir\n const relativePath = relative(baseDir, fullPath);\n if (relativePath.startsWith('..') || fullPath === baseDir) {\n logger.warn('FastApply', 'security_check_failed', { target_filepath: input.target_filepath, relative: relativePath });\n return {\n success: false,\n filepath: input.target_filepath,\n changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },\n error: `Invalid filepath: '${input.target_filepath}' is outside baseDir`,\n };\n }\n\n logger.debug('FastApply', 'security_check', { resolved: fullPath, relative: relativePath });\n\n try {\n // Dynamic import to avoid loading Node.js fs module at module evaluation time\n const { readFile, writeFile } = await import('fs/promises');\n const { callMorphAPI, generateUdiff, countChanges } = await import('./apply.js');\n\n // Handle both existing and non-existent files\n let originalCode = '';\n let fileExists = true;\n try {\n originalCode = await readFile(fullPath, 'utf-8');\n logger.debug('FastApply', 'file_read', { path: fullPath, exists: true, size_bytes: originalCode.length });\n } catch (error: any) {\n if (error.code !== 'ENOENT') {\n throw error; // Re-throw if it's not a \"file not found\" error\n }\n fileExists = false;\n logger.debug('FastApply', 'file_read', { path: fullPath, exists: false });\n }\n\n const instruction = input.instruction ?? input.instructions ?? '';\n logger.debug('FastApply', 'api_call', { instruction_len: instruction.length, code_edit_len: input.code_edit.length, original_len: originalCode.length });\n\n const { content: mergedCode, completionId } = await callMorphAPI(originalCode, input.code_edit, instruction, input.target_filepath, config);\n\n logger.debug('FastApply', 'api_response', { completion_id: completionId, merged_len: mergedCode.length });\n\n const udiff = config.generateUdiff !== false ? generateUdiff(originalCode, mergedCode, input.target_filepath) : undefined;\n\n if (config.autoWrite !== false) {\n await writeFile(fullPath, mergedCode, 'utf-8');\n logger.debug('FastApply', 'file_write', { path: fullPath, size_bytes: mergedCode.length });\n }\n\n const changes = countChanges(originalCode, mergedCode);\n logger.debug('FastApply', 'changes', { added: changes.linesAdded, removed: changes.linesRemoved, modified: changes.linesModified });\n\n return {\n success: true,\n filepath: input.target_filepath,\n udiff,\n changes,\n completionId,\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';\n logger.error('FastApply', 'execute_error', { error: errorMessage, target_filepath: input.target_filepath, stack: error instanceof Error ? error.stack : undefined });\n\n return {\n success: false,\n filepath: input.target_filepath,\n changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },\n error: errorMessage,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AAOA,SAAS,MAAM,SAAS,gBAAgB;AAaxC,IAAM,iBAA2H;AAAA,EAC/H,aAAa;AAAA,EACb,SAAS,QAAQ,IAAI;AAAA,EACrB,eAAe;AAAA,EACf,WAAW;AAAA,EACX,SAAS;AAAA,EACT,OAAO;AACT;AAUO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EACvC;AAAA,EAER,YAAY,iBAA6G,CAAC,GAAG;AAC3H,UAAM,WAAW,0BAA0B;AAC3C;AAAA,MACE,WACI,iBACA,IAAI,eAAe;AAAA,QACjB,QAAQ,eAAe;AAAA,QACvB,SAAS,eAAe,WAAW,eAAe;AAAA,QAClD,aAAa,eAAe;AAAA,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W,OAAO,CAAC;AAAA,IAC3F;AAEA,UAAM,UAAUC,cAAa,cAAc,UAAU;AACrD,WAAO,MAAM,aAAa,WAAW,EAAE,OAAO,QAAQ,YAAY,SAAS,QAAQ,cAAc,UAAU,QAAQ,cAAc,CAAC;AAElI,WAAO;AAAA,MACL,SAAS;AAAA,MACT,UAAU,MAAM;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,UAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU;AAC9D,WAAO,MAAM,aAAa,iBAAiB,EAAE,OAAO,cAAc,iBAAiB,MAAM,iBAAiB,OAAO,iBAAiB,QAAQ,MAAM,QAAQ,OAAU,CAAC;AAEnK,WAAO;AAAA,MACL,SAAS;AAAA,MACT,UAAU,MAAM;AAAA,MAChB,SAAS,EAAE,YAAY,GAAG,cAAc,GAAG,eAAe,EAAE;AAAA,MAC5D,OAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["applyEdit","callMorphAPI","generateUdiff","countChanges"]}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MorphAPIClient
|
|
3
|
+
} from "./chunk-QE3SPHIM.js";
|
|
4
|
+
import {
|
|
5
|
+
logger
|
|
6
|
+
} from "./chunk-F3NCFNUX.js";
|
|
7
|
+
import {
|
|
8
|
+
MorphError
|
|
9
|
+
} from "./chunk-JXJBF6CV.js";
|
|
10
|
+
import {
|
|
11
|
+
APIResource
|
|
12
|
+
} from "./chunk-LKFZBBTD.js";
|
|
13
|
+
|
|
14
|
+
// modelrouter/core.ts
|
|
15
|
+
var DEFAULT_API_URL = "https://api.morphllm.com";
|
|
16
|
+
var DEFAULT_TIMEOUT = 5e3;
|
|
17
|
+
function resolveClient(clientOrConfig) {
|
|
18
|
+
if (clientOrConfig instanceof MorphAPIClient) return clientOrConfig;
|
|
19
|
+
return new MorphAPIClient({
|
|
20
|
+
apiKey: clientOrConfig.apiKey,
|
|
21
|
+
baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL,
|
|
22
|
+
timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,
|
|
23
|
+
retryConfig: clientOrConfig.retryConfig,
|
|
24
|
+
debug: clientOrConfig.debug
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
var BaseRouter = class extends APIResource {
|
|
28
|
+
provider;
|
|
29
|
+
timeout;
|
|
30
|
+
constructor(provider, clientOrConfig = {}) {
|
|
31
|
+
super(resolveClient(clientOrConfig));
|
|
32
|
+
this.provider = provider;
|
|
33
|
+
const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;
|
|
34
|
+
this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT;
|
|
35
|
+
}
|
|
36
|
+
/** Throw the historical "API key is required" message when no key is resolvable. */
|
|
37
|
+
requireApiKey() {
|
|
38
|
+
if (!this._client.resolveApiKey()) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
"Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config."
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** POST to the router and surface failures as `Router API error (<status>): ...`. */
|
|
45
|
+
async route(provider, input) {
|
|
46
|
+
try {
|
|
47
|
+
return await this._client.post(`/v1/router/${provider}`, {
|
|
48
|
+
body: { input: input.input, mode: input.mode || "balanced" },
|
|
49
|
+
timeout: this.timeout
|
|
50
|
+
});
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (error instanceof MorphError) {
|
|
53
|
+
throw new Error(`Router API error (${error.statusCode}): ${error.message}`);
|
|
54
|
+
}
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Select the optimal model for a given input and mode
|
|
60
|
+
*/
|
|
61
|
+
async selectModel(input) {
|
|
62
|
+
this.requireApiKey();
|
|
63
|
+
logger.debug("ModelRouter", "request", { provider: this.provider, mode: input.mode || "balanced" });
|
|
64
|
+
const apiResult = await this.route(this.provider, input);
|
|
65
|
+
logger.debug("ModelRouter", "selected", { provider: this.provider, model: apiResult.model });
|
|
66
|
+
return { model: apiResult.model };
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var OpenAIRouter = class extends BaseRouter {
|
|
70
|
+
constructor(clientOrConfig = {}) {
|
|
71
|
+
super("openai", clientOrConfig);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Select optimal GPT-5 model
|
|
75
|
+
*
|
|
76
|
+
* @param input - User input and mode
|
|
77
|
+
* @returns Selected model name (gpt-5-mini | gpt-5-low | gpt-5-medium | gpt-5-high)
|
|
78
|
+
*/
|
|
79
|
+
async selectModel(input) {
|
|
80
|
+
return super.selectModel(input);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var AnthropicRouter = class extends BaseRouter {
|
|
84
|
+
constructor(clientOrConfig = {}) {
|
|
85
|
+
super("anthropic", clientOrConfig);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Select optimal Claude model
|
|
89
|
+
*
|
|
90
|
+
* @param input - User input and mode
|
|
91
|
+
* @returns Selected model name (claude-4.5-haiku | claude-4.5-sonnet)
|
|
92
|
+
*/
|
|
93
|
+
async selectModel(input) {
|
|
94
|
+
return super.selectModel(input);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var GeminiRouter = class extends BaseRouter {
|
|
98
|
+
constructor(clientOrConfig = {}) {
|
|
99
|
+
super("gemini", clientOrConfig);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Select optimal Gemini model
|
|
103
|
+
*
|
|
104
|
+
* @param input - User input and mode
|
|
105
|
+
* @returns Selected model name (gemini-2.5-flash | gemini-2.5-pro)
|
|
106
|
+
*/
|
|
107
|
+
async selectModel(input) {
|
|
108
|
+
return super.selectModel(input);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var RawRouter = class extends BaseRouter {
|
|
112
|
+
constructor(clientOrConfig = {}) {
|
|
113
|
+
super("raw", clientOrConfig);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get raw difficulty classification
|
|
117
|
+
*
|
|
118
|
+
* @param input - User input and mode
|
|
119
|
+
* @returns Raw difficulty (easy | medium | hard | needs_info)
|
|
120
|
+
*/
|
|
121
|
+
async classify(input) {
|
|
122
|
+
this.requireApiKey();
|
|
123
|
+
logger.debug("RawRouter", "request", { mode: input.mode || "balanced" });
|
|
124
|
+
const apiResult = await this.route("raw", input);
|
|
125
|
+
let difficulty;
|
|
126
|
+
if (apiResult.difficulty === "") {
|
|
127
|
+
difficulty = "medium";
|
|
128
|
+
} else {
|
|
129
|
+
difficulty = apiResult.difficulty || apiResult.model;
|
|
130
|
+
}
|
|
131
|
+
logger.debug("RawRouter", "classified", { difficulty });
|
|
132
|
+
return { difficulty };
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export {
|
|
137
|
+
OpenAIRouter,
|
|
138
|
+
AnthropicRouter,
|
|
139
|
+
GeminiRouter,
|
|
140
|
+
RawRouter
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=chunk-SM3OQZRS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../modelrouter/core.ts"],"sourcesContent":["/**\n * Core implementation for intelligent model routing.\n *\n * Routers are thin resources over the shared `MorphAPIClient` transport: they\n * POST to `/v1/router/<provider>` and map the response. Auth, retries, timeouts,\n * and the SDK-version header all live in the transport.\n */\nimport { MorphAPIClient } from '../core/client.js';\nimport { APIResource } from '../core/resource.js';\nimport { MorphError } from '../tools/utils/resilience.js';\nimport { logger } from '../logger.js';\nimport type {\n RouterConfig,\n RouterInput,\n RouterResult,\n RawRouterResult,\n ComplexityLevel,\n Provider,\n} from './types.js';\n\nconst DEFAULT_API_URL = 'https://api.morphllm.com';\nconst DEFAULT_TIMEOUT = 5000; // 5 seconds (responses typically <500ms)\n\nfunction resolveClient(clientOrConfig: MorphAPIClient | RouterConfig): MorphAPIClient {\n if (clientOrConfig instanceof MorphAPIClient) return clientOrConfig;\n return new MorphAPIClient({\n apiKey: clientOrConfig.apiKey,\n baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL,\n timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,\n retryConfig: clientOrConfig.retryConfig,\n debug: clientOrConfig.debug,\n });\n}\n\nabstract class BaseRouter extends APIResource {\n protected provider: Provider;\n protected timeout: number;\n\n constructor(provider: Provider, clientOrConfig: MorphAPIClient | RouterConfig = {}) {\n super(resolveClient(clientOrConfig));\n this.provider = provider;\n const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;\n this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT;\n }\n\n /** Throw the historical \"API key is required\" message when no key is resolvable. */\n protected requireApiKey(): void {\n if (!this._client.resolveApiKey()) {\n throw new Error(\n 'Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config.',\n );\n }\n }\n\n /** POST to the router and surface failures as `Router API error (<status>): ...`. */\n protected async route<T>(provider: string, input: RouterInput): Promise<T> {\n try {\n return await this._client.post<T>(`/v1/router/${provider}`, {\n body: { input: input.input, mode: input.mode || 'balanced' },\n timeout: this.timeout,\n });\n } catch (error) {\n if (error instanceof MorphError) {\n throw new Error(`Router API error (${error.statusCode}): ${error.message}`);\n }\n throw error;\n }\n }\n\n /**\n * Select the optimal model for a given input and mode\n */\n async selectModel(input: RouterInput): Promise<RouterResult> {\n this.requireApiKey();\n logger.debug('ModelRouter', 'request', { provider: this.provider, mode: input.mode || 'balanced' });\n const apiResult = await this.route<{ model: string; confidence?: number }>(this.provider, input);\n logger.debug('ModelRouter', 'selected', { provider: this.provider, model: apiResult.model });\n return { model: apiResult.model };\n }\n}\n\n/**\n * OpenAI model router for GPT-5 series\n *\n * @deprecated Prefer `MorphClient` (`new MorphClient({ apiKey }).routers.openai`). In edge\n * runtimes where `MorphClient` is unavailable, pass a shared transport:\n * `new OpenAIRouter(new MorphAPIClient({ apiKey }))`. Kept only for backwards compatibility.\n */\nexport class OpenAIRouter extends BaseRouter {\n constructor(clientOrConfig: MorphAPIClient | RouterConfig = {}) {\n super('openai', clientOrConfig);\n }\n\n /**\n * Select optimal GPT-5 model\n *\n * @param input - User input and mode\n * @returns Selected model name (gpt-5-mini | gpt-5-low | gpt-5-medium | gpt-5-high)\n */\n async selectModel(input: RouterInput): Promise<RouterResult> {\n return super.selectModel(input);\n }\n}\n\n/**\n * Anthropic model router for Claude 4.5 series\n *\n * @deprecated Prefer `MorphClient` (`new MorphClient({ apiKey }).routers.anthropic`). In edge\n * runtimes where `MorphClient` is unavailable, pass a shared transport:\n * `new AnthropicRouter(new MorphAPIClient({ apiKey }))`. Kept only for backwards compatibility.\n */\nexport class AnthropicRouter extends BaseRouter {\n constructor(clientOrConfig: MorphAPIClient | RouterConfig = {}) {\n super('anthropic', clientOrConfig);\n }\n\n /**\n * Select optimal Claude model\n *\n * @param input - User input and mode\n * @returns Selected model name (claude-4.5-haiku | claude-4.5-sonnet)\n */\n async selectModel(input: RouterInput): Promise<RouterResult> {\n return super.selectModel(input);\n }\n}\n\n/**\n * Google Gemini model router\n *\n * @deprecated Prefer `MorphClient` (`new MorphClient({ apiKey }).routers.gemini`). In edge\n * runtimes where `MorphClient` is unavailable, pass a shared transport:\n * `new GeminiRouter(new MorphAPIClient({ apiKey }))`. Kept only for backwards compatibility.\n */\nexport class GeminiRouter extends BaseRouter {\n constructor(clientOrConfig: MorphAPIClient | RouterConfig = {}) {\n super('gemini', clientOrConfig);\n }\n\n /**\n * Select optimal Gemini model\n *\n * @param input - User input and mode\n * @returns Selected model name (gemini-2.5-flash | gemini-2.5-pro)\n */\n async selectModel(input: RouterInput): Promise<RouterResult> {\n return super.selectModel(input);\n }\n}\n\n/**\n * Raw difficulty classification router (no provider-specific mapping)\n *\n * @deprecated Prefer `MorphClient` (`new MorphClient({ apiKey }).routers.raw`). In edge\n * runtimes where `MorphClient` is unavailable, pass a shared transport:\n * `new RawRouter(new MorphAPIClient({ apiKey }))`. Kept only for backwards compatibility.\n */\nexport class RawRouter extends BaseRouter {\n constructor(clientOrConfig: MorphAPIClient | RouterConfig = {}) {\n super('raw' as Provider, clientOrConfig);\n }\n\n /**\n * Get raw difficulty classification\n *\n * @param input - User input and mode\n * @returns Raw difficulty (easy | medium | hard | needs_info)\n */\n async classify(input: RouterInput): Promise<RawRouterResult> {\n this.requireApiKey();\n logger.debug('RawRouter', 'request', { mode: input.mode || 'balanced' });\n\n const apiResult = await this.route<{ model?: string; difficulty?: string; confidence?: number }>('raw', input);\n\n // Support both 'model' and 'difficulty' fields for compatibility.\n // Empty string from API means \"medium\" difficulty (API bug workaround).\n let difficulty: ComplexityLevel;\n if (apiResult.difficulty === '') {\n difficulty = 'medium';\n } else {\n difficulty = (apiResult.difficulty || apiResult.model) as ComplexityLevel;\n }\n\n logger.debug('RawRouter', 'classified', { difficulty });\n return { difficulty };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AAExB,SAAS,cAAc,gBAA+D;AACpF,MAAI,0BAA0B,eAAgB,QAAO;AACrD,SAAO,IAAI,eAAe;AAAA,IACxB,QAAQ,eAAe;AAAA,IACvB,SAAS,eAAe,UAAU;AAAA,IAClC,SAAS,eAAe,WAAW;AAAA,IACnC,aAAa,eAAe;AAAA,IAC5B,OAAO,eAAe;AAAA,EACxB,CAAC;AACH;AAEA,IAAe,aAAf,cAAkC,YAAY;AAAA,EAClC;AAAA,EACA;AAAA,EAEV,YAAY,UAAoB,iBAAgD,CAAC,GAAG;AAClF,UAAM,cAAc,cAAc,CAAC;AACnC,SAAK,WAAW;AAChB,UAAM,MAAM,0BAA0B,iBAAiB,CAAC,IAAI;AAC5D,SAAK,UAAU,IAAI,WAAW;AAAA,EAChC;AAAA;AAAA,EAGU,gBAAsB;AAC9B,QAAI,CAAC,KAAK,QAAQ,cAAc,GAAG;AACj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