@agentskit/ink — for agents
Terminal chat UI via Ink — same `useChat` contract as `@agentskit/react`, running in Node with ANSI theming and keyboard navigation.
#Purpose
Ink binding for the ChatReturn contract from @agentskit/core. Renders a full chat interface in the terminal using React + Ink, with keyboard navigation, ANSI theming, and human-in-the-loop tool confirmation — no browser required.
#Install
npm install @agentskit/ink
# peers:
npm install react ink#Primary exports
useChat(config): ChatReturn— mirrors@agentskit/react.<ChatContainer>,<Message>,<InputBar>,<ToolCallView>,<ThinkingIndicator>— Ink components with keyboard nav + ANSI theming.<StatusHeader>— header strip showing provider / model / cost / status.<ToolConfirmation>— HITL approval prompt for risky tool calls.<MarkdownText>— render Markdown to Ink Text nodes.
#Minimal example
import { render } from 'ink'
import { ChatContainer } from '@agentskit/ink'
import { anthropic } from '@agentskit/adapters'
const adapter = anthropic({ apiKey: process.env.ANTHROPIC_KEY, model: 'claude-sonnet-4-6' })
render(<ChatContainer config={{ adapter }} />)To use useChat directly and build a custom layout:
import { useEffect } from 'react'
import { render, Box, Text } from 'ink'
import { useChat } from '@agentskit/ink'
import { anthropic } from '@agentskit/adapters'
const adapter = anthropic({ apiKey: process.env.ANTHROPIC_KEY, model: 'claude-sonnet-4-6' })
function Chat() {
const chat = useChat({ adapter })
useEffect(() => {
// cleanup: abort any in-flight stream when the component unmounts
return () => chat.stop()
}, [])
return (
<Box flexDirection="column">
{chat.messages.map(m => <Text key={m.id}>{m.role}: {m.content}</Text>)}
</Box>
)
}
render(<Chat />)#Common patterns
- Node only / TTY required:
@agentskit/inkuses Ink which writes directly toprocess.stdout. It does not run in the browser or in non-TTY environments (e.g. piped CI output). Use@agentskit/reactfor browser targets. - Peer deps on
reactandink: both must be installed alongside@agentskit/ink— Ink requires React 18+ and does not bundle it. - Cleanup via
useEffectreturn: if you calluseChatoutside of<ChatContainer>, returnchat.stopfrom auseEffectto abort in-flight streams when the component unmounts or the process exits. - ANSI theming: pass a
themeprop to<ChatContainer>or set CSS-variable-equivalent tokens via thethemeconfig key to customise colours without forking components.
#Related
- @agentskit/core —
ChatReturncontract. - @agentskit/adapters — provider adapters.
- @agentskit/react, @agentskit/vue, @agentskit/svelte, @agentskit/solid, @agentskit/angular, @agentskit/react-native — sibling bindings.
- @agentskit/cli —
agentskit chatships Ink internally.
#Source
- npm: https://www.npmjs.com/package/@agentskit/ink
- repo: https://github.com/AgentsKit-io/agentskit/tree/main/packages/ink
Explore nearby
- PeerFor agents — overview
Dense, LLM-friendly reference for every AgentsKit package. Designed to paste into an agent's context window.
- Peer@agentskit/core — for agents
Zero-dependency foundation. Contracts, chat controller, primitives, and a dozen feature subpaths.
- Peer@agentskit/adapters — for agents
Provider adapters (OpenAI-compatible + native) + router + ensemble + fallback + generic factory.