工具能力 Tool capabilities
默认 37 个工具,开启设备与构建工具后 55 个。DitingAgent 向宿主提供这些工具。前半部分是每个工具能做什么,后半部分是宿主接入、预算与权限。 37 tools by default, 55 with device and build tools enabled. DitingAgent exposes these tools to the host. The first half covers each tool; the second covers host setup, budgets, and permissions.
会话与报告工具Session and report tools
这 6 个工具构成一次分析的生命周期。Trace 只转换一次,后续 run 复用会话中的数据库、能力和 EvidenceStore。These six tools make up the analysis lifecycle. A trace is converted once; later runs reuse the database, capabilities, and evidence store in the session.
purge_workspace=true 时删除转换工作区。Close the session; purge_workspace=true removes the conversion workspace.长操作Long operations
3 个工具管理构建、抓取和安装长任务。任务在后台保留状态和 Evidence,不阻塞 Agent 主循环;可以查询、请求取消并读取产物。Three tools manage long build, capture, and install jobs. Jobs keep state and evidence in the background without blocking the agent loop, and can be inspected, cancelled, or read afterwards.
Trace 取证工具Trace inspection tools
16 个只读工具。调用时会检查当前 Trace 的能力、预算和输入契约;能力不足返回 CAPABILITY_MISSING。Sixteen read-only tools. Each call checks trace capability, budget, and input contract; missing support returns CAPABILITY_MISSING.
概览与边界Overview and boundaries
进程、CPU、内存与 IOProcesses, CPU, memory, and IO
冷启动Cold start
响应与完成Response and completion
帧、线程与 PerfFrames, threads, and Perf
工具返回确定性的摘要和 Evidence ID。超过内联预算时,完整数据保留在会话中,用 get_evidence 按路径和分页读取。Tools return deterministic summaries and Evidence IDs. Above the inline budget, the full payload stays in the session and is paged through get_evidence.
证据检索
与 bundleEvidence and
bundles
读取会话中的 Evidence;用 bundle 导出、合并和比较跨会话的证据快照。Read evidence in the session; use bundles to export, merge, and compare evidence snapshots across sessions.
设备、构建
与环境(opt-in)Device, build
and environment (opt-in)
这 18 个工具只在启动 server 时带 --enable-device 才会出现。构建、签名和安装工具完成代码到设备的闭环;设备与抓取工具会真实操作设备;应用包与 native 库工具读取本地文件。它们不在 Trace evidence 预算内。These eighteen tools appear only when the server starts with --enable-device. Build, signing, and install tools close the loop from code to device; device and capture tools operate the device; app-package and native-library tools read local files. They sit outside the trace-evidence budget.
uitest dumpLayout 控件树,返回文本、类型、bounds 和 center。Capture a screenshot and parse the uitest dumpLayout control tree, returning text, type, bounds, and center./data/local/tmp/ 拉取 Trace、截图或日志,返回本地路径、大小和 SHA-256。Pull traces, screenshots, or logs from /data/local/tmp/ over hdc, returning the local path, size, and SHA-256.confirm=true 时把 Command Line Tools 安装到 ~/.diting/tools 并注册 hdc;URL 安装必须提供 SHA-256。With confirm=true, install Command Line Tools into ~/.diting/tools and register hdc. URL installs require a SHA-256.APP_PATH_DENIED。Try to pull a .so from app libs or a readable HAP; insufficient access returns APP_PATH_DENIED.libs/**/*.so,返回本地路径和 SHA-256。Extract libs/**/*.so from a local HAP/HSP/ZIP, returning local paths and SHA-256.module.json5/app.json5 或设备 bm dump 读取 Bundle、module、Ability 和 launcher ability。Read bundle, module, abilities, and the launcher ability from local module.json5/app.json5 or device bm dump.aa force-stop + bm clean 清除应用 data/cache,可分别控制。Clear app data/cache through aa force-stop + bm clean, with separate controls.hap-sign-tool 对 HAP/HSP 做 localSign,可选 verify-app;密码不回显。Use hap-sign-tool to localSign a HAP/HSP with optional verify-app; passwords are never echoed.hvigorw assembleHap 构建 HarmonyOS 工程并返回 HAP 产物。Build a HarmonyOS project with hvigorw assembleHap and return the HAP artifact.hvigorw assembleApp 打包 App Pack 并返回 .app 产物。Package an App Pack with hvigorw assembleApp and return the .app artifact.hdc install 安装本地 .hap/.hsp/.app。Install a local .hap/.hsp/.app through hdc install.hdc uninstall 卸载应用,可选择保留数据。Uninstall an app through hdc uninstall, optionally keeping its data.构建与设备工具需要 hdc、Command Line Tools 和 HarmonyOS 工程;签名还需要 keystore、证书和 profile。开启前先看 安装页的设备与构建步骤;完整参数和错误码见 权限边界。Build and device tools need hdc, Command Line Tools, and a HarmonyOS project; signing also needs a keystore, certificate, and profile. See the device and build setup steps before enabling them; see integration boundaries for configuration and error codes.
未知与 handoffUnknowns and handoff
把未解决的问题留下,把一次会话的状态带走;恢复时仍以 Evidence 和 revision 为准。Leave unresolved questions behind and carry a session state forward; restoration still follows evidence and revisions.
接入宿主 Connect a host
需要 Node.js 18+ 和 Python 3.12+;npx 首次运行会准备环境。先检测宿主,再写入配置并运行健康检查。
Node.js 18+ and Python 3.12+ are required; the first npx run prepares the environment. Detect the host, write its config, then run the health check.
# 1. detect the host
npx diting-agents@latest setup --detect
# 2. register and verify
npx diting-agents@latest setup --client dsh --yes --allow-root ~/traces
npx diting-agents@latest doctor
# 3. or run the stdio server manually
npx diting-agents@latest mcp \
--workspace .diting/sessions \
--allow-root ~/traces
其他宿主可以用 setup --client generic 打印通用 JSON;Windows、macOS 和 Linux 使用同一条 npx 命令。
For other hosts, setup --client generic prints a JSON configuration. Windows, macOS, and Linux use the same npx command.
完整安装与接入步骤Full installation and setup
会话复用与转换缓存 Session reuse and conversion cache
缓存与复用Caching and reuse
同一个会话内,转换后的只读 DB、能力声明和 EvidenceStore 跨 run 复用。未调用 begin_analysis 时,每次工具调用使用独立的 run 级预算;开始分析后,预算和 seal 在整次分析内共享。
Within one session, the read-only database, capability declaration, and evidence store are reused across runs. Before begin_analysis, each tool call gets an independent run-scoped budget; during analysis, budget and seal are shared across the whole analysis.
会话 TTL 与容量Session TTL and capacity
默认空闲 TTL 为 1440 分钟,最多保留 8 个会话;close_trace(purge_workspace=true) 立即删除转换工作区。历史目录可以用 diting-agent clean 清理。
Default idle TTL is 1440 minutes with a maximum of 8 sessions. close_trace(purge_workspace=true) removes the conversion workspace immediately; historical directories can be cleaned with diting-agent clean.
结果预算与 Evidence Result budgets and evidence
单次结果超过 --max-result-bytes(默认 64 KB)时,宿主只拿到摘要、字节数和 Evidence ID。完整数据仍在会话中,可以用点路径、offset 和 limit 分页读取。
When a result exceeds --max-result-bytes (64 KB by default), the host receives a summary, byte count, and Evidence ID. The complete payload remains in-session and can be paged by dot path, offset, and limit.
{
"evidence_id": "ev-0007",
"summary": "4 frame clusters, 17 slow frames",
"data_bytes": 18342,
"full_evidence_persisted": true,
"read_with": "get_evidence"
}
get_evidence(
evidence_id="ev-0007",
path="clusters",
offset=0,
limit=50
)
设备、构建与权限边界 Device, build, and permissions
DitingAgent 继承启动用户的文件权限,没有额外沙箱。设备与构建工具默认关闭;一旦开启,它们会真实操作设备、构建工程或写入签名产物。 DitingAgent inherits the launching user’s file permissions and has no extra sandbox. Device and build tools are off by default; once enabled, they really operate the device, build projects, or write signing artifacts.
--allow-root 指定 Trace 目录。In production, point --allow-root at the trace directory at minimum.
act 会真的 tap / swipe;pull_artifact 会读取设备文件。act really taps and swipes; pull_artifact reads device files.
install_environment 只有 confirm=true 才解压写入,URL 必须带 SHA-256。install_environment only writes with confirm=true; URL installs require a SHA-256.
close_trace(purge_workspace=true),或按 TTL / 容量自动淘汰。Use close_trace(purge_workspace=true), or let TTL and capacity evict sessions.
宿主拥有 Agent 循环、模型选择和用户审批;DitingAgent 拥有 Trace 转换、取证、Evidence、校验和报告。设备与构建工具始终需要显式开启。 The host owns the agent loop, model choice, and user approvals. DitingAgent owns build/sign/install execution, trace conversion, inspection, evidence, validation, and reporting. Device and build tools always require an explicit opt-in.