diff --git a/packages/aiCore/package.json b/packages/aiCore/package.json index 867f6c7cbb..20fdeb9576 100644 --- a/packages/aiCore/package.json +++ b/packages/aiCore/package.json @@ -1,6 +1,6 @@ { "name": "@cherrystudio/ai-core", - "version": "1.0.0-alpha.1", + "version": "1.0.0-alpha.2", "description": "Cherry Studio AI Core - Unified AI Provider Interface Based on Vercel AI SDK", "main": "dist/index.js", "module": "dist/index.mjs", @@ -137,12 +137,12 @@ "require": "./dist/index.js", "default": "./dist/index.js" }, - "./core/plugins/built-in": { - "types": "./dist/core/plugins/built-in/index.d.ts", - "react-native": "./dist/core/plugins/built-in/index.js", - "import": "./dist/core/plugins/built-in/index.mjs", - "require": "./dist/core/plugins/built-in/index.js", - "default": "./dist/core/plugins/built-in/index.js" + "./built-in/plugins": { + "types": "./dist/built-in/plugins/index.d.ts", + "react-native": "./dist/built-in/plugins/index.js", + "import": "./dist/built-in/plugins/index.mjs", + "require": "./dist/built-in/plugins/index.js", + "default": "./dist/built-in/plugins/index.js" } } } diff --git a/packages/aiCore/src/core/plugins/index.ts b/packages/aiCore/src/core/plugins/index.ts index 5883c0a41d..0532bc714c 100644 --- a/packages/aiCore/src/core/plugins/index.ts +++ b/packages/aiCore/src/core/plugins/index.ts @@ -1,5 +1,5 @@ // 核心类型和接口 -export type { AiPlugin, AiRequestContext, HookResult, HookType, PluginManagerConfig } from './types' +export type { AiPlugin, AiRequestContext, HookResult, PluginManagerConfig } from './types' import type { ProviderId } from '../../types' import type { AiPlugin, AiRequestContext } from './types' @@ -30,5 +30,3 @@ export function definePlugin AiPlugin>(pluginFacto export function definePlugin(plugin: AiPlugin | ((...args: any[]) => AiPlugin)) { return plugin } - -export { createLoggingPlugin } from './built-in/logging' diff --git a/packages/aiCore/src/core/plugins/types.ts b/packages/aiCore/src/core/plugins/types.ts index 53bb6f6fe1..5692e79d4f 100644 --- a/packages/aiCore/src/core/plugins/types.ts +++ b/packages/aiCore/src/core/plugins/types.ts @@ -66,11 +66,6 @@ export interface PluginManagerConfig { context: Partial } -/** - * 钩子执行器类型 - */ -export type HookType = 'first' | 'sequential' | 'parallel' | 'stream' - /** * 钩子执行结果 */ diff --git a/packages/aiCore/src/index.ts b/packages/aiCore/src/index.ts index cb840e2d79..e8831d7026 100644 --- a/packages/aiCore/src/index.ts +++ b/packages/aiCore/src/index.ts @@ -10,7 +10,7 @@ import { } from './core/models' import { aiProviderRegistry, isProviderSupported } from './core/providers/registry' import { createExecutor } from './core/runtime' -import { ProviderId, type ProviderSettingsMap } from './types' +import type { ProviderId, ProviderSettingsMap } from './types' // ==================== 主要用户接口 ==================== export { createExecutor, createOpenAICompatibleExecutor } from './core/runtime' @@ -19,9 +19,9 @@ export { createExecutor, createOpenAICompatibleExecutor } from './core/runtime' export { createModel, type ModelConfig } from './core/models' // ==================== 插件系统 ==================== -export type { AiPlugin, AiRequestContext, HookResult, HookType, PluginManagerConfig } from './core/plugins' +export type { AiPlugin, AiRequestContext, HookResult, PluginManagerConfig } from './core/plugins' export { createContext, definePlugin, PluginManager } from './core/plugins' -export { createPromptToolUsePlugin, webSearchPlugin } from './core/plugins/built-in' +// export { createPromptToolUsePlugin, webSearchPlugin } from './core/plugins/built-in' export { PluginEngine } from './core/runtime/pluginEngine' // ==================== 低级 API ==================== @@ -38,11 +38,36 @@ export { aiProviderRegistry } from './core/providers/registry' export type { ProviderConfig } from './core/providers/registry' export type { ProviderError } from './core/providers/types' export type { + AmazonBedrockProviderSettings, + AnthropicProviderSettings, + AnthropicVertexProviderSettings, + AzureOpenAIProviderSettings, + CerebrasProviderSettings, + CohereProviderSettings, + DeepInfraProviderSettings, + DeepSeekProviderSettings, + FalProviderSettings, + FireworksProviderSettings, GenerateObjectParams, GenerateTextParams, + GoogleGenerativeAIProviderSettings, + GoogleVertexProviderSettings, + GroqProviderSettings, + MistralProviderSettings, + OllamaProviderSettings, + OpenAICompatibleProviderSettings, + OpenAIProviderSettings, + OpenRouterProviderSettings, + PerplexityProviderSettings, + ProviderId, ProviderSettings, + ProviderSettingsMap, + ReplicateProviderSettings, StreamObjectParams, - StreamTextParams + StreamTextParams, + TogetherAIProviderSettings, + VercelProviderSettings, + XaiProviderSettings } from './types' export * as aiSdk from 'ai' @@ -91,35 +116,6 @@ export { // 重新导出 Agent export { Experimental_Agent as Agent } from 'ai' -// 重新导出所有 Provider Settings 类型 -export type { - AmazonBedrockProviderSettings, - AnthropicProviderSettings, - AnthropicVertexProviderSettings, - AzureOpenAIProviderSettings, - CerebrasProviderSettings, - CohereProviderSettings, - DeepInfraProviderSettings, - DeepSeekProviderSettings, - FalProviderSettings, - FireworksProviderSettings, - GoogleGenerativeAIProviderSettings, - GoogleVertexProviderSettings, - GroqProviderSettings, - MistralProviderSettings, - OllamaProviderSettings, - OpenAICompatibleProviderSettings, - OpenAIProviderSettings, - OpenRouterProviderSettings, - PerplexityProviderSettings, - ProviderId, - ProviderSettingsMap, - ReplicateProviderSettings, - TogetherAIProviderSettings, - VercelProviderSettings, - XaiProviderSettings -} from './types' - // ==================== 选项 ==================== export { createAnthropicOptions, diff --git a/packages/aiCore/src/types.ts b/packages/aiCore/src/types.ts index c4a05f9ba0..db68750f89 100644 --- a/packages/aiCore/src/types.ts +++ b/packages/aiCore/src/types.ts @@ -38,3 +38,6 @@ export type { VercelProviderSettings, XaiProviderSettings } from './core/providers/registry' + +// 重新导出插件类型 +export type { AiPlugin, AiRequestContext, HookResult, PluginManagerConfig } from './core/plugins/types' diff --git a/packages/aiCore/tsdown.config.ts b/packages/aiCore/tsdown.config.ts index 315799695d..101e38a3fa 100644 --- a/packages/aiCore/tsdown.config.ts +++ b/packages/aiCore/tsdown.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from 'tsdown' export default defineConfig({ entry: { index: 'src/index.ts', - 'core/plugins/built-in/index': 'src/core/plugins/built-in/index.ts' + 'built-in/plugins/index': 'src/core/plugins/built-in/index.ts' }, outDir: 'dist', format: ['esm', 'cjs'], diff --git a/tsconfig.web.json b/tsconfig.web.json index 048864a036..a8d43abbfb 100644 --- a/tsconfig.web.json +++ b/tsconfig.web.json @@ -16,6 +16,7 @@ "@renderer/*": ["src/renderer/src/*"], "@shared/*": ["packages/shared/*"], "@types": ["src/renderer/src/types/index.ts"], + "@cherrystudio/ai-core": ["packages/aiCore/src/index.ts"], "@cherrystudio/ai-core/*": ["packages/aiCore/src/*"] } }