AgentService class
Drives a provider-agnostic agent loop that investigates a node, plans and executes commands to accomplish a natural-language goal.
Every command the model wants to run is first scored by shield; DENY or
SecurityLevel.critical commands are auto-blocked in all modes and never
run. The remaining confirmation behaviour depends on the AgentMode (see
AgentMode for the contract).
Pure Dart with no dart:io: the transport is injected via AgentCommandRunner
and all user interaction via AgentHandlers, so the loop runs unchanged in
the CLI and the browser.
Constructors
- AgentService({required AiProvider provider, required AgentCommandRunner runner, required CommandShield shield, required AiConfig config, required CommandSyntax syntax, required AgentEnvironment environment, required AgentHandlers handlers, AgentStyle style = const AgentStyle(), String? language})
Properties
- config → AiConfig
-
final
- environment → AgentEnvironment
-
final
- handlers → AgentHandlers
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- language → String?
-
The language the agent replies in (free-form), or
nullto let the model choose. Applied to its prose, plans, explanations and summaries — not to shell commands or command output.final - provider → AiProvider
-
final
- runner → AgentCommandRunner
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shield → CommandShield
-
final
- style → AgentStyle
-
Styles output by category (planning/executing/command/prompt/blocked).
Defaults to a no-op; the native CLI injects an ANSI style.
final
- syntax → CommandSyntax
-
The command syntax used by shield (derived from the node's shell family).
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run(
String goal, {required AgentMode mode, AgentAbort? abort}) → Future< String?> -
Runs the agent toward
goalundermode. Returns the model's final summary text (also already written via AgentHandlers.writeLine), ornullif the agent was aborted/cancelled or hit the step cap without concluding. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited