mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 04:20:04 +08:00
* feat: add codebuddy provider * fix: treat codebuddy as login-backed provider * feat: sync codebuddy account models * fix: ignore no-key placeholder for codebuddy * feat: add codebuddy web login * fix: streamline codebuddy settings and latency * fix: support switching codebuddy accounts * fix: preserve codebuddy sessions and tool calls * feat: use CodeBuddy HTTP provider over Agent SDK Chat with CodeBuddy over plain HTTP by reusing the login state that the IDE plugin / CLI stores on disk, instead of bundling the ~130MB Agent SDK. - add codebuddy_http_provider (OpenAI-compatible /chat/completions on <endpoint>/v2) with codebuddy_credentials for local OAuth session reuse - provider_factory picks HTTP transport whenever a login state or API key is available; Agent SDK stays as fallback for CLI agent features - demote codebuddy-agent-sdk from core deps to optional codebuddy extra - default model codebuddy/default -> codebuddy/hy3 - update auth card UX and locales for SDK-less sign-in flow * chore: label codebuddy provider as codebuddy/workbuddy in the dashboard * style: apply pre-commit formatting after upstream merge * chore: capitalise codebuddy provider label as CodeBuddy/WorkBuddy --------- Co-authored-by: Bingxi Zhao (Frank) <13051345080@163.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { apiFetch, apiUrl } from "@/lib/api";
|
|
|
|
export type CodeBuddyAuthStatus = {
|
|
connection: "disconnected" | "authorizing" | "connected" | "error";
|
|
operation_state: "waiting" | "completed" | "cancelled" | "failed" | null;
|
|
authorize_url: string | null;
|
|
user_label: string | null;
|
|
error_code: string | null;
|
|
};
|
|
|
|
const BASE = "/api/v1/settings/providers/codebuddy/auth";
|
|
|
|
async function request(
|
|
path: string,
|
|
method: "GET" | "POST",
|
|
): Promise<CodeBuddyAuthStatus> {
|
|
const response = await apiFetch(apiUrl(`${BASE}${path}`), {
|
|
method,
|
|
skipAuthRedirect: true,
|
|
});
|
|
if (!response.ok) {
|
|
throw new Error(`CodeBuddy auth request failed: HTTP ${response.status}`);
|
|
}
|
|
return (await response.json()) as CodeBuddyAuthStatus;
|
|
}
|
|
|
|
export function getCodeBuddyAuthStatus(): Promise<CodeBuddyAuthStatus> {
|
|
return request("/status", "GET");
|
|
}
|
|
|
|
export function startCodeBuddyLogin(): Promise<CodeBuddyAuthStatus> {
|
|
return request("/start", "POST");
|
|
}
|
|
|
|
export function cancelCodeBuddyLogin(): Promise<CodeBuddyAuthStatus> {
|
|
return request("/cancel", "POST");
|
|
}
|
|
|
|
export function logoutCodeBuddy(): Promise<CodeBuddyAuthStatus> {
|
|
return request("/logout", "POST");
|
|
}
|
|
|
|
export function shouldPollCodeBuddyAuth(status: CodeBuddyAuthStatus): boolean {
|
|
return status.operation_state === "waiting";
|
|
}
|