connectonion 0.6.3__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.
Files changed (50) hide show
  1. connectonion/__init__.py +1 -1
  2. connectonion/cli/co_ai/agent.py +3 -3
  3. connectonion/cli/co_ai/main.py +2 -2
  4. connectonion/cli/co_ai/plugins/__init__.py +2 -3
  5. connectonion/cli/co_ai/plugins/system_reminder.py +154 -0
  6. connectonion/cli/co_ai/prompts/connectonion/concepts/trust.md +166 -208
  7. connectonion/cli/co_ai/prompts/system-reminders/agent.md +23 -0
  8. connectonion/cli/co_ai/prompts/system-reminders/plan_mode.md +13 -0
  9. connectonion/cli/co_ai/prompts/system-reminders/security.md +14 -0
  10. connectonion/cli/co_ai/prompts/system-reminders/simplicity.md +14 -0
  11. connectonion/cli/co_ai/tools/plan_mode.py +1 -4
  12. connectonion/cli/co_ai/tools/read.py +0 -6
  13. connectonion/cli/commands/copy_commands.py +21 -0
  14. connectonion/cli/commands/trust_commands.py +152 -0
  15. connectonion/cli/main.py +82 -0
  16. connectonion/core/llm.py +2 -2
  17. connectonion/docs/concepts/fast_rules.md +237 -0
  18. connectonion/docs/concepts/onboarding.md +465 -0
  19. connectonion/docs/concepts/plugins.md +2 -1
  20. connectonion/docs/concepts/trust.md +933 -192
  21. connectonion/docs/design-decisions/023-trust-policy-system-design.md +323 -0
  22. connectonion/docs/network/README.md +23 -1
  23. connectonion/docs/network/connect.md +135 -0
  24. connectonion/docs/network/host.md +73 -4
  25. connectonion/docs/useful_plugins/tool_approval.md +139 -0
  26. connectonion/network/__init__.py +7 -6
  27. connectonion/network/asgi/__init__.py +3 -0
  28. connectonion/network/asgi/http.py +125 -19
  29. connectonion/network/asgi/websocket.py +276 -15
  30. connectonion/network/connect.py +145 -29
  31. connectonion/network/host/auth.py +70 -67
  32. connectonion/network/host/routes.py +88 -3
  33. connectonion/network/host/server.py +100 -17
  34. connectonion/network/trust/__init__.py +27 -19
  35. connectonion/network/trust/factory.py +51 -24
  36. connectonion/network/trust/fast_rules.py +100 -0
  37. connectonion/network/trust/tools.py +316 -32
  38. connectonion/network/trust/trust_agent.py +403 -0
  39. connectonion/transcribe.py +1 -1
  40. connectonion/useful_plugins/__init__.py +2 -1
  41. connectonion/useful_plugins/tool_approval.py +233 -0
  42. {connectonion-0.6.3.dist-info → connectonion-0.6.5.dist-info}/METADATA +1 -1
  43. {connectonion-0.6.3.dist-info → connectonion-0.6.5.dist-info}/RECORD +45 -37
  44. connectonion/cli/co_ai/plugins/reminder.py +0 -76
  45. connectonion/cli/co_ai/plugins/shell_approval.py +0 -105
  46. connectonion/cli/co_ai/prompts/reminders/plan_mode.md +0 -34
  47. connectonion/cli/co_ai/reminders.py +0 -159
  48. connectonion/network/trust/prompts.py +0 -71
  49. {connectonion-0.6.3.dist-info → connectonion-0.6.5.dist-info}/WHEEL +0 -0
  50. {connectonion-0.6.3.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.
@@ -54,9 +54,10 @@ agent = Agent("a", plugins=[re_act, logger])
54
54
  | `eval` | Task evaluation for debugging | [eval.md](../useful_plugins/eval.md) |
55
55
  | `image_result_formatter` | Format images for vision models | [image_result_formatter.md](../useful_plugins/image_result_formatter.md) |
56
56
  | `shell_approval` | Approve shell commands before execution | [shell_approval.md](../useful_plugins/shell_approval.md) |
57
+ | `tool_approval` | Web-based approval for dangerous tools | [tool_approval.md](../useful_plugins/tool_approval.md) |
57
58
 
58
59
  ```python
59
- from connectonion.useful_plugins import re_act, eval, image_result_formatter, shell_approval
60
+ from connectonion.useful_plugins import re_act, eval, image_result_formatter, shell_approval, tool_approval
60
61
 
61
62
  # Combine plugins
62
63
  agent = Agent("assistant", plugins=[re_act, image_result_formatter])