feat(desktop): add promotion marquee and proxy fix

This commit is contained in:
leokun
2026-09-04 23:07:41 +08:00
parent 900364229e
commit 8fbbcd5ae9
20 changed files with 145 additions and 154 deletions
@@ -2,7 +2,7 @@
"apiVersion": 1,
"id": "dev.cursorbyok.plugins.antigravity-auth",
"name": "Antigravity",
"version": "0.3.1",
"version": "0.1.7",
"author": "@masudranaxpert",
"minAppVersion": "0.1.0",
"icon": "assets/antigravity.svg",
@@ -0,0 +1,43 @@
import type { PluginContext } from "cursor-byok:plugin";
import { parseCredentialFiles } from "./resources.ts";
function assert(condition: unknown, message: string): asserts condition {
if (!condition) throw new Error(message);
}
function context(requests: string[]): PluginContext["network"] {
return {
fetch: async (url, init = {}) => {
requests.push(`${url}:${init.body ?? ""}`);
return {
status: 200,
headers: {},
body: JSON.stringify({
access_token: "access-token",
refresh_token: "refresh-token",
expires_in: 3600,
}),
};
},
stream: () => Promise.reject(new Error("stream is not expected")),
};
}
Deno.test("imports an array of email and refresh_token credentials", async () => {
const requests: string[] = [];
const result = await parseCredentialFiles([
{
name: "antigravity.json",
content: JSON.stringify([
{ email: "teocougar@gmail.com", refresh_token: "refresh-token" },
]),
},
], context(requests));
assert(result.warnings.length === 0, "the credential file should not produce warnings");
assert(result.credentials.length === 1, "one credential should be imported");
assert(result.credentials[0].displayName === "teocougar@gmail.com", "email should be used as display name");
assert(result.credentials[0].accessToken === "access-token", "refresh token should be exchanged for an access token");
assert(result.credentials[0].refreshToken === "refresh-token", "refresh token should be preserved");
assert(requests.length === 1, "the refresh token should be exchanged once");
});
@@ -2,7 +2,7 @@
"apiVersion": 1,
"id": "dev.cursorbyok.examples.codex-auth",
"name": "Codex",
"version": "0.1.0",
"version": "0.1.7",
"author": "@leookun",
"minAppVersion": "0.1.0",
"icon": "assets/codex.svg",
@@ -2,7 +2,7 @@
"apiVersion": 1,
"id": "dev.cursorbyok.examples.grok-auth",
"name": "Grok",
"version": "0.1.0",
"version": "0.1.7",
"author": "@leookun",
"minAppVersion": "0.1.0",
"icon": "assets/grok.svg",
+1 -1
View File
@@ -33,7 +33,7 @@ pub(super) const OS_HEADER: &str = "X-Cursor-Assistant-OS";
pub(super) const APP_VERSION_HEADER: &str = "X-Cursor-Assistant-Version";
pub(super) const DISABLED_AD_IDS_HEADER: &str = "disable-ad-ids";
pub(super) const LANGUAGE_HEADER: &str = "accept-language";
const ADS_IMAGE_ROUTE: &str = "/__byok-api__/api/ads/images";
const ADS_IMAGE_ROUTE: &str = "/__byok-api__/api/promotions/images";
const MAX_AD_IMAGE_BYTES: usize = 10 * 1024 * 1024;
const IMAGE_EXTENSIONS: &[&str] = &["png", "jpg", "gif", "webp", "avif"];
+6 -3
View File
@@ -111,10 +111,13 @@ fn proxy_error(error: impl std::fmt::Display) -> Response<Body> {
pub fn api_router(service: ControlService) -> Router {
Router::new()
.route("/__byok-api__/api/ads", get(ads::get))
.route("/__byok-api__/api/ads/images/{file_name}", get(ads::image))
.route("/__byok-api__/api/promotions", get(ads::get))
.route(
"/__byok-api__/api/ads/{ad_id}/dismissals",
"/__byok-api__/api/promotions/images/{file_name}",
get(ads::image),
)
.route(
"/__byok-api__/api/promotions/{ad_id}/dismissals",
post(ads::dismiss),
)
.route(
+2
View File
@@ -5,6 +5,7 @@ use serde_json::Value;
use crate::{Error, Result};
const NO_PROXY_KEY: &str = "http.noProxy";
const KEYS: [&str; 5] = [
"http.proxy",
"http.proxyKerberosServicePrincipal",
@@ -60,6 +61,7 @@ fn write(settings: &BTreeMap<String, Value>) -> Result<()> {
pub fn write_proxy_settings(proxy_url: &str) -> Result<()> {
let mut settings = read()?;
settings.remove(NO_PROXY_KEY);
settings.insert(KEYS[0].into(), Value::String(proxy_url.into()));
settings.insert(KEYS[1].into(), Value::String(proxy_url.into()));
settings.insert(KEYS[2].into(), Value::String("on".into()));