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