# AGENT 19: AI AGENTS INTEGRATION
## 5-Phase Implementation Prompts
---
## PROMPT 1: AGENT FRAMEWORK INTEGRATIONS
**Context:** Build integrations for major AI agent frameworks to use UCM tools.
**Objective:** Create plug-and-play integrations for 15+ agent frameworks.
**Requirements:**
1. **LangChain Toolkit** (`packages/integrations/langchain/toolkit.ts`)
```typescript
import { StructuredTool } from 'langchain/tools';
import { UCMClient } from '@ucm/sdk';
export class UCMToolkit {
private client: UCMClient;
constructor(config: UCMConfig) {
this.client = new UCMClient(config);
}
async getTools(options?: GetToolsOptions): Promise<StructuredTool[]> {
const tools = await this.client.tools.list({
categories: options?.categories,
});
return tools.map(tool => this.createLangChainTool(tool));
}
private createLangChainTool(tool: UCMTool): StructuredTool {
return new StructuredTool({
name: tool.id,
description: tool.description,
schema: this.convertSchema(tool.inputSchema),
func: async (input) => {
const result = await this.client.tools.execute(tool.id, input);
return JSON.stringify(result);
},
});
}
}
```
2. **CrewAI Integration** (`packages/integrations/crewai/tools.py`)
```python
from crewai import Tool
from ucm import UCMClient
class UCMTools:
def __init__(self, api_key: str):
self.client = UCMClient(api_key=api_key)
def get_tools(self, categories: list[str] = None) -> list[Tool]:
"""Get CrewAI tools from UCM"""
ucm_tools = self.client.tools.list(categories=categories)
return [
Tool(
name=tool.id,
description=tool.description,
func=lambda params, t=tool: self.client.tools.execute(t.id, params)
)
for tool in ucm_tools
]
def get_market_data_crew(self) -> list[Tool]:
"""Pre-configured market data tools"""
return self.get_tools(categories=["market-data"])
def get_defi_crew(self) -> list[Tool]:
"""Pre-configured DeFi tools"""
return self.get_tools(categories=["defi"])
```
3. **AutoGPT Plugin** (`packages/integrations/autogpt/plugin.py`)
```python
from auto_gpt_plugin_template import AutoGPTPluginTemplate
from ucm import UCMClient
class UCMPlugin(AutoGPTPluginTemplate):
def __init__(self):
super().__init__()
self.client = UCMClient(api_key=os.environ["UCM_API_KEY"])
def can_handle_post_command(self) -> bool:
return True
def post_command(self, command_name: str, response: str) -> str:
# Log tool usage
return response
def get_commands(self) -> dict:
tools = self.client.tools.list()
return {
tool.id: {
"description": tool.description,
"method": self._create_method(tool),
"signature": self._create_signature(tool),
}
for tool in tools
}
```
4. **Eliza Integration** (`packages/integrations/eliza/actions.ts`)
```typescript
import { Action, IAgentRuntime } from '@ai16z/eliza';
import { UCMClient } from '@ucm/sdk';
export function createUCMActions(client: UCMClient): Action[] {
const tools = client.tools.listSync();
return tools.map(tool => ({
name: tool.id,
description: tool.description,
similes: tool.aliases || [],
validate: async (runtime: IAgentRuntime, message) => {
// Validate tool can be used
return true;
},
handler: async (runtime: IAgentRuntime, message, state) => {
const params = extractParams(message, tool.inputSchema);
const result = await client.tools.execute(tool.id, params);
return {
text: formatResult(result),
data: result,
};
},
examples: tool.examples?.map(ex => [
{ user: 'user', content: ex.prompt },
{ user: 'assistant', content: ex.response },
]) || [],
}));
}
```
**Technical Stack:**
- LangChain
- CrewAI
- AutoGPT
- Eliza
- BabyAGI
**Deliverables:**
- LangChain toolkit
- CrewAI tools
- AutoGPT plugin
- Eliza actions
---
## PROMPT 2: AGENT ORCHESTRATION UI
**Context:** Build UI for configuring and managing AI agents with UCM tools.
**Objective:** Create visual agent builder and management interface.
**Requirements:**
1. **Agent Builder** (`website-unified/app/(agents)/builder/page.tsx`)
```typescript
export default function AgentBuilderPage() {
const [agent, setAgent] = useState<AgentConfig>({
name: '',
description: '',
framework: 'langchain',
tools: [],
model: 'gpt-4',
systemPrompt: '',
});
return (
<div className="agent-builder">
<AgentConfigForm agent={agent} onChange={setAgent} />
<div className="builder-panels">
<ToolSelector
selected={agent.tools}
onSelect={(tools) => setAgent({ ...agent, tools })}
/>
<AgentPreview agent={agent} />
<SystemPromptEditor
value={agent.systemPrompt}
onChange={(prompt) => setAgent({ ...agent, systemPrompt: prompt })}
/>
</div>
<div className="actions">
<Button onClick={() => testAgent(agent)}>Test Agent</Button>
<Button onClick={() => deployAgent(agent)}>Deploy</Button>
</div>
</div>
);
}
```
2. **Tool Selector** (`website-unified/components/agents/ToolSelector.tsx`)
```typescript
interface ToolSelectorProps {
selected: string[];
onSelect: (tools: string[]) => void;
}
export function ToolSelector({ selected, onSelect }: ToolSelectorProps) {
const { data: tools } = useTools();
const [filter, setFilter] = useState('');
const categories = useMemo(() =>
groupBy(tools, 'category'),
[tools]
);
return (
<div className="tool-selector">
<SearchInput
value={filter}
onChange={setFilter}
placeholder="Search tools..."
/>
<div className="categories">
{Object.entries(categories).map(([category, categoryTools]) => (
<Accordion key={category} title={category}>
{categoryTools.map(tool => (
<ToolItem
key={tool.id}
tool={tool}
selected={selected.includes(tool.id)}
onToggle={() => {
if (selected.includes(tool.id)) {
onSelect(selected.filter(id => id !== tool.id));
} else {
onSelect([...selected, tool.id]);
}
}}
/>
))}
</Accordion>
))}
</div>
<SelectedToolsSummary tools={selected} />
</div>
);
}
```
3. **Agent Testing Interface** (`website-unified/components/agents/AgentTester.tsx`)
```typescript
export function AgentTester({ agent }: { agent: AgentConfig }) {
const [messages, setMessages] = useState<Message[]>([]);
const [input, setInput] = useState('');
const [isRunning, setIsRunning] = useState(false);
const sendMessage = async () => {
const userMessage = { role: 'user', content: input };
setMessages(prev => [...prev, userMessage]);
setInput('');
setIsRunning(true);
try {
const response = await fetch('/api/agents/test', {
method: 'POST',
body: JSON.stringify({
agent,
messages: [...messages, userMessage],
}),
});
const stream = response.body;
// Handle streaming response
} finally {
setIsRunning(false);
}
};
return (
<div className="agent-tester">
<MessageList messages={messages} />
<ToolCallsViewer calls={getToolCalls(messages)} />
<ChatInput
value={input}
onChange={setInput}
onSend={sendMessage}
disabled={isRunning}
/>
</div>
);
}
```
4. **Agent Deployment** (`website-unified/components/agents/AgentDeployment.tsx`)
```typescript
export function AgentDeployment({ agent }: { agent: AgentConfig }) {
const [deployment, setDeployment] = useState<DeploymentConfig>({
target: 'api', // 'api' | 'discord' | 'telegram' | 'slack'
scaling: 'auto',
rateLimit: 100,
});
const deploy = async () => {
const result = await fetch('/api/agents/deploy', {
method: 'POST',
body: JSON.stringify({ agent, deployment }),
});
return result.json();
};
return (
<div className="agent-deployment">
<DeploymentTargetSelector
value={deployment.target}
onChange={(target) => setDeployment({ ...deployment, target })}
/>
{deployment.target === 'api' && (
<APIDeploymentConfig config={deployment} onChange={setDeployment} />
)}
{deployment.target === 'discord' && (
<DiscordDeploymentConfig config={deployment} onChange={setDeployment} />
)}
<DeploymentPreview agent={agent} deployment={deployment} />
<Button onClick={deploy}>Deploy Agent</Button>
</div>
);
}
```
**Technical Requirements:**
- Visual builder
- Drag-and-drop tools
- Real-time testing
- Streaming responses
- Deployment options
**Deliverables:**
- Agent builder page
- Tool selector
- Testing interface
- Deployment wizard
---
## PROMPT 3: AGENT MARKETPLACE
**Context:** Create marketplace for sharing and discovering AI agents.
**Objective:** Build agent marketplace with templates, sharing, and monetization.
**Requirements:**
1. **Agent Marketplace Page** (`website-unified/app/(agents)/marketplace/page.tsx`)
```typescript
export default function AgentMarketplacePage() {
const [filters, setFilters] = useState<AgentFilters>({});
const { data: agents } = useAgents(filters);
return (
<div className="agent-marketplace">
<header>
<h1>Agent Marketplace</h1>
<p>Discover and deploy AI agents for crypto</p>
</header>
<AgentFilters filters={filters} onChange={setFilters} />
<div className="featured">
<h2>Featured Agents</h2>
<AgentCarousel agents={agents?.featured} />
</div>
<div className="categories">
<AgentCategoryGrid
categories={[
{ name: 'Trading', icon: '📈', count: 45 },
{ name: 'Research', icon: '🔍', count: 32 },
{ name: 'Portfolio', icon: '💼', count: 28 },
{ name: 'DeFi', icon: '🏦', count: 56 },
{ name: 'NFT', icon: '🖼️', count: 19 },
{ name: 'Security', icon: '🔒', count: 23 },
]}
/>
</div>
<div className="all-agents">
<h2>All Agents</h2>
<AgentGrid agents={agents?.all} />
</div>
</div>
);
}
```
2. **Agent Card** (`website-unified/components/agents/AgentCard.tsx`)
```typescript
interface AgentCardProps {
agent: Agent;
}
export function AgentCard({ agent }: AgentCardProps) {
return (
<Card className="agent-card">
<CardHeader>
<AgentIcon framework={agent.framework} />
<div>
<CardTitle>{agent.name}</CardTitle>
<CardDescription>{agent.shortDescription}</CardDescription>
</div>
</CardHeader>
<CardContent>
<div className="stats">
<Stat icon="⭐" value={agent.rating} label="Rating" />
<Stat icon="📥" value={agent.downloads} label="Uses" />
<Stat icon="🔧" value={agent.toolCount} label="Tools" />
</div>
<div className="tools-preview">
{agent.tools.slice(0, 5).map(tool => (
<ToolBadge key={tool} tool={tool} />
))}
{agent.tools.length > 5 && (
<Badge>+{agent.tools.length - 5} more</Badge>
)}
</div>
<div className="pricing">
{agent.pricing.type === 'free' ? (
<Badge variant="success">Free</Badge>
) : (
<span>${agent.pricing.price}/month</span>
)}
</div>
</CardContent>
<CardFooter>
<Button variant="outline" asChild>
<Link href={`/agents/${agent.id}`}>View Details</Link>
</Button>
<Button>Use Agent</Button>
</CardFooter>
</Card>
);
}
```
3. **Agent Templates** (`website-unified/lib/agents/templates.ts`)
```typescript
export const agentTemplates: AgentTemplate[] = [
{
id: 'market-analyst',
name: 'Market Analyst',
description: 'Analyze crypto markets with AI',
framework: 'langchain',
tools: [
'getTokenPrice',
'getMarketCap',
'getTrendingTokens',
'getHistoricalPrice',
'getSocialSentiment',
],
systemPrompt: `You are an expert crypto market analyst...`,
examples: [
{ input: 'Analyze BTC market conditions', output: '...' },
],
},
{
id: 'defi-assistant',
name: 'DeFi Assistant',
description: 'Help users with DeFi operations',
framework: 'langchain',
tools: [
'getSwapQuote',
'getLendingRates',
'getPoolInfo',
'getYieldOpportunities',
'checkPositionHealth',
],
systemPrompt: `You are a DeFi expert assistant...`,
},
{
id: 'portfolio-manager',
name: 'Portfolio Manager',
description: 'Track and manage crypto portfolio',
framework: 'crewai',
tools: [
'getWalletBalance',
'getTokenPrices',
'getPortfolioHistory',
'calculatePnL',
'getAssetAllocation',
],
systemPrompt: `You are a portfolio management assistant...`,
},
];
```
4. **Agent Analytics** (`website-unified/components/agents/AgentAnalytics.tsx`)
```typescript
export function AgentAnalytics({ agentId }: { agentId: string }) {
const { data: analytics } = useAgentAnalytics(agentId);
return (
<div className="agent-analytics">
<div className="stats-grid">
<StatCard
title="Total Uses"
value={analytics?.totalUses}
trend={analytics?.usesTrend}
/>
<StatCard
title="Active Users"
value={analytics?.activeUsers}
trend={analytics?.usersTrend}
/>
<StatCard
title="Avg. Rating"
value={analytics?.avgRating}
suffix="/5"
/>
<StatCard
title="Revenue"
value={analytics?.revenue}
prefix="$"
/>
</div>
<div className="charts">
<UsageChart data={analytics?.usageHistory} />
<ToolUsageBreakdown data={analytics?.toolUsage} />
</div>
<div className="feedback">
<h3>Recent Feedback</h3>
<FeedbackList feedback={analytics?.recentFeedback} />
</div>
</div>
);
}
```
**Technical Requirements:**
- Agent discovery
- Template system
- Usage analytics
- Rating system
- Revenue sharing
**Deliverables:**
- Marketplace page
- Agent cards
- Template library
- Analytics dashboard
---
## PROMPT 4: AUTONOMOUS AGENT CAPABILITIES
**Context:** Enable agents to perform autonomous operations with proper safeguards.
**Objective:** Build secure autonomous execution framework.
**Requirements:**
1. **Agent Execution Engine** (`website-unified/lib/agents/executor.ts`)
```typescript
export class AgentExecutor {
private client: UCMClient;
private limits: ExecutionLimits;
constructor(config: ExecutorConfig) {
this.client = new UCMClient(config.apiKey);
this.limits = config.limits;
}
async execute(agent: AgentConfig, task: Task): Promise<ExecutionResult> {
const session = await this.createSession(agent, task);
try {
while (!session.isComplete && session.stepCount < this.limits.maxSteps) {
const action = await this.getNextAction(session);
if (action.type === 'tool_call') {
await this.validateToolCall(action, session);
const result = await this.executeToolCall(action);
session.addResult(action, result);
} else if (action.type === 'complete') {
session.complete(action.result);
} else if (action.type === 'approval_needed') {
await this.requestApproval(action, session);
}
session.stepCount++;
}
return session.getResult();
} finally {
await this.cleanup(session);
}
}
private async validateToolCall(action: ToolCall, session: Session): Promise<void> {
// Check if tool requires approval
if (this.requiresApproval(action.tool)) {
throw new ApprovalRequiredError(action);
}
// Check spending limits
if (action.estimatedCost > session.remainingBudget) {
throw new BudgetExceededError(action);
}
// Validate parameters
await this.validateParameters(action);
}
}
```
2. **Approval System** (`website-unified/components/agents/ApprovalQueue.tsx`)
```typescript
export function ApprovalQueue({ agentId }: { agentId: string }) {
const { data: pending } = usePendingApprovals(agentId);
const approve = async (approvalId: string) => {
await fetch(`/api/agents/approvals/${approvalId}/approve`, {
method: 'POST',
});
};
const reject = async (approvalId: string, reason: string) => {
await fetch(`/api/agents/approvals/${approvalId}/reject`, {
method: 'POST',
body: JSON.stringify({ reason }),
});
};
return (
<div className="approval-queue">
<h2>Pending Approvals</h2>
{pending?.map(approval => (
<ApprovalCard key={approval.id} approval={approval}>
<ActionPreview action={approval.action} />
<RiskAssessment risk={approval.risk} />
<div className="actions">
<Button variant="destructive" onClick={() => reject(approval.id, '')}>
Reject
</Button>
<Button onClick={() => approve(approval.id)}>
Approve
</Button>
</div>
</ApprovalCard>
))}
</div>
);
}
```
3. **Spending Limits** (`website-unified/lib/agents/limits.ts`)
```typescript
export interface SpendingLimits {
perTransaction: bigint;
perHour: bigint;
perDay: bigint;
perMonth: bigint;
allowedTokens: string[];
allowedProtocols: string[];
}
export class SpendingLimitManager {
async checkLimit(
agentId: string,
action: ToolCall
): Promise<LimitCheckResult> {
const limits = await this.getLimits(agentId);
const usage = await this.getUsage(agentId);
const cost = await this.estimateCost(action);
if (cost > limits.perTransaction) {
return { allowed: false, reason: 'Exceeds per-transaction limit' };
}
if (usage.hourly + cost > limits.perHour) {
return { allowed: false, reason: 'Exceeds hourly limit' };
}
// ... more checks
return { allowed: true };
}
async recordSpending(agentId: string, amount: bigint): Promise<void> {
await this.db.agentSpending.create({
data: { agentId, amount, timestamp: new Date() },
});
}
}
```
4. **Agent Monitoring** (`website-unified/components/agents/AgentMonitor.tsx`)
```typescript
export function AgentMonitor({ agentId }: { agentId: string }) {
const { data: status } = useAgentStatus(agentId);
const { data: logs } = useAgentLogs(agentId);
return (
<div className="agent-monitor">
<div className="status-header">
<StatusIndicator status={status?.state} />
<h2>{status?.name}</h2>
<div className="uptime">Uptime: {formatDuration(status?.uptime)}</div>
</div>
<div className="metrics">
<MetricCard
label="Active Tasks"
value={status?.activeTasks}
/>
<MetricCard
label="Completed Today"
value={status?.completedToday}
/>
<MetricCard
label="Spent Today"
value={formatCurrency(status?.spentToday)}
/>
<MetricCard
label="Remaining Budget"
value={formatCurrency(status?.remainingBudget)}
/>
</div>
<div className="logs">
<h3>Activity Log</h3>
<LogViewer logs={logs} />
</div>
<div className="controls">
<Button onClick={() => pauseAgent(agentId)}>Pause</Button>
<Button variant="destructive" onClick={() => stopAgent(agentId)}>
Stop
</Button>
</div>
</div>
);
}
```
**Technical Requirements:**
- Secure execution
- Approval workflows
- Spending limits
- Real-time monitoring
- Emergency stop
**Deliverables:**
- Execution engine
- Approval system
- Spending limits
- Monitoring dashboard
---
## PROMPT 5: MULTI-AGENT COORDINATION
**Context:** Enable multiple agents to work together on complex tasks.
**Objective:** Build multi-agent coordination and communication system.
**Requirements:**
1. **Agent Crew System** (`website-unified/lib/agents/crew.ts`)
```typescript
export class AgentCrew {
private agents: Map<string, Agent>;
private coordinator: CoordinatorAgent;
constructor(config: CrewConfig) {
this.coordinator = new CoordinatorAgent(config.coordinator);
config.agents.forEach(agent => {
this.agents.set(agent.role, new Agent(agent));
});
}
async execute(task: Task): Promise<CrewResult> {
// Coordinator breaks down task
const subtasks = await this.coordinator.planTask(task);
// Execute subtasks with appropriate agents
const results = await Promise.all(
subtasks.map(async subtask => {
const agent = this.agents.get(subtask.role);
return agent.execute(subtask);
})
);
// Coordinator synthesizes results
return this.coordinator.synthesize(results);
}
async addAgent(agent: AgentConfig): void {
this.agents.set(agent.role, new Agent(agent));
}
async removeAgent(role: string): void {
this.agents.delete(role);
}
}
```
2. **Crew Builder UI** (`website-unified/app/(agents)/crew/builder/page.tsx`)
```typescript
export default function CrewBuilderPage() {
const [crew, setCrew] = useState<CrewConfig>({
name: '',
coordinator: null,
agents: [],
communication: 'sequential',
});
return (
<div className="crew-builder">
<CrewConfigForm crew={crew} onChange={setCrew} />
<div className="agent-slots">
<CoordinatorSlot
agent={crew.coordinator}
onSelect={(agent) => setCrew({ ...crew, coordinator: agent })}
/>
<div className="worker-agents">
{crew.agents.map((agent, i) => (
<AgentSlot
key={i}
agent={agent}
onUpdate={(updated) => {
const agents = [...crew.agents];
agents[i] = updated;
setCrew({ ...crew, agents });
}}
onRemove={() => {
setCrew({
...crew,
agents: crew.agents.filter((_, j) => j !== i),
});
}}
/>
))}
<AddAgentButton
onClick={() => setCrew({
...crew,
agents: [...crew.agents, { role: '', agent: null }],
})}
/>
</div>
</div>
<CommunicationFlow
mode={crew.communication}
agents={crew.agents}
onChange={(mode) => setCrew({ ...crew, communication: mode })}
/>
<CrewTestPanel crew={crew} />
</div>
);
}
```
3. **Agent Communication** (`website-unified/lib/agents/communication.ts`)
```typescript
export class AgentCommunicationHub {
private channels: Map<string, Channel>;
private messageQueue: MessageQueue;
constructor() {
this.channels = new Map();
this.messageQueue = new MessageQueue();
}
async sendMessage(from: string, to: string, message: AgentMessage): Promise<void> {
const channel = this.getChannel(from, to);
await channel.send(message);
// Log for debugging
this.logMessage(from, to, message);
}
async broadcast(from: string, message: AgentMessage): Promise<void> {
const agents = this.getAllAgents();
await Promise.all(
agents
.filter(a => a !== from)
.map(to => this.sendMessage(from, to, message))
);
}
subscribe(agentId: string, callback: MessageCallback): Unsubscribe {
return this.messageQueue.subscribe(agentId, callback);
}
async getConversation(agent1: string, agent2: string): Promise<AgentMessage[]> {
const channel = this.getChannel(agent1, agent2);
return channel.getHistory();
}
}
```
4. **Crew Execution Viewer** (`website-unified/components/agents/CrewExecutionViewer.tsx`)
```typescript
export function CrewExecutionViewer({ executionId }: { executionId: string }) {
const { data: execution } = useCrewExecution(executionId);
return (
<div className="crew-execution-viewer">
<div className="task-overview">
<h2>{execution?.task.name}</h2>
<ProgressBar progress={execution?.progress} />
<StatusBadge status={execution?.status} />
</div>
<div className="agent-activities">
{execution?.agents.map(agent => (
<AgentActivityCard key={agent.id}>
<AgentHeader agent={agent} />
<CurrentTask task={agent.currentTask} />
<ThinkingProcess thoughts={agent.thoughts} />
<ToolCalls calls={agent.toolCalls} />
</AgentActivityCard>
))}
</div>
<div className="communication-log">
<h3>Agent Communication</h3>
<MessageTimeline messages={execution?.messages} />
</div>
<div className="results">
<h3>Results</h3>
<ResultViewer result={execution?.result} />
</div>
</div>
);
}
```
**Technical Requirements:**
- Multi-agent orchestration
- Agent communication
- Task decomposition
- Result synthesis
- Visualization
**Deliverables:**
- Crew system
- Crew builder UI
- Communication hub
- Execution viewer
---
**Integration Notes:**
- Uses UCM tools
- Integrates with marketplace
- Wallet for agent operations
- Spending limits enforced
- Complete audit trail
**Success Criteria:**
- 15+ framework integrations
- Visual agent builder
- Agent marketplace
- Safe autonomous execution
- Multi-agent crews
- Real-time monitoring
- Complete logging