026429cb2f
- 移除 adapter.ts 中约 160 行冗余接口定义 - 简化 initCore 函数,改为初始化检查逻辑 - 简化 getOrCreateAgent,直接使用 ConfigurationError 类 - 更新缓存类型注解使用 Core 导出的类型 - 简化事件订阅代码,直接使用 agentEventEmitter - 在 Core index.ts 中添加 agentEventEmitter 导出 - 更新测试文件适配静态导入模式
303 lines
6.4 KiB
TypeScript
303 lines
6.4 KiB
TypeScript
export { Agent } from './core/agent.js';
|
|
export type { AgentChatOptions, ToolStartInfo, ToolEndInfo, DoomLoopInfo } from './core/agent.js';
|
|
|
|
// Doom Loop Detection
|
|
export {
|
|
createDoomLoopDetector,
|
|
DOOM_LOOP_THRESHOLD,
|
|
DOOM_LOOP_WARNING,
|
|
MAX_STEPS_WARNING,
|
|
} from './core/doom-loop.js';
|
|
export type { DoomLoopDetector } from './core/doom-loop.js';
|
|
export { toolRegistry, todoManager, initTaskContext, updateTaskDescription, updateSkillDescription } from './tools/index.js';
|
|
export { loadConfig, loadVisionConfig, buildConfigFromModelConfig, ConfigurationError } from './utils/config.js';
|
|
export type { VisionConfig } from './utils/config.js';
|
|
|
|
// Context compression
|
|
export {
|
|
CompressionManager,
|
|
CompressionStatus,
|
|
DEFAULT_COMPRESSION_CONFIG,
|
|
} from './context/index.js';
|
|
export type {
|
|
TokenUsage,
|
|
CompressionConfig,
|
|
DetailedCompressionResult,
|
|
} from './context/index.js';
|
|
// Session - 新的三层存储结构
|
|
export { SessionManager } from './session/index.js';
|
|
export type { SessionData, SessionSummary, ProjectMetadata } from './session/index.js';
|
|
|
|
// Session Storage API
|
|
export {
|
|
SessionStorage,
|
|
MessageStorage,
|
|
PartStorage,
|
|
TodoStorage,
|
|
initStorage,
|
|
getStorageDir,
|
|
StorageNotFoundError,
|
|
} from './session/index.js';
|
|
|
|
export type {
|
|
SessionInfo,
|
|
MessageInfo,
|
|
Part,
|
|
PartType,
|
|
ToolStatus,
|
|
TodoItem,
|
|
TodoList,
|
|
} from './session/index.js';
|
|
|
|
// Types
|
|
export type { UserInput, ChatResult } from './types/index.js';
|
|
|
|
// Permission
|
|
export { getPermissionManager } from './permission/index.js';
|
|
export type {
|
|
PermissionContext,
|
|
PermissionDecision,
|
|
PermissionCheckResult,
|
|
FilePermissionContext,
|
|
GitPermissionContext,
|
|
WebPermissionContext,
|
|
} from './permission/index.js';
|
|
|
|
// LSP
|
|
export { initLSP, shutdownLSP } from './lsp/index.js';
|
|
export {
|
|
printServerList,
|
|
installServer,
|
|
installAllServers,
|
|
showServerInfo,
|
|
} from './lsp/cli.js';
|
|
|
|
// Skills
|
|
export { getSkillRegistry } from './skills/index.js';
|
|
|
|
// Image utils
|
|
export {
|
|
extractImageReferences,
|
|
loadImages,
|
|
loadImage,
|
|
formatFileSize,
|
|
isImagePath,
|
|
IMAGE_EXTENSIONS,
|
|
} from './utils/image.js';
|
|
export type { ImageInfo, ImageLoadResult } from './utils/image.js';
|
|
|
|
// Commands
|
|
export { getCommandRegistry, createCommandExecutor, createCommandManager } from './commands/index.js';
|
|
export type {
|
|
Command,
|
|
CommandInput,
|
|
CommandExecutionResult,
|
|
CreateCommandInput,
|
|
UpdateCommandInput,
|
|
CommandContent,
|
|
CommandOperationResult,
|
|
} from './commands/index.js';
|
|
|
|
// Checkpoint
|
|
export {
|
|
CheckpointManager,
|
|
getCheckpointManager,
|
|
initCheckpointManager,
|
|
resetCheckpointManager,
|
|
ShadowGit,
|
|
createShadowGit,
|
|
hashWorkingDir,
|
|
CheckpointSafetyChecker,
|
|
createSafetyChecker,
|
|
SessionTracker,
|
|
createSessionTracker,
|
|
CheckpointLock,
|
|
LFSPatternLoader,
|
|
createLFSPatternLoader,
|
|
isCommonLargeFile,
|
|
COMMON_LARGE_FILE_EXTENSIONS,
|
|
WorkspacePathValidator,
|
|
createPathValidator,
|
|
CommitMessageGenerator,
|
|
createCommitMessageGenerator,
|
|
RestoreMode,
|
|
DEFAULT_CHECKPOINT_CONFIG,
|
|
} from './checkpoint/index.js';
|
|
|
|
export type {
|
|
CheckpointMetadata,
|
|
CheckpointConfig,
|
|
CheckpointTrigger,
|
|
FileChange,
|
|
FileChangeType,
|
|
DiffInfo,
|
|
FileDiff,
|
|
RollbackOptions,
|
|
RollbackResult,
|
|
CheckpointEvent,
|
|
CheckpointEventType,
|
|
CheckpointEventListener,
|
|
RollbackRecord,
|
|
UnrevertResult,
|
|
SafetyCheckResult,
|
|
SessionState,
|
|
SessionStats,
|
|
PathValidationResult,
|
|
} from './checkpoint/index.js';
|
|
|
|
// Hooks
|
|
export {
|
|
HookManager,
|
|
getHookManager,
|
|
initHookManager,
|
|
resetHookManager,
|
|
loadProjectConfig,
|
|
loadHookConfig,
|
|
loadPluginList,
|
|
createDefaultConfig,
|
|
getConfigFilePath,
|
|
} from './hooks/index.js';
|
|
|
|
export type {
|
|
HookType,
|
|
HookConfig,
|
|
HookEvent,
|
|
HookEventListener,
|
|
ShellCommandConfig,
|
|
FileHookConfig,
|
|
Hooks,
|
|
Plugin,
|
|
PluginInput,
|
|
ToolExecuteBeforeInput,
|
|
ToolExecuteBeforeOutput,
|
|
ToolExecuteAfterInput,
|
|
ToolExecuteAfterOutput,
|
|
SessionStartInput,
|
|
SessionEndInput,
|
|
MessageBeforeInput,
|
|
MessageBeforeOutput,
|
|
MessageAfterInput,
|
|
FileChangeInput,
|
|
FileChangeOutput,
|
|
ProjectConfig,
|
|
} from './hooks/index.js';
|
|
|
|
// Agent Registry & Presets
|
|
export { agentRegistry, AgentRegistry } from './agent/index.js';
|
|
export { loadAgentConfig, saveAgentConfig, getConfigTemplate } from './agent/index.js';
|
|
export { presetAgents, isPresetAgent, getPresetAgentNames } from './agent/index.js';
|
|
export type {
|
|
AgentMode,
|
|
AgentInfo,
|
|
AgentConfigFile,
|
|
AgentModelConfig,
|
|
AgentToolConfig,
|
|
AgentPermission,
|
|
} from './agent/index.js';
|
|
|
|
// Agent Events (for subagent progress tracking)
|
|
export { agentEventEmitter, AgentEventEmitter } from './agent/index.js';
|
|
export type {
|
|
SubagentEvent,
|
|
SubagentEventType,
|
|
SubagentStartEvent,
|
|
SubagentEndEvent,
|
|
SubagentStreamEvent,
|
|
SubagentToolStartEvent,
|
|
SubagentToolEndEvent,
|
|
SubagentEventListener,
|
|
} from './agent/index.js';
|
|
|
|
// MCP
|
|
export {
|
|
getMCPManager,
|
|
loadMCPConfig,
|
|
createMCPToolAdapter,
|
|
} from './mcp/index.js';
|
|
|
|
// Provider
|
|
export {
|
|
ProviderRegistry,
|
|
providerRegistry,
|
|
getProviderRegistry,
|
|
builtinProviders,
|
|
getBuiltinProviders,
|
|
getBuiltinProvider,
|
|
isBuiltinProvider,
|
|
loadProvidersConfig,
|
|
saveProvidersConfig,
|
|
resolveApiKey,
|
|
testOpenAICompatibleConnection,
|
|
createOpenAICompatibleFactory,
|
|
isValidProviderId,
|
|
isValidUrl,
|
|
} from './provider/index.js';
|
|
|
|
export type {
|
|
BuiltinProviderType,
|
|
ProviderType,
|
|
ModelCapabilities,
|
|
ModelInfo,
|
|
ProviderInfo,
|
|
ProviderConfig,
|
|
CustomProviderDefinition,
|
|
ConnectionTestResult,
|
|
ProviderFactory,
|
|
RegisteredProvider,
|
|
ProvidersConfigFile,
|
|
ProviderListItem,
|
|
ProviderDetail,
|
|
} from './provider/index.js';
|
|
|
|
// File Index
|
|
export {
|
|
getFileIndex,
|
|
searchFiles,
|
|
refreshFileIndex,
|
|
getFileIndexStats,
|
|
} from './file-index/index.js';
|
|
|
|
export type {
|
|
FileIndexEntry,
|
|
FileSearchOptions,
|
|
} from './file-index/index.js';
|
|
|
|
// Constants - 统一存储路径
|
|
export {
|
|
APP_DIR_NAME,
|
|
getAppDir,
|
|
getConfigDir,
|
|
getDataDir,
|
|
getCheckpointsDir,
|
|
getCacheDir,
|
|
getLogsDir,
|
|
} from './constants/index.js';
|
|
|
|
// Template - 通用模板引擎
|
|
export {
|
|
// 通用模板渲染
|
|
renderTemplate,
|
|
render,
|
|
// Agent 特定函数
|
|
renderPromptTemplate,
|
|
renderPrompt,
|
|
createDefaultContext,
|
|
createPlanContext,
|
|
createToolDescriptionContext,
|
|
checkPlanFileExists,
|
|
DEFAULT_TOOL_NAMES,
|
|
} from './template/index.js';
|
|
|
|
export type {
|
|
TemplateContext,
|
|
Template,
|
|
RenderOptions,
|
|
// Agent 特定类型
|
|
PromptContext,
|
|
PromptTemplate,
|
|
ToolNameMapping,
|
|
PlanModeContext,
|
|
EnvContext,
|
|
AgentContext,
|
|
} from './template/index.js';
|