@elizaos/plugin-twitter 1.2.21 → 1.2.23-alpha.0
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/README.md +55 -15
- package/dist/index.js +14508 -4196
- package/dist/index.js.map +1 -1
- package/package.json +43 -10
package/README.md
CHANGED
|
@@ -8,21 +8,36 @@ This package provides Twitter/X integration for the Eliza AI agent using the off
|
|
|
8
8
|
|
|
9
9
|
1. **Get Twitter Developer account** → https://developer.twitter.com
|
|
10
10
|
2. **Create an app** → Enable "Read and write" permissions
|
|
11
|
-
3.
|
|
12
|
-
|
|
13
|
-
-
|
|
11
|
+
3. Choose your auth mode:
|
|
12
|
+
|
|
13
|
+
- **Option A (default, legacy): OAuth 1.0a env vars**
|
|
14
|
+
- API Key & Secret (from "Consumer Keys")
|
|
15
|
+
- Access Token & Secret (from "Authentication Tokens")
|
|
16
|
+
|
|
17
|
+
- **Option B (recommended): “login + approve” OAuth 2.0 (PKCE)**
|
|
18
|
+
- Client ID (from "OAuth 2.0 Client ID")
|
|
19
|
+
- Redirect URI (loopback recommended)
|
|
20
|
+
|
|
14
21
|
4. **Add to `.env`:**
|
|
15
22
|
```bash
|
|
23
|
+
# Option A: legacy OAuth 1.0a (default)
|
|
24
|
+
TWITTER_AUTH_MODE=env
|
|
16
25
|
TWITTER_API_KEY=xxx
|
|
17
26
|
TWITTER_API_SECRET_KEY=xxx
|
|
18
27
|
TWITTER_ACCESS_TOKEN=xxx
|
|
19
28
|
TWITTER_ACCESS_TOKEN_SECRET=xxx
|
|
29
|
+
|
|
30
|
+
# Option B: OAuth 2.0 PKCE (interactive login + approve, no client secret)
|
|
31
|
+
# TWITTER_AUTH_MODE=oauth
|
|
32
|
+
# TWITTER_CLIENT_ID=xxx
|
|
33
|
+
# TWITTER_REDIRECT_URI=http://127.0.0.1:8080/callback
|
|
34
|
+
|
|
20
35
|
TWITTER_ENABLE_POST=true
|
|
21
36
|
TWITTER_POST_IMMEDIATELY=true
|
|
22
37
|
```
|
|
23
38
|
5. **Run:** `bun start`
|
|
24
39
|
|
|
25
|
-
|
|
40
|
+
Tip: if you use **OAuth 2.0 PKCE**, the plugin will print an authorization URL on first run and store tokens for you (no manual token pasting).
|
|
26
41
|
|
|
27
42
|
## Features
|
|
28
43
|
|
|
@@ -39,7 +54,7 @@ This package provides Twitter/X integration for the Eliza AI agent using the off
|
|
|
39
54
|
## Prerequisites
|
|
40
55
|
|
|
41
56
|
- Twitter Developer Account with API v2 access
|
|
42
|
-
- Twitter OAuth 1.0a credentials (
|
|
57
|
+
- Either Twitter OAuth 1.0a credentials (legacy env vars) or OAuth 2.0 Client ID (PKCE)
|
|
43
58
|
- Node.js and bun installed
|
|
44
59
|
|
|
45
60
|
## 🚀 Quick Start
|
|
@@ -77,12 +92,12 @@ This package provides Twitter/X integration for the Eliza AI agent using the off
|
|
|
77
92
|
|
|
78
93
|
### Step 3: Get the RIGHT Credentials (OAuth 1.0a)
|
|
79
94
|
|
|
80
|
-
|
|
95
|
+
You can use either legacy **OAuth 1.0a** env vars (default) or **OAuth 2.0 PKCE** (“login + approve”).
|
|
81
96
|
|
|
82
97
|
In your app's **"Keys and tokens"** page, you'll see several sections. Here's what to use:
|
|
83
98
|
|
|
84
99
|
```
|
|
85
|
-
✅ USE THESE (OAuth 1.0a):
|
|
100
|
+
✅ USE THESE when TWITTER_AUTH_MODE=env (OAuth 1.0a):
|
|
86
101
|
┌─────────────────────────────────────────────────┐
|
|
87
102
|
│ Consumer Keys │
|
|
88
103
|
│ ├─ API Key: xxx...xxx → TWITTER_API_KEY │
|
|
@@ -93,13 +108,13 @@ In your app's **"Keys and tokens"** page, you'll see several sections. Here's wh
|
|
|
93
108
|
│ └─ Access Token Secret: xxx → TWITTER_ACCESS_TOKEN_SECRET │
|
|
94
109
|
└─────────────────────────────────────────────────┘
|
|
95
110
|
|
|
96
|
-
|
|
111
|
+
✅ USE THESE when TWITTER_AUTH_MODE=oauth (OAuth 2.0 PKCE):
|
|
97
112
|
┌─────────────────────────────────────────────────┐
|
|
98
113
|
│ OAuth 2.0 Client ID and Client Secret │
|
|
99
|
-
│ ├─ Client ID: xxx...xxx
|
|
100
|
-
│ └─ Client Secret: xxx...xxx ←
|
|
114
|
+
│ ├─ Client ID: xxx...xxx → TWITTER_CLIENT_ID │
|
|
115
|
+
│ └─ Client Secret: xxx...xxx ← NOT USED (do not put in env) │
|
|
101
116
|
│ │
|
|
102
|
-
│ Bearer Token ←
|
|
117
|
+
│ Bearer Token ← NOT USED │
|
|
103
118
|
└─────────────────────────────────────────────────┘
|
|
104
119
|
```
|
|
105
120
|
|
|
@@ -113,6 +128,12 @@ In your app's **"Keys and tokens"** page, you'll see several sections. Here's wh
|
|
|
113
128
|
Create or edit `.env` file in your project root:
|
|
114
129
|
|
|
115
130
|
```bash
|
|
131
|
+
# Auth mode (default: env)
|
|
132
|
+
# - env: legacy OAuth 1.0a keys/tokens
|
|
133
|
+
# - oauth: “login + approve” OAuth 2.0 PKCE (no client secret in plugin)
|
|
134
|
+
# - broker: stub (not implemented yet)
|
|
135
|
+
TWITTER_AUTH_MODE=env
|
|
136
|
+
|
|
116
137
|
# REQUIRED: OAuth 1.0a Credentials (from "Consumer Keys" section)
|
|
117
138
|
TWITTER_API_KEY=your_api_key_here # From "API Key"
|
|
118
139
|
TWITTER_API_SECRET_KEY=your_api_key_secret_here # From "API Key Secret"
|
|
@@ -121,6 +142,14 @@ TWITTER_API_SECRET_KEY=your_api_key_secret_here # From "API Key Secret"
|
|
|
121
142
|
TWITTER_ACCESS_TOKEN=your_access_token_here # Must have "Read and Write"
|
|
122
143
|
TWITTER_ACCESS_TOKEN_SECRET=your_token_secret_here # Regenerate after permission change
|
|
123
144
|
|
|
145
|
+
# ---- OR ----
|
|
146
|
+
# OAuth 2.0 PKCE (“login + approve”) configuration:
|
|
147
|
+
# TWITTER_AUTH_MODE=oauth
|
|
148
|
+
# TWITTER_CLIENT_ID=your_oauth2_client_id_here
|
|
149
|
+
# TWITTER_REDIRECT_URI=http://127.0.0.1:8080/callback
|
|
150
|
+
# Optional:
|
|
151
|
+
# TWITTER_SCOPES="tweet.read tweet.write users.read offline.access"
|
|
152
|
+
|
|
124
153
|
# Basic Configuration
|
|
125
154
|
TWITTER_DRY_RUN=false # Set to true to test without posting
|
|
126
155
|
TWITTER_ENABLE_POST=true # Enable autonomous tweet posting
|
|
@@ -133,6 +162,11 @@ TWITTER_POST_INTERVAL_MIN=90 # Minimum minutes between posts
|
|
|
133
162
|
TWITTER_POST_INTERVAL_MAX=150 # Maximum minutes between posts
|
|
134
163
|
```
|
|
135
164
|
|
|
165
|
+
When using **TWITTER_AUTH_MODE=oauth**, the plugin will:
|
|
166
|
+
- Print an authorization URL on first run
|
|
167
|
+
- Capture the callback via a local loopback server **or** ask you to paste the redirected URL
|
|
168
|
+
- Persist tokens via Eliza runtime cache if available, otherwise a local token file at `~/.eliza/twitter/oauth2.tokens.json`
|
|
169
|
+
|
|
136
170
|
### Step 5: Run Your Bot
|
|
137
171
|
|
|
138
172
|
```typescript
|
|
@@ -348,12 +382,17 @@ This is the #1 issue! Your app has read-only permissions.
|
|
|
348
382
|
|
|
349
383
|
### "Could not authenticate you"
|
|
350
384
|
|
|
351
|
-
|
|
385
|
+
This usually means your credentials don’t match your selected auth mode.
|
|
352
386
|
|
|
353
387
|
**Solution:**
|
|
354
|
-
-
|
|
355
|
-
- Use credentials from "
|
|
356
|
-
-
|
|
388
|
+
- If `TWITTER_AUTH_MODE=env`:
|
|
389
|
+
- Use credentials from "Consumer Keys" section (API Key/Secret)
|
|
390
|
+
- Use credentials from "Authentication Tokens" section (Access Token/Secret)
|
|
391
|
+
- Do not use OAuth 2.0 Client ID/Client Secret/Bearer Token for this mode
|
|
392
|
+
- If `TWITTER_AUTH_MODE=oauth`:
|
|
393
|
+
- Use OAuth 2.0 **Client ID** (`TWITTER_CLIENT_ID`)
|
|
394
|
+
- Set a loopback redirect URI (`TWITTER_REDIRECT_URI`, e.g. `http://127.0.0.1:8080/callback`)
|
|
395
|
+
- Do not set/ship a client secret (PKCE flow)
|
|
357
396
|
|
|
358
397
|
### Bot Not Posting Automatically
|
|
359
398
|
|
|
@@ -460,6 +499,7 @@ Monitor your usage at: https://developer.twitter.com/en/portal/dashboard
|
|
|
460
499
|
|
|
461
500
|
- [Twitter API v2 Documentation](https://developer.twitter.com/en/docs/twitter-api)
|
|
462
501
|
- [Twitter OAuth 1.0a Guide](https://developer.twitter.com/en/docs/authentication/oauth-1-0a)
|
|
502
|
+
- [Twitter OAuth 2.0 (Authorization Code with PKCE)](https://developer.twitter.com/en/docs/authentication/oauth-2-0/authorization-code)
|
|
463
503
|
- [Rate Limits Reference](https://developer.twitter.com/en/docs/twitter-api/rate-limits)
|
|
464
504
|
- [ElizaOS Documentation](https://github.com/elizaos/eliza)
|
|
465
505
|
|