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