opencode-pollinations-plugin 5.8.4-beta.4 → 5.8.4-beta.6

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.
@@ -176,18 +176,6 @@ export async function generatePollinationsConfig(forceApiKey, forceStrict = fals
176
176
  enterList.forEach((m) => {
177
177
  if (m.tools === false)
178
178
  return;
179
- // FIX: ChickyTutor (Bedrock) crashes with tools due to missing toolConfig.
180
- // Force disable tools to match Free behavior and ensure stability.
181
- if ((m.id || m.name).includes('chickytutor')) {
182
- // m.tools = false; // We can't mutate m effectively if we want to filter?
183
- // No, simply map it but strip tools capability in mapModel?
184
- // mapModel reads raw.tools to set capability icon.
185
- // But OpenCode decides to send tools based on ???
186
- // OpenCode reads the 'modalities' or expects 'tools' option?
187
- // Let's just NOT push it here if we filter by tools, but wait, we want CHAT.
188
- // So we allow it, but we hack mapModel to NOT advertise tools?
189
- m.tools = false;
190
- }
191
179
  const mapped = mapModel(m, 'enter/', '[Enter] ');
192
180
  modelsOutput.push(mapped);
193
181
  });
@@ -153,6 +153,11 @@ export async function handleChatCompletion(req, res, bodyRaw) {
153
153
  const config = loadConfig();
154
154
  // DEBUG: Trace Config State for Hot Reload verification
155
155
  log(`[Proxy Request] Config Loaded. Mode: ${config.mode}, HasKey: ${!!config.apiKey}, KeyLength: ${config.apiKey ? config.apiKey.length : 0}`);
156
+ // SPY LOGGING
157
+ try {
158
+ fs.appendFileSync('/tmp/opencode_spy.log', `\n\n=== REQUEST ${new Date().toISOString()} ===\nMODEL: ${body.model}\nBODY:\n${JSON.stringify(body, null, 2)}\n==========================\n`);
159
+ }
160
+ catch (e) { }
156
161
  // 0. COMMAND HANDLING
157
162
  if (body.messages && body.messages.length > 0) {
158
163
  const lastMsg = body.messages[body.messages.length - 1];
@@ -416,6 +421,23 @@ export async function handleChatCompletion(req, res, bodyRaw) {
416
421
  // Restore Tools but REMOVE conflicting ones (Search)
417
422
  // B. GEMINI UNIFIED FIX (Free, Fast, Pro, Enterprise, Legacy)
418
423
  // Handles: "tools" vs "grounding" conflicts, and "infinite loops" via Stop Sequences.
424
+ // GLOBAL BEDROCK FIX (All Models)
425
+ // Check if history has tools but current request misses tools definition.
426
+ // This happens when OpenCode sends the Tool Result (optimisation),
427
+ // but Bedrock requires toolConfig to validate the history.
428
+ const hasToolHistory = proxyBody.messages?.some((m) => m.role === 'tool' || m.tool_calls);
429
+ if (hasToolHistory && (!proxyBody.tools || proxyBody.tools.length === 0)) {
430
+ // Inject Shim Tool to satisfy Bedrock
431
+ proxyBody.tools = [{
432
+ type: 'function',
433
+ function: {
434
+ name: '_bedrock_compatibility_shim',
435
+ description: 'Internal system tool to satisfy Bedrock strict toolConfig requirement. Do not use.',
436
+ parameters: { type: 'object', properties: {} }
437
+ }
438
+ }];
439
+ log(`[Proxy] Bedrock Fix: Injected shim tool for ${actualModel} (History has tools, Request missing tools)`);
440
+ }
419
441
  // B. GEMINI UNIFIED FIX (Free, Fast, Pro, Enterprise, Legacy)
420
442
  // Fixes "Multiple tools" error (Vertex) and "JSON body validation failed" (v5.3.5 regression)
421
443
  // Added ChickyTutor (Claude/Gemini based) to fix "toolConfig must be defined" error.
@@ -424,6 +446,7 @@ export async function handleChatCompletion(req, res, bodyRaw) {
424
446
  if (proxyBody.tools && Array.isArray(proxyBody.tools)) {
425
447
  hasFunctions = proxyBody.tools.some((t) => t.type === 'function' || t.function);
426
448
  }
449
+ // Old Shim logic removed (moved up)
427
450
  if (hasFunctions) {
428
451
  // 1. Strict cleanup of 'google_search' tool
429
452
  proxyBody.tools = proxyBody.tools.filter((t) => {
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": "5.8.4-beta.4",
4
+ "version": "5.8.4-beta.6",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {