@morphllm/morphsdk 0.2.171 → 0.2.172
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-3XRNC56L.js → chunk-2SNAXTUJ.js} +4 -4
- package/dist/chunk-453ZV2AX.js +120 -0
- package/dist/chunk-453ZV2AX.js.map +1 -0
- package/dist/chunk-53ZJMCWU.js +142 -0
- package/dist/chunk-53ZJMCWU.js.map +1 -0
- package/dist/{chunk-IW4TYYG6.js → chunk-5DA6SZQJ.js} +2 -2
- package/dist/chunk-66OHYI24.js +78 -0
- package/dist/chunk-66OHYI24.js.map +1 -0
- package/dist/chunk-6X6QMRQG.js +158 -0
- package/dist/chunk-6X6QMRQG.js.map +1 -0
- package/dist/{chunk-C37YAYBK.js → chunk-7PVVPLRL.js} +2 -2
- package/dist/{chunk-MZZMSL26.js → chunk-AE7M2I52.js} +2 -2
- package/dist/{chunk-JLLIVBKY.js → chunk-CQF76HJC.js} +30 -6
- package/dist/chunk-CQF76HJC.js.map +1 -0
- package/dist/{chunk-EFCDIESP.js → chunk-ESXCQBMU.js} +2 -2
- package/dist/{chunk-FQJCE2FX.js → chunk-FOIDGIY4.js} +29 -10
- package/dist/chunk-FOIDGIY4.js.map +1 -0
- package/dist/{chunk-JEDEBCZM.js → chunk-GJZXDRH5.js} +8 -3
- package/dist/{chunk-JEDEBCZM.js.map → chunk-GJZXDRH5.js.map} +1 -1
- package/dist/{chunk-2ALTBYMY.js → chunk-IJ33I7P5.js} +4 -4
- package/dist/{chunk-UK7TI7QY.js → chunk-IN2U7AAI.js} +99 -143
- package/dist/chunk-IN2U7AAI.js.map +1 -0
- package/dist/{chunk-LE66XCOI.js → chunk-JWZ5DLAS.js} +27 -10
- package/dist/chunk-JWZ5DLAS.js.map +1 -0
- package/dist/chunk-LKFZBBTD.js +12 -0
- package/dist/chunk-LKFZBBTD.js.map +1 -0
- package/dist/{chunk-TAS6S42A.js → chunk-MO6S2LRD.js} +2 -2
- package/dist/{chunk-2OAKX4SZ.js → chunk-NI7PWQ3B.js} +4 -4
- package/dist/{chunk-GLQWEINZ.js → chunk-QAXXE4AD.js} +2 -2
- package/dist/{chunk-3BCKZKNK.js → chunk-QFE5523Q.js} +2 -2
- package/dist/{chunk-LL3EWDKD.js → chunk-QQXNZIVK.js} +4 -4
- package/dist/{chunk-IGQYZ2KH.js → chunk-QZ3V2BP7.js} +2 -2
- package/dist/chunk-QZR7SJ5N.js +24 -0
- package/dist/chunk-QZR7SJ5N.js.map +1 -0
- package/dist/{chunk-SW527EQT.js → chunk-SJVLAGUL.js} +4 -4
- package/dist/{chunk-CMFY26F3.js → chunk-U4J3BVAQ.js} +4 -4
- package/dist/{chunk-5EUMJI3I.js → chunk-U4MRSZQQ.js} +2 -2
- package/dist/{chunk-ZJQTTOHO.js → chunk-UADW6FYD.js} +2 -2
- package/dist/{chunk-4324ZSCW.js → chunk-VBARKJWL.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-Y6T4NA75.js → chunk-XJDXV5VX.js} +2 -2
- package/dist/{chunk-JTUB5ZCT.js → chunk-XYTYIAMQ.js} +2 -2
- package/dist/{chunk-4MTZUTNH.js → chunk-Z4GJVN52.js} +23 -8
- package/dist/chunk-Z4GJVN52.js.map +1 -0
- package/dist/chunk-ZLSNL6M2.js +97 -0
- package/dist/chunk-ZLSNL6M2.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 +113 -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-3XRNC56L.js.map → chunk-2SNAXTUJ.js.map} +0 -0
- /package/dist/{chunk-IW4TYYG6.js.map → chunk-5DA6SZQJ.js.map} +0 -0
- /package/dist/{chunk-C37YAYBK.js.map → chunk-7PVVPLRL.js.map} +0 -0
- /package/dist/{chunk-MZZMSL26.js.map → chunk-AE7M2I52.js.map} +0 -0
- /package/dist/{chunk-EFCDIESP.js.map → chunk-ESXCQBMU.js.map} +0 -0
- /package/dist/{chunk-2ALTBYMY.js.map → chunk-IJ33I7P5.js.map} +0 -0
- /package/dist/{chunk-TAS6S42A.js.map → chunk-MO6S2LRD.js.map} +0 -0
- /package/dist/{chunk-2OAKX4SZ.js.map → chunk-NI7PWQ3B.js.map} +0 -0
- /package/dist/{chunk-GLQWEINZ.js.map → chunk-QAXXE4AD.js.map} +0 -0
- /package/dist/{chunk-3BCKZKNK.js.map → chunk-QFE5523Q.js.map} +0 -0
- /package/dist/{chunk-LL3EWDKD.js.map → chunk-QQXNZIVK.js.map} +0 -0
- /package/dist/{chunk-IGQYZ2KH.js.map → chunk-QZ3V2BP7.js.map} +0 -0
- /package/dist/{chunk-SW527EQT.js.map → chunk-SJVLAGUL.js.map} +0 -0
- /package/dist/{chunk-CMFY26F3.js.map → chunk-U4J3BVAQ.js.map} +0 -0
- /package/dist/{chunk-5EUMJI3I.js.map → chunk-U4MRSZQQ.js.map} +0 -0
- /package/dist/{chunk-ZJQTTOHO.js.map → chunk-UADW6FYD.js.map} +0 -0
- /package/dist/{chunk-4324ZSCW.js.map → chunk-VBARKJWL.js.map} +0 -0
- /package/dist/{chunk-OPNTDMHH.js.map → chunk-VLZ6PNAD.js.map} +0 -0
- /package/dist/{chunk-Y6T4NA75.js.map → chunk-XJDXV5VX.js.map} +0 -0
- /package/dist/{chunk-JTUB5ZCT.js.map → chunk-XYTYIAMQ.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { SDK_VERSION } from './version.js';
|
|
2
|
-
export { A as AnthropicToolFactory, f as CheckRun, C as Comment, m as CreateCheckRunInput, k as CreateCommentInput, r as CreateProjectInput, l as DeleteCommentInput, D as Deployment, F as FileChange, h as GetPullRequestInput, G as GitHubClient, b as GitHubClientConfig, u as GitHubError, I as Installation, j as ListCommentsInput, i as ListDeploymentsInput, t as ListProjectsInput, g as ListPullRequestsInput, L as ListReposInput, M as MorphClient, a as MorphClientConfig, N as NoInstallationError, v as NotFoundError, O as OpenAIToolFactory, w as PermissionError, P as Project, d as PullRequest, e as PullRequestWithContext, R as Repo, c as RepoConfig, S as SiteAuth, q as SyncReposInput, n as UpdateCheckRunInput, U as UpdateCommentInput, o as UpdateInstallationInput, s as UpdateProjectInput, p as UpdateRepoInput, V as VercelToolFactory } from './client-
|
|
2
|
+
export { A as AnthropicToolFactory, f as CheckRun, C as Comment, m as CreateCheckRunInput, k as CreateCommentInput, r as CreateProjectInput, l as DeleteCommentInput, D as Deployment, F as FileChange, h as GetPullRequestInput, G as GitHubClient, b as GitHubClientConfig, u as GitHubError, I as Installation, j as ListCommentsInput, i as ListDeploymentsInput, t as ListProjectsInput, g as ListPullRequestsInput, L as ListReposInput, M as MorphClient, a as MorphClientConfig, N as NoInstallationError, v as NotFoundError, O as OpenAIToolFactory, w as PermissionError, P as Project, d as PullRequest, e as PullRequestWithContext, R as Repo, c as RepoConfig, S as SiteAuth, q as SyncReposInput, n as UpdateCheckRunInput, U as UpdateCommentInput, o as UpdateInstallationInput, s as UpdateProjectInput, p as UpdateRepoInput, V as VercelToolFactory } from './client-Dh6yzCm4.js';
|
|
3
|
+
export { MorphAPIClient, MorphAPIClientOptions, RequestOptions } from './core/client.js';
|
|
4
|
+
export { APIResource } from './core/resource.js';
|
|
5
|
+
export { RetryConfig } from './tools/utils/resilience.js';
|
|
3
6
|
export { FastApplyClient } from './tools/fastapply/core.js';
|
|
4
7
|
export { CodebaseSearchClient } from './tools/codebase_search/core.js';
|
|
5
8
|
export { WarpGrepClient } from './tools/warp_grep/client.js';
|
|
@@ -8,6 +11,8 @@ export { MorphGit } from './git/client.js';
|
|
|
8
11
|
export { MorphGitConfig } from './git/types.js';
|
|
9
12
|
export { CompactClient } from './tools/compact/core.js';
|
|
10
13
|
export { CompactConfig, CompactInput, CompactMessage, CompactResult, CompactedRange } from './tools/compact/types.js';
|
|
14
|
+
export { ReflexClient, ReflexJobsResource } from './tools/reflex/core.js';
|
|
15
|
+
export { CreateReflexJobInput, DeletedReflexJob, ListReflexJobsInput, ReflexConfig, ReflexEvent, ReflexJob, ReflexJobList, ReflexJobStatus, ReflexPredictInput, ReflexPredictResult, TrainingExample } from './tools/reflex/types.js';
|
|
11
16
|
export { W as WarpGrepClientConfig, c as WarpGrepContext, a as WarpGrepInput, b as WarpGrepResult, d as WarpGrepToolConfig } from './types-CtkD4o1_.js';
|
|
12
17
|
export { GrepResult, ListDirectoryEntry, ReadResult, WarpGrepProvider } from './tools/warp_grep/providers/types.js';
|
|
13
18
|
export { LocalRipgrepProvider } from './tools/warp_grep/providers/local.js';
|
|
@@ -17,7 +22,6 @@ export { ApplyEditConfig, ApplyEditInput, ApplyEditResult, EditChanges, EditFile
|
|
|
17
22
|
export { CodeSearchResult, CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult, SearchStats } from './tools/codebase_search/types.js';
|
|
18
23
|
export { BrowserConfig, BrowserError, BrowserModel, BrowserTaskInput, BrowserTaskInputWithSchema, BrowserTaskResult, BrowserTaskWithPromise, BrowserTaskWithPromiseAndSchema, ErrorsResponse, IframeOptions, LiveSessionOptions, RecordingStatus } from './tools/browser/types.js';
|
|
19
24
|
export { ComplexityLevel, Provider, RawRouterResult, RouterConfig, RouterInput, RouterMode, RouterResult } from './modelrouter/types.js';
|
|
20
|
-
export { RetryConfig } from './tools/utils/resilience.js';
|
|
21
25
|
export { ExploreEvent, ExploreResult, ExploreSession, ExploreStep, ExploreSubagentConfig, ExploreThoroughness, SubagentMessage } from './subagents/types.js';
|
|
22
26
|
export { applyEdit } from './tools/fastapply/apply.js';
|
|
23
27
|
import 'openai/resources/index.mjs';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "./chunk-HYRHI2UL.js";
|
|
2
|
-
import "./chunk-QRXG5CAZ.js";
|
|
3
2
|
import {
|
|
4
3
|
LocalRipgrepProvider
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-G2RSY56Q.js";
|
|
4
|
+
} from "./chunk-VLZ6PNAD.js";
|
|
7
5
|
import "./chunk-YPKNMYD4.js";
|
|
8
6
|
import "./chunk-TPP2UGQP.js";
|
|
7
|
+
import "./chunk-G2RSY56Q.js";
|
|
8
|
+
import "./chunk-QRXG5CAZ.js";
|
|
9
9
|
import {
|
|
10
10
|
AnthropicToolFactory,
|
|
11
11
|
GitHubClient,
|
|
@@ -16,69 +16,82 @@ import {
|
|
|
16
16
|
OpenAIToolFactory,
|
|
17
17
|
PermissionError,
|
|
18
18
|
VercelToolFactory
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import
|
|
19
|
+
} from "./chunk-IN2U7AAI.js";
|
|
20
|
+
import "./chunk-U4MRSZQQ.js";
|
|
21
|
+
import "./chunk-MO6S2LRD.js";
|
|
22
|
+
import {
|
|
23
|
+
ReflexClient,
|
|
24
|
+
ReflexJobsResource
|
|
25
|
+
} from "./chunk-6X6QMRQG.js";
|
|
26
|
+
import "./chunk-5DA6SZQJ.js";
|
|
23
27
|
import "./chunk-Q6QCHAMD.js";
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-SJVLAGUL.js";
|
|
29
|
+
import "./chunk-2SNAXTUJ.js";
|
|
30
|
+
import "./chunk-IJ33I7P5.js";
|
|
31
|
+
import "./chunk-YQMPVJ2L.js";
|
|
27
32
|
import {
|
|
28
33
|
CodebaseSearchClient
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
import "./chunk-
|
|
31
|
-
import "./chunk-
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import "./chunk-
|
|
34
|
-
import "./chunk-63WE2C5R.js";
|
|
34
|
+
} from "./chunk-ZLSNL6M2.js";
|
|
35
|
+
import "./chunk-QZ3V2BP7.js";
|
|
36
|
+
import "./chunk-QQXNZIVK.js";
|
|
37
|
+
import "./chunk-U4J3BVAQ.js";
|
|
38
|
+
import "./chunk-NI7PWQ3B.js";
|
|
35
39
|
import {
|
|
36
40
|
FastApplyClient
|
|
37
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-Z4GJVN52.js";
|
|
42
|
+
import "./chunk-63WE2C5R.js";
|
|
38
43
|
import {
|
|
39
44
|
BrowserClient
|
|
40
|
-
} from "./chunk-
|
|
41
|
-
import "./chunk-
|
|
45
|
+
} from "./chunk-FOIDGIY4.js";
|
|
46
|
+
import "./chunk-VBARKJWL.js";
|
|
42
47
|
import "./chunk-2AMEQAO2.js";
|
|
43
|
-
import "./chunk-2VERUKO2.js";
|
|
44
48
|
import "./chunk-YTYCHRQ2.js";
|
|
45
|
-
import "./chunk-
|
|
46
|
-
import "./chunk-
|
|
49
|
+
import "./chunk-2VERUKO2.js";
|
|
50
|
+
import "./chunk-GZMUGMOZ.js";
|
|
51
|
+
import {
|
|
52
|
+
MorphGit
|
|
53
|
+
} from "./chunk-JWZ5DLAS.js";
|
|
54
|
+
import "./chunk-AE7M2I52.js";
|
|
47
55
|
import {
|
|
48
56
|
WarpGrepClient
|
|
49
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-CQF76HJC.js";
|
|
50
58
|
import "./chunk-63VHBANJ.js";
|
|
51
|
-
import "./chunk-
|
|
59
|
+
import "./chunk-7PVVPLRL.js";
|
|
52
60
|
import "./chunk-GVGJIXV2.js";
|
|
53
61
|
import "./chunk-A4D2CIIT.js";
|
|
54
62
|
import "./chunk-IA5K2HTC.js";
|
|
55
63
|
import "./chunk-FBRNUWEB.js";
|
|
56
64
|
import "./chunk-CCJK3HTG.js";
|
|
57
|
-
import "./chunk-
|
|
65
|
+
import "./chunk-QAXXE4AD.js";
|
|
58
66
|
import "./chunk-ZZ25FZG2.js";
|
|
59
67
|
import {
|
|
60
68
|
applyEdit
|
|
61
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-QFE5523Q.js";
|
|
62
70
|
import {
|
|
63
71
|
AnthropicRouter,
|
|
64
72
|
GeminiRouter,
|
|
65
73
|
OpenAIRouter,
|
|
66
74
|
RawRouter
|
|
67
|
-
} from "./chunk-
|
|
68
|
-
import "./chunk-JTUB5ZCT.js";
|
|
75
|
+
} from "./chunk-53ZJMCWU.js";
|
|
69
76
|
import {
|
|
70
77
|
CompactClient
|
|
71
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-66OHYI24.js";
|
|
79
|
+
import "./chunk-VZ7BOH2K.js";
|
|
80
|
+
import {
|
|
81
|
+
MorphAPIClient
|
|
82
|
+
} from "./chunk-453ZV2AX.js";
|
|
72
83
|
import "./chunk-F3NCFNUX.js";
|
|
84
|
+
import "./chunk-QZR7SJ5N.js";
|
|
85
|
+
import "./chunk-XYTYIAMQ.js";
|
|
73
86
|
import {
|
|
74
87
|
SDK_VERSION
|
|
75
|
-
} from "./chunk-
|
|
76
|
-
import "./chunk-GZMUGMOZ.js";
|
|
88
|
+
} from "./chunk-GJZXDRH5.js";
|
|
77
89
|
import {
|
|
78
|
-
|
|
79
|
-
} from "./chunk-
|
|
90
|
+
APIResource
|
|
91
|
+
} from "./chunk-LKFZBBTD.js";
|
|
80
92
|
import "./chunk-PZ5AY32C.js";
|
|
81
93
|
export {
|
|
94
|
+
APIResource,
|
|
82
95
|
AnthropicRouter,
|
|
83
96
|
AnthropicToolFactory,
|
|
84
97
|
BrowserClient,
|
|
@@ -89,6 +102,7 @@ export {
|
|
|
89
102
|
GitHubClient,
|
|
90
103
|
GitHubError,
|
|
91
104
|
LocalRipgrepProvider,
|
|
105
|
+
MorphAPIClient,
|
|
92
106
|
MorphClient,
|
|
93
107
|
MorphGit,
|
|
94
108
|
NoInstallationError,
|
|
@@ -97,6 +111,8 @@ export {
|
|
|
97
111
|
OpenAIToolFactory,
|
|
98
112
|
PermissionError,
|
|
99
113
|
RawRouter,
|
|
114
|
+
ReflexClient,
|
|
115
|
+
ReflexJobsResource,
|
|
100
116
|
SDK_VERSION,
|
|
101
117
|
VercelToolFactory,
|
|
102
118
|
WarpGrepClient,
|
|
@@ -40,7 +40,7 @@ module.exports = __toCommonJS(core_exports);
|
|
|
40
40
|
// package.json
|
|
41
41
|
var package_default = {
|
|
42
42
|
name: "@morphllm/morphsdk",
|
|
43
|
-
version: "0.2.
|
|
43
|
+
version: "0.2.172",
|
|
44
44
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
45
45
|
type: "module",
|
|
46
46
|
main: "./dist/index.cjs",
|
|
@@ -177,6 +177,11 @@ var package_default = {
|
|
|
177
177
|
import: "./dist/tools/compact/index.js",
|
|
178
178
|
require: "./dist/tools/compact/index.cjs"
|
|
179
179
|
},
|
|
180
|
+
"./tools/reflex": {
|
|
181
|
+
types: "./dist/tools/reflex/index.d.ts",
|
|
182
|
+
import: "./dist/tools/reflex/index.js",
|
|
183
|
+
require: "./dist/tools/reflex/index.cjs"
|
|
184
|
+
},
|
|
180
185
|
"./subagents": {
|
|
181
186
|
types: "./dist/subagents/index.d.ts",
|
|
182
187
|
import: "./dist/subagents/index.js",
|
|
@@ -202,7 +207,7 @@ var package_default = {
|
|
|
202
207
|
"!dist/**/*.test.*"
|
|
203
208
|
],
|
|
204
209
|
scripts: {
|
|
205
|
-
build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts subagents/index.ts subagents/types.ts subagents/prompts.ts subagents/vercel.ts subagents/anthropic.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
|
|
210
|
+
build: "tsup version.ts index.ts edge.ts client.ts core/index.ts core/client.ts core/resource.ts core/error.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/reflex/index.ts tools/reflex/core.ts tools/reflex/types.ts tools/utils/resilience.ts subagents/index.ts subagents/types.ts subagents/prompts.ts subagents/vercel.ts subagents/anthropic.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
|
|
206
211
|
prepare: "npm run build",
|
|
207
212
|
typecheck: "tsc --noEmit",
|
|
208
213
|
lint: "eslint .",
|
|
@@ -358,6 +363,15 @@ async function withTimeout(promise, timeoutMs, errorMessage) {
|
|
|
358
363
|
function sleep(ms) {
|
|
359
364
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
360
365
|
}
|
|
366
|
+
var MorphError = class extends Error {
|
|
367
|
+
constructor(message, code, statusCode, retryable = false) {
|
|
368
|
+
super(message);
|
|
369
|
+
this.code = code;
|
|
370
|
+
this.statusCode = statusCode;
|
|
371
|
+
this.retryable = retryable;
|
|
372
|
+
this.name = "MorphError";
|
|
373
|
+
}
|
|
374
|
+
};
|
|
361
375
|
|
|
362
376
|
// logger.ts
|
|
363
377
|
var MorphLogger = class {
|
|
@@ -406,86 +420,193 @@ var MorphLogger = class {
|
|
|
406
420
|
};
|
|
407
421
|
var logger = new MorphLogger();
|
|
408
422
|
|
|
409
|
-
//
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
423
|
+
// core/error.ts
|
|
424
|
+
async function toMorphError(response) {
|
|
425
|
+
let message = `Morph API request failed (${response.status})`;
|
|
426
|
+
let code = "api_error";
|
|
427
|
+
try {
|
|
428
|
+
const body = await response.json();
|
|
429
|
+
message = body.error?.message ?? body.message ?? message;
|
|
430
|
+
code = body.error?.code ?? body.error?.type ?? code;
|
|
431
|
+
} catch {
|
|
432
|
+
}
|
|
433
|
+
if (response.status === 401) code = "authentication_error";
|
|
434
|
+
if (response.status === 429) code = "rate_limit_exceeded";
|
|
435
|
+
const retryable = response.status === 429 || response.status === 503;
|
|
436
|
+
return new MorphError(message, code, response.status, retryable);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// core/client.ts
|
|
440
|
+
var DEFAULT_BASE_URL = "https://api.morphllm.com";
|
|
441
|
+
var DEFAULT_REPOS_URL = "https://repos.morphllm.com";
|
|
442
|
+
var DEFAULT_BROWSER_URL = "https://browser.morphllm.com";
|
|
443
|
+
var DEFAULT_TIMEOUT = 6e4;
|
|
444
|
+
var env = (name) => typeof process !== "undefined" ? process.env?.[name] : void 0;
|
|
445
|
+
var stripTrailingSlash = (url) => url.replace(/\/+$/, "");
|
|
446
|
+
var MorphAPIClient = class {
|
|
447
|
+
/** Explicit key as provided; resolved against env at request time. */
|
|
448
|
+
apiKey;
|
|
449
|
+
baseURL;
|
|
450
|
+
reposURL;
|
|
451
|
+
browserURL;
|
|
452
|
+
/** Explicit default timeout (ms), if set. The request default is applied lazily so
|
|
453
|
+
* resources can read an undefined value and supply their own fallback. */
|
|
454
|
+
timeout;
|
|
455
|
+
retryConfig;
|
|
456
|
+
debug;
|
|
457
|
+
constructor(options = {}) {
|
|
458
|
+
this.apiKey = options.apiKey;
|
|
459
|
+
this.baseURL = stripTrailingSlash(options.baseURL ?? DEFAULT_BASE_URL);
|
|
460
|
+
this.reposURL = stripTrailingSlash(options.reposURL ?? env("MORPH_SEARCH_URL") ?? DEFAULT_REPOS_URL);
|
|
461
|
+
this.browserURL = stripTrailingSlash(
|
|
462
|
+
options.browserURL ?? (env("MORPH_ENVIRONMENT") === "DEV" ? "http://localhost:8000" : DEFAULT_BROWSER_URL)
|
|
463
|
+
);
|
|
464
|
+
this.timeout = options.timeout;
|
|
465
|
+
this.retryConfig = options.retryConfig;
|
|
466
|
+
this.debug = options.debug ?? false;
|
|
467
|
+
if (this.debug) logger.enable();
|
|
468
|
+
}
|
|
469
|
+
/** The key actually used for requests: explicit, else `MORPH_API_KEY`. */
|
|
470
|
+
resolveApiKey() {
|
|
471
|
+
return this.apiKey ?? env("MORPH_API_KEY");
|
|
472
|
+
}
|
|
473
|
+
/** Headers shared with tools that bring their own HTTP client (FastApply/WarpGrep via the `openai` package). */
|
|
474
|
+
defaultHeaders() {
|
|
475
|
+
return { "X-Morph-SDK-Version": SDK_VERSION };
|
|
476
|
+
}
|
|
477
|
+
buildURL(path, baseURL) {
|
|
478
|
+
if (/^https?:\/\//i.test(path)) return path;
|
|
479
|
+
const base = stripTrailingSlash(baseURL ?? this.baseURL);
|
|
480
|
+
return `${base}${path.startsWith("/") ? "" : "/"}${path}`;
|
|
481
|
+
}
|
|
482
|
+
buildHeaders(apiKey, extra) {
|
|
483
|
+
return {
|
|
484
|
+
"Content-Type": "application/json",
|
|
485
|
+
"X-Morph-SDK-Version": SDK_VERSION,
|
|
486
|
+
Authorization: `Bearer ${apiKey}`,
|
|
487
|
+
...extra
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
applyQuery(url, query) {
|
|
491
|
+
if (!query) return url;
|
|
492
|
+
const params = new URLSearchParams();
|
|
493
|
+
for (const [key, value] of Object.entries(query)) {
|
|
494
|
+
if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
495
|
+
}
|
|
496
|
+
const qs = params.toString();
|
|
497
|
+
return qs ? `${url}${url.includes("?") ? "&" : "?"}${qs}` : url;
|
|
498
|
+
}
|
|
499
|
+
async request(method, path, opts = {}) {
|
|
500
|
+
const apiKey = this.resolveApiKey();
|
|
501
|
+
if (!apiKey) {
|
|
502
|
+
throw new MorphError(
|
|
503
|
+
"Morph API key not found. Set the MORPH_API_KEY environment variable or pass apiKey in config.",
|
|
504
|
+
"missing_api_key",
|
|
505
|
+
401
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
const url = this.applyQuery(this.buildURL(path, opts.baseURL), opts.query);
|
|
509
|
+
const timeout = opts.timeout ?? this.timeout ?? DEFAULT_TIMEOUT;
|
|
510
|
+
const init = {
|
|
511
|
+
method,
|
|
512
|
+
headers: this.buildHeaders(apiKey, opts.headers),
|
|
513
|
+
...opts.body !== void 0 ? { body: JSON.stringify(opts.body) } : {},
|
|
514
|
+
...opts.signal ? { signal: opts.signal } : {}
|
|
515
|
+
};
|
|
516
|
+
logger.debug("MorphAPIClient", "request", { method, url });
|
|
517
|
+
const response = await withTimeout(
|
|
518
|
+
fetchWithRetry(url, init, this.retryConfig ?? {}),
|
|
519
|
+
timeout,
|
|
520
|
+
`Morph request to ${url} timed out after ${timeout}ms`
|
|
521
|
+
);
|
|
522
|
+
if (opts.raw) return response;
|
|
523
|
+
if (!response.ok) throw await toMorphError(response);
|
|
524
|
+
if (opts.stream) return response;
|
|
525
|
+
if (response.status === 204) return void 0;
|
|
526
|
+
const text = await response.text();
|
|
527
|
+
return text ? JSON.parse(text) : void 0;
|
|
528
|
+
}
|
|
529
|
+
get(path, opts) {
|
|
530
|
+
return this.request("GET", path, opts);
|
|
531
|
+
}
|
|
532
|
+
post(path, opts) {
|
|
533
|
+
return this.request("POST", path, opts);
|
|
534
|
+
}
|
|
535
|
+
delete(path, opts) {
|
|
536
|
+
return this.request("DELETE", path, opts);
|
|
537
|
+
}
|
|
415
538
|
};
|
|
416
|
-
|
|
417
|
-
|
|
539
|
+
|
|
540
|
+
// core/resource.ts
|
|
541
|
+
var APIResource = class {
|
|
542
|
+
_client;
|
|
543
|
+
constructor(client) {
|
|
544
|
+
this._client = client;
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
// modelrouter/core.ts
|
|
549
|
+
var DEFAULT_API_URL = "https://api.morphllm.com";
|
|
550
|
+
var DEFAULT_TIMEOUT2 = 5e3;
|
|
551
|
+
function resolveClient(clientOrConfig) {
|
|
552
|
+
if (clientOrConfig instanceof MorphAPIClient) return clientOrConfig;
|
|
553
|
+
return new MorphAPIClient({
|
|
554
|
+
apiKey: clientOrConfig.apiKey,
|
|
555
|
+
baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL,
|
|
556
|
+
timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT2,
|
|
557
|
+
retryConfig: clientOrConfig.retryConfig,
|
|
558
|
+
debug: clientOrConfig.debug
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
var BaseRouter = class extends APIResource {
|
|
418
562
|
provider;
|
|
419
|
-
|
|
563
|
+
timeout;
|
|
564
|
+
constructor(provider, clientOrConfig = {}) {
|
|
565
|
+
super(resolveClient(clientOrConfig));
|
|
420
566
|
this.provider = provider;
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
apiUrl: config.apiUrl || DEFAULT_CONFIG.apiUrl,
|
|
424
|
-
timeout: config.timeout || DEFAULT_CONFIG.timeout,
|
|
425
|
-
debug: config.debug || DEFAULT_CONFIG.debug,
|
|
426
|
-
retryConfig: config.retryConfig
|
|
427
|
-
};
|
|
567
|
+
const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;
|
|
568
|
+
this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT2;
|
|
428
569
|
}
|
|
429
|
-
/**
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
async selectModel(input) {
|
|
433
|
-
const mode = input.mode || "balanced";
|
|
434
|
-
const apiKey = this.config.apiKey || (typeof process !== "undefined" ? process.env?.MORPH_API_KEY : void 0);
|
|
435
|
-
if (!apiKey) {
|
|
570
|
+
/** Throw the historical "API key is required" message when no key is resolvable. */
|
|
571
|
+
requireApiKey() {
|
|
572
|
+
if (!this._client.resolveApiKey()) {
|
|
436
573
|
throw new Error(
|
|
437
574
|
"Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config."
|
|
438
575
|
);
|
|
439
576
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
mode
|
|
444
|
-
};
|
|
445
|
-
logger.debug("ModelRouter", "request", { provider: this.provider, mode, input_len: input.input.length, url });
|
|
577
|
+
}
|
|
578
|
+
/** POST to the router and surface failures as `Router API error (<status>): ...`. */
|
|
579
|
+
async route(provider, input) {
|
|
446
580
|
try {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
headers: {
|
|
452
|
-
"Content-Type": "application/json",
|
|
453
|
-
Authorization: `Bearer ${apiKey}`
|
|
454
|
-
},
|
|
455
|
-
body: JSON.stringify(payload)
|
|
456
|
-
},
|
|
457
|
-
this.config.retryConfig
|
|
458
|
-
);
|
|
459
|
-
const response = await withTimeout(
|
|
460
|
-
fetchPromise,
|
|
461
|
-
this.config.timeout,
|
|
462
|
-
`Router API request timed out after ${this.config.timeout}ms`
|
|
463
|
-
);
|
|
464
|
-
if (!response.ok) {
|
|
465
|
-
const errorText = await response.text();
|
|
466
|
-
throw new Error(
|
|
467
|
-
`Router API error (${response.status}): ${errorText || response.statusText}`
|
|
468
|
-
);
|
|
469
|
-
}
|
|
470
|
-
const apiResult = await response.json();
|
|
471
|
-
const result = {
|
|
472
|
-
model: apiResult.model
|
|
473
|
-
};
|
|
474
|
-
logger.debug("ModelRouter", "selected", { provider: this.provider, model: apiResult.model, confidence: apiResult.confidence });
|
|
475
|
-
return result;
|
|
581
|
+
return await this._client.post(`/v1/router/${provider}`, {
|
|
582
|
+
body: { input: input.input, mode: input.mode || "balanced" },
|
|
583
|
+
timeout: this.timeout
|
|
584
|
+
});
|
|
476
585
|
} catch (error) {
|
|
477
|
-
|
|
586
|
+
if (error instanceof MorphError) {
|
|
587
|
+
throw new Error(`Router API error (${error.statusCode}): ${error.message}`);
|
|
588
|
+
}
|
|
478
589
|
throw error;
|
|
479
590
|
}
|
|
480
591
|
}
|
|
592
|
+
/**
|
|
593
|
+
* Select the optimal model for a given input and mode
|
|
594
|
+
*/
|
|
595
|
+
async selectModel(input) {
|
|
596
|
+
this.requireApiKey();
|
|
597
|
+
logger.debug("ModelRouter", "request", { provider: this.provider, mode: input.mode || "balanced" });
|
|
598
|
+
const apiResult = await this.route(this.provider, input);
|
|
599
|
+
logger.debug("ModelRouter", "selected", { provider: this.provider, model: apiResult.model });
|
|
600
|
+
return { model: apiResult.model };
|
|
601
|
+
}
|
|
481
602
|
};
|
|
482
603
|
var OpenAIRouter = class extends BaseRouter {
|
|
483
|
-
constructor(
|
|
484
|
-
super("openai",
|
|
604
|
+
constructor(clientOrConfig = {}) {
|
|
605
|
+
super("openai", clientOrConfig);
|
|
485
606
|
}
|
|
486
607
|
/**
|
|
487
608
|
* Select optimal GPT-5 model
|
|
488
|
-
*
|
|
609
|
+
*
|
|
489
610
|
* @param input - User input and mode
|
|
490
611
|
* @returns Selected model name (gpt-5-mini | gpt-5-low | gpt-5-medium | gpt-5-high)
|
|
491
612
|
*/
|
|
@@ -494,12 +615,12 @@ var OpenAIRouter = class extends BaseRouter {
|
|
|
494
615
|
}
|
|
495
616
|
};
|
|
496
617
|
var AnthropicRouter = class extends BaseRouter {
|
|
497
|
-
constructor(
|
|
498
|
-
super("anthropic",
|
|
618
|
+
constructor(clientOrConfig = {}) {
|
|
619
|
+
super("anthropic", clientOrConfig);
|
|
499
620
|
}
|
|
500
621
|
/**
|
|
501
622
|
* Select optimal Claude model
|
|
502
|
-
*
|
|
623
|
+
*
|
|
503
624
|
* @param input - User input and mode
|
|
504
625
|
* @returns Selected model name (claude-4.5-haiku | claude-4.5-sonnet)
|
|
505
626
|
*/
|
|
@@ -508,12 +629,12 @@ var AnthropicRouter = class extends BaseRouter {
|
|
|
508
629
|
}
|
|
509
630
|
};
|
|
510
631
|
var GeminiRouter = class extends BaseRouter {
|
|
511
|
-
constructor(
|
|
512
|
-
super("gemini",
|
|
632
|
+
constructor(clientOrConfig = {}) {
|
|
633
|
+
super("gemini", clientOrConfig);
|
|
513
634
|
}
|
|
514
635
|
/**
|
|
515
636
|
* Select optimal Gemini model
|
|
516
|
-
*
|
|
637
|
+
*
|
|
517
638
|
* @param input - User input and mode
|
|
518
639
|
* @returns Selected model name (gemini-2.5-flash | gemini-2.5-pro)
|
|
519
640
|
*/
|
|
@@ -522,69 +643,27 @@ var GeminiRouter = class extends BaseRouter {
|
|
|
522
643
|
}
|
|
523
644
|
};
|
|
524
645
|
var RawRouter = class extends BaseRouter {
|
|
525
|
-
constructor(
|
|
526
|
-
super("raw",
|
|
646
|
+
constructor(clientOrConfig = {}) {
|
|
647
|
+
super("raw", clientOrConfig);
|
|
527
648
|
}
|
|
528
649
|
/**
|
|
529
650
|
* Get raw difficulty classification
|
|
530
|
-
*
|
|
651
|
+
*
|
|
531
652
|
* @param input - User input and mode
|
|
532
653
|
* @returns Raw difficulty (easy | medium | hard | needs_info)
|
|
533
654
|
*/
|
|
534
655
|
async classify(input) {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
const payload = {
|
|
544
|
-
input: input.input,
|
|
545
|
-
mode
|
|
546
|
-
};
|
|
547
|
-
logger.debug("RawRouter", "request", { mode, input_len: input.input.length, url });
|
|
548
|
-
try {
|
|
549
|
-
const fetchPromise = fetchWithRetry(
|
|
550
|
-
url,
|
|
551
|
-
{
|
|
552
|
-
method: "POST",
|
|
553
|
-
headers: {
|
|
554
|
-
"Content-Type": "application/json",
|
|
555
|
-
Authorization: `Bearer ${apiKey}`
|
|
556
|
-
},
|
|
557
|
-
body: JSON.stringify(payload)
|
|
558
|
-
},
|
|
559
|
-
this.config.retryConfig
|
|
560
|
-
);
|
|
561
|
-
const response = await withTimeout(
|
|
562
|
-
fetchPromise,
|
|
563
|
-
this.config.timeout,
|
|
564
|
-
`Router API request timed out after ${this.config.timeout}ms`
|
|
565
|
-
);
|
|
566
|
-
if (!response.ok) {
|
|
567
|
-
const errorText = await response.text();
|
|
568
|
-
throw new Error(
|
|
569
|
-
`Router API error (${response.status}): ${errorText || response.statusText}`
|
|
570
|
-
);
|
|
571
|
-
}
|
|
572
|
-
const apiResult = await response.json();
|
|
573
|
-
let difficulty;
|
|
574
|
-
if (apiResult.difficulty === "") {
|
|
575
|
-
difficulty = "medium";
|
|
576
|
-
} else {
|
|
577
|
-
difficulty = apiResult.difficulty || apiResult.model;
|
|
578
|
-
}
|
|
579
|
-
const result = {
|
|
580
|
-
difficulty
|
|
581
|
-
};
|
|
582
|
-
logger.debug("RawRouter", "classified", { difficulty });
|
|
583
|
-
return result;
|
|
584
|
-
} catch (error) {
|
|
585
|
-
logger.error("RawRouter", "error", { error: error instanceof Error ? error.message : String(error) });
|
|
586
|
-
throw error;
|
|
656
|
+
this.requireApiKey();
|
|
657
|
+
logger.debug("RawRouter", "request", { mode: input.mode || "balanced" });
|
|
658
|
+
const apiResult = await this.route("raw", input);
|
|
659
|
+
let difficulty;
|
|
660
|
+
if (apiResult.difficulty === "") {
|
|
661
|
+
difficulty = "medium";
|
|
662
|
+
} else {
|
|
663
|
+
difficulty = apiResult.difficulty || apiResult.model;
|
|
587
664
|
}
|
|
665
|
+
logger.debug("RawRouter", "classified", { difficulty });
|
|
666
|
+
return { difficulty };
|
|
588
667
|
}
|
|
589
668
|
};
|
|
590
669
|
// Annotate the CommonJS export names for ESM import in node:
|