@autotest/agent 0.0.11 → 0.0.13
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/README.md +64 -0
- package/dist/api/autotest_agent.d.ts +0 -1
- package/dist/autotest-cli.js +1 -1
- package/dist/common/image_similarity.d.ts +14 -0
- package/dist/common/logger.d.ts +3 -0
- package/dist/core/agent/single_agent/agent.d.ts +14 -52
- package/dist/core/device/hdc/index.d.ts +1 -1
- package/dist/core/device/hdc/screen_recorder.d.ts +58 -0
- package/dist/core/device/hdc/screenshot.d.ts +0 -42
- package/dist/core/mcp/harmony_hdc_adapter.d.ts +0 -29
- package/dist/core/mcp/mcp_tools.d.ts +4 -4
- package/dist/core/mcp/types.d.ts +0 -32
- package/dist/core/mcp/verify_tool.d.ts +2 -2
- package/dist/core/prompt/templates/debug/planner/planner_v3.0.md +20 -20
- package/dist/core/prompt/templates/single/single_v2.0.md +35 -58
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/reporter/html_template/index.d.ts +4 -0
- package/dist/tools/batch_runner.js +1 -1
- package/dist/tools/case_runner/runner.js +1 -1
- package/dist/tools/config/config_tool.js +1 -1
- package/dist/tools/prompt_compare/compare_runner.js +1 -1
- package/package.json +11 -2
- package/dist/.buildstamp +0 -1
- package/dist/core/mcp/detect_tool.d.ts +0 -12
- package/dist/tools/cache/clear_cache.d.ts +0 -18
- package/dist/tools/cache/clear_cache.js +0 -1
package/README.md
CHANGED
|
@@ -679,6 +679,70 @@ const agent = new AutoTestAgent({
|
|
|
679
679
|
});
|
|
680
680
|
```
|
|
681
681
|
|
|
682
|
+
## 日志显示
|
|
683
|
+
|
|
684
|
+
日志格式:`<时间> - AutoTest - <级别> - <消息>`。控制台默认输出 INFO+(INFO→stdout,WARNING/ERROR→stderr),`runTask` 时另落盘全量(DEBUG+)到报告目录 `log/agent_<taskId>.log`。各场景默认即可见 INFO+:
|
|
685
|
+
|
|
686
|
+
| 场景 | 日志去向 |
|
|
687
|
+
|------|----------|
|
|
688
|
+
| cmd / opencode 跑 `node ...` | stdout/stderr → 终端或被父进程捕获 |
|
|
689
|
+
| 脚本 spawn `node` | 管道,需同时读 child 的 stdout+stderr |
|
|
690
|
+
| 脚本内 `new AutoTestAgent(...)` | 当前进程 stdout;可用 `addLogSink` 接入自定义流 |
|
|
691
|
+
|
|
692
|
+
### 场景一:cmd / opencode 直接跑 CLI
|
|
693
|
+
|
|
694
|
+
无需额外配置,INFO+ 默认打印到控制台:
|
|
695
|
+
|
|
696
|
+
```bash
|
|
697
|
+
node dist/autotest-cli.js run --task "打开设置应用"
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
### 场景二:脚本内 spawn 子进程
|
|
701
|
+
|
|
702
|
+
INFO 走 stdout、WARN/ERROR 走 stderr,需同时捕获两路才能拿到完整 INFO+:
|
|
703
|
+
|
|
704
|
+
```ts
|
|
705
|
+
import { spawn } from 'child_process';
|
|
706
|
+
|
|
707
|
+
const child = spawn('node', ['dist/autotest-cli.js', 'run', '--task', '打开设置'], {
|
|
708
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
709
|
+
});
|
|
710
|
+
|
|
711
|
+
child.stdout.on('data', (d) => process.stdout.write(`[out] ${d}`));
|
|
712
|
+
child.stderr.on('data', (d) => process.stderr.write(`[err] ${d}`));
|
|
713
|
+
child.on('exit', (code) => console.log('exit', code));
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
### 场景三:进程内 `new AutoTestAgent` 接入自定义日志流
|
|
717
|
+
|
|
718
|
+
默认日志会进当前进程的 stdout。若要接入自己的日志系统(winston / pino / 远程上报等),用 `addLogSink` 订阅——回调按 INFO+ 阈值投递,返回取消订阅函数:
|
|
719
|
+
|
|
720
|
+
```ts
|
|
721
|
+
import { AutoTestAgent, addLogSink } from '@autotest/agent';
|
|
722
|
+
|
|
723
|
+
// 接入自定义日志流
|
|
724
|
+
const unsubscribe = addLogSink((level, message, formatted) => {
|
|
725
|
+
// level: 'INFO' | 'WARNING' | 'ERROR'(DEBUG 已被默认 INFO 阈值过滤)
|
|
726
|
+
myLogger.log({ level, message });
|
|
727
|
+
// 或转发完整带时间戳行:formatted
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
const agent = new AutoTestAgent({ apiKey, modelName, baseUrl });
|
|
731
|
+
await agent.runTask('打开设置应用,查看 WiFi 列表');
|
|
732
|
+
|
|
733
|
+
unsubscribe(); // 可选:停止订阅
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
### 调整详细度
|
|
737
|
+
|
|
738
|
+
```ts
|
|
739
|
+
import { configureLogger } from '@autotest/agent';
|
|
740
|
+
|
|
741
|
+
configureLogger({ consoleLevel: 'DEBUG' }); // 控制台 + sink 同时放行 DEBUG
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
> `consoleLevel` 是控制台与 sink 的共同「详细度」旋钮;文件日志始终为 `DEBUG`(落盘全量)。控制台写入已做 EPIPE 保护,消费方管道意外关闭不会导致 agent 崩溃。
|
|
745
|
+
|
|
682
746
|
## 脚本
|
|
683
747
|
|
|
684
748
|
在 `AutoTest-nodejs/` 目录下:
|