Skip to content

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.

TypeScript
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.

TypeScript
function printTerminalHeader(
  agent: Agent,
  model: string,
  prompt: string,
  preset: Preset,
  title?: string,
): void
Parameters
NameTypeDefaultDescription
agentAgent

Agent in use. Its auth mode is shown beside the model.

modelstring

Model id to show.

promptstring

Prompt to show.

presetPreset

Preset whose name and tools are listed.

title?string'⚽ Zizou'

Title line of the header.

src/output/terminal.ts:79

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.

TypeScript
function setupTerminalOutput(
  agent: Agent,
  model: string,
  prompt: string,
  preset: Preset,
  options?: TerminalOutputOptions,
): Promise<() => void>
Parameters
NameTypeDefaultDescription
agentAgent

Agent whose hooks the renderer attaches to.

modelstring

Model id shown in the header.

promptstring

Prompt shown in the header.

presetPreset

Preset whose name and tools are shown in the header.

options?TerminalOutputOptions{}

Header and filtering options. See TerminalOutputOptions.

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()

src/output/terminal.ts:118

Interfaces#

TerminalOutputOptionsInterface#

Options for setupTerminalOutput.

TypeScript
interface TerminalOutputOptions
TerminalOutputOptions properties
NameTypeDefaultDescription
printHeader?booleantrue

Print the header before streaming starts. Set false to skip it.

shouldPrint?() => boolean

Checked before every write. Return false to silence all output.

shouldPrintSummary?(stats: AgentStats) => boolean

Checked before the run summary is printed. Return false to hide it.

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 false to hide that call.

title?string'⚽ Zizou'

Title line of the header.

src/output/terminal.ts:49