Skip to content

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 / OrchestratorAPI - Agent
LLM ProviderOpenAI / Anthropic / Fallback / RateLimiter / RouterAPI - LLM
Tool 系统Registry / CircuitBreaker / Validator / FiltersAPI - Tools
Message 类型Message / Role / ToolCallAPI - Messages
SessionSessionManager / SessionStateAPI - Session
Context & CompressionContextManager / ProgressiveCompressorAPI - Context
SkillsSkillManager / FileSkillLoader / Skill指南 - Skills
SubAgentSubAgentManager / SubAgentLoader指南 - SubAgent
MCPMcpClientManager / McpServerConfig指南 - MCP
RAGRAGManager / OpenAIEmbeddingProvider / InMemoryVectorStore指南 - RAG
MemoryMemoryManager / Memory指南 - Memory
ReflectionReflectionAgent / ErrorNotebook指南 - Reflection
SecuritywrapUntrusted / detectInjectionSignatures指南 - Security
EvalToolCallEvaluator / EvalRunner / Benchmark指南 - Eval
TraceTraceLogger指南 - 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

下一步

基于 MIT 协议发布