0.1.40 • Published 10 months ago

@defikitdotnet/public-agent-module v0.1.40

Weekly downloads
-
License
-
Repository
-
Last release
10 months ago

Public Agent Management Module

A module for the Agent Framework that enables users to publish their AI agents publicly and provides a listing to view and interact with published agents.

Features

  • Publish agents to make them publicly accessible
  • List all published agents
  • View details of specific published agents
  • Send messages to published agents
  • Unpublish agents to hide them from the public listing

API Endpoints

MethodEndpointDescription
GET/api/agents/publicGet all published agents
GET/api/agents/public/:idGet details of a published agent
POST/api/agents/:id/publishPublish an agent
POST/api/agents/:id/unpublishUnpublish an agent
POST/api/agents/:id/messageSend a message to a published agent

Database Schema

The module uses the following database schema:

-- Existing accounts table (referenced only)
CREATE TABLE IF NOT EXISTS "accounts" ( 
  "id" TEXT PRIMARY KEY, 
  "createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 
  "name" TEXT, 
  "username" TEXT, 
  "email" TEXT, 
  "avatarUrl" TEXT, 
  "details" TEXT DEFAULT '{}' CHECK(json_valid("details")), 
  "character" TEXT CHECK(json_valid("character")),
  "status" TEXT DEFAULT 'active' CHECK(status IN ('active', 'inactive', 'deleted')),
  "createdBy" TEXT DEFAULT 'did:privy:cm6077sr4041241z02cdo6hpv',
  "isExportData" BOOLEAN DEFAULT 0,
  "type" TEXT DEFAULT 'user' CHECK(type IN ('user', 'agent'))
);

-- Public agents table
CREATE TABLE IF NOT EXISTS "public_agents" ( 
  "agentId" TEXT PRIMARY KEY REFERENCES accounts(id) ON DELETE CASCADE, 
  "publishedAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 
  "status" TEXT DEFAULT 'published' CHECK(status IN ('published', 'unpublished'))
);

Installation

pnpm add public-agent-management

Usage

Backend Setup

import express from 'express';
import { initializeBackend } from 'public-agent-management';
import { sqliteAdapter } from '@elizaos/adapter-sqlite';

const app = express();
app.use(express.json());

// Create database adapter
const dbAdapter = sqliteAdapter.createAdapter({
  databasePath: './data/myapp.db',
});

// Initialize the public agent management module
initializeBackend(app, dbAdapter);

app.listen(3000, () => {
  console.log('Server running on port 3000');
});

Environment Variables

Create a .env file with the following configuration:

AGENT_MESSAGING_ENDPOINT=http://localhost:3001/api/agent/message

API Examples

Publish an Agent

curl -X POST http://localhost:3000/api/agents/agent-123/publish

Get Published Agents

curl http://localhost:3000/api/agents/public

Send a Message to an Agent

curl -X POST http://localhost:3000/api/agents/agent-123/message \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello, agent!", "userId": "user-456"}'

Development

# Clone the repository
git clone [repository-url]

# Navigate to the module directory
cd examples/public-agent-management

# Install dependencies
pnpm install

# Start the development server
pnpm run backend

License

MIT

0.1.40

10 months ago

0.1.39

10 months ago

0.1.38

10 months ago

0.1.37

10 months ago

0.1.36

10 months ago

0.1.35

10 months ago

0.1.34

10 months ago

0.1.33

10 months ago

0.1.32

10 months ago

0.1.31

10 months ago

0.1.30

10 months ago

0.1.29

10 months ago

0.1.28

10 months ago

0.1.27

10 months ago

0.1.26

10 months ago

0.1.25

10 months ago

0.1.24

10 months ago

0.1.23

10 months ago

0.1.22

10 months ago

0.1.21

10 months ago

0.1.20

10 months ago

0.1.19

10 months ago

0.1.18

10 months ago

0.1.17

10 months ago

0.1.16

10 months ago

0.1.15

10 months ago

0.1.14

10 months ago

0.1.13

10 months ago

0.1.12

10 months ago

0.1.11

10 months ago

0.1.10

10 months ago

0.1.9

10 months ago

0.1.8

10 months ago

0.1.7

10 months ago

0.1.6

10 months ago

0.1.5

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.2

10 months ago

0.1.1

10 months ago