From 637aa4bf9e9ef05cefe2afebfac08cd90b150086 Mon Sep 17 00:00:00 2001 From: NitroRCr Date: Sun, 1 Jun 2025 13:25:22 +0800 Subject: [PATCH 1/2] fix(mcp): handle undefined prompt.arguments --- android/app/build.gradle | 4 ++-- package.json | 4 ++-- pnpm-lock.yaml | 36 ++++++++++++++---------------------- src-tauri/tauri.conf.json | 2 +- src/pages/AccountPage.vue | 5 +++-- src/pages/ErrorNotFound.vue | 2 +- src/utils/plugins.ts | 6 +++--- src/version.json | 4 ++-- 8 files changed, 28 insertions(+), 35 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 9c93ff46..f2215a4e 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "app.aiaw" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 10703 - versionName "Arona-v1.7.3" + versionCode 10704 + versionName "Arona-v1.7.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. diff --git a/package.json b/package.json index edeb73ec..0e049ee8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aiaw", - "version": "1.7.3", + "version": "1.7.4", "description": "精心设计的 AI (LLM) 客户端。全功能,轻量级;支持多工作区、插件系统、跨平台、本地优先+实时云同步", "productName": "AI as Workspace", "author": "NitroRCr ", @@ -25,7 +25,7 @@ "@ai-sdk/groq": "^1.1.7", "@ai-sdk/mistral": "^1.1.6", "@ai-sdk/openai": "^1.3.19", - "@ai-sdk/openai-compatible": "^0.2.8", + "@ai-sdk/openai-compatible": "^0.2.14", "@ai-sdk/togetherai": "^0.0.5", "@ai-sdk/xai": "^1.2.15", "@bradenmacdonald/s3-lite-client": "npm:@jsr/bradenmacdonald__s3-lite-client@^0.8.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ea136fad..3d0808ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,8 +33,8 @@ importers: specifier: ^1.3.19 version: 1.3.19(zod@3.24.1) '@ai-sdk/openai-compatible': - specifier: ^0.2.8 - version: 0.2.8(zod@3.24.1) + specifier: ^0.2.14 + version: 0.2.14(zod@3.24.1) '@ai-sdk/togetherai': specifier: ^0.0.5 version: 0.0.5(zod@3.24.1) @@ -366,8 +366,8 @@ packages: peerDependencies: zod: ^3.0.0 - '@ai-sdk/openai-compatible@0.2.8': - resolution: {integrity: sha512-o1CrhTrXnMj72G44oBqlDDBtunw6iwONysXj7EYN/Fx27rhP7YTcWwVeKs5gMx/u/8TIho9iZ9rkqXXc2xg8Bg==} + '@ai-sdk/openai-compatible@0.2.14': + resolution: {integrity: sha512-icjObfMCHKSIbywijaoLdZ1nSnuRnWgMEMLgwoxPJgxsUHMx0aVORnsLUid4SPtdhHI3X2masrt6iaEQLvOSFw==} engines: {node: '>=18'} peerDependencies: zod: ^3.0.0 @@ -426,14 +426,14 @@ packages: peerDependencies: zod: ^3.23.8 - '@ai-sdk/provider-utils@2.2.6': - resolution: {integrity: sha512-sUlZ7Gnq84DCGWMQRIK8XVbkzIBnvPR1diV4v6JwPgpn5armnLI/j+rqn62MpLrU5ZCQZlDKl/Lw6ed3ulYqaA==} + '@ai-sdk/provider-utils@2.2.7': + resolution: {integrity: sha512-kM0xS3GWg3aMChh9zfeM+80vEZfXzR3JEUBdycZLtbRZ2TRT8xOj3WodGHPb06sUK5yD7pAXC/P7ctsi2fvUGQ==} engines: {node: '>=18'} peerDependencies: zod: ^3.23.8 - '@ai-sdk/provider-utils@2.2.7': - resolution: {integrity: sha512-kM0xS3GWg3aMChh9zfeM+80vEZfXzR3JEUBdycZLtbRZ2TRT8xOj3WodGHPb06sUK5yD7pAXC/P7ctsi2fvUGQ==} + '@ai-sdk/provider-utils@2.2.8': + resolution: {integrity: sha512-fqhG+4sCVv8x7nFzYnFo19ryhAa3w096Kmc3hWxMQfW/TubPOmt3A6tYZhl4mUfQWWQMsuSkLrtjlWuXBVSGQA==} engines: {node: '>=18'} peerDependencies: zod: ^3.23.8 @@ -462,10 +462,6 @@ packages: resolution: {integrity: sha512-0M+qjp+clUD0R1E5eWQFhxEvWLNaOtGQRUaBn8CUABnSKredagq92hUS9VjOzGsTm37xLfpaxl97AVtbeOsHew==} engines: {node: '>=18'} - '@ai-sdk/provider@1.1.2': - resolution: {integrity: sha512-ITdgNilJZwLKR7X5TnUr1BsQW6UTX5yFp0h66Nfx8XjBYkWD9W3yugr50GOz3CnE9m/U/Cd5OyEbTMI0rgi6ZQ==} - engines: {node: '>=18'} - '@ai-sdk/provider@1.1.3': resolution: {integrity: sha512-qZMxYJ0qqX/RfnuIaab+zp8UAeJn/ygXXAffR5I4N0n1IrvA6qBsjc8hXLmBiMV2zoXlifkacF7sEFnYnjBcqg==} engines: {node: '>=18'} @@ -7149,10 +7145,10 @@ snapshots: '@ai-sdk/provider-utils': 2.2.7(zod@3.24.1) zod: 3.24.1 - '@ai-sdk/openai-compatible@0.2.8(zod@3.24.1)': + '@ai-sdk/openai-compatible@0.2.14(zod@3.24.1)': dependencies: - '@ai-sdk/provider': 1.1.2 - '@ai-sdk/provider-utils': 2.2.6(zod@3.24.1) + '@ai-sdk/provider': 1.1.3 + '@ai-sdk/provider-utils': 2.2.8(zod@3.24.1) zod: 3.24.1 '@ai-sdk/openai@1.1.9(zod@3.24.1)': @@ -7210,14 +7206,14 @@ snapshots: secure-json-parse: 2.7.0 zod: 3.24.1 - '@ai-sdk/provider-utils@2.2.6(zod@3.24.1)': + '@ai-sdk/provider-utils@2.2.7(zod@3.24.1)': dependencies: - '@ai-sdk/provider': 1.1.2 + '@ai-sdk/provider': 1.1.3 nanoid: 3.3.11 secure-json-parse: 2.7.0 zod: 3.24.1 - '@ai-sdk/provider-utils@2.2.7(zod@3.24.1)': + '@ai-sdk/provider-utils@2.2.8(zod@3.24.1)': dependencies: '@ai-sdk/provider': 1.1.3 nanoid: 3.3.11 @@ -7248,10 +7244,6 @@ snapshots: dependencies: json-schema: 0.4.0 - '@ai-sdk/provider@1.1.2': - dependencies: - json-schema: 0.4.0 - '@ai-sdk/provider@1.1.3': dependencies: json-schema: 0.4.0 diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 765b422c..e46cc7cf 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "AI as Workspace", - "version": "1.7.3", + "version": "1.7.4", "identifier": "app.aiaw", "build": { "frontendDist": "../dist/spa", diff --git a/src/pages/AccountPage.vue b/src/pages/AccountPage.vue index d7c0b949..598ec755 100644 --- a/src/pages/AccountPage.vue +++ b/src/pages/AccountPage.vue @@ -133,7 +133,8 @@ {{ $t('accountPage.remainingBudget') }} - {{ localePrice(llmBalance, 4) }} + ≤0 + {{ localePrice(llmBalance, 4) }} - @@ -281,7 +282,7 @@ async function refreshLlmBalance() { }) const { info, error } = await resp.json() if (resp.status === 400 && error.type === 'budget_exceeded') { - llmBalance.value = 0 + llmBalance.value = NaN return } llmBalance.value = info.max_budget - info.spend diff --git a/src/pages/ErrorNotFound.vue b/src/pages/ErrorNotFound.vue index 467703da..2de0854a 100644 --- a/src/pages/ErrorNotFound.vue +++ b/src/pages/ErrorNotFound.vue @@ -45,7 +45,7 @@ const show = ref(false) onMounted(() => { setTimeout(() => { show.value = true - }, props.timeout ?? 200) + }, props.timeout ?? 250) }) diff --git a/src/utils/plugins.ts b/src/utils/plugins.ts index adb0759b..8da69f07 100644 --- a/src/utils/plugins.ts +++ b/src/utils/plugins.ts @@ -402,7 +402,7 @@ function buildMcpPlugin(dump: McpPluginDump, available: boolean): Plugin { const prompts: PluginApi[] = dump.prompts.map(prompt => { const { name, description } = prompt const params: Record = {} - prompt.arguments.forEach(arg => { + prompt.arguments?.forEach(arg => { const t = TString({ title: arg.name, description: arg.description }) params[arg.name] = arg.required ? t : TOptional(t) }) @@ -476,12 +476,12 @@ async function dumpMcpPlugin(manifest: McpPluginManifest): Promise Date: Sun, 1 Jun 2025 14:33:50 +0800 Subject: [PATCH 2/2] fix(mcp): close client when sse connect failed --- src/utils/mcp-client.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/mcp-client.ts b/src/utils/mcp-client.ts index fd4b5853..61a51da7 100644 --- a/src/utils/mcp-client.ts +++ b/src/utils/mcp-client.ts @@ -54,7 +54,10 @@ export async function getClient(key: string, transportConf: TransportConf) { cwd: transportConf.cwd })) } else { - await client.connect(new SSEClientTransport(new URL(transportConf.url), { fetch })) + await client.connect(new SSEClientTransport(new URL(transportConf.url), { fetch })).catch(err => { + client.close() + throw err + }) } const timeoutId = window.setTimeout(() => { client.close()