connectonion 0.6.2__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 +13 -3
- connectonion/cli/browser_agent/element_finder.py +8 -0
- connectonion/cli/browser_agent/highlight_screenshot.py +9 -1
- connectonion/cli/browser_agent/scroll.py +8 -0
- connectonion/cli/co_ai/__init__.py +6 -0
- connectonion/cli/co_ai/agent.py +87 -0
- connectonion/cli/co_ai/agents/__init__.py +5 -0
- connectonion/cli/co_ai/agents/registry.py +57 -0
- connectonion/cli/co_ai/commands/__init__.py +45 -0
- connectonion/cli/co_ai/commands/compact.py +173 -0
- connectonion/cli/co_ai/commands/cost.py +77 -0
- connectonion/cli/co_ai/commands/export.py +60 -0
- connectonion/cli/co_ai/commands/help.py +80 -0
- connectonion/cli/co_ai/commands/init.py +101 -0
- connectonion/cli/co_ai/commands/sessions.py +55 -0
- connectonion/cli/co_ai/commands/tasks.py +63 -0
- connectonion/cli/co_ai/commands/undo.py +103 -0
- connectonion/cli/co_ai/context.py +127 -0
- connectonion/cli/co_ai/main.py +52 -0
- connectonion/cli/co_ai/plugins/__init__.py +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.2.dist-info → connectonion-0.6.3.dist-info}/METADATA +10 -3
- connectonion-0.6.3.dist-info/RECORD +469 -0
- connectonion/network/asgi.py +0 -407
- connectonion/network/host.py +0 -616
- connectonion/network/trust.py +0 -166
- connectonion-0.6.2.dist-info/RECORD +0 -129
- /connectonion/cli/{docs → co_ai/prompts/connectonion}/connectonion.md +0 -0
- {connectonion-0.6.2.dist-info → connectonion-0.6.3.dist-info}/WHEEL +0 -0
- {connectonion-0.6.2.dist-info → connectonion-0.6.3.dist-info}/entry_points.txt +0 -0
connectonion/docs/api.md
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
## Agent
|
|
4
|
+
|
|
5
|
+
The main class for creating AI agents that can use tools.
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
Agent(
|
|
11
|
+
name: str,
|
|
12
|
+
llm: Optional[LLM] = None,
|
|
13
|
+
tools: Optional[List[Callable]] = None,
|
|
14
|
+
system_prompt: Union[str, Path, None] = None,
|
|
15
|
+
api_key: Optional[str] = None,
|
|
16
|
+
model: str = "co/gemini-2.5-pro"
|
|
17
|
+
)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
#### Parameters
|
|
21
|
+
|
|
22
|
+
- **name** (`str`): Unique identifier for the agent
|
|
23
|
+
- **llm** (`Optional[LLM]`): Custom LLM instance (defaults to OpenAILLM)
|
|
24
|
+
- **tools** (`Optional[List[Callable]]`): List of functions the agent can use
|
|
25
|
+
- **system_prompt** (`Union[str, Path, None]`): Agent's personality and behavior definition
|
|
26
|
+
- `str`: Can be either a direct prompt text or a file path (auto-detected)
|
|
27
|
+
- `Path`: Path object pointing to a prompt file
|
|
28
|
+
- `None`: Uses default prompt
|
|
29
|
+
- **api_key** (`Optional[str]`): OpenAI API key (if not using custom LLM)
|
|
30
|
+
- **model** (`str`): Model to use (default: "co/gemini-2.5-pro")
|
|
31
|
+
- Managed keys: `co/gemini-2.5-pro`, `co/gpt-4o-mini`, `co/claude-3-5-sonnet`
|
|
32
|
+
- Your own key: `gpt-4o-mini`, `claude-3-5-sonnet`, `gemini-1.5-pro`
|
|
33
|
+
|
|
34
|
+
### System Prompt Options
|
|
35
|
+
|
|
36
|
+
The `system_prompt` parameter accepts multiple input types:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
# 1. Direct string
|
|
40
|
+
agent = Agent(name="bot", system_prompt="You are helpful")
|
|
41
|
+
|
|
42
|
+
# 2. File path as string (auto-detected if file exists)
|
|
43
|
+
agent = Agent(name="bot", system_prompt="prompts/assistant.md")
|
|
44
|
+
|
|
45
|
+
# 3. Path object (must point to existing file)
|
|
46
|
+
from pathlib import Path
|
|
47
|
+
agent = Agent(name="bot", system_prompt=Path("prompts/assistant.txt"))
|
|
48
|
+
|
|
49
|
+
# 4. None (uses default)
|
|
50
|
+
agent = Agent(name="bot") # Default: "You are a helpful assistant..."
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**File Loading Rules:**
|
|
54
|
+
- Any text file can be used (no extension restrictions)
|
|
55
|
+
- Files must be valid UTF-8 encoded text
|
|
56
|
+
- Empty files raise `ValueError`
|
|
57
|
+
- Non-existent Path objects raise `FileNotFoundError`
|
|
58
|
+
- Strings that don't exist as files are treated as literal prompts
|
|
59
|
+
|
|
60
|
+
### Methods
|
|
61
|
+
|
|
62
|
+
#### `input(prompt: str, max_iterations: Optional[int] = None) -> str`
|
|
63
|
+
|
|
64
|
+
Provide input to the agent and get response.
|
|
65
|
+
|
|
66
|
+
**Parameters:**
|
|
67
|
+
- `prompt` - User input/task for the agent
|
|
68
|
+
- `max_iterations` - Override agent's default max_iterations for this task only
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
result = agent.input("Calculate 2 + 2")
|
|
72
|
+
|
|
73
|
+
# Override iterations for complex tasks
|
|
74
|
+
result = agent.input("Complex multi-step task", max_iterations=25)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### `add_tool(tool: Callable) -> None`
|
|
78
|
+
|
|
79
|
+
Add a new tool to the agent.
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
def new_tool(param: str) -> str:
|
|
83
|
+
return f"Processed {param}"
|
|
84
|
+
|
|
85
|
+
agent.add_tool(new_tool)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### `remove_tool(tool_name: str) -> None`
|
|
89
|
+
|
|
90
|
+
Remove a tool from the agent.
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
agent.remove_tool("calculator")
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### `list_tools() -> List[str]`
|
|
97
|
+
|
|
98
|
+
Get list of available tool names.
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
tools = agent.list_tools()
|
|
102
|
+
# ['calculator', 'search', 'get_time']
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Tools
|
|
106
|
+
|
|
107
|
+
### Function-Based Tools
|
|
108
|
+
|
|
109
|
+
Any Python function can be used as a tool:
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
def my_tool(param: str, optional: int = 10) -> str:
|
|
113
|
+
"""Tool description from docstring.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
param: The main parameter.
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
Formatted result.
|
|
120
|
+
"""
|
|
121
|
+
return f"Result: {param} with {optional}"
|
|
122
|
+
|
|
123
|
+
agent = Agent("bot", tools=[my_tool])
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**How schemas are generated:**
|
|
127
|
+
- `name` ← function name
|
|
128
|
+
- `description` ← first paragraph of docstring (Args/Returns NOT included)
|
|
129
|
+
- `parameters` ← from Python type hints
|
|
130
|
+
- `required` ← parameters without default values
|
|
131
|
+
|
|
132
|
+
**Everything is optional:**
|
|
133
|
+
- No docstring? Description defaults to "Execute the {name} tool."
|
|
134
|
+
- No type hints? Defaults to string type
|
|
135
|
+
|
|
136
|
+
### Tool Conversion
|
|
137
|
+
|
|
138
|
+
The `create_tool_from_function` utility converts functions to tools:
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from connectonion import create_tool_from_function
|
|
142
|
+
|
|
143
|
+
def simple_function(x: int) -> int:
|
|
144
|
+
"""Double a number."""
|
|
145
|
+
return x * 2
|
|
146
|
+
|
|
147
|
+
tool = create_tool_from_function(simple_function)
|
|
148
|
+
# tool now has: .name, .description, .run(), .to_function_schema()
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Logging
|
|
152
|
+
|
|
153
|
+
Automatic activity logging for agents. Three output destinations:
|
|
154
|
+
- **Console**: Rich-formatted terminal output
|
|
155
|
+
- **Plain text**: `.co/logs/{name}.log`
|
|
156
|
+
- **Session YAML**: `.co/evals/{name}_{timestamp}.yaml`
|
|
157
|
+
|
|
158
|
+
### Configuration
|
|
159
|
+
|
|
160
|
+
Control logging via `quiet` and `log` parameters:
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
# Default: everything on (console + logs + sessions)
|
|
164
|
+
agent = Agent("assistant")
|
|
165
|
+
|
|
166
|
+
# Quiet mode: suppress console, keep sessions for eval
|
|
167
|
+
agent = Agent("assistant", quiet=True)
|
|
168
|
+
|
|
169
|
+
# Disable all file logging (console only)
|
|
170
|
+
agent = Agent("assistant", log=False)
|
|
171
|
+
|
|
172
|
+
# Custom log file path
|
|
173
|
+
agent = Agent("assistant", log="my_logs/custom.log")
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Logging Modes
|
|
177
|
+
|
|
178
|
+
| quiet | log | Console | Plain Text | Sessions | Use Case |
|
|
179
|
+
|-------|-----|---------|------------|----------|----------|
|
|
180
|
+
| False | True/None | ✓ | ✓ | ✓ | Development (default) |
|
|
181
|
+
| True | True/None | ✗ | ✗ | ✓ | Eval/testing |
|
|
182
|
+
| False | False | ✓ | ✗ | ✗ | Benchmarking |
|
|
183
|
+
| False | "path" | ✓ | custom | ✓ | Custom log path |
|
|
184
|
+
|
|
185
|
+
### Log Format
|
|
186
|
+
|
|
187
|
+
Plain text logs include:
|
|
188
|
+
- Timestamp
|
|
189
|
+
- User input
|
|
190
|
+
- LLM calls with timing, tokens, cost
|
|
191
|
+
- Tool executions with parameters and results
|
|
192
|
+
- Final agent responses
|
|
193
|
+
|
|
194
|
+
Example log output:
|
|
195
|
+
```
|
|
196
|
+
[10:30:15] INPUT: Calculate 2 + 2
|
|
197
|
+
[10:30:15] -> LLM Request (gpt-4o-mini) • 2 msgs • 1 tools
|
|
198
|
+
[10:30:16] <- LLM Response (234ms) • 1 tools • 156 tokens • $0.0001
|
|
199
|
+
[10:30:16] -> Tool: calculator({"expression": "2+2"})
|
|
200
|
+
[10:30:16] <- Result (1ms): 4
|
|
201
|
+
[10:30:16] [OK] Complete (1.2s)
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Session YAML Format
|
|
205
|
+
|
|
206
|
+
Sessions are saved for replay and eval:
|
|
207
|
+
|
|
208
|
+
```yaml
|
|
209
|
+
name: assistant
|
|
210
|
+
timestamp: 2024-12-02 10:30:15
|
|
211
|
+
|
|
212
|
+
turns:
|
|
213
|
+
- input: "Calculate 2 + 2"
|
|
214
|
+
model: "gpt-4o-mini"
|
|
215
|
+
duration_ms: 1200
|
|
216
|
+
tokens: 156
|
|
217
|
+
cost: 0.0001
|
|
218
|
+
tools_called: [calculator]
|
|
219
|
+
result: "The answer is 4"
|
|
220
|
+
messages: '[{"role":"system",...}]'
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## LLM
|
|
224
|
+
|
|
225
|
+
Abstract base class for language models. ConnectOnion supports multiple LLM providers through a unified interface.
|
|
226
|
+
|
|
227
|
+
### Model Routing
|
|
228
|
+
|
|
229
|
+
The `create_llm()` factory function routes models to the appropriate provider:
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
from connectonion.llm import create_llm
|
|
233
|
+
|
|
234
|
+
# OpenAI models
|
|
235
|
+
llm = create_llm("gpt-4o-mini") # → OpenAILLM
|
|
236
|
+
llm = create_llm("o4-mini") # → OpenAILLM
|
|
237
|
+
|
|
238
|
+
# Anthropic models
|
|
239
|
+
llm = create_llm("claude-3-5-sonnet") # → AnthropicLLM
|
|
240
|
+
|
|
241
|
+
# Google Gemini models
|
|
242
|
+
llm = create_llm("gemini-2.5-flash") # → GeminiLLM
|
|
243
|
+
|
|
244
|
+
# ConnectOnion managed keys (co/ prefix)
|
|
245
|
+
llm = create_llm("co/gpt-4o-mini") # → OpenOnionLLM
|
|
246
|
+
llm = create_llm("co/gemini-2.5-flash") # → OpenOnionLLM
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### co/ Models (Managed Keys)
|
|
250
|
+
|
|
251
|
+
Models prefixed with `co/` use ConnectOnion's managed API keys through the OpenOnion proxy:
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
from connectonion import Agent
|
|
255
|
+
|
|
256
|
+
# Uses OpenOnion managed keys - no API key needed
|
|
257
|
+
agent = Agent(name="bot", model="co/gemini-2.5-flash")
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**How it works:**
|
|
261
|
+
1. Client detects `co/` prefix → routes to `OpenOnionLLM`
|
|
262
|
+
2. Prefix is stripped before sending to server
|
|
263
|
+
3. Server routes to appropriate provider (OpenAI, Anthropic, Gemini)
|
|
264
|
+
4. Response returned in OpenAI-compatible format
|
|
265
|
+
|
|
266
|
+
**Available co/ models:**
|
|
267
|
+
- `co/gpt-4o-mini`, `co/gpt-4o`, `co/gpt-5`, `co/gpt-5-mini`, `co/gpt-5-nano`, `co/o4-mini`
|
|
268
|
+
- `co/gemini-2.5-pro`, `co/gemini-2.5-flash`, `co/gemini-2.5-flash-lite`, `co/gemini-2.0-flash`
|
|
269
|
+
|
|
270
|
+
**Environment variable:** `OPENONION_API_KEY` (auto-loaded from `.env`)
|
|
271
|
+
|
|
272
|
+
### OpenAILLM
|
|
273
|
+
|
|
274
|
+
OpenAI API implementation.
|
|
275
|
+
|
|
276
|
+
```python
|
|
277
|
+
from connectonion.llm import OpenAILLM
|
|
278
|
+
|
|
279
|
+
llm = OpenAILLM(
|
|
280
|
+
api_key="your-key", # or OPENAI_API_KEY env var
|
|
281
|
+
model="gpt-4o-mini",
|
|
282
|
+
temperature=0.7
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
agent = Agent("bot", llm=llm)
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### AnthropicLLM
|
|
289
|
+
|
|
290
|
+
Anthropic Claude API implementation.
|
|
291
|
+
|
|
292
|
+
```python
|
|
293
|
+
from connectonion.llm import AnthropicLLM
|
|
294
|
+
|
|
295
|
+
llm = AnthropicLLM(
|
|
296
|
+
api_key="your-key", # or ANTHROPIC_API_KEY env var
|
|
297
|
+
model="claude-3-5-sonnet-20241022"
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
agent = Agent("bot", llm=llm)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### GeminiLLM
|
|
304
|
+
|
|
305
|
+
Google Gemini API implementation (uses OpenAI-compatible endpoint).
|
|
306
|
+
|
|
307
|
+
```python
|
|
308
|
+
from connectonion.llm import GeminiLLM
|
|
309
|
+
|
|
310
|
+
llm = GeminiLLM(
|
|
311
|
+
api_key="your-key", # or GEMINI_API_KEY env var
|
|
312
|
+
model="gemini-2.5-flash"
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
agent = Agent("bot", llm=llm)
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### OpenOnionLLM
|
|
319
|
+
|
|
320
|
+
ConnectOnion managed keys implementation.
|
|
321
|
+
|
|
322
|
+
```python
|
|
323
|
+
from connectonion.llm import OpenOnionLLM
|
|
324
|
+
|
|
325
|
+
llm = OpenOnionLLM(
|
|
326
|
+
api_key="your-token", # or OPENONION_API_KEY env var
|
|
327
|
+
model="co/gemini-2.5-flash"
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
agent = Agent("bot", llm=llm)
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
**Base URLs:**
|
|
334
|
+
- Production: `https://oo.openonion.ai/v1`
|
|
335
|
+
- Development: `http://localhost:8000/v1` (when `ENVIRONMENT=development`)
|
|
336
|
+
|
|
337
|
+
## Prompts Module
|
|
338
|
+
|
|
339
|
+
Utilities for loading system prompts.
|
|
340
|
+
|
|
341
|
+
### `load_system_prompt(prompt: Union[str, Path, None]) -> str`
|
|
342
|
+
|
|
343
|
+
Load system prompt from various sources.
|
|
344
|
+
|
|
345
|
+
```python
|
|
346
|
+
from connectonion.prompts import load_system_prompt
|
|
347
|
+
|
|
348
|
+
# From string
|
|
349
|
+
prompt = load_system_prompt("You are helpful")
|
|
350
|
+
|
|
351
|
+
# From file
|
|
352
|
+
prompt = load_system_prompt("prompts/assistant.md")
|
|
353
|
+
|
|
354
|
+
# From Path
|
|
355
|
+
from pathlib import Path
|
|
356
|
+
prompt = load_system_prompt(Path("prompts/assistant.txt"))
|
|
357
|
+
|
|
358
|
+
# Default
|
|
359
|
+
prompt = load_system_prompt(None)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Raises:**
|
|
363
|
+
- `FileNotFoundError`: If Path object points to non-existent file
|
|
364
|
+
- `ValueError`: If file is empty or not valid UTF-8
|
|
365
|
+
- `TypeError`: If invalid type provided
|
|
366
|
+
|
|
367
|
+
## Decorators
|
|
368
|
+
|
|
369
|
+
### `@xray`
|
|
370
|
+
|
|
371
|
+
Enable detailed execution tracing.
|
|
372
|
+
|
|
373
|
+
```python
|
|
374
|
+
from connectonion import xray
|
|
375
|
+
|
|
376
|
+
@xray
|
|
377
|
+
def my_agent_function():
|
|
378
|
+
agent = Agent("tracer")
|
|
379
|
+
return agent.input("task")
|
|
380
|
+
|
|
381
|
+
# After execution:
|
|
382
|
+
xray.trace() # Shows detailed execution flow
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### `@replay`
|
|
386
|
+
|
|
387
|
+
Record and replay agent interactions.
|
|
388
|
+
|
|
389
|
+
```python
|
|
390
|
+
from connectonion import replay
|
|
391
|
+
|
|
392
|
+
@replay
|
|
393
|
+
def workflow():
|
|
394
|
+
agent = Agent("bot")
|
|
395
|
+
return agent.input("task")
|
|
396
|
+
|
|
397
|
+
# Replay the recorded interaction
|
|
398
|
+
replay.last()
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## Examples
|
|
402
|
+
|
|
403
|
+
### Basic Agent
|
|
404
|
+
|
|
405
|
+
```python
|
|
406
|
+
from connectonion import Agent
|
|
407
|
+
|
|
408
|
+
# Simple calculator agent
|
|
409
|
+
def calculate(expression: str) -> str:
|
|
410
|
+
"""Evaluate mathematical expressions."""
|
|
411
|
+
return str(eval(expression))
|
|
412
|
+
|
|
413
|
+
agent = Agent("calculator", tools=[calculate])
|
|
414
|
+
result = agent.input("What is 15 * 4?")
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### Agent with Custom Prompt File
|
|
418
|
+
|
|
419
|
+
```python
|
|
420
|
+
# prompts/expert.md
|
|
421
|
+
"""
|
|
422
|
+
You are an expert Python developer with 10 years of experience.
|
|
423
|
+
Focus on clean code, best practices, and performance.
|
|
424
|
+
"""
|
|
425
|
+
|
|
426
|
+
# main.py
|
|
427
|
+
agent = Agent(
|
|
428
|
+
name="python_expert",
|
|
429
|
+
system_prompt="prompts/expert.md",
|
|
430
|
+
tools=[code_review, suggest_improvement]
|
|
431
|
+
)
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Multi-Tool Agent
|
|
435
|
+
|
|
436
|
+
```python
|
|
437
|
+
def search(query: str) -> str:
|
|
438
|
+
"""Search the web."""
|
|
439
|
+
# Implementation
|
|
440
|
+
|
|
441
|
+
def calculate(expr: str) -> str:
|
|
442
|
+
"""Do math."""
|
|
443
|
+
# Implementation
|
|
444
|
+
|
|
445
|
+
def get_time() -> str:
|
|
446
|
+
"""Get current time."""
|
|
447
|
+
# Implementation
|
|
448
|
+
|
|
449
|
+
agent = Agent(
|
|
450
|
+
name="assistant",
|
|
451
|
+
system_prompt="You are a helpful research assistant.",
|
|
452
|
+
tools=[search, calculate, get_time]
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
# Agent can use multiple tools in one request
|
|
456
|
+
result = agent.input("Search for Python tutorials, calculate 42*17, and tell me the time")
|
|
457
|
+
```
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# Tutorial 001: AI Agent = Prompt + Function
|
|
2
|
+
|
|
3
|
+
**Read time: 1 minute. Build your first AI Agent: 30 seconds.**
|
|
4
|
+
|
|
5
|
+
## The Truth About Those $199 Courses
|
|
6
|
+
|
|
7
|
+
People are selling courses right now:
|
|
8
|
+
- **"Master LangChain in 30 Days!"** - $199
|
|
9
|
+
- **"AutoGen Expert Certification"** - $299
|
|
10
|
+
- **"Complete CrewAI Bootcamp"** - $499
|
|
11
|
+
|
|
12
|
+
Here's what they don't want you to know:
|
|
13
|
+
|
|
14
|
+
**AI Agent = Prompt + Function**
|
|
15
|
+
|
|
16
|
+
That's it. That's the entire course.
|
|
17
|
+
|
|
18
|
+
## Why I Built ConnectOnion
|
|
19
|
+
|
|
20
|
+
I was building a project with LangChain and got disgusted:
|
|
21
|
+
- Simple agent required 100+ lines of code
|
|
22
|
+
- Documentation was incomprehensible, too many abstractions
|
|
23
|
+
- Debugging made me want to throw my laptop
|
|
24
|
+
- Every version update broke my code
|
|
25
|
+
|
|
26
|
+
**I thought: Why can't this be simple?**
|
|
27
|
+
|
|
28
|
+
So I built ConnectOnion. One design principle: **Keep simple things simple**.
|
|
29
|
+
|
|
30
|
+
## See the Difference
|
|
31
|
+
|
|
32
|
+
**LangChain Weather Agent:** 67 lines of hell
|
|
33
|
+
```python
|
|
34
|
+
from langchain.agents import Tool, AgentExecutor, LLMSingleActionAgent
|
|
35
|
+
from langchain.prompts import StringPromptTemplate
|
|
36
|
+
from langchain.chains import LLMChain
|
|
37
|
+
from langchain.schema import AgentAction, AgentFinish, OutputParserException
|
|
38
|
+
from langchain.chat_models import ChatOpenAI
|
|
39
|
+
from typing import List, Union
|
|
40
|
+
import re
|
|
41
|
+
|
|
42
|
+
# Define the tool
|
|
43
|
+
def get_weather(city: str) -> str:
|
|
44
|
+
return f"Sunny in {city}, 22°C"
|
|
45
|
+
|
|
46
|
+
weather_tool = Tool(
|
|
47
|
+
name="Weather",
|
|
48
|
+
func=get_weather,
|
|
49
|
+
description="Get weather for a city"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
tools = [weather_tool]
|
|
53
|
+
|
|
54
|
+
# Set up the prompt template (yes, this is required)
|
|
55
|
+
template = """You are a weather assistant.
|
|
56
|
+
|
|
57
|
+
You have access to the following tools:
|
|
58
|
+
|
|
59
|
+
{tools}
|
|
60
|
+
|
|
61
|
+
Use the following format:
|
|
62
|
+
|
|
63
|
+
Question: the input question you must answer
|
|
64
|
+
Thought: you should always think about what to do
|
|
65
|
+
Action: the action to take, should be one of [{tool_names}]
|
|
66
|
+
Action Input: the input to the action
|
|
67
|
+
Observation: the result of the action
|
|
68
|
+
... (this Thought/Action/Action Input/Observation can repeat N times)
|
|
69
|
+
Thought: I now know the final answer
|
|
70
|
+
Final Answer: the final answer to the original input question
|
|
71
|
+
|
|
72
|
+
Question: {input}
|
|
73
|
+
{agent_scratchpad}"""
|
|
74
|
+
|
|
75
|
+
class CustomPromptTemplate(StringPromptTemplate):
|
|
76
|
+
template: str
|
|
77
|
+
tools: List[Tool]
|
|
78
|
+
|
|
79
|
+
def format(self, **kwargs) -> str:
|
|
80
|
+
intermediate_steps = kwargs.pop("intermediate_steps")
|
|
81
|
+
thoughts = ""
|
|
82
|
+
for action, observation in intermediate_steps:
|
|
83
|
+
thoughts += action.log
|
|
84
|
+
thoughts += f"\nObservation: {observation}\nThought: "
|
|
85
|
+
kwargs["agent_scratchpad"] = thoughts
|
|
86
|
+
kwargs["tools"] = "\n".join([f"{tool.name}: {tool.description}" for tool in self.tools])
|
|
87
|
+
kwargs["tool_names"] = ", ".join([tool.name for tool in self.tools])
|
|
88
|
+
return self.template.format(**kwargs)
|
|
89
|
+
|
|
90
|
+
prompt = CustomPromptTemplate(
|
|
91
|
+
template=template,
|
|
92
|
+
tools=tools,
|
|
93
|
+
input_variables=["input", "intermediate_steps"]
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Output parser (more boilerplate)
|
|
97
|
+
class CustomOutputParser:
|
|
98
|
+
def parse(self, llm_output: str) -> Union[AgentAction, AgentFinish]:
|
|
99
|
+
if "Final Answer:" in llm_output:
|
|
100
|
+
return AgentFinish(
|
|
101
|
+
return_values={"output": llm_output.split("Final Answer:")[-1].strip()},
|
|
102
|
+
log=llm_output,
|
|
103
|
+
)
|
|
104
|
+
regex = r"Action\s*\d*\s*:(.*?)\nAction\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)"
|
|
105
|
+
match = re.search(regex, llm_output, re.DOTALL)
|
|
106
|
+
if not match:
|
|
107
|
+
raise OutputParserException(f"Could not parse LLM output: `{llm_output}`")
|
|
108
|
+
action = match.group(1).strip()
|
|
109
|
+
action_input = match.group(2)
|
|
110
|
+
return AgentAction(tool=action, tool_input=action_input.strip(" ").strip('"'), log=llm_output)
|
|
111
|
+
|
|
112
|
+
# Create the LLM chain
|
|
113
|
+
llm = ChatOpenAI(temperature=0)
|
|
114
|
+
llm_chain = LLMChain(llm=llm, prompt=prompt)
|
|
115
|
+
|
|
116
|
+
# Create the agent (finally!)
|
|
117
|
+
tool_names = [tool.name for tool in tools]
|
|
118
|
+
agent = LLMSingleActionAgent(
|
|
119
|
+
llm_chain=llm_chain,
|
|
120
|
+
output_parser=CustomOutputParser(),
|
|
121
|
+
stop=["\nObservation:"],
|
|
122
|
+
allowed_tools=tool_names
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
# Create the executor
|
|
126
|
+
agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True)
|
|
127
|
+
|
|
128
|
+
# Use it (after 67 lines of setup)
|
|
129
|
+
agent_executor.run("What's the weather in Tokyo?")
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**My ConnectOnion:** 5 lines
|
|
133
|
+
```python
|
|
134
|
+
from connectonion import Agent
|
|
135
|
+
|
|
136
|
+
def get_weather(city: str) -> str:
|
|
137
|
+
return f"Sunny in {city}, 22°C"
|
|
138
|
+
|
|
139
|
+
agent = Agent("weather_bot", tools=[get_weather])
|
|
140
|
+
agent.input("What's the weather in Tokyo?")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Same result. 92% less code.**
|
|
144
|
+
|
|
145
|
+
## How I Did It
|
|
146
|
+
|
|
147
|
+
Simple. I found the essence:
|
|
148
|
+
- **LangChain**: Makes simple problems complex to look professional
|
|
149
|
+
- **My insight**: AI Agent is just ChatGPT that can call functions
|
|
150
|
+
|
|
151
|
+
So ConnectOnion's core is:
|
|
152
|
+
1. You write functions (define capabilities)
|
|
153
|
+
2. You write prompts (define behavior)
|
|
154
|
+
3. Framework combines them (I already built this part)
|
|
155
|
+
|
|
156
|
+
## 30 Seconds with My Framework
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from connectonion import Agent
|
|
160
|
+
|
|
161
|
+
# 1. Write a function - You already know how (10 seconds)
|
|
162
|
+
def calculate(expression: str) -> str:
|
|
163
|
+
"""Calculate math expression"""
|
|
164
|
+
return str(eval(expression))
|
|
165
|
+
|
|
166
|
+
# 2. Create agent - Just prompt + function (10 seconds)
|
|
167
|
+
agent = Agent(
|
|
168
|
+
"calculator",
|
|
169
|
+
system_prompt="You're a math tutor, explain your steps",
|
|
170
|
+
tools=[calculate]
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# 3. Use it (10 seconds)
|
|
174
|
+
print(agent.input("What's 42 times 17?"))
|
|
175
|
+
# Output: 42 times 17 equals 714. Here's how: 40×17=680, 2×17=34, 680+34=714
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Done. This is the simplicity I wanted.**
|
|
179
|
+
|
|
180
|
+
## Why Other Frameworks Are Garbage
|
|
181
|
+
|
|
182
|
+
I've tried them all:
|
|
183
|
+
|
|
184
|
+
**LangChain:**
|
|
185
|
+
- Too many abstraction layers, like Russian dolls
|
|
186
|
+
- Breaking changes every update
|
|
187
|
+
- Debugging? Good luck
|
|
188
|
+
- **My verdict:** Textbook overengineering
|
|
189
|
+
|
|
190
|
+
**AutoGen:**
|
|
191
|
+
- Forces you to learn Actor patterns
|
|
192
|
+
- Message passing will make you dizzy
|
|
193
|
+
- **My verdict:** Microsoft-style complexity for no reason
|
|
194
|
+
|
|
195
|
+
**My ConnectOnion:**
|
|
196
|
+
- No unnecessary abstractions
|
|
197
|
+
- Functions are functions, prompts are prompts
|
|
198
|
+
- Something wrong? Just print and debug
|
|
199
|
+
- **Design philosophy:** If it needs documentation to explain, the design is wrong
|
|
200
|
+
|
|
201
|
+
## Real Feedback
|
|
202
|
+
|
|
203
|
+
What users are saying:
|
|
204
|
+
- "Finally someone built a sane framework"
|
|
205
|
+
- "Migrated from LangChain, 90% less code"
|
|
206
|
+
- "This is what AI Agents should be"
|
|
207
|
+
|
|
208
|
+
## Why I Made It Free and Open Source
|
|
209
|
+
|
|
210
|
+
Because I'm sick of:
|
|
211
|
+
1. Garbage frameworks wasting everyone's time
|
|
212
|
+
2. Course sellers scamming people
|
|
213
|
+
3. Simple things made complex
|
|
214
|
+
|
|
215
|
+
**ConnectOnion will always be free, always open source.**
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
pip install connectonion
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## The Formula
|
|
222
|
+
|
|
223
|
+
**AI Agent = Prompt + Function**
|
|
224
|
+
|
|
225
|
+
This is the essence I discovered. Now I'm sharing it with you.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Class Dismissed
|
|
230
|
+
|
|
231
|
+
This tutorial series is over.
|
|
232
|
+
|
|
233
|
+
**Because there's really nothing to teach.**
|
|
234
|
+
|
|
235
|
+
ConnectOnion is that simple:
|
|
236
|
+
- Can you write functions? Yes
|
|
237
|
+
- Can you write prompts? Yes
|
|
238
|
+
- Then you already know how to use it
|
|
239
|
+
|
|
240
|
+
The rest is just creativity.
|
|
241
|
+
|
|
242
|
+
**Stop paying for garbage courses.**
|
|
243
|
+
**Use ConnectOnion. 5 lines of code to change the world.**
|
|
244
|
+
|
|
245
|
+
**Class dismissed.**
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
**Next**: Want to see what real agents can do? → [002: Real-World Agent Examples](002-make-your-agent-useful.md)
|