@morphllm/morphsdk 0.2.85 → 0.2.86

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.
@@ -8,11 +8,22 @@ import {
8
8
  // tools/warp_grep/vercel.ts
9
9
  import { tool } from "ai";
10
10
  import { z } from "zod";
11
+ var warpGrepJsonSchema = {
12
+ type: "object",
13
+ properties: {
14
+ query: {
15
+ type: "string",
16
+ description: "Free-form repository question"
17
+ }
18
+ },
19
+ required: ["query"],
20
+ additionalProperties: false
21
+ };
11
22
  async function execute(input, config) {
12
23
  return executeToolCall(input, config);
13
24
  }
14
25
  function createWarpGrepTool(config) {
15
- const schema = z.object({
26
+ const schema = config.inputSchema ?? z.object({
16
27
  query: z.string().describe("Free-form repository question")
17
28
  });
18
29
  return tool({
@@ -34,8 +45,9 @@ function createWarpGrepTool(config) {
34
45
  var vercel_default = createWarpGrepTool;
35
46
 
36
47
  export {
48
+ warpGrepJsonSchema,
37
49
  execute,
38
50
  createWarpGrepTool,
39
51
  vercel_default
40
52
  };
41
- //# sourceMappingURL=chunk-5X7IJXKA.js.map
53
+ //# sourceMappingURL=chunk-KJL5RNVA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../tools/warp_grep/vercel.ts"],"sourcesContent":["/**\n * Vercel AI SDK adapter for morph-warp-grep tool\n *\n * @example Using with your own Zod instance (recommended for avoiding version conflicts)\n * ```typescript\n * import { z } from 'zod'; // Your project's Zod\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const schema = z.object({\n * query: z.string().describe('Free-form repository question'),\n * });\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: schema,\n * });\n * ```\n */\n\nimport { tool } from 'ai';\nimport { z } from 'zod';\nimport { jsonSchema } from 'ai';\nimport { executeToolCall, formatResult } from './client.js';\nimport { WARP_GREP_DESCRIPTION, getSystemPrompt } from './prompts.js';\nimport type { WarpGrepToolConfig, WarpGrepResult } from './types.js';\n\n/**\n * Raw JSON Schema for warp grep input (no Zod dependency).\n * Use this with jsonSchema() from 'ai' if you have Zod version conflicts.\n *\n * @example\n * ```typescript\n * import { jsonSchema } from 'ai';\n * import { warpGrepJsonSchema, createWarpGrepToolWithSchema } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepToolWithSchema({\n * repoRoot: '.',\n * inputSchema: jsonSchema(warpGrepJsonSchema),\n * });\n * ```\n */\nexport const warpGrepJsonSchema = {\n type: 'object' as const,\n properties: {\n query: {\n type: 'string' as const,\n description: 'Free-form repository question',\n },\n },\n required: ['query'] as const,\n additionalProperties: false as const,\n};\n\n/** Type for the warp grep input */\nexport type WarpGrepInput = { query: string };\n\n/**\n * Extended config that accepts a custom inputSchema\n */\nexport interface WarpGrepVercelConfig extends WarpGrepToolConfig {\n /**\n * Custom Zod schema or AI SDK schema. Use this to provide your own Zod instance\n * to avoid version conflicts between your project and the SDK.\n *\n * @example Using your own Zod\n * ```typescript\n * import { z } from 'zod'; // Your Zod version\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: z.object({\n * query: z.string().describe('Free-form repository question'),\n * }),\n * });\n * ```\n *\n * @example Using jsonSchema (no Zod needed)\n * ```typescript\n * import { jsonSchema } from 'ai';\n * import { warpGrepJsonSchema } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: jsonSchema(warpGrepJsonSchema),\n * });\n * ```\n */\n inputSchema?: Parameters<typeof tool>[0]['inputSchema'];\n}\n\n/**\n * Execute warp grep search\n *\n * @param input - Tool input with query\n * @param config - Configuration with repoRoot and optional provider\n * @returns Search results\n */\nexport async function execute(\n input: { query: string },\n config: WarpGrepToolConfig\n): Promise<WarpGrepResult> {\n return executeToolCall(input, config);\n}\n\n// Re-export formatResult and getSystemPrompt for convenience\nexport { formatResult, getSystemPrompt };\n\n/**\n * Create Vercel AI SDK warp grep tool\n *\n * @param config - Configuration options\n * @returns Vercel AI SDK tool\n *\n * @example Local usage (uses SDK's Zod)\n * ```typescript\n * import { generateText } from 'ai';\n * import { anthropic } from '@ai-sdk/anthropic';\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepTool({ repoRoot: '.' });\n *\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { grep: grepTool },\n * prompt: 'Find authentication middleware'\n * });\n * ```\n *\n * @example With your own Zod (avoids version conflicts)\n * ```typescript\n * import { z } from 'zod'; // Your project's Zod\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: z.object({\n * query: z.string().describe('Free-form repository question'),\n * }),\n * });\n * ```\n *\n * @example Without Zod (using jsonSchema)\n * ```typescript\n * import { jsonSchema } from 'ai';\n * import { createWarpGrepTool, warpGrepJsonSchema } from '@morphllm/morphsdk/tools/warp-grep/vercel';\n *\n * const grepTool = createWarpGrepTool({\n * repoRoot: '.',\n * inputSchema: jsonSchema(warpGrepJsonSchema),\n * });\n * ```\n *\n * @example Remote sandbox (E2B, Modal, etc.)\n * ```typescript\n * const grepTool = createWarpGrepTool({\n * repoRoot: '/home/repo',\n * remoteCommands: {\n * grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,\n * read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,\n * listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,\n * },\n * });\n * ```\n */\nexport function createWarpGrepTool(config: WarpGrepVercelConfig) {\n // Use provided schema or fall back to SDK's Zod schema\n const schema = config.inputSchema ?? z.object({\n query: z.string().describe('Free-form repository question'),\n });\n\n return tool({\n description: config.description ?? WARP_GREP_DESCRIPTION,\n inputSchema: schema,\n execute: async (params: WarpGrepInput) => {\n const result = await executeToolCall(params, config);\n\n if (!result.success) {\n throw new Error(`Failed to search codebase: ${result.error}`);\n }\n\n return {\n success: true,\n contexts: result.contexts,\n summary: result.summary,\n };\n },\n });\n}\n\n// Default export for convenience\nexport default createWarpGrepTool;\n"],"mappings":";;;;;;;;AAmBA,SAAS,YAAY;AACrB,SAAS,SAAS;AAqBX,IAAM,qBAAqB;AAAA,EAChC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,OAAO;AAAA,MACL,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,UAAU,CAAC,OAAO;AAAA,EAClB,sBAAsB;AACxB;AA8CA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AA8DO,SAAS,mBAAmB,QAA8B;AAE/D,QAAM,SAAS,OAAO,eAAe,EAAE,OAAO;AAAA,IAC5C,OAAO,EAAE,OAAO,EAAE,SAAS,+BAA+B;AAAA,EAC5D,CAAC;AAED,SAAO,KAAK;AAAA,IACV,aAAa,OAAO,eAAe;AAAA,IACnC,aAAa;AAAA,IACb,SAAS,OAAO,WAA0B;AACxC,YAAM,SAAS,MAAM,gBAAgB,QAAQ,MAAM;AAEnD,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,IAAI,MAAM,8BAA8B,OAAO,KAAK,EAAE;AAAA,MAC9D;AAEA,aAAO;AAAA,QACL,SAAS;AAAA,QACT,UAAU,OAAO;AAAA,QACjB,SAAS,OAAO;AAAA,MAClB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAGA,IAAO,iBAAQ;","names":[]}
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-IXNX4HMC.js";
7
7
  import {
8
8
  createWarpGrepTool as createWarpGrepTool3
9
- } from "./chunk-5X7IJXKA.js";
9
+ } from "./chunk-KJL5RNVA.js";
10
10
  import {
11
11
  WarpGrepClient
12
12
  } from "./chunk-37SJ3IOY.js";
@@ -280,4 +280,4 @@ export {
280
280
  VercelToolFactory,
281
281
  MorphClient
282
282
  };
283
- //# sourceMappingURL=chunk-SQF3OG24.js.map
283
+ //# sourceMappingURL=chunk-YWS4Y75I.js.map
@@ -11,6 +11,7 @@ import { d as WarpGrepToolConfig, b as WarpGrepResult, c as WarpGrepContext } fr
11
11
  import * as openai_resources_index_mjs from 'openai/resources/index.mjs';
12
12
  import * as _anthropic_ai_sdk_resources_messages_mjs from '@anthropic-ai/sdk/resources/messages.mjs';
13
13
  import * as ai from 'ai';
14
+ import { WarpGrepInput } from './tools/warp_grep/vercel.js';
14
15
 
15
16
  /**
16
17
  * Factory for creating OpenAI-compatible tools with inherited API key
@@ -154,9 +155,7 @@ declare class VercelToolFactory {
154
155
  * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
155
156
  * @returns Vercel AI SDK tool
156
157
  */
157
- createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>): ai.Tool<{
158
- query: string;
159
- }, {
158
+ createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>): ai.Tool<WarpGrepInput, {
160
159
  success: boolean;
161
160
  contexts: WarpGrepContext[] | undefined;
162
161
  summary: string | undefined;
package/dist/client.cjs CHANGED
@@ -4120,7 +4120,7 @@ var AnthropicToolFactory = class {
4120
4120
  var import_ai = require("ai");
4121
4121
  var import_zod = require("zod");
4122
4122
  function createWarpGrepTool3(config) {
4123
- const schema = import_zod.z.object({
4123
+ const schema = config.inputSchema ?? import_zod.z.object({
4124
4124
  query: import_zod.z.string().describe("Free-form repository question")
4125
4125
  });
4126
4126
  return (0, import_ai.tool)({