autobyteus 1.1.4__py3-none-any.whl → 1.1.5__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.
Files changed (167) hide show
  1. autobyteus/agent/context/__init__.py +4 -2
  2. autobyteus/agent/context/agent_config.py +0 -4
  3. autobyteus/agent/context/agent_context_registry.py +73 -0
  4. autobyteus/agent/events/notifiers.py +4 -0
  5. autobyteus/agent/handlers/inter_agent_message_event_handler.py +7 -2
  6. autobyteus/agent/handlers/llm_complete_response_received_event_handler.py +19 -19
  7. autobyteus/agent/handlers/user_input_message_event_handler.py +15 -0
  8. autobyteus/agent/message/send_message_to.py +29 -23
  9. autobyteus/agent/runtime/agent_runtime.py +10 -2
  10. autobyteus/agent/sender_type.py +15 -0
  11. autobyteus/agent/streaming/agent_event_stream.py +6 -0
  12. autobyteus/agent/streaming/stream_event_payloads.py +12 -0
  13. autobyteus/agent/streaming/stream_events.py +3 -0
  14. autobyteus/agent/system_prompt_processor/tool_manifest_injector_processor.py +7 -4
  15. autobyteus/agent_team/__init__.py +1 -0
  16. autobyteus/agent_team/agent_team.py +93 -0
  17. autobyteus/agent_team/agent_team_builder.py +184 -0
  18. autobyteus/agent_team/base_agent_team.py +86 -0
  19. autobyteus/agent_team/bootstrap_steps/__init__.py +24 -0
  20. autobyteus/agent_team/bootstrap_steps/agent_configuration_preparation_step.py +73 -0
  21. autobyteus/agent_team/bootstrap_steps/agent_team_bootstrapper.py +54 -0
  22. autobyteus/agent_team/bootstrap_steps/agent_team_runtime_queue_initialization_step.py +25 -0
  23. autobyteus/agent_team/bootstrap_steps/base_agent_team_bootstrap_step.py +23 -0
  24. autobyteus/agent_team/bootstrap_steps/coordinator_initialization_step.py +41 -0
  25. autobyteus/agent_team/bootstrap_steps/coordinator_prompt_preparation_step.py +85 -0
  26. autobyteus/agent_team/bootstrap_steps/task_notifier_initialization_step.py +51 -0
  27. autobyteus/agent_team/bootstrap_steps/team_context_initialization_step.py +45 -0
  28. autobyteus/agent_team/context/__init__.py +17 -0
  29. autobyteus/agent_team/context/agent_team_config.py +33 -0
  30. autobyteus/agent_team/context/agent_team_context.py +61 -0
  31. autobyteus/agent_team/context/agent_team_runtime_state.py +56 -0
  32. autobyteus/agent_team/context/team_manager.py +147 -0
  33. autobyteus/agent_team/context/team_node_config.py +76 -0
  34. autobyteus/agent_team/events/__init__.py +29 -0
  35. autobyteus/agent_team/events/agent_team_event_dispatcher.py +39 -0
  36. autobyteus/agent_team/events/agent_team_events.py +53 -0
  37. autobyteus/agent_team/events/agent_team_input_event_queue_manager.py +21 -0
  38. autobyteus/agent_team/exceptions.py +8 -0
  39. autobyteus/agent_team/factory/__init__.py +9 -0
  40. autobyteus/agent_team/factory/agent_team_factory.py +99 -0
  41. autobyteus/agent_team/handlers/__init__.py +19 -0
  42. autobyteus/agent_team/handlers/agent_team_event_handler_registry.py +23 -0
  43. autobyteus/agent_team/handlers/base_agent_team_event_handler.py +16 -0
  44. autobyteus/agent_team/handlers/inter_agent_message_request_event_handler.py +61 -0
  45. autobyteus/agent_team/handlers/lifecycle_agent_team_event_handler.py +27 -0
  46. autobyteus/agent_team/handlers/process_user_message_event_handler.py +46 -0
  47. autobyteus/agent_team/handlers/tool_approval_team_event_handler.py +48 -0
  48. autobyteus/agent_team/phases/__init__.py +11 -0
  49. autobyteus/agent_team/phases/agent_team_operational_phase.py +19 -0
  50. autobyteus/agent_team/phases/agent_team_phase_manager.py +48 -0
  51. autobyteus/agent_team/runtime/__init__.py +13 -0
  52. autobyteus/agent_team/runtime/agent_team_runtime.py +82 -0
  53. autobyteus/agent_team/runtime/agent_team_worker.py +117 -0
  54. autobyteus/agent_team/shutdown_steps/__init__.py +17 -0
  55. autobyteus/agent_team/shutdown_steps/agent_team_shutdown_orchestrator.py +35 -0
  56. autobyteus/agent_team/shutdown_steps/agent_team_shutdown_step.py +42 -0
  57. autobyteus/agent_team/shutdown_steps/base_agent_team_shutdown_step.py +16 -0
  58. autobyteus/agent_team/shutdown_steps/bridge_cleanup_step.py +28 -0
  59. autobyteus/agent_team/shutdown_steps/sub_team_shutdown_step.py +41 -0
  60. autobyteus/agent_team/streaming/__init__.py +26 -0
  61. autobyteus/agent_team/streaming/agent_event_bridge.py +48 -0
  62. autobyteus/agent_team/streaming/agent_event_multiplexer.py +70 -0
  63. autobyteus/agent_team/streaming/agent_team_event_notifier.py +64 -0
  64. autobyteus/agent_team/streaming/agent_team_event_stream.py +33 -0
  65. autobyteus/agent_team/streaming/agent_team_stream_event_payloads.py +32 -0
  66. autobyteus/agent_team/streaming/agent_team_stream_events.py +56 -0
  67. autobyteus/agent_team/streaming/team_event_bridge.py +50 -0
  68. autobyteus/agent_team/task_notification/__init__.py +11 -0
  69. autobyteus/agent_team/task_notification/system_event_driven_agent_task_notifier.py +164 -0
  70. autobyteus/agent_team/task_notification/task_notification_mode.py +24 -0
  71. autobyteus/agent_team/utils/__init__.py +9 -0
  72. autobyteus/agent_team/utils/wait_for_idle.py +46 -0
  73. autobyteus/cli/agent_team_tui/__init__.py +4 -0
  74. autobyteus/cli/agent_team_tui/app.py +210 -0
  75. autobyteus/cli/agent_team_tui/state.py +180 -0
  76. autobyteus/cli/agent_team_tui/widgets/__init__.py +6 -0
  77. autobyteus/cli/agent_team_tui/widgets/agent_list_sidebar.py +149 -0
  78. autobyteus/cli/agent_team_tui/widgets/focus_pane.py +320 -0
  79. autobyteus/cli/agent_team_tui/widgets/logo.py +20 -0
  80. autobyteus/cli/agent_team_tui/widgets/renderables.py +77 -0
  81. autobyteus/cli/agent_team_tui/widgets/shared.py +60 -0
  82. autobyteus/cli/agent_team_tui/widgets/status_bar.py +14 -0
  83. autobyteus/cli/agent_team_tui/widgets/task_board_panel.py +82 -0
  84. autobyteus/events/event_types.py +7 -2
  85. autobyteus/llm/api/autobyteus_llm.py +11 -12
  86. autobyteus/llm/api/lmstudio_llm.py +10 -13
  87. autobyteus/llm/api/ollama_llm.py +8 -13
  88. autobyteus/llm/autobyteus_provider.py +73 -46
  89. autobyteus/llm/llm_factory.py +102 -140
  90. autobyteus/llm/lmstudio_provider.py +63 -48
  91. autobyteus/llm/models.py +83 -53
  92. autobyteus/llm/ollama_provider.py +69 -61
  93. autobyteus/llm/ollama_provider_resolver.py +1 -0
  94. autobyteus/llm/providers.py +13 -13
  95. autobyteus/llm/runtimes.py +11 -0
  96. autobyteus/task_management/__init__.py +43 -0
  97. autobyteus/task_management/base_task_board.py +68 -0
  98. autobyteus/task_management/converters/__init__.py +11 -0
  99. autobyteus/task_management/converters/task_board_converter.py +64 -0
  100. autobyteus/task_management/converters/task_plan_converter.py +48 -0
  101. autobyteus/task_management/deliverable.py +16 -0
  102. autobyteus/task_management/deliverables/__init__.py +8 -0
  103. autobyteus/task_management/deliverables/file_deliverable.py +15 -0
  104. autobyteus/task_management/events.py +27 -0
  105. autobyteus/task_management/in_memory_task_board.py +126 -0
  106. autobyteus/task_management/schemas/__init__.py +15 -0
  107. autobyteus/task_management/schemas/deliverable_schema.py +13 -0
  108. autobyteus/task_management/schemas/plan_definition.py +35 -0
  109. autobyteus/task_management/schemas/task_status_report.py +27 -0
  110. autobyteus/task_management/task_plan.py +110 -0
  111. autobyteus/task_management/tools/__init__.py +14 -0
  112. autobyteus/task_management/tools/get_task_board_status.py +68 -0
  113. autobyteus/task_management/tools/publish_task_plan.py +113 -0
  114. autobyteus/task_management/tools/update_task_status.py +135 -0
  115. autobyteus/tools/bash/bash_executor.py +59 -14
  116. autobyteus/tools/mcp/config_service.py +63 -58
  117. autobyteus/tools/mcp/server/http_managed_mcp_server.py +14 -2
  118. autobyteus/tools/mcp/server/stdio_managed_mcp_server.py +14 -2
  119. autobyteus/tools/mcp/server_instance_manager.py +30 -4
  120. autobyteus/tools/mcp/tool_registrar.py +103 -50
  121. autobyteus/tools/parameter_schema.py +17 -11
  122. autobyteus/tools/registry/tool_definition.py +24 -29
  123. autobyteus/tools/tool_category.py +1 -0
  124. autobyteus/tools/usage/formatters/default_json_example_formatter.py +78 -3
  125. autobyteus/tools/usage/formatters/default_xml_example_formatter.py +23 -3
  126. autobyteus/tools/usage/formatters/gemini_json_example_formatter.py +6 -0
  127. autobyteus/tools/usage/formatters/google_json_example_formatter.py +7 -0
  128. autobyteus/tools/usage/formatters/openai_json_example_formatter.py +6 -4
  129. autobyteus/tools/usage/parsers/gemini_json_tool_usage_parser.py +23 -7
  130. autobyteus/tools/usage/parsers/provider_aware_tool_usage_parser.py +14 -25
  131. autobyteus/tools/usage/providers/__init__.py +2 -12
  132. autobyteus/tools/usage/providers/tool_manifest_provider.py +36 -29
  133. autobyteus/tools/usage/registries/__init__.py +7 -12
  134. autobyteus/tools/usage/registries/tool_formatter_pair.py +15 -0
  135. autobyteus/tools/usage/registries/tool_formatting_registry.py +58 -0
  136. autobyteus/tools/usage/registries/tool_usage_parser_registry.py +55 -0
  137. {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/METADATA +3 -3
  138. {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/RECORD +146 -72
  139. examples/agent_team/__init__.py +1 -0
  140. examples/run_browser_agent.py +17 -15
  141. examples/run_google_slides_agent.py +17 -16
  142. examples/run_poem_writer.py +22 -12
  143. examples/run_sqlite_agent.py +17 -15
  144. autobyteus/tools/mcp/call_handlers/__init__.py +0 -16
  145. autobyteus/tools/mcp/call_handlers/base_handler.py +0 -40
  146. autobyteus/tools/mcp/call_handlers/stdio_handler.py +0 -76
  147. autobyteus/tools/mcp/call_handlers/streamable_http_handler.py +0 -55
  148. autobyteus/tools/usage/providers/json_example_provider.py +0 -32
  149. autobyteus/tools/usage/providers/json_schema_provider.py +0 -35
  150. autobyteus/tools/usage/providers/json_tool_usage_parser_provider.py +0 -28
  151. autobyteus/tools/usage/providers/xml_example_provider.py +0 -28
  152. autobyteus/tools/usage/providers/xml_schema_provider.py +0 -29
  153. autobyteus/tools/usage/providers/xml_tool_usage_parser_provider.py +0 -26
  154. autobyteus/tools/usage/registries/json_example_formatter_registry.py +0 -51
  155. autobyteus/tools/usage/registries/json_schema_formatter_registry.py +0 -51
  156. autobyteus/tools/usage/registries/json_tool_usage_parser_registry.py +0 -42
  157. autobyteus/tools/usage/registries/xml_example_formatter_registry.py +0 -30
  158. autobyteus/tools/usage/registries/xml_schema_formatter_registry.py +0 -33
  159. autobyteus/tools/usage/registries/xml_tool_usage_parser_registry.py +0 -30
  160. examples/workflow/__init__.py +0 -1
  161. examples/workflow/run_basic_research_workflow.py +0 -189
  162. examples/workflow/run_code_review_workflow.py +0 -269
  163. examples/workflow/run_debate_workflow.py +0 -212
  164. examples/workflow/run_workflow_with_tui.py +0 -153
  165. {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/WHEEL +0 -0
  166. {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/licenses/LICENSE +0 -0
  167. {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/top_level.txt +0 -0
@@ -207,15 +207,18 @@ async def main(args: argparse.Namespace):
207
207
  # 5. Configure and create the agent.
208
208
  try:
209
209
  _ = LLMModel[args.llm_model]
210
- except KeyError:
211
- all_models = sorted(list(LLMModel), key=lambda m: m.name)
212
- available_models_list = [f" - Name: {m.name:<35} Value: {m.value}" for m in all_models]
213
- logger.error(
214
- f"LLM Model '{args.llm_model}' is not valid.\n"
215
- f"You can use either the model name (e.g., 'GPT_4o_API') or its value (e.g., 'gpt-4o').\n\n"
216
- f"Available models:\n" +
217
- "\n".join(available_models_list)
218
- )
210
+ except (KeyError, ValueError):
211
+ logger.error(f"LLM Model '{args.llm_model}' is not valid or ambiguous.", file=sys.stderr)
212
+ try:
213
+ LLMFactory.ensure_initialized()
214
+ print("\nAvailable LLM Models (use the 'Identifier' with --llm-model):")
215
+ all_models = sorted(list(LLMModel), key=lambda m: m.model_identifier)
216
+ if not all_models:
217
+ print(" No models found.")
218
+ for model in all_models:
219
+ print(f" - Display Name: {model.name:<30} Identifier: {model.model_identifier}")
220
+ except Exception as e:
221
+ print(f"Additionally, an error occurred while listing models: {e}", file=sys.stderr)
219
222
  sys.exit(1)
220
223
 
221
224
  logger.info(f"Creating LLM instance for model: {args.llm_model}")
@@ -238,8 +241,7 @@ async def main(args: argparse.Namespace):
238
241
  llm_instance=llm_instance,
239
242
  system_prompt=system_prompt,
240
243
  tools=tools_for_agent,
241
- auto_execute_tools=False,
242
- use_xml_tool_format=False
244
+ auto_execute_tools=False
243
245
  )
244
246
 
245
247
  agent = AgentFactory().create_agent(config=sqlite_agent_config)
@@ -257,7 +259,7 @@ async def main(args: argparse.Namespace):
257
259
 
258
260
  if __name__ == "__main__":
259
261
  parser = argparse.ArgumentParser(description="Run the SQLiteAgent interactively.")
260
- parser.add_argument("--llm-model", type=str, default="kimi-latest", help=f"The LLM model to use. Call --help-models for list.")
262
+ parser.add_argument("--llm-model", type=str, default="kimi-latest", help=f"The LLM model identifier to use. Call --help-models for list.")
261
263
  parser.add_argument("--help-models", action="store_true", help="Display available LLM models and exit.")
262
264
  parser.add_argument("--debug", action="store_true", help="Enable debug logging.")
263
265
  parser.add_argument("--agent-log-file", type=str, default="./agent_logs_sqlite.txt",
@@ -268,12 +270,12 @@ if __name__ == "__main__":
268
270
  if "--help-models" in sys.argv:
269
271
  try:
270
272
  LLMFactory.ensure_initialized()
271
- print("Available LLM Models (you can use either name or value with --llm-model):")
272
- all_models = sorted(list(LLMModel), key=lambda m: m.name)
273
+ print("Available LLM Models (use the 'Identifier' with --llm-model):")
274
+ all_models = sorted(list(LLMModel), key=lambda m: m.model_identifier)
273
275
  if not all_models:
274
276
  print(" No models found.")
275
277
  for model in all_models:
276
- print(f" - Name: {model.name:<35} Value: {model.value}")
278
+ print(f" - Display Name: {model.name:<30} Identifier: {model.model_identifier}")
277
279
  except Exception as e:
278
280
  print(f"Error listing models: {e}")
279
281
  sys.exit(0)
@@ -1,16 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/mcp/call_handlers/__init__.py
2
- """
3
- This package contains the MCP Call Handlers.
4
- Each handler is responsible for performing a complete, end-to-end tool call
5
- for a specific transport protocol (e.g., STDIO, Streamable HTTP).
6
- """
7
-
8
- from .base_handler import McpCallHandler
9
- from .stdio_handler import StdioMcpCallHandler
10
- from .streamable_http_handler import StreamableHttpMcpCallHandler
11
-
12
- __all__ = [
13
- "McpCallHandler",
14
- "StdioMcpCallHandler",
15
- "StreamableHttpMcpCallHandler",
16
- ]
@@ -1,40 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/mcp/call_handlers/base_handler.py
2
- import logging
3
- from abc import ABC, abstractmethod
4
- from typing import Dict, Any, TYPE_CHECKING
5
-
6
- if TYPE_CHECKING:
7
- from ..types import BaseMcpConfig
8
-
9
- logger = logging.getLogger(__name__)
10
-
11
- class McpCallHandler(ABC):
12
- """
13
- Abstract base class for a handler that performs a single, end-to-end
14
- MCP tool call for a specific transport protocol.
15
- """
16
-
17
- @abstractmethod
18
- async def handle_call(
19
- self,
20
- config: 'BaseMcpConfig',
21
- remote_tool_name: str,
22
- arguments: Dict[str, Any]
23
- ) -> Any:
24
- """
25
- Handles a complete MCP tool call, including connection, execution,
26
- and disconnection if necessary.
27
-
28
- Args:
29
- config: The configuration object for the target MCP server.
30
- remote_tool_name: The name of the tool to call on the remote server.
31
- arguments: A dictionary of arguments for the tool call.
32
-
33
- Returns:
34
- The result returned by the remote tool.
35
-
36
- Raises:
37
- NotImplementedError: If the handler for a specific transport is not implemented.
38
- RuntimeError: If the tool call fails for any reason.
39
- """
40
- pass
@@ -1,76 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/mcp/call_handlers/stdio_handler.py
2
- import logging
3
- import asyncio
4
- from typing import Dict, Any, cast, TYPE_CHECKING
5
-
6
- from .base_handler import McpCallHandler
7
- from mcp import StdioServerParameters, ClientSession
8
- from mcp.client.stdio import stdio_client
9
-
10
- if TYPE_CHECKING:
11
- from ..types import BaseMcpConfig, StdioMcpServerConfig
12
-
13
- logger = logging.getLogger(__name__)
14
-
15
- # A default timeout for STDIO subprocesses to prevent indefinite hangs.
16
- DEFAULT_STDIO_TIMEOUT = 30 # seconds
17
-
18
- class StdioMcpCallHandler(McpCallHandler):
19
- """Handles MCP tool calls over a stateless STDIO transport."""
20
-
21
- async def handle_call(
22
- self,
23
- config: 'BaseMcpConfig',
24
- remote_tool_name: str,
25
- arguments: Dict[str, Any]
26
- ) -> Any:
27
- """
28
- Creates a new subprocess, establishes a session, and executes the
29
- requested tool call. It handles 'list_tools' as a special case.
30
- Includes a timeout to prevent hanging on unresponsive subprocesses.
31
- """
32
- logger.debug(f"Handling STDIO call to tool '{remote_tool_name}' on server '{config.server_id}'.")
33
-
34
- from ..types import StdioMcpServerConfig
35
- if not isinstance(config, StdioMcpServerConfig):
36
- raise TypeError(f"StdioMcpCallHandler requires a StdioMcpServerConfig, but got {type(config).__name__}.")
37
-
38
- stdio_config = cast(StdioMcpServerConfig, config)
39
-
40
- mcp_lib_stdio_params = StdioServerParameters(
41
- command=stdio_config.command,
42
- args=stdio_config.args,
43
- env=stdio_config.env,
44
- cwd=stdio_config.cwd
45
- )
46
-
47
- async def _perform_call():
48
- """Inner function to be wrapped by the timeout."""
49
- # The stdio_client context manager provides the read/write streams.
50
- async with stdio_client(mcp_lib_stdio_params) as (read_stream, write_stream):
51
- # The ClientSession is its own context manager that handles initialization.
52
- async with ClientSession(read_stream, write_stream) as session:
53
- logger.debug(f"STDIO session established for '{config.server_id}'. Calling tool '{remote_tool_name}'.")
54
-
55
- # The 'list_tools' command is a special method on the session.
56
- if remote_tool_name == "list_tools":
57
- result = await session.list_tools()
58
- else:
59
- result = await session.call_tool(remote_tool_name, arguments)
60
-
61
- logger.debug(f"STDIO call to tool '{remote_tool_name}' on server '{config.server_id}' completed.")
62
- return result
63
-
64
- try:
65
- return await asyncio.wait_for(_perform_call(), timeout=DEFAULT_STDIO_TIMEOUT)
66
- except asyncio.TimeoutError:
67
- error_message = (f"MCP call to '{remote_tool_name}' on server '{config.server_id}' timed out "
68
- f"after {DEFAULT_STDIO_TIMEOUT} seconds. The subprocess may have hung.")
69
- logger.error(error_message)
70
- raise RuntimeError(error_message) from None
71
- except Exception as e:
72
- logger.error(
73
- f"An error occurred during STDIO tool call to '{remote_tool_name}' on server '{config.server_id}': {e}",
74
- exc_info=True
75
- )
76
- raise RuntimeError(f"Failed to execute MCP tool '{remote_tool_name}' via STDIO on server '{config.server_id}': {e}") from e
@@ -1,55 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/mcp/call_handlers/streamable_http_handler.py
2
- import logging
3
- from typing import Dict, Any, cast, TYPE_CHECKING
4
-
5
- from .base_handler import McpCallHandler
6
- from mcp import ClientSession
7
- from mcp.client.streamable_http import streamablehttp_client
8
-
9
- if TYPE_CHECKING:
10
- from ..types import BaseMcpConfig, StreamableHttpMcpServerConfig
11
-
12
- logger = logging.getLogger(__name__)
13
-
14
- class StreamableHttpMcpCallHandler(McpCallHandler):
15
- """Handles MCP tool calls over a stateless Streamable HTTP transport."""
16
-
17
- async def handle_call(
18
- self,
19
- config: 'BaseMcpConfig',
20
- remote_tool_name: str,
21
- arguments: Dict[str, Any]
22
- ) -> Any:
23
- """
24
- Creates a new HTTP connection, establishes a session, and executes the
25
- requested tool call. It handles 'list_tools' as a special case.
26
- """
27
- logger.debug(f"Handling Streamable HTTP call to tool '{remote_tool_name}' on server '{config.server_id}'.")
28
-
29
- from ..types import StreamableHttpMcpServerConfig
30
- if not isinstance(config, StreamableHttpMcpServerConfig):
31
- raise TypeError(f"StreamableHttpMcpCallHandler requires a StreamableHttpMcpServerConfig, got {type(config).__name__}.")
32
-
33
- http_config = cast(StreamableHttpMcpServerConfig, config)
34
-
35
- try:
36
- # The streamablehttp_client context manager provides the read/write streams.
37
- async with streamablehttp_client(http_config.url, headers=http_config.headers) as (read_stream, write_stream):
38
- # The ClientSession is its own context manager that handles initialization.
39
- async with ClientSession(read_stream, write_stream) as session:
40
- logger.debug(f"Streamable HTTP session established for '{config.server_id}'. Calling tool '{remote_tool_name}'.")
41
-
42
- # The 'list_tools' command is a special method on the session.
43
- if remote_tool_name == "list_tools":
44
- result = await session.list_tools()
45
- else:
46
- result = await session.call_tool(remote_tool_name, arguments)
47
-
48
- logger.debug(f"Streamable HTTP call to tool '{remote_tool_name}' on server '{config.server_id}' completed.")
49
- return result
50
- except Exception as e:
51
- logger.error(
52
- f"An error occurred during Streamable HTTP tool call to '{remote_tool_name}' on server '{config.server_id}': {e}",
53
- exc_info=True
54
- )
55
- raise RuntimeError(f"Failed to execute MCP tool '{remote_tool_name}' via Streamable HTTP on server '{config.server_id}': {e}") from e
@@ -1,32 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/usage/providers/json_example_provider.py
2
- from typing import Optional, Any, TYPE_CHECKING
3
-
4
- from autobyteus.llm.providers import LLMProvider
5
- from autobyteus.tools.usage.registries.json_example_formatter_registry import JsonExampleFormatterRegistry
6
-
7
- if TYPE_CHECKING:
8
- from autobyteus.tools.registry import ToolDefinition
9
-
10
- class JsonExampleProvider:
11
- """Provides a tool usage example as a JSON dictionary for a specific LLM provider."""
12
-
13
- def __init__(self):
14
- self._registry = JsonExampleFormatterRegistry()
15
-
16
- def provide(self, tool_definition: 'ToolDefinition', llm_provider: Optional[LLMProvider] = None) -> Any:
17
- """
18
- Generates a JSON dictionary or string for a single tool usage example.
19
-
20
- Args:
21
- tool_definition: A ToolDefinition object.
22
- llm_provider: The LLMProvider for which to format the JSON.
23
-
24
- Returns:
25
- A dictionary or string representing the tool usage example.
26
- """
27
- if llm_provider:
28
- formatter = self._registry.get_formatter(llm_provider)
29
- else:
30
- formatter = self._registry.get_default_formatter()
31
-
32
- return formatter.provide(tool_definition)
@@ -1,35 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/usage/providers/json_schema_provider.py
2
- from typing import Optional, Dict, TYPE_CHECKING
3
-
4
- from autobyteus.llm.providers import LLMProvider
5
- from autobyteus.tools.usage.registries.json_schema_formatter_registry import JsonSchemaFormatterRegistry
6
-
7
- if TYPE_CHECKING:
8
- from autobyteus.tools.registry import ToolDefinition
9
-
10
- class JsonSchemaProvider:
11
- """
12
- Provides the schema for a single tool formatted as a JSON dictionary,
13
- tailored to the specific LLM provider's requirements.
14
- """
15
- def __init__(self):
16
- self._registry = JsonSchemaFormatterRegistry()
17
-
18
- def provide(self, tool_definition: 'ToolDefinition', llm_provider: Optional[LLMProvider] = None) -> Dict:
19
- """
20
- Generates a JSON dictionary for a single tool's schema.
21
-
22
- Args:
23
- tool_definition: A ToolDefinition object.
24
- llm_provider: The LLMProvider for which to format the JSON. If None,
25
- a default generic format is used.
26
-
27
- Returns:
28
- A dictionary representing the tool schema.
29
- """
30
- if llm_provider:
31
- formatter = self._registry.get_formatter(llm_provider)
32
- else:
33
- formatter = self._registry.get_default_formatter()
34
-
35
- return formatter.provide(tool_definition)
@@ -1,28 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/usage/providers/json_tool_usage_parser_provider.py
2
- from typing import Optional, TYPE_CHECKING
3
-
4
- from autobyteus.llm.providers import LLMProvider
5
- from autobyteus.tools.usage.registries.json_tool_usage_parser_registry import JsonToolUsageParserRegistry
6
-
7
- if TYPE_CHECKING:
8
- from autobyteus.tools.usage.parsers.base_parser import BaseToolUsageParser
9
-
10
- class JsonToolUsageParserProvider:
11
- """Provides a tool usage parser for JSON-based responses, specific to an LLM provider."""
12
-
13
- def __init__(self):
14
- self._registry = JsonToolUsageParserRegistry()
15
-
16
- def provide(self, llm_provider: Optional[LLMProvider] = None) -> 'BaseToolUsageParser':
17
- """
18
- Gets the appropriate parser from the registry.
19
-
20
- Args:
21
- llm_provider: The LLMProvider for which to get a parser.
22
-
23
- Returns:
24
- An instance of a class derived from BaseToolUsageParser.
25
- """
26
- if llm_provider:
27
- return self._registry.get_parser(llm_provider)
28
- return self._registry.get_default_parser()
@@ -1,28 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/usage/providers/xml_example_provider.py
2
- from typing import Optional, TYPE_CHECKING
3
-
4
- from autobyteus.llm.providers import LLMProvider
5
- from autobyteus.tools.usage.registries.xml_example_formatter_registry import XmlExampleFormatterRegistry
6
-
7
- if TYPE_CHECKING:
8
- from autobyteus.tools.registry import ToolDefinition
9
-
10
- class XmlExampleProvider:
11
- """Provides a tool usage example formatted as a single XML string."""
12
-
13
- def __init__(self):
14
- self._registry = XmlExampleFormatterRegistry()
15
-
16
- def provide(self, tool_definition: 'ToolDefinition', llm_provider: Optional[LLMProvider] = None) -> str:
17
- """
18
- Generates a single XML string for a tool usage example.
19
-
20
- Args:
21
- tool_definition: A ToolDefinition object.
22
- llm_provider: Ignored, for API consistency.
23
-
24
- Returns:
25
- A string containing the XML tool usage example.
26
- """
27
- formatter = self._registry.get_formatter(llm_provider)
28
- return formatter.provide(tool_definition)
@@ -1,29 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/usage/providers/xml_schema_provider.py
2
- from typing import Optional, TYPE_CHECKING
3
-
4
- from autobyteus.llm.providers import LLMProvider
5
- from autobyteus.tools.usage.registries.xml_schema_formatter_registry import XmlSchemaFormatterRegistry
6
-
7
- if TYPE_CHECKING:
8
- from autobyteus.tools.registry import ToolDefinition
9
-
10
- class XmlSchemaProvider:
11
- """
12
- Provides the schema for a single tool formatted as an XML string.
13
- """
14
- def __init__(self):
15
- self._registry = XmlSchemaFormatterRegistry()
16
-
17
- def provide(self, tool_definition: 'ToolDefinition', llm_provider: Optional[LLMProvider] = None) -> str:
18
- """
19
- Generates an XML string for a single tool's schema.
20
-
21
- Args:
22
- tool_definition: A ToolDefinition object.
23
- llm_provider: This argument is passed to the registry for API consistency.
24
-
25
- Returns:
26
- A string containing the XML tool schema.
27
- """
28
- formatter = self._registry.get_formatter(llm_provider)
29
- return formatter.provide(tool_definition)
@@ -1,26 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/usage/providers/xml_tool_usage_parser_provider.py
2
- from typing import Optional, TYPE_CHECKING
3
-
4
- from autobyteus.llm.providers import LLMProvider
5
- from autobyteus.tools.usage.registries.xml_tool_usage_parser_registry import XmlToolUsageParserRegistry
6
-
7
- if TYPE_CHECKING:
8
- from autobyteus.tools.usage.parsers.base_parser import BaseToolUsageParser
9
-
10
- class XmlToolUsageParserProvider:
11
- """Provides a tool usage parser for XML-based responses."""
12
-
13
- def __init__(self):
14
- self._registry = XmlToolUsageParserRegistry()
15
-
16
- def provide(self, llm_provider: Optional[LLMProvider] = None) -> 'BaseToolUsageParser':
17
- """
18
- Gets the appropriate parser from the registry.
19
-
20
- Args:
21
- llm_provider: Ignored, for API consistency.
22
-
23
- Returns:
24
- An instance of a class derived from BaseToolUsageParser.
25
- """
26
- return self._registry.get_parser(llm_provider)
@@ -1,51 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/usage/registries/json_example_formatter_registry.py
2
- import logging
3
- from typing import Dict
4
-
5
- from autobyteus.llm.providers import LLMProvider
6
- from autobyteus.tools.usage.formatters.base_formatter import BaseExampleFormatter
7
- from autobyteus.tools.usage.formatters.default_json_example_formatter import DefaultJsonExampleFormatter
8
- from autobyteus.tools.usage.formatters.openai_json_example_formatter import OpenAiJsonExampleFormatter
9
- from autobyteus.tools.usage.formatters.anthropic_json_example_formatter import AnthropicJsonExampleFormatter
10
- from autobyteus.tools.usage.formatters.gemini_json_example_formatter import GeminiJsonExampleFormatter
11
- from autobyteus.utils.singleton import SingletonMeta
12
-
13
- logger = logging.getLogger(__name__)
14
-
15
- class JsonExampleFormatterRegistry(metaclass=SingletonMeta):
16
- """A singleton registry for retrieving JSON example formatters based on LLM provider."""
17
-
18
- def __init__(self):
19
- self._formatters: Dict[LLMProvider, BaseExampleFormatter] = {
20
- LLMProvider.OPENAI: OpenAiJsonExampleFormatter(),
21
- LLMProvider.MISTRAL: OpenAiJsonExampleFormatter(),
22
- LLMProvider.DEEPSEEK: OpenAiJsonExampleFormatter(),
23
- LLMProvider.GROK: OpenAiJsonExampleFormatter(),
24
- LLMProvider.ANTHROPIC: AnthropicJsonExampleFormatter(),
25
- LLMProvider.GEMINI: GeminiJsonExampleFormatter(),
26
- }
27
- self._default_formatter = DefaultJsonExampleFormatter()
28
- logger.info("JsonExampleFormatterRegistry initialized.")
29
-
30
- def get_formatter(self, provider: LLMProvider) -> BaseExampleFormatter:
31
- """
32
- Retrieves the appropriate example formatter for a given LLM provider.
33
-
34
- Args:
35
- provider: The LLMProvider enum member.
36
-
37
- Returns:
38
- An instance of a class derived from BaseExampleFormatter.
39
- """
40
- formatter = self._formatters.get(provider)
41
- if formatter:
42
- logger.debug(f"Found specific example formatter for provider {provider.name}: {formatter.__class__.__name__}")
43
- return formatter
44
-
45
- logger.debug(f"No specific example formatter for provider {provider.name}. "
46
- f"Returning default: {self._default_formatter.__class__.__name__}")
47
- return self._default_formatter
48
-
49
- def get_default_formatter(self) -> BaseExampleFormatter:
50
- """Explicitly returns the default formatter."""
51
- return self._default_formatter
@@ -1,51 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/usage/registries/json_schema_formatter_registry.py
2
- import logging
3
- from typing import Dict
4
-
5
- from autobyteus.llm.providers import LLMProvider
6
- from autobyteus.tools.usage.formatters.base_formatter import BaseSchemaFormatter
7
- from autobyteus.tools.usage.formatters.default_json_schema_formatter import DefaultJsonSchemaFormatter
8
- from autobyteus.tools.usage.formatters.openai_json_schema_formatter import OpenAiJsonSchemaFormatter
9
- from autobyteus.tools.usage.formatters.anthropic_json_schema_formatter import AnthropicJsonSchemaFormatter
10
- from autobyteus.tools.usage.formatters.gemini_json_schema_formatter import GeminiJsonSchemaFormatter
11
- from autobyteus.utils.singleton import SingletonMeta
12
-
13
- logger = logging.getLogger(__name__)
14
-
15
- class JsonSchemaFormatterRegistry(metaclass=SingletonMeta):
16
- """A singleton registry for retrieving JSON schema formatters based on LLM provider."""
17
-
18
- def __init__(self):
19
- self._formatters: Dict[LLMProvider, BaseSchemaFormatter] = {
20
- LLMProvider.OPENAI: OpenAiJsonSchemaFormatter(),
21
- LLMProvider.MISTRAL: OpenAiJsonSchemaFormatter(),
22
- LLMProvider.DEEPSEEK: OpenAiJsonSchemaFormatter(),
23
- LLMProvider.GROK: OpenAiJsonSchemaFormatter(),
24
- LLMProvider.ANTHROPIC: AnthropicJsonSchemaFormatter(),
25
- LLMProvider.GEMINI: GeminiJsonSchemaFormatter(),
26
- }
27
- self._default_formatter = DefaultJsonSchemaFormatter()
28
- logger.info("JsonSchemaFormatterRegistry initialized.")
29
-
30
- def get_formatter(self, provider: LLMProvider) -> BaseSchemaFormatter:
31
- """
32
- Retrieves the appropriate schema formatter for a given LLM provider.
33
-
34
- Args:
35
- provider: The LLMProvider enum member.
36
-
37
- Returns:
38
- An instance of a class derived from BaseSchemaFormatter.
39
- """
40
- formatter = self._formatters.get(provider)
41
- if formatter:
42
- logger.debug(f"Found specific schema formatter for provider {provider.name}: {formatter.__class__.__name__}")
43
- return formatter
44
-
45
- logger.debug(f"No specific schema formatter for provider {provider.name}. "
46
- f"Returning default: {self._default_formatter.__class__.__name__}")
47
- return self._default_formatter
48
-
49
- def get_default_formatter(self) -> BaseSchemaFormatter:
50
- """Explicitly returns the default formatter."""
51
- return self._default_formatter
@@ -1,42 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/usage/registries/json_tool_usage_parser_registry.py
2
- import logging
3
- from typing import Dict
4
-
5
- from autobyteus.llm.providers import LLMProvider
6
- from autobyteus.tools.usage.parsers.base_parser import BaseToolUsageParser
7
- from autobyteus.tools.usage.parsers.default_json_tool_usage_parser import DefaultJsonToolUsageParser
8
- from autobyteus.tools.usage.parsers.openai_json_tool_usage_parser import OpenAiJsonToolUsageParser
9
- from autobyteus.tools.usage.parsers.gemini_json_tool_usage_parser import GeminiJsonToolUsageParser
10
- from autobyteus.utils.singleton import SingletonMeta
11
-
12
- logger = logging.getLogger(__name__)
13
-
14
- class JsonToolUsageParserRegistry(metaclass=SingletonMeta):
15
- """A singleton registry for retrieving JSON-based tool usage parsers."""
16
-
17
- def __init__(self):
18
- self._parsers: Dict[LLMProvider, BaseToolUsageParser] = {
19
- LLMProvider.OPENAI: OpenAiJsonToolUsageParser(),
20
- LLMProvider.MISTRAL: OpenAiJsonToolUsageParser(),
21
- LLMProvider.DEEPSEEK: OpenAiJsonToolUsageParser(),
22
- LLMProvider.GROK: OpenAiJsonToolUsageParser(),
23
- LLMProvider.GEMINI: GeminiJsonToolUsageParser(),
24
- }
25
- self._default_parser = DefaultJsonToolUsageParser()
26
- logger.info("JsonToolUsageParserRegistry initialized.")
27
-
28
- def get_parser(self, provider: LLMProvider) -> BaseToolUsageParser:
29
- """
30
- Retrieves the appropriate parser for a given LLM provider.
31
- """
32
- parser = self._parsers.get(provider)
33
- if parser:
34
- logger.debug(f"Found specific tool usage parser for provider {provider.name}: {parser.get_name()}")
35
- return parser
36
-
37
- logger.debug(f"No specific tool usage parser for provider {provider.name}. Returning default: {self._default_parser.get_name()}")
38
- return self._default_parser
39
-
40
- def get_default_parser(self) -> BaseToolUsageParser:
41
- """Explicitly returns the default parser."""
42
- return self._default_parser
@@ -1,30 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/usage/registries/xml_example_formatter_registry.py
2
- import logging
3
- from typing import Optional
4
-
5
- from autobyteus.llm.providers import LLMProvider
6
- from autobyteus.tools.usage.formatters.base_formatter import BaseExampleFormatter
7
- from autobyteus.tools.usage.formatters.default_xml_example_formatter import DefaultXmlExampleFormatter
8
- from autobyteus.utils.singleton import SingletonMeta
9
-
10
- logger = logging.getLogger(__name__)
11
-
12
- class XmlExampleFormatterRegistry(metaclass=SingletonMeta):
13
- """A singleton registry for retrieving XML example formatters."""
14
-
15
- def __init__(self):
16
- self._default_formatter = DefaultXmlExampleFormatter()
17
- logger.info("XmlExampleFormatterRegistry initialized.")
18
-
19
- def get_formatter(self, provider: Optional[LLMProvider] = None) -> BaseExampleFormatter:
20
- """
21
- Retrieves the appropriate XML example formatter.
22
-
23
- Args:
24
- provider: The LLMProvider enum member. This is currently ignored
25
- but is kept for API consistency and future expansion.
26
-
27
- Returns:
28
- An instance of the DefaultXmlExampleFormatter.
29
- """
30
- return self._default_formatter
@@ -1,33 +0,0 @@
1
- # file: autobyteus/autobyteus/tools/usage/registries/xml_schema_formatter_registry.py
2
- import logging
3
- from typing import Dict, Optional
4
-
5
- from autobyteus.llm.providers import LLMProvider
6
- from autobyteus.tools.usage.formatters.base_formatter import BaseSchemaFormatter
7
- from autobyteus.tools.usage.formatters.default_xml_schema_formatter import DefaultXmlSchemaFormatter
8
- from autobyteus.utils.singleton import SingletonMeta
9
-
10
- logger = logging.getLogger(__name__)
11
-
12
- class XmlSchemaFormatterRegistry(metaclass=SingletonMeta):
13
- """A singleton registry for retrieving XML schema formatters based on LLM provider."""
14
-
15
- def __init__(self):
16
- # Currently, there is only one XML format, so all providers map to it.
17
- # This structure allows for future expansion if providers diverge.
18
- self._default_formatter = DefaultXmlSchemaFormatter()
19
- logger.info("XmlSchemaFormatterRegistry initialized.")
20
-
21
- def get_formatter(self, provider: Optional[LLMProvider] = None) -> BaseSchemaFormatter:
22
- """
23
- Retrieves the appropriate XML schema formatter.
24
-
25
- Args:
26
- provider: The LLMProvider enum member. This is currently ignored
27
- but is kept for API consistency and future expansion.
28
-
29
- Returns:
30
- An instance of the DefaultXmlSchemaFormatter.
31
- """
32
- # For now, we only have one XML formatter. This always returns it.
33
- return self._default_formatter