opencode-pollinations-plugin 6.0.0-beta.20 → 6.0.0-beta.22
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 +22 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,13 +17,12 @@ function log(msg) {
|
|
|
17
17
|
}
|
|
18
18
|
// === PROXY SERVER (Singleton with Fixed Port) ===
|
|
19
19
|
const DEFAULT_PORT = 18888;
|
|
20
|
-
|
|
21
|
-
let existingPort = 0;
|
|
20
|
+
const GLOBAL_SERVER_KEY = '__POLLINATIONS_PROXY_SERVER__';
|
|
22
21
|
const startProxy = () => {
|
|
23
|
-
//
|
|
24
|
-
if (
|
|
25
|
-
log(`[Proxy] Reusing existing server on port ${
|
|
26
|
-
return Promise.resolve(
|
|
22
|
+
// Check if server exists in global scope (survives module reloads)
|
|
23
|
+
if (global[GLOBAL_SERVER_KEY]) {
|
|
24
|
+
log(`[Proxy] Reusing existing global server on port ${DEFAULT_PORT}`);
|
|
25
|
+
return Promise.resolve(DEFAULT_PORT);
|
|
27
26
|
}
|
|
28
27
|
return new Promise((resolve) => {
|
|
29
28
|
const server = http.createServer(async (req, res) => {
|
|
@@ -73,8 +72,7 @@ const startProxy = () => {
|
|
|
73
72
|
server.listen(port, '127.0.0.1', () => {
|
|
74
73
|
// @ts-ignore
|
|
75
74
|
const assignedPort = server.address().port;
|
|
76
|
-
|
|
77
|
-
existingPort = assignedPort;
|
|
75
|
+
global[GLOBAL_SERVER_KEY] = server;
|
|
78
76
|
log(`[Proxy] Started v${require('../package.json').version} on port ${assignedPort}${port === 0 ? ' (dynamic fallback)' : ''}`);
|
|
79
77
|
resolve(assignedPort);
|
|
80
78
|
});
|
|
@@ -214,14 +212,25 @@ export const PollinationsPlugin = async (ctx) => {
|
|
|
214
212
|
return {
|
|
215
213
|
// AUTH HOOK: Native /connect integration
|
|
216
214
|
auth: createAuthHook(),
|
|
217
|
-
// EVENT HOOK: Listen for
|
|
215
|
+
// EVENT HOOK: Listen for changes that might indicate /connect completed
|
|
218
216
|
event: async ({ event }) => {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
log(
|
|
217
|
+
// Log only relevant events (auth-related)
|
|
218
|
+
if (event.type === 'installation.updated' ||
|
|
219
|
+
event.type === 'server.connected') {
|
|
220
|
+
log(`[Event] Relevant event: ${event.type}`);
|
|
223
221
|
await refreshProviderConfig();
|
|
224
222
|
}
|
|
223
|
+
// Also watch for tui.command.execute (when user types /connect)
|
|
224
|
+
// Note: This fires at START of /connect, not at completion
|
|
225
|
+
// The AuthHook handles the actual key update
|
|
226
|
+
if (event.type === 'tui.command.execute') {
|
|
227
|
+
const cmd = event.command || event.data?.command;
|
|
228
|
+
if (cmd === 'connect' || cmd === '/connect') {
|
|
229
|
+
log('[Event] /connect command detected - will refresh after auth hook completes');
|
|
230
|
+
// Small delay to let auth hook complete
|
|
231
|
+
setTimeout(() => refreshProviderConfig(), 2000);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
225
234
|
},
|
|
226
235
|
async config(config) {
|
|
227
236
|
log("[Hook] config() called");
|
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.22",
|
|
5
5
|
"description": "Native Pollinations.ai Provider Plugin for OpenCode",
|
|
6
6
|
"publisher": "pollinations",
|
|
7
7
|
"repository": {
|