clodds 1.2.9 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/skills/bundled/acp/SKILL.md +188 -0
- package/dist/skills/bundled/acp/index.d.ts +0 -3
- package/dist/skills/bundled/acp/index.js +1 -1
- package/dist/skills/bundled/acp/index.js.map +1 -1
- package/dist/skills/bundled/agentbets/SKILL.md +19 -0
- package/dist/skills/bundled/agentbets/index.js +1 -1
- package/dist/skills/bundled/agentbets/index.js.map +1 -1
- package/dist/skills/bundled/ai-strategy/SKILL.md +111 -0
- package/dist/skills/bundled/ai-strategy/index.js +1 -1
- package/dist/skills/bundled/ai-strategy/index.js.map +1 -1
- package/dist/skills/bundled/alerts/SKILL.md +87 -0
- package/dist/skills/bundled/analytics/SKILL.md +252 -0
- package/dist/skills/bundled/analytics/index.js +2 -2
- package/dist/skills/bundled/analytics/index.js.map +1 -1
- package/dist/skills/bundled/arbitrage/SKILL.md +287 -0
- package/dist/skills/bundled/arbitrage/index.js +6 -1
- package/dist/skills/bundled/arbitrage/index.js.map +1 -1
- package/dist/skills/bundled/auto-reply/SKILL.md +285 -0
- package/dist/skills/bundled/auto-reply/index.js +2 -2
- package/dist/skills/bundled/auto-reply/index.js.map +1 -1
- package/dist/skills/bundled/automation/SKILL.md +242 -0
- package/dist/skills/bundled/automation/index.js +2 -2
- package/dist/skills/bundled/automation/index.js.map +1 -1
- package/dist/skills/bundled/backtest/SKILL.md +225 -0
- package/dist/skills/bundled/bags/SKILL.md +131 -0
- package/dist/skills/bundled/bankr/SKILL.md +114 -0
- package/dist/skills/bundled/betfair/SKILL.md +113 -0
- package/dist/skills/bundled/binance-futures/SKILL.md +84 -0
- package/dist/skills/bundled/binance-futures/index.d.ts +0 -3
- package/dist/skills/bundled/binance-futures/index.js +1 -2
- package/dist/skills/bundled/binance-futures/index.js.map +1 -1
- package/dist/skills/bundled/botchan/SKILL.md +66 -0
- package/dist/skills/bundled/botchan/index.d.ts +0 -3
- package/dist/skills/bundled/botchan/index.js +0 -1
- package/dist/skills/bundled/botchan/index.js.map +1 -1
- package/dist/skills/bundled/bridge/SKILL.md +215 -0
- package/dist/skills/bundled/bridge/index.js +6 -0
- package/dist/skills/bundled/bridge/index.js.map +1 -1
- package/dist/skills/bundled/bybit-futures/SKILL.md +84 -0
- package/dist/skills/bundled/bybit-futures/index.d.ts +0 -3
- package/dist/skills/bundled/bybit-futures/index.js +0 -1
- package/dist/skills/bundled/bybit-futures/index.js.map +1 -1
- package/dist/skills/bundled/clanker/SKILL.md +125 -0
- package/dist/skills/bundled/clanker/index.d.ts +0 -3
- package/dist/skills/bundled/clanker/index.js +0 -1
- package/dist/skills/bundled/clanker/index.js.map +1 -1
- package/dist/skills/bundled/copy-trading/SKILL.md +285 -0
- package/dist/skills/bundled/copy-trading/index.js +15 -8
- package/dist/skills/bundled/copy-trading/index.js.map +1 -1
- package/dist/skills/bundled/copy-trading-solana/SKILL.md +66 -0
- package/dist/skills/bundled/credentials/SKILL.md +261 -0
- package/dist/skills/bundled/credentials/index.js +4 -0
- package/dist/skills/bundled/credentials/index.js.map +1 -1
- package/dist/skills/bundled/crypto-hft/SKILL.md +121 -0
- package/dist/skills/bundled/crypto-hft/index.js +18 -3
- package/dist/skills/bundled/crypto-hft/index.js.map +1 -1
- package/dist/skills/bundled/dca/SKILL.md +27 -0
- package/dist/skills/bundled/dex/SKILL.md +92 -0
- package/dist/skills/bundled/dex/index.js +77 -29
- package/dist/skills/bundled/dex/index.js.map +1 -1
- package/dist/skills/bundled/divergence/SKILL.md +83 -0
- package/dist/skills/bundled/doctor/SKILL.md +267 -0
- package/dist/skills/bundled/doctor/index.js +2 -8
- package/dist/skills/bundled/doctor/index.js.map +1 -1
- package/dist/skills/bundled/drift/SKILL.md +53 -0
- package/dist/skills/bundled/drift-sdk/SKILL.md +103 -0
- package/dist/skills/bundled/drift-sdk/index.d.ts +0 -3
- package/dist/skills/bundled/drift-sdk/index.js +0 -1
- package/dist/skills/bundled/drift-sdk/index.js.map +1 -1
- package/dist/skills/bundled/edge/SKILL.md +84 -0
- package/dist/skills/bundled/embeddings/SKILL.md +244 -0
- package/dist/skills/bundled/endaoment/SKILL.md +65 -0
- package/dist/skills/bundled/endaoment/index.d.ts +0 -3
- package/dist/skills/bundled/endaoment/index.js +0 -1
- package/dist/skills/bundled/endaoment/index.js.map +1 -1
- package/dist/skills/bundled/ens/SKILL.md +63 -0
- package/dist/skills/bundled/ens/index.d.ts +0 -3
- package/dist/skills/bundled/ens/index.js +0 -1
- package/dist/skills/bundled/ens/index.js.map +1 -1
- package/dist/skills/bundled/erc8004/SKILL.md +79 -0
- package/dist/skills/bundled/erc8004/index.d.ts +0 -3
- package/dist/skills/bundled/erc8004/index.js +0 -1
- package/dist/skills/bundled/erc8004/index.js.map +1 -1
- package/dist/skills/bundled/execution/SKILL.md +278 -0
- package/dist/skills/bundled/farcaster/SKILL.md +80 -0
- package/dist/skills/bundled/farcaster/index.js +12 -0
- package/dist/skills/bundled/farcaster/index.js.map +1 -1
- package/dist/skills/bundled/features/SKILL.md +20 -0
- package/dist/skills/bundled/feeds/SKILL.md +288 -0
- package/dist/skills/bundled/harden/SKILL.md +74 -0
- package/dist/skills/bundled/history/SKILL.md +257 -0
- package/dist/skills/bundled/hyperliquid/SKILL.md +200 -0
- package/dist/skills/bundled/hyperliquid/index.d.ts +0 -3
- package/dist/skills/bundled/hyperliquid/index.js +0 -1
- package/dist/skills/bundled/hyperliquid/index.js.map +1 -1
- package/dist/skills/bundled/identity/SKILL.md +228 -0
- package/dist/skills/bundled/identity/index.js +2 -2
- package/dist/skills/bundled/identity/index.js.map +1 -1
- package/dist/skills/bundled/integrations/SKILL.md +321 -0
- package/dist/skills/bundled/integrations/index.js +2 -2
- package/dist/skills/bundled/integrations/index.js.map +1 -1
- package/dist/skills/bundled/jupiter/SKILL.md +163 -0
- package/dist/skills/bundled/jupiter/index.js +2 -2
- package/dist/skills/bundled/kamino/SKILL.md +69 -0
- package/dist/skills/bundled/ledger/SKILL.md +20 -0
- package/dist/skills/bundled/lighter/SKILL.md +83 -0
- package/dist/skills/bundled/lighter/index.d.ts +0 -3
- package/dist/skills/bundled/lighter/index.js +0 -1
- package/dist/skills/bundled/lighter/index.js.map +1 -1
- package/dist/skills/bundled/marginfi/SKILL.md +62 -0
- package/dist/skills/bundled/market-index/SKILL.md +242 -0
- package/dist/skills/bundled/market-index/index.js +1 -3
- package/dist/skills/bundled/market-index/index.js.map +1 -1
- package/dist/skills/bundled/markets/SKILL.md +49 -0
- package/dist/skills/bundled/mcp/SKILL.md +235 -0
- package/dist/skills/bundled/mcp/index.js +1 -3
- package/dist/skills/bundled/mcp/index.js.map +1 -1
- package/dist/skills/bundled/memory/SKILL.md +209 -0
- package/dist/skills/bundled/metaculus/SKILL.md +62 -0
- package/dist/skills/bundled/metaculus/index.js +4 -1
- package/dist/skills/bundled/metaculus/index.js.map +1 -1
- package/dist/skills/bundled/meteora/SKILL.md +28 -0
- package/dist/skills/bundled/meteora-dbc/SKILL.md +25 -0
- package/dist/skills/bundled/metrics/SKILL.md +338 -0
- package/dist/skills/bundled/mev/SKILL.md +239 -0
- package/dist/skills/bundled/mev/index.js +2 -2
- package/dist/skills/bundled/mev/index.js.map +1 -1
- package/dist/skills/bundled/mexc-futures/SKILL.md +86 -0
- package/dist/skills/bundled/mexc-futures/index.d.ts +0 -3
- package/dist/skills/bundled/mexc-futures/index.js +0 -1
- package/dist/skills/bundled/mexc-futures/index.js.map +1 -1
- package/dist/skills/bundled/mm/SKILL.md +142 -0
- package/dist/skills/bundled/mm/index.js +28 -27
- package/dist/skills/bundled/mm/index.js.map +1 -1
- package/dist/skills/bundled/monitoring/SKILL.md +249 -0
- package/dist/skills/bundled/news/SKILL.md +95 -0
- package/dist/skills/bundled/news/index.js +1 -2
- package/dist/skills/bundled/news/index.js.map +1 -1
- package/dist/skills/bundled/onchainkit/SKILL.md +83 -0
- package/dist/skills/bundled/opinion/SKILL.md +87 -0
- package/dist/skills/bundled/opportunity/SKILL.md +308 -0
- package/dist/skills/bundled/orca/SKILL.md +28 -0
- package/dist/skills/bundled/orca/index.js +11 -7
- package/dist/skills/bundled/orca/index.js.map +1 -1
- package/dist/skills/bundled/pairing/SKILL.md +275 -0
- package/dist/skills/bundled/pancakeswap/SKILL.md +93 -0
- package/dist/skills/bundled/pancakeswap/index.d.ts +0 -3
- package/dist/skills/bundled/pancakeswap/index.js +0 -1
- package/dist/skills/bundled/pancakeswap/index.js.map +1 -1
- package/dist/skills/bundled/percolator/SKILL.md +22 -0
- package/dist/skills/bundled/permissions/SKILL.md +269 -0
- package/dist/skills/bundled/permissions/index.js +2 -2
- package/dist/skills/bundled/permissions/index.js.map +1 -1
- package/dist/skills/bundled/plugins/SKILL.md +263 -0
- package/dist/skills/bundled/plugins/index.js +2 -2
- package/dist/skills/bundled/plugins/index.js.map +1 -1
- package/dist/skills/bundled/portfolio/SKILL.md +161 -0
- package/dist/skills/bundled/portfolio/index.js +1 -1
- package/dist/skills/bundled/portfolio/index.js.map +1 -1
- package/dist/skills/bundled/portfolio-sync/SKILL.md +466 -0
- package/dist/skills/bundled/positions/SKILL.md +262 -0
- package/dist/skills/bundled/predictfun/SKILL.md +109 -0
- package/dist/skills/bundled/predictfun/index.js +1 -1
- package/dist/skills/bundled/predictfun/index.js.map +1 -1
- package/dist/skills/bundled/predictit/SKILL.md +66 -0
- package/dist/skills/bundled/predictit/index.js +4 -1
- package/dist/skills/bundled/predictit/index.js.map +1 -1
- package/dist/skills/bundled/presence/SKILL.md +217 -0
- package/dist/skills/bundled/presence/index.js +2 -2
- package/dist/skills/bundled/presence/index.js.map +1 -1
- package/dist/skills/bundled/processes/SKILL.md +254 -0
- package/dist/skills/bundled/pump-swarm/SKILL.md +309 -0
- package/dist/skills/bundled/pumpfun/SKILL.md +145 -0
- package/dist/skills/bundled/pumpfun/index.js +82 -8
- package/dist/skills/bundled/pumpfun/index.js.map +1 -1
- package/dist/skills/bundled/qmd/SKILL.md +129 -0
- package/dist/skills/bundled/qrcoin/SKILL.md +60 -0
- package/dist/skills/bundled/qrcoin/index.d.ts +0 -3
- package/dist/skills/bundled/qrcoin/index.js +0 -1
- package/dist/skills/bundled/qrcoin/index.js.map +1 -1
- package/dist/skills/bundled/raydium/SKILL.md +198 -0
- package/dist/skills/bundled/remote/SKILL.md +201 -0
- package/dist/skills/bundled/research/SKILL.md +83 -0
- package/dist/skills/bundled/research/index.js +2 -2
- package/dist/skills/bundled/research/index.js.map +1 -1
- package/dist/skills/bundled/risk/SKILL.md +323 -0
- package/dist/skills/bundled/router/SKILL.md +233 -0
- package/dist/skills/bundled/routing/SKILL.md +258 -0
- package/dist/skills/bundled/sandbox/SKILL.md +257 -0
- package/dist/skills/bundled/search-config/SKILL.md +257 -0
- package/dist/skills/bundled/search-config/index.js +2 -2
- package/dist/skills/bundled/search-config/index.js.map +1 -1
- package/dist/skills/bundled/sessions/SKILL.md +251 -0
- package/dist/skills/bundled/sessions/index.js +1 -1
- package/dist/skills/bundled/sessions/index.js.map +1 -1
- package/dist/skills/bundled/setup/SKILL.md +53 -0
- package/dist/skills/bundled/shield/SKILL.md +21 -0
- package/dist/skills/bundled/signals/SKILL.md +106 -0
- package/dist/skills/bundled/signals/index.d.ts +0 -3
- package/dist/skills/bundled/signals/index.js +3 -4
- package/dist/skills/bundled/signals/index.js.map +1 -1
- package/dist/skills/bundled/sizing/SKILL.md +238 -0
- package/dist/skills/bundled/slippage/SKILL.md +306 -0
- package/dist/skills/bundled/smarkets/SKILL.md +107 -0
- package/dist/skills/bundled/smarkets/index.js +3 -3
- package/dist/skills/bundled/smarkets/index.js.map +1 -1
- package/dist/skills/bundled/solend/SKILL.md +63 -0
- package/dist/skills/bundled/strategy/SKILL.md +266 -0
- package/dist/skills/bundled/streaming/SKILL.md +150 -0
- package/dist/skills/bundled/streaming/index.js +2 -2
- package/dist/skills/bundled/streaming/index.js.map +1 -1
- package/dist/skills/bundled/tailscale/SKILL.md +249 -0
- package/dist/skills/bundled/tailscale/index.js +2 -2
- package/dist/skills/bundled/tailscale/index.js.map +1 -1
- package/dist/skills/bundled/ticks/SKILL.md +61 -0
- package/dist/skills/bundled/token-security/SKILL.md +18 -0
- package/dist/skills/bundled/trading-evm/SKILL.md +329 -0
- package/dist/skills/bundled/trading-futures/SKILL.md +865 -0
- package/dist/skills/bundled/trading-kalshi/SKILL.md +629 -0
- package/dist/skills/bundled/trading-kalshi/index.js +2 -0
- package/dist/skills/bundled/trading-kalshi/index.js.map +1 -1
- package/dist/skills/bundled/trading-manifold/SKILL.md +387 -0
- package/dist/skills/bundled/trading-polymarket/SKILL.md +1080 -0
- package/dist/skills/bundled/trading-polymarket/index.js +28 -19
- package/dist/skills/bundled/trading-polymarket/index.js.map +1 -1
- package/dist/skills/bundled/trading-solana/SKILL.md +418 -0
- package/dist/skills/bundled/trading-solana/index.js +1 -1
- package/dist/skills/bundled/trading-solana/index.js.map +1 -1
- package/dist/skills/bundled/trading-system/SKILL.md +290 -0
- package/dist/skills/bundled/triggers/SKILL.md +433 -0
- package/dist/skills/bundled/tts/SKILL.md +220 -0
- package/dist/skills/bundled/tweet-ideas/SKILL.md +77 -0
- package/dist/skills/bundled/usage/SKILL.md +239 -0
- package/dist/skills/bundled/usage/index.js +2 -2
- package/dist/skills/bundled/usage/index.js.map +1 -1
- package/dist/skills/bundled/veil/SKILL.md +76 -0
- package/dist/skills/bundled/veil/index.d.ts +0 -3
- package/dist/skills/bundled/veil/index.js +0 -1
- package/dist/skills/bundled/veil/index.js.map +1 -1
- package/dist/skills/bundled/verify/SKILL.md +199 -0
- package/dist/skills/bundled/verify/index.d.ts +0 -3
- package/dist/skills/bundled/verify/index.js +0 -1
- package/dist/skills/bundled/verify/index.js.map +1 -1
- package/dist/skills/bundled/virtuals/SKILL.md +82 -0
- package/dist/skills/bundled/voice/SKILL.md +217 -0
- package/dist/skills/bundled/voice/index.js +2 -2
- package/dist/skills/bundled/voice/index.js.map +1 -1
- package/dist/skills/bundled/weather/SKILL.md +80 -0
- package/dist/skills/bundled/weather/index.js +3 -0
- package/dist/skills/bundled/weather/index.js.map +1 -1
- package/dist/skills/bundled/webhooks/SKILL.md +297 -0
- package/dist/skills/bundled/webhooks/index.js +2 -2
- package/dist/skills/bundled/webhooks/index.js.map +1 -1
- package/dist/skills/bundled/whale-tracking/SKILL.md +287 -0
- package/dist/skills/bundled/whale-tracking/index.js +2 -2
- package/dist/skills/bundled/whale-tracking/index.js.map +1 -1
- package/dist/skills/bundled/yoink/SKILL.md +54 -0
- package/dist/skills/bundled/yoink/index.d.ts +0 -3
- package/dist/skills/bundled/yoink/index.js +0 -1
- package/dist/skills/bundled/yoink/index.js.map +1 -1
- package/dist/skills/executor.js +5 -3
- package/dist/skills/executor.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: routing
|
|
3
|
+
description: "Multi-agent routing, channel bindings, and tool policies"
|
|
4
|
+
emoji: "🔀"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Routing - Complete API Reference
|
|
8
|
+
|
|
9
|
+
Route messages to specialized agents, configure channel bindings, and manage tool access policies.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Chat Commands
|
|
14
|
+
|
|
15
|
+
### Agent Management
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
/agents List available agents
|
|
19
|
+
/agent trading Switch to trading agent
|
|
20
|
+
/agent research Switch to research agent
|
|
21
|
+
/agent main Switch to main agent
|
|
22
|
+
/agent status Current agent info
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Channel Bindings
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
/bind trading Bind channel to trading agent
|
|
29
|
+
/bind research Bind channel to research agent
|
|
30
|
+
/unbind Remove channel binding
|
|
31
|
+
/bindings List all bindings
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Tool Policies (Admin)
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
/tools List available tools
|
|
38
|
+
/tools allow <agent> <tool> Allow tool for agent
|
|
39
|
+
/tools deny <agent> <tool> Deny tool for agent
|
|
40
|
+
/tools policy <agent> View agent's tool policy
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## TypeScript API Reference
|
|
46
|
+
|
|
47
|
+
### Create Routing Service
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { createRoutingService } from 'clodds/routing';
|
|
51
|
+
|
|
52
|
+
const routing = createRoutingService({
|
|
53
|
+
// Default agent
|
|
54
|
+
defaultAgent: 'main',
|
|
55
|
+
|
|
56
|
+
// Agent definitions
|
|
57
|
+
agents: {
|
|
58
|
+
main: {
|
|
59
|
+
name: 'Main',
|
|
60
|
+
description: 'General assistant',
|
|
61
|
+
model: 'claude-3-sonnet',
|
|
62
|
+
systemPrompt: 'You are a helpful trading assistant...',
|
|
63
|
+
allowedTools: ['*'], // All tools
|
|
64
|
+
},
|
|
65
|
+
trading: {
|
|
66
|
+
name: 'Trading',
|
|
67
|
+
description: 'Order execution specialist',
|
|
68
|
+
model: 'claude-3-haiku',
|
|
69
|
+
systemPrompt: 'You execute trades efficiently...',
|
|
70
|
+
allowedTools: ['execute', 'portfolio', 'markets', 'feeds'],
|
|
71
|
+
},
|
|
72
|
+
research: {
|
|
73
|
+
name: 'Research',
|
|
74
|
+
description: 'Market analysis expert',
|
|
75
|
+
model: 'claude-3-opus',
|
|
76
|
+
systemPrompt: 'You provide deep market analysis...',
|
|
77
|
+
allowedTools: ['web-search', 'web-fetch', 'markets', 'news'],
|
|
78
|
+
},
|
|
79
|
+
alerts: {
|
|
80
|
+
name: 'Alerts',
|
|
81
|
+
description: 'Notification handler',
|
|
82
|
+
model: 'claude-3-haiku',
|
|
83
|
+
systemPrompt: 'You manage price alerts...',
|
|
84
|
+
allowedTools: ['alerts', 'feeds'],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
// Storage
|
|
89
|
+
storage: 'sqlite',
|
|
90
|
+
dbPath: './routing.db',
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Route Message
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
// Route determines best agent
|
|
98
|
+
const route = await routing.route({
|
|
99
|
+
message: 'Buy 100 shares of Trump YES',
|
|
100
|
+
channelId: 'telegram-123',
|
|
101
|
+
userId: 'user-456',
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
console.log(`Routed to: ${route.agent}`);
|
|
105
|
+
console.log(`Confidence: ${route.confidence}`);
|
|
106
|
+
console.log(`Reason: ${route.reason}`);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Get Available Agents
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
const agents = routing.getAgents();
|
|
113
|
+
|
|
114
|
+
for (const [id, agent] of Object.entries(agents)) {
|
|
115
|
+
console.log(`${id}: ${agent.name}`);
|
|
116
|
+
console.log(` ${agent.description}`);
|
|
117
|
+
console.log(` Model: ${agent.model}`);
|
|
118
|
+
console.log(` Tools: ${agent.allowedTools.join(', ')}`);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Add Custom Agent
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
routing.addAgent({
|
|
126
|
+
id: 'defi',
|
|
127
|
+
name: 'DeFi Specialist',
|
|
128
|
+
description: 'Solana and EVM DeFi expert',
|
|
129
|
+
model: 'claude-3-sonnet',
|
|
130
|
+
systemPrompt: 'You are an expert in DeFi protocols...',
|
|
131
|
+
allowedTools: ['solana', 'evm', 'bridge', 'portfolio'],
|
|
132
|
+
patterns: [
|
|
133
|
+
/swap|dex|liquidity|pool/i,
|
|
134
|
+
/solana|jupiter|raydium/i,
|
|
135
|
+
/uniswap|1inch|bridge/i,
|
|
136
|
+
],
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Update Agent
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
routing.updateAgent('trading', {
|
|
144
|
+
model: 'claude-3-sonnet', // Upgrade model
|
|
145
|
+
allowedTools: [...currentTools, 'futures'],
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Channel Bindings
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
// Bind channel to specific agent
|
|
153
|
+
await routing.addBinding({
|
|
154
|
+
channelId: 'telegram-trading-group',
|
|
155
|
+
agentId: 'trading',
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Get binding for channel
|
|
159
|
+
const binding = await routing.getBinding('telegram-trading-group');
|
|
160
|
+
console.log(`Channel bound to: ${binding?.agentId || 'default'}`);
|
|
161
|
+
|
|
162
|
+
// List all bindings
|
|
163
|
+
const bindings = await routing.getBindings();
|
|
164
|
+
for (const b of bindings) {
|
|
165
|
+
console.log(`${b.channelId} → ${b.agentId}`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Remove binding
|
|
169
|
+
await routing.removeBinding('telegram-trading-group');
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Tool Policies
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
// Check if tool is allowed for agent
|
|
176
|
+
const allowed = routing.isToolAllowed('trading', 'web-search');
|
|
177
|
+
console.log(`web-search allowed for trading: ${allowed}`);
|
|
178
|
+
|
|
179
|
+
// Get allowed tools for agent
|
|
180
|
+
const tools = routing.getAllowedTools('trading');
|
|
181
|
+
console.log(`Trading agent tools: ${tools.join(', ')}`);
|
|
182
|
+
|
|
183
|
+
// Update tool policy
|
|
184
|
+
routing.setToolPolicy('trading', {
|
|
185
|
+
allow: ['execute', 'portfolio', 'futures'],
|
|
186
|
+
deny: ['web-search', 'browser'],
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Built-in Agents
|
|
193
|
+
|
|
194
|
+
| Agent | Model | Purpose | Tools |
|
|
195
|
+
|-------|-------|---------|-------|
|
|
196
|
+
| **main** | Sonnet | General assistant | All |
|
|
197
|
+
| **trading** | Haiku | Fast order execution | Execute, Portfolio |
|
|
198
|
+
| **research** | Opus | Deep analysis | Search, Fetch, News |
|
|
199
|
+
| **alerts** | Haiku | Notifications | Alerts, Feeds |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Routing Rules
|
|
204
|
+
|
|
205
|
+
Messages are routed based on:
|
|
206
|
+
|
|
207
|
+
1. **Channel binding** — If channel is bound, use that agent
|
|
208
|
+
2. **Pattern matching** — Match against agent patterns
|
|
209
|
+
3. **Keyword detection** — Trading terms → trading agent
|
|
210
|
+
4. **Default fallback** — Use main agent
|
|
211
|
+
|
|
212
|
+
### Pattern Examples
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
{
|
|
216
|
+
trading: [/buy|sell|order|position|close/i],
|
|
217
|
+
research: [/analyze|research|explain|why/i],
|
|
218
|
+
alerts: [/alert|notify|when|watch/i],
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Tool Categories
|
|
225
|
+
|
|
226
|
+
| Category | Tools |
|
|
227
|
+
|----------|-------|
|
|
228
|
+
| **Execution** | execute, portfolio, markets |
|
|
229
|
+
| **Data** | feeds, news, web-search, web-fetch |
|
|
230
|
+
| **Crypto** | solana, evm, bridge |
|
|
231
|
+
| **System** | files, browser, docker |
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Workspace Isolation
|
|
236
|
+
|
|
237
|
+
Each agent can have isolated workspace:
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
routing.addAgent({
|
|
241
|
+
id: 'research',
|
|
242
|
+
workspace: {
|
|
243
|
+
directory: '/tmp/research',
|
|
244
|
+
allowedPaths: ['/tmp/research/**'],
|
|
245
|
+
sandboxed: true,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Best Practices
|
|
253
|
+
|
|
254
|
+
1. **Use fast models for trading** — Haiku for time-sensitive operations
|
|
255
|
+
2. **Restrict tools appropriately** — Trading agent doesn't need browser
|
|
256
|
+
3. **Channel bindings** — Dedicated channels for specific workflows
|
|
257
|
+
4. **Custom agents** — Create specialized agents for your use case
|
|
258
|
+
5. **Monitor routing** — Check logs to see routing decisions
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sandbox
|
|
3
|
+
description: "Safe code execution in Docker containers with resource limits"
|
|
4
|
+
emoji: "📦"
|
|
5
|
+
gates:
|
|
6
|
+
envs:
|
|
7
|
+
anyOf:
|
|
8
|
+
- DOCKER_HOST
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Sandbox - Complete API Reference
|
|
12
|
+
|
|
13
|
+
Execute code safely in isolated Docker containers with resource limits and timeout protection.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Chat Commands
|
|
18
|
+
|
|
19
|
+
### Run Code
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
/run python "print('Hello')" Run Python code
|
|
23
|
+
/run node "console.log('Hi')" Run JavaScript
|
|
24
|
+
/run bash "ls -la" Run shell command
|
|
25
|
+
/run ruby "puts 'Hello'" Run Ruby code
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### With Options
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
/run python "code" --timeout 30 Set timeout (seconds)
|
|
32
|
+
/run node "code" --memory 512 Memory limit (MB)
|
|
33
|
+
/run python "code" --file script.py From file
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Sandbox Management
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
/sandbox status Container status
|
|
40
|
+
/sandbox images Available images
|
|
41
|
+
/sandbox cleanup Remove old containers
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## TypeScript API Reference
|
|
47
|
+
|
|
48
|
+
### Create Sandbox
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { createSandbox } from 'clodds/sandbox';
|
|
52
|
+
|
|
53
|
+
const sandbox = createSandbox({
|
|
54
|
+
// Docker settings
|
|
55
|
+
dockerHost: process.env.DOCKER_HOST,
|
|
56
|
+
|
|
57
|
+
// Default limits
|
|
58
|
+
defaultTimeoutMs: 30000,
|
|
59
|
+
defaultMemoryMB: 256,
|
|
60
|
+
defaultCpuShares: 512,
|
|
61
|
+
|
|
62
|
+
// Cleanup
|
|
63
|
+
autoCleanup: true,
|
|
64
|
+
maxContainerAgeMs: 3600000,
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Run Code
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// Run Python
|
|
72
|
+
const result = await sandbox.run({
|
|
73
|
+
language: 'python',
|
|
74
|
+
code: `
|
|
75
|
+
import math
|
|
76
|
+
print(f"Pi is {math.pi}")
|
|
77
|
+
`,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
console.log(`Output: ${result.stdout}`);
|
|
81
|
+
console.log(`Exit code: ${result.exitCode}`);
|
|
82
|
+
console.log(`Duration: ${result.durationMs}ms`);
|
|
83
|
+
|
|
84
|
+
// Run with limits
|
|
85
|
+
const result = await sandbox.run({
|
|
86
|
+
language: 'node',
|
|
87
|
+
code: `console.log('Hello from Node.js')`,
|
|
88
|
+
timeout: 10000,
|
|
89
|
+
memoryMB: 128,
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Supported Languages
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// Python
|
|
97
|
+
await sandbox.run({ language: 'python', code: 'print("Hello")' });
|
|
98
|
+
|
|
99
|
+
// JavaScript (Node.js)
|
|
100
|
+
await sandbox.run({ language: 'node', code: 'console.log("Hello")' });
|
|
101
|
+
|
|
102
|
+
// Bash
|
|
103
|
+
await sandbox.run({ language: 'bash', code: 'echo "Hello"' });
|
|
104
|
+
|
|
105
|
+
// Ruby
|
|
106
|
+
await sandbox.run({ language: 'ruby', code: 'puts "Hello"' });
|
|
107
|
+
|
|
108
|
+
// Go
|
|
109
|
+
await sandbox.run({ language: 'go', code: 'package main\nimport "fmt"\nfunc main() { fmt.Println("Hello") }' });
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Run From File
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
const result = await sandbox.runFile({
|
|
116
|
+
language: 'python',
|
|
117
|
+
filePath: '/path/to/script.py',
|
|
118
|
+
args: ['--input', 'data.csv'],
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Install Packages
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
// Python packages
|
|
126
|
+
const result = await sandbox.run({
|
|
127
|
+
language: 'python',
|
|
128
|
+
code: `
|
|
129
|
+
import pandas as pd
|
|
130
|
+
print(pd.__version__)
|
|
131
|
+
`,
|
|
132
|
+
packages: ['pandas', 'numpy'],
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Node packages
|
|
136
|
+
const result = await sandbox.run({
|
|
137
|
+
language: 'node',
|
|
138
|
+
code: `
|
|
139
|
+
const _ = require('lodash');
|
|
140
|
+
console.log(_.VERSION);
|
|
141
|
+
`,
|
|
142
|
+
packages: ['lodash'],
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Resource Limits
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const result = await sandbox.run({
|
|
150
|
+
language: 'python',
|
|
151
|
+
code: 'import time; time.sleep(100)',
|
|
152
|
+
|
|
153
|
+
// Limits
|
|
154
|
+
timeout: 5000, // 5 second timeout
|
|
155
|
+
memoryMB: 256, // 256 MB RAM
|
|
156
|
+
cpuShares: 512, // CPU shares (default 1024)
|
|
157
|
+
networkDisabled: true, // No network access
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Container Management
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
// Get status
|
|
165
|
+
const status = await sandbox.getStatus();
|
|
166
|
+
console.log(`Running containers: ${status.running}`);
|
|
167
|
+
console.log(`Total containers: ${status.total}`);
|
|
168
|
+
|
|
169
|
+
// List available images
|
|
170
|
+
const images = await sandbox.listImages();
|
|
171
|
+
for (const img of images) {
|
|
172
|
+
console.log(`${img.language}: ${img.image}`);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Cleanup old containers
|
|
176
|
+
await sandbox.cleanup({
|
|
177
|
+
olderThan: '1h',
|
|
178
|
+
status: 'exited',
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Language Images
|
|
185
|
+
|
|
186
|
+
| Language | Image | Version |
|
|
187
|
+
|----------|-------|---------|
|
|
188
|
+
| **python** | python:3.11-slim | 3.11 |
|
|
189
|
+
| **node** | node:20-slim | 20.x |
|
|
190
|
+
| **bash** | alpine:latest | Alpine |
|
|
191
|
+
| **ruby** | ruby:3.2-slim | 3.2 |
|
|
192
|
+
| **go** | golang:1.21-alpine | 1.21 |
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Resource Limits
|
|
197
|
+
|
|
198
|
+
| Resource | Default | Max |
|
|
199
|
+
|----------|---------|-----|
|
|
200
|
+
| **Timeout** | 30s | 300s |
|
|
201
|
+
| **Memory** | 256 MB | 2048 MB |
|
|
202
|
+
| **CPU** | 512 shares | 2048 shares |
|
|
203
|
+
| **Disk** | 100 MB | 1 GB |
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Security
|
|
208
|
+
|
|
209
|
+
| Feature | Description |
|
|
210
|
+
|---------|-------------|
|
|
211
|
+
| **Isolation** | Each run in separate container |
|
|
212
|
+
| **No network** | Network disabled by default |
|
|
213
|
+
| **No volumes** | No host filesystem access |
|
|
214
|
+
| **Read-only** | Filesystem is read-only |
|
|
215
|
+
| **Resource caps** | Memory and CPU limits |
|
|
216
|
+
| **Timeout** | Force kill after timeout |
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Use Cases
|
|
221
|
+
|
|
222
|
+
### Run Backtest
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
const result = await sandbox.run({
|
|
226
|
+
language: 'python',
|
|
227
|
+
code: backtestCode,
|
|
228
|
+
packages: ['pandas', 'numpy', 'ta'],
|
|
229
|
+
timeout: 60000,
|
|
230
|
+
memoryMB: 512,
|
|
231
|
+
});
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Data Processing
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
const result = await sandbox.run({
|
|
238
|
+
language: 'python',
|
|
239
|
+
code: `
|
|
240
|
+
import json
|
|
241
|
+
data = ${JSON.stringify(inputData)}
|
|
242
|
+
result = process(data)
|
|
243
|
+
print(json.dumps(result))
|
|
244
|
+
`,
|
|
245
|
+
});
|
|
246
|
+
const output = JSON.parse(result.stdout);
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Best Practices
|
|
252
|
+
|
|
253
|
+
1. **Set timeouts** — Prevent runaway code
|
|
254
|
+
2. **Limit memory** — Avoid OOM
|
|
255
|
+
3. **Disable network** — Unless needed
|
|
256
|
+
4. **Use slim images** — Faster startup
|
|
257
|
+
5. **Cleanup regularly** — Remove old containers
|