@morphllm/morphsdk 0.2.82 → 0.2.83
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-EK5ZEOI3.js → chunk-HPR6BJA7.js} +5 -5
- package/dist/{chunk-FJKPMMNQ.js → chunk-HRK53IKL.js} +2 -2
- package/dist/{chunk-24EYSWME.js → chunk-LXG37353.js} +2 -2
- package/dist/{chunk-WIAYUEJK.js → chunk-QOYI77CN.js} +25 -5
- package/dist/chunk-QOYI77CN.js.map +1 -0
- package/dist/{chunk-ZLJAODDJ.js → chunk-RL4JBZ3T.js} +2 -2
- package/dist/{chunk-3ONNAQZU.js → chunk-S27A4NQM.js} +2 -2
- package/dist/client.cjs +24 -4
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +6 -6
- package/dist/index.cjs +24 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -6
- package/dist/tools/warp_grep/agent/runner.cjs +24 -4
- 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/agent/types.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/types.d.ts +14 -1
- package/dist/tools/warp_grep/anthropic.cjs +24 -4
- 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 +24 -4
- 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 +24 -4
- 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 +24 -4
- 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 +24 -4
- 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 +24 -4
- 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-WIAYUEJK.js.map +0 -1
- /package/dist/{chunk-EK5ZEOI3.js.map → chunk-HPR6BJA7.js.map} +0 -0
- /package/dist/{chunk-FJKPMMNQ.js.map → chunk-HRK53IKL.js.map} +0 -0
- /package/dist/{chunk-24EYSWME.js.map → chunk-LXG37353.js.map} +0 -0
- /package/dist/{chunk-ZLJAODDJ.js.map → chunk-RL4JBZ3T.js.map} +0 -0
- /package/dist/{chunk-3ONNAQZU.js.map → chunk-S27A4NQM.js.map} +0 -0
|
@@ -1008,10 +1008,15 @@ async function callModel(messages, model, options = {}) {
|
|
|
1008
1008
|
return content;
|
|
1009
1009
|
}
|
|
1010
1010
|
async function runWarpGrep(config) {
|
|
1011
|
+
const totalStart = Date.now();
|
|
1012
|
+
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1013
|
+
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1011
1014
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1012
1015
|
const messages = [];
|
|
1013
1016
|
messages.push({ role: "system", content: getSystemPrompt() });
|
|
1017
|
+
const initialStateStart = Date.now();
|
|
1014
1018
|
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1019
|
+
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1015
1020
|
messages.push({ role: "user", content: initialState });
|
|
1016
1021
|
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1017
1022
|
const model = config.model || DEFAULT_MODEL;
|
|
@@ -1020,22 +1025,29 @@ async function runWarpGrep(config) {
|
|
|
1020
1025
|
let finishMeta;
|
|
1021
1026
|
let terminationReason = "terminated";
|
|
1022
1027
|
for (let turn = 1; turn <= maxTurns; turn += 1) {
|
|
1028
|
+
const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
|
|
1023
1029
|
enforceContextLimit(messages);
|
|
1030
|
+
const modelCallStart = Date.now();
|
|
1024
1031
|
const assistantContent = await callModel(messages, model, {
|
|
1025
1032
|
morphApiKey: config.morphApiKey,
|
|
1026
1033
|
morphApiUrl: config.morphApiUrl,
|
|
1027
1034
|
retryConfig: config.retryConfig,
|
|
1028
|
-
timeout:
|
|
1035
|
+
timeout: timeoutMs
|
|
1029
1036
|
}).catch((e) => {
|
|
1030
1037
|
errors.push({ message: e instanceof Error ? e.message : String(e) });
|
|
1031
1038
|
return "";
|
|
1032
1039
|
});
|
|
1033
|
-
|
|
1040
|
+
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
1041
|
+
if (!assistantContent) {
|
|
1042
|
+
timings.turns.push(turnMetrics);
|
|
1043
|
+
break;
|
|
1044
|
+
}
|
|
1034
1045
|
messages.push({ role: "assistant", content: assistantContent });
|
|
1035
1046
|
const toolCalls = parser.parse(assistantContent);
|
|
1036
1047
|
if (toolCalls.length === 0) {
|
|
1037
1048
|
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" });
|
|
1038
1049
|
terminationReason = "terminated";
|
|
1050
|
+
timings.turns.push(turnMetrics);
|
|
1039
1051
|
break;
|
|
1040
1052
|
}
|
|
1041
1053
|
const finishCalls = toolCalls.filter((c) => c.name === "finish");
|
|
@@ -1076,7 +1088,9 @@ async function runWarpGrep(config) {
|
|
|
1076
1088
|
)
|
|
1077
1089
|
);
|
|
1078
1090
|
}
|
|
1091
|
+
const toolExecStart = Date.now();
|
|
1079
1092
|
const allResults = await Promise.all(allPromises);
|
|
1093
|
+
turnMetrics.local_tools_ms = Date.now() - toolExecStart;
|
|
1080
1094
|
for (const result of allResults) {
|
|
1081
1095
|
formatted.push(result);
|
|
1082
1096
|
}
|
|
@@ -1085,6 +1099,7 @@ async function runWarpGrep(config) {
|
|
|
1085
1099
|
const contextBudget = calculateContextBudget(messages);
|
|
1086
1100
|
messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
|
|
1087
1101
|
}
|
|
1102
|
+
timings.turns.push(turnMetrics);
|
|
1088
1103
|
if (finishCalls.length) {
|
|
1089
1104
|
const fc = finishCalls[0];
|
|
1090
1105
|
const files = fc.arguments?.files ?? [];
|
|
@@ -1094,7 +1109,8 @@ async function runWarpGrep(config) {
|
|
|
1094
1109
|
}
|
|
1095
1110
|
}
|
|
1096
1111
|
if (terminationReason !== "completed" || !finishMeta) {
|
|
1097
|
-
|
|
1112
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1113
|
+
return { terminationReason, messages, errors, timings };
|
|
1098
1114
|
}
|
|
1099
1115
|
const parts = ["Relevant context found:"];
|
|
1100
1116
|
for (const f of finishMeta.files) {
|
|
@@ -1102,6 +1118,7 @@ async function runWarpGrep(config) {
|
|
|
1102
1118
|
parts.push(`- ${f.path}: ${ranges}`);
|
|
1103
1119
|
}
|
|
1104
1120
|
const payload = parts.join("\n");
|
|
1121
|
+
const finishResolutionStart = Date.now();
|
|
1105
1122
|
const fileReadErrors = [];
|
|
1106
1123
|
const resolved = await readFinishFiles(
|
|
1107
1124
|
repoRoot,
|
|
@@ -1121,13 +1138,16 @@ async function runWarpGrep(config) {
|
|
|
1121
1138
|
}
|
|
1122
1139
|
}
|
|
1123
1140
|
);
|
|
1141
|
+
timings.finish_resolution_ms = Date.now() - finishResolutionStart;
|
|
1124
1142
|
if (fileReadErrors.length > 0) {
|
|
1125
1143
|
errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
|
|
1126
1144
|
}
|
|
1145
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1127
1146
|
return {
|
|
1128
1147
|
terminationReason: "completed",
|
|
1129
1148
|
messages,
|
|
1130
|
-
finish: { payload, metadata: finishMeta, resolved }
|
|
1149
|
+
finish: { payload, metadata: finishMeta, resolved },
|
|
1150
|
+
timings
|
|
1131
1151
|
};
|
|
1132
1152
|
}
|
|
1133
1153
|
|