@morphllm/morphsdk 0.2.55 → 0.2.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-37SRI4GW.js → chunk-6X5UOY7B.js} +34 -39
- package/dist/chunk-6X5UOY7B.js.map +1 -0
- package/dist/chunk-7OQOOB3R.js +1 -0
- package/dist/{chunk-X5HNQ7SB.js → chunk-CFF636UC.js} +3 -3
- package/dist/{chunk-KO6JQFRE.js → chunk-GJ5TYNRD.js} +2 -2
- package/dist/{chunk-ZWY434TS.js → chunk-IMYQOKFO.js} +3 -3
- package/dist/{chunk-BSHJGJ25.js → chunk-KBQWGT5L.js} +3 -3
- package/dist/{chunk-C6QQL6FX.js → chunk-QFIHUCTF.js} +5 -5
- package/dist/client.cjs +28 -142
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +8 -9
- package/dist/index.cjs +28 -209
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +9 -14
- package/dist/tools/warp_grep/agent/runner.cjs +28 -142
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +3 -4
- package/dist/tools/warp_grep/anthropic.cjs +28 -142
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +5 -6
- package/dist/tools/warp_grep/harness.cjs +859 -0
- package/dist/tools/warp_grep/harness.cjs.map +1 -0
- package/dist/tools/warp_grep/harness.d.ts +176 -0
- package/dist/tools/warp_grep/harness.js +76 -0
- package/dist/tools/warp_grep/harness.js.map +1 -0
- package/dist/tools/warp_grep/index.cjs +28 -209
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +0 -1
- package/dist/tools/warp_grep/index.js +8 -13
- package/dist/tools/warp_grep/openai.cjs +28 -142
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +5 -6
- package/dist/tools/warp_grep/vercel.cjs +28 -142
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +5 -6
- package/package.json +7 -2
- package/dist/chunk-37SRI4GW.js.map +0 -1
- package/dist/chunk-JYBVRF72.js +0 -1
- package/dist/chunk-NDZO5IPV.js +0 -121
- package/dist/chunk-NDZO5IPV.js.map +0 -1
- package/dist/chunk-P2XKFWFD.js +0 -73
- package/dist/chunk-P2XKFWFD.js.map +0 -1
- 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/agent/grep_helpers.js.map +0 -1
- package/dist/tools/warp_grep/providers/command.cjs +0 -177
- package/dist/tools/warp_grep/providers/command.cjs.map +0 -1
- package/dist/tools/warp_grep/providers/command.d.ts +0 -48
- package/dist/tools/warp_grep/providers/command.js +0 -9
- package/dist/tools/warp_grep/providers/command.js.map +0 -1
- /package/dist/{chunk-JYBVRF72.js.map → chunk-7OQOOB3R.js.map} +0 -0
- /package/dist/{chunk-X5HNQ7SB.js.map → chunk-CFF636UC.js.map} +0 -0
- /package/dist/{chunk-KO6JQFRE.js.map → chunk-GJ5TYNRD.js.map} +0 -0
- /package/dist/{chunk-ZWY434TS.js.map → chunk-IMYQOKFO.js.map} +0 -0
- /package/dist/{chunk-BSHJGJ25.js.map → chunk-KBQWGT5L.js.map} +0 -0
- /package/dist/{chunk-C6QQL6FX.js.map → chunk-QFIHUCTF.js.map} +0 -0
package/dist/client.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MorphClient
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-EK7OQPWD.js";
|
|
3
|
+
} from "./chunk-QFIHUCTF.js";
|
|
4
|
+
import "./chunk-KBQWGT5L.js";
|
|
5
|
+
import "./chunk-IMYQOKFO.js";
|
|
6
|
+
import "./chunk-CFF636UC.js";
|
|
7
|
+
import "./chunk-GJ5TYNRD.js";
|
|
8
|
+
import "./chunk-6X5UOY7B.js";
|
|
10
9
|
import "./chunk-HQO45BAJ.js";
|
|
10
|
+
import "./chunk-73RQWOQC.js";
|
|
11
11
|
import "./chunk-LVPVVLTI.js";
|
|
12
12
|
import "./chunk-WETRQJGU.js";
|
|
13
13
|
import "./chunk-ZJIIICRA.js";
|
|
14
14
|
import "./chunk-G2RSY56Q.js";
|
|
15
15
|
import "./chunk-SMGZ6A64.js";
|
|
16
16
|
import "./chunk-TPP2UGQP.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-EK7OQPWD.js";
|
|
18
18
|
import "./chunk-TJIUA27P.js";
|
|
19
19
|
import "./chunk-TICMYDII.js";
|
|
20
|
-
import "./chunk-NDZO5IPV.js";
|
|
21
20
|
import "./chunk-UBX7QYBD.js";
|
|
22
21
|
import "./chunk-GJU7UOFL.js";
|
|
23
22
|
import "./chunk-76DJEQEP.js";
|
package/dist/index.cjs
CHANGED
|
@@ -34,7 +34,6 @@ __export(index_exports, {
|
|
|
34
34
|
AnthropicToolFactory: () => AnthropicToolFactory,
|
|
35
35
|
BrowserClient: () => BrowserClient,
|
|
36
36
|
CodebaseSearchClient: () => CodebaseSearchClient,
|
|
37
|
-
CommandExecProvider: () => CommandExecProvider,
|
|
38
37
|
FastApplyClient: () => FastApplyClient,
|
|
39
38
|
GeminiRouter: () => GeminiRouter,
|
|
40
39
|
LocalRipgrepProvider: () => LocalRipgrepProvider,
|
|
@@ -1461,120 +1460,6 @@ function formatAgentToolOutput(toolName, args, output, options = {}) {
|
|
|
1461
1460
|
return sharedFormatter.format(toolName, args, output, options);
|
|
1462
1461
|
}
|
|
1463
1462
|
|
|
1464
|
-
// tools/warp_grep/agent/grep_helpers.ts
|
|
1465
|
-
var GrepState = class {
|
|
1466
|
-
seenLines = /* @__PURE__ */ new Set();
|
|
1467
|
-
isNew(path4, lineNumber) {
|
|
1468
|
-
const key = this.makeKey(path4, lineNumber);
|
|
1469
|
-
return !this.seenLines.has(key);
|
|
1470
|
-
}
|
|
1471
|
-
add(path4, lineNumber) {
|
|
1472
|
-
this.seenLines.add(this.makeKey(path4, lineNumber));
|
|
1473
|
-
}
|
|
1474
|
-
makeKey(path4, lineNumber) {
|
|
1475
|
-
return `${path4}:${lineNumber}`;
|
|
1476
|
-
}
|
|
1477
|
-
};
|
|
1478
|
-
var MAX_GREP_OUTPUT_CHARS_PER_TURN = 6e4;
|
|
1479
|
-
function extractMatchFields(payload) {
|
|
1480
|
-
const text = payload.replace(/\r?\n$/, "");
|
|
1481
|
-
if (!text || text.startsWith("[error]")) {
|
|
1482
|
-
return null;
|
|
1483
|
-
}
|
|
1484
|
-
const firstSep = text.indexOf(":");
|
|
1485
|
-
if (firstSep === -1) {
|
|
1486
|
-
return null;
|
|
1487
|
-
}
|
|
1488
|
-
let filePath = text.slice(0, firstSep).trim();
|
|
1489
|
-
if (!filePath) {
|
|
1490
|
-
return null;
|
|
1491
|
-
}
|
|
1492
|
-
if (filePath.startsWith("./") || filePath.startsWith(".\\")) {
|
|
1493
|
-
filePath = filePath.slice(2);
|
|
1494
|
-
}
|
|
1495
|
-
const remainder = text.slice(firstSep + 1);
|
|
1496
|
-
const secondSep = remainder.indexOf(":");
|
|
1497
|
-
if (secondSep === -1) {
|
|
1498
|
-
return null;
|
|
1499
|
-
}
|
|
1500
|
-
const linePart = remainder.slice(0, secondSep);
|
|
1501
|
-
const lineNumber = Number.parseInt(linePart, 10);
|
|
1502
|
-
if (!Number.isInteger(lineNumber) || lineNumber <= 0) {
|
|
1503
|
-
return null;
|
|
1504
|
-
}
|
|
1505
|
-
let contentSegment = remainder.slice(secondSep + 1);
|
|
1506
|
-
const columnSep = contentSegment.indexOf(":");
|
|
1507
|
-
if (columnSep !== -1 && /^\d+$/.test(contentSegment.slice(0, columnSep))) {
|
|
1508
|
-
contentSegment = contentSegment.slice(columnSep + 1);
|
|
1509
|
-
}
|
|
1510
|
-
const content = contentSegment.trim();
|
|
1511
|
-
if (!content) {
|
|
1512
|
-
return null;
|
|
1513
|
-
}
|
|
1514
|
-
return { path: filePath, lineNumber, content };
|
|
1515
|
-
}
|
|
1516
|
-
function parseAndFilterGrepOutput(rawOutput, state) {
|
|
1517
|
-
const matches = [];
|
|
1518
|
-
if (typeof rawOutput !== "string" || !rawOutput.trim()) {
|
|
1519
|
-
return matches;
|
|
1520
|
-
}
|
|
1521
|
-
for (const line of rawOutput.split(/\r?\n/)) {
|
|
1522
|
-
const fields = extractMatchFields(line);
|
|
1523
|
-
if (!fields) {
|
|
1524
|
-
continue;
|
|
1525
|
-
}
|
|
1526
|
-
if (state.isNew(fields.path, fields.lineNumber)) {
|
|
1527
|
-
matches.push(fields);
|
|
1528
|
-
state.add(fields.path, fields.lineNumber);
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
return matches;
|
|
1532
|
-
}
|
|
1533
|
-
function truncateOutput(payload, maxChars) {
|
|
1534
|
-
if (payload.length <= maxChars) {
|
|
1535
|
-
return payload;
|
|
1536
|
-
}
|
|
1537
|
-
const note = "... (output truncated)";
|
|
1538
|
-
const available = maxChars - note.length - 1;
|
|
1539
|
-
if (available <= 0) {
|
|
1540
|
-
return note;
|
|
1541
|
-
}
|
|
1542
|
-
if (payload.length <= available) {
|
|
1543
|
-
return `${payload.slice(0, available).replace(/\n$/, "")}
|
|
1544
|
-
${note}`;
|
|
1545
|
-
}
|
|
1546
|
-
const core = payload.slice(0, Math.max(0, available - 1));
|
|
1547
|
-
const trimmed = core.replace(/\n$/, "").replace(/\s+$/, "");
|
|
1548
|
-
const snippet = trimmed ? `${trimmed}\u2026` : "\u2026";
|
|
1549
|
-
return `${snippet}
|
|
1550
|
-
${note}`;
|
|
1551
|
-
}
|
|
1552
|
-
function formatTurnGrepOutput(matches, maxChars = MAX_GREP_OUTPUT_CHARS_PER_TURN) {
|
|
1553
|
-
if (!matches || matches.length === 0) {
|
|
1554
|
-
return "No new matches found.";
|
|
1555
|
-
}
|
|
1556
|
-
const matchesByFile = /* @__PURE__ */ new Map();
|
|
1557
|
-
for (const match of matches) {
|
|
1558
|
-
if (!matchesByFile.has(match.path)) {
|
|
1559
|
-
matchesByFile.set(match.path, []);
|
|
1560
|
-
}
|
|
1561
|
-
matchesByFile.get(match.path).push(match);
|
|
1562
|
-
}
|
|
1563
|
-
const lines = [];
|
|
1564
|
-
const sortedPaths = Array.from(matchesByFile.keys()).sort();
|
|
1565
|
-
sortedPaths.forEach((filePath, index) => {
|
|
1566
|
-
if (index > 0) {
|
|
1567
|
-
lines.push("");
|
|
1568
|
-
}
|
|
1569
|
-
lines.push(filePath);
|
|
1570
|
-
const sortedMatches = matchesByFile.get(filePath).slice().sort((a, b) => a.lineNumber - b.lineNumber);
|
|
1571
|
-
for (const match of sortedMatches) {
|
|
1572
|
-
lines.push(`${match.lineNumber}:${match.content}`);
|
|
1573
|
-
}
|
|
1574
|
-
});
|
|
1575
|
-
return truncateOutput(lines.join("\n"), maxChars);
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
1463
|
// tools/warp_grep/tools/finish.ts
|
|
1579
1464
|
async function readFinishFiles(repoRoot, files, reader) {
|
|
1580
1465
|
const out = [];
|
|
@@ -1670,7 +1555,6 @@ async function runWarpGrep(config) {
|
|
|
1670
1555
|
const model = config.model || DEFAULT_MODEL;
|
|
1671
1556
|
const provider = config.provider;
|
|
1672
1557
|
const errors = [];
|
|
1673
|
-
const grepState = new GrepState();
|
|
1674
1558
|
let finishMeta;
|
|
1675
1559
|
let terminationReason = "terminated";
|
|
1676
1560
|
for (let round = 1; round <= maxRounds; round += 1) {
|
|
@@ -1696,10 +1580,25 @@ async function runWarpGrep(config) {
|
|
|
1696
1580
|
const msg = c.arguments?.message || "Command skipped due to parsing error";
|
|
1697
1581
|
formatted.push(msg);
|
|
1698
1582
|
}
|
|
1699
|
-
const
|
|
1583
|
+
const allPromises = [];
|
|
1584
|
+
for (const c of grepCalls) {
|
|
1585
|
+
const args = c.arguments ?? {};
|
|
1586
|
+
allPromises.push(
|
|
1587
|
+
provider.grep({ pattern: args.pattern, path: args.path }).then(
|
|
1588
|
+
(grepRes) => {
|
|
1589
|
+
if (grepRes.error) {
|
|
1590
|
+
return { terminate: true, error: grepRes.error };
|
|
1591
|
+
}
|
|
1592
|
+
const output = grepRes.lines.join("\n") || "no matches";
|
|
1593
|
+
return formatAgentToolOutput("grep", args, output, { isError: false });
|
|
1594
|
+
},
|
|
1595
|
+
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
1596
|
+
)
|
|
1597
|
+
);
|
|
1598
|
+
}
|
|
1700
1599
|
for (const c of analyseCalls) {
|
|
1701
1600
|
const args = c.arguments ?? {};
|
|
1702
|
-
|
|
1601
|
+
allPromises.push(
|
|
1703
1602
|
toolAnalyse(provider, args).then(
|
|
1704
1603
|
(p) => formatAgentToolOutput("analyse", args, p, { isError: false }),
|
|
1705
1604
|
(err) => formatAgentToolOutput("analyse", args, String(err), { isError: true })
|
|
@@ -1708,38 +1607,24 @@ async function runWarpGrep(config) {
|
|
|
1708
1607
|
}
|
|
1709
1608
|
for (const c of readCalls) {
|
|
1710
1609
|
const args = c.arguments ?? {};
|
|
1711
|
-
|
|
1610
|
+
allPromises.push(
|
|
1712
1611
|
toolRead(provider, args).then(
|
|
1713
1612
|
(p) => formatAgentToolOutput("read", args, p, { isError: false }),
|
|
1714
1613
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
1715
1614
|
)
|
|
1716
1615
|
);
|
|
1717
1616
|
}
|
|
1718
|
-
const
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
errors
|
|
1726
|
-
|
|
1727
|
-
return {
|
|
1728
|
-
terminationReason: "terminated",
|
|
1729
|
-
messages,
|
|
1730
|
-
errors
|
|
1731
|
-
};
|
|
1732
|
-
}
|
|
1733
|
-
const rawOutput = Array.isArray(grepRes.lines) ? grepRes.lines.join("\n") : "";
|
|
1734
|
-
const newMatches = parseAndFilterGrepOutput(rawOutput, grepState);
|
|
1735
|
-
let formattedPayload = formatTurnGrepOutput(newMatches);
|
|
1736
|
-
if (formattedPayload === "No new matches found.") {
|
|
1737
|
-
formattedPayload = "no new matches";
|
|
1738
|
-
}
|
|
1739
|
-
formatted.push(formatAgentToolOutput("grep", args, formattedPayload, { isError: false }));
|
|
1740
|
-
} catch (err) {
|
|
1741
|
-
formatted.push(formatAgentToolOutput("grep", args, String(err), { isError: true }));
|
|
1617
|
+
const allResults = await Promise.all(allPromises);
|
|
1618
|
+
for (const result of allResults) {
|
|
1619
|
+
if (typeof result === "object" && "terminate" in result) {
|
|
1620
|
+
errors.push({ message: result.error });
|
|
1621
|
+
return {
|
|
1622
|
+
terminationReason: "terminated",
|
|
1623
|
+
messages,
|
|
1624
|
+
errors
|
|
1625
|
+
};
|
|
1742
1626
|
}
|
|
1627
|
+
formatted.push(result);
|
|
1743
1628
|
}
|
|
1744
1629
|
if (formatted.length > 0) {
|
|
1745
1630
|
const turnsUsed = round;
|
|
@@ -3697,78 +3582,12 @@ var MorphClient = class {
|
|
|
3697
3582
|
this.vercel = new VercelToolFactory(config);
|
|
3698
3583
|
}
|
|
3699
3584
|
};
|
|
3700
|
-
|
|
3701
|
-
// tools/warp_grep/providers/command.ts
|
|
3702
|
-
var CommandExecProvider = class {
|
|
3703
|
-
constructor(opts) {
|
|
3704
|
-
this.opts = opts;
|
|
3705
|
-
}
|
|
3706
|
-
map(path4) {
|
|
3707
|
-
return this.opts.pathMap ? this.opts.pathMap(path4) : path4;
|
|
3708
|
-
}
|
|
3709
|
-
async grep(params) {
|
|
3710
|
-
const remotePath = this.map(params.path);
|
|
3711
|
-
const args = [
|
|
3712
|
-
"--no-config",
|
|
3713
|
-
"--no-heading",
|
|
3714
|
-
"--with-filename",
|
|
3715
|
-
"--line-number",
|
|
3716
|
-
"--color=never",
|
|
3717
|
-
"--trim",
|
|
3718
|
-
"--max-columns=400",
|
|
3719
|
-
...(this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ["-g", `!${e}`]),
|
|
3720
|
-
params.pattern,
|
|
3721
|
-
remotePath || "."
|
|
3722
|
-
];
|
|
3723
|
-
const res = await this.opts.run("rg", args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
3724
|
-
if (res.exitCode === -1) throw new Error(res.stderr || "ripgrep execution failed");
|
|
3725
|
-
if (res.exitCode !== 0 && res.exitCode !== 1) throw new Error(res.stderr || `ripgrep failed (${res.exitCode})`);
|
|
3726
|
-
const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
3727
|
-
return { lines };
|
|
3728
|
-
}
|
|
3729
|
-
async glob(params) {
|
|
3730
|
-
const remotePath = this.map(params.path);
|
|
3731
|
-
const args = [
|
|
3732
|
-
"--no-config",
|
|
3733
|
-
"--files",
|
|
3734
|
-
"-g",
|
|
3735
|
-
params.pattern,
|
|
3736
|
-
...(this.opts.excludes ?? DEFAULT_EXCLUDES).flatMap((e) => ["-g", `!${e}`]),
|
|
3737
|
-
remotePath || "."
|
|
3738
|
-
];
|
|
3739
|
-
const res = await this.opts.run("rg", args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
3740
|
-
if (res.exitCode === -1) throw new Error(res.stderr || "ripgrep execution failed");
|
|
3741
|
-
const files = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
3742
|
-
return { files };
|
|
3743
|
-
}
|
|
3744
|
-
async read(params) {
|
|
3745
|
-
const remotePath = this.map(params.path);
|
|
3746
|
-
const rc = this.opts.readCommand ? this.opts.readCommand(remotePath, params.start, params.end) : { cmd: "sed", args: ["-n", `${params.start ?? 1},${params.end ?? 1e6}p`, remotePath] };
|
|
3747
|
-
const res = await this.opts.run(rc.cmd, rc.args, { cwd: this.opts.cwd, env: this.opts.env });
|
|
3748
|
-
if (res.exitCode !== 0) throw new Error(res.stderr || `read failed (${res.exitCode})`);
|
|
3749
|
-
const text = res.stdout || "";
|
|
3750
|
-
const lines = text.split(/\r?\n/).map((line, idx) => `${(params.start ?? 1) + idx}|${line}`);
|
|
3751
|
-
return { lines: lines.filter((l) => l !== `${(params.start ?? 1) + (lines.length - 1)}|`) };
|
|
3752
|
-
}
|
|
3753
|
-
async analyse(params) {
|
|
3754
|
-
const target = this.map(params.path);
|
|
3755
|
-
const pattern = params.pattern ?? "*";
|
|
3756
|
-
const files = await this.glob({ pattern, path: target }).catch(() => ({ files: [] }));
|
|
3757
|
-
return files.files.slice(0, params.maxResults ?? 100).map((f) => ({
|
|
3758
|
-
name: f.split("/").pop() || f,
|
|
3759
|
-
path: f,
|
|
3760
|
-
type: f.endsWith("/") ? "dir" : "file",
|
|
3761
|
-
depth: 0
|
|
3762
|
-
}));
|
|
3763
|
-
}
|
|
3764
|
-
};
|
|
3765
3585
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3766
3586
|
0 && (module.exports = {
|
|
3767
3587
|
AnthropicRouter,
|
|
3768
3588
|
AnthropicToolFactory,
|
|
3769
3589
|
BrowserClient,
|
|
3770
3590
|
CodebaseSearchClient,
|
|
3771
|
-
CommandExecProvider,
|
|
3772
3591
|
FastApplyClient,
|
|
3773
3592
|
GeminiRouter,
|
|
3774
3593
|
LocalRipgrepProvider,
|