@morphllm/morphsdk 0.2.45 → 0.2.46
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/README.md +1 -1
- package/dist/{chunk-TVFGHXPE.js → chunk-3FTAIJBH.js} +4 -4
- package/dist/chunk-5JTJOQUX.js +283 -0
- package/dist/chunk-5JTJOQUX.js.map +1 -0
- package/dist/{chunk-ZRLEAPZV.js → chunk-76DJEQEP.js} +4 -4
- package/dist/{chunk-W3XLPMV3.js → chunk-7HS6YXA3.js} +21 -5
- package/dist/{chunk-W3XLPMV3.js.map → chunk-7HS6YXA3.js.map} +1 -1
- package/dist/chunk-7T7YOPJV.js +82 -0
- package/dist/chunk-7T7YOPJV.js.map +1 -0
- package/dist/chunk-CL45IWIU.js +105 -0
- package/dist/chunk-CL45IWIU.js.map +1 -0
- package/dist/chunk-D6OD3IST.js +70 -0
- package/dist/chunk-D6OD3IST.js.map +1 -0
- package/dist/{chunk-PEGZVGG4.js → chunk-G4AWE5A2.js} +4 -4
- package/dist/{chunk-OUEJ6XEO.js → chunk-GJU7UOFL.js} +4 -4
- package/dist/{chunk-Q7PDN7TS.js → chunk-GZMUGMOZ.js} +1 -1
- package/dist/{chunk-Q7PDN7TS.js.map → chunk-GZMUGMOZ.js.map} +1 -1
- package/dist/chunk-JYBVRF72.js +1 -0
- package/dist/{chunk-GDR65N2J.js → chunk-OXHGFHEU.js} +53 -26
- package/dist/chunk-OXHGFHEU.js.map +1 -0
- package/dist/{chunk-VBBJGWHY.js → chunk-P2XKFWFD.js} +2 -2
- package/dist/chunk-PABIV7X6.js +76 -0
- package/dist/chunk-PABIV7X6.js.map +1 -0
- package/dist/{chunk-GTOXMAF2.js → chunk-SWQPIKPY.js} +44 -3
- package/dist/chunk-SWQPIKPY.js.map +1 -0
- package/dist/chunk-TJIUA27P.js +94 -0
- package/dist/chunk-TJIUA27P.js.map +1 -0
- package/dist/{chunk-O5DA5V5S.js → chunk-UBX7QYBD.js} +4 -4
- package/dist/{chunk-X4CQ6D3G.js → chunk-UIZT3KVJ.js} +4 -4
- package/dist/{chunk-UYBIKZPM.js → chunk-UXYK7WZX.js} +2 -2
- package/dist/chunk-WETRQJGU.js +129 -0
- package/dist/chunk-WETRQJGU.js.map +1 -0
- package/dist/client-BGctTHu9.d.ts +318 -0
- package/dist/client.cjs +1885 -44
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +14 -110
- package/dist/client.js +28 -3
- package/dist/core-DxiUwyBe.d.ts +156 -0
- package/dist/git/client.cjs +52 -25
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.d.ts +17 -8
- package/dist/git/client.js +1 -1
- package/dist/git/index.cjs +52 -25
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.d.ts +1 -1
- package/dist/git/index.js +2 -2
- package/dist/git/types.cjs.map +1 -1
- package/dist/git/types.d.ts +20 -2
- package/dist/index.cjs +1964 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +47 -5
- package/dist/tools/codebase_search/anthropic.js +2 -2
- package/dist/tools/codebase_search/index.js +9 -9
- package/dist/tools/codebase_search/openai.js +2 -2
- package/dist/tools/codebase_search/vercel.js +2 -2
- package/dist/tools/fastapply/anthropic.js +2 -2
- package/dist/tools/fastapply/index.js +7 -7
- package/dist/tools/fastapply/openai.js +2 -2
- package/dist/tools/fastapply/vercel.js +2 -2
- package/dist/tools/index.js +7 -7
- package/dist/tools/warp_grep/agent/config.cjs +80 -1
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/config.js +1 -1
- package/dist/tools/warp_grep/agent/parser.cjs +43 -2
- package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/parser.js +1 -1
- package/dist/tools/warp_grep/agent/prompt.cjs +89 -45
- package/dist/tools/warp_grep/agent/prompt.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/prompt.d.ts +1 -1
- package/dist/tools/warp_grep/agent/prompt.js +1 -1
- package/dist/tools/warp_grep/agent/runner.cjs +229 -49
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +4 -4
- package/dist/tools/warp_grep/agent/types.js +0 -1
- package/dist/tools/warp_grep/anthropic.cjs +311 -83
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +75 -12
- package/dist/tools/warp_grep/anthropic.js +21 -8
- package/dist/tools/warp_grep/index.cjs +415 -126
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +17 -4
- package/dist/tools/warp_grep/index.js +29 -21
- package/dist/tools/warp_grep/openai.cjs +314 -83
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +73 -29
- package/dist/tools/warp_grep/openai.js +21 -8
- package/dist/tools/warp_grep/providers/command.cjs +80 -1
- package/dist/tools/warp_grep/providers/command.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/command.js +2 -2
- package/dist/tools/warp_grep/providers/local.cjs +80 -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/vercel.cjs +291 -57
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +40 -19
- package/dist/tools/warp_grep/vercel.js +17 -8
- package/package.json +1 -1
- package/dist/chunk-AFEPUNAO.js +0 -15
- package/dist/chunk-AFEPUNAO.js.map +0 -1
- package/dist/chunk-GDR65N2J.js.map +0 -1
- package/dist/chunk-GTOXMAF2.js.map +0 -1
- package/dist/chunk-HKZB23U7.js +0 -85
- package/dist/chunk-HKZB23U7.js.map +0 -1
- package/dist/chunk-IQHKEIQX.js +0 -54
- package/dist/chunk-IQHKEIQX.js.map +0 -1
- package/dist/chunk-JKFVDM62.js +0 -45
- package/dist/chunk-JKFVDM62.js.map +0 -1
- package/dist/chunk-K6FQZZ2E.js +0 -104
- package/dist/chunk-K6FQZZ2E.js.map +0 -1
- package/dist/chunk-KL4YVZRF.js +0 -57
- package/dist/chunk-KL4YVZRF.js.map +0 -1
- package/dist/chunk-XYPMN4A3.js +0 -1
- /package/dist/{chunk-TVFGHXPE.js.map → chunk-3FTAIJBH.js.map} +0 -0
- /package/dist/{chunk-ZRLEAPZV.js.map → chunk-76DJEQEP.js.map} +0 -0
- /package/dist/{chunk-PEGZVGG4.js.map → chunk-G4AWE5A2.js.map} +0 -0
- /package/dist/{chunk-OUEJ6XEO.js.map → chunk-GJU7UOFL.js.map} +0 -0
- /package/dist/{chunk-XYPMN4A3.js.map → chunk-JYBVRF72.js.map} +0 -0
- /package/dist/{chunk-VBBJGWHY.js.map → chunk-P2XKFWFD.js.map} +0 -0
- /package/dist/{chunk-O5DA5V5S.js.map → chunk-UBX7QYBD.js.map} +0 -0
- /package/dist/{chunk-X4CQ6D3G.js.map → chunk-UIZT3KVJ.js.map} +0 -0
- /package/dist/{chunk-UYBIKZPM.js.map → chunk-UXYK7WZX.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/agent/parser.ts"],"sourcesContent":["// Parses assistant lines into structured tool calls\nimport type { ToolCall } from './types.js';\n\nexport class LLMResponseParseError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'LLMResponseParseError';\n }\n}\n\ntype LineContext = { lineNumber: number; raw: string };\n\n// Valid tool command names\nconst VALID_COMMANDS = ['analyse', 'grep', 'read', 'finish'];\n\n/**\n * Preprocesses text to handle XML tags:\n * 1. Removes <think>...</think> blocks entirely\n * 2. Extracts content from <tool>...</tool> or <tool_call>...</tool_call> tags\n * 3. Passes through raw tool calls (lines starting with valid commands)\n * 4. Discards unclosed <tool...> tags\n */\nfunction preprocessText(text: string): string[] {\n // Step 1: Remove <think>...</think> blocks (including multiline)\n let processed = text.replace(/<think>[\\s\\S]*?<\\/think>/gi, '');\n \n // Step 2: Check for unclosed <tool or <tool_call tags and discard them\n // Find all opening tags and their positions\n const openingTagRegex = /<tool_call>|<tool>/gi;\n const closingTagRegex = /<\\/tool_call>|<\\/tool>/gi;\n \n // Count opening and closing tags\n const openingMatches = processed.match(openingTagRegex) || [];\n const closingMatches = processed.match(closingTagRegex) || [];\n \n // If there are more opening than closing tags, we have unclosed tags\n // In that case, only process complete tag pairs\n if (openingMatches.length > closingMatches.length) {\n // Remove any content after the last complete closing tag\n const lastClosingMatch = /<\\/tool_call>|<\\/tool>/gi;\n let lastClosingIndex = -1;\n let match;\n while ((match = lastClosingMatch.exec(processed)) !== null) {\n lastClosingIndex = match.index + match[0].length;\n }\n if (lastClosingIndex > 0) {\n processed = processed.slice(0, lastClosingIndex);\n }\n }\n \n // Step 3: Extract content from <tool_call>...</tool_call> and <tool>...</tool> tags\n const toolCallLines: string[] = [];\n const toolTagRegex = /<tool_call>([\\s\\S]*?)<\\/tool_call>|<tool>([\\s\\S]*?)<\\/tool>/gi;\n let tagMatch;\n \n while ((tagMatch = toolTagRegex.exec(processed)) !== null) {\n const content = (tagMatch[1] || tagMatch[2] || '').trim();\n if (content) {\n // Split content by newlines in case there are multiple tool calls in one tag\n const lines = content.split(/\\r?\\n/).map(l => l.trim()).filter(l => l);\n toolCallLines.push(...lines);\n }\n }\n \n // Step 4: Also extract raw tool calls (lines starting with valid commands)\n // This provides backwards compatibility\n const allLines = processed.split(/\\r?\\n/).map(l => l.trim());\n for (const line of allLines) {\n if (!line) continue;\n \n // Skip lines that are inside XML tags (already processed above)\n if (line.startsWith('<')) continue;\n \n // Check if line starts with a valid command\n const firstWord = line.split(/\\s/)[0];\n if (VALID_COMMANDS.includes(firstWord)) {\n // Avoid duplicates\n if (!toolCallLines.includes(line)) {\n toolCallLines.push(line);\n }\n }\n }\n \n return toolCallLines;\n}\n\nexport class LLMResponseParser {\n private readonly finishSpecSplitRe = /,(?=[^,\\s]+:)/;\n\n parse(text: string): ToolCall[] {\n if (typeof text !== 'string') {\n throw new TypeError('Command text must be a string.');\n }\n \n // Preprocess to handle XML tags\n const lines = preprocessText(text);\n \n const commands: ToolCall[] = [];\n let finishAccumulator: Map<string, number[][]> | null = null;\n\n lines.forEach((line, idx) => {\n if (!line || line.startsWith('#')) return;\n const ctx: LineContext = { lineNumber: idx + 1, raw: line };\n const parts = this.splitLine(line, ctx);\n if (parts.length === 0) return;\n const cmd = parts[0];\n switch (cmd) {\n case 'analyse':\n this.handleAnalyse(parts, ctx, commands);\n break;\n case 'grep':\n this.handleGrep(parts, ctx, commands);\n break;\n case 'read':\n this.handleRead(parts, ctx, commands);\n break;\n case 'finish':\n finishAccumulator = this.handleFinish(parts, ctx, finishAccumulator);\n break;\n default:\n // Silently ignore unknown commands after preprocessing\n // (they might be remnants of XML or other content)\n break;\n }\n });\n\n if (finishAccumulator) {\n const map = finishAccumulator as Map<string, number[][]>;\n const entries = [...map.entries()];\n const filesPayload = entries.map(([path, ranges]) => ({\n path,\n lines: [...ranges].sort((a, b) => a[0] - b[0]) as Array<[number, number]>,\n }));\n commands.push({ name: 'finish', arguments: { files: filesPayload } });\n }\n return commands;\n }\n\n private splitLine(line: string, ctx: LineContext): string[] {\n try {\n // Split by whitespace but keep quoted blocks as one\n const parts: string[] = [];\n let current = '';\n let inSingle = false;\n for (let i = 0; i < line.length; i++) {\n const ch = line[i];\n if (ch === \"'\" && line[i - 1] !== '\\\\') {\n inSingle = !inSingle;\n current += ch;\n } else if (!inSingle && /\\s/.test(ch)) {\n if (current) {\n parts.push(current);\n current = '';\n }\n } else {\n current += ch;\n }\n }\n if (current) parts.push(current);\n return parts;\n } catch {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: Unable to parse line.`);\n }\n }\n\n private handleAnalyse(parts: string[], ctx: LineContext, commands: ToolCall[]) {\n // analyse <path> [pattern]\n if (parts.length < 2) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: analyse requires <path>`);\n }\n const path = parts[1];\n const pattern = parts[2]?.replace(/^\"|\"$/g, '') ?? null;\n commands.push({ name: 'analyse', arguments: { path, pattern } });\n }\n\n // no glob tool in MCP\n\n private handleGrep(parts: string[], ctx: LineContext, commands: ToolCall[]) {\n // grep '<pattern>' <path>\n if (parts.length < 3) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: grep requires '<pattern>' and <path>`);\n }\n const pat = parts[1];\n if (!pat.startsWith(\"'\") || !pat.endsWith(\"'\")) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: grep pattern must be single-quoted`);\n }\n commands.push({ name: 'grep', arguments: { pattern: pat.slice(1, -1), path: parts[2] } });\n }\n\n private handleRead(parts: string[], ctx: LineContext, commands: ToolCall[]) {\n // read <path>[:start-end]\n if (parts.length < 2) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: read requires <path> or <path>:<start-end>`);\n }\n const spec = parts[1];\n const rangeIdx = spec.indexOf(':');\n if (rangeIdx === -1) {\n commands.push({ name: 'read', arguments: { path: spec } });\n return;\n }\n const path = spec.slice(0, rangeIdx);\n const range = spec.slice(rangeIdx + 1);\n const [s, e] = range.split('-').map(v => parseInt(v, 10));\n if (!Number.isFinite(s) || !Number.isFinite(e)) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: invalid read range '${range}'`);\n }\n commands.push({ name: 'read', arguments: { path, start: s, end: e } });\n }\n\n private handleFinish(parts: string[], ctx: LineContext, acc: Map<string, number[][]> | null) {\n // finish file1:1-10,20-30 file2:5-7\n const map = acc ?? new Map<string, number[][]>();\n const args = parts.slice(1);\n for (const token of args) {\n const [path, rangesText] = token.split(':', 2);\n if (!path || !rangesText) {\n throw new LLMResponseParseError(`Line ${ctx.lineNumber}: invalid finish token '${token}'`);\n }\n const rangeSpecs = rangesText.split(',').filter(Boolean);\n for (const spec of rangeSpecs) {\n const [s, e] = spec.split('-').map(v => parseInt(v, 10));\n if (!Number.isFinite(s) || !Number.isFinite(e) || e < s) {\n throw new LLMRes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AACxB,YAAM,CAAC,MAAM,UAAU,IAAI,MAAM,MAAM,KAAK,CAAC;AAC7C,UAAI,CAAC,QAAQ,CAAC,YAAY;AACxB,cAAM,IAAI,sBAAsB,QAAQ,IAAI,UAAU,2BAA2B,KAAK,GAAG;AAAA,MAC3F;AACA,YAAM,aAAa,WAAW,MAAM,GAAG,EAAE,OAAO,OAAO;AACvD,iBAAW,QAAQ,YAAY;AAC7B,cAAM,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI,OAAK,SAAS,GAAG,EAAE,CAAC;AACvD,YAAI,CAAC,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,KAAK,IAAI,GAAG;AACvD,gBAAM,IAAI,sBAAsB,QAAQ,IAAI,UAAU,oBAAoB,IAAI,GAAG;AAAA,QACnF;AACA,cAAM,MAAM,IAAI,IAAI,IAAI,KAAK,CAAC;AAC9B,YAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AACf,YAAI,IAAI,MAAM,GAAG;AAAA,MACnB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// tools/warp_grep/agent/config.ts
|
|
2
|
+
var AGENT_CONFIG = {
|
|
3
|
+
// Give the model freedom; failsafe cap to prevent infinite loops
|
|
4
|
+
MAX_ROUNDS: 10,
|
|
5
|
+
TIMEOUT_MS: 3e4
|
|
6
|
+
};
|
|
7
|
+
var BUILTIN_EXCLUDES = [
|
|
8
|
+
// Version control
|
|
9
|
+
".git",
|
|
10
|
+
".svn",
|
|
11
|
+
".hg",
|
|
12
|
+
".bzr",
|
|
13
|
+
// Dependencies
|
|
14
|
+
"node_modules",
|
|
15
|
+
"bower_components",
|
|
16
|
+
".pnpm",
|
|
17
|
+
".yarn",
|
|
18
|
+
"vendor",
|
|
19
|
+
"packages",
|
|
20
|
+
"Pods",
|
|
21
|
+
".bundle",
|
|
22
|
+
// Python
|
|
23
|
+
"__pycache__",
|
|
24
|
+
".pytest_cache",
|
|
25
|
+
".mypy_cache",
|
|
26
|
+
".ruff_cache",
|
|
27
|
+
".venv",
|
|
28
|
+
"venv",
|
|
29
|
+
".tox",
|
|
30
|
+
".nox",
|
|
31
|
+
".eggs",
|
|
32
|
+
"*.egg-info",
|
|
33
|
+
// Build outputs
|
|
34
|
+
"dist",
|
|
35
|
+
"build",
|
|
36
|
+
"out",
|
|
37
|
+
"output",
|
|
38
|
+
"target",
|
|
39
|
+
"_build",
|
|
40
|
+
".next",
|
|
41
|
+
".nuxt",
|
|
42
|
+
".output",
|
|
43
|
+
".vercel",
|
|
44
|
+
".netlify",
|
|
45
|
+
// Cache directories
|
|
46
|
+
".cache",
|
|
47
|
+
".parcel-cache",
|
|
48
|
+
".turbo",
|
|
49
|
+
".nx",
|
|
50
|
+
".gradle",
|
|
51
|
+
// IDE/Editor
|
|
52
|
+
".idea",
|
|
53
|
+
".vscode",
|
|
54
|
+
".vs",
|
|
55
|
+
// Coverage
|
|
56
|
+
"coverage",
|
|
57
|
+
".coverage",
|
|
58
|
+
"htmlcov",
|
|
59
|
+
".nyc_output",
|
|
60
|
+
// Temporary
|
|
61
|
+
"tmp",
|
|
62
|
+
"temp",
|
|
63
|
+
".tmp",
|
|
64
|
+
".temp",
|
|
65
|
+
// Lock files
|
|
66
|
+
"package-lock.json",
|
|
67
|
+
"yarn.lock",
|
|
68
|
+
"pnpm-lock.yaml",
|
|
69
|
+
"bun.lockb",
|
|
70
|
+
"Cargo.lock",
|
|
71
|
+
"Gemfile.lock",
|
|
72
|
+
"poetry.lock",
|
|
73
|
+
// Binary/minified
|
|
74
|
+
"*.min.js",
|
|
75
|
+
"*.min.css",
|
|
76
|
+
"*.bundle.js",
|
|
77
|
+
"*.wasm",
|
|
78
|
+
"*.so",
|
|
79
|
+
"*.dll",
|
|
80
|
+
"*.pyc",
|
|
81
|
+
"*.map",
|
|
82
|
+
"*.js.map",
|
|
83
|
+
// Hidden directories catch-all
|
|
84
|
+
".*"
|
|
85
|
+
];
|
|
86
|
+
var DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
|
|
87
|
+
var DEFAULT_MODEL = "morph-warp-grep";
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
AGENT_CONFIG,
|
|
91
|
+
DEFAULT_EXCLUDES,
|
|
92
|
+
DEFAULT_MODEL
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=chunk-TJIUA27P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/agent/config.ts"],"sourcesContent":["// Agent configuration defaults for morph-warp-grep\n// Hard-coded: SDK does not expose control over rounds or timeout.\nexport const AGENT_CONFIG = {\n // Give the model freedom; failsafe cap to prevent infinite loops\n MAX_ROUNDS: 10,\n TIMEOUT_MS: 30000,\n};\n\n/**\n * Comprehensive exclusion list for directories and files\n * These patterns are used with ripgrep's -g flag\n */\nconst BUILTIN_EXCLUDES = [\n // Version control\n '.git', '.svn', '.hg', '.bzr',\n \n // Dependencies\n 'node_modules', 'bower_components', '.pnpm', '.yarn',\n 'vendor', 'packages', 'Pods', '.bundle',\n \n // Python\n '__pycache__', '.pytest_cache', '.mypy_cache', '.ruff_cache',\n '.venv', 'venv', '.tox', '.nox', '.eggs', '*.egg-info',\n \n // Build outputs\n 'dist', 'build', 'out', 'output', 'target', '_build',\n '.next', '.nuxt', '.output', '.vercel', '.netlify',\n \n // Cache directories\n '.cache', '.parcel-cache', '.turbo', '.nx', '.gradle',\n \n // IDE/Editor\n '.idea', '.vscode', '.vs',\n \n // Coverage\n 'coverage', '.coverage', 'htmlcov', '.nyc_output',\n \n // Temporary\n 'tmp', 'temp', '.tmp', '.temp',\n \n // Lock files\n 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb',\n 'Cargo.lock', 'Gemfile.lock', 'poetry.lock',\n \n // Binary/minified\n '*.min.js', '*.min.css', '*.bundle.js',\n '*.wasm', '*.so', '*.dll', '*.pyc',\n '*.map', '*.js.map',\n \n // Hidden directories catch-all\n '.*',\n];\n\nexport const DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || '')\n .split(',')\n .map(s => s.trim())\n .filter(Boolean)\n .concat(BUILTIN_EXCLUDES);\n\nexport const DEFAULT_MODEL = 'morph-warp-grep';\n\n\n"],"mappings":";AAEO,IAAM,eAAe;AAAA;AAAA,EAE1B,YAAY;AAAA,EACZ,YAAY;AACd;AAMA,IAAM,mBAAmB;AAAA;AAAA,EAEvB;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAO;AAAA;AAAA,EAGvB;AAAA,EAAgB;AAAA,EAAoB;AAAA,EAAS;AAAA,EAC7C;AAAA,EAAU;AAAA,EAAY;AAAA,EAAQ;AAAA;AAAA,EAG9B;AAAA,EAAe;AAAA,EAAiB;AAAA,EAAe;AAAA,EAC/C;AAAA,EAAS;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAS;AAAA;AAAA,EAG1C;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAO;AAAA,EAAU;AAAA,EAAU;AAAA,EAC5C;AAAA,EAAS;AAAA,EAAS;AAAA,EAAW;AAAA,EAAW;AAAA;AAAA,EAGxC;AAAA,EAAU;AAAA,EAAiB;AAAA,EAAU;AAAA,EAAO;AAAA;AAAA,EAG5C;AAAA,EAAS;AAAA,EAAW;AAAA;AAAA,EAGpB;AAAA,EAAY;AAAA,EAAa;AAAA,EAAW;AAAA;AAAA,EAGpC;AAAA,EAAO;AAAA,EAAQ;AAAA,EAAQ;AAAA;AAAA,EAGvB;AAAA,EAAqB;AAAA,EAAa;AAAA,EAAkB;AAAA,EACpD;AAAA,EAAc;AAAA,EAAgB;AAAA;AAAA,EAG9B;AAAA,EAAY;AAAA,EAAa;AAAA,EACzB;AAAA,EAAU;AAAA,EAAQ;AAAA,EAAS;AAAA,EAC3B;AAAA,EAAS;AAAA;AAAA,EAGT;AACF;AAEO,IAAM,oBAAoB,QAAQ,IAAI,2BAA2B,IACrE,MAAM,GAAG,EACT,IAAI,OAAK,EAAE,KAAK,CAAC,EACjB,OAAO,OAAO,EACd,OAAO,gBAAgB;AAEnB,IAAM,gBAAgB;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CODEBASE_SEARCH_DESCRIPTION
|
|
3
|
-
} from "./chunk-YQMPVJ2L.js";
|
|
4
1
|
import {
|
|
5
2
|
executeCodebaseSearch
|
|
6
3
|
} from "./chunk-WM77HRKO.js";
|
|
4
|
+
import {
|
|
5
|
+
CODEBASE_SEARCH_DESCRIPTION
|
|
6
|
+
} from "./chunk-YQMPVJ2L.js";
|
|
7
7
|
|
|
8
8
|
// tools/codebase_search/vercel.ts
|
|
9
9
|
import { tool } from "ai";
|
|
@@ -55,4 +55,4 @@ export {
|
|
|
55
55
|
getSystemPrompt,
|
|
56
56
|
vercel_default
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-UBX7QYBD.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
executeEditFile
|
|
3
|
+
} from "./chunk-64PMM72R.js";
|
|
1
4
|
import {
|
|
2
5
|
EDIT_FILE_SYSTEM_PROMPT,
|
|
3
6
|
EDIT_FILE_TOOL_DESCRIPTION
|
|
4
7
|
} from "./chunk-63WE2C5R.js";
|
|
5
|
-
import {
|
|
6
|
-
executeEditFile
|
|
7
|
-
} from "./chunk-64PMM72R.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -86,4 +86,4 @@ export {
|
|
|
86
86
|
vercel_default,
|
|
87
87
|
vercel_exports
|
|
88
88
|
};
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
89
|
+
//# sourceMappingURL=chunk-UIZT3KVJ.js.map
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-RSLIOCOE.js";
|
|
13
13
|
import {
|
|
14
14
|
DEFAULT_EXCLUDES
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-TJIUA27P.js";
|
|
16
16
|
|
|
17
17
|
// tools/warp_grep/providers/local.ts
|
|
18
18
|
import fs from "fs/promises";
|
|
@@ -132,4 +132,4 @@ var LocalRipgrepProvider = class {
|
|
|
132
132
|
export {
|
|
133
133
|
LocalRipgrepProvider
|
|
134
134
|
};
|
|
135
|
-
//# sourceMappingURL=chunk-
|
|
135
|
+
//# sourceMappingURL=chunk-UXYK7WZX.js.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// tools/warp_grep/agent/prompt.ts
|
|
2
|
+
var SYSTEM_PROMPT = `You are a code search agent. Your task is to find all relevant code for a given query.
|
|
3
|
+
|
|
4
|
+
<workflow>
|
|
5
|
+
You have exactly 4 turns. The 4th turn MUST be a \`finish\` call. Each turn allows up to 8 parallel tool calls.
|
|
6
|
+
|
|
7
|
+
- Turn 1: Map the territory OR dive deep (based on query specificity)
|
|
8
|
+
- Turn 2-3: Refine based on findings
|
|
9
|
+
- Turn 4: MUST call \`finish\` with all relevant code locations
|
|
10
|
+
- You MAY call \`finish\` early if confident\u2014but never before at least 1 search turn.
|
|
11
|
+
|
|
12
|
+
Remember, if the task feels easy to you, it is strongly desirable to call \`finish\` early using fewer turns, but quality over speed.
|
|
13
|
+
</workflow>
|
|
14
|
+
|
|
15
|
+
<tools>
|
|
16
|
+
### \`analyse <path> [pattern]\`
|
|
17
|
+
Directory tree or file search. Shows structure of a path, optionally filtered by regex pattern.
|
|
18
|
+
- \`path\`: Required. Directory or file path (use \`.\` for repo root)
|
|
19
|
+
- \`pattern\`: Optional regex to filter results
|
|
20
|
+
|
|
21
|
+
Examples:
|
|
22
|
+
\`\`\`
|
|
23
|
+
analyse .
|
|
24
|
+
analyse src/api
|
|
25
|
+
analyse . ".*\\.ts$"
|
|
26
|
+
analyse src "test.*"
|
|
27
|
+
\`\`\`
|
|
28
|
+
|
|
29
|
+
### \`read <path>[:start-end]\`
|
|
30
|
+
Read file contents. Line range is 1-based, inclusive.
|
|
31
|
+
- Returns numbered lines for easy reference
|
|
32
|
+
- Omit range to read entire file
|
|
33
|
+
|
|
34
|
+
Examples:
|
|
35
|
+
\`\`\`
|
|
36
|
+
read src/main.py
|
|
37
|
+
read src/db/conn.py:10-50
|
|
38
|
+
read package.json:1-20
|
|
39
|
+
\`\`\`
|
|
40
|
+
|
|
41
|
+
### \`grep '<pattern>' <path>\`
|
|
42
|
+
Ripgrep search. Finds pattern matches across files.
|
|
43
|
+
- \`'<pattern>'\`: Required. Regex pattern wrapped in single quotes
|
|
44
|
+
- \`<path>\`: Required. Directory or file to search (use \`.\` for repo root)
|
|
45
|
+
|
|
46
|
+
Examples:
|
|
47
|
+
\`\`\`
|
|
48
|
+
grep 'class.*Service' src/
|
|
49
|
+
grep 'def authenticate' .
|
|
50
|
+
grep 'import.*from' src/components/
|
|
51
|
+
grep 'TODO' .
|
|
52
|
+
\`\`\`
|
|
53
|
+
|
|
54
|
+
### \`finish <file1:ranges> [file2:ranges ...]\`
|
|
55
|
+
Submit final answer with all relevant code locations.
|
|
56
|
+
- Include generous line ranges\u2014don't be stingy with context
|
|
57
|
+
- Ranges are comma-separated: \`file.py:10-30,50-60\`
|
|
58
|
+
- ALWAYS include import statements at the top of files (usually lines 1-20)
|
|
59
|
+
- If code spans multiple files, include ALL of them
|
|
60
|
+
- Small files can be returned in full
|
|
61
|
+
|
|
62
|
+
Examples:
|
|
63
|
+
\`\`\`
|
|
64
|
+
finish src/auth.py:1-15,25-50,75-80 src/models/user.py:1-10,20-45
|
|
65
|
+
finish src/index.ts:1-100
|
|
66
|
+
\`\`\`
|
|
67
|
+
</tools>
|
|
68
|
+
|
|
69
|
+
<strategy>
|
|
70
|
+
**Before your first tool call, classify the query:**
|
|
71
|
+
|
|
72
|
+
| Query Type | Turn 1 Strategy | Early Finish? |
|
|
73
|
+
|------------|-----------------|---------------|
|
|
74
|
+
| **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by turn 2 |
|
|
75
|
+
| **Conceptual** (how does X work, where is Y handled) | analyse + 2-3 broad greps | Rarely early |
|
|
76
|
+
| **Exploratory** (find all tests, list API endpoints) | analyse at multiple depths | Usually needs 3 turns |
|
|
77
|
+
|
|
78
|
+
**Parallel call patterns:**
|
|
79
|
+
- **Shotgun grep**: Same pattern, 8 different directories\u2014fast coverage
|
|
80
|
+
- **Variant grep**: 8 pattern variations (synonyms, naming conventions)\u2014catches inconsistent codebases
|
|
81
|
+
- **Funnel**: 1 analyse + 7 greps\u2014orient and search simultaneously
|
|
82
|
+
- **Deep read**: 8 reads on files you already identified\u2014gather full context fast
|
|
83
|
+
</strategy>
|
|
84
|
+
|
|
85
|
+
<output_format>
|
|
86
|
+
EVERY response MUST follow this exact format:
|
|
87
|
+
|
|
88
|
+
1. First, wrap your reasoning in \`<think>...</think>\` tags containing:
|
|
89
|
+
- Query classification (specific/conceptual/exploratory)
|
|
90
|
+
- Confidence estimate (can I finish in 1-2 turns?)
|
|
91
|
+
- This turn's parallel strategy
|
|
92
|
+
- What signals would let me finish early?
|
|
93
|
+
|
|
94
|
+
2. Then, output tool calls wrapped in \`<tool_call>...</tool_call>\` tags, one per line.
|
|
95
|
+
|
|
96
|
+
Example:
|
|
97
|
+
\`\`\`
|
|
98
|
+
<think>
|
|
99
|
+
This is a specific query about authentication. I'll grep for auth-related patterns.
|
|
100
|
+
High confidence I can finish in 2 turns if I find the auth module.
|
|
101
|
+
Strategy: Shotgun grep across likely directories.
|
|
102
|
+
</think>
|
|
103
|
+
<tool_call>grep 'authenticate' src/</tool_call>
|
|
104
|
+
<tool_call>grep 'login' src/</tool_call>
|
|
105
|
+
<tool_call>analyse src/auth</tool_call>
|
|
106
|
+
\`\`\`
|
|
107
|
+
|
|
108
|
+
No commentary outside \`<think>\`. No explanations after tool calls.
|
|
109
|
+
</output_format>
|
|
110
|
+
|
|
111
|
+
<finishing_requirements>
|
|
112
|
+
When calling \`finish\`:
|
|
113
|
+
- Include the import section (typically lines 1-20) of each file
|
|
114
|
+
- Include all function/class definitions that are relevant
|
|
115
|
+
- Include any type definitions, interfaces, or constants used
|
|
116
|
+
- Better to over-include than leave the user missing context
|
|
117
|
+
- If unsure about boundaries, include more rather than less
|
|
118
|
+
</finishing_requirements>
|
|
119
|
+
|
|
120
|
+
Begin your exploration now to find code relevant to the query.`;
|
|
121
|
+
function getSystemPrompt() {
|
|
122
|
+
return SYSTEM_PROMPT;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
SYSTEM_PROMPT,
|
|
127
|
+
getSystemPrompt
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=chunk-WETRQJGU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/agent/prompt.ts"],"sourcesContent":["export const SYSTEM_PROMPT = `You are a code search agent. Your task is to find all relevant code for a given query.\n\n<workflow>\nYou have exactly 4 turns. The 4th turn MUST be a \\`finish\\` call. Each turn allows up to 8 parallel tool calls.\n\n- Turn 1: Map the territory OR dive deep (based on query specificity)\n- Turn 2-3: Refine based on findings\n- Turn 4: MUST call \\`finish\\` with all relevant code locations\n- You MAY call \\`finish\\` early if confident—but never before at least 1 search turn.\n\nRemember, if the task feels easy to you, it is strongly desirable to call \\`finish\\` early using fewer turns, but quality over speed.\n</workflow>\n\n<tools>\n### \\`analyse <path> [pattern]\\`\nDirectory tree or file search. Shows structure of a path, optionally filtered by regex pattern.\n- \\`path\\`: Required. Directory or file path (use \\`.\\` for repo root)\n- \\`pattern\\`: Optional regex to filter results\n\nExamples:\n\\`\\`\\`\nanalyse .\nanalyse src/api\nanalyse . \".*\\\\.ts$\"\nanalyse src \"test.*\"\n\\`\\`\\`\n\n### \\`read <path>[:start-end]\\`\nRead file contents. Line range is 1-based, inclusive.\n- Returns numbered lines for easy reference\n- Omit range to read entire file\n\nExamples:\n\\`\\`\\`\nread src/main.py\nread src/db/conn.py:10-50\nread package.json:1-20\n\\`\\`\\`\n\n### \\`grep '<pattern>' <path>\\`\nRipgrep search. Finds pattern matches across files.\n- \\`'<pattern>'\\`: Required. Regex pattern wrapped in single quotes\n- \\`<path>\\`: Required. Directory or file to search (use \\`.\\` for repo root)\n\nExamples:\n\\`\\`\\`\ngrep 'class.*Service' src/\ngrep 'def authenticate' .\ngrep 'import.*from' src/components/\ngrep 'TODO' .\n\\`\\`\\`\n\n### \\`finish <file1:ranges> [file2:ranges ...]\\`\nSubmit final answer with all relevant code locations.\n- Include generous line ranges—don't be stingy with context\n- Ranges are comma-separated: \\`file.py:10-30,50-60\\`\n- ALWAYS include import statements at the top of files (usually lines 1-20)\n- If code spans multiple files, include ALL of them\n- Small files can be returned in full\n\nExamples:\n\\`\\`\\`\nfinish src/auth.py:1-15,25-50,75-80 src/models/user.py:1-10,20-45\nfinish src/index.ts:1-100\n\\`\\`\\`\n</tools>\n\n<strategy>\n**Before your first tool call, classify the query:**\n\n| Query Type | Turn 1 Strategy | Early Finish? |\n|------------|-----------------|---------------|\n| **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by turn 2 |\n| **Conceptual** (how does X work, where is Y handled) | analyse + 2-3 broad greps | Rarely early |\n| **Exploratory** (find all tests, list API endpoints) | analyse at multiple depths | Usually needs 3 turns |\n\n**Parallel call patterns:**\n- **Shotgun grep**: Same pattern, 8 different directories—fast coverage\n- **Variant grep**: 8 pattern variations (synonyms, naming conventions)—catches inconsistent codebases\n- **Funnel**: 1 analyse + 7 greps—orient and search simultaneously\n- **Deep read**: 8 reads on files you already identified—gather full context fast\n</strategy>\n\n<output_format>\nEVERY response MUST follow this exact format:\n\n1. First, wrap your reasoning in \\`<think>...</think>\\` tags containing:\n - Query classification (specific/conceptual/exploratory)\n - Confidence estimate (can I finish in 1-2 turns?)\n - This turn's parallel strategy\n - What signals would let me finish early?\n\n2. Then, output tool calls wrapped in \\`<tool_call>...</tool_call>\\` tags, one per line.\n\nExample:\n\\`\\`\\`\n<think>\nThis is a specific query about authentication. I'll grep for auth-related patterns.\nHigh confidence I can finish in 2 turns if I find the auth module.\nStrategy: Shotgun grep across likely directories.\n</think>\n<tool_call>grep 'authenticate' src/</tool_call>\n<tool_call>grep 'login' src/</tool_call>\n<tool_call>analyse src/auth</tool_call>\n\\`\\`\\`\n\nNo commentary outside \\`<think>\\`. No explanations after tool calls.\n</output_format>\n\n<finishing_requirements>\nWhen calling \\`finish\\`:\n- Include the import section (typically lines 1-20) of each file\n- Include all function/class definitions that are relevant\n- Include any type definitions, interfaces, or constants used\n- Better to over-include than leave the user missing context\n- If unsure about boundaries, include more rather than less\n</finishing_requirements>\n\nBegin your exploration now to find code relevant to the query.`;\n\nexport function getSystemPrompt(): string {\n\treturn SYSTEM_PROMPT;\n}\n"],"mappings":";AAAO,IAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwHtB,SAAS,kBAA0B;AACzC,SAAO;AACR;","names":[]}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { RetryConfig } from './tools/utils/resilience.js';
|
|
2
|
+
import { FastApplyClient } from './tools/fastapply/core.js';
|
|
3
|
+
import { CodebaseSearchClient } from './tools/codebase_search/core.js';
|
|
4
|
+
import { BrowserClient } from './tools/browser/core.js';
|
|
5
|
+
import { e as WarpGrepToolConfig, c as WarpGrepResult, d as WarpGrepContext, W as WarpGrepClient } from './core-DxiUwyBe.js';
|
|
6
|
+
import { MorphGit } from './git/client.js';
|
|
7
|
+
import { OpenAIRouter, AnthropicRouter, GeminiRouter, RawRouter } from './modelrouter/core.js';
|
|
8
|
+
import { EditFileConfig, EditFileInput, EditFileResult, EditChanges } from './tools/fastapply/types.js';
|
|
9
|
+
import { CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult } from './tools/codebase_search/types.js';
|
|
10
|
+
import * as openai_resources_index_mjs from 'openai/resources/index.mjs';
|
|
11
|
+
import * as _anthropic_ai_sdk_resources_messages_mjs from '@anthropic-ai/sdk/resources/messages.mjs';
|
|
12
|
+
import * as ai from 'ai';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Factory for creating OpenAI-compatible tools with inherited API key
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
|
|
20
|
+
*
|
|
21
|
+
* const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });
|
|
22
|
+
* const searchTool = morph.openai.createCodebaseSearchTool({ repoId: 'my-project' });
|
|
23
|
+
* const editTool = morph.openai.createEditFileTool({ baseDir: './src' });
|
|
24
|
+
*
|
|
25
|
+
* // Use with OpenAI client
|
|
26
|
+
* const response = await openai.chat.completions.create({
|
|
27
|
+
* model: 'gpt-4o',
|
|
28
|
+
* tools: [grepTool, searchTool, editTool],
|
|
29
|
+
* messages: [{ role: 'user', content: 'Find and fix the bug' }]
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare class OpenAIToolFactory {
|
|
34
|
+
private config;
|
|
35
|
+
constructor(config: MorphClientConfig);
|
|
36
|
+
/**
|
|
37
|
+
* Create an OpenAI-compatible warp grep tool
|
|
38
|
+
*
|
|
39
|
+
* @param toolConfig - Tool configuration (apiKey inherited from MorphClient)
|
|
40
|
+
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
41
|
+
*/
|
|
42
|
+
createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'apiKey'>): openai_resources_index_mjs.ChatCompletionTool & {
|
|
43
|
+
execute: (input: unknown) => Promise<WarpGrepResult>;
|
|
44
|
+
formatResult: (result: WarpGrepResult) => string;
|
|
45
|
+
getSystemPrompt: () => string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Create an OpenAI-compatible codebase search tool
|
|
49
|
+
*
|
|
50
|
+
* @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
|
|
51
|
+
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
52
|
+
*/
|
|
53
|
+
createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>): openai_resources_index_mjs.ChatCompletionTool & {
|
|
54
|
+
execute: (input: CodebaseSearchInput | string) => Promise<CodebaseSearchResult>;
|
|
55
|
+
formatResult: (result: CodebaseSearchResult) => string;
|
|
56
|
+
getSystemPrompt: () => string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Create an OpenAI-compatible edit file tool
|
|
60
|
+
*
|
|
61
|
+
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
62
|
+
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
63
|
+
*/
|
|
64
|
+
createEditFileTool(toolConfig?: Omit<EditFileConfig, 'morphApiKey'>): openai_resources_index_mjs.ChatCompletionTool & {
|
|
65
|
+
execute: (input: EditFileInput | string) => Promise<EditFileResult>;
|
|
66
|
+
formatResult: (result: EditFileResult) => string;
|
|
67
|
+
getSystemPrompt: () => string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Factory for creating Anthropic-compatible tools with inherited API key
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
|
|
77
|
+
*
|
|
78
|
+
* const grepTool = morph.anthropic.createWarpGrepTool({ repoRoot: '.' });
|
|
79
|
+
* const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'my-project' });
|
|
80
|
+
* const editTool = morph.anthropic.createEditFileTool({ baseDir: './src' });
|
|
81
|
+
*
|
|
82
|
+
* // Use with Anthropic client
|
|
83
|
+
* const response = await anthropic.messages.create({
|
|
84
|
+
* model: 'claude-sonnet-4-5-20250929',
|
|
85
|
+
* tools: [grepTool, searchTool, editTool],
|
|
86
|
+
* messages: [{ role: 'user', content: 'Find and fix the bug' }]
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare class AnthropicToolFactory {
|
|
91
|
+
private config;
|
|
92
|
+
constructor(config: MorphClientConfig);
|
|
93
|
+
/**
|
|
94
|
+
* Create an Anthropic-compatible warp grep tool
|
|
95
|
+
*
|
|
96
|
+
* @param toolConfig - Tool configuration (apiKey inherited from MorphClient)
|
|
97
|
+
* @returns Anthropic Tool with execute and formatResult methods
|
|
98
|
+
*/
|
|
99
|
+
createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'apiKey'>): _anthropic_ai_sdk_resources_messages_mjs.Tool & {
|
|
100
|
+
execute: (input: unknown) => Promise<WarpGrepResult>;
|
|
101
|
+
formatResult: (result: WarpGrepResult) => string;
|
|
102
|
+
getSystemPrompt: () => string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Create an Anthropic-compatible codebase search tool
|
|
106
|
+
*
|
|
107
|
+
* @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
|
|
108
|
+
* @returns Anthropic Tool with execute and formatResult methods
|
|
109
|
+
*/
|
|
110
|
+
createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>): _anthropic_ai_sdk_resources_messages_mjs.Tool & {
|
|
111
|
+
execute: (input: CodebaseSearchInput) => Promise<CodebaseSearchResult>;
|
|
112
|
+
formatResult: (result: CodebaseSearchResult) => string;
|
|
113
|
+
getSystemPrompt: () => string;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Create an Anthropic-compatible edit file tool
|
|
117
|
+
*
|
|
118
|
+
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
119
|
+
* @returns Anthropic Tool with execute and formatResult methods
|
|
120
|
+
*/
|
|
121
|
+
createEditFileTool(toolConfig?: Omit<EditFileConfig, 'morphApiKey'>): _anthropic_ai_sdk_resources_messages_mjs.Tool & {
|
|
122
|
+
execute: (input: EditFileInput) => Promise<EditFileResult>;
|
|
123
|
+
formatResult: (result: EditFileResult) => string;
|
|
124
|
+
getSystemPrompt: () => string;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Factory for creating Vercel AI SDK-compatible tools with inherited API key
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
|
|
134
|
+
*
|
|
135
|
+
* const grepTool = morph.vercel.createWarpGrepTool({ repoRoot: '.' });
|
|
136
|
+
* const searchTool = morph.vercel.createCodebaseSearchTool({ repoId: 'my-project' });
|
|
137
|
+
* const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });
|
|
138
|
+
*
|
|
139
|
+
* // Use with Vercel AI SDK
|
|
140
|
+
* const result = await generateText({
|
|
141
|
+
* model: anthropic('claude-sonnet-4-5-20250929'),
|
|
142
|
+
* tools: { grep: grepTool, search: searchTool, edit: editTool },
|
|
143
|
+
* prompt: 'Find and fix the bug'
|
|
144
|
+
* });
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare class VercelToolFactory {
|
|
148
|
+
private config;
|
|
149
|
+
constructor(config: MorphClientConfig);
|
|
150
|
+
/**
|
|
151
|
+
* Create a Vercel AI SDK-compatible warp grep tool
|
|
152
|
+
*
|
|
153
|
+
* @param toolConfig - Tool configuration (apiKey inherited from MorphClient)
|
|
154
|
+
* @returns Vercel AI SDK tool
|
|
155
|
+
*/
|
|
156
|
+
createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'apiKey'>): ai.Tool<{
|
|
157
|
+
query: string;
|
|
158
|
+
}, {
|
|
159
|
+
success: boolean;
|
|
160
|
+
error: string;
|
|
161
|
+
contexts?: undefined;
|
|
162
|
+
summary?: undefined;
|
|
163
|
+
} | {
|
|
164
|
+
success: boolean;
|
|
165
|
+
contexts: WarpGrepContext[];
|
|
166
|
+
summary: string;
|
|
167
|
+
error?: undefined;
|
|
168
|
+
}>;
|
|
169
|
+
/**
|
|
170
|
+
* Create a Vercel AI SDK-compatible codebase search tool
|
|
171
|
+
*
|
|
172
|
+
* @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
|
|
173
|
+
* @returns Vercel AI SDK tool
|
|
174
|
+
*/
|
|
175
|
+
createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>): ai.Tool<{
|
|
176
|
+
query: string;
|
|
177
|
+
target_directories: string[];
|
|
178
|
+
explanation: string;
|
|
179
|
+
limit?: number | undefined;
|
|
180
|
+
}, {
|
|
181
|
+
error: string | undefined;
|
|
182
|
+
results: never[];
|
|
183
|
+
found?: undefined;
|
|
184
|
+
searchTime?: undefined;
|
|
185
|
+
} | {
|
|
186
|
+
found: number;
|
|
187
|
+
searchTime: string;
|
|
188
|
+
results: {
|
|
189
|
+
file: string;
|
|
190
|
+
symbol: string;
|
|
191
|
+
lines: string;
|
|
192
|
+
language: string;
|
|
193
|
+
relevance: string;
|
|
194
|
+
code: string;
|
|
195
|
+
}[];
|
|
196
|
+
error?: undefined;
|
|
197
|
+
}>;
|
|
198
|
+
/**
|
|
199
|
+
* Create a Vercel AI SDK-compatible edit file tool
|
|
200
|
+
*
|
|
201
|
+
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
202
|
+
* @returns Vercel AI SDK tool
|
|
203
|
+
*/
|
|
204
|
+
createEditFileTool(toolConfig?: Omit<EditFileConfig, 'morphApiKey'>): ai.Tool<{
|
|
205
|
+
target_filepath: string;
|
|
206
|
+
instructions: string;
|
|
207
|
+
code_edit: string;
|
|
208
|
+
}, {
|
|
209
|
+
success: boolean;
|
|
210
|
+
filepath: string;
|
|
211
|
+
changes: EditChanges;
|
|
212
|
+
udiff: string | undefined;
|
|
213
|
+
}>;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Unified Morph SDK Client
|
|
218
|
+
*
|
|
219
|
+
* Provides access to all Morph tools through a single interface
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* import { MorphClient } from '@morphllm/morphsdk';
|
|
224
|
+
*
|
|
225
|
+
* const morph = new MorphClient({
|
|
226
|
+
* apiKey: process.env.MORPH_API_KEY,
|
|
227
|
+
* debug: true,
|
|
228
|
+
* timeout: 60000
|
|
229
|
+
* });
|
|
230
|
+
*
|
|
231
|
+
* // Direct execution
|
|
232
|
+
* await morph.fastApply.execute({ target_filepath: 'src/index.ts', ... });
|
|
233
|
+
* await morph.warpGrep.execute({ query: 'Find auth', repoRoot: '.' });
|
|
234
|
+
* await morph.codebaseSearch.search({ query: 'auth logic', repoId: 'x' });
|
|
235
|
+
*
|
|
236
|
+
* // Tool creation for AI agents (API key inherited)
|
|
237
|
+
* const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });
|
|
238
|
+
* const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'x' });
|
|
239
|
+
* const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });
|
|
240
|
+
*
|
|
241
|
+
* // Use tools with OpenAI
|
|
242
|
+
* const response = await openai.chat.completions.create({
|
|
243
|
+
* model: 'gpt-4o',
|
|
244
|
+
* tools: [grepTool],
|
|
245
|
+
* messages: [{ role: 'user', content: 'Find the bug' }]
|
|
246
|
+
* });
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Configuration for the MorphClient
|
|
252
|
+
*/
|
|
253
|
+
interface MorphClientConfig {
|
|
254
|
+
/** Morph API key for authentication (defaults to MORPH_API_KEY env var) */
|
|
255
|
+
apiKey?: string;
|
|
256
|
+
/** Enable debug logging across all tools */
|
|
257
|
+
debug?: boolean;
|
|
258
|
+
/** Default timeout in milliseconds for API requests */
|
|
259
|
+
timeout?: number;
|
|
260
|
+
/** Retry configuration for failed requests */
|
|
261
|
+
retryConfig?: RetryConfig;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Unified Morph SDK Client
|
|
265
|
+
*
|
|
266
|
+
* Provides access to all Morph tools through a single interface:
|
|
267
|
+
* - fastApply: AI-powered file editing with intelligent merging
|
|
268
|
+
* - codebaseSearch: Semantic code search
|
|
269
|
+
* - warpGrep: Fast code search with ripgrep
|
|
270
|
+
* - browser: AI-powered browser automation
|
|
271
|
+
* - git: Version control operations
|
|
272
|
+
* - routers: Intelligent model selection (OpenAI, Anthropic, Gemini)
|
|
273
|
+
* - openai/anthropic/vercel: Tool factories for agent frameworks
|
|
274
|
+
*/
|
|
275
|
+
declare class MorphClient {
|
|
276
|
+
/** Client configuration */
|
|
277
|
+
config: MorphClientConfig;
|
|
278
|
+
/** FastApply tool for editing files with AI-powered merge */
|
|
279
|
+
fastApply: FastApplyClient;
|
|
280
|
+
/** CodebaseSearch tool for semantic code search */
|
|
281
|
+
codebaseSearch: CodebaseSearchClient;
|
|
282
|
+
/** WarpGrep tool for fast code search using ripgrep */
|
|
283
|
+
warpGrep: WarpGrepClient;
|
|
284
|
+
/** Browser tool for AI-powered browser automation */
|
|
285
|
+
browser: BrowserClient;
|
|
286
|
+
/** Git tool for version control operations */
|
|
287
|
+
git: MorphGit;
|
|
288
|
+
/** Model routers for intelligent model selection */
|
|
289
|
+
routers: {
|
|
290
|
+
openai: OpenAIRouter;
|
|
291
|
+
anthropic: AnthropicRouter;
|
|
292
|
+
gemini: GeminiRouter;
|
|
293
|
+
raw: RawRouter;
|
|
294
|
+
};
|
|
295
|
+
/** OpenAI-compatible tool factories */
|
|
296
|
+
openai: OpenAIToolFactory;
|
|
297
|
+
/** Anthropic-compatible tool factories */
|
|
298
|
+
anthropic: AnthropicToolFactory;
|
|
299
|
+
/** Vercel AI SDK tool factories */
|
|
300
|
+
vercel: VercelToolFactory;
|
|
301
|
+
/**
|
|
302
|
+
* Create a new Morph SDK client
|
|
303
|
+
*
|
|
304
|
+
* @param config - Client configuration (apiKey, debug, timeout, retryConfig)
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```typescript
|
|
308
|
+
* const morph = new MorphClient({
|
|
309
|
+
* apiKey: process.env.MORPH_API_KEY,
|
|
310
|
+
* debug: true,
|
|
311
|
+
* timeout: 60000
|
|
312
|
+
* });
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
constructor(config?: MorphClientConfig);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export { AnthropicToolFactory as A, MorphClient as M, OpenAIToolFactory as O, VercelToolFactory as V, type MorphClientConfig as a };
|