@morphllm/morphsdk 0.2.115 → 0.2.116
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-SYZ75S3S.js → chunk-3JVHMOYJ.js} +2 -2
- package/dist/{chunk-CM75JPVD.js → chunk-5JARN2NG.js} +2 -2
- package/dist/{chunk-TZBDXZFC.js → chunk-62OVBE6G.js} +5 -5
- package/dist/{chunk-GQUNK324.js → chunk-GENFEPHG.js} +2 -2
- package/dist/{chunk-NTDAIKZI.js → chunk-OVNPKTEG.js} +2 -2
- package/dist/{chunk-RBTL6EJG.js → chunk-RBOCP2MX.js} +32 -18
- package/dist/chunk-RBOCP2MX.js.map +1 -0
- package/dist/client.cjs +31 -17
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +6 -6
- package/dist/index.cjs +31 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -6
- package/dist/tools/warp_grep/agent/runner.cjs +31 -17
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +1 -1
- package/dist/tools/warp_grep/anthropic.cjs +31 -17
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +3 -3
- package/dist/tools/warp_grep/client.cjs +31 -17
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +2 -2
- package/dist/tools/warp_grep/gemini.cjs +31 -17
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.js +2 -2
- package/dist/tools/warp_grep/index.cjs +31 -17
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.js +2 -2
- package/dist/tools/warp_grep/openai.cjs +31 -17
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +3 -3
- package/dist/tools/warp_grep/vercel.cjs +31 -17
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-RBTL6EJG.js.map +0 -1
- /package/dist/{chunk-SYZ75S3S.js.map → chunk-3JVHMOYJ.js.map} +0 -0
- /package/dist/{chunk-CM75JPVD.js.map → chunk-5JARN2NG.js.map} +0 -0
- /package/dist/{chunk-TZBDXZFC.js.map → chunk-62OVBE6G.js.map} +0 -0
- /package/dist/{chunk-GQUNK324.js.map → chunk-GENFEPHG.js.map} +0 -0
- /package/dist/{chunk-NTDAIKZI.js.map → chunk-OVNPKTEG.js.map} +0 -0
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
executeToolCallStreaming,
|
|
5
5
|
executeWarpGrep,
|
|
6
6
|
formatResult
|
|
7
|
-
} from "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
7
|
+
} from "../../chunk-OVNPKTEG.js";
|
|
8
|
+
import "../../chunk-RBOCP2MX.js";
|
|
9
9
|
import "../../chunk-PUGSTXLO.js";
|
|
10
10
|
import "../../chunk-3MLWXJTJ.js";
|
|
11
11
|
import "../../chunk-SNGGSPYJ.js";
|
|
@@ -1369,27 +1369,41 @@ async function callModel(messages, model, options = {}) {
|
|
|
1369
1369
|
maxRetries: options.retryConfig?.maxRetries,
|
|
1370
1370
|
timeout: timeoutMs
|
|
1371
1371
|
});
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
data
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1372
|
+
const MAX_EMPTY_RETRIES = 1;
|
|
1373
|
+
for (let attempt = 0; attempt <= MAX_EMPTY_RETRIES; attempt++) {
|
|
1374
|
+
let data;
|
|
1375
|
+
try {
|
|
1376
|
+
data = await client.chat.completions.create({
|
|
1377
|
+
model,
|
|
1378
|
+
temperature: 0,
|
|
1379
|
+
max_tokens: 1024,
|
|
1380
|
+
messages
|
|
1381
|
+
});
|
|
1382
|
+
} catch (error) {
|
|
1383
|
+
if (error instanceof import_openai.default.APIError && error.status === 404) {
|
|
1384
|
+
throw new Error(
|
|
1385
|
+
"The endpoint you are trying to call is likely deprecated. Please update with: npm cache clean --force && npx -y @morphllm/morphmcp@latest or visit: https://morphllm.com/mcp"
|
|
1386
|
+
);
|
|
1387
|
+
}
|
|
1388
|
+
throw error;
|
|
1389
|
+
}
|
|
1390
|
+
const choice = data?.choices?.[0];
|
|
1391
|
+
const content = choice?.message?.content;
|
|
1392
|
+
if (content && typeof content === "string") {
|
|
1393
|
+
return content;
|
|
1394
|
+
}
|
|
1395
|
+
if (attempt === MAX_EMPTY_RETRIES) {
|
|
1396
|
+
const finishReason = choice?.finish_reason ?? "unknown";
|
|
1397
|
+
const hasToolCalls = Array.isArray(choice?.message?.tool_calls) && choice.message.tool_calls.length > 0;
|
|
1398
|
+
const choicesLen = data?.choices?.length ?? 0;
|
|
1399
|
+
const contentType = content === null ? "null" : content === void 0 ? "undefined" : typeof content;
|
|
1382
1400
|
throw new Error(
|
|
1383
|
-
|
|
1401
|
+
`Invalid response from model: content=${contentType}, finish_reason=${finishReason}, has_tool_calls=${hasToolCalls}, choices_length=${choicesLen}`
|
|
1384
1402
|
);
|
|
1385
1403
|
}
|
|
1386
|
-
|
|
1387
|
-
}
|
|
1388
|
-
const content = data?.choices?.[0]?.message?.content;
|
|
1389
|
-
if (!content || typeof content !== "string") {
|
|
1390
|
-
throw new Error("Invalid response from model");
|
|
1404
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
1391
1405
|
}
|
|
1392
|
-
|
|
1406
|
+
throw new Error("Invalid response from model");
|
|
1393
1407
|
}
|
|
1394
1408
|
async function runWarpGrep(config) {
|
|
1395
1409
|
const totalStart = Date.now();
|