Fix : noAuth support for providers and adjusted MITM restart settings.
This commit is contained in:
@@ -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
|
||||
},
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ export class BaseExecutor {
|
||||
constructor(provider, config) {
|
||||
this.provider = provider;
|
||||
this.config = config;
|
||||
this.noAuth = config?.noAuth || false;
|
||||
}
|
||||
|
||||
getProvider() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user