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,86 @@
|
|
|
1
|
+
"""Worker configuration models."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Annotated, Literal
|
|
6
|
+
|
|
7
|
+
from pydantic import ConfigDict, Field
|
|
8
|
+
from schemez import Schema
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BaseWorkerConfig(Schema):
|
|
12
|
+
"""Base configuration for workers.
|
|
13
|
+
|
|
14
|
+
Workers are nodes that can be registered as tools with a parent node.
|
|
15
|
+
This allows building hierarchies of specialized nodes.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
name: str = Field(
|
|
19
|
+
examples=["web_agent", "code_analyzer", "data_processor"],
|
|
20
|
+
title="Worker node name",
|
|
21
|
+
)
|
|
22
|
+
"""Name of the node to use as a worker."""
|
|
23
|
+
|
|
24
|
+
model_config = ConfigDict(frozen=True)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class TeamWorkerConfig(BaseWorkerConfig):
|
|
28
|
+
"""Configuration for team workers.
|
|
29
|
+
|
|
30
|
+
Team workers allow using entire teams as tools for other nodes.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
type: Literal["team"] = Field("team", init=False)
|
|
34
|
+
"""Team worker configuration."""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class AgentWorkerConfig(BaseWorkerConfig):
|
|
38
|
+
"""Configuration for agent workers.
|
|
39
|
+
|
|
40
|
+
Agent workers provide advanced features like history management and
|
|
41
|
+
context sharing between agents.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
type: Literal["agent"] = Field("agent", init=False)
|
|
45
|
+
"""Agent worker configuration."""
|
|
46
|
+
|
|
47
|
+
reset_history_on_run: bool = Field(default=True, title="Reset history on run")
|
|
48
|
+
"""Whether to clear worker's conversation history before each run.
|
|
49
|
+
True (default): Fresh conversation each time
|
|
50
|
+
False: Maintain conversation context between runs
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
pass_message_history: bool = Field(default=False, title="Pass message history")
|
|
54
|
+
"""Whether to pass parent agent's message history to worker.
|
|
55
|
+
True: Worker sees parent's conversation context
|
|
56
|
+
False (default): Worker only sees current request
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class ACPAgentWorkerConfig(BaseWorkerConfig):
|
|
61
|
+
"""Configuration for ACP agent workers.
|
|
62
|
+
|
|
63
|
+
ACP agent workers allow using external ACP-compatible agents as tools.
|
|
64
|
+
Unlike regular agents, ACP agents manage their own history server-side,
|
|
65
|
+
so history options are not available.
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
type: Literal["acp_agent"] = Field("acp_agent", init=False)
|
|
69
|
+
"""ACP agent worker configuration."""
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class AGUIAgentWorkerConfig(BaseWorkerConfig):
|
|
73
|
+
"""Configuration for AG-UI agent workers.
|
|
74
|
+
|
|
75
|
+
AG-UI agent workers allow using remote AG-UI protocol servers as tools.
|
|
76
|
+
Like ACP agents, they manage their own state server-side.
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
type: Literal["agui_agent"] = Field("agui_agent", init=False)
|
|
80
|
+
"""AG-UI agent worker configuration."""
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
WorkerConfig = Annotated[
|
|
84
|
+
TeamWorkerConfig | AgentWorkerConfig | ACPAgentWorkerConfig | AGUIAgentWorkerConfig,
|
|
85
|
+
Field(discriminator="type"),
|
|
86
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Prompts package."""
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"""Braintrust prompt provider implementation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import contextlib
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
import os
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from braintrust import init_logger, load_prompt
|
|
12
|
+
import httpx
|
|
13
|
+
|
|
14
|
+
from agentpool.prompts.base import BasePromptProvider
|
|
15
|
+
from agentpool_config.prompt_hubs import BraintrustConfig
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class BraintrustPromptMetadata:
|
|
20
|
+
"""Metadata for a Braintrust prompt."""
|
|
21
|
+
|
|
22
|
+
id: str
|
|
23
|
+
"""Unique identifier for the prompt."""
|
|
24
|
+
|
|
25
|
+
name: str
|
|
26
|
+
"""Name of the prompt."""
|
|
27
|
+
|
|
28
|
+
slug: str
|
|
29
|
+
"""Unique slug identifier for the prompt."""
|
|
30
|
+
|
|
31
|
+
description: str | None
|
|
32
|
+
"""Textual description of the prompt."""
|
|
33
|
+
|
|
34
|
+
project_id: str
|
|
35
|
+
"""Project ID the prompt belongs to."""
|
|
36
|
+
|
|
37
|
+
org_id: str
|
|
38
|
+
"""Organization ID."""
|
|
39
|
+
|
|
40
|
+
created: datetime | None
|
|
41
|
+
"""Creation timestamp."""
|
|
42
|
+
|
|
43
|
+
tags: list[str]
|
|
44
|
+
"""List of tags associated with the prompt."""
|
|
45
|
+
|
|
46
|
+
function_type: str | None
|
|
47
|
+
"""Type of function (llm, scorer, task, tool)."""
|
|
48
|
+
|
|
49
|
+
has_variables: bool
|
|
50
|
+
"""Whether the prompt contains template variables."""
|
|
51
|
+
|
|
52
|
+
model: str | None
|
|
53
|
+
"""Default model specified in prompt options."""
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def web_url(self) -> str:
|
|
57
|
+
"""URL to view this prompt in Braintrust web interface."""
|
|
58
|
+
return f"https://www.braintrustdata.com/app/prompt/{self.slug}"
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def from_api_object(cls, obj: dict[str, Any]) -> BraintrustPromptMetadata:
|
|
62
|
+
"""Create metadata from Braintrust API response object."""
|
|
63
|
+
created = None
|
|
64
|
+
if obj.get("created"):
|
|
65
|
+
with contextlib.suppress(ValueError, AttributeError):
|
|
66
|
+
created = datetime.fromisoformat(obj["created"].replace("Z", "+00:00"))
|
|
67
|
+
|
|
68
|
+
# Extract model from prompt_data.options.model if available
|
|
69
|
+
model = None
|
|
70
|
+
if prompt_data := obj.get("prompt_data"): # noqa: SIM102
|
|
71
|
+
if options := prompt_data.get("options"):
|
|
72
|
+
model = options.get("model")
|
|
73
|
+
|
|
74
|
+
# Check for template variables in prompt content
|
|
75
|
+
has_variables = False
|
|
76
|
+
if prompt_data := obj.get("prompt_data"): # noqa: SIM102
|
|
77
|
+
if prompt := prompt_data.get("prompt"):
|
|
78
|
+
if prompt.get("type") == "chat" and prompt.get("messages"):
|
|
79
|
+
# Check for Jinja2 template variables in message content
|
|
80
|
+
for msg in prompt["messages"]:
|
|
81
|
+
content = msg.get("content", "")
|
|
82
|
+
if isinstance(content, str) and ("{{" in content or "{%" in content):
|
|
83
|
+
has_variables = True
|
|
84
|
+
break
|
|
85
|
+
elif prompt.get("type") == "completion":
|
|
86
|
+
content = prompt.get("content", "")
|
|
87
|
+
if isinstance(content, str) and ("{{" in content or "{%" in content):
|
|
88
|
+
has_variables = True
|
|
89
|
+
|
|
90
|
+
return cls(
|
|
91
|
+
id=obj["id"],
|
|
92
|
+
name=obj["name"],
|
|
93
|
+
slug=obj["slug"],
|
|
94
|
+
description=obj.get("description"),
|
|
95
|
+
project_id=obj["project_id"],
|
|
96
|
+
org_id=obj["org_id"],
|
|
97
|
+
created=created,
|
|
98
|
+
tags=obj.get("tags") or [],
|
|
99
|
+
function_type=obj.get("function_type"),
|
|
100
|
+
has_variables=has_variables,
|
|
101
|
+
model=model,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class BraintrustPromptHub(BasePromptProvider):
|
|
106
|
+
"""Braintrust prompt provider implementation."""
|
|
107
|
+
|
|
108
|
+
def __init__(self, config: BraintrustConfig) -> None:
|
|
109
|
+
self.config = config or BraintrustConfig()
|
|
110
|
+
api_key = self.config.api_key.get_secret_value() if self.config.api_key else None
|
|
111
|
+
key = api_key or os.getenv("BRAINTRUST_API_KEY")
|
|
112
|
+
init_logger(api_key=key, project=self.config.project)
|
|
113
|
+
self.api_key = key
|
|
114
|
+
self._prompt_metadata: dict[str, BraintrustPromptMetadata] = {}
|
|
115
|
+
|
|
116
|
+
async def get_prompt(
|
|
117
|
+
self,
|
|
118
|
+
name: str,
|
|
119
|
+
version: str | None = None,
|
|
120
|
+
variables: dict[str, Any] | None = None,
|
|
121
|
+
) -> str:
|
|
122
|
+
"""Get and optionally compile a prompt from Braintrust."""
|
|
123
|
+
import jinjarope
|
|
124
|
+
|
|
125
|
+
env = jinjarope.Environment(enable_async=True)
|
|
126
|
+
prompt = load_prompt(slug=name, version=version, project=self.config.project)
|
|
127
|
+
assert prompt.prompt
|
|
128
|
+
string = prompt.prompt.messages[0].content # type: ignore
|
|
129
|
+
assert isinstance(string, str)
|
|
130
|
+
return await env.render_string_async(string, **(variables or {}))
|
|
131
|
+
|
|
132
|
+
async def list_prompts(self) -> list[str]:
|
|
133
|
+
"""List available prompts from Braintrust with pagination support."""
|
|
134
|
+
if not self.api_key:
|
|
135
|
+
raise RuntimeError("API key is required to list prompts")
|
|
136
|
+
|
|
137
|
+
params: dict[str, Any] = {"limit": 100} # Get up to 100 per page
|
|
138
|
+
if self.config.project: # Add project filter if specified
|
|
139
|
+
params["project_name"] = self.config.project
|
|
140
|
+
|
|
141
|
+
all_prompts = []
|
|
142
|
+
async with httpx.AsyncClient() as client:
|
|
143
|
+
while True:
|
|
144
|
+
url = "https://api.braintrust.dev/v1/prompt"
|
|
145
|
+
headers = {"Authorization": f"Bearer {self.api_key}"}
|
|
146
|
+
response = await client.get(url, headers=headers, params=params)
|
|
147
|
+
match response.status_code:
|
|
148
|
+
case 401:
|
|
149
|
+
raise RuntimeError("Unauthorized: Check your Braintrust API key")
|
|
150
|
+
case 403:
|
|
151
|
+
msg = "Forbidden: API key doesn't have permission to list prompts"
|
|
152
|
+
raise RuntimeError(msg)
|
|
153
|
+
case 200:
|
|
154
|
+
msg = f"Failed to list prompts: {response.status_code} - {response.text}"
|
|
155
|
+
raise RuntimeError(msg)
|
|
156
|
+
try:
|
|
157
|
+
data = response.json()
|
|
158
|
+
except Exception as e:
|
|
159
|
+
msg = f"Failed to parse response JSON: {e}"
|
|
160
|
+
raise RuntimeError(msg) from e
|
|
161
|
+
|
|
162
|
+
objects = data.get("objects", [])
|
|
163
|
+
if not objects:
|
|
164
|
+
break
|
|
165
|
+
|
|
166
|
+
# Parse metadata and collect prompt names
|
|
167
|
+
for obj in objects:
|
|
168
|
+
if obj.get("name") or obj.get("slug"):
|
|
169
|
+
metadata = BraintrustPromptMetadata.from_api_object(obj)
|
|
170
|
+
prompt_name = metadata.name or metadata.slug
|
|
171
|
+
self._prompt_metadata[prompt_name] = metadata
|
|
172
|
+
all_prompts.append(prompt_name)
|
|
173
|
+
|
|
174
|
+
# Check if there are more pages
|
|
175
|
+
if len(objects) < params["limit"]:
|
|
176
|
+
break
|
|
177
|
+
|
|
178
|
+
# Set up pagination for next request
|
|
179
|
+
last_id = objects[-1].get("id")
|
|
180
|
+
if last_id:
|
|
181
|
+
params["starting_after"] = last_id
|
|
182
|
+
else:
|
|
183
|
+
break
|
|
184
|
+
|
|
185
|
+
return all_prompts
|
|
186
|
+
|
|
187
|
+
def get_prompt_metadata(self, name: str) -> BraintrustPromptMetadata | None:
|
|
188
|
+
"""Get metadata for a specific prompt."""
|
|
189
|
+
return self._prompt_metadata.get(name)
|
|
190
|
+
|
|
191
|
+
def get_all_metadata(self) -> dict[str, BraintrustPromptMetadata]:
|
|
192
|
+
"""Get all parsed prompt metadata."""
|
|
193
|
+
return self._prompt_metadata.copy()
|
|
194
|
+
|
|
195
|
+
def filter_prompts_by_tag(self, tag: str) -> list[str]:
|
|
196
|
+
"""Filter prompts by tag."""
|
|
197
|
+
return [name for name, metadata in self._prompt_metadata.items() if tag in metadata.tags]
|
|
198
|
+
|
|
199
|
+
def filter_prompts_by_function_type(self, function_type: str) -> list[str]:
|
|
200
|
+
"""Filter prompts by function type (llm, scorer, task, tool)."""
|
|
201
|
+
return [
|
|
202
|
+
name
|
|
203
|
+
for name, metadata in self._prompt_metadata.items()
|
|
204
|
+
if metadata.function_type == function_type
|
|
205
|
+
]
|
|
206
|
+
|
|
207
|
+
def filter_prompts_with_variables(self) -> list[str]:
|
|
208
|
+
"""Get prompts that contain template variables."""
|
|
209
|
+
return [name for name, metadata in self._prompt_metadata.items() if metadata.has_variables]
|
|
210
|
+
|
|
211
|
+
def get_prompts_by_model(self, model: str) -> list[str]:
|
|
212
|
+
"""Get prompts configured for a specific model."""
|
|
213
|
+
return [name for name, metadata in self._prompt_metadata.items() if metadata.model == model]
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
if __name__ == "__main__":
|
|
217
|
+
import anyio
|
|
218
|
+
|
|
219
|
+
from agentpool_config.prompt_hubs import BraintrustConfig
|
|
220
|
+
|
|
221
|
+
config = BraintrustConfig(project="test")
|
|
222
|
+
prompt_hub = BraintrustPromptHub(config)
|
|
223
|
+
|
|
224
|
+
async def main() -> None:
|
|
225
|
+
# List available prompts
|
|
226
|
+
print("Available prompts:")
|
|
227
|
+
try:
|
|
228
|
+
prompts = await prompt_hub.list_prompts()
|
|
229
|
+
print(f"Found {len(prompts)} prompts:")
|
|
230
|
+
for prompt in prompts[:10]: # Show first 10
|
|
231
|
+
print(f"- {prompt}")
|
|
232
|
+
except Exception as e: # noqa: BLE001
|
|
233
|
+
print(f"Error listing prompts: {e}")
|
|
234
|
+
|
|
235
|
+
anyio.run(main)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Fabric GitHub prompt provider implementation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from agentpool.prompts.base import BasePromptProvider
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from agentpool_config.prompt_hubs import FabricConfig
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class FabricPromptHub(BasePromptProvider):
|
|
17
|
+
"""Provider for prompts from Fabric GitHub repository."""
|
|
18
|
+
|
|
19
|
+
_BASE_URL = "https://raw.githubusercontent.com/danielmiessler/fabric/main"
|
|
20
|
+
_API_URL = "https://api.github.com/repos/danielmiessler/fabric/contents/data/patterns"
|
|
21
|
+
|
|
22
|
+
def __init__(self, config: FabricConfig) -> None:
|
|
23
|
+
self.config = config
|
|
24
|
+
|
|
25
|
+
async def get_prompt(
|
|
26
|
+
self,
|
|
27
|
+
name: str,
|
|
28
|
+
version: str | None = None, # Ignored for Fabric
|
|
29
|
+
variables: dict[str, Any] | None = None,
|
|
30
|
+
) -> str:
|
|
31
|
+
"""Get prompt from Fabric GitHub repository."""
|
|
32
|
+
system_url = f"{self._BASE_URL}/data/patterns/{name}/system.md"
|
|
33
|
+
user_url = f"{self._BASE_URL}/data/patterns/{name}/user.md"
|
|
34
|
+
|
|
35
|
+
async with httpx.AsyncClient() as client:
|
|
36
|
+
# Try system prompt first
|
|
37
|
+
if (response := await client.get(system_url)).status_code == 200: # noqa: PLR2004
|
|
38
|
+
return response.text
|
|
39
|
+
if (response := await client.get(user_url)).status_code == 200: # noqa: PLR2004
|
|
40
|
+
return response.text
|
|
41
|
+
msg = f"Template {name!r} not found in Fabric repository"
|
|
42
|
+
raise ValueError(msg)
|
|
43
|
+
|
|
44
|
+
async def list_prompts(self) -> list[str]:
|
|
45
|
+
"""List available prompts from Fabric repository."""
|
|
46
|
+
headers = {"Accept": "application/vnd.github.v3+json"}
|
|
47
|
+
|
|
48
|
+
async with httpx.AsyncClient() as client:
|
|
49
|
+
response = await client.get(self._API_URL, headers=headers)
|
|
50
|
+
|
|
51
|
+
if response.status_code != 200: # noqa: PLR2004
|
|
52
|
+
raise RuntimeError(f"Failed to list prompts: {response.status_code}")
|
|
53
|
+
|
|
54
|
+
content = response.json()
|
|
55
|
+
return [item["name"] for item in content if item["type"] == "dir"]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if __name__ == "__main__":
|
|
59
|
+
import anyio
|
|
60
|
+
|
|
61
|
+
from agentpool_config.prompt_hubs import FabricConfig
|
|
62
|
+
|
|
63
|
+
async def main() -> None:
|
|
64
|
+
hub = FabricPromptHub(FabricConfig())
|
|
65
|
+
# List available prompts
|
|
66
|
+
print("Available prompts:")
|
|
67
|
+
prompts = await hub.list_prompts()
|
|
68
|
+
print("\n".join(f"- {p}" for p in prompts[:5])) # Show first 5
|
|
69
|
+
|
|
70
|
+
# Get a specific prompt
|
|
71
|
+
print("\nFetching 'summarize' prompt:")
|
|
72
|
+
prompt = await hub.get_prompt("summarize")
|
|
73
|
+
print(f"\n{prompt[:200]}...") # Show first 200 chars
|
|
74
|
+
|
|
75
|
+
anyio.run(main)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""Langfuse prompt provider implementation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
|
+
|
|
7
|
+
from langfuse import Langfuse # pyright: ignore
|
|
8
|
+
|
|
9
|
+
from agentpool.prompts.base import BasePromptProvider
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from agentpool_config.prompt_hubs import LangfuseConfig
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class LangfusePromptHub(BasePromptProvider):
|
|
17
|
+
"""Langfuse prompt provider implementation."""
|
|
18
|
+
|
|
19
|
+
name = "langfuse"
|
|
20
|
+
supports_versions = True
|
|
21
|
+
supports_variables = True
|
|
22
|
+
|
|
23
|
+
def __init__(self, config: LangfuseConfig) -> None:
|
|
24
|
+
self.config = config
|
|
25
|
+
secret = config.secret_key.get_secret_value()
|
|
26
|
+
pub = config.public_key.get_secret_value()
|
|
27
|
+
self._client = Langfuse(secret_key=secret, public_key=pub, host=str(config.host))
|
|
28
|
+
|
|
29
|
+
from langfuse.api.client import FernLangfuse
|
|
30
|
+
|
|
31
|
+
self._api_client = FernLangfuse(
|
|
32
|
+
base_url=str(config.host),
|
|
33
|
+
x_langfuse_public_key=pub,
|
|
34
|
+
username=pub,
|
|
35
|
+
password=secret,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
async def get_prompt(
|
|
39
|
+
self,
|
|
40
|
+
name: str,
|
|
41
|
+
version: str | None = None,
|
|
42
|
+
variables: dict[str, Any] | None = None,
|
|
43
|
+
) -> str:
|
|
44
|
+
"""Get and optionally compile a prompt from Langfuse."""
|
|
45
|
+
prompt = self._client.get_prompt(
|
|
46
|
+
name,
|
|
47
|
+
type="text",
|
|
48
|
+
version=int(version) if version else None,
|
|
49
|
+
cache_ttl_seconds=self.config.cache_ttl_seconds,
|
|
50
|
+
max_retries=self.config.max_retries,
|
|
51
|
+
fetch_timeout_seconds=self.config.fetch_timeout_seconds,
|
|
52
|
+
)
|
|
53
|
+
if variables:
|
|
54
|
+
return prompt.compile(**variables)
|
|
55
|
+
return prompt.prompt
|
|
56
|
+
|
|
57
|
+
async def list_prompts(self) -> list[str]:
|
|
58
|
+
"""List available prompts from Langfuse."""
|
|
59
|
+
try:
|
|
60
|
+
response = self._api_client.prompts.list()
|
|
61
|
+
return [prompt_meta.name for prompt_meta in response.data]
|
|
62
|
+
except Exception: # noqa: BLE001
|
|
63
|
+
# Fallback to empty list if listing fails
|
|
64
|
+
return []
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if __name__ == "__main__":
|
|
68
|
+
import anyio
|
|
69
|
+
from pydantic import SecretStr
|
|
70
|
+
|
|
71
|
+
from agentpool_config.prompt_hubs import LangfuseConfig
|
|
72
|
+
|
|
73
|
+
config = LangfuseConfig(secret_key=SecretStr("test"), public_key=SecretStr(""))
|
|
74
|
+
prompt_hub = LangfusePromptHub(config)
|
|
75
|
+
|
|
76
|
+
async def main() -> None:
|
|
77
|
+
print(await prompt_hub.list_prompts())
|
|
78
|
+
|
|
79
|
+
anyio.run(main)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""PromptLayer prompt provider implementation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
|
+
|
|
7
|
+
from promptlayer import PromptLayer # type: ignore[import-untyped]
|
|
8
|
+
|
|
9
|
+
from agentpool.prompts.base import BasePromptProvider
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from agentpool_config.prompt_hubs import PromptLayerConfig
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class PromptLayerProvider(BasePromptProvider):
|
|
17
|
+
"""PromptLayer provider."""
|
|
18
|
+
|
|
19
|
+
name = "promptlayer"
|
|
20
|
+
supports_versions = True
|
|
21
|
+
|
|
22
|
+
def __init__(self, config: PromptLayerConfig) -> None:
|
|
23
|
+
self.client = PromptLayer(
|
|
24
|
+
api_key=config.api_key.get_secret_value() if config.api_key else None
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
async def get_prompt(
|
|
28
|
+
self,
|
|
29
|
+
name: str,
|
|
30
|
+
version: str | None = None,
|
|
31
|
+
variables: dict[str, Any] | None = None,
|
|
32
|
+
) -> str:
|
|
33
|
+
# PromptLayer primarily tracks prompts used with their API
|
|
34
|
+
# But also allows template management
|
|
35
|
+
dct = self.client.templates.get(name)
|
|
36
|
+
template = dct["prompt_template"]
|
|
37
|
+
return (
|
|
38
|
+
str(template.get("content")) if "content" in template else str(template.get("messages"))
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
async def list_prompts(self) -> list[str]:
|
|
42
|
+
"""List available prompts from Fabric repository."""
|
|
43
|
+
dct = self.client.templates.all()
|
|
44
|
+
return [prompt["prompt_name"] for prompt in dct]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
import anyio
|
|
49
|
+
from pydantic import SecretStr
|
|
50
|
+
|
|
51
|
+
from agentpool_config.prompt_hubs import PromptLayerConfig
|
|
52
|
+
|
|
53
|
+
async def main() -> None:
|
|
54
|
+
config = PromptLayerConfig(api_key=SecretStr("pl_480ead79b098fc25c63cdb4c95115deb"))
|
|
55
|
+
provider = PromptLayerProvider(config)
|
|
56
|
+
prompt = await provider.list_prompts()
|
|
57
|
+
print(prompt)
|
|
58
|
+
|
|
59
|
+
anyio.run(main)
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""AgentPool Server implementations."""
|
|
2
|
+
|
|
3
|
+
from agentpool_server.a2a_server import A2AServer
|
|
4
|
+
from agentpool_server.aggregating_server import AggregatingServer
|
|
5
|
+
from agentpool_server.agui_server import AGUIServer
|
|
6
|
+
from agentpool_server.base import BaseServer
|
|
7
|
+
from agentpool_server.http_server import HTTPServer
|
|
8
|
+
|
|
9
|
+
__all__ = ["A2AServer", "AGUIServer", "AggregatingServer", "BaseServer", "HTTPServer"]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""A2A types."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, TypedDict
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class A2ARequest(TypedDict):
|
|
9
|
+
"""A2A JSON-RPC request format."""
|
|
10
|
+
|
|
11
|
+
jsonrpc: str
|
|
12
|
+
method: str
|
|
13
|
+
params: dict[str, Any]
|
|
14
|
+
id: str | int | None
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class A2AResponse(TypedDict):
|
|
18
|
+
"""A2A JSON-RPC response format."""
|
|
19
|
+
|
|
20
|
+
jsonrpc: str
|
|
21
|
+
id: str | int | None
|
|
22
|
+
result: dict[str, Any]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class TaskData(TypedDict):
|
|
26
|
+
"""Task storage data format."""
|
|
27
|
+
|
|
28
|
+
id: str
|
|
29
|
+
status: str
|
|
30
|
+
data: A2ARequest
|
|
31
|
+
result: dict[str, Any] | None
|
|
32
|
+
error: str | None
|
|
33
|
+
context_id: str | None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class TaskStatus(TypedDict):
|
|
37
|
+
"""Task status response format."""
|
|
38
|
+
|
|
39
|
+
status: str
|
|
40
|
+
result: dict[str, Any] | None
|
|
41
|
+
error: str | None
|