@morphllm/morphsdk 0.2.202 → 0.2.204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -0
- package/dist/chunk-2GMG5XKU.js +100 -0
- package/dist/chunk-2PPYWRMZ.js +3 -4
- package/dist/chunk-3HAHJYZQ.cjs +74 -0
- package/dist/{chunk-2XU3XXUE.js → chunk-3JROKKS4.js} +3 -25
- package/dist/{chunk-26K5EJD3.js → chunk-43JBUEIX.js} +4 -18
- package/dist/chunk-44OIEPIO.js +4 -23
- package/dist/chunk-4EQQGUZ7.cjs +104 -0
- package/dist/chunk-4OUGA3KS.js +1 -5
- package/dist/{chunk-VQDDL3UH.js → chunk-4TZBUFVP.js} +2 -8
- package/dist/{chunk-YAM6P5OQ.js → chunk-564XJOQP.js} +2 -6
- package/dist/chunk-5H3FKFOI.cjs +77 -0
- package/dist/chunk-5TTZQF4X.cjs +110 -0
- package/dist/chunk-6HAYJA6M.cjs +317 -0
- package/dist/chunk-6TZCVTW5.js +3 -4
- package/dist/chunk-6WP7EA4F.js +2 -4
- package/dist/chunk-74A4HLIO.cjs +42 -0
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/chunk-7PJYY46L.cjs +2 -0
- package/dist/chunk-AWFZKS27.cjs +11 -0
- package/dist/chunk-BJBWWIZV.cjs +2 -0
- package/dist/chunk-DLYDIYDK.cjs +305 -0
- package/dist/{chunk-65TUD7JV.js → chunk-DYCMPDPV.js} +13 -29
- package/dist/{chunk-3CPI6ZIC.js → chunk-DZP7BR66.js} +22 -43
- package/dist/chunk-E63OPKP7.js +96 -0
- package/dist/chunk-E6V75LI6.cjs +334 -0
- package/dist/{chunk-XPHNS7NW.js → chunk-EJ6ID24K.js} +3 -12
- package/dist/chunk-EJTL2BOZ.cjs +42 -0
- package/dist/chunk-ETBRAKVV.js +1 -5
- package/dist/chunk-F633IVQA.cjs +91 -0
- package/dist/chunk-FBOZIVVQ.js +1 -0
- package/dist/{chunk-UKXCGQPS.js → chunk-FGA6EYC2.js} +35 -37
- package/dist/{chunk-CAWQEHKP.js → chunk-G4RODMXA.js} +4 -19
- package/dist/chunk-GUNGJC6X.cjs +256 -0
- package/dist/chunk-GYE3FY6Z.js +8 -0
- package/dist/chunk-HDP4QAZL.js +1 -4
- package/dist/chunk-HNMEBYIS.cjs +86 -0
- package/dist/chunk-HP3PCOTW.cjs +81 -0
- package/dist/{chunk-ICCGLO6V.js → chunk-IGXNLXPN.js} +12 -17
- package/dist/chunk-IPJA3ZS6.cjs +10 -0
- package/dist/chunk-JHC2R3HU.cjs +317 -0
- package/dist/{chunk-IBRBSDLT.js → chunk-JVMIFGZY.js} +5 -8
- package/dist/chunk-KF6S3EPJ.cjs +100 -0
- package/dist/chunk-KVGZ2TSG.cjs +274 -0
- package/dist/{chunk-6OYJC4TZ.js → chunk-L5SCKZVK.js} +13 -22
- package/dist/chunk-LDM7RNNN.js +1 -0
- package/dist/{chunk-UAZKHSEU.js → chunk-LQST3NW2.js} +5 -15
- package/dist/chunk-M34E2AMK.js +1 -5
- package/dist/chunk-MF56KEI4.js +1 -4
- package/dist/chunk-MLKGABMK.js +1 -3
- package/dist/chunk-MLPZKUCO.js +4 -5
- package/dist/chunk-MMX5PUGC.cjs +242 -0
- package/dist/chunk-MWXJ6DZ2.cjs +21 -0
- package/dist/chunk-NJWOWXUR.cjs +137 -0
- package/dist/chunk-NNKBKENK.cjs +15 -0
- package/dist/chunk-NRG6QX3L.js +1 -3
- package/dist/chunk-OCKEEEYE.cjs +433 -0
- package/dist/chunk-OENJO7YW.js +306 -0
- package/dist/chunk-OKLAYEBC.cjs +2 -0
- package/dist/chunk-OPDWMD4Q.js +1 -3
- package/dist/{chunk-D6YJ5X3C.js → chunk-OX5GN2KB.js} +26 -14
- package/dist/{chunk-JEVLCA5C.js → chunk-OYBOP47A.js} +18 -19
- package/dist/chunk-OZHCHPIE.js +1 -0
- package/dist/chunk-PA3UTI4A.js +1 -4
- package/dist/chunk-QEEAIXL5.cjs +74 -0
- package/dist/chunk-QT5LGZG3.cjs +10 -0
- package/dist/chunk-R3TUE7O2.cjs +107 -0
- package/dist/chunk-RYVW7RUM.js +2 -6
- package/dist/{chunk-LVKKICOB.js → chunk-SOQYE5A4.js} +36 -69
- package/dist/chunk-ST2OXLT5.cjs +91 -0
- package/dist/{chunk-SIFDK4AA.js → chunk-TH4MG73B.js} +3 -24
- package/dist/{chunk-OSL4CNSO.js → chunk-TLMAMVAW.js} +7 -23
- package/dist/chunk-TPZHMD7J.cjs +72 -0
- package/dist/{chunk-PDSIWL7I.js → chunk-U4PYAGNR.js} +6 -19
- package/dist/chunk-UAPK3AIJ.js +1 -10
- package/dist/chunk-UF5IKELS.cjs +26 -0
- package/dist/chunk-UHFVWYSP.cjs +408 -0
- package/dist/chunk-UKBSXYKE.cjs +280 -0
- package/dist/chunk-UNX7V6P6.cjs +60 -0
- package/dist/chunk-UZMMJ47A.cjs +107 -0
- package/dist/chunk-VHD7CW5O.cjs +43 -0
- package/dist/chunk-VL4QNALG.cjs +50 -0
- package/dist/chunk-VYE7O4FM.cjs +51 -0
- package/dist/chunk-WIYVT4UO.cjs +173 -0
- package/dist/chunk-WJHHO24M.cjs +91 -0
- package/dist/chunk-WR7LSUIR.cjs +213 -0
- package/dist/chunk-XE6D4J63.cjs +72 -0
- package/dist/chunk-YAUXTFIN.cjs +21 -0
- package/dist/{chunk-NFPRKZQ5.js → chunk-YJUCGZNN.js} +5 -22
- package/dist/chunk-ZSHVXDA2.js +4 -10
- package/dist/chunk-ZX6T3LNG.js +302 -0
- package/dist/{client-BWhi-vSj.d.ts → client-DSXbcxII.d.ts} +10 -1
- package/dist/client.cjs +44 -4360
- package/dist/client.d.ts +4 -2
- package/dist/client.js +36 -37
- package/dist/core/client.cjs +14 -476
- package/dist/core/client.d.ts +8 -0
- package/dist/core/client.js +10 -11
- package/dist/core/error.cjs +8 -251
- package/dist/core/error.js +4 -9
- package/dist/core/index.cjs +27 -491
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +12 -19
- package/dist/core/resource.cjs +9 -33
- package/dist/core/resource.d.ts +2 -0
- package/dist/core/resource.js +2 -7
- package/dist/edge.cjs +74 -1111
- package/dist/edge.d.ts +3 -0
- package/dist/edge.js +14 -42
- package/dist/guard-CvW03v4u.d.ts +59 -0
- package/dist/index.cjs +140 -4431
- package/dist/index.d.ts +6 -2
- package/dist/index.js +44 -87
- package/dist/modelrouter/core.cjs +35 -651
- package/dist/modelrouter/core.d.ts +2 -0
- package/dist/modelrouter/core.js +12 -21
- package/dist/modelrouter/index.cjs +35 -651
- package/dist/modelrouter/index.d.ts +2 -0
- package/dist/modelrouter/index.js +12 -21
- package/dist/modelrouter/types.cjs +1 -17
- package/dist/modelrouter/types.d.ts +5 -0
- package/dist/modelrouter/types.js +1 -0
- package/dist/subagents/anthropic.cjs +31 -2784
- package/dist/subagents/anthropic.d.ts +3 -1
- package/dist/subagents/anthropic.js +23 -24
- package/dist/subagents/index.cjs +14 -95
- package/dist/subagents/index.d.ts +3 -1
- package/dist/subagents/index.js +2 -11
- package/dist/subagents/prompts.cjs +14 -93
- package/dist/subagents/prompts.d.ts +3 -1
- package/dist/subagents/prompts.js +2 -11
- package/dist/subagents/types.cjs +1 -17
- package/dist/subagents/types.d.ts +3 -1
- package/dist/subagents/types.js +1 -0
- package/dist/subagents/vercel.cjs +31 -2761
- package/dist/subagents/vercel.d.ts +3 -1
- package/dist/subagents/vercel.js +23 -24
- package/dist/tools/compact/core.cjs +20 -552
- package/dist/tools/compact/core.d.ts +2 -0
- package/dist/tools/compact/core.js +12 -13
- package/dist/tools/compact/index.cjs +24 -598
- package/dist/tools/compact/index.d.ts +3 -1
- package/dist/tools/compact/index.js +13 -17
- package/dist/tools/compact/types.cjs +1 -17
- package/dist/tools/compact/types.d.ts +4 -4
- package/dist/tools/compact/types.js +1 -0
- package/dist/tools/fastapply/anthropic.cjs +39 -899
- package/dist/tools/fastapply/anthropic.d.ts +2 -0
- package/dist/tools/fastapply/anthropic.js +15 -24
- package/dist/tools/fastapply/apply.cjs +32 -672
- package/dist/tools/fastapply/apply.d.ts +2 -0
- package/dist/tools/fastapply/apply.js +8 -19
- package/dist/tools/fastapply/core.cjs +49 -1069
- package/dist/tools/fastapply/core.d.ts +3 -0
- package/dist/tools/fastapply/core.js +13 -29
- package/dist/tools/fastapply/index.cjs +56 -1052
- package/dist/tools/fastapply/index.d.ts +2 -0
- package/dist/tools/fastapply/index.js +18 -44
- package/dist/tools/fastapply/openai.cjs +45 -910
- package/dist/tools/fastapply/openai.d.ts +2 -0
- package/dist/tools/fastapply/openai.js +15 -26
- package/dist/tools/fastapply/prompts.cjs +10 -62
- package/dist/tools/fastapply/prompts.js +2 -9
- package/dist/tools/fastapply/types.cjs +1 -17
- package/dist/tools/fastapply/types.d.ts +9 -4
- package/dist/tools/fastapply/types.js +1 -0
- package/dist/tools/fastapply/vercel.cjs +37 -905
- package/dist/tools/fastapply/vercel.d.ts +2 -0
- package/dist/tools/fastapply/vercel.js +15 -22
- package/dist/tools/index.cjs +56 -1052
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +18 -44
- package/dist/tools/pii/index.cjs +47 -0
- package/dist/tools/pii/index.d.ts +4 -0
- package/dist/tools/pii/index.js +6 -0
- package/dist/tools/pii/model.cjs +45 -0
- package/dist/tools/pii/model.d.ts +83 -0
- package/dist/tools/pii/model.js +4 -0
- package/dist/tools/pii/patterns.cjs +15 -0
- package/dist/tools/pii/patterns.d.ts +31 -0
- package/dist/tools/pii/patterns.js +2 -0
- package/dist/tools/pii/regex.cjs +32 -0
- package/dist/tools/pii/regex.d.ts +48 -0
- package/dist/tools/pii/regex.js +3 -0
- package/dist/tools/pii/types.cjs +2 -0
- package/dist/tools/pii/types.d.ts +108 -0
- package/dist/tools/pii/types.js +1 -0
- package/dist/tools/utils/resilience.cjs +15 -312
- package/dist/tools/utils/resilience.js +3 -12
- package/dist/tools/warp_grep/agent/config.cjs +16 -127
- package/dist/tools/warp_grep/agent/config.js +2 -11
- package/dist/tools/warp_grep/agent/formatter.cjs +12 -48
- package/dist/tools/warp_grep/agent/formatter.js +2 -9
- package/dist/tools/warp_grep/agent/parser.cjs +16 -83
- package/dist/tools/warp_grep/agent/parser.d.ts +2 -0
- package/dist/tools/warp_grep/agent/parser.js +2 -11
- package/dist/tools/warp_grep/agent/runner.cjs +19 -1081
- package/dist/tools/warp_grep/agent/runner.d.ts +2 -0
- package/dist/tools/warp_grep/agent/runner.js +11 -14
- package/dist/tools/warp_grep/agent/types.cjs +1 -17
- package/dist/tools/warp_grep/agent/types.d.ts +4 -0
- package/dist/tools/warp_grep/agent/types.js +1 -0
- package/dist/tools/warp_grep/anthropic.cjs +51 -2561
- package/dist/tools/warp_grep/anthropic.d.ts +3 -1
- package/dist/tools/warp_grep/anthropic.js +23 -35
- package/dist/tools/warp_grep/client.cjs +53 -2471
- package/dist/tools/warp_grep/client.d.ts +3 -1
- package/dist/tools/warp_grep/client.js +21 -34
- package/dist/tools/warp_grep/gemini.cjs +52 -2490
- package/dist/tools/warp_grep/gemini.d.ts +3 -1
- package/dist/tools/warp_grep/gemini.js +25 -41
- package/dist/tools/warp_grep/harness.cjs +81 -936
- package/dist/tools/warp_grep/harness.d.ts +2 -0
- package/dist/tools/warp_grep/harness.js +12 -51
- package/dist/tools/warp_grep/index.cjs +128 -2575
- package/dist/tools/warp_grep/index.d.ts +3 -1
- package/dist/tools/warp_grep/index.js +28 -87
- package/dist/tools/warp_grep/openai.cjs +57 -2575
- package/dist/tools/warp_grep/openai.d.ts +3 -1
- package/dist/tools/warp_grep/openai.js +23 -37
- package/dist/tools/warp_grep/providers/code_storage_http.cjs +12 -65
- package/dist/tools/warp_grep/providers/code_storage_http.d.ts +3 -1
- package/dist/tools/warp_grep/providers/code_storage_http.js +2 -9
- package/dist/tools/warp_grep/providers/local.cjs +10 -589
- package/dist/tools/warp_grep/providers/local.js +6 -11
- package/dist/tools/warp_grep/providers/remote.cjs +8 -331
- package/dist/tools/warp_grep/providers/remote.d.ts +3 -1
- package/dist/tools/warp_grep/providers/remote.js +3 -8
- package/dist/tools/warp_grep/providers/types.cjs +1 -17
- package/dist/tools/warp_grep/providers/types.js +1 -0
- package/dist/tools/warp_grep/utils/files.cjs +9 -42
- package/dist/tools/warp_grep/utils/files.js +2 -7
- package/dist/tools/warp_grep/utils/github.cjs +9 -43
- package/dist/tools/warp_grep/utils/github.js +2 -7
- package/dist/tools/warp_grep/utils/paths.cjs +28 -104
- package/dist/tools/warp_grep/utils/paths.js +2 -17
- package/dist/tools/warp_grep/utils/ripgrep.cjs +9 -103
- package/dist/tools/warp_grep/utils/ripgrep.js +2 -7
- package/dist/tools/warp_grep/vercel.cjs +57 -2557
- package/dist/tools/warp_grep/vercel.d.ts +3 -1
- package/dist/tools/warp_grep/vercel.js +23 -37
- package/dist/{types-DxZLPogx.d.ts → types-BKhXjDCB.d.ts} +6 -1
- package/dist/version.cjs +7 -225
- package/dist/version.js +2 -7
- package/package.json +11 -2
- package/dist/chunk-E6TL6MIH.js +0 -203
|
@@ -1,653 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// modelrouter/core.ts
|
|
31
|
-
var core_exports = {};
|
|
32
|
-
__export(core_exports, {
|
|
33
|
-
AnthropicRouter: () => AnthropicRouter,
|
|
34
|
-
GeminiRouter: () => GeminiRouter,
|
|
35
|
-
OpenAIRouter: () => OpenAIRouter,
|
|
36
|
-
RawRouter: () => RawRouter,
|
|
37
|
-
RouterClassifier: () => RouterClassifier
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkWIYVT4UO_cjs = require('../chunk-WIYVT4UO.cjs');
|
|
4
|
+
require('../chunk-5TTZQF4X.cjs');
|
|
5
|
+
require('../chunk-VL4QNALG.cjs');
|
|
6
|
+
require('../chunk-KF6S3EPJ.cjs');
|
|
7
|
+
require('../chunk-6HAYJA6M.cjs');
|
|
8
|
+
require('../chunk-R3TUE7O2.cjs');
|
|
9
|
+
require('../chunk-DLYDIYDK.cjs');
|
|
10
|
+
require('../chunk-YAUXTFIN.cjs');
|
|
11
|
+
require('../chunk-WJHHO24M.cjs');
|
|
12
|
+
require('../chunk-QT5LGZG3.cjs');
|
|
13
|
+
require('../chunk-AWFZKS27.cjs');
|
|
14
|
+
require('../chunk-75ZPJI57.cjs');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, "AnthropicRouter", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return chunkWIYVT4UO_cjs.AnthropicRouter; }
|
|
38
21
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
require: "./dist/index.cjs"
|
|
55
|
-
},
|
|
56
|
-
"./logger": {
|
|
57
|
-
types: "./dist/logger.d.ts",
|
|
58
|
-
import: "./dist/logger.js",
|
|
59
|
-
require: "./dist/logger.cjs"
|
|
60
|
-
},
|
|
61
|
-
"./edge": {
|
|
62
|
-
types: "./dist/edge.d.ts",
|
|
63
|
-
import: "./dist/edge.js",
|
|
64
|
-
require: "./dist/edge.cjs"
|
|
65
|
-
},
|
|
66
|
-
"./tools/warp-grep": {
|
|
67
|
-
types: "./dist/tools/warp_grep/index.d.ts",
|
|
68
|
-
import: "./dist/tools/warp_grep/index.js",
|
|
69
|
-
require: "./dist/tools/warp_grep/index.cjs"
|
|
70
|
-
},
|
|
71
|
-
"./tools/warp-grep/openai": {
|
|
72
|
-
types: "./dist/tools/warp_grep/openai.d.ts",
|
|
73
|
-
import: "./dist/tools/warp_grep/openai.js",
|
|
74
|
-
require: "./dist/tools/warp_grep/openai.cjs"
|
|
75
|
-
},
|
|
76
|
-
"./tools/warp-grep/anthropic": {
|
|
77
|
-
types: "./dist/tools/warp_grep/anthropic.d.ts",
|
|
78
|
-
import: "./dist/tools/warp_grep/anthropic.js",
|
|
79
|
-
require: "./dist/tools/warp_grep/anthropic.cjs"
|
|
80
|
-
},
|
|
81
|
-
"./tools/warp-grep/vercel": {
|
|
82
|
-
types: "./dist/tools/warp_grep/vercel.d.ts",
|
|
83
|
-
import: "./dist/tools/warp_grep/vercel.js",
|
|
84
|
-
require: "./dist/tools/warp_grep/vercel.cjs"
|
|
85
|
-
},
|
|
86
|
-
"./tools/warp-grep/client": {
|
|
87
|
-
types: "./dist/tools/warp_grep/client.d.ts",
|
|
88
|
-
import: "./dist/tools/warp_grep/client.js",
|
|
89
|
-
require: "./dist/tools/warp_grep/client.cjs"
|
|
90
|
-
},
|
|
91
|
-
"./tools/warp-grep/gemini": {
|
|
92
|
-
types: "./dist/tools/warp_grep/gemini.d.ts",
|
|
93
|
-
import: "./dist/tools/warp_grep/gemini.js",
|
|
94
|
-
require: "./dist/tools/warp_grep/gemini.cjs"
|
|
95
|
-
},
|
|
96
|
-
"./tools/warp-grep/harness": {
|
|
97
|
-
types: "./dist/tools/warp_grep/harness.d.ts",
|
|
98
|
-
import: "./dist/tools/warp_grep/harness.js",
|
|
99
|
-
require: "./dist/tools/warp_grep/harness.cjs"
|
|
100
|
-
},
|
|
101
|
-
"./tools/fastapply": {
|
|
102
|
-
types: "./dist/tools/fastapply/index.d.ts",
|
|
103
|
-
import: "./dist/tools/fastapply/index.js",
|
|
104
|
-
require: "./dist/tools/fastapply/index.cjs"
|
|
105
|
-
},
|
|
106
|
-
"./tools/fastapply/anthropic": {
|
|
107
|
-
types: "./dist/tools/fastapply/anthropic.d.ts",
|
|
108
|
-
import: "./dist/tools/fastapply/anthropic.js",
|
|
109
|
-
require: "./dist/tools/fastapply/anthropic.cjs"
|
|
110
|
-
},
|
|
111
|
-
"./tools/fastapply/openai": {
|
|
112
|
-
types: "./dist/tools/fastapply/openai.d.ts",
|
|
113
|
-
import: "./dist/tools/fastapply/openai.js",
|
|
114
|
-
require: "./dist/tools/fastapply/openai.cjs"
|
|
115
|
-
},
|
|
116
|
-
"./tools/fastapply/vercel": {
|
|
117
|
-
types: "./dist/tools/fastapply/vercel.d.ts",
|
|
118
|
-
import: "./dist/tools/fastapply/vercel.js",
|
|
119
|
-
require: "./dist/tools/fastapply/vercel.cjs"
|
|
120
|
-
},
|
|
121
|
-
"./modelrouter": {
|
|
122
|
-
types: "./dist/modelrouter/index.d.ts",
|
|
123
|
-
import: "./dist/modelrouter/index.js",
|
|
124
|
-
require: "./dist/modelrouter/index.cjs"
|
|
125
|
-
},
|
|
126
|
-
"./tools/compact": {
|
|
127
|
-
types: "./dist/tools/compact/index.d.ts",
|
|
128
|
-
import: "./dist/tools/compact/index.js",
|
|
129
|
-
require: "./dist/tools/compact/index.cjs"
|
|
130
|
-
},
|
|
131
|
-
"./subagents": {
|
|
132
|
-
types: "./dist/subagents/index.d.ts",
|
|
133
|
-
import: "./dist/subagents/index.js",
|
|
134
|
-
require: "./dist/subagents/index.cjs"
|
|
135
|
-
},
|
|
136
|
-
"./subagents/vercel": {
|
|
137
|
-
types: "./dist/subagents/vercel.d.ts",
|
|
138
|
-
import: "./dist/subagents/vercel.js",
|
|
139
|
-
require: "./dist/subagents/vercel.cjs"
|
|
140
|
-
},
|
|
141
|
-
"./subagents/anthropic": {
|
|
142
|
-
types: "./dist/subagents/anthropic.d.ts",
|
|
143
|
-
import: "./dist/subagents/anthropic.js",
|
|
144
|
-
require: "./dist/subagents/anthropic.cjs"
|
|
145
|
-
},
|
|
146
|
-
"./ai-sdk": {
|
|
147
|
-
types: "./dist/ai-sdk/index.d.ts",
|
|
148
|
-
import: "./dist/ai-sdk/index.js",
|
|
149
|
-
require: "./dist/ai-sdk/index.cjs"
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
files: [
|
|
153
|
-
"dist/**/*.js",
|
|
154
|
-
"dist/**/*.cjs",
|
|
155
|
-
"dist/**/*.d.ts",
|
|
156
|
-
"!dist/**/__tests__/**",
|
|
157
|
-
"!dist/**/*.test.*"
|
|
158
|
-
],
|
|
159
|
-
scripts: {
|
|
160
|
-
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/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 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 --clean --dts --dts-resolve && tsup ai-sdk/index.ts --format esm,cjs --dts --no-clean --out-dir dist/ai-sdk",
|
|
161
|
-
prepare: "npm run build",
|
|
162
|
-
typecheck: "tsc --noEmit && tsc --noEmit -p ai-sdk/tsconfig.json",
|
|
163
|
-
lint: "eslint .",
|
|
164
|
-
test: "vitest run",
|
|
165
|
-
"test:watch": "vitest watch",
|
|
166
|
-
"test:anthropic": "vitest run anthropic",
|
|
167
|
-
"test:openai": "vitest run openai",
|
|
168
|
-
"test:vercel": "vitest run vercel",
|
|
169
|
-
"test:git": "vitest run git",
|
|
170
|
-
"test:agent": "npx tsx tests/fullAgentTest.ts",
|
|
171
|
-
"test:integration": "npx tsx tests/fullIntegrationTest.ts",
|
|
172
|
-
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
173
|
-
"release:patch": "npm version patch && npm publish",
|
|
174
|
-
"release:minor": "npm version minor && npm publish",
|
|
175
|
-
"release:major": "npm version major && npm publish"
|
|
176
|
-
},
|
|
177
|
-
keywords: [
|
|
178
|
-
"morph",
|
|
179
|
-
"fast-apply",
|
|
180
|
-
"cli",
|
|
181
|
-
"sdk",
|
|
182
|
-
"edit-file"
|
|
183
|
-
],
|
|
184
|
-
engines: {
|
|
185
|
-
node: ">=18"
|
|
186
|
-
},
|
|
187
|
-
license: "MIT",
|
|
188
|
-
dependencies: {
|
|
189
|
-
"@vscode/ripgrep": "^1.17.0",
|
|
190
|
-
ai: ">=5.0.0",
|
|
191
|
-
diff: "^7.0.0",
|
|
192
|
-
openai: "^4.52.7",
|
|
193
|
-
zod: ">=3.23.0"
|
|
194
|
-
},
|
|
195
|
-
devDependencies: {
|
|
196
|
-
"@ai-sdk/anthropic": "^2.0.70",
|
|
197
|
-
"@ai-sdk/openai": "^2.0.35",
|
|
198
|
-
"@anthropic-ai/sdk": "^0.30.1",
|
|
199
|
-
"@google/generative-ai": "^0.24.1",
|
|
200
|
-
"@types/diff": "^7.0.2",
|
|
201
|
-
"@types/node": "^20.14.10",
|
|
202
|
-
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
203
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
204
|
-
dotenv: "^16.4.5",
|
|
205
|
-
eslint: "^8.57.0",
|
|
206
|
-
shx: "^0.3.4",
|
|
207
|
-
tsup: "^8.5.0",
|
|
208
|
-
tsx: "^4.16.2",
|
|
209
|
-
typescript: "^5.5.4",
|
|
210
|
-
vitest: "^2.1.6"
|
|
211
|
-
},
|
|
212
|
-
peerDependencies: {
|
|
213
|
-
"@ai-sdk/openai-compatible": ">=2.0.74 <4",
|
|
214
|
-
"@anthropic-ai/sdk": ">=0.25.0",
|
|
215
|
-
"@google/generative-ai": ">=0.21.0",
|
|
216
|
-
ai: ">=5.0.0",
|
|
217
|
-
zod: ">=3.23.0"
|
|
218
|
-
},
|
|
219
|
-
peerDependenciesMeta: {
|
|
220
|
-
"@anthropic-ai/sdk": {
|
|
221
|
-
optional: true
|
|
222
|
-
},
|
|
223
|
-
"@google/generative-ai": {
|
|
224
|
-
optional: true
|
|
225
|
-
},
|
|
226
|
-
ai: {
|
|
227
|
-
optional: true
|
|
228
|
-
},
|
|
229
|
-
zod: {
|
|
230
|
-
optional: true
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
publishConfig: {
|
|
234
|
-
access: "public"
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
// version.ts
|
|
239
|
-
var SDK_VERSION = package_default.version;
|
|
240
|
-
|
|
241
|
-
// tools/utils/resilience.ts
|
|
242
|
-
var DEFAULT_RETRY_CONFIG = {
|
|
243
|
-
maxRetries: 3,
|
|
244
|
-
initialDelay: 1e3,
|
|
245
|
-
maxDelay: 3e4,
|
|
246
|
-
backoffMultiplier: 2,
|
|
247
|
-
retryableErrors: ["ECONNREFUSED", "ETIMEDOUT", "ENOTFOUND"]
|
|
248
|
-
};
|
|
249
|
-
async function fetchWithRetry(url, options, retryConfig = {}) {
|
|
250
|
-
const {
|
|
251
|
-
maxRetries = DEFAULT_RETRY_CONFIG.maxRetries,
|
|
252
|
-
initialDelay = DEFAULT_RETRY_CONFIG.initialDelay,
|
|
253
|
-
maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,
|
|
254
|
-
backoffMultiplier = DEFAULT_RETRY_CONFIG.backoffMultiplier,
|
|
255
|
-
retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors,
|
|
256
|
-
onRetry
|
|
257
|
-
} = retryConfig;
|
|
258
|
-
let lastError = null;
|
|
259
|
-
let delay = initialDelay;
|
|
260
|
-
options = { ...options, headers: { "X-Morph-SDK-Version": SDK_VERSION, ...options.headers } };
|
|
261
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
262
|
-
try {
|
|
263
|
-
const response = await fetch(url, options);
|
|
264
|
-
if (response.status === 429 || response.status === 503) {
|
|
265
|
-
if (attempt < maxRetries) {
|
|
266
|
-
const retryAfter = response.headers.get("Retry-After");
|
|
267
|
-
const waitTime = retryAfter ? parseInt(retryAfter) * 1e3 : Math.min(delay, maxDelay);
|
|
268
|
-
const error = new Error(`HTTP ${response.status}: Retrying after ${waitTime}ms`);
|
|
269
|
-
if (onRetry) {
|
|
270
|
-
onRetry(attempt + 1, error);
|
|
271
|
-
}
|
|
272
|
-
await sleep(waitTime);
|
|
273
|
-
delay *= backoffMultiplier;
|
|
274
|
-
continue;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return response;
|
|
278
|
-
} catch (error) {
|
|
279
|
-
lastError = error;
|
|
280
|
-
const isRetryable = retryableErrors.some(
|
|
281
|
-
(errType) => lastError?.message?.includes(errType)
|
|
282
|
-
);
|
|
283
|
-
if (!isRetryable || attempt === maxRetries) {
|
|
284
|
-
throw lastError;
|
|
285
|
-
}
|
|
286
|
-
const waitTime = Math.min(delay, maxDelay);
|
|
287
|
-
if (onRetry) {
|
|
288
|
-
onRetry(attempt + 1, lastError);
|
|
289
|
-
}
|
|
290
|
-
await sleep(waitTime);
|
|
291
|
-
delay *= backoffMultiplier;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
throw lastError || new Error("Max retries exceeded");
|
|
295
|
-
}
|
|
296
|
-
async function withTimeout(promise, timeoutMs, errorMessage) {
|
|
297
|
-
let timeoutId;
|
|
298
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
299
|
-
timeoutId = setTimeout(() => {
|
|
300
|
-
reject(new Error(errorMessage || `Operation timed out after ${timeoutMs}ms`));
|
|
301
|
-
}, timeoutMs);
|
|
302
|
-
});
|
|
303
|
-
try {
|
|
304
|
-
const result = await Promise.race([promise, timeoutPromise]);
|
|
305
|
-
clearTimeout(timeoutId);
|
|
306
|
-
return result;
|
|
307
|
-
} catch (error) {
|
|
308
|
-
clearTimeout(timeoutId);
|
|
309
|
-
throw error;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
function sleep(ms) {
|
|
313
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
314
|
-
}
|
|
315
|
-
var MorphError = class extends Error {
|
|
316
|
-
constructor(message, code, statusCode, retryable = false) {
|
|
317
|
-
super(message);
|
|
318
|
-
this.code = code;
|
|
319
|
-
this.statusCode = statusCode;
|
|
320
|
-
this.retryable = retryable;
|
|
321
|
-
this.name = "MorphError";
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
// logger.ts
|
|
326
|
-
var MorphLogger = class {
|
|
327
|
-
enabled;
|
|
328
|
-
fileStream;
|
|
329
|
-
/** Resolves once the file stream is initialized (or immediately if no file logging). */
|
|
330
|
-
ready;
|
|
331
|
-
constructor() {
|
|
332
|
-
this.enabled = typeof process !== "undefined" && (process.env.MORPH_DEBUG === "1" || !!process.env.MORPH_LOG_FILE);
|
|
333
|
-
this.fileStream = null;
|
|
334
|
-
const f = typeof process !== "undefined" ? process.env.MORPH_LOG_FILE : void 0;
|
|
335
|
-
if (f) {
|
|
336
|
-
this.ready = import("fs").then((fs) => {
|
|
337
|
-
this.fileStream = fs.createWriteStream(f, { flags: "a" });
|
|
338
|
-
}).catch(() => {
|
|
339
|
-
});
|
|
340
|
-
} else {
|
|
341
|
-
this.ready = Promise.resolve();
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
debug(component, msg, data) {
|
|
345
|
-
this._log("debug", component, msg, data);
|
|
346
|
-
}
|
|
347
|
-
info(component, msg, data) {
|
|
348
|
-
this._log("info", component, msg, data);
|
|
349
|
-
}
|
|
350
|
-
warn(component, msg, data) {
|
|
351
|
-
this._log("warn", component, msg, data);
|
|
352
|
-
}
|
|
353
|
-
error(component, msg, data) {
|
|
354
|
-
this._log("error", component, msg, data);
|
|
355
|
-
}
|
|
356
|
-
enable() {
|
|
357
|
-
this.enabled = true;
|
|
358
|
-
}
|
|
359
|
-
get isEnabled() {
|
|
360
|
-
return this.enabled;
|
|
361
|
-
}
|
|
362
|
-
_log(level, component, msg, data) {
|
|
363
|
-
if (level !== "error" && !this.enabled) return;
|
|
364
|
-
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
365
|
-
const prefix = `[${ts}] [${level.toUpperCase()}] [${component}]`;
|
|
366
|
-
console.error(data ? `${prefix} ${msg} ${JSON.stringify(data)}` : `${prefix} ${msg}`);
|
|
367
|
-
this.fileStream?.write(JSON.stringify({ ts, level, component, msg, ...data && { data } }) + "\n");
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
var logger = new MorphLogger();
|
|
371
|
-
|
|
372
|
-
// core/error.ts
|
|
373
|
-
async function toMorphError(response) {
|
|
374
|
-
let message = `Morph API request failed (${response.status})`;
|
|
375
|
-
let code = "api_error";
|
|
376
|
-
try {
|
|
377
|
-
const body = await response.json();
|
|
378
|
-
message = body.error?.message ?? body.message ?? message;
|
|
379
|
-
code = body.error?.code ?? body.error?.type ?? code;
|
|
380
|
-
} catch {
|
|
381
|
-
}
|
|
382
|
-
if (response.status === 401) code = "authentication_error";
|
|
383
|
-
if (response.status === 429) code = "rate_limit_exceeded";
|
|
384
|
-
const retryable = response.status === 429 || response.status === 503;
|
|
385
|
-
return new MorphError(message, code, response.status, retryable);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// core/client.ts
|
|
389
|
-
var DEFAULT_BASE_URL = "https://api.morphllm.com";
|
|
390
|
-
var DEFAULT_REPOS_URL = "https://repos.morphllm.com";
|
|
391
|
-
var DEFAULT_TIMEOUT = 6e4;
|
|
392
|
-
var env = (name) => typeof process !== "undefined" ? process.env?.[name] : void 0;
|
|
393
|
-
var stripTrailingSlash = (url) => url.replace(/\/+$/, "");
|
|
394
|
-
var MorphAPIClient = class {
|
|
395
|
-
/** Explicit key as provided; resolved against env at request time. */
|
|
396
|
-
apiKey;
|
|
397
|
-
baseURL;
|
|
398
|
-
reposURL;
|
|
399
|
-
/** Explicit default timeout (ms), if set. The request default is applied lazily so
|
|
400
|
-
* resources can read an undefined value and supply their own fallback. */
|
|
401
|
-
timeout;
|
|
402
|
-
retryConfig;
|
|
403
|
-
debug;
|
|
404
|
-
constructor(options = {}) {
|
|
405
|
-
this.apiKey = options.apiKey;
|
|
406
|
-
this.baseURL = stripTrailingSlash(options.baseURL ?? DEFAULT_BASE_URL);
|
|
407
|
-
this.reposURL = stripTrailingSlash(options.reposURL ?? env("MORPH_SEARCH_URL") ?? DEFAULT_REPOS_URL);
|
|
408
|
-
this.timeout = options.timeout;
|
|
409
|
-
this.retryConfig = options.retryConfig;
|
|
410
|
-
this.debug = options.debug ?? false;
|
|
411
|
-
if (this.debug) logger.enable();
|
|
412
|
-
}
|
|
413
|
-
/** The key actually used for requests: explicit, else `MORPH_API_KEY`. */
|
|
414
|
-
resolveApiKey() {
|
|
415
|
-
return this.apiKey ?? env("MORPH_API_KEY");
|
|
416
|
-
}
|
|
417
|
-
/** Headers shared with tools that bring their own HTTP client (FastApply/WarpGrep via the `openai` package). */
|
|
418
|
-
defaultHeaders() {
|
|
419
|
-
return { "X-Morph-SDK-Version": SDK_VERSION };
|
|
420
|
-
}
|
|
421
|
-
buildURL(path, baseURL) {
|
|
422
|
-
if (/^https?:\/\//i.test(path)) return path;
|
|
423
|
-
const base = stripTrailingSlash(baseURL ?? this.baseURL);
|
|
424
|
-
return `${base}${path.startsWith("/") ? "" : "/"}${path}`;
|
|
425
|
-
}
|
|
426
|
-
buildHeaders(apiKey, extra) {
|
|
427
|
-
return {
|
|
428
|
-
"Content-Type": "application/json",
|
|
429
|
-
"X-Morph-SDK-Version": SDK_VERSION,
|
|
430
|
-
Authorization: `Bearer ${apiKey}`,
|
|
431
|
-
...extra
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
applyQuery(url, query) {
|
|
435
|
-
if (!query) return url;
|
|
436
|
-
const params = new URLSearchParams();
|
|
437
|
-
for (const [key, value] of Object.entries(query)) {
|
|
438
|
-
if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
439
|
-
}
|
|
440
|
-
const qs = params.toString();
|
|
441
|
-
return qs ? `${url}${url.includes("?") ? "&" : "?"}${qs}` : url;
|
|
442
|
-
}
|
|
443
|
-
async request(method, path, opts = {}) {
|
|
444
|
-
const apiKey = this.resolveApiKey();
|
|
445
|
-
if (!apiKey) {
|
|
446
|
-
throw new MorphError(
|
|
447
|
-
"Morph API key not found. Set the MORPH_API_KEY environment variable or pass apiKey in config.",
|
|
448
|
-
"missing_api_key",
|
|
449
|
-
401
|
|
450
|
-
);
|
|
451
|
-
}
|
|
452
|
-
const url = this.applyQuery(this.buildURL(path, opts.baseURL), opts.query);
|
|
453
|
-
const timeout = opts.timeout ?? this.timeout ?? DEFAULT_TIMEOUT;
|
|
454
|
-
const init = {
|
|
455
|
-
method,
|
|
456
|
-
headers: this.buildHeaders(apiKey, opts.headers),
|
|
457
|
-
...opts.body !== void 0 ? { body: JSON.stringify(opts.body) } : {},
|
|
458
|
-
...opts.signal ? { signal: opts.signal } : {}
|
|
459
|
-
};
|
|
460
|
-
logger.debug("MorphAPIClient", "request", { method, url });
|
|
461
|
-
const response = await withTimeout(
|
|
462
|
-
fetchWithRetry(url, init, this.retryConfig ?? {}),
|
|
463
|
-
timeout,
|
|
464
|
-
`Morph request to ${url} timed out after ${timeout}ms`
|
|
465
|
-
);
|
|
466
|
-
if (!response.ok) throw await toMorphError(response);
|
|
467
|
-
if (opts.stream) return response;
|
|
468
|
-
if (response.status === 204) return void 0;
|
|
469
|
-
const text = await response.text();
|
|
470
|
-
return text ? JSON.parse(text) : void 0;
|
|
471
|
-
}
|
|
472
|
-
get(path, opts) {
|
|
473
|
-
return this.request("GET", path, opts);
|
|
474
|
-
}
|
|
475
|
-
post(path, opts) {
|
|
476
|
-
return this.request("POST", path, opts);
|
|
477
|
-
}
|
|
478
|
-
delete(path, opts) {
|
|
479
|
-
return this.request("DELETE", path, opts);
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
|
|
483
|
-
// core/resource.ts
|
|
484
|
-
var APIResource = class {
|
|
485
|
-
_client;
|
|
486
|
-
constructor(client) {
|
|
487
|
-
this._client = client;
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
// modelrouter/core.ts
|
|
492
|
-
var DEFAULT_API_URL = "https://api.morphllm.com";
|
|
493
|
-
var DEFAULT_TIMEOUT2 = 5e3;
|
|
494
|
-
function resolveClient(clientOrConfig) {
|
|
495
|
-
if (clientOrConfig instanceof MorphAPIClient) return clientOrConfig;
|
|
496
|
-
return new MorphAPIClient({
|
|
497
|
-
apiKey: clientOrConfig.apiKey,
|
|
498
|
-
baseURL: clientOrConfig.apiUrl ?? DEFAULT_API_URL,
|
|
499
|
-
timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT2,
|
|
500
|
-
retryConfig: clientOrConfig.retryConfig,
|
|
501
|
-
debug: clientOrConfig.debug
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
var BaseRouter = class extends APIResource {
|
|
505
|
-
provider;
|
|
506
|
-
timeout;
|
|
507
|
-
constructor(provider, clientOrConfig = {}) {
|
|
508
|
-
super(resolveClient(clientOrConfig));
|
|
509
|
-
this.provider = provider;
|
|
510
|
-
const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;
|
|
511
|
-
this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT2;
|
|
512
|
-
}
|
|
513
|
-
/** Throw the historical "API key is required" message when no key is resolvable. */
|
|
514
|
-
requireApiKey() {
|
|
515
|
-
if (!this._client.resolveApiKey()) {
|
|
516
|
-
throw new Error(
|
|
517
|
-
"Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config."
|
|
518
|
-
);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
/** POST to the router and surface failures as `Router API error (<status>): ...`. */
|
|
522
|
-
async route(provider, input) {
|
|
523
|
-
try {
|
|
524
|
-
return await this._client.post(`/v1/router/${provider}`, {
|
|
525
|
-
body: { input: input.input, mode: input.mode || "balanced" },
|
|
526
|
-
timeout: this.timeout
|
|
527
|
-
});
|
|
528
|
-
} catch (error) {
|
|
529
|
-
if (error instanceof MorphError) {
|
|
530
|
-
throw new Error(`Router API error (${error.statusCode}): ${error.message}`);
|
|
531
|
-
}
|
|
532
|
-
throw error;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
/**
|
|
536
|
-
* Select the optimal model for a given input and mode
|
|
537
|
-
*/
|
|
538
|
-
async selectModel(input) {
|
|
539
|
-
this.requireApiKey();
|
|
540
|
-
logger.debug("ModelRouter", "request", { provider: this.provider, mode: input.mode || "balanced" });
|
|
541
|
-
const apiResult = await this.route(this.provider, input);
|
|
542
|
-
logger.debug("ModelRouter", "selected", { provider: this.provider, model: apiResult.model });
|
|
543
|
-
return { model: apiResult.model };
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
var OpenAIRouter = class extends BaseRouter {
|
|
547
|
-
constructor(clientOrConfig = {}) {
|
|
548
|
-
super("openai", clientOrConfig);
|
|
549
|
-
}
|
|
550
|
-
/**
|
|
551
|
-
* Select optimal GPT-5 model
|
|
552
|
-
*
|
|
553
|
-
* @param input - User input and mode
|
|
554
|
-
* @returns Selected model name (gpt-5-mini | gpt-5-low | gpt-5-medium | gpt-5-high)
|
|
555
|
-
*/
|
|
556
|
-
async selectModel(input) {
|
|
557
|
-
return super.selectModel(input);
|
|
558
|
-
}
|
|
559
|
-
};
|
|
560
|
-
var AnthropicRouter = class extends BaseRouter {
|
|
561
|
-
constructor(clientOrConfig = {}) {
|
|
562
|
-
super("anthropic", clientOrConfig);
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* Select optimal Claude model
|
|
566
|
-
*
|
|
567
|
-
* @param input - User input and mode
|
|
568
|
-
* @returns Selected model name (claude-4.5-haiku | claude-4.5-sonnet)
|
|
569
|
-
*/
|
|
570
|
-
async selectModel(input) {
|
|
571
|
-
return super.selectModel(input);
|
|
572
|
-
}
|
|
573
|
-
};
|
|
574
|
-
var GeminiRouter = class extends BaseRouter {
|
|
575
|
-
constructor(clientOrConfig = {}) {
|
|
576
|
-
super("gemini", clientOrConfig);
|
|
577
|
-
}
|
|
578
|
-
/**
|
|
579
|
-
* Select optimal Gemini model
|
|
580
|
-
*
|
|
581
|
-
* @param input - User input and mode
|
|
582
|
-
* @returns Selected model name (gemini-2.5-flash | gemini-2.5-pro)
|
|
583
|
-
*/
|
|
584
|
-
async selectModel(input) {
|
|
585
|
-
return super.selectModel(input);
|
|
586
|
-
}
|
|
587
|
-
};
|
|
588
|
-
var RawRouter = class extends BaseRouter {
|
|
589
|
-
constructor(clientOrConfig = {}) {
|
|
590
|
-
super("raw", clientOrConfig);
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* Get raw difficulty classification
|
|
594
|
-
*
|
|
595
|
-
* @param input - User input and mode
|
|
596
|
-
* @returns Raw difficulty (easy | medium | hard | needs_info)
|
|
597
|
-
*/
|
|
598
|
-
async classify(input) {
|
|
599
|
-
this.requireApiKey();
|
|
600
|
-
logger.debug("RawRouter", "request", { mode: input.mode || "balanced" });
|
|
601
|
-
const apiResult = await this.route("raw", input);
|
|
602
|
-
let difficulty;
|
|
603
|
-
if (apiResult.difficulty === "") {
|
|
604
|
-
difficulty = "medium";
|
|
605
|
-
} else {
|
|
606
|
-
difficulty = apiResult.difficulty || apiResult.model;
|
|
607
|
-
}
|
|
608
|
-
logger.debug("RawRouter", "classified", { difficulty });
|
|
609
|
-
return { difficulty };
|
|
610
|
-
}
|
|
611
|
-
};
|
|
612
|
-
var RouterClassifier = class extends APIResource {
|
|
613
|
-
timeout;
|
|
614
|
-
constructor(clientOrConfig = {}) {
|
|
615
|
-
super(resolveClient(clientOrConfig));
|
|
616
|
-
const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;
|
|
617
|
-
this.timeout = cfg.timeout ?? DEFAULT_TIMEOUT2;
|
|
618
|
-
}
|
|
619
|
-
/** Classify an input across the requested axes (all three by default). */
|
|
620
|
-
async classify(input) {
|
|
621
|
-
if (!this._client.resolveApiKey()) {
|
|
622
|
-
throw new Error(
|
|
623
|
-
"Morph API key is required. Set MORPH_API_KEY environment variable or pass apiKey in config."
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
logger.debug("RouterClassifier", "request", { classes: input.classes ?? "all" });
|
|
627
|
-
try {
|
|
628
|
-
const res = await this._client.post("/v1/router/classify", {
|
|
629
|
-
body: { input: input.input, ...input.classes ? { classes: input.classes } : {} },
|
|
630
|
-
timeout: this.timeout
|
|
631
|
-
});
|
|
632
|
-
logger.debug("RouterClassifier", "classified", {
|
|
633
|
-
difficulty: res.classifications.difficulty?.label,
|
|
634
|
-
ambiguity: res.classifications.ambiguity?.label,
|
|
635
|
-
domain: res.classifications.domain?.label
|
|
636
|
-
});
|
|
637
|
-
return res.classifications;
|
|
638
|
-
} catch (error) {
|
|
639
|
-
if (error instanceof MorphError) {
|
|
640
|
-
throw new Error(`Router API error (${error.statusCode}): ${error.message}`);
|
|
641
|
-
}
|
|
642
|
-
throw error;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
647
|
-
0 && (module.exports = {
|
|
648
|
-
AnthropicRouter,
|
|
649
|
-
GeminiRouter,
|
|
650
|
-
OpenAIRouter,
|
|
651
|
-
RawRouter,
|
|
652
|
-
RouterClassifier
|
|
22
|
+
Object.defineProperty(exports, "GeminiRouter", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return chunkWIYVT4UO_cjs.GeminiRouter; }
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "OpenAIRouter", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return chunkWIYVT4UO_cjs.OpenAIRouter; }
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "RawRouter", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return chunkWIYVT4UO_cjs.RawRouter; }
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, "RouterClassifier", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return chunkWIYVT4UO_cjs.RouterClassifier; }
|
|
653
37
|
});
|