A plugin-based agent framework with CLI
Project description
Developer's Guide to AgentForge Plugins
Welcome to the official documentation for creating plugins for AgentForge. This guide will walk you through everything you need to know to build, test, and publish powerful tools on our marketplace.
By building a plugin, you're not just creating a tool; you're creating a new capability for thousands of AI agents, empowering users to automate their world in new and exciting ways.
Getting Started
1. Install the SDK
The AgentForge SDK is a Python package that provides the CLI and base classes for development. Install it via pip:
pip install agentforge-sdk
2. Initialize Your Project
Use the ag-cli tool to bootstrap a new plugin project:
ag-cli init my-weather-plugin
This command creates a new directory with a sample tool and your manifest file, agentforge.json.
The Manifest File (agentforge.json)
The manifest is a JSON file that defines your plugin. It's the central configuration file that the AgentForge platform reads to understand your plugin's capabilities, dependencies, and metadata.
{
"manifestVersion": "1.0.0",
"name": "Weather Reporter",
"pluginId": "com.yourname.weather-reporter",
"version": "1.0.0",
"author": "Your Name <your.email@example.com>",
"description": "A plugin to get real-time weather information.",
"roleName": "Weather Specialist",
"personaPrompt": "You are a friendly weather assistant. You provide clear and concise weather updates.",
"tools": [ ... ],
"requirements": [ "requests" ],
"configurationSchema": [ ... ]
}
Key fields include pluginId, personaPrompt, and tools.
Creating a Tool
A tool is a single, executable function that an AI agent can call. Your tool code should reside in the tools/ directory. Every tool class must inherit from BaseTool and implement a run method.
from agentforge_sdk.base import BaseTool, ToolContext
class GetCurrentWeatherTool(BaseTool):
def run(self, **kwargs) -> str:
location = kwargs.get("location")
if not location:
return "Error: Please specify a location."
# Your API call logic here...
return f"The weather in {location} is sunny and 25°C."
Using User Configuration
If your tool needs sensitive information like an API key, define it in the configurationSchema section of your manifest. This creates a secure form for the user.
In your manifest:
"configurationSchema": [
{
"name": "weather_api_key",
"label": "Weather API Key",
"type": "secret",
"required": true,
"help_text": "Your API key from weatherapi.com"
}
]
Access this value in your tool's code via the ToolContext:
class GetCurrentWeatherTool(BaseTool):
def __init__(self, context: ToolContext):
super().__init__(context)
self.api_key = self.context.get_config("weather_api_key")
def run(self, **kwargs) -> str:
# Use self.api_key in your request
...
Handling File Uploads
Your plugin can process files directly uploaded by users, such as text files, CSVs, or images. This is achieved using the special parameter type file_id.
Step 1: Declare a file_id Parameter in Your Manifest
"tools": [
{
"name": "analyze_csv",
"description": "Analyzes the data in a user-uploaded CSV file.",
"entrypoint": "tools.csv_analyzer:CSVAnalyzerTool",
"parameters": [
{
"name": "csv_file_ref",
"type": "file_id",
"description": "The reference ID of the CSV file to analyze.",
"required": true
}
]
}
]
Step 2: Receive the File Path in Your Tool
When a user invokes your tool with a file, the AgentForge platform automatically resolves the file ID to a secure, temporary file path on the server. Your tool's run method will receive this path as a simple string.
import csv
class CSVAnalyzerTool(BaseTool):
def run(self, **kwargs) -> str:
# The argument name "csv_file_ref" matches the manifest
file_path = kwargs.get("csv_file_ref")
if not file_path:
return "Error: File reference was not provided."
try:
with open(file_path, 'r', encoding='utf-8') as f:
reader = csv.reader(f)
row_count = sum(1 for row in reader)
return f"Successfully analyzed the CSV file. It contains {row_count} rows."
except FileNotFoundError:
return "Error: The specified file could not be found on the server."
except Exception as e:
return f"An error occurred while processing the file: {str(e)}"
Saving Output Files (Artifacts)
If your plugin generates new files (e.g., reports, processed CSVs, or images), you should save them using the get_artifacts_path method from the context. This ensures files are stored in the correct location and are accessible to the user.
Example:
class CSVAnalyzerTool(BaseTool):
def run(self, **kwargs) -> str:
output_path = self.context.get_artifacts_path("summary.txt")
output_path.write_text("Analysis complete: 120 rows processed.", encoding="utf-8")
return f"Report saved to {output_path}"
How It Works Behind the Scenes
- A user uploads a file, e.g.,
sales_report.csv. - The system displays it in the chat with a unique Reference ID, e.g.,
[File: sales_report.csv, ID: 123]. - The user prompts: "Analyze the data in file 123".
- The LLM intelligently calls your tool:
analyze_csv(csv_file_ref="123"). - The AgentForge platform intercepts this call. It looks up ID "123", finds its secure path (
/tmp/path/to/sales_report.csv), and replaces the ID with the path. - Your tool's
runmethod is finally executed withkwargs={'csv_file_ref': '/tmp/path/to/sales_report.csv'}.
Validating & Packaging
Before uploading, always validate your manifest to catch common errors:
cd my-weather-plugin
ag-cli validate
Once validation passes, package your plugin into an .afp file, ready for upload:
ag-cli package
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentforge_sdk-0.1.2.tar.gz.
File metadata
- Download URL: agentforge_sdk-0.1.2.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ee88a89a0d84f641d626f055a7e4f12b71b5eb27078ab7b37a06dbb33653fc4
|
|
| MD5 |
4e316747f8c888de584a2486f5b02fee
|
|
| BLAKE2b-256 |
af590a30b3c979cc80d92fcd7e0bb779f5f401a74ebafd34c665b4fec01a7073
|
File details
Details for the file agentforge_sdk-0.1.2-py3-none-any.whl.
File metadata
- Download URL: agentforge_sdk-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b83be81f244883e9d31f264b2b5625ffa15b4a3fdf9b098e5d67bb361cb8249a
|
|
| MD5 |
9074becd78712267ba17403e1f0c6814
|
|
| BLAKE2b-256 |
9604ca83f7320f1f965be97a6eac3e676ff3140fceaba587b798f716039cc2d5
|