@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export { WarpGrepClient, executeToolCall, executeWarpGrep, formatResult } from './client.js';
|
|
3
|
-
export { R as RemoteCommands, W as WarpGrepClientConfig, c as WarpGrepContext, a as WarpGrepInput, b as WarpGrepResult, d as WarpGrepToolConfig } from '../../types-
|
|
3
|
+
export { R as RemoteCommands, W as WarpGrepClientConfig, c as WarpGrepContext, a as WarpGrepInput, b as WarpGrepResult, d as WarpGrepToolConfig } from '../../types-Cv4LpqVl.js';
|
|
4
4
|
export { GrepResult, ListDirectoryEntry, ReadResult, WarpGrepProvider } from './providers/types.js';
|
|
5
5
|
export { LocalRipgrepProvider } from './providers/local.js';
|
|
6
6
|
export { RemoteCommandsProvider } from './providers/remote.js';
|
|
@@ -10,20 +10,20 @@ import {
|
|
|
10
10
|
executeToolCall,
|
|
11
11
|
executeWarpGrep,
|
|
12
12
|
formatResult
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-FJKPMMNQ.js";
|
|
14
14
|
import {
|
|
15
15
|
runWarpGrep
|
|
16
|
-
} from "../../chunk-
|
|
16
|
+
} from "../../chunk-WIAYUEJK.js";
|
|
17
17
|
import {
|
|
18
18
|
RemoteCommandsProvider
|
|
19
|
-
} from "../../chunk-
|
|
19
|
+
} from "../../chunk-PUGSTXLO.js";
|
|
20
20
|
import {
|
|
21
21
|
normalizeFinishFiles,
|
|
22
22
|
readFinishFiles,
|
|
23
23
|
toolGrep,
|
|
24
24
|
toolListDirectory,
|
|
25
25
|
toolRead
|
|
26
|
-
} from "../../chunk-
|
|
26
|
+
} from "../../chunk-P2O5JKE5.js";
|
|
27
27
|
import "../../chunk-APP75CBN.js";
|
|
28
28
|
import "../../chunk-5QRN3JNB.js";
|
|
29
29
|
import {
|
|
@@ -32,13 +32,13 @@ import {
|
|
|
32
32
|
} from "../../chunk-FMLHRJDF.js";
|
|
33
33
|
import {
|
|
34
34
|
LocalRipgrepProvider
|
|
35
|
-
} from "../../chunk-
|
|
35
|
+
} from "../../chunk-4KMBU6T3.js";
|
|
36
36
|
import "../../chunk-G2RSY56Q.js";
|
|
37
37
|
import {
|
|
38
38
|
fixPathRepetition
|
|
39
39
|
} from "../../chunk-YPKNMYD4.js";
|
|
40
40
|
import "../../chunk-TPP2UGQP.js";
|
|
41
|
-
import "../../chunk-
|
|
41
|
+
import "../../chunk-5PNMAWLC.js";
|
|
42
42
|
import "../../chunk-4VWJFZVS.js";
|
|
43
43
|
import "../../chunk-PZ5AY32C.js";
|
|
44
44
|
export {
|
|
@@ -40,9 +40,15 @@ __export(openai_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(openai_exports);
|
|
41
41
|
|
|
42
42
|
// tools/warp_grep/agent/config.ts
|
|
43
|
+
var parseEnvTimeout = (envValue, defaultMs) => {
|
|
44
|
+
if (!envValue) return defaultMs;
|
|
45
|
+
const parsed = parseInt(envValue, 10);
|
|
46
|
+
return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
|
|
47
|
+
};
|
|
43
48
|
var AGENT_CONFIG = {
|
|
44
49
|
MAX_TURNS: 4,
|
|
45
|
-
|
|
50
|
+
/** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
|
|
51
|
+
TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 3e4),
|
|
46
52
|
MAX_CONTEXT_CHARS: 54e4,
|
|
47
53
|
MAX_OUTPUT_LINES: 200,
|
|
48
54
|
MAX_READ_LINES: 800,
|
|
@@ -608,10 +614,25 @@ async function toolGrep(provider, args) {
|
|
|
608
614
|
}
|
|
609
615
|
|
|
610
616
|
// tools/warp_grep/agent/tools/read.ts
|
|
617
|
+
function isValidRange(start, end) {
|
|
618
|
+
return typeof start === "number" && typeof end === "number" && Number.isFinite(start) && Number.isFinite(end) && start > 0 && end >= start;
|
|
619
|
+
}
|
|
611
620
|
async function toolRead(provider, args) {
|
|
612
|
-
if (args.lines && args.lines.length > 0) {
|
|
621
|
+
if (args.lines && Array.isArray(args.lines) && args.lines.length > 0) {
|
|
622
|
+
const validRanges = [];
|
|
623
|
+
for (const range of args.lines) {
|
|
624
|
+
if (Array.isArray(range) && range.length >= 2 && isValidRange(range[0], range[1])) {
|
|
625
|
+
validRanges.push([range[0], range[1]]);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if (validRanges.length === 0) {
|
|
629
|
+
const res2 = await provider.read({ path: args.path });
|
|
630
|
+
if (res2.error) return res2.error;
|
|
631
|
+
if (!res2.lines.length) return "(empty file)";
|
|
632
|
+
return res2.lines.join("\n");
|
|
633
|
+
}
|
|
613
634
|
const chunks = [];
|
|
614
|
-
for (const [start, end] of
|
|
635
|
+
for (const [start, end] of validRanges) {
|
|
615
636
|
const res2 = await provider.read({ path: args.path, start, end });
|
|
616
637
|
if (res2.error) return res2.error;
|
|
617
638
|
chunks.push(res2.lines.join("\n"));
|
|
@@ -647,14 +668,28 @@ async function toolListDirectory(provider, args) {
|
|
|
647
668
|
}
|
|
648
669
|
|
|
649
670
|
// tools/warp_grep/agent/tools/finish.ts
|
|
671
|
+
function isValidRange2(range) {
|
|
672
|
+
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];
|
|
673
|
+
}
|
|
674
|
+
function extractValidRanges(lines) {
|
|
675
|
+
if (!Array.isArray(lines)) return null;
|
|
676
|
+
const valid = [];
|
|
677
|
+
for (const range of lines) {
|
|
678
|
+
if (isValidRange2(range)) {
|
|
679
|
+
valid.push([range[0], range[1]]);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return valid.length > 0 ? valid : null;
|
|
683
|
+
}
|
|
650
684
|
async function readFinishFiles(repoRoot, files, reader) {
|
|
651
685
|
const out = [];
|
|
652
686
|
for (const f of files) {
|
|
653
|
-
|
|
687
|
+
const validRanges = f.lines === "*" ? null : extractValidRanges(f.lines);
|
|
688
|
+
if (f.lines === "*" || !validRanges) {
|
|
654
689
|
const lines = await reader(f.path);
|
|
655
690
|
out.push({ path: f.path, ranges: "*", content: lines.join("\n") });
|
|
656
691
|
} else {
|
|
657
|
-
const ranges = mergeRanges(
|
|
692
|
+
const ranges = mergeRanges(validRanges);
|
|
658
693
|
const chunks = [];
|
|
659
694
|
for (const [s, e] of ranges) {
|
|
660
695
|
const lines = await reader(f.path, s, e);
|
|
@@ -955,7 +990,8 @@ async function callModel(messages, model, options = {}) {
|
|
|
955
990
|
},
|
|
956
991
|
options.retryConfig
|
|
957
992
|
);
|
|
958
|
-
const
|
|
993
|
+
const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
994
|
+
const resp = await withTimeout(fetchPromise, timeoutMs, "morph-warp-grep request timed out");
|
|
959
995
|
if (!resp.ok) {
|
|
960
996
|
if (resp.status === 404) {
|
|
961
997
|
throw new Error(
|
|
@@ -989,7 +1025,8 @@ async function runWarpGrep(config) {
|
|
|
989
1025
|
const assistantContent = await callModel(messages, model, {
|
|
990
1026
|
morphApiKey: config.morphApiKey,
|
|
991
1027
|
morphApiUrl: config.morphApiUrl,
|
|
992
|
-
retryConfig: config.retryConfig
|
|
1028
|
+
retryConfig: config.retryConfig,
|
|
1029
|
+
timeout: config.timeout
|
|
993
1030
|
}).catch((e) => {
|
|
994
1031
|
errors.push({ message: e instanceof Error ? e.message : String(e) });
|
|
995
1032
|
return "";
|
|
@@ -1062,7 +1099,7 @@ async function runWarpGrep(config) {
|
|
|
1062
1099
|
}
|
|
1063
1100
|
const parts = ["Relevant context found:"];
|
|
1064
1101
|
for (const f of finishMeta.files) {
|
|
1065
|
-
const ranges = f.lines === "*" ? "*" : f.lines.map(([s, e]) => `${s}-${e}`).join(", ");
|
|
1102
|
+
const ranges = f.lines === "*" ? "*" : Array.isArray(f.lines) ? f.lines.map(([s, e]) => `${s}-${e}`).join(", ") : "*";
|
|
1066
1103
|
parts.push(`- ${f.path}: ${ranges}`);
|
|
1067
1104
|
}
|
|
1068
1105
|
const payload = parts.join("\n");
|
|
@@ -1422,11 +1459,19 @@ Details: ${res.stderr}` : ""}`
|
|
|
1422
1459
|
};
|
|
1423
1460
|
}
|
|
1424
1461
|
const total = lines.length;
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1462
|
+
const rawStart = params.start;
|
|
1463
|
+
const rawEnd = params.end;
|
|
1464
|
+
let s = 1;
|
|
1465
|
+
let e = total;
|
|
1466
|
+
const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
|
|
1467
|
+
const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
|
|
1468
|
+
if (startValid && endValid) {
|
|
1469
|
+
s = rawStart ?? 1;
|
|
1470
|
+
e = Math.min(rawEnd ?? total, total);
|
|
1471
|
+
if (s > total && total > 0 || s > e) {
|
|
1472
|
+
s = 1;
|
|
1473
|
+
e = total;
|
|
1474
|
+
}
|
|
1430
1475
|
}
|
|
1431
1476
|
const out = [];
|
|
1432
1477
|
for (let i = s; i <= e; i += 1) {
|
|
@@ -1602,8 +1647,13 @@ var RemoteCommandsProvider = class {
|
|
|
1602
1647
|
* Read file and add line numbers
|
|
1603
1648
|
*/
|
|
1604
1649
|
async read(params) {
|
|
1605
|
-
const
|
|
1606
|
-
const
|
|
1650
|
+
const rawStart = params.start;
|
|
1651
|
+
const rawEnd = params.end;
|
|
1652
|
+
const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
|
|
1653
|
+
const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
|
|
1654
|
+
const rangeValid = startValid && endValid && (rawStart === void 0 || rawEnd === void 0 || rawStart <= rawEnd);
|
|
1655
|
+
const start = rangeValid && rawStart !== void 0 ? rawStart : 1;
|
|
1656
|
+
const end = rangeValid && rawEnd !== void 0 ? rawEnd : 1e6;
|
|
1607
1657
|
try {
|
|
1608
1658
|
const stdout = await this.commands.read(params.path, start, end);
|
|
1609
1659
|
const contentLines = (stdout || "").split("\n");
|
|
@@ -1675,7 +1725,8 @@ async function executeToolCall(input, config) {
|
|
|
1675
1725
|
debug: config.debug ?? false,
|
|
1676
1726
|
morphApiKey: config.morphApiKey,
|
|
1677
1727
|
morphApiUrl: config.morphApiUrl,
|
|
1678
|
-
retryConfig: config.retryConfig
|
|
1728
|
+
retryConfig: config.retryConfig,
|
|
1729
|
+
timeout: config.timeout
|
|
1679
1730
|
});
|
|
1680
1731
|
const finish = result.finish;
|
|
1681
1732
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|