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