Skip to content

Commit 21a17ab

Browse files
Merge pull request #303 from modelstudioai/fix/telemetry-command-prefix
chore(release): prepare 2.8.2
2 parents e40504f + 30a07af commit 21a17ab

22 files changed

Lines changed: 177 additions & 31 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
66

77
[中文版](CHANGELOG.zh.md) · [README](README.md) · [Contributing](CONTRIBUTING.md)
88

9+
## [2.8.2] - 2026-11-04
10+
11+
### Internal
12+
13+
- Improve CLI usage statistics.
14+
915
## [2.8.1] - 2026-11-04
1016

1117
### Added

‎CHANGELOG.zh.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
[English](CHANGELOG.md) · [README](README.zh.md) · [参与贡献](CONTRIBUTING.zh.md)
88

9+
## [2.8.2] - 2026-11-04
10+
11+
### 内部维护
12+
13+
- 完善 CLI 使用统计。
14+
915
## [2.8.1] - 2026-11-04
1016

1117
### 新增

‎docs/agents/telemetry-change.md‎

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ source-config 只用于百炼 / DashScope API 侧消费,不发送到通用网
9595

9696
- `command`、`timestamp`、`durationMs`、`success`
9797
- `cliVersion`、`nodeVersion`、`os`
98+
- `commandPrefix`(调用入口,来自 `Identity`)
9899
- `authMethod`
99100
- `callerType`(必填:`agent` 或 `unknown`);`callerType=agent` 时可选 `callerName`、`skillName`、`skillVersion`
100101
- 失败时的 `errorMessage`、`exitCode`、`httpStatus`、`requestId`
@@ -119,20 +120,32 @@ source-config 只用于百炼 / DashScope API 侧消费,不发送到通用网
119120

120121
底层 Node tracker 还会附加公共设备字段:OS 类型/版本、Node 应用名与版本、平台,以及由本机网络标识计算的 MD5 `device_id`。
121122

122-
当前 AEM 事件没有 `binName` 或 `clientName` 产品维度,并且 `bl`、`kscli` 共用 `pid=bailian-cli-node`。两边相同路径的 `config show`、`config set`、`update` 无法仅凭当前事件稳定区分产品;Knowledge 命令虽然因路径映射不同而表现为 `knowledge chat` 与 `chat`,也不应把命令路径当作长期产品标识。后端 source-config 的 `t2` 已能区分 `bl/kscli`,但这个维度尚未进入 AEM 客户端事件。
123+
从 2.8.2 起,每条命令事件通过 `commandPrefix` 显式记录调用入口,三种入口仍共用 `pid=bailian-cli-node`:
124+
125+
| 调用入口 | `commandPrefix` |
126+
| ----------- | --------------- |
127+
| `bl` | `bl` |
128+
| `kscli` | `kscli` |
129+
| `aliyun bl` | `aliyun bl` |
130+
131+
`commandPrefix` 使用 `formatCommand(identity)` 从结构化的 `commandInvocation` 生成,未设置时回落到 `binName`。Aliyun 兼容入口由产品入口识别并注入 `Identity.commandInvocation = { bin: "aliyun", path: ["bl"] }`;telemetry 不读取环境变量或 argv 猜测来源,也不采用旧的显示覆盖字段。命令路径保持不变:如三种入口的 `config show` 仍以 `config show` 为事件名,按 `commandPrefix` 区分入口。调用方 `callerType` / `callerName` 是独立维度。
132+
133+
该字段同时进入本地 JSONL 与远端 AEM `ext`,成功与失败均携带。旧版本缺少入口字段的事件保留为入口未知,不能自动归为 `bl`,也不能靠命令路径可靠补回。后端 source-config 和 User-Agent 的既有口径不变。
134+
135+
`createTrackingEvent()` 必须传入 `identity`,统一从中读取 `cliVersion` 并生成 `commandPrefix`。`trackCommandExecution()` 传入产品 `Identity`,因此本版 CLI 命令事件始终包含 `commandPrefix`。
123136

124137
AEM 映射:
125138

126-
| AEM 字段 | 内容 |
127-
| ---------- | -------------------------------------------------------------------------------- |
128-
| event name | 命令路径 |
129-
| `et` | `EXP` |
130-
| `ext` | 除 `command`、`params` 外的结构化事件字段,含 `callerType` 与失败时的 `exitCode` |
131-
| `c1` | allowlist 参数 |
132-
| `c2` | `success` / `failure` |
133-
| `c3` | HTTP status |
134-
| `c4` | 错误文案,最多 500 字符 |
135-
| `c5` | request ID |
139+
| AEM 字段 | 内容 |
140+
| ---------- | ------------------------------------------------------------------------------------------------- |
141+
| event name | 命令路径 |
142+
| `et` | `EXP` |
143+
| `ext` | 除 `command`、`params` 外的结构化事件字段,含 `commandPrefix`、`callerType` 与失败时的 `exitCode` |
144+
| `c1` | allowlist 参数 |
145+
| `c2` | `success` / `failure` |
146+
| `c3` | HTTP status |
147+
| `c4` | 错误文案,最多 500 字符 |
148+
| `c5` | request ID |
136149

137150
远端发送是 best-effort,不得阻塞命令或改变退出码。正常退出最多等待 1 秒,SIGINT 最多等待 500 ms。
138151

@@ -159,6 +172,7 @@ AEM 映射:
159172

160173
- [ ] 更新 `TrackingEvent`、`createTrackingEvent()` 与 `buildRemoteAemOptions()` 的字段映射
161174
- [ ] 本地 JSONL 与远端 AEM 必须基于同一结构化事件,不能维护两套字段口径
175+
- [ ] 三种入口分别核对 `commandPrefix`;共享路径也必须可区分,旧数据缺字段保留为未知
162176
- [ ] 调用方字段经 `readCaller` → `TrackingDeps.caller` → 事件;仅显式 `agent` / `ai_agent` 为 `agent`,其余为 `unknown`
163177
- [ ] 成功与失败均覆盖;遥测异常必须静默且不改变业务退出码
164178
- [ ] runtime 本地语义错误应记录 `exitCode`;新增字段默认随 AEM `ext` 上报,无需占用新的 `c1`—`c5`

‎packages/bailian-kb-dsh/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bailian-kb-dsh",
3-
"version": "2.8.1",
3+
"version": "2.8.2",
44
"description": "Bailian knowledge-base tools for DeepSeek Harness: kb_search and kb_chat over the DashScope RAG API, plus the bl CLI management skill.",
55
"keywords": [
66
"alibaba-cloud",

‎packages/bailian-memo-dsh/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bailian-memo-dsh",
3-
"version": "2.8.1",
3+
"version": "2.8.2",
44
"description": "Bailian personal memory for DeepSeek Harness: automatic recall, silent curation, and user-controlled remember/forget.",
55
"keywords": [
66
"alibaba-cloud",

‎packages/cli/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bailian-cli",
3-
"version": "2.8.1",
3+
"version": "2.8.2",
44
"description": "CLI for Aliyun Model Studio (DashScope) AI Platform.",
55
"keywords": [
66
"agent",

‎packages/commands/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bailian-cli-commands",
3-
"version": "2.8.1",
3+
"version": "2.8.2",
44
"description": "Command library for bailian-cli products (knowledge, memory, media, …). See https://www.npmjs.com/package/bailian-cli for usage.",
55
"homepage": "https://bailian.console.aliyun.com/cli",
66
"bugs": {

‎packages/core/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bailian-cli-core",
3-
"version": "2.8.1",
3+
"version": "2.8.2",
44
"description": "Core SDK for bailian-cli. See https://www.npmjs.com/package/bailian-cli for usage.",
55
"homepage": "https://bailian.console.aliyun.com/cli",
66
"bugs": {

‎packages/core/src/telemetry/event.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { Identity } from "../config/schema.ts";
2+
import { formatCommand } from "../output/command.ts";
13
import type { AuthRequirement } from "../types/command.ts";
24
import type { CallerAttribution } from "./caller.ts";
35

@@ -11,6 +13,7 @@ export interface TrackingEvent {
1113
httpStatus?: number;
1214
requestId?: string;
1315
cliVersion: string;
16+
commandPrefix: string;
1417
nodeVersion: string;
1518
os: string;
1619
authMethod?: AuthRequirement;
@@ -27,7 +30,7 @@ export function createTrackingEvent(opts: {
2730
durationMs: number;
2831
success: boolean;
2932
error?: { message?: string; exitCode?: number; httpStatus?: number; requestId?: string };
30-
cliVersion: string;
33+
identity: Identity;
3134
authMethod?: AuthRequirement;
3235
params?: Record<string, unknown>;
3336
caller: CallerAttribution;
@@ -37,7 +40,8 @@ export function createTrackingEvent(opts: {
3740
timestamp: new Date().toISOString(),
3841
durationMs: opts.durationMs,
3942
success: opts.success,
40-
cliVersion: opts.cliVersion,
43+
cliVersion: opts.identity.version,
44+
commandPrefix: formatCommand(opts.identity),
4145
nodeVersion: process.version,
4246
os: process.platform,
4347
callerType: opts.caller.callerType,

‎packages/core/src/telemetry/tracker.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export async function trackCommandExecution(
133133
durationMs,
134134
success,
135135
error: success ? undefined : { message: errorMessage, exitCode, httpStatus, requestId },
136-
cliVersion: deps.identity.version,
136+
identity: deps.identity,
137137
authMethod: deps.authMethod,
138138
params: extractParams(flags),
139139
caller: deps.caller,

0 commit comments

Comments
 (0)