fix(qoder): report usage to all clients and stop inlining large attachments

- Coalesce Qoder's empty finish-in-delta frame with the later choices:[] usage
  frame so OpenAI and Claude clients receive prompt_tokens, completion_tokens
  and cache-hit tokens (the dashboard already saw them)
- Upload inlined images through /api/v2/image/upload like qodercli, and stub
  oversized non-image files instead of stuffing 30MB+ data URIs into
  agent_chat_generation
- Emit response.completed -> response.usage for chat-native upstreams so
  /v1/responses clients (Codex CLI, sub2api) no longer log 0/0/0
- Keep Claude message_delta.usage working when usage arrives without choices[0]
- Escalate to the smallest advertised Qoder context tier (200K/400K/1M) when
  the estimated prompt no longer fits max_input_tokens
- Pass apiKey for PAT connections and list hidden enable:false catalog keys
  from /v1/models
This commit is contained in:
LLL
2026-09-10 22:06:49 +07:00
committed by decolua
parent 832a34659e
commit 1f10f9e5c4
19 changed files with 1615 additions and 121 deletions

View File

@@ -9,7 +9,7 @@ import { getProviderConnections, getCombos, getCustomModels, getModelAliases } f
import { getDisabledModels } from "@/lib/disabledModelsDb";
import { resolveKiroModels } from "open-sse/services/kiroModels.js";
import { resolveKimchiModels } from "open-sse/services/kimchiModels.js";
import { resolveQoderModels } from "open-sse/services/qoderModels.js";
import { resolveQoderModels, routableQoderModels } from "open-sse/services/qoderModels.js";
import { resolveCopilotModels } from "open-sse/services/copilotModels.js";
import { resolveClinepassModels } from "open-sse/services/clinepassModels.js";
import { resolveGrokCliModels } from "open-sse/services/grokCliModels.js";
@@ -34,15 +34,18 @@ const LIVE_MODEL_RESOLVERS = {
qoder: async (conn) => {
const result = await resolveQoderModels({
accessToken: conn.accessToken,
// PAT (pt-...) connections keep the token in apiKey; without it the live
// catalog silently fails and /v1/models falls back to the static list.
apiKey: conn.apiKey,
refreshToken: conn.refreshToken,
email: conn.email,
displayName: conn.displayName,
providerSpecificData: conn.providerSpecificData || {}
});
if (!result?.models?.length) return null;
return {
models: result.models.map((m) => ({ id: m.id, name: m.name })),
};
// Visible + hidden (enable:false) catalog keys — chat routes all of them.
const models = routableQoderModels(result);
if (!models.length) return null;
return { models: models.map((m) => ({ id: m.id, name: m.name })) };
},
kimchi: async (conn) => {
const result = await resolveKimchiModels({