Build your first Super Agent CLI plugin in 5 minutes!
- Node.js 18+ or Bun
- Super Agent CLI installed (
npm install -g @involvex/super-agent-cli) - TypeScript knowledge (optional but recommended)
Start with the basic template:
cp -r templates/basic my-plugin
cd my-pluginEdit src/index.ts:
import { SuperAgentPlugin, SuperAgentTool } from "@involvex/super-agent-cli";
const helloTool: SuperAgentTool = {
type: "function",
function: {
name: "say_hello",
description: "Says hello to a person",
parameters: {
type: "object",
properties: {
name: {
type: "string",
description: "Name of the person to greet",
},
},
required: ["name"],
},
executor: async args => {
return `Hello, ${args.name}! 👋`;
},
},
};
export const plugin: SuperAgentPlugin = {
name: "my-plugin",
version: "1.0.0",
description: "My first Super Agent plugin",
tools: [helloTool],
async onInit(context) {
console.log("Plugin initialized!");
},
};
export default plugin;npm install
npm run buildThis creates dist/index.js - your compiled plugin.
# Install the plugin
super-agent plugins install ./dist/index.js
# Test it in interactive mode
super-agent
# In the chat, try:
# "say hello to Alice"The AI should use your say_hello tool automatically when appropriate!
Add additional tools to the tools array:
const farewellTool: SuperAgentTool = {
type: "function",
function: {
name: "say_goodbye",
description: "Says goodbye to a person",
parameters: {
type: "object",
properties: {
name: { type: "string", description: "Name of the person" },
},
required: ["name"],
},
executor: async args => {
return `Goodbye, ${args.name}! 👋`;
},
},
};
export const plugin: SuperAgentPlugin = {
// ... other properties
tools: [helloTool, farewellTool],
};Accept custom configuration in onInit:
async onInit(context) {
const apiKey = context.config.apiKey;
if (!apiKey) {
throw new Error("API key required!");
}
// Initialize your service with the API key
}Users configure via ~/.super-agent/settings.json:
{
"plugins": ["./my-plugin/dist/index.js"],
"pluginConfigs": {
"my-plugin": {
"apiKey": "your-key-here"
}
}
}Always validate inputs and handle errors gracefully:
executor: async args => {
try {
if (!args.name || typeof args.name !== "string") {
throw new Error("Name must be a non-empty string");
}
// Your logic here
return `Hello, ${args.name}!`;
} catch (error) {
return `Error: ${error.message}`;
}
};For API calls or I/O operations:
executor: async args => {
const response = await fetch(`https://api.example.com/greet/${args.name}`);
const data = await response.json();
return data.message;
};For more advanced features, check out the advanced template which includes:
- Multiple tools
- External API integration
- State management
- Error handling
- TypeScript configuration
- Tests
- CI/CD setup
Plugin not loading?
- Check that
dist/index.jsexists - Verify the export:
export default plugin;orexport const plugin = ... - Check the console for error messages
Tool not being called?
- Make sure the
descriptionclearly explains when to use the tool - Test with explicit requests: "use say_hello to greet Bob"
- Check that required parameters are properly defined
Type errors?
- Install type definitions:
npm install -D @involvex/super-agent-cli - Check your
tsconfig.jsonmatches the template
Explore working examples in the examples/ directory:
Happy plugin building! 🎉