@copilotkit/channels-discord 0.2.0 → 0.2.1-canary.1784916581

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +28 -3
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -8,6 +8,12 @@ streaming, opaque-id interactions, and HITL.
8
8
  You write your UI as JSX once (`@copilotkit/channels-ui`) and drive the bot with
9
9
  `@copilotkit/channels`; this package is the only one that talks to Discord.
10
10
 
11
+ The adapter keeps its own Discord credentials (`botToken` / `appId` / …) — but
12
+ the Channel itself only runs inside a CopilotKit Intelligence-configured
13
+ `CopilotRuntime` (an API key; a free tier is available). There is no
14
+ standalone / DIY runner and no `channel.start()`; the runtime starts and owns
15
+ the channel because Intelligence is configured.
16
+
11
17
  ## Install
12
18
 
13
19
  ```sh
@@ -23,8 +29,14 @@ import {
23
29
  defaultDiscordTools,
24
30
  defaultDiscordContext,
25
31
  } from "@copilotkit/channels-discord";
32
+ import {
33
+ CopilotRuntime,
34
+ CopilotKitIntelligence,
35
+ createCopilotRuntimeHandler,
36
+ } from "@copilotkit/runtime/v2";
26
37
 
27
38
  const bot = createChannel({
39
+ name: "support-bot", // project-unique Intelligence Channel name
28
40
  adapters: [
29
41
  discord({
30
42
  botToken: process.env.DISCORD_BOT_TOKEN!, // Bot token — Gateway + REST
@@ -48,7 +60,19 @@ const bot = createChannel({
48
60
 
49
61
  bot.onMention(({ thread }) => thread.runAgent());
50
62
 
51
- await bot.start();
63
+ // The runtime owns the channel's lifecycle — there is no `bot.start()`.
64
+ const runtime = new CopilotRuntime({
65
+ intelligence: new CopilotKitIntelligence({
66
+ apiUrl: "https://api.copilotkit.ai",
67
+ wsUrl: "wss://api.copilotkit.ai",
68
+ apiKey: process.env.COPILOTKIT_INTELLIGENCE_API_KEY!, // free tier available
69
+ }),
70
+ identifyUser: async () => ({ id: "support-bot", name: "Support Bot" }),
71
+ channels: [bot],
72
+ });
73
+
74
+ const handler = createCopilotRuntimeHandler({ runtime });
75
+ await handler.channels.ready(); // starts the channel; handler.channels.stop() tears it down
52
76
  ```
53
77
 
54
78
  `discord(opts)` returns a `DiscordAdapter`. The adapter connects via the
@@ -250,8 +274,9 @@ work against any adapter that advertises the same capabilities.
250
274
 
251
275
  ## Slash commands
252
276
 
253
- Slash commands are registered up front on `bot.start()` via `registerCommands`.
254
- When `guildId` is set they register to that guild instantly; without it they
277
+ Slash commands are registered up front — when the runtime activates the
278
+ channel (`await handler.channels.ready()`) — via `registerCommands`. When
279
+ `guildId` is set they register to that guild instantly; without it they
255
280
  register globally and take ~1 hour to propagate. Register handlers with
256
281
  `bot.onCommand`:
257
282
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkit/channels-discord",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-canary.1784916581",
4
4
  "description": "Discord PlatformAdapter for @copilotkit/channels.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "@ag-ui/client": "0.0.57",
37
37
  "discord.js": "^14.16.0",
38
38
  "zod": "^3.25.76",
39
- "@copilotkit/channels-core": "^0.2.0",
40
- "@copilotkit/channels-ui": "^0.2.0"
39
+ "@copilotkit/channels-core": "^0.2.1-canary.1784916581",
40
+ "@copilotkit/channels-ui": "^0.2.1-canary.1784916581"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^22.10.0",