mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
b394f06fdc
Renames the Bots SDK to the Channels SDK. Names only — no behavior change. - 8 packages @copilotkit/bot* -> @copilotkit/channels* (git mv dirs, names, workspace: cross-deps). Now includes @copilotkit/bot-intelligence -> @copilotkit/channels-intelligence (landed on main via #5761; unpublished, so renamed fresh with the family). - release.config.json scope keys + versionSource; ReleaseScope union; canary/stable-release/publish-release scope dropdowns; verify script - examples/slack (Kite) + examples/teams: deps, jsxImportSource, imports - showcase/shell-docs: content dirs docs/bots->docs/channels and reference/bot->reference/channels, nav registry, redirects createBot and other API names unchanged. Old @copilotkit/bot* to be deprecated after the new packages publish (bot-intelligence was never published). Re-derived onto latest main (was conflicting after #5761 landed). Refs OSS-438
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
/**
|
|
* `read_thread` — an app-side `BotTool` that hands the agent the full
|
|
* conversation thread it's replying in. This is what makes "write this
|
|
* incident thread up as a postmortem" possible: the agent calls
|
|
* `read_thread`, gets the actual messages, and summarizes those instead
|
|
* of inventing content.
|
|
*
|
|
* It's a worked example of a `BotTool` that reads conversation history
|
|
* via the platform-agnostic `ctx.thread.getMessages()` capability —
|
|
* the adapter targets the current thread, so no channel/ts plumbing is
|
|
* needed.
|
|
*/
|
|
import { z } from "zod";
|
|
import { defineBotTool } from "@copilotkit/channels";
|
|
|
|
export const readThreadTool = defineBotTool({
|
|
name: "read_thread",
|
|
description:
|
|
"Fetch the messages in the current conversation thread so you can " +
|
|
"summarize or act on them. Call this before turning a conversation into a " +
|
|
"Linear issue or a Notion postmortem — never guess what was said. Returns " +
|
|
"the messages in chronological order with author and timestamp.",
|
|
parameters: z.object({}),
|
|
async handler(_args, { thread }) {
|
|
const messages = await thread.getMessages();
|
|
return {
|
|
count: messages.length,
|
|
messages: messages.map((m) => ({
|
|
user: m.user?.name ?? m.user?.handle ?? (m.isBot ? "bot" : "unknown"),
|
|
text: m.text,
|
|
ts: m.ts,
|
|
})),
|
|
};
|
|
},
|
|
});
|