29 Commits

Author SHA1 Message Date
icarus
caebaf5d46 chore: add tailwindCSS class attributes to vscode settings 2025-09-24 03:21:19 +08:00
icarus
a65b30f3a1 chore: update vscode settings for i18n configuration
Remove display language setting and clean up comments
2025-09-18 14:33:10 +08:00
Vaayne
49eed449c3 refactor: Remove outdated validation and planning documents for agents service 2025-09-18 12:02:11 +08:00
Vaayne
8ada7ffaf6 Merge remote-tracking branch 'origin/main' into feat/agents-new 2025-09-18 11:51:34 +08:00
SuYao
4f91a321a0 chore: update dependencies and VSCode settings (#10206)
* chore: update dependencies and VSCode settings

* chore

* chore: ts
2025-09-17 14:07:45 +08:00
Vaayne
c37af25525 Merge remote-tracking branch 'origin/main' into feat/agents-new 2025-09-16 18:08:14 +08:00
SuYao
5451e2f34a Perf/tsgo (#10188)
* feat: update tsgo

* chore: update alpha.15

* feat: add script

* chore: update ai-core version to alpha.16 and add npm registry settings

* chore
2025-09-16 10:16:42 +08:00
Phantom
d44654f003 chore: add tailwindcss and vitest extensions to vscode config (#10169) 2025-09-16 00:53:46 +08:00
Phantom
4d1d3e316f feat: use oxlint to speed up lint (#10168)
* build: add eslint-plugin-oxlint dependency

Add new eslint plugin to enhance linting capabilities with oxlint rules

* build(eslint): add oxlint plugin to eslint config

Add oxlint plugin as recommended in the documentation to enhance linting capabilities

* build: add oxlint v1.15.0 as a dependency

* build: add oxlint to linting commands

Add oxlint alongside eslint in test:lint and lint scripts for enhanced static analysis

* build: add oxlint configuration file

Configure oxlint with a comprehensive set of rules for JavaScript/TypeScript code quality checks

* chore: update oxlint configuration and related settings

- Add oxc to editor code actions on save
- Update oxlint configs to use eslint, typescript, and unicorn presets
- Extend ignore patterns in oxlint configuration
- Simplify oxlint command in package.json scripts
- Add oxlint-tsgolint dependency

* fix: lint warning

* chore: update oxlintrc from eslint.recommended

* refactor(lint): update eslint and oxlint configurations

- Add src/preload to eslint ignore patterns
- Update oxlint env to es2022 and add environment overrides
- Adjust several lint rule severities and configurations

* fix: lint error

* fix(file): replace eslint-disable with oxlint-disable in sanitizeFilename

The linter was changed from ESLint to oxlint, so the directive needs to be updated accordingly.

* fix: enforce stricter linting by failing on warnings in test:lint script

* feat: add recommended ts-eslint rules into exlint

* docs: remove outdated comment in oxlint config file

* style: disable typescript/no-require-imports rule in oxlint config

* docs(utils): fix comment typo from NODE to NOTE

* fix(MessageErrorBoundary): correct error description display condition

The error description was incorrectly showing in production and hiding in development. Fix the logic to show detailed errors only in development mode

* chore: add oxc-vscode extension to recommended list

* ci(workflows): reorder format check step in pr-ci.yml

* chore: update yarn.lock
2025-09-15 19:42:13 +08:00
Phantom
e5ccf68476 feat: use biome to format files (#10170)
* build: add @biomejs/biome as a dependency

* chore: add biome extension to vscode recommendations

* chore: migrate from prettier to biome for code formatting

Update VSCode settings to use Biome as the default formatter for multiple languages
Add Biome to code actions on save and reorder search exclude patterns

* build: add biome.json configuration file for code formatting

* build: migrate from prettier to biome for formatting

Update package.json scripts and biome.json configuration to use biome instead of prettier for code formatting. Adjust biome formatter includes/excludes patterns for better file matching.

* refactor(eslint): remove unused prettier config and imports

* chore: update biome.json configuration

- Enable linter and set custom rules
- Change jsxQuoteStyle to single quotes
- Add json parser configuration
- Set formatWithErrors to true

* chore: migrate biome config from json to jsonc format

The new jsonc format allows for comments in the configuration file, making it more maintainable and easier to document configuration choices.

* style(biome): update ignore patterns and jsx quote style

Update file ignore patterns from `/*` to `/**` for consistency
Change jsxQuoteStyle from single to double quotes for alignment with project standards

* refactor: simplify error type annotations from Error | any to any

The change standardizes error handling by using 'any' type instead of union types with Error | any, making the code more consistent and reducing unnecessary type complexity.

* chore: exclude tailwind.css from biome formatting

* style: standardize quote usage and fix JSX formatting

- Replace single quotes with double quotes in CSS imports and selectors
- Fix JSX element closing bracket alignment and formatting
- Standardize JSON formatting in package.json files

* Revert "style: standardize quote usage and fix JSX formatting"

This reverts commit 0947f8505d.

* fix: remove json import assertion for biome compatibility

The import assertion syntax is not supported by biome, so it was replaced with a standard import statement.

* style: change quote styles in biome.jsonc to use single quotes for JSX and double quotes for JS

* style: change quote style from double to single in biome config

* style: change JSX quote style from single to double

* chore: update biome.jsonc to use single quotes for CSS formatting

* chore: update biome config and format commands

- Exclude tailwind.css from linter includes
- Add biome lint to format commands

* style: format JSX closing brackets for better readability

* style: set bracketSameLine to true in biome config

The change aligns with common JSX formatting preferences where brackets on the same line improve readability for many developers

* Revert "style: format JSX closing brackets for better readability"

This reverts commit d442c934ee.

* style: format code and clean up whitespace

- Remove unnecessary whitespace in CSS and TS files
- Format package.json files to consistent style
- Reorder tsconfig.json properties alphabetically
- Improve code formatting in React components

* style(biome): update biome.jsonc config with clearer comment

Add explanation for keeping bracketSameLine as true to minimize changes in current PR while noting false would be better for future

* chore: remove prettier dependency and format package.json files

- Remove prettier from dependencies as it's no longer needed
- Reformat package.json files for better readability

* chore: replace prettier with biome for code formatting

Remove all prettier-related configuration, dependencies, and references
Update formatting scripts and documentation to use biome instead
Adjust electron-builder config to exclude biome.jsonc

* build: replace prettier with biome for formatting

Use biome as the default formatter instead of prettier for better performance and modern tooling support

* ci(i18n): replace prettier with biome for i18n formatting

Update the auto-i18n workflow to use Biome instead of Prettier for formatting translated files. This change simplifies the dependencies by removing multiple Prettier plugins and using a single tool for formatting.

* fix(i18n): Auto update translations for PR #10170

* style: format package.json files by consolidating array formatting

Consolidate multi-line array formatting into single-line format for better readability and consistency across package.json files

* Revert "fix(i18n): Auto update translations for PR #10170"

This reverts commit a7edd32efd.

* ci(workflows): specify biome config path in auto-i18n workflow

* chore: update biome.jsonc to use lexicographic sort order for json keys

* ci(workflows): update biome format command to use --config-path flag

* chore: exclude package.json from biome formatting

* ci: update biome.jsonc linter configuration

Update linter includes to target specific files and modify useSortedClasses rule

* chore: reorder search exclude patterns in vscode settings

* style(OGCard): reorder tailwind classes for consistent styling

* fix(biome): update tailwind classes sorting to safe and warn level

* docs(dev): update ide setup instructions in dev docs

Replace Prettier with Biome as the recommended formatter and clarify editor options

* build(extension-table-plus): replace prettier with biome for formatting

- Add biome.json configuration file
- Update package.json to use biome instead of prettier
- Remove prettier from dependencies
- Update lint script to use biome format

* chore: replace biome.json with biome.jsonc for extended configuration

Update biome configuration file to use JSONC format for comments and more detailed settings

* chore: remove unused biome.jsonc configuration file

---------

Co-authored-by: GitHub Action <action@github.com>
2025-09-15 19:21:15 +08:00
icarus
fa380619ce chore: update vscode i18n settings and comments
Clean up i18n-related settings in vscode config by commenting out display language and fixing comment alignment
2025-09-14 03:56:02 +08:00
Phantom
11502edad2 feat(translate): Auto copy when translation is done (#10032)
* feat(translate): add settings with autoCopy option to translate state

Add settings object to translate state to store user preferences like autoCopy functionality. Implement updateSettings reducer to handle settings updates.

* docs(translate): add todo comment for settings field

* refactor(translate): simplify settings update and expose in hook

Remove dependency on objectEntriesStrict and use Object.entries directly
Expose translate settings and update function in useTranslate hook

* fix(useTranslate): use dispatch to update

* feat(translate): add auto-copy setting for translated content

Add auto-copy functionality that automatically copies translated text to clipboard when enabled. Includes settings toggle in TranslateSettings component and integration with translate logic.

* chore: add tailwindcss file association to vscode settings

* feat(translate): add auto copy setting and improve switch styling

Add new translation strings for auto copy feature and apply consistent primary color to all switches in translation settings

* fix(theme): update hero UI primary color variable

Add --primary CSS variable to match --color-primary for hero UI components

* refactor(hooks): rename _updateSettings to handleUpdateSettings for clarity

Improve variable naming consistency and better reflect the function's purpose

* refactor(translate): simplify settings update using Object.assign

* fix(translate): handle clipboard write errors in copy functionality

Add error handling for clipboard operations to prevent silent failures and show user feedback when copy fails

* feat(i18n): add translation placeholders for new UI strings

Add new translation keys for front matter operations and auto-copy setting
Include additional Anthropic OAuth related messages for better user feedback

* fix(i18n): Auto update translations for PR #10032

* fix(i18n): correct translation errors in multiple language files

Fix incorrect translations and fill missing values in Japanese, Russian, Portuguese, French and Spanish localization files. Changes include correcting property name in Japanese, adding missing empty value in Russian, fixing editValue in Portuguese, correcting date and empty values in French, and fixing multiple terms in Spanish.

* fix: update error message in migration from 151 to 152

* fix(translate): await copy operation and show success message

Ensure the copy operation completes before proceeding and notify user of successful copy

* feat(translate): add delay timer for auto-copy functionality

Use setTimeoutTimer to introduce a 100ms delay before auto-copy to ensure UI stability

* fix(translate): increase modal width from 420 to 520 for better content display

* fix(ThemeProvider): ensure proper theme class is applied to body

Add logic to toggle 'light' and 'dark' classes on body element when theme changes

* fix(translate): only copy when success

* fix(translate): remove redundant error message display on translation failure

* fix(translate): handle abort and empty translation cases properly

Improve error handling for translation abort scenarios and empty responses. Show appropriate user messages when translation is aborted and properly handle NoOutputGeneratedError cases.

* fix(translate): handle translation errors by showing user-friendly message

Display a localized error message to users when translation fails instead of just logging it

---------

Co-authored-by: GitHub Action <action@github.com>
2025-09-09 00:49:20 +08:00
George·Dong
2633a1429a chore(vscode): improve VSCode launch configurations for debugging (#9483) 2025-08-25 10:46:45 +08:00
Phantom
36a22129a1 fix(i18n): standardize i18n usage (#8525)
* fix(数据设置): 修复菜单项标题未使用翻译函数的问题

* refactor(i18n): 使用labelMap集中管理翻译键以提升维护性

将分散在各处的翻译键集中管理到labelMap中,统一通过映射获取翻译文本
替换直接使用i18n.t的调用为从labelMap获取,减少重复代码
修复部分未考虑Linux平台的翻译描述

* fix(NewApiPage): 将未知提供者的值设为undefined以保持一致

* refactor(i18n): 将labelMap替换为动态获取标签的函数

重构国际化标签的获取方式,从静态对象改为动态函数,以支持语言切换时实时更新标签内容

* feat(i18n): 添加文件字段标签的国际化支持

将文件字段的标签文本提取到i18n模块中统一管理,便于维护和翻译

* refactor(utils): 移除调试用的console.log语句
2025-07-25 22:03:31 +08:00
Phantom
6cc29c5005 chore(i18n): forced nested structure to support i18n ally (#8457)
* chore(i18n): 更新i18n文件为嵌套结构以适应插件

* feat(i18n): 添加自动翻译脚本处理待翻译文本

添加自动翻译脚本auto-translate-i18n.ts,用于处理以[to be translated]开头的待翻译文本
在package.json中添加对应的运行命令auto:i18n

* chore(i18n): 更新嵌套结构

* chore(i18n): 更新多语言翻译文件并改进翻译逻辑

更新了多个语言的翻译文件,替换了"[to be translated]"标记为实际翻译内容
改进auto-translate-i18n.ts中的翻译逻辑,添加错误处理和日志输出
部分数组格式的翻译描述自动改为对象格式

* fix(i18n): 修复嵌套结构检查并改进错误处理

添加对嵌套结构中使用点符号的检查,确保使用严格嵌套结构
改进错误处理,在检查失败时输出更清晰的错误信息

* fix(测试): 更新下载失败测试中的翻译键名

* test(下载): 移除重复的下载失败翻译并更新测试

* feat(eslint): 添加规则,警告不建议在t()函数中使用模板字符串

* style: 使用单引号替换模板字符串中的反引号

* docs(.vscode): 添加i18n-ally扩展推荐到vscode配置

* fix: 在自动翻译脚本中停止进度条显示

确保在脚本执行完成后正确停止进度条,避免控制台输出混乱

* fix(i18n): 修复模型列表添加确认对话框的翻译键名

更新多语言文件中模型管理部分的翻译结构,将"add_listed"从字符串改为包含"confirm"和"key"的对象
同时修正EditModelsPopup组件中对应的翻译键引用

* chore: 注释掉i18n-ally命名空间配置

* docs: 添加国际化(i18n)最佳实践文档

添加中英文双语的技术文档,详细介绍项目中的i18n实现方案、工具链和最佳实践
包含i18n ally插件使用指南、自动化脚本说明以及代码规范要求

* docs(国际化): 更新i18n文档中的键名格式示例

将文档中错误的flat格式示例从下划线命名改为点分隔命名,以保持一致性

* refactor(i18n): 统一翻译键名从.key后缀改为.label后缀

* chore(i18n): sort

* refactor(locales): 使用 Object.fromEntries 重构 locales 对象

* feat(i18n): 添加机器翻译的语言支持

新增希腊语、西班牙语、法语和葡萄牙语的机器翻译支持,并调整语言资源加载顺序
2025-07-25 17:36:04 +08:00
George·Dong
ee32942f71 feat(minapp): add Google login tip for untrusted browser issue (#8230)
* feat(minapp): add Google login tip for untrusted browser issue

* feat(miniapp): add open Google button for Google Login popup

* feat(minapp): replace custom alert with Ant Design Alert component
2025-07-18 00:22:55 +08:00
one
92be3c0f56 chore: update vscode settings (#7974)
* chore: update vscode settings

* refactor: add editorconfig to extensions
2025-07-10 19:34:57 +08:00
Phantom
fb624cc368 chore: Disable auto-organize imports on save (#7744)
chore: 禁用保存时自动整理导入功能
2025-07-02 19:29:08 +08:00
kangfenmao
ba21a2c5fa refactor(EmojiIcon): enhance EmojiIcon component to accept size and fontSize props for better customization; update styles accordingly.
fix(AddAssistantPopup): adjust body padding for improved layout consistency.

style(Messages): modify padding in ScrollContainer for better spacing; add missing line for groupedMessages.

style(Prompt): update padding and margin for improved layout aesthetics.
2025-07-01 20:10:04 +08:00
MyPrototypeWhat
5f4d73b00d feat: add middleware support for provider (#6176)
* feat: add middleware support for OpenAIProvider with logging capabilities

- Introduced middleware functionality in OpenAIProvider to enhance completions processing.
- Created AiProviderMiddlewareTypes for defining middleware interfaces and contexts.
- Implemented sampleLoggingMiddleware for logging message content and processing times.
- Updated OpenAIProvider constructor to accept middleware as an optional parameter.
- Refactored completions method to utilize middleware for improved extensibility and logging.

* refactor: streamline OpenAIProvider initialization and middleware application

- Removed optional middleware parameter from OpenAIProvider constructor for simplicity.
- Refactored ProviderFactory to create instances of providers and apply logging middleware consistently.
- Enhanced completions method visibility by changing it from private to public.
- Cleaned up unused code related to middleware handling in OpenAIProvider.

* feat: enhance AiProvider with new middleware capabilities and completion context

- Added public getter for provider info in BaseProvider.
- Introduced finalizeSdkRequestParams hook for middleware to modify SDK-specific request parameters.
- Refactored completions method in OpenAIProvider to accept a context object, improving middleware integration.
- Updated middleware types to include new context structure and callback functions for better extensibility.
- Enhanced logging middleware to utilize new context structure for improved logging capabilities.

* refactor: enhance middleware structure and context handling in AiProvider

- Updated BaseProvider and AiProvider to utilize AiProviderMiddlewareCompletionsContext for completions method.
- Introduced new utility functions for middleware context creation and execution.
- Refactored middleware application logic to improve extensibility and maintainability.
- Replaced sampleLoggingMiddleware with a more robust LoggingMiddleware implementation.
- Added new context management features for better middleware integration.

* refactor: update AiProvider and middleware structure for improved completions handling

- Refactored BaseProvider and AiProvider to change completions method signature from context to params.
- Removed unused AiProviderMiddlewareCompletionsContext and related code for cleaner implementation.
- Enhanced middleware configuration by introducing a dedicated middleware registration file.
- Implemented logging middleware for completions to improve observability during processing.
- Streamlined middleware application logic in ProviderFactory for better maintainability.

* docs: 添加中间件编写指南文档

- 新增《如何为 AI Provider 编写中间件》文档,详细介绍中间件架构、类型及编写示例。
- 说明了中间件的执行顺序、注册方法及最佳实践,旨在帮助开发者有效创建和维护中间件。

* refactor: update completions method signatures and introduce CompletionsResult type

- Changed the completions method signature in BaseProvider and AiProvider to return CompletionsResult instead of void.
- Added CompletionsResult type definition to encapsulate streaming and usage metrics.
- Updated middleware and related components to handle the new CompletionsResult structure, ensuring compatibility with existing functionality.
- Introduced new middleware for stream adaptation to enhance chunk processing during completions.

* refactor: enhance AiProvider middleware and streaming handling

- Updated CompletionsResult type to support both OpenAI SDK stream and ReadableStream.
- Modified CompletionsMiddleware to return CompletionsResult, improving type safety.
- Introduced StreamAdapterMiddleware to adapt OpenAI SDK streams to application-specific chunk streams.
- Enhanced logging in CompletionsLoggingMiddleware to capture and return results from next middleware calls.

* refactor: update AiProvider and middleware for OpenAI completions handling

- Renamed CompletionsResult to CompletionsOpenAIResult for clarity and updated its structure to support both OpenAI SDK and application-specific streams.
- Modified completions method signatures in AiProvider and OpenAIProvider to return CompletionsOpenAIResult.
- Enhanced middleware to process and adapt OpenAI SDK streams into standard chunk formats, improving overall streaming handling.
- Introduced new middleware components: FinalChunkConsumerAndNotifierMiddleware and OpenAISDKChunkToStandardChunkMiddleware for better chunk processing and logging.

* 删除 ExtractReasoningCompletionsMiddleware.ts 文件,清理未使用的中间件代码以提高代码整洁性和可维护性。

* refactor: consolidate middleware types and improve imports

- Replaced references to AiProviderMiddlewareTypes with the new middlewareTypes file across various middleware components for better organization.
- Introduced TextChunkMiddleware to enhance chunk processing from OpenAI SDK streams.
- Cleaned up imports in multiple files to reflect the new structure, improving code clarity and maintainability.

* feat: enhance abort handling with AbortController in middleware chain

- Update CompletionsOpenAIResult interface to use AbortController instead of AbortSignal
- Modify OpenAIProvider to pass abortController in completions method return
- Update AbortHandlerMiddleware to use controller from upstream result
- Improve abort handling flexibility by exposing full controller capabilities
- Enable middleware to actively control abort operations beyond passive monitoring

This change provides better control over request cancellation and enables
more sophisticated abort handling patterns in the middleware pipeline.

* refactor: enhance AiProvider and middleware for improved completions handling

- Updated BaseProvider to expose additional methods and properties, including getMessageParam and createAbortController.
- Modified OpenAIProvider to streamline completions processing and integrate new middleware for tool handling.
- Introduced TransformParamsBeforeCompletions middleware to standardize parameter transformation before completions.
- Added McpToolChunkMiddleware for managing tool calls within the completions stream.
- Enhanced middleware types to support new functionalities and improve overall structure.

These changes improve the flexibility and maintainability of the AiProvider and its middleware, facilitating better handling of OpenAI completions and tool interactions.

* refactor: enhance middleware for recursive handling and internal state management

- Introduced internal state management in middleware to support recursive calls, including enhanced dispatch functionality.
- Updated middleware types to include new internal fields for managing recursion depth and call status.
- Improved logging for better traceability of recursive calls and state transitions.
- Adjusted various middleware components to utilize the new internal state, ensuring consistent behavior during recursive processing.

These changes enhance the middleware's ability to handle complex scenarios involving recursive calls, improving overall robustness and maintainability.

* fix(OpenAIProvider): return empty object for missing sdkParams in completions handling

- Updated OpenAIProvider to return an empty object instead of undefined when sdkParams are not found, ensuring consistent return types.
- Enhanced TransformParamsBeforeCompletions middleware to include a flag for built-in web search functionality based on assistant settings.

* refactor(OpenAIProvider): enhance completions handling and middleware integration

- Updated the completions method in OpenAIProvider to include an onChunk callback for improved streaming support.
- Enabled the ThinkChunkMiddleware in the middleware registration for better handling of reasoning content.
- Increased the maximum recursion depth in McpToolChunkMiddleware to prevent infinite loops.
- Refined TextChunkMiddleware to directly enqueue chunks without unnecessary type checks.
- Improved the ThinkChunkMiddleware to better manage reasoning tags and streamline chunk processing.

These changes enhance the overall functionality and robustness of the AI provider and middleware components.

* feat(WebSearchMiddleware): add web search handling and integration

- Introduced WebSearchMiddleware to process various web search results, including annotations and citations, and generate LLM_WEB_SEARCH_COMPLETE chunks.
- Enhanced TextChunkMiddleware to support link conversion based on the model and assistant settings, improving the handling of TEXT_DELTA chunks.
- Updated middleware registration to include WebSearchMiddleware for comprehensive search result processing.

These changes enhance the AI provider's capabilities in handling web search functionalities and improve the overall middleware architecture.

* fix(middleware): improve optional chaining for chunk processing

- Updated McpToolChunkMiddleware and ThinkChunkMiddleware to use optional chaining for accessing choices, enhancing robustness against undefined values.
- Removed commented-out code in ThinkChunkMiddleware to streamline the chunk handling process.

These changes improve the reliability of middleware when processing OpenAI API responses.

* feat(middleware): enhance AbortHandlerMiddleware with recursion handling

- Added logic to detect and handle recursive calls, preventing unnecessary creation of AbortControllers.
- Improved logging for better visibility into middleware operations, including recursion depth and cleanup processes.
- Streamlined cleanup process for non-stream responses to ensure resources are released promptly.

These changes enhance the robustness and efficiency of the AbortHandlerMiddleware in managing API requests.

* docs(middleware): 迁移步骤

* feat(middleware): implement FinalChunkConsumerMiddleware for usage and metrics accumulation

- Introduced FinalChunkConsumerMiddleware to replace the deprecated FinalChunkConsumerAndNotifierMiddleware.
- This new middleware accumulates usage and metrics data from OpenAI API responses, enhancing tracking capabilities.
- Updated middleware registration to utilize the new FinalChunkConsumerMiddleware, ensuring proper integration.
- Added support for handling recursive calls and improved logging for better debugging and monitoring.

These changes enhance the middleware's ability to manage and report usage metrics effectively during API interactions.

* refactor(migrate): update API request and response structures to TypeScript types

- Changed the definitions of `CoreCompletionsRequest` and `Chunk` to use TypeScript types instead of Zod Schemas for better type safety and clarity.
- Updated middleware and service classes to handle the new `Chunk` type, ensuring compatibility with the revised API client structure.
- Enhanced the response processing logic to standardize the handling of raw SDK chunks into application-level `Chunk` objects.
- Adjusted middleware to consume the new `Chunk` type, streamlining the overall architecture and improving maintainability.

These changes facilitate a more robust and type-safe integration with AI provider APIs.

* feat(AiProvider): implement API client architecture

- Introduced ApiClientFactory for creating instances of API clients based on provider configuration.
- Added BaseApiClient as an abstract class to provide common functionality for specific client implementations.
- Implemented OpenAIApiClient for OpenAI and Azure OpenAI, including request and response handling.
- Defined types and interfaces for API client operations, enhancing type safety and clarity.
- Established middleware schemas for standardized request processing across AI providers.

These changes lay the groundwork for a modular and extensible API client architecture, improving the integration of various AI providers.

* refactor(StreamAdapterMiddleware): simplify stream adaptation logic

- Updated StreamAdapterMiddleware to directly use AsyncIterable instead of wrapping it with rawSdkChunkAdapter, streamlining the adaptation process.
- Modified asyncGeneratorToReadableStream to accept AsyncIterable, enhancing its flexibility and usability.

These changes improve the efficiency of stream handling in the middleware.

* refactor(AiProvider): simplify ResponseChunkTransformer interface and streamline OpenAIApiClient response handling

- Changed ResponseChunkTransformer from an interface to a type for improved clarity and simplicity.
- Refactored OpenAIApiClient to streamline the response transformation logic, reducing unnecessary complexity in handling tool calls and reasoning content.
- Enhanced type safety by ensuring consistent handling of optional properties in response processing.

These changes improve the maintainability and readability of the codebase while ensuring robust response handling in the API client.

* doc(technicalArchitecture): add comprehensive documentation for AI Provider architecture

* feat(architecture): introduce AI Core Design documentation and middleware specification

- Added a comprehensive technical architecture document for the new AI Provider (`aiCore`), outlining core design principles, component details, and execution flow.
- Established a middleware specification document to define the design, implementation, and usage of middleware within the `aiCore` module, promoting a flexible and maintainable system.
- These additions provide clarity and guidance for future development and integration of AI functionalities within Cherry Studio.

* refactor(middleware): consolidate and enhance middleware architecture

- Removed deprecated extractReasoningMiddleware and integrated its functionality into existing middleware.
- Streamlined middleware registration and improved type definitions for better clarity and maintainability.
- Introduced new middleware components for handling chunk processing, web search, and reasoning tags, enhancing overall functionality.
- Updated various middleware to utilize the new structures and improve logging for better debugging.

These changes enhance the middleware's efficiency and maintainability, providing a more robust framework for API interactions.

* refactor(AiProvider): enhance API client and middleware integration

- Updated ApiClientFactory to include new SDK types for improved type safety and clarity.
- Refactored BaseApiClient to support additional parameters in the completions method, enhancing flexibility for processing states.
- Streamlined OpenAIApiClient to better handle tool calls and responses, including the introduction of new chunk types for tool management.
- Improved middleware architecture by integrating processing states and refining message handling, ensuring a more robust interaction with the API.

These changes enhance the overall maintainability and functionality of the API client and middleware, providing a more efficient framework for AI interactions.

* fix(McpToolChunkMiddleware): remove redundant logging in recursion state update

* refactor(McpToolChunkMiddleware): update tool call handling and type definitions

- Replaced ChatCompletionMessageToolCall with SdkToolCall for improved type consistency.
- Updated return types of executeToolCalls and executeToolUses functions to SdkMessage[], enhancing clarity in message handling.
- Removed unused import to streamline the code.

These changes enhance the maintainability and type safety of the middleware, ensuring better integration with the SDK.

* refactor(middleware): enhance middleware structure and type handling

- Updated middleware components to utilize new SDK types, improving type safety and clarity across the board.
- Refactored various middleware to streamline processing logic, including enhanced handling of SDK messages and tool calls.
- Improved logging and error handling for better debugging and maintainability.
- Consolidated middleware functions to reduce redundancy and improve overall architecture.

These changes enhance the robustness and maintainability of the middleware framework, ensuring a more efficient interaction with the API.

* refactor(middleware): unify type imports and enhance middleware structure

- Updated middleware components to import types from a unified 'types' file, improving consistency and clarity across the codebase.
- Removed the deprecated 'type.ts' file to streamline the middleware structure.
- Enhanced middleware registration and export mechanisms for better accessibility and maintainability.

These changes contribute to a more organized and efficient middleware framework, facilitating easier future development and integration.

* refactor(AiProvider): enhance API client and middleware integration

- Updated AiProvider components to support new SDK types, improving type safety and clarity.
- Refactored middleware to streamline processing logic, including enhanced handling of tool calls and responses.
- Introduced new middleware for tool use extraction and raw stream listening, improving overall functionality.
- Improved logging and error handling for better debugging and maintainability.

These changes enhance the robustness and maintainability of the API client and middleware, ensuring a more efficient interaction with the API.

* feat(middleware): add new middleware components for raw stream listening and tool use extraction

- Introduced RawStreamListenerMiddleware and ToolUseExtractionMiddleware to enhance middleware capabilities.
- Updated MiddlewareRegistry to include new middleware entries, improving overall functionality and extensibility.

These changes expand the middleware framework, facilitating better handling of streaming and tool usage scenarios.

* refactor(AiProvider): integrate new API client and middleware architecture

- Replaced BaseProvider with ApiClientFactory to enhance API client instantiation.
- Updated completions method to utilize new middleware architecture for improved processing.
- Added TODOs for refactoring remaining methods to align with the new API client structure.
- Removed deprecated middleware wrapping logic from ApiClientFactory for cleaner implementation.

These changes improve the overall structure and maintainability of the AiProvider, facilitating better integration with the new middleware system.

* refactor(middleware): update middleware architecture and documentation

- Revised middleware naming conventions and introduced a centralized MiddlewareRegistry for better management and accessibility.
- Enhanced MiddlewareBuilder to support named middleware and streamline the construction of middleware chains.
- Updated documentation to reflect changes in middleware usage and structure, improving clarity for future development.

These changes improve the organization and usability of the middleware framework, facilitating easier integration and maintenance.

* refactor(AiProvider): enhance completions middleware logic and API client handling

- Updated the completions method to conditionally remove middleware based on parameters, improving flexibility in processing.
- Refactored the response chunk transformer in OpenAIApiClient and AnthropicAPIClient to utilize a more streamlined approach with TransformStream.
- Simplified middleware context handling by removing unnecessary custom state management.
- Improved logging and error handling across middleware components for better debugging and maintainability.

These changes enhance the efficiency and clarity of the AiProvider's middleware integration, ensuring a more adaptable and robust processing framework.

* refactor(AiProvider, middleware): clean up logging and improve method naming

- Removed unnecessary logging of parameters in AiProvider to streamline the code.
- Updated method name assignment in middleware to enhance clarity and consistency.

These changes contribute to a cleaner codebase and improve the readability of the middleware and provider components.

* feat(middleware): enhance middleware types and add RawStreamListenerMiddleware

- Introduced RawStreamListenerMiddleware to the MiddlewareName enum for improved middleware capabilities.
- Updated type definitions across middleware components to enhance type safety and clarity, including the addition of new SDK types.
- Refactored context and middleware API interfaces to support more specific type parameters, improving overall maintainability.

These changes expand the middleware framework, facilitating better handling of streaming scenarios and enhancing type safety across the codebase.

* refactor(messageThunk): convert callback functions to async and handle errors during database updates

This commit updates several callback functions in the messageThunk to be asynchronous, ensuring that block transitions are awaited properly. Additionally, error handling is added for the database update function to log any failures when saving blocks. This improves the reliability and responsiveness of the message processing flow.

* refactor: enhance message block handling in messageThunk

This commit refactors the message processing logic in messageThunk to improve the management of message blocks. Key changes include the introduction of dedicated IDs for different block types (main text, thinking, tool, and image) to streamline updates and transitions. The handling of placeholder blocks has been improved, ensuring that they are correctly converted to their respective types during processing. Additionally, error handling has been enhanced for better reliability in database updates.

* feat(AiProvider): add default timeout configuration and enhance API client aborthandler

- Introduced a default timeout constant to the configuration for improved API client timeout management.
- Updated BaseApiClient and its derived classes to utilize the new timeout setting, ensuring consistent timeout behavior across different API clients.
- Enhanced middleware to pass the timeout value during API calls, improving error handling and responsiveness.

These changes improve the overall robustness and configurability of the API client interactions, facilitating better control over request timeouts.

* feat(GeminiProvider): implement Gemini API client and enhance file handling

- Introduced GeminiAPIClient to facilitate interactions with the Gemini API, replacing the previous GoogleGenAI integration.
- Refactored GeminiProvider to utilize the new API client, improving code organization and maintainability.
- Enhanced file handling capabilities, including support for PDF uploads and retrieval of file metadata.
- Updated message processing to accommodate new SDK types and improve content generation logic.

These changes significantly enhance the functionality and robustness of the GeminiProvider, enabling better integration with the Gemini API and improving overall user experience.

* refactor(AiProvider, middleware): streamline API client and middleware integration

- Removed deprecated methods and types from various API clients, enhancing code clarity and maintainability.
- Updated the CompletionsParams interface to support messages as a string or array, improving flexibility in message handling.
- Refactored middleware components to eliminate unnecessary state management and improve type safety.
- Enhanced the handling of streaming responses and added utility functions for better stream management.

These changes contribute to a more robust and efficient architecture for the AiProvider and its associated middleware, facilitating improved API interactions and user experience.

* refactor(middleware): translation 适配

- Deleted SdkCallMiddleware to streamline middleware architecture and improve maintainability.
- Commented out references to SdkCallModule in examples and registration files to prevent usage.
- Enhanced logging in AbortHandlerMiddleware for better debugging and tracking of middleware execution.
- Updated parameters in ResponseTransformMiddleware to improve flexibility in handling response settings.

These changes contribute to a cleaner and more efficient middleware framework, facilitating better integration and performance.

* refactor(ApiCheck): streamline API validation and error handling

- Updated the API check logic to simplify validation processes and improve error handling across various components.
- Refactored the `checkApi` function to throw errors directly instead of returning validation objects, enhancing clarity in error management.
- Improved the handling of API key checks in `checkModelWithMultipleKeys` to provide more informative error messages.
- Added a new method `getEmbeddingDimensions` in the `AiProvider` class to facilitate embedding dimension retrieval, enhancing model compatibility checks.

These changes contribute to a more robust and maintainable API validation framework, improving overall user experience and error reporting.

* refactor(HealthCheckService, ModelService): improve error handling and performance metrics

- Updated error handling in `checkModelWithMultipleKeys` to truncate error messages for better readability.
- Refactored `performModelCheck` to remove unnecessary error handling, focusing on performance metrics by returning only latency.
- Enhanced the `checkModel` function to ensure consistent return types, improving clarity in API interactions.

These changes contribute to a more efficient and user-friendly error reporting and performance tracking system.

* refactor(AiProvider, models): enhance model handling and API client integration

- Updated the `listModels` method in various API clients to improve model retrieval and ensure consistent return types.
- Refactored the `EditModelsPopup` component to handle model properties more robustly, including fallback options for `id`, `name`, and other attributes.
- Enhanced type definitions for models in the SDK to support new integrations and improve type safety.

These changes contribute to a more reliable and maintainable model management system within the AiProvider, enhancing overall user experience and API interactions.

* refactor(AiProvider, clients): implement image generation functionality

- Refactored the `generateImage` method in the `AiProvider` class to utilize the `apiClient` for image generation, replacing the previous placeholder implementation.
- Updated the `BaseApiClient` to include an abstract `generateImage` method, ensuring all derived clients implement this functionality.
- Implemented the `generateImage` method in `GeminiAPIClient` and `OpenAIAPIClient`, providing specific logic for image generation based on the respective SDKs.
- Added type definitions for `GenerateImageParams` across relevant files to enhance type safety and clarity in image generation parameters.

These changes enhance the image generation capabilities of the AiProvider, improving integration with various API clients and overall user experience.

* refactor(AiProvider, clients): restructure API client architecture and remove deprecated components

- Refactored the `ProviderFactory` and removed the `AihubmixProvider` to streamline the API client architecture.
- Updated the import paths for `isOpenAIProvider` to reflect the new structure.
- Introduced `AihubmixAPIClient` and `OpenAIResponseAPIClient` to enhance client handling based on model types.
- Improved the `AiProvider` class to utilize the new clients for better model-specific API interactions.
- Enhanced type definitions and error handling across various components to improve maintainability and clarity.

These changes contribute to a more efficient and organized API client structure, enhancing overall integration and user experience.

* fix: update system prompt handling in API clients to use await for asynchronous operations

- Modified the `AnthropicAPIClient`, `GeminiAPIClient`, `OpenAIAPIClient`, and `OpenAIResponseAPIClient` to ensure `buildSystemPrompt` is awaited, improving the handling of system prompts.
- Adjusted the `fetchMessagesSummary` function to utilize the last five user messages for better context in API calls and added a utility function to clean up topic names.

These changes enhance the reliability of prompt generation and improve the overall API interaction experience.

* refactor(middleware): remove examples.ts to streamline middleware documentation

- Deleted the `examples.ts` file containing various middleware usage examples to simplify the middleware structure and documentation.
- This change contributes to a cleaner codebase and focuses on essential middleware components, enhancing maintainability.

* refactor(AiProvider, middleware): enhance middleware handling and error management

- Updated the `CompletionsParams` interface to include a new `callType` property for better middleware decision-making based on the context of the API call.
- Introduced `ErrorHandlerMiddleware` to standardize error handling across middleware, allowing errors to be captured and processed as `ErrorChunk` objects.
- Modified the `AbortHandlerMiddleware` to conditionally remove itself based on the `callType`, improving middleware efficiency.
- Cleaned up logging in `AbortHandlerMiddleware` to reduce console output and enhance performance.
- Updated middleware registration to include the new `ErrorHandlerMiddleware`, ensuring comprehensive error management in the middleware pipeline.

These changes contribute to a more robust and maintainable middleware architecture, improving error handling and overall API interaction efficiency.

* feat: implement token estimation for message handling

- Added an abstract method `estimateMessageTokens` to the `BaseApiClient` class for estimating token usage based on message content.
- Implemented the `estimateMessageTokens` method in `AnthropicAPIClient`, `GeminiAPIClient`, `OpenAIAPIClient`, and `OpenAIResponseAPIClient` to calculate token consumption for various message types.
- Enhanced middleware to accumulate token usage for new messages, improving tracking of API call costs.

These changes improve the efficiency of message processing and provide better insights into token usage across different API clients.

* feat: add support for image generation and model handling

- Introduced `SUPPORTED_DISABLE_GENERATION_MODELS` to manage models that disable image generation.
- Updated `isSupportedDisableGenerationModel` function to check model compatibility.
- Enhanced `Inputbar` logic to conditionally enable image generation based on model support.
- Modified API clients to handle image generation calls and responses, including new chunk types for image data.
- Updated middleware and service layers to incorporate image generation parameters and improve overall processing.

These changes enhance the application's capabilities for image generation and improve the handling of various model types.

* feat: enhance GeminiAPIClient for image generation support

- Added `getGenerateImageParameter` method to configure image generation parameters.
- Updated request handling in `GeminiAPIClient` to include image generation options.
- Enhanced response processing to handle image data and enqueue it correctly.

These changes improve the GeminiAPIClient's capabilities for generating and processing images, aligning with recent enhancements in image generation support.

* feat: enhance image generation handling in OpenAIResponseAPIClient and middleware

- Updated OpenAIResponseAPIClient to improve user message processing for image generation.
- Added handling for image creation events in TransformCoreToSdkParamsMiddleware.
- Adjusted ApiService to streamline image generation event handling.
- Modified messageThunk to reflect changes in image block status during processing.

These enhancements improve the integration and responsiveness of image generation features across the application.

* refactor: remove unused AI provider classes

- Deleted `AihubmixProvider`, `AnthropicProvider`, `BaseProvider`, `GeminiProvider`, and `OpenAIProvider` as they are no longer utilized in the codebase.
- This cleanup reduces code complexity and improves maintainability by removing obsolete components related to AI provider functionality.

* chore: remove obsolete test files for middleware

- Deleted test files for `AbortHandlerMiddleware`, `LoggingMiddleware`, `TextChunkMiddleware`, `ThinkChunkMiddleware`, and `WebSearchMiddleware` as they are no longer needed.
- This cleanup helps streamline the codebase and reduces maintenance overhead by removing outdated tests.

* chore: remove Suggestions component and related functionality

- Deleted the `Suggestions` component from the home page as it is no longer needed.
- Removed associated imports and functions related to suggestion fetching, streamlining the codebase.
- This cleanup helps improve maintainability by eliminating unused components.

* feat: enhance OpenAIAPIClient and StreamProcessingService for tool call handling

- Updated OpenAIAPIClient to conditionally include tool calls in the assistant message, improving message processing logic.
- Enhanced tool call handling in the response transformer to correctly manage and enqueue tool call data.
- Added a new callback for LLM response completion in StreamProcessingService, allowing better integration of response handling.

These changes improve the functionality and responsiveness of the OpenAI API client and stream processing capabilities.

* fix: copilot error

* fix: improve chunk handling in TextChunkMiddleware and ThinkChunkMiddleware

- Updated TextChunkMiddleware to enqueue LLM_RESPONSE_COMPLETE chunks based on accumulated text content.
- Refactored ThinkChunkMiddleware to generate THINKING_COMPLETE chunks when receiving non-THINKING_DELTA chunks, ensuring proper handling of accumulated thinking content.
- These changes enhance the middleware's responsiveness and accuracy in processing text and thinking chunks.

* chore: update dependencies and improve styling

- Updated `selection-hook` dependency to version 0.9.23 in `package.json` and `yarn.lock`.
- Removed unused styles from `container.scss` and adjusted padding in `index.scss`.
- Enhanced message rendering and layout in various components, including `Message`, `MessageHeader`, and `MessageMenubar`.
- Added tooltip support for message divider settings in `SettingsTab`.
- Improved handling of citation display in `CitationsList` and `CitationBlock`.

These changes streamline the codebase and enhance the user interface for better usability.

* feat: implement image generation middleware and enhance model handling

- Added `ImageGenerationMiddleware` to handle dedicated image generation models, integrating image processing and OpenAI's image generation API.
- Updated `AiProvider` to utilize the new middleware for dedicated image models, ensuring proper middleware chaining.
- Introduced constants for dedicated image models in `models.ts` to streamline model identification.
- Refactored error handling in `ErrorHandlerMiddleware` to use a utility function for better error management.
- Cleaned up imports and removed unused code in various files for improved maintainability.

* fix: update dedicated image models identification logic

- Modified the `DEDICATED_IMAGE_MODELS` array to include 'grok-2-image' for improved model handling.
- Enhanced the `isDedicatedImageGenerationModel` function to use a more robust check for model identification, ensuring better accuracy in middleware processing.

* refactor: remove OpenAIResponseProvider class

- Deleted the `OpenAIResponseProvider` class from the `AiProvider` module, streamlining the codebase by eliminating unused code.
- This change enhances maintainability and reduces complexity in the provider architecture.

* fix: usermessage

* refactor: simplify AbortHandlerMiddleware for improved abort handling

- Removed direct dependency on ApiClient for creating AbortController, enhancing modularity.
- Introduced utility functions to manage abort controllers, streamlining the middleware's responsibilities.
- Delegated abort signal handling to downstream middlewares, allowing for cleaner separation of concerns.

* refactor(aiCore): Consolidate AI provider and middleware architecture

This commit refactors the AI-related modules by unifying the `clients` and `middleware` directories under a single `aiCore` directory. This change simplifies the project structure, improves modularity, and makes the architecture more cohesive.

Key changes:
- Relocated provider-specific clients and middleware into the `aiCore` directory, removing the previous `providers/AiProvider` structure.
- Updated the architectural documentation (`AI_CORE_DESIGN.md`) to accurately reflect the new, streamlined directory layout and execution flow.
- The main `AiProvider` class is now the primary export of `aiCore/index.ts`, serving as the central access point for AI functionalities.

* refactor: update imports and enhance middleware functionality

- Adjusted import statements in `AnthropicAPIClient` and `GeminiAPIClient` for better organization.
- Improved `AbortHandlerMiddleware` to handle abort signals more effectively, including the conversion of streams to handle abort scenarios.
- Enhanced `ErrorHandlerMiddleware` to differentiate between abort errors and other types, ensuring proper error handling.
- Cleaned up commented-out code in `FinalChunkConsumerMiddleware` for better readability and maintainability.

* refactor: streamline middleware logging and improve error handling

- Removed excessive debug logging from various middleware components, including `AbortHandlerMiddleware`, `FinalChunkConsumerMiddleware`, and `McpToolChunkMiddleware`, to enhance readability and performance.
- Updated logging levels to use warnings for potential issues in `ResponseTransformMiddleware`, `TextChunkMiddleware`, and `ThinkChunkMiddleware`, ensuring better visibility of important messages.
- Cleaned up commented-out code and unnecessary debug statements across multiple middleware files for improved maintainability.

---------

Co-authored-by: suyao <sy20010504@gmail.com>
Co-authored-by: eeee0717 <chentao020717Work@outlook.com>
Co-authored-by: lizhixuan <zhixuan.li@banosuperapp.com>
2025-06-12 16:01:19 +08:00
Camol
d64ae18bfc chore: Update runtime version in VSCode launch configuration (#5434)
Co-authored-by: kanweiwei <kanweiwei@nutstore.net>
2025-04-28 18:48:00 +08:00
africa1207
a54360cc69 feat: 优化webdav备份文件恢复管理功能 (#4699)
* feat: 优化webdav备份文件恢复管理功能

* fix: 恢复和删除操作更改为文字而非图标

* feat: 统一坚果云与webdav备份恢复功能
2025-04-13 21:52:16 +08:00
kangfenmao
fd6e4db888 chore: update configuration files for optimization and exclusion
- Added 'chunk-4X6ZJEXY.js' to the optimizeDeps exclusion list in electron.vite.config.ts to improve build performance.
- Updated .vscode/settings.json to exclude '.yarn/releases/**' from search results for better project organization.
2025-03-19 15:04:43 +08:00
Aimer
cb068d71ca Modified the prompt part Modified the minapp data part 2024-09-14 16:23:58 +08:00
kangfenmao
f866387862 feat: add redux-persist 2024-05-31 15:53:55 +08:00
kangfenmao
3e055b0822 feat: add redux store 2024-05-31 14:38:19 +08:00
kangfenmao
2b92c57f1e style(config): update Prettier and VS Code settings 2024-05-24 12:45:41 +08:00
kangfenmao
6acd758342 feat(vscode): added new snippet for creating React function components 2024-05-24 12:38:16 +08:00
kangfenmao
21f937a9cc feat: add vite-electron template 2024-05-24 10:03:02 +08:00