agentpool 2.1.9__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.
Potentially problematic release.
This version of agentpool might be problematic. Click here for more details.
- acp/README.md +64 -0
- acp/__init__.py +172 -0
- acp/__main__.py +10 -0
- acp/acp_requests.py +285 -0
- acp/agent/__init__.py +6 -0
- acp/agent/connection.py +256 -0
- acp/agent/implementations/__init__.py +6 -0
- acp/agent/implementations/debug_server/__init__.py +1 -0
- acp/agent/implementations/debug_server/cli.py +79 -0
- acp/agent/implementations/debug_server/debug.html +234 -0
- acp/agent/implementations/debug_server/debug_server.py +496 -0
- acp/agent/implementations/testing.py +91 -0
- acp/agent/protocol.py +65 -0
- acp/bridge/README.md +162 -0
- acp/bridge/__init__.py +6 -0
- acp/bridge/__main__.py +91 -0
- acp/bridge/bridge.py +246 -0
- acp/bridge/py.typed +0 -0
- acp/bridge/settings.py +15 -0
- acp/client/__init__.py +7 -0
- acp/client/connection.py +251 -0
- acp/client/implementations/__init__.py +7 -0
- acp/client/implementations/default_client.py +185 -0
- acp/client/implementations/headless_client.py +266 -0
- acp/client/implementations/noop_client.py +110 -0
- acp/client/protocol.py +61 -0
- acp/connection.py +280 -0
- acp/exceptions.py +46 -0
- acp/filesystem.py +524 -0
- acp/notifications.py +832 -0
- acp/py.typed +0 -0
- acp/schema/__init__.py +265 -0
- acp/schema/agent_plan.py +30 -0
- acp/schema/agent_requests.py +126 -0
- acp/schema/agent_responses.py +256 -0
- acp/schema/base.py +39 -0
- acp/schema/capabilities.py +230 -0
- acp/schema/client_requests.py +247 -0
- acp/schema/client_responses.py +96 -0
- acp/schema/common.py +81 -0
- acp/schema/content_blocks.py +188 -0
- acp/schema/mcp.py +82 -0
- acp/schema/messages.py +171 -0
- acp/schema/notifications.py +82 -0
- acp/schema/protocol_stuff.md +3 -0
- acp/schema/session_state.py +160 -0
- acp/schema/session_updates.py +419 -0
- acp/schema/slash_commands.py +51 -0
- acp/schema/terminal.py +15 -0
- acp/schema/tool_call.py +347 -0
- acp/stdio.py +250 -0
- acp/task/__init__.py +53 -0
- acp/task/debug.py +197 -0
- acp/task/dispatcher.py +93 -0
- acp/task/queue.py +69 -0
- acp/task/sender.py +82 -0
- acp/task/state.py +87 -0
- acp/task/supervisor.py +93 -0
- acp/terminal_handle.py +30 -0
- acp/tool_call_reporter.py +199 -0
- acp/tool_call_state.py +178 -0
- acp/transports.py +104 -0
- acp/utils.py +240 -0
- agentpool/__init__.py +63 -0
- agentpool/__main__.py +7 -0
- agentpool/agents/__init__.py +30 -0
- agentpool/agents/acp_agent/__init__.py +5 -0
- agentpool/agents/acp_agent/acp_agent.py +837 -0
- agentpool/agents/acp_agent/acp_converters.py +294 -0
- agentpool/agents/acp_agent/client_handler.py +317 -0
- agentpool/agents/acp_agent/session_state.py +44 -0
- agentpool/agents/agent.py +1264 -0
- agentpool/agents/agui_agent/__init__.py +19 -0
- agentpool/agents/agui_agent/agui_agent.py +677 -0
- agentpool/agents/agui_agent/agui_converters.py +423 -0
- agentpool/agents/agui_agent/chunk_transformer.py +204 -0
- agentpool/agents/agui_agent/event_types.py +83 -0
- agentpool/agents/agui_agent/helpers.py +192 -0
- agentpool/agents/architect.py +71 -0
- agentpool/agents/base_agent.py +177 -0
- agentpool/agents/claude_code_agent/__init__.py +11 -0
- agentpool/agents/claude_code_agent/claude_code_agent.py +1021 -0
- agentpool/agents/claude_code_agent/converters.py +243 -0
- agentpool/agents/context.py +105 -0
- agentpool/agents/events/__init__.py +61 -0
- agentpool/agents/events/builtin_handlers.py +129 -0
- agentpool/agents/events/event_emitter.py +320 -0
- agentpool/agents/events/events.py +561 -0
- agentpool/agents/events/tts_handlers.py +186 -0
- agentpool/agents/interactions.py +419 -0
- agentpool/agents/slashed_agent.py +244 -0
- agentpool/agents/sys_prompts.py +178 -0
- agentpool/agents/tool_wrapping.py +184 -0
- agentpool/base_provider.py +28 -0
- agentpool/common_types.py +226 -0
- agentpool/config_resources/__init__.py +16 -0
- agentpool/config_resources/acp_assistant.yml +24 -0
- agentpool/config_resources/agents.yml +109 -0
- agentpool/config_resources/agents_template.yml +18 -0
- agentpool/config_resources/agui_test.yml +18 -0
- agentpool/config_resources/claude_code_agent.yml +16 -0
- agentpool/config_resources/claude_style_subagent.md +30 -0
- agentpool/config_resources/external_acp_agents.yml +77 -0
- agentpool/config_resources/opencode_style_subagent.md +19 -0
- agentpool/config_resources/tts_test_agents.yml +78 -0
- agentpool/delegation/__init__.py +8 -0
- agentpool/delegation/base_team.py +504 -0
- agentpool/delegation/message_flow_tracker.py +39 -0
- agentpool/delegation/pool.py +1129 -0
- agentpool/delegation/team.py +325 -0
- agentpool/delegation/teamrun.py +343 -0
- agentpool/docs/__init__.py +5 -0
- agentpool/docs/gen_examples.py +42 -0
- agentpool/docs/utils.py +370 -0
- agentpool/functional/__init__.py +20 -0
- agentpool/functional/py.typed +0 -0
- agentpool/functional/run.py +80 -0
- agentpool/functional/structure.py +136 -0
- agentpool/hooks/__init__.py +20 -0
- agentpool/hooks/agent_hooks.py +247 -0
- agentpool/hooks/base.py +119 -0
- agentpool/hooks/callable.py +140 -0
- agentpool/hooks/command.py +180 -0
- agentpool/hooks/prompt.py +122 -0
- agentpool/jinja_filters.py +132 -0
- agentpool/log.py +224 -0
- agentpool/mcp_server/__init__.py +17 -0
- agentpool/mcp_server/client.py +429 -0
- agentpool/mcp_server/constants.py +32 -0
- agentpool/mcp_server/conversions.py +172 -0
- agentpool/mcp_server/helpers.py +47 -0
- agentpool/mcp_server/manager.py +232 -0
- agentpool/mcp_server/message_handler.py +164 -0
- agentpool/mcp_server/registries/__init__.py +1 -0
- agentpool/mcp_server/registries/official_registry_client.py +345 -0
- agentpool/mcp_server/registries/pulsemcp_client.py +88 -0
- agentpool/mcp_server/tool_bridge.py +548 -0
- agentpool/messaging/__init__.py +58 -0
- agentpool/messaging/compaction.py +928 -0
- agentpool/messaging/connection_manager.py +319 -0
- agentpool/messaging/context.py +66 -0
- agentpool/messaging/event_manager.py +426 -0
- agentpool/messaging/events.py +39 -0
- agentpool/messaging/message_container.py +209 -0
- agentpool/messaging/message_history.py +491 -0
- agentpool/messaging/messagenode.py +377 -0
- agentpool/messaging/messages.py +655 -0
- agentpool/messaging/processing.py +76 -0
- agentpool/mime_utils.py +95 -0
- agentpool/models/__init__.py +21 -0
- agentpool/models/acp_agents/__init__.py +22 -0
- agentpool/models/acp_agents/base.py +308 -0
- agentpool/models/acp_agents/mcp_capable.py +790 -0
- agentpool/models/acp_agents/non_mcp.py +842 -0
- agentpool/models/agents.py +450 -0
- agentpool/models/agui_agents.py +89 -0
- agentpool/models/claude_code_agents.py +238 -0
- agentpool/models/file_agents.py +116 -0
- agentpool/models/file_parsing.py +367 -0
- agentpool/models/manifest.py +658 -0
- agentpool/observability/__init__.py +9 -0
- agentpool/observability/observability_registry.py +97 -0
- agentpool/prompts/__init__.py +1 -0
- agentpool/prompts/base.py +27 -0
- agentpool/prompts/builtin_provider.py +75 -0
- agentpool/prompts/conversion_manager.py +95 -0
- agentpool/prompts/convert.py +96 -0
- agentpool/prompts/manager.py +204 -0
- agentpool/prompts/parts/zed.md +33 -0
- agentpool/prompts/prompts.py +581 -0
- agentpool/py.typed +0 -0
- agentpool/queries/tree-sitter-language-pack/README.md +7 -0
- agentpool/queries/tree-sitter-language-pack/arduino-tags.scm +5 -0
- agentpool/queries/tree-sitter-language-pack/c-tags.scm +9 -0
- agentpool/queries/tree-sitter-language-pack/chatito-tags.scm +16 -0
- agentpool/queries/tree-sitter-language-pack/clojure-tags.scm +7 -0
- agentpool/queries/tree-sitter-language-pack/commonlisp-tags.scm +122 -0
- agentpool/queries/tree-sitter-language-pack/cpp-tags.scm +15 -0
- agentpool/queries/tree-sitter-language-pack/csharp-tags.scm +26 -0
- agentpool/queries/tree-sitter-language-pack/d-tags.scm +26 -0
- agentpool/queries/tree-sitter-language-pack/dart-tags.scm +92 -0
- agentpool/queries/tree-sitter-language-pack/elisp-tags.scm +5 -0
- agentpool/queries/tree-sitter-language-pack/elixir-tags.scm +54 -0
- agentpool/queries/tree-sitter-language-pack/elm-tags.scm +19 -0
- agentpool/queries/tree-sitter-language-pack/gleam-tags.scm +41 -0
- agentpool/queries/tree-sitter-language-pack/go-tags.scm +42 -0
- agentpool/queries/tree-sitter-language-pack/java-tags.scm +20 -0
- agentpool/queries/tree-sitter-language-pack/javascript-tags.scm +88 -0
- agentpool/queries/tree-sitter-language-pack/lua-tags.scm +34 -0
- agentpool/queries/tree-sitter-language-pack/matlab-tags.scm +10 -0
- agentpool/queries/tree-sitter-language-pack/ocaml-tags.scm +115 -0
- agentpool/queries/tree-sitter-language-pack/ocaml_interface-tags.scm +98 -0
- agentpool/queries/tree-sitter-language-pack/pony-tags.scm +39 -0
- agentpool/queries/tree-sitter-language-pack/properties-tags.scm +5 -0
- agentpool/queries/tree-sitter-language-pack/python-tags.scm +14 -0
- agentpool/queries/tree-sitter-language-pack/r-tags.scm +21 -0
- agentpool/queries/tree-sitter-language-pack/racket-tags.scm +12 -0
- agentpool/queries/tree-sitter-language-pack/ruby-tags.scm +64 -0
- agentpool/queries/tree-sitter-language-pack/rust-tags.scm +60 -0
- agentpool/queries/tree-sitter-language-pack/solidity-tags.scm +43 -0
- agentpool/queries/tree-sitter-language-pack/swift-tags.scm +51 -0
- agentpool/queries/tree-sitter-language-pack/udev-tags.scm +20 -0
- agentpool/queries/tree-sitter-languages/README.md +24 -0
- agentpool/queries/tree-sitter-languages/c-tags.scm +9 -0
- agentpool/queries/tree-sitter-languages/c_sharp-tags.scm +46 -0
- agentpool/queries/tree-sitter-languages/cpp-tags.scm +15 -0
- agentpool/queries/tree-sitter-languages/dart-tags.scm +91 -0
- agentpool/queries/tree-sitter-languages/elisp-tags.scm +8 -0
- agentpool/queries/tree-sitter-languages/elixir-tags.scm +54 -0
- agentpool/queries/tree-sitter-languages/elm-tags.scm +19 -0
- agentpool/queries/tree-sitter-languages/fortran-tags.scm +15 -0
- agentpool/queries/tree-sitter-languages/go-tags.scm +30 -0
- agentpool/queries/tree-sitter-languages/haskell-tags.scm +3 -0
- agentpool/queries/tree-sitter-languages/hcl-tags.scm +77 -0
- agentpool/queries/tree-sitter-languages/java-tags.scm +20 -0
- agentpool/queries/tree-sitter-languages/javascript-tags.scm +88 -0
- agentpool/queries/tree-sitter-languages/julia-tags.scm +60 -0
- agentpool/queries/tree-sitter-languages/kotlin-tags.scm +27 -0
- agentpool/queries/tree-sitter-languages/matlab-tags.scm +10 -0
- agentpool/queries/tree-sitter-languages/ocaml-tags.scm +115 -0
- agentpool/queries/tree-sitter-languages/ocaml_interface-tags.scm +98 -0
- agentpool/queries/tree-sitter-languages/php-tags.scm +26 -0
- agentpool/queries/tree-sitter-languages/python-tags.scm +12 -0
- agentpool/queries/tree-sitter-languages/ql-tags.scm +26 -0
- agentpool/queries/tree-sitter-languages/ruby-tags.scm +64 -0
- agentpool/queries/tree-sitter-languages/rust-tags.scm +60 -0
- agentpool/queries/tree-sitter-languages/scala-tags.scm +65 -0
- agentpool/queries/tree-sitter-languages/typescript-tags.scm +41 -0
- agentpool/queries/tree-sitter-languages/zig-tags.scm +3 -0
- agentpool/repomap.py +1231 -0
- agentpool/resource_providers/__init__.py +17 -0
- agentpool/resource_providers/aggregating.py +54 -0
- agentpool/resource_providers/base.py +172 -0
- agentpool/resource_providers/codemode/__init__.py +9 -0
- agentpool/resource_providers/codemode/code_executor.py +215 -0
- agentpool/resource_providers/codemode/default_prompt.py +19 -0
- agentpool/resource_providers/codemode/helpers.py +83 -0
- agentpool/resource_providers/codemode/progress_executor.py +212 -0
- agentpool/resource_providers/codemode/provider.py +150 -0
- agentpool/resource_providers/codemode/remote_mcp_execution.py +143 -0
- agentpool/resource_providers/codemode/remote_provider.py +171 -0
- agentpool/resource_providers/filtering.py +42 -0
- agentpool/resource_providers/mcp_provider.py +246 -0
- agentpool/resource_providers/plan_provider.py +196 -0
- agentpool/resource_providers/pool.py +69 -0
- agentpool/resource_providers/static.py +289 -0
- agentpool/running/__init__.py +20 -0
- agentpool/running/decorators.py +56 -0
- agentpool/running/discovery.py +101 -0
- agentpool/running/executor.py +284 -0
- agentpool/running/injection.py +111 -0
- agentpool/running/py.typed +0 -0
- agentpool/running/run_nodes.py +87 -0
- agentpool/server.py +122 -0
- agentpool/sessions/__init__.py +13 -0
- agentpool/sessions/manager.py +302 -0
- agentpool/sessions/models.py +71 -0
- agentpool/sessions/session.py +239 -0
- agentpool/sessions/store.py +163 -0
- agentpool/skills/__init__.py +5 -0
- agentpool/skills/manager.py +120 -0
- agentpool/skills/registry.py +210 -0
- agentpool/skills/skill.py +36 -0
- agentpool/storage/__init__.py +17 -0
- agentpool/storage/manager.py +419 -0
- agentpool/storage/serialization.py +136 -0
- agentpool/talk/__init__.py +13 -0
- agentpool/talk/registry.py +128 -0
- agentpool/talk/stats.py +159 -0
- agentpool/talk/talk.py +604 -0
- agentpool/tasks/__init__.py +20 -0
- agentpool/tasks/exceptions.py +25 -0
- agentpool/tasks/registry.py +33 -0
- agentpool/testing.py +129 -0
- agentpool/text_templates/__init__.py +39 -0
- agentpool/text_templates/system_prompt.jinja +30 -0
- agentpool/text_templates/tool_call_default.jinja +13 -0
- agentpool/text_templates/tool_call_markdown.jinja +25 -0
- agentpool/text_templates/tool_call_simple.jinja +5 -0
- agentpool/tools/__init__.py +16 -0
- agentpool/tools/base.py +269 -0
- agentpool/tools/exceptions.py +9 -0
- agentpool/tools/manager.py +255 -0
- agentpool/tools/tool_call_info.py +87 -0
- agentpool/ui/__init__.py +2 -0
- agentpool/ui/base.py +89 -0
- agentpool/ui/mock_provider.py +81 -0
- agentpool/ui/stdlib_provider.py +150 -0
- agentpool/utils/__init__.py +44 -0
- agentpool/utils/baseregistry.py +185 -0
- agentpool/utils/count_tokens.py +62 -0
- agentpool/utils/dag.py +184 -0
- agentpool/utils/importing.py +206 -0
- agentpool/utils/inspection.py +334 -0
- agentpool/utils/model_capabilities.py +25 -0
- agentpool/utils/network.py +28 -0
- agentpool/utils/now.py +22 -0
- agentpool/utils/parse_time.py +87 -0
- agentpool/utils/result_utils.py +35 -0
- agentpool/utils/signatures.py +305 -0
- agentpool/utils/streams.py +112 -0
- agentpool/utils/tasks.py +186 -0
- agentpool/vfs_registry.py +250 -0
- agentpool-2.1.9.dist-info/METADATA +336 -0
- agentpool-2.1.9.dist-info/RECORD +474 -0
- agentpool-2.1.9.dist-info/WHEEL +4 -0
- agentpool-2.1.9.dist-info/entry_points.txt +14 -0
- agentpool-2.1.9.dist-info/licenses/LICENSE +22 -0
- agentpool_cli/__init__.py +34 -0
- agentpool_cli/__main__.py +66 -0
- agentpool_cli/agent.py +175 -0
- agentpool_cli/cli_types.py +23 -0
- agentpool_cli/common.py +163 -0
- agentpool_cli/create.py +175 -0
- agentpool_cli/history.py +217 -0
- agentpool_cli/log.py +78 -0
- agentpool_cli/py.typed +0 -0
- agentpool_cli/run.py +84 -0
- agentpool_cli/serve_acp.py +177 -0
- agentpool_cli/serve_api.py +69 -0
- agentpool_cli/serve_mcp.py +74 -0
- agentpool_cli/serve_vercel.py +233 -0
- agentpool_cli/store.py +171 -0
- agentpool_cli/task.py +84 -0
- agentpool_cli/utils.py +104 -0
- agentpool_cli/watch.py +54 -0
- agentpool_commands/__init__.py +180 -0
- agentpool_commands/agents.py +199 -0
- agentpool_commands/base.py +45 -0
- agentpool_commands/commands.py +58 -0
- agentpool_commands/completers.py +110 -0
- agentpool_commands/connections.py +175 -0
- agentpool_commands/markdown_utils.py +31 -0
- agentpool_commands/models.py +62 -0
- agentpool_commands/prompts.py +78 -0
- agentpool_commands/py.typed +0 -0
- agentpool_commands/read.py +77 -0
- agentpool_commands/resources.py +210 -0
- agentpool_commands/session.py +48 -0
- agentpool_commands/tools.py +269 -0
- agentpool_commands/utils.py +189 -0
- agentpool_commands/workers.py +163 -0
- agentpool_config/__init__.py +53 -0
- agentpool_config/builtin_tools.py +265 -0
- agentpool_config/commands.py +237 -0
- agentpool_config/conditions.py +301 -0
- agentpool_config/converters.py +30 -0
- agentpool_config/durable.py +331 -0
- agentpool_config/event_handlers.py +600 -0
- agentpool_config/events.py +153 -0
- agentpool_config/forward_targets.py +251 -0
- agentpool_config/hook_conditions.py +331 -0
- agentpool_config/hooks.py +241 -0
- agentpool_config/jinja.py +206 -0
- agentpool_config/knowledge.py +41 -0
- agentpool_config/loaders.py +350 -0
- agentpool_config/mcp_server.py +243 -0
- agentpool_config/nodes.py +202 -0
- agentpool_config/observability.py +191 -0
- agentpool_config/output_types.py +55 -0
- agentpool_config/pool_server.py +267 -0
- agentpool_config/prompt_hubs.py +105 -0
- agentpool_config/prompts.py +185 -0
- agentpool_config/py.typed +0 -0
- agentpool_config/resources.py +33 -0
- agentpool_config/session.py +119 -0
- agentpool_config/skills.py +17 -0
- agentpool_config/storage.py +288 -0
- agentpool_config/system_prompts.py +190 -0
- agentpool_config/task.py +162 -0
- agentpool_config/teams.py +52 -0
- agentpool_config/tools.py +112 -0
- agentpool_config/toolsets.py +1033 -0
- agentpool_config/workers.py +86 -0
- agentpool_prompts/__init__.py +1 -0
- agentpool_prompts/braintrust_hub.py +235 -0
- agentpool_prompts/fabric.py +75 -0
- agentpool_prompts/langfuse_hub.py +79 -0
- agentpool_prompts/promptlayer_provider.py +59 -0
- agentpool_prompts/py.typed +0 -0
- agentpool_server/__init__.py +9 -0
- agentpool_server/a2a_server/__init__.py +5 -0
- agentpool_server/a2a_server/a2a_types.py +41 -0
- agentpool_server/a2a_server/server.py +190 -0
- agentpool_server/a2a_server/storage.py +81 -0
- agentpool_server/acp_server/__init__.py +22 -0
- agentpool_server/acp_server/acp_agent.py +786 -0
- agentpool_server/acp_server/acp_tools.py +43 -0
- agentpool_server/acp_server/commands/__init__.py +18 -0
- agentpool_server/acp_server/commands/acp_commands.py +594 -0
- agentpool_server/acp_server/commands/debug_commands.py +376 -0
- agentpool_server/acp_server/commands/docs_commands/__init__.py +39 -0
- agentpool_server/acp_server/commands/docs_commands/fetch_repo.py +169 -0
- agentpool_server/acp_server/commands/docs_commands/get_schema.py +176 -0
- agentpool_server/acp_server/commands/docs_commands/get_source.py +110 -0
- agentpool_server/acp_server/commands/docs_commands/git_diff.py +111 -0
- agentpool_server/acp_server/commands/docs_commands/helpers.py +33 -0
- agentpool_server/acp_server/commands/docs_commands/url_to_markdown.py +90 -0
- agentpool_server/acp_server/commands/spawn.py +210 -0
- agentpool_server/acp_server/converters.py +235 -0
- agentpool_server/acp_server/input_provider.py +338 -0
- agentpool_server/acp_server/server.py +288 -0
- agentpool_server/acp_server/session.py +969 -0
- agentpool_server/acp_server/session_manager.py +313 -0
- agentpool_server/acp_server/syntax_detection.py +250 -0
- agentpool_server/acp_server/zed_tools.md +90 -0
- agentpool_server/aggregating_server.py +309 -0
- agentpool_server/agui_server/__init__.py +11 -0
- agentpool_server/agui_server/server.py +128 -0
- agentpool_server/base.py +189 -0
- agentpool_server/http_server.py +164 -0
- agentpool_server/mcp_server/__init__.py +6 -0
- agentpool_server/mcp_server/server.py +314 -0
- agentpool_server/mcp_server/zed_wrapper.py +110 -0
- agentpool_server/openai_api_server/__init__.py +5 -0
- agentpool_server/openai_api_server/completions/__init__.py +1 -0
- agentpool_server/openai_api_server/completions/helpers.py +81 -0
- agentpool_server/openai_api_server/completions/models.py +98 -0
- agentpool_server/openai_api_server/responses/__init__.py +1 -0
- agentpool_server/openai_api_server/responses/helpers.py +74 -0
- agentpool_server/openai_api_server/responses/models.py +96 -0
- agentpool_server/openai_api_server/server.py +242 -0
- agentpool_server/py.typed +0 -0
- agentpool_storage/__init__.py +9 -0
- agentpool_storage/base.py +310 -0
- agentpool_storage/file_provider.py +378 -0
- agentpool_storage/formatters.py +129 -0
- agentpool_storage/memory_provider.py +396 -0
- agentpool_storage/models.py +108 -0
- agentpool_storage/py.typed +0 -0
- agentpool_storage/session_store.py +262 -0
- agentpool_storage/sql_provider/__init__.py +21 -0
- agentpool_storage/sql_provider/cli.py +146 -0
- agentpool_storage/sql_provider/models.py +249 -0
- agentpool_storage/sql_provider/queries.py +15 -0
- agentpool_storage/sql_provider/sql_provider.py +444 -0
- agentpool_storage/sql_provider/utils.py +234 -0
- agentpool_storage/text_log_provider.py +275 -0
- agentpool_toolsets/__init__.py +15 -0
- agentpool_toolsets/builtin/__init__.py +33 -0
- agentpool_toolsets/builtin/agent_management.py +239 -0
- agentpool_toolsets/builtin/chain.py +288 -0
- agentpool_toolsets/builtin/code.py +398 -0
- agentpool_toolsets/builtin/debug.py +291 -0
- agentpool_toolsets/builtin/execution_environment.py +381 -0
- agentpool_toolsets/builtin/file_edit/__init__.py +11 -0
- agentpool_toolsets/builtin/file_edit/file_edit.py +747 -0
- agentpool_toolsets/builtin/file_edit/fuzzy_matcher/__init__.py +5 -0
- agentpool_toolsets/builtin/file_edit/fuzzy_matcher/example_usage.py +311 -0
- agentpool_toolsets/builtin/file_edit/fuzzy_matcher/streaming_fuzzy_matcher.py +443 -0
- agentpool_toolsets/builtin/history.py +36 -0
- agentpool_toolsets/builtin/integration.py +85 -0
- agentpool_toolsets/builtin/skills.py +77 -0
- agentpool_toolsets/builtin/subagent_tools.py +324 -0
- agentpool_toolsets/builtin/tool_management.py +90 -0
- agentpool_toolsets/builtin/user_interaction.py +52 -0
- agentpool_toolsets/builtin/workers.py +128 -0
- agentpool_toolsets/composio_toolset.py +96 -0
- agentpool_toolsets/config_creation.py +192 -0
- agentpool_toolsets/entry_points.py +47 -0
- agentpool_toolsets/fsspec_toolset/__init__.py +7 -0
- agentpool_toolsets/fsspec_toolset/diagnostics.py +115 -0
- agentpool_toolsets/fsspec_toolset/grep.py +450 -0
- agentpool_toolsets/fsspec_toolset/helpers.py +631 -0
- agentpool_toolsets/fsspec_toolset/streaming_diff_parser.py +249 -0
- agentpool_toolsets/fsspec_toolset/toolset.py +1384 -0
- agentpool_toolsets/mcp_run_toolset.py +61 -0
- agentpool_toolsets/notifications.py +146 -0
- agentpool_toolsets/openapi.py +118 -0
- agentpool_toolsets/py.typed +0 -0
- agentpool_toolsets/search_toolset.py +202 -0
- agentpool_toolsets/semantic_memory_toolset.py +536 -0
- agentpool_toolsets/streaming_tools.py +265 -0
- agentpool_toolsets/vfs_toolset.py +124 -0
agentpool_cli/history.py
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"""History management commands."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from datetime import UTC, datetime
|
|
6
|
+
from typing import TYPE_CHECKING, Annotated
|
|
7
|
+
|
|
8
|
+
import typer as t
|
|
9
|
+
|
|
10
|
+
from agentpool_cli import log, resolve_agent_config
|
|
11
|
+
from agentpool_cli.cli_types import GroupBy
|
|
12
|
+
from agentpool_cli.common import OutputFormat, format_output, output_format_opt
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from agentpool_storage.base import StorageProvider
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
logger = log.get_logger(__name__)
|
|
20
|
+
|
|
21
|
+
help_text = "Conversation history management"
|
|
22
|
+
history_cli = t.Typer(name="history", help=help_text, no_args_is_help=True)
|
|
23
|
+
|
|
24
|
+
AGENT_NAME_HELP = "Agent name (shows all if not provided)"
|
|
25
|
+
SINCE_HELP = "Show conversations since (YYYY-MM-DD or YYYY-MM-DD HH:MM)"
|
|
26
|
+
PERIOD_HELP = "Show conversations from last period (1h, 2d, 1w, 1m)"
|
|
27
|
+
COMPACT_HELP = "Show only first/last message of conversations"
|
|
28
|
+
TOKEN_HELP = "Include token usage statistics"
|
|
29
|
+
CONFIG_HELP = "Override agent config path"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def get_history_provider(config_path: str) -> StorageProvider:
|
|
33
|
+
"""Get history provider from manifest config.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
config_path: Path to agent configuration file
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Storage provider configured for history operations
|
|
40
|
+
"""
|
|
41
|
+
from agentpool import AgentsManifest
|
|
42
|
+
from agentpool.storage import StorageManager
|
|
43
|
+
|
|
44
|
+
manifest = AgentsManifest.from_file(config_path)
|
|
45
|
+
storage = StorageManager(manifest.storage)
|
|
46
|
+
return storage.get_history_provider()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@history_cli.command(name="show")
|
|
50
|
+
def show_history(
|
|
51
|
+
agent_name: Annotated[str | None, t.Argument(help=AGENT_NAME_HELP)] = None,
|
|
52
|
+
config: Annotated[str | None, t.Option("--config", "-c", help=CONFIG_HELP)] = None,
|
|
53
|
+
# Time-based filtering
|
|
54
|
+
since: Annotated[datetime | None, t.Option("--since", "-s", help=SINCE_HELP)] = None,
|
|
55
|
+
period: Annotated[str | None, t.Option("--period", "-p", help=PERIOD_HELP)] = None,
|
|
56
|
+
# Content filtering
|
|
57
|
+
query: Annotated[
|
|
58
|
+
str | None, t.Option("--query", "-q", help="Search in message content")
|
|
59
|
+
] = None,
|
|
60
|
+
model: Annotated[str | None, t.Option("--model", "-m", help="Filter by model used")] = None,
|
|
61
|
+
# Output control
|
|
62
|
+
limit: Annotated[int, t.Option("--limit", "-n", help="Number of conversations")] = 10,
|
|
63
|
+
compact: Annotated[bool, t.Option("--compact", help=COMPACT_HELP)] = False,
|
|
64
|
+
tokens: Annotated[bool, t.Option("--tokens", "-t", help=TOKEN_HELP)] = False,
|
|
65
|
+
output_format: OutputFormat = output_format_opt,
|
|
66
|
+
) -> None:
|
|
67
|
+
"""Show conversation history with filtering options.
|
|
68
|
+
|
|
69
|
+
Examples:
|
|
70
|
+
# Show last 5 conversations
|
|
71
|
+
agentpool history show -n 5
|
|
72
|
+
|
|
73
|
+
# Show conversations from last 24 hours
|
|
74
|
+
agentpool history show --period 24h
|
|
75
|
+
|
|
76
|
+
# Show conversations since specific date
|
|
77
|
+
agentpool history show --since 2024-01-01
|
|
78
|
+
|
|
79
|
+
# Search for specific content
|
|
80
|
+
agentpool history show --query "database schema"
|
|
81
|
+
|
|
82
|
+
# Show GPT-5 conversations with token usage
|
|
83
|
+
agentpool history show --model gpt-5 --tokens
|
|
84
|
+
|
|
85
|
+
# Compact view of recent conversations
|
|
86
|
+
agentpool history show --period 1d --compact
|
|
87
|
+
"""
|
|
88
|
+
import anyio
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
# Resolve config and get provider
|
|
92
|
+
config_path = resolve_agent_config(config)
|
|
93
|
+
provider = get_history_provider(config_path)
|
|
94
|
+
|
|
95
|
+
async def main() -> None:
|
|
96
|
+
async with provider:
|
|
97
|
+
results = await provider.get_filtered_conversations(
|
|
98
|
+
agent_name=agent_name,
|
|
99
|
+
period=period,
|
|
100
|
+
since=since,
|
|
101
|
+
query=query,
|
|
102
|
+
model=model,
|
|
103
|
+
limit=limit,
|
|
104
|
+
compact=compact,
|
|
105
|
+
include_tokens=tokens,
|
|
106
|
+
)
|
|
107
|
+
format_output(results, output_format)
|
|
108
|
+
|
|
109
|
+
anyio.run(main)
|
|
110
|
+
|
|
111
|
+
except Exception as e:
|
|
112
|
+
logger.exception("Failed to show history")
|
|
113
|
+
raise t.Exit(1) from e
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@history_cli.command(name="stats")
|
|
117
|
+
def show_stats(
|
|
118
|
+
agent_name: Annotated[str | None, t.Argument(help=AGENT_NAME_HELP)] = None,
|
|
119
|
+
config: Annotated[str | None, t.Option("--config", "-c", help=CONFIG_HELP)] = None,
|
|
120
|
+
period: Annotated[
|
|
121
|
+
str, t.Option("--period", "-p", help="Time period (1h, 1d, 1w, 1m, 1y)")
|
|
122
|
+
] = "1d",
|
|
123
|
+
group_by: Annotated[GroupBy, t.Option("--group-by", "-g", help="Group by")] = "agent",
|
|
124
|
+
output_format: OutputFormat = output_format_opt,
|
|
125
|
+
) -> None:
|
|
126
|
+
"""Show usage statistics.
|
|
127
|
+
|
|
128
|
+
Examples:
|
|
129
|
+
# Show stats for all agents
|
|
130
|
+
agentpool history stats
|
|
131
|
+
|
|
132
|
+
# Show daily stats for specific agent
|
|
133
|
+
agentpool history stats myagent --group-by day
|
|
134
|
+
|
|
135
|
+
# Show model usage for last week
|
|
136
|
+
agentpool history stats --period 1w --group-by model
|
|
137
|
+
"""
|
|
138
|
+
import anyio
|
|
139
|
+
|
|
140
|
+
from agentpool.utils.parse_time import parse_time_period
|
|
141
|
+
from agentpool_storage.formatters import format_stats
|
|
142
|
+
from agentpool_storage.models import StatsFilters
|
|
143
|
+
|
|
144
|
+
try:
|
|
145
|
+
# Resolve config and get provider
|
|
146
|
+
config_path = resolve_agent_config(config)
|
|
147
|
+
provider = get_history_provider(config_path)
|
|
148
|
+
|
|
149
|
+
# Create filters
|
|
150
|
+
cutoff = datetime.now(UTC) - parse_time_period(period)
|
|
151
|
+
filters = StatsFilters(cutoff=cutoff, group_by=group_by, agent_name=agent_name)
|
|
152
|
+
|
|
153
|
+
async def main() -> None:
|
|
154
|
+
async with provider:
|
|
155
|
+
stats = await provider.get_conversation_stats(filters)
|
|
156
|
+
formatted = format_stats(stats, period, group_by)
|
|
157
|
+
format_output(formatted, output_format)
|
|
158
|
+
|
|
159
|
+
anyio.run(main)
|
|
160
|
+
|
|
161
|
+
except Exception as e:
|
|
162
|
+
logger.exception("Failed to show stats")
|
|
163
|
+
raise t.Exit(1) from e
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
@history_cli.command(name="reset")
|
|
167
|
+
def reset_history(
|
|
168
|
+
config: Annotated[str | None, t.Option("--config", "-c", help=CONFIG_HELP)] = None,
|
|
169
|
+
confirm: Annotated[bool, t.Option("--confirm", "-y", help="Confirm deletion")] = False,
|
|
170
|
+
agent_name: Annotated[
|
|
171
|
+
str | None, t.Option("--agent", "-a", help="Only delete for specific agent")
|
|
172
|
+
] = None,
|
|
173
|
+
hard: Annotated[
|
|
174
|
+
bool, t.Option("--hard", help="Drop and recreate tables (for schema changes)")
|
|
175
|
+
] = False,
|
|
176
|
+
) -> None:
|
|
177
|
+
"""Reset (clear) conversation history.
|
|
178
|
+
|
|
179
|
+
Examples:
|
|
180
|
+
# Clear all history (with confirmation)
|
|
181
|
+
agentpool history reset
|
|
182
|
+
|
|
183
|
+
# Clear without confirmation
|
|
184
|
+
agentpool history reset --confirm
|
|
185
|
+
|
|
186
|
+
# Clear history for specific agent
|
|
187
|
+
agentpool history reset --agent myagent
|
|
188
|
+
|
|
189
|
+
# Drop and recreate tables (for schema changes)
|
|
190
|
+
agentpool history reset --hard --confirm
|
|
191
|
+
"""
|
|
192
|
+
import anyio
|
|
193
|
+
|
|
194
|
+
try:
|
|
195
|
+
# Resolve config and get provider
|
|
196
|
+
config_path = resolve_agent_config(config)
|
|
197
|
+
provider = get_history_provider(config_path)
|
|
198
|
+
|
|
199
|
+
if not confirm:
|
|
200
|
+
what = f" for {agent_name}" if agent_name else ""
|
|
201
|
+
msg = f"This will delete all history{what}. Are you sure? [y/N] "
|
|
202
|
+
if input(msg).lower() != "y":
|
|
203
|
+
print("Operation cancelled.")
|
|
204
|
+
return
|
|
205
|
+
|
|
206
|
+
async def main() -> None:
|
|
207
|
+
async with provider:
|
|
208
|
+
conv_count, msg_count = await provider.reset(agent_name=agent_name, hard=hard)
|
|
209
|
+
|
|
210
|
+
what = f" for {agent_name}" if agent_name else ""
|
|
211
|
+
print(f"Deleted {conv_count} conversations and {msg_count} messages{what}.")
|
|
212
|
+
|
|
213
|
+
anyio.run(main)
|
|
214
|
+
|
|
215
|
+
except Exception as e:
|
|
216
|
+
logger.exception("Failed to reset history")
|
|
217
|
+
raise t.Exit(1) from e
|
agentpool_cli/log.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""Lightweight logging configuration for CLI startup.
|
|
2
|
+
|
|
3
|
+
This is a simplified copy of agentpool.log to avoid importing the full
|
|
4
|
+
agentpool package (which pulls in pydantic-ai, llmling-models, etc.)
|
|
5
|
+
just for CLI help text.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
import sys
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
import structlog
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
_LOGGING_CONFIGURED = False
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def configure_logging(
|
|
21
|
+
level: str | int = "INFO",
|
|
22
|
+
*,
|
|
23
|
+
use_colors: bool | None = None,
|
|
24
|
+
) -> None:
|
|
25
|
+
"""Configure structlog and standard logging for CLI.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
level: Logging level (e.g., "INFO", "DEBUG")
|
|
29
|
+
use_colors: Whether to use colored output (auto-detected if None)
|
|
30
|
+
"""
|
|
31
|
+
global _LOGGING_CONFIGURED # noqa: PLW0603
|
|
32
|
+
|
|
33
|
+
if _LOGGING_CONFIGURED:
|
|
34
|
+
return
|
|
35
|
+
|
|
36
|
+
if isinstance(level, str):
|
|
37
|
+
level = getattr(logging, level.upper())
|
|
38
|
+
|
|
39
|
+
# Determine if we should use colors
|
|
40
|
+
colors = sys.stderr.isatty() if use_colors is None else use_colors
|
|
41
|
+
|
|
42
|
+
# Configure standard logging
|
|
43
|
+
handler = logging.StreamHandler(sys.stderr)
|
|
44
|
+
handler.setFormatter(logging.Formatter("%(message)s"))
|
|
45
|
+
logging.basicConfig(level=level, handlers=[handler], force=True)
|
|
46
|
+
|
|
47
|
+
# Configure structlog
|
|
48
|
+
processors: list[Any] = [
|
|
49
|
+
structlog.stdlib.filter_by_level,
|
|
50
|
+
structlog.stdlib.add_log_level,
|
|
51
|
+
structlog.stdlib.PositionalArgumentsFormatter(),
|
|
52
|
+
structlog.processors.TimeStamper(fmt="iso"),
|
|
53
|
+
structlog.processors.StackInfoRenderer(),
|
|
54
|
+
structlog.processors.UnicodeDecoder(),
|
|
55
|
+
structlog.dev.ConsoleRenderer(colors=colors),
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
structlog.configure(
|
|
59
|
+
processors=processors,
|
|
60
|
+
context_class=dict,
|
|
61
|
+
logger_factory=structlog.stdlib.LoggerFactory(),
|
|
62
|
+
wrapper_class=structlog.stdlib.BoundLogger,
|
|
63
|
+
cache_logger_on_first_use=True,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
_LOGGING_CONFIGURED = True
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def get_logger(name: str) -> structlog.stdlib.BoundLogger:
|
|
70
|
+
"""Get a structlog logger for the given name.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
name: The name of the logger
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
A structlog BoundLogger instance
|
|
77
|
+
"""
|
|
78
|
+
return structlog.get_logger(name) # type: ignore[no-any-return]
|
agentpool_cli/py.typed
ADDED
|
File without changes
|
agentpool_cli/run.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""Run command for agent execution."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import traceback
|
|
7
|
+
from typing import TYPE_CHECKING, Annotated, Any
|
|
8
|
+
|
|
9
|
+
import typer as t
|
|
10
|
+
|
|
11
|
+
from agentpool_cli import resolve_agent_config
|
|
12
|
+
from agentpool_cli.cli_types import DetailLevel # noqa: TC001
|
|
13
|
+
from agentpool_cli.common import verbose_opt
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from agentpool import ChatMessage
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def run_command(
|
|
21
|
+
node_name: Annotated[str, t.Argument(help="Agent / Team name to run")],
|
|
22
|
+
prompts: Annotated[list[str] | None, t.Argument(help="Additional prompts to send")] = None,
|
|
23
|
+
config_path: Annotated[
|
|
24
|
+
str | None, t.Option("-c", "--config", help="Override config path")
|
|
25
|
+
] = None,
|
|
26
|
+
show_messages: Annotated[
|
|
27
|
+
bool, t.Option("--show-messages", help="Show all messages (not just final responses)")
|
|
28
|
+
] = True,
|
|
29
|
+
detail_level: Annotated[
|
|
30
|
+
DetailLevel, t.Option("-d", "--detail", help="Output detail level")
|
|
31
|
+
] = "simple",
|
|
32
|
+
show_metadata: Annotated[bool, t.Option("--metadata", help="Show message metadata")] = False,
|
|
33
|
+
show_costs: Annotated[bool, t.Option("--costs", help="Show token usage and costs")] = False,
|
|
34
|
+
verbose: bool = verbose_opt,
|
|
35
|
+
) -> None:
|
|
36
|
+
"""Single-shot run a node (agent/team) with prompts."""
|
|
37
|
+
try:
|
|
38
|
+
# Resolve configuration path
|
|
39
|
+
try:
|
|
40
|
+
config_path = resolve_agent_config(config_path)
|
|
41
|
+
except ValueError as e:
|
|
42
|
+
error_msg = str(e)
|
|
43
|
+
raise t.BadParameter(error_msg) from e
|
|
44
|
+
|
|
45
|
+
async def run() -> None:
|
|
46
|
+
from agentpool import AgentPool
|
|
47
|
+
|
|
48
|
+
async with AgentPool(config_path) as pool:
|
|
49
|
+
|
|
50
|
+
def on_message(chat_message: ChatMessage[Any]) -> None:
|
|
51
|
+
print(
|
|
52
|
+
chat_message.format(
|
|
53
|
+
style=detail_level,
|
|
54
|
+
show_metadata=show_metadata,
|
|
55
|
+
show_costs=show_costs,
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Connect message handlers if showing all messages
|
|
60
|
+
if show_messages:
|
|
61
|
+
for node in pool.nodes.values():
|
|
62
|
+
node.message_sent.connect(on_message)
|
|
63
|
+
for prompt in prompts or []:
|
|
64
|
+
response = await pool.nodes[node_name].run(prompt)
|
|
65
|
+
|
|
66
|
+
if not show_messages:
|
|
67
|
+
print(
|
|
68
|
+
response.format(
|
|
69
|
+
style=detail_level,
|
|
70
|
+
show_metadata=show_metadata,
|
|
71
|
+
show_costs=show_costs,
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Run the async code in the sync command
|
|
76
|
+
asyncio.run(run())
|
|
77
|
+
|
|
78
|
+
except t.Exit:
|
|
79
|
+
raise
|
|
80
|
+
except Exception as e:
|
|
81
|
+
t.echo(f"Error: {e}", err=True)
|
|
82
|
+
if verbose:
|
|
83
|
+
t.echo(traceback.format_exc(), err=True)
|
|
84
|
+
raise t.Exit(1) from e
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"""Command for running agents as an ACP (Agent Client Protocol) server.
|
|
2
|
+
|
|
3
|
+
This creates an ACP-compatible JSON-RPC 2.0 server that exposes your agents
|
|
4
|
+
for bidirectional communication over stdio streams, enabling desktop application
|
|
5
|
+
integration with file system access, permission handling, and terminal support.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import asyncio
|
|
11
|
+
import os
|
|
12
|
+
from typing import Annotated
|
|
13
|
+
|
|
14
|
+
from platformdirs import user_log_path
|
|
15
|
+
import typer as t
|
|
16
|
+
|
|
17
|
+
from agentpool_cli import log, resolve_agent_config
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
logger = log.get_logger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def acp_command(
|
|
24
|
+
config: Annotated[str | None, t.Argument(help="Path to agent configuration (optional)")] = None,
|
|
25
|
+
file_access: Annotated[
|
|
26
|
+
bool,
|
|
27
|
+
t.Option(
|
|
28
|
+
"--file-access/--no-file-access",
|
|
29
|
+
help="Enable file system access for agents",
|
|
30
|
+
),
|
|
31
|
+
] = True,
|
|
32
|
+
terminal_access: Annotated[
|
|
33
|
+
bool,
|
|
34
|
+
t.Option(
|
|
35
|
+
"--terminal-access/--no-terminal-access",
|
|
36
|
+
help="Enable terminal access for agents",
|
|
37
|
+
),
|
|
38
|
+
] = True,
|
|
39
|
+
show_messages: Annotated[
|
|
40
|
+
bool, t.Option("--show-messages", help="Show message activity in logs")
|
|
41
|
+
] = False,
|
|
42
|
+
debug_messages: Annotated[
|
|
43
|
+
bool, t.Option("--debug-messages", help="Save raw JSON-RPC messages to debug file")
|
|
44
|
+
] = False,
|
|
45
|
+
debug_file: Annotated[
|
|
46
|
+
str | None,
|
|
47
|
+
t.Option(
|
|
48
|
+
"--debug-file",
|
|
49
|
+
help="File to save JSON-RPC debug messages (default: acp-debug.jsonl)",
|
|
50
|
+
),
|
|
51
|
+
] = None,
|
|
52
|
+
providers: Annotated[
|
|
53
|
+
list[str] | None,
|
|
54
|
+
t.Option(
|
|
55
|
+
"--model-provider",
|
|
56
|
+
help="Providers to search for models (can be specified multiple times)",
|
|
57
|
+
),
|
|
58
|
+
] = None,
|
|
59
|
+
debug_commands: Annotated[
|
|
60
|
+
bool,
|
|
61
|
+
t.Option(
|
|
62
|
+
"--debug-commands",
|
|
63
|
+
help="Enable debug slash commands for testing ACP notifications",
|
|
64
|
+
),
|
|
65
|
+
] = False,
|
|
66
|
+
agent: Annotated[
|
|
67
|
+
str | None,
|
|
68
|
+
t.Option(
|
|
69
|
+
"--agent",
|
|
70
|
+
help="Name of specific agent to use (defaults to first agent in config)",
|
|
71
|
+
),
|
|
72
|
+
] = None,
|
|
73
|
+
load_skills: Annotated[
|
|
74
|
+
bool,
|
|
75
|
+
t.Option(
|
|
76
|
+
"--skills/--no-skills",
|
|
77
|
+
help="Load client-side skills from .claude/skills directory",
|
|
78
|
+
),
|
|
79
|
+
] = True,
|
|
80
|
+
) -> None:
|
|
81
|
+
r"""Run agents as an ACP (Agent Client Protocol) server.
|
|
82
|
+
|
|
83
|
+
This creates an ACP-compatible JSON-RPC 2.0 server that communicates over stdio
|
|
84
|
+
streams, enabling your agents to work with desktop applications that support
|
|
85
|
+
the Agent Client Protocol.
|
|
86
|
+
|
|
87
|
+
Configuration:
|
|
88
|
+
Config file is optional. Without a config file, creates a general-purpose
|
|
89
|
+
agent with default settings. This is useful for clients/installers that
|
|
90
|
+
start agents directly without configuration support.
|
|
91
|
+
|
|
92
|
+
Agent Selection:
|
|
93
|
+
Use --agent to specify which agent to use by name. Without this option,
|
|
94
|
+
the first agent in your config is used as the default (or "agentpool"
|
|
95
|
+
if no config provided).
|
|
96
|
+
|
|
97
|
+
Agent Mode Switching:
|
|
98
|
+
If your config defines multiple agents, the IDE will show a mode selector
|
|
99
|
+
allowing users to switch between agents mid-conversation. Each agent appears
|
|
100
|
+
as a different "mode" with its own name and capabilities.
|
|
101
|
+
"""
|
|
102
|
+
from agentpool import log
|
|
103
|
+
from agentpool_server.acp_server import ACPServer
|
|
104
|
+
|
|
105
|
+
# Always log to file with rollover
|
|
106
|
+
log_dir = user_log_path("agentpool", appauthor=False)
|
|
107
|
+
log_dir.mkdir(parents=True, exist_ok=True)
|
|
108
|
+
log_file = log_dir / "acp.log"
|
|
109
|
+
log.configure_logging(force=True, log_file=str(log_file))
|
|
110
|
+
logger.info("Configured file logging with rollover", log_file=str(log_file))
|
|
111
|
+
|
|
112
|
+
if config:
|
|
113
|
+
# Use config file
|
|
114
|
+
try:
|
|
115
|
+
config_path = resolve_agent_config(config)
|
|
116
|
+
except ValueError as e:
|
|
117
|
+
msg = str(e)
|
|
118
|
+
raise t.BadParameter(msg) from e
|
|
119
|
+
|
|
120
|
+
logger.info("Starting ACP server", config_path=config_path)
|
|
121
|
+
acp_server = ACPServer.from_config(
|
|
122
|
+
config_path,
|
|
123
|
+
file_access=file_access,
|
|
124
|
+
terminal_access=terminal_access,
|
|
125
|
+
providers=providers, # type: ignore[arg-type]
|
|
126
|
+
debug_messages=debug_messages,
|
|
127
|
+
debug_file=debug_file or "acp-debug.jsonl" if debug_messages else None,
|
|
128
|
+
debug_commands=debug_commands,
|
|
129
|
+
agent=agent,
|
|
130
|
+
load_skills=load_skills,
|
|
131
|
+
)
|
|
132
|
+
else:
|
|
133
|
+
# Use default ACP assistant config
|
|
134
|
+
from agentpool.config_resources import ACP_ASSISTANT
|
|
135
|
+
|
|
136
|
+
logger.info("Starting ACP server with default configuration")
|
|
137
|
+
acp_server = ACPServer.from_config(
|
|
138
|
+
ACP_ASSISTANT,
|
|
139
|
+
file_access=file_access,
|
|
140
|
+
terminal_access=terminal_access,
|
|
141
|
+
providers=providers, # type: ignore[arg-type]
|
|
142
|
+
debug_messages=debug_messages,
|
|
143
|
+
debug_file=debug_file or "acp-debug.jsonl" if debug_messages else None,
|
|
144
|
+
debug_commands=debug_commands,
|
|
145
|
+
agent=agent,
|
|
146
|
+
load_skills=load_skills,
|
|
147
|
+
)
|
|
148
|
+
# Configure agent capabilities
|
|
149
|
+
agent_count = len(acp_server.pool.all_agents)
|
|
150
|
+
if agent_count == 0:
|
|
151
|
+
logger.error("No agents found in configuration")
|
|
152
|
+
raise t.Exit(1)
|
|
153
|
+
logger.info("Configured agents for ACP protocol", count=agent_count)
|
|
154
|
+
if show_messages:
|
|
155
|
+
logger.info("Message activity logging enabled")
|
|
156
|
+
if debug_messages:
|
|
157
|
+
debug_path = debug_file or "acp-debug.jsonl"
|
|
158
|
+
logger.info("Raw JSON-RPC message debugging enabled", path=debug_path)
|
|
159
|
+
if debug_commands:
|
|
160
|
+
logger.info("Debug slash commands enabled")
|
|
161
|
+
logger.info("Server PID", pid=os.getpid())
|
|
162
|
+
|
|
163
|
+
async def run_acp_server() -> None:
|
|
164
|
+
try:
|
|
165
|
+
async with acp_server:
|
|
166
|
+
await acp_server.start()
|
|
167
|
+
except KeyboardInterrupt:
|
|
168
|
+
logger.info("ACP server shutdown requested")
|
|
169
|
+
except Exception as e:
|
|
170
|
+
logger.exception("ACP server error")
|
|
171
|
+
raise t.Exit(1) from e
|
|
172
|
+
|
|
173
|
+
asyncio.run(run_acp_server())
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
if __name__ == "__main__":
|
|
177
|
+
t.run(acp_command)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Command for running agents as a completions API server."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from typing import TYPE_CHECKING, Annotated, Any
|
|
7
|
+
|
|
8
|
+
import typer as t
|
|
9
|
+
|
|
10
|
+
from agentpool_cli import resolve_agent_config
|
|
11
|
+
from agentpool_cli.log import get_logger
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from agentpool import ChatMessage
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
logger = get_logger(__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def api_command(
|
|
22
|
+
ctx: t.Context,
|
|
23
|
+
config: Annotated[str | None, t.Argument(help="Path to agent configuration")] = None,
|
|
24
|
+
host: Annotated[str, t.Option(help="Host to bind server to")] = "localhost",
|
|
25
|
+
port: Annotated[int, t.Option(help="Port to listen on")] = 8000,
|
|
26
|
+
cors: Annotated[bool, t.Option(help="Enable CORS")] = True,
|
|
27
|
+
show_messages: Annotated[
|
|
28
|
+
bool, t.Option("--show-messages", help="Show message activity")
|
|
29
|
+
] = False,
|
|
30
|
+
docs: Annotated[bool, t.Option(help="Enable API documentation")] = True,
|
|
31
|
+
) -> None:
|
|
32
|
+
"""Run agents as a completions API server.
|
|
33
|
+
|
|
34
|
+
This creates an OpenAI-compatible API server that makes your agents available
|
|
35
|
+
through a standard completions API interface.
|
|
36
|
+
"""
|
|
37
|
+
import uvicorn
|
|
38
|
+
|
|
39
|
+
from agentpool import AgentPool, AgentsManifest
|
|
40
|
+
from agentpool_server.openai_api_server.server import OpenAIAPIServer
|
|
41
|
+
|
|
42
|
+
logger.info("Server PID", pid=os.getpid())
|
|
43
|
+
|
|
44
|
+
def on_message(message: ChatMessage[Any]) -> None:
|
|
45
|
+
print(message.format(style="simple"))
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
config_path = resolve_agent_config(config)
|
|
49
|
+
except ValueError as e:
|
|
50
|
+
msg = str(e)
|
|
51
|
+
raise t.BadParameter(msg) from e
|
|
52
|
+
manifest = AgentsManifest.from_file(config_path)
|
|
53
|
+
pool = AgentPool(manifest)
|
|
54
|
+
|
|
55
|
+
if show_messages:
|
|
56
|
+
for agent in pool.agents.values():
|
|
57
|
+
agent.message_sent.connect(on_message)
|
|
58
|
+
|
|
59
|
+
server = OpenAIAPIServer(pool, cors=cors, docs=docs)
|
|
60
|
+
|
|
61
|
+
# Get log level from the global context
|
|
62
|
+
log_level = ctx.obj.get("log_level", "info") if ctx.obj else "info"
|
|
63
|
+
uvicorn.run(server.app, host=host, port=port, log_level=log_level.lower())
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
if __name__ == "__main__":
|
|
67
|
+
import typer
|
|
68
|
+
|
|
69
|
+
typer.run(api_command)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Command for running agents as an MCP server."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import os
|
|
7
|
+
from typing import TYPE_CHECKING, Annotated, Any, Literal
|
|
8
|
+
|
|
9
|
+
import typer as t
|
|
10
|
+
|
|
11
|
+
from agentpool_cli import log
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Duplicated from agentpool_config.pool_server to avoid heavy imports at CLI startup
|
|
15
|
+
TransportType = Literal["stdio", "sse", "streamable-http"]
|
|
16
|
+
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
from agentpool import ChatMessage
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
logger = log.get_logger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def serve_command(
|
|
25
|
+
config: Annotated[str, t.Argument(help="Path to agent configuration")],
|
|
26
|
+
transport: Annotated[TransportType, t.Option(help="Transport type")] = "stdio",
|
|
27
|
+
host: Annotated[
|
|
28
|
+
str, t.Option(help="Host to bind server to (sse/streamable-http only)")
|
|
29
|
+
] = "localhost",
|
|
30
|
+
port: Annotated[int, t.Option(help="Port to listen on (sse/streamable-http only)")] = 3001,
|
|
31
|
+
zed_mode: Annotated[bool, t.Option(help="Enable Zed editor compatibility")] = False,
|
|
32
|
+
show_messages: Annotated[
|
|
33
|
+
bool, t.Option("--show-messages", help="Show message activity")
|
|
34
|
+
] = False,
|
|
35
|
+
) -> None:
|
|
36
|
+
"""Run agents as an MCP server.
|
|
37
|
+
|
|
38
|
+
This makes agents available as tools to other applications, regardless of
|
|
39
|
+
whether pool_server is configured in the manifest.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
def on_message(message: ChatMessage[Any]) -> None:
|
|
43
|
+
print(message.format(style="simple"))
|
|
44
|
+
|
|
45
|
+
async def run_server() -> None:
|
|
46
|
+
|
|
47
|
+
from agentpool import AgentPool, AgentsManifest
|
|
48
|
+
from agentpool_config.pool_server import MCPPoolServerConfig
|
|
49
|
+
from agentpool_server.mcp_server.server import MCPServer
|
|
50
|
+
|
|
51
|
+
logger.info("Server PID", pid=os.getpid())
|
|
52
|
+
# Load manifest and create pool (without server config)
|
|
53
|
+
manifest = AgentsManifest.from_file(config)
|
|
54
|
+
pool = AgentPool(manifest)
|
|
55
|
+
# Create server config and server externally
|
|
56
|
+
server_config = MCPPoolServerConfig(
|
|
57
|
+
enabled=True,
|
|
58
|
+
transport=transport,
|
|
59
|
+
host=host,
|
|
60
|
+
port=port,
|
|
61
|
+
zed_mode=zed_mode,
|
|
62
|
+
)
|
|
63
|
+
server = MCPServer(pool, server_config)
|
|
64
|
+
async with pool, server:
|
|
65
|
+
if show_messages:
|
|
66
|
+
for agent in pool.agents.values():
|
|
67
|
+
agent.message_sent.connect(on_message)
|
|
68
|
+
|
|
69
|
+
try:
|
|
70
|
+
await server.start() # Blocks until server stops
|
|
71
|
+
except KeyboardInterrupt:
|
|
72
|
+
logger.info("Server shutdown requested")
|
|
73
|
+
|
|
74
|
+
asyncio.run(run_server())
|