For agents
@agentskit/core — for agents
Zero-dependency foundation. Contracts, chat controller, primitives, and a dozen feature subpaths.
Purpose
Stable TypeScript contracts (Adapter, Tool, Memory, Retriever, Skill,
Runtime) + createChatController + primitives. Target: <10 KB
gzipped, zero runtime deps.
Install
npm install @agentskit/corePrimary exports (main entry)
createChatController(config)— state machine behind every UI binding. Returns{ getState, subscribe, send, stop, retry, edit, regenerate, setInput, clear, approve, deny, updateConfig }.defineTool(config)— typed tool factory with JSON-Schema input inference.createInMemoryMemory/createLocalStorageMemory— defaultChatMemoryimplementations.createStaticRetriever/formatRetrievedDocuments— RAG-less retrieval.executeToolCall,consumeStream,createEventEmitter,safeParseArgs,generateId,buildMessage— low-level helpers.AgentsKitError,AdapterError,ToolError,MemoryError,ConfigError,ErrorCodes— error taxonomy.
Subpath exports (zero main-bundle weight)
| Subpath | Purpose | Recipe |
|---|---|---|
@agentskit/core/agent-schema | Declarative agent YAML/JSON + validator | Schema-first agents |
@agentskit/core/prompt-experiments | A/B prompts with feature flags | A/B prompts |
@agentskit/core/auto-summarize | Auto-summarizing ChatMemory wrapper | Auto-summarize |
@agentskit/core/hitl | Approval gates + ApprovalStore | HITL approvals |
@agentskit/core/security | PII redactor + injection detector + rate limiter | PII, Injection, Rate limit |
@agentskit/core/compose-tool | Chain N tools into one | Tool composer |
@agentskit/core/self-debug | Retry tools with LLM-corrected args | Self-debug |
@agentskit/core/generative-ui | Typed UI element tree + artifacts | Gen UI |
@agentskit/core/a2a | Agent-to-Agent protocol spec | Open specs |
@agentskit/core/manifest | Skill + tool manifest format (MCP-compat) | Open specs |
@agentskit/core/eval-format | Portable eval dataset + run-result | Open specs |
Minimal example
import { createChatController } from '@agentskit/core'
import { anthropic } from '@agentskit/adapters'
const controller = createChatController({
adapter: anthropic({ apiKey: process.env.ANTHROPIC_API_KEY!, model: 'claude-sonnet-4-6' }),
})
controller.subscribe(() => console.log(controller.getState().messages))
await controller.send('Hello')Common patterns
- Wire a controller into any framework via
getState+subscribe(see the framework bindings under For agents). - Compose tools with
composeToolor wrap failing ones withwrapToolWithSelfDebug. - Gate risky operations with
createApprovalGate+ HITL + signed audit log.