@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
package/dist/client.cjs
CHANGED
|
@@ -987,9 +987,15 @@ async function checkHealth(config = {}) {
|
|
|
987
987
|
}
|
|
988
988
|
|
|
989
989
|
// tools/warp_grep/agent/config.ts
|
|
990
|
+
var parseEnvTimeout = (envValue, defaultMs) => {
|
|
991
|
+
if (!envValue) return defaultMs;
|
|
992
|
+
const parsed = parseInt(envValue, 10);
|
|
993
|
+
return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
|
|
994
|
+
};
|
|
990
995
|
var AGENT_CONFIG = {
|
|
991
996
|
MAX_TURNS: 4,
|
|
992
|
-
|
|
997
|
+
/** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
|
|
998
|
+
TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 3e4),
|
|
993
999
|
MAX_CONTEXT_CHARS: 54e4,
|
|
994
1000
|
MAX_OUTPUT_LINES: 200,
|
|
995
1001
|
MAX_READ_LINES: 800,
|
|
@@ -1555,10 +1561,25 @@ async function toolGrep(provider, args) {
|
|
|
1555
1561
|
}
|
|
1556
1562
|
|
|
1557
1563
|
// tools/warp_grep/agent/tools/read.ts
|
|
1564
|
+
function isValidRange(start, end) {
|
|
1565
|
+
return typeof start === "number" && typeof end === "number" && Number.isFinite(start) && Number.isFinite(end) && start > 0 && end >= start;
|
|
1566
|
+
}
|
|
1558
1567
|
async function toolRead(provider, args) {
|
|
1559
|
-
if (args.lines && args.lines.length > 0) {
|
|
1568
|
+
if (args.lines && Array.isArray(args.lines) && args.lines.length > 0) {
|
|
1569
|
+
const validRanges = [];
|
|
1570
|
+
for (const range of args.lines) {
|
|
1571
|
+
if (Array.isArray(range) && range.length >= 2 && isValidRange(range[0], range[1])) {
|
|
1572
|
+
validRanges.push([range[0], range[1]]);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
if (validRanges.length === 0) {
|
|
1576
|
+
const res2 = await provider.read({ path: args.path });
|
|
1577
|
+
if (res2.error) return res2.error;
|
|
1578
|
+
if (!res2.lines.length) return "(empty file)";
|
|
1579
|
+
return res2.lines.join("\n");
|
|
1580
|
+
}
|
|
1560
1581
|
const chunks = [];
|
|
1561
|
-
for (const [start, end] of
|
|
1582
|
+
for (const [start, end] of validRanges) {
|
|
1562
1583
|
const res2 = await provider.read({ path: args.path, start, end });
|
|
1563
1584
|
if (res2.error) return res2.error;
|
|
1564
1585
|
chunks.push(res2.lines.join("\n"));
|
|
@@ -1594,14 +1615,28 @@ async function toolListDirectory(provider, args) {
|
|
|
1594
1615
|
}
|
|
1595
1616
|
|
|
1596
1617
|
// tools/warp_grep/agent/tools/finish.ts
|
|
1618
|
+
function isValidRange2(range) {
|
|
1619
|
+
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];
|
|
1620
|
+
}
|
|
1621
|
+
function extractValidRanges(lines) {
|
|
1622
|
+
if (!Array.isArray(lines)) return null;
|
|
1623
|
+
const valid = [];
|
|
1624
|
+
for (const range of lines) {
|
|
1625
|
+
if (isValidRange2(range)) {
|
|
1626
|
+
valid.push([range[0], range[1]]);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
return valid.length > 0 ? valid : null;
|
|
1630
|
+
}
|
|
1597
1631
|
async function readFinishFiles(repoRoot, files, reader) {
|
|
1598
1632
|
const out = [];
|
|
1599
1633
|
for (const f of files) {
|
|
1600
|
-
|
|
1634
|
+
const validRanges = f.lines === "*" ? null : extractValidRanges(f.lines);
|
|
1635
|
+
if (f.lines === "*" || !validRanges) {
|
|
1601
1636
|
const lines = await reader(f.path);
|
|
1602
1637
|
out.push({ path: f.path, ranges: "*", content: lines.join("\n") });
|
|
1603
1638
|
} else {
|
|
1604
|
-
const ranges = mergeRanges(
|
|
1639
|
+
const ranges = mergeRanges(validRanges);
|
|
1605
1640
|
const chunks = [];
|
|
1606
1641
|
for (const [s, e] of ranges) {
|
|
1607
1642
|
const lines = await reader(f.path, s, e);
|
|
@@ -1828,7 +1863,8 @@ async function callModel(messages, model, options = {}) {
|
|
|
1828
1863
|
},
|
|
1829
1864
|
options.retryConfig
|
|
1830
1865
|
);
|
|
1831
|
-
const
|
|
1866
|
+
const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1867
|
+
const resp = await withTimeout(fetchPromise, timeoutMs, "morph-warp-grep request timed out");
|
|
1832
1868
|
if (!resp.ok) {
|
|
1833
1869
|
if (resp.status === 404) {
|
|
1834
1870
|
throw new Error(
|
|
@@ -1862,7 +1898,8 @@ async function runWarpGrep(config) {
|
|
|
1862
1898
|
const assistantContent = await callModel(messages, model, {
|
|
1863
1899
|
morphApiKey: config.morphApiKey,
|
|
1864
1900
|
morphApiUrl: config.morphApiUrl,
|
|
1865
|
-
retryConfig: config.retryConfig
|
|
1901
|
+
retryConfig: config.retryConfig,
|
|
1902
|
+
timeout: config.timeout
|
|
1866
1903
|
}).catch((e) => {
|
|
1867
1904
|
errors.push({ message: e instanceof Error ? e.message : String(e) });
|
|
1868
1905
|
return "";
|
|
@@ -1935,7 +1972,7 @@ async function runWarpGrep(config) {
|
|
|
1935
1972
|
}
|
|
1936
1973
|
const parts = ["Relevant context found:"];
|
|
1937
1974
|
for (const f of finishMeta.files) {
|
|
1938
|
-
const ranges = f.lines === "*" ? "*" : f.lines.map(([s, e]) => `${s}-${e}`).join(", ");
|
|
1975
|
+
const ranges = f.lines === "*" ? "*" : Array.isArray(f.lines) ? f.lines.map(([s, e]) => `${s}-${e}`).join(", ") : "*";
|
|
1939
1976
|
parts.push(`- ${f.path}: ${ranges}`);
|
|
1940
1977
|
}
|
|
1941
1978
|
const payload = parts.join("\n");
|
|
@@ -2295,11 +2332,19 @@ Details: ${res.stderr}` : ""}`
|
|
|
2295
2332
|
};
|
|
2296
2333
|
}
|
|
2297
2334
|
const total = lines.length;
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2335
|
+
const rawStart = params.start;
|
|
2336
|
+
const rawEnd = params.end;
|
|
2337
|
+
let s = 1;
|
|
2338
|
+
let e = total;
|
|
2339
|
+
const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
|
|
2340
|
+
const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
|
|
2341
|
+
if (startValid && endValid) {
|
|
2342
|
+
s = rawStart ?? 1;
|
|
2343
|
+
e = Math.min(rawEnd ?? total, total);
|
|
2344
|
+
if (s > total && total > 0 || s > e) {
|
|
2345
|
+
s = 1;
|
|
2346
|
+
e = total;
|
|
2347
|
+
}
|
|
2303
2348
|
}
|
|
2304
2349
|
const out = [];
|
|
2305
2350
|
for (let i = s; i <= e; i += 1) {
|
|
@@ -2475,8 +2520,13 @@ var RemoteCommandsProvider = class {
|
|
|
2475
2520
|
* Read file and add line numbers
|
|
2476
2521
|
*/
|
|
2477
2522
|
async read(params) {
|
|
2478
|
-
const
|
|
2479
|
-
const
|
|
2523
|
+
const rawStart = params.start;
|
|
2524
|
+
const rawEnd = params.end;
|
|
2525
|
+
const startValid = rawStart === void 0 || Number.isFinite(rawStart) && rawStart > 0;
|
|
2526
|
+
const endValid = rawEnd === void 0 || Number.isFinite(rawEnd) && rawEnd > 0;
|
|
2527
|
+
const rangeValid = startValid && endValid && (rawStart === void 0 || rawEnd === void 0 || rawStart <= rawEnd);
|
|
2528
|
+
const start = rangeValid && rawStart !== void 0 ? rawStart : 1;
|
|
2529
|
+
const end = rangeValid && rawEnd !== void 0 ? rawEnd : 1e6;
|
|
2480
2530
|
try {
|
|
2481
2531
|
const stdout = await this.commands.read(params.path, start, end);
|
|
2482
2532
|
const contentLines = (stdout || "").split("\n");
|
|
@@ -2580,7 +2630,8 @@ var WarpGrepClient = class {
|
|
|
2580
2630
|
debug: input.debug ?? this.config.debug,
|
|
2581
2631
|
morphApiKey: this.config.morphApiKey,
|
|
2582
2632
|
morphApiUrl: this.config.morphApiUrl,
|
|
2583
|
-
retryConfig: this.config.retryConfig
|
|
2633
|
+
retryConfig: this.config.retryConfig,
|
|
2634
|
+
timeout: this.config.timeout
|
|
2584
2635
|
}
|
|
2585
2636
|
);
|
|
2586
2637
|
}
|
|
@@ -2597,7 +2648,8 @@ async function executeToolCall(input, config) {
|
|
|
2597
2648
|
debug: config.debug ?? false,
|
|
2598
2649
|
morphApiKey: config.morphApiKey,
|
|
2599
2650
|
morphApiUrl: config.morphApiUrl,
|
|
2600
|
-
retryConfig: config.retryConfig
|
|
2651
|
+
retryConfig: config.retryConfig,
|
|
2652
|
+
timeout: config.timeout
|
|
2601
2653
|
});
|
|
2602
2654
|
const finish = result.finish;
|
|
2603
2655
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|