@morphllm/morphsdk 0.2.121 → 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.
- package/dist/{chunk-L4PK4VC7.js → chunk-5OJE7GH4.js} +2 -2
- package/dist/chunk-63VHBANJ.js +22 -0
- package/dist/chunk-63VHBANJ.js.map +1 -0
- package/dist/{chunk-BDKXYMU2.js → chunk-ANPZFWYV.js} +2 -2
- package/dist/{chunk-DL3Y3R6A.js → chunk-BJ2764MK.js} +2 -2
- package/dist/{chunk-JBIFS33U.js → chunk-DBSOONOY.js} +2 -2
- package/dist/chunk-ETTCJWJK.js +113 -0
- package/dist/chunk-ETTCJWJK.js.map +1 -0
- package/dist/{chunk-EJYFE73S.js → chunk-FMKJ72KT.js} +3 -3
- package/dist/{chunk-EJYFE73S.js.map → chunk-FMKJ72KT.js.map} +1 -1
- package/dist/{chunk-7QZFNYOH.js → chunk-GXFJLL5O.js} +2 -2
- package/dist/chunk-H3U7J5RI.js +98 -0
- package/dist/chunk-H3U7J5RI.js.map +1 -0
- package/dist/{chunk-MAAULSSQ.js → chunk-HVBJ4UO6.js} +2 -2
- package/dist/{chunk-3HBZXN6E.js → chunk-K74GLGST.js} +2 -2
- package/dist/{chunk-EZFXR52Q.js → chunk-KL3AMLGL.js} +2 -2
- package/dist/{chunk-YMOTJ6ZP.js → chunk-L426IMZD.js} +2 -2
- package/dist/{chunk-C3BQUIFE.js → chunk-MXSGTN7R.js} +145 -9
- package/dist/chunk-MXSGTN7R.js.map +1 -0
- package/dist/{chunk-266SWRHK.js → chunk-OFJYDTQI.js} +2 -2
- package/dist/chunk-OTOVGCG6.js +42 -0
- package/dist/chunk-OTOVGCG6.js.map +1 -0
- package/dist/{chunk-W37KJB25.js → chunk-QD7KPI7A.js} +2 -2
- package/dist/chunk-QGRFAVGK.js +112 -0
- package/dist/chunk-QGRFAVGK.js.map +1 -0
- package/dist/{chunk-WEBUKGPK.js → chunk-UHL2ZEWG.js} +3 -3
- package/dist/{chunk-CIFPLFBQ.js → chunk-UJS3AIWS.js} +2 -2
- package/dist/{chunk-FV3R3JGV.js → chunk-UX65IRCX.js} +2 -2
- package/dist/{chunk-L5C6E32T.js → chunk-V3HLOZK2.js} +1 -1
- package/dist/{chunk-L5C6E32T.js.map → chunk-V3HLOZK2.js.map} +1 -1
- package/dist/{chunk-7IZUNRPZ.js → chunk-V4KBK66V.js} +54 -15
- package/dist/{chunk-7IZUNRPZ.js.map → chunk-V4KBK66V.js.map} +1 -1
- package/dist/{chunk-AI3ZCOCT.js → chunk-WE75QX2B.js} +1 -1
- package/dist/chunk-WYYR2EU6.js +29 -0
- package/dist/chunk-WYYR2EU6.js.map +1 -0
- package/dist/{chunk-GNRMDXJA.js → chunk-XXL62KSJ.js} +2 -2
- package/dist/{chunk-QDGB6FLI.js → chunk-ZZCMAFN7.js} +5 -5
- package/dist/chunk-ZZCMAFN7.js.map +1 -0
- package/dist/{client-Bp3MRcJc.d.ts → client-JHPwle1Z.d.ts} +46 -1
- package/dist/client.cjs +287 -12
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +23 -21
- package/dist/edge.cjs +2 -2
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +4 -4
- package/dist/index.cjs +287 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +24 -22
- package/dist/modelrouter/core.cjs +2 -2
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +3 -3
- package/dist/modelrouter/index.cjs +2 -2
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +3 -3
- package/dist/tools/browser/anthropic.cjs +2 -2
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +5 -5
- package/dist/tools/browser/core.cjs +2 -2
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +4 -4
- package/dist/tools/browser/index.cjs +2 -2
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +7 -7
- package/dist/tools/browser/openai.cjs +2 -2
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +5 -5
- package/dist/tools/browser/profiles/core.cjs +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +5 -5
- package/dist/tools/codebase_search/anthropic.cjs +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +4 -4
- package/dist/tools/fastapply/apply.cjs +2 -2
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +2 -2
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +3 -3
- package/dist/tools/fastapply/index.cjs +2 -2
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +6 -6
- package/dist/tools/fastapply/openai.cjs +2 -2
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +4 -4
- package/dist/tools/fastapply/vercel.cjs +2 -2
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +4 -4
- package/dist/tools/index.cjs +2 -2
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +6 -6
- package/dist/tools/utils/resilience.cjs +2 -2
- 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 +5 -5
- 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 +476 -5
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +62 -2
- package/dist/tools/warp_grep/anthropic.js +11 -5
- package/dist/tools/warp_grep/client.cjs +187 -12
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.d.ts +58 -2
- package/dist/tools/warp_grep/client.js +9 -3
- package/dist/tools/warp_grep/gemini.cjs +475 -5
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +62 -2
- package/dist/tools/warp_grep/gemini.js +69 -4
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/index.cjs +228 -12
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +52 -3
- package/dist/tools/warp_grep/index.js +26 -5
- package/dist/tools/warp_grep/openai.cjs +482 -5
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +62 -2
- package/dist/tools/warp_grep/openai.js +11 -5
- package/dist/tools/warp_grep/providers/code_storage_http.cjs +53 -0
- package/dist/tools/warp_grep/providers/code_storage_http.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/code_storage_http.d.ts +23 -0
- package/dist/tools/warp_grep/providers/code_storage_http.js +8 -0
- package/dist/tools/warp_grep/providers/code_storage_http.js.map +1 -0
- package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
- package/dist/tools/warp_grep/utils/github.cjs +46 -0
- package/dist/tools/warp_grep/utils/github.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/github.d.ts +13 -0
- package/dist/tools/warp_grep/utils/github.js +8 -0
- package/dist/tools/warp_grep/utils/github.js.map +1 -0
- package/dist/tools/warp_grep/vercel.cjs +245 -5
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +60 -2
- package/dist/tools/warp_grep/vercel.js +11 -5
- package/dist/{types-D5p8QErL.d.ts → types-DY_hq2eZ.d.ts} +53 -1
- package/dist/version.cjs +2 -2
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-C3BQUIFE.js.map +0 -1
- package/dist/chunk-CXP63PHW.js +0 -61
- package/dist/chunk-CXP63PHW.js.map +0 -1
- package/dist/chunk-KW7OEGZK.js +0 -9
- package/dist/chunk-KW7OEGZK.js.map +0 -1
- package/dist/chunk-QDGB6FLI.js.map +0 -1
- package/dist/chunk-U5UDFQXK.js +0 -66
- package/dist/chunk-U5UDFQXK.js.map +0 -1
- package/dist/chunk-XERAWJ3H.js +0 -53
- package/dist/chunk-XERAWJ3H.js.map +0 -1
- /package/dist/{chunk-L4PK4VC7.js.map → chunk-5OJE7GH4.js.map} +0 -0
- /package/dist/{chunk-BDKXYMU2.js.map → chunk-ANPZFWYV.js.map} +0 -0
- /package/dist/{chunk-DL3Y3R6A.js.map → chunk-BJ2764MK.js.map} +0 -0
- /package/dist/{chunk-JBIFS33U.js.map → chunk-DBSOONOY.js.map} +0 -0
- /package/dist/{chunk-7QZFNYOH.js.map → chunk-GXFJLL5O.js.map} +0 -0
- /package/dist/{chunk-MAAULSSQ.js.map → chunk-HVBJ4UO6.js.map} +0 -0
- /package/dist/{chunk-3HBZXN6E.js.map → chunk-K74GLGST.js.map} +0 -0
- /package/dist/{chunk-EZFXR52Q.js.map → chunk-KL3AMLGL.js.map} +0 -0
- /package/dist/{chunk-YMOTJ6ZP.js.map → chunk-L426IMZD.js.map} +0 -0
- /package/dist/{chunk-266SWRHK.js.map → chunk-OFJYDTQI.js.map} +0 -0
- /package/dist/{chunk-W37KJB25.js.map → chunk-QD7KPI7A.js.map} +0 -0
- /package/dist/{chunk-WEBUKGPK.js.map → chunk-UHL2ZEWG.js.map} +0 -0
- /package/dist/{chunk-CIFPLFBQ.js.map → chunk-UJS3AIWS.js.map} +0 -0
- /package/dist/{chunk-FV3R3JGV.js.map → chunk-UX65IRCX.js.map} +0 -0
- /package/dist/{chunk-AI3ZCOCT.js.map → chunk-WE75QX2B.js.map} +0 -0
- /package/dist/{chunk-GNRMDXJA.js.map → chunk-XXL62KSJ.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChatCompletionTool } from 'openai/resources/chat/completions';
|
|
2
2
|
export { formatResult } from './client.js';
|
|
3
3
|
export { getSystemPrompt } from './agent/prompt.js';
|
|
4
|
-
import { d as WarpGrepToolConfig, b as WarpGrepResult } from '../../types-
|
|
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';
|
|
@@ -79,5 +79,65 @@ declare function createWarpGrepTool(config: WarpGrepToolConfig): ChatCompletionT
|
|
|
79
79
|
formatResult: (result: WarpGrepResult) => string;
|
|
80
80
|
getSystemPrompt: () => string;
|
|
81
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* Create a GitHub search tool for OpenAI SDK
|
|
84
|
+
*
|
|
85
|
+
* @param config - Configuration options (morphApiKey, morphApiUrl, codeSearchUrl, timeout)
|
|
86
|
+
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* import OpenAI from 'openai';
|
|
91
|
+
* import { createGitHubSearchTool } from '@morphllm/morphsdk/tools/warp-grep/openai';
|
|
92
|
+
*
|
|
93
|
+
* const tool = createGitHubSearchTool({ morphApiKey: process.env.MORPH_API_KEY });
|
|
94
|
+
*
|
|
95
|
+
* const response = await openai.chat.completions.create({
|
|
96
|
+
* model: 'gpt-4o',
|
|
97
|
+
* tools: [tool],
|
|
98
|
+
* messages: [{ role: 'user', content: 'How does auth work in vercel/next.js?' }]
|
|
99
|
+
* });
|
|
100
|
+
*
|
|
101
|
+
* // Execute
|
|
102
|
+
* const result = await tool.execute({ query: 'auth middleware', github: 'vercel/next.js' });
|
|
103
|
+
* console.log(tool.formatResult(result));
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
declare function createGitHubSearchTool(config: GitHubSearchToolConfig): ChatCompletionTool & {
|
|
107
|
+
execute: (input: {
|
|
108
|
+
query: string;
|
|
109
|
+
github: string;
|
|
110
|
+
branch?: string;
|
|
111
|
+
}) => Promise<WarpGrepResult>;
|
|
112
|
+
formatResult: (result: WarpGrepResult) => string;
|
|
113
|
+
getSystemPrompt: () => string;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Create a GitHub read file tool for OpenAI SDK
|
|
117
|
+
*
|
|
118
|
+
* @param config - Optional configuration (timeout)
|
|
119
|
+
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* import OpenAI from 'openai';
|
|
124
|
+
* import { createGitHubReadFileTool } from '@morphllm/morphsdk/tools/warp-grep/openai';
|
|
125
|
+
*
|
|
126
|
+
* const tool = createGitHubReadFileTool();
|
|
127
|
+
*
|
|
128
|
+
* const response = await openai.chat.completions.create({
|
|
129
|
+
* model: 'gpt-4o',
|
|
130
|
+
* tools: [tool],
|
|
131
|
+
* messages: [{ role: 'user', content: 'Read the package.json from vercel/next.js' }]
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* const result = await tool.execute({ github: 'vercel/next.js', path: 'package.json' });
|
|
135
|
+
* console.log(tool.formatResult(result));
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
declare function createGitHubReadFileTool(config?: GitHubReadFileToolConfig): ChatCompletionTool & {
|
|
139
|
+
execute: (input: GitHubReadFileInput) => Promise<GitHubReadFileResult>;
|
|
140
|
+
formatResult: (result: GitHubReadFileResult) => string;
|
|
141
|
+
};
|
|
82
142
|
|
|
83
|
-
export { createWarpGrepTool, warpGrepTool as default, execute, warpGrepTool };
|
|
143
|
+
export { createGitHubReadFileTool, createGitHubSearchTool, createWarpGrepTool, warpGrepTool as default, execute, warpGrepTool };
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
+
createGitHubReadFileTool,
|
|
3
|
+
createGitHubSearchTool,
|
|
2
4
|
createWarpGrepTool,
|
|
3
5
|
execute,
|
|
4
6
|
openai_default,
|
|
5
7
|
warpGrepTool
|
|
6
|
-
} from "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
+
} from "../../chunk-QGRFAVGK.js";
|
|
9
|
+
import "../../chunk-OTOVGCG6.js";
|
|
8
10
|
import {
|
|
9
11
|
formatResult
|
|
10
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-MXSGTN7R.js";
|
|
13
|
+
import "../../chunk-WYYR2EU6.js";
|
|
11
14
|
import "../../chunk-PUGSTXLO.js";
|
|
12
|
-
import "../../chunk-
|
|
15
|
+
import "../../chunk-63VHBANJ.js";
|
|
16
|
+
import "../../chunk-ZZCMAFN7.js";
|
|
13
17
|
import "../../chunk-3MLWXJTJ.js";
|
|
14
18
|
import "../../chunk-5PNMAWLC.js";
|
|
15
19
|
import "../../chunk-APP75CBN.js";
|
|
@@ -17,9 +21,11 @@ import "../../chunk-GHGJAQSJ.js";
|
|
|
17
21
|
import {
|
|
18
22
|
getSystemPrompt
|
|
19
23
|
} from "../../chunk-FMLHRJDF.js";
|
|
20
|
-
import "../../chunk-
|
|
24
|
+
import "../../chunk-FMKJ72KT.js";
|
|
21
25
|
import "../../chunk-PZ5AY32C.js";
|
|
22
26
|
export {
|
|
27
|
+
createGitHubReadFileTool,
|
|
28
|
+
createGitHubSearchTool,
|
|
23
29
|
createWarpGrepTool,
|
|
24
30
|
openai_default as default,
|
|
25
31
|
execute,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// tools/warp_grep/providers/code_storage_http.ts
|
|
21
|
+
var code_storage_http_exports = {};
|
|
22
|
+
__export(code_storage_http_exports, {
|
|
23
|
+
createCodeStorageHttpCommands: () => createCodeStorageHttpCommands
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(code_storage_http_exports);
|
|
26
|
+
async function post(url, body, op) {
|
|
27
|
+
const res = await fetch(url, {
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers: { "Content-Type": "application/json" },
|
|
30
|
+
body: JSON.stringify(body)
|
|
31
|
+
});
|
|
32
|
+
if (!res.ok) {
|
|
33
|
+
const text = await res.text().catch(() => res.statusText);
|
|
34
|
+
throw new Error(`${op} failed (${res.status}): ${text}`);
|
|
35
|
+
}
|
|
36
|
+
const data = await res.json();
|
|
37
|
+
if (data.error) throw new Error(data.error);
|
|
38
|
+
return data.stdout;
|
|
39
|
+
}
|
|
40
|
+
function createCodeStorageHttpCommands(config) {
|
|
41
|
+
const { baseUrl, repoId, branch } = config;
|
|
42
|
+
const encodedRepoId = encodeURIComponent(repoId);
|
|
43
|
+
return {
|
|
44
|
+
grep: (pattern, path, glob) => post(`${baseUrl}/api/code-search/${encodedRepoId}/grep`, { pattern, path, glob, branch }, "grep"),
|
|
45
|
+
read: (path, start, end) => post(`${baseUrl}/api/code-search/${encodedRepoId}/read`, { path, start, end, branch }, "read"),
|
|
46
|
+
listDir: (path, maxDepth) => post(`${baseUrl}/api/code-search/${encodedRepoId}/list`, { path, maxDepth, branch }, "list")
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
createCodeStorageHttpCommands
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=code_storage_http.cjs.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 throw new 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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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;AACxD,UAAM,IAAI,MAAM,GAAG,EAAE,YAAY,IAAI,MAAM,MAAM,IAAI,EAAE;AAAA,EACzD;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":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { R as RemoteCommands } from '../../../types-DY_hq2eZ.js';
|
|
2
|
+
import './types.js';
|
|
3
|
+
import '../../utils/resilience.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* HTTP-based RemoteCommands for code search against the Morph landing API.
|
|
7
|
+
*
|
|
8
|
+
* Translates grep/read/listDir into POST requests to the code-search endpoints,
|
|
9
|
+
* so the WarpGrep agent can search GitHub repositories that have been indexed
|
|
10
|
+
* by the Morph code storage service.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface CodeStorageHttpConfig {
|
|
14
|
+
/** Base URL for the code search API (e.g. "https://morphllm.com") */
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
/** Repository ID returned by the get-or-create endpoint */
|
|
17
|
+
repoId: string;
|
|
18
|
+
/** Git branch to search */
|
|
19
|
+
branch: string;
|
|
20
|
+
}
|
|
21
|
+
declare function createCodeStorageHttpCommands(config: CodeStorageHttpConfig): RemoteCommands;
|
|
22
|
+
|
|
23
|
+
export { type CodeStorageHttpConfig, createCodeStorageHttpCommands };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WarpGrepProvider, GrepResult, ReadResult, ListDirectoryEntry } from './types.js';
|
|
2
|
-
import { R as RemoteCommands } from '../../../types-
|
|
2
|
+
import { R as RemoteCommands } from '../../../types-DY_hq2eZ.js';
|
|
3
3
|
import '../../utils/resilience.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// tools/warp_grep/utils/github.ts
|
|
21
|
+
var github_exports = {};
|
|
22
|
+
__export(github_exports, {
|
|
23
|
+
parseGitHubUrl: () => parseGitHubUrl
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(github_exports);
|
|
26
|
+
function parseGitHubUrl(input) {
|
|
27
|
+
input = input.trim();
|
|
28
|
+
const urlPattern = /^(?:https?:\/\/)?github\.com\/([^\/]+)\/([^\/\?\#]+)/;
|
|
29
|
+
const match = input.match(urlPattern);
|
|
30
|
+
if (match) {
|
|
31
|
+
return { owner: match[1], repo: match[2].replace(/\.git$/, "") };
|
|
32
|
+
}
|
|
33
|
+
const shortPattern = /^([^\/]+)\/([^\/]+)$/;
|
|
34
|
+
const shortMatch = input.match(shortPattern);
|
|
35
|
+
if (shortMatch && !shortMatch[1].includes(".")) {
|
|
36
|
+
return { owner: shortMatch[1], repo: shortMatch[2].replace(/\.git$/, "") };
|
|
37
|
+
}
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Invalid GitHub URL or shorthand: "${input}". Expected "owner/repo" or "https://github.com/owner/repo"`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
parseGitHubUrl
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=github.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../tools/warp_grep/utils/github.ts"],"sourcesContent":["/**\n * GitHub URL parsing utilities\n */\n\n/**\n * Parse GitHub URL or \"owner/repo\" shorthand into owner and repo components.\n * Handles: \"owner/repo\", \"https://github.com/owner/repo\", \"github.com/owner/repo.git\"\n */\nexport function parseGitHubUrl(input: string): { owner: string; repo: string } {\n input = input.trim();\n\n // Try URL patterns first\n const urlPattern = /^(?:https?:\\/\\/)?github\\.com\\/([^\\/]+)\\/([^\\/\\?\\#]+)/;\n const match = input.match(urlPattern);\n if (match) {\n return { owner: match[1], repo: match[2].replace(/\\.git$/, '') };\n }\n\n // Try \"owner/repo\" shorthand (reject if owner contains '.', e.g. \"github.com/owner\")\n const shortPattern = /^([^\\/]+)\\/([^\\/]+)$/;\n const shortMatch = input.match(shortPattern);\n if (shortMatch && !shortMatch[1].includes('.')) {\n return { owner: shortMatch[1], repo: shortMatch[2].replace(/\\.git$/, '') };\n }\n\n throw new Error(\n `Invalid GitHub URL or shorthand: \"${input}\". Expected \"owner/repo\" or \"https://github.com/owner/repo\"`\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,SAAS,eAAe,OAAgD;AAC7E,UAAQ,MAAM,KAAK;AAGnB,QAAM,aAAa;AACnB,QAAM,QAAQ,MAAM,MAAM,UAAU;AACpC,MAAI,OAAO;AACT,WAAO,EAAE,OAAO,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,EAAE,QAAQ,UAAU,EAAE,EAAE;AAAA,EACjE;AAGA,QAAM,eAAe;AACrB,QAAM,aAAa,MAAM,MAAM,YAAY;AAC3C,MAAI,cAAc,CAAC,WAAW,CAAC,EAAE,SAAS,GAAG,GAAG;AAC9C,WAAO,EAAE,OAAO,WAAW,CAAC,GAAG,MAAM,WAAW,CAAC,EAAE,QAAQ,UAAU,EAAE,EAAE;AAAA,EAC3E;AAEA,QAAM,IAAI;AAAA,IACR,qCAAqC,KAAK;AAAA,EAC5C;AACF;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub URL parsing utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Parse GitHub URL or "owner/repo" shorthand into owner and repo components.
|
|
6
|
+
* Handles: "owner/repo", "https://github.com/owner/repo", "github.com/owner/repo.git"
|
|
7
|
+
*/
|
|
8
|
+
declare function parseGitHubUrl(input: string): {
|
|
9
|
+
owner: string;
|
|
10
|
+
repo: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { parseGitHubUrl };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -572,6 +572,8 @@ Details: ${res.stderr}` : ""}`
|
|
|
572
572
|
// tools/warp_grep/vercel.ts
|
|
573
573
|
var vercel_exports = {};
|
|
574
574
|
__export(vercel_exports, {
|
|
575
|
+
createGitHubReadFileTool: () => createGitHubReadFileTool,
|
|
576
|
+
createGitHubSearchTool: () => createGitHubSearchTool,
|
|
575
577
|
createWarpGrepTool: () => createWarpGrepTool,
|
|
576
578
|
default: () => vercel_default,
|
|
577
579
|
execute: () => execute,
|
|
@@ -1380,7 +1382,7 @@ var import_openai = __toESM(require("openai"), 1);
|
|
|
1380
1382
|
// package.json
|
|
1381
1383
|
var package_default = {
|
|
1382
1384
|
name: "@morphllm/morphsdk",
|
|
1383
|
-
version: "0.2.
|
|
1385
|
+
version: "0.2.123",
|
|
1384
1386
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
1385
1387
|
type: "module",
|
|
1386
1388
|
main: "./dist/index.cjs",
|
|
@@ -1522,7 +1524,7 @@ var package_default = {
|
|
|
1522
1524
|
"!dist/**/*.test.*"
|
|
1523
1525
|
],
|
|
1524
1526
|
scripts: {
|
|
1525
|
-
build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/prompt.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
|
|
1527
|
+
build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/prompt.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
|
|
1526
1528
|
prepare: "npm run build",
|
|
1527
1529
|
typecheck: "tsc --noEmit",
|
|
1528
1530
|
lint: "eslint .",
|
|
@@ -1630,9 +1632,9 @@ async function callModel(messages, model, options = {}) {
|
|
|
1630
1632
|
});
|
|
1631
1633
|
} catch (error) {
|
|
1632
1634
|
if (error instanceof import_openai.default.APIError && error.status === 404) {
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
);
|
|
1635
|
+
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";
|
|
1636
|
+
const errorText = error.message?.trim();
|
|
1637
|
+
throw new Error(errorText || defaultMsg);
|
|
1636
1638
|
}
|
|
1637
1639
|
throw error;
|
|
1638
1640
|
}
|
|
@@ -2160,11 +2162,153 @@ var RemoteCommandsProvider = class {
|
|
|
2160
2162
|
}
|
|
2161
2163
|
};
|
|
2162
2164
|
|
|
2165
|
+
// tools/warp_grep/providers/code_storage_http.ts
|
|
2166
|
+
async function post(url, body, op) {
|
|
2167
|
+
const res = await fetch(url, {
|
|
2168
|
+
method: "POST",
|
|
2169
|
+
headers: { "Content-Type": "application/json" },
|
|
2170
|
+
body: JSON.stringify(body)
|
|
2171
|
+
});
|
|
2172
|
+
if (!res.ok) {
|
|
2173
|
+
const text = await res.text().catch(() => res.statusText);
|
|
2174
|
+
throw new Error(`${op} failed (${res.status}): ${text}`);
|
|
2175
|
+
}
|
|
2176
|
+
const data = await res.json();
|
|
2177
|
+
if (data.error) throw new Error(data.error);
|
|
2178
|
+
return data.stdout;
|
|
2179
|
+
}
|
|
2180
|
+
function createCodeStorageHttpCommands(config) {
|
|
2181
|
+
const { baseUrl, repoId, branch } = config;
|
|
2182
|
+
const encodedRepoId = encodeURIComponent(repoId);
|
|
2183
|
+
return {
|
|
2184
|
+
grep: (pattern, path5, glob) => post(`${baseUrl}/api/code-search/${encodedRepoId}/grep`, { pattern, path: path5, glob, branch }, "grep"),
|
|
2185
|
+
read: (path5, start, end) => post(`${baseUrl}/api/code-search/${encodedRepoId}/read`, { path: path5, start, end, branch }, "read"),
|
|
2186
|
+
listDir: (path5, maxDepth) => post(`${baseUrl}/api/code-search/${encodedRepoId}/list`, { path: path5, maxDepth, branch }, "list")
|
|
2187
|
+
};
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
// tools/warp_grep/utils/github.ts
|
|
2191
|
+
function parseGitHubUrl(input) {
|
|
2192
|
+
input = input.trim();
|
|
2193
|
+
const urlPattern = /^(?:https?:\/\/)?github\.com\/([^\/]+)\/([^\/\?\#]+)/;
|
|
2194
|
+
const match = input.match(urlPattern);
|
|
2195
|
+
if (match) {
|
|
2196
|
+
return { owner: match[1], repo: match[2].replace(/\.git$/, "") };
|
|
2197
|
+
}
|
|
2198
|
+
const shortPattern = /^([^\/]+)\/([^\/]+)$/;
|
|
2199
|
+
const shortMatch = input.match(shortPattern);
|
|
2200
|
+
if (shortMatch && !shortMatch[1].includes(".")) {
|
|
2201
|
+
return { owner: shortMatch[1], repo: shortMatch[2].replace(/\.git$/, "") };
|
|
2202
|
+
}
|
|
2203
|
+
throw new Error(
|
|
2204
|
+
`Invalid GitHub URL or shorthand: "${input}". Expected "owner/repo" or "https://github.com/owner/repo"`
|
|
2205
|
+
);
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2163
2208
|
// tools/warp_grep/client.ts
|
|
2209
|
+
var DEFAULT_CODE_SEARCH_URL = "https://morphllm.com";
|
|
2164
2210
|
async function getLocalProvider(repoRoot, excludes) {
|
|
2165
2211
|
const { LocalRipgrepProvider: LocalRipgrepProvider2 } = await Promise.resolve().then(() => (init_local(), local_exports));
|
|
2166
2212
|
return new LocalRipgrepProvider2(repoRoot, excludes);
|
|
2167
2213
|
}
|
|
2214
|
+
var WarpGrepClient = class {
|
|
2215
|
+
config;
|
|
2216
|
+
constructor(config = {}) {
|
|
2217
|
+
this.config = { ...config };
|
|
2218
|
+
}
|
|
2219
|
+
execute(input) {
|
|
2220
|
+
const toolConfig = {
|
|
2221
|
+
repoRoot: input.repoRoot,
|
|
2222
|
+
remoteCommands: input.remoteCommands,
|
|
2223
|
+
provider: input.provider,
|
|
2224
|
+
excludes: input.excludes,
|
|
2225
|
+
includes: input.includes,
|
|
2226
|
+
debug: input.debug ?? this.config.debug,
|
|
2227
|
+
morphApiKey: this.config.morphApiKey,
|
|
2228
|
+
morphApiUrl: this.config.morphApiUrl,
|
|
2229
|
+
retryConfig: this.config.retryConfig,
|
|
2230
|
+
timeout: this.config.timeout
|
|
2231
|
+
};
|
|
2232
|
+
if (input.streamSteps) {
|
|
2233
|
+
return executeToolCallStreaming({ query: input.query }, toolConfig);
|
|
2234
|
+
}
|
|
2235
|
+
return executeToolCall({ query: input.query }, toolConfig);
|
|
2236
|
+
}
|
|
2237
|
+
searchGitHub(input) {
|
|
2238
|
+
if (input.streamSteps) {
|
|
2239
|
+
return this._searchGitHubStreaming(input);
|
|
2240
|
+
}
|
|
2241
|
+
return this._searchGitHubAsync(input);
|
|
2242
|
+
}
|
|
2243
|
+
/**
|
|
2244
|
+
* Read a single file from a public GitHub repository
|
|
2245
|
+
*
|
|
2246
|
+
* @example
|
|
2247
|
+
* ```typescript
|
|
2248
|
+
* const result = await client.readGitHubFile({
|
|
2249
|
+
* github: 'vercel/next.js',
|
|
2250
|
+
* path: 'src/server/app-render/index.tsx',
|
|
2251
|
+
* startLine: 1,
|
|
2252
|
+
* endLine: 50,
|
|
2253
|
+
* });
|
|
2254
|
+
* if (result.success) console.log(result.content);
|
|
2255
|
+
* ```
|
|
2256
|
+
*/
|
|
2257
|
+
async readGitHubFile(input) {
|
|
2258
|
+
return executeGitHubReadFile(input, { timeout: this.config.timeout });
|
|
2259
|
+
}
|
|
2260
|
+
async _resolveGitHubRepo(input) {
|
|
2261
|
+
const { owner, repo } = parseGitHubUrl(input.github);
|
|
2262
|
+
const baseUrl = this.config.codeSearchUrl || DEFAULT_CODE_SEARCH_URL;
|
|
2263
|
+
const importRes = await fetch(`${baseUrl}/api/code-search/get-or-create?url=${encodeURIComponent(`${owner}/${repo}`)}`);
|
|
2264
|
+
if (!importRes.ok) {
|
|
2265
|
+
const text = await importRes.text().catch(() => importRes.statusText);
|
|
2266
|
+
throw new Error(`Failed to import repo ${owner}/${repo}: ${text}`);
|
|
2267
|
+
}
|
|
2268
|
+
const { repoId, defaultBranch } = await importRes.json();
|
|
2269
|
+
return {
|
|
2270
|
+
repo,
|
|
2271
|
+
remoteCommands: createCodeStorageHttpCommands({ baseUrl, repoId, branch: input.branch || defaultBranch })
|
|
2272
|
+
};
|
|
2273
|
+
}
|
|
2274
|
+
async _searchGitHubAsync(input) {
|
|
2275
|
+
try {
|
|
2276
|
+
const { repo, remoteCommands } = await this._resolveGitHubRepo(input);
|
|
2277
|
+
return this.execute({
|
|
2278
|
+
query: input.query,
|
|
2279
|
+
repoRoot: repo,
|
|
2280
|
+
remoteCommands
|
|
2281
|
+
});
|
|
2282
|
+
} catch (error) {
|
|
2283
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
async *_searchGitHubStreaming(input) {
|
|
2287
|
+
let repo;
|
|
2288
|
+
let remoteCommands;
|
|
2289
|
+
try {
|
|
2290
|
+
({ repo, remoteCommands } = await this._resolveGitHubRepo(input));
|
|
2291
|
+
} catch (error) {
|
|
2292
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
2293
|
+
}
|
|
2294
|
+
const generator = this.execute({
|
|
2295
|
+
query: input.query,
|
|
2296
|
+
repoRoot: repo,
|
|
2297
|
+
remoteCommands,
|
|
2298
|
+
streamSteps: true
|
|
2299
|
+
});
|
|
2300
|
+
let result;
|
|
2301
|
+
for (; ; ) {
|
|
2302
|
+
const { value, done } = await generator.next();
|
|
2303
|
+
if (done) {
|
|
2304
|
+
result = value;
|
|
2305
|
+
break;
|
|
2306
|
+
}
|
|
2307
|
+
yield value;
|
|
2308
|
+
}
|
|
2309
|
+
return result;
|
|
2310
|
+
}
|
|
2311
|
+
};
|
|
2168
2312
|
async function executeToolCall(input, config) {
|
|
2169
2313
|
const parsed = typeof input === "string" ? JSON.parse(input) : input;
|
|
2170
2314
|
const provider = config.remoteCommands ? new RemoteCommandsProvider(config.repoRoot, config.remoteCommands) : config.provider ?? await getLocalProvider(config.repoRoot, config.excludes);
|
|
@@ -2233,6 +2377,56 @@ async function* executeToolCallStreaming(input, config) {
|
|
|
2233
2377
|
}
|
|
2234
2378
|
return processAgentResult(agentResult);
|
|
2235
2379
|
}
|
|
2380
|
+
async function fetchRawGitHubFile(owner, repo, filePath, branch, timeout) {
|
|
2381
|
+
const branches = branch ? [branch] : ["HEAD"];
|
|
2382
|
+
const fallbacks = ["main", "master", "develop"];
|
|
2383
|
+
const fetchWithTimeout = (url) => timeout ? fetch(url, { signal: AbortSignal.timeout(timeout) }) : fetch(url);
|
|
2384
|
+
for (const b of branches) {
|
|
2385
|
+
const url = `https://raw.githubusercontent.com/${owner}/${repo}/${b}/${filePath}`;
|
|
2386
|
+
const res = await fetchWithTimeout(url);
|
|
2387
|
+
if (res.ok) return { content: await res.text(), branch: b };
|
|
2388
|
+
}
|
|
2389
|
+
for (const fb of fallbacks) {
|
|
2390
|
+
if (branch && fb === branch) continue;
|
|
2391
|
+
const url = `https://raw.githubusercontent.com/${owner}/${repo}/${fb}/${filePath}`;
|
|
2392
|
+
const res = await fetchWithTimeout(url);
|
|
2393
|
+
if (res.ok) return { content: await res.text(), branch: fb };
|
|
2394
|
+
}
|
|
2395
|
+
throw new Error(`File not found: ${owner}/${repo}/${filePath}`);
|
|
2396
|
+
}
|
|
2397
|
+
async function executeGitHubReadFile(input, config) {
|
|
2398
|
+
try {
|
|
2399
|
+
const { owner, repo } = parseGitHubUrl(input.github);
|
|
2400
|
+
const { content: raw, branch } = await fetchRawGitHubFile(
|
|
2401
|
+
owner,
|
|
2402
|
+
repo,
|
|
2403
|
+
input.path,
|
|
2404
|
+
input.branch,
|
|
2405
|
+
config?.timeout
|
|
2406
|
+
);
|
|
2407
|
+
const allLines = raw.split("\n");
|
|
2408
|
+
const totalLines = allLines.length;
|
|
2409
|
+
const start = Math.max(1, input.startLine ?? 1);
|
|
2410
|
+
const end = Math.min(totalLines, input.endLine ?? totalLines);
|
|
2411
|
+
const selected = allLines.slice(start - 1, end);
|
|
2412
|
+
const padWidth = String(end).length;
|
|
2413
|
+
const numbered = selected.map((line, i) => `${String(start + i).padStart(padWidth)}|${line}`).join("\n");
|
|
2414
|
+
return {
|
|
2415
|
+
success: true,
|
|
2416
|
+
content: numbered,
|
|
2417
|
+
path: input.path,
|
|
2418
|
+
github: `${owner}/${repo}`,
|
|
2419
|
+
branch,
|
|
2420
|
+
lineRange: [start, end],
|
|
2421
|
+
totalLines
|
|
2422
|
+
};
|
|
2423
|
+
} catch (error) {
|
|
2424
|
+
return {
|
|
2425
|
+
success: false,
|
|
2426
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2236
2430
|
function formatResult(result) {
|
|
2237
2431
|
if (!result.success) {
|
|
2238
2432
|
return `Search failed: ${result.error}`;
|
|
@@ -2260,6 +2454,9 @@ function formatResult(result) {
|
|
|
2260
2454
|
|
|
2261
2455
|
// tools/warp_grep/prompts.ts
|
|
2262
2456
|
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.';
|
|
2457
|
+
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.';
|
|
2458
|
+
var GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;
|
|
2459
|
+
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.";
|
|
2263
2460
|
|
|
2264
2461
|
// tools/warp_grep/vercel.ts
|
|
2265
2462
|
var warpGrepJsonSchema = {
|
|
@@ -2308,9 +2505,52 @@ function createWarpGrepTool(config) {
|
|
|
2308
2505
|
}
|
|
2309
2506
|
});
|
|
2310
2507
|
}
|
|
2508
|
+
function createGitHubSearchTool(config) {
|
|
2509
|
+
const client = new WarpGrepClient(config);
|
|
2510
|
+
return (0, import_ai.tool)({
|
|
2511
|
+
description: GITHUB_SEARCH_DESCRIPTION,
|
|
2512
|
+
inputSchema: import_zod.z.object({
|
|
2513
|
+
query: import_zod.z.string().describe("Natural language search query"),
|
|
2514
|
+
github: import_zod.z.string().describe('GitHub URL or "owner/repo" shorthand'),
|
|
2515
|
+
branch: import_zod.z.string().optional().describe("Branch to search (defaults to repo default branch)")
|
|
2516
|
+
}),
|
|
2517
|
+
execute: async (params) => {
|
|
2518
|
+
const result = await client.searchGitHub(params);
|
|
2519
|
+
if (!result.success) {
|
|
2520
|
+
throw new Error(`GitHub search failed: ${result.error}`);
|
|
2521
|
+
}
|
|
2522
|
+
return {
|
|
2523
|
+
success: true,
|
|
2524
|
+
contexts: result.contexts,
|
|
2525
|
+
summary: result.summary
|
|
2526
|
+
};
|
|
2527
|
+
}
|
|
2528
|
+
});
|
|
2529
|
+
}
|
|
2530
|
+
function createGitHubReadFileTool(config) {
|
|
2531
|
+
return (0, import_ai.tool)({
|
|
2532
|
+
description: GITHUB_READ_FILE_DESCRIPTION,
|
|
2533
|
+
inputSchema: import_zod.z.object({
|
|
2534
|
+
github: import_zod.z.string().describe('owner/repo shorthand (e.g., "vercel/next.js")'),
|
|
2535
|
+
path: import_zod.z.string().describe("File path within the repository"),
|
|
2536
|
+
startLine: import_zod.z.number().optional().describe("Start line number (1-based)"),
|
|
2537
|
+
endLine: import_zod.z.number().optional().describe("End line number (1-based, inclusive)"),
|
|
2538
|
+
branch: import_zod.z.string().optional().describe("Branch to read from (defaults to repo default branch)")
|
|
2539
|
+
}),
|
|
2540
|
+
execute: async (params) => {
|
|
2541
|
+
const result = await executeGitHubReadFile(params, config);
|
|
2542
|
+
if (!result.success) {
|
|
2543
|
+
throw new Error(`GitHub read file failed: ${result.error}`);
|
|
2544
|
+
}
|
|
2545
|
+
return result;
|
|
2546
|
+
}
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2311
2549
|
var vercel_default = createWarpGrepTool;
|
|
2312
2550
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2313
2551
|
0 && (module.exports = {
|
|
2552
|
+
createGitHubReadFileTool,
|
|
2553
|
+
createGitHubSearchTool,
|
|
2314
2554
|
createWarpGrepTool,
|
|
2315
2555
|
execute,
|
|
2316
2556
|
formatResult,
|