opencode-pollinations-plugin 6.0.0-beta.24 → 6.0.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.
Files changed (3) hide show
  1. package/README.md +88 -134
  2. package/dist/index.js +54 -86
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,165 +1,119 @@
1
- # 🌸 Pollinations AI Plugin for OpenCode (v5.6.0)
1
+ # 🌸 Pollinations AI Plugin for OpenCode
2
2
 
3
3
  <div align="center">
4
- <img src="https://avatars.githubusercontent.com/u/88394740?s=400&v=4" alt="Pollinations.ai Logo" width="200">
4
+ <img src="https://avatars.githubusercontent.com/u/88394740?s=400&v=4" alt="Pollinations.ai Logo" width="150">
5
5
  <br>
6
- <b>The Bridge between OpenCode and the Pollinations.ai Ecosystem.</b>
6
+ <b>The Bridge between OpenCode and the Pollinations.ai Ecosystem</b>
7
7
  <br>
8
- Access unlimited free AI models or premium enterprise models directly within your editor.
8
+ Access 25+ AI models with Vision, Reasoning, and Tools support.
9
9
  </div>
10
10
 
11
11
  <div align="center">
12
12
 
13
- ![Version](https://img.shields.io/badge/version-5.8.4--beta.15-orange.svg)
13
+ ![Version](https://img.shields.io/badge/version-6.0.0--beta.25-blue.svg)
14
14
  ![License](https://img.shields.io/badge/license-MIT-green.svg)
15
- ![Status](https://img.shields.io/badge/status-Beta-yellow.svg)
15
+ ![Status](https://img.shields.io/badge/status-Stable-brightgreen.svg)
16
16
 
17
- [📜 View Changelog](./CHANGELOG.md) | [🛣️ Roadmap](./ROADMAP.md)
17
+ [📜 Changelog](./CHANGELOG.md) | [🛣️ Roadmap](./ROADMAP.md)
18
18
 
19
19
  </div>
20
20
 
21
- ## 📖 Philosophy: Open AI for Creators
21
+ ---
22
22
 
23
- > **"No closed doors, no corporate hoops — just good tools and good people."**
23
+ ## Features
24
24
 
25
- Pollinations.ai is an open-source platform built by and for the community. We provide a unified API for image, text, audio, and video generation.
26
- - **Transparent**: Our code, roadmap, and discussions are open.
27
- - **Community Driven**: Features are prioritized based on what *you* need.
28
- - **Fair**: One single currency (**Pollen**) for all models. No complex subscriptions.
25
+ - **👁️ Vision Support**: Send images to AI models (OpenAI, Claude, Gemini, Kimi)
26
+ - **🧠 Reasoning Models**: Access advanced thinking models (DeepSeek, Kimi, Perplexity)
27
+ - **🛠️ Native Tools**: Full function calling support for compatible models
28
+ - **🔐 Secure Auth**: Native OpenCode `/connect` integration
29
+ - **🔄 Hot-Reload**: Change API keys without restarting OpenCode
29
30
 
30
- ## 📸 Gallery
31
+ ---
31
32
 
32
- <p align="center">
33
- <img src="https://github.com/fkom13/opencode-pollinations-plugin/raw/main/docs/images/connect.png" alt="Connect Command" width="800">
34
- <br>
35
- <em>Easy Connection with /connect or /pollinations config apiKey</em>
36
- </p>
33
+ ## 🐝 Understanding Pollen & Tiers
37
34
 
38
- <p align="center">
39
- <img src="https://github.com/fkom13/opencode-pollinations-plugin/raw/main/docs/images/usage_dashboard.png" alt="Usage Dashboard" width="800">
40
- <br>
41
- <em>Integrated Usage Dashboard (/pollinations usage)</em>
42
- </p>
35
+ **Pollen** is Pollinations' unified credit system. $1 ≈ 1 Pollen.
43
36
 
44
- <p align="center">
45
- <img src="https://github.com/fkom13/opencode-pollinations-plugin/raw/main/docs/images/models.png" alt="Models" width="800">
46
- <br>
47
- <em>Wide Range of Models (Mistral, OpenAI, Gemini, Claude)</em>
48
- </p>
37
+ | Tier | Daily Grant | Requirement |
38
+ |:-----|:------------|:------------|
39
+ | 🦠 **Microbe** | 0.1 Pollen | Flagged accounts |
40
+ | 🌱 **Spore** | 1 Pollen | Sign up |
41
+ | 🌿 **Seed** | 3 Pollen | Active GitHub dev (8+ points) |
42
+ | 🌸 **Flower** | 10 Pollen | Published app |
43
+ | 🍯 **Nectar** | 20 Pollen | Major contributor |
49
44
 
50
- <p align="center">
51
- <img src="https://github.com/fkom13/opencode-pollinations-plugin/raw/main/docs/images/free_add.png" alt="Free Chat Example" width="800">
52
- <br>
53
- <em>Free Universe Chat (Supported by Pollinations Ads)</em>
54
- </p>
45
+ > 💡 This plugin was published to the OpenCode ecosystem, granting its author **Flower** tier (10 Pollen/day).
55
46
 
56
- <p align="center">
57
- <img src="https://github.com/fkom13/opencode-pollinations-plugin/raw/main/docs/images/plan_1.png" alt="Plan Build Step 1" width="400">
58
- <img src="https://github.com/fkom13/opencode-pollinations-plugin/raw/main/docs/images/plan_2.png" alt="Plan Build Step 2" width="400">
59
- <br>
60
- <em>Integrated Plan Building Workflow</em>
61
- </p>
47
+ ---
62
48
 
63
- ## Features
49
+ ## 🚀 Quick Start
64
50
 
65
- - **🌍 Free Universe**: Access generic models (`openai`, `mistral`, `gemini`) for **FREE**, unlimited time, no API key required.
66
- - **🚀 Pro Mode**: Connect your Pollinations API Key to access Premium Models (`claude-3-opus`, `gpt-4o`, `deepseek-coder`).
67
- - **🔐 Limited Key Support (v5.6.0)**: Use keys restricted to "Generation Only". The plugin automatically disables Advanced Features (Dashboard/Quota) but allows full generation in Manual Mode.
68
- - **🛡️ Safety Net V5**: never get blocked.
69
- - **Transparent Fallback**: If your Pro quota runs out mid-chat, the plugin automatically switches to a free model instantly. No errors, just a seamless experience.
70
- - **Smart Mode Switching**: Prevents Limited Keys from entering "Pro" mode to avoid confusing errors.
71
- - **📊 Real-time Dashboard**: Track your **Pollen** usage, Tier Status, and Wallet Balance inside OpenCode.
72
- - **🔇 Stealth Mode (v5.4.7)**: Status notifications are now strictly limited to Pollinations Enter (Paid) sessions. No more cluttered notifications when using other providers like Nvidia or Google AI.
51
+ ### 1. Install Plugin
52
+ ```bash
53
+ npm install -g opencode-pollinations-plugin
54
+ npx opencode-pollinations-plugin
55
+ ```
73
56
 
74
- ## 🐝 Understanding Pollen & Tiers
57
+ ### 2. Connect Your Account
58
+ ```
59
+ /connect
60
+ ```
61
+ Select **pollinations** → Enter your API key from [enter.pollinations.ai](https://enter.pollinations.ai)
62
+
63
+ ### 3. Start Using
64
+ Select any `pollinations/*` model in OpenCode and chat!
65
+
66
+ ---
67
+
68
+ ## 👁️ Vision Support
75
69
 
76
- **Pollen** is our unified credit system. $1 ≈ 1 Pollen.
77
- You spend it to verify API calls on premium models.
78
-
79
- ### Tiers (Free Daily Grants during Beta)
80
-
81
- | Tier | Grant | Requirement |
82
- | :--- | :--- | :--- |
83
- | **🦠 Spore** | **1 Pollen/day** | Just Sign Up! |
84
- | **🌱 Seed** | **3 Pollen/day** | Active GitHub Developer (8+ points) |
85
- | **🌸 Flower** | **10 Pollen/day** | **Publish an App** (Like this Plugin!) |
86
- | **🍯 Nectar** | **20 Pollen/day** | Major Contributors (Coming Soon) |
87
-
88
- > 🎁 **Beta Bonus**: Buy one Pollen pack, get one free!
89
-
90
- ### 🐧 Platform Support & Dynamic Ports (v5.4.6+)
91
- This plugin is **true Cross-Platform** (Windows, macOS, Linux).
92
- - **Dynamic Port Allocation**: No more port conflicts! The plugin automatically finds an available port on startup.
93
- - **Tools Support**: Using tools with Gemini (Free) triggers an **Automatic Intelligent Fallback** to OpenAI to ensure your workflow never breaks.
94
-
95
- > **Note**: Legacy static port (10001) logic has been replaced with system-assigned ports (0). This eliminates "Address in use" errors and effectively removes the need for Linux-specific `fuser` commands, making the plugin fully **Cross-Platform**.
96
-
97
- This plugin is part of the **OpenCode Ecosystem**.
98
-
99
- ### Option 1: NPM (Instant Setup) (Recommended)
100
- This method automatically configures OpenCode to load the plugin.
101
-
102
- 1. Install global:
103
- ```bash
104
- npm install -g opencode-pollinations-plugin
105
- ```
106
- 2. Run the Auto-Setup (Magic):
107
- ```bash
108
- npx opencode-pollinations-plugin
109
- ```
110
- *This detects your OpenCode config and injects the plugin path automatically.*
111
-
112
- ### Option 2: Manual Configuration
113
- 1. Install globally as above.
114
- 2. Edit `~/.config/opencode/opencode.json`:
115
- ```json
116
- {
117
- "plugin": [
118
- "opencode-pollinations-plugin"
119
- ]
120
- }
121
- ```
122
- *Note: If OpenCode fails to find it, use the absolute path to the global install.*
123
-
124
- ## 🚀 Publication (The "Registry")
125
- OpenCode uses NPM as its registry. To publish:
126
-
127
- 1. **Publish to NPM**:
128
- ```bash
129
- npm login
130
- npm publish
131
- ```
132
- 2. **Join Ecosystem**: Submit a Pull Request to [OpenCode Ecosystem](https://github.com/opencode-ai/ecosystem) to list your plugin officially.
133
- *Once accepted, users can find it via documentation or future registry commands.*
134
-
135
- ## 🚀 Getting Started
136
-
137
- ### 1. The Basics (Free Mode)
138
- Just type in the chat. You are in **Manual Mode** by default.
139
- - Model: `openai` (GPT-4o Mini equivalent)
140
- - Model: `mistral` (Mistral Nemo)
141
-
142
- ### 🔑 Configuration (API Key)
143
-
144
- 1. Run the setup command:
145
- ```bash
146
- /connect
147
- ```
148
- 2. Choose "pollinations" and enter your key if you have one (or leave blank for free tier).
149
- 3. **IMPORTANT**: You must **restart OpenCode** for the model list to update with your new tier (e.g. to see Paid models).
150
-
151
- ### 🤖 Models
152
-
153
- ### 🔑 Types de Clés Supportés
154
- - **Clés Standard (`sk-...`)**: Accès complet (Modèles + Dashboard Usage + Quota).
155
- - **Clés Limitées**: Accès Génération uniquement. Le dashboard affichera une alerte de restriction (v5.4.11).
156
- - **Support Legacy**: Les anciennes clés (`sk_...`) sont aussi acceptées.
70
+ The following models support image input:
71
+
72
+ | Model | Vision | Reasoning | Tools |
73
+ |-------|:------:|:---------:|:-----:|
74
+ | `openai` / `openai-large` | ✅ | - | ✅ |
75
+ | `gemini` / `gemini-search` | | - | ✅ |
76
+ | `claude` / `claude-large` | | - | ✅ |
77
+ | `kimi` | | | - |
78
+ | `openai-audio` | | - | |
79
+
80
+ **Usage**: Simply paste an image in the chat or use an image URL. The plugin handles encoding automatically.
81
+
82
+ ---
83
+
84
+ ## 📊 Available Models (25+)
85
+
86
+ ### Text/Chat Models
87
+ - **OpenAI**: `openai`, `openai-fast`, `openai-large`
88
+ - **Gemini**: `gemini`, `gemini-fast`, `gemini-search`, `gemini-large` 💎
89
+ - **Claude**: `claude-fast`, `claude`, `claude-large` 💎
90
+ - **Reasoning**: `deepseek`, `kimi`, `perplexity-reasoning`
91
+ - **Code**: `qwen-coder`, `mistral`
92
+ - **Fast**: `nova-fast`, `grok`
93
+
94
+ ### Paid-Only Models (💎)
95
+ These require purchased credits (not daily grants):
96
+ - `claude-large`, `gemini-large`, `veo`, `seedream-pro`
97
+
98
+ ---
99
+
100
+ ## 🔧 Commands
101
+
102
+ ```
103
+ /pollinations usage # View Pollen balance
104
+ /pollinations usage full # Detailed model breakdown
105
+ /pollinations status # Plugin health check
106
+ ```
107
+
108
+ ---
157
109
 
158
110
  ## 🔗 Links
159
111
 
160
- - **Pollinations Website**: [pollinations.ai](https://pollinations.ai)
161
- - **Discord Community**: [Join us!](https://discord.gg/pollinations-ai-885844321461485618)
162
- - **OpenCode Ecosystem**: [opencode.ai](https://opencode.ai/docs/ecosystem#plugins)
112
+ - **Get API Key**: [enter.pollinations.ai](https://enter.pollinations.ai)
113
+ - **Discord**: [Join Community](https://discord.gg/pollinations-ai-885844321461485618)
114
+ - **GitHub**: [Plugin Repository](https://github.com/fkom13/opencode-pollinations-plugin)
115
+
116
+ ---
163
117
 
164
118
  ## 📜 License
165
119
 
package/dist/index.js CHANGED
@@ -92,80 +92,7 @@ const startProxy = () => {
92
92
  });
93
93
  };
94
94
  // === AUTH HOOK: Native /connect Integration ===
95
- const createAuthHook = () => ({
96
- provider: 'pollinations',
97
- // LOADER: Called by OpenCode when it needs credentials
98
- // This enables HOT RELOAD - called before each request that needs auth
99
- loader: async (auth, provider) => {
100
- log('[AuthHook] loader() called - fetching credentials');
101
- try {
102
- const authData = await auth();
103
- if (authData && 'key' in authData && authData.key) {
104
- log(`[AuthHook] Got key from OpenCode auth: ${authData.key.substring(0, 8)}...`);
105
- // Sync to our config for other parts of the plugin
106
- saveConfig({ apiKey: authData.key });
107
- return { apiKey: authData.key };
108
- }
109
- }
110
- catch (e) {
111
- log(`[AuthHook] loader() error: ${e}`);
112
- }
113
- // Fallback to our own config
114
- const config = loadConfig();
115
- if (config.apiKey) {
116
- log(`[AuthHook] Using key from plugin config: ${config.apiKey.substring(0, 8)}...`);
117
- return { apiKey: config.apiKey };
118
- }
119
- log('[AuthHook] No API key available');
120
- return {};
121
- },
122
- // METHODS: Define how user can authenticate
123
- methods: [{
124
- type: 'api',
125
- label: 'API Key',
126
- prompts: [{
127
- type: 'text',
128
- key: 'apiKey',
129
- message: 'Enter your Pollinations API Key',
130
- placeholder: 'sk_...',
131
- validate: (value) => {
132
- if (!value || value.length < 10) {
133
- return 'API key must be at least 10 characters';
134
- }
135
- if (!value.startsWith('sk_') && !value.startsWith('sk-')) {
136
- return 'API key should start with sk_ or sk-';
137
- }
138
- return undefined; // Valid
139
- }
140
- }],
141
- authorize: async (inputs) => {
142
- log(`[AuthHook] authorize() called with key: ${inputs?.apiKey?.substring(0, 8)}...`);
143
- if (!inputs?.apiKey) {
144
- return { type: 'failed' };
145
- }
146
- // Validate key by testing API
147
- try {
148
- const response = await fetch('https://gen.pollinations.ai/text/models', {
149
- headers: { 'Authorization': `Bearer ${inputs.apiKey}` }
150
- });
151
- if (response.ok) {
152
- log('[AuthHook] Key validated successfully');
153
- // Save to our config for immediate use
154
- saveConfig({ apiKey: inputs.apiKey });
155
- return { type: 'success', key: inputs.apiKey };
156
- }
157
- else {
158
- log(`[AuthHook] Key validation failed: ${response.status}`);
159
- return { type: 'failed' };
160
- }
161
- }
162
- catch (e) {
163
- log(`[AuthHook] Key validation error: ${e}`);
164
- return { type: 'failed' };
165
- }
166
- }
167
- }]
168
- });
95
+ // Auth Hook moved inside plugin to access context
169
96
  // === PLUGIN EXPORT ===
170
97
  export const PollinationsPlugin = async (ctx) => {
171
98
  log(`Plugin Initializing v${require('../package.json').version}...`);
@@ -232,20 +159,61 @@ export const PollinationsPlugin = async (ctx) => {
232
159
  }
233
160
  };
234
161
  return {
235
- // AUTH HOOK: Native /connect integration
236
- auth: createAuthHook(),
237
- // EVENT HOOK: Listen ONLY for explicit /connect command
238
- // We removed installation.updated/server.connected because they caused infinite loops
239
- event: async ({ event }) => {
240
- if (event.type === 'tui.command.execute') {
241
- const cmd = event.command || event.data?.command;
242
- if (cmd === 'connect' || cmd === '/connect') {
243
- log('[Event] /connect command detected - will refresh after auth hook completes');
244
- // Small delay to let auth hook complete
245
- setTimeout(() => refreshProviderConfig(), 2000);
162
+ // AUTH HOOK: Native /connect integration (INLINED)
163
+ auth: {
164
+ provider: 'pollinations',
165
+ loader: async (auth, provider) => {
166
+ log('[AuthHook] loader() called');
167
+ try {
168
+ const authData = await auth();
169
+ if (authData && 'key' in authData) {
170
+ const k = authData.key;
171
+ saveConfig({ apiKey: k });
172
+ return { apiKey: k };
173
+ }
246
174
  }
247
- }
175
+ catch (e) {
176
+ log(`[AuthHook] loader error: ${e}`);
177
+ }
178
+ const config = loadConfig();
179
+ if (config.apiKey)
180
+ return { apiKey: config.apiKey };
181
+ return {};
182
+ },
183
+ methods: [{
184
+ type: 'api',
185
+ label: 'Pollinations API Key',
186
+ prompts: [{
187
+ type: 'text',
188
+ key: 'apiKey',
189
+ message: 'Enter Pollinations API Key (starts with sk_)',
190
+ validate: (v) => (!v || v.length < 10) ? 'Invalid key' : undefined
191
+ }],
192
+ authorize: async (inputs) => {
193
+ log(`[AuthHook] authorize() called`);
194
+ if (!inputs?.apiKey)
195
+ return { type: 'failed' };
196
+ try {
197
+ const r = await fetch('https://gen.pollinations.ai/text/models', {
198
+ headers: { 'Authorization': `Bearer ${inputs.apiKey}` }
199
+ });
200
+ if (r.ok) {
201
+ log('[AuthHook] Success. Saving & Refreshing Config...');
202
+ saveConfig({ apiKey: inputs.apiKey });
203
+ // CRITICAL: Refresh config IMMEDIATELY after successful auth
204
+ await refreshProviderConfig();
205
+ return { type: 'success', key: inputs.apiKey };
206
+ }
207
+ }
208
+ catch (e) {
209
+ log(`[AuthHook] Auth error: ${e}`);
210
+ }
211
+ return { type: 'failed' };
212
+ }
213
+ }]
248
214
  },
215
+ // Event hook removed (logic moved to authorize)
216
+ event: async ({ event }) => { },
249
217
  async config(config) {
250
218
  log("[Hook] config() called");
251
219
  // Generate models based on current auth state
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-pollinations-plugin",
3
3
  "displayName": "Pollinations AI (V5.6)",
4
- "version": "6.0.0-beta.24",
4
+ "version": "6.0.0",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {