agent_tools library
A tool surface for LLM agents: declared tools, a permission scope with a fixed gate order, an invocation record that carries execution consent, an append-only audit trail, the presentations a model sees (native tool declarations, an in-process MCP server) and preview-then-apply runs.
Classes
- AgentAuditEntry
- One audited operation.
- AgentAuditExecution
- What a program run reports to the tool call that started it: the program, the digest of what ran, how it ended, and sizes.
- AgentAuditLog
- The append-only audit log.
- AgentAuditRecording
- One tool call's audit entries, collected while the call runs and appended as one batch when it ends — applied, denied or failed.
- AgentAuditStore
- Where an AgentFileAuditLog keeps its files: a keyed file medium the application supplies — a directory, a browser store, a container.
- AgentExecutionGrant
- The statement an application shows a user before execution is granted, as the value an execution grant is checked against.
- AgentFileAuditLog
-
The audit log as a stream of files over an AgentAuditStore: one file per
appended batch, filed under the UTC day it was written
(
<yyyy-mm-dd>/<µs>-<instance>-<n>.json). - AgentGuardTarget
- What a guard is asked about: one target a call reads or writes, or one it is about to create.
- AgentInProcessMcpServer
- An MCP server, in-process: a JSON-RPC 2.0 message handler a caller invokes directly. It binds nothing and listens on nothing.
- AgentInvocation
- One entry into the tool surface. Immutable once minted; widening requires a new invocation minted by a new user action.
- AgentMemoryAuditLog
- An audit log kept for the life of the process — for a build with nowhere to write, and for tests.
- AgentPreviewThenApply
- Preview-then-apply. See the library doc.
-
AgentProposalOutcome<
P> - What AgentPreviewThenApply.run reports.
- AgentRun
- One agent run: a model-driven sequence of tool calls that is atomic and reversible as a unit.
- AgentRunOutcome
- AgentRunStep
- One tool call made during a run, as the preview shows it and the run reports it.
- AgentScope
- What an invocation may touch. Immutable once made; least privilege by construction.
-
AgentTool<
C extends AgentToolContext> - A named, declared operation on behalf of an agent.
- AgentToolArgument
- One declared argument of a tool.
-
AgentToolBinding<
C extends AgentToolContext> -
{invocation, registry}for one request, plus the context the calls run against. - AgentToolContext
- What one invocation may reach, and how its calls are recorded.
- AgentToolErrorCode
-
One refusal kind: the stable
E_…spelling every presentation reports and the reason the audit trail records when the refusal carries no truer one. -
AgentToolRegistry<
C extends AgentToolContext> - A set of tools a presentation renders.
- AgentToolResult
- What a dispatched call hands back to the model.
- AgentToolSchema
- A tool's declared argument set.
Enums
- AgentAuditEntryPoint
- Which surface a call arrived on. agent is an in-process native call, mcp the in-process MCP surface, rest a network surface.
- AgentAuditOutcome
- What became of the operation an entry records.
- AgentOrigin
- Where an invocation came from. One value.
- AgentProposalStatus
- How a proposal ended.
- AgentRunStatus
- AgentScopeGate
- The gate a guard denial names — its number, and the reason the audit trail records.
- AgentToolValueType
- The value kinds a declared argument may take.
Functions
-
agentAuditCallIsOneGroup(
) → void - Tells the tool call running now that its writes are one group: if the call fails, every write it made was rolled back. A no-op outside one.
-
agentAuditEntering<
T> (AgentAuditEntryPoint entry, T body()) → T -
Runs
bodyas calls arriving onentry: every entry a tool call made inside it records carries thatentry. -
agentAuditExecution(
AgentAuditExecution run) → void - Reports a program run to the tool call it runs under. A no-op outside one.
-
agentAuditExecutionStarted(
) → void - Marks where a program run's mutations begin in the tool call it runs under. A no-op outside one.
-
agentAuditResolved(
String locator) → void - Tells the tool call running now which resource it reached. A no-op outside one.
-
agentFilterAudit(
Iterable< AgentAuditEntry> entries, {String? scopeId, String? locator, AgentAuditOutcome? outcome}) → List<AgentAuditEntry> - A viewer's three filters, over an entry list.
-
agentGuard(
AgentScope scope, AgentGuardTarget target, {required bool write}) → AgentScopeGate? -
The gate that denies
targetunderscope, or null when it is allowed (gate 5).writesays whether the call writes it.
Typedefs
-
AgentAtomicScope
= Future<
void> Function(String label, Future<void> body()) - Runs a body as one atomic unit — all of it rolled back together if it throws. An application supplies one over whatever it writes (one undo group per document, a database transaction, …).
-
AgentToolInvoke<
C extends AgentToolContext> = FutureOr< Object?> Function(C context, Map<String, Object?> arguments) - What a tool's body does, once its arguments have been validated.
Exceptions / Errors
- AgentToolException
- A refused tool call.