@elizaos/plugin-discord-local 2.0.0-beta.1 → 2.0.3-beta.3

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shaw Walters and elizaOS Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # @elizaos/plugin-discord-local
2
+
3
+ Local Discord desktop integration for elizaOS agents, using the Discord RPC socket and macOS UI
4
+ automation to read messages and send replies without the Bot API.
5
+
6
+ ## What it does
7
+
8
+ - Connects to the Discord desktop app running on the same machine over its local IPC socket.
9
+ - Subscribes to `MESSAGE_CREATE` events on configured channels and `NOTIFICATION_CREATE`
10
+ notifications, ingesting each message into the Eliza agent's memory.
11
+ - Sends replies by opening the target channel with a `discord://` deep-link and typing the
12
+ message via AppleScript (`osascript`).
13
+ - Exposes HTTP routes that a setup UI can call to authorize, inspect status, browse guilds and
14
+ channels, and update channel subscriptions.
15
+
16
+ **Platform:** macOS only. The send path uses `osascript` and `/usr/bin/open`.
17
+
18
+ ## Capabilities
19
+
20
+ | Capability | Notes |
21
+ |---|---|
22
+ | Read incoming messages | `MESSAGE_CREATE` RPC subscription on configured channel IDs |
23
+ | Read notifications | `NOTIFICATION_CREATE` RPC subscription (`rpc.notifications.read` scope) |
24
+ | Send replies | AppleScript UI automation — focuses Discord, navigates to channel, types text |
25
+ | Setup API | HTTP routes for authorization and channel management (see below) |
26
+ | OAuth token management | Authorization code + refresh token flow, persisted to disk |
27
+ | Auto-reconnect | Reconnects on socket close if a valid session exists |
28
+
29
+ ## Required configuration
30
+
31
+ These must be set in the agent's settings or environment before the plugin will activate.
32
+
33
+ | Setting | Description |
34
+ |---|---|
35
+ | `DISCORD_LOCAL_CLIENT_ID` | Discord application client ID (from [Discord Developer Portal](https://discord.com/developers/applications)) |
36
+ | `DISCORD_LOCAL_CLIENT_SECRET` | Discord application client secret |
37
+
38
+ The Discord application must have the **RPC** feature enabled and `http://localhost` listed as a
39
+ redirect URI. Required OAuth scopes: `rpc`, `identify`, `rpc.notifications.read`.
40
+
41
+ ## Optional settings
42
+
43
+ | Setting | Default | Description |
44
+ |---|---|---|
45
+ | `DISCORD_LOCAL_ENABLED` | `true` | Set to `"false"` to disable without removing credentials |
46
+ | `DISCORD_LOCAL_SCOPES` | `rpc,identify,rpc.notifications.read` | Comma-separated OAuth scopes |
47
+ | `DISCORD_LOCAL_MESSAGE_CHANNEL_IDS` | _(none)_ | Comma-separated channel IDs to subscribe to `MESSAGE_CREATE` |
48
+ | `DISCORD_LOCAL_SEND_DELAY_MS` | `900` | Delay in ms after focusing Discord before typing (min 100) |
49
+
50
+ ## How to enable
51
+
52
+ Add the plugin to your agent character or runtime configuration:
53
+
54
+ ```ts
55
+ import discordLocalPlugin from "@elizaos/plugin-discord-local";
56
+
57
+ const character = {
58
+ // ...
59
+ plugins: [discordLocalPlugin],
60
+ };
61
+ ```
62
+
63
+ On first run, no session exists. Call `POST /api/setup/discord/start` to trigger the OAuth
64
+ authorization dialog in the Discord desktop app, then subscribe to channels via
65
+ `POST /api/discord/subscriptions`.
66
+
67
+ ## Setup API routes
68
+
69
+ | Method | Path | Description |
70
+ |---|---|---|
71
+ | GET | `/api/setup/discord/status` | Connection and auth status |
72
+ | POST | `/api/setup/discord/start` | Start OAuth authorization (opens Discord dialog) |
73
+ | POST | `/api/setup/discord/cancel` | Disconnect and clear session |
74
+ | GET | `/api/discord/guilds` | List guilds the logged-in user belongs to |
75
+ | GET | `/api/discord/channels?guildId=<id>` | List channels in a guild |
76
+ | POST | `/api/discord/subscriptions` | Set active channel subscriptions (`{ channelIds: string[] }`) |
77
+
78
+ ## How messages flow
79
+
80
+ 1. The `discord-local` service connects to the Discord IPC socket on startup (if a session
81
+ exists) and subscribes to configured channels.
82
+ 2. Inbound `MESSAGE_CREATE` / `NOTIFICATION_CREATE` payloads are decoded and written to the
83
+ agent's `messages` memory table via `runtime.createMemory`.
84
+ 3. The agent processes the memory and produces a reply through the normal elizaOS pipeline.
85
+ 4. The reply is delivered via the `discord-local` send handler registered on
86
+ `runtime.registerSendHandler`. The handler calls `sendUiMessage`, which drives Discord via
87
+ AppleScript.
88
+
89
+ ## Session storage
90
+
91
+ OAuth tokens are persisted at `<stateDir>/discord-local/session.json`. `stateDir` is resolved by
92
+ `resolveStateDir()` from `@elizaos/core` (`ELIZA_STATE_DIR`, else `$XDG_STATE_HOME/eliza`, else
93
+ `~/.local/state/eliza`).
94
+
95
+ ## Limitations
96
+
97
+ - macOS only — the send path is AppleScript; no Linux/Windows support.
98
+ - Authorization requires the Discord desktop app to be open and the user to accept the
99
+ permission dialog interactively. It cannot be automated headlessly.
100
+ - Only text messages are sent; attachments and embeds are read but replies are text-only.
101
+ - There is no built-in rate limiting on outbound messages beyond the configurable send delay.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-discord-local",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.3-beta.3",
4
4
  "description": "Local Discord desktop integration for Eliza via Discord RPC and macOS UI automation",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,9 +22,25 @@
22
22
  "exports": {
23
23
  "./package.json": "./package.json",
24
24
  ".": {
25
+ "types": "./dist/src/index.d.ts",
26
+ "eliza-source": {
27
+ "types": "./src/index.ts",
28
+ "import": "./src/index.ts",
29
+ "default": "./src/index.ts"
30
+ },
25
31
  "import": "./dist/index.js",
26
- "default": "./dist/index.js",
27
- "types": "./dist/src/index.d.ts"
32
+ "default": "./dist/index.js"
33
+ },
34
+ "./*.css": "./dist/*.css",
35
+ "./*": {
36
+ "types": "./dist/*.d.ts",
37
+ "eliza-source": {
38
+ "types": "./src/*.ts",
39
+ "import": "./src/*.ts",
40
+ "default": "./src/*.ts"
41
+ },
42
+ "import": "./dist/*.js",
43
+ "default": "./dist/*.js"
28
44
  }
29
45
  },
30
46
  "files": [
@@ -39,7 +55,7 @@
39
55
  }
40
56
  },
41
57
  "peerDependencies": {
42
- "@elizaos/core": "2.0.0-beta.1"
58
+ "@elizaos/core": "2.0.3-beta.3"
43
59
  },
44
60
  "devDependencies": {
45
61
  "@biomejs/biome": "^2.4.14",
@@ -49,7 +65,7 @@
49
65
  "scripts": {
50
66
  "dev": "bun --hot build.ts",
51
67
  "lint": "bunx @biomejs/biome check --write --config-path ./biome.json .",
52
- "typecheck": "tsc --noEmit -p tsconfig.json",
68
+ "typecheck": "tsgo --noEmit -p tsconfig.json",
53
69
  "clean": "rm -rf dist .turbo",
54
70
  "lint:check": "bunx @biomejs/biome check --config-path ./biome.json .",
55
71
  "build": "bun run build.ts",
@@ -59,5 +75,6 @@
59
75
  },
60
76
  "publishConfig": {
61
77
  "access": "public"
62
- }
78
+ },
79
+ "gitHead": "f54b0f4eaed317d59fa7dbcdce20f4cdb0734420"
63
80
  }