Documentation Index
Fetch the complete documentation index at: https://docs.morphllm.com/llms.txt
Use this file to discover all available pages before exploring further.
This page covers how to execute WarpGrep’s tools (grep, read, list directory, glob) in a remote sandbox instead of locally. If you haven’t set up WarpGrep as a tool yet, start with the Agent Tool guide first.
Remote Commands
The simplest way to run WarpGrep in a sandbox. Provide functions that execute commands remotely and return raw stdout — the SDK handles all parsing.
import { MorphClient } from '@morphllm/morphsdk';
const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
const grepTool = morph.anthropic.createWarpGrepTool({
repoRoot: '/home/user/repo',
remoteCommands: {
grep: async (pattern, path, glob) => {
// Equivalent command:
// rg --no-config --no-heading --with-filename --line-number \
// --color=never --trim --max-columns=400 -C 1 \
// --glob '<glob>' '<pattern>' '<path>'
const r = await sandbox.exec(`rg --no-config --no-heading --with-filename --line-number --color=never --trim --max-columns=400 -C 1 ${glob ? `--glob '${glob}'` : ''} '${pattern}' '${path}'`);
return r.stdout;
},
read: async (path, start, end) => {
// Equivalent command:
// sed -n '<start>,<end>p' '<path>'
const r = await sandbox.exec(`sed -n '${start},${end}p' '${path}'`);
return r.stdout;
},
listDir: async (path, maxDepth) => {
// Equivalent command:
// find '<path>' -maxdepth <maxDepth>
const r = await sandbox.exec(`find '${path}' -maxdepth ${maxDepth}`);
return r.stdout;
},
glob: async (pattern, path) => {
// Equivalent command:
// rg --no-config --files --color=never -g '<pattern>' '<path>'
const r = await sandbox.exec(`rg --no-config --files --color=never -g '${pattern}' '${path}'`);
return r.stdout;
},
},
});
Each function receives decomposed arguments from the model’s tool call and should return raw stdout as a string. The SDK parses and formats the output internally:
| Function | What to return | SDK post-processing |
|---|
grep | ripgrep stdout (path:line:content lines) | Truncates at 200 lines |
read | Raw file content (just the text) | Adds lineNumber|content formatting, truncates at 800 lines |
listDir | One path per line | Infers file/dir type, calculates depth, filters junk directories |
glob | One file path per line | Caps at 100 results |
Custom Providers
The remoteCommands example above is itself a custom provider — a set of tool implementations (grep, read, list directory, glob) that override WarpGrep’s defaults. You might need a custom provider if you’re running on a non-standard operating system, a non-standard file system, or any environment where the built-in tools don’t work.
Below are examples of custom providers for common sandbox providers
See complete, runnable examples for each platform: