zidane/ output/ terminal
A terminal renderer that streams an agent run to stdout, with depth-aware output for sub-agents.
import { … } from 'zidane/output/terminal'src/output/terminal.ts
Use setupTerminalOutput() when you run an agent from a script or CLI: text and thinking deltas, tool calls and sub-agent activity print as they happen. It attaches to the agent's hooks and returns a function that detaches it again. printTerminalHeader() prints the title, model, prompt and tool names on its own.
import { createAgent } from 'zidane'
import { setupTerminalOutput } from 'zidane/output/terminal'
import { basic } from 'zidane/presets'
import { anthropic } from 'zidane/providers/anthropic'
const agent = createAgent({ ...basic, provider: anthropic() })
const prompt = 'Summarize README.md in three bullets.'
const detach = await setupTerminalOutput(agent, 'claude-fable-5-1', prompt, basic, { title: 'Docs run' })
await agent.run({ prompt })
detach()Functions#
printTerminalHeaderFunction#
Prints the run header: title, model, prompt, preset name and tool names.
setupTerminalOutputFunction#
Wire the depth-aware terminal renderer onto an agent's hook bus.
Returns a disposer that unregisters every hook this function installed — hosts reusing one agent across phases can detach the renderer without tearing the agent down. Callers that never detach can ignore the return value.
function setupTerminalOutput(
agent: Agent,
model: string,
prompt: string,
preset: Preset,
options?: TerminalOutputOptions,
): Promise<() => void>Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| agent | Agent | Agent whose hooks the renderer attaches to. | |
| model | string | Model id shown in the header. | |
| prompt | string | Prompt shown in the header. | |
| preset | Preset | Preset whose name and tools are shown in the header. | |
| options? | TerminalOutputOptions | {} | Header and filtering options. See |
Returns
Promise<() => void>Example
import { createAgent } from 'zidane'
import { basic } from 'zidane/presets'
import { anthropic } from 'zidane/providers'
import { setupTerminalOutput } from 'zidane/output/terminal'
const agent = createAgent({ ...basic, provider: anthropic({ apiKey: 'sk-ant-...' }) })
const prompt = 'build a REST API'
const detach = await setupTerminalOutput(agent, 'claude-opus-4-7', prompt, basic)
await agent.run({ prompt })
detach()Interfaces#
TerminalOutputOptionsInterface#
Options for setupTerminalOutput.
interface TerminalOutputOptionsProperties
| Name | Type | Default | Description |
|---|---|---|---|
| printHeader? | boolean | true | Print the header before streaming starts. Set |
| shouldPrint? | () => boolean | Checked before every write. Return | |
| shouldPrintSummary? | (stats: AgentStats) => boolean | Checked before the run summary is printed. Return | |
| shouldPrintToolCall? | (ctx: ToolHookContext & { coercions?: readonly string[]; priorContent?: string; runToolCounts: Readonly<Record<string, number>>; unknown?: boolean }) => boolean | Checked before each tool call line is printed. Return | |
| title? | string | '⚽ Zizou' | Title line of the header. |