Skip to content

Commit f716a52

Browse files
steinerkelvinclaude
andcommitted
feat: Add v0.5 agent documentation for GEN-31
- Add agent capabilities documentation explaining namespace registration and management - Add demand signaling documentation for expressing capability demands - Add emission stream allocation documentation for compensating other agents - Update navigation to include new agent workflow pages - Follow proper user flow: register agent → serve implementation → signal demands → delegate streams 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 02131b9 commit f716a52

File tree

8 files changed

+1056
-3
lines changed

8 files changed

+1056
-3
lines changed

.direnv/flake-profile

Lines changed: 0 additions & 1 deletion
This file was deleted.

.direnv/flake-profile-3-link

Lines changed: 0 additions & 1 deletion
This file was deleted.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Nix / direnv
2+
/.direnv
3+
14
# build output
25
dist/
36
# generated types
@@ -12,7 +15,6 @@ yarn-debug.log*
1215
yarn-error.log*
1316
pnpm-debug.log*
1417

15-
1618
# environment variables
1719
.env
1820
.env.production

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"cSpell.words": ["alice", "keypair"]
3+
}

astro.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ export default defineConfig({
4646
{ label: "Agent Application", slug: "agents/application" },
4747
{ label: "Register an Agent", slug: "agents/register-agent" },
4848
{ label: "Register a Root Agent", slug: "agents/register-root-agent" },
49+
{ label: "Agent Capabilities", slug: "agents/agent-capabilities" },
4950
{ label: "Agent Server Setup", slug: "agents/server-setup" },
5051
{ label: "Agent Client", slug: "agents/client" },
52+
{ label: "Demand Signaling", slug: "agents/demand-signaling" },
53+
{ label: "Emission Stream Allocation", slug: "agents/emission-stream-allocation" },
5154
{ label: "Managing Your Agent", slug: "agents/management" },
5255
],
5356
},
Lines changed: 314 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,314 @@
1+
---
2+
title: Agent Capabilities
3+
description: Learn how agents register and manage their capabilities within namespaces.
4+
prev:
5+
link: /agents/register-agent
6+
label: Register an Agent
7+
next:
8+
link: /agents/demand-signaling
9+
label: Demand Signaling
10+
---
11+
12+
import {
13+
Aside,
14+
Card,
15+
CardGrid,
16+
Code,
17+
Tabs,
18+
TabItem,
19+
} from "@astrojs/starlight/components";
20+
21+
When you register an agent, it automatically receives a namespace in the format `agent.<agent_name>`. This namespace serves as your agent's capability registry within the Torus Control Space, allowing you to organize and manage the specific services your agent provides.
22+
23+
## Understanding Agent Namespaces
24+
25+
Every registered agent gets an exclusive namespace that follows the hierarchical structure:
26+
27+
```
28+
agent.<agent_name>.<capability_path>
29+
```
30+
31+
For example, if you register an agent named "alice", you automatically own:
32+
33+
- `agent.alice` (root namespace)
34+
- `agent.alice.*` (all sub-paths)
35+
36+
## Namespace Hierarchy
37+
38+
Your agent namespace enables you to organize capabilities in a logical hierarchy:
39+
40+
### Memory Agent Example
41+
42+
```
43+
agent.alice.memory # Root memory capability
44+
agent.alice.memory.twitter # Twitter-specific memory
45+
agent.alice.memory.discord # Discord-specific memory
46+
agent.alice.memory.long-term # Long-term memory storage
47+
agent.alice.memory.search # Memory search functionality
48+
```
49+
50+
### Trading Agent Example
51+
52+
```
53+
agent.trader-bot.analyze # Market analysis capability
54+
agent.trader-bot.execute # Trade execution capability
55+
agent.trader-bot.risk # Risk management capability
56+
agent.trader-bot.portfolio # Portfolio management
57+
```
58+
59+
## Capability Registration
60+
61+
### On-Chain Registration Required
62+
63+
**Important**: Capability entries must be manually registered on-chain through blockchain transactions. The Agent Server code does not automatically register capabilities - it only implements the functionality for namespace paths that have been registered.
64+
65+
The registration process involves:
66+
67+
1. **Register Agent**: First register your agent to get the base namespace
68+
2. **Register Capability Entries**: For each capability your agent provides, register the namespace path on-chain
69+
3. **Implement Agent Server**: Write code that responds to the registered namespace paths
70+
4. **Configure Permissions**: Set up access control for who can use each capability
71+
72+
### Registration Process
73+
74+
<Tabs>
75+
<TabItem label="On-Chain Registration">
76+
Each capability must be registered as a namespace permission on the blockchain:
77+
78+
```ts
79+
// This is done through blockchain transactions, not code
80+
// Example: Registering agent.alice.memory.store capability
81+
82+
const capability = {
83+
namespace: "agent.alice.memory.store",
84+
grantor: "5FgfC2DY4yreEWEughz46RZYQ8oBhHVqD9fVq6gV89E6z4Ea", // Agent owner
85+
duration: "indefinite",
86+
revocation: "revocable_by_grantor",
87+
};
88+
89+
// Submit transaction to register this capability entry
90+
await api.tx.permission0
91+
.grantNamespacePermission(
92+
capability.namespace,
93+
capability.duration,
94+
capability.revocation
95+
)
96+
.signAndSend(agentOwnerKeypair);
97+
```
98+
99+
</TabItem>
100+
<TabItem label="Agent Server Implementation">
101+
After registering the capability on-chain, implement the corresponding functionality:
102+
103+
```ts
104+
import { AgentServer } from "@torus-network/torus-ts-sdk";
105+
106+
const agent = new AgentServer({
107+
agentKey: "5FgfC2DY4yreEWEughz46RZYQ8oBhHVqD9fVq6gV89E6z4Ea",
108+
port: 3000,
109+
docs: {
110+
info: {
111+
title: "Alice Memory Agent",
112+
version: "1.0.0",
113+
},
114+
},
115+
});
116+
117+
// This implements functionality for the registered namespace
118+
// The namespace path must already exist on-chain
119+
agent.method(
120+
"memory/store",
121+
{
122+
auth: { required: true },
123+
namespace: {
124+
enabled: true,
125+
path: "agent.alice.memory.store", // Must match on-chain registration
126+
},
127+
input: z.object({
128+
content: z.string(),
129+
tags: z.array(z.string()).optional(),
130+
}),
131+
output: {
132+
ok: {
133+
description: "Memory stored successfully",
134+
schema: z.object({ id: z.string() }),
135+
},
136+
err: {
137+
description: "Storage failed",
138+
schema: z.object({ error: z.string() }),
139+
},
140+
},
141+
},
142+
async (input, context) => {
143+
// Implementation here
144+
return { ok: { id: "mem_123" } };
145+
}
146+
);
147+
148+
agent.run();
149+
```
150+
151+
</TabItem>
152+
</Tabs>
153+
154+
<Aside type="caution" title="Registration Order Matters">
155+
You must register the capability entry on-chain before implementing it in your
156+
Agent Server. The blockchain serves as the source of truth for which
157+
capabilities exist and who can access them.
158+
</Aside>
159+
160+
## Namespace Permissions as Access Control
161+
162+
Once capability entries are registered on-chain, the permission system serves as access control for your Agent Server:
163+
164+
### Permission Verification Flow
165+
166+
1. **User Request**: User sends authenticated request to your agent endpoint
167+
2. **JWT Validation**: Agent Server validates the user's JWT token
168+
3. **Permission Check**: Agent Server queries the blockchain to verify the user has permission for the namespace path
169+
4. **Access Decision**: Grant or deny access based on on-chain permissions
170+
171+
### Permission Types
172+
173+
<CardGrid>
174+
<Card title="Execute Permission" icon="rocket">
175+
Allows users to call the agent's API endpoints for specific capabilities.
176+
</Card>
177+
<Card title="Read Permission" icon="document">
178+
Grants access to capability documentation and schemas.
179+
</Card>
180+
<Card title="Admin Permission" icon="setting">
181+
Provides management access for configuration and monitoring.
182+
</Card>
183+
</CardGrid>
184+
185+
### Granting Access to Users
186+
187+
As the agent owner, you can grant permissions to specific users through blockchain transactions:
188+
189+
```ts
190+
// Grant user permission to access agent.alice.memory.search
191+
await api.tx.permission0
192+
.grantNamespacePermission(
193+
granteeAddress, // User receiving permission
194+
["agent.alice.memory.search"], // Namespace paths
195+
duration, // How long permission lasts
196+
revocationTerms // How permission can be revoked
197+
)
198+
.signAndSend(agentOwnerKeypair);
199+
```
200+
201+
## Capability Discovery
202+
203+
### Through Agent Registry
204+
205+
Users can discover your agent's capabilities through the agent registry:
206+
207+
1. **Browse Agents**: Users browse registered agents in the network
208+
2. **View Capabilities**: See on-chain registered capabilities and their descriptions
209+
3. **Check Permissions**: Understand access requirements
210+
4. **Request Access**: Apply for permission to use capabilities
211+
212+
### Through API Documentation
213+
214+
Your Agent Server automatically generates documentation that includes capability information:
215+
216+
```
217+
https://your-agent.com/docs
218+
```
219+
220+
This includes:
221+
222+
- Available endpoints mapped to namespace paths
223+
- Authentication requirements
224+
- Input/output schemas
225+
- Permission requirements
226+
227+
## Namespace Validation Rules
228+
229+
Your namespace paths must follow strict validation:
230+
231+
- **Character Set**: Lowercase letters, digits, hyphens, underscores only
232+
- **Boundaries**: Must begin and end with alphanumeric characters
233+
- **Length**: 1-63 characters per segment
234+
- **Pattern**: `^[a-z0-9]([a-z0-9-_]{0,61}[a-z0-9])?$`
235+
236+
### Valid Examples
237+
238+
```
239+
agent.alice.memory.store ✓ Valid
240+
agent.trader-bot.analyze ✓ Valid
241+
agent.data_processor.transform ✓ Valid
242+
agent.alice123.service ✓ Valid
243+
```
244+
245+
### Invalid Examples
246+
247+
```
248+
agent.Alice.memory.store ✗ Uppercase letters
249+
agent.alice..memory ✗ Double dots
250+
agent.alice.memory- ✗ Ending with hyphen
251+
agent.alice.memory.very-long-capability-name-that-exceeds-limit ✗ Too long
252+
```
253+
254+
## Best Practices
255+
256+
### Logical Organization
257+
258+
Structure your capabilities logically:
259+
260+
```
261+
agent.alice.memory.* # All memory-related
262+
agent.alice.social.* # Social interaction capabilities
263+
agent.alice.analysis.* # Analysis and processing
264+
agent.alice.integration.* # External integrations
265+
```
266+
267+
### Clear Namespace Naming
268+
269+
Design namespace paths that clearly indicate their purpose:
270+
271+
```
272+
agent.alice.memory.store # Store memories
273+
agent.alice.memory.retrieve # Retrieve specific memories
274+
agent.alice.memory.search # Search through memories
275+
agent.alice.analysis.sentiment # Sentiment analysis
276+
agent.alice.integration.twitter # Twitter integration
277+
```
278+
279+
### Granular Permissions
280+
281+
Design capabilities with appropriate granularity:
282+
283+
- **Too Broad**: `agent.alice.all` (gives access to everything)
284+
- **Too Narrow**: `agent.alice.memory.store.text.short.personal` (overly specific)
285+
- **Just Right**: `agent.alice.memory.store` (focused but flexible)
286+
287+
### Version Management
288+
289+
Consider versioning for evolving capabilities:
290+
291+
```
292+
agent.alice.memory.v1.store # Version 1 interface
293+
agent.alice.memory.v2.store # Version 2 with enhanced features
294+
```
295+
296+
## Next Steps
297+
298+
Once you've registered your agent's capabilities on-chain and implemented them in your Agent Server:
299+
300+
1. **[Signal Demands](/agents/demand-signaling)**: Signal what capabilities you need from other agents
301+
2. **[Allocate Streams](/agents/emission-stream-allocation)**: Compensate other agents that provide value to your operations
302+
3. **[Monitor Usage](/agents/management)**: Track how your capabilities are being used
303+
304+
<CardGrid>
305+
<Card title="Demand Signaling" icon="rocket">
306+
Learn how to signal demands for capabilities from other agents.
307+
</Card>
308+
<Card title="Emission Stream Allocation" icon="seti:pipeline">
309+
Configure emission streams to compensate other agents.
310+
</Card>
311+
<Card title="Namespace Permissions" icon="seti:lock">
312+
Deep dive into the permission system.
313+
</Card>
314+
</CardGrid>

0 commit comments

Comments
 (0)