builtinTools function
- ExecutionEnv env, {
- HashlineSnapshotStore? snapshots,
- WebSearchConfig? webSearch,
- Model? model()?,
- SqliteEngine? sqlite,
- LspToolConfig? lsp,
Creates the four built-in tools (readFileTool, writeFileTool,
listDirTool, shellTool) bound to env.
snapshots is the session-scoped hashline snapshot store shared by the
read and edit tools: hashline-mode reads mint the content tags that
hashline edit patches cite, and edits mint fresh tags for follow-ups.
Defaults to a fresh store — one per builtinTools call, i.e. one per
agent session.
When webSearch is provided, the web_search and web_fetch tools are
registered with it (provider chain resolved from the config; keyless
DuckDuckGo works with all defaults).
When sqlite is provided, the read tool resolves SQLite database
targets (data.db:table); without an engine (e.g. web hosts, where FFI
is unavailable) such reads return a clean "not supported" note.
When lsp is provided, the lsp tool is registered (diagnostics /
definition / references / rename backed by a language server). Only
process-capable hosts (CLI/desktop) pass it — the process transport
factory lives in lib/io.dart; web/stub construction leaves the tool
out.
model is forwarded to readFileTool for the non-vision image note.
Implementation
List<AgentTool> builtinTools(
ExecutionEnv env, {
HashlineSnapshotStore? snapshots,
WebSearchConfig? webSearch,
Model? Function()? model,
SqliteEngine? sqlite,
LspToolConfig? lsp,
}) {
final store = snapshots ?? HashlineSnapshotStore();
return [
readFileTool(env, snapshots: store, model: model, sqlite: sqlite),
writeFileTool(env),
editFileTool(env, snapshots: store),
listDirTool(env),
shellTool(env),
if (lsp != null) lspTool(env, config: lsp),
if (webSearch != null) ...[
webSearchTool(config: webSearch),
webFetchTool(config: webSearch),
],
];
}