@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,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runWarpGrep
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-QOYI77CN.js";
|
|
4
|
+
import "../../../chunk-P2O5JKE5.js";
|
|
5
5
|
import "../../../chunk-APP75CBN.js";
|
|
6
6
|
import "../../../chunk-5QRN3JNB.js";
|
|
7
7
|
import "../../../chunk-FMLHRJDF.js";
|
|
8
|
-
import "../../../chunk-
|
|
8
|
+
import "../../../chunk-5PNMAWLC.js";
|
|
9
9
|
import "../../../chunk-4VWJFZVS.js";
|
|
10
10
|
import "../../../chunk-PZ5AY32C.js";
|
|
11
11
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../tools/warp_grep/agent/types.ts"],"sourcesContent":["// Core types for morph-warp-grep agent\n\nexport type ChatMessage = {\n role: 'system' | 'user' | 'assistant';\n content: string;\n};\n\nexport type ToolName = 'list_directory' | 'grep' | 'read' | 'finish' | '_skip';\n\nexport type ToolCall = {\n name: ToolName;\n arguments?: Record<string, unknown>;\n};\n\nexport type FinishFileSpec = {\n path: string;\n lines: '*' | Array<[number, number]>;\n};\n\nexport type ResolvedContext = {\n path: string;\n ranges: '*' | Array<[number, number]>;\n content: string;\n};\n\nexport type AgentFinish = {\n files: FinishFileSpec[];\n};\n\nexport type ResolvedFile = {\n path: string;\n content: string;\n};\n\nexport type AgentRunResult = {\n terminationReason: 'completed' | 'terminated' | 'error';\n messages: ChatMessage[];\n finish?: { \n payload: string; \n metadata?: AgentFinish;\n resolved?: ResolvedFile[];\n };\n errors?: Array<{ message: string }>;\n};\n\nexport type SessionConfig = {\n query: string;\n model?: string;\n repoRoot: string;\n excludes?: string[];\n includes?: string[];\n debug?: boolean;\n provider?: unknown; // late-bound to provider interface to avoid cycles\n /** Morph API key (defaults to MORPH_API_KEY env var) */\n morphApiKey?: string;\n /** Morph API base URL */\n morphApiUrl?: string;\n /** Retry configuration */\n retryConfig?: import('../../utils/resilience.js').RetryConfig;\n};\n\n\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../tools/warp_grep/agent/types.ts"],"sourcesContent":["// Core types for morph-warp-grep agent\n\nexport type ChatMessage = {\n role: 'system' | 'user' | 'assistant';\n content: string;\n};\n\nexport type ToolName = 'list_directory' | 'grep' | 'read' | 'finish' | '_skip';\n\nexport type ToolCall = {\n name: ToolName;\n arguments?: Record<string, unknown>;\n};\n\nexport type FinishFileSpec = {\n path: string;\n lines: '*' | Array<[number, number]>;\n};\n\nexport type ResolvedContext = {\n path: string;\n ranges: '*' | Array<[number, number]>;\n content: string;\n};\n\nexport type AgentFinish = {\n files: FinishFileSpec[];\n};\n\nexport type ResolvedFile = {\n path: string;\n content: string;\n};\n\nexport type WarpGrepTurnMetrics = {\n turn: number;\n morph_api_ms: number;\n local_tools_ms: number;\n};\n\nexport type WarpGrepExecutionMetrics = {\n total_ms: number;\n timeout_ms: number;\n initial_state_ms: number;\n turns: WarpGrepTurnMetrics[];\n finish_resolution_ms?: number;\n};\n\nexport type AgentRunResult = {\n terminationReason: 'completed' | 'terminated' | 'error';\n messages: ChatMessage[];\n finish?: { \n payload: string; \n metadata?: AgentFinish;\n resolved?: ResolvedFile[];\n };\n errors?: Array<{ message: string }>;\n timings?: WarpGrepExecutionMetrics;\n};\n\nexport type SessionConfig = {\n query: string;\n model?: string;\n repoRoot: string;\n excludes?: string[];\n includes?: string[];\n debug?: boolean;\n provider?: unknown; // late-bound to provider interface to avoid cycles\n /** Morph API key (defaults to MORPH_API_KEY env var) */\n morphApiKey?: string;\n /** Morph API base URL */\n morphApiUrl?: string;\n /** Retry configuration */\n retryConfig?: import('../../utils/resilience.js').RetryConfig;\n /** Timeout for model calls in ms (defaults to MORPH_WARP_GREP_TIMEOUT env var, then 30000) */\n timeout?: number;\n};\n\n\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -25,6 +25,18 @@ type ResolvedFile = {
|
|
|
25
25
|
path: string;
|
|
26
26
|
content: string;
|
|
27
27
|
};
|
|
28
|
+
type WarpGrepTurnMetrics = {
|
|
29
|
+
turn: number;
|
|
30
|
+
morph_api_ms: number;
|
|
31
|
+
local_tools_ms: number;
|
|
32
|
+
};
|
|
33
|
+
type WarpGrepExecutionMetrics = {
|
|
34
|
+
total_ms: number;
|
|
35
|
+
timeout_ms: number;
|
|
36
|
+
initial_state_ms: number;
|
|
37
|
+
turns: WarpGrepTurnMetrics[];
|
|
38
|
+
finish_resolution_ms?: number;
|
|
39
|
+
};
|
|
28
40
|
type AgentRunResult = {
|
|
29
41
|
terminationReason: 'completed' | 'terminated' | 'error';
|
|
30
42
|
messages: ChatMessage[];
|
|
@@ -36,6 +48,7 @@ type AgentRunResult = {
|
|
|
36
48
|
errors?: Array<{
|
|
37
49
|
message: string;
|
|
38
50
|
}>;
|
|
51
|
+
timings?: WarpGrepExecutionMetrics;
|
|
39
52
|
};
|
|
40
53
|
type SessionConfig = {
|
|
41
54
|
query: string;
|
|
@@ -51,6 +64,8 @@ type SessionConfig = {
|
|
|
51
64
|
morphApiUrl?: string;
|
|
52
65
|
/** Retry configuration */
|
|
53
66
|
retryConfig?: RetryConfig;
|
|
67
|
+
/** Timeout for model calls in ms (defaults to MORPH_WARP_GREP_TIMEOUT env var, then 30000) */
|
|
68
|
+
timeout?: number;
|
|
54
69
|
};
|
|
55
70
|
|
|
56
|
-
export type { AgentFinish, AgentRunResult, ChatMessage, FinishFileSpec, ResolvedContext, ResolvedFile, SessionConfig, ToolCall, ToolName };
|
|
71
|
+
export type { AgentFinish, AgentRunResult, ChatMessage, FinishFileSpec, ResolvedContext, ResolvedFile, SessionConfig, ToolCall, ToolName, WarpGrepExecutionMetrics, WarpGrepTurnMetrics };
|
|
@@ -39,9 +39,15 @@ __export(anthropic_exports, {
|
|
|
39
39
|
module.exports = __toCommonJS(anthropic_exports);
|
|
40
40
|
|
|
41
41
|
// tools/warp_grep/agent/config.ts
|
|
42
|
+
var parseEnvTimeout = (envValue, defaultMs) => {
|
|
43
|
+
if (!envValue) return defaultMs;
|
|
44
|
+
const parsed = parseInt(envValue, 10);
|
|
45
|
+
return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
|
|
46
|
+
};
|
|
42
47
|
var AGENT_CONFIG = {
|
|
43
48
|
MAX_TURNS: 4,
|
|
44
|
-
|
|
49
|
+
/** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
|
|
50
|
+
TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 3e4),
|
|
45
51
|
MAX_CONTEXT_CHARS: 54e4,
|
|
46
52
|
MAX_OUTPUT_LINES: 200,
|
|
47
53
|
MAX_READ_LINES: 800,
|
|
@@ -983,7 +989,8 @@ async function callModel(messages, model, options = {}) {
|
|
|
983
989
|
},
|
|
984
990
|
options.retryConfig
|
|
985
991
|
);
|
|
986
|
-
const
|
|
992
|
+
const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
993
|
+
const resp = await withTimeout(fetchPromise, timeoutMs, "morph-warp-grep request timed out");
|
|
987
994
|
if (!resp.ok) {
|
|
988
995
|
if (resp.status === 404) {
|
|
989
996
|
throw new Error(
|
|
@@ -1001,10 +1008,15 @@ async function callModel(messages, model, options = {}) {
|
|
|
1001
1008
|
return content;
|
|
1002
1009
|
}
|
|
1003
1010
|
async function runWarpGrep(config) {
|
|
1011
|
+
const totalStart = Date.now();
|
|
1012
|
+
const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1013
|
+
const timings = { turns: [], timeout_ms: timeoutMs };
|
|
1004
1014
|
const repoRoot = import_path2.default.resolve(config.repoRoot || process.cwd());
|
|
1005
1015
|
const messages = [];
|
|
1006
1016
|
messages.push({ role: "system", content: getSystemPrompt() });
|
|
1017
|
+
const initialStateStart = Date.now();
|
|
1007
1018
|
const initialState = await buildInitialState(repoRoot, config.query, config.provider);
|
|
1019
|
+
timings.initial_state_ms = Date.now() - initialStateStart;
|
|
1008
1020
|
messages.push({ role: "user", content: initialState });
|
|
1009
1021
|
const maxTurns = AGENT_CONFIG.MAX_TURNS;
|
|
1010
1022
|
const model = config.model || DEFAULT_MODEL;
|
|
@@ -1013,21 +1025,29 @@ async function runWarpGrep(config) {
|
|
|
1013
1025
|
let finishMeta;
|
|
1014
1026
|
let terminationReason = "terminated";
|
|
1015
1027
|
for (let turn = 1; turn <= maxTurns; turn += 1) {
|
|
1028
|
+
const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
|
|
1016
1029
|
enforceContextLimit(messages);
|
|
1030
|
+
const modelCallStart = Date.now();
|
|
1017
1031
|
const assistantContent = await callModel(messages, model, {
|
|
1018
1032
|
morphApiKey: config.morphApiKey,
|
|
1019
1033
|
morphApiUrl: config.morphApiUrl,
|
|
1020
|
-
retryConfig: config.retryConfig
|
|
1034
|
+
retryConfig: config.retryConfig,
|
|
1035
|
+
timeout: timeoutMs
|
|
1021
1036
|
}).catch((e) => {
|
|
1022
1037
|
errors.push({ message: e instanceof Error ? e.message : String(e) });
|
|
1023
1038
|
return "";
|
|
1024
1039
|
});
|
|
1025
|
-
|
|
1040
|
+
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
1041
|
+
if (!assistantContent) {
|
|
1042
|
+
timings.turns.push(turnMetrics);
|
|
1043
|
+
break;
|
|
1044
|
+
}
|
|
1026
1045
|
messages.push({ role: "assistant", content: assistantContent });
|
|
1027
1046
|
const toolCalls = parser.parse(assistantContent);
|
|
1028
1047
|
if (toolCalls.length === 0) {
|
|
1029
1048
|
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" });
|
|
1030
1049
|
terminationReason = "terminated";
|
|
1050
|
+
timings.turns.push(turnMetrics);
|
|
1031
1051
|
break;
|
|
1032
1052
|
}
|
|
1033
1053
|
const finishCalls = toolCalls.filter((c) => c.name === "finish");
|
|
@@ -1068,7 +1088,9 @@ async function runWarpGrep(config) {
|
|
|
1068
1088
|
)
|
|
1069
1089
|
);
|
|
1070
1090
|
}
|
|
1091
|
+
const toolExecStart = Date.now();
|
|
1071
1092
|
const allResults = await Promise.all(allPromises);
|
|
1093
|
+
turnMetrics.local_tools_ms = Date.now() - toolExecStart;
|
|
1072
1094
|
for (const result of allResults) {
|
|
1073
1095
|
formatted.push(result);
|
|
1074
1096
|
}
|
|
@@ -1077,6 +1099,7 @@ async function runWarpGrep(config) {
|
|
|
1077
1099
|
const contextBudget = calculateContextBudget(messages);
|
|
1078
1100
|
messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
|
|
1079
1101
|
}
|
|
1102
|
+
timings.turns.push(turnMetrics);
|
|
1080
1103
|
if (finishCalls.length) {
|
|
1081
1104
|
const fc = finishCalls[0];
|
|
1082
1105
|
const files = fc.arguments?.files ?? [];
|
|
@@ -1086,7 +1109,8 @@ async function runWarpGrep(config) {
|
|
|
1086
1109
|
}
|
|
1087
1110
|
}
|
|
1088
1111
|
if (terminationReason !== "completed" || !finishMeta) {
|
|
1089
|
-
|
|
1112
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1113
|
+
return { terminationReason, messages, errors, timings };
|
|
1090
1114
|
}
|
|
1091
1115
|
const parts = ["Relevant context found:"];
|
|
1092
1116
|
for (const f of finishMeta.files) {
|
|
@@ -1094,6 +1118,7 @@ async function runWarpGrep(config) {
|
|
|
1094
1118
|
parts.push(`- ${f.path}: ${ranges}`);
|
|
1095
1119
|
}
|
|
1096
1120
|
const payload = parts.join("\n");
|
|
1121
|
+
const finishResolutionStart = Date.now();
|
|
1097
1122
|
const fileReadErrors = [];
|
|
1098
1123
|
const resolved = await readFinishFiles(
|
|
1099
1124
|
repoRoot,
|
|
@@ -1113,13 +1138,16 @@ async function runWarpGrep(config) {
|
|
|
1113
1138
|
}
|
|
1114
1139
|
}
|
|
1115
1140
|
);
|
|
1141
|
+
timings.finish_resolution_ms = Date.now() - finishResolutionStart;
|
|
1116
1142
|
if (fileReadErrors.length > 0) {
|
|
1117
1143
|
errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
|
|
1118
1144
|
}
|
|
1145
|
+
timings.total_ms = Date.now() - totalStart;
|
|
1119
1146
|
return {
|
|
1120
1147
|
terminationReason: "completed",
|
|
1121
1148
|
messages,
|
|
1122
|
-
finish: { payload, metadata: finishMeta, resolved }
|
|
1149
|
+
finish: { payload, metadata: finishMeta, resolved },
|
|
1150
|
+
timings
|
|
1123
1151
|
};
|
|
1124
1152
|
}
|
|
1125
1153
|
|
|
@@ -1716,7 +1744,8 @@ async function executeToolCall(input, config) {
|
|
|
1716
1744
|
debug: config.debug ?? false,
|
|
1717
1745
|
morphApiKey: config.morphApiKey,
|
|
1718
1746
|
morphApiUrl: config.morphApiUrl,
|
|
1719
|
-
retryConfig: config.retryConfig
|
|
1747
|
+
retryConfig: config.retryConfig,
|
|
1748
|
+
timeout: config.timeout
|
|
1720
1749
|
});
|
|
1721
1750
|
const finish = result.finish;
|
|
1722
1751
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|