@morphllm/morphsdk 0.2.153 → 0.2.155
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-MJQNHIUZ.js → chunk-372QEHFA.js} +2 -2
- package/dist/{chunk-QMLGJK66.js → chunk-3ULQXPPO.js} +2 -2
- package/dist/{chunk-UFPDHAZ2.js → chunk-AEYK5XL5.js} +2 -2
- package/dist/{chunk-7IQMKVT4.js → chunk-CNKSTKRM.js} +2 -2
- package/dist/{chunk-ZAADJ3ER.js → chunk-CZ2LZ4GV.js} +4 -3
- package/dist/{chunk-ZAADJ3ER.js.map → chunk-CZ2LZ4GV.js.map} +1 -1
- package/dist/{chunk-H6RMMTKF.js → chunk-D34NUQGV.js} +2 -2
- package/dist/{chunk-NO2FGIQ7.js → chunk-DQJBEM4O.js} +2 -2
- package/dist/{chunk-NO2FGIQ7.js.map → chunk-DQJBEM4O.js.map} +1 -1
- package/dist/chunk-GLQWEINZ.js +53 -0
- package/dist/chunk-GLQWEINZ.js.map +1 -0
- package/dist/{chunk-GKBKSSUA.js → chunk-GOKSI67V.js} +2 -2
- package/dist/{chunk-QFRDNJXM.js → chunk-GPK433QG.js} +3 -3
- package/dist/{chunk-WTMEO2YB.js → chunk-GZXWWB4Z.js} +2 -2
- package/dist/{chunk-Q4DXGXXU.js → chunk-KQR3VCGR.js} +2 -2
- package/dist/{chunk-JB4T3K5T.js → chunk-L4GXXQEO.js} +2 -2
- package/dist/{chunk-QDDT5L5Y.js → chunk-MBVOMNXG.js} +2 -2
- package/dist/{chunk-KM7RICB6.js → chunk-NMBM37CB.js} +3 -2
- package/dist/{chunk-KM7RICB6.js.map → chunk-NMBM37CB.js.map} +1 -1
- package/dist/{chunk-5D7DDSZQ.js → chunk-Q3HZGVQ2.js} +2 -2
- package/dist/{chunk-AGFVQOGJ.js → chunk-SCVWDNQP.js} +2 -2
- package/dist/chunk-SCVWDNQP.js.map +1 -0
- package/dist/{chunk-6FRGRPUO.js → chunk-TZCNMJHF.js} +2 -2
- package/dist/{chunk-GAZCVVNY.js → chunk-V2BUYOKP.js} +2 -2
- package/dist/{chunk-QVWKDO76.js → chunk-Y23PQQRM.js} +20 -20
- package/dist/{chunk-FWHQH6RG.js → chunk-Y3LQWQHU.js} +4 -4
- package/dist/chunk-Y3LQWQHU.js.map +1 -0
- package/dist/{chunk-MFKR5VVL.js → chunk-YCUX3ZNQ.js} +17 -16
- package/dist/chunk-YCUX3ZNQ.js.map +1 -0
- package/dist/{chunk-77O2YF4B.js → chunk-YIUOPGWE.js} +2 -2
- package/dist/{chunk-3VMW3UJY.js → chunk-YJEXFOLJ.js} +4 -4
- package/dist/chunk-YJEXFOLJ.js.map +1 -0
- package/dist/{chunk-YBVAKGFE.js → chunk-YRHDWJDA.js} +2 -2
- package/dist/{chunk-I3ZPXGMZ.js → chunk-YYOPTKC3.js} +2 -2
- package/dist/{chunk-7AWNEVBE.js → chunk-ZMGKZNII.js} +6 -6
- package/dist/chunk-ZMGKZNII.js.map +1 -0
- package/dist/{client-BcO_qte8.d.ts → client-PkB7g9SA.d.ts} +1 -1
- package/dist/client.cjs +152 -107
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +24 -23
- package/dist/edge.cjs +4 -3
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +7 -7
- package/dist/index.cjs +152 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -25
- package/dist/modelrouter/core.cjs +1 -1
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +3 -3
- package/dist/modelrouter/index.cjs +1 -1
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +3 -3
- package/dist/subagents/anthropic.cjs +138 -15
- package/dist/subagents/anthropic.cjs.map +1 -1
- package/dist/subagents/anthropic.js +6 -4
- package/dist/subagents/vercel.cjs +138 -15
- package/dist/subagents/vercel.cjs.map +1 -1
- package/dist/subagents/vercel.js +6 -4
- package/dist/tools/browser/anthropic.cjs +1 -1
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +5 -5
- package/dist/tools/browser/core.cjs +1 -1
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +4 -4
- package/dist/tools/browser/index.cjs +1 -1
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +7 -7
- package/dist/tools/browser/openai.cjs +1 -1
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +5 -5
- package/dist/tools/browser/profiles/core.cjs +1 -1
- package/dist/tools/browser/profiles/core.cjs.map +1 -1
- package/dist/tools/browser/profiles/core.js +3 -3
- package/dist/tools/browser/profiles/index.cjs +1 -1
- package/dist/tools/browser/profiles/index.cjs.map +1 -1
- package/dist/tools/browser/profiles/index.js +3 -3
- package/dist/tools/browser/vercel.cjs +1 -1
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +5 -5
- package/dist/tools/codebase_search/anthropic.cjs +1 -1
- package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +4 -4
- package/dist/tools/codebase_search/core.cjs +1 -1
- package/dist/tools/codebase_search/core.cjs.map +1 -1
- package/dist/tools/codebase_search/core.js +3 -3
- package/dist/tools/codebase_search/index.cjs +1 -1
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.js +6 -6
- package/dist/tools/codebase_search/openai.cjs +1 -1
- package/dist/tools/codebase_search/openai.cjs.map +1 -1
- package/dist/tools/codebase_search/openai.js +4 -4
- package/dist/tools/codebase_search/vercel.cjs +1 -1
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +4 -4
- package/dist/tools/compact/core.cjs +1 -1
- package/dist/tools/compact/core.cjs.map +1 -1
- package/dist/tools/compact/core.js +1 -1
- package/dist/tools/compact/index.cjs +50 -3
- package/dist/tools/compact/index.cjs.map +1 -1
- package/dist/tools/compact/index.d.ts +10 -0
- package/dist/tools/compact/index.js +6 -2
- package/dist/tools/fastapply/anthropic.cjs +7 -5
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +4 -4
- package/dist/tools/fastapply/apply.cjs +3 -2
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +5 -3
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +3 -3
- package/dist/tools/fastapply/index.cjs +13 -11
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.d.ts +1 -1
- package/dist/tools/fastapply/index.js +6 -6
- package/dist/tools/fastapply/openai.cjs +7 -5
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +4 -4
- package/dist/tools/fastapply/types.cjs.map +1 -1
- package/dist/tools/fastapply/types.d.ts +6 -2
- package/dist/tools/fastapply/vercel.cjs +9 -7
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.d.ts +1 -1
- package/dist/tools/fastapply/vercel.js +4 -4
- package/dist/tools/index.cjs +13 -11
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +6 -6
- package/dist/tools/utils/resilience.cjs +1 -1
- package/dist/tools/utils/resilience.cjs.map +1 -1
- package/dist/tools/utils/resilience.js +2 -2
- package/dist/tools/warp_grep/agent/runner.cjs +1 -1
- 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/anthropic.cjs +138 -15
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +6 -4
- package/dist/tools/warp_grep/client.cjs +138 -15
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +5 -3
- package/dist/tools/warp_grep/gemini.cjs +138 -15
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.js +5 -3
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/index.cjs +138 -15
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.js +5 -3
- package/dist/tools/warp_grep/openai.cjs +138 -15
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +6 -4
- package/dist/tools/warp_grep/vercel.cjs +138 -15
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +6 -4
- package/dist/{vercel-B1GZ_g9N.d.ts → vercel-Cg38kNm4.d.ts} +2 -2
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3VMW3UJY.js.map +0 -1
- package/dist/chunk-7AWNEVBE.js.map +0 -1
- package/dist/chunk-AGFVQOGJ.js.map +0 -1
- package/dist/chunk-FWHQH6RG.js.map +0 -1
- package/dist/chunk-MFKR5VVL.js.map +0 -1
- /package/dist/{chunk-MJQNHIUZ.js.map → chunk-372QEHFA.js.map} +0 -0
- /package/dist/{chunk-QMLGJK66.js.map → chunk-3ULQXPPO.js.map} +0 -0
- /package/dist/{chunk-UFPDHAZ2.js.map → chunk-AEYK5XL5.js.map} +0 -0
- /package/dist/{chunk-7IQMKVT4.js.map → chunk-CNKSTKRM.js.map} +0 -0
- /package/dist/{chunk-H6RMMTKF.js.map → chunk-D34NUQGV.js.map} +0 -0
- /package/dist/{chunk-GKBKSSUA.js.map → chunk-GOKSI67V.js.map} +0 -0
- /package/dist/{chunk-QFRDNJXM.js.map → chunk-GPK433QG.js.map} +0 -0
- /package/dist/{chunk-WTMEO2YB.js.map → chunk-GZXWWB4Z.js.map} +0 -0
- /package/dist/{chunk-Q4DXGXXU.js.map → chunk-KQR3VCGR.js.map} +0 -0
- /package/dist/{chunk-JB4T3K5T.js.map → chunk-L4GXXQEO.js.map} +0 -0
- /package/dist/{chunk-QDDT5L5Y.js.map → chunk-MBVOMNXG.js.map} +0 -0
- /package/dist/{chunk-5D7DDSZQ.js.map → chunk-Q3HZGVQ2.js.map} +0 -0
- /package/dist/{chunk-6FRGRPUO.js.map → chunk-TZCNMJHF.js.map} +0 -0
- /package/dist/{chunk-GAZCVVNY.js.map → chunk-V2BUYOKP.js.map} +0 -0
- /package/dist/{chunk-QVWKDO76.js.map → chunk-Y23PQQRM.js.map} +0 -0
- /package/dist/{chunk-77O2YF4B.js.map → chunk-YIUOPGWE.js.map} +0 -0
- /package/dist/{chunk-YBVAKGFE.js.map → chunk-YRHDWJDA.js.map} +0 -0
- /package/dist/{chunk-I3ZPXGMZ.js.map → chunk-YYOPTKC3.js.map} +0 -0
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createGitHubSearchTool,
|
|
3
3
|
createWarpGrepTool
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-L4GXXQEO.js";
|
|
5
5
|
import {
|
|
6
6
|
createGitHubSearchTool as createGitHubSearchTool3,
|
|
7
7
|
createWarpGrepTool as createWarpGrepTool3
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-Q3HZGVQ2.js";
|
|
9
9
|
import {
|
|
10
10
|
createGitHubSearchTool as createGitHubSearchTool2,
|
|
11
11
|
createWarpGrepTool as createWarpGrepTool2
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-YIUOPGWE.js";
|
|
13
13
|
import {
|
|
14
14
|
createCodebaseSearchTool as createCodebaseSearchTool3
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-3ULQXPPO.js";
|
|
16
16
|
import {
|
|
17
17
|
createCodebaseSearchTool as createCodebaseSearchTool2
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-GOKSI67V.js";
|
|
19
19
|
import {
|
|
20
20
|
createCodebaseSearchTool
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-YYOPTKC3.js";
|
|
22
22
|
import {
|
|
23
23
|
CodebaseSearchClient
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-V2BUYOKP.js";
|
|
25
25
|
import {
|
|
26
26
|
createEditFileTool
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-YJEXFOLJ.js";
|
|
28
28
|
import {
|
|
29
29
|
createEditFileTool as createEditFileTool3
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-ZMGKZNII.js";
|
|
31
31
|
import {
|
|
32
32
|
createEditFileTool as createEditFileTool2
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-Y3LQWQHU.js";
|
|
34
34
|
import {
|
|
35
35
|
FastApplyClient
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-NMBM37CB.js";
|
|
37
37
|
import {
|
|
38
38
|
BrowserClient
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-GPK433QG.js";
|
|
40
40
|
import {
|
|
41
41
|
createExploreSubagent
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-D34NUQGV.js";
|
|
43
43
|
import {
|
|
44
44
|
createExploreSubagent as createExploreSubagent2
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-GZXWWB4Z.js";
|
|
46
46
|
import {
|
|
47
47
|
WarpGrepClient
|
|
48
|
-
} from "./chunk-
|
|
49
|
-
import {
|
|
50
|
-
CompactClient
|
|
51
|
-
} from "./chunk-AGFVQOGJ.js";
|
|
48
|
+
} from "./chunk-YCUX3ZNQ.js";
|
|
52
49
|
import {
|
|
53
50
|
AnthropicRouter,
|
|
54
51
|
GeminiRouter,
|
|
55
52
|
OpenAIRouter,
|
|
56
53
|
RawRouter
|
|
57
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-372QEHFA.js";
|
|
55
|
+
import {
|
|
56
|
+
CompactClient
|
|
57
|
+
} from "./chunk-SCVWDNQP.js";
|
|
58
58
|
import {
|
|
59
59
|
MorphGit
|
|
60
60
|
} from "./chunk-LE66XCOI.js";
|
|
@@ -724,4 +724,4 @@ export {
|
|
|
724
724
|
VercelToolFactory,
|
|
725
725
|
MorphClient
|
|
726
726
|
};
|
|
727
|
-
//# sourceMappingURL=chunk-
|
|
727
|
+
//# sourceMappingURL=chunk-Y23PQQRM.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-63WE2C5R.js";
|
|
5
5
|
import {
|
|
6
6
|
executeEditFile
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NMBM37CB.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -28,7 +28,7 @@ var editFileTool = {
|
|
|
28
28
|
type: "string",
|
|
29
29
|
description: "The path of the target file to modify"
|
|
30
30
|
},
|
|
31
|
-
|
|
31
|
+
instruction: {
|
|
32
32
|
type: "string",
|
|
33
33
|
description: "A single sentence describing what you are changing (first person)"
|
|
34
34
|
},
|
|
@@ -37,7 +37,7 @@ var editFileTool = {
|
|
|
37
37
|
description: "The lazy edit with // ... existing code ... markers"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
required: ["target_filepath", "
|
|
40
|
+
required: ["target_filepath", "instruction", "code_edit"]
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
function formatResult(result) {
|
|
@@ -79,4 +79,4 @@ export {
|
|
|
79
79
|
getSystemPrompt,
|
|
80
80
|
anthropic_exports
|
|
81
81
|
};
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
82
|
+
//# sourceMappingURL=chunk-Y3LQWQHU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/fastapply/anthropic.ts"],"sourcesContent":["/**\n * Anthropic SDK adapter for edit_file tool\n */\n\nimport type { Tool } from '@anthropic-ai/sdk/resources/messages';\nimport { executeEditFile } from './core.js';\nimport { EDIT_FILE_TOOL_DESCRIPTION, EDIT_FILE_SYSTEM_PROMPT } from './prompts.js';\nimport type { EditFileInput, EditFileResult, EditFileConfig } from './types.js';\n\n/**\n * Anthropic-native tool definition for edit_file\n * \n * @example\n * ```ts\n * import Anthropic from '@anthropic-ai/sdk';\n * import { editFileTool } from 'morphsdk/tools/anthropic';\n * \n * const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });\n * \n * const response = await client.messages.create({\n * model: \"claude-sonnet-4-5-20250929\",\n * tools: [editFileTool],\n * messages: [{ role: \"user\", content: \"Fix the bug in app.ts\" }]\n * });\n * ```\n */\nexport const editFileTool: Tool = {\n name: 'edit_file',\n description: EDIT_FILE_TOOL_DESCRIPTION,\n input_schema: {\n type: 'object',\n properties: {\n target_filepath: {\n type: 'string',\n description: 'The path of the target file to modify',\n },\n instruction: {\n type: 'string',\n description: 'A single sentence describing what you are changing (first person)',\n },\n code_edit: {\n type: 'string',\n description: 'The lazy edit with // ... existing code ... markers',\n },\n },\n required: ['target_filepath', 'instruction', 'code_edit'],\n },\n};\n\n/**\n * Format the result for passing back to Claude\n * \n * @param result - The edit result\n * @returns Formatted string for tool_result\n */\nexport function formatResult(result: EditFileResult): string {\n if (!result.success) {\n return `Error editing file: ${result.error}`;\n }\n \n const { changes } = result;\n return `Successfully applied changes to ${result.filepath}. Added ${changes.linesAdded}, removed ${changes.linesRemoved}, modified ${changes.linesModified}.`;\n}\n\n/**\n * Create a custom edit_file tool with configuration\n * \n * @param config - Configuration options\n * @returns Tool definition with execute and formatResult methods\n * \n * @example\n * ```ts\n * const tool = createEditFileTool({\n * baseDir: './src',\n * generateUdiff: true,\n * morphApiKey: 'sk-...',\n * description: 'Custom tool description for your use case'\n * });\n * \n * // Use as Anthropic tool\n * const response = await client.messages.create({\n * tools: [tool], // tool itself is the Tool definition\n * ...\n * });\n * \n * // Execute and format\n * const result = await tool.execute(toolUseBlock.input);\n * const formatted = tool.formatResult(result);\n * ```\n */\nexport function createEditFileTool(config: EditFileConfig = {}) {\n const toolDef: Tool = {\n ...editFileTool,\n ...(config.description && { description: config.description }),\n };\n \n return Object.assign({}, toolDef, {\n execute: async (input: EditFileInput): Promise<EditFileResult> => {\n return executeEditFile(input, config);\n },\n formatResult: (result: EditFileResult): string => {\n return formatResult(result);\n },\n getSystemPrompt: (): string => {\n return EDIT_FILE_SYSTEM_PROMPT;\n },\n });\n}\n\n/**\n * Execute the edit_file tool with raw input\n * \n * @param input - Tool input from Claude's tool_use\n * @param config - Configuration for Fast Apply\n * @returns Tool result to send back to Claude\n */\nexport async function execute(\n input: EditFileInput,\n config?: EditFileConfig\n): Promise<EditFileResult> {\n return executeEditFile(input, config);\n}\n\n/**\n * Get the system prompt for the edit_file tool\n * \n * @returns System prompt string\n */\nexport function getSystemPrompt(): string {\n return EDIT_FILE_SYSTEM_PROMPT;\n}\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BO,IAAM,eAAqB;AAAA,EAChC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,YAAY;AAAA,MACV,iBAAiB;AAAA,QACf,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA,aAAa;AAAA,QACX,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA,WAAW;AAAA,QACT,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA,UAAU,CAAC,mBAAmB,eAAe,WAAW;AAAA,EAC1D;AACF;AAQO,SAAS,aAAa,QAAgC;AAC3D,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,uBAAuB,OAAO,KAAK;AAAA,EAC5C;AAEA,QAAM,EAAE,QAAQ,IAAI;AACpB,SAAO,mCAAmC,OAAO,QAAQ,WAAW,QAAQ,UAAU,aAAa,QAAQ,YAAY,cAAc,QAAQ,aAAa;AAC5J;AA4BO,SAAS,mBAAmB,SAAyB,CAAC,GAAG;AAC9D,QAAM,UAAgB;AAAA,IACpB,GAAG;AAAA,IACH,GAAI,OAAO,eAAe,EAAE,aAAa,OAAO,YAAY;AAAA,EAC9D;AAEA,SAAO,OAAO,OAAO,CAAC,GAAG,SAAS;AAAA,IAChC,SAAS,OAAO,UAAkD;AAChE,aAAO,gBAAgB,OAAO,MAAM;AAAA,IACtC;AAAA,IACA,cAAc,CAAC,WAAmC;AAChD,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,IACA,iBAAiB,MAAc;AAC7B,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;AASA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AAOO,SAAS,kBAA0B;AACxC,SAAO;AACT;","names":[]}
|
|
@@ -4,13 +4,16 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
runWarpGrep,
|
|
6
6
|
runWarpGrepStreaming
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-TZCNMJHF.js";
|
|
8
8
|
import {
|
|
9
9
|
createCodeStorageHttpCommands
|
|
10
10
|
} from "./chunk-GVGJIXV2.js";
|
|
11
11
|
import {
|
|
12
12
|
RemoteCommandsProvider
|
|
13
13
|
} from "./chunk-B3AKP3RA.js";
|
|
14
|
+
import {
|
|
15
|
+
compactFileContexts
|
|
16
|
+
} from "./chunk-GLQWEINZ.js";
|
|
14
17
|
|
|
15
18
|
// tools/warp_grep/client.ts
|
|
16
19
|
var DEFAULT_CODE_SEARCH_URL = "https://morphllm.com";
|
|
@@ -141,20 +144,9 @@ async function executeToolCall(input, config) {
|
|
|
141
144
|
timeout: config.timeout,
|
|
142
145
|
search_type: config.search_type
|
|
143
146
|
});
|
|
144
|
-
|
|
145
|
-
if (result.terminationReason !== "completed" || !finish?.metadata) {
|
|
146
|
-
const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
|
|
147
|
-
console.error(`[warp_grep] executeToolCall failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);
|
|
148
|
-
return { success: false, error: `Search did not complete: ${errorDetails}` };
|
|
149
|
-
}
|
|
150
|
-
const contexts = (finish.resolved ?? []).map((r) => ({
|
|
151
|
-
file: r.path,
|
|
152
|
-
content: r.content,
|
|
153
|
-
lines: r.ranges
|
|
154
|
-
}));
|
|
155
|
-
return { success: true, contexts, summary: finish.payload };
|
|
147
|
+
return processAgentResult(result, parsed.search_term, config.morphApiKey, config.morphApiUrl);
|
|
156
148
|
}
|
|
157
|
-
function processAgentResult(result) {
|
|
149
|
+
async function processAgentResult(result, searchTerm, apiKey, apiUrl) {
|
|
158
150
|
const finish = result.finish;
|
|
159
151
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|
|
160
152
|
const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
|
|
@@ -166,6 +158,15 @@ function processAgentResult(result) {
|
|
|
166
158
|
content: r.content,
|
|
167
159
|
lines: r.ranges
|
|
168
160
|
}));
|
|
161
|
+
try {
|
|
162
|
+
const compactable = contexts.map((c) => ({ path: c.file, content: c.content }));
|
|
163
|
+
const compacted = await compactFileContexts(compactable, searchTerm, apiKey, apiUrl);
|
|
164
|
+
for (let i = 0; i < contexts.length; i++) {
|
|
165
|
+
contexts[i].content = compacted[i].content;
|
|
166
|
+
}
|
|
167
|
+
} catch (error) {
|
|
168
|
+
console.error(`[warp_grep] Failed to compact result contexts:`, error);
|
|
169
|
+
}
|
|
169
170
|
return { success: true, contexts, summary: finish.payload };
|
|
170
171
|
}
|
|
171
172
|
async function* executeToolCallStreaming(input, config) {
|
|
@@ -194,7 +195,7 @@ async function* executeToolCallStreaming(input, config) {
|
|
|
194
195
|
}
|
|
195
196
|
yield value;
|
|
196
197
|
}
|
|
197
|
-
return processAgentResult(agentResult);
|
|
198
|
+
return processAgentResult(agentResult, parsed.search_term, config.morphApiKey, config.morphApiUrl);
|
|
198
199
|
}
|
|
199
200
|
async function fetchRawGitHubFile(owner, repo, filePath, branch, timeout) {
|
|
200
201
|
const branches = branch ? [branch] : ["HEAD"];
|
|
@@ -289,4 +290,4 @@ export {
|
|
|
289
290
|
formatGitHubReadFileResult,
|
|
290
291
|
formatResult
|
|
291
292
|
};
|
|
292
|
-
//# sourceMappingURL=chunk-
|
|
293
|
+
//# sourceMappingURL=chunk-YCUX3ZNQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/client.ts"],"sourcesContent":["/**\n * WarpGrep client for programmatic code search\n */\n\nimport { runWarpGrep, runWarpGrepStreaming } from './agent/runner.js';\nimport { RemoteCommandsProvider } from './providers/remote.js';\nimport type { WarpGrepProvider } from './providers/types.js';\nimport type { AgentRunResult, WarpGrepStep } from './agent/types.js';\nimport type {\n WarpGrepClientConfig,\n WarpGrepInput,\n WarpGrepResult,\n WarpGrepContext,\n WarpGrepToolConfig,\n GitHubSearchInput,\n GitHubReadFileInput,\n GitHubReadFileResult,\n RemoteCommands,\n} from './types.js';\nimport { createCodeStorageHttpCommands } from './providers/code_storage_http.js';\nimport { parseGitHubUrl } from './utils/github.js';\nimport { compactFileContexts } from '../compact/utils.js';\n\nconst DEFAULT_CODE_SEARCH_URL = 'https://morphllm.com';\n\n/**\n * Lazy-load LocalRipgrepProvider to avoid importing Node.js-specific\n * modules (child_process, fs) in edge environments like Cloudflare Workers.\n * Only loads when actually needed (i.e., when no remoteCommands or provider is specified).\n */\nasync function getLocalProvider(repoRoot: string, excludes?: string[], allowNames?: string[]): Promise<WarpGrepProvider> {\n const { LocalRipgrepProvider } = await import('./providers/local.js');\n const opts = allowNames?.length ? { allowNames } : undefined;\n return new LocalRipgrepProvider(repoRoot, excludes, opts);\n}\n\n/**\n * WarpGrep client for programmatic code search\n * \n * @example\n * ```typescript\n * import { WarpGrepClient } from '@morphllm/morphsdk';\n * \n * const client = new WarpGrepClient({ morphApiKey: process.env.MORPH_API_KEY });\n * \n * // Simple usage - defaults to LocalRipgrepProvider\n * const result = await client.execute({\n * searchTerm: 'Find authentication middleware',\n * repoRoot: '.'\n * });\n *\n * // With custom excludes\n * const result = await client.execute({\n * searchTerm: 'Find database models',\n * repoRoot: '.',\n * excludes: ['node_modules', '.git', 'dist']\n * });\n * ```\n */\nexport class WarpGrepClient {\n private config: WarpGrepClientConfig;\n\n constructor(config: WarpGrepClientConfig = {}) {\n this.config = { ...config };\n }\n\n /**\n * Execute a code search\n *\n * @param input - Search parameters including searchTerm, repoRoot, and optional provider\n * @returns Search results with relevant code contexts, or an AsyncGenerator if streamSteps is true\n *\n * @example\n * ```typescript\n * // Standard execution\n * const result = await client.execute({\n * searchTerm: 'Find authentication middleware',\n * repoRoot: '.'\n * });\n *\n * if (result.success) {\n * for (const ctx of result.contexts) {\n * console.log(`File: ${ctx.file}`);\n * console.log(ctx.content);\n * }\n * }\n *\n * // Streaming execution\n * const stream = client.execute({\n * searchTerm: 'Find auth middleware',\n * repoRoot: '.',\n * streamSteps: true\n * });\n *\n * for await (const step of stream) {\n * console.log(`Turn ${step.turn}:`, step.toolCalls);\n * }\n * ```\n */\n execute(input: WarpGrepInput & { streamSteps: true }): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined>;\n execute(input: WarpGrepInput & { streamSteps?: false | undefined }): Promise<WarpGrepResult>;\n execute(input: WarpGrepInput): Promise<WarpGrepResult> | AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined> {\n const toolConfig: WarpGrepToolConfig = {\n repoRoot: input.repoRoot,\n remoteCommands: input.remoteCommands,\n provider: input.provider,\n excludes: input.excludes,\n includes: input.includes,\n debug: input.debug ?? this.config.debug,\n morphApiKey: this.config.morphApiKey,\n morphApiUrl: this.config.morphApiUrl,\n retryConfig: this.config.retryConfig,\n timeout: this.config.timeout,\n search_type: input.search_type,\n };\n\n if (input.streamSteps) {\n return executeToolCallStreaming({ search_term: input.searchTerm }, toolConfig);\n }\n return executeToolCall({ search_term: input.searchTerm }, toolConfig);\n }\n\n /**\n * Search a public GitHub repository\n *\n * @example\n * ```typescript\n * // Simple usage\n * const result = await client.searchGitHub({\n * searchTerm: 'Find authentication middleware',\n * github: 'vercel/next.js',\n * });\n *\n * // With streaming\n * const stream = client.searchGitHub({\n * searchTerm: 'Find auth middleware',\n * github: 'https://github.com/vercel/next.js',\n * streamSteps: true,\n * });\n * for await (const step of stream) {\n * console.log(`Turn ${step.turn}:`, step.toolCalls);\n * }\n * ```\n */\n searchGitHub(input: GitHubSearchInput & { streamSteps: true }): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined>;\n searchGitHub(input: GitHubSearchInput & { streamSteps?: false | undefined }): Promise<WarpGrepResult>;\n searchGitHub(input: GitHubSearchInput): Promise<WarpGrepResult> | AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined> {\n if (input.streamSteps) {\n return this._searchGitHubStreaming(input);\n }\n return this._searchGitHubAsync(input);\n }\n\n /**\n * Read a single file from a public GitHub repository\n *\n * @example\n * ```typescript\n * const result = await client.readGitHubFile({\n * github: 'vercel/next.js',\n * path: 'src/server/app-render/index.tsx',\n * startLine: 1,\n * endLine: 50,\n * });\n * if (result.success) console.log(result.content);\n * ```\n */\n async readGitHubFile(input: GitHubReadFileInput): Promise<GitHubReadFileResult> {\n return executeGitHubReadFile(input, { timeout: this.config.timeout });\n }\n\n private async _resolveGitHubRepo(input: GitHubSearchInput): Promise<{ repo: string; remoteCommands: RemoteCommands }> {\n const { owner, repo } = parseGitHubUrl(input.github);\n const baseUrl = this.config.codeSearchUrl || DEFAULT_CODE_SEARCH_URL;\n const importRes = await fetch(`${baseUrl}/api/code-search/get-or-create?url=${encodeURIComponent(`${owner}/${repo}`)}`);\n if (!importRes.ok) {\n const text = await importRes.text().catch(() => importRes.statusText);\n throw new Error(`Failed to import repo ${owner}/${repo}: ${text}`);\n }\n const { repoId, defaultBranch } = await importRes.json();\n return {\n repo,\n remoteCommands: createCodeStorageHttpCommands({ baseUrl, repoId, branch: input.branch || defaultBranch }),\n };\n }\n\n private async _searchGitHubAsync(input: GitHubSearchInput): Promise<WarpGrepResult> {\n try {\n const { remoteCommands } = await this._resolveGitHubRepo(input);\n return this.execute({\n searchTerm: input.searchTerm,\n repoRoot: '.',\n remoteCommands,\n });\n } catch (error) {\n return { success: false, error: error instanceof Error ? error.message : String(error) };\n }\n }\n\n private async *_searchGitHubStreaming(input: GitHubSearchInput): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined> {\n let remoteCommands: RemoteCommands;\n try {\n ({ remoteCommands } = await this._resolveGitHubRepo(input));\n } catch (error) {\n return { success: false, error: error instanceof Error ? error.message : String(error) };\n }\n\n const generator = this.execute({\n searchTerm: input.searchTerm,\n repoRoot: '.',\n remoteCommands,\n streamSteps: true,\n });\n\n let result: WarpGrepResult;\n for (;;) {\n const { value, done } = await generator.next();\n if (done) {\n result = value;\n break;\n }\n yield value;\n }\n return result;\n }\n}\n\n/**\n * Execute a warp grep search directly\n *\n * @param input - Search parameters\n * @param config - Optional client configuration\n * @returns Search results, or an AsyncGenerator if streamSteps is true\n *\n * @example\n * ```typescript\n * import { executeWarpGrep } from '@morphllm/morphsdk/tools/warp-grep';\n *\n * const result = await executeWarpGrep({\n * searchTerm: 'Find authentication middleware',\n * repoRoot: '.'\n * });\n *\n * // Streaming\n * const stream = executeWarpGrep({\n * searchTerm: 'Find auth',\n * repoRoot: '.',\n * streamSteps: true\n * });\n * for await (const step of stream) {\n * console.log(step.turn, step.toolCalls);\n * }\n * ```\n */\nexport function executeWarpGrep(\n input: WarpGrepInput & { streamSteps: true },\n config?: WarpGrepClientConfig\n): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined>;\nexport function executeWarpGrep(\n input: WarpGrepInput & { streamSteps?: false | undefined },\n config?: WarpGrepClientConfig\n): Promise<WarpGrepResult>;\nexport function executeWarpGrep(\n input: WarpGrepInput,\n config?: WarpGrepClientConfig\n): Promise<WarpGrepResult> | AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined> {\n const client = new WarpGrepClient(config);\n if (input.streamSteps) {\n return client.execute({ ...input, streamSteps: true });\n }\n return client.execute({ ...input, streamSteps: false });\n}\n\nexport async function executeToolCall(\n input: { search_term: string } | string,\n config: WarpGrepToolConfig\n): Promise<WarpGrepResult> {\n const parsed = typeof input === 'string' ? JSON.parse(input) : input;\n\n // Priority: remoteCommands > provider > LocalRipgrepProvider (lazy-loaded for edge compatibility)\n const allowNames = config.search_type === 'node_modules' ? ['node_modules'] : undefined;\n const provider = config.remoteCommands\n ? new RemoteCommandsProvider(config.repoRoot, config.remoteCommands)\n : config.provider ?? await getLocalProvider(config.repoRoot, config.excludes, allowNames);\n\n const result = await runWarpGrep({\n searchTerm: parsed.search_term,\n repoRoot: config.repoRoot,\n provider,\n excludes: config.excludes,\n includes: config.includes,\n debug: config.debug ?? false,\n morphApiKey: config.morphApiKey,\n morphApiUrl: config.morphApiUrl,\n retryConfig: config.retryConfig,\n timeout: config.timeout,\n search_type: config.search_type,\n });\n\n return processAgentResult(result, parsed.search_term, config.morphApiKey, config.morphApiUrl);\n}\n\n/**\n * Helper to process AgentRunResult into WarpGrepResult\n */\nasync function processAgentResult(\n result: AgentRunResult,\n searchTerm: string,\n apiKey?: string,\n apiUrl?: string\n): Promise<WarpGrepResult> {\n const finish = result.finish;\n if (result.terminationReason !== 'completed' || !finish?.metadata) {\n const errorDetails = result.errors?.map(e => e.message).join('; ') || 'unknown reason';\n console.error(`[warp_grep] processAgentResult failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);\n return { success: false, error: `Search did not complete: ${errorDetails}` };\n }\n\n const contexts: WarpGrepContext[] = (finish.resolved ?? []).map(r => ({\n file: r.path,\n content: r.content,\n lines: r.ranges,\n }));\n\n try {\n const compactable = contexts.map(c => ({ path: c.file, content: c.content }));\n const compacted = await compactFileContexts(compactable, searchTerm, apiKey, apiUrl);\n for (let i = 0; i < contexts.length; i++) {\n contexts[i].content = compacted[i].content;\n }\n } catch (error) {\n console.error(`[warp_grep] Failed to compact result contexts:`, error);\n }\n\n return { success: true, contexts, summary: finish.payload };\n}\n\n/**\n * Streaming version of executeToolCall that yields WarpGrepStep for each turn.\n */\nexport async function* executeToolCallStreaming(\n input: { search_term: string } | string,\n config: WarpGrepToolConfig\n): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined> {\n const parsed = typeof input === 'string' ? JSON.parse(input) : input;\n\n // Priority: remoteCommands > provider > LocalRipgrepProvider (lazy-loaded for edge compatibility)\n const allowNames = config.search_type === 'node_modules' ? ['node_modules'] : undefined;\n const provider = config.remoteCommands\n ? new RemoteCommandsProvider(config.repoRoot, config.remoteCommands)\n : config.provider ?? await getLocalProvider(config.repoRoot, config.excludes, allowNames);\n\n const generator = runWarpGrepStreaming({\n searchTerm: parsed.search_term,\n repoRoot: config.repoRoot,\n provider,\n excludes: config.excludes,\n includes: config.includes,\n debug: config.debug ?? false,\n morphApiKey: config.morphApiKey,\n morphApiUrl: config.morphApiUrl,\n retryConfig: config.retryConfig,\n timeout: config.timeout,\n search_type: config.search_type,\n });\n\n // Forward all yielded steps\n let agentResult: AgentRunResult;\n for (;;) {\n const { value, done } = await generator.next();\n if (done) {\n agentResult = value;\n break;\n }\n yield value;\n }\n\n return processAgentResult(agentResult, parsed.search_term, config.morphApiKey, config.morphApiUrl);\n}\n\n/**\n * Fetch raw file content from a public GitHub repository.\n * Tries the given branch first, then falls back to main/master/develop.\n */\nasync function fetchRawGitHubFile(\n owner: string,\n repo: string,\n filePath: string,\n branch?: string,\n timeout?: number,\n): Promise<{ content: string; branch: string }> {\n const branches = branch ? [branch] : ['HEAD'];\n const fallbacks = ['main', 'master', 'develop'];\n\n const fetchWithTimeout = (url: string) =>\n timeout ? fetch(url, { signal: AbortSignal.timeout(timeout) }) : fetch(url);\n\n for (const b of branches) {\n const url = `https://raw.githubusercontent.com/${owner}/${repo}/${b}/${filePath}`;\n const res = await fetchWithTimeout(url);\n if (res.ok) return { content: await res.text(), branch: b };\n }\n\n for (const fb of fallbacks) {\n if (branch && fb === branch) continue;\n const url = `https://raw.githubusercontent.com/${owner}/${repo}/${fb}/${filePath}`;\n const res = await fetchWithTimeout(url);\n if (res.ok) return { content: await res.text(), branch: fb };\n }\n\n throw new Error(`File not found: ${owner}/${repo}/${filePath}`);\n}\n\n/**\n * Read a single file (or line range) from a public GitHub repository\n */\nexport async function executeGitHubReadFile(\n input: GitHubReadFileInput,\n config?: { timeout?: number },\n): Promise<GitHubReadFileResult> {\n try {\n const { owner, repo } = parseGitHubUrl(input.github);\n const { content: raw, branch } = await fetchRawGitHubFile(\n owner, repo, input.path, input.branch, config?.timeout,\n );\n\n const allLines = raw.split('\\n');\n const totalLines = allLines.length;\n const start = Math.max(1, input.startLine ?? 1);\n const end = Math.min(totalLines, input.endLine ?? totalLines);\n\n const selected = allLines.slice(start - 1, end);\n const padWidth = String(end).length;\n const numbered = selected\n .map((line, i) => `${String(start + i).padStart(padWidth)}|${line}`)\n .join('\\n');\n\n return {\n success: true,\n content: numbered,\n path: input.path,\n github: `${owner}/${repo}`,\n branch,\n lineRange: [start, end],\n totalLines,\n };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n}\n\n/**\n * Format a GitHub read file result for display or tool responses\n */\nexport function formatGitHubReadFileResult(result: GitHubReadFileResult): string {\n if (!result.success) {\n return `Failed to read file: ${result.error}`;\n }\n\n const rangeStr = result.lineRange\n ? ` (lines ${result.lineRange[0]}-${result.lineRange[1]} of ${result.totalLines})`\n : '';\n\n return `File: ${result.github}/${result.path}${rangeStr}\\n\\n${result.content}`;\n}\n\n/**\n * Format warp grep results for display or tool responses\n * \n * @param result - The search result\n * @returns Formatted string representation\n */\nexport function formatResult(result: WarpGrepResult): string {\n if (!result.success) {\n return `Search failed: ${result.error}`;\n }\n\n if (!result.contexts || result.contexts.length === 0) {\n return 'No relevant code found. Try rephrasing your search term.';\n }\n\n const parts: string[] = [];\n parts.push(`Morph Fast Context subagent performed search on repository:\\n`);\n parts.push('Relevant context found:');\n\n for (const ctx of result.contexts) {\n const rangeStr = !ctx.lines || ctx.lines === '*'\n ? '*'\n : ctx.lines.map(([s, e]) => `${s}-${e}`).join(',');\n parts.push(`- ${ctx.file}:${rangeStr}`);\n }\n\n parts.push('\\nHere is the content of files:\\n');\n\n for (const ctx of result.contexts) {\n const rangeStr = !ctx.lines || ctx.lines === '*'\n ? ''\n : ` lines=\"${ctx.lines.map(([s, e]) => `${s}-${e}`).join(',')}\"`;\n parts.push(`<file path=\"${ctx.file}\"${rangeStr}>`);\n parts.push(ctx.content);\n parts.push('</file>\\n');\n }\n\n return parts.join('\\n');\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,IAAM,0BAA0B;AAOhC,eAAe,iBAAiB,UAAkB,UAAqB,YAAkD;AACvH,QAAM,EAAE,qBAAqB,IAAI,MAAM,OAAO,sCAAsB;AACpE,QAAM,OAAO,YAAY,SAAS,EAAE,WAAW,IAAI;AACnD,SAAO,IAAI,qBAAqB,UAAU,UAAU,IAAI;AAC1D;AAyBO,IAAM,iBAAN,MAAqB;AAAA,EAClB;AAAA,EAER,YAAY,SAA+B,CAAC,GAAG;AAC7C,SAAK,SAAS,EAAE,GAAG,OAAO;AAAA,EAC5B;AAAA,EAqCA,QAAQ,OAAyG;AAC/G,UAAM,aAAiC;AAAA,MACrC,UAAU,MAAM;AAAA,MAChB,gBAAgB,MAAM;AAAA,MACtB,UAAU,MAAM;AAAA,MAChB,UAAU,MAAM;AAAA,MAChB,UAAU,MAAM;AAAA,MAChB,OAAO,MAAM,SAAS,KAAK,OAAO;AAAA,MAClC,aAAa,KAAK,OAAO;AAAA,MACzB,aAAa,KAAK,OAAO;AAAA,MACzB,aAA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AAI,CAAC,EAAE,EAAE,KAAK,GAAG,CAAC;AAC/D,UAAM,KAAK,eAAe,IAAI,IAAI,IAAI,QAAQ,GAAG;AACjD,UAAM,KAAK,IAAI,OAAO;AACtB,UAAM,KAAK,WAAW;AAAA,EACxB;AAEA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
executeToolCall,
|
|
15
15
|
formatGitHubReadFileResult,
|
|
16
16
|
formatResult
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-YCUX3ZNQ.js";
|
|
18
18
|
|
|
19
19
|
// tools/warp_grep/anthropic.ts
|
|
20
20
|
var INPUT_SCHEMA = {
|
|
@@ -90,4 +90,4 @@ export {
|
|
|
90
90
|
createGitHubSearchTool,
|
|
91
91
|
createGitHubReadFileTool
|
|
92
92
|
};
|
|
93
|
-
//# sourceMappingURL=chunk-
|
|
93
|
+
//# sourceMappingURL=chunk-YIUOPGWE.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-63WE2C5R.js";
|
|
5
5
|
import {
|
|
6
6
|
executeEditFile
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NMBM37CB.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -31,7 +31,7 @@ var editFileTool = {
|
|
|
31
31
|
type: "string",
|
|
32
32
|
description: "The path of the target file to modify"
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
instruction: {
|
|
35
35
|
type: "string",
|
|
36
36
|
description: "A single sentence describing what you are changing (first person)"
|
|
37
37
|
},
|
|
@@ -40,7 +40,7 @@ var editFileTool = {
|
|
|
40
40
|
description: "The lazy edit with // ... existing code ... markers"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
required: ["target_filepath", "
|
|
43
|
+
required: ["target_filepath", "instruction", "code_edit"]
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
};
|
|
@@ -91,4 +91,4 @@ export {
|
|
|
91
91
|
openai_default,
|
|
92
92
|
openai_exports
|
|
93
93
|
};
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-YJEXFOLJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/fastapply/openai.ts"],"sourcesContent":["/**\n * OpenAI SDK adapter for edit_file tool\n */\n\nimport type { ChatCompletionTool } from 'openai/resources/chat/completions';\nimport { executeEditFile } from './core.js';\nimport { EDIT_FILE_TOOL_DESCRIPTION, EDIT_FILE_SYSTEM_PROMPT } from './prompts.js';\nimport type { EditFileInput, EditFileResult, EditFileConfig } from './types.js';\n\n/**\n * OpenAI-native tool definition for edit_file\n * \n * @example\n * ```ts\n * import OpenAI from 'openai';\n * import { editFileTool } from 'morphsdk/tools/openai';\n * \n * const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });\n * \n * const response = await client.chat.completions.create({\n * model: \"gpt-4o\",\n * tools: [editFileTool],\n * messages: [{ role: \"user\", content: \"Fix the bug in app.ts\" }]\n * });\n * ```\n */\nexport const editFileTool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: 'edit_file',\n description: EDIT_FILE_TOOL_DESCRIPTION,\n parameters: {\n type: 'object',\n properties: {\n target_filepath: {\n type: 'string',\n description: 'The path of the target file to modify',\n },\n instruction: {\n type: 'string',\n description: 'A single sentence describing what you are changing (first person)',\n },\n code_edit: {\n type: 'string',\n description: 'The lazy edit with // ... existing code ... markers',\n },\n },\n required: ['target_filepath', 'instruction', 'code_edit'],\n },\n },\n};\n\n/**\n * Execute an edit_file tool call\n * \n * @param input - The tool input from GPT (parsed from tool_calls)\n * @param config - Optional configuration\n * @returns The result of the edit operation\n * \n * @example\n * ```ts\n * const args = JSON.parse(toolCall.function.arguments);\n * const result = await execute(args);\n * console.log('Changes applied:', result.udiff);\n * ```\n */\nexport async function execute(\n input: EditFileInput,\n config?: EditFileConfig\n): Promise<EditFileResult> {\n return executeEditFile(input, config);\n}\n\n/**\n * Get the system prompt for edit_file usage\n * \n * Add this to your system message to guide GPT on using edit_file properly.\n * \n * @example\n * ```ts\n * const response = await client.chat.completions.create({\n * model: \"gpt-4o\",\n * messages: [\n * { role: \"system\", content: getSystemPrompt() },\n * { role: \"user\", content: \"Fix bugs\" }\n * ],\n * tools: [editFileTool]\n * });\n * ```\n */\nexport function getSystemPrompt(): string {\n return EDIT_FILE_SYSTEM_PROMPT;\n}\n\n/**\n * Format the result for passing back to GPT\n * \n * @param result - The edit result\n * @returns Formatted string for tool message\n */\nexport function formatResult(result: EditFileResult): string {\n if (!result.success) {\n return `Error editing file: ${result.error}`;\n }\n \n const { changes } = result;\n return `Successfully applied changes to ${result.filepath}. Added ${changes.linesAdded}, removed ${changes.linesRemoved}, modified ${changes.linesModified}.`;\n}\n\n/**\n * Create a custom edit_file tool with configuration and methods\n * \n * @param config - Configuration options\n * @returns Tool definition with execute and formatResult methods\n * \n * @example\n * ```ts\n * import OpenAI from 'openai';\n * import { createEditFileTool } from 'morphsdk/tools/fastapply/openai';\n * \n * const tool = createEditFileTool({\n * baseDir: './src',\n * generateUdiff: true,\n * description: 'Custom tool description for your use case'\n * });\n * \n * const client = new OpenAI();\n * \n * const response = await client.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [tool], // tool itself is the ChatCompletionTool\n * messages: [{ role: 'user', content: 'Fix bug in app.ts' }]\n * });\n * \n * // Execute and format\n * const result = await tool.execute(toolCallArgs);\n * const formatted = tool.formatResult(result);\n * ```\n */\nexport function createEditFileTool(config: EditFileConfig = {}) {\n const toolDef: ChatCompletionTool = {\n ...editFileTool,\n ...(config.description && {\n function: {\n ...editFileTool.function,\n description: config.description,\n },\n }),\n };\n \n return Object.assign({}, toolDef, {\n execute: async (input: EditFileInput | string): Promise<EditFileResult> => {\n const parsedInput = typeof input === 'string' ? JSON.parse(input) : input;\n return execute(parsedInput, config);\n },\n formatResult: (result: EditFileResult): string => {\n return formatResult(result);\n },\n getSystemPrompt: (): string => {\n return getSystemPrompt();\n },\n });\n}\n\n// Default export for convenience\nexport default editFileTool;\n\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BO,IAAM,eAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,UAAU;AAAA,IACR,MAAM;AAAA,IACN,aAAa;AAAA,IACb,YAAY;AAAA,MACV,MAAM;AAAA,MACN,YAAY;AAAA,QACV,iBAAiB;AAAA,UACf,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,aAAa;AAAA,UACX,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,WAAW;AAAA,UACT,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,MACF;AAAA,MACA,UAAU,CAAC,mBAAmB,eAAe,WAAW;AAAA,IAC1D;AAAA,EACF;AACF;AAgBA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AAmBO,SAAS,kBAA0B;AACxC,SAAO;AACT;AAQO,SAAS,aAAa,QAAgC;AAC3D,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,uBAAuB,OAAO,KAAK;AAAA,EAC5C;AAEA,QAAM,EAAE,QAAQ,IAAI;AACpB,SAAO,mCAAmC,OAAO,QAAQ,WAAW,QAAQ,UAAU,aAAa,QAAQ,YAAY,cAAc,QAAQ,aAAa;AAC5J;AAgCO,SAAS,mBAAmB,SAAyB,CAAC,GAAG;AAC9D,QAAM,UAA8B;AAAA,IAClC,GAAG;AAAA,IACH,GAAI,OAAO,eAAe;AAAA,MACxB,UAAU;AAAA,QACR,GAAG,aAAa;AAAA,QAChB,aAAa,OAAO;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO,OAAO,CAAC,GAAG,SAAS;AAAA,IAChC,SAAS,OAAO,UAA2D;AACzE,YAAM,cAAc,OAAO,UAAU,WAAW,KAAK,MAAM,KAAK,IAAI;AACpE,aAAO,QAAQ,aAAa,MAAM;AAAA,IACpC;AAAA,IACA,cAAc,CAAC,WAAmC;AAChD,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,IACA,iBAAiB,MAAc;AAC7B,aAAO,gBAAgB;AAAA,IACzB;AAAA,EACF,CAAC;AACH;AAGA,IAAO,iBAAQ;","names":[]}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-2VERUKO2.js";
|
|
13
13
|
import {
|
|
14
14
|
fetchWithRetry
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MBVOMNXG.js";
|
|
16
16
|
|
|
17
17
|
// tools/browser/profiles/core.ts
|
|
18
18
|
var DEFAULT_API_URL = process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com";
|
|
@@ -386,4 +386,4 @@ export {
|
|
|
386
386
|
listRepos,
|
|
387
387
|
getProfileState
|
|
388
388
|
};
|
|
389
|
-
//# sourceMappingURL=chunk-
|
|
389
|
+
//# sourceMappingURL=chunk-YRHDWJDA.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeCodebaseSearch
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-V2BUYOKP.js";
|
|
4
4
|
import {
|
|
5
5
|
CODEBASE_SEARCH_DESCRIPTION,
|
|
6
6
|
CODEBASE_SEARCH_SYSTEM_PROMPT
|
|
@@ -125,4 +125,4 @@ export {
|
|
|
125
125
|
getSystemPrompt,
|
|
126
126
|
openai_default
|
|
127
127
|
};
|
|
128
|
-
//# sourceMappingURL=chunk-
|
|
128
|
+
//# sourceMappingURL=chunk-YYOPTKC3.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-63WE2C5R.js";
|
|
5
5
|
import {
|
|
6
6
|
executeEditFile
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NMBM37CB.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -21,7 +21,7 @@ import { tool } from "ai";
|
|
|
21
21
|
import { z } from "zod";
|
|
22
22
|
var editFileSchema = z.object({
|
|
23
23
|
target_filepath: z.string().describe("The path of the target file to modify"),
|
|
24
|
-
|
|
24
|
+
instruction: z.string().describe("A single sentence describing what you are changing (first person)"),
|
|
25
25
|
code_edit: z.string().describe("The lazy edit with // ... existing code ... markers")
|
|
26
26
|
});
|
|
27
27
|
var editFileTool = tool({
|
|
@@ -30,7 +30,7 @@ var editFileTool = tool({
|
|
|
30
30
|
execute: async (params) => {
|
|
31
31
|
const result = await executeEditFile({
|
|
32
32
|
target_filepath: params.target_filepath,
|
|
33
|
-
|
|
33
|
+
instruction: params.instruction,
|
|
34
34
|
code_edit: params.code_edit
|
|
35
35
|
});
|
|
36
36
|
if (!result.success) {
|
|
@@ -50,7 +50,7 @@ function getSystemPrompt() {
|
|
|
50
50
|
function createEditFileTool(config = {}) {
|
|
51
51
|
const schema = z.object({
|
|
52
52
|
target_filepath: z.string().describe("The path of the target file to modify"),
|
|
53
|
-
|
|
53
|
+
instruction: z.string().describe("A single sentence describing what you are changing (first person)"),
|
|
54
54
|
code_edit: z.string().describe("The lazy edit with // ... existing code ... markers")
|
|
55
55
|
});
|
|
56
56
|
return tool({
|
|
@@ -60,7 +60,7 @@ function createEditFileTool(config = {}) {
|
|
|
60
60
|
const result = await executeEditFile(
|
|
61
61
|
{
|
|
62
62
|
target_filepath: params.target_filepath,
|
|
63
|
-
|
|
63
|
+
instruction: params.instruction,
|
|
64
64
|
code_edit: params.code_edit
|
|
65
65
|
},
|
|
66
66
|
config
|
|
@@ -86,4 +86,4 @@ export {
|
|
|
86
86
|
vercel_default,
|
|
87
87
|
vercel_exports
|
|
88
88
|
};
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
89
|
+
//# sourceMappingURL=chunk-ZMGKZNII.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/fastapply/vercel.ts"],"sourcesContent":["/**\n * Vercel AI SDK adapter for edit_file tool\n */\n\nimport { tool } from 'ai';\nimport { z } from 'zod';\nimport { executeEditFile } from './core.js';\nimport { EDIT_FILE_TOOL_DESCRIPTION, EDIT_FILE_SYSTEM_PROMPT } from './prompts.js';\nimport type { EditFileConfig } from './types.js';\n\n/**\n * Vercel AI SDK tool for edit_file\n * \n * @example\n * ```ts\n * import { generateText } from 'ai';\n * import { anthropic } from '@ai-sdk/anthropic';\n * import { editFileTool } from 'morphsdk/tools/vercel';\n * \n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { editFile: editFileTool },\n * prompt: \"Fix the bug in app.ts\"\n * });\n * ```\n */\nconst editFileSchema = z.object({\n target_filepath: z.string().describe('The path of the target file to modify'),\n instruction: z\n .string()\n .describe('A single sentence describing what you are changing (first person)'),\n code_edit: z\n .string()\n .describe('The lazy edit with // ... existing code ... markers'),\n});\n\nexport const editFileTool = tool({\n description: EDIT_FILE_TOOL_DESCRIPTION,\n inputSchema: editFileSchema,\n execute: async (params) => {\n const result = await executeEditFile({\n target_filepath: params.target_filepath,\n instruction: params.instruction,\n code_edit: params.code_edit,\n });\n \n if (!result.success) {\n throw new Error(`Failed to edit file: ${result.error}`);\n }\n \n return {\n success: true,\n filepath: result.filepath,\n changes: result.changes,\n udiff: result.udiff,\n };\n },\n});\n\n/**\n * Get the system prompt for edit_file usage\n * \n * Add this to your system message to guide the model on using edit_file properly.\n * \n * @example\n * ```ts\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * system: getSystemPrompt(),\n * tools: { editFile: editFileTool },\n * prompt: \"Fix bugs\"\n * });\n * ```\n */\nexport function getSystemPrompt(): string {\n return EDIT_FILE_SYSTEM_PROMPT;\n}\n\n/**\n * Create a custom edit_file tool with configuration\n * \n * @param config - Configuration options\n * @returns Vercel AI SDK tool with custom config\n * \n * @example\n * ```ts\n * const customEditTool = createEditFileTool({\n * baseDir: './src',\n * generateUdiff: true,\n * description: 'Custom tool description for your use case'\n * });\n * \n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { editFile: customEditTool },\n * prompt: \"Fix bugs\"\n * });\n * ```\n */\nexport function createEditFileTool(config: EditFileConfig = {}) {\n const schema = z.object({\n target_filepath: z.string().describe('The path of the target file to modify'),\n instruction: z\n .string()\n .describe('A single sentence describing what you are changing (first person)'),\n code_edit: z\n .string()\n .describe('The lazy edit with // ... existing code ... markers'),\n });\n\n return tool({\n description: config.description || EDIT_FILE_TOOL_DESCRIPTION,\n inputSchema: schema,\n execute: async (params) => {\n const result = await executeEditFile(\n {\n target_filepath: params.target_filepath,\n instruction: params.instruction,\n code_edit: params.code_edit,\n },\n config\n );\n \n if (!result.success) {\n throw new Error(`Failed to edit file: ${result.error}`);\n }\n \n return {\n success: true,\n filepath: result.filepath,\n changes: result.changes,\n udiff: result.udiff,\n };\n },\n });\n}\n\n// Default export for convenience\nexport default editFileTool;\n\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,SAAS,YAAY;AACrB,SAAS,SAAS;AAqBlB,IAAM,iBAAiB,EAAE,OAAO;AAAA,EAC9B,iBAAiB,EAAE,OAAO,EAAE,SAAS,uCAAuC;AAAA,EAC5E,aAAa,EACV,OAAO,EACP,SAAS,mEAAmE;AAAA,EAC/E,WAAW,EACR,OAAO,EACP,SAAS,qDAAqD;AACnE,CAAC;AAEM,IAAM,eAAe,KAAK;AAAA,EAC/B,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS,OAAO,WAAW;AACzB,UAAM,SAAS,MAAM,gBAAgB;AAAA,MACnC,iBAAiB,OAAO;AAAA,MACxB,aAAa,OAAO;AAAA,MACpB,WAAW,OAAO;AAAA,IACpB,CAAC;AAED,QAAI,CAAC,OAAO,SAAS;AACnB,YAAM,IAAI,MAAM,wBAAwB,OAAO,KAAK,EAAE;AAAA,IACxD;AAEA,WAAO;AAAA,MACL,SAAS;AAAA,MACT,UAAU,OAAO;AAAA,MACjB,SAAS,OAAO;AAAA,MAChB,OAAO,OAAO;AAAA,IAChB;AAAA,EACF;AACF,CAAC;AAiBM,SAAS,kBAA0B;AACxC,SAAO;AACT;AAuBO,SAAS,mBAAmB,SAAyB,CAAC,GAAG;AAC9D,QAAM,SAAS,EAAE,OAAO;AAAA,IACtB,iBAAiB,EAAE,OAAO,EAAE,SAAS,uCAAuC;AAAA,IAC5E,aAAa,EACV,OAAO,EACP,SAAS,mEAAmE;AAAA,IAC/E,WAAW,EACR,OAAO,EACP,SAAS,qDAAqD;AAAA,EACnE,CAAC;AAED,SAAO,KAAK;AAAA,IACV,aAAa,OAAO,eAAe;AAAA,IACnC,aAAa;AAAA,IACb,SAAS,OAAO,WAAW;AACzB,YAAM,SAAS,MAAM;AAAA,QACnB;AAAA,UACE,iBAAiB,OAAO;AAAA,UACxB,aAAa,OAAO;AAAA,UACpB,WAAW,OAAO;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAEA,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,IAAI,MAAM,wBAAwB,OAAO,KAAK,EAAE;AAAA,MACxD;AAEA,aAAO;AAAA,QACL,SAAS;AAAA,QACT,UAAU,OAAO;AAAA,QACjB,SAAS,OAAO;AAAA,QAChB,OAAO,OAAO;AAAA,MAChB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAGA,IAAO,iBAAQ;","names":[]}
|
|
@@ -851,7 +851,7 @@ declare class VercelToolFactory {
|
|
|
851
851
|
*/
|
|
852
852
|
createEditFileTool(toolConfig?: Omit<EditFileConfig, 'morphApiKey'>): ai.Tool<{
|
|
853
853
|
target_filepath: string;
|
|
854
|
-
|
|
854
|
+
instruction: string;
|
|
855
855
|
code_edit: string;
|
|
856
856
|
}, {
|
|
857
857
|
success: boolean;
|