Skip to content

ui

Functions

initUI

ts
initUI(title: string)

Initialize a terminal UI with a scrollable output area and a fixed input bar at the bottom. Call this once at the start of your agent. The title is shown in the scrollable output area on init; use status() to populate the status bar.

Parameters:

NameTypeDefault
titlestring

(source)

destroyUI

ts
destroyUI()

Tear down the terminal UI and restore normal terminal behavior. Called automatically on exit, but you can call it early if needed.

(source)

log

ts
log(message: string)

Print a message to the scrollable output area. Supports ANSI colors.

Parameters:

NameTypeDefault
messagestring

(source)

status

ts
status(left: string, right: string)

Update the status bar. The left text appears on the left side, the right text on the right.

@param left - Text for the left side @param right - Text for the right side

Parameters:

NameTypeDefault
leftstring
rightstring""

(source)

chat

ts
chat(role: string, message: string)

Print a chat message with a colored role prefix. Built-in colors: "user" (cyan), "agent" (white). Other roles appear dim.

@param role - The speaker role @param message - The message text

Parameters:

NameTypeDefault
rolestring""
messagestring""

(source)

code

ts
code(filename: string, content: string)

Display a code block with a filename header and line numbers, inside a bordered box.

@param filename - The filename to display @param content - The code content

Parameters:

NameTypeDefault
filenamestring
contentstring

(source)

diff

ts
diff(filename: string, content: string)

Display a diff with colored +/- lines, inside a bordered box with the filename as a header.

@param filename - The filename to display @param content - The diff content

Parameters:

NameTypeDefault
filenamestring
contentstring

(source)

separator

ts
separator(label: string)

Print a horizontal line with an optional label. Useful for visually grouping output sections.

Parameters:

NameTypeDefault
labelstring""

(source)

startSpinner

ts
startSpinner(text: string)

Show an animated spinner in the input bar with a label. Useful while the agent is thinking or running a long operation.

Parameters:

NameTypeDefault
textstring"working"

(source)

stopSpinner

ts
stopSpinner()

Stop the spinner and clear the input bar.

(source)

prompt

ts
prompt(question: string): string

Prompt the user for text input in the fixed input bar at the bottom of the screen. The question appears as a hint. Returns the user's input as a string.

Parameters:

NameTypeDefault
questionstring

Returns: string

(source)

getConfirmation

ts
getConfirmation(question: string): boolean

Ask the user a yes/no question in the input bar. Returns true if the user answers yes (y/yes), false otherwise. Useful inside handler blocks to approve or reject interrupts interactively.

Parameters:

NameTypeDefault
questionstring

Returns: boolean

(source)

emptyLine

ts
emptyLine()

Print an empty line. Useful for adding spacing in the output.

(source)