@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
|
@@ -41,9 +41,15 @@ __export(gemini_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(gemini_exports);
|
|
42
42
|
|
|
43
43
|
// tools/warp_grep/agent/config.ts
|
|
44
|
+
var parseEnvTimeout = (envValue, defaultMs) => {
|
|
45
|
+
if (!envValue) return defaultMs;
|
|
46
|
+
const parsed = parseInt(envValue, 10);
|
|
47
|
+
return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
|
|
48
|
+
};
|
|
44
49
|
var AGENT_CONFIG = {
|
|
45
50
|
MAX_TURNS: 4,
|
|
46
|
-
|
|
51
|
+
/** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
|
|
52
|
+
TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 3e4),
|
|
47
53
|
MAX_CONTEXT_CHARS: 54e4,
|
|
48
54
|
MAX_OUTPUT_LINES: 200,
|
|
49
55
|
MAX_READ_LINES: 800,
|
|
@@ -609,10 +615,25 @@ async function toolGrep(provider, args) {
|
|
|
609
615
|
}
|
|
610
616
|
|
|
611
617
|
// tools/warp_grep/agent/tools/read.ts
|
|
618
|
+
function isValidRange(start, end) {
|
|
619
|
+
return typeof start === "number" && typeof end === "number" && Number.isFinite(start) && Number.isFinite(end) && start > 0 && end >= start;
|
|
620
|
+
}
|
|
612
621
|
async function toolRead(provider, args) {
|
|
613
|
-
if (args.lines && args.lines.length > 0) {
|
|
622
|
+
if (args.lines && Array.isArray(args.lines) && args.lines.length > 0) {
|
|
623
|
+
const validRanges = [];
|
|
624
|
+
for (const range of args.lines) {
|
|
625
|
+
if (Array.isArray(range) && range.length >= 2 && isValidRange(range[0], range[1])) {
|
|
626
|
+
validRanges.push([range[0], range[1]]);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
if (validRanges.length === 0) {
|
|
630
|
+
const res2 = await provider.read({ path: args.path });
|
|
631
|
+
if (res2.error) return res2.error;
|
|
632
|
+
if (!res2.lines.length) return "(empty file)";
|
|
633
|
+
return res2.lines.join("\n");
|
|
634
|
+
}
|
|
614
635
|
const chunks = [];
|
|
615
|
-
for (const [start, end] of
|
|
636
|
+
for (const [start, end] of validRanges) {
|
|
616
637
|
const res2 = await provider.read({ path: args.path, start, end });
|
|
617
638
|
if (res2.error) return res2.error;
|
|
618
639
|
chunks.push(res2.lines.join("\n"));
|
|
@@ -648,14 +669,28 @@ async function toolListDirectory(provider, args) {
|
|
|
648
669
|
}
|
|
649
670
|
|
|
650
671
|
// tools/warp_grep/agent/tools/finish.ts
|
|
672
|
+
function isValidRange2(range) {
|
|
673
|
+
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];
|
|
674
|
+
}
|
|
675
|
+
function extractValidRanges(lines) {
|
|
676
|
+
if (!Array.isArray(lines)) return null;
|
|
677
|
+
const valid = [];
|
|
678
|
+
for (const range of lines) {
|
|
679
|
+
if (isValidRange2(range)) {
|
|
680
|
+
valid.push([range[0], range[1]]);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return valid.length > 0 ? valid : null;
|
|
684
|
+
}
|
|
651
685
|
async function readFinishFiles(repoRoot, files, reader) {
|
|
652
686
|
const out = [];
|
|
653
687
|
for (const f of files) {
|
|
654
|
-
|
|
688
|
+
const validRanges = f.lines === "*" ? null : extractValidRanges(f.lines);
|
|
689
|
+
if (f.lines === "*" || !validRanges) {
|
|
655
690
|
const lines = await reader(f.path);
|
|
656
691
|
out.push({ path: f.path, ranges: "*", content: lines.join("\n") });
|
|
657
692
|
} else {
|
|
658
|
-
const ranges = mergeRanges(
|
|
693
|
+
const ranges = mergeRanges(validRanges);
|
|
659
694
|
const chunks = [];
|
|
660
695
|
for (const [s, e] of ranges) {
|
|
661
696
|
const lines = await reader(f.path, s, e);
|
|
@@ -956,7 +991,8 @@ async function callModel(messages, model, options = {}) {
|
|
|
956
991
|
},
|
|
957
992
|
options.retryConfig
|
|
958
993
|
);
|
|
959
|
-
const
|
|
994
|
+
const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
995
|
+
const resp = await withTimeout(fetchPromise, timeoutMs, "morph-warp-grep request timed out");
|
|
960
996
|
if (!resp.ok) {
|
|
961
997
|
if (resp.status === 404) {
|
|
962
998
|
throw new Error(
|
|
@@ -990,7 +1026,8 @@ async function runWarpGrep(config) {
|
|
|
990
1026
|
const assistantContent = await callModel(messages, model, {
|
|
991
1027
|
morphApiKey: config.morphApiKey,
|
|
992
1028
|
morphApiUrl: config.morphApiUrl,
|
|
993
|
-
retryConfig: config.retryConfig
|
|
1029
|
+
retryConfig: config.retryConfig,
|
|
1030
|
+
timeout: config.timeout
|
|
994
1031
|
}).catch((e) => {
|
|
995
1032
|
errors.push({ message: e instanceof Error ? e.message : String(e) });
|
|
996
1033
|
return "";
|
|
@@ -1063,7 +1100,7 @@ async function runWarpGrep(config) {
|
|
|
1063
1100
|
}
|
|
1064
1101
|
const parts = ["Relevant context found:"];
|
|
1065
1102
|
for (const f of finishMeta.files) {
|
|
1066
|
-
const ranges = f.lines === "*" ? "*" : f.lines.map(([s, e]) => `${s}-${e}`).join(", ");
|
|
1103
|
+
const ranges = f.lines === "*" ? "*" : Array.isArray(f.lines) ? f.lines.map(([s, e]) => `${s}-${e}`).join(", ") : "*";
|
|
1067
1104
|
parts.push(`- ${f.path}: ${ranges}`);
|
|
1068
1105
|
}
|
|
1069
1106
|
const payload = parts.join("\n");
|
|
@@ -1423,11 +1460,19 @@ Details: ${res.stderr}` : ""}`
|
|
|
1423
1460
|
};
|
|
1424
1461
|
}
|
|
1425
1462
|
const total = lines.length;
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1463
|
+
const rawStart = params.start;
|
|
1464
|
+
const rawEnd = params.end;
|
|
1465
|
+
let s = 1;
|
|
1466
|
+
let e = total;
|
|
1467
|
+
const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
|
|
1468
|
+
const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
|
|
1469
|
+
if (startValid && endValid) {
|
|
1470
|
+
s = rawStart ?? 1;
|
|
1471
|
+
e = Math.min(rawEnd ?? total, total);
|
|
1472
|
+
if (s > total && total > 0 || s > e) {
|
|
1473
|
+
s = 1;
|
|
1474
|
+
e = total;
|
|
1475
|
+
}
|
|
1431
1476
|
}
|
|
1432
1477
|
const out = [];
|
|
1433
1478
|
for (let i = s; i <= e; i += 1) {
|
|
@@ -1603,8 +1648,13 @@ var RemoteCommandsProvider = class {
|
|
|
1603
1648
|
* Read file and add line numbers
|
|
1604
1649
|
*/
|
|
1605
1650
|
async read(params) {
|
|
1606
|
-
const
|
|
1607
|
-
const
|
|
1651
|
+
const rawStart = params.start;
|
|
1652
|
+
const rawEnd = params.end;
|
|
1653
|
+
const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
|
|
1654
|
+
const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
|
|
1655
|
+
const rangeValid = startValid && endValid && (rawStart === void 0 || rawEnd === void 0 || rawStart <= rawEnd);
|
|
1656
|
+
const start = rangeValid && rawStart !== void 0 ? rawStart : 1;
|
|
1657
|
+
const end = rangeValid && rawEnd !== void 0 ? rawEnd : 1e6;
|
|
1608
1658
|
try {
|
|
1609
1659
|
const stdout = await this.commands.read(params.path, start, end);
|
|
1610
1660
|
const contentLines = (stdout || "").split("\n");
|
|
@@ -1676,7 +1726,8 @@ async function executeToolCall(input, config) {
|
|
|
1676
1726
|
debug: config.debug ?? false,
|
|
1677
1727
|
morphApiKey: config.morphApiKey,
|
|
1678
1728
|
morphApiUrl: config.morphApiUrl,
|
|
1679
|
-
retryConfig: config.retryConfig
|
|
1729
|
+
retryConfig: config.retryConfig,
|
|
1730
|
+
timeout: config.timeout
|
|
1680
1731
|
});
|
|
1681
1732
|
const finish = result.finish;
|
|
1682
1733
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|