Package Exports
- @agforge/core
- @agforge/core/cjs/index.js
- @agforge/core/esm/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@agforge/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@agforge/core
Agent protocol, execution skeleton, interceptor chain, message types, and ScopeContext — the foundational layer of AgForge SDK.
Overview
@agforge/core defines only interfaces and execution skeletons, with no concrete implementations. It provides:
- Agent — abstract agent protocol
- ReActAgent — zero-built-in-interceptor agent with the ReAct loop skeleton
- Interceptor chain — onion-model composition across multiple lifecycle hooks
- Message types — full message type definitions (user, assistant, tool call, tool result, etc.)
- Model interface — LLM abstraction for streaming
request()returningAsyncGenerator<AssistantMessageChunk> - Tool interface — dual-channel output (
structResult+llmMessage) - ScopeContext — WeakMap-based data isolation (private + shared)
- MessageStore — conversation history persistence interface
Install
npm install @agforge/core
# or
pnpm add @agforge/coreUsage
import { ReActAgent } from '@agforge/core';
import type { Model, Tool, Interceptor } from '@agforge/core';For a fully-featured agent with 14 built-in interceptors, use
@agforge/enginewhich providesDefaultAgent.
Lifecycle Hooks
Agent.execute()
├── execute — Agent-level entry & exit
│ └── doExecute — ReAct loop entry
│ └── eachLoop — Single iteration
│ ├── llmRequest — LLM call
│ └── executeTool — Tool execution entry
│ ├── resolveTool — Match tool, parse params
│ └── doExecuteTool — Core tool execution
└── stop — Graceful shutdownInterceptor Phases
Interceptors are organized into phases to guarantee execution order:
| Phase | Order | Purpose |
|---|---|---|
SYSTEM |
Outermost | Framework concerns (tracing, compression, etc.) |
USER |
Middle | Your business logic |
SYSTEM_POST |
Innermost | Final preparation (sanitization, system reminder) |
Related Packages
| Package | Role |
|---|---|
@agforge/engine |
Capability implementations (DefaultAgent, interceptors, MCP, tools) |
@agforge/models |
LLM provider adapters (Vercel AI SDK v6) |
@agforge/logger |
Hierarchical logging with scoped config |
@agforge/utils |
Shared utilities (CircuitBreaker, sleep, timeout, etc.) |
License
ISC