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