@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
|
@@ -614,120 +614,6 @@ function formatAgentToolOutput(toolName, args, output, options = {}) {
|
|
|
614
614
|
return sharedFormatter.format(toolName, args, output, options);
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
-
// tools/warp_grep/agent/grep_helpers.ts
|
|
618
|
-
var GrepState = class {
|
|
619
|
-
seenLines = /* @__PURE__ */ new Set();
|
|
620
|
-
isNew(path4, lineNumber) {
|
|
621
|
-
const key = this.makeKey(path4, lineNumber);
|
|
622
|
-
return !this.seenLines.has(key);
|
|
623
|
-
}
|
|
624
|
-
add(path4, lineNumber) {
|
|
625
|
-
this.seenLines.add(this.makeKey(path4, lineNumber));
|
|
626
|
-
}
|
|
627
|
-
makeKey(path4, lineNumber) {
|
|
628
|
-
return `${path4}:${lineNumber}`;
|
|
629
|
-
}
|
|
630
|
-
};
|
|
631
|
-
var MAX_GREP_OUTPUT_CHARS_PER_TURN = 6e4;
|
|
632
|
-
function extractMatchFields(payload) {
|
|
633
|
-
const text = payload.replace(/\r?\n$/, "");
|
|
634
|
-
if (!text || text.startsWith("[error]")) {
|
|
635
|
-
return null;
|
|
636
|
-
}
|
|
637
|
-
const firstSep = text.indexOf(":");
|
|
638
|
-
if (firstSep === -1) {
|
|
639
|
-
return null;
|
|
640
|
-
}
|
|
641
|
-
let filePath = text.slice(0, firstSep).trim();
|
|
642
|
-
if (!filePath) {
|
|
643
|
-
return null;
|
|
644
|
-
}
|
|
645
|
-
if (filePath.startsWith("./") || filePath.startsWith(".\\")) {
|
|
646
|
-
filePath = filePath.slice(2);
|
|
647
|
-
}
|
|
648
|
-
const remainder = text.slice(firstSep + 1);
|
|
649
|
-
const secondSep = remainder.indexOf(":");
|
|
650
|
-
if (secondSep === -1) {
|
|
651
|
-
return null;
|
|
652
|
-
}
|
|
653
|
-
const linePart = remainder.slice(0, secondSep);
|
|
654
|
-
const lineNumber = Number.parseInt(linePart, 10);
|
|
655
|
-
if (!Number.isInteger(lineNumber) || lineNumber <= 0) {
|
|
656
|
-
return null;
|
|
657
|
-
}
|
|
658
|
-
let contentSegment = remainder.slice(secondSep + 1);
|
|
659
|
-
const columnSep = contentSegment.indexOf(":");
|
|
660
|
-
if (columnSep !== -1 && /^\d+$/.test(contentSegment.slice(0, columnSep))) {
|
|
661
|
-
contentSegment = contentSegment.slice(columnSep + 1);
|
|
662
|
-
}
|
|
663
|
-
const content = contentSegment.trim();
|
|
664
|
-
if (!content) {
|
|
665
|
-
return null;
|
|
666
|
-
}
|
|
667
|
-
return { path: filePath, lineNumber, content };
|
|
668
|
-
}
|
|
669
|
-
function parseAndFilterGrepOutput(rawOutput, state) {
|
|
670
|
-
const matches = [];
|
|
671
|
-
if (typeof rawOutput !== "string" || !rawOutput.trim()) {
|
|
672
|
-
return matches;
|
|
673
|
-
}
|
|
674
|
-
for (const line of rawOutput.split(/\r?\n/)) {
|
|
675
|
-
const fields = extractMatchFields(line);
|
|
676
|
-
if (!fields) {
|
|
677
|
-
continue;
|
|
678
|
-
}
|
|
679
|
-
if (state.isNew(fields.path, fields.lineNumber)) {
|
|
680
|
-
matches.push(fields);
|
|
681
|
-
state.add(fields.path, fields.lineNumber);
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
return matches;
|
|
685
|
-
}
|
|
686
|
-
function truncateOutput(payload, maxChars) {
|
|
687
|
-
if (payload.length <= maxChars) {
|
|
688
|
-
return payload;
|
|
689
|
-
}
|
|
690
|
-
const note = "... (output truncated)";
|
|
691
|
-
const available = maxChars - note.length - 1;
|
|
692
|
-
if (available <= 0) {
|
|
693
|
-
return note;
|
|
694
|
-
}
|
|
695
|
-
if (payload.length <= available) {
|
|
696
|
-
return `${payload.slice(0, available).replace(/\n$/, "")}
|
|
697
|
-
${note}`;
|
|
698
|
-
}
|
|
699
|
-
const core = payload.slice(0, Math.max(0, available - 1));
|
|
700
|
-
const trimmed = core.replace(/\n$/, "").replace(/\s+$/, "");
|
|
701
|
-
const snippet = trimmed ? `${trimmed}\u2026` : "\u2026";
|
|
702
|
-
return `${snippet}
|
|
703
|
-
${note}`;
|
|
704
|
-
}
|
|
705
|
-
function formatTurnGrepOutput(matches, maxChars = MAX_GREP_OUTPUT_CHARS_PER_TURN) {
|
|
706
|
-
if (!matches || matches.length === 0) {
|
|
707
|
-
return "No new matches found.";
|
|
708
|
-
}
|
|
709
|
-
const matchesByFile = /* @__PURE__ */ new Map();
|
|
710
|
-
for (const match of matches) {
|
|
711
|
-
if (!matchesByFile.has(match.path)) {
|
|
712
|
-
matchesByFile.set(match.path, []);
|
|
713
|
-
}
|
|
714
|
-
matchesByFile.get(match.path).push(match);
|
|
715
|
-
}
|
|
716
|
-
const lines = [];
|
|
717
|
-
const sortedPaths = Array.from(matchesByFile.keys()).sort();
|
|
718
|
-
sortedPaths.forEach((filePath, index) => {
|
|
719
|
-
if (index > 0) {
|
|
720
|
-
lines.push("");
|
|
721
|
-
}
|
|
722
|
-
lines.push(filePath);
|
|
723
|
-
const sortedMatches = matchesByFile.get(filePath).slice().sort((a, b) => a.lineNumber - b.lineNumber);
|
|
724
|
-
for (const match of sortedMatches) {
|
|
725
|
-
lines.push(`${match.lineNumber}:${match.content}`);
|
|
726
|
-
}
|
|
727
|
-
});
|
|
728
|
-
return truncateOutput(lines.join("\n"), maxChars);
|
|
729
|
-
}
|
|
730
|
-
|
|
731
617
|
// tools/warp_grep/tools/finish.ts
|
|
732
618
|
async function readFinishFiles(repoRoot, files, reader) {
|
|
733
619
|
const out = [];
|
|
@@ -823,7 +709,6 @@ async function runWarpGrep(config) {
|
|
|
823
709
|
const model = config.model || DEFAULT_MODEL;
|
|
824
710
|
const provider = config.provider;
|
|
825
711
|
const errors = [];
|
|
826
|
-
const grepState = new GrepState();
|
|
827
712
|
let finishMeta;
|
|
828
713
|
let terminationReason = "terminated";
|
|
829
714
|
for (let round = 1; round <= maxRounds; round += 1) {
|
|
@@ -849,10 +734,25 @@ async function runWarpGrep(config) {
|
|
|
849
734
|
const msg = c.arguments?.message || "Command skipped due to parsing error";
|
|
850
735
|
formatted.push(msg);
|
|
851
736
|
}
|
|
852
|
-
const
|
|
737
|
+
const allPromises = [];
|
|
738
|
+
for (const c of grepCalls) {
|
|
739
|
+
const args = c.arguments ?? {};
|
|
740
|
+
allPromises.push(
|
|
741
|
+
provider.grep({ pattern: args.pattern, path: args.path }).then(
|
|
742
|
+
(grepRes) => {
|
|
743
|
+
if (grepRes.error) {
|
|
744
|
+
return { terminate: true, error: grepRes.error };
|
|
745
|
+
}
|
|
746
|
+
const output = grepRes.lines.join("\n") || "no matches";
|
|
747
|
+
return formatAgentToolOutput("grep", args, output, { isError: false });
|
|
748
|
+
},
|
|
749
|
+
(err) => formatAgentToolOutput("grep", args, String(err), { isError: true })
|
|
750
|
+
)
|
|
751
|
+
);
|
|
752
|
+
}
|
|
853
753
|
for (const c of analyseCalls) {
|
|
854
754
|
const args = c.arguments ?? {};
|
|
855
|
-
|
|
755
|
+
allPromises.push(
|
|
856
756
|
toolAnalyse(provider, args).then(
|
|
857
757
|
(p) => formatAgentToolOutput("analyse", args, p, { isError: false }),
|
|
858
758
|
(err) => formatAgentToolOutput("analyse", args, String(err), { isError: true })
|
|
@@ -861,38 +761,24 @@ async function runWarpGrep(config) {
|
|
|
861
761
|
}
|
|
862
762
|
for (const c of readCalls) {
|
|
863
763
|
const args = c.arguments ?? {};
|
|
864
|
-
|
|
764
|
+
allPromises.push(
|
|
865
765
|
toolRead(provider, args).then(
|
|
866
766
|
(p) => formatAgentToolOutput("read", args, p, { isError: false }),
|
|
867
767
|
(err) => formatAgentToolOutput("read", args, String(err), { isError: true })
|
|
868
768
|
)
|
|
869
769
|
);
|
|
870
770
|
}
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
errors
|
|
879
|
-
|
|
880
|
-
return {
|
|
881
|
-
terminationReason: "terminated",
|
|
882
|
-
messages,
|
|
883
|
-
errors
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
const rawOutput = Array.isArray(grepRes.lines) ? grepRes.lines.join("\n") : "";
|
|
887
|
-
const newMatches = parseAndFilterGrepOutput(rawOutput, grepState);
|
|
888
|
-
let formattedPayload = formatTurnGrepOutput(newMatches);
|
|
889
|
-
if (formattedPayload === "No new matches found.") {
|
|
890
|
-
formattedPayload = "no new matches";
|
|
891
|
-
}
|
|
892
|
-
formatted.push(formatAgentToolOutput("grep", args, formattedPayload, { isError: false }));
|
|
893
|
-
} catch (err) {
|
|
894
|
-
formatted.push(formatAgentToolOutput("grep", args, String(err), { isError: true }));
|
|
771
|
+
const allResults = await Promise.all(allPromises);
|
|
772
|
+
for (const result of allResults) {
|
|
773
|
+
if (typeof result === "object" && "terminate" in result) {
|
|
774
|
+
errors.push({ message: result.error });
|
|
775
|
+
return {
|
|
776
|
+
terminationReason: "terminated",
|
|
777
|
+
messages,
|
|
778
|
+
errors
|
|
779
|
+
};
|
|
895
780
|
}
|
|
781
|
+
formatted.push(result);
|
|
896
782
|
}
|
|
897
783
|
if (formatted.length > 0) {
|
|
898
784
|
const turnsUsed = round;
|