LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。
TypeScript
feat: route LLM fetch through Tauri HTTP plugin (bypass browser CORS)
nash_sucb1ebba25bcc
diff --git a/.gitignore b/.gitignoreindex dcc50549..2fd3cd88 100644--- a/.gitignore+++ b/.gitignore@@ -43,3 +43,4 @@ pnpm-debug.log*# Brainstorm assets (not tracked in source control).superpowers/+.claude/diff --git a/package-lock.json b/package-lock.jsonindex b39d0083..5802efd7 100644--- a/package-lock.json+++ b/package-lock.json@@ -18,6 +18,7 @@"@tailwindcss/vite": "^4.2.2","@tauri-apps/api": "^2.10.1","@tauri-apps/plugin-dialog": "^2.7.0",+ "@tauri-apps/plugin-http": "^2.5.8","@tauri-apps/plugin-store": "^2.4.2","class-variance-authority": "^0.7.1","clsx": "^2.1.1",@@ -2886,6 +2887,15 @@"@tauri-apps/api": "^2.10.1"}},+ "node_modules/@tauri-apps/plugin-http": {+ "version": "2.5.8",+ "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-http/-/plugin-http-2.5.8.tgz",+ "integrity": "sha512-oxd7oypzQeu8kAfFCrw534Kq7Cw+NzozcnCY21O4rz3A+veJiIiuSCMIprgGcZOcLAXFP9GmDhKUbhuKWcunRw==",+ "license": "MIT OR Apache-2.0",+ "dependencies": {+ "@tauri-apps/api": "^2.10.1"+ }+ },"node_modules/@tauri-apps/plugin-store": {"version": "2.4.2","resolved": "https://registry.npmjs.org/@tauri-apps/plugin-store/-/plugin-store-2.4.2.tgz",diff --git a/package.json b/package.jsonindex 49cab1b0..fc08c0c4 100644--- a/package.json+++ b/package.json@@ -23,6 +23,7 @@"@tailwindcss/vite": "^4.2.2","@tauri-apps/api": "^2.10.1","@tauri-apps/plugin-dialog": "^2.7.0",+ "@tauri-apps/plugin-http": "^2.5.8","@tauri-apps/plugin-store": "^2.4.2","class-variance-authority": "^0.7.1","clsx": "^2.1.1",diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex efa1543b..70c7542b 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -1077,10 +1077,39 @@ version = "0.18.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747"dependencies = [+ "percent-encoding","time","version_check",]+[[package]]+name = "cookie_store"+version = "0.22.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "15b2c103cf610ec6cae3da84a766285b42fd16aad564758459e6ecf128c75206"+dependencies = [+ "cookie",+ "document-features",+ "idna",+ "log",+ "publicsuffix",+ "serde",+ "serde_derive",+ "serde_json",+ "time",+ "url",+]++[[package]]+name = "core-foundation"+version = "0.9.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"+dependencies = [+ "core-foundation-sys",+ "libc",+]+[[package]]name = "core-foundation"version = "0.10.1"@@ -1104,7 +1133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "064badf302c3194842cf2c5d61f56cc88e54a759313879cdf03abdd27d0c3b97"dependencies = ["bitflags 2.11.0",- "core-foundation",+ "core-foundation 0.10.1","core-graphics-types","foreign-types","libc",@@ -1117,7 +1146,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb"dependencies = ["bitflags 2.11.0",- "core-foundation",+ "core-foundation 0.10.1","libc",]@@ -1351,6 +1380,12 @@ dependencies = ["parking_lot_core",]+[[package]]+name = "data-url"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376"+[[package]]name = "datafusion"version = "52.5.0"@@ -2120,6 +2155,15 @@ dependencies = ["syn 2.0.117",]+[[package]]+name = "document-features"+version = "0.2.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61"+dependencies = [+ "litrs",+]+[[package]]name = "docx-rs"version = "0.4.20"@@ -3159,6 +3203,7 @@ dependencies = ["tokio","tokio-rustls","tower-service",+ "webpki-roots",][[package]]@@ -3179,9 +3224,11 @@ dependencies = ["percent-encoding","pin-project-lite","socket2",+ "system-configuration","tokio","tower-service","tracing",+ "windows-registry",][[package]]@@ -4359,6 +4406,12 @@ version = "0.8.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0"+[[package]]+name = "litrs"+version = "1.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092"+[[package]]name = "llm-wiki"version = "0.3.7"@@ -4376,6 +4429,7 @@ dependencies = ["tauri","tauri-build","tauri-plugin-dialog",+ "tauri-plugin-http","tauri-plugin-opener","tauri-plugin-store","tiny_http",@@ -5704,6 +5758,22 @@ dependencies = ["prost",]+[[package]]+name = "psl-types"+version = "2.0.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac"++[[package]]+name = "publicsuffix"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6f42ea446cab60335f76979ec15e12619a2165b5ae2c12166bef27d283a9fadf"+dependencies = [+ "idna",+ "psl-types",+]+[[package]]name = "pxfm"version = "0.1.28"@@ -6094,6 +6164,8 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147"dependencies = ["base64 0.22.1","bytes",+ "cookie",+ "cookie_store","encoding_rs","futures-core","futures-util",@@ -6129,6 +6201,7 @@ dependencies = ["wasm-bindgen-futures","wasm-streams 0.4.2","web-sys",+ "webpki-roots",][[package]]@@ -6411,7 +6484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d"dependencies = ["bitflags 2.11.0",- "core-foundation",+ "core-foundation 0.10.1","core-foundation-sys","libc","security-framework-sys",@@ -7026,6 +7099,27 @@ dependencies = ["syn 2.0.117",]+[[package]]+name = "system-configuration"+version = "0.7.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b"+dependencies = [+ "bitflags 2.11.0",+ "core-foundation 0.9.4",+ "system-configuration-sys",+]++[[package]]+name = "system-configuration-sys"+version = "0.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"+dependencies = [+ "core-foundation-sys",+ "libc",+]+[[package]]name = "system-deps"version = "6.2.2"@@ -7199,7 +7293,7 @@ checksum = "9103edf55f2da3c82aea4c7fab7c4241032bfeea0e71fa557d98e00e7ce7cc20"dependencies = ["bitflags 2.11.0","block2",- "core-foundation",+ "core-foundation 0.10.1","core-graphics","crossbeam-channel","dispatch2",@@ -7426,6 +7520,30 @@ dependencies = ["url",]+[[package]]+name = "tauri-plugin-http"+version = "2.5.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cfba7d4ec72763f9d1fdf73c217747f01e2c84b08b87a8cacd2f94f35853f84d"+dependencies = [+ "bytes",+ "cookie_store",+ "data-url",+ "http",+ "regex",+ "reqwest 0.12.28",+ "schemars 0.8.22",+ "serde",+ "serde_json",+ "tauri",+ "tauri-plugin",+ "tauri-plugin-fs",+ "thiserror 2.0.18",+ "tokio",+ "url",+ "urlpattern",+]+[[package]]name = "tauri-plugin-opener"version = "2.5.3"@@ -8519,6 +8637,15 @@ dependencies = ["system-deps",]+[[package]]+name = "webpki-roots"+version = "1.0.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "52f5ee44c96cf55f1b349600768e3ece3a8f26010c05265ab73f945bb1a2eb9d"+dependencies = [+ "rustls-pki-types",+]+[[package]]name = "webview2-com"version = "0.38.2"@@ -8710,6 +8837,17 @@ dependencies = ["windows-link 0.1.3",]+[[package]]+name = "windows-registry"+version = "0.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720"+dependencies = [+ "windows-link 0.2.1",+ "windows-result 0.4.1",+ "windows-strings 0.5.1",+]+[[package]]name = "windows-result"version = "0.3.4"diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 9348da21..d2019b9d 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -27,6 +27,7 @@ chrono = { version = "0.4", features = ["clock"] }tauri-plugin-dialog = "2.7.0"pdfium-render = "0.9"tauri-plugin-store = "2.4.2"+tauri-plugin-http = { version = "2", features = ["unsafe-headers"] }tiny_http = "0.12"zip = "2"calamine = "0.34.0"diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.jsonindex e7f9d8b2..5dd4e32c 100644--- a/src-tauri/capabilities/default.json+++ b/src-tauri/capabilities/default.json@@ -7,6 +7,13 @@"core:default","opener:default","dialog:default",- "store:default"+ "store:default",+ {+ "identifier": "http:default",+ "allow": [+ { "url": "https://**" },+ { "url": "http://**" }+ ]+ }]}diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 4e70879a..2a90e32c 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -21,6 +21,11 @@ pub fn run() {.plugin(tauri_plugin_opener::init()).plugin(tauri_plugin_dialog::init()).plugin(tauri_plugin_store::Builder::default().build())+ // Rust-backed fetch so third-party LLM APIs that reject+ // browser-origin headers via CORS preflight (MiniMax, Volcengine+ // Ark's api/coding/v3, etc.) still work. Requests leave the app+ // from Rust, never the webview.+ .plugin(tauri_plugin_http::init()).setup(|app| {// Let the PDF extractor find the bundled pdfium dynamic// library via Tauri's platform-correct resource path.diff --git a/src/components/settings/llm-presets.ts b/src/components/settings/llm-presets.tsindex eedf9803..0806994a 100644--- a/src/components/settings/llm-presets.ts+++ b/src/components/settings/llm-presets.ts@@ -251,6 +251,31 @@ export const LLM_PRESETS: LlmPreset[] = [suggestedModels: ["MiniMax-M2.7", "MiniMax-M2.5", "MiniMax-M2.1", "MiniMax-M2"],suggestedContextSize: 200000,},+ {+ id: "volcengine-ark",+ label: "火山引擎 Ark (Volcengine)",+ hint: "ark.cn-beijing.volces.com/api/coding/v3",+ provider: "custom",+ // Volcengine Ark's "coding" product line mandates this exact base URL+ // per their official docs. Their other OpenAI-compat base (api/v3) is+ // not a valid substitute. This endpoint rejects browser-origin fetch+ // via CORS (allow-headers omits `authorization`), so LLM calls route+ // through Tauri's HTTP plugin — see src/lib/llm-client.ts.+ baseUrl: "https://ark.cn-beijing.volces.com/api/coding/v3",+ apiMode: "chat_completions",+ // Current Volcengine Ark model families. Users commonly bring their+ // own endpoint id (ep-xxx…) via the custom text input when they have+ // a private deployment provisioned on the console.+ suggestedModels: [+ "doubao-seed-1-6-250615",+ "doubao-1-5-pro-32k-250115",+ "doubao-1-5-pro-256k-250115",+ "doubao-1-5-lite-32k-250115",+ "deepseek-v3-250324",+ "deepseek-r1-250528",+ ],+ suggestedContextSize: 128000,+ },{id: "ollama-local",label: "Ollama (Local)",diff --git a/src/lib/llm-client.ts b/src/lib/llm-client.tsindex 2733aac3..192ae9f8 100644--- a/src/lib/llm-client.ts+++ b/src/lib/llm-client.ts@@ -11,6 +11,37 @@ export interface StreamCallbacks {const DECODER = new TextDecoder()+/**+ * All LLM HTTP traffic goes through Tauri's Rust-backed HTTP plugin+ * instead of the webview's native fetch. This bypasses CORS entirely —+ * the request leaves the app from Rust, never the browser engine — which+ * is the only way some third-party LLM endpoints work at all:+ *+ * - MiniMax (CORS allow-headers omits `x-api-key`; we worked around+ * this by using Bearer, but the plugin makes it robust)+ * - Volcengine Ark `/api/coding/v3` (allow-headers omits `authorization`+ * entirely — there is NO header swap that fixes it in the webview)+ * - Any other enterprise / on-prem gateway that doesn't expect browser+ * origins (a common class of bug across domestic Chinese clouds)+ *+ * The plugin's `fetch` API mirrors the web Fetch API shape so the rest+ * of this file looks like normal fetch code. Import is lazy + cached so+ * unit tests (vitest in node) can import this module for the helpers+ * below without the plugin's browser-only globals blowing up at load.+ */+let pluginFetchPromise: Promise<typeof globalThis.fetch> | null = null+function getHttpFetch(): Promise<typeof globalThis.fetch> {+ if (!pluginFetchPromise) {+ pluginFetchPromise = import("@tauri-apps/plugin-http")+ .then((m) => m.fetch as unknown as typeof globalThis.fetch)+ // In a non-Tauri context (vitest / node / storybook) the plugin's+ // global init fails; fall back to the browser's own fetch so+ // importing this module for helper functions still works.+ .catch(() => globalThis.fetch)+ }+ return pluginFetchPromise+}+/*** Detect fetch-level network failures across Tauri's different webview* backends. Each platform phrases the same failure class differently:@@ -91,13 +122,12 @@ export async function streamChat(try {const baseBody = providerConfig.buildBody(messages) as Record<string, unknown>const body = requestOverrides ? { ...baseBody, ...requestOverrides } : baseBody- response = await fetch(providerConfig.url, {+ const httpFetch = await getHttpFetch()+ response = await httpFetch(providerConfig.url, {method: "POST",headers: providerConfig.headers,body: JSON.stringify(body),signal: combinedSignal,- // @ts-ignore — keepalive hint for Tauri webview- keepalive: false,})} catch (err) {if (signal?.aborted) {