agentworkshop 0.7.63 → 0.7.64

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentworkshop-prod",
3
- "version": "0.7.63",
3
+ "version": "0.7.64",
4
4
  "type": "module",
5
5
  "private": true,
6
6
  "dependencies": {
package/README-zh.md CHANGED
@@ -390,7 +390,7 @@ aw update --check # 只报告,不安装
390
390
  npm install -g agentworkshop@latest # 手动等效
391
391
  ```
392
392
 
393
- 版本遵循 semver。每次 `aw start` 都会校验配置根,并把 `home` 之前的旧版 `data/` 布局迁移进来(以最新文件为准),因此数据可以跨版本存活。SQLite schema 迁移在服务端启动时执行。当前版本:**v0.7.63**——见[版本发布](https://github.com/kingdol666/AgentWorkShop/releases)。
393
+ 版本遵循 semver。每次 `aw start` 都会校验配置根,并把 `home` 之前的旧版 `data/` 布局迁移进来(以最新文件为准),因此数据可以跨版本存活。SQLite schema 迁移在服务端启动时执行。当前版本:**v0.7.64**——见[版本发布](https://github.com/kingdol666/AgentWorkShop/releases)。
394
394
 
395
395
  ### 第一次「Agent × 产线」会话(约 2 分钟)
396
396
 
package/README.md CHANGED
@@ -381,7 +381,7 @@ aw update --check # only report; nothing is installed
381
381
  npm install -g agentworkshop@latest # manual equivalent
382
382
  ```
383
383
 
384
- Releases follow semver. `aw start` verifies the config root on every launch and migrates the legacy pre-`home` `data/` layout into it (newest file wins), so data survives upgrades. SQLite schema migrations run server-side at boot. Current version: **v0.7.63** — see [Releases](https://github.com/kingdol666/AgentWorkShop/releases).
384
+ Releases follow semver. `aw start` verifies the config root on every launch and migrates the legacy pre-`home` `data/` layout into it (newest file wins), so data survives upgrades. SQLite schema migrations run server-side at boot. Current version: **v0.7.64** — see [Releases](https://github.com/kingdol666/AgentWorkShop/releases).
385
385
 
386
386
  ### Your first agent × line session (~2 minutes)
387
387
 
package/config.yml CHANGED
@@ -12,7 +12,7 @@
12
12
  app:
13
13
  name: AgentWorkShop
14
14
  title: AgentWorkShop
15
- version: 0.7.63
15
+ version: 0.7.64
16
16
  description: 基于 Nuxt 4 的配置驱动运行范式
17
17
 
18
18
  # 运行模式(dev/prod 实际由启动命令决定,此处仅作运行时展示)
package/docs/cli.en.md CHANGED
@@ -62,7 +62,7 @@ pnpm tui # the terminal workbench
62
62
  ### 3. Quick use via npx (no global install)
63
63
 
64
64
  ```bash
65
- npx agentworkshop start # fetch and start (pin a version with: npx agentworkshop@0.7.63 start)
65
+ npx agentworkshop start # fetch and start (pin a version with: npx agentworkshop@0.7.64 start)
66
66
  npx agentworkshop doctor # subcommands work as usual
67
67
  npx -p agentworkshop aw doctor # use -p when you want the name aw
68
68
  ```
@@ -79,7 +79,7 @@ npx -p agentworkshop aw doctor # use -p when you want the name aw
79
79
  | Package manager | `pnpm@11.9.0` (`packageManager`, needed only for source development) |
80
80
  | Module format | ESM (`type: module`) |
81
81
  | License | `Apache-2.0` |
82
- | Current version | `0.7.63` (`package.json`) |
82
+ | Current version | `0.7.64` (`package.json`) |
83
83
 
84
84
  ## 2. First start (the Claude Code experience)
85
85
 
package/docs/cli.md CHANGED
@@ -60,7 +60,7 @@ pnpm tui # 终端工作台
60
60
  ### 3. npx 快速使用(免全局安装)
61
61
 
62
62
  ```bash
63
- npx agentworkshop start # 拉取并启动(可锁定版本: npx agentworkshop@0.7.63 start)
63
+ npx agentworkshop start # 拉取并启动(可锁定版本: npx agentworkshop@0.7.64 start)
64
64
  npx agentworkshop doctor # 子命令照常可用
65
65
  npx -p agentworkshop aw doctor # 需要 aw 这个名字时用 -p 指定包
66
66
  ```
@@ -76,7 +76,7 @@ npx -p agentworkshop aw doctor # 需要 aw 这个名字时用 -p 指定包
76
76
  | 包管理器 | `pnpm@11.9.0`(`packageManager`,仅源码开发需要) |
77
77
  | 模块形态 | ESM(`type: module`) |
78
78
  | 许可证 | `Apache-2.0` |
79
- | 当前版本 | `0.7.63`(`package.json`) |
79
+ | 当前版本 | `0.7.64`(`package.json`) |
80
80
 
81
81
  ## 二、首次启动(Claude Code 式)
82
82
 
@@ -1,6 +1,6 @@
1
1
  # AgentWorkShop 全功能测试流程 Plan
2
2
 
3
- > 版本无关的常备测试手册(撰写时基线 v0.7.62)。用途:后续直接指令 agent
3
+ > 版本无关的常备测试手册(撰写时基线 v0.7.63)。用途:后续直接指令 agent
4
4
  > 「按 docs/full-test-plan.md 执行 Phase 0–N」即可完成全功能测试。
5
5
  > 断言数为历史全绿基线(2026-09 上旬各轮验收),以脚本实际输出为准;括号内数字仅用于识别明显回退。
6
6
  > 最后核对:2026-09-12(脚本清单逐一经 `scripts/` 实存核对)。
@@ -9,7 +9,7 @@
9
9
  >
10
10
  > Applies to: plugin system v2 has been available since **v0.7.29** (frontend component
11
11
  > injection / plugin settings / plugin i18n / runtime services surface); this document
12
- > describes **v0.7.63**. `ctx.sdkVersion` is currently `0.3.0`.
12
+ > describes **v0.7.64**. `ctx.sdkVersion` is currently `0.3.0`.
13
13
 
14
14
  ## 1. Folder layout & quick start
15
15
 
package/docs/plugins.md CHANGED
@@ -6,7 +6,7 @@
6
6
  > 本文是唯一权威参考;`docs/site/plugins/` 的分页文档与本文同源。
7
7
  >
8
8
  > 适用版本:插件系统 v2 自 **v0.7.29** 起可用(前端组件注入 / 插件设置 / 插件 i18n /
9
- > 运行时服务面);本文档对应当前版本 **v0.7.63**。`ctx.sdkVersion` 当前为 `0.3.0`。
9
+ > 运行时服务面);本文档对应当前版本 **v0.7.64**。`ctx.sdkVersion` 当前为 `0.3.0`。
10
10
 
11
11
  ## 一、目录结构与快速开始
12
12
 
package/docs/sdk.en.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  **SDK version constants**: server-side `SDK_VERSION = '0.3.0'`, browser-side `CLIENT_SDK_VERSION = '0.3.0'`.
9
9
  These two constants are the **interface version of the SDK itself** and evolve **independently**
10
- from the npm package version (the `version` field in `package.json`, currently 0.7.63) —
10
+ from the npm package version (the `version` field in `package.json`, currently 0.7.64) —
11
11
  them being out of sync is expected. Never use `SDK_VERSION` to infer the package version, or the reverse.
12
12
  **Module format**: ESM only (only `import` / `export`; there is no CJS entry).
13
13
  **Types**: `sdk/index.d.mts` and `sdk/client.d.mts` ship with the package, so TypeScript projects
package/docs/sdk.md CHANGED
@@ -5,7 +5,7 @@
5
5
  > 零第三方运行时依赖,Node ≥ 23.4 与现代浏览器双端可用。
6
6
 
7
7
  **SDK 版本常量**:服务端 `SDK_VERSION = '0.3.0'`,浏览器端 `CLIENT_SDK_VERSION = '0.3.0'`。
8
- 这两个常量是 **SDK 自身接口的版本号**,与 npm 包版本(`package.json` 的 `version`,当前 0.7.63)
8
+ 这两个常量是 **SDK 自身接口的版本号**,与 npm 包版本(`package.json` 的 `version`,当前 0.7.64)
9
9
  **各自独立演进** —— 常数不同步是预期行为,不要拿 `SDK_VERSION` 去推断包版本,反之亦然。
10
10
  **模块形态**:ESM only(只有 `import` / `export`,没有 CJS 入口)。
11
11
  **类型**:`sdk/index.d.mts`、`sdk/client.d.mts` 随包发布,TS 项目零配置获得提示(覆盖范围见 §7)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentworkshop",
3
- "version": "0.7.63",
3
+ "version": "0.7.64",
4
4
  "type": "module",
5
5
  "description": "AgentWorkShop 软件开发系统 - 基于 Nuxt 4 的配置驱动运行范式",
6
6
  "license": "Apache-2.0",
@@ -5,10 +5,15 @@
5
5
  import { baseOf, harnessOf, jpost, maxMinutesOf, maxTurnsOf, runKey, runningOfLine, short } from './helpers.mjs'
6
6
  import { snapshotCore } from './snapshot.mjs'
7
7
  import { startingLines } from './constants.mjs'
8
+ import { defaultQuestionFor, resolveBridgeIntent } from './intents.mjs'
8
9
 
9
- export async function startDiagnosis(ctx, { line, fromMs, toMs, question, scene, source, dataPath, dataPaths, harness, agentId, channelId, analysisIntent }) {
10
+ export async function startDiagnosis(ctx, { line, fromMs, toMs, question, scene, source, dataPath, dataPaths, harness, agentId, channelId, analysisIntent, model, permissionMode }) {
10
11
  const base = baseOf(ctx)
11
12
  if (!base) return { ok: false, error: 'diag.base_url 非法(仅允许 http/https 且 host 为 127.0.0.1/localhost)。' }
13
+ const intent = resolveBridgeIntent(analysisIntent)
14
+ if (analysisIntent && String(analysisIntent).trim() && !intent) {
15
+ return { ok: false, error: `未知分析意图: ${String(analysisIntent)}(支持 deep-diagnosis/stability-report/quick-screen/doe-analysis/experience-mining/optimizer-campaign)` }
16
+ }
12
17
  if (startingLines.has(line)) return { ok: false, error: `产线 ${line} 已有诊断正在启动,请稍后再试。` }
13
18
  const existing = runningOfLine(ctx, line)
14
19
  if (existing) return { ok: false, error: `产线 ${line} 已有运行中的诊断(run_id=${existing.id}),请稍后用 diag_status 查询。` }
@@ -19,8 +24,8 @@ export async function startDiagnosis(ctx, { line, fromMs, toMs, question, scene,
19
24
  snap = await snapshotCore(ctx, line, fromMs, toMs)
20
25
  if (!snap.ok) return { ok: false, error: snap.error }
21
26
  }
22
- const intent = String(analysisIntent ?? '').trim()
23
- const q = question || (intent && intent !== 'deep-diagnosis' ? `${line} 产线该时窗数据分析(${intent})` : `${line} 产线该时窗数据深度根因诊断`)
27
+ // 按情景注入业务提示词:调用方显式 question 优先,否则用意图目录的模板(分析语义在此,执行解耦在 IDD)
28
+ const q = question || defaultQuestionFor(intent, { line, fromMs, toMs })
24
29
  const sceneName = scene || `${line}_diag`
25
30
  // v2.1:统一走 IDD 任务管理面 /api/diagnosis/tasks——接收即返 task_id,
26
31
  // 诊断在 IDD 后台线程执行(内部 start+execute),Channel 绝不等待。
@@ -33,7 +38,9 @@ export async function startDiagnosis(ctx, { line, fromMs, toMs, question, scene,
33
38
  sceneName,
34
39
  userQuestion: q,
35
40
  harness: harness || harnessOf(ctx), // 缺省落 claude 引擎会因无 key 失败,必须显式(系统配置 plugins.diag-bridge.harness → kv → omp;diag_run 可按次覆盖)
36
- ...(intent ? { analysisIntent: intent } : {}), // 分析意图透传(stability-report=产线稳定报告等;未知值由 IDD 400 拒,不做白名单硬编码)
41
+ ...(intent && intent !== 'deep-diagnosis' ? { analysisIntent: intent } : {}), // 分析意图透传(缺省意图不传,由 IDD 兜底)
42
+ ...(model ? { model: String(model) } : {}), // 引擎模型按次覆盖(合法性由 IDD validateEngineOption 校验,不合法 400)
43
+ ...(permissionMode ? { permissionMode: String(permissionMode) } : {}),
37
44
  enhancement: 'off',
38
45
  reportLanguage: 'zh',
39
46
  maxTurns: maxTurnsOf(ctx), // 修复循环会加转数;150 不够走完全管线
@@ -44,6 +51,7 @@ export async function startDiagnosis(ctx, { line, fromMs, toMs, question, scene,
44
51
  if (!runId) return { ok: false, error: `tasks 响应缺少 data.task_id: ${short(started)}` }
45
52
  ctx.kv.set(runKey(runId), {
46
53
  line, fromMs, toMs, question: q, scene: sceneName,
54
+ intent: intent || 'deep-diagnosis',
47
55
  status: 'running', createdAt: Date.now(), source,
48
56
  csvPath: snap.csvPath,
49
57
  files: Array.isArray(dataPaths) ? dataPaths.length : 0,
@@ -51,7 +59,7 @@ export async function startDiagnosis(ctx, { line, fromMs, toMs, question, scene,
51
59
  // 归因:发起 Agent 完成后的结果回执靠它寻址(平台通告面 deliver)
52
60
  agentId: agentId || '', channelId: channelId || '',
53
61
  })
54
- return { ok: true, runId, name, csvPath: snap.csvPath, rows: snap.rows, nodes: snap.nodes, files: Array.isArray(dataPaths) ? dataPaths.length : 0 }
62
+ return { ok: true, runId, name, csvPath: snap.csvPath, rows: snap.rows, nodes: snap.nodes, files: Array.isArray(dataPaths) ? dataPaths.length : 0, intent: intent || 'deep-diagnosis', question: q }
55
63
  }
56
64
  catch (err) {
57
65
  return { ok: false, error: `发起诊断失败: ${err?.message ?? err}` }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * 分析意图目录(diag-bridge 侧镜像)。
3
+ *
4
+ * ⚠️ 权威源在 IDD:`app/backend/src/engine/claude-client.mjs` 的 ANALYSIS_INTENTS
5
+ * (每个意图 = 一个 skill 协议,buildIntentDirective 生成绑定指令,由 IDD 的 harness 执行)。
6
+ * 本目录只是**调用面镜像**:给 diag_run 提供 enum 校验、中文标签与按情景的缺省提问模板
7
+ * (数据分析业务语义在此注入,执行完全解耦在 IDD)。IDD 对未知意图 400 拒绝,不会静默降级。
8
+ */
9
+
10
+ /** 各意图的缺省提问模板(按任务情景注入给 IDD harness 的业务提示词)。
11
+ * line=产线标识;win=可读时窗描述(缺省时可空)。 */
12
+ const QUESTION_TEMPLATES = {
13
+ 'deep-diagnosis': ({ line, win }) =>
14
+ `${line} 产线${win}数据深度根因诊断:定位异常根因,给出证据链与修复建议`,
15
+ 'stability-report': ({ line, win }) =>
16
+ `${line} 产线${win}运行稳定性报告:给出综合评分与等级、各参数稳态表现(均值/波动/趋势)、问题清单与运行建议;不需要根因分析`,
17
+ 'quick-screen': ({ line, win }) =>
18
+ `${line} 产线${win}数据快速筛查:识别越限/漂移/冻结/卡死等异常,按严重度给出关注点清单,产出筛查报告与 HTML 看板;不做深度根因分析`,
19
+ 'doe-analysis': ({ line, win }) =>
20
+ `${line} 产线${win}DOE 试验数据分析:识别因子与响应,给出因子效应、显著性判断与最优工况组合建议;若数据不含多因子试验结构,请在报告中明确说明数据局限`,
21
+ 'experience-mining': ({ line, win }) =>
22
+ `${line} 产线${win}数据调参经验挖掘:总结可复用的调整经验(参数方向、幅度、生效条件与反例),按结构化经验条目输出,供知识库沉淀`,
23
+ 'optimizer-campaign': ({ line, win }) =>
24
+ `${line} 产线${win}数据优化战役:基于数据确定优化目标与约束,执行寻优迭代并汇报每轮目标值变化,最终给出推荐工况与预期收益`,
25
+ }
26
+
27
+ /** 意图元数据(label 给审批卡/回执用;skill 仅供诊断对账,执行由 IDD 自主) */
28
+ export const ANALYSIS_INTENTS = {
29
+ 'deep-diagnosis': { label: '深度根因诊断', skill: 'industrial-analysis-auto', defaultPolicy: true },
30
+ 'stability-report': { label: '产线稳定报告', skill: 'industrial-line-stability-report' },
31
+ 'quick-screen': { label: '快速筛查', skill: 'industrial-sentinel' },
32
+ 'doe-analysis': { label: 'DOE 试验分析', skill: 'industrial-doe-analyzer' },
33
+ 'experience-mining': { label: '调参经验挖掘', skill: 'industrial-tuning-memory' },
34
+ 'optimizer-campaign': { label: '优化战役', skill: 'industrial-optimizer-loop' },
35
+ }
36
+
37
+ /** 归一化:空/未知 → null(空=缺省 deep-diagnosis 由 IDD 兜底;未知由调用方报错) */
38
+ export function resolveBridgeIntent(value) {
39
+ const v = String(value ?? '').trim()
40
+ if (!v) return 'deep-diagnosis'
41
+ return Object.prototype.hasOwnProperty.call(ANALYSIS_INTENTS, v) ? v : null
42
+ }
43
+
44
+ export function intentLabel(intent) {
45
+ return ANALYSIS_INTENTS[intent]?.label ?? intent
46
+ }
47
+
48
+ /** 按情景生成缺省提问(业务提示词注入点;caller 显式 question 优先) */
49
+ export function defaultQuestionFor(intent, { line, fromMs, toMs } = {}) {
50
+ const tpl = QUESTION_TEMPLATES[intent] ?? QUESTION_TEMPLATES['deep-diagnosis']
51
+ const win = fromMs && toMs && toMs > fromMs
52
+ ? `${new Date(fromMs).toISOString().slice(0, 16)} ~ ${new Date(toMs).toISOString().slice(0, 16)} 时窗`
53
+ : '该时窗'
54
+ return tpl({ line: line || 'offline-data', win })
55
+ }
56
+
57
+ /** diag_run 参数面的 enum 说明(工具描述用;一行一意图) */
58
+ export function intentCatalogText() {
59
+ return Object.entries(ANALYSIS_INTENTS)
60
+ .map(([id, m]) => `${id}=${m.label}`)
61
+ .join(';')
62
+ }
@@ -8,6 +8,7 @@ import { snapshotCore } from './snapshot.mjs'
8
8
  import { startDiagnosis } from './diagnosis.mjs'
9
9
  import { uploadExportDataset } from './exports.mjs'
10
10
  import { sweepOnce } from './sweep.mjs'
11
+ import { intentLabel } from './intents.mjs'
11
12
 
12
13
  export default {
13
14
  name: 'diag-bridge',
@@ -94,22 +95,28 @@ export default {
94
95
  // 工具 ×2
95
96
  ctx.omp.registerTool({
96
97
  name: 'diag_run',
97
- label: '深度诊断',
98
- description: '发起深度根因诊断(异步任务,提交即返 task_id,无需等待)。三种数据来源:① line+时间窗:导出产线 DAQ 快照 CSV;② data_path:诊断服务内已有数据文件;③ export_id(推荐):上传宿主工具 daq_export 导出的数据集(manifest 节点映射 + 全量原始时序多文件)。Channel 可继续其他任务;完成后平台自动把结果回执到本频道,空闲时也可 diag_status 查询;mode=sync 可同步等待完成。',
98
+ label: '发起分析',
99
+ description: '发起 IDD 后台分析任务(提交即返 task_id,无需等待;完成后平台自动回执本频道,空闲时也可 diag_status 查询)。analysis_intent 选择分析模式,每种意图由 IDD 侧对应 skill 协议执行(harness 在 IDD 内,分析业务与平台解耦):deep-diagnosis=深度根因诊断(9 阶段管线,最重);stability-report=产线稳定报告(评分+等级+建议,零根因);quick-screen=快速筛查(越限/漂移/冻结异常清单+HTML 看板,最快);doe-analysis=DOE 试验分析(因子效应/显著性/最优工况);experience-mining=调参经验挖掘(结构化经验条目,供知识库沉淀);optimizer-campaign=优化战役(寻优迭代+推荐工况,最重)。数据来源三选一:① line+时间窗(导出产线 DAQ 快照);② data_path:诊断服务内已有数据文件;③ export_id(推荐):daq_export 导出的数据集。',
99
100
  parameters: {
100
101
  type: 'object',
101
102
  properties: {
102
103
  line: { type: 'string', description: '产线 id(与 data_path/export_id 三选一;export/data_path 模式可填 any)' },
103
- export_id: { type: 'string', description: 'daq_export 返回的数据集 id(daqexp-…):上传 manifest+全部节点全量时序 CSV 做多文件深度分析' },
104
+ export_id: { type: 'string', description: 'daq_export 返回的数据集 id(daqexp-…):上传 manifest+全部节点全量时序 CSV 做多文件分析' },
104
105
  data_path: { type: 'string', description: '可选:诊断服务内数据文件相对路径(如 data/aw-snapshots/x.csv;跳过快照导出,适合离线数据分析)' },
105
106
  from_ms: { type: 'number', description: '窗口起点(epoch 毫秒;仅 line 模式;缺省 now-60min)' },
106
107
  to_ms: { type: 'number', description: '窗口终点(epoch 毫秒;仅 line 模式;缺省 now)' },
107
- question: { type: 'string', description: '诊断问题(缺省按数据来源自动组题;export 模式自动携带 manifest 场景备注)' },
108
- scene: { type: 'string', description: '场景名(缺省 <line>_diag);场景为自由标签,诊断管线按数据特征自适应' },
108
+ question: { type: 'string', description: '分析问题(缺省按意图自动生成情景化提示词;业务要求特殊时才覆写)' },
109
+ analysis_intent: {
110
+ type: 'string',
111
+ enum: ['deep-diagnosis', 'stability-report', 'quick-screen', 'doe-analysis', 'experience-mining', 'optimizer-campaign'],
112
+ description: '分析模式(缺省 deep-diagnosis)。按业务情景选择:要根因→deep-diagnosis;要运行健康度评分/等级→stability-report;要快速异常清单→quick-screen;要多因子试验数据→doe-analysis;要沉淀调参经验→experience-mining;要寻优推荐工况→optimizer-campaign',
113
+ },
114
+ scene: { type: 'string', description: '场景名(缺省 <line>_diag);场景为自由标签,分析管线按数据特征自适应' },
109
115
  mode: { type: 'string', enum: ['async', 'sync'], description: 'async(缺省)=提交即返后台跑;sync=同步等待完成(最长 sync_timeout_s,超时自动转后台继续)' },
110
116
  sync_timeout_s: { type: 'number', description: 'sync 模式等待上限秒(缺省 240,上限 540)' },
111
- harness: { type: 'string', description: '诊断引擎按次覆盖(omp/claude/mock;缺省用插件设置)' },
112
- analysis_intent: { type: 'string', description: '分析意图(可选):deep-diagnosis=深度根因诊断(缺省);stability-report=产线稳定报告(零根因分析,出分+等级+运行建议);quick-screen=快速筛查;doe-analysis=DOE 分析。非缺省意图由对应 skill 协议执行' },
117
+ harness: { type: 'string', description: '分析引擎按次覆盖(omp/claude/mock;缺省用插件设置)' },
118
+ model: { type: 'string', description: '可选:引擎模型按次覆盖(合法性由 IDD 校验,不合法返回 400 说明)' },
119
+ permission_mode: { type: 'string', description: '可选:引擎权限模式按次覆盖(合法性由 IDD 校验)' },
113
120
  },
114
121
  required: [],
115
122
  },
@@ -160,6 +167,8 @@ export default {
160
167
  dataPaths,
161
168
  harness: args.harness ? String(args.harness) : undefined,
162
169
  analysisIntent: args.analysis_intent ? String(args.analysis_intent) : undefined,
170
+ model: args.model ? String(args.model) : undefined,
171
+ permissionMode: args.permission_mode ? String(args.permission_mode) : undefined,
163
172
  // 归因(分发层注入的调用方上下文):诊断完成后平台据此把结果回执给发起 Agent
164
173
  agentId: agent?.agentId ?? '',
165
174
  channelId: agent?.channelId ?? '',
@@ -192,14 +201,14 @@ export default {
192
201
  return { text: `✅ 同步诊断完成 task_id=${r.runId}(${via})\n评分=${st?.result?.score ?? '-'} 结论=${st?.result?.verdict ?? '-'}\nreport_md_path=${rep}\n总结:${String(st?.result?.summary ?? '').slice(0, 800)}\n\n入库知识库:调用 rag-bridge 的 kb_agent(mode=async,prompt=「请把这份深度诊断报告入库到 aw-industrial 知识库:读取文件 ${rep} 的全文内容并入库,完成后报告 doc_path 与分块数。标签:诊断、深度诊断。」),完成后 kb_agent_status(task_id) 查询。` }
193
202
  }
194
203
  if (status === 'failed' || status === 'stopped') {
195
- return { text: `诊断 ${r.runId} 以 ${status} 结束:${st?.result?.error ?? '详见 diag_status'}`, isError: true }
204
+ return { text: `分析任务 ${r.runId} 以 ${status} 结束:${st?.result?.error ?? '详见 diag_status'}`, isError: true }
196
205
  }
197
206
  }
198
- return { text: `已发起深度诊断 task_id=${r.runId}(${via})。同步等待 ${timeoutS}s 超时,诊断仍在后台运行——完成后平台会自动把结果回执到你的信箱并唤醒你;也可 diag_status(run_id=${r.runId}) 主动查询。` }
207
+ return { text: `已发起${intentLabel(r.intent)}任务 task_id=${r.runId}(${via})。同步等待 ${timeoutS}s 超时,分析仍在后台运行——完成后平台会自动把结果回执到你的信箱并唤醒你;也可 diag_status(run_id=${r.runId}) 主动查询。注入的分析问题:${r.question}` }
199
208
  }
200
209
  }
201
210
  return {
202
- text: `已发起深度诊断异步任务 task_id=${r.runId}(${via})。知识库 IDD 在后台执行,Channel 无需等待——可继续其他任务;完成后平台会自动把结果回执到你的信箱并唤醒你(空闲时也可用 diag_status(run_id=${r.runId}) 主动查询;完成后按指引调 kb_agent 入库知识库)。`,
211
+ text: `已发起「${intentLabel(r.intent)}」异步分析任务 task_id=${r.runId}(${via})。IDD 在后台以对应 skill 协议执行,Channel 无需等待——可继续其他任务;完成后平台会自动把结果回执到你的信箱并唤醒你(空闲时也可用 diag_status(run_id=${r.runId}) 主动查询;完成后按指引调 kb_agent 把报告入库知识库)。注入的分析问题:${r.question}`,
203
212
  }
204
213
  }
205
214
  catch (err) {
@@ -210,8 +219,8 @@ export default {
210
219
 
211
220
  ctx.omp.registerTool({
212
221
  name: 'diag_status',
213
- label: '诊断状态',
214
- description: '查询深度诊断进度:传 run_id 看单条实时状态(完成时含评分/结论/报告路径),不传看最近 5 条概要。',
222
+ label: '分析任务状态',
223
+ description: '查询后台分析任务进度:传 run_id 看单条实时状态(完成时含评分/结论/总结/报告路径),不传看最近 5 条概要。适用 diag_run 发起的全部意图(深度诊断/产线报告/快速筛查/DOE/经验挖掘/优化战役)。',
215
224
  parameters: {
216
225
  type: 'object',
217
226
  properties: {
@@ -228,7 +237,7 @@ export default {
228
237
  .slice(0, 5)
229
238
  if (!runs.length) return { text: '暂无诊断记录。用 diag_run 发起一次深度诊断。' }
230
239
  const lines = runs.map(({ id: rid, meta }) =>
231
- `- ${rid} | ${meta.line} | ${meta.status}${meta.stored ? '(已入库)' : ''} | ${meta.source ?? 'agent'} | ${meta.createdAt ? new Date(meta.createdAt).toISOString() : '?'} | ${meta.question ?? ''}`)
240
+ `- ${rid} | ${meta.line} | [${intentLabel(meta.intent ?? 'deep-diagnosis')}] ${meta.status}${meta.stored ? '(已入库)' : ''} | ${meta.source ?? 'agent'} | ${meta.createdAt ? new Date(meta.createdAt).toISOString() : '?'} | ${meta.question ?? ''}`)
232
241
  return { text: `最近 ${runs.length} 条诊断:\n${lines.join('\n')}` }
233
242
  }
234
243
  const meta = ctx.kv.get(runKey(id))
@@ -245,6 +254,7 @@ export default {
245
254
  engineStatus: st.status,
246
255
  score: st.result.score ?? null,
247
256
  judge_verdict: st.result.verdict ?? null,
257
+ summary: st.result.summary ?? '',
248
258
  report_path: st.result.report_md_path ?? st.report_path ?? null,
249
259
  error_message: st.result.error ?? st.error_message ?? null,
250
260
  }
@@ -263,6 +273,7 @@ export default {
263
273
  `run_id=${id}`,
264
274
  `name=${st?.name ?? meta?.name ?? '?'}`,
265
275
  `产线=${meta?.line ?? st?.scene_name ?? '?'}`,
276
+ `意图=${meta?.intent ?? 'deep-diagnosis'}(${intentLabel(meta?.intent ?? 'deep-diagnosis')})`,
266
277
  `状态=${status}`,
267
278
  `来源=${meta?.source ?? '?'}`,
268
279
  ]
@@ -272,10 +283,11 @@ export default {
272
283
  const reportPath = st?.report_path ?? meta?.reportPath ?? '-'
273
284
  parts.push(`评分=${st?.score ?? meta?.score ?? '-'}`)
274
285
  parts.push(`结论=${st?.judge_verdict ?? meta?.verdict ?? '-'}`)
286
+ if (st?.summary) parts.push(`总结=${String(st.summary).slice(0, 600)}`)
275
287
  parts.push(`report_md_path=${reportPath}`)
276
288
  parts.push('')
277
- parts.push('✅ 诊断完成,报告已就绪。入库知识库请调用 rag-bridge 的 kb_agent 工具:')
278
- parts.push(` mode=async, prompt=「请把这份深度诊断报告入库到 aw-industrial 知识库:读取文件 ${reportPath} 的全文内容并入库(写盘+索引),完成后报告 doc_path 与分块数。标签:诊断、深度诊断。」`)
289
+ parts.push('✅ 分析完成,报告已就绪。入库知识库请调用 rag-bridge 的 kb_agent 工具:')
290
+ parts.push(` mode=async, prompt=「请把这份分析报告入库到 aw-industrial 知识库:读取文件 ${reportPath} 的全文内容并入库(写盘+索引),完成后报告 doc_path 与分块数。标签:分析、${intentLabel(meta?.intent ?? 'deep-diagnosis')}。」`)
279
291
  parts.push('提交后频道无需等待,空闲时用 kb_agent_status(task_id) 查询入库结果。')
280
292
  }
281
293
  if (status === 'failed' || status === 'stopped') parts.push(`错误=${st?.error_message ?? meta?.error ?? '-'}`)
@@ -3,6 +3,7 @@
3
3
  * (由 server/plugins-builtin/diag-bridge/index.mjs 按职责拆出;内容逐行原文搬运)
4
4
  */
5
5
  import { baseOf, jget, kvRuns, runKey } from './helpers.mjs'
6
+ import { intentLabel } from './intents.mjs'
6
7
 
7
8
  /** 平台通告面(异步结果回执):懒取,未接线/平台未就绪时 null(回执降级为日志,行为同旧版) */
8
9
  async function notifyOf(ctx) {
@@ -25,23 +26,29 @@ export async function sweepOnce(ctx) {
25
26
  const notify = await notifyOf(ctx)
26
27
  for (const { id, meta } of running) {
27
28
  try {
28
- const st = (await jget(ctx, `${base}/api/diagnosis/status/${encodeURIComponent(id)}`, 8000)).data ?? {}
29
- const status = st.engineStatus || st.status || meta.status
29
+ // v2.3:统一走任务管理面 /tasks/:id(与 diag_status 同源)——
30
+ // result.report_md_path 是绝对路径(kb_agent 可直接读),result.summary 是报告结论段;
31
+ // 旧 /status 的相对路径会让 kb_agent/Agent 找不到文件。
32
+ const st = (await jget(ctx, `${base}/api/diagnosis/tasks/${encodeURIComponent(id)}`, 8000)).data ?? {}
33
+ const status = st.status || st.run_status || meta.status
34
+ const intent = meta.intent ?? 'deep-diagnosis'
30
35
  if (status === 'completed') {
36
+ const result = st.result ?? {}
31
37
  ctx.kv.set(runKey(id), {
32
38
  ...meta,
33
39
  status: 'completed',
34
40
  completedAt: meta.completedAt ?? Date.now(),
35
41
  name: st.name ?? meta.name,
36
- score: st.score ?? null,
37
- verdict: st.judge_verdict ?? null,
38
- reportPath: st.report_path ?? null,
42
+ score: result.score ?? null,
43
+ verdict: result.verdict ?? null,
44
+ summary: result.summary ?? '',
45
+ reportPath: result.report_md_path ?? null,
39
46
  })
40
- ctx.logger.info(`诊断 ${id}(产线 ${meta.line})完成——待 Channel 空闲时 diag_status 查询,经 kb_agent 入库知识库`)
47
+ ctx.logger.info(`分析任务 ${id}[${intent}](产线 ${meta.line})完成——待 Channel 空闲时 diag_status 查询,经 kb_agent 入库知识库`)
41
48
  // 异步结果回执:发起 Agent 不必轮询,完成后平台投递信箱消息并即时唤醒;
42
49
  // claim 先到先得(Agent 已用 diag_status 看到则不再补送)
43
50
  if (meta.agentId) {
44
- const reportPath = st.report_path ?? null
51
+ const reportPath = result.report_md_path ?? null
45
52
  notify?.deliver({
46
53
  kind: 'tool-result',
47
54
  tool: 'diag_run',
@@ -49,13 +56,14 @@ export async function sweepOnce(ctx) {
49
56
  agentId: meta.agentId,
50
57
  ...(meta.channelId ? { channelId: meta.channelId } : {}),
51
58
  ok: true,
52
- title: `深度诊断完成(产线 ${meta.line})`,
59
+ title: `${intentLabel(intent)}完成(产线 ${meta.line})`,
53
60
  summary: [
54
- st.score != null ? `评分=${st.score}` : '',
55
- st.judge_verdict ? `结论=${st.judge_verdict}` : '',
61
+ result.score != null ? `评分=${result.score}` : '',
62
+ result.verdict ? `结论=${result.verdict}` : '',
63
+ result.summary ? `总结=${String(result.summary).slice(0, 400)}` : '',
56
64
  reportPath ? `report_md_path=${reportPath}` : '',
57
65
  reportPath
58
- ? '入库知识库:调用 rag-bridge 的 kb_agent(mode=async)读取该报告文件全文入库(标签:诊断、深度诊断),完成后用 kb_agent_status 查询入库结果。'
66
+ ? '入库知识库:调用 rag-bridge 的 kb_agent(mode=async)读取该报告文件全文入库(标签:分析,' + intentLabel(intent) + '),完成后用 kb_agent_status 查询入库结果。'
59
67
  : '报告路径未就绪,可用 diag_status(run_id=' + id + ') 查询详情。',
60
68
  ].filter(Boolean).join(';'),
61
69
  })
@@ -67,9 +75,9 @@ export async function sweepOnce(ctx) {
67
75
  status,
68
76
  completedAt: Date.now(),
69
77
  name: st.name ?? meta.name,
70
- error: st.error_message ?? null,
78
+ error: st.result?.error ?? null,
71
79
  })
72
- ctx.logger.warn(`诊断 ${id}(产线 ${meta.line})结束: ${status}${st.error_message ? `(${st.error_message})` : ''}`)
80
+ ctx.logger.warn(`分析任务 ${id}[${intent}](产线 ${meta.line})结束: ${status}${st.result?.error ? `(${st.result.error})` : ''}`)
73
81
  if (meta.agentId) {
74
82
  notify?.deliver({
75
83
  kind: 'tool-result',
@@ -78,10 +86,10 @@ export async function sweepOnce(ctx) {
78
86
  agentId: meta.agentId,
79
87
  ...(meta.channelId ? { channelId: meta.channelId } : {}),
80
88
  ok: false,
81
- title: `深度诊断${status === 'stopped' ? '已停止' : '失败'}(产线 ${meta.line})`,
82
- summary: st.error_message
83
- ? `原因:${st.error_message}`
84
- : `诊断以 ${status} 结束;可用 diag_status(run_id=${id}) 查询详情。`,
89
+ title: `${intentLabel(intent)}${status === 'stopped' ? '已停止' : '失败'}(产线 ${meta.line})`,
90
+ summary: st.result?.error
91
+ ? `原因:${st.result.error}`
92
+ : `任务以 ${status} 结束;可用 diag_status(run_id=${id}) 查询详情。`,
85
93
  })
86
94
  }
87
95
  }
@@ -90,7 +98,7 @@ export async function sweepOnce(ctx) {
90
98
  }
91
99
  }
92
100
  catch (err) {
93
- ctx.logger.warn(`轮询诊断 ${id} 失败(下轮继续): ${err?.message ?? err}`)
101
+ ctx.logger.warn(`轮询分析任务 ${id} 失败(下轮继续): ${err?.message ?? err}`)
94
102
  }
95
103
  }
96
104
  }
@@ -1 +0,0 @@
1
- {"id":"3097fe87-dd0d-4037-b7bb-ead0620af56b","timestamp":1792035633061,"prerendered":[]}