opencode-pollinations-plugin 6.0.0-beta.19 → 6.0.0-beta.20
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/dist/index.js +44 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -171,15 +171,58 @@ const createAuthHook = () => ({
|
|
|
171
171
|
// === PLUGIN EXPORT ===
|
|
172
172
|
export const PollinationsPlugin = async (ctx) => {
|
|
173
173
|
log(`Plugin Initializing v${require('../package.json').version}...`);
|
|
174
|
-
// START PROXY
|
|
174
|
+
// START PROXY on fixed port
|
|
175
175
|
const port = await startProxy();
|
|
176
176
|
const localBaseUrl = `http://127.0.0.1:${port}/v1`;
|
|
177
177
|
setGlobalClient(ctx.client);
|
|
178
178
|
const toastHooks = createToastHooks(ctx.client);
|
|
179
179
|
const commandHooks = createCommandHooks();
|
|
180
|
+
// Helper: Refresh provider config (for hot-reload after /connect)
|
|
181
|
+
const refreshProviderConfig = async () => {
|
|
182
|
+
try {
|
|
183
|
+
log('[Event] Refreshing provider config after auth update...');
|
|
184
|
+
const modelsArray = await generatePollinationsConfig();
|
|
185
|
+
const modelsObj = {};
|
|
186
|
+
for (const m of modelsArray) {
|
|
187
|
+
modelsObj[m.id] = m;
|
|
188
|
+
}
|
|
189
|
+
const version = require('../package.json').version;
|
|
190
|
+
// Use Server API to PATCH the config at runtime
|
|
191
|
+
await ctx.client.fetch('/config', {
|
|
192
|
+
method: 'PATCH',
|
|
193
|
+
headers: { 'Content-Type': 'application/json' },
|
|
194
|
+
body: JSON.stringify({
|
|
195
|
+
provider: {
|
|
196
|
+
pollinations: {
|
|
197
|
+
id: 'openai',
|
|
198
|
+
name: `Pollinations AI (v${version})`,
|
|
199
|
+
options: {
|
|
200
|
+
baseURL: localBaseUrl,
|
|
201
|
+
apiKey: 'plugin-managed',
|
|
202
|
+
},
|
|
203
|
+
models: modelsObj
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
});
|
|
208
|
+
log(`[Event] Provider config refreshed with ${Object.keys(modelsObj).length} models.`);
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
211
|
+
log(`[Event] Failed to refresh provider config: ${e}`);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
180
214
|
return {
|
|
181
215
|
// AUTH HOOK: Native /connect integration
|
|
182
216
|
auth: createAuthHook(),
|
|
217
|
+
// EVENT HOOK: Listen for auth/installation updates (triggered by /connect)
|
|
218
|
+
event: async ({ event }) => {
|
|
219
|
+
log(`[Event] Received: ${event.type}`);
|
|
220
|
+
// React to installation.updated (fired after /connect completes)
|
|
221
|
+
if (event.type === 'installation.updated') {
|
|
222
|
+
log('[Event] installation.updated detected - triggering hot-reload');
|
|
223
|
+
await refreshProviderConfig();
|
|
224
|
+
}
|
|
225
|
+
},
|
|
183
226
|
async config(config) {
|
|
184
227
|
log("[Hook] config() called");
|
|
185
228
|
// 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.
|
|
4
|
+
"version": "6.0.0-beta.20",
|
|
5
5
|
"description": "Native Pollinations.ai Provider Plugin for OpenCode",
|
|
6
6
|
"publisher": "pollinations",
|
|
7
7
|
"repository": {
|