32 Commits

2 changed files with 21 additions and 21 deletions

View File

@@ -366,9 +366,9 @@ PROVIDER_PRESETS = {
], ],
}, },
"Codebuff (Free DeepSeek/Kimi)": { "Codebuff (Free DeepSeek/Kimi)": {
"backend_type": "freebuff", "backend_type": "codebuff",
"base_url": "https://freebuff.com", "base_url": "https://codebuff.com",
"oauth_provider": "freebuff", "oauth_provider": "codebuff",
"models": [ "models": [
"deepseek/deepseek-v4-pro", "deepseek/deepseek-v4-flash", "deepseek/deepseek-v4-pro", "deepseek/deepseek-v4-flash",
"moonshotai/kimi-k2.6", "minimax/minimax-m2.7", "moonshotai/kimi-k2.6", "minimax/minimax-m2.7",
@@ -386,7 +386,7 @@ def label_for_backend(backend_type):
"openai-compat": "OpenAI-compatible", "openai-compat": "OpenAI-compatible",
"anthropic": "Anthropic", "anthropic": "Anthropic",
"command-code": "Command Code", "command-code": "Command Code",
"freebuff": "Codebuff (Free AI)", "codebuff": "Codebuff (Free AI)",
"native": "Native", "native": "Native",
}.get(backend_type, backend_type) }.get(backend_type, backend_type)
@@ -3010,7 +3010,7 @@ class EditEndpointDialog(Gtk.Dialog):
for val, lab in [("openai-compat", "OpenAI-compatible (needs proxy)"), for val, lab in [("openai-compat", "OpenAI-compatible (needs proxy)"),
("anthropic", "Anthropic (needs proxy)"), ("anthropic", "Anthropic (needs proxy)"),
("command-code", "Command Code (needs proxy)"), ("command-code", "Command Code (needs proxy)"),
("freebuff", "Codebuff - Free DeepSeek/Kimi (needs proxy)"), ("codebuff", "Codebuff - Free DeepSeek/Kimi (needs proxy)"),
("gemini-oauth-cli", "Gemini CLI OAuth (needs proxy)"), ("gemini-oauth-cli", "Gemini CLI OAuth (needs proxy)"),
("gemini-oauth-antigravity", "Antigravity OAuth (needs proxy)"), ("gemini-oauth-antigravity", "Antigravity OAuth (needs proxy)"),
("native", "Native OpenAI (no proxy)")]: ("native", "Native OpenAI (no proxy)")]:
@@ -3175,7 +3175,7 @@ class EditEndpointDialog(Gtk.Dialog):
oauth_provider = preset.get("oauth_provider", "") oauth_provider = preset.get("oauth_provider", "")
is_oauth = bool(oauth_provider) is_oauth = bool(oauth_provider)
self._oauth_btn.set_visible(is_oauth) self._oauth_btn.set_visible(is_oauth)
if oauth_provider == "freebuff": if oauth_provider == "codebuff":
self._oauth_btn.set_label("Codebuff Login") self._oauth_btn.set_label("Codebuff Login")
self._entry_key.set_placeholder_text("Auto-filled by codebuff login") self._entry_key.set_placeholder_text("Auto-filled by codebuff login")
elif is_oauth: elif is_oauth:
@@ -3210,8 +3210,8 @@ class EditEndpointDialog(Gtk.Dialog):
preset_name = self._combo_preset.get_active_text() or "Custom" preset_name = self._combo_preset.get_active_text() or "Custom"
preset = PROVIDER_PRESETS.get(preset_name, {}) preset = PROVIDER_PRESETS.get(preset_name, {})
provider = preset.get("oauth_provider", "") provider = preset.get("oauth_provider", "")
if provider == "freebuff": if provider == "codebuff":
self._freebuff_oauth_flow() self._codebuff_oauth_flow()
elif (provider or "").startswith("google"): elif (provider or "").startswith("google"):
self._google_oauth_flow(provider) self._google_oauth_flow(provider)
@@ -3488,7 +3488,7 @@ class EditEndpointDialog(Gtk.Dialog):
dlg.connect("response", lambda d, r: d.destroy()) dlg.connect("response", lambda d, r: d.destroy())
dlg.run() dlg.run()
def _freebuff_oauth_flow(self): def _codebuff_oauth_flow(self):
dlg = Gtk.Dialog(title="Codebuff Login", parent=self, modal=True) dlg = Gtk.Dialog(title="Codebuff Login", parent=self, modal=True)
dlg.add_button("Cancel", Gtk.ResponseType.CANCEL) dlg.add_button("Cancel", Gtk.ResponseType.CANCEL)
dlg.set_default_size(500, 240) dlg.set_default_size(500, 240)

View File

@@ -173,10 +173,10 @@ DEFAULT_MODELS = {
{"id": "claude-sonnet-4-20250514", "object": "model", "created": 1700000000, "owned_by": "anthropic"}, {"id": "claude-sonnet-4-20250514", "object": "model", "created": 1700000000, "owned_by": "anthropic"},
], ],
"codebuff": [ "codebuff": [
{"id": "deepseek/deepseek-v4-pro", "object": "model", "created": 1700000000, "owned_by": "freebuff"}, {"id": "deepseek/deepseek-v4-pro", "object": "model", "created": 1700000000, "owned_by": "codebuff"},
{"id": "deepseek/deepseek-v4-flash", "object": "model", "created": 1700000000, "owned_by": "freebuff"}, {"id": "deepseek/deepseek-v4-flash", "object": "model", "created": 1700000000, "owned_by": "codebuff"},
{"id": "moonshotai/kimi-k2.6", "object": "model", "created": 1700000000, "owned_by": "freebuff"}, {"id": "moonshotai/kimi-k2.6", "object": "model", "created": 1700000000, "owned_by": "codebuff"},
{"id": "minimax/minimax-m2.7", "object": "model", "created": 1700000000, "owned_by": "freebuff"}, {"id": "minimax/minimax-m2.7", "object": "model", "created": 1700000000, "owned_by": "codebuff"},
], ],
"auto": [ "auto": [
{"id": "default-model", "object": "model", "created": 1700000000, "owned_by": "auto"}, {"id": "default-model", "object": "model", "created": 1700000000, "owned_by": "auto"},
@@ -294,7 +294,7 @@ _conn_pool = {}
_STREAM_IDLE_TIMEOUT = 300 _STREAM_IDLE_TIMEOUT = 300
_CODEBUFF_AUTH_URL = "https://freebuff.com" _CODEBUFF_AUTH_URL = "https://codebuff.com"
_CODEBUFF_API_URL = "https://www.codebuff.com" _CODEBUFF_API_URL = "https://www.codebuff.com"
_CODEBUFF_AGENT_MAP = { _CODEBUFF_AGENT_MAP = {
"deepseek/deepseek-v4-pro": "base2-free-deepseek", "deepseek/deepseek-v4-pro": "base2-free-deepseek",
@@ -336,7 +336,7 @@ def _codebuff_get_session(token, model):
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": f"Bearer {token}", "Authorization": f"Bearer {token}",
"User-Agent": "codex-launcher/3.9.7", "User-Agent": "codex-launcher/3.9.7",
"x-freebuff-model": model, "x-codebuff-model": model,
}) })
try: try:
resp = urllib.request.urlopen(req, timeout=15) resp = urllib.request.urlopen(req, timeout=15)
@@ -5283,7 +5283,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
"cost_mode": "free", "cost_mode": "free",
} }
if instance_id: if instance_id:
metadata["freebuff_instance_id"] = instance_id metadata["codebuff_instance_id"] = instance_id
chat_body = { chat_body = {
"model": model, "model": model,
@@ -5306,10 +5306,10 @@ class Handler(http.server.BaseHTTPRequestHandler):
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": f"Bearer {token}", "Authorization": f"Bearer {token}",
"User-Agent": "codex-launcher/3.9.7", "User-Agent": "codex-launcher/3.9.7",
"x-freebuff-model": model, "x-codebuff-model": model,
} }
if instance_id: if instance_id:
headers["x-freebuff-instance-id"] = instance_id headers["x-codebuff-instance-id"] = instance_id
print(f"[{self._session_id}] [codebuff] POST {target} model={model} stream={stream} run={run_id} acct={acct_id}", file=sys.stderr) print(f"[{self._session_id}] [codebuff] POST {target} model={model} stream={stream} run={run_id} acct={acct_id}", file=sys.stderr)
chat_body_b = json.dumps(chat_body).encode() chat_body_b = json.dumps(chat_body).encode()
@@ -5458,7 +5458,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
_codebuff_hard_disable_reasoning(messages) _codebuff_hard_disable_reasoning(messages)
metadata = {"run_id": run_id, "cost_mode": "free"} metadata = {"run_id": run_id, "cost_mode": "free"}
if instance_id: if instance_id:
metadata["freebuff_instance_id"] = instance_id metadata["codebuff_instance_id"] = instance_id
chat_body = { chat_body = {
"model": model, "messages": messages, "stream": stream, "model": model, "messages": messages, "stream": stream,
"max_tokens": max(body.get("max_output_tokens", 0), 64000), "max_tokens": max(body.get("max_output_tokens", 0), 64000),
@@ -5474,9 +5474,9 @@ class Handler(http.server.BaseHTTPRequestHandler):
if body.get("tool_choice"): if body.get("tool_choice"):
chat_body["tool_choice"] = body["tool_choice"] chat_body["tool_choice"] = body["tool_choice"]
target = f"{_CODEBUFF_API_URL}/api/v1/chat/completions" target = f"{_CODEBUFF_API_URL}/api/v1/chat/completions"
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {token}", "User-Agent": "codex-launcher/3.9.7", "x-freebuff-model": model} headers = {"Content-Type": "application/json", "Authorization": f"Bearer {token}", "User-Agent": "codex-launcher/3.9.7", "x-codebuff-model": model}
if instance_id: if instance_id:
headers["x-freebuff-instance-id"] = instance_id headers["x-codebuff-instance-id"] = instance_id
print(f"[codebuff] retry POST {target} model={model} stream={stream} run={run_id} (thinking disabled via DeepSeek native)", file=sys.stderr) print(f"[codebuff] retry POST {target} model={model} stream={stream} run={run_id} (thinking disabled via DeepSeek native)", file=sys.stderr)
try: try:
req = urllib.request.Request(target, data=json.dumps(chat_body).encode(), headers=headers) req = urllib.request.Request(target, data=json.dumps(chat_body).encode(), headers=headers)