@morphllm/morphsdk 0.2.81 → 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-4NI25AKV.js → chunk-4KMBU6T3.js} +2 -2
- package/dist/{chunk-XT5ZO6ES.js → chunk-5PNMAWLC.js} +8 -2
- package/dist/chunk-5PNMAWLC.js.map +1 -0
- package/dist/{chunk-X6A64F2F.js → chunk-HPR6BJA7.js} +5 -5
- package/dist/{chunk-4VMIPD4G.js → chunk-HRK53IKL.js} +8 -6
- package/dist/chunk-HRK53IKL.js.map +1 -0
- package/dist/{chunk-NTTQJM6O.js → chunk-LXG37353.js} +2 -2
- package/dist/{chunk-467MCW5R.js → chunk-P2O5JKE5.js} +2 -2
- package/dist/{chunk-PHJQ4N3T.js → chunk-PUGSTXLO.js} +2 -2
- package/dist/{chunk-B3UC7UVA.js → chunk-QOYI77CN.js} +30 -8
- package/dist/chunk-QOYI77CN.js.map +1 -0
- package/dist/{chunk-Z2HDXUH7.js → chunk-RL4JBZ3T.js} +2 -2
- package/dist/{chunk-OFMDENAQ.js → chunk-S27A4NQM.js} +2 -2
- package/dist/{client-CSINf0lQ.d.ts → client-CsO9LifG.d.ts} +1 -1
- package/dist/client.cjs +38 -8
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +10 -10
- package/dist/index.cjs +38 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -10
- package/dist/tools/warp_grep/agent/config.cjs +7 -1
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/config.d.ts +1 -0
- package/dist/tools/warp_grep/agent/config.js +1 -1
- package/dist/tools/warp_grep/agent/runner.cjs +34 -6
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +3 -3
- package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/types.d.ts +16 -1
- package/dist/tools/warp_grep/anthropic.cjs +36 -7
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +1 -1
- package/dist/tools/warp_grep/anthropic.js +7 -7
- package/dist/tools/warp_grep/client.cjs +38 -8
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.d.ts +1 -1
- package/dist/tools/warp_grep/client.js +6 -6
- package/dist/tools/warp_grep/gemini.cjs +36 -7
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +1 -1
- package/dist/tools/warp_grep/gemini.js +6 -6
- package/dist/tools/warp_grep/harness.cjs +7 -1
- package/dist/tools/warp_grep/harness.cjs.map +1 -1
- package/dist/tools/warp_grep/harness.js +3 -3
- package/dist/tools/warp_grep/index.cjs +38 -8
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +1 -1
- package/dist/tools/warp_grep/index.js +6 -6
- package/dist/tools/warp_grep/openai.cjs +36 -7
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +1 -1
- package/dist/tools/warp_grep/openai.js +7 -7
- package/dist/tools/warp_grep/providers/local.cjs +7 -1
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/providers/remote.cjs +7 -1
- package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
- package/dist/tools/warp_grep/providers/remote.js +2 -2
- package/dist/tools/warp_grep/vercel.cjs +36 -7
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +1 -1
- package/dist/tools/warp_grep/vercel.js +7 -7
- package/dist/{types-CnvVDM63.d.ts → types-Cv4LpqVl.d.ts} +2 -0
- package/package.json +1 -1
- package/dist/chunk-4VMIPD4G.js.map +0 -1
- package/dist/chunk-B3UC7UVA.js.map +0 -1
- package/dist/chunk-XT5ZO6ES.js.map +0 -1
- /package/dist/{chunk-4NI25AKV.js.map → chunk-4KMBU6T3.js.map} +0 -0
- /package/dist/{chunk-X6A64F2F.js.map → chunk-HPR6BJA7.js.map} +0 -0
- /package/dist/{chunk-NTTQJM6O.js.map → chunk-LXG37353.js.map} +0 -0
- /package/dist/{chunk-467MCW5R.js.map → chunk-P2O5JKE5.js.map} +0 -0
- /package/dist/{chunk-PHJQ4N3T.js.map → chunk-PUGSTXLO.js.map} +0 -0
- /package/dist/{chunk-Z2HDXUH7.js.map → chunk-RL4JBZ3T.js.map} +0 -0
- /package/dist/{chunk-OFMDENAQ.js.map → chunk-S27A4NQM.js.map} +0 -0
|
@@ -3,18 +3,18 @@ import {
|
|
|
3
3
|
executeToolCall,
|
|
4
4
|
executeWarpGrep,
|
|
5
5
|
formatResult
|
|
6
|
-
} from "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
6
|
+
} from "../../chunk-HRK53IKL.js";
|
|
7
|
+
import "../../chunk-QOYI77CN.js";
|
|
8
|
+
import "../../chunk-PUGSTXLO.js";
|
|
9
|
+
import "../../chunk-P2O5JKE5.js";
|
|
10
10
|
import "../../chunk-APP75CBN.js";
|
|
11
11
|
import "../../chunk-5QRN3JNB.js";
|
|
12
12
|
import "../../chunk-FMLHRJDF.js";
|
|
13
|
-
import "../../chunk-
|
|
13
|
+
import "../../chunk-4KMBU6T3.js";
|
|
14
14
|
import "../../chunk-G2RSY56Q.js";
|
|
15
15
|
import "../../chunk-YPKNMYD4.js";
|
|
16
16
|
import "../../chunk-TPP2UGQP.js";
|
|
17
|
-
import "../../chunk-
|
|
17
|
+
import "../../chunk-5PNMAWLC.js";
|
|
18
18
|
import "../../chunk-4VWJFZVS.js";
|
|
19
19
|
import "../../chunk-PZ5AY32C.js";
|
|
20
20
|
export {
|
|
@@ -41,9 +41,15 @@ __export(gemini_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(gemini_exports);
|
|
42
42
|
|
|
43
43
|
// tools/warp_grep/agent/config.ts
|
|
44
|
+
var parseEnvTimeout = (envValue, defaultMs) => {
|
|
45
|
+
if (!envValue) return defaultMs;
|
|
46
|
+
const parsed = parseInt(envValue, 10);
|
|
47
|
+
return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
|
|
48
|
+
};
|
|
44
49
|
var AGENT_CONFIG = {
|
|
45
50
|
MAX_TURNS: 4,
|
|
46
|
-
|
|
51
|
+
/** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
|
|
52
|
+
TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 3e4),
|
|
47
53
|
MAX_CONTEXT_CHARS: 54e4,
|
|
48
54
|
MAX_OUTPUT_LINES: 200,
|
|
49
55
|
MAX_READ_LINES: 800,
|
|
@@ -985,7 +991,8 @@ async function callModel(messages, model, options = {}) {
|
|
|
985
991
|
},
|
|
986
992
|
options.retryConfig
|
|
987
993
|
);
|
|
988
|
-
const
|
|
994
|
+
const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
995
|
+
const resp = await withTimeout(fetchPromise, timeoutMs, "morph-warp-grep request timed out");
|
|
989
996
|
if (!resp.ok) {
|
|
990
997
|
if (resp.status === 404) {
|
|
991
998
|
throw new Error(
|
|
@@ -1003,10 +1010,15 @@ async function callModel(messages, model, options = {}) {
|
|
|
1003
1010
|
return content;
|
|
1004
1011
|
}
|
|
1005
1012
|
async function runWarpGrep(config) {
|
|
1013
|
+
const totalStart = Date.now();
|
|
1014
|
+
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1015
|
+
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1006
1016
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1007
1017
|
const messages = [];
|
|
1008
1018
|
messages.push({ role: "system", content: getSystemPrompt() });
|
|
1019
|
+
const initialStateStart = Date.now();
|
|
1009
1020
|
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1021
|
+
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1010
1022
|
messages.push({ role: "user", content: initialState });
|
|
1011
1023
|
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1012
1024
|
const model = config.model || DEFAULT_MODEL;
|
|
@@ -1015,21 +1027,29 @@ async function runWarpGrep(config) {
|
|
|
1015
1027
|
let finishMeta;
|
|
1016
1028
|
let terminationReason = "terminated";
|
|
1017
1029
|
for (let turn = 1; turn <= maxTurns; turn += 1) {
|
|
1030
|
+
const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
|
|
1018
1031
|
enforceContextLimit(messages);
|
|
1032
|
+
const modelCallStart = Date.now();
|
|
1019
1033
|
const assistantContent = await callModel(messages, model, {
|
|
1020
1034
|
morphApiKey: config.morphApiKey,
|
|
1021
1035
|
morphApiUrl: config.morphApiUrl,
|
|
1022
|
-
retryConfig: config.retryConfig
|
|
1036
|
+
retryConfig: config.retryConfig,
|
|
1037
|
+
timeout: timeoutMs
|
|
1023
1038
|
}).catch((e) => {
|
|
1024
1039
|
errors.push({ message: e instanceof Error ? e.message : String(e) });
|
|
1025
1040
|
return "";
|
|
1026
1041
|
});
|
|
1027
|
-
|
|
1042
|
+
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
1043
|
+
if (!assistantContent) {
|
|
1044
|
+
timings.turns.push(turnMetrics);
|
|
1045
|
+
break;
|
|
1046
|
+
}
|
|
1028
1047
|
messages.push({ role: "assistant", content: assistantContent });
|
|
1029
1048
|
const toolCalls = parser.parse(assistantContent);
|
|
1030
1049
|
if (toolCalls.length === 0) {
|
|
1031
1050
|
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" });
|
|
1032
1051
|
terminationReason = "terminated";
|
|
1052
|
+
timings.turns.push(turnMetrics);
|
|
1033
1053
|
break;
|
|
1034
1054
|
}
|
|
1035
1055
|
const finishCalls = toolCalls.filter((c) => c.name === "finish");
|
|
@@ -1070,7 +1090,9 @@ async function runWarpGrep(config) {
|
|
|
1070
1090
|
)
|
|
1071
1091
|
);
|
|
1072
1092
|
}
|
|
1093
|
+
const toolExecStart = Date.now();
|
|
1073
1094
|
const allResults = await Promise.all(allPromises);
|
|
1095
|
+
turnMetrics.local_tools_ms = Date.now() - toolExecStart;
|
|
1074
1096
|
for (const result of allResults) {
|
|
1075
1097
|
formatted.push(result);
|
|
1076
1098
|
}
|
|
@@ -1079,6 +1101,7 @@ async function runWarpGrep(config) {
|
|
|
1079
1101
|
const contextBudget = calculateContextBudget(messages);
|
|
1080
1102
|
messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
|
|
1081
1103
|
}
|
|
1104
|
+
timings.turns.push(turnMetrics);
|
|
1082
1105
|
if (finishCalls.length) {
|
|
1083
1106
|
const fc = finishCalls[0];
|
|
1084
1107
|
const files = fc.arguments?.files ?? [];
|
|
@@ -1088,7 +1111,8 @@ async function runWarpGrep(config) {
|
|
|
1088
1111
|
}
|
|
1089
1112
|
}
|
|
1090
1113
|
if (terminationReason !== "completed" || !finishMeta) {
|
|
1091
|
-
|
|
1114
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1115
|
+
return { terminationReason, messages, errors, timings };
|
|
1092
1116
|
}
|
|
1093
1117
|
const parts = ["Relevant context found:"];
|
|
1094
1118
|
for (const f of finishMeta.files) {
|
|
@@ -1096,6 +1120,7 @@ async function runWarpGrep(config) {
|
|
|
1096
1120
|
parts.push(`- ${f.path}: ${ranges}`);
|
|
1097
1121
|
}
|
|
1098
1122
|
const payload = parts.join("\n");
|
|
1123
|
+
const finishResolutionStart = Date.now();
|
|
1099
1124
|
const fileReadErrors = [];
|
|
1100
1125
|
const resolved = await readFinishFiles(
|
|
1101
1126
|
repoRoot,
|
|
@@ -1115,13 +1140,16 @@ async function runWarpGrep(config) {
|
|
|
1115
1140
|
}
|
|
1116
1141
|
}
|
|
1117
1142
|
);
|
|
1143
|
+
timings.finish_resolution_ms = Date.now() - finishResolutionStart;
|
|
1118
1144
|
if (fileReadErrors.length > 0) {
|
|
1119
1145
|
errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
|
|
1120
1146
|
}
|
|
1147
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1121
1148
|
return {
|
|
1122
1149
|
terminationReason: "completed",
|
|
1123
1150
|
messages,
|
|
1124
|
-
finish: { payload, metadata: finishMeta, resolved }
|
|
1151
|
+
finish: { payload, metadata: finishMeta, resolved },
|
|
1152
|
+
timings
|
|
1125
1153
|
};
|
|
1126
1154
|
}
|
|
1127
1155
|
|
|
@@ -1718,7 +1746,8 @@ async function executeToolCall(input, config) {
|
|
|
1718
1746
|
debug: config.debug ?? false,
|
|
1719
1747
|
morphApiKey: config.morphApiKey,
|
|
1720
1748
|
morphApiUrl: config.morphApiUrl,
|
|
1721
|
-
retryConfig: config.retryConfig
|
|
1749
|
+
retryConfig: config.retryConfig,
|
|
1750
|
+
timeout: config.timeout
|
|
1722
1751
|
});
|
|
1723
1752
|
const finish = result.finish;
|
|
1724
1753
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|