@autotest/agent 0.0.1 → 0.0.2
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.
- package/dist/api/agent_api.d.ts.map +1 -0
- package/dist/api/agent_api.js +550 -0
- package/dist/api/agent_api.js.map +1 -0
- package/dist/api/autotest_agent.d.ts.map +1 -0
- package/dist/api/autotest_agent.js +206 -0
- package/dist/api/autotest_agent.js.map +1 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +12 -0
- package/dist/api/types.js.map +1 -0
- package/dist/autotest-cli.d.ts +1 -0
- package/dist/autotest-cli.d.ts.map +1 -0
- package/dist/autotest-cli.js +392 -0
- package/dist/autotest-cli.js.map +1 -0
- package/dist/common/case_manager.d.ts.map +1 -0
- package/dist/common/case_manager.js +92 -0
- package/dist/common/case_manager.js.map +1 -0
- package/dist/common/collect_case.d.ts.map +1 -0
- package/dist/common/collect_case.js +129 -0
- package/dist/common/collect_case.js.map +1 -0
- package/dist/common/common_errors.d.ts.map +1 -0
- package/dist/common/common_errors.js +67 -0
- package/dist/common/common_errors.js.map +1 -0
- package/dist/common/config/config_validator.d.ts.map +1 -0
- package/dist/common/config/config_validator.js +29 -0
- package/dist/common/config/config_validator.js.map +1 -0
- package/dist/common/config/manager.d.ts.map +1 -0
- package/dist/common/config/manager.js +258 -0
- package/dist/common/config/manager.js.map +1 -0
- package/dist/common/config/output.d.ts.map +1 -0
- package/dist/common/config/output.js +60 -0
- package/dist/common/config/output.js.map +1 -0
- package/dist/common/config/types.d.ts.map +1 -0
- package/dist/common/config/types.js +185 -0
- package/dist/common/config/types.js.map +1 -0
- package/dist/common/dfx/client_factory.d.ts.map +1 -0
- package/dist/common/dfx/client_factory.js +63 -0
- package/dist/common/dfx/client_factory.js.map +1 -0
- package/dist/common/dfx/context.d.ts.map +1 -0
- package/dist/common/dfx/context.js +24 -0
- package/dist/common/dfx/context.js.map +1 -0
- package/dist/common/dfx/index.d.ts.map +1 -0
- package/dist/common/dfx/index.js +16 -0
- package/dist/common/dfx/index.js.map +1 -0
- package/dist/common/dfx/recorder.d.ts.map +1 -0
- package/dist/common/dfx/recorder.js +192 -0
- package/dist/common/dfx/recorder.js.map +1 -0
- package/dist/common/dfx/recording_fetch.d.ts.map +1 -0
- package/dist/common/dfx/recording_fetch.js +229 -0
- package/dist/common/dfx/recording_fetch.js.map +1 -0
- package/dist/common/dfx/source.d.ts.map +1 -0
- package/dist/common/dfx/source.js +14 -0
- package/dist/common/dfx/source.js.map +1 -0
- package/dist/common/image_cacher.d.ts.map +1 -0
- package/dist/common/image_cacher.js +37 -0
- package/dist/common/image_cacher.js.map +1 -0
- package/dist/common/image_helper.d.ts.map +1 -0
- package/dist/common/image_helper.js +129 -0
- package/dist/common/image_helper.js.map +1 -0
- package/dist/common/image_similarity.d.ts.map +1 -0
- package/dist/common/image_similarity.js +172 -0
- package/dist/common/image_similarity.js.map +1 -0
- package/dist/common/llm_cache/cache_transport.d.ts.map +1 -0
- package/dist/common/llm_cache/cache_transport.js +99 -0
- package/dist/common/llm_cache/cache_transport.js.map +1 -0
- package/dist/common/logger.d.ts.map +1 -0
- package/dist/common/logger.js +159 -0
- package/dist/common/logger.js.map +1 -0
- package/dist/common/model/custom_model.d.ts.map +1 -0
- package/dist/common/model/custom_model.js +435 -0
- package/dist/common/model/custom_model.js.map +1 -0
- package/dist/common/model/index.d.ts.map +1 -0
- package/dist/common/model/index.js +6 -0
- package/dist/common/model/index.js.map +1 -0
- package/dist/common/path_utils.d.ts.map +1 -0
- package/dist/common/path_utils.js +82 -0
- package/dist/common/path_utils.js.map +1 -0
- package/dist/common/result_parser.d.ts.map +1 -0
- package/dist/common/result_parser.js +50 -0
- package/dist/common/result_parser.js.map +1 -0
- package/dist/common/usage/token_usage.d.ts.map +1 -0
- package/dist/common/usage/token_usage.js +118 -0
- package/dist/common/usage/token_usage.js.map +1 -0
- package/dist/common/utils.d.ts.map +1 -0
- package/dist/common/utils.js +126 -0
- package/dist/common/utils.js.map +1 -0
- package/dist/core/agent/layered_agent/ability_helper.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/ability_helper.js +126 -0
- package/dist/core/agent/layered_agent/ability_helper.js.map +1 -0
- package/dist/core/agent/layered_agent/agent.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/agent.js +38 -0
- package/dist/core/agent/layered_agent/agent.js.map +1 -0
- package/dist/core/agent/layered_agent/agent_registry.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/agent_registry.js +76 -0
- package/dist/core/agent/layered_agent/agent_registry.js.map +1 -0
- package/dist/core/agent/layered_agent/decision.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/decision.js +479 -0
- package/dist/core/agent/layered_agent/decision.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/action_handler.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/action_handler.js +156 -0
- package/dist/core/agent/layered_agent/execute_agent/action_handler.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/agent_factory.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/agent_factory.js +42 -0
- package/dist/core/agent/layered_agent/execute_agent/agent_factory.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/base_agent.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/base_agent.js +113 -0
- package/dist/core/agent/layered_agent/execute_agent/base_agent.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/general_agent.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/general_agent.js +208 -0
- package/dist/core/agent/layered_agent/execute_agent/general_agent.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/glm_agent.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/glm_agent.js +242 -0
- package/dist/core/agent/layered_agent/execute_agent/glm_agent.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/i18n.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/i18n.js +35 -0
- package/dist/core/agent/layered_agent/execute_agent/i18n.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/index.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/index.js +68 -0
- package/dist/core/agent/layered_agent/execute_agent/index.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/mai_ui_agent.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/mai_ui_agent.js +317 -0
- package/dist/core/agent/layered_agent/execute_agent/mai_ui_agent.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/mcp_prompts.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/mcp_prompts.js +155 -0
- package/dist/core/agent/layered_agent/execute_agent/mcp_prompts.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/parser/general_parser.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/parser/general_parser.js +244 -0
- package/dist/core/agent/layered_agent/execute_agent/parser/general_parser.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/parser/glm_parser.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/parser/glm_parser.js +140 -0
- package/dist/core/agent/layered_agent/execute_agent/parser/glm_parser.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/parser/index.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/parser/index.js +10 -0
- package/dist/core/agent/layered_agent/execute_agent/parser/index.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/parser/mai_ui_parser.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/parser/mai_ui_parser.js +95 -0
- package/dist/core/agent/layered_agent/execute_agent/parser/mai_ui_parser.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/prompts.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/prompts.js +110 -0
- package/dist/core/agent/layered_agent/execute_agent/prompts.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/simple_reporter.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/simple_reporter.js +34 -0
- package/dist/core/agent/layered_agent/execute_agent/simple_reporter.js.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/utils.d.ts.map +1 -0
- package/dist/core/agent/layered_agent/execute_agent/utils.js +53 -0
- package/dist/core/agent/layered_agent/execute_agent/utils.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/agent.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/agent.js +566 -0
- package/dist/core/agent/report_analyzer_agent/agent.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/config.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/config.js +23 -0
- package/dist/core/agent/report_analyzer_agent/config.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/data_loader.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/data_loader.js +256 -0
- package/dist/core/agent/report_analyzer_agent/data_loader.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/guardrails.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/guardrails.js +100 -0
- package/dist/core/agent/report_analyzer_agent/guardrails.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/hooks.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/hooks.js +32 -0
- package/dist/core/agent/report_analyzer_agent/hooks.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/index.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/index.js +53 -0
- package/dist/core/agent/report_analyzer_agent/index.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/key_steps_builder.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/key_steps_builder.js +43 -0
- package/dist/core/agent/report_analyzer_agent/key_steps_builder.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/mapping.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/mapping.js +134 -0
- package/dist/core/agent/report_analyzer_agent/mapping.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/parse.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/parse.js +376 -0
- package/dist/core/agent/report_analyzer_agent/parse.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/prompt.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/prompt.js +301 -0
- package/dist/core/agent/report_analyzer_agent/prompt.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/report_writer.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/report_writer.js +559 -0
- package/dist/core/agent/report_analyzer_agent/report_writer.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/tools.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/tools.js +151 -0
- package/dist/core/agent/report_analyzer_agent/tools.js.map +1 -0
- package/dist/core/agent/report_analyzer_agent/types.d.ts.map +1 -0
- package/dist/core/agent/report_analyzer_agent/types.js +275 -0
- package/dist/core/agent/report_analyzer_agent/types.js.map +1 -0
- package/dist/core/agent/rewrite_agent/agent.d.ts.map +1 -0
- package/dist/core/agent/rewrite_agent/agent.js +210 -0
- package/dist/core/agent/rewrite_agent/agent.js.map +1 -0
- package/dist/core/agent/rewrite_agent/guardrails.d.ts.map +1 -0
- package/dist/core/agent/rewrite_agent/guardrails.js +96 -0
- package/dist/core/agent/rewrite_agent/guardrails.js.map +1 -0
- package/dist/core/agent/rewrite_agent/mapping.d.ts.map +1 -0
- package/dist/core/agent/rewrite_agent/mapping.js +57 -0
- package/dist/core/agent/rewrite_agent/mapping.js.map +1 -0
- package/dist/core/agent/rewrite_agent/parse.d.ts.map +1 -0
- package/dist/core/agent/rewrite_agent/parse.js +122 -0
- package/dist/core/agent/rewrite_agent/parse.js.map +1 -0
- package/dist/core/agent/rewrite_agent/types.d.ts.map +1 -0
- package/dist/core/agent/rewrite_agent/types.js +38 -0
- package/dist/core/agent/rewrite_agent/types.js.map +1 -0
- package/dist/core/agent/single_agent/agent.d.ts.map +1 -0
- package/dist/core/agent/single_agent/agent.js +799 -0
- package/dist/core/agent/single_agent/agent.js.map +1 -0
- package/dist/core/agent/single_agent/hook_manager.d.ts.map +1 -0
- package/dist/core/agent/single_agent/hook_manager.js +61 -0
- package/dist/core/agent/single_agent/hook_manager.js.map +1 -0
- package/dist/core/agent/single_agent/hooks.d.ts.map +1 -0
- package/dist/core/agent/single_agent/hooks.js +289 -0
- package/dist/core/agent/single_agent/hooks.js.map +1 -0
- package/dist/core/agent/single_agent/image_utils.d.ts.map +1 -0
- package/dist/core/agent/single_agent/image_utils.js +160 -0
- package/dist/core/agent/single_agent/image_utils.js.map +1 -0
- package/dist/core/agent/single_agent/scroll_search_agent.d.ts.map +1 -0
- package/dist/core/agent/single_agent/scroll_search_agent.js +377 -0
- package/dist/core/agent/single_agent/scroll_search_agent.js.map +1 -0
- package/dist/core/agent/single_agent/subagent_manager.d.ts.map +1 -0
- package/dist/core/agent/single_agent/subagent_manager.js +74 -0
- package/dist/core/agent/single_agent/subagent_manager.js.map +1 -0
- package/dist/core/agent/single_agent/tool_recorder_hook.d.ts.map +1 -0
- package/dist/core/agent/single_agent/tool_recorder_hook.js +43 -0
- package/dist/core/agent/single_agent/tool_recorder_hook.js.map +1 -0
- package/dist/core/agent/types.d.ts.map +1 -0
- package/dist/core/agent/types.js +3 -0
- package/dist/core/agent/types.js.map +1 -0
- package/dist/core/agent/utils/message_builder.d.ts.map +1 -0
- package/dist/core/agent/utils/message_builder.js +139 -0
- package/dist/core/agent/utils/message_builder.js.map +1 -0
- package/dist/core/device/device_protocol.d.ts.map +1 -0
- package/dist/core/device/device_protocol.js +3 -0
- package/dist/core/device/device_protocol.js.map +1 -0
- package/dist/core/device/hdc/apps.d.ts.map +1 -0
- package/dist/core/device/hdc/apps.js +438 -0
- package/dist/core/device/hdc/apps.js.map +1 -0
- package/dist/core/device/hdc/device.d.ts.map +1 -0
- package/dist/core/device/hdc/device.js +220 -0
- package/dist/core/device/hdc/device.js.map +1 -0
- package/dist/core/device/hdc/index.d.ts.map +1 -0
- package/dist/core/device/hdc/index.js +32 -0
- package/dist/core/device/hdc/index.js.map +1 -0
- package/dist/core/device/hdc/input.d.ts.map +1 -0
- package/dist/core/device/hdc/input.js +75 -0
- package/dist/core/device/hdc/input.js.map +1 -0
- package/dist/core/device/hdc/screenshot.d.ts.map +1 -0
- package/dist/core/device/hdc/screenshot.js +172 -0
- package/dist/core/device/hdc/screenshot.js.map +1 -0
- package/dist/core/device/index.d.ts.map +1 -0
- package/dist/core/device/index.js +71 -0
- package/dist/core/device/index.js.map +1 -0
- package/dist/core/device/types.d.ts.map +1 -0
- package/dist/core/device/types.js +3 -0
- package/dist/core/device/types.js.map +1 -0
- package/dist/core/knowledge/knowledge_manager.d.ts.map +1 -0
- package/dist/core/knowledge/knowledge_manager.js +71 -0
- package/dist/core/knowledge/knowledge_manager.js.map +1 -0
- package/dist/core/knowledge/vectordb.d.ts.map +1 -0
- package/dist/core/knowledge/vectordb.js +284 -0
- package/dist/core/knowledge/vectordb.js.map +1 -0
- package/dist/core/mcp/adapter_factory.d.ts.map +1 -0
- package/dist/core/mcp/adapter_factory.js +100 -0
- package/dist/core/mcp/adapter_factory.js.map +1 -0
- package/dist/core/mcp/android_adapter.d.ts.map +1 -0
- package/dist/core/mcp/android_adapter.js +287 -0
- package/dist/core/mcp/android_adapter.js.map +1 -0
- package/dist/core/mcp/base_adapter.d.ts.map +1 -0
- package/dist/core/mcp/base_adapter.js +87 -0
- package/dist/core/mcp/base_adapter.js.map +1 -0
- package/dist/core/mcp/harmony_hdc_adapter.d.ts.map +1 -0
- package/dist/core/mcp/harmony_hdc_adapter.js +589 -0
- package/dist/core/mcp/harmony_hdc_adapter.js.map +1 -0
- package/dist/core/mcp/ios_adapter.d.ts.map +1 -0
- package/dist/core/mcp/ios_adapter.js +287 -0
- package/dist/core/mcp/ios_adapter.js.map +1 -0
- package/dist/core/mcp/local_tools.d.ts.map +1 -0
- package/dist/core/mcp/local_tools.js +42 -0
- package/dist/core/mcp/local_tools.js.map +1 -0
- package/dist/core/mcp/mcp_tools.d.ts.map +1 -0
- package/dist/core/mcp/mcp_tools.js +383 -0
- package/dist/core/mcp/mcp_tools.js.map +1 -0
- package/dist/core/mcp/types.d.ts.map +1 -0
- package/dist/core/mcp/types.js +7 -0
- package/dist/core/mcp/types.js.map +1 -0
- package/dist/core/memory/compressed_session.d.ts.map +1 -0
- package/dist/core/memory/compressed_session.js +183 -0
- package/dist/core/memory/compressed_session.js.map +1 -0
- package/dist/core/memory/context_compressor.d.ts.map +1 -0
- package/dist/core/memory/context_compressor.js +177 -0
- package/dist/core/memory/context_compressor.js.map +1 -0
- package/dist/core/memory/index.d.ts.map +1 -0
- package/dist/core/memory/index.js +23 -0
- package/dist/core/memory/index.js.map +1 -0
- package/dist/core/memory/memory_manager.d.ts.map +1 -0
- package/dist/core/memory/memory_manager.js +29 -0
- package/dist/core/memory/memory_manager.js.map +1 -0
- package/dist/core/memory/reflector.d.ts.map +1 -0
- package/dist/core/memory/reflector.js +96 -0
- package/dist/core/memory/reflector.js.map +1 -0
- package/dist/core/memory/session_factory.d.ts.map +1 -0
- package/dist/core/memory/session_factory.js +30 -0
- package/dist/core/memory/session_factory.js.map +1 -0
- package/dist/core/memory/tool_player.d.ts.map +1 -0
- package/dist/core/memory/tool_player.js +226 -0
- package/dist/core/memory/tool_player.js.map +1 -0
- package/dist/core/memory/tool_recorder.d.ts.map +1 -0
- package/dist/core/memory/tool_recorder.js +127 -0
- package/dist/core/memory/tool_recorder.js.map +1 -0
- package/dist/core/preprocessor/task_splitter.d.ts.map +1 -0
- package/dist/core/preprocessor/task_splitter.js +113 -0
- package/dist/core/preprocessor/task_splitter.js.map +1 -0
- package/dist/core/prompt/prompt_loader.d.ts.map +1 -0
- package/dist/core/prompt/prompt_loader.js +314 -0
- package/dist/core/prompt/prompt_loader.js.map +1 -0
- package/dist/core/skill/skill_manager.d.ts.map +1 -0
- package/dist/core/skill/skill_manager.js +300 -0
- package/dist/core/skill/skill_manager.js.map +1 -0
- package/dist/data_types/action.d.ts.map +1 -0
- package/dist/data_types/action.js +3 -0
- package/dist/data_types/action.js.map +1 -0
- package/dist/data_types/agent.d.ts.map +1 -0
- package/dist/data_types/agent.js +3 -0
- package/dist/data_types/agent.js.map +1 -0
- package/dist/data_types/device.d.ts.map +1 -0
- package/dist/data_types/device.js +3 -0
- package/dist/data_types/device.js.map +1 -0
- package/dist/data_types/index.d.ts.map +1 -0
- package/dist/data_types/index.js +7 -0
- package/dist/data_types/index.js.map +1 -0
- package/dist/data_types/report.d.ts.map +1 -0
- package/dist/data_types/report.js +7 -0
- package/dist/data_types/report.js.map +1 -0
- package/dist/data_types/task.d.ts.map +1 -0
- package/dist/data_types/task.js +3 -0
- package/dist/data_types/task.js.map +1 -0
- package/dist/hypium_generator/generator.d.ts.map +1 -0
- package/dist/hypium_generator/generator.js +847 -0
- package/dist/hypium_generator/generator.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +136 -1
- package/dist/index.js.map +1 -0
- package/dist/loop/cli.d.ts.map +1 -0
- package/dist/loop/cli.js +128 -0
- package/dist/loop/cli.js.map +1 -0
- package/dist/loop/orchestrator.d.ts.map +1 -0
- package/dist/loop/orchestrator.js +315 -0
- package/dist/loop/orchestrator.js.map +1 -0
- package/dist/loop/result_writer.d.ts.map +1 -0
- package/dist/loop/result_writer.js +261 -0
- package/dist/loop/result_writer.js.map +1 -0
- package/dist/loop/types.d.ts.map +1 -0
- package/dist/loop/types.js +83 -0
- package/dist/loop/types.js.map +1 -0
- package/dist/mcp-server/server.d.ts.map +1 -0
- package/dist/mcp-server/server.js +277 -0
- package/dist/mcp-server/server.js.map +1 -0
- package/dist/mcp-server/types.d.ts.map +1 -0
- package/dist/mcp-server/types.js +82 -0
- package/dist/mcp-server/types.js.map +1 -0
- package/dist/reporter/batch_summary.d.ts.map +1 -0
- package/dist/reporter/batch_summary.js +198 -0
- package/dist/reporter/batch_summary.js.map +1 -0
- package/dist/reporter/generator.d.ts.map +1 -0
- package/dist/reporter/generator.js +773 -0
- package/dist/reporter/generator.js.map +1 -0
- package/dist/reporter/types.d.ts.map +1 -0
- package/dist/reporter/types.js +45 -0
- package/dist/reporter/types.js.map +1 -0
- package/dist/tools/batch_runner.d.ts +1 -0
- package/dist/tools/batch_runner.d.ts.map +1 -0
- package/dist/tools/batch_runner.js +722 -0
- package/dist/tools/batch_runner.js.map +1 -0
- package/package.json +4 -2
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FastActionAgent = exports.SingleAgent = void 0;
|
|
4
|
+
const ai_1 = require("ai");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const types_1 = require("../../../reporter/types");
|
|
7
|
+
const utils_1 = require("../../../common/utils");
|
|
8
|
+
const hook_manager_1 = require("./hook_manager");
|
|
9
|
+
const subagent_manager_1 = require("./subagent_manager");
|
|
10
|
+
const scroll_search_agent_1 = require("./scroll_search_agent");
|
|
11
|
+
const compressed_session_1 = require("../../memory/compressed_session");
|
|
12
|
+
const image_helper_1 = require("../../../common/image_helper");
|
|
13
|
+
const image_utils_1 = require("./image_utils");
|
|
14
|
+
const model_1 = require("../../../common/model");
|
|
15
|
+
const logger_1 = require("../../../common/logger");
|
|
16
|
+
const prompt_loader_1 = require("../../prompt/prompt_loader");
|
|
17
|
+
const skill_manager_1 = require("../../skill/skill_manager");
|
|
18
|
+
const cache_transport_1 = require("../../../common/llm_cache/cache_transport");
|
|
19
|
+
const MAX_HISTORY_IMAGES = 3;
|
|
20
|
+
const MAX_HISTORY_ACTIONS = 10;
|
|
21
|
+
const CLICK_LIKE_TOOLS = new Set(['click', 'double_click', 'long_press', 'long_click', 'tap', 'double_tap']);
|
|
22
|
+
const SWIPE_LIKE_TOOLS = new Set(['swipe', 'drag']);
|
|
23
|
+
const COMMON_ERRORS_PROMPT = `
|
|
24
|
+
常见错误提示:
|
|
25
|
+
- 坐标偏移:如果点击没反应,检查坐标是否准确,尝试微调
|
|
26
|
+
- 滑动无效:确保起点在可滑动区域内,滑动距离适中
|
|
27
|
+
- 页面未加载:操作后适当等待
|
|
28
|
+
- 重复操作:避免对同一位置重复点击超过3次`;
|
|
29
|
+
class SingleAgent {
|
|
30
|
+
adapter;
|
|
31
|
+
config;
|
|
32
|
+
hooks;
|
|
33
|
+
reportGenerator;
|
|
34
|
+
stepNumber = 0;
|
|
35
|
+
maxSteps;
|
|
36
|
+
maxResultRetries;
|
|
37
|
+
lastScreenshot = null;
|
|
38
|
+
previousScreenshotB64 = null;
|
|
39
|
+
lastActionInfo = null;
|
|
40
|
+
llmCaller;
|
|
41
|
+
task = '';
|
|
42
|
+
session = null;
|
|
43
|
+
historyActions = [];
|
|
44
|
+
toolCount = 0;
|
|
45
|
+
constructor(adapter, config, reportGenerator, hooks, llmCaller) {
|
|
46
|
+
this.adapter = adapter;
|
|
47
|
+
this.config = config;
|
|
48
|
+
this.reportGenerator = reportGenerator;
|
|
49
|
+
this.hooks = hooks;
|
|
50
|
+
this.maxSteps = config.agent.unified.maxSteps;
|
|
51
|
+
this.maxResultRetries = config.agent.unified.maxResultRetries;
|
|
52
|
+
this.llmCaller = llmCaller ?? new model_1.LLMCaller(new cache_transport_1.CacheTransport(config.agent.unified.enableCache));
|
|
53
|
+
}
|
|
54
|
+
async run(args) {
|
|
55
|
+
const task = args.task;
|
|
56
|
+
this.task = task;
|
|
57
|
+
const testCase = args.caseNum ?? args.taskName ?? task;
|
|
58
|
+
this.reportGenerator.setTask(task);
|
|
59
|
+
this.reportGenerator.setTestCase(testCase);
|
|
60
|
+
this.reportGenerator.startTask();
|
|
61
|
+
// Initialize compressed session (replaces raw conversationHistory + trimHistory).
|
|
62
|
+
// Aligned with python hybrid_agent Runner.run(session=CompressedSession).
|
|
63
|
+
this.session = new compressed_session_1.CompressedSession({
|
|
64
|
+
autoCompress: true,
|
|
65
|
+
modelConfig: this.config.model.unified,
|
|
66
|
+
reportGenerator: this.reportGenerator,
|
|
67
|
+
getCurrentStepNumber: () => this.stepNumber,
|
|
68
|
+
maxHistoryImage: this.config.agent.unified.maxHistoryImage,
|
|
69
|
+
compressionConfig: this.config.contextCompression ?? { enabled: true, maxTokens: 7000, maxRecentMessages: 6 },
|
|
70
|
+
reflectionConfig: this.config.reflection ?? { enabled: true, initialStep: 15, interval: 8, recentMessages: 10 },
|
|
71
|
+
});
|
|
72
|
+
if (this.hooks) {
|
|
73
|
+
await this.hooks.onAgentStart('single');
|
|
74
|
+
}
|
|
75
|
+
await hook_manager_1.hookManager.fireEvent('on_agent_start', { agentName: 'single' });
|
|
76
|
+
let finalOutput = '';
|
|
77
|
+
let finalStatus = 'UNKNOWN';
|
|
78
|
+
let stepsUsed = 0;
|
|
79
|
+
for (let attempt = 0; attempt <= this.maxResultRetries; attempt++) {
|
|
80
|
+
this.stepNumber = 0;
|
|
81
|
+
finalStatus = 'UNKNOWN';
|
|
82
|
+
// Aligned with python _run_with_retry: retries get a remaining-steps budget
|
|
83
|
+
// (max(3, original_max_steps - steps_used)) instead of the full maxSteps.
|
|
84
|
+
const attemptMaxSteps = attempt === 0 ? this.maxSteps : Math.max(3, this.maxSteps - stepsUsed);
|
|
85
|
+
finalOutput = '';
|
|
86
|
+
while (this.stepNumber < attemptMaxSteps) {
|
|
87
|
+
this.stepNumber++;
|
|
88
|
+
if (this.adapter.isAborted()) {
|
|
89
|
+
finalStatus = 'STOP_BY_USER';
|
|
90
|
+
finalOutput = 'Task stopped by user';
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
this.reportGenerator.addEvent({
|
|
94
|
+
eventType: types_1.EventType.STEP_START,
|
|
95
|
+
timestamp: new Date().toISOString(),
|
|
96
|
+
content: `Step ${this.stepNumber} started`,
|
|
97
|
+
data: {},
|
|
98
|
+
stepNumber: this.stepNumber,
|
|
99
|
+
});
|
|
100
|
+
// Register scroll_search subagent
|
|
101
|
+
const sm = (0, subagent_manager_1.getSubagentManager)();
|
|
102
|
+
sm.register('scroll_search', '滑动查找目标使其进入可见区域(列表/导航栏/时间选择器等)', async (task, opts) => {
|
|
103
|
+
const sub = new scroll_search_agent_1.ScrollSearchAgent(this.adapter, this.config.model.unified, undefined, this.reportGenerator);
|
|
104
|
+
const result = await sub.run(task, '');
|
|
105
|
+
return {
|
|
106
|
+
name: 'scroll_search',
|
|
107
|
+
success: result.success,
|
|
108
|
+
output: result.success ? `找到目标: ${result.message}` : `未找到: ${result.message}`,
|
|
109
|
+
stepsUsed: result.totalSteps,
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
if (this.hooks) {
|
|
113
|
+
await this.hooks.onLLMStart('single', this.stepNumber);
|
|
114
|
+
}
|
|
115
|
+
await hook_manager_1.hookManager.fireEvent('on_step_start', { agentName: 'single', step: this.stepNumber });
|
|
116
|
+
await this.injectScreenshot('observation');
|
|
117
|
+
const stepResult = await this.callLLMStep();
|
|
118
|
+
if (!stepResult.action) {
|
|
119
|
+
const extracted = this.extractResult(stepResult.thinking);
|
|
120
|
+
if (extracted.status === 'PASS' || extracted.status === 'FAIL') {
|
|
121
|
+
finalStatus = extracted.status;
|
|
122
|
+
finalOutput = extracted.tip;
|
|
123
|
+
logger_1.logger.info(`Step ${this.stepNumber} final result: ${finalStatus} - ${finalOutput.slice(0, 100)}`);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (stepResult.action) {
|
|
128
|
+
const actionResult = await this.executeAction(stepResult.action);
|
|
129
|
+
if (actionResult.finished) {
|
|
130
|
+
this.reportGenerator.addEvent({
|
|
131
|
+
eventType: types_1.EventType.STEP_END,
|
|
132
|
+
timestamp: new Date().toISOString(),
|
|
133
|
+
content: `Step ${this.stepNumber} finished: ${actionResult.message ?? ''}`,
|
|
134
|
+
data: { success: actionResult.success },
|
|
135
|
+
stepNumber: this.stepNumber,
|
|
136
|
+
});
|
|
137
|
+
const extracted = this.extractResult(actionResult.message ?? stepResult.thinking);
|
|
138
|
+
if (extracted.status === 'PASS' || extracted.status === 'FAIL') {
|
|
139
|
+
finalStatus = extracted.status;
|
|
140
|
+
finalOutput = extracted.tip;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (actionResult.aborted) {
|
|
145
|
+
finalStatus = 'FAIL';
|
|
146
|
+
finalOutput = actionResult.message ?? 'Task aborted';
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (this.config.agent.unified.stepEndWaitTime > 0) {
|
|
151
|
+
await new Promise((r) => setTimeout(r, this.config.agent.unified.stepEndWaitTime * 1000));
|
|
152
|
+
}
|
|
153
|
+
this.reportGenerator.addEvent({
|
|
154
|
+
eventType: types_1.EventType.STEP_END,
|
|
155
|
+
timestamp: new Date().toISOString(),
|
|
156
|
+
content: `Step ${this.stepNumber} completed`,
|
|
157
|
+
data: {},
|
|
158
|
+
stepNumber: this.stepNumber,
|
|
159
|
+
});
|
|
160
|
+
this.reportGenerator.saveJson();
|
|
161
|
+
if (this.hooks) {
|
|
162
|
+
await this.hooks.onLLMEnd('single', this.stepNumber, stepResult);
|
|
163
|
+
}
|
|
164
|
+
await hook_manager_1.hookManager.fireEvent('on_step_end', { agentName: 'single', step: this.stepNumber });
|
|
165
|
+
}
|
|
166
|
+
stepsUsed += this.stepNumber;
|
|
167
|
+
if (this.stepNumber >= attemptMaxSteps && finalStatus === 'UNKNOWN') {
|
|
168
|
+
finalStatus = 'FAIL';
|
|
169
|
+
finalOutput = `任务结果: 不通过 (超过最大步数 ${attemptMaxSteps})`;
|
|
170
|
+
}
|
|
171
|
+
const hasVerdict = (finalOutput.includes('任务结果') || finalOutput.includes('判定结果')) &&
|
|
172
|
+
(finalOutput.includes('通过') || finalOutput.includes('不通过'));
|
|
173
|
+
if (hasVerdict || finalStatus === 'PASS' || attempt >= this.maxResultRetries) {
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
logger_1.logger.warn(`No verdict in output, retrying (${attempt + 1}/${this.maxResultRetries})...`);
|
|
177
|
+
await this.session.addItems([{
|
|
178
|
+
role: 'user',
|
|
179
|
+
content: '请继续完成当前任务。如果所有步骤已执行完毕,请输出最终结果。',
|
|
180
|
+
}]);
|
|
181
|
+
}
|
|
182
|
+
this.reportGenerator.endTask(finalOutput, finalStatus);
|
|
183
|
+
if (this.hooks) {
|
|
184
|
+
await this.hooks.onAgentEnd('single', { finalOutput, status: finalStatus });
|
|
185
|
+
}
|
|
186
|
+
await hook_manager_1.hookManager.fireEvent('on_agent_end', { agentName: 'single', result: finalOutput });
|
|
187
|
+
const savedFiles = await this.reportGenerator.saveAll();
|
|
188
|
+
return {
|
|
189
|
+
finalOutput,
|
|
190
|
+
status: finalStatus,
|
|
191
|
+
savedFiles,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
async injectScreenshot(phase = 'observation') {
|
|
195
|
+
try {
|
|
196
|
+
const screenshot = await this.adapter.getScreenshot();
|
|
197
|
+
// Save current screenshot as previous for next step (aligned with python
|
|
198
|
+
// hooks/image_utils.py line 562: _previous_screenshot = screenshot.base64_data)
|
|
199
|
+
if (phase === 'observation' && this.lastScreenshot?.base64Data) {
|
|
200
|
+
this.previousScreenshotB64 = this.lastScreenshot.base64Data;
|
|
201
|
+
}
|
|
202
|
+
this.lastScreenshot = screenshot;
|
|
203
|
+
if (screenshot.base64Data) {
|
|
204
|
+
const screenshotPath = this.reportGenerator.saveScreenshot(screenshot.base64Data, screenshot.layoutData, `step_${this.stepNumber}_${phase}`);
|
|
205
|
+
this.reportGenerator.addEvent({
|
|
206
|
+
eventType: types_1.EventType.SCREENSHOT,
|
|
207
|
+
timestamp: new Date().toISOString(),
|
|
208
|
+
content: `Screenshot ${phase}: step ${this.stepNumber}`,
|
|
209
|
+
data: { phase, width: screenshot.width, height: screenshot.height, path: screenshotPath },
|
|
210
|
+
screenshotPath,
|
|
211
|
+
stepNumber: this.stepNumber,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
this.reportGenerator.addEvent({
|
|
217
|
+
eventType: types_1.EventType.SCREENSHOT,
|
|
218
|
+
timestamp: new Date().toISOString(),
|
|
219
|
+
content: `Screenshot capture failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
220
|
+
data: { error: true, phase },
|
|
221
|
+
stepNumber: this.stepNumber,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
extractResult(output) {
|
|
226
|
+
const verdictKeyword = output.includes('任务结果') ? '任务结果'
|
|
227
|
+
: output.includes('判定结果') ? '判定结果'
|
|
228
|
+
: output.match(/PASS/i) ? 'PASS'
|
|
229
|
+
: output.match(/FAIL/i) ? 'FAIL'
|
|
230
|
+
: null;
|
|
231
|
+
if (verdictKeyword) {
|
|
232
|
+
if (output.includes('不通过') || output.match(/FAIL/i)) {
|
|
233
|
+
const idx = output.indexOf(verdictKeyword);
|
|
234
|
+
return { status: 'FAIL', tip: idx >= 0 ? output.slice(idx).trim() : output };
|
|
235
|
+
}
|
|
236
|
+
if (output.includes('通过') || output.match(/PASS/i)) {
|
|
237
|
+
const idx = output.indexOf(verdictKeyword);
|
|
238
|
+
return { status: 'PASS', tip: idx >= 0 ? output.slice(idx).trim() : output };
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (output.includes('任务结果: 不通过') || output.includes('任务结果:不通过') ||
|
|
242
|
+
output.includes('判定结果: 不通过') || output.includes('判定结果:不通过')) {
|
|
243
|
+
return { status: 'FAIL', tip: output };
|
|
244
|
+
}
|
|
245
|
+
if (output.includes('任务结果: 通过') || output.includes('任务结果:通过') ||
|
|
246
|
+
output.includes('判定结果: 通过') || output.includes('判定结果:通过')) {
|
|
247
|
+
return { status: 'PASS', tip: output };
|
|
248
|
+
}
|
|
249
|
+
return { status: 'UNKNOWN', tip: output };
|
|
250
|
+
}
|
|
251
|
+
async executeAction(action) {
|
|
252
|
+
const toolName = (action.tool ?? action.name ?? action.action);
|
|
253
|
+
const toolArgs = (action.args ?? action.parameters ?? {});
|
|
254
|
+
if (!toolName) {
|
|
255
|
+
return {
|
|
256
|
+
success: false,
|
|
257
|
+
finished: false,
|
|
258
|
+
thinking: 'No action specified',
|
|
259
|
+
message: 'No action specified',
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
this.toolCount++;
|
|
263
|
+
const actionLog = this.formatActionLog(toolName, toolArgs);
|
|
264
|
+
this.historyActions.push(`${this.stepNumber}. ${actionLog}`);
|
|
265
|
+
if (this.historyActions.length > MAX_HISTORY_ACTIONS) {
|
|
266
|
+
this.historyActions = this.historyActions.slice(-MAX_HISTORY_ACTIONS);
|
|
267
|
+
}
|
|
268
|
+
this.reportGenerator.addEvent({
|
|
269
|
+
eventType: types_1.EventType.PLANNER_TOOL_CALL,
|
|
270
|
+
timestamp: new Date().toISOString(),
|
|
271
|
+
content: `Called: ${toolName}`,
|
|
272
|
+
data: { tool_name: toolName, arguments: toolArgs },
|
|
273
|
+
stepNumber: this.stepNumber,
|
|
274
|
+
});
|
|
275
|
+
let beforeScreenshotPath = null;
|
|
276
|
+
if (this.lastScreenshot?.base64Data) {
|
|
277
|
+
try {
|
|
278
|
+
beforeScreenshotPath = this.reportGenerator.saveScreenshot(this.lastScreenshot.base64Data, this.lastScreenshot.layoutData, `step_${this.stepNumber}_before`);
|
|
279
|
+
}
|
|
280
|
+
catch { /* non-blocking */ }
|
|
281
|
+
}
|
|
282
|
+
const toolStartData = { toolName, args: toolArgs };
|
|
283
|
+
if (['click', 'double_click', 'long_press', 'long_click'].includes(toolName)) {
|
|
284
|
+
toolStartData.action = toolName;
|
|
285
|
+
if (toolArgs && 'x' in toolArgs && 'y' in toolArgs) {
|
|
286
|
+
toolStartData.point = [Number(toolArgs.x), Number(toolArgs.y)];
|
|
287
|
+
}
|
|
288
|
+
else if (toolArgs && 'pos' in toolArgs && Array.isArray(toolArgs.pos) && toolArgs.pos.length === 2) {
|
|
289
|
+
toolStartData.point = [Number(toolArgs.pos[0]), Number(toolArgs.pos[1])];
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else if (toolName === 'swipe' && toolArgs) {
|
|
293
|
+
if ('start' in toolArgs && 'end' in toolArgs) {
|
|
294
|
+
const start = toolArgs.start;
|
|
295
|
+
const end = toolArgs.end;
|
|
296
|
+
if (Array.isArray(start) && start.length === 2 && Array.isArray(end) && end.length === 2) {
|
|
297
|
+
toolStartData.action = 'swipe';
|
|
298
|
+
toolStartData.start = [start[0], start[1]];
|
|
299
|
+
toolStartData.end = [end[0], end[1]];
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
else if ('start_x' in toolArgs && 'start_y' in toolArgs && 'end_x' in toolArgs && 'end_y' in toolArgs) {
|
|
303
|
+
toolStartData.action = 'swipe';
|
|
304
|
+
toolStartData.start = [Number(toolArgs.start_x), Number(toolArgs.start_y)];
|
|
305
|
+
toolStartData.end = [Number(toolArgs.end_x), Number(toolArgs.end_y)];
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
this.reportGenerator.addEvent({
|
|
309
|
+
eventType: types_1.EventType.MCP_TOOL_START,
|
|
310
|
+
timestamp: new Date().toISOString(),
|
|
311
|
+
content: `Tool call: ${toolName}`,
|
|
312
|
+
data: toolStartData,
|
|
313
|
+
screenshotPath: beforeScreenshotPath,
|
|
314
|
+
stepNumber: this.stepNumber,
|
|
315
|
+
});
|
|
316
|
+
if (this.hooks) {
|
|
317
|
+
await this.hooks.onToolStart('single', toolName, toolArgs);
|
|
318
|
+
}
|
|
319
|
+
await hook_manager_1.hookManager.fireEvent('on_tool_start', { agentName: 'single', toolName, toolArgs, step: this.stepNumber });
|
|
320
|
+
// 坐标防御层:模型可能输出 0-1000 千分制坐标,执行前归一化到 0-1
|
|
321
|
+
(0, utils_1.normalizeToolCoordinates)(toolName, toolArgs);
|
|
322
|
+
// Save action info for drawing markers on next step's screenshots.
|
|
323
|
+
// Aligned with python hybrid_hooks.py line 500: _last_action_info = {...}
|
|
324
|
+
const lowerName = toolName.toLowerCase();
|
|
325
|
+
if (CLICK_LIKE_TOOLS.has(lowerName)) {
|
|
326
|
+
const pos = toolArgs['pos'] ?? toolArgs['point'];
|
|
327
|
+
if (Array.isArray(pos) && pos.length === 2) {
|
|
328
|
+
this.lastActionInfo = { action: lowerName, point: [pos[0], pos[1]] };
|
|
329
|
+
}
|
|
330
|
+
else if (typeof toolArgs['x'] === 'number' && typeof toolArgs['y'] === 'number') {
|
|
331
|
+
this.lastActionInfo = { action: lowerName, point: [toolArgs['x'], toolArgs['y']] };
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
else if (SWIPE_LIKE_TOOLS.has(lowerName)) {
|
|
335
|
+
const startVal = toolArgs['start'];
|
|
336
|
+
const endVal = toolArgs['end'];
|
|
337
|
+
if (Array.isArray(startVal) && startVal.length === 2 && Array.isArray(endVal) && endVal.length === 2) {
|
|
338
|
+
this.lastActionInfo = {
|
|
339
|
+
action: lowerName,
|
|
340
|
+
start: [startVal[0], startVal[1]],
|
|
341
|
+
end: [endVal[0], endVal[1]],
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
try {
|
|
346
|
+
// Subagent delegation: run_subagent 不走 adapter.callTool,委托 SubagentManager
|
|
347
|
+
let result;
|
|
348
|
+
if (toolName === 'run_subagent') {
|
|
349
|
+
const sm = (0, subagent_manager_1.getSubagentManager)();
|
|
350
|
+
sm.setParentStep(this.stepNumber);
|
|
351
|
+
const subName = toolArgs['name'] ?? '';
|
|
352
|
+
const subTask = toolArgs['task_description'] ?? '';
|
|
353
|
+
const subResult = await sm.runSubagent(subName, subTask, this.reportGenerator);
|
|
354
|
+
result = subResult.success ? subResult.output : `Sub-agent '${subName}' failed: ${subResult.output}`;
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
result = await this.adapter.callTool(toolName, toolArgs);
|
|
358
|
+
}
|
|
359
|
+
const resultStr = typeof result === 'string' ? result : JSON.stringify(result);
|
|
360
|
+
let afterScreenshotPath = null;
|
|
361
|
+
// Aligned with python hybrid_hooks.on_tool_end: only capture the post-action
|
|
362
|
+
// screenshot when screenshotOnToolEnd is enabled (skip for fast/minimal modes).
|
|
363
|
+
if (this.config.agent.unified.screenshotOnToolEnd) {
|
|
364
|
+
try {
|
|
365
|
+
const afterScreenshot = await this.adapter.getScreenshot();
|
|
366
|
+
if (afterScreenshot.base64Data) {
|
|
367
|
+
afterScreenshotPath = this.reportGenerator.saveScreenshot(afterScreenshot.base64Data, afterScreenshot.layoutData, `step_${this.stepNumber}_after`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
catch { /* non-blocking */ }
|
|
371
|
+
}
|
|
372
|
+
if (this.config.agent.unified.actionInterval > 0) {
|
|
373
|
+
await new Promise((r) => setTimeout(r, this.config.agent.unified.actionInterval * 1000));
|
|
374
|
+
}
|
|
375
|
+
this.reportGenerator.addEvent({
|
|
376
|
+
eventType: types_1.EventType.MCP_TOOL_END,
|
|
377
|
+
timestamp: new Date().toISOString(),
|
|
378
|
+
content: `${toolName} -> ${resultStr.slice(0, 200)}`,
|
|
379
|
+
data: { toolName, result: resultStr },
|
|
380
|
+
screenshotPath: afterScreenshotPath,
|
|
381
|
+
stepNumber: this.stepNumber,
|
|
382
|
+
});
|
|
383
|
+
if (this.hooks) {
|
|
384
|
+
await this.hooks.onToolEnd('single', toolName, resultStr, this.stepNumber);
|
|
385
|
+
}
|
|
386
|
+
await hook_manager_1.hookManager.fireEvent('on_tool_end', { agentName: 'single', toolName, toolArgs, result: resultStr, step: this.stepNumber });
|
|
387
|
+
const toolCallId = action.toolCallId;
|
|
388
|
+
if (toolCallId) {
|
|
389
|
+
await this.session.addItems([{
|
|
390
|
+
role: 'tool',
|
|
391
|
+
content: [
|
|
392
|
+
{ type: 'tool-result', toolCallId, toolName, output: { type: 'text', value: resultStr } },
|
|
393
|
+
],
|
|
394
|
+
}]);
|
|
395
|
+
}
|
|
396
|
+
const extracted = this.extractResult(resultStr);
|
|
397
|
+
const aborted = this.shouldAbort(toolName, resultStr);
|
|
398
|
+
return {
|
|
399
|
+
success: !aborted,
|
|
400
|
+
finished: extracted.status !== 'UNKNOWN' || aborted,
|
|
401
|
+
thinking: resultStr,
|
|
402
|
+
message: resultStr,
|
|
403
|
+
action,
|
|
404
|
+
aborted,
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
catch (err) {
|
|
408
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
409
|
+
this.reportGenerator.addEvent({
|
|
410
|
+
eventType: types_1.EventType.MCP_TOOL_END,
|
|
411
|
+
timestamp: new Date().toISOString(),
|
|
412
|
+
content: `Tool error: ${errMsg}`,
|
|
413
|
+
data: { toolName, error: errMsg },
|
|
414
|
+
stepNumber: this.stepNumber,
|
|
415
|
+
});
|
|
416
|
+
const toolCallId = action.toolCallId;
|
|
417
|
+
if (toolCallId) {
|
|
418
|
+
await this.session.addItems([{
|
|
419
|
+
role: 'tool',
|
|
420
|
+
content: [
|
|
421
|
+
{ type: 'tool-result', toolCallId, toolName, output: { type: 'text', value: errMsg }, isError: true },
|
|
422
|
+
],
|
|
423
|
+
}]);
|
|
424
|
+
}
|
|
425
|
+
const aborted = this.shouldAbort(toolName, errMsg);
|
|
426
|
+
return {
|
|
427
|
+
success: false,
|
|
428
|
+
finished: aborted,
|
|
429
|
+
thinking: errMsg,
|
|
430
|
+
message: errMsg,
|
|
431
|
+
aborted,
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
shouldAbort(toolName, resultStr) {
|
|
436
|
+
const lower = resultStr.toLowerCase();
|
|
437
|
+
if (toolName === 'start_app' && (lower.includes('failed') || lower.includes('"iserror":true'))) {
|
|
438
|
+
logger_1.logger.warn(`start_app failed, aborting task: ${resultStr.slice(0, 200)}`);
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
formatActionLog(toolName, args) {
|
|
444
|
+
if (args.log && typeof args.log === 'string') {
|
|
445
|
+
return args.log;
|
|
446
|
+
}
|
|
447
|
+
const argStr = Object.entries(args)
|
|
448
|
+
.filter(([k]) => k !== 'log')
|
|
449
|
+
.map(([k, v]) => {
|
|
450
|
+
if (Array.isArray(v) && v.length === 2 && typeof v[0] === 'number') {
|
|
451
|
+
return `${k}=(${v[0]},${v[1]})`;
|
|
452
|
+
}
|
|
453
|
+
return `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`;
|
|
454
|
+
})
|
|
455
|
+
.join(' ');
|
|
456
|
+
return `${toolName}(${argStr})`;
|
|
457
|
+
}
|
|
458
|
+
async callLLMStep() {
|
|
459
|
+
this.reportGenerator.addEvent({
|
|
460
|
+
eventType: types_1.EventType.LLM_CALL,
|
|
461
|
+
timestamp: new Date().toISOString(),
|
|
462
|
+
content: `LLM call for step ${this.stepNumber}`,
|
|
463
|
+
data: {},
|
|
464
|
+
stepNumber: this.stepNumber,
|
|
465
|
+
});
|
|
466
|
+
// Prompt priority (aligned with python HybridAgent._load_default_prompt):
|
|
467
|
+
// 1. explicit systemPrompt override
|
|
468
|
+
// 2. promptName (loadByName) — e.g. --prompt-name single_v2.0
|
|
469
|
+
// 3. SINGLE category with promptType
|
|
470
|
+
let systemPrompt = this.config.agent.unified.systemPrompt;
|
|
471
|
+
if (!systemPrompt) {
|
|
472
|
+
const promptName = this.config.agent.unified.promptName;
|
|
473
|
+
if (promptName) {
|
|
474
|
+
systemPrompt = (0, prompt_loader_1.loadByName)(promptName) ?? undefined;
|
|
475
|
+
}
|
|
476
|
+
if (!systemPrompt) {
|
|
477
|
+
systemPrompt = (0, prompt_loader_1.load)(prompt_loader_1.PromptCategory.SINGLE, this.config.model.unified.promptType);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
// Fill {skills_metadata} placeholder with available skills (aligned with python)
|
|
481
|
+
if (systemPrompt && systemPrompt.includes('{skills_metadata}')) {
|
|
482
|
+
try {
|
|
483
|
+
const sm = new skill_manager_1.SkillManager();
|
|
484
|
+
systemPrompt = systemPrompt.replace('{skills_metadata}', sm.getSkillsMetadata());
|
|
485
|
+
}
|
|
486
|
+
catch {
|
|
487
|
+
systemPrompt = systemPrompt.replace('{skills_metadata}', 'No skills available.');
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
let promptText;
|
|
491
|
+
if (this.stepNumber === 1) {
|
|
492
|
+
promptText = `Task: ${this.task}\n\nStep ${this.stepNumber}: Execute the next action based on current screenshot and task context.`;
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
promptText = `Step ${this.stepNumber}: Observe the new screenshot and continue executing the task.`;
|
|
496
|
+
if (this.historyActions.length > 0) {
|
|
497
|
+
promptText += `\n\n## 历史操作\n${this.historyActions.join('\n')}`;
|
|
498
|
+
}
|
|
499
|
+
promptText += `\n${COMMON_ERRORS_PROMPT}`;
|
|
500
|
+
}
|
|
501
|
+
const userContent = [
|
|
502
|
+
{ type: 'text', text: promptText },
|
|
503
|
+
];
|
|
504
|
+
// Aligned with python inject_screenshots_and_history (image_utils.py:442-562):
|
|
505
|
+
// 1. Inject previous screenshot with action marker (red dot + crosshair)
|
|
506
|
+
// 2. Inject current screenshot with action marker if last action was click
|
|
507
|
+
const maxPixels = this.config.agent.unified.screenshotMaxPixels || 1500;
|
|
508
|
+
const prevCompressRatio = this.config.agent.unified.previousScreenshotCompressRatio ?? 0.7;
|
|
509
|
+
const includePrev = this.config.agent.unified.includePreviousScreenshot;
|
|
510
|
+
if (includePrev && this.previousScreenshotB64 && this.stepNumber > 1) {
|
|
511
|
+
const prevPixels = Math.round(maxPixels * prevCompressRatio);
|
|
512
|
+
let prevB64 = await (0, image_helper_1.compressBase64Image)(this.previousScreenshotB64, prevPixels, 70);
|
|
513
|
+
let prevText = '** 上一步页面截图 **';
|
|
514
|
+
if (this.lastActionInfo) {
|
|
515
|
+
const actionType = CLICK_LIKE_TOOLS.has(this.lastActionInfo.action) ? 'click' : 'swipe';
|
|
516
|
+
const markerInfo = actionType === 'click' && this.lastActionInfo.point
|
|
517
|
+
? { type: 'click', point: this.lastActionInfo.point }
|
|
518
|
+
: actionType === 'swipe' && this.lastActionInfo.start && this.lastActionInfo.end
|
|
519
|
+
? { type: 'swipe', start: this.lastActionInfo.start, end: this.lastActionInfo.end }
|
|
520
|
+
: null;
|
|
521
|
+
if (markerInfo) {
|
|
522
|
+
prevB64 = await (0, image_utils_1.drawActionMarker)(prevB64, markerInfo);
|
|
523
|
+
if (actionType === 'click') {
|
|
524
|
+
prevText = '** 上一步页面截图 **\n图中标记说明:红色圆点+十字线 = 上一步的点击位置';
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
prevText = '** 上一步页面截图 **\n图中标记说明:红色箭头 = 上一步的滑动方向和距离(起点圆点 → 箭头终点)';
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
userContent.push({ type: 'text', text: prevText });
|
|
532
|
+
userContent.push({
|
|
533
|
+
type: 'file',
|
|
534
|
+
data: `data:image/jpeg;base64,${prevB64}`,
|
|
535
|
+
mediaType: 'image/jpeg',
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
if (this.lastScreenshot?.base64Data) {
|
|
539
|
+
let curB64 = this.lastScreenshot.base64Data;
|
|
540
|
+
let curText = '** 当前页面截图 **';
|
|
541
|
+
// Draw action marker on current screenshot if last action was click
|
|
542
|
+
// (aligned with python image_utils.py:530-537)
|
|
543
|
+
const hasMarker = this.lastActionInfo && CLICK_LIKE_TOOLS.has(this.lastActionInfo.action) && this.lastActionInfo.point;
|
|
544
|
+
if (hasMarker) {
|
|
545
|
+
curB64 = await (0, image_utils_1.drawActionMarker)(curB64, { type: 'click', point: this.lastActionInfo.point });
|
|
546
|
+
curText = '** 当前页面截图 **\n'
|
|
547
|
+
+ '图中标记说明:红色圆点 + 十字线 = 上一步的点击位置\n'
|
|
548
|
+
+ '如果页面与上一步相比未变化(点击没点动),检查点击是否落在目标元素上,'
|
|
549
|
+
+ '并据此调整本次坐标;如果页面已变化,忽略此标记';
|
|
550
|
+
}
|
|
551
|
+
// Compress screenshot before sending to LLM (reduces tokens → faster response).
|
|
552
|
+
const finalB64 = await (0, image_helper_1.compressBase64Image)(curB64, maxPixels, 70);
|
|
553
|
+
userContent.push({ type: 'text', text: curText });
|
|
554
|
+
userContent.push({
|
|
555
|
+
type: 'file',
|
|
556
|
+
data: `data:image/jpeg;base64,${finalB64}`,
|
|
557
|
+
mediaType: 'image/jpeg',
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
await this.session.addItems([{ role: 'user', content: userContent }]);
|
|
561
|
+
const llmResult = await this.llmCaller.callWithMessages({
|
|
562
|
+
messages: await this.session.getItems(),
|
|
563
|
+
systemPrompt,
|
|
564
|
+
tools: this.getDeviceTools(),
|
|
565
|
+
modelConfig: this.config.model.unified,
|
|
566
|
+
});
|
|
567
|
+
if (llmResult.responseMessages && llmResult.responseMessages.length > 0) {
|
|
568
|
+
await this.session.addItems(llmResult.responseMessages);
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
571
|
+
await this.session.addItems([{
|
|
572
|
+
role: 'assistant',
|
|
573
|
+
content: llmResult.text || '(no response)',
|
|
574
|
+
}]);
|
|
575
|
+
}
|
|
576
|
+
if (llmResult.tokenUsage) {
|
|
577
|
+
this.reportGenerator.addTokenUsage(llmResult.tokenUsage, 'single_agent', this.stepNumber);
|
|
578
|
+
}
|
|
579
|
+
const thinkingContent = this.parseThinkingTags(llmResult.text);
|
|
580
|
+
const judgmentContent = this.parseJudgmentTags(llmResult.text);
|
|
581
|
+
this.reportGenerator.addEvent({
|
|
582
|
+
eventType: types_1.EventType.LLM_RESPONSE,
|
|
583
|
+
timestamp: new Date().toISOString(),
|
|
584
|
+
content: llmResult.text,
|
|
585
|
+
data: {
|
|
586
|
+
text: llmResult.text,
|
|
587
|
+
reasoning: llmResult.reasoning,
|
|
588
|
+
thinking: thinkingContent,
|
|
589
|
+
judgment: judgmentContent,
|
|
590
|
+
finishReason: llmResult.finishReason,
|
|
591
|
+
},
|
|
592
|
+
stepNumber: this.stepNumber,
|
|
593
|
+
});
|
|
594
|
+
let action;
|
|
595
|
+
if (llmResult.toolCalls && llmResult.toolCalls.length > 0) {
|
|
596
|
+
const tc = llmResult.toolCalls[0];
|
|
597
|
+
action = { tool: tc.toolName, args: tc.args, toolCallId: tc.toolCallId };
|
|
598
|
+
logger_1.logger.info(`Step ${this.stepNumber} tool call: ${tc.toolName} ${JSON.stringify(tc.args)}`);
|
|
599
|
+
for (let i = 1; i < llmResult.toolCalls.length; i++) {
|
|
600
|
+
const extra = llmResult.toolCalls[i];
|
|
601
|
+
logger_1.logger.info(`Step ${this.stepNumber} additional tool call ${i + 1}: ${extra.toolName} ${JSON.stringify(extra.args)}`);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
else {
|
|
605
|
+
const textAction = this.parseTextAction(llmResult.text);
|
|
606
|
+
if (textAction)
|
|
607
|
+
action = textAction;
|
|
608
|
+
}
|
|
609
|
+
if (llmResult.reasoning) {
|
|
610
|
+
logger_1.logger.info(`Step ${this.stepNumber} reasoning:\n${llmResult.reasoning}`);
|
|
611
|
+
}
|
|
612
|
+
logger_1.logger.info(`Step ${this.stepNumber} response:\n${llmResult.text}`);
|
|
613
|
+
return {
|
|
614
|
+
success: true,
|
|
615
|
+
finished: false,
|
|
616
|
+
thinking: llmResult.reasoning
|
|
617
|
+
? `${llmResult.reasoning}\n\n${llmResult.text}`
|
|
618
|
+
: llmResult.text,
|
|
619
|
+
action,
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
// trimHistory removed: CompressedSession auto-compresses + filters images.
|
|
623
|
+
parseThinkingTags(text) {
|
|
624
|
+
const match = text.match(/<thinking>([\s\S]*?)<\/thinking>/i);
|
|
625
|
+
return match ? match[1].trim() : null;
|
|
626
|
+
}
|
|
627
|
+
parseJudgmentTags(text) {
|
|
628
|
+
const match = text.match(/<judgment>([\s\S]*?)<\/judgment>/i)
|
|
629
|
+
?? text.match(/##\s*判定过程\s*([\s\S]*?)(?:\n##|\n---|\n$|$)/i);
|
|
630
|
+
return match ? match[1].trim() : null;
|
|
631
|
+
}
|
|
632
|
+
getDeviceTools() {
|
|
633
|
+
// 放开坐标 schema:允许模型输出 0-1 浮点或 0-1000 千分制整数,
|
|
634
|
+
// 由 normalizeToolCoordinates 在执行前归一化(防御部分模型遵守 integer schema)。
|
|
635
|
+
const coord = zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()]);
|
|
636
|
+
const logParam = zod_1.z.string().optional().describe('一句话简要描述操作意图');
|
|
637
|
+
return {
|
|
638
|
+
click: (0, ai_1.tool)({
|
|
639
|
+
description: '在指定坐标执行点击操作。坐标为相对坐标,(0.0,0.0)为屏幕左上角,(1.0,1.0)为右下角。',
|
|
640
|
+
inputSchema: zod_1.z.object({
|
|
641
|
+
pos: coord.describe('点击坐标 (x, y),相对坐标,取值范围 0.0~1.0'),
|
|
642
|
+
log: logParam,
|
|
643
|
+
}),
|
|
644
|
+
}),
|
|
645
|
+
long_click: (0, ai_1.tool)({
|
|
646
|
+
description: '在指定坐标执行长按操作',
|
|
647
|
+
inputSchema: zod_1.z.object({
|
|
648
|
+
pos: coord.describe('坐标 (x, y),0.0~1.0'),
|
|
649
|
+
duration: zod_1.z.number().optional().describe('长按持续时间(秒),默认2'),
|
|
650
|
+
log: logParam,
|
|
651
|
+
}),
|
|
652
|
+
}),
|
|
653
|
+
double_click: (0, ai_1.tool)({
|
|
654
|
+
description: '在指定坐标执行双击操作',
|
|
655
|
+
inputSchema: zod_1.z.object({
|
|
656
|
+
pos: coord.describe('坐标 (x, y),0.0~1.0'),
|
|
657
|
+
log: logParam,
|
|
658
|
+
}),
|
|
659
|
+
}),
|
|
660
|
+
swipe: (0, ai_1.tool)({
|
|
661
|
+
description: '从起点滑动到终点。起点必须在可滑动区域内,滑动距离建议小于0.2。',
|
|
662
|
+
inputSchema: zod_1.z.object({
|
|
663
|
+
start: coord.describe('起点坐标 (x, y),0.0~1.0,必须在可滑动区域内'),
|
|
664
|
+
end: coord.describe('终点坐标 (x, y),0.0~1.0'),
|
|
665
|
+
direction: zod_1.z.enum(['left', 'right', 'up', 'down']).optional().describe('滑动方向'),
|
|
666
|
+
log: logParam,
|
|
667
|
+
}),
|
|
668
|
+
}),
|
|
669
|
+
drag: (0, ai_1.tool)({
|
|
670
|
+
description: '从起点拖拽到终点',
|
|
671
|
+
inputSchema: zod_1.z.object({
|
|
672
|
+
start: coord.describe('起点坐标 (x, y),0.0~1.0'),
|
|
673
|
+
end: coord.describe('终点坐标 (x, y),0.0~1.0'),
|
|
674
|
+
log: logParam,
|
|
675
|
+
}),
|
|
676
|
+
}),
|
|
677
|
+
input_text: (0, ai_1.tool)({
|
|
678
|
+
description: '在当前光标位置输入文本',
|
|
679
|
+
inputSchema: zod_1.z.object({
|
|
680
|
+
text: zod_1.z.string().describe('要输入的文本'),
|
|
681
|
+
log: logParam,
|
|
682
|
+
}),
|
|
683
|
+
}),
|
|
684
|
+
go_back: (0, ai_1.tool)({
|
|
685
|
+
description: '返回上一级',
|
|
686
|
+
inputSchema: zod_1.z.object({
|
|
687
|
+
times: zod_1.z.number().int().optional().describe('返回次数,默认1'),
|
|
688
|
+
log: logParam,
|
|
689
|
+
}),
|
|
690
|
+
}),
|
|
691
|
+
go_home: (0, ai_1.tool)({
|
|
692
|
+
description: '返回桌面',
|
|
693
|
+
inputSchema: zod_1.z.object({
|
|
694
|
+
times: zod_1.z.number().int().optional().describe('返回次数,默认1'),
|
|
695
|
+
log: logParam,
|
|
696
|
+
}),
|
|
697
|
+
}),
|
|
698
|
+
start_app: (0, ai_1.tool)({
|
|
699
|
+
description: '在设备上启动应用程序',
|
|
700
|
+
inputSchema: zod_1.z.object({
|
|
701
|
+
app_name: zod_1.z.string().describe('应用包名或显示名称,如"华为商城"或"com.huawei.hmos.vmall"'),
|
|
702
|
+
cold_start: zod_1.z.boolean().optional().describe('是否冷启动(先停止再启动)'),
|
|
703
|
+
log: logParam,
|
|
704
|
+
}),
|
|
705
|
+
}),
|
|
706
|
+
stop_app: (0, ai_1.tool)({
|
|
707
|
+
description: '在设备上停止应用程序',
|
|
708
|
+
inputSchema: zod_1.z.object({
|
|
709
|
+
app_name: zod_1.z.string().describe('应用包名或显示名称'),
|
|
710
|
+
log: logParam,
|
|
711
|
+
}),
|
|
712
|
+
}),
|
|
713
|
+
wait: (0, ai_1.tool)({
|
|
714
|
+
description: '等待指定时间',
|
|
715
|
+
inputSchema: zod_1.z.object({
|
|
716
|
+
duration: zod_1.z.number().describe('等待时间(秒)'),
|
|
717
|
+
log: logParam,
|
|
718
|
+
}),
|
|
719
|
+
}),
|
|
720
|
+
press_key: (0, ai_1.tool)({
|
|
721
|
+
description: '按下物理按键',
|
|
722
|
+
inputSchema: zod_1.z.object({
|
|
723
|
+
key_name: zod_1.z.enum(['home', 'power', 'volume_up', 'volume_down']).describe('按键名称'),
|
|
724
|
+
log: logParam,
|
|
725
|
+
}),
|
|
726
|
+
}),
|
|
727
|
+
screen_on: (0, ai_1.tool)({
|
|
728
|
+
description: '打开设备屏幕(点亮屏幕)',
|
|
729
|
+
inputSchema: zod_1.z.object({
|
|
730
|
+
log: logParam,
|
|
731
|
+
}),
|
|
732
|
+
}),
|
|
733
|
+
unlock_screen: (0, ai_1.tool)({
|
|
734
|
+
description: '解锁设备屏幕(解除锁屏状态)',
|
|
735
|
+
inputSchema: zod_1.z.object({
|
|
736
|
+
log: logParam,
|
|
737
|
+
}),
|
|
738
|
+
}),
|
|
739
|
+
clear_recent_task: (0, ai_1.tool)({
|
|
740
|
+
description: '清空最近任务(清后台)',
|
|
741
|
+
inputSchema: zod_1.z.object({
|
|
742
|
+
log: logParam,
|
|
743
|
+
}),
|
|
744
|
+
}),
|
|
745
|
+
run_subagent: (0, ai_1.tool)({
|
|
746
|
+
description: '委托子代理执行特定任务(如滚动搜索、时间选择器等)。子代理在独立的步骤范围内运行,完成后返回结果。',
|
|
747
|
+
inputSchema: zod_1.z.object({
|
|
748
|
+
name: zod_1.z.string().describe('子代理名称(如 scroll_search, time_picker)'),
|
|
749
|
+
task_description: zod_1.z.string().describe('子代理的任务描述'),
|
|
750
|
+
}),
|
|
751
|
+
}),
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
parseTextAction(text) {
|
|
755
|
+
const actionMatch = text.match(/action\s*:\s*(\w+)/i);
|
|
756
|
+
if (!actionMatch)
|
|
757
|
+
return null;
|
|
758
|
+
const toolName = actionMatch[1];
|
|
759
|
+
const argsMatch = text.match(/args\s*:\s*(\{[^}]*\})/i);
|
|
760
|
+
let args = {};
|
|
761
|
+
if (argsMatch) {
|
|
762
|
+
try {
|
|
763
|
+
args = JSON.parse(argsMatch[1]);
|
|
764
|
+
}
|
|
765
|
+
catch {
|
|
766
|
+
args = {};
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
return { tool: toolName, args };
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
exports.SingleAgent = SingleAgent;
|
|
773
|
+
/**
|
|
774
|
+
* FastActionAgent — ≤5-step quick-execute mode (aligned with python
|
|
775
|
+
* hybrid_agent/agent/fast_action.py). Applies fast defaults: maxSteps=5,
|
|
776
|
+
* no retries, no post-tool screenshots, minimal inject, FAST_ACTION prompt.
|
|
777
|
+
*/
|
|
778
|
+
class FastActionAgent extends SingleAgent {
|
|
779
|
+
constructor(adapter, config, reportGenerator, hooks, llmCaller) {
|
|
780
|
+
const fastConfig = {
|
|
781
|
+
...config,
|
|
782
|
+
agent: {
|
|
783
|
+
...config.agent,
|
|
784
|
+
unified: {
|
|
785
|
+
...config.agent.unified,
|
|
786
|
+
maxSteps: 5,
|
|
787
|
+
maxResultRetries: 0,
|
|
788
|
+
screenshotOnToolEnd: false,
|
|
789
|
+
minimalInject: true,
|
|
790
|
+
parseMode: 'custom',
|
|
791
|
+
promptName: 'fast_action_v1.0',
|
|
792
|
+
},
|
|
793
|
+
},
|
|
794
|
+
};
|
|
795
|
+
super(adapter, fastConfig, reportGenerator, hooks, llmCaller);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
exports.FastActionAgent = FastActionAgent;
|
|
799
|
+
//# sourceMappingURL=agent.js.map
|