@morphllm/morphsdk 0.2.56 → 0.2.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/anthropic-CaFUHxBW.d.ts +89 -0
- package/dist/{chunk-SALJ2K6S.js → chunk-2CASO3ZO.js} +60 -98
- package/dist/chunk-2CASO3ZO.js.map +1 -0
- package/dist/chunk-374N3GIA.js +118 -0
- package/dist/chunk-374N3GIA.js.map +1 -0
- package/dist/chunk-3IQIT6MC.js +65 -0
- package/dist/chunk-3IQIT6MC.js.map +1 -0
- package/dist/chunk-4VGOBA2J.js +57 -0
- package/dist/chunk-4VGOBA2J.js.map +1 -0
- package/dist/chunk-527P5X2E.js +98 -0
- package/dist/chunk-527P5X2E.js.map +1 -0
- package/dist/chunk-6N6ZYZYD.js +74 -0
- package/dist/chunk-6N6ZYZYD.js.map +1 -0
- package/dist/chunk-6Y5JB4JC.js +195 -0
- package/dist/chunk-6Y5JB4JC.js.map +1 -0
- package/dist/{chunk-WSSSSBWU.js → chunk-7EIHYJSG.js} +18 -18
- package/dist/chunk-7EIHYJSG.js.map +1 -0
- package/dist/{chunk-TICMYDII.js → chunk-APP75CBN.js} +33 -16
- package/dist/chunk-APP75CBN.js.map +1 -0
- package/dist/chunk-ILJ3J5IA.js +72 -0
- package/dist/chunk-ILJ3J5IA.js.map +1 -0
- package/dist/chunk-ISWL67SF.js +1 -0
- package/dist/chunk-KW7OEGZK.js +9 -0
- package/dist/chunk-KW7OEGZK.js.map +1 -0
- package/dist/chunk-Q5AHGIQO.js +205 -0
- package/dist/chunk-Q5AHGIQO.js.map +1 -0
- package/dist/{chunk-TJIUA27P.js → chunk-XT5ZO6ES.js} +9 -5
- package/dist/chunk-XT5ZO6ES.js.map +1 -0
- package/dist/{chunk-LVPVVLTI.js → chunk-YV75OQTE.js} +105 -17
- package/dist/chunk-YV75OQTE.js.map +1 -0
- package/dist/{chunk-ZJIIICRA.js → chunk-ZO4PPFCZ.js} +60 -29
- package/dist/chunk-ZO4PPFCZ.js.map +1 -0
- package/dist/{client-CFoR--IU.d.ts → client-CextMMm9.d.ts} +10 -15
- package/dist/client.cjs +698 -466
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +3 -2
- package/dist/client.js +14 -15
- package/dist/finish-kXAcUJyB.d.ts +33 -0
- package/dist/gemini-CE80Pbdy.d.ts +117 -0
- package/dist/index.cjs +711 -466
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +16 -16
- package/dist/openai-Fvpqln7F.d.ts +89 -0
- package/dist/tools/warp_grep/agent/config.cjs +8 -4
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/config.d.ts +7 -2
- package/dist/tools/warp_grep/agent/config.js +1 -1
- package/dist/tools/warp_grep/agent/formatter.cjs +32 -15
- package/dist/tools/warp_grep/agent/formatter.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/formatter.d.ts +1 -1
- package/dist/tools/warp_grep/agent/formatter.js +1 -1
- package/dist/tools/warp_grep/agent/parser.cjs +104 -17
- package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/parser.d.ts +3 -5
- package/dist/tools/warp_grep/agent/parser.js +1 -3
- package/dist/tools/warp_grep/agent/prompt.cjs +132 -56
- package/dist/tools/warp_grep/agent/prompt.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/prompt.d.ts +1 -1
- package/dist/tools/warp_grep/agent/prompt.js +1 -1
- package/dist/tools/warp_grep/agent/runner.cjs +466 -313
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.d.ts +1 -0
- package/dist/tools/warp_grep/agent/runner.js +6 -9
- package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/types.d.ts +9 -2
- package/dist/tools/warp_grep/anthropic.cjs +656 -380
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +4 -74
- package/dist/tools/warp_grep/anthropic.js +13 -16
- package/dist/tools/warp_grep/client.cjs +1593 -0
- package/dist/tools/warp_grep/client.cjs.map +1 -0
- package/dist/tools/warp_grep/client.d.ts +87 -0
- package/dist/tools/warp_grep/client.js +26 -0
- package/dist/tools/warp_grep/gemini.cjs +1587 -0
- package/dist/tools/warp_grep/gemini.cjs.map +1 -0
- package/dist/tools/warp_grep/gemini.d.ts +7 -0
- package/dist/tools/warp_grep/gemini.js +34 -0
- package/dist/tools/warp_grep/harness.cjs +1195 -0
- package/dist/tools/warp_grep/harness.cjs.map +1 -0
- package/dist/tools/warp_grep/harness.d.ts +107 -0
- package/dist/tools/warp_grep/harness.js +68 -0
- package/dist/tools/warp_grep/harness.js.map +1 -0
- package/dist/tools/warp_grep/index.cjs +818 -466
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +11 -6
- package/dist/tools/warp_grep/index.js +43 -23
- package/dist/tools/warp_grep/openai.cjs +656 -378
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +4 -74
- package/dist/tools/warp_grep/openai.js +13 -14
- package/dist/tools/warp_grep/providers/local.cjs +66 -27
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/local.d.ts +4 -9
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/providers/remote.cjs +211 -0
- package/dist/tools/warp_grep/providers/remote.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/remote.d.ts +67 -0
- package/dist/tools/warp_grep/providers/remote.js +9 -0
- package/dist/tools/warp_grep/providers/types.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/types.d.ts +7 -15
- package/dist/tools/warp_grep/vercel.cjs +668 -397
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +4 -51
- package/dist/tools/warp_grep/vercel.js +16 -15
- package/dist/types-a_hxdPI6.d.ts +144 -0
- package/dist/vercel-3yjvfmVB.d.ts +66 -0
- package/package.json +17 -2
- package/dist/chunk-4ZHDBKBY.js +0 -83
- package/dist/chunk-4ZHDBKBY.js.map +0 -1
- package/dist/chunk-73RQWOQC.js +0 -16
- package/dist/chunk-73RQWOQC.js.map +0 -1
- package/dist/chunk-7OQOOB3R.js +0 -1
- package/dist/chunk-EK7OQPWD.js +0 -44
- package/dist/chunk-EK7OQPWD.js.map +0 -1
- package/dist/chunk-GJURLQ3L.js +0 -77
- package/dist/chunk-GJURLQ3L.js.map +0 -1
- package/dist/chunk-HQO45BAJ.js +0 -14
- package/dist/chunk-HQO45BAJ.js.map +0 -1
- package/dist/chunk-LVPVVLTI.js.map +0 -1
- package/dist/chunk-NDZO5IPV.js +0 -121
- package/dist/chunk-NDZO5IPV.js.map +0 -1
- package/dist/chunk-QVRXBAMM.js +0 -107
- package/dist/chunk-QVRXBAMM.js.map +0 -1
- package/dist/chunk-SALJ2K6S.js.map +0 -1
- package/dist/chunk-TICMYDII.js.map +0 -1
- package/dist/chunk-TJIUA27P.js.map +0 -1
- package/dist/chunk-UIRJE422.js +0 -70
- package/dist/chunk-UIRJE422.js.map +0 -1
- package/dist/chunk-WETRQJGU.js +0 -129
- package/dist/chunk-WETRQJGU.js.map +0 -1
- package/dist/chunk-WSSSSBWU.js.map +0 -1
- package/dist/chunk-ZJIIICRA.js.map +0 -1
- package/dist/core-CpkYEi_T.d.ts +0 -158
- package/dist/tools/warp_grep/agent/grep_helpers.cjs +0 -148
- package/dist/tools/warp_grep/agent/grep_helpers.cjs.map +0 -1
- package/dist/tools/warp_grep/agent/grep_helpers.d.ts +0 -16
- package/dist/tools/warp_grep/agent/grep_helpers.js +0 -14
- package/dist/tools/warp_grep/tools/analyse.cjs +0 -40
- package/dist/tools/warp_grep/tools/analyse.cjs.map +0 -1
- package/dist/tools/warp_grep/tools/analyse.d.ts +0 -10
- package/dist/tools/warp_grep/tools/analyse.js +0 -8
- package/dist/tools/warp_grep/tools/finish.cjs +0 -69
- package/dist/tools/warp_grep/tools/finish.cjs.map +0 -1
- package/dist/tools/warp_grep/tools/finish.d.ts +0 -10
- package/dist/tools/warp_grep/tools/finish.js +0 -10
- package/dist/tools/warp_grep/tools/grep.cjs +0 -38
- package/dist/tools/warp_grep/tools/grep.cjs.map +0 -1
- package/dist/tools/warp_grep/tools/grep.d.ts +0 -8
- package/dist/tools/warp_grep/tools/grep.js +0 -15
- package/dist/tools/warp_grep/tools/grep.js.map +0 -1
- package/dist/tools/warp_grep/tools/read.cjs +0 -38
- package/dist/tools/warp_grep/tools/read.cjs.map +0 -1
- package/dist/tools/warp_grep/tools/read.d.ts +0 -9
- package/dist/tools/warp_grep/tools/read.js +0 -8
- package/dist/tools/warp_grep/tools/read.js.map +0 -1
- package/dist/tools/warp_grep/utils/format.cjs +0 -42
- package/dist/tools/warp_grep/utils/format.cjs.map +0 -1
- package/dist/tools/warp_grep/utils/format.d.ts +0 -4
- package/dist/tools/warp_grep/utils/format.js +0 -18
- package/dist/tools/warp_grep/utils/format.js.map +0 -1
- /package/dist/{chunk-7OQOOB3R.js.map → chunk-ISWL67SF.js.map} +0 -0
- /package/dist/tools/warp_grep/{agent/grep_helpers.js.map → client.js.map} +0 -0
- /package/dist/tools/warp_grep/{tools/analyse.js.map → gemini.js.map} +0 -0
- /package/dist/tools/warp_grep/{tools/finish.js.map → providers/remote.js.map} +0 -0
|
@@ -11,8 +11,9 @@ import {
|
|
|
11
11
|
runRipgrep
|
|
12
12
|
} from "./chunk-TPP2UGQP.js";
|
|
13
13
|
import {
|
|
14
|
+
AGENT_CONFIG,
|
|
14
15
|
DEFAULT_EXCLUDES
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-XT5ZO6ES.js";
|
|
16
17
|
|
|
17
18
|
// tools/warp_grep/providers/local.ts
|
|
18
19
|
import fs from "fs/promises";
|
|
@@ -23,7 +24,15 @@ var LocalRipgrepProvider = class {
|
|
|
23
24
|
this.excludes = excludes;
|
|
24
25
|
}
|
|
25
26
|
async grep(params) {
|
|
26
|
-
|
|
27
|
+
let abs;
|
|
28
|
+
try {
|
|
29
|
+
abs = resolveUnderRepo(this.repoRoot, params.path);
|
|
30
|
+
} catch (err) {
|
|
31
|
+
return {
|
|
32
|
+
lines: [],
|
|
33
|
+
error: `[PATH ERROR] ${err instanceof Error ? err.message : String(err)}`
|
|
34
|
+
};
|
|
35
|
+
}
|
|
27
36
|
const stat = await fs.stat(abs).catch(() => null);
|
|
28
37
|
if (!stat) return { lines: [] };
|
|
29
38
|
const targetArg = abs === path.resolve(this.repoRoot) ? "." : toRepoRelative(this.repoRoot, abs);
|
|
@@ -35,6 +44,9 @@ var LocalRipgrepProvider = class {
|
|
|
35
44
|
"--color=never",
|
|
36
45
|
"--trim",
|
|
37
46
|
"--max-columns=400",
|
|
47
|
+
"-C",
|
|
48
|
+
"1",
|
|
49
|
+
...params.glob ? ["--glob", params.glob] : [],
|
|
38
50
|
...this.excludes.flatMap((e) => ["-g", `!${e}`]),
|
|
39
51
|
params.pattern,
|
|
40
52
|
targetArg || "."
|
|
@@ -59,29 +71,24 @@ Details: ${res.stderr}` : ""}`
|
|
|
59
71
|
};
|
|
60
72
|
}
|
|
61
73
|
const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const args = [
|
|
68
|
-
"--no-config",
|
|
69
|
-
"--files",
|
|
70
|
-
"-g",
|
|
71
|
-
params.pattern,
|
|
72
|
-
...this.excludes.flatMap((e) => ["-g", `!${e}`]),
|
|
73
|
-
targetArg || "."
|
|
74
|
-
];
|
|
75
|
-
const res = await runRipgrep(args, { cwd: this.repoRoot });
|
|
76
|
-
if (res.exitCode === -1) {
|
|
77
|
-
console.warn(`[warp_grep] ripgrep not available for glob: ${res.stderr || "execution failed"}`);
|
|
78
|
-
return { files: [] };
|
|
74
|
+
if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
|
|
75
|
+
return {
|
|
76
|
+
lines: [],
|
|
77
|
+
error: "query not specific enough, tool tried to return too much context and failed"
|
|
78
|
+
};
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
return { files };
|
|
80
|
+
return { lines };
|
|
82
81
|
}
|
|
83
82
|
async read(params) {
|
|
84
|
-
|
|
83
|
+
let abs;
|
|
84
|
+
try {
|
|
85
|
+
abs = resolveUnderRepo(this.repoRoot, params.path);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
return {
|
|
88
|
+
lines: [],
|
|
89
|
+
error: `[PATH ERROR] ${err instanceof Error ? err.message : String(err)}`
|
|
90
|
+
};
|
|
91
|
+
}
|
|
85
92
|
const stat = await fs.stat(abs).catch(() => null);
|
|
86
93
|
if (!stat || !stat.isFile()) {
|
|
87
94
|
return {
|
|
@@ -101,7 +108,15 @@ Details: ${res.stderr}` : ""}`
|
|
|
101
108
|
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.`
|
|
102
109
|
};
|
|
103
110
|
}
|
|
104
|
-
|
|
111
|
+
let lines;
|
|
112
|
+
try {
|
|
113
|
+
lines = await readAllLines(abs);
|
|
114
|
+
} catch (err) {
|
|
115
|
+
return {
|
|
116
|
+
lines: [],
|
|
117
|
+
error: `[READ ERROR] Failed to read "${params.path}": ${err instanceof Error ? err.message : String(err)}`
|
|
118
|
+
};
|
|
119
|
+
}
|
|
105
120
|
const total = lines.length;
|
|
106
121
|
let s = params.start ?? 1;
|
|
107
122
|
let e = Math.min(params.end ?? total, total);
|
|
@@ -114,27 +129,43 @@ Details: ${res.stderr}` : ""}`
|
|
|
114
129
|
const content = lines[i - 1] ?? "";
|
|
115
130
|
out.push(`${i}|${content}`);
|
|
116
131
|
}
|
|
132
|
+
if (out.length > AGENT_CONFIG.MAX_READ_LINES) {
|
|
133
|
+
const truncated = out.slice(0, AGENT_CONFIG.MAX_READ_LINES);
|
|
134
|
+
truncated.push(`... [truncated: showing ${AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines]`);
|
|
135
|
+
return { lines: truncated };
|
|
136
|
+
}
|
|
117
137
|
return { lines: out };
|
|
118
138
|
}
|
|
119
|
-
async
|
|
120
|
-
|
|
139
|
+
async listDirectory(params) {
|
|
140
|
+
let abs;
|
|
141
|
+
try {
|
|
142
|
+
abs = resolveUnderRepo(this.repoRoot, params.path);
|
|
143
|
+
} catch {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
121
146
|
const stat = await fs.stat(abs).catch(() => null);
|
|
122
147
|
if (!stat || !stat.isDirectory()) {
|
|
123
148
|
return [];
|
|
124
149
|
}
|
|
125
|
-
const maxResults = params.maxResults ??
|
|
126
|
-
const maxDepth = params.maxDepth ??
|
|
150
|
+
const maxResults = params.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES;
|
|
151
|
+
const maxDepth = params.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
|
|
127
152
|
const regex = params.pattern ? new RegExp(params.pattern) : null;
|
|
128
153
|
const results = [];
|
|
154
|
+
let timedOut = false;
|
|
155
|
+
const startTime = Date.now();
|
|
129
156
|
async function walk(dir, depth) {
|
|
157
|
+
if (Date.now() - startTime > AGENT_CONFIG.LIST_TIMEOUT_MS) {
|
|
158
|
+
timedOut = true;
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
130
161
|
if (depth > maxDepth || results.length >= maxResults) return;
|
|
131
162
|
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
132
163
|
for (const entry of entries) {
|
|
164
|
+
if (timedOut || results.length >= maxResults) break;
|
|
133
165
|
const full = path.join(dir, entry.name);
|
|
134
166
|
const rel = toRepoRelative(abs, full).replace(/^[.][/\\]?/, "");
|
|
135
167
|
if (DEFAULT_EXCLUDES.some((ex) => rel.split(path.sep).includes(ex))) continue;
|
|
136
168
|
if (regex && !regex.test(entry.name)) continue;
|
|
137
|
-
if (results.length >= maxResults) break;
|
|
138
169
|
results.push({
|
|
139
170
|
name: entry.name,
|
|
140
171
|
path: toRepoRelative(path.resolve(""), full),
|
|
@@ -155,4 +186,4 @@ Details: ${res.stderr}` : ""}`
|
|
|
155
186
|
export {
|
|
156
187
|
LocalRipgrepProvider
|
|
157
188
|
};
|
|
158
|
-
//# sourceMappingURL=chunk-
|
|
189
|
+
//# sourceMappingURL=chunk-ZO4PPFCZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/providers/local.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport fssync from 'fs';\nimport path from 'path';\nimport { runRipgrep } from '../utils/ripgrep.js';\nimport { ensureWithinRepo, resolveUnderRepo, toRepoRelative, isSymlink, isTextualFile } from '../utils/paths.js';\nimport type { WarpGrepProvider, GrepResult, ReadResult, ListDirectoryEntry } from './types.js';\nimport { readAllLines } from '../utils/files.js';\nimport { DEFAULT_EXCLUDES, AGENT_CONFIG } from '../agent/config.js';\n\nexport class LocalRipgrepProvider implements WarpGrepProvider {\n constructor(private readonly repoRoot: string, private readonly excludes: string[] = DEFAULT_EXCLUDES) {}\n\n async grep(params: { pattern: string; path: string; glob?: string }): Promise<GrepResult> {\n let abs: string;\n try {\n abs = resolveUnderRepo(this.repoRoot, params.path);\n } catch (err) {\n return {\n lines: [],\n error: `[PATH ERROR] ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n const stat = await fs.stat(abs).catch(() => null);\n if (!stat) return { lines: [] };\n const targetArg = abs === path.resolve(this.repoRoot) ? '.' : toRepoRelative(this.repoRoot, abs);\n const args = [\n '--no-config',\n '--no-heading',\n '--with-filename',\n '--line-number',\n '--color=never',\n '--trim',\n '--max-columns=400',\n '-C', '1',\n ...(params.glob ? ['--glob', params.glob] : []),\n ...this.excludes.flatMap((e) => ['-g', `!${e}`]),\n params.pattern,\n targetArg || '.',\n ];\n const res = await runRipgrep(args, { cwd: this.repoRoot });\n \n // Gracefully handle ripgrep not being available\n if (res.exitCode === -1) {\n return {\n lines: [],\n error: `[RIPGREP NOT AVAILABLE] ripgrep (rg) is required but failed to execute. Please install it:\\n` +\n ` • macOS: brew install ripgrep\\n` +\n ` • Ubuntu/Debian: apt install ripgrep\\n` +\n ` • Windows: choco install ripgrep\\n` +\n ` • Or visit: https://github.com/BurntSushi/ripgrep#installation\\n` +\n `Exit code: ${res.exitCode}${res.stderr ? `\\nDetails: ${res.stderr}` : ''}`,\n };\n }\n \n // Handle other ripgrep errors gracefully\n if (res.exitCode !== 0 && res.exitCode !== 1) {\n return {\n lines: [],\n error: `[RIPGREP ERROR] grep failed with exit code ${res.exitCode}${res.stderr ? `: ${res.stderr}` : ''}`,\n };\n }\n \n const lines = (res.stdout || '')\n .trim()\n .split(/\\r?\\n/)\n .filter((l) => l.length > 0);\n if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {\n return {\n lines: [],\n error: 'query not specific enough, tool tried to return too much context and failed',\n };\n }\n \n return { lines };\n }\n\n async read(params: { path: string; start?: number; end?: number }): Promise<ReadResult> {\n let abs: string;\n try {\n abs = resolveUnderRepo(this.repoRoot, params.path);\n } catch (err) {\n return {\n lines: [],\n error: `[PATH ERROR] ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n const stat = await fs.stat(abs).catch(() => null);\n \n // Gracefully handle file not found / not a file\n if (!stat || !stat.isFile()) {\n return {\n lines: [],\n error: `[FILE NOT FOUND] You tried to read \"${params.path}\" but there is no file at this path. ` +\n `Double-check the path exists and is spelled correctly.`,\n };\n }\n \n // Gracefully handle symlinks\n if (isSymlink(abs)) {\n return {\n lines: [],\n error: `[SYMLINK] You tried to read \"${params.path}\" but this is a symlink. ` +\n `Try reading the actual file it points to instead.`,\n };\n }\n \n // Gracefully handle non-text or too-large files\n if (!isTextualFile(abs)) {\n return {\n lines: [],\n error: `[UNREADABLE FILE] You tried to read \"${params.path}\" but this file is either too large ` +\n `or not a text file, so it cannot be read. Try a different file.`,\n };\n }\n \n let lines: string[];\n try {\n lines = await readAllLines(abs);\n } catch (err) {\n return {\n lines: [],\n error: `[READ ERROR] Failed to read \"${params.path}\": ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n const total = lines.length;\n let s = params.start ?? 1;\n let e = Math.min(params.end ?? total, total);\n if (s > total && total > 0) {\n // Model hallucinated range - fallback to full file\n s = 1;\n e = total;\n }\n const out: string[] = [];\n for (let i = s; i <= e; i += 1) {\n const content = lines[i - 1] ?? '';\n out.push(`${i}|${content}`);\n }\n if (out.length > AGENT_CONFIG.MAX_READ_LINES) {\n const truncated = out.slice(0, AGENT_CONFIG.MAX_READ_LINES);\n truncated.push(`... [truncated: showing ${AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines]`);\n return { lines: truncated };\n }\n \n return { lines: out };\n }\n\n async listDirectory(params: { path: string; pattern?: string | null; maxResults?: number; maxDepth?: number }): Promise<ListDirectoryEntry[]> {\n let abs: string;\n try {\n abs = resolveUnderRepo(this.repoRoot, params.path);\n } catch {\n // Path outside repo - return empty (graceful failure)\n return [];\n }\n const stat = await fs.stat(abs).catch(() => null);\n if (!stat || !stat.isDirectory()) {\n return [];\n }\n const maxResults = params.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES;\n const maxDepth = params.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;\n const regex = params.pattern ? new RegExp(params.pattern) : null;\n\n const results: ListDirectoryEntry[] = [];\n let timedOut = false;\n const startTime = Date.now();\n \n async function walk(dir: string, depth: number) {\n if (Date.now() - startTime > AGENT_CONFIG.LIST_TIMEOUT_MS) {\n timedOut = true;\n return;\n }\n if (depth > maxDepth || results.length >= maxResults) return;\n const entries = await fs.readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (timedOut || results.length >= maxResults) break;\n const full = path.join(dir, entry.name);\n const rel = toRepoRelative(abs, full).replace(/^[.][/\\\\]?/, '');\n if (DEFAULT_EXCLUDES.some((ex) => rel.split(path.sep).includes(ex))) continue;\n if (regex && !regex.test(entry.name)) continue;\n results.push({\n name: entry.name,\n path: toRepoRelative(path.resolve(''), full), // relative display\n type: entry.isDirectory() ? 'dir' : 'file',\n depth,\n });\n if (entry.isDirectory()) {\n await walk(full, depth + 1);\n }\n }\n }\n await walk(abs, 0);\n return results;\n }\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AAEf,OAAO,UAAU;AAOV,IAAM,uBAAN,MAAuD;AAAA,EAC5D,YAA6B,UAAmC,WAAqB,kBAAkB;AAA1E;AAAmC;AAAA,EAAwC;AAAA,EAExG,MAAM,KAAK,QAA+E;AACxF,QAAI;AACJ,QAAI;AACF,YAAM,iBAAiB,KAAK,UAAU,OAAO,IAAI;AAAA,IACnD,SAAS,KAAK;AACZ,aAAO;AAAA,QACL,OAAO,CAAC;AAAA,QACR,OAAO,gBAAgB,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,MACzE;AAAA,IACF;AACA,UAAM,OAAO,MAAM,GAAG,KAAK,GAAG,EAAE,MAAM,MAAM,IAAI;AAChD,QAAI,CAAC,KAAM,QAAO,EAAE,OAAO,CAAC,EAAE;AAC9B,UAAM,YAAY,QAAQ,KAAK,QAAQ,KAAK,QAAQ,IAAI,MAAM,eAAe,KAAK,UAAU,GAAG;AAC/F,UAAM,OAAO;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAAM;AAAA,MACN,GAAI,OAAO,OAAO,CAAC,UAAU,OAAO,IAAI,IAAI,CAAC;AAAA,MAC7C,GAAG,KAAK,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;AAAA,MAC/C,OAAO;AAAA,MACP,aAAa;AAAA,IACf;AACA,UAAM,MAAM,MAAM,WAAW,MAAM,EAAE,KAAK,KAAK,SAAS,CAAC;AAGzD,QA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C;AAAA,IACV;AACA,UAAM,aAAa,OAAO,cAAc,aAAa;AACrD,UAAM,WAAW,OAAO,YAAY,aAAa;AACjD,UAAM,QAAQ,OAAO,UAAU,IAAI,OAAO,OAAO,OAAO,IAAI;AAE5D,UAAM,UAAgC,CAAC;AACvC,QAAI,WAAW;AACf,UAAM,YAAY,KAAK,IAAI;AAE3B,mBAAe,KAAK,KAAa,OAAe;AAC9C,UAAI,KAAK,IAAI,IAAI,YAAY,aAAa,iBAAiB;AACzD,mBAAW;AACX;AAAA,MACF;AACA,UAAI,QAAQ,YAAY,QAAQ,UAAU,WAAY;AACtD,YAAM,UAAU,MAAM,GAAG,QAAQ,KAAK,EAAE,eAAe,KAAK,CAAC;AAC7D,iBAAW,SAAS,SAAS;AAC3B,YAAI,YAAY,QAAQ,UAAU,WAAY;AAC9C,cAAM,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI;AACtC,cAAM,MAAM,eAAe,KAAK,IAAI,EAAE,QAAQ,cAAc,EAAE;AAC9D,YAAI,iBAAiB,KAAK,CAAC,OAAO,IAAI,MAAM,KAAK,GAAG,EAAE,SAAS,EAAE,CAAC,EAAG;AACrE,YAAI,SAAS,CAAC,MAAM,KAAK,MAAM,IAAI,EAAG;AACtC,gBAAQ,KAAK;AAAA,UACX,MAAM,MAAM;AAAA,UACZ,MAAM,eAAe,KAAK,QAAQ,EAAE,GAAG,IAAI;AAAA;AAAA,UAC3C,MAAM,MAAM,YAAY,IAAI,QAAQ;AAAA,UACpC;AAAA,QACF,CAAC;AACD,YAAI,MAAM,YAAY,GAAG;AACvB,gBAAM,KAAK,MAAM,QAAQ,CAAC;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AACA,UAAM,KAAK,KAAK,CAAC;AACjB,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -2,11 +2,12 @@ import { RetryConfig } from './tools/utils/resilience.js';
|
|
|
2
2
|
import { FastApplyClient } from './tools/fastapply/core.js';
|
|
3
3
|
import { CodebaseSearchClient } from './tools/codebase_search/core.js';
|
|
4
4
|
import { BrowserClient } from './tools/browser/core.js';
|
|
5
|
-
import {
|
|
5
|
+
import { WarpGrepClient } from './tools/warp_grep/client.js';
|
|
6
6
|
import { MorphGit } from './git/client.js';
|
|
7
7
|
import { OpenAIRouter, AnthropicRouter, GeminiRouter, RawRouter } from './modelrouter/core.js';
|
|
8
8
|
import { EditFileConfig, EditFileInput, EditFileResult, EditChanges } from './tools/fastapply/types.js';
|
|
9
9
|
import { CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult } from './tools/codebase_search/types.js';
|
|
10
|
+
import { d as WarpGrepToolConfig, b as WarpGrepResult, c as WarpGrepContext } from './types-a_hxdPI6.js';
|
|
10
11
|
import * as openai_resources_index_mjs from 'openai/resources/index.mjs';
|
|
11
12
|
import * as _anthropic_ai_sdk_resources_messages_mjs from '@anthropic-ai/sdk/resources/messages.mjs';
|
|
12
13
|
import * as ai from 'ai';
|
|
@@ -36,10 +37,10 @@ declare class OpenAIToolFactory {
|
|
|
36
37
|
/**
|
|
37
38
|
* Create an OpenAI-compatible warp grep tool
|
|
38
39
|
*
|
|
39
|
-
* @param toolConfig - Tool configuration (
|
|
40
|
+
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
40
41
|
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
41
42
|
*/
|
|
42
|
-
createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, '
|
|
43
|
+
createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>): openai_resources_index_mjs.ChatCompletionTool & {
|
|
43
44
|
execute: (input: unknown) => Promise<WarpGrepResult>;
|
|
44
45
|
formatResult: (result: WarpGrepResult) => string;
|
|
45
46
|
getSystemPrompt: () => string;
|
|
@@ -93,10 +94,10 @@ declare class AnthropicToolFactory {
|
|
|
93
94
|
/**
|
|
94
95
|
* Create an Anthropic-compatible warp grep tool
|
|
95
96
|
*
|
|
96
|
-
* @param toolConfig - Tool configuration (
|
|
97
|
+
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
97
98
|
* @returns Anthropic Tool with execute and formatResult methods
|
|
98
99
|
*/
|
|
99
|
-
createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, '
|
|
100
|
+
createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>): _anthropic_ai_sdk_resources_messages_mjs.Tool & {
|
|
100
101
|
execute: (input: unknown) => Promise<WarpGrepResult>;
|
|
101
102
|
formatResult: (result: WarpGrepResult) => string;
|
|
102
103
|
getSystemPrompt: () => string;
|
|
@@ -150,21 +151,15 @@ declare class VercelToolFactory {
|
|
|
150
151
|
/**
|
|
151
152
|
* Create a Vercel AI SDK-compatible warp grep tool
|
|
152
153
|
*
|
|
153
|
-
* @param toolConfig - Tool configuration (
|
|
154
|
+
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
154
155
|
* @returns Vercel AI SDK tool
|
|
155
156
|
*/
|
|
156
|
-
createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, '
|
|
157
|
+
createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>): ai.Tool<{
|
|
157
158
|
query: string;
|
|
158
159
|
}, {
|
|
159
160
|
success: boolean;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
summary?: undefined;
|
|
163
|
-
} | {
|
|
164
|
-
success: boolean;
|
|
165
|
-
contexts: WarpGrepContext[];
|
|
166
|
-
summary: string;
|
|
167
|
-
error?: undefined;
|
|
161
|
+
contexts: WarpGrepContext[] | undefined;
|
|
162
|
+
summary: string | undefined;
|
|
168
163
|
}>;
|
|
169
164
|
/**
|
|
170
165
|
* Create a Vercel AI SDK-compatible codebase search tool
|