@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tool } from '@anthropic-ai/sdk/resources/messages';
|
|
2
2
|
export { formatResult } from './client.js';
|
|
3
3
|
export { getSystemPrompt } from './agent/prompt.js';
|
|
4
|
-
import { d as WarpGrepToolConfig, b as WarpGrepResult } from '../../types-
|
|
4
|
+
import { d as WarpGrepToolConfig, b as WarpGrepResult } from '../../types-Cv4LpqVl.js';
|
|
5
5
|
import './providers/types.js';
|
|
6
6
|
import '../utils/resilience.js';
|
|
7
7
|
|
|
@@ -2,24 +2,24 @@ 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-
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
9
|
+
} from "../../chunk-HRK53IKL.js";
|
|
10
|
+
import "../../chunk-QOYI77CN.js";
|
|
11
|
+
import "../../chunk-PUGSTXLO.js";
|
|
12
|
+
import "../../chunk-P2O5JKE5.js";
|
|
13
13
|
import "../../chunk-APP75CBN.js";
|
|
14
14
|
import "../../chunk-5QRN3JNB.js";
|
|
15
15
|
import {
|
|
16
16
|
getSystemPrompt
|
|
17
17
|
} from "../../chunk-FMLHRJDF.js";
|
|
18
|
-
import "../../chunk-
|
|
18
|
+
import "../../chunk-4KMBU6T3.js";
|
|
19
19
|
import "../../chunk-G2RSY56Q.js";
|
|
20
20
|
import "../../chunk-YPKNMYD4.js";
|
|
21
21
|
import "../../chunk-TPP2UGQP.js";
|
|
22
|
-
import "../../chunk-
|
|
22
|
+
import "../../chunk-5PNMAWLC.js";
|
|
23
23
|
import "../../chunk-4VWJFZVS.js";
|
|
24
24
|
import "../../chunk-PZ5AY32C.js";
|
|
25
25
|
export {
|
|
@@ -38,9 +38,15 @@ __export(client_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(client_exports);
|
|
39
39
|
|
|
40
40
|
// tools/warp_grep/agent/config.ts
|
|
41
|
+
var parseEnvTimeout = (envValue, defaultMs) => {
|
|
42
|
+
if (!envValue) return defaultMs;
|
|
43
|
+
const parsed = parseInt(envValue, 10);
|
|
44
|
+
return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
|
|
45
|
+
};
|
|
41
46
|
var AGENT_CONFIG = {
|
|
42
47
|
MAX_TURNS: 4,
|
|
43
|
-
|
|
48
|
+
/** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
|
|
49
|
+
TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 3e4),
|
|
44
50
|
MAX_CONTEXT_CHARS: 54e4,
|
|
45
51
|
MAX_OUTPUT_LINES: 200,
|
|
46
52
|
MAX_READ_LINES: 800,
|
|
@@ -982,7 +988,8 @@ async function callModel(messages, model, options = {}) {
|
|
|
982
988
|
},
|
|
983
989
|
options.retryConfig
|
|
984
990
|
);
|
|
985
|
-
const
|
|
991
|
+
const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
992
|
+
const resp = await withTimeout(fetchPromise, timeoutMs, "morph-warp-grep request timed out");
|
|
986
993
|
if (!resp.ok) {
|
|
987
994
|
if (resp.status === 404) {
|
|
988
995
|
throw new Error(
|
|
@@ -1000,10 +1007,15 @@ async function callModel(messages, model, options = {}) {
|
|
|
1000
1007
|
return content;
|
|
1001
1008
|
}
|
|
1002
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 };
|
|
1003
1013
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1004
1014
|
const messages = [];
|
|
1005
1015
|
messages.push({ role: "system", content: getSystemPrompt() });
|
|
1016
|
+
const initialStateStart = Date.now();
|
|
1006
1017
|
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1018
|
+
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1007
1019
|
messages.push({ role: "user", content: initialState });
|
|
1008
1020
|
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1009
1021
|
const model = config.model || DEFAULT_MODEL;
|
|
@@ -1012,21 +1024,29 @@ async function runWarpGrep(config) {
|
|
|
1012
1024
|
let finishMeta;
|
|
1013
1025
|
let terminationReason = "terminated";
|
|
1014
1026
|
for (let turn = 1; turn <= maxTurns; turn += 1) {
|
|
1027
|
+
const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
|
|
1015
1028
|
enforceContextLimit(messages);
|
|
1029
|
+
const modelCallStart = Date.now();
|
|
1016
1030
|
const assistantContent = await callModel(messages, model, {
|
|
1017
1031
|
morphApiKey: config.morphApiKey,
|
|
1018
1032
|
morphApiUrl: config.morphApiUrl,
|
|
1019
|
-
retryConfig: config.retryConfig
|
|
1033
|
+
retryConfig: config.retryConfig,
|
|
1034
|
+
timeout: timeoutMs
|
|
1020
1035
|
}).catch((e) => {
|
|
1021
1036
|
errors.push({ message: e instanceof Error ? e.message : String(e) });
|
|
1022
1037
|
return "";
|
|
1023
1038
|
});
|
|
1024
|
-
|
|
1039
|
+
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
1040
|
+
if (!assistantContent) {
|
|
1041
|
+
timings.turns.push(turnMetrics);
|
|
1042
|
+
break;
|
|
1043
|
+
}
|
|
1025
1044
|
messages.push({ role: "assistant", content: assistantContent });
|
|
1026
1045
|
const toolCalls = parser.parse(assistantContent);
|
|
1027
1046
|
if (toolCalls.length === 0) {
|
|
1028
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" });
|
|
1029
1048
|
terminationReason = "terminated";
|
|
1049
|
+
timings.turns.push(turnMetrics);
|
|
1030
1050
|
break;
|
|
1031
1051
|
}
|
|
1032
1052
|
const finishCalls = toolCalls.filter((c) => c.name === "finish");
|
|
@@ -1067,7 +1087,9 @@ async function runWarpGrep(config) {
|
|
|
1067
1087
|
)
|
|
1068
1088
|
);
|
|
1069
1089
|
}
|
|
1090
|
+
const toolExecStart = Date.now();
|
|
1070
1091
|
const allResults = await Promise.all(allPromises);
|
|
1092
|
+
turnMetrics.local_tools_ms = Date.now() - toolExecStart;
|
|
1071
1093
|
for (const result of allResults) {
|
|
1072
1094
|
formatted.push(result);
|
|
1073
1095
|
}
|
|
@@ -1076,6 +1098,7 @@ async function runWarpGrep(config) {
|
|
|
1076
1098
|
const contextBudget = calculateContextBudget(messages);
|
|
1077
1099
|
messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
|
|
1078
1100
|
}
|
|
1101
|
+
timings.turns.push(turnMetrics);
|
|
1079
1102
|
if (finishCalls.length) {
|
|
1080
1103
|
const fc = finishCalls[0];
|
|
1081
1104
|
const files = fc.arguments?.files ?? [];
|
|
@@ -1085,7 +1108,8 @@ async function runWarpGrep(config) {
|
|
|
1085
1108
|
}
|
|
1086
1109
|
}
|
|
1087
1110
|
if (terminationReason !== "completed" || !finishMeta) {
|
|
1088
|
-
|
|
1111
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1112
|
+
return { terminationReason, messages, errors, timings };
|
|
1089
1113
|
}
|
|
1090
1114
|
const parts = ["Relevant context found:"];
|
|
1091
1115
|
for (const f of finishMeta.files) {
|
|
@@ -1093,6 +1117,7 @@ async function runWarpGrep(config) {
|
|
|
1093
1117
|
parts.push(`- ${f.path}: ${ranges}`);
|
|
1094
1118
|
}
|
|
1095
1119
|
const payload = parts.join("\n");
|
|
1120
|
+
const finishResolutionStart = Date.now();
|
|
1096
1121
|
const fileReadErrors = [];
|
|
1097
1122
|
const resolved = await readFinishFiles(
|
|
1098
1123
|
repoRoot,
|
|
@@ -1112,13 +1137,16 @@ async function runWarpGrep(config) {
|
|
|
1112
1137
|
}
|
|
1113
1138
|
}
|
|
1114
1139
|
);
|
|
1140
|
+
timings.finish_resolution_ms = Date.now() - finishResolutionStart;
|
|
1115
1141
|
if (fileReadErrors.length > 0) {
|
|
1116
1142
|
errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
|
|
1117
1143
|
}
|
|
1144
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1118
1145
|
return {
|
|
1119
1146
|
terminationReason: "completed",
|
|
1120
1147
|
messages,
|
|
1121
|
-
finish: { payload, metadata: finishMeta, resolved }
|
|
1148
|
+
finish: { payload, metadata: finishMeta, resolved },
|
|
1149
|
+
timings
|
|
1122
1150
|
};
|
|
1123
1151
|
}
|
|
1124
1152
|
|
|
@@ -1747,7 +1775,8 @@ var WarpGrepClient = class {
|
|
|
1747
1775
|
debug: input.debug ?? this.config.debug,
|
|
1748
1776
|
morphApiKey: this.config.morphApiKey,
|
|
1749
1777
|
morphApiUrl: this.config.morphApiUrl,
|
|
1750
|
-
retryConfig: this.config.retryConfig
|
|
1778
|
+
retryConfig: this.config.retryConfig,
|
|
1779
|
+
timeout: this.config.timeout
|
|
1751
1780
|
}
|
|
1752
1781
|
);
|
|
1753
1782
|
}
|
|
@@ -1768,7 +1797,8 @@ async function executeToolCall(input, config) {
|
|
|
1768
1797
|
debug: config.debug ?? false,
|
|
1769
1798
|
morphApiKey: config.morphApiKey,
|
|
1770
1799
|
morphApiUrl: config.morphApiUrl,
|
|
1771
|
-
retryConfig: config.retryConfig
|
|
1800
|
+
retryConfig: config.retryConfig,
|
|
1801
|
+
timeout: config.timeout
|
|
1772
1802
|
});
|
|
1773
1803
|
const finish = result.finish;
|
|
1774
1804
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|