Channels
Terminal
Chat with your assistant from the local terminal.
Overview
TerminalChannel is a readline-based REPL channel. cogitator up adds it automatically so the owner can talk to the assistant from the machine it runs on. It is only active when stdin is a TTY (or COGITATOR_FORCE_TERMINAL is set), so it stays silent under systemd/launchd.
Usage
import { Gateway, terminalChannel } from '@cogitator-ai/channels';
const gateway = new Gateway({
agent,
cogitator,
channels: [
terminalChannel({
userName: 'Alice',
userId: 'owner', // default
prompt: '> ',
onExit: () => shutdown(),
}),
],
});Configuration
interface TerminalConfig {
userName?: string; // default: OS user name
userId?: string; // default: 'owner'
prompt?: string; // default: '> '
onExit?: () => void; // default: raise SIGINT
}Behavior
- Messages arrive with
channelType: 'terminal'andchannelId: 'terminal'. - Streaming edits rewrite the previous output in place (wrapped lines are accounted for).
- Messages that arrive while you are typing (e.g. scheduled reminders) are printed above the prompt and your input line is redrawn.
- The prompt returns after every answer, including when the agent fails.
- Ctrl+C, Ctrl+D,
/quit,/exitandexitcallonExit. The default raisesSIGINT, so your process' signal handler (for examplecogitator up's graceful shutdown) runs;gateway.stop()closes readline without exiting the process. RuntimeBuildertreats the terminal user as an owner for self-configuration tools, and takesuserNamefrom a personality line likeassistant for Alex.sendFileprints[filename] url; there is no typing indicator.