AgentCli class

The CLI harness: agent + built-in tools + session persistence + compaction, driven by a CliIO.

Available extensions

Constructors

AgentCli({required AgentCliConfig config, required CliIO io, StreamFunction? streamFunction, String prompt = 'fa> ', bool useColor = false, bool useTui = false, String version = '0.0.0'})
Creates an AgentCli. streamFunction overrides the provider adapter (used in tests); otherwise one is built from AgentCliConfig.providerKind and AgentCliConfig.apiKey.

Properties

agent Agent
The underlying Agent driving the session.
no setter
approval ApprovalManager
The approval gate attached to the agent: mode, per-tool overrides, and the session always-allow set (/approval, /allow).
no setter
checkpoints CheckpointRewindController
The checkpoint/rewind controller: its checkpoint and rewind tools are registered on the agent, and it applies rewinds at turn end.
no setter
config AgentCliConfig
The static configuration.
final
currentMode AgentMode
The active mode.
no setter
hashCode int
The hash code for this object.
no setterinherited
io CliIO
Terminal IO.
final
isBusy bool
Whether a run is currently streaming.
no setter
prompt String
The input prompt written when the agent is idle.
final
providerKind String
The live provider adapter kind (see _providerKind).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
systemPrompt String
The effective system prompt sent to the model.
no setter
ttsr TtsrController?
The TTSR controller, when stream rules are configured (AgentCliConfig.ttsr).
no setter

Methods

discoverAgentsFromRoots(({List<String> projectRoots, List<String> userRoots}) roots) Future<void>

Available on AgentCli, provided by the AgentCliAgentExt extension

Fire-and-forget discovery: scans project + user roots for agent .md files.
listAgentTypes() → void

Available on AgentCli, provided by the AgentCliAgentExt extension

/agents: lists all available agent types (built-in + discovered).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
printSessionResumeHint() Future<void>
After an interactive run ends, prints the command that picks this session back up (kimi prints the resume hint on exit too). Skipped for sessions with nothing persisted yet — resuming those is pointless. Also called from the top-level idle-SIGINT path in bin/fah.dart, which exits 130 without returning from run.
run() Future<void>
Runs the REPL until /exit or the input stream closes.
runHeadless(String prompt) Future<int>
Runs a single non-interactive prompt (headless mode: fah "<prompt>") and returns the process exit code: 0 on success, 1 when the run ends with a provider error, 130 when aborted (Ctrl-C via CliIO.interrupts). Tool errors the agent recovers from still exit 0 — the exit code reflects the run's terminal state, like claude/pi.
runProviderModelFlow({required String title, bool openAiCompatibleOnly = false, required Future<void> apply(ProviderModelChoice choice)}) Future<void>

Available on AgentCli, provided by the SettingsFlow extension

The two-level "provider → model" pick: step 1 picks the provider (saved custom entries first, then the catalog), step 2 fetches that endpoint's /models (openai-like endpoints; manual entry otherwise or when the list is empty), then apply receives the choice. Cancelling any step aborts silently. openAiCompatibleOnly restricts the provider list to the wire format the media tools speak.
startChatModelFlow() Future<void>

Available on AgentCli, provided by the SettingsFlow extension

Settings → Chat model: provider → model, then switch the connection. Mirrors _switchToSavedProvider for saved entries (secure-store key resolution included) but applies the picked model instead of the entry's last-used one.
startMediaSlotFlow() Future<void>

Available on AgentCli, provided by the SettingsFlow extension

Settings → Media models: pick the slot, then provider → model, then pin the slot override (same persistence as /models set).
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited