@morphllm/morphsdk 0.2.114 → 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-HI35Y6EZ.js → chunk-3JVHMOYJ.js} +18 -5
- package/dist/chunk-3JVHMOYJ.js.map +1 -0
- package/dist/{chunk-ALTKGCG5.js → chunk-5JARN2NG.js} +2 -2
- package/dist/{chunk-3U7AWFBN.js → chunk-62OVBE6G.js} +5 -5
- package/dist/{chunk-FL4ZBHK2.js → chunk-GENFEPHG.js} +2 -2
- package/dist/{chunk-23R562QJ.js → chunk-OVNPKTEG.js} +9 -4
- package/dist/chunk-OVNPKTEG.js.map +1 -0
- package/dist/{chunk-YY7NZLAI.js → chunk-RBOCP2MX.js} +42 -20
- package/dist/chunk-RBOCP2MX.js.map +1 -0
- package/dist/{client-Bm_umdno.d.ts → client-D7iO2TbA.d.ts} +7 -0
- package/dist/client.cjs +61 -23
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +6 -6
- package/dist/index.cjs +61 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/tools/warp_grep/agent/runner.cjs +41 -19
- 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 +39 -19
- 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 +49 -21
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.d.ts +7 -1
- package/dist/tools/warp_grep/client.js +4 -2
- package/dist/tools/warp_grep/gemini.cjs +39 -19
- 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 +47 -21
- 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 +39 -19
- 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 +247 -21
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +7 -0
- package/dist/tools/warp_grep/vercel.js +3 -3
- package/package.json +6 -1
- package/dist/chunk-23R562QJ.js.map +0 -1
- package/dist/chunk-HI35Y6EZ.js.map +0 -1
- package/dist/chunk-YY7NZLAI.js.map +0 -1
- /package/dist/{chunk-ALTKGCG5.js.map → chunk-5JARN2NG.js.map} +0 -0
- /package/dist/{chunk-3U7AWFBN.js.map → chunk-62OVBE6G.js.map} +0 -0
- /package/dist/{chunk-FL4ZBHK2.js.map → chunk-GENFEPHG.js.map} +0 -0
package/dist/client.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import './tools/fastapply/core.js';
|
|
|
3
3
|
import './tools/codebase_search/core.js';
|
|
4
4
|
import './tools/browser/core.js';
|
|
5
5
|
import './tools/warp_grep/client.js';
|
|
6
|
-
export { M as MorphClient, a as MorphClientConfig } from './client-
|
|
6
|
+
export { M as MorphClient, a as MorphClientConfig } from './client-D7iO2TbA.js';
|
|
7
7
|
import './git/client.js';
|
|
8
8
|
import './modelrouter/core.js';
|
|
9
9
|
import './tools/fastapply/types.js';
|
package/dist/client.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MorphClient
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-62OVBE6G.js";
|
|
4
|
+
import "./chunk-GENFEPHG.js";
|
|
5
|
+
import "./chunk-3JVHMOYJ.js";
|
|
6
|
+
import "./chunk-5JARN2NG.js";
|
|
7
7
|
import "./chunk-KW7OEGZK.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-OVNPKTEG.js";
|
|
9
|
+
import "./chunk-RBOCP2MX.js";
|
|
10
10
|
import "./chunk-PUGSTXLO.js";
|
|
11
11
|
import "./chunk-3MLWXJTJ.js";
|
|
12
12
|
import "./chunk-SNGGSPYJ.js";
|
package/dist/index.cjs
CHANGED
|
@@ -3033,27 +3033,41 @@ async function callModel(messages, model, options = {}) {
|
|
|
3033
3033
|
maxRetries: options.retryConfig?.maxRetries,
|
|
3034
3034
|
timeout: timeoutMs
|
|
3035
3035
|
});
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
data
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3036
|
+
const MAX_EMPTY_RETRIES = 1;
|
|
3037
|
+
for (let attempt = 0; attempt <= MAX_EMPTY_RETRIES; attempt++) {
|
|
3038
|
+
let data;
|
|
3039
|
+
try {
|
|
3040
|
+
data = await client.chat.completions.create({
|
|
3041
|
+
model,
|
|
3042
|
+
temperature: 0,
|
|
3043
|
+
max_tokens: 1024,
|
|
3044
|
+
messages
|
|
3045
|
+
});
|
|
3046
|
+
} catch (error) {
|
|
3047
|
+
if (error instanceof import_openai2.default.APIError && error.status === 404) {
|
|
3048
|
+
throw new Error(
|
|
3049
|
+
"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"
|
|
3050
|
+
);
|
|
3051
|
+
}
|
|
3052
|
+
throw error;
|
|
3053
|
+
}
|
|
3054
|
+
const choice = data?.choices?.[0];
|
|
3055
|
+
const content = choice?.message?.content;
|
|
3056
|
+
if (content && typeof content === "string") {
|
|
3057
|
+
return content;
|
|
3058
|
+
}
|
|
3059
|
+
if (attempt === MAX_EMPTY_RETRIES) {
|
|
3060
|
+
const finishReason = choice?.finish_reason ?? "unknown";
|
|
3061
|
+
const hasToolCalls = Array.isArray(choice?.message?.tool_calls) && choice.message.tool_calls.length > 0;
|
|
3062
|
+
const choicesLen = data?.choices?.length ?? 0;
|
|
3063
|
+
const contentType = content === null ? "null" : content === void 0 ? "undefined" : typeof content;
|
|
3046
3064
|
throw new Error(
|
|
3047
|
-
|
|
3065
|
+
`Invalid response from model: content=${contentType}, finish_reason=${finishReason}, has_tool_calls=${hasToolCalls}, choices_length=${choicesLen}`
|
|
3048
3066
|
);
|
|
3049
3067
|
}
|
|
3050
|
-
|
|
3068
|
+
await new Promise((resolve2) => setTimeout(resolve2, 200));
|
|
3051
3069
|
}
|
|
3052
|
-
|
|
3053
|
-
if (!content || typeof content !== "string") {
|
|
3054
|
-
throw new Error("Invalid response from model");
|
|
3055
|
-
}
|
|
3056
|
-
return content;
|
|
3070
|
+
throw new Error("Invalid response from model");
|
|
3057
3071
|
}
|
|
3058
3072
|
async function runWarpGrep(config) {
|
|
3059
3073
|
const totalStart = Date.now();
|
|
@@ -3082,17 +3096,21 @@ async function runWarpGrep(config) {
|
|
|
3082
3096
|
retryConfig: config.retryConfig,
|
|
3083
3097
|
timeout: timeoutMs
|
|
3084
3098
|
}).catch((e) => {
|
|
3085
|
-
|
|
3099
|
+
const errMsg = e instanceof Error ? e.message : String(e);
|
|
3100
|
+
console.error(`[warp_grep] Morph API call failed on turn ${turn}:`, errMsg);
|
|
3101
|
+
errors.push({ message: errMsg });
|
|
3086
3102
|
return "";
|
|
3087
3103
|
});
|
|
3088
3104
|
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
3089
3105
|
if (!assistantContent) {
|
|
3106
|
+
console.error(`[warp_grep] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);
|
|
3090
3107
|
timings.turns.push(turnMetrics);
|
|
3091
3108
|
break;
|
|
3092
3109
|
}
|
|
3093
3110
|
messages.push({ role: "assistant", content: assistantContent });
|
|
3094
3111
|
const toolCalls = parser.parse(assistantContent);
|
|
3095
3112
|
if (toolCalls.length === 0) {
|
|
3113
|
+
console.error(`[warp_grep] No tool calls parsed on turn ${turn}. Assistant content (first 500 chars):`, assistantContent.slice(0, 500));
|
|
3096
3114
|
errors.push({ message: "No tool calls produced by the model. Your MCP is likely out of date! Update it by running: rm -rf ~/.npm/_npx && npm cache clean --force && npx -y @morphllm/morphmcp@latest" });
|
|
3097
3115
|
terminationReason = "terminated";
|
|
3098
3116
|
timings.turns.push(turnMetrics);
|
|
@@ -3225,17 +3243,21 @@ async function* runWarpGrepStreaming(config) {
|
|
|
3225
3243
|
retryConfig: config.retryConfig,
|
|
3226
3244
|
timeout: timeoutMs
|
|
3227
3245
|
}).catch((e) => {
|
|
3228
|
-
|
|
3246
|
+
const errMsg = e instanceof Error ? e.message : String(e);
|
|
3247
|
+
console.error(`[warp_grep:stream] Morph API call failed on turn ${turn}:`, errMsg);
|
|
3248
|
+
errors.push({ message: errMsg });
|
|
3229
3249
|
return "";
|
|
3230
3250
|
});
|
|
3231
3251
|
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
3232
3252
|
if (!assistantContent) {
|
|
3253
|
+
console.error(`[warp_grep:stream] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);
|
|
3233
3254
|
timings.turns.push(turnMetrics);
|
|
3234
3255
|
break;
|
|
3235
3256
|
}
|
|
3236
3257
|
messages.push({ role: "assistant", content: assistantContent });
|
|
3237
3258
|
const toolCalls = parser.parse(assistantContent);
|
|
3238
3259
|
if (toolCalls.length === 0) {
|
|
3260
|
+
console.error(`[warp_grep:stream] No tool calls parsed on turn ${turn}. Assistant content (first 500 chars):`, assistantContent.slice(0, 500));
|
|
3239
3261
|
errors.push({ message: "No tool calls produced by the model. Your MCP is likely out of date! Update it by running: rm -rf ~/.npm/_npx && npm cache clean --force && npx -y @morphllm/morphmcp@latest" });
|
|
3240
3262
|
terminationReason = "terminated";
|
|
3241
3263
|
timings.turns.push(turnMetrics);
|
|
@@ -3582,7 +3604,9 @@ async function executeToolCall(input, config) {
|
|
|
3582
3604
|
});
|
|
3583
3605
|
const finish = result.finish;
|
|
3584
3606
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|
|
3585
|
-
|
|
3607
|
+
const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
|
|
3608
|
+
console.error(`[warp_grep] executeToolCall failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);
|
|
3609
|
+
return { success: false, error: `Search did not complete: ${errorDetails}` };
|
|
3586
3610
|
}
|
|
3587
3611
|
const contexts = (finish.resolved ?? []).map((r) => ({
|
|
3588
3612
|
file: r.path,
|
|
@@ -3594,7 +3618,9 @@ async function executeToolCall(input, config) {
|
|
|
3594
3618
|
function processAgentResult(result) {
|
|
3595
3619
|
const finish = result.finish;
|
|
3596
3620
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|
|
3597
|
-
|
|
3621
|
+
const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
|
|
3622
|
+
console.error(`[warp_grep] processAgentResult failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);
|
|
3623
|
+
return { success: false, error: `Search did not complete: ${errorDetails}` };
|
|
3598
3624
|
}
|
|
3599
3625
|
const contexts = (finish.resolved ?? []).map((r) => ({
|
|
3600
3626
|
file: r.path,
|
|
@@ -5227,14 +5253,26 @@ function createWarpGrepTool3(config) {
|
|
|
5227
5253
|
description: config.description ?? WARP_GREP_DESCRIPTION,
|
|
5228
5254
|
inputSchema: schema,
|
|
5229
5255
|
execute: async (params) => {
|
|
5230
|
-
const
|
|
5256
|
+
const steps = [];
|
|
5257
|
+
const generator = executeToolCallStreaming(params, config);
|
|
5258
|
+
let result;
|
|
5259
|
+
for (; ; ) {
|
|
5260
|
+
const { value, done } = await generator.next();
|
|
5261
|
+
if (done) {
|
|
5262
|
+
result = value;
|
|
5263
|
+
break;
|
|
5264
|
+
}
|
|
5265
|
+
steps.push(value);
|
|
5266
|
+
}
|
|
5231
5267
|
if (!result.success) {
|
|
5232
5268
|
throw new Error(`Failed to search codebase: ${result.error}`);
|
|
5233
5269
|
}
|
|
5270
|
+
const allToolCalls = steps.flatMap((s) => s.toolCalls);
|
|
5234
5271
|
return {
|
|
5235
5272
|
success: true,
|
|
5236
5273
|
contexts: result.contexts,
|
|
5237
|
-
summary: result.summary
|
|
5274
|
+
summary: result.summary,
|
|
5275
|
+
progress: allToolCalls.length > 0 ? { turn: steps.length, toolCalls: allToolCalls } : void 0
|
|
5238
5276
|
};
|
|
5239
5277
|
}
|
|
5240
5278
|
});
|