@amaster.ai/copilot-client
v1.1.25
Published
AI copilot chat client with streaming support
Readme
@amaster.ai/copilot-client
Supports: Vite / Browser / Taro H5 / Taro Mini-program (auto-detected)
Installation
pnpm add @amaster.ai/copilot-clientPeer Dependencies
pnpm add @a2a-js/sdkUsage
import { createHttpClient } from "@amaster.ai/http-client";
import { createCopilotClient, type ServerToClientMessage } from "@amaster.ai/copilot-client";
const http = createHttpClient();
const client = createCopilotClient(http);
for await (const messages of client.chat([{ role: "user", content: "Hello" }])) {
// messages: ServerToClientMessage[]
// Process/render the messages
}API
createCopilotClient(http)
Creates a Copilot client.
client.chat(messages, options?)
Streams messages converted from A2A response.
interface ChatMessage {
role: "system" | "user" | "assistant";
content: string | MessageContent[];
}
interface ChatOptions {
taskId?: string;
}client.cancelChat(taskId)
Cancels an ongoing chat task.
client.getChatStatus(taskId)
Gets the current status of a chat task.
Multimodal Input
// Text
{ role: "user", content: "Hello" }
// Image
{ role: "user", content: [
{ type: "text", text: "What's this?" },
{ type: "image", url: "https://..." }
]}
// File
{ role: "user", content: [
{ type: "file", url: "https://...", name: "doc.pdf" }
]}References
License
MIT
