opencode-pollinations-plugin 6.1.0-beta.9 → 6.2.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 (109) hide show
  1. package/README.de.md +130 -0
  2. package/README.es.md +130 -0
  3. package/README.fr.md +130 -0
  4. package/README.it.md +130 -0
  5. package/README.md +87 -73
  6. package/dist/index.js +52 -161
  7. package/dist/locales/de.json +374 -0
  8. package/dist/locales/en.json +373 -0
  9. package/dist/locales/es.json +374 -0
  10. package/dist/locales/fr.json +373 -0
  11. package/dist/locales/index.d.ts +1 -0
  12. package/dist/locales/index.js +37 -0
  13. package/dist/locales/it.json +374 -0
  14. package/dist/server/commands.d.ts +6 -0
  15. package/dist/server/commands.js +394 -125
  16. package/dist/server/config.d.ts +34 -23
  17. package/dist/server/config.js +200 -108
  18. package/dist/server/connect-response.d.ts +2 -0
  19. package/dist/server/connect-response.js +59 -0
  20. package/dist/server/generate-config.d.ts +3 -30
  21. package/dist/server/generate-config.js +164 -106
  22. package/dist/server/index.d.ts +2 -1
  23. package/dist/server/index.js +124 -149
  24. package/dist/server/logger.d.ts +8 -0
  25. package/dist/server/logger.js +38 -0
  26. package/dist/server/models/cache.d.ts +35 -0
  27. package/dist/server/models/cache.js +160 -0
  28. package/dist/server/models/fetcher.d.ts +18 -0
  29. package/dist/server/models/fetcher.js +194 -0
  30. package/dist/server/models/index.d.ts +6 -0
  31. package/dist/server/models/index.js +5 -0
  32. package/dist/server/models/manual.d.ts +15 -0
  33. package/dist/server/models/manual.js +92 -0
  34. package/dist/server/models/types.d.ts +55 -0
  35. package/dist/server/models/types.js +7 -0
  36. package/dist/server/models/worker.d.ts +22 -0
  37. package/dist/server/models/worker.js +174 -0
  38. package/dist/server/pollinations-api.d.ts +11 -0
  39. package/dist/server/pollinations-api.js +21 -8
  40. package/dist/server/proxy.js +222 -307
  41. package/dist/server/quota.d.ts +2 -0
  42. package/dist/server/quota.js +89 -86
  43. package/dist/server/scripts/pollinations_pricing.d.ts +8 -0
  44. package/dist/server/scripts/pollinations_pricing.js +246 -0
  45. package/dist/server/scripts/test_cost_endpoints.d.ts +1 -0
  46. package/dist/server/scripts/test_cost_endpoints.js +61 -0
  47. package/dist/server/scripts/test_dynamic_pricing.d.ts +1 -0
  48. package/dist/server/scripts/test_dynamic_pricing.js +39 -0
  49. package/dist/server/scripts/test_freetier_audit.d.ts +11 -0
  50. package/dist/server/scripts/test_freetier_audit.js +215 -0
  51. package/dist/server/scripts/test_parallel_cost.d.ts +1 -0
  52. package/dist/server/scripts/test_parallel_cost.js +104 -0
  53. package/dist/server/toast.d.ts +7 -1
  54. package/dist/server/toast.js +43 -10
  55. package/dist/tools/design/gen_diagram.d.ts +2 -0
  56. package/dist/tools/design/gen_diagram.js +94 -0
  57. package/dist/tools/design/gen_palette.d.ts +2 -0
  58. package/dist/tools/design/gen_palette.js +182 -0
  59. package/dist/tools/design/gen_qrcode.d.ts +2 -0
  60. package/dist/tools/design/gen_qrcode.js +50 -0
  61. package/dist/tools/ffmpeg.d.ts +24 -0
  62. package/dist/tools/ffmpeg.js +54 -0
  63. package/dist/tools/index.d.ts +25 -0
  64. package/dist/tools/index.js +86 -0
  65. package/dist/tools/pollinations/beta_discovery.d.ts +9 -0
  66. package/dist/tools/pollinations/beta_discovery.js +201 -0
  67. package/dist/tools/pollinations/cost-guard.d.ts +38 -0
  68. package/dist/tools/pollinations/cost-guard.js +136 -0
  69. package/dist/tools/pollinations/deepsearch.d.ts +7 -0
  70. package/dist/tools/pollinations/deepsearch.js +80 -0
  71. package/dist/tools/pollinations/gen_audio.d.ts +18 -0
  72. package/dist/tools/pollinations/gen_audio.js +220 -0
  73. package/dist/tools/pollinations/gen_image.d.ts +11 -0
  74. package/dist/tools/pollinations/gen_image.js +211 -0
  75. package/dist/tools/pollinations/gen_music.d.ts +14 -0
  76. package/dist/tools/pollinations/gen_music.js +157 -0
  77. package/dist/tools/pollinations/gen_video.d.ts +16 -0
  78. package/dist/tools/pollinations/gen_video.js +249 -0
  79. package/dist/tools/pollinations/polli_config.d.ts +2 -0
  80. package/dist/tools/pollinations/polli_config.js +95 -0
  81. package/dist/tools/pollinations/polli_gen_confirm.d.ts +2 -0
  82. package/dist/tools/pollinations/polli_gen_confirm.js +48 -0
  83. package/dist/tools/pollinations/polli_status.d.ts +2 -0
  84. package/dist/tools/pollinations/polli_status.js +31 -0
  85. package/dist/tools/pollinations/polli_web_search.d.ts +15 -0
  86. package/dist/tools/pollinations/polli_web_search.js +126 -0
  87. package/dist/tools/pollinations/search_crawl_scrape.d.ts +7 -0
  88. package/dist/tools/pollinations/search_crawl_scrape.js +85 -0
  89. package/dist/tools/pollinations/shared.d.ts +181 -0
  90. package/dist/tools/pollinations/shared.js +758 -0
  91. package/dist/tools/pollinations/test_estimators.d.ts +1 -0
  92. package/dist/tools/pollinations/test_estimators.js +22 -0
  93. package/dist/tools/pollinations/transcribe_audio.d.ts +13 -0
  94. package/dist/tools/pollinations/transcribe_audio.js +171 -0
  95. package/dist/tools/power/extract_audio.d.ts +2 -0
  96. package/dist/tools/power/extract_audio.js +179 -0
  97. package/dist/tools/power/extract_frames.d.ts +2 -0
  98. package/dist/tools/power/extract_frames.js +237 -0
  99. package/dist/tools/power/file_to_url.d.ts +2 -0
  100. package/dist/tools/power/file_to_url.js +217 -0
  101. package/dist/tools/power/remove_background.d.ts +2 -0
  102. package/dist/tools/power/remove_background.js +404 -0
  103. package/dist/tools/power/rmbg_keys.d.ts +2 -0
  104. package/dist/tools/power/rmbg_keys.js +79 -0
  105. package/dist/tools/shared.d.ts +30 -0
  106. package/dist/tools/shared.js +80 -0
  107. package/package.json +10 -4
  108. package/dist/server/models-seed.d.ts +0 -18
  109. package/dist/server/models-seed.js +0 -55
@@ -0,0 +1,79 @@
1
+ import { tool } from '@opencode-ai/plugin/tool';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ // ─── Shared Logic (Duplicated from rmbg to avoid circular deps if not using shared.ts for this) ──
5
+ import { CONFIG_DIR } from '../../server/config.js';
6
+ const KEYS_FILE = path.join(CONFIG_DIR, 'backgroundcut_keys.json');
7
+ function loadKeys() {
8
+ try {
9
+ if (fs.existsSync(KEYS_FILE)) {
10
+ return JSON.parse(fs.readFileSync(KEYS_FILE, 'utf-8'));
11
+ }
12
+ }
13
+ catch { }
14
+ return { keys: [], currentIndex: 0 };
15
+ }
16
+ function saveKeys(store) {
17
+ try {
18
+ const dir = path.dirname(KEYS_FILE);
19
+ if (!fs.existsSync(dir))
20
+ fs.mkdirSync(dir, { recursive: true });
21
+ fs.writeFileSync(KEYS_FILE, JSON.stringify(store, null, 2));
22
+ }
23
+ catch { }
24
+ }
25
+ // ─── Tool Definition ────────────────────────────────────────────────────────
26
+ export const rmbgKeysTool = tool({
27
+ description: `Manage BackgroundCut API keys for the remove_background tool.
28
+ Allows adding, listing, removing, and clearing keys.
29
+ Keys are stored locally in ~/.pollinations/backgroundcut_keys.json`,
30
+ args: {
31
+ action: tool.schema.string().describe('Action to perform: "list", "add", "remove", "clear"'), // Removed .enum()
32
+ key: tool.schema.string().optional().describe('API Key to add or remove (required for add/remove)'),
33
+ },
34
+ async execute(args, context) {
35
+ const action = args.action.toLowerCase();
36
+ let store = loadKeys();
37
+ switch (action) {
38
+ case 'list':
39
+ if (store.keys.length === 0) {
40
+ return `🔑 No keys stored. Using free provider (cut).`;
41
+ }
42
+ const maskedKeys = store.keys.map((k, i) => {
43
+ const active = i === store.currentIndex ? ' (active)' : '';
44
+ return ` ${i + 1}. ${k.substring(0, 8)}...${k.substring(k.length - 4)}${active}`;
45
+ });
46
+ return `🔑 BackgroundCut Keys: ${store.keys.length} stored\n${maskedKeys.join('\n')}`;
47
+ case 'add':
48
+ if (!args.key)
49
+ return `❌ Error: Missing 'key' argument for add action.`;
50
+ if (store.keys.includes(args.key))
51
+ return `⚠️ Key already exists.`;
52
+ store.keys.push(args.key);
53
+ saveKeys(store);
54
+ context.metadata({
55
+ title: '🔑 Key Added',
56
+ metadata: { type: 'success', message: 'BackgroundCut key stored successfully' }
57
+ });
58
+ return `✅ Key added! Total keys: ${store.keys.length}.`;
59
+ case 'remove':
60
+ if (!args.key)
61
+ return `❌ Error: Missing 'key' argument for remove action.`;
62
+ const initialLen = store.keys.length;
63
+ store.keys = store.keys.filter(k => k !== args.key);
64
+ if (store.keys.length === initialLen)
65
+ return `⚠️ Key not found.`;
66
+ // Reset index if out of bounds
67
+ if (store.currentIndex >= store.keys.length)
68
+ store.currentIndex = 0;
69
+ saveKeys(store);
70
+ return `🗑️ Key removed. Remaining: ${store.keys.length}`;
71
+ case 'clear':
72
+ store = { keys: [], currentIndex: 0 };
73
+ saveKeys(store);
74
+ return `🗑️ All keys cleared. Reverting to free provider.`;
75
+ default:
76
+ return `❌ Unknown action: ${action}. Use list, add, remove, clear.`;
77
+ }
78
+ }
79
+ });
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Subdirectories for each tool category
3
+ */
4
+ export declare const TOOL_DIRS: {
5
+ readonly qrcodes: "qrcodes";
6
+ readonly diagrams: "diagrams";
7
+ readonly palettes: "palettes";
8
+ readonly rembg: "rembg";
9
+ readonly frames: "frames";
10
+ readonly audio: "audio";
11
+ readonly uploads: "uploads";
12
+ };
13
+ /**
14
+ * Resolve the output directory — uses customPath if provided,
15
+ * otherwise falls back to ~/Downloads/pollinations/{subdir}
16
+ * Works on all OSes (Linux, macOS, Windows).
17
+ */
18
+ export declare function resolveOutputDir(subdir: string, customPath?: string): string;
19
+ /**
20
+ * Format file size for human-readable output
21
+ */
22
+ export declare function formatFileSize(bytes: number): string;
23
+ /**
24
+ * Sanitize a filename — remove special chars, keep it safe
25
+ */
26
+ export declare function safeName(input: string): string;
27
+ /**
28
+ * Format a timestamp for display (human readable)
29
+ */
30
+ export declare function formatTimestamp(seconds: number): string;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Shared utilities for power tools — file saving, paths, and formatting.
3
+ * All tools use these helpers for consistent behavior.
4
+ */
5
+ import * as fs from 'fs';
6
+ import * as path from 'path';
7
+ import * as os from 'os';
8
+ // ─── Default base directory ──────────────────────────────────────────────────
9
+ const DEFAULT_BASE = path.join(os.homedir(), 'Downloads', 'pollinations');
10
+ /**
11
+ * Subdirectories for each tool category
12
+ */
13
+ export const TOOL_DIRS = {
14
+ qrcodes: 'qrcodes',
15
+ diagrams: 'diagrams',
16
+ palettes: 'palettes',
17
+ rembg: 'rembg',
18
+ frames: 'frames',
19
+ audio: 'audio',
20
+ uploads: 'uploads',
21
+ };
22
+ /**
23
+ * Resolve the output directory — uses customPath if provided,
24
+ * otherwise falls back to ~/Downloads/pollinations/{subdir}
25
+ * Works on all OSes (Linux, macOS, Windows).
26
+ */
27
+ export function resolveOutputDir(subdir, customPath) {
28
+ let dir;
29
+ if (customPath) {
30
+ // If customPath is absolute, use it directly
31
+ // If relative, resolve from cwd
32
+ // Handle tilde ~ manual expansion for cross-platform support
33
+ if (customPath.startsWith('~')) {
34
+ dir = path.join(os.homedir(), customPath.slice(1));
35
+ }
36
+ else {
37
+ dir = path.isAbsolute(customPath)
38
+ ? customPath
39
+ : path.resolve(process.cwd(), customPath);
40
+ }
41
+ }
42
+ else {
43
+ dir = path.join(DEFAULT_BASE, subdir);
44
+ }
45
+ // Ensure directory exists
46
+ if (!fs.existsSync(dir)) {
47
+ fs.mkdirSync(dir, { recursive: true });
48
+ }
49
+ return dir;
50
+ }
51
+ /**
52
+ * Format file size for human-readable output
53
+ */
54
+ export function formatFileSize(bytes) {
55
+ if (bytes < 1024)
56
+ return `${bytes} B`;
57
+ if (bytes < 1024 * 1024)
58
+ return `${(bytes / 1024).toFixed(1)} KB`;
59
+ if (bytes < 1024 * 1024 * 1024)
60
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
61
+ return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
62
+ }
63
+ /**
64
+ * Sanitize a filename — remove special chars, keep it safe
65
+ */
66
+ export function safeName(input) {
67
+ return input.replace(/[^a-zA-Z0-9_.-]/g, '_').replace(/_+/g, '_');
68
+ }
69
+ /**
70
+ * Format a timestamp for display (human readable)
71
+ */
72
+ export function formatTimestamp(seconds) {
73
+ const h = Math.floor(seconds / 3600);
74
+ const m = Math.floor((seconds % 3600) / 60);
75
+ const s = Math.floor(seconds % 60);
76
+ const ms = Math.round((seconds % 1) * 100);
77
+ if (h > 0)
78
+ return `${h}:${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`;
79
+ return `${m}:${String(s).padStart(2, '0')}.${String(ms).padStart(2, '0')}`;
80
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-pollinations-plugin",
3
- "displayName": "Pollinations AI (V5.6)",
4
- "version": "6.1.0-beta.9",
3
+ "displayName": "Pollinations",
4
+ "version": "6.2.0",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {
@@ -41,6 +41,10 @@
41
41
  {
42
42
  "command": "pollinations.usage",
43
43
  "title": "Pollinations: Show Usage"
44
+ },
45
+ {
46
+ "command": "pollinations.addKey",
47
+ "title": "Pollinations: Add BackgroundCut Key"
44
48
  }
45
49
  ]
46
50
  },
@@ -49,10 +53,12 @@
49
53
  ],
50
54
  "dependencies": {
51
55
  "@opencode-ai/plugin": "^1.0.85",
52
- "zod": "^3.22.4"
56
+ "qrcode": "^1.5.4",
57
+ "zod": "^3.25.76"
53
58
  },
54
59
  "devDependencies": {
55
60
  "@types/node": "^20.0.0",
61
+ "@types/qrcode": "^1.5.6",
56
62
  "typescript": "^5.0.0"
57
63
  }
58
- }
64
+ }
@@ -1,18 +0,0 @@
1
- export interface PollinationsModel {
2
- name: string;
3
- description?: string;
4
- type?: string;
5
- tools?: boolean;
6
- reasoning?: boolean;
7
- context?: number;
8
- context_window?: number;
9
- input_modalities?: string[];
10
- output_modalities?: string[];
11
- paid_only?: boolean;
12
- vision?: boolean;
13
- audio?: boolean;
14
- community?: boolean;
15
- censored?: boolean;
16
- [key: string]: any;
17
- }
18
- export declare const FREE_MODELS_SEED: PollinationsModel[];
@@ -1,55 +0,0 @@
1
- export const FREE_MODELS_SEED = [
2
- {
3
- "name": "gemini",
4
- "description": "Gemini 2.5 Flash Lite",
5
- "tier": "anonymous",
6
- "tools": true,
7
- "input_modalities": ["text", "image"],
8
- "output_modalities": ["text"],
9
- "vision": true
10
- },
11
- {
12
- "name": "mistral",
13
- "description": "Mistral Small 3.2 24B",
14
- "tier": "anonymous",
15
- "tools": true,
16
- "input_modalities": ["text"],
17
- "output_modalities": ["text"],
18
- "vision": false
19
- },
20
- {
21
- "name": "openai-fast",
22
- "description": "GPT-OSS 20B Reasoning LLM (OVH)",
23
- "tier": "anonymous",
24
- "tools": true,
25
- "input_modalities": ["text"],
26
- "output_modalities": ["text"],
27
- "vision": false,
28
- "reasoning": true
29
- },
30
- {
31
- "name": "bidara",
32
- "description": "BIDARA (Biomimetic Designer)",
33
- "tier": "anonymous",
34
- "community": true,
35
- "input_modalities": ["text", "image"],
36
- "output_modalities": ["text"],
37
- "vision": true
38
- },
39
- {
40
- "name": "chickytutor",
41
- "description": "ChickyTutor AI Language Tutor",
42
- "tier": "anonymous",
43
- "community": true,
44
- "input_modalities": ["text"],
45
- "output_modalities": ["text"]
46
- },
47
- {
48
- "name": "midijourney",
49
- "description": "MIDIjourney",
50
- "tier": "anonymous",
51
- "community": true,
52
- "input_modalities": ["text"],
53
- "output_modalities": ["text"]
54
- }
55
- ];