kingkont 0.20.24 → 0.20.26

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 (2) hide show
  1. package/lib/providers.js +35 -3
  2. package/package.json +1 -1
package/lib/providers.js CHANGED
@@ -322,10 +322,29 @@ async function startGeneration(args) {
322
322
  const orAvailable = s.useOpenrouter && process.env.OPENROUTER_API_KEY;
323
323
  const orImgModel = kind === 'image' && OPENROUTER_IMAGE_MODELS[orKey];
324
324
  const orVidModel = kind === 'video' && OPENROUTER_VIDEO_MODELS[orKey];
325
+ // OpenRouter video API (/api/v1/videos) принимает только ОДНО `image_input`
326
+ // (см. _startGenerationViaOpenRouterVideo). Если refs > 1 — второй+ silent-drop.
327
+ // Юзер: «дал 2 референса, кажется ни один не заюзан» (на самом деле #1 ушёл,
328
+ // #2 потерян). Авто-роутинг multi-ref video на Chatium/KIE — там
329
+ // reference_image_urls/imageInputs принимают массив. Если ни Chatium ни
330
+ // KIE не настроены — fallback на OR с первым ref + warning (лучше работающая
331
+ // генерация с потерей #2, чем ошибка «нет провайдера»).
332
+ const orVidMultiRef = orVidModel && kind === 'video' && (imageInputs?.length || 0) > 1;
333
+ const _kieOkForOrKey = s.useKie && process.env.KIE_API_KEY && kind === 'video' && KIE_VIDEO_MODELS[orKey];
334
+ const _chatiumOkForOrKey = s.useChatium && s.chatium?.token && s.chatium?.base && kind === 'video' && CHATIUM_VIDEO_MODELS[orKey];
335
+ const orVidShouldFallback = orVidMultiRef && (_kieOkForOrKey || _chatiumOkForOrKey);
336
+ if (orVidMultiRef) {
337
+ if (orVidShouldFallback) {
338
+ const target = _kieOkForOrKey ? 'KIE' : 'Chatium';
339
+ console.warn(`[providers] video "${orKey}" с ${imageInputs.length} refs → OpenRouter /videos принимает 1, роутим через ${target}`);
340
+ } else {
341
+ console.warn(`[providers] video "${orKey}" с ${imageInputs.length} refs, но Chatium/KIE для неё недоступны → используем OpenRouter с первым ref (остальные ${imageInputs.length - 1} проигнорированы)`);
342
+ }
343
+ }
325
344
  if (orAvailable && orImgModel) {
326
345
  return await _startGenerationViaOpenRouter({ key: orKey, prompt, imageInputs, aspectRatio });
327
346
  }
328
- if (orAvailable && orVidModel) {
347
+ if (orAvailable && orVidModel && !orVidShouldFallback) {
329
348
  return await _startGenerationViaOpenRouterVideo({
330
349
  key: orKey, prompt, imageInputs, firstFrame, aspectRatio, resolution, duration,
331
350
  });
@@ -510,10 +529,21 @@ async function _startGenerationViaOpenRouterVideo({ key, prompt, imageInputs, fi
510
529
  if (aspectRatio) body.aspect_ratio = aspectRatio;
511
530
  if (resolution) body.resolution = resolution;
512
531
  // image-to-video: первый кадр или первая ref-картинка.
532
+ // ВАЖНО: OpenRouter `/api/v1/videos` ждёт поле `image_url` (single),
533
+ // а не `image_input`. Раньше слали `image_input` — OpenRouter молча
534
+ // игнорировал и генерил text-to-video (юзер: «1 реф — он его не использовал»).
535
+ // Если у seedance/kling/veo через OR появятся ещё параметры для i2v
536
+ // (last_image_url для end-frame и т.д.) — добавлять по тому же принципу.
513
537
  const startImage = firstFrame || (Array.isArray(imageInputs) && imageInputs[0]) || null;
514
- if (startImage) body.image_input = startImage;
538
+ if (startImage) body.image_url = startImage;
515
539
  logCall('POST', 'OpenRouter', 'https://openrouter.ai/api/v1/videos',
516
- `model=${model} dur=${duration || '-'}s asp=${aspectRatio || '-'} res=${resolution || '-'}`);
540
+ `model=${model} dur=${duration || '-'}s asp=${aspectRatio || '-'} res=${resolution || '-'} i2v=${startImage ? 'yes' : 'no'}`);
541
+ // Полный body-dump в лог — для верификации какие поля принял OpenRouter
542
+ // (особенно `image_url` для i2v — без этого было непонятно почему ref
543
+ // не используется).
544
+ const bodyForLog = { ...body };
545
+ if (bodyForLog.image_url) bodyForLog.image_url = String(bodyForLog.image_url).slice(0, 120) + '…';
546
+ console.log(`[providers] OpenRouter video body: ${JSON.stringify(bodyForLog)}`);
517
547
  const r = await fetch('https://openrouter.ai/api/v1/videos', {
518
548
  method: 'POST',
519
549
  headers: {
@@ -531,6 +561,8 @@ async function _startGenerationViaOpenRouterVideo({ key, prompt, imageInputs, fi
531
561
  throw new Error(`OpenRouter /videos: ${baseMsg}`);
532
562
  }
533
563
  if (!data.id) throw new Error(`OpenRouter не вернул id: ${text.slice(0, 200)}`);
564
+ // Дамп ответа (особенно если OR ругнётся в `metadata` на неизвестные поля).
565
+ console.log(`[providers] OpenRouter video response: id=${data.id} status=${data.status || '?'} ${data.metadata ? 'meta=' + JSON.stringify(data.metadata).slice(0, 200) : ''}`);
534
566
  return { taskId: 'openrouter-vid:' + data.id, provider: 'openrouter' };
535
567
  }
536
568
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kingkont",
3
- "version": "0.20.24",
3
+ "version": "0.20.26",
4
4
  "description": "KingKont \u00b7 Chatium \u2014 \u043d\u043e\u0434-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0441\u0446\u0435\u043d \u0441 AI-\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 (\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438/\u0432\u0438\u0434\u0435\u043e/\u0433\u043e\u043b\u043e\u0441/SFX/\u043c\u0443\u0437\u044b\u043a\u0430/\u0442\u0435\u043a\u0441\u0442)",
5
5
  "main": "main.js",
6
6
  "bin": {