Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
fix: change gateway pinging API endpoint
Vanalite652e23dfb13e
diff --git a/src-tauri/src/core/openclaw/commands.rs b/src-tauri/src/core/openclaw/commands.rsindex 654e8d18c..6d0e30ab4 100644--- a/src-tauri/src/core/openclaw/commands.rs+++ b/src-tauri/src/core/openclaw/commands.rs@@ -2394,6 +2394,13 @@ pub async fn openclaw_stop(state: State<'_, OpenClawState>) -> Result<(), String}}+/// Lightweight gateway reachability check (TCP only, no HTTP).+/// Used by the frontend before sending agent-mode chat requests.+#[tauri::command]+pub async fn openclaw_check_gateway() -> bool {+ check_gateway_responding().await+}+/// Get the current OpenClaw status, including sandbox information.#[tauri::command]pub async fn openclaw_status(state: State<'_, OpenClawState>) -> Result<OpenClawStatus, String> {diff --git a/web-app/src/lib/custom-chat-transport.ts b/web-app/src/lib/custom-chat-transport.tsindex 130c440ca..9d7985e05 100644--- a/web-app/src/lib/custom-chat-transport.ts+++ b/web-app/src/lib/custom-chat-transport.ts@@ -16,7 +16,7 @@ import { ModelFactory } from './model-factory'import { useModelProvider } from '@/hooks/useModelProvider'import { useAssistant } from '@/hooks/useAssistant'import { useAgentMode } from '@/hooks/useAgentMode'-import { getOpenClawAuthToken, ensureOpenClawHttpApi, OPENCLAW_GATEWAY_URL, checkOpenClawGatewayReachable } from '@/utils/openclaw'+import { getOpenClawAuthToken, ensureOpenClawHttpApi, checkOpenClawGateway, OPENCLAW_GATEWAY_URL } from '@/utils/openclaw'import { useThreads } from '@/hooks/useThreads'import { useAttachments } from '@/hooks/useAttachments'import { ExtensionManager } from '@/lib/extension'@@ -281,13 +281,17 @@ export class CustomChatTransport implements ChatTransport<UIMessage> {if (isAgentMode) {// Agent mode: route to OpenClaw gatewayawait ensureOpenClawHttpApi()++ const gatewayReachable = await checkOpenClawGateway()+ if (!gatewayReachable) {+ throw new Error('Cannot reach the OpenClaw gateway. Please check that Remote Access is running in Settings.')+ }+const authToken = await getOpenClawAuthToken()if (!authToken) {throw new Error('OpenClaw is not available. Please check that it is running in Settings > Remote Access.')}- await checkOpenClawGatewayReachable()-const openclawProvider: ProviderObject = {active: true,provider: 'openclaw',diff --git a/web-app/src/utils/openclaw.ts b/web-app/src/utils/openclaw.tsindex be3cd23ca..164f48de1 100644--- a/web-app/src/utils/openclaw.ts+++ b/web-app/src/utils/openclaw.ts@@ -1,5 +1,4 @@import { invoke } from '@tauri-apps/api/core'-import { fetch as httpFetch } from '@tauri-apps/plugin-http'import { useAgentMode } from '@/hooks/useAgentMode'import { useAppState } from '@/hooks/useAppState'@@ -176,6 +175,15 @@ export async function getOpenClawAuthToken(forceRefresh = false): Promise<string}}+/** TCP-level gateway reachability check via Tauri IPC. Works on all platforms. */+export async function checkOpenClawGateway(): Promise<boolean> {+ try {+ return await invoke<boolean>('openclaw_check_gateway')+ } catch {+ return false+ }+}+/** Get the currently configured model in OpenClaw. */export async function getOpenClawModel(): Promise<string | null> {try {@@ -185,27 +193,3 @@ export async function getOpenClawModel(): Promise<string | null> {}}-/** Verify the OpenClaw gateway is reachable. Throws if not. */-export async function checkOpenClawGatewayReachable(): Promise<void> {- try {- const res = await httpFetch(`${OPENCLAW_GATEWAY_URL}/models`, {- method: 'GET',- signal: AbortSignal.timeout(5_000),- })- if (!res.ok) {- const body = await res.text().catch(() => '')- throw new Error(- `OpenClaw gateway returned HTTP ${res.status}${body ? `: ${body}` : ''}`- )- }- } catch (error) {- if (error instanceof Error && error.message.startsWith('OpenClaw gateway returned')) {- throw error- }- const msg = error instanceof Error ? error.message : String(error)- throw new Error(- `Cannot reach the OpenClaw gateway at ${OPENCLAW_GATEWAY_URL}. ` +- `Please make sure the local API server is running.\n\nDetails: ${msg}`- )- }-}