builtinTools function
- ExecutionEnv env, {
- HashlineSnapshotStore? snapshots,
- WebSearchConfig? webSearch,
- CubeNetworkGate? networkGate,
- ConfigService? config,
- Model? model()?,
- SqliteEngine? sqlite,
- LspToolConfig? lsp,
- McpManager? mcp,
- ShellJobRegistry? shellJobs,
- PasswordPromptCallback? onPasswordPrompt,
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 networkGate is provided, it gates every model-invoked web egress
of the web tools (issue #682): null — no cube — keeps the requests on
the unwrapped client, byte-identical to pre-gate runs.
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.
When config is provided, the config tool is registered (the
check|path|get|set ops over ConfigService — issue #29 S3). Hosts
without a config service (tests of individual tools, minimal embeds)
leave it out.
When mcp is provided, the tools of currently CONNECTED MCP servers are
included (as mcp__<server>__<tool>); servers connect in the background
after startup, so the host must additionally listen to
McpManager.onChanged to re-register late arrivals (see AgentCli).
model is forwarded to readFileTool for the non-vision image note.
Implementation
List<AgentTool> builtinTools(
ExecutionEnv env, {
HashlineSnapshotStore? snapshots,
WebSearchConfig? webSearch,
CubeNetworkGate? networkGate,
ConfigService? config,
Model? Function()? model,
SqliteEngine? sqlite,
LspToolConfig? lsp,
McpManager? mcp,
ShellJobRegistry? shellJobs,
PasswordPromptCallback? onPasswordPrompt,
}) {
final store = snapshots ?? HashlineSnapshotStore();
return [
readFileTool(env, snapshots: store, model: model, sqlite: sqlite),
writeFileTool(env),
editFileTool(env, snapshots: store),
listDirTool(env),
shellTool(env, jobs: shellJobs, onPasswordPrompt: onPasswordPrompt),
if (shellJobs != null) bashJobTool(shellJobs),
if (lsp != null) lspTool(env, config: lsp),
if (webSearch != null) ...[
webSearchTool(config: webSearch.withNetworkGate(networkGate)),
webFetchTool(config: webSearch.withNetworkGate(networkGate)),
],
if (config != null) configTool(config),
...?mcp?.tools,
];
}