core

The core package provides the agent runtime and extension system. It's protocol-agnostic—HTTP, payments, and other capabilities are added via extensions.

Installation

bun add @regent/core

Basic Usage

import { createAgent } from '@regent/core';
import { http } from '@regent/http';

const agent = await createAgent({
  name: 'my-agent',
  version: '1.0.0',
  description: 'An AI-powered assistant',
})
  .use(http())
  .build();

API Reference

createAgent(meta)

Creates an AgentBuilder for constructing an agent with extensions.

Parameters:

Parameter
Type
Description

meta

AgentMeta

Agent metadata (name, version, description, etc.)

Returns: AgentBuilder - A fluent builder for configuring the agent.

AgentMeta

AgentBuilder

Fluent builder for composing extensions.

.use(extension)

Adds an extension to the agent:

Extensions are applied in order. Each extension can access context from previous extensions.

.addEntrypoint(def)

Adds an entrypoint definition:

.build()

Builds the agent runtime:

AgentRuntime

The built agent runtime:

AgentCore

Core agent functionality:

Extension System

Extension Interface

BuildContext

Lifecycle Hooks

Hook
When Called
Purpose

build

During .build()

Initialize extension, return runtime slice

onEntrypointAdded

After addEntrypoint()

React to new entrypoints

onBuild

After all extensions built

Final setup (can be async)

onManifestBuild

When building Agent Card

Enhance manifest

Creating a Custom Extension

Conflict Detection

The builder detects when extensions add the same property:

EntrypointDef

Handler Types

EntrypointHandler

EntrypointStreamHandler

AgentContext

Usage

Validation

Exports

Last updated