opencode-pollinations-plugin 6.1.0-beta.2 → 6.1.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.
Files changed (96) hide show
  1. package/README.md +242 -62
  2. package/dist/index.js +68 -159
  3. package/dist/server/commands.d.ts +6 -0
  4. package/dist/server/commands.js +400 -71
  5. package/dist/server/config.d.ts +32 -23
  6. package/dist/server/config.js +183 -99
  7. package/dist/server/connect-response.d.ts +2 -0
  8. package/dist/server/connect-response.js +141 -0
  9. package/dist/server/generate-config.d.ts +3 -30
  10. package/dist/server/generate-config.js +164 -106
  11. package/dist/server/index.d.ts +2 -1
  12. package/dist/server/index.js +124 -149
  13. package/dist/server/logger.d.ts +8 -0
  14. package/dist/server/logger.js +36 -0
  15. package/dist/server/models/cache.d.ts +35 -0
  16. package/dist/server/models/cache.js +160 -0
  17. package/dist/server/models/fetcher.d.ts +18 -0
  18. package/dist/server/models/fetcher.js +150 -0
  19. package/dist/server/models/index.d.ts +6 -0
  20. package/dist/server/models/index.js +5 -0
  21. package/dist/server/models/manual.d.ts +15 -0
  22. package/dist/server/models/manual.js +92 -0
  23. package/dist/server/models/types.d.ts +55 -0
  24. package/dist/server/models/types.js +7 -0
  25. package/dist/server/models/worker.d.ts +21 -0
  26. package/dist/server/models/worker.js +97 -0
  27. package/dist/server/pollinations-api.d.ts +11 -0
  28. package/dist/server/pollinations-api.js +21 -8
  29. package/dist/server/proxy.js +223 -160
  30. package/dist/server/quota.d.ts +2 -0
  31. package/dist/server/quota.js +89 -86
  32. package/dist/server/scripts/pollinations_pricing.d.ts +8 -0
  33. package/dist/server/scripts/pollinations_pricing.js +246 -0
  34. package/dist/server/scripts/test_cost_endpoints.d.ts +1 -0
  35. package/dist/server/scripts/test_cost_endpoints.js +61 -0
  36. package/dist/server/scripts/test_dynamic_pricing.d.ts +1 -0
  37. package/dist/server/scripts/test_dynamic_pricing.js +39 -0
  38. package/dist/server/scripts/test_freetier_audit.d.ts +11 -0
  39. package/dist/server/scripts/test_freetier_audit.js +215 -0
  40. package/dist/server/scripts/test_parallel_cost.d.ts +1 -0
  41. package/dist/server/scripts/test_parallel_cost.js +104 -0
  42. package/dist/server/toast.d.ts +7 -1
  43. package/dist/server/toast.js +43 -10
  44. package/dist/tools/design/gen_diagram.d.ts +2 -0
  45. package/dist/tools/design/gen_diagram.js +94 -0
  46. package/dist/tools/design/gen_palette.d.ts +2 -0
  47. package/dist/tools/design/gen_palette.js +182 -0
  48. package/dist/tools/design/gen_qrcode.d.ts +2 -0
  49. package/dist/tools/design/gen_qrcode.js +50 -0
  50. package/dist/tools/ffmpeg.d.ts +24 -0
  51. package/dist/tools/ffmpeg.js +54 -0
  52. package/dist/tools/index.d.ts +24 -0
  53. package/dist/tools/index.js +83 -0
  54. package/dist/tools/pollinations/beta_discovery.d.ts +9 -0
  55. package/dist/tools/pollinations/beta_discovery.js +197 -0
  56. package/dist/tools/pollinations/cost-guard.d.ts +38 -0
  57. package/dist/tools/pollinations/cost-guard.js +141 -0
  58. package/dist/tools/pollinations/deepsearch.d.ts +7 -0
  59. package/dist/tools/pollinations/deepsearch.js +80 -0
  60. package/dist/tools/pollinations/gen_audio.d.ts +18 -0
  61. package/dist/tools/pollinations/gen_audio.js +246 -0
  62. package/dist/tools/pollinations/gen_image.d.ts +11 -0
  63. package/dist/tools/pollinations/gen_image.js +225 -0
  64. package/dist/tools/pollinations/gen_music.d.ts +14 -0
  65. package/dist/tools/pollinations/gen_music.js +180 -0
  66. package/dist/tools/pollinations/gen_video.d.ts +16 -0
  67. package/dist/tools/pollinations/gen_video.js +256 -0
  68. package/dist/tools/pollinations/polli_gen_confirm.d.ts +2 -0
  69. package/dist/tools/pollinations/polli_gen_confirm.js +48 -0
  70. package/dist/tools/pollinations/polli_status.d.ts +2 -0
  71. package/dist/tools/pollinations/polli_status.js +31 -0
  72. package/dist/tools/pollinations/polli_web_search.d.ts +15 -0
  73. package/dist/tools/pollinations/polli_web_search.js +164 -0
  74. package/dist/tools/pollinations/search_crawl_scrape.d.ts +7 -0
  75. package/dist/tools/pollinations/search_crawl_scrape.js +85 -0
  76. package/dist/tools/pollinations/shared.d.ts +165 -0
  77. package/dist/tools/pollinations/shared.js +665 -0
  78. package/dist/tools/pollinations/test_estimators.d.ts +1 -0
  79. package/dist/tools/pollinations/test_estimators.js +22 -0
  80. package/dist/tools/pollinations/transcribe_audio.d.ts +13 -0
  81. package/dist/tools/pollinations/transcribe_audio.js +194 -0
  82. package/dist/tools/power/extract_audio.d.ts +2 -0
  83. package/dist/tools/power/extract_audio.js +179 -0
  84. package/dist/tools/power/extract_frames.d.ts +2 -0
  85. package/dist/tools/power/extract_frames.js +237 -0
  86. package/dist/tools/power/file_to_url.d.ts +2 -0
  87. package/dist/tools/power/file_to_url.js +217 -0
  88. package/dist/tools/power/remove_background.d.ts +2 -0
  89. package/dist/tools/power/remove_background.js +366 -0
  90. package/dist/tools/power/rmbg_keys.d.ts +2 -0
  91. package/dist/tools/power/rmbg_keys.js +79 -0
  92. package/dist/tools/shared.d.ts +30 -0
  93. package/dist/tools/shared.js +80 -0
  94. package/package.json +10 -4
  95. package/dist/server/models-seed.d.ts +0 -18
  96. package/dist/server/models-seed.js +0 -55
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Shared utilities for Pollinations API tools
3
+ *
4
+ * Updated: 2026-02-18 - Sprint 2: Dynamic ModelRegistry integration
5
+ * Hardcoded model lists replaced by ModelRegistry lookups with static fallback.
6
+ */
7
+ export interface PollinationsConfig {
8
+ apiKey?: string;
9
+ mode?: string;
10
+ }
11
+ export interface ModelInfo {
12
+ name: string;
13
+ pricing: {
14
+ currency: string;
15
+ completionImageTokens?: number;
16
+ completionVideoSeconds?: number;
17
+ completionVideoTokens?: number;
18
+ completionAudioTokens?: number;
19
+ completionAudioSeconds?: number;
20
+ promptAudioSeconds?: number;
21
+ promptTextTokens?: number;
22
+ completionTextTokens?: number;
23
+ };
24
+ paid_only?: boolean;
25
+ input_modalities?: string[];
26
+ output_modalities?: string[];
27
+ description?: string;
28
+ }
29
+ export interface GenerationResult {
30
+ success: boolean;
31
+ url?: string;
32
+ localPath?: string;
33
+ cost: number;
34
+ model: string;
35
+ error?: string;
36
+ }
37
+ export interface CostTracking {
38
+ imageTokens?: number;
39
+ videoSeconds?: number;
40
+ videoTokens?: number;
41
+ costUsd?: number;
42
+ modelUsed?: string;
43
+ requestId?: string;
44
+ }
45
+ export declare function getApiKey(): string | undefined;
46
+ export declare function hasApiKey(): boolean;
47
+ /**
48
+ * FREE Image Models (DEPRECATED - image.pollinations.ai is dead)
49
+ */
50
+ export declare const FREE_IMAGE_MODELS: {};
51
+ /**
52
+ * Dynamic Paid Image Models accessor.
53
+ * Returns data from ModelRegistry if ready, otherwise falls back to static data.
54
+ *
55
+ * BACKWARD COMPATIBLE: Same shape as the old hardcoded PAID_IMAGE_MODELS
56
+ */
57
+ export declare function getPaidImageModels(): Record<string, {
58
+ desc: string;
59
+ cost: string;
60
+ t2i: boolean;
61
+ i2i: boolean;
62
+ params: string[];
63
+ notes?: string;
64
+ }>;
65
+ /**
66
+ * Dynamic Video Models accessor.
67
+ * BACKWARD COMPATIBLE: Same shape as old VIDEO_MODELS
68
+ */
69
+ export declare function getVideoModels(): Record<string, {
70
+ desc: string;
71
+ cost: string;
72
+ t2v: boolean;
73
+ i2v: boolean;
74
+ audio: boolean;
75
+ duration: [number, number];
76
+ aspectRatios: string[];
77
+ costHeader: string;
78
+ genTime: string;
79
+ }>;
80
+ /**
81
+ * Dynamic Audio Models accessor.
82
+ * BACKWARD COMPATIBLE: Same shape as old AUDIO_MODELS
83
+ */
84
+ export declare function getAudioModels(): Record<string, {
85
+ desc: string;
86
+ type: 'tts' | 'stt' | 'both';
87
+ endpoint: string;
88
+ params: string[];
89
+ voices?: string[];
90
+ notes?: string;
91
+ }>;
92
+ /**
93
+ * Music Model accessor (backward compatible)
94
+ */
95
+ export declare function getMusicModel(): Record<string, {
96
+ desc: string;
97
+ endpoint: string;
98
+ params: string[];
99
+ duration: [number, number];
100
+ }>;
101
+ export declare function httpsGet(url: string, headers?: Record<string, string>): Promise<{
102
+ data: Buffer;
103
+ headers: Record<string, string>;
104
+ }>;
105
+ export declare function httpsPost(url: string, body: any, headers?: Record<string, string>): Promise<{
106
+ data: Buffer;
107
+ headers: Record<string, string>;
108
+ }>;
109
+ /**
110
+ * Multipart POST for file uploads (STT)
111
+ */
112
+ export declare function httpsPostMultipart(url: string, fields: Record<string, string | Buffer>, headers?: Record<string, string>): Promise<{
113
+ data: Buffer;
114
+ headers: Record<string, string>;
115
+ }>;
116
+ /**
117
+ * @deprecated Use ModelRegistry.list() directly
118
+ */
119
+ export declare function fetchModels(type: 'image' | 'audio' | 'text'): Promise<ModelInfo[]>;
120
+ /**
121
+ * @deprecated Use ModelRegistry.get() directly
122
+ */
123
+ export declare function getModelInfo(type: 'image' | 'audio' | 'text', name: string): Promise<ModelInfo | undefined>;
124
+ /**
125
+ * Extract cost tracking from response headers
126
+ */
127
+ export declare function extractCostFromHeaders(headers: Record<string, string>): CostTracking;
128
+ /**
129
+ * Fetch current Enter balance (`/account/balance`) for Real Cost calculation.
130
+ */
131
+ export declare function fetchEnterBalance(): Promise<number | null>;
132
+ /**
133
+ * Check if cost estimator is enabled in config
134
+ */
135
+ export declare function isCostEstimatorEnabled(): boolean;
136
+ export declare function per1pollen(cost: number | null): string;
137
+ export declare function estimateImageCost(model: string): number;
138
+ export declare function estimateVideoCost(model: string, duration: number): number;
139
+ export declare function estimateTtsCost(textLength: number): number;
140
+ export declare function estimateMusicCost(duration: number): number;
141
+ export declare function ensureDir(dir: string): void;
142
+ export declare function generateFilename(type: string, model: string, ext: string): string;
143
+ export declare function getDefaultOutputDir(type: string): string;
144
+ export declare function formatCost(cost: number): string;
145
+ export declare function formatFileSize(bytes: number): string;
146
+ /**
147
+ * Check if model supports Image-to-Image
148
+ */
149
+ export declare function supportsI2I(model: string): boolean;
150
+ /**
151
+ * Check if video model supports Image-to-Video
152
+ */
153
+ export declare function supportsI2V(model: string): boolean;
154
+ /**
155
+ * Check if video model requires Image-to-Video (no T2V)
156
+ */
157
+ export declare function requiresI2V(model: string): boolean;
158
+ /**
159
+ * Validate aspect ratio for video model
160
+ */
161
+ export declare function validateAspectRatio(model: string, ratio: string): boolean;
162
+ /**
163
+ * Get valid duration range for video model
164
+ */
165
+ export declare function getDurationRange(model: string): [number, number];