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
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"""ACP Session Manager - delegates to pool's SessionManager."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Self
|
|
7
|
+
|
|
8
|
+
from acp.schema import ClientCapabilities
|
|
9
|
+
from agentpool.log import get_logger
|
|
10
|
+
from agentpool.sessions import SessionData
|
|
11
|
+
from agentpool_server.acp_server.session import ACPSession
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from collections.abc import Sequence
|
|
16
|
+
from types import TracebackType
|
|
17
|
+
|
|
18
|
+
from acp import Client
|
|
19
|
+
from acp.schema import Implementation, McpServer
|
|
20
|
+
from agentpool import AgentPool
|
|
21
|
+
from agentpool.sessions import SessionManager
|
|
22
|
+
from agentpool_server.acp_server.acp_agent import AgentPoolACPAgent
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
logger = get_logger(__name__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ACPSessionManager:
|
|
29
|
+
"""Manages ACP sessions, delegating persistence to pool's SessionManager.
|
|
30
|
+
|
|
31
|
+
This is a thin coordinator that:
|
|
32
|
+
- Creates and tracks active ACP sessions
|
|
33
|
+
- Delegates session persistence to pool.sessions (SessionManager)
|
|
34
|
+
- Handles ACP-specific session initialization
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def __init__(self, pool: AgentPool[Any]) -> None:
|
|
38
|
+
"""Initialize ACP session manager.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
pool: Agent pool containing SessionManager for persistence
|
|
42
|
+
"""
|
|
43
|
+
self._pool = pool
|
|
44
|
+
self._active: dict[str, ACPSession] = {}
|
|
45
|
+
self._lock = asyncio.Lock()
|
|
46
|
+
self._command_update_task: asyncio.Task[None] | None = None
|
|
47
|
+
logger.info("Initialized ACP session manager")
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def session_manager(self) -> SessionManager:
|
|
51
|
+
"""Get the pool's session manager for persistence."""
|
|
52
|
+
return self._pool.sessions
|
|
53
|
+
|
|
54
|
+
async def create_session(
|
|
55
|
+
self,
|
|
56
|
+
default_agent_name: str,
|
|
57
|
+
cwd: str,
|
|
58
|
+
client: Client,
|
|
59
|
+
acp_agent: AgentPoolACPAgent,
|
|
60
|
+
mcp_servers: Sequence[McpServer] | None = None,
|
|
61
|
+
session_id: str | None = None,
|
|
62
|
+
client_capabilities: ClientCapabilities | None = None,
|
|
63
|
+
client_info: Implementation | None = None,
|
|
64
|
+
) -> str:
|
|
65
|
+
"""Create a new ACP session.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
default_agent_name: Name of the default agent to start with
|
|
69
|
+
cwd: Working directory for the session
|
|
70
|
+
client: ACP client connection
|
|
71
|
+
acp_agent: ACP agent instance
|
|
72
|
+
mcp_servers: Optional MCP server configurations
|
|
73
|
+
session_id: Optional specific session ID (generated if None)
|
|
74
|
+
client_capabilities: Client capabilities for tool registration
|
|
75
|
+
client_info: Client implementation info (name, version)
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
Session ID for the created session
|
|
79
|
+
"""
|
|
80
|
+
async with self._lock:
|
|
81
|
+
# Generate session ID if not provided
|
|
82
|
+
if session_id is None:
|
|
83
|
+
session_id = self.session_manager.generate_session_id()
|
|
84
|
+
|
|
85
|
+
# Check for existing session
|
|
86
|
+
if session_id in self._active:
|
|
87
|
+
logger.warning("Session ID already exists", session_id=session_id)
|
|
88
|
+
msg = f"Session {session_id} already exists"
|
|
89
|
+
raise ValueError(msg)
|
|
90
|
+
|
|
91
|
+
# Create and persist session data via pool's SessionManager
|
|
92
|
+
data = SessionData(
|
|
93
|
+
session_id=session_id,
|
|
94
|
+
agent_name=default_agent_name,
|
|
95
|
+
conversation_id=f"conv_{session_id}",
|
|
96
|
+
cwd=cwd,
|
|
97
|
+
metadata={
|
|
98
|
+
"protocol": "acp",
|
|
99
|
+
"mcp_server_count": len(mcp_servers) if mcp_servers else 0,
|
|
100
|
+
},
|
|
101
|
+
)
|
|
102
|
+
await self.session_manager.save(data)
|
|
103
|
+
|
|
104
|
+
# Create the ACP-specific runtime session
|
|
105
|
+
session = ACPSession(
|
|
106
|
+
session_id=session_id,
|
|
107
|
+
agent_pool=self._pool,
|
|
108
|
+
current_agent_name=default_agent_name,
|
|
109
|
+
cwd=cwd,
|
|
110
|
+
client=client,
|
|
111
|
+
mcp_servers=mcp_servers,
|
|
112
|
+
acp_agent=acp_agent,
|
|
113
|
+
client_capabilities=client_capabilities or ClientCapabilities(),
|
|
114
|
+
client_info=client_info,
|
|
115
|
+
manager=self,
|
|
116
|
+
)
|
|
117
|
+
session.register_update_callback(self._on_commands_updated)
|
|
118
|
+
|
|
119
|
+
# Initialize async resources
|
|
120
|
+
await session.initialize()
|
|
121
|
+
|
|
122
|
+
# Initialize MCP servers if any are provided
|
|
123
|
+
await session.initialize_mcp_servers()
|
|
124
|
+
|
|
125
|
+
self._active[session_id] = session
|
|
126
|
+
logger.info("Created ACP session", session_id=session_id, agent=default_agent_name)
|
|
127
|
+
return session_id
|
|
128
|
+
|
|
129
|
+
def get_session(self, session_id: str) -> ACPSession | None:
|
|
130
|
+
"""Get an active session by ID.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
session_id: Session identifier
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
ACPSession instance or None if not found
|
|
137
|
+
"""
|
|
138
|
+
return self._active.get(session_id)
|
|
139
|
+
|
|
140
|
+
async def resume_session(
|
|
141
|
+
self,
|
|
142
|
+
session_id: str,
|
|
143
|
+
client: Client,
|
|
144
|
+
acp_agent: AgentPoolACPAgent,
|
|
145
|
+
client_capabilities: ClientCapabilities | None = None,
|
|
146
|
+
client_info: Implementation | None = None,
|
|
147
|
+
) -> ACPSession | None:
|
|
148
|
+
"""Resume a session from storage.
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
session_id: Session identifier
|
|
152
|
+
client: ACP client connection
|
|
153
|
+
acp_agent: ACP agent instance
|
|
154
|
+
client_capabilities: Client capabilities
|
|
155
|
+
client_info: Client implementation info (name, version)
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
Resumed ACPSession if found, None otherwise
|
|
159
|
+
"""
|
|
160
|
+
async with self._lock:
|
|
161
|
+
# Check if already active
|
|
162
|
+
if session_id in self._active:
|
|
163
|
+
return self._active[session_id]
|
|
164
|
+
|
|
165
|
+
# Try to load from pool's session store
|
|
166
|
+
data = await self.session_manager.store.load(session_id)
|
|
167
|
+
if data is None:
|
|
168
|
+
logger.warning("Session not found in store", session_id=session_id)
|
|
169
|
+
return None
|
|
170
|
+
|
|
171
|
+
# Validate agent still exists
|
|
172
|
+
if data.agent_name not in self._pool.all_agents:
|
|
173
|
+
logger.warning(
|
|
174
|
+
"Session agent no longer exists",
|
|
175
|
+
session_id=session_id,
|
|
176
|
+
agent=data.agent_name,
|
|
177
|
+
)
|
|
178
|
+
return None
|
|
179
|
+
|
|
180
|
+
# Reconstruct ACP session
|
|
181
|
+
session = ACPSession(
|
|
182
|
+
session_id=session_id,
|
|
183
|
+
agent_pool=self._pool,
|
|
184
|
+
current_agent_name=data.agent_name,
|
|
185
|
+
cwd=data.cwd or "",
|
|
186
|
+
client=client,
|
|
187
|
+
mcp_servers=None, # MCP servers would need to be re-provided
|
|
188
|
+
acp_agent=acp_agent,
|
|
189
|
+
client_capabilities=client_capabilities or ClientCapabilities(),
|
|
190
|
+
client_info=client_info,
|
|
191
|
+
manager=self,
|
|
192
|
+
)
|
|
193
|
+
session.register_update_callback(self._on_commands_updated)
|
|
194
|
+
|
|
195
|
+
# Initialize async resources
|
|
196
|
+
await session.initialize()
|
|
197
|
+
|
|
198
|
+
self._active[session_id] = session
|
|
199
|
+
logger.info("Resumed ACP session", session_id=session_id)
|
|
200
|
+
return session
|
|
201
|
+
|
|
202
|
+
async def close_session(self, session_id: str, *, delete: bool = False) -> None:
|
|
203
|
+
"""Close and optionally delete a session.
|
|
204
|
+
|
|
205
|
+
Args:
|
|
206
|
+
session_id: Session identifier to close
|
|
207
|
+
delete: Whether to also delete from persistent storage
|
|
208
|
+
"""
|
|
209
|
+
async with self._lock:
|
|
210
|
+
session = self._active.pop(session_id, None)
|
|
211
|
+
|
|
212
|
+
if session:
|
|
213
|
+
await session.close()
|
|
214
|
+
logger.info("Closed ACP session", session_id=session_id)
|
|
215
|
+
|
|
216
|
+
if delete:
|
|
217
|
+
await self.session_manager.store.delete(session_id)
|
|
218
|
+
logger.info("Deleted session from store", session_id=session_id)
|
|
219
|
+
|
|
220
|
+
async def update_session_agent(self, session_id: str, agent_name: str) -> None:
|
|
221
|
+
"""Update the agent for a session and persist.
|
|
222
|
+
|
|
223
|
+
Args:
|
|
224
|
+
session_id: Session identifier
|
|
225
|
+
agent_name: New agent name
|
|
226
|
+
"""
|
|
227
|
+
session = self._active.get(session_id)
|
|
228
|
+
if not session:
|
|
229
|
+
return
|
|
230
|
+
|
|
231
|
+
# Load, update, and save session data
|
|
232
|
+
data = await self.session_manager.store.load(session_id)
|
|
233
|
+
if data:
|
|
234
|
+
updated = data.with_agent(agent_name)
|
|
235
|
+
await self.session_manager.save(updated)
|
|
236
|
+
|
|
237
|
+
async def list_sessions(self, *, active_only: bool = False) -> list[str]:
|
|
238
|
+
"""List session IDs.
|
|
239
|
+
|
|
240
|
+
Args:
|
|
241
|
+
active_only: Only return currently active sessions
|
|
242
|
+
|
|
243
|
+
Returns:
|
|
244
|
+
List of session IDs
|
|
245
|
+
"""
|
|
246
|
+
if active_only:
|
|
247
|
+
return list(self._active.keys())
|
|
248
|
+
|
|
249
|
+
return await self.session_manager.store.list_sessions()
|
|
250
|
+
|
|
251
|
+
async def close_all_sessions(self) -> int:
|
|
252
|
+
"""Close all active sessions.
|
|
253
|
+
|
|
254
|
+
This is used during pool hot-switching to cleanly shut down
|
|
255
|
+
all sessions before swapping the pool.
|
|
256
|
+
|
|
257
|
+
Returns:
|
|
258
|
+
Number of sessions that were closed
|
|
259
|
+
"""
|
|
260
|
+
async with self._lock:
|
|
261
|
+
sessions = list(self._active.values())
|
|
262
|
+
self._active.clear()
|
|
263
|
+
|
|
264
|
+
closed_count = 0
|
|
265
|
+
for session in sessions:
|
|
266
|
+
try:
|
|
267
|
+
await session.close()
|
|
268
|
+
closed_count += 1
|
|
269
|
+
except Exception:
|
|
270
|
+
logger.exception(
|
|
271
|
+
"Error closing session during pool swap", session=session.session_id
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
logger.info("Closed all sessions for pool swap", count=closed_count)
|
|
275
|
+
return closed_count
|
|
276
|
+
|
|
277
|
+
async def __aenter__(self) -> Self:
|
|
278
|
+
"""Async context manager entry."""
|
|
279
|
+
return self
|
|
280
|
+
|
|
281
|
+
async def __aexit__(
|
|
282
|
+
self,
|
|
283
|
+
exc_type: type[BaseException] | None,
|
|
284
|
+
exc_val: BaseException | None,
|
|
285
|
+
exc_tb: TracebackType | None,
|
|
286
|
+
) -> None:
|
|
287
|
+
"""Async context manager exit - close all active sessions."""
|
|
288
|
+
async with self._lock:
|
|
289
|
+
sessions = list(self._active.values())
|
|
290
|
+
self._active.clear()
|
|
291
|
+
|
|
292
|
+
for session in sessions:
|
|
293
|
+
try:
|
|
294
|
+
await session.close()
|
|
295
|
+
except Exception:
|
|
296
|
+
logger.exception("Error closing session", session=session.session_id)
|
|
297
|
+
|
|
298
|
+
logger.info("Closed all %d ACP sessions", len(sessions))
|
|
299
|
+
|
|
300
|
+
def _on_commands_updated(self) -> None:
|
|
301
|
+
"""Handle command updates by notifying all active sessions."""
|
|
302
|
+
task = asyncio.create_task(self._update_all_sessions_commands())
|
|
303
|
+
self._command_update_task = task
|
|
304
|
+
|
|
305
|
+
async def _update_all_sessions_commands(self) -> None:
|
|
306
|
+
"""Update available commands for all active sessions."""
|
|
307
|
+
async with self._lock:
|
|
308
|
+
for session in self._active.values():
|
|
309
|
+
try:
|
|
310
|
+
await session.send_available_commands_update()
|
|
311
|
+
except Exception:
|
|
312
|
+
msg = "Failed to update commands"
|
|
313
|
+
logger.exception(msg, session_id=session.session_id)
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"""Syntax highlighting utilities for file content display."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
dot_file_map = {
|
|
13
|
+
".bashrc": "bash",
|
|
14
|
+
".bash_profile": "bash",
|
|
15
|
+
".bash_logout": "bash",
|
|
16
|
+
".zshrc": "bash",
|
|
17
|
+
".zsh_profile": "bash",
|
|
18
|
+
".profile": "bash",
|
|
19
|
+
".vimrc": "vim",
|
|
20
|
+
".gvimrc": "vim",
|
|
21
|
+
".tmux.conf": "tmux",
|
|
22
|
+
".gitignore": "gitignore",
|
|
23
|
+
".gitconfig": "gitconfig",
|
|
24
|
+
".editorconfig": "editorconfig",
|
|
25
|
+
".eslintrc": "json",
|
|
26
|
+
".prettierrc": "json",
|
|
27
|
+
".babelrc": "json",
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
lang_map = {
|
|
31
|
+
# Python
|
|
32
|
+
".py": "python",
|
|
33
|
+
".pyx": "python",
|
|
34
|
+
".pyi": "python",
|
|
35
|
+
# JavaScript/TypeScript
|
|
36
|
+
".js": "javascript",
|
|
37
|
+
".mjs": "javascript",
|
|
38
|
+
".jsx": "javascript",
|
|
39
|
+
".ts": "typescript",
|
|
40
|
+
".tsx": "typescript",
|
|
41
|
+
".mts": "typescript",
|
|
42
|
+
# JVM Languages
|
|
43
|
+
".java": "java",
|
|
44
|
+
".kt": "kotlin",
|
|
45
|
+
".scala": "scala",
|
|
46
|
+
".groovy": "groovy",
|
|
47
|
+
# C/C++
|
|
48
|
+
".c": "c",
|
|
49
|
+
".h": "c",
|
|
50
|
+
".cpp": "cpp",
|
|
51
|
+
".cc": "cpp",
|
|
52
|
+
".cxx": "cpp",
|
|
53
|
+
".hpp": "cpp",
|
|
54
|
+
".hxx": "cpp",
|
|
55
|
+
# Rust
|
|
56
|
+
".rs": "rust",
|
|
57
|
+
# Go
|
|
58
|
+
".go": "go",
|
|
59
|
+
# Web
|
|
60
|
+
".html": "html",
|
|
61
|
+
".htm": "html",
|
|
62
|
+
".xml": "xml",
|
|
63
|
+
".xhtml": "html",
|
|
64
|
+
".css": "css",
|
|
65
|
+
".scss": "scss",
|
|
66
|
+
".sass": "sass",
|
|
67
|
+
".less": "less",
|
|
68
|
+
# Data formats
|
|
69
|
+
".json": "json",
|
|
70
|
+
".yaml": "yaml",
|
|
71
|
+
".yml": "yaml",
|
|
72
|
+
".toml": "toml",
|
|
73
|
+
".csv": "csv",
|
|
74
|
+
# Shell/Scripts
|
|
75
|
+
".sh": "bash",
|
|
76
|
+
".bash": "bash",
|
|
77
|
+
".zsh": "bash",
|
|
78
|
+
".fish": "fish",
|
|
79
|
+
".ps1": "powershell",
|
|
80
|
+
".psm1": "powershell",
|
|
81
|
+
".bat": "batch",
|
|
82
|
+
".cmd": "batch",
|
|
83
|
+
# Other languages
|
|
84
|
+
".rb": "ruby",
|
|
85
|
+
".php": "php",
|
|
86
|
+
".sql": "sql",
|
|
87
|
+
".r": "r",
|
|
88
|
+
".swift": "swift",
|
|
89
|
+
".dart": "dart",
|
|
90
|
+
".lua": "lua",
|
|
91
|
+
".pl": "perl",
|
|
92
|
+
".pm": "perl",
|
|
93
|
+
".vim": "vim",
|
|
94
|
+
".tex": "latex",
|
|
95
|
+
".cls": "latex",
|
|
96
|
+
".sty": "latex",
|
|
97
|
+
# Config/Other
|
|
98
|
+
".ini": "ini",
|
|
99
|
+
".cfg": "ini",
|
|
100
|
+
".conf": "conf",
|
|
101
|
+
".log": "log",
|
|
102
|
+
".md": "markdown",
|
|
103
|
+
".markdown": "markdown",
|
|
104
|
+
".mdown": "markdown",
|
|
105
|
+
".mkd": "markdown",
|
|
106
|
+
".rst": "rst",
|
|
107
|
+
".txt": "text",
|
|
108
|
+
# Docker
|
|
109
|
+
".dockerfile": "dockerfile",
|
|
110
|
+
# Makefiles
|
|
111
|
+
".mk": "makefile",
|
|
112
|
+
# Nginx
|
|
113
|
+
".nginx": "nginx",
|
|
114
|
+
# Apache
|
|
115
|
+
".htaccess": "apache",
|
|
116
|
+
# Git
|
|
117
|
+
".gitignore": "gitignore",
|
|
118
|
+
".gitconfig": "gitconfig",
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def get_language_from_path(path: str | Path) -> str: # noqa: PLR0911
|
|
123
|
+
"""Get syntax highlighting language identifier from file path.
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
path: File path to analyze
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
Language identifier for syntax highlighting, or empty string if unknown
|
|
130
|
+
|
|
131
|
+
Examples:
|
|
132
|
+
>>> get_language_from_path("src/main.py")
|
|
133
|
+
'python'
|
|
134
|
+
>>> get_language_from_path("config.json")
|
|
135
|
+
'json'
|
|
136
|
+
>>> get_language_from_path("Dockerfile")
|
|
137
|
+
'dockerfile'
|
|
138
|
+
>>> get_language_from_path("unknown.xyz")
|
|
139
|
+
''
|
|
140
|
+
"""
|
|
141
|
+
path_str = str(path)
|
|
142
|
+
_, ext = os.path.splitext(path_str.lower()) # noqa: PTH122
|
|
143
|
+
|
|
144
|
+
# Special cases for files without extensions or specific names
|
|
145
|
+
filename = os.path.basename(path_str.lower()) # noqa: PTH119
|
|
146
|
+
|
|
147
|
+
# Docker files
|
|
148
|
+
if filename in ("dockerfile", "dockerfile.dev", "dockerfile.prod"):
|
|
149
|
+
return "dockerfile"
|
|
150
|
+
|
|
151
|
+
# Build files
|
|
152
|
+
if filename in ("makefile", "rakefile", "justfile"):
|
|
153
|
+
return "makefile"
|
|
154
|
+
|
|
155
|
+
if filename in (".rules", ".cursorrules"):
|
|
156
|
+
return "markdown"
|
|
157
|
+
|
|
158
|
+
# Config files starting with dot
|
|
159
|
+
|
|
160
|
+
if filename in dot_file_map:
|
|
161
|
+
return dot_file_map[filename]
|
|
162
|
+
|
|
163
|
+
# License files
|
|
164
|
+
if filename in ("license", "licence", "copying", "contributing"):
|
|
165
|
+
return "text"
|
|
166
|
+
|
|
167
|
+
# README files
|
|
168
|
+
if filename.startswith("readme") and "." not in filename:
|
|
169
|
+
return "text"
|
|
170
|
+
|
|
171
|
+
# Package files
|
|
172
|
+
if filename == "yarn.lock":
|
|
173
|
+
return "yaml"
|
|
174
|
+
|
|
175
|
+
return lang_map.get(ext, "")
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def format_code_block(content: str, language: str = "") -> str:
|
|
179
|
+
r"""Format content as a markdown code block with optional language.
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
content: The code/text content
|
|
183
|
+
language: Optional language identifier for syntax highlighting
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
Formatted markdown code block
|
|
187
|
+
|
|
188
|
+
Examples:
|
|
189
|
+
>>> format_code_block('print("hello")', 'python')
|
|
190
|
+
'```python\\nprint("hello")\\n```'
|
|
191
|
+
>>> format_code_block('some text')
|
|
192
|
+
'```\\nsome text\\n```'
|
|
193
|
+
"""
|
|
194
|
+
return f"```{language}\n{content}\n```"
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def format_file_content(content: str, file_path: str | Path) -> str:
|
|
198
|
+
r"""Format file content as a syntax-highlighted code block.
|
|
199
|
+
|
|
200
|
+
Args:
|
|
201
|
+
content: The file content
|
|
202
|
+
file_path: Path to the file (used to determine language)
|
|
203
|
+
|
|
204
|
+
Returns:
|
|
205
|
+
Formatted markdown code block with appropriate syntax highlighting
|
|
206
|
+
|
|
207
|
+
Examples:
|
|
208
|
+
>>> format_file_content('def hello(): pass', 'main.py')
|
|
209
|
+
'```python\\ndef hello(): pass\\n```'
|
|
210
|
+
"""
|
|
211
|
+
language = get_language_from_path(file_path)
|
|
212
|
+
return format_code_block(content, language)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def format_zed_code_block(
|
|
216
|
+
content: str,
|
|
217
|
+
file_path: str | Path,
|
|
218
|
+
start_line: int | None = None,
|
|
219
|
+
end_line: int | None = None,
|
|
220
|
+
) -> str:
|
|
221
|
+
r"""Format content as a Zed-compatible code block with path and optional line numbers.
|
|
222
|
+
|
|
223
|
+
Args:
|
|
224
|
+
content: The code/text content
|
|
225
|
+
file_path: Path to the file (used in code block header)
|
|
226
|
+
start_line: Optional starting line number (1-based)
|
|
227
|
+
end_line: Optional ending line number (1-based)
|
|
228
|
+
|
|
229
|
+
Returns:
|
|
230
|
+
Formatted Zed-compatible code block
|
|
231
|
+
|
|
232
|
+
Examples:
|
|
233
|
+
>>> format_zed_code_block('def hello(): pass', 'src/main.py')
|
|
234
|
+
'```src/main.py\\ndef hello(): pass\\n```'
|
|
235
|
+
>>> format_zed_code_block('def hello(): pass', 'src/main.py', 10)
|
|
236
|
+
'```src/main.py#L10\\ndef hello(): pass\\n```'
|
|
237
|
+
>>> format_zed_code_block('def hello(): pass', 'src/main.py', 10, 15)
|
|
238
|
+
'```src/main.py#L10-15\\ndef hello(): pass\\n```'
|
|
239
|
+
"""
|
|
240
|
+
path_str = str(file_path)
|
|
241
|
+
|
|
242
|
+
# Build line number suffix if provided
|
|
243
|
+
line_suffix = ""
|
|
244
|
+
if start_line is not None:
|
|
245
|
+
if end_line is not None and end_line != start_line:
|
|
246
|
+
line_suffix = f"#L{start_line}-{end_line}"
|
|
247
|
+
else:
|
|
248
|
+
line_suffix = f"#L{start_line}"
|
|
249
|
+
|
|
250
|
+
return f"```{path_str}{line_suffix}\n{content}\n```"
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
File System Operations
|
|
2
|
+
|
|
3
|
+
### `copy_path`
|
|
4
|
+
Copies a file or directory in the project
|
|
5
|
+
- **source_path** (required): The source path of the file or directory to copy
|
|
6
|
+
- **destination_path** (required): The destination path where the file or directory should be copied to
|
|
7
|
+
|
|
8
|
+
### `create_directory`
|
|
9
|
+
Creates a new directory at the specified path
|
|
10
|
+
- **path** (required): The path of the new directory
|
|
11
|
+
|
|
12
|
+
### `delete_path`
|
|
13
|
+
Deletes the file or directory at the specified path
|
|
14
|
+
- **path** (required): The path of the file or directory to delete
|
|
15
|
+
|
|
16
|
+
### `move_path`
|
|
17
|
+
Moves or renames a file or directory
|
|
18
|
+
- **source_path** (required): The source path of the file or directory to move/rename
|
|
19
|
+
- **destination_path** (required): The destination path where the file or directory should be moved/renamed to
|
|
20
|
+
|
|
21
|
+
## File Content Operations
|
|
22
|
+
|
|
23
|
+
### `edit_file`
|
|
24
|
+
Creates a new file or edits an existing file
|
|
25
|
+
- **display_description** (required): A one-line, user-friendly markdown description of the edit
|
|
26
|
+
- **path** (required): The full path of the file to create or modify
|
|
27
|
+
- **mode** (required): The mode of operation - 'edit', 'create', or 'overwrite'
|
|
28
|
+
|
|
29
|
+
### `read_file`
|
|
30
|
+
Reads the content of a file
|
|
31
|
+
- **path** (required): The relative path of the file to read
|
|
32
|
+
- **start_line** (optional): Line number to start reading on (1-based index)
|
|
33
|
+
- **end_line** (optional): Line number to end reading on (1-based index, inclusive)
|
|
34
|
+
|
|
35
|
+
## Search and Discovery
|
|
36
|
+
|
|
37
|
+
### `find_path`
|
|
38
|
+
Fast file path pattern matching with glob patterns
|
|
39
|
+
- **glob** (required): The glob pattern to match against every path in the project
|
|
40
|
+
- **offset** (optional): Starting position for paginated results (default: 0)
|
|
41
|
+
|
|
42
|
+
### `grep`
|
|
43
|
+
Searches file contents with regular expressions
|
|
44
|
+
- **regex** (required): A regex pattern to search for in the project
|
|
45
|
+
- **include_pattern** (optional): A glob pattern for the paths of files to include in the search
|
|
46
|
+
- **case_sensitive** (optional): Whether the regex is case-sensitive (default: false)
|
|
47
|
+
- **offset** (optional): Starting position for paginated results (default: 0)
|
|
48
|
+
|
|
49
|
+
### `list_directory`
|
|
50
|
+
Lists files and directories in a given path
|
|
51
|
+
- **path** (required): The fully-qualified path of the directory to list
|
|
52
|
+
|
|
53
|
+
## Code Quality and Diagnostics
|
|
54
|
+
|
|
55
|
+
### `diagnostics`
|
|
56
|
+
Get errors and warnings for the project or a specific file
|
|
57
|
+
- **path** (optional): The path to get diagnostics for. If not provided, returns a project-wide summary
|
|
58
|
+
|
|
59
|
+
## External Resources
|
|
60
|
+
|
|
61
|
+
### `fetch`
|
|
62
|
+
Fetches a URL and returns the content as Markdown
|
|
63
|
+
- **url** (required): The URL to fetch
|
|
64
|
+
|
|
65
|
+
### `resolve-library-id`
|
|
66
|
+
Resolves a package/product name to a Context7-compatible library ID
|
|
67
|
+
- **libraryName** (required): Library name to search for and retrieve a Context7-compatible library ID
|
|
68
|
+
|
|
69
|
+
### `get-library-docs`
|
|
70
|
+
Fetches up-to-date documentation for a library
|
|
71
|
+
- **context7CompatibleLibraryID** (required): Exact Context7-compatible library ID
|
|
72
|
+
- **topic** (optional): Topic to focus documentation on
|
|
73
|
+
- **tokens** (optional): Maximum number of tokens of documentation to retrieve (default: 5000)
|
|
74
|
+
|
|
75
|
+
## System Operations
|
|
76
|
+
|
|
77
|
+
### `terminal`
|
|
78
|
+
Executes a shell one-liner and returns the combined output
|
|
79
|
+
- **command** (required): The one-liner command to execute
|
|
80
|
+
- **cd** (required): Working directory for the command (must be one of the root directories)
|
|
81
|
+
|
|
82
|
+
### `now`
|
|
83
|
+
Returns the current datetime in RFC 3339 format
|
|
84
|
+
- **timezone** (required): The timezone to use - 'utc' or 'local'
|
|
85
|
+
|
|
86
|
+
## Analysis and Planning
|
|
87
|
+
|
|
88
|
+
### `thinking`
|
|
89
|
+
A tool for thinking through problems, brainstorming ideas, or planning without executing actions
|
|
90
|
+
- **content** (required): Content to think about or a problem to solve
|