@morphllm/morphsdk 0.2.69 → 0.2.70
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-B3J2O2NW.js → chunk-AB27WETH.js} +4 -4
- package/dist/chunk-B5A4XLSQ.js +10 -0
- package/dist/chunk-B5A4XLSQ.js.map +1 -0
- package/dist/{chunk-P6OEPI4N.js → chunk-GZP6HY5W.js} +3 -19
- package/dist/{chunk-P6OEPI4N.js.map → chunk-GZP6HY5W.js.map} +1 -1
- package/dist/{chunk-XFCMTW5L.js → chunk-I2GXV3BQ.js} +2 -15
- package/dist/{chunk-XFCMTW5L.js.map → chunk-I2GXV3BQ.js.map} +1 -1
- package/dist/{chunk-Q6GHKKS5.js → chunk-PT3DGIUF.js} +2 -14
- package/dist/{chunk-Q6GHKKS5.js.map → chunk-PT3DGIUF.js.map} +1 -1
- package/dist/client.js +4 -4
- package/dist/index.cjs +5 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -6
- package/dist/tools/warp_grep/anthropic.d.ts +78 -3
- package/dist/tools/warp_grep/anthropic.js +1 -1
- package/dist/tools/warp_grep/gemini.cjs +2 -3
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +109 -3
- package/dist/tools/warp_grep/gemini.js +44 -7
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/index.cjs +6 -187
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +89 -9
- package/dist/tools/warp_grep/index.js +3 -16
- package/dist/tools/warp_grep/openai.d.ts +78 -3
- package/dist/tools/warp_grep/openai.js +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +56 -3
- package/dist/tools/warp_grep/vercel.js +1 -1
- package/package.json +1 -1
- package/dist/anthropic-BC-AMEIN.d.ts +0 -89
- package/dist/chunk-2LSVUHIE.js +0 -75
- package/dist/chunk-2LSVUHIE.js.map +0 -1
- package/dist/chunk-ISWL67SF.js +0 -1
- package/dist/chunk-ISWL67SF.js.map +0 -1
- package/dist/gemini-BIFBiIjY.d.ts +0 -119
- package/dist/openai-Beb9escY.d.ts +0 -89
- package/dist/vercel-Bo84tpBe.d.ts +0 -66
- /package/dist/{chunk-B3J2O2NW.js.map → chunk-AB27WETH.js.map} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
export { WarpGrepClient, executeToolCall, executeWarpGrep, formatResult } from './client.js';
|
|
2
3
|
export { R as RemoteCommands, W as WarpGrepClientConfig, c as WarpGrepContext, a as WarpGrepInput, b as WarpGrepResult, d as WarpGrepToolConfig } from '../../types-CnvVDM63.js';
|
|
3
4
|
export { GrepResult, ListDirectoryEntry, ReadResult, WarpGrepProvider } from './providers/types.js';
|
|
@@ -7,15 +8,7 @@ export { runWarpGrep } from './agent/runner.js';
|
|
|
7
8
|
export { AgentRunResult, ChatMessage, SessionConfig } from './agent/types.js';
|
|
8
9
|
export { SYSTEM_PROMPT as WARP_GREP_SYSTEM_PROMPT, getSystemPrompt } from './agent/prompt.js';
|
|
9
10
|
export { n as normalizeFinishFiles, r as readFinishFiles, t as toolGrep, b as toolListDirectory, a as toolRead } from '../../finish-pPJfB0uO.js';
|
|
10
|
-
export { a as anthropic } from '../../anthropic-BC-AMEIN.js';
|
|
11
|
-
export { o as openai } from '../../openai-Beb9escY.js';
|
|
12
|
-
export { v as vercel } from '../../vercel-Bo84tpBe.js';
|
|
13
|
-
export { g as gemini } from '../../gemini-BIFBiIjY.js';
|
|
14
11
|
import '../utils/resilience.js';
|
|
15
|
-
import '@anthropic-ai/sdk/resources/messages';
|
|
16
|
-
import 'openai/resources/chat/completions';
|
|
17
|
-
import 'ai';
|
|
18
|
-
import '@google/generative-ai';
|
|
19
12
|
|
|
20
13
|
/**
|
|
21
14
|
* Prompts and descriptions for warpgrep_codebase_search
|
|
@@ -29,4 +22,91 @@ declare const WARP_GREP_TOOL_NAME = "warpgrep_codebase_search";
|
|
|
29
22
|
*/
|
|
30
23
|
declare const WARP_GREP_DESCRIPTION: string;
|
|
31
24
|
|
|
32
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Morph Warp Grep SDK
|
|
27
|
+
*
|
|
28
|
+
* Fast and accurate code search tool for AI agents.
|
|
29
|
+
* Uses ripgrep locally, or use `remoteCommands` for sandbox environments.
|
|
30
|
+
*
|
|
31
|
+
* @example Local usage
|
|
32
|
+
* ```typescript
|
|
33
|
+
* // With MorphClient (recommended)
|
|
34
|
+
* import { MorphClient } from '@morphllm/morphsdk';
|
|
35
|
+
*
|
|
36
|
+
* const morph = new MorphClient({ morphApiKey: process.env.MORPH_API_KEY });
|
|
37
|
+
* const result = await morph.warpGrep.execute({
|
|
38
|
+
* query: 'Find authentication middleware',
|
|
39
|
+
* repoRoot: '.'
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // Standalone client
|
|
46
|
+
* import { WarpGrepClient } from '@morphllm/morphsdk/tools/warp-grep';
|
|
47
|
+
*
|
|
48
|
+
* const client = new WarpGrepClient({ morphApiKey: process.env.MORPH_API_KEY });
|
|
49
|
+
* const result = await client.execute({
|
|
50
|
+
* query: 'Find authentication middleware',
|
|
51
|
+
* repoRoot: '.'
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // As a tool for AI agents
|
|
58
|
+
* import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';
|
|
59
|
+
*
|
|
60
|
+
* const tool = createWarpGrepTool({ repoRoot: '.' });
|
|
61
|
+
* // Pass to Claude, GPT, Gemini, etc.
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @example Remote sandbox (E2B, Modal, Daytona, etc.)
|
|
65
|
+
* ```typescript
|
|
66
|
+
* import { createMorphWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';
|
|
67
|
+
*
|
|
68
|
+
* const tool = createMorphWarpGrepTool({
|
|
69
|
+
* repoRoot: '/home/repo',
|
|
70
|
+
* remoteCommands: {
|
|
71
|
+
* grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,
|
|
72
|
+
* read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,
|
|
73
|
+
* listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,
|
|
74
|
+
* },
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @example Provider-agnostic usage (bring your own tool abstraction)
|
|
79
|
+
* ```typescript
|
|
80
|
+
* import {
|
|
81
|
+
* warpGrepInputSchema,
|
|
82
|
+
* executeToolCall,
|
|
83
|
+
* WARP_GREP_TOOL_NAME,
|
|
84
|
+
* WARP_GREP_DESCRIPTION,
|
|
85
|
+
* } from '@morphllm/morphsdk/tools/warp-grep';
|
|
86
|
+
*
|
|
87
|
+
* // Use with your own tool definition abstraction
|
|
88
|
+
* const toolDef = createToolDef({
|
|
89
|
+
* name: WARP_GREP_TOOL_NAME,
|
|
90
|
+
* description: WARP_GREP_DESCRIPTION,
|
|
91
|
+
* schema: warpGrepInputSchema,
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* // Execute
|
|
95
|
+
* const result = await executeToolCall(
|
|
96
|
+
* { query: 'Find auth middleware' },
|
|
97
|
+
* { repoRoot: '.', morphApiKey: process.env.MORPH_API_KEY }
|
|
98
|
+
* );
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/** Provider-agnostic Zod schema for warp grep input */
|
|
103
|
+
declare const warpGrepInputSchema: z.ZodObject<{
|
|
104
|
+
query: z.ZodString;
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
|
+
query: string;
|
|
107
|
+
}, {
|
|
108
|
+
query: string;
|
|
109
|
+
}>;
|
|
110
|
+
type WarpGrepInputSchema = z.infer<typeof warpGrepInputSchema>;
|
|
111
|
+
|
|
112
|
+
export { WARP_GREP_DESCRIPTION, WARP_GREP_TOOL_NAME, type WarpGrepInputSchema, warpGrepInputSchema };
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import "../../chunk-ISWL67SF.js";
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import {
|
|
6
|
-
anthropic_exports
|
|
7
|
-
} from "../../chunk-Q6GHKKS5.js";
|
|
8
|
-
import {
|
|
9
|
-
openai_exports
|
|
10
|
-
} from "../../chunk-XFCMTW5L.js";
|
|
11
|
-
import {
|
|
12
|
-
vercel_exports
|
|
13
|
-
} from "../../chunk-P6OEPI4N.js";
|
|
2
|
+
warpGrepInputSchema
|
|
3
|
+
} from "../../chunk-B5A4XLSQ.js";
|
|
14
4
|
import {
|
|
15
5
|
WARP_GREP_DESCRIPTION,
|
|
16
6
|
WARP_GREP_TOOL_NAME
|
|
@@ -56,19 +46,16 @@ export {
|
|
|
56
46
|
SYSTEM_PROMPT as WARP_GREP_SYSTEM_PROMPT,
|
|
57
47
|
WARP_GREP_TOOL_NAME,
|
|
58
48
|
WarpGrepClient,
|
|
59
|
-
anthropic_exports as anthropic,
|
|
60
49
|
executeToolCall,
|
|
61
50
|
executeWarpGrep,
|
|
62
51
|
formatResult,
|
|
63
|
-
gemini_exports as gemini,
|
|
64
52
|
getSystemPrompt,
|
|
65
53
|
normalizeFinishFiles,
|
|
66
|
-
openai_exports as openai,
|
|
67
54
|
readFinishFiles,
|
|
68
55
|
runWarpGrep,
|
|
69
56
|
toolGrep,
|
|
70
57
|
toolListDirectory,
|
|
71
58
|
toolRead,
|
|
72
|
-
|
|
59
|
+
warpGrepInputSchema
|
|
73
60
|
};
|
|
74
61
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,82 @@
|
|
|
1
|
-
import 'openai/resources/chat/completions';
|
|
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 '../../types-CnvVDM63.js';
|
|
5
|
-
export { c as createWarpGrepTool, w as default, e as execute, w as warpGrepTool } from '../../openai-Beb9escY.js';
|
|
4
|
+
import { d as WarpGrepToolConfig, b as WarpGrepResult } from '../../types-CnvVDM63.js';
|
|
6
5
|
import './providers/types.js';
|
|
7
6
|
import '../utils/resilience.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* OpenAI SDK adapter for morph-warp-grep tool
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* OpenAI-native warp grep tool definition
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import OpenAI from 'openai';
|
|
18
|
+
* import { warpGrepTool, execute } from '@morphllm/morphsdk/tools/warp-grep/openai';
|
|
19
|
+
*
|
|
20
|
+
* const client = new OpenAI();
|
|
21
|
+
* const response = await client.chat.completions.create({
|
|
22
|
+
* model: 'gpt-4o',
|
|
23
|
+
* tools: [warpGrepTool],
|
|
24
|
+
* messages: [{ role: 'user', content: 'Find authentication middleware' }]
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Execute the tool call
|
|
28
|
+
* const result = await execute({ query: '...' }, { repoRoot: '.' });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare const warpGrepTool: ChatCompletionTool;
|
|
32
|
+
/**
|
|
33
|
+
* Execute warp grep search
|
|
34
|
+
*
|
|
35
|
+
* @param input - Tool input with query
|
|
36
|
+
* @param config - Configuration with repoRoot and optional provider
|
|
37
|
+
* @returns Search results
|
|
38
|
+
*/
|
|
39
|
+
declare function execute(input: {
|
|
40
|
+
query: string;
|
|
41
|
+
} | string, config: WarpGrepToolConfig): Promise<WarpGrepResult>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Create a custom warp grep tool with configuration and methods
|
|
45
|
+
*
|
|
46
|
+
* @param config - Configuration options
|
|
47
|
+
* @returns Tool definition with execute and formatResult methods
|
|
48
|
+
*
|
|
49
|
+
* @example Local usage
|
|
50
|
+
* ```typescript
|
|
51
|
+
* import OpenAI from 'openai';
|
|
52
|
+
* import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/openai';
|
|
53
|
+
*
|
|
54
|
+
* const tool = createWarpGrepTool({ repoRoot: '.' });
|
|
55
|
+
*
|
|
56
|
+
* const client = new OpenAI();
|
|
57
|
+
* const response = await client.chat.completions.create({
|
|
58
|
+
* model: 'gpt-4o',
|
|
59
|
+
* tools: [tool],
|
|
60
|
+
* messages: [{ role: 'user', content: 'Find authentication middleware' }]
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @example Remote sandbox (E2B, Modal, etc.)
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const tool = createMorphWarpGrepTool({
|
|
67
|
+
* repoRoot: '/home/repo',
|
|
68
|
+
* remoteCommands: {
|
|
69
|
+
* grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,
|
|
70
|
+
* read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,
|
|
71
|
+
* listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,
|
|
72
|
+
* },
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function createWarpGrepTool(config: WarpGrepToolConfig): ChatCompletionTool & {
|
|
77
|
+
execute: (input: unknown) => Promise<WarpGrepResult>;
|
|
78
|
+
formatResult: (result: WarpGrepResult) => string;
|
|
79
|
+
getSystemPrompt: () => string;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { createWarpGrepTool, warpGrepTool as default, execute, warpGrepTool };
|
|
@@ -1,7 +1,60 @@
|
|
|
1
|
-
import 'ai';
|
|
2
|
-
import '../../types-CnvVDM63.js';
|
|
1
|
+
import * as ai from 'ai';
|
|
2
|
+
import { d as WarpGrepToolConfig, c as WarpGrepContext, b as WarpGrepResult } from '../../types-CnvVDM63.js';
|
|
3
3
|
export { formatResult } from './client.js';
|
|
4
4
|
export { getSystemPrompt } from './agent/prompt.js';
|
|
5
|
-
export { c as createWarpGrepTool, c as default, e as execute } from '../../vercel-Bo84tpBe.js';
|
|
6
5
|
import './providers/types.js';
|
|
7
6
|
import '../utils/resilience.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Execute warp grep search
|
|
10
|
+
*
|
|
11
|
+
* @param input - Tool input with query
|
|
12
|
+
* @param config - Configuration with repoRoot and optional provider
|
|
13
|
+
* @returns Search results
|
|
14
|
+
*/
|
|
15
|
+
declare function execute(input: {
|
|
16
|
+
query: string;
|
|
17
|
+
}, config: WarpGrepToolConfig): Promise<WarpGrepResult>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create Vercel AI SDK warp grep tool
|
|
21
|
+
*
|
|
22
|
+
* @param config - Configuration options
|
|
23
|
+
* @returns Vercel AI SDK tool
|
|
24
|
+
*
|
|
25
|
+
* @example Local usage
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { generateText } from 'ai';
|
|
28
|
+
* import { anthropic } from '@ai-sdk/anthropic';
|
|
29
|
+
* import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';
|
|
30
|
+
*
|
|
31
|
+
* const grepTool = createWarpGrepTool({ repoRoot: '.' });
|
|
32
|
+
*
|
|
33
|
+
* const result = await generateText({
|
|
34
|
+
* model: anthropic('claude-sonnet-4-5-20250929'),
|
|
35
|
+
* tools: { grep: grepTool },
|
|
36
|
+
* prompt: 'Find authentication middleware'
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example Remote sandbox (E2B, Modal, etc.)
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const grepTool = createMorphWarpGrepTool({
|
|
43
|
+
* repoRoot: '/home/repo',
|
|
44
|
+
* remoteCommands: {
|
|
45
|
+
* grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,
|
|
46
|
+
* read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,
|
|
47
|
+
* listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,
|
|
48
|
+
* },
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function createWarpGrepTool(config: WarpGrepToolConfig): ai.Tool<{
|
|
53
|
+
query: string;
|
|
54
|
+
}, {
|
|
55
|
+
success: boolean;
|
|
56
|
+
contexts: WarpGrepContext[] | undefined;
|
|
57
|
+
summary: string | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
|
|
60
|
+
export { createWarpGrepTool, createWarpGrepTool as default, execute };
|
package/package.json
CHANGED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { Tool } from '@anthropic-ai/sdk/resources/messages';
|
|
2
|
-
import { formatResult } from './tools/warp_grep/client.js';
|
|
3
|
-
import { getSystemPrompt } from './tools/warp_grep/agent/prompt.js';
|
|
4
|
-
import { d as WarpGrepToolConfig, b as WarpGrepResult } from './types-CnvVDM63.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Anthropic SDK adapter for morph-warp-grep tool
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Anthropic-native warp grep tool definition
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import Anthropic from '@anthropic-ai/sdk';
|
|
16
|
-
* import { warpGrepTool, execute } from '@morphllm/morphsdk/tools/warp-grep/anthropic';
|
|
17
|
-
*
|
|
18
|
-
* const client = new Anthropic();
|
|
19
|
-
* const response = await client.messages.create({
|
|
20
|
-
* model: 'claude-sonnet-4-5-20250929',
|
|
21
|
-
* tools: [warpGrepTool],
|
|
22
|
-
* messages: [{ role: 'user', content: 'Find authentication middleware' }]
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
* // Execute the tool call
|
|
26
|
-
* const result = await execute({ query: '...' }, { repoRoot: '.' });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
declare const warpGrepTool: Tool;
|
|
30
|
-
/**
|
|
31
|
-
* Execute warp grep search
|
|
32
|
-
*
|
|
33
|
-
* @param input - Tool input with query
|
|
34
|
-
* @param config - Configuration with repoRoot and optional provider
|
|
35
|
-
* @returns Search results
|
|
36
|
-
*/
|
|
37
|
-
declare function execute(input: {
|
|
38
|
-
query: string;
|
|
39
|
-
} | string, config: WarpGrepToolConfig): Promise<WarpGrepResult>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Create a custom warp grep tool with configuration and methods
|
|
43
|
-
*
|
|
44
|
-
* @param config - Configuration options
|
|
45
|
-
* @returns Tool definition with execute and formatResult methods
|
|
46
|
-
*
|
|
47
|
-
* @example Local usage
|
|
48
|
-
* ```typescript
|
|
49
|
-
* import Anthropic from '@anthropic-ai/sdk';
|
|
50
|
-
* import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';
|
|
51
|
-
*
|
|
52
|
-
* const tool = createWarpGrepTool({ repoRoot: '.' });
|
|
53
|
-
*
|
|
54
|
-
* const client = new Anthropic();
|
|
55
|
-
* const response = await client.messages.create({
|
|
56
|
-
* model: 'claude-sonnet-4-5-20250929',
|
|
57
|
-
* tools: [tool],
|
|
58
|
-
* messages: [{ role: 'user', content: 'Find authentication middleware' }]
|
|
59
|
-
* });
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @example Remote sandbox (E2B, Modal, etc.)
|
|
63
|
-
* ```typescript
|
|
64
|
-
* const tool = createMorphWarpGrepTool({
|
|
65
|
-
* repoRoot: '/home/repo',
|
|
66
|
-
* remoteCommands: {
|
|
67
|
-
* grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,
|
|
68
|
-
* read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,
|
|
69
|
-
* listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,
|
|
70
|
-
* },
|
|
71
|
-
* });
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
declare function createWarpGrepTool(config: WarpGrepToolConfig): Tool & {
|
|
75
|
-
execute: (input: unknown) => Promise<WarpGrepResult>;
|
|
76
|
-
formatResult: (result: WarpGrepResult) => string;
|
|
77
|
-
getSystemPrompt: () => string;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
declare const anthropic_createWarpGrepTool: typeof createWarpGrepTool;
|
|
81
|
-
declare const anthropic_execute: typeof execute;
|
|
82
|
-
declare const anthropic_formatResult: typeof formatResult;
|
|
83
|
-
declare const anthropic_getSystemPrompt: typeof getSystemPrompt;
|
|
84
|
-
declare const anthropic_warpGrepTool: typeof warpGrepTool;
|
|
85
|
-
declare namespace anthropic {
|
|
86
|
-
export { anthropic_createWarpGrepTool as createWarpGrepTool, anthropic_execute as execute, anthropic_formatResult as formatResult, anthropic_getSystemPrompt as getSystemPrompt, anthropic_warpGrepTool as warpGrepTool };
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export { anthropic as a, createWarpGrepTool as c, execute as e, warpGrepTool as w };
|
package/dist/chunk-2LSVUHIE.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WARP_GREP_DESCRIPTION,
|
|
3
|
-
WARP_GREP_TOOL_NAME
|
|
4
|
-
} from "./chunk-KW7OEGZK.js";
|
|
5
|
-
import {
|
|
6
|
-
executeToolCall,
|
|
7
|
-
formatResult
|
|
8
|
-
} from "./chunk-E4434A4Y.js";
|
|
9
|
-
import {
|
|
10
|
-
getSystemPrompt
|
|
11
|
-
} from "./chunk-Q5AHGIQO.js";
|
|
12
|
-
import {
|
|
13
|
-
__export
|
|
14
|
-
} from "./chunk-PZ5AY32C.js";
|
|
15
|
-
|
|
16
|
-
// tools/warp_grep/gemini.ts
|
|
17
|
-
var gemini_exports = {};
|
|
18
|
-
__export(gemini_exports, {
|
|
19
|
-
createMorphWarpGrepTool: () => createMorphWarpGrepTool,
|
|
20
|
-
createWarpGrepTool: () => createWarpGrepTool,
|
|
21
|
-
default: () => gemini_default,
|
|
22
|
-
execute: () => execute,
|
|
23
|
-
formatResult: () => formatResult,
|
|
24
|
-
getSystemPrompt: () => getSystemPrompt,
|
|
25
|
-
warpGrepFunctionDeclaration: () => warpGrepFunctionDeclaration
|
|
26
|
-
});
|
|
27
|
-
import { SchemaType } from "@google/generative-ai";
|
|
28
|
-
var TOOL_PARAMETERS = {
|
|
29
|
-
type: SchemaType.OBJECT,
|
|
30
|
-
properties: {
|
|
31
|
-
query: {
|
|
32
|
-
type: SchemaType.STRING,
|
|
33
|
-
description: "Free-form repository question"
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
required: ["query"]
|
|
37
|
-
};
|
|
38
|
-
var warpGrepFunctionDeclaration = {
|
|
39
|
-
name: WARP_GREP_TOOL_NAME,
|
|
40
|
-
description: WARP_GREP_DESCRIPTION,
|
|
41
|
-
parameters: TOOL_PARAMETERS
|
|
42
|
-
};
|
|
43
|
-
async function execute(input, config) {
|
|
44
|
-
return executeToolCall(input, config);
|
|
45
|
-
}
|
|
46
|
-
function createWarpGrepTool(config) {
|
|
47
|
-
const declaration = {
|
|
48
|
-
name: config.name ?? WARP_GREP_TOOL_NAME,
|
|
49
|
-
description: config.description ?? WARP_GREP_DESCRIPTION,
|
|
50
|
-
parameters: TOOL_PARAMETERS
|
|
51
|
-
};
|
|
52
|
-
return Object.assign(declaration, {
|
|
53
|
-
execute: async (input) => {
|
|
54
|
-
return executeToolCall(input, config);
|
|
55
|
-
},
|
|
56
|
-
formatResult: (result) => {
|
|
57
|
-
return formatResult(result);
|
|
58
|
-
},
|
|
59
|
-
getSystemPrompt: () => {
|
|
60
|
-
return getSystemPrompt();
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
var createMorphWarpGrepTool = createWarpGrepTool;
|
|
65
|
-
var gemini_default = warpGrepFunctionDeclaration;
|
|
66
|
-
|
|
67
|
-
export {
|
|
68
|
-
warpGrepFunctionDeclaration,
|
|
69
|
-
execute,
|
|
70
|
-
createWarpGrepTool,
|
|
71
|
-
createMorphWarpGrepTool,
|
|
72
|
-
gemini_default,
|
|
73
|
-
gemini_exports
|
|
74
|
-
};
|
|
75
|
-
//# sourceMappingURL=chunk-2LSVUHIE.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/warp_grep/gemini.ts"],"sourcesContent":["/**\n * Google Gemini SDK adapter for morph-warp-grep tool\n */\n\nimport type { FunctionDeclaration, FunctionDeclarationSchema } from '@google/generative-ai';\nimport { SchemaType } from '@google/generative-ai';\nimport { executeToolCall, formatResult } from './client.js';\nimport { WARP_GREP_DESCRIPTION, WARP_GREP_TOOL_NAME, getSystemPrompt } from './prompts.js';\nimport type { WarpGrepToolConfig, WarpGrepResult } from './types.js';\n\n/**\n * Parameter schema for the warp grep tool (Gemini format)\n */\nconst TOOL_PARAMETERS: FunctionDeclarationSchema = {\n type: SchemaType.OBJECT,\n properties: {\n query: { \n type: SchemaType.STRING, \n description: 'Free-form repository question' \n },\n },\n required: ['query'],\n};\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\n// Re-export formatResult and getSystemPrompt for convenience\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\nexport default warpGrepFunctionDeclaration;\n\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,SAAS,kBAAkB;AAQ3B,IAAM,kBAA6C;AAAA,EACjD,MAAM,WAAW;AAAA,EACjB,YAAY;AAAA,IACV,OAAO;AAAA,MACL,MAAM,WAAW;AAAA,MACjB,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;AAgEO,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,IAAO,iBAAQ;","names":[]}
|
package/dist/chunk-ISWL67SF.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-ISWL67SF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { FunctionDeclaration } from '@google/generative-ai';
|
|
2
|
-
import { formatResult } from './tools/warp_grep/client.js';
|
|
3
|
-
import { getSystemPrompt } from './tools/warp_grep/agent/prompt.js';
|
|
4
|
-
import { d as WarpGrepToolConfig, b as WarpGrepResult } from './types-CnvVDM63.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Google Gemini SDK adapter for morph-warp-grep tool
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Gemini-native warp grep function declaration
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { GoogleGenerativeAI } from '@google/generative-ai';
|
|
16
|
-
* import { warpGrepFunctionDeclaration, execute } from '@morphllm/morphsdk/tools/warp-grep/gemini';
|
|
17
|
-
*
|
|
18
|
-
* const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);
|
|
19
|
-
* const model = genAI.getGenerativeModel({
|
|
20
|
-
* model: 'gemini-2.0-flash',
|
|
21
|
-
* tools: [{ functionDeclarations: [warpGrepFunctionDeclaration] }]
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* const chat = model.startChat();
|
|
25
|
-
* const result = await chat.sendMessage('Find authentication middleware');
|
|
26
|
-
*
|
|
27
|
-
* // Handle function call
|
|
28
|
-
* const call = result.response.functionCalls()?.[0];
|
|
29
|
-
* if (call) {
|
|
30
|
-
* const searchResult = await execute(call.args, { repoRoot: '.' });
|
|
31
|
-
* console.log(searchResult);
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
declare const warpGrepFunctionDeclaration: FunctionDeclaration;
|
|
36
|
-
/**
|
|
37
|
-
* Execute warp grep search
|
|
38
|
-
*
|
|
39
|
-
* @param input - Tool input with query
|
|
40
|
-
* @param config - Configuration with repoRoot and optional provider
|
|
41
|
-
* @returns Search results
|
|
42
|
-
*/
|
|
43
|
-
declare function execute(input: {
|
|
44
|
-
query: string;
|
|
45
|
-
} | string, config: WarpGrepToolConfig): Promise<WarpGrepResult>;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Gemini tool with execute method attached
|
|
49
|
-
*/
|
|
50
|
-
interface GeminiWarpGrepTool extends FunctionDeclaration {
|
|
51
|
-
execute: (input: unknown) => Promise<WarpGrepResult>;
|
|
52
|
-
formatResult: (result: WarpGrepResult) => string;
|
|
53
|
-
getSystemPrompt: () => string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Create a custom warp grep tool with configuration and methods
|
|
57
|
-
*
|
|
58
|
-
* @param config - Configuration options
|
|
59
|
-
* @returns Function declaration with execute and formatResult methods
|
|
60
|
-
*
|
|
61
|
-
* @example Local usage
|
|
62
|
-
* ```typescript
|
|
63
|
-
* import { GoogleGenerativeAI } from '@google/generative-ai';
|
|
64
|
-
* import { createMorphWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/gemini';
|
|
65
|
-
*
|
|
66
|
-
* const tool = createMorphWarpGrepTool({ repoRoot: '.' });
|
|
67
|
-
*
|
|
68
|
-
* const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);
|
|
69
|
-
* const model = genAI.getGenerativeModel({
|
|
70
|
-
* model: 'gemini-2.0-flash',
|
|
71
|
-
* tools: [{ functionDeclarations: [tool] }]
|
|
72
|
-
* });
|
|
73
|
-
*
|
|
74
|
-
* const chat = model.startChat();
|
|
75
|
-
* const result = await chat.sendMessage('Find authentication middleware');
|
|
76
|
-
*
|
|
77
|
-
* // Handle function call
|
|
78
|
-
* const call = result.response.functionCalls()?.[0];
|
|
79
|
-
* if (call && call.name === tool.name) {
|
|
80
|
-
* const searchResult = await tool.execute(call.args);
|
|
81
|
-
* console.log(tool.formatResult(searchResult));
|
|
82
|
-
*
|
|
83
|
-
* // Send result back to model
|
|
84
|
-
* await chat.sendMessage([{
|
|
85
|
-
* functionResponse: {
|
|
86
|
-
* name: call.name,
|
|
87
|
-
* response: { result: tool.formatResult(searchResult) }
|
|
88
|
-
* }
|
|
89
|
-
* }]);
|
|
90
|
-
* }
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* @example Remote sandbox (E2B, Modal, etc.)
|
|
94
|
-
* ```typescript
|
|
95
|
-
* const tool = createMorphWarpGrepTool({
|
|
96
|
-
* repoRoot: '/home/repo',
|
|
97
|
-
* remoteCommands: {
|
|
98
|
-
* grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,
|
|
99
|
-
* read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,
|
|
100
|
-
* listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,
|
|
101
|
-
* },
|
|
102
|
-
* });
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
declare function createWarpGrepTool(config: WarpGrepToolConfig): GeminiWarpGrepTool;
|
|
106
|
-
declare const createMorphWarpGrepTool: typeof createWarpGrepTool;
|
|
107
|
-
|
|
108
|
-
type gemini_GeminiWarpGrepTool = GeminiWarpGrepTool;
|
|
109
|
-
declare const gemini_createMorphWarpGrepTool: typeof createMorphWarpGrepTool;
|
|
110
|
-
declare const gemini_createWarpGrepTool: typeof createWarpGrepTool;
|
|
111
|
-
declare const gemini_execute: typeof execute;
|
|
112
|
-
declare const gemini_formatResult: typeof formatResult;
|
|
113
|
-
declare const gemini_getSystemPrompt: typeof getSystemPrompt;
|
|
114
|
-
declare const gemini_warpGrepFunctionDeclaration: typeof warpGrepFunctionDeclaration;
|
|
115
|
-
declare namespace gemini {
|
|
116
|
-
export { type gemini_GeminiWarpGrepTool as GeminiWarpGrepTool, gemini_createMorphWarpGrepTool as createMorphWarpGrepTool, gemini_createWarpGrepTool as createWarpGrepTool, warpGrepFunctionDeclaration as default, gemini_execute as execute, gemini_formatResult as formatResult, gemini_getSystemPrompt as getSystemPrompt, gemini_warpGrepFunctionDeclaration as warpGrepFunctionDeclaration };
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export { type GeminiWarpGrepTool as G, createMorphWarpGrepTool as a, createWarpGrepTool as c, execute as e, gemini as g, warpGrepFunctionDeclaration as w };
|