Built-in Tools
Exhaustive API reference for all 8 built-in tools — Read, Grep, List, Write, Edit, Bash, Skill, and JavaScript.
Use activeTools to restrict which tools are available per-agent or per-session. Use needsApproval to require human approval before specific tools execute.
import { agent } from "experimental-agent";
agent("my-agent", { activeTools: ["Read", "Grep", "List"] });
const session = myAgent.session(id, { activeTools: ["Read", "Grep", "List", "MyCustomTool"] });Read
Read files with optional pagination. For files over 200 lines, automatically shows first 100 lines unless a specific line range is provided.
Input
| Parameter | Type | Required | Description |
|---|---|---|---|
label | string | Yes | Label describing the action. |
path | string | Yes | Path to file relative to workspace root. |
startLine | number | No | Starting line (1-indexed). With endLine, reads exact range. |
endLine | number | No | Ending line (1-indexed, inclusive). With startLine, reads exact range. |
Output
| Field | Type | Description |
|---|---|---|
content | string | File content (or requested range). |
metadata.totalLines | number | Total lines in file. |
metadata.linesShown | number | Lines included in response. |
metadata.startLine | number | First line shown (1-indexed). |
metadata.endLine | number | Last line shown (1-indexed). |
metadata.isPaginated | boolean | Whether this is a partial view. |
metadata.fileSize | string | Human-readable size (e.g. "2.5K", "1.2M"). |
metadata.path | string | Path to file. |
Notes: Auto-paginates files over 200 lines (shows first 100). Use startLine and endLine for exact ranges on large files.
Grep
Search files with ripgrep. Find code patterns, function definitions, imports, etc.
Input
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
label | string | Yes | — | Label describing the action. |
pattern | string | Yes | — | Regex pattern (ripgrep syntax). |
path | string | No | "." | Path to search (file or directory). |
fileType | string | No | — | Filter by type (e.g. "ts", "js", "py", "md"). |
glob | string | No | — | Glob filter (e.g. "*.tsx", "src/**/*.ts"). |
caseSensitive | boolean | No | true | Case-sensitive search. |
contextLines | number | No | — | Lines before/after each match. |
maxCount | number | No | — | Max matches per file. |
filesWithMatches | boolean | No | false | Only show file paths, not matching lines. |
Output
| Field | Type | Description |
|---|---|---|
matches | string | Search results with paths, line numbers, content. |
summary.matchCount | number | Number of matches. |
summary.fileCount | number | Files containing matches. |
summary.searchPath | string | Path searched. |
summary.pattern | string | Pattern searched. |
Notes: Output truncated at ~50k chars. Use more specific pattern or path for large result sets.
List
Recursively list directory contents. Control depth for overview vs. detail.
Input
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
label | string | Yes | — | Label describing the action. |
path | string | No | "." | Path to list. |
depth | number | No | — | Max depth (1–2 overview, 3–4 detailed, 5+ comprehensive). |
includeHidden | boolean | No | false | Include hidden files (starting with .). |
filesOnly | boolean | No | false | Only files, not directories. |
pattern | string | No | — | Glob filter (e.g. "*.ts", "*test*"). |
Output
| Field | Type | Description |
|---|---|---|
listing | string | Directory tree, paths relative to search root. |
summary.totalItems | number | Total items found. |
summary.totalFiles | number | Total files. |
summary.totalDirs | number | Total directories. |
summary.searchPath | string | Path listed. |
summary.depth | number | Max depth used (if specified). |
Write
Write content to a file. Creates parent directories. Overwrites existing files.
Input
| Parameter | Type | Required | Description |
|---|---|---|---|
label | string | Yes | Label describing the action. |
path | string | Yes | Path relative to workspace root. |
content | string | Yes | Content to write. |
Output
| Field | Type | Description |
|---|---|---|
success | boolean | Whether write succeeded. |
path | string | Path written. |
bytesWritten | number | Bytes written. |
error | string | Error message if failed. |
Edit
Edit a file by exact string replacement. Fails if old_string is not found or appears multiple times.
Input
| Parameter | Type | Required | Description |
|---|---|---|---|
label | string | Yes | Label describing the action. |
path | string | Yes | Path relative to workspace root. |
old_string | string | Yes | Exact string to find and replace (must be unique). |
new_string | string | Yes | Replacement string. |
Output
| Field | Type | Description |
|---|---|---|
success | boolean | Whether edit succeeded. |
path | string | Path edited. |
error | string | Error message if failed. |
Notes: Include enough surrounding context to make old_string unique. For multiple replacements, call the tool multiple times.
Bash
Execute bash commands. Returns stdout and stderr. Use waitUntil to control how long to wait.
Input
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
label | string | Yes | — | Label describing the action. |
command | string | Yes | — | Shell command to execute. |
waitUntil | number | No | 2000 | Max ms to wait. Use 0 to return immediately; process keeps running. |
Output
| Field | Type | Description |
|---|---|---|
commandId | string | Use to reference or kill the process. |
stdout | string | Command stdout. Tail-truncated if large. |
stderr | string | Command stderr. Tail-truncated if large. |
exitCode | number | Exit code (-1 if still running). |
status | "running" | "completed" | "failed" | Process status. |
outputDir | string | Path to output dir with stdout.txt, stderr.txt, metadata.json. Empty if still running. |
Notes: waitUntil=0 returns immediately; process continues in sandbox. Large outputs truncated (~50k stdout, ~10k stderr); full content in outputDir.
Skill
Load a skill's full instructions by name. Call before following a skill. Only available when skills is configured.
Input
| Parameter | Type | Required | Description |
|---|---|---|---|
label | string | Yes | Label describing the action. |
name | string | Yes | Skill name from Available Skills list. |
Output
| Field | Type | Description |
|---|---|---|
name | string | Skill name. |
description | string | Skill description. |
content | string | Full SKILL.md content (body after frontmatter). |
path | string | Path to skill directory in sandbox. |
Notes: Tool is omitted when skills is not set. Throws if skill not found.
JavaScript
Execute JavaScript code dynamically. Code runs as async function body with ctx in scope. Must return to produce output. Can call other tools as sub-tools via ctx.tools.
Input
| Parameter | Type | Required | Description |
|---|---|---|---|
label | string | Yes | Label describing the action. |
code | string | Yes | JavaScript async function body. ctx is in scope. Must use return to produce output. |
Output
Returns whatever the code returns. undefined or missing return yields null.
Notes: Code runs in sandbox via Node.js. ctx has tools (call other tools), session, sandbox, storage, context. Execution timeout: 5 minutes. Can invoke Read, Write, Edit, Grep, List, Bash, and custom tools as sub-tools.
activeTools
Restrict which tools are available at agent or session level:
agent("my-agent", {
activeTools: ["Read", "Grep", "List"],
});
const session = myAgent.session(id, {
activeTools: ["Read", "Grep", "List", "Deploy"],
});Session-level activeTools overrides agent-level. Include both built-in and custom tool names.
builtinToolNames
Use for type-safe tool references:
import { builtinToolNames } from "experimental-agent";
builtinToolNames.Read; // "Read"
builtinToolNames.Bash; // "Bash"
builtinToolNames.Write; // "Write"See also
- agent() — Setting activeTools on the agent
- Session API — Overriding activeTools per session
- Custom Tools — Building tools with ToolContext
- Extending Built-in Tools — Wrapping or replacing built-ins
- Skills — Skill discovery and usage