@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
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
executeToolCall,
|
|
7
7
|
formatResult
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
8
|
+
} from "../../chunk-HRK53IKL.js";
|
|
9
|
+
import "../../chunk-QOYI77CN.js";
|
|
10
10
|
import "../../chunk-PUGSTXLO.js";
|
|
11
11
|
import "../../chunk-P2O5JKE5.js";
|
|
12
12
|
import "../../chunk-APP75CBN.js";
|
|
@@ -1030,10 +1030,15 @@ async function callModel(messages, model, options = {}) {
|
|
|
1030
1030
|
return content;
|
|
1031
1031
|
}
|
|
1032
1032
|
async function runWarpGrep(config) {
|
|
1033
|
+
const totalStart = Date.now();
|
|
1034
|
+
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1035
|
+
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1033
1036
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1034
1037
|
const messages = [];
|
|
1035
1038
|
messages.push({ role: "system", content: getSystemPrompt() });
|
|
1039
|
+
const initialStateStart = Date.now();
|
|
1036
1040
|
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1041
|
+
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1037
1042
|
messages.push({ role: "user", content: initialState });
|
|
1038
1043
|
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1039
1044
|
const model = config.model || DEFAULT_MODEL;
|
|
@@ -1042,22 +1047,29 @@ async function runWarpGrep(config) {
|
|
|
1042
1047
|
let finishMeta;
|
|
1043
1048
|
let terminationReason = "terminated";
|
|
1044
1049
|
for (let turn = 1; turn <= maxTurns; turn += 1) {
|
|
1050
|
+
const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
|
|
1045
1051
|
enforceContextLimit(messages);
|
|
1052
|
+
const modelCallStart = Date.now();
|
|
1046
1053
|
const assistantContent = await callModel(messages, model, {
|
|
1047
1054
|
morphApiKey: config.morphApiKey,
|
|
1048
1055
|
morphApiUrl: config.morphApiUrl,
|
|
1049
1056
|
retryConfig: config.retryConfig,
|
|
1050
|
-
timeout:
|
|
1057
|
+
timeout: timeoutMs
|
|
1051
1058
|
}).catch((e) => {
|
|
1052
1059
|
errors.push({ message: e instanceof Error ? e.message : String(e) });
|
|
1053
1060
|
return "";
|
|
1054
1061
|
});
|
|
1055
|
-
|
|
1062
|
+
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
1063
|
+
if (!assistantContent) {
|
|
1064
|
+
timings.turns.push(turnMetrics);
|
|
1065
|
+
break;
|
|
1066
|
+
}
|
|
1056
1067
|
messages.push({ role: "assistant", content: assistantContent });
|
|
1057
1068
|
const toolCalls = parser.parse(assistantContent);
|
|
1058
1069
|
if (toolCalls.length === 0) {
|
|
1059
1070
|
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" });
|
|
1060
1071
|
terminationReason = "terminated";
|
|
1072
|
+
timings.turns.push(turnMetrics);
|
|
1061
1073
|
break;
|
|
1062
1074
|
}
|
|
1063
1075
|
const finishCalls = toolCalls.filter((c) => c.name === "finish");
|
|
@@ -1098,7 +1110,9 @@ async function runWarpGrep(config) {
|
|
|
1098
1110
|
)
|
|
1099
1111
|
);
|
|
1100
1112
|
}
|
|
1113
|
+
const toolExecStart = Date.now();
|
|
1101
1114
|
const allResults = await Promise.all(allPromises);
|
|
1115
|
+
turnMetrics.local_tools_ms = Date.now() - toolExecStart;
|
|
1102
1116
|
for (const result of allResults) {
|
|
1103
1117
|
formatted.push(result);
|
|
1104
1118
|
}
|
|
@@ -1107,6 +1121,7 @@ async function runWarpGrep(config) {
|
|
|
1107
1121
|
const contextBudget = calculateContextBudget(messages);
|
|
1108
1122
|
messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
|
|
1109
1123
|
}
|
|
1124
|
+
timings.turns.push(turnMetrics);
|
|
1110
1125
|
if (finishCalls.length) {
|
|
1111
1126
|
const fc = finishCalls[0];
|
|
1112
1127
|
const files = fc.arguments?.files ?? [];
|
|
@@ -1116,7 +1131,8 @@ async function runWarpGrep(config) {
|
|
|
1116
1131
|
}
|
|
1117
1132
|
}
|
|
1118
1133
|
if (terminationReason !== "completed" || !finishMeta) {
|
|
1119
|
-
|
|
1134
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1135
|
+
return { terminationReason, messages, errors, timings };
|
|
1120
1136
|
}
|
|
1121
1137
|
const parts = ["Relevant context found:"];
|
|
1122
1138
|
for (const f of finishMeta.files) {
|
|
@@ -1124,6 +1140,7 @@ async function runWarpGrep(config) {
|
|
|
1124
1140
|
parts.push(`- ${f.path}: ${ranges}`);
|
|
1125
1141
|
}
|
|
1126
1142
|
const payload = parts.join("\n");
|
|
1143
|
+
const finishResolutionStart = Date.now();
|
|
1127
1144
|
const fileReadErrors = [];
|
|
1128
1145
|
const resolved = await readFinishFiles(
|
|
1129
1146
|
repoRoot,
|
|
@@ -1143,13 +1160,16 @@ async function runWarpGrep(config) {
|
|
|
1143
1160
|
}
|
|
1144
1161
|
}
|
|
1145
1162
|
);
|
|
1163
|
+
timings.finish_resolution_ms = Date.now() - finishResolutionStart;
|
|
1146
1164
|
if (fileReadErrors.length > 0) {
|
|
1147
1165
|
errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
|
|
1148
1166
|
}
|
|
1167
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1149
1168
|
return {
|
|
1150
1169
|
terminationReason: "completed",
|
|
1151
1170
|
messages,
|
|
1152
|
-
finish: { payload, metadata: finishMeta, resolved }
|
|
1171
|
+
finish: { payload, metadata: finishMeta, resolved },
|
|
1172
|
+
timings
|
|
1153
1173
|
};
|
|
1154
1174
|
}
|
|
1155
1175
|
|