connectonion 0.6.2__py3-none-any.whl → 0.6.4__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 +46 -9
- connectonion/cli/__init__.py +11 -1
- connectonion/cli/browser_agent/__init__.py +11 -1
- connectonion/cli/browser_agent/browser.py +13 -3
- connectonion/cli/browser_agent/element_finder.py +8 -0
- connectonion/cli/browser_agent/highlight_screenshot.py +9 -1
- connectonion/cli/browser_agent/scroll.py +8 -0
- connectonion/cli/co_ai/__init__.py +6 -0
- connectonion/cli/co_ai/agent.py +87 -0
- connectonion/cli/co_ai/agents/__init__.py +5 -0
- connectonion/cli/co_ai/agents/registry.py +57 -0
- connectonion/cli/co_ai/commands/__init__.py +45 -0
- connectonion/cli/co_ai/commands/compact.py +173 -0
- connectonion/cli/co_ai/commands/cost.py +77 -0
- connectonion/cli/co_ai/commands/export.py +60 -0
- connectonion/cli/co_ai/commands/help.py +80 -0
- connectonion/cli/co_ai/commands/init.py +101 -0
- connectonion/cli/co_ai/commands/sessions.py +55 -0
- connectonion/cli/co_ai/commands/tasks.py +63 -0
- connectonion/cli/co_ai/commands/undo.py +103 -0
- connectonion/cli/co_ai/context.py +127 -0
- connectonion/cli/co_ai/main.py +52 -0
- connectonion/cli/co_ai/plugins/__init__.py +5 -0
- connectonion/cli/co_ai/plugins/system_reminder.py +154 -0
- connectonion/cli/co_ai/prompts/agents/explore.md +79 -0
- connectonion/cli/co_ai/prompts/agents/plan.md +60 -0
- connectonion/cli/co_ai/prompts/assembler.py +303 -0
- connectonion/cli/{docs/co-vibecoding-principles-docs-contexts-all-in-one.md → co_ai/prompts/connectonion/README.md} +26 -0
- connectonion/cli/co_ai/prompts/connectonion/api.md +457 -0
- connectonion/cli/co_ai/prompts/connectonion/cli/README.md +805 -0
- connectonion/cli/co_ai/prompts/connectonion/cli/auth.md +46 -0
- connectonion/cli/co_ai/prompts/connectonion/cli/browser.md +235 -0
- connectonion/cli/co_ai/prompts/connectonion/cli/copy.md +184 -0
- connectonion/cli/co_ai/prompts/connectonion/cli/create.md +335 -0
- connectonion/cli/co_ai/prompts/connectonion/cli/init.md +431 -0
- connectonion/cli/co_ai/prompts/connectonion/co-directory-structure.md +214 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/agent.md +1078 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/events.md +816 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/llm_do.md +256 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/max_iterations.md +362 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/models.md +641 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/plugins.md +100 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/prompts.md +122 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/tools.md +512 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/transcribe.md +156 -0
- connectonion/cli/co_ai/prompts/connectonion/concepts/trust.md +291 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/README.md +18 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/auto_debug.md +1026 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/console.md +129 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/eval-format.md +178 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/eval.md +230 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/exceptions.md +307 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/log.md +117 -0
- connectonion/cli/co_ai/prompts/connectonion/debug/xray.md +215 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/001-choosing-input-method.md +202 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/002-choosing-llm-function-name.md +202 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/003-choosing-trust-keyword.md +141 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/004-cli-create-flow.md +117 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/005-designing-agent-network-protocol.md +503 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/006-agent-address-format.md +305 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/007-authentication-backend-design.md +240 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/008-naming-is-hard.md +228 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/009-why-connect-function.md +167 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/010-cli-ux-progressive-disclosure.md +176 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/011-global-config-identity-management.md +357 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/012-tool-execution-separation.md +259 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/013-debug-and-logging-design.md +253 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/014-hook-system-design.md +510 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/015-interactive-auto-debug-design.md +837 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/016-why-no-zero-knowledge-proofs.md +358 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/017-session-logging-and-eval-format.md +120 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/018-event-api-naming.md +274 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/019-agent-lifecycle-design.md +655 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/020-trust-system-and-network-architecture.md +503 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/021-task-storage-jsonl-design.md +496 -0
- connectonion/cli/co_ai/prompts/connectonion/design-decisions/022-raw-asgi-implementation.md +273 -0
- connectonion/cli/co_ai/prompts/connectonion/examples/agent_reasoning.md +62 -0
- connectonion/cli/co_ai/prompts/connectonion/examples/atomic_tools.md +24 -0
- connectonion/cli/co_ai/prompts/connectonion/examples/load_guide.md +18 -0
- connectonion/cli/co_ai/prompts/connectonion/examples.md +0 -0
- connectonion/cli/co_ai/prompts/connectonion/hook-system-options.md +364 -0
- connectonion/cli/co_ai/prompts/connectonion/index.md +162 -0
- connectonion/cli/co_ai/prompts/connectonion/integrations/README.md +12 -0
- connectonion/cli/co_ai/prompts/connectonion/integrations/auth.md +450 -0
- connectonion/cli/co_ai/prompts/connectonion/integrations/google.md +431 -0
- connectonion/cli/co_ai/prompts/connectonion/integrations/microsoft.md +370 -0
- connectonion/cli/co_ai/prompts/connectonion/network/README.md +14 -0
- connectonion/cli/co_ai/prompts/connectonion/network/connect.md +543 -0
- connectonion/cli/co_ai/prompts/connectonion/network/connection.md +538 -0
- connectonion/cli/co_ai/prompts/connectonion/network/deploy.md +123 -0
- connectonion/cli/co_ai/prompts/connectonion/network/host.md +1049 -0
- connectonion/cli/co_ai/prompts/connectonion/network/protocol/agent-relay-protocol.md +495 -0
- connectonion/cli/co_ai/prompts/connectonion/network/protocol/announce-message.md +115 -0
- connectonion/cli/co_ai/prompts/connectonion/principles.md +124 -0
- connectonion/cli/co_ai/prompts/connectonion/quickstart.md +261 -0
- connectonion/cli/co_ai/prompts/connectonion/roadmap.md +81 -0
- connectonion/cli/co_ai/prompts/connectonion/templates/README.md +77 -0
- connectonion/cli/co_ai/prompts/connectonion/templates/meta-agent.md +152 -0
- connectonion/cli/co_ai/prompts/connectonion/templates/minimal.md +105 -0
- connectonion/cli/co_ai/prompts/connectonion/templates/playwright.md +130 -0
- connectonion/cli/co_ai/prompts/connectonion/templates/web-research.md +144 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/README.md +95 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/chat.md +181 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/divider.md +63 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/dropdown.md +83 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/footer.md +44 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/fuzzy.md +68 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/input.md +84 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/keys.md +77 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/pick.md +71 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/providers.md +89 -0
- connectonion/cli/co_ai/prompts/connectonion/tui/status_bar.md +67 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/README.md +156 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/calendar_plugin.md +68 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/eval.md +89 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/gmail_plugin.md +68 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/image_result_formatter.md +74 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/re_act.md +86 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_plugins/shell_approval.md +69 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/README.md +81 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/diff_writer.md +138 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/get_emails.md +499 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/gmail.md +135 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/google_calendar.md +106 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/memory.md +486 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/microsoft_calendar.md +106 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/outlook.md +120 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/send_email.md +403 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/shell.md +95 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/slash_command.md +96 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/terminal.md +97 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/todo_list.md +252 -0
- connectonion/cli/co_ai/prompts/connectonion/useful_tools/web_fetch.md +130 -0
- connectonion/cli/co_ai/prompts/connectonion/vibe-coding-guide.md +97 -0
- connectonion/cli/co_ai/prompts/connectonion/windows-support.md +258 -0
- connectonion/cli/co_ai/prompts/main.md +247 -0
- connectonion/cli/co_ai/prompts/summarization.md +55 -0
- connectonion/cli/co_ai/prompts/system-reminders/agent.md +23 -0
- connectonion/cli/co_ai/prompts/system-reminders/plan_mode.md +13 -0
- connectonion/cli/co_ai/prompts/system-reminders/security.md +14 -0
- connectonion/cli/co_ai/prompts/system-reminders/simplicity.md +14 -0
- connectonion/cli/co_ai/prompts/tools/ask_user.md +61 -0
- connectonion/cli/co_ai/prompts/tools/background.md +57 -0
- connectonion/cli/co_ai/prompts/tools/edit.md +90 -0
- connectonion/cli/co_ai/prompts/tools/glob.md +52 -0
- connectonion/cli/co_ai/prompts/tools/grep.md +55 -0
- connectonion/cli/co_ai/prompts/tools/plan_mode.md +80 -0
- connectonion/cli/co_ai/prompts/tools/read.md +40 -0
- connectonion/cli/co_ai/prompts/tools/shell.md +67 -0
- connectonion/cli/co_ai/prompts/tools/task.md +51 -0
- connectonion/cli/co_ai/prompts/tools/todo.md +139 -0
- connectonion/cli/co_ai/prompts/tools/write.md +47 -0
- connectonion/cli/co_ai/prompts/workflow.md +89 -0
- connectonion/cli/co_ai/sessions.py +110 -0
- connectonion/cli/co_ai/skills/__init__.py +37 -0
- connectonion/cli/co_ai/skills/builtin/commit/SKILL.md +63 -0
- connectonion/cli/co_ai/skills/builtin/review-pr/SKILL.md +76 -0
- connectonion/cli/co_ai/skills/loader.py +166 -0
- connectonion/cli/co_ai/skills/tool.py +46 -0
- connectonion/cli/co_ai/tools/__init__.py +92 -0
- connectonion/cli/co_ai/tools/ask_user.py +35 -0
- connectonion/cli/co_ai/tools/background.py +201 -0
- connectonion/cli/co_ai/tools/diff_writer.py +291 -0
- connectonion/cli/co_ai/tools/edit.py +89 -0
- connectonion/cli/co_ai/tools/glob.py +84 -0
- connectonion/cli/co_ai/tools/grep.py +158 -0
- connectonion/cli/co_ai/tools/load_guide.py +23 -0
- connectonion/cli/co_ai/tools/multi_edit.py +116 -0
- connectonion/cli/co_ai/tools/plan_mode.py +169 -0
- connectonion/cli/co_ai/tools/read.py +61 -0
- connectonion/cli/co_ai/tools/task.py +59 -0
- connectonion/cli/co_ai/tools/todo_list.py +159 -0
- connectonion/cli/co_ai/tools/write.py +126 -0
- connectonion/cli/commands/__init__.py +11 -1
- connectonion/cli/commands/ai_commands.py +34 -0
- connectonion/cli/commands/copy_commands.py +55 -6
- connectonion/cli/commands/create.py +20 -17
- connectonion/cli/commands/init.py +19 -22
- connectonion/cli/commands/project_cmd_lib.py +15 -0
- connectonion/cli/main.py +11 -0
- connectonion/console.py +15 -1
- connectonion/core/__init__.py +10 -1
- connectonion/core/agent.py +37 -16
- connectonion/core/exceptions.py +74 -0
- connectonion/core/llm.py +54 -6
- connectonion/core/tool_executor.py +32 -31
- connectonion/core/tool_factory.py +47 -10
- connectonion/debug/__init__.py +10 -1
- connectonion/debug/debug_explainer/__init__.py +10 -1
- connectonion/debug/execution_analyzer/__init__.py +10 -1
- connectonion/debug/execution_analyzer/execution_analysis.py +5 -2
- connectonion/debug/runtime_inspector/__init__.py +10 -1
- connectonion/docs/.package-ignore +6 -0
- connectonion/docs/README.md +2036 -0
- connectonion/docs/api.md +457 -0
- connectonion/docs/archive/001-ai-agent-is-just-prompt-plus-function.md +249 -0
- connectonion/docs/archive/README.md +53 -0
- connectonion/docs/archive/archive/consolidation-plan.md +72 -0
- connectonion/docs/archive/archive/core-principles-extracted.md +239 -0
- connectonion/docs/archive/archive/master-principles.md +222 -0
- connectonion/docs/archive/archive/principles.md +293 -0
- connectonion/docs/archive/archive/simplicity-principles.md +221 -0
- connectonion/docs/archive/attack-defense-insights.md +410 -0
- connectonion/docs/archive/business-model.md +305 -0
- connectonion/docs/archive/core-principles-unified.md +190 -0
- connectonion/docs/archive/discussion-journey.md +178 -0
- connectonion/docs/archive/economic-analysis.md +323 -0
- connectonion/docs/archive/features/01-share-and-find.md +256 -0
- connectonion/docs/archive/features/02-agent-authentication.md +93 -0
- connectonion/docs/archive/features/03-test-before-trust.md +71 -0
- connectonion/docs/archive/features/06-reliability-and-offline.md +197 -0
- connectonion/docs/archive/features/README.md +46 -0
- connectonion/docs/archive/features-roadmap.md +247 -0
- connectonion/docs/archive/mcp-comparison-insights.md +215 -0
- connectonion/docs/archive/migration-strategy.md +571 -0
- connectonion/docs/archive/mini-whitepaper.md +293 -0
- connectonion/docs/archive/network-protocol.md +394 -0
- connectonion/docs/archive/semantic-revolution.md +367 -0
- connectonion/docs/archive/technical-architecture.md +453 -0
- connectonion/docs/archive/the-semantic-insight.md +207 -0
- connectonion/docs/archive/threat-model.md +164 -0
- connectonion/docs/cli/README.md +805 -0
- connectonion/docs/cli/auth.md +46 -0
- connectonion/docs/cli/browser.md +235 -0
- connectonion/docs/cli/copy.md +232 -0
- connectonion/docs/cli/create.md +335 -0
- connectonion/docs/cli/init.md +431 -0
- connectonion/docs/co-directory-structure.md +214 -0
- connectonion/docs/concepts/agent.md +1078 -0
- connectonion/docs/concepts/events.md +699 -0
- connectonion/docs/concepts/llm_do.md +256 -0
- connectonion/docs/concepts/max_iterations.md +362 -0
- connectonion/docs/concepts/models.md +641 -0
- connectonion/docs/concepts/plugins.md +101 -0
- connectonion/docs/concepts/prompts.md +122 -0
- connectonion/docs/concepts/session.md +428 -0
- connectonion/docs/concepts/tools.md +512 -0
- connectonion/docs/concepts/transcribe.md +156 -0
- connectonion/docs/concepts/trust.md +291 -0
- connectonion/docs/connectonion.md +1256 -0
- connectonion/docs/debug/README.md +18 -0
- connectonion/docs/debug/auto_debug.md +1026 -0
- connectonion/docs/debug/console.md +129 -0
- connectonion/docs/debug/eval-format.md +178 -0
- connectonion/docs/debug/eval.md +230 -0
- connectonion/docs/debug/exceptions.md +307 -0
- connectonion/docs/debug/log.md +117 -0
- connectonion/docs/debug/xray.md +215 -0
- connectonion/docs/design-decisions/001-choosing-input-method.md +202 -0
- connectonion/docs/design-decisions/002-choosing-llm-function-name.md +202 -0
- connectonion/docs/design-decisions/003-choosing-trust-keyword.md +141 -0
- connectonion/docs/design-decisions/004-cli-create-flow.md +117 -0
- connectonion/docs/design-decisions/005-designing-agent-network-protocol.md +503 -0
- connectonion/docs/design-decisions/006-agent-address-format.md +305 -0
- connectonion/docs/design-decisions/007-authentication-backend-design.md +240 -0
- connectonion/docs/design-decisions/008-naming-is-hard.md +228 -0
- connectonion/docs/design-decisions/009-why-connect-function.md +167 -0
- connectonion/docs/design-decisions/010-cli-ux-progressive-disclosure.md +176 -0
- connectonion/docs/design-decisions/011-global-config-identity-management.md +357 -0
- connectonion/docs/design-decisions/012-tool-execution-separation.md +259 -0
- connectonion/docs/design-decisions/013-debug-and-logging-design.md +253 -0
- connectonion/docs/design-decisions/014-hook-system-design.md +510 -0
- connectonion/docs/design-decisions/015-interactive-auto-debug-design.md +837 -0
- connectonion/docs/design-decisions/016-why-no-zero-knowledge-proofs.md +358 -0
- connectonion/docs/design-decisions/017-session-logging-and-eval-format.md +120 -0
- connectonion/docs/design-decisions/018-event-api-naming.md +274 -0
- connectonion/docs/design-decisions/019-agent-lifecycle-design.md +655 -0
- connectonion/docs/design-decisions/020-trust-system-and-network-architecture.md +503 -0
- connectonion/docs/design-decisions/021-task-storage-jsonl-design.md +496 -0
- connectonion/docs/design-decisions/022-raw-asgi-implementation.md +273 -0
- connectonion/docs/examples.md +0 -0
- connectonion/docs/hook-system-options.md +364 -0
- connectonion/docs/integrations/README.md +12 -0
- connectonion/docs/integrations/auth.md +450 -0
- connectonion/docs/integrations/google.md +431 -0
- connectonion/docs/integrations/microsoft.md +370 -0
- connectonion/docs/network/README.md +14 -0
- connectonion/docs/network/connect.md +629 -0
- connectonion/docs/network/deploy.md +124 -0
- connectonion/docs/network/host.md +1087 -0
- connectonion/docs/network/io.md +538 -0
- connectonion/docs/network/protocol/agent-relay-protocol.md +495 -0
- connectonion/docs/network/protocol/announce-message.md +115 -0
- connectonion/docs/principles.md +124 -0
- connectonion/docs/quickstart.md +261 -0
- connectonion/docs/roadmap.md +81 -0
- connectonion/docs/templates/README.md +77 -0
- connectonion/docs/templates/meta-agent.md +152 -0
- connectonion/docs/templates/minimal.md +105 -0
- connectonion/docs/templates/playwright.md +130 -0
- connectonion/docs/templates/web-research.md +144 -0
- connectonion/docs/tui/README.md +95 -0
- connectonion/docs/tui/chat.md +181 -0
- connectonion/docs/tui/divider.md +63 -0
- connectonion/docs/tui/dropdown.md +83 -0
- connectonion/docs/tui/footer.md +44 -0
- connectonion/docs/tui/fuzzy.md +68 -0
- connectonion/docs/tui/input.md +84 -0
- connectonion/docs/tui/keys.md +77 -0
- connectonion/docs/tui/pick.md +71 -0
- connectonion/docs/tui/providers.md +89 -0
- connectonion/docs/tui/status_bar.md +67 -0
- connectonion/docs/useful_plugins/README.md +160 -0
- connectonion/docs/useful_plugins/calendar_plugin.md +68 -0
- connectonion/docs/useful_plugins/eval.md +89 -0
- connectonion/docs/useful_plugins/gmail_plugin.md +68 -0
- connectonion/docs/useful_plugins/image_result_formatter.md +74 -0
- connectonion/docs/useful_plugins/re_act.md +86 -0
- connectonion/docs/useful_plugins/shell_approval.md +69 -0
- connectonion/docs/useful_plugins/system_reminder.md +210 -0
- connectonion/docs/useful_plugins/tool_approval.md +139 -0
- connectonion/docs/useful_prompts/README.md +127 -0
- connectonion/docs/useful_prompts/coding_agent.md +214 -0
- connectonion/docs/useful_tools/README.md +81 -0
- connectonion/docs/useful_tools/ask_user.md +103 -0
- connectonion/docs/useful_tools/diff_writer.md +158 -0
- connectonion/docs/useful_tools/get_emails.md +519 -0
- connectonion/docs/useful_tools/gmail.md +155 -0
- connectonion/docs/useful_tools/google_calendar.md +126 -0
- connectonion/docs/useful_tools/memory.md +506 -0
- connectonion/docs/useful_tools/microsoft_calendar.md +126 -0
- connectonion/docs/useful_tools/outlook.md +140 -0
- connectonion/docs/useful_tools/send_email.md +423 -0
- connectonion/docs/useful_tools/shell.md +115 -0
- connectonion/docs/useful_tools/slash_command.md +116 -0
- connectonion/docs/useful_tools/terminal.md +115 -0
- connectonion/docs/useful_tools/todo_list.md +272 -0
- connectonion/docs/useful_tools/web_fetch.md +150 -0
- connectonion/docs/vibe-coding-guide.md +97 -0
- connectonion/docs/windows-support.md +258 -0
- connectonion/logger.py +3 -3
- connectonion/network/__init__.py +19 -6
- connectonion/network/asgi/__init__.py +81 -0
- connectonion/network/asgi/http.py +205 -0
- connectonion/network/asgi/websocket.py +217 -0
- connectonion/network/connect.py +232 -185
- connectonion/network/host/__init__.py +59 -0
- connectonion/network/host/auth.py +191 -0
- connectonion/network/host/routes.py +135 -0
- connectonion/network/host/server.py +289 -0
- connectonion/network/host/session.py +78 -0
- connectonion/network/io/__init__.py +21 -0
- connectonion/network/{connection.py → io/base.py} +17 -42
- connectonion/network/io/websocket.py +55 -0
- connectonion/network/relay.py +37 -16
- connectonion/network/trust/__init__.py +30 -0
- connectonion/network/trust/factory.py +138 -0
- connectonion/network/{trust_agents.py → trust/prompts.py} +3 -3
- connectonion/network/{trust_functions.py → trust/tools.py} +2 -2
- connectonion/prompt_files/__init__.py +11 -1
- connectonion/prompt_files/react_acknowledge.md +26 -0
- connectonion/prompts.py +10 -1
- connectonion/tui/chat.py +10 -1
- connectonion/tui/divider.py +10 -1
- connectonion/tui/dropdown.py +10 -1
- connectonion/tui/footer.py +8 -0
- connectonion/tui/fuzzy.py +11 -1
- connectonion/tui/input.py +118 -70
- connectonion/tui/keys.py +133 -6
- connectonion/tui/providers.py +11 -1
- connectonion/tui/status_bar.py +10 -1
- connectonion/useful_events_handlers/__init__.py +8 -0
- connectonion/useful_events_handlers/reflect.py +19 -4
- connectonion/useful_plugins/__init__.py +3 -1
- connectonion/useful_plugins/eval.py +2 -2
- connectonion/useful_plugins/gmail_plugin.py +3 -3
- connectonion/useful_plugins/image_result_formatter.py +3 -3
- connectonion/useful_plugins/re_act.py +114 -28
- connectonion/useful_plugins/shell_approval.py +2 -2
- connectonion/useful_plugins/system_reminder.py +103 -0
- connectonion/useful_plugins/tool_approval.py +233 -0
- connectonion/useful_plugins/ui_stream.py +18 -133
- connectonion/useful_prompts/README.md +61 -0
- connectonion/useful_prompts/__init__.py +45 -0
- connectonion/useful_prompts/coding_agent/README.md +106 -0
- connectonion/useful_prompts/coding_agent/assembler.py +123 -0
- connectonion/useful_prompts/coding_agent/prompts/main.md +227 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/ask_user.md +61 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/background.md +57 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/edit.md +90 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/glob.md +52 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/grep.md +55 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/plan_mode.md +80 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/read.md +40 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/shell.md +67 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/task.md +51 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/todo.md +139 -0
- connectonion/useful_prompts/coding_agent/prompts/tools/write.md +48 -0
- connectonion/useful_prompts/system-reminders/security-warning.md +14 -0
- connectonion/useful_prompts/system-reminders/test-reminder.md +11 -0
- connectonion/useful_tools/__init__.py +31 -4
- connectonion/useful_tools/ask_user.py +35 -0
- connectonion/useful_tools/bash.py +69 -0
- connectonion/useful_tools/diff_writer.py +186 -94
- connectonion/useful_tools/edit.py +102 -0
- connectonion/useful_tools/glob_files.py +97 -0
- connectonion/useful_tools/grep_files.py +171 -0
- connectonion/useful_tools/multi_edit.py +116 -0
- connectonion/useful_tools/read_file.py +73 -0
- connectonion/useful_tools/shell.py +50 -45
- connectonion/useful_tools/write_file.py +129 -0
- {connectonion-0.6.2.dist-info → connectonion-0.6.4.dist-info}/METADATA +10 -3
- connectonion-0.6.4.dist-info/RECORD +472 -0
- connectonion/network/asgi.py +0 -407
- connectonion/network/host.py +0 -616
- connectonion/network/trust.py +0 -166
- connectonion-0.6.2.dist-info/RECORD +0 -129
- /connectonion/cli/{docs → co_ai/prompts/connectonion}/connectonion.md +0 -0
- {connectonion-0.6.2.dist-info → connectonion-0.6.4.dist-info}/WHEEL +0 -0
- {connectonion-0.6.2.dist-info → connectonion-0.6.4.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,1049 @@
|
|
|
1
|
+
# host()
|
|
2
|
+
|
|
3
|
+
> Make your agent accessible over the network. One function call.
|
|
4
|
+
|
|
5
|
+
**Looking to deploy?** See [Deploy Your Agent](deploy.md) for production deployment options.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Start (60 Seconds)
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
from connectonion import Agent, host
|
|
13
|
+
|
|
14
|
+
agent = Agent("translator", tools=[translate])
|
|
15
|
+
|
|
16
|
+
# Make it network-accessible
|
|
17
|
+
host(agent)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Output:**
|
|
21
|
+
```
|
|
22
|
+
╭─────────────────────────────────────────────────────────╮
|
|
23
|
+
│ Agent 'translator' is now hosted │
|
|
24
|
+
├─────────────────────────────────────────────────────────┤
|
|
25
|
+
│ │
|
|
26
|
+
│ Address: 0x3d4017c3e843895a92b70aa74d1b7ebc9c98... │
|
|
27
|
+
│ │
|
|
28
|
+
│ HTTP Endpoints: │
|
|
29
|
+
│ POST http://localhost:8000/input │
|
|
30
|
+
│ GET http://localhost:8000/sessions/{session_id} │
|
|
31
|
+
│ GET http://localhost:8000/sessions │
|
|
32
|
+
│ GET http://localhost:8000/health │
|
|
33
|
+
│ GET http://localhost:8000/info │
|
|
34
|
+
│ GET http://localhost:8000/admin/logs (API key) │
|
|
35
|
+
│ GET http://localhost:8000/admin/sessions (API key) │
|
|
36
|
+
│ WS ws://localhost:8000/ws │
|
|
37
|
+
│ │
|
|
38
|
+
│ Interactive UI: │
|
|
39
|
+
│ http://localhost:8000/docs │
|
|
40
|
+
│ │
|
|
41
|
+
│ P2P Relay: │
|
|
42
|
+
│ wss://oo.openonion.ai/ws/announce │
|
|
43
|
+
│ │
|
|
44
|
+
╰─────────────────────────────────────────────────────────╯
|
|
45
|
+
|
|
46
|
+
Waiting for tasks...
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**That's it.** Your agent is now accessible via HTTP, WebSocket, and P2P relay.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Function Signature
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
def host(
|
|
57
|
+
agent: Agent,
|
|
58
|
+
|
|
59
|
+
# Trust
|
|
60
|
+
trust: Union[str, Agent] = "careful",
|
|
61
|
+
blacklist: list = None,
|
|
62
|
+
whitelist: list = None,
|
|
63
|
+
|
|
64
|
+
# Server
|
|
65
|
+
port: int = 8000,
|
|
66
|
+
workers: int = 1,
|
|
67
|
+
|
|
68
|
+
# Storage
|
|
69
|
+
result_ttl: int = 86400, # 24 hours (how long server keeps results)
|
|
70
|
+
|
|
71
|
+
# P2P Discovery
|
|
72
|
+
relay_url: str = "wss://oo.openonion.ai/ws/announce",
|
|
73
|
+
|
|
74
|
+
# Development
|
|
75
|
+
reload: bool = False,
|
|
76
|
+
) -> None:
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## How It Works
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
┌─────────────────────────────────────────────────────────┐
|
|
85
|
+
│ host(agent) │
|
|
86
|
+
├─────────────────────────────────────────────────────────┤
|
|
87
|
+
│ │
|
|
88
|
+
│ 1. Request arrives (HTTP or WebSocket) │
|
|
89
|
+
│ 2. Trust check (blacklist/whitelist/policy) │
|
|
90
|
+
│ 3. Deep copy agent (isolated instance for this request)│
|
|
91
|
+
│ 4. Create session_id, append to session_results.jsonl │
|
|
92
|
+
│ 5. Execute agent.input(prompt, session) │
|
|
93
|
+
│ 6. Append result to session_results.jsonl (done) │
|
|
94
|
+
│ 7. Return result (or client fetches via GET /sessions) │
|
|
95
|
+
│ │
|
|
96
|
+
└─────────────────────────────────────────────────────────┘
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Results are always saved first.** If connection drops, client can fetch later via HTTP.
|
|
100
|
+
|
|
101
|
+
### Worker Isolation
|
|
102
|
+
|
|
103
|
+
Each request gets a **fresh deep copy** of your agent. This ensures:
|
|
104
|
+
|
|
105
|
+
- **No shared state** between concurrent requests
|
|
106
|
+
- **Stateful tools work correctly** (e.g., browser tools with page state)
|
|
107
|
+
- **Complete isolation** - one request can't affect another
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
# Request A and B arrive simultaneously
|
|
111
|
+
# Each gets its own copy of the agent and tools
|
|
112
|
+
# No interference, no race conditions
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
For horizontal scaling, use uvicorn `workers`:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
host(agent, workers=4) # 4 OS processes, each with isolated agents
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## HTTP API
|
|
124
|
+
|
|
125
|
+
### POST /input
|
|
126
|
+
|
|
127
|
+
Submit input. Creates a session, returns session_id.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
curl -X POST http://localhost:8000/input \
|
|
131
|
+
-H "Content-Type: application/json" \
|
|
132
|
+
-d '{"prompt": "Translate hello to Spanish"}'
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Response:**
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"session_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
139
|
+
"status": "done",
|
|
140
|
+
"result": "Hola",
|
|
141
|
+
"duration_ms": 1250,
|
|
142
|
+
"session": {
|
|
143
|
+
"session_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
144
|
+
"messages": [...],
|
|
145
|
+
"trace": [...],
|
|
146
|
+
"turn": 1
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### Multi-turn Conversations
|
|
152
|
+
|
|
153
|
+
To continue a conversation, pass the `session` from the previous response:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# First request
|
|
157
|
+
curl -X POST http://localhost:8000/input \
|
|
158
|
+
-H "Content-Type: application/json" \
|
|
159
|
+
-d '{"prompt": "My name is John"}'
|
|
160
|
+
|
|
161
|
+
# Response includes session
|
|
162
|
+
# {"result": "Nice to meet you, John!", "session": {...}}
|
|
163
|
+
|
|
164
|
+
# Second request - pass session back
|
|
165
|
+
curl -X POST http://localhost:8000/input \
|
|
166
|
+
-H "Content-Type: application/json" \
|
|
167
|
+
-d '{
|
|
168
|
+
"prompt": "What is my name?",
|
|
169
|
+
"session": {...}
|
|
170
|
+
}'
|
|
171
|
+
|
|
172
|
+
# Agent remembers: "Your name is John"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Request format:**
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"prompt": "What is my name?",
|
|
179
|
+
"session": { // Optional - omit to start fresh
|
|
180
|
+
"session_id": "abc-123",
|
|
181
|
+
"messages": [...],
|
|
182
|
+
"trace": [...],
|
|
183
|
+
"turn": 1
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Response format:**
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"session_id": "abc-123",
|
|
192
|
+
"status": "done",
|
|
193
|
+
"result": "Your name is John",
|
|
194
|
+
"duration_ms": 850,
|
|
195
|
+
"session": { // Always returned - save for next request
|
|
196
|
+
"session_id": "abc-123",
|
|
197
|
+
"messages": [...],
|
|
198
|
+
"trace": [...],
|
|
199
|
+
"turn": 2
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### GET /sessions/{session_id}
|
|
205
|
+
|
|
206
|
+
Fetch session result anytime.
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
curl http://localhost:8000/sessions/550e8400-e29b-41d4-a716-446655440000
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Response (running):**
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"session_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
216
|
+
"status": "running"
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Response (done):**
|
|
221
|
+
```json
|
|
222
|
+
{
|
|
223
|
+
"session_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
224
|
+
"status": "done",
|
|
225
|
+
"result": "Hola",
|
|
226
|
+
"duration_ms": 1250
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### GET /sessions
|
|
231
|
+
|
|
232
|
+
List recent sessions.
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
curl http://localhost:8000/sessions
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Response:**
|
|
239
|
+
```json
|
|
240
|
+
{
|
|
241
|
+
"sessions": [
|
|
242
|
+
{"session_id": "abc-123", "status": "done", "created": 1702234567},
|
|
243
|
+
{"session_id": "def-456", "status": "running", "created": 1702234570}
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### GET /health
|
|
249
|
+
|
|
250
|
+
Health check for load balancers.
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
curl http://localhost:8000/health
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**Response:**
|
|
257
|
+
```json
|
|
258
|
+
{
|
|
259
|
+
"status": "healthy",
|
|
260
|
+
"agent": "translator",
|
|
261
|
+
"uptime": 3600
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### GET /info
|
|
266
|
+
|
|
267
|
+
Agent capabilities and metadata.
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
curl http://localhost:8000/info
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Response:**
|
|
274
|
+
```json
|
|
275
|
+
{
|
|
276
|
+
"name": "translator",
|
|
277
|
+
"address": "0x3d4017c3...",
|
|
278
|
+
"tools": ["translate", "detect_language"],
|
|
279
|
+
"trust": "careful",
|
|
280
|
+
"version": "0.4.1"
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### GET /docs
|
|
285
|
+
|
|
286
|
+
Interactive UI to test your agent in the browser.
|
|
287
|
+
|
|
288
|
+
```
|
|
289
|
+
http://localhost:8000/docs
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### GET /admin/logs (Requires API Key)
|
|
293
|
+
|
|
294
|
+
Fetch agent activity logs (plain text). Requires `OPENONION_API_KEY` authentication.
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
curl http://localhost:8000/admin/logs \
|
|
298
|
+
-H "Authorization: Bearer YOUR_OPENONION_API_KEY"
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Response:**
|
|
302
|
+
```
|
|
303
|
+
2024-01-15 10:23:45 [translator] Processing: Translate hello
|
|
304
|
+
2024-01-15 10:23:46 [translator] Tool: translate_text executed (450ms)
|
|
305
|
+
2024-01-15 10:23:46 [translator] Result: Hola
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### GET /admin/sessions (Requires API Key)
|
|
309
|
+
|
|
310
|
+
Fetch all activity sessions as JSON array. Requires `OPENONION_API_KEY` authentication.
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
curl http://localhost:8000/admin/sessions \
|
|
314
|
+
-H "Authorization: Bearer YOUR_OPENONION_API_KEY"
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Response:**
|
|
318
|
+
```json
|
|
319
|
+
{
|
|
320
|
+
"sessions": [
|
|
321
|
+
{
|
|
322
|
+
"id": "translator_20240115_102345",
|
|
323
|
+
"created": "2024-01-15T10:23:45",
|
|
324
|
+
"agent": "translator",
|
|
325
|
+
"input": "Translate hello to Spanish",
|
|
326
|
+
"result": "Hola",
|
|
327
|
+
"tools_called": ["translate_text"],
|
|
328
|
+
"duration_ms": 1250
|
|
329
|
+
}
|
|
330
|
+
]
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**Note:** These endpoints require setting `OPENONION_API_KEY` as an environment variable when running your agent. The same key must be used to authenticate requests.
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## WebSocket API
|
|
339
|
+
|
|
340
|
+
WebSocket provides real-time communication. Connection stays alive via ping/pong (automatic).
|
|
341
|
+
|
|
342
|
+
### Connect
|
|
343
|
+
|
|
344
|
+
```javascript
|
|
345
|
+
const ws = new WebSocket("ws://localhost:8000/ws");
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Send INPUT
|
|
349
|
+
|
|
350
|
+
```javascript
|
|
351
|
+
ws.send(JSON.stringify({
|
|
352
|
+
type: "INPUT",
|
|
353
|
+
prompt: "Translate hello to Spanish"
|
|
354
|
+
}));
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Receive Messages
|
|
358
|
+
|
|
359
|
+
```javascript
|
|
360
|
+
ws.onmessage = (event) => {
|
|
361
|
+
const msg = JSON.parse(event.data);
|
|
362
|
+
|
|
363
|
+
if (msg.type === "OUTPUT") {
|
|
364
|
+
console.log("Result:", msg.result);
|
|
365
|
+
} else if (msg.type === "STREAM") {
|
|
366
|
+
process.stdout.write(msg.chunk);
|
|
367
|
+
} else if (msg.type === "ERROR") {
|
|
368
|
+
console.error("Error:", msg.message);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Message Types
|
|
374
|
+
|
|
375
|
+
| Type | Direction | Purpose |
|
|
376
|
+
|------|-----------|---------|
|
|
377
|
+
| INPUT | Client → Agent | Send prompt |
|
|
378
|
+
| OUTPUT | Agent → Client | Final result |
|
|
379
|
+
| STREAM | Agent → Client | Streaming chunk |
|
|
380
|
+
| ERROR | Agent → Client | Error message |
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
## Design: Stateless Sessions
|
|
385
|
+
|
|
386
|
+
ConnectOnion uses **client-managed sessions** for multi-turn conversations. This section explains why.
|
|
387
|
+
|
|
388
|
+
### Why Full `session` Instead of Just `messages`?
|
|
389
|
+
|
|
390
|
+
You might expect an API like Anthropic or OpenAI that only passes `messages`:
|
|
391
|
+
|
|
392
|
+
```json
|
|
393
|
+
// What Anthropic/OpenAI do
|
|
394
|
+
{"messages": [...]}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
But ConnectOnion passes the full session:
|
|
398
|
+
|
|
399
|
+
```json
|
|
400
|
+
// What ConnectOnion does
|
|
401
|
+
{"session": {"messages": [...], "trace": [...], "turn": 2}}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
**The reason:** ConnectOnion is not just an LLM API wrapper. It's an agent framework with:
|
|
405
|
+
|
|
406
|
+
| Feature | Needs Session Data |
|
|
407
|
+
|---------|-------------------|
|
|
408
|
+
| Activity logging | `trace` - tool executions, timings |
|
|
409
|
+
| Turn tracking | `turn` - conversation turn count |
|
|
410
|
+
| XRay debugging | Full execution context |
|
|
411
|
+
| Session replay | Complete session history |
|
|
412
|
+
|
|
413
|
+
If we stripped down to just `messages`, we'd lose:
|
|
414
|
+
- Execution trace (which tools ran, how long they took)
|
|
415
|
+
- Turn count (for accurate logging)
|
|
416
|
+
- Debugging context (for XRay inspection)
|
|
417
|
+
|
|
418
|
+
**ConnectOnion's value is debugging and observability.** The full session preserves that.
|
|
419
|
+
|
|
420
|
+
### Why Client-Managed State?
|
|
421
|
+
|
|
422
|
+
The server doesn't store your session. You store it, you send it back. Like:
|
|
423
|
+
|
|
424
|
+
| Pattern | How It Works |
|
|
425
|
+
|---------|--------------|
|
|
426
|
+
| **JWT tokens** | Server gives you a token, you send it with each request |
|
|
427
|
+
| **Game save files** | Game gives you save data, you store it, you load it |
|
|
428
|
+
| **ConnectOnion sessions** | Server gives you session, you store it, you send it back |
|
|
429
|
+
|
|
430
|
+
**Benefits:**
|
|
431
|
+
|
|
432
|
+
1. **Infinitely scalable** - No server-side session storage
|
|
433
|
+
2. **Client transparency** - You can inspect the session, see exactly what's happening
|
|
434
|
+
3. **Coherent logs** - Server logs preserve turn count, trace
|
|
435
|
+
4. **Easy debugging** - Session contains full execution history
|
|
436
|
+
5. **No session cleanup** - No TTL, no expiry, no "session not found" errors
|
|
437
|
+
|
|
438
|
+
### Comparison
|
|
439
|
+
|
|
440
|
+
| API | Approach | State Storage |
|
|
441
|
+
|-----|----------|---------------|
|
|
442
|
+
| Anthropic Messages API | `messages` array | Client |
|
|
443
|
+
| OpenAI Chat API | `messages` array | Client |
|
|
444
|
+
| OpenAI Assistants API | `thread_id` | Server |
|
|
445
|
+
| **ConnectOnion** | `session` object | Client |
|
|
446
|
+
|
|
447
|
+
We chose client-managed state like Anthropic/OpenAI's Messages API, but with the full session object to preserve ConnectOnion's debugging features.
|
|
448
|
+
|
|
449
|
+
### When to Use Sessions
|
|
450
|
+
|
|
451
|
+
```python
|
|
452
|
+
# Single request - no session needed
|
|
453
|
+
{"prompt": "Translate hello to Spanish"}
|
|
454
|
+
|
|
455
|
+
# Multi-turn conversation - pass session
|
|
456
|
+
{"prompt": "What did I ask you?", "session": {...}}
|
|
457
|
+
|
|
458
|
+
# Start fresh - omit session
|
|
459
|
+
{"prompt": "New conversation"}
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
**Simple rule:** Save the `session` from each response. Pass it back if you want to continue.
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
## Project Structure
|
|
467
|
+
|
|
468
|
+
When you run `host(agent)`, these files are used:
|
|
469
|
+
|
|
470
|
+
```
|
|
471
|
+
your-project/
|
|
472
|
+
├── agent.py # Your agent code
|
|
473
|
+
├── .co/ # ConnectOnion data folder
|
|
474
|
+
│ ├── session_results.jsonl # Session result storage (created by host)
|
|
475
|
+
│ ├── logs/ # Activity logs (existing)
|
|
476
|
+
│ └── sessions/ # Session YAML (full conversation history)
|
|
477
|
+
└── .env # API keys (optional)
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
**On the network:**
|
|
481
|
+
|
|
482
|
+
```
|
|
483
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
484
|
+
│ Your Agent │
|
|
485
|
+
│ host(agent) │
|
|
486
|
+
├─────────────────────────────────────────────────────────────┤
|
|
487
|
+
│ │
|
|
488
|
+
│ HTTP Server (localhost:8000) │
|
|
489
|
+
│ ├── POST /input ← Submit prompts │
|
|
490
|
+
│ ├── GET /sessions/{id} ← Fetch results │
|
|
491
|
+
│ ├── GET /sessions ← List sessions │
|
|
492
|
+
│ ├── GET /health ← Health check │
|
|
493
|
+
│ ├── GET /info ← Agent info │
|
|
494
|
+
│ ├── GET /docs ← Interactive UI │
|
|
495
|
+
│ ├── GET /admin/logs ← Activity logs (API key auth) │
|
|
496
|
+
│ ├── GET /admin/sessions ← Session logs (API key auth) │
|
|
497
|
+
│ └── WS /ws ← Real-time WebSocket │
|
|
498
|
+
│ │
|
|
499
|
+
│ P2P Relay Connection │
|
|
500
|
+
│ └── wss://oo.openonion.ai/ws/announce │
|
|
501
|
+
│ │
|
|
502
|
+
└─────────────────────────────────────────────────────────────┘
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## Session Result Storage
|
|
508
|
+
|
|
509
|
+
Results are stored locally in `.co/session_results.jsonl` (JSON Lines format):
|
|
510
|
+
|
|
511
|
+
```jsonl
|
|
512
|
+
{"session_id":"550e8400","prompt":"Translate hello","status":"running","created":1702234567,"expires":1702320967}
|
|
513
|
+
{"session_id":"550e8400","prompt":"Translate hello","status":"done","result":"Hola","created":1702234567,"expires":1702320967}
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
**Why `.co/` folder?**
|
|
517
|
+
- Consistent with `.co/logs/` and `.co/evals/` (existing patterns)
|
|
518
|
+
- Project-specific (each project has its own results)
|
|
519
|
+
- Already in `.gitignore`
|
|
520
|
+
- Easy to find (in project directory)
|
|
521
|
+
|
|
522
|
+
**Why JSON Lines?**
|
|
523
|
+
- Human readable (`cat session_results.jsonl`)
|
|
524
|
+
- Append-only (safe for multiple workers)
|
|
525
|
+
- Single file (easy to manage)
|
|
526
|
+
- Queryable (`grep "550e8400" session_results.jsonl`)
|
|
527
|
+
|
|
528
|
+
**Benefits:**
|
|
529
|
+
- Connection drops? Fetch result later via `GET /sessions/{session_id}`
|
|
530
|
+
- Client restarts? Results still there
|
|
531
|
+
- Debug issues? Read the file directly
|
|
532
|
+
- Multiple workers? Append-only = no race conditions
|
|
533
|
+
|
|
534
|
+
### TTL Expiry
|
|
535
|
+
|
|
536
|
+
Each result has an `expires` timestamp. Default: 24 hours after creation.
|
|
537
|
+
|
|
538
|
+
```python
|
|
539
|
+
host(agent) # Default: 24h TTL
|
|
540
|
+
host(agent, result_ttl=3600) # 1 hour
|
|
541
|
+
host(agent, result_ttl=604800) # 7 days
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
Expired results are automatically cleaned up. Running sessions are never cleaned even if expired.
|
|
545
|
+
|
|
546
|
+
### View Results
|
|
547
|
+
|
|
548
|
+
```bash
|
|
549
|
+
# See all results
|
|
550
|
+
cat .co/session_results.jsonl
|
|
551
|
+
|
|
552
|
+
# Find specific session
|
|
553
|
+
grep "550e8400" .co/session_results.jsonl | tail -1
|
|
554
|
+
|
|
555
|
+
# See running sessions
|
|
556
|
+
grep '"status":"running"' .co/session_results.jsonl
|
|
557
|
+
|
|
558
|
+
# Pretty print
|
|
559
|
+
cat .co/session_results.jsonl | jq .
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
---
|
|
563
|
+
|
|
564
|
+
## Authentication (Signed Requests)
|
|
565
|
+
|
|
566
|
+
For secure communication, requests can be signed with Ed25519.
|
|
567
|
+
|
|
568
|
+
### Signed Request Format
|
|
569
|
+
|
|
570
|
+
```json
|
|
571
|
+
{
|
|
572
|
+
"payload": {
|
|
573
|
+
"prompt": "Translate hello",
|
|
574
|
+
"to": "0xAgentPublicKey",
|
|
575
|
+
"timestamp": 1702234567
|
|
576
|
+
},
|
|
577
|
+
"from": "0xClientPublicKey",
|
|
578
|
+
"signature": "0x..."
|
|
579
|
+
}
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
### How Signing Works
|
|
583
|
+
|
|
584
|
+
```python
|
|
585
|
+
import json
|
|
586
|
+
from nacl.signing import SigningKey
|
|
587
|
+
|
|
588
|
+
# Sign the payload directly
|
|
589
|
+
payload = {"prompt": "...", "to": "...", "timestamp": ...}
|
|
590
|
+
canonical = json.dumps(payload, sort_keys=True, separators=(',', ':'))
|
|
591
|
+
signature = signing_key.sign(canonical.encode()).signature.hex()
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
### Authentication Modes
|
|
595
|
+
|
|
596
|
+
| Trust Level | Required Auth |
|
|
597
|
+
|-------------|---------------|
|
|
598
|
+
| `open` | None (anonymous OK) |
|
|
599
|
+
| `careful` | Signature recommended |
|
|
600
|
+
| `strict` | Signature required |
|
|
601
|
+
|
|
602
|
+
---
|
|
603
|
+
|
|
604
|
+
## The `trust` Parameter
|
|
605
|
+
|
|
606
|
+
Trust controls **who can access your agent**. All forms of trust use a trust agent behind the scenes.
|
|
607
|
+
|
|
608
|
+
See [Trust in ConnectOnion](/docs/concepts/trust.md) for the complete trust system documentation.
|
|
609
|
+
|
|
610
|
+
### 1. Trust Level (string)
|
|
611
|
+
|
|
612
|
+
Pre-configured trust agents for common scenarios:
|
|
613
|
+
|
|
614
|
+
```python
|
|
615
|
+
host(agent, trust="open") # Accept all (development)
|
|
616
|
+
host(agent, trust="careful") # Recommend signature, accept unsigned (default)
|
|
617
|
+
host(agent, trust="strict") # Require valid signature (production)
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
| Level | Behavior |
|
|
621
|
+
|-------|----------|
|
|
622
|
+
| `open` | Accept all requests, no verification |
|
|
623
|
+
| `careful` | Recommend signature, accept unsigned requests |
|
|
624
|
+
| `strict` | Require identity and valid signature |
|
|
625
|
+
|
|
626
|
+
### 2. Trust Policy (natural language)
|
|
627
|
+
|
|
628
|
+
Express requirements in plain English - an LLM evaluates each request:
|
|
629
|
+
|
|
630
|
+
```python
|
|
631
|
+
host(agent, trust="""
|
|
632
|
+
I trust requests that:
|
|
633
|
+
- Come from known contacts with good history
|
|
634
|
+
- Have valid signatures
|
|
635
|
+
- Are on my whitelist OR from local network
|
|
636
|
+
|
|
637
|
+
I reject requests that:
|
|
638
|
+
- Come from blacklisted addresses
|
|
639
|
+
- Have no identity in production
|
|
640
|
+
""")
|
|
641
|
+
|
|
642
|
+
# Or from a file
|
|
643
|
+
host(agent, trust="./trust_policy.md")
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
### 3. Trust Agent (custom)
|
|
647
|
+
|
|
648
|
+
Full control with your own verification agent:
|
|
649
|
+
|
|
650
|
+
```python
|
|
651
|
+
guardian = Agent(
|
|
652
|
+
"my_guardian",
|
|
653
|
+
tools=[check_whitelist, verify_identity, check_reputation],
|
|
654
|
+
system_prompt="""
|
|
655
|
+
You verify requests before allowing interaction.
|
|
656
|
+
Return ACCEPT or REJECT with reason.
|
|
657
|
+
"""
|
|
658
|
+
)
|
|
659
|
+
|
|
660
|
+
host(agent, trust=guardian)
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
### Environment-Based Defaults
|
|
664
|
+
|
|
665
|
+
```python
|
|
666
|
+
# No trust parameter needed - auto-detected!
|
|
667
|
+
host(agent)
|
|
668
|
+
|
|
669
|
+
# CONNECTONION_ENV=development → trust="open"
|
|
670
|
+
# CONNECTONION_ENV=test → trust="careful"
|
|
671
|
+
# CONNECTONION_ENV=staging → trust="careful"
|
|
672
|
+
# CONNECTONION_ENV=production → trust="strict"
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
---
|
|
676
|
+
|
|
677
|
+
## Trust Flow
|
|
678
|
+
|
|
679
|
+
```
|
|
680
|
+
Request arrives
|
|
681
|
+
│
|
|
682
|
+
▼
|
|
683
|
+
┌─────────────────┐
|
|
684
|
+
│ Blacklist? │─── Yes ──▶ REJECT (403 forbidden)
|
|
685
|
+
└─────────────────┘
|
|
686
|
+
│ No
|
|
687
|
+
▼
|
|
688
|
+
┌─────────────────┐
|
|
689
|
+
│ Whitelist? │─── Yes ──▶ ACCEPT (bypass trust agent)
|
|
690
|
+
└─────────────────┘
|
|
691
|
+
│ No
|
|
692
|
+
▼
|
|
693
|
+
┌─────────────────┐
|
|
694
|
+
│ Signed request? │─── Yes ──▶ Verify signature
|
|
695
|
+
└─────────────────┘ │
|
|
696
|
+
│ No ├─ Invalid ──▶ REJECT (401)
|
|
697
|
+
│ │
|
|
698
|
+
▼ ▼
|
|
699
|
+
┌─────────────────────────────────────┐
|
|
700
|
+
│ Trust Agent evaluates request │
|
|
701
|
+
│ │
|
|
702
|
+
│ - Level? → Pre-configured agent │
|
|
703
|
+
│ - Policy? → LLM interprets policy │
|
|
704
|
+
│ - Agent? → Custom agent decides │
|
|
705
|
+
│ │
|
|
706
|
+
│ Input: prompt, identity, sig_valid │
|
|
707
|
+
│ Output: ACCEPT or REJECT │
|
|
708
|
+
└─────────────────────────────────────┘
|
|
709
|
+
│
|
|
710
|
+
├─ ACCEPT ──▶ Execute agent.input(prompt)
|
|
711
|
+
└─ REJECT ──▶ Return 403 forbidden
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
---
|
|
715
|
+
|
|
716
|
+
## Progress Updates (Custom)
|
|
717
|
+
|
|
718
|
+
The framework provides event hooks. You decide what progress to send.
|
|
719
|
+
|
|
720
|
+
```python
|
|
721
|
+
from connectonion import Agent, host, after_each_tool
|
|
722
|
+
|
|
723
|
+
def send_progress(agent):
|
|
724
|
+
# Your custom progress logic
|
|
725
|
+
iteration = agent.current_session["iteration"]
|
|
726
|
+
print(f"Progress: iteration {iteration}")
|
|
727
|
+
# Or send via your own WebSocket, webhook, etc.
|
|
728
|
+
|
|
729
|
+
agent = Agent("worker", on_events=[after_each_tool(send_progress)])
|
|
730
|
+
host(agent)
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
Available events:
|
|
734
|
+
- `after_user_input` - After receiving input
|
|
735
|
+
- `before_llm` - Before each LLM call
|
|
736
|
+
- `after_llm` - After each LLM call
|
|
737
|
+
- `before_each_tool` - Before each tool execution
|
|
738
|
+
- `after_each_tool` - After each tool execution
|
|
739
|
+
|
|
740
|
+
---
|
|
741
|
+
|
|
742
|
+
## Progressive Disclosure
|
|
743
|
+
|
|
744
|
+
### Level 0: Just Works
|
|
745
|
+
|
|
746
|
+
```python
|
|
747
|
+
host(agent)
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
### Level 1: Trust Control
|
|
751
|
+
|
|
752
|
+
```python
|
|
753
|
+
host(agent, trust="strict")
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
### Level 2: Access Control
|
|
757
|
+
|
|
758
|
+
```python
|
|
759
|
+
host(agent, blacklist=["0xbad..."], whitelist=["0xgood..."])
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
### Level 3: Production Scaling
|
|
763
|
+
|
|
764
|
+
```python
|
|
765
|
+
host(agent, workers=4, port=8000) # 4 uvicorn workers
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
Each worker is an OS process with isolated memory. Within each worker, requests get fresh agent copies.
|
|
769
|
+
|
|
770
|
+
### Level 4: Custom Trust Logic
|
|
771
|
+
|
|
772
|
+
```python
|
|
773
|
+
host(agent, trust=my_guardian_agent)
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
---
|
|
777
|
+
|
|
778
|
+
## Accessing Your Agent
|
|
779
|
+
|
|
780
|
+
### HTTP (Simple)
|
|
781
|
+
|
|
782
|
+
```python
|
|
783
|
+
import requests
|
|
784
|
+
|
|
785
|
+
# Single request
|
|
786
|
+
response = requests.post("http://localhost:8000/input", json={
|
|
787
|
+
"prompt": "Translate hello to Spanish"
|
|
788
|
+
})
|
|
789
|
+
print(response.json()["result"]) # "Hola"
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
### HTTP (Multi-turn)
|
|
793
|
+
|
|
794
|
+
```python
|
|
795
|
+
import requests
|
|
796
|
+
|
|
797
|
+
# First request
|
|
798
|
+
r1 = requests.post("http://localhost:8000/input", json={
|
|
799
|
+
"prompt": "My name is John"
|
|
800
|
+
})
|
|
801
|
+
session = r1.json()["session"] # Save session
|
|
802
|
+
|
|
803
|
+
# Second request - pass session back
|
|
804
|
+
r2 = requests.post("http://localhost:8000/input", json={
|
|
805
|
+
"prompt": "What is my name?",
|
|
806
|
+
"session": session # Continue conversation
|
|
807
|
+
})
|
|
808
|
+
print(r2.json()["result"]) # "Your name is John"
|
|
809
|
+
session = r2.json()["session"] # Update session for next request
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
### WebSocket (Real-time)
|
|
813
|
+
|
|
814
|
+
```python
|
|
815
|
+
import websockets
|
|
816
|
+
import json
|
|
817
|
+
|
|
818
|
+
async with websockets.connect("ws://localhost:8000/ws") as ws:
|
|
819
|
+
await ws.send(json.dumps({"type": "INPUT", "prompt": "Translate hello"}))
|
|
820
|
+
|
|
821
|
+
while True:
|
|
822
|
+
msg = json.loads(await ws.recv())
|
|
823
|
+
if msg["type"] == "OUTPUT":
|
|
824
|
+
print(msg["result"])
|
|
825
|
+
break
|
|
826
|
+
elif msg["type"] == "STREAM":
|
|
827
|
+
print(msg["chunk"], end="")
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
### P2P Relay (From Anywhere)
|
|
831
|
+
|
|
832
|
+
```python
|
|
833
|
+
from connectonion import connect
|
|
834
|
+
|
|
835
|
+
translator = connect("0x3d4017c3...660c")
|
|
836
|
+
result = translator.input("Translate hello to Spanish")
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
---
|
|
840
|
+
|
|
841
|
+
## Development vs Production
|
|
842
|
+
|
|
843
|
+
### Development
|
|
844
|
+
|
|
845
|
+
```python
|
|
846
|
+
host(agent, reload=True, trust="open")
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
- Auto-reloads on code changes
|
|
850
|
+
- No authentication required
|
|
851
|
+
|
|
852
|
+
### Production
|
|
853
|
+
|
|
854
|
+
```python
|
|
855
|
+
host(agent, workers=4, trust="strict")
|
|
856
|
+
```
|
|
857
|
+
|
|
858
|
+
- Multiple workers for parallel requests (OS-level isolation)
|
|
859
|
+
- Each request gets fresh agent copy (request-level isolation)
|
|
860
|
+
- Strict authentication and limits
|
|
861
|
+
|
|
862
|
+
---
|
|
863
|
+
|
|
864
|
+
## Deployment
|
|
865
|
+
|
|
866
|
+
### Direct
|
|
867
|
+
|
|
868
|
+
```bash
|
|
869
|
+
python myagent.py
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
### Standard Tooling
|
|
873
|
+
|
|
874
|
+
```python
|
|
875
|
+
# myagent.py
|
|
876
|
+
from connectonion import Agent, host
|
|
877
|
+
|
|
878
|
+
agent = Agent("translator", tools=[translate])
|
|
879
|
+
|
|
880
|
+
# Export ASGI app for uvicorn/gunicorn
|
|
881
|
+
app = host.app(agent)
|
|
882
|
+
|
|
883
|
+
if __name__ == "__main__":
|
|
884
|
+
host(agent)
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
```bash
|
|
888
|
+
# Uvicorn
|
|
889
|
+
uvicorn myagent:app --workers 4
|
|
890
|
+
|
|
891
|
+
# Gunicorn
|
|
892
|
+
gunicorn myagent:app -w 4 -k uvicorn.workers.UvicornWorker
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
### Docker
|
|
896
|
+
|
|
897
|
+
```dockerfile
|
|
898
|
+
FROM python:3.11-slim
|
|
899
|
+
RUN pip install connectonion
|
|
900
|
+
COPY myagent.py .
|
|
901
|
+
CMD ["python", "myagent.py"]
|
|
902
|
+
```
|
|
903
|
+
|
|
904
|
+
```yaml
|
|
905
|
+
# docker-compose.yml
|
|
906
|
+
services:
|
|
907
|
+
agent:
|
|
908
|
+
build: .
|
|
909
|
+
ports:
|
|
910
|
+
- "8000:8000"
|
|
911
|
+
environment:
|
|
912
|
+
- CONNECTONION_ENV=production
|
|
913
|
+
```
|
|
914
|
+
|
|
915
|
+
### Reverse Proxy (Caddy)
|
|
916
|
+
|
|
917
|
+
```
|
|
918
|
+
# Caddyfile
|
|
919
|
+
agent.example.com {
|
|
920
|
+
reverse_proxy localhost:8000
|
|
921
|
+
}
|
|
922
|
+
```
|
|
923
|
+
|
|
924
|
+
### systemd Service
|
|
925
|
+
|
|
926
|
+
```ini
|
|
927
|
+
# /etc/systemd/system/myagent.service
|
|
928
|
+
[Unit]
|
|
929
|
+
Description=My ConnectOnion Agent
|
|
930
|
+
After=network.target
|
|
931
|
+
|
|
932
|
+
[Service]
|
|
933
|
+
User=app
|
|
934
|
+
WorkingDirectory=/app
|
|
935
|
+
ExecStart=/usr/bin/python myagent.py
|
|
936
|
+
Restart=always
|
|
937
|
+
RestartSec=5
|
|
938
|
+
|
|
939
|
+
[Install]
|
|
940
|
+
WantedBy=multi-user.target
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
```bash
|
|
944
|
+
sudo systemctl enable myagent
|
|
945
|
+
sudo systemctl start myagent
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
---
|
|
949
|
+
|
|
950
|
+
## API Reference
|
|
951
|
+
|
|
952
|
+
### host()
|
|
953
|
+
|
|
954
|
+
```python
|
|
955
|
+
def host(
|
|
956
|
+
agent: Agent,
|
|
957
|
+
trust: Union[str, Agent] = "careful",
|
|
958
|
+
blacklist: list = None,
|
|
959
|
+
whitelist: list = None,
|
|
960
|
+
port: int = 8000,
|
|
961
|
+
workers: int = 1,
|
|
962
|
+
result_ttl: int = 86400,
|
|
963
|
+
relay_url: str = "wss://oo.openonion.ai/ws/announce",
|
|
964
|
+
reload: bool = False,
|
|
965
|
+
) -> None
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
| Parameter | Type | Default | Description |
|
|
969
|
+
|-----------|------|---------|-------------|
|
|
970
|
+
| `agent` | `Agent` | required | The agent to host |
|
|
971
|
+
| `trust` | `str` or `Agent` | `"careful"` | Trust level, policy, or agent |
|
|
972
|
+
| `blacklist` | `list` | `None` | Addresses to always reject |
|
|
973
|
+
| `whitelist` | `list` | `None` | Addresses to always accept |
|
|
974
|
+
| `port` | `int` | `8000` | HTTP port |
|
|
975
|
+
| `workers` | `int` | `1` | Number of uvicorn worker processes (each request also gets isolated agent copy) |
|
|
976
|
+
| `result_ttl` | `int` | `86400` | How long server keeps results (24h) |
|
|
977
|
+
| `relay_url` | `str` | production | P2P relay server |
|
|
978
|
+
| `reload` | `bool` | `False` | Auto-reload on changes |
|
|
979
|
+
|
|
980
|
+
### host.app()
|
|
981
|
+
|
|
982
|
+
```python
|
|
983
|
+
app = host.app(
|
|
984
|
+
agent: Agent,
|
|
985
|
+
trust: Union[str, Agent] = "careful",
|
|
986
|
+
blacklist: list = None,
|
|
987
|
+
whitelist: list = None,
|
|
988
|
+
result_ttl: int = 86400,
|
|
989
|
+
) -> ASGIApp
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
Returns ASGI app for use with uvicorn/gunicorn directly.
|
|
993
|
+
|
|
994
|
+
---
|
|
995
|
+
|
|
996
|
+
## Examples
|
|
997
|
+
|
|
998
|
+
### Minimal
|
|
999
|
+
|
|
1000
|
+
```python
|
|
1001
|
+
from connectonion import Agent, host
|
|
1002
|
+
|
|
1003
|
+
agent = Agent("helper", tools=[search])
|
|
1004
|
+
host(agent)
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
### With Trust
|
|
1008
|
+
|
|
1009
|
+
```python
|
|
1010
|
+
host(agent, trust="strict")
|
|
1011
|
+
```
|
|
1012
|
+
|
|
1013
|
+
### With Access Control
|
|
1014
|
+
|
|
1015
|
+
```python
|
|
1016
|
+
host(agent, blacklist=["0xbad..."], whitelist=["0xpartner..."])
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
### Production
|
|
1020
|
+
|
|
1021
|
+
```python
|
|
1022
|
+
host(agent, workers=4, trust="strict", reload=False)
|
|
1023
|
+
```
|
|
1024
|
+
|
|
1025
|
+
### Custom Trust Policy
|
|
1026
|
+
|
|
1027
|
+
```python
|
|
1028
|
+
host(agent, trust="Only accept from known contacts with >10 successful tasks")
|
|
1029
|
+
```
|
|
1030
|
+
|
|
1031
|
+
### Development
|
|
1032
|
+
|
|
1033
|
+
```python
|
|
1034
|
+
host(agent, reload=True, trust="open")
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
---
|
|
1038
|
+
|
|
1039
|
+
## Comparison with Other Frameworks
|
|
1040
|
+
|
|
1041
|
+
| Framework | To Deploy |
|
|
1042
|
+
|-----------|-----------|
|
|
1043
|
+
| FastAPI | Learn uvicorn, ASGI, workers |
|
|
1044
|
+
| Django | `runserver` vs gunicorn |
|
|
1045
|
+
| LangServe | FastAPI + uvicorn |
|
|
1046
|
+
| PydanticAI | Build everything yourself |
|
|
1047
|
+
| **ConnectOnion** | `host(agent)` |
|
|
1048
|
+
|
|
1049
|
+
**We hide the complexity. You just host.**
|