@morphllm/morphsdk 0.2.56 → 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.
Files changed (47) hide show
  1. package/dist/{chunk-SALJ2K6S.js → chunk-6X5UOY7B.js} +32 -37
  2. package/dist/chunk-6X5UOY7B.js.map +1 -0
  3. package/dist/{chunk-UIRJE422.js → chunk-CFF636UC.js} +3 -3
  4. package/dist/{chunk-QVRXBAMM.js → chunk-GJ5TYNRD.js} +2 -2
  5. package/dist/{chunk-4ZHDBKBY.js → chunk-IMYQOKFO.js} +3 -3
  6. package/dist/{chunk-GJURLQ3L.js → chunk-KBQWGT5L.js} +3 -3
  7. package/dist/{chunk-WSSSSBWU.js → chunk-QFIHUCTF.js} +5 -5
  8. package/dist/client.cjs +28 -142
  9. package/dist/client.cjs.map +1 -1
  10. package/dist/client.js +7 -8
  11. package/dist/index.cjs +28 -142
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.js +7 -8
  14. package/dist/tools/warp_grep/agent/runner.cjs +28 -142
  15. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  16. package/dist/tools/warp_grep/agent/runner.js +2 -3
  17. package/dist/tools/warp_grep/anthropic.cjs +28 -142
  18. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  19. package/dist/tools/warp_grep/anthropic.js +4 -5
  20. package/dist/tools/warp_grep/harness.cjs +859 -0
  21. package/dist/tools/warp_grep/harness.cjs.map +1 -0
  22. package/dist/tools/warp_grep/harness.d.ts +176 -0
  23. package/dist/tools/warp_grep/harness.js +76 -0
  24. package/dist/tools/warp_grep/harness.js.map +1 -0
  25. package/dist/tools/warp_grep/index.cjs +28 -142
  26. package/dist/tools/warp_grep/index.cjs.map +1 -1
  27. package/dist/tools/warp_grep/index.js +6 -7
  28. package/dist/tools/warp_grep/openai.cjs +28 -142
  29. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  30. package/dist/tools/warp_grep/openai.js +4 -5
  31. package/dist/tools/warp_grep/vercel.cjs +28 -142
  32. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  33. package/dist/tools/warp_grep/vercel.js +4 -5
  34. package/package.json +7 -2
  35. package/dist/chunk-NDZO5IPV.js +0 -121
  36. package/dist/chunk-NDZO5IPV.js.map +0 -1
  37. package/dist/chunk-SALJ2K6S.js.map +0 -1
  38. package/dist/tools/warp_grep/agent/grep_helpers.cjs +0 -148
  39. package/dist/tools/warp_grep/agent/grep_helpers.cjs.map +0 -1
  40. package/dist/tools/warp_grep/agent/grep_helpers.d.ts +0 -16
  41. package/dist/tools/warp_grep/agent/grep_helpers.js +0 -14
  42. package/dist/tools/warp_grep/agent/grep_helpers.js.map +0 -1
  43. /package/dist/{chunk-UIRJE422.js.map → chunk-CFF636UC.js.map} +0 -0
  44. /package/dist/{chunk-QVRXBAMM.js.map → chunk-GJ5TYNRD.js.map} +0 -0
  45. /package/dist/{chunk-4ZHDBKBY.js.map → chunk-IMYQOKFO.js.map} +0 -0
  46. /package/dist/{chunk-GJURLQ3L.js.map → chunk-KBQWGT5L.js.map} +0 -0
  47. /package/dist/{chunk-WSSSSBWU.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-WSSSSBWU.js";
4
- import "./chunk-GJURLQ3L.js";
5
- import "./chunk-4ZHDBKBY.js";
6
- import "./chunk-UIRJE422.js";
7
- import "./chunk-QVRXBAMM.js";
8
- import "./chunk-SALJ2K6S.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";
9
9
  import "./chunk-HQO45BAJ.js";
10
+ import "./chunk-73RQWOQC.js";
10
11
  import "./chunk-LVPVVLTI.js";
11
12
  import "./chunk-WETRQJGU.js";
12
13
  import "./chunk-ZJIIICRA.js";
13
14
  import "./chunk-G2RSY56Q.js";
14
15
  import "./chunk-SMGZ6A64.js";
15
16
  import "./chunk-TPP2UGQP.js";
16
- import "./chunk-73RQWOQC.js";
17
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
@@ -1460,120 +1460,6 @@ function formatAgentToolOutput(toolName, args, output, options = {}) {
1460
1460
  return sharedFormatter.format(toolName, args, output, options);
1461
1461
  }
1462
1462
 
1463
- // tools/warp_grep/agent/grep_helpers.ts
1464
- var GrepState = class {
1465
- seenLines = /* @__PURE__ */ new Set();
1466
- isNew(path4, lineNumber) {
1467
- const key = this.makeKey(path4, lineNumber);
1468
- return !this.seenLines.has(key);
1469
- }
1470
- add(path4, lineNumber) {
1471
- this.seenLines.add(this.makeKey(path4, lineNumber));
1472
- }
1473
- makeKey(path4, lineNumber) {
1474
- return `${path4}:${lineNumber}`;
1475
- }
1476
- };
1477
- var MAX_GREP_OUTPUT_CHARS_PER_TURN = 6e4;
1478
- function extractMatchFields(payload) {
1479
- const text = payload.replace(/\r?\n$/, "");
1480
- if (!text || text.startsWith("[error]")) {
1481
- return null;
1482
- }
1483
- const firstSep = text.indexOf(":");
1484
- if (firstSep === -1) {
1485
- return null;
1486
- }
1487
- let filePath = text.slice(0, firstSep).trim();
1488
- if (!filePath) {
1489
- return null;
1490
- }
1491
- if (filePath.startsWith("./") || filePath.startsWith(".\\")) {
1492
- filePath = filePath.slice(2);
1493
- }
1494
- const remainder = text.slice(firstSep + 1);
1495
- const secondSep = remainder.indexOf(":");
1496
- if (secondSep === -1) {
1497
- return null;
1498
- }
1499
- const linePart = remainder.slice(0, secondSep);
1500
- const lineNumber = Number.parseInt(linePart, 10);
1501
- if (!Number.isInteger(lineNumber) || lineNumber <= 0) {
1502
- return null;
1503
- }
1504
- let contentSegment = remainder.slice(secondSep + 1);
1505
- const columnSep = contentSegment.indexOf(":");
1506
- if (columnSep !== -1 && /^\d+$/.test(contentSegment.slice(0, columnSep))) {
1507
- contentSegment = contentSegment.slice(columnSep + 1);
1508
- }
1509
- const content = contentSegment.trim();
1510
- if (!content) {
1511
- return null;
1512
- }
1513
- return { path: filePath, lineNumber, content };
1514
- }
1515
- function parseAndFilterGrepOutput(rawOutput, state) {
1516
- const matches = [];
1517
- if (typeof rawOutput !== "string" || !rawOutput.trim()) {
1518
- return matches;
1519
- }
1520
- for (const line of rawOutput.split(/\r?\n/)) {
1521
- const fields = extractMatchFields(line);
1522
- if (!fields) {
1523
- continue;
1524
- }
1525
- if (state.isNew(fields.path, fields.lineNumber)) {
1526
- matches.push(fields);
1527
- state.add(fields.path, fields.lineNumber);
1528
- }
1529
- }
1530
- return matches;
1531
- }
1532
- function truncateOutput(payload, maxChars) {
1533
- if (payload.length <= maxChars) {
1534
- return payload;
1535
- }
1536
- const note = "... (output truncated)";
1537
- const available = maxChars - note.length - 1;
1538
- if (available <= 0) {
1539
- return note;
1540
- }
1541
- if (payload.length <= available) {
1542
- return `${payload.slice(0, available).replace(/\n$/, "")}
1543
- ${note}`;
1544
- }
1545
- const core = payload.slice(0, Math.max(0, available - 1));
1546
- const trimmed = core.replace(/\n$/, "").replace(/\s+$/, "");
1547
- const snippet = trimmed ? `${trimmed}\u2026` : "\u2026";
1548
- return `${snippet}
1549
- ${note}`;
1550
- }
1551
- function formatTurnGrepOutput(matches, maxChars = MAX_GREP_OUTPUT_CHARS_PER_TURN) {
1552
- if (!matches || matches.length === 0) {
1553
- return "No new matches found.";
1554
- }
1555
- const matchesByFile = /* @__PURE__ */ new Map();
1556
- for (const match of matches) {
1557
- if (!matchesByFile.has(match.path)) {
1558
- matchesByFile.set(match.path, []);
1559
- }
1560
- matchesByFile.get(match.path).push(match);
1561
- }
1562
- const lines = [];
1563
- const sortedPaths = Array.from(matchesByFile.keys()).sort();
1564
- sortedPaths.forEach((filePath, index) => {
1565
- if (index > 0) {
1566
- lines.push("");
1567
- }
1568
- lines.push(filePath);
1569
- const sortedMatches = matchesByFile.get(filePath).slice().sort((a, b) => a.lineNumber - b.lineNumber);
1570
- for (const match of sortedMatches) {
1571
- lines.push(`${match.lineNumber}:${match.content}`);
1572
- }
1573
- });
1574
- return truncateOutput(lines.join("\n"), maxChars);
1575
- }
1576
-
1577
1463
  // tools/warp_grep/tools/finish.ts
1578
1464
  async function readFinishFiles(repoRoot, files, reader) {
1579
1465
  const out = [];
@@ -1669,7 +1555,6 @@ async function runWarpGrep(config) {
1669
1555
  const model = config.model || DEFAULT_MODEL;
1670
1556
  const provider = config.provider;
1671
1557
  const errors = [];
1672
- const grepState = new GrepState();
1673
1558
  let finishMeta;
1674
1559
  let terminationReason = "terminated";
1675
1560
  for (let round = 1; round <= maxRounds; round += 1) {
@@ -1695,10 +1580,25 @@ async function runWarpGrep(config) {
1695
1580
  const msg = c.arguments?.message || "Command skipped due to parsing error";
1696
1581
  formatted.push(msg);
1697
1582
  }
1698
- const otherPromises = [];
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
+ }
1699
1599
  for (const c of analyseCalls) {
1700
1600
  const args = c.arguments ?? {};
1701
- otherPromises.push(
1601
+ allPromises.push(
1702
1602
  toolAnalyse(provider, args).then(
1703
1603
  (p) => formatAgentToolOutput("analyse", args, p, { isError: false }),
1704
1604
  (err) => formatAgentToolOutput("analyse", args, String(err), { isError: true })
@@ -1707,38 +1607,24 @@ async function runWarpGrep(config) {
1707
1607
  }
1708
1608
  for (const c of readCalls) {
1709
1609
  const args = c.arguments ?? {};
1710
- otherPromises.push(
1610
+ allPromises.push(
1711
1611
  toolRead(provider, args).then(
1712
1612
  (p) => formatAgentToolOutput("read", args, p, { isError: false }),
1713
1613
  (err) => formatAgentToolOutput("read", args, String(err), { isError: true })
1714
1614
  )
1715
1615
  );
1716
1616
  }
1717
- const otherResults = await Promise.all(otherPromises);
1718
- formatted.push(...otherResults);
1719
- for (const c of grepCalls) {
1720
- const args = c.arguments ?? {};
1721
- try {
1722
- const grepRes = await provider.grep({ pattern: args.pattern, path: args.path });
1723
- if (grepRes.error) {
1724
- errors.push({ message: grepRes.error });
1725
- terminationReason = "terminated";
1726
- return {
1727
- terminationReason: "terminated",
1728
- messages,
1729
- errors
1730
- };
1731
- }
1732
- const rawOutput = Array.isArray(grepRes.lines) ? grepRes.lines.join("\n") : "";
1733
- const newMatches = parseAndFilterGrepOutput(rawOutput, grepState);
1734
- let formattedPayload = formatTurnGrepOutput(newMatches);
1735
- if (formattedPayload === "No new matches found.") {
1736
- formattedPayload = "no new matches";
1737
- }
1738
- formatted.push(formatAgentToolOutput("grep", args, formattedPayload, { isError: false }));
1739
- } catch (err) {
1740
- 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
+ };
1741
1626
  }
1627
+ formatted.push(result);
1742
1628
  }
1743
1629
  if (formatted.length > 0) {
1744
1630
  const turnsUsed = round;