connectonion 0.6.1__py3-none-any.whl → 0.6.3__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 +95 -142
- connectonion/cli/browser_agent/element_finder.py +147 -0
- connectonion/cli/browser_agent/highlight_screenshot.py +182 -0
- connectonion/cli/browser_agent/prompt.md +188 -105
- connectonion/cli/browser_agent/prompts/element_matcher.md +59 -0
- connectonion/cli/browser_agent/prompts/form_filler.md +19 -0
- connectonion/cli/browser_agent/prompts/scroll_strategy.md +36 -0
- connectonion/cli/browser_agent/scripts/extract_elements.js +126 -0
- connectonion/cli/browser_agent/scroll.py +145 -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 +6 -0
- connectonion/cli/co_ai/plugins/reminder.py +76 -0
- connectonion/cli/co_ai/plugins/shell_approval.py +105 -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/reminders/plan_mode.md +34 -0
- connectonion/cli/co_ai/prompts/summarization.md +55 -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/reminders.py +159 -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 +172 -0
- connectonion/cli/co_ai/tools/read.py +67 -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 +100 -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_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 +2 -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/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.1.dist-info → connectonion-0.6.3.dist-info}/METADATA +10 -3
- connectonion-0.6.3.dist-info/RECORD +469 -0
- connectonion/cli/browser_agent/scroll_strategies.py +0 -276
- connectonion/network/asgi.py +0 -407
- connectonion/network/host.py +0 -616
- connectonion/network/trust.py +0 -166
- connectonion-0.6.1.dist-info/RECORD +0 -123
- /connectonion/cli/{docs → co_ai/prompts/connectonion}/connectonion.md +0 -0
- {connectonion-0.6.1.dist-info → connectonion-0.6.3.dist-info}/WHEEL +0 -0
- {connectonion-0.6.1.dist-info → connectonion-0.6.3.dist-info}/entry_points.txt +0 -0
connectonion/network/connect.py
CHANGED
|
@@ -1,46 +1,64 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Purpose: Client interface for connecting to remote agents
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
Purpose: Client interface for connecting to remote agents with real-time UI updates
|
|
3
|
+
|
|
4
|
+
Lifecycle (Client Side):
|
|
5
|
+
1. connect(address) creates RemoteAgent instance
|
|
6
|
+
2. agent.input(prompt) opens WebSocket to relay /ws/input endpoint
|
|
7
|
+
3. Sends INPUT message: {type: "INPUT", input_id, to, prompt, session?}
|
|
8
|
+
4. Receives streaming events: tool_call, tool_result, thinking, assistant
|
|
9
|
+
5. Receives final OUTPUT: {type: "OUTPUT", result, session} or ask_user
|
|
10
|
+
6. Returns Response(text, done) - done=False means agent asked a question
|
|
11
|
+
|
|
12
|
+
Message Flow:
|
|
13
|
+
Client → /ws/input → Relay → forwards to Agent's /ws/announce connection
|
|
14
|
+
Agent processes → sends OUTPUT → Relay resolves pending_outputs future
|
|
15
|
+
Relay → forwards OUTPUT → Client receives response
|
|
16
|
+
|
|
17
|
+
Related Files:
|
|
18
|
+
- oo-api/relay/routes.py: Relay server WebSocket endpoints
|
|
19
|
+
- connectonion/network/relay.py: Agent-side relay connection (serve_loop)
|
|
20
|
+
- connectonion-ts/src/connect.ts: TypeScript equivalent of this file
|
|
11
21
|
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
LLM-Note:
|
|
23
|
+
Dependencies: imports from [asyncio, json, uuid, time, websockets, address, dataclasses]
|
|
24
|
+
Data flow: connect(address) → RemoteAgent → input() → WebSocket /ws/input → events → Response
|
|
25
|
+
State/Effects: current_session synced from server | ui transforms server events
|
|
26
|
+
Integration: exposes connect(), RemoteAgent with .input(), .input_async(), .ui, .status
|
|
14
27
|
"""
|
|
15
28
|
|
|
16
29
|
import asyncio
|
|
17
30
|
import json
|
|
18
31
|
import time
|
|
19
32
|
import uuid
|
|
33
|
+
from dataclasses import dataclass
|
|
20
34
|
from typing import Any, Dict, List, Optional
|
|
21
35
|
|
|
22
36
|
from .. import address as addr
|
|
23
37
|
|
|
24
38
|
|
|
39
|
+
@dataclass
|
|
40
|
+
class Response:
|
|
41
|
+
"""Response from remote agent."""
|
|
42
|
+
text: str # Agent's response or question
|
|
43
|
+
done: bool # True = complete, False = needs more input (agent asked a question)
|
|
44
|
+
|
|
45
|
+
|
|
25
46
|
class RemoteAgent:
|
|
26
47
|
"""
|
|
27
|
-
Interface to a remote agent.
|
|
48
|
+
Interface to a remote agent with real-time UI updates.
|
|
28
49
|
|
|
29
50
|
Supports:
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
- Multi-turn conversations via session management
|
|
51
|
+
- WebSocket streaming for real-time events
|
|
52
|
+
- Session state synced from server
|
|
53
|
+
- UI events transformed for rendering
|
|
54
|
+
- Multi-turn conversations
|
|
35
55
|
|
|
36
56
|
Usage:
|
|
37
|
-
# Standard Python scripts
|
|
38
|
-
agent = connect("0x...")
|
|
39
|
-
result = agent.input("Hello")
|
|
40
|
-
|
|
41
|
-
# Jupyter notebooks or async code
|
|
42
57
|
agent = connect("0x...")
|
|
43
|
-
|
|
58
|
+
response = agent.input("Book a flight")
|
|
59
|
+
print(response.text) # "Which date?"
|
|
60
|
+
print(response.done) # False (agent asked a question)
|
|
61
|
+
print(agent.ui) # All events for rendering
|
|
44
62
|
"""
|
|
45
63
|
|
|
46
64
|
def __init__(
|
|
@@ -48,192 +66,219 @@ class RemoteAgent:
|
|
|
48
66
|
agent_address: str,
|
|
49
67
|
*,
|
|
50
68
|
keys: Optional[Dict[str, Any]] = None,
|
|
51
|
-
relay_url: str = "wss://oo.openonion.ai
|
|
69
|
+
relay_url: str = "wss://oo.openonion.ai"
|
|
52
70
|
):
|
|
53
71
|
self.address = agent_address
|
|
54
72
|
self._keys = keys
|
|
55
|
-
self._relay_url = relay_url
|
|
56
|
-
self.
|
|
57
|
-
self.
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
self._relay_url = relay_url.rstrip("/")
|
|
74
|
+
self._status = "idle"
|
|
75
|
+
self._current_session: Optional[Dict[str, Any]] = None
|
|
76
|
+
self._ui_events: List[Dict[str, Any]] = []
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def status(self) -> str:
|
|
80
|
+
"""Current status: 'idle' | 'working' | 'waiting'"""
|
|
81
|
+
return self._status
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def current_session(self) -> Optional[Dict[str, Any]]:
|
|
85
|
+
"""Session state synced from server (read-only)."""
|
|
86
|
+
return self._current_session
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def ui(self) -> List[Dict[str, Any]]:
|
|
90
|
+
"""UI events for rendering. One type = one component.
|
|
91
|
+
|
|
92
|
+
Server events are transformed:
|
|
93
|
+
- tool_call + tool_result merged into single UI item
|
|
94
|
+
- user_input → type: 'user'
|
|
95
|
+
- assistant → type: 'agent'
|
|
60
96
|
"""
|
|
61
|
-
|
|
97
|
+
return self._ui_events
|
|
62
98
|
|
|
63
|
-
|
|
99
|
+
def input(self, prompt: str, timeout: float = 60.0) -> Response:
|
|
100
|
+
"""
|
|
101
|
+
Send prompt to remote agent and get response.
|
|
64
102
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
103
|
+
Returns Response(text, done) where:
|
|
104
|
+
- done=True: Task complete
|
|
105
|
+
- done=False: Agent asked a question, send another input to answer
|
|
68
106
|
|
|
69
107
|
Args:
|
|
70
108
|
prompt: Task/prompt to send
|
|
71
|
-
timeout: Seconds to wait for response (default
|
|
109
|
+
timeout: Seconds to wait for response (default 60)
|
|
72
110
|
|
|
73
111
|
Returns:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
Raises:
|
|
77
|
-
RuntimeError: If called from within a running event loop
|
|
112
|
+
Response with text and done flag
|
|
78
113
|
|
|
79
114
|
Example:
|
|
80
|
-
>>>
|
|
81
|
-
>>>
|
|
82
|
-
|
|
83
|
-
>>> result2 = translator.input("Now translate it to French")
|
|
115
|
+
>>> response = agent.input("Book a flight to Tokyo")
|
|
116
|
+
>>> if not response.done:
|
|
117
|
+
... response = agent.input("March 15") # Answer the question
|
|
84
118
|
"""
|
|
85
119
|
try:
|
|
86
120
|
asyncio.get_running_loop()
|
|
87
121
|
raise RuntimeError(
|
|
88
|
-
"input() cannot be used inside async context
|
|
122
|
+
"input() cannot be used inside async context. "
|
|
89
123
|
"Use 'await agent.input_async()' instead."
|
|
90
124
|
)
|
|
91
125
|
except RuntimeError as e:
|
|
92
126
|
if "input() cannot be used" in str(e):
|
|
93
127
|
raise
|
|
94
|
-
|
|
95
|
-
return asyncio.run(self._send_task(prompt, timeout))
|
|
96
|
-
|
|
97
|
-
async def input_async(self, prompt: str, timeout: float = 30.0) -> str:
|
|
98
|
-
"""
|
|
99
|
-
Send task to remote agent and get response (async version).
|
|
128
|
+
return asyncio.run(self._stream_input(prompt, timeout))
|
|
100
129
|
|
|
101
|
-
|
|
130
|
+
async def input_async(self, prompt: str, timeout: float = 60.0) -> Response:
|
|
131
|
+
"""Async version of input()."""
|
|
132
|
+
return await self._stream_input(prompt, timeout)
|
|
102
133
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Agent's response string
|
|
109
|
-
"""
|
|
110
|
-
return await self._send_task(prompt, timeout)
|
|
111
|
-
|
|
112
|
-
def reset_conversation(self):
|
|
113
|
-
"""Clear conversation history and start fresh."""
|
|
114
|
-
self._session = None
|
|
115
|
-
|
|
116
|
-
def _sign_payload(self, payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
117
|
-
"""Sign a payload if keys are available."""
|
|
118
|
-
if not self._keys:
|
|
119
|
-
return {"prompt": payload.get("prompt", "")}
|
|
120
|
-
|
|
121
|
-
canonical = json.dumps(payload, sort_keys=True, separators=(',', ':'))
|
|
122
|
-
signature = addr.sign(self._keys, canonical.encode())
|
|
123
|
-
return {
|
|
124
|
-
"payload": payload,
|
|
125
|
-
"from": self._keys["address"],
|
|
126
|
-
"signature": signature.hex()
|
|
127
|
-
}
|
|
134
|
+
def reset(self) -> None:
|
|
135
|
+
"""Clear conversation and start fresh."""
|
|
136
|
+
self._current_session = None
|
|
137
|
+
self._ui_events = []
|
|
138
|
+
self._status = "idle"
|
|
128
139
|
|
|
129
|
-
async def
|
|
130
|
-
"""
|
|
131
|
-
import aiohttp
|
|
132
|
-
|
|
133
|
-
# Convert wss://oo.openonion.ai/ws/announce to https://oo.openonion.ai
|
|
134
|
-
base_url = self._relay_url.replace("wss://", "https://").replace("ws://", "http://")
|
|
135
|
-
base_url = base_url.replace("/ws/announce", "")
|
|
136
|
-
|
|
137
|
-
async with aiohttp.ClientSession() as session:
|
|
138
|
-
async with session.get(f"{base_url}/api/relay/agents/{self.address}") as resp:
|
|
139
|
-
if resp.status == 200:
|
|
140
|
-
data = await resp.json()
|
|
141
|
-
if data.get("online"):
|
|
142
|
-
return data.get("endpoints", [])
|
|
143
|
-
return []
|
|
144
|
-
|
|
145
|
-
def _create_signed_body(self, prompt: str) -> Dict[str, Any]:
|
|
146
|
-
"""Create signed request body for agent /input endpoint."""
|
|
147
|
-
payload = {"prompt": prompt, "to": self.address, "timestamp": int(time.time())}
|
|
148
|
-
body = self._sign_payload(payload)
|
|
149
|
-
if self._session:
|
|
150
|
-
body["session"] = self._session
|
|
151
|
-
return body
|
|
152
|
-
|
|
153
|
-
async def _send_http(self, endpoint: str, prompt: str, timeout: float) -> str:
|
|
154
|
-
"""Send request via direct HTTP POST to agent /input endpoint."""
|
|
155
|
-
import aiohttp
|
|
156
|
-
|
|
157
|
-
body = self._create_signed_body(prompt)
|
|
158
|
-
|
|
159
|
-
async with aiohttp.ClientSession() as http_session:
|
|
160
|
-
async with http_session.post(
|
|
161
|
-
f"{endpoint}/input",
|
|
162
|
-
json=body,
|
|
163
|
-
timeout=aiohttp.ClientTimeout(total=timeout)
|
|
164
|
-
) as resp:
|
|
165
|
-
data = await resp.json()
|
|
166
|
-
if not resp.ok:
|
|
167
|
-
raise ConnectionError(data.get("error", f"HTTP {resp.status}"))
|
|
168
|
-
# Save session for conversation continuation
|
|
169
|
-
if "session" in data:
|
|
170
|
-
self._session = data["session"]
|
|
171
|
-
return data.get("result", "")
|
|
172
|
-
|
|
173
|
-
async def _send_relay(self, prompt: str, timeout: float) -> str:
|
|
174
|
-
"""Send request via WebSocket relay."""
|
|
140
|
+
async def _stream_input(self, prompt: str, timeout: float) -> Response:
|
|
141
|
+
"""Send prompt via WebSocket and stream events."""
|
|
175
142
|
import websockets
|
|
176
143
|
|
|
177
|
-
|
|
178
|
-
relay_input_url = self._relay_url.replace("/ws/announce", "/ws/input")
|
|
144
|
+
self._status = "working"
|
|
179
145
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
146
|
+
# Add user event to UI
|
|
147
|
+
self._add_ui_event({
|
|
148
|
+
"type": "user",
|
|
149
|
+
"content": prompt
|
|
150
|
+
})
|
|
183
151
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
"input_id": input_id,
|
|
187
|
-
"to": self.address,
|
|
188
|
-
**signed
|
|
189
|
-
}
|
|
152
|
+
# Connect to relay's input endpoint
|
|
153
|
+
ws_url = f"{self._relay_url}/ws/input"
|
|
190
154
|
|
|
191
|
-
|
|
155
|
+
# Generate input_id for routing/response matching
|
|
156
|
+
import uuid
|
|
157
|
+
input_id = str(uuid.uuid4())
|
|
192
158
|
|
|
193
|
-
|
|
194
|
-
|
|
159
|
+
# Build the INPUT message
|
|
160
|
+
input_msg = {
|
|
161
|
+
"type": "INPUT",
|
|
162
|
+
"input_id": input_id,
|
|
163
|
+
"prompt": prompt,
|
|
164
|
+
"to": self.address,
|
|
165
|
+
"timestamp": int(time.time())
|
|
166
|
+
}
|
|
195
167
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
raise ConnectionError(f"Agent error: {response.get('error')}")
|
|
200
|
-
else:
|
|
201
|
-
raise ConnectionError(f"Unexpected response: {response}")
|
|
168
|
+
# Add session for conversation continuation
|
|
169
|
+
if self._current_session:
|
|
170
|
+
input_msg["session"] = self._current_session
|
|
202
171
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
172
|
+
# Sign if keys provided
|
|
173
|
+
if self._keys:
|
|
174
|
+
payload = {"prompt": prompt, "to": self.address, "timestamp": input_msg["timestamp"]}
|
|
175
|
+
canonical = json.dumps(payload, sort_keys=True, separators=(',', ':'))
|
|
176
|
+
signature = addr.sign(self._keys, canonical.encode())
|
|
177
|
+
input_msg["payload"] = payload
|
|
178
|
+
input_msg["from"] = self._keys["address"]
|
|
179
|
+
input_msg["signature"] = signature.hex()
|
|
206
180
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
181
|
+
try:
|
|
182
|
+
async with websockets.connect(ws_url) as ws:
|
|
183
|
+
await ws.send(json.dumps(input_msg))
|
|
184
|
+
|
|
185
|
+
# Stream events until OUTPUT or timeout
|
|
186
|
+
result_text = ""
|
|
187
|
+
done = True
|
|
188
|
+
|
|
189
|
+
while True:
|
|
190
|
+
# Wrap recv in timeout to prevent hanging indefinitely
|
|
191
|
+
msg = await asyncio.wait_for(ws.recv(), timeout=timeout)
|
|
192
|
+
event = json.loads(msg)
|
|
193
|
+
event_type = event.get("type")
|
|
194
|
+
|
|
195
|
+
if event_type == "OUTPUT":
|
|
196
|
+
# Final result
|
|
197
|
+
result_text = event.get("result", "")
|
|
198
|
+
self._current_session = event.get("session")
|
|
199
|
+
self._status = "idle"
|
|
200
|
+
|
|
201
|
+
# Add agent response to UI
|
|
202
|
+
self._add_ui_event({
|
|
203
|
+
"type": "agent",
|
|
204
|
+
"content": result_text
|
|
205
|
+
})
|
|
206
|
+
break
|
|
207
|
+
|
|
208
|
+
elif event_type == "ERROR":
|
|
209
|
+
self._status = "idle"
|
|
210
|
+
raise ConnectionError(f"Agent error: {event.get('message', event.get('error'))}")
|
|
211
|
+
|
|
212
|
+
elif event_type == "ask_user":
|
|
213
|
+
# Agent is asking a question - return done=False so caller sends another input()
|
|
214
|
+
self._status = "waiting"
|
|
215
|
+
done = False
|
|
216
|
+
result_text = event.get("text", "")
|
|
217
|
+
|
|
218
|
+
# Add ask_user event to UI
|
|
219
|
+
self._add_ui_event({
|
|
220
|
+
"type": "ask_user",
|
|
221
|
+
"text": event.get("text"),
|
|
222
|
+
"options": event.get("options")
|
|
223
|
+
})
|
|
224
|
+
break
|
|
225
|
+
|
|
226
|
+
else:
|
|
227
|
+
# Stream event (tool_call, tool_result, thinking, etc.)
|
|
228
|
+
self._handle_stream_event(event)
|
|
229
|
+
|
|
230
|
+
return Response(text=result_text, done=done)
|
|
231
|
+
|
|
232
|
+
except asyncio.TimeoutError:
|
|
233
|
+
self._status = "idle"
|
|
234
|
+
raise TimeoutError(f"Request timed out after {timeout}s")
|
|
235
|
+
|
|
236
|
+
def _handle_stream_event(self, event: Dict[str, Any]) -> None:
|
|
237
|
+
"""Handle streaming event and update UI."""
|
|
238
|
+
event_type = event.get("type")
|
|
239
|
+
|
|
240
|
+
if event_type == "tool_call":
|
|
241
|
+
# Add new tool_call UI event with running status
|
|
242
|
+
self._add_ui_event({
|
|
243
|
+
"type": "tool_call",
|
|
244
|
+
"id": event.get("id"),
|
|
245
|
+
"name": event.get("name"),
|
|
246
|
+
"args": event.get("args"),
|
|
247
|
+
"status": "running"
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
elif event_type == "tool_result":
|
|
251
|
+
# Find and update existing tool_call by id
|
|
252
|
+
tool_id = event.get("id")
|
|
253
|
+
for ui_event in self._ui_events:
|
|
254
|
+
if ui_event.get("type") == "tool_call" and ui_event.get("id") == tool_id:
|
|
255
|
+
ui_event["status"] = "done" if event.get("status") == "success" else "error"
|
|
256
|
+
ui_event["result"] = event.get("result")
|
|
257
|
+
break
|
|
258
|
+
|
|
259
|
+
elif event_type == "thinking":
|
|
260
|
+
self._add_ui_event({"type": "thinking"})
|
|
261
|
+
|
|
262
|
+
elif event_type == "user_input":
|
|
263
|
+
# Already added when input() called, skip
|
|
264
|
+
pass
|
|
265
|
+
|
|
266
|
+
elif event_type == "assistant":
|
|
267
|
+
self._add_ui_event({
|
|
268
|
+
"type": "agent",
|
|
269
|
+
"content": event.get("content")
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
elif event_type == "llm_call":
|
|
273
|
+
# Internal event, add thinking indicator if not already present
|
|
274
|
+
if not any(e.get("type") == "thinking" for e in self._ui_events[-3:]):
|
|
275
|
+
self._add_ui_event({"type": "thinking"})
|
|
276
|
+
|
|
277
|
+
def _add_ui_event(self, event: Dict[str, Any]) -> None:
|
|
278
|
+
"""Add event to UI with auto-generated id."""
|
|
279
|
+
if "id" not in event:
|
|
280
|
+
event["id"] = str(len(self._ui_events) + 1)
|
|
281
|
+
self._ui_events.append(event)
|
|
237
282
|
|
|
238
283
|
def __repr__(self):
|
|
239
284
|
short = self.address[:12] + "..." if len(self.address) > 12 else self.address
|
|
@@ -244,7 +289,7 @@ def connect(
|
|
|
244
289
|
address: str,
|
|
245
290
|
*,
|
|
246
291
|
keys: Optional[Dict[str, Any]] = None,
|
|
247
|
-
relay_url: str = "wss://oo.openonion.ai
|
|
292
|
+
relay_url: str = "wss://oo.openonion.ai"
|
|
248
293
|
) -> RemoteAgent:
|
|
249
294
|
"""
|
|
250
295
|
Connect to a remote agent.
|
|
@@ -252,21 +297,23 @@ def connect(
|
|
|
252
297
|
Args:
|
|
253
298
|
address: Agent's public key address (0x...)
|
|
254
299
|
keys: Signing keys from address.load() - required for strict trust agents
|
|
255
|
-
relay_url: Relay server URL (default: production)
|
|
300
|
+
relay_url: Relay server base URL (default: production)
|
|
256
301
|
|
|
257
302
|
Returns:
|
|
258
|
-
RemoteAgent interface
|
|
303
|
+
RemoteAgent interface with real-time UI updates
|
|
259
304
|
|
|
260
305
|
Example:
|
|
261
|
-
>>> from connectonion import connect
|
|
306
|
+
>>> from connectonion import connect
|
|
262
307
|
>>>
|
|
263
|
-
>>> # Simple (unsigned)
|
|
264
308
|
>>> agent = connect("0x3d4017c3...")
|
|
265
|
-
>>>
|
|
309
|
+
>>> response = agent.input("Book a flight")
|
|
310
|
+
>>> print(response.text) # "Which date?"
|
|
311
|
+
>>> print(response.done) # False
|
|
312
|
+
>>> print(agent.ui) # All events for rendering
|
|
313
|
+
>>> print(agent.status) # 'waiting'
|
|
266
314
|
>>>
|
|
267
|
-
>>>
|
|
268
|
-
>>>
|
|
269
|
-
>>>
|
|
270
|
-
>>> result = agent.input("Hello")
|
|
315
|
+
>>> response = agent.input("March 15")
|
|
316
|
+
>>> print(response.text) # "Booked! Confirmation #ABC123"
|
|
317
|
+
>>> print(response.done) # True
|
|
271
318
|
"""
|
|
272
319
|
return RemoteAgent(address, keys=keys, relay_url=relay_url)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Purpose: Host module re-exporting session, auth, routes, and server components for agent hosting
|
|
3
|
+
LLM-Note:
|
|
4
|
+
Dependencies: imports from [session.py, auth.py, routes.py, server.py] | imported by [network/__init__.py, user code] | tested via integration tests
|
|
5
|
+
Data flow: pure re-export module aggregating host functionality
|
|
6
|
+
State/Effects: no state
|
|
7
|
+
Integration: exposes host(agent, port, trust) main entry point, Session/SessionStorage for persistence, auth utilities (verify_signature, extract_and_authenticate, get_agent_address, is_custom_trust), route handlers (input_handler, session_handler, health_handler, info_handler, admin_*), create_app() ASGI factory, get_default_trust() helper
|
|
8
|
+
Performance: trivial
|
|
9
|
+
Errors: none
|
|
10
|
+
Host an agent over HTTP/WebSocket.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from .session import Session, SessionStorage
|
|
14
|
+
from .auth import (
|
|
15
|
+
verify_signature,
|
|
16
|
+
extract_and_authenticate,
|
|
17
|
+
get_agent_address,
|
|
18
|
+
is_custom_trust,
|
|
19
|
+
SIGNATURE_EXPIRY_SECONDS,
|
|
20
|
+
)
|
|
21
|
+
from .routes import (
|
|
22
|
+
input_handler,
|
|
23
|
+
session_handler,
|
|
24
|
+
sessions_handler,
|
|
25
|
+
health_handler,
|
|
26
|
+
info_handler,
|
|
27
|
+
admin_logs_handler,
|
|
28
|
+
admin_sessions_handler,
|
|
29
|
+
)
|
|
30
|
+
from .server import (
|
|
31
|
+
host,
|
|
32
|
+
get_default_trust,
|
|
33
|
+
create_app,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
# Main entry point
|
|
38
|
+
"host",
|
|
39
|
+
# Session
|
|
40
|
+
"Session",
|
|
41
|
+
"SessionStorage",
|
|
42
|
+
# Auth
|
|
43
|
+
"verify_signature",
|
|
44
|
+
"extract_and_authenticate",
|
|
45
|
+
"get_agent_address",
|
|
46
|
+
"is_custom_trust",
|
|
47
|
+
"SIGNATURE_EXPIRY_SECONDS",
|
|
48
|
+
# Routes
|
|
49
|
+
"input_handler",
|
|
50
|
+
"session_handler",
|
|
51
|
+
"sessions_handler",
|
|
52
|
+
"health_handler",
|
|
53
|
+
"info_handler",
|
|
54
|
+
"admin_logs_handler",
|
|
55
|
+
"admin_sessions_handler",
|
|
56
|
+
# Helpers
|
|
57
|
+
"get_default_trust",
|
|
58
|
+
"create_app",
|
|
59
|
+
]
|