@morphllm/morphsdk 0.2.122 → 0.2.124
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-T3T4LGRD.js → chunk-27BLOUAR.js} +27 -3
- package/dist/chunk-27BLOUAR.js.map +1 -0
- package/dist/{chunk-2MJEULZU.js → chunk-34UAUD5I.js} +2 -2
- package/dist/{chunk-OTGBQEVH.js → chunk-3ZO2UAYM.js} +2 -2
- package/dist/{chunk-L4URLBKV.js → chunk-A2OVRHEW.js} +3 -3
- package/dist/{chunk-7KOUCN6T.js → chunk-BFJAFWMR.js} +2 -2
- package/dist/{chunk-5UUJULLM.js → chunk-DUJ32DHI.js} +2 -2
- package/dist/{chunk-73GZ6KUK.js → chunk-EIJAUTHH.js} +2 -2
- package/dist/{chunk-OWISPSLH.js → chunk-F7VTQZH7.js} +2 -2
- package/dist/{chunk-WYYR2EU6.js → chunk-GVGJIXV2.js} +7 -2
- package/dist/chunk-GVGJIXV2.js.map +1 -0
- package/dist/{chunk-MQWEZJTP.js → chunk-HHRHUUGN.js} +5 -5
- package/dist/chunk-HHRHUUGN.js.map +1 -0
- package/dist/{chunk-TBLMIAIH.js → chunk-ICLIJKYL.js} +25 -3
- package/dist/chunk-ICLIJKYL.js.map +1 -0
- package/dist/{chunk-4GEBF5OH.js → chunk-KAI2DLL5.js} +2 -2
- package/dist/{chunk-GTANVDUZ.js → chunk-KQRX2K2W.js} +2 -2
- package/dist/{chunk-4LA3OT4Q.js → chunk-M6VWLSL4.js} +25 -4
- package/dist/chunk-M6VWLSL4.js.map +1 -0
- package/dist/{chunk-EBROW6GK.js → chunk-N6YX3M4I.js} +2 -2
- package/dist/chunk-OTOVGCG6.js +42 -0
- package/dist/chunk-OTOVGCG6.js.map +1 -0
- package/dist/{chunk-TXT3W4QK.js → chunk-S4RLT56A.js} +81 -3
- package/dist/chunk-S4RLT56A.js.map +1 -0
- package/dist/{chunk-RNKHRNSG.js → chunk-SGRNIWJD.js} +2 -2
- package/dist/{chunk-RNKHRNSG.js.map → chunk-SGRNIWJD.js.map} +1 -1
- package/dist/{chunk-QGE7FGGT.js → chunk-STPK3AAF.js} +2 -2
- package/dist/{chunk-64KNVHR4.js → chunk-V3HLOZK2.js} +1 -1
- package/dist/{chunk-64KNVHR4.js.map → chunk-V3HLOZK2.js.map} +1 -1
- package/dist/{chunk-LE24SVVU.js → chunk-VKQLHW6G.js} +2 -2
- package/dist/{chunk-3PMFQ5AV.js → chunk-W4PYHVIJ.js} +2 -2
- package/dist/{chunk-2AQLRL4U.js → chunk-WG5E7MMA.js} +2 -2
- package/dist/{chunk-4IU2K63O.js → chunk-Z7U7ZRMP.js} +2 -2
- package/dist/{chunk-ZHRT6F72.js → chunk-ZD5PEXNS.js} +1 -1
- package/dist/{chunk-UDGJQBTC.js → chunk-ZVVCJGNL.js} +15 -15
- package/dist/{client-BJrzbMYL.d.ts → client-JHPwle1Z.d.ts} +1 -1
- package/dist/client.cjs +84 -9
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +22 -22
- package/dist/edge.cjs +1 -1
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +4 -4
- package/dist/index.cjs +84 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -23
- 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/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/fastapply/anthropic.cjs +1 -1
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +4 -4
- package/dist/tools/fastapply/apply.cjs +1 -1
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +1 -1
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +3 -3
- package/dist/tools/fastapply/index.cjs +1 -1
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +6 -6
- package/dist/tools/fastapply/openai.cjs +1 -1
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +4 -4
- package/dist/tools/fastapply/vercel.cjs +1 -1
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +4 -4
- package/dist/tools/index.cjs +1 -1
- package/dist/tools/index.cjs.map +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 +4 -4
- 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 +123 -9
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +29 -2
- package/dist/tools/warp_grep/anthropic.js +8 -6
- package/dist/tools/warp_grep/client.cjs +90 -5
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.d.ts +27 -2
- package/dist/tools/warp_grep/client.js +8 -4
- package/dist/tools/warp_grep/gemini.cjs +120 -7
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +29 -2
- package/dist/tools/warp_grep/gemini.js +36 -5
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/index.cjs +116 -9
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +32 -4
- package/dist/tools/warp_grep/index.js +16 -6
- package/dist/tools/warp_grep/openai.cjs +126 -9
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +29 -2
- package/dist/tools/warp_grep/openai.js +8 -6
- package/dist/tools/warp_grep/providers/code_storage_http.cjs +6 -1
- package/dist/tools/warp_grep/providers/code_storage_http.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/code_storage_http.d.ts +1 -1
- package/dist/tools/warp_grep/providers/code_storage_http.js +1 -1
- package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
- package/dist/tools/warp_grep/vercel.cjs +101 -6
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +30 -2
- package/dist/tools/warp_grep/vercel.js +8 -6
- package/dist/{types-CA7989hK.d.ts → types-DY_hq2eZ.d.ts} +37 -1
- 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-4LA3OT4Q.js.map +0 -1
- package/dist/chunk-KJZMKDDP.js +0 -23
- package/dist/chunk-KJZMKDDP.js.map +0 -1
- package/dist/chunk-MQWEZJTP.js.map +0 -1
- package/dist/chunk-T3T4LGRD.js.map +0 -1
- package/dist/chunk-TBLMIAIH.js.map +0 -1
- package/dist/chunk-TXT3W4QK.js.map +0 -1
- package/dist/chunk-WYYR2EU6.js.map +0 -1
- /package/dist/{chunk-2MJEULZU.js.map → chunk-34UAUD5I.js.map} +0 -0
- /package/dist/{chunk-OTGBQEVH.js.map → chunk-3ZO2UAYM.js.map} +0 -0
- /package/dist/{chunk-L4URLBKV.js.map → chunk-A2OVRHEW.js.map} +0 -0
- /package/dist/{chunk-7KOUCN6T.js.map → chunk-BFJAFWMR.js.map} +0 -0
- /package/dist/{chunk-5UUJULLM.js.map → chunk-DUJ32DHI.js.map} +0 -0
- /package/dist/{chunk-73GZ6KUK.js.map → chunk-EIJAUTHH.js.map} +0 -0
- /package/dist/{chunk-OWISPSLH.js.map → chunk-F7VTQZH7.js.map} +0 -0
- /package/dist/{chunk-4GEBF5OH.js.map → chunk-KAI2DLL5.js.map} +0 -0
- /package/dist/{chunk-GTANVDUZ.js.map → chunk-KQRX2K2W.js.map} +0 -0
- /package/dist/{chunk-EBROW6GK.js.map → chunk-N6YX3M4I.js.map} +0 -0
- /package/dist/{chunk-QGE7FGGT.js.map → chunk-STPK3AAF.js.map} +0 -0
- /package/dist/{chunk-LE24SVVU.js.map → chunk-VKQLHW6G.js.map} +0 -0
- /package/dist/{chunk-3PMFQ5AV.js.map → chunk-W4PYHVIJ.js.map} +0 -0
- /package/dist/{chunk-2AQLRL4U.js.map → chunk-WG5E7MMA.js.map} +0 -0
- /package/dist/{chunk-4IU2K63O.js.map → chunk-Z7U7ZRMP.js.map} +0 -0
- /package/dist/{chunk-ZHRT6F72.js.map → chunk-ZD5PEXNS.js.map} +0 -0
- /package/dist/{chunk-UDGJQBTC.js.map → chunk-ZVVCJGNL.js.map} +0 -0
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
+
GITHUB_READ_FILE_DESCRIPTION,
|
|
3
|
+
GITHUB_READ_FILE_INPUT_SCHEMA,
|
|
4
|
+
GITHUB_READ_FILE_TOOL_NAME,
|
|
2
5
|
GITHUB_SEARCH_DESCRIPTION,
|
|
3
6
|
GITHUB_SEARCH_INPUT_SCHEMA,
|
|
4
7
|
GITHUB_SEARCH_TOOL_NAME,
|
|
5
8
|
WARP_GREP_DESCRIPTION,
|
|
6
9
|
WARP_GREP_TOOL_NAME
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OTOVGCG6.js";
|
|
8
11
|
import {
|
|
9
12
|
WarpGrepClient,
|
|
13
|
+
executeGitHubReadFile,
|
|
10
14
|
executeToolCall,
|
|
15
|
+
formatGitHubReadFileResult,
|
|
11
16
|
formatResult
|
|
12
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-S4RLT56A.js";
|
|
13
18
|
import {
|
|
14
19
|
getSystemPrompt
|
|
15
20
|
} from "./chunk-FMLHRJDF.js";
|
|
@@ -76,6 +81,24 @@ function createGitHubSearchTool(config) {
|
|
|
76
81
|
}
|
|
77
82
|
});
|
|
78
83
|
}
|
|
84
|
+
function createGitHubReadFileTool(config) {
|
|
85
|
+
const tool = {
|
|
86
|
+
type: "function",
|
|
87
|
+
function: {
|
|
88
|
+
name: GITHUB_READ_FILE_TOOL_NAME,
|
|
89
|
+
description: GITHUB_READ_FILE_DESCRIPTION,
|
|
90
|
+
parameters: GITHUB_READ_FILE_INPUT_SCHEMA
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return Object.assign(tool, {
|
|
94
|
+
execute: async (input) => {
|
|
95
|
+
return executeGitHubReadFile(input, config);
|
|
96
|
+
},
|
|
97
|
+
formatResult: (result) => {
|
|
98
|
+
return formatGitHubReadFileResult(result);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
79
102
|
var openai_default = warpGrepTool;
|
|
80
103
|
|
|
81
104
|
export {
|
|
@@ -83,6 +106,7 @@ export {
|
|
|
83
106
|
execute,
|
|
84
107
|
createWarpGrepTool,
|
|
85
108
|
createGitHubSearchTool,
|
|
109
|
+
createGitHubReadFileTool,
|
|
86
110
|
openai_default
|
|
87
111
|
};
|
|
88
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-27BLOUAR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/openai.ts"],"sourcesContent":["/**\n * OpenAI SDK adapter for morph-warp-grep tool\n */\n\nimport type { ChatCompletionTool } from 'openai/resources/chat/completions';\nimport { executeToolCall, formatResult, WarpGrepClient, executeGitHubReadFile, formatGitHubReadFileResult } from './client.js';\nimport { WARP_GREP_DESCRIPTION, WARP_GREP_TOOL_NAME, GITHUB_SEARCH_TOOL_NAME, GITHUB_SEARCH_DESCRIPTION, GITHUB_SEARCH_INPUT_SCHEMA, GITHUB_READ_FILE_TOOL_NAME, GITHUB_READ_FILE_DESCRIPTION, GITHUB_READ_FILE_INPUT_SCHEMA, getSystemPrompt } from './prompts.js';\nimport type { WarpGrepToolConfig, WarpGrepResult, GitHubSearchToolConfig, GitHubReadFileInput, GitHubReadFileResult, GitHubReadFileToolConfig } from './types.js';\n\n/**\n * Input schema for the warp grep tool\n */\nconst TOOL_PARAMETERS = {\n type: 'object',\n properties: {\n query: { type: 'string', description: 'Free-form repository question' },\n },\n required: ['query'],\n} as const;\n\n/**\n * OpenAI-native warp grep tool definition\n * \n * @example\n * ```typescript\n * import OpenAI from 'openai';\n * import { warpGrepTool, execute } from '@morphllm/morphsdk/tools/warp-grep/openai';\n * \n * const client = new OpenAI();\n * const response = await client.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [warpGrepTool],\n * messages: [{ role: 'user', content: 'Find authentication middleware' }]\n * });\n * \n * // Execute the tool call\n * const result = await execute({ query: '...' }, { repoRoot: '.' });\n * ```\n */\nexport const warpGrepTool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: WARP_GREP_TOOL_NAME,\n description: WARP_GREP_DESCRIPTION,\n parameters: TOOL_PARAMETERS,\n },\n};\n\n/**\n * Execute warp grep search\n * \n * @param input - Tool input with query\n * @param config - Configuration with repoRoot and optional provider\n * @returns Search results\n */\nexport async function execute(\n input: { query: string } | string,\n config: WarpGrepToolConfig\n): Promise<WarpGrepResult> {\n return executeToolCall(input, config);\n}\n\n// Re-export formatResult and getSystemPrompt for convenience\nexport { formatResult, getSystemPrompt };\n\n/**\n * Create a custom warp grep tool with configuration and methods\n * \n * @param config - Configuration options\n * @returns Tool definition with execute and formatResult methods\n * \n * @example Local usage\n * ```typescript\n * import OpenAI from 'openai';\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/openai';\n * \n * const tool = createWarpGrepTool({ repoRoot: '.' });\n * \n * const client = new OpenAI();\n * const response = await client.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'Find authentication middleware' }]\n * });\n * ```\n * \n * @example Remote sandbox (E2B, Modal, etc.)\n * ```typescript\n * const tool = createMorphWarpGrepTool({\n * repoRoot: '/home/repo',\n * remoteCommands: {\n * grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,\n * read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,\n * listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,\n * },\n * });\n * ```\n */\nexport function createWarpGrepTool(config: WarpGrepToolConfig) {\n const tool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: config.name ?? WARP_GREP_TOOL_NAME,\n description: config.description ?? WARP_GREP_DESCRIPTION,\n parameters: TOOL_PARAMETERS,\n },\n };\n\n return Object.assign(tool, {\n execute: async (input: unknown): Promise<WarpGrepResult> => {\n return executeToolCall(input as { query: string } | string, config);\n },\n formatResult: (result: WarpGrepResult): string => {\n return formatResult(result);\n },\n getSystemPrompt: (): string => {\n return getSystemPrompt();\n },\n });\n}\n\n/**\n * Create a GitHub search tool for OpenAI SDK\n *\n * @param config - Configuration options (morphApiKey, morphApiUrl, codeSearchUrl, timeout)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import OpenAI from 'openai';\n * import { createGitHubSearchTool } from '@morphllm/morphsdk/tools/warp-grep/openai';\n *\n * const tool = createGitHubSearchTool({ morphApiKey: process.env.MORPH_API_KEY });\n *\n * const response = await openai.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'How does auth work in vercel/next.js?' }]\n * });\n *\n * // Execute\n * const result = await tool.execute({ query: 'auth middleware', github: 'vercel/next.js' });\n * console.log(tool.formatResult(result));\n * ```\n */\nexport function createGitHubSearchTool(config: GitHubSearchToolConfig) {\n const client = new WarpGrepClient(config);\n\n const tool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: GITHUB_SEARCH_TOOL_NAME,\n description: GITHUB_SEARCH_DESCRIPTION,\n parameters: GITHUB_SEARCH_INPUT_SCHEMA,\n },\n };\n\n return Object.assign(tool, {\n execute: async (input: { query: string; github: string; branch?: string }): Promise<WarpGrepResult> => {\n return client.searchGitHub(input);\n },\n formatResult: (result: WarpGrepResult): string => {\n return formatResult(result);\n },\n getSystemPrompt: (): string => {\n return getSystemPrompt();\n },\n });\n}\n\n/**\n * Create a GitHub read file tool for OpenAI SDK\n *\n * @param config - Optional configuration (timeout)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import OpenAI from 'openai';\n * import { createGitHubReadFileTool } from '@morphllm/morphsdk/tools/warp-grep/openai';\n *\n * const tool = createGitHubReadFileTool();\n *\n * const response = await openai.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'Read the package.json from vercel/next.js' }]\n * });\n *\n * const result = await tool.execute({ github: 'vercel/next.js', path: 'package.json' });\n * console.log(tool.formatResult(result));\n * ```\n */\nexport function createGitHubReadFileTool(config?: GitHubReadFileToolConfig) {\n const tool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: GITHUB_READ_FILE_TOOL_NAME,\n description: GITHUB_READ_FILE_DESCRIPTION,\n parameters: GITHUB_READ_FILE_INPUT_SCHEMA,\n },\n };\n\n return Object.assign(tool, {\n execute: async (input: GitHubReadFileInput): Promise<GitHubReadFileResult> => {\n return executeGitHubReadFile(input, config);\n },\n formatResult: (result: GitHubReadFileResult): string => {\n return formatGitHubReadFileResult(result);\n },\n });\n}\n\nexport default warpGrepTool;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA,IAAM,kBAAkB;AAAA,EACtB,MAAM;AAAA,EACN,YAAY;AAAA,IACV,OAAO,EAAE,MAAM,UAAU,aAAa,gCAAgC;AAAA,EACxE;AAAA,EACA,UAAU,CAAC,OAAO;AACpB;AAqBO,IAAM,eAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,UAAU;AAAA,IACR,MAAM;AAAA,IACN,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AACF;AASA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AAsCO,S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H;AAEA,IAAO,iBAAQ;","names":[]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-YQMPVJ2L.js";
|
|
5
5
|
import {
|
|
6
6
|
executeCodebaseSearch
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DUJ32DHI.js";
|
|
8
8
|
|
|
9
9
|
// tools/codebase_search/openai.ts
|
|
10
10
|
var codebaseSearchTool = {
|
|
@@ -125,4 +125,4 @@ export {
|
|
|
125
125
|
getSystemPrompt,
|
|
126
126
|
openai_default
|
|
127
127
|
};
|
|
128
|
-
//# sourceMappingURL=chunk-
|
|
128
|
+
//# sourceMappingURL=chunk-34UAUD5I.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-2HMEZZKK.js";
|
|
5
5
|
import {
|
|
6
6
|
executeBrowserTask
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-A2OVRHEW.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -93,4 +93,4 @@ export {
|
|
|
93
93
|
createBrowserTool,
|
|
94
94
|
openai_exports
|
|
95
95
|
};
|
|
96
|
-
//# sourceMappingURL=chunk-
|
|
96
|
+
//# sourceMappingURL=chunk-3ZO2UAYM.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProfilesClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KQRX2K2W.js";
|
|
4
4
|
import {
|
|
5
5
|
buildEmbedCode,
|
|
6
6
|
buildLiveIframe,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
fetchWithRetry,
|
|
12
12
|
withTimeout
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-EIJAUTHH.js";
|
|
14
14
|
|
|
15
15
|
// tools/browser/core.ts
|
|
16
16
|
var DEFAULT_CONFIG = {
|
|
@@ -609,4 +609,4 @@ export {
|
|
|
609
609
|
getWebp,
|
|
610
610
|
checkHealth
|
|
611
611
|
};
|
|
612
|
-
//# sourceMappingURL=chunk-
|
|
612
|
+
//# sourceMappingURL=chunk-A2OVRHEW.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-YQMPVJ2L.js";
|
|
4
4
|
import {
|
|
5
5
|
executeCodebaseSearch
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DUJ32DHI.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-BFJAFWMR.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fetchWithRetry,
|
|
3
3
|
withTimeout
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EIJAUTHH.js";
|
|
5
5
|
|
|
6
6
|
// tools/codebase_search/core.ts
|
|
7
7
|
var CodebaseSearchClient = class {
|
|
@@ -102,4 +102,4 @@ export {
|
|
|
102
102
|
CodebaseSearchClient,
|
|
103
103
|
executeCodebaseSearch
|
|
104
104
|
};
|
|
105
|
-
//# sourceMappingURL=chunk-
|
|
105
|
+
//# sourceMappingURL=chunk-DUJ32DHI.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SDK_VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SGRNIWJD.js";
|
|
4
4
|
|
|
5
5
|
// tools/utils/resilience.ts
|
|
6
6
|
var DEFAULT_RETRY_CONFIG = {
|
|
@@ -91,4 +91,4 @@ export {
|
|
|
91
91
|
withTimeout,
|
|
92
92
|
MorphError
|
|
93
93
|
};
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-EIJAUTHH.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-YQMPVJ2L.js";
|
|
5
5
|
import {
|
|
6
6
|
executeCodebaseSearch
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DUJ32DHI.js";
|
|
8
8
|
|
|
9
9
|
// tools/codebase_search/anthropic.ts
|
|
10
10
|
function createCodebaseSearchTool(config) {
|
|
@@ -80,4 +80,4 @@ function formatResult(result) {
|
|
|
80
80
|
export {
|
|
81
81
|
createCodebaseSearchTool
|
|
82
82
|
};
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
83
|
+
//# sourceMappingURL=chunk-F7VTQZH7.js.map
|
|
@@ -7,7 +7,12 @@ async function post(url, body, op) {
|
|
|
7
7
|
});
|
|
8
8
|
if (!res.ok) {
|
|
9
9
|
const text = await res.text().catch(() => res.statusText);
|
|
10
|
-
|
|
10
|
+
try {
|
|
11
|
+
const parsed = JSON.parse(text);
|
|
12
|
+
if (parsed.error) return `Error: ${parsed.error}`;
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
return `Error: ${op} failed (${res.status}): ${text}`;
|
|
11
16
|
}
|
|
12
17
|
const data = await res.json();
|
|
13
18
|
if (data.error) throw new Error(data.error);
|
|
@@ -26,4 +31,4 @@ function createCodeStorageHttpCommands(config) {
|
|
|
26
31
|
export {
|
|
27
32
|
createCodeStorageHttpCommands
|
|
28
33
|
};
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-GVGJIXV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/providers/code_storage_http.ts"],"sourcesContent":["/**\n * HTTP-based RemoteCommands for code search against the Morph landing API.\n *\n * Translates grep/read/listDir into POST requests to the code-search endpoints,\n * so the WarpGrep agent can search GitHub repositories that have been indexed\n * by the Morph code storage service.\n */\n\nimport type { RemoteCommands } from '../types.js';\n\nexport interface CodeStorageHttpConfig {\n /** Base URL for the code search API (e.g. \"https://morphllm.com\") */\n baseUrl: string;\n /** Repository ID returned by the get-or-create endpoint */\n repoId: string;\n /** Git branch to search */\n branch: string;\n}\n\nasync function post(url: string, body: Record<string, unknown>, op: string): Promise<string> {\n const res = await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n });\n if (!res.ok) {\n const text = await res.text().catch(() => res.statusText);\n // Return error as content instead of throwing so the agent can handle it gracefully\n try {\n const parsed = JSON.parse(text);\n if (parsed.error) return `Error: ${parsed.error}`;\n } catch { /* not JSON, fall through */ }\n return `Error: ${op} failed (${res.status}): ${text}`;\n }\n const data = await res.json();\n if (data.error) throw new Error(data.error);\n return data.stdout;\n}\n\nexport function createCodeStorageHttpCommands(config: CodeStorageHttpConfig): RemoteCommands {\n const { baseUrl, repoId, branch } = config;\n const encodedRepoId = encodeURIComponent(repoId);\n\n return {\n grep: (pattern: string, path: string, glob?: string) =>\n post(`${baseUrl}/api/code-search/${encodedRepoId}/grep`, { pattern, path, glob, branch }, 'grep'),\n\n read: (path: string, start: number, end: number) =>\n post(`${baseUrl}/api/code-search/${encodedRepoId}/read`, { path, start, end, branch }, 'read'),\n\n listDir: (path: string, maxDepth: number) =>\n post(`${baseUrl}/api/code-search/${encodedRepoId}/list`, { path, maxDepth, branch }, 'list'),\n };\n}\n"],"mappings":";AAmBA,eAAe,KAAK,KAAa,MAA+B,IAA6B;AAC3F,QAAM,MAAM,MAAM,MAAM,KAAK;AAAA,IAC3B,QAAQ;AAAA,IACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,IAC9C,MAAM,KAAK,UAAU,IAAI;AAAA,EAC3B,CAAC;AACD,MAAI,CAAC,IAAI,IAAI;AACX,UAAM,OAAO,MAAM,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,UAAU;AAExD,QAAI;AACF,YAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,UAAI,OAAO,MAAO,QAAO,UAAU,OAAO,KAAK;AAAA,IACjD,QAAQ;AAAA,IAA+B;AACvC,WAAO,UAAU,EAAE,YAAY,IAAI,MAAM,MAAM,IAAI;AAAA,EACrD;AACA,QAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,MAAI,KAAK,MAAO,OAAM,IAAI,MAAM,KAAK,KAAK;AAC1C,SAAO,KAAK;AACd;AAEO,SAAS,8BAA8B,QAA+C;AAC3F,QAAM,EAAE,SAAS,QAAQ,OAAO,IAAI;AACpC,QAAM,gBAAgB,mBAAmB,MAAM;AAE/C,SAAO;AAAA,IACL,MAAM,CAAC,SAAiB,MAAc,SACpC,KAAK,GAAG,OAAO,oBAAoB,aAAa,SAAS,EAAE,SAAS,MAAM,MAAM,OAAO,GAAG,MAAM;AAAA,IAElG,MAAM,CAAC,MAAc,OAAe,QAClC,KAAK,GAAG,OAAO,oBAAoB,aAAa,SAAS,EAAE,MAAM,OAAO,KAAK,OAAO,GAAG,MAAM;AAAA,IAE/F,SAAS,CAAC,MAAc,aACtB,KAAK,GAAG,OAAO,oBAAoB,aAAa,SAAS,EAAE,MAAM,UAAU,OAAO,GAAG,MAAM;AAAA,EAC/F;AACF;","names":[]}
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "./chunk-FMLHRJDF.js";
|
|
24
24
|
import {
|
|
25
25
|
SDK_VERSION
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-SGRNIWJD.js";
|
|
27
27
|
|
|
28
28
|
// tools/warp_grep/agent/runner.ts
|
|
29
29
|
import OpenAI from "openai";
|
|
@@ -53,9 +53,9 @@ async function callModel(messages, model, options = {}) {
|
|
|
53
53
|
});
|
|
54
54
|
} catch (error) {
|
|
55
55
|
if (error instanceof OpenAI.APIError && error.status === 404) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
);
|
|
56
|
+
const defaultMsg = "The endpoint you are trying to call is likely deprecated. Please update with: npm cache clean --force && npx -y @morphllm/morphmcp@latest or visit: https://morphllm.com/mcp";
|
|
57
|
+
const errorText = error.message?.trim();
|
|
58
|
+
throw new Error(errorText || defaultMsg);
|
|
59
59
|
}
|
|
60
60
|
throw error;
|
|
61
61
|
}
|
|
@@ -406,4 +406,4 @@ export {
|
|
|
406
406
|
runWarpGrep,
|
|
407
407
|
runWarpGrepStreaming
|
|
408
408
|
};
|
|
409
|
-
//# sourceMappingURL=chunk-
|
|
409
|
+
//# sourceMappingURL=chunk-HHRHUUGN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/agent/runner.ts"],"sourcesContent":["import { AGENT_CONFIG, DEFAULT_MODEL } from './config.js';\nimport { getSystemPrompt } from './prompt.js';\nimport type { AgentRunResult, ChatMessage, SessionConfig, AgentFinish, WarpGrepExecutionMetrics, WarpGrepTurnMetrics, WarpGrepStep } from './types.js';\nimport { LLMResponseParser } from './parser.js';\nimport type { WarpGrepProvider } from '../providers/types.js';\nimport { toolGrep } from './tools/grep.js';\nimport { toolRead } from './tools/read.js';\nimport { toolListDirectory } from './tools/list_directory.js';\nimport { readFinishFiles } from './tools/finish.js';\nimport type { RetryConfig } from '../../utils/resilience.js';\nimport { formatAgentToolOutput } from './formatter.js';\nimport { formatTurnMessage, calculateContextBudget, buildInitialState, enforceContextLimit } from './helpers.js';\nimport OpenAI from 'openai';\nimport { SDK_VERSION } from '../../../version.js';\nimport path from 'path';\n\ntype EventName =\n | 'initial_state'\n | 'round_start'\n | 'round_end'\n | 'finish'\n | 'error';\n\nexport type EventCallback = (name: EventName, payload: Record<string, unknown>) => void;\n\nconst parser = new LLMResponseParser();\n\nconst DEFAULT_API_URL = 'https://api.morphllm.com';\n\ninterface CallModelOptions {\n morphApiKey?: string;\n morphApiUrl?: string;\n retryConfig?: RetryConfig;\n timeout?: number;\n}\n\nasync function callModel(\n messages: ChatMessage[],\n model: string,\n options: CallModelOptions = {}\n): Promise<string> {\n const baseUrl = options.morphApiUrl || DEFAULT_API_URL;\n const apiKey = options.morphApiKey || process.env.MORPH_API_KEY || '';\n const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;\n\n const client = new OpenAI({\n apiKey,\n baseURL: `${baseUrl}/v1`,\n maxRetries: options.retryConfig?.maxRetries,\n timeout: timeoutMs,\n defaultHeaders: { 'X-Morph-SDK-Version': SDK_VERSION },\n });\n\n const MAX_EMPTY_RETRIES = 1;\n\n for (let attempt = 0; attempt <= MAX_EMPTY_RETRIES; attempt++) {\n let data;\n try {\n data = await client.chat.completions.create({\n model,\n temperature: 0.0,\n max_tokens: 1024,\n messages,\n });\n } catch (error) {\n if (error instanceof OpenAI.APIError && error.status === 404) {\n const defaultMsg =\n 'The endpoint you are trying to call is likely deprecated. Please update with: npm cache clean --force && npx -y @morphllm/morphmcp@latest or visit: https://morphllm.com/mcp';\n const errorText = error.message?.trim();\n throw new Error(errorText || defaultMsg);\n }\n throw error;\n }\n\n const choice = data?.choices?.[0];\n const content = choice?.message?.content;\n\n if (content && typeof content === 'string') {\n return content;\n }\n\n // Last attempt — throw with diagnostics\n if (attempt === MAX_EMPTY_RETRIES) {\n const finishReason = choice?.finish_reason ?? 'unknown';\n const hasToolCalls = Array.isArray(choice?.message?.tool_calls) && choice.message.tool_calls.length > 0;\n const choicesLen = data?.choices?.length ?? 0;\n const contentType = content === null ? 'null' : content === undefined ? 'undefined' : typeof content;\n\n throw new Error(\n `Invalid response from model: content=${contentType}, finish_reason=${finishReason}, ` +\n `has_tool_calls=${hasToolCalls}, choices_length=${choicesLen}`\n );\n }\n\n // Retry — brief pause before next attempt\n await new Promise(resolve => setTimeout(resolve, 200));\n }\n\n // Unreachable, but satisfies TypeScript\n throw new Error('Invalid response from model');\n}\n\nexport async function runWarpGrep(config: SessionConfig & { provider: WarpGrepProvider }): Promise<AgentRunResult> {\n const totalStart = Date.now();\n const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;\n const timings: Partial<WarpGrepExecutionMetrics> = { turns: [], timeout_ms: timeoutMs };\n \n const repoRoot = path.resolve(config.repoRoot || process.cwd());\n const messages: ChatMessage[] = [];\n\n messages.push({ role: 'system' as const, content: getSystemPrompt() });\n \n const initialStateStart = Date.now();\n const initialState = await buildInitialState(repoRoot, config.query, config.provider);\n timings.initial_state_ms = Date.now() - initialStateStart;\n \n messages.push({ role: 'user', content: initialState });\n\n const maxTurns = AGENT_CONFIG.MAX_TURNS;\n const model = config.model || DEFAULT_MODEL;\n const provider = config.provider;\n const errors: Array<{ message: string }> = [];\n\n let finishMeta: AgentFinish | undefined;\n let terminationReason: AgentRunResult['terminationReason'] = 'terminated';\n\n for (let turn = 1; turn <= maxTurns; turn += 1) {\n const turnMetrics: WarpGrepTurnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };\n \n // Enforce hard context limit before calling model\n enforceContextLimit(messages);\n \n // call model\n const modelCallStart = Date.now();\n const assistantContent = await callModel(messages, model, {\n morphApiKey: config.morphApiKey,\n morphApiUrl: config.morphApiUrl,\n retryConfig: config.retryConfig,\n timeout: timeoutMs,\n }).catch((e: unknown) => {\n const errMsg = e instanceof Error ? e.message : String(e);\n console.error(`[warp_grep] Morph API call failed on turn ${turn}:`, errMsg);\n errors.push({ message: errMsg });\n return '';\n });\n turnMetrics.morph_api_ms = Date.now() - modelCallStart;\n\n if (!assistantContent) {\n console.error(`[warp_grep] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);\n timings.turns!.push(turnMetrics);\n break;\n }\n messages.push({ role: 'assistant', content: assistantContent });\n\n // parse tool calls (no longer throws - returns _skip calls for malformed commands)\n const toolCalls = parser.parse(assistantContent);\n if (toolCalls.length === 0) {\n console.error(`[warp_grep] No tool calls parsed on turn ${turn}. Assistant content (first 500 chars):`, assistantContent.slice(0, 500));\n errors.push({ message: 'No tool calls produced by the model. Your MCP is likely out of date! Update it by running: rm -rf ~/.npm/_npx && npm cache clean --force && npx -y @morphllm/morphmcp@latest' });\n terminationReason = 'terminated';\n timings.turns!.push(turnMetrics);\n break;\n }\n\n const finishCalls = toolCalls.filter(c => c.name === 'finish');\n const grepCalls = toolCalls.filter(c => c.name === 'grep');\n const listDirCalls = toolCalls.filter(c => c.name === 'list_directory');\n const readCalls = toolCalls.filter(c => c.name === 'read');\n const skipCalls = toolCalls.filter(c => c.name === '_skip');\n\n const formatted: string[] = [];\n\n // Surface any skipped commands as feedback to the LLM\n for (const c of skipCalls) {\n const msg = (c.arguments as { message?: string })?.message || 'Command skipped due to parsing error';\n formatted.push(msg);\n }\n\n const allPromises: Array<Promise<string>> = [];\n \n for (const c of grepCalls) {\n const args = (c.arguments ?? {}) as { pattern: string; path: string; glob?: string };\n allPromises.push(\n toolGrep(provider, args).then(\n ({ output }) => formatAgentToolOutput('grep', args, output, { isError: false }),\n err => formatAgentToolOutput('grep', args, String(err), { isError: true })\n )\n );\n }\n \n for (const c of listDirCalls) {\n const args = (c.arguments ?? {}) as { path: string; pattern?: string | null };\n allPromises.push(\n toolListDirectory(provider, args).then(\n p => formatAgentToolOutput('list_directory', args, p, { isError: false }),\n err => formatAgentToolOutput('list_directory', args, String(err), { isError: true })\n )\n );\n }\n \n for (const c of readCalls) {\n const args = (c.arguments ?? {}) as { path: string; start?: number; end?: number; lines?: Array<[number, number]> };\n allPromises.push(\n toolRead(provider, args).then(\n p => formatAgentToolOutput('read', args, p, { isError: false }),\n err => formatAgentToolOutput('read', args, String(err), { isError: true })\n )\n );\n }\n \n const toolExecStart = Date.now();\n const allResults = await Promise.all(allPromises);\n turnMetrics.local_tools_ms = Date.now() - toolExecStart;\n \n for (const result of allResults) {\n formatted.push(result);\n }\n\n if (formatted.length > 0) {\n const turnMessage = formatTurnMessage(turn, maxTurns);\n const contextBudget = calculateContextBudget(messages);\n messages.push({ role: 'user', content: formatted.join('\\n') + turnMessage + '\\n' + contextBudget });\n }\n\n timings.turns!.push(turnMetrics);\n\n if (finishCalls.length) {\n const fc = finishCalls[0];\n const files = ((fc.arguments as any)?.files ?? []) as AgentFinish['files'];\n const textResult = (fc.arguments as any)?.textResult as string | undefined;\n finishMeta = { files };\n terminationReason = 'completed';\n\n // Text-only finish: model returned a text response instead of file references\n // (e.g. \"No relevant code found\"). Surface the text to the parent LLM.\n if (files.length === 0) {\n const payload = textResult || 'No relevant code found.';\n timings.turns!.push(turnMetrics);\n timings.total_ms = Date.now() - totalStart;\n return {\n terminationReason: 'completed',\n messages,\n finish: { payload, metadata: finishMeta },\n timings: timings as WarpGrepExecutionMetrics,\n };\n }\n\n break;\n }\n }\n\n if (terminationReason !== 'completed' || !finishMeta) {\n timings.total_ms = Date.now() - totalStart;\n return { terminationReason, messages, errors, timings: timings as WarpGrepExecutionMetrics };\n }\n\n // Build finish payload\n const parts: string[] = ['Relevant context found:'];\n for (const f of finishMeta.files) {\n const ranges = f.lines === '*' ? '*'\n : Array.isArray(f.lines) ? f.lines.map(([s, e]) => `${s}-${e}`).join(', ')\n : '*';\n parts.push(`- ${f.path}: ${ranges}`);\n }\n const payload = parts.join('\\n');\n\n // Resolve file contents for returned ranges\n // Wrap reader in try-catch to handle non-existent or unreadable files gracefully\n // Track files that couldn't be read for error reporting\n const finishResolutionStart = Date.now();\n const fileReadErrors: Array<{ path: string; error: string }> = [];\n const resolved = await readFinishFiles(\n repoRoot,\n finishMeta.files,\n async (p: string, s?: number, e?: number) => {\n try {\n const rr = await provider.read({ path: p, start: s, end: e });\n // rr.lines are \"line|content\" → strip the \"line|\" prefix\n return rr.lines.map(l => {\n const idx = l.indexOf('|');\n return idx >= 0 ? l.slice(idx + 1) : l;\n });\n } catch (err) {\n // File doesn't exist or can't be read - log error but don't throw\n // This handles cases where the agent hallucinated a path or the file was deleted\n const errorMsg = err instanceof Error ? err.message : String(err);\n fileReadErrors.push({ path: p, error: errorMsg });\n console.error(`[warp_grep] Failed to read file: ${p} - ${errorMsg}`);\n return [`[couldn't find: ${p}]`];\n }\n }\n );\n\n timings.finish_resolution_ms = Date.now() - finishResolutionStart;\n\n // Add file read errors to the result so MCP can report them\n if (fileReadErrors.length > 0) {\n errors.push(...fileReadErrors.map(e => ({ message: `File read error: ${e.path} - ${e.error}` })));\n }\n\n timings.total_ms = Date.now() - totalStart;\n return {\n terminationReason: 'completed',\n messages,\n finish: { payload, metadata: finishMeta, resolved },\n timings: timings as WarpGrepExecutionMetrics,\n };\n}\n\n/**\n * Streaming version of runWarpGrep that yields step information after each turn.\n * Yields WarpGrepStep with tool calls for each turn, then returns the final AgentRunResult.\n */\nexport async function* runWarpGrepStreaming(\n config: SessionConfig & { provider: WarpGrepProvider }\n): AsyncGenerator<WarpGrepStep, AgentRunResult, undefined> {\n const totalStart = Date.now();\n const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;\n const timings: Partial<WarpGrepExecutionMetrics> = { turns: [], timeout_ms: timeoutMs };\n\n const repoRoot = path.resolve(config.repoRoot || process.cwd());\n const messages: ChatMessage[] = [];\n\n messages.push({ role: 'system' as const, content: getSystemPrompt() });\n\n const initialStateStart = Date.now();\n const initialState = await buildInitialState(repoRoot, config.query, config.provider);\n timings.initial_state_ms = Date.now() - initialStateStart;\n\n messages.push({ role: 'user', content: initialState });\n\n const maxTurns = AGENT_CONFIG.MAX_TURNS;\n const model = config.model || DEFAULT_MODEL;\n const provider = config.provider;\n const errors: Array<{ message: string }> = [];\n\n let finishMeta: AgentFinish | undefined;\n let terminationReason: AgentRunResult['terminationReason'] = 'terminated';\n\n for (let turn = 1; turn <= maxTurns; turn += 1) {\n const turnMetrics: WarpGrepTurnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };\n\n // Enforce hard context limit before calling model\n enforceContextLimit(messages);\n\n // call model\n const modelCallStart = Date.now();\n const assistantContent = await callModel(messages, model, {\n morphApiKey: config.morphApiKey,\n morphApiUrl: config.morphApiUrl,\n retryConfig: config.retryConfig,\n timeout: timeoutMs,\n }).catch((e: unknown) => {\n const errMsg = e instanceof Error ? e.message : String(e);\n console.error(`[warp_grep:stream] Morph API call failed on turn ${turn}:`, errMsg);\n errors.push({ message: errMsg });\n return '';\n });\n turnMetrics.morph_api_ms = Date.now() - modelCallStart;\n\n if (!assistantContent) {\n console.error(`[warp_grep:stream] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);\n timings.turns!.push(turnMetrics);\n break;\n }\n messages.push({ role: 'assistant', content: assistantContent });\n\n // parse tool calls (no longer throws - returns _skip calls for malformed commands)\n const toolCalls = parser.parse(assistantContent);\n if (toolCalls.length === 0) {\n console.error(`[warp_grep:stream] No tool calls parsed on turn ${turn}. Assistant content (first 500 chars):`, assistantContent.slice(0, 500));\n errors.push({ message: 'No tool calls produced by the model. Your MCP is likely out of date! Update it by running: rm -rf ~/.npm/_npx && npm cache clean --force && npx -y @morphllm/morphmcp@latest' });\n terminationReason = 'terminated';\n timings.turns!.push(turnMetrics);\n break;\n }\n\n // Yield step with tool calls (before execution)\n yield {\n turn,\n toolCalls: toolCalls.map(c => ({\n name: c.name,\n arguments: c.arguments ?? {}\n }))\n };\n\n const finishCalls = toolCalls.filter(c => c.name === 'finish');\n const grepCalls = toolCalls.filter(c => c.name === 'grep');\n const listDirCalls = toolCalls.filter(c => c.name === 'list_directory');\n const readCalls = toolCalls.filter(c => c.name === 'read');\n const skipCalls = toolCalls.filter(c => c.name === '_skip');\n\n const formatted: string[] = [];\n\n // Surface any skipped commands as feedback to the LLM\n for (const c of skipCalls) {\n const msg = (c.arguments as { message?: string })?.message || 'Command skipped due to parsing error';\n formatted.push(msg);\n }\n\n const allPromises: Array<Promise<string>> = [];\n\n for (const c of grepCalls) {\n const args = (c.arguments ?? {}) as { pattern: string; path: string; glob?: string };\n allPromises.push(\n toolGrep(provider, args).then(\n ({ output }) => formatAgentToolOutput('grep', args, output, { isError: false }),\n err => formatAgentToolOutput('grep', args, String(err), { isError: true })\n )\n );\n }\n\n for (const c of listDirCalls) {\n const args = (c.arguments ?? {}) as { path: string; pattern?: string | null };\n allPromises.push(\n toolListDirectory(provider, args).then(\n p => formatAgentToolOutput('list_directory', args, p, { isError: false }),\n err => formatAgentToolOutput('list_directory', args, String(err), { isError: true })\n )\n );\n }\n\n for (const c of readCalls) {\n const args = (c.arguments ?? {}) as { path: string; start?: number; end?: number; lines?: Array<[number, number]> };\n allPromises.push(\n toolRead(provider, args).then(\n p => formatAgentToolOutput('read', args, p, { isError: false }),\n err => formatAgentToolOutput('read', args, String(err), { isError: true })\n )\n );\n }\n\n const toolExecStart = Date.now();\n const allResults = await Promise.all(allPromises);\n turnMetrics.local_tools_ms = Date.now() - toolExecStart;\n\n for (const result of allResults) {\n formatted.push(result);\n }\n\n if (formatted.length > 0) {\n const turnMessage = formatTurnMessage(turn, maxTurns);\n const contextBudget = calculateContextBudget(messages);\n messages.push({ role: 'user', content: formatted.join('\\n') + turnMessage + '\\n' + contextBudget });\n }\n\n timings.turns!.push(turnMetrics);\n\n if (finishCalls.length) {\n const fc = finishCalls[0];\n const files = ((fc.arguments as any)?.files ?? []) as AgentFinish['files'];\n const textResult = (fc.arguments as any)?.textResult as string | undefined;\n finishMeta = { files };\n terminationReason = 'completed';\n\n // Text-only finish: model returned a text response instead of file references\n if (files.length === 0) {\n const payload = textResult || 'No relevant code found.';\n timings.total_ms = Date.now() - totalStart;\n return {\n terminationReason: 'completed',\n messages,\n finish: { payload, metadata: finishMeta },\n timings: timings as WarpGrepExecutionMetrics,\n };\n }\n\n break;\n }\n }\n\n if (terminationReason !== 'completed' || !finishMeta) {\n timings.total_ms = Date.now() - totalStart;\n return { terminationReason, messages, errors, timings: timings as WarpGrepExecutionMetrics };\n }\n\n // Build finish payload\n const parts: string[] = ['Relevant context found:'];\n for (const f of finishMeta.files) {\n const ranges = f.lines === '*' ? '*'\n : Array.isArray(f.lines) ? f.lines.map(([s, e]) => `${s}-${e}`).join(', ')\n : '*';\n parts.push(`- ${f.path}: ${ranges}`);\n }\n const payload = parts.join('\\n');\n\n // Resolve file contents for returned ranges\n const finishResolutionStart = Date.now();\n const fileReadErrors: Array<{ path: string; error: string }> = [];\n const resolved = await readFinishFiles(\n repoRoot,\n finishMeta.files,\n async (p: string, s?: number, e?: number) => {\n try {\n const rr = await provider.read({ path: p, start: s, end: e });\n return rr.lines.map(l => {\n const idx = l.indexOf('|');\n return idx >= 0 ? l.slice(idx + 1) : l;\n });\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n fileReadErrors.push({ path: p, error: errorMsg });\n console.error(`[warp_grep] Failed to read file: ${p} - ${errorMsg}`);\n return [`[couldn't find: ${p}]`];\n }\n }\n );\n\n timings.finish_resolution_ms = Date.now() - finishResolutionStart;\n\n if (fileReadErrors.length > 0) {\n errors.push(...fileReadErrors.map(e => ({ message: `File read error: ${e.path} - ${e.error}` })));\n }\n\n timings.total_ms = Date.now() - totalStart;\n return {\n terminationReason: 'completed',\n messages,\n finish: { payload, metadata: finishMeta, resolved },\n timings: timings as WarpGrepExecutionMetrics,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,OAAO,YAAY;AAEnB,OAAO,UAAU;AAWjB,IAAM,SAAS,IAAI,kBAAkB;AAErC,IAAM,kBAAkB;AASxB,eAAe,UACb,UACA,OACA,UAA4B,CAAC,GACZ;AACjB,QAAM,UAAU,QAAQ,eAAe;AACvC,QAAM,SAAS,QAAQ,eAAe,QAAQ,IAAI,iBAAiB;AACnE,QAAM,YAAY,QAAQ,WAAW,aAAa;AAElD,QAAM,SAAS,IAAI,OAAO;AAAA,IACxB;AAAA,IACA,SAAS,GAAG,OAAO;AAAA,IACnB,YAAY,QAAQ,aAAa;AAAA,IACjC,SAAS;AAAA,IACT,gBAAgB,EAAE,uBAAuB,YAAY;AAAA,EACvD,CAAC;AAED,QAAM,oBAAoB;AAE1B,WAAS,UAAU,GAAG,WAAW,mBAAmB,WAAW;AAC7D,QAAI;AACJ,QAAI;AACF,aAAO,MAAM,OAAO,KAAK,YAAY,OAAO;AAAA,QAC1C;AAAA,QACA,aAAa;AAAA,Q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,EAAE,MAAM,GAAG,OAAO,SAAS,CAAC;AAChD,gBAAQ,MAAM,oCAAoC,CAAC,MAAM,QAAQ,EAAE;AACnE,eAAO,CAAC,mBAAmB,CAAC,GAAG;AAAA,MACjC;AAAA,IACF;AAAA,EACF;AAEA,UAAQ,uBAAuB,KAAK,IAAI,IAAI;AAE5C,MAAI,eAAe,SAAS,GAAG;AAC7B,WAAO,KAAK,GAAG,eAAe,IAAI,QAAM,EAAE,SAAS,oBAAoB,EAAE,IAAI,MAAM,EAAE,KAAK,GAAG,EAAE,CAAC;AAAA,EAClG;AAEA,UAAQ,WAAW,KAAK,IAAI,IAAI;AAChC,SAAO;AAAA,IACL,mBAAmB;AAAA,IACnB;AAAA,IACA,QAAQ,EAAE,SAAS,UAAU,YAAY,SAAS;AAAA,IAClD;AAAA,EACF;AACF;","names":["payload"]}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
+
GITHUB_READ_FILE_DESCRIPTION,
|
|
2
3
|
GITHUB_SEARCH_DESCRIPTION,
|
|
3
4
|
WARP_GREP_DESCRIPTION
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-OTOVGCG6.js";
|
|
5
6
|
import {
|
|
6
7
|
WarpGrepClient,
|
|
8
|
+
executeGitHubReadFile,
|
|
7
9
|
executeToolCall,
|
|
8
10
|
executeToolCallStreaming
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-S4RLT56A.js";
|
|
10
12
|
|
|
11
13
|
// tools/warp_grep/vercel.ts
|
|
12
14
|
import { tool } from "ai";
|
|
@@ -79,6 +81,25 @@ function createGitHubSearchTool(config) {
|
|
|
79
81
|
}
|
|
80
82
|
});
|
|
81
83
|
}
|
|
84
|
+
function createGitHubReadFileTool(config) {
|
|
85
|
+
return tool({
|
|
86
|
+
description: GITHUB_READ_FILE_DESCRIPTION,
|
|
87
|
+
inputSchema: z.object({
|
|
88
|
+
github: z.string().describe('owner/repo shorthand (e.g., "vercel/next.js")'),
|
|
89
|
+
path: z.string().describe("File path within the repository"),
|
|
90
|
+
startLine: z.number().optional().describe("Start line number (1-based)"),
|
|
91
|
+
endLine: z.number().optional().describe("End line number (1-based, inclusive)"),
|
|
92
|
+
branch: z.string().optional().describe("Branch to read from (defaults to repo default branch)")
|
|
93
|
+
}),
|
|
94
|
+
execute: async (params) => {
|
|
95
|
+
const result = await executeGitHubReadFile(params, config);
|
|
96
|
+
if (!result.success) {
|
|
97
|
+
throw new Error(`GitHub read file failed: ${result.error}`);
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
82
103
|
var vercel_default = createWarpGrepTool;
|
|
83
104
|
|
|
84
105
|
export {
|
|
@@ -86,6 +107,7 @@ export {
|
|
|
86
107
|
execute,
|
|
87
108
|
createWarpGrepTool,
|
|
88
109
|
createGitHubSearchTool,
|
|
110
|
+
createGitHubReadFileTool,
|
|
89
111
|
vercel_default
|
|
90
112
|
};
|
|
91
|
-
//# sourceMappingURL=chunk-
|
|
113
|
+
//# sourceMappingURL=chunk-ICLIJKYL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/vercel.ts"],"sourcesContent":["/**\n * Vercel AI SDK adapter for morph-warp-grep tool\n *\n * @example Using with your own Zod instance (recommended for avoiding version conflicts)\n * ```typescript\n * import { z } from 'zod'; // Your project's Zod\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const schema = z.object({\n * query: z.string().describe('Free-form repository question'),\n * });\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: schema,\n * });\n * ```\n */\n\nimport { tool } from 'ai';\nimport { z } from 'zod';\nimport { jsonSchema } from 'ai';\nimport { executeToolCall, executeToolCallStreaming, formatResult, WarpGrepClient, executeGitHubReadFile, formatGitHubReadFileResult } from './client.js';\nimport { WARP_GREP_DESCRIPTION, GITHUB_SEARCH_DESCRIPTION, GITHUB_READ_FILE_DESCRIPTION, getSystemPrompt } from './prompts.js';\nimport type { WarpGrepToolConfig, WarpGrepResult, GitHubSearchToolConfig, GitHubReadFileInput, GitHubReadFileResult, GitHubReadFileToolConfig } from './types.js';\nimport type { WarpGrepStep } from './agent/types.js';\n\n/**\n * Raw JSON Schema for warp grep input (no Zod dependency).\n * Use this with jsonSchema() from 'ai' if you have Zod version conflicts.\n *\n * @example\n * ```typescript\n * import { jsonSchema } from 'ai';\n * import { warpGrepJsonSchema, createWarpGrepToolWithSchema } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepToolWithSchema({\n * repoRoot: '.',\n * inputSchema: jsonSchema(warpGrepJsonSchema),\n * });\n * ```\n */\nexport const warpGrepJsonSchema = {\n type: 'object' as const,\n properties: {\n query: {\n type: 'string' as const,\n description: 'Free-form repository question',\n },\n },\n required: ['query'] as const,\n additionalProperties: false as const,\n};\n\n/** Type for the warp grep input */\nexport type WarpGrepInput = { query: string };\n\n/**\n * Extended config that accepts a custom inputSchema\n */\nexport interface WarpGrepVercelConfig extends WarpGrepToolConfig {\n /**\n * Custom Zod schema or AI SDK schema. Use this to provide your own Zod instance\n * to avoid version conflicts between your project and the SDK.\n *\n * @example Using your own Zod\n * ```typescript\n * import { z } from 'zod'; // Your Zod version\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: z.object({\n * query: z.string().describe('Free-form repository question'),\n * }),\n * });\n * ```\n *\n * @example Using jsonSchema (no Zod needed)\n * ```typescript\n * import { jsonSchema } from 'ai';\n * import { warpGrepJsonSchema } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: jsonSchema(warpGrepJsonSchema),\n * });\n * ```\n */\n inputSchema?: Parameters<typeof tool>[0]['inputSchema'];\n}\n\n/**\n * Execute warp grep search\n *\n * @param input - Tool input with query\n * @param config - Configuration with repoRoot and optional provider\n * @returns Search results\n */\nexport async function execute(\n input: { query: string },\n config: WarpGrepToolConfig\n): Promise<WarpGrepResult> {\n return executeToolCall(input, config);\n}\n\n// Re-export formatResult and getSystemPrompt for convenience\nexport { formatResult, getSystemPrompt };\n\n/**\n * Create Vercel AI SDK warp grep tool\n *\n * @param config - Configuration options\n * @returns Vercel AI SDK tool\n *\n * @example Local usage (uses SDK's Zod)\n * ```typescript\n * import { generateText } from 'ai';\n * import { anthropic } from '@ai-sdk/anthropic';\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepTool({ repoRoot: '.' });\n *\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { grep: grepTool },\n * prompt: 'Find authentication middleware'\n * });\n * ```\n *\n * @example With your own Zod (avoids version conflicts)\n * ```typescript\n * import { z } from 'zod'; // Your project's Zod\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: z.object({\n * query: z.string().describe('Free-form repository question'),\n * }),\n * });\n * ```\n *\n * @example Without Zod (using jsonSchema)\n * ```typescript\n * import { jsonSchema } from 'ai';\n * import { createWarpGrepTool, warpGrepJsonSchema } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: jsonSchema(warpGrepJsonSchema),\n * });\n * ```\n *\n * @example Remote sandbox (E2B, Modal, etc.)\n * ```typescript\n * const grepTool = createWarpGrepTool({\n * repoRoot: '/home/repo',\n * remoteCommands: {\n * grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,\n * read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,\n * listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,\n * },\n * });\n * ```\n */\nexport function createWarpGrepTool(config: WarpGrepVercelConfig) {\n // Use provided schema or fall back to SDK's Zod schema\n const schema = config.inputSchema ?? z.object({\n query: z.string().describe('Free-form repository question'),\n });\n\n return tool({\n description: config.description ?? WARP_GREP_DESCRIPTION,\n inputSchema: schema,\n execute: async (params: WarpGrepInput) => {\n // Use streaming execution to collect intermediate steps\n const steps: WarpGrepStep[] = [];\n const generator = executeToolCallStreaming(params, config);\n\n let result: WarpGrepResult;\n for (;;) {\n const { value, done } = await generator.next();\n if (done) {\n result = value;\n break;\n }\n steps.push(value);\n }\n\n if (!result!.success) {\n throw new Error(`Failed to search codebase: ${result!.error}`);\n }\n\n // Flatten all intermediate tool calls across turns for progress display\n const allToolCalls = steps.flatMap(s => s.toolCalls);\n return {\n success: true,\n contexts: result!.contexts,\n summary: result!.summary,\n progress: allToolCalls.length > 0 ? { turn: steps.length, toolCalls: allToolCalls } : undefined,\n };\n },\n });\n}\n\n/**\n * Create a GitHub search tool for Vercel AI SDK\n *\n * @param config - Configuration options (morphApiKey, morphApiUrl, codeSearchUrl, timeout)\n * @returns Vercel AI SDK tool\n *\n * @example\n * ```typescript\n * import { generateText } from 'ai';\n * import { anthropic } from '@ai-sdk/anthropic';\n * import { createGitHubSearchTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const githubTool = createGitHubSearchTool({ morphApiKey: process.env.MORPH_API_KEY });\n *\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { githubSearch: githubTool },\n * prompt: 'How does auth work in vercel/next.js?'\n * });\n * ```\n */\nexport function createGitHubSearchTool(config: GitHubSearchToolConfig) {\n const client = new WarpGrepClient(config);\n\n return tool({\n description: GITHUB_SEARCH_DESCRIPTION,\n inputSchema: z.object({\n query: z.string().describe('Natural language search query'),\n github: z.string().describe('GitHub URL or \"owner/repo\" shorthand'),\n branch: z.string().optional().describe('Branch to search (defaults to repo default branch)'),\n }),\n execute: async (params: { query: string; github: string; branch?: string }) => {\n const result = await client.searchGitHub(params);\n if (!result.success) {\n throw new Error(`GitHub search failed: ${result.error}`);\n }\n return {\n success: true,\n contexts: result.contexts,\n summary: result.summary,\n };\n },\n });\n}\n\n/**\n * Create a GitHub read file tool for Vercel AI SDK\n *\n * @param config - Optional configuration (timeout)\n * @returns Vercel AI SDK tool\n *\n * @example\n * ```typescript\n * import { generateText } from 'ai';\n * import { anthropic } from '@ai-sdk/anthropic';\n * import { createGitHubReadFileTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const readFileTool = createGitHubReadFileTool();\n *\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { readFile: readFileTool },\n * prompt: 'Read the package.json from vercel/next.js'\n * });\n * ```\n */\nexport function createGitHubReadFileTool(config?: GitHubReadFileToolConfig) {\n return tool({\n description: GITHUB_READ_FILE_DESCRIPTION,\n inputSchema: z.object({\n github: z.string().describe('owner/repo shorthand (e.g., \"vercel/next.js\")'),\n path: z.string().describe('File path within the repository'),\n startLine: z.number().optional().describe('Start line number (1-based)'),\n endLine: z.number().optional().describe('End line number (1-based, inclusive)'),\n branch: z.string().optional().describe('Branch to read from (defaults to repo default branch)'),\n }),\n execute: async (params: GitHubReadFileInput) => {\n const result = await executeGitHubReadFile(params, config);\n if (!result.success) {\n throw new Error(`GitHub read file failed: ${result.error}`);\n }\n return result;\n },\n });\n}\n\n// Default export for convenience\nexport default createWarpGrepTool;\n"],"mappings":";;;;;;;;;;;;;AAmBA,SAAS,YAAY;AACrB,SAAS,SAAS;AAsBX,IAAM,qBAAqB;AAAA,EAChC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,OAAO;AAAA,MACL,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,UAAU,CAAC,OAAO;AAAA,EAClB,sBAAsB;AACxB;AA8CA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AA8DO,SAAS,mBAAmB,QAA8B;AAE/D,QA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KAAK,EAAE;AAAA,MACzD;AACA,aAAO;AAAA,QACL,SAAS;AAAA,QACT,UAAU,OAAO;AAAA,QACjB,SAAS,OAAO;AAAA,MAClB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAuBO,SAAS,yBAAyB,QAAmC;AAC1E,SAAO,KAAK;AAAA,IACV,aAAa;AAAA,IACb,aAAa,EAAE,OAAO;AAAA,MACpB,QAAQ,EAAE,OAAO,EAAE,SAAS,+CAA+C;AAAA,MAC3E,MAAM,EAAE,OAAO,EAAE,SAAS,iCAAiC;AAAA,MAC3D,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,6BAA6B;AAAA,MACvE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,sCAAsC;AAAA,MAC9E,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,uDAAuD;AAAA,IAChG,CAAC;AAAA,IACD,SAAS,OAAO,WAAgC;AAC9C,YAAM,SAAS,MAAM,sBAAsB,QAAQ,MAAM;AACzD,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,IAAI,MAAM,4BAA4B,OAAO,KAAK,EAAE;AAAA,MAC5D;AACA,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;AAGA,IAAO,iBAAQ;","names":[]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-2HMEZZKK.js";
|
|
5
5
|
import {
|
|
6
6
|
executeBrowserTask
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-A2OVRHEW.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -77,4 +77,4 @@ export {
|
|
|
77
77
|
createBrowserTool,
|
|
78
78
|
anthropic_exports
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-KAI2DLL5.js.map
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-2VERUKO2.js";
|
|
13
13
|
import {
|
|
14
14
|
fetchWithRetry
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-EIJAUTHH.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-KQRX2K2W.js.map
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
+
GITHUB_READ_FILE_DESCRIPTION,
|
|
3
|
+
GITHUB_READ_FILE_INPUT_SCHEMA,
|
|
4
|
+
GITHUB_READ_FILE_TOOL_NAME,
|
|
2
5
|
GITHUB_SEARCH_DESCRIPTION,
|
|
3
6
|
GITHUB_SEARCH_INPUT_SCHEMA,
|
|
4
7
|
GITHUB_SEARCH_TOOL_NAME,
|
|
5
8
|
WARP_GREP_DESCRIPTION,
|
|
6
9
|
WARP_GREP_TOOL_NAME
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OTOVGCG6.js";
|
|
8
11
|
import {
|
|
9
12
|
WarpGrepClient,
|
|
13
|
+
executeGitHubReadFile,
|
|
10
14
|
executeToolCall,
|
|
15
|
+
formatGitHubReadFileResult,
|
|
11
16
|
formatResult
|
|
12
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-S4RLT56A.js";
|
|
13
18
|
import {
|
|
14
19
|
getSystemPrompt
|
|
15
20
|
} from "./chunk-FMLHRJDF.js";
|
|
@@ -67,11 +72,27 @@ function createGitHubSearchTool(config) {
|
|
|
67
72
|
}
|
|
68
73
|
});
|
|
69
74
|
}
|
|
75
|
+
function createGitHubReadFileTool(config) {
|
|
76
|
+
const tool = {
|
|
77
|
+
name: GITHUB_READ_FILE_TOOL_NAME,
|
|
78
|
+
description: GITHUB_READ_FILE_DESCRIPTION,
|
|
79
|
+
input_schema: GITHUB_READ_FILE_INPUT_SCHEMA
|
|
80
|
+
};
|
|
81
|
+
return Object.assign(tool, {
|
|
82
|
+
execute: async (input) => {
|
|
83
|
+
return executeGitHubReadFile(input, config);
|
|
84
|
+
},
|
|
85
|
+
formatResult: (result) => {
|
|
86
|
+
return formatGitHubReadFileResult(result);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
70
90
|
|
|
71
91
|
export {
|
|
72
92
|
warpGrepTool,
|
|
73
93
|
execute,
|
|
74
94
|
createWarpGrepTool,
|
|
75
|
-
createGitHubSearchTool
|
|
95
|
+
createGitHubSearchTool,
|
|
96
|
+
createGitHubReadFileTool
|
|
76
97
|
};
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
98
|
+
//# sourceMappingURL=chunk-M6VWLSL4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/anthropic.ts"],"sourcesContent":["/**\n * Anthropic SDK adapter for morph-warp-grep tool\n */\n\nimport type { Tool } from '@anthropic-ai/sdk/resources/messages';\nimport { executeToolCall, formatResult, WarpGrepClient, executeGitHubReadFile, formatGitHubReadFileResult } from './client.js';\nimport { WARP_GREP_DESCRIPTION, WARP_GREP_TOOL_NAME, GITHUB_SEARCH_TOOL_NAME, GITHUB_SEARCH_DESCRIPTION, GITHUB_SEARCH_INPUT_SCHEMA, GITHUB_READ_FILE_TOOL_NAME, GITHUB_READ_FILE_DESCRIPTION, GITHUB_READ_FILE_INPUT_SCHEMA, getSystemPrompt } from './prompts.js';\nimport type { WarpGrepToolConfig, WarpGrepResult, GitHubSearchToolConfig, GitHubReadFileInput, GitHubReadFileResult, GitHubReadFileToolConfig } from './types.js';\n\n/**\n * Input schema for the warp grep tool\n */\nconst INPUT_SCHEMA = {\n type: 'object',\n properties: {\n query: { type: 'string', description: 'Free-form repository question' },\n },\n required: ['query'],\n} as const;\n\n/**\n * Anthropic-native warp grep tool definition\n * \n * @example\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { warpGrepTool, execute } from '@morphllm/morphsdk/tools/warp-grep/anthropic';\n * \n * const client = new Anthropic();\n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [warpGrepTool],\n * messages: [{ role: 'user', content: 'Find authentication middleware' }]\n * });\n * \n * // Execute the tool call\n * const result = await execute({ query: '...' }, { repoRoot: '.' });\n * ```\n */\nexport const warpGrepTool: Tool = {\n name: WARP_GREP_TOOL_NAME,\n description: WARP_GREP_DESCRIPTION,\n input_schema: INPUT_SCHEMA,\n};\n\n/**\n * Execute warp grep search\n * \n * @param input - Tool input with query\n * @param config - Configuration with repoRoot and optional provider\n * @returns Search results\n */\nexport async function execute(\n input: { query: string } | string,\n config: WarpGrepToolConfig\n): Promise<WarpGrepResult> {\n return executeToolCall(input, config);\n}\n\n// Re-export formatResult and getSystemPrompt for convenience\nexport { formatResult, getSystemPrompt };\n\n/**\n * Create a custom warp grep tool with configuration and methods\n * \n * @param config - Configuration options\n * @returns Tool definition with execute and formatResult methods\n * \n * @example Local usage\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';\n * \n * const tool = createWarpGrepTool({ repoRoot: '.' });\n * \n * const client = new Anthropic();\n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'Find authentication middleware' }]\n * });\n * ```\n * \n * @example Remote sandbox (E2B, Modal, etc.)\n * ```typescript\n * const tool = createMorphWarpGrepTool({\n * repoRoot: '/home/repo',\n * remoteCommands: {\n * grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,\n * read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,\n * listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,\n * },\n * });\n * ```\n */\nexport function createWarpGrepTool(config: WarpGrepToolConfig) {\n const tool: Tool = {\n name: config.name ?? WARP_GREP_TOOL_NAME,\n description: config.description ?? WARP_GREP_DESCRIPTION,\n input_schema: INPUT_SCHEMA,\n };\n\n return Object.assign(tool, {\n execute: async (input: unknown): Promise<WarpGrepResult> => {\n return executeToolCall(input as { query: string } | string, config);\n },\n formatResult: (result: WarpGrepResult): string => {\n return formatResult(result);\n },\n getSystemPrompt: (): string => {\n return getSystemPrompt();\n },\n });\n}\n\n/**\n * Create a GitHub search tool for Anthropic SDK\n *\n * @param config - Configuration options (morphApiKey, morphApiUrl, codeSearchUrl, timeout)\n * @returns Anthropic Tool with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { createGitHubSearchTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';\n *\n * const tool = createGitHubSearchTool({ morphApiKey: process.env.MORPH_API_KEY });\n *\n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'How does auth work in vercel/next.js?' }]\n * });\n *\n * // Execute\n * const result = await tool.execute({ query: 'auth middleware', github: 'vercel/next.js' });\n * console.log(tool.formatResult(result));\n * ```\n */\nexport function createGitHubSearchTool(config: GitHubSearchToolConfig) {\n const client = new WarpGrepClient(config);\n\n const tool: Tool = {\n name: GITHUB_SEARCH_TOOL_NAME,\n description: GITHUB_SEARCH_DESCRIPTION,\n input_schema: GITHUB_SEARCH_INPUT_SCHEMA,\n };\n\n return Object.assign(tool, {\n execute: async (input: { query: string; github: string; branch?: string }): Promise<WarpGrepResult> => {\n return client.searchGitHub(input);\n },\n formatResult: (result: WarpGrepResult): string => {\n return formatResult(result);\n },\n getSystemPrompt: (): string => {\n return getSystemPrompt();\n },\n });\n}\n\n/**\n * Create a GitHub read file tool for Anthropic SDK\n *\n * @param config - Optional configuration (timeout)\n * @returns Anthropic Tool with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { createGitHubReadFileTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';\n *\n * const tool = createGitHubReadFileTool();\n *\n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'Read the package.json from vercel/next.js' }]\n * });\n *\n * const result = await tool.execute({ github: 'vercel/next.js', path: 'package.json' });\n * console.log(tool.formatResult(result));\n * ```\n */\nexport function createGitHubReadFileTool(config?: GitHubReadFileToolConfig) {\n const tool: Tool = {\n name: GITHUB_READ_FILE_TOOL_NAME,\n description: GITHUB_READ_FILE_DESCRIPTION,\n input_schema: GITHUB_READ_FILE_INPUT_SCHEMA,\n };\n\n return Object.assign(tool, {\n execute: async (input: GitHubReadFileInput): Promise<GitHubReadFileResult> => {\n return executeGitHubReadFile(input, config);\n },\n formatResult: (result: GitHubReadFileResult): string => {\n return formatGitHubReadFileResult(result);\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA,IAAM,eAAe;AAAA,EACnB,MAAM;AAAA,EACN,YAAY;AAAA,IACV,OAAO,EAAE,MAAM,UAAU,aAAa,gCAAgC;AAAA,EACxE;AAAA,EACA,UAAU,CAAC,OAAO;AACpB;AAqBO,IAAM,eAAqB;AAAA,EAChC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,cAAc;AAChB;AASA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AAsCO,SAAS,mBAAmB,QAA4B;AAC7D,QAAM,OAAa;AAAA,IACjB,MAAM,OAAO,QAAQ;AAAA,IACrB,aAAa,OAAO,eAAe;AAAA,IACnC,cAAc;AAAA,EAChB;AAEA,SAAO,OAAO,OAAO,MAAM;AAAA,IACzB,SAAS,OAAO,UAA4C;AAC1D,aAAO,gBAAgB,OAAqC,MAAM;AAAA,IACpE;AAAA,IACA,cAAc,CAAC,WAAmC;AAChD,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,IACA,iBAAiB,MAAc;AAC7B,aAAO,gBAAgB;AAAA,IACzB;AAAA,EACF,CAAC;AACH;AA0BO,SAAS,uBAAuB,QAAgC;AACrE,QAAM,SAAS,IAAI,eAAe,MAAM;AAExC,QAAM,OAAa;AAAA,IACjB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,cAAc;AAAA,EAChB;AAEA,SAAO,OAAO,OAAO,MAAM;AAAA,IACzB,SAAS,OAAO,UAAuF;AACrG,aAAO,OAAO,aAAa,KAAK;AAAA,IAClC;AAAA,IACA,cAAc,CAAC,WAAmC;AAChD,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,IACA,iBAAiB,MAAc;AAC7B,aAAO,gBAAgB;AAAA,IACzB;AAAA,EACF,CAAC;AACH;AAyBO,SAAS,yBAAyB,QAAmC;AAC1E,QAAM,OAAa;AAAA,IACjB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,cAAc;AAAA,EAChB;AAEA,SAAO,OAAO,OAAO,MAAM;AAAA,IACzB,SAAS,OAAO,UAA8D;AAC5E,aAAO,sBAAsB,OAAO,MAAM;AAAA,IAC5C;AAAA,IACA,cAAc,CAAC,WAAyC;AACtD,aAAO,2BAA2B,MAAM;AAAA,IAC1C;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SDK_VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SGRNIWJD.js";
|
|
4
4
|
|
|
5
5
|
// tools/fastapply/apply.ts
|
|
6
6
|
import { createTwoFilesPatch } from "diff";
|
|
@@ -116,4 +116,4 @@ export {
|
|
|
116
116
|
callMorphAPI,
|
|
117
117
|
applyEdit
|
|
118
118
|
};
|
|
119
|
-
//# sourceMappingURL=chunk-
|
|
119
|
+
//# sourceMappingURL=chunk-N6YX3M4I.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// tools/warp_grep/prompts.ts
|
|
2
|
+
var WARP_GREP_TOOL_NAME = "warpgrep_codebase_search";
|
|
3
|
+
var WARP_GREP_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase to gather context, and the task does not involve a single file or function which is provided by name, you should ALWAYS use the warpgrep codebase search tool first instead of running search commands. When the task requires exploration beyond a single known file, invoke warpgrep first with a natural-language query describing the target functionality, bug, or architectural concern. Warp Grep is a fast and accurate tool that can search for all relevant context in a codebase. Keep queries action-oriented (e.g., "Find where billing invoices are generated and emailed"), and after reviewing the summarized results, you may verify important findings with other search tools or direct file reads to ensure completeness. Warp Grep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task requires exploration beyond a single known file, ALWAYS default to warpgrep codebase search before other search mechanisms.';
|
|
4
|
+
var GITHUB_WARP_GREP_SEARCH_TOOL_NAME = "warpgrep_github_search";
|
|
5
|
+
var GITHUB_WARP_GREP_SEARCH_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase of a public GitHub repository (not your local workspace), use warpgrep_github_search instead of warpgrep_codebase_search. When the task requires understanding code in an external repo, invoke warpgrep_github_search with a GitHub URL or owner/repo shorthand (e.g., vercel/next.js) and a natural-language query describing the target functionality, bug, or architectural concern. WarpGrep searches GitHub repos the same way it searches local codebases: fast and accurate. Keep queries action-oriented (e.g., "Find where how the new use workflow directive works"), and after reviewing the results, you may verify important findings with other tools or direct file reads. WarpGrep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task involves exploring code in an external public repo, ALWAYS use warpgrep_github_search.';
|
|
6
|
+
var GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA = {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
query: { type: "string", description: "Natural language search query describing what to find in the repository" },
|
|
10
|
+
github: { type: "string", description: 'owner/repo shorthand (ex: "vercel/next.js" for "https://github.com/vercel/next.js")' },
|
|
11
|
+
branch: { type: "string", description: "Branch to search (defaults to the repository default branch)" }
|
|
12
|
+
},
|
|
13
|
+
required: ["query", "github"]
|
|
14
|
+
};
|
|
15
|
+
var GITHUB_SEARCH_TOOL_NAME = GITHUB_WARP_GREP_SEARCH_TOOL_NAME;
|
|
16
|
+
var GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;
|
|
17
|
+
var GITHUB_SEARCH_INPUT_SCHEMA = GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA;
|
|
18
|
+
var GITHUB_READ_FILE_TOOL_NAME = "readfile_github_search";
|
|
19
|
+
var GITHUB_READ_FILE_DESCRIPTION = "Read a single file (or a line range) from a public GitHub repository. Use this when you already know the exact file path you want to read, for example after finding it via warpgrep_github_search results. Takes owner/repo shorthand and the file path within the repo. Optionally specify startLine and endLine (1-based) to read a specific range. Returns the file content with line numbers.";
|
|
20
|
+
var GITHUB_READ_FILE_INPUT_SCHEMA = {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {
|
|
23
|
+
github: { type: "string", description: 'owner/repo shorthand (e.g., "vercel/next.js")' },
|
|
24
|
+
path: { type: "string", description: 'File path within the repository (e.g., "src/server/index.ts")' },
|
|
25
|
+
startLine: { type: "number", description: "Start line number (1-based). Omit to start from beginning." },
|
|
26
|
+
endLine: { type: "number", description: "End line number (1-based, inclusive). Omit to read to the end." },
|
|
27
|
+
branch: { type: "string", description: "Branch to read from (defaults to the repository default branch)" }
|
|
28
|
+
},
|
|
29
|
+
required: ["github", "path"]
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
WARP_GREP_TOOL_NAME,
|
|
34
|
+
WARP_GREP_DESCRIPTION,
|
|
35
|
+
GITHUB_SEARCH_TOOL_NAME,
|
|
36
|
+
GITHUB_SEARCH_DESCRIPTION,
|
|
37
|
+
GITHUB_SEARCH_INPUT_SCHEMA,
|
|
38
|
+
GITHUB_READ_FILE_TOOL_NAME,
|
|
39
|
+
GITHUB_READ_FILE_DESCRIPTION,
|
|
40
|
+
GITHUB_READ_FILE_INPUT_SCHEMA
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=chunk-OTOVGCG6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/prompts.ts"],"sourcesContent":["/**\n * Prompts and descriptions for warpgrep_codebase_search\n */\n\n/**\n * Default tool name for the warp grep tool\n */\nexport const WARP_GREP_TOOL_NAME = 'warpgrep_codebase_search';\n\n/**\n * Default tool description for the warp grep tool\n */\nexport const WARP_GREP_DESCRIPTION = \n 'IMPORTANT: If you need to explore the codebase to gather context, and the task does not involve a single file or function which is provided by name, you should ALWAYS use the warpgrep codebase search tool first instead of running search commands. ' +\n 'When the task requires exploration beyond a single known file, invoke warpgrep first with a natural-language query describing the target functionality, bug, or architectural concern. ' +\n 'Warp Grep is a fast and accurate tool that can search for all relevant context in a codebase. ' +\n 'Keep queries action-oriented (e.g., \"Find where billing invoices are generated and emailed\"), and after reviewing the summarized results, you may verify important findings with other search tools or direct file reads to ensure completeness. ' +\n 'Warp Grep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. ' +\n 'When a task requires exploration beyond a single known file, ALWAYS default to warpgrep codebase search before other search mechanisms.'\n\nexport const GITHUB_WARP_GREP_SEARCH_TOOL_NAME = 'warpgrep_github_search';\n\nexport const GITHUB_WARP_GREP_SEARCH_DESCRIPTION =\n 'IMPORTANT: If you need to explore the codebase of a public GitHub repository (not your local workspace), use warpgrep_github_search instead of warpgrep_codebase_search. ' +\n 'When the task requires understanding code in an external repo, invoke warpgrep_github_search with a GitHub URL or owner/repo shorthand (e.g., vercel/next.js) and a natural-language query describing the target functionality, bug, or architectural concern. ' +\n 'WarpGrep searches GitHub repos the same way it searches local codebases: fast and accurate. ' +\n 'Keep queries action-oriented (e.g., \"Find where how the new use workflow directive works\"), and after reviewing the results, you may verify important findings with other tools or direct file reads. ' +\n 'WarpGrep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. ' +\n 'When a task involves exploring code in an external public repo, ALWAYS use warpgrep_github_search.';\n\nexport const GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA = {\n type: 'object' as const,\n properties: {\n query: { type: 'string' as const, description: 'Natural language search query describing what to find in the repository' },\n github: { type: 'string' as const, description: 'owner/repo shorthand (ex: \"vercel/next.js\" for \"https://github.com/vercel/next.js\")' },\n branch: { type: 'string' as const, description: 'Branch to search (defaults to the repository default branch)' },\n },\n required: ['query', 'github'] as const,\n};\n\nexport const GITHUB_SEARCH_TOOL_NAME = GITHUB_WARP_GREP_SEARCH_TOOL_NAME;\nexport const GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;\nexport const GITHUB_SEARCH_INPUT_SCHEMA = GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA;\n\nexport const GITHUB_READ_FILE_TOOL_NAME = 'readfile_github_search';\n\nexport const GITHUB_READ_FILE_DESCRIPTION =\n 'Read a single file (or a line range) from a public GitHub repository. ' +\n 'Use this when you already know the exact file path you want to read, for example after finding it via warpgrep_github_search results. ' +\n 'Takes owner/repo shorthand and the file path within the repo. Optionally specify startLine and endLine (1-based) to read a specific range. ' +\n 'Returns the file content with line numbers.';\n\nexport const GITHUB_READ_FILE_INPUT_SCHEMA = {\n type: 'object' as const,\n properties: {\n github: { type: 'string' as const, description: 'owner/repo shorthand (e.g., \"vercel/next.js\")' },\n path: { type: 'string' as const, description: 'File path within the repository (e.g., \"src/server/index.ts\")' },\n startLine: { type: 'number' as const, description: 'Start line number (1-based). Omit to start from beginning.' },\n endLine: { type: 'number' as const, description: 'End line number (1-based, inclusive). Omit to read to the end.' },\n branch: { type: 'string' as const, description: 'Branch to read from (defaults to the repository default branch)' },\n },\n required: ['github', 'path'] as const,\n};\n\n/**\n * System prompt for the warp grep agent\n * Re-exported from agent/prompt.ts for convenience\n */\nexport { SYSTEM_PROMPT as WARP_GREP_SYSTEM_PROMPT, getSystemPrompt } from './agent/prompt.js';\n"],"mappings":";AAOO,IAAM,sBAAsB;AAK5B,IAAM,wBACX;AAOK,IAAM,oCAAoC;AAE1C,IAAM,sCACX;AAOK,IAAM,uCAAuC;AAAA,EAClD,MAAM;AAAA,EACN,YAAY;AAAA,IACV,OAAO,EAAE,MAAM,UAAmB,aAAa,0EAA0E;AAAA,IACzH,QAAQ,EAAE,MAAM,UAAmB,aAAa,sFAAsF;AAAA,IACtI,QAAQ,EAAE,MAAM,UAAmB,aAAa,+DAA+D;AAAA,EACjH;AAAA,EACA,UAAU,CAAC,SAAS,QAAQ;AAC9B;AAEO,IAAM,0BAA0B;AAChC,IAAM,4BAA4B;AAClC,IAAM,6BAA6B;AAEnC,IAAM,6BAA6B;AAEnC,IAAM,+BACX;AAKK,IAAM,gCAAgC;AAAA,EAC3C,MAAM;AAAA,EACN,YAAY;AAAA,IACV,QAAQ,EAAE,MAAM,UAAmB,aAAa,gDAAgD;AAAA,IAChG,MAAM,EAAE,MAAM,UAAmB,aAAa,gEAAgE;AAAA,IAC9G,WAAW,EAAE,MAAM,UAAmB,aAAa,6DAA6D;AAAA,IAChH,SAAS,EAAE,MAAM,UAAmB,aAAa,iEAAiE;AAAA,IAClH,QAAQ,EAAE,MAAM,UAAmB,aAAa,kEAAkE;AAAA,EACpH;AAAA,EACA,UAAU,CAAC,UAAU,MAAM;AAC7B;","names":[]}
|