autoglm-gui 1.5.1__tar.gz → 1.5.2__tar.gz

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 (126) hide show
  1. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/__init__.py +1 -1
  2. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/__main__.py +11 -2
  3. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb_plus/qr_pair.py +3 -3
  4. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/__init__.py +7 -2
  5. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/factory.py +46 -6
  6. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/glm/agent.py +2 -2
  7. autoglm_gui-1.5.2/AutoGLM_GUI/agents/glm/async_agent.py +515 -0
  8. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/glm/parser.py +4 -2
  9. autoglm_gui-1.5.2/AutoGLM_GUI/agents/protocols.py +137 -0
  10. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/stream_runner.py +4 -5
  11. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/__init__.py +3 -1
  12. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/agents.py +78 -37
  13. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/devices.py +72 -0
  14. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/layered_agent.py +9 -8
  15. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/mcp.py +6 -4
  16. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/config_manager.py +38 -1
  17. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/device_manager.py +28 -4
  18. autoglm_gui-1.5.2/AutoGLM_GUI/device_metadata_manager.py +174 -0
  19. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/devices/mock_device.py +8 -1
  20. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/phone_agent_manager.py +145 -32
  21. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/scheduler_manager.py +6 -6
  22. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/schemas.py +89 -0
  23. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/scrcpy_stream.py +2 -1
  24. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/about-CfwX1Cmc.js → autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/about-D7r9gCvG.js +1 -1
  25. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/alert-dialog-CtGlN2IJ.js → autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/alert-dialog-BKM-yRiQ.js +1 -1
  26. autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/chat-k6TTD7PW.js +129 -0
  27. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/circle-alert-t08bEMPO.js → autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/circle-alert-sohSDLhl.js +1 -1
  28. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/dialog-FNwZJFwk.js → autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/dialog-BgtPh0d5.js +1 -1
  29. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/eye-D0UPWCWC.js → autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/eye-DLqKbQmg.js +1 -1
  30. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/history-CRo95B7i.js → autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/history-Bv1lfGUU.js +1 -1
  31. autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/index-CxWwh1VO.js +1 -0
  32. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/index-CTHbFvKl.js → autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/index-SysdKciY.js +5 -5
  33. autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/label-DTUnzN4B.js +1 -0
  34. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/logs-RW09DyYY.js → autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/logs-BIhnDizW.js +1 -1
  35. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/popover--JTJrE5v.js → autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/popover-CikYqu2P.js +1 -1
  36. autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/scheduled-tasks-B-KBsGbl.js +1 -0
  37. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/textarea-PRmVnWq5.js → autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/textarea-knJZrz77.js +1 -1
  38. autoglm_gui-1.5.2/AutoGLM_GUI/static/assets/workflows-DzcSYwLZ.js +1 -0
  39. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/static/index.html +1 -1
  40. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/PKG-INFO +10 -1
  41. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/README.md +9 -0
  42. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/pyproject.toml +1 -1
  43. autoglm_gui-1.5.1/AutoGLM_GUI/agents/protocols.py +0 -27
  44. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/chat-BYa-foUI.js +0 -129
  45. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/index-BaLMSqd3.js +0 -1
  46. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/label-DJFevVmr.js +0 -1
  47. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/scheduled-tasks-DTRKsQXF.js +0 -1
  48. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/square-pen-CPK_K680.js +0 -1
  49. autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/workflows-CdcsAoaT.js +0 -1
  50. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/.gitignore +0 -0
  51. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/actions/__init__.py +0 -0
  52. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/actions/handler.py +0 -0
  53. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/actions/types.py +0 -0
  54. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb/__init__.py +0 -0
  55. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb/apps.py +0 -0
  56. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb/connection.py +0 -0
  57. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb/device.py +0 -0
  58. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb/input.py +0 -0
  59. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb/screenshot.py +0 -0
  60. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb/timing.py +0 -0
  61. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb_plus/__init__.py +0 -0
  62. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb_plus/device.py +0 -0
  63. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb_plus/ip.py +0 -0
  64. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb_plus/keyboard_installer.py +0 -0
  65. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb_plus/mdns.py +0 -0
  66. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb_plus/pair.py +0 -0
  67. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb_plus/screenshot.py +0 -0
  68. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb_plus/serial.py +0 -0
  69. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb_plus/touch.py +0 -0
  70. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/adb_plus/version.py +0 -0
  71. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/events.py +0 -0
  72. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/glm/__init__.py +0 -0
  73. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/glm/message_builder.py +0 -0
  74. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/glm/prompts_en.py +0 -0
  75. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/glm/prompts_zh.py +0 -0
  76. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/mai/__init__.py +0 -0
  77. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/mai/agent.py +0 -0
  78. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/mai/parser.py +0 -0
  79. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/mai/prompts.py +0 -0
  80. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/agents/mai/traj_memory.py +0 -0
  81. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/control.py +0 -0
  82. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/health.py +0 -0
  83. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/history.py +0 -0
  84. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/media.py +0 -0
  85. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/metrics.py +0 -0
  86. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/scheduled_tasks.py +0 -0
  87. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/version.py +0 -0
  88. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/api/workflows.py +0 -0
  89. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/config.py +0 -0
  90. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/device_protocol.py +0 -0
  91. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/devices/__init__.py +0 -0
  92. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/devices/adb_device.py +0 -0
  93. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/devices/remote_device.py +0 -0
  94. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/exceptions.py +0 -0
  95. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/history_manager.py +0 -0
  96. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/i18n.py +0 -0
  97. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/logger.py +0 -0
  98. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/metrics.py +0 -0
  99. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/model/__init__.py +0 -0
  100. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/model/message_builder.py +0 -0
  101. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/model/types.py +0 -0
  102. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/models/__init__.py +0 -0
  103. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/models/history.py +0 -0
  104. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/models/scheduled_task.py +0 -0
  105. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/parsers/__init__.py +0 -0
  106. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/parsers/base.py +0 -0
  107. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/parsers/phone_parser.py +0 -0
  108. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/platform_utils.py +0 -0
  109. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/prompt_config.py +0 -0
  110. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/prompts/__init__.py +0 -0
  111. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/prompts.py +0 -0
  112. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/scrcpy_protocol.py +0 -0
  113. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/server.py +0 -0
  114. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/socketio_server.py +0 -0
  115. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/state.py +0 -0
  116. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/static/assets/index-CV7jGxGm.css +0 -0
  117. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/static/assets/logo-Cyfm06Ym.png +0 -0
  118. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/static/assets/worker-D6BRitjy.js +0 -0
  119. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/static/favicon.ico +0 -0
  120. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/static/logo-192.png +0 -0
  121. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/static/logo-512.png +0 -0
  122. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/types.py +0 -0
  123. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/version.py +0 -0
  124. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/AutoGLM_GUI/workflow_manager.py +0 -0
  125. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/LICENSE +0 -0
  126. {autoglm_gui-1.5.1 → autoglm_gui-1.5.2}/scrcpy-server-v3.3.3 +0 -0
@@ -28,7 +28,7 @@ _original_popen = subprocess.Popen
28
28
 
29
29
 
30
30
  @wraps(_original_run)
31
- def _patched_run(*args, **kwargs):
31
+ def _patched_run(*args, **kwargs) -> subprocess.CompletedProcess:
32
32
  """Patched subprocess.run that defaults to UTF-8 encoding on Windows."""
33
33
  if sys.platform == "win32":
34
34
  # Add encoding='utf-8' if text=True is set but encoding is not specified
@@ -56,7 +56,7 @@ def open_browser(
56
56
  delay: Delay in seconds before opening browser
57
57
  """
58
58
 
59
- def _open():
59
+ def _open() -> None:
60
60
  time.sleep(delay)
61
61
  protocol = "https" if use_ssl else "http"
62
62
  url = (
@@ -141,6 +141,12 @@ def main() -> None:
141
141
  default=None,
142
142
  help="SSL certificate file path (for HTTPS)",
143
143
  )
144
+ parser.add_argument(
145
+ "--layered-max-turns",
146
+ type=int,
147
+ default=None,
148
+ help="Maximum turns for layered agent mode (default: 50, minimum: 1)",
149
+ )
144
150
 
145
151
  args = parser.parse_args()
146
152
 
@@ -170,7 +176,10 @@ def main() -> None:
170
176
 
171
177
  # 1. 设置 CLI 参数配置(最高优先级)
172
178
  config_manager.set_cli_config(
173
- base_url=args.base_url, model_name=args.model, api_key=args.apikey
179
+ base_url=args.base_url,
180
+ model_name=args.model,
181
+ api_key=args.apikey,
182
+ layered_max_turns=args.layered_max_turns,
174
183
  )
175
184
 
176
185
  # 2. 加载环境变量配置
@@ -238,10 +238,10 @@ class QRPairingManager:
238
238
 
239
239
  return session
240
240
 
241
- def _start_listener(self, session: PairingSession, adb_path: str):
241
+ def _start_listener(self, session: PairingSession, adb_path: str) -> None:
242
242
  """Start zeroconf listener (runs in thread pool to avoid blocking)."""
243
243
 
244
- def _listen():
244
+ def _listen() -> None:
245
245
  """Listener thread function."""
246
246
  try:
247
247
  zc = Zeroconf()
@@ -350,7 +350,7 @@ class QRPairingManager:
350
350
  logger.warning(f"[QR Pair] Session {session_id} not found for cancellation")
351
351
  return False
352
352
 
353
- async def cleanup_expired_sessions(self):
353
+ async def cleanup_expired_sessions(self) -> None:
354
354
  """Background task to cleanup expired sessions.
355
355
 
356
356
  Runs indefinitely, checking every 60 seconds for expired sessions.
@@ -2,6 +2,8 @@ from __future__ import annotations
2
2
 
3
3
  from typing import Callable
4
4
 
5
+ from .protocols import AsyncAgent, BaseAgent, is_async_agent
6
+
5
7
 
6
8
  def register_agent(agent_type: str, creator: Callable) -> None:
7
9
  from .factory import register_agent as _register_agent
@@ -44,8 +46,11 @@ def is_agent_type_registered(agent_type: str) -> bool:
44
46
 
45
47
 
46
48
  __all__ = [
49
+ "AsyncAgent",
50
+ "BaseAgent",
47
51
  "create_agent",
48
- "register_agent",
49
- "list_agent_types",
50
52
  "is_agent_type_registered",
53
+ "is_async_agent",
54
+ "list_agent_types",
55
+ "register_agent",
51
56
  ]
@@ -12,7 +12,7 @@ from AutoGLM_GUI.config import AgentConfig, ModelConfig
12
12
  from AutoGLM_GUI.logger import logger
13
13
  from AutoGLM_GUI.types import AgentSpecificConfig
14
14
 
15
- from .protocols import BaseAgent
15
+ from .protocols import AsyncAgent, BaseAgent
16
16
 
17
17
 
18
18
  # Agent registry: agent_type -> (creator_function, config_schema)
@@ -52,7 +52,7 @@ def create_agent(
52
52
  device,
53
53
  takeover_callback: Callable | None = None,
54
54
  confirmation_callback: Callable | None = None,
55
- ) -> BaseAgent:
55
+ ) -> AsyncAgent | BaseAgent:
56
56
  """
57
57
  Create an agent instance using the factory pattern.
58
58
 
@@ -66,7 +66,8 @@ def create_agent(
66
66
  confirmation_callback: Confirmation callback
67
67
 
68
68
  Returns:
69
- Agent instance implementing BaseAgent interface
69
+ Agent instance implementing AsyncAgent or BaseAgent interface.
70
+ Use runtime type detection (e.g., inspect.iscoroutinefunction) to determine which.
70
71
 
71
72
  Raises:
72
73
  ValueError: If agent_type is not registered
@@ -108,14 +109,51 @@ def is_agent_type_registered(agent_type: str) -> bool:
108
109
  # ==================== Built-in Agent Creators ====================
109
110
 
110
111
 
111
- def _create_glm_agent_v2(
112
+ def _create_async_glm_agent(
112
113
  model_config: ModelConfig,
113
114
  agent_config: AgentConfig,
114
- agent_specific_config: AgentSpecificConfig,
115
+ agent_specific_config: AgentSpecificConfig, # noqa: ARG001
116
+ device,
117
+ takeover_callback: Callable | None = None,
118
+ confirmation_callback: Callable | None = None,
119
+ ) -> AsyncAgent:
120
+ """Create AsyncGLMAgent instance.
121
+
122
+ This is the default async implementation that supports:
123
+ - Native streaming with AsyncIterator
124
+ - Immediate cancellation with asyncio.CancelledError
125
+ - No worker threads or queues needed
126
+
127
+ Note: 'glm' now uses AsyncGLMAgent by default for better performance.
128
+ Use 'glm-sync' if you need the old synchronous implementation.
129
+ """
130
+ from .glm.async_agent import AsyncGLMAgent
131
+
132
+ # Note: AsyncGLMAgent implements AsyncAgent Protocol, but pyright cannot verify
133
+ # async generator function compatibility with Protocol. This is a known limitation
134
+ # of Python's type system. The implementation is correct at runtime.
135
+ return AsyncGLMAgent( # type: ignore[return-value]
136
+ model_config=model_config,
137
+ agent_config=agent_config,
138
+ device=device,
139
+ confirmation_callback=confirmation_callback,
140
+ takeover_callback=takeover_callback,
141
+ )
142
+
143
+
144
+ def _create_glm_agent_sync(
145
+ model_config: ModelConfig,
146
+ agent_config: AgentConfig,
147
+ agent_specific_config: AgentSpecificConfig, # noqa: ARG001
115
148
  device,
116
149
  takeover_callback: Callable | None = None,
117
150
  confirmation_callback: Callable | None = None,
118
151
  ) -> BaseAgent:
152
+ """Create synchronous GLMAgent (legacy, for backward compatibility).
153
+
154
+ This is the old synchronous implementation using AgentStepStreamer.
155
+ Only use this if you have compatibility issues with AsyncGLMAgent.
156
+ """
119
157
  from .glm.agent import GLMAgent
120
158
 
121
159
  return GLMAgent(
@@ -149,5 +187,7 @@ def _create_internal_mai_agent(
149
187
  )
150
188
 
151
189
 
152
- register_agent("glm", _create_glm_agent_v2)
190
+ register_agent("glm", _create_glm_agent_sync) # 默认使用同步实现 (向后兼容)
191
+ register_agent("glm-async", _create_async_glm_agent) # 异步实现 (显式选择)
192
+ register_agent("async-glm", _create_async_glm_agent) # 别名
153
193
  register_agent("mai", _create_internal_mai_agent)
@@ -1,6 +1,6 @@
1
1
  import json
2
2
  import traceback
3
- from typing import Any, Callable, cast
3
+ from typing import Any, Callable
4
4
 
5
5
  from openai import OpenAI
6
6
 
@@ -90,7 +90,7 @@ class GLMAgent:
90
90
  on_thinking_chunk: Callable[[str], None] | None = None,
91
91
  ) -> tuple[str, str, str]:
92
92
  stream = self.openai_client.chat.completions.create(
93
- messages=cast(Any, messages),
93
+ messages=messages, # type: ignore[arg-type]
94
94
  model=self.model_config.model_name,
95
95
  max_tokens=self.model_config.max_tokens,
96
96
  temperature=self.model_config.temperature,