Fix : noAuth support for providers and adjusted MITM restart settings.

This commit is contained in:
decolua
2026-04-14 10:14:50 +07:00
parent 7959fd37ad
commit 6a6e2fcd77
9 changed files with 23 additions and 14 deletions

View File

@@ -335,6 +335,7 @@ export const PROVIDERS = {
opencode: {
baseUrl: "https://opencode.ai",
format: "openai",
headers: { "x-opencode-client": "desktop" }
headers: { "x-opencode-client": "desktop" },
noAuth: true
},
};

View File

@@ -8,6 +8,7 @@ export class BaseExecutor {
constructor(provider, config) {
this.provider = provider;
this.config = config;
this.noAuth = config?.noAuth || false;
}
getProvider() {

View File

@@ -172,8 +172,8 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
return createErrorResult(HTTP_STATUS.BAD_GATEWAY, errMsg);
}
// Handle 401/403 - try token refresh
if (providerResponse.status === HTTP_STATUS.UNAUTHORIZED || providerResponse.status === HTTP_STATUS.FORBIDDEN) {
// Handle 401/403 - try token refresh (skip for noAuth providers)
if (!executor.noAuth && (providerResponse.status === HTTP_STATUS.UNAUTHORIZED || providerResponse.status === HTTP_STATUS.FORBIDDEN)) {
try {
const newCredentials = await refreshWithRetry(() => executor.refreshCredentials(credentials, log), 3, log);
if (newCredentials?.accessToken || newCredentials?.copilotToken) {

View File

@@ -228,12 +228,13 @@ export async function handleEmbeddingsCore({
return createErrorResult(HTTP_STATUS.BAD_GATEWAY, errMsg);
}
// Handle 401/403 — try token refresh
// Handle 401/403 — try token refresh (skip for noAuth providers)
const executor = getExecutor(provider);
if (
providerResponse.status === HTTP_STATUS.UNAUTHORIZED ||
providerResponse.status === HTTP_STATUS.FORBIDDEN
!executor.noAuth &&
(providerResponse.status === HTTP_STATUS.UNAUTHORIZED ||
providerResponse.status === HTTP_STATUS.FORBIDDEN)
) {
const executor = getExecutor(provider);
const newCredentials = await refreshWithRetry(
() => executor.refreshCredentials(credentials, log),
3,