JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 133
  • Score
    100M100P100Q61644F
  • License ISC

Agent protocol, execution skeleton, interceptor chain, message types, and ScopeContext for AgForge SDK

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() returning AsyncGenerator<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/core

Usage

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/engine which provides DefaultAgent.

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 shutdown

Interceptor 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)
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