autoglm-gui 1.5.0__tar.gz → 1.5.1__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.
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/glm/agent.py +6 -1
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/mai/agent.py +3 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/stream_runner.py +7 -2
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/agents.py +26 -1
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/history.py +27 -1
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/models/history.py +45 -1
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/scheduler_manager.py +52 -6
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/schemas.py +12 -0
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/about-BQm96DAl.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/about-CfwX1Cmc.js +1 -1
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/alert-dialog-B42XxGPR.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/alert-dialog-CtGlN2IJ.js +1 -1
- autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/chat-BYa-foUI.js +129 -0
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/circle-alert-D4rSJh37.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/circle-alert-t08bEMPO.js +1 -1
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/dialog-DZ78cEcj.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/dialog-FNwZJFwk.js +1 -1
- autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/eye-D0UPWCWC.js +1 -0
- autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/history-CRo95B7i.js +1 -0
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/index-CmZSnDqc.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/index-BaLMSqd3.js +1 -1
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/index-CssG-3TH.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/index-CTHbFvKl.js +5 -5
- autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/index-CV7jGxGm.css +1 -0
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/label-BCUzE_nm.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/label-DJFevVmr.js +1 -1
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/logs-eoFxn5of.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/logs-RW09DyYY.js +1 -1
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/popover-DLsuV5Sx.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/popover--JTJrE5v.js +1 -1
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/scheduled-tasks-MyqGJvy_.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/scheduled-tasks-DTRKsQXF.js +1 -1
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/square-pen-zGWYrdfj.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/square-pen-CPK_K680.js +1 -1
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/textarea-BX6y7uM5.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/textarea-PRmVnWq5.js +1 -1
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/workflows-CYFs6ssC.js → autoglm_gui-1.5.1/AutoGLM_GUI/static/assets/workflows-CdcsAoaT.js +1 -1
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/static/index.html +2 -2
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/PKG-INFO +49 -7
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/README.md +46 -4
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/pyproject.toml +6 -6
- autoglm_gui-1.5.0/AutoGLM_GUI/device_adapter.py +0 -263
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/chat-C0L2gQYG.js +0 -129
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/history-DFBv7TGc.js +0 -1
- autoglm_gui-1.5.0/AutoGLM_GUI/static/assets/index-Bzyv2yQ2.css +0 -1
- autoglm_gui-1.5.0/mai_agent/base.py +0 -137
- autoglm_gui-1.5.0/mai_agent/mai_grounding_agent.py +0 -263
- autoglm_gui-1.5.0/mai_agent/mai_naivigation_agent.py +0 -526
- autoglm_gui-1.5.0/mai_agent/prompt.py +0 -148
- autoglm_gui-1.5.0/mai_agent/unified_memory.py +0 -67
- autoglm_gui-1.5.0/mai_agent/utils.py +0 -73
- autoglm_gui-1.5.0/phone_agent/__init__.py +0 -12
- autoglm_gui-1.5.0/phone_agent/actions/__init__.py +0 -5
- autoglm_gui-1.5.0/phone_agent/actions/handler.py +0 -400
- autoglm_gui-1.5.0/phone_agent/actions/handler_ios.py +0 -278
- autoglm_gui-1.5.0/phone_agent/adb/__init__.py +0 -51
- autoglm_gui-1.5.0/phone_agent/adb/connection.py +0 -358
- autoglm_gui-1.5.0/phone_agent/adb/device.py +0 -253
- autoglm_gui-1.5.0/phone_agent/adb/input.py +0 -108
- autoglm_gui-1.5.0/phone_agent/adb/screenshot.py +0 -108
- autoglm_gui-1.5.0/phone_agent/agent.py +0 -253
- autoglm_gui-1.5.0/phone_agent/agent_ios.py +0 -277
- autoglm_gui-1.5.0/phone_agent/config/__init__.py +0 -53
- autoglm_gui-1.5.0/phone_agent/config/apps.py +0 -227
- autoglm_gui-1.5.0/phone_agent/config/apps_harmonyos.py +0 -256
- autoglm_gui-1.5.0/phone_agent/config/apps_ios.py +0 -339
- autoglm_gui-1.5.0/phone_agent/config/i18n.py +0 -81
- autoglm_gui-1.5.0/phone_agent/config/prompts.py +0 -80
- autoglm_gui-1.5.0/phone_agent/config/prompts_en.py +0 -79
- autoglm_gui-1.5.0/phone_agent/config/prompts_zh.py +0 -82
- autoglm_gui-1.5.0/phone_agent/config/timing.py +0 -167
- autoglm_gui-1.5.0/phone_agent/device_factory.py +0 -166
- autoglm_gui-1.5.0/phone_agent/hdc/__init__.py +0 -53
- autoglm_gui-1.5.0/phone_agent/hdc/connection.py +0 -384
- autoglm_gui-1.5.0/phone_agent/hdc/device.py +0 -269
- autoglm_gui-1.5.0/phone_agent/hdc/input.py +0 -145
- autoglm_gui-1.5.0/phone_agent/hdc/screenshot.py +0 -127
- autoglm_gui-1.5.0/phone_agent/model/__init__.py +0 -5
- autoglm_gui-1.5.0/phone_agent/model/client.py +0 -290
- autoglm_gui-1.5.0/phone_agent/xctest/__init__.py +0 -47
- autoglm_gui-1.5.0/phone_agent/xctest/connection.py +0 -379
- autoglm_gui-1.5.0/phone_agent/xctest/device.py +0 -472
- autoglm_gui-1.5.0/phone_agent/xctest/input.py +0 -311
- autoglm_gui-1.5.0/phone_agent/xctest/screenshot.py +0 -226
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/.gitignore +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/__main__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/actions/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/actions/handler.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/actions/types.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb/apps.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb/connection.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb/device.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb/input.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb/screenshot.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb/timing.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb_plus/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb_plus/device.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb_plus/ip.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb_plus/keyboard_installer.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb_plus/mdns.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb_plus/pair.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb_plus/qr_pair.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb_plus/screenshot.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb_plus/serial.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb_plus/touch.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/adb_plus/version.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/events.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/factory.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/glm/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/glm/message_builder.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/glm/parser.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/glm/prompts_en.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/glm/prompts_zh.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/mai/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/mai/parser.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/mai/prompts.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/mai/traj_memory.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/agents/protocols.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/control.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/devices.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/health.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/layered_agent.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/mcp.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/media.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/metrics.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/scheduled_tasks.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/version.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/api/workflows.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/config.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/config_manager.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/device_manager.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/device_protocol.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/devices/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/devices/adb_device.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/devices/mock_device.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/devices/remote_device.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/exceptions.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/history_manager.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/i18n.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/logger.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/metrics.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/model/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/model/message_builder.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/model/types.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/models/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/models/scheduled_task.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/parsers/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/parsers/base.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/parsers/phone_parser.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/phone_agent_manager.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/platform_utils.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/prompt_config.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/prompts/__init__.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/prompts.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/scrcpy_protocol.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/scrcpy_stream.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/server.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/socketio_server.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/state.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/static/assets/logo-Cyfm06Ym.png +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/static/assets/worker-D6BRitjy.js +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/static/favicon.ico +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/static/logo-192.png +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/static/logo-512.png +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/types.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/version.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/AutoGLM_GUI/workflow_manager.py +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/LICENSE +0 -0
- {autoglm_gui-1.5.0 → autoglm_gui-1.5.1}/scrcpy-server-v3.3.3 +0 -0
|
@@ -193,7 +193,12 @@ class GLMAgent:
|
|
|
193
193
|
)
|
|
194
194
|
else:
|
|
195
195
|
screen_info = MessageBuilder.build_screen_info(current_app)
|
|
196
|
-
|
|
196
|
+
# 如果有新的用户消息(多轮对话场景),把它加入消息中
|
|
197
|
+
if user_prompt:
|
|
198
|
+
text_content = f"{user_prompt}\n\n** Screen Info **\n\n{screen_info}"
|
|
199
|
+
else:
|
|
200
|
+
# 继续执行当前任务,只需要屏幕信息
|
|
201
|
+
text_content = f"** Screen Info **\n\n{screen_info}"
|
|
197
202
|
|
|
198
203
|
self._context.append(
|
|
199
204
|
MessageBuilder.create_user_message(
|
|
@@ -99,9 +99,14 @@ class AgentStepStreamer:
|
|
|
99
99
|
|
|
100
100
|
try:
|
|
101
101
|
# 执行 step 循环
|
|
102
|
+
# 使用会话级别的标记,而不是 agent.step_count
|
|
103
|
+
# 这样每次新对话开始时,第一步都会传递 task
|
|
104
|
+
is_first_in_session = True
|
|
102
105
|
while not self._stop_event.is_set():
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
result = self._agent.step(
|
|
107
|
+
self._task if is_first_in_session else None
|
|
108
|
+
)
|
|
109
|
+
is_first_in_session = False
|
|
105
110
|
|
|
106
111
|
# 发射 step 事件
|
|
107
112
|
self._event_queue.put(
|
|
@@ -200,7 +200,7 @@ def chat_stream(request: ChatRequest):
|
|
|
200
200
|
from AutoGLM_GUI.device_manager import DeviceManager
|
|
201
201
|
from AutoGLM_GUI.exceptions import AgentInitializationError, DeviceBusyError
|
|
202
202
|
from AutoGLM_GUI.history_manager import history_manager
|
|
203
|
-
from AutoGLM_GUI.models.history import ConversationRecord
|
|
203
|
+
from AutoGLM_GUI.models.history import ConversationRecord, MessageRecord
|
|
204
204
|
from AutoGLM_GUI.phone_agent_manager import PhoneAgentManager
|
|
205
205
|
|
|
206
206
|
device_id = request.device_id
|
|
@@ -213,6 +213,17 @@ def chat_stream(request: ChatRequest):
|
|
|
213
213
|
final_success = False
|
|
214
214
|
final_steps = 0
|
|
215
215
|
|
|
216
|
+
# 收集完整对话消息
|
|
217
|
+
messages: list[MessageRecord] = []
|
|
218
|
+
# 添加用户消息
|
|
219
|
+
messages.append(
|
|
220
|
+
MessageRecord(
|
|
221
|
+
role="user",
|
|
222
|
+
content=request.message,
|
|
223
|
+
timestamp=start_time,
|
|
224
|
+
)
|
|
225
|
+
)
|
|
226
|
+
|
|
216
227
|
try:
|
|
217
228
|
acquired = manager.acquire_device(
|
|
218
229
|
device_id, timeout=0, raise_on_timeout=True, auto_initialize=True
|
|
@@ -235,6 +246,19 @@ def chat_stream(request: ChatRequest):
|
|
|
235
246
|
):
|
|
236
247
|
continue
|
|
237
248
|
|
|
249
|
+
# 收集每个 step 的消息
|
|
250
|
+
if event_type == AgentEventType.STEP.value:
|
|
251
|
+
messages.append(
|
|
252
|
+
MessageRecord(
|
|
253
|
+
role="assistant",
|
|
254
|
+
content="",
|
|
255
|
+
timestamp=datetime.now(),
|
|
256
|
+
thinking=event_data_dict.get("thinking"),
|
|
257
|
+
action=event_data_dict.get("action"),
|
|
258
|
+
step=event_data_dict.get("step"),
|
|
259
|
+
)
|
|
260
|
+
)
|
|
261
|
+
|
|
238
262
|
if event_type == AgentEventType.DONE.value:
|
|
239
263
|
final_message = event_data_dict.get("message", "")
|
|
240
264
|
final_success = event_data_dict.get("success", False)
|
|
@@ -263,6 +287,7 @@ def chat_stream(request: ChatRequest):
|
|
|
263
287
|
duration_ms=int((end_time - start_time).total_seconds() * 1000),
|
|
264
288
|
source="chat",
|
|
265
289
|
error_message=None if final_success else final_message,
|
|
290
|
+
messages=messages,
|
|
266
291
|
)
|
|
267
292
|
history_manager.add_record(serialno, record)
|
|
268
293
|
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
from fastapi import APIRouter, HTTPException
|
|
4
4
|
|
|
5
5
|
from AutoGLM_GUI.history_manager import history_manager
|
|
6
|
-
from AutoGLM_GUI.schemas import
|
|
6
|
+
from AutoGLM_GUI.schemas import (
|
|
7
|
+
HistoryListResponse,
|
|
8
|
+
HistoryRecordResponse,
|
|
9
|
+
MessageRecordResponse,
|
|
10
|
+
)
|
|
7
11
|
|
|
8
12
|
router = APIRouter()
|
|
9
13
|
|
|
@@ -34,6 +38,17 @@ def list_history(
|
|
|
34
38
|
source=r.source,
|
|
35
39
|
source_detail=r.source_detail,
|
|
36
40
|
error_message=r.error_message,
|
|
41
|
+
messages=[
|
|
42
|
+
MessageRecordResponse(
|
|
43
|
+
role=m.role,
|
|
44
|
+
content=m.content,
|
|
45
|
+
timestamp=m.timestamp.isoformat(),
|
|
46
|
+
thinking=m.thinking,
|
|
47
|
+
action=m.action,
|
|
48
|
+
step=m.step,
|
|
49
|
+
)
|
|
50
|
+
for m in r.messages
|
|
51
|
+
],
|
|
37
52
|
)
|
|
38
53
|
for r in records
|
|
39
54
|
],
|
|
@@ -61,6 +76,17 @@ def get_history_record(serialno: str, record_id: str) -> HistoryRecordResponse:
|
|
|
61
76
|
source=record.source,
|
|
62
77
|
source_detail=record.source_detail,
|
|
63
78
|
error_message=record.error_message,
|
|
79
|
+
messages=[
|
|
80
|
+
MessageRecordResponse(
|
|
81
|
+
role=m.role,
|
|
82
|
+
content=m.content,
|
|
83
|
+
timestamp=m.timestamp.isoformat(),
|
|
84
|
+
thinking=m.thinking,
|
|
85
|
+
action=m.action,
|
|
86
|
+
step=m.step,
|
|
87
|
+
)
|
|
88
|
+
for m in record.messages
|
|
89
|
+
],
|
|
64
90
|
)
|
|
65
91
|
|
|
66
92
|
|
|
@@ -2,10 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass, field
|
|
4
4
|
from datetime import datetime
|
|
5
|
-
from typing import Literal
|
|
5
|
+
from typing import Any, Literal
|
|
6
6
|
from uuid import uuid4
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
@dataclass
|
|
10
|
+
class MessageRecord:
|
|
11
|
+
"""对话中的单条消息记录."""
|
|
12
|
+
|
|
13
|
+
role: Literal["user", "assistant"]
|
|
14
|
+
content: str
|
|
15
|
+
timestamp: datetime = field(default_factory=datetime.now)
|
|
16
|
+
|
|
17
|
+
# assistant 消息特有字段
|
|
18
|
+
thinking: str | None = None
|
|
19
|
+
action: dict[str, Any] | None = None
|
|
20
|
+
step: int | None = None
|
|
21
|
+
|
|
22
|
+
def to_dict(self) -> dict:
|
|
23
|
+
"""转换为可序列化的字典."""
|
|
24
|
+
return {
|
|
25
|
+
"role": self.role,
|
|
26
|
+
"content": self.content,
|
|
27
|
+
"timestamp": self.timestamp.isoformat(),
|
|
28
|
+
"thinking": self.thinking,
|
|
29
|
+
"action": self.action,
|
|
30
|
+
"step": self.step,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def from_dict(cls, data: dict) -> "MessageRecord":
|
|
35
|
+
"""从字典创建实例."""
|
|
36
|
+
return cls(
|
|
37
|
+
role=data.get("role", "user"),
|
|
38
|
+
content=data.get("content", ""),
|
|
39
|
+
timestamp=datetime.fromisoformat(data["timestamp"])
|
|
40
|
+
if data.get("timestamp")
|
|
41
|
+
else datetime.now(),
|
|
42
|
+
thinking=data.get("thinking"),
|
|
43
|
+
action=data.get("action"),
|
|
44
|
+
step=data.get("step"),
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
9
48
|
@dataclass
|
|
10
49
|
class ConversationRecord:
|
|
11
50
|
"""单条对话记录."""
|
|
@@ -30,6 +69,9 @@ class ConversationRecord:
|
|
|
30
69
|
# 错误信息
|
|
31
70
|
error_message: str | None = None
|
|
32
71
|
|
|
72
|
+
# 完整对话消息列表
|
|
73
|
+
messages: list[MessageRecord] = field(default_factory=list)
|
|
74
|
+
|
|
33
75
|
def to_dict(self) -> dict:
|
|
34
76
|
"""转换为可序列化的字典."""
|
|
35
77
|
return {
|
|
@@ -44,6 +86,7 @@ class ConversationRecord:
|
|
|
44
86
|
"source": self.source,
|
|
45
87
|
"source_detail": self.source_detail,
|
|
46
88
|
"error_message": self.error_message,
|
|
89
|
+
"messages": [m.to_dict() for m in self.messages],
|
|
47
90
|
}
|
|
48
91
|
|
|
49
92
|
@classmethod
|
|
@@ -65,6 +108,7 @@ class ConversationRecord:
|
|
|
65
108
|
source=data.get("source", "chat"),
|
|
66
109
|
source_detail=data.get("source_detail", ""),
|
|
67
110
|
error_message=data.get("error_message"),
|
|
111
|
+
messages=[MessageRecord.from_dict(m) for m in data.get("messages", [])],
|
|
68
112
|
)
|
|
69
113
|
|
|
70
114
|
|
|
@@ -177,7 +177,7 @@ class SchedulerManager:
|
|
|
177
177
|
|
|
178
178
|
from AutoGLM_GUI.device_manager import DeviceManager
|
|
179
179
|
from AutoGLM_GUI.history_manager import history_manager
|
|
180
|
-
from AutoGLM_GUI.models.history import ConversationRecord
|
|
180
|
+
from AutoGLM_GUI.models.history import ConversationRecord, MessageRecord
|
|
181
181
|
from AutoGLM_GUI.phone_agent_manager import PhoneAgentManager
|
|
182
182
|
from AutoGLM_GUI.workflow_manager import workflow_manager
|
|
183
183
|
|
|
@@ -210,27 +210,72 @@ class SchedulerManager:
|
|
|
210
210
|
return
|
|
211
211
|
|
|
212
212
|
start_time = datetime.now()
|
|
213
|
+
|
|
214
|
+
# 收集完整对话消息
|
|
215
|
+
messages: list[MessageRecord] = []
|
|
216
|
+
messages.append(
|
|
217
|
+
MessageRecord(
|
|
218
|
+
role="user",
|
|
219
|
+
content=workflow["text"],
|
|
220
|
+
timestamp=start_time,
|
|
221
|
+
)
|
|
222
|
+
)
|
|
223
|
+
|
|
213
224
|
try:
|
|
214
225
|
agent = manager.get_agent(device.primary_device_id)
|
|
215
226
|
agent.reset()
|
|
216
|
-
result = agent.run(workflow["text"])
|
|
217
|
-
steps = agent.step_count
|
|
218
227
|
|
|
228
|
+
# 使用 step 循环执行,收集每步信息
|
|
229
|
+
is_first = True
|
|
230
|
+
result_message = ""
|
|
231
|
+
task_success = False
|
|
232
|
+
|
|
233
|
+
while agent.step_count < agent.agent_config.max_steps:
|
|
234
|
+
step_result = agent.step(workflow["text"] if is_first else None)
|
|
235
|
+
is_first = False
|
|
236
|
+
|
|
237
|
+
# 收集每个 step 的消息
|
|
238
|
+
messages.append(
|
|
239
|
+
MessageRecord(
|
|
240
|
+
role="assistant",
|
|
241
|
+
content="",
|
|
242
|
+
timestamp=datetime.now(),
|
|
243
|
+
thinking=step_result.thinking,
|
|
244
|
+
action=step_result.action,
|
|
245
|
+
step=agent.step_count,
|
|
246
|
+
)
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
if step_result.finished:
|
|
250
|
+
result_message = step_result.message or "Task completed"
|
|
251
|
+
task_success = step_result.success
|
|
252
|
+
break
|
|
253
|
+
else:
|
|
254
|
+
result_message = "Max steps reached"
|
|
255
|
+
task_success = False
|
|
256
|
+
|
|
257
|
+
steps = agent.step_count
|
|
219
258
|
end_time = datetime.now()
|
|
259
|
+
|
|
220
260
|
record = ConversationRecord(
|
|
221
261
|
task_text=workflow["text"],
|
|
222
|
-
final_message=
|
|
223
|
-
success=
|
|
262
|
+
final_message=result_message,
|
|
263
|
+
success=task_success,
|
|
224
264
|
steps=steps,
|
|
225
265
|
start_time=start_time,
|
|
226
266
|
end_time=end_time,
|
|
227
267
|
duration_ms=int((end_time - start_time).total_seconds() * 1000),
|
|
228
268
|
source="scheduled",
|
|
229
269
|
source_detail=task.name,
|
|
270
|
+
error_message=None if task_success else result_message,
|
|
271
|
+
messages=messages,
|
|
230
272
|
)
|
|
231
273
|
history_manager.add_record(task.device_serialno, record)
|
|
232
274
|
|
|
233
|
-
|
|
275
|
+
if task_success:
|
|
276
|
+
self._record_success(task, result_message)
|
|
277
|
+
else:
|
|
278
|
+
self._record_failure(task, result_message)
|
|
234
279
|
|
|
235
280
|
except Exception as e:
|
|
236
281
|
end_time = datetime.now()
|
|
@@ -248,6 +293,7 @@ class SchedulerManager:
|
|
|
248
293
|
source="scheduled",
|
|
249
294
|
source_detail=task.name,
|
|
250
295
|
error_message=error_msg,
|
|
296
|
+
messages=messages,
|
|
251
297
|
)
|
|
252
298
|
history_manager.add_record(task.device_serialno, record)
|
|
253
299
|
|
|
@@ -702,6 +702,17 @@ class ReinitAllAgentsResponse(BaseModel):
|
|
|
702
702
|
# History Models
|
|
703
703
|
|
|
704
704
|
|
|
705
|
+
class MessageRecordResponse(BaseModel):
|
|
706
|
+
"""对话消息响应."""
|
|
707
|
+
|
|
708
|
+
role: str # "user" | "assistant"
|
|
709
|
+
content: str
|
|
710
|
+
timestamp: str
|
|
711
|
+
thinking: str | None = None
|
|
712
|
+
action: dict | None = None
|
|
713
|
+
step: int | None = None
|
|
714
|
+
|
|
715
|
+
|
|
705
716
|
class HistoryRecordResponse(BaseModel):
|
|
706
717
|
"""历史记录条目响应."""
|
|
707
718
|
|
|
@@ -716,6 +727,7 @@ class HistoryRecordResponse(BaseModel):
|
|
|
716
727
|
source: str
|
|
717
728
|
source_detail: str
|
|
718
729
|
error_message: str | None
|
|
730
|
+
messages: list[MessageRecordResponse] = []
|
|
719
731
|
|
|
720
732
|
|
|
721
733
|
class HistoryListResponse(BaseModel):
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o}from"./index-
|
|
1
|
+
import{j as o}from"./index-CTHbFvKl.js";function t(){return o.jsx("div",{className:"p-2",children:o.jsx("h3",{children:"About"})})}export{t as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as u,r as o,j as a,b as r,B as d}from"./index-
|
|
1
|
+
import{o as u,r as o,j as a,b as r,B as d}from"./index-CTHbFvKl.js";import{P as g,c as x,b as f,d as m}from"./popover--JTJrE5v.js";import{D as p,d as h,e as w,f as j,g as D}from"./dialog-FNwZJFwk.js";const N=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],b=u("check",N),c=o.createContext(void 0),P=({value:t="",onValueChange:e,children:s})=>{const[n,l]=o.useState(!1);return a.jsx(c.Provider,{value:{value:t,onValueChange:e||(()=>{}),open:n,setOpen:l},children:a.jsx(g,{open:n,onOpenChange:l,children:s})})},C=o.forwardRef(({className:t,children:e,...s},n)=>{if(!o.useContext(c))throw new Error("SelectTrigger must be used within Select");return a.jsx(x,{asChild:!0,children:a.jsxs("button",{ref:n,className:r("flex h-10 w-full items-center justify-between rounded-md border border-slate-200 bg-white px-3 py-2 text-sm ring-offset-white placeholder:text-slate-500 focus:outline-none focus:ring-2 focus:ring-slate-950 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:ring-offset-slate-950 dark:placeholder:text-slate-400 dark:focus:ring-slate-300",t),...s,children:[e,a.jsx(f,{className:"h-4 w-4 opacity-50"})]})})});C.displayName="SelectTrigger";const V=({placeholder:t})=>{const e=o.useContext(c);if(!e)throw new Error("SelectValue must be used within Select");return a.jsx("span",{className:e.value?"":"text-slate-500",children:e.value||t})},I=({children:t,className:e})=>a.jsx(m,{className:r("w-[var(--radix-popover-trigger-width)] p-1",e),children:t}),O=({value:t,children:e,disabled:s,className:n})=>{const l=o.useContext(c);if(!l)throw new Error("SelectItem must be used within Select");const i=l.value===t;return a.jsxs("div",{role:"option","aria-selected":i,className:r("relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none hover:bg-slate-100 focus:bg-slate-100 dark:hover:bg-slate-800 dark:focus:bg-slate-800",s&&"pointer-events-none opacity-50",n),onClick:()=>{s||(l.onValueChange(t),l.setOpen(!1))},children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i&&a.jsx(b,{className:"h-4 w-4"})}),e]})},B=({open:t,onOpenChange:e,children:s})=>a.jsx(p,{open:t,onOpenChange:e,children:s}),v=o.forwardRef(({className:t,...e},s)=>a.jsx(h,{ref:s,className:r("sm:max-w-[425px]",t),...e}));v.displayName="AlertDialogContent";const F=({className:t,...e})=>a.jsx(w,{className:r(t),...e}),H=({className:t,...e})=>a.jsx(D,{className:r(t),...e}),A=o.forwardRef(({className:t,...e},s)=>a.jsx(j,{ref:s,className:r(t),...e}));A.displayName="AlertDialogTitle";const S=o.forwardRef(({className:t,...e},s)=>a.jsx("p",{ref:s,className:r("text-sm text-slate-500 dark:text-slate-400",t),...e}));S.displayName="AlertDialogDescription";const y=o.forwardRef(({className:t,...e},s)=>a.jsx(d,{ref:s,className:r(t),...e}));y.displayName="AlertDialogAction";const k=o.forwardRef(({className:t,...e},s)=>a.jsx(d,{ref:s,variant:"outline",className:r(t),...e}));k.displayName="AlertDialogCancel";export{B as A,P as S,C as a,V as b,I as c,O as d,v as e,F as f,A as g,S as h,H as i,k as j,y as k};
|