* feat: add @cherrystudio/ai-sdk-provider package and integrate with CherryIN - Introduced the @cherrystudio/ai-sdk-provider package, providing a CherryIN routing solution for AI SDKs. - Updated configuration files to include the new provider. - Enhanced provider initialization to support CherryIN as a new AI provider. - Added README and documentation for usage instructions. * chore: remove deprecated @ai-sdk/google dependency and clean up package files - Removed the @ai-sdk/google dependency from package.json and yarn.lock as it is no longer needed. - Simplified the createGeminiModel function in index.ts for better readability and maintainability. * feat: update CherryIN provider integration and dependencies - Updated @ai-sdk/anthropic and @ai-sdk/google dependencies to their latest versions in package.json and yarn.lock. - Introduced a new CherryInProvider implementation in cherryin-provider.ts, enhancing support for CherryIN API. - Refactored provider initialization to include CherryIN as a supported provider in schemas.ts and options.ts. - Updated web search plugin to utilize the new CherryIN provider capabilities. - Cleaned up and organized imports across various files for better maintainability. * chore: clean up tsconfig and remove unnecessary nullish coalescing in CherryIn provider - Simplified tsconfig.json by consolidating exclude and include arrays. - Removed nullish coalescing in cherryin-provider.ts for cleaner header handling in model initialization. * fix: remove console.log from webSearchPlugin to clean up code - Eliminated unnecessary console.log statement in the webSearchPlugin to enhance code clarity and maintainability. * fix(i18n): Auto update translations for PR #10715 * chore: update yarn.lock with new package versions and dependencies - Added new versions for @ai-sdk/anthropic, @ai-sdk/google, @ai-sdk/provider-utils, and eventsource-parser. - Updated dependencies and peerDependencies for the newly added packages. * feat: enhance CherryIn provider with chat model support and custom fetch logic - Introduced CherryInOpenAIChatLanguageModel to handle chat-specific configurations. - Updated createChatModel to support CherryIn chat models. - Modified webSearchPlugin to accommodate both 'cherryin' and 'cherryin-chat' provider IDs. - Added 'cherryin-chat' provider ID to schemas and provider configurations. - Adjusted provider factory to correctly set provider ID for chat mode. - Enhanced web search utility to handle CherryIn chat models. * 🐛 fix: resolve cherryin provider lint errors and web search config - Add fetch global variable declaration for ai-sdk-provider in oxlintrc - Fix endpoint_type mapping fallback logic in cherryin provider - Add error handling comment for better code readability * chore(dependencies): update AI SDK packages and patches - Added new versions for @ai-sdk/anthropic, @ai-sdk/google, and @ai-sdk/provider-utils in yarn.lock. - Updated @ai-sdk/openai dependency to use a patch version in package.json. - Included @cherrystudio/ai-sdk-provider as a new dependency in the workspace. * chore(dependencies): update peer dependencies and installation instructions - Removed specific versions of @ai-sdk/anthropic and @ai-sdk/google from package.json and yarn.lock. - Updated peer dependencies in package.json to include @ai-sdk/anthropic, @ai-sdk/google, and @ai-sdk/openai. - Revised installation instructions in README.md to reflect the new dependencies. --------- Co-authored-by: GitHub Action <action@github.com>
130 lines
4.4 KiB
TypeScript
130 lines
4.4 KiB
TypeScript
import react from '@vitejs/plugin-react-swc'
|
|
import { CodeInspectorPlugin } from 'code-inspector-plugin'
|
|
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
|
import { resolve } from 'path'
|
|
import { visualizer } from 'rollup-plugin-visualizer'
|
|
|
|
// assert not supported by biome
|
|
// import pkg from './package.json' assert { type: 'json' }
|
|
import pkg from './package.json'
|
|
|
|
const visualizerPlugin = (type: 'renderer' | 'main') => {
|
|
return process.env[`VISUALIZER_${type.toUpperCase()}`] ? [visualizer({ open: true })] : []
|
|
}
|
|
|
|
const isDev = process.env.NODE_ENV === 'development'
|
|
const isProd = process.env.NODE_ENV === 'production'
|
|
|
|
export default defineConfig({
|
|
main: {
|
|
plugins: [externalizeDepsPlugin(), ...visualizerPlugin('main')],
|
|
resolve: {
|
|
alias: {
|
|
'@main': resolve('src/main'),
|
|
'@types': resolve('src/renderer/src/types'),
|
|
'@shared': resolve('packages/shared'),
|
|
'@logger': resolve('src/main/services/LoggerService'),
|
|
'@mcp-trace/trace-core': resolve('packages/mcp-trace/trace-core'),
|
|
'@mcp-trace/trace-node': resolve('packages/mcp-trace/trace-node')
|
|
}
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
external: ['bufferutil', 'utf-8-validate', 'electron', ...Object.keys(pkg.dependencies)],
|
|
output: {
|
|
manualChunks: undefined, // 彻底禁用代码分割 - 返回 null 强制单文件打包
|
|
inlineDynamicImports: true // 内联所有动态导入,这是关键配置
|
|
},
|
|
onwarn(warning, warn) {
|
|
if (warning.code === 'COMMONJS_VARIABLE_IN_ESM') return
|
|
warn(warning)
|
|
}
|
|
},
|
|
sourcemap: isDev
|
|
},
|
|
esbuild: isProd ? { legalComments: 'none' } : {},
|
|
optimizeDeps: {
|
|
noDiscovery: isDev
|
|
}
|
|
},
|
|
preload: {
|
|
plugins: [
|
|
react({
|
|
tsDecorators: true
|
|
}),
|
|
externalizeDepsPlugin()
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@shared': resolve('packages/shared'),
|
|
'@mcp-trace/trace-core': resolve('packages/mcp-trace/trace-core')
|
|
}
|
|
},
|
|
build: {
|
|
sourcemap: isDev
|
|
}
|
|
},
|
|
renderer: {
|
|
plugins: [
|
|
(async () => (await import('@tailwindcss/vite')).default())(),
|
|
react({
|
|
tsDecorators: true,
|
|
plugins: [
|
|
[
|
|
'@swc/plugin-styled-components',
|
|
{
|
|
displayName: true, // 开发环境下启用组件名称
|
|
fileName: false, // 不在类名中包含文件名
|
|
pure: true, // 优化性能
|
|
ssr: false // 不需要服务端渲染
|
|
}
|
|
]
|
|
]
|
|
}),
|
|
...(isDev ? [CodeInspectorPlugin({ bundler: 'vite' })] : []), // 只在开发环境下启用 CodeInspectorPlugin
|
|
...visualizerPlugin('renderer')
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@renderer': resolve('src/renderer/src'),
|
|
'@shared': resolve('packages/shared'),
|
|
'@types': resolve('src/renderer/src/types'),
|
|
'@logger': resolve('src/renderer/src/services/LoggerService'),
|
|
'@mcp-trace/trace-core': resolve('packages/mcp-trace/trace-core'),
|
|
'@mcp-trace/trace-web': resolve('packages/mcp-trace/trace-web'),
|
|
'@cherrystudio/ai-core/provider': resolve('packages/aiCore/src/core/providers'),
|
|
'@cherrystudio/ai-core/built-in/plugins': resolve('packages/aiCore/src/core/plugins/built-in'),
|
|
'@cherrystudio/ai-core': resolve('packages/aiCore/src'),
|
|
'@cherrystudio/extension-table-plus': resolve('packages/extension-table-plus/src'),
|
|
'@cherrystudio/ai-sdk-provider': resolve('packages/ai-sdk-provider/src')
|
|
}
|
|
},
|
|
optimizeDeps: {
|
|
exclude: ['pyodide'],
|
|
esbuildOptions: {
|
|
target: 'esnext' // for dev
|
|
}
|
|
},
|
|
worker: {
|
|
format: 'es'
|
|
},
|
|
build: {
|
|
target: 'esnext', // for build
|
|
rollupOptions: {
|
|
input: {
|
|
index: resolve(__dirname, 'src/renderer/index.html'),
|
|
miniWindow: resolve(__dirname, 'src/renderer/miniWindow.html'),
|
|
selectionToolbar: resolve(__dirname, 'src/renderer/selectionToolbar.html'),
|
|
selectionAction: resolve(__dirname, 'src/renderer/selectionAction.html'),
|
|
traceWindow: resolve(__dirname, 'src/renderer/traceWindow.html')
|
|
},
|
|
onwarn(warning, warn) {
|
|
if (warning.code === 'COMMONJS_VARIABLE_IN_ESM') return
|
|
warn(warning)
|
|
}
|
|
}
|
|
},
|
|
esbuild: isProd ? { legalComments: 'none' } : {}
|
|
}
|
|
})
|