mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 14:25:51 +00:00
- 新建 workspace 包 packages/@anthropic-ai/model-provider - 定义 ModelProviderHooks 接口(依赖注入:分析、成本、日志等) - 定义 ClientFactories 接口(Anthropic/OpenAI/Gemini/Grok 客户端工厂) - 搬入核心类型:Message 体系、NonNullableUsage、EMPTY_USAGE、SystemPrompt、错误常量 - 主项目 src/types/message.ts 等改为 re-export,保持向后兼容 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
28 lines
655 B
TypeScript
28 lines
655 B
TypeScript
import type { ModelProviderHooks } from './types.js'
|
|
|
|
let registeredHooks: ModelProviderHooks | null = null
|
|
|
|
/**
|
|
* Register hooks from the main project.
|
|
* Call this during application initialization.
|
|
*/
|
|
export function registerHooks(hooks: ModelProviderHooks): void {
|
|
registeredHooks = hooks
|
|
}
|
|
|
|
/**
|
|
* Get registered hooks.
|
|
* Throws if hooks not registered (fail-fast).
|
|
*/
|
|
export function getHooks(): ModelProviderHooks {
|
|
if (!registeredHooks) {
|
|
throw new Error(
|
|
'ModelProvider hooks not registered. ' +
|
|
'Call registerHooks() during app initialization.',
|
|
)
|
|
}
|
|
return registeredHooks
|
|
}
|
|
|
|
export type { ModelProviderHooks }
|