@assistant-ui/react-ink
v0.0.6
Published
React Ink (terminal UI) bindings for assistant-ui
Readme
@assistant-ui/react-ink
React Ink (terminal UI) bindings for assistant-ui.
Build AI chat interfaces for the terminal using Ink — React for CLIs — powered by the same runtime as assistant-ui.
Installation
npm install @assistant-ui/react-ink ink reactQuick Start
import { render } from "ink";
import { Box, Text } from "ink";
import {
AssistantProvider,
useLocalRuntime,
ThreadRoot,
ThreadMessages,
ComposerInput,
type ChatModelAdapter,
} from "@assistant-ui/react-ink";
const myAdapter: ChatModelAdapter = {
async *run({ messages }) {
// your AI backend here
yield { content: [{ type: "text", text: "Hello from AI!" }] };
},
};
function App() {
const runtime = useLocalRuntime(myAdapter);
return (
<AssistantProvider runtime={runtime}>
<ThreadRoot>
<ThreadMessages
renderMessage={({ message }) => (
<Box marginBottom={1}>
<Text>
{message.content
.filter((p) => p.type === "text")
.map((p) => p.text)
.join("")}
</Text>
</Box>
)}
/>
<ComposerInput submitOnEnter placeholder="Message..." autoFocus />
</ThreadRoot>
</AssistantProvider>
);
}
render(<App />);Features
- Composable, unstyled primitives (Thread, Composer, Message, ActionBar, etc.)
- Streaming responses with real-time updates
- Tool call support with built-in ToolFallback component
- Message branching and editing
- Multi-thread support with thread list management
- Markdown rendering via
@assistant-ui/react-ink-markdown - Same runtime as
@assistant-ui/react— share adapters, tools, and backend code
Documentation
Related Packages
@assistant-ui/react-ink-markdown— Terminal markdown rendering with syntax highlighting@assistant-ui/react— Web (React) bindings@assistant-ui/react-native— React Native bindings
License
MIT
