agentskit.js

@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/core

#Primary 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 — default ChatMemory implementations.
  • createStaticRetriever / formatRetrievedDocuments — RAG-less retrieval.
  • executeToolCall, consumeStream, createEventEmitter, safeParseArgs, generateId, buildMessage — low-level helpers.
  • AgentsKitError, AdapterError, ToolError, MemoryError, ConfigError, RuntimeError, SandboxError, SkillError, ErrorCodes — error taxonomy.
  • Token budget: compileBudget, approximateCounter.
  • Progressive tool args: createProgressiveArgParser, executeToolProgressively.
  • createVirtualizedMemory — hot-window + cold-retriever wrapper (also re-exported from @agentskit/memory).
  • Multi-modal content parts: textPart, imagePart, audioPart, videoPart, filePart, partsToText, normalizeContent, filterParts.
  • Agent-loop internals (advanced): buildToolMap, activateSkills, executeSafeTool, createToolLifecycle.
  • Memory serialization: serializeMessages, deserializeMessages.

#Subpath exports (zero main-bundle weight)

SubpathPurposeRecipe
@agentskit/core/agent-schemaDeclarative agent YAML/JSON + validatorSchema-first agents
@agentskit/core/prompt-experimentsA/B prompts with feature flagsA/B prompts
@agentskit/core/auto-summarizeAuto-summarizing ChatMemory wrapperAuto-summarize
@agentskit/core/hitlApproval gates + ApprovalStoreHITL approvals
@agentskit/core/securityPII redactor + injection detector + rate limiterPII, Injection, Rate limit
@agentskit/core/compose-toolChain N tools into oneTool composer
@agentskit/core/self-debugRetry tools with LLM-corrected argsSelf-debug
@agentskit/core/generative-uiTyped UI element tree + artifactsGen UI
@agentskit/core/a2aAgent-to-Agent protocol specOpen specs
@agentskit/core/manifestSkill + tool manifest format (MCP-compat)Open specs
@agentskit/core/eval-formatPortable eval dataset + run-resultOpen 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

#Source

Explore nearby

✎ Edit this page on GitHub·Found a problem? Open an issue →·How to contribute →

On this page