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
connectonion/__init__.py CHANGED
@@ -10,7 +10,7 @@ LLM-Note:
10
10
  ConnectOnion - A simple agent framework with behavior tracking.
11
11
  """
12
12
 
13
- __version__ = "0.6.3"
13
+ __version__ = "0.6.5"
14
14
 
15
15
  # Auto-load .env files for the entire framework
16
16
  from dotenv import load_dotenv
@@ -12,9 +12,9 @@ from .tools import (
12
12
  load_guide,
13
13
  )
14
14
  from .skills import skill
15
- from .plugins import reminder_plugin
15
+ from .plugins import system_reminder
16
16
  from connectonion import Agent, bash, after_user_input, FileWriter, MODE_AUTO, MODE_NORMAL, TodoList
17
- from connectonion.useful_plugins import re_act, eval
17
+ from connectonion.useful_plugins import eval, tool_approval
18
18
 
19
19
 
20
20
  PROMPTS_DIR = Path(__file__).parent / "prompts"
@@ -71,7 +71,7 @@ def create_coding_agent(
71
71
  if project_context:
72
72
  system_prompt += f"\n\n---\n\n{project_context}"
73
73
 
74
- plugins = [re_act, eval, reminder_plugin]
74
+ plugins = [eval, system_reminder, tool_approval]
75
75
 
76
76
  agent = Agent(
77
77
  name="oo",
@@ -47,6 +47,6 @@ def start_server(
47
47
  web_mode=True,
48
48
  )
49
49
 
50
- # Start server with open trust (no auth required)
50
+ # Start server with careful trust (requires invite code or payment for strangers)
51
51
  # relay_url=None disables P2P discovery
52
- host(agent_factory, port=port, trust="open", relay_url=None)
52
+ host(agent_factory, port=port, trust="careful", relay_url=None)
@@ -1,6 +1,5 @@
1
1
  """OO Agent plugins."""
2
2
 
3
- from .shell_approval import shell_approval
4
- from .reminder import reminder_plugin
3
+ from .system_reminder import system_reminder
5
4
 
6
- __all__ = ['shell_approval', 'reminder_plugin']
5
+ __all__ = ['system_reminder']
@@ -0,0 +1,154 @@
1
+ """
2
+ System Reminder Plugin - Injects contextual guidance based on intent and tool usage.
3
+
4
+ Two triggers:
5
+ 1. after_user_input: Detect intent (coding, agent creation) and inject relevant reminder
6
+ 2. after_each_tool: Inject reminder based on tool usage
7
+
8
+ Usage:
9
+ from connectonion.cli.co_ai.plugins.system_reminder import system_reminder
10
+
11
+ agent = Agent("coder", plugins=[system_reminder])
12
+ """
13
+
14
+ from pathlib import Path
15
+ import fnmatch
16
+ from typing import TYPE_CHECKING
17
+
18
+ from connectonion.core.events import after_each_tool, after_user_input
19
+ from connectonion.llm_do import llm_do
20
+
21
+ if TYPE_CHECKING:
22
+ from connectonion.core.agent import Agent
23
+
24
+ # Default reminders directory
25
+ REMINDERS_DIR = Path(__file__).parent.parent / "prompts" / "system-reminders"
26
+
27
+ # Intent detection prompt
28
+ INTENT_PROMPT = """Analyze the user's request.
29
+
30
+ User request: {user_prompt}
31
+
32
+ Is this about building software, creating agents, writing code, or automation?
33
+ Respond with ONE word only: "build" or "other"
34
+
35
+ One word only:"""
36
+
37
+
38
+ def _parse_frontmatter(text):
39
+ """Parse YAML frontmatter from markdown."""
40
+ if not text.startswith('---'):
41
+ return {}, text
42
+ parts = text.split('---', 2)
43
+ if len(parts) < 3:
44
+ return {}, text
45
+ import yaml
46
+ return yaml.safe_load(parts[1]) or {}, parts[2].strip()
47
+
48
+
49
+ def _load_reminders(reminders_dir):
50
+ """Load all .md reminder files from directory."""
51
+ reminders_dir = Path(reminders_dir)
52
+ if not reminders_dir.exists():
53
+ return {}
54
+ reminders = {}
55
+ for f in reminders_dir.glob("*.md"):
56
+ meta, body = _parse_frontmatter(f.read_text())
57
+ if meta.get('name'):
58
+ reminders[meta['name']] = {
59
+ 'content': body,
60
+ 'triggers': meta.get('triggers', []),
61
+ 'intent': meta.get('intent'), # New: intent-based trigger
62
+ }
63
+ return reminders
64
+
65
+
66
+ def _matches_pattern(pattern, value):
67
+ """Check if value matches glob pattern(s)."""
68
+ if not pattern or not value:
69
+ return False
70
+ patterns = [pattern] if isinstance(pattern, str) else pattern
71
+ return any(fnmatch.fnmatch(value, p) for p in patterns)
72
+
73
+
74
+ def _find_tool_reminder(reminders, tool_name, args):
75
+ """Find matching reminder for tool usage."""
76
+ for reminder in reminders.values():
77
+ for trigger in reminder['triggers']:
78
+ if trigger.get('tool') and trigger['tool'] != tool_name:
79
+ continue
80
+ if trigger.get('path_pattern'):
81
+ path = args.get('path') or args.get('file_path', '')
82
+ if not _matches_pattern(trigger['path_pattern'], path):
83
+ continue
84
+ if trigger.get('command_pattern'):
85
+ cmd = args.get('command') or args.get('cmd', '')
86
+ if not _matches_pattern(trigger['command_pattern'], cmd):
87
+ continue
88
+ # All conditions matched
89
+ content = reminder['content']
90
+ path = args.get('path') or args.get('file_path', '')
91
+ return content.replace('${file_path}', path).replace('${tool_name}', tool_name)
92
+ return None
93
+
94
+
95
+ def _find_intent_reminder(reminders, intent):
96
+ """Find matching reminder for detected intent."""
97
+ for reminder in reminders.values():
98
+ if reminder.get('intent') == intent:
99
+ return reminder['content']
100
+ return None
101
+
102
+
103
+ # Load reminders once at import
104
+ _REMINDERS = _load_reminders(REMINDERS_DIR)
105
+
106
+
107
+ @after_user_input
108
+ def detect_intent(agent: 'Agent') -> None:
109
+ """Detect user intent and inject relevant system reminder."""
110
+ user_prompt = agent.current_session.get('user_prompt', '')
111
+ if not user_prompt:
112
+ return
113
+
114
+ # Use llm_do to detect intent
115
+ intent = llm_do(
116
+ INTENT_PROMPT.format(user_prompt=user_prompt),
117
+ model="co/gemini-2.5-flash",
118
+ temperature=0,
119
+ ).strip().lower()
120
+
121
+ # Store intent in session
122
+ agent.current_session['intent'] = intent
123
+
124
+ # Find and inject intent-based reminder
125
+ content = _find_intent_reminder(_REMINDERS, intent)
126
+ if content:
127
+ agent.current_session['messages'].append({
128
+ 'role': 'user',
129
+ 'content': f"\n\n{content}"
130
+ })
131
+
132
+
133
+ @after_each_tool
134
+ def inject_tool_reminder(agent: 'Agent') -> None:
135
+ """Inject matching system reminder into tool result."""
136
+ trace = agent.current_session.get('trace', [])
137
+ messages = agent.current_session.get('messages', [])
138
+ if not trace or not messages:
139
+ return
140
+
141
+ last = trace[-1]
142
+ if last.get('type') != 'tool_result':
143
+ return
144
+
145
+ content = _find_tool_reminder(_REMINDERS, last.get('name', ''), last.get('args', {}))
146
+ if content:
147
+ for msg in reversed(messages):
148
+ if msg.get('role') == 'tool':
149
+ msg['content'] = msg.get('content', '') + '\n\n' + content
150
+ break
151
+
152
+
153
+ # Export plugin
154
+ system_reminder = [detect_intent, inject_tool_reminder]
@@ -1,291 +1,249 @@
1
1
  # Trust in ConnectOnion
2
2
 
3
- The `trust` parameter provides flexible, bidirectional trust configuration for agent interactions.
3
+ Trust is a **host layer** concern that controls who can access your agent. It manages onboarding, access control, and client state transitions.
4
4
 
5
5
  ## Quick Start
6
6
 
7
7
  ```python
8
- from connectonion import Agent, need
9
-
10
- # Simple trust levels
11
- translator = need("translate", trust="strict") # Production: verified only
12
- analyzer = need("analyze", trust="tested") # Default: test first
13
- scraper = need("scrape", trust="open") # Development: trust all
14
-
15
- # For your own agent
16
- agent = Agent(
17
- name="my_service",
18
- tools=[process_data],
19
- trust="strict" # Who can use my services
20
- )
8
+ from connectonion import Agent
9
+ from connectonion.network import host
10
+
11
+ # Create your agent (no trust here - agent only cares about its job)
12
+ agent = Agent("my_service", tools=[process_data])
13
+
14
+ # Host it with trust (trust is a host concern)
15
+ host(agent, trust="careful") # Default: verify before allowing access
21
16
  ```
22
17
 
23
- ## Three Forms of Trust
18
+ ## Core Concepts
24
19
 
25
- ### 1. Trust Levels (String)
20
+ ### Separation of Concerns
26
21
 
27
- Simple predefined levels for common scenarios:
22
+ | Layer | Responsibility |
23
+ |-------|----------------|
24
+ | **Agent** | What it does (skills, tools, reasoning) |
25
+ | **Host** | How it's accessed (network, trust, security) |
28
26
 
29
27
  ```python
30
- # Development - trust everyone
31
- agent = need("service", trust="open")
28
+ # Agent is pure - only cares about its job
29
+ agent = Agent("translator", tools=[translate])
32
30
 
33
- # Default - test before trusting
34
- agent = need("service", trust="tested")
35
-
36
- # Production - only verified/whitelisted
37
- agent = need("service", trust="strict")
31
+ # Trust is configured at host level
32
+ host(agent, trust="open") # Dev: trust everyone
33
+ host(agent, trust="careful") # Staging: verify first
34
+ host(agent, trust="strict") # Prod: whitelist only
38
35
  ```
39
36
 
40
- ### 2. Trust Policy (Natural Language)
37
+ ### Two-Tier Verification
41
38
 
42
- Express complex requirements in plain English:
39
+ | Type | Tokens | When to Use |
40
+ |------|--------|-------------|
41
+ | **Fast Rules** | Zero | Simple checks (invite code, payment, whitelist) |
42
+ | **Trust Agent** | Burns tokens | Complex decisions (behavior analysis, edge cases) |
43
43
 
44
- ```python
45
- # Inline policy
46
- translator = need("translate", trust="""
47
- I trust agents that:
48
- - Pass capability tests
49
- - Respond within 500ms
50
- - Are on my whitelist OR from local network
51
- """)
52
-
53
- # From file
54
- translator = need("translate", trust="./trust_policy.md")
55
- ```
44
+ 90% of requests use fast rules (instant, free). 10% use trust agent (LLM reasoning, rare).
56
45
 
57
- Example trust policy file:
58
- ```markdown
59
- # My Trust Requirements
46
+ ## Trust Levels
60
47
 
61
- I trust agents that meet ALL of these criteria:
62
- - Successfully translate "Hello" to "Hola"
63
- - Respond in less than 1 second
64
- - Have processed at least 10 requests successfully
48
+ ### Open (Development)
65
49
 
66
- I immediately reject agents that:
67
- - Fail basic capability tests
68
- - Take longer than 5 seconds
69
- - Are on my blacklist
70
- ```
50
+ Trust everyone. No verification.
71
51
 
72
- ### 3. Trust Agent
52
+ ```python
53
+ host(agent, trust="open")
54
+ ```
73
55
 
74
- For maximum control, use a custom trust agent:
56
+ Use for: Local development, Jupyter notebooks, testing.
75
57
 
76
- ```python
77
- # Create a trust agent with verification tools
78
- trust_agent = Agent(
79
- name="my_guardian",
80
- tools=[
81
- check_whitelist,
82
- verify_capability,
83
- measure_response_time,
84
- check_reputation
85
- ],
86
- system_prompt="""
87
- You verify other agents before allowing interaction.
88
- Be strict with payment processors, relaxed with read-only services.
89
- """
90
- )
58
+ ### Careful (Default)
91
59
 
92
- # Use it for your agent
93
- my_agent = Agent(
94
- name="my_service",
95
- tools=[process_payment],
96
- trust=trust_agent # My guardian protects me
97
- )
60
+ Verify strangers before granting access. Fast rules first, then trust agent for complex cases.
98
61
 
99
- # And for discovering services
100
- payment = need("payment processor", trust=trust_agent)
62
+ ```python
63
+ host(agent, trust="careful")
101
64
  ```
102
65
 
103
- ## Bidirectional Trust
66
+ Use for: Staging, testing, pre-production.
67
+
68
+ ### Strict (Production)
104
69
 
105
- The same `trust` parameter works in both directions:
70
+ Whitelist only. No exceptions.
106
71
 
107
72
  ```python
108
- # As a SERVICE provider (who can use me?)
109
- alice_agent = Agent(
110
- name="alice_translator",
111
- tools=[translate],
112
- trust="tested" # Users must pass my tests
113
- )
73
+ host(agent, trust="strict")
74
+ ```
75
+
76
+ Use for: Production, sensitive data, payments.
114
77
 
115
- # As a SERVICE consumer (who do I trust?)
116
- translator = need("translate", trust="strict") # I only use verified services
78
+ ## Client States
117
79
 
118
- # Both trust requirements must be satisfied for interaction!
119
80
  ```
81
+ Promotion Chain (earned trust):
120
82
 
121
- ## Trust Flow Example
83
+ ┌─────────────┐ verify ┌─────────────┐ earn trust ┌─────────────┐
84
+ │ Stranger │ ──────────► │ Contact │ ───────────► │ Whitelist │
85
+ └─────────────┘ └─────────────┘ └─────────────┘
86
+ │ │ │
87
+ │ block │ demote │ demote
88
+ ▼ ▼ ▼
89
+ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
90
+ │ Blocklist │ │ Stranger │ │ Contact │
91
+ └─────────────┘ └─────────────┘ └─────────────┘
122
92
 
123
- ```python
124
- # Alice creates a translation service
125
- alice = Agent(
126
- name="alice_translator",
127
- tools=[translate],
128
- trust="tested" # Test users before serving them
129
- )
130
- share(alice)
131
93
 
132
- # Bob looks for a translator
133
- translator = need(
134
- "translate to Spanish",
135
- trust="strict" # Bob only uses verified services
136
- )
94
+ Admin (separate, manual only):
137
95
 
138
- # What happens:
139
- # 1. Bob's trust agent evaluates Alice (strict check)
140
- # 2. Alice's trust agent evaluates Bob (test required)
141
- # 3. Both must approve for connection to succeed
96
+ ┌─────────────┐ set_admin() ┌─────────────┐
97
+ │ Any Level │ ─────────────► │ Admin │
98
+ └─────────────┘ └─────────────┘
99
+
100
+ remove_admin()
101
+
102
+
103
+ ┌─────────────┐
104
+ │ Previous │
105
+ └─────────────┘
142
106
  ```
143
107
 
144
- ## Environment-Based Defaults
145
-
146
- ConnectOnion automatically adjusts trust based on environment:
108
+ ### Client Levels
147
109
 
148
- ```python
149
- # No trust parameter needed - auto-detected!
150
- translator = need("translate")
110
+ | Level | Description | Access |
111
+ |-------|-------------|--------|
112
+ | **Stranger** | Unknown client, not verified | Limited or none |
113
+ | **Contact** | Verified via invite/payment | Standard access |
114
+ | **Whitelist** | Trusted, pre-approved | Full access |
115
+ | **Admin** | Can manage other clients | Full access + management |
116
+ | **Blocklist** | Blocked, denied access | No access |
151
117
 
152
- # In development (localhost, Jupyter)
153
- # → Defaults to trust="open"
118
+ ## Trust Policy Files
154
119
 
155
- # In test files (test_*.py)
156
- # → Defaults to trust="tested"
120
+ Trust policies are markdown files with YAML frontmatter. YAML defines fast rules (no tokens), markdown body defines trust agent behavior (for complex decisions).
157
121
 
158
- # In production
159
- # → Defaults to trust="strict"
122
+ ```yaml
123
+ # prompts/trust/careful.md
124
+ ---
125
+ fast_rules:
126
+ - if: has_invite_code
127
+ action: verify_invite
128
+ on_success: promote_to_contact
160
129
 
161
- # Override when needed
162
- translator = need("translate", trust="open") # Force open even in production
163
- ```
130
+ - if: is_blocked
131
+ action: deny
164
132
 
165
- ## Trust Functions
133
+ - if: is_whitelist
134
+ action: allow
166
135
 
167
- Trust agents use composable functions:
136
+ - if: is_stranger
137
+ action: deny
168
138
 
169
- ```python
170
- # Basic trust functions (provided by ConnectOnion)
171
- def check_whitelist(agent_id: str) -> bool:
172
- """Check if agent is whitelisted"""
173
-
174
- def test_capability(agent, test_input, expected) -> bool:
175
- """Test if agent produces expected output"""
176
-
177
- def measure_response_time(agent, timeout_ms) -> float:
178
- """Measure agent response time"""
179
-
180
- def check_local_network(agent_ip: str) -> bool:
181
- """Check if agent is on local network"""
182
-
183
- # Combine in your trust agent
184
- my_trust = Agent(
185
- name="guardian",
186
- tools=[
187
- check_whitelist,
188
- test_capability,
189
- measure_response_time,
190
- check_local_network
191
- ]
192
- )
193
- ```
139
+ use_agent:
140
+ - when: requests > 10
141
+ reason: "Evaluate for promotion"
194
142
 
195
- ## Whitelist Management
143
+ cache: 24h
144
+ ---
196
145
 
197
- Simple text file at `~/.connectonion/trusted.txt`:
146
+ # Trust Agent Policy
198
147
 
199
- ```
200
- translator.api.com
201
- analyzer.local
202
- my-company.internal.net
203
- 192.168.1.*
204
- ```
148
+ You handle complex trust decisions.
205
149
 
206
- Edit with any text editor or programmatically:
150
+ ## Available Tools
151
+ - promote_to_contact(client_id)
152
+ - block(client_id, reason)
207
153
 
208
- ```python
209
- # Add to whitelist
210
- with open("~/.connectonion/trusted.txt", "a") as f:
211
- f.write("new-service.com\n")
154
+ ## When to Promote
155
+ Promote stranger to contact when:
156
+ - 10+ requests with good behavior
157
+ - No suspicious patterns
212
158
  ```
213
159
 
214
- ## Progressive Trust Building
160
+ ## Atomic Functions
215
161
 
216
- Trust grows through successful interactions:
162
+ Trust manager provides simple atomic functions as tools:
217
163
 
218
164
  ```python
219
- # First encounter - requires testing
220
- translator = need("translate", trust="tested")
221
- # → Agent is tested before use
165
+ # Promotion (earned)
166
+ promote_to_contact(client_id) # Stranger Contact
167
+ promote_to_whitelist(client_id) # Contact Whitelist
168
+
169
+ # Demotion
170
+ demote_to_contact(client_id) # Whitelist → Contact
171
+ demote_to_stranger(client_id) # Contact → Stranger
222
172
 
223
- # After successful interactions
224
- # → Agent automatically added to "verified" list
173
+ # Blocking
174
+ block(client_id, reason)
175
+ unblock(client_id)
225
176
 
226
- # Future encounters
227
- translator = need("translate", trust="tested")
228
- # → Skip testing, already verified
177
+ # Admin (manual only)
178
+ set_admin(client_id, by_admin)
179
+ remove_admin(client_id, by_admin)
229
180
  ```
230
181
 
231
- ## Common Patterns
182
+ ## Custom Trust Policies
183
+
184
+ ### Option 1: Use Preset
232
185
 
233
- ### Development Mode
234
186
  ```python
235
- # Trust everyone for rapid development
236
- connectonion.set_default_trust("open")
187
+ host(agent, trust="careful") # Uses prompts/trust/careful.md
237
188
  ```
238
189
 
239
- ### Production Mode
190
+ ### Option 2: Custom Markdown File
191
+
240
192
  ```python
241
- # Strict verification for production
242
- payment = need("payment processor", trust="strict")
243
- sensitive = need("data processor", trust="strict")
193
+ host(agent, trust="./my_policy.md")
244
194
  ```
245
195
 
246
- ### Mixed Trust
196
+ ### Option 3: Custom TrustAgent
197
+
247
198
  ```python
248
- # Different trust for different services
249
- scraper = need("web scraper", trust="open") # Low risk
250
- analyzer = need("analyze data", trust="tested") # Medium risk
251
- payment = need("process payment", trust="strict") # High risk
199
+ from connectonion.network.trust import TrustAgent
200
+
201
+ trust = TrustAgent(
202
+ system_prompt="./my_policy.md",
203
+ tools=[my_custom_verifier]
204
+ )
205
+ host(agent, trust=trust)
252
206
  ```
253
207
 
254
- ### Custom Trust Logic
208
+ ## Environment-Based Defaults
209
+
255
210
  ```python
256
- # Trust based on context
257
- def get_trust_level(service_type):
258
- if "payment" in service_type:
259
- return "strict"
260
- elif "read" in service_type:
261
- return "open"
262
- else:
263
- return "tested"
264
-
265
- service = need("read data", trust=get_trust_level("read data"))
211
+ # No trust specified - auto-detected from environment
212
+ host(agent)
213
+
214
+ # CONNECTONION_ENV=development → trust="open"
215
+ # CONNECTONION_ENV=staging → trust="careful"
216
+ # CONNECTONION_ENV=production → trust="strict"
266
217
  ```
267
218
 
268
- ## Security Best Practices
219
+ ## List Management
269
220
 
270
- 1. **Production = Strict**: Always use `trust="strict"` in production
271
- 2. **Test Sensitive Operations**: Payment, data modification, etc.
272
- 3. **Whitelist Critical Services**: Manually verify and whitelist
273
- 4. **Monitor Trust Decisions**: Log all trust evaluations
274
- 5. **Regular Audits**: Review whitelist and trust policies
221
+ Trust manager maintains lists at `~/.co/`:
222
+
223
+ ```
224
+ ~/.co/
225
+ ├── contacts.txt # Verified contacts
226
+ ├── whitelist.txt # Trusted, pre-approved
227
+ ├── admins.txt # Can manage other clients
228
+ └── blocklist.txt # Blocked clients
229
+ ```
275
230
 
276
231
  ## FAQ
277
232
 
278
233
  **Q: What's the default trust level?**
279
- A: `"tested"` - agents are tested before first use
234
+ A: `"careful"` - verify strangers, allow contacts.
280
235
 
281
- **Q: Can I change trust after agent creation?**
282
- A: Yes: `agent.trust = new_trust_agent`
236
+ **Q: Do fast rules burn tokens?**
237
+ A: No. Fast rules are simple if/then executed by host. Zero tokens.
283
238
 
284
- **Q: How do trust agents communicate?**
285
- A: They're regular ConnectOnion agents - they talk naturally
239
+ **Q: When does trust agent run?**
240
+ A: Only when `use_agent` triggers fire (e.g., after 10 requests). Rare.
286
241
 
287
- **Q: What if both agents have strict trust?**
288
- A: Both requirements must be met - most restrictive wins
242
+ **Q: Can I use the same agent with different trust levels?**
243
+ A: Yes. Trust is host config, not agent config.
289
244
 
290
- **Q: Can I disable trust completely?**
291
- A: Yes: `trust="open"` accepts everyone without checks
245
+ ```python
246
+ # Same agent, different trust
247
+ host(agent, trust="open") # Dev
248
+ host(agent, trust="strict") # Prod
249
+ ```