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
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
# Design Decision: Global Config and Identity Management
|
|
2
|
+
|
|
3
|
+
*Date: 2025-09-18*
|
|
4
|
+
*Decision: One global identity (address + email) shared by all projects*
|
|
5
|
+
*Status: Implemented*
|
|
6
|
+
|
|
7
|
+
## The Problem We Saw
|
|
8
|
+
|
|
9
|
+
Every Friday, we'd watch developers create their 5th ConnectOnion project of the week. And every time, the same ritual:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
$ co create another-bot
|
|
13
|
+
✔ Enter your OpenAI API key: sk-proj-xxx... # Same key as before
|
|
14
|
+
✓ Generated address: 0x4f5a... # 5th address this week
|
|
15
|
+
✓ Agent email: 0x4f5a@openonion.ai # 5th email to track
|
|
16
|
+
✓ Created recovery phrase... # 5th phrase to backup
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
By project #10, developers had:
|
|
20
|
+
- Entered the same API key 10 times
|
|
21
|
+
- Generated 10 different addresses they'd never use
|
|
22
|
+
- Created 10 emails they couldn't remember
|
|
23
|
+
- Saved 10 recovery phrases they'd definitely lose
|
|
24
|
+
|
|
25
|
+
**The breaking point:** A user asked us, "Why does my local test bot need a different email address than my production bot? They're both me."
|
|
26
|
+
|
|
27
|
+
They were right. We were forcing unnecessary complexity.
|
|
28
|
+
|
|
29
|
+
## The Core Insight
|
|
30
|
+
|
|
31
|
+
> "Your laptop has one user account. Your browser has one profile. Why should every agent need its own identity?"
|
|
32
|
+
|
|
33
|
+
Most developers ARE their agents. The agent's email is effectively the developer's email. The agent's address represents the developer. Creating separate identities for every project is like creating a new email account for every document you write.
|
|
34
|
+
|
|
35
|
+
## What We Changed
|
|
36
|
+
|
|
37
|
+
### Before: Every Project Is an Island
|
|
38
|
+
```
|
|
39
|
+
project1/.co/
|
|
40
|
+
├── keys/
|
|
41
|
+
│ ├── agent.key # Unique keypair
|
|
42
|
+
│ └── recovery.txt # Unique recovery phrase
|
|
43
|
+
└── config.toml # address: 0x1234..., email: 0x1234@openonion.ai
|
|
44
|
+
|
|
45
|
+
project2/.co/
|
|
46
|
+
├── keys/
|
|
47
|
+
│ ├── agent.key # Different keypair
|
|
48
|
+
│ └── recovery.txt # Different recovery phrase
|
|
49
|
+
└── config.toml # address: 0x5678..., email: 0x5678@openonion.ai
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### After: One Identity, Many Projects
|
|
53
|
+
```
|
|
54
|
+
~/.co/ # GLOBAL
|
|
55
|
+
├── config.toml # Your identity (address + email)
|
|
56
|
+
├── keys.env # Your API keys (one place!)
|
|
57
|
+
└── keys/
|
|
58
|
+
└── master.key # Your keypair
|
|
59
|
+
|
|
60
|
+
project1/.co/
|
|
61
|
+
└── config.toml # Uses global address + email
|
|
62
|
+
|
|
63
|
+
project2/.co/
|
|
64
|
+
└── config.toml # Same global address + email
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## The Complete Design
|
|
68
|
+
|
|
69
|
+
### 1. Global Identity (Address + Email)
|
|
70
|
+
|
|
71
|
+
Every user gets ONE identity when they first run `co create`:
|
|
72
|
+
|
|
73
|
+
```toml
|
|
74
|
+
# ~/.co/config.toml
|
|
75
|
+
[agent]
|
|
76
|
+
address = "0x7b78b4cf850331c4b26dac089eb9cd84493483eccbf0e067f1c36e1c7f570e6b"
|
|
77
|
+
short_address = "0x7b78...0e6b"
|
|
78
|
+
email = "0x7b78b4cf@openonion.ai" # Derived from address
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
This identity is **automatically copied** to every project:
|
|
82
|
+
- Same address for all agents
|
|
83
|
+
- Same email for all agents
|
|
84
|
+
- One identity to rule them all
|
|
85
|
+
|
|
86
|
+
### 2. Global API Keys
|
|
87
|
+
|
|
88
|
+
API keys live in ONE place and are copied to all projects:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# ~/.co/keys.env (global)
|
|
92
|
+
OPENAI_API_KEY=sk-proj-xxx
|
|
93
|
+
ANTHROPIC_API_KEY=sk-ant-xxx
|
|
94
|
+
|
|
95
|
+
# Automatically copied to:
|
|
96
|
+
# - project1/.env
|
|
97
|
+
# - project2/.env
|
|
98
|
+
# - project3/.env
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Why `.env` format?** Because it's the universal standard. No JSON parsing, no YAML confusion, just `KEY=value`.
|
|
102
|
+
|
|
103
|
+
### 3. Progressive Complexity
|
|
104
|
+
|
|
105
|
+
Start simple, add complexity only when needed:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# 99% of projects - use global everything
|
|
109
|
+
$ co create my-bot
|
|
110
|
+
✓ Using global identity: 0x7b78...0e6b
|
|
111
|
+
✓ Using global email: 0x7b78b4cf@openonion.ai
|
|
112
|
+
✓ Copied API keys from ~/.co/keys.env
|
|
113
|
+
|
|
114
|
+
# 1% of projects - need their own identity
|
|
115
|
+
$ cd special-project
|
|
116
|
+
$ co address
|
|
117
|
+
✓ Generated project-specific address: 0x9c7d...
|
|
118
|
+
✓ Generated project-specific email: 0x9c7d@openonion.ai
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Implementation Principles
|
|
122
|
+
|
|
123
|
+
### 1. Fail Fast, Fail Loud
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
# OLD - Silent failure
|
|
127
|
+
try:
|
|
128
|
+
addr_data = address.generate()
|
|
129
|
+
except:
|
|
130
|
+
addr_data = {"address": "0x000..."} # User wonders why address is zeros
|
|
131
|
+
|
|
132
|
+
# NEW - Immediate feedback
|
|
133
|
+
addr_data = address.generate() # Crashes with clear error if PyNaCl missing
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 2. Install Everything by Default
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
# setup.py
|
|
140
|
+
requirements = [
|
|
141
|
+
"PyNaCl>=1.5.0", # No longer optional
|
|
142
|
+
"mnemonic>=0.20", # No longer optional
|
|
143
|
+
"questionary>=2.0.0", # No longer optional
|
|
144
|
+
]
|
|
145
|
+
# Only playwright remains optional (it's 100MB+)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Why?** Because "Module not found" after installation is user-hostile.
|
|
149
|
+
|
|
150
|
+
### 3. One Source of Truth
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
~/.co/config.toml → Global identity (address + email)
|
|
154
|
+
~/.co/keys.env → API keys
|
|
155
|
+
~/.co/keys/ → Cryptographic keys
|
|
156
|
+
|
|
157
|
+
Everything else copies from these.
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## User Experience Transformation
|
|
161
|
+
|
|
162
|
+
### First Project (First Time Ever)
|
|
163
|
+
```bash
|
|
164
|
+
$ co create my-first-agent
|
|
165
|
+
|
|
166
|
+
🚀 Welcome to ConnectOnion!
|
|
167
|
+
✨ Setting up global configuration...
|
|
168
|
+
✓ Generated master keypair
|
|
169
|
+
✓ Your address: 0x7b78...0e6b
|
|
170
|
+
✓ Your email: 0x7b78b4cf@openonion.ai
|
|
171
|
+
✓ Created ~/.co/config.toml
|
|
172
|
+
✓ Created ~/.co/keys.env
|
|
173
|
+
|
|
174
|
+
✔ Enter your API key: sk-proj-xxx
|
|
175
|
+
✓ Saved to ~/.co/keys.env for all future projects
|
|
176
|
+
|
|
177
|
+
✅ Project created!
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Every Project After That
|
|
181
|
+
```bash
|
|
182
|
+
$ co create another-agent
|
|
183
|
+
|
|
184
|
+
✓ Using global identity: 0x7b78...0e6b
|
|
185
|
+
✓ Using global email: 0x7b78b4cf@openonion.ai
|
|
186
|
+
✓ Found OpenAI key in ~/.co/keys.env
|
|
187
|
+
✓ Copied to project .env
|
|
188
|
+
|
|
189
|
+
✅ Project created in 2 seconds!
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### The 50th Project
|
|
193
|
+
```bash
|
|
194
|
+
$ co create yet-another-agent
|
|
195
|
+
|
|
196
|
+
✓ Using global identity: 0x7b78...0e6b
|
|
197
|
+
✓ Using global email: 0x7b78b4cf@openonion.ai
|
|
198
|
+
✓ Copied API keys from ~/.co/keys.env
|
|
199
|
+
|
|
200
|
+
✅ Still just 2 seconds!
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Real-World Analogies That Clicked
|
|
204
|
+
|
|
205
|
+
**Email:** You don't create a new email address for every document you write. You use your one email.
|
|
206
|
+
|
|
207
|
+
**SSH Keys:** Most developers use one SSH key for all their repositories, not one key per repo.
|
|
208
|
+
|
|
209
|
+
**Phone Number:** You don't get a new phone number for each app you install.
|
|
210
|
+
|
|
211
|
+
**Office Building:** You have one keycard that opens all the doors you're authorized for, not 50 different keys.
|
|
212
|
+
|
|
213
|
+
## The Philosophy
|
|
214
|
+
|
|
215
|
+
This design embodies our core principle:
|
|
216
|
+
|
|
217
|
+
> **"Keep simple things simple, make complicated things possible"**
|
|
218
|
+
|
|
219
|
+
- **Simple:** One identity, one email, one place for API keys
|
|
220
|
+
- **Possible:** Need project-specific identity? Run `co address`
|
|
221
|
+
|
|
222
|
+
We're not removing capabilities, we're changing defaults. The complex path still exists for those who need it, but the simple path is now the default.
|
|
223
|
+
|
|
224
|
+
## What This Enables
|
|
225
|
+
|
|
226
|
+
### Today
|
|
227
|
+
- Zero-friction project creation
|
|
228
|
+
- No more API key repetition
|
|
229
|
+
- One identity to remember
|
|
230
|
+
- One email for all agents
|
|
231
|
+
|
|
232
|
+
### Tomorrow
|
|
233
|
+
- **Network Features:** Your global identity becomes your network account
|
|
234
|
+
- **Reputation:** One reputation score across all your agents
|
|
235
|
+
- **Discovery:** Find all agents by one developer
|
|
236
|
+
- **Payments:** One wallet for ConnectOnion credits
|
|
237
|
+
|
|
238
|
+
## Lessons We Learned
|
|
239
|
+
|
|
240
|
+
1. **Users hate repetition more than they love security**
|
|
241
|
+
- Theoretical: "Each project should be isolated"
|
|
242
|
+
- Reality: "Just let me build my bot"
|
|
243
|
+
|
|
244
|
+
2. **Defaults matter more than options**
|
|
245
|
+
- Having the option for project keys isn't enough
|
|
246
|
+
- The default path must be the right path for 99% of users
|
|
247
|
+
|
|
248
|
+
3. **Explicit is better than magical**
|
|
249
|
+
- Show "(global)" next to addresses
|
|
250
|
+
- Tell users they're using global identity
|
|
251
|
+
- Make the behavior obvious
|
|
252
|
+
|
|
253
|
+
4. **Directory names matter**
|
|
254
|
+
- `~/.co/keys/` is clear and concrete
|
|
255
|
+
- `~/.co/identity/` was abstract and confusing
|
|
256
|
+
- Users understand "keys", they question "identity"
|
|
257
|
+
|
|
258
|
+
## The Result
|
|
259
|
+
|
|
260
|
+
Before: 10 projects = 10 identities, 10 emails, 10 API key entries, 10 recovery phrases
|
|
261
|
+
|
|
262
|
+
After: 10 projects = 1 identity, 1 email, 0 API key entries (after first), 1 recovery phrase
|
|
263
|
+
|
|
264
|
+
**Time to create project #10:**
|
|
265
|
+
- Before: 2 minutes (entering API key, saving recovery phrase)
|
|
266
|
+
- After: 2 seconds
|
|
267
|
+
|
|
268
|
+
## Deeper Philosophical Insights
|
|
269
|
+
|
|
270
|
+
### The Identity Paradox
|
|
271
|
+
|
|
272
|
+
We started with a computer science assumption: "Each agent needs its own cryptographic identity for security and isolation." But we discovered a human truth: **Identity isn't about isolation, it's about connection.**
|
|
273
|
+
|
|
274
|
+
When developers create agents, they're not creating separate entities—they're extending themselves. The agent IS the developer, speaking through code. Forcing separate identities was like forcing someone to use different signatures for every document they sign.
|
|
275
|
+
|
|
276
|
+
### The Simplicity Gradient
|
|
277
|
+
|
|
278
|
+
Most systems force you up the complexity mountain immediately:
|
|
279
|
+
```
|
|
280
|
+
Day 1: "Here's your keypair, recovery phrase, wallet address,
|
|
281
|
+
API configuration, network registration..."
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
We inverted this. Start at sea level, climb only when you need the altitude:
|
|
285
|
+
```
|
|
286
|
+
Day 1: "Here's your agent. It works."
|
|
287
|
+
Day 1000: "Oh, you need deployment keys? Run 'co address'."
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**Insight:** Complexity should be proportional to ambition, not a entry fee.
|
|
291
|
+
|
|
292
|
+
### The Locality Principle
|
|
293
|
+
|
|
294
|
+
We observed that trust and identity operate differently at different scales:
|
|
295
|
+
|
|
296
|
+
- **Local (your machine):** Everything trusts everything. One identity makes sense.
|
|
297
|
+
- **Team (your organization):** Selective trust. Some shared identity, some unique.
|
|
298
|
+
- **Global (the internet):** Zero trust. Every agent needs unique identity.
|
|
299
|
+
|
|
300
|
+
Our design mirrors this reality. Local development uses global identity (high trust), deployment triggers project identity (low trust).
|
|
301
|
+
|
|
302
|
+
### The Repetition Revelation
|
|
303
|
+
|
|
304
|
+
Every time a user enters the same API key again, they're not thinking "good security practice." They're thinking "this tool doesn't respect my time."
|
|
305
|
+
|
|
306
|
+
**The principle we discovered:** Repetition without purpose is disrespect.
|
|
307
|
+
|
|
308
|
+
If the API key is the same, if the user is the same, if the purpose is the same—why pretend otherwise?
|
|
309
|
+
|
|
310
|
+
### The Conservation of Complexity
|
|
311
|
+
|
|
312
|
+
We realized we couldn't eliminate complexity, only move it:
|
|
313
|
+
|
|
314
|
+
**Option A:** Complex for users (our old way)
|
|
315
|
+
- Users manage multiple identities
|
|
316
|
+
- Users enter API keys repeatedly
|
|
317
|
+
- Users track which key is which
|
|
318
|
+
|
|
319
|
+
**Option B:** Complex for us (our new way)
|
|
320
|
+
- We manage global config initialization
|
|
321
|
+
- We handle key copying logic
|
|
322
|
+
- We provide migration paths
|
|
323
|
+
|
|
324
|
+
We chose to bear the complexity so users don't have to. **This is the fundamental trade-off of good design: the creator suffers so the user doesn't.**
|
|
325
|
+
|
|
326
|
+
### The YAGNI Principle (You Aren't Gonna Need It)
|
|
327
|
+
|
|
328
|
+
We asked ourselves: "How many projects actually need separate identities?"
|
|
329
|
+
|
|
330
|
+
Real data from users:
|
|
331
|
+
- Local experiments: 70% (don't need unique identity)
|
|
332
|
+
- Learning projects: 20% (don't need unique identity)
|
|
333
|
+
- Shared demos: 8% (don't need unique identity)
|
|
334
|
+
- Production deployments: 2% (might need unique identity)
|
|
335
|
+
|
|
336
|
+
We were optimizing for the 2% while punishing the 98%.
|
|
337
|
+
|
|
338
|
+
## The Ultimate Principle
|
|
339
|
+
|
|
340
|
+
After all the analysis, we arrived at a simple truth:
|
|
341
|
+
|
|
342
|
+
> **"The tool should work the way humans think, not the way computers compute."**
|
|
343
|
+
|
|
344
|
+
Humans think: "I am creating these agents, they represent me."
|
|
345
|
+
Computers compute: "Each process needs isolated credentials."
|
|
346
|
+
|
|
347
|
+
We chose the human way.
|
|
348
|
+
|
|
349
|
+
## Conclusion
|
|
350
|
+
|
|
351
|
+
By making identity and email global by default, we removed the biggest source of friction in ConnectOnion. Developers can now focus on building agents, not managing identities.
|
|
352
|
+
|
|
353
|
+
The design follows our core philosophy: **"Keep simple things simple, make complicated things possible."**
|
|
354
|
+
|
|
355
|
+
But more deeply, it reflects a belief about tools and their users: The best tools disappear. They don't announce their complexity or demand your attention. They quietly do what you expect, so you can focus on what you're creating, not on the tool itself.
|
|
356
|
+
|
|
357
|
+
Sometimes the best design decision is recognizing that developers don't want to manage infrastructure—they want to build. And sometimes, the most profound technical decision is choosing to be less technical.
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# Design Decision: Why We Split Tool Execution from Agent.py
|
|
2
|
+
|
|
3
|
+
*Date: 2025-09-26*
|
|
4
|
+
*Status: Implemented*
|
|
5
|
+
*Impact: Major refactoring reducing agent.py from 400+ to 260 lines*
|
|
6
|
+
|
|
7
|
+
## The Problem: A 150-Line Monster Method
|
|
8
|
+
|
|
9
|
+
Our `agent.py` had become a jungle. The `input()` method alone was 150+ lines of deeply nested code:
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
def input(self, prompt):
|
|
13
|
+
# Setup messages...
|
|
14
|
+
# Call LLM...
|
|
15
|
+
# If tool calls:
|
|
16
|
+
# For each tool:
|
|
17
|
+
# Try:
|
|
18
|
+
# Setup xray context...
|
|
19
|
+
# Time execution...
|
|
20
|
+
# Execute tool...
|
|
21
|
+
# Update history...
|
|
22
|
+
# Format messages...
|
|
23
|
+
# Except:
|
|
24
|
+
# Handle errors...
|
|
25
|
+
# Clean up context...
|
|
26
|
+
# More error handling...
|
|
27
|
+
# Save history...
|
|
28
|
+
# Return result...
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Reading this code was like solving a puzzle. Testing it? Nearly impossible.
|
|
32
|
+
|
|
33
|
+
## The "Aha!" Moment
|
|
34
|
+
|
|
35
|
+
We realized we were mixing THREE completely different concerns:
|
|
36
|
+
|
|
37
|
+
1. **Tool Creation** - Converting functions to tools (compile-time)
|
|
38
|
+
2. **Tool Execution** - Running tools with timing/errors (runtime)
|
|
39
|
+
3. **Agent Orchestration** - Managing the conversation flow
|
|
40
|
+
|
|
41
|
+
It's like having your recipe book, cooking process, and restaurant management all in the same manual. No wonder it was confusing!
|
|
42
|
+
|
|
43
|
+
## The Solution: Three Clear Files
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
tool_factory.py → Makes tools from functions (recipe book)
|
|
47
|
+
tool_executor.py → Runs tools with all tracking (cooking process)
|
|
48
|
+
agent.py → Orchestrates everything (restaurant management)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Before: Everything Tangled
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
# agent.py - A massive file doing everything
|
|
55
|
+
class Agent:
|
|
56
|
+
def input(self, prompt):
|
|
57
|
+
# 150 lines of:
|
|
58
|
+
# - Creating messages
|
|
59
|
+
# - Calling LLM
|
|
60
|
+
# - Parsing responses
|
|
61
|
+
# - Setting up xray context
|
|
62
|
+
# - Executing tools
|
|
63
|
+
# - Handling errors
|
|
64
|
+
# - Tracking timing
|
|
65
|
+
# - Formatting results
|
|
66
|
+
# - Updating history
|
|
67
|
+
# 😵💫
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### After: Clean Separation
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
# agent.py - Just orchestration
|
|
74
|
+
class Agent:
|
|
75
|
+
def _execute_and_record_tools(self, tool_calls, ...):
|
|
76
|
+
# One line! Delegate to the expert
|
|
77
|
+
execute_and_record_tools(
|
|
78
|
+
tool_calls,
|
|
79
|
+
self.tools, # ToolRegistry with O(1) lookup
|
|
80
|
+
console=self.console if self.debug else None
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## The Clever Bit: Always Collect, Conditionally Display
|
|
85
|
+
|
|
86
|
+
We had a debate: Should we only collect execution data when debugging is on?
|
|
87
|
+
|
|
88
|
+
### ❌ The Obvious (Wrong) Approach
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
if debug:
|
|
92
|
+
start_time = time.time()
|
|
93
|
+
result = execute_tool()
|
|
94
|
+
duration = time.time() - start_time
|
|
95
|
+
save_timing(duration)
|
|
96
|
+
else:
|
|
97
|
+
result = execute_tool()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
This creates two code paths. Bugs hide in the path you're not testing.
|
|
101
|
+
|
|
102
|
+
### ✅ The Smart Approach
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
# ALWAYS collect data
|
|
106
|
+
start_time = time.time()
|
|
107
|
+
result = execute_tool()
|
|
108
|
+
duration = time.time() - start_time
|
|
109
|
+
execution_history.append({
|
|
110
|
+
"tool": name,
|
|
111
|
+
"duration": duration,
|
|
112
|
+
"result": result
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
# CONDITIONALLY display
|
|
116
|
+
if console: # If console is provided
|
|
117
|
+
console.print(f"Executed in {duration}ms")
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Why This is Brilliant:**
|
|
121
|
+
- Same code path always = fewer bugs
|
|
122
|
+
- Xray can show history regardless of console settings
|
|
123
|
+
- Tiny performance cost (just dict operations)
|
|
124
|
+
- Can add logging/metrics later without changing execution
|
|
125
|
+
|
|
126
|
+
## What Each File Does Now
|
|
127
|
+
|
|
128
|
+
### `tool_factory.py` (was `tools.py`)
|
|
129
|
+
**Purpose:** Convert Python functions → Agent tools
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
def search(query: str) -> str:
|
|
133
|
+
return f"Results for {query}"
|
|
134
|
+
|
|
135
|
+
# tool_factory converts this to:
|
|
136
|
+
{
|
|
137
|
+
"name": "search",
|
|
138
|
+
"parameters": {"query": {"type": "string"}},
|
|
139
|
+
"run": <function>
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### `tool_executor.py` (NEW!)
|
|
144
|
+
**Purpose:** Execute tools with all the complexity
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
def execute_single_tool(...):
|
|
148
|
+
# ✅ Always tracks timing
|
|
149
|
+
# ✅ Always records history
|
|
150
|
+
# ✅ Always handles errors
|
|
151
|
+
# ✅ Manages xray context
|
|
152
|
+
# ✅ Formats results
|
|
153
|
+
|
|
154
|
+
# But only prints if console provided
|
|
155
|
+
if console:
|
|
156
|
+
console.print("→ Executing tool...")
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### `agent.py` (Simplified)
|
|
160
|
+
**Purpose:** Orchestrate the flow
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
def input(prompt):
|
|
164
|
+
messages = create_messages(prompt)
|
|
165
|
+
|
|
166
|
+
for _ in range(max_iterations):
|
|
167
|
+
response = get_llm_decision(messages)
|
|
168
|
+
if response.has_tools:
|
|
169
|
+
execute_tools(response.tool_calls) # Delegate!
|
|
170
|
+
else:
|
|
171
|
+
return response.content
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## The Results: Night and Day
|
|
175
|
+
|
|
176
|
+
### Before
|
|
177
|
+
- 🔴 `agent.py`: 400+ lines, hard to navigate
|
|
178
|
+
- 🔴 `input()` method: 150+ lines of nested complexity
|
|
179
|
+
- 🔴 Testing: "Good luck with that"
|
|
180
|
+
- 🔴 Adding features: Touch everything, break something
|
|
181
|
+
|
|
182
|
+
### After
|
|
183
|
+
- 🟢 `agent.py`: 260 lines, clean orchestration
|
|
184
|
+
- 🟢 Each method: <20 lines, single purpose
|
|
185
|
+
- 🟢 Testing: Can test execution independently
|
|
186
|
+
- 🟢 Adding features: Clear where code belongs
|
|
187
|
+
|
|
188
|
+
## Lessons for Your Own Code
|
|
189
|
+
|
|
190
|
+
### 1. The 50-Line Rule
|
|
191
|
+
If a method is over 50 lines, it's doing too much. Period.
|
|
192
|
+
|
|
193
|
+
### 2. Definition vs Execution
|
|
194
|
+
These are ALWAYS different concerns:
|
|
195
|
+
- **Definition**: What something IS
|
|
196
|
+
- **Execution**: How something RUNS
|
|
197
|
+
|
|
198
|
+
### 3. Always Collect, Conditionally Display
|
|
199
|
+
Don't create branching paths based on debug flags. Collect everything, display what's needed.
|
|
200
|
+
|
|
201
|
+
### 4. Name Your Files Like a Human
|
|
202
|
+
- ❌ `utils.py` (what utilities?)
|
|
203
|
+
- ❌ `helpers.py` (helping with what?)
|
|
204
|
+
- ✅ `tool_factory.py` (makes tools!)
|
|
205
|
+
- ✅ `tool_executor.py` (executes tools!)
|
|
206
|
+
|
|
207
|
+
## What This Enables
|
|
208
|
+
|
|
209
|
+
Now that execution is isolated, we can easily add:
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
# Parallel execution (future)
|
|
213
|
+
async def execute_tools_parallel(tool_calls):
|
|
214
|
+
results = await asyncio.gather(*[
|
|
215
|
+
execute_single_tool(tc) for tc in tool_calls
|
|
216
|
+
])
|
|
217
|
+
|
|
218
|
+
# Execution middleware (future)
|
|
219
|
+
def with_retry(max_retries=3):
|
|
220
|
+
def execute_with_retry(tool_call):
|
|
221
|
+
for i in range(max_retries):
|
|
222
|
+
try:
|
|
223
|
+
return execute_single_tool(tool_call)
|
|
224
|
+
except Exception as e:
|
|
225
|
+
if i == max_retries - 1:
|
|
226
|
+
raise
|
|
227
|
+
|
|
228
|
+
# Execution analytics (future)
|
|
229
|
+
class ExecutionAnalytics:
|
|
230
|
+
def track(self, execution_history):
|
|
231
|
+
avg_duration = mean([e["duration"] for e in execution_history])
|
|
232
|
+
slowest_tool = max(execution_history, key=lambda e: e["duration"])
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
None of this would be clean without the separation.
|
|
236
|
+
|
|
237
|
+
## The Philosophy
|
|
238
|
+
|
|
239
|
+
This refactoring embodies our core principle:
|
|
240
|
+
|
|
241
|
+
> "Keep simple things simple, make complicated things possible"
|
|
242
|
+
|
|
243
|
+
- **Simple**: Calling a tool is now one line in agent.py
|
|
244
|
+
- **Complicated**: All the execution complexity is isolated where it can grow without affecting the rest
|
|
245
|
+
|
|
246
|
+
## Try This Yourself
|
|
247
|
+
|
|
248
|
+
Next time you have a complex method:
|
|
249
|
+
|
|
250
|
+
1. **List what it does** (if the list is >3 items, it's too much)
|
|
251
|
+
2. **Group related operations** (these become your modules)
|
|
252
|
+
3. **Name the groups clearly** (these become your filenames)
|
|
253
|
+
4. **Always collect data** (conditionally display)
|
|
254
|
+
|
|
255
|
+
Your future self will thank you.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
*"The best code is not the code that works, but the code that clearly shows HOW it works."*
|