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