@morphllm/morphsdk
v0.2.200
Published
TypeScript SDK and CLI for Morph Fast Apply integration
Readme
Morph SDK
Production-ready tools for AI coding agents: WarpGrep (intelligent code search) and Fast Apply (10,500 tokens/s).
Install
npm install @morphllm/morphsdkGet your API key: morphllm.com/dashboard/api-keys
export MORPH_API_KEY="sk-your-key-here"Features
- 🔍 WarpGrep - Intelligent code search agent that explores your codebase with parallel grep/read operations
- ⚡ Fast Apply - 98% 1st pass accuracy, AI-powered code editing at 10,500 tokens/s
- 📦 Repo Storage - Agent native git with automatic code indexing and agent metadata
- 🤖 Agent Tools - Ready-to-use tools for Anthropic, OpenAI, Gemini, and Vercel AI SDK
Quick Start
Vercel AI SDK provider
The provider works with AI SDK 6 and newer. It reads MORPH_API_KEY by default.
import { morph } from '@morphllm/morphsdk/ai-sdk';
import { generateText } from 'ai';
const { text } = await generateText({
model: morph('morph-glm53-744b'),
prompt: 'Write a TypeScript rate limiter.',
});Create a provider instance to use custom headers or a dedicated inference endpoint:
import { createMorph } from '@morphllm/morphsdk/ai-sdk';
const morph = createMorph({
apiKey: process.env.MORPH_API_KEY,
baseURL: 'https://your-endpoint.morphllm.com/v1',
});WarpGrep - Intelligent Code Search
WarpGrep is a search subagent that explores your codebase using parallel grep and file read operations. It understands natural language queries and returns relevant code with line numbers.
import { WarpGrepClient } from '@morphllm/morphsdk/tools/warp-grep';
const client = new WarpGrepClient({ morphApiKey: process.env.MORPH_API_KEY });
const result = await client.execute({
query: 'Find where authentication requests are handled',
repoRoot: './my-project'
});
// Returns relevant files with specific line ranges
result.files.forEach(file => {
console.log(`${file.path}: lines ${file.lines}`);
});As Agent Tool
import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic();
const tool = createWarpGrepTool({ repoRoot: './my-project' });
const response = await client.messages.create({
model: "claude-sonnet-4-5-20250929",
tools: [tool],
messages: [{ role: "user", content: "Find the error handling logic" }]
});Remote Sandbox Support
WarpGrep works in remote sandboxes (E2B, Modal, Daytona) by providing custom command implementations:
import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';
const tool = createWarpGrepTool({
repoRoot: '/home/repo',
remoteCommands: {
grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,
read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,
listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,
},
});Fast Apply
AI-powered code editing at 10,500 tokens/s with 98% first-pass accuracy.
import { MorphClient } from '@morphllm/morphsdk';
const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
await morph.fastApply.execute({
target_filepath: 'src/app.ts',
instructions: 'Add error handling to the API call',
code_edit: `
// ... existing code ...
try {
const response = await fetch(url);
// ... existing code ...
} catch (e) {
console.error('API call failed:', e);
throw e;
}
`
});See tools/fastapply/README.md for details.
Repo Storage
Git built for AI agents with automatic code indexing.
import { MorphClient } from '@morphllm/morphsdk';
const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
// Initialize repo
await morph.git.init({ repoId: 'my-project', dir: './my-project' });
// Stage and commit with agent metadata
await morph.git.add({ dir: './my-project', filepath: '.' });
await morph.git.commit({
dir: './my-project',
message: 'Add authentication',
chatHistory: [
{ role: 'user', content: 'Add OAuth login' },
{ role: 'assistant', content: 'Adding Google OAuth...' }
]
});
// Push
await morph.git.push({ dir: './my-project' });
// Clone, branch, checkout
await morph.git.clone({ repoId: 'my-project', dir: './local-copy' });
await morph.git.branch({ dir: './my-project', name: 'feature' });
await morph.git.checkout({ dir: './my-project', ref: 'main' });Agent Tools
Ready-to-use tools for popular AI frameworks:
| Framework | Import Path |
|-----------|-------------|
| Anthropic SDK | @morphllm/morphsdk/tools/warp-grep/anthropic |
| OpenAI SDK | @morphllm/morphsdk/tools/warp-grep/openai |
| Gemini SDK | @morphllm/morphsdk/tools/warp-grep/gemini |
| Vercel AI SDK | @morphllm/morphsdk/tools/warp-grep/vercel |
Available tools:
createWarpGrepTool- Intelligent code searchcreateFastApplyTool- AI-powered code editing
Documentation
Full docs: docs.morphllm.com
Key Pages:
- WarpGrep - Intelligent code search
- Fast Apply - AI-powered code editing
- Repo Storage - Git operations and agent metadata
