fast-agent-mcp 0.4.7__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.
- fast_agent/__init__.py +183 -0
- fast_agent/acp/__init__.py +19 -0
- fast_agent/acp/acp_aware_mixin.py +304 -0
- fast_agent/acp/acp_context.py +437 -0
- fast_agent/acp/content_conversion.py +136 -0
- fast_agent/acp/filesystem_runtime.py +427 -0
- fast_agent/acp/permission_store.py +269 -0
- fast_agent/acp/server/__init__.py +5 -0
- fast_agent/acp/server/agent_acp_server.py +1472 -0
- fast_agent/acp/slash_commands.py +1050 -0
- fast_agent/acp/terminal_runtime.py +408 -0
- fast_agent/acp/tool_permission_adapter.py +125 -0
- fast_agent/acp/tool_permissions.py +474 -0
- fast_agent/acp/tool_progress.py +814 -0
- fast_agent/agents/__init__.py +85 -0
- fast_agent/agents/agent_types.py +64 -0
- fast_agent/agents/llm_agent.py +350 -0
- fast_agent/agents/llm_decorator.py +1139 -0
- fast_agent/agents/mcp_agent.py +1337 -0
- fast_agent/agents/tool_agent.py +271 -0
- fast_agent/agents/workflow/agents_as_tools_agent.py +849 -0
- fast_agent/agents/workflow/chain_agent.py +212 -0
- fast_agent/agents/workflow/evaluator_optimizer.py +380 -0
- fast_agent/agents/workflow/iterative_planner.py +652 -0
- fast_agent/agents/workflow/maker_agent.py +379 -0
- fast_agent/agents/workflow/orchestrator_models.py +218 -0
- fast_agent/agents/workflow/orchestrator_prompts.py +248 -0
- fast_agent/agents/workflow/parallel_agent.py +250 -0
- fast_agent/agents/workflow/router_agent.py +353 -0
- fast_agent/cli/__init__.py +0 -0
- fast_agent/cli/__main__.py +73 -0
- fast_agent/cli/commands/acp.py +159 -0
- fast_agent/cli/commands/auth.py +404 -0
- fast_agent/cli/commands/check_config.py +783 -0
- fast_agent/cli/commands/go.py +514 -0
- fast_agent/cli/commands/quickstart.py +557 -0
- fast_agent/cli/commands/serve.py +143 -0
- fast_agent/cli/commands/server_helpers.py +114 -0
- fast_agent/cli/commands/setup.py +174 -0
- fast_agent/cli/commands/url_parser.py +190 -0
- fast_agent/cli/constants.py +40 -0
- fast_agent/cli/main.py +115 -0
- fast_agent/cli/terminal.py +24 -0
- fast_agent/config.py +798 -0
- fast_agent/constants.py +41 -0
- fast_agent/context.py +279 -0
- fast_agent/context_dependent.py +50 -0
- fast_agent/core/__init__.py +92 -0
- fast_agent/core/agent_app.py +448 -0
- fast_agent/core/core_app.py +137 -0
- fast_agent/core/direct_decorators.py +784 -0
- fast_agent/core/direct_factory.py +620 -0
- fast_agent/core/error_handling.py +27 -0
- fast_agent/core/exceptions.py +90 -0
- fast_agent/core/executor/__init__.py +0 -0
- fast_agent/core/executor/executor.py +280 -0
- fast_agent/core/executor/task_registry.py +32 -0
- fast_agent/core/executor/workflow_signal.py +324 -0
- fast_agent/core/fastagent.py +1186 -0
- fast_agent/core/logging/__init__.py +5 -0
- fast_agent/core/logging/events.py +138 -0
- fast_agent/core/logging/json_serializer.py +164 -0
- fast_agent/core/logging/listeners.py +309 -0
- fast_agent/core/logging/logger.py +278 -0
- fast_agent/core/logging/transport.py +481 -0
- fast_agent/core/prompt.py +9 -0
- fast_agent/core/prompt_templates.py +183 -0
- fast_agent/core/validation.py +326 -0
- fast_agent/event_progress.py +62 -0
- fast_agent/history/history_exporter.py +49 -0
- fast_agent/human_input/__init__.py +47 -0
- fast_agent/human_input/elicitation_handler.py +123 -0
- fast_agent/human_input/elicitation_state.py +33 -0
- fast_agent/human_input/form_elements.py +59 -0
- fast_agent/human_input/form_fields.py +256 -0
- fast_agent/human_input/simple_form.py +113 -0
- fast_agent/human_input/types.py +40 -0
- fast_agent/interfaces.py +310 -0
- fast_agent/llm/__init__.py +9 -0
- fast_agent/llm/cancellation.py +22 -0
- fast_agent/llm/fastagent_llm.py +931 -0
- fast_agent/llm/internal/passthrough.py +161 -0
- fast_agent/llm/internal/playback.py +129 -0
- fast_agent/llm/internal/silent.py +41 -0
- fast_agent/llm/internal/slow.py +38 -0
- fast_agent/llm/memory.py +275 -0
- fast_agent/llm/model_database.py +490 -0
- fast_agent/llm/model_factory.py +388 -0
- fast_agent/llm/model_info.py +102 -0
- fast_agent/llm/prompt_utils.py +155 -0
- fast_agent/llm/provider/anthropic/anthropic_utils.py +84 -0
- fast_agent/llm/provider/anthropic/cache_planner.py +56 -0
- fast_agent/llm/provider/anthropic/llm_anthropic.py +796 -0
- fast_agent/llm/provider/anthropic/multipart_converter_anthropic.py +462 -0
- fast_agent/llm/provider/bedrock/bedrock_utils.py +218 -0
- fast_agent/llm/provider/bedrock/llm_bedrock.py +2207 -0
- fast_agent/llm/provider/bedrock/multipart_converter_bedrock.py +84 -0
- fast_agent/llm/provider/google/google_converter.py +466 -0
- fast_agent/llm/provider/google/llm_google_native.py +681 -0
- fast_agent/llm/provider/openai/llm_aliyun.py +31 -0
- fast_agent/llm/provider/openai/llm_azure.py +143 -0
- fast_agent/llm/provider/openai/llm_deepseek.py +76 -0
- fast_agent/llm/provider/openai/llm_generic.py +35 -0
- fast_agent/llm/provider/openai/llm_google_oai.py +32 -0
- fast_agent/llm/provider/openai/llm_groq.py +42 -0
- fast_agent/llm/provider/openai/llm_huggingface.py +85 -0
- fast_agent/llm/provider/openai/llm_openai.py +1195 -0
- fast_agent/llm/provider/openai/llm_openai_compatible.py +138 -0
- fast_agent/llm/provider/openai/llm_openrouter.py +45 -0
- fast_agent/llm/provider/openai/llm_tensorzero_openai.py +128 -0
- fast_agent/llm/provider/openai/llm_xai.py +38 -0
- fast_agent/llm/provider/openai/multipart_converter_openai.py +561 -0
- fast_agent/llm/provider/openai/openai_multipart.py +169 -0
- fast_agent/llm/provider/openai/openai_utils.py +67 -0
- fast_agent/llm/provider/openai/responses.py +133 -0
- fast_agent/llm/provider_key_manager.py +139 -0
- fast_agent/llm/provider_types.py +34 -0
- fast_agent/llm/request_params.py +61 -0
- fast_agent/llm/sampling_converter.py +98 -0
- fast_agent/llm/stream_types.py +9 -0
- fast_agent/llm/usage_tracking.py +445 -0
- fast_agent/mcp/__init__.py +56 -0
- fast_agent/mcp/common.py +26 -0
- fast_agent/mcp/elicitation_factory.py +84 -0
- fast_agent/mcp/elicitation_handlers.py +164 -0
- fast_agent/mcp/gen_client.py +83 -0
- fast_agent/mcp/helpers/__init__.py +36 -0
- fast_agent/mcp/helpers/content_helpers.py +352 -0
- fast_agent/mcp/helpers/server_config_helpers.py +25 -0
- fast_agent/mcp/hf_auth.py +147 -0
- fast_agent/mcp/interfaces.py +92 -0
- fast_agent/mcp/logger_textio.py +108 -0
- fast_agent/mcp/mcp_agent_client_session.py +411 -0
- fast_agent/mcp/mcp_aggregator.py +2175 -0
- fast_agent/mcp/mcp_connection_manager.py +723 -0
- fast_agent/mcp/mcp_content.py +262 -0
- fast_agent/mcp/mime_utils.py +108 -0
- fast_agent/mcp/oauth_client.py +509 -0
- fast_agent/mcp/prompt.py +159 -0
- fast_agent/mcp/prompt_message_extended.py +155 -0
- fast_agent/mcp/prompt_render.py +84 -0
- fast_agent/mcp/prompt_serialization.py +580 -0
- fast_agent/mcp/prompts/__init__.py +0 -0
- fast_agent/mcp/prompts/__main__.py +7 -0
- fast_agent/mcp/prompts/prompt_constants.py +18 -0
- fast_agent/mcp/prompts/prompt_helpers.py +238 -0
- fast_agent/mcp/prompts/prompt_load.py +186 -0
- fast_agent/mcp/prompts/prompt_server.py +552 -0
- fast_agent/mcp/prompts/prompt_template.py +438 -0
- fast_agent/mcp/resource_utils.py +215 -0
- fast_agent/mcp/sampling.py +200 -0
- fast_agent/mcp/server/__init__.py +4 -0
- fast_agent/mcp/server/agent_server.py +613 -0
- fast_agent/mcp/skybridge.py +44 -0
- fast_agent/mcp/sse_tracking.py +287 -0
- fast_agent/mcp/stdio_tracking_simple.py +59 -0
- fast_agent/mcp/streamable_http_tracking.py +309 -0
- fast_agent/mcp/tool_execution_handler.py +137 -0
- fast_agent/mcp/tool_permission_handler.py +88 -0
- fast_agent/mcp/transport_tracking.py +634 -0
- fast_agent/mcp/types.py +24 -0
- fast_agent/mcp/ui_agent.py +48 -0
- fast_agent/mcp/ui_mixin.py +209 -0
- fast_agent/mcp_server_registry.py +89 -0
- fast_agent/py.typed +0 -0
- fast_agent/resources/examples/data-analysis/analysis-campaign.py +189 -0
- fast_agent/resources/examples/data-analysis/analysis.py +68 -0
- fast_agent/resources/examples/data-analysis/fastagent.config.yaml +41 -0
- fast_agent/resources/examples/data-analysis/mount-point/WA_Fn-UseC_-HR-Employee-Attrition.csv +1471 -0
- fast_agent/resources/examples/mcp/elicitations/elicitation_account_server.py +88 -0
- fast_agent/resources/examples/mcp/elicitations/elicitation_forms_server.py +297 -0
- fast_agent/resources/examples/mcp/elicitations/elicitation_game_server.py +164 -0
- fast_agent/resources/examples/mcp/elicitations/fastagent.config.yaml +35 -0
- fast_agent/resources/examples/mcp/elicitations/fastagent.secrets.yaml.example +17 -0
- fast_agent/resources/examples/mcp/elicitations/forms_demo.py +107 -0
- fast_agent/resources/examples/mcp/elicitations/game_character.py +65 -0
- fast_agent/resources/examples/mcp/elicitations/game_character_handler.py +256 -0
- fast_agent/resources/examples/mcp/elicitations/tool_call.py +21 -0
- fast_agent/resources/examples/mcp/state-transfer/agent_one.py +18 -0
- fast_agent/resources/examples/mcp/state-transfer/agent_two.py +18 -0
- fast_agent/resources/examples/mcp/state-transfer/fastagent.config.yaml +27 -0
- fast_agent/resources/examples/mcp/state-transfer/fastagent.secrets.yaml.example +15 -0
- fast_agent/resources/examples/researcher/fastagent.config.yaml +61 -0
- fast_agent/resources/examples/researcher/researcher-eval.py +53 -0
- fast_agent/resources/examples/researcher/researcher-imp.py +189 -0
- fast_agent/resources/examples/researcher/researcher.py +36 -0
- fast_agent/resources/examples/tensorzero/.env.sample +2 -0
- fast_agent/resources/examples/tensorzero/Makefile +31 -0
- fast_agent/resources/examples/tensorzero/README.md +56 -0
- fast_agent/resources/examples/tensorzero/agent.py +35 -0
- fast_agent/resources/examples/tensorzero/demo_images/clam.jpg +0 -0
- fast_agent/resources/examples/tensorzero/demo_images/crab.png +0 -0
- fast_agent/resources/examples/tensorzero/demo_images/shrimp.png +0 -0
- fast_agent/resources/examples/tensorzero/docker-compose.yml +105 -0
- fast_agent/resources/examples/tensorzero/fastagent.config.yaml +19 -0
- fast_agent/resources/examples/tensorzero/image_demo.py +67 -0
- fast_agent/resources/examples/tensorzero/mcp_server/Dockerfile +25 -0
- fast_agent/resources/examples/tensorzero/mcp_server/entrypoint.sh +35 -0
- fast_agent/resources/examples/tensorzero/mcp_server/mcp_server.py +31 -0
- fast_agent/resources/examples/tensorzero/mcp_server/pyproject.toml +11 -0
- fast_agent/resources/examples/tensorzero/simple_agent.py +25 -0
- fast_agent/resources/examples/tensorzero/tensorzero_config/system_schema.json +29 -0
- fast_agent/resources/examples/tensorzero/tensorzero_config/system_template.minijinja +11 -0
- fast_agent/resources/examples/tensorzero/tensorzero_config/tensorzero.toml +35 -0
- fast_agent/resources/examples/workflows/agents_as_tools_extended.py +73 -0
- fast_agent/resources/examples/workflows/agents_as_tools_simple.py +50 -0
- fast_agent/resources/examples/workflows/chaining.py +37 -0
- fast_agent/resources/examples/workflows/evaluator.py +77 -0
- fast_agent/resources/examples/workflows/fastagent.config.yaml +26 -0
- fast_agent/resources/examples/workflows/graded_report.md +89 -0
- fast_agent/resources/examples/workflows/human_input.py +28 -0
- fast_agent/resources/examples/workflows/maker.py +156 -0
- fast_agent/resources/examples/workflows/orchestrator.py +70 -0
- fast_agent/resources/examples/workflows/parallel.py +56 -0
- fast_agent/resources/examples/workflows/router.py +69 -0
- fast_agent/resources/examples/workflows/short_story.md +13 -0
- fast_agent/resources/examples/workflows/short_story.txt +19 -0
- fast_agent/resources/setup/.gitignore +30 -0
- fast_agent/resources/setup/agent.py +28 -0
- fast_agent/resources/setup/fastagent.config.yaml +65 -0
- fast_agent/resources/setup/fastagent.secrets.yaml.example +38 -0
- fast_agent/resources/setup/pyproject.toml.tmpl +23 -0
- fast_agent/skills/__init__.py +9 -0
- fast_agent/skills/registry.py +235 -0
- fast_agent/tools/elicitation.py +369 -0
- fast_agent/tools/shell_runtime.py +402 -0
- fast_agent/types/__init__.py +59 -0
- fast_agent/types/conversation_summary.py +294 -0
- fast_agent/types/llm_stop_reason.py +78 -0
- fast_agent/types/message_search.py +249 -0
- fast_agent/ui/__init__.py +38 -0
- fast_agent/ui/console.py +59 -0
- fast_agent/ui/console_display.py +1080 -0
- fast_agent/ui/elicitation_form.py +946 -0
- fast_agent/ui/elicitation_style.py +59 -0
- fast_agent/ui/enhanced_prompt.py +1400 -0
- fast_agent/ui/history_display.py +734 -0
- fast_agent/ui/interactive_prompt.py +1199 -0
- fast_agent/ui/markdown_helpers.py +104 -0
- fast_agent/ui/markdown_truncator.py +1004 -0
- fast_agent/ui/mcp_display.py +857 -0
- fast_agent/ui/mcp_ui_utils.py +235 -0
- fast_agent/ui/mermaid_utils.py +169 -0
- fast_agent/ui/message_primitives.py +50 -0
- fast_agent/ui/notification_tracker.py +205 -0
- fast_agent/ui/plain_text_truncator.py +68 -0
- fast_agent/ui/progress_display.py +10 -0
- fast_agent/ui/rich_progress.py +195 -0
- fast_agent/ui/streaming.py +774 -0
- fast_agent/ui/streaming_buffer.py +449 -0
- fast_agent/ui/tool_display.py +422 -0
- fast_agent/ui/usage_display.py +204 -0
- fast_agent/utils/__init__.py +5 -0
- fast_agent/utils/reasoning_stream_parser.py +77 -0
- fast_agent/utils/time.py +22 -0
- fast_agent/workflow_telemetry.py +261 -0
- fast_agent_mcp-0.4.7.dist-info/METADATA +788 -0
- fast_agent_mcp-0.4.7.dist-info/RECORD +261 -0
- fast_agent_mcp-0.4.7.dist-info/WHEEL +4 -0
- fast_agent_mcp-0.4.7.dist-info/entry_points.txt +7 -0
- fast_agent_mcp-0.4.7.dist-info/licenses/LICENSE +201 -0
fast_agent/interfaces.py
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Generic Fast Agent protocol interfaces and types.
|
|
3
|
+
|
|
4
|
+
These are provider- and transport-agnostic and can be safely imported
|
|
5
|
+
without pulling in MCP-specific code, helping to avoid circular imports.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import (
|
|
9
|
+
TYPE_CHECKING,
|
|
10
|
+
Any,
|
|
11
|
+
Callable,
|
|
12
|
+
Mapping,
|
|
13
|
+
Protocol,
|
|
14
|
+
Sequence,
|
|
15
|
+
Type,
|
|
16
|
+
TypeVar,
|
|
17
|
+
Union,
|
|
18
|
+
runtime_checkable,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from a2a.types import AgentCard
|
|
22
|
+
from mcp import Tool
|
|
23
|
+
from mcp.types import GetPromptResult, ListToolsResult, Prompt, PromptMessage, ReadResourceResult
|
|
24
|
+
from pydantic import BaseModel
|
|
25
|
+
from rich.text import Text
|
|
26
|
+
|
|
27
|
+
from fast_agent.llm.provider_types import Provider
|
|
28
|
+
from fast_agent.llm.stream_types import StreamChunk
|
|
29
|
+
from fast_agent.llm.usage_tracking import UsageAccumulator
|
|
30
|
+
from fast_agent.types import PromptMessageExtended, RequestParams
|
|
31
|
+
|
|
32
|
+
if TYPE_CHECKING:
|
|
33
|
+
from fast_agent.acp.acp_aware_mixin import ACPCommand, ACPModeInfo
|
|
34
|
+
from fast_agent.acp.acp_context import ACPContext
|
|
35
|
+
from fast_agent.agents.agent_types import AgentType
|
|
36
|
+
from fast_agent.llm.model_info import ModelInfo
|
|
37
|
+
|
|
38
|
+
__all__ = [
|
|
39
|
+
"FastAgentLLMProtocol",
|
|
40
|
+
"StreamingAgentProtocol",
|
|
41
|
+
"LlmAgentProtocol",
|
|
42
|
+
"AgentProtocol",
|
|
43
|
+
"ACPAwareProtocol",
|
|
44
|
+
"LLMFactoryProtocol",
|
|
45
|
+
"ModelFactoryFunctionProtocol",
|
|
46
|
+
"ModelT",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
ModelT = TypeVar("ModelT", bound=BaseModel)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class LLMFactoryProtocol(Protocol):
|
|
54
|
+
"""Protocol for LLM factory functions that create FastAgentLLM instances."""
|
|
55
|
+
|
|
56
|
+
def __call__(self, agent: "AgentProtocol", **kwargs: Any) -> "FastAgentLLMProtocol": ...
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class ModelFactoryFunctionProtocol(Protocol):
|
|
60
|
+
"""Returns an LLM Model Factory for the specified model string"""
|
|
61
|
+
|
|
62
|
+
def __call__(self, model: str | None = None) -> LLMFactoryProtocol: ...
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@runtime_checkable
|
|
66
|
+
class FastAgentLLMProtocol(Protocol):
|
|
67
|
+
"""Protocol defining the interface for LLMs"""
|
|
68
|
+
|
|
69
|
+
async def structured(
|
|
70
|
+
self,
|
|
71
|
+
messages: list[PromptMessageExtended],
|
|
72
|
+
model: Type[ModelT],
|
|
73
|
+
request_params: RequestParams | None = None,
|
|
74
|
+
) -> tuple[ModelT | None, PromptMessageExtended]: ...
|
|
75
|
+
|
|
76
|
+
async def generate(
|
|
77
|
+
self,
|
|
78
|
+
messages: list[PromptMessageExtended],
|
|
79
|
+
request_params: RequestParams | None = None,
|
|
80
|
+
tools: list[Tool] | None = None,
|
|
81
|
+
) -> PromptMessageExtended: ...
|
|
82
|
+
|
|
83
|
+
async def apply_prompt_template(
|
|
84
|
+
self, prompt_result: "GetPromptResult", prompt_name: str
|
|
85
|
+
) -> str: ...
|
|
86
|
+
|
|
87
|
+
def get_request_params(
|
|
88
|
+
self,
|
|
89
|
+
request_params: RequestParams | None = None,
|
|
90
|
+
) -> RequestParams: ...
|
|
91
|
+
|
|
92
|
+
def add_stream_listener(self, listener: Callable[[StreamChunk], None]) -> Callable[[], None]: ...
|
|
93
|
+
|
|
94
|
+
def add_tool_stream_listener(
|
|
95
|
+
self, listener: Callable[[str, dict[str, Any] | None], None]
|
|
96
|
+
) -> Callable[[], None]: ...
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def message_history(self) -> list[PromptMessageExtended]: ...
|
|
100
|
+
|
|
101
|
+
def pop_last_message(self) -> PromptMessageExtended | None: ...
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def usage_accumulator(self) -> UsageAccumulator | None: ...
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def provider(self) -> Provider: ...
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def model_name(self) -> str | None: ...
|
|
111
|
+
|
|
112
|
+
@property
|
|
113
|
+
def model_info(self) -> "ModelInfo | None": ...
|
|
114
|
+
|
|
115
|
+
def clear(self, *, clear_prompts: bool = False) -> None: ...
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@runtime_checkable
|
|
119
|
+
class LlmAgentProtocol(Protocol):
|
|
120
|
+
"""Protocol defining the minimal interface for LLM agents."""
|
|
121
|
+
|
|
122
|
+
@property
|
|
123
|
+
def llm(self) -> FastAgentLLMProtocol | None: ...
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
def name(self) -> str: ...
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def agent_type(self) -> "AgentType": ...
|
|
130
|
+
|
|
131
|
+
async def initialize(self) -> None: ...
|
|
132
|
+
|
|
133
|
+
async def shutdown(self) -> None: ...
|
|
134
|
+
|
|
135
|
+
def clear(self, *, clear_prompts: bool = False) -> None: ...
|
|
136
|
+
|
|
137
|
+
def pop_last_message(self) -> PromptMessageExtended | None: ...
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@runtime_checkable
|
|
141
|
+
class AgentProtocol(LlmAgentProtocol, Protocol):
|
|
142
|
+
"""Standard agent interface with flexible input types."""
|
|
143
|
+
|
|
144
|
+
async def __call__(
|
|
145
|
+
self,
|
|
146
|
+
message: Union[
|
|
147
|
+
str,
|
|
148
|
+
PromptMessage,
|
|
149
|
+
PromptMessageExtended,
|
|
150
|
+
Sequence[Union[str, PromptMessage, PromptMessageExtended]],
|
|
151
|
+
],
|
|
152
|
+
) -> str: ...
|
|
153
|
+
|
|
154
|
+
async def send(
|
|
155
|
+
self,
|
|
156
|
+
message: Union[
|
|
157
|
+
str,
|
|
158
|
+
PromptMessage,
|
|
159
|
+
PromptMessageExtended,
|
|
160
|
+
Sequence[Union[str, PromptMessage, PromptMessageExtended]],
|
|
161
|
+
],
|
|
162
|
+
request_params: RequestParams | None = None,
|
|
163
|
+
) -> str: ...
|
|
164
|
+
|
|
165
|
+
async def generate(
|
|
166
|
+
self,
|
|
167
|
+
messages: Union[
|
|
168
|
+
str,
|
|
169
|
+
PromptMessage,
|
|
170
|
+
PromptMessageExtended,
|
|
171
|
+
Sequence[Union[str, PromptMessage, PromptMessageExtended]],
|
|
172
|
+
],
|
|
173
|
+
request_params: RequestParams | None = None,
|
|
174
|
+
) -> PromptMessageExtended: ...
|
|
175
|
+
|
|
176
|
+
async def structured(
|
|
177
|
+
self,
|
|
178
|
+
messages: Union[
|
|
179
|
+
str,
|
|
180
|
+
PromptMessage,
|
|
181
|
+
PromptMessageExtended,
|
|
182
|
+
Sequence[Union[str, PromptMessage, PromptMessageExtended]],
|
|
183
|
+
],
|
|
184
|
+
model: Type[ModelT],
|
|
185
|
+
request_params: RequestParams | None = None,
|
|
186
|
+
) -> tuple[ModelT | None, PromptMessageExtended]: ...
|
|
187
|
+
|
|
188
|
+
@property
|
|
189
|
+
def message_history(self) -> list[PromptMessageExtended]: ...
|
|
190
|
+
|
|
191
|
+
@property
|
|
192
|
+
def usage_accumulator(self) -> UsageAccumulator | None: ...
|
|
193
|
+
|
|
194
|
+
async def apply_prompt(
|
|
195
|
+
self,
|
|
196
|
+
prompt: Union[str, "GetPromptResult"],
|
|
197
|
+
arguments: dict[str, str] | None = None,
|
|
198
|
+
as_template: bool = False,
|
|
199
|
+
namespace: str | None = None,
|
|
200
|
+
) -> str: ...
|
|
201
|
+
|
|
202
|
+
async def get_prompt(
|
|
203
|
+
self,
|
|
204
|
+
prompt_name: str,
|
|
205
|
+
arguments: dict[str, str] | None = None,
|
|
206
|
+
namespace: str | None = None,
|
|
207
|
+
) -> GetPromptResult: ...
|
|
208
|
+
|
|
209
|
+
async def list_prompts(self, namespace: str | None = None) -> Mapping[str, list[Prompt]]: ...
|
|
210
|
+
|
|
211
|
+
async def list_resources(self, namespace: str | None = None) -> Mapping[str, list[str]]: ...
|
|
212
|
+
|
|
213
|
+
async def list_mcp_tools(self, namespace: str | None = None) -> Mapping[str, list[Tool]]: ...
|
|
214
|
+
|
|
215
|
+
async def list_tools(self) -> ListToolsResult: ...
|
|
216
|
+
|
|
217
|
+
async def get_resource(
|
|
218
|
+
self, resource_uri: str, namespace: str | None = None
|
|
219
|
+
) -> ReadResourceResult: ...
|
|
220
|
+
|
|
221
|
+
async def with_resource(
|
|
222
|
+
self,
|
|
223
|
+
prompt_content: Union[str, PromptMessage, PromptMessageExtended],
|
|
224
|
+
resource_uri: str,
|
|
225
|
+
namespace: str | None = None,
|
|
226
|
+
) -> str: ...
|
|
227
|
+
|
|
228
|
+
async def agent_card(self) -> AgentCard: ...
|
|
229
|
+
|
|
230
|
+
async def initialize(self) -> None: ...
|
|
231
|
+
|
|
232
|
+
async def shutdown(self) -> None: ...
|
|
233
|
+
|
|
234
|
+
async def run_tools(self, request: PromptMessageExtended) -> PromptMessageExtended: ...
|
|
235
|
+
|
|
236
|
+
async def show_assistant_message(
|
|
237
|
+
self,
|
|
238
|
+
message: PromptMessageExtended,
|
|
239
|
+
bottom_items: list[str] | None = None,
|
|
240
|
+
highlight_items: str | list[str] | None = None,
|
|
241
|
+
max_item_length: int | None = None,
|
|
242
|
+
name: str | None = None,
|
|
243
|
+
model: str | None = None,
|
|
244
|
+
additional_message: Text | None = None,
|
|
245
|
+
) -> None: ...
|
|
246
|
+
|
|
247
|
+
async def attach_llm(
|
|
248
|
+
self,
|
|
249
|
+
llm_factory: LLMFactoryProtocol,
|
|
250
|
+
model: str | None = None,
|
|
251
|
+
request_params: RequestParams | None = None,
|
|
252
|
+
**additional_kwargs,
|
|
253
|
+
) -> FastAgentLLMProtocol: ...
|
|
254
|
+
|
|
255
|
+
@property
|
|
256
|
+
def initialized(self) -> bool: ...
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
@runtime_checkable
|
|
260
|
+
class StreamingAgentProtocol(AgentProtocol, Protocol):
|
|
261
|
+
"""Optional extension for agents that expose LLM streaming callbacks."""
|
|
262
|
+
|
|
263
|
+
def add_stream_listener(self, listener: Callable[[StreamChunk], None]) -> Callable[[], None]: ...
|
|
264
|
+
|
|
265
|
+
def add_tool_stream_listener(
|
|
266
|
+
self, listener: Callable[[str, dict[str, Any] | None], None]
|
|
267
|
+
) -> Callable[[], None]: ...
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
@runtime_checkable
|
|
271
|
+
class ACPAwareProtocol(Protocol):
|
|
272
|
+
"""
|
|
273
|
+
Protocol for agents that can be ACP-aware.
|
|
274
|
+
|
|
275
|
+
This protocol defines the interface for agents that can check whether
|
|
276
|
+
they're running in ACP mode and access ACP features when available.
|
|
277
|
+
|
|
278
|
+
Agents implementing this protocol can:
|
|
279
|
+
- Check if they're in ACP mode via `is_acp_mode`
|
|
280
|
+
- Access ACP context via `acp` property
|
|
281
|
+
- Declare slash commands via `acp_commands` property
|
|
282
|
+
|
|
283
|
+
The ACPAwareMixin provides a concrete implementation of this protocol.
|
|
284
|
+
"""
|
|
285
|
+
|
|
286
|
+
@property
|
|
287
|
+
def acp(self) -> "ACPContext | None":
|
|
288
|
+
"""Get the ACP context if available."""
|
|
289
|
+
...
|
|
290
|
+
|
|
291
|
+
@property
|
|
292
|
+
def is_acp_mode(self) -> bool:
|
|
293
|
+
"""Check if the agent is running in ACP mode."""
|
|
294
|
+
...
|
|
295
|
+
|
|
296
|
+
@property
|
|
297
|
+
def acp_commands(self) -> dict[str, "ACPCommand"]:
|
|
298
|
+
"""
|
|
299
|
+
Declare slash commands this agent exposes via ACP.
|
|
300
|
+
|
|
301
|
+
Returns a dict mapping command names to ACPCommand instances.
|
|
302
|
+
Commands are queried dynamically when the agent is the active mode.
|
|
303
|
+
"""
|
|
304
|
+
...
|
|
305
|
+
|
|
306
|
+
def acp_mode_info(self) -> "ACPModeInfo | None":
|
|
307
|
+
"""
|
|
308
|
+
Optional ACP mode metadata (name/description) for client display.
|
|
309
|
+
"""
|
|
310
|
+
...
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Cancellation support for LLM provider calls.
|
|
3
|
+
|
|
4
|
+
This module previously provided a CancellationToken class for cancellation.
|
|
5
|
+
Now cancellation is handled natively through asyncio.Task.cancel() which raises
|
|
6
|
+
asyncio.CancelledError at the next await point.
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
# Store the task when starting work
|
|
10
|
+
task = asyncio.current_task()
|
|
11
|
+
|
|
12
|
+
# To cancel:
|
|
13
|
+
task.cancel() # Raises asyncio.CancelledError in the task
|
|
14
|
+
|
|
15
|
+
# In the LLM provider, CancelledError propagates naturally:
|
|
16
|
+
async for chunk in stream:
|
|
17
|
+
# task.cancel() will raise CancelledError here
|
|
18
|
+
process(chunk)
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
# This module is kept for documentation purposes.
|
|
22
|
+
# All cancellation is now handled via asyncio.Task.cancel()
|