@morphllm/morphsdk 0.2.82 → 0.2.84
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-ZLJAODDJ.js → chunk-262WRPS5.js} +2 -2
- package/dist/{chunk-FJKPMMNQ.js → chunk-D4EQYM6O.js} +2 -2
- package/dist/{chunk-P2O5JKE5.js → chunk-KRDIR7GG.js} +17 -8
- package/dist/chunk-KRDIR7GG.js.map +1 -0
- package/dist/{chunk-WIAYUEJK.js → chunk-LF2X6YNP.js} +26 -6
- package/dist/chunk-LF2X6YNP.js.map +1 -0
- package/dist/{chunk-24EYSWME.js → chunk-LX2WNS3L.js} +2 -2
- package/dist/{chunk-3ONNAQZU.js → chunk-MJ7JODAY.js} +2 -2
- package/dist/{chunk-EK5ZEOI3.js → chunk-N3RNM4A4.js} +5 -5
- package/dist/client.cjs +40 -11
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +7 -7
- package/dist/index.cjs +40 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -7
- package/dist/tools/warp_grep/agent/runner.cjs +40 -11
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +2 -2
- 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 +40 -11
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +4 -4
- package/dist/tools/warp_grep/client.cjs +40 -11
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +3 -3
- package/dist/tools/warp_grep/gemini.cjs +40 -11
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.js +3 -3
- package/dist/tools/warp_grep/harness.cjs +16 -7
- package/dist/tools/warp_grep/harness.cjs.map +1 -1
- package/dist/tools/warp_grep/harness.js +1 -1
- package/dist/tools/warp_grep/index.cjs +40 -11
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.js +3 -3
- package/dist/tools/warp_grep/openai.cjs +40 -11
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +4 -4
- package/dist/tools/warp_grep/vercel.cjs +40 -11
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-P2O5JKE5.js.map +0 -1
- package/dist/chunk-WIAYUEJK.js.map +0 -1
- /package/dist/{chunk-ZLJAODDJ.js.map → chunk-262WRPS5.js.map} +0 -0
- /package/dist/{chunk-FJKPMMNQ.js.map → chunk-D4EQYM6O.js.map} +0 -0
- /package/dist/{chunk-24EYSWME.js.map → chunk-LX2WNS3L.js.map} +0 -0
- /package/dist/{chunk-3ONNAQZU.js.map → chunk-MJ7JODAY.js.map} +0 -0
- /package/dist/{chunk-EK5ZEOI3.js.map → chunk-N3RNM4A4.js.map} +0 -0
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
createWarpGrepTool,
|
|
3
3
|
execute,
|
|
4
4
|
warpGrepTool
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-262WRPS5.js";
|
|
6
6
|
import "../../chunk-KW7OEGZK.js";
|
|
7
7
|
import {
|
|
8
8
|
formatResult
|
|
9
|
-
} from "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
9
|
+
} from "../../chunk-D4EQYM6O.js";
|
|
10
|
+
import "../../chunk-LF2X6YNP.js";
|
|
11
11
|
import "../../chunk-PUGSTXLO.js";
|
|
12
|
-
import "../../chunk-
|
|
12
|
+
import "../../chunk-KRDIR7GG.js";
|
|
13
13
|
import "../../chunk-APP75CBN.js";
|
|
14
14
|
import "../../chunk-5QRN3JNB.js";
|
|
15
15
|
import {
|
|
@@ -648,14 +648,23 @@ async function toolRead(provider, args) {
|
|
|
648
648
|
|
|
649
649
|
// tools/warp_grep/agent/tools/list_directory.ts
|
|
650
650
|
async function toolListDirectory(provider, args) {
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
651
|
+
const maxResults = args.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES;
|
|
652
|
+
const initialDepth = args.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
|
|
653
|
+
async function getListRecursive(currentDepth) {
|
|
654
|
+
const entries = await provider.listDirectory({
|
|
655
|
+
path: args.path,
|
|
656
|
+
pattern: args.pattern ?? null,
|
|
657
|
+
maxResults,
|
|
658
|
+
maxDepth: currentDepth
|
|
659
|
+
});
|
|
660
|
+
if (entries.length >= maxResults && currentDepth > 0) {
|
|
661
|
+
return getListRecursive(currentDepth - 1);
|
|
662
|
+
}
|
|
663
|
+
return { entries };
|
|
664
|
+
}
|
|
665
|
+
const { entries: list } = await getListRecursive(initialDepth);
|
|
657
666
|
if (!list.length) return "empty";
|
|
658
|
-
if (list.length >=
|
|
667
|
+
if (list.length >= maxResults) {
|
|
659
668
|
return "query not specific enough, tool called tried to return too much context and failed";
|
|
660
669
|
}
|
|
661
670
|
return list.map((e) => {
|
|
@@ -1007,10 +1016,15 @@ async function callModel(messages, model, options = {}) {
|
|
|
1007
1016
|
return content;
|
|
1008
1017
|
}
|
|
1009
1018
|
async function runWarpGrep(config) {
|
|
1019
|
+
const totalStart = Date.now();
|
|
1020
|
+
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1021
|
+
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1010
1022
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1011
1023
|
const messages = [];
|
|
1012
1024
|
messages.push({ role: "system", content: getSystemPrompt() });
|
|
1025
|
+
const initialStateStart = Date.now();
|
|
1013
1026
|
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1027
|
+
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1014
1028
|
messages.push({ role: "user", content: initialState });
|
|
1015
1029
|
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1016
1030
|
const model = config.model || DEFAULT_MODEL;
|
|
@@ -1019,22 +1033,29 @@ async function runWarpGrep(config) {
|
|
|
1019
1033
|
let finishMeta;
|
|
1020
1034
|
let terminationReason = "terminated";
|
|
1021
1035
|
for (let turn = 1; turn <= maxTurns; turn += 1) {
|
|
1036
|
+
const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
|
|
1022
1037
|
enforceContextLimit(messages);
|
|
1038
|
+
const modelCallStart = Date.now();
|
|
1023
1039
|
const assistantContent = await callModel(messages, model, {
|
|
1024
1040
|
morphApiKey: config.morphApiKey,
|
|
1025
1041
|
morphApiUrl: config.morphApiUrl,
|
|
1026
1042
|
retryConfig: config.retryConfig,
|
|
1027
|
-
timeout:
|
|
1043
|
+
timeout: timeoutMs
|
|
1028
1044
|
}).catch((e) => {
|
|
1029
1045
|
errors.push({ message: e instanceof Error ? e.message : String(e) });
|
|
1030
1046
|
return "";
|
|
1031
1047
|
});
|
|
1032
|
-
|
|
1048
|
+
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
1049
|
+
if (!assistantContent) {
|
|
1050
|
+
timings.turns.push(turnMetrics);
|
|
1051
|
+
break;
|
|
1052
|
+
}
|
|
1033
1053
|
messages.push({ role: "assistant", content: assistantContent });
|
|
1034
1054
|
const toolCalls = parser.parse(assistantContent);
|
|
1035
1055
|
if (toolCalls.length === 0) {
|
|
1036
1056
|
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
1057
|
terminationReason = "terminated";
|
|
1058
|
+
timings.turns.push(turnMetrics);
|
|
1038
1059
|
break;
|
|
1039
1060
|
}
|
|
1040
1061
|
const finishCalls = toolCalls.filter((c) => c.name === "finish");
|
|
@@ -1075,7 +1096,9 @@ async function runWarpGrep(config) {
|
|
|
1075
1096
|
)
|
|
1076
1097
|
);
|
|
1077
1098
|
}
|
|
1099
|
+
const toolExecStart = Date.now();
|
|
1078
1100
|
const allResults = await Promise.all(allPromises);
|
|
1101
|
+
turnMetrics.local_tools_ms = Date.now() - toolExecStart;
|
|
1079
1102
|
for (const result of allResults) {
|
|
1080
1103
|
formatted.push(result);
|
|
1081
1104
|
}
|
|
@@ -1084,6 +1107,7 @@ async function runWarpGrep(config) {
|
|
|
1084
1107
|
const contextBudget = calculateContextBudget(messages);
|
|
1085
1108
|
messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
|
|
1086
1109
|
}
|
|
1110
|
+
timings.turns.push(turnMetrics);
|
|
1087
1111
|
if (finishCalls.length) {
|
|
1088
1112
|
const fc = finishCalls[0];
|
|
1089
1113
|
const files = fc.arguments?.files ?? [];
|
|
@@ -1093,7 +1117,8 @@ async function runWarpGrep(config) {
|
|
|
1093
1117
|
}
|
|
1094
1118
|
}
|
|
1095
1119
|
if (terminationReason !== "completed" || !finishMeta) {
|
|
1096
|
-
|
|
1120
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1121
|
+
return { terminationReason, messages, errors, timings };
|
|
1097
1122
|
}
|
|
1098
1123
|
const parts = ["Relevant context found:"];
|
|
1099
1124
|
for (const f of finishMeta.files) {
|
|
@@ -1101,6 +1126,7 @@ async function runWarpGrep(config) {
|
|
|
1101
1126
|
parts.push(`- ${f.path}: ${ranges}`);
|
|
1102
1127
|
}
|
|
1103
1128
|
const payload = parts.join("\n");
|
|
1129
|
+
const finishResolutionStart = Date.now();
|
|
1104
1130
|
const fileReadErrors = [];
|
|
1105
1131
|
const resolved = await readFinishFiles(
|
|
1106
1132
|
repoRoot,
|
|
@@ -1120,13 +1146,16 @@ async function runWarpGrep(config) {
|
|
|
1120
1146
|
}
|
|
1121
1147
|
}
|
|
1122
1148
|
);
|
|
1149
|
+
timings.finish_resolution_ms = Date.now() - finishResolutionStart;
|
|
1123
1150
|
if (fileReadErrors.length > 0) {
|
|
1124
1151
|
errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
|
|
1125
1152
|
}
|
|
1153
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1126
1154
|
return {
|
|
1127
1155
|
terminationReason: "completed",
|
|
1128
1156
|
messages,
|
|
1129
|
-
finish: { payload, metadata: finishMeta, resolved }
|
|
1157
|
+
finish: { payload, metadata: finishMeta, resolved },
|
|
1158
|
+
timings
|
|
1130
1159
|
};
|
|
1131
1160
|
}
|
|
1132
1161
|
|