@flutchai/chat-contract
TypeScript types for the Flutch External API: sending a message to an agent (invoke, stream, cancel), listing threads, reading history, reactions, file uploads and reports sent to the user. No runtime code.
npm install @flutchai/chat-contract
import type {
AgentRequest,
Message,
StreamEvent,
ThreadList,
} from "@flutchai/chat-contract";
const request: AgentRequest = {
externalUserId: "customer-42", // your own id for the user
content: { text: "Hello" },
};
Most apps want @flutchai/chat-core (client, SSE streaming, conversation store) or @flutchai/chat-react (React UI), which depend on this package. Use it directly when you write your own client, or the server side of a proxy, in TypeScript.
What is in it
| Area | Types |
|---|---|
| Request | AgentRequest, UserRef, RequestMetadata, CancelRequest |
| Messages | Message, MessageContent, MessageInput, ContentChain, ReactionRequest |
| Attachments | Attachment, TypedAttachment, AttachmentValueMap and one type per attachment kind (ImageValue, Button, CardValue, ...) |
| Streaming | StreamEvent, StreamEventMap, StreamDelta, EscalationReason |
| Threads | ThreadSummary, ThreadList, ThreadMessages, Page |
| Errors | ApiErrorBody |
Unknown attachment types and new fields can appear at any time: treat the contract as open and ignore what you do not recognize.
Identifying the user
Every request names the end user with exactly one of externalUserId (your own id, the user is created on first use) or userId (a Flutch user id). See UserRef.
License
MIT