@morphllm/morphsdk 0.2.122 → 0.2.123

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.
Files changed (170) hide show
  1. package/dist/{chunk-2AQLRL4U.js → chunk-5OJE7GH4.js} +2 -2
  2. package/dist/{chunk-4IU2K63O.js → chunk-ANPZFWYV.js} +2 -2
  3. package/dist/{chunk-OTGBQEVH.js → chunk-BJ2764MK.js} +2 -2
  4. package/dist/{chunk-GTANVDUZ.js → chunk-DBSOONOY.js} +2 -2
  5. package/dist/{chunk-TBLMIAIH.js → chunk-ETTCJWJK.js} +25 -3
  6. package/dist/chunk-ETTCJWJK.js.map +1 -0
  7. package/dist/{chunk-RNKHRNSG.js → chunk-FMKJ72KT.js} +2 -2
  8. package/dist/{chunk-RNKHRNSG.js.map → chunk-FMKJ72KT.js.map} +1 -1
  9. package/dist/{chunk-EBROW6GK.js → chunk-GXFJLL5O.js} +2 -2
  10. package/dist/{chunk-4LA3OT4Q.js → chunk-H3U7J5RI.js} +25 -4
  11. package/dist/chunk-H3U7J5RI.js.map +1 -0
  12. package/dist/{chunk-LE24SVVU.js → chunk-HVBJ4UO6.js} +2 -2
  13. package/dist/{chunk-73GZ6KUK.js → chunk-K74GLGST.js} +2 -2
  14. package/dist/{chunk-4GEBF5OH.js → chunk-KL3AMLGL.js} +2 -2
  15. package/dist/{chunk-3PMFQ5AV.js → chunk-L426IMZD.js} +2 -2
  16. package/dist/{chunk-TXT3W4QK.js → chunk-MXSGTN7R.js} +80 -2
  17. package/dist/chunk-MXSGTN7R.js.map +1 -0
  18. package/dist/{chunk-2MJEULZU.js → chunk-OFJYDTQI.js} +2 -2
  19. package/dist/chunk-OTOVGCG6.js +42 -0
  20. package/dist/chunk-OTOVGCG6.js.map +1 -0
  21. package/dist/{chunk-7KOUCN6T.js → chunk-QD7KPI7A.js} +2 -2
  22. package/dist/{chunk-T3T4LGRD.js → chunk-QGRFAVGK.js} +27 -3
  23. package/dist/chunk-QGRFAVGK.js.map +1 -0
  24. package/dist/{chunk-L4URLBKV.js → chunk-UHL2ZEWG.js} +3 -3
  25. package/dist/{chunk-5UUJULLM.js → chunk-UJS3AIWS.js} +2 -2
  26. package/dist/{chunk-QGE7FGGT.js → chunk-UX65IRCX.js} +2 -2
  27. package/dist/{chunk-64KNVHR4.js → chunk-V3HLOZK2.js} +1 -1
  28. package/dist/{chunk-64KNVHR4.js.map → chunk-V3HLOZK2.js.map} +1 -1
  29. package/dist/{chunk-UDGJQBTC.js → chunk-V4KBK66V.js} +15 -15
  30. package/dist/{chunk-ZHRT6F72.js → chunk-WE75QX2B.js} +1 -1
  31. package/dist/{chunk-OWISPSLH.js → chunk-XXL62KSJ.js} +2 -2
  32. package/dist/{chunk-MQWEZJTP.js → chunk-ZZCMAFN7.js} +5 -5
  33. package/dist/chunk-ZZCMAFN7.js.map +1 -0
  34. package/dist/{client-BJrzbMYL.d.ts → client-JHPwle1Z.d.ts} +1 -1
  35. package/dist/client.cjs +78 -8
  36. package/dist/client.cjs.map +1 -1
  37. package/dist/client.d.ts +2 -2
  38. package/dist/client.js +21 -21
  39. package/dist/edge.cjs +1 -1
  40. package/dist/edge.cjs.map +1 -1
  41. package/dist/edge.js +4 -4
  42. package/dist/index.cjs +78 -8
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.d.ts +2 -2
  45. package/dist/index.js +22 -22
  46. package/dist/modelrouter/core.cjs +1 -1
  47. package/dist/modelrouter/core.cjs.map +1 -1
  48. package/dist/modelrouter/core.js +3 -3
  49. package/dist/modelrouter/index.cjs +1 -1
  50. package/dist/modelrouter/index.cjs.map +1 -1
  51. package/dist/modelrouter/index.js +3 -3
  52. package/dist/tools/browser/anthropic.cjs +1 -1
  53. package/dist/tools/browser/anthropic.cjs.map +1 -1
  54. package/dist/tools/browser/anthropic.js +5 -5
  55. package/dist/tools/browser/core.cjs +1 -1
  56. package/dist/tools/browser/core.cjs.map +1 -1
  57. package/dist/tools/browser/core.js +4 -4
  58. package/dist/tools/browser/index.cjs +1 -1
  59. package/dist/tools/browser/index.cjs.map +1 -1
  60. package/dist/tools/browser/index.js +7 -7
  61. package/dist/tools/browser/openai.cjs +1 -1
  62. package/dist/tools/browser/openai.cjs.map +1 -1
  63. package/dist/tools/browser/openai.js +5 -5
  64. package/dist/tools/browser/profiles/core.cjs +1 -1
  65. package/dist/tools/browser/profiles/core.cjs.map +1 -1
  66. package/dist/tools/browser/profiles/core.js +3 -3
  67. package/dist/tools/browser/profiles/index.cjs +1 -1
  68. package/dist/tools/browser/profiles/index.cjs.map +1 -1
  69. package/dist/tools/browser/profiles/index.js +3 -3
  70. package/dist/tools/browser/vercel.cjs +1 -1
  71. package/dist/tools/browser/vercel.cjs.map +1 -1
  72. package/dist/tools/browser/vercel.js +5 -5
  73. package/dist/tools/codebase_search/anthropic.cjs +1 -1
  74. package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
  75. package/dist/tools/codebase_search/anthropic.js +4 -4
  76. package/dist/tools/codebase_search/core.cjs +1 -1
  77. package/dist/tools/codebase_search/core.cjs.map +1 -1
  78. package/dist/tools/codebase_search/core.js +3 -3
  79. package/dist/tools/codebase_search/index.cjs +1 -1
  80. package/dist/tools/codebase_search/index.cjs.map +1 -1
  81. package/dist/tools/codebase_search/index.js +6 -6
  82. package/dist/tools/codebase_search/openai.cjs +1 -1
  83. package/dist/tools/codebase_search/openai.cjs.map +1 -1
  84. package/dist/tools/codebase_search/openai.js +4 -4
  85. package/dist/tools/codebase_search/vercel.cjs +1 -1
  86. package/dist/tools/codebase_search/vercel.cjs.map +1 -1
  87. package/dist/tools/codebase_search/vercel.js +4 -4
  88. package/dist/tools/fastapply/anthropic.cjs +1 -1
  89. package/dist/tools/fastapply/anthropic.cjs.map +1 -1
  90. package/dist/tools/fastapply/anthropic.js +4 -4
  91. package/dist/tools/fastapply/apply.cjs +1 -1
  92. package/dist/tools/fastapply/apply.cjs.map +1 -1
  93. package/dist/tools/fastapply/apply.js +2 -2
  94. package/dist/tools/fastapply/core.cjs +1 -1
  95. package/dist/tools/fastapply/core.cjs.map +1 -1
  96. package/dist/tools/fastapply/core.js +3 -3
  97. package/dist/tools/fastapply/index.cjs +1 -1
  98. package/dist/tools/fastapply/index.cjs.map +1 -1
  99. package/dist/tools/fastapply/index.js +6 -6
  100. package/dist/tools/fastapply/openai.cjs +1 -1
  101. package/dist/tools/fastapply/openai.cjs.map +1 -1
  102. package/dist/tools/fastapply/openai.js +4 -4
  103. package/dist/tools/fastapply/vercel.cjs +1 -1
  104. package/dist/tools/fastapply/vercel.cjs.map +1 -1
  105. package/dist/tools/fastapply/vercel.js +4 -4
  106. package/dist/tools/index.cjs +1 -1
  107. package/dist/tools/index.cjs.map +1 -1
  108. package/dist/tools/index.js +6 -6
  109. package/dist/tools/utils/resilience.cjs +1 -1
  110. package/dist/tools/utils/resilience.cjs.map +1 -1
  111. package/dist/tools/utils/resilience.js +2 -2
  112. package/dist/tools/warp_grep/agent/runner.cjs +4 -4
  113. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  114. package/dist/tools/warp_grep/agent/runner.js +2 -2
  115. package/dist/tools/warp_grep/anthropic.cjs +117 -8
  116. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  117. package/dist/tools/warp_grep/anthropic.d.ts +29 -2
  118. package/dist/tools/warp_grep/anthropic.js +7 -5
  119. package/dist/tools/warp_grep/client.cjs +84 -4
  120. package/dist/tools/warp_grep/client.cjs.map +1 -1
  121. package/dist/tools/warp_grep/client.d.ts +27 -2
  122. package/dist/tools/warp_grep/client.js +7 -3
  123. package/dist/tools/warp_grep/gemini.cjs +114 -6
  124. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  125. package/dist/tools/warp_grep/gemini.d.ts +29 -2
  126. package/dist/tools/warp_grep/gemini.js +35 -4
  127. package/dist/tools/warp_grep/gemini.js.map +1 -1
  128. package/dist/tools/warp_grep/index.cjs +110 -8
  129. package/dist/tools/warp_grep/index.cjs.map +1 -1
  130. package/dist/tools/warp_grep/index.d.ts +32 -4
  131. package/dist/tools/warp_grep/index.js +15 -5
  132. package/dist/tools/warp_grep/openai.cjs +120 -8
  133. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  134. package/dist/tools/warp_grep/openai.d.ts +29 -2
  135. package/dist/tools/warp_grep/openai.js +7 -5
  136. package/dist/tools/warp_grep/providers/code_storage_http.d.ts +1 -1
  137. package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
  138. package/dist/tools/warp_grep/vercel.cjs +95 -5
  139. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  140. package/dist/tools/warp_grep/vercel.d.ts +30 -2
  141. package/dist/tools/warp_grep/vercel.js +7 -5
  142. package/dist/{types-CA7989hK.d.ts → types-DY_hq2eZ.d.ts} +37 -1
  143. package/dist/version.cjs +1 -1
  144. package/dist/version.cjs.map +1 -1
  145. package/dist/version.js +1 -1
  146. package/package.json +1 -1
  147. package/dist/chunk-4LA3OT4Q.js.map +0 -1
  148. package/dist/chunk-KJZMKDDP.js +0 -23
  149. package/dist/chunk-KJZMKDDP.js.map +0 -1
  150. package/dist/chunk-MQWEZJTP.js.map +0 -1
  151. package/dist/chunk-T3T4LGRD.js.map +0 -1
  152. package/dist/chunk-TBLMIAIH.js.map +0 -1
  153. package/dist/chunk-TXT3W4QK.js.map +0 -1
  154. /package/dist/{chunk-2AQLRL4U.js.map → chunk-5OJE7GH4.js.map} +0 -0
  155. /package/dist/{chunk-4IU2K63O.js.map → chunk-ANPZFWYV.js.map} +0 -0
  156. /package/dist/{chunk-OTGBQEVH.js.map → chunk-BJ2764MK.js.map} +0 -0
  157. /package/dist/{chunk-GTANVDUZ.js.map → chunk-DBSOONOY.js.map} +0 -0
  158. /package/dist/{chunk-EBROW6GK.js.map → chunk-GXFJLL5O.js.map} +0 -0
  159. /package/dist/{chunk-LE24SVVU.js.map → chunk-HVBJ4UO6.js.map} +0 -0
  160. /package/dist/{chunk-73GZ6KUK.js.map → chunk-K74GLGST.js.map} +0 -0
  161. /package/dist/{chunk-4GEBF5OH.js.map → chunk-KL3AMLGL.js.map} +0 -0
  162. /package/dist/{chunk-3PMFQ5AV.js.map → chunk-L426IMZD.js.map} +0 -0
  163. /package/dist/{chunk-2MJEULZU.js.map → chunk-OFJYDTQI.js.map} +0 -0
  164. /package/dist/{chunk-7KOUCN6T.js.map → chunk-QD7KPI7A.js.map} +0 -0
  165. /package/dist/{chunk-L4URLBKV.js.map → chunk-UHL2ZEWG.js.map} +0 -0
  166. /package/dist/{chunk-5UUJULLM.js.map → chunk-UJS3AIWS.js.map} +0 -0
  167. /package/dist/{chunk-QGE7FGGT.js.map → chunk-UX65IRCX.js.map} +0 -0
  168. /package/dist/{chunk-UDGJQBTC.js.map → chunk-V4KBK66V.js.map} +0 -0
  169. /package/dist/{chunk-ZHRT6F72.js.map → chunk-WE75QX2B.js.map} +0 -0
  170. /package/dist/{chunk-OWISPSLH.js.map → chunk-XXL62KSJ.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { FunctionDeclaration } from '@google/generative-ai';
2
2
  export { formatResult } from './client.js';
3
3
  export { getSystemPrompt } from './agent/prompt.js';
4
- import { d as WarpGrepToolConfig, b as WarpGrepResult, e as GitHubSearchToolConfig } from '../../types-CA7989hK.js';
4
+ import { d as WarpGrepToolConfig, b as WarpGrepResult, g as GitHubSearchToolConfig, h as GitHubReadFileToolConfig, e as GitHubReadFileInput, f as GitHubReadFileResult } from '../../types-DY_hq2eZ.js';
5
5
  import './agent/types.js';
6
6
  import '../utils/resilience.js';
7
7
  import './providers/types.js';
@@ -143,5 +143,32 @@ declare function createGitHubSearchTool(config: GitHubSearchToolConfig): Functio
143
143
  formatResult: (result: WarpGrepResult) => string;
144
144
  getSystemPrompt: () => string;
145
145
  };
146
+ /**
147
+ * Create a GitHub read file tool for Google Gemini SDK
148
+ *
149
+ * @param config - Optional configuration (timeout)
150
+ * @returns Gemini FunctionDeclaration with execute and formatResult methods
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * import { GoogleGenerativeAI } from '@google/generative-ai';
155
+ * import { createGitHubReadFileTool } from '@morphllm/morphsdk/tools/warp-grep/gemini';
156
+ *
157
+ * const tool = createGitHubReadFileTool();
158
+ *
159
+ * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);
160
+ * const model = genAI.getGenerativeModel({
161
+ * model: 'gemini-2.0-flash',
162
+ * tools: [{ functionDeclarations: [tool] }]
163
+ * });
164
+ *
165
+ * const result = await tool.execute({ github: 'vercel/next.js', path: 'package.json' });
166
+ * console.log(tool.formatResult(result));
167
+ * ```
168
+ */
169
+ declare function createGitHubReadFileTool(config?: GitHubReadFileToolConfig): FunctionDeclaration & {
170
+ execute: (input: GitHubReadFileInput) => Promise<GitHubReadFileResult>;
171
+ formatResult: (result: GitHubReadFileResult) => string;
172
+ };
146
173
 
147
- export { type GeminiWarpGrepTool, createGitHubSearchTool, createMorphWarpGrepTool, createWarpGrepTool, warpGrepFunctionDeclaration as default, execute, warpGrepFunctionDeclaration };
174
+ export { type GeminiWarpGrepTool, createGitHubReadFileTool, createGitHubSearchTool, createMorphWarpGrepTool, createWarpGrepTool, warpGrepFunctionDeclaration as default, execute, warpGrepFunctionDeclaration };
@@ -1,18 +1,22 @@
1
1
  import {
2
+ GITHUB_READ_FILE_DESCRIPTION,
3
+ GITHUB_READ_FILE_TOOL_NAME,
2
4
  GITHUB_SEARCH_DESCRIPTION,
3
5
  GITHUB_SEARCH_TOOL_NAME,
4
6
  WARP_GREP_DESCRIPTION,
5
7
  WARP_GREP_TOOL_NAME
6
- } from "../../chunk-KJZMKDDP.js";
8
+ } from "../../chunk-OTOVGCG6.js";
7
9
  import {
8
10
  WarpGrepClient,
11
+ executeGitHubReadFile,
9
12
  executeToolCall,
13
+ formatGitHubReadFileResult,
10
14
  formatResult
11
- } from "../../chunk-TXT3W4QK.js";
15
+ } from "../../chunk-MXSGTN7R.js";
12
16
  import "../../chunk-WYYR2EU6.js";
13
17
  import "../../chunk-PUGSTXLO.js";
14
18
  import "../../chunk-63VHBANJ.js";
15
- import "../../chunk-MQWEZJTP.js";
19
+ import "../../chunk-ZZCMAFN7.js";
16
20
  import "../../chunk-3MLWXJTJ.js";
17
21
  import "../../chunk-5PNMAWLC.js";
18
22
  import "../../chunk-APP75CBN.js";
@@ -20,7 +24,7 @@ import "../../chunk-GHGJAQSJ.js";
20
24
  import {
21
25
  getSystemPrompt
22
26
  } from "../../chunk-FMLHRJDF.js";
23
- import "../../chunk-RNKHRNSG.js";
27
+ import "../../chunk-FMKJ72KT.js";
24
28
  import "../../chunk-PZ5AY32C.js";
25
29
 
26
30
  // tools/warp_grep/gemini.ts
@@ -89,8 +93,35 @@ function createGitHubSearchTool(config) {
89
93
  }
90
94
  });
91
95
  }
96
+ var GITHUB_READ_FILE_PARAMETERS = {
97
+ type: "OBJECT",
98
+ properties: {
99
+ github: { type: "STRING", description: 'owner/repo shorthand (e.g., "vercel/next.js")' },
100
+ path: { type: "STRING", description: "File path within the repository" },
101
+ startLine: { type: "NUMBER", description: "Start line number (1-based)" },
102
+ endLine: { type: "NUMBER", description: "End line number (1-based, inclusive)" },
103
+ branch: { type: "STRING", description: "Branch to read from (defaults to repo default branch)" }
104
+ },
105
+ required: ["github", "path"]
106
+ };
107
+ function createGitHubReadFileTool(config) {
108
+ const declaration = {
109
+ name: GITHUB_READ_FILE_TOOL_NAME,
110
+ description: GITHUB_READ_FILE_DESCRIPTION,
111
+ parameters: GITHUB_READ_FILE_PARAMETERS
112
+ };
113
+ return Object.assign(declaration, {
114
+ execute: async (input) => {
115
+ return executeGitHubReadFile(input, config);
116
+ },
117
+ formatResult: (result) => {
118
+ return formatGitHubReadFileResult(result);
119
+ }
120
+ });
121
+ }
92
122
  var gemini_default = warpGrepFunctionDeclaration;
93
123
  export {
124
+ createGitHubReadFileTool,
94
125
  createGitHubSearchTool,
95
126
  createMorphWarpGrepTool,
96
127
  createWarpGrepTool,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../tools/warp_grep/gemini.ts"],"sourcesContent":["/**\n * Google Gemini SDK adapter for morph-warp-grep tool\n * \n * Requires @google/generative-ai as a peer dependency.\n * Install with: npm install @google/generative-ai\n */\n\nimport type { FunctionDeclaration, FunctionDeclarationSchema } from '@google/generative-ai';\nimport { executeToolCall, formatResult, WarpGrepClient } from './client.js';\nimport { WARP_GREP_DESCRIPTION, WARP_GREP_TOOL_NAME, GITHUB_SEARCH_TOOL_NAME, GITHUB_SEARCH_DESCRIPTION, getSystemPrompt } from './prompts.js';\nimport type { WarpGrepToolConfig, WarpGrepResult, GitHubSearchToolConfig } from './types.js';\n\n// Use plain object to avoid runtime import of SchemaType enum\nconst TOOL_PARAMETERS = {\n type: 'OBJECT',\n properties: {\n query: { \n type: 'STRING', \n description: 'Free-form repository question' \n },\n },\n required: ['query'],\n} as unknown as FunctionDeclarationSchema;\n\n/**\n * Gemini-native warp grep function declaration\n * \n * @example\n * ```typescript\n * import { GoogleGenerativeAI } from '@google/generative-ai';\n * import { warpGrepFunctionDeclaration, execute } from '@morphllm/morphsdk/tools/warp-grep/gemini';\n * \n * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);\n * const model = genAI.getGenerativeModel({\n * model: 'gemini-2.0-flash',\n * tools: [{ functionDeclarations: [warpGrepFunctionDeclaration] }]\n * });\n * \n * const chat = model.startChat();\n * const result = await chat.sendMessage('Find authentication middleware');\n * \n * // Handle function call\n * const call = result.response.functionCalls()?.[0];\n * if (call) {\n * const searchResult = await execute(call.args, { repoRoot: '.' });\n * console.log(searchResult);\n * }\n * ```\n */\nexport const warpGrepFunctionDeclaration: FunctionDeclaration = {\n name: WARP_GREP_TOOL_NAME,\n description: WARP_GREP_DESCRIPTION,\n parameters: TOOL_PARAMETERS,\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\nexport { formatResult, getSystemPrompt };\n\n/**\n * Gemini tool with execute method attached\n */\nexport interface GeminiWarpGrepTool extends FunctionDeclaration {\n execute: (input: unknown) => Promise<WarpGrepResult>;\n formatResult: (result: WarpGrepResult) => string;\n getSystemPrompt: () => string;\n}\n\n/**\n * Create a custom warp grep tool with configuration and methods\n * \n * @param config - Configuration options\n * @returns Function declaration with execute and formatResult methods\n * \n * @example Local usage\n * ```typescript\n * import { GoogleGenerativeAI } from '@google/generative-ai';\n * import { createMorphWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/gemini';\n * \n * const tool = createMorphWarpGrepTool({ repoRoot: '.' });\n * \n * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);\n * const model = genAI.getGenerativeModel({\n * model: 'gemini-2.0-flash',\n * tools: [{ functionDeclarations: [tool] }]\n * });\n * \n * const chat = model.startChat();\n * const result = await chat.sendMessage('Find authentication middleware');\n * \n * // Handle function call\n * const call = result.response.functionCalls()?.[0];\n * if (call && call.name === tool.name) {\n * const searchResult = await tool.execute(call.args);\n * console.log(tool.formatResult(searchResult));\n * \n * // Send result back to model\n * await chat.sendMessage([{\n * functionResponse: {\n * name: call.name,\n * response: { result: tool.formatResult(searchResult) }\n * }\n * }]);\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): GeminiWarpGrepTool {\n const declaration: FunctionDeclaration = {\n name: config.name ?? WARP_GREP_TOOL_NAME,\n description: config.description ?? WARP_GREP_DESCRIPTION,\n parameters: TOOL_PARAMETERS,\n };\n\n return Object.assign(declaration, {\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// Legacy alias for backwards compatibility\nexport const createMorphWarpGrepTool = createWarpGrepTool;\n\nconst GITHUB_SEARCH_PARAMETERS = {\n type: 'OBJECT',\n properties: {\n query: { type: 'STRING', description: 'Natural language search query' },\n github: { type: 'STRING', description: 'GitHub URL or \"owner/repo\" shorthand' },\n branch: { type: 'STRING', description: 'Branch to search (defaults to repo default branch)' },\n },\n required: ['query', 'github'],\n} as unknown as FunctionDeclarationSchema;\n\n/**\n * Create a GitHub search tool for Google Gemini SDK\n *\n * @param config - Configuration options (morphApiKey, morphApiUrl, codeSearchUrl, timeout)\n * @returns Gemini FunctionDeclaration with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import { GoogleGenerativeAI } from '@google/generative-ai';\n * import { createGitHubSearchTool } from '@morphllm/morphsdk/tools/warp-grep/gemini';\n *\n * const tool = createGitHubSearchTool({ morphApiKey: process.env.MORPH_API_KEY });\n *\n * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);\n * const model = genAI.getGenerativeModel({\n * model: 'gemini-2.0-flash',\n * tools: [{ functionDeclarations: [tool] }]\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 declaration: FunctionDeclaration = {\n name: GITHUB_SEARCH_TOOL_NAME,\n description: GITHUB_SEARCH_DESCRIPTION,\n parameters: GITHUB_SEARCH_PARAMETERS,\n };\n\n return Object.assign(declaration, {\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\nexport default warpGrepFunctionDeclaration;\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAM,kBAAkB;AAAA,EACtB,MAAM;AAAA,EACN,YAAY;AAAA,IACV,OAAO;AAAA,MACL,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,UAAU,CAAC,OAAO;AACpB;AA2BO,IAAM,8BAAmD;AAAA,EAC9D,MAAM;AAAA,EACN,aAAa;AAAA,EACb,YAAY;AACd;AASA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AA+DO,SAAS,mBAAmB,QAAgD;AACjF,QAAM,cAAmC;AAAA,IACvC,MAAM,OAAO,QAAQ;AAAA,IACrB,aAAa,OAAO,eAAe;AAAA,IACnC,YAAY;AAAA,EACd;AAEA,SAAO,OAAO,OAAO,aAAa;AAAA,IAChC,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;AAGO,IAAM,0BAA0B;AAEvC,IAAM,2BAA2B;AAAA,EAC/B,MAAM;AAAA,EACN,YAAY;AAAA,IACV,OAAO,EAAE,MAAM,UAAU,aAAa,gCAAgC;AAAA,IACtE,QAAQ,EAAE,MAAM,UAAU,aAAa,uCAAuC;AAAA,IAC9E,QAAQ,EAAE,MAAM,UAAU,aAAa,qDAAqD;AAAA,EAC9F;AAAA,EACA,UAAU,CAAC,SAAS,QAAQ;AAC9B;AA0BO,SAAS,uBAAuB,QAAgC;AACrE,QAAM,SAAS,IAAI,eAAe,MAAM;AAExC,QAAM,cAAmC;AAAA,IACvC,MAAM;AAAA,IACN,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AAEA,SAAO,OAAO,OAAO,aAAa;AAAA,IAChC,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;AAEA,IAAO,iBAAQ;","names":[]}
1
+ {"version":3,"sources":["../../../tools/warp_grep/gemini.ts"],"sourcesContent":["/**\n * Google Gemini SDK adapter for morph-warp-grep tool\n * \n * Requires @google/generative-ai as a peer dependency.\n * Install with: npm install @google/generative-ai\n */\n\nimport type { FunctionDeclaration, FunctionDeclarationSchema } from '@google/generative-ai';\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_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// Use plain object to avoid runtime import of SchemaType enum\nconst TOOL_PARAMETERS = {\n type: 'OBJECT',\n properties: {\n query: { \n type: 'STRING', \n description: 'Free-form repository question' \n },\n },\n required: ['query'],\n} as unknown as FunctionDeclarationSchema;\n\n/**\n * Gemini-native warp grep function declaration\n * \n * @example\n * ```typescript\n * import { GoogleGenerativeAI } from '@google/generative-ai';\n * import { warpGrepFunctionDeclaration, execute } from '@morphllm/morphsdk/tools/warp-grep/gemini';\n * \n * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);\n * const model = genAI.getGenerativeModel({\n * model: 'gemini-2.0-flash',\n * tools: [{ functionDeclarations: [warpGrepFunctionDeclaration] }]\n * });\n * \n * const chat = model.startChat();\n * const result = await chat.sendMessage('Find authentication middleware');\n * \n * // Handle function call\n * const call = result.response.functionCalls()?.[0];\n * if (call) {\n * const searchResult = await execute(call.args, { repoRoot: '.' });\n * console.log(searchResult);\n * }\n * ```\n */\nexport const warpGrepFunctionDeclaration: FunctionDeclaration = {\n name: WARP_GREP_TOOL_NAME,\n description: WARP_GREP_DESCRIPTION,\n parameters: TOOL_PARAMETERS,\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\nexport { formatResult, getSystemPrompt };\n\n/**\n * Gemini tool with execute method attached\n */\nexport interface GeminiWarpGrepTool extends FunctionDeclaration {\n execute: (input: unknown) => Promise<WarpGrepResult>;\n formatResult: (result: WarpGrepResult) => string;\n getSystemPrompt: () => string;\n}\n\n/**\n * Create a custom warp grep tool with configuration and methods\n * \n * @param config - Configuration options\n * @returns Function declaration with execute and formatResult methods\n * \n * @example Local usage\n * ```typescript\n * import { GoogleGenerativeAI } from '@google/generative-ai';\n * import { createMorphWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/gemini';\n * \n * const tool = createMorphWarpGrepTool({ repoRoot: '.' });\n * \n * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);\n * const model = genAI.getGenerativeModel({\n * model: 'gemini-2.0-flash',\n * tools: [{ functionDeclarations: [tool] }]\n * });\n * \n * const chat = model.startChat();\n * const result = await chat.sendMessage('Find authentication middleware');\n * \n * // Handle function call\n * const call = result.response.functionCalls()?.[0];\n * if (call && call.name === tool.name) {\n * const searchResult = await tool.execute(call.args);\n * console.log(tool.formatResult(searchResult));\n * \n * // Send result back to model\n * await chat.sendMessage([{\n * functionResponse: {\n * name: call.name,\n * response: { result: tool.formatResult(searchResult) }\n * }\n * }]);\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): GeminiWarpGrepTool {\n const declaration: FunctionDeclaration = {\n name: config.name ?? WARP_GREP_TOOL_NAME,\n description: config.description ?? WARP_GREP_DESCRIPTION,\n parameters: TOOL_PARAMETERS,\n };\n\n return Object.assign(declaration, {\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// Legacy alias for backwards compatibility\nexport const createMorphWarpGrepTool = createWarpGrepTool;\n\nconst GITHUB_SEARCH_PARAMETERS = {\n type: 'OBJECT',\n properties: {\n query: { type: 'STRING', description: 'Natural language search query' },\n github: { type: 'STRING', description: 'GitHub URL or \"owner/repo\" shorthand' },\n branch: { type: 'STRING', description: 'Branch to search (defaults to repo default branch)' },\n },\n required: ['query', 'github'],\n} as unknown as FunctionDeclarationSchema;\n\n/**\n * Create a GitHub search tool for Google Gemini SDK\n *\n * @param config - Configuration options (morphApiKey, morphApiUrl, codeSearchUrl, timeout)\n * @returns Gemini FunctionDeclaration with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import { GoogleGenerativeAI } from '@google/generative-ai';\n * import { createGitHubSearchTool } from '@morphllm/morphsdk/tools/warp-grep/gemini';\n *\n * const tool = createGitHubSearchTool({ morphApiKey: process.env.MORPH_API_KEY });\n *\n * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);\n * const model = genAI.getGenerativeModel({\n * model: 'gemini-2.0-flash',\n * tools: [{ functionDeclarations: [tool] }]\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 declaration: FunctionDeclaration = {\n name: GITHUB_SEARCH_TOOL_NAME,\n description: GITHUB_SEARCH_DESCRIPTION,\n parameters: GITHUB_SEARCH_PARAMETERS,\n };\n\n return Object.assign(declaration, {\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\nconst GITHUB_READ_FILE_PARAMETERS = {\n type: 'OBJECT',\n properties: {\n github: { type: 'STRING', description: 'owner/repo shorthand (e.g., \"vercel/next.js\")' },\n path: { type: 'STRING', description: 'File path within the repository' },\n startLine: { type: 'NUMBER', description: 'Start line number (1-based)' },\n endLine: { type: 'NUMBER', description: 'End line number (1-based, inclusive)' },\n branch: { type: 'STRING', description: 'Branch to read from (defaults to repo default branch)' },\n },\n required: ['github', 'path'],\n} as unknown as FunctionDeclarationSchema;\n\n/**\n * Create a GitHub read file tool for Google Gemini SDK\n *\n * @param config - Optional configuration (timeout)\n * @returns Gemini FunctionDeclaration with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import { GoogleGenerativeAI } from '@google/generative-ai';\n * import { createGitHubReadFileTool } from '@morphllm/morphsdk/tools/warp-grep/gemini';\n *\n * const tool = createGitHubReadFileTool();\n *\n * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);\n * const model = genAI.getGenerativeModel({\n * model: 'gemini-2.0-flash',\n * tools: [{ functionDeclarations: [tool] }]\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 declaration: FunctionDeclaration = {\n name: GITHUB_READ_FILE_TOOL_NAME,\n description: GITHUB_READ_FILE_DESCRIPTION,\n parameters: GITHUB_READ_FILE_PARAMETERS,\n };\n\n return Object.assign(declaration, {\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 warpGrepFunctionDeclaration;\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAM,kBAAkB;AAAA,EACtB,MAAM;AAAA,EACN,YAAY;AAAA,IACV,OAAO;AAAA,MACL,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,UAAU,CAAC,OAAO;AACpB;AA2BO,IAAM,8BAAmD;AAAA,EAC9D,MAAM;AAAA,EACN,aAAa;AAAA,EACb,YAAY;AACd;AASA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AA+DO,SAAS,mBAAmB,QAAgD;AACjF,QAAM,cAAmC;AAAA,IACvC,MAAM,OAAO,QAAQ;AAAA,IACrB,aAAa,OAAO,eAAe;AAAA,IACnC,YAAY;AAAA,EACd;AAEA,SAAO,OAAO,OAAO,aAAa;AAAA,IAChC,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;AAGO,IAAM,0BAA0B;AAEvC,IAAM,2BAA2B;AAAA,EAC/B,MAAM;AAAA,EACN,YAAY;AAAA,IACV,OAAO,EAAE,MAAM,UAAU,aAAa,gCAAgC;AAAA,IACtE,QAAQ,EAAE,MAAM,UAAU,aAAa,uCAAuC;AAAA,IAC9E,QAAQ,EAAE,MAAM,UAAU,aAAa,qDAAqD;AAAA,EAC9F;AAAA,EACA,UAAU,CAAC,SAAS,QAAQ;AAC9B;AA0BO,SAAS,uBAAuB,QAAgC;AACrE,QAAM,SAAS,IAAI,eAAe,MAAM;AAExC,QAAM,cAAmC;AAAA,IACvC,MAAM;AAAA,IACN,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AAEA,SAAO,OAAO,OAAO,aAAa;AAAA,IAChC,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;AAEA,IAAM,8BAA8B;AAAA,EAClC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,QAAQ,EAAE,MAAM,UAAU,aAAa,gDAAgD;AAAA,IACvF,MAAM,EAAE,MAAM,UAAU,aAAa,kCAAkC;AAAA,IACvE,WAAW,EAAE,MAAM,UAAU,aAAa,8BAA8B;AAAA,IACxE,SAAS,EAAE,MAAM,UAAU,aAAa,uCAAuC;AAAA,IAC/E,QAAQ,EAAE,MAAM,UAAU,aAAa,wDAAwD;AAAA,EACjG;AAAA,EACA,UAAU,CAAC,UAAU,MAAM;AAC7B;AAyBO,SAAS,yBAAyB,QAAmC;AAC1E,QAAM,cAAmC;AAAA,IACvC,MAAM;AAAA,IACN,aAAa;AAAA,IACb,YAAY;AAAA,EACd;AAEA,SAAO,OAAO,OAAO,aAAa;AAAA,IAChC,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;AAEA,IAAO,iBAAQ;","names":[]}
@@ -572,6 +572,9 @@ Details: ${res.stderr}` : ""}`
572
572
  // tools/warp_grep/index.ts
573
573
  var warp_grep_exports = {};
574
574
  __export(warp_grep_exports, {
575
+ GITHUB_READ_FILE_DESCRIPTION: () => GITHUB_READ_FILE_DESCRIPTION,
576
+ GITHUB_READ_FILE_INPUT_SCHEMA: () => GITHUB_READ_FILE_INPUT_SCHEMA,
577
+ GITHUB_READ_FILE_TOOL_NAME: () => GITHUB_READ_FILE_TOOL_NAME,
575
578
  GITHUB_SEARCH_DESCRIPTION: () => GITHUB_SEARCH_DESCRIPTION,
576
579
  GITHUB_SEARCH_INPUT_SCHEMA: () => GITHUB_SEARCH_INPUT_SCHEMA,
577
580
  GITHUB_SEARCH_TOOL_NAME: () => GITHUB_SEARCH_TOOL_NAME,
@@ -582,9 +585,11 @@ __export(warp_grep_exports, {
582
585
  WARP_GREP_TOOL_NAME: () => WARP_GREP_TOOL_NAME,
583
586
  WarpGrepClient: () => WarpGrepClient,
584
587
  createCodeStorageHttpCommands: () => createCodeStorageHttpCommands,
588
+ executeGitHubReadFile: () => executeGitHubReadFile,
585
589
  executeToolCall: () => executeToolCall,
586
590
  executeWarpGrep: () => executeWarpGrep,
587
591
  fixPathRepetition: () => fixPathRepetition,
592
+ formatGitHubReadFileResult: () => formatGitHubReadFileResult,
588
593
  formatResult: () => formatResult,
589
594
  getSystemPrompt: () => getSystemPrompt,
590
595
  normalizeFinishFiles: () => normalizeFinishFiles,
@@ -1404,7 +1409,7 @@ var import_openai = __toESM(require("openai"), 1);
1404
1409
  // package.json
1405
1410
  var package_default = {
1406
1411
  name: "@morphllm/morphsdk",
1407
- version: "0.2.122",
1412
+ version: "0.2.123",
1408
1413
  description: "TypeScript SDK and CLI for Morph Fast Apply integration",
1409
1414
  type: "module",
1410
1415
  main: "./dist/index.cjs",
@@ -1654,9 +1659,9 @@ async function callModel(messages, model, options = {}) {
1654
1659
  });
1655
1660
  } catch (error) {
1656
1661
  if (error instanceof import_openai.default.APIError && error.status === 404) {
1657
- throw new Error(
1658
- "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"
1659
- );
1662
+ 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";
1663
+ const errorText = error.message?.trim();
1664
+ throw new Error(errorText || defaultMsg);
1660
1665
  }
1661
1666
  throw error;
1662
1667
  }
@@ -2262,6 +2267,23 @@ var WarpGrepClient = class {
2262
2267
  }
2263
2268
  return this._searchGitHubAsync(input);
2264
2269
  }
2270
+ /**
2271
+ * Read a single file from a public GitHub repository
2272
+ *
2273
+ * @example
2274
+ * ```typescript
2275
+ * const result = await client.readGitHubFile({
2276
+ * github: 'vercel/next.js',
2277
+ * path: 'src/server/app-render/index.tsx',
2278
+ * startLine: 1,
2279
+ * endLine: 50,
2280
+ * });
2281
+ * if (result.success) console.log(result.content);
2282
+ * ```
2283
+ */
2284
+ async readGitHubFile(input) {
2285
+ return executeGitHubReadFile(input, { timeout: this.config.timeout });
2286
+ }
2265
2287
  async _resolveGitHubRepo(input) {
2266
2288
  const { owner, repo } = parseGitHubUrl(input.github);
2267
2289
  const baseUrl = this.config.codeSearchUrl || DEFAULT_CODE_SEARCH_URL;
@@ -2389,6 +2411,65 @@ async function* executeToolCallStreaming(input, config) {
2389
2411
  }
2390
2412
  return processAgentResult(agentResult);
2391
2413
  }
2414
+ async function fetchRawGitHubFile(owner, repo, filePath, branch, timeout) {
2415
+ const branches = branch ? [branch] : ["HEAD"];
2416
+ const fallbacks = ["main", "master", "develop"];
2417
+ const fetchWithTimeout = (url) => timeout ? fetch(url, { signal: AbortSignal.timeout(timeout) }) : fetch(url);
2418
+ for (const b of branches) {
2419
+ const url = `https://raw.githubusercontent.com/${owner}/${repo}/${b}/${filePath}`;
2420
+ const res = await fetchWithTimeout(url);
2421
+ if (res.ok) return { content: await res.text(), branch: b };
2422
+ }
2423
+ for (const fb of fallbacks) {
2424
+ if (branch && fb === branch) continue;
2425
+ const url = `https://raw.githubusercontent.com/${owner}/${repo}/${fb}/${filePath}`;
2426
+ const res = await fetchWithTimeout(url);
2427
+ if (res.ok) return { content: await res.text(), branch: fb };
2428
+ }
2429
+ throw new Error(`File not found: ${owner}/${repo}/${filePath}`);
2430
+ }
2431
+ async function executeGitHubReadFile(input, config) {
2432
+ try {
2433
+ const { owner, repo } = parseGitHubUrl(input.github);
2434
+ const { content: raw, branch } = await fetchRawGitHubFile(
2435
+ owner,
2436
+ repo,
2437
+ input.path,
2438
+ input.branch,
2439
+ config?.timeout
2440
+ );
2441
+ const allLines = raw.split("\n");
2442
+ const totalLines = allLines.length;
2443
+ const start = Math.max(1, input.startLine ?? 1);
2444
+ const end = Math.min(totalLines, input.endLine ?? totalLines);
2445
+ const selected = allLines.slice(start - 1, end);
2446
+ const padWidth = String(end).length;
2447
+ const numbered = selected.map((line, i) => `${String(start + i).padStart(padWidth)}|${line}`).join("\n");
2448
+ return {
2449
+ success: true,
2450
+ content: numbered,
2451
+ path: input.path,
2452
+ github: `${owner}/${repo}`,
2453
+ branch,
2454
+ lineRange: [start, end],
2455
+ totalLines
2456
+ };
2457
+ } catch (error) {
2458
+ return {
2459
+ success: false,
2460
+ error: error instanceof Error ? error.message : String(error)
2461
+ };
2462
+ }
2463
+ }
2464
+ function formatGitHubReadFileResult(result) {
2465
+ if (!result.success) {
2466
+ return `Failed to read file: ${result.error}`;
2467
+ }
2468
+ const rangeStr = result.lineRange ? ` (lines ${result.lineRange[0]}-${result.lineRange[1]} of ${result.totalLines})` : "";
2469
+ return `File: ${result.github}/${result.path}${rangeStr}
2470
+
2471
+ ${result.content}`;
2472
+ }
2392
2473
  function formatResult(result) {
2393
2474
  if (!result.success) {
2394
2475
  return `Search failed: ${result.error}`;
@@ -2417,17 +2498,33 @@ function formatResult(result) {
2417
2498
  // tools/warp_grep/prompts.ts
2418
2499
  var WARP_GREP_TOOL_NAME = "warpgrep_codebase_search";
2419
2500
  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.';
2420
- var GITHUB_SEARCH_TOOL_NAME = "warpgrep_github_search";
2421
- var GITHUB_SEARCH_DESCRIPTION = "Search a public GitHub repository using WarpGrep. Provide a GitHub URL or owner/repo shorthand and a natural language query.";
2422
- var GITHUB_SEARCH_INPUT_SCHEMA = {
2501
+ var GITHUB_WARP_GREP_SEARCH_TOOL_NAME = "warpgrep_github_search";
2502
+ 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.';
2503
+ var GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA = {
2423
2504
  type: "object",
2424
2505
  properties: {
2425
2506
  query: { type: "string", description: "Natural language search query describing what to find in the repository" },
2426
- github: { type: "string", description: 'GitHub repository URL or owner/repo shorthand (e.g., "vercel/next.js" or "https://github.com/vercel/next.js")' },
2507
+ github: { type: "string", description: 'owner/repo shorthand (ex: "vercel/next.js" for "https://github.com/vercel/next.js")' },
2427
2508
  branch: { type: "string", description: "Branch to search (defaults to the repository default branch)" }
2428
2509
  },
2429
2510
  required: ["query", "github"]
2430
2511
  };
2512
+ var GITHUB_SEARCH_TOOL_NAME = GITHUB_WARP_GREP_SEARCH_TOOL_NAME;
2513
+ var GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;
2514
+ var GITHUB_SEARCH_INPUT_SCHEMA = GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA;
2515
+ var GITHUB_READ_FILE_TOOL_NAME = "readfile_github_search";
2516
+ 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.";
2517
+ var GITHUB_READ_FILE_INPUT_SCHEMA = {
2518
+ type: "object",
2519
+ properties: {
2520
+ github: { type: "string", description: 'owner/repo shorthand (e.g., "vercel/next.js")' },
2521
+ path: { type: "string", description: 'File path within the repository (e.g., "src/server/index.ts")' },
2522
+ startLine: { type: "number", description: "Start line number (1-based). Omit to start from beginning." },
2523
+ endLine: { type: "number", description: "End line number (1-based, inclusive). Omit to read to the end." },
2524
+ branch: { type: "string", description: "Branch to read from (defaults to the repository default branch)" }
2525
+ },
2526
+ required: ["github", "path"]
2527
+ };
2431
2528
 
2432
2529
  // tools/warp_grep/providers/index.ts
2433
2530
  init_local();
@@ -2444,6 +2541,9 @@ var warpGrepInputSchema = import_zod.z.object({
2444
2541
  });
2445
2542
  // Annotate the CommonJS export names for ESM import in node:
2446
2543
  0 && (module.exports = {
2544
+ GITHUB_READ_FILE_DESCRIPTION,
2545
+ GITHUB_READ_FILE_INPUT_SCHEMA,
2546
+ GITHUB_READ_FILE_TOOL_NAME,
2447
2547
  GITHUB_SEARCH_DESCRIPTION,
2448
2548
  GITHUB_SEARCH_INPUT_SCHEMA,
2449
2549
  GITHUB_SEARCH_TOOL_NAME,
@@ -2454,9 +2554,11 @@ var warpGrepInputSchema = import_zod.z.object({
2454
2554
  WARP_GREP_TOOL_NAME,
2455
2555
  WarpGrepClient,
2456
2556
  createCodeStorageHttpCommands,
2557
+ executeGitHubReadFile,
2457
2558
  executeToolCall,
2458
2559
  executeWarpGrep,
2459
2560
  fixPathRepetition,
2561
+ formatGitHubReadFileResult,
2460
2562
  formatResult,
2461
2563
  getSystemPrompt,
2462
2564
  normalizeFinishFiles,