API 参考总览
kagent-ts 通过单一的入口文件导出所有公共 API。
导入方式
ts
// 从主入口导入所有内容
import {
// Agent
ReActAgent, PlanSolveAgent, FusionAgent, OrchestratorAgent, Agent,
// LLM
OpenAIProvider, AnthropicProvider, FallbackProvider, RateLimitedProvider,
ModelRouter, createLLMProvider, TokenBudget,
// Tools
ToolRegistry, CircuitBreaker, BUILTIN_TOOLS, BUILTIN_TOOL_NAMES,
// Messages
Message, Role,
// Session
SessionManager,
// Skills
SkillManager, FileSkillLoader,
// MCP
McpClientManager,
// RAG
RAGManager, OpenAIEmbeddingProvider, InMemoryVectorStore,
// SubAgent
SubAgentManager, SubAgentLoader,
// Memory
MemoryManager,
// Reflection
ReflectionAgent, ErrorNotebook, createReflectionHook,
// Security
wrapUntrusted, detectInjectionSignatures, buildInjectionWarning,
// Eval
ToolCallEvaluator, EvalRunner, Benchmark,
// Utils
countTokens, countMessageTokens,
// Logging
Logger, ConsoleLogger, SilentLogger,
} from 'kagent-ts'模块导航
| 模块 | 说明 | 文档 |
|---|---|---|
| Agent 类 | ReAct / Plan-Solve / Fusion / Orchestrator | API - Agent |
| LLM Provider | OpenAI / Anthropic / Fallback / RateLimiter / Router | API - LLM |
| Tool 系统 | Registry / CircuitBreaker / Validator / Filters | API - Tools |
| Message 类型 | Message / Role / ToolCall | API - Messages |
| Session | SessionManager / SessionState | API - Session |
| Context & Compression | ContextManager / ProgressiveCompressor | API - Context |
| Skills | SkillManager / FileSkillLoader / Skill | 指南 - Skills |
| SubAgent | SubAgentManager / SubAgentLoader | 指南 - SubAgent |
| MCP | McpClientManager / McpServerConfig | 指南 - MCP |
| RAG | RAGManager / OpenAIEmbeddingProvider / InMemoryVectorStore | 指南 - RAG |
| Memory | MemoryManager / Memory | 指南 - Memory |
| Reflection | ReflectionAgent / ErrorNotebook | 指南 - Reflection |
| Security | wrapUntrusted / detectInjectionSignatures | 指南 - Security |
| Eval | ToolCallEvaluator / EvalRunner / Benchmark | 指南 - Eval |
| Trace | TraceLogger | 指南 - Trace |
主要类型一览
ts
// Agent 配置
type AgentConfig
type ReActAgentConfig
type PlanSolveAgentConfig
type FusionAgentConfig
type OrchestratorAgentConfig
// LLM Provider
type LLMProvider
type LLMResponse
type OpenAIConfig
type AnthropicConfig
type ModelRouterConfig
type TokenBudgetConfig
// RAG
type RAGConfig
type RAGDocument
type RAGChunk
type EmbeddingProvider
type VectorStore
type RAGSearchResult
// 工具系统
type Tool
type ToolResult
type ToolFilter
type ToolErrorTrace下一步
- API - Agent — Agent 类的完整 API
- API - LLM — LLM Provider 的完整 API
- API - Tools — Tool 系统的完整 API