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
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Plugins
|
|
2
|
+
|
|
3
|
+
Plugins are reusable event handlers. Package capabilities and reuse them across agents.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from connectonion import Agent
|
|
9
|
+
from connectonion.useful_plugins import re_act
|
|
10
|
+
|
|
11
|
+
agent = Agent("assistant", tools=[search], plugins=[re_act])
|
|
12
|
+
agent.input("Search for Python")
|
|
13
|
+
# 💭 Planning: Will search for Python info first.
|
|
14
|
+
# ... tool executes ...
|
|
15
|
+
# 🤔 Reflecting: Found Python basics, task complete.
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## What is a Plugin?
|
|
19
|
+
|
|
20
|
+
A plugin is a list of event handlers:
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from connectonion import after_user_input, after_tools
|
|
24
|
+
|
|
25
|
+
# Define handlers
|
|
26
|
+
def plan(agent):
|
|
27
|
+
print("Planning...")
|
|
28
|
+
|
|
29
|
+
def reflect(agent):
|
|
30
|
+
print("Reflecting...")
|
|
31
|
+
|
|
32
|
+
# Plugin = list of event handlers
|
|
33
|
+
re_act = [after_user_input(plan), after_tools(reflect)]
|
|
34
|
+
|
|
35
|
+
# Use it
|
|
36
|
+
agent = Agent("assistant", tools=[search], plugins=[re_act])
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Plugin vs on_events
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
# on_events: one list (custom for this agent)
|
|
43
|
+
agent = Agent("a", on_events=[after_llm(handler)])
|
|
44
|
+
|
|
45
|
+
# plugins: list of lists (reusable across agents)
|
|
46
|
+
agent = Agent("a", plugins=[re_act, logger])
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Built-in Plugins
|
|
50
|
+
|
|
51
|
+
| Plugin | Purpose | Docs |
|
|
52
|
+
|--------|---------|------|
|
|
53
|
+
| `re_act` | Planning + reflection (ReAct pattern) | [re_act.md](../useful_plugins/re_act.md) |
|
|
54
|
+
| `eval` | Task evaluation for debugging | [eval.md](../useful_plugins/eval.md) |
|
|
55
|
+
| `image_result_formatter` | Format images for vision models | [image_result_formatter.md](../useful_plugins/image_result_formatter.md) |
|
|
56
|
+
| `shell_approval` | Approve shell commands before execution | [shell_approval.md](../useful_plugins/shell_approval.md) |
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from connectonion.useful_plugins import re_act, eval, image_result_formatter, shell_approval
|
|
60
|
+
|
|
61
|
+
# Combine plugins
|
|
62
|
+
agent = Agent("assistant", plugins=[re_act, image_result_formatter])
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Writing Custom Plugins
|
|
66
|
+
|
|
67
|
+
Simple example - log each tool execution:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from connectonion import Agent, after_each_tool
|
|
71
|
+
|
|
72
|
+
def log_tool(agent):
|
|
73
|
+
trace = agent.current_session['trace'][-1]
|
|
74
|
+
print(f"✓ {trace['tool_name']} completed")
|
|
75
|
+
|
|
76
|
+
# Plugin = list of handlers
|
|
77
|
+
logger = [after_each_tool(log_tool)]
|
|
78
|
+
|
|
79
|
+
# Use it
|
|
80
|
+
agent = Agent("assistant", tools=[search], plugins=[logger])
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
For more complex plugins, see [Events](events.md) for available event hooks.
|
|
84
|
+
|
|
85
|
+
## Reusing Plugins
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
# Define once
|
|
89
|
+
logger = [after_each_tool(log_tool)]
|
|
90
|
+
|
|
91
|
+
# Use across agents
|
|
92
|
+
researcher = Agent("researcher", tools=[search], plugins=[logger])
|
|
93
|
+
writer = Agent("writer", tools=[generate], plugins=[logger])
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Next Steps
|
|
97
|
+
|
|
98
|
+
- [Events](events.md) - Available event hooks
|
|
99
|
+
- [llm_do](llm_do.md) - Use LLM in handlers
|
|
100
|
+
- [Built-in Plugins](../useful_plugins/) - Detailed plugin docs
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# System Prompts - File Format Support
|
|
2
|
+
|
|
3
|
+
ConnectOnion can load system prompts from **any text file format**. Use whatever format your team prefers.
|
|
4
|
+
|
|
5
|
+
## Supported Formats
|
|
6
|
+
|
|
7
|
+
**All text files work** - ConnectOnion simply reads the content:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from connectonion import Agent
|
|
11
|
+
|
|
12
|
+
# All of these work identically:
|
|
13
|
+
agent = Agent("bot", system_prompt="prompts/assistant.md") # Markdown
|
|
14
|
+
agent = Agent("bot", system_prompt="prompts/assistant.yaml") # YAML
|
|
15
|
+
agent = Agent("bot", system_prompt="prompts/assistant.json") # JSON
|
|
16
|
+
agent = Agent("bot", system_prompt="prompts/assistant.txt") # Plain text
|
|
17
|
+
agent = Agent("bot", system_prompt="prompts/assistant") # No extension
|
|
18
|
+
agent = Agent("bot", system_prompt="prompts/assistant.prompt") # Custom extension
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Loading Methods
|
|
22
|
+
|
|
23
|
+
### 1. String (Auto-Detection)
|
|
24
|
+
```python
|
|
25
|
+
agent = Agent("bot", system_prompt="prompts/my_prompt.md")
|
|
26
|
+
# ✅ Loads file if it exists
|
|
27
|
+
# ✅ Uses as literal text if file doesn't exist
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 2. Path Object (Explicit)
|
|
31
|
+
```python
|
|
32
|
+
from pathlib import Path
|
|
33
|
+
agent = Agent("bot", system_prompt=Path("prompts/my_prompt.yaml"))
|
|
34
|
+
# ✅ Must be a valid file path
|
|
35
|
+
# ❌ Raises error if file doesn't exist
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 3. Direct String
|
|
39
|
+
```python
|
|
40
|
+
agent = Agent("bot", system_prompt="You are a helpful assistant.")
|
|
41
|
+
# ✅ Uses the text directly
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## File Format Examples
|
|
45
|
+
|
|
46
|
+
### Markdown Format (`assistant.md`)
|
|
47
|
+
```markdown
|
|
48
|
+
# AI Assistant
|
|
49
|
+
You are a helpful assistant who provides clear, concise answers.
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### YAML Format (`assistant.yaml`)
|
|
53
|
+
```yaml
|
|
54
|
+
role: AI Assistant
|
|
55
|
+
instructions: You are a helpful assistant who provides clear, concise answers.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### JSON Format (`assistant.json`)
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"role": "AI Assistant",
|
|
62
|
+
"instructions": "You are a helpful assistant who provides clear, concise answers."
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Plain Text (`assistant.txt`)
|
|
67
|
+
```
|
|
68
|
+
You are a helpful assistant who provides clear, concise answers.
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### No Extension (`assistant`)
|
|
72
|
+
```
|
|
73
|
+
You are a helpful assistant who provides clear, concise answers.
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Key Points
|
|
77
|
+
|
|
78
|
+
- **No parsing** - ConnectOnion just reads the text content
|
|
79
|
+
- **Any extension** - `.md`, `.yaml`, `.json`, `.txt`, `.prompt`, or none
|
|
80
|
+
- **Simple** - No special configuration required
|
|
81
|
+
- **Flexible** - Change formats without changing code
|
|
82
|
+
|
|
83
|
+
## Environment-Based Loading
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import os
|
|
87
|
+
|
|
88
|
+
# Use different prompts for different environments
|
|
89
|
+
env = os.getenv("ENV", "dev")
|
|
90
|
+
agent = Agent("bot", system_prompt=f"prompts/{env}/assistant.md")
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Dynamic Loading
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from pathlib import Path
|
|
97
|
+
|
|
98
|
+
def create_agent(name: str, prompt_file: str):
|
|
99
|
+
path = Path(prompt_file)
|
|
100
|
+
if path.exists():
|
|
101
|
+
return Agent(name, system_prompt=path)
|
|
102
|
+
else:
|
|
103
|
+
# Fallback to default
|
|
104
|
+
return Agent(name, system_prompt="You are a helpful assistant.")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Error Handling
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from pathlib import Path
|
|
111
|
+
from connectonion.prompts import load_system_prompt
|
|
112
|
+
|
|
113
|
+
try:
|
|
114
|
+
prompt = load_system_prompt(Path("prompts/missing.md"))
|
|
115
|
+
except FileNotFoundError:
|
|
116
|
+
print("Prompt file not found, using default")
|
|
117
|
+
prompt = "You are a helpful assistant."
|
|
118
|
+
|
|
119
|
+
agent = Agent("bot", system_prompt=prompt)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
That's it! ConnectOnion makes it simple - just point to any text file and it works.
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
# Session
|
|
2
|
+
|
|
3
|
+
> The runtime state of your agent. Access it via `agent.current_session` to inspect messages, trace execution, and build plugins.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Quick Start (60 Seconds)
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from connectonion import Agent, after_each_tool
|
|
11
|
+
|
|
12
|
+
def log_tool_result(agent):
|
|
13
|
+
"""Access session data in your event handler."""
|
|
14
|
+
trace = agent.current_session['trace'][-1]
|
|
15
|
+
print(f"Tool: {trace['name']} -> {trace['status']}")
|
|
16
|
+
|
|
17
|
+
agent = Agent("bot", tools=[search], on_events=[after_each_tool(log_tool_result)])
|
|
18
|
+
agent.input("Search for Python")
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**That's it.** `current_session` gives you everything about the current execution.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## What's in a Session?
|
|
26
|
+
|
|
27
|
+
When you call `agent.input()`, a session is created (or continued):
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
agent.current_session = {
|
|
31
|
+
'messages': [...], # OpenAI-format conversation history
|
|
32
|
+
'trace': [...], # Execution log (what happened)
|
|
33
|
+
'user_prompt': '...', # Current turn's input
|
|
34
|
+
'iteration': 1, # Current loop iteration (1 to max_iterations)
|
|
35
|
+
'turn': 1, # Conversation turn number
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
| Field | Type | Description |
|
|
40
|
+
|-------|------|-------------|
|
|
41
|
+
| `messages` | `list[dict]` | Full conversation in OpenAI format |
|
|
42
|
+
| `trace` | `list[dict]` | Sequential log of all execution events |
|
|
43
|
+
| `user_prompt` | `str` | The current user input |
|
|
44
|
+
| `iteration` | `int` | Current iteration within this turn (1-10 by default) |
|
|
45
|
+
| `turn` | `int` | Which conversation turn (increments on each `input()`) |
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Messages
|
|
50
|
+
|
|
51
|
+
The `messages` list follows [OpenAI's message format](https://platform.openai.com/docs/api-reference/chat/create):
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
agent.current_session['messages'] = [
|
|
55
|
+
{'role': 'system', 'content': 'You are a helpful assistant...'},
|
|
56
|
+
{'role': 'user', 'content': 'Search for Python tutorials'},
|
|
57
|
+
{'role': 'assistant', 'content': None, 'tool_calls': [...]},
|
|
58
|
+
{'role': 'tool', 'content': 'Found 10 results...', 'tool_call_id': 'call_abc'},
|
|
59
|
+
{'role': 'assistant', 'content': 'I found some Python tutorials...'},
|
|
60
|
+
]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Message roles:**
|
|
64
|
+
- `system` - Agent's personality/instructions
|
|
65
|
+
- `user` - User input
|
|
66
|
+
- `assistant` - LLM responses (may include `tool_calls`)
|
|
67
|
+
- `tool` - Tool execution results (includes `tool_call_id`)
|
|
68
|
+
|
|
69
|
+
### Modify Messages in Events
|
|
70
|
+
|
|
71
|
+
You can inject messages in your event handlers:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from connectonion import Agent, after_tools
|
|
75
|
+
|
|
76
|
+
def add_context(agent):
|
|
77
|
+
"""Add context after tools complete."""
|
|
78
|
+
agent.current_session['messages'].append({
|
|
79
|
+
'role': 'system',
|
|
80
|
+
'content': f'Current time: {datetime.now()}'
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
agent = Agent("bot", tools=[search], on_events=[after_tools(add_context)])
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
> **Important:** Only modify messages in `after_tools` events. Other events may cause issues with some LLM providers (e.g., Anthropic requires tool results immediately after tool_calls).
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Trace
|
|
91
|
+
|
|
92
|
+
The `trace` is a sequential log of everything that happened during execution. This is your primary tool for understanding agent behavior.
|
|
93
|
+
|
|
94
|
+
### Trace Entry Types
|
|
95
|
+
|
|
96
|
+
| Type | When Created | Key Fields |
|
|
97
|
+
|------|--------------|------------|
|
|
98
|
+
| `user_input` | User provides input | `content`, `turn` |
|
|
99
|
+
| `thinking` | Agent plans or reflects | `content`, `kind` |
|
|
100
|
+
| `llm_call` | LLM API call completes | `model`, `duration_ms`, `usage` |
|
|
101
|
+
| `tool_result` | Tool execution completes | `name`, `args`, `result`, `status` |
|
|
102
|
+
| `assistant` | Final response ready | `content` |
|
|
103
|
+
| `error` | System/LLM error occurs | `error`, `error_type` |
|
|
104
|
+
|
|
105
|
+
### Common Fields
|
|
106
|
+
|
|
107
|
+
Every trace entry has:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
{
|
|
111
|
+
'id': 1, # Sequential ID (1, 2, 3...)
|
|
112
|
+
'type': 'tool_result', # Entry type
|
|
113
|
+
'ts': 1234567890.123, # Unix timestamp
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### user_input
|
|
118
|
+
|
|
119
|
+
Created when user calls `agent.input()`:
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
{
|
|
123
|
+
'id': 1,
|
|
124
|
+
'type': 'user_input',
|
|
125
|
+
'content': 'Search for Python tutorials',
|
|
126
|
+
'turn': 1,
|
|
127
|
+
'ts': 1234567890.123,
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### thinking
|
|
132
|
+
|
|
133
|
+
Created by planning/reflection plugins (ReAct, Reflect):
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
{
|
|
137
|
+
'id': 2,
|
|
138
|
+
'type': 'thinking',
|
|
139
|
+
'content': 'I should search for tutorials first, then summarize...',
|
|
140
|
+
'kind': 'plan', # 'plan' or 'reflection'
|
|
141
|
+
'ts': 1234567890.456,
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### llm_call
|
|
146
|
+
|
|
147
|
+
Created after each LLM API call:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
{
|
|
151
|
+
'id': 3,
|
|
152
|
+
'type': 'llm_call',
|
|
153
|
+
'model': 'gpt-4o-mini',
|
|
154
|
+
'duration_ms': 234.5,
|
|
155
|
+
'tool_calls_count': 2,
|
|
156
|
+
'iteration': 1,
|
|
157
|
+
'usage': TokenUsage(...), # Token usage object
|
|
158
|
+
'timestamp': 1234567890.789,
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### tool_result
|
|
163
|
+
|
|
164
|
+
Created after each tool execution:
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
{
|
|
168
|
+
'id': 4,
|
|
169
|
+
'type': 'tool_result',
|
|
170
|
+
'name': 'search',
|
|
171
|
+
'args': {'query': 'Python tutorials'},
|
|
172
|
+
'result': 'Found 10 results for Python tutorials...',
|
|
173
|
+
'status': 'success', # 'success', 'error', or 'not_found'
|
|
174
|
+
'timing_ms': 45.2,
|
|
175
|
+
'tool_id': 'call_abc123', # LLM's tool call ID for matching
|
|
176
|
+
'ts': 1234567891.234,
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
# On error:
|
|
180
|
+
{
|
|
181
|
+
'id': 5,
|
|
182
|
+
'type': 'tool_result',
|
|
183
|
+
'name': 'database',
|
|
184
|
+
'args': {'query': 'SELECT *'},
|
|
185
|
+
'result': 'Connection refused',
|
|
186
|
+
'status': 'error',
|
|
187
|
+
'error': 'Connection refused',
|
|
188
|
+
'error_type': 'ConnectionError',
|
|
189
|
+
'timing_ms': 1023.4,
|
|
190
|
+
'tool_id': 'call_def456', # LLM's tool call ID for matching
|
|
191
|
+
'ts': 1234567892.567,
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### assistant
|
|
196
|
+
|
|
197
|
+
Created when LLM provides final response (no more tool calls):
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
{
|
|
201
|
+
'id': 6,
|
|
202
|
+
'type': 'assistant',
|
|
203
|
+
'content': 'I found several Python tutorials. Here are the top results...',
|
|
204
|
+
'ts': 1234567893.890,
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### error
|
|
209
|
+
|
|
210
|
+
Created on system/LLM errors:
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
{
|
|
214
|
+
'id': 7,
|
|
215
|
+
'type': 'error',
|
|
216
|
+
'error': 'Rate limit exceeded',
|
|
217
|
+
'error_type': 'RateLimitError',
|
|
218
|
+
'ts': 1234567894.123,
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Reading Trace in Events
|
|
225
|
+
|
|
226
|
+
Access the latest trace entry:
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
def my_event(agent):
|
|
230
|
+
last = agent.current_session['trace'][-1]
|
|
231
|
+
|
|
232
|
+
if last['type'] == 'tool_result':
|
|
233
|
+
print(f"Tool {last['name']} returned: {last['status']}")
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Filter trace by type:
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
def count_tools(agent):
|
|
240
|
+
trace = agent.current_session['trace']
|
|
241
|
+
tool_calls = [t for t in trace if t['type'] == 'tool_result']
|
|
242
|
+
print(f"Tools used so far: {len(tool_calls)}")
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Aggregate statistics:
|
|
246
|
+
|
|
247
|
+
```python
|
|
248
|
+
def session_stats(agent):
|
|
249
|
+
trace = agent.current_session['trace']
|
|
250
|
+
|
|
251
|
+
llm_calls = [t for t in trace if t['type'] == 'llm_call']
|
|
252
|
+
tool_calls = [t for t in trace if t['type'] == 'tool_result']
|
|
253
|
+
errors = [t for t in trace if t.get('status') == 'error']
|
|
254
|
+
|
|
255
|
+
total_llm_time = sum(t['duration_ms'] for t in llm_calls)
|
|
256
|
+
total_tool_time = sum(t.get('timing_ms', 0) for t in tool_calls)
|
|
257
|
+
|
|
258
|
+
print(f"LLM: {len(llm_calls)} calls, {total_llm_time:.0f}ms")
|
|
259
|
+
print(f"Tools: {len(tool_calls)} calls, {total_tool_time:.0f}ms")
|
|
260
|
+
print(f"Errors: {len(errors)}")
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Pending Tool (before_each_tool only)
|
|
266
|
+
|
|
267
|
+
During `before_each_tool` events, you can access the tool about to execute:
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
from connectonion import Agent, before_each_tool
|
|
271
|
+
|
|
272
|
+
def approve_dangerous(agent):
|
|
273
|
+
pending = agent.current_session.get('pending_tool')
|
|
274
|
+
if not pending:
|
|
275
|
+
return
|
|
276
|
+
|
|
277
|
+
# Inspect before execution
|
|
278
|
+
print(f"About to call: {pending['name']}")
|
|
279
|
+
print(f"With args: {pending['arguments']}")
|
|
280
|
+
print(f"Tool ID: {pending['id']}")
|
|
281
|
+
|
|
282
|
+
# Block if needed
|
|
283
|
+
if pending['name'] == 'delete_all':
|
|
284
|
+
raise ValueError("Blocked dangerous operation")
|
|
285
|
+
|
|
286
|
+
agent = Agent("bot", tools=[...], on_events=[before_each_tool(approve_dangerous)])
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
`pending_tool` structure:
|
|
290
|
+
|
|
291
|
+
```python
|
|
292
|
+
{
|
|
293
|
+
'name': 'bash',
|
|
294
|
+
'arguments': {'command': 'rm -rf /tmp/*'},
|
|
295
|
+
'id': 'call_xyz789', # LLM's tool call ID
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Streaming Trace to Frontend
|
|
302
|
+
|
|
303
|
+
When connected to a frontend (via `agent.connection`), trace entries are automatically streamed as WebSocket events:
|
|
304
|
+
|
|
305
|
+
```python
|
|
306
|
+
# Backend emits these events:
|
|
307
|
+
{'type': 'user_input', 'content': '...', 'id': 1, 'ts': ...}
|
|
308
|
+
{'type': 'thinking', 'content': '...', 'kind': 'plan', 'id': 2, 'ts': ...}
|
|
309
|
+
{'type': 'tool_call', 'tool_id': '...', 'name': '...', 'args': {...}, 'id': 3, 'ts': ...}
|
|
310
|
+
{'type': 'tool_result', 'tool_id': '...', 'name': '...', 'status': 'success', 'id': 4, 'ts': ...}
|
|
311
|
+
{'type': 'assistant', 'content': '...', 'id': 4, 'ts': ...}
|
|
312
|
+
{'type': 'complete', 'tools_used': [...], 'llm_calls': 2, 'iterations': 3}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Frontend can render these in real-time to show agent activity.
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Session Lifecycle
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
agent.input("prompt")
|
|
323
|
+
|
|
|
324
|
+
v
|
|
325
|
+
[Session Created/Continued]
|
|
326
|
+
|
|
|
327
|
+
+-- messages: [system, user]
|
|
328
|
+
+-- trace: [{user_input}]
|
|
329
|
+
+-- turn: 1
|
|
330
|
+
+-- iteration: 1
|
|
331
|
+
|
|
|
332
|
+
v
|
|
333
|
+
[LLM Call]
|
|
334
|
+
|
|
|
335
|
+
+-- trace: [..., {llm_call}]
|
|
336
|
+
|
|
|
337
|
+
v
|
|
338
|
+
[Tool Execution] (if tool_calls)
|
|
339
|
+
|
|
|
340
|
+
+-- trace: [..., {tool_result}]
|
|
341
|
+
+-- messages: [..., assistant, tool]
|
|
342
|
+
+-- iteration: 2
|
|
343
|
+
|
|
|
344
|
+
v
|
|
345
|
+
[Loop until done or max_iterations]
|
|
346
|
+
|
|
|
347
|
+
v
|
|
348
|
+
[Final Response]
|
|
349
|
+
|
|
|
350
|
+
+-- trace: [..., {assistant}]
|
|
351
|
+
+-- messages: [..., assistant]
|
|
352
|
+
|
|
|
353
|
+
v
|
|
354
|
+
[Session Persists for Next Turn]
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## Resetting Session
|
|
360
|
+
|
|
361
|
+
Clear conversation history and start fresh:
|
|
362
|
+
|
|
363
|
+
```python
|
|
364
|
+
agent.reset_conversation()
|
|
365
|
+
|
|
366
|
+
# Next input() starts with clean session
|
|
367
|
+
agent.input("New conversation")
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
After reset:
|
|
371
|
+
- `messages` cleared (only system prompt remains)
|
|
372
|
+
- `trace` cleared
|
|
373
|
+
- `turn` reset to 1
|
|
374
|
+
- Token usage preserved (for cost tracking)
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## Best Practices
|
|
379
|
+
|
|
380
|
+
### 1. Check trace type before accessing fields
|
|
381
|
+
|
|
382
|
+
```python
|
|
383
|
+
def safe_handler(agent):
|
|
384
|
+
last = agent.current_session['trace'][-1]
|
|
385
|
+
|
|
386
|
+
# Different types have different fields
|
|
387
|
+
if last['type'] == 'tool_result':
|
|
388
|
+
print(last['name'], last['result'])
|
|
389
|
+
elif last['type'] == 'llm_call':
|
|
390
|
+
print(last['model'], last['duration_ms'])
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### 2. Use .get() for optional fields
|
|
394
|
+
|
|
395
|
+
```python
|
|
396
|
+
def handle_error(agent):
|
|
397
|
+
last = agent.current_session['trace'][-1]
|
|
398
|
+
|
|
399
|
+
# 'error' only exists on error status
|
|
400
|
+
error = last.get('error', 'Unknown error')
|
|
401
|
+
error_type = last.get('error_type', 'Error')
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### 3. Don't modify trace directly
|
|
405
|
+
|
|
406
|
+
Trace is append-only. Add entries via proper channels (tools, LLM calls), not by modifying the list.
|
|
407
|
+
|
|
408
|
+
### 4. Use after_tools for message injection
|
|
409
|
+
|
|
410
|
+
```python
|
|
411
|
+
# Good - after_tools is safe for all providers
|
|
412
|
+
@after_tools
|
|
413
|
+
def add_reflection(agent):
|
|
414
|
+
agent.current_session['messages'].append({...})
|
|
415
|
+
|
|
416
|
+
# Risky - may break Anthropic compatibility
|
|
417
|
+
@after_each_tool
|
|
418
|
+
def add_reflection(agent):
|
|
419
|
+
agent.current_session['messages'].append({...}) # Don't do this
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
## What's Next?
|
|
425
|
+
|
|
426
|
+
- [Events](events.md) - Hook into agent lifecycle
|
|
427
|
+
- [Agent](agent.md) - Full agent API reference
|
|
428
|
+
- [Tools](tools.md) - Build powerful tools
|