@elizaos/plugin-twitch 2.0.0-alpha.8 → 2.0.3-beta.2

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,126 @@
1
+ # @elizaos/plugin-twitch
2
+
3
+ Twitch chat integration for elizaOS agents. Connects to one or more Twitch
4
+ channels over IRC (via [@twurple](https://twurple.js.org)), receives chat
5
+ messages with role-based filtering and optional @mention gating, and sends
6
+ replies. Outbound send/join/leave operations route through the runtime
7
+ `MESSAGE` action via a registered `MessageConnector` — this plugin registers no
8
+ actions or providers of its own.
9
+
10
+ Node-only (`"runtime": "node"` in package.json). Not compatible with browser or
11
+ mobile runtimes.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ bun add @elizaos/plugin-twitch
17
+ ```
18
+
19
+ Add the plugin name to a character's `plugins` array, or rely on auto-enable: a
20
+ `twitch` connector block under agent config activates the plugin automatically
21
+ unless `enabled: false` is set.
22
+
23
+ ```ts
24
+ import type { Character } from "@elizaos/core";
25
+
26
+ const character: Character = {
27
+ name: "my-agent",
28
+ plugins: ["@elizaos/plugin-twitch"],
29
+ };
30
+ ```
31
+
32
+ ## Prerequisites
33
+
34
+ 1. A Twitch application registered at the
35
+ [Twitch Developer Console](https://dev.twitch.tv/console) (provides the
36
+ client ID, and a client secret if you want token refresh).
37
+ 2. An OAuth access token with `chat:read` and `chat:edit` scopes.
38
+
39
+ ## Configuration
40
+
41
+ Settings resolve in priority order: a per-account object in `TWITCH_ACCOUNTS`
42
+ JSON > `character.settings.twitch` > top-level env vars (default account only).
43
+ See `src/accounts.ts` (`resolveTwitchAccountSettings`).
44
+
45
+ ### Required
46
+
47
+ | Variable | Description |
48
+ |----------|-------------|
49
+ | `TWITCH_USERNAME` | Bot's Twitch login name |
50
+ | `TWITCH_CLIENT_ID` | Application client ID |
51
+ | `TWITCH_ACCESS_TOKEN` | OAuth token (`oauth:` prefix stripped automatically) |
52
+ | `TWITCH_CHANNEL` | Primary channel to join (no `#` prefix) |
53
+
54
+ ### Optional
55
+
56
+ | Variable | Description | Default |
57
+ |----------|-------------|---------|
58
+ | `TWITCH_CLIENT_SECRET` | Enables `RefreshingAuthProvider`; without it a `StaticAuthProvider` is used | - |
59
+ | `TWITCH_REFRESH_TOKEN` | Passed to `RefreshingAuthProvider` when the client secret is also set | - |
60
+ | `TWITCH_CHANNELS` | Comma-separated additional channels to join at startup | - |
61
+ | `TWITCH_REQUIRE_MENTION` | `"true"` only processes messages that @mention the bot | `false` |
62
+ | `TWITCH_ALLOWED_ROLES` | Comma-separated: `all`, `owner`, `moderator`, `vip`, `subscriber` | `all` |
63
+ | `TWITCH_ACCOUNTS` | JSON array/object for multi-account mode | - |
64
+ | `TWITCH_ACCOUNT_ID` / `TWITCH_DEFAULT_ACCOUNT_ID` | Select the default account when several are configured | - |
65
+
66
+ The same settings can live under `character.settings.twitch` as camelCase
67
+ fields (`username`, `clientId`, `accessToken`, `channel`, `additionalChannels`,
68
+ `requireMention`, `allowedRoles`, `allowedUserIds`), with a nested `accounts`
69
+ map for multi-account configs.
70
+
71
+ ## Messaging operations
72
+
73
+ Twitch chat operations route through the canonical `MESSAGE` action with
74
+ `source: "twitch"`. The connector exposes these operations:
75
+
76
+ | Operation | Description |
77
+ |-----------|-------------|
78
+ | `send` | Send a message to a Twitch channel |
79
+ | `join` | Join a Twitch channel |
80
+ | `leave` | Leave a Twitch channel (the primary channel cannot be left) |
81
+ | `list_channels` | List the configured/joined Twitch channels |
82
+
83
+ Messages over 500 characters are split at sentence/word boundaries with a 300 ms
84
+ delay between chunks (`splitMessageForTwitch`). LLM markdown is converted to
85
+ plain text before sending (`stripMarkdownForTwitch`); Twitch does not render
86
+ markdown.
87
+
88
+ ## Events
89
+
90
+ `TwitchService` emits these runtime events (string constants on
91
+ `TwitchEventTypes`):
92
+
93
+ | Constant | String value |
94
+ |----------|--------------|
95
+ | `MESSAGE_RECEIVED` | `TWITCH_MESSAGE_RECEIVED` |
96
+ | `MESSAGE_SENT` | `TWITCH_MESSAGE_SENT` |
97
+ | `JOIN_CHANNEL` | `TWITCH_JOIN_CHANNEL` |
98
+ | `LEAVE_CHANNEL` | `TWITCH_LEAVE_CHANNEL` |
99
+ | `CONNECTION_READY` | `TWITCH_CONNECTION_READY` |
100
+ | `CONNECTION_LOST` | `TWITCH_CONNECTION_LOST` |
101
+
102
+ ## Source layout
103
+
104
+ ```
105
+ src/
106
+ index.ts Plugin entry (default export)
107
+ service.ts TwitchService — IRC lifecycle, connector handlers
108
+ accounts.ts Multi-account config resolution
109
+ connector-account-provider.ts ConnectorAccountProvider adapter
110
+ workflow-credential-provider.ts TwitchWorkflowCredentialProvider service
111
+ types.ts Interfaces, enums, constants, utils, errors
112
+ auto-enable.ts Lightweight shouldEnable() for the auto-enable engine
113
+ ```
114
+
115
+ ## Commands
116
+
117
+ ```bash
118
+ bun run --cwd plugins/plugin-twitch build # compile dist/
119
+ bun run --cwd plugins/plugin-twitch test # bun test
120
+ bun run --cwd plugins/plugin-twitch format # biome format --write
121
+ bun run --cwd plugins/plugin-twitch format:check # biome format (check only)
122
+ ```
123
+
124
+ ## License
125
+
126
+ MIT
package/auto-enable.ts ADDED
@@ -0,0 +1,21 @@
1
+ // Auto-enable check for @elizaos/plugin-twitch.
2
+ //
3
+ // Plugin manifest entry-point — referenced by package.json's
4
+ // `elizaos.plugin.autoEnableModule`. Keep this module light: env reads only,
5
+ // no service init, no transitive imports of the full plugin runtime. The
6
+ // auto-enable engine loads dozens of these per boot.
7
+ import type { PluginAutoEnableContext } from "@elizaos/core";
8
+
9
+ /** Enable when a `twitch` connector block is present and not explicitly disabled. */
10
+ export function shouldEnable(ctx: PluginAutoEnableContext): boolean {
11
+ const c = (ctx.config?.connectors as Record<string, unknown> | undefined)
12
+ ?.twitch;
13
+ if (!c || typeof c !== "object") return false;
14
+ const config = c as Record<string, unknown>;
15
+ if (config.enabled === false) return false;
16
+ // The full per-connector field check (clientId/oauth token/channel) lives
17
+ // in the central engine's isConnectorConfigured. We delegate to a simple
18
+ // "block present + not explicitly disabled" check here; the central
19
+ // engine's stricter check remains as a fallback during migration.
20
+ return true;
21
+ }
package/package.json CHANGED
@@ -1,19 +1,45 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-twitch",
3
- "version": "2.0.0-alpha.8",
3
+ "version": "2.0.3-beta.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
9
  "types": "./dist/index.d.ts",
10
+ "eliza-source": {
11
+ "types": "./src/index.ts",
12
+ "import": "./src/index.ts",
13
+ "default": "./src/index.ts"
14
+ },
10
15
  "import": "./dist/index.js",
11
16
  "default": "./dist/index.js"
17
+ },
18
+ "./*.css": "./dist/*.css",
19
+ "./*": {
20
+ "types": "./dist/*.d.ts",
21
+ "eliza-source": {
22
+ "types": "./src/*.ts",
23
+ "import": "./src/*.ts",
24
+ "default": "./src/*.ts"
25
+ },
26
+ "import": "./dist/*.js",
27
+ "default": "./dist/*.js"
12
28
  }
13
29
  },
14
30
  "files": [
15
- "dist"
31
+ "dist",
32
+ "auto-enable.ts"
16
33
  ],
34
+ "elizaos": {
35
+ "plugin": {
36
+ "autoEnableModule": "./auto-enable.ts",
37
+ "capabilities": [
38
+ "messaging",
39
+ "live-streaming"
40
+ ]
41
+ }
42
+ },
17
43
  "scripts": {
18
44
  "build": "bun run build.ts",
19
45
  "test": "bun test",
@@ -24,19 +50,18 @@
24
50
  "typecheck": "echo \"Typecheck skipped for release\""
25
51
  },
26
52
  "dependencies": {
27
- "@twurple/auth": "^7.2.0",
28
- "@twurple/chat": "^7.2.0",
29
- "zod": "^4.3.6"
53
+ "@twurple/auth": "^8.0.0",
54
+ "@twurple/chat": "^8.0.0"
30
55
  },
31
56
  "peerDependencies": {
32
- "@elizaos/core": "2.0.0-alpha.3"
57
+ "@elizaos/core": "2.0.3-beta.2"
33
58
  },
34
59
  "devDependencies": {
60
+ "@biomejs/biome": "^2.4.14",
35
61
  "@types/bun": "^1.1.0",
36
- "typescript": "^5.3.0",
37
- "@biomejs/biome": "^2.3.11"
62
+ "typescript": "^6.0.3"
38
63
  },
39
- "milady": {
64
+ "eliza": {
40
65
  "platforms": [
41
66
  "node"
42
67
  ],
@@ -105,5 +130,6 @@
105
130
  "sensitive": false
106
131
  }
107
132
  }
108
- }
133
+ },
134
+ "gitHead": "82fe0f44215954c2417328203f5bd6510985c1fc"
109
135
  }
@@ -1,6 +0,0 @@
1
- /**
2
- * Join channel action for Twitch plugin.
3
- */
4
- import type { Action } from "@elizaos/core";
5
- export declare const joinChannel: Action;
6
- //# sourceMappingURL=joinChannel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"joinChannel.d.ts","sourceRoot":"","sources":["../../src/actions/joinChannel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EAKP,MAAM,eAAe,CAAC;AAyBvB,eAAO,MAAM,WAAW,EAAE,MA+IzB,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Leave channel action for Twitch plugin.
3
- */
4
- import type { Action } from "@elizaos/core";
5
- export declare const leaveChannel: Action;
6
- //# sourceMappingURL=leaveChannel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"leaveChannel.d.ts","sourceRoot":"","sources":["../../src/actions/leaveChannel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EAKP,MAAM,eAAe,CAAC;AA2BvB,eAAO,MAAM,YAAY,EAAE,MAsK1B,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * List channels action for Twitch plugin.
3
- */
4
- import type { Action } from "@elizaos/core";
5
- export declare const listChannels: Action;
6
- //# sourceMappingURL=listChannels.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"listChannels.d.ts","sourceRoot":"","sources":["../../src/actions/listChannels.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EAKP,MAAM,eAAe,CAAC;AAIvB,eAAO,MAAM,YAAY,EAAE,MAqH1B,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Send message action for Twitch plugin.
3
- */
4
- import type { Action } from "@elizaos/core";
5
- export declare const sendMessage: Action;
6
- //# sourceMappingURL=sendMessage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sendMessage.d.ts","sourceRoot":"","sources":["../../src/actions/sendMessage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EAKP,MAAM,eAAe,CAAC;AAiCvB,eAAO,MAAM,WAAW,EAAE,MAqKzB,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,22 +0,0 @@
1
- /**
2
- * Twitch chat integration plugin for ElizaOS.
3
- *
4
- * This plugin provides Twitch chat integration using the @twurple library.
5
- */
6
- import type { Plugin } from "@elizaos/core";
7
- export { TwitchService } from "./service.js";
8
- export * from "./types.js";
9
- import { joinChannel } from "./actions/joinChannel.js";
10
- import { leaveChannel } from "./actions/leaveChannel.js";
11
- import { listChannels } from "./actions/listChannels.js";
12
- import { sendMessage } from "./actions/sendMessage.js";
13
- export { sendMessage, joinChannel, leaveChannel, listChannels };
14
- import { channelStateProvider } from "./providers/channelState.js";
15
- import { userContextProvider } from "./providers/userContext.js";
16
- export { channelStateProvider, userContextProvider };
17
- /**
18
- * Twitch plugin definition.
19
- */
20
- declare const twitchPlugin: Plugin;
21
- export default twitchPlugin;
22
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAI3D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AAGhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;AAKrD;;GAEG;AACH,QAAA,MAAM,YAAY,EAAE,MA+EnB,CAAC;AAEF,eAAe,YAAY,CAAC"}