@aichatkit/types
Version:
Shared TypeScript types for Hypermode ChatKit
103 lines (101 loc) • 2.11 kB
text/typescript
/**
* Core message type definitions for the chat application
*/
/**
* Base response item type
*/
type ResponseItemType = 'message' | 'tool_call' | 'card';
/**
* Tool call data structure
*/
interface ToolCall {
id: string;
name: string;
arguments: Record<string, any>;
status: 'pending' | 'executing' | 'completed' | 'error';
result?: any;
error?: string;
}
/**
* Card data structure for rich content
*/
interface Card {
id: string;
type: string;
title?: string;
content: Record<string, any>;
actions?: CardAction[];
}
interface CardAction {
id: string;
label: string;
type: 'button' | 'link';
action: string;
data?: Record<string, any>;
}
/**
* Base response item
*/
interface ResponseItem {
id: string | number;
type: ResponseItemType;
timestamp?: string;
}
/**
* Message response item
*/
interface MessageItem extends ResponseItem {
type: 'message';
content: string;
role: 'user' | 'assistant';
}
/**
* Tool call response item
*/
interface ToolCallItem extends ResponseItem {
type: 'tool_call';
toolCall: ToolCall;
}
/**
* Card response item
*/
interface CardItem extends ResponseItem {
type: 'card';
card: Card;
}
/**
* Union type for all response items
*/
type ChatResponseItem = MessageItem | ToolCallItem | CardItem;
/**
* Represents a single chat message
*/
interface Message {
id: string | number;
content: string;
role: 'user' | 'assistant';
timestamp?: string;
}
/**
* Represents a conversation consisting of multiple response items
*/
interface Conversation {
id: string;
title: string;
items: ChatResponseItem[];
}
/**
* Response from the chat API
*/
interface ChatResponse {
items: ChatResponseItem[];
conversationId: string;
}
/**
* Simple message structure to handle chat history
*/
interface ChatMessage {
role: string;
content: string;
}
export type { Card, CardAction, CardItem, ChatMessage, ChatResponse, ChatResponseItem, Conversation, Message, MessageItem, ResponseItem, ResponseItemType, ToolCall, ToolCallItem };