autobyteus 1.2.0__py3-none-any.whl → 1.2.3__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 (512) hide show
  1. autobyteus/agent/agent.py +15 -5
  2. autobyteus/agent/bootstrap_steps/__init__.py +1 -3
  3. autobyteus/agent/bootstrap_steps/agent_bootstrapper.py +3 -59
  4. autobyteus/agent/bootstrap_steps/base_bootstrap_step.py +1 -4
  5. autobyteus/agent/bootstrap_steps/mcp_server_prewarming_step.py +1 -3
  6. autobyteus/agent/bootstrap_steps/system_prompt_processing_step.py +16 -13
  7. autobyteus/agent/bootstrap_steps/workspace_context_initialization_step.py +2 -4
  8. autobyteus/agent/context/agent_config.py +43 -20
  9. autobyteus/agent/context/agent_context.py +23 -18
  10. autobyteus/agent/context/agent_runtime_state.py +23 -19
  11. autobyteus/agent/events/__init__.py +16 -1
  12. autobyteus/agent/events/agent_events.py +43 -3
  13. autobyteus/agent/events/agent_input_event_queue_manager.py +79 -26
  14. autobyteus/agent/events/event_store.py +57 -0
  15. autobyteus/agent/events/notifiers.py +74 -60
  16. autobyteus/agent/events/worker_event_dispatcher.py +21 -64
  17. autobyteus/agent/factory/agent_factory.py +52 -0
  18. autobyteus/agent/handlers/__init__.py +2 -0
  19. autobyteus/agent/handlers/approved_tool_invocation_event_handler.py +51 -34
  20. autobyteus/agent/handlers/bootstrap_event_handler.py +155 -0
  21. autobyteus/agent/handlers/inter_agent_message_event_handler.py +10 -0
  22. autobyteus/agent/handlers/lifecycle_event_logger.py +19 -11
  23. autobyteus/agent/handlers/llm_complete_response_received_event_handler.py +10 -15
  24. autobyteus/agent/handlers/llm_user_message_ready_event_handler.py +188 -48
  25. autobyteus/agent/handlers/tool_execution_approval_event_handler.py +0 -10
  26. autobyteus/agent/handlers/tool_invocation_request_event_handler.py +53 -48
  27. autobyteus/agent/handlers/tool_result_event_handler.py +7 -8
  28. autobyteus/agent/handlers/user_input_message_event_handler.py +10 -3
  29. autobyteus/agent/input_processor/memory_ingest_input_processor.py +40 -0
  30. autobyteus/agent/lifecycle/__init__.py +12 -0
  31. autobyteus/agent/lifecycle/base_processor.py +109 -0
  32. autobyteus/agent/lifecycle/events.py +35 -0
  33. autobyteus/agent/lifecycle/processor_definition.py +36 -0
  34. autobyteus/agent/lifecycle/processor_registry.py +106 -0
  35. autobyteus/agent/llm_request_assembler.py +98 -0
  36. autobyteus/agent/llm_response_processor/__init__.py +1 -8
  37. autobyteus/agent/message/context_file_type.py +1 -1
  38. autobyteus/agent/message/send_message_to.py +5 -4
  39. autobyteus/agent/runtime/agent_runtime.py +29 -21
  40. autobyteus/agent/runtime/agent_worker.py +98 -19
  41. autobyteus/agent/shutdown_steps/__init__.py +2 -0
  42. autobyteus/agent/shutdown_steps/agent_shutdown_orchestrator.py +2 -0
  43. autobyteus/agent/shutdown_steps/tool_cleanup_step.py +58 -0
  44. autobyteus/agent/status/__init__.py +14 -0
  45. autobyteus/agent/status/manager.py +93 -0
  46. autobyteus/agent/status/status_deriver.py +96 -0
  47. autobyteus/agent/{phases/phase_enum.py → status/status_enum.py} +16 -16
  48. autobyteus/agent/status/status_update_utils.py +73 -0
  49. autobyteus/agent/streaming/__init__.py +52 -5
  50. autobyteus/agent/streaming/adapters/__init__.py +18 -0
  51. autobyteus/agent/streaming/adapters/invocation_adapter.py +184 -0
  52. autobyteus/agent/streaming/adapters/tool_call_parsing.py +163 -0
  53. autobyteus/agent/streaming/adapters/tool_syntax_registry.py +67 -0
  54. autobyteus/agent/streaming/agent_event_stream.py +3 -178
  55. autobyteus/agent/streaming/api_tool_call/__init__.py +16 -0
  56. autobyteus/agent/streaming/api_tool_call/file_content_streamer.py +56 -0
  57. autobyteus/agent/streaming/api_tool_call/json_string_field_extractor.py +175 -0
  58. autobyteus/agent/streaming/api_tool_call_streaming_response_handler.py +4 -0
  59. autobyteus/agent/streaming/events/__init__.py +6 -0
  60. autobyteus/agent/streaming/events/stream_event_payloads.py +284 -0
  61. autobyteus/agent/streaming/events/stream_events.py +141 -0
  62. autobyteus/agent/streaming/handlers/__init__.py +15 -0
  63. autobyteus/agent/streaming/handlers/api_tool_call_streaming_response_handler.py +303 -0
  64. autobyteus/agent/streaming/handlers/parsing_streaming_response_handler.py +107 -0
  65. autobyteus/agent/streaming/handlers/pass_through_streaming_response_handler.py +107 -0
  66. autobyteus/agent/streaming/handlers/streaming_handler_factory.py +177 -0
  67. autobyteus/agent/streaming/handlers/streaming_response_handler.py +58 -0
  68. autobyteus/agent/streaming/parser/__init__.py +61 -0
  69. autobyteus/agent/streaming/parser/event_emitter.py +181 -0
  70. autobyteus/agent/streaming/parser/events.py +4 -0
  71. autobyteus/agent/streaming/parser/invocation_adapter.py +4 -0
  72. autobyteus/agent/streaming/parser/json_parsing_strategies/__init__.py +19 -0
  73. autobyteus/agent/streaming/parser/json_parsing_strategies/base.py +32 -0
  74. autobyteus/agent/streaming/parser/json_parsing_strategies/default.py +34 -0
  75. autobyteus/agent/streaming/parser/json_parsing_strategies/gemini.py +31 -0
  76. autobyteus/agent/streaming/parser/json_parsing_strategies/openai.py +64 -0
  77. autobyteus/agent/streaming/parser/json_parsing_strategies/registry.py +75 -0
  78. autobyteus/agent/streaming/parser/parser_context.py +227 -0
  79. autobyteus/agent/streaming/parser/parser_factory.py +132 -0
  80. autobyteus/agent/streaming/parser/sentinel_format.py +7 -0
  81. autobyteus/agent/streaming/parser/state_factory.py +62 -0
  82. autobyteus/agent/streaming/parser/states/__init__.py +1 -0
  83. autobyteus/agent/streaming/parser/states/base_state.py +60 -0
  84. autobyteus/agent/streaming/parser/states/custom_xml_tag_run_bash_parsing_state.py +38 -0
  85. autobyteus/agent/streaming/parser/states/custom_xml_tag_write_file_parsing_state.py +55 -0
  86. autobyteus/agent/streaming/parser/states/delimited_content_state.py +146 -0
  87. autobyteus/agent/streaming/parser/states/json_initialization_state.py +144 -0
  88. autobyteus/agent/streaming/parser/states/json_tool_parsing_state.py +137 -0
  89. autobyteus/agent/streaming/parser/states/sentinel_content_state.py +30 -0
  90. autobyteus/agent/streaming/parser/states/sentinel_initialization_state.py +117 -0
  91. autobyteus/agent/streaming/parser/states/text_state.py +78 -0
  92. autobyteus/agent/streaming/parser/states/xml_patch_file_tool_parsing_state.py +328 -0
  93. autobyteus/agent/streaming/parser/states/xml_run_bash_tool_parsing_state.py +129 -0
  94. autobyteus/agent/streaming/parser/states/xml_tag_initialization_state.py +151 -0
  95. autobyteus/agent/streaming/parser/states/xml_tool_parsing_state.py +63 -0
  96. autobyteus/agent/streaming/parser/states/xml_write_file_tool_parsing_state.py +343 -0
  97. autobyteus/agent/streaming/parser/strategies/__init__.py +17 -0
  98. autobyteus/agent/streaming/parser/strategies/base.py +24 -0
  99. autobyteus/agent/streaming/parser/strategies/json_tool_strategy.py +26 -0
  100. autobyteus/agent/streaming/parser/strategies/registry.py +28 -0
  101. autobyteus/agent/streaming/parser/strategies/sentinel_strategy.py +23 -0
  102. autobyteus/agent/streaming/parser/strategies/xml_tag_strategy.py +21 -0
  103. autobyteus/agent/streaming/parser/stream_scanner.py +167 -0
  104. autobyteus/agent/streaming/parser/streaming_parser.py +212 -0
  105. autobyteus/agent/streaming/parser/tool_call_parsing.py +4 -0
  106. autobyteus/agent/streaming/parser/tool_constants.py +7 -0
  107. autobyteus/agent/streaming/parser/tool_syntax_registry.py +4 -0
  108. autobyteus/agent/streaming/parser/xml_tool_parsing_state_registry.py +55 -0
  109. autobyteus/agent/streaming/parsing_streaming_response_handler.py +4 -0
  110. autobyteus/agent/streaming/pass_through_streaming_response_handler.py +4 -0
  111. autobyteus/agent/streaming/queue_streamer.py +3 -57
  112. autobyteus/agent/streaming/segments/__init__.py +5 -0
  113. autobyteus/agent/streaming/segments/segment_events.py +81 -0
  114. autobyteus/agent/streaming/stream_event_payloads.py +2 -198
  115. autobyteus/agent/streaming/stream_events.py +3 -128
  116. autobyteus/agent/streaming/streaming_handler_factory.py +4 -0
  117. autobyteus/agent/streaming/streaming_response_handler.py +4 -0
  118. autobyteus/agent/streaming/streams/__init__.py +5 -0
  119. autobyteus/agent/streaming/streams/agent_event_stream.py +197 -0
  120. autobyteus/agent/streaming/utils/__init__.py +5 -0
  121. autobyteus/agent/streaming/utils/queue_streamer.py +59 -0
  122. autobyteus/agent/system_prompt_processor/__init__.py +2 -0
  123. autobyteus/agent/system_prompt_processor/available_skills_processor.py +96 -0
  124. autobyteus/agent/system_prompt_processor/base_processor.py +1 -1
  125. autobyteus/agent/system_prompt_processor/processor_meta.py +15 -2
  126. autobyteus/agent/system_prompt_processor/tool_manifest_injector_processor.py +39 -58
  127. autobyteus/agent/token_budget.py +56 -0
  128. autobyteus/agent/tool_execution_result_processor/memory_ingest_tool_result_processor.py +29 -0
  129. autobyteus/agent/tool_invocation.py +16 -40
  130. autobyteus/agent/tool_invocation_preprocessor/__init__.py +9 -0
  131. autobyteus/agent/tool_invocation_preprocessor/base_preprocessor.py +45 -0
  132. autobyteus/agent/tool_invocation_preprocessor/processor_definition.py +15 -0
  133. autobyteus/agent/tool_invocation_preprocessor/processor_meta.py +33 -0
  134. autobyteus/agent/tool_invocation_preprocessor/processor_registry.py +60 -0
  135. autobyteus/agent/utils/wait_for_idle.py +12 -14
  136. autobyteus/agent/workspace/base_workspace.py +6 -27
  137. autobyteus/agent_team/agent_team.py +3 -3
  138. autobyteus/agent_team/agent_team_builder.py +1 -41
  139. autobyteus/agent_team/bootstrap_steps/__init__.py +0 -4
  140. autobyteus/agent_team/bootstrap_steps/agent_configuration_preparation_step.py +8 -18
  141. autobyteus/agent_team/bootstrap_steps/agent_team_bootstrapper.py +4 -16
  142. autobyteus/agent_team/bootstrap_steps/base_agent_team_bootstrap_step.py +1 -2
  143. autobyteus/agent_team/bootstrap_steps/coordinator_initialization_step.py +1 -2
  144. autobyteus/agent_team/bootstrap_steps/task_notifier_initialization_step.py +5 -6
  145. autobyteus/agent_team/bootstrap_steps/team_context_initialization_step.py +15 -15
  146. autobyteus/agent_team/context/agent_team_config.py +6 -3
  147. autobyteus/agent_team/context/agent_team_context.py +25 -3
  148. autobyteus/agent_team/context/agent_team_runtime_state.py +11 -8
  149. autobyteus/agent_team/events/__init__.py +11 -0
  150. autobyteus/agent_team/events/agent_team_event_dispatcher.py +22 -9
  151. autobyteus/agent_team/events/agent_team_events.py +16 -0
  152. autobyteus/agent_team/events/event_store.py +57 -0
  153. autobyteus/agent_team/factory/agent_team_factory.py +8 -0
  154. autobyteus/agent_team/handlers/inter_agent_message_request_event_handler.py +18 -2
  155. autobyteus/agent_team/handlers/lifecycle_agent_team_event_handler.py +21 -5
  156. autobyteus/agent_team/handlers/process_user_message_event_handler.py +17 -8
  157. autobyteus/agent_team/handlers/tool_approval_team_event_handler.py +19 -4
  158. autobyteus/agent_team/runtime/agent_team_runtime.py +41 -10
  159. autobyteus/agent_team/runtime/agent_team_worker.py +69 -5
  160. autobyteus/agent_team/status/__init__.py +14 -0
  161. autobyteus/agent_team/status/agent_team_status.py +18 -0
  162. autobyteus/agent_team/status/agent_team_status_manager.py +33 -0
  163. autobyteus/agent_team/status/status_deriver.py +62 -0
  164. autobyteus/agent_team/status/status_update_utils.py +42 -0
  165. autobyteus/agent_team/streaming/__init__.py +2 -2
  166. autobyteus/agent_team/streaming/agent_team_event_notifier.py +10 -10
  167. autobyteus/agent_team/streaming/agent_team_stream_event_payloads.py +7 -7
  168. autobyteus/agent_team/streaming/agent_team_stream_events.py +11 -11
  169. autobyteus/agent_team/system_prompt_processor/__init__.py +6 -0
  170. autobyteus/agent_team/system_prompt_processor/team_manifest_injector_processor.py +76 -0
  171. autobyteus/agent_team/task_notification/activation_policy.py +1 -1
  172. autobyteus/agent_team/task_notification/system_event_driven_agent_task_notifier.py +22 -22
  173. autobyteus/agent_team/task_notification/task_notification_mode.py +20 -1
  174. autobyteus/agent_team/utils/wait_for_idle.py +4 -4
  175. autobyteus/cli/agent_cli.py +18 -10
  176. autobyteus/cli/agent_team_tui/app.py +18 -15
  177. autobyteus/cli/agent_team_tui/state.py +21 -23
  178. autobyteus/cli/agent_team_tui/widgets/agent_list_sidebar.py +15 -15
  179. autobyteus/cli/agent_team_tui/widgets/focus_pane.py +146 -39
  180. autobyteus/cli/agent_team_tui/widgets/renderables.py +1 -1
  181. autobyteus/cli/agent_team_tui/widgets/shared.py +26 -26
  182. autobyteus/cli/agent_team_tui/widgets/{task_board_panel.py → task_plan_panel.py} +5 -5
  183. autobyteus/cli/cli_display.py +193 -44
  184. autobyteus/cli/workflow_tui/app.py +9 -10
  185. autobyteus/cli/workflow_tui/state.py +14 -16
  186. autobyteus/cli/workflow_tui/widgets/agent_list_sidebar.py +15 -15
  187. autobyteus/cli/workflow_tui/widgets/focus_pane.py +137 -35
  188. autobyteus/cli/workflow_tui/widgets/renderables.py +1 -1
  189. autobyteus/cli/workflow_tui/widgets/shared.py +25 -25
  190. autobyteus/clients/autobyteus_client.py +94 -1
  191. autobyteus/events/event_types.py +15 -21
  192. autobyteus/llm/api/autobyteus_llm.py +33 -29
  193. autobyteus/llm/api/claude_llm.py +142 -36
  194. autobyteus/llm/api/gemini_llm.py +163 -59
  195. autobyteus/llm/api/grok_llm.py +1 -1
  196. autobyteus/llm/api/minimax_llm.py +26 -0
  197. autobyteus/llm/api/mistral_llm.py +113 -87
  198. autobyteus/llm/api/ollama_llm.py +9 -42
  199. autobyteus/llm/api/openai_compatible_llm.py +127 -91
  200. autobyteus/llm/api/openai_llm.py +3 -3
  201. autobyteus/llm/api/openai_responses_llm.py +324 -0
  202. autobyteus/llm/api/zhipu_llm.py +21 -2
  203. autobyteus/llm/autobyteus_provider.py +70 -60
  204. autobyteus/llm/base_llm.py +85 -81
  205. autobyteus/llm/converters/__init__.py +14 -0
  206. autobyteus/llm/converters/anthropic_tool_call_converter.py +37 -0
  207. autobyteus/llm/converters/gemini_tool_call_converter.py +57 -0
  208. autobyteus/llm/converters/mistral_tool_call_converter.py +37 -0
  209. autobyteus/llm/converters/openai_tool_call_converter.py +38 -0
  210. autobyteus/llm/extensions/base_extension.py +6 -12
  211. autobyteus/llm/extensions/token_usage_tracking_extension.py +45 -18
  212. autobyteus/llm/llm_factory.py +282 -204
  213. autobyteus/llm/lmstudio_provider.py +60 -49
  214. autobyteus/llm/models.py +35 -2
  215. autobyteus/llm/ollama_provider.py +60 -49
  216. autobyteus/llm/ollama_provider_resolver.py +0 -1
  217. autobyteus/llm/prompt_renderers/__init__.py +19 -0
  218. autobyteus/llm/prompt_renderers/anthropic_prompt_renderer.py +104 -0
  219. autobyteus/llm/prompt_renderers/autobyteus_prompt_renderer.py +19 -0
  220. autobyteus/llm/prompt_renderers/base_prompt_renderer.py +10 -0
  221. autobyteus/llm/prompt_renderers/gemini_prompt_renderer.py +63 -0
  222. autobyteus/llm/prompt_renderers/mistral_prompt_renderer.py +87 -0
  223. autobyteus/llm/prompt_renderers/ollama_prompt_renderer.py +51 -0
  224. autobyteus/llm/prompt_renderers/openai_chat_renderer.py +97 -0
  225. autobyteus/llm/prompt_renderers/openai_responses_renderer.py +101 -0
  226. autobyteus/llm/providers.py +1 -3
  227. autobyteus/llm/token_counter/claude_token_counter.py +56 -25
  228. autobyteus/llm/token_counter/mistral_token_counter.py +12 -8
  229. autobyteus/llm/token_counter/openai_token_counter.py +24 -5
  230. autobyteus/llm/token_counter/token_counter_factory.py +12 -5
  231. autobyteus/llm/utils/llm_config.py +6 -12
  232. autobyteus/llm/utils/media_payload_formatter.py +27 -20
  233. autobyteus/llm/utils/messages.py +55 -3
  234. autobyteus/llm/utils/response_types.py +3 -0
  235. autobyteus/llm/utils/tool_call_delta.py +31 -0
  236. autobyteus/memory/__init__.py +32 -0
  237. autobyteus/memory/active_transcript.py +69 -0
  238. autobyteus/memory/compaction/__init__.py +9 -0
  239. autobyteus/memory/compaction/compaction_result.py +8 -0
  240. autobyteus/memory/compaction/compactor.py +89 -0
  241. autobyteus/memory/compaction/summarizer.py +11 -0
  242. autobyteus/memory/compaction_snapshot_builder.py +84 -0
  243. autobyteus/memory/memory_manager.py +183 -0
  244. autobyteus/memory/models/__init__.py +14 -0
  245. autobyteus/memory/models/episodic_item.py +41 -0
  246. autobyteus/memory/models/memory_types.py +7 -0
  247. autobyteus/memory/models/raw_trace_item.py +79 -0
  248. autobyteus/memory/models/semantic_item.py +41 -0
  249. autobyteus/memory/models/tool_interaction.py +20 -0
  250. autobyteus/memory/policies/__init__.py +5 -0
  251. autobyteus/memory/policies/compaction_policy.py +16 -0
  252. autobyteus/memory/retrieval/__init__.py +7 -0
  253. autobyteus/memory/retrieval/memory_bundle.py +11 -0
  254. autobyteus/memory/retrieval/retriever.py +13 -0
  255. autobyteus/memory/store/__init__.py +7 -0
  256. autobyteus/memory/store/base_store.py +14 -0
  257. autobyteus/memory/store/file_store.py +98 -0
  258. autobyteus/memory/tool_interaction_builder.py +46 -0
  259. autobyteus/memory/turn_tracker.py +9 -0
  260. autobyteus/multimedia/audio/api/__init__.py +3 -2
  261. autobyteus/multimedia/audio/api/autobyteus_audio_client.py +19 -5
  262. autobyteus/multimedia/audio/api/gemini_audio_client.py +108 -16
  263. autobyteus/multimedia/audio/api/openai_audio_client.py +112 -0
  264. autobyteus/multimedia/audio/audio_client_factory.py +84 -9
  265. autobyteus/multimedia/audio/audio_model.py +2 -1
  266. autobyteus/multimedia/image/api/autobyteus_image_client.py +19 -5
  267. autobyteus/multimedia/image/api/gemini_image_client.py +38 -17
  268. autobyteus/multimedia/image/api/openai_image_client.py +125 -43
  269. autobyteus/multimedia/image/autobyteus_image_provider.py +2 -1
  270. autobyteus/multimedia/image/image_client_factory.py +47 -15
  271. autobyteus/multimedia/image/image_model.py +5 -2
  272. autobyteus/multimedia/providers.py +3 -2
  273. autobyteus/skills/loader.py +71 -0
  274. autobyteus/skills/model.py +11 -0
  275. autobyteus/skills/registry.py +70 -0
  276. autobyteus/task_management/__init__.py +43 -20
  277. autobyteus/task_management/{base_task_board.py → base_task_plan.py} +16 -13
  278. autobyteus/task_management/converters/__init__.py +2 -2
  279. autobyteus/task_management/converters/{task_board_converter.py → task_plan_converter.py} +13 -13
  280. autobyteus/task_management/events.py +7 -7
  281. autobyteus/task_management/{in_memory_task_board.py → in_memory_task_plan.py} +34 -22
  282. autobyteus/task_management/schemas/__init__.py +3 -0
  283. autobyteus/task_management/schemas/task_status_report.py +2 -2
  284. autobyteus/task_management/schemas/todo_definition.py +15 -0
  285. autobyteus/task_management/todo.py +29 -0
  286. autobyteus/task_management/todo_list.py +75 -0
  287. autobyteus/task_management/tools/__init__.py +24 -8
  288. autobyteus/task_management/tools/task_tools/__init__.py +19 -0
  289. autobyteus/task_management/tools/{assign_task_to.py → task_tools/assign_task_to.py} +18 -18
  290. autobyteus/task_management/tools/{publish_task.py → task_tools/create_task.py} +16 -18
  291. autobyteus/task_management/tools/{publish_tasks.py → task_tools/create_tasks.py} +19 -19
  292. autobyteus/task_management/tools/{get_my_tasks.py → task_tools/get_my_tasks.py} +15 -15
  293. autobyteus/task_management/tools/{get_task_board_status.py → task_tools/get_task_plan_status.py} +16 -16
  294. autobyteus/task_management/tools/{update_task_status.py → task_tools/update_task_status.py} +16 -16
  295. autobyteus/task_management/tools/todo_tools/__init__.py +18 -0
  296. autobyteus/task_management/tools/todo_tools/add_todo.py +78 -0
  297. autobyteus/task_management/tools/todo_tools/create_todo_list.py +79 -0
  298. autobyteus/task_management/tools/todo_tools/get_todo_list.py +55 -0
  299. autobyteus/task_management/tools/todo_tools/update_todo_status.py +85 -0
  300. autobyteus/tools/__init__.py +43 -52
  301. autobyteus/tools/base_tool.py +7 -0
  302. autobyteus/tools/file/__init__.py +9 -0
  303. autobyteus/tools/file/patch_file.py +149 -0
  304. autobyteus/tools/file/{file_reader.py → read_file.py} +38 -7
  305. autobyteus/tools/file/{file_writer.py → write_file.py} +7 -4
  306. autobyteus/tools/functional_tool.py +53 -14
  307. autobyteus/tools/mcp/__init__.py +2 -0
  308. autobyteus/tools/mcp/config_service.py +5 -1
  309. autobyteus/tools/mcp/server/__init__.py +2 -0
  310. autobyteus/tools/mcp/server/http_managed_mcp_server.py +1 -1
  311. autobyteus/tools/mcp/server/websocket_managed_mcp_server.py +141 -0
  312. autobyteus/tools/mcp/server_instance_manager.py +8 -1
  313. autobyteus/tools/mcp/tool.py +3 -3
  314. autobyteus/tools/mcp/tool_registrar.py +5 -2
  315. autobyteus/tools/mcp/types.py +61 -0
  316. autobyteus/tools/multimedia/__init__.py +2 -1
  317. autobyteus/tools/multimedia/audio_tools.py +72 -19
  318. autobyteus/tools/{download_media_tool.py → multimedia/download_media_tool.py} +21 -7
  319. autobyteus/tools/multimedia/image_tools.py +248 -64
  320. autobyteus/tools/multimedia/media_reader_tool.py +1 -1
  321. autobyteus/tools/operation_executor/journal_manager.py +107 -0
  322. autobyteus/tools/operation_executor/operation_event_buffer.py +57 -0
  323. autobyteus/tools/operation_executor/operation_event_producer.py +29 -0
  324. autobyteus/tools/operation_executor/operation_executor.py +58 -0
  325. autobyteus/tools/registry/tool_definition.py +108 -14
  326. autobyteus/tools/registry/tool_registry.py +29 -0
  327. autobyteus/tools/search/__init__.py +17 -0
  328. autobyteus/tools/search/base_strategy.py +35 -0
  329. autobyteus/tools/search/client.py +24 -0
  330. autobyteus/tools/search/factory.py +81 -0
  331. autobyteus/tools/search/google_cse_strategy.py +68 -0
  332. autobyteus/tools/search/providers.py +10 -0
  333. autobyteus/tools/search/serpapi_strategy.py +65 -0
  334. autobyteus/tools/search/serper_strategy.py +87 -0
  335. autobyteus/tools/search_tool.py +83 -0
  336. autobyteus/tools/skill/load_skill.py +50 -0
  337. autobyteus/tools/terminal/__init__.py +45 -0
  338. autobyteus/tools/terminal/ansi_utils.py +32 -0
  339. autobyteus/tools/terminal/background_process_manager.py +233 -0
  340. autobyteus/tools/terminal/output_buffer.py +105 -0
  341. autobyteus/tools/terminal/prompt_detector.py +63 -0
  342. autobyteus/tools/terminal/pty_session.py +241 -0
  343. autobyteus/tools/terminal/session_factory.py +20 -0
  344. autobyteus/tools/terminal/terminal_session_manager.py +226 -0
  345. autobyteus/tools/terminal/tools/__init__.py +13 -0
  346. autobyteus/tools/terminal/tools/get_process_output.py +81 -0
  347. autobyteus/tools/terminal/tools/run_bash.py +109 -0
  348. autobyteus/tools/terminal/tools/start_background_process.py +104 -0
  349. autobyteus/tools/terminal/tools/stop_background_process.py +67 -0
  350. autobyteus/tools/terminal/types.py +54 -0
  351. autobyteus/tools/terminal/wsl_tmux_session.py +221 -0
  352. autobyteus/tools/terminal/wsl_utils.py +156 -0
  353. autobyteus/tools/tool_meta.py +4 -24
  354. autobyteus/tools/transaction_management/backup_handler.py +48 -0
  355. autobyteus/tools/transaction_management/operation_lifecycle_manager.py +62 -0
  356. autobyteus/tools/usage/__init__.py +1 -2
  357. autobyteus/tools/usage/formatters/__init__.py +17 -1
  358. autobyteus/tools/usage/formatters/base_formatter.py +8 -0
  359. autobyteus/tools/usage/formatters/default_xml_schema_formatter.py +2 -2
  360. autobyteus/tools/usage/formatters/mistral_json_schema_formatter.py +18 -0
  361. autobyteus/tools/usage/formatters/patch_file_xml_example_formatter.py +64 -0
  362. autobyteus/tools/usage/formatters/patch_file_xml_schema_formatter.py +31 -0
  363. autobyteus/tools/usage/formatters/run_bash_xml_example_formatter.py +32 -0
  364. autobyteus/tools/usage/formatters/run_bash_xml_schema_formatter.py +36 -0
  365. autobyteus/tools/usage/formatters/write_file_xml_example_formatter.py +53 -0
  366. autobyteus/tools/usage/formatters/write_file_xml_schema_formatter.py +31 -0
  367. autobyteus/tools/usage/providers/tool_manifest_provider.py +10 -10
  368. autobyteus/tools/usage/registries/__init__.py +1 -3
  369. autobyteus/tools/usage/registries/tool_formatting_registry.py +115 -8
  370. autobyteus/tools/usage/tool_schema_provider.py +51 -0
  371. autobyteus/tools/web/__init__.py +4 -0
  372. autobyteus/tools/web/read_url_tool.py +80 -0
  373. autobyteus/utils/diff_utils.py +271 -0
  374. autobyteus/utils/download_utils.py +109 -0
  375. autobyteus/utils/file_utils.py +57 -2
  376. autobyteus/utils/gemini_helper.py +56 -0
  377. autobyteus/utils/gemini_model_mapping.py +71 -0
  378. autobyteus/utils/llm_output_formatter.py +75 -0
  379. autobyteus/utils/tool_call_format.py +36 -0
  380. autobyteus/workflow/agentic_workflow.py +3 -3
  381. autobyteus/workflow/bootstrap_steps/agent_tool_injection_step.py +2 -2
  382. autobyteus/workflow/bootstrap_steps/base_workflow_bootstrap_step.py +2 -2
  383. autobyteus/workflow/bootstrap_steps/coordinator_initialization_step.py +2 -2
  384. autobyteus/workflow/bootstrap_steps/coordinator_prompt_preparation_step.py +4 -11
  385. autobyteus/workflow/bootstrap_steps/workflow_bootstrapper.py +6 -6
  386. autobyteus/workflow/bootstrap_steps/workflow_runtime_queue_initialization_step.py +2 -2
  387. autobyteus/workflow/context/workflow_context.py +3 -3
  388. autobyteus/workflow/context/workflow_runtime_state.py +5 -5
  389. autobyteus/workflow/events/workflow_event_dispatcher.py +5 -5
  390. autobyteus/workflow/handlers/lifecycle_workflow_event_handler.py +3 -3
  391. autobyteus/workflow/handlers/process_user_message_event_handler.py +5 -5
  392. autobyteus/workflow/handlers/tool_approval_workflow_event_handler.py +2 -2
  393. autobyteus/workflow/runtime/workflow_runtime.py +8 -8
  394. autobyteus/workflow/runtime/workflow_worker.py +3 -3
  395. autobyteus/workflow/status/__init__.py +11 -0
  396. autobyteus/workflow/status/workflow_status.py +19 -0
  397. autobyteus/workflow/status/workflow_status_manager.py +48 -0
  398. autobyteus/workflow/streaming/__init__.py +2 -2
  399. autobyteus/workflow/streaming/workflow_event_notifier.py +7 -7
  400. autobyteus/workflow/streaming/workflow_stream_event_payloads.py +4 -4
  401. autobyteus/workflow/streaming/workflow_stream_events.py +3 -3
  402. autobyteus/workflow/utils/wait_for_idle.py +4 -4
  403. autobyteus-1.2.3.dist-info/METADATA +293 -0
  404. autobyteus-1.2.3.dist-info/RECORD +600 -0
  405. {autobyteus-1.2.0.dist-info → autobyteus-1.2.3.dist-info}/WHEEL +1 -1
  406. {autobyteus-1.2.0.dist-info → autobyteus-1.2.3.dist-info}/top_level.txt +0 -1
  407. autobyteus/agent/bootstrap_steps/agent_runtime_queue_initialization_step.py +0 -57
  408. autobyteus/agent/hooks/__init__.py +0 -16
  409. autobyteus/agent/hooks/base_phase_hook.py +0 -78
  410. autobyteus/agent/hooks/hook_definition.py +0 -36
  411. autobyteus/agent/hooks/hook_meta.py +0 -37
  412. autobyteus/agent/hooks/hook_registry.py +0 -106
  413. autobyteus/agent/llm_response_processor/provider_aware_tool_usage_processor.py +0 -103
  414. autobyteus/agent/phases/__init__.py +0 -18
  415. autobyteus/agent/phases/discover.py +0 -53
  416. autobyteus/agent/phases/manager.py +0 -265
  417. autobyteus/agent/phases/transition_decorator.py +0 -40
  418. autobyteus/agent/phases/transition_info.py +0 -33
  419. autobyteus/agent/remote_agent.py +0 -244
  420. autobyteus/agent/workspace/workspace_definition.py +0 -36
  421. autobyteus/agent/workspace/workspace_meta.py +0 -37
  422. autobyteus/agent/workspace/workspace_registry.py +0 -72
  423. autobyteus/agent_team/bootstrap_steps/agent_team_runtime_queue_initialization_step.py +0 -25
  424. autobyteus/agent_team/bootstrap_steps/coordinator_prompt_preparation_step.py +0 -85
  425. autobyteus/agent_team/phases/__init__.py +0 -11
  426. autobyteus/agent_team/phases/agent_team_operational_phase.py +0 -19
  427. autobyteus/agent_team/phases/agent_team_phase_manager.py +0 -48
  428. autobyteus/llm/api/bedrock_llm.py +0 -92
  429. autobyteus/llm/api/groq_llm.py +0 -94
  430. autobyteus/llm/api/nvidia_llm.py +0 -108
  431. autobyteus/llm/utils/token_pricing_config.py +0 -87
  432. autobyteus/person/examples/sample_persons.py +0 -14
  433. autobyteus/person/examples/sample_roles.py +0 -14
  434. autobyteus/person/person.py +0 -29
  435. autobyteus/person/role.py +0 -14
  436. autobyteus/rpc/__init__.py +0 -73
  437. autobyteus/rpc/client/__init__.py +0 -17
  438. autobyteus/rpc/client/abstract_client_connection.py +0 -124
  439. autobyteus/rpc/client/client_connection_manager.py +0 -153
  440. autobyteus/rpc/client/sse_client_connection.py +0 -306
  441. autobyteus/rpc/client/stdio_client_connection.py +0 -280
  442. autobyteus/rpc/config/__init__.py +0 -13
  443. autobyteus/rpc/config/agent_server_config.py +0 -153
  444. autobyteus/rpc/config/agent_server_registry.py +0 -152
  445. autobyteus/rpc/hosting.py +0 -244
  446. autobyteus/rpc/protocol.py +0 -244
  447. autobyteus/rpc/server/__init__.py +0 -20
  448. autobyteus/rpc/server/agent_server_endpoint.py +0 -181
  449. autobyteus/rpc/server/base_method_handler.py +0 -40
  450. autobyteus/rpc/server/method_handlers.py +0 -259
  451. autobyteus/rpc/server/sse_server_handler.py +0 -182
  452. autobyteus/rpc/server/stdio_server_handler.py +0 -151
  453. autobyteus/rpc/server_main.py +0 -198
  454. autobyteus/rpc/transport_type.py +0 -13
  455. autobyteus/tools/bash/__init__.py +0 -2
  456. autobyteus/tools/bash/bash_executor.py +0 -100
  457. autobyteus/tools/browser/__init__.py +0 -2
  458. autobyteus/tools/browser/session_aware/__init__.py +0 -0
  459. autobyteus/tools/browser/session_aware/browser_session_aware_navigate_to.py +0 -75
  460. autobyteus/tools/browser/session_aware/browser_session_aware_tool.py +0 -30
  461. autobyteus/tools/browser/session_aware/browser_session_aware_web_element_trigger.py +0 -154
  462. autobyteus/tools/browser/session_aware/browser_session_aware_webpage_reader.py +0 -89
  463. autobyteus/tools/browser/session_aware/browser_session_aware_webpage_screenshot_taker.py +0 -107
  464. autobyteus/tools/browser/session_aware/factory/__init__.py +0 -0
  465. autobyteus/tools/browser/session_aware/factory/browser_session_aware_web_element_trigger_factory.py +0 -14
  466. autobyteus/tools/browser/session_aware/factory/browser_session_aware_webpage_reader_factory.py +0 -26
  467. autobyteus/tools/browser/session_aware/factory/browser_session_aware_webpage_screenshot_taker_factory.py +0 -14
  468. autobyteus/tools/browser/session_aware/shared_browser_session.py +0 -11
  469. autobyteus/tools/browser/session_aware/shared_browser_session_manager.py +0 -25
  470. autobyteus/tools/browser/session_aware/web_element_action.py +0 -20
  471. autobyteus/tools/browser/standalone/__init__.py +0 -6
  472. autobyteus/tools/browser/standalone/factory/__init__.py +0 -0
  473. autobyteus/tools/browser/standalone/factory/webpage_reader_factory.py +0 -25
  474. autobyteus/tools/browser/standalone/factory/webpage_screenshot_taker_factory.py +0 -14
  475. autobyteus/tools/browser/standalone/navigate_to.py +0 -80
  476. autobyteus/tools/browser/standalone/web_page_pdf_generator.py +0 -97
  477. autobyteus/tools/browser/standalone/webpage_image_downloader.py +0 -165
  478. autobyteus/tools/browser/standalone/webpage_reader.py +0 -101
  479. autobyteus/tools/browser/standalone/webpage_screenshot_taker.py +0 -101
  480. autobyteus/tools/file/file_editor.py +0 -200
  481. autobyteus/tools/google_search.py +0 -149
  482. autobyteus/tools/timer.py +0 -171
  483. autobyteus/tools/usage/parsers/__init__.py +0 -22
  484. autobyteus/tools/usage/parsers/_json_extractor.py +0 -99
  485. autobyteus/tools/usage/parsers/_string_decoders.py +0 -18
  486. autobyteus/tools/usage/parsers/anthropic_xml_tool_usage_parser.py +0 -10
  487. autobyteus/tools/usage/parsers/base_parser.py +0 -41
  488. autobyteus/tools/usage/parsers/default_json_tool_usage_parser.py +0 -83
  489. autobyteus/tools/usage/parsers/default_xml_tool_usage_parser.py +0 -316
  490. autobyteus/tools/usage/parsers/exceptions.py +0 -13
  491. autobyteus/tools/usage/parsers/gemini_json_tool_usage_parser.py +0 -77
  492. autobyteus/tools/usage/parsers/openai_json_tool_usage_parser.py +0 -149
  493. autobyteus/tools/usage/parsers/provider_aware_tool_usage_parser.py +0 -59
  494. autobyteus/tools/usage/registries/tool_usage_parser_registry.py +0 -62
  495. autobyteus/workflow/phases/__init__.py +0 -11
  496. autobyteus/workflow/phases/workflow_operational_phase.py +0 -19
  497. autobyteus/workflow/phases/workflow_phase_manager.py +0 -48
  498. autobyteus-1.2.0.dist-info/METADATA +0 -205
  499. autobyteus-1.2.0.dist-info/RECORD +0 -496
  500. examples/__init__.py +0 -1
  501. examples/agent_team/__init__.py +0 -1
  502. examples/discover_phase_transitions.py +0 -104
  503. examples/run_browser_agent.py +0 -262
  504. examples/run_google_slides_agent.py +0 -287
  505. examples/run_mcp_browser_client.py +0 -174
  506. examples/run_mcp_google_slides_client.py +0 -270
  507. examples/run_mcp_list_tools.py +0 -189
  508. examples/run_poem_writer.py +0 -284
  509. examples/run_sqlite_agent.py +0 -295
  510. /autobyteus/{person → skills}/__init__.py +0 -0
  511. /autobyteus/{person/examples → tools/skill}/__init__.py +0 -0
  512. {autobyteus-1.2.0.dist-info → autobyteus-1.2.3.dist-info}/licenses/LICENSE +0 -0
@@ -1,153 +0,0 @@
1
- # file: autobyteus/autobyteus/rpc/config/agent_server_config.py
2
- import logging
3
- from typing import Optional, Dict, Any, List # List was missing
4
- from pydantic import BaseModel, Field, validator, HttpUrl
5
-
6
- from autobyteus.rpc.transport_type import TransportType
7
-
8
- logger = logging.getLogger(__name__)
9
-
10
- class AgentServerConfig(BaseModel):
11
- """
12
- Configuration for an Agent Server, specifying how it can be connected to.
13
- """
14
- server_id: str = Field(..., description="Unique identifier for this server configuration.")
15
- transport_type: TransportType = Field(..., description="The transport mechanism (e.g., stdio, sse).")
16
-
17
- # For stdio transport
18
- stdio_command: Optional[List[str]] = Field(default=None, description="Command and arguments to launch the agent server process for stdio.")
19
-
20
- # For sse transport
21
- sse_base_url: Optional[HttpUrl] = Field(default=None, description="Base URL for the agent server's HTTP/SSE endpoints.")
22
- sse_request_endpoint: str = Field(default="/invoke", description="Relative path for synchronous requests (e.g., invoke_method).")
23
- sse_events_endpoint: str = Field(default="/events", description="Relative path for the Server-Sent Events stream.")
24
- # New field for HTTP stream downloads
25
- sse_stream_download_path_prefix: str = Field(default="/streams", description="Base relative path for HTTP stream downloads. Full path will be {base_url}{prefix}/{agent_id_on_server}/{stream_id}.")
26
-
27
-
28
- # Optional metadata
29
- metadata: Dict[str, Any] = Field(default_factory=dict, description="Optional metadata for the server configuration.")
30
-
31
- class Config:
32
- use_enum_values = True # Serialize enums to their values
33
- validate_assignment = True
34
-
35
- @validator('stdio_command')
36
- def _check_stdio_command(cls, v, values):
37
- if values.get('transport_type') == TransportType.STDIO and not v:
38
- raise ValueError("stdio_command is required for stdio transport type.")
39
- if values.get('transport_type') != TransportType.STDIO and v:
40
- logger.warning("stdio_command is provided but transport_type is not stdio. It will be ignored.")
41
- return v
42
-
43
- @validator('sse_base_url')
44
- def _check_sse_base_url(cls, v, values):
45
- if values.get('transport_type') == TransportType.SSE and not v:
46
- raise ValueError("sse_base_url is required for sse transport type.")
47
- if values.get('transport_type') != TransportType.SSE and v:
48
- logger.warning("sse_base_url is provided but transport_type is not sse. It will be ignored.")
49
- return v
50
-
51
- @validator('sse_stream_download_path_prefix')
52
- def _check_sse_stream_download_path_prefix(cls, v, values):
53
- if not v.startswith('/'):
54
- raise ValueError("sse_stream_download_path_prefix must start with a '/'.")
55
- if values.get('transport_type') != TransportType.SSE and v != "/streams": # if not default and not SSE
56
- logger.warning("sse_stream_download_path_prefix is customized but transport_type is not sse. It might be ignored.")
57
- return v
58
-
59
-
60
- def get_sse_full_request_url(self) -> Optional[str]:
61
- """Returns the full URL for SSE synchronous requests if applicable."""
62
- if self.transport_type == TransportType.SSE and self.sse_base_url:
63
- # Pydantic's HttpUrl converts to string automatically when concatenated this way
64
- return str(self.sse_base_url).rstrip('/') + self.sse_request_endpoint
65
- return None
66
-
67
- def get_sse_full_events_url(self) -> Optional[str]:
68
- """Returns the full URL for the SSE event stream if applicable."""
69
- if self.transport_type == TransportType.SSE and self.sse_base_url:
70
- return str(self.sse_base_url).rstrip('/') + self.sse_events_endpoint
71
- return None
72
-
73
- def get_sse_full_stream_download_url_prefix_for_agent(self, agent_id_on_server: str) -> Optional[str]:
74
- """
75
- Returns the full URL prefix for HTTP stream downloads for a specific agent,
76
- up to the point where stream_id should be appended.
77
- e.g., http://host:port/streams/{agent_id_on_server}
78
- """
79
- if self.transport_type == TransportType.SSE and self.sse_base_url:
80
- base = str(self.sse_base_url).rstrip('/')
81
- prefix = self.sse_stream_download_path_prefix.rstrip('/')
82
- return f"{base}{prefix}/{agent_id_on_server}"
83
- return None
84
-
85
-
86
- def __repr__(self) -> str:
87
- return f"<AgentServerConfig server_id='{self.server_id}', transport='{self.transport_type.value}'>"
88
-
89
- if __name__ == "__main__": # pragma: no cover
90
- logging.basicConfig(level=logging.DEBUG)
91
-
92
- # Stdio Example
93
- try:
94
- stdio_config_data = {
95
- "server_id": "local_agent_stdio",
96
- "transport_type": "stdio",
97
- "stdio_command": ["python", "-m", "autobyteus.agent.server_main", "--config-id", "local_agent_stdio"]
98
- }
99
- stdio_config = AgentServerConfig(**stdio_config_data)
100
- logger.info(f"Stdio Config: {stdio_config!r}")
101
- logger.info(f"Stdio Config (dict): {stdio_config.model_dump_json(indent=2)}")
102
- except ValueError as e:
103
- logger.error(f"Error creating stdio_config: {e}")
104
-
105
- # SSE Example
106
- try:
107
- sse_config_data = {
108
- "server_id": "remote_agent_sse",
109
- "transport_type": "sse",
110
- "sse_base_url": "http://localhost:8000/agent1",
111
- "sse_request_endpoint": "/api/request",
112
- "sse_events_endpoint": "/api/events",
113
- "sse_stream_download_path_prefix": "/downloadable_content" # Custom prefix
114
- }
115
- sse_config = AgentServerConfig(**sse_config_data)
116
- logger.info(f"SSE Config: {sse_config!r}")
117
- logger.info(f"SSE Config (dict): {sse_config.model_dump_json(indent=2)}")
118
- logger.info(f"SSE Request URL: {sse_config.get_sse_full_request_url()}")
119
- logger.info(f"SSE Events URL: {sse_config.get_sse_full_events_url()}")
120
- logger.info(f"SSE Stream Download URL prefix for agent 'test_agent': {sse_config.get_sse_full_stream_download_url_prefix_for_agent('test_agent')}")
121
-
122
- # Test HttpUrl string conversion
123
- assert isinstance(sse_config.sse_base_url, HttpUrl)
124
- logger.info(f"SSE base URL type: {type(sse_config.sse_base_url)}, value: {sse_config.sse_base_url}")
125
-
126
- except ValueError as e:
127
- logger.error(f"Error creating sse_config: {e}")
128
-
129
- # Validation error examples
130
- try:
131
- invalid_stdio_data = {"server_id": "invalid_stdio", "transport_type": "stdio"} # Missing stdio_command
132
- AgentServerConfig(**invalid_stdio_data)
133
- except ValueError as e:
134
- logger.error(f"Expected validation error (stdio): {e}")
135
-
136
- try:
137
- invalid_sse_data = {"server_id": "invalid_sse", "transport_type": "sse"} # Missing sse_base_url
138
- AgentServerConfig(**invalid_sse_data)
139
- except ValueError as e:
140
- logger.error(f"Expected validation error (sse): {e}")
141
-
142
- try:
143
- invalid_url_sse_data = {"server_id": "invalid_url_sse", "transport_type": "sse", "sse_base_url": "not_a_url"}
144
- AgentServerConfig(**invalid_url_sse_data)
145
- except ValueError as e:
146
- logger.error(f"Expected validation error (invalid sse_base_url): {e}")
147
-
148
- try:
149
- invalid_stream_prefix = {"server_id": "invalid_stream_prefix", "transport_type": "sse", "sse_base_url":"http://foo.com", "sse_stream_download_path_prefix": "no_slash_prefix"}
150
- AgentServerConfig(**invalid_stream_prefix)
151
- except ValueError as e:
152
- logger.error(f"Expected validation error (invalid sse_stream_download_path_prefix): {e}")
153
-
@@ -1,152 +0,0 @@
1
- # file: autobyteus/autobyteus/rpc/config/agent_server_registry.py
2
- import logging
3
- from typing import Dict, Optional, List
4
-
5
- from autobyteus.utils.singleton import SingletonMeta
6
- from .agent_server_config import AgentServerConfig
7
-
8
- logger = logging.getLogger(__name__)
9
-
10
- class AgentServerRegistry(metaclass=SingletonMeta):
11
- """
12
- A singleton registry for storing and managing AgentServerConfig objects.
13
- This allows different parts of the system to retrieve server connection
14
- details by a server_id.
15
- """
16
-
17
- def __init__(self):
18
- """Initializes the AgentServerRegistry with an empty store."""
19
- self._configs: Dict[str, AgentServerConfig] = {}
20
- logger.info("AgentServerRegistry initialized.")
21
-
22
- def register_config(self, config: AgentServerConfig) -> None:
23
- """
24
- Registers an agent server configuration.
25
- If a configuration with the same server_id already exists, it will be
26
- overwritten, and a warning will be logged.
27
-
28
- Args:
29
- config: The AgentServerConfig object to register.
30
-
31
- Raises:
32
- TypeError: If the provided config is not an AgentServerConfig instance.
33
- """
34
- if not isinstance(config, AgentServerConfig):
35
- raise TypeError(f"Expected AgentServerConfig instance, got {type(config).__name__}.")
36
-
37
- if config.server_id in self._configs:
38
- logger.warning(f"Overwriting existing agent server configuration for server_id: '{config.server_id}'.")
39
-
40
- self._configs[config.server_id] = config
41
- logger.info(f"AgentServerConfig for server_id '{config.server_id}' (transport: {config.transport_type.value}) registered.")
42
-
43
- def get_config(self, server_id: str) -> Optional[AgentServerConfig]:
44
- """
45
- Retrieves an agent server configuration by its server_id.
46
-
47
- Args:
48
- server_id: The unique identifier of the server configuration.
49
-
50
- Returns:
51
- The AgentServerConfig object if found, otherwise None.
52
- """
53
- if not isinstance(server_id, str):
54
- logger.warning(f"Attempted to retrieve agent server config with non-string server_id: {type(server_id).__name__}.")
55
- return None
56
-
57
- config = self._configs.get(server_id)
58
- if not config:
59
- logger.debug(f"AgentServerConfig with server_id '{server_id}' not found in registry.")
60
- return config
61
-
62
- def unregister_config(self, server_id: str) -> bool:
63
- """
64
- Removes an agent server configuration from the registry.
65
-
66
- Args:
67
- server_id: The server_id of the configuration to remove.
68
-
69
- Returns:
70
- True if the configuration was found and removed, False otherwise.
71
- """
72
- if not isinstance(server_id, str):
73
- logger.warning(f"Attempted to unregister agent server config with non-string server_id: {type(server_id).__name__}.")
74
- return False
75
-
76
- if server_id in self._configs:
77
- removed_config = self._configs.pop(server_id)
78
- logger.info(f"AgentServerConfig for server_id '{removed_config.server_id}' unregistered successfully.")
79
- return True
80
- else:
81
- logger.warning(f"AgentServerConfig with server_id '{server_id}' not found for unregistration.")
82
- return False
83
-
84
- def list_server_ids(self) -> List[str]:
85
- """Returns a list of all registered server_ids."""
86
- return list(self._configs.keys())
87
-
88
- def get_all_configs(self) -> Dict[str, AgentServerConfig]:
89
- """Returns a shallow copy of all registered configurations."""
90
- return dict(self._configs)
91
-
92
- def clear(self) -> None:
93
- """Removes all configurations from the registry."""
94
- count = len(self._configs)
95
- self._configs.clear()
96
- logger.info(f"Cleared {count} configurations from the AgentServerRegistry.")
97
-
98
- def __len__(self) -> int:
99
- return len(self._configs)
100
-
101
- def __contains__(self, server_id: str) -> bool:
102
- if isinstance(server_id, str):
103
- return server_id in self._configs
104
- return False
105
-
106
- # Default global instance of the registry
107
- default_agent_server_registry = AgentServerRegistry()
108
-
109
- if __name__ == "__main__": # pragma: no cover
110
- logging.basicConfig(level=logging.DEBUG)
111
-
112
- registry = default_agent_server_registry # Use the default instance
113
-
114
- # Stdio Config
115
- stdio_config_data = {
116
- "server_id": "local_agent_stdio_main",
117
- "transport_type": "stdio",
118
- "stdio_command": ["python", "-m", "some_module"]
119
- }
120
- stdio_conf = AgentServerConfig(**stdio_config_data)
121
- registry.register_config(stdio_conf)
122
-
123
- # SSE Config
124
- sse_config_data = {
125
- "server_id": "remote_agent_sse_main",
126
- "transport_type": "sse",
127
- "sse_base_url": "http://localhost:8080"
128
- }
129
- sse_conf = AgentServerConfig(**sse_config_data)
130
- registry.register_config(sse_conf)
131
-
132
- logger.info(f"Registered server IDs: {registry.list_server_ids()}")
133
-
134
- retrieved_stdio = registry.get_config("local_agent_stdio_main")
135
- if retrieved_stdio:
136
- logger.info(f"Retrieved Stdio Config: {retrieved_stdio.stdio_command}")
137
-
138
- retrieved_sse = registry.get_config("remote_agent_sse_main")
139
- if retrieved_sse:
140
- logger.info(f"Retrieved SSE Config URL: {retrieved_sse.get_sse_full_request_url()}")
141
-
142
- assert "local_agent_stdio_main" in registry
143
- assert len(registry) == 2
144
-
145
- registry.unregister_config("local_agent_stdio_main")
146
- assert "local_agent_stdio_main" not in registry
147
- logger.info(f"After unregistering, server IDs: {registry.list_server_ids()}")
148
-
149
- registry.clear()
150
- assert len(registry) == 0
151
- logger.info(f"After clearing, server IDs: {registry.list_server_ids()}")
152
-
autobyteus/rpc/hosting.py DELETED
@@ -1,244 +0,0 @@
1
- # file: autobyteus/autobyteus/rpc/hosting.py
2
- import asyncio
3
- import logging
4
- import signal
5
- from typing import Optional, Dict, Union # Added Dict, Union
6
-
7
- from autobyteus.agent.agent import Agent
8
- from autobyteus.rpc.server import AgentServerEndpoint
9
- from autobyteus.rpc.config import AgentServerConfig
10
- from autobyteus.rpc.transport_type import TransportType
11
-
12
- logger = logging.getLogger(__name__)
13
-
14
- async def serve_agent_stdio(
15
- agent: Agent,
16
- stop_event: asyncio.Event,
17
- server_id_for_config: Optional[str] = None
18
- ) -> None:
19
- """
20
- Hosts a single Agent instance over STDIO within the current process.
21
- This function will run until the stop_event is set.
22
- The script calling this function will dedicate its sys.stdin/sys.stdout
23
- to RPC communication.
24
-
25
- Args:
26
- agent: The Agent instance to serve.
27
- stop_event: An asyncio.Event that signals when to stop the server.
28
- server_id_for_config: Optional string to use as server_id in the internal
29
- AgentServerConfig. Defaults to f"embedded_stdio_{agent.agent_id}".
30
- """
31
- if not isinstance(agent, Agent):
32
- raise TypeError("agent must be an instance of autobyteus.agent.agent.Agent")
33
- if not isinstance(stop_event, asyncio.Event):
34
- raise TypeError("stop_event must be an asyncio.Event")
35
-
36
- actual_server_id = server_id_for_config or f"embedded_stdio_{agent.agent_id}"
37
-
38
- stdio_config = AgentServerConfig(
39
- server_id=actual_server_id,
40
- transport_type=TransportType.STDIO,
41
- stdio_command=["in-process-stdio-server"]
42
- )
43
- logger.info(f"Configuring in-process STDIO server for agent '{agent.agent_id}' with config_id '{actual_server_id}'.")
44
-
45
- server_endpoint = AgentServerEndpoint(agent) # Pass single agent
46
-
47
- try:
48
- if not agent.is_running:
49
- logger.info(f"Starting agent '{agent.agent_id}' for STDIO hosting...")
50
- agent.start()
51
-
52
- logger.info(f"Starting STDIO server endpoint for agent '{agent.agent_id}'...")
53
- await server_endpoint.start(stdio_config)
54
-
55
- logger.info(f"Agent '{agent.agent_id}' now being served via STDIO. Waiting for stop signal...")
56
- await stop_event.wait()
57
- logger.info(f"Stop signal received for STDIO server of agent '{agent.agent_id}'.")
58
-
59
- except Exception as e:
60
- logger.error(f"Error during STDIO hosting for agent '{agent.agent_id}': {e}", exc_info=True)
61
- finally:
62
- logger.info(f"Shutting down STDIO server for agent '{agent.agent_id}'...")
63
- if server_endpoint.is_running:
64
- await server_endpoint.stop()
65
-
66
- if agent.is_running:
67
- logger.info(f"Stopping agent '{agent.agent_id}' after STDIO hosting...")
68
- await agent.stop()
69
- logger.info(f"STDIO hosting for agent '{agent.agent_id}' has shut down.")
70
-
71
-
72
- async def serve_single_agent_http_sse(
73
- agent: Agent,
74
- host: str,
75
- port: int,
76
- stop_event: asyncio.Event,
77
- server_id_prefix: str = "embedded_http_single",
78
- request_endpoint: str = "/rpc",
79
- events_endpoint_base: str = "/events" # Base path for events
80
- ) -> None:
81
- """
82
- Hosts a single Agent instance over HTTP/SSE within the current process.
83
- The agent will be accessible using its own agent_id as the key on the server
84
- (e.g., for SSE events: /events/{agent.agent_id}).
85
-
86
- Args:
87
- agent: The Agent instance to serve.
88
- host: The hostname or IP address to bind the HTTP server to.
89
- port: The port number to bind the HTTP server to.
90
- stop_event: An asyncio.Event that signals when to stop the server.
91
- server_id_prefix: Prefix for the server_id in the internal AgentServerConfig.
92
- request_endpoint: The URL path for RPC requests.
93
- events_endpoint_base: The base URL path for SSE event streams (agent_id will be appended).
94
- """
95
- # This function now essentially calls serve_multiple_agents_http_sse
96
- # The agent's own ID will be used as the key for routing on the server.
97
- agents_to_serve = {agent.agent_id: agent}
98
- await serve_multiple_agents_http_sse(
99
- agents=agents_to_serve,
100
- host=host,
101
- port=port,
102
- stop_event=stop_event,
103
- server_id_prefix=server_id_prefix,
104
- request_endpoint=request_endpoint,
105
- events_endpoint_base=events_endpoint_base
106
- )
107
-
108
-
109
- async def serve_multiple_agents_http_sse(
110
- agents: Dict[str, Agent], # Key: server-routable ID, Value: Agent instance
111
- host: str,
112
- port: int,
113
- stop_event: asyncio.Event,
114
- server_id_prefix: str = "embedded_http_multi",
115
- request_endpoint: str = "/rpc", # Single RPC endpoint for the gateway
116
- events_endpoint_base: str = "/events" # Base for /events/{agent_id_on_server}
117
- ) -> None:
118
- """
119
- Hosts multiple Agent instances over a single HTTP/SSE server within the current process.
120
- This function will run until the stop_event is set.
121
-
122
- Args:
123
- agents: A dictionary where keys are server-routable string IDs for each agent,
124
- and values are the Agent instances to serve.
125
- host: The hostname or IP address to bind the HTTP server to.
126
- port: The port number to bind the HTTP server to.
127
- stop_event: An asyncio.Event that signals when to stop the server.
128
- server_id_prefix: Prefix for the server_id in the internal AgentServerConfig for the gateway.
129
- request_endpoint: The URL path for all RPC requests (target_agent_id must be in payload).
130
- events_endpoint_base: The base URL path for SSE event streams. Clients subscribe to
131
- {events_endpoint_base}/{server_routable_agent_id}.
132
- """
133
- if not isinstance(agents, dict) or not agents:
134
- raise TypeError("agents must be a non-empty dictionary of [str, Agent] instances.")
135
- if not all(isinstance(k, str) and isinstance(v, Agent) for k, v in agents.items()):
136
- raise TypeError("agents dictionary keys must be strings and values must be Agent instances.")
137
- if not isinstance(stop_event, asyncio.Event):
138
- raise TypeError("stop_event must be an asyncio.Event")
139
-
140
- # server_id for the gateway server config
141
- gateway_server_id = f"{server_id_prefix}_gateway"
142
-
143
- sse_config = AgentServerConfig(
144
- server_id=gateway_server_id,
145
- transport_type=TransportType.SSE,
146
- sse_base_url=f"http://{host}:{port}", # type: ignore
147
- sse_request_endpoint=request_endpoint,
148
- sse_events_endpoint=events_endpoint_base # SseServerHandler will append /{agent_id_on_server}
149
- )
150
- routable_agent_ids = list(agents.keys())
151
- logger.info(f"Configuring in-process HTTP/SSE gateway server at {sse_config.sse_base_url} "
152
- f"(config_id: '{gateway_server_id}') to serve agents: {routable_agent_ids}.")
153
-
154
- server_endpoint = AgentServerEndpoint(agents) # Pass the dictionary of agents
155
-
156
- try:
157
- for agent_id_on_server, agent_instance in agents.items():
158
- if not agent_instance.is_running:
159
- logger.info(f"Starting agent '{agent_instance.agent_id}' (server key: '{agent_id_on_server}') for HTTP/SSE gateway hosting...")
160
- agent_instance.start()
161
-
162
- logger.info(f"Starting HTTP/SSE gateway server endpoint for agents: {routable_agent_ids}...")
163
- await server_endpoint.start(sse_config)
164
-
165
- logger.info(f"Multi-agent gateway now being served via HTTP/SSE on http://{host}:{port}. Waiting for stop signal...")
166
- await stop_event.wait()
167
- logger.info(f"Stop signal received for multi-agent HTTP/SSE gateway server.")
168
-
169
- except Exception as e:
170
- logger.error(f"Error during multi-agent HTTP/SSE hosting: {e}", exc_info=True)
171
- finally:
172
- logger.info(f"Shutting down multi-agent HTTP/SSE gateway server...")
173
- if server_endpoint.is_running:
174
- await server_endpoint.stop()
175
-
176
- for agent_id_on_server, agent_instance in agents.items():
177
- if agent_instance.is_running:
178
- logger.info(f"Stopping agent '{agent_instance.agent_id}' (server key: '{agent_id_on_server}')...")
179
- await agent_instance.stop()
180
- logger.info(f"Multi-agent HTTP/SSE hosting has shut down.")
181
-
182
-
183
- # Renamed old serve_agent_http_sse to serve_single_agent_http_sse
184
- # Kept the old signature for backward compatibility if any tests used it,
185
- # but it now delegates to the multi-agent version.
186
- async def serve_agent_http_sse(
187
- agent: Agent,
188
- host: str,
189
- port: int,
190
- stop_event: asyncio.Event,
191
- server_id_prefix: str = "embedded_http", # Note: prefix change if desired
192
- request_endpoint: str = "/rpc",
193
- events_endpoint_base: str = "/events"
194
- ) -> None:
195
- await serve_single_agent_http_sse(
196
- agent, host, port, stop_event, server_id_prefix, request_endpoint, events_endpoint_base
197
- )
198
-
199
-
200
- if __name__ == "__main__": # pragma: no cover
201
- logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
202
- from autobyteus.agent.registry.agent_definition import AgentDefinition
203
- from autobyteus.agent.registry.agent_registry import default_agent_registry, default_definition_registry
204
- from autobyteus.llm.models import LLMModel
205
- try: import autobyteus.agent.input_processor
206
- except ImportError: print("Warning: input_processor module not found.", file=sys.stderr)
207
-
208
- def create_example_agent(name: str, role: str) -> Optional[Agent]:
209
- agent_def = default_definition_registry.get(name, role)
210
- if not agent_def:
211
- try:
212
- agent_def = AgentDefinition(name=name, role=role, description=f"{name} agent",
213
- system_prompt=f"You are {name}.", tool_names=[],
214
- input_processor_names=["PassthroughInputProcessor"])
215
- except Exception as e_def:
216
- logger.error(f"Failed to create def for {name}: {e_def}"); return None
217
-
218
- try: chosen_llm_model = next(iter(LLMModel)) if LLMModel else None
219
- except StopIteration: chosen_llm_model = None
220
- if not chosen_llm_model:
221
- class MockLLMModel(str, Enum): DUMMY = "dummy_model" # type: ignore
222
- LLMModel = MockLLMModel # type: ignore
223
- chosen_llm_model = LLMModel.DUMMY
224
-
225
- if chosen_llm_model:
226
- try: return default_agent_registry.create_agent(definition=agent_def, llm_model=chosen_llm_model)
227
- except Exception as e_create: logger.error(f"Failed to create agent {name}: {e_create}", exc_info=True)
228
- return None
229
-
230
- agent1 = create_example_agent("AgentAlpha", "analyzer")
231
- agent2 = create_example_agent("AgentBeta", "writer")
232
-
233
- if agent1 and agent2:
234
- agents_for_server = {
235
- "alpha": agent1, # Routable ID "alpha" maps to AgentAlpha
236
- "beta": agent2 # Routable ID "beta" maps to AgentBeta
237
- }
238
- # Example: Run the multi-agent SSE server
239
- asyncio.run(serve_multiple_agents_http_sse(agents_for_server, "127.0.0.1", 8888, asyncio.Event()))
240
- # To test, connect to http://127.0.0.1:8888/events/alpha and /events/beta for SSE
241
- # Send POST to http://127.0.0.1:8888/rpc with {"target_agent_id": "alpha", ...}
242
- else:
243
- logger.error("Could not create example agents for multi-agent hosting demo.")
244
-