connectonion 0.6.4__py3-none-any.whl → 0.6.5__py3-none-any.whl
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.
- connectonion/__init__.py +1 -1
- connectonion/cli/co_ai/main.py +2 -2
- connectonion/cli/co_ai/prompts/connectonion/concepts/trust.md +166 -208
- connectonion/cli/commands/copy_commands.py +21 -0
- connectonion/cli/commands/trust_commands.py +152 -0
- connectonion/cli/main.py +82 -0
- connectonion/core/llm.py +2 -2
- connectonion/docs/concepts/fast_rules.md +237 -0
- connectonion/docs/concepts/onboarding.md +465 -0
- connectonion/docs/concepts/trust.md +933 -192
- connectonion/docs/design-decisions/023-trust-policy-system-design.md +323 -0
- connectonion/docs/network/README.md +23 -1
- connectonion/docs/network/connect.md +135 -0
- connectonion/docs/network/host.md +73 -4
- connectonion/network/__init__.py +7 -6
- connectonion/network/asgi/__init__.py +3 -0
- connectonion/network/asgi/http.py +125 -19
- connectonion/network/asgi/websocket.py +276 -15
- connectonion/network/connect.py +145 -29
- connectonion/network/host/auth.py +70 -67
- connectonion/network/host/routes.py +88 -3
- connectonion/network/host/server.py +100 -17
- connectonion/network/trust/__init__.py +27 -19
- connectonion/network/trust/factory.py +51 -24
- connectonion/network/trust/fast_rules.py +100 -0
- connectonion/network/trust/tools.py +316 -32
- connectonion/network/trust/trust_agent.py +403 -0
- connectonion/transcribe.py +1 -1
- {connectonion-0.6.4.dist-info → connectonion-0.6.5.dist-info}/METADATA +1 -1
- {connectonion-0.6.4.dist-info → connectonion-0.6.5.dist-info}/RECORD +32 -27
- connectonion/network/trust/prompts.py +0 -71
- {connectonion-0.6.4.dist-info → connectonion-0.6.5.dist-info}/WHEEL +0 -0
- {connectonion-0.6.4.dist-info → connectonion-0.6.5.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
# Trust Onboarding in ConnectOnion
|
|
2
|
+
|
|
3
|
+
Control who can use your agent by defining onboarding requirements in natural language.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from connectonion import Agent, host
|
|
9
|
+
|
|
10
|
+
def translate(text: str, target: str) -> str:
|
|
11
|
+
"""Translate text to target language."""
|
|
12
|
+
return f"Translated: {text}"
|
|
13
|
+
|
|
14
|
+
agent = Agent("translator", tools=[translate])
|
|
15
|
+
|
|
16
|
+
# Just host it - onboarding defined in docstring
|
|
17
|
+
host(agent)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Add trust policy to your agent's docstring:
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
"""
|
|
24
|
+
Translation Agent
|
|
25
|
+
|
|
26
|
+
# Trust Policy
|
|
27
|
+
|
|
28
|
+
## Stranger → Contact
|
|
29
|
+
New users can access by:
|
|
30
|
+
- Entering invite code
|
|
31
|
+
- Transferring 100 credits
|
|
32
|
+
|
|
33
|
+
## Contact → Whitelist
|
|
34
|
+
Promote users who have:
|
|
35
|
+
- Completed 50 tasks
|
|
36
|
+
- 95% satisfaction rate
|
|
37
|
+
|
|
38
|
+
## Access Levels
|
|
39
|
+
- Strangers: REJECTED
|
|
40
|
+
- Contacts: 10,000 tokens, 60s timeout
|
|
41
|
+
- Whitelist: 50,000 tokens, 300s timeout
|
|
42
|
+
"""
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
That's it! The system reads your policy and enforces it automatically.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## How It Works
|
|
50
|
+
|
|
51
|
+
### Three Status Levels
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
Stranger → Contact → Whitelist
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Stranger**: Unknown users who haven't onboarded yet
|
|
58
|
+
**Contact**: Users who passed onboarding, building reputation
|
|
59
|
+
**Whitelist**: Proven reliable users with full access
|
|
60
|
+
|
|
61
|
+
### Trust Progression
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
1. Stranger discovers your agent
|
|
65
|
+
GET /info → "Need invite code or 100 credits"
|
|
66
|
+
|
|
67
|
+
2. Stranger checks their status
|
|
68
|
+
POST /status → "You're a stranger, onboard first"
|
|
69
|
+
|
|
70
|
+
3. Stranger onboards
|
|
71
|
+
POST /onboard → Provides invite code or transfers credits
|
|
72
|
+
|
|
73
|
+
4. Now they're a contact
|
|
74
|
+
POST /status → "You're a contact, 47/50 tasks to whitelist"
|
|
75
|
+
|
|
76
|
+
5. After proving reliability
|
|
77
|
+
You manually promote them to whitelist
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Onboarding Methods
|
|
83
|
+
|
|
84
|
+
### 1. Invite Codes
|
|
85
|
+
|
|
86
|
+
Simple codes for beta access or exclusive entry.
|
|
87
|
+
|
|
88
|
+
```markdown
|
|
89
|
+
## Stranger → Contact
|
|
90
|
+
- Enter invite code
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**How it works:**
|
|
94
|
+
- Admin creates codes in oo-frontend dashboard
|
|
95
|
+
- User provides code during onboarding
|
|
96
|
+
- System verifies with oo-api (one-time use)
|
|
97
|
+
- User added to contacts
|
|
98
|
+
|
|
99
|
+
### 2. Credit Transfer
|
|
100
|
+
|
|
101
|
+
Users transfer credits from their account to yours.
|
|
102
|
+
|
|
103
|
+
```markdown
|
|
104
|
+
## Stranger → Contact
|
|
105
|
+
- Transfer 100 credits
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**How it works:**
|
|
109
|
+
- User buys credits on oo-frontend
|
|
110
|
+
- User transfers credits to your agent
|
|
111
|
+
- System verifies transfer with oo-api
|
|
112
|
+
- User added to contacts
|
|
113
|
+
|
|
114
|
+
### 3. Skill Test
|
|
115
|
+
|
|
116
|
+
Test users locally before granting access.
|
|
117
|
+
|
|
118
|
+
```markdown
|
|
119
|
+
## Stranger → Contact
|
|
120
|
+
- Pass translation test (5 phrases, 80% accuracy)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**How it works:**
|
|
124
|
+
- User requests onboarding
|
|
125
|
+
- Your agent runs a test
|
|
126
|
+
- Agent evaluates response
|
|
127
|
+
- If passed, user added to contacts
|
|
128
|
+
|
|
129
|
+
### 4. Social Proof
|
|
130
|
+
|
|
131
|
+
Existing users vouch for new users.
|
|
132
|
+
|
|
133
|
+
```markdown
|
|
134
|
+
## Stranger → Contact
|
|
135
|
+
- Get vouched by 2 existing contacts
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**How it works:**
|
|
139
|
+
- Two contacts sign vouches
|
|
140
|
+
- User submits signed vouches
|
|
141
|
+
- Agent verifies signatures locally
|
|
142
|
+
- User added to contacts
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Access Control
|
|
147
|
+
|
|
148
|
+
Define different limits for each status level:
|
|
149
|
+
|
|
150
|
+
```markdown
|
|
151
|
+
## Access Levels
|
|
152
|
+
- Strangers: REJECTED (must onboard first)
|
|
153
|
+
- Contacts: 10,000 tokens, 60s timeout
|
|
154
|
+
- Whitelist: unlimited tokens, 300s timeout
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The system automatically applies these limits based on user status.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Promotion to Whitelist
|
|
162
|
+
|
|
163
|
+
Define criteria for automatic eligibility:
|
|
164
|
+
|
|
165
|
+
```markdown
|
|
166
|
+
## Contact → Whitelist
|
|
167
|
+
Users become eligible after:
|
|
168
|
+
- 50 successful tasks
|
|
169
|
+
- 95% satisfaction rate
|
|
170
|
+
- No violations in 30 days
|
|
171
|
+
- Response time under 5 seconds
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Note:** Promotion is manual. The system shows eligibility, but you decide when to promote.
|
|
175
|
+
|
|
176
|
+
Check eligibility:
|
|
177
|
+
```bash
|
|
178
|
+
# User checks their progress
|
|
179
|
+
POST /status → Shows "47/50 tasks, eligible soon"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Promote manually:
|
|
183
|
+
```bash
|
|
184
|
+
# Edit whitelist file
|
|
185
|
+
echo '0xUserPublicKey' >> .co/trust/whitelist.json
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Storage
|
|
191
|
+
|
|
192
|
+
All trust data stored locally in `.co/trust/`:
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
.co/trust/
|
|
196
|
+
├── contacts.json # Who's onboarded, their stats
|
|
197
|
+
├── whitelist.json # Promoted users
|
|
198
|
+
└── blacklist.json # Blocked users
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### contacts.json
|
|
202
|
+
|
|
203
|
+
Flexible schema - add any fields you want:
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"0xUserPublicKey": {
|
|
208
|
+
"onboarded_at": 1640000000,
|
|
209
|
+
"method": "invite_code:BETA123",
|
|
210
|
+
"tasks_completed": 47,
|
|
211
|
+
"satisfaction_rate": 0.96,
|
|
212
|
+
"notes": "Early adopter",
|
|
213
|
+
"custom_field": "anything"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Client Usage
|
|
221
|
+
|
|
222
|
+
### From Browser (TypeScript)
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
import { AgentClient } from 'connectonion-ts';
|
|
226
|
+
|
|
227
|
+
const client = new AgentClient({
|
|
228
|
+
agentUrl: 'https://translator.example.com'
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// Check status
|
|
232
|
+
const status = await client.getStatus();
|
|
233
|
+
console.log(status.status); // "stranger"
|
|
234
|
+
|
|
235
|
+
// Onboard
|
|
236
|
+
await client.onboard('invite_code', {
|
|
237
|
+
invite_code: 'BETA123'
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Now use the agent
|
|
241
|
+
const result = await client.ask('translate hello');
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### From Python
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
from connectonion import connect
|
|
248
|
+
|
|
249
|
+
# Connect to remote agent
|
|
250
|
+
translator = connect("https://translator.example.com")
|
|
251
|
+
|
|
252
|
+
# Check status
|
|
253
|
+
status = translator.status()
|
|
254
|
+
print(status['status']) # "stranger"
|
|
255
|
+
|
|
256
|
+
# Onboard
|
|
257
|
+
translator.onboard("invite_code", invite_code="BETA123")
|
|
258
|
+
|
|
259
|
+
# Use the agent
|
|
260
|
+
result = translator.input("translate hello")
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Endpoints
|
|
266
|
+
|
|
267
|
+
### GET /info - Public discovery
|
|
268
|
+
No authentication required. Anyone can check requirements.
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
curl https://translator.example.com/info
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Returns:
|
|
275
|
+
```json
|
|
276
|
+
{
|
|
277
|
+
"name": "translator",
|
|
278
|
+
"requirements": {
|
|
279
|
+
"onboarding": {
|
|
280
|
+
"methods": ["invite_code", "payment"]
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### POST /status - Check your status
|
|
287
|
+
Requires signature. Shows your current status and progress.
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
# Signed request
|
|
291
|
+
POST /status
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Returns:
|
|
295
|
+
```json
|
|
296
|
+
{
|
|
297
|
+
"status": "contact",
|
|
298
|
+
"access": "allowed",
|
|
299
|
+
"stats": {
|
|
300
|
+
"tasks_completed": 47,
|
|
301
|
+
"satisfaction_rate": 0.96
|
|
302
|
+
},
|
|
303
|
+
"whitelist_eligibility": {
|
|
304
|
+
"eligible": false,
|
|
305
|
+
"progress": {
|
|
306
|
+
"tasks_completed": "47/50"
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### POST /onboard - Onboard yourself
|
|
313
|
+
Requires signature. Provide proof of eligibility.
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
# Signed request
|
|
317
|
+
POST /onboard
|
|
318
|
+
{
|
|
319
|
+
"method": "invite_code",
|
|
320
|
+
"invite_code": "BETA123"
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Returns:
|
|
325
|
+
```json
|
|
326
|
+
{
|
|
327
|
+
"success": true,
|
|
328
|
+
"message": "Onboarded via invite code",
|
|
329
|
+
"status": "contact"
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Examples
|
|
336
|
+
|
|
337
|
+
### Beta Access Only
|
|
338
|
+
|
|
339
|
+
```markdown
|
|
340
|
+
# Trust Policy
|
|
341
|
+
|
|
342
|
+
## Stranger → Contact
|
|
343
|
+
- Enter beta invite code
|
|
344
|
+
|
|
345
|
+
## Access Levels
|
|
346
|
+
- Strangers: REJECTED
|
|
347
|
+
- Contacts: 5,000 tokens, 30s timeout
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Paid Service
|
|
351
|
+
|
|
352
|
+
```markdown
|
|
353
|
+
# Trust Policy
|
|
354
|
+
|
|
355
|
+
## Stranger → Contact
|
|
356
|
+
- Transfer 200 credits
|
|
357
|
+
|
|
358
|
+
## Contact → Whitelist
|
|
359
|
+
- 100 tasks completed
|
|
360
|
+
- 98% satisfaction
|
|
361
|
+
|
|
362
|
+
## Access Levels
|
|
363
|
+
- Strangers: REJECTED
|
|
364
|
+
- Contacts: 10,000 tokens, 60s timeout
|
|
365
|
+
- Whitelist: unlimited tokens
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Community-Based
|
|
369
|
+
|
|
370
|
+
```markdown
|
|
371
|
+
# Trust Policy
|
|
372
|
+
|
|
373
|
+
## Stranger → Contact
|
|
374
|
+
- Get vouched by 3 existing contacts
|
|
375
|
+
|
|
376
|
+
## Contact → Whitelist
|
|
377
|
+
- 30 tasks completed
|
|
378
|
+
- 90% satisfaction
|
|
379
|
+
- No violations in 60 days
|
|
380
|
+
|
|
381
|
+
## Access Levels
|
|
382
|
+
- Strangers: REJECTED
|
|
383
|
+
- Contacts: 3,000 tokens, 20s timeout
|
|
384
|
+
- Whitelist: 20,000 tokens, 120s timeout
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Mixed Methods
|
|
388
|
+
|
|
389
|
+
```markdown
|
|
390
|
+
# Trust Policy
|
|
391
|
+
|
|
392
|
+
## Stranger → Contact
|
|
393
|
+
Choose one method:
|
|
394
|
+
- Enter invite code
|
|
395
|
+
- Transfer 100 credits
|
|
396
|
+
- Pass coding challenge
|
|
397
|
+
- Get vouched by 2 contacts
|
|
398
|
+
|
|
399
|
+
## Access Levels
|
|
400
|
+
- Strangers: REJECTED
|
|
401
|
+
- Contacts: 10,000 tokens, 60s timeout
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## FAQ
|
|
407
|
+
|
|
408
|
+
**Q: Who controls the whitelist?**
|
|
409
|
+
A: You do. Edit `.co/trust/whitelist.json` manually.
|
|
410
|
+
|
|
411
|
+
**Q: Can I use multiple onboarding methods?**
|
|
412
|
+
A: Yes! Users can choose any method you define.
|
|
413
|
+
|
|
414
|
+
**Q: Is contacts.json shared across agents?**
|
|
415
|
+
A: Yes, all agents on your machine share `.co/trust/` data.
|
|
416
|
+
|
|
417
|
+
**Q: What if I lose my keypair?**
|
|
418
|
+
A: You'll need to re-onboard. Keypairs are identity.
|
|
419
|
+
|
|
420
|
+
**Q: Can I customize contact fields?**
|
|
421
|
+
A: Yes! `contacts.json` accepts any fields. Add whatever you need.
|
|
422
|
+
|
|
423
|
+
**Q: How do I revoke access?**
|
|
424
|
+
A: Add public key to `blacklist.json`.
|
|
425
|
+
|
|
426
|
+
**Q: Does this work offline?**
|
|
427
|
+
A: After onboarding (requires oo-api), everything is local and works offline.
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
## Security Notes
|
|
432
|
+
|
|
433
|
+
- All requests signed with Ed25519
|
|
434
|
+
- Invite codes verified once with oo-api
|
|
435
|
+
- Credit transfers verified with oo-api
|
|
436
|
+
- Skill tests run locally (no external verification)
|
|
437
|
+
- Social proof verified via signatures (no external verification)
|
|
438
|
+
- After onboarding, everything is local
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## Progressive Disclosure
|
|
443
|
+
|
|
444
|
+
**Level 0: No onboarding**
|
|
445
|
+
```python
|
|
446
|
+
host(agent) # Anyone can use it
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
**Level 1: Simple trust level**
|
|
450
|
+
```python
|
|
451
|
+
host(agent, trust="strict") # Whitelist only
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**Level 2: Natural language policy**
|
|
455
|
+
```python
|
|
456
|
+
# Add markdown to docstring
|
|
457
|
+
host(agent) # Auto-parsed
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
**Level 3: Custom verification**
|
|
461
|
+
```python
|
|
462
|
+
# Implement custom onboarding logic
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
Start simple, add complexity only when needed.
|