@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,600 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
// tools/compact/index.ts
|
|
31
|
-
var compact_exports = {};
|
|
32
|
-
__export(compact_exports, {
|
|
33
|
-
CompactClient: () => CompactClient,
|
|
34
|
-
compactFileContexts: () => compactFileContexts
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkVYE7O4FM_cjs = require('../../chunk-VYE7O4FM.cjs');
|
|
4
|
+
var chunkF633IVQA_cjs = require('../../chunk-F633IVQA.cjs');
|
|
5
|
+
require('../../chunk-5TTZQF4X.cjs');
|
|
6
|
+
require('../../chunk-VL4QNALG.cjs');
|
|
7
|
+
require('../../chunk-KF6S3EPJ.cjs');
|
|
8
|
+
require('../../chunk-6HAYJA6M.cjs');
|
|
9
|
+
require('../../chunk-R3TUE7O2.cjs');
|
|
10
|
+
require('../../chunk-DLYDIYDK.cjs');
|
|
11
|
+
require('../../chunk-YAUXTFIN.cjs');
|
|
12
|
+
require('../../chunk-WJHHO24M.cjs');
|
|
13
|
+
require('../../chunk-QT5LGZG3.cjs');
|
|
14
|
+
require('../../chunk-AWFZKS27.cjs');
|
|
15
|
+
require('../../chunk-75ZPJI57.cjs');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
Object.defineProperty(exports, "compactFileContexts", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkVYE7O4FM_cjs.compactFileContexts; }
|
|
35
22
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var package_default = {
|
|
40
|
-
name: "@morphllm/morphsdk",
|
|
41
|
-
version: "0.2.202",
|
|
42
|
-
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
43
|
-
type: "module",
|
|
44
|
-
main: "./dist/index.cjs",
|
|
45
|
-
module: "./dist/index.js",
|
|
46
|
-
types: "./dist/index.d.ts",
|
|
47
|
-
exports: {
|
|
48
|
-
".": {
|
|
49
|
-
types: "./dist/index.d.ts",
|
|
50
|
-
import: "./dist/index.js",
|
|
51
|
-
require: "./dist/index.cjs"
|
|
52
|
-
},
|
|
53
|
-
"./logger": {
|
|
54
|
-
types: "./dist/logger.d.ts",
|
|
55
|
-
import: "./dist/logger.js",
|
|
56
|
-
require: "./dist/logger.cjs"
|
|
57
|
-
},
|
|
58
|
-
"./edge": {
|
|
59
|
-
types: "./dist/edge.d.ts",
|
|
60
|
-
import: "./dist/edge.js",
|
|
61
|
-
require: "./dist/edge.cjs"
|
|
62
|
-
},
|
|
63
|
-
"./tools/warp-grep": {
|
|
64
|
-
types: "./dist/tools/warp_grep/index.d.ts",
|
|
65
|
-
import: "./dist/tools/warp_grep/index.js",
|
|
66
|
-
require: "./dist/tools/warp_grep/index.cjs"
|
|
67
|
-
},
|
|
68
|
-
"./tools/warp-grep/openai": {
|
|
69
|
-
types: "./dist/tools/warp_grep/openai.d.ts",
|
|
70
|
-
import: "./dist/tools/warp_grep/openai.js",
|
|
71
|
-
require: "./dist/tools/warp_grep/openai.cjs"
|
|
72
|
-
},
|
|
73
|
-
"./tools/warp-grep/anthropic": {
|
|
74
|
-
types: "./dist/tools/warp_grep/anthropic.d.ts",
|
|
75
|
-
import: "./dist/tools/warp_grep/anthropic.js",
|
|
76
|
-
require: "./dist/tools/warp_grep/anthropic.cjs"
|
|
77
|
-
},
|
|
78
|
-
"./tools/warp-grep/vercel": {
|
|
79
|
-
types: "./dist/tools/warp_grep/vercel.d.ts",
|
|
80
|
-
import: "./dist/tools/warp_grep/vercel.js",
|
|
81
|
-
require: "./dist/tools/warp_grep/vercel.cjs"
|
|
82
|
-
},
|
|
83
|
-
"./tools/warp-grep/client": {
|
|
84
|
-
types: "./dist/tools/warp_grep/client.d.ts",
|
|
85
|
-
import: "./dist/tools/warp_grep/client.js",
|
|
86
|
-
require: "./dist/tools/warp_grep/client.cjs"
|
|
87
|
-
},
|
|
88
|
-
"./tools/warp-grep/gemini": {
|
|
89
|
-
types: "./dist/tools/warp_grep/gemini.d.ts",
|
|
90
|
-
import: "./dist/tools/warp_grep/gemini.js",
|
|
91
|
-
require: "./dist/tools/warp_grep/gemini.cjs"
|
|
92
|
-
},
|
|
93
|
-
"./tools/warp-grep/harness": {
|
|
94
|
-
types: "./dist/tools/warp_grep/harness.d.ts",
|
|
95
|
-
import: "./dist/tools/warp_grep/harness.js",
|
|
96
|
-
require: "./dist/tools/warp_grep/harness.cjs"
|
|
97
|
-
},
|
|
98
|
-
"./tools/fastapply": {
|
|
99
|
-
types: "./dist/tools/fastapply/index.d.ts",
|
|
100
|
-
import: "./dist/tools/fastapply/index.js",
|
|
101
|
-
require: "./dist/tools/fastapply/index.cjs"
|
|
102
|
-
},
|
|
103
|
-
"./tools/fastapply/anthropic": {
|
|
104
|
-
types: "./dist/tools/fastapply/anthropic.d.ts",
|
|
105
|
-
import: "./dist/tools/fastapply/anthropic.js",
|
|
106
|
-
require: "./dist/tools/fastapply/anthropic.cjs"
|
|
107
|
-
},
|
|
108
|
-
"./tools/fastapply/openai": {
|
|
109
|
-
types: "./dist/tools/fastapply/openai.d.ts",
|
|
110
|
-
import: "./dist/tools/fastapply/openai.js",
|
|
111
|
-
require: "./dist/tools/fastapply/openai.cjs"
|
|
112
|
-
},
|
|
113
|
-
"./tools/fastapply/vercel": {
|
|
114
|
-
types: "./dist/tools/fastapply/vercel.d.ts",
|
|
115
|
-
import: "./dist/tools/fastapply/vercel.js",
|
|
116
|
-
require: "./dist/tools/fastapply/vercel.cjs"
|
|
117
|
-
},
|
|
118
|
-
"./modelrouter": {
|
|
119
|
-
types: "./dist/modelrouter/index.d.ts",
|
|
120
|
-
import: "./dist/modelrouter/index.js",
|
|
121
|
-
require: "./dist/modelrouter/index.cjs"
|
|
122
|
-
},
|
|
123
|
-
"./tools/compact": {
|
|
124
|
-
types: "./dist/tools/compact/index.d.ts",
|
|
125
|
-
import: "./dist/tools/compact/index.js",
|
|
126
|
-
require: "./dist/tools/compact/index.cjs"
|
|
127
|
-
},
|
|
128
|
-
"./subagents": {
|
|
129
|
-
types: "./dist/subagents/index.d.ts",
|
|
130
|
-
import: "./dist/subagents/index.js",
|
|
131
|
-
require: "./dist/subagents/index.cjs"
|
|
132
|
-
},
|
|
133
|
-
"./subagents/vercel": {
|
|
134
|
-
types: "./dist/subagents/vercel.d.ts",
|
|
135
|
-
import: "./dist/subagents/vercel.js",
|
|
136
|
-
require: "./dist/subagents/vercel.cjs"
|
|
137
|
-
},
|
|
138
|
-
"./subagents/anthropic": {
|
|
139
|
-
types: "./dist/subagents/anthropic.d.ts",
|
|
140
|
-
import: "./dist/subagents/anthropic.js",
|
|
141
|
-
require: "./dist/subagents/anthropic.cjs"
|
|
142
|
-
},
|
|
143
|
-
"./ai-sdk": {
|
|
144
|
-
types: "./dist/ai-sdk/index.d.ts",
|
|
145
|
-
import: "./dist/ai-sdk/index.js",
|
|
146
|
-
require: "./dist/ai-sdk/index.cjs"
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
files: [
|
|
150
|
-
"dist/**/*.js",
|
|
151
|
-
"dist/**/*.cjs",
|
|
152
|
-
"dist/**/*.d.ts",
|
|
153
|
-
"!dist/**/__tests__/**",
|
|
154
|
-
"!dist/**/*.test.*"
|
|
155
|
-
],
|
|
156
|
-
scripts: {
|
|
157
|
-
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",
|
|
158
|
-
prepare: "npm run build",
|
|
159
|
-
typecheck: "tsc --noEmit && tsc --noEmit -p ai-sdk/tsconfig.json",
|
|
160
|
-
lint: "eslint .",
|
|
161
|
-
test: "vitest run",
|
|
162
|
-
"test:watch": "vitest watch",
|
|
163
|
-
"test:anthropic": "vitest run anthropic",
|
|
164
|
-
"test:openai": "vitest run openai",
|
|
165
|
-
"test:vercel": "vitest run vercel",
|
|
166
|
-
"test:git": "vitest run git",
|
|
167
|
-
"test:agent": "npx tsx tests/fullAgentTest.ts",
|
|
168
|
-
"test:integration": "npx tsx tests/fullIntegrationTest.ts",
|
|
169
|
-
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
170
|
-
"release:patch": "npm version patch && npm publish",
|
|
171
|
-
"release:minor": "npm version minor && npm publish",
|
|
172
|
-
"release:major": "npm version major && npm publish"
|
|
173
|
-
},
|
|
174
|
-
keywords: [
|
|
175
|
-
"morph",
|
|
176
|
-
"fast-apply",
|
|
177
|
-
"cli",
|
|
178
|
-
"sdk",
|
|
179
|
-
"edit-file"
|
|
180
|
-
],
|
|
181
|
-
engines: {
|
|
182
|
-
node: ">=18"
|
|
183
|
-
},
|
|
184
|
-
license: "MIT",
|
|
185
|
-
dependencies: {
|
|
186
|
-
"@vscode/ripgrep": "^1.17.0",
|
|
187
|
-
ai: ">=5.0.0",
|
|
188
|
-
diff: "^7.0.0",
|
|
189
|
-
openai: "^4.52.7",
|
|
190
|
-
zod: ">=3.23.0"
|
|
191
|
-
},
|
|
192
|
-
devDependencies: {
|
|
193
|
-
"@ai-sdk/anthropic": "^2.0.70",
|
|
194
|
-
"@ai-sdk/openai": "^2.0.35",
|
|
195
|
-
"@anthropic-ai/sdk": "^0.30.1",
|
|
196
|
-
"@google/generative-ai": "^0.24.1",
|
|
197
|
-
"@types/diff": "^7.0.2",
|
|
198
|
-
"@types/node": "^20.14.10",
|
|
199
|
-
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
200
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
201
|
-
dotenv: "^16.4.5",
|
|
202
|
-
eslint: "^8.57.0",
|
|
203
|
-
shx: "^0.3.4",
|
|
204
|
-
tsup: "^8.5.0",
|
|
205
|
-
tsx: "^4.16.2",
|
|
206
|
-
typescript: "^5.5.4",
|
|
207
|
-
vitest: "^2.1.6"
|
|
208
|
-
},
|
|
209
|
-
peerDependencies: {
|
|
210
|
-
"@ai-sdk/openai-compatible": ">=2.0.74 <4",
|
|
211
|
-
"@anthropic-ai/sdk": ">=0.25.0",
|
|
212
|
-
"@google/generative-ai": ">=0.21.0",
|
|
213
|
-
ai: ">=5.0.0",
|
|
214
|
-
zod: ">=3.23.0"
|
|
215
|
-
},
|
|
216
|
-
peerDependenciesMeta: {
|
|
217
|
-
"@anthropic-ai/sdk": {
|
|
218
|
-
optional: true
|
|
219
|
-
},
|
|
220
|
-
"@google/generative-ai": {
|
|
221
|
-
optional: true
|
|
222
|
-
},
|
|
223
|
-
ai: {
|
|
224
|
-
optional: true
|
|
225
|
-
},
|
|
226
|
-
zod: {
|
|
227
|
-
optional: true
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
publishConfig: {
|
|
231
|
-
access: "public"
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
// version.ts
|
|
236
|
-
var SDK_VERSION = package_default.version;
|
|
237
|
-
|
|
238
|
-
// tools/utils/resilience.ts
|
|
239
|
-
var DEFAULT_RETRY_CONFIG = {
|
|
240
|
-
maxRetries: 3,
|
|
241
|
-
initialDelay: 1e3,
|
|
242
|
-
maxDelay: 3e4,
|
|
243
|
-
backoffMultiplier: 2,
|
|
244
|
-
retryableErrors: ["ECONNREFUSED", "ETIMEDOUT", "ENOTFOUND"]
|
|
245
|
-
};
|
|
246
|
-
async function fetchWithRetry(url, options, retryConfig = {}) {
|
|
247
|
-
const {
|
|
248
|
-
maxRetries = DEFAULT_RETRY_CONFIG.maxRetries,
|
|
249
|
-
initialDelay = DEFAULT_RETRY_CONFIG.initialDelay,
|
|
250
|
-
maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,
|
|
251
|
-
backoffMultiplier = DEFAULT_RETRY_CONFIG.backoffMultiplier,
|
|
252
|
-
retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors,
|
|
253
|
-
onRetry
|
|
254
|
-
} = retryConfig;
|
|
255
|
-
let lastError = null;
|
|
256
|
-
let delay = initialDelay;
|
|
257
|
-
options = { ...options, headers: { "X-Morph-SDK-Version": SDK_VERSION, ...options.headers } };
|
|
258
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
259
|
-
try {
|
|
260
|
-
const response = await fetch(url, options);
|
|
261
|
-
if (response.status === 429 || response.status === 503) {
|
|
262
|
-
if (attempt < maxRetries) {
|
|
263
|
-
const retryAfter = response.headers.get("Retry-After");
|
|
264
|
-
const waitTime = retryAfter ? parseInt(retryAfter) * 1e3 : Math.min(delay, maxDelay);
|
|
265
|
-
const error = new Error(`HTTP ${response.status}: Retrying after ${waitTime}ms`);
|
|
266
|
-
if (onRetry) {
|
|
267
|
-
onRetry(attempt + 1, error);
|
|
268
|
-
}
|
|
269
|
-
await sleep(waitTime);
|
|
270
|
-
delay *= backoffMultiplier;
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return response;
|
|
275
|
-
} catch (error) {
|
|
276
|
-
lastError = error;
|
|
277
|
-
const isRetryable = retryableErrors.some(
|
|
278
|
-
(errType) => lastError?.message?.includes(errType)
|
|
279
|
-
);
|
|
280
|
-
if (!isRetryable || attempt === maxRetries) {
|
|
281
|
-
throw lastError;
|
|
282
|
-
}
|
|
283
|
-
const waitTime = Math.min(delay, maxDelay);
|
|
284
|
-
if (onRetry) {
|
|
285
|
-
onRetry(attempt + 1, lastError);
|
|
286
|
-
}
|
|
287
|
-
await sleep(waitTime);
|
|
288
|
-
delay *= backoffMultiplier;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
throw lastError || new Error("Max retries exceeded");
|
|
292
|
-
}
|
|
293
|
-
async function withTimeout(promise, timeoutMs, errorMessage) {
|
|
294
|
-
let timeoutId;
|
|
295
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
296
|
-
timeoutId = setTimeout(() => {
|
|
297
|
-
reject(new Error(errorMessage || `Operation timed out after ${timeoutMs}ms`));
|
|
298
|
-
}, timeoutMs);
|
|
299
|
-
});
|
|
300
|
-
try {
|
|
301
|
-
const result = await Promise.race([promise, timeoutPromise]);
|
|
302
|
-
clearTimeout(timeoutId);
|
|
303
|
-
return result;
|
|
304
|
-
} catch (error) {
|
|
305
|
-
clearTimeout(timeoutId);
|
|
306
|
-
throw error;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
function sleep(ms) {
|
|
310
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
311
|
-
}
|
|
312
|
-
var MorphError = class extends Error {
|
|
313
|
-
constructor(message, code, statusCode, retryable = false) {
|
|
314
|
-
super(message);
|
|
315
|
-
this.code = code;
|
|
316
|
-
this.statusCode = statusCode;
|
|
317
|
-
this.retryable = retryable;
|
|
318
|
-
this.name = "MorphError";
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
// logger.ts
|
|
323
|
-
var MorphLogger = class {
|
|
324
|
-
enabled;
|
|
325
|
-
fileStream;
|
|
326
|
-
/** Resolves once the file stream is initialized (or immediately if no file logging). */
|
|
327
|
-
ready;
|
|
328
|
-
constructor() {
|
|
329
|
-
this.enabled = typeof process !== "undefined" && (process.env.MORPH_DEBUG === "1" || !!process.env.MORPH_LOG_FILE);
|
|
330
|
-
this.fileStream = null;
|
|
331
|
-
const f = typeof process !== "undefined" ? process.env.MORPH_LOG_FILE : void 0;
|
|
332
|
-
if (f) {
|
|
333
|
-
this.ready = import("fs").then((fs) => {
|
|
334
|
-
this.fileStream = fs.createWriteStream(f, { flags: "a" });
|
|
335
|
-
}).catch(() => {
|
|
336
|
-
});
|
|
337
|
-
} else {
|
|
338
|
-
this.ready = Promise.resolve();
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
debug(component, msg, data) {
|
|
342
|
-
this._log("debug", component, msg, data);
|
|
343
|
-
}
|
|
344
|
-
info(component, msg, data) {
|
|
345
|
-
this._log("info", component, msg, data);
|
|
346
|
-
}
|
|
347
|
-
warn(component, msg, data) {
|
|
348
|
-
this._log("warn", component, msg, data);
|
|
349
|
-
}
|
|
350
|
-
error(component, msg, data) {
|
|
351
|
-
this._log("error", component, msg, data);
|
|
352
|
-
}
|
|
353
|
-
enable() {
|
|
354
|
-
this.enabled = true;
|
|
355
|
-
}
|
|
356
|
-
get isEnabled() {
|
|
357
|
-
return this.enabled;
|
|
358
|
-
}
|
|
359
|
-
_log(level, component, msg, data) {
|
|
360
|
-
if (level !== "error" && !this.enabled) return;
|
|
361
|
-
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
362
|
-
const prefix = `[${ts}] [${level.toUpperCase()}] [${component}]`;
|
|
363
|
-
console.error(data ? `${prefix} ${msg} ${JSON.stringify(data)}` : `${prefix} ${msg}`);
|
|
364
|
-
this.fileStream?.write(JSON.stringify({ ts, level, component, msg, ...data && { data } }) + "\n");
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
var logger = new MorphLogger();
|
|
368
|
-
|
|
369
|
-
// core/error.ts
|
|
370
|
-
async function toMorphError(response) {
|
|
371
|
-
let message = `Morph API request failed (${response.status})`;
|
|
372
|
-
let code = "api_error";
|
|
373
|
-
try {
|
|
374
|
-
const body = await response.json();
|
|
375
|
-
message = body.error?.message ?? body.message ?? message;
|
|
376
|
-
code = body.error?.code ?? body.error?.type ?? code;
|
|
377
|
-
} catch {
|
|
378
|
-
}
|
|
379
|
-
if (response.status === 401) code = "authentication_error";
|
|
380
|
-
if (response.status === 429) code = "rate_limit_exceeded";
|
|
381
|
-
const retryable = response.status === 429 || response.status === 503;
|
|
382
|
-
return new MorphError(message, code, response.status, retryable);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// core/client.ts
|
|
386
|
-
var DEFAULT_BASE_URL = "https://api.morphllm.com";
|
|
387
|
-
var DEFAULT_REPOS_URL = "https://repos.morphllm.com";
|
|
388
|
-
var DEFAULT_TIMEOUT = 6e4;
|
|
389
|
-
var env = (name) => typeof process !== "undefined" ? process.env?.[name] : void 0;
|
|
390
|
-
var stripTrailingSlash = (url) => url.replace(/\/+$/, "");
|
|
391
|
-
var MorphAPIClient = class {
|
|
392
|
-
/** Explicit key as provided; resolved against env at request time. */
|
|
393
|
-
apiKey;
|
|
394
|
-
baseURL;
|
|
395
|
-
reposURL;
|
|
396
|
-
/** Explicit default timeout (ms), if set. The request default is applied lazily so
|
|
397
|
-
* resources can read an undefined value and supply their own fallback. */
|
|
398
|
-
timeout;
|
|
399
|
-
retryConfig;
|
|
400
|
-
debug;
|
|
401
|
-
constructor(options = {}) {
|
|
402
|
-
this.apiKey = options.apiKey;
|
|
403
|
-
this.baseURL = stripTrailingSlash(options.baseURL ?? DEFAULT_BASE_URL);
|
|
404
|
-
this.reposURL = stripTrailingSlash(options.reposURL ?? env("MORPH_SEARCH_URL") ?? DEFAULT_REPOS_URL);
|
|
405
|
-
this.timeout = options.timeout;
|
|
406
|
-
this.retryConfig = options.retryConfig;
|
|
407
|
-
this.debug = options.debug ?? false;
|
|
408
|
-
if (this.debug) logger.enable();
|
|
409
|
-
}
|
|
410
|
-
/** The key actually used for requests: explicit, else `MORPH_API_KEY`. */
|
|
411
|
-
resolveApiKey() {
|
|
412
|
-
return this.apiKey ?? env("MORPH_API_KEY");
|
|
413
|
-
}
|
|
414
|
-
/** Headers shared with tools that bring their own HTTP client (FastApply/WarpGrep via the `openai` package). */
|
|
415
|
-
defaultHeaders() {
|
|
416
|
-
return { "X-Morph-SDK-Version": SDK_VERSION };
|
|
417
|
-
}
|
|
418
|
-
buildURL(path, baseURL) {
|
|
419
|
-
if (/^https?:\/\//i.test(path)) return path;
|
|
420
|
-
const base = stripTrailingSlash(baseURL ?? this.baseURL);
|
|
421
|
-
return `${base}${path.startsWith("/") ? "" : "/"}${path}`;
|
|
422
|
-
}
|
|
423
|
-
buildHeaders(apiKey, extra) {
|
|
424
|
-
return {
|
|
425
|
-
"Content-Type": "application/json",
|
|
426
|
-
"X-Morph-SDK-Version": SDK_VERSION,
|
|
427
|
-
Authorization: `Bearer ${apiKey}`,
|
|
428
|
-
...extra
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
applyQuery(url, query) {
|
|
432
|
-
if (!query) return url;
|
|
433
|
-
const params = new URLSearchParams();
|
|
434
|
-
for (const [key, value] of Object.entries(query)) {
|
|
435
|
-
if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
436
|
-
}
|
|
437
|
-
const qs = params.toString();
|
|
438
|
-
return qs ? `${url}${url.includes("?") ? "&" : "?"}${qs}` : url;
|
|
439
|
-
}
|
|
440
|
-
async request(method, path, opts = {}) {
|
|
441
|
-
const apiKey = this.resolveApiKey();
|
|
442
|
-
if (!apiKey) {
|
|
443
|
-
throw new MorphError(
|
|
444
|
-
"Morph API key not found. Set the MORPH_API_KEY environment variable or pass apiKey in config.",
|
|
445
|
-
"missing_api_key",
|
|
446
|
-
401
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
const url = this.applyQuery(this.buildURL(path, opts.baseURL), opts.query);
|
|
450
|
-
const timeout = opts.timeout ?? this.timeout ?? DEFAULT_TIMEOUT;
|
|
451
|
-
const init = {
|
|
452
|
-
method,
|
|
453
|
-
headers: this.buildHeaders(apiKey, opts.headers),
|
|
454
|
-
...opts.body !== void 0 ? { body: JSON.stringify(opts.body) } : {},
|
|
455
|
-
...opts.signal ? { signal: opts.signal } : {}
|
|
456
|
-
};
|
|
457
|
-
logger.debug("MorphAPIClient", "request", { method, url });
|
|
458
|
-
const response = await withTimeout(
|
|
459
|
-
fetchWithRetry(url, init, this.retryConfig ?? {}),
|
|
460
|
-
timeout,
|
|
461
|
-
`Morph request to ${url} timed out after ${timeout}ms`
|
|
462
|
-
);
|
|
463
|
-
if (!response.ok) throw await toMorphError(response);
|
|
464
|
-
if (opts.stream) return response;
|
|
465
|
-
if (response.status === 204) return void 0;
|
|
466
|
-
const text = await response.text();
|
|
467
|
-
return text ? JSON.parse(text) : void 0;
|
|
468
|
-
}
|
|
469
|
-
get(path, opts) {
|
|
470
|
-
return this.request("GET", path, opts);
|
|
471
|
-
}
|
|
472
|
-
post(path, opts) {
|
|
473
|
-
return this.request("POST", path, opts);
|
|
474
|
-
}
|
|
475
|
-
delete(path, opts) {
|
|
476
|
-
return this.request("DELETE", path, opts);
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
// core/resource.ts
|
|
481
|
-
var APIResource = class {
|
|
482
|
-
_client;
|
|
483
|
-
constructor(client) {
|
|
484
|
-
this._client = client;
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
// tools/compact/core.ts
|
|
489
|
-
var DEFAULT_API_URL = "https://api.morphllm.com";
|
|
490
|
-
var DEFAULT_TIMEOUT2 = 12e4;
|
|
491
|
-
function resolveClient(clientOrConfig) {
|
|
492
|
-
if (clientOrConfig instanceof MorphAPIClient) return clientOrConfig;
|
|
493
|
-
return new MorphAPIClient({
|
|
494
|
-
apiKey: clientOrConfig.morphApiKey,
|
|
495
|
-
baseURL: clientOrConfig.morphApiUrl ?? DEFAULT_API_URL,
|
|
496
|
-
timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT2,
|
|
497
|
-
retryConfig: clientOrConfig.retryConfig,
|
|
498
|
-
debug: clientOrConfig.debug
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
var CompactClient = class extends APIResource {
|
|
502
|
-
/** Resolved URL/timeout, exposed for backwards-compatible introspection. */
|
|
503
|
-
config;
|
|
504
|
-
constructor(clientOrConfig = {}) {
|
|
505
|
-
super(resolveClient(clientOrConfig));
|
|
506
|
-
const cfg = clientOrConfig instanceof MorphAPIClient ? {} : clientOrConfig;
|
|
507
|
-
this.config = {
|
|
508
|
-
morphApiUrl: this._client.baseURL,
|
|
509
|
-
timeout: cfg.timeout ?? DEFAULT_TIMEOUT2,
|
|
510
|
-
debug: cfg.debug ?? false
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* Compact messages or text via /v1/compact.
|
|
515
|
-
* Returns per-message `compacted_line_ranges` showing which lines were removed.
|
|
516
|
-
*
|
|
517
|
-
* @example
|
|
518
|
-
* ```typescript
|
|
519
|
-
* const client = new CompactClient({ morphApiKey: 'sk-...' });
|
|
520
|
-
* const result = await client.compact({
|
|
521
|
-
* input: codeFile,
|
|
522
|
-
* query: "authentication",
|
|
523
|
-
* compressionRatio: 0.5,
|
|
524
|
-
* });
|
|
525
|
-
* console.log(result.output);
|
|
526
|
-
* ```
|
|
527
|
-
*/
|
|
528
|
-
async compact(input) {
|
|
529
|
-
const body = {
|
|
530
|
-
compression_ratio: input.compressionRatio ?? 0.5,
|
|
531
|
-
preserve_recent: input.preserveRecent ?? 2,
|
|
532
|
-
model: input.model ?? "morph-compactor",
|
|
533
|
-
include_line_ranges: input.includeLineRanges ?? true,
|
|
534
|
-
include_markers: input.includeMarkers ?? true
|
|
535
|
-
};
|
|
536
|
-
if (input.query !== void 0) body.query = input.query;
|
|
537
|
-
if (input.messages) body.messages = input.messages;
|
|
538
|
-
else if (typeof input.input === "string") body.input = input.input;
|
|
539
|
-
else if (Array.isArray(input.input)) body.messages = input.input;
|
|
540
|
-
else throw new Error("Either 'input' or 'messages' must be provided");
|
|
541
|
-
try {
|
|
542
|
-
return await this._client.post("/v1/compact", { body, timeout: this.config.timeout });
|
|
543
|
-
} catch (err) {
|
|
544
|
-
if (err instanceof MorphError) {
|
|
545
|
-
throw new Error(`Compact API error ${err.statusCode}: ${err.message}`);
|
|
546
|
-
}
|
|
547
|
-
throw err;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
// tools/compact/utils.ts
|
|
553
|
-
async function compactFileContexts(files, query, apiKey, apiUrl, maxTokens = 1e4, maxConcurrency = 3) {
|
|
554
|
-
const totalLength = files.reduce((sum, file) => sum + file.content.length, 0);
|
|
555
|
-
const estimatedTokens = totalLength / 3;
|
|
556
|
-
if (estimatedTokens <= maxTokens) {
|
|
557
|
-
return files;
|
|
558
|
-
}
|
|
559
|
-
let compressionRatio = maxTokens / estimatedTokens;
|
|
560
|
-
compressionRatio = Math.max(0.3, Math.min(0.99, compressionRatio));
|
|
561
|
-
const client = new CompactClient({
|
|
562
|
-
morphApiKey: apiKey,
|
|
563
|
-
morphApiUrl: apiUrl
|
|
564
|
-
});
|
|
565
|
-
const results = [];
|
|
566
|
-
const inProgress = /* @__PURE__ */ new Set();
|
|
567
|
-
for (const file of files) {
|
|
568
|
-
if (file.content.length < 500) {
|
|
569
|
-
results.push({ path: file.path, content: file.content });
|
|
570
|
-
continue;
|
|
571
|
-
}
|
|
572
|
-
const task = async () => {
|
|
573
|
-
try {
|
|
574
|
-
const result = await client.compact({
|
|
575
|
-
input: file.content,
|
|
576
|
-
query,
|
|
577
|
-
compressionRatio,
|
|
578
|
-
preserveRecent: 0
|
|
579
|
-
});
|
|
580
|
-
results.push({ path: file.path, content: result.output });
|
|
581
|
-
} catch (error) {
|
|
582
|
-
console.error(`[compactFileContexts] Failed to compact file ${file.path}:`, error);
|
|
583
|
-
results.push({ path: file.path, content: file.content });
|
|
584
|
-
}
|
|
585
|
-
};
|
|
586
|
-
const promise = task().finally(() => inProgress.delete(promise));
|
|
587
|
-
inProgress.add(promise);
|
|
588
|
-
if (inProgress.size >= maxConcurrency) {
|
|
589
|
-
await Promise.race(inProgress);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
await Promise.all(inProgress);
|
|
593
|
-
const orderMap = new Map(files.map((f, i) => [f.path, i]));
|
|
594
|
-
return results.sort((a, b) => (orderMap.get(a.path) ?? 0) - (orderMap.get(b.path) ?? 0));
|
|
595
|
-
}
|
|
596
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
597
|
-
0 && (module.exports = {
|
|
598
|
-
CompactClient,
|
|
599
|
-
compactFileContexts
|
|
23
|
+
Object.defineProperty(exports, "CompactClient", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkF633IVQA_cjs.CompactClient; }
|
|
600
26
|
});
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export { CompactClient } from './core.js';
|
|
2
|
+
import { R as RedactPIIOption } from '../../guard-CvW03v4u.js';
|
|
2
3
|
export { CompactConfig, CompactInput, CompactMessage, CompactResult, CompactedRange } from './types.js';
|
|
3
4
|
import '../../core/client.js';
|
|
4
5
|
import '../utils/resilience.js';
|
|
5
6
|
import '../../core/resource.js';
|
|
7
|
+
import '../pii/types.js';
|
|
6
8
|
|
|
7
9
|
declare function compactFileContexts(files: {
|
|
8
10
|
path: string;
|
|
9
11
|
content: string;
|
|
10
|
-
}[], query: string, apiKey?: string, apiUrl?: string, maxTokens?: number, maxConcurrency?: number): Promise<{
|
|
12
|
+
}[], query: string, apiKey?: string, apiUrl?: string, maxTokens?: number, maxConcurrency?: number, redactPII?: RedactPIIOption): Promise<{
|
|
11
13
|
path: string;
|
|
12
14
|
content: string;
|
|
13
15
|
}[]>;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
export {
|
|
15
|
-
CompactClient,
|
|
16
|
-
compactFileContexts
|
|
17
|
-
};
|
|
1
|
+
export { compactFileContexts } from '../../chunk-JVMIFGZY.js';
|
|
2
|
+
export { CompactClient } from '../../chunk-OX5GN2KB.js';
|
|
3
|
+
import '../../chunk-IGXNLXPN.js';
|
|
4
|
+
import '../../chunk-6WP7EA4F.js';
|
|
5
|
+
import '../../chunk-E63OPKP7.js';
|
|
6
|
+
import '../../chunk-OENJO7YW.js';
|
|
7
|
+
import '../../chunk-2GMG5XKU.js';
|
|
8
|
+
import '../../chunk-ZX6T3LNG.js';
|
|
9
|
+
import '../../chunk-564XJOQP.js';
|
|
10
|
+
import '../../chunk-4TZBUFVP.js';
|
|
11
|
+
import '../../chunk-GYE3FY6Z.js';
|
|
12
|
+
import '../../chunk-NRG6QX3L.js';
|
|
13
|
+
import '../../chunk-MLKGABMK.js';
|