@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
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkNNKBKENK_cjs = require('./chunk-NNKBKENK.cjs');
|
|
4
|
+
var chunkQEEAIXL5_cjs = require('./chunk-QEEAIXL5.cjs');
|
|
5
|
+
var chunkXE6D4J63_cjs = require('./chunk-XE6D4J63.cjs');
|
|
6
|
+
var chunk4EQQGUZ7_cjs = require('./chunk-4EQQGUZ7.cjs');
|
|
7
|
+
var fs = require('fs/promises');
|
|
8
|
+
var path = require('path');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
13
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
14
|
+
|
|
15
|
+
var SKIP_NAMES = /* @__PURE__ */ new Set([
|
|
16
|
+
// Version control
|
|
17
|
+
".git",
|
|
18
|
+
".svn",
|
|
19
|
+
".hg",
|
|
20
|
+
".bzr",
|
|
21
|
+
// Dependencies
|
|
22
|
+
"node_modules",
|
|
23
|
+
"bower_components",
|
|
24
|
+
".pnpm",
|
|
25
|
+
".yarn",
|
|
26
|
+
"vendor",
|
|
27
|
+
"Pods",
|
|
28
|
+
".bundle",
|
|
29
|
+
// Python
|
|
30
|
+
"__pycache__",
|
|
31
|
+
".pytest_cache",
|
|
32
|
+
".mypy_cache",
|
|
33
|
+
".ruff_cache",
|
|
34
|
+
".venv",
|
|
35
|
+
"venv",
|
|
36
|
+
".tox",
|
|
37
|
+
".nox",
|
|
38
|
+
".eggs",
|
|
39
|
+
// Build outputs
|
|
40
|
+
"dist",
|
|
41
|
+
"build",
|
|
42
|
+
"out",
|
|
43
|
+
"output",
|
|
44
|
+
"target",
|
|
45
|
+
"_build",
|
|
46
|
+
".next",
|
|
47
|
+
".nuxt",
|
|
48
|
+
".output",
|
|
49
|
+
".vercel",
|
|
50
|
+
".netlify",
|
|
51
|
+
// Cache
|
|
52
|
+
".cache",
|
|
53
|
+
".parcel-cache",
|
|
54
|
+
".turbo",
|
|
55
|
+
".nx",
|
|
56
|
+
".gradle",
|
|
57
|
+
// IDE
|
|
58
|
+
".idea",
|
|
59
|
+
".vscode",
|
|
60
|
+
".vs",
|
|
61
|
+
// Coverage
|
|
62
|
+
"coverage",
|
|
63
|
+
".coverage",
|
|
64
|
+
"htmlcov",
|
|
65
|
+
".nyc_output",
|
|
66
|
+
// Temp
|
|
67
|
+
"tmp",
|
|
68
|
+
"temp",
|
|
69
|
+
".tmp",
|
|
70
|
+
".temp",
|
|
71
|
+
// Lock files
|
|
72
|
+
"package-lock.json",
|
|
73
|
+
"yarn.lock",
|
|
74
|
+
"pnpm-lock.yaml",
|
|
75
|
+
"bun.lockb",
|
|
76
|
+
"Cargo.lock",
|
|
77
|
+
"Gemfile.lock",
|
|
78
|
+
"poetry.lock"
|
|
79
|
+
]);
|
|
80
|
+
var SKIP_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
81
|
+
".min.js",
|
|
82
|
+
".min.css",
|
|
83
|
+
".bundle.js",
|
|
84
|
+
".wasm",
|
|
85
|
+
".so",
|
|
86
|
+
".dll",
|
|
87
|
+
".pyc",
|
|
88
|
+
".map",
|
|
89
|
+
".js.map"
|
|
90
|
+
]);
|
|
91
|
+
function shouldSkip(name, allowNames) {
|
|
92
|
+
if (allowNames?.has(name)) return false;
|
|
93
|
+
if (SKIP_NAMES.has(name)) return true;
|
|
94
|
+
if (name.startsWith(".")) return true;
|
|
95
|
+
for (const ext of SKIP_EXTENSIONS) {
|
|
96
|
+
if (name.endsWith(ext)) return true;
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
var LocalRipgrepProvider = class {
|
|
101
|
+
constructor(repoRoot, excludes = chunk4EQQGUZ7_cjs.DEFAULT_EXCLUDES, options) {
|
|
102
|
+
this.repoRoot = repoRoot;
|
|
103
|
+
this.excludes = excludes;
|
|
104
|
+
if (options?.allowNames?.length) {
|
|
105
|
+
this.allowNames = new Set(options.allowNames);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
allowNames;
|
|
109
|
+
async grep(params) {
|
|
110
|
+
let abs;
|
|
111
|
+
try {
|
|
112
|
+
abs = chunkQEEAIXL5_cjs.resolveUnderRepo(this.repoRoot, params.path);
|
|
113
|
+
} catch (err) {
|
|
114
|
+
return {
|
|
115
|
+
lines: [],
|
|
116
|
+
error: `[PATH ERROR] ${err instanceof Error ? err.message : String(err)}`
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const stat = await fs__default.default.stat(abs).catch(() => null);
|
|
120
|
+
if (!stat) return { lines: [] };
|
|
121
|
+
const targetArg = abs === path__default.default.resolve(this.repoRoot) ? "." : chunkQEEAIXL5_cjs.toRepoRelative(this.repoRoot, abs);
|
|
122
|
+
const contextLines = params.context_lines !== void 0 ? String(params.context_lines) : "1";
|
|
123
|
+
const args = [
|
|
124
|
+
"--no-config",
|
|
125
|
+
"--no-heading",
|
|
126
|
+
"--with-filename",
|
|
127
|
+
"--line-number",
|
|
128
|
+
"--color=never",
|
|
129
|
+
"--trim",
|
|
130
|
+
"--max-columns=400",
|
|
131
|
+
"-C",
|
|
132
|
+
contextLines,
|
|
133
|
+
...params.case_sensitive === false ? ["--ignore-case"] : [],
|
|
134
|
+
...params.glob ? ["--glob", params.glob] : [],
|
|
135
|
+
...this.excludes.filter((e) => !this.allowNames?.has(e)).flatMap((e) => ["-g", `!${e}`]),
|
|
136
|
+
params.pattern,
|
|
137
|
+
targetArg || "."
|
|
138
|
+
];
|
|
139
|
+
const res = await chunkXE6D4J63_cjs.runRipgrep(args, { cwd: this.repoRoot });
|
|
140
|
+
if (res.exitCode === -1) {
|
|
141
|
+
return {
|
|
142
|
+
lines: [],
|
|
143
|
+
error: `[RIPGREP NOT AVAILABLE] ripgrep (rg) is required but failed to execute. Please install it:
|
|
144
|
+
\u2022 macOS: brew install ripgrep
|
|
145
|
+
\u2022 Ubuntu/Debian: apt install ripgrep
|
|
146
|
+
\u2022 Windows: choco install ripgrep
|
|
147
|
+
\u2022 Or visit: https://github.com/BurntSushi/ripgrep#installation
|
|
148
|
+
Exit code: ${res.exitCode}${res.stderr ? `
|
|
149
|
+
Details: ${res.stderr}` : ""}`
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (res.exitCode !== 0 && res.exitCode !== 1) {
|
|
153
|
+
return {
|
|
154
|
+
lines: [],
|
|
155
|
+
error: `[RIPGREP ERROR] grep failed with exit code ${res.exitCode}${res.stderr ? `: ${res.stderr}` : ""}`
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
159
|
+
if (lines.length > chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_OUTPUT_LINES) {
|
|
160
|
+
const truncated = lines.slice(0, chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_OUTPUT_LINES);
|
|
161
|
+
truncated.push(`... (output truncated at ${chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
|
|
162
|
+
return { lines: truncated };
|
|
163
|
+
}
|
|
164
|
+
return { lines };
|
|
165
|
+
}
|
|
166
|
+
async read(params) {
|
|
167
|
+
let abs;
|
|
168
|
+
try {
|
|
169
|
+
abs = chunkQEEAIXL5_cjs.resolveUnderRepo(this.repoRoot, params.path);
|
|
170
|
+
} catch (err) {
|
|
171
|
+
return {
|
|
172
|
+
lines: [],
|
|
173
|
+
error: `[PATH ERROR] ${err instanceof Error ? err.message : String(err)}`
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
let stat = await fs__default.default.stat(abs).catch(() => null);
|
|
177
|
+
if (!stat || !stat.isFile()) {
|
|
178
|
+
const fixedPath = chunkQEEAIXL5_cjs.fixPathRepetition(abs);
|
|
179
|
+
if (fixedPath) {
|
|
180
|
+
const fixedStat = await fs__default.default.stat(fixedPath).catch(() => null);
|
|
181
|
+
if (fixedStat?.isFile()) {
|
|
182
|
+
abs = fixedPath;
|
|
183
|
+
stat = fixedStat;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (!stat || !stat.isFile()) {
|
|
188
|
+
return {
|
|
189
|
+
lines: [],
|
|
190
|
+
error: `[FILE NOT FOUND] You tried to read "${params.path}" but there is no file at this path. Double-check the path exists and is spelled correctly.`
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (chunkQEEAIXL5_cjs.isSymlink(abs)) {
|
|
194
|
+
return {
|
|
195
|
+
lines: [],
|
|
196
|
+
error: `[SYMLINK] You tried to read "${params.path}" but this is a symlink. Try reading the actual file it points to instead.`
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (!chunkQEEAIXL5_cjs.isTextualFile(abs)) {
|
|
200
|
+
return {
|
|
201
|
+
lines: [],
|
|
202
|
+
error: `[UNREADABLE FILE] You tried to read "${params.path}" but this file is either too large or not a text file, so it cannot be read. Try a different file.`
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
let lines;
|
|
206
|
+
try {
|
|
207
|
+
lines = await chunkNNKBKENK_cjs.readAllLines(abs);
|
|
208
|
+
} catch (err) {
|
|
209
|
+
return {
|
|
210
|
+
lines: [],
|
|
211
|
+
error: `[READ ERROR] Failed to read "${params.path}": ${err instanceof Error ? err.message : String(err)}`
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
const total = lines.length;
|
|
215
|
+
const rawStart = params.start;
|
|
216
|
+
const rawEnd = params.end;
|
|
217
|
+
let s = 1;
|
|
218
|
+
let e = total;
|
|
219
|
+
const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
|
|
220
|
+
const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
|
|
221
|
+
if (startValid && endValid) {
|
|
222
|
+
s = rawStart ?? 1;
|
|
223
|
+
e = Math.min(rawEnd ?? total, total);
|
|
224
|
+
if (s > total && total > 0 || s > e) {
|
|
225
|
+
s = 1;
|
|
226
|
+
e = total;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const out = [];
|
|
230
|
+
for (let i = s; i <= e; i += 1) {
|
|
231
|
+
const content = lines[i - 1] ?? "";
|
|
232
|
+
out.push(`${i}|${content}`);
|
|
233
|
+
}
|
|
234
|
+
if (out.length > chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_READ_LINES) {
|
|
235
|
+
const truncated = out.slice(0, chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_READ_LINES);
|
|
236
|
+
truncated.push(`... (output truncated at ${chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines)`);
|
|
237
|
+
return { lines: truncated };
|
|
238
|
+
}
|
|
239
|
+
return { lines: out };
|
|
240
|
+
}
|
|
241
|
+
async listDirectory(params) {
|
|
242
|
+
let abs;
|
|
243
|
+
try {
|
|
244
|
+
abs = chunkQEEAIXL5_cjs.resolveUnderRepo(this.repoRoot, params.path);
|
|
245
|
+
} catch {
|
|
246
|
+
return [];
|
|
247
|
+
}
|
|
248
|
+
const stat = await fs__default.default.stat(abs).catch(() => null);
|
|
249
|
+
if (!stat || !stat.isDirectory()) {
|
|
250
|
+
return [];
|
|
251
|
+
}
|
|
252
|
+
const maxResults = params.maxResults ?? chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_OUTPUT_LINES;
|
|
253
|
+
const maxDepth = params.maxDepth ?? chunk4EQQGUZ7_cjs.AGENT_CONFIG.MAX_LIST_DEPTH;
|
|
254
|
+
const regex = params.pattern ? new RegExp(params.pattern) : null;
|
|
255
|
+
const repoRoot = this.repoRoot;
|
|
256
|
+
const allowNames = this.allowNames;
|
|
257
|
+
const results = [];
|
|
258
|
+
let timedOut = false;
|
|
259
|
+
const startTime = Date.now();
|
|
260
|
+
async function walk(dir, depth) {
|
|
261
|
+
if (Date.now() - startTime > chunk4EQQGUZ7_cjs.AGENT_CONFIG.LIST_TIMEOUT_MS) {
|
|
262
|
+
timedOut = true;
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (depth > maxDepth || results.length >= maxResults) return;
|
|
266
|
+
let entries;
|
|
267
|
+
try {
|
|
268
|
+
entries = await fs__default.default.readdir(dir, { withFileTypes: true });
|
|
269
|
+
} catch {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
for (const entry of entries) {
|
|
273
|
+
if (timedOut || results.length >= maxResults) break;
|
|
274
|
+
if (shouldSkip(entry.name, allowNames)) continue;
|
|
275
|
+
if (regex && !regex.test(entry.name)) continue;
|
|
276
|
+
const full = path__default.default.join(dir, entry.name);
|
|
277
|
+
const isDir = entry.isDirectory();
|
|
278
|
+
results.push({
|
|
279
|
+
name: entry.name,
|
|
280
|
+
path: chunkQEEAIXL5_cjs.toRepoRelative(repoRoot, full),
|
|
281
|
+
type: isDir ? "dir" : "file",
|
|
282
|
+
depth
|
|
283
|
+
});
|
|
284
|
+
if (isDir) {
|
|
285
|
+
await walk(full, depth + 1);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
await walk(abs, 0);
|
|
290
|
+
return results;
|
|
291
|
+
}
|
|
292
|
+
async glob(params) {
|
|
293
|
+
let abs;
|
|
294
|
+
try {
|
|
295
|
+
abs = params.path ? chunkQEEAIXL5_cjs.resolveUnderRepo(this.repoRoot, params.path) : this.repoRoot;
|
|
296
|
+
} catch (err) {
|
|
297
|
+
return { files: [], searchDir: this.repoRoot, totalFound: 0, error: `[PATH ERROR] ${err instanceof Error ? err.message : String(err)}` };
|
|
298
|
+
}
|
|
299
|
+
const stat = await fs__default.default.stat(abs).catch(() => null);
|
|
300
|
+
if (!stat || !stat.isDirectory()) {
|
|
301
|
+
return { files: [], searchDir: abs, totalFound: 0, error: `[PATH ERROR] Directory not found: ${params.path || "."}` };
|
|
302
|
+
}
|
|
303
|
+
const targetArg = abs === path__default.default.resolve(this.repoRoot) ? "." : chunkQEEAIXL5_cjs.toRepoRelative(this.repoRoot, abs);
|
|
304
|
+
const args = [
|
|
305
|
+
"--no-config",
|
|
306
|
+
"--files",
|
|
307
|
+
"--color=never",
|
|
308
|
+
"-g",
|
|
309
|
+
params.pattern,
|
|
310
|
+
...this.excludes.filter((e) => !this.allowNames?.has(e)).flatMap((e) => ["-g", `!${e}`]),
|
|
311
|
+
targetArg || "."
|
|
312
|
+
];
|
|
313
|
+
const res = await chunkXE6D4J63_cjs.runRipgrep(args, { cwd: this.repoRoot });
|
|
314
|
+
if (res.exitCode === -1) {
|
|
315
|
+
return { files: [], searchDir: abs, totalFound: 0, error: `[RIPGREP NOT AVAILABLE] ripgrep (rg) is required for glob search.` };
|
|
316
|
+
}
|
|
317
|
+
if (res.exitCode !== 0 && res.exitCode !== 1) {
|
|
318
|
+
return { files: [], searchDir: abs, totalFound: 0, error: `[GLOB ERROR] glob failed with exit code ${res.exitCode}${res.stderr ? `: ${res.stderr}` : ""}` };
|
|
319
|
+
}
|
|
320
|
+
const absRoot = path__default.default.resolve(this.repoRoot);
|
|
321
|
+
const relFiles = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
322
|
+
const absFiles = relFiles.map((f) => path__default.default.resolve(absRoot, f));
|
|
323
|
+
const withMtime = [];
|
|
324
|
+
for (const f of absFiles) {
|
|
325
|
+
const s = await fs__default.default.stat(f).catch(() => null);
|
|
326
|
+
withMtime.push({ file: f, mtime: s?.mtimeMs ?? 0 });
|
|
327
|
+
}
|
|
328
|
+
withMtime.sort((a, b) => b.mtime - a.mtime);
|
|
329
|
+
const totalFound = withMtime.length;
|
|
330
|
+
return { files: withMtime.slice(0, 100).map((f) => f.file), searchDir: abs, totalFound };
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
exports.LocalRipgrepProvider = LocalRipgrepProvider;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
formatResult
|
|
4
|
-
} from "./chunk-3CPI6ZIC.js";
|
|
5
|
-
import {
|
|
6
|
-
CODEBASE_SEARCH_TOOL,
|
|
7
|
-
SEND_MESSAGE_TOOL,
|
|
8
|
-
getSystemPrompt
|
|
9
|
-
} from "./chunk-ETBRAKVV.js";
|
|
1
|
+
import { WarpGrepClient, formatResult } from './chunk-DZP7BR66.js';
|
|
2
|
+
import { CODEBASE_SEARCH_TOOL, SEND_MESSAGE_TOOL, getSystemPrompt } from './chunk-ETBRAKVV.js';
|
|
10
3
|
|
|
11
4
|
// subagents/anthropic.ts
|
|
12
5
|
var DEFAULT_MAX_TURNS = {
|
|
@@ -282,6 +275,4 @@ function deduplicateContexts(contexts) {
|
|
|
282
275
|
return Array.from(map.values());
|
|
283
276
|
}
|
|
284
277
|
|
|
285
|
-
export {
|
|
286
|
-
createExploreSubagent
|
|
287
|
-
};
|
|
278
|
+
export { createExploreSubagent };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// tools/warp_grep/prompts.ts
|
|
4
|
+
var WARP_GREP_TOOL_NAME = "codebase_search";
|
|
5
|
+
var WARP_GREP_DESCRIPTION = 'Very fast code search exploration subagent (not a grep tool) that runs parallel grep and file read calls over multiple turns to locate relevant files and line ranges. The search term should be a targeted natural-language query describing what you are trying to find or accomplish, e.g. "Find where authentication requests are handled in the Express routes" or "How do callers of processOrder handle the error case?". Fill in extra context you can infer to make the query specific. Do not pass bare keywords or symbol names \u2014 use grep directly for exact symbol lookups. Use this tool first when exploring unfamiliar code. The results may be partial \u2014 follow up with classical search tools or direct file reads if needed.';
|
|
6
|
+
var GITHUB_WARP_GREP_SEARCH_TOOL_NAME = "github_codebase_search";
|
|
7
|
+
var GITHUB_WARP_GREP_SEARCH_DESCRIPTION = "Always use this when debugging errors in third-party dependencies to check for upstream fixes, open issues, or newer code pathsSearch tool for public GitHub repositories.Code search exploration subagent for public GitHub repositories (not your local workspace \u2014 use codebase_search for that). Runs parallel grep and file read calls to locate relevant files and line ranges in external github repositories without cloning the repository. Pass a targeted natural-language query, not bare keywords. Useful for understanding how a library works or investigating upstream bugs. You must provide either github_url or owner_repo (at least one required). ";
|
|
8
|
+
var GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA = {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
search_term: { type: "string", description: 'A targeted natural-language query describing what to find (e.g. "How does auth work for SSO users?"). Not a keyword or symbol name.' },
|
|
12
|
+
github_url: { type: "string", description: 'GitHub repository URL to search (e.g. "https://github.com/vercel/next.js"). You must provide either github_url or owner_repo.' },
|
|
13
|
+
owner_repo: { type: "string", description: 'Repository owner/repo shorthand (e.g. "vercel/next.js"). You must provide either github_url or owner_repo.' },
|
|
14
|
+
branch: { type: "string", description: "Branch to search (defaults to the repository default branch)" }
|
|
15
|
+
},
|
|
16
|
+
required: ["search_term"]
|
|
17
|
+
};
|
|
18
|
+
var GITHUB_SEARCH_TOOL_NAME = GITHUB_WARP_GREP_SEARCH_TOOL_NAME;
|
|
19
|
+
var GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;
|
|
20
|
+
var GITHUB_SEARCH_INPUT_SCHEMA = GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA;
|
|
21
|
+
var GITHUB_READ_FILE_TOOL_NAME = "readfile_github_search";
|
|
22
|
+
var GITHUB_READ_FILE_DESCRIPTION = "Read a single file (or a line range) from a public GitHub repository. ONLY USE THIS WHEN YOU ALREADY KNOW THE EXACT FILE PATH YOU WANT TO READ, for example after finding it via github_codebase_search results. Takes owner/repo shorthand and the file path within the repo. Optionally specify startLine and endLine (1-based) to read a specific range. Returns the file content with line numbers.";
|
|
23
|
+
var GITHUB_READ_FILE_INPUT_SCHEMA = {
|
|
24
|
+
type: "object",
|
|
25
|
+
properties: {
|
|
26
|
+
github: { type: "string", description: 'owner/repo shorthand (e.g., "vercel/next.js")' },
|
|
27
|
+
path: { type: "string", description: 'File path within the repository (e.g., "src/server/index.ts")' },
|
|
28
|
+
startLine: { type: "number", description: "Start line number (1-based). Omit to start from beginning." },
|
|
29
|
+
endLine: { type: "number", description: "End line number (1-based, inclusive). Omit to read to the end." },
|
|
30
|
+
branch: { type: "string", description: "Branch to read from (defaults to the repository default branch)" }
|
|
31
|
+
},
|
|
32
|
+
required: ["github", "path"]
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.GITHUB_READ_FILE_DESCRIPTION = GITHUB_READ_FILE_DESCRIPTION;
|
|
36
|
+
exports.GITHUB_READ_FILE_INPUT_SCHEMA = GITHUB_READ_FILE_INPUT_SCHEMA;
|
|
37
|
+
exports.GITHUB_READ_FILE_TOOL_NAME = GITHUB_READ_FILE_TOOL_NAME;
|
|
38
|
+
exports.GITHUB_SEARCH_DESCRIPTION = GITHUB_SEARCH_DESCRIPTION;
|
|
39
|
+
exports.GITHUB_SEARCH_INPUT_SCHEMA = GITHUB_SEARCH_INPUT_SCHEMA;
|
|
40
|
+
exports.GITHUB_SEARCH_TOOL_NAME = GITHUB_SEARCH_TOOL_NAME;
|
|
41
|
+
exports.WARP_GREP_DESCRIPTION = WARP_GREP_DESCRIPTION;
|
|
42
|
+
exports.WARP_GREP_TOOL_NAME = WARP_GREP_TOOL_NAME;
|
package/dist/chunk-ETBRAKVV.js
CHANGED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk5TTZQF4X_cjs = require('./chunk-5TTZQF4X.cjs');
|
|
4
|
+
var chunkWJHHO24M_cjs = require('./chunk-WJHHO24M.cjs');
|
|
5
|
+
var chunkAWFZKS27_cjs = require('./chunk-AWFZKS27.cjs');
|
|
6
|
+
|
|
7
|
+
// tools/compact/core.ts
|
|
8
|
+
var DEFAULT_API_URL = "https://api.morphllm.com";
|
|
9
|
+
var DEFAULT_TIMEOUT = 12e4;
|
|
10
|
+
function resolveClient(clientOrConfig) {
|
|
11
|
+
if (clientOrConfig instanceof chunk5TTZQF4X_cjs.MorphAPIClient) return clientOrConfig;
|
|
12
|
+
return new chunk5TTZQF4X_cjs.MorphAPIClient({
|
|
13
|
+
apiKey: clientOrConfig.morphApiKey,
|
|
14
|
+
baseURL: clientOrConfig.morphApiUrl ?? DEFAULT_API_URL,
|
|
15
|
+
timeout: clientOrConfig.timeout ?? DEFAULT_TIMEOUT,
|
|
16
|
+
retryConfig: clientOrConfig.retryConfig,
|
|
17
|
+
debug: clientOrConfig.debug,
|
|
18
|
+
redactPII: clientOrConfig.redactPII
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
var CompactClient = class extends chunkAWFZKS27_cjs.APIResource {
|
|
22
|
+
/** Resolved URL/timeout, exposed for backwards-compatible introspection. */
|
|
23
|
+
config;
|
|
24
|
+
constructor(clientOrConfig = {}) {
|
|
25
|
+
super(resolveClient(clientOrConfig));
|
|
26
|
+
const cfg = clientOrConfig instanceof chunk5TTZQF4X_cjs.MorphAPIClient ? {} : clientOrConfig;
|
|
27
|
+
this.config = {
|
|
28
|
+
morphApiUrl: this._client.baseURL,
|
|
29
|
+
timeout: cfg.timeout ?? DEFAULT_TIMEOUT,
|
|
30
|
+
debug: cfg.debug ?? false
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Compact messages or text via /v1/compact.
|
|
35
|
+
* Returns per-message `compacted_line_ranges` showing which lines were removed.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const client = new CompactClient({ morphApiKey: 'sk-...' });
|
|
40
|
+
* const result = await client.compact({
|
|
41
|
+
* input: codeFile,
|
|
42
|
+
* query: "authentication",
|
|
43
|
+
* compressionRatio: 0.5,
|
|
44
|
+
* });
|
|
45
|
+
* console.log(result.output);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
async compact(input) {
|
|
49
|
+
const body = {
|
|
50
|
+
compression_ratio: input.compressionRatio ?? 0.5,
|
|
51
|
+
preserve_recent: input.preserveRecent ?? 2,
|
|
52
|
+
model: input.model ?? "morph-compactor",
|
|
53
|
+
include_line_ranges: input.includeLineRanges ?? true,
|
|
54
|
+
include_markers: input.includeMarkers ?? true
|
|
55
|
+
};
|
|
56
|
+
if (input.query !== void 0) body.query = input.query;
|
|
57
|
+
if (input.messages) body.messages = input.messages;
|
|
58
|
+
else if (typeof input.input === "string") body.input = input.input;
|
|
59
|
+
else if (Array.isArray(input.input)) body.messages = input.input;
|
|
60
|
+
else throw new Error("Either 'input' or 'messages' must be provided");
|
|
61
|
+
const pii = this._client.pii?.session();
|
|
62
|
+
if (pii) {
|
|
63
|
+
if (typeof body.query === "string") body.query = await pii.redact(body.query);
|
|
64
|
+
if (typeof body.input === "string") body.input = await pii.redact(body.input);
|
|
65
|
+
if (Array.isArray(body.messages)) {
|
|
66
|
+
body.messages = await Promise.all(
|
|
67
|
+
body.messages.map(
|
|
68
|
+
async (m) => typeof m.content === "string" ? { ...m, content: await pii.redact(m.content) } : m
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const result = await this._client.post("/v1/compact", { body, timeout: this.config.timeout });
|
|
75
|
+
if (pii && result) {
|
|
76
|
+
if (typeof result.output === "string") result.output = pii.restore(result.output);
|
|
77
|
+
for (const m of result.messages ?? []) {
|
|
78
|
+
if (typeof m.content === "string") m.content = pii.restore(m.content);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
} catch (err) {
|
|
83
|
+
if (err instanceof chunkWJHHO24M_cjs.MorphError) {
|
|
84
|
+
throw new Error(`Compact API error ${err.statusCode}: ${err.message}`);
|
|
85
|
+
}
|
|
86
|
+
throw err;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
exports.CompactClient = CompactClient;
|
package/dist/chunk-FBOZIVVQ.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,33 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
toolListDirectory,
|
|
10
|
-
toolRead
|
|
11
|
-
} from "./chunk-44OIEPIO.js";
|
|
12
|
-
import {
|
|
13
|
-
AGENT_CONFIG,
|
|
14
|
-
DEFAULT_MODEL
|
|
15
|
-
} from "./chunk-M34E2AMK.js";
|
|
16
|
-
import {
|
|
17
|
-
extractPathFromCommand,
|
|
18
|
-
parseFinishFiles,
|
|
19
|
-
parseReadLines
|
|
20
|
-
} from "./chunk-4OUGA3KS.js";
|
|
21
|
-
import {
|
|
22
|
-
logger
|
|
23
|
-
} from "./chunk-6WP7EA4F.js";
|
|
24
|
-
import {
|
|
25
|
-
SDK_VERSION
|
|
26
|
-
} from "./chunk-E6TL6MIH.js";
|
|
1
|
+
import { buildInitialState, enforceContextLimit, formatTurnMessage, calculateContextBudget, readFinishFiles, toolRead, toolListDirectory, toolGlob, toolGrep } from './chunk-44OIEPIO.js';
|
|
2
|
+
import { parseFinishFiles, parseReadLines, extractPathFromCommand } from './chunk-4OUGA3KS.js';
|
|
3
|
+
import { AGENT_CONFIG, DEFAULT_MODEL } from './chunk-M34E2AMK.js';
|
|
4
|
+
import { logger } from './chunk-6WP7EA4F.js';
|
|
5
|
+
import { resolvePIIGuard } from './chunk-E63OPKP7.js';
|
|
6
|
+
import { SDK_VERSION } from './chunk-GYE3FY6Z.js';
|
|
7
|
+
import OpenAI from 'openai';
|
|
8
|
+
import path from 'path';
|
|
27
9
|
|
|
28
|
-
// tools/warp_grep/agent/runner.ts
|
|
29
|
-
import OpenAI from "openai";
|
|
30
|
-
import path from "path";
|
|
31
10
|
var DEFAULT_API_URL = "https://api.morphllm.com";
|
|
32
11
|
var TOOL_SPECS = [
|
|
33
12
|
{
|
|
@@ -136,6 +115,23 @@ var TOOL_SPECS = [
|
|
|
136
115
|
}
|
|
137
116
|
}
|
|
138
117
|
];
|
|
118
|
+
async function redactMessages(messages, pii) {
|
|
119
|
+
return Promise.all(
|
|
120
|
+
messages.map(async (message) => {
|
|
121
|
+
const out = { ...message };
|
|
122
|
+
if (typeof message.content === "string") out.content = await pii.redact(message.content);
|
|
123
|
+
if (message.role === "assistant" && out.role === "assistant" && message.tool_calls) {
|
|
124
|
+
out.tool_calls = await Promise.all(
|
|
125
|
+
message.tool_calls.map(async (tc) => ({
|
|
126
|
+
...tc,
|
|
127
|
+
function: { ...tc.function, arguments: await pii.redact(tc.function.arguments) }
|
|
128
|
+
}))
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
return out;
|
|
132
|
+
})
|
|
133
|
+
);
|
|
134
|
+
}
|
|
139
135
|
async function callModel(messages, model, options = {}) {
|
|
140
136
|
const baseUrl = options.morphApiUrl || DEFAULT_API_URL;
|
|
141
137
|
const apiKey = options.morphApiKey || process.env.MORPH_API_KEY || "";
|
|
@@ -150,6 +146,8 @@ async function callModel(messages, model, options = {}) {
|
|
|
150
146
|
defaultHeaders: { "X-Morph-SDK-Version": SDK_VERSION }
|
|
151
147
|
});
|
|
152
148
|
const MAX_EMPTY_RETRIES = 1;
|
|
149
|
+
const pii = options.pii;
|
|
150
|
+
const outgoing = pii ? await redactMessages(messages, pii) : messages;
|
|
153
151
|
logger.debug("WarpGrep", "model_call", { url: baseURL, model, message_count: messages.length });
|
|
154
152
|
const callStartTime = Date.now();
|
|
155
153
|
for (let attempt = 0; attempt <= MAX_EMPTY_RETRIES; attempt++) {
|
|
@@ -159,7 +157,7 @@ async function callModel(messages, model, options = {}) {
|
|
|
159
157
|
model,
|
|
160
158
|
temperature: 0,
|
|
161
159
|
max_tokens: 2048,
|
|
162
|
-
messages,
|
|
160
|
+
messages: outgoing,
|
|
163
161
|
tools: TOOL_SPECS,
|
|
164
162
|
...options.search_type ? { search_type: options.search_type } : {}
|
|
165
163
|
});
|
|
@@ -189,11 +187,12 @@ async function callModel(messages, model, options = {}) {
|
|
|
189
187
|
const toolCalls = (message.tool_calls || []).map((tc) => ({
|
|
190
188
|
id: tc.id,
|
|
191
189
|
type: "function",
|
|
192
|
-
|
|
190
|
+
// Restore real values so grep patterns and file paths work against the local repo.
|
|
191
|
+
function: { name: tc.function.name, arguments: pii ? pii.restore(tc.function.arguments) : tc.function.arguments }
|
|
193
192
|
}));
|
|
194
193
|
if (message.content || toolCalls.length > 0) {
|
|
195
194
|
logger.debug("WarpGrep", "model_call_complete", { latency_ms: Date.now() - callStartTime, tool_calls_count: toolCalls.length, finish_reason: choice?.finish_reason ?? "unknown" });
|
|
196
|
-
return { content: message.content ?? null, tool_calls: toolCalls };
|
|
195
|
+
return { content: pii ? pii.restore(message.content ?? null) ?? null : message.content ?? null, tool_calls: toolCalls };
|
|
197
196
|
}
|
|
198
197
|
if (attempt === MAX_EMPTY_RETRIES) {
|
|
199
198
|
const finishReason = choice?.finish_reason ?? "unknown";
|
|
@@ -262,6 +261,7 @@ async function* runWarpGrepStreaming(config) {
|
|
|
262
261
|
const repoRoot = config.repoRoot || process.cwd();
|
|
263
262
|
const model = config.model || DEFAULT_MODEL;
|
|
264
263
|
const messages = [];
|
|
264
|
+
const pii = resolvePIIGuard(config.redactPII)?.session();
|
|
265
265
|
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
266
266
|
logger.debug("WarpGrep", "session_start", { search_term: config.searchTerm, model, max_turns: maxTurns });
|
|
267
267
|
const initialStateStart = Date.now();
|
|
@@ -288,7 +288,8 @@ async function* runWarpGrepStreaming(config) {
|
|
|
288
288
|
morphApiUrl: config.morphApiUrl,
|
|
289
289
|
retryConfig: config.retryConfig,
|
|
290
290
|
timeout: timeoutMs,
|
|
291
|
-
search_type: config.search_type
|
|
291
|
+
search_type: config.search_type,
|
|
292
|
+
pii
|
|
292
293
|
}).catch((e) => {
|
|
293
294
|
const errMsg = e instanceof Error ? e.message : String(e);
|
|
294
295
|
console.error(`[warp_grep] Morph API call failed on turn ${turn}:`, errMsg);
|
|
@@ -421,7 +422,4 @@ async function runWarpGrep(config) {
|
|
|
421
422
|
return result.value;
|
|
422
423
|
}
|
|
423
424
|
|
|
424
|
-
export {
|
|
425
|
-
runWarpGrepStreaming,
|
|
426
|
-
runWarpGrep
|
|
427
|
-
};
|
|
425
|
+
export { runWarpGrep, runWarpGrepStreaming };
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./chunk-PA3UTI4A.js";
|
|
5
|
-
import {
|
|
6
|
-
executeEditFile
|
|
7
|
-
} from "./chunk-65TUD7JV.js";
|
|
8
|
-
import {
|
|
9
|
-
__export
|
|
10
|
-
} from "./chunk-MLKGABMK.js";
|
|
1
|
+
import { EDIT_FILE_TOOL_DESCRIPTION, EDIT_FILE_SYSTEM_PROMPT } from './chunk-PA3UTI4A.js';
|
|
2
|
+
import { executeEditFile } from './chunk-DYCMPDPV.js';
|
|
3
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
11
4
|
|
|
12
5
|
// tools/fastapply/openai.ts
|
|
13
6
|
var openai_exports = {};
|
|
@@ -82,12 +75,4 @@ function createEditFileTool(config = {}) {
|
|
|
82
75
|
}
|
|
83
76
|
var openai_default = editFileTool;
|
|
84
77
|
|
|
85
|
-
export {
|
|
86
|
-
editFileTool,
|
|
87
|
-
execute,
|
|
88
|
-
getSystemPrompt,
|
|
89
|
-
formatResult,
|
|
90
|
-
createEditFileTool,
|
|
91
|
-
openai_default,
|
|
92
|
-
openai_exports
|
|
93
|
-
};
|
|
78
|
+
export { createEditFileTool, editFileTool, execute, formatResult, getSystemPrompt, openai_default, openai_exports };
|