@morphllm/morphsdk 0.2.80 → 0.2.82
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-QL5SMQ73.js → chunk-24EYSWME.js} +2 -2
- package/dist/{chunk-ND7IFSMR.js → chunk-3ONNAQZU.js} +2 -2
- package/dist/{chunk-HBIDSKIQ.js → chunk-4KMBU6T3.js} +15 -7
- package/dist/chunk-4KMBU6T3.js.map +1 -0
- package/dist/{chunk-XT5ZO6ES.js → chunk-5PNMAWLC.js} +8 -2
- package/dist/chunk-5PNMAWLC.js.map +1 -0
- package/dist/{chunk-LM62QCGS.js → chunk-EK5ZEOI3.js} +5 -5
- package/dist/{chunk-5PGRBWJX.js → chunk-FJKPMMNQ.js} +8 -6
- package/dist/chunk-FJKPMMNQ.js.map +1 -0
- package/dist/{chunk-DCIUCDWJ.js → chunk-P2O5JKE5.js} +39 -11
- package/dist/chunk-P2O5JKE5.js.map +1 -0
- package/dist/{chunk-26QXQFLZ.js → chunk-PUGSTXLO.js} +9 -4
- package/dist/chunk-PUGSTXLO.js.map +1 -0
- package/dist/{chunk-6OII5QOW.js → chunk-WIAYUEJK.js} +8 -6
- package/dist/chunk-WIAYUEJK.js.map +1 -0
- package/dist/{chunk-4R3ALD5C.js → chunk-ZLJAODDJ.js} +2 -2
- package/dist/{client-CSINf0lQ.d.ts → client-CsO9LifG.d.ts} +1 -1
- package/dist/client.cjs +69 -17
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +10 -10
- package/dist/index.cjs +69 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -10
- package/dist/tools/warp_grep/agent/config.cjs +7 -1
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/config.d.ts +1 -0
- package/dist/tools/warp_grep/agent/config.js +1 -1
- package/dist/tools/warp_grep/agent/runner.cjs +45 -8
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +3 -3
- package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/types.d.ts +2 -0
- package/dist/tools/warp_grep/anthropic.cjs +67 -16
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +1 -1
- package/dist/tools/warp_grep/anthropic.js +7 -7
- package/dist/tools/warp_grep/client.cjs +69 -17
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.d.ts +1 -1
- package/dist/tools/warp_grep/client.js +6 -6
- package/dist/tools/warp_grep/gemini.cjs +67 -16
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +1 -1
- package/dist/tools/warp_grep/gemini.js +6 -6
- package/dist/tools/warp_grep/harness.cjs +57 -15
- package/dist/tools/warp_grep/harness.cjs.map +1 -1
- package/dist/tools/warp_grep/harness.js +3 -3
- package/dist/tools/warp_grep/index.cjs +73 -22
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +1 -1
- package/dist/tools/warp_grep/index.js +6 -6
- package/dist/tools/warp_grep/openai.cjs +67 -16
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +1 -1
- package/dist/tools/warp_grep/openai.js +7 -7
- package/dist/tools/warp_grep/providers/local.cjs +20 -6
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/providers/remote.cjs +14 -3
- package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
- package/dist/tools/warp_grep/providers/remote.js +2 -2
- package/dist/tools/warp_grep/vercel.cjs +67 -16
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +1 -1
- package/dist/tools/warp_grep/vercel.js +7 -7
- package/dist/{types-CnvVDM63.d.ts → types-Cv4LpqVl.d.ts} +2 -0
- package/package.json +1 -1
- package/dist/chunk-26QXQFLZ.js.map +0 -1
- package/dist/chunk-5PGRBWJX.js.map +0 -1
- package/dist/chunk-6OII5QOW.js.map +0 -1
- package/dist/chunk-DCIUCDWJ.js.map +0 -1
- package/dist/chunk-HBIDSKIQ.js.map +0 -1
- package/dist/chunk-XT5ZO6ES.js.map +0 -1
- /package/dist/{chunk-QL5SMQ73.js.map → chunk-24EYSWME.js.map} +0 -0
- /package/dist/{chunk-ND7IFSMR.js.map → chunk-3ONNAQZU.js.map} +0 -0
- /package/dist/{chunk-LM62QCGS.js.map → chunk-EK5ZEOI3.js.map} +0 -0
- /package/dist/{chunk-4R3ALD5C.js.map → chunk-ZLJAODDJ.js.map} +0 -0
|
@@ -53,9 +53,15 @@ module.exports = __toCommonJS(warp_grep_exports);
|
|
|
53
53
|
var import_zod = require("zod");
|
|
54
54
|
|
|
55
55
|
// tools/warp_grep/agent/config.ts
|
|
56
|
+
var parseEnvTimeout = (envValue, defaultMs) => {
|
|
57
|
+
if (!envValue) return defaultMs;
|
|
58
|
+
const parsed = parseInt(envValue, 10);
|
|
59
|
+
return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
|
|
60
|
+
};
|
|
56
61
|
var AGENT_CONFIG = {
|
|
57
62
|
MAX_TURNS: 4,
|
|
58
|
-
|
|
63
|
+
/** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
|
|
64
|
+
TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 3e4),
|
|
59
65
|
MAX_CONTEXT_CHARS: 54e4,
|
|
60
66
|
MAX_OUTPUT_LINES: 200,
|
|
61
67
|
MAX_READ_LINES: 800,
|
|
@@ -621,10 +627,25 @@ async function toolGrep(provider, args) {
|
|
|
621
627
|
}
|
|
622
628
|
|
|
623
629
|
// tools/warp_grep/agent/tools/read.ts
|
|
630
|
+
function isValidRange(start, end) {
|
|
631
|
+
return typeof start === "number" && typeof end === "number" && Number.isFinite(start) && Number.isFinite(end) && start > 0 && end >= start;
|
|
632
|
+
}
|
|
624
633
|
async function toolRead(provider, args) {
|
|
625
|
-
if (args.lines && args.lines.length > 0) {
|
|
634
|
+
if (args.lines && Array.isArray(args.lines) && args.lines.length > 0) {
|
|
635
|
+
const validRanges = [];
|
|
636
|
+
for (const range of args.lines) {
|
|
637
|
+
if (Array.isArray(range) && range.length >= 2 && isValidRange(range[0], range[1])) {
|
|
638
|
+
validRanges.push([range[0], range[1]]);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if (validRanges.length === 0) {
|
|
642
|
+
const res2 = await provider.read({ path: args.path });
|
|
643
|
+
if (res2.error) return res2.error;
|
|
644
|
+
if (!res2.lines.length) return "(empty file)";
|
|
645
|
+
return res2.lines.join("\n");
|
|
646
|
+
}
|
|
626
647
|
const chunks = [];
|
|
627
|
-
for (const [start, end] of
|
|
648
|
+
for (const [start, end] of validRanges) {
|
|
628
649
|
const res2 = await provider.read({ path: args.path, start, end });
|
|
629
650
|
if (res2.error) return res2.error;
|
|
630
651
|
chunks.push(res2.lines.join("\n"));
|
|
@@ -660,23 +681,36 @@ async function toolListDirectory(provider, args) {
|
|
|
660
681
|
}
|
|
661
682
|
|
|
662
683
|
// tools/warp_grep/agent/tools/finish.ts
|
|
684
|
+
function isValidRange2(range) {
|
|
685
|
+
return Array.isArray(range) && range.length >= 2 && typeof range[0] === "number" && typeof range[1] === "number" && Number.isFinite(range[0]) && Number.isFinite(range[1]) && range[0] > 0 && range[1] >= range[0];
|
|
686
|
+
}
|
|
687
|
+
function extractValidRanges(lines) {
|
|
688
|
+
if (!Array.isArray(lines)) return null;
|
|
689
|
+
const valid = [];
|
|
690
|
+
for (const range of lines) {
|
|
691
|
+
if (isValidRange2(range)) {
|
|
692
|
+
valid.push([range[0], range[1]]);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return valid.length > 0 ? valid : null;
|
|
696
|
+
}
|
|
663
697
|
function normalizeFinishFiles(files) {
|
|
664
698
|
return files.map((f) => {
|
|
665
|
-
if (f.lines === "*") {
|
|
666
|
-
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
return { path: f.path, lines: merged };
|
|
699
|
+
if (f.lines === "*") return { path: f.path, lines: "*" };
|
|
700
|
+
const validRanges = extractValidRanges(f.lines);
|
|
701
|
+
if (!validRanges) return { path: f.path, lines: "*" };
|
|
702
|
+
return { path: f.path, lines: mergeRanges(validRanges) };
|
|
670
703
|
});
|
|
671
704
|
}
|
|
672
705
|
async function readFinishFiles(repoRoot, files, reader) {
|
|
673
706
|
const out = [];
|
|
674
707
|
for (const f of files) {
|
|
675
|
-
|
|
708
|
+
const validRanges = f.lines === "*" ? null : extractValidRanges(f.lines);
|
|
709
|
+
if (f.lines === "*" || !validRanges) {
|
|
676
710
|
const lines = await reader(f.path);
|
|
677
711
|
out.push({ path: f.path, ranges: "*", content: lines.join("\n") });
|
|
678
712
|
} else {
|
|
679
|
-
const ranges = mergeRanges(
|
|
713
|
+
const ranges = mergeRanges(validRanges);
|
|
680
714
|
const chunks = [];
|
|
681
715
|
for (const [s, e] of ranges) {
|
|
682
716
|
const lines = await reader(f.path, s, e);
|
|
@@ -977,7 +1011,8 @@ async function callModel(messages, model, options = {}) {
|
|
|
977
1011
|
},
|
|
978
1012
|
options.retryConfig
|
|
979
1013
|
);
|
|
980
|
-
const
|
|
1014
|
+
const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1015
|
+
const resp = await withTimeout(fetchPromise, timeoutMs, "morph-warp-grep request timed out");
|
|
981
1016
|
if (!resp.ok) {
|
|
982
1017
|
if (resp.status === 404) {
|
|
983
1018
|
throw new Error(
|
|
@@ -1011,7 +1046,8 @@ async function runWarpGrep(config) {
|
|
|
1011
1046
|
const assistantContent = await callModel(messages, model, {
|
|
1012
1047
|
morphApiKey: config.morphApiKey,
|
|
1013
1048
|
morphApiUrl: config.morphApiUrl,
|
|
1014
|
-
retryConfig: config.retryConfig
|
|
1049
|
+
retryConfig: config.retryConfig,
|
|
1050
|
+
timeout: config.timeout
|
|
1015
1051
|
}).catch((e) => {
|
|
1016
1052
|
errors.push({ message: e instanceof Error ? e.message : String(e) });
|
|
1017
1053
|
return "";
|
|
@@ -1084,7 +1120,7 @@ async function runWarpGrep(config) {
|
|
|
1084
1120
|
}
|
|
1085
1121
|
const parts = ["Relevant context found:"];
|
|
1086
1122
|
for (const f of finishMeta.files) {
|
|
1087
|
-
const ranges = f.lines === "*" ? "*" : f.lines.map(([s, e]) => `${s}-${e}`).join(", ");
|
|
1123
|
+
const ranges = f.lines === "*" ? "*" : Array.isArray(f.lines) ? f.lines.map(([s, e]) => `${s}-${e}`).join(", ") : "*";
|
|
1088
1124
|
parts.push(`- ${f.path}: ${ranges}`);
|
|
1089
1125
|
}
|
|
1090
1126
|
const payload = parts.join("\n");
|
|
@@ -1444,11 +1480,19 @@ Details: ${res.stderr}` : ""}`
|
|
|
1444
1480
|
};
|
|
1445
1481
|
}
|
|
1446
1482
|
const total = lines.length;
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1483
|
+
const rawStart = params.start;
|
|
1484
|
+
const rawEnd = params.end;
|
|
1485
|
+
let s = 1;
|
|
1486
|
+
let e = total;
|
|
1487
|
+
const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
|
|
1488
|
+
const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
|
|
1489
|
+
if (startValid && endValid) {
|
|
1490
|
+
s = rawStart ?? 1;
|
|
1491
|
+
e = Math.min(rawEnd ?? total, total);
|
|
1492
|
+
if (s > total && total > 0 || s > e) {
|
|
1493
|
+
s = 1;
|
|
1494
|
+
e = total;
|
|
1495
|
+
}
|
|
1452
1496
|
}
|
|
1453
1497
|
const out = [];
|
|
1454
1498
|
for (let i = s; i <= e; i += 1) {
|
|
@@ -1624,8 +1668,13 @@ var RemoteCommandsProvider = class {
|
|
|
1624
1668
|
* Read file and add line numbers
|
|
1625
1669
|
*/
|
|
1626
1670
|
async read(params) {
|
|
1627
|
-
const
|
|
1628
|
-
const
|
|
1671
|
+
const rawStart = params.start;
|
|
1672
|
+
const rawEnd = params.end;
|
|
1673
|
+
const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
|
|
1674
|
+
const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
|
|
1675
|
+
const rangeValid = startValid && endValid && (rawStart === void 0 || rawEnd === void 0 || rawStart <= rawEnd);
|
|
1676
|
+
const start = rangeValid && rawStart !== void 0 ? rawStart : 1;
|
|
1677
|
+
const end = rangeValid && rawEnd !== void 0 ? rawEnd : 1e6;
|
|
1629
1678
|
try {
|
|
1630
1679
|
const stdout = await this.commands.read(params.path, start, end);
|
|
1631
1680
|
const contentLines = (stdout || "").split("\n");
|
|
@@ -1729,7 +1778,8 @@ var WarpGrepClient = class {
|
|
|
1729
1778
|
debug: input.debug ?? this.config.debug,
|
|
1730
1779
|
morphApiKey: this.config.morphApiKey,
|
|
1731
1780
|
morphApiUrl: this.config.morphApiUrl,
|
|
1732
|
-
retryConfig: this.config.retryConfig
|
|
1781
|
+
retryConfig: this.config.retryConfig,
|
|
1782
|
+
timeout: this.config.timeout
|
|
1733
1783
|
}
|
|
1734
1784
|
);
|
|
1735
1785
|
}
|
|
@@ -1750,7 +1800,8 @@ async function executeToolCall(input, config) {
|
|
|
1750
1800
|
debug: config.debug ?? false,
|
|
1751
1801
|
morphApiKey: config.morphApiKey,
|
|
1752
1802
|
morphApiUrl: config.morphApiUrl,
|
|
1753
|
-
retryConfig: config.retryConfig
|
|
1803
|
+
retryConfig: config.retryConfig,
|
|
1804
|
+
timeout: config.timeout
|
|
1754
1805
|
});
|
|
1755
1806
|
const finish = result.finish;
|
|
1756
1807
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|